Forráskód Böngészése

富文本组件添加几个方法

lizhenhao 2 éve
szülő
commit
e0f774d67c
1 módosított fájl, 33 hozzáadás és 0 törlés
  1. 33 0
      src/components/editor/WangEditor.vue

+ 33 - 0
src/components/editor/WangEditor.vue

@@ -110,6 +110,35 @@
 				editorRef.value = editor; // 记录 editor 实例,重要!
 			};
 
+				// 清空编辑器内容
+			const clear = () => {
+				const editor = editorRef.value;
+				if (editor == null) return;
+				editor.clear()
+			}
+
+			// 取消禁用,取消只读
+			const enable = () => {
+				const editor = editorRef.value;
+				if (editor == null) return;
+				editor.enable()
+			}
+
+			// 禁用编辑器,设置为只读
+			const disable = () => {
+				const editor = editorRef.value;
+				if (editor == null) return;
+				editor.disable()
+			}
+
+			// 强制更新视图
+			const updateView = () => {
+				const editor = editorRef.value;
+				if (editor == null) return;
+				editor.updateView()
+			}
+
+
 			return {
 				editorRef,
 				valueHtml,
@@ -117,6 +146,10 @@
 				toolbarConfig,
 				editorConfig,
 				handleCreated,
+				clear,
+				enable,
+				disable,
+				updateView
 			};
 		},
 	};