Files
outline/shared/editor/nodes/BulletList.ts
Tom Moor bf45e97641 chore: Enforce type import consistency (#10968)
* Update types

* fix circular dep

* type imports

* lint type imports and --fix
2025-12-19 23:07:02 -05:00

48 lines
1.2 KiB
TypeScript

import type {
Schema,
NodeType,
NodeSpec,
Node as ProsemirrorModel,
} from "prosemirror-model";
import toggleList from "../commands/toggleList";
import type { MarkdownSerializerState } from "../lib/markdown/serializer";
import { listWrappingInputRule } from "../lib/listInputRule";
import Node from "./Node";
export default class BulletList extends Node {
get name() {
return "bullet_list";
}
get schema(): NodeSpec {
return {
content: "list_item+",
group: "block list",
parseDOM: [{ tag: "ul" }],
toDOM: () => ["ul", 0],
};
}
commands({ type, schema }: { type: NodeType; schema: Schema }) {
return () => toggleList(type, schema.nodes.list_item);
}
keys({ type, schema }: { type: NodeType; schema: Schema }) {
return {
"Shift-Ctrl-8": toggleList(type, schema.nodes.list_item),
};
}
inputRules({ type }: { type: NodeType }) {
return [listWrappingInputRule(/^\s*([-+*])\s$/, type)];
}
toMarkdown(state: MarkdownSerializerState, node: ProsemirrorModel) {
state.renderList(node, " ", () => (node.attrs.bullet || "*") + " ");
}
parseMarkdown() {
return { block: "bullet_list" };
}
}