From d0d09f0c9c98d1eeee6e46ecabc1723af1805026 Mon Sep 17 00:00:00 2001 From: yutent Date: Tue, 10 Jan 2023 17:16:45 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E5=AF=8C=E6=96=87=E6=9C=AC?= =?UTF-8?q?=E7=BC=96=E8=BE=91=E5=99=A8=E5=92=8Cmd=E7=BC=96=E8=BE=91?= =?UTF-8?q?=E5=99=A8=E7=9A=84=E7=B2=98=E8=B4=B4=E4=BA=8B=E4=BB=B6=E9=80=BB?= =?UTF-8?q?=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 1 + .prettierrc.yaml | 2 +- package.json | 2 +- src/editor/index.wc | 34 ++++++++++++++++++++++------------ src/meditor/index.wc | 21 +++++++++++---------- 5 files changed, 36 insertions(+), 24 deletions(-) diff --git a/.gitignore b/.gitignore index 16c1f4b..c626b0f 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,6 @@ *.min.js *.min.css +.httpserver index.html .vscode node_modules/ diff --git a/.prettierrc.yaml b/.prettierrc.yaml index c0e277f..b007fb1 100644 --- a/.prettierrc.yaml +++ b/.prettierrc.yaml @@ -2,7 +2,7 @@ jsxBracketSameLine: true jsxSingleQuote: true semi: false singleQuote: true -printWidth: 100 +printWidth: 80 useTabs: false tabWidth: 2 trailingComma: none diff --git a/package.json b/package.json index 2999118..a6a155e 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@bytedo/wcui", - "version": "1.0.6", + "version": "1.0.7", "type": "module", "description": "基于wc开发的一套UI库, 面向未来, 面向electron", "scripts": { diff --git a/src/editor/index.wc b/src/editor/index.wc index 9e7bc9e..63452f0 100644 --- a/src/editor/index.wc +++ b/src/editor/index.wc @@ -582,13 +582,33 @@ export default class Editor { var txt = ev.clipboardData.getData('text/plain') var items = ev.clipboardData.items + // 先文件判断, 避免右键单击复制图片时, 当成html处理 + if (items && items.length) { + let blob = null + for (let it of items) { + if (it.type.indexOf('image') > -1) { + blob = it.getAsFile() + } + } + + if (blob) { + return this._handleImage(blob) + } + } + if (html) { html = html .replace(/\t/g, ' ') .replace(/<\/?(meta|link|script)[^>]*?>/g, '') .replace(//g, '') - .replace(/]*? href\s?=\s?["']?([^"']*)["']?[^>]*?>/g, '') - .replace(/]*? src\s?=\s?["']?([^"']*)["']?[^>]*?>/g, '') + .replace( + /]*? href\s?=\s?["']?([^"']*)["']?[^>]*?>/g, + '' + ) + .replace( + /]*? src\s?=\s?["']?([^"']*)["']?[^>]*?>/g, + '' + ) .replace(/<(?!a|img)([\w\-]+)[^>]*>/g, '<$1>') .replace(/]*?>[\w\W]*?<\/xml>/g, '') .replace(/