v1.4.7: 라이브 인라인 서식·인용 배경·소스→라이브 스크롤 보정

- 라이브 모드 blur 시 인라인 마크다운(**·*)이 사라지던 문제 수정
- 인용 블록에 > [!bg=색상] 옵션으로 콜아웃과 동일한 배경 프리셋 지정
- 소스 모드에서 라이브 전환 시 현재 커서 줄을 화면 중앙에 가깝게 스크롤
This commit is contained in:
2026-05-26 10:07:01 +09:00
parent dcd1060ec7
commit 6536465b12
9 changed files with 222 additions and 38 deletions

View File

@@ -256,6 +256,30 @@ function* iterateEditableTextUnits(root) {
}
}
/**
* contenteditable 루트의 단일 자식 노드를 마크다운 인라인 문자열로 직렬화한다.
* @param {Node} node - 자식 노드
* @returns {string} 마크다운 조각
*/
const readEditableChildNodeToMarkdown = (node) => {
if (node.nodeType === Node.TEXT_NODE) {
return node.textContent || ''
}
if (node.nodeType !== Node.ELEMENT_NODE) {
return ''
}
const element = /** @type {HTMLElement} */ (node)
const tagName = element.tagName.toLowerCase()
if (tagName === 'br') {
return '\n'
}
return convertHtmlInlineNodeToMarkdown(element)
}
/**
* contenteditable 루트에서 텍스트를 읽는다.
* @param {HTMLElement} root - contenteditable 루트
@@ -268,13 +292,14 @@ export const readEditableTextFromElement = (root) => {
const parts = []
for (const unit of iterateEditableTextUnits(root)) {
if (unit.kind === 'text') {
parts.push(unit.node?.textContent || '')
continue
for (let index = 0; index < root.childNodes.length; index += 1) {
const node = root.childNodes[index]
if (node.nodeType === Node.ELEMENT_NODE && isEditableBlockBreak(/** @type {HTMLElement} */ (node), root) && index > 0) {
parts.push('\n')
}
parts.push('\n')
parts.push(readEditableChildNodeToMarkdown(node))
}
return parts.join('').replace(/\u00a0/g, ' ').trimEnd()