슬래시 메뉴 재입력 억제 보정
This commit is contained in:
@@ -16,14 +16,15 @@ import {
|
||||
* liveSlashMenuRef: import('vue').Ref<HTMLElement|null>,
|
||||
* liveSlashInsertLine: import('vue').Ref<number|null>,
|
||||
* liveSlashSuppressedLines: import('vue').Ref<Set<number>>,
|
||||
* liveSlashSuppressedLineValues: import('vue').Ref<Record<string, string>>,
|
||||
* liveSlashKeyboardNav: import('vue').Ref<boolean>,
|
||||
* liveSlashVisible: import('vue').ComputedRef<boolean>,
|
||||
* liveSlashSuppressedLineList: import('vue').ComputedRef<number[]>,
|
||||
* visibleLiveSlashCommands: import('vue').ComputedRef<import('../lib/markdown-slash-commands.js').MarkdownSlashCommand[]>,
|
||||
* clearLiveSlashState: () => void,
|
||||
* openLiveSlashMenu: (sourceLine: number, query: string) => void,
|
||||
* isLiveSlashLineSuppressed: (line: number) => boolean,
|
||||
* suppressLiveSlashLine: (line: number) => void,
|
||||
* isLiveSlashLineSuppressed: (line: number, lineValue?: string) => boolean,
|
||||
* suppressLiveSlashLine: (line: number, lineValue?: string) => void,
|
||||
* releaseLiveSlashLine: (line: number) => void,
|
||||
* resetLiveSlashHighlightedIndex: () => void,
|
||||
* clampLiveSlashHighlightedIndex: (commandCount: number) => void,
|
||||
@@ -39,6 +40,7 @@ export const useAdminMarkdownSlashMenu = () => {
|
||||
const liveSlashMenuRef = ref(null)
|
||||
const liveSlashInsertLine = ref(null)
|
||||
const liveSlashSuppressedLines = ref(new Set())
|
||||
const liveSlashSuppressedLineValues = ref({})
|
||||
const liveSlashKeyboardNav = ref(false)
|
||||
let liveSlashKeyboardNavTimer = null
|
||||
|
||||
@@ -72,15 +74,35 @@ export const useAdminMarkdownSlashMenu = () => {
|
||||
* @param {number} line - 줄 번호
|
||||
* @returns {boolean} 억제 여부
|
||||
*/
|
||||
const isLiveSlashLineSuppressed = (line) => liveSlashSuppressedLines.value.has(line)
|
||||
const isLiveSlashLineSuppressed = (line, lineValue) => {
|
||||
if (!liveSlashSuppressedLines.value.has(line)) {
|
||||
return false
|
||||
}
|
||||
|
||||
const suppressedValue = liveSlashSuppressedLineValues.value[String(line)]
|
||||
|
||||
if (suppressedValue === undefined || lineValue === undefined) {
|
||||
return true
|
||||
}
|
||||
|
||||
return suppressedValue === lineValue
|
||||
}
|
||||
|
||||
/**
|
||||
* 지정 줄에서 슬래시 메뉴가 다시 열리지 않도록 억제한다.
|
||||
* @param {number} line - 줄 번호
|
||||
* @param {string} [lineValue] - 억제 당시 줄 내용
|
||||
* @returns {void}
|
||||
*/
|
||||
const suppressLiveSlashLine = (line) => {
|
||||
const suppressLiveSlashLine = (line, lineValue) => {
|
||||
liveSlashSuppressedLines.value = addSlashSuppressedLine(liveSlashSuppressedLines.value, line)
|
||||
|
||||
if (Number.isFinite(line)) {
|
||||
liveSlashSuppressedLineValues.value = {
|
||||
...liveSlashSuppressedLineValues.value,
|
||||
[String(line)]: String(lineValue ?? '')
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -90,6 +112,12 @@ export const useAdminMarkdownSlashMenu = () => {
|
||||
*/
|
||||
const releaseLiveSlashLine = (line) => {
|
||||
liveSlashSuppressedLines.value = removeSlashSuppressedLine(liveSlashSuppressedLines.value, line)
|
||||
|
||||
if (Number.isFinite(line)) {
|
||||
const nextValues = { ...liveSlashSuppressedLineValues.value }
|
||||
delete nextValues[String(line)]
|
||||
liveSlashSuppressedLineValues.value = nextValues
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -140,6 +168,7 @@ export const useAdminMarkdownSlashMenu = () => {
|
||||
liveSlashMenuRef,
|
||||
liveSlashInsertLine,
|
||||
liveSlashSuppressedLines,
|
||||
liveSlashSuppressedLineValues,
|
||||
liveSlashKeyboardNav,
|
||||
liveSlashVisible,
|
||||
liveSlashSuppressedLineList,
|
||||
|
||||
Reference in New Issue
Block a user