@prosekit/extensions 0.0.0-next-20231120040948 → 0.0.0-next-20240421132240

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 (37) hide show
  1. package/dist/_tsup-dts-rollup.d.ts +521 -91
  2. package/dist/chunk-ASTUC4KT.js +111 -0
  3. package/dist/chunk-DYFRBXUX.js +56 -0
  4. package/dist/list/style.css +17 -12
  5. package/dist/prosekit-extensions-autocomplete.js +8 -4
  6. package/dist/prosekit-extensions-blockquote.d.ts +1 -0
  7. package/dist/prosekit-extensions-blockquote.js +12 -1
  8. package/dist/prosekit-extensions-code-block.d.ts +14 -4
  9. package/dist/prosekit-extensions-code-block.js +171 -75
  10. package/dist/prosekit-extensions-drop-cursor.d.ts +2 -0
  11. package/dist/prosekit-extensions-drop-cursor.js +9 -0
  12. package/dist/prosekit-extensions-enter-rule.d.ts +5 -0
  13. package/dist/prosekit-extensions-enter-rule.js +8 -0
  14. package/dist/prosekit-extensions-heading.js +20 -14
  15. package/dist/prosekit-extensions-image.js +1 -0
  16. package/dist/prosekit-extensions-input-rule.d.ts +3 -0
  17. package/dist/prosekit-extensions-input-rule.js +10 -0
  18. package/dist/prosekit-extensions-link.d.ts +2 -0
  19. package/dist/prosekit-extensions-link.js +63 -5
  20. package/dist/prosekit-extensions-list.d.ts +1 -0
  21. package/dist/prosekit-extensions-list.js +7 -2
  22. package/dist/prosekit-extensions-mention.d.ts +1 -0
  23. package/dist/prosekit-extensions-mention.js +15 -2
  24. package/dist/prosekit-extensions-placeholder.js +4 -1
  25. package/dist/prosekit-extensions-readonly.d.ts +1 -0
  26. package/dist/prosekit-extensions-readonly.js +16 -0
  27. package/dist/prosekit-extensions-table.d.ts +7 -0
  28. package/dist/prosekit-extensions-table.js +197 -0
  29. package/dist/prosekit-extensions-virtual-selection.d.ts +1 -0
  30. package/dist/prosekit-extensions-virtual-selection.js +58 -0
  31. package/dist/shiki-import-25BJYIO2.js +5 -0
  32. package/dist/table/style.css +34 -0
  33. package/dist/virtual-selection/style.css +6 -0
  34. package/package.json +63 -15
  35. package/dist/prosekit-extensions-suggestion.d.ts +0 -3
  36. package/dist/prosekit-extensions-suggestion.js +0 -161
  37. package/src/index.ts +0 -1
@@ -1,19 +1,32 @@
1
+ import { Attrs } from '@prosekit/pm/model';
2
+ import { BundledLanguage } from 'shiki';
3
+ import { BundledLanguageInfo } from 'shiki';
4
+ import { bundledLanguagesInfo } from 'shiki';
5
+ import { BundledTheme } from 'shiki';
6
+ import { BundledThemeInfo } from 'shiki';
7
+ import { bundledThemesInfo } from 'shiki';
8
+ import { Command } from '@prosekit/pm/state';
1
9
  import { CommandArgs } from '@prosekit/core';
2
10
  import { DedentListOptions } from 'prosemirror-flat-list';
3
11
  import { EditorState } from '@prosekit/pm/state';
4
12
  import { Extension } from '@prosekit/core';
5
13
  import { ExtensionTyping } from '@prosekit/core';
6
- import type { HLJSApi } from 'highlight.js';
14
+ import { getHighlighter } from 'shiki/bundle/full';
7
15
  import { IndentListOptions } from 'prosemirror-flat-list';
16
+ import { InputRule } from '@prosekit/pm/inputrules';
8
17
  import { ListAttributes } from 'prosemirror-flat-list';
18
+ import { ListDOMSerializer } from 'prosemirror-flat-list';
9
19
  import { NodeRange } from 'prosemirror-model';
20
+ import { NodeType } from '@prosekit/pm/model';
10
21
  import { Options } from 'tsup';
22
+ import { Parser } from 'prosemirror-highlight';
11
23
  import { Plugin as Plugin_2 } from '@prosekit/pm/state';
12
24
  import { PluginKey } from '@prosekit/pm/state';
25
+ import { ProseMirrorNode } from '@prosekit/pm/model';
26
+ import type { SpecialLanguage } from 'shiki';
13
27
  import { ToggleCollapsedOptions } from 'prosemirror-flat-list';
