perf: 默认的文本占位文字在首次获取光标后移除

This commit is contained in:
pipipi-pikachu 2021-02-25 15:53:00 +08:00
parent 9e4945d3ea
commit e58095cfe7

View File

@ -149,12 +149,6 @@ export default defineComponent({
// //
// vuex // 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() { const handleInput = debounce(function() {
store.commit(MutationTypes.UPDATE_ELEMENT, { store.commit(MutationTypes.UPDATE_ELEMENT, {
id: props.elementInfo.id, id: props.elementInfo.id,
@ -163,6 +157,18 @@ export default defineComponent({
addHistorySnapshot() addHistorySnapshot()
}, 300, { trailing: true }) }, 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 handleClick = debounce(function() {
const attr = getTextAttrs(editorView) const attr = getTextAttrs(editorView)
emitter.emit(EmitterEvents.UPDATE_TEXT_STATE, attr) emitter.emit(EmitterEvents.UPDATE_TEXT_STATE, attr)