@prosekit/core 0.0.0-next-20230709090937 → 0.0.0-next-20231120040948
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 +1022 -0
- package/dist/prosekit-core.d.ts +66 -283
- package/dist/prosekit-core.js +1137 -392
- package/dist/style.css +4 -1
- package/package.json +6 -6
- package/src/index.ts +56 -15
@@ -0,0 +1,1022 @@
|
|
1
|
+
import { AllSelection } from '@prosekit/pm/state';
|
2
|
+
import { Attrs } from '@prosekit/pm/model';
|
3
|
+
import { Attrs as Attrs_2 } from 'prosemirror-model';
|
4
|
+
import { Command } from '@prosekit/pm/state';
|
5
|
+
import type { ConditionalExcept } from 'type-fest';
|
6
|
+
import type { DirectEditorProps } from '@prosekit/pm/view';
|
7
|
+
import { EditorState } from '@prosekit/pm/state';
|
8
|
+
import type { EditorStateConfig } from '@prosekit/pm/state';
|
9
|
+
import { EditorView } from '@prosekit/pm/view';
|
10
|
+
import type { EmptyObject } from 'type-fest';
|
11
|
+
import { InputRule } from '@prosekit/pm/inputrules';
|
12
|
+
import type { IsEqual } from 'type-fest';
|
13
|
+
import { Mark } from '@prosekit/pm/model';
|
14
|
+
import type { MarkSpec } from '@prosekit/pm/model';
|
15
|
+
import { MarkType } from '@prosekit/pm/model';
|
16
|
+
import { MarkType as MarkType_2 } from 'prosemirror-model';
|
17
|
+
import { Node as Node_2 } from 'prosemirror-model';
|
18
|
+
import { NodeSelection } from '@prosekit/pm/state';
|
19
|
+
import type { NodeSpec } from '@prosekit/pm/model';
|
20
|
+
import { NodeType } from '@prosekit/pm/model';
|
21
|
+
import { NodeType as NodeType_2 } from 'prosemirror-model';
|
22
|
+
import { NodeViewConstructor } from '@prosekit/pm/view';
|
23
|
+
import { Options } from 'tsup';
|
24
|
+
import { Plugin as Plugin_2 } from '@prosekit/pm/state';
|
25
|
+
import { ProseMirrorFragment } from '@prosekit/pm/model';
|
26
|
+
import { ProseMirrorNode } from '@prosekit/pm/model';
|
27
|
+
import { Schema } from '@prosekit/pm/model';
|
28
|
+
import type { SchemaSpec } from '@prosekit/pm/model';
|
29
|
+
import { Selection as Selection_2 } from '@prosekit/pm/state';
|
30
|
+
import { Selection as Selection_3 } from 'prosemirror-state';
|
31
|
+
import type { Simplify } from 'type-fest';
|
32
|
+
import { TextSelection } from '@prosekit/pm/state';
|
33
|
+
import { Transaction } from '@prosekit/pm/state';
|
34
|
+
import type { UnionToIntersection } from 'type-fest';
|
35
|
+
import { UserProjectConfigExport } from 'vitest/dist/config.js';
|
36
|
+
|
37
|
+
declare type Action = (options: {
|
38
|
+
tr: Transaction;
|
39
|
+
view?: EditorView;
|
40
|
+
}) => boolean;
|
41
|
+
|
42
|
+
/**
|
43
|
+
* Add the given mark to the inline content.
|
44
|
+
*/
|
45
|
+
declare function addMark(options: {
|
46
|
+
/**
|
47
|
+
* The type of the mark to add.
|
48
|
+
*/
|
49
|
+
type: string | MarkType;
|
50
|
+
/**
|
51
|
+
* The attributes of the mark to add.
|
52
|
+
*/
|
53
|
+
attrs?: Attrs | null;
|
54
|
+
/**
|
55
|
+
* The start position of the document. By default it will be the start position of current selection.
|
56
|
+
*/
|
57
|
+
from?: number;
|
58
|
+
/**
|
59
|
+
* The end position of the document. By default it will be the end position of current selection.
|
60
|
+
*/
|
61
|
+
to?: number;
|
62
|
+
}): Command;
|
63
|
+
export { addMark }
|
64
|
+
export { addMark as addMark_alias_1 }
|
65
|
+
|
66
|
+
export declare function applyAction(operator: Action): Command;
|
67
|
+
|
68
|
+
/**
|
69
|
+
* Utility function assert that two types are equal in tests.
|
70
|
+
*/
|
71
|
+
export declare function assertTypeEqual<T, U>(_val: IsEqual<T, U>): void;
|
72
|
+
|
73
|
+
export declare function attrsMatch(nodeOrMark: ProseMirrorNode | Mark, attrs: Attrs): boolean;
|
74
|
+
|
75
|
+
export declare abstract class BaseExtension<T extends ExtensionTyping = ExtensionTyping> implements Extension<T> {
|
76
|
+
extension: Extension | Extension[];
|
77
|
+
priority?: Priority;
|
78
|
+
_type?: T;
|
79
|
+
/**
|
80
|
+
* @internal
|
81
|
+
*
|
82
|
+
* Whether this extension has payload that can be converted to a schema.
|
83
|
+
*
|
84
|
+
* Notice that this does not mean that the extension has a schema. For
|
85
|
+
* example, a `FacetExtension` with a `schemaFacet` will return `true` for
|
86
|
+
* this property, but will return `null` for `schema`.
|
87
|
+
*/
|
88
|
+
abstract hasSchema: boolean;
|
89
|
+
/**
|
90
|
+
* @internal
|
91
|
+
*
|
92
|
+
* The schema that this extension represents.
|
93
|
+
*/
|
94
|
+
abstract schema: Schema | null;
|
95
|
+
}
|
96
|
+
|
97
|
+
export declare function collectNodes(content: NodeContent): ProseMirrorNode[];
|
98
|
+
|
99
|
+
export declare interface CommandApplier<Args extends any[] = any[]> {
|
100
|
+
(...args: Args): boolean;
|
101
|
+
canApply(...args: Args): boolean;
|
102
|
+
}
|
103
|
+
|
104
|
+
/**
|
105
|
+
* @internal
|
106
|
+
*/
|
107
|
+
declare interface CommandArgs {
|
108
|
+
[name: string]: any[];
|
109
|
+
}
|
110
|
+
export { CommandArgs }
|
111
|
+
export { CommandArgs as CommandArgs_alias_1 }
|
112
|
+
|
113
|
+
export declare type CommandCreator<Args extends any[] = any[]> = (...arg: Args) => Command;
|
114
|
+
|
115
|
+
export declare interface CommandCreators {
|
116
|
+
[name: string]: CommandCreator;
|
117
|
+
}
|
118
|
+
|
119
|
+
export declare const commandFacet: Facet<CommandCreators, CommandCreators>;
|
120
|
+
|
121
|
+
export declare type CommandPayload = CommandCreators;
|
122
|
+
|
123
|
+
export declare type Converters = ConverterTuple[];
|
124
|
+
|
125
|
+
declare type ConverterTuple = Tuple5<FacetConverter | undefined>;
|
126
|
+
|
127
|
+
/**
|
128
|
+
* @public
|
129
|
+
*/
|
130
|
+
declare function createEditor<E extends Extension>({ extension, defaultDoc, defaultHTML, defaultSelection, }: EditorOptions<E>): Editor<E>;
|
131
|
+
export { createEditor }
|
132
|
+
export { createEditor as createEditor_alias_1 }
|
133
|
+
|
134
|
+
export declare function createMarkBuilder(getState: () => EditorState | null | undefined, type: MarkType): MarkBuilder;
|
135
|
+
|
136
|
+
export declare function createNodeBuilder(getState: () => EditorState | null | undefined, type: NodeType): NodeBuilder;
|
137
|
+
|
138
|
+
export declare const default_alias: Options | Options[] | ((overrideOptions: Options) => Options | Options[] | Promise<Options | Options[]>);
|
139
|
+
|
140
|
+
export declare const default_alias_1: UserProjectConfigExport;
|
141
|
+
|
142
|
+
declare interface DefaultStateOptions {
|
143
|
+
/**
|
144
|
+
* A JSON object representing the starting document to use when creating the
|
145
|
+
* editor.
|
146
|
+
*/
|
147
|
+
defaultDoc?: NodeJSON;
|
148
|
+
/**
|
149
|
+
* A HTML element or a HTML string representing the starting document to use
|
150
|
+
* when creating the editor.
|
151
|
+
*/
|
152
|
+
defaultHTML?: string | HTMLElement;
|
153
|
+
/**
|
154
|
+
* A JSON object representing the starting selection to use when creating the
|
155
|
+
* editor. It's only used when `defaultDoc` or `defaultHTML` is also provided.
|
156
|
+
*/
|
157
|
+
defaultSelection?: SelectionJSON;
|
158
|
+
}
|
159
|
+
export { DefaultStateOptions }
|
160
|
+
export { DefaultStateOptions as DefaultStateOptions_alias_1 }
|
161
|
+
|
162
|
+
/**
|
163
|
+
* Add some base commands
|
164
|
+
*
|
165
|
+
* @public
|
166
|
+
*/
|
167
|
+
declare function defineBaseCommands(): Extension<{
|
168
|
+
COMMAND_ARGS: {
|
169
|
+
insertText: [{
|
170
|
+
text: string;
|
171
|
+
from?: number | undefined;
|
172
|
+
to?: number | undefined;
|
173
|
+
}];
|
174
|
+
insertNode: [options: {
|
175
|
+
node: Node_2;
|
176
|
+
pos?: number | undefined;
|
177
|
+
type?: undefined;
|
178
|
+
attrs?: undefined;
|
179
|
+
} | {
|
180
|
+
node?: undefined;
|
181
|
+
pos?: number | undefined;
|
182
|
+
type: string;
|
183
|
+
attrs?: Attrs_2 | undefined;
|
184
|
+
}];
|
185
|
+
wrap: [{
|
186
|
+
nodeType: NodeType_2;
|
187
|
+
attrs?: Attrs_2 | null | undefined;
|
188
|
+
}];
|
189
|
+
setBlockType: [options: {
|
190
|
+
type: string | NodeType_2;
|
191
|
+
attrs?: Attrs_2 | null | undefined;
|
192
|
+
from?: number | undefined;
|
193
|
+
to?: number | undefined;
|
194
|
+
}];
|
195
|
+
selectAll: [];
|
196
|
+
addMark: [options: {
|
197
|
+
type: string | MarkType_2;
|
198
|
+
attrs?: Attrs_2 | null | undefined;
|
199
|
+
from?: number | undefined;
|
200
|
+
to?: number | undefined;
|
201
|
+
}];
|
202
|
+
removeMark: [options: {
|
203
|
+
type: string | MarkType_2;
|
204
|
+
attrs?: Attrs_2 | null | undefined;
|
205
|
+
from?: number | undefined;
|
206
|
+
to?: number | undefined;
|
207
|
+
}];
|
208
|
+
};
|
209
|
+
}>;
|
210
|
+
export { defineBaseCommands }
|
211
|
+
export { defineBaseCommands as defineBaseCommands_alias_1 }
|
212
|
+
|
213
|
+
/**
|
214
|
+
* @public
|
215
|
+
*/
|
216
|
+
declare function defineBaseKeymap(): Extension<ExtensionTyping<string, string, CommandArgs>>;
|
217
|
+
export { defineBaseKeymap }
|
218
|
+
export { defineBaseKeymap as defineBaseKeymap_alias_1 }
|
219
|
+
|
220
|
+
declare function defineCommands<T extends Record<string, CommandCreator> = Record<string, CommandCreator>>(commands: T): Extension<{
|
221
|
+
COMMAND_ARGS: {
|
222
|
+
[K in keyof T]: Parameters<T[K]>;
|
223
|
+
};
|
224
|
+
}>;
|
225
|
+
export { defineCommands }
|
226
|
+
export { defineCommands as defineCommands_alias_1 }
|
227
|
+
|
228
|
+
declare function defineDefaultState({ defaultDoc, defaultHTML, defaultSelection, }: DefaultStateOptions): Extension;
|
229
|
+
export { defineDefaultState }
|
230
|
+
export { defineDefaultState as defineDefaultState_alias_1 }
|
231
|
+
|
232
|
+
/**
|
233
|
+
* @public
|
234
|
+
*/
|
235
|
+
declare function defineDoc(): Extension< {
|
236
|
+
NODES: "doc";
|
237
|
+
}>;
|
238
|
+
export { defineDoc }
|
239
|
+
export { defineDoc as defineDoc_alias_1 }
|
240
|
+
|
241
|
+
/**
|
242
|
+
* Add undo/redo history to the editor.
|
243
|
+
*/
|
244
|
+
declare function defineHistory(): Extension< {
|
245
|
+
COMMAND_ARGS: {
|
246
|
+
undo: [];
|
247
|
+
redo: [];
|
248
|
+
};
|
249
|
+
}>;
|
250
|
+
export { defineHistory }
|
251
|
+
export { defineHistory as defineHistory_alias_1 }
|
252
|
+
|
253
|
+
/**
|
254
|
+
* Defines an input rule extension.
|
255
|
+
*
|
256
|
+
* @param rule - The ProseMirror input rule to add, or an array of input rules,
|
257
|
+
* or a function that returns one or multiple input rules.
|
258
|
+
*
|
259
|
+
* @public
|
260
|
+
*/
|
261
|
+
declare function defineInputRule(rule: InputRule | InputRule[] | ((context: {
|
262
|
+
schema: Schema;
|
263
|
+
}) => InputRule | InputRule[])): Extension;
|
264
|
+
export { defineInputRule }
|
265
|
+
export { defineInputRule as defineInputRule_alias_1 }
|
266
|
+
|
267
|
+
/**
|
268
|
+
* @public
|
269
|
+
*/
|
270
|
+
declare function defineKeymap(keymap: Keymap): Extension;
|
271
|
+
export { defineKeymap }
|
272
|
+
export { defineKeymap as defineKeymap_alias_1 }
|
273
|
+
|
274
|
+
/**
|
275
|
+
* @public
|
276
|
+
*/
|
277
|
+
declare function defineMarkSpec<Mark extends string>(options: MarkSpecOptions<Mark>): Extension<{
|
278
|
+
MARKS: Mark;
|
279
|
+
}>;
|
280
|
+
export { defineMarkSpec }
|
281
|
+
export { defineMarkSpec as defineMarkSpec_alias_1 }
|
282
|
+
|
283
|
+
/**
|
284
|
+
* @public
|
285
|
+
*/
|
286
|
+
declare function defineNodeSpec<NodeName extends string>(options: NodeSpecOptions<NodeName>): Extension<{
|
287
|
+
NODES: NodeName;
|
288
|
+
}>;
|
289
|
+
export { defineNodeSpec }
|
290
|
+
export { defineNodeSpec as defineNodeSpec_alias_1 }
|
291
|
+
|
292
|
+
declare function defineNodeView(options: NodeViewOptions): Extension;
|
293
|
+
export { defineNodeView }
|
294
|
+
export { defineNodeView as defineNodeView_alias_1 }
|
295
|
+
|
296
|
+
declare function defineNodeViewEffect(options: NodeViewEffectOptions): Extension;
|
297
|
+
export { defineNodeViewEffect }
|
298
|
+
export { defineNodeViewEffect as defineNodeViewEffect_alias_1 }
|
299
|
+
|
300
|
+
/**
|
301
|
+
* @public
|
302
|
+
*
|
303
|
+
* Defines a paragraph node spec as the highest priority, because it should be the default block node for most cases.
|
304
|
+
*/
|
305
|
+
declare function defineParagraph(): Extension< {
|
306
|
+
NODES: "paragraph";
|
307
|
+
}>;
|
308
|
+
export { defineParagraph }
|
309
|
+
export { defineParagraph as defineParagraph_alias_1 }
|
310
|
+
|
311
|
+
/**
|
312
|
+
* @public
|
313
|
+
*
|
314
|
+
* Defines a paragraph node spec.
|
315
|
+
*/
|
316
|
+
export declare function defineParagraphSpec(): Extension< {
|
317
|
+
NODES: "paragraph";
|
318
|
+
}>;
|
319
|
+
|
320
|
+
/**
|
321
|
+
* Adds a ProseMirror plugin to the editor.
|
322
|
+
*
|
323
|
+
* @param plugin - The ProseMirror plugin to add, or an array of plugins, or a
|
324
|
+
* function that returns one or multiple plugins.
|
325
|
+
*
|
326
|
+
* @public
|
327
|
+
*/
|
328
|
+
declare function definePlugin(plugin: Plugin_2 | Plugin_2[] | ((context: {
|
329
|
+
schema: Schema;
|
330
|
+
}) => Plugin_2 | Plugin_2[])): Extension;
|
331
|
+
export { definePlugin }
|
332
|
+
export { definePlugin as definePlugin_alias_1 }
|
333
|
+
|
334
|
+
/**
|
335
|
+
* @public
|
336
|
+
*/
|
337
|
+
declare function defineText(): Extension< {
|
338
|
+
NODES: "text";
|
339
|
+
}>;
|
340
|
+
export { defineText }
|
341
|
+
export { defineText as defineText_alias_1 }
|
342
|
+
|
343
|
+
/**
|
344
|
+
* @internal
|
345
|
+
*/
|
346
|
+
declare function defineUpdateHandler(handler: UpdateHandler): Extension<ExtensionTyping<string, string, CommandArgs>>;
|
347
|
+
export { defineUpdateHandler }
|
348
|
+
export { defineUpdateHandler as defineUpdateHandler_alias_1 }
|
349
|
+
|
350
|
+
/**
|
351
|
+
* @public
|
352
|
+
*/
|
353
|
+
declare class Editor<E extends Extension = any> {
|
354
|
+
private instance;
|
355
|
+
private constructor();
|
356
|
+
private afterMounted;
|
357
|
+
/**
|
358
|
+
* @internal
|
359
|
+
*/
|
360
|
+
static create(instance: any): Editor<any>;
|
361
|
+
get mounted(): boolean;
|
362
|
+
get view(): EditorView;
|
363
|
+
get schema(): Schema<ExtractNodes<E>, ExtractMarks<E>>;
|
364
|
+
get commands(): ExtractCommandAppliers<E>;
|
365
|
+
mount(place: HTMLElement | null | undefined | void): void;
|
366
|
+
unmount(): void;
|
367
|
+
use(extension: Extension): VoidFunction;
|
368
|
+
/**
|
369
|
+
* @deprecated
|
370
|
+
*/
|
371
|
+
isNodeActive(nodeType: string | NodeType, attrs?: Attrs): boolean;
|
372
|
+
/**
|
373
|
+
* @deprecated
|
374
|
+
*/
|
375
|
+
isMarkActive(markType: string | MarkType, attrs?: Attrs): boolean;
|
376
|
+
get nodes(): Record<ExtractNodes<E>, NodeBuilder>;
|
377
|
+
get marks(): Record<ExtractMarks<E>, MarkBuilder>;
|
378
|
+
}
|
379
|
+
export { Editor }
|
380
|
+
export { Editor as Editor_alias_1 }
|
381
|
+
|
382
|
+
/**
|
383
|
+
* @public
|
384
|
+
*/
|
385
|
+
declare interface EditorOptions<E extends Extension> {
|
386
|
+
/**
|
387
|
+
* The extension to use when creating the editor.
|
388
|
+
*/
|
389
|
+
extension: E;
|
390
|
+
/**
|
391
|
+
* A JSON object representing the starting document to use when creating the
|
392
|
+
* editor.
|
393
|
+
*/
|
394
|
+
defaultDoc?: NodeJSON;
|
395
|
+
/**
|
396
|
+
* A HTML element or a HTML string representing the starting document to use
|
397
|
+
* when creating the editor.
|
398
|
+
*/
|
399
|
+
defaultHTML?: string | HTMLElement;
|
400
|
+
/**
|
401
|
+
* A JSON object representing the starting selection to use when creating the
|
402
|
+
* editor. It's only used when `defaultDoc` or `defaultHTML` is also provided.
|
403
|
+
*/
|
404
|
+
defaultSelection?: SelectionJSON;
|
405
|
+
}
|
406
|
+
export { EditorOptions }
|
407
|
+
export { EditorOptions as EditorOptions_alias_1 }
|
408
|
+
|
409
|
+
/**
|
410
|
+
* Parse a HTML string to a HTML element.
|
411
|
+
*
|
412
|
+
* @internal
|
413
|
+
*/
|
414
|
+
export declare function elementFromHTML(html: string): HTMLElement;
|
415
|
+
|
416
|
+
declare type EmptyValue = undefined | null | EmptyObject;
|
417
|
+
|
418
|
+
export declare type ExceptEmptyValue<T> = ConditionalExcept<T, EmptyValue>;
|
419
|
+
|
420
|
+
/**
|
421
|
+
* @public
|
422
|
+
*/
|
423
|
+
declare interface Extension<T extends ExtensionTyping = ExtensionTyping> {
|
424
|
+
extension: Extension | Extension[];
|
425
|
+
priority?: Priority;
|
426
|
+
_type?: T;
|
427
|
+
/**
|
428
|
+
* @public
|
429
|
+
*
|
430
|
+
* The schema that this extension represents.
|
431
|
+
*/
|
432
|
+
schema: Schema | null;
|
433
|
+
}
|
434
|
+
export { Extension }
|
435
|
+
export { Extension as Extension_alias_1 }
|
436
|
+
|
437
|
+
/**
|
438
|
+
* @internal
|
439
|
+
*/
|
440
|
+
declare interface ExtensionTyping<Node extends string = string, Mark extends string = string, Commands extends CommandArgs = CommandArgs> {
|
441
|
+
NODES?: Node;
|
442
|
+
MARKS?: Mark;
|
443
|
+
COMMAND_ARGS?: Commands;
|
444
|
+
}
|
445
|
+
export { ExtensionTyping }
|
446
|
+
export { ExtensionTyping as ExtensionTyping_alias_1 }
|
447
|
+
|
448
|
+
/**
|
449
|
+
* @public
|
450
|
+
*/
|
451
|
+
declare type ExtractCommandAppliers<E extends Extension> = ToCommandApplier<ExtractCommandArgs<E>>;
|
452
|
+
export { ExtractCommandAppliers }
|
453
|
+
export { ExtractCommandAppliers as ExtractCommandAppliers_alias_1 }
|
454
|
+
|
455
|
+
/**
|
456
|
+
* @internal
|
457
|
+
*/
|
458
|
+
export declare type ExtractCommandArgs<E extends Extension> = ExtractCommandArgsFromTyping<ExtractTyping<E>>;
|
459
|
+
|
460
|
+
export declare type ExtractCommandArgsFromTyping<T extends ExtensionTyping> = ExtractKey<T, 'COMMAND_ARGS'>;
|
461
|
+
|
462
|
+
/**
|
463
|
+
* @public
|
464
|
+
*/
|
465
|
+
declare type ExtractCommandCreators<E extends Extension> = ToCommandCreators<ExtractCommandArgs<E>>;
|
466
|
+
export { ExtractCommandCreators }
|
467
|
+
export { ExtractCommandCreators as ExtractCommandCreators_alias_1 }
|
468
|
+
|
469
|
+
/**
|
470
|
+
* @intneral
|
471
|
+
*/
|
472
|
+
export declare type ExtractKey<T, K extends string> = Extract<T, Record<K, any>>[K];
|
473
|
+
|
474
|
+
/**
|
475
|
+
* @public
|
476
|
+
*/
|
477
|
+
declare type ExtractMarks<E extends Extension> = ExtractMarksFromTyping<ExtractTyping<E>>;
|
478
|
+
export { ExtractMarks }
|
479
|
+
export { ExtractMarks as ExtractMarks_alias_1 }
|
480
|
+
|
481
|
+
export declare type ExtractMarksFromTyping<T extends ExtensionTyping> = ExtractKey<T, 'MARKS'>;
|
482
|
+
|
483
|
+
/**
|
484
|
+
* @public
|
485
|
+
*/
|
486
|
+
declare type ExtractNodes<E extends Extension> = ExtractNodesFromTyping<ExtractTyping<E>>;
|
487
|
+
export { ExtractNodes }
|
488
|
+
export { ExtractNodes as ExtractNodes_alias_1 }
|
489
|
+
|
490
|
+
export declare type ExtractNodesFromTyping<T extends ExtensionTyping> = ExtractKey<T, 'NODES'>;
|
491
|
+
|
492
|
+
/**
|
493
|
+
* @internal
|
494
|
+
*/
|
495
|
+
export declare type ExtractTyping<E extends Extension> = E extends Extension<infer T> ? T : never;
|
496
|
+
|
497
|
+
/**
|
498
|
+
* @public
|
499
|
+
*/
|
500
|
+
declare class Facet<Input, Output> {
|
501
|
+
/**
|
502
|
+
* @internal
|
503
|
+
*/
|
504
|
+
readonly index: number;
|
505
|
+
/**
|
506
|
+
* @internal
|
507
|
+
*/
|
508
|
+
readonly converter: () => FacetConverter<Input, Output>;
|
509
|
+
/**
|
510
|
+
* @internal
|
511
|
+
*/
|
512
|
+
readonly next: Facet<Output, any> | null;
|
513
|
+
/**
|
514
|
+
* @internal
|
515
|
+
*/
|
516
|
+
readonly singleton: boolean;
|
517
|
+
/**
|
518
|
+
* @internal
|
519
|
+
*/
|
520
|
+
isSchema: boolean;
|
521
|
+
private constructor();
|
522
|
+
static define<Input, Output>({ converter, convert, next, singleton, }: FacetOptions<Input, Output>): Facet<Input, Output>;
|
523
|
+
/**
|
524
|
+
* @internal
|
525
|
+
*/
|
526
|
+
static defineRootFacet<Input>(options: Omit<FacetOptions<Input, Input>, 'next'>): Facet<Input, Input>;
|
527
|
+
extension(payloads: Input[]): Extension;
|
528
|
+
}
|
529
|
+
export { Facet }
|
530
|
+
export { Facet as Facet_alias_1 }
|
531
|
+
|
532
|
+
/**
|
533
|
+
* @public
|
534
|
+
*/
|
535
|
+
export declare interface FacetConverter<Input = any, Output = any> {
|
536
|
+
create: (inputs: Input[]) => Output;
|
537
|
+
update: (inputs: Input[]) => Output | null;
|
538
|
+
}
|
539
|
+
|
540
|
+
/**
|
541
|
+
* @public
|
542
|
+
*/
|
543
|
+
export declare class FacetExtensionImpl<Input, Output> extends BaseExtension {
|
544
|
+
readonly facet: Facet<Input, Output>;
|
545
|
+
readonly payloads: Input[];
|
546
|
+
extension: Extension;
|
547
|
+
hasSchema: boolean;
|
548
|
+
schema: null;
|
549
|
+
constructor(facet: Facet<Input, Output>, payloads: Input[]);
|
550
|
+
}
|
551
|
+
|
552
|
+
/**
|
553
|
+
* @public
|
554
|
+
*/
|
555
|
+
declare interface FacetOptions<Input, Output> {
|
556
|
+
convert?: (payloads: Input[]) => Output;
|
557
|
+
converter?: () => FacetConverter<Input, Output>;
|
558
|
+
next: Facet<Output, any>;
|
559
|
+
singleton?: boolean;
|
560
|
+
}
|
561
|
+
export { FacetOptions }
|
562
|
+
export { FacetOptions as FacetOptions_alias_1 }
|
563
|
+
|
564
|
+
export declare function getBrowserDocument(): Document | undefined;
|
565
|
+
|
566
|
+
export declare function getBrowserWindow(): (Window & typeof globalThis) | null | undefined;
|
567
|
+
|
568
|
+
export declare function getCustomSelection(state: EditorState, from?: number | null, to?: number | null): Selection_3;
|
569
|
+
|
570
|
+
export declare function getFacetCount(): number;
|
571
|
+
|
572
|
+
/**
|
573
|
+
* @internal
|
574
|
+
*/
|
575
|
+
declare function getMarkType(schema: Schema, type: string | MarkType): MarkType;
|
576
|
+
export { getMarkType }
|
577
|
+
export { getMarkType as getMarkType_alias_1 }
|
578
|
+
|
579
|
+
/**
|
580
|
+
* @internal
|
581
|
+
*/
|
582
|
+
declare function getNodeType(schema: Schema, type: string | NodeType): NodeType;
|
583
|
+
export { getNodeType }
|
584
|
+
export { getNodeType as getNodeType_alias_1 }
|
585
|
+
|
586
|
+
declare function insertNode(options: {
|
587
|
+
node: ProseMirrorNode;
|
588
|
+
pos?: number;
|
589
|
+
type?: undefined;
|
590
|
+
attrs?: undefined;
|
591
|
+
} | {
|
592
|
+
node?: undefined;
|
593
|
+
pos?: number;
|
594
|
+
type: string;
|
595
|
+
attrs?: Attrs;
|
596
|
+
}): Command;
|
597
|
+
export { insertNode }
|
598
|
+
export { insertNode as insertNode_alias_1 }
|
599
|
+
|
600
|
+
export declare function insertNodeAction({ node, pos, }: {
|
601
|
+
node: ProseMirrorNode;
|
602
|
+
pos?: number;
|
603
|
+
}): Action;
|
604
|
+
|
605
|
+
export declare function insertText({ text, from, to, }: {
|
606
|
+
text: string;
|
607
|
+
from?: number;
|
608
|
+
to?: number;
|
609
|
+
}): Command;
|
610
|
+
|
611
|
+
/**
|
612
|
+
* @internal
|
613
|
+
*/
|
614
|
+
declare function isAllSelection(sel: Selection_2): sel is AllSelection;
|
615
|
+
export { isAllSelection }
|
616
|
+
export { isAllSelection as isAllSelection_alias_1 }
|
617
|
+
|
618
|
+
export declare const isMac: boolean;
|
619
|
+
|
620
|
+
/**
|
621
|
+
* @internal
|
622
|
+
*/
|
623
|
+
declare function isMark(mark: unknown): mark is Mark;
|
624
|
+
export { isMark }
|
625
|
+
export { isMark as isMark_alias_1 }
|
626
|
+
|
627
|
+
export declare function isMarkActive(state: EditorState, type: string | MarkType, attrs?: Attrs | null): boolean;
|
628
|
+
|
629
|
+
export declare function isNodeActive(state: EditorState, type: string | NodeType, attrs?: Attrs | null): boolean;
|
630
|
+
|
631
|
+
/**
|
632
|
+
* @internal
|
633
|
+
*/
|
634
|
+
declare function isNodeSelection(sel: Selection_2): sel is NodeSelection;
|
635
|
+
export { isNodeSelection }
|
636
|
+
export { isNodeSelection as isNodeSelection_alias_1 }
|
637
|
+
|
638
|
+
export declare function isNotNull<T>(value: T | null | undefined): value is T;
|
639
|
+
|
640
|
+
/**
|
641
|
+
* @internal
|
642
|
+
*/
|
643
|
+
declare function isProseMirrorNode(node: unknown): node is ProseMirrorNode;
|
644
|
+
export { isProseMirrorNode }
|
645
|
+
export { isProseMirrorNode as isProseMirrorNode_alias_1 }
|
646
|
+
|
647
|
+
/**
|
648
|
+
* @internal
|
649
|
+
*/
|
650
|
+
declare function isTextSelection(sel: Selection_2): sel is TextSelection;
|
651
|
+
export { isTextSelection }
|
652
|
+
export { isTextSelection as isTextSelection_alias_1 }
|
653
|
+
|
654
|
+
/**
|
655
|
+
* Parse a HTML element to a ProseMirror document JSON.
|
656
|
+
*
|
657
|
+
* @public
|
658
|
+
*/
|
659
|
+
declare function jsonFromElement(element: HTMLElement, schema: Schema): NodeJSON;
|
660
|
+
export { jsonFromElement }
|
661
|
+
export { jsonFromElement as jsonFromElement_alias_1 }
|
662
|
+
|
663
|
+
/**
|
664
|
+
* Parse a HTML string to a ProseMirror document JSON.
|
665
|
+
*
|
666
|
+
* @public
|
667
|
+
*/
|
668
|
+
declare function jsonFromHTML(html: string, schema: Schema): NodeJSON;
|
669
|
+
export { jsonFromHTML }
|
670
|
+
export { jsonFromHTML as jsonFromHTML_alias_1 }
|
671
|
+
|
672
|
+
/**
|
673
|
+
* Return a JSON object representing this node.
|
674
|
+
*
|
675
|
+
* @public
|
676
|
+
*/
|
677
|
+
declare function jsonFromNode(node: ProseMirrorNode): NodeJSON;
|
678
|
+
export { jsonFromNode }
|
679
|
+
export { jsonFromNode as jsonFromNode_alias_1 }
|
680
|
+
|
681
|
+
/**
|
682
|
+
* Return a JSON object representing this state.
|
683
|
+
*
|
684
|
+
* @public
|
685
|
+
*/
|
686
|
+
declare function jsonFromState(state: EditorState): StateJSON;
|
687
|
+
export { jsonFromState }
|
688
|
+
export { jsonFromState as jsonFromState_alias_1 }
|
689
|
+
|
690
|
+
/**
|
691
|
+
* @public
|
692
|
+
*/
|
693
|
+
declare interface Keymap {
|
694
|
+
[key: string]: Command;
|
695
|
+
}
|
696
|
+
export { Keymap }
|
697
|
+
export { Keymap as Keymap_alias_1 }
|
698
|
+
|
699
|
+
export declare interface MarkBuilder {
|
700
|
+
(attrs: Attrs | null, ...children: NodeChild[]): ProseMirrorNode[];
|
701
|
+
(...children: NodeChild[]): ProseMirrorNode[];
|
702
|
+
isActive(attrs?: Attrs): boolean;
|
703
|
+
}
|
704
|
+
|
705
|
+
/**
|
706
|
+
* @public
|
707
|
+
*/
|
708
|
+
declare interface MarkSpecOptions<MarkName extends string = string> extends MarkSpec {
|
709
|
+
name: MarkName;
|
710
|
+
}
|
711
|
+
export { MarkSpecOptions }
|
712
|
+
export { MarkSpecOptions as MarkSpecOptions_alias_1 }
|
713
|
+
|
714
|
+
export declare interface NodeBuilder {
|
715
|
+
(attrs: Attrs | null, ...children: NodeChild[]): ProseMirrorNode;
|
716
|
+
(...children: NodeChild[]): ProseMirrorNode;
|
717
|
+
isActive(attrs?: Attrs): boolean;
|
718
|
+
}
|
719
|
+
|
720
|
+
export declare type NodeChild = ProseMirrorNode | string | NodeChild[];
|
721
|
+
|
722
|
+
export declare type NodeContent = ProseMirrorNode | ProseMirrorFragment | NodeContent[];
|
723
|
+
|
724
|
+
/**
|
725
|
+
* Parse a HTML element to a ProseMirror node.
|
726
|
+
*
|
727
|
+
* @public
|
728
|
+
*/
|
729
|
+
declare function nodeFromElement(element: HTMLElement, schema: Schema): ProseMirrorNode;
|
730
|
+
export { nodeFromElement }
|
731
|
+
export { nodeFromElement as nodeFromElement_alias_1 }
|
732
|
+
|
733
|
+
/**
|
734
|
+
* Parse a HTML string to a ProseMirror node.
|
735
|
+
*
|
736
|
+
* @public
|
737
|
+
*/
|
738
|
+
declare function nodeFromHTML(html: string, schema: Schema): ProseMirrorNode;
|
739
|
+
export { nodeFromHTML }
|
740
|
+
export { nodeFromHTML as nodeFromHTML_alias_1 }
|
741
|
+
|
742
|
+
/**
|
743
|
+
* Parse a JSON object to a ProseMirror node.
|
744
|
+
*
|
745
|
+
* @public
|
746
|
+
*/
|
747
|
+
declare function nodeFromJSON(json: NodeJSON, schema: Schema): ProseMirrorNode;
|
748
|
+
export { nodeFromJSON }
|
749
|
+
export { nodeFromJSON as nodeFromJSON_alias_1 }
|
750
|
+
|
751
|
+
/**
|
752
|
+
* A JSON representation of the prosemirror node.
|
753
|
+
*
|
754
|
+
* @public
|
755
|
+
*/
|
756
|
+
declare interface NodeJSON {
|
757
|
+
type: string;
|
758
|
+
marks?: Array<any>;
|
759
|
+
text?: string;
|
760
|
+
content?: NodeJSON[];
|
761
|
+
attrs?: Record<string, any>;
|
762
|
+
}
|
763
|
+
export { NodeJSON }
|
764
|
+
export { NodeJSON as NodeJSON_alias_1 }
|
765
|
+
|
766
|
+
/**
|
767
|
+
* @public
|
768
|
+
*/
|
769
|
+
declare interface NodeSpecOptions<NodeName extends string = string> extends NodeSpec {
|
770
|
+
name: NodeName;
|
771
|
+
topNode?: boolean;
|
772
|
+
}
|
773
|
+
export { NodeSpecOptions }
|
774
|
+
export { NodeSpecOptions as NodeSpecOptions_alias_1 }
|
775
|
+
|
776
|
+
declare type NodeViewEffectOptions = {
|
777
|
+
group: string;
|
778
|
+
name: string;
|
779
|
+
args: unknown;
|
780
|
+
} | {
|
781
|
+
group: string;
|
782
|
+
name?: undefined;
|
783
|
+
factory: (args: unknown) => NodeViewConstructor;
|
784
|
+
};
|
785
|
+
export { NodeViewEffectOptions }
|
786
|
+
export { NodeViewEffectOptions as NodeViewEffectOptions_alias_1 }
|
787
|
+
|
788
|
+
declare interface NodeViewOptions {
|
789
|
+
name: string;
|
790
|
+
constructor: NodeViewConstructor;
|
791
|
+
}
|
792
|
+
export { NodeViewOptions }
|
793
|
+
export { NodeViewOptions as NodeViewOptions_alias_1 }
|
794
|
+
|
795
|
+
export declare function objectEqual<T>(a: T, b: T): boolean;
|
796
|
+
|
797
|
+
declare type Payload = unknown;
|
798
|
+
|
799
|
+
export declare type Payloads = PayloadTuple[];
|
800
|
+
|
801
|
+
declare type PayloadTuple = Tuple5<Payload[]>;
|
802
|
+
|
803
|
+
/**
|
804
|
+
* @internal
|
805
|
+
*/
|
806
|
+
declare const pluginFacet: Facet<PluginPayload, StatePayload>;
|
807
|
+
export { pluginFacet }
|
808
|
+
export { pluginFacet as pluginFacet_alias_1 }
|
809
|
+
|
810
|
+
/**
|
811
|
+
* @internal
|
812
|
+
*/
|
813
|
+
declare type PluginPayload = (context: {
|
814
|
+
schema: Schema;
|
815
|
+
}) => Plugin_2 | Plugin_2[];
|
816
|
+
export { PluginPayload }
|
817
|
+
export { PluginPayload as PluginPayload_alias_1 }
|
818
|
+
|
819
|
+
/**
|
820
|
+
* @public
|
821
|
+
*/
|
822
|
+
declare const enum Priority {
|
823
|
+
lowest = 4,
|
824
|
+
low = 3,
|
825
|
+
default = 2,
|
826
|
+
high = 1,
|
827
|
+
highest = 0
|
828
|
+
}
|
829
|
+
export { Priority }
|
830
|
+
export { Priority as Priority_alias_1 }
|
831
|
+
|
832
|
+
/**
|
833
|
+
* Base class for all ProseKit errors.
|
834
|
+
*/
|
835
|
+
declare class ProseKitError extends Error {
|
836
|
+
}
|
837
|
+
export { ProseKitError }
|
838
|
+
export { ProseKitError as ProseKitError_alias_1 }
|
839
|
+
|
840
|
+
/**
|
841
|
+
* Remove the given mark from the inline content.
|
842
|
+
*/
|
843
|
+
declare function removeMark(options: {
|
844
|
+
/**
|
845
|
+
* The type of the mark to remove.
|
846
|
+
*/
|
847
|
+
type: string | MarkType;
|
848
|
+
/**
|
849
|
+
* If attrs is given, remove precisely the mark with the given attrs. Otherwise, remove all marks of the given type.
|
850
|
+
*/
|
851
|
+
attrs?: Attrs | null;
|
852
|
+
/**
|
853
|
+
* The start position of the document. By default it will be the start position of current selection.
|
854
|
+
*/
|
855
|
+
from?: number;
|
856
|
+
/**
|
857
|
+
* The end position of the document. By default it will be the end position of current selection.
|
858
|
+
*/
|
859
|
+
to?: number;
|
860
|
+
}): Command;
|
861
|
+
export { removeMark }
|
862
|
+
export { removeMark as removeMark_alias_1 }
|
863
|
+
|
864
|
+
export declare const schemaFacet: Facet<SchemaPayload, SchemaPayload>;
|
865
|
+
|
866
|
+
export declare type SchemaPayload = SchemaSpec;
|
867
|
+
|
868
|
+
export declare function selectAll(): Command;
|
869
|
+
|
870
|
+
/**
|
871
|
+
* A JSON representation of the prosemirror selection.
|
872
|
+
*
|
873
|
+
* @public
|
874
|
+
*/
|
875
|
+
declare interface SelectionJSON {
|
876
|
+
anchor: number;
|
877
|
+
head: number;
|
878
|
+
type: string;
|
879
|
+
}
|
880
|
+
export { SelectionJSON }
|
881
|
+
export { SelectionJSON as SelectionJSON_alias_1 }
|
882
|
+
|
883
|
+
/**
|
884
|
+
* Returns a command that tries to set the selected textblocks to the given node
|
885
|
+
* type with the given attributes.
|
886
|
+
*/
|
887
|
+
declare function setBlockType(options: {
|
888
|
+
type: NodeType | string;
|
889
|
+
attrs?: Attrs | null;
|
890
|
+
from?: number;
|
891
|
+
to?: number;
|
892
|
+
}): Command;
|
893
|
+
export { setBlockType }
|
894
|
+
export { setBlockType as setBlockType_alias_1 }
|
895
|
+
|
896
|
+
/**
|
897
|
+
* @internal
|
898
|
+
*/
|
899
|
+
declare type SimplifyExtension<E extends Extension | Extension[]> = E extends Extension[] ? Extension<ExceptEmptyValue<{
|
900
|
+
NODES: ExtractNodes<E[number]>;
|
901
|
+
MARKS: ExtractMarks<E[number]>;
|
902
|
+
COMMAND_ARGS: SimplifyUnion<ExtractCommandArgs<E[number]>>;
|
903
|
+
}>> : E;
|
904
|
+
export { SimplifyExtension }
|
905
|
+
export { SimplifyExtension as SimplifyExtension_alias_1 }
|
906
|
+
|
907
|
+
/**
|
908
|
+
* @intneral
|
909
|
+
*/
|
910
|
+
declare type SimplifyUnion<T> = Simplify<UnionToIntersection<T>>;
|
911
|
+
export { SimplifyUnion }
|
912
|
+
export { SimplifyUnion as SimplifyUnion_alias_1 }
|
913
|
+
|
914
|
+
export declare const stateFacet: Facet<StatePayload, StatePayload>;
|
915
|
+
|
916
|
+
/**
|
917
|
+
* Parse a JSON object to a ProseMirror state.
|
918
|
+
*
|
919
|
+
* @public
|
920
|
+
*/
|
921
|
+
declare function stateFromJSON(json: StateJSON, schema: Schema): EditorState;
|
922
|
+
export { stateFromJSON }
|
923
|
+
export { stateFromJSON as stateFromJSON_alias_1 }
|
924
|
+
|
925
|
+
/**
|
926
|
+
* A JSON representation of the prosemirror state.
|
927
|
+
*
|
928
|
+
* @public
|
929
|
+
*/
|
930
|
+
declare interface StateJSON {
|
931
|
+
/**
|
932
|
+
* The main `ProseMirror` doc.
|
933
|
+
*/
|
934
|
+
doc: NodeJSON;
|
935
|
+
/**
|
936
|
+
* The current selection.
|
937
|
+
*/
|
938
|
+
selection: SelectionJSON;
|
939
|
+
}
|
940
|
+
export { StateJSON }
|
941
|
+
export { StateJSON as StateJSON_alias_1 }
|
942
|
+
|
943
|
+
export declare type StatePayload = (ctx: {
|
944
|
+
schema: Schema;
|
945
|
+
}) => EditorStateConfig;
|
946
|
+
|
947
|
+
export declare type ToCommandApplier<T extends CommandArgs> = {
|
948
|
+
[K in keyof T]: CommandApplier<T[K]>;
|
949
|
+
};
|
950
|
+
|
951
|
+
export declare type ToCommandArgs<T extends CommandCreators> = {
|
952
|
+
[K in keyof T]: Parameters<T[K]>;
|
953
|
+
};
|
954
|
+
|
955
|
+
export declare type ToCommandCreators<T extends CommandArgs> = {
|
956
|
+
[K in keyof T]: CommandCreator<T[K]>;
|
957
|
+
};
|
958
|
+
|
959
|
+
declare function toggleMark({ type, attrs, }: {
|
960
|
+
type: string | MarkType;
|
961
|
+
attrs?: Attrs | null;
|
962
|
+
}): Command;
|
963
|
+
export { toggleMark }
|
964
|
+
export { toggleMark as toggleMark_alias_1 }
|
965
|
+
|
966
|
+
declare function toggleNode({ type, attrs, }: {
|
967
|
+
type: string | NodeType;
|
968
|
+
attrs?: Attrs | null;
|
969
|
+
}): Command;
|
970
|
+
export { toggleNode }
|
971
|
+
export { toggleNode as toggleNode_alias_1 }
|
972
|
+
|
973
|
+
declare type Tuple5<T> = [T, T, T, T, T];
|
974
|
+
|
975
|
+
declare function union<E extends Extension | Extension[]>(extension: E): SimplifyExtension<E>;
|
976
|
+
export { union }
|
977
|
+
export { union as union_alias_1 }
|
978
|
+
|
979
|
+
export declare class UnionExtensionImpl<T extends ExtensionTyping = ExtensionTyping> extends BaseExtension<T> implements Extension<T> {
|
980
|
+
extension: BaseExtension[];
|
981
|
+
private _schema;
|
982
|
+
private hasSchemaCount;
|
983
|
+
constructor(extension?: BaseExtension[]);
|
984
|
+
get hasSchema(): boolean;
|
985
|
+
get schema(): Schema | null;
|
986
|
+
}
|
987
|
+
|
988
|
+
export declare function uniqPush<T>(prev: readonly T[], next: readonly T[]): T[];
|
989
|
+
|
990
|
+
export declare function uniqRemove<T>(prev: T[], next: T[]): T[];
|
991
|
+
|
992
|
+
export declare function updateExtension(prevInputs: Payloads, prevConverters: Converters, extension: Extension, mode: 'add' | 'remove'): {
|
993
|
+
schemaInput: SchemaPayload | null;
|
994
|
+
stateInput: StatePayload | null;
|
995
|
+
viewInput: ViewPayload | null;
|
996
|
+
commandInput: CommandCreators | null;
|
997
|
+
};
|
998
|
+
|
999
|
+
export declare type UpdateHandler = (options: {
|
1000
|
+
view: EditorView;
|
1001
|
+
prevState?: EditorState;
|
1002
|
+
}) => void;
|
1003
|
+
|
1004
|
+
export declare const viewFacet: Facet<ViewPayload, ViewPayload>;
|
1005
|
+
|
1006
|
+
export declare type ViewPayload = Omit<DirectEditorProps, 'state'>;
|
1007
|
+
|
1008
|
+
export declare function voidFunction(): void;
|
1009
|
+
|
1010
|
+
/**
|
1011
|
+
* @public
|
1012
|
+
*/
|
1013
|
+
declare function withPriority<T extends Extension>(extension: T, priority: Priority): T;
|
1014
|
+
export { withPriority }
|
1015
|
+
export { withPriority as withPriority_alias_1 }
|
1016
|
+
|
1017
|
+
export declare function wrap({ nodeType, attrs, }: {
|
1018
|
+
nodeType: NodeType;
|
1019
|
+
attrs?: Attrs | null;
|
1020
|
+
}): Command;
|
1021
|
+
|
1022
|
+
export { }
|