라이브 코드 블록 패널 상태 수정
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user