|
|
@@ -65,6 +65,7 @@ export default {
|
|
|
Editor,
|
|
|
MathDialog,
|
|
|
},
|
|
|
+ inject: ['getBookUnifiedAttr'],
|
|
|
inheritAttrs: false,
|
|
|
props: {
|
|
|
inline: {
|
|
|
@@ -102,8 +103,12 @@ export default {
|
|
|
default: false,
|
|
|
},
|
|
|
fontSize: {
|
|
|
- type: Number,
|
|
|
- default: 16,
|
|
|
+ type: String,
|
|
|
+ default: '12pt',
|
|
|
+ },
|
|
|
+ fontFamily: {
|
|
|
+ type: String,
|
|
|
+ default: 'Arial',
|
|
|
},
|
|
|
isHasSpace: {
|
|
|
type: Boolean,
|
|
|
@@ -137,6 +142,7 @@ export default {
|
|
|
left: 0,
|
|
|
},
|
|
|
id: getRandomNumber(),
|
|
|
+ bookUnifiedAttr: this.getBookUnifiedAttr(),
|
|
|
init: {
|
|
|
content_style: `
|
|
|
mjx-container, mjx-container * {
|
|
|
@@ -148,6 +154,7 @@ export default {
|
|
|
extended_valid_elements: 'span[*],mjx-container[*],svg[*],path[*]', // 明确允许 MathJax 标签
|
|
|
inline: this.inline,
|
|
|
font_size: this.fontSize,
|
|
|
+ font_family: this.fontFamily,
|
|
|
language_url: `${process.env.BASE_URL}tinymce/langs/zh_CN.js`,
|
|
|
placeholder: this.placeholder,
|
|
|
language: 'zh_CN',
|
|
|
@@ -168,11 +175,11 @@ export default {
|
|
|
let isRendered = false; // 标记是否已渲染
|
|
|
let that = this;
|
|
|
editor.on('init', () => {
|
|
|
- editor.getBody().style.fontSize = `${this.font_size}pt`; // 设置默认字体大小
|
|
|
- editor.getBody().style.fontFamily = 'Arial'; // 设置默认字体
|
|
|
+ editor.getBody().style.fontSize = this.init.font_size; // 设置默认字体大小
|
|
|
+ editor.getBody().style.fontFamily = this.init.font_family; // 设置默认字体
|
|
|
});
|
|
|
|
|
|
- editor.on('click', (e) => {
|
|
|
+ editor.on('click', () => {
|
|
|
if (editor?.queryCommandState('ToggleToolbarDrawer')) {
|
|
|
editor.execCommand('ToggleToolbarDrawer');
|
|
|
}
|
|
|
@@ -194,19 +201,19 @@ export default {
|
|
|
// 内容变化时重新渲染公式
|
|
|
editor.on('change', () => this.renderMath());
|
|
|
|
|
|
- editor.on('KeyDown', function (e) {
|
|
|
+ editor.on('KeyDown', (e) => {
|
|
|
// 检测删除或退格键
|
|
|
if (e.keyCode === 8 || e.keyCode === 46) {
|
|
|
// 延迟执行以确保删除已完成
|
|
|
- setTimeout(function () {
|
|
|
+ setTimeout(() => {
|
|
|
that.cleanupRemovedAnnotations(editor);
|
|
|
}, 500);
|
|
|
}
|
|
|
});
|
|
|
|
|
|
// 也可以监听剪切操作
|
|
|
- editor.on('Cut', function () {
|
|
|
- setTimeout(function () {
|
|
|
+ editor.on('Cut', () => {
|
|
|
+ setTimeout(() => {
|
|
|
that.cleanupRemovedAnnotations(editor);
|
|
|
}, 500);
|
|
|
});
|
|
|
@@ -257,7 +264,7 @@ export default {
|
|
|
},
|
|
|
watch: {
|
|
|
isViewNote: {
|
|
|
- handler(newVal, oldVal) {
|
|
|
+ handler(newVal) {
|
|
|
if (newVal) {
|
|
|
let editor = tinymce.get(this.id);
|
|
|
if (editor) {
|
|
|
@@ -267,6 +274,24 @@ export default {
|
|
|
}
|
|
|
},
|
|
|
},
|
|
|
+ fontSize: {
|
|
|
+ handler(newVal) {
|
|
|
+ let editor = tinymce.get(this.id);
|
|
|
+ if (editor) {
|
|
|
+ editor.getBody().style.fontSize = newVal;
|
|
|
+ editor.execCommand('FontSize', false, newVal);
|
|
|
+ }
|
|
|
+ },
|
|
|
+ },
|
|
|
+ fontFamily: {
|
|
|
+ handler(newVal) {
|
|
|
+ let editor = tinymce.get(this.id);
|
|
|
+ if (editor) {
|
|
|
+ editor.getBody().style.fontFamily = newVal;
|
|
|
+ editor.execCommand('FontName', false, newVal);
|
|
|
+ }
|
|
|
+ },
|
|
|
+ },
|
|
|
},
|
|
|
created() {
|
|
|
if (this.pageFrom !== 'audit') {
|