@tiptap/extension-bullet-list 3.0.0-next.4 → 3.0.0-next.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE.md CHANGED
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2024, Tiptap GmbH
3
+ Copyright (c) 2025, Tiptap GmbH
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
package/dist/index.cjs CHANGED
@@ -20,78 +20,17 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
20
20
  // src/index.ts
21
21
  var index_exports = {};
22
22
  __export(index_exports, {
23
- BulletList: () => BulletList,
24
- default: () => index_default,
25
- inputRegex: () => inputRegex
23
+ BulletList: () => import_extension_list2.BulletList,
24
+ BulletListOptions: () => import_extension_list2.BulletListOptions,
25
+ default: () => index_default
26
26
  });
27
27
  module.exports = __toCommonJS(index_exports);
28
-
29
- // src/bullet-list.ts
30
- var import_core = require("@tiptap/core");
31
- var ListItemName = "listItem";
32
- var TextStyleName = "textStyle";
33
- var inputRegex = /^\s*([-+*])\s$/;
34
- var BulletList = import_core.Node.create({
35
- name: "bulletList",
36
- addOptions() {
37
- return {
38
- itemTypeName: "listItem",
39
- HTMLAttributes: {},
40
- keepMarks: false,
41
- keepAttributes: false
42
- };
43
- },
44
- group: "block list",
45
- content() {
46
- return `${this.options.itemTypeName}+`;
47
- },
48
- parseHTML() {
49
- return [{ tag: "ul" }];
50
- },
51
- renderHTML({ HTMLAttributes }) {
52
- return ["ul", (0, import_core.mergeAttributes)(this.options.HTMLAttributes, HTMLAttributes), 0];
53
- },
54
- addCommands() {
55
- return {
56
- toggleBulletList: () => ({ commands, chain }) => {
57
- if (this.options.keepAttributes) {
58
- return chain().toggleList(this.name, this.options.itemTypeName, this.options.keepMarks).updateAttributes(ListItemName, this.editor.getAttributes(TextStyleName)).run();
59
- }
60
- return commands.toggleList(this.name, this.options.itemTypeName, this.options.keepMarks);
61
- }
62
- };
63
- },
64
- addKeyboardShortcuts() {
65
- return {
66
- "Mod-Shift-8": () => this.editor.commands.toggleBulletList()
67
- };
68
- },
69
- addInputRules() {
70
- let inputRule = (0, import_core.wrappingInputRule)({
71
- find: inputRegex,
72
- type: this.type
73
- });
74
- if (this.options.keepMarks || this.options.keepAttributes) {
75
- inputRule = (0, import_core.wrappingInputRule)({
76
- find: inputRegex,
77
- type: this.type,
78
- keepMarks: this.options.keepMarks,
79
- keepAttributes: this.options.keepAttributes,
80
- getAttributes: () => {
81
- return this.editor.getAttributes(TextStyleName);
82
- },
83
- editor: this.editor
84
- });
85
- }
86
- return [inputRule];
87
- }
88
- });
89
-
90
- // src/index.ts
91
- var index_default = BulletList;
28
+ var import_extension_list = require("@tiptap/extension-list");
29
+ var import_extension_list2 = require("@tiptap/extension-list");
30
+ var index_default = import_extension_list.BulletList;
92
31
  // Annotate the CommonJS export names for ESM import in node:
93
32
  0 && (module.exports = {
94
33
  BulletList,
95
- inputRegex
34
+ BulletListOptions
96
35
  });
