|
@@ -948,7 +948,8 @@ export default {
|
|
|
/**
|
|
/**
|
|
|
* 设置整体富文本格式
|
|
* 设置整体富文本格式
|
|
|
* @param {string} type 格式名称
|
|
* @param {string} type 格式名称
|
|
|
- * @param {string} val 格式值
|
|
|
|
|
|
|
+ * @param {string|boolean} val 格式值;对于开关型格式(bold/italic/underline/strikethrough 等),
|
|
|
|
|
+ * 传 true 表示应用、false 表示取消,其余情况沿用 toggle 切换
|
|
|
* @param {boolean} [isSetDefault=false] 是否设置为默认格式
|
|
* @param {boolean} [isSetDefault=false] 是否设置为默认格式
|
|
|
*/
|
|
*/
|
|
|
setRichFormat(type, val, isSetDefault = false) {
|
|
setRichFormat(type, val, isSetDefault = false) {
|
|
@@ -1012,7 +1013,20 @@ export default {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
default: {
|
|
default: {
|
|
|
- editor.formatter.toggle(type);
|
|
|
|
|
|
|
+ // val 为布尔值时表示明确「应用 / 取消」该格式(批量设置场景,如取消下划线)
|
|
|
|
|
+ // 其余情况(未传 val 或传字符串)保持原有的 toggle 行为
|
|
|
|
|
+ if (typeof val === 'boolean') {
|
|
|
|
|
+ console.log(val);
|
|
|
|
|
+
|
|
|
|
|
+ if (val) {
|
|
|
|
|
+ editor.formatter.apply(type);
|
|
|
|
|
+ } else {
|
|
|
|
|
+ editor.formatter.remove(type);
|
|
|
|
|
+ }
|
|
|
|
|
+ } else {
|
|
|
|
|
+ editor.formatter.toggle(type);
|
|
|
|
|
+ }
|
|
|
|
|
+ break;
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
},
|
|
},
|