perf: 形状进入编辑状态后自动聚焦

This commit is contained in:
pipipi-pikachu 2021-07-31 22:06:22 +08:00
parent a7afcc8232
commit d26a7a1b43
2 changed files with 6 additions and 0 deletions

View File

@ -39,6 +39,10 @@ export default defineComponent({
type: String,
required: true,
},
autoFocus: {
type: Boolean,
default: false,
},
},
setup(props, { emit }) {
const store = useStore()
@ -107,6 +111,7 @@ export default defineComponent({
},
editable: () => props.editable,
})
if (props.autoFocus) editorView.focus()
})
onUnmounted(() => {
editorView && editorView.destroy()

View File

@ -64,6 +64,7 @@
:defaultColor="text.defaultColor"
:defaultFontName="text.defaultFontName"
:editable="!elementInfo.lock"
:autoFocus="true"
:value="text.content"
@update="value => updateText(value)"
@mousedown.stop