-
-
-
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