diff --git a/src/common/js/commonJS.js b/src/common/js/commonJS.js index 78e978b..570bffd 100644 --- a/src/common/js/commonJS.js +++ b/src/common/js/commonJS.js @@ -28,6 +28,7 @@ export default { var str = '' // 获取单元格的 HTML 内容 let htmlContent = cell.innerHTML.trim(); + console.log('htmlContent at line 30111:', htmlContent) str = this.transformHtmlString(htmlContent) // 创建一个临时的 DOM 元素来解析 HTML @@ -48,10 +49,14 @@ export default { str = capitalizeFirstLetter(str); // 添加蓝色标签 - const regex = /\[(\d+(?:–\d+)?(?:,\d+(?:–\d+)?)*)\]/g;; - if (regex.test(str)) { - str = `${str}`; - } + const regex = /\[(\d+(?:–\d+)?(?:,\d+(?:–\d+)?)*)\]/g; + +str = str.replace(//g, '').replace(/<\/blue>/g, ''); // 先去掉所有的 标签 + +if (regex.test(str)) { + str = str.replace(regex, `$&`); // 然后再进行替换 +} + // 如果没有 标签,直接返回原始 HTML 内容 return str; }, @@ -278,11 +283,15 @@ export default { formattedText = capitalizeFirstLetter(formattedText); // 添加蓝色标签 - const regex = /\[\d+(?:,\d+)*\]/g; - if (regex.test(formattedText)) { - formattedText = `${formattedText}`; - } + + const regex = /\[(\d+(?:–\d+)?(?:,\d+(?:–\d+)?)*)\]/g; + formattedText = formattedText.replace(//g, '').replace(/<\/blue>/g, ''); // 先去掉所有的 标签 + + if (regex.test(formattedText)) { + formattedText = formattedText.replace(regex, `$&`); // 然后再进行替换 + } + paragraphText += formattedText; } @@ -330,11 +339,12 @@ export default { } }, transformHtmlString(inputHtml) { + console.log('inputHtml at line 332:', inputHtml) inputHtml = inputHtml.replace(/(<[^>]+) style="[^"]*"/g, '$1'); // 移除style属性 inputHtml = inputHtml.replace(/(<[^>]+) class="[^"]*"/g, '$1'); // 移除class属性 // 2. 删除所有不需要的标签 (除 `strong`, `em`, `sub`, `sup`, `b`, `i` 外的所有标签) - inputHtml = inputHtml.replace(/<(?!\/?(strong|em|sub|sup|b|i))[^>]+>/g, ''); // 删除不需要的标签 + inputHtml = inputHtml.replace(/<(?!\/?(strong|em|sub|sup|b|i|blue))[^>]+>/g, ''); // 删除不需要的标签 // 3. 如果有 `` 和 `` 标签,去掉内部样式并保留内容 inputHtml = inputHtml.replace(/]*>/g, '').replace(/<\/span>/g, ''); // 去除span标签 @@ -1480,6 +1490,7 @@ export default { ed.setContent(''); } }); + ed.ui.registry.addButton('customBlue', { text: 'Blue', // 按钮文本 diff --git a/src/components/page/GenerateCharts.vue b/src/components/page/GenerateCharts.vue index f2e9f47..5f445c6 100644 --- a/src/components/page/GenerateCharts.vue +++ b/src/components/page/GenerateCharts.vue @@ -496,19 +496,15 @@ export default { }, async getContent(type, content) { + console.log('content at line 498:', content) if (type == 'content') { - // 使用正则表达式移除所有不允许的标签 - // 1. 移除不允许的标签 + content = content.replace(/<(?!\/?(img|b|i|sub|sup|span|strong|em |blue)\b)[^>]+>/g, ''); - // 2. 移除所有 style 属性 content = content.replace(/\s*style="[^"]*"/g, ''); - // 3. 将 转换为 转换为 - var div = document.createElement('div'); div.innerHTML = content; // 将 HTML 字符串加载到 div 中 - // 替换所有 var strongTags = div.getElementsByTagName('strong'); for (var i = 0; i < strongTags.length; i++) { @@ -516,7 +512,6 @@ export default { bTag.innerHTML = strongTags[i].innerHTML; // 保留内容 strongTags[i].parentNode.replaceChild(bTag, strongTags[i]); } - // 替换所有 var emTags = div.getElementsByTagName('em'); for (var i = 0; i < emTags.length; i++) { @@ -529,14 +524,6 @@ export default { content = div.innerHTML; console.log('content at line 486:', content); - // // 4. 去除多余的空格:替换连续的空格、换行符、制表符等 - // content = content.replace(/\s+/g, ' ').trim(); // 将多个空白字符替换为一个空格,并去除前后空白 - - // // 5. 去除标签之间的空格 - // content = content.replace(/>\s+<'); // 去除标签之间的空格 - - // 6. 如果需要,还可以去除 标签内部的空格 - // content = content.replace(/]*>\s*([^<]+)\s*<\/span>/g, '$1'); // 清理 标签内部的空格 this.saveContent(content, this.currentContent.am_id); } else if (type == 'table') { @@ -544,6 +531,30 @@ export default { } else if (type == 'comment') { this.addComment(content); } + }, + async saveContent(content, am_id) { + + var that = this; + var str = content.replace(/^

(.*?)<\/p>$/, '$1') ? content.replace(/^

(.*?)<\/p>$/, '$1') : ''; + if (str == '') { + this.$message({ + type: 'warning', + message: 'Please enter the content!' + }); + } + str= await that.$commonJS.decodeHtml(str) + await that.$api + .post(that.urlList.editContent, { + am_id: am_id, + content: str + }) + .then(async (res) => { + if (res.code == 0) { + this.editVisible = false; + this.getDate(); + this.getCommentList(); + } + }); }, deleteComment(comment, index) { console.log('comment at line 480:', comment); @@ -571,28 +582,7 @@ export default { .catch(() => {}); } }, - async saveContent(content, am_id) { - var that = this; - var str = content.replace(/^

(.*?)<\/p>$/, '$1') ? content.replace(/^

(.*?)<\/p>$/, '$1') : ''; - if (str == '') { - this.$message({ - type: 'warning', - message: 'Please enter the content!' - }); - } - await that.$api - .post(that.urlList.editContent, { - am_id: am_id, - content: str - }) - .then(async (res) => { - if (res.code == 0) { - this.editVisible = false; - this.getDate(); - this.getCommentList(); - } - }); - }, + async huifu(id) { var that = this; await this.$confirm(this.$t('commonTable.reContent'), 'Prompt', { @@ -972,6 +962,7 @@ export default { } }, updateChange(content, type) { + console.log('content at line 976:', content) var str = this.$commonJS.transformHtmlString(content); if (type == 'imgNote') { this.picStyle.note = str; @@ -1014,7 +1005,9 @@ export default { this.lineStyle.visiTitle = 'Edit Table'; this.threeVisible = true; } else { + data.content = data.content.replace(/]*>/g, '').replace(/<\/span>/g, ''); // 去除span标签 this.currentContent = data; + this.editVisible = true; this.currentId = dataId; } @@ -1337,15 +1330,16 @@ export default { }, // 确定保存图片 - savePic() { + async savePic() { this.picStyle.picUrl; - + var str=this.picStyle.note + str= await this.$commonJS.decodeHtml(str) if (this.picStyle.visiTitle == 'Edit Figure') { this.$api .post(this.urlList.editImage, { ami_id: this.picStyle.ami_id, url: this.picStyle.picUrl, - note: this.picStyle.note + note:str }) .then((res) => { if (res.code == 0) { @@ -1397,9 +1391,16 @@ export default { this.$refs.tinymceChildComment.getContent('comment'); }); }, - saveTable(content) { + async saveTable(content) { console.log('content at line 998:', content); - + var strTitle=this.lineStyle.title + strTitle= await this.$commonJS.decodeHtml(strTitle) + + var strNote=this.lineStyle.note + if(strNote!=''){ + strNote= await this.$commonJS.decodeHtml(strNote) + } + if (content && content.table && content.table.length > 0) { if (this.lineStyle.visiTitle == 'Edit Table') { this.$api @@ -1407,8 +1408,8 @@ export default { amt_id: this.lineStyle.amt_id, table_data: JSON.stringify(content.table), html_data: content.html_data, - note: this.lineStyle.note, - title: this.lineStyle.title + note: strNote, + title: strTitle }) .then((res) => { if (res.code == 0) { diff --git a/src/components/page/articleListEditor_E.vue b/src/components/page/articleListEditor_E.vue index da658d1..63a599f 100644 --- a/src/components/page/articleListEditor_E.vue +++ b/src/components/page/articleListEditor_E.vue @@ -1149,6 +1149,7 @@ export default { }, // 文章html弹出层 async htmlContet(e) { + console.log('e at line 1151:', e) this.htmlContent='' this.articleId = e.article_id; this.tg_article_id = e.tg_article_id; diff --git a/src/components/page/components/Tinymce/index.vue b/src/components/page/components/Tinymce/index.vue index b820fcf..9ef796e 100644 --- a/src/components/page/components/Tinymce/index.vue +++ b/src/components/page/components/Tinymce/index.vue @@ -421,7 +421,8 @@ export default { if (_this.isAutomaticUpdate) { - _this.$emit('updateChange', _this.$commonJS.decodeHtml(currentContent)); + // _this.$emit('updateChange', _this.$commonJS.decodeHtml(currentContent)); + _this.$emit('updateChange',currentContent); } }); @@ -510,13 +511,14 @@ export default { //获取内容 async getContent(type) { var content = window.tinymce.get(this.tinymceId).getContent(); - content= await this.$commonJS.decodeHtml(content) + content = content.replace(/]*>/g, '').replace(/<\/span>/g, ''); // 去除span标签 + console.log('content at line 513:', content) content = content.replace(//g, '').replace(/<\/strong>/g, ''); content = content.replace(//g, '').replace(/<\/em>/g, ''); content = content.replace(/ /g, ' '); // 将所有   替换为空格 - this.$emit('getContent', type, content); - console.log('window.tinymce.get(this.tinymceId).getContent() at line 431:', content); + this.$emit('getContent', type, content); + }, async export(type, data) {