@tiptap/extension-list 3.26.1 → 3.27.1

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/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { Node, Extension, Editor } from '@tiptap/core';
1
+ import { Node, Extension, Editor, JSONContent } from '@tiptap/core';
2
2
  import * as prosemirror_model from 'prosemirror-model';
3
3
  import { NodeType, Node as Node$1 } from '@tiptap/pm/model';
4
4
  import { EditorState } from '@tiptap/pm/state';
@@ -183,6 +183,71 @@ declare const orderedListInputRegex: RegExp;
183
183
  */
184
184
  declare const OrderedList: Node<OrderedListOptions, any>;
185
185
 
186
+ /**
187
+ * Marker segment for ordered list lines: numeric, roman, or 1–2 letter alpha.
188
+ * Roman is matched before alpha so "iii" is roman; invalid romans like "aa" fall through to alpha.
189
+ */
190
+ declare const ORDERED_LIST_MARKER_PATTERN: string;
191
+ /**
192
+ * Convert a number to lowercase roman numerals.
193
+ * @example toRoman(1) // 'i'
194
+ * @example toRoman(4) // 'iv'
195
+ */
196
+ declare function toRoman(num: number): string;
197
+ /**
198
+ * Convert a number to uppercase roman numerals.
199
+ * @example toRomanUpper(1) // 'I'
200
+ * @example toRomanUpper(4) // 'IV'
201
+ */
202
+ declare function toRomanUpper(num: number): string;
203
+ /**
204
+ * Extract the list marker type from a marker string.
205
+ * Supports "1", "a", "A", "i", "I" marker styles.
206
+ *
207
+ * @param marker The text content of the list marker (e.g. "a", "1", "iii", "b")
208
+ * @returns The normalized type string, or undefined for default numeric type
209
+ */
210
+ declare function detectMarkerType(marker: string): string | undefined;
211
+ /**
212
+ * Convert a list marker string to its numeric start position.
213
+ *
214
+ * @param marker The text content of the list marker (e.g. "3", "b", "II")
215
+ * @returns The 1-based start value for the ordered list
216
+ */
217
+ declare function markerToStart(marker: string): number;
218
+ /**
219
+ * Returns true when all markers share the same style and increment by 1.
220
+ * Style is inferred from the first marker so ambiguous letters (e.g. "c", "i")
221
+ * are not re-classified differently on later lines.
222
+ */
223
+ declare function areOrderedListMarkersSequential(markers: string[]): boolean;
224
+ interface ParsedListMarker {
225
+ type?: string;
226
+ start: number;
227
+ }
228
+ /**
229
+ * Parse a list marker into HTML ordered-list attrs (type + start).
230
+ */
231
+ declare function parseListMarker(marker: string): ParsedListMarker;
232
+ /**
233
+ * Build orderedList node attrs from the first list item marker.
234
+ */
235
+ declare function buildOrderedListAttrsFromMarker(marker: string): Record<string, string | number>;
236
+ /**
237
+ * Returns the list marker prefix for a given item at a given index.
238
+ *
239
+ * @param type The list type attribute (e.g. "a", "A", "i", "I", null/undefined for default)
240
+ * @param index The zero-based index of the list item
241
+ * @param separator The separator to use (default: ". ")
242
+ * @returns The marker string (e.g. "a. ", "I. ", "1. ")
243
+ */
244
+ declare function getListMarker(type: string | null | undefined, index: number, separator?: string): string;
245
+
246
+ /**
247
+ * Parse plain-text pasted ordered list lines into JSONContent, or null if not a typed list.
248
+ */
249
+ declare function parsePlainTextOrderedListPaste(text: string): JSONContent | null;
250
+
186
251
  interface TaskItemOptions {
187
252
  /**
188
253
  * A callback function that is called when the checkbox is clicked while the editor is in readonly mode.
@@ -297,4 +362,4 @@ interface ListKitOptions {
297
362
  */
298
363
  declare const ListKit: Extension<ListKitOptions, any>;
299
364
 
300
- export { BulletList, type BulletListOptions, ListItem, type ListItemOptions, ListKeymap, type ListKeymapOptions, ListKit, type ListKitOptions, OrderedList, type OrderedListOptions, TaskItem, type TaskItemOptions, TaskList, type TaskListOptions, bulletListInputRegex, inputRegex, index as listHelpers, orderedListInputRegex };
365
+ export { BulletList, type BulletListOptions, ListItem, type ListItemOptions, ListKeymap, type ListKeymapOptions, ListKit, type ListKitOptions, ORDERED_LIST_MARKER_PATTERN, OrderedList, type OrderedListOptions, TaskItem, type TaskItemOptions, TaskList, type TaskListOptions, areOrderedListMarkersSequential, buildOrderedListAttrsFromMarker, bulletListInputRegex, detectMarkerType, getListMarker, inputRegex, index as listHelpers, markerToStart, orderedListInputRegex, parseListMarker, parsePlainTextOrderedListPaste, toRoman, toRomanUpper };
package/dist/index.js CHANGED
@@ -194,6 +194,194 @@ var createBranchingListDeleteKeymap = (itemName, wrapperNames) => {
194
194
  });
