@prosekit/extensions 0.4.7 → 0.5.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.
@@ -6,11 +6,9 @@ import { BundledTheme } from 'shiki';
6
6
  import { BundledThemeInfo } from 'shiki';
7
7
  import { bundledThemesInfo } from 'shiki';
8
8
  import { Command } from '@prosekit/pm/state';
9
- import { CommandArgs } from '@prosekit/core';
10
9
  import { DedentListOptions } from 'prosemirror-flat-list';
11
10
  import { EditorState } from '@prosekit/pm/state';
12
11
  import { Extension } from '@prosekit/core';
13
- import { ExtensionTyping } from '@prosekit/core';
14
12
  import { getHighlighter } from 'shiki/bundle/full';
15
13
  import { IndentListOptions } from 'prosemirror-flat-list';
16
14
  import { InputRule } from '@prosekit/pm/inputrules';
@@ -141,50 +139,62 @@ export declare function defineAutocomplete(rule: AutocompleteRule): Extension;
141
139
  * @public
142
140
  */
143
141
  export declare function defineBlockquote(): Extension< {
144
- NODES: "blockquote";
142
+ Nodes: any;
143
+ Marks: any;
144
+ Commands: {
145
+ [x: string]: any;
146
+ };
145
147
  }>;
146
148
 
147
149
  /**
148
150
  * Wraps the text block in a blockquote when `>` is typed at the start of a new
149
151
  * line followed by a space.
150
152
  */
151
- export declare function defineBlockquoteInputRule(): Extension<ExtensionTyping<string, string, CommandArgs>>;
153
+ export declare function defineBlockquoteInputRule(): Extension<any>;
152
154
 
153
155
  export declare function defineBlockquoteSpec(): Extension< {
154
- NODES: "blockquote";
156
+ Nodes: "blockquote";
157
+ Marks: never;
158
+ Commands: never;
155
159
  }>;
156
160
 
157
161
  /**
158
162
  * @public
159
163
  */
