Files
outline/shared/editor/marks/Strikethrough.ts
Tom Moor 92b1c578f6 feat: Improve inline rule matching (#8085)
* stash

* fix: Allow inline mark matching to work with preceding brackets
Refactor markInputRule, add markInputRuleForPattern

* docs
2024-12-07 12:46:25 -08:00

59 lines
1.1 KiB
TypeScript

import { toggleMark } from "prosemirror-commands";
import { MarkSpec, MarkType } from "prosemirror-model";
import { markInputRuleForPattern } from "../lib/markInputRule";
import Mark from "./Mark";
export default class Strikethrough extends Mark {
get name() {
return "strikethrough";
}
get schema(): MarkSpec {
return {
parseDOM: [
{
tag: "s",
},
{
tag: "del",
},
{
tag: "strike",
},
{
style: "text-decoration",
getAttrs: (value) => (value === "line-through" ? null : false),
},
],
toDOM: () => ["del", 0],
};
}
keys({ type }: { type: MarkType }) {
return {
"Mod-d": toggleMark(type),
};
}
inputRules({ type }: { type: MarkType }) {
return [markInputRuleForPattern("~", type)];
}
toMarkdown() {
return {
open: "~~",
close: "~~",
mixable: true,
expelEnclosingWhitespace: true,
};
}
get markdownToken() {
return "s";
}
parseMarkdown() {
return { mark: "strikethrough" };
}
}