@tiptap/extension-list 3.26.0 → 3.27.0

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.
@@ -1,4 +1,4 @@
1
- import { Node } from '@tiptap/core';
1
+ import { Node, JSONContent } from '@tiptap/core';
2
2
 
3
3
  interface OrderedListOptions {
4
4
  /**
@@ -49,4 +49,69 @@ declare const orderedListInputRegex: RegExp;
49
49
  */
50
50
  declare const OrderedList: Node<OrderedListOptions, any>;
51
51
 
52
- export { OrderedList, type OrderedListOptions, orderedListInputRegex };
52
+ /**
53
+ * Marker segment for ordered list lines: numeric, roman, or 1–2 letter alpha.
54
+ * Roman is matched before alpha so "iii" is roman; invalid romans like "aa" fall through to alpha.
55
+ */
56
+ declare const ORDERED_LIST_MARKER_PATTERN: string;
57
+ /**
58
+ * Convert a number to lowercase roman numerals.
59
+ * @example toRoman(1) // 'i'
60
+ * @example toRoman(4) // 'iv'
61
+ */
62
+ declare function toRoman(num: number): string;
63
+ /**
64
+ * Convert a number to uppercase roman numerals.
65
+ * @example toRomanUpper(1) // 'I'
66
+ * @example toRomanUpper(4) // 'IV'
67
+ */
68
+ declare function toRomanUpper(num: number): string;
69
+ /**
70
+ * Extract the list marker type from a marker string.
71
+ * Supports "1", "a", "A", "i", "I" marker styles.
72
+ *
73
+ * @param marker The text content of the list marker (e.g. "a", "1", "iii", "b")
74
+ * @returns The normalized type string, or undefined for default numeric type
75
+ */
76
+ declare function detectMarkerType(marker: string): string | undefined;
77
+ /**
78
+ * Convert a list marker string to its numeric start position.
79
+ *
80
+ * @param marker The text content of the list marker (e.g. "3", "b", "II")
81
+ * @returns The 1-based start value for the ordered list
82
+ */
83
+ declare function markerToStart(marker: string): number;
84
+ /**
85
+ * Returns true when all markers share the same style and increment by 1.
86
+ * Style is inferred from the first marker so ambiguous letters (e.g. "c", "i")
87
+ * are not re-classified differently on later lines.
88
+ */
89
+ declare function areOrderedListMarkersSequential(markers: string[]): boolean;
90
+ interface ParsedListMarker {
91
+ type?: string;
92
+ start: number;
93
+ }
94
+ /**
95
+ * Parse a list marker into HTML ordered-list attrs (type + start).
96
+ */
97
+ declare function parseListMarker(marker: string): ParsedListMarker;
98
+ /**
99
+ * Build orderedList node attrs from the first list item marker.
100
+ */
101
+ declare function buildOrderedListAttrsFromMarker(marker: string): Record<string, string | number>;
102
+ /**
103
+ * Returns the list marker prefix for a given item at a given index.
104
+ *
105
+ * @param type The list type attribute (e.g. "a", "A", "i", "I", null/undefined for default)
106
+ * @param index The zero-based index of the list item
107
+ * @param separator The separator to use (default: ". ")
108
+ * @returns The marker string (e.g. "a. ", "I. ", "1. ")
109
+ */
110
+ declare function getListMarker(type: string | null | undefined, index: number, separator?: string): string;
111
+
112
+ /**
113
+ * Parse plain-text pasted ordered list lines into JSONContent, or null if not a typed list.
114
+ */
115
+ declare function parsePlainTextOrderedListPaste(text: string): JSONContent | null;
116
+
117
+ export { ORDERED_LIST_MARKER_PATTERN, OrderedList, type OrderedListOptions, areOrderedListMarkersSequential, buildOrderedListAttrsFromMarker, detectMarkerType, getListMarker, markerToStart, orderedListInputRegex, parseListMarker, parsePlainTextOrderedListPaste, toRoman, toRomanUpper };
@@ -1,4 +1,4 @@
1
- import { Node } from '@tiptap/core';
1
+ import { Node, JSONContent } from '@tiptap/core';
2
2
 
3
3
  interface OrderedListOptions {
4
4
  /**
@@ -49,4 +49,69 @@ declare const orderedListInputRegex: RegExp;
49
49
  */
50
50
  declare const OrderedList: Node<OrderedListOptions, any>;
51
51
 
52
- export { OrderedList, type OrderedListOptions, orderedListInputRegex };
52
+ /**
53
+ * Marker segment for ordered list lines: numeric, roman, or 1–2 letter alpha.
54
+ * Roman is matched before alpha so "iii" is roman; invalid romans like "aa" fall through to alpha.
55
+ */
56
+ declare const ORDERED_LIST_MARKER_PATTERN: string;
57
+ /**
58
+ * Convert a number to lowercase roman numerals.
59
+ * @example toRoman(1) // 'i'
60
+ * @example toRoman(4) // 'iv'
61
+ */
62
+ declare function toRoman(num: number): string;
63
+ /**
64
+ * Convert a number to uppercase roman numerals.
65
+ * @example toRomanUpper(1) // 'I'
66
+ * @example toRomanUpper(4) // 'IV'
67
+ */
68
+ declare function toRomanUpper(num: number): string;
69
+ /**
70
+ * Extract the list marker type from a marker string.
71
+ * Supports "1", "a", "A", "i", "I" marker styles.
72
+ *
73
+ * @param marker The text content of the list marker (e.g. "a", "1", "iii", "b")
74
+ * @returns The normalized type string, or undefined for default numeric type
75
+ */
76
+ declare function detectMarkerType(marker: string): string | undefined;
77
+ /**
78
+ * Convert a list marker string to its numeric start position.
79
+ *
80
+ * @param marker The text content of the list marker (e.g. "3", "b", "II")
81
+ * @returns The 1-based start value for the ordered list
82
+ */
83
+ declare function markerToStart(marker: string): number;
84
+ /**
85
+ * Returns true when all markers share the same style and increment by 1.
86
+ * Style is inferred from the first marker so ambiguous letters (e.g. "c", "i")
87
+ * are not re-classified differently on later lines.
88
+ */
89
+ declare function areOrderedListMarkersSequential(markers: string[]): boolean;
90
+ interface ParsedListMarker {
91
+ type?: string;
92
+ start: number;
93
+ }
94
+ /**
95
+ * Parse a list marker into HTML ordered-list attrs (type + start).
96
+ */
97
+ declare function parseListMarker(marker: string): ParsedListMarker;
98
+ /**
99
+ * Build orderedList node attrs from the first list item marker.
100
+ */
101
+ declare function buildOrderedListAttrsFromMarker(marker: string): Record<string, string | number>;
102
+ /**
103
+ * Returns the list marker prefix for a given item at a given index.
104
+ *
105
+ * @param type The list type attribute (e.g. "a", "A", "i", "I", null/undefined for default)
106
+ * @param index The zero-based index of the list item
107
+ * @param separator The separator to use (default: ". ")
108
+ * @returns The marker string (e.g. "a. ", "I. ", "1. ")
109
+ */
110
+ declare function getListMarker(type: string | null | undefined, index: number, separator?: string): string;
111
+
112
+ /**
113
+ * Parse plain-text pasted ordered list lines into JSONContent, or null if not a typed list.
114
+ */
115
+ declare function parsePlainTextOrderedListPaste(text: string): JSONContent | null;
116
+
117
+ export { ORDERED_LIST_MARKER_PATTERN, OrderedList, type OrderedListOptions, areOrderedListMarkersSequential, buildOrderedListAttrsFromMarker, detectMarkerType, getListMarker, markerToStart, orderedListInputRegex, parseListMarker, parsePlainTextOrderedListPaste, toRoman, toRomanUpper };
@@ -1,15 +1,211 @@
1
1
  // src/ordered-list/ordered-list.ts
2
+ import { Plugin } from "@tiptap/pm/state";
2
3
  import { mergeAttributes, Node, wrappingInputRule } from "@tiptap/core";
3
4
 
5
+ // src/ordered-list/roman.ts
6
+ var ROMAN_NUMERALS = [
7
+ [1e3, "m"],
8
+ [900, "cm"],
9
+ [500, "d"],
10
+ [400, "cd"],
11
+ [100, "c"],
12
+ [90, "xc"],
13
+ [50, "l"],
14
+ [40, "xl"],
15
+ [10, "x"],
16
+ [9, "ix"],
17
+ [5, "v"],
18
+ [4, "iv"],
19
+ [1, "i"]
20
+ ];
21
+ var ALPHA_NUMERALS = "abcdefghijklmnopqrstuvwxyz";
22
+ var ORDERED_LIST_ALPHA_MARKER_PATTERN = "[a-zA-Z]{1,2}";
23
+ var ORDERED_LIST_MARKER_PATTERN = String.raw`\d+|[ivxlcdmIVXLCDM]+|${ORDERED_LIST_ALPHA_MARKER_PATTERN}`;
24
+ function toRoman(num) {
25
+ let remaining = num;
26
+ let result = "";
27
+ for (const [value, numeral] of ROMAN_NUMERALS) {
28
+ while (remaining >= value) {
29
+ result += numeral;
30
+ remaining -= value;
31
+ }
32
+ }
33
+ return result;
34
+ }
35
+ function toRomanUpper(num) {
36
+ return toRoman(num).toUpperCase();
37
+ }
38
+ function fromRoman(roman) {
39
+ const lower = roman.toLowerCase();
40
+ let index = 0;
41
+ let result = 0;
42
+ while (index < lower.length) {
43
+ let matched = false;
44
+ for (const [value, numeral] of ROMAN_NUMERALS) {
45
+ if (lower.startsWith(numeral, index)) {
46
+ result += value;
47
+ index += numeral.length;
48
+ matched = true;
49
+ break;
50
+ }
51
+ }
52
+ if (!matched) {
53
+ return 0;
54
+ }
55
+ }
56
+ return result;
57
+ }
58
+ function isValidRoman(marker) {
59
+ if (!/^[ivxlcdmIVXLCDM]+$/.test(marker)) {
60
+ return false;
61
+ }
62
+ const value = fromRoman(marker);
63
+ if (value <= 0) {
64
+ return false;
65
+ }
66
+ const expected = marker === marker.toLowerCase() ? toRoman(value) : toRomanUpper(value);
67
+ return expected === marker;
68
+ }
69
+ function fromAlpha(marker) {
70
+ const lower = marker.toLowerCase();
71
+ if (lower.length === 1) {
72
+ return lower.charCodeAt(0) - "a".charCodeAt(0) + 1;
73
+ }
74
+ if (lower.length === 2) {
75
+ const first = lower.charCodeAt(0) - "a".charCodeAt(0);
76
+ const second = lower.charCodeAt(1) - "a".charCodeAt(0);
77
+ return (first + 1) * 26 + second + 1;
78
+ }
79
+ return 0;
80
+ }
81
+ function toRomanAlpha(num) {
82
+ if (num <= 26) {
83
+ return ALPHA_NUMERALS[num - 1];
84
+ }
85
+ const first = Math.floor((num - 1) / 26) - 1;
86
+ const second = (num - 1) % 26;
87
+ if (first < 0) {
88
+ return ALPHA_NUMERALS[second];
89
+ }
90
+ return ALPHA_NUMERALS[first] + ALPHA_NUMERALS[second];
91
+ }
92
+ function detectMarkerType(marker) {
93
+ if (!marker || /^\d+$/.test(marker)) {
94
+ return void 0;
95
+ }
96
+ if (isValidRoman(marker)) {
97
+ return marker === marker.toLowerCase() ? "i" : "I";
98
+ }
99
+ if (/^[a-z]{1,2}$/.test(marker)) {
100
+ return "a";
101
+ }
102
+ if (/^[A-Z]{1,2}$/.test(marker)) {
103
+ return "A";
104
+ }
105
+ return void 0;
106
+ }
107
+ function markerToStart(marker) {
108
+ if (/^\d+$/.test(marker)) {
109
+ return parseInt(marker, 10);
110
+ }
111
+ const type = detectMarkerType(marker);
112
+ if (type === "i" || type === "I") {
113
+ return fromRoman(marker);
114
+ }
115
+ if (type === "a" || type === "A") {
116
+ const start = fromAlpha(marker);
117
+ return start > 0 ? start : 1;
118
+ }
119
+ const parsed = parseInt(marker, 10);
120
+ return Number.isNaN(parsed) ? 1 : parsed;
121
+ }
122
+ function startToMarker(type, start) {
123
+ if (type === "numeric") {
124
+ return String(start);
125
+ }
126
+ switch (type) {
127
+ case "a":
128
+ return toRomanAlpha(start);
129
+ case "A":
130
+ return toRomanAlpha(start).toUpperCase();
131
+ case "i":
132
+ return toRoman(start);
133
+ case "I":
134
+ return toRomanUpper(start);
135
+ default:
136
+ return String(start);
137
+ }
138
+ }
139
+ function areOrderedListMarkersSequential(markers) {
140
+ var _a;
141
+ if (markers.length === 0) {
142
+ return false;
143
+ }
144
+ const firstType = (_a = detectMarkerType(markers[0])) != null ? _a : "numeric";
145
+ const firstStart = markerToStart(markers[0]);
146
+ if (firstStart < 1) {
147
+ return false;
148
+ }
149
+ for (let i = 0; i < markers.length; i++) {
150
+ const expected = startToMarker(firstType, firstStart + i);
151
+ if (markers[i] !== expected) {
152
+ return false;
153
+ }
154
+ }
155
+ return true;
156
+ }
157
+ function parseListMarker(marker) {
158
+ return {
159
+ type: detectMarkerType(marker),
160
+ start: markerToStart(marker)
161
+ };
162
+ }
163
+ function buildOrderedListAttrsFromMarker(marker) {
164
+ const { type, start } = parseListMarker(marker);
165
+ const attrs = {};
166
+ if (type) {
167
+ attrs.type = type;
168
+ }
169
+ if (start !== 1) {
170
+ attrs.start = start;
171
+ }
172
+ return attrs;
173
+ }
174
+ function getListMarker(type, index, separator = ". ") {
175
+ const position = index + 1;
176
+ if (!type || type === "1") {
177
+ return `${position}${separator}`;
178
+ }
179
+ switch (type) {
180
+ case "a":
181
+ return `${toRomanAlpha(position)}${separator}`;
182
+ case "A":
183
+ return `${toRomanAlpha(position).toUpperCase()}${separator}`;
184
+ case "i":
185
+ return `${toRoman(position)}${separator}`;
186
+ case "I":
187
+ return `${toRomanUpper(position)}${separator}`;
188
+ default:
189
+ return `${position}${separator}`;
190
+ }
191
+ }
192
+
4
193
  // src/ordered-list/utils.ts
5
- var ORDERED_LIST_ITEM_REGEX = /^(\s*)(\d+)\.\s+(.*)$/;
194
+ var ORDERED_LIST_ITEM_REGEX = new RegExp(
195
+ `^(\\s*)(${ORDERED_LIST_MARKER_PATTERN})([.)])\\s+(.*)$`
196
+ );
197
+ var ORDERED_LIST_LINE_START_REGEX = new RegExp(
198
+ `^(\\s*)(${ORDERED_LIST_MARKER_PATTERN})([.)])\\s+`
199
+ );
6
200
  var INDENTED_LINE_REGEX = /^\s/;
201
+ function isOrderedListMarkerLine(line) {
202
+ return ORDERED_LIST_ITEM_REGEX.test(line.trimStart());
203
+ }
7
204
  function isBlockContentLine(line) {
8
205
  const trimmedLine = line.trimStart();
9
206
  return (
10
207
  // oxlint-disable-next-line prefer-string-starts-ends-with
11
- /^[-+*]\s+/.test(trimmedLine) || // oxlint-disable-next-line prefer-string-starts-ends-with
12
- /^\d+\.\s+/.test(trimmedLine) || // oxlint-disable-next-line prefer-string-starts-ends-with
208
+ /^[-+*]\s+/.test(trimmedLine) || isOrderedListMarkerLine(trimmedLine) || // oxlint-disable-next-line prefer-string-starts-ends-with
13
209
  /^>\s?/.test(trimmedLine) || // oxlint-disable-next-line prefer-string-starts-ends-with
14
210
  /^```/.test(trimmedLine) || // oxlint-disable-next-line prefer-string-starts-ends-with
15
211
  /^~~~/.test(trimmedLine)
@@ -51,8 +247,11 @@ function collectOrderedListItems(lines) {
51
247
  if (!match) {
52
248
  break;
53
249
  }
54
- const [, indent, number, content] = match;
250
+ const [, indent, marker, _separator, content] = match;
55
251
  const indentLevel = indent.length;
252
+ const number = parseInt(marker, 10);
253
+ const markerType = isNaN(number) ? detectMarkerType(marker) : void 0;
254
+ const itemNumber = isNaN(number) ? markerToStart(marker) : number;
56
255
  const itemContentLines = [content];
57
256
  let nextLineIndex = currentLineIndex + 1;
58
257
  const itemLines = [line];
@@ -83,7 +282,8 @@ function collectOrderedListItems(lines) {
83
282
  }
84
283
  listItems.push({
85
284
  indent: indentLevel,
86
- number: parseInt(number, 10),
285
+ number: itemNumber,
286
+ type: markerType,
87
287
  content: itemContentLines.join("\n").trim(),
88
288
  contentLines: itemContentLines,
89
289
  raw: itemLines.join("\n")
@@ -93,6 +293,44 @@ function collectOrderedListItems(lines) {
93
293
  }
94
294
  return [listItems, consumed];
95
295
  }
296
+ var PLAIN_TEXT_ORDERED_LIST_LINE_REGEX = new RegExp(
297
+ `^(${ORDERED_LIST_MARKER_PATTERN})([.)])\\s+(.+)$`
298
+ );
299
+ function parsePlainTextOrderedListPaste(text) {
300
+ const lines = text.split("\n").filter((l) => l.trim().length > 0);
301
+ if (lines.length === 0) {
302
+ return null;
303
+ }
304
+ const parsedItems = [];
305
+ for (const line of lines) {
306
+ const match = line.trim().match(PLAIN_TEXT_ORDERED_LIST_LINE_REGEX);
307
+ if (!match) {
308
+ return null;
309
+ }
310
+ parsedItems.push({
311
+ marker: match[1],
312
+ content: match[3]
313
+ });
314
+ }
315
+ const markers = parsedItems.map((item) => item.marker);
316
+ if (!areOrderedListMarkersSequential(markers)) {
317
+ return null;
318
+ }
319
+ const attrs = buildOrderedListAttrsFromMarker(parsedItems[0].marker);
320
+ return {
321
+ type: "orderedList",
322
+ attrs,
323
+ content: parsedItems.map((item) => ({
324
+ type: "listItem",
325
+ content: [
326
+ {
327
+ type: "paragraph",
328
+ content: [{ type: "text", text: item.content }]
329
+ }
330
+ ]
331
+ }))
332
+ };
333
+ }
96
334
  function buildNestedStructure(items, baseIndent, lexer) {
97
335
  const result = [];
98
336
  let currentIndex = 0;
@@ -127,6 +365,7 @@ function buildNestedStructure(items, baseIndent, lexer) {
127
365
  type: "list",
128
366
  ordered: true,
129
367
  start: nestedItems[0].number,
368
+ typeMarker: nestedItems[0].type,
130
369
  items: nestedListItems,
131
370
  raw: nestedItems.map((nestedItem) => nestedItem.raw).join("\n")
132
371
  });
@@ -178,6 +417,27 @@ function parseListItems(items, helpers) {
178
417
  var ListItemName = "listItem";
179
418
  var TextStyleName = "textStyle";
180
419
  var orderedListInputRegex = /^(\d+)\.\s$/;
420
+ function cssListStyleTypeToHtmlType(style) {
421
+ const match = style.match(/list-style-type\s*:\s*([^;]+)/i);
422
+ if (!match) {
423
+ return null;
424
+ }
425
+ const cssValue = match[1].trim().toLowerCase();
426
+ switch (cssValue) {
427
+ case "upper-roman":
428
+ return "I";
429
+ case "lower-roman":
430
+ return "i";
431
+ case "upper-alpha":
432
+ case "upper-latin":
433
+ return "A";
434
+ case "lower-alpha":
435
+ case "lower-latin":
436
+ return "a";
437
+ default:
438
+ return null;
439
+ }
440
+ }
181
441
  var OrderedList = Node.create({
182
442
  name: "orderedList",
183
443
  addOptions() {
@@ -202,7 +462,30 @@ var OrderedList = Node.create({
202
462
  },
203
463
  type: {
204
464
  default: null,
205
- parseHTML: (element) => element.getAttribute("type")
465
+ parseHTML: (element) => {
466
+ const htmlType = element.getAttribute("type");
467
+ if (htmlType) {
468
+ return htmlType;
469
+ }
470
+ const style = element.getAttribute("style");
471
+ if (style) {
472
+ const mappedFromOl = cssListStyleTypeToHtmlType(style);
473
+ if (mappedFromOl) {
474
+ return mappedFromOl;
475
+ }
476
+ }
477
+ const firstLi = element.querySelector("li");
478
+ if (firstLi) {
479
+ const liStyle = firstLi.getAttribute("style");
480
+ if (liStyle) {
481
+ const mappedFromLi = cssListStyleTypeToHtmlType(liStyle);
482
+ if (mappedFromLi) {
483
+ return mappedFromLi;
484
+ }
485
+ }
486
+ }
487
+ return null;
488
+ }
206
489
  }
207
490
  };
208
491
  },
@@ -214,8 +497,15 @@ var OrderedList = Node.create({
214
497
  ];
215
498
  },
216
499
  renderHTML({ HTMLAttributes }) {
217
- const { start, ...attributesWithoutStart } = HTMLAttributes;
218
- return start === 1 ? ["ol", mergeAttributes(this.options.HTMLAttributes, attributesWithoutStart), 0] : ["ol", mergeAttributes(this.options.HTMLAttributes, HTMLAttributes), 0];
500
+ const { start, type, ...attributesWithoutType } = HTMLAttributes;
501
+ const attrs = mergeAttributes(this.options.HTMLAttributes, attributesWithoutType);
502
+ if (start !== 1) {
503
+ attrs.start = start;
504
+ }
505
+ if (type && type !== "1") {
506
+ attrs.type = type;
507
+ }
508
+ return ["ol", attrs, 0];
219
509
  },
220
510
  markdownTokenName: "list",
221
511
  parseMarkdown: (token, helpers) => {
@@ -223,11 +513,19 @@ var OrderedList = Node.create({
223
513
  return [];
224
514
  }
225
515
  const startValue = token.start || 1;
516
+ const typeValue = token.typeMarker;
226
517
  const content = token.items ? parseListItems(token.items, helpers) : [];
518
+ const attrs = {};
227
519
  if (startValue !== 1) {
520
+ attrs.start = startValue;
521
+ }
522
+ if (typeValue) {
523
+ attrs.type = typeValue;
524
+ }
525
+ if (Object.keys(attrs).length > 0) {
228
526
  return {
229
527
  type: "orderedList",
230
- attrs: { start: startValue },
528
+ attrs,
231
529
  content
232
530
  };
233
531
  }
@@ -246,12 +544,12 @@ var OrderedList = Node.create({
246
544
  name: "orderedList",
247
545
  level: "block",
248
546
  start: (src) => {
249
- const match = src.match(/^(\s*)(\d+)\.\s+/);
547
+ const match = src.match(ORDERED_LIST_LINE_START_REGEX);
250
548
  const index = match == null ? void 0 : match.index;
251
549
  return index !== void 0 ? index : -1;
252
550
  },
253
551
  tokenize: (src, _tokens, lexer) => {
254
- var _a;
552
+ var _a, _b;
255
553
  const lines = src.split("\n");
256
554
  const [listItems, consumed] = collectOrderedListItems(lines);
257
555
  if (listItems.length === 0) {
@@ -262,10 +560,12 @@ var OrderedList = Node.create({
262
560
  return void 0;
263
561
  }
264
562
  const startValue = ((_a = listItems[0]) == null ? void 0 : _a.number) || 1;
563
+ const typeMarker = (_b = listItems[0]) == null ? void 0 : _b.type;
265
564
  return {
266
565
  type: "list",
267
566
  ordered: true,
268
567
  start: startValue,
568
+ typeMarker,
269
569
  items,
270
570
  raw: lines.slice(0, consumed).join("\n")
271
571
  };
@@ -289,12 +589,47 @@ var OrderedList = Node.create({
289
589
  "Mod-Shift-7": () => this.editor.commands.toggleOrderedList()
290
590
  };
291
591
  },
592
+ addProseMirrorPlugins() {
593
+ return [
594
+ new Plugin({
595
+ props: {
596
+ handlePaste: (view, event) => {
597
+ var _a, _b;
598
+ const html = (_a = event.clipboardData) == null ? void 0 : _a.getData("text/html");
599
+ if (html == null ? void 0 : html.trim()) {
600
+ return false;
601
+ }
602
+ const text = (_b = event.clipboardData) == null ? void 0 : _b.getData("text/plain");
603
+ if (!text) {
604
+ return false;
605
+ }
606
+ const orderedListContent = parsePlainTextOrderedListPaste(text);
607
+ if (!orderedListContent) {
608
+ return false;
609
+ }
610
+ try {
611
+ const orderedListNode = view.state.schema.nodeFromJSON(orderedListContent);
612
+ const tr = view.state.tr.replaceSelectionWith(orderedListNode);
613
+ view.dispatch(tr);
614
+ return true;
615
+ } catch {
616
+ return false;
617
+ }
618
+ }
619
+ }
620
+ })
621
+ ];
622
+ },
292
623
  addInputRules() {
624
+ const joinPredicate = (match, node) => {
625
+ const hasDefaultType = !node.attrs.type || node.attrs.type === "1";
626
+ return hasDefaultType && node.childCount + node.attrs.start === +match[1];
627
+ };
293
628
  let inputRule = wrappingInputRule({
294
629
  find: orderedListInputRegex,
295
630
  type: this.type,
296
631
  getAttributes: (match) => ({ start: +match[1] }),
297
- joinPredicate: (match, node) => node.childCount + node.attrs.start === +match[1]
632
+ joinPredicate
298
633
  });
299
634
  if (this.options.keepMarks || this.options.keepAttributes) {
300
635
  inputRule = wrappingInputRule({
@@ -303,7 +638,7 @@ var OrderedList = Node.create({
303
638
  keepMarks: this.options.keepMarks,
304
639
  keepAttributes: this.options.keepAttributes,
305
640
  getAttributes: (match) => ({ start: +match[1], ...this.editor.getAttributes(TextStyleName) }),
306
- joinPredicate: (match, node) => node.childCount + node.attrs.start === +match[1],
641
+ joinPredicate,
307
642
  editor: this.editor
308
643
  });
309
644
  }
@@ -311,7 +646,17 @@ var OrderedList = Node.create({
311
646
  }
312
647
  });
313
648
  export {
649
+ ORDERED_LIST_MARKER_PATTERN,
314
650
  OrderedList,
315
- orderedListInputRegex
651
+ areOrderedListMarkersSequential,
652
+ buildOrderedListAttrsFromMarker,
653
+ detectMarkerType,
654
+ getListMarker,
655
+ markerToStart,
656
+ orderedListInputRegex,
657
+ parseListMarker,
658
+ parsePlainTextOrderedListPaste,
659
+ toRoman,
660
+ toRomanUpper
316
661
  };
317
662
  //# sourceMappingURL=index.js.map