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

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 ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024, Tiptap GmbH
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,14 +1,18 @@
1
1
  # @tiptap/extension-bullet-list
2
+
2
3
  [![Version](https://img.shields.io/npm/v/@tiptap/extension-bullet-list.svg?label=version)](https://www.npmjs.com/package/@tiptap/extension-bullet-list)
3
4
  [![Downloads](https://img.shields.io/npm/dm/@tiptap/extension-bullet-list.svg)](https://npmcharts.com/compare/tiptap?minimal=true)
4
5
  [![License](https://img.shields.io/npm/l/@tiptap/extension-bullet-list.svg)](https://www.npmjs.com/package/@tiptap/extension-bullet-list)
5
6
  [![Sponsor](https://img.shields.io/static/v1?label=Sponsor&message=%E2%9D%A4&logo=GitHub)](https://github.com/sponsors/ueberdosis)
6
7
 
7
8
  ## Introduction
8
- Tiptap is a headless wrapper around [ProseMirror](https://ProseMirror.net) – a toolkit for building rich text WYSIWYG editors, which is already in use at many well-known companies such as *New York Times*, *The Guardian* or *Atlassian*.
9
+
10
+ Tiptap is a headless wrapper around [ProseMirror](https://ProseMirror.net) – a toolkit for building rich text WYSIWYG editors, which is already in use at many well-known companies such as _New York Times_, _The Guardian_ or _Atlassian_.
9
11
 
10
12
  ## Official Documentation
13
+
11
14
  Documentation can be found on the [Tiptap website](https://tiptap.dev).
12
15
 
13
16
  ## License
17
+
14
18
  Tiptap is open sourced software licensed under the [MIT license](https://github.com/ueberdosis/tiptap/blob/main/LICENSE.md).
package/dist/index.cjs CHANGED
@@ -18,13 +18,13 @@ var __copyProps = (to, from, except, desc) => {
18
18
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
19
 
20
20
  // src/index.ts
21
- var src_exports = {};
22
- __export(src_exports, {
21
+ var index_exports = {};
22
+ __export(index_exports, {
23
23
  BulletList: () => BulletList,
24
- default: () => src_default,
24
+ default: () => index_default,
25
25
  inputRegex: () => inputRegex
26
26
  });
27
- module.exports = __toCommonJS(src_exports);
27
+ module.exports = __toCommonJS(index_exports);
28
28
 
29
29
  // src/bullet-list.ts
30
30
  var import_core = require("@tiptap/core");
@@ -46,9 +46,7 @@ var BulletList = import_core.Node.create({
46
46
  return `${this.options.itemTypeName}+`;
47
47
  },
48
48
  parseHTML() {
49
- return [
50
- { tag: "ul" }
51
- ];
49
+ return [{ tag: "ul" }];
52
50
  },
53
51
  renderHTML({ HTMLAttributes }) {
54
52
  return ["ul", (0, import_core.mergeAttributes)(this.options.HTMLAttributes, HTMLAttributes), 0];
@@ -85,14 +83,12 @@ var BulletList = import_core.Node.create({
85
83
  editor: this.editor
86
84
  });
87
85
  }
88
- return [
89
- inputRule
90
- ];
86
+ return [inputRule];
91
87
  }
92
88
  });
93
89
 
94
90
  // src/index.ts
95
- var src_default = BulletList;
91
+ var index_default = BulletList;
96
92
  // Annotate the CommonJS export names for ESM import in node:
97
93
  0 && (module.exports = {
98
94
  BulletList,
@@ -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 [\n { tag: 'ul' },\n ]\n },\n\n renderHTML({ HTMLAttributes }) {\n return ['ul', mergeAttributes(this.options.HTMLAttributes, HTMLAttributes), 0]\n },\n\n addCommands() {\n return {\n toggleBulletList: () => ({ commands, chain }) => {\n if (this.options.keepAttributes) {\n return chain().toggleList(this.name, this.options.itemTypeName, this.options.keepMarks).updateAttributes(ListItemName, this.editor.getAttributes(TextStyleName)).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: () => { return this.editor.getAttributes(TextStyleName) },\n editor: this.editor,\n })\n }\n return [\n inputRule,\n ]\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;AAAA,MACL,EAAE,KAAK,KAAK;AAAA,IACd;AAAA,EACF;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,kBAAkB,MAAM,CAAC,EAAE,UAAU,MAAM,MAAM;AAC/C,YAAI,KAAK,QAAQ,gBAAgB;AAC/B,iBAAO,MAAM,EAAE,WAAW,KAAK,MAAM,KAAK,QAAQ,cAAc,KAAK,QAAQ,SAAS,EAAE,iBAAiB,cAAc,KAAK,OAAO,cAAc,aAAa,CAAC,EAAE,IAAI;AAAA,QACvK;AACA,eAAO,SAAS,WAAW,KAAK,MAAM,KAAK,QAAQ,cAAc,KAAK,QAAQ,SAAS;AAAA,MACzF;AAAA,IACF;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;AAAE,iBAAO,KAAK,OAAO,cAAc,aAAa;AAAA,QAAE;AAAA,QACvE,QAAQ,KAAK;AAAA,MACf,CAAC;AAAA,IACH;AACA,WAAO;AAAA,MACL;AAAA,IACF;AAAA,EACF;AACF,CAAC;;;ADtHD,IAAO,cAAQ;","names":[]}
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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I,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":[]}
package/dist/index.js CHANGED
@@ -18,9 +18,7 @@ var BulletList = Node.create({
18
18
  return `${this.options.itemTypeName}+`;
19
19
  },
20
20
  parseHTML() {
21
- return [
22
- { tag: "ul" }
23
- ];
21
+ return [{ tag: "ul" }];
24
22
  },
25
23
  renderHTML({ HTMLAttributes }) {
26
24
  return ["ul", mergeAttributes(this.options.HTMLAttributes, HTMLAttributes), 0];
@@ -57,17 +55,15 @@ var BulletList = Node.create({
57
55
  editor: this.editor
58
56
  });
59
57
  }
60
- return [
61
- inputRule
62
- ];
58
+ return [inputRule];
63
59
  }
64
60
  });
65
61
 
66
62
  // src/index.ts
67
- var src_default = BulletList;
63
+ var index_default = BulletList;
68
64
  export {
69
65
  BulletList,
70
- src_default as default,
66
+ index_default as default,
71
67
  inputRegex
72
68
  };
73
69
  //# 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 [\n { tag: 'ul' },\n ]\n },\n\n renderHTML({ HTMLAttributes }) {\n return ['ul', mergeAttributes(this.options.HTMLAttributes, HTMLAttributes), 0]\n },\n\n addCommands() {\n return {\n toggleBulletList: () => ({ commands, chain }) => {\n if (this.options.keepAttributes) {\n return chain().toggleList(this.name, this.options.itemTypeName, this.options.keepMarks).updateAttributes(ListItemName, this.editor.getAttributes(TextStyleName)).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: () => { return this.editor.getAttributes(TextStyleName) },\n editor: this.editor,\n })\n }\n return [\n inputRule,\n ]\n },\n})\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AAI,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;AAAE,iBAAO,KAAK,OAAO,cAAc,aAAa;AAAA,QAAE;AAAA,QACvE,QAAQ,KAAK;AAAA,MACf,CAAC;AAAA,IACH;AACA,WAAO;AAAA,MACL;AAAA,IACF;AAAA,EACF;AACF,CAAC;;;ACtHD,IAAO,cAAQ;","names":[]}
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":[]}
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.3",
4
+ "version": "3.0.0-next.4",
5
5
  "homepage": "https://tiptap.dev",
6
6
  "keywords": [
7
7
  "tiptap",
@@ -15,7 +15,10 @@
15
15
  "type": "module",
16
16
  "exports": {
17
17
  ".": {
18
- "types": "./dist/index.d.ts",
18
+ "types": {
19
+ "import": "./dist/index.d.ts",
20
+ "require": "./dist/index.d.cts"
21
+ },
19
22
  "import": "./dist/index.js",
20
23
  "require": "./dist/index.cjs"
21
24
  }
@@ -28,7 +31,7 @@
28
31
  "dist"
29
32
  ],
30
33
  "devDependencies": {
31
- "@tiptap/core": "^3.0.0-next.3"
34
+ "@tiptap/core": "^3.0.0-next.4"
32
35
  },
33
36
  "peerDependencies": {
34
37
  "@tiptap/core": "^3.0.0-next.1"
@@ -39,6 +42,7 @@
39
42
  "directory": "packages/extension-bullet-list"
40
43
  },
41
44
  "scripts": {
42
- "build": "tsup"
45
+ "build": "tsup",
46
+ "lint": "prettier ./src/ --check && eslint --cache --quiet --no-error-on-unmatched-pattern ./src/"
43
47
  }
44
- }
48
+ }
@@ -9,28 +9,28 @@ export interface BulletListOptions {
9
9
  * @default 'listItem'
10
10
  * @example 'paragraph'
11
11
  */
12
- itemTypeName: string,
12
+ itemTypeName: string
13
13
 
14
14
  /**
15
15
  * HTML attributes to add to the bullet list element
16
16
  * @default {}
17
17
  * @example { class: 'foo' }
18
18
  */
19
- HTMLAttributes: Record<string, any>,
19
+ HTMLAttributes: Record<string, any>
20
20
 
21
21
  /**
22
22
  * Keep the marks when splitting the list
23
23
  * @default false
24
24
  * @example true
25
25
  */
26
- keepMarks: boolean,
26
+ keepMarks: boolean
27
27
 
28
28
  /**
29
29
  * Keep the attributes when splitting the list
30
30
  * @default false
31
31
  * @example true
32
32
  */
33
- keepAttributes: boolean,
33
+ keepAttributes: boolean
34
34
  }
35
35
 
36
36
  declare module '@tiptap/core' {
@@ -39,7 +39,7 @@ declare module '@tiptap/core' {
39
39
  /**
40
40
  * Toggle a bullet list
41
41
  */
42
- toggleBulletList: () => ReturnType,
42
+ toggleBulletList: () => ReturnType
43
43
  }
44
44
  }
45
45
  }
@@ -74,9 +74,7 @@ export const BulletList = Node.create<BulletListOptions>({
74
74
  },
75
75
 
76
76
  parseHTML() {
77
- return [
78
- { tag: 'ul' },
79
- ]
77
+ return [{ tag: 'ul' }]
80
78
  },
81
79
 
82
80
  renderHTML({ HTMLAttributes }) {
@@ -85,12 +83,17 @@ export const BulletList = Node.create<BulletListOptions>({
85
83
 
86
84
  addCommands() {
87
85
  return {
88
- toggleBulletList: () => ({ commands, chain }) => {
89
- if (this.options.keepAttributes) {
90
- return chain().toggleList(this.name, this.options.itemTypeName, this.options.keepMarks).updateAttributes(ListItemName, this.editor.getAttributes(TextStyleName)).run()
91
- }
92
- return commands.toggleList(this.name, this.options.itemTypeName, this.options.keepMarks)
93
- },
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
+ },
94
97
  }
95
98
  },
96
99
 
@@ -112,12 +115,12 @@ export const BulletList = Node.create<BulletListOptions>({
112
115
  type: this.type,
113
116
  keepMarks: this.options.keepMarks,
114
117
  keepAttributes: this.options.keepAttributes,
115
- getAttributes: () => { return this.editor.getAttributes(TextStyleName) },
118
+ getAttributes: () => {
119
+ return this.editor.getAttributes(TextStyleName)
120
+ },
116
121
  editor: this.editor,
117
122
  })
118
123
  }
119
- return [
120
- inputRule,
121
- ]
124
+ return [inputRule]
122
125
  },
123
126
  })