슬래시 미일치 Enter 동작 보정
This commit is contained in:
@@ -55,6 +55,7 @@ import {
|
||||
insertMarkdownLinesAtSlashTarget,
|
||||
parseSlashInput,
|
||||
resolveSlashCommand,
|
||||
shouldCaptureSlashMenuKeyboardAction,
|
||||
shouldIgnorePendingMediaSlashCommit
|
||||
} from '../../lib/markdown-slash-commands.js'
|
||||
import {
|
||||
@@ -1276,37 +1277,49 @@ onMounted(() => {
|
||||
|
||||
if (liveSlashVisible.value) {
|
||||
const slashKeyboardAction = getSlashMenuKeyboardAction(event.key)
|
||||
const slashCommandCount = visibleLiveSlashCommands.value.length
|
||||
|
||||
if (slashKeyboardAction === 'navigate') {
|
||||
event.preventDefault()
|
||||
const count = visibleLiveSlashCommands.value.length
|
||||
|
||||
if (count) {
|
||||
startLiveSlashKeyboardNavigation()
|
||||
|
||||
liveSlashHighlightedIndex.value = getNextSlashHighlightedIndex({
|
||||
currentIndex: liveSlashHighlightedIndex.value,
|
||||
commandCount: count,
|
||||
key: event.key
|
||||
})
|
||||
if (!shouldCaptureSlashMenuKeyboardAction({
|
||||
action: slashKeyboardAction,
|
||||
commandCount: slashCommandCount
|
||||
})) {
|
||||
return
|
||||
}
|
||||
|
||||
event.preventDefault()
|
||||
event.stopPropagation()
|
||||
startLiveSlashKeyboardNavigation()
|
||||
|
||||
liveSlashHighlightedIndex.value = getNextSlashHighlightedIndex({
|
||||
currentIndex: liveSlashHighlightedIndex.value,
|
||||
commandCount: slashCommandCount,
|
||||
key: event.key
|
||||
})
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
if (slashKeyboardAction === 'apply') {
|
||||
event.preventDefault()
|
||||
const command = visibleLiveSlashCommands.value[liveSlashHighlightedIndex.value]
|
||||
|
||||
if (command) {
|
||||
applyLiveSlashCommand(command)
|
||||
if (!shouldCaptureSlashMenuKeyboardAction({
|
||||
action: slashKeyboardAction,
|
||||
commandCount: slashCommandCount
|
||||
}) || !command) {
|
||||
clearLiveSlashState()
|
||||
return
|
||||
}
|
||||
|
||||
event.preventDefault()
|
||||
event.stopPropagation()
|
||||
applyLiveSlashCommand(command)
|
||||
return
|
||||
}
|
||||
|
||||
if (slashKeyboardAction === 'cancel') {
|
||||
event.preventDefault()
|
||||
event.stopPropagation()
|
||||
cancelLiveSlashCommand()
|
||||
return
|
||||
}
|
||||
@@ -2517,6 +2530,7 @@ const onLiveSlashApply = (payload) => {
|
||||
const command = resolveSlashCommand(parsed?.query ?? liveSlashQuery.value)
|
||||
|
||||
if (!command) {
|
||||
onLiveSlashEnd({ sourceLine: payload?.sourceLine })
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
@@ -13,7 +13,10 @@ import {
|
||||
LIVE_SELECTION_BRIDGE_KEY,
|
||||
selectEditableElementContents
|
||||
} from '../../lib/markdown-live-selection.js'
|
||||
import { parseSlashInput } from '../../lib/markdown-slash-commands.js'
|
||||
import {
|
||||
parseSlashInput,
|
||||
resolveSlashCommandFromInputValue
|
||||
} from '../../lib/markdown-slash-commands.js'
|
||||
|
||||
const props = defineProps({
|
||||
/** 인라인 마크다운 원문 */
|
||||
@@ -1340,7 +1343,7 @@ const onKeydown = (event) => {
|
||||
}
|
||||
}
|
||||
|
||||
if (props.slashMenuActive) {
|
||||
if (props.slashMenuActive && event.key !== 'Enter') {
|
||||
return
|
||||
}
|
||||
|
||||
@@ -1388,15 +1391,26 @@ const onKeydown = (event) => {
|
||||
const isComposingEnter = event.key === 'Enter'
|
||||
&& (event.isComposing || event.keyCode === 229 || isComposingText.value)
|
||||
|
||||
if (event.key === 'Enter' && !event.shiftKey && !isComposingEnter && parseSlashInput(readEditorValue())) {
|
||||
event.preventDefault()
|
||||
event.stopPropagation()
|
||||
event.stopImmediatePropagation?.()
|
||||
emit('slash-apply', {
|
||||
sourceLine: props.sourceLine,
|
||||
value: readEditorValue()
|
||||
})
|
||||
return
|
||||
if (event.key === 'Enter' && !event.shiftKey && !isComposingEnter) {
|
||||
const editorValue = readEditorValue()
|
||||
const parsedSlashInput = parseSlashInput(editorValue)
|
||||
|
||||
if (parsedSlashInput) {
|
||||
const command = resolveSlashCommandFromInputValue(editorValue)
|
||||
|
||||
if (command) {
|
||||
event.preventDefault()
|
||||
event.stopPropagation()
|
||||
event.stopImmediatePropagation?.()
|
||||
emit('slash-apply', {
|
||||
sourceLine: props.sourceLine,
|
||||
value: editorValue
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
emit('slash-end', { sourceLine: props.sourceLine })
|
||||
}
|
||||
}
|
||||
|
||||
if (event.key === 'Enter' && enterAction) {
|
||||
|
||||
Reference in New Issue
Block a user