mirror of
https://github.com/outline/outline.git
synced 2026-06-13 11:25:03 +03:00
45c797653f
* wip * refactor * Potential fix for pull request finding Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> --------- Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
57 lines
1.2 KiB
TypeScript
57 lines
1.2 KiB
TypeScript
import type { MarkSpec, MarkType } from "prosemirror-model";
|
|
import { toggleMark } from "../commands/toggleMark";
|
|
import { markInputRuleForPattern } from "../lib/markInputRule";
|
|
import underlinesRule from "../rules/underlines";
|
|
import Mark from "./Mark";
|
|
|
|
export default class Underline extends Mark {
|
|
get name() {
|
|
return "underline";
|
|
}
|
|
|
|
get schema(): MarkSpec {
|
|
return {
|
|
parseDOM: [
|
|
{ tag: "u" },
|
|
{
|
|
consuming: false,
|
|
tag: ":not(a)",
|
|
getAttrs: (node: HTMLElement) =>
|
|
node.style.textDecoration.includes("underline") ||
|
|
node.style.textDecorationLine.includes("underline")
|
|
? null
|
|
: false,
|
|
},
|
|
],
|
|
toDOM: () => ["u", 0],
|
|
};
|
|
}
|
|
|
|
get rulePlugins() {
|
|
return [underlinesRule];
|
|
}
|
|
|
|
inputRules({ type }: { type: MarkType }) {
|
|
return [markInputRuleForPattern("__", type)];
|
|
}
|
|
|
|
keys({ type }: { type: MarkType }) {
|
|
return {
|
|
"Mod-u": toggleMark(type),
|
|
};
|
|
}
|
|
|
|
toMarkdown() {
|
|
return {
|
|
open: "__",
|
|
close: "__",
|
|
mixable: true,
|
|
expelEnclosingWhitespace: true,
|
|
};
|
|
}
|
|
|
|
parseMarkdown() {
|
|
return { mark: "underline" };
|
|
}
|
|
}
|