Fix: Markdown Nodes Inherit inline styles
This commit is contained in:
@@ -573,6 +573,12 @@ export function applyMarkdownToNode(node: Node) {
|
|||||||
if (markdown !== text) {
|
if (markdown !== text) {
|
||||||
const span = document.createElement('span');
|
const span = document.createElement('span');
|
||||||
span.innerHTML = markdown;
|
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);
|
(node as Element)?.replaceWith(span);
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user