|
|
@@ -876,8 +876,9 @@ export default {
|
|
|
* 设置整体富文本格式
|
|
|
* @param {string} type 格式名称
|
|
|
* @param {string} val 格式值
|
|
|
+ * @param {boolean} [isSetDefault=false] 是否设置为默认格式
|
|
|
*/
|
|
|
- setRichFormat(type, val) {
|
|
|
+ setRichFormat(type, val, isSetDefault = false) {
|
|
|
let editor = tinymce.get(this.id);
|
|
|
if (!editor) return;
|
|
|
editor.execCommand('SelectAll');
|
|
|
@@ -885,6 +886,10 @@ export default {
|
|
|
editor.selection.collapse(false);
|
|
|
editor.fire('change'); // 触发内容变化事件,确保内容更新
|
|
|
|
|
|
+ if (isSetDefault) {
|
|
|
+ this.setDefaultRichtext(editor, type, val);
|
|
|
+ }
|
|
|
+
|
|
|
if (this.isViewPinyin) {
|
|
|
this.$nextTick(() => {
|
|
|
let styles = this.getFirstCharStyles();
|
|
|
@@ -893,7 +898,8 @@ export default {
|
|
|
}
|
|
|
},
|
|
|
/**
|
|
|
- * 设置整体富文本格式
|
|
|
+ * 处理编辑器格式化逻辑
|
|
|
+ * @param {Editor} editor 编辑器实例
|
|
|
* @param {string} type 格式名称
|
|
|
* @param {string} val 格式值
|
|
|
*/
|
|
|
@@ -937,6 +943,17 @@ export default {
|
|
|
}
|
|
|
}
|
|
|
},
|
|
|
+ /**
|
|
|
+ * 设置默认富文本格式
|
|
|
+ * @param {Editor} editor 编辑器实例
|
|
|
+ * @param {string} type 格式名称
|
|
|
+ * @param {string} val 格式值
|
|
|
+ */
|
|
|
+ setDefaultRichtext(editor, type, val) {
|
|
|
+ const bodyStyle = editor.getBody().style;
|
|
|
+ if (!bodyStyle) return;
|
|
|
+ bodyStyle[type] = val;
|
|
|
+ },
|
|
|
setRichTitleFormat(config) {
|
|
|
if (!this.editorIsInited) {
|
|
|
this.editorBeforeInitConfig['style'] = config;
|