@prosekit/core 0.3.0 → 0.3.2
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 +301 -11
- package/dist/prosekit-core.d.ts +30 -1
- package/dist/prosekit-core.js +282 -50
- package/package.json +2 -2
@@ -5,6 +5,7 @@ import { Command } from '@prosekit/pm/state';
|
|
5
5
|
import type { ConditionalExcept } from 'type-fest';
|
6
6
|
import type { ContentMatch } from '@prosekit/pm/model';
|
7
7
|
import type { DirectEditorProps } from '@prosekit/pm/view';
|
8
|
+
import type { DOMEventMap } from '@prosekit/pm/view';
|
8
9
|
import { EditorState } from '@prosekit/pm/state';
|
9
10
|
import type { EditorStateConfig } from '@prosekit/pm/state';
|
10
11
|
import { EditorView } from '@prosekit/pm/view';
|
@@ -15,6 +16,7 @@ import type { MarkSpec } from '@prosekit/pm/model';
|
|
15
16
|
import { MarkType } from '@prosekit/pm/model';
|
16
17
|
import { MarkType as MarkType_2 } from 'prosemirror-model';
|
17
18
|
import { Node as Node_2 } from 'prosemirror-model';
|
19
|
+
import type { Node as Node_3 } from '@prosekit/pm/model';
|
18
20
|
import { NodeSelection } from '@prosekit/pm/state';
|
19
21
|
import type { NodeSpec } from '@prosekit/pm/model';
|
20
22
|
import { NodeType } from '@prosekit/pm/model';
|
@@ -30,6 +32,7 @@ import type { SchemaSpec } from '@prosekit/pm/model';
|
|
30
32
|
import { Selection as Selection_2 } from '@prosekit/pm/state';
|
31
33
|
import { Selection as Selection_3 } from 'prosemirror-state';
|
32
34
|
import type { Simplify } from 'type-fest';
|
35
|
+
import type { Slice } from '@prosekit/pm/model';
|
33
36
|
import { TextSelection } from '@prosekit/pm/state';
|
34
37
|
import { Transaction } from '@prosekit/pm/state';
|
35
38
|
import type { UnionToIntersection } from 'type-fest';
|
@@ -122,6 +125,14 @@ declare interface BaseNodeViewOptions {
|
|
122
125
|
export { BaseNodeViewOptions }
|
123
126
|
export { BaseNodeViewOptions as BaseNodeViewOptions_alias_1 }
|
124
127
|
|
128
|
+
declare type ClickHandler = (view: EditorView, pos: number, event: MouseEvent) => boolean | void;
|
129
|
+
export { ClickHandler }
|
130
|
+
export { ClickHandler as ClickHandler_alias_1 }
|
131
|
+
|
132
|
+
declare type ClickOnHandler = (view: EditorView, pos: number, node: Node_3, nodePos: number, event: MouseEvent, direct: boolean) => boolean | void;
|
133
|
+
export { ClickOnHandler }
|
134
|
+
export { ClickOnHandler as ClickOnHandler_alias_1 }
|
135
|
+
|
125
136
|
/**
|
126
137
|
* A utility for constructing `className` strings conditionally.
|
127
138
|
*
|
@@ -135,6 +146,8 @@ export { clsx as clsx_alias_1 }
|
|
135
146
|
|
136
147
|
export declare function collectNodes(content: NodeContent): ProseMirrorNode[];
|
137
148
|
|
149
|
+
export declare function combineEventHandlers<Handler extends (...args: any[]) => boolean | void, Args extends Parameters<Handler> = Parameters<Handler>>(): readonly [(handlers: Handler[]) => void, (...args: Args) => boolean];
|
150
|
+
|
138
151
|
export declare interface CommandApplier<Args extends any[] = any[]> {
|
139
152
|
(...args: Args): boolean;
|
140
153
|
canApply(...args: Args): boolean;
|
@@ -281,6 +294,24 @@ declare function defineBaseKeymap(options?: {
|
|
281
294
|
export { defineBaseKeymap }
|
282
295
|
export { defineBaseKeymap as defineBaseKeymap_alias_1 }
|
283
296
|
|
297
|
+
/**
|
298
|
+
* @public
|
299
|
+
*
|
300
|
+
* See {@link https://prosemirror.net/docs/ref/#view.EditorProps.handleClick}
|
301
|
+
*/
|
302
|
+
declare function defineClickHandler(handler: ClickHandler): Extension<ExtensionTyping<string, string, CommandArgs>>;
|
303
|
+
export { defineClickHandler }
|
304
|
+
export { defineClickHandler as defineClickHandler_alias_1 }
|
305
|
+
|
306
|
+
/**
|
307
|
+
* @public
|
308
|
+
*
|
309
|
+
* See {@link https://prosemirror.net/docs/ref/#view.EditorProps.handleClickOn}
|
310
|
+
*/
|
311
|
+
declare function defineClickOnHandler(handler: ClickOnHandler): Extension<ExtensionTyping<string, string, CommandArgs>>;
|
312
|
+
export { defineClickOnHandler }
|
313
|
+
export { defineClickOnHandler as defineClickOnHandler_alias_1 }
|
314
|
+
|
284
315
|
declare function defineCommands<T extends Record<string, CommandCreator> = Record<string, CommandCreator>>(commands: T): Extension<{
|
285
316
|
COMMAND_ARGS: {
|
286
317
|
[K in keyof T]: Parameters<T[K]>;
|
@@ -311,6 +342,42 @@ declare function defineDocChangeHandler(handler: DocChangeHandler): Extension<Ex
|
|
311
342
|
export { defineDocChangeHandler }
|
312
343
|
export { defineDocChangeHandler as defineDocChangeHandler_alias_1 }
|
313
344
|
|
345
|
+
/**
|
346
|
+
* Register a new event handler for the given event type.
|
347
|
+
*
|
348
|
+
* @public
|
349
|
+
*/
|
350
|
+
declare function defineDOMEventHandler<Event extends keyof DOMEventMap = string>(event: Event, handler: DOMEventHandler<Event>): Extension<ExtensionTyping<string, string, CommandArgs>>;
|
351
|
+
export { defineDOMEventHandler }
|
352
|
+
export { defineDOMEventHandler as defineDOMEventHandler_alias_1 }
|
353
|
+
|
354
|
+
/**
|
355
|
+
* @public
|
356
|
+
*
|
357
|
+
* See {@link https://prosemirror.net/docs/ref/#view.EditorProps.handleDoubleClick}
|
358
|
+
*/
|
359
|
+
declare function defineDoubleClickHandler(handler: DoubleClickHandler): Extension<ExtensionTyping<string, string, CommandArgs>>;
|
360
|
+
export { defineDoubleClickHandler }
|
361
|
+
export { defineDoubleClickHandler as defineDoubleClickHandler_alias_1 }
|
362
|
+
|
363
|
+
/**
|
364
|
+
* @public
|
365
|
+
*
|
366
|
+
* See {@link https://prosemirror.net/docs/ref/#view.EditorProps.handleDoubleClickOn}
|
367
|
+
*/
|
368
|
+
declare function defineDoubleClickOnHandler(handler: DoubleClickOnHandler): Extension<ExtensionTyping<string, string, CommandArgs>>;
|
369
|
+
export { defineDoubleClickOnHandler }
|
370
|
+
export { defineDoubleClickOnHandler as defineDoubleClickOnHandler_alias_1 }
|
371
|
+
|
372
|
+
/**
|
373
|
+
* @public
|
374
|
+
*
|
375
|
+
* See {@link https://prosemirror.net/docs/ref/#view.EditorProps.handleDrop}
|
376
|
+
*/
|
377
|
+
declare function defineDropHandler(handler: DropHandler): Extension<ExtensionTyping<string, string, CommandArgs>>;
|
378
|
+
export { defineDropHandler }
|
379
|
+
export { defineDropHandler as defineDropHandler_alias_1 }
|
380
|
+
|
314
381
|
/**
|
315
382
|
* Registers a event handler that is called when the editor gains or loses focus.
|
316
383
|
*
|
@@ -332,6 +399,15 @@ redo: [];
|
|
332
399
|
export { defineHistory }
|
333
400
|
export { defineHistory as defineHistory_alias_1 }
|
334
401
|
|
402
|
+
/**
|
403
|
+
* @public
|
404
|
+
*
|
405
|
+
* See {@link https://prosemirror.net/docs/ref/#view.EditorProps.handleKeyDown}
|
406
|
+
*/
|
407
|
+
declare function defineKeyDownHandler(handler: KeyDownHandler): Extension<ExtensionTyping<string, string, CommandArgs>>;
|
408
|
+
export { defineKeyDownHandler }
|
409
|
+
export { defineKeyDownHandler as defineKeyDownHandler_alias_1 }
|
410
|
+
|
335
411
|
/**
|
336
412
|
* @public
|
337
413
|
*/
|
@@ -339,6 +415,15 @@ declare function defineKeymap(keymap: Keymap): Extension;
|
|
339
415
|
export { defineKeymap }
|
340
416
|
export { defineKeymap as defineKeymap_alias_1 }
|
341
417
|
|
418
|
+
/**
|
419
|
+
* @public
|
420
|
+
*
|
421
|
+
* See {@link https://prosemirror.net/docs/ref/#view.EditorProps.handleKeyPress}
|
422
|
+
*/
|
423
|
+
declare function defineKeyPressHandler(handler: KeyPressHandler): Extension<ExtensionTyping<string, string, CommandArgs>>;
|
424
|
+
export { defineKeyPressHandler }
|
425
|
+
export { defineKeyPressHandler as defineKeyPressHandler_alias_1 }
|
426
|
+
|
342
427
|
/**
|
343
428
|
* @public
|
344
429
|
*/
|
@@ -415,6 +500,15 @@ export declare function defineParagraphSpec(): Extension< {
|
|
415
500
|
NODES: "paragraph";
|
416
501
|
}>;
|
417
502
|
|
503
|
+
/**
|
504
|
+
* @public
|
505
|
+
*
|
506
|
+
* See {@link https://prosemirror.net/docs/ref/#view.EditorProps.handlePaste}
|
507
|
+
*/
|
508
|
+
declare function definePasteHandler(handler: PasteHandler): Extension<ExtensionTyping<string, string, CommandArgs>>;
|
509
|
+
export { definePasteHandler }
|
510
|
+
export { definePasteHandler as definePasteHandler_alias_1 }
|
511
|
+
|
418
512
|
/**
|
419
513
|
* Adds a ProseMirror plugin to the editor.
|
420
514
|
*
|
@@ -429,6 +523,15 @@ declare function definePlugin(plugin: Plugin_2 | Plugin_2[] | ((context: {
|
|
429
523
|
export { definePlugin }
|
430
524
|
export { definePlugin as definePlugin_alias_1 }
|
431
525
|
|
526
|
+
/**
|
527
|
+
* @public
|
528
|
+
*
|
529
|
+
* See {@link https://prosemirror.net/docs/ref/#view.EditorProps.handleScrollToSelection}
|
530
|
+
*/
|
531
|
+
declare function defineScrollToSelectionHandler(handler: ScrollToSelectionHandler): Extension<ExtensionTyping<string, string, CommandArgs>>;
|
532
|
+
export { defineScrollToSelectionHandler }
|
533
|
+
export { defineScrollToSelectionHandler as defineScrollToSelectionHandler_alias_1 }
|
534
|
+
|
432
535
|
/**
|
433
536
|
* @public
|
434
537
|
*/
|
@@ -438,6 +541,33 @@ NODES: "text";
|
|
438
541
|
export { defineText }
|
439
542
|
export { defineText as defineText_alias_1 }
|
440
543
|
|
544
|
+
/**
|
545
|
+
* @public
|
546
|
+
*
|
547
|
+
* See {@link https://prosemirror.net/docs/ref/#view.EditorProps.handleTextInput}
|
548
|
+
*/
|
549
|
+
declare function defineTextInputHandler(handler: TextInputHandler): Extension<ExtensionTyping<string, string, CommandArgs>>;
|
550
|
+
export { defineTextInputHandler }
|
551
|
+
export { defineTextInputHandler as defineTextInputHandler_alias_1 }
|
552
|
+
|
553
|
+
/**
|
554
|
+
* @public
|
555
|
+
*
|
556
|
+
* See {@link https://prosemirror.net/docs/ref/#view.EditorProps.handleTripleClick}
|
557
|
+
*/
|
558
|
+
declare function defineTripleClickHandler(handler: TripleClickHandler): Extension<ExtensionTyping<string, string, CommandArgs>>;
|
559
|
+
export { defineTripleClickHandler }
|
560
|
+
export { defineTripleClickHandler as defineTripleClickHandler_alias_1 }
|
561
|
+
|
562
|
+
/**
|
563
|
+
* @public
|
564
|
+
*
|
565
|
+
* See {@link https://prosemirror.net/docs/ref/#view.EditorProps.handleTripleClickOn}
|
566
|
+
*/
|
567
|
+
declare function defineTripleClickOnHandler(handler: TripleClickOnHandler): Extension<ExtensionTyping<string, string, CommandArgs>>;
|
568
|
+
export { defineTripleClickOnHandler }
|
569
|
+
export { defineTripleClickOnHandler as defineTripleClickOnHandler_alias_1 }
|
570
|
+
|
441
571
|
/**
|
442
572
|
* Registers a event handler that is called when the editor view is unmounted.
|
443
573
|
*
|
@@ -468,6 +598,49 @@ declare type DocChangeHandler = (view: EditorView, prevState: EditorState) => vo
|
|
468
598
|
export { DocChangeHandler }
|
469
599
|
export { DocChangeHandler as DocChangeHandler_alias_1 }
|
470
600
|
|
601
|
+
/**
|
602
|
+
* @internal
|
603
|
+
*/
|
604
|
+
export declare class DOMDocumentNotFoundError extends ProseKitError {
|
605
|
+
constructor();
|
606
|
+
}
|
607
|
+
|
608
|
+
/**
|
609
|
+
* @internal
|
610
|
+
*/
|
611
|
+
export declare const domEventFacet: Facet<DOMEventPayload, PluginPayload>;
|
612
|
+
|
613
|
+
/**
|
614
|
+
* A function to handle the events fired on the editable DOM element. Returns
|
615
|
+
* `true` to indicate that it handled the given event. you are responsible for
|
616
|
+
* calling `preventDefault` yourself (or not, if you want to allow the default
|
617
|
+
* behavior).
|
618
|
+
*
|
619
|
+
* @public
|
620
|
+
*/
|
621
|
+
declare type DOMEventHandler<Event extends keyof DOMEventMap = string> = (view: EditorView, event: DOMEventMap[Event]) => boolean | void;
|
622
|
+
export { DOMEventHandler }
|
623
|
+
export { DOMEventHandler as DOMEventHandler_alias_1 }
|
624
|
+
|
625
|
+
/**
|
626
|
+
* @internal
|
627
|
+
*/
|
628
|
+
export declare type DOMEventPayload = [event: string, handler: DOMEventHandler];
|
629
|
+
|
630
|
+
export declare type DOMNode = InstanceType<typeof window.Node>;
|
631
|
+
|
632
|
+
declare type DoubleClickHandler = (view: EditorView, pos: number, event: MouseEvent) => boolean | void;
|
633
|
+
export { DoubleClickHandler }
|
634
|
+
export { DoubleClickHandler as DoubleClickHandler_alias_1 }
|
635
|
+
|
636
|
+
declare type DoubleClickOnHandler = (view: EditorView, pos: number, node: Node_3, nodePos: number, event: MouseEvent, direct: boolean) => boolean | void;
|
637
|
+
export { DoubleClickOnHandler }
|
638
|
+
export { DoubleClickOnHandler as DoubleClickOnHandler_alias_1 }
|
639
|
+
|
640
|
+
declare type DropHandler = (view: EditorView, event: DragEvent, slice: Slice, moved: boolean) => boolean | void;
|
641
|
+
export { DropHandler }
|
642
|
+
export { DropHandler as DropHandler_alias_1 }
|
643
|
+
|
471
644
|
/**
|
472
645
|
* @public
|
473
646
|
*/
|
@@ -562,7 +735,31 @@ export { EditorOptions as EditorOptions_alias_1 }
|
|
562
735
|
*
|
563
736
|
* @internal
|
564
737
|
*/
|
565
|
-
export declare function elementFromHTML(html: string
|
738
|
+
export declare function elementFromHTML(html: string, options?: {
|
739
|
+
document?: Document;
|
740
|
+
}): HTMLElement;
|
741
|
+
|
742
|
+
/**
|
743
|
+
* Parse a ProseMirror document JSON object to a HTML element.
|
744
|
+
*
|
745
|
+
* @public
|
746
|
+
*/
|
747
|
+
declare function elementFromJSON(json: NodeJSON, schema: Schema, options?: {
|
748
|
+
document?: Document;
|
749
|
+
}): HTMLElement;
|
750
|
+
export { elementFromJSON }
|
751
|
+
export { elementFromJSON as elementFromJSON_alias_1 }
|
752
|
+
|
753
|
+
/**
|
754
|
+
* Serialize a ProseMirror node to a HTML element.
|
755
|
+
*
|
756
|
+
* @public
|
757
|
+
*/
|
758
|
+
declare function elementFromNode(node: ProseMirrorNode, options?: {
|
759
|
+
document?: Document;
|
760
|
+
}): HTMLElement;
|
761
|
+
export { elementFromNode }
|
762
|
+
export { elementFromNode as elementFromNode_alias_1 }
|
566
763
|
|
567
764
|
declare type EmptyValue = undefined | null | EmptyObject;
|
568
765
|
|
@@ -726,6 +923,14 @@ declare interface FacetOptions<Input, Output> {
|
|
726
923
|
export { FacetOptions }
|
727
924
|
export { FacetOptions as FacetOptions_alias_1 }
|
728
925
|
|
926
|
+
export declare function findBrowserDocument(options?: {
|
927
|
+
document?: Document;
|
928
|
+
}): Document | undefined;
|
929
|
+
|
930
|
+
export declare function findBrowserWindow(options?: {
|
931
|
+
document?: Document;
|
932
|
+
}): (Window & typeof globalThis) | null | undefined;
|
933
|
+
|
729
934
|
/**
|
730
935
|
* A function that is called when the editor gains or loses focus.
|
731
936
|
*
|
@@ -737,9 +942,13 @@ declare type FocusChangeHandler = (hasFocus: boolean) => void;
|
|
737
942
|
export { FocusChangeHandler }
|
738
943
|
export { FocusChangeHandler as FocusChangeHandler_alias_1 }
|
739
944
|
|
740
|
-
export declare function getBrowserDocument(
|
945
|
+
export declare function getBrowserDocument(options?: {
|
946
|
+
document?: Document;
|
947
|
+
}): Document;
|
741
948
|
|
742
|
-
export declare function getBrowserWindow(
|
949
|
+
export declare function getBrowserWindow(options?: {
|
950
|
+
document?: Document;
|
951
|
+
}): Window & typeof globalThis;
|
743
952
|
|
744
953
|
export declare function getCustomSelection(state: EditorState, from?: number | null, to?: number | null): Selection_3;
|
745
954
|
|
@@ -768,6 +977,37 @@ declare function getNodeType(schema: Schema, type: string | NodeType): NodeType;
|
|
768
977
|
export { getNodeType }
|
769
978
|
export { getNodeType as getNodeType_alias_1 }
|
770
979
|
|
980
|
+
export declare type GroupedEntries<T extends Record<string, any>> = {
|
981
|
+
[K in keyof T]?: T[K][];
|
982
|
+
};
|
983
|
+
|
984
|
+
export declare function groupEntries<T extends Record<string, any>>(entries: ObjectEntries<T>[]): GroupedEntries<T>;
|
985
|
+
|
986
|
+
/**
|
987
|
+
* @internal
|
988
|
+
*/
|
989
|
+
export declare function htmlFromElement(element: HTMLElement): string;
|
990
|
+
|
991
|
+
/**
|
992
|
+
* Parse a ProseMirror document JSON object to a HTML string.
|
993
|
+
*
|
994
|
+
* @public
|
995
|
+
*/
|
996
|
+
declare function htmlFromJSON(json: NodeJSON, schema: Schema, options?: {
|
997
|
+
document?: Document;
|
998
|
+
}): string;
|
999
|
+
export { htmlFromJSON }
|
1000
|
+
export { htmlFromJSON as htmlFromJSON_alias_1 }
|
1001
|
+
|
1002
|
+
/**
|
1003
|
+
* Serialize a ProseMirror node to a HTML string
|
1004
|
+
*
|
1005
|
+
* @public
|
1006
|
+
*/
|
1007
|
+
declare function htmlFromNode(node: ProseMirrorNode): string;
|
1008
|
+
export { htmlFromNode }
|
1009
|
+
export { htmlFromNode as htmlFromNode_alias_1 }
|
1010
|
+
|
771
1011
|
/**
|
772
1012
|
* Returns a command that inserts the given node at the current selection or at
|
773
1013
|
* the given position.
|
@@ -862,20 +1102,20 @@ export { isTextSelection }
|
|
862
1102
|
export { isTextSelection as isTextSelection_alias_1 }
|
863
1103
|
|
864
1104
|
/**
|
865
|
-
*
|
1105
|
+
* Serialize a HTML element to a ProseMirror document JSON object.
|
866
1106
|
*
|
867
1107
|
* @public
|
868
1108
|
*/
|
869
|
-
declare function jsonFromElement(element:
|
870
|
-
export { jsonFromElement }
|
871
|
-
export { jsonFromElement as jsonFromElement_alias_1 }
|
1109
|
+
export declare function jsonFromElement(element: DOMNode, schema: Schema): NodeJSON;
|
872
1110
|
|
873
1111
|
/**
|
874
|
-
* Parse a HTML string to a ProseMirror document JSON.
|
1112
|
+
* Parse a HTML string to a ProseMirror document JSON object.
|
875
1113
|
*
|
876
1114
|
* @public
|
877
1115
|
*/
|
878
|
-
declare function jsonFromHTML(html: string, schema: Schema
|
1116
|
+
declare function jsonFromHTML(html: string, schema: Schema, options?: {
|
1117
|
+
document?: Document;
|
1118
|
+
}): NodeJSON;
|
879
1119
|
export { jsonFromHTML }
|
880
1120
|
export { jsonFromHTML as jsonFromHTML_alias_1 }
|
881
1121
|
|
@@ -897,6 +1137,10 @@ declare function jsonFromState(state: EditorState): StateJSON;
|
|
897
1137
|
export { jsonFromState }
|
898
1138
|
export { jsonFromState as jsonFromState_alias_1 }
|
899
1139
|
|
1140
|
+
declare type KeyDownHandler = (view: EditorView, event: KeyboardEvent) => boolean | void;
|
1141
|
+
export { KeyDownHandler }
|
1142
|
+
export { KeyDownHandler as KeyDownHandler_alias_1 }
|
1143
|
+
|
900
1144
|
/**
|
901
1145
|
* @public
|
902
1146
|
*/
|
@@ -920,6 +1164,10 @@ declare type KeymapPayload = Keymap;
|
|
920
1164
|
export { KeymapPayload }
|
921
1165
|
export { KeymapPayload as KeymapPayload_alias_1 }
|
922
1166
|
|
1167
|
+
declare type KeyPressHandler = (view: EditorView, event: KeyboardEvent) => boolean | void;
|
1168
|
+
export { KeyPressHandler }
|
1169
|
+
export { KeyPressHandler as KeyPressHandler_alias_1 }
|
1170
|
+
|
923
1171
|
/**
|
924
1172
|
* @public
|
925
1173
|
*/
|
@@ -1021,7 +1269,7 @@ export declare type NodeContent = ProseMirrorNode | ProseMirrorFragment | NodeCo
|
|
1021
1269
|
*
|
1022
1270
|
* @public
|
1023
1271
|
*/
|
1024
|
-
declare function nodeFromElement(element:
|
1272
|
+
declare function nodeFromElement(element: DOMNode, schema: Schema): ProseMirrorNode;
|
1025
1273
|
export { nodeFromElement }
|
1026
1274
|
export { nodeFromElement as nodeFromElement_alias_1 }
|
1027
1275
|
|
@@ -1030,7 +1278,9 @@ export { nodeFromElement as nodeFromElement_alias_1 }
|
|
1030
1278
|
*
|
1031
1279
|
* @public
|
1032
1280
|
*/
|
1033
|
-
declare function nodeFromHTML(html: string, schema: Schema
|
1281
|
+
declare function nodeFromHTML(html: string, schema: Schema, options?: {
|
1282
|
+
document?: Document;
|
1283
|
+
}): ProseMirrorNode;
|
1034
1284
|
export { nodeFromHTML }
|
1035
1285
|
export { nodeFromHTML as nodeFromHTML_alias_1 }
|
1036
1286
|
|
@@ -1097,8 +1347,27 @@ declare const OBJECT_REPLACEMENT_CHARACTER = "\uFFFC";
|
|
1097
1347
|
export { OBJECT_REPLACEMENT_CHARACTER }
|
1098
1348
|
export { OBJECT_REPLACEMENT_CHARACTER as OBJECT_REPLACEMENT_CHARACTER_alias_1 }
|
1099
1349
|
|
1350
|
+
/**
|
1351
|
+
* @internal
|
1352
|
+
*
|
1353
|
+
* @example
|
1354
|
+
*
|
1355
|
+
* ```
|
1356
|
+
* type MyObject = { a: 1; b: 'B' }
|
1357
|
+
* type MyEntries = ObjectEntries<MyObject>
|
1358
|
+
* // ^ ["a", 1] | ["b", "B"]
|
1359
|
+
*
|
1360
|
+
*/
|
1361
|
+
export declare type ObjectEntries<T extends Record<string, any>> = {
|
1362
|
+
[K in keyof T]: [K, T[K]];
|
1363
|
+
}[keyof T];
|
1364
|
+
|
1100
1365
|
export declare function objectEqual<T>(a: T, b: T): boolean;
|
1101
1366
|
|
1367
|
+
declare type PasteHandler = (view: EditorView, event: ClipboardEvent, slice: Slice) => boolean | void;
|
1368
|
+
export { PasteHandler }
|
1369
|
+
export { PasteHandler as PasteHandler_alias_1 }
|
1370
|
+
|
1102
1371
|
declare type Payload = unknown;
|
1103
1372
|
|
1104
1373
|
export declare type Payloads = PayloadTuple[];
|
@@ -1176,6 +1445,10 @@ export declare const schemaFacet: Facet<SchemaPayload, SchemaPayload>;
|
|
1176
1445
|
|
1177
1446
|
export declare type SchemaPayload = SchemaSpec;
|
1178
1447
|
|
1448
|
+
declare type ScrollToSelectionHandler = (view: EditorView) => boolean;
|
1449
|
+
export { ScrollToSelectionHandler }
|
1450
|
+
export { ScrollToSelectionHandler as ScrollToSelectionHandler_alias_1 }
|
1451
|
+
|
1179
1452
|
/**
|
1180
1453
|
* Returns a command that selects the whole document.
|
1181
1454
|
*
|
@@ -1238,6 +1511,11 @@ export { setNodeAttrs as setNodeAttrs_alias_1 }
|
|
1238
1511
|
|
1239
1512
|
export declare function setSelectionAround(tr: Transaction, pos: number): void;
|
1240
1513
|
|
1514
|
+
/**
|
1515
|
+
* @internal
|
1516
|
+
*/
|
1517
|
+
export declare type Setter<T> = (value: T) => void;
|
1518
|
+
|
1241
1519
|
/**
|
1242
1520
|
* @internal
|
1243
1521
|
*/
|
@@ -1289,6 +1567,10 @@ export declare type StatePayload = (ctx: {
|
|
1289
1567
|
schema: Schema;
|
1290
1568
|
}) => EditorStateConfig;
|
1291
1569
|
|
1570
|
+
declare type TextInputHandler = (view: EditorView, from: number, to: number, text: string) => boolean | void;
|
1571
|
+
export { TextInputHandler }
|
1572
|
+
export { TextInputHandler as TextInputHandler_alias_1 }
|
1573
|
+
|
1292
1574
|
export declare type ToCommandApplier<T extends CommandArgs> = {
|
1293
1575
|
[K in keyof T]: CommandApplier<T[K]>;
|
1294
1576
|
};
|
@@ -1326,6 +1608,14 @@ declare function toggleNode({ type, attrs, }: {
|
|
1326
1608
|
export { toggleNode }
|
1327
1609
|
export { toggleNode as toggleNode_alias_1 }
|
1328
1610
|
|
1611
|
+
declare type TripleClickHandler = (view: EditorView, pos: number, event: MouseEvent) => boolean | void;
|
1612
|
+
export { TripleClickHandler }
|
1613
|
+
export { TripleClickHandler as TripleClickHandler_alias_1 }
|
1614
|
+
|
1615
|
+
declare type TripleClickOnHandler = (view: EditorView, pos: number, node: Node_3, nodePos: number, event: MouseEvent, direct: boolean) => boolean | void;
|
1616
|
+
export { TripleClickOnHandler }
|
1617
|
+
export { TripleClickOnHandler as TripleClickOnHandler_alias_1 }
|
1618
|
+
|
1329
1619
|
declare type Tuple5<T> = [T, T, T, T, T];
|
1330
1620
|
|
1331
1621
|
/**
|
package/dist/prosekit-core.d.ts
CHANGED
@@ -20,6 +20,32 @@ export { DefaultStateOptions } from './_tsup-dts-rollup';
|
|
20
20
|
export { defineDoc } from './_tsup-dts-rollup';
|
21
21
|
export { defineDocChangeHandler } from './_tsup-dts-rollup';
|
22
22
|
export { DocChangeHandler } from './_tsup-dts-rollup';
|
23
|
+
export { defineDOMEventHandler } from './_tsup-dts-rollup';
|
24
|
+
export { DOMEventHandler } from './_tsup-dts-rollup';
|
25
|
+
export { defineClickHandler } from './_tsup-dts-rollup';
|
26
|
+
export { defineClickOnHandler } from './_tsup-dts-rollup';
|
27
|
+
export { defineDoubleClickHandler } from './_tsup-dts-rollup';
|
28
|
+
export { defineDoubleClickOnHandler } from './_tsup-dts-rollup';
|
29
|
+
export { defineDropHandler } from './_tsup-dts-rollup';
|
30
|
+
export { defineKeyDownHandler } from './_tsup-dts-rollup';
|
31
|
+
export { defineKeyPressHandler } from './_tsup-dts-rollup';
|
32
|
+
export { definePasteHandler } from './_tsup-dts-rollup';
|
33
|
+
export { defineScrollToSelectionHandler } from './_tsup-dts-rollup';
|
34
|
+
export { defineTextInputHandler } from './_tsup-dts-rollup';
|
35
|
+
export { defineTripleClickHandler } from './_tsup-dts-rollup';
|
36
|
+
export { defineTripleClickOnHandler } from './_tsup-dts-rollup';
|
37
|
+
export { ClickHandler } from './_tsup-dts-rollup';
|
38
|
+
export { ClickOnHandler } from './_tsup-dts-rollup';
|
39
|
+
export { DoubleClickHandler } from './_tsup-dts-rollup';
|
40
|
+
export { DoubleClickOnHandler } from './_tsup-dts-rollup';
|
41
|
+
export { DropHandler } from './_tsup-dts-rollup';
|
42
|
+
export { KeyDownHandler } from './_tsup-dts-rollup';
|
43
|
+
export { KeyPressHandler } from './_tsup-dts-rollup';
|
44
|
+
export { PasteHandler } from './_tsup-dts-rollup';
|
45
|
+
export { ScrollToSelectionHandler } from './_tsup-dts-rollup';
|
46
|
+
export { TextInputHandler } from './_tsup-dts-rollup';
|
47
|
+
export { TripleClickHandler } from './_tsup-dts-rollup';
|
48
|
+
export { TripleClickOnHandler } from './_tsup-dts-rollup';
|
23
49
|
export { defineFocusChangeHandler } from './_tsup-dts-rollup';
|
24
50
|
export { FocusChangeHandler } from './_tsup-dts-rollup';
|
25
51
|
export { defineMountHandler } from './_tsup-dts-rollup';
|
@@ -73,7 +99,10 @@ export { _getId } from './_tsup-dts-rollup';
|
|
73
99
|
export { getMarkType } from './_tsup-dts-rollup';
|
74
100
|
export { getNodeType } from './_tsup-dts-rollup';
|
75
101
|
export { isInCodeBlock } from './_tsup-dts-rollup';
|
76
|
-
export {
|
102
|
+
export { elementFromJSON } from './_tsup-dts-rollup';
|
103
|
+
export { elementFromNode } from './_tsup-dts-rollup';
|
104
|
+
export { htmlFromJSON } from './_tsup-dts-rollup';
|
105
|
+
export { htmlFromNode } from './_tsup-dts-rollup';
|
77
106
|
export { jsonFromHTML } from './_tsup-dts-rollup';
|
78
107
|
export { jsonFromNode } from './_tsup-dts-rollup';
|
79
108
|
export { jsonFromState } from './_tsup-dts-rollup';
|
package/dist/prosekit-core.js
CHANGED
@@ -15,6 +15,13 @@ var EditorNotFoundError = class extends ProseKitError {
|
|
15
15
|
);
|
16
16
|
}
|
17
17
|
};
|
18
|
+
var DOMDocumentNotFoundError = class extends ProseKitError {
|
19
|
+
constructor() {
|
20
|
+
super(
|
21
|
+
"Unable to find browser Document. When not in the browser environment, you need to pass a DOM Document."
|
22
|
+
);
|
23
|
+
}
|
24
|
+
};
|
18
25
|
|
19
26
|
// src/utils/get-mark-type.ts
|
20
27
|
function getMarkType(schema, type) {
|
@@ -433,11 +440,11 @@ var stateFacet = Facet.defineRootFacet({
|
|
433
440
|
});
|
434
441
|
|
435
442
|
// src/utils/parse.ts
|
436
|
-
import { DOMParser } from "@prosekit/pm/model";
|
443
|
+
import { DOMParser, DOMSerializer } from "@prosekit/pm/model";
|
437
444
|
import { EditorState } from "@prosekit/pm/state";
|
438
445
|
|
439
446
|
// src/utils/get-dom-api.ts
|
440
|
-
function
|
447
|
+
function findGlobalBrowserDocument() {
|
441
448
|
if (typeof document !== "undefined") {
|
442
449
|
return document;
|
443
450
|
}
|
@@ -445,7 +452,7 @@ function getGlobalBrowserDocument() {
|
|
445
452
|
return globalThis.document;
|
446
453
|
}
|
447
454
|
}
|
448
|
-
function
|
455
|
+
function findGlobalBrowserWindow() {
|
449
456
|
if (typeof window !== "undefined") {
|
450
457
|
return window;
|
451
458
|
}
|
@@ -453,49 +460,78 @@ function getGlobalBrowserWindow() {
|
|
453
460
|
return globalThis.window;
|
454
461
|
}
|
455
462
|
}
|
456
|
-
function
|
457
|
-
var _a;
|
458
|
-
|
459
|
-
|
463
|
+
function findBrowserDocument(options) {
|
464
|
+
var _a, _b, _c;
|
465
|
+
return (_c = (_a = options == null ? void 0 : options.document) != null ? _a : findGlobalBrowserDocument()) != null ? _c : (_b = findGlobalBrowserWindow()) == null ? void 0 : _b.document;
|
466
|
+
}
|
467
|
+
function findBrowserWindow(options) {
|
468
|
+
var _a, _b, _c, _d;
|
469
|
+
return (_d = (_b = (_a = options == null ? void 0 : options.document) == null ? void 0 : _a.defaultView) != null ? _b : findGlobalBrowserWindow()) != null ? _d : (_c = findBrowserDocument(options)) == null ? void 0 : _c.defaultView;
|
470
|
+
}
|
471
|
+
function getBrowserDocument(options) {
|
472
|
+
const doc = findBrowserDocument(options);
|
473
|
+
if (doc)
|
474
|
+
return doc;
|
475
|
+
throw new DOMDocumentNotFoundError();
|
476
|
+
}
|
477
|
+
function getBrowserWindow(options) {
|
478
|
+
const win = findBrowserWindow(options);
|
479
|
+
if (win)
|
460
480
|
return win;
|
461
|
-
|
462
|
-
return (_a = getGlobalBrowserDocument()) == null ? void 0 : _a.defaultView;
|
481
|
+
throw new DOMDocumentNotFoundError();
|
463
482
|
}
|
464
483
|
|
465
484
|
// src/utils/parse.ts
|
466
|
-
function
|
467
|
-
return
|
485
|
+
function jsonFromState(state) {
|
486
|
+
return state.toJSON();
|
468
487
|
}
|
469
|
-
function
|
470
|
-
return
|
488
|
+
function stateFromJSON(json, schema) {
|
489
|
+
return EditorState.fromJSON({ schema }, json);
|
471
490
|
}
|
472
|
-
function
|
473
|
-
return
|
491
|
+
function jsonFromNode(node) {
|
492
|
+
return node.toJSON();
|
493
|
+
}
|
494
|
+
function nodeFromJSON(json, schema) {
|
495
|
+
return schema.nodeFromJSON(json);
|
474
496
|
}
|
475
|
-
function
|
476
|
-
return
|
497
|
+
function nodeFromElement(element, schema) {
|
498
|
+
return DOMParser.fromSchema(schema).parse(element);
|
477
499
|
}
|
478
|
-
function
|
479
|
-
const
|
480
|
-
|
481
|
-
|
482
|
-
|
483
|
-
);
|
500
|
+
function elementFromNode(node, options) {
|
501
|
+
const schema = node.type.schema;
|
502
|
+
const serializer = DOMSerializer.fromSchema(schema);
|
503
|
+
if (schema.topNodeType !== node.type) {
|
504
|
+
return serializer.serializeNode(node, options);
|
484
505
|
}
|
506
|
+
const doc = getBrowserDocument();
|
507
|
+
const div = doc.createElement("div");
|
508
|
+
return serializer.serializeFragment(node.content, options, div);
|
509
|
+
}
|
510
|
+
function elementFromHTML(html, options) {
|
511
|
+
const win = getBrowserWindow(options);
|
485
512
|
const parser = new win.DOMParser();
|
486
|
-
return parser.parseFromString(`<body>${html}</body>`, "text/html").body;
|
513
|
+
return parser.parseFromString(`<body><div>${html}</div></body>`, "text/html").body.firstElementChild;
|
487
514
|
}
|
488
|
-
function
|
489
|
-
return
|
515
|
+
function htmlFromElement(element) {
|
516
|
+
return element.outerHTML;
|
490
517
|
}
|
491
|
-
function
|
492
|
-
return
|
518
|
+
function nodeFromHTML(html, schema, options) {
|
519
|
+
return nodeFromElement(elementFromHTML(html, options), schema);
|
493
520
|
}
|
494
|
-
function
|
495
|
-
return
|
521
|
+
function htmlFromNode(node) {
|
522
|
+
return elementFromNode(node).outerHTML;
|
496
523
|
}
|
497
|
-
function
|
498
|
-
return
|
524
|
+
function jsonFromElement(element, schema) {
|
525
|
+
return jsonFromNode(nodeFromElement(element, schema));
|
526
|
+
}
|
527
|
+
function elementFromJSON(json, schema, options) {
|
528
|
+
return elementFromNode(nodeFromJSON(json, schema), options);
|
529
|
+
}
|
530
|
+
function jsonFromHTML(html, schema, options) {
|
531
|
+
return jsonFromElement(elementFromHTML(html, options), schema);
|
532
|
+
}
|
533
|
+
function htmlFromJSON(json, schema, options) {
|
534
|
+
return htmlFromElement(elementFromJSON(json, schema, options));
|
499
535
|
}
|
500
536
|
|
501
537
|
// src/extensions/default-state.ts
|
@@ -1442,21 +1478,201 @@ function defineDocChangeHandler(handler) {
|
|
1442
1478
|
});
|
1443
1479
|
}
|
1444
1480
|
|
1445
|
-
// src/extensions/events/
|
1481
|
+
// src/extensions/events/dom-event.ts
|
1446
1482
|
import { PluginKey as PluginKey2, ProseMirrorPlugin as ProseMirrorPlugin2 } from "@prosekit/pm/state";
|
1447
|
-
|
1448
|
-
|
1449
|
-
|
1450
|
-
|
1451
|
-
|
1452
|
-
|
1453
|
-
|
1454
|
-
|
1455
|
-
|
1483
|
+
|
1484
|
+
// src/utils/combine-event-handlers.ts
|
1485
|
+
function combineEventHandlers() {
|
1486
|
+
let _handlers = [];
|
1487
|
+
function setHandlers(handlers) {
|
1488
|
+
_handlers = handlers;
|
1489
|
+
}
|
1490
|
+
function combinedEventHandler(...args) {
|
1491
|
+
for (const handler of _handlers) {
|
1492
|
+
if (handler(...args)) {
|
1493
|
+
return true;
|
1456
1494
|
}
|
1457
1495
|
}
|
1496
|
+
return false;
|
1497
|
+
}
|
1498
|
+
return [setHandlers, combinedEventHandler];
|
1499
|
+
}
|
1500
|
+
|
1501
|
+
// src/utils/group-entries.ts
|
1502
|
+
function groupEntries(entries) {
|
1503
|
+
const map = {};
|
1504
|
+
for (const [key, value] of entries) {
|
1505
|
+
const values = map[key];
|
1506
|
+
if (!values) {
|
1507
|
+
map[key] = [value];
|
1508
|
+
} else {
|
1509
|
+
values.push(value);
|
1510
|
+
}
|
1511
|
+
}
|
1512
|
+
return map;
|
1513
|
+
}
|
1514
|
+
|
1515
|
+
// src/extensions/events/dom-event.ts
|
1516
|
+
function defineDOMEventHandler(event, handler) {
|
1517
|
+
return domEventFacet.extension([
|
1518
|
+
[event, handler]
|
1519
|
+
]);
|
1520
|
+
}
|
1521
|
+
var domEventFacet = Facet.define({
|
1522
|
+
converter: () => {
|
1523
|
+
const setHandlersMap = {};
|
1524
|
+
const combinedHandlerMap = {};
|
1525
|
+
const update = (payloads) => {
|
1526
|
+
let hasNewEvent = false;
|
1527
|
+
for (const [event] of payloads) {
|
1528
|
+
if (!setHandlersMap[event]) {
|
1529
|
+
hasNewEvent = true;
|
1530
|
+
const [setHandlers, combinedHandler] = combineEventHandlers();
|
1531
|
+
setHandlersMap[event] = setHandlers;
|
1532
|
+
combinedHandlerMap[event] = combinedHandler;
|
1533
|
+
}
|
1534
|
+
}
|
1535
|
+
const map = groupEntries(payloads);
|
1536
|
+
for (const [event, handlers] of Object.entries(map)) {
|
1537
|
+
const setHandlers = setHandlersMap[event];
|
1538
|
+
setHandlers(handlers != null ? handlers : []);
|
1539
|
+
}
|
1540
|
+
if (hasNewEvent) {
|
1541
|
+
return new ProseMirrorPlugin2({
|
1542
|
+
key: new PluginKey2("prosekit-dom-event-handler"),
|
1543
|
+
props: { handleDOMEvents: combinedHandlerMap }
|
1544
|
+
});
|
1545
|
+
} else {
|
1546
|
+
return null;
|
1547
|
+
}
|
1548
|
+
};
|
1549
|
+
return {
|
1550
|
+
create: (payloads) => {
|
1551
|
+
const plugin = update(payloads);
|
1552
|
+
return plugin ? () => plugin : () => [];
|
1553
|
+
},
|
1554
|
+
update: (payloads) => {
|
1555
|
+
const plugin = update(payloads);
|
1556
|
+
return plugin ? () => plugin : null;
|
1557
|
+
}
|
1558
|
+
};
|
1559
|
+
},
|
1560
|
+
next: pluginFacet,
|
1561
|
+
singleton: true
|
1562
|
+
});
|
1563
|
+
|
1564
|
+
// src/extensions/events/editor-event.ts
|
1565
|
+
import { PluginKey as PluginKey3, ProseMirrorPlugin as ProseMirrorPlugin3 } from "@prosekit/pm/state";
|
1566
|
+
function defineKeyDownHandler(handler) {
|
1567
|
+
return editorEventFacet.extension([["keyDown", handler]]);
|
1568
|
+
}
|
1569
|
+
function defineKeyPressHandler(handler) {
|
1570
|
+
return editorEventFacet.extension([["keyPress", handler]]);
|
1571
|
+
}
|
1572
|
+
function defineTextInputHandler(handler) {
|
1573
|
+
return editorEventFacet.extension([["textInput", handler]]);
|
1574
|
+
}
|
1575
|
+
function defineClickOnHandler(handler) {
|
1576
|
+
return editorEventFacet.extension([["clickOn", handler]]);
|
1577
|
+
}
|
1578
|
+
function defineClickHandler(handler) {
|
1579
|
+
return editorEventFacet.extension([["click", handler]]);
|
1580
|
+
}
|
1581
|
+
function defineDoubleClickOnHandler(handler) {
|
1582
|
+
return editorEventFacet.extension([["doubleClickOn", handler]]);
|
1583
|
+
}
|
1584
|
+
function defineDoubleClickHandler(handler) {
|
1585
|
+
return editorEventFacet.extension([["doubleClick", handler]]);
|
1586
|
+
}
|
1587
|
+
function defineTripleClickOnHandler(handler) {
|
1588
|
+
return editorEventFacet.extension([["tripleClickOn", handler]]);
|
1589
|
+
}
|
1590
|
+
function defineTripleClickHandler(handler) {
|
1591
|
+
return editorEventFacet.extension([["tripleClick", handler]]);
|
1592
|
+
}
|
1593
|
+
function definePasteHandler(handler) {
|
1594
|
+
return editorEventFacet.extension([["paste", handler]]);
|
1595
|
+
}
|
1596
|
+
function defineDropHandler(handler) {
|
1597
|
+
return editorEventFacet.extension([["drop", handler]]);
|
1598
|
+
}
|
1599
|
+
function defineScrollToSelectionHandler(handler) {
|
1600
|
+
return editorEventFacet.extension([["scrollToSelection", handler]]);
|
1601
|
+
}
|
1602
|
+
var editorEventFacet = Facet.define({
|
1603
|
+
converter: () => {
|
1604
|
+
const [update, plugin] = setupEditorEventPlugin();
|
1605
|
+
return {
|
1606
|
+
create: (entries) => {
|
1607
|
+
update(entries);
|
1608
|
+
return () => plugin;
|
1609
|
+
},
|
1610
|
+
update: (entries) => {
|
1611
|
+
update(entries);
|
1612
|
+
return null;
|
1613
|
+
}
|
1614
|
+
};
|
1615
|
+
},
|
1616
|
+
next: pluginFacet,
|
1617
|
+
singleton: true
|
1618
|
+
});
|
1619
|
+
function setupEditorEventPlugin() {
|
1620
|
+
const [setKeyDownHandlers, handleKeyDown] = combineEventHandlers();
|
1621
|
+
const [setKeyPressHandlers, handleKeyPress] = combineEventHandlers();
|
1622
|
+
const [setTextInputHandlers, handleTextInput] = combineEventHandlers();
|
1623
|
+
const [setClickOnHandlers, handleClickOn] = combineEventHandlers();
|
1624
|
+
const [setClickHandlers, handleClick] = combineEventHandlers();
|
1625
|
+
const [setDoubleClickOnHandlers, handleDoubleClickOn] = combineEventHandlers();
|
1626
|
+
const [setDoubleClickHandlers, handleDoubleClick] = combineEventHandlers();
|
1627
|
+
const [setTripleClickOnHandlers, handleTripleClickOn] = combineEventHandlers();
|
1628
|
+
const [setTripleClickHandlers, handleTripleClick] = combineEventHandlers();
|
1629
|
+
const [setPasteHandlers, handlePaste] = combineEventHandlers();
|
1630
|
+
const [setDropHandlers, handleDrop] = combineEventHandlers();
|
1631
|
+
const [setScrollToSelectionHandlers, handleScrollToSelection] = combineEventHandlers();
|
1632
|
+
const update = (entries) => {
|
1633
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l;
|
1634
|
+
const map = groupEntries(entries);
|
1635
|
+
setKeyDownHandlers((_a = map.keyDown) != null ? _a : []);
|
1636
|
+
setKeyPressHandlers((_b = map.keyPress) != null ? _b : []);
|
1637
|
+
setTextInputHandlers((_c = map.textInput) != null ? _c : []);
|
1638
|
+
setClickOnHandlers((_d = map.clickOn) != null ? _d : []);
|
1639
|
+
setClickHandlers((_e = map.click) != null ? _e : []);
|
1640
|
+
setDoubleClickOnHandlers((_f = map.doubleClickOn) != null ? _f : []);
|
1641
|
+
setDoubleClickHandlers((_g = map.doubleClick) != null ? _g : []);
|
1642
|
+
setTripleClickOnHandlers((_h = map.tripleClickOn) != null ? _h : []);
|
1643
|
+
setTripleClickHandlers((_i = map.tripleClick) != null ? _i : []);
|
1644
|
+
setPasteHandlers((_j = map.paste) != null ? _j : []);
|
1645
|
+
setDropHandlers((_k = map.drop) != null ? _k : []);
|
1646
|
+
setScrollToSelectionHandlers((_l = map.scrollToSelection) != null ? _l : []);
|
1647
|
+
};
|
1648
|
+
const plugin = new ProseMirrorPlugin3({
|
1649
|
+
key: new PluginKey3("prosekit-editor-handler"),
|
1650
|
+
props: {
|
1651
|
+
handleKeyDown,
|
1652
|
+
handleKeyPress,
|
1653
|
+
handleTextInput,
|
1654
|
+
handleClickOn,
|
1655
|
+
handleClick,
|
1656
|
+
handleDoubleClickOn,
|
1657
|
+
handleDoubleClick,
|
1658
|
+
handleTripleClickOn,
|
1659
|
+
handleTripleClick,
|
1660
|
+
handlePaste,
|
1661
|
+
handleDrop,
|
1662
|
+
handleScrollToSelection
|
1663
|
+
}
|
1458
1664
|
});
|
1459
|
-
return
|
1665
|
+
return [update, plugin];
|
1666
|
+
}
|
1667
|
+
|
1668
|
+
// src/extensions/events/focus.ts
|
1669
|
+
function defineFocusChangeHandler(handler) {
|
1670
|
+
const handleFocus = () => handler(true);
|
1671
|
+
const handleBlur = () => handler(false);
|
1672
|
+
return domEventFacet.extension([
|
1673
|
+
["focus", handleFocus],
|
1674
|
+
["blur", handleBlur]
|
1675
|
+
]);
|
1460
1676
|
}
|
1461
1677
|
|
1462
1678
|
// src/extensions/history.ts
|
@@ -1468,7 +1684,7 @@ var isMac = typeof navigator !== "undefined" ? /Mac|iP(hone|[ao]d)/.test(navigat
|
|
1468
1684
|
// src/extensions/keymap.ts
|
1469
1685
|
import { baseKeymap, chainCommands } from "@prosekit/pm/commands";
|
1470
1686
|
import { keydownHandler } from "@prosekit/pm/keymap";
|
1471
|
-
import { Plugin as Plugin3, PluginKey as
|
1687
|
+
import { Plugin as Plugin3, PluginKey as PluginKey4 } from "@prosekit/pm/state";
|
1472
1688
|
function defineKeymap(keymap) {
|
1473
1689
|
return keymapFacet.extension([keymap]);
|
1474
1690
|
}
|
@@ -1519,7 +1735,7 @@ function mergeKeymaps(keymaps) {
|
|
1519
1735
|
])
|
1520
1736
|
);
|
1521
1737
|
}
|
1522
|
-
var keymapPluginKey = new
|
1738
|
+
var keymapPluginKey = new PluginKey4("prosekit-keymap");
|
1523
1739
|
|
1524
1740
|
// src/extensions/history.ts
|
1525
1741
|
function defineHistory() {
|
@@ -1632,7 +1848,7 @@ var markSpecFacet = Facet.define({
|
|
1632
1848
|
});
|
1633
1849
|
|
1634
1850
|
// src/extensions/node-view.ts
|
1635
|
-
import { ProseMirrorPlugin as
|
1851
|
+
import { ProseMirrorPlugin as ProseMirrorPlugin4 } from "@prosekit/pm/state";
|
1636
1852
|
import "@prosekit/pm/view";
|
1637
1853
|
function defineNodeView(options) {
|
1638
1854
|
return nodeViewFacet.extension([options]);
|
@@ -1645,13 +1861,13 @@ var nodeViewFacet = Facet.define({
|
|
1645
1861
|
nodeViews[input.name] = input.constructor;
|
1646
1862
|
}
|
1647
1863
|
}
|
1648
|
-
return () => [new
|
1864
|
+
return () => [new ProseMirrorPlugin4({ props: { nodeViews } })];
|
1649
1865
|
},
|
1650
1866
|
next: pluginFacet
|
1651
1867
|
});
|
1652
1868
|
|
1653
1869
|
// src/extensions/node-view-effect.ts
|
1654
|
-
import { ProseMirrorPlugin as
|
1870
|
+
import { ProseMirrorPlugin as ProseMirrorPlugin5 } from "@prosekit/pm/state";
|
1655
1871
|
import "@prosekit/pm/view";
|
1656
1872
|
function defineNodeViewFactory(options) {
|
1657
1873
|
return nodeViewFactoryFacet.extension([options]);
|
@@ -1679,7 +1895,7 @@ var nodeViewFactoryFacet = Facet.define({
|
|
1679
1895
|
nodeViews[name] = factory(args);
|
1680
1896
|
}
|
1681
1897
|
}
|
1682
|
-
return () => [new
|
1898
|
+
return () => [new ProseMirrorPlugin5({ props: { nodeViews } })];
|
1683
1899
|
},
|
1684
1900
|
next: pluginFacet
|
1685
1901
|
});
|
@@ -1763,12 +1979,20 @@ export {
|
|
1763
1979
|
defaultBlockAt,
|
1764
1980
|
defineBaseCommands,
|
1765
1981
|
defineBaseKeymap,
|
1982
|
+
defineClickHandler,
|
1983
|
+
defineClickOnHandler,
|
1766
1984
|
defineCommands,
|
1985
|
+
defineDOMEventHandler,
|
1767
1986
|
defineDefaultState,
|
1768
1987
|
defineDoc,
|
1769
1988
|
defineDocChangeHandler,
|
1989
|
+
defineDoubleClickHandler,
|
1990
|
+
defineDoubleClickOnHandler,
|
1991
|
+
defineDropHandler,
|
1770
1992
|
defineFocusChangeHandler,
|
1771
1993
|
defineHistory,
|
1994
|
+
defineKeyDownHandler,
|
1995
|
+
defineKeyPressHandler,
|
1772
1996
|
defineKeymap,
|
1773
1997
|
defineMarkAttr,
|
1774
1998
|
defineMarkSpec,
|
@@ -1778,13 +2002,22 @@ export {
|
|
1778
2002
|
defineNodeView,
|
1779
2003
|
defineNodeViewFactory,
|
1780
2004
|
defineParagraph,
|
2005
|
+
definePasteHandler,
|
1781
2006
|
definePlugin,
|
2007
|
+
defineScrollToSelectionHandler,
|
1782
2008
|
defineText,
|
2009
|
+
defineTextInputHandler,
|
2010
|
+
defineTripleClickHandler,
|
2011
|
+
defineTripleClickOnHandler,
|
1783
2012
|
defineUnmountHandler,
|
1784
2013
|
defineUpdateHandler,
|
2014
|
+
elementFromJSON,
|
2015
|
+
elementFromNode,
|
1785
2016
|
expandMark,
|
1786
2017
|
getMarkType,
|
1787
2018
|
getNodeType,
|
2019
|
+
htmlFromJSON,
|
2020
|
+
htmlFromNode,
|
1788
2021
|
insertNode,
|
1789
2022
|
isAllSelection,
|
1790
2023
|
isInCodeBlock,
|
@@ -1792,7 +2025,6 @@ export {
|
|
1792
2025
|
isNodeSelection,
|
1793
2026
|
isProseMirrorNode,
|
1794
2027
|
isTextSelection,
|
1795
|
-
jsonFromElement,
|
1796
2028
|
jsonFromHTML,
|
1797
2029
|
jsonFromNode,
|
1798
2030
|
jsonFromState,
|
package/package.json
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
{
|
2
2
|
"name": "@prosekit/core",
|
3
3
|
"type": "module",
|
4
|
-
"version": "0.3.
|
4
|
+
"version": "0.3.2",
|
5
5
|
"private": false,
|
6
6
|
"author": {
|
7
7
|
"name": "ocavue",
|
@@ -42,7 +42,7 @@
|
|
42
42
|
},
|
43
43
|
"devDependencies": {
|
44
44
|
"@prosekit/dev": "*",
|
45
|
-
"tsup": "^8.0.
|
45
|
+
"tsup": "^8.0.2",
|
46
46
|
"typescript": "^5.3.3",
|
47
47
|
"vitest": "^1.2.2"
|
48
48
|
},
|