chore: sync super markdown import implementation with lexical
This commit is contained in:
@@ -257,18 +257,15 @@ function importTextMatchTransformers(textNode_: TextNode, textMatchTransformers:
|
|||||||
|
|
||||||
const startIndex = match.index || 0
|
const startIndex = match.index || 0
|
||||||
const endIndex = startIndex + match[0].length
|
const endIndex = startIndex + match[0].length
|
||||||
let replaceNode, leftTextNode, rightTextNode
|
let replaceNode, newTextNode
|
||||||
|
|
||||||
if (startIndex === 0) {
|
if (startIndex === 0) {
|
||||||
;[replaceNode, textNode] = textNode.splitText(endIndex)
|
;[replaceNode, textNode] = textNode.splitText(endIndex)
|
||||||
} else {
|
} else {
|
||||||
;[leftTextNode, replaceNode, rightTextNode] = textNode.splitText(startIndex, endIndex)
|
;[, replaceNode, newTextNode] = textNode.splitText(startIndex, endIndex)
|
||||||
}
|
}
|
||||||
if (leftTextNode) {
|
if (newTextNode) {
|
||||||
importTextMatchTransformers(leftTextNode, textMatchTransformers)
|
importTextMatchTransformers(newTextNode, textMatchTransformers)
|
||||||
}
|
|
||||||
if (rightTextNode) {
|
|
||||||
textNode = rightTextNode
|
|
||||||
}
|
}
|
||||||
transformer.replace(replaceNode, match)
|
transformer.replace(replaceNode, match)
|
||||||
continue mainLoop
|
continue mainLoop
|
||||||
|
|||||||
Reference in New Issue
Block a user