슬래시 명령 로직 분리

This commit is contained in:
2026-07-24 17:27:24 +09:00
parent 7bc04ec5b9
commit 31cae6f90b
7 changed files with 135 additions and 17 deletions

View File

@@ -19,8 +19,11 @@ import {
import {
filterSlashCommands,
getSlashCommandFocusTarget,
insertMarkdownLinesAtSlashTarget,
isMediaSlashAction,
parseSlashInput,
resolveSlashCommand
resolveSlashCommand,
shouldIgnorePendingMediaSlashCommit
} from '../../lib/markdown-slash-commands.js'
import { buildCalloutOpenerLine, CALLOUT_BACKGROUND_OPTIONS, QUOTE_BACKGROUND_OPTIONS } from '../../lib/markdown-callout.js'
import { buildCodeFenceOpener } from '../../lib/markdown-code-block.js'
@@ -2340,9 +2343,11 @@ const onPreviewBlockContentChange = ({ startLine, endLine, replacementLines }) =
return
}
if (liveSlashInsertLine.value === startLine
&& replacementLines.length === 1
&& parseSlashInput(replacementLines[0])) {
if (shouldIgnorePendingMediaSlashCommit({
pendingInsertLine: liveSlashInsertLine.value,
startLine,
replacementLines
})) {
return
}
@@ -2794,7 +2799,7 @@ const applyLiveSlashCommand = (command) => {
const line = liveSlashSourceLine.value
if (['media-image', 'media-gallery', 'media-video', 'media-audio', 'media-file'].includes(command.action)) {
if (isMediaSlashAction(command.action)) {
liveSlashInsertLine.value = line
replaceLineRange(line, line, [], false)
onLiveSlashEnd()
@@ -2843,14 +2848,7 @@ const onLiveSlashApply = (payload) => {
* @returns {void}
*/
const insertMarkdownAtLine = (lineIndex, insertLines) => {
const sourceLines = (markdownValue.value ?? '').split('\n')
const replaceCount = parseSlashInput(sourceLines[lineIndex] ?? '') ? 1 : 0
markdownValue.value = [
...sourceLines.slice(0, lineIndex),
...insertLines,
...sourceLines.slice(lineIndex + replaceCount)
].join('\n')
markdownValue.value = insertMarkdownLinesAtSlashTarget(markdownValue.value, lineIndex, insertLines)
}
const onPreviewMergeWithPreviousLine = ({ lineIndex, mergedLine }) => {