라이브 코드 블록 패널 상태 수정

This commit is contained in:
2026-06-09 15:59:51 +09:00
parent 4b18ee78f0
commit e6669439f3
9 changed files with 49 additions and 31 deletions

View File

@@ -304,34 +304,33 @@ const findCodeFenceEnd = (lines, startLine) => {
* @returns {{ kind: 'code', startLine: number, endLine: number, language: string, showLineNumbers: boolean }|null}
*/
const resolveCodeBlock = (lines, currentLine) => {
let codeStart = -1
for (let index = currentLine; index >= 0; index -= 1) {
if ((lines[index] || '').trim().startsWith('```')) {
codeStart = index
break
for (let index = 0; index <= currentLine; index += 1) {
if (!(lines[index] || '').trim().startsWith('```')) {
continue
}
const codeEnd = findCodeFenceEnd(lines, index)
if (codeEnd === -1) {
return null
}
if (currentLine >= index && currentLine <= codeEnd) {
const options = parseCodeFenceLine(lines[index]) || { language: '', showLineNumbers: true }
return {
kind: 'code',
startLine: index,
endLine: codeEnd,
language: options.language,
showLineNumbers: options.showLineNumbers
}
}
index = codeEnd
}
if (codeStart === -1) {
return null
}
const codeEnd = findCodeFenceEnd(lines, codeStart)
if (codeEnd === -1 || currentLine > codeEnd) {
return null
}
const options = parseCodeFenceLine(lines[codeStart]) || { language: '', showLineNumbers: true }
return {
kind: 'code',
startLine: codeStart,
endLine: codeEnd,
language: options.language,
showLineNumbers: options.showLineNumbers
}
return null
}
/**