diff --git a/package.json b/package.json index 6d7f01f..358bd98 100644 --- a/package.json +++ b/package.json @@ -24,6 +24,7 @@ "install": "^0.13.0", "jszip": "^3.10.1", "mammoth": "^1.5.1", + "mathlive": "^0.104.0", "mavon-editor": "^2.6.17", "multi-items-input": "^0.2.0", "pizzip": "^3.1.7", diff --git a/src/common/js/commonJS.js b/src/common/js/commonJS.js index fa2ce15..fc20718 100644 --- a/src/common/js/commonJS.js +++ b/src/common/js/commonJS.js @@ -360,10 +360,11 @@ export default { const breaks = paragraph.getElementsByTagName("w:br"); for (const br of breaks) { - paragraphText += "
"; + paragraphText += "
"; } cellText += paragraphText; + console.log('cellText at line 366:', cellText) } rowArray.push({ @@ -644,33 +645,39 @@ export default { let tempDiv = document.createElement('div'); tempDiv.innerHTML = content; // 解析 HTML 内容 let paragraphs = tempDiv.querySelectorAll("p"); // 选取所有

作为数据项 - - // 2️⃣ 将

内容转换为数组,处理空标签对 + + // 2️⃣ 将

内容转换为数组,并处理内容 let parsedData = Array.from(paragraphs).map(p => { let text = p.innerHTML.trim(); // 获取内容,去除两端空格 - - // 3️⃣ 移除 (Word 复制的无效标签) - text = text.replace(/<\/?o:p>/g, ""); - - // 4️⃣ 移除 style="..."(防止 Word 带入无用样式) - text = text.replace(/\s*style="[^"]*"/g, ""); - - // 5️⃣ 替换 - text = text.replace(//g, "").replace(/<\/strong>/g, ""); - - // 6️⃣ 替换 - text = text.replace(//g, "").replace(/<\/em>/g, ""); - - // 7️⃣ 处理空标签对: 等 - text = text.replace(/<[^>]+>\s*<\/[^>]+>/g, ""); - - // 8️⃣ 如果最终内容为空,则替换为 `""` + + // 3️⃣ **正确移除 (Word 复制的无效标签)** + text = text.replace(/<\/?o:p[^>]*>/g, ""); + + // 4️⃣ **移除所有 style="..."** + text = text.replace(/\s*style="[^"]*"/gi, ""); + + // 5️⃣ **修正标签替换** + text = text.replace(//gi, "").replace(/<\/strong>/gi, ""); + text = text.replace(//gi, "").replace(/<\/em>/gi, ""); + + // 6️⃣ **移除空的 span、b、i 标签** + text = text.replace(/\s*<\/span>/gi, ""); + text = text.replace(/\s*<\/b>/gi, ""); + text = text.replace(/\s*<\/i>/gi, ""); + + // 7️⃣ **确保不移除半个标签(修复匹配规则)** + text = text.replace(/<[^\/>]+>\s*<\/[^>]+>/gi, match => { + return match.trim() === "" ? "" : match; + }); + + // 8️⃣ **返回最终内容** return text.trim() === "" ? "" : text; }); - + console.log(parsedData); // 输出数组,方便调试 return parsedData; } + , @@ -1825,6 +1832,22 @@ export default { } } }); + ed.ui.registry.addButton('LateX', { + text: 'LateX', // 按钮文本 + className: 'custom-button-blue', // 添加自定义类 + // shortcut: "Ctrl+J", + onAction: function () { + // 在选中的文本周围包裹 标签 + // var selectedText = ed.selection.getContent(); + // console.log('selectedText at line 529:', selectedText); + // if (selectedText) { + // var wrappedText = `${selectedText}`; + // ed.selection.setContent(wrappedText); + // } else { + // this.$message.error('请选择要添加蓝色的文本'); + // } + } + }); ed.ui.registry.addButton('myuppercase', { text: 'A', // 按钮文本 diff --git a/src/components/page/components/table/LateX.vue b/src/components/page/components/table/LateX.vue new file mode 100644 index 0000000..fdd317f --- /dev/null +++ b/src/components/page/components/table/LateX.vue @@ -0,0 +1,56 @@ + + + + + diff --git a/src/components/page/components/table/word.vue b/src/components/page/components/table/word.vue index fb03b3d..100ef93 100644 --- a/src/components/page/components/table/word.vue +++ b/src/components/page/components/table/word.vue @@ -65,6 +65,7 @@ Batch Add content + @@ -116,6 +117,8 @@ position: relative; " > + +