슬래시 명령 커서 복원 계산 분리

This commit is contained in:
2026-07-27 11:22:51 +09:00
parent 736f7d24ec
commit 675c45092b
7 changed files with 77 additions and 9 deletions

View File

@@ -46,6 +46,7 @@ import {
import {
filterSlashCommands,
getSlashCommandFocusTarget,
getSlashCommandTextareaSelection,
insertMarkdownLinesAtSlashTarget,
isMediaSlashAction,
parseSlashInput,
@@ -2648,10 +2649,12 @@ const focusPreviewAfterSlashCommand = (line, replacementLines) => {
* @returns {void}
*/
const focusTextareaAfterSlashCommand = (line, replacementLines) => {
const value = markdownValue.value ?? ''
const lineStart = value.split('\n').slice(0, line).join('\n').length + (line > 0 ? 1 : 0)
const { offset } = getSlashCommandFocusTarget(line, replacementLines)
setTextareaSelection(lineStart + offset, lineStart + offset)
const selection = getSlashCommandTextareaSelection({
markdown: markdownValue.value ?? '',
startLine: line,
lines: replacementLines
})
setTextareaSelection(selection.start, selection.end)
}
/**