Added markdown null check and reapply markdown in all cases

parent null check applyMarkdownToNode
This commit is contained in:
sub-hub
2024-05-06 17:10:26 +09:00
parent e204eeb385
commit 9b3571beeb
2 changed files with 7 additions and 10 deletions

View File

@@ -574,10 +574,12 @@ export function applyMarkdownToNode(node: Node) {
span.innerHTML = markdown;
// inherit inline style from the parent node
const parentStyle = (node.parentNode as HTMLElement).style;
for(let i=0;i<parentStyle.length;i++){
span.style.setProperty(parentStyle[i], parentStyle.getPropertyValue(parentStyle[i]))
}
const parentStyle = (node.parentNode as HTMLElement)?.style;
if(parentStyle){
for(let i=0;i<parentStyle.length;i++){
span.style.setProperty(parentStyle[i], parentStyle.getPropertyValue(parentStyle[i]))
}
}
(node as Element)?.replaceWith(span);
return
}