DEV: Export Tag class to modify methods in plugin

This commit is contained in:
Vinoth Kannan 2018-08-01 15:10:15 +05:30
parent a115aae45f
commit 8556288397
1 changed files with 29 additions and 27 deletions

View File

@ -9,7 +9,7 @@ const msoListClasses = [
"MsoListParagraphCxSpLast" "MsoListParagraphCxSpLast"
]; ];
class Tag { export class Tag {
constructor(name, prefix = "", suffix = "", inline = false) { constructor(name, prefix = "", suffix = "", inline = false) {
this.name = name; this.name = name;
this.prefix = prefix; this.prefix = prefix;
@ -419,31 +419,33 @@ class Tag {
} }
} }
const tags = [ function tags() {
...Tag.blocks().map(b => Tag.block(b)), return [
...Tag.headings().map((h, i) => Tag.heading(h, i + 1)), ...Tag.blocks().map(b => Tag.block(b)),
...Tag.slices().map(s => Tag.slice(s, "\n")), ...Tag.headings().map((h, i) => Tag.heading(h, i + 1)),
...Tag.emphases().map(e => Tag.emphasis(e[0], e[1])), ...Tag.slices().map(s => Tag.slice(s, "\n")),
Tag.cell("td"), ...Tag.emphases().map(e => Tag.emphasis(e[0], e[1])),
Tag.cell("th"), Tag.cell("td"),
Tag.replace("br", "\n"), Tag.cell("th"),
Tag.replace("hr", "\n---\n"), Tag.replace("br", "\n"),
Tag.replace("head", ""), Tag.replace("hr", "\n---\n"),
Tag.keep("ins"), Tag.replace("head", ""),
Tag.keep("del"), Tag.keep("ins"),
Tag.keep("small"), Tag.keep("del"),
Tag.keep("big"), Tag.keep("small"),
Tag.keep("kbd"), Tag.keep("big"),
Tag.li(), Tag.keep("kbd"),
Tag.link(), Tag.li(),
Tag.image(), Tag.link(),
Tag.code(), Tag.image(),
Tag.blockquote(), Tag.code(),
Tag.table(), Tag.blockquote(),
Tag.tr(), Tag.table(),
Tag.ol(), Tag.tr(),
Tag.list("ul") Tag.ol(),
]; Tag.list("ul")
];
}
class Element { class Element {
constructor(element, parent, previous, next) { constructor(element, parent, previous, next) {
@ -472,7 +474,7 @@ class Element {
} }
tag() { tag() {
const tag = new (tags.filter(t => new t().name === this.name)[0] || Tag)(); const tag = new (tags().filter(t => new t().name === this.name)[0] || Tag)();
tag.element = this; tag.element = this;
return tag; return tag;
} }