修改blue标签
This commit is contained in:
@@ -2060,17 +2060,18 @@ export default {
|
|||||||
|
|
||||||
|
|
||||||
ed.ui.registry.addButton('customBlue', {
|
ed.ui.registry.addButton('customBlue', {
|
||||||
text: 'Blue', // 按钮文本
|
text: 'Blue',
|
||||||
className: 'custom-button-blue', // 添加自定义类
|
className: 'custom-button-blue',
|
||||||
// shortcut: "Ctrl+J",
|
|
||||||
onAction: function () {
|
onAction: function () {
|
||||||
// 在选中的文本周围包裹 <blue> 标签
|
// 必须获取带 HTML 的内容,否则里面的 em/i 标签在拼接前就丢了
|
||||||
var selectedText = ed.selection.getContent();
|
var selectedText = ed.selection.getContent({ format: 'html' });
|
||||||
|
|
||||||
if (selectedText) {
|
if (selectedText) {
|
||||||
|
// 这就是你想要的:直接外层套一个 blue
|
||||||
var wrappedText = `<blue>${selectedText}</blue>`;
|
var wrappedText = `<blue>${selectedText}</blue>`;
|
||||||
|
|
||||||
|
// 使用 setContent 强行回写
|
||||||
ed.selection.setContent(wrappedText);
|
ed.selection.setContent(wrappedText);
|
||||||
} else {
|
|
||||||
this.$message.error('请选择要添加蓝色的文本');
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -119,15 +119,14 @@ const tableStyle = `
|
|||||||
}
|
}
|
||||||
table span blue {
|
table span blue {
|
||||||
color: rgb(0, 130, 170) !important;
|
color: rgb(0, 130, 170) !important;
|
||||||
}blue {
|
}
|
||||||
|
blue {
|
||||||
color: rgb(0, 130, 170) !important;
|
color: rgb(0, 130, 170) !important;
|
||||||
}
|
}
|
||||||
blue sup {
|
blue *{
|
||||||
color: rgb(0, 130, 170) !important;
|
|
||||||
}
|
|
||||||
blue sub {
|
|
||||||
color: rgb(0, 130, 170) !important;
|
color: rgb(0, 130, 170) !important;
|
||||||
}
|
}
|
||||||
|
|
||||||
.wordTableHtml table tr.table-header-row:nth-of-type(2) td {
|
.wordTableHtml table tr.table-header-row:nth-of-type(2) td {
|
||||||
border-bottom: 1px solid #000 !important;
|
border-bottom: 1px solid #000 !important;
|
||||||
}
|
}
|
||||||
@@ -391,6 +390,10 @@ export default {
|
|||||||
var _this = this;
|
var _this = this;
|
||||||
window.tinymce.init({
|
window.tinymce.init({
|
||||||
..._this.tinymceOtherInit,
|
..._this.tinymceOtherInit,
|
||||||
|
extended_valid_elements: 'blue[*]',
|
||||||
|
custom_elements: 'blue',
|
||||||
|
valid_children: '+blue[#text|i|em|b|strong|span],+body[blue],+p[blue]',
|
||||||
|
|
||||||
inline: false, // 使用 iframe 模式
|
inline: false, // 使用 iframe 模式
|
||||||
selector: `#${this.tinymceId}`,
|
selector: `#${this.tinymceId}`,
|
||||||
// noneditable_regexp: "/<wmath>.*?<\/wmath>/g",
|
// noneditable_regexp: "/<wmath>.*?<\/wmath>/g",
|
||||||
@@ -406,10 +409,13 @@ export default {
|
|||||||
content_style: `
|
content_style: `
|
||||||
${tableStyle}
|
${tableStyle}
|
||||||
${_this.wordStyle}
|
${_this.wordStyle}
|
||||||
|
blue{
|
||||||
|
display: inline;
|
||||||
|
}
|
||||||
`,
|
`,
|
||||||
formats: {
|
formats: {
|
||||||
bold: { inline: 'b' },
|
bold: { inline: 'b' },
|
||||||
italic: { inline: 'i' }
|
italic: { inline: 'i' },
|
||||||
},
|
},
|
||||||
body_class: 'panel-body ',
|
body_class: 'panel-body ',
|
||||||
object_resizing: false,
|
object_resizing: false,
|
||||||
@@ -617,9 +623,9 @@ export default {
|
|||||||
},
|
},
|
||||||
paste_preprocess: function (plugin, args) {
|
paste_preprocess: function (plugin, args) {
|
||||||
let imgIdx = 0;
|
let imgIdx = 0;
|
||||||
|
|
||||||
const silentPlaceholder = 'data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7';
|
const silentPlaceholder = 'data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7';
|
||||||
|
|
||||||
let content = args.content.replace(/(<img[^>]*?)src="file:\/\/\/[^" ]*"/gi, (match, p1) => {
|
let content = args.content.replace(/(<img[^>]*?)src="file:\/\/\/[^" ]*"/gi, (match, p1) => {
|
||||||
// 保留 data-idx, Word 里的尺寸
|
// 保留 data-idx, Word 里的尺寸
|
||||||
return `${p1}src="${silentPlaceholder}" class="word-img-placeholder" data-idx="${imgIdx++}"`;
|
return `${p1}src="${silentPlaceholder}" class="word-img-placeholder" data-idx="${imgIdx++}"`;
|
||||||
@@ -702,9 +708,9 @@ export default {
|
|||||||
},
|
},
|
||||||
init_instance_callback: (editor) => {
|
init_instance_callback: (editor) => {
|
||||||
if (_this.value) {
|
if (_this.value) {
|
||||||
editor.setContent(_this.value);
|
|
||||||
|
editor.setContent('<p>'+_this.value+'</p>');
|
||||||
|
|
||||||
// console.log('at line 489:', ' 页面');
|
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
window.renderMathJax(_this.tinymceId); // 初始化时渲染 MathJax
|
window.renderMathJax(_this.tinymceId); // 初始化时渲染 MathJax
|
||||||
}, 10);
|
}, 10);
|
||||||
@@ -910,5 +916,4 @@ export default {
|
|||||||
::v-deep .tox:not(.tox-tinymce-inline) .tox-editor-header {
|
::v-deep .tox:not(.tox-tinymce-inline) .tox-editor-header {
|
||||||
padding: 0 !important;
|
padding: 0 !important;
|
||||||
}
|
}
|
||||||
|
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
Reference in New Issue
Block a user