연속 콜아웃 편집 범위 보정
This commit is contained in:
@@ -108,9 +108,8 @@ const suppressBlurCommit = ref(false)
|
||||
const splitLock = ref(false)
|
||||
/** 조합 중 Enter 후 compositionend에서 분리할지 */
|
||||
const pendingSplitAfterComposition = ref(false)
|
||||
/** 조합 종료 직후 중복 Enter를 1회 무시할지 */
|
||||
const suppressNextEnterAfterComposition = ref(false)
|
||||
const showingRaw = ref(false)
|
||||
let cleanupComposedEnterSuppressor = null
|
||||
|
||||
/** @returns {string} Enter 동작 모드 */
|
||||
const resolvedEnterMode = computed(() => {
|
||||
@@ -186,6 +185,10 @@ onMounted(() => {
|
||||
syncEditorHtml()
|
||||
})
|
||||
|
||||
onBeforeUnmount(() => {
|
||||
cleanupComposedEnterSuppressor?.()
|
||||
})
|
||||
|
||||
/**
|
||||
* 포커스 시 편집 상태를 표시한다.
|
||||
* @returns {void}
|
||||
@@ -680,6 +683,46 @@ const scheduleEnterAction = (action) => {
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 조합 종료 직후 브라우저가 다시 전달하는 Enter를 한 번 차단한다.
|
||||
* @returns {void}
|
||||
*/
|
||||
const suppressNextComposedEnterGlobally = () => {
|
||||
if (!import.meta.client) {
|
||||
return
|
||||
}
|
||||
|
||||
cleanupComposedEnterSuppressor?.()
|
||||
|
||||
const deadline = Date.now() + 500
|
||||
|
||||
const handler = (event) => {
|
||||
if (
|
||||
event.key === 'Enter'
|
||||
&& !event.shiftKey
|
||||
&& !event.metaKey
|
||||
&& !event.ctrlKey
|
||||
&& !event.altKey
|
||||
&& Date.now() <= deadline
|
||||
) {
|
||||
event.preventDefault()
|
||||
event.stopPropagation()
|
||||
event.stopImmediatePropagation?.()
|
||||
cleanupComposedEnterSuppressor?.()
|
||||
}
|
||||
}
|
||||
|
||||
cleanupComposedEnterSuppressor = () => {
|
||||
window.removeEventListener('keydown', handler, true)
|
||||
cleanupComposedEnterSuppressor = null
|
||||
}
|
||||
|
||||
window.addEventListener('keydown', handler, true)
|
||||
window.setTimeout(() => {
|
||||
cleanupComposedEnterSuppressor?.()
|
||||
}, 520)
|
||||
}
|
||||
|
||||
/**
|
||||
* 원문 모드 상태를 부모에 알린다.
|
||||
* @param {boolean} active - 활성 여부
|
||||
@@ -878,17 +921,6 @@ const onKeydown = (event) => {
|
||||
|
||||
const enterMode = showingRaw.value ? 'insert-below' : resolvedEnterMode.value
|
||||
|
||||
if (
|
||||
event.key === 'Enter'
|
||||
&& !event.shiftKey
|
||||
&& suppressNextEnterAfterComposition.value
|
||||
) {
|
||||
event.preventDefault()
|
||||
event.stopPropagation()
|
||||
suppressNextEnterAfterComposition.value = false
|
||||
return
|
||||
}
|
||||
|
||||
if (event.key === 'Enter' && !event.shiftKey && parseSlashInput(readEditorValue())) {
|
||||
event.preventDefault()
|
||||
event.stopPropagation()
|
||||
@@ -950,11 +982,8 @@ const onCompositionEnd = () => {
|
||||
}
|
||||
|
||||
nextTick(() => {
|
||||
suppressNextEnterAfterComposition.value = true
|
||||
suppressNextComposedEnterGlobally()
|
||||
scheduleEnterAction(enterMode === 'split-paragraph' ? 'split' : 'insert-below')
|
||||
window.setTimeout(() => {
|
||||
suppressNextEnterAfterComposition.value = false
|
||||
}, 1200)
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user