diff --git a/packages/cw/cw_text_power_library/CHANGELOG.md b/packages/cw/cw_text_power_library/CHANGELOG.md new file mode 100644 index 00000000..f1a6322b --- /dev/null +++ b/packages/cw/cw_text_power_library/CHANGELOG.md @@ -0,0 +1,8 @@ +## 1.1.6 + +Associated Task: [#278603](https://projectmanage.netease-official.lcap.163yun.com/dashboard/TaskDetail?id=2786032954278656) + +### ✨Features + +- [60094da](https://github.com/vusion/cloud-ui-materials/commit/60094dad3f3ad4538558d691aa9331ef4a636b63) Thanks [ncqwer](https://github.com/ncqwer) ! - 现在粘贴base64格式的图片的时候会先把base64的图片先上传到指定服务器后在执行粘贴指令。 + diff --git a/packages/cw/cw_text_power_library/components/cw-wang-editor/docs/examples.md b/packages/cw/cw_text_power_library/components/cw-wang-editor/docs/examples.md index 07f396b3..c73a99ec 100644 --- a/packages/cw/cw_text_power_library/components/cw-wang-editor/docs/examples.md +++ b/packages/cw/cw_text_power_library/components/cw-wang-editor/docs/examples.md @@ -2,29 +2,77 @@ ```vue ``` @@ -33,9 +81,8 @@ export default { ```html + value="

hello

``` ### 只读模式 @@ -44,27 +91,26 @@ export default { ```vue ``` @@ -73,42 +119,40 @@ export default { ```vue ``` diff --git a/packages/cw/cw_text_power_library/components/cw-wang-editor/index.vue b/packages/cw/cw_text_power_library/components/cw-wang-editor/index.vue index fa9a4c20..0327ac98 100644 --- a/packages/cw/cw_text_power_library/components/cw-wang-editor/index.vue +++ b/packages/cw/cw_text_power_library/components/cw-wang-editor/index.vue @@ -1,328 +1,392 @@ diff --git a/packages/cw/cw_text_power_library/components/cw-wang-editor/processHTML.js b/packages/cw/cw_text_power_library/components/cw-wang-editor/processHTML.js new file mode 100644 index 00000000..dea88306 --- /dev/null +++ b/packages/cw/cw_text_power_library/components/cw-wang-editor/processHTML.js @@ -0,0 +1,27 @@ +export const traverseNode = (node, fn) => { + fn(node); + return Array.from(node.childNodes).forEach((n) => traverseNode(n, fn)); +}; + +export const processHTML = async (html, upload) => { + const domBody = new DOMParser().parseFromString(html, 'text/html').body; + const needUploadImgs = []; + traverseNode(domBody, (node) => { + if (node instanceof HTMLImageElement) { + const src = node.getAttribute('src'); + if (src.startsWith('data:image')) { + needUploadImgs.push({ + node, + src, + }); + } + } + }); + await Promise.all( + needUploadImgs.map(async ({ node, src }) => { + const realSrc = await upload(src); + node.setAttribute('src', realSrc); + }) + ); + return domBody; +}; diff --git a/packages/cw/cw_text_power_library/manifest b/packages/cw/cw_text_power_library/manifest index 9c159541..f65f642e 100644 --- a/packages/cw/cw_text_power_library/manifest +++ b/packages/cw/cw_text_power_library/manifest @@ -1,6 +1,6 @@ Plugin-Version: 1.0.0 Library-Type: Frontend Metadata-File: usage.json -packages/extension/cw_text_power_library@1.1.4/dist-theme/demo.html: dist-theme/demo.html -packages/extension/cw_text_power_library@1.1.4/dist-theme/index.js: dist-theme/index.js -packages/extension/cw_text_power_library@1.1.4/dist-theme/index.js.map: dist-theme/index.js.map +packages/extension/cw_text_power_library@1.1.6/dist-theme/demo.html: dist-theme/demo.html +packages/extension/cw_text_power_library@1.1.6/dist-theme/index.js: dist-theme/index.js +packages/extension/cw_text_power_library@1.1.6/dist-theme/index.js.map: dist-theme/index.js.map \ No newline at end of file diff --git a/packages/cw/cw_text_power_library/package.json b/packages/cw/cw_text_power_library/package.json index 819fcbdf..c52d7964 100644 --- a/packages/cw/cw_text_power_library/package.json +++ b/packages/cw/cw_text_power_library/package.json @@ -2,7 +2,7 @@ "name": "cw_text_power_library", "title": "文本功能依赖库", "description": "", - "version": "1.1.4", + "version": "1.1.6", "main": "./index.js", "author": "", "repository": "", @@ -56,4 +56,4 @@ "template": { "inited": true } -} +} \ No newline at end of file