perf: 形状内文字编辑优化

This commit is contained in:
pipipi-pikachu 2022-05-14 12:03:57 +08:00
parent 5eeb1fb545
commit 6a7e172140

View File

@ -68,6 +68,7 @@
:autoFocus="true" :autoFocus="true"
:value="text.content" :value="text.content"
@update="value => updateText(value)" @update="value => updateText(value)"
@blur="checkEmptyText()"
@mousedown="$event => handleSelectElement($event, false)" @mousedown="$event => handleSelectElement($event, false)"
/> />
</div> </div>
@ -163,6 +164,16 @@ export default defineComponent({
addHistorySnapshot() addHistorySnapshot()
} }
const checkEmptyText = () => {
if (!props.elementInfo.text) return
const pureText = props.elementInfo.text.content.replaceAll(/<[^>]+>/g, '')
if (!pureText) {
slidesStore.removeElementProps({ id: props.elementInfo.id, propName: 'text' })
addHistorySnapshot()
}
}
return { return {
shadowStyle, shadowStyle,
outlineWidth, outlineWidth,
@ -173,6 +184,7 @@ export default defineComponent({
text, text,
handleSelectElement, handleSelectElement,
updateText, updateText,
checkEmptyText,
} }
}, },
}) })