修改blue标签

This commit is contained in:
2026-01-15 16:41:29 +08:00
parent 2a71d139ea
commit 88715ff43a
2 changed files with 24 additions and 18 deletions

View File

@@ -2060,17 +2060,18 @@ export default {
ed.ui.registry.addButton('customBlue', {
text: 'Blue', // 按钮文本
className: 'custom-button-blue', // 添加自定义类
// shortcut: "Ctrl+J",
text: 'Blue',
className: 'custom-button-blue',
onAction: function () {
// 在选中的文本周围包裹 <blue> 标签
var selectedText = ed.selection.getContent();
// 必须获取带 HTML 的内容,否则里面的 em/i 标签在拼接前就丢了
var selectedText = ed.selection.getContent({ format: 'html' });
if (selectedText) {
// 这就是你想要的:直接外层套一个 blue
var wrappedText = `<blue>${selectedText}</blue>`;
// 使用 setContent 强行回写
ed.selection.setContent(wrappedText);
} else {
this.$message.error('请选择要添加蓝色的文本');
}
}
});

View File

@@ -119,15 +119,14 @@ const tableStyle = `
}
table span blue {
color: rgb(0, 130, 170) !important;
}blue {
}
blue {
color: rgb(0, 130, 170) !important;
}
blue sup {
color: rgb(0, 130, 170) !important;
}
blue sub {
blue *{
color: rgb(0, 130, 170) !important;
}
.wordTableHtml table tr.table-header-row:nth-of-type(2) td {
border-bottom: 1px solid #000 !important;
}
@@ -391,6 +390,10 @@ export default {
var _this = this;
window.tinymce.init({
..._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 模式
selector: `#${this.tinymceId}`,
// noneditable_regexp: "/<wmath>.*?<\/wmath>/g",
@@ -406,10 +409,13 @@ export default {
content_style: `
${tableStyle}
${_this.wordStyle}
blue{
display: inline;
}
`,
formats: {
bold: { inline: 'b' },
italic: { inline: 'i' }
italic: { inline: 'i' },
},
body_class: 'panel-body ',
object_resizing: false,
@@ -702,9 +708,9 @@ export default {
},
init_instance_callback: (editor) => {
if (_this.value) {
editor.setContent(_this.value);
// console.log('at line 489:', ' 页面');
editor.setContent('<p>'+_this.value+'</p>');
setTimeout(() => {
window.renderMathJax(_this.tinymceId); // 初始化时渲染 MathJax
}, 10);
@@ -910,5 +916,4 @@ export default {
::v-deep .tox:not(.tox-tinymce-inline) .tox-editor-header {
padding: 0 !important;
}
</style>