@prosekit/core 0.7.3 → 0.7.5
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 +355 -77
- package/dist/{chunk-UDQXAK7F.js → chunk-M267LRMB.js} +54 -27
- package/dist/prosekit-core-test.js +5 -13
- package/dist/prosekit-core.d.ts +17 -1
- package/dist/prosekit-core.js +12 -12
- package/package.json +5 -5
@@ -1,5 +1,6 @@
|
|
1
1
|
import { AllSelection } from '@prosekit/pm/state';
|
2
2
|
import { Attrs } from '@prosekit/pm/model';
|
3
|
+
import { Attrs as Attrs_2 } from 'prosemirror-model';
|
3
4
|
import { Command } from '@prosekit/pm/state';
|
4
5
|
import type { ContentMatch } from '@prosekit/pm/model';
|
5
6
|
import { config as default_alias_1 } from '@prosekit/dev/config-vitest';
|
@@ -19,8 +20,8 @@ import { NodeSelection } from '@prosekit/pm/state';
|
|
19
20
|
import type { NodeSpec } from '@prosekit/pm/model';
|
20
21
|
import { NodeType } from '@prosekit/pm/model';
|
21
22
|
import { NodeType as NodeType_2 } from 'prosemirror-model';
|
22
|
-
import { NodeView } from '@prosekit/pm/view';
|
23
|
-
import { NodeViewConstructor } from '@prosekit/pm/view';
|
23
|
+
import type { NodeView } from '@prosekit/pm/view';
|
24
|
+
import type { NodeViewConstructor } from '@prosekit/pm/view';
|
24
25
|
import { Options } from 'tsup';
|
25
26
|
import type { ParseOptions } from '@prosekit/pm/model';
|
26
27
|
import { Plugin as Plugin_2 } from '@prosekit/pm/state';
|
@@ -75,6 +76,15 @@ declare interface AddMarkOptions {
|
|
75
76
|
export { AddMarkOptions }
|
76
77
|
export { AddMarkOptions as AddMarkOptions_alias_1 }
|
77
78
|
|
79
|
+
/**
|
80
|
+
* An object holding the attributes of a node.
|
81
|
+
|
82
|
+
* @public
|
83
|
+
*/
|
84
|
+
declare type AnyAttrs = Attrs;
|
85
|
+
export { AnyAttrs }
|
86
|
+
export { AnyAttrs as AnyAttrs_alias_1 }
|
87
|
+
|
78
88
|
export declare function applyAction(operator: Action): Command;
|
79
89
|
|
80
90
|
export declare const applyMarkForTest: ApplyMarkFunction;
|
@@ -106,8 +116,38 @@ export { assert as assert_alias_1 }
|
|
106
116
|
*/
|
107
117
|
export declare function assertTypeEqual<T, U>(_val: IsEqual<T, U>): void;
|
108
118
|
|
119
|
+
/**
|
120
|
+
* Utility function assert that two types are equal in tests.
|
121
|
+
*/
|
122
|
+
export declare function assertTypeEqual_alias_1<T, U>(_val: IsEqual<T, U>): void;
|
123
|
+
|
109
124
|
export declare function attrsMatch(nodeOrMark: ProseMirrorNode | Mark, attrs: Attrs): boolean;
|
110
125
|
|
126
|
+
/**
|
127
|
+
* @public
|
128
|
+
*/
|
129
|
+
declare type AttrSpec<AttrType = any> = {
|
130
|
+
/**
|
131
|
+
* The default value for this attribute, to use when no explicit value is
|
132
|
+
* provided. Attributes that have no default must be provided whenever a node
|
133
|
+
* or mark of a type that has them is created.
|
134
|
+
*/
|
135
|
+
default?: AttrType;
|
136
|
+
/**
|
137
|
+
* A function or type name used to validate values of this attribute. This
|
138
|
+
* will be used when deserializing the attribute from JSON, and when running
|
139
|
+
* [`Node.check`](https://prosemirror.net/docs/ref/#model.Node.check). When a
|
140
|
+
* function, it should raise an exception if the value isn't of the expected
|
141
|
+
* type or shape. When a string, it should be a `|`-separated string of
|
142
|
+
* primitive types (`"number"`, `"string"`, `"boolean"`, `"null"`, and
|
143
|
+
* `"undefined"`), and the library will raise an error when the value is not
|
144
|
+
* one of those types.
|
145
|
+
*/
|
146
|
+
validate?: string | ((value: unknown) => void);
|
147
|
+
};
|
148
|
+
export { AttrSpec }
|
149
|
+
export { AttrSpec as AttrSpec_alias_1 }
|
150
|
+
|
111
151
|
/**
|
112
152
|
* @internal
|
113
153
|
*/
|
@@ -199,10 +239,19 @@ export { collectNodes as collectNodes_alias_1 }
|
|
199
239
|
|
200
240
|
export declare function combineEventHandlers<Handler extends (...args: any[]) => boolean | void, Args extends Parameters<Handler> = Parameters<Handler>>(): readonly [(handlers: Handler[]) => void, (...args: Args) => boolean];
|
201
241
|
|
202
|
-
|
242
|
+
/**
|
243
|
+
* A function to apply a command to the editor. It will return `true` if the command was applied, and `false` otherwise.
|
244
|
+
*
|
245
|
+
* It also has a `canApply` method to check if the command can be applied.
|
246
|
+
*
|
247
|
+
* @public
|
248
|
+
*/
|
249
|
+
declare interface CommandAction<Args extends any[] = any[]> {
|
203
250
|
(...args: Args): boolean;
|
204
251
|
canApply(...args: Args): boolean;
|
205
252
|
}
|
253
|
+
export { CommandAction }
|
254
|
+
export { CommandAction as CommandAction_alias_1 }
|
206
255
|
|
207
256
|
export declare type CommandCreator<Args extends any[] = any[]> = (...arg: Args) => Command;
|
208
257
|
|
@@ -223,6 +272,13 @@ declare interface CommandTyping {
|
|
223
272
|
export { CommandTyping }
|
224
273
|
export { CommandTyping as CommandTyping_alias_1 }
|
225
274
|
|
275
|
+
/**
|
276
|
+
* @internal
|
277
|
+
*/
|
278
|
+
declare function containsInlineNode(doc: ProseMirrorNode, from: number, to: number): boolean;
|
279
|
+
export { containsInlineNode }
|
280
|
+
export { containsInlineNode as containsInlineNode_alias_1 }
|
281
|
+
|
226
282
|
/**
|
227
283
|
* @public
|
228
284
|
*/
|
@@ -233,12 +289,12 @@ export { createEditor as createEditor_alias_1 }
|
|
233
289
|
/**
|
234
290
|
* @internal
|
235
291
|
*/
|
236
|
-
export declare function
|
292
|
+
export declare function createMarkActions(schema: Schema, getState: () => EditorState | null | undefined, applyMark?: ApplyMarkFunction): Record<string, MarkAction>;
|
237
293
|
|
238
294
|
/**
|
239
295
|
* @internal
|
240
296
|
*/
|
241
|
-
export declare function
|
297
|
+
export declare function createNodeActions(schema: Schema, getState: () => EditorState | null | undefined, createNode?: CreateNodeFunction): Record<string, NodeAction>;
|
242
298
|
|
243
299
|
export declare const createNodeForTest: CreateNodeFunction;
|
244
300
|
|
@@ -368,7 +424,9 @@ export { defineDefaultState as defineDefaultState_alias_1 }
|
|
368
424
|
* @public
|
369
425
|
*/
|
370
426
|
declare function defineDoc(): Extension< {
|
371
|
-
Nodes:
|
427
|
+
Nodes: {
|
428
|
+
doc: Attrs_2;
|
429
|
+
};
|
372
430
|
Marks: never;
|
373
431
|
Commands: never;
|
374
432
|
}>;
|
@@ -507,15 +565,23 @@ export { defineKeyPressHandler as defineKeyPressHandler_alias_1 }
|
|
507
565
|
/**
|
508
566
|
* @public
|
509
567
|
*/
|
510
|
-
declare function defineMarkAttr(options: MarkAttrOptions): Extension
|
568
|
+
declare function defineMarkAttr<MarkType extends string = string, AttrName extends string = string, AttrType = any>(options: MarkAttrOptions<MarkType, AttrName, AttrType>): Extension<{
|
569
|
+
Nodes: never;
|
570
|
+
Marks: {
|
571
|
+
[K in MarkType]: AttrType;
|
572
|
+
};
|
573
|
+
Commands: never;
|
574
|
+
}>;
|
511
575
|
export { defineMarkAttr }
|
512
576
|
export { defineMarkAttr as defineMarkAttr_alias_1 }
|
513
577
|
|
514
578
|
/**
|
515
579
|
* @public
|
516
580
|
*/
|
517
|
-
declare function defineMarkSpec<Mark extends string>(options: MarkSpecOptions<Mark>): Extension<{
|
518
|
-
Marks:
|
581
|
+
declare function defineMarkSpec<Mark extends string, Attrs extends AnyAttrs = AnyAttrs>(options: MarkSpecOptions<Mark, Attrs>): Extension<{
|
582
|
+
Marks: {
|
583
|
+
[K in Mark]: Attrs;
|
584
|
+
};
|
519
585
|
Nodes: never;
|
520
586
|
Commands: never;
|
521
587
|
}>;
|
@@ -536,7 +602,15 @@ export { defineMountHandler as defineMountHandler_alias_1 }
|
|
536
602
|
*
|
537
603
|
* @public
|
538
604
|
*/
|
539
|
-
declare function defineNodeAttr(options: NodeAttrOptions): Extension
|
605
|
+
declare function defineNodeAttr<NodeType extends string = string, AttrName extends string = string, AttrType = any>(options: NodeAttrOptions<NodeType, AttrName, AttrType>): Extension<{
|
606
|
+
Nodes: {
|
607
|
+
[K in NodeType]: {
|
608
|
+
[K in AttrName]: AttrType;
|
609
|
+
};
|
610
|
+
};
|
611
|
+
Marks: never;
|
612
|
+
Commands: never;
|
613
|
+
}>;
|
540
614
|
export { defineNodeAttr }
|
541
615
|
export { defineNodeAttr as defineNodeAttr_alias_1 }
|
542
616
|
|
@@ -545,8 +619,10 @@ export { defineNodeAttr as defineNodeAttr_alias_1 }
|
|
545
619
|
*
|
546
620
|
* @public
|
547
621
|
*/
|
548
|
-
declare function defineNodeSpec<Node extends string>(options: NodeSpecOptions<Node>): Extension<{
|
549
|
-
Nodes:
|
622
|
+
declare function defineNodeSpec<Node extends string, Attrs extends AnyAttrs = AnyAttrs>(options: NodeSpecOptions<Node, Attrs>): Extension<{
|
623
|
+
Nodes: {
|
624
|
+
[K in Node]: Attrs;
|
625
|
+
};
|
550
626
|
Marks: never;
|
551
627
|
Commands: never;
|
552
628
|
}>;
|
@@ -577,7 +653,9 @@ export { defineNodeViewFactory as defineNodeViewFactory_alias_1 }
|
|
577
653
|
* Defines a paragraph node spec as the highest priority, because it should be the default block node for most cases.
|
578
654
|
*/
|
579
655
|
declare function defineParagraph(): Extension< {
|
580
|
-
Nodes:
|
656
|
+
Nodes: {
|
657
|
+
paragraph: Attrs_2;
|
658
|
+
};
|
581
659
|
Marks: never;
|
582
660
|
Commands: never;
|
583
661
|
}>;
|
@@ -590,7 +668,9 @@ export { defineParagraph as defineParagraph_alias_1 }
|
|
590
668
|
* Defines a paragraph node spec.
|
591
669
|
*/
|
592
670
|
export declare function defineParagraphSpec(): Extension< {
|
593
|
-
Nodes:
|
671
|
+
Nodes: {
|
672
|
+
paragraph: Attrs_2;
|
673
|
+
};
|
594
674
|
Marks: never;
|
595
675
|
Commands: never;
|
596
676
|
}>;
|
@@ -631,8 +711,19 @@ export { defineScrollToSelectionHandler as defineScrollToSelectionHandler_alias_
|
|
631
711
|
* @internal
|
632
712
|
*/
|
633
713
|
export declare function defineTestExtension(): Extension<{
|
634
|
-
Nodes:
|
635
|
-
|
714
|
+
Nodes: SimplifyDeeper< {
|
715
|
+
paragraph: Attrs_2;
|
716
|
+
doc: Attrs_2;
|
717
|
+
text: Attrs_2;
|
718
|
+
heading: Attrs_2;
|
719
|
+
codeBlock: {
|
720
|
+
language: string;
|
721
|
+
};
|
722
|
+
}>;
|
723
|
+
Marks: SimplifyDeeper< {
|
724
|
+
bold: Attrs_2;
|
725
|
+
italic: Attrs_2;
|
726
|
+
}>;
|
636
727
|
Commands: {
|
637
728
|
insertText: [{
|
638
729
|
text: string;
|
@@ -658,7 +749,9 @@ export declare function defineTestExtension(): Extension<{
|
|
658
749
|
* @public
|
659
750
|
*/
|
660
751
|
declare function defineText(): Extension< {
|
661
|
-
Nodes:
|
752
|
+
Nodes: {
|
753
|
+
text: Attrs_2;
|
754
|
+
};
|
662
755
|
Marks: never;
|
663
756
|
Commands: never;
|
664
757
|
}>;
|
@@ -811,11 +904,7 @@ declare class Editor<E extends Extension = any> {
|
|
811
904
|
/**
|
812
905
|
* The editor schema.
|
813
906
|
*/
|
814
|
-
get schema(): Schema<
|
815
|
-
/**
|
816
|
-
* All commands defined by the editor.
|
817
|
-
*/
|
818
|
-
get commands(): ExtractCommandAppliers<E>;
|
907
|
+
get schema(): Schema<ExtractNodeNames<E>, ExtractMarkNames<E>>;
|
819
908
|
/**
|
820
909
|
* Whether the editor is focused.
|
821
910
|
*/
|
@@ -855,8 +944,18 @@ declare class Editor<E extends Extension = any> {
|
|
855
944
|
* directly manipulate the editor's state.
|
856
945
|
*/
|
857
946
|
updateState(state: EditorState): void;
|
858
|
-
|
859
|
-
|
947
|
+
/**
|
948
|
+
* All {@link CommandAction}s defined by the editor.
|
949
|
+
*/
|
950
|
+
get commands(): ExtractCommandActions<E>;
|
951
|
+
/**
|
952
|
+
* All {@link NodeAction}s defined by the editor.
|
953
|
+
*/
|
954
|
+
get nodes(): ExtractNodeActions<E>;
|
955
|
+
/**
|
956
|
+
* All {@link MarkAction}s defined by the editor.
|
957
|
+
*/
|
958
|
+
get marks(): ExtractMarkActions<E>;
|
860
959
|
}
|
861
960
|
export { Editor }
|
862
961
|
export { Editor as Editor_alias_1 }
|
@@ -867,9 +966,9 @@ export { Editor as Editor_alias_1 }
|
|
867
966
|
export declare class EditorInstance {
|
868
967
|
view: EditorView | null;
|
869
968
|
schema: Schema;
|
870
|
-
|
871
|
-
|
872
|
-
|
969
|
+
nodes: Record<string, NodeAction>;
|
970
|
+
marks: Record<string, MarkAction>;
|
971
|
+
commands: Record<string, CommandAction>;
|
873
972
|
private tree;
|
874
973
|
private directEditorProps;
|
875
974
|
constructor(extension: Extension);
|
@@ -988,7 +1087,7 @@ export { Extension as Extension_alias_1 }
|
|
988
1087
|
/**
|
989
1088
|
* @internal
|
990
1089
|
*/
|
991
|
-
declare interface ExtensionTyping<N extends
|
1090
|
+
declare interface ExtensionTyping<N extends NodeTyping | never = never, M extends MarkTyping | never = never, C extends CommandTyping | never = never> {
|
992
1091
|
Nodes: N;
|
993
1092
|
Marks: M;
|
994
1093
|
Commands: C;
|
@@ -997,9 +1096,18 @@ export { ExtensionTyping }
|
|
997
1096
|
export { ExtensionTyping as ExtensionTyping_alias_1 }
|
998
1097
|
|
999
1098
|
/**
|
1099
|
+
* Extracts the {@link CommandAction}s from an extension type.
|
1100
|
+
*
|
1000
1101
|
* @public
|
1001
1102
|
*/
|
1002
|
-
declare type
|
1103
|
+
declare type ExtractCommandActions<E extends Extension> = ToCommandAction<ExtractCommands<E>>;
|
1104
|
+
export { ExtractCommandActions }
|
1105
|
+
export { ExtractCommandActions as ExtractCommandActions_alias_1 }
|
1106
|
+
|
1107
|
+
/**
|
1108
|
+
* @deprecated Use `ExtractCommandActions` instead.
|
1109
|
+
*/
|
1110
|
+
declare type ExtractCommandAppliers<E extends Extension> = ExtractCommandActions<E>;
|
1003
1111
|
export { ExtractCommandAppliers }
|
1004
1112
|
export { ExtractCommandAppliers as ExtractCommandAppliers_alias_1 }
|
1005
1113
|
|
@@ -1015,17 +1123,45 @@ export { ExtractCommandCreators as ExtractCommandCreators_alias_1 }
|
|
1015
1123
|
*/
|
1016
1124
|
export declare type ExtractCommands<E extends Extension> = SimplifyUnion<ExtractTyping<E>['Commands']>;
|
1017
1125
|
|
1126
|
+
/**
|
1127
|
+
* Extracts the {@link MarkAction}s from an extension type.
|
1128
|
+
*
|
1129
|
+
* @public
|
1130
|
+
*/
|
1131
|
+
declare type ExtractMarkActions<E extends Extension> = ToMarkAction<ExtractMarks<E>>;
|
1132
|
+
export { ExtractMarkActions }
|
1133
|
+
export { ExtractMarkActions as ExtractMarkActions_alias_1 }
|
1134
|
+
|
1135
|
+
/**
|
1136
|
+
* @public
|
1137
|
+
*/
|
1138
|
+
export declare type ExtractMarkNames<E extends Extension> = PickStringLiteral<keyof ExtractMarks<E>>;
|
1139
|
+
|
1018
1140
|
/**
|
1019
1141
|
* @public
|
1020
1142
|
*/
|
1021
|
-
declare type ExtractMarks<E extends Extension> = ExtractTyping<E>['Marks']
|
1143
|
+
declare type ExtractMarks<E extends Extension> = SimplifyDeeper<SimplifyUnion<ExtractTyping<E>['Marks']>>;
|
1022
1144
|
export { ExtractMarks }
|
1023
1145
|
export { ExtractMarks as ExtractMarks_alias_1 }
|
1024
1146
|
|
1147
|
+
/**
|
1148
|
+
* Extracts the {@link NodeAction}s from an extension type.
|
1149
|
+
*
|
1150
|
+
* @public
|
1151
|
+
*/
|
1152
|
+
declare type ExtractNodeActions<E extends Extension> = ToNodeAction<ExtractNodes<E>>;
|
1153
|
+
export { ExtractNodeActions }
|
1154
|
+
export { ExtractNodeActions as ExtractNodeActions_alias_1 }
|
1155
|
+
|
1156
|
+
/**
|
1157
|
+
* @public
|
1158
|
+
*/
|
1159
|
+
export declare type ExtractNodeNames<E extends Extension> = PickStringLiteral<keyof ExtractNodes<E>>;
|
1160
|
+
|
1025
1161
|
/**
|
1026
1162
|
* @public
|
1027
1163
|
*/
|
1028
|
-
declare type ExtractNodes<E extends Extension> = ExtractTyping<E>['Nodes']
|
1164
|
+
declare type ExtractNodes<E extends Extension> = SimplifyDeeper<SimplifyUnion<ExtractTyping<E>['Nodes']>>;
|
1029
1165
|
export { ExtractNodes }
|
1030
1166
|
export { ExtractNodes as ExtractNodes_alias_1 }
|
1031
1167
|
|
@@ -1034,7 +1170,7 @@ export declare function extractTags(node: TaggedProseMirrorNode): Record<string,
|
|
1034
1170
|
/**
|
1035
1171
|
* @internal
|
1036
1172
|
*/
|
1037
|
-
export declare type ExtractTyping<E extends Extension> = E extends Extension<ExtensionTyping<infer N, infer M, infer C>> ? ExtensionTyping<
|
1173
|
+
export declare type ExtractTyping<E extends Extension> = E extends Extension<ExtensionTyping<infer N, infer M, infer C>> ? ExtensionTyping<PickSubType<N, NodeTyping>, PickSubType<M, MarkTyping>, PickSubType<C, CommandTyping>> : never;
|
1038
1174
|
|
1039
1175
|
/**
|
1040
1176
|
* @internal
|
@@ -1220,6 +1356,8 @@ declare function htmlFromNode(node: ProseMirrorNode, options?: DOMSerializerOpti
|
|
1220
1356
|
export { htmlFromNode }
|
1221
1357
|
export { htmlFromNode as htmlFromNode_alias_1 }
|
1222
1358
|
|
1359
|
+
export declare function includesMark(marks: readonly Mark[], markType: MarkType, attrs?: Attrs | null): boolean;
|
1360
|
+
|
1223
1361
|
/**
|
1224
1362
|
* Returns a command that inserts the given node at the current selection or at
|
1225
1363
|
* the given position.
|
@@ -1315,6 +1453,7 @@ export { isMark as isMark_alias_1 }
|
|
1315
1453
|
/**
|
1316
1454
|
* Returns true if the given mark is missing in some part of the range.
|
1317
1455
|
* Returns false if the entire range has the given mark.
|
1456
|
+
* Returns true if the mark is not allowed in the range.
|
1318
1457
|
*
|
1319
1458
|
* @internal
|
1320
1459
|
*/
|
@@ -1347,6 +1486,13 @@ declare function isProseMirrorNode(node: unknown): node is ProseMirrorNode;
|
|
1347
1486
|
export { isProseMirrorNode }
|
1348
1487
|
export { isProseMirrorNode as isProseMirrorNode_alias_1 }
|
1349
1488
|
|
1489
|
+
/**
|
1490
|
+
* Check if `subset` is a subset of `superset`.
|
1491
|
+
*
|
1492
|
+
* @internal
|
1493
|
+
*/
|
1494
|
+
export declare function isSubset(subset: Record<string, unknown>, superset: Record<string, unknown>): boolean;
|
1495
|
+
|
1350
1496
|
/**
|
1351
1497
|
* @internal
|
1352
1498
|
*/
|
@@ -1427,23 +1573,39 @@ export { KeyPressHandler }
|
|
1427
1573
|
export { KeyPressHandler as KeyPressHandler_alias_1 }
|
1428
1574
|
|
1429
1575
|
/**
|
1576
|
+
* A function for creating a mark with optional attributes and any number of
|
1577
|
+
* children.
|
1578
|
+
*
|
1579
|
+
* It also has a `isActive` method for checking if the mark is active in the
|
1580
|
+
* current editor selection.
|
1581
|
+
*
|
1430
1582
|
* @public
|
1431
1583
|
*/
|
1432
|
-
declare interface
|
1584
|
+
declare interface MarkAction<Attrs extends AnyAttrs = AnyAttrs> {
|
1585
|
+
(attrs: Attrs | null, ...children: NodeChild[]): ProseMirrorNode[];
|
1586
|
+
(...children: NodeChild[]): ProseMirrorNode[];
|
1433
1587
|
/**
|
1434
|
-
*
|
1588
|
+
* Checks if the mark is active in the current editor selection. If the
|
1589
|
+
* optional `attrs` parameter is provided, it will check if the mark is active
|
1590
|
+
* with the given attributes.
|
1435
1591
|
*/
|
1436
|
-
|
1592
|
+
isActive: (attrs?: Attrs) => boolean;
|
1593
|
+
}
|
1594
|
+
export { MarkAction }
|
1595
|
+
export { MarkAction as MarkAction_alias_1 }
|
1596
|
+
|
1597
|
+
/**
|
1598
|
+
* @public
|
1599
|
+
*/
|
1600
|
+
declare interface MarkAttrOptions<MarkName extends string = string, AttrName extends string = string, AttrType = any> extends AttrSpec<AttrType> {
|
1437
1601
|
/**
|
1438
|
-
* The name of the
|
1602
|
+
* The name of the mark type.
|
1439
1603
|
*/
|
1440
|
-
|
1604
|
+
type: MarkName;
|
1441
1605
|
/**
|
1442
|
-
* The
|
1443
|
-
* provided. Attributes that have no default must be provided whenever a mark
|
1444
|
-
* of a type that has them is created.
|
1606
|
+
* The name of the attribute.
|
1445
1607
|
*/
|
1446
|
-
|
1608
|
+
attr: AttrName;
|
1447
1609
|
/**
|
1448
1610
|
* Returns the attribute key and value to be set on the DOM node.
|
1449
1611
|
*/
|
@@ -1457,25 +1619,39 @@ export { MarkAttrOptions }
|
|
1457
1619
|
export { MarkAttrOptions as MarkAttrOptions_alias_1 }
|
1458
1620
|
|
1459
1621
|
/**
|
1460
|
-
* @
|
1622
|
+
* @deprecated Use type {@link MarkAction} instead.
|
1461
1623
|
*/
|
1462
|
-
declare
|
1463
|
-
(attrs: Attrs | null, ...children: NodeChild[]): ProseMirrorNode[];
|
1464
|
-
(...children: NodeChild[]): ProseMirrorNode[];
|
1465
|
-
isActive: (attrs?: Attrs) => boolean;
|
1466
|
-
}
|
1624
|
+
declare type MarkBuilder = MarkAction;
|
1467
1625
|
export { MarkBuilder }
|
1468
1626
|
export { MarkBuilder as MarkBuilder_alias_1 }
|
1469
1627
|
|
1470
1628
|
/**
|
1471
1629
|
* @public
|
1472
1630
|
*/
|
1473
|
-
declare interface MarkSpecOptions<MarkName extends string = string> extends MarkSpec {
|
1631
|
+
declare interface MarkSpecOptions<MarkName extends string = string, Attrs extends AnyAttrs = AnyAttrs> extends MarkSpec {
|
1632
|
+
/**
|
1633
|
+
* The name of the mark type.
|
1634
|
+
*/
|
1474
1635
|
name: MarkName;
|
1636
|
+
/**
|
1637
|
+
* The attributes that marks of this type get.
|
1638
|
+
*/
|
1639
|
+
attrs?: {
|
1640
|
+
[K in keyof Attrs]: AttrSpec<Attrs[K]>;
|
1641
|
+
};
|
1475
1642
|
}
|
1476
1643
|
export { MarkSpecOptions }
|
1477
1644
|
export { MarkSpecOptions as MarkSpecOptions_alias_1 }
|
1478
1645
|
|
1646
|
+
/**
|
1647
|
+
* @internal
|
1648
|
+
*/
|
1649
|
+
declare interface MarkTyping {
|
1650
|
+
[name: string]: Record<string, any>;
|
1651
|
+
}
|
1652
|
+
export { MarkTyping }
|
1653
|
+
export { MarkTyping as MarkTyping_alias_1 }
|
1654
|
+
|
1479
1655
|
/**
|
1480
1656
|
* @internal
|
1481
1657
|
*/
|
@@ -1495,23 +1671,39 @@ export { MountHandler }
|
|
1495
1671
|
export { MountHandler as MountHandler_alias_1 }
|
1496
1672
|
|
1497
1673
|
/**
|
1674
|
+
* A function for creating a node with optional attributes and any number of
|
1675
|
+
* children.
|
1676
|
+
*
|
1677
|
+
* It also has a `isActive` method for checking if the node is active in the
|
1678
|
+
* current editor selection.
|
1679
|
+
*
|
1498
1680
|
* @public
|
1499
1681
|
*/
|
1500
|
-
declare interface
|
1682
|
+
declare interface NodeAction<Attrs extends AnyAttrs = AnyAttrs> {
|
1683
|
+
(attrs: Attrs | null, ...children: NodeChild[]): ProseMirrorNode;
|
1684
|
+
(...children: NodeChild[]): ProseMirrorNode;
|
1501
1685
|
/**
|
1502
|
-
*
|
1686
|
+
* Checks if the node is active in the current editor selection. If the
|
1687
|
+
* optional `attrs` parameter is provided, it will check if the node is active
|
1688
|
+
* with the given attributes.
|
1503
1689
|
*/
|
1504
|
-
|
1690
|
+
isActive: (attrs?: Attrs) => boolean;
|
1691
|
+
}
|
1692
|
+
export { NodeAction }
|
1693
|
+
export { NodeAction as NodeAction_alias_1 }
|
1694
|
+
|
1695
|
+
/**
|
1696
|
+
* @public
|
1697
|
+
*/
|
1698
|
+
declare interface NodeAttrOptions<NodeName extends string = string, AttrName extends string = string, AttrType = any> extends AttrSpec<AttrType> {
|
1505
1699
|
/**
|
1506
|
-
* The name of the
|
1700
|
+
* The name of the node type.
|
1507
1701
|
*/
|
1508
|
-
|
1702
|
+
type: NodeName;
|
1509
1703
|
/**
|
1510
|
-
* The
|
1511
|
-
* provided. Attributes that have no default must be provided whenever a node
|
1512
|
-
* of a type that has them is created.
|
1704
|
+
* The name of the attribute.
|
1513
1705
|
*/
|
1514
|
-
|
1706
|
+
attr: AttrName;
|
1515
1707
|
/**
|
1516
1708
|
* Whether the attribute should be kept when the node is split. Set it to
|
1517
1709
|
* `true` if you want to inherit the attribute from the previous node when
|
@@ -1536,20 +1728,20 @@ export { NodeAttrOptions }
|
|
1536
1728
|
export { NodeAttrOptions as NodeAttrOptions_alias_1 }
|
1537
1729
|
|
1538
1730
|
/**
|
1539
|
-
* @
|
1731
|
+
* @deprecated Use type {@link NodeAction} instead.
|
1540
1732
|
*/
|
1541
|
-
declare
|
1542
|
-
(attrs: Attrs | null, ...children: NodeChild[]): ProseMirrorNode;
|
1543
|
-
(...children: NodeChild[]): ProseMirrorNode;
|
1544
|
-
isActive: (attrs?: Attrs) => boolean;
|
1545
|
-
}
|
1733
|
+
declare type NodeBuilder = NodeAction;
|
1546
1734
|
export { NodeBuilder }
|
1547
1735
|
export { NodeBuilder as NodeBuilder_alias_1 }
|
1548
1736
|
|
1549
1737
|
/**
|
1738
|
+
* Available children parameters for {@link NodeAction} and {@link MarkAction}.
|
1739
|
+
*
|
1550
1740
|
* @public
|
1551
1741
|
*/
|
1552
|
-
|
1742
|
+
declare type NodeChild = ProseMirrorNode | string | NodeChild[];
|
1743
|
+
export { NodeChild }
|
1744
|
+
export { NodeChild as NodeChild_alias_1 }
|
1553
1745
|
|
1554
1746
|
/**
|
1555
1747
|
* @public
|
@@ -1603,13 +1795,35 @@ export { NodeJSON as NodeJSON_alias_1 }
|
|
1603
1795
|
/**
|
1604
1796
|
* @public
|
1605
1797
|
*/
|
1606
|
-
declare interface NodeSpecOptions<NodeName extends string = string> extends NodeSpec {
|
1798
|
+
declare interface NodeSpecOptions<NodeName extends string = string, Attrs extends AnyAttrs = AnyAttrs> extends NodeSpec {
|
1799
|
+
/**
|
1800
|
+
* The name of the node type.
|
1801
|
+
*/
|
1607
1802
|
name: NodeName;
|
1803
|
+
/**
|
1804
|
+
* Whether this is the top-level node type. Only one node type can be the
|
1805
|
+
* top-level node type in a schema.
|
1806
|
+
*/
|
1608
1807
|
topNode?: boolean;
|
1808
|
+
/**
|
1809
|
+
* The attributes that nodes of this type get.
|
1810
|
+
*/
|
1811
|
+
attrs?: {
|
1812
|
+
[key in keyof Attrs]: AttrSpec<Attrs[key]>;
|
1813
|
+
};
|
1609
1814
|
}
|
1610
1815
|
export { NodeSpecOptions }
|
1611
1816
|
export { NodeSpecOptions as NodeSpecOptions_alias_1 }
|
1612
1817
|
|
1818
|
+
/**
|
1819
|
+
* @internal
|
1820
|
+
*/
|
1821
|
+
declare interface NodeTyping {
|
1822
|
+
[name: string]: Record<string, any>;
|
1823
|
+
}
|
1824
|
+
export { NodeTyping }
|
1825
|
+
export { NodeTyping as NodeTyping_alias_1 }
|
1826
|
+
|
1613
1827
|
/**
|
1614
1828
|
* @internal
|
1615
1829
|
*/
|
@@ -1674,14 +1888,14 @@ export declare type Payloads<T> = Tuple5<T[]>;
|
|
1674
1888
|
/**
|
1675
1889
|
* @internal
|
1676
1890
|
*/
|
1677
|
-
export declare type
|
1678
|
-
CommandTyping
|
1679
|
-
] extends [T] ? never : T;
|
1891
|
+
export declare type PickStringLiteral<T> = PickSubType<T, string>;
|
1680
1892
|
|
1681
1893
|
/**
|
1682
1894
|
* @internal
|
1683
1895
|
*/
|
1684
|
-
|
1896
|
+
declare type PickSubType<Type, ParentType> = Type extends ParentType ? [ParentType] extends [Type] ? never : Type : never;
|
1897
|
+
export { PickSubType }
|
1898
|
+
export { PickSubType as PickSubType_alias_1 }
|
1685
1899
|
|
1686
1900
|
/**
|
1687
1901
|
* @internal
|
@@ -1899,8 +2113,19 @@ export declare function setupEditorExtension<E extends Extension>(options: Edito
|
|
1899
2113
|
*/
|
1900
2114
|
export declare function setupTest(): {
|
1901
2115
|
editor: TestEditor<Extension<{
|
1902
|
-
Nodes:
|
1903
|
-
|
2116
|
+
Nodes: SimplifyDeeper< {
|
2117
|
+
paragraph: Attrs_2;
|
2118
|
+
doc: Attrs_2;
|
2119
|
+
text: Attrs_2;
|
2120
|
+
heading: Attrs_2;
|
2121
|
+
codeBlock: {
|
2122
|
+
language: string;
|
2123
|
+
};
|
2124
|
+
}>;
|
2125
|
+
Marks: SimplifyDeeper< {
|
2126
|
+
bold: Attrs_2;
|
2127
|
+
italic: Attrs_2;
|
2128
|
+
}>;
|
1904
2129
|
Commands: {
|
1905
2130
|
insertText: [{
|
1906
2131
|
text: string;
|
@@ -1921,8 +2146,34 @@ export declare function setupTest(): {
|
|
1921
2146
|
readonly redo: [];
|
1922
2147
|
};
|
1923
2148
|
}>>;
|
1924
|
-
|
1925
|
-
|
2149
|
+
m: ToMarkAction<SimplifyDeeper< {
|
2150
|
+
bold: {
|
2151
|
+
readonly [x: string]: any;
|
2152
|
+
};
|
2153
|
+
italic: {
|
2154
|
+
readonly [x: string]: any;
|
2155
|
+
};
|
2156
|
+
}>>;
|
2157
|
+
n: {
|
2158
|
+
p: NodeAction< {
|
2159
|
+
readonly [x: string]: any;
|
2160
|
+
}>;
|
2161
|
+
paragraph: NodeAction< {
|
2162
|
+
readonly [x: string]: any;
|
2163
|
+
}>;
|
2164
|
+
doc: NodeAction< {
|
2165
|
+
readonly [x: string]: any;
|
2166
|
+
}>;
|
2167
|
+
text: NodeAction< {
|
2168
|
+
readonly [x: string]: any;
|
2169
|
+
}>;
|
2170
|
+
heading: NodeAction< {
|
2171
|
+
readonly [x: string]: any;
|
2172
|
+
}>;
|
2173
|
+
codeBlock: NodeAction< {
|
2174
|
+
language: string;
|
2175
|
+
}>;
|
2176
|
+
};
|
1926
2177
|
};
|
1927
2178
|
|
1928
2179
|
/**
|
@@ -1930,9 +2181,18 @@ export declare function setupTest(): {
|
|
1930
2181
|
*/
|
1931
2182
|
export declare function setupTestFromExtension<E extends Extension>(extension: E): {
|
1932
2183
|
editor: TestEditor<E>;
|
1933
|
-
n:
|
1934
|
-
m:
|
2184
|
+
n: ExtractNodeActions<E>;
|
2185
|
+
m: ExtractMarkActions<E>;
|
2186
|
+
};
|
2187
|
+
|
2188
|
+
/**
|
2189
|
+
* @internal
|
2190
|
+
*/
|
2191
|
+
declare type SimplifyDeeper<T> = {
|
2192
|
+
[KeyType in keyof T]: Simplify<T[KeyType]>;
|
1935
2193
|
};
|
2194
|
+
export { SimplifyDeeper }
|
2195
|
+
export { SimplifyDeeper as SimplifyDeeper_alias_1 }
|
1936
2196
|
|
1937
2197
|
/**
|
1938
2198
|
* @internal
|
@@ -2034,8 +2294,8 @@ declare type TextInputHandler = (view: EditorView, from: number, to: number, tex
|
|
2034
2294
|
export { TextInputHandler }
|
2035
2295
|
export { TextInputHandler as TextInputHandler_alias_1 }
|
2036
2296
|
|
2037
|
-
export declare type
|
2038
|
-
[K in keyof T]:
|
2297
|
+
export declare type ToCommandAction<T extends CommandTyping> = {
|
2298
|
+
[K in keyof T]: CommandAction<T[K]>;
|
2039
2299
|
};
|
2040
2300
|
|
2041
2301
|
export declare type ToCommandCreators<T extends CommandTyping> = {
|
@@ -2087,6 +2347,24 @@ declare interface ToggleNodeOptions {
|
|
2087
2347
|
export { ToggleNodeOptions }
|
2088
2348
|
export { ToggleNodeOptions as ToggleNodeOptions_alias_1 }
|
2089
2349
|
|
2350
|
+
/**
|
2351
|
+
* @internal
|
2352
|
+
*/
|
2353
|
+
declare type ToMarkAction<T extends MarkTyping> = {
|
2354
|
+
[K in keyof T]: MarkAction<T[K]>;
|
2355
|
+
};
|
2356
|
+
export { ToMarkAction }
|
2357
|
+
export { ToMarkAction as ToMarkAction_alias_1 }
|
2358
|
+
|
2359
|
+
/**
|
2360
|
+
* @internal
|
2361
|
+
*/
|
2362
|
+
declare type ToNodeAction<T extends NodeTyping> = {
|
2363
|
+
[K in keyof T]: NodeAction<T[K]>;
|
2364
|
+
};
|
2365
|
+
export { ToNodeAction }
|
2366
|
+
export { ToNodeAction as ToNodeAction_alias_1 }
|
2367
|
+
|
2090
2368
|
export declare function toReversed<T>(arr: T[]): T[];
|
2091
2369
|
|
2092
2370
|
declare type TripleClickHandler = (view: EditorView, pos: number, event: MouseEvent) => boolean | void;
|
@@ -512,15 +512,36 @@ function defineDefaultState({
|
|
512
512
|
]);
|
513
513
|
}
|
514
514
|
|
515
|
+
// src/utils/is-subset.ts
|
516
|
+
function isSubset(subset, superset) {
|
517
|
+
return Object.keys(subset).every((key) => subset[key] === superset[key]);
|
518
|
+
}
|
519
|
+
|
520
|
+
// src/utils/includes-mark.ts
|
521
|
+
function includesMark(marks, markType, attrs) {
|
522
|
+
attrs = attrs || {};
|
523
|
+
return marks.some((mark) => {
|
524
|
+
return mark.type === markType && isSubset(attrs, mark.attrs);
|
525
|
+
});
|
526
|
+
}
|
527
|
+
|
515
528
|
// src/utils/is-mark-absent.ts
|
516
529
|
function isMarkAbsent(node, from, to, markType, attrs) {
|
517
|
-
const mark = attrs ? markType.create(attrs) : markType;
|
518
530
|
let missing = false;
|
531
|
+
let available = false;
|
519
532
|
node.nodesBetween(from, to, (node2, pos, parent) => {
|
520
|
-
if (missing)
|
521
|
-
|
533
|
+
if (missing) {
|
534
|
+
return false;
|
535
|
+
}
|
536
|
+
const allowed = (parent == null ? void 0 : parent.type.allowsMarkType(markType)) && !node2.marks.some((m) => m.type !== markType && m.type.excludes(markType));
|
537
|
+
if (allowed) {
|
538
|
+
available = true;
|
539
|
+
if (!includesMark(node2.marks, markType, attrs)) {
|
540
|
+
missing = true;
|
541
|
+
}
|
542
|
+
}
|
522
543
|
});
|
523
|
-
return missing;
|
544
|
+
return available ? missing : true;
|
524
545
|
}
|
525
546
|
|
526
547
|
// src/utils/is-mark-active.ts
|
@@ -528,8 +549,8 @@ function isMarkActive(state, type, attrs) {
|
|
528
549
|
const { from, $from, to, empty } = state.selection;
|
529
550
|
const markType = getMarkType(state.schema, type);
|
530
551
|
if (empty) {
|
531
|
-
const
|
532
|
-
return
|
552
|
+
const marks = state.storedMarks || $from.marks();
|
553
|
+
return includesMark(marks, markType, attrs);
|
533
554
|
} else {
|
534
555
|
return !isMarkAbsent(state.doc, from, to, markType, attrs);
|
535
556
|
}
|
@@ -625,7 +646,7 @@ function deepEquals(a, b) {
|
|
625
646
|
return false;
|
626
647
|
}
|
627
648
|
|
628
|
-
// src/editor/
|
649
|
+
// src/editor/action.ts
|
629
650
|
import "@prosekit/pm/model";
|
630
651
|
|
631
652
|
// src/utils/attrs-match.ts
|
@@ -652,8 +673,8 @@ function isNodeActive(state, type, attrs) {
|
|
652
673
|
return false;
|
653
674
|
}
|
654
675
|
|
655
|
-
// src/editor/
|
656
|
-
function
|
676
|
+
// src/editor/action.ts
|
677
|
+
function createNodeActions(schema, getState, createNode = defaultCreateNode) {
|
657
678
|
const builders = {};
|
658
679
|
for (const type of Object.values(schema.nodes)) {
|
659
680
|
const builder = (...args) => buildNode(type, args, createNode);
|
@@ -665,7 +686,7 @@ function createNodeBuilders(schema, getState, createNode = defaultCreateNode) {
|
|
665
686
|
}
|
666
687
|
return builders;
|
667
688
|
}
|
668
|
-
function
|
689
|
+
function createMarkActions(schema, getState, applyMark = defaultApplyMark) {
|
669
690
|
const builders = {};
|
670
691
|
for (const type of Object.values(schema.marks)) {
|
671
692
|
const builder = (...args) => buildMark(type, args, applyMark);
|
@@ -751,7 +772,7 @@ function createEditor(options) {
|
|
751
772
|
var EditorInstance = class {
|
752
773
|
constructor(extension) {
|
753
774
|
this.view = null;
|
754
|
-
this.
|
775
|
+
this.commands = {};
|
755
776
|
this.getState = () => {
|
756
777
|
var _a;
|
757
778
|
return ((_a = this.view) == null ? void 0 : _a.state) || this.directEditorProps.state;
|
@@ -767,8 +788,8 @@ var EditorInstance = class {
|
|
767
788
|
this.defineCommand(name, commandCreator);
|
768
789
|
}
|
769
790
|
}
|
770
|
-
this.
|
771
|
-
this.
|
791
|
+
this.nodes = createNodeActions(state.schema, this.getState);
|
792
|
+
this.marks = createMarkActions(state.schema, this.getState);
|
772
793
|
this.schema = state.schema;
|
773
794
|
this.directEditorProps = { state, ...payload.view };
|
774
795
|
}
|
@@ -852,13 +873,13 @@ var EditorInstance = class {
|
|
852
873
|
view.setProps({ state: newState });
|
853
874
|
}
|
854
875
|
defineCommand(name, commandCreator) {
|
855
|
-
const
|
876
|
+
const action = (...args) => {
|
856
877
|
const view = this.view;
|
857
878
|
assert(view, `Cannot call command "${name}" before the editor is mounted`);
|
858
879
|
const command = commandCreator(...args);
|
859
880
|
return command(view.state, view.dispatch.bind(view), view);
|
860
881
|
};
|
861
|
-
|
882
|
+
action.canApply = (...args) => {
|
862
883
|
const view = this.view;
|
863
884
|
if (!view) {
|
864
885
|
return false;
|
@@ -866,10 +887,10 @@ var EditorInstance = class {
|
|
866
887
|
const command = commandCreator(...args);
|
867
888
|
return command(view.state, void 0, view);
|
868
889
|
};
|
869
|
-
this.
|
890
|
+
this.commands[name] = action;
|
870
891
|
}
|
871
892
|
removeCommand(name) {
|
872
|
-
delete this.
|
893
|
+
delete this.commands[name];
|
873
894
|
}
|
874
895
|
};
|
875
896
|
var Editor = class _Editor {
|
@@ -910,12 +931,6 @@ var Editor = class _Editor {
|
|
910
931
|
get schema() {
|
911
932
|
return this.instance.schema;
|
912
933
|
}
|
913
|
-
/**
|
914
|
-
* All commands defined by the editor.
|
915
|
-
*/
|
916
|
-
get commands() {
|
917
|
-
return this.instance.commandAppliers;
|
918
|
-
}
|
919
934
|
/**
|
920
935
|
* Whether the editor is focused.
|
921
936
|
*/
|
@@ -995,11 +1010,23 @@ var Editor = class _Editor {
|
|
995
1010
|
updateState(state) {
|
996
1011
|
this.instance.updateState(state);
|
997
1012
|
}
|
1013
|
+
/**
|
1014
|
+
* All {@link CommandAction}s defined by the editor.
|
1015
|
+
*/
|
1016
|
+
get commands() {
|
1017
|
+
return this.instance.commands;
|
1018
|
+
}
|
1019
|
+
/**
|
1020
|
+
* All {@link NodeAction}s defined by the editor.
|
1021
|
+
*/
|
998
1022
|
get nodes() {
|
999
|
-
return this.instance.
|
1023
|
+
return this.instance.nodes;
|
1000
1024
|
}
|
1025
|
+
/**
|
1026
|
+
* All {@link MarkAction}s defined by the editor.
|
1027
|
+
*/
|
1001
1028
|
get marks() {
|
1002
|
-
return this.instance.
|
1029
|
+
return this.instance.marks;
|
1003
1030
|
}
|
1004
1031
|
};
|
1005
1032
|
|
@@ -1037,8 +1064,8 @@ export {
|
|
1037
1064
|
isTextSelection,
|
1038
1065
|
isNodeSelection,
|
1039
1066
|
isAllSelection,
|
1040
|
-
|
1041
|
-
|
1067
|
+
createNodeActions,
|
1068
|
+
createMarkActions,
|
1042
1069
|
union,
|
1043
1070
|
setupEditorExtension,
|
1044
1071
|
createEditor,
|
@@ -2,10 +2,10 @@ import {
|
|
2
2
|
Editor,
|
3
3
|
EditorInstance,
|
4
4
|
assert,
|
5
|
-
|
6
|
-
|
5
|
+
createMarkActions,
|
6
|
+
createNodeActions,
|
7
7
|
setupEditorExtension
|
8
|
-
} from "./chunk-
|
8
|
+
} from "./chunk-M267LRMB.js";
|
9
9
|
|
10
10
|
// src/test/test-editor.ts
|
11
11
|
import { EditorState, NodeSelection, TextSelection } from "@prosekit/pm/state";
|
@@ -82,16 +82,8 @@ function getSelection(doc) {
|
|
82
82
|
var TestEditorInstance = class extends EditorInstance {
|
83
83
|
constructor(extension) {
|
84
84
|
super(extension);
|
85
|
-
this.
|
86
|
-
|
87
|
-
this.getState,
|
88
|
-
createNodeForTest
|
89
|
-
);
|
90
|
-
this.markBuilders = createMarkBuilders(
|
91
|
-
this.schema,
|
92
|
-
this.getState,
|
93
|
-
applyMarkForTest
|
94
|
-
);
|
85
|
+
this.nodes = createNodeActions(this.schema, this.getState, createNodeForTest);
|
86
|
+
this.marks = createMarkActions(this.schema, this.getState, applyMarkForTest);
|
95
87
|
}
|
96
88
|
};
|
97
89
|
var TestEditor = class extends Editor {
|
package/dist/prosekit-core.d.ts
CHANGED
@@ -22,8 +22,11 @@ export { unsetMark } from './_tsup-dts-rollup';
|
|
22
22
|
export { UnsetMarkOptions } from './_tsup-dts-rollup';
|
23
23
|
export { wrap } from './_tsup-dts-rollup';
|
24
24
|
export { WrapOptions } from './_tsup-dts-rollup';
|
25
|
+
export { MarkAction } from './_tsup-dts-rollup';
|
25
26
|
export { MarkBuilder } from './_tsup-dts-rollup';
|
27
|
+
export { NodeAction } from './_tsup-dts-rollup';
|
26
28
|
export { NodeBuilder } from './_tsup-dts-rollup';
|
29
|
+
export { NodeChild } from './_tsup-dts-rollup';
|
27
30
|
export { Editor } from './_tsup-dts-rollup';
|
28
31
|
export { createEditor } from './_tsup-dts-rollup';
|
29
32
|
export { EditorOptions } from './_tsup-dts-rollup';
|
@@ -101,26 +104,39 @@ export { defineText } from './_tsup-dts-rollup';
|
|
101
104
|
export { defineFacet } from './_tsup-dts-rollup';
|
102
105
|
export { Facet } from './_tsup-dts-rollup';
|
103
106
|
export { defineFacetPayload } from './_tsup-dts-rollup';
|
107
|
+
export { AnyAttrs } from './_tsup-dts-rollup';
|
108
|
+
export { AttrSpec } from './_tsup-dts-rollup';
|
104
109
|
export { BaseNodeViewOptions } from './_tsup-dts-rollup';
|
105
|
-
export { CommandTyping } from './_tsup-dts-rollup';
|
106
110
|
export { Extension } from './_tsup-dts-rollup';
|
107
111
|
export { ExtensionTyping } from './_tsup-dts-rollup';
|
112
|
+
export { ExtractCommandActions } from './_tsup-dts-rollup';
|
108
113
|
export { ExtractCommandAppliers } from './_tsup-dts-rollup';
|
109
114
|
export { ExtractCommandCreators } from './_tsup-dts-rollup';
|
115
|
+
export { ExtractMarkActions } from './_tsup-dts-rollup';
|
110
116
|
export { ExtractMarks } from './_tsup-dts-rollup';
|
117
|
+
export { ExtractNodeActions } from './_tsup-dts-rollup';
|
111
118
|
export { ExtractNodes } from './_tsup-dts-rollup';
|
112
119
|
export { UnionExtension } from './_tsup-dts-rollup';
|
120
|
+
export { CommandAction } from './_tsup-dts-rollup';
|
121
|
+
export { CommandTyping } from './_tsup-dts-rollup';
|
122
|
+
export { MarkTyping } from './_tsup-dts-rollup';
|
123
|
+
export { ToMarkAction } from './_tsup-dts-rollup';
|
124
|
+
export { NodeTyping } from './_tsup-dts-rollup';
|
125
|
+
export { ToNodeAction } from './_tsup-dts-rollup';
|
113
126
|
export { NodeJSON } from './_tsup-dts-rollup';
|
114
127
|
export { SelectionJSON } from './_tsup-dts-rollup';
|
115
128
|
export { StateJSON } from './_tsup-dts-rollup';
|
116
129
|
export { StepJSON } from './_tsup-dts-rollup';
|
130
|
+
export { PickSubType } from './_tsup-dts-rollup';
|
117
131
|
export { Priority } from './_tsup-dts-rollup';
|
132
|
+
export { SimplifyDeeper } from './_tsup-dts-rollup';
|
118
133
|
export { SimplifyUnion } from './_tsup-dts-rollup';
|
119
134
|
export { assert } from './_tsup-dts-rollup';
|
120
135
|
export { canUseRegexLookbehind } from './_tsup-dts-rollup';
|
121
136
|
export { clsx } from './_tsup-dts-rollup';
|
122
137
|
export { collectNodes } from './_tsup-dts-rollup';
|
123
138
|
export { NodeContent } from './_tsup-dts-rollup';
|
139
|
+
export { containsInlineNode } from './_tsup-dts-rollup';
|
124
140
|
export { defaultBlockAt } from './_tsup-dts-rollup';
|
125
141
|
export { isApple } from './_tsup-dts-rollup';
|
126
142
|
export { _getId } from './_tsup-dts-rollup';
|
package/dist/prosekit-core.js
CHANGED
@@ -35,11 +35,10 @@ import {
|
|
35
35
|
stateFromJSON,
|
36
36
|
toReversed,
|
37
37
|
union
|
38
|
-
} from "./chunk-
|
38
|
+
} from "./chunk-M267LRMB.js";
|
39
39
|
|
40
40
|
// src/commands/add-mark.ts
|
41
41
|
import "@prosekit/pm/model";
|
42
|
-
import "@prosekit/pm/state";
|
43
42
|
function addMark(options) {
|
44
43
|
return (state, dispatch) => {
|
45
44
|
var _a, _b;
|
@@ -108,7 +107,6 @@ function expandMarkAfter($pos, predicate) {
|
|
108
107
|
}
|
109
108
|
|
110
109
|
// src/commands/insert-node.ts
|
111
|
-
import "@prosekit/pm/state";
|
112
110
|
import { insertPoint } from "@prosekit/pm/transform";
|
113
111
|
|
114
112
|
// src/utils/set-selection-around.ts
|
@@ -143,7 +141,6 @@ function insertNode(options) {
|
|
143
141
|
|
144
142
|
// src/commands/remove-mark.ts
|
145
143
|
import "@prosekit/pm/model";
|
146
|
-
import "@prosekit/pm/state";
|
147
144
|
function removeMark(options) {
|
148
145
|
return (state, dispatch) => {
|
149
146
|
var _a, _b;
|
@@ -192,9 +189,6 @@ function removeNode(options) {
|
|
192
189
|
};
|
193
190
|
}
|
194
191
|
|
195
|
-
// src/commands/set-block-type.ts
|
196
|
-
import "@prosekit/pm/state";
|
197
|
-
|
198
192
|
// src/utils/get-custom-selection.ts
|
199
193
|
import { TextSelection as TextSelection3 } from "@prosekit/pm/state";
|
200
194
|
function getCustomSelection(state, from, to) {
|
@@ -366,7 +360,6 @@ function toggleMark({ type, attrs }) {
|
|
366
360
|
// src/commands/toggle-node.ts
|
367
361
|
import { setBlockType as setBlockType2 } from "@prosekit/pm/commands";
|
368
362
|
import "@prosekit/pm/model";
|
369
|
-
import "@prosekit/pm/state";
|
370
363
|
function toggleNode({ type, attrs }) {
|
371
364
|
return (state, dispatch, view) => {
|
372
365
|
if (isNodeActive(state, type, attrs)) {
|
@@ -426,7 +419,6 @@ function unsetTextBlockType(tr, from, to) {
|
|
426
419
|
}
|
427
420
|
|
428
421
|
// src/commands/unset-mark.ts
|
429
|
-
import "@prosekit/pm/state";
|
430
422
|
function unsetMark(options) {
|
431
423
|
return (state, dispatch) => {
|
432
424
|
var _a, _b;
|
@@ -440,7 +432,6 @@ function unsetMark(options) {
|
|
440
432
|
|
441
433
|
// src/commands/wrap.ts
|
442
434
|
import "@prosekit/pm/model";
|
443
|
-
import "@prosekit/pm/state";
|
444
435
|
import { findWrapping } from "@prosekit/pm/transform";
|
445
436
|
function wrap({ nodeType, attrs }) {
|
446
437
|
return (state, dispatch) => {
|
@@ -1163,7 +1154,6 @@ var markSpecFacet = defineFacet({
|
|
1163
1154
|
|
1164
1155
|
// src/extensions/node-view.ts
|
1165
1156
|
import { PluginKey as PluginKey5, ProseMirrorPlugin as ProseMirrorPlugin5 } from "@prosekit/pm/state";
|
1166
|
-
import "@prosekit/pm/view";
|
1167
1157
|
function defineNodeView(options) {
|
1168
1158
|
return defineFacetPayload(nodeViewFacet, [options]);
|
1169
1159
|
}
|
@@ -1187,7 +1177,6 @@ var nodeViewFacet = defineFacet({
|
|
1187
1177
|
|
1188
1178
|
// src/extensions/node-view-effect.ts
|
1189
1179
|
import { PluginKey as PluginKey6, ProseMirrorPlugin as ProseMirrorPlugin6 } from "@prosekit/pm/state";
|
1190
|
-
import "@prosekit/pm/view";
|
1191
1180
|
function defineNodeViewFactory(options) {
|
1192
1181
|
const input = [options, null];
|
1193
1182
|
return defineFacetPayload(nodeViewFactoryFacet, [input]);
|
@@ -1285,6 +1274,16 @@ function collectNodes(content) {
|
|
1285
1274
|
throw new ProseKitError(`Invalid node content: ${typeof content}`);
|
1286
1275
|
}
|
1287
1276
|
|
1277
|
+
// src/utils/contains-inline-node.ts
|
1278
|
+
function containsInlineNode(doc, from, to) {
|
1279
|
+
let found = false;
|
1280
|
+
doc.nodesBetween(from, to, (node) => {
|
1281
|
+
if (found) return false;
|
1282
|
+
if (node.isInline) found = true;
|
1283
|
+
});
|
1284
|
+
return found;
|
1285
|
+
}
|
1286
|
+
|
1288
1287
|
// src/utils/default-block-at.ts
|
1289
1288
|
function defaultBlockAt(match) {
|
1290
1289
|
for (let i = 0; i < match.edgeCount; i++) {
|
@@ -1346,6 +1345,7 @@ export {
|
|
1346
1345
|
canUseRegexLookbehind,
|
1347
1346
|
clsx,
|
1348
1347
|
collectNodes,
|
1348
|
+
containsInlineNode,
|
1349
1349
|
createEditor,
|
1350
1350
|
defaultBlockAt,
|
1351
1351
|
defineBaseCommands,
|
package/package.json
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
{
|
2
2
|
"name": "@prosekit/core",
|
3
3
|
"type": "module",
|
4
|
-
"version": "0.7.
|
4
|
+
"version": "0.7.5",
|
5
5
|
"private": false,
|
6
6
|
"author": {
|
7
7
|
"name": "ocavue",
|
@@ -43,13 +43,13 @@
|
|
43
43
|
"clsx": "^2.1.1",
|
44
44
|
"orderedmap": "^2.1.1",
|
45
45
|
"prosemirror-splittable": "^0.1.1",
|
46
|
-
"type-fest": "^4.
|
47
|
-
"@prosekit/pm": "^0.1.
|
46
|
+
"type-fest": "^4.22.1",
|
47
|
+
"@prosekit/pm": "^0.1.7"
|
48
48
|
},
|
49
49
|
"devDependencies": {
|
50
|
-
"tsup": "^8.1.
|
50
|
+
"tsup": "^8.1.2",
|
51
51
|
"typescript": "^5.5.3",
|
52
|
-
"vitest": "^2.0.
|
52
|
+
"vitest": "^2.0.3",
|
53
53
|
"@prosekit/dev": "0.0.0"
|
54
54
|
},
|
55
55
|
"scripts": {
|