From e58095cfe7ed8d1e1f482b1129a814714a2cbd5c Mon Sep 17 00:00:00 2001 From: pipipi-pikachu Date: Thu, 25 Feb 2021 15:53:00 +0800 Subject: [PATCH] =?UTF-8?q?perf:=20=E9=BB=98=E8=AE=A4=E7=9A=84=E6=96=87?= =?UTF-8?q?=E6=9C=AC=E5=8D=A0=E4=BD=8D=E6=96=87=E5=AD=97=E5=9C=A8=E9=A6=96?= =?UTF-8?q?=E6=AC=A1=E8=8E=B7=E5=8F=96=E5=85=89=E6=A0=87=E5=90=8E=E7=A7=BB?= =?UTF-8?q?=E9=99=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../components/element/TextElement/index.vue | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/src/views/components/element/TextElement/index.vue b/src/views/components/element/TextElement/index.vue index 0c191739..da74c4d2 100644 --- a/src/views/components/element/TextElement/index.vue +++ b/src/views/components/element/TextElement/index.vue @@ -149,12 +149,6 @@ export default defineComponent({ // 聚焦时取消全局快捷键事件 // 输入文字时同步数据到vuex // 点击鼠标和键盘时同步富文本状态到工具栏 - const handleFocus = () => { - store.commit(MutationTypes.SET_DISABLE_HOTKEYS_STATE, true) - } - const handleBlur = () => { - store.commit(MutationTypes.SET_DISABLE_HOTKEYS_STATE, false) - } const handleInput = debounce(function() { store.commit(MutationTypes.UPDATE_ELEMENT, { id: props.elementInfo.id, @@ -163,6 +157,18 @@ export default defineComponent({ addHistorySnapshot() }, 300, { trailing: true }) + const handleFocus = () => { + if (props.elementInfo.content === '请输入内容') { + editorView.dom.innerHTML = '' + handleInput() + } + store.commit(MutationTypes.SET_DISABLE_HOTKEYS_STATE, true) + } + + const handleBlur = () => { + store.commit(MutationTypes.SET_DISABLE_HOTKEYS_STATE, false) + } + const handleClick = debounce(function() { const attr = getTextAttrs(editorView) emitter.emit(EmitterEvents.UPDATE_TEXT_STATE, attr)