@tiptap/extension-ordered-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,98 +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
- OrderedList: () => OrderedList,
24
- default: () => index_default,
25
- inputRegex: () => inputRegex
23
+ OrderedList: () => import_extension_list2.OrderedList,
24
+ OrderedListOptions: () => import_extension_list2.OrderedListOptions,
25
+ default: () => index_default
26
26
  });
27
27
  module.exports = __toCommonJS(index_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 [inputRule];
107
- }
108
- });
109
-
110
- // src/index.ts
111
- var index_default = OrderedList;
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;
112
31
  // Annotate the CommonJS export names for ESM import in node:
113
32
  0 && (module.exports = {
114
33
  OrderedList,
115
- inputRegex
34
+ OrderedListOptions
116
35
  });
117
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') ? parseInt(element.getAttribute('start') || '', 10) : 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:\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-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 [inputRule]\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;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,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AO,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,CAAC,SAAS;AAAA,EACnB;AACF,CAAC;;;ADlJD,IAAO,gBAAQ;","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,89 +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 [inputRule];
79
- }
80
- });
81
-
82
1
  // src/index.ts
2
+ import { OrderedList } from "@tiptap/extension-list";
3
+ import { OrderedList as OrderedList2, OrderedListOptions } from "@tiptap/extension-list";
83
4
  var index_default = OrderedList;
84
5
  export {
85
- OrderedList,
86
- index_default as default,
87
- inputRegex
6
+ OrderedList2 as OrderedList,
7
+ OrderedListOptions,
8
+ index_default as default
88
9
  };
89
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') ? parseInt(element.getAttribute('start') || '', 10) : 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:\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-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 [inputRule]\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,IAAI,SAAS,QAAQ,aAAa,OAAO,KAAK,IAAI,EAAE,IAAI;AAAA,QAC7F;AAAA,MACF;AAAA,MACA,MAAM;AAAA,QACJ,SAAS;AAAA,QACT,WAAW,aAAW,QAAQ,aAAa,MAAM;AAAA,MACnD;AAAA,IACF;AAAA,EACF;AAAA,EAEA,YAAY;AACV,WAAO;AAAA,MACL;AAAA,QACE,KAAK;AAAA,MACP;AAAA,IACF;AAAA,EACF;AAAA,EAEA,WAAW,EAAE,eAAe,GAAG;AAC7B,UAAM,EAAE,OAAO,GAAG,uBAAuB,IAAI;AAE7C,WAAO,UAAU,IACb,CAAC,MA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AA,QAC/E,QAAQ,KAAK;AAAA,MACf,CAAC;AAAA,IACH;AACA,WAAO,CAAC,SAAS;AAAA,EACnB;AACF,CAAC;;;AClJD,IAAO,gBAAQ;","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.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 { 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,151 +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') ? parseInt(element.getAttribute('start') || '', 10) : 1
83
- },
84
- },
85
- type: {
86
- default: undefined,
87
- parseHTML: element => element.getAttribute('type'),
88
- },
89
- }
90
- },
91
-
92
- parseHTML() {
93
- return [
94
- {
95
- tag: 'ol',
96
- },
97
- ]
98
- },
99
-
100
- renderHTML({ HTMLAttributes }) {
101
- const { start, ...attributesWithoutStart } = HTMLAttributes
102
-
103
- return start === 1
104
- ? ['ol', mergeAttributes(this.options.HTMLAttributes, attributesWithoutStart), 0]
105
- : ['ol', mergeAttributes(this.options.HTMLAttributes, HTMLAttributes), 0]
106
- },
107
-
108
- addCommands() {
109
- return {
110
- toggleOrderedList:
111
- () =>
112
- ({ commands, chain }) => {
113
- if (this.options.keepAttributes) {
114
- return chain()
115
- .toggleList(this.name, this.options.itemTypeName, this.options.keepMarks)
116
- .updateAttributes(ListItemName, this.editor.getAttributes(TextStyleName))
117
- .run()
118
- }
119
- return commands.toggleList(this.name, this.options.itemTypeName, this.options.keepMarks)
120
- },
121
- }
122
- },
123
-
124
- addKeyboardShortcuts() {
125
- return {
126
- 'Mod-Shift-7': () => this.editor.commands.toggleOrderedList(),
127
- }
128
- },
129
-
130
- addInputRules() {
131
- let inputRule = wrappingInputRule({
132
- find: inputRegex,
133
- type: this.type,
134
- getAttributes: match => ({ start: +match[1] }),
135
- joinPredicate: (match, node) => node.childCount + node.attrs.start === +match[1],
136
- })
137
-
138
- if (this.options.keepMarks || this.options.keepAttributes) {
139
- inputRule = wrappingInputRule({
140
- find: inputRegex,
141
- type: this.type,
142
- keepMarks: this.options.keepMarks,
143
- keepAttributes: this.options.keepAttributes,
144
- getAttributes: match => ({ start: +match[1], ...this.editor.getAttributes(TextStyleName) }),
145
- joinPredicate: (match, node) => node.childCount + node.attrs.start === +match[1],
146
- editor: this.editor,
147
- })
148
- }
149
- return [inputRule]
150
- },
151
- })