Fix: Markdown Nodes Inherit inline styles

This commit is contained in:
sub-hub
2024-05-06 14:04:00 +09:00
parent e1eaf08df8
commit 8f9f075cdb

View File

@@ -573,6 +573,12 @@ export function applyMarkdownToNode(node: Node) {
if (markdown !== text) {
const span = document.createElement('span');
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]))
}
(node as Element)?.replaceWith(span);
return
}