195
195
  };
196
196
 
197
+ // src/ordered-list/roman.ts
198
+ var ROMAN_NUMERALS = [
199
+ [1e3, "m"],
200
+ [900, "cm"],
201
+ [500, "d"],
202
+ [400, "cd"],
203
+ [100, "c"],
204
+ [90, "xc"],
205
+ [50, "l"],
206
+ [40, "xl"],
207
+ [10, "x"],
208
+ [9, "ix"],
209
+ [5, "v"],
210
+ [4, "iv"],
211
+ [1, "i"]
212
+ ];
213
+ var ALPHA_NUMERALS = "abcdefghijklmnopqrstuvwxyz";
214
+ var ORDERED_LIST_ALPHA_MARKER_PATTERN = "[a-zA-Z]{1,2}";
215
+ var ORDERED_LIST_MARKER_PATTERN = String.raw`\d+|[ivxlcdmIVXLCDM]+|${ORDERED_LIST_ALPHA_MARKER_PATTERN}`;
216
+ function toRoman(num) {
217
+ let remaining = num;
218
+ let result = "";
219
+ for (const [value, numeral] of ROMAN_NUMERALS) {
220
+ while (remaining >= value) {
221
+ result += numeral;
222
+ remaining -= value;
223
+ }
224
+ }
225
+ return result;
226
+ }
227
+ function toRomanUpper(num) {
228
+ return toRoman(num).toUpperCase();
229
+ }
230
+ function fromRoman(roman) {
231
+ const lower = roman.toLowerCase();
232
+ let index = 0;
233
+ let result = 0;
234
+ while (index < lower.length) {
235
+ let matched = false;
236
+ for (const [value, numeral] of ROMAN_NUMERALS) {
237
+ if (lower.startsWith(numeral, index)) {
238
+ result += value;
239
+ index += numeral.length;
240
+ matched = true;
241
+ break;
242
+ }
243
+ }
244
+ if (!matched) {
245
+ return 0;
246
+ }
247
+ }
248
+ return result;
249
+ }
250
+ function isValidRoman(marker) {
251
+ if (!/^[ivxlcdmIVXLCDM]+$/.test(marker)) {
252
+ return false;
253
+ }
254
+ const value = fromRoman(marker);
255
+ if (value <= 0) {
256
+ return false;
257
+ }
258
+ const expected = marker === marker.toLowerCase() ? toRoman(value) : toRomanUpper(value);
259
+ return expected === marker;
260
+ }
261
+ function fromAlpha(marker) {
262
+ const lower = marker.toLowerCase();
263
+ if (lower.length === 1) {
264
+ return lower.charCodeAt(0) - "a".charCodeAt(0) + 1;
265
+ }
266
+ if (lower.length === 2) {
267
+ const first = lower.charCodeAt(0) - "a".charCodeAt(0);
268
+ const second = lower.charCodeAt(1) - "a".charCodeAt(0);
269
+ return (first + 1) * 26 + second + 1;
270
+ }
271
+ return 0;
272
+ }
273
+ function toRomanAlpha(num) {
274
+ if (num <= 26) {
275
+ return ALPHA_NUMERALS[num - 1];
276
+ }
277
+ const first = Math.floor((num - 1) / 26) - 1;
278
+ const second = (num - 1) % 26;
279
+ if (first < 0) {
280
+ return ALPHA_NUMERALS[second];
281
+ }
282
+ return ALPHA_NUMERALS[first] + ALPHA_NUMERALS[second];
283
+ }
284
+ function detectMarkerType(marker) {
285
+ if (!marker || /^\d+$/.test(marker)) {
286
+ return void 0;
287
+ }
288
+ if (isValidRoman(marker)) {
289
+ return marker === marker.toLowerCase() ? "i" : "I";
290
+ }
291
+ if (/^[a-z]{1,2}$/.test(marker)) {
292
+ return "a";
293
+ }
294
+ if (/^[A-Z]{1,2}$/.test(marker)) {
295
+ return "A";
296
+ }
297
+ return void 0;
298
+ }
299
+ function markerToStart(marker) {
300
+ if (/^\d+$/.test(marker)) {
301
+ return parseInt(marker, 10);
302
+ }
303
+ const type = detectMarkerType(marker);
304
+ if (type === "i" || type === "I") {
305
+ return fromRoman(marker);
306
+ }
307
+ if (type === "a" || type === "A") {
308
+ const start = fromAlpha(marker);
309
+ return start > 0 ? start : 1;
310
+ }
311
+ const parsed = parseInt(marker, 10);
312
+ return Number.isNaN(parsed) ? 1 : parsed;
313
+ }
314
+ function startToMarker(type, start) {
315
+ if (type === "numeric") {
316
+ return String(start);
317
+ }
318
+ switch (type) {
319
+ case "a":
320
+ return toRomanAlpha(start);
321
+ case "A":
322
+ return toRomanAlpha(start).toUpperCase();
323
+ case "i":
324
+ return toRoman(start);
325
+ case "I":
326
+ return toRomanUpper(start);
327
+ default:
328
+ return String(start);
329
+ }
330
+ }
331
+ function areOrderedListMarkersSequential(markers) {
332
+ var _a;
333
+ if (markers.length === 0) {
334
+ return false;
335
+ }
336
+ const firstType = (_a = detectMarkerType(markers[0])) != null ? _a : "numeric";
337
+ const firstStart = markerToStart(markers[0]);
338
+ if (firstStart < 1) {
339
+ return false;
340
+ }
341
+ for (let i = 0; i < markers.length; i++) {
342
+ const expected = startToMarker(firstType, firstStart + i);
343
+ if (markers[i] !== expected) {
344
+ return false;
345
+ }
346
+ }
347
+ return true;
348
+ }
349
+ function parseListMarker(marker) {
350
+ return {
351
+ type: detectMarkerType(marker),
352
+ start: markerToStart(marker)
353
+ };
354
+ }
355
+ function buildOrderedListAttrsFromMarker(marker) {
356
+ const { type, start } = parseListMarker(marker);
357
+ const attrs = {};
358
+ if (type) {
359
+ attrs.type = type;
360
+ }
361
+ if (start !== 1) {
362
+ attrs.start = start;
363
+ }
364
+ return attrs;
365
+ }
366
+ function getListMarker(type, index, separator = ". ") {
367
+ const position = index + 1;
368
+ if (!type || type === "1") {
369
+ return `${position}${separator}`;
370
+ }
371
+ switch (type) {
372
+ case "a":
373
+ return `${toRomanAlpha(position)}${separator}`;
374
+ case "A":
375
+ return `${toRomanAlpha(position).toUpperCase()}${separator}`;
376
+ case "i":
377
+ return `${toRoman(position)}${separator}`;
378
+ case "I":
379
+ return `${toRomanUpper(position)}${separator}`;
380
+ default:
381
+ return `${position}${separator}`;
382
+ }
383
+ }
384
+
197
385
  // src/item/list-item.ts
