Skip to content

Commit 8ff7d1d

Browse files
committed
wire up the rest of the switch from NodeView to ToDOM()
1 parent bb9b59f commit 8ff7d1d

5 files changed

Lines changed: 18 additions & 56 deletions

File tree

src/rich-text/editor.ts

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ import { stackOverflowMarkdownSerializer } from "../shared/markdown-serializer";
2929
import { CodeBlockView } from "./node-views/code-block";
3030
import { HtmlBlock, HtmlBlockContainer } from "./node-views/html-block";
3131
import { ImageView } from "./node-views/image";
32-
import { TagLink } from "./node-views/tag-link";
3332
import { richTextCodePasteHandler } from "../shared/prosemirror-plugins/code-paste-handler";
3433
import { linkPasteHandler } from "./plugins/link-paste-handler";
3534
import { linkPreviewPlugin, LinkPreviewProvider } from "./plugins/link-preview";
@@ -97,7 +96,6 @@ export class RichTextEditor extends BaseView {
9796
this.options.menuParentContainer
9897
);
9998

100-
const tagLinkOptions = this.options.parserFeatures.tagLinks;
10199
this.editorView = new EditorView(
102100
(node: HTMLElement) => {
103101
node.classList.add(...(this.options.classList || []));
@@ -158,9 +156,6 @@ export class RichTextEditor extends BaseView {
158156
) {
159157
return new ImageView(node, view, getPos);
160158
},
161-
tagLink: (node, view, getPos) => {
162-
return new TagLink(node, view, getPos, tagLinkOptions);
163-
},
164159
html_block: function (node: ProseMirrorNode) {
165160
return new HtmlBlock(node);
166161
},

src/rich-text/node-views/tag-link.ts

Lines changed: 0 additions & 41 deletions
This file was deleted.

src/rich-text/schema.ts

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -423,22 +423,29 @@ const nodes: {
423423
},
424424
},
425425

426-
// TODO should this be a mark instead?
427426
tagLink: {
428427
content: "text*",
429-
marks: "", // TODO should it accept marks?
428+
marks: "",
430429
atom: true, // TODO allow this to be editable
431430
inline: true,
432431
group: "inline",
433432
attrs: {
434-
tagName: { default: null },
435-
tagType: { default: "tag" },
433+
tagName: { default: null }, // TODO: remove?
434+
tagType: { default: "tag" }, // TODO: remove?
436435
href: { default: null },
437436
title: { default: null },
438-
additionalClasses: { default: null },
437+
additionalClasses: { default: "" },
439438
},
440439
toDOM(node) {
441-
// TODO
440+
return [
441+
"a",
442+
{
443+
href: node.attrs.href as string,
444+
title: node.attrs.title as string,
445+
class: "s-tag " + node.attrs.additionalClasses
446+
},
447+
node.attrs.tagName
448+
];
442449
},
443450
},
444451
};

src/shared/markdown-it/tag-link.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ function parse_tag_link(
3838
return false;
3939
}
4040

41-
const tagName = totalContent.slice(isMeta ? 10 : 5, -1);
41+
const tagName = totalContent.slice(isMeta ? 10 : 5, -1).trim();
4242

4343
// check that the tag name follows specific rules TODO better docs
4444
const validationRegex = options.allowNonAscii
@@ -75,8 +75,6 @@ function parse_tag_link(
7575
token.attrSet("additionalClasses", additionalClasses.join(" "));
7676
}
7777

78-
token.content = totalContent;
79-
8078
token = state.push("text", "", 0);
8179
token.content = tagName;
8280

src/shared/markdown-parser.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,10 +113,13 @@ const customMarkdownParserTokens: MarkdownParser["tokens"] = {
113113
},
114114

115115
tag_link: {
116-
block: "tagLink",
116+
block: "tagLink", // TODO: rename to "tag_link" to match others?
117117
getAttrs: (tok: Token) => ({
118118
tagName: tok.attrGet("tagName"),
119119
tagType: tok.attrGet("tagType"),
120+
href: tok.attrGet("href"),
121+
additionalClasses: tok.attrGet("additionalClasses"),
122+
title: tok.attrGet("title")
120123
}),
121124
},
122125

0 commit comments

Comments
 (0)