Skip to content

Commit 6e7e735

Browse files
committed
fix(editor): improve editor update timing
1 parent 2a51deb commit 6e7e735

File tree

1 file changed

+5
-16
lines changed

1 file changed

+5
-16
lines changed

packages/client/internals/Editor.vue

Lines changed: 5 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<script setup lang="ts">
22
import { useEventListener, throttledWatch } from '@vueuse/core'
33
import { computed, watch, ref, onMounted } from 'vue'
4-
import { activeElement, showEditor, editorWidth } from '../state'
4+
import { activeElement, showEditor, editorWidth, isInputing } from '../state'
55
import { useCodeMirror } from '../setup/codemirror'
66
import { currentRoute, currentSlideId } from '../logic/nav'
77
import { useDynamicSlideInfo } from '../logic/note'
@@ -13,17 +13,16 @@ const dirty = ref(false)
1313
const frontmatter = ref<any>({})
1414
const contentInput = ref<HTMLTextAreaElement>()
1515
const noteInput = ref<HTMLTextAreaElement>()
16-
const focused = ref(false)
1716
1817
const { info, update } = useDynamicSlideInfo(currentSlideId)
1918
2019
watch(
2120
info,
2221
(v) => {
23-
note.value = (v?.note || '').trim()
2422
frontmatter.value = v?.frontmatter || {}
2523
26-
if (!focused.value) {
24+
if (!isInputing.value) {
25+
note.value = (v?.note || '').trim()
2726
content.value = (v?.content || '').trim()
2827
dirty.value = false
2928
}
@@ -67,14 +66,9 @@ onMounted(() => {
6766
{
6867
mode: 'markdown',
6968
lineWrapping: true,
69+
// @ts-ignore
7070
highlightFormatting: true,
7171
fencedCodeBlockDefaultMode: 'javascript',
72-
onfocus() {
73-
focused.value = true
74-
},
75-
onblur() {
76-
focused.value = false
77-
},
7872
},
7973
)
8074
@@ -90,14 +84,9 @@ onMounted(() => {
9084
{
9185
mode: 'markdown',
9286
lineWrapping: true,
87+
// @ts-ignore
9388
highlightFormatting: true,
9489
fencedCodeBlockDefaultMode: 'javascript',
95-
onfocus() {
96-
focused.value = true
97-
},
98-
onblur() {
99-
focused.value = false
100-
},
10190
},
10291
)
10392
})

0 commit comments

Comments
 (0)