198
386
  function isSameLineOrderedListToken(token) {
199
387
  var _a, _b;
@@ -296,13 +484,15 @@ var ListItem = Node2.create({
296
484
  node,
297
485
  h,
298
486
  (context) => {
299
- var _a, _b;
487
+ var _a, _b, _c, _d;
300
488
  if (context.parentType === "bulletList") {
301
489
  return "- ";
302
490
  }
303
491
  if (context.parentType === "orderedList") {
304
492
  const start = ((_b = (_a = context.meta) == null ? void 0 : _a.parentAttrs) == null ? void 0 : _b.start) || 1;
305
- return `${start + context.index}. `;
493
+ const type = (_d = (_c = context.meta) == null ? void 0 : _c.parentAttrs) == null ? void 0 : _d.type;
494
+ const index = start - 1 + (context.index || 0);
495
+ return getListMarker(type, index, ". ");
306
496
  }
307
497
  return "- ";
308
498
  },
@@ -596,17 +786,25 @@ var ListKeymap = Extension2.create({
596
786
  import { Extension as Extension3 } from "@tiptap/core";
597
787
 
598
788
  // src/ordered-list/ordered-list.ts
789
+ import { Plugin } from "@tiptap/pm/state";
599
790
  import { mergeAttributes as mergeAttributes3, Node as Node3, wrappingInputRule as wrappingInputRule2 } from "@tiptap/core";
600
791
 
601
792
  // src/ordered-list/utils.ts
602
- var ORDERED_LIST_ITEM_REGEX = /^(\s*)(\d+)\.\s+(.*)$/;
793
+ var ORDERED_LIST_ITEM_REGEX = new RegExp(
794
+ `^(\\s*)(${ORDERED_LIST_MARKER_PATTERN})([.)])\\s+(.*)$`
795
+ );
796
+ var ORDERED_LIST_LINE_START_REGEX = new RegExp(
797
+ `^(\\s*)(${ORDERED_LIST_MARKER_PATTERN})([.)])\\s+`
798
+ );
603
799
  var INDENTED_LINE_REGEX = /^\s/;
800
+ function isOrderedListMarkerLine(line) {
801
+ return ORDERED_LIST_ITEM_REGEX.test(line.trimStart());
802
+ }
604
803
  function isBlockContentLine(line) {
605
804
  const trimmedLine = line.trimStart();
606
805
  return (
607
806
  // oxlint-disable-next-line prefer-string-starts-ends-with
608
- /^[-+*]\s+/.test(trimmedLine) || // oxlint-disable-next-line prefer-string-starts-ends-with
609
- /^\d+\.\s+/.test(trimmedLine) || // oxlint-disable-next-line prefer-string-starts-ends-with
807
+ /^[-+*]\s+/.test(trimmedLine) || isOrderedListMarkerLine(trimmedLine) || // oxlint-disable-next-line prefer-string-starts-ends-with
610
808
  /^>\s?/.test(trimmedLine) || // oxlint-disable-next-line prefer-string-starts-ends-with
611
809
  /^```/.test(trimmedLine) || // oxlint-disable-next-line prefer-string-starts-ends-with
612
810
  /^~~~/.test(trimmedLine)
@@ -648,8 +846,11 @@ function collectOrderedListItems(lines) {
648
846
  if (!match) {
649
847
  break;
650
848
  }
651
- const [, indent, number, content] = match;
849
+ const [, indent, marker, _separator, content] = match;
652
850
  const indentLevel = indent.length;
851
+ const number = parseInt(marker, 10);
852
+ const markerType = isNaN(number) ? detectMarkerType(marker) : void 0;
853
+ const itemNumber = isNaN(number) ? markerToStart(marker) : number;
653
854
  const itemContentLines = [content];
654
855
  let nextLineIndex = currentLineIndex + 1;
655
856
  const itemLines = [line];
@@ -666,8 +867,10 @@ function collectOrderedListItems(lines) {
666
867
  sawBlankLine = true;
667
868
  nextLineIndex += 1;
668
869
  } else if (nextLine.match(INDENTED_LINE_REGEX)) {
870
+ const leadingWhitespace = nextLine.length - nextLine.trimStart().length;
871
+ const contentIndent = indentLevel + marker.length + 1;
669
872
  itemLines.push(nextLine);
670
- itemContentLines.push(nextLine.slice(indentLevel + 2));
873
+ itemContentLines.push(nextLine.slice(Math.min(leadingWhitespace, contentIndent)));
671
874
  nextLineIndex += 1;
672
875
  } else {
673
876
  if (sawBlankLine) {
@@ -680,7 +883,8 @@ function collectOrderedListItems(lines) {
680
883
  }
681
884
  listItems.push({
682
885
  indent: indentLevel,
683
- number: parseInt(number, 10),
886
+ number: itemNumber,
887
+ type: markerType,
684
888
  content: itemContentLines.join("\n").trim(),
685
889
  contentLines: itemContentLines,
686
890
  raw: itemLines.join("\n")
@@ -690,6 +894,44 @@ function collectOrderedListItems(lines) {
690
894
  }
691
895
  return [listItems, consumed];
692
896
  }
897
+ var PLAIN_TEXT_ORDERED_LIST_LINE_REGEX = new RegExp(
898
+ `^(${ORDERED_LIST_MARKER_PATTERN})([.)])\\s+(.+)$`
899
+ );
900
+ function parsePlainTextOrderedListPaste(text) {
901
+ const lines = text.split("\n").filter((l) => l.trim().length > 0);
902
+ if (lines.length === 0) {
903
+ return null;
904
+ }
905
+ const parsedItems = [];
906
+ for (const line of lines) {
907
+ const match = line.trim().match(PLAIN_TEXT_ORDERED_LIST_LINE_REGEX);
908
+ if (!match) {
909
+ return null;
910
+ }
911
+ parsedItems.push({
912
+ marker: match[1],
913
+ content: match[3]
914
+ });
915
+ }
916
+ const markers = parsedItems.map((item) => item.marker);
917
+ if (!areOrderedListMarkersSequential(markers)) {
918
+ return null;
919
+ }
920
+ const attrs = buildOrderedListAttrsFromMarker(parsedItems[0].marker);
921
+ return {
922
+ type: "orderedList",
923
+ attrs,
924
+ content: parsedItems.map((item) => ({
925
+ type: "listItem",
926
+ content: [
927
+ {
928
+ type: "paragraph",
929
+ content: [{ type: "text", text: item.content }]
930
+ }
931
+ ]
932
+ }))
933
+ };
934
+ }
693
935
  function buildNestedStructure(items, baseIndent, lexer) {
694
936
  const result = [];
695
937
  let currentIndex = 0;
@@ -724,6 +966,7 @@ function buildNestedStructure(items, baseIndent, lexer) {
724
966
  type: "list",
725
967
  ordered: true,
726
968
  start: nestedItems[0].number,
969
+ typeMarker: nestedItems[0].type,
727
970
  items: nestedListItems,
728
971
  raw: nestedItems.map((nestedItem) => nestedItem.raw).join("\n")
729
972
  });
@@ -775,6 +1018,27 @@ function parseListItems(items, helpers) {
775
1018
  var ListItemName2 = "listItem";
776
1019
  var TextStyleName2 = "textStyle";
777
1020
  var orderedListInputRegex = /^(\d+)\.\s$/;
1021
+ function cssListStyleTypeToHtmlType(style) {
1022
+ const match = style.match(/list-style-type\s*:\s*([^;]+)/i);
1023
+ if (!match) {
1024
+ return null;
1025
+ }
1026
+ const cssValue = match[1].trim().toLowerCase();
1027
+ switch (cssValue) {
1028
+ case "upper-roman":
1029
+ return "I";
1030
+ case "lower-roman":
1031
+ return "i";
1032
+ case "upper-alpha":
1033
+ case "upper-latin":
1034
+ return "A";
1035
+ case "lower-alpha":
1036
+ case "lower-latin":
1037
+ return "a";
1038
+ default:
1039
+ return null;
1040
+ }
1041
+ }
778
1042
  var OrderedList = Node3.create({
779
1043
  name: "orderedList",
780
1044
  addOptions() {
@@ -799,7 +1063,30 @@ var OrderedList = Node3.create({
799
1063
  },
800
1064
  type: {
801
1065
  default: null,
802
- parseHTML: (element) => element.getAttribute("type")
1066
+ parseHTML: (element) => {
1067
+ const htmlType = element.getAttribute("type");
1068
+ if (htmlType) {
1069
+ return htmlType;
1070
+ }
1071
+ const style = element.getAttribute("style");
1072
+ if (style) {
1073
+ const mappedFromOl = cssListStyleTypeToHtmlType(style);
1074
+ if (mappedFromOl) {
1075
+ return mappedFromOl;
1076
+ }
1077
+ }
1078
+ const firstLi = element.querySelector("li");
1079
+ if (firstLi) {
1080
+ const liStyle = firstLi.getAttribute("style");
1081
+ if (liStyle) {
1082
+ const mappedFromLi = cssListStyleTypeToHtmlType(liStyle);
1083
+ if (mappedFromLi) {
1084
+ return mappedFromLi;
1085
+ }
1086
+ }
1087
+ }
1088
+ return null;
1089
+ }
803
1090
  }
804
1091
  };
805
1092
  },
@@ -811,8 +1098,15 @@ var OrderedList = Node3.create({
811
1098
  ];
812
1099
  },
813
1100
  renderHTML({ HTMLAttributes }) {
814
- const { start, ...attributesWithoutStart } = HTMLAttributes;
815
- return start === 1 ? ["ol", mergeAttributes3(this.options.HTMLAttributes, attributesWithoutStart), 0] : ["ol", mergeAttributes3(this.options.HTMLAttributes, HTMLAttributes), 0];
1101
+ const { start, type, ...attributesWithoutType } = HTMLAttributes;
1102
+ const attrs = mergeAttributes3(this.options.HTMLAttributes, attributesWithoutType);
1103
+ if (start !== 1) {
1104
+ attrs.start = start;
1105
+ }
1106
+ if (type && type !== "1") {
1107
+ attrs.type = type;
1108
+ }
1109
+ return ["ol", attrs, 0];
816
1110
  },
817
1111
  markdownTokenName: "list",
818
1112
  parseMarkdown: (token, helpers) => {
@@ -820,11 +1114,19 @@ var OrderedList = Node3.create({
820
1114
  return [];
821
1115
  }
822
1116
  const startValue = token.start || 1;
1117
+ const typeValue = token.typeMarker;
823
1118
  const content = token.items ? parseListItems(token.items, helpers) : [];
1119
+ const attrs = {};
824
1120
  if (startValue !== 1) {
1121
+ attrs.start = startValue;
1122
+ }
1123
+ if (typeValue) {
1124
+ attrs.type = typeValue;
1125
+ }
1126
+ if (Object.keys(attrs).length > 0) {
825
1127
  return {
826
1128
  type: "orderedList",
827
- attrs: { start: startValue },
1129
+ attrs,
828
1130
  content
829
1131
  };
830
1132
  }
@@ -843,12 +1145,12 @@ var OrderedList = Node3.create({
843
1145
  name: "orderedList",
844
1146
  level: "block",
845
1147
  start: (src) => {
846
- const match = src.match(/^(\s*)(\d+)\.\s+/);
1148
+ const match = src.match(ORDERED_LIST_LINE_START_REGEX);
847
1149
  const index = match == null ? void 0 : match.index;
848
1150
  return index !== void 0 ? index : -1;
849
1151
  },
850
1152
  tokenize: (src, _tokens, lexer) => {
851
- var _a;
1153
+ var _a, _b;
852
1154
  const lines = src.split("\n");
853
1155
  const [listItems, consumed] = collectOrderedListItems(lines);
854
1156
  if (listItems.length === 0) {
@@ -859,10 +1161,12 @@ var OrderedList = Node3.create({
859
1161
  return void 0;
860
1162
  }
861
1163
  const startValue = ((_a = listItems[0]) == null ? void 0 : _a.number) || 1;
1164
+ const typeMarker = (_b = listItems[0]) == null ? void 0 : _b.type;
862
1165
  return {
863
1166
  type: "list",
864
1167
  ordered: true,
865
1168
  start: startValue,
1169
+ typeMarker,
866
1170
  items,
867
1171
  raw: lines.slice(0, consumed).join("\n")
868
1172
  };
@@ -886,12 +1190,47 @@ var OrderedList = Node3.create({
886
1190
  "Mod-Shift-7": () => this.editor.commands.toggleOrderedList()
887
1191
  };
888
1192
  },
1193
+ addProseMirrorPlugins() {
1194
+ return [
1195
+ new Plugin({
1196
+ props: {
1197
+ handlePaste: (view, event) => {
1198
+ var _a, _b;
1199
+ const html = (_a = event.clipboardData) == null ? void 0 : _a.getData("text/html");
1200
+ if (html == null ? void 0 : html.trim()) {
1201
+ return false;
1202
+ }
1203
+ const text = (_b = event.clipboardData) == null ? void 0 : _b.getData("text/plain");
1204
+ if (!text) {
1205
+ return false;
1206
+ }
1207
+ const orderedListContent = parsePlainTextOrderedListPaste(text);
1208
+ if (!orderedListContent) {
1209
+ return false;
1210
+ }
1211
+ try {
1212
+ const orderedListNode = view.state.schema.nodeFromJSON(orderedListContent);
1213
+ const tr = view.state.tr.replaceSelectionWith(orderedListNode);
1214
+ view.dispatch(tr);
1215
+ return true;
1216
+ } catch {
1217
+ return false;
1218
+ }
1219
+ }
1220
+ }
1221
+ })
1222
+ ];
1223
+ },
889
1224
  addInputRules() {
1225
+ const joinPredicate = (match, node) => {
1226
+ const hasDefaultType = !node.attrs.type || node.attrs.type === "1";
1227
+ return hasDefaultType && node.childCount + node.attrs.start === +match[1];
1228
+ };
890
1229
  let inputRule = wrappingInputRule2({
891
1230
  find: orderedListInputRegex,
892
1231
  type: this.type,
893
1232
  getAttributes: (match) => ({ start: +match[1] }),
894
- joinPredicate: (match, node) => node.childCount + node.attrs.start === +match[1]
1233
+ joinPredicate
895
1234
  });
896
1235
  if (this.options.keepMarks || this.options.keepAttributes) {
897
1236
  inputRule = wrappingInputRule2({
@@ -900,7 +1239,7 @@ var OrderedList = Node3.create({
900
1239
  keepMarks: this.options.keepMarks,
901
1240
  keepAttributes: this.options.keepAttributes,
902
1241
  getAttributes: (match) => ({ start: +match[1], ...this.editor.getAttributes(TextStyleName2) }),
903
- joinPredicate: (match, node) => node.childCount + node.attrs.start === +match[1],
1242
+ joinPredicate,
904
1243
  editor: this.editor
905
1244
  });
906
1245
  }
@@ -1284,12 +1623,22 @@ export {
1284
1623
  ListItem,
1285
1624
  ListKeymap,
1286
1625
  ListKit,
1626
+ ORDERED_LIST_MARKER_PATTERN,
1287
1627
  OrderedList,
1288
1628
  TaskItem,
1289
1629
  TaskList,
1630
+ areOrderedListMarkersSequential,
1631
+ buildOrderedListAttrsFromMarker,
1290
1632
  bulletListInputRegex,
1633
+ detectMarkerType,
1634
+ getListMarker,
1291
1635
  inputRegex,
1292
1636
  listHelpers_exports as listHelpers,
1293
- orderedListInputRegex
1637
+ markerToStart,
1638
+ orderedListInputRegex,
1639
+ parseListMarker,
1640
+ parsePlainTextOrderedListPaste,
1641
+ toRoman,
1642
+ toRomanUpper
1294
1643
  };
1295
1644
  //# sourceMappingURL=index.js.map