fix: types to insert list

This commit is contained in:
Palanikannan M
2024-10-22 13:06:37 +05:30
parent 1b9b59799e
commit ce99563a0d
2 changed files with 18 additions and 2 deletions

View File

@@ -1,12 +1,12 @@
import { Node } from "@tiptap/core";
import { createListSpec, createListPlugins, listKeymap, listInputRules } from "prosemirror-flat-list";
import { createListSpec, createListPlugins, listKeymap, listInputRules, ListAttributes } from "prosemirror-flat-list";
import { keymap } from "@tiptap/pm/keymap";
import { inputRules } from "@tiptap/pm/inputrules";
declare module "@tiptap/core" {
interface Commands<ReturnType> {
flatListComponent: {
toggleCustomList: (attrs: Record<string, any>) => ReturnType;
createList: (attrs: ListAttributes) => ReturnType;
};
}
}
@@ -30,6 +30,18 @@ export const FlatListExtension = Node.create({
renderHTML({ node }) {
return toDOM(node);
},
addCommands() {
return {
createList:
(attrs: ListAttributes) =>
({ commands }) =>
commands.insertContent({
type: this.name,
attrs,
}),
};
},
addProseMirrorPlugins() {
return [...createListPlugins({ schema: this.editor.schema }), listKeymapPlugin, listInputRulePlugin];
},

View File

@@ -444,3 +444,7 @@ ul[data-type="taskList"] ul[data-type="taskList"] {
background-color: var(--editor-colors-purple-background);
}
/* end background colors */
.prosemirror-flat-list > .list-marker {
top: 7px;
}