Skip to content

Commit 5f8f4c9

Browse files
committed
implement parseDOM for tag links
1 parent 8ff7d1d commit 5f8f4c9

1 file changed

Lines changed: 19 additions & 3 deletions

File tree

src/rich-text/schema.ts

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -430,16 +430,32 @@ const nodes: {
430430
inline: true,
431431
group: "inline",
432432
attrs: {
433-
tagName: { default: null }, // TODO: remove?
434-
tagType: { default: "tag" }, // TODO: remove?
433+
tagName: { default: null },
434+
tagType: { default: "tag" },
435435
href: { default: null },
436436
title: { default: null },
437437
additionalClasses: { default: "" },
438438
},
439+
parseDOM: [
440+
{
441+
tag: "a.s-tag",
442+
getAttrs(dom: HTMLElement) {
443+
dom.classList.remove("s-tag");
444+
return {
445+
href: dom.getAttribute("href"),
446+
title: dom.getAttribute("title"),
447+
additionalClasses: Array.from(dom.classList).join(" "),
448+
tagType: dom.getAttribute("tagtype"),
449+
tagName: dom.textContent,
450+
}
451+
},
452+
},
453+
],
439454
toDOM(node) {
440455
return [
441456
"a",
442457
{
458+
tagType: node.attrs.tagType,
443459
href: node.attrs.href as string,
444460
title: node.attrs.title as string,
445461
class: "s-tag " + node.attrs.additionalClasses
@@ -492,7 +508,7 @@ const marks: {
492508
},
493509
parseDOM: [
494510
{
495-
tag: "a[href]",
511+
tag: "a[href]:not(.s-tag)",
496512
getAttrs(dom: HTMLElement) {
497513
return {
498514
href: dom.getAttribute("href"),

0 commit comments

Comments
 (0)