블록 설정 패널 확장 v1.5.37

This commit is contained in:
2026-06-02 16:13:38 +09:00
parent 093d09c8bf
commit ba17e3aa18
14 changed files with 538 additions and 28 deletions

View File

@@ -14,7 +14,9 @@ import {
parseSlashInput,
resolveSlashCommand
} from '../../lib/markdown-slash-commands.js'
import { CALLOUT_BACKGROUND_OPTIONS } from '../../lib/markdown-callout.js'
import { buildCalloutOpenerLine, CALLOUT_BACKGROUND_OPTIONS } from '../../lib/markdown-callout.js'
import { buildCodeFenceOpener } from '../../lib/markdown-code-block.js'
import { buildToggleOpenerLine } from '../../lib/markdown-toggle.js'
import { getTextareaCaretCoordinates } from '../../lib/textarea-caret-coordinates.js'
import {
buildDefaultUploadSizeLimits,
@@ -1212,7 +1214,7 @@ const createMediaBlockMarkdown = (blockType, item) => {
return [
':::file',
`url=${item.url}`,
`title=${title}`,
`title=${item.name || title}`,
'description=',
`name=${item.name || title}`,
`size=${formatMediaFileSize(item.size)}`,
@@ -2107,6 +2109,82 @@ const updateActiveQuoteBackground = (background) => {
markdownValue.value = nextLines.join('\n')
}
/**
* 현재 콜아웃 블록 옵션을 수정한다.
* @param {Partial<{ calloutEmojiEnabled: boolean, calloutEmoji: string, calloutBackground: string }>} patch - 변경 옵션
* @returns {void}
*/
const updateActiveCalloutOptions = (patch = {}) => {
const block = activeBlockContext.value
if (!block || block.kind !== 'callout') {
return
}
ensureBlockPanelEngaged()
const nextBackground = CALLOUT_BACKGROUND_OPTIONS.includes(patch.calloutBackground)
? patch.calloutBackground
: block.calloutBackground
const nextLine = buildCalloutOpenerLine({
calloutEmojiEnabled: patch.calloutEmojiEnabled ?? block.calloutEmojiEnabled,
calloutEmoji: patch.calloutEmoji ?? block.calloutEmoji,
calloutBackground: nextBackground
})
const lines = (markdownValue.value || '').split('\n')
const nextLines = [...lines]
nextLines.splice(block.startLine, 1, nextLine)
markdownValue.value = nextLines.join('\n')
}
/**
* 현재 코드 블록 옵션을 수정한다.
* @param {Partial<{ language: string, showLineNumbers: boolean }>} patch - 변경 옵션
* @returns {void}
*/
const updateActiveCodeOptions = (patch = {}) => {
const block = activeBlockContext.value
if (!block || block.kind !== 'code') {
return
}
ensureBlockPanelEngaged()
const nextLine = buildCodeFenceOpener({
language: patch.language ?? block.language,
showLineNumbers: patch.showLineNumbers ?? block.showLineNumbers
})
const lines = (markdownValue.value || '').split('\n')
const nextLines = [...lines]
nextLines.splice(block.startLine, 1, nextLine)
markdownValue.value = nextLines.join('\n')
}
/**
* 현재 토글 블록 옵션을 수정한다.
* @param {Partial<{ defaultOpen: boolean }>} patch - 변경 옵션
* @returns {void}
*/
const updateActiveToggleOptions = (patch = {}) => {
const block = activeBlockContext.value
if (!block || block.kind !== 'toggle') {
return
}
ensureBlockPanelEngaged()
const nextLine = buildToggleOpenerLine({
title: block.title,
defaultOpen: patch.defaultOpen ?? block.defaultOpen
})
const lines = (markdownValue.value || '').split('\n')
const nextLines = [...lines]
nextLines.splice(block.startLine, 1, nextLine)
markdownValue.value = nextLines.join('\n')
}
/**
* 이미지 마크다운을 삽입한다.
* @param {{ url: string, alt?: string, width?: string }} image - 이미지 정보
@@ -2174,6 +2252,9 @@ defineExpose({
appendImagesToActiveGallery,
updateActiveEmbedUrl,
updateActiveQuoteBackground,
updateActiveCalloutOptions,
updateActiveCodeOptions,
updateActiveToggleOptions,
openMediaPicker
})