v1.2.2: 이미지 파일명 alt 판별 및 미리보기 캡션 분리 수정
대괄호 내용이 URL 파일명과 일치할 때만 useAlt로 처리해, 캡션과 대체 텍스트가 미리보기에서 혼동되지 않도록 했다. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -48,14 +48,21 @@ export const parseImageMarkdownLine = (line) => {
|
||||
return null
|
||||
}
|
||||
|
||||
const alt = match[1] || ''
|
||||
const url = match[2] || ''
|
||||
const altBracket = (match[1] || '').trim()
|
||||
const quotedCaption = unescapeImageCaption(match[3])
|
||||
const filenameAlt = getImageDefaultAltLabel(url)
|
||||
/** 대괄호 안 문자열이 URL 파일명과 같을 때만 파일명 대체 텍스트 모드 */
|
||||
const useAlt = altBracket !== '' && altBracket === filenameAlt
|
||||
|
||||
return {
|
||||
url: match[2] || '',
|
||||
caption: unescapeImageCaption(match[3]),
|
||||
url,
|
||||
/** `` 따옴표 캡션만 편집 필드에 반영 */
|
||||
caption: quotedCaption,
|
||||
/** 레거시 `` — 캡션 따옴표 없을 때 미리보기용 */
|
||||
legacyBracketLabel: !quotedCaption && altBracket && !useAlt ? altBracket : '',
|
||||
width: match[4] || 'regular',
|
||||
/** true이면 대체 텍스트로 URL 파일명을 사용한다 */
|
||||
useAlt: Boolean(alt)
|
||||
useAlt
|
||||
}
|
||||
}
|
||||
|
||||
@@ -97,4 +104,16 @@ export const getImageAltAttribute = (image) => {
|
||||
* @param {{ caption?: string }} image - 이미지 정보
|
||||
* @returns {string} 캡션
|
||||
*/
|
||||
export const getImageCaption = (image) => String(image?.caption || '').trim()
|
||||
export const getImageCaption = (image) => {
|
||||
const caption = String(image?.caption || '').trim()
|
||||
|
||||
if (caption) {
|
||||
return caption
|
||||
}
|
||||
|
||||
if (image?.useAlt) {
|
||||
return ''
|
||||
}
|
||||
|
||||
return String(image?.legacyBracketLabel || '').trim()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user