라이브 콜아웃 줄바꿈 보존 보강
This commit is contained in:
@@ -1480,6 +1480,29 @@ const replaceLineRange = (startLine, endLine, replacementLines, focusEditor = tr
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 현재 문서 기준 fenced 블록의 닫는 줄을 찾는다.
|
||||
* @param {number} startLine - 시작 줄
|
||||
* @param {number} fallbackEndLine - 기본 끝 줄
|
||||
* @returns {number} 보정된 끝 줄
|
||||
*/
|
||||
const resolveCurrentFencedBlockEndLine = (startLine, fallbackEndLine) => {
|
||||
const lines = (markdownValue.value || '').split('\n')
|
||||
const opener = lines[startLine]?.trim() ?? ''
|
||||
|
||||
if (opener.startsWith(':::')) {
|
||||
const closingLine = lines.findIndex((line, index) => index > startLine && line.trim() === ':::')
|
||||
return closingLine >= 0 ? closingLine : fallbackEndLine
|
||||
}
|
||||
|
||||
if (opener.startsWith('```')) {
|
||||
const closingLine = lines.findIndex((line, index) => index > startLine && line.trim().startsWith('```'))
|
||||
return closingLine >= 0 ? closingLine : fallbackEndLine
|
||||
}
|
||||
|
||||
return fallbackEndLine
|
||||
}
|
||||
|
||||
/**
|
||||
* 현재 미디어 블록을 이미지 목록 기준으로 다시 작성한다.
|
||||
* @param {Array<{ alt: string, url: string, width?: string }>} images - 이미지 목록
|
||||
@@ -1778,7 +1801,7 @@ const onPreviewBlockContentChange = ({ startLine, endLine, replacementLines }) =
|
||||
return
|
||||
}
|
||||
|
||||
replaceLineRange(startLine, endLine, replacementLines, false)
|
||||
replaceLineRange(startLine, resolveCurrentFencedBlockEndLine(startLine, endLine), replacementLines, false)
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user