슬래시 명령 효과 계획 분리
This commit is contained in:
@@ -296,6 +296,38 @@ export const createSlashCommandApplyPlan = ({ command, sourceLine }) => {
|
||||
return { kind: 'none' }
|
||||
}
|
||||
|
||||
/**
|
||||
* 슬래시 명령 적용 후 에디터가 실행할 부수 효과 계획을 계산한다.
|
||||
* @param {Object} options - 계산 옵션
|
||||
* @param {{ kind: 'none' }|{ kind: 'media', line: number, mediaKind: 'image'|'gallery'|'video'|'audio'|'file' }|{ kind: 'lines', line: number, lines: string[] }} options.plan - 슬래시 명령 적용 계획
|
||||
* @param {string} options.activeMode - 현재 에디터 모드
|
||||
* @returns {{ kind: 'none' }|{ kind: 'media', line: number, mediaKind: 'image'|'gallery'|'video'|'audio'|'file' }|{ kind: 'lines', line: number, lines: string[], focusTarget: 'textarea'|'preview' }} 에디터 부수 효과 계획
|
||||
*/
|
||||
export const createSlashCommandEditorEffectPlan = ({ plan, activeMode }) => {
|
||||
if (!plan || plan.kind === 'none') {
|
||||
return { kind: 'none' }
|
||||
}
|
||||
|
||||
if (plan.kind === 'media' && Number.isFinite(plan.line) && plan.mediaKind) {
|
||||
return {
|
||||
kind: 'media',
|
||||
line: plan.line,
|
||||
mediaKind: plan.mediaKind
|
||||
}
|
||||
}
|
||||
|
||||
if (plan.kind === 'lines' && Number.isFinite(plan.line) && Array.isArray(plan.lines)) {
|
||||
return {
|
||||
kind: 'lines',
|
||||
line: plan.line,
|
||||
lines: [...plan.lines],
|
||||
focusTarget: activeMode === 'write' ? 'textarea' : 'preview'
|
||||
}
|
||||
}
|
||||
|
||||
return { kind: 'none' }
|
||||
}
|
||||
|
||||
/**
|
||||
* 슬래시 메뉴를 다시 열지 않을 줄 목록에 줄을 추가한다.
|
||||
* @param {Set<number>} suppressedLines - 기존 제외 줄 Set
|
||||
|
||||
Reference in New Issue
Block a user