@tiptap/extension-ordered-list 3.0.0-next.0 → 3.0.0-next.2

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.
Files changed (176) hide show
  1. package/dist/index.cjs +113 -169
  2. package/dist/index.cjs.map +1 -1
  3. package/dist/{packages/extension-ordered-list/src/ordered-list.d.ts → index.d.cts} +6 -3
  4. package/dist/index.d.ts +52 -0
  5. package/dist/index.js +88 -166
  6. package/dist/index.js.map +1 -1
  7. package/package.json +6 -8
  8. package/src/ordered-list.ts +8 -4
  9. package/dist/index.umd.js +0 -179
  10. package/dist/index.umd.js.map +0 -1
  11. package/dist/packages/core/src/CommandManager.d.ts +0 -20
  12. package/dist/packages/core/src/Editor.d.ts +0 -159
  13. package/dist/packages/core/src/EventEmitter.d.ts +0 -11
  14. package/dist/packages/core/src/Extension.d.ts +0 -343
  15. package/dist/packages/core/src/ExtensionManager.d.ts +0 -55
  16. package/dist/packages/core/src/InputRule.d.ts +0 -42
  17. package/dist/packages/core/src/Mark.d.ts +0 -451
  18. package/dist/packages/core/src/Node.d.ts +0 -611
  19. package/dist/packages/core/src/NodePos.d.ts +0 -44
  20. package/dist/packages/core/src/NodeView.d.ts +0 -31
  21. package/dist/packages/core/src/PasteRule.d.ts +0 -50
  22. package/dist/packages/core/src/Tracker.d.ts +0 -11
  23. package/dist/packages/core/src/commands/blur.d.ts +0 -13
  24. package/dist/packages/core/src/commands/clearContent.d.ts +0 -14
  25. package/dist/packages/core/src/commands/clearNodes.d.ts +0 -13
  26. package/dist/packages/core/src/commands/command.d.ts +0 -18
  27. package/dist/packages/core/src/commands/createParagraphNear.d.ts +0 -13
  28. package/dist/packages/core/src/commands/cut.d.ts +0 -20
  29. package/dist/packages/core/src/commands/deleteCurrentNode.d.ts +0 -13
  30. package/dist/packages/core/src/commands/deleteNode.d.ts +0 -15
  31. package/dist/packages/core/src/commands/deleteRange.d.ts +0 -14
  32. package/dist/packages/core/src/commands/deleteSelection.d.ts +0 -13
  33. package/dist/packages/core/src/commands/enter.d.ts +0 -13
  34. package/dist/packages/core/src/commands/exitCode.d.ts +0 -13
  35. package/dist/packages/core/src/commands/extendMarkRange.d.ts +0 -25
  36. package/dist/packages/core/src/commands/first.d.ts +0 -14
  37. package/dist/packages/core/src/commands/focus.d.ts +0 -27
  38. package/dist/packages/core/src/commands/forEach.d.ts +0 -14
  39. package/dist/packages/core/src/commands/index.d.ts +0 -55
  40. package/dist/packages/core/src/commands/insertContent.d.ts +0 -34
  41. package/dist/packages/core/src/commands/insertContentAt.d.ts +0 -47
  42. package/dist/packages/core/src/commands/join.d.ts +0 -41
  43. package/dist/packages/core/src/commands/joinItemBackward.d.ts +0 -13
  44. package/dist/packages/core/src/commands/joinItemForward.d.ts +0 -13
  45. package/dist/packages/core/src/commands/joinTextblockBackward.d.ts +0 -12
  46. package/dist/packages/core/src/commands/joinTextblockForward.d.ts +0 -12
  47. package/dist/packages/core/src/commands/keyboardShortcut.d.ts +0 -14
  48. package/dist/packages/core/src/commands/lift.d.ts +0 -17
  49. package/dist/packages/core/src/commands/liftEmptyBlock.d.ts +0 -13
  50. package/dist/packages/core/src/commands/liftListItem.d.ts +0 -15
  51. package/dist/packages/core/src/commands/newlineInCode.d.ts +0 -13
  52. package/dist/packages/core/src/commands/resetAttributes.d.ts +0 -16
  53. package/dist/packages/core/src/commands/scrollIntoView.d.ts +0 -13
  54. package/dist/packages/core/src/commands/selectAll.d.ts +0 -13
  55. package/dist/packages/core/src/commands/selectNodeBackward.d.ts +0 -13
  56. package/dist/packages/core/src/commands/selectNodeForward.d.ts +0 -13
  57. package/dist/packages/core/src/commands/selectParentNode.d.ts +0 -13
  58. package/dist/packages/core/src/commands/selectTextblockEnd.d.ts +0 -13
  59. package/dist/packages/core/src/commands/selectTextblockStart.d.ts +0 -13
  60. package/dist/packages/core/src/commands/setContent.d.ts +0 -40
  61. package/dist/packages/core/src/commands/setMark.d.ts +0 -15
  62. package/dist/packages/core/src/commands/setMeta.d.ts +0 -15
  63. package/dist/packages/core/src/commands/setNode.d.ts +0 -16
  64. package/dist/packages/core/src/commands/setNodeSelection.d.ts +0 -14
  65. package/dist/packages/core/src/commands/setTextSelection.d.ts +0 -14
  66. package/dist/packages/core/src/commands/sinkListItem.d.ts +0 -15
  67. package/dist/packages/core/src/commands/splitBlock.d.ts +0 -17
  68. package/dist/packages/core/src/commands/splitListItem.d.ts +0 -15
  69. package/dist/packages/core/src/commands/toggleList.d.ts +0 -18
  70. package/dist/packages/core/src/commands/toggleMark.d.ts +0 -30
  71. package/dist/packages/core/src/commands/toggleNode.d.ts +0 -17
  72. package/dist/packages/core/src/commands/toggleWrap.d.ts +0 -16
  73. package/dist/packages/core/src/commands/undoInputRule.d.ts +0 -13
  74. package/dist/packages/core/src/commands/unsetAllMarks.d.ts +0 -13
  75. package/dist/packages/core/src/commands/unsetMark.d.ts +0 -25
  76. package/dist/packages/core/src/commands/updateAttributes.d.ts +0 -24
  77. package/dist/packages/core/src/commands/wrapIn.d.ts +0 -16
  78. package/dist/packages/core/src/commands/wrapInList.d.ts +0 -16
  79. package/dist/packages/core/src/extensions/clipboardTextSerializer.d.ts +0 -5
  80. package/dist/packages/core/src/extensions/commands.d.ts +0 -3
  81. package/dist/packages/core/src/extensions/editable.d.ts +0 -2
  82. package/dist/packages/core/src/extensions/focusEvents.d.ts +0 -2
  83. package/dist/packages/core/src/extensions/index.d.ts +0 -6
  84. package/dist/packages/core/src/extensions/keymap.d.ts +0 -2
  85. package/dist/packages/core/src/extensions/tabindex.d.ts +0 -2
  86. package/dist/packages/core/src/helpers/combineTransactionSteps.d.ts +0 -10
  87. package/dist/packages/core/src/helpers/createChainableState.d.ts +0 -10
  88. package/dist/packages/core/src/helpers/createDocument.d.ts +0 -12
  89. package/dist/packages/core/src/helpers/createNodeFromContent.d.ts +0 -15
  90. package/dist/packages/core/src/helpers/defaultBlockAt.d.ts +0 -7
  91. package/dist/packages/core/src/helpers/findChildren.d.ts +0 -9
  92. package/dist/packages/core/src/helpers/findChildrenInRange.d.ts +0 -10
  93. package/dist/packages/core/src/helpers/findParentNode.d.ts +0 -16
  94. package/dist/packages/core/src/helpers/findParentNodeClosestToPos.d.ts +0 -17
  95. package/dist/packages/core/src/helpers/generateHTML.d.ts +0 -8
  96. package/dist/packages/core/src/helpers/generateJSON.d.ts +0 -8
  97. package/dist/packages/core/src/helpers/generateText.d.ts +0 -12
  98. package/dist/packages/core/src/helpers/getAttributes.d.ts +0 -9
  99. package/dist/packages/core/src/helpers/getAttributesFromExtensions.d.ts +0 -6
  100. package/dist/packages/core/src/helpers/getChangedRanges.d.ts +0 -11
  101. package/dist/packages/core/src/helpers/getDebugJSON.d.ts +0 -8
  102. package/dist/packages/core/src/helpers/getExtensionField.d.ts +0 -9
  103. package/dist/packages/core/src/helpers/getHTMLFromFragment.d.ts +0 -2
  104. package/dist/packages/core/src/helpers/getMarkAttributes.d.ts +0 -3
  105. package/dist/packages/core/src/helpers/getMarkRange.d.ts +0 -3
  106. package/dist/packages/core/src/helpers/getMarkType.d.ts +0 -2
  107. package/dist/packages/core/src/helpers/getMarksBetween.d.ts +0 -3
  108. package/dist/packages/core/src/helpers/getNodeAtPosition.d.ts +0 -11
  109. package/dist/packages/core/src/helpers/getNodeAttributes.d.ts +0 -3
  110. package/dist/packages/core/src/helpers/getNodeType.d.ts +0 -2
  111. package/dist/packages/core/src/helpers/getRenderedAttributes.d.ts +0 -3
  112. package/dist/packages/core/src/helpers/getSchema.d.ts +0 -4
  113. package/dist/packages/core/src/helpers/getSchemaByResolvedExtensions.d.ts +0 -10
  114. package/dist/packages/core/src/helpers/getSchemaTypeByName.d.ts +0 -8
  115. package/dist/packages/core/src/helpers/getSchemaTypeNameByName.d.ts +0 -8
  116. package/dist/packages/core/src/helpers/getSplittedAttributes.d.ts +0 -9
  117. package/dist/packages/core/src/helpers/getText.d.ts +0 -15
  118. package/dist/packages/core/src/helpers/getTextBetween.d.ts +0 -14
  119. package/dist/packages/core/src/helpers/getTextContentFromNodes.d.ts +0 -8
  120. package/dist/packages/core/src/helpers/getTextSerializersFromSchema.d.ts +0 -8
  121. package/dist/packages/core/src/helpers/index.d.ts +0 -50
  122. package/dist/packages/core/src/helpers/injectExtensionAttributesToParseRule.d.ts +0 -9
  123. package/dist/packages/core/src/helpers/isActive.d.ts +0 -2
  124. package/dist/packages/core/src/helpers/isAtEndOfNode.d.ts +0 -2
  125. package/dist/packages/core/src/helpers/isAtStartOfNode.d.ts +0 -2
  126. package/dist/packages/core/src/helpers/isExtensionRulesEnabled.d.ts +0 -2
  127. package/dist/packages/core/src/helpers/isList.d.ts +0 -2
  128. package/dist/packages/core/src/helpers/isMarkActive.d.ts +0 -3
  129. package/dist/packages/core/src/helpers/isNodeActive.d.ts +0 -3
  130. package/dist/packages/core/src/helpers/isNodeEmpty.d.ts +0 -8
  131. package/dist/packages/core/src/helpers/isNodeSelection.d.ts +0 -2
  132. package/dist/packages/core/src/helpers/isTextSelection.d.ts +0 -2
  133. package/dist/packages/core/src/helpers/posToDOMRect.d.ts +0 -2
  134. package/dist/packages/core/src/helpers/resolveFocusPosition.d.ts +0 -4
  135. package/dist/packages/core/src/helpers/selectionToInsertionEnd.d.ts +0 -2
  136. package/dist/packages/core/src/helpers/splitExtensions.d.ts +0 -9
  137. package/dist/packages/core/src/index.d.ts +0 -24
  138. package/dist/packages/core/src/inputRules/index.d.ts +0 -5
  139. package/dist/packages/core/src/inputRules/markInputRule.d.ts +0 -13
  140. package/dist/packages/core/src/inputRules/nodeInputRule.d.ts +0 -23
  141. package/dist/packages/core/src/inputRules/textInputRule.d.ts +0 -10
  142. package/dist/packages/core/src/inputRules/textblockTypeInputRule.d.ts +0 -15
  143. package/dist/packages/core/src/inputRules/wrappingInputRule.d.ts +0 -28
  144. package/dist/packages/core/src/pasteRules/index.d.ts +0 -3
  145. package/dist/packages/core/src/pasteRules/markPasteRule.d.ts +0 -13
  146. package/dist/packages/core/src/pasteRules/nodePasteRule.d.ts +0 -13
  147. package/dist/packages/core/src/pasteRules/textPasteRule.d.ts +0 -10
  148. package/dist/packages/core/src/style.d.ts +0 -1
  149. package/dist/packages/core/src/types.d.ts +0 -253
  150. package/dist/packages/core/src/utilities/callOrReturn.d.ts +0 -9
  151. package/dist/packages/core/src/utilities/createStyleTag.d.ts +0 -1
  152. package/dist/packages/core/src/utilities/deleteProps.d.ts +0 -6
  153. package/dist/packages/core/src/utilities/elementFromString.d.ts +0 -1
  154. package/dist/packages/core/src/utilities/escapeForRegEx.d.ts +0 -1
  155. package/dist/packages/core/src/utilities/findDuplicates.d.ts +0 -1
  156. package/dist/packages/core/src/utilities/fromString.d.ts +0 -1
  157. package/dist/packages/core/src/utilities/index.d.ts +0 -20
  158. package/dist/packages/core/src/utilities/isAndroid.d.ts +0 -1
  159. package/dist/packages/core/src/utilities/isEmptyObject.d.ts +0 -1
  160. package/dist/packages/core/src/utilities/isFunction.d.ts +0 -1
  161. package/dist/packages/core/src/utilities/isMacOS.d.ts +0 -1
  162. package/dist/packages/core/src/utilities/isNumber.d.ts +0 -1
  163. package/dist/packages/core/src/utilities/isPlainObject.d.ts +0 -1
  164. package/dist/packages/core/src/utilities/isRegExp.d.ts +0 -1
  165. package/dist/packages/core/src/utilities/isString.d.ts +0 -1
  166. package/dist/packages/core/src/utilities/isiOS.d.ts +0 -1
  167. package/dist/packages/core/src/utilities/mergeAttributes.d.ts +0 -1
  168. package/dist/packages/core/src/utilities/mergeDeep.d.ts +0 -1
  169. package/dist/packages/core/src/utilities/minMax.d.ts +0 -1
  170. package/dist/packages/core/src/utilities/objectIncludes.d.ts +0 -8
  171. package/dist/packages/core/src/utilities/removeDuplicates.d.ts +0 -8
  172. package/dist/packages/extension-list-item/src/index.d.ts +0 -3
  173. package/dist/packages/extension-list-item/src/list-item.d.ts +0 -26
  174. package/dist/packages/extension-ordered-list/src/index.d.ts +0 -3
  175. package/dist/packages/extension-text-style/src/index.d.ts +0 -3
  176. package/dist/packages/extension-text-style/src/text-style.d.ts +0 -26
