@prosekit/core 0.2.7 → 0.3.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.
- package/dist/_tsup-dts-rollup.d.ts +230 -12
- package/dist/prosekit-core.d.ts +28 -2
- package/dist/prosekit-core.js +283 -77
- package/package.json +4 -4
@@ -5,17 +5,18 @@ 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';
|
11
12
|
import type { EmptyObject } from 'type-fest';
|
12
|
-
import { InputRule } from '@prosekit/pm/inputrules';
|
13
13
|
import type { IsEqual } from 'type-fest';
|
14
14
|
import { Mark } from '@prosekit/pm/model';
|
15
15
|
import type { MarkSpec } from '@prosekit/pm/model';
|
16
16
|
import { MarkType } from '@prosekit/pm/model';
|
17
17
|
import { MarkType as MarkType_2 } from 'prosemirror-model';
|
18
18
|
import { Node as Node_2 } from 'prosemirror-model';
|
19
|
+
import type { Node as Node_3 } from '@prosekit/pm/model';
|
19
20
|
import { NodeSelection } from '@prosekit/pm/state';
|
20
21
|
import type { NodeSpec } from '@prosekit/pm/model';
|
21
22
|
import { NodeType } from '@prosekit/pm/model';
|
@@ -31,6 +32,7 @@ import type { SchemaSpec } from '@prosekit/pm/model';
|
|
31
32
|
import { Selection as Selection_2 } from '@prosekit/pm/state';
|
32
33
|
import { Selection as Selection_3 } from 'prosemirror-state';
|
33
34
|
import type { Simplify } from 'type-fest';
|
35
|
+
import type { Slice } from '@prosekit/pm/model';
|
34
36
|
import { TextSelection } from '@prosekit/pm/state';
|
35
37
|
import { Transaction } from '@prosekit/pm/state';
|
36
38
|
import type { UnionToIntersection } from 'type-fest';
|
@@ -123,6 +125,14 @@ declare interface BaseNodeViewOptions {
|
|
123
125
|
export { BaseNodeViewOptions }
|
124
126
|
export { BaseNodeViewOptions as BaseNodeViewOptions_alias_1 }
|
125
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
|
+
|
126
136
|
/**
|
127
137
|
* A utility for constructing `className` strings conditionally.
|
128
138
|
*
|
@@ -136,6 +146,8 @@ export { clsx as clsx_alias_1 }
|
|
136
146
|
|
137
147
|
export declare function collectNodes(content: NodeContent): ProseMirrorNode[];
|
138
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
|
+
|
139
151
|
export declare interface CommandApplier<Args extends any[] = any[]> {
|
140
152
|
(...args: Args): boolean;
|
141
153
|
canApply(...args: Args): boolean;
|
@@ -282,6 +294,24 @@ declare function defineBaseKeymap(options?: {
|
|
282
294
|
export { defineBaseKeymap }
|
283
295
|
export { defineBaseKeymap as defineBaseKeymap_alias_1 }
|
284
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
|
+
|
285
315
|
declare function defineCommands<T extends Record<string, CommandCreator> = Record<string, CommandCreator>>(commands: T): Extension<{
|
286
316
|
COMMAND_ARGS: {
|
287
317
|
[K in keyof T]: Parameters<T[K]>;
|
@@ -312,6 +342,42 @@ declare function defineDocChangeHandler(handler: DocChangeHandler): Extension<Ex
|
|
312
342
|
export { defineDocChangeHandler }
|
313
343
|
export { defineDocChangeHandler as defineDocChangeHandler_alias_1 }
|
314
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
|
+
|
315
381
|
/**
|
316
382
|
* Registers a event handler that is called when the editor gains or loses focus.
|
317
383
|
*
|
@@ -334,20 +400,13 @@ export { defineHistory }
|
|
334
400
|
export { defineHistory as defineHistory_alias_1 }
|
335
401
|
|
336
402
|
/**
|
337
|
-
* Defines an input rule extension.
|
338
|
-
*
|
339
|
-
* @param rule - The ProseMirror input rule to add, or an array of input rules,
|
340
|
-
* or a function that returns one or multiple input rules.
|
341
|
-
*
|
342
403
|
* @public
|
343
404
|
*
|
344
|
-
* @
|
405
|
+
* See {@link https://prosemirror.net/docs/ref/#view.EditorProps.handleKeyDown}
|
345
406
|
*/
|
346
|
-
declare function
|
347
|
-
|
348
|
-
|
349
|
-
export { defineInputRule }
|
350
|
-
export { defineInputRule as defineInputRule_alias_1 }
|
407
|
+
declare function defineKeyDownHandler(handler: KeyDownHandler): Extension<ExtensionTyping<string, string, CommandArgs>>;
|
408
|
+
export { defineKeyDownHandler }
|
409
|
+
export { defineKeyDownHandler as defineKeyDownHandler_alias_1 }
|
351
410
|
|
352
411
|
/**
|
353
412
|
* @public
|
@@ -356,6 +415,15 @@ declare function defineKeymap(keymap: Keymap): Extension;
|
|
356
415
|
export { defineKeymap }
|
357
416
|
export { defineKeymap as defineKeymap_alias_1 }
|
358
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
|
+
|
359
427
|
/**
|
360
428
|
* @public
|
361
429
|
*/
|
@@ -432,6 +500,15 @@ export declare function defineParagraphSpec(): Extension< {
|
|
432
500
|
NODES: "paragraph";
|
433
501
|
}>;
|
434
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
|
+
|
435
512
|
/**
|
436
513
|
* Adds a ProseMirror plugin to the editor.
|
437
514
|
*
|
@@ -446,6 +523,15 @@ declare function definePlugin(plugin: Plugin_2 | Plugin_2[] | ((context: {
|
|
446
523
|
export { definePlugin }
|
447
524
|
export { definePlugin as definePlugin_alias_1 }
|
448
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
|
+
|
449
535
|
/**
|
450
536
|
* @public
|
451
537
|
*/
|
@@ -455,6 +541,33 @@ NODES: "text";
|
|
455
541
|
export { defineText }
|
456
542
|
export { defineText as defineText_alias_1 }
|
457
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
|
+
|
458
571
|
/**
|
459
572
|
* Registers a event handler that is called when the editor view is unmounted.
|
460
573
|
*
|
@@ -485,6 +598,40 @@ declare type DocChangeHandler = (view: EditorView, prevState: EditorState) => vo
|
|
485
598
|
export { DocChangeHandler }
|
486
599
|
export { DocChangeHandler as DocChangeHandler_alias_1 }
|
487
600
|
|
601
|
+
/**
|
602
|
+
* @internal
|
603
|
+
*/
|
604
|
+
export declare const domEventFacet: Facet<DOMEventPayload, PluginPayload>;
|
605
|
+
|
606
|
+
/**
|
607
|
+
* A function to handle the events fired on the editable DOM element. Returns
|
608
|
+
* `true` to indicate that it handled the given event. you are responsible for
|
609
|
+
* calling `preventDefault` yourself (or not, if you want to allow the default
|
610
|
+
* behavior).
|
611
|
+
*
|
612
|
+
* @public
|
613
|
+
*/
|
614
|
+
declare type DOMEventHandler<Event extends keyof DOMEventMap = string> = (view: EditorView, event: DOMEventMap[Event]) => boolean | void;
|
615
|
+
export { DOMEventHandler }
|
616
|
+
export { DOMEventHandler as DOMEventHandler_alias_1 }
|
617
|
+
|
618
|
+
/**
|
619
|
+
* @internal
|
620
|
+
*/
|
621
|
+
export declare type DOMEventPayload = [event: string, handler: DOMEventHandler];
|
622
|
+
|
623
|
+
declare type DoubleClickHandler = (view: EditorView, pos: number, event: MouseEvent) => boolean | void;
|
624
|
+
export { DoubleClickHandler }
|
625
|
+
export { DoubleClickHandler as DoubleClickHandler_alias_1 }
|
626
|
+
|
627
|
+
declare type DoubleClickOnHandler = (view: EditorView, pos: number, node: Node_3, nodePos: number, event: MouseEvent, direct: boolean) => boolean | void;
|
628
|
+
export { DoubleClickOnHandler }
|
629
|
+
export { DoubleClickOnHandler as DoubleClickOnHandler_alias_1 }
|
630
|
+
|
631
|
+
declare type DropHandler = (view: EditorView, event: DragEvent, slice: Slice, moved: boolean) => boolean | void;
|
632
|
+
export { DropHandler }
|
633
|
+
export { DropHandler as DropHandler_alias_1 }
|
634
|
+
|
488
635
|
/**
|
489
636
|
* @public
|
490
637
|
*/
|
@@ -585,6 +732,20 @@ declare type EmptyValue = undefined | null | EmptyObject;
|
|
585
732
|
|
586
733
|
export declare type ExceptEmptyValue<T> = ConditionalExcept<T, EmptyValue>;
|
587
734
|
|
735
|
+
/**
|
736
|
+
* Expands the selection to include the entire mark at the current position.
|
737
|
+
*
|
738
|
+
* @public
|
739
|
+
*/
|
740
|
+
declare function expandMark(options: {
|
741
|
+
/**
|
742
|
+
* The type of the mark to expand.
|
743
|
+
*/
|
744
|
+
type: string | MarkType;
|
745
|
+
}): Command;
|
746
|
+
export { expandMark }
|
747
|
+
export { expandMark as expandMark_alias_1 }
|
748
|
+
|
588
749
|
/**
|
589
750
|
* @public
|
590
751
|
*/
|
@@ -771,6 +932,12 @@ declare function getNodeType(schema: Schema, type: string | NodeType): NodeType;
|
|
771
932
|
export { getNodeType }
|
772
933
|
export { getNodeType as getNodeType_alias_1 }
|
773
934
|
|
935
|
+
export declare type GroupedEntries<T extends Record<string, any>> = {
|
936
|
+
[K in keyof T]?: T[K][];
|
937
|
+
};
|
938
|
+
|
939
|
+
export declare function groupEntries<T extends Record<string, any>>(entries: ObjectEntries<T>[]): GroupedEntries<T>;
|
940
|
+
|
774
941
|
/**
|
775
942
|
* Returns a command that inserts the given node at the current selection or at
|
776
943
|
* the given position.
|
@@ -834,6 +1001,9 @@ declare function isMark(mark: unknown): mark is Mark;
|
|
834
1001
|
export { isMark }
|
835
1002
|
export { isMark as isMark_alias_1 }
|
836
1003
|
|
1004
|
+
/**
|
1005
|
+
* @internal
|
1006
|
+
*/
|
837
1007
|
export declare function isMarkActive(state: EditorState, type: string | MarkType, attrs?: Attrs | null): boolean;
|
838
1008
|
|
839
1009
|
export declare function isNodeActive(state: EditorState, type: string | NodeType, attrs?: Attrs | null): boolean;
|
@@ -897,6 +1067,10 @@ declare function jsonFromState(state: EditorState): StateJSON;
|
|
897
1067
|
export { jsonFromState }
|
898
1068
|
export { jsonFromState as jsonFromState_alias_1 }
|
899
1069
|
|
1070
|
+
declare type KeyDownHandler = (view: EditorView, event: KeyboardEvent) => boolean | void;
|
1071
|
+
export { KeyDownHandler }
|
1072
|
+
export { KeyDownHandler as KeyDownHandler_alias_1 }
|
1073
|
+
|
900
1074
|
/**
|
901
1075
|
* @public
|
902
1076
|
*/
|
@@ -920,6 +1094,10 @@ declare type KeymapPayload = Keymap;
|
|
920
1094
|
export { KeymapPayload }
|
921
1095
|
export { KeymapPayload as KeymapPayload_alias_1 }
|
922
1096
|
|
1097
|
+
declare type KeyPressHandler = (view: EditorView, event: KeyboardEvent) => boolean | void;
|
1098
|
+
export { KeyPressHandler }
|
1099
|
+
export { KeyPressHandler as KeyPressHandler_alias_1 }
|
1100
|
+
|
923
1101
|
/**
|
924
1102
|
* @public
|
925
1103
|
*/
|
@@ -1097,8 +1275,27 @@ declare const OBJECT_REPLACEMENT_CHARACTER = "\uFFFC";
|
|
1097
1275
|
export { OBJECT_REPLACEMENT_CHARACTER }
|
1098
1276
|
export { OBJECT_REPLACEMENT_CHARACTER as OBJECT_REPLACEMENT_CHARACTER_alias_1 }
|
1099
1277
|
|
1278
|
+
/**
|
1279
|
+
* @internal
|
1280
|
+
*
|
1281
|
+
* @example
|
1282
|
+
*
|
1283
|
+
* ```
|
1284
|
+
* type MyObject = { a: 1; b: 'B' }
|
1285
|
+
* type MyEntries = ObjectEntries<MyObject>
|
1286
|
+
* // ^ ["a", 1] | ["b", "B"]
|
1287
|
+
*
|
1288
|
+
*/
|
1289
|
+
export declare type ObjectEntries<T extends Record<string, any>> = {
|
1290
|
+
[K in keyof T]: [K, T[K]];
|
1291
|
+
}[keyof T];
|
1292
|
+
|
1100
1293
|
export declare function objectEqual<T>(a: T, b: T): boolean;
|
1101
1294
|
|
1295
|
+
declare type PasteHandler = (view: EditorView, event: ClipboardEvent, slice: Slice) => boolean | void;
|
1296
|
+
export { PasteHandler }
|
1297
|
+
export { PasteHandler as PasteHandler_alias_1 }
|
1298
|
+
|
1102
1299
|
declare type Payload = unknown;
|
1103
1300
|
|
1104
1301
|
export declare type Payloads = PayloadTuple[];
|
@@ -1176,6 +1373,10 @@ export declare const schemaFacet: Facet<SchemaPayload, SchemaPayload>;
|
|
1176
1373
|
|
1177
1374
|
export declare type SchemaPayload = SchemaSpec;
|
1178
1375
|
|
1376
|
+
declare type ScrollToSelectionHandler = (view: EditorView) => boolean;
|
1377
|
+
export { ScrollToSelectionHandler }
|
1378
|
+
export { ScrollToSelectionHandler as ScrollToSelectionHandler_alias_1 }
|
1379
|
+
|
1179
1380
|
/**
|
1180
1381
|
* Returns a command that selects the whole document.
|
1181
1382
|
*
|
@@ -1238,6 +1439,11 @@ export { setNodeAttrs as setNodeAttrs_alias_1 }
|
|
1238
1439
|
|
1239
1440
|
export declare function setSelectionAround(tr: Transaction, pos: number): void;
|
1240
1441
|
|
1442
|
+
/**
|
1443
|
+
* @internal
|
1444
|
+
*/
|
1445
|
+
export declare type Setter<T> = (value: T) => void;
|
1446
|
+
|
1241
1447
|
/**
|
1242
1448
|
* @internal
|
1243
1449
|
*/
|
@@ -1289,6 +1495,10 @@ export declare type StatePayload = (ctx: {
|
|
1289
1495
|
schema: Schema;
|
1290
1496
|
}) => EditorStateConfig;
|
1291
1497
|
|
1498
|
+
declare type TextInputHandler = (view: EditorView, from: number, to: number, text: string) => boolean | void;
|
1499
|
+
export { TextInputHandler }
|
1500
|
+
export { TextInputHandler as TextInputHandler_alias_1 }
|
1501
|
+
|
1292
1502
|
export declare type ToCommandApplier<T extends CommandArgs> = {
|
1293
1503
|
[K in keyof T]: CommandApplier<T[K]>;
|
1294
1504
|
};
|
@@ -1326,6 +1536,14 @@ declare function toggleNode({ type, attrs, }: {
|
|
1326
1536
|
export { toggleNode }
|
1327
1537
|
export { toggleNode as toggleNode_alias_1 }
|
1328
1538
|
|
1539
|
+
declare type TripleClickHandler = (view: EditorView, pos: number, event: MouseEvent) => boolean | void;
|
1540
|
+
export { TripleClickHandler }
|
1541
|
+
export { TripleClickHandler as TripleClickHandler_alias_1 }
|
1542
|
+
|
1543
|
+
declare type TripleClickOnHandler = (view: EditorView, pos: number, node: Node_3, nodePos: number, event: MouseEvent, direct: boolean) => boolean | void;
|
1544
|
+
export { TripleClickOnHandler }
|
1545
|
+
export { TripleClickOnHandler as TripleClickOnHandler_alias_1 }
|
1546
|
+
|
1329
1547
|
declare type Tuple5<T> = [T, T, T, T, T];
|
1330
1548
|
|
1331
1549
|
/**
|
package/dist/prosekit-core.d.ts
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
export { addMark } from './_tsup-dts-rollup';
|
2
|
+
export { expandMark } from './_tsup-dts-rollup';
|
2
3
|
export { insertNode } from './_tsup-dts-rollup';
|
3
4
|
export { removeMark } from './_tsup-dts-rollup';
|
4
5
|
export { setBlockType } from './_tsup-dts-rollup';
|
@@ -10,8 +11,8 @@ export { createEditor } from './_tsup-dts-rollup';
|
|
10
11
|
export { EditorOptions } from './_tsup-dts-rollup';
|
11
12
|
export { union } from './_tsup-dts-rollup';
|
12
13
|
export { withPriority } from './_tsup-dts-rollup';
|
13
|
-
export { ProseKitError_alias_1 as ProseKitError } from './_tsup-dts-rollup';
|
14
14
|
export { EditorNotFoundError_alias_1 as EditorNotFoundError } from './_tsup-dts-rollup';
|
15
|
+
export { ProseKitError_alias_1 as ProseKitError } from './_tsup-dts-rollup';
|
15
16
|
export { defineBaseCommands } from './_tsup-dts-rollup';
|
16
17
|
export { defineCommands } from './_tsup-dts-rollup';
|
17
18
|
export { defineDefaultState } from './_tsup-dts-rollup';
|
@@ -19,6 +20,32 @@ export { DefaultStateOptions } from './_tsup-dts-rollup';
|
|
19
20
|
export { defineDoc } from './_tsup-dts-rollup';
|
20
21
|
export { defineDocChangeHandler } from './_tsup-dts-rollup';
|
21
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';
|
22
49
|
export { defineFocusChangeHandler } from './_tsup-dts-rollup';
|
23
50
|
export { FocusChangeHandler } from './_tsup-dts-rollup';
|
24
51
|
export { defineMountHandler } from './_tsup-dts-rollup';
|
@@ -28,7 +55,6 @@ export { MountHandler } from './_tsup-dts-rollup';
|
|
28
55
|
export { UnmountHandler } from './_tsup-dts-rollup';
|
29
56
|
export { UpdateHandler } from './_tsup-dts-rollup';
|
30
57
|
export { defineHistory } from './_tsup-dts-rollup';
|
31
|
-
export { defineInputRule } from './_tsup-dts-rollup';
|
32
58
|
export { defineBaseKeymap } from './_tsup-dts-rollup';
|
33
59
|
export { defineKeymap } from './_tsup-dts-rollup';
|
34
60
|
export { keymapFacet } from './_tsup-dts-rollup';
|
package/dist/prosekit-core.js
CHANGED
@@ -43,6 +43,59 @@ function addMark(options) {
|
|
43
43
|
};
|
44
44
|
}
|
45
45
|
|
46
|
+
// src/commands/expand-mark.ts
|
47
|
+
import { TextSelection } from "@prosekit/pm/state";
|
48
|
+
function expandMark(options) {
|
49
|
+
return (state, dispatch) => {
|
50
|
+
const markType = getMarkType(state.schema, options.type);
|
51
|
+
const predicate = (mark) => mark.type === markType;
|
52
|
+
const from = expandMarkBefore(state.selection.$from, predicate);
|
53
|
+
const to = expandMarkAfter(state.selection.$to, predicate);
|
54
|
+
if (from === state.selection.from && to === state.selection.to) {
|
55
|
+
return false;
|
56
|
+
}
|
57
|
+
if (dispatch) {
|
58
|
+
dispatch(state.tr.setSelection(TextSelection.create(state.doc, from, to)));
|
59
|
+
}
|
60
|
+
return true;
|
61
|
+
};
|
62
|
+
}
|
63
|
+
function expandMarkBefore($pos, predicate) {
|
64
|
+
const { parent } = $pos;
|
65
|
+
if (!$pos.marks().some(predicate)) {
|
66
|
+
return $pos.pos;
|
67
|
+
}
|
68
|
+
const index = $pos.index();
|
69
|
+
let boundaryIndex = index;
|
70
|
+
for (let i = index; i >= 0; i--) {
|
71
|
+
const node = parent.child(i);
|
72
|
+
if (node.marks.some(predicate)) {
|
73
|
+
boundaryIndex = i;
|
74
|
+
} else {
|
75
|
+
break;
|
76
|
+
}
|
77
|
+
}
|
78
|
+
return $pos.posAtIndex(boundaryIndex);
|
79
|
+
}
|
80
|
+
function expandMarkAfter($pos, predicate) {
|
81
|
+
const { parent } = $pos;
|
82
|
+
if (!$pos.marks().some(predicate)) {
|
83
|
+
return $pos.pos;
|
84
|
+
}
|
85
|
+
const index = Math.max(0, $pos.indexAfter() - 1);
|
86
|
+
const childCount = parent.childCount;
|
87
|
+
let boundaryIndex = index;
|
88
|
+
for (let i = index; i < childCount; i++) {
|
89
|
+
const node = parent.child(i);
|
90
|
+
if (node.marks.some(predicate)) {
|
91
|
+
boundaryIndex = i;
|
92
|
+
} else {
|
93
|
+
break;
|
94
|
+
}
|
95
|
+
}
|
96
|
+
return $pos.posAtIndex(boundaryIndex) + parent.child(boundaryIndex).nodeSize;
|
97
|
+
}
|
98
|
+
|
46
99
|
// src/commands/insert-node.ts
|
47
100
|
import "@prosekit/pm/state";
|
48
101
|
import { insertPoint } from "@prosekit/pm/transform";
|
@@ -61,11 +114,11 @@ function getNodeType(schema, type) {
|
|
61
114
|
}
|
62
115
|
|
63
116
|
// src/utils/set-selection-around.ts
|
64
|
-
import { TextSelection } from "@prosekit/pm/state";
|
117
|
+
import { TextSelection as TextSelection2 } from "@prosekit/pm/state";
|
65
118
|
function setSelectionAround(tr, pos) {
|
66
119
|
const docSize = tr.doc.content.size;
|
67
120
|
const $pos = tr.doc.resolve(pos > docSize ? docSize : pos < 0 ? 0 : pos);
|
68
|
-
const selection =
|
121
|
+
const selection = TextSelection2.between($pos, $pos);
|
69
122
|
tr.setSelection(selection);
|
70
123
|
}
|
71
124
|
|
@@ -115,13 +168,13 @@ function removeMark(options) {
|
|
115
168
|
import "@prosekit/pm/state";
|
116
169
|
|
117
170
|
// src/utils/get-custom-selection.ts
|
118
|
-
import { TextSelection as
|
171
|
+
import { TextSelection as TextSelection3 } from "@prosekit/pm/state";
|
119
172
|
function getCustomSelection(state, from, to) {
|
120
173
|
const pos = from != null ? from : to;
|
121
174
|
if (pos != null) {
|
122
175
|
const $from = state.doc.resolve(from != null ? from : pos);
|
123
176
|
const $to = state.doc.resolve(to != null ? to : pos);
|
124
|
-
return
|
177
|
+
return TextSelection3.between($from, $to);
|
125
178
|
}
|
126
179
|
return state.selection;
|
127
180
|
}
|
@@ -696,12 +749,25 @@ function updateExtension(prevInputs, prevConverters, extension, mode) {
|
|
696
749
|
// src/editor/builder.ts
|
697
750
|
import "@prosekit/pm/model";
|
698
751
|
|
752
|
+
// src/utils/is-mark-active.ts
|
753
|
+
function isMarkActive(state, type, attrs) {
|
754
|
+
const { from, $from, to, empty } = state.selection;
|
755
|
+
const markType = getMarkType(state.schema, type);
|
756
|
+
if (empty) {
|
757
|
+
const mark = attrs ? markType.create(attrs) : markType;
|
758
|
+
return !!mark.isInSet(state.storedMarks || $from.marks());
|
759
|
+
} else {
|
760
|
+
const markOrType = attrs ? markType.create(attrs) : markType;
|
761
|
+
return state.doc.rangeHasMark(from, to, markOrType);
|
762
|
+
}
|
763
|
+
}
|
764
|
+
|
699
765
|
// src/utils/type-assertion.ts
|
700
766
|
import { Mark, ProseMirrorNode } from "@prosekit/pm/model";
|
701
767
|
import {
|
702
768
|
AllSelection,
|
703
769
|
NodeSelection,
|
704
|
-
TextSelection as
|
770
|
+
TextSelection as TextSelection4
|
705
771
|
} from "@prosekit/pm/state";
|
706
772
|
function isProseMirrorNode(node) {
|
707
773
|
return node instanceof ProseMirrorNode;
|
@@ -710,7 +776,7 @@ function isMark(mark) {
|
|
710
776
|
return mark instanceof Mark;
|
711
777
|
}
|
712
778
|
function isTextSelection(sel) {
|
713
|
-
return sel instanceof
|
779
|
+
return sel instanceof TextSelection4;
|
714
780
|
}
|
715
781
|
function isNodeSelection(sel) {
|
716
782
|
return sel instanceof NodeSelection;
|
@@ -719,28 +785,6 @@ function isAllSelection(sel) {
|
|
719
785
|
return sel instanceof AllSelection;
|
720
786
|
}
|
721
787
|
|
722
|
-
// src/utils/is-mark-active.ts
|
723
|
-
function isMarkActive(state, type, attrs) {
|
724
|
-
const markType = getMarkType(state.schema, type);
|
725
|
-
const mark = attrs ? markType.create(attrs) : markType;
|
726
|
-
const { from, $from, to, empty } = state.selection;
|
727
|
-
if (empty) {
|
728
|
-
return hasMark(state.storedMarks || $from.marks(), mark);
|
729
|
-
} else {
|
730
|
-
return state.doc.rangeHasMark(from, to, mark);
|
731
|
-
}
|
732
|
-
}
|
733
|
-
function hasMark(marks, mark) {
|
734
|
-
if (marks.length === 0) {
|
735
|
-
return false;
|
736
|
-
}
|
737
|
-
if (isMark(mark)) {
|
738
|
-
return marks.some((m) => m.eq(mark));
|
739
|
-
} else {
|
740
|
-
return marks.some((m) => m.type === mark);
|
741
|
-
}
|
742
|
-
}
|
743
|
-
|
744
788
|
// src/editor/builder.ts
|
745
789
|
function createNodeBuilder(getState, type) {
|
746
790
|
const builder = (...args) => buildNode(type, args);
|
@@ -1398,26 +1442,201 @@ function defineDocChangeHandler(handler) {
|
|
1398
1442
|
});
|
1399
1443
|
}
|
1400
1444
|
|
1401
|
-
// src/extensions/events/
|
1445
|
+
// src/extensions/events/dom-event.ts
|
1402
1446
|
import { PluginKey as PluginKey2, ProseMirrorPlugin as ProseMirrorPlugin2 } from "@prosekit/pm/state";
|
1403
|
-
|
1404
|
-
|
1405
|
-
|
1406
|
-
|
1407
|
-
|
1408
|
-
|
1409
|
-
|
1410
|
-
|
1411
|
-
|
1412
|
-
|
1413
|
-
|
1414
|
-
|
1415
|
-
|
1447
|
+
|
1448
|
+
// src/utils/combine-event-handlers.ts
|
1449
|
+
function combineEventHandlers() {
|
1450
|
+
let _handlers = [];
|
1451
|
+
function setHandlers(handlers) {
|
1452
|
+
_handlers = handlers;
|
1453
|
+
}
|
1454
|
+
function combinedEventHandler(...args) {
|
1455
|
+
for (const handler of _handlers) {
|
1456
|
+
if (handler(...args)) {
|
1457
|
+
return true;
|
1458
|
+
}
|
1459
|
+
}
|
1460
|
+
return false;
|
1461
|
+
}
|
1462
|
+
return [setHandlers, combinedEventHandler];
|
1463
|
+
}
|
1464
|
+
|
1465
|
+
// src/utils/group-entries.ts
|
1466
|
+
function groupEntries(entries) {
|
1467
|
+
const map = {};
|
1468
|
+
for (const [key, value] of entries) {
|
1469
|
+
const values = map[key];
|
1470
|
+
if (!values) {
|
1471
|
+
map[key] = [value];
|
1472
|
+
} else {
|
1473
|
+
values.push(value);
|
1474
|
+
}
|
1475
|
+
}
|
1476
|
+
return map;
|
1477
|
+
}
|
1478
|
+
|
1479
|
+
// src/extensions/events/dom-event.ts
|
1480
|
+
function defineDOMEventHandler(event, handler) {
|
1481
|
+
return domEventFacet.extension([
|
1482
|
+
[event, handler]
|
1483
|
+
]);
|
1484
|
+
}
|
1485
|
+
var domEventFacet = Facet.define({
|
1486
|
+
converter: () => {
|
1487
|
+
const setHandlersMap = {};
|
1488
|
+
const combinedHandlerMap = {};
|
1489
|
+
const update = (payloads) => {
|
1490
|
+
let hasNewEvent = false;
|
1491
|
+
for (const [event] of payloads) {
|
1492
|
+
if (!setHandlersMap[event]) {
|
1493
|
+
hasNewEvent = true;
|
1494
|
+
const [setHandlers, combinedHandler] = combineEventHandlers();
|
1495
|
+
setHandlersMap[event] = setHandlers;
|
1496
|
+
combinedHandlerMap[event] = combinedHandler;
|
1416
1497
|
}
|
1417
|
-
}
|
1498
|
+
}
|
1499
|
+
const map = groupEntries(payloads);
|
1500
|
+
for (const [event, handlers] of Object.entries(map)) {
|
1501
|
+
const setHandlers = setHandlersMap[event];
|
1502
|
+
setHandlers(handlers != null ? handlers : []);
|
1503
|
+
}
|
1504
|
+
if (hasNewEvent) {
|
1505
|
+
return new ProseMirrorPlugin2({
|
1506
|
+
key: new PluginKey2("prosekit-dom-event-handler"),
|
1507
|
+
props: { handleDOMEvents: combinedHandlerMap }
|
1508
|
+
});
|
1509
|
+
} else {
|
1510
|
+
return null;
|
1511
|
+
}
|
1512
|
+
};
|
1513
|
+
return {
|
1514
|
+
create: (payloads) => {
|
1515
|
+
const plugin = update(payloads);
|
1516
|
+
return plugin ? () => plugin : () => [];
|
1517
|
+
},
|
1518
|
+
update: (payloads) => {
|
1519
|
+
const plugin = update(payloads);
|
1520
|
+
return plugin ? () => plugin : null;
|
1521
|
+
}
|
1522
|
+
};
|
1523
|
+
},
|
1524
|
+
next: pluginFacet,
|
1525
|
+
singleton: true
|
1526
|
+
});
|
1527
|
+
|
1528
|
+
// src/extensions/events/editor-event.ts
|
1529
|
+
import { PluginKey as PluginKey3, ProseMirrorPlugin as ProseMirrorPlugin3 } from "@prosekit/pm/state";
|
1530
|
+
function defineKeyDownHandler(handler) {
|
1531
|
+
return editorEventFacet.extension([["keyDown", handler]]);
|
1532
|
+
}
|
1533
|
+
function defineKeyPressHandler(handler) {
|
1534
|
+
return editorEventFacet.extension([["keyPress", handler]]);
|
1535
|
+
}
|
1536
|
+
function defineTextInputHandler(handler) {
|
1537
|
+
return editorEventFacet.extension([["textInput", handler]]);
|
1538
|
+
}
|
1539
|
+
function defineClickOnHandler(handler) {
|
1540
|
+
return editorEventFacet.extension([["clickOn", handler]]);
|
1541
|
+
}
|
1542
|
+
function defineClickHandler(handler) {
|
1543
|
+
return editorEventFacet.extension([["click", handler]]);
|
1544
|
+
}
|
1545
|
+
function defineDoubleClickOnHandler(handler) {
|
1546
|
+
return editorEventFacet.extension([["doubleClickOn", handler]]);
|
1547
|
+
}
|
1548
|
+
function defineDoubleClickHandler(handler) {
|
1549
|
+
return editorEventFacet.extension([["doubleClick", handler]]);
|
1550
|
+
}
|
1551
|
+
function defineTripleClickOnHandler(handler) {
|
1552
|
+
return editorEventFacet.extension([["tripleClickOn", handler]]);
|
1553
|
+
}
|
1554
|
+
function defineTripleClickHandler(handler) {
|
1555
|
+
return editorEventFacet.extension([["tripleClick", handler]]);
|
1556
|
+
}
|
1557
|
+
function definePasteHandler(handler) {
|
1558
|
+
return editorEventFacet.extension([["paste", handler]]);
|
1559
|
+
}
|
1560
|
+
function defineDropHandler(handler) {
|
1561
|
+
return editorEventFacet.extension([["drop", handler]]);
|
1562
|
+
}
|
1563
|
+
function defineScrollToSelectionHandler(handler) {
|
1564
|
+
return editorEventFacet.extension([["scrollToSelection", handler]]);
|
1565
|
+
}
|
1566
|
+
var editorEventFacet = Facet.define({
|
1567
|
+
converter: () => {
|
1568
|
+
const [update, plugin] = setupEditorEventPlugin();
|
1569
|
+
return {
|
1570
|
+
create: (entries) => {
|
1571
|
+
update(entries);
|
1572
|
+
return () => plugin;
|
1573
|
+
},
|
1574
|
+
update: (entries) => {
|
1575
|
+
update(entries);
|
1576
|
+
return null;
|
1577
|
+
}
|
1578
|
+
};
|
1579
|
+
},
|
1580
|
+
next: pluginFacet,
|
1581
|
+
singleton: true
|
1582
|
+
});
|
1583
|
+
function setupEditorEventPlugin() {
|
1584
|
+
const [setKeyDownHandlers, handleKeyDown] = combineEventHandlers();
|
1585
|
+
const [setKeyPressHandlers, handleKeyPress] = combineEventHandlers();
|
1586
|
+
const [setTextInputHandlers, handleTextInput] = combineEventHandlers();
|
1587
|
+
const [setClickOnHandlers, handleClickOn] = combineEventHandlers();
|
1588
|
+
const [setClickHandlers, handleClick] = combineEventHandlers();
|
1589
|
+
const [setDoubleClickOnHandlers, handleDoubleClickOn] = combineEventHandlers();
|
1590
|
+
const [setDoubleClickHandlers, handleDoubleClick] = combineEventHandlers();
|
1591
|
+
const [setTripleClickOnHandlers, handleTripleClickOn] = combineEventHandlers();
|
1592
|
+
const [setTripleClickHandlers, handleTripleClick] = combineEventHandlers();
|
1593
|
+
const [setPasteHandlers, handlePaste] = combineEventHandlers();
|
1594
|
+
const [setDropHandlers, handleDrop] = combineEventHandlers();
|
1595
|
+
const [setScrollToSelectionHandlers, handleScrollToSelection] = combineEventHandlers();
|
1596
|
+
const update = (entries) => {
|
1597
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l;
|
1598
|
+
const map = groupEntries(entries);
|
1599
|
+
setKeyDownHandlers((_a = map.keyDown) != null ? _a : []);
|
1600
|
+
setKeyPressHandlers((_b = map.keyPress) != null ? _b : []);
|
1601
|
+
setTextInputHandlers((_c = map.textInput) != null ? _c : []);
|
1602
|
+
setClickOnHandlers((_d = map.clickOn) != null ? _d : []);
|
1603
|
+
setClickHandlers((_e = map.click) != null ? _e : []);
|
1604
|
+
setDoubleClickOnHandlers((_f = map.doubleClickOn) != null ? _f : []);
|
1605
|
+
setDoubleClickHandlers((_g = map.doubleClick) != null ? _g : []);
|
1606
|
+
setTripleClickOnHandlers((_h = map.tripleClickOn) != null ? _h : []);
|
1607
|
+
setTripleClickHandlers((_i = map.tripleClick) != null ? _i : []);
|
1608
|
+
setPasteHandlers((_j = map.paste) != null ? _j : []);
|
1609
|
+
setDropHandlers((_k = map.drop) != null ? _k : []);
|
1610
|
+
setScrollToSelectionHandlers((_l = map.scrollToSelection) != null ? _l : []);
|
1611
|
+
};
|
1612
|
+
const plugin = new ProseMirrorPlugin3({
|
1613
|
+
key: new PluginKey3("prosekit-editor-handler"),
|
1614
|
+
props: {
|
1615
|
+
handleKeyDown,
|
1616
|
+
handleKeyPress,
|
1617
|
+
handleTextInput,
|
1618
|
+
handleClickOn,
|
1619
|
+
handleClick,
|
1620
|
+
handleDoubleClickOn,
|
1621
|
+
handleDoubleClick,
|
1622
|
+
handleTripleClickOn,
|
1623
|
+
handleTripleClick,
|
1624
|
+
handlePaste,
|
1625
|
+
handleDrop,
|
1626
|
+
handleScrollToSelection
|
1418
1627
|
}
|
1419
1628
|
});
|
1420
|
-
return
|
1629
|
+
return [update, plugin];
|
1630
|
+
}
|
1631
|
+
|
1632
|
+
// src/extensions/events/focus.ts
|
1633
|
+
function defineFocusChangeHandler(handler) {
|
1634
|
+
const handleFocus = () => handler(true);
|
1635
|
+
const handleBlur = () => handler(false);
|
1636
|
+
return domEventFacet.extension([
|
1637
|
+
["focus", handleFocus],
|
1638
|
+
["blur", handleBlur]
|
1639
|
+
]);
|
1421
1640
|
}
|
1422
1641
|
|
1423
1642
|
// src/extensions/history.ts
|
@@ -1429,7 +1648,7 @@ var isMac = typeof navigator !== "undefined" ? /Mac|iP(hone|[ao]d)/.test(navigat
|
|
1429
1648
|
// src/extensions/keymap.ts
|
1430
1649
|
import { baseKeymap, chainCommands } from "@prosekit/pm/commands";
|
1431
1650
|
import { keydownHandler } from "@prosekit/pm/keymap";
|
1432
|
-
import { Plugin as Plugin3, PluginKey as
|
1651
|
+
import { Plugin as Plugin3, PluginKey as PluginKey4 } from "@prosekit/pm/state";
|
1433
1652
|
function defineKeymap(keymap) {
|
1434
1653
|
return keymapFacet.extension([keymap]);
|
1435
1654
|
}
|
@@ -1480,7 +1699,7 @@ function mergeKeymaps(keymaps) {
|
|
1480
1699
|
])
|
1481
1700
|
);
|
1482
1701
|
}
|
1483
|
-
var keymapPluginKey = new
|
1702
|
+
var keymapPluginKey = new PluginKey4("prosekit-keymap");
|
1484
1703
|
|
1485
1704
|
// src/extensions/history.ts
|
1486
1705
|
function defineHistory() {
|
@@ -1501,32 +1720,6 @@ function defineHistory() {
|
|
1501
1720
|
]);
|
1502
1721
|
}
|
1503
1722
|
|
1504
|
-
// src/extensions/input-rules.ts
|
1505
|
-
import { InputRule, inputRules } from "@prosekit/pm/inputrules";
|
1506
|
-
import "@prosekit/pm/model";
|
1507
|
-
import "@prosekit/pm/state";
|
1508
|
-
function defineInputRule(rule) {
|
1509
|
-
if (rule instanceof InputRule) {
|
1510
|
-
return inputRuleFacet.extension([() => rule]);
|
1511
|
-
}
|
1512
|
-
if (Array.isArray(rule) && rule.every((r) => r instanceof InputRule)) {
|
1513
|
-
return inputRuleFacet.extension([() => rule]);
|
1514
|
-
}
|
1515
|
-
if (typeof rule === "function") {
|
1516
|
-
return inputRuleFacet.extension([rule]);
|
1517
|
-
}
|
1518
|
-
throw new TypeError("Invalid input rule");
|
1519
|
-
}
|
1520
|
-
var inputRuleFacet = Facet.define({
|
1521
|
-
convert: (inputs) => {
|
1522
|
-
return (context) => {
|
1523
|
-
const rules = inputs.flatMap((callback) => callback(context));
|
1524
|
-
return [inputRules({ rules })];
|
1525
|
-
};
|
1526
|
-
},
|
1527
|
-
next: pluginFacet
|
1528
|
-
});
|
1529
|
-
|
1530
1723
|
// src/extensions/mark-spec.ts
|
1531
1724
|
function defineMarkSpec(options) {
|
1532
1725
|
const payload = [options, void 0];
|
@@ -1619,7 +1812,7 @@ var markSpecFacet = Facet.define({
|
|
1619
1812
|
});
|
1620
1813
|
|
1621
1814
|
// src/extensions/node-view.ts
|
1622
|
-
import { ProseMirrorPlugin as
|
1815
|
+
import { ProseMirrorPlugin as ProseMirrorPlugin4 } from "@prosekit/pm/state";
|
1623
1816
|
import "@prosekit/pm/view";
|
1624
1817
|
function defineNodeView(options) {
|
1625
1818
|
return nodeViewFacet.extension([options]);
|
@@ -1632,13 +1825,13 @@ var nodeViewFacet = Facet.define({
|
|
1632
1825
|
nodeViews[input.name] = input.constructor;
|
1633
1826
|
}
|
1634
1827
|
}
|
1635
|
-
return () => [new
|
1828
|
+
return () => [new ProseMirrorPlugin4({ props: { nodeViews } })];
|
1636
1829
|
},
|
1637
1830
|
next: pluginFacet
|
1638
1831
|
});
|
1639
1832
|
|
1640
1833
|
// src/extensions/node-view-effect.ts
|
1641
|
-
import { ProseMirrorPlugin as
|
1834
|
+
import { ProseMirrorPlugin as ProseMirrorPlugin5 } from "@prosekit/pm/state";
|
1642
1835
|
import "@prosekit/pm/view";
|
1643
1836
|
function defineNodeViewFactory(options) {
|
1644
1837
|
return nodeViewFactoryFacet.extension([options]);
|
@@ -1666,7 +1859,7 @@ var nodeViewFactoryFacet = Facet.define({
|
|
1666
1859
|
nodeViews[name] = factory(args);
|
1667
1860
|
}
|
1668
1861
|
}
|
1669
|
-
return () => [new
|
1862
|
+
return () => [new ProseMirrorPlugin5({ props: { nodeViews } })];
|
1670
1863
|
},
|
1671
1864
|
next: pluginFacet
|
1672
1865
|
});
|
@@ -1750,13 +1943,20 @@ export {
|
|
1750
1943
|
defaultBlockAt,
|
1751
1944
|
defineBaseCommands,
|
1752
1945
|
defineBaseKeymap,
|
1946
|
+
defineClickHandler,
|
1947
|
+
defineClickOnHandler,
|
1753
1948
|
defineCommands,
|
1949
|
+
defineDOMEventHandler,
|
1754
1950
|
defineDefaultState,
|
1755
1951
|
defineDoc,
|
1756
1952
|
defineDocChangeHandler,
|
1953
|
+
defineDoubleClickHandler,
|
1954
|
+
defineDoubleClickOnHandler,
|
1955
|
+
defineDropHandler,
|
1757
1956
|
defineFocusChangeHandler,
|
1758
1957
|
defineHistory,
|
1759
|
-
|
1958
|
+
defineKeyDownHandler,
|
1959
|
+
defineKeyPressHandler,
|
1760
1960
|
defineKeymap,
|
1761
1961
|
defineMarkAttr,
|
1762
1962
|
defineMarkSpec,
|
@@ -1766,10 +1966,16 @@ export {
|
|
1766
1966
|
defineNodeView,
|
1767
1967
|
defineNodeViewFactory,
|
1768
1968
|
defineParagraph,
|
1969
|
+
definePasteHandler,
|
1769
1970
|
definePlugin,
|
1971
|
+
defineScrollToSelectionHandler,
|
1770
1972
|
defineText,
|
1973
|
+
defineTextInputHandler,
|
1974
|
+
defineTripleClickHandler,
|
1975
|
+
defineTripleClickOnHandler,
|
1771
1976
|
defineUnmountHandler,
|
1772
1977
|
defineUpdateHandler,
|
1978
|
+
expandMark,
|
1773
1979
|
getMarkType,
|
1774
1980
|
getNodeType,
|
1775
1981
|
insertNode,
|
package/package.json
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
{
|
2
2
|
"name": "@prosekit/core",
|
3
3
|
"type": "module",
|
4
|
-
"version": "0.
|
4
|
+
"version": "0.3.1",
|
5
5
|
"private": false,
|
6
6
|
"author": {
|
7
7
|
"name": "ocavue",
|
@@ -38,13 +38,13 @@
|
|
38
38
|
"@prosekit/pm": "^0.1.1",
|
39
39
|
"clsx": "^2.1.0",
|
40
40
|
"orderedmap": "^2.1.1",
|
41
|
-
"type-fest": "^4.10.
|
41
|
+
"type-fest": "^4.10.2"
|
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
|
-
"vitest": "^1.2.
|
47
|
+
"vitest": "^1.2.2"
|
48
48
|
},
|
49
49
|
"scripts": {
|
50
50
|
"build:tsup": "tsup",
|