From e63c4537be9c157ac85c1c9d88df21eec5d4d535 Mon Sep 17 00:00:00 2001 From: hanyuqing <1106611654@qq.com> Date: Sat, 1 Nov 2025 18:23:38 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AF=BC=E5=85=A5=E6=96=87=E4=BB=B6=E5=A4=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ruoyi-ui/src/components/Editor/index.vue | 38 +++++++++++++++++++++--- ruoyi-ui/src/views/system/fileManage/indexNB.vue | 34 ++++++++++++++++++++- 2 files changed, 67 insertions(+), 5 deletions(-) diff --git a/ruoyi-ui/src/components/Editor/index.vue b/ruoyi-ui/src/components/Editor/index.vue index 2df00b9..39cf79e 100644 --- a/ruoyi-ui/src/components/Editor/index.vue +++ b/ruoyi-ui/src/components/Editor/index.vue @@ -30,7 +30,18 @@ export default { /* 编辑器的内容 */ value: { type: String, - default: "", + default: ` +
这是一个公式:
+ +这是普通段落。
+ ` }, /* 高度 */ height: { @@ -108,7 +119,8 @@ export default { if (val !== this.currentValue) { this.currentValue = val === null ? "" : val; if (this.Quill) { - this.Quill.pasteHTML(this.currentValue); + // this.Quill.pasteHTML(this.currentValue); + this.Quill.clipboard.dangerouslyPasteHTML(this.currentValue); } } }, @@ -117,6 +129,11 @@ export default { }, mounted() { this.init(); + this.$nextTick(() => { + setTimeout(() => { + this.renderMath(); + }, 500); + }); }, beforeDestroy() { this.Quill = null; @@ -125,6 +142,7 @@ export default { init() { const editor = this.$refs.editor; this.Quill = new Quill(editor, this.options); + console.log('Quill registered blots:', Quill.import('blots/bubble').blots); // 如果设置了上传地址则自定义图片上传事件 if (this.type == 'url') { let toolbar = this.Quill.getModule("toolbar"); @@ -136,7 +154,9 @@ export default { } }); } - this.Quill.pasteHTML(this.currentValue); + if (this.currentValue) { + this.Quill.clipboard.dangerouslyPasteHTML(0, this.currentValue); + } this.Quill.on("text-change", (delta, oldDelta, source) => { const html = this.$refs.editor.children[0].innerHTML; const text = this.Quill.getText(); @@ -191,7 +211,17 @@ export default { this.$message.error("图片插入失败"); } }, - + renderMath() { + if (window.MathJax && window.MathJax.typesetPromise) { + window.MathJax.typesetPromise() + .then(() => { + console.log('✅ MathML 公式已渲染'); + }) + .catch(err => { + console.error('❌ MathJax 渲染失败:', err); + }); + } + }, fileToBase64(file) { return new Promise((resolve, reject) => { // 创建一个新的 FileReader 对象 diff --git a/ruoyi-ui/src/views/system/fileManage/indexNB.vue b/ruoyi-ui/src/views/system/fileManage/indexNB.vue index 4673de8..4044796 100644 --- a/ruoyi-ui/src/views/system/fileManage/indexNB.vue +++ b/ruoyi-ui/src/views/system/fileManage/indexNB.vue @@ -723,7 +723,39 @@ export default { ); this.htmlContent = htmlContent; - this.TxtValue = this.htmlContent + this.TxtValue = ` +爱因斯坦质能方程:
+ +求根公式:
+ + ` this.loading = false; this.$nextTick(() => {