package/dist/index.cjs CHANGED
@@ -1,175 +1,119 @@
1
- 'use strict';
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
2
19
 
3
- Object.defineProperty(exports, '__esModule', { value: true });
4
-
5
- var core = require('@tiptap/core');
6
-
7
- /**
8
- * This extension allows you to create list items.
9
- * @see https://www.tiptap.dev/api/nodes/list-item
10
- */
11
- const ListItem = core.Node.create({
12
- name: 'listItem',
13
- addOptions() {
14
- return {
15
- HTMLAttributes: {},
16
- bulletListTypeName: 'bulletList',
17
- orderedListTypeName: 'orderedList',
18
- };
19
- },
20
- content: 'paragraph block*',
21
- defining: true,
22
- parseHTML() {
23
- return [
24
- {
25
- tag: 'li',
26
- },
27
- ];
28
- },
29
- renderHTML({ HTMLAttributes }) {
30
- return ['li', core.mergeAttributes(this.options.HTMLAttributes, HTMLAttributes), 0];
31
- },
32
- addKeyboardShortcuts() {
33
- return {
34
- Enter: () => this.editor.commands.splitListItem(this.name),
35
- Tab: () => this.editor.commands.sinkListItem(this.name),
36
- 'Shift-Tab': () => this.editor.commands.liftListItem(this.name),
37
- };
38
- },
39
- });
40
-
41
- /**
42
- * This extension allows you to create text styles. It is required by default
43
- * for the `textColor` and `backgroundColor` extensions.
44
- * @see https://www.tiptap.dev/api/marks/text-style
45
- */
46
- const TextStyle = core.Mark.create({
47
- name: 'textStyle',
48
- addOptions() {
49
- return {
50
- HTMLAttributes: {},
51
- };
52
- },
53
- parseHTML() {
54
- return [
55
- {
56
- tag: 'span',
57
- getAttrs: element => {
58
- const hasStyles = element.hasAttribute('style');
59
- if (!hasStyles) {
60
- return false;
61
- }
62
- return {};
63
- },
64
- },
65
- ];
66
- },
67
- renderHTML({ HTMLAttributes }) {
68
- return ['span', core.mergeAttributes(this.options.HTMLAttributes, HTMLAttributes), 0];
69
- },
70
- addCommands() {
71
- return {
72
- removeEmptyTextStyle: () => ({ state, commands }) => {
73
- const attributes = core.getMarkAttributes(state, this.type);
74
- const hasStyles = Object.entries(attributes).some(([, value]) => !!value);
75
- if (hasStyles) {
76
- return true;
77
- }
78
- return commands.unsetMark(this.name);
79
- },
80
- };
81
- },
20
+ // src/index.ts
21
+ var src_exports = {};
22
+ __export(src_exports, {
23
+ OrderedList: () => OrderedList,
24
+ default: () => src_default,
25
+ inputRegex: () => inputRegex
82
26
  });
27
+ module.exports = __toCommonJS(src_exports);
83
28
 
84
- /**
85
- * Matches an ordered list to a 1. on input (or any number followed by a dot).
86
- */
87
- const inputRegex = /^(\d+)\.\s$/;
88
- /**
89
- * This extension allows you to create ordered lists.
90
- * This requires the ListItem extension
91
- * @see https://www.tiptap.dev/api/nodes/ordered-list
92
- * @see https://www.tiptap.dev/api/nodes/list-item
93
- */
94
- const OrderedList = core.Node.create({
95
- name: 'orderedList',
96
- addOptions() {
97
- return {
98
- itemTypeName: 'listItem',
99
- HTMLAttributes: {},
100
- keepMarks: false,
101
- keepAttributes: false,
102
- };
103
- },
104
- group: 'block list',
105
- content() {
106
- return `${this.options.itemTypeName}+`;
107
- },
108
- addAttributes() {
109
- return {
110
- start: {
111
- default: 1,
112
- parseHTML: element => {
113
- return element.hasAttribute('start')
114
- ? parseInt(element.getAttribute('start') || '', 10)
115
- : 1;
116
- },
117
- },
118
- };
119
- },
120
- parseHTML() {
121
- return [
122
- {
123
- tag: 'ol',
124
- },
125
- ];
126
- },
127
- renderHTML({ HTMLAttributes }) {
128
- const { start, ...attributesWithoutStart } = HTMLAttributes;
129
- return start === 1
130
- ? ['ol', core.mergeAttributes(this.options.HTMLAttributes, attributesWithoutStart), 0]
131
- : ['ol', core.mergeAttributes(this.options.HTMLAttributes, HTMLAttributes), 0];
132
- },
133
- addCommands() {
134
- return {
135
- toggleOrderedList: () => ({ commands, chain }) => {
136
- if (this.options.keepAttributes) {
137
- return chain().toggleList(this.name, this.options.itemTypeName, this.options.keepMarks).updateAttributes(ListItem.name, this.editor.getAttributes(TextStyle.name)).run();
138
- }
139
- return commands.toggleList(this.name, this.options.itemTypeName, this.options.keepMarks);
140
- },
141
- };
142
- },
143
- addKeyboardShortcuts() {
144
- return {
145
- 'Mod-Shift-7': () => this.editor.commands.toggleOrderedList(),
146
- };
147
- },
148
- addInputRules() {
149
- let inputRule = core.wrappingInputRule({
150
- find: inputRegex,
151
- type: this.type,
152
- getAttributes: match => ({ start: +match[1] }),
153
- joinPredicate: (match, node) => node.childCount + node.attrs.start === +match[1],
154
- });
155
- if (this.options.keepMarks || this.options.keepAttributes) {
156
- inputRule = core.wrappingInputRule({
157
- find: inputRegex,
158
- type: this.type,
159
- keepMarks: this.options.keepMarks,
160
- keepAttributes: this.options.keepAttributes,
161
- getAttributes: match => ({ start: +match[1], ...this.editor.getAttributes(TextStyle.name) }),
162
- joinPredicate: (match, node) => node.childCount + node.attrs.start === +match[1],
163
- editor: this.editor,
164
- });
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();
165
78
  }
166
- return [
167
- inputRule,
168
- ];
169
- },
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
+ }
170
110
  });
171
111
 
172
- exports.OrderedList = OrderedList;
173
- exports.default = OrderedList;
174
- exports.inputRegex = inputRegex;
175
- //# sourceMappingURL=index.cjs.map
112
+ // src/index.ts
113
+ var src_default = OrderedList;
114
+ // Annotate the CommonJS export names for ESM import in node:
115
+ 0 && (module.exports = {
116
+ OrderedList,
117
+ inputRegex
118
+ });
119
+ //# sourceMappingURL=index.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs","sources":["../../extension-list-item/src/list-item.ts","../../extension-text-style/src/text-style.ts","../src/ordered-list.ts"],"sourcesContent":["import { mergeAttributes, Node } from '@tiptap/core'\n\nexport interface ListItemOptions {\n /**\n * The HTML attributes for a list item node.\n * @default {}\n * @example { class: 'foo' }\n */\n HTMLAttributes: Record<string, any>,\n\n /**\n * The node type for bulletList nodes\n * @default 'bulletList'\n * @example 'myCustomBulletList'\n */\n bulletListTypeName: string\n\n /**\n * The node type for orderedList nodes\n * @default 'orderedList'\n * @example 'myCustomOrderedList'\n */\n orderedListTypeName: string\n}\n\n/**\n * This extension allows you to create list items.\n * @see https://www.tiptap.dev/api/nodes/list-item\n */\nexport const ListItem = Node.create<ListItemOptions>({\n name: 'listItem',\n\n addOptions() {\n return {\n HTMLAttributes: {},\n bulletListTypeName: 'bulletList',\n orderedListTypeName: 'orderedList',\n }\n },\n\n content: 'paragraph block*',\n\n defining: true,\n\n parseHTML() {\n return [\n {\n tag: 'li',\n },\n ]\n },\n\n renderHTML({ HTMLAttributes }) {\n return ['li', mergeAttributes(this.options.HTMLAttributes, HTMLAttributes), 0]\n },\n\n addKeyboardShortcuts() {\n return {\n Enter: () => this.editor.commands.splitListItem(this.name),\n Tab: () => this.editor.commands.sinkListItem(this.name),\n 'Shift-Tab': () => this.editor.commands.liftListItem(this.name),\n }\n },\n})\n","import {\n getMarkAttributes,\n Mark,\n mergeAttributes,\n} from '@tiptap/core'\n\nexport interface TextStyleOptions {\n /**\n * HTML attributes to add to the span element.\n * @default {}\n * @example { class: 'foo' }\n */\n HTMLAttributes: Record<string, any>,\n}\n\ndeclare module '@tiptap/core' {\n interface Commands<ReturnType> {\n textStyle: {\n /**\n * Remove spans without inline style attributes.\n * @example editor.commands.removeEmptyTextStyle()\n */\n removeEmptyTextStyle: () => ReturnType,\n }\n }\n}\n\n/**\n * This extension allows you to create text styles. It is required by default\n * for the `textColor` and `backgroundColor` extensions.\n * @see https://www.tiptap.dev/api/marks/text-style\n */\nexport const TextStyle = Mark.create<TextStyleOptions>({\n name: 'textStyle',\n\n addOptions() {\n return {\n HTMLAttributes: {},\n }\n },\n\n parseHTML() {\n return [\n {\n tag: 'span',\n getAttrs: element => {\n const hasStyles = (element as HTMLElement).hasAttribute('style')\n\n if (!hasStyles) {\n return false\n }\n\n return {}\n },\n },\n ]\n },\n\n renderHTML({ HTMLAttributes }) {\n return ['span', mergeAttributes(this.options.HTMLAttributes, HTMLAttributes), 0]\n },\n\n addCommands() {\n return {\n removeEmptyTextStyle: () => ({ state, commands }) => {\n const attributes = getMarkAttributes(state, this.type)\n const hasStyles = Object.entries(attributes).some(([, value]) => !!value)\n\n if (hasStyles) {\n return true\n }\n\n return commands.unsetMark(this.name)\n },\n }\n },\n\n})\n","import { mergeAttributes, Node, wrappingInputRule } from '@tiptap/core'\n\nimport ListItem from '../../extension-list-item/src/index.js'\nimport TextStyle from '../../extension-text-style/src/index.js'\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 }\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(ListItem.name, this.editor.getAttributes(TextStyle.name)).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(TextStyle.name) }),\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"],"names":["Node","mergeAttributes","Mark","getMarkAttributes","wrappingInputRule"],"mappings":";;;;;;AAyBA;;;AAGG;AACI,MAAM,QAAQ,GAAGA,SAAI,CAAC,MAAM,CAAkB;AACnD,IAAA,IAAI,EAAE,UAAU;IAEhB,UAAU,GAAA;QACR,OAAO;AACL,YAAA,cAAc,EAAE,EAAE;AAClB,YAAA,kBAAkB,EAAE,YAAY;AAChC,YAAA,mBAAmB,EAAE,aAAa;SACnC,CAAA;KACF;AAED,IAAA,OAAO,EAAE,kBAAkB;AAE3B,IAAA,QAAQ,EAAE,IAAI;IAEd,SAAS,GAAA;QACP,OAAO;AACL,YAAA;AACE,gBAAA,GAAG,EAAE,IAAI;AACV,aAAA;SACF,CAAA;KACF;IAED,UAAU,CAAC,EAAE,cAAc,EAAE,EAAA;AAC3B,QAAA,OAAO,CAAC,IAAI,EAAEC,oBAAe,CAAC,IAAI,CAAC,OAAO,CAAC,cAAc,EAAE,cAAc,CAAC,EAAE,CAAC,CAAC,CAAA;KAC/E;IAED,oBAAoB,GAAA;QAClB,OAAO;AACL,YAAA,KAAK,EAAE,MAAM,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,aAAa,CAAC,IAAI,CAAC,IAAI,CAAC;AAC1D,YAAA,GAAG,EAAE,MAAM,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,YAAY,CAAC,IAAI,CAAC,IAAI,CAAC;AACvD,YAAA,WAAW,EAAE,MAAM,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,YAAY,CA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AAC,IAAI;AACf,gBAAA,SAAS,EAAE,IAAI,CAAC,OAAO,CAAC,SAAS;AACjC,gBAAA,cAAc,EAAE,IAAI,CAAC,OAAO,CAAC,cAAc;gBAC3C,aAAa,EAAE,KAAK,KAAK,EAAE,KAAK,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,GAAG,IAAI,CAAC,MAAM,CAAC,aAAa,CAAC,SAAS,CAAC,IAAI,CAAC,EAAE,CAAC;gBAC5F,aAAa,EAAE,CAAC,KAAK,EAAE,IAAI,KAAK,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC,KAAK,CAAC,KAAK,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC;gBAChF,MAAM,EAAE,IAAI,CAAC,MAAM;AACpB,aAAA,CAAC,CAAA;SACH;QACD,OAAO;YACL,SAAS;SACV,CAAA;KACF;AACF,CAAA;;;;;;"}
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;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;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,UAAM,6BAAgB,KAAK,QAAQ,gBAAgB,sBAAsB,GAAG,CAAC,IAC9E,CAAC,UAAM,6BAAgB,KAAK,QAAQ,gBAAgB,cAAc,GAAG,CAAC;AAAA,EAC5E;AAAA,EAEA,cAAc;AACZ,WAAO;AAAA,MACL,mBAAmB,MAAM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
- export interface OrderedListOptions {
2
+
3
+ interface OrderedListOptions {
3
4
  /**
4
5
  * The node type name for list items.
5
6
  * @default 'listItem'
@@ -39,11 +40,13 @@ declare module '@tiptap/core' {
39
40
  /**
40
41
  * Matches an ordered list to a 1. on input (or any number followed by a dot).
41
42
  */
42
- export declare const inputRegex: RegExp;
43
+ declare const inputRegex: RegExp;
43
44
  /**
44
45
  * This extension allows you to create ordered lists.
45
46
  * This requires the ListItem extension
46
47
  * @see https://www.tiptap.dev/api/nodes/ordered-list
47
48
  * @see https://www.tiptap.dev/api/nodes/list-item
48
49
  */
49
- export declare const OrderedList: Node<OrderedListOptions, any>;
50
+ declare const OrderedList: Node<OrderedListOptions, any>;
51
+
52
+ export { OrderedList, type OrderedListOptions, OrderedList as default, inputRegex };
@@ -0,0 +1,52 @@
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 };
package/dist/index.js CHANGED
@@ -1,169 +1,91 @@
1
- import { Node, mergeAttributes, Mark, getMarkAttributes, wrappingInputRule } from '@tiptap/core';
2
-
3
- /**
4
- * This extension allows you to create list items.
5
- * @see https://www.tiptap.dev/api/nodes/list-item
6
- */
7
- const ListItem = Node.create({
8
- name: 'listItem',
9
- addOptions() {
10
- return {
11
- HTMLAttributes: {},
12
- bulletListTypeName: 'bulletList',
13
- orderedListTypeName: 'orderedList',
14
- };
15
- },
16
- content: 'paragraph block*',
17
- defining: true,
18
- parseHTML() {
19
- return [
20
- {
21
- tag: 'li',
22
- },
23
- ];
24
- },
25
- renderHTML({ HTMLAttributes }) {
26
- return ['li', mergeAttributes(this.options.HTMLAttributes, HTMLAttributes), 0];
27
- },
28
- addKeyboardShortcuts() {
29
- return {
30
- Enter: () => this.editor.commands.splitListItem(this.name),
31
- Tab: () => this.editor.commands.sinkListItem(this.name),
32
- 'Shift-Tab': () => this.editor.commands.liftListItem(this.name),
33
- };
34
- },
35
- });
36
-
37
- /**
38
- * This extension allows you to create text styles. It is required by default
39
- * for the `textColor` and `backgroundColor` extensions.
40
- * @see https://www.tiptap.dev/api/marks/text-style
41
- */
42
- const TextStyle = Mark.create({
43
- name: 'textStyle',
44
- addOptions() {
45
- return {
46
- HTMLAttributes: {},
47
- };
48
- },
49
- parseHTML() {
50
- return [
51
- {
52
- tag: 'span',
53
- getAttrs: element => {
54
- const hasStyles = element.hasAttribute('style');
55
- if (!hasStyles) {
56
- return false;
57
- }
58
- return {};
59
- },
60
- },
61
- ];
62
- },
63
- renderHTML({ HTMLAttributes }) {
64
- return ['span', mergeAttributes(this.options.HTMLAttributes, HTMLAttributes), 0];
65
- },
66
- addCommands() {
67
- return {
68
- removeEmptyTextStyle: () => ({ state, commands }) => {
69
- const attributes = getMarkAttributes(state, this.type);
70
- const hasStyles = Object.entries(attributes).some(([, value]) => !!value);
71
- if (hasStyles) {
72
- return true;
73
- }
74
- return commands.unsetMark(this.name);
75
- },
76
- };
77
- },
78
- });
79
-
80
- /**
81
- * Matches an ordered list to a 1. on input (or any number followed by a dot).
82
- */
83
- const inputRegex = /^(\d+)\.\s$/;
84
- /**
85
- * This extension allows you to create ordered lists.
86
- * This requires the ListItem extension
87
- * @see https://www.tiptap.dev/api/nodes/ordered-list
88
- * @see https://www.tiptap.dev/api/nodes/list-item
89
- */
90
- const OrderedList = Node.create({
91
- name: 'orderedList',
92
- addOptions() {
93
- return {
94
- itemTypeName: 'listItem',
95
- HTMLAttributes: {},
96
- keepMarks: false,
97
- keepAttributes: false,
98
- };
99
- },
100
- group: 'block list',
101
- content() {
102
- return `${this.options.itemTypeName}+`;
103
- },
104
- addAttributes() {
105
- return {
106
- start: {
107
- default: 1,
108
- parseHTML: element => {
109
- return element.hasAttribute('start')
110
- ? parseInt(element.getAttribute('start') || '', 10)
111
- : 1;
112
- },
113
- },
114
- };
115
- },
116
- parseHTML() {
117
- return [
118
- {
119
- tag: 'ol',
120
- },
121
- ];
122
- },
123
- renderHTML({ HTMLAttributes }) {
124
- const { start, ...attributesWithoutStart } = HTMLAttributes;
125
- return start === 1
126
- ? ['ol', mergeAttributes(this.options.HTMLAttributes, attributesWithoutStart), 0]
127
- : ['ol', mergeAttributes(this.options.HTMLAttributes, HTMLAttributes), 0];
128
- },
129
- addCommands() {
130
- return {
131
- toggleOrderedList: () => ({ commands, chain }) => {
132
- if (this.options.keepAttributes) {
133
- return chain().toggleList(this.name, this.options.itemTypeName, this.options.keepMarks).updateAttributes(ListItem.name, this.editor.getAttributes(TextStyle.name)).run();
134
- }
135
- return commands.toggleList(this.name, this.options.itemTypeName, this.options.keepMarks);
136
- },
137
- };
138
- },
139
- addKeyboardShortcuts() {
140
- return {
141
- 'Mod-Shift-7': () => this.editor.commands.toggleOrderedList(),
142
- };
143
- },
144
- addInputRules() {
145
- let inputRule = wrappingInputRule({
146
- find: inputRegex,
147
- type: this.type,
148
- getAttributes: match => ({ start: +match[1] }),
149
- joinPredicate: (match, node) => node.childCount + node.attrs.start === +match[1],
150
- });
151
- if (this.options.keepMarks || this.options.keepAttributes) {
152
- inputRule = wrappingInputRule({
153
- find: inputRegex,
154
- type: this.type,
155
- keepMarks: this.options.keepMarks,
156
- keepAttributes: this.options.keepAttributes,
157
- getAttributes: match => ({ start: +match[1], ...this.editor.getAttributes(TextStyle.name) }),
158
- joinPredicate: (match, node) => node.childCount + node.attrs.start === +match[1],
159
- editor: this.editor,
160
- });
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();
161
50
  }
162
- return [
163
- inputRule,
164
- ];
165
- },
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
+ }
166
82
  });
167
83
 
168
- export { OrderedList, OrderedList as default, inputRegex };
169
- //# sourceMappingURL=index.js.map
84
+ // src/index.ts
85
+ var src_default = OrderedList;
86
+ export {
87
+ OrderedList,
88
+ src_default as default,
89
+ inputRegex
90
+ };
91
+ //# sourceMappingURL=index.js.map