14
28
  import { Transaction } from '@prosekit/pm/state';
15
29
  import { UnwrapListOptions } from 'prosemirror-flat-list';
16
- import { UserProjectConfigExport } from 'vitest/dist/config.js';
17
30
 
18
31
  declare class AutocompleteRule {
19
32
  readonly regex: RegExp;
@@ -34,30 +47,86 @@ declare class AutocompleteRule {
34
47
  export { AutocompleteRule }
35
48
  export { AutocompleteRule as AutocompleteRule_alias_1 }
36
49
 
50
+ export { BundledLanguage as ShikiBundledLanguage }
51
+ export { BundledLanguage as ShikiBundledLanguage_alias_1 }
52
+
53
+ export { BundledLanguageInfo as ShikiBundledLanguageInfo }
54
+ export { BundledLanguageInfo as ShikiBundledLanguageInfo_alias_1 }
55
+
56
+ export { bundledLanguagesInfo as shikiBundledLanguagesInfo }
57
+ export { bundledLanguagesInfo as shikiBundledLanguagesInfo_alias_1 }
58
+
59
+ export { BundledTheme as ShikiBundledTheme }
60
+ export { BundledTheme as ShikiBundledTheme_alias_1 }
61
+
62
+ export { BundledThemeInfo as ShikiBundledThemeInfo }
63
+ export { BundledThemeInfo as ShikiBundledThemeInfo_alias_1 }
64
+
65
+ export { bundledThemesInfo as shikiBundledThemesInfo }
66
+ export { bundledThemesInfo as shikiBundledThemesInfo_alias_1 }
67
+
68
+ export declare interface CellAttrs {
69
+ colspan: number;
70
+ rowspan: number;
71
+ colwidth: number[] | null;
72
+ }
73
+
74
+ /**
75
+ * The attributes for the `codeBlock` node.
76
+ *
77
+ * @public
78
+ */
37
79
  declare interface CodeBlockAttrs {
38
80
  language?: string;
39
81
  }
40
82
  export { CodeBlockAttrs }
41
83
  export { CodeBlockAttrs as CodeBlockAttrs_alias_1 }
42
84
 
85
+ /**
86
+ * @public
87
+ */
88
+ export declare interface CodeBlockShikiOptions {
89
+ /**
90
+ * Theme registation
91
+ *
92
+ * @default ['one-dark-pro']
93
+ */
94
+ themes?: BundledTheme[];
95
+ /**
96
+ * Language registation
97
+ *
98
+ * @default ['text']
99
+ */
100
+ langs?: (BundledLanguage | SpecialLanguage)[];
101
+ /**
102
+ * Alias of languages
103
+ *
104
+ * @example { 'my-lang': 'javascript' }
105
+ */
106
+ langAlias?: Record<string, BundledLanguage>;
107
+ }
108
+
43
109
  export declare function createAutocompletePlugin({ getRules, }: {
44
110
  getRules: () => AutocompleteRule[];
45
111
  }): Plugin_2;
46
112
 
47
- export declare function createPredictionPlugin(options: SuggestionOptions): Plugin_2;
113
+ /**
114
+ * @internal
115
+ */
116
+ export declare function createLazyParser(highlighterOptions: HighlighterOptions): Parser;
48
117
 
49
118
  export declare const default_alias: Options | Options[] | ((overrideOptions: Options) => Options | Options[] | Promise<Options | Options[]>);
50
119
 
51
- export declare const default_alias_1: UserProjectConfigExport;
120
+ export declare const default_alias_1: {
121
+ test: {
122
+ environment: "jsdom";
123
+ };
124
+ };
52
125
 
53
126
  export declare function defaultCanMatch({ state }: {
54
127
  state: EditorState;
55
128
  }): boolean;
56
129
 
57
- export declare function defaultIsValid({ state }: {
58
- state: EditorState;
59
- }): boolean;
60
-
61
130
  export declare function defineAutocomplete(rule: AutocompleteRule): Extension;
62
131
 
63
132
  /**
@@ -67,6 +136,12 @@ export declare function defineBlockquote(): Extension< {
67
136
  NODES: "blockquote";
68
137
  }>;
69
138
 
139
+ /**
140
+ * Wraps the text block in a blockquote when `>` is typed at the start of a new
141
+ * line followed by a space.
142
+ */
143
+ export declare function defineBlockquoteInputRule(): Extension<ExtensionTyping<string, string, CommandArgs>>;
144
+
70
145
  export declare function defineBlockquoteSpec(): Extension< {
71
146
  NODES: "blockquote";
72
147
  }>;
@@ -104,32 +179,100 @@ toggleCode: [];
104
179
  }>;
105
180
 
106
181
  /**
182
+ * Adds `codeBlock` nodes to the editor. This includes the following extensions:
183
+ *
184
+ * - {@link defineCodeBlockSpec}
185
+ * - {@link defineCodeBlockInputRule}
186
+ * - {@link defineCodeBlockEnterRule}
187
+ * - {@link defineCodeBlockKeymap}
188
+ * - {@link defineCodeBlockCommands}.
189
+ *
107
190
  * @public
108
191
  */
109
- export declare function defineCodeBlock(options?: {
110
- hljs?: HLJSApi;
111
- }): Extension< {
192
+ declare function defineCodeBlock(): Extension< {
112
193
  NODES: "codeBlock";
113
194
  COMMAND_ARGS: {
114
- setCodeBlockLanguage: [language: string];
195
+ setCodeBlock: [attrs?: CodeBlockAttrs | undefined];
196
+ insertCodeBlock: [attrs?: CodeBlockAttrs | undefined];
197
+ toggleCodeBlock: [attrs?: CodeBlockAttrs | undefined];
198
+ setCodeBlockAttrs: [attrs: CodeBlockAttrs];
115
199
  };
116
200
  }>;
201
+ export { defineCodeBlock }
202
+ export { defineCodeBlock as defineCodeBlock_alias_1 }
117
203
 
118
- export declare function defineCodeBlockCommands(): Extension< {
204
+ /**
205
+ * Adds commands for working with `codeBlock` nodes.
206
+ *
207
+ * @public
208
+ */
209
+ declare function defineCodeBlockCommands(): Extension< {
119
210
  COMMAND_ARGS: {
120
- setCodeBlockLanguage: [language: string];
211
+ setCodeBlock: [attrs?: CodeBlockAttrs | undefined];
212
+ insertCodeBlock: [attrs?: CodeBlockAttrs | undefined];
213
+ toggleCodeBlock: [attrs?: CodeBlockAttrs | undefined];
214
+ setCodeBlockAttrs: [attrs: CodeBlockAttrs];
121
215
  };
122
216
  }>;
217
+ export { defineCodeBlockCommands }
218
+ export { defineCodeBlockCommands as defineCodeBlockCommands_alias_1 }
123
219
 
124
- export declare function defineCodeBlockHighlight(options: {
125
- hljs?: HLJSApi;
126
- }): Extension<ExtensionTyping<string, string, CommandArgs>>;
220
+ /**
221
+ * Adds enter rules for `codeBlock` nodes.
222
+ *
223
+ * @public
224
+ */
225
+ declare function defineCodeBlockEnterRule(): Extension<ExtensionTyping<string, string, CommandArgs>>;
226
+ export { defineCodeBlockEnterRule }
227
+ export { defineCodeBlockEnterRule as defineCodeBlockEnterRule_alias_1 }
127
228
 
128
- export declare function defineCodeBlockInputRule(): Extension<ExtensionTyping<string, string, CommandArgs>>;
229
+ /**
230
+ * Adds syntax highlighting to code blocks. This function requires a `Parser`
231
+ * instance from the `prosemirror-highlight` package. See the
232
+ * [documentation](https://github.com/ocavue/prosemirror-highlight) for more
233
+ * information.
234
+ *
235
+ * @public
236
+ */
237
+ declare function defineCodeBlockHighlight({ parser, }: {
238
+ parser: HighlightParser;
239
+ }): Extension;
240
+ export { defineCodeBlockHighlight }
241
+ export { defineCodeBlockHighlight as defineCodeBlockHighlight_alias_1 }
242
+
243
+ /**
244
+ * Adds input rules for `codeBlock` nodes.
245
+ *
246
+ * @public
247
+ */
248
+ declare function defineCodeBlockInputRule(): Extension<ExtensionTyping<string, string, CommandArgs>>;
249
+ export { defineCodeBlockInputRule }
250
+ export { defineCodeBlockInputRule as defineCodeBlockInputRule_alias_1 }
129
251
 
130
- export declare function defineCodeBlockSpec(): Extension< {
252
+ /**
253
+ * Defines the keymap for code blocks.
254
+ */
255
+ export declare function defineCodeBlockKeymap(): Extension<ExtensionTyping<string, string, CommandArgs>>;
256
+
257
+ /**
258
+ * Adds syntax highlighting to code blocks using the [shiki](https://github.com/shikijs/shiki) package.
259
+ *
260
+ * @public
261
+ */
262
+ declare function defineCodeBlockShiki({ themes, langs, langAlias, }?: CodeBlockShikiOptions): Extension;
263
+ export { defineCodeBlockShiki }
264
+ export { defineCodeBlockShiki as defineCodeBlockShiki_alias_1 }
265
+
266
+ /**
267
+ * Defines the `codeBlock` node spec.
268
+ *
269
+ * @public
270
+ */
271
+ declare function defineCodeBlockSpec(): Extension< {
131
272
  NODES: "codeBlock";
132
273
  }>;
274
+ export { defineCodeBlockSpec }
275
+ export { defineCodeBlockSpec as defineCodeBlockSpec_alias_1 }
133
276
 
134
277
  export declare function defineCodeCommands(): Extension< {
135
278
  COMMAND_ARGS: {
@@ -144,6 +287,24 @@ export declare function defineCodeSpec(): Extension< {
144
287
  MARKS: "code";
145
288
  }>;
146
289
 
290
+ /**
291
+ * Show up a decoration at the drop position when something is dragged over the editor.
292
+ *
293
+ * See [prosemirror-dropcursor](https://github.com/ProseMirror/prosemirror-dropcursor) for more information.
294
+ *
295
+ * @public
296
+ */
297
+ export declare function defineDropCursor(options?: DropCursorOptions): Extension<ExtensionTyping<string, string, CommandArgs>>;
298
+
299
+ /**
300
+ * Defines an enter rule. An enter rule applies when the text directly in front of
301
+ * the cursor matches `regex` and user presses Enter. The `regex` should end
302
+ * with `$`.
303
+ *
304
+ * @public
305
+ */
306
+ export declare function defineEnterRule({ regex, handler, stop, }: EnterRuleOptions): Extension;
307
+
147
308
  /**
148
309
  * @public
149
310
  */
@@ -164,6 +325,10 @@ toggleHeading: [attrs?: HeadingAttrs | undefined];
164
325
  };
165
326
  }>;
166
327
 
328
+ /**
329
+ * Converts the text block to a heading when `#` is typed at the start of a new
330
+ * line followed by a space.
331
+ */
167
332
  export declare function defineHeadingInputRule(): Extension<ExtensionTyping<string, string, CommandArgs>>;
168
333
 
169
334
  export declare function defineHeadingKeymap(): Extension<ExtensionTyping<string, string, CommandArgs>>;
@@ -192,6 +357,15 @@ export declare function defineImageSpec(): Extension< {
192
357
  NODES: "image";
193
358
  }>;
194
359
 
360
+ /**
361
+ * Defines an input rule extension.
362
+ *
363
+ * @param rule - The ProseMirror input rule to add.
364
+ *
365
+ * @public
366
+ */
367
+ export declare function defineInputRule(rule: InputRule): Extension;
368
+
195
369
  /**
196
370
  * @public
197
371
  */
@@ -223,17 +397,25 @@ export declare function defineLink(): Extension< {
223
397
  MARKS: "link";
224
398
  COMMAND_ARGS: {
225
399
  addLink: [attrs: LinkAttrs];
400
+ removeLink: [];
226
401
  toggleLink: [attrs: LinkAttrs];
402
+ expandLink: [];
227
403
  };
228
404
  }>;
229
405
 
230
406
  export declare function defineLinkCommands(): Extension< {
231
407
  COMMAND_ARGS: {
232
408
  addLink: [attrs: LinkAttrs];
409
+ removeLink: [];
233
410
  toggleLink: [attrs: LinkAttrs];
411
+ expandLink: [];
234
412
  };
235
413
  }>;
236
414
 
415
+ export declare function defineLinkEnterRule(): Extension<ExtensionTyping<string, string, CommandArgs>>;
416
+
417
+ export declare function defineLinkInputRule(): Extension<ExtensionTyping<string, string, CommandArgs>>;
418
+
237
419
  export declare function defineLinkSpec(): Extension< {
238
420
  MARKS: "link";
239
421
  }>;
@@ -241,36 +423,36 @@ MARKS: "link";
241
423
  /**
242
424
  * @public
243
425
  */
244
- export declare function defineList(): Extension< {
245
- NODES: "list";
246
- COMMAND_ARGS: {
247
- dedentList: [options?: DedentListOptions | undefined];
248
- indentList: [options?: IndentListOptions | undefined];
249
- moveList: [direction: "up" | "down"];
250
- splitList: [];
251
- toggleCollapsed: [(ToggleCollapsedOptions | undefined)?];
252
- toggleList: [attrs: ListAttributes];
253
- unwrapList: [options?: UnwrapListOptions | undefined];
254
- wrapInList: [getAttrs: ListAttributes | ((range: NodeRange) => ListAttributes | null)];
255
- insertList: [attrs?: ListAttributes | undefined];
256
- };
257
- }>;
258
-
259
- export declare function defineListCommands(): Extension< {
260
- COMMAND_ARGS: {
261
- dedentList: [options?: DedentListOptions | undefined];
262
- indentList: [options?: IndentListOptions | undefined];
263
- moveList: [direction: "up" | "down"];
264
- splitList: [];
265
- toggleCollapsed: [(ToggleCollapsedOptions | undefined)?];
266
- toggleList: [attrs: ListAttributes];
267
- unwrapList: [options?: UnwrapListOptions | undefined];
268
- wrapInList: [getAttrs: ListAttributes | ((range: NodeRange) => ListAttributes | null)];
269
- insertList: [attrs?: ListAttributes | undefined];
270
- };
271
- }>;
272
-
273
- export declare function defineListInputRules(): Extension<ExtensionTyping<string, string, CommandArgs>>;
426
+ export declare function defineList(): Extension<{
427
+ NODES: "list";
428
+ COMMAND_ARGS: {
429
+ dedentList: [options?: DedentListOptions | undefined];
430
+ indentList: [options?: IndentListOptions | undefined];
431
+ moveList: [direction: "up" | "down"];
432
+ splitList: [];
433
+ toggleCollapsed: [(ToggleCollapsedOptions | undefined)?];
434
+ toggleList: [attrs: ListAttributes];
435
+ unwrapList: [options?: UnwrapListOptions | undefined];
436
+ wrapInList: [getAttrs: ListAttributes | ((range: NodeRange) => ListAttributes | null)];
437
+ insertList: [attrs?: ListAttributes | undefined];
438
+ };
439
+ }>;
440
+
441
+ export declare function defineListCommands(): Extension<{
442
+ COMMAND_ARGS: {
443
+ dedentList: [options?: DedentListOptions | undefined];
444
+ indentList: [options?: IndentListOptions | undefined];
445
+ moveList: [direction: "up" | "down"];
446
+ splitList: [];
447
+ toggleCollapsed: [(ToggleCollapsedOptions | undefined)?];
448
+ toggleList: [attrs: ListAttributes];
449
+ unwrapList: [options?: UnwrapListOptions | undefined];
450
+ wrapInList: [getAttrs: ListAttributes | ((range: NodeRange) => ListAttributes | null)];
451
+ insertList: [attrs?: ListAttributes | undefined];
452
+ };
453
+ }>;
454
+
455
+ export declare function defineListInputRules(): Extension;
274
456
 
275
457
  /**
276
458
  * Returns a extension that adds key bindings for list.
@@ -281,8 +463,8 @@ export declare function defineListKeymap(): Extension<ExtensionTyping<string, st
281
463
 
282
464
  export declare function defineListPlugins(): Extension<ExtensionTyping<string, string, CommandArgs>>;
283
465
 
284
- export declare function defineListSpec(): Extension< {
285
- NODES: "list";
466
+ export declare function defineListSpec(): Extension<{
467
+ NODES: "list";
286
468
  }>;
287
469
 
288
470
  /**
@@ -290,6 +472,15 @@ NODES: "list";
290
472
  */
291
473
  export declare function defineMention(): Extension< {
292
474
  NODES: "mention";
475
+ COMMAND_ARGS: {
476
+ insertMention: [attrs: MentionAttrs];
477
+ };
478
+ }>;
479
+
480
+ export declare function defineMentionCommands(): Extension< {
481
+ COMMAND_ARGS: {
482
+ insertMention: [attrs: MentionAttrs];
483
+ };
293
484
  }>;
294
485
 
295
486
  /**
@@ -305,6 +496,11 @@ NODES: "mention";
305
496
  */
306
497
  export declare function definePlaceholder(options: PlaceholderOptions): Extension<ExtensionTyping<string, string, CommandArgs>>;
307
498
 
499
+ /**
500
+ * Make the editor read-only.
501
+ */
502
+ export declare function defineReadonly(): Extension<ExtensionTyping<string, string, CommandArgs>>;
503
+
308
504
  /**
309
505
  * @public
310
506
  */
@@ -327,7 +523,102 @@ export declare function defineStrikeSpec(): Extension< {
327
523
  MARKS: "strike";
328
524
  }>;
329
525
 
330
- export declare function defineSuggestion(options: SuggestionOptions): Extension<ExtensionTyping<string, string, CommandArgs>>;
526
+ /**
527
+ * @public
528
+ */
529
+ export declare function defineTable(): Extension< {
530
+ NODES: "table" | "tableRow" | "tableCell" | "tableHeaderCell";
531
+ COMMAND_ARGS: {
532
+ insertTable: [{
533
+ row: number;
534
+ col: number;
535
+ header: boolean;
536
+ }];
537
+ exitTable: [];
538
+ };
539
+ }>;
540
+
541
+ declare function defineTableCellSpec(): Extension< {
542
+ NODES: "tableCell";
543
+ }>;
544
+ export { defineTableCellSpec }
545
+ export { defineTableCellSpec as defineTableCellSpec_alias_1 }
546
+
547
+ /**
548
+ * Adds commands for working with `table` nodes.
549
+ *
550
+ * @public
551
+ */
552
+ declare function defineTableCommands(): Extension< {
553
+ COMMAND_ARGS: {
554
+ insertTable: [{
555
+ row: number;
556
+ col: number;
557
+ header: boolean;
558
+ }];
559
+ exitTable: [];
560
+ };
561
+ }>;
562
+ export { defineTableCommands }
563
+ export { defineTableCommands as defineTableCommands_alias_1 }
564
+
565
+ declare function defineTableHeaderCellSpec(): Extension< {
566
+ NODES: "tableHeaderCell";
567
+ }>;
568
+ export { defineTableHeaderCellSpec }
569
+ export { defineTableHeaderCellSpec as defineTableHeaderCellSpec_alias_1 }
570
+
571
+ /**
572
+ * @public
573
+ */
574
+ declare function defineTablePlugins(): Extension<ExtensionTyping<string, string, CommandArgs>>;
575
+ export { defineTablePlugins }
576
+ export { defineTablePlugins as defineTablePlugins_alias_1 }
577
+
578
+ declare function defineTableRowSpec(): Extension< {
579
+ NODES: "tableRow";
580
+ }>;
581
+ export { defineTableRowSpec }
582
+ export { defineTableRowSpec as defineTableRowSpec_alias_1 }
583
+
584
+ declare function defineTableSpec(): Extension< {
585
+ NODES: "table";
586
+ }>;
587
+ export { defineTableSpec }
588
+ export { defineTableSpec as defineTableSpec_alias_1 }
589
+
590
+ /**
591
+ * Defines an enter rule that replaces the matched text with a block node.
592
+ *
593
+ * See also {@link defineEnterRule}.
594
+ *
595
+ * @public
596
+ */
597
+ export declare function defineTextBlockEnterRule({ regex, type, attrs, stop, }: TextBlockEnterRuleOptions): Extension;
598
+
599
+ /**
600
+ * Defines an input rule that changes the type of a textblock when the matched
601
+ * text is typed into it.
602
+ *
603
+ * See also [textblockTypeInputRule](https://prosemirror.net/docs/ref/#inputrules.textblockTypeInputRule)
604
+ *
605
+ * @public
606
+ */
607
+ export declare function defineTextBlockInputRule({ regex, type, attrs, }: {
608
+ /**
609
+ * The regular expression to match against. You'll usually want to start it
610
+ * with `^` to that it is only matched at the start of a textblock.
611
+ */
612
+ regex: RegExp;
613
+ /**
614
+ * The node type to replace the matched text with.
615
+ */
616
+ type: string | NodeType;
617
+ /**
618
+ * Attributes to set on the node.
619
+ */
620
+ attrs?: Attrs | null | ((match: RegExpMatchArray) => Attrs | null);
621
+ }): Extension;
331
622
 
332
623
  /**
333
624
  * @public
@@ -351,6 +642,124 @@ export declare function defineUnderlineSpec(): Extension< {
351
642
  MARKS: "underline";
352
643
  }>;
353
644
 
645
+ /**
646
+ * Shows a virtual selection when the editor is not focused. When the editor is
647
+ * not focused, the selected inline content will be wrapped in a `<span>`
648
+ * element with the class `prosekit-virtual-selection`.
649
+ *
650
+ * This is useful when you want to move the focus to an element outside the
651
+ * editor, but still want to show the selection.
652
+ *
653
+ * @public
654
+ */
655
+ export declare function defineVirtualSelection(): Extension;
656
+
657
+ /**
658
+ * Defines an input rule for automatically wrapping a textblock when a given
659
+ * string is typed.
660
+ *
661
+ * See also [wrappingInputRule](https://prosemirror.net/docs/ref/#inputrules.wrappingInputRule)
662
+ *
663
+ * @public
664
+ */
665
+ export declare function defineWrappingInputRule({ regex, type, attrs, join, }: {
666
+ /**
667
+ * The regular expression to match against. You'll usually want to start it
668
+ * with `^` to that it is only matched at the start of a textblock.
669
+ */
670
+ regex: RegExp;
671
+ /**
672
+ * The type of node to wrap in.
673
+ */
674
+ type: string | NodeType;
675
+ /**
676
+ * Attributes to set on the node.
677
+ */
678
+ attrs?: Attrs | null | ((match: RegExpMatchArray) => Attrs | null);
679
+ /**
680
+ * By default, if there's a node with the same type above the newly wrapped
681
+ * node, the rule will try to
682
+ * [join](https://prosemirror.net/docs/ref/#transform.Transform.join) those
683
+ * two nodes. You can pass a join predicate, which takes a regular expression
684
+ * match and the node before the wrapped node, and can return a boolean to
685
+ * indicate whether a join should happen.
686
+ */
687
+ join?: (match: RegExpMatchArray, node: ProseMirrorNode) => boolean;
688
+ }): Extension;
689
+
690
+ export declare interface DropCursorOptions {
691
+ /**
692
+ * The color of the cursor. Use `false` to apply no color and rely only on class.
693
+ *
694
+ * @default 'black'
695
+ */
696
+ color?: string | false;
697
+ /**
698
+ * The precise width of the cursor in pixels.
699
+ *
700
+ * @default 1
701
+ */
702
+ width?: number;
703
+ /**
704
+ * A CSS class name to add to the cursor element.
705
+ */
706
+ class?: string;
707
+ }
708
+
709
+ /**
710
+ * @public
711
+ */
712
+ export declare type EnterRuleHandler = (options: {
713
+ /**
714
+ * The current editor state.
715
+ */
716
+ state: EditorState;
717
+ /**
718
+ * The start position of the matched text.
719
+ */
720
+ from: number;
721
+ /**
722
+ * The end position of the matched text.
723
+ */
724
+ to: number;
725
+ /**
726
+ * The matched result from the regular expression.
727
+ */
728
+ match: RegExpExecArray;
729
+ }) => Transaction | null;
730
+
731
+ /**
732
+ * Options for {@link defineEnterRule}.
733
+ *
734
+ * @public
735
+ */
736
+ export declare type EnterRuleOptions = {
737
+ /**
738
+ * The regular expression to match against. It should end with `$`.
739
+ */
740
+ regex: RegExp;
741
+ /**
742
+ * A function to be called when an enter rule is triggered.
743
+ */
744
+ handler: EnterRuleHandler;
745
+ /**
746
+ * Whether to stop further handlers from being called if this rule is triggered.
747
+ *
748
+ * @default false
749
+ */
750
+ stop?: boolean;
751
+ };
752
+
753
+ /**
754
+ * When the selection is in a table node, create a default block after the table
755
+ * table, and move the cursor there.
756
+ *
757
+ * @public
758
+ */
759
+ export declare const exitTable: Command;
760
+
761
+ export { getHighlighter }
762
+
354
763
  export declare function getPluginState(state: EditorState): PredictionPluginState | undefined;
355
764
 
356
765
  export declare function getTrMeta(tr: Transaction): PredictionPluginState;
@@ -359,10 +768,41 @@ export declare interface HeadingAttrs {
359
768
  level: number;
360
769
  }
361
770
 
771
+ declare type HighlighterOptions = {
772
+ themes: BundledTheme[];
773
+ langs: (BundledLanguage | SpecialLanguage)[];
774
+ langAlias?: Record<string, BundledLanguage>;
775
+ };
776
+
777
+ /**
778
+ * @public
779
+ *
780
+ * An alias for the `Parser` type from the `prosemirror-highlight` package.
781
+ */
782
+ declare type HighlightParser = Parser;
783
+ export { HighlightParser }
784
+ export { HighlightParser as HighlightParser_alias_1 }
785
+
362
786
  export declare interface ImageAttrs {
363
787
  src?: string | null;
364
788
  }
365
789
 
790
+ /**
791
+ * Insert a table node with the given number of rows and columns, and optionally
792
+ * a header row.
793
+ *
794
+ * @public
795
+ */
796
+ export declare function insertTable({ row, col, header, }: {
797
+ row: number;
798
+ col: number;
799
+ header: boolean;
800
+ }): Command;
801
+
802
+ export declare const LINK_RE: RegExp;
803
+
804
+ export declare const LINK_SPACE_RE: RegExp;
805
+
366
806
  /**
367
807
  * @public
368
808
  */
@@ -370,6 +810,8 @@ export declare interface LinkAttrs {
370
810
  href: string;
371
811
  }
372
812
 
813
+ export { ListDOMSerializer }
814
+
373
815
  declare type MatchHandler = (options: {
374
816
  state: EditorState;
375
817
  match: RegExpExecArray;
@@ -377,30 +819,16 @@ declare type MatchHandler = (options: {
377
819
  to: number;
378
820
  ignoreMatch: () => void;
379
821
  deleteMatch: () => void;
380
- }) => Transaction | null | void;
822
+ }) => void;
381
823
  export { MatchHandler }
382
824
  export { MatchHandler as MatchHandler_alias_1 }
383
825
 
384
- /**
385
- * @returns Return a Transaction object if you want to append a transaction to current state (using )
386
- */
387
- declare type MatchHandler_2 = (options: {
388
- rule: PredictionRule;
389
- match: RegExpMatchArray;
390
- matchAfter: RegExpMatchArray | null;
391
- state: EditorState;
392
- dismiss: VoidFunction;
393
- deleteMatch: VoidFunction;
394
- }) => void;
395
-
396
826
  export declare interface MentionAttrs {
397
827
  id: string;
398
828
  kind: string;
399
829
  value: string;
400
830
  }
401
831
 
402
- export declare const OBJECT_REPLACEMENT = "\uFFFC";
403
-
404
832
  export declare interface PlaceholderOptions {
405
833
  /**
406
834
  * The placeholder text to use.
@@ -408,8 +836,8 @@ export declare interface PlaceholderOptions {
408
836
  placeholder: string;
409
837
  /**
410
838
  * By default, the placeholder text will be shown whenever the current text
411
- * cursor is in an empty node. If you only want to show the placeholder when
412
- * the whole doc is empty, you can set this option to 'doc'.
839
+ * cursor is in an empty text node. If you only want to show the placeholder
840
+ * when the whole doc is empty, you can set this option to 'doc'.
413
841
  *
414
842
  * @default 'block'
415
843
  */
@@ -429,31 +857,33 @@ export declare interface PredictionPluginState {
429
857
  } | null;
430
858
  }
431
859
 
432
- declare interface PredictionRule {
433
- match: RegExp;
434
- matchAfter?: RegExp;
435
- }
436
- export { PredictionRule }
437
- export { PredictionRule as PredictionRule_alias_1 }
438
-
439
860
  export declare function setTrMeta(tr: Transaction, meta: PredictionPluginState): Transaction;
440
861
 
441
- declare interface SuggestionOptions {
442
- rules: PredictionRule[];
443
- onMatch: MatchHandler_2;
444
- onDeactivate: VoidFunction;
862
+ /**
863
+ * Options for {@link defineTextBlockEnterRule}.
864
+ *
865
+ * @public
866
+ */
867
+ export declare type TextBlockEnterRuleOptions = {
445
868
  /**
446
- * You can pass this function if you want to skip the matching in some cases.
447
- * By default, the plugin will only run the matching if the current selection
448
- * is empty, and the selection is not inside a
449
- * [code](https://prosemirror.net/docs/ref/#model.NodeSpec.code) node nor
450
- * inside a mark with the name as `code`.
869
+ * The regular expression to match against. It should end with `$`.
451
870
  */
452
- isValid?: (options: {
453
- state: EditorState;
454
- }) => boolean;
455
- }
456
- export { SuggestionOptions }
457
- export { SuggestionOptions as SuggestionOptions_alias_1 }
871
+ regex: RegExp;
872
+ /**
873
+ * The node type to replace the matched text with.
874
+ */
875
+ type: string | NodeType;
876
+ /**
877
+ * Attributes to set on the node. If a function is provided, it will be called
878
+ * with the matched result from the regular expression.
879
+ */
880
+ attrs?: Attrs | null | ((match: RegExpMatchArray) => Attrs | null);
881
+ /**
882
+ * Whether to stop further handlers from being called if this rule is triggered.
883
+ *
884
+ * @default true
885
+ */
886
+ stop?: boolean;
887
+ };
458
888
 
459
889
  export { }