fix: Retain title attribute when parsing from Markdown sources

This commit is contained in:
Tom Moor
2022-12-30 15:54:31 -05:00
parent c6c06ac4ce
commit 2e36ad9d1f

View File

@@ -68,6 +68,9 @@ export default class Link extends Mark {
href: {
default: "",
},
title: {
default: null,
},
},
inclusive: false,
parseDOM: [
@@ -75,6 +78,7 @@ export default class Link extends Mark {
tag: "a[href]",
getAttrs: (dom: HTMLElement) => ({
href: dom.getAttribute("href"),
title: dom.getAttribute("title"),
}),
},
],
@@ -315,9 +319,9 @@ export default class Link extends Mark {
parseMarkdown() {
return {
mark: "link",
getAttrs: (tok: Token) => ({
href: tok.attrGet("href"),
title: tok.attrGet("title") || null,
getAttrs: (token: Token) => ({
href: token.attrGet("href"),
title: token.attrGet("title") || null,
}),
};
}