97
36
  //# sourceMappingURL=index.cjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts","../src/bullet-list.ts"],"sourcesContent":["import { BulletList } from './bullet-list.js'\n\nexport * from './bullet-list.js'\n\nexport default BulletList\n","import { mergeAttributes, Node, wrappingInputRule } from '@tiptap/core'\n\nconst ListItemName = 'listItem'\nconst TextStyleName = 'textStyle'\n\nexport interface BulletListOptions {\n /**\n * The node name for the list items\n * @default 'listItem'\n * @example 'paragraph'\n */\n itemTypeName: string\n\n /**\n * HTML attributes to add to the bullet list element\n * @default {}\n * @example { class: 'foo' }\n */\n HTMLAttributes: Record<string, any>\n\n /**\n * Keep the marks when splitting the list\n * @default false\n * @example true\n */\n keepMarks: boolean\n\n /**\n * Keep the attributes when splitting the list\n * @default false\n * @example true\n */\n keepAttributes: boolean\n}\n\ndeclare module '@tiptap/core' {\n interface Commands<ReturnType> {\n bulletList: {\n /**\n * Toggle a bullet list\n */\n toggleBulletList: () => ReturnType\n }\n }\n}\n\n/**\n * Matches a bullet list to a dash or asterisk.\n */\nexport const inputRegex = /^\\s*([-+*])\\s$/\n\n/**\n * This extension allows you to create bullet lists.\n * This requires the ListItem extension\n * @see https://tiptap.dev/api/nodes/bullet-list\n * @see https://tiptap.dev/api/nodes/list-item.\n */\nexport const BulletList = Node.create<BulletListOptions>({\n name: 'bulletList',\n\n addOptions() {\n return {\n itemTypeName: 'listItem',\n HTMLAttributes: {},\n keepMarks: false,\n keepAttributes: false,\n }\n },\n\n group: 'block list',\n\n content() {\n return `${this.options.itemTypeName}+`\n },\n\n parseHTML() {\n return [{ tag: 'ul' }]\n },\n\n renderHTML({ HTMLAttributes }) {\n return ['ul', mergeAttributes(this.options.HTMLAttributes, HTMLAttributes), 0]\n },\n\n addCommands() {\n return {\n toggleBulletList:\n () =>\n ({ commands, chain }) => {\n if (this.options.keepAttributes) {\n return chain()\n .toggleList(this.name, this.options.itemTypeName, this.options.keepMarks)\n .updateAttributes(ListItemName, this.editor.getAttributes(TextStyleName))\n .run()\n }\n return commands.toggleList(this.name, this.options.itemTypeName, this.options.keepMarks)\n },\n }\n },\n\n addKeyboardShortcuts() {\n return {\n 'Mod-Shift-8': () => this.editor.commands.toggleBulletList(),\n }\n },\n\n addInputRules() {\n let inputRule = wrappingInputRule({\n find: inputRegex,\n type: this.type,\n })\n\n if (this.options.keepMarks || this.options.keepAttributes) {\n inputRule = wrappingInputRule({\n find: inputRegex,\n type: this.type,\n keepMarks: this.options.keepMarks,\n keepAttributes: this.options.keepAttributes,\n getAttributes: () => {\n return this.editor.getAttributes(TextStyleName)\n },\n editor: this.editor,\n })\n }\n return [inputRule]\n },\n})\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,kBAAyD;AAEzD,IAAM,eAAe;AACrB,IAAM,gBAAgB;AA8Cf,IAAM,aAAa;AAQnB,IAAM,aAAa,iBAAK,OAA0B;AAAA,EACvD,MAAM;AAAA,EAEN,aAAa;AACX,WAAO;AAAA,MACL,cAAc;AAAA,MACd,gBAAgB,CAAC;AAAA,MACjB,WAAW;AAAA,MACX,gBAAgB;AAAA,IAClB;AAAA,EACF;AAAA,EAEA,OAAO;AAAA,EAEP,UAAU;AACR,WAAO,GAAG,KAAK,QAAQ,YAAY;AAAA,EACrC;AAAA,EAEA,YAAY;AACV,WAAO,CAAC,EAAE,KAAK,KAAK,CAAC;AAAA,EACvB;AAAA,EAEA,WAAW,EAAE,eAAe,GAAG;AAC7B,WAAO,CAAC,UAAM,6BAAgB,KAAK,QAAQ,gBAAgB,cAAc,GAAG,CAAC;AAAA,EAC/E;AAAA,EAEA,cAAc;AACZ,WAAO;AAAA,MACL,kBACE,MACA,CAAC,EAAE,UAAU,MAAM,MAAM;AACvB,YAAI,KAAK,QAAQ,gBAAgB;AAC/B,iBAAO,MAAM,EACV,WAAW,KAAK,MAAM,KAAK,QAAQ,cAAc,KAAK,QAAQ,SAAS,EACvE,iBAAiB,cAAc,KAAK,OAAO,cAAc,aAAa,CAAC,EACvE,IAAI;AAAA,QACT;AACA,eAAO,SAAS,WAAW,KAAK,MAAM,KAAK,QAAQ,cAAc,KAAK,QAAQ,SAAS;AAAA,MACzF;AAAA,IACJ;AAAA,EACF;AAAA,EAEA,uBAAuB;AACrB,WAAO;AAAA,MACL,eAAe,MAAM,KAAK,OAAO,SAAS,iBAAiB;AAAA,IAC7D;AAAA,EACF;AAAA,EAEA,gBAAgB;AACd,QAAI,gBAAY,+BAAkB;AAAA,MAChC,MAAM;AAAA,MACN,MAAM,KAAK;AAAA,IACb,CAAC;AAED,QAAI,KAAK,QAAQ,aAAa,KAAK,QAAQ,gBAAgB;AACzD,sBAAY,+BAAkB;AAAA,QAC5B,MAAM;AAAA,QACN,MAAM,KAAK;AAAA,QACX,WAAW,KAAK,QAAQ;AAAA,QACxB,gBAAgB,KAAK,QAAQ;AAAA,QAC7B,eAAe,MAAM;AACnB,iBAAO,KAAK,OAAO,cAAc,aAAa;AAAA,QAChD;AAAA,QACA,QAAQ,KAAK;AAAA,MACf,CAAC;AAAA,IACH;AACA,WAAO,CAAC,SAAS;AAAA,EACnB;AACF,CAAC;;;ADzHD,IAAO,gBAAQ;","names":[]}
