@prosekit/extensions 0.6.0 → 0.7.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.
- package/dist/_tsup-dts-rollup.d.ts +339 -70
- package/dist/commit/style.css +8 -0
- package/dist/list/style.css +1 -1
- package/dist/prosekit-extensions-code-block.js +3 -3
- package/dist/prosekit-extensions-commit.d.ts +4 -0
- package/dist/prosekit-extensions-commit.js +160 -0
- package/dist/prosekit-extensions-link.js +3 -3
- package/package.json +19 -6
@@ -1,4 +1,5 @@
|
|
1
1
|
import { Attrs } from '@prosekit/pm/model';
|
2
|
+
import { Attrs as Attrs_2 } from 'prosemirror-model';
|
2
3
|
import { BundledLanguage } from 'shiki';
|
3
4
|
import { BundledLanguageInfo } from 'shiki';
|
4
5
|
import { bundledLanguagesInfo } from 'shiki';
|
@@ -7,23 +8,35 @@ import { BundledThemeInfo } from 'shiki';
|
|
7
8
|
import { bundledThemesInfo } from 'shiki';
|
8
9
|
import { Command } from '@prosekit/pm/state';
|
9
10
|
import { DedentListOptions } from 'prosemirror-flat-list';
|
11
|
+
import { config as default_alias_1 } from '@prosekit/dev/config-vitest';
|
10
12
|
import { EditorState } from '@prosekit/pm/state';
|
11
13
|
import { Extension } from '@prosekit/core';
|
14
|
+
import { ExtensionTyping } from '@prosekit/core';
|
15
|
+
import { ExtractMarks } from '@prosekit/core';
|
16
|
+
import { ExtractNodes } from '@prosekit/core';
|
12
17
|
import { getSingletonHighlighter } from 'shiki/bundle/full';
|
13
18
|
import type { Highlighter } from 'shiki';
|
14
19
|
import { IndentListOptions } from 'prosemirror-flat-list';
|
15
20
|
import { InputRule } from '@prosekit/pm/inputrules';
|
16
21
|
import { ListAttributes } from 'prosemirror-flat-list';
|
17
22
|
import { ListDOMSerializer } from 'prosemirror-flat-list';
|
23
|
+
import { MarkBuilder } from '@prosekit/core';
|
18
24
|
import { MarkType } from '@prosekit/pm/model';
|
25
|
+
import { MarkType as MarkType_2 } from 'prosemirror-model';
|
26
|
+
import { Node as Node_2 } from 'prosemirror-model';
|
27
|
+
import { NodeBuilder } from '@prosekit/core';
|
28
|
+
import { NodeJSON } from '@prosekit/core';
|
19
29
|
import { NodeRange } from 'prosemirror-model';
|
20
30
|
import { NodeType } from '@prosekit/pm/model';
|
31
|
+
import { NodeType as NodeType_2 } from 'prosemirror-model';
|
21
32
|
import { Options } from 'tsup';
|
22
33
|
import { Parser } from 'prosemirror-highlight';
|
23
34
|
import { Plugin as Plugin_2 } from '@prosekit/pm/state';
|
24
35
|
import { PluginKey } from '@prosekit/pm/state';
|
25
36
|
import { ProseMirrorNode } from '@prosekit/pm/model';
|
26
37
|
import type { SpecialLanguage } from 'shiki';
|
38
|
+
import { StepJSON } from '@prosekit/core';
|
39
|
+
import { TestEditor } from '@prosekit/core/test';
|
27
40
|
import { ToggleCollapsedOptions } from 'prosemirror-flat-list';
|
28
41
|
import { Transaction } from '@prosekit/pm/state';
|
29
42
|
import { UnwrapListOptions } from 'prosemirror-flat-list';
|
@@ -109,6 +122,44 @@ export declare interface CodeBlockShikiOptions {
|
|
109
122
|
langAlias?: Record<string, BundledLanguage>;
|
110
123
|
}
|
111
124
|
|
125
|
+
/**
|
126
|
+
* A JSON representation of a commit.
|
127
|
+
*/
|
128
|
+
export declare interface Commit {
|
129
|
+
/**
|
130
|
+
* The current doc node in the JSON format
|
131
|
+
*/
|
132
|
+
doc: NodeJSON;
|
133
|
+
/**
|
134
|
+
* The parent node in the JSON format
|
135
|
+
*/
|
136
|
+
parent: NodeJSON;
|
137
|
+
/**
|
138
|
+
* An array of steps in the JSON format that transform the parent node to the
|
139
|
+
* current doc node.
|
140
|
+
*/
|
141
|
+
steps: StepJSON[];
|
142
|
+
}
|
143
|
+
|
144
|
+
export declare class CommitRecorder {
|
145
|
+
private parent;
|
146
|
+
private doc;
|
147
|
+
private steps;
|
148
|
+
/**
|
149
|
+
* Return a commit object including all changes since the last commit. `null`
|
150
|
+
* will be returned if there is no change.
|
151
|
+
*/
|
152
|
+
commit(): Commit | null;
|
153
|
+
/**
|
154
|
+
* @internal
|
155
|
+
*/
|
156
|
+
init(doc: ProseMirrorNode): void;
|
157
|
+
/**
|
158
|
+
* @internal
|
159
|
+
*/
|
160
|
+
apply(tr: Transaction): void;
|
161
|
+
}
|
162
|
+
|
112
163
|
export declare function createAutocompletePlugin({ getRules, }: {
|
113
164
|
getRules: () => AutocompleteRule[];
|
114
165
|
}): Plugin_2;
|
@@ -125,11 +176,7 @@ export declare function createMarkInputRule({ regex, type, attrs, }: MarkInputRu
|
|
125
176
|
|
126
177
|
export declare const default_alias: Options | Options[] | ((overrideOptions: Options) => Options | Options[] | Promise<Options | Options[]>);
|
127
178
|
|
128
|
-
export
|
129
|
-
test: {
|
130
|
-
environment: "jsdom";
|
131
|
-
};
|
132
|
-
};
|
179
|
+
export { default_alias_1 }
|
133
180
|
|
134
181
|
export declare function defaultCanMatch({ state }: {
|
135
182
|
state: EditorState;
|
@@ -141,18 +188,16 @@ export declare function defineAutocomplete(rule: AutocompleteRule): Extension;
|
|
141
188
|
* @public
|
142
189
|
*/
|
143
190
|
export declare function defineBlockquote(): Extension< {
|
144
|
-
Nodes:
|
145
|
-
Marks:
|
146
|
-
Commands:
|
147
|
-
[x: string]: any;
|
148
|
-
};
|
191
|
+
Nodes: "blockquote";
|
192
|
+
Marks: never;
|
193
|
+
Commands: never;
|
149
194
|
}>;
|
150
195
|
|
151
196
|
/**
|
152
197
|
* Wraps the text block in a blockquote when `>` is typed at the start of a new
|
153
198
|
* line followed by a space.
|
154
199
|
*/
|
155
|
-
export declare function defineBlockquoteInputRule(): Extension<any
|
200
|
+
export declare function defineBlockquoteInputRule(): Extension<ExtensionTyping<any, any, any>>;
|
156
201
|
|
157
202
|
export declare function defineBlockquoteSpec(): Extension< {
|
158
203
|
Nodes: "blockquote";
|
@@ -164,10 +209,10 @@ Commands: never;
|
|
164
209
|
* @public
|
165
210
|
*/
|
166
211
|
export declare function defineBold(): Extension< {
|
167
|
-
Nodes:
|
168
|
-
Marks:
|
212
|
+
Nodes: never;
|
213
|
+
Marks: "bold";
|
169
214
|
Commands: {
|
170
|
-
|
215
|
+
toggleBold: [];
|
171
216
|
};
|
172
217
|
}>;
|
173
218
|
|
@@ -179,9 +224,9 @@ Nodes: never;
|
|
179
224
|
Marks: never;
|
180
225
|
}>;
|
181
226
|
|
182
|
-
export declare function defineBoldInputRule(): Extension<any
|
227
|
+
export declare function defineBoldInputRule(): Extension<ExtensionTyping<any, any, any>>;
|
183
228
|
|
184
|
-
export declare function defineBoldKeymap(): Extension<any
|
229
|
+
export declare function defineBoldKeymap(): Extension<ExtensionTyping<any, any, any>>;
|
185
230
|
|
186
231
|
export declare function defineBoldSpec(): Extension< {
|
187
232
|
Marks: "bold";
|
@@ -193,10 +238,10 @@ Commands: never;
|
|
193
238
|
* @public
|
194
239
|
*/
|
195
240
|
export declare function defineCode(): Extension< {
|
196
|
-
Nodes:
|
197
|
-
Marks:
|
241
|
+
Nodes: never;
|
242
|
+
Marks: "code";
|
198
243
|
Commands: {
|
199
|
-
|
244
|
+
toggleCode: [];
|
200
245
|
};
|
201
246
|
}>;
|
202
247
|
|
@@ -212,10 +257,13 @@ Commands: {
|
|
212
257
|
* @public
|
213
258
|
*/
|
214
259
|
declare function defineCodeBlock(): Extension< {
|
215
|
-
Nodes:
|
216
|
-
Marks:
|
260
|
+
Nodes: "codeBlock";
|
261
|
+
Marks: never;
|
217
262
|
Commands: {
|
218
|
-
|
263
|
+
setCodeBlock: [attrs?: CodeBlockAttrs | undefined];
|
264
|
+
insertCodeBlock: [attrs?: CodeBlockAttrs | undefined];
|
265
|
+
toggleCodeBlock: [attrs?: CodeBlockAttrs | undefined];
|
266
|
+
setCodeBlockAttrs: [attrs: CodeBlockAttrs];
|
219
267
|
};
|
220
268
|
}>;
|
221
269
|
export { defineCodeBlock }
|
@@ -244,7 +292,7 @@ export { defineCodeBlockCommands as defineCodeBlockCommands_alias_1 }
|
|
244
292
|
*
|
245
293
|
* @public
|
246
294
|
*/
|
247
|
-
declare function defineCodeBlockEnterRule(): Extension<any
|
295
|
+
declare function defineCodeBlockEnterRule(): Extension<ExtensionTyping<any, any, any>>;
|
248
296
|
export { defineCodeBlockEnterRule }
|
249
297
|
export { defineCodeBlockEnterRule as defineCodeBlockEnterRule_alias_1 }
|
250
298
|
|
@@ -267,14 +315,14 @@ export { defineCodeBlockHighlight as defineCodeBlockHighlight_alias_1 }
|
|
267
315
|
*
|
268
316
|
* @public
|
269
317
|
*/
|
270
|
-
declare function defineCodeBlockInputRule(): Extension<any
|
318
|
+
declare function defineCodeBlockInputRule(): Extension<ExtensionTyping<any, any, any>>;
|
271
319
|
export { defineCodeBlockInputRule }
|
272
320
|
export { defineCodeBlockInputRule as defineCodeBlockInputRule_alias_1 }
|
273
321
|
|
274
322
|
/**
|
275
323
|
* Defines the keymap for code blocks.
|
276
324
|
*/
|
277
|
-
export declare function defineCodeBlockKeymap(): Extension<any
|
325
|
+
export declare function defineCodeBlockKeymap(): Extension<ExtensionTyping<any, any, any>>;
|
278
326
|
|
279
327
|
/**
|
280
328
|
* Adds syntax highlighting to code blocks using the [shiki](https://github.com/shikijs/shiki) package.
|
@@ -306,9 +354,9 @@ Nodes: never;
|
|
306
354
|
Marks: never;
|
307
355
|
}>;
|
308
356
|
|
309
|
-
export declare function defineCodeInputRule(): Extension<any
|
357
|
+
export declare function defineCodeInputRule(): Extension<ExtensionTyping<any, any, any>>;
|
310
358
|
|
311
|
-
export declare function defineCodeKeymap(): Extension<any
|
359
|
+
export declare function defineCodeKeymap(): Extension<ExtensionTyping<any, any, any>>;
|
312
360
|
|
313
361
|
/**
|
314
362
|
* @public
|
@@ -319,6 +367,20 @@ Nodes: never;
|
|
319
367
|
Commands: never;
|
320
368
|
}>;
|
321
369
|
|
370
|
+
/**
|
371
|
+
* Define an extension that can record the changes in the editor.
|
372
|
+
*/
|
373
|
+
export declare function defineCommitRecorder(commitRecorder: CommitRecorder): Extension<ExtensionTyping<any, any, any>>;
|
374
|
+
|
375
|
+
/**
|
376
|
+
* Define an extension to display the changes from the given commit in the editor.
|
377
|
+
*/
|
378
|
+
export declare function defineCommitViewer(commit: Commit): Extension< {
|
379
|
+
Nodes: never;
|
380
|
+
Marks: never;
|
381
|
+
Commands: never;
|
382
|
+
}>;
|
383
|
+
|
322
384
|
/**
|
323
385
|
* Show up a decoration at the drop position when something is dragged over the editor.
|
324
386
|
*
|
@@ -326,7 +388,7 @@ Commands: never;
|
|
326
388
|
*
|
327
389
|
* @public
|
328
390
|
*/
|
329
|
-
export declare function defineDropCursor(options?: DropCursorOptions): Extension<any
|
391
|
+
export declare function defineDropCursor(options?: DropCursorOptions): Extension<ExtensionTyping<any, any, any>>;
|
330
392
|
|
331
393
|
/**
|
332
394
|
* Defines an enter rule. An enter rule applies when the text directly in front of
|
@@ -341,10 +403,12 @@ export declare function defineEnterRule({ regex, handler, stop, }: EnterRuleOpti
|
|
341
403
|
* @public
|
342
404
|
*/
|
343
405
|
export declare function defineHeading(): Extension< {
|
344
|
-
Nodes:
|
345
|
-
Marks:
|
406
|
+
Nodes: "heading";
|
407
|
+
Marks: never;
|
346
408
|
Commands: {
|
347
|
-
|
409
|
+
setHeading: [attrs?: HeadingAttrs | undefined];
|
410
|
+
insertHeading: [attrs?: HeadingAttrs | undefined];
|
411
|
+
toggleHeading: [attrs?: HeadingAttrs | undefined];
|
348
412
|
};
|
349
413
|
}>;
|
350
414
|
|
@@ -362,9 +426,9 @@ Marks: never;
|
|
362
426
|
* Converts the text block to a heading when `#` is typed at the start of a new
|
363
427
|
* line followed by a space.
|
364
428
|
*/
|
365
|
-
export declare function defineHeadingInputRule(): Extension<any
|
429
|
+
export declare function defineHeadingInputRule(): Extension<ExtensionTyping<any, any, any>>;
|
366
430
|
|
367
|
-
export declare function defineHeadingKeymap(): Extension<any
|
431
|
+
export declare function defineHeadingKeymap(): Extension<ExtensionTyping<any, any, any>>;
|
368
432
|
|
369
433
|
export declare function defineHeadingSpec(): Extension< {
|
370
434
|
Nodes: "heading";
|
@@ -410,10 +474,10 @@ export declare function defineInputRule(rule: InputRule): Extension;
|
|
410
474
|
* @public
|
411
475
|
*/
|
412
476
|
export declare function defineItalic(): Extension< {
|
413
|
-
Nodes:
|
414
|
-
Marks:
|
477
|
+
Nodes: never;
|
478
|
+
Marks: "italic";
|
415
479
|
Commands: {
|
416
|
-
|
480
|
+
toggleItalic: [];
|
417
481
|
};
|
418
482
|
}>;
|
419
483
|
|
@@ -425,9 +489,9 @@ Nodes: never;
|
|
425
489
|
Marks: never;
|
426
490
|
}>;
|
427
491
|
|
428
|
-
export declare function defineItalicInputRule(): Extension<any
|
492
|
+
export declare function defineItalicInputRule(): Extension<ExtensionTyping<any, any, any>>;
|
429
493
|
|
430
|
-
export declare function defineItalicKeymap(): Extension<any
|
494
|
+
export declare function defineItalicKeymap(): Extension<ExtensionTyping<any, any, any>>;
|
431
495
|
|
432
496
|
export declare function defineItalicSpec(): Extension< {
|
433
497
|
Marks: "italic";
|
@@ -439,10 +503,13 @@ Commands: never;
|
|
439
503
|
* @public
|
440
504
|
*/
|
441
505
|
export declare function defineLink(): Extension< {
|
442
|
-
Nodes:
|
443
|
-
Marks:
|
506
|
+
Nodes: never;
|
507
|
+
Marks: "link";
|
444
508
|
Commands: {
|
445
|
-
[
|
509
|
+
addLink: [attrs: LinkAttrs];
|
510
|
+
removeLink: [];
|
511
|
+
toggleLink: [attrs: LinkAttrs];
|
512
|
+
expandLink: [];
|
446
513
|
};
|
447
514
|
}>;
|
448
515
|
|
@@ -460,17 +527,17 @@ Marks: never;
|
|
460
527
|
/**
|
461
528
|
* Apply link marks after typing Enter.
|
462
529
|
*/
|
463
|
-
export declare function defineLinkEnterRule(): Extension<any
|
530
|
+
export declare function defineLinkEnterRule(): Extension<ExtensionTyping<any, any, any>>;
|
464
531
|
|
465
532
|
/**
|
466
533
|
* Apply link marks after pressing Space.
|
467
534
|
*/
|
468
|
-
export declare function defineLinkInputRule(): Extension<any
|
535
|
+
export declare function defineLinkInputRule(): Extension<ExtensionTyping<any, any, any>>;
|
469
536
|
|
470
537
|
/**
|
471
538
|
* Apply and remove link marks to the text during typing.
|
472
539
|
*/
|
473
|
-
export declare function defineLinkMarkRule(): Extension<any
|
540
|
+
export declare function defineLinkMarkRule(): Extension<ExtensionTyping<any, any, any>>;
|
474
541
|
|
475
542
|
export declare function defineLinkSpec(): Extension< {
|
476
543
|
Marks: "link";
|
@@ -482,10 +549,18 @@ Commands: never;
|
|
482
549
|
* @public
|
483
550
|
*/
|
484
551
|
export declare function defineList(): Extension<{
|
485
|
-
Nodes:
|
486
|
-
Marks:
|
552
|
+
Nodes: "list";
|
553
|
+
Marks: never;
|
487
554
|
Commands: {
|
488
|
-
|
555
|
+
dedentList: [options?: DedentListOptions | undefined];
|
556
|
+
indentList: [options?: IndentListOptions | undefined];
|
557
|
+
moveList: [direction: "up" | "down"];
|
558
|
+
splitList: [];
|
559
|
+
toggleCollapsed: [(ToggleCollapsedOptions | undefined)?];
|
560
|
+
toggleList: [attrs: ListAttributes];
|
561
|
+
unwrapList: [options?: UnwrapListOptions | undefined];
|
562
|
+
wrapInList: [getAttrs: ListAttributes | ((range: NodeRange) => ListAttributes | null)];
|
563
|
+
insertList: [attrs?: ListAttributes | undefined];
|
489
564
|
};
|
490
565
|
}>;
|
491
566
|
|
@@ -512,9 +587,9 @@ export declare function defineListInputRules(): Extension;
|
|
512
587
|
*
|
513
588
|
* @public
|
514
589
|
*/
|
515
|
-
export declare function defineListKeymap(): Extension<any
|
590
|
+
export declare function defineListKeymap(): Extension<ExtensionTyping<any, any, any>>;
|
516
591
|
|
517
|
-
export declare function defineListPlugins(): Extension<any
|
592
|
+
export declare function defineListPlugins(): Extension<ExtensionTyping<any, any, any>>;
|
518
593
|
|
519
594
|
export declare function defineListSpec(): Extension<{
|
520
595
|
Nodes: "list";
|
@@ -534,7 +609,7 @@ export declare function defineMarkInputRule(options: MarkInputRuleOptions): Exte
|
|
534
609
|
* A mark rule is something that can automatically apply marks to text if it
|
535
610
|
* matches a certain pattern, and remove them if it doesn't match anymore.
|
536
611
|
*/
|
537
|
-
declare function defineMarkRule(options: MarkRuleOptions): Extension<any
|
612
|
+
declare function defineMarkRule(options: MarkRuleOptions): Extension<ExtensionTyping<any, any, any>>;
|
538
613
|
export { defineMarkRule }
|
539
614
|
export { defineMarkRule as defineMarkRule_alias_1 }
|
540
615
|
|
@@ -578,12 +653,12 @@ export declare function defineModClickPrevention(): Extension;
|
|
578
653
|
* Add a placeholder text to the editor when the current block or document is
|
579
654
|
* empty.
|
580
655
|
*/
|
581
|
-
export declare function definePlaceholder(options: PlaceholderOptions): Extension<any
|
656
|
+
export declare function definePlaceholder(options: PlaceholderOptions): Extension<ExtensionTyping<any, any, any>>;
|
582
657
|
|
583
658
|
/**
|
584
659
|
* Make the editor read-only.
|
585
660
|
*/
|
586
|
-
export declare function defineReadonly(): Extension<any
|
661
|
+
export declare function defineReadonly(): Extension<ExtensionTyping<any, any, any>>;
|
587
662
|
|
588
663
|
/**
|
589
664
|
* Defines commands for search and replace.
|
@@ -610,16 +685,16 @@ Marks: never;
|
|
610
685
|
*
|
611
686
|
* @public
|
612
687
|
*/
|
613
|
-
export declare function defineSearchQuery(options: SearchQueryOptions): Extension<any
|
688
|
+
export declare function defineSearchQuery(options: SearchQueryOptions): Extension<ExtensionTyping<any, any, any>>;
|
614
689
|
|
615
690
|
/**
|
616
691
|
* @public
|
617
692
|
*/
|
618
693
|
export declare function defineStrike(): Extension< {
|
619
|
-
Nodes:
|
620
|
-
Marks:
|
694
|
+
Nodes: never;
|
695
|
+
Marks: "strike";
|
621
696
|
Commands: {
|
622
|
-
|
697
|
+
toggleStrike: [];
|
623
698
|
};
|
624
699
|
}>;
|
625
700
|
|
@@ -631,9 +706,9 @@ Nodes: never;
|
|
631
706
|
Marks: never;
|
632
707
|
}>;
|
633
708
|
|
634
|
-
export declare function defineStrikeInputRule(): Extension<any
|
709
|
+
export declare function defineStrikeInputRule(): Extension<ExtensionTyping<any, any, any>>;
|
635
710
|
|
636
|
-
export declare function defineStrikeKeymap(): Extension<any
|
711
|
+
export declare function defineStrikeKeymap(): Extension<ExtensionTyping<any, any, any>>;
|
637
712
|
|
638
713
|
export declare function defineStrikeSpec(): Extension< {
|
639
714
|
Marks: "strike";
|
@@ -645,10 +720,15 @@ Commands: never;
|
|
645
720
|
* @public
|
646
721
|
*/
|
647
722
|
export declare function defineTable(): Extension< {
|
648
|
-
Nodes:
|
649
|
-
Marks:
|
723
|
+
Nodes: "table" | "tableRow" | "tableCell" | "tableHeaderCell";
|
724
|
+
Marks: never;
|
650
725
|
Commands: {
|
651
|
-
|
726
|
+
insertTable: [{
|
727
|
+
row: number;
|
728
|
+
col: number;
|
729
|
+
header: boolean;
|
730
|
+
}];
|
731
|
+
exitTable: [];
|
652
732
|
};
|
653
733
|
}>;
|
654
734
|
|
@@ -691,7 +771,7 @@ export { defineTableHeaderCellSpec as defineTableHeaderCellSpec_alias_1 }
|
|
691
771
|
/**
|
692
772
|
* @public
|
693
773
|
*/
|
694
|
-
declare function defineTablePlugins(): Extension<any
|
774
|
+
declare function defineTablePlugins(): Extension<ExtensionTyping<any, any, any>>;
|
695
775
|
export { defineTablePlugins }
|
696
776
|
export { defineTablePlugins as defineTablePlugins_alias_1 }
|
697
777
|
|
@@ -711,6 +791,94 @@ Commands: never;
|
|
711
791
|
export { defineTableSpec }
|
712
792
|
export { defineTableSpec as defineTableSpec_alias_1 }
|
713
793
|
|
794
|
+
/**
|
795
|
+
* @internal
|
796
|
+
*/
|
797
|
+
export declare function defineTestExtension(): Extension<{
|
798
|
+
Nodes: "blockquote" | "table" | "text" | "doc" | "paragraph" | "heading" | "image" | "list" | "tableRow" | "tableCell" | "tableHeaderCell";
|
799
|
+
Marks: "code" | "link" | "bold" | "strike" | "italic" | "underline";
|
800
|
+
Commands: {
|
801
|
+
insertText: [{
|
802
|
+
text: string;
|
803
|
+
from?: number;
|
804
|
+
to?: number;
|
805
|
+
}];
|
806
|
+
insertNode: [options: {
|
807
|
+
node: Node_2;
|
808
|
+
pos?: number;
|
809
|
+
type?: undefined;
|
810
|
+
attrs?: undefined;
|
811
|
+
} | {
|
812
|
+
node?: undefined;
|
813
|
+
pos?: number;
|
814
|
+
type: string;
|
815
|
+
attrs?: Attrs_2;
|
816
|
+
}];
|
817
|
+
removeNode: [options: {
|
818
|
+
type: string | NodeType_2;
|
819
|
+
pos?: number;
|
820
|
+
}];
|
821
|
+
wrap: [{
|
822
|
+
nodeType: NodeType_2;
|
823
|
+
attrs?: Attrs_2 | null;
|
824
|
+
}];
|
825
|
+
setBlockType: [options: {
|
826
|
+
type: NodeType_2 | string;
|
827
|
+
attrs?: Attrs_2 | null;
|
828
|
+
from?: number;
|
829
|
+
to?: number;
|
830
|
+
}];
|
831
|
+
setNodeAttrs: [options: {
|
832
|
+
type: string | NodeType_2 | string[] | NodeType_2[];
|
833
|
+
attrs: Attrs_2;
|
834
|
+
pos?: number;
|
835
|
+
}];
|
836
|
+
selectAll: [];
|
837
|
+
addMark: [options: {
|
838
|
+
type: string | MarkType_2;
|
839
|
+
attrs?: Attrs_2 | null;
|
840
|
+
from?: number;
|
841
|
+
to?: number;
|
842
|
+
}];
|
843
|
+
removeMark: [options: {
|
844
|
+
type: string | MarkType_2;
|
845
|
+
attrs?: Attrs_2 | null;
|
846
|
+
from?: number;
|
847
|
+
to?: number;
|
848
|
+
}];
|
849
|
+
toggleItalic: [];
|
850
|
+
undo: [];
|
851
|
+
redo: [];
|
852
|
+
toggleBold: [];
|
853
|
+
toggleCode: [];
|
854
|
+
setHeading: [attrs?: HeadingAttrs | undefined];
|
855
|
+
insertHeading: [attrs?: HeadingAttrs | undefined];
|
856
|
+
toggleHeading: [attrs?: HeadingAttrs | undefined];
|
857
|
+
insertImage: [attrs?: ImageAttrs | undefined];
|
858
|
+
addLink: [attrs: LinkAttrs];
|
859
|
+
removeLink: [];
|
860
|
+
toggleLink: [attrs: LinkAttrs];
|
861
|
+
expandLink: [];
|
862
|
+
dedentList: [options?: DedentListOptions | undefined];
|
863
|
+
indentList: [options?: IndentListOptions | undefined];
|
864
|
+
moveList: [direction: "up" | "down"];
|
865
|
+
splitList: [];
|
866
|
+
toggleCollapsed: [(ToggleCollapsedOptions | undefined)?];
|
867
|
+
toggleList: [attrs: ListAttributes];
|
868
|
+
unwrapList: [options?: UnwrapListOptions | undefined];
|
869
|
+
wrapInList: [getAttrs: ListAttributes | ((range: NodeRange) => ListAttributes | null)];
|
870
|
+
insertList: [attrs?: ListAttributes | undefined];
|
871
|
+
toggleStrike: [];
|
872
|
+
insertTable: [{
|
873
|
+
row: number;
|
874
|
+
col: number;
|
875
|
+
header: boolean;
|
876
|
+
}];
|
877
|
+
exitTable: [];
|
878
|
+
toggleUnderline: [];
|
879
|
+
};
|
880
|
+
}>;
|
881
|
+
|
714
882
|
/**
|
715
883
|
* Adds a `textAlign` attribute to the specified nodes. This will be rendered as
|
716
884
|
* a CSS `text-align` style.
|
@@ -718,10 +886,10 @@ export { defineTableSpec as defineTableSpec_alias_1 }
|
|
718
886
|
* @public
|
719
887
|
*/
|
720
888
|
export declare function defineTextAlign(options: TextAlignOptions): Extension<{
|
721
|
-
Nodes:
|
722
|
-
Marks:
|
889
|
+
Nodes: never;
|
890
|
+
Marks: never;
|
723
891
|
Commands: {
|
724
|
-
[
|
892
|
+
setTextAlign: [value: string | null];
|
725
893
|
};
|
726
894
|
}>;
|
727
895
|
|
@@ -739,7 +907,7 @@ export declare function defineTextAlignCommands(types: string[]): Extension<{
|
|
739
907
|
/**
|
740
908
|
* @internal
|
741
909
|
*/
|
742
|
-
export declare function defineTextAlignKeymap(types: string[]): Extension<any
|
910
|
+
export declare function defineTextAlignKeymap(types: string[]): Extension<ExtensionTyping<any, any, any>>;
|
743
911
|
|
744
912
|
/**
|
745
913
|
* Defines an enter rule that replaces the matched text with a block node.
|
@@ -779,10 +947,10 @@ export declare function defineTextBlockInputRule({ regex, type, attrs, }: {
|
|
779
947
|
* @public
|
780
948
|
*/
|
781
949
|
export declare function defineUnderline(): Extension< {
|
782
|
-
Nodes:
|
783
|
-
Marks:
|
950
|
+
Nodes: never;
|
951
|
+
Marks: "underline";
|
784
952
|
Commands: {
|
785
|
-
|
953
|
+
toggleUnderline: [];
|
786
954
|
};
|
787
955
|
}>;
|
788
956
|
|
@@ -794,7 +962,7 @@ Nodes: never;
|
|
794
962
|
Marks: never;
|
795
963
|
}>;
|
796
964
|
|
797
|
-
export declare function defineUnderlineKeymap(): Extension<any
|
965
|
+
export declare function defineUnderlineKeymap(): Extension<ExtensionTyping<any, any, any>>;
|
798
966
|
|
799
967
|
export declare function defineUnderlineSpec(): Extension< {
|
800
968
|
Marks: "underline";
|
@@ -1132,6 +1300,107 @@ export declare function setTextAlign({ types, value, }: {
|
|
1132
1300
|
|
1133
1301
|
export declare function setTrMeta(tr: Transaction, meta: PredictionPluginState): Transaction;
|
1134
1302
|
|
1303
|
+
/**
|
1304
|
+
* @internal
|
1305
|
+
*/
|
1306
|
+
export declare function setupDefaultTest(): {
|
1307
|
+
editor: TestEditor<Extension<{
|
1308
|
+
Nodes: "blockquote" | "table" | "text" | "doc" | "paragraph" | "heading" | "image" | "list" | "tableRow" | "tableCell" | "tableHeaderCell";
|
1309
|
+
Marks: "code" | "link" | "bold" | "strike" | "italic" | "underline";
|
1310
|
+
Commands: {
|
1311
|
+
insertText: [{
|
1312
|
+
text: string;
|
1313
|
+
from?: number;
|
1314
|
+
to?: number;
|
1315
|
+
}];
|
1316
|
+
insertNode: [options: {
|
1317
|
+
node: Node_2;
|
1318
|
+
pos?: number;
|
1319
|
+
type?: undefined;
|
1320
|
+
attrs?: undefined;
|
1321
|
+
} | {
|
1322
|
+
node?: undefined;
|
1323
|
+
pos?: number;
|
1324
|
+
type: string;
|
1325
|
+
attrs?: Attrs_2;
|
1326
|
+
}];
|
1327
|
+
removeNode: [options: {
|
1328
|
+
type: string | NodeType_2;
|
1329
|
+
pos?: number;
|
1330
|
+
}];
|
1331
|
+
wrap: [{
|
1332
|
+
nodeType: NodeType_2;
|
1333
|
+
attrs?: Attrs_2 | null;
|
1334
|
+
}];
|
1335
|
+
setBlockType: [options: {
|
1336
|
+
type: NodeType_2 | string;
|
1337
|
+
attrs?: Attrs_2 | null;
|
1338
|
+
from?: number;
|
1339
|
+
to?: number;
|
1340
|
+
}];
|
1341
|
+
setNodeAttrs: [options: {
|
1342
|
+
type: string | NodeType_2 | string[] | NodeType_2[];
|
1343
|
+
attrs: Attrs_2;
|
1344
|
+
pos?: number;
|
1345
|
+
}];
|
1346
|
+
selectAll: [];
|
1347
|
+
addMark: [options: {
|
1348
|
+
type: string | MarkType_2;
|
1349
|
+
attrs?: Attrs_2 | null;
|
1350
|
+
from?: number;
|
1351
|
+
to?: number;
|
1352
|
+
}];
|
1353
|
+
removeMark: [options: {
|
1354
|
+
type: string | MarkType_2;
|
1355
|
+
attrs?: Attrs_2 | null;
|
1356
|
+
from?: number;
|
1357
|
+
to?: number;
|
1358
|
+
}];
|
1359
|
+
toggleItalic: [];
|
1360
|
+
undo: [];
|
1361
|
+
redo: [];
|
1362
|
+
toggleBold: [];
|
1363
|
+
toggleCode: [];
|
1364
|
+
setHeading: [attrs?: HeadingAttrs | undefined];
|
1365
|
+
insertHeading: [attrs?: HeadingAttrs | undefined];
|
1366
|
+
toggleHeading: [attrs?: HeadingAttrs | undefined];
|
1367
|
+
insertImage: [attrs?: ImageAttrs | undefined];
|
1368
|
+
addLink: [attrs: LinkAttrs];
|
1369
|
+
removeLink: [];
|
1370
|
+
toggleLink: [attrs: LinkAttrs];
|
1371
|
+
expandLink: [];
|
1372
|
+
dedentList: [options?: DedentListOptions | undefined];
|
1373
|
+
indentList: [options?: IndentListOptions | undefined];
|
1374
|
+
moveList: [direction: "up" | "down"];
|
1375
|
+
splitList: [];
|
1376
|
+
toggleCollapsed: [(ToggleCollapsedOptions | undefined)?];
|
1377
|
+
toggleList: [attrs: ListAttributes];
|
1378
|
+
unwrapList: [options?: UnwrapListOptions | undefined];
|
1379
|
+
wrapInList: [getAttrs: ListAttributes | ((range: NodeRange) => ListAttributes | null)];
|
1380
|
+
insertList: [attrs?: ListAttributes | undefined];
|
1381
|
+
toggleStrike: [];
|
1382
|
+
insertTable: [{
|
1383
|
+
row: number;
|
1384
|
+
col: number;
|
1385
|
+
header: boolean;
|
1386
|
+
}];
|
1387
|
+
exitTable: [];
|
1388
|
+
toggleUnderline: [];
|
1389
|
+
};
|
1390
|
+
}>>;
|
1391
|
+
n: Record<"blockquote" | "table" | "text" | "doc" | "paragraph" | "heading" | "image" | "list" | "tableRow" | "tableCell" | "tableHeaderCell", NodeBuilder>;
|
1392
|
+
m: Record<"code" | "link" | "bold" | "strike" | "italic" | "underline", MarkBuilder>;
|
1393
|
+
};
|
1394
|
+
|
1395
|
+
/**
|
1396
|
+
* @internal
|
1397
|
+
*/
|
1398
|
+
export declare function setupTest<E extends Extension>(extension: E): {
|
1399
|
+
editor: TestEditor<E>;
|
1400
|
+
n: Record<ExtractNodes<E>, NodeBuilder>;
|
1401
|
+
m: Record<ExtractMarks<E>, MarkBuilder>;
|
1402
|
+
};
|
1403
|
+
|
1135
1404
|
export declare interface TextAlignOptions {
|
1136
1405
|
/**
|
1137
1406
|
* The names of node to add the attribute to.
|
package/dist/list/style.css
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
/* ../../node_modules/.pnpm/prosemirror-flat-list@0.5.
|
1
|
+
/* ../../node_modules/.pnpm/prosemirror-flat-list@0.5.1/node_modules/prosemirror-flat-list/dist/style.css */
|
2
2
|
.prosemirror-flat-list {
|
3
3
|
padding: 0;
|
4
4
|
margin-top: 0;
|
@@ -1,9 +1,9 @@
|
|
1
|
-
import {
|
2
|
-
defineTextBlockInputRule
|
3
|
-
} from "./chunk-PYT3MOTF.js";
|
4
1
|
import {
|
5
2
|
defineTextBlockEnterRule
|
6
3
|
} from "./chunk-2JYT2MT7.js";
|
4
|
+
import {
|
5
|
+
defineTextBlockInputRule
|
6
|
+
} from "./chunk-PYT3MOTF.js";
|
7
7
|
|
8
8
|
// src/code-block/code-block.ts
|
9
9
|
import { union } from "@prosekit/core";
|
@@ -0,0 +1,160 @@
|
|
1
|
+
// src/commit/index.ts
|
2
|
+
import {
|
3
|
+
collectNodes,
|
4
|
+
defineDefaultState,
|
5
|
+
definePlugin,
|
6
|
+
jsonFromNode,
|
7
|
+
union
|
8
|
+
} from "@prosekit/core";
|
9
|
+
import {
|
10
|
+
DOMSerializer,
|
11
|
+
Fragment,
|
12
|
+
Slice
|
13
|
+
} from "@prosekit/pm/model";
|
14
|
+
import { PluginKey, ProseMirrorPlugin } from "@prosekit/pm/state";
|
15
|
+
import { Step } from "@prosekit/pm/transform";
|
16
|
+
import { Decoration, DecorationSet } from "@prosekit/pm/view";
|
17
|
+
import { ChangeSet } from "prosemirror-changeset";
|
18
|
+
function getChanges(doc, parent, steps) {
|
19
|
+
return ChangeSet.create(parent).addSteps(
|
20
|
+
doc,
|
21
|
+
steps.map((step) => step.getMap()),
|
22
|
+
null
|
23
|
+
).changes;
|
24
|
+
}
|
25
|
+
function renderDivWeight(view) {
|
26
|
+
return view.dom.ownerDocument.createElement("div");
|
27
|
+
}
|
28
|
+
function decorateDeletionSlice(slice) {
|
29
|
+
let { openStart, openEnd, content } = slice;
|
30
|
+
for (; openStart > 0 && openEnd > 0 && content.childCount === 1; )
|
31
|
+
openStart--, openEnd--, content = content.child(0).content;
|
32
|
+
if (content.childCount === 0)
|
33
|
+
return [];
|
34
|
+
if (openStart > 0 && openEnd > 0 && content.childCount === 2) {
|
35
|
+
let head = Fragment.from([content.child(0)]), tail = Fragment.from([content.child(1)]);
|
36
|
+
return [
|
37
|
+
...decorateDeletionSlice(new Slice(head, openStart, openStart)),
|
38
|
+
renderDivWeight,
|
39
|
+
...decorateDeletionSlice(new Slice(tail, openEnd, openEnd))
|
40
|
+
];
|
41
|
+
}
|
42
|
+
if (openStart > 0 && content.childCount >= 2) {
|
43
|
+
let nodes = collectNodes(content), head = Fragment.from(nodes.slice(0, 1)), body = Fragment.from(nodes.slice(1));
|
44
|
+
return [
|
45
|
+
...decorateDeletionSlice(new Slice(head, openStart, openStart)),
|
46
|
+
...decorateDeletionSlice(new Slice(body, 0, openEnd))
|
47
|
+
];
|
48
|
+
}
|
49
|
+
if (openEnd > 0 && content.childCount >= 2) {
|
50
|
+
let nodes = collectNodes(content), body = Fragment.from(nodes.slice(0, -1)), tail = Fragment.from(nodes.slice(-1));
|
51
|
+
return [
|
52
|
+
...decorateDeletionSlice(new Slice(body, openStart, 0)),
|
53
|
+
...decorateDeletionSlice(new Slice(tail, openEnd, openEnd))
|
54
|
+
];
|
55
|
+
}
|
56
|
+
let schema = content.child(0).type.schema, isInline = content.child(0).isInline;
|
57
|
+
return [(view) => {
|
58
|
+
let document = view.dom.ownerDocument, element = document.createElement(isInline ? "span" : "div");
|
59
|
+
return DOMSerializer.fromSchema(schema).serializeFragment(content, { document }, element), element.classList.add("prosekit-commit-deletion"), element;
|
60
|
+
}];
|
61
|
+
}
|
62
|
+
function decorateDeletion(doc, from, to, pos) {
|
63
|
+
let slice = doc.slice(from, to), renders = decorateDeletionSlice(slice), count = renders.length;
|
64
|
+
return renders.map(
|
65
|
+
(render, index) => Decoration.widget(pos, render, {
|
66
|
+
side: -20 - count + index,
|
67
|
+
// Ensure the text in the decoration is able to be selected.
|
68
|
+
ignoreSelection: !0
|
69
|
+
})
|
70
|
+
);
|
71
|
+
}
|
72
|
+
function decorateAddition(from, to) {
|
73
|
+
return Decoration.inline(from, to, { class: "prosekit-commit-addition" });
|
74
|
+
}
|
75
|
+
function decorateChange(prev, change) {
|
76
|
+
let { fromA, toA, fromB, toB } = change, decorations = [];
|
77
|
+
return fromA < toA && decorations.push(...decorateDeletion(prev, fromA, toA, fromB)), fromB < toB && decorations.push(decorateAddition(fromB, toB)), decorations;
|
78
|
+
}
|
79
|
+
function decorateCommit(doc, parent, steps) {
|
80
|
+
let decorations = getChanges(doc, parent, steps).flatMap(
|
81
|
+
(change) => decorateChange(parent, change)
|
82
|
+
);
|
83
|
+
return DecorationSet.create(doc, decorations);
|
84
|
+
}
|
85
|
+
function defineCommitDecoration(commit) {
|
86
|
+
let key = new PluginKey("prosekit-commit-decoration");
|
87
|
+
return definePlugin(({ schema }) => {
|
88
|
+
let parent = schema.nodeFromJSON(commit.parent), steps = commit.steps.map((step) => Step.fromJSON(schema, step));
|
89
|
+
return new ProseMirrorPlugin({
|
90
|
+
key,
|
91
|
+
state: {
|
92
|
+
init: (_, instance) => decorateCommit(instance.doc, parent, steps),
|
93
|
+
apply: (tr, deco) => deco.map(tr.mapping, tr.doc)
|
94
|
+
},
|
95
|
+
props: {
|
96
|
+
decorations: (state) => key.getState(state)
|
97
|
+
}
|
98
|
+
});
|
99
|
+
});
|
100
|
+
}
|
101
|
+
function defineCommitViewer(commit) {
|
102
|
+
return union([
|
103
|
+
defineDefaultState({ defaultDoc: commit.doc }),
|
104
|
+
defineCommitDecoration(commit)
|
105
|
+
]);
|
106
|
+
}
|
107
|
+
var CommitRecorder = class {
|
108
|
+
constructor() {
|
109
|
+
this.parent = null;
|
110
|
+
this.doc = null;
|
111
|
+
this.steps = [];
|
112
|
+
}
|
113
|
+
/**
|
114
|
+
* Return a commit object including all changes since the last commit. `null`
|
115
|
+
* will be returned if there is no change.
|
116
|
+
*/
|
117
|
+
commit() {
|
118
|
+
if (!this.parent || !this.doc || this.steps.length === 0 || this.parent.eq(this.doc))
|
119
|
+
return null;
|
120
|
+
let commit = {
|
121
|
+
doc: jsonFromNode(this.doc),
|
122
|
+
parent: jsonFromNode(this.parent),
|
123
|
+
steps: this.steps.map((step) => step.toJSON())
|
124
|
+
};
|
125
|
+
return this.init(this.doc), commit;
|
126
|
+
}
|
127
|
+
/**
|
128
|
+
* @internal
|
129
|
+
*/
|
130
|
+
init(doc) {
|
131
|
+
this.doc = doc, this.parent = doc, this.steps = [];
|
132
|
+
}
|
133
|
+
/**
|
134
|
+
* @internal
|
135
|
+
*/
|
136
|
+
apply(tr) {
|
137
|
+
this.steps.push(...tr.steps), this.doc = tr.doc;
|
138
|
+
}
|
139
|
+
};
|
140
|
+
function defineCommitRecorder(commitRecorder) {
|
141
|
+
let key = new PluginKey("prosekit-commit-recorder");
|
142
|
+
return definePlugin(
|
143
|
+
new ProseMirrorPlugin({
|
144
|
+
key,
|
145
|
+
state: {
|
146
|
+
init: (_, state) => {
|
147
|
+
commitRecorder.init(state.doc);
|
148
|
+
},
|
149
|
+
apply: (tr) => {
|
150
|
+
commitRecorder.apply(tr);
|
151
|
+
}
|
152
|
+
}
|
153
|
+
})
|
154
|
+
);
|
155
|
+
}
|
156
|
+
export {
|
157
|
+
CommitRecorder,
|
158
|
+
defineCommitRecorder,
|
159
|
+
defineCommitViewer
|
160
|
+
};
|
@@ -1,12 +1,12 @@
|
|
1
1
|
import {
|
2
2
|
defineMarkRule
|
3
3
|
} from "./chunk-ZPEMHYTU.js";
|
4
|
-
import {
|
5
|
-
defineInputRule
|
6
|
-
} from "./chunk-PYT3MOTF.js";
|
7
4
|
import {
|
8
5
|
defineEnterRule
|
9
6
|
} from "./chunk-2JYT2MT7.js";
|
7
|
+
import {
|
8
|
+
defineInputRule
|
9
|
+
} from "./chunk-PYT3MOTF.js";
|
10
10
|
|
11
11
|
// src/link/index.ts
|
12
12
|
import {
|
package/package.json
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
{
|
2
2
|
"name": "@prosekit/extensions",
|
3
3
|
"type": "module",
|
4
|
-
"version": "0.
|
4
|
+
"version": "0.7.0",
|
5
5
|
"private": false,
|
6
6
|
"author": {
|
7
7
|
"name": "ocavue",
|
@@ -55,6 +55,14 @@
|
|
55
55
|
"import": "./dist/prosekit-extensions-code-block.js",
|
56
56
|
"default": "./dist/prosekit-extensions-code-block.js"
|
57
57
|
},
|
58
|
+
"./commit": {
|
59
|
+
"types": "./dist/prosekit-extensions-commit.d.ts",
|
60
|
+
"import": "./dist/prosekit-extensions-commit.js",
|
61
|
+
"default": "./dist/prosekit-extensions-commit.js"
|
62
|
+
},
|
63
|
+
"./commit/style.css": {
|
64
|
+
"default": "./dist/commit/style.css"
|
65
|
+
},
|
58
66
|
"./drop-cursor": {
|
59
67
|
"types": "./dist/prosekit-extensions-drop-cursor.d.ts",
|
60
68
|
"import": "./dist/prosekit-extensions-drop-cursor.js",
|
@@ -170,19 +178,21 @@
|
|
170
178
|
"dist"
|
171
179
|
],
|
172
180
|
"dependencies": {
|
181
|
+
"prosemirror-changeset": "^2.2.1",
|
173
182
|
"prosemirror-dropcursor": "^1.8.1",
|
174
|
-
"prosemirror-flat-list": "^0.5.
|
183
|
+
"prosemirror-flat-list": "^0.5.1",
|
175
184
|
"prosemirror-highlight": "^0.8.0",
|
176
185
|
"prosemirror-search": "^0.1.0",
|
177
186
|
"prosemirror-tables": "^1.3.7",
|
178
|
-
"shiki": "^1.
|
179
|
-
"@prosekit/core": "^0.
|
187
|
+
"shiki": "^1.10.1",
|
188
|
+
"@prosekit/core": "^0.7.0",
|
180
189
|
"@prosekit/pm": "^0.1.5"
|
181
190
|
},
|
182
191
|
"devDependencies": {
|
192
|
+
"@vitest/browser": "^2.0.0-beta.13",
|
183
193
|
"tsup": "^8.1.0",
|
184
|
-
"typescript": "^5.5.
|
185
|
-
"vitest": "^
|
194
|
+
"typescript": "^5.5.3",
|
195
|
+
"vitest": "^2.0.0-beta.13",
|
186
196
|
"@prosekit/dev": "0.0.0"
|
187
197
|
},
|
188
198
|
"scripts": {
|
@@ -210,6 +220,9 @@
|
|
210
220
|
"code-block": [
|
211
221
|
"./dist/prosekit-extensions-code-block.d.ts"
|
212
222
|
],
|
223
|
+
"commit": [
|
224
|
+
"./dist/prosekit-extensions-commit.d.ts"
|
225
|
+
],
|
213
226
|
"drop-cursor": [
|
214
227
|
"./dist/prosekit-extensions-drop-cursor.d.ts"
|
215
228
|
],
|