소스 검색

富文本组件添加几个方法

lizhenhao 2 년 전
부모
커밋
e0f774d67c
1개의 변경된 파일33개의 추가작업 그리고 0개의 파일을 삭제
  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
 			};
 		},
 	};