fix: 토스트 에디터 한글(IME) 조합 끊김 수정
CI / build (push) Successful in 22s

부모가 되돌린 echo 값이면 setMarkdown 생략 → 문자 조합 유지

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
ByungCheol
2026-05-31 19:52:23 +09:00
parent 840ec84e0d
commit 772bc85bae
3 changed files with 27 additions and 8 deletions
+13 -4
View File
@@ -16,6 +16,8 @@ const emit = defineEmits(['update:modelValue'])
const el = ref(null)
let editor = null
// 에디터가 마지막으로 emit 한 값. 부모가 되돌려준 echo 를 구분해 한글 조합(IME)이 깨지지 않게 한다.
let lastEmitted = props.modelValue || ''
onMounted(() => {
editor = new Editor({
@@ -29,17 +31,24 @@ onMounted(() => {
usageStatistics: false,
autofocus: false,
events: {
change: () => emit('update:modelValue', editor.getMarkdown()),
change: () => {
lastEmitted = editor.getMarkdown()
emit('update:modelValue', lastEmitted)
},
},
})
})
// 외부 값 변경(수정 로드, 제출 후 초기화 등) 에디터에 반영 (입력 중 루프 방지 가드)
// 외부 값 변경(수정 로드, 제출 후 초기화 등) 에디터에 반영.
// 에디터 자신이 방금 emit 한 값(echo)이면 무시 → 입력 중 setMarkdown 으로 IME(한글) 조합이 끊기지 않게 한다.
watch(
() => props.modelValue,
(val) => {
if (editor && (val || '') !== editor.getMarkdown()) {
editor.setMarkdown(val || '')
const v = val || ''
if (v === lastEmitted) return
if (editor && v !== editor.getMarkdown()) {
lastEmitted = v
editor.setMarkdown(v)
}
},
)