@prosekit/core 0.7.6 → 0.7.8
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 +325 -95
- package/dist/{chunk-MOSGJZHV.js → chunk-UKHJHMFE.js} +250 -170
- package/dist/prosekit-core-test.js +13 -19
- package/dist/prosekit-core.d.ts +7 -0
- package/dist/prosekit-core.js +249 -257
- package/package.json +5 -3
@@ -1,16 +1,17 @@
|
|
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';
|
4
3
|
import { Command } from '@prosekit/pm/state';
|
5
4
|
import type { ContentMatch } from '@prosekit/pm/model';
|
6
5
|
import { config as default_alias_1 } from '@prosekit/dev/config-vitest';
|
7
6
|
import type { DirectEditorProps } from '@prosekit/pm/view';
|
8
7
|
import type { DOMEventMap } from '@prosekit/pm/view';
|
8
|
+
import type { DOMOutputSpec } from '@prosekit/pm/model';
|
9
9
|
import { DOMParser as DOMParser_2 } from '@prosekit/pm/model';
|
10
10
|
import { DOMSerializer } from '@prosekit/pm/model';
|
11
11
|
import { EditorState } from '@prosekit/pm/state';
|
12
12
|
import type { EditorStateConfig } from '@prosekit/pm/state';
|
13
13
|
import { EditorView } from '@prosekit/pm/view';
|
14
|
+
import { Fragment } from '@prosekit/pm/model';
|
14
15
|
import type { IsEqual } from 'type-fest';
|
15
16
|
import { Mark } from '@prosekit/pm/model';
|
16
17
|
import type { MarkSpec } from '@prosekit/pm/model';
|
@@ -33,7 +34,8 @@ import { SchemaSpec } from '@prosekit/pm/model';
|
|
33
34
|
import { Selection as Selection_2 } from '@prosekit/pm/state';
|
34
35
|
import { Selection as Selection_3 } from 'prosemirror-state';
|
35
36
|
import type { Simplify } from 'type-fest';
|
36
|
-
import
|
37
|
+
import { Slice } from '@prosekit/pm/model';
|
38
|
+
import type { TagParseRule } from '@prosekit/pm/model';
|
37
39
|
import { TextSelection } from '@prosekit/pm/state';
|
38
40
|
import { Transaction } from '@prosekit/pm/state';
|
39
41
|
import type { UnionToIntersection } from 'type-fest';
|
@@ -121,6 +123,12 @@ export declare function assertTypeEqual<T, U>(_val: IsEqual<T, U>): void;
|
|
121
123
|
*/
|
122
124
|
export declare function assertTypeEqual_alias_1<T, U>(_val: IsEqual<T, U>): void;
|
123
125
|
|
126
|
+
declare interface AttrOptions {
|
127
|
+
attr: string;
|
128
|
+
toDOM?: (value: unknown) => [key: string, value: string] | null | undefined;
|
129
|
+
parseDOM?: (node: HTMLElement) => unknown;
|
130
|
+
}
|
131
|
+
|
124
132
|
export declare function attrsMatch(nodeOrMark: ProseMirrorNode | Mark, attrs: Attrs): boolean;
|
125
133
|
|
126
134
|
/**
|
@@ -225,9 +233,11 @@ declare interface BaseNodeViewOptions {
|
|
225
233
|
export { BaseNodeViewOptions }
|
226
234
|
export { BaseNodeViewOptions as BaseNodeViewOptions_alias_1 }
|
227
235
|
|
228
|
-
|
229
|
-
|
230
|
-
|
236
|
+
declare type BoldExtension = Extension<{
|
237
|
+
Marks: {
|
238
|
+
bold: Attrs;
|
239
|
+
};
|
240
|
+
}>;
|
231
241
|
|
232
242
|
export declare function buildNode(type: NodeType, args: [Attrs | NodeChild | null | undefined, ...NodeChild[]], createNode: CreateNodeFunction): ProseMirrorNode;
|
233
243
|
|
@@ -256,9 +266,28 @@ declare const clsx: (...args: Array<string | boolean | null | undefined>) => str
|
|
256
266
|
export { clsx }
|
257
267
|
export { clsx as clsx_alias_1 }
|
258
268
|
|
269
|
+
declare type CodeBlockExtension = Extension<{
|
270
|
+
Nodes: {
|
271
|
+
codeBlock: {
|
272
|
+
language: string;
|
273
|
+
};
|
274
|
+
};
|
275
|
+
}>;
|
276
|
+
|
277
|
+
/**
|
278
|
+
* Collects all children of a node or a fragment, and returns them as an array.
|
279
|
+
*
|
280
|
+
* @public
|
281
|
+
*/
|
282
|
+
declare function collectChildren(parent: ProseMirrorNode | Fragment): ProseMirrorNode[];
|
283
|
+
export { collectChildren }
|
284
|
+
export { collectChildren as collectChildren_alias_1 }
|
285
|
+
|
259
286
|
/**
|
260
287
|
* Collects all nodes from a given content.
|
261
288
|
*
|
289
|
+
* @deprecated Use `collectChildren` instead.
|
290
|
+
*
|
262
291
|
* @public
|
263
292
|
*/
|
264
293
|
declare function collectNodes(content: NodeContent): ProseMirrorNode[];
|
@@ -317,12 +346,12 @@ export { createEditor as createEditor_alias_1 }
|
|
317
346
|
/**
|
318
347
|
* @internal
|
319
348
|
*/
|
320
|
-
export declare function createMarkActions(schema: Schema, getState:
|
349
|
+
export declare function createMarkActions(schema: Schema, getState: GetStateFunction, applyMark?: ApplyMarkFunction): Record<string, MarkAction>;
|
321
350
|
|
322
351
|
/**
|
323
352
|
* @internal
|
324
353
|
*/
|
325
|
-
export declare function createNodeActions(schema: Schema, getState:
|
354
|
+
export declare function createNodeActions(schema: Schema, getState: GetStateFunction, createNode?: CreateNodeFunction): Record<string, NodeAction>;
|
326
355
|
|
327
356
|
export declare const createNodeForTest: CreateNodeFunction;
|
328
357
|
|
@@ -351,20 +380,32 @@ declare function defaultBlockAt(match: ContentMatch): NodeType_2 | null;
|
|
351
380
|
export { defaultBlockAt }
|
352
381
|
export { defaultBlockAt as defaultBlockAt_alias_1 }
|
353
382
|
|
383
|
+
/**
|
384
|
+
* @public
|
385
|
+
*/
|
354
386
|
declare interface DefaultStateOptions {
|
387
|
+
/**
|
388
|
+
* The starting document to use when creating the editor. It can be a
|
389
|
+
* ProseMirror node JSON object, a HTML string, or a HTML element instance.
|
390
|
+
*/
|
391
|
+
defaultContent?: NodeJSON | string | HTMLElement;
|
355
392
|
/**
|
356
393
|
* A JSON object representing the starting document to use when creating the
|
357
394
|
* editor.
|
395
|
+
*
|
396
|
+
* @deprecated Use `defaultContent` instead.
|
358
397
|
*/
|
359
398
|
defaultDoc?: NodeJSON;
|
360
399
|
/**
|
361
400
|
* A HTML element or a HTML string representing the starting document to use
|
362
401
|
* when creating the editor.
|
402
|
+
*
|
403
|
+
* @deprecated Use `defaultContent` instead.
|
363
404
|
*/
|
364
405
|
defaultHTML?: string | HTMLElement;
|
365
406
|
/**
|
366
407
|
* A JSON object representing the starting selection to use when creating the
|
367
|
-
* editor. It's only used when `
|
408
|
+
* editor. It's only used when `defaultContent` is also provided.
|
368
409
|
*/
|
369
410
|
defaultSelection?: SelectionJSON;
|
370
411
|
}
|
@@ -422,7 +463,14 @@ declare function defineCommands<T extends Record<string, CommandCreator> = Recor
|
|
422
463
|
export { defineCommands }
|
423
464
|
export { defineCommands as defineCommands_alias_1 }
|
424
465
|
|
425
|
-
|
466
|
+
/**
|
467
|
+
* Define a default state for the editor.
|
468
|
+
*
|
469
|
+
* @param options
|
470
|
+
*
|
471
|
+
* @public
|
472
|
+
*/
|
473
|
+
declare function defineDefaultState({ defaultSelection, defaultContent, defaultDoc, defaultHTML, }: DefaultStateOptions): PlainExtension;
|
426
474
|
export { defineDefaultState }
|
427
475
|
export { defineDefaultState as defineDefaultState_alias_1 }
|
428
476
|
|
@@ -524,6 +572,8 @@ export { defineFocusChangeHandler as defineFocusChangeHandler_alias_1 }
|
|
524
572
|
/**
|
525
573
|
* Add undo/redo history to the editor.
|
526
574
|
*
|
575
|
+
* @param options
|
576
|
+
*
|
527
577
|
* @public
|
528
578
|
*/
|
529
579
|
declare function defineHistory({ depth, newGroupDelay, }?: HistoryOptions): HistoryExtension;
|
@@ -685,27 +735,9 @@ export { defineScrollToSelectionHandler as defineScrollToSelectionHandler_alias_
|
|
685
735
|
*/
|
686
736
|
export declare function defineTestExtension(): Union<readonly [BaseCommandsExtension, PlainExtension, DocExtension, HistoryExtension, Extension<{
|
687
737
|
Nodes: {
|
688
|
-
paragraph:
|
689
|
-
};
|
690
|
-
}>, TextExtension, Extension<{
|
691
|
-
Marks: {
|
692
|
-
bold: Attrs_2;
|
693
|
-
};
|
694
|
-
}>, Extension<{
|
695
|
-
Marks: {
|
696
|
-
italic: Attrs_2;
|
697
|
-
};
|
698
|
-
}>, Extension<{
|
699
|
-
Nodes: {
|
700
|
-
heading: Attrs_2;
|
701
|
-
};
|
702
|
-
}>, Extension<{
|
703
|
-
Nodes: {
|
704
|
-
codeBlock: {
|
705
|
-
language: string;
|
706
|
-
};
|
738
|
+
paragraph: Attrs;
|
707
739
|
};
|
708
|
-
}
|
740
|
+
}>, TextExtension, BoldExtension, ItalicExtension, LinkExtension, HeadingExtension, CodeBlockExtension]>;
|
709
741
|
|
710
742
|
/**
|
711
743
|
* @public
|
@@ -851,15 +883,10 @@ export { DropHandler as DropHandler_alias_1 }
|
|
851
883
|
*/
|
852
884
|
declare class Editor<E extends Extension = any> {
|
853
885
|
private instance;
|
854
|
-
private afterMounted;
|
855
886
|
/**
|
856
887
|
* @internal
|
857
888
|
*/
|
858
889
|
constructor(instance: EditorInstance);
|
859
|
-
/**
|
860
|
-
* @internal
|
861
|
-
*/
|
862
|
-
static create(instance: any): Editor;
|
863
890
|
/**
|
864
891
|
* Whether the editor is mounted.
|
865
892
|
*/
|
@@ -872,6 +899,10 @@ declare class Editor<E extends Extension = any> {
|
|
872
899
|
* The editor schema.
|
873
900
|
*/
|
874
901
|
get schema(): Schema<ExtractNodeNames<E>, ExtractMarkNames<E>>;
|
902
|
+
/**
|
903
|
+
* The editor's current state.
|
904
|
+
*/
|
905
|
+
get state(): EditorState;
|
875
906
|
/**
|
876
907
|
* Whether the editor is focused.
|
877
908
|
*/
|
@@ -880,28 +911,24 @@ declare class Editor<E extends Extension = any> {
|
|
880
911
|
* Mount the editor to the given HTML element.
|
881
912
|
* Pass `null` or `undefined` to unmount the editor.
|
882
913
|
*/
|
883
|
-
mount(place: HTMLElement | null | undefined)
|
914
|
+
mount: (place: HTMLElement | null | undefined) => void;
|
884
915
|
/**
|
885
916
|
* Unmount the editor. This is equivalent to `mount(null)`.
|
886
917
|
*/
|
887
|
-
unmount()
|
918
|
+
unmount: () => void;
|
888
919
|
/**
|
889
920
|
* Focus the editor.
|
890
921
|
*/
|
891
|
-
focus()
|
922
|
+
focus: () => void;
|
892
923
|
/**
|
893
924
|
* Blur the editor.
|
894
925
|
*/
|
895
|
-
blur()
|
926
|
+
blur: () => void;
|
896
927
|
/**
|
897
928
|
* Register an extension to the editor. Return a function to unregister the
|
898
929
|
* extension.
|
899
930
|
*/
|
900
|
-
use(extension: Extension)
|
901
|
-
/**
|
902
|
-
* The editor's current state.
|
903
|
-
*/
|
904
|
-
get state(): EditorState;
|
931
|
+
use: (extension: Extension) => VoidFunction;
|
905
932
|
/**
|
906
933
|
* Update the editor's state.
|
907
934
|
*
|
@@ -910,7 +937,22 @@ declare class Editor<E extends Extension = any> {
|
|
910
937
|
* This is an advanced method. Use it only if you have a specific reason to
|
911
938
|
* directly manipulate the editor's state.
|
912
939
|
*/
|
913
|
-
updateState(state: EditorState)
|
940
|
+
updateState: (state: EditorState) => void;
|
941
|
+
/**
|
942
|
+
* Update the editor's document and selection.
|
943
|
+
*
|
944
|
+
* @param content - The new document to set. It can be one of the following:
|
945
|
+
* - A ProseMirror node instance
|
946
|
+
* - A ProseMirror node JSON object
|
947
|
+
* - An HTML string
|
948
|
+
* - An HTML element instance
|
949
|
+
* @param selection - Optional. Specifies the new selection. It can be one of the following:
|
950
|
+
* - A ProseMirror selection instance
|
951
|
+
* - A ProseMirror selection JSON object
|
952
|
+
* - The string "start" (to set selection at the beginning, default value)
|
953
|
+
* - The string "end" (to set selection at the end)
|
954
|
+
*/
|
955
|
+
setContent: (content: ProseMirrorNode | NodeJSON | string | HTMLElement, selection?: SelectionJSON | Selection_2 | "start" | "end") => void;
|
914
956
|
/**
|
915
957
|
* All {@link CommandAction}s defined by the editor.
|
916
958
|
*/
|
@@ -928,6 +970,8 @@ export { Editor }
|
|
928
970
|
export { Editor as Editor_alias_1 }
|
929
971
|
|
930
972
|
/**
|
973
|
+
* An internal class to make TypeScript generic type easier to use.
|
974
|
+
*
|
931
975
|
* @internal
|
932
976
|
*/
|
933
977
|
export declare class EditorInstance {
|
@@ -938,10 +982,13 @@ export declare class EditorInstance {
|
|
938
982
|
commands: Record<string, CommandAction>;
|
939
983
|
private tree;
|
940
984
|
private directEditorProps;
|
985
|
+
private afterMounted;
|
941
986
|
constructor(extension: Extension);
|
942
987
|
getState: () => EditorState;
|
943
988
|
updateState(state: EditorState): void;
|
944
|
-
|
989
|
+
setContent(content: NodeJSON | string | HTMLElement | ProseMirrorNode, selection?: SelectionJSON | Selection_2 | 'start' | 'end'): void;
|
990
|
+
private updateExtension;
|
991
|
+
use(extension: Extension): VoidFunction;
|
945
992
|
mount(place: HTMLElement): void;
|
946
993
|
unmount(): void;
|
947
994
|
get mounted(): boolean;
|
@@ -969,19 +1016,28 @@ declare interface EditorOptions<E extends Extension> {
|
|
969
1016
|
* The extension to use when creating the editor.
|
970
1017
|
*/
|
971
1018
|
extension: E;
|
1019
|
+
/**
|
1020
|
+
* The starting document to use when creating the editor. It can be a
|
1021
|
+
* ProseMirror node JSON object, a HTML string, or a HTML element instance.
|
1022
|
+
*/
|
1023
|
+
defaultContent?: NodeJSON | string | HTMLElement;
|
972
1024
|
/**
|
973
1025
|
* A JSON object representing the starting document to use when creating the
|
974
1026
|
* editor.
|
1027
|
+
*
|
1028
|
+
* @deprecated Use `defaultContent` instead.
|
975
1029
|
*/
|
976
1030
|
defaultDoc?: NodeJSON;
|
977
1031
|
/**
|
978
1032
|
* A HTML element or a HTML string representing the starting document to use
|
979
1033
|
* when creating the editor.
|
1034
|
+
*
|
1035
|
+
* @deprecated Use `defaultContent` instead.
|
980
1036
|
*/
|
981
1037
|
defaultHTML?: string | HTMLElement;
|
982
1038
|
/**
|
983
1039
|
* A JSON object representing the starting selection to use when creating the
|
984
|
-
* editor. It's only used when `
|
1040
|
+
* editor. It's only used when `defaultContent` is also provided.
|
985
1041
|
*/
|
986
1042
|
defaultSelection?: SelectionJSON;
|
987
1043
|
}
|
@@ -1216,10 +1272,63 @@ export declare function findBrowserWindow(options?: {
|
|
1216
1272
|
document?: Document;
|
1217
1273
|
}): (Window & typeof globalThis) | null | undefined;
|
1218
1274
|
|
1219
|
-
|
1220
|
-
|
1221
|
-
|
1222
|
-
|
1275
|
+
/**
|
1276
|
+
* Find the closest parent node that satisfies the predicate.
|
1277
|
+
*
|
1278
|
+
* @public
|
1279
|
+
*/
|
1280
|
+
declare function findParentNode(
|
1281
|
+
/**
|
1282
|
+
* The predicate to test the parent node.
|
1283
|
+
*/
|
1284
|
+
predicate: (node: ProseMirrorNode) => boolean,
|
1285
|
+
/**
|
1286
|
+
* The position to start searching from.
|
1287
|
+
*/
|
1288
|
+
$pos: ResolvedPos): FindParentNodeResult | undefined;
|
1289
|
+
export { findParentNode }
|
1290
|
+
export { findParentNode as findParentNode_alias_1 }
|
1291
|
+
|
1292
|
+
/**
|
1293
|
+
* Finds the closest parent node that matches the given node type.
|
1294
|
+
*
|
1295
|
+
* @public
|
1296
|
+
*/
|
1297
|
+
declare function findParentNodeOfType(
|
1298
|
+
/**
|
1299
|
+
* The type of the node to remove.
|
1300
|
+
*/
|
1301
|
+
type: NodeType | string,
|
1302
|
+
/**
|
1303
|
+
* The position to start searching from.
|
1304
|
+
*/
|
1305
|
+
$pos: ResolvedPos): FindParentNodeResult | undefined;
|
1306
|
+
export { findParentNodeOfType }
|
1307
|
+
export { findParentNodeOfType as findParentNodeOfType_alias_1 }
|
1308
|
+
|
1309
|
+
/**
|
1310
|
+
* @public
|
1311
|
+
*/
|
1312
|
+
declare interface FindParentNodeResult {
|
1313
|
+
/**
|
1314
|
+
* The closest parent node that satisfies the predicate.
|
1315
|
+
*/
|
1316
|
+
node: ProseMirrorNode;
|
1317
|
+
/**
|
1318
|
+
* The position directly before the node.
|
1319
|
+
*/
|
1320
|
+
pos: number;
|
1321
|
+
/**
|
1322
|
+
* The position at the start of the node.
|
1323
|
+
*/
|
1324
|
+
start: number;
|
1325
|
+
/**
|
1326
|
+
* The depth of the node.
|
1327
|
+
*/
|
1328
|
+
depth: number;
|
1329
|
+
}
|
1330
|
+
export { FindParentNodeResult }
|
1331
|
+
export { FindParentNodeResult as FindParentNodeResult_alias_1 }
|
1223
1332
|
|
1224
1333
|
/**
|
1225
1334
|
* A function that is called when the editor gains or loses focus.
|
@@ -1242,6 +1351,14 @@ export declare function getBrowserWindow(options?: {
|
|
1242
1351
|
|
1243
1352
|
export declare function getCustomSelection(state: EditorState, from?: number | null, to?: number | null): Selection_3;
|
1244
1353
|
|
1354
|
+
export declare function getEditorContentDoc(schema: Schema, content: NodeJSON | string | HTMLElement | ProseMirrorNode): ProseMirrorNode;
|
1355
|
+
|
1356
|
+
export declare function getEditorContentJSON(schema: Schema, content: NodeJSON | string | HTMLElement): NodeJSON;
|
1357
|
+
|
1358
|
+
export declare function getEditorContentNode(schema: Schema, content: NodeJSON | string | HTMLElement | ProseMirrorNode): ProseMirrorNode;
|
1359
|
+
|
1360
|
+
export declare function getEditorSelection(doc: ProseMirrorNode, selection: SelectionJSON | Selection_2 | 'start' | 'end'): Selection_2;
|
1361
|
+
|
1245
1362
|
/**
|
1246
1363
|
* Returns a unique id in the current process that can be used in various places.
|
1247
1364
|
*
|
@@ -1270,11 +1387,19 @@ export { getNodeType as getNodeType_alias_1 }
|
|
1270
1387
|
*/
|
1271
1388
|
export declare function getNodeTypes(schema: Schema, types: string | NodeType | string[] | NodeType[]): NodeType[];
|
1272
1389
|
|
1273
|
-
|
1390
|
+
declare type GetStateFunction = () => EditorState | null | undefined;
|
1391
|
+
|
1392
|
+
export declare function groupBy<K extends PropertyKey, T>(items: Iterable<T>, keySelector: (item: T) => K): Partial<Record<K, T[]>>;
|
1393
|
+
|
1394
|
+
export declare function groupEntries<T extends Record<string, any>>(entries: ObjectEntries<T>[]): {
|
1274
1395
|
[K in keyof T]?: T[K][];
|
1275
1396
|
};
|
1276
1397
|
|
1277
|
-
|
1398
|
+
declare type HeadingExtension = Extension<{
|
1399
|
+
Nodes: {
|
1400
|
+
heading: Attrs;
|
1401
|
+
};
|
1402
|
+
}>;
|
1278
1403
|
|
1279
1404
|
/**
|
1280
1405
|
* @internal
|
@@ -1377,6 +1502,8 @@ declare interface InsertNodeOptions {
|
|
1377
1502
|
export { InsertNodeOptions }
|
1378
1503
|
export { InsertNodeOptions as InsertNodeOptions_alias_1 }
|
1379
1504
|
|
1505
|
+
export declare function insertOutputSpecAttrs(dom: DOMOutputSpec, attrs: Array<[key: string, value: string]>): DOMOutputSpec;
|
1506
|
+
|
1380
1507
|
/**
|
1381
1508
|
* Returns a command that inserts the given text.
|
1382
1509
|
*
|
@@ -1394,7 +1521,9 @@ export declare type InsertTextOptions = {
|
|
1394
1521
|
};
|
1395
1522
|
|
1396
1523
|
/**
|
1397
|
-
*
|
1524
|
+
* Checks if the given object is a `AllSelection` instance.
|
1525
|
+
*
|
1526
|
+
* @public
|
1398
1527
|
*/
|
1399
1528
|
declare function isAllSelection(sel: Selection_2): sel is AllSelection;
|
1400
1529
|
export { isAllSelection }
|
@@ -1416,7 +1545,16 @@ declare function isAtBlockStart(state: EditorState, view?: EditorView): Resolved
|
|
1416
1545
|
export { isAtBlockStart }
|
1417
1546
|
export { isAtBlockStart as isAtBlockStart_alias_1 }
|
1418
1547
|
|
1419
|
-
export declare function isElement(
|
1548
|
+
export declare function isElement(el: unknown): el is Element;
|
1549
|
+
|
1550
|
+
/**
|
1551
|
+
* Checks if the given object is a `Fragment` instance.
|
1552
|
+
*
|
1553
|
+
* @public
|
1554
|
+
*/
|
1555
|
+
declare function isFragment(fragment: unknown): fragment is Fragment;
|
1556
|
+
export { isFragment }
|
1557
|
+
export { isFragment as isFragment_alias_1 }
|
1420
1558
|
|
1421
1559
|
/**
|
1422
1560
|
* Check if the selection is in a code block.
|
@@ -1428,7 +1566,9 @@ export { isInCodeBlock }
|
|
1428
1566
|
export { isInCodeBlock as isInCodeBlock_alias_1 }
|
1429
1567
|
|
1430
1568
|
/**
|
1431
|
-
*
|
1569
|
+
* Checks if the given object is a `Mark` instance.
|
1570
|
+
*
|
1571
|
+
* @public
|
1432
1572
|
*/
|
1433
1573
|
declare function isMark(mark: unknown): mark is Mark;
|
1434
1574
|
export { isMark }
|
@@ -1455,21 +1595,46 @@ export { isMarkActive as isMarkActive_alias_1 }
|
|
1455
1595
|
export declare function isNodeActive(state: EditorState, type: string | NodeType, attrs?: Attrs | null): boolean;
|
1456
1596
|
|
1457
1597
|
/**
|
1458
|
-
*
|
1598
|
+
* Checks if the given object is a `NodeSelection` instance.
|
1599
|
+
*
|
1600
|
+
* @public
|
1459
1601
|
*/
|
1460
1602
|
declare function isNodeSelection(sel: Selection_2): sel is NodeSelection;
|
1461
1603
|
export { isNodeSelection }
|
1462
1604
|
export { isNodeSelection as isNodeSelection_alias_1 }
|
1463
1605
|
|
1464
|
-
export declare function isNotNull<T>(value: T | null | undefined): value is T;
|
1465
|
-
|
1466
1606
|
/**
|
1467
1607
|
* @internal
|
1468
1608
|
*/
|
1609
|
+
export declare function isNotNullish<T>(value: T | null | undefined | void): value is T;
|
1610
|
+
|
1611
|
+
export declare function isObject(v: unknown): v is Record<string, unknown>;
|
1612
|
+
|
1613
|
+
/**
|
1614
|
+
* Checks if the given object is a `ProseMirrorNode` instance.
|
1615
|
+
*/
|
1469
1616
|
declare function isProseMirrorNode(node: unknown): node is ProseMirrorNode;
|
1470
1617
|
export { isProseMirrorNode }
|
1471
1618
|
export { isProseMirrorNode as isProseMirrorNode_alias_1 }
|
1472
1619
|
|
1620
|
+
/**
|
1621
|
+
* Checks if the given object is a `Selection` instance.
|
1622
|
+
*
|
1623
|
+
* @public
|
1624
|
+
*/
|
1625
|
+
declare function isSelection(sel: unknown): sel is Selection_2;
|
1626
|
+
export { isSelection }
|
1627
|
+
export { isSelection as isSelection_alias_1 }
|
1628
|
+
|
1629
|
+
/**
|
1630
|
+
* Checks if the given object is a `Slice` instance.
|
1631
|
+
*
|
1632
|
+
* @public
|
1633
|
+
*/
|
1634
|
+
declare function isSlice(slice: unknown): slice is Slice;
|
1635
|
+
export { isSlice }
|
1636
|
+
export { isSlice as isSlice_alias_1 }
|
1637
|
+
|
1473
1638
|
/**
|
1474
1639
|
* Check if `subset` is a subset of `superset`.
|
1475
1640
|
*
|
@@ -1478,12 +1643,20 @@ export { isProseMirrorNode as isProseMirrorNode_alias_1 }
|
|
1478
1643
|
export declare function isSubset(subset: Record<string, unknown>, superset: Record<string, unknown>): boolean;
|
1479
1644
|
|
1480
1645
|
/**
|
1481
|
-
*
|
1646
|
+
* Checks if the given object is a `TextSelection` instance.
|
1647
|
+
*
|
1648
|
+
* @public
|
1482
1649
|
*/
|
1483
1650
|
declare function isTextSelection(sel: Selection_2): sel is TextSelection;
|
1484
1651
|
export { isTextSelection }
|
1485
1652
|
export { isTextSelection as isTextSelection_alias_1 }
|
1486
1653
|
|
1654
|
+
declare type ItalicExtension = Extension<{
|
1655
|
+
Marks: {
|
1656
|
+
italic: Attrs;
|
1657
|
+
};
|
1658
|
+
}>;
|
1659
|
+
|
1487
1660
|
/**
|
1488
1661
|
* Serialize a HTML element to a ProseMirror document JSON object.
|
1489
1662
|
*
|
@@ -1556,6 +1729,16 @@ declare type KeyPressHandler = (view: EditorView, event: KeyboardEvent) => boole
|
|
1556
1729
|
export { KeyPressHandler }
|
1557
1730
|
export { KeyPressHandler as KeyPressHandler_alias_1 }
|
1558
1731
|
|
1732
|
+
declare interface LinkAttrs {
|
1733
|
+
href: string;
|
1734
|
+
}
|
1735
|
+
|
1736
|
+
declare type LinkExtension = Extension<{
|
1737
|
+
Marks: {
|
1738
|
+
link: LinkAttrs;
|
1739
|
+
};
|
1740
|
+
}>;
|
1741
|
+
|
1559
1742
|
/**
|
1560
1743
|
* A function for creating a mark with optional attributes and any number of
|
1561
1744
|
* children.
|
@@ -1591,13 +1774,18 @@ declare interface MarkAttrOptions<MarkName extends string = string, AttrName ext
|
|
1591
1774
|
*/
|
1592
1775
|
attr: AttrName;
|
1593
1776
|
/**
|
1594
|
-
* Returns the attribute key and value to be set on the
|
1777
|
+
* Returns the attribute key and value to be set on the HTML element.
|
1778
|
+
*
|
1779
|
+
* If the returned `key` is `"style"`, the value is a string of CSS properties and will
|
1780
|
+
* be prepended to the existing `style` attribute on the DOM node.
|
1781
|
+
*
|
1782
|
+
* @param value - The value of the attribute of current ProseMirror node.
|
1595
1783
|
*/
|
1596
|
-
toDOM?: (value:
|
1784
|
+
toDOM?: (value: AttrType) => [key: string, value: string] | null | undefined;
|
1597
1785
|
/**
|
1598
1786
|
* Parses the attribute value from the DOM.
|
1599
1787
|
*/
|
1600
|
-
parseDOM?: (node: HTMLElement) =>
|
1788
|
+
parseDOM?: (node: HTMLElement) => AttrType;
|
1601
1789
|
}
|
1602
1790
|
export { MarkAttrOptions }
|
1603
1791
|
export { MarkAttrOptions as MarkAttrOptions_alias_1 }
|
@@ -1643,6 +1831,12 @@ declare function maybeRun<T, R = T extends (...args: any[]) => void ? ReturnType
|
|
1643
1831
|
export { maybeRun }
|
1644
1832
|
export { maybeRun as maybeRun_alias_1 }
|
1645
1833
|
|
1834
|
+
export declare function mergeObjects<T extends object>(...objects: Array<Partial<T> | null | undefined>): Partial<T>;
|
1835
|
+
|
1836
|
+
export declare function mergeSpecs(a: NodeSpec, b: NodeSpec): NodeSpec;
|
1837
|
+
|
1838
|
+
export declare function mergeSpecs(a: MarkSpec, b: MarkSpec): MarkSpec;
|
1839
|
+
|
1646
1840
|
/**
|
1647
1841
|
* A function that is called when the editor view is mounted.
|
1648
1842
|
*
|
@@ -1697,16 +1891,18 @@ declare interface NodeAttrOptions<NodeName extends string = string, AttrName ext
|
|
1697
1891
|
*/
|
1698
1892
|
splittable?: boolean;
|
1699
1893
|
/**
|
1700
|
-
* Returns the attribute key and value to be set on the
|
1894
|
+
* Returns the attribute key and value to be set on the HTML element.
|
1701
1895
|
*
|
1702
|
-
* If the `key` is `"style"`, the value is a string of CSS properties and will
|
1896
|
+
* If the returned `key` is `"style"`, the value is a string of CSS properties and will
|
1703
1897
|
* be prepended to the existing `style` attribute on the DOM node.
|
1898
|
+
*
|
1899
|
+
* @param value - The value of the attribute of current ProseMirror node.
|
1704
1900
|
*/
|
1705
|
-
toDOM?: (value:
|
1901
|
+
toDOM?: (value: AttrType) => [key: string, value: string] | null | undefined;
|
1706
1902
|
/**
|
1707
1903
|
* Parses the attribute value from the DOM.
|
1708
1904
|
*/
|
1709
|
-
parseDOM?: (node: HTMLElement) =>
|
1905
|
+
parseDOM?: (node: HTMLElement) => AttrType;
|
1710
1906
|
}
|
1711
1907
|
export { NodeAttrOptions }
|
1712
1908
|
export { NodeAttrOptions as NodeAttrOptions_alias_1 }
|
@@ -1729,6 +1925,8 @@ export { NodeChild as NodeChild_alias_1 }
|
|
1729
1925
|
|
1730
1926
|
/**
|
1731
1927
|
* @public
|
1928
|
+
*
|
1929
|
+
* @deprecated
|
1732
1930
|
*/
|
1733
1931
|
declare type NodeContent = ProseMirrorNode | ProseMirrorFragment | NodeContent[];
|
1734
1932
|
export { NodeContent }
|
@@ -1768,7 +1966,10 @@ export { nodeFromJSON as nodeFromJSON_alias_1 }
|
|
1768
1966
|
*/
|
1769
1967
|
declare interface NodeJSON {
|
1770
1968
|
type: string;
|
1771
|
-
marks?: Array<
|
1969
|
+
marks?: Array<{
|
1970
|
+
type: string;
|
1971
|
+
attrs?: Record<string, any>;
|
1972
|
+
}>;
|
1772
1973
|
text?: string;
|
1773
1974
|
content?: NodeJSON[];
|
1774
1975
|
attrs?: Record<string, any>;
|
@@ -2002,13 +2203,16 @@ declare interface RemoveNodeOptions {
|
|
2002
2203
|
*/
|
2003
2204
|
type: string | NodeType;
|
2004
2205
|
/**
|
2005
|
-
* The document position to start searching node. By default it will be the
|
2206
|
+
* The document position to start searching node. By default it will be the
|
2207
|
+
* anchor position of current selection.
|
2006
2208
|
*/
|
2007
2209
|
pos?: number;
|
2008
2210
|
}
|
2009
2211
|
export { RemoveNodeOptions }
|
2010
2212
|
export { RemoveNodeOptions as RemoveNodeOptions_alias_1 }
|
2011
2213
|
|
2214
|
+
export declare function removeUndefinedValues<T extends object>(obj: T): T;
|
2215
|
+
|
2012
2216
|
export declare const rootFacet: Facet<RootPayload, RootOutput>;
|
2013
2217
|
|
2014
2218
|
export declare type RootOutput = {
|
@@ -2127,27 +2331,9 @@ export declare function setupEditorExtension<E extends Extension>(options: Edito
|
|
2127
2331
|
export declare function setupTest(): {
|
2128
2332
|
editor: TestEditor<Union<readonly [BaseCommandsExtension, PlainExtension, DocExtension, HistoryExtension, Extension<{
|
2129
2333
|
Nodes: {
|
2130
|
-
paragraph:
|
2131
|
-
};
|
2132
|
-
}>, TextExtension, Extension<{
|
2133
|
-
Marks: {
|
2134
|
-
bold: Attrs_2;
|
2135
|
-
};
|
2136
|
-
}>, Extension<{
|
2137
|
-
Marks: {
|
2138
|
-
italic: Attrs_2;
|
2139
|
-
};
|
2140
|
-
}>, Extension<{
|
2141
|
-
Nodes: {
|
2142
|
-
heading: Attrs_2;
|
2143
|
-
};
|
2144
|
-
}>, Extension<{
|
2145
|
-
Nodes: {
|
2146
|
-
codeBlock: {
|
2147
|
-
language: string;
|
2148
|
-
};
|
2334
|
+
paragraph: Attrs;
|
2149
2335
|
};
|
2150
|
-
}
|
2336
|
+
}>, TextExtension, BoldExtension, ItalicExtension, LinkExtension, HeadingExtension, CodeBlockExtension]>>;
|
2151
2337
|
m: ToMarkAction<SimplifyDeeper< {
|
2152
2338
|
bold: {
|
2153
2339
|
readonly [x: string]: any;
|
@@ -2155,6 +2341,9 @@ export declare function setupTest(): {
|
|
2155
2341
|
italic: {
|
2156
2342
|
readonly [x: string]: any;
|
2157
2343
|
};
|
2344
|
+
link: {
|
2345
|
+
href: string;
|
2346
|
+
};
|
2158
2347
|
}>>;
|
2159
2348
|
n: {
|
2160
2349
|
p: NodeAction< {
|
@@ -2169,12 +2358,12 @@ export declare function setupTest(): {
|
|
2169
2358
|
text: NodeAction< {
|
2170
2359
|
readonly [x: string]: any;
|
2171
2360
|
}>;
|
2172
|
-
codeBlock: NodeAction< {
|
2173
|
-
language: string;
|
2174
|
-
}>;
|
2175
2361
|
heading: NodeAction< {
|
2176
2362
|
readonly [x: string]: any;
|
2177
2363
|
}>;
|
2364
|
+
codeBlock: NodeAction< {
|
2365
|
+
language: string;
|
2366
|
+
}>;
|
2178
2367
|
};
|
2179
2368
|
};
|
2180
2369
|
|
@@ -2318,9 +2507,11 @@ export declare type ToCommandCreators<T extends CommandTyping> = {
|
|
2318
2507
|
/**
|
2319
2508
|
* Returns a command that toggles the given mark with the given attributes.
|
2320
2509
|
*
|
2510
|
+
* @param options
|
2511
|
+
*
|
2321
2512
|
* @public
|
2322
2513
|
*/
|
2323
|
-
declare function toggleMark({ type, attrs }: ToggleMarkOptions): Command;
|
2514
|
+
declare function toggleMark({ type, attrs, removeWhenPresent, enterInlineAtoms, }: ToggleMarkOptions): Command;
|
2324
2515
|
export { toggleMark }
|
2325
2516
|
export { toggleMark as toggleMark_alias_1 }
|
2326
2517
|
|
@@ -2328,8 +2519,30 @@ export { toggleMark as toggleMark_alias_1 }
|
|
2328
2519
|
* @public
|
2329
2520
|
*/
|
2330
2521
|
declare interface ToggleMarkOptions {
|
2522
|
+
/**
|
2523
|
+
* The mark type to toggle.
|
2524
|
+
*/
|
2331
2525
|
type: string | MarkType;
|
2526
|
+
/**
|
2527
|
+
* The optional attributes to set on the mark.
|
2528
|
+
*/
|
2332
2529
|
attrs?: Attrs | null;
|
2530
|
+
/**
|
2531
|
+
* Controls whether, when part of the selected range has the mark
|
2532
|
+
* already and part doesn't, the mark is removed (`true`) or added
|
2533
|
+
* (`false`).
|
2534
|
+
*
|
2535
|
+
* @default false
|
2536
|
+
*/
|
2537
|
+
removeWhenPresent?: boolean;
|
2538
|
+
/**
|
2539
|
+
* Whether the command should act on the content of inline nodes marked as
|
2540
|
+
* [atoms](https://prosemirror.net/docs/ref/#model.NodeSpec.atom) that are
|
2541
|
+
* completely covered by a selection range.
|
2542
|
+
*
|
2543
|
+
* @default true
|
2544
|
+
*/
|
2545
|
+
enterInlineAtoms?: boolean;
|
2333
2546
|
}
|
2334
2547
|
export { ToggleMarkOptions }
|
2335
2548
|
export { ToggleMarkOptions as ToggleMarkOptions_alias_1 }
|
@@ -2338,6 +2551,8 @@ export { ToggleMarkOptions as ToggleMarkOptions_alias_1 }
|
|
2338
2551
|
* Returns a command that set the selected textblocks to the given node type
|
2339
2552
|
* with the given attributes.
|
2340
2553
|
*
|
2554
|
+
* @param options
|
2555
|
+
*
|
2341
2556
|
* @public
|
2342
2557
|
*/
|
2343
2558
|
declare function toggleNode({ type, attrs }: ToggleNodeOptions): Command;
|
@@ -2568,12 +2783,13 @@ export { withSkipCodeBlock }
|
|
2568
2783
|
export { withSkipCodeBlock as withSkipCodeBlock_alias_1 }
|
2569
2784
|
|
2570
2785
|
/**
|
2571
|
-
* Returns a command that wraps the selected textblock with the given node type
|
2572
|
-
*
|
2786
|
+
* Returns a command that wraps the selected textblock with the given node type.
|
2787
|
+
*
|
2788
|
+
* @param options
|
2573
2789
|
*
|
2574
2790
|
* @public
|
2575
2791
|
*/
|
2576
|
-
declare function wrap(
|
2792
|
+
declare function wrap(options: WrapOptions): Command;
|
2577
2793
|
export { wrap }
|
2578
2794
|
export { wrap as wrap_alias_1 }
|
2579
2795
|
|
@@ -2581,12 +2797,26 @@ export { wrap as wrap_alias_1 }
|
|
2581
2797
|
* @public
|
2582
2798
|
*/
|
2583
2799
|
declare interface WrapOptions {
|
2800
|
+
/**
|
2801
|
+
* The node type to wrap the selected textblock with.
|
2802
|
+
*/
|
2803
|
+
type: NodeType | string;
|
2804
|
+
/**
|
2805
|
+
* @deprecated Use `nodeSpec` instead.
|
2806
|
+
*/
|
2584
2807
|
nodeType: NodeType;
|
2808
|
+
/**
|
2809
|
+
* Optional attributes to apply to the node.
|
2810
|
+
*/
|
2585
2811
|
attrs?: Attrs | null;
|
2586
2812
|
}
|
2587
2813
|
export { WrapOptions }
|
2588
2814
|
export { WrapOptions as WrapOptions_alias_1 }
|
2589
2815
|
|
2816
|
+
export declare function wrapOutputSpecAttrs<T extends ProseMirrorNode | Mark, Args extends readonly unknown[]>(toDOM: (node: T, ...args: Args) => DOMOutputSpec, options: AttrOptions[]): (node: T, ...args: Args) => DOMOutputSpec;
|
2817
|
+
|
2818
|
+
export declare function wrapTagParseRuleAttrs(rule: TagParseRule, options: AttrOptions[]): TagParseRule;
|
2819
|
+
|
2590
2820
|
export declare function zip<T, P>(a: T[], b: P[]): [T, P][];
|
2591
2821
|
|
2592
2822
|
export { }
|