1
+ {"version":3,"sources":["../src/index.ts"],"sourcesContent":["import { BulletList } from '@tiptap/extension-list'\n\nexport { BulletList, BulletListOptions } from '@tiptap/extension-list'\n\nexport default BulletList\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,4BAA2B;AAE3B,IAAAA,yBAA8C;AAE9C,IAAO,gBAAQ;","names":["import_extension_list"]}
package/dist/index.d.cts CHANGED
@@ -1,51 +1,2 @@
1
- import { Node } from '@tiptap/core';
2
-
3
- interface BulletListOptions {
4
- /**
5
- * The node name for the list items
6
- * @default 'listItem'
7
- * @example 'paragraph'
8
- */
9
- itemTypeName: string;
10
- /**
11
- * HTML attributes to add to the bullet list element
12
- * @default {}
13
- * @example { class: 'foo' }
14
- */
15
- HTMLAttributes: Record<string, any>;
16
- /**
17
- * Keep the marks when splitting the list
18
- * @default false
19
- * @example true
20
- */
21
- keepMarks: boolean;
22
- /**
23
- * Keep the attributes when splitting the list
24
- * @default false
25
- * @example true
26
- */
27
- keepAttributes: boolean;
28
- }
29
- declare module '@tiptap/core' {
30
- interface Commands<ReturnType> {
31
- bulletList: {
32
- /**
33
- * Toggle a bullet list
34
- */
35
- toggleBulletList: () => ReturnType;
36
- };
37
- }
38
- }
39
- /**
40
- * Matches a bullet list to a dash or asterisk.
41
- */
42
- declare const inputRegex: RegExp;
43
- /**
44
- * This extension allows you to create bullet lists.
45
- * This requires the ListItem extension
46
- * @see https://tiptap.dev/api/nodes/bullet-list
47
- * @see https://tiptap.dev/api/nodes/list-item.
48
- */
49
- declare const BulletList: Node<BulletListOptions, any>;
50
-
51
- export { BulletList, type BulletListOptions, BulletList as default, inputRegex };
1
+ import { BulletList } from '@tiptap/extension-list';
2
+ export { BulletList, BulletListOptions, BulletList as default } from '@tiptap/extension-list';
package/dist/index.d.ts CHANGED
@@ -1,51 +1,2 @@
1
- import { Node } from '@tiptap/core';
2
-
3
- interface BulletListOptions {
4
- /**
5
- * The node name for the list items
6
- * @default 'listItem'
7
- * @example 'paragraph'
8
- */
9
- itemTypeName: string;
10
- /**
11
- * HTML attributes to add to the bullet list element
12
- * @default {}
13
- * @example { class: 'foo' }
14
- */
15
- HTMLAttributes: Record<string, any>;
16
- /**
17
- * Keep the marks when splitting the list
18
- * @default false
19
- * @example true
20
- */
21
- keepMarks: boolean;
22
- /**
23
- * Keep the attributes when splitting the list
24
- * @default false
25
- * @example true
26
- */
27
- keepAttributes: boolean;
28
- }
29
- declare module '@tiptap/core' {
30
- interface Commands<ReturnType> {
31
- bulletList: {
32
- /**
33
- * Toggle a bullet list
34
- */
35
- toggleBulletList: () => ReturnType;
36
- };
37
- }
38
- }
39
- /**
40
- * Matches a bullet list to a dash or asterisk.
41
- */
42
- declare const inputRegex: RegExp;
43
- /**
44
- * This extension allows you to create bullet lists.
45
- * This requires the ListItem extension
46
- * @see https://tiptap.dev/api/nodes/bullet-list
47
- * @see https://tiptap.dev/api/nodes/list-item.
48
- */
49
- declare const BulletList: Node<BulletListOptions, any>;
50
-
51
- export { BulletList, type BulletListOptions, BulletList as default, inputRegex };
1
+ import { BulletList } from '@tiptap/extension-list';
2
+ export { BulletList, BulletListOptions, BulletList as default } from '@tiptap/extension-list';
package/dist/index.js CHANGED
@@ -1,69 +1,10 @@
1
- // src/bullet-list.ts
2
- import { mergeAttributes, Node, wrappingInputRule } from "@tiptap/core";
3
- var ListItemName = "listItem";
4
- var TextStyleName = "textStyle";
5
- var inputRegex = /^\s*([-+*])\s$/;
6
- var BulletList = Node.create({
7
- name: "bulletList",
8
- addOptions() {
9
- return {
10
- itemTypeName: "listItem",
11
- HTMLAttributes: {},
12
- keepMarks: false,
13
- keepAttributes: false
14
- };
15
- },
16
- group: "block list",
17
- content() {
18
- return `${this.options.itemTypeName}+`;
19
- },
20
- parseHTML() {
21
- return [{ tag: "ul" }];
22
- },
23
- renderHTML({ HTMLAttributes }) {
24
- return ["ul", mergeAttributes(this.options.HTMLAttributes, HTMLAttributes), 0];
25
- },
26
- addCommands() {
27
- return {
28
- toggleBulletList: () => ({ commands, chain }) => {
29
- if (this.options.keepAttributes) {
30
- return chain().toggleList(this.name, this.options.itemTypeName, this.options.keepMarks).updateAttributes(ListItemName, this.editor.getAttributes(TextStyleName)).run();
31
- }
32
- return commands.toggleList(this.name, this.options.itemTypeName, this.options.keepMarks);
33
- }
34
- };
35
- },
36
- addKeyboardShortcuts() {
37
- return {
38
- "Mod-Shift-8": () => this.editor.commands.toggleBulletList()
39
- };
40
- },
41
- addInputRules() {
42
- let inputRule = wrappingInputRule({
43
- find: inputRegex,
44
- type: this.type
45
- });
46
- if (this.options.keepMarks || this.options.keepAttributes) {
47
- inputRule = wrappingInputRule({
48
- find: inputRegex,
49
- type: this.type,
50
- keepMarks: this.options.keepMarks,
51
- keepAttributes: this.options.keepAttributes,
52
- getAttributes: () => {
53
- return this.editor.getAttributes(TextStyleName);
54
- },
55
- editor: this.editor
56
- });
57
- }
58
- return [inputRule];
59
- }
60
- });
61
-
62
1
  // src/index.ts
2
+ import { BulletList } from "@tiptap/extension-list";
3
+ import { BulletList as BulletList2, BulletListOptions } from "@tiptap/extension-list";
63
4
  var index_default = BulletList;
64
5
  export {
65
- BulletList,
66
- index_default as default,
67
- inputRegex
6
+ BulletList2 as BulletList,
7
+ BulletListOptions,
8
+ index_default as default
68
9
  };
69
10
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/bullet-list.ts","../src/index.ts"],"sourcesContent":["import { mergeAttributes, Node, wrappingInputRule } from '@tiptap/core'\n\nconst ListItemName = 'listItem'\nconst TextStyleName = 'textStyle'\n\nexport interface BulletListOptions {\n /**\n * The node name for the list items\n * @default 'listItem'\n * @example 'paragraph'\n */\n itemTypeName: string\n\n /**\n * HTML attributes to add to the bullet list element\n * @default {}\n * @example { class: 'foo' }\n */\n HTMLAttributes: Record<string, any>\n\n /**\n * Keep the marks when splitting the list\n * @default false\n * @example true\n */\n keepMarks: boolean\n\n /**\n * Keep the attributes when splitting the list\n * @default false\n * @example true\n */\n keepAttributes: boolean\n}\n\ndeclare module '@tiptap/core' {\n interface Commands<ReturnType> {\n bulletList: {\n /**\n * Toggle a bullet list\n */\n toggleBulletList: () => ReturnType\n }\n }\n}\n\n/**\n * Matches a bullet list to a dash or asterisk.\n */\nexport const inputRegex = /^\\s*([-+*])\\s$/\n\n/**\n * This extension allows you to create bullet lists.\n * This requires the ListItem extension\n * @see https://tiptap.dev/api/nodes/bullet-list\n * @see https://tiptap.dev/api/nodes/list-item.\n */\nexport const BulletList = Node.create<BulletListOptions>({\n name: 'bulletList',\n\n addOptions() {\n return {\n itemTypeName: 'listItem',\n HTMLAttributes: {},\n keepMarks: false,\n keepAttributes: false,\n }\n },\n\n group: 'block list',\n\n content() {\n return `${this.options.itemTypeName}+`\n },\n\n parseHTML() {\n return [{ tag: 'ul' }]\n },\n\n renderHTML({ HTMLAttributes }) {\n return ['ul', mergeAttributes(this.options.HTMLAttributes, HTMLAttributes), 0]\n },\n\n addCommands() {\n return {\n toggleBulletList:\n () =>\n ({ commands, chain }) => {\n if (this.options.keepAttributes) {\n return chain()\n .toggleList(this.name, this.options.itemTypeName, this.options.keepMarks)\n .updateAttributes(ListItemName, this.editor.getAttributes(TextStyleName))\n .run()\n }\n return commands.toggleList(this.name, this.options.itemTypeName, this.options.keepMarks)\n },\n }\n },\n\n addKeyboardShortcuts() {\n return {\n 'Mod-Shift-8': () => this.editor.commands.toggleBulletList(),\n }\n },\n\n addInputRules() {\n let inputRule = wrappingInputRule({\n find: inputRegex,\n type: this.type,\n })\n\n if (this.options.keepMarks || this.options.keepAttributes) {\n inputRule = wrappingInputRule({\n find: inputRegex,\n type: this.type,\n keepMarks: this.options.keepMarks,\n keepAttributes: this.options.keepAttributes,\n getAttributes: () => {\n return this.editor.getAttributes(TextStyleName)\n },\n editor: this.editor,\n })\n }\n return [inputRule]\n },\n})\n","import { BulletList } from './bullet-list.js'\n\nexport * from './bullet-list.js'\n\nexport default BulletList\n"],"mappings":";AAAA,SAAS,iBAAiB,MAAM,yBAAyB;AAEzD,IAAM,eAAe;AACrB,IAAM,gBAAgB;AA8Cf,IAAM,aAAa;AAQnB,IAAM,aAAa,KAAK,OAA0B;AAAA,EACvD,MAAM;AAAA,EAEN,aAAa;AACX,WAAO;AAAA,MACL,cAAc;AAAA,MACd,gBAAgB,CAAC;AAAA,MACjB,WAAW;AAAA,MACX,gBAAgB;AAAA,IAClB;AAAA,EACF;AAAA,EAEA,OAAO;AAAA,EAEP,UAAU;AACR,WAAO,GAAG,KAAK,QAAQ,YAAY;AAAA,EACrC;AAAA,EAEA,YAAY;AACV,WAAO,CAAC,EAAE,KAAK,KAAK,CAAC;AAAA,EACvB;AAAA,EAEA,WAAW,EAAE,eAAe,GAAG;AAC7B,WAAO,CAAC,MAAM,gBAAgB,KAAK,QAAQ,gBAAgB,cAAc,GAAG,CAAC;AAAA,EAC/E;AAAA,EAEA,cAAc;AACZ,WAAO;AAAA,MACL,kBACE,MACA,CAAC,EAAE,UAAU,MAAM,MAAM;AACvB,YAAI,KAAK,QAAQ,gBAAgB;AAC/B,iBAAO,MAAM,EACV,WAAW,KAAK,MAAM,KAAK,QAAQ,cAAc,KAAK,QAAQ,SAAS,EACvE,iBAAiB,cAAc,KAAK,OAAO,cAAc,aAAa,CAAC,EACvE,IAAI;AAAA,QACT;AACA,eAAO,SAAS,WAAW,KAAK,MAAM,KAAK,QAAQ,cAAc,KAAK,QAAQ,SAAS;AAAA,MACzF;AAAA,IACJ;AAAA,EACF;AAAA,EAEA,uBAAuB;AACrB,WAAO;AAAA,MACL,eAAe,MAAM,KAAK,OAAO,SAAS,iBAAiB;AAAA,IAC7D;AAAA,EACF;AAAA,EAEA,gBAAgB;AACd,QAAI,YAAY,kBAAkB;AAAA,MAChC,MAAM;AAAA,MACN,MAAM,KAAK;AAAA,IACb,CAAC;AAED,QAAI,KAAK,QAAQ,aAAa,KAAK,QAAQ,gBAAgB;AACzD,kBAAY,kBAAkB;AAAA,QAC5B,MAAM;AAAA,QACN,MAAM,KAAK;AAAA,QACX,WAAW,KAAK,QAAQ;AAAA,QACxB,gBAAgB,KAAK,QAAQ;AAAA,QAC7B,eAAe,MAAM;AACnB,iBAAO,KAAK,OAAO,cAAc,aAAa;AAAA,QAChD;AAAA,QACA,QAAQ,KAAK;AAAA,MACf,CAAC;AAAA,IACH;AACA,WAAO,CAAC,SAAS;AAAA,EACnB;AACF,CAAC;;;ACzHD,IAAO,gBAAQ;","names":[]}
1
+ {"version":3,"sources":["../src/index.ts"],"sourcesContent":["import { BulletList } from '@tiptap/extension-list'\n\nexport { BulletList, BulletListOptions } from '@tiptap/extension-list'\n\nexport default BulletList\n"],"mappings":";AAAA,SAAS,kBAAkB;AAE3B,SAAS,cAAAA,aAAY,yBAAyB;AAE9C,IAAO,gBAAQ;","names":["BulletList"]}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@tiptap/extension-bullet-list",
3
3
  "description": "bullet list extension for tiptap",
4
- "version": "3.0.0-next.4",
4
+ "version": "3.0.0-next.5",
5
5
  "homepage": "https://tiptap.dev",
6
6
  "keywords": [
7
7
  "tiptap",
@@ -31,10 +31,10 @@
31
31
  "dist"
32
32
  ],
33
33
  "devDependencies": {
34
- "@tiptap/core": "^3.0.0-next.4"
34
+ "@tiptap/extension-list": "^3.0.0-next.5"
35
35
  },
36
36
  "peerDependencies": {
37
- "@tiptap/core": "^3.0.0-next.1"
37
+ "@tiptap/extension-list": "^3.0.0-next.4"
38
38
  },
39
39
  "repository": {
40
40
  "type": "git",
package/src/index.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { BulletList } from './bullet-list.js'
1
+ import { BulletList } from '@tiptap/extension-list'
2
2
 
3
- export * from './bullet-list.js'
3
+ export { BulletList, BulletListOptions } from '@tiptap/extension-list'
4
4
 
5
5
  export default BulletList
@@ -1,126 +0,0 @@
1
- import { mergeAttributes, Node, wrappingInputRule } from '@tiptap/core'
2
-
3
- const ListItemName = 'listItem'
4
- const TextStyleName = 'textStyle'
5
-
6
- export interface BulletListOptions {
7
- /**
8
- * The node name for the list items
9
- * @default 'listItem'
10
- * @example 'paragraph'
11
- */
12
- itemTypeName: string
13
-
14
- /**
15
- * HTML attributes to add to the bullet list element
16
- * @default {}
17
- * @example { class: 'foo' }
18
- */
19
- HTMLAttributes: Record<string, any>
20
-
21
- /**
22
- * Keep the marks when splitting the list
23
- * @default false
24
- * @example true
25
- */
26
- keepMarks: boolean
27
-
28
- /**
29
- * Keep the attributes when splitting the list
30
- * @default false
31
- * @example true
32
- */
33
- keepAttributes: boolean
34
- }
35
-
36
- declare module '@tiptap/core' {
37
- interface Commands<ReturnType> {
38
- bulletList: {
39
- /**
40
- * Toggle a bullet list
41
- */
42
- toggleBulletList: () => ReturnType
43
- }
44
- }
45
- }
46
-
47
- /**
48
- * Matches a bullet list to a dash or asterisk.
49
- */
50
- export const inputRegex = /^\s*([-+*])\s$/
51
-
52
- /**
53
- * This extension allows you to create bullet lists.
54
- * This requires the ListItem extension
55
- * @see https://tiptap.dev/api/nodes/bullet-list
56
- * @see https://tiptap.dev/api/nodes/list-item.
57
- */
58
- export const BulletList = Node.create<BulletListOptions>({
59
- name: 'bulletList',
60
-
61
- addOptions() {
62
- return {
63
- itemTypeName: 'listItem',
64
- HTMLAttributes: {},
65
- keepMarks: false,
66
- keepAttributes: false,
67
- }
68
- },
69
-
70
- group: 'block list',
71
-
72
- content() {
73
- return `${this.options.itemTypeName}+`
74
- },
75
-
76
- parseHTML() {
77
- return [{ tag: 'ul' }]
78
- },
79
-
80
- renderHTML({ HTMLAttributes }) {
81
- return ['ul', mergeAttributes(this.options.HTMLAttributes, HTMLAttributes), 0]
82
- },
83
-
84
- addCommands() {
85
- return {
86
- toggleBulletList:
87
- () =>
88
- ({ commands, chain }) => {
89
- if (this.options.keepAttributes) {
90
- return chain()
91
- .toggleList(this.name, this.options.itemTypeName, this.options.keepMarks)
92
- .updateAttributes(ListItemName, this.editor.getAttributes(TextStyleName))
93
- .run()
94
- }
95
- return commands.toggleList(this.name, this.options.itemTypeName, this.options.keepMarks)
96
- },
97
- }
98
- },
99
-
100
- addKeyboardShortcuts() {
101
- return {
102
- 'Mod-Shift-8': () => this.editor.commands.toggleBulletList(),
103
- }
104
- },
105
-
106
- addInputRules() {
107
- let inputRule = wrappingInputRule({
108
- find: inputRegex,
109
- type: this.type,
110
- })
111
-
112
- if (this.options.keepMarks || this.options.keepAttributes) {
113
- inputRule = wrappingInputRule({
114
- find: inputRegex,
115
- type: this.type,
116
- keepMarks: this.options.keepMarks,
117
- keepAttributes: this.options.keepAttributes,
118
- getAttributes: () => {
119
- return this.editor.getAttributes(TextStyleName)
120
- },
121
- editor: this.editor,
122
- })
123
- }
124
- return [inputRule]
125
- },
126
- })