@tiptap/extension-ordered-list 3.0.0-next.3 → 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 ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025, 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-ordered-list
2
+
2
3
  [![Version](https://img.shields.io/npm/v/@tiptap/extension-ordered-list.svg?label=version)](https://www.npmjs.com/package/@tiptap/extension-ordered-list)
3
4
  [![Downloads](https://img.shields.io/npm/dm/@tiptap/extension-ordered-list.svg)](https://npmcharts.com/compare/tiptap?minimal=true)
4
5
  [![License](https://img.shields.io/npm/l/@tiptap/extension-ordered-list.svg)](https://www.npmjs.com/package/@tiptap/extension-ordered-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,102 +18,19 @@ 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, {
23
- OrderedList: () => OrderedList,
24
- default: () => src_default,
25
- inputRegex: () => inputRegex
21
+ var index_exports = {};
22
+ __export(index_exports, {
23
+ OrderedList: () => import_extension_list2.OrderedList,
24
+ OrderedListOptions: () => import_extension_list2.OrderedListOptions,
25
+ default: () => index_default
26
26
  });
27
- module.exports = __toCommonJS(src_exports);
28
-
29
- // src/ordered-list.ts
30
- var import_core = require("@tiptap/core");
31
- var ListItemName = "listItem";
32
- var TextStyleName = "textStyle";
33
- var inputRegex = /^(\d+)\.\s$/;
34
- var OrderedList = import_core.Node.create({
35
- name: "orderedList",
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
- addAttributes() {
49
- return {
50
- start: {
51
- default: 1,
52
- parseHTML: (element) => {
53
- return element.hasAttribute("start") ? parseInt(element.getAttribute("start") || "", 10) : 1;
54
- }
55
- },
56
- type: {
57
- default: void 0,
58
- parseHTML: (element) => element.getAttribute("type")
59
- }
60
- };
61
- },
62
- parseHTML() {
63
- return [
64
- {
65
- tag: "ol"
66
- }
67
- ];
68
- },
69
- renderHTML({ HTMLAttributes }) {
70
- const { start, ...attributesWithoutStart } = HTMLAttributes;
71
- return start === 1 ? ["ol", (0, import_core.mergeAttributes)(this.options.HTMLAttributes, attributesWithoutStart), 0] : ["ol", (0, import_core.mergeAttributes)(this.options.HTMLAttributes, HTMLAttributes), 0];
72
- },
73
- addCommands() {
74
- return {
75
- toggleOrderedList: () => ({ commands, chain }) => {
76
- if (this.options.keepAttributes) {
77
- return chain().toggleList(this.name, this.options.itemTypeName, this.options.keepMarks).updateAttributes(ListItemName, this.editor.getAttributes(TextStyleName)).run();
78
- }
79
- return commands.toggleList(this.name, this.options.itemTypeName, this.options.keepMarks);
80
- }
81
- };
82
- },
83
- addKeyboardShortcuts() {
84
- return {
85
- "Mod-Shift-7": () => this.editor.commands.toggleOrderedList()
86
- };
87
- },
88
- addInputRules() {
89
- let inputRule = (0, import_core.wrappingInputRule)({
90
- find: inputRegex,
91
- type: this.type,
92
- getAttributes: (match) => ({ start: +match[1] }),
93
- joinPredicate: (match, node) => node.childCount + node.attrs.start === +match[1]
94
- });
95
- if (this.options.keepMarks || this.options.keepAttributes) {
96
- inputRule = (0, import_core.wrappingInputRule)({
97
- find: inputRegex,
98
- type: this.type,
99
- keepMarks: this.options.keepMarks,
100
- keepAttributes: this.options.keepAttributes,
101
- getAttributes: (match) => ({ start: +match[1], ...this.editor.getAttributes(TextStyleName) }),
102
- joinPredicate: (match, node) => node.childCount + node.attrs.start === +match[1],
103
- editor: this.editor
104
- });
105
- }
106
- return [
107
- inputRule
108
- ];
109
- }
110
- });
111
-
112
- // src/index.ts
113
- var src_default = OrderedList;
27
+ module.exports = __toCommonJS(index_exports);
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.OrderedList;
114
31
  // Annotate the CommonJS export names for ESM import in node:
115
32
  0 && (module.exports = {
116
33
  OrderedList,
117
- inputRegex
34
+ OrderedListOptions
118
35
  });
119
36
  //# sourceMappingURL=index.cjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts","../src/ordered-list.ts"],"sourcesContent":["import { OrderedList } from './ordered-list.js'\n\nexport * from './ordered-list.js'\n\nexport default OrderedList\n","import { mergeAttributes, Node, wrappingInputRule } from '@tiptap/core'\n\nconst ListItemName = 'listItem'\nconst TextStyleName = 'textStyle'\n\nexport interface OrderedListOptions {\n /**\n * The node type name for list items.\n * @default 'listItem'\n * @example 'myListItem'\n */\n itemTypeName: string,\n\n /**\n * The HTML attributes for an ordered list node.\n * @default {}\n * @example { class: 'foo' }\n */\n HTMLAttributes: Record<string, any>,\n\n /**\n * Keep the marks when splitting a list item.\n * @default false\n * @example true\n */\n keepMarks: boolean,\n\n /**\n * Keep the attributes when splitting a list item.\n * @default false\n * @example true\n */\n keepAttributes: boolean,\n}\n\ndeclare module '@tiptap/core' {\n interface Commands<ReturnType> {\n orderedList: {\n /**\n * Toggle an ordered list\n * @example editor.commands.toggleOrderedList()\n */\n toggleOrderedList: () => ReturnType,\n }\n }\n}\n\n/**\n * Matches an ordered list to a 1. on input (or any number followed by a dot).\n */\nexport const inputRegex = /^(\\d+)\\.\\s$/\n\n/**\n * This extension allows you to create ordered lists.\n * This requires the ListItem extension\n * @see https://www.tiptap.dev/api/nodes/ordered-list\n * @see https://www.tiptap.dev/api/nodes/list-item\n */\nexport const OrderedList = Node.create<OrderedListOptions>({\n name: 'orderedList',\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 addAttributes() {\n return {\n start: {\n default: 1,\n parseHTML: element => {\n return element.hasAttribute('start')\n ? parseInt(element.getAttribute('start') || '', 10)\n : 1\n },\n },\n type: {\n default: undefined,\n parseHTML: element => element.getAttribute('type'),\n },\n }\n },\n\n parseHTML() {\n return [\n {\n tag: 'ol',\n },\n ]\n },\n\n renderHTML({ HTMLAttributes }) {\n const { start, ...attributesWithoutStart } = HTMLAttributes\n\n return start === 1\n ? ['ol', mergeAttributes(this.options.HTMLAttributes, attributesWithoutStart), 0]\n : ['ol', mergeAttributes(this.options.HTMLAttributes, HTMLAttributes), 0]\n },\n\n addCommands() {\n return {\n toggleOrderedList: () => ({ 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-7': () => this.editor.commands.toggleOrderedList(),\n }\n },\n\n addInputRules() {\n let inputRule = wrappingInputRule({\n find: inputRegex,\n type: this.type,\n getAttributes: match => ({ start: +match[1] }),\n joinPredicate: (match, node) => node.childCount + node.attrs.start === +match[1],\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: match => ({ start: +match[1], ...this.editor.getAttributes(TextStyleName) }),\n joinPredicate: (match, node) => node.childCount + node.attrs.start === +match[1],\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;AA+Cf,IAAM,aAAa;AAQnB,IAAM,cAAc,iBAAK,OAA2B;AAAA,EACzD,MAAM;AAAA,EAEN,aAAa;AAC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EAEA,uBAAuB;AACrB,WAAO;AAAA,MACL,eAAe,MAAM,KAAK,OAAO,SAAS,kBAAkB;AAAA,IAC9D;AAAA,EACF;AAAA,EAEA,gBAAgB;AACd,QAAI,gBAAY,+BAAkB;AAAA,MAChC,MAAM;AAAA,MACN,MAAM,KAAK;AAAA,MACX,eAAe,YAAU,EAAE,OAAO,CAAC,MAAM,CAAC,EAAE;AAAA,MAC5C,eAAe,CAAC,OAAO,SAAS,KAAK,aAAa,KAAK,MAAM,UAAU,CAAC,MAAM,CAAC;AAAA,IACjF,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,YAAU,EAAE,OAAO,CAAC,MAAM,CAAC,GAAG,GAAG,KAAK,OAAO,cAAc,aAAa,EAAE;AAAA,QACzF,eAAe,CAAC,OAAO,SAAS,KAAK,aAAa,KAAK,MAAM,UAAU,CAAC,MAAM,CAAC;AAAA,QAC/E,QAAQ,KAAK;AAAA,MACf,CAAC;AAAA,IACH;AACA,WAAO;AAAA,MACL;AAAA,IACF;AAAA,EACF;AACF,CAAC;;;ADjJD,IAAO,cAAQ;","names":[]}
1
+ {"version":3,"sources":["../src/index.ts"],"sourcesContent":["import { OrderedList } from '@tiptap/extension-list'\n\nexport { OrderedList, OrderedListOptions } from '@tiptap/extension-list'\n\nexport default OrderedList\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,4BAA4B;AAE5B,IAAAA,yBAAgD;AAEhD,IAAO,gBAAQ;","names":["import_extension_list"]}
package/dist/index.d.cts CHANGED
@@ -1,52 +1,2 @@
1
- import { Node } from '@tiptap/core';
2
-
3
- interface OrderedListOptions {
4
- /**
5
- * The node type name for list items.
6
- * @default 'listItem'
7
- * @example 'myListItem'
8
- */
9
- itemTypeName: string;
10
- /**
11
- * The HTML attributes for an ordered list node.
12
- * @default {}
13
- * @example { class: 'foo' }
14
- */
15
- HTMLAttributes: Record<string, any>;
16
- /**
17
- * Keep the marks when splitting a list item.
18
- * @default false
19
- * @example true
20
- */
21
- keepMarks: boolean;
22
- /**
23
- * Keep the attributes when splitting a list item.
24
- * @default false
25
- * @example true
26
- */
27
- keepAttributes: boolean;
28
- }
29
- declare module '@tiptap/core' {
30
- interface Commands<ReturnType> {
31
- orderedList: {
32
- /**
33
- * Toggle an ordered list
34
- * @example editor.commands.toggleOrderedList()
35
- */
36
- toggleOrderedList: () => ReturnType;
37
- };
38
- }
39
- }
40
- /**
41
- * Matches an ordered list to a 1. on input (or any number followed by a dot).
42
- */
43
- declare const inputRegex: RegExp;
44
- /**
45
- * This extension allows you to create ordered lists.
46
- * This requires the ListItem extension
47
- * @see https://www.tiptap.dev/api/nodes/ordered-list
48
- * @see https://www.tiptap.dev/api/nodes/list-item
49
- */
50
- declare const OrderedList: Node<OrderedListOptions, any>;
51
-
52
- export { OrderedList, type OrderedListOptions, OrderedList as default, inputRegex };
1
+ import { OrderedList } from '@tiptap/extension-list';
2
+ export { OrderedList, OrderedListOptions, OrderedList as default } from '@tiptap/extension-list';
package/dist/index.d.ts CHANGED
@@ -1,52 +1,2 @@
1
- import { Node } from '@tiptap/core';
2
-
3
- interface OrderedListOptions {
4
- /**
5
- * The node type name for list items.
6
- * @default 'listItem'
7
- * @example 'myListItem'
8
- */
9
- itemTypeName: string;
10
- /**
11
- * The HTML attributes for an ordered list node.
12
- * @default {}
13
- * @example { class: 'foo' }
14
- */
15
- HTMLAttributes: Record<string, any>;
16
- /**
17
- * Keep the marks when splitting a list item.
18
- * @default false
19
- * @example true
20
- */
21
- keepMarks: boolean;
22
- /**
23
- * Keep the attributes when splitting a list item.
24
- * @default false
25
- * @example true
26
- */
27
- keepAttributes: boolean;
28
- }
29
- declare module '@tiptap/core' {
30
- interface Commands<ReturnType> {
31
- orderedList: {
32
- /**
33
- * Toggle an ordered list
34
- * @example editor.commands.toggleOrderedList()
35
- */
36
- toggleOrderedList: () => ReturnType;
37
- };
38
- }
39
- }
40
- /**
41
- * Matches an ordered list to a 1. on input (or any number followed by a dot).
42
- */
43
- declare const inputRegex: RegExp;
44
- /**
45
- * This extension allows you to create ordered lists.
46
- * This requires the ListItem extension
47
- * @see https://www.tiptap.dev/api/nodes/ordered-list
48
- * @see https://www.tiptap.dev/api/nodes/list-item
49
- */
50
- declare const OrderedList: Node<OrderedListOptions, any>;
51
-
52
- export { OrderedList, type OrderedListOptions, OrderedList as default, inputRegex };
1
+ import { OrderedList } from '@tiptap/extension-list';
2
+ export { OrderedList, OrderedListOptions, OrderedList as default } from '@tiptap/extension-list';
package/dist/index.js CHANGED
@@ -1,91 +1,10 @@
1
- // src/ordered-list.ts
2
- import { mergeAttributes, Node, wrappingInputRule } from "@tiptap/core";
3
- var ListItemName = "listItem";
4
- var TextStyleName = "textStyle";
5
- var inputRegex = /^(\d+)\.\s$/;
6
- var OrderedList = Node.create({
7
- name: "orderedList",
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
- addAttributes() {
21
- return {
22
- start: {
23
- default: 1,
24
- parseHTML: (element) => {
25
- return element.hasAttribute("start") ? parseInt(element.getAttribute("start") || "", 10) : 1;
26
- }
27
- },
28
- type: {
29
- default: void 0,
30
- parseHTML: (element) => element.getAttribute("type")
31
- }
32
- };
33
- },
34
- parseHTML() {
35
- return [
36
- {
37
- tag: "ol"
38
- }
39
- ];
40
- },
41
- renderHTML({ HTMLAttributes }) {
42
- const { start, ...attributesWithoutStart } = HTMLAttributes;
43
- return start === 1 ? ["ol", mergeAttributes(this.options.HTMLAttributes, attributesWithoutStart), 0] : ["ol", mergeAttributes(this.options.HTMLAttributes, HTMLAttributes), 0];
44
- },
45
- addCommands() {
46
- return {
47
- toggleOrderedList: () => ({ commands, chain }) => {
48
- if (this.options.keepAttributes) {
49
- return chain().toggleList(this.name, this.options.itemTypeName, this.options.keepMarks).updateAttributes(ListItemName, this.editor.getAttributes(TextStyleName)).run();
50
- }
51
- return commands.toggleList(this.name, this.options.itemTypeName, this.options.keepMarks);
52
- }
53
- };
54
- },
55
- addKeyboardShortcuts() {
56
- return {
57
- "Mod-Shift-7": () => this.editor.commands.toggleOrderedList()
58
- };
59
- },
60
- addInputRules() {
61
- let inputRule = wrappingInputRule({
62
- find: inputRegex,
63
- type: this.type,
64
- getAttributes: (match) => ({ start: +match[1] }),
65
- joinPredicate: (match, node) => node.childCount + node.attrs.start === +match[1]
66
- });
67
- if (this.options.keepMarks || this.options.keepAttributes) {
68
- inputRule = wrappingInputRule({
69
- find: inputRegex,
70
- type: this.type,
71
- keepMarks: this.options.keepMarks,
72
- keepAttributes: this.options.keepAttributes,
73
- getAttributes: (match) => ({ start: +match[1], ...this.editor.getAttributes(TextStyleName) }),
74
- joinPredicate: (match, node) => node.childCount + node.attrs.start === +match[1],
75
- editor: this.editor
76
- });
77
- }
78
- return [
79
- inputRule
80
- ];
81
- }
82
- });
83
-
84
1
  // src/index.ts
85
- var src_default = OrderedList;
2
+ import { OrderedList } from "@tiptap/extension-list";
3
+ import { OrderedList as OrderedList2, OrderedListOptions } from "@tiptap/extension-list";
4
+ var index_default = OrderedList;
86
5
  export {
87
- OrderedList,
88
- src_default as default,
89
- inputRegex
6
+ OrderedList2 as OrderedList,
7
+ OrderedListOptions,
8
+ index_default as default
90
9
  };
91
10
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/ordered-list.ts","../src/index.ts"],"sourcesContent":["import { mergeAttributes, Node, wrappingInputRule } from '@tiptap/core'\n\nconst ListItemName = 'listItem'\nconst TextStyleName = 'textStyle'\n\nexport interface OrderedListOptions {\n /**\n * The node type name for list items.\n * @default 'listItem'\n * @example 'myListItem'\n */\n itemTypeName: string,\n\n /**\n * The HTML attributes for an ordered list node.\n * @default {}\n * @example { class: 'foo' }\n */\n HTMLAttributes: Record<string, any>,\n\n /**\n * Keep the marks when splitting a list item.\n * @default false\n * @example true\n */\n keepMarks: boolean,\n\n /**\n * Keep the attributes when splitting a list item.\n * @default false\n * @example true\n */\n keepAttributes: boolean,\n}\n\ndeclare module '@tiptap/core' {\n interface Commands<ReturnType> {\n orderedList: {\n /**\n * Toggle an ordered list\n * @example editor.commands.toggleOrderedList()\n */\n toggleOrderedList: () => ReturnType,\n }\n }\n}\n\n/**\n * Matches an ordered list to a 1. on input (or any number followed by a dot).\n */\nexport const inputRegex = /^(\\d+)\\.\\s$/\n\n/**\n * This extension allows you to create ordered lists.\n * This requires the ListItem extension\n * @see https://www.tiptap.dev/api/nodes/ordered-list\n * @see https://www.tiptap.dev/api/nodes/list-item\n */\nexport const OrderedList = Node.create<OrderedListOptions>({\n name: 'orderedList',\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 addAttributes() {\n return {\n start: {\n default: 1,\n parseHTML: element => {\n return element.hasAttribute('start')\n ? parseInt(element.getAttribute('start') || '', 10)\n : 1\n },\n },\n type: {\n default: undefined,\n parseHTML: element => element.getAttribute('type'),\n },\n }\n },\n\n parseHTML() {\n return [\n {\n tag: 'ol',\n },\n ]\n },\n\n renderHTML({ HTMLAttributes }) {\n const { start, ...attributesWithoutStart } = HTMLAttributes\n\n return start === 1\n ? ['ol', mergeAttributes(this.options.HTMLAttributes, attributesWithoutStart), 0]\n : ['ol', mergeAttributes(this.options.HTMLAttributes, HTMLAttributes), 0]\n },\n\n addCommands() {\n return {\n toggleOrderedList: () => ({ 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-7': () => this.editor.commands.toggleOrderedList(),\n }\n },\n\n addInputRules() {\n let inputRule = wrappingInputRule({\n find: inputRegex,\n type: this.type,\n getAttributes: match => ({ start: +match[1] }),\n joinPredicate: (match, node) => node.childCount + node.attrs.start === +match[1],\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: match => ({ start: +match[1], ...this.editor.getAttributes(TextStyleName) }),\n joinPredicate: (match, node) => node.childCount + node.attrs.start === +match[1],\n editor: this.editor,\n })\n }\n return [\n inputRule,\n ]\n },\n})\n","import { OrderedList } from './ordered-list.js'\n\nexport * from './ordered-list.js'\n\nexport default OrderedList\n"],"mappings":";AAAA,SAAS,iBAAiB,MAAM,yBAAyB;AAEzD,IAAM,eAAe;AACrB,IAAM,gBAAgB;AA+Cf,IAAM,aAAa;AAQnB,IAAM,cAAc,KAAK,OAA2B;AAAA,EACzD,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,gBAAgB;AACd,WAAO;AAAA,MACL,OAAO;AAAA,QACL,SAAS;AAAA,QACT,WAAW,aAAW;AACpB,iBAAO,QAAQ,aAAa,OAAO,IAC/B,SAAS,QAAQ,aAAa,OAAO,KAAK,IAAI,EAAE,IAChD;AAAA,QACN;AAAA,MACF;AAA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gB;AACzD,kBAAY,kBAAkB;AAAA,QAC5B,MAAM;AAAA,QACN,MAAM,KAAK;AAAA,QACX,WAAW,KAAK,QAAQ;AAAA,QACxB,gBAAgB,KAAK,QAAQ;AAAA,QAC7B,eAAe,YAAU,EAAE,OAAO,CAAC,MAAM,CAAC,GAAG,GAAG,KAAK,OAAO,cAAc,aAAa,EAAE;AAAA,QACzF,eAAe,CAAC,OAAO,SAAS,KAAK,aAAa,KAAK,MAAM,UAAU,CAAC,MAAM,CAAC;AAAA,QAC/E,QAAQ,KAAK;AAAA,MACf,CAAC;AAAA,IACH;AACA,WAAO;AAAA,MACL;AAAA,IACF;AAAA,EACF;AACF,CAAC;;;ACjJD,IAAO,cAAQ;","names":[]}
1
+ {"version":3,"sources":["../src/index.ts"],"sourcesContent":["import { OrderedList } from '@tiptap/extension-list'\n\nexport { OrderedList, OrderedListOptions } from '@tiptap/extension-list'\n\nexport default OrderedList\n"],"mappings":";AAAA,SAAS,mBAAmB;AAE5B,SAAS,eAAAA,cAAa,0BAA0B;AAEhD,IAAO,gBAAQ;","names":["OrderedList"]}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@tiptap/extension-ordered-list",
3
3
  "description": "ordered list extension for tiptap",
4
- "version": "3.0.0-next.3",
4
+ "version": "3.0.0-next.5",
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,10 +31,10 @@
28
31
  "dist"
29
32
  ],
30
33
  "devDependencies": {
31
- "@tiptap/core": "^3.0.0-next.3"
34
+ "@tiptap/extension-list": "^3.0.0-next.5"
32
35
  },
33
36
  "peerDependencies": {
34
- "@tiptap/core": "^3.0.0-next.1"
37
+ "@tiptap/extension-list": "^3.0.0-next.4"
35
38
  },
36
39
  "repository": {
37
40
  "type": "git",
@@ -39,6 +42,7 @@
39
42
  "directory": "packages/extension-ordered-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
+ }
package/src/index.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { OrderedList } from './ordered-list.js'
1
+ import { OrderedList } from '@tiptap/extension-list'
2
2
 
3
- export * from './ordered-list.js'
3
+ export { OrderedList, OrderedListOptions } from '@tiptap/extension-list'
4
4
 
5
5
  export default OrderedList
@@ -1,150 +0,0 @@
1
- import { mergeAttributes, Node, wrappingInputRule } from '@tiptap/core'
2
-
3
- const ListItemName = 'listItem'
4
- const TextStyleName = 'textStyle'
5
-
6
- export interface OrderedListOptions {
7
- /**
8
- * The node type name for list items.
9
- * @default 'listItem'
10
- * @example 'myListItem'
11
- */
12
- itemTypeName: string,
13
-
14
- /**
15
- * The HTML attributes for an ordered list node.
16
- * @default {}
17
- * @example { class: 'foo' }
18
- */
19
- HTMLAttributes: Record<string, any>,
20
-
21
- /**
22
- * Keep the marks when splitting a list item.
23
- * @default false
24
- * @example true
25
- */
26
- keepMarks: boolean,
27
-
28
- /**
29
- * Keep the attributes when splitting a list item.
30
- * @default false
31
- * @example true
32
- */
33
- keepAttributes: boolean,
34
- }
35
-
36
- declare module '@tiptap/core' {
37
- interface Commands<ReturnType> {
38
- orderedList: {
39
- /**
40
- * Toggle an ordered list
41
- * @example editor.commands.toggleOrderedList()
42
- */
43
- toggleOrderedList: () => ReturnType,
44
- }
45
- }
46
- }
47
-
48
- /**
49
- * Matches an ordered list to a 1. on input (or any number followed by a dot).
50
- */
51
- export const inputRegex = /^(\d+)\.\s$/
52
-
53
- /**
54
- * This extension allows you to create ordered lists.
55
- * This requires the ListItem extension
56
- * @see https://www.tiptap.dev/api/nodes/ordered-list
57
- * @see https://www.tiptap.dev/api/nodes/list-item
58
- */
59
- export const OrderedList = Node.create<OrderedListOptions>({
60
- name: 'orderedList',
61
-
62
- addOptions() {
63
- return {
64
- itemTypeName: 'listItem',
65
- HTMLAttributes: {},
66
- keepMarks: false,
67
- keepAttributes: false,
68
- }
69
- },
70
-
71
- group: 'block list',
72
-
73
- content() {
74
- return `${this.options.itemTypeName}+`
75
- },
76
-
77
- addAttributes() {
78
- return {
79
- start: {
80
- default: 1,
81
- parseHTML: element => {
82
- return element.hasAttribute('start')
83
- ? parseInt(element.getAttribute('start') || '', 10)
84
- : 1
85
- },
86
- },
87
- type: {
88
- default: undefined,
89
- parseHTML: element => element.getAttribute('type'),
90
- },
91
- }
92
- },
93
-
94
- parseHTML() {
95
- return [
96
- {
97
- tag: 'ol',
98
- },
99
- ]
100
- },
101
-
102
- renderHTML({ HTMLAttributes }) {
103
- const { start, ...attributesWithoutStart } = HTMLAttributes
104
-
105
- return start === 1
106
- ? ['ol', mergeAttributes(this.options.HTMLAttributes, attributesWithoutStart), 0]
107
- : ['ol', mergeAttributes(this.options.HTMLAttributes, HTMLAttributes), 0]
108
- },
109
-
110
- addCommands() {
111
- return {
112
- toggleOrderedList: () => ({ commands, chain }) => {
113
- if (this.options.keepAttributes) {
114
- return chain().toggleList(this.name, this.options.itemTypeName, this.options.keepMarks).updateAttributes(ListItemName, this.editor.getAttributes(TextStyleName)).run()
115
- }
116
- return commands.toggleList(this.name, this.options.itemTypeName, this.options.keepMarks)
117
- },
118
- }
119
- },
120
-
121
- addKeyboardShortcuts() {
122
- return {
123
- 'Mod-Shift-7': () => this.editor.commands.toggleOrderedList(),
124
- }
125
- },
126
-
127
- addInputRules() {
128
- let inputRule = wrappingInputRule({
129
- find: inputRegex,
130
- type: this.type,
131
- getAttributes: match => ({ start: +match[1] }),
132
- joinPredicate: (match, node) => node.childCount + node.attrs.start === +match[1],
133
- })
134
-
135
- if (this.options.keepMarks || this.options.keepAttributes) {
136
- inputRule = wrappingInputRule({
137
- find: inputRegex,
138
- type: this.type,
139
- keepMarks: this.options.keepMarks,
140
- keepAttributes: this.options.keepAttributes,
141
- getAttributes: match => ({ start: +match[1], ...this.editor.getAttributes(TextStyleName) }),
142
- joinPredicate: (match, node) => node.childCount + node.attrs.start === +match[1],
143
- editor: this.editor,
144
- })
145
- }
146
- return [
147
- inputRule,
148
- ]
149
- },
150
- })