v1.2.5: 갤러리 드롭 위치 표시 및 파일명 캡션 토글 정리

미리보기 갤러리 드래그 시 드롭 대상 셀을 시각적으로 표시하고, 파일명 토글을 캡션(figcaption) 표시로 맞춤. 미리보기 클릭→작성 모드 전환은 제거.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-05-15 19:00:26 +09:00
parent c9b484e4c8
commit 0c051cbe3b
7 changed files with 226 additions and 59 deletions

View File

@@ -71,14 +71,17 @@ export const parseImageMarkdownLine = (line) => {
const altBracket = (match[1] || '').trim()
const quotedCaption = unescapeImageCaption(match[3])
const filenameAlt = getImageDefaultAltLabel(url)
/** 대괄호 안 문자열이 URL 파일명과 같을 때 파일명 대체 텍스트 모드 */
const useAlt = altBracket !== ''
&& normalizeFilenameLabel(altBracket) === normalizeFilenameLabel(filenameAlt)
/** 레거시 `![파일명](url)` 또는 따옴표 캡션이 URL 파일명과 같을 때 파일명 캡션 모드 */
const useAlt = (altBracket !== ''
&& normalizeFilenameLabel(altBracket) === normalizeFilenameLabel(filenameAlt))
|| (quotedCaption !== ''
&& altBracket === ''
&& normalizeFilenameLabel(quotedCaption) === normalizeFilenameLabel(filenameAlt))
return {
url,
/** `![](url "캡션")` 따옴표 캡션만 편집 필드에 반영 */
caption: quotedCaption,
/** `![](url "캡션")` — 파일명 캡션 모드면 편집 필드에 파일명 반영 */
caption: quotedCaption || (useAlt ? filenameAlt : ''),
/** 레거시 `![표시문구](url)` — 캡션 따옴표 없을 때 미리보기용 */
legacyBracketLabel: !quotedCaption && altBracket && !useAlt ? altBracket : '',
width: match[4] || 'regular',
@@ -98,12 +101,17 @@ export const serializeImageMarkdown = (image) => {
return ''
}
const alt = image.useAlt === true ? getImageDefaultAltLabel(url) : ''
const caption = String(image.caption ?? '').trim()
const filename = getImageDefaultAltLabel(url)
let caption = String(image.caption ?? '').trim()
if (image.useAlt === true && !caption) {
caption = filename
}
const titlePart = caption ? ` "${escapeImageCaption(caption)}"` : ''
const width = image.width && image.width !== 'regular' ? `{width=${image.width}}` : ''
return `![${alt}](${url}${titlePart})${width}`
return `![](${url}${titlePart})${width}`
}
/**
@@ -111,13 +119,7 @@ export const serializeImageMarkdown = (image) => {
* @param {{ url?: string, useAlt?: boolean }} image - 이미지 정보
* @returns {string} alt 속성값
*/
export const getImageAltAttribute = (image) => {
if (!image?.useAlt) {
return ''
}
return getImageDefaultAltLabel(image.url)
}
export const getImageAltAttribute = () => ''
/**
* 공개 렌더용 캡션(표시용 figcaption)
@@ -132,7 +134,7 @@ export const getImageCaption = (image) => {
}
if (image?.useAlt) {
return ''
return getImageDefaultAltLabel(image.url)
}
return String(image?.legacyBracketLabel || '').trim()