提交
This commit is contained in:
@@ -18,6 +18,11 @@ const capitalizeFirstLetter = function (text) {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
export default {
|
export default {
|
||||||
|
decodeHtml(html) {
|
||||||
|
var txt = document.createElement('textarea');
|
||||||
|
txt.innerHTML = html;
|
||||||
|
return txt.value;
|
||||||
|
},
|
||||||
//去掉最外层自定义的span标签
|
//去掉最外层自定义的span标签
|
||||||
extractContentWithoutOuterSpan(cell) {
|
extractContentWithoutOuterSpan(cell) {
|
||||||
var str = ''
|
var str = ''
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="tinymce-container editor-container">
|
<div class="tinymce-container editor-container">
|
||||||
|
|
||||||
<textarea class="tinymce-textarea" :id="tinymceId"></textarea>
|
<textarea class="tinymce-textarea" :id="tinymceId"></textarea>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
@@ -138,9 +137,7 @@ export default {
|
|||||||
},
|
},
|
||||||
isEdit: {},
|
isEdit: {},
|
||||||
toolbar: {
|
toolbar: {
|
||||||
|
required: false
|
||||||
required: false,
|
|
||||||
|
|
||||||
},
|
},
|
||||||
menubar: {
|
menubar: {
|
||||||
default: 'file edit insert view format table '
|
default: 'file edit insert view format table '
|
||||||
@@ -269,10 +266,11 @@ export default {
|
|||||||
|
|
||||||
this.$forceUpdate();
|
this.$forceUpdate();
|
||||||
},
|
},
|
||||||
|
|
||||||
initTinymce() {
|
initTinymce() {
|
||||||
var _this = this;
|
var _this = this;
|
||||||
window.tinymce.init({
|
window.tinymce.init({
|
||||||
inline: false, // 使用 iframe 模式
|
inline: false, // 使用 iframe 模式
|
||||||
selector: `#${this.tinymceId}`,
|
selector: `#${this.tinymceId}`,
|
||||||
content_css: false, // 禁用默认样式
|
content_css: false, // 禁用默认样式
|
||||||
table_resize_bars: true, // 启用拖动调整功能
|
table_resize_bars: true, // 启用拖动调整功能
|
||||||
@@ -357,7 +355,8 @@ export default {
|
|||||||
statusbar: false, // 关闭底部状态栏
|
statusbar: false, // 关闭底部状态栏
|
||||||
custom_colors: false,
|
custom_colors: false,
|
||||||
color_map: ['0082AA', 'TMR Blue'],
|
color_map: ['0082AA', 'TMR Blue'],
|
||||||
plugins: 'forecolor code paste table image mathType searchreplace', // 启用 forecolor 和 code 插件
|
|
||||||
|
// plugins: 'forecolor code paste table image mathType searchreplace raw', // 启用 forecolor 和 code 插件
|
||||||
end_container_on_empty_block: true,
|
end_container_on_empty_block: true,
|
||||||
content_css: 'default', // 加载 TinyMCE 默认样式表
|
content_css: 'default', // 加载 TinyMCE 默认样式表
|
||||||
mathjax: {
|
mathjax: {
|
||||||
@@ -411,18 +410,18 @@ export default {
|
|||||||
// callback(menuItems);
|
// callback(menuItems);
|
||||||
// }
|
// }
|
||||||
// });
|
// });
|
||||||
|
|
||||||
ed.on('init', function () {
|
ed.on('init', function () {
|
||||||
_this.$commonJS.inTinymceButtonClass();
|
_this.$commonJS.inTinymceButtonClass();
|
||||||
const editorBody = ed.getBody();
|
const editorBody = ed.getBody();
|
||||||
// 创建 MutationObserver 监听内容变化
|
// 创建 MutationObserver 监听内容变化
|
||||||
const observer = new MutationObserver(() => {
|
const observer = new MutationObserver(() => {
|
||||||
const currentContent = ed.getContent();
|
const currentContent = ed.getContent();
|
||||||
|
|
||||||
|
|
||||||
if (_this.isAutomaticUpdate) {
|
if (_this.isAutomaticUpdate) {
|
||||||
_this.$emit('updateChange', ed.getContent());
|
|
||||||
|
|
||||||
|
_this.$emit('updateChange', _this.$commonJS.decodeHtml(currentContent));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -509,8 +508,10 @@ export default {
|
|||||||
window.tinymce.get(this.tinymceId).setContent(value);
|
window.tinymce.get(this.tinymceId).setContent(value);
|
||||||
},
|
},
|
||||||
//获取内容
|
//获取内容
|
||||||
getContent(type) {
|
async getContent(type) {
|
||||||
var content = window.tinymce.get(this.tinymceId).getContent();
|
var content = window.tinymce.get(this.tinymceId).getContent();
|
||||||
|
content= await this.$commonJS.decodeHtml(content)
|
||||||
|
console.log('content at line 513:', content)
|
||||||
content = content.replace(/<strong>/g, '<b>').replace(/<\/strong>/g, '</b>');
|
content = content.replace(/<strong>/g, '<b>').replace(/<\/strong>/g, '</b>');
|
||||||
content = content.replace(/<em>/g, '<i>').replace(/<\/em>/g, '</i>');
|
content = content.replace(/<em>/g, '<i>').replace(/<\/em>/g, '</i>');
|
||||||
content = content.replace(/ /g, ' '); // 将所有 替换为空格
|
content = content.replace(/ /g, ' '); // 将所有 替换为空格
|
||||||
|
|||||||
@@ -723,7 +723,7 @@ export default {
|
|||||||
table_resize_bars: true,
|
table_resize_bars: true,
|
||||||
image_advtab: false, // 禁用图片高级选项卡(防止自动调整大小)
|
image_advtab: false, // 禁用图片高级选项卡(防止自动调整大小)
|
||||||
valid_elements: '*[*]',
|
valid_elements: '*[*]',
|
||||||
|
entity_encoding: 'raw', // 不编码 > 等字符
|
||||||
plugins: 'forecolor code paste table image resize dragdrop',
|
plugins: 'forecolor code paste table image resize dragdrop',
|
||||||
|
|
||||||
menubar: false,
|
menubar: false,
|
||||||
@@ -782,7 +782,7 @@ export default {
|
|||||||
table_resize_bars: true,
|
table_resize_bars: true,
|
||||||
image_advtab: false, // 禁用图片高级选项卡(防止自动调整大小)
|
image_advtab: false, // 禁用图片高级选项卡(防止自动调整大小)
|
||||||
valid_elements: '*[*]',
|
valid_elements: '*[*]',
|
||||||
|
|
||||||
plugins: 'forecolor code paste table image resize ',
|
plugins: 'forecolor code paste table image resize ',
|
||||||
content_style: `${tableStyle + this.wordStyle}
|
content_style: `${tableStyle + this.wordStyle}
|
||||||
|
|
||||||
@@ -870,8 +870,8 @@ export default {
|
|||||||
image_advtab: false, // 禁用图片高级选项卡(防止自动调整大小)
|
image_advtab: false, // 禁用图片高级选项卡(防止自动调整大小)
|
||||||
plugins: 'forecolor code paste table image resize ',
|
plugins: 'forecolor code paste table image resize ',
|
||||||
content_style: `${tableStyle + this.wordStyle}
|
content_style: `${tableStyle + this.wordStyle}
|
||||||
|
|
||||||
`,
|
`,entity_encoding: 'raw', // 不编码 > 等字符
|
||||||
menubar: false,
|
menubar: false,
|
||||||
toolbar: _this.isEditComment ? ['commentAdd |delete| addRow|Edit'] : ['delete| addRow|Edit'],
|
toolbar: _this.isEditComment ? ['commentAdd |delete| addRow|Edit'] : ['delete| addRow|Edit'],
|
||||||
end_container_on_empty_block: true,
|
end_container_on_empty_block: true,
|
||||||
|
|||||||
Reference in New Issue
Block a user