Skip to content

Commit 2df552e

Browse files
committed
refactor(app): lazy update in node renderer
1 parent 6ae4aa1 commit 2df552e

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

packages/app/modules/editor/components/NodeEditorRenderer.vue

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,10 @@ const emit = defineEmits(['update:modelValue'])
2020
const el = ref<HTMLElement>()
2121
const innerModel = ref('')
2222
23-
const textHaveVariable = computed(() => props.modelValue.includes('{{'))
23+
const textHaveVariable = computed(() => {
24+
// have {{ }} in text
25+
return /\{\{.*\}\}/.test(props.modelValue)
26+
})
2427
2528
function setInnerModel() {
2629
let text = props.modelValue
@@ -44,17 +47,15 @@ function update() {
4447
emit('update:modelValue', text)
4548
}
4649
47-
const onInput = debounce(() => {
48-
if (textHaveVariable.value) return
50+
// const onInput = debounce(() => {
51+
// if (textHaveVariable.value) return
4952
50-
update()
51-
}, 100)
53+
// update()
54+
// }, 100)
5255
5356
const editMode = ref(false)
5457
5558
function onBlur() {
56-
if (!textHaveVariable.value) return
57-
5859
update()
5960
6061
editMode.value = false
@@ -143,15 +144,14 @@ defineExpose({
143144
:is="componentData"
144145
v-if="textHaveVariable"
145146
class="absolute left-0 top-0 transition-opacity w-full h-full"
146-
:class="[textHaveVariable && editMode ? 'opacity-0' : '']"
147+
:class="[editMode ? 'opacity-0' : '']"
147148
/>
148149

149150
<div
150151
ref="el"
151152
contenteditable
152153
class="outline-none transition-opacity"
153154
:class="[textHaveVariable && !editMode ? 'opacity-0' : '']"
154-
@input="onInput"
155155
@blur="onBlur"
156156
@focus="editMode = true"
157157
@click="editMode = true"

0 commit comments

Comments
 (0)