@prosekit/core 0.8.1 → 0.8.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{editor-BP9kgR6R.d.ts → editor-CjVyjJqw.d.ts} +13 -24
- package/dist/{editor-BOiNwODb.js → editor-DbMrpnmL.js} +153 -71
- package/dist/prosekit-core-test.d.ts +2 -6
- package/dist/prosekit-core-test.js +1 -1
- package/dist/prosekit-core.d.ts +14 -82
- package/dist/prosekit-core.js +5 -18
- package/package.json +6 -6
@@ -7,11 +7,6 @@ import { Simplify, UnionToIntersection } from "type-fest";
|
|
7
7
|
/**
|
8
8
|
* An object holding the attributes of a node.
|
9
9
|
|
10
|
-
* @public
|
11
|
-
*/
|
12
|
-
/**
|
13
|
-
* An object holding the attributes of a node.
|
14
|
-
|
15
10
|
* @public
|
16
11
|
*/
|
17
12
|
type AnyAttrs = Attrs;
|
@@ -36,7 +31,8 @@ type AttrSpec<AttrType = any> = {
|
|
36
31
|
* one of those types.
|
37
32
|
*/
|
38
33
|
validate?: string | ((value: unknown) => void);
|
39
|
-
};
|
34
|
+
};
|
35
|
+
//#endregion
|
40
36
|
//#region src/editor/action.d.ts
|
41
37
|
/**
|
42
38
|
* Available children parameters for {@link NodeAction} and {@link MarkAction}.
|
@@ -90,12 +86,11 @@ type NodeBuilder = NodeAction;
|
|
90
86
|
* @deprecated Use type {@link MarkAction} instead.
|
91
87
|
*/
|
92
88
|
type MarkBuilder = MarkAction;
|
93
|
-
|
94
|
-
//#endregion
|
95
|
-
//#region src/types/extension-command.d.ts
|
96
89
|
/**
|
97
90
|
* @internal
|
98
91
|
*/
|
92
|
+
//#endregion
|
93
|
+
//#region src/types/extension-command.d.ts
|
99
94
|
/**
|
100
95
|
* A function to apply a command to the editor. It will return `true` if the command was applied, and `false` otherwise.
|
101
96
|
*
|
@@ -130,7 +125,6 @@ interface CommandTyping {
|
|
130
125
|
}
|
131
126
|
type ToCommandCreators<T extends CommandTyping> = { [K in keyof T]: CommandCreator<T[K]> };
|
132
127
|
type ToCommandAction<T extends CommandTyping> = { [K in keyof T]: CommandAction<T[K]> };
|
133
|
-
|
134
128
|
//#endregion
|
135
129
|
//#region src/types/extension-mark.d.ts
|
136
130
|
/**
|
@@ -143,7 +137,6 @@ interface MarkTyping {
|
|
143
137
|
* @internal
|
144
138
|
*/
|
145
139
|
type ToMarkAction<T extends MarkTyping> = { [K in keyof T]: MarkAction<T[K]> };
|
146
|
-
|
147
140
|
//#endregion
|
148
141
|
//#region src/types/extension-node.d.ts
|
149
142
|
/**
|
@@ -156,21 +149,18 @@ interface NodeTyping {
|
|
156
149
|
* @internal
|
157
150
|
*/
|
158
151
|
type ToNodeAction<T extends NodeTyping> = { [K in keyof T]: NodeAction<T[K]> };
|
159
|
-
|
160
152
|
//#endregion
|
161
153
|
//#region src/types/pick-sub-type.d.ts
|
162
154
|
/**
|
163
155
|
* @internal
|
164
156
|
*/
|
165
157
|
type PickSubType<Type, ParentType> = Type extends ParentType ? [ParentType] extends [Type] ? never : Type : never;
|
166
|
-
|
167
158
|
//#endregion
|
168
159
|
//#region src/types/pick-string-literal.d.ts
|
169
160
|
/**
|
170
161
|
* @internal
|
171
162
|
*/
|
172
163
|
type PickStringLiteral<T> = PickSubType<T, string>;
|
173
|
-
|
174
164
|
//#endregion
|
175
165
|
//#region src/types/priority.d.ts
|
176
166
|
/**
|
@@ -185,27 +175,24 @@ declare enum Priority {
|
|
185
175
|
high = 3,
|
186
176
|
highest = 4,
|
187
177
|
}
|
188
|
-
|
189
178
|
//#endregion
|
190
179
|
//#region src/types/simplify-deeper.d.ts
|
191
180
|
/**
|
192
181
|
* @internal
|
193
182
|
*/
|
194
183
|
type SimplifyDeeper<T> = { [KeyType in keyof T]: Simplify<T[KeyType]> };
|
195
|
-
|
196
184
|
//#endregion
|
197
185
|
//#region src/types/simplify-union.d.ts
|
198
186
|
/**
|
199
187
|
* @internal
|
200
188
|
*/
|
201
189
|
type SimplifyUnion<T> = Simplify<UnionToIntersection<T extends undefined ? never : T>>;
|
202
|
-
|
203
190
|
//#endregion
|
204
191
|
//#region src/types/extension.d.ts
|
205
192
|
/**
|
206
193
|
* @internal
|
207
194
|
*/
|
208
|
-
interface ExtensionTyping<N extends NodeTyping
|
195
|
+
interface ExtensionTyping<N extends NodeTyping = never, M extends MarkTyping = never, C extends CommandTyping = never> {
|
209
196
|
Nodes?: N;
|
210
197
|
Marks?: M;
|
211
198
|
Commands?: C;
|
@@ -301,7 +288,6 @@ type UnionExtension<E extends Extension | readonly Extension[]> = E extends read
|
|
301
288
|
Marks: ExtractMarks<E[number]>;
|
302
289
|
Commands: ExtractCommands<E[number]>;
|
303
290
|
}> : E;
|
304
|
-
|
305
291
|
//#endregion
|
306
292
|
//#region src/types/model.d.ts
|
307
293
|
/**
|
@@ -356,11 +342,9 @@ interface StepJSON {
|
|
356
342
|
stepType: string;
|
357
343
|
[x: string]: unknown;
|
358
344
|
}
|
359
|
-
|
360
345
|
//#endregion
|
361
346
|
//#region src/types/dom-node.d.ts
|
362
347
|
type DOMNode = InstanceType<typeof window.Node>;
|
363
|
-
|
364
348
|
//#endregion
|
365
349
|
//#region src/utils/parse.d.ts
|
366
350
|
/** @public */
|
@@ -389,6 +373,7 @@ interface JSONParserOptions {
|
|
389
373
|
*/
|
390
374
|
schema: Schema;
|
391
375
|
}
|
376
|
+
/////////////// JSON <=> State ///////////////
|
392
377
|
/**
|
393
378
|
* Return a JSON object representing this state.
|
394
379
|
*
|
@@ -415,6 +400,7 @@ declare function jsonFromState(state: EditorState): StateJSON;
|
|
415
400
|
* ```
|
416
401
|
*/
|
417
402
|
declare function stateFromJSON(json: StateJSON, options: JSONParserOptions): EditorState;
|
403
|
+
/////////////// JSON <=> Node ///////////////
|
418
404
|
/**
|
419
405
|
* Return a JSON object representing this node.
|
420
406
|
*
|
@@ -441,6 +427,7 @@ declare function jsonFromNode(node: ProseMirrorNode): NodeJSON;
|
|
441
427
|
* ```
|
442
428
|
*/
|
443
429
|
declare function nodeFromJSON(json: NodeJSON, options: JSONParserOptions): ProseMirrorNode;
|
430
|
+
/////////////// Node <=> Element ///////////////
|
444
431
|
/**
|
445
432
|
* Parse a HTML element to a ProseMirror node.
|
446
433
|
*
|
@@ -466,12 +453,14 @@ declare function nodeFromElement(element: DOMNode, options: DOMParserOptions & J
|
|
466
453
|
* ```
|
467
454
|
*/
|
468
455
|
declare function elementFromNode(node: ProseMirrorNode, options?: DOMSerializerOptions & DOMDocumentOptions): HTMLElement;
|
456
|
+
/////////////// Element <=> HTML ///////////////
|
469
457
|
/**
|
470
458
|
* Parse a HTML string to a HTML element.
|
471
459
|
*
|
472
460
|
* @internal
|
473
461
|
*/
|
474
462
|
|
463
|
+
/////////////// Node <=> HTML ///////////////
|
475
464
|
/**
|
476
465
|
* Parse a HTML string to a ProseMirror node.
|
477
466
|
*
|
@@ -497,6 +486,7 @@ declare function nodeFromHTML(html: string, options: DOMParserOptions & JSONPars
|
|
497
486
|
* ```
|
498
487
|
*/
|
499
488
|
declare function htmlFromNode(node: ProseMirrorNode, options?: DOMSerializerOptions & DOMDocumentOptions): string;
|
489
|
+
/////////////// JSON <=> Element ///////////////
|
500
490
|
/**
|
501
491
|
* Serialize a HTML element to a ProseMirror document JSON object.
|
502
492
|
*
|
@@ -523,6 +513,7 @@ declare function htmlFromNode(node: ProseMirrorNode, options?: DOMSerializerOpti
|
|
523
513
|
* ```
|
524
514
|
*/
|
525
515
|
declare function elementFromJSON(json: NodeJSON, options: JSONParserOptions & DOMSerializerOptions & DOMDocumentOptions): HTMLElement;
|
516
|
+
/////////////// JSON <=> HTML ///////////////
|
526
517
|
/**
|
527
518
|
* Parse a HTML string to a ProseMirror document JSON object.
|
528
519
|
*
|
@@ -549,7 +540,6 @@ declare function jsonFromHTML(html: string, options: DOMDocumentOptions & DOMPar
|
|
549
540
|
* ```
|
550
541
|
*/
|
551
542
|
declare function htmlFromJSON(json: NodeJSON, options: JSONParserOptions & DOMSerializerOptions & DOMDocumentOptions): string;
|
552
|
-
|
553
543
|
//#endregion
|
554
544
|
//#region src/editor/editor.d.ts
|
555
545
|
/**
|
@@ -745,6 +735,5 @@ declare class Editor<E extends Extension = any> {
|
|
745
735
|
*/
|
746
736
|
get marks(): ExtractMarkActions<E>;
|
747
737
|
}
|
748
|
-
|
749
738
|
//#endregion
|
750
|
-
export { AnyAttrs, AttrSpec, CommandAction, CommandCreator, CommandTyping, DOMDocumentOptions, DOMParserOptions, DOMSerializerOptions, Editor
|
739
|
+
export { AnyAttrs, AttrSpec, CommandAction, CommandCreator, CommandTyping, DOMDocumentOptions, DOMParserOptions, DOMSerializerOptions, Editor, EditorInstance, EditorOptions, Extension, ExtensionTyping, ExtractCommandActions, ExtractCommandAppliers, ExtractCommandCreators, ExtractMarkActions, ExtractMarks, ExtractNodeActions, ExtractNodes, JSONParserOptions, MarkAction, MarkBuilder, MarkTyping, NodeAction, NodeBuilder, NodeChild, NodeJSON, NodeTyping, PickSubType, PlainExtension, Priority, SelectionJSON, SimplifyDeeper, SimplifyUnion, StateJSON, StepJSON, ToMarkAction, ToNodeAction, Union, UnionExtension, createEditor, elementFromJSON, elementFromNode, htmlFromJSON, htmlFromNode, jsonFromHTML, jsonFromNode, jsonFromState, nodeFromElement, nodeFromHTML, nodeFromJSON, stateFromJSON };
|
@@ -109,13 +109,30 @@ let facetCount = 0;
|
|
109
109
|
* @internal
|
110
110
|
*/
|
111
111
|
var Facet = class {
|
112
|
+
/**
|
113
|
+
* @internal
|
114
|
+
*/
|
115
|
+
index = facetCount++;
|
116
|
+
/**
|
117
|
+
* @internal
|
118
|
+
*/
|
119
|
+
parent;
|
120
|
+
/**
|
121
|
+
* @internal
|
122
|
+
*/
|
123
|
+
singleton;
|
124
|
+
/**
|
125
|
+
* A index path to retrieve the current facet in a tree from the root.
|
126
|
+
*
|
127
|
+
* @internal
|
128
|
+
*/
|
129
|
+
path;
|
112
130
|
/**
|
113
131
|
* @internal
|
114
132
|
*/
|
115
133
|
constructor(parent, singleton, _reducer, _reduce) {
|
116
134
|
this._reducer = _reducer;
|
117
135
|
this._reduce = _reduce;
|
118
|
-
this.index = facetCount++;
|
119
136
|
assert((_reduce || _reducer) && !(_reduce && _reducer));
|
120
137
|
this.parent = parent;
|
121
138
|
this.singleton = singleton;
|
@@ -174,15 +191,15 @@ const schemaFacet = defineFacet({
|
|
174
191
|
* @internal
|
175
192
|
*/
|
176
193
|
var BaseExtension = class {
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
194
|
+
priority;
|
195
|
+
_type;
|
196
|
+
trees = [
|
197
|
+
null,
|
198
|
+
null,
|
199
|
+
null,
|
200
|
+
null,
|
201
|
+
null
|
202
|
+
];
|
186
203
|
/**
|
187
204
|
* @internal
|
188
205
|
*/
|
@@ -214,7 +231,7 @@ function uniqPush(prev, next) {
|
|
214
231
|
/**
|
215
232
|
* @internal
|
216
233
|
*/
|
217
|
-
function
|
234
|
+
function arraySubtract(a, b) {
|
218
235
|
return a.filter((x) => !b.includes(x));
|
219
236
|
}
|
220
237
|
function toReversed(arr) {
|
@@ -310,7 +327,7 @@ function unionInput(a, b) {
|
|
310
327
|
function subtractInput(a, b) {
|
311
328
|
if (!a) return null;
|
312
329
|
if (!b) return [...a];
|
313
|
-
return
|
330
|
+
return arraySubtract(a, b);
|
314
331
|
}
|
315
332
|
function unionChildren(a, b) {
|
316
333
|
const merged = new Map(a);
|
@@ -353,13 +370,14 @@ function subtractFacetNode(a, b) {
|
|
353
370
|
return new FacetNode(a.facet, zip5(a.inputs, b.inputs, subtractInput), subtractChildren(a.children, b.children), a.reducers);
|
354
371
|
}
|
355
372
|
var FacetNode = class {
|
373
|
+
output = null;
|
356
374
|
constructor(facet, inputs = [
|
357
375
|
null,
|
358
376
|
null,
|
359
377
|
null,
|
360
378
|
null,
|
361
379
|
null
|
362
|
-
], children = new Map(), reducers = [
|
380
|
+
], children = /* @__PURE__ */ new Map(), reducers = [
|
363
381
|
null,
|
364
382
|
null,
|
365
383
|
null,
|
@@ -370,7 +388,6 @@ var FacetNode = class {
|
|
370
388
|
this.inputs = inputs;
|
371
389
|
this.children = children;
|
372
390
|
this.reducers = reducers;
|
373
|
-
this.output = null;
|
374
391
|
}
|
375
392
|
calcOutput() {
|
376
393
|
const inputs = [
|
@@ -980,30 +997,15 @@ function createEditor(options) {
|
|
980
997
|
* @internal
|
981
998
|
*/
|
982
999
|
var EditorInstance = class {
|
1000
|
+
view = null;
|
1001
|
+
schema;
|
1002
|
+
nodes;
|
1003
|
+
marks;
|
1004
|
+
commands = {};
|
1005
|
+
tree;
|
1006
|
+
directEditorProps;
|
1007
|
+
afterMounted = [];
|
983
1008
|
constructor(extension) {
|
984
|
-
this.view = null;
|
985
|
-
this.commands = {};
|
986
|
-
this.afterMounted = [];
|
987
|
-
this.getState = () => {
|
988
|
-
return this.view?.state || this.directEditorProps.state;
|
989
|
-
};
|
990
|
-
this.dispatch = (tr) => {
|
991
|
-
if (this.view) this.view.dispatch(tr);
|
992
|
-
else this.directEditorProps.state = this.directEditorProps.state.apply(tr);
|
993
|
-
};
|
994
|
-
this.getDocJSON = () => {
|
995
|
-
const state$1 = this.getState();
|
996
|
-
return jsonFromNode(state$1.doc);
|
997
|
-
};
|
998
|
-
this.getDocHTML = (options) => {
|
999
|
-
const serializer = this.getProp("clipboardSerializer");
|
1000
|
-
const DOMSerializer$1 = serializer ? { fromSchema: () => serializer } : void 0;
|
1001
|
-
const doc = this.getDoc();
|
1002
|
-
return htmlFromNode(doc, {
|
1003
|
-
...options,
|
1004
|
-
DOMSerializer: DOMSerializer$1
|
1005
|
-
});
|
1006
|
-
};
|
1007
1009
|
this.tree = extension.getTree();
|
1008
1010
|
const payload = this.tree.getRootOutput();
|
1009
1011
|
const schema = payload.schema;
|
@@ -1019,6 +1021,9 @@ var EditorInstance = class {
|
|
1019
1021
|
...payload.view
|
1020
1022
|
};
|
1021
1023
|
}
|
1024
|
+
getState = () => {
|
1025
|
+
return this.view?.state || this.directEditorProps.state;
|
1026
|
+
};
|
1022
1027
|
getDoc() {
|
1023
1028
|
return this.getState().doc;
|
1024
1029
|
}
|
@@ -1029,6 +1034,10 @@ var EditorInstance = class {
|
|
1029
1034
|
if (this.view) this.view.updateState(state);
|
1030
1035
|
else this.directEditorProps.state = state;
|
1031
1036
|
}
|
1037
|
+
dispatch = (tr) => {
|
1038
|
+
if (this.view) this.view.dispatch(tr);
|
1039
|
+
else this.directEditorProps.state = this.directEditorProps.state.apply(tr);
|
1040
|
+
};
|
1032
1041
|
setContent(content, selection) {
|
1033
1042
|
const doc = getEditorContentDoc(this.schema, content);
|
1034
1043
|
doc.check();
|
@@ -1042,6 +1051,25 @@ var EditorInstance = class {
|
|
1042
1051
|
});
|
1043
1052
|
this.updateState(newState);
|
1044
1053
|
}
|
1054
|
+
/**
|
1055
|
+
* Return a JSON object representing the editor's current document.
|
1056
|
+
*/
|
1057
|
+
getDocJSON = () => {
|
1058
|
+
const state = this.getState();
|
1059
|
+
return jsonFromNode(state.doc);
|
1060
|
+
};
|
1061
|
+
/**
|
1062
|
+
* Return a HTML string representing the editor's current document.
|
1063
|
+
*/
|
1064
|
+
getDocHTML = (options) => {
|
1065
|
+
const serializer = this.getProp("clipboardSerializer");
|
1066
|
+
const DOMSerializer$1 = serializer ? { fromSchema: () => serializer } : void 0;
|
1067
|
+
const doc = this.getDoc();
|
1068
|
+
return htmlFromNode(doc, {
|
1069
|
+
...options,
|
1070
|
+
DOMSerializer: DOMSerializer$1
|
1071
|
+
});
|
1072
|
+
};
|
1045
1073
|
updateExtension(extension, add) {
|
1046
1074
|
const view = this.view;
|
1047
1075
|
if (!view || view.isDestroyed) return;
|
@@ -1142,44 +1170,11 @@ var EditorInstance = class {
|
|
1142
1170
|
* @public
|
1143
1171
|
*/
|
1144
1172
|
var Editor = class {
|
1173
|
+
instance;
|
1145
1174
|
/**
|
1146
1175
|
* @internal
|
1147
1176
|
*/
|
1148
1177
|
constructor(instance) {
|
1149
|
-
this.mount = (place) => {
|
1150
|
-
if (place) this.instance.mount(place);
|
1151
|
-
else this.instance.unmount();
|
1152
|
-
};
|
1153
|
-
this.unmount = () => {
|
1154
|
-
this.instance.unmount();
|
1155
|
-
};
|
1156
|
-
this.focus = () => {
|
1157
|
-
this.instance.view?.focus();
|
1158
|
-
};
|
1159
|
-
this.blur = () => {
|
1160
|
-
this.instance.view?.dom.blur();
|
1161
|
-
};
|
1162
|
-
this.use = (extension) => {
|
1163
|
-
return this.instance.use(extension);
|
1164
|
-
};
|
1165
|
-
this.updateState = (state) => {
|
1166
|
-
this.instance.updateState(state);
|
1167
|
-
};
|
1168
|
-
this.setContent = (content, selection) => {
|
1169
|
-
return this.instance.setContent(content, selection);
|
1170
|
-
};
|
1171
|
-
this.getDocJSON = () => {
|
1172
|
-
return this.instance.getDocJSON();
|
1173
|
-
};
|
1174
|
-
this.getDocHTML = (options) => {
|
1175
|
-
return this.instance.getDocHTML(options);
|
1176
|
-
};
|
1177
|
-
this.exec = (command) => {
|
1178
|
-
return this.instance.exec(command);
|
1179
|
-
};
|
1180
|
-
this.canExec = (command) => {
|
1181
|
-
return this.instance.canExec(command);
|
1182
|
-
};
|
1183
1178
|
if (!(instance instanceof EditorInstance)) throw new TypeError("Invalid EditorInstance");
|
1184
1179
|
this.instance = instance;
|
1185
1180
|
}
|
@@ -1214,6 +1209,93 @@ var Editor = class {
|
|
1214
1209
|
return this.instance.view?.hasFocus() ?? false;
|
1215
1210
|
}
|
1216
1211
|
/**
|
1212
|
+
* Mount the editor to the given HTML element.
|
1213
|
+
* Pass `null` or `undefined` to unmount the editor.
|
1214
|
+
*/
|
1215
|
+
mount = (place) => {
|
1216
|
+
if (place) this.instance.mount(place);
|
1217
|
+
else this.instance.unmount();
|
1218
|
+
};
|
1219
|
+
/**
|
1220
|
+
* Unmount the editor. This is equivalent to `mount(null)`.
|
1221
|
+
*/
|
1222
|
+
unmount = () => {
|
1223
|
+
this.instance.unmount();
|
1224
|
+
};
|
1225
|
+
/**
|
1226
|
+
* Focus the editor.
|
1227
|
+
*/
|
1228
|
+
focus = () => {
|
1229
|
+
this.instance.view?.focus();
|
1230
|
+
};
|
1231
|
+
/**
|
1232
|
+
* Blur the editor.
|
1233
|
+
*/
|
1234
|
+
blur = () => {
|
1235
|
+
this.instance.view?.dom.blur();
|
1236
|
+
};
|
1237
|
+
/**
|
1238
|
+
* Register an extension to the editor. Return a function to unregister the
|
1239
|
+
* extension.
|
1240
|
+
*/
|
1241
|
+
use = (extension) => {
|
1242
|
+
return this.instance.use(extension);
|
1243
|
+
};
|
1244
|
+
/**
|
1245
|
+
* Update the editor's state.
|
1246
|
+
*
|
1247
|
+
* @remarks
|
1248
|
+
*
|
1249
|
+
* This is an advanced method. Use it only if you have a specific reason to
|
1250
|
+
* directly manipulate the editor's state.
|
1251
|
+
*/
|
1252
|
+
updateState = (state) => {
|
1253
|
+
this.instance.updateState(state);
|
1254
|
+
};
|
1255
|
+
/**
|
1256
|
+
* Update the editor's document and selection.
|
1257
|
+
*
|
1258
|
+
* @param content - The new document to set. It can be one of the following:
|
1259
|
+
* - A ProseMirror node instance
|
1260
|
+
* - A ProseMirror node JSON object
|
1261
|
+
* - An HTML string
|
1262
|
+
* - An HTML element instance
|
1263
|
+
* @param selection - Optional. Specifies the new selection. It can be one of the following:
|
1264
|
+
* - A ProseMirror selection instance
|
1265
|
+
* - A ProseMirror selection JSON object
|
1266
|
+
* - The string "start" (to set selection at the beginning, default value)
|
1267
|
+
* - The string "end" (to set selection at the end)
|
1268
|
+
*/
|
1269
|
+
setContent = (content, selection) => {
|
1270
|
+
return this.instance.setContent(content, selection);
|
1271
|
+
};
|
1272
|
+
/**
|
1273
|
+
* Return a JSON object representing the editor's current document.
|
1274
|
+
*/
|
1275
|
+
getDocJSON = () => {
|
1276
|
+
return this.instance.getDocJSON();
|
1277
|
+
};
|
1278
|
+
/**
|
1279
|
+
* Return a HTML string representing the editor's current document.
|
1280
|
+
*/
|
1281
|
+
getDocHTML = (options) => {
|
1282
|
+
return this.instance.getDocHTML(options);
|
1283
|
+
};
|
1284
|
+
/**
|
1285
|
+
* Execute the given command. Return `true` if the command was successfully
|
1286
|
+
* executed, otherwise `false`.
|
1287
|
+
*/
|
1288
|
+
exec = (command) => {
|
1289
|
+
return this.instance.exec(command);
|
1290
|
+
};
|
1291
|
+
/**
|
1292
|
+
* Check if the given command can be executed. Return `true` if the command
|
1293
|
+
* can be executed, otherwise `false`.
|
1294
|
+
*/
|
1295
|
+
canExec = (command) => {
|
1296
|
+
return this.instance.canExec(command);
|
1297
|
+
};
|
1298
|
+
/**
|
1217
1299
|
* All {@link CommandAction}s defined by the editor.
|
1218
1300
|
*/
|
1219
1301
|
get commands() {
|
@@ -1,11 +1,8 @@
|
|
1
|
-
import { Editor
|
1
|
+
import { Editor, EditorInstance, EditorOptions, Extension } from "./editor-CjVyjJqw.js";
|
2
2
|
import { ProseMirrorNode } from "@prosekit/pm/model";
|
3
3
|
|
4
4
|
//#region src/test/test-editor.d.ts
|
5
|
-
|
6
|
-
* An editor for testing purposes.
|
7
|
-
* @public
|
8
|
-
*/
|
5
|
+
|
9
6
|
/**
|
10
7
|
* An editor for testing purposes.
|
11
8
|
* @public
|
@@ -32,6 +29,5 @@ declare class TestEditor<E extends Extension = Extension> extends Editor<E> {
|
|
32
29
|
* @public
|
33
30
|
*/
|
34
31
|
declare function createTestEditor<E extends Extension>(options: EditorOptions<E>): TestEditor<E>;
|
35
|
-
|
36
32
|
//#endregion
|
37
33
|
export { TestEditor, createTestEditor };
|
@@ -1,4 +1,4 @@
|
|
1
|
-
import { Editor, EditorInstance, assert, createMarkActions, createNodeActions, isProseMirrorNode, setupEditorExtension } from "./editor-
|
1
|
+
import { Editor, EditorInstance, assert, createMarkActions, createNodeActions, isProseMirrorNode, setupEditorExtension } from "./editor-DbMrpnmL.js";
|
2
2
|
import { NodeSelection, TextSelection } from "@prosekit/pm/state";
|
3
3
|
|
4
4
|
//#region src/test/test-builder.ts
|
package/dist/prosekit-core.d.ts
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
import { AnyAttrs, AttrSpec, CommandAction, CommandCreator, CommandTyping, DOMDocumentOptions, DOMParserOptions, DOMSerializerOptions, Editor
|
1
|
+
import { AnyAttrs, AttrSpec, CommandAction, CommandCreator, CommandTyping, DOMDocumentOptions, DOMParserOptions, DOMSerializerOptions, Editor, EditorOptions, Extension, ExtensionTyping, ExtractCommandActions, ExtractCommandAppliers, ExtractCommandCreators, ExtractMarkActions, ExtractMarks, ExtractNodeActions, ExtractNodes, JSONParserOptions, MarkAction, MarkBuilder, MarkTyping, NodeAction, NodeBuilder, NodeChild, NodeJSON, NodeTyping, PickSubType, PlainExtension, Priority, SelectionJSON, SimplifyDeeper, SimplifyUnion, StateJSON, StepJSON, ToMarkAction, ToNodeAction, Union, UnionExtension, createEditor, elementFromJSON, elementFromNode, htmlFromJSON, htmlFromNode, jsonFromHTML, jsonFromNode, jsonFromState, nodeFromElement, nodeFromHTML, nodeFromJSON, stateFromJSON } from "./editor-CjVyjJqw.js";
|
2
2
|
import { AllSelection, Command, EditorState, EditorStateConfig, NodeSelection, Plugin, Selection, TextSelection, Transaction } from "@prosekit/pm/state";
|
3
3
|
import { Attrs as Attrs$1, ContentMatch, DOMSerializer, Fragment, Mark as Mark$1, MarkSpec, MarkType as MarkType$1, Node as Node$1, NodeSpec, NodeType as NodeType$1, ProseMirrorFragment, ProseMirrorNode, ResolvedPos, Schema, Slice } from "@prosekit/pm/model";
|
4
4
|
import { DOMEventMap, EditorView, MarkViewConstructor, NodeView, NodeViewConstructor } from "@prosekit/pm/view";
|
@@ -7,9 +7,6 @@ import { DOMEventMap, EditorView, MarkViewConstructor, NodeView, NodeViewConstru
|
|
7
7
|
/**
|
8
8
|
* @public
|
9
9
|
*/
|
10
|
-
/**
|
11
|
-
* @public
|
12
|
-
*/
|
13
10
|
interface AddMarkOptions {
|
14
11
|
/**
|
15
12
|
* The type of the mark to add.
|
@@ -33,7 +30,8 @@ interface AddMarkOptions {
|
|
33
30
|
*
|
34
31
|
* @public
|
35
32
|
*/
|
36
|
-
declare function addMark(options: AddMarkOptions): Command;
|
33
|
+
declare function addMark(options: AddMarkOptions): Command;
|
34
|
+
//#endregion
|
37
35
|
//#region src/commands/expand-mark.d.ts
|
38
36
|
/**
|
39
37
|
* @public
|
@@ -50,7 +48,6 @@ interface ExpandMarkOptions {
|
|
50
48
|
* @public
|
51
49
|
*/
|
52
50
|
declare function expandMark(options: ExpandMarkOptions): Command;
|
53
|
-
|
54
51
|
//#endregion
|
55
52
|
//#region src/commands/insert-default-block.d.ts
|
56
53
|
/**
|
@@ -70,7 +67,6 @@ interface InsertDefaultBlockOptions {
|
|
70
67
|
* @public
|
71
68
|
*/
|
72
69
|
declare function insertDefaultBlock(options?: InsertDefaultBlockOptions): Command;
|
73
|
-
|
74
70
|
//#endregion
|
75
71
|
//#region src/commands/insert-node.d.ts
|
76
72
|
/**
|
@@ -102,7 +98,6 @@ interface InsertNodeOptions {
|
|
102
98
|
* @public
|
103
99
|
*/
|
104
100
|
declare function insertNode(options: InsertNodeOptions): Command;
|
105
|
-
|
106
101
|
//#endregion
|
107
102
|
//#region src/commands/remove-mark.d.ts
|
108
103
|
/**
|
@@ -132,7 +127,6 @@ interface RemoveMarkOptions {
|
|
132
127
|
* @public
|
133
128
|
*/
|
134
129
|
declare function removeMark(options: RemoveMarkOptions): Command;
|
135
|
-
|
136
130
|
//#endregion
|
137
131
|
//#region src/commands/remove-node.d.ts
|
138
132
|
/**
|
@@ -155,7 +149,6 @@ interface RemoveNodeOptions {
|
|
155
149
|
* @public
|
156
150
|
*/
|
157
151
|
declare function removeNode(options: RemoveNodeOptions): Command;
|
158
|
-
|
159
152
|
//#endregion
|
160
153
|
//#region src/commands/set-block-type.d.ts
|
161
154
|
/**
|
@@ -174,7 +167,6 @@ interface SetBlockTypeOptions {
|
|
174
167
|
* @public
|
175
168
|
*/
|
176
169
|
declare function setBlockType(options: SetBlockTypeOptions): Command;
|
177
|
-
|
178
170
|
//#endregion
|
179
171
|
//#region src/commands/set-node-attrs.d.ts
|
180
172
|
/**
|
@@ -203,7 +195,6 @@ interface SetNodeAttrsOptions {
|
|
203
195
|
* @public
|
204
196
|
*/
|
205
197
|
declare function setNodeAttrs(options: SetNodeAttrsOptions): Command;
|
206
|
-
|
207
198
|
//#endregion
|
208
199
|
//#region src/commands/toggle-mark.d.ts
|
209
200
|
/**
|
@@ -248,7 +239,6 @@ declare function toggleMark({
|
|
248
239
|
removeWhenPresent,
|
249
240
|
enterInlineAtoms
|
250
241
|
}: ToggleMarkOptions): Command;
|
251
|
-
|
252
242
|
//#endregion
|
253
243
|
//#region src/commands/toggle-node.d.ts
|
254
244
|
/**
|
@@ -276,7 +266,6 @@ declare function toggleNode({
|
|
276
266
|
type,
|
277
267
|
attrs
|
278
268
|
}: ToggleNodeOptions): Command;
|
279
|
-
|
280
269
|
//#endregion
|
281
270
|
//#region src/commands/toggle-wrap.d.ts
|
282
271
|
interface ToggleWrapOptions {
|
@@ -291,14 +280,13 @@ interface ToggleWrapOptions {
|
|
291
280
|
}
|
292
281
|
/**
|
293
282
|
* Toggle between wrapping an inactive node with the provided node type, and
|
294
|
-
* lifting it up into
|
283
|
+
* lifting it up into its parent.
|
295
284
|
*
|
296
285
|
* @param options
|
297
286
|
*
|
298
287
|
* @public
|
299
288
|
*/
|
300
289
|
declare function toggleWrap(options: ToggleWrapOptions): Command;
|
301
|
-
|
302
290
|
//#endregion
|
303
291
|
//#region src/commands/unset-block-type.d.ts
|
304
292
|
/**
|
@@ -321,7 +309,6 @@ interface UnsetBlockTypeOptions {
|
|
321
309
|
* @public
|
322
310
|
*/
|
323
311
|
declare function unsetBlockType(options?: UnsetBlockTypeOptions): Command;
|
324
|
-
|
325
312
|
//#endregion
|
326
313
|
//#region src/commands/unset-mark.d.ts
|
327
314
|
/**
|
@@ -343,7 +330,6 @@ interface UnsetMarkOptions {
|
|
343
330
|
* @public
|
344
331
|
*/
|
345
332
|
declare function unsetMark(options?: UnsetMarkOptions): Command;
|
346
|
-
|
347
333
|
//#endregion
|
348
334
|
//#region src/commands/wrap.d.ts
|
349
335
|
/**
|
@@ -371,7 +357,6 @@ interface WrapOptions {
|
|
371
357
|
* @public
|
372
358
|
*/
|
373
359
|
declare function wrap(options: WrapOptions): Command;
|
374
|
-
|
375
360
|
//#endregion
|
376
361
|
//#region src/editor/union.d.ts
|
377
362
|
/**
|
@@ -406,7 +391,6 @@ declare function wrap(options: WrapOptions): Command;
|
|
406
391
|
*/
|
407
392
|
declare function union<const E extends readonly Extension[]>(...exts: E): Union<E>;
|
408
393
|
declare function union<const E extends readonly Extension[]>(exts: E): Union<E>;
|
409
|
-
|
410
394
|
//#endregion
|
411
395
|
//#region src/editor/with-priority.d.ts
|
412
396
|
/**
|
@@ -422,7 +406,6 @@ declare function union<const E extends readonly Extension[]>(exts: E): Union<E>;
|
|
422
406
|
* @public
|
423
407
|
*/
|
424
408
|
declare function withPriority<T extends Extension>(extension: T, priority: Priority): T;
|
425
|
-
|
426
409
|
//#endregion
|
427
410
|
//#region src/error.d.ts
|
428
411
|
/**
|
@@ -437,17 +420,15 @@ declare class ProseKitError extends Error {}
|
|
437
420
|
declare class EditorNotFoundError extends ProseKitError {
|
438
421
|
constructor();
|
439
422
|
}
|
440
|
-
|
441
|
-
//#endregion
|
442
|
-
//#region src/types/any-function.d.ts
|
443
423
|
/**
|
444
424
|
* @internal
|
445
425
|
*/
|
426
|
+
//#endregion
|
427
|
+
//#region src/types/any-function.d.ts
|
446
428
|
/**
|
447
429
|
* @internal
|
448
430
|
*/
|
449
431
|
type AnyFunction = (...args: any[]) => any;
|
450
|
-
|
451
432
|
//#endregion
|
452
433
|
//#region src/extensions/clipboard-serializer.d.ts
|
453
434
|
type SerializeFragmentFunction = typeof DOMSerializer.prototype.serializeFragment;
|
@@ -468,7 +449,6 @@ interface ClipboardSerializerOptions {
|
|
468
449
|
* @internal
|
469
450
|
*/
|
470
451
|
declare function defineClipboardSerializer(options: ClipboardSerializerOptions): PlainExtension;
|
471
|
-
|
472
452
|
//#endregion
|
473
453
|
//#region src/commands/insert-text.d.ts
|
474
454
|
/**
|
@@ -479,14 +459,13 @@ type InsertTextOptions = {
|
|
479
459
|
from?: number;
|
480
460
|
to?: number;
|
481
461
|
};
|
482
|
-
|
483
|
-
//#endregion
|
484
|
-
//#region src/extensions/command.d.ts
|
485
462
|
/**
|
486
463
|
* Returns a command that inserts the given text.
|
487
464
|
*
|
488
465
|
* @public
|
489
466
|
*/
|
467
|
+
//#endregion
|
468
|
+
//#region src/extensions/command.d.ts
|
490
469
|
declare function defineCommands<T extends Record<string, CommandCreator> = Record<string, CommandCreator>>(commands: T): Extension<{
|
491
470
|
Commands: { [K in keyof T]: Parameters<T[K]> };
|
492
471
|
}>;
|
@@ -516,7 +495,6 @@ type BaseCommandsExtension = Extension<{
|
|
516
495
|
* @public
|
517
496
|
*/
|
518
497
|
declare function defineBaseCommands(): BaseCommandsExtension;
|
519
|
-
|
520
498
|
//#endregion
|
521
499
|
//#region src/extensions/default-state.d.ts
|
522
500
|
/**
|
@@ -561,7 +539,6 @@ declare function defineDefaultState({
|
|
561
539
|
defaultDoc,
|
562
540
|
defaultHTML
|
563
541
|
}: DefaultStateOptions): PlainExtension;
|
564
|
-
|
565
542
|
//#endregion
|
566
543
|
//#region src/extensions/doc.d.ts
|
567
544
|
/**
|
@@ -582,7 +559,6 @@ type DocExtension = Extension<{
|
|
582
559
|
* ```
|
583
560
|
*/
|
584
561
|
declare function defineDoc(): DocExtension;
|
585
|
-
|
586
562
|
//#endregion
|
587
563
|
//#region src/extensions/events/doc-change.d.ts
|
588
564
|
/**
|
@@ -600,14 +576,12 @@ type DocChangeHandler = (view: EditorView, prevState: EditorState) => void;
|
|
600
576
|
* @public
|
601
577
|
*/
|
602
578
|
declare function defineDocChangeHandler(handler: DocChangeHandler): PlainExtension;
|
603
|
-
|
604
579
|
//#endregion
|
605
580
|
//#region src/facets/facet-types.d.ts
|
606
581
|
/**
|
607
582
|
* @internal
|
608
583
|
*/
|
609
584
|
type FacetReducer<Input, Output> = (input: Input[]) => Output;
|
610
|
-
|
611
585
|
//#endregion
|
612
586
|
//#region src/facets/facet.d.ts
|
613
587
|
/**
|
@@ -664,13 +638,11 @@ declare function defineFacet<Input, Output>(options: {
|
|
664
638
|
*/
|
665
639
|
reduce?: () => FacetReducer<Input, Output>;
|
666
640
|
}): Facet<Input, Output>;
|
667
|
-
|
668
641
|
//#endregion
|
669
642
|
//#region src/facets/state.d.ts
|
670
643
|
type StatePayload = (ctx: {
|
671
644
|
schema: Schema;
|
672
645
|
}) => EditorStateConfig;
|
673
|
-
|
674
646
|
//#endregion
|
675
647
|
//#region src/extensions/plugin.d.ts
|
676
648
|
/**
|
@@ -694,7 +666,6 @@ type PluginPayload = Plugin | Plugin[] | ((context: {
|
|
694
666
|
* @internal
|
695
667
|
*/
|
696
668
|
declare const pluginFacet: Facet<PluginPayload, StatePayload>;
|
697
|
-
|
698
669
|
//#endregion
|
699
670
|
//#region src/extensions/events/dom-event.d.ts
|
700
671
|
/**
|
@@ -716,12 +687,11 @@ type DOMEventHandler<Event extends keyof DOMEventMap = string> = (view: EditorVi
|
|
716
687
|
* @public
|
717
688
|
*/
|
718
689
|
declare function defineDOMEventHandler<Event extends keyof DOMEventMap = string>(event: Event, handler: DOMEventHandler<Event>): PlainExtension;
|
719
|
-
|
720
|
-
//#endregion
|
721
|
-
//#region src/types/object-entries.d.ts
|
722
690
|
/**
|
723
691
|
* @internal
|
724
692
|
*/
|
693
|
+
//#endregion
|
694
|
+
//#region src/types/object-entries.d.ts
|
725
695
|
/**
|
726
696
|
* @internal
|
727
697
|
*
|
@@ -733,7 +703,6 @@ declare function defineDOMEventHandler<Event extends keyof DOMEventMap = string>
|
|
733
703
|
* // ^ ["a", 1] | ["b", "B"]
|
734
704
|
*/
|
735
705
|
type ObjectEntries<T extends Record<string, any>> = { [K in keyof T]: [K, T[K]] }[keyof T];
|
736
|
-
|
737
706
|
//#endregion
|
738
707
|
//#region src/extensions/events/editor-event.d.ts
|
739
708
|
type KeyDownHandler = (view: EditorView, event: KeyboardEvent) => boolean | void;
|
@@ -842,7 +811,6 @@ type EditorEventPayload = ObjectEntries<EditorEventMap>;
|
|
842
811
|
* @internal
|
843
812
|
*/
|
844
813
|
declare const editorEventFacet: Facet<EditorEventPayload, PluginPayload>;
|
845
|
-
|
846
814
|
//#endregion
|
847
815
|
//#region src/extensions/events/focus.d.ts
|
848
816
|
/**
|
@@ -859,7 +827,6 @@ type FocusChangeHandler = (hasFocus: boolean) => void;
|
|
859
827
|
* @public
|
860
828
|
*/
|
861
829
|
declare function defineFocusChangeHandler(handler: FocusChangeHandler): PlainExtension;
|
862
|
-
|
863
830
|
//#endregion
|
864
831
|
//#region src/extensions/events/plugin-view.d.ts
|
865
832
|
/**
|
@@ -903,7 +870,6 @@ declare function defineUpdateHandler(handler: UpdateHandler): PlainExtension;
|
|
903
870
|
* @public
|
904
871
|
*/
|
905
872
|
declare function defineUnmountHandler(handler: UnmountHandler): PlainExtension;
|
906
|
-
|
907
873
|
//#endregion
|
908
874
|
//#region src/extensions/history.d.ts
|
909
875
|
/**
|
@@ -947,7 +913,6 @@ declare function defineHistory({
|
|
947
913
|
depth,
|
948
914
|
newGroupDelay
|
949
915
|
}?: HistoryOptions): HistoryExtension;
|
950
|
-
|
951
916
|
//#endregion
|
952
917
|
//#region src/extensions/keymap.d.ts
|
953
918
|
/**
|
@@ -968,7 +933,6 @@ type KeymapPayload = Keymap;
|
|
968
933
|
* @internal
|
969
934
|
*/
|
970
935
|
declare const keymapFacet: Facet<KeymapPayload, PluginPayload>;
|
971
|
-
|
972
936
|
//#endregion
|
973
937
|
//#region src/extensions/keymap-base.d.ts
|
974
938
|
/**
|
@@ -988,7 +952,6 @@ declare function defineBaseKeymap(options?: {
|
|
988
952
|
*/
|
989
953
|
priority?: Priority;
|
990
954
|
}): BaseKeymapExtension;
|
991
|
-
|
992
955
|
//#endregion
|
993
956
|
//#region src/extensions/mark-spec.d.ts
|
994
957
|
/**
|
@@ -1042,7 +1005,6 @@ declare function defineMarkSpec<Mark extends string, Attrs extends AnyAttrs = An
|
|
1042
1005
|
declare function defineMarkAttr<MarkType extends string = string, AttrName extends string = string, AttrType = any>(options: MarkAttrOptions<MarkType, AttrName, AttrType>): Extension<{
|
1043
1006
|
Marks: { [K in MarkType]: AttrType };
|
1044
1007
|
}>;
|
1045
|
-
|
1046
1008
|
//#endregion
|
1047
1009
|
//#region src/extensions/mark-view.d.ts
|
1048
1010
|
interface MarkViewOptions {
|
@@ -1050,7 +1012,6 @@ interface MarkViewOptions {
|
|
1050
1012
|
constructor: MarkViewConstructor;
|
1051
1013
|
}
|
1052
1014
|
declare function defineMarkView(options: MarkViewOptions): Extension;
|
1053
|
-
|
1054
1015
|
//#endregion
|
1055
1016
|
//#region src/extensions/mark-view-effect.d.ts
|
1056
1017
|
/**
|
@@ -1076,7 +1037,6 @@ declare function defineMarkViewFactory<T>(options: MarkViewFactoryOptions<T>): E
|
|
1076
1037
|
* @internal
|
1077
1038
|
*/
|
1078
1039
|
declare function defineMarkViewComponent<T>(options: MarkViewComponentOptions<T>): Extension;
|
1079
|
-
|
1080
1040
|
//#endregion
|
1081
1041
|
//#region src/extensions/node-spec.d.ts
|
1082
1042
|
/**
|
@@ -1147,7 +1107,6 @@ declare function defineNodeSpec<Node extends string, Attrs extends AnyAttrs = An
|
|
1147
1107
|
declare function defineNodeAttr<NodeType extends string = string, AttrName extends string = string, AttrType = any>(options: NodeAttrOptions<NodeType, AttrName, AttrType>): Extension<{
|
1148
1108
|
Nodes: { [K in NodeType]: { [K in AttrName]: AttrType } };
|
1149
1109
|
}>;
|
1150
|
-
|
1151
1110
|
//#endregion
|
1152
1111
|
//#region src/extensions/node-view.d.ts
|
1153
1112
|
interface NodeViewOptions {
|
@@ -1155,7 +1114,6 @@ interface NodeViewOptions {
|
|
1155
1114
|
constructor: NodeViewConstructor;
|
1156
1115
|
}
|
1157
1116
|
declare function defineNodeView(options: NodeViewOptions): Extension;
|
1158
|
-
|
1159
1117
|
//#endregion
|
1160
1118
|
//#region src/extensions/node-view-effect.d.ts
|
1161
1119
|
/**
|
@@ -1181,7 +1139,6 @@ declare function defineNodeViewFactory<T>(options: NodeViewFactoryOptions<T>): E
|
|
1181
1139
|
* @internal
|
1182
1140
|
*/
|
1183
1141
|
declare function defineNodeViewComponent<T>(options: NodeViewComponentOptions<T>): Extension;
|
1184
|
-
|
1185
1142
|
//#endregion
|
1186
1143
|
//#region src/extensions/paragraph.d.ts
|
1187
1144
|
/**
|
@@ -1214,7 +1171,6 @@ type ParagraphExtension = ParagraphSpecExtension;
|
|
1214
1171
|
* ```
|
1215
1172
|
*/
|
1216
1173
|
declare function defineParagraph(): ParagraphExtension;
|
1217
|
-
|
1218
1174
|
//#endregion
|
1219
1175
|
//#region src/extensions/text.d.ts
|
1220
1176
|
/**
|
@@ -1235,16 +1191,15 @@ type TextExtension = Extension<{
|
|
1235
1191
|
* ```
|
1236
1192
|
*/
|
1237
1193
|
declare function defineText(): TextExtension;
|
1238
|
-
|
1239
1194
|
//#endregion
|
1240
1195
|
//#region src/facets/facet-extension.d.ts
|
1241
1196
|
/**
|
1242
1197
|
* @internal
|
1243
1198
|
*/
|
1244
1199
|
declare function defineFacetPayload<Input>(facet: Facet<Input, any>, payloads: Input[]): Extension;
|
1245
|
-
|
1246
1200
|
//#endregion
|
1247
1201
|
//#region src/types/base-node-view-options.d.ts
|
1202
|
+
// This should be synced with the type `CoreNodeViewUserOptions` from `@prosemirror-adapter/core`
|
1248
1203
|
/**
|
1249
1204
|
* Some basic props for custom node views.
|
1250
1205
|
*
|
@@ -1270,18 +1225,15 @@ interface BaseNodeViewOptions {
|
|
1270
1225
|
destroy?: NodeView["destroy"];
|
1271
1226
|
onUpdate?: () => void;
|
1272
1227
|
}
|
1273
|
-
|
1274
1228
|
//#endregion
|
1275
1229
|
//#region src/utils/assert.d.ts
|
1276
1230
|
/**
|
1277
1231
|
* @internal
|
1278
1232
|
*/
|
1279
1233
|
declare function assert(condition: unknown, message?: string): asserts condition;
|
1280
|
-
|
1281
1234
|
//#endregion
|
1282
1235
|
//#region src/utils/can-use-regex-lookbehind.d.ts
|
1283
1236
|
declare const canUseRegexLookbehind: () => boolean;
|
1284
|
-
|
1285
1237
|
//#endregion
|
1286
1238
|
//#region src/utils/clsx.d.ts
|
1287
1239
|
/**
|
@@ -1292,7 +1244,6 @@ declare const canUseRegexLookbehind: () => boolean;
|
|
1292
1244
|
* @public
|
1293
1245
|
*/
|
1294
1246
|
declare const clsx: (...args: Array<string | boolean | null | undefined>) => string;
|
1295
|
-
|
1296
1247
|
//#endregion
|
1297
1248
|
//#region src/utils/collect-children.d.ts
|
1298
1249
|
/**
|
@@ -1301,7 +1252,6 @@ declare const clsx: (...args: Array<string | boolean | null | undefined>) => str
|
|
1301
1252
|
* @public
|
1302
1253
|
*/
|
1303
1254
|
declare function collectChildren(parent: ProseMirrorNode | Fragment): ProseMirrorNode[];
|
1304
|
-
|
1305
1255
|
//#endregion
|
1306
1256
|
//#region src/utils/collect-nodes.d.ts
|
1307
1257
|
/**
|
@@ -1318,28 +1268,24 @@ type NodeContent = ProseMirrorNode | ProseMirrorFragment | NodeContent[];
|
|
1318
1268
|
* @public
|
1319
1269
|
*/
|
1320
1270
|
declare function collectNodes(content: NodeContent): ProseMirrorNode[];
|
1321
|
-
|
1322
1271
|
//#endregion
|
1323
1272
|
//#region src/utils/contains-inline-node.d.ts
|
1324
1273
|
/**
|
1325
1274
|
* @internal
|
1326
1275
|
*/
|
1327
1276
|
declare function containsInlineNode(doc: ProseMirrorNode, from: number, to: number): boolean;
|
1328
|
-
|
1329
1277
|
//#endregion
|
1330
1278
|
//#region src/utils/default-block-at.d.ts
|
1331
1279
|
/**
|
1332
1280
|
* @internal
|
1333
1281
|
*/
|
1334
1282
|
declare function defaultBlockAt(match: ContentMatch): NodeType$1 | null;
|
1335
|
-
|
1336
1283
|
//#endregion
|
1337
1284
|
//#region src/utils/env.d.ts
|
1338
1285
|
/**
|
1339
1286
|
* @private
|
1340
1287
|
*/
|
1341
1288
|
declare const isApple: boolean;
|
1342
|
-
|
1343
1289
|
//#endregion
|
1344
1290
|
//#region src/utils/find-parent-node.d.ts
|
1345
1291
|
/**
|
@@ -1369,7 +1315,6 @@ interface FindParentNodeResult {
|
|
1369
1315
|
* @public
|
1370
1316
|
*/
|
1371
1317
|
declare function findParentNode(predicate: (node: ProseMirrorNode) => boolean, $pos: ResolvedPos): FindParentNodeResult | undefined;
|
1372
|
-
|
1373
1318
|
//#endregion
|
1374
1319
|
//#region src/utils/find-parent-node-of-type.d.ts
|
1375
1320
|
/**
|
@@ -1378,7 +1323,6 @@ declare function findParentNode(predicate: (node: ProseMirrorNode) => boolean, $
|
|
1378
1323
|
* @public
|
1379
1324
|
*/
|
1380
1325
|
declare function findParentNodeOfType(type: NodeType$1 | string, $pos: ResolvedPos): FindParentNodeResult | undefined;
|
1381
|
-
|
1382
1326
|
//#endregion
|
1383
1327
|
//#region src/utils/get-id.d.ts
|
1384
1328
|
/**
|
@@ -1387,21 +1331,18 @@ declare function findParentNodeOfType(type: NodeType$1 | string, $pos: ResolvedP
|
|
1387
1331
|
* @internal
|
1388
1332
|
*/
|
1389
1333
|
declare function getId(): string;
|
1390
|
-
|
1391
1334
|
//#endregion
|
1392
1335
|
//#region src/utils/get-mark-type.d.ts
|
1393
1336
|
/**
|
1394
1337
|
* @internal
|
1395
1338
|
*/
|
1396
1339
|
declare function getMarkType(schema: Schema, type: string | MarkType$1): MarkType$1;
|
1397
|
-
|
1398
1340
|
//#endregion
|
1399
1341
|
//#region src/utils/get-node-type.d.ts
|
1400
1342
|
/**
|
1401
1343
|
* @internal
|
1402
1344
|
*/
|
1403
1345
|
declare function getNodeType(schema: Schema, type: string | NodeType$1): NodeType$1;
|
1404
|
-
|
1405
1346
|
//#endregion
|
1406
1347
|
//#region src/utils/is-at-block-start.d.ts
|
1407
1348
|
/**
|
@@ -1410,7 +1351,6 @@ declare function getNodeType(schema: Schema, type: string | NodeType$1): NodeTyp
|
|
1410
1351
|
* @internal
|
1411
1352
|
*/
|
1412
1353
|
declare function isAtBlockStart(state: EditorState, view?: EditorView): ResolvedPos | null;
|
1413
|
-
|
1414
1354
|
//#endregion
|
1415
1355
|
//#region src/utils/is-in-code-block.d.ts
|
1416
1356
|
/**
|
@@ -1419,7 +1359,6 @@ declare function isAtBlockStart(state: EditorState, view?: EditorView): Resolved
|
|
1419
1359
|
* @internal
|
1420
1360
|
*/
|
1421
1361
|
declare function isInCodeBlock(selection: Selection): boolean;
|
1422
|
-
|
1423
1362
|
//#endregion
|
1424
1363
|
//#region src/utils/is-mark-absent.d.ts
|
1425
1364
|
/**
|
@@ -1430,25 +1369,21 @@ declare function isInCodeBlock(selection: Selection): boolean;
|
|
1430
1369
|
* @internal
|
1431
1370
|
*/
|
1432
1371
|
declare function isMarkAbsent(node: ProseMirrorNode, from: number, to: number, markType: MarkType$1, attrs?: Attrs$1 | null): boolean;
|
1433
|
-
|
1434
1372
|
//#endregion
|
1435
1373
|
//#region src/utils/is-mark-active.d.ts
|
1436
1374
|
/**
|
1437
1375
|
* @internal
|
1438
1376
|
*/
|
1439
1377
|
declare function isMarkActive(state: EditorState, type: string | MarkType$1, attrs?: Attrs$1 | null): boolean;
|
1440
|
-
|
1441
1378
|
//#endregion
|
1442
1379
|
//#region src/utils/maybe-run.d.ts
|
1443
1380
|
/**
|
1444
1381
|
* @internal
|
1445
1382
|
*/
|
1446
|
-
declare function maybeRun<
|
1447
|
-
|
1383
|
+
declare function maybeRun<Value, Args extends unknown[]>(value: Value | ((...args: Args) => Value), ...args: Args): Value;
|
1448
1384
|
//#endregion
|
1449
1385
|
//#region src/utils/set-selection-around.d.ts
|
1450
1386
|
declare function setSelectionAround(tr: Transaction, pos: number): void;
|
1451
|
-
|
1452
1387
|
//#endregion
|
1453
1388
|
//#region src/utils/type-assertion.d.ts
|
1454
1389
|
/**
|
@@ -1497,23 +1432,20 @@ declare function isNodeSelection(sel: Selection): sel is NodeSelection;
|
|
1497
1432
|
* @public
|
1498
1433
|
*/
|
1499
1434
|
declare function isAllSelection(sel: Selection): sel is AllSelection;
|
1500
|
-
|
1501
|
-
//#endregion
|
1502
|
-
//#region src/utils/unicode.d.ts
|
1503
1435
|
/**
|
1504
1436
|
* @internal
|
1505
1437
|
*/
|
1438
|
+
//#endregion
|
1439
|
+
//#region src/utils/unicode.d.ts
|
1506
1440
|
/**
|
1507
1441
|
* @internal
|
1508
1442
|
*/
|
1509
1443
|
declare const OBJECT_REPLACEMENT_CHARACTER = "";
|
1510
|
-
|
1511
1444
|
//#endregion
|
1512
1445
|
//#region src/utils/with-skip-code-block.d.ts
|
1513
1446
|
/**
|
1514
1447
|
* @internal
|
1515
1448
|
*/
|
1516
1449
|
declare function withSkipCodeBlock(command: Command): Command;
|
1517
|
-
|
1518
1450
|
//#endregion
|
1519
1451
|
export { AddMarkOptions, AnyAttrs, AnyFunction, AttrSpec, BaseCommandsExtension, BaseKeymapExtension, BaseNodeViewOptions, ClickHandler, ClickOnHandler, ClipboardSerializerOptions, CommandAction, CommandTyping, DOMDocumentOptions, DOMEventHandler, DOMParserOptions, DOMSerializerOptions, DefaultStateOptions, DocChangeHandler, DocExtension, DoubleClickHandler, DoubleClickOnHandler, DropHandler, Editor, EditorEventPayload, EditorNotFoundError, EditorOptions, ExpandMarkOptions, Extension, ExtensionTyping, ExtractCommandActions, ExtractCommandAppliers, ExtractCommandCreators, ExtractMarkActions, ExtractMarks, ExtractNodeActions, ExtractNodes, Facet, FindParentNodeResult, FocusChangeHandler, HistoryExtension, HistoryOptions, InsertDefaultBlockOptions, InsertNodeOptions, JSONParserOptions, KeyDownHandler, KeyPressHandler, Keymap, KeymapPayload, MarkAction, MarkAttrOptions, MarkBuilder, MarkSpecOptions, MarkTyping, MarkViewComponentOptions, MarkViewFactoryOptions, MarkViewOptions, MountHandler, NodeAction, NodeAttrOptions, NodeBuilder, NodeChild, NodeContent, NodeJSON, NodeSpecOptions, NodeTyping, NodeViewComponentOptions, NodeViewFactoryOptions, NodeViewOptions, OBJECT_REPLACEMENT_CHARACTER, ParagraphExtension, PasteHandler, PickSubType, PlainExtension, PluginPayload, Priority, ProseKitError, RemoveMarkOptions, RemoveNodeOptions, ScrollToSelectionHandler, SelectionJSON, SetBlockTypeOptions, SetNodeAttrsOptions, SimplifyDeeper, SimplifyUnion, StateJSON, StepJSON, TextExtension, TextInputHandler, ToMarkAction, ToNodeAction, ToggleMarkOptions, ToggleNodeOptions, ToggleWrapOptions, TripleClickHandler, TripleClickOnHandler, Union, UnionExtension, UnmountHandler, UnsetBlockTypeOptions, UnsetMarkOptions, UpdateHandler, WrapOptions, getId as _getId, addMark, assert, canUseRegexLookbehind, clsx, collectChildren, collectNodes, containsInlineNode, createEditor, defaultBlockAt, defineBaseCommands, defineBaseKeymap, defineClickHandler, defineClickOnHandler, defineClipboardSerializer, defineCommands, defineDOMEventHandler, defineDefaultState, defineDoc, defineDocChangeHandler, defineDoubleClickHandler, defineDoubleClickOnHandler, defineDropHandler, defineFacet, defineFacetPayload, defineFocusChangeHandler, defineHistory, defineKeyDownHandler, defineKeyPressHandler, defineKeymap, defineMarkAttr, defineMarkSpec, defineMarkView, defineMarkViewComponent, defineMarkViewFactory, defineMountHandler, defineNodeAttr, defineNodeSpec, defineNodeView, defineNodeViewComponent, defineNodeViewFactory, defineParagraph, definePasteHandler, definePlugin, defineScrollToSelectionHandler, defineText, defineTextInputHandler, defineTripleClickHandler, defineTripleClickOnHandler, defineUnmountHandler, defineUpdateHandler, editorEventFacet, elementFromJSON, elementFromNode, expandMark, findParentNode, findParentNodeOfType, getMarkType, getNodeType, htmlFromJSON, htmlFromNode, insertDefaultBlock, insertNode, isAllSelection, isApple, isAtBlockStart, isFragment, isInCodeBlock, isMark, isMarkAbsent, isMarkActive, isNodeSelection, isProseMirrorNode, isSelection, isSlice, isTextSelection, jsonFromHTML, jsonFromNode, jsonFromState, keymapFacet, maybeRun, nodeFromElement, nodeFromHTML, nodeFromJSON, pluginFacet, removeMark, removeNode, setBlockType, setNodeAttrs, setSelectionAround, stateFromJSON, toggleMark, toggleNode, toggleWrap, union, unsetBlockType, unsetMark, withPriority, withSkipCodeBlock, wrap };
|
package/dist/prosekit-core.js
CHANGED
@@ -1,9 +1,9 @@
|
|
1
|
-
import { Editor, EditorNotFoundError, Priority, ProseKitError, assert, createEditor, defineDefaultState, defineFacet, defineFacetPayload, elementFromJSON, elementFromNode, getMarkType, getNodeType, htmlFromJSON, htmlFromNode, isAllSelection, isFragment, isMark, isMarkAbsent, isMarkActive, isNodeActive, isNodeSelection, isNotNullish, isProseMirrorNode, isSelection, isSlice, isTextSelection, jsonFromHTML, jsonFromNode, jsonFromState, nodeFromElement, nodeFromHTML, nodeFromJSON, rootFacet, schemaFacet, stateFacet, stateFromJSON, toReversed, union } from "./editor-
|
1
|
+
import { Editor, EditorNotFoundError, Priority, ProseKitError, assert, createEditor, defineDefaultState, defineFacet, defineFacetPayload, elementFromJSON, elementFromNode, getMarkType, getNodeType, htmlFromJSON, htmlFromNode, isAllSelection, isFragment, isMark, isMarkAbsent, isMarkActive, isNodeActive, isNodeSelection, isNotNullish, isProseMirrorNode, isSelection, isSlice, isTextSelection, jsonFromHTML, jsonFromNode, jsonFromState, nodeFromElement, nodeFromHTML, nodeFromJSON, rootFacet, schemaFacet, stateFacet, stateFromJSON, toReversed, union } from "./editor-DbMrpnmL.js";
|
2
2
|
import { AllSelection, Plugin, PluginKey, ProseMirrorPlugin, TextSelection } from "@prosekit/pm/state";
|
3
3
|
import { ReplaceAroundStep, findWrapping, insertPoint } from "@prosekit/pm/transform";
|
4
4
|
import { baseKeymap, chainCommands, createParagraphNear, deleteSelection, joinTextblockBackward, lift, liftEmptyBlock, newlineInCode, selectNodeBackward, setBlockType as setBlockType$1, toggleMark as toggleMark$1 } from "@prosekit/pm/commands";
|
5
5
|
import { DOMSerializer, Fragment, ProseMirrorFragment, ProseMirrorNode, Slice } from "@prosekit/pm/model";
|
6
|
-
import { isElementLike } from "@ocavue/utils";
|
6
|
+
import { isElementLike, once } from "@ocavue/utils";
|
7
7
|
import OrderedMap from "orderedmap";
|
8
8
|
import mapValues from "just-map-values";
|
9
9
|
import clone from "just-clone";
|
@@ -375,7 +375,7 @@ function wrap(options) {
|
|
375
375
|
//#region src/commands/toggle-wrap.ts
|
376
376
|
/**
|
377
377
|
* Toggle between wrapping an inactive node with the provided node type, and
|
378
|
-
* lifting it up into
|
378
|
+
* lifting it up into its parent.
|
379
379
|
*
|
380
380
|
* @param options
|
381
381
|
*
|
@@ -1208,10 +1208,7 @@ const keymapFacet = defineFacet({
|
|
1208
1208
|
props: { handleKeyDown: handlerWrapper }
|
1209
1209
|
});
|
1210
1210
|
return (keymaps) => {
|
1211
|
-
handler = keydownHandler(mergeKeymaps(
|
1212
|
-
// The keymap at the end have a higher priority.
|
1213
|
-
toReversed(keymaps)
|
1214
|
-
));
|
1211
|
+
handler = keydownHandler(mergeKeymaps(toReversed(keymaps)));
|
1215
1212
|
return plugin;
|
1216
1213
|
};
|
1217
1214
|
},
|
@@ -1486,19 +1483,9 @@ function defineText() {
|
|
1486
1483
|
});
|
1487
1484
|
}
|
1488
1485
|
|
1489
|
-
//#endregion
|
1490
|
-
//#region src/utils/cache.ts
|
1491
|
-
function cache(fn) {
|
1492
|
-
let result = void 0;
|
1493
|
-
return () => {
|
1494
|
-
if (result === void 0) result = fn();
|
1495
|
-
return result;
|
1496
|
-
};
|
1497
|
-
}
|
1498
|
-
|
1499
1486
|
//#endregion
|
1500
1487
|
//#region src/utils/can-use-regex-lookbehind.ts
|
1501
|
-
const canUseRegexLookbehind =
|
1488
|
+
const canUseRegexLookbehind = once(() => {
|
1502
1489
|
try {
|
1503
1490
|
return "ab".replace(new RegExp("(?<=a)b", "g"), "c") === "ac";
|
1504
1491
|
} catch {
|
package/package.json
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
{
|
2
2
|
"name": "@prosekit/core",
|
3
3
|
"type": "module",
|
4
|
-
"version": "0.8.
|
4
|
+
"version": "0.8.2",
|
5
5
|
"private": false,
|
6
6
|
"description": "Core features for ProseKit",
|
7
7
|
"author": {
|
@@ -39,20 +39,20 @@
|
|
39
39
|
"dist"
|
40
40
|
],
|
41
41
|
"dependencies": {
|
42
|
-
"@ocavue/utils": "^0.
|
42
|
+
"@ocavue/utils": "^0.5.0",
|
43
43
|
"clsx": "^2.1.1",
|
44
44
|
"just-clone": "^6.2.0",
|
45
45
|
"just-map-values": "^3.2.0",
|
46
46
|
"orderedmap": "^2.1.1",
|
47
47
|
"prosemirror-splittable": "^0.1.1",
|
48
48
|
"type-fest": "^4.41.0",
|
49
|
-
"@prosekit/pm": "^0.1.
|
49
|
+
"@prosekit/pm": "^0.1.11"
|
50
50
|
},
|
51
51
|
"devDependencies": {
|
52
|
-
"@vitest/browser": "^3.
|
53
|
-
"tsdown": "^0.
|
52
|
+
"@vitest/browser": "^3.2.3",
|
53
|
+
"tsdown": "^0.12.7",
|
54
54
|
"typescript": "~5.8.3",
|
55
|
-
"vitest": "^3.
|
55
|
+
"vitest": "^3.2.3",
|
56
56
|
"@prosekit/config-tsdown": "0.0.0",
|
57
57
|
"@prosekit/config-vitest": "0.0.0"
|
58
58
|
},
|