You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
48 lines
1.3 KiB
48 lines
1.3 KiB
3 years ago
|
import { Node, mergeAttributes, wrappingInputRule } from '@tiptap/core';
|
||
|
|
||
|
const inputRegex = /^\s*([-+*])\s$/;
|
||
|
const BulletList = Node.create({
|
||
|
name: 'bulletList',
|
||
|
addOptions() {
|
||
|
return {
|
||
|
itemTypeName: 'listItem',
|
||
|
HTMLAttributes: {},
|
||
|
};
|
||
|
},
|
||
|
group: 'block list',
|
||
|
content() {
|
||
|
return `${this.options.itemTypeName}+`;
|
||
|
},
|
||
|
parseHTML() {
|
||
|
return [
|
||
|
{ tag: 'ul' },
|
||
|
];
|
||
|
},
|
||
|
renderHTML({ HTMLAttributes }) {
|
||
|
return ['ul', mergeAttributes(this.options.HTMLAttributes, HTMLAttributes), 0];
|
||
|
},
|
||
|
addCommands() {
|
||
|
return {
|
||
|
toggleBulletList: () => ({ commands }) => {
|
||
|
return commands.toggleList(this.name, this.options.itemTypeName);
|
||
|
},
|
||
|
};
|
||
|
},
|
||
|
addKeyboardShortcuts() {
|
||
|
return {
|
||
|
'Mod-Shift-8': () => this.editor.commands.toggleBulletList(),
|
||
|
};
|
||
|
},
|
||
|
addInputRules() {
|
||
|
return [
|
||
|
wrappingInputRule({
|
||
|
find: inputRegex,
|
||
|
type: this.type,
|
||
|
}),
|
||
|
];
|
||
|
},
|
||
|
});
|
||
|
|
||
|
export { BulletList, BulletList as default, inputRegex };
|
||
|
//# sourceMappingURL=tiptap-extension-bullet-list.esm.js.map
|