160
164
  export declare function defineBold(): Extension< {
161
- MARKS: "bold";
162
- COMMAND_ARGS: {
163
- toggleBold: [];
165
+ Nodes: any;
166
+ Marks: any;
167
+ Commands: {
168
+ [x: string]: any;
164
169
  };
165
170
  }>;
166
171
 
167
172
  export declare function defineBoldCommands(): Extension< {
168
- COMMAND_ARGS: {
173
+ Commands: {
169
174
  toggleBold: [];
170
175
  };
176
+ Nodes: never;
177
+ Marks: never;
171
178
  }>;
172
179
 
173
- export declare function defineBoldInputRule(): Extension<ExtensionTyping<string, string, CommandArgs>>;
180
+ export declare function defineBoldInputRule(): Extension<any>;
174
181
 
175
- export declare function defineBoldKeymap(): Extension<ExtensionTyping<string, string, CommandArgs>>;
182
+ export declare function defineBoldKeymap(): Extension<any>;
176
183
 
177
184
  export declare function defineBoldSpec(): Extension< {
178
- MARKS: "bold";
185
+ Marks: "bold";
186
+ Nodes: never;
187
+ Commands: never;
179
188
  }>;
180
189
 
181
190
  /**
182
191
  * @public
183
192
  */
184
193
  export declare function defineCode(): Extension< {
185
- MARKS: "code";
186
- COMMAND_ARGS: {
187
- toggleCode: [];
194
+ Nodes: any;
195
+ Marks: any;
196
+ Commands: {
197
+ [x: string]: any;
188
198
  };
189
199
  }>;
190
200
 
@@ -200,12 +210,10 @@ toggleCode: [];
200
210
  * @public
201
211
  */
202
212
  declare function defineCodeBlock(): Extension< {
203
- NODES: "codeBlock";
204
- COMMAND_ARGS: {
205
- setCodeBlock: [attrs?: CodeBlockAttrs | undefined];
206
- insertCodeBlock: [attrs?: CodeBlockAttrs | undefined];
207
- toggleCodeBlock: [attrs?: CodeBlockAttrs | undefined];
208
- setCodeBlockAttrs: [attrs: CodeBlockAttrs];
213
+ Nodes: any;
214
+ Marks: any;
215
+ Commands: {
216
+ [x: string]: any;
209
217
  };
210
218
  }>;
211
219
  export { defineCodeBlock }
@@ -217,12 +225,14 @@ export { defineCodeBlock as defineCodeBlock_alias_1 }
217
225
  * @public
218
226
  */
219
227
  declare function defineCodeBlockCommands(): Extension< {
220
- COMMAND_ARGS: {
228
+ Commands: {
221
229
  setCodeBlock: [attrs?: CodeBlockAttrs | undefined];
222
230
  insertCodeBlock: [attrs?: CodeBlockAttrs | undefined];
223
231
  toggleCodeBlock: [attrs?: CodeBlockAttrs | undefined];
224
232
  setCodeBlockAttrs: [attrs: CodeBlockAttrs];
225
233
  };
234
+ Nodes: never;
235
+ Marks: never;
226
236
  }>;
227
237
  export { defineCodeBlockCommands }
228
238
  export { defineCodeBlockCommands as defineCodeBlockCommands_alias_1 }
@@ -232,7 +242,7 @@ export { defineCodeBlockCommands as defineCodeBlockCommands_alias_1 }
232
242
  *
233
243
  * @public
234
244
  */
235
- declare function defineCodeBlockEnterRule(): Extension<ExtensionTyping<string, string, CommandArgs>>;
245
+ declare function defineCodeBlockEnterRule(): Extension<any>;
236
246
  export { defineCodeBlockEnterRule }
237
247
  export { defineCodeBlockEnterRule as defineCodeBlockEnterRule_alias_1 }
238
248
 
@@ -255,14 +265,14 @@ export { defineCodeBlockHighlight as defineCodeBlockHighlight_alias_1 }
255
265
  *
256
266
  * @public
257
267
  */
258
- declare function defineCodeBlockInputRule(): Extension<ExtensionTyping<string, string, CommandArgs>>;
268
+ declare function defineCodeBlockInputRule(): Extension<any>;
259
269
  export { defineCodeBlockInputRule }
260
270
  export { defineCodeBlockInputRule as defineCodeBlockInputRule_alias_1 }
261
271
 
262
272
  /**
263
273
  * Defines the keymap for code blocks.
264
274
  */
265
- export declare function defineCodeBlockKeymap(): Extension<ExtensionTyping<string, string, CommandArgs>>;
275
+ export declare function defineCodeBlockKeymap(): Extension<any>;
266
276
 
267
277
  /**
268
278
  * Adds syntax highlighting to code blocks using the [shiki](https://github.com/shikijs/shiki) package.
@@ -279,26 +289,32 @@ export { defineCodeBlockShiki as defineCodeBlockShiki_alias_1 }
279
289
  * @public
280
290
  */
281
291
  declare function defineCodeBlockSpec(): Extension< {
282
- NODES: "codeBlock";
292
+ Nodes: "codeBlock";
293
+ Marks: never;
294
+ Commands: never;
283
295
  }>;
284
296
  export { defineCodeBlockSpec }
285
297
  export { defineCodeBlockSpec as defineCodeBlockSpec_alias_1 }
286
298
 
287
299
  export declare function defineCodeCommands(): Extension< {
288
- COMMAND_ARGS: {
300
+ Commands: {
289
301
  toggleCode: [];
290
302
  };
303
+ Nodes: never;
304
+ Marks: never;
291
305
  }>;
292
306
 
293
- export declare function defineCodeInputRule(): Extension<ExtensionTyping<string, string, CommandArgs>>;
307
+ export declare function defineCodeInputRule(): Extension<any>;
294
308
 
295
- export declare function defineCodeKeymap(): Extension<ExtensionTyping<string, string, CommandArgs>>;
309
+ export declare function defineCodeKeymap(): Extension<any>;
296
310
 
297
311
  /**
298
312
  * @public
299
313
  */
300
314
  export declare function defineCodeSpec(): Extension< {
301
- MARKS: "code";
315
+ Marks: "code";
316
+ Nodes: never;
317
+ Commands: never;
302
318
  }>;
303
319
 
304
320
  /**
@@ -308,7 +324,7 @@ MARKS: "code";
308
324
  *
309
325
  * @public
310
326
  */
311
- export declare function defineDropCursor(options?: DropCursorOptions): Extension<ExtensionTyping<string, string, CommandArgs>>;
327
+ export declare function defineDropCursor(options?: DropCursorOptions): Extension<any>;
312
328
 
313
329
  /**
314
330
  * Defines an enter rule. An enter rule applies when the text directly in front of
@@ -323,52 +339,60 @@ export declare function defineEnterRule({ regex, handler, stop, }: EnterRuleOpti
323
339
  * @public
324
340
  */
325
341
  export declare function defineHeading(): Extension< {
326
- NODES: "heading";
327
- COMMAND_ARGS: {
328
- setHeading: [attrs?: HeadingAttrs | undefined];
329
- insertHeading: [attrs?: HeadingAttrs | undefined];
330
- toggleHeading: [attrs?: HeadingAttrs | undefined];
342
+ Nodes: any;
343
+ Marks: any;
344
+ Commands: {
345
+ [x: string]: any;
331
346
  };
332
347
  }>;
333
348
 
334
349
  export declare function defineHeadingCommands(): Extension< {
335
- COMMAND_ARGS: {
350
+ Commands: {
336
351
  setHeading: [attrs?: HeadingAttrs | undefined];
337
352
  insertHeading: [attrs?: HeadingAttrs | undefined];
338
353
  toggleHeading: [attrs?: HeadingAttrs | undefined];
339
354
  };
355
+ Nodes: never;
356
+ Marks: never;
340
357
  }>;
341
358
 
342
359
  /**
343
360
  * Converts the text block to a heading when `#` is typed at the start of a new
344
361
  * line followed by a space.
345
362
  */
346
- export declare function defineHeadingInputRule(): Extension<ExtensionTyping<string, string, CommandArgs>>;
363
+ export declare function defineHeadingInputRule(): Extension<any>;
347
364
 
348
- export declare function defineHeadingKeymap(): Extension<ExtensionTyping<string, string, CommandArgs>>;
365
+ export declare function defineHeadingKeymap(): Extension<any>;
349
366
 
350
367
  export declare function defineHeadingSpec(): Extension< {
351
- NODES: "heading";
368
+ Nodes: "heading";
369
+ Marks: never;
370
+ Commands: never;
352
371
  }>;
353
372
 
354
373
  /**
355
374
  * @public
356
375
  */
357
376
  export declare function defineImage(): Extension< {
358
- NODES: "image";
359
- COMMAND_ARGS: {
377
+ Nodes: "image";
378
+ Marks: never;
379
+ Commands: {
360
380
  insertImage: [attrs?: ImageAttrs | undefined];
361
381
  };
362
382
  }>;
363
383
 
364
384
  export declare function defineImageCommands(): Extension< {
365
- COMMAND_ARGS: {
385
+ Commands: {
366
386
  insertImage: [attrs?: ImageAttrs | undefined];
367
387
  };
388
+ Nodes: never;
389
+ Marks: never;
368
390
  }>;
369
391
 
370
392
  export declare function defineImageSpec(): Extension< {
371
- NODES: "image";
393
+ Nodes: "image";
394
+ Marks: never;
395
+ Commands: never;
372
396
  }>;
373
397
 
374
398
  /**
@@ -384,87 +408,87 @@ export declare function defineInputRule(rule: InputRule): Extension;
384
408
  * @public
385
409
  */
386
410
  export declare function defineItalic(): Extension< {
387
- MARKS: "italic";
388
- COMMAND_ARGS: {
389
- toggleItalic: [];
411
+ Nodes: any;
412
+ Marks: any;
413
+ Commands: {
414
+ [x: string]: any;
390
415
  };
391
416
  }>;
392
417
 
393
418
  export declare function defineItalicCommands(): Extension< {
394
- COMMAND_ARGS: {
419
+ Commands: {
395
420
  toggleItalic: [];
396
421
  };
422
+ Nodes: never;
423
+ Marks: never;
397
424
  }>;
398
425
 
399
- export declare function defineItalicInputRule(): Extension<ExtensionTyping<string, string, CommandArgs>>;
426
+ export declare function defineItalicInputRule(): Extension<any>;
400
427
 
401
- export declare function defineItalicKeymap(): Extension<ExtensionTyping<string, string, CommandArgs>>;
428
+ export declare function defineItalicKeymap(): Extension<any>;
402
429
 
403
430
  export declare function defineItalicSpec(): Extension< {
404
- MARKS: "italic";
431
+ Marks: "italic";
432
+ Nodes: never;
433
+ Commands: never;
405
434
  }>;
406
435
 
407
436
  /**
408
437
  * @public
409
438
  */
410
439
  export declare function defineLink(): Extension< {
411
- MARKS: "link";
412
- COMMAND_ARGS: {
413
- addLink: [attrs: LinkAttrs];
414
- removeLink: [];
415
- toggleLink: [attrs: LinkAttrs];
416
- expandLink: [];
440
+ Nodes: any;
441
+ Marks: any;
442
+ Commands: {
443
+ [x: string]: any;
417
444
  };
418
445
  }>;
419
446
 
420
447
  export declare function defineLinkCommands(): Extension< {
421
- COMMAND_ARGS: {
448
+ Commands: {
422
449
  addLink: [attrs: LinkAttrs];
423
450
  removeLink: [];
424
451
  toggleLink: [attrs: LinkAttrs];
425
452
  expandLink: [];
426
453
  };
454
+ Nodes: never;
455
+ Marks: never;
427
456
  }>;
428
457
 
429
458
  /**
430
459
  * Apply link marks after typing Enter.
431
460
  */
432
- export declare function defineLinkEnterRule(): Extension<ExtensionTyping<string, string, CommandArgs>>;
461
+ export declare function defineLinkEnterRule(): Extension<any>;
433
462
 
434
463
  /**
435
464
  * Apply link marks after pressing Space.
436
465
  */
437
- export declare function defineLinkInputRule(): Extension<ExtensionTyping<string, string, CommandArgs>>;
466
+ export declare function defineLinkInputRule(): Extension<any>;
438
467
 
439
468
  /**
440
469
  * Apply and remove link marks to the text during typing.
441
470
  */
442
- export declare function defineLinkMarkRule(): Extension<ExtensionTyping<string, string, CommandArgs>>;
471
+ export declare function defineLinkMarkRule(): Extension<any>;
443
472
 
444
473
  export declare function defineLinkSpec(): Extension< {
445
- MARKS: "link";
474
+ Marks: "link";
475
+ Nodes: never;
476
+ Commands: never;
446
477
  }>;
447
478
 
448
479
  /**
449
480
  * @public
450
481
  */
451
482
  export declare function defineList(): Extension<{
452
- NODES: "list";
453
- COMMAND_ARGS: {
454
- dedentList: [options?: DedentListOptions | undefined];
455
- indentList: [options?: IndentListOptions | undefined];
456
- moveList: [direction: "up" | "down"];
457
- splitList: [];
458
- toggleCollapsed: [(ToggleCollapsedOptions | undefined)?];
459
- toggleList: [attrs: ListAttributes];
460
- unwrapList: [options?: UnwrapListOptions | undefined];
461
- wrapInList: [getAttrs: ListAttributes | ((range: NodeRange) => ListAttributes | null)];
462
- insertList: [attrs?: ListAttributes | undefined];
483
+ Nodes: any;
484
+ Marks: any;
485
+ Commands: {
486
+ [x: string]: any;
463
487
  };
464
488
  }>;
465
489
 
466
490
  export declare function defineListCommands(): Extension<{
467
- COMMAND_ARGS: {
491
+ Commands: {
468
492
  dedentList: [options?: DedentListOptions | undefined];
469
493
  indentList: [options?: IndentListOptions | undefined];
470
494
  moveList: [direction: "up" | "down"];
@@ -475,6 +499,8 @@ export declare function defineListCommands(): Extension<{
475
499
  wrapInList: [getAttrs: ListAttributes | ((range: NodeRange) => ListAttributes | null)];
476
500
  insertList: [attrs?: ListAttributes | undefined];
477
501
  };
502
+ Nodes: never;
503
+ Marks: never;
478
504
  }>;
479
505
 
480
506
  export declare function defineListInputRules(): Extension;
@@ -484,12 +510,14 @@ export declare function defineListInputRules(): Extension;
484
510
  *
485
511
  * @public
486
512
  */
487
- export declare function defineListKeymap(): Extension<ExtensionTyping<string, string, CommandArgs>>;
513
+ export declare function defineListKeymap(): Extension<any>;
488
514
 
489
- export declare function defineListPlugins(): Extension<ExtensionTyping<string, string, CommandArgs>>;
515
+ export declare function defineListPlugins(): Extension<any>;
490
516
 
491
517
  export declare function defineListSpec(): Extension<{
492
- NODES: "list";
518
+ Nodes: "list";
519
+ Marks: never;
520
+ Commands: never;
493
521
  }>;
494
522
 
495
523
  /**
@@ -504,7 +532,7 @@ export declare function defineMarkInputRule(options: MarkInputRuleOptions): Exte
504
532
  * A mark rule is something that can automatically apply marks to text if it
505
533
  * matches a certain pattern, and remove them if it doesn't match anymore.
506
534
  */
507
- declare function defineMarkRule(options: MarkRuleOptions): Extension<ExtensionTyping<string, string, CommandArgs>>;
535
+ declare function defineMarkRule(options: MarkRuleOptions): Extension<any>;
508
536
  export { defineMarkRule }
509
537
  export { defineMarkRule as defineMarkRule_alias_1 }
510
538
 
@@ -512,23 +540,28 @@ export { defineMarkRule as defineMarkRule_alias_1 }
512
540
  * @public
513
541
  */
514
542
  export declare function defineMention(): Extension< {
515
- NODES: "mention";
516
- COMMAND_ARGS: {
543
+ Nodes: "mention";
544
+ Marks: never;
545
+ Commands: {
517
546
  insertMention: [attrs: MentionAttrs];
518
547
  };
519
548
  }>;
520
549
 
521
550
  export declare function defineMentionCommands(): Extension< {
522
- COMMAND_ARGS: {
551
+ Commands: {
523
552
  insertMention: [attrs: MentionAttrs];
524
553
  };
554
+ Nodes: never;
555
+ Marks: never;
525
556
  }>;
526
557
 
527
558
  /**
528
559
  * @public
529
560
  */
530
561
  export declare function defineMentionSpec(): Extension< {
531
- NODES: "mention";
562
+ Nodes: "mention";
563
+ Marks: never;
564
+ Commands: never;
532
565
  }>;
533
566
 
534
567
  /**
@@ -543,54 +576,57 @@ export declare function defineModClickPrevention(): Extension;
543
576
  * Add a placeholder text to the editor when the current block or document is
544
577
  * empty.
545
578
  */
546
- export declare function definePlaceholder(options: PlaceholderOptions): Extension<ExtensionTyping<string, string, CommandArgs>>;
579
+ export declare function definePlaceholder(options: PlaceholderOptions): Extension<any>;
547
580
 
548
581
  /**
549
582
  * Make the editor read-only.
550
583
  */
551
- export declare function defineReadonly(): Extension<ExtensionTyping<string, string, CommandArgs>>;
584
+ export declare function defineReadonly(): Extension<any>;
552
585
 
553
586
  /**
554
587
  * @public
555
588
  */
556
589
  export declare function defineStrike(): Extension< {
557
- MARKS: "strike";
558
- COMMAND_ARGS: {
559
- toggleStrike: [];
590
+ Nodes: any;
591
+ Marks: any;
592
+ Commands: {
593
+ [x: string]: any;
560
594
  };
561
595
  }>;
562
596
 
563
597
  export declare function defineStrikeCommands(): Extension< {
564
- COMMAND_ARGS: {
598
+ Commands: {
565
599
  toggleStrike: [];
566
600
  };
601
+ Nodes: never;
602
+ Marks: never;
567
603
  }>;
568
604
 
569
- export declare function defineStrikeInputRule(): Extension<ExtensionTyping<string, string, CommandArgs>>;
605
+ export declare function defineStrikeInputRule(): Extension<any>;
570
606
 
571
- export declare function defineStrikeKeymap(): Extension<ExtensionTyping<string, string, CommandArgs>>;
607
+ export declare function defineStrikeKeymap(): Extension<any>;
572
608
 
573
609
  export declare function defineStrikeSpec(): Extension< {
574
- MARKS: "strike";
610
+ Marks: "strike";
611
+ Nodes: never;
612
+ Commands: never;
575
613
  }>;
576
614
 
577
615
  /**
578
616
  * @public
579
617
  */
580
618
  export declare function defineTable(): Extension< {
581
- NODES: "table" | "tableRow" | "tableCell" | "tableHeaderCell";
582
- COMMAND_ARGS: {
583
- insertTable: [{
584
- row: number;
585
- col: number;
586
- header: boolean;
587
- }];
588
- exitTable: [];
619
+ Nodes: any;
620
+ Marks: any;
621
+ Commands: {
622
+ [x: string]: any;
589
623
  };
590
624
  }>;
591
625
 
592
626
  declare function defineTableCellSpec(): Extension< {
593
- NODES: "tableCell";
627
+ Nodes: "tableCell";
628
+ Marks: never;
629
+ Commands: never;
594
630
  }>;
595
631
  export { defineTableCellSpec }
596
632
  export { defineTableCellSpec as defineTableCellSpec_alias_1 }
@@ -601,7 +637,7 @@ export { defineTableCellSpec as defineTableCellSpec_alias_1 }
601
637
  * @public
602
638
  */
603
639
  declare function defineTableCommands(): Extension< {
604
- COMMAND_ARGS: {
640
+ Commands: {
605
641
  insertTable: [{
606
642
  row: number;
607
643
  col: number;
@@ -609,12 +645,16 @@ header: boolean;
609
645
  }];
610
646
  exitTable: [];
611
647
  };
648
+ Nodes: never;
649
+ Marks: never;
612
650
  }>;
613
651
  export { defineTableCommands }
614
652
  export { defineTableCommands as defineTableCommands_alias_1 }
615
653
 
616
654
  declare function defineTableHeaderCellSpec(): Extension< {
617
- NODES: "tableHeaderCell";
655
+ Nodes: "tableHeaderCell";
656
+ Marks: never;
657
+ Commands: never;
618
658
  }>;
619
659
  export { defineTableHeaderCellSpec }
620
660
  export { defineTableHeaderCellSpec as defineTableHeaderCellSpec_alias_1 }
@@ -622,22 +662,56 @@ export { defineTableHeaderCellSpec as defineTableHeaderCellSpec_alias_1 }
622
662
  /**
623
663
  * @public
624
664
  */
625
- declare function defineTablePlugins(): Extension<ExtensionTyping<string, string, CommandArgs>>;
665
+ declare function defineTablePlugins(): Extension<any>;
626
666
  export { defineTablePlugins }
627
667
  export { defineTablePlugins as defineTablePlugins_alias_1 }
628
668
 
629
669
  declare function defineTableRowSpec(): Extension< {
630
- NODES: "tableRow";
670
+ Nodes: "tableRow";
671
+ Marks: never;
672
+ Commands: never;
631
673
  }>;
632
674
  export { defineTableRowSpec }
633
675
  export { defineTableRowSpec as defineTableRowSpec_alias_1 }
634
676
 
635
677
  declare function defineTableSpec(): Extension< {
636
- NODES: "table";
678
+ Nodes: "table";
679
+ Marks: never;
680
+ Commands: never;
637
681
  }>;
638
682
  export { defineTableSpec }
639
683
  export { defineTableSpec as defineTableSpec_alias_1 }
640
684
 
685
+ /**
686
+ * Adds a `textAlign` attribute to the specified nodes. This will be rendered as
687
+ * a CSS `text-align` style.
688
+ *
689
+ * @public
690
+ */
691
+ export declare function defineTextAlign(options: TextAlignOptions): Extension<{
692
+ Nodes: any;
693
+ Marks: any;
694
+ Commands: {
695
+ [x: string]: any;
696
+ };
697
+ }>;
698
+
699
+ /**
700
+ * @internal
701
+ */
702
+ export declare function defineTextAlignCommands(types: string[]): Extension<{
703
+ Commands: {
704
+ setTextAlign: [value: string | null];
705
+ };
706
+ Nodes: never;
707
+ Marks: never;
708
+ }>;
709
+
710
+ /**
711
+ * @internal
712
+ */
713
+ export declare function defineTextAlignKeymap(types: string[]): Extension<any>;
714
+
641
715
  /**
642
716
  * Defines an enter rule that replaces the matched text with a block node.
643
717
  *
@@ -676,22 +750,27 @@ export declare function defineTextBlockInputRule({ regex, type, attrs, }: {
676
750
  * @public
677
751
  */
678
752
  export declare function defineUnderline(): Extension< {
679
- MARKS: "underline";
680
- COMMAND_ARGS: {
681
- toggleUnderline: [];
753
+ Nodes: any;
754
+ Marks: any;
755
+ Commands: {
756
+ [x: string]: any;
682
757
  };
683
758
  }>;
684
759
 
685
760
  export declare function defineUnderlineCommands(): Extension< {
686
- COMMAND_ARGS: {
761
+ Commands: {
687
762
  toggleUnderline: [];
688
763
  };
764
+ Nodes: never;
765
+ Marks: never;
689
766
  }>;
690
767
 
691
- export declare function defineUnderlineKeymap(): Extension<ExtensionTyping<string, string, CommandArgs>>;
768
+ export declare function defineUnderlineKeymap(): Extension<any>;
692
769
 
693
770
  export declare function defineUnderlineSpec(): Extension< {
694
- MARKS: "underline";
771
+ Marks: "underline";
772
+ Nodes: never;
773
+ Commands: never;
695
774
  }>;
696
775
 
697
776
  /**
@@ -854,11 +933,6 @@ export declare function insertTable({ row, col, header, }: {
854
933
  header: boolean;
855
934
  }): Command;
856
935
 
857
- /**
858
- * @deprecated Use `isApple` from `@prosekit/core`
859
- */
860
- export declare const isApple: boolean;
861
-
862
936
  export declare const LINK_ENTER_RE: RegExp;
863
937
 
864
938
  export declare const LINK_INPUT_RE: RegExp;
@@ -967,8 +1041,33 @@ export declare interface PredictionPluginState {
967
1041
  } | null;
968
1042
  }
969
1043
 
1044
+ /**
1045
+ * @internal
1046
+ */
1047
+ export declare function setTextAlign({ types, value, }: {
1048
+ types: string[];
1049
+ value: string | null;
1050
+ }): Command;
1051
+
970
1052
  export declare function setTrMeta(tr: Transaction, meta: PredictionPluginState): Transaction;
971
1053
 
1054
+ export declare interface TextAlignOptions {
1055
+ /**
1056
+ * The names of node to add the attribute to.
1057
+ *
1058
+ * @example
1059
+ *
1060
+ * ["paragraph", "heading"]
1061
+ */
1062
+ types: string[];
1063
+ /**
1064
+ * The default value for the attribute.
1065
+ *
1066
+ * @default "left"
1067
+ */
1068
+ default?: string;
1069
+ }
1070
+
972
1071
  /**
973
1072
  * Options for {@link defineTextBlockEnterRule}.
974
1073
  *
@@ -1,7 +1,8 @@
1
1
  // src/enter-rule/index.ts
2
2
  import {
3
- Facet,
4
3
  OBJECT_REPLACEMENT_CHARACTER,
4
+ defineFacet,
5
+ defineFacetPayload,
5
6
  getNodeType,
6
7
  isTextSelection,
7
8
  maybeRun,
@@ -9,7 +10,8 @@ import {
9
10
  } from "@prosekit/core";
10
11
  import { keydownHandler } from "@prosekit/pm/keymap";
11
12
  import {
12
- ProseMirrorPlugin
13
+ ProseMirrorPlugin,
14
+ PluginKey
13
15
  } from "@prosekit/pm/state";
14
16
  function defineEnterRule({
15
17
  regex,
@@ -17,7 +19,7 @@ function defineEnterRule({
17
19
  stop = false
18
20
  }) {
19
21
  const rule = new EnterRule(regex, handler, stop);
20
- return enterRule.extension([rule]);
22
+ return defineFacetPayload(enterRule, [rule]);
21
23
  }
22
24
  function defineTextBlockEnterRule({
23
25
  regex,
@@ -46,8 +48,8 @@ var EnterRule = class {
46
48
  this.stop = stop;
47
49
  }
48
50
  };
49
- var enterRule = Facet.define({
50
- converter: () => {
51
+ var enterRule = defineFacet({
52
+ reduce: () => {
51
53
  let rules = [];
52
54
  const command = (state, dispatch, view) => {
53
55
  if (!view)
@@ -55,20 +57,16 @@ var enterRule = Facet.define({
55
57
  return execRules(view, rules, dispatch);
56
58
  };
57
59
  const handler = keydownHandler({ Enter: command });
58
- const plugin = new ProseMirrorPlugin({ props: { handleKeyDown: handler } });
59
- const pluginFunc = () => [plugin];
60
- return {
61
- create: (inputs) => {
62
- rules = inputs;
63
- return pluginFunc;
64
- },
65
- update: (inputs) => {
66
- rules = inputs;
67
- return null;
68
- }
60
+ const plugin = new ProseMirrorPlugin({
61
+ key: new PluginKey("prosekit-enter-rule"),
62
+ props: { handleKeyDown: handler }
63
+ });
64
+ return function reducer(inputs) {
65
+ rules = inputs;
66
+ return plugin;
69
67
  };
70
68
  },
71
- next: pluginFacet
69
+ parent: pluginFacet
72
70
  });
73
71
  function execRules(view, rules, dispatch) {
74
72
  if (view.composing)
@@ -1,6 +1,7 @@
1
1
  // src/input-rule/index.ts
2
2
  import {
3
- Facet,
3
+ defineFacet,
4
+ defineFacetPayload,
4
5
  getMarkType,
5
6
  getNodeType,
6
7
  isMarkAbsent,
@@ -16,7 +17,7 @@ import {
16
17
  import "@prosekit/pm/model";
17
18
  import "@prosekit/pm/state";
18
19
  function defineInputRule(rule) {
19
- return inputRuleFacet.extension([() => rule]);
20
+ return defineFacetPayload(inputRuleFacet, [() => rule]);
20
21
  }
21
22
  function createMarkInputRule({
22
23
  regex,
@@ -61,7 +62,7 @@ function defineTextBlockInputRule({
61
62
  type,
62
63
  attrs
63
64
  }) {
64
- return inputRuleFacet.extension([
65
+ return defineFacetPayload(inputRuleFacet, [
65
66
  ({ schema }) => {
66
67
  const nodeType = getNodeType(schema, type);
67
68
  return textblockTypeInputRule(regex, nodeType, attrs);
@@ -74,21 +75,21 @@ function defineWrappingInputRule({
74
75
  attrs,
75
76
  join
76
77
  }) {
77
- return inputRuleFacet.extension([
78
+ return defineFacetPayload(inputRuleFacet, [
78
79
  ({ schema }) => {
79
80
  const nodeType = getNodeType(schema, type);
80
81
  return wrappingInputRule(regex, nodeType, attrs, join);
81
82
  }
82
83
  ]);
83
84
  }
84
- var inputRuleFacet = Facet.define({
85
- convert: (inputs) => {
85
+ var inputRuleFacet = defineFacet({
86
+ reducer: (inputs) => {
86
87
  return (context) => {
87
88
  const rules = inputs.flatMap((callback) => callback(context));
88
89
  return [inputRules({ rules })];
89
90
  };
90
91
  },
91
- next: pluginFacet
92
+ parent: pluginFacet
92
93
  });
93
94
 
94
95
  export {
@@ -1,6 +1,13 @@
1
1
  // src/mark-rule/extension.ts
2
- import { Facet, pluginFacet } from "@prosekit/core";
3
- import { ProseMirrorPlugin } from "@prosekit/pm/state";
2
+ import {
3
+ defineFacet,
4
+ defineFacetPayload,
5
+ pluginFacet
6
+ } from "@prosekit/core";
7
+ import {
8
+ PluginKey,
9
+ ProseMirrorPlugin
10
+ } from "@prosekit/pm/state";
4
11
 
5
12
  // src/mark-rule/apply.ts
6
13
  import {
@@ -158,29 +165,23 @@ function applyMarkRules(rules, transactions, oldState, newState) {
158
165
 
159
166
  // src/mark-rule/extension.ts
160
167
  function defineMarkRule(options) {
161
- return markRuleFacet.extension([options]);
168
+ return defineFacetPayload(markRuleFacet, [options]);
162
169
  }
163
- var markRuleFacet = Facet.define({
164
- converter: () => {
170
+ var markRuleFacet = defineFacet({
171
+ reduce: () => {
165
172
  let rules = [];
166
173
  const plugin = new ProseMirrorPlugin({
174
+ key: new PluginKey("prosekit-mark-rule"),
167
175
  appendTransaction: (transactions, oldState, newState) => {
168
176
  return applyMarkRules(rules, transactions, oldState, newState);
169
177
  }
170
178
  });
171
- const pluginFunc = () => [plugin];
172
- return {
173
- create: (inputs) => {
174
- rules = inputs;
175
- return pluginFunc;
176
- },
177
- update: (inputs) => {
178
- rules = inputs;
179
- return null;
180
- }
179
+ return function reducer(input) {
180
+ rules = input;
181
+ return plugin;
181
182
  };
182
183
  },
183
- next: pluginFacet
184
+ parent: pluginFacet
184
185
  });
185
186
 
186
187
  export {
@@ -1,6 +1,7 @@
1
1
  // src/autocomplete/index.ts
2
2
  import {
3
- Facet,
3
+ defineFacet,
4
+ defineFacetPayload,
4
5
  pluginFacet
5
6
  } from "@prosekit/core";
6
7
 
@@ -170,25 +171,20 @@ var AutocompleteRule = class {
170
171
 
171
172
  // src/autocomplete/index.ts
172
173
  function defineAutocomplete(rule) {
173
- return autocompleteFacet.extension([rule]);
174
+ return defineFacetPayload(autocompleteFacet, [rule]);
174
175
  }
175
- var autocompleteFacet = Facet.define({
176
- converter: () => {
177
- let localRules = [];
178
- const getRules = () => localRules;
179
- return {
180
- create: (rules) => {
181
- localRules = rules;
182
- const plugin = createAutocompletePlugin({ getRules });
183
- return () => [plugin];
184
- },
185
- update: (rules) => {
186
- localRules = rules;
187
- return null;
188
- }
176
+ var autocompleteFacet = defineFacet({
177
+ reduce: () => {
178
+ let rules = [];
179
+ const getRules = () => rules;
180
+ const plugin = createAutocompletePlugin({ getRules });
181
+ return function reducer(inputs) {
182
+ rules = inputs;
183
+ return plugin;
189
184
  };
190
185
  },
191
- next: pluginFacet
186
+ parent: pluginFacet,
187
+ singleton: true
192
188
  });
193
189
  export {
194
190
  AutocompleteRule,
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  defineWrappingInputRule
3
- } from "./chunk-CJ3SOSL6.js";
3
+ } from "./chunk-LVMTQOWG.js";
4
4
 
5
5
  // src/blockquote/index.ts
6
6
  import { defineNodeSpec, union } from "@prosekit/core";
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  defineMarkInputRule
3
- } from "./chunk-CJ3SOSL6.js";
3
+ } from "./chunk-LVMTQOWG.js";
4
4
 
5
5
  // src/bold/index.ts
6
6
  import {
@@ -1,9 +1,9 @@
1
1
  import {
2
2
  defineTextBlockInputRule
3
- } from "./chunk-CJ3SOSL6.js";
3
+ } from "./chunk-LVMTQOWG.js";
4
4
  import {
5
5
  defineTextBlockEnterRule
6
- } from "./chunk-HLBUHIMJ.js";
6
+ } from "./chunk-DZAKXWWF.js";
7
7
 
8
8
  // src/code-block/code-block.ts
9
9
  import { union } from "@prosekit/core";
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  defineMarkInputRule
3
- } from "./chunk-CJ3SOSL6.js";
3
+ } from "./chunk-LVMTQOWG.js";
4
4
 
5
5
  // src/code/index.ts
6
6
  import {
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  defineEnterRule,
3
3
  defineTextBlockEnterRule
4
- } from "./chunk-HLBUHIMJ.js";
4
+ } from "./chunk-DZAKXWWF.js";
5
5
  export {
6
6
  defineEnterRule,
7
7
  defineTextBlockEnterRule
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  defineTextBlockInputRule
3
- } from "./chunk-CJ3SOSL6.js";
3
+ } from "./chunk-LVMTQOWG.js";
4
4
 
5
5
  // src/heading/index.ts
6
6
  import {
@@ -4,7 +4,7 @@ import {
4
4
  defineMarkInputRule,
5
5
  defineTextBlockInputRule,
6
6
  defineWrappingInputRule
7
- } from "./chunk-CJ3SOSL6.js";
7
+ } from "./chunk-LVMTQOWG.js";
8
8
  export {
9
9
  createMarkInputRule,
10
10
  defineInputRule,
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  defineMarkInputRule
3
- } from "./chunk-CJ3SOSL6.js";
3
+ } from "./chunk-LVMTQOWG.js";
4
4
 
5
5
  // src/italic/index.ts
6
6
  import {
@@ -1,12 +1,12 @@
1
1
  import {
2
2
  defineMarkRule
3
- } from "./chunk-7G7COECS.js";
3
+ } from "./chunk-ZOBSD7ZH.js";
4
4
  import {
5
5
  defineInputRule
6
- } from "./chunk-CJ3SOSL6.js";
6
+ } from "./chunk-LVMTQOWG.js";
7
7
  import {
8
8
  defineEnterRule
9
- } from "./chunk-HLBUHIMJ.js";
9
+ } from "./chunk-DZAKXWWF.js";
10
10
 
11
11
  // src/link/index.ts
12
12
  import {
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  defineInputRule
3
- } from "./chunk-CJ3SOSL6.js";
3
+ } from "./chunk-LVMTQOWG.js";
4
4
 
5
5
  // src/list/index.ts
6
6
  import {
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  defineMarkRule
3
- } from "./chunk-7G7COECS.js";
3
+ } from "./chunk-ZOBSD7ZH.js";
4
4
  export {
5
5
  defineMarkRule
6
6
  };
@@ -1,11 +1,6 @@
1
1
  // src/mod-click-prevention/index.ts
2
- import { definePlugin } from "@prosekit/core";
2
+ import { definePlugin, isApple } from "@prosekit/core";
3
3
  import { Plugin, PluginKey } from "@prosekit/pm/state";
4
-
5
- // src/mod-click-prevention/env.ts
6
- var isApple = typeof navigator !== "undefined" ? /Mac|iP(hone|[ao]d)/.test(navigator.platform) : false;
7
-
8
- // src/mod-click-prevention/index.ts
9
4
  function defineModClickPrevention() {
10
5
  return definePlugin(new Plugin({ key, props: { handleClick } }));
11
6
  }
@@ -8,7 +8,7 @@ function definePlaceholder(options) {
8
8
  }
9
9
  function createPlaceholderPlugin(options) {
10
10
  return new Plugin({
11
- key: placeholderPluginKey,
11
+ key: new PluginKey("prosekit-placeholder"),
12
12
  props: {
13
13
  decorations: (state) => {
14
14
  if (options.strategy === "doc" && !isDocEmpty(state.doc)) {
@@ -27,7 +27,6 @@ function createPlaceholderPlugin(options) {
27
27
  }
28
28
  });
29
29
  }
30
- var placeholderPluginKey = new PluginKey("prosekit-placeholder");
31
30
  function isDocEmpty(doc) {
32
31
  var _a;
33
32
  return doc.childCount <= 1 && !((_a = doc.firstChild) == null ? void 0 : _a.content.size);
@@ -4,9 +4,8 @@ import { PluginKey, ProseMirrorPlugin } from "@prosekit/pm/state";
4
4
  function defineReadonly() {
5
5
  return definePlugin(plugin);
6
6
  }
7
- var key = new PluginKey("readonly");
8
7
  var plugin = new ProseMirrorPlugin({
9
- key,
8
+ key: new PluginKey("prosekey-readonly"),
10
9
  props: {
11
10
  editable: () => false
12
11
  }
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  defineMarkInputRule
3
- } from "./chunk-CJ3SOSL6.js";
3
+ } from "./chunk-LVMTQOWG.js";
4
4
 
5
5
  // src/strike/index.ts
6
6
  import {
@@ -0,0 +1,5 @@
1
+ export { setTextAlign } from './_tsup-dts-rollup';
2
+ export { defineTextAlignCommands } from './_tsup-dts-rollup';
3
+ export { defineTextAlignKeymap } from './_tsup-dts-rollup';
4
+ export { defineTextAlign } from './_tsup-dts-rollup';
5
+ export { TextAlignOptions } from './_tsup-dts-rollup';
@@ -0,0 +1,55 @@
1
+ // src/text-align/index.ts
2
+ import {
3
+ defineCommands,
4
+ defineKeymap,
5
+ defineNodeAttr,
6
+ setNodeAttrs,
7
+ union
8
+ } from "@prosekit/core";
9
+ function defineTextAlignAttr(type, defaultValue) {
10
+ return defineNodeAttr({
11
+ type,
12
+ attr: "textAlign",
13
+ default: defaultValue,
14
+ splittable: true,
15
+ toDOM: (value) => value ? ["style", `text-align:${value};`] : null,
16
+ parseDOM: (node) => {
17
+ return node.style.getPropertyValue("text-align") || null;
18
+ }
19
+ });
20
+ }
21
+ function defineTextAlignAttrs(types, defaultValue) {
22
+ return union(types.map((type) => defineTextAlignAttr(type, defaultValue)));
23
+ }
24
+ function setTextAlign({
25
+ types,
26
+ value
27
+ }) {
28
+ return setNodeAttrs({ type: types, attrs: { textAlign: value } });
29
+ }
30
+ function defineTextAlignCommands(types) {
31
+ return defineCommands({
32
+ setTextAlign: (value) => setTextAlign({ types, value })
33
+ });
34
+ }
35
+ function defineTextAlignKeymap(types) {
36
+ return defineKeymap({
37
+ "mod-shift-l": setTextAlign({ types, value: "left" }),
38
+ "mod-shift-e": setTextAlign({ types, value: "center" }),
39
+ "mod-shift-r": setTextAlign({ types, value: "right" }),
40
+ "mod-shift-j": setTextAlign({ types, value: "justify" })
41
+ });
42
+ }
43
+ function defineTextAlign(options) {
44
+ return union([
45
+ defineTextAlignAttrs(options.types, options.default || "left"),
46
+ defineTextAlignKeymap(options.types),
47
+ defineTextAlignCommands(options.types)
48
+ ]);
49
+ }
50
+ export {
51
+ defineTextAlign,
52
+ defineTextAlignCommands,
53
+ defineTextAlignKeymap,
54
+ setTextAlign
55
+ };
@@ -1,6 +1,6 @@
1
1
  /* src/virtual-selection/style.css */
2
2
  .prosekit-virtual-selection {
3
- background-color: Highlight;
4
- box-shadow: 0 0 0 3px Highlight;
3
+ background-color: #8888884d;
4
+ box-shadow: 0 0 0 2px #8888884d;
5
5
  border-radius: 2px;
6
6
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@prosekit/extensions",
3
3
  "type": "module",
4
- "version": "0.4.7",
4
+ "version": "0.5.1",
5
5
  "private": false,
6
6
  "author": {
7
7
  "name": "ocavue",
@@ -139,6 +139,11 @@
139
139
  "./table/style.css": {
140
140
  "default": "./dist/table/style.css"
141
141
  },
142
+ "./text-align": {
143
+ "types": "./dist/prosekit-extensions-text-align.d.ts",
144
+ "import": "./dist/prosekit-extensions-text-align.js",
145
+ "default": "./dist/prosekit-extensions-text-align.js"
146
+ },
142
147
  "./underline": {
143
148
  "types": "./dist/prosekit-extensions-underline.d.ts",
144
149
  "import": "./dist/prosekit-extensions-underline.js",
@@ -157,19 +162,19 @@
157
162
  "dist"
158
163
  ],
159
164
  "dependencies": {
160
- "@prosekit/core": "^0.4.2",
161
- "@prosekit/pm": "^0.1.3",
165
+ "@prosekit/core": "^0.5.2",
166
+ "@prosekit/pm": "^0.1.4",
162
167
  "prosemirror-dropcursor": "^1.8.1",
163
168
  "prosemirror-flat-list": "^0.5.0",
164
- "prosemirror-highlight": "^0.5.0",
169
+ "prosemirror-highlight": "^0.6.0",
165
170
  "prosemirror-tables": "^1.3.7",
166
- "shiki": "^1.4.0"
171
+ "shiki": "^1.6.1"
167
172
  },
168
173
  "devDependencies": {
169
- "@prosekit/dev": "*",
170
174
  "tsup": "^8.0.2",
171
175
  "typescript": "^5.4.5",
172
- "vitest": "^1.6.0"
176
+ "vitest": "^1.6.0",
177
+ "@prosekit/dev": "0.0.0"
173
178
  },
174
179
  "scripts": {
175
180
  "build:tsup": "tsup",
@@ -241,6 +246,9 @@
241
246
  "table": [
242
247
  "./dist/prosekit-extensions-table.d.ts"
243
248
  ],
249
+ "text-align": [
250
+ "./dist/prosekit-extensions-text-align.d.ts"
251
+ ],
244
252
  "underline": [
245
253
  "./dist/prosekit-extensions-underline.d.ts"
246
254
  ],