diff --git a/src/components/Editor/index.vue b/src/components/Editor/index.vue index 6bab39d76c250798fb7cfe7ab725285a1a1961da..d05f3c49d71d8ec158e2cbec05c35f2c6412a47e 100644 --- a/src/components/Editor/index.vue +++ b/src/components/Editor/index.vue @@ -1,74 +1,135 @@ - + // 跨域是否传递 cookie ,默认为 false + withCredentials: true, + // 超时时间,默认为 30 秒 + timeout: 15 * 1000, // 15 秒 + // 自定义插入视频 + customInsert(res, insertFn) { + ;-( + // 从 res 中找到 url alt href ,然后插图图片 + insertFn(res.data.url) + ) + }, + } + onBeforeUnmount(() => { + const editor = editorRef.value + if (editor == null) return + editor.destroy() + }) + const handleCreated = (editor) => { + editorRef.value = editor + } + const handleChange = (editor) => { + emit('update:modelValue', editor.getHtml()) + } + watch( + () => props.modelValue, + (value) => { + const editor = editorRef.value + if (value == undefined) { + editor.clear() + return + } + editor.setHtml(value) + }, + ) + return { + editorRef, + valueHtml, + mode: 'default', + toolbarConfig, + editorConfig, + handleCreated, + handleChange, + } + }, +} + \ No newline at end of file