관리자 슬래시 명령 적용 계획 분리
This commit is contained in:
@@ -242,6 +242,45 @@ export const getMediaPickerKindFromSlashAction = (action) => {
|
||||
return normalized.slice('media-'.length)
|
||||
}
|
||||
|
||||
/**
|
||||
* 슬래시 명령 적용 계획을 계산한다.
|
||||
* @param {Object} options - 계산 옵션
|
||||
* @param {MarkdownSlashCommand|null|undefined} options.command - 적용할 명령
|
||||
* @param {number|null} options.sourceLine - 명령이 입력된 줄 번호
|
||||
* @returns {{ kind: 'none' }|{ kind: 'media', line: number, mediaKind: 'image'|'gallery'|'video'|'audio'|'file' }|{ kind: 'lines', line: number, lines: string[] }} 적용 계획
|
||||
*/
|
||||
export const createSlashCommandApplyPlan = ({ command, sourceLine }) => {
|
||||
if (!command || !Number.isFinite(sourceLine)) {
|
||||
return { kind: 'none' }
|
||||
}
|
||||
|
||||
const line = Math.max(0, Math.floor(sourceLine))
|
||||
|
||||
if (isMediaSlashAction(command.action)) {
|
||||
const mediaKind = getMediaPickerKindFromSlashAction(command.action)
|
||||
|
||||
if (!mediaKind) {
|
||||
return { kind: 'none' }
|
||||
}
|
||||
|
||||
return {
|
||||
kind: 'media',
|
||||
line,
|
||||
mediaKind
|
||||
}
|
||||
}
|
||||
|
||||
if (command.action === 'lines' && Array.isArray(command.lines)) {
|
||||
return {
|
||||
kind: 'lines',
|
||||
line,
|
||||
lines: [...command.lines]
|
||||
}
|
||||
}
|
||||
|
||||
return { kind: 'none' }
|
||||
}
|
||||
|
||||
/**
|
||||
* 슬래시 메뉴를 다시 열지 않을 줄 목록에 줄을 추가한다.
|
||||
* @param {Set<number>} suppressedLines - 기존 제외 줄 Set
|
||||
|
||||
Reference in New Issue
Block a user