@blockslides/core 0.1.0
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/LICENSE.md +36 -0
- package/dist/index.d.mts +4131 -0
- package/dist/index.d.ts +4131 -0
- package/dist/index.js +6623 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +6485 -0
- package/dist/index.mjs.map +1 -0
- package/dist/jsx-runtime/jsx-runtime.d.mts +23 -0
- package/dist/jsx-runtime/jsx-runtime.d.ts +23 -0
- package/dist/jsx-runtime/jsx-runtime.js +56 -0
- package/dist/jsx-runtime/jsx-runtime.js.map +1 -0
- package/dist/jsx-runtime/jsx-runtime.mjs +26 -0
- package/dist/jsx-runtime/jsx-runtime.mjs.map +1 -0
- package/package.json +65 -0
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,4131 @@
|
|
|
1
|
+
import { Transaction, EditorState, Plugin, Selection, NodeSelection, TextSelection, PluginKey } from '@blockslides/pm/state';
|
|
2
|
+
import { Node as Node$1, MarkType as MarkType$1, MarkSpec, Mark as Mark$1, DOMOutputSpec, NodeType as NodeType$1, NodeSpec, Slice, ParseOptions, Fragment as Fragment$1, Schema, ContentMatch, ResolvedPos, ParseRule } from '@blockslides/pm/model';
|
|
3
|
+
import { NodeViewConstructor, NodeView as NodeView$1, MarkViewConstructor, MarkView as MarkView$1, EditorProps, EditorView, ViewMutationRecord, Decoration, DecorationAttrs } from '@blockslides/pm/view';
|
|
4
|
+
import { Transform, Mappable } from '@blockslides/pm/transform';
|
|
5
|
+
|
|
6
|
+
type StringKeyOf<T> = Extract<keyof T, string>;
|
|
7
|
+
type CallbackType<T extends Record<string, any>, EventName extends StringKeyOf<T>> = T[EventName] extends any[] ? T[EventName] : [T[EventName]];
|
|
8
|
+
type CallbackFunction<T extends Record<string, any>, EventName extends StringKeyOf<T>> = (...props: CallbackType<T, EventName>) => any;
|
|
9
|
+
declare class EventEmitter<T extends Record<string, any>> {
|
|
10
|
+
private callbacks;
|
|
11
|
+
on<EventName extends StringKeyOf<T>>(event: EventName, fn: CallbackFunction<T, EventName>): this;
|
|
12
|
+
emit<EventName extends StringKeyOf<T>>(event: EventName, ...args: CallbackType<T, EventName>): this;
|
|
13
|
+
off<EventName extends StringKeyOf<T>>(event: EventName, fn?: CallbackFunction<T, EventName>): this;
|
|
14
|
+
once<EventName extends StringKeyOf<T>>(event: EventName, fn: CallbackFunction<T, EventName>): this;
|
|
15
|
+
removeAllListeners(): void;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Returns a new `Transform` based on all steps of the passed transactions.
|
|
20
|
+
* @param oldDoc The Prosemirror node to start from
|
|
21
|
+
* @param transactions The transactions to combine
|
|
22
|
+
* @returns A new `Transform` with all steps of the passed transactions
|
|
23
|
+
*/
|
|
24
|
+
declare function combineTransactionSteps(oldDoc: Node$1, transactions: Transaction[]): Transform;
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Takes a Transaction & Editor State and turns it into a chainable state object
|
|
28
|
+
* @param config The transaction and state to create the chainable state from
|
|
29
|
+
* @returns A chainable Editor state object
|
|
30
|
+
*/
|
|
31
|
+
declare function createChainableState(config: {
|
|
32
|
+
transaction: Transaction;
|
|
33
|
+
state: EditorState;
|
|
34
|
+
}): EditorState;
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Editor Theme System
|
|
38
|
+
*
|
|
39
|
+
* Defines the styling system for both editor and slides.
|
|
40
|
+
* Single unified theme that controls all visual aspects.
|
|
41
|
+
*/
|
|
42
|
+
/**
|
|
43
|
+
* Complete theme definition
|
|
44
|
+
*/
|
|
45
|
+
interface Theme {
|
|
46
|
+
name: string;
|
|
47
|
+
editor: {
|
|
48
|
+
background: string;
|
|
49
|
+
foreground: string;
|
|
50
|
+
border: string;
|
|
51
|
+
};
|
|
52
|
+
slide: {
|
|
53
|
+
background: string;
|
|
54
|
+
border: string;
|
|
55
|
+
borderRadius: string;
|
|
56
|
+
shadow: string;
|
|
57
|
+
marginBottom: string;
|
|
58
|
+
padding: string;
|
|
59
|
+
minHeight?: string;
|
|
60
|
+
};
|
|
61
|
+
selection: string;
|
|
62
|
+
selectionBg: string;
|
|
63
|
+
hover: string;
|
|
64
|
+
active: string;
|
|
65
|
+
focus: string;
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Resolved theme type (can be null if no theme should be applied)
|
|
69
|
+
*/
|
|
70
|
+
type ResolvedTheme = Theme | null;
|
|
71
|
+
/**
|
|
72
|
+
* Partial theme for extending/overriding built-in themes
|
|
73
|
+
*/
|
|
74
|
+
type PartialTheme = {
|
|
75
|
+
name?: string;
|
|
76
|
+
editor?: Partial<Theme["editor"]>;
|
|
77
|
+
slide?: Partial<Theme["slide"]>;
|
|
78
|
+
selection?: string;
|
|
79
|
+
selectionBg?: string;
|
|
80
|
+
hover?: string;
|
|
81
|
+
active?: string;
|
|
82
|
+
focus?: string;
|
|
83
|
+
};
|
|
84
|
+
/**
|
|
85
|
+
* Theme configuration with optional extension
|
|
86
|
+
*/
|
|
87
|
+
type ThemeConfig = PartialTheme & {
|
|
88
|
+
extends?: string;
|
|
89
|
+
};
|
|
90
|
+
/**
|
|
91
|
+
* Union type for all theme input options
|
|
92
|
+
*/
|
|
93
|
+
type ThemeInput = string | Theme | ThemeConfig | undefined;
|
|
94
|
+
|
|
95
|
+
type InputRuleMatch = {
|
|
96
|
+
index: number;
|
|
97
|
+
text: string;
|
|
98
|
+
replaceWith?: string;
|
|
99
|
+
match?: RegExpMatchArray;
|
|
100
|
+
data?: Record<string, any>;
|
|
101
|
+
};
|
|
102
|
+
type InputRuleFinder = RegExp | ((text: string) => InputRuleMatch | null);
|
|
103
|
+
declare class InputRule {
|
|
104
|
+
find: InputRuleFinder;
|
|
105
|
+
handler: (props: {
|
|
106
|
+
state: EditorState;
|
|
107
|
+
range: Range;
|
|
108
|
+
match: ExtendedRegExpMatchArray;
|
|
109
|
+
commands: SingleCommands;
|
|
110
|
+
chain: () => ChainedCommands;
|
|
111
|
+
can: () => CanCommands;
|
|
112
|
+
}) => void | null;
|
|
113
|
+
undoable: boolean;
|
|
114
|
+
constructor(config: {
|
|
115
|
+
find: InputRuleFinder;
|
|
116
|
+
handler: (props: {
|
|
117
|
+
state: EditorState;
|
|
118
|
+
range: Range;
|
|
119
|
+
match: ExtendedRegExpMatchArray;
|
|
120
|
+
commands: SingleCommands;
|
|
121
|
+
chain: () => ChainedCommands;
|
|
122
|
+
can: () => CanCommands;
|
|
123
|
+
}) => void | null;
|
|
124
|
+
undoable?: boolean;
|
|
125
|
+
});
|
|
126
|
+
}
|
|
127
|
+
/**
|
|
128
|
+
* Create an input rules plugin. When enabled, it will cause text
|
|
129
|
+
* input that matches any of the given rules to trigger the rule’s
|
|
130
|
+
* action.
|
|
131
|
+
*/
|
|
132
|
+
declare function inputRulesPlugin(props: {
|
|
133
|
+
editor: SlideEditor;
|
|
134
|
+
rules: InputRule[];
|
|
135
|
+
}): Plugin;
|
|
136
|
+
|
|
137
|
+
interface MarkConfig<Options = any, Storage = any> extends ExtendableConfig<Options, Storage, MarkConfig<Options, Storage>, MarkType$1> {
|
|
138
|
+
/**
|
|
139
|
+
* Mark View
|
|
140
|
+
*/
|
|
141
|
+
addMarkView?: ((this: {
|
|
142
|
+
name: string;
|
|
143
|
+
options: Options;
|
|
144
|
+
storage: Storage;
|
|
145
|
+
editor: SlideEditor;
|
|
146
|
+
type: MarkType$1;
|
|
147
|
+
parent: ParentConfig<MarkConfig<Options, Storage>>["addMarkView"];
|
|
148
|
+
}) => MarkViewRenderer) | null;
|
|
149
|
+
/**
|
|
150
|
+
* Keep mark after split node
|
|
151
|
+
*/
|
|
152
|
+
keepOnSplit?: boolean | (() => boolean);
|
|
153
|
+
/**
|
|
154
|
+
* Inclusive
|
|
155
|
+
*/
|
|
156
|
+
inclusive?: MarkSpec["inclusive"] | ((this: {
|
|
157
|
+
name: string;
|
|
158
|
+
options: Options;
|
|
159
|
+
storage: Storage;
|
|
160
|
+
parent: ParentConfig<MarkConfig<Options, Storage>>["inclusive"];
|
|
161
|
+
editor?: SlideEditor;
|
|
162
|
+
}) => MarkSpec["inclusive"]);
|
|
163
|
+
/**
|
|
164
|
+
* Excludes
|
|
165
|
+
*/
|
|
166
|
+
excludes?: MarkSpec["excludes"] | ((this: {
|
|
167
|
+
name: string;
|
|
168
|
+
options: Options;
|
|
169
|
+
storage: Storage;
|
|
170
|
+
parent: ParentConfig<MarkConfig<Options, Storage>>["excludes"];
|
|
171
|
+
editor?: SlideEditor;
|
|
172
|
+
}) => MarkSpec["excludes"]);
|
|
173
|
+
/**
|
|
174
|
+
* Marks this Mark as exitable
|
|
175
|
+
*/
|
|
176
|
+
exitable?: boolean | (() => boolean);
|
|
177
|
+
/**
|
|
178
|
+
* Group
|
|
179
|
+
*/
|
|
180
|
+
group?: MarkSpec["group"] | ((this: {
|
|
181
|
+
name: string;
|
|
182
|
+
options: Options;
|
|
183
|
+
storage: Storage;
|
|
184
|
+
parent: ParentConfig<MarkConfig<Options, Storage>>["group"];
|
|
185
|
+
editor?: SlideEditor;
|
|
186
|
+
}) => MarkSpec["group"]);
|
|
187
|
+
/**
|
|
188
|
+
* Spanning
|
|
189
|
+
*/
|
|
190
|
+
spanning?: MarkSpec["spanning"] | ((this: {
|
|
191
|
+
name: string;
|
|
192
|
+
options: Options;
|
|
193
|
+
storage: Storage;
|
|
194
|
+
parent: ParentConfig<MarkConfig<Options, Storage>>["spanning"];
|
|
195
|
+
editor?: SlideEditor;
|
|
196
|
+
}) => MarkSpec["spanning"]);
|
|
197
|
+
/**
|
|
198
|
+
* Code
|
|
199
|
+
*/
|
|
200
|
+
code?: boolean | ((this: {
|
|
201
|
+
name: string;
|
|
202
|
+
options: Options;
|
|
203
|
+
storage: Storage;
|
|
204
|
+
parent: ParentConfig<MarkConfig<Options, Storage>>["code"];
|
|
205
|
+
editor?: SlideEditor;
|
|
206
|
+
}) => boolean);
|
|
207
|
+
/**
|
|
208
|
+
* Parse HTML
|
|
209
|
+
*/
|
|
210
|
+
parseHTML?: (this: {
|
|
211
|
+
name: string;
|
|
212
|
+
options: Options;
|
|
213
|
+
storage: Storage;
|
|
214
|
+
parent: ParentConfig<MarkConfig<Options, Storage>>["parseHTML"];
|
|
215
|
+
editor?: SlideEditor;
|
|
216
|
+
}) => MarkSpec["parseDOM"];
|
|
217
|
+
/**
|
|
218
|
+
* Render HTML
|
|
219
|
+
*/
|
|
220
|
+
renderHTML?: ((this: {
|
|
221
|
+
name: string;
|
|
222
|
+
options: Options;
|
|
223
|
+
storage: Storage;
|
|
224
|
+
parent: ParentConfig<MarkConfig<Options, Storage>>["renderHTML"];
|
|
225
|
+
editor?: SlideEditor;
|
|
226
|
+
}, props: {
|
|
227
|
+
mark: Mark$1;
|
|
228
|
+
HTMLAttributes: Record<string, any>;
|
|
229
|
+
}) => DOMOutputSpec) | null;
|
|
230
|
+
/**
|
|
231
|
+
* Attributes
|
|
232
|
+
*/
|
|
233
|
+
addAttributes?: (this: {
|
|
234
|
+
name: string;
|
|
235
|
+
options: Options;
|
|
236
|
+
storage: Storage;
|
|
237
|
+
parent: ParentConfig<MarkConfig<Options, Storage>>["addAttributes"];
|
|
238
|
+
editor?: SlideEditor;
|
|
239
|
+
}) => Attributes$1 | {};
|
|
240
|
+
}
|
|
241
|
+
declare class Mark<Options = any, Storage = any> extends Extendable<Options, Storage, MarkConfig<Options, Storage>> {
|
|
242
|
+
type: string;
|
|
243
|
+
/**
|
|
244
|
+
* Create a new Mark instance
|
|
245
|
+
* @param config - Mark configuration object or a function that returns a configuration object
|
|
246
|
+
*/
|
|
247
|
+
static create<O = any, S = any>(config?: Partial<MarkConfig<O, S>> | (() => Partial<MarkConfig<O, S>>)): Mark<O, S>;
|
|
248
|
+
static handleExit({ editor, mark }: {
|
|
249
|
+
editor: SlideEditor;
|
|
250
|
+
mark: Mark;
|
|
251
|
+
}): boolean;
|
|
252
|
+
configure(options?: Partial<Options>): Mark<Options, Storage>;
|
|
253
|
+
extend<ExtendedOptions = Options, ExtendedStorage = Storage, ExtendedConfig = MarkConfig<ExtendedOptions, ExtendedStorage>>(extendedConfig?: (() => Partial<ExtendedConfig>) | (Partial<ExtendedConfig> & ThisType<{
|
|
254
|
+
name: string;
|
|
255
|
+
options: ExtendedOptions;
|
|
256
|
+
storage: ExtendedStorage;
|
|
257
|
+
editor: SlideEditor;
|
|
258
|
+
type: MarkType$1;
|
|
259
|
+
}>)): Mark<ExtendedOptions, ExtendedStorage>;
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
interface NodeConfig<Options = any, Storage = any> extends ExtendableConfig<Options, Storage, NodeConfig<Options, Storage>, NodeType$1> {
|
|
263
|
+
/**
|
|
264
|
+
* Node View
|
|
265
|
+
*/
|
|
266
|
+
addNodeView?: ((this: {
|
|
267
|
+
name: string;
|
|
268
|
+
options: Options;
|
|
269
|
+
storage: Storage;
|
|
270
|
+
editor: SlideEditor;
|
|
271
|
+
type: NodeType$1;
|
|
272
|
+
parent: ParentConfig<NodeConfig<Options, Storage>>["addNodeView"];
|
|
273
|
+
}) => NodeViewRenderer) | null;
|
|
274
|
+
/**
|
|
275
|
+
* Defines if this node should be a top level node (doc)
|
|
276
|
+
* @default false
|
|
277
|
+
* @example true
|
|
278
|
+
*/
|
|
279
|
+
topNode?: boolean;
|
|
280
|
+
/**
|
|
281
|
+
* The content expression for this node, as described in the [schema
|
|
282
|
+
* guide](/docs/guide/#schema.content_expressions). When not given,
|
|
283
|
+
* the node does not allow any content.
|
|
284
|
+
*
|
|
285
|
+
* You can read more about it on the Prosemirror documentation here
|
|
286
|
+
* @see https://prosemirror.net/docs/guide/#schema.content_expressions
|
|
287
|
+
* @default undefined
|
|
288
|
+
* @example content: 'block+'
|
|
289
|
+
* @example content: 'headline paragraph block*'
|
|
290
|
+
*/
|
|
291
|
+
content?: NodeSpec["content"] | ((this: {
|
|
292
|
+
name: string;
|
|
293
|
+
options: Options;
|
|
294
|
+
storage: Storage;
|
|
295
|
+
parent: ParentConfig<NodeConfig<Options, Storage>>["content"];
|
|
296
|
+
editor?: SlideEditor;
|
|
297
|
+
}) => NodeSpec["content"]);
|
|
298
|
+
/**
|
|
299
|
+
* The marks that are allowed inside of this node. May be a
|
|
300
|
+
* space-separated string referring to mark names or groups, `"_"`
|
|
301
|
+
* to explicitly allow all marks, or `""` to disallow marks. When
|
|
302
|
+
* not given, nodes with inline content default to allowing all
|
|
303
|
+
* marks, other nodes default to not allowing marks.
|
|
304
|
+
*
|
|
305
|
+
* @example marks: 'strong em'
|
|
306
|
+
*/
|
|
307
|
+
marks?: NodeSpec["marks"] | ((this: {
|
|
308
|
+
name: string;
|
|
309
|
+
options: Options;
|
|
310
|
+
storage: Storage;
|
|
311
|
+
parent: ParentConfig<NodeConfig<Options, Storage>>["marks"];
|
|
312
|
+
editor?: SlideEditor;
|
|
313
|
+
}) => NodeSpec["marks"]);
|
|
314
|
+
/**
|
|
315
|
+
* The group or space-separated groups to which this node belongs,
|
|
316
|
+
* which can be referred to in the content expressions for the
|
|
317
|
+
* schema.
|
|
318
|
+
*
|
|
319
|
+
* By default BlockSlides uses the groups 'block' and 'inline' for nodes. You
|
|
320
|
+
* can also use custom groups if you want to group specific nodes together
|
|
321
|
+
* and handle them in your schema.
|
|
322
|
+
* @example group: 'block'
|
|
323
|
+
* @example group: 'inline'
|
|
324
|
+
* @example group: 'customBlock' // this uses a custom group
|
|
325
|
+
*/
|
|
326
|
+
group?: NodeSpec["group"] | ((this: {
|
|
327
|
+
name: string;
|
|
328
|
+
options: Options;
|
|
329
|
+
storage: Storage;
|
|
330
|
+
parent: ParentConfig<NodeConfig<Options, Storage>>["group"];
|
|
331
|
+
editor?: SlideEditor;
|
|
332
|
+
}) => NodeSpec["group"]);
|
|
333
|
+
/**
|
|
334
|
+
* Should be set to true for inline nodes. (Implied for text nodes.)
|
|
335
|
+
*/
|
|
336
|
+
inline?: NodeSpec["inline"] | ((this: {
|
|
337
|
+
name: string;
|
|
338
|
+
options: Options;
|
|
339
|
+
storage: Storage;
|
|
340
|
+
parent: ParentConfig<NodeConfig<Options, Storage>>["inline"];
|
|
341
|
+
editor?: SlideEditor;
|
|
342
|
+
}) => NodeSpec["inline"]);
|
|
343
|
+
/**
|
|
344
|
+
* Can be set to true to indicate that, though this isn't a [leaf
|
|
345
|
+
* node](https://prosemirror.net/docs/ref/#model.NodeType.isLeaf), it doesn't have directly editable
|
|
346
|
+
* content and should be treated as a single unit in the view.
|
|
347
|
+
*
|
|
348
|
+
* @example atom: true
|
|
349
|
+
*/
|
|
350
|
+
atom?: NodeSpec["atom"] | ((this: {
|
|
351
|
+
name: string;
|
|
352
|
+
options: Options;
|
|
353
|
+
storage: Storage;
|
|
354
|
+
parent: ParentConfig<NodeConfig<Options, Storage>>["atom"];
|
|
355
|
+
editor?: SlideEditor;
|
|
356
|
+
}) => NodeSpec["atom"]);
|
|
357
|
+
/**
|
|
358
|
+
* Controls whether nodes of this type can be selected as a [node
|
|
359
|
+
* selection](https://prosemirror.net/docs/ref/#state.NodeSelection). Defaults to true for non-text
|
|
360
|
+
* nodes.
|
|
361
|
+
*
|
|
362
|
+
* @default true
|
|
363
|
+
* @example selectable: false
|
|
364
|
+
*/
|
|
365
|
+
selectable?: NodeSpec["selectable"] | ((this: {
|
|
366
|
+
name: string;
|
|
367
|
+
options: Options;
|
|
368
|
+
storage: Storage;
|
|
369
|
+
parent: ParentConfig<NodeConfig<Options, Storage>>["selectable"];
|
|
370
|
+
editor?: SlideEditor;
|
|
371
|
+
}) => NodeSpec["selectable"]);
|
|
372
|
+
/**
|
|
373
|
+
* Determines whether nodes of this type can be dragged without
|
|
374
|
+
* being selected. Defaults to false.
|
|
375
|
+
*
|
|
376
|
+
* @default: false
|
|
377
|
+
* @example: draggable: true
|
|
378
|
+
*/
|
|
379
|
+
draggable?: NodeSpec["draggable"] | ((this: {
|
|
380
|
+
name: string;
|
|
381
|
+
options: Options;
|
|
382
|
+
storage: Storage;
|
|
383
|
+
parent: ParentConfig<NodeConfig<Options, Storage>>["draggable"];
|
|
384
|
+
editor?: SlideEditor;
|
|
385
|
+
}) => NodeSpec["draggable"]);
|
|
386
|
+
/**
|
|
387
|
+
* Can be used to indicate that this node contains code, which
|
|
388
|
+
* causes some commands to behave differently.
|
|
389
|
+
*/
|
|
390
|
+
code?: NodeSpec["code"] | ((this: {
|
|
391
|
+
name: string;
|
|
392
|
+
options: Options;
|
|
393
|
+
storage: Storage;
|
|
394
|
+
parent: ParentConfig<NodeConfig<Options, Storage>>["code"];
|
|
395
|
+
editor?: SlideEditor;
|
|
396
|
+
}) => NodeSpec["code"]);
|
|
397
|
+
/**
|
|
398
|
+
* Controls way whitespace in this a node is parsed. The default is
|
|
399
|
+
* `"normal"`, which causes the [DOM parser](https://prosemirror.net/docs/ref/#model.DOMParser) to
|
|
400
|
+
* collapse whitespace in normal mode, and normalize it (replacing
|
|
401
|
+
* newlines and such with spaces) otherwise. `"pre"` causes the
|
|
402
|
+
* parser to preserve spaces inside the node. When this option isn't
|
|
403
|
+
* given, but [`code`](https://prosemirror.net/docs/ref/#model.NodeSpec.code) is true, `whitespace`
|
|
404
|
+
* will default to `"pre"`. Note that this option doesn't influence
|
|
405
|
+
* the way the node is rendered—that should be handled by `toDOM`
|
|
406
|
+
* and/or styling.
|
|
407
|
+
*/
|
|
408
|
+
whitespace?: NodeSpec["whitespace"] | ((this: {
|
|
409
|
+
name: string;
|
|
410
|
+
options: Options;
|
|
411
|
+
storage: Storage;
|
|
412
|
+
parent: ParentConfig<NodeConfig<Options, Storage>>["whitespace"];
|
|
413
|
+
editor?: SlideEditor;
|
|
414
|
+
}) => NodeSpec["whitespace"]);
|
|
415
|
+
/**
|
|
416
|
+
* Allows a **single** node to be set as linebreak equivalent (e.g. hardBreak).
|
|
417
|
+
* When converting between block types that have whitespace set to "pre"
|
|
418
|
+
* and don't support the linebreak node (e.g. codeBlock) and other block types
|
|
419
|
+
* that do support the linebreak node (e.g. paragraphs) - this node will be used
|
|
420
|
+
* as the linebreak instead of stripping the newline.
|
|
421
|
+
*
|
|
422
|
+
* See [linebreakReplacement](https://prosemirror.net/docs/ref/#model.NodeSpec.linebreakReplacement).
|
|
423
|
+
*/
|
|
424
|
+
linebreakReplacement?: NodeSpec["linebreakReplacement"] | ((this: {
|
|
425
|
+
name: string;
|
|
426
|
+
options: Options;
|
|
427
|
+
storage: Storage;
|
|
428
|
+
parent: ParentConfig<NodeConfig<Options, Storage>>["linebreakReplacement"];
|
|
429
|
+
editor?: SlideEditor;
|
|
430
|
+
}) => NodeSpec["linebreakReplacement"]);
|
|
431
|
+
/**
|
|
432
|
+
* When enabled, enables both
|
|
433
|
+
* [`definingAsContext`](https://prosemirror.net/docs/ref/#model.NodeSpec.definingAsContext) and
|
|
434
|
+
* [`definingForContent`](https://prosemirror.net/docs/ref/#model.NodeSpec.definingForContent).
|
|
435
|
+
*
|
|
436
|
+
* @default false
|
|
437
|
+
* @example isolating: true
|
|
438
|
+
*/
|
|
439
|
+
defining?: NodeSpec["defining"] | ((this: {
|
|
440
|
+
name: string;
|
|
441
|
+
options: Options;
|
|
442
|
+
storage: Storage;
|
|
443
|
+
parent: ParentConfig<NodeConfig<Options, Storage>>["defining"];
|
|
444
|
+
editor?: SlideEditor;
|
|
445
|
+
}) => NodeSpec["defining"]);
|
|
446
|
+
/**
|
|
447
|
+
* When enabled (default is false), the sides of nodes of this type
|
|
448
|
+
* count as boundaries that regular editing operations, like
|
|
449
|
+
* backspacing or lifting, won't cross. An example of a node that
|
|
450
|
+
* should probably have this enabled is a table cell.
|
|
451
|
+
*/
|
|
452
|
+
isolating?: NodeSpec["isolating"] | ((this: {
|
|
453
|
+
name: string;
|
|
454
|
+
options: Options;
|
|
455
|
+
storage: Storage;
|
|
456
|
+
parent: ParentConfig<NodeConfig<Options, Storage>>["isolating"];
|
|
457
|
+
editor?: SlideEditor;
|
|
458
|
+
}) => NodeSpec["isolating"]);
|
|
459
|
+
/**
|
|
460
|
+
* Associates DOM parser information with this node, which can be
|
|
461
|
+
* used by [`DOMParser.fromSchema`](https://prosemirror.net/docs/ref/#model.DOMParser^fromSchema) to
|
|
462
|
+
* automatically derive a parser. The `node` field in the rules is
|
|
463
|
+
* implied (the name of this node will be filled in automatically).
|
|
464
|
+
* If you supply your own parser, you do not need to also specify
|
|
465
|
+
* parsing rules in your schema.
|
|
466
|
+
*
|
|
467
|
+
* @example parseHTML: [{ tag: 'div', attrs: { 'data-id': 'my-block' } }]
|
|
468
|
+
*/
|
|
469
|
+
parseHTML?: (this: {
|
|
470
|
+
name: string;
|
|
471
|
+
options: Options;
|
|
472
|
+
storage: Storage;
|
|
473
|
+
parent: ParentConfig<NodeConfig<Options, Storage>>["parseHTML"];
|
|
474
|
+
editor?: SlideEditor;
|
|
475
|
+
}) => NodeSpec["parseDOM"];
|
|
476
|
+
/**
|
|
477
|
+
* A description of a DOM structure. Can be either a string, which is
|
|
478
|
+
* interpreted as a text node, a DOM node, which is interpreted as
|
|
479
|
+
* itself, a `{dom, contentDOM}` object, or an array.
|
|
480
|
+
*
|
|
481
|
+
* An array describes a DOM element. The first value in the array
|
|
482
|
+
* should be a string—the name of the DOM element, optionally prefixed
|
|
483
|
+
* by a namespace URL and a space. If the second element is plain
|
|
484
|
+
* object, it is interpreted as a set of attributes for the element.
|
|
485
|
+
* Any elements after that (including the 2nd if it's not an attribute
|
|
486
|
+
* object) are interpreted as children of the DOM elements, and must
|
|
487
|
+
* either be valid `DOMOutputSpec` values, or the number zero.
|
|
488
|
+
*
|
|
489
|
+
* The number zero (pronounced “hole”) is used to indicate the place
|
|
490
|
+
* where a node's child nodes should be inserted. If it occurs in an
|
|
491
|
+
* output spec, it should be the only child element in its parent
|
|
492
|
+
* node.
|
|
493
|
+
*
|
|
494
|
+
* @example toDOM: ['div[data-id="my-block"]', { class: 'my-block' }, 0]
|
|
495
|
+
*/
|
|
496
|
+
renderHTML?: ((this: {
|
|
497
|
+
name: string;
|
|
498
|
+
options: Options;
|
|
499
|
+
storage: Storage;
|
|
500
|
+
parent: ParentConfig<NodeConfig<Options, Storage>>["renderHTML"];
|
|
501
|
+
editor?: SlideEditor;
|
|
502
|
+
}, props: {
|
|
503
|
+
node: Node$1;
|
|
504
|
+
HTMLAttributes: Record<string, any>;
|
|
505
|
+
}) => DOMOutputSpec) | null;
|
|
506
|
+
/**
|
|
507
|
+
* renders the node as text
|
|
508
|
+
* @example renderText: () => 'foo
|
|
509
|
+
*/
|
|
510
|
+
renderText?: ((this: {
|
|
511
|
+
name: string;
|
|
512
|
+
options: Options;
|
|
513
|
+
storage: Storage;
|
|
514
|
+
parent: ParentConfig<NodeConfig<Options, Storage>>["renderText"];
|
|
515
|
+
editor?: SlideEditor;
|
|
516
|
+
}, props: {
|
|
517
|
+
node: Node$1;
|
|
518
|
+
pos: number;
|
|
519
|
+
parent: Node$1;
|
|
520
|
+
index: number;
|
|
521
|
+
}) => string) | null;
|
|
522
|
+
/**
|
|
523
|
+
* Add attributes to the node
|
|
524
|
+
* @example addAttributes: () => ({ class: 'foo' })
|
|
525
|
+
*/
|
|
526
|
+
addAttributes?: (this: {
|
|
527
|
+
name: string;
|
|
528
|
+
options: Options;
|
|
529
|
+
storage: Storage;
|
|
530
|
+
parent: ParentConfig<NodeConfig<Options, Storage>>["addAttributes"];
|
|
531
|
+
editor?: SlideEditor;
|
|
532
|
+
}) => Attributes$1 | {};
|
|
533
|
+
}
|
|
534
|
+
declare class Node<Options = any, Storage = any> extends Extendable<Options, Storage, NodeConfig<Options, Storage>> {
|
|
535
|
+
type: string;
|
|
536
|
+
/**
|
|
537
|
+
* Create a new Node instance
|
|
538
|
+
* @param config - Node configuration object or a function that returns a configuration object
|
|
539
|
+
*/
|
|
540
|
+
static create<O = any, S = any>(config?: Partial<NodeConfig<O, S>> | (() => Partial<NodeConfig<O, S>>)): Node<O, S>;
|
|
541
|
+
configure(options?: Partial<Options>): Node<Options, Storage>;
|
|
542
|
+
extend<ExtendedOptions = Options, ExtendedStorage = Storage, ExtendedConfig = NodeConfig<ExtendedOptions, ExtendedStorage>>(extendedConfig?: (() => Partial<ExtendedConfig>) | (Partial<ExtendedConfig> & ThisType<{
|
|
543
|
+
name: string;
|
|
544
|
+
options: ExtendedOptions;
|
|
545
|
+
storage: ExtendedStorage;
|
|
546
|
+
editor: SlideEditor;
|
|
547
|
+
type: NodeType$1;
|
|
548
|
+
}>)): Node<ExtendedOptions, ExtendedStorage>;
|
|
549
|
+
}
|
|
550
|
+
|
|
551
|
+
type PasteRuleMatch = {
|
|
552
|
+
index: number;
|
|
553
|
+
text: string;
|
|
554
|
+
replaceWith?: string;
|
|
555
|
+
match?: RegExpMatchArray;
|
|
556
|
+
data?: Record<string, any>;
|
|
557
|
+
};
|
|
558
|
+
type PasteRuleFinder = RegExp | ((text: string, event?: ClipboardEvent | null) => PasteRuleMatch[] | null | undefined);
|
|
559
|
+
declare class PasteRule {
|
|
560
|
+
find: PasteRuleFinder;
|
|
561
|
+
handler: (props: {
|
|
562
|
+
state: EditorState;
|
|
563
|
+
range: Range;
|
|
564
|
+
match: ExtendedRegExpMatchArray;
|
|
565
|
+
commands: SingleCommands;
|
|
566
|
+
chain: () => ChainedCommands;
|
|
567
|
+
can: () => CanCommands;
|
|
568
|
+
pasteEvent: ClipboardEvent | null;
|
|
569
|
+
dropEvent: DragEvent | null;
|
|
570
|
+
}) => void | null;
|
|
571
|
+
constructor(config: {
|
|
572
|
+
find: PasteRuleFinder;
|
|
573
|
+
handler: (props: {
|
|
574
|
+
can: () => CanCommands;
|
|
575
|
+
chain: () => ChainedCommands;
|
|
576
|
+
commands: SingleCommands;
|
|
577
|
+
dropEvent: DragEvent | null;
|
|
578
|
+
match: ExtendedRegExpMatchArray;
|
|
579
|
+
pasteEvent: ClipboardEvent | null;
|
|
580
|
+
range: Range;
|
|
581
|
+
state: EditorState;
|
|
582
|
+
}) => void | null;
|
|
583
|
+
});
|
|
584
|
+
}
|
|
585
|
+
/**
|
|
586
|
+
* Create an paste rules plugin. When enabled, it will cause pasted
|
|
587
|
+
* text that matches any of the given rules to trigger the rule’s
|
|
588
|
+
* action.
|
|
589
|
+
*/
|
|
590
|
+
declare function pasteRulesPlugin(props: {
|
|
591
|
+
editor: SlideEditor;
|
|
592
|
+
rules: PasteRule[];
|
|
593
|
+
}): Plugin[];
|
|
594
|
+
|
|
595
|
+
interface ExtendableConfig<Options = any, Storage = any, Config extends ExtensionConfig<Options, Storage> | NodeConfig<Options, Storage> | MarkConfig<Options, Storage> | ExtendableConfig<Options, Storage> = ExtendableConfig<Options, Storage, any, any>, PMType = any> {
|
|
596
|
+
/**
|
|
597
|
+
* The extension name - this must be unique.
|
|
598
|
+
* It will be used to identify the extension.
|
|
599
|
+
*
|
|
600
|
+
* @example 'myExtension'
|
|
601
|
+
*/
|
|
602
|
+
name: string;
|
|
603
|
+
/**
|
|
604
|
+
* The priority of your extension. The higher, the earlier it will be called
|
|
605
|
+
* and will take precedence over other extensions with a lower priority.
|
|
606
|
+
* @default 100
|
|
607
|
+
* @example 101
|
|
608
|
+
*/
|
|
609
|
+
priority?: number;
|
|
610
|
+
addOptions?: (this: {
|
|
611
|
+
name: string;
|
|
612
|
+
parent: ParentConfig<Config>["addOptions"];
|
|
613
|
+
}) => Options;
|
|
614
|
+
addStorage?: (this: {
|
|
615
|
+
name: string;
|
|
616
|
+
options: Options;
|
|
617
|
+
parent: ParentConfig<Config>["addStorage"];
|
|
618
|
+
}) => Storage;
|
|
619
|
+
addGlobalAttributes?: (this: {
|
|
620
|
+
name: string;
|
|
621
|
+
options: Options;
|
|
622
|
+
storage: Storage;
|
|
623
|
+
extensions: (Node | Mark)[];
|
|
624
|
+
parent: ParentConfig<Config>["addGlobalAttributes"];
|
|
625
|
+
}) => GlobalAttributes;
|
|
626
|
+
addCommands?: (this: {
|
|
627
|
+
name: string;
|
|
628
|
+
options: Options;
|
|
629
|
+
storage: Storage;
|
|
630
|
+
editor: SlideEditor;
|
|
631
|
+
type: PMType;
|
|
632
|
+
parent: ParentConfig<Config>["addCommands"];
|
|
633
|
+
}) => Partial<RawCommands>;
|
|
634
|
+
addKeyboardShortcuts?: (this: {
|
|
635
|
+
name: string;
|
|
636
|
+
options: Options;
|
|
637
|
+
storage: Storage;
|
|
638
|
+
editor: SlideEditor;
|
|
639
|
+
type: PMType;
|
|
640
|
+
parent: ParentConfig<Config>["addKeyboardShortcuts"];
|
|
641
|
+
}) => {
|
|
642
|
+
[key: string]: KeyboardShortcutCommand;
|
|
643
|
+
};
|
|
644
|
+
addInputRules?: (this: {
|
|
645
|
+
name: string;
|
|
646
|
+
options: Options;
|
|
647
|
+
storage: Storage;
|
|
648
|
+
editor: SlideEditor;
|
|
649
|
+
type: PMType;
|
|
650
|
+
parent: ParentConfig<Config>["addInputRules"];
|
|
651
|
+
}) => InputRule[];
|
|
652
|
+
addPasteRules?: (this: {
|
|
653
|
+
name: string;
|
|
654
|
+
options: Options;
|
|
655
|
+
storage: Storage;
|
|
656
|
+
editor: SlideEditor;
|
|
657
|
+
type: PMType;
|
|
658
|
+
parent: ParentConfig<Config>["addPasteRules"];
|
|
659
|
+
}) => PasteRule[];
|
|
660
|
+
addProseMirrorPlugins?: (this: {
|
|
661
|
+
name: string;
|
|
662
|
+
options: Options;
|
|
663
|
+
storage: Storage;
|
|
664
|
+
editor: SlideEditor;
|
|
665
|
+
type: PMType;
|
|
666
|
+
parent: ParentConfig<Config>["addProseMirrorPlugins"];
|
|
667
|
+
}) => Plugin[];
|
|
668
|
+
addExtensions?: (this: {
|
|
669
|
+
name: string;
|
|
670
|
+
options: Options;
|
|
671
|
+
storage: Storage;
|
|
672
|
+
parent: ParentConfig<Config>["addExtensions"];
|
|
673
|
+
}) => Extensions;
|
|
674
|
+
markdownTokenName?: string;
|
|
675
|
+
/**
|
|
676
|
+
* The parse function used by the markdown parser to convert markdown tokens to ProseMirror nodes.
|
|
677
|
+
*/
|
|
678
|
+
parseMarkdown?: (token: MarkdownToken, helpers: MarkdownParseHelpers) => MarkdownParseResult;
|
|
679
|
+
/**
|
|
680
|
+
* The serializer function used by the markdown serializer to convert ProseMirror nodes to markdown tokens.
|
|
681
|
+
*/
|
|
682
|
+
renderMarkdown?: (node: JSONContent, helpers: MarkdownRendererHelpers, ctx: RenderContext) => string;
|
|
683
|
+
/**
|
|
684
|
+
* The markdown tokenizer responsible for turning a markdown string into tokens
|
|
685
|
+
*
|
|
686
|
+
* Custom tokenizers are only needed when you want to parse non-standard markdown token.
|
|
687
|
+
*/
|
|
688
|
+
markdownTokenizer?: MarkdownTokenizer;
|
|
689
|
+
/**
|
|
690
|
+
* Optional markdown options for indentation
|
|
691
|
+
*/
|
|
692
|
+
markdownOptions?: {
|
|
693
|
+
/**
|
|
694
|
+
* Defines if this markdown element should indent it's child elements
|
|
695
|
+
*/
|
|
696
|
+
indentsContent?: boolean;
|
|
697
|
+
};
|
|
698
|
+
/**
|
|
699
|
+
* This function extends the schema of the node.
|
|
700
|
+
* @example
|
|
701
|
+
* extendNodeSchema() {
|
|
702
|
+
* return {
|
|
703
|
+
* group: 'inline',
|
|
704
|
+
* selectable: false,
|
|
705
|
+
* }
|
|
706
|
+
* }
|
|
707
|
+
*/
|
|
708
|
+
extendNodeSchema?: ((this: {
|
|
709
|
+
name: string;
|
|
710
|
+
options: Options;
|
|
711
|
+
storage: Storage;
|
|
712
|
+
parent: ParentConfig<Config>["extendNodeSchema"];
|
|
713
|
+
}, extension: Node) => Record<string, any>) | null;
|
|
714
|
+
/**
|
|
715
|
+
* This function extends the schema of the mark.
|
|
716
|
+
* @example
|
|
717
|
+
* extendMarkSchema() {
|
|
718
|
+
* return {
|
|
719
|
+
* group: 'inline',
|
|
720
|
+
* selectable: false,
|
|
721
|
+
* }
|
|
722
|
+
* }
|
|
723
|
+
*/
|
|
724
|
+
extendMarkSchema?: ((this: {
|
|
725
|
+
name: string;
|
|
726
|
+
options: Options;
|
|
727
|
+
storage: Storage;
|
|
728
|
+
parent: ParentConfig<Config>["extendMarkSchema"];
|
|
729
|
+
}, extension: Mark) => Record<string, any>) | null;
|
|
730
|
+
/**
|
|
731
|
+
* The editor is not ready yet.
|
|
732
|
+
*/
|
|
733
|
+
onBeforeCreate?: ((this: {
|
|
734
|
+
name: string;
|
|
735
|
+
options: Options;
|
|
736
|
+
storage: Storage;
|
|
737
|
+
editor: SlideEditor;
|
|
738
|
+
type: PMType;
|
|
739
|
+
parent: ParentConfig<Config>["onBeforeCreate"];
|
|
740
|
+
}, event: EditorEvents["beforeCreate"]) => void) | null;
|
|
741
|
+
/**
|
|
742
|
+
* The editor is ready.
|
|
743
|
+
*/
|
|
744
|
+
onCreate?: ((this: {
|
|
745
|
+
name: string;
|
|
746
|
+
options: Options;
|
|
747
|
+
storage: Storage;
|
|
748
|
+
editor: SlideEditor;
|
|
749
|
+
type: PMType;
|
|
750
|
+
parent: ParentConfig<Config>["onCreate"];
|
|
751
|
+
}, event: EditorEvents["create"]) => void) | null;
|
|
752
|
+
/**
|
|
753
|
+
* The content has changed.
|
|
754
|
+
*/
|
|
755
|
+
onUpdate?: ((this: {
|
|
756
|
+
name: string;
|
|
757
|
+
options: Options;
|
|
758
|
+
storage: Storage;
|
|
759
|
+
editor: SlideEditor;
|
|
760
|
+
type: PMType;
|
|
761
|
+
parent: ParentConfig<Config>["onUpdate"];
|
|
762
|
+
}, event: EditorEvents["update"]) => void) | null;
|
|
763
|
+
/**
|
|
764
|
+
* The selection has changed.
|
|
765
|
+
*/
|
|
766
|
+
onSelectionUpdate?: ((this: {
|
|
767
|
+
name: string;
|
|
768
|
+
options: Options;
|
|
769
|
+
storage: Storage;
|
|
770
|
+
editor: SlideEditor;
|
|
771
|
+
type: PMType;
|
|
772
|
+
parent: ParentConfig<Config>["onSelectionUpdate"];
|
|
773
|
+
}, event: EditorEvents["selectionUpdate"]) => void) | null;
|
|
774
|
+
/**
|
|
775
|
+
* The editor state has changed.
|
|
776
|
+
*/
|
|
777
|
+
onTransaction?: ((this: {
|
|
778
|
+
name: string;
|
|
779
|
+
options: Options;
|
|
780
|
+
storage: Storage;
|
|
781
|
+
editor: SlideEditor;
|
|
782
|
+
type: PMType;
|
|
783
|
+
parent: ParentConfig<Config>["onTransaction"];
|
|
784
|
+
}, event: EditorEvents["transaction"]) => void) | null;
|
|
785
|
+
/**
|
|
786
|
+
* The editor is focused.
|
|
787
|
+
*/
|
|
788
|
+
onFocus?: ((this: {
|
|
789
|
+
name: string;
|
|
790
|
+
options: Options;
|
|
791
|
+
storage: Storage;
|
|
792
|
+
editor: SlideEditor;
|
|
793
|
+
type: PMType;
|
|
794
|
+
parent: ParentConfig<Config>["onFocus"];
|
|
795
|
+
}, event: EditorEvents["focus"]) => void) | null;
|
|
796
|
+
/**
|
|
797
|
+
* The editor isn’t focused anymore.
|
|
798
|
+
*/
|
|
799
|
+
onBlur?: ((this: {
|
|
800
|
+
name: string;
|
|
801
|
+
options: Options;
|
|
802
|
+
storage: Storage;
|
|
803
|
+
editor: SlideEditor;
|
|
804
|
+
type: PMType;
|
|
805
|
+
parent: ParentConfig<Config>["onBlur"];
|
|
806
|
+
}, event: EditorEvents["blur"]) => void) | null;
|
|
807
|
+
/**
|
|
808
|
+
* The editor is destroyed.
|
|
809
|
+
*/
|
|
810
|
+
onDestroy?: ((this: {
|
|
811
|
+
name: string;
|
|
812
|
+
options: Options;
|
|
813
|
+
storage: Storage;
|
|
814
|
+
editor: SlideEditor;
|
|
815
|
+
type: PMType;
|
|
816
|
+
parent: ParentConfig<Config>["onDestroy"];
|
|
817
|
+
}, event: EditorEvents["destroy"]) => void) | null;
|
|
818
|
+
}
|
|
819
|
+
declare class Extendable<Options = any, Storage = any, Config = ExtensionConfig<Options, Storage> | NodeConfig<Options, Storage> | MarkConfig<Options, Storage>> {
|
|
820
|
+
type: string;
|
|
821
|
+
parent: Extendable | null;
|
|
822
|
+
child: Extendable | null;
|
|
823
|
+
name: string;
|
|
824
|
+
config: Config;
|
|
825
|
+
constructor(config?: Partial<Config>);
|
|
826
|
+
get options(): Options;
|
|
827
|
+
get storage(): Readonly<Storage>;
|
|
828
|
+
configure(options?: Partial<Options>): Extendable<Options, Storage, ExtensionConfig<Options, Storage> | NodeConfig<Options, Storage> | MarkConfig<Options, Storage>>;
|
|
829
|
+
extend<ExtendedOptions = Options, ExtendedStorage = Storage, ExtendedConfig = ExtensionConfig<ExtendedOptions, ExtendedStorage> | NodeConfig<ExtendedOptions, ExtendedStorage> | MarkConfig<ExtendedOptions, ExtendedStorage>>(extendedConfig?: Partial<ExtendedConfig>): Extendable<ExtendedOptions, ExtendedStorage>;
|
|
830
|
+
}
|
|
831
|
+
|
|
832
|
+
type AnyConfig = ExtensionConfig | NodeConfig | MarkConfig;
|
|
833
|
+
type AnyExtension = Extendable;
|
|
834
|
+
type Extensions = AnyExtension[];
|
|
835
|
+
type ParentConfig<T> = Partial<{
|
|
836
|
+
[P in keyof T]: Required<T>[P] extends (...args: any) => any ? (...args: Parameters<Required<T>[P]>) => ReturnType<Required<T>[P]> : T[P];
|
|
837
|
+
}>;
|
|
838
|
+
type Primitive = null | undefined | string | number | boolean | symbol | bigint;
|
|
839
|
+
type RemoveThis<T> = T extends (...args: any) => any ? (...args: Parameters<T>) => ReturnType<T> : T;
|
|
840
|
+
type MaybeReturnType<T> = T extends (...args: any) => any ? ReturnType<T> : T;
|
|
841
|
+
type MaybeThisParameterType<T> = Exclude<T, Primitive> extends (...args: any) => any ? ThisParameterType<Exclude<T, Primitive>> : any;
|
|
842
|
+
interface EditorEvents {
|
|
843
|
+
mount: {
|
|
844
|
+
/**
|
|
845
|
+
* The editor instance
|
|
846
|
+
*/
|
|
847
|
+
editor: SlideEditor;
|
|
848
|
+
};
|
|
849
|
+
unmount: {
|
|
850
|
+
/**
|
|
851
|
+
* The editor instance
|
|
852
|
+
*/
|
|
853
|
+
editor: SlideEditor;
|
|
854
|
+
};
|
|
855
|
+
beforeCreate: {
|
|
856
|
+
/**
|
|
857
|
+
* The editor instance
|
|
858
|
+
*/
|
|
859
|
+
editor: SlideEditor;
|
|
860
|
+
};
|
|
861
|
+
create: {
|
|
862
|
+
/**
|
|
863
|
+
* The editor instance
|
|
864
|
+
*/
|
|
865
|
+
editor: SlideEditor;
|
|
866
|
+
};
|
|
867
|
+
contentError: {
|
|
868
|
+
/**
|
|
869
|
+
* The editor instance
|
|
870
|
+
*/
|
|
871
|
+
editor: SlideEditor;
|
|
872
|
+
/**
|
|
873
|
+
* The error that occurred while parsing the content
|
|
874
|
+
*/
|
|
875
|
+
error: Error;
|
|
876
|
+
/**
|
|
877
|
+
* If called, will re-initialize the editor with the collaboration extension removed.
|
|
878
|
+
* This will prevent syncing back deletions of content not present in the current schema.
|
|
879
|
+
*/
|
|
880
|
+
disableCollaboration: () => void;
|
|
881
|
+
};
|
|
882
|
+
update: {
|
|
883
|
+
/**
|
|
884
|
+
* The editor instance
|
|
885
|
+
*/
|
|
886
|
+
editor: SlideEditor;
|
|
887
|
+
/**
|
|
888
|
+
* The transaction that caused the update
|
|
889
|
+
*/
|
|
890
|
+
transaction: Transaction;
|
|
891
|
+
/**
|
|
892
|
+
* Appended transactions that were added to the initial transaction by plugins
|
|
893
|
+
*/
|
|
894
|
+
appendedTransactions: Transaction[];
|
|
895
|
+
};
|
|
896
|
+
selectionUpdate: {
|
|
897
|
+
/**
|
|
898
|
+
* The editor instance
|
|
899
|
+
*/
|
|
900
|
+
editor: SlideEditor;
|
|
901
|
+
/**
|
|
902
|
+
* The transaction that caused the selection update
|
|
903
|
+
*/
|
|
904
|
+
transaction: Transaction;
|
|
905
|
+
};
|
|
906
|
+
beforeTransaction: {
|
|
907
|
+
/**
|
|
908
|
+
* The editor instance
|
|
909
|
+
*/
|
|
910
|
+
editor: SlideEditor;
|
|
911
|
+
/**
|
|
912
|
+
* The transaction that will be applied
|
|
913
|
+
*/
|
|
914
|
+
transaction: Transaction;
|
|
915
|
+
/**
|
|
916
|
+
* The next state of the editor after the transaction is applied
|
|
917
|
+
*/
|
|
918
|
+
nextState: EditorState;
|
|
919
|
+
};
|
|
920
|
+
transaction: {
|
|
921
|
+
/**
|
|
922
|
+
* The editor instance
|
|
923
|
+
*/
|
|
924
|
+
editor: SlideEditor;
|
|
925
|
+
/**
|
|
926
|
+
* The initial transaction
|
|
927
|
+
*/
|
|
928
|
+
transaction: Transaction;
|
|
929
|
+
/**
|
|
930
|
+
* Appended transactions that were added to the initial transaction by plugins
|
|
931
|
+
*/
|
|
932
|
+
appendedTransactions: Transaction[];
|
|
933
|
+
};
|
|
934
|
+
focus: {
|
|
935
|
+
/**
|
|
936
|
+
* The editor instance
|
|
937
|
+
*/
|
|
938
|
+
editor: SlideEditor;
|
|
939
|
+
/**
|
|
940
|
+
* The focus event
|
|
941
|
+
*/
|
|
942
|
+
event: FocusEvent;
|
|
943
|
+
/**
|
|
944
|
+
* The transaction that caused the focus
|
|
945
|
+
*/
|
|
946
|
+
transaction: Transaction;
|
|
947
|
+
};
|
|
948
|
+
blur: {
|
|
949
|
+
/**
|
|
950
|
+
* The editor instance
|
|
951
|
+
*/
|
|
952
|
+
editor: SlideEditor;
|
|
953
|
+
/**
|
|
954
|
+
* The focus event
|
|
955
|
+
*/
|
|
956
|
+
event: FocusEvent;
|
|
957
|
+
/**
|
|
958
|
+
* The transaction that caused the blur
|
|
959
|
+
*/
|
|
960
|
+
transaction: Transaction;
|
|
961
|
+
};
|
|
962
|
+
destroy: void;
|
|
963
|
+
paste: {
|
|
964
|
+
/**
|
|
965
|
+
* The editor instance
|
|
966
|
+
*/
|
|
967
|
+
editor: SlideEditor;
|
|
968
|
+
/**
|
|
969
|
+
* The clipboard event
|
|
970
|
+
*/
|
|
971
|
+
event: ClipboardEvent;
|
|
972
|
+
/**
|
|
973
|
+
* The slice that was pasted
|
|
974
|
+
*/
|
|
975
|
+
slice: Slice;
|
|
976
|
+
};
|
|
977
|
+
drop: {
|
|
978
|
+
/**
|
|
979
|
+
* The editor instance
|
|
980
|
+
*/
|
|
981
|
+
editor: SlideEditor;
|
|
982
|
+
/**
|
|
983
|
+
* The drag event
|
|
984
|
+
*/
|
|
985
|
+
event: DragEvent;
|
|
986
|
+
/**
|
|
987
|
+
* The slice that was dropped
|
|
988
|
+
*/
|
|
989
|
+
slice: Slice;
|
|
990
|
+
/**
|
|
991
|
+
* Whether the content was moved (true) or copied (false)
|
|
992
|
+
*/
|
|
993
|
+
moved: boolean;
|
|
994
|
+
};
|
|
995
|
+
delete: {
|
|
996
|
+
/**
|
|
997
|
+
* The editor instance
|
|
998
|
+
*/
|
|
999
|
+
editor: SlideEditor;
|
|
1000
|
+
/**
|
|
1001
|
+
* The range of the deleted content (before the deletion)
|
|
1002
|
+
*/
|
|
1003
|
+
deletedRange: Range;
|
|
1004
|
+
/**
|
|
1005
|
+
* The new range of positions of where the deleted content was in the new document (after the deletion)
|
|
1006
|
+
*/
|
|
1007
|
+
newRange: Range;
|
|
1008
|
+
/**
|
|
1009
|
+
* The transaction that caused the deletion
|
|
1010
|
+
*/
|
|
1011
|
+
transaction: Transaction;
|
|
1012
|
+
/**
|
|
1013
|
+
* The combined transform (including all appended transactions) that caused the deletion
|
|
1014
|
+
*/
|
|
1015
|
+
combinedTransform: Transform;
|
|
1016
|
+
/**
|
|
1017
|
+
* Whether the deletion was partial (only a part of this content was deleted)
|
|
1018
|
+
*/
|
|
1019
|
+
partial: boolean;
|
|
1020
|
+
/**
|
|
1021
|
+
* This is the start position of the mark in the document (before the deletion)
|
|
1022
|
+
*/
|
|
1023
|
+
from: number;
|
|
1024
|
+
/**
|
|
1025
|
+
* This is the end position of the mark in the document (before the deletion)
|
|
1026
|
+
*/
|
|
1027
|
+
to: number;
|
|
1028
|
+
} & ({
|
|
1029
|
+
/**
|
|
1030
|
+
* The content that was deleted
|
|
1031
|
+
*/
|
|
1032
|
+
type: "node";
|
|
1033
|
+
/**
|
|
1034
|
+
* The node which the deletion occurred in
|
|
1035
|
+
* @note This can be a parent node of the deleted content
|
|
1036
|
+
*/
|
|
1037
|
+
node: Node$1;
|
|
1038
|
+
/**
|
|
1039
|
+
* The new start position of the node in the document (after the deletion)
|
|
1040
|
+
*/
|
|
1041
|
+
newFrom: number;
|
|
1042
|
+
/**
|
|
1043
|
+
* The new end position of the node in the document (after the deletion)
|
|
1044
|
+
*/
|
|
1045
|
+
newTo: number;
|
|
1046
|
+
} | {
|
|
1047
|
+
/**
|
|
1048
|
+
* The content that was deleted
|
|
1049
|
+
*/
|
|
1050
|
+
type: "mark";
|
|
1051
|
+
/**
|
|
1052
|
+
* The mark that was deleted
|
|
1053
|
+
*/
|
|
1054
|
+
mark: Mark$1;
|
|
1055
|
+
});
|
|
1056
|
+
}
|
|
1057
|
+
type EnableRules = (AnyExtension | string)[] | boolean;
|
|
1058
|
+
interface EditorOptions {
|
|
1059
|
+
/**
|
|
1060
|
+
* The element to bind the editor to:
|
|
1061
|
+
* - If an `Element` is passed, the editor will be mounted appended to that element
|
|
1062
|
+
* - If `null` is passed, the editor will not be mounted automatically
|
|
1063
|
+
* - If an object with a `mount` property is passed, the editor will be mounted to that element
|
|
1064
|
+
* - If a function is passed, it will be called with the editor's element, which should place the editor within the document
|
|
1065
|
+
*/
|
|
1066
|
+
element: Element | {
|
|
1067
|
+
mount: HTMLElement;
|
|
1068
|
+
} | ((editor: HTMLElement) => void) | null;
|
|
1069
|
+
/**
|
|
1070
|
+
* The content of the editor (HTML, JSON, or a JSON array)
|
|
1071
|
+
*/
|
|
1072
|
+
content: Content;
|
|
1073
|
+
/**
|
|
1074
|
+
* The extensions to use
|
|
1075
|
+
*/
|
|
1076
|
+
extensions: Extensions;
|
|
1077
|
+
/**
|
|
1078
|
+
* Editor theme for UI styling
|
|
1079
|
+
*
|
|
1080
|
+
* Can be:
|
|
1081
|
+
* - String: 'light' or 'dark' (built-in themes)
|
|
1082
|
+
* - Full theme object with all colors
|
|
1083
|
+
* - Partial theme with extends property to override built-in theme
|
|
1084
|
+
*
|
|
1085
|
+
* @default undefined (no theme applied)
|
|
1086
|
+
* @example 'light'
|
|
1087
|
+
* @example 'dark'
|
|
1088
|
+
* @example { name: 'custom', colors: { background: '#000', ... } }
|
|
1089
|
+
* @example { extends: 'dark', colors: { background: '#0a0a0a' } }
|
|
1090
|
+
*/
|
|
1091
|
+
theme?: string | Theme | ThemeConfig;
|
|
1092
|
+
/**
|
|
1093
|
+
* Whether to inject base CSS styles
|
|
1094
|
+
*/
|
|
1095
|
+
injectCSS: boolean;
|
|
1096
|
+
/**
|
|
1097
|
+
* A nonce to use for CSP while injecting styles
|
|
1098
|
+
*/
|
|
1099
|
+
injectNonce: string | undefined;
|
|
1100
|
+
/**
|
|
1101
|
+
* The editor's initial focus position
|
|
1102
|
+
*/
|
|
1103
|
+
autofocus: FocusPosition;
|
|
1104
|
+
/**
|
|
1105
|
+
* Whether the editor is editable
|
|
1106
|
+
*/
|
|
1107
|
+
editable: boolean;
|
|
1108
|
+
/**
|
|
1109
|
+
* The editor's props
|
|
1110
|
+
*/
|
|
1111
|
+
editorProps: EditorProps;
|
|
1112
|
+
/**
|
|
1113
|
+
* The editor's content parser options
|
|
1114
|
+
*/
|
|
1115
|
+
parseOptions: ParseOptions;
|
|
1116
|
+
/**
|
|
1117
|
+
* The editor's core extension options
|
|
1118
|
+
*/
|
|
1119
|
+
coreExtensionOptions?: {
|
|
1120
|
+
clipboardTextSerializer?: {
|
|
1121
|
+
blockSeparator?: string;
|
|
1122
|
+
};
|
|
1123
|
+
delete?: {
|
|
1124
|
+
/**
|
|
1125
|
+
* Whether the `delete` extension should be called asynchronously to avoid blocking the editor while processing deletions
|
|
1126
|
+
* @default true deletion events are called asynchronously
|
|
1127
|
+
*/
|
|
1128
|
+
async?: boolean;
|
|
1129
|
+
/**
|
|
1130
|
+
* Allows filtering the transactions that are processed by the `delete` extension.
|
|
1131
|
+
* If the function returns `true`, the transaction will be ignored.
|
|
1132
|
+
*/
|
|
1133
|
+
filterTransaction?: (transaction: Transaction) => boolean;
|
|
1134
|
+
};
|
|
1135
|
+
};
|
|
1136
|
+
/**
|
|
1137
|
+
* Whether to enable input rules behavior
|
|
1138
|
+
*/
|
|
1139
|
+
enableInputRules: EnableRules;
|
|
1140
|
+
/**
|
|
1141
|
+
* Whether to enable paste rules behavior
|
|
1142
|
+
*/
|
|
1143
|
+
enablePasteRules: EnableRules;
|
|
1144
|
+
/**
|
|
1145
|
+
* Determines whether core extensions are enabled.
|
|
1146
|
+
*
|
|
1147
|
+
* If set to `false`, all core extensions will be disabled.
|
|
1148
|
+
* To disable specific core extensions, provide an object where the keys are the extension names and the values are `false`.
|
|
1149
|
+
* Extensions not listed in the object will remain enabled.
|
|
1150
|
+
*
|
|
1151
|
+
* @example
|
|
1152
|
+
* // Disable all core extensions
|
|
1153
|
+
* enabledCoreExtensions: false
|
|
1154
|
+
*
|
|
1155
|
+
* @example
|
|
1156
|
+
* // Disable only the keymap core extension
|
|
1157
|
+
* enabledCoreExtensions: { keymap: false }
|
|
1158
|
+
*
|
|
1159
|
+
* @default true
|
|
1160
|
+
*/
|
|
1161
|
+
enableCoreExtensions?: boolean | Partial<Record<"editable" | "clipboardTextSerializer" | "commands" | "focusEvents" | "keymap" | "tabindex" | "drop" | "paste" | "delete", false>>;
|
|
1162
|
+
/**
|
|
1163
|
+
* If `true`, the editor will check the content for errors on initialization.
|
|
1164
|
+
* Emitting the `contentError` event if the content is invalid.
|
|
1165
|
+
* Which can be used to show a warning or error message to the user.
|
|
1166
|
+
* @default false
|
|
1167
|
+
*/
|
|
1168
|
+
enableContentCheck: boolean;
|
|
1169
|
+
/**
|
|
1170
|
+
* If `true`, the editor will emit the `contentError` event if invalid content is
|
|
1171
|
+
* encountered but `enableContentCheck` is `false`. This lets you preserve the
|
|
1172
|
+
* invalid editor content while still showing a warning or error message to
|
|
1173
|
+
* the user.
|
|
1174
|
+
*
|
|
1175
|
+
* @default false
|
|
1176
|
+
*/
|
|
1177
|
+
emitContentError: boolean;
|
|
1178
|
+
/**
|
|
1179
|
+
* Called before the editor is constructed.
|
|
1180
|
+
*/
|
|
1181
|
+
onBeforeCreate: (props: EditorEvents["beforeCreate"]) => void;
|
|
1182
|
+
/**
|
|
1183
|
+
* Called after the editor is constructed.
|
|
1184
|
+
*/
|
|
1185
|
+
onCreate: (props: EditorEvents["create"]) => void;
|
|
1186
|
+
/**
|
|
1187
|
+
* Called when the editor is mounted.
|
|
1188
|
+
*/
|
|
1189
|
+
onMount: (props: EditorEvents["mount"]) => void;
|
|
1190
|
+
/**
|
|
1191
|
+
* Called when the editor is unmounted.
|
|
1192
|
+
*/
|
|
1193
|
+
onUnmount: (props: EditorEvents["unmount"]) => void;
|
|
1194
|
+
/**
|
|
1195
|
+
* Called when the editor encounters an error while parsing the content.
|
|
1196
|
+
* Only enabled if `enableContentCheck` is `true`.
|
|
1197
|
+
*/
|
|
1198
|
+
onContentError: (props: EditorEvents["contentError"]) => void;
|
|
1199
|
+
/**
|
|
1200
|
+
* Called when the editor's content is updated.
|
|
1201
|
+
*/
|
|
1202
|
+
onUpdate: (props: EditorEvents["update"]) => void;
|
|
1203
|
+
/**
|
|
1204
|
+
* Called when the editor's selection is updated.
|
|
1205
|
+
*/
|
|
1206
|
+
onSelectionUpdate: (props: EditorEvents["selectionUpdate"]) => void;
|
|
1207
|
+
/**
|
|
1208
|
+
* Called after a transaction is applied to the editor.
|
|
1209
|
+
*/
|
|
1210
|
+
onTransaction: (props: EditorEvents["transaction"]) => void;
|
|
1211
|
+
/**
|
|
1212
|
+
* Called on focus events.
|
|
1213
|
+
*/
|
|
1214
|
+
onFocus: (props: EditorEvents["focus"]) => void;
|
|
1215
|
+
/**
|
|
1216
|
+
* Called on blur events.
|
|
1217
|
+
*/
|
|
1218
|
+
onBlur: (props: EditorEvents["blur"]) => void;
|
|
1219
|
+
/**
|
|
1220
|
+
* Called when the editor is destroyed.
|
|
1221
|
+
*/
|
|
1222
|
+
onDestroy: (props: EditorEvents["destroy"]) => void;
|
|
1223
|
+
/**
|
|
1224
|
+
* Called when content is pasted into the editor.
|
|
1225
|
+
*/
|
|
1226
|
+
onPaste: (e: ClipboardEvent, slice: Slice) => void;
|
|
1227
|
+
/**
|
|
1228
|
+
* Called when content is dropped into the editor.
|
|
1229
|
+
*/
|
|
1230
|
+
onDrop: (e: DragEvent, slice: Slice, moved: boolean) => void;
|
|
1231
|
+
/**
|
|
1232
|
+
* Called when content is deleted from the editor.
|
|
1233
|
+
*/
|
|
1234
|
+
onDelete: (props: EditorEvents["delete"]) => void;
|
|
1235
|
+
}
|
|
1236
|
+
/**
|
|
1237
|
+
* The editor's content as HTML
|
|
1238
|
+
*/
|
|
1239
|
+
type HTMLContent = string;
|
|
1240
|
+
/**
|
|
1241
|
+
* Loosely describes a JSON representation of a Prosemirror document or node
|
|
1242
|
+
*/
|
|
1243
|
+
type JSONContent = {
|
|
1244
|
+
type?: string;
|
|
1245
|
+
attrs?: Record<string, any> | undefined;
|
|
1246
|
+
content?: JSONContent[];
|
|
1247
|
+
marks?: {
|
|
1248
|
+
type: string;
|
|
1249
|
+
attrs?: Record<string, any>;
|
|
1250
|
+
[key: string]: any;
|
|
1251
|
+
}[];
|
|
1252
|
+
text?: string;
|
|
1253
|
+
[key: string]: any;
|
|
1254
|
+
};
|
|
1255
|
+
/**
|
|
1256
|
+
* A mark type is either a JSON representation of a mark or a Prosemirror mark instance
|
|
1257
|
+
*/
|
|
1258
|
+
type MarkType<Type extends string | {
|
|
1259
|
+
name: string;
|
|
1260
|
+
} = any, TAttributes extends undefined | Record<string, any> = any> = {
|
|
1261
|
+
type: Type;
|
|
1262
|
+
attrs: TAttributes;
|
|
1263
|
+
};
|
|
1264
|
+
/**
|
|
1265
|
+
* A node type is either a JSON representation of a node or a Prosemirror node instance
|
|
1266
|
+
*/
|
|
1267
|
+
type NodeType<Type extends string | {
|
|
1268
|
+
name: string;
|
|
1269
|
+
} = any, TAttributes extends undefined | Record<string, any> = any, NodeMarkType extends MarkType = any, TContent extends (NodeType | TextType)[] = any> = {
|
|
1270
|
+
type: Type;
|
|
1271
|
+
attrs: TAttributes;
|
|
1272
|
+
content?: TContent;
|
|
1273
|
+
marks?: NodeMarkType[];
|
|
1274
|
+
};
|
|
1275
|
+
/**
|
|
1276
|
+
* A node type is either a JSON representation of a doc node or a Prosemirror doc node instance
|
|
1277
|
+
*/
|
|
1278
|
+
type DocumentType<TDocAttributes extends Record<string, any> | undefined = Record<string, any>, TContentType extends NodeType[] = NodeType[]> = Omit<NodeType<"doc", TDocAttributes, never, TContentType>, "marks" | "content"> & {
|
|
1279
|
+
content: TContentType;
|
|
1280
|
+
};
|
|
1281
|
+
/**
|
|
1282
|
+
* A node type is either a JSON representation of a text node or a Prosemirror text node instance
|
|
1283
|
+
*/
|
|
1284
|
+
type TextType<TMarkType extends MarkType = MarkType> = {
|
|
1285
|
+
type: "text";
|
|
1286
|
+
text: string;
|
|
1287
|
+
marks: TMarkType[];
|
|
1288
|
+
};
|
|
1289
|
+
/**
|
|
1290
|
+
* Describes the output of a `renderHTML` function in prosemirror
|
|
1291
|
+
* @see https://prosemirror.net/docs/ref/#model.DOMOutputSpec
|
|
1292
|
+
*/
|
|
1293
|
+
type DOMOutputSpecArray$1 = [string] | [string, Record<string, any>] | [string, 0] | [string, Record<string, any>, 0] | [string, Record<string, any>, DOMOutputSpecArray$1 | 0] | [string, DOMOutputSpecArray$1];
|
|
1294
|
+
type Content = HTMLContent | JSONContent | JSONContent[] | null;
|
|
1295
|
+
type CommandProps = {
|
|
1296
|
+
editor: SlideEditor;
|
|
1297
|
+
tr: Transaction;
|
|
1298
|
+
commands: SingleCommands;
|
|
1299
|
+
can: () => CanCommands;
|
|
1300
|
+
chain: () => ChainedCommands;
|
|
1301
|
+
state: EditorState;
|
|
1302
|
+
view: EditorView;
|
|
1303
|
+
dispatch: ((args?: any) => any) | undefined;
|
|
1304
|
+
};
|
|
1305
|
+
type Command = (props: CommandProps) => boolean;
|
|
1306
|
+
type CommandSpec = (...args: any[]) => Command;
|
|
1307
|
+
type KeyboardShortcutCommand = (props: {
|
|
1308
|
+
editor: SlideEditor;
|
|
1309
|
+
}) => boolean;
|
|
1310
|
+
type Attribute = {
|
|
1311
|
+
default?: any;
|
|
1312
|
+
validate?: string | ((value: any) => void);
|
|
1313
|
+
rendered?: boolean;
|
|
1314
|
+
renderHTML?: ((attributes: Record<string, any>) => Record<string, any> | null) | null;
|
|
1315
|
+
parseHTML?: ((element: HTMLElement) => any | null) | null;
|
|
1316
|
+
keepOnSplit?: boolean;
|
|
1317
|
+
isRequired?: boolean;
|
|
1318
|
+
};
|
|
1319
|
+
type Attributes$1 = {
|
|
1320
|
+
[key: string]: Attribute;
|
|
1321
|
+
};
|
|
1322
|
+
type ExtensionAttribute = {
|
|
1323
|
+
type: string;
|
|
1324
|
+
name: string;
|
|
1325
|
+
attribute: Required<Omit<Attribute, "validate">> & Pick<Attribute, "validate">;
|
|
1326
|
+
};
|
|
1327
|
+
type GlobalAttributes = {
|
|
1328
|
+
/**
|
|
1329
|
+
* The node & mark types this attribute should be applied to.
|
|
1330
|
+
*/
|
|
1331
|
+
types: string[];
|
|
1332
|
+
/**
|
|
1333
|
+
* The attributes to add to the node or mark types.
|
|
1334
|
+
*/
|
|
1335
|
+
attributes: Record<string, Attribute | undefined>;
|
|
1336
|
+
}[];
|
|
1337
|
+
type PickValue<T, K extends keyof T> = T[K];
|
|
1338
|
+
type UnionToIntersection<U> = (U extends any ? (k: U) => void : never) extends (k: infer I) => void ? I : never;
|
|
1339
|
+
type Diff<T extends keyof any, U extends keyof any> = ({
|
|
1340
|
+
[P in T]: P;
|
|
1341
|
+
} & {
|
|
1342
|
+
[P in U]: never;
|
|
1343
|
+
} & {
|
|
1344
|
+
[x: string]: never;
|
|
1345
|
+
})[T];
|
|
1346
|
+
type Overwrite<T, U> = Pick<T, Diff<keyof T, keyof U>> & U;
|
|
1347
|
+
type ValuesOf<T> = T[keyof T];
|
|
1348
|
+
type KeysWithTypeOf<T, Type> = {
|
|
1349
|
+
[P in keyof T]: T[P] extends Type ? P : never;
|
|
1350
|
+
}[keyof T];
|
|
1351
|
+
type DOMNode = InstanceType<typeof window.Node>;
|
|
1352
|
+
/**
|
|
1353
|
+
* prosemirror-view does not export the `type` property of `Decoration`.
|
|
1354
|
+
* So, this defines the `DecorationType` interface to include the `type` property.
|
|
1355
|
+
*/
|
|
1356
|
+
interface DecorationType {
|
|
1357
|
+
spec: any;
|
|
1358
|
+
map(mapping: Mappable, span: Decoration, offset: number, oldOffset: number): Decoration | null;
|
|
1359
|
+
valid(node: Node, span: Decoration): boolean;
|
|
1360
|
+
eq(other: DecorationType): boolean;
|
|
1361
|
+
destroy(dom: DOMNode): void;
|
|
1362
|
+
readonly attrs: DecorationAttrs;
|
|
1363
|
+
}
|
|
1364
|
+
/**
|
|
1365
|
+
* prosemirror-view does not export the `type` property of `Decoration`.
|
|
1366
|
+
* This adds the `type` property to the `Decoration` type.
|
|
1367
|
+
*/
|
|
1368
|
+
type DecorationWithType = Decoration & {
|
|
1369
|
+
type: DecorationType;
|
|
1370
|
+
};
|
|
1371
|
+
interface NodeViewProps extends NodeViewRendererProps {
|
|
1372
|
+
decorations: readonly DecorationWithType[];
|
|
1373
|
+
selected: boolean;
|
|
1374
|
+
updateAttributes: (attributes: Record<string, any>) => void;
|
|
1375
|
+
deleteNode: () => void;
|
|
1376
|
+
}
|
|
1377
|
+
interface NodeViewRendererOptions {
|
|
1378
|
+
stopEvent: ((props: {
|
|
1379
|
+
event: Event;
|
|
1380
|
+
}) => boolean) | null;
|
|
1381
|
+
ignoreMutation: ((props: {
|
|
1382
|
+
mutation: ViewMutationRecord;
|
|
1383
|
+
}) => boolean) | null;
|
|
1384
|
+
contentDOMElementTag: string;
|
|
1385
|
+
}
|
|
1386
|
+
interface NodeViewRendererProps {
|
|
1387
|
+
/**
|
|
1388
|
+
* The node that is being rendered.
|
|
1389
|
+
*/
|
|
1390
|
+
node: Parameters<NodeViewConstructor>[0];
|
|
1391
|
+
/**
|
|
1392
|
+
* The editor's view.
|
|
1393
|
+
*/
|
|
1394
|
+
view: Parameters<NodeViewConstructor>[1];
|
|
1395
|
+
/**
|
|
1396
|
+
* A function that can be called to get the node's current position in the document.
|
|
1397
|
+
*/
|
|
1398
|
+
getPos: Parameters<NodeViewConstructor>[2];
|
|
1399
|
+
/**
|
|
1400
|
+
* is an array of node or inline decorations that are active around the node.
|
|
1401
|
+
* They are automatically drawn in the normal way, and you will usually just want to ignore this, but they can also be used as a way to provide context information to the node view without adding it to the document itself.
|
|
1402
|
+
*/
|
|
1403
|
+
decorations: Parameters<NodeViewConstructor>[3];
|
|
1404
|
+
/**
|
|
1405
|
+
* holds the decorations for the node's content. You can safely ignore this if your view has no content or a contentDOM property, since the editor will draw the decorations on the content.
|
|
1406
|
+
* But if you, for example, want to create a nested editor with the content, it may make sense to provide it with the inner decorations.
|
|
1407
|
+
*/
|
|
1408
|
+
innerDecorations: Parameters<NodeViewConstructor>[4];
|
|
1409
|
+
/**
|
|
1410
|
+
* The editor instance.
|
|
1411
|
+
*/
|
|
1412
|
+
editor: SlideEditor;
|
|
1413
|
+
/**
|
|
1414
|
+
* The extension that is responsible for the node.
|
|
1415
|
+
*/
|
|
1416
|
+
extension: Node;
|
|
1417
|
+
/**
|
|
1418
|
+
* The HTML attributes that should be added to the node's DOM element.
|
|
1419
|
+
*/
|
|
1420
|
+
HTMLAttributes: Record<string, any>;
|
|
1421
|
+
}
|
|
1422
|
+
type NodeViewRenderer = (props: NodeViewRendererProps) => NodeView$1;
|
|
1423
|
+
interface MarkViewProps extends MarkViewRendererProps {
|
|
1424
|
+
}
|
|
1425
|
+
interface MarkViewRendererProps {
|
|
1426
|
+
/**
|
|
1427
|
+
* The node that is being rendered.
|
|
1428
|
+
*/
|
|
1429
|
+
mark: Parameters<MarkViewConstructor>[0];
|
|
1430
|
+
/**
|
|
1431
|
+
* The editor's view.
|
|
1432
|
+
*/
|
|
1433
|
+
view: Parameters<MarkViewConstructor>[1];
|
|
1434
|
+
/**
|
|
1435
|
+
* indicates whether the mark's content is inline
|
|
1436
|
+
*/
|
|
1437
|
+
inline: Parameters<MarkViewConstructor>[2];
|
|
1438
|
+
/**
|
|
1439
|
+
* The editor instance.
|
|
1440
|
+
*/
|
|
1441
|
+
editor: SlideEditor;
|
|
1442
|
+
/**
|
|
1443
|
+
* The extension that is responsible for the mark.
|
|
1444
|
+
*/
|
|
1445
|
+
extension: Mark;
|
|
1446
|
+
/**
|
|
1447
|
+
* The HTML attributes that should be added to the mark's DOM element.
|
|
1448
|
+
*/
|
|
1449
|
+
HTMLAttributes: Record<string, any>;
|
|
1450
|
+
updateAttributes: (attrs: Record<string, any>) => void;
|
|
1451
|
+
}
|
|
1452
|
+
type MarkViewRenderer<Props = MarkViewRendererProps> = (props: Props) => MarkView$1;
|
|
1453
|
+
interface MarkViewRendererOptions {
|
|
1454
|
+
ignoreMutation: ((props: {
|
|
1455
|
+
mutation: ViewMutationRecord;
|
|
1456
|
+
}) => boolean) | null;
|
|
1457
|
+
}
|
|
1458
|
+
type AnyCommands = Record<string, (...args: any[]) => Command>;
|
|
1459
|
+
type UnionCommands<T = Command> = UnionToIntersection<ValuesOf<Pick<Commands<T>, KeysWithTypeOf<Commands<T>, object>>>>;
|
|
1460
|
+
type RawCommands = {
|
|
1461
|
+
[Item in keyof UnionCommands]: UnionCommands<Command>[Item];
|
|
1462
|
+
};
|
|
1463
|
+
type SingleCommands = {
|
|
1464
|
+
[Item in keyof UnionCommands]: UnionCommands<boolean>[Item];
|
|
1465
|
+
};
|
|
1466
|
+
type ChainedCommands = {
|
|
1467
|
+
[Item in keyof UnionCommands]: UnionCommands<ChainedCommands>[Item];
|
|
1468
|
+
} & {
|
|
1469
|
+
run: () => boolean;
|
|
1470
|
+
};
|
|
1471
|
+
type CanCommands = SingleCommands & {
|
|
1472
|
+
chain: () => ChainedCommands;
|
|
1473
|
+
};
|
|
1474
|
+
type FocusPosition = "start" | "end" | "all" | number | boolean | null;
|
|
1475
|
+
type Range = {
|
|
1476
|
+
from: number;
|
|
1477
|
+
to: number;
|
|
1478
|
+
};
|
|
1479
|
+
type NodeRange = {
|
|
1480
|
+
node: Node$1;
|
|
1481
|
+
from: number;
|
|
1482
|
+
to: number;
|
|
1483
|
+
};
|
|
1484
|
+
type MarkRange = {
|
|
1485
|
+
mark: Mark$1;
|
|
1486
|
+
from: number;
|
|
1487
|
+
to: number;
|
|
1488
|
+
};
|
|
1489
|
+
type Predicate = (node: Node$1) => boolean;
|
|
1490
|
+
type NodeWithPos = {
|
|
1491
|
+
node: Node$1;
|
|
1492
|
+
pos: number;
|
|
1493
|
+
};
|
|
1494
|
+
type TextSerializer = (props: {
|
|
1495
|
+
node: Node$1;
|
|
1496
|
+
pos: number;
|
|
1497
|
+
parent: Node$1;
|
|
1498
|
+
index: number;
|
|
1499
|
+
range: Range;
|
|
1500
|
+
}) => string;
|
|
1501
|
+
type ExtendedRegExpMatchArray = RegExpMatchArray & {
|
|
1502
|
+
data?: Record<string, any>;
|
|
1503
|
+
};
|
|
1504
|
+
type Dispatch = ((args?: any) => any) | undefined;
|
|
1505
|
+
/** Markdown related types */
|
|
1506
|
+
type MarkdownToken = {
|
|
1507
|
+
type?: string;
|
|
1508
|
+
raw?: string;
|
|
1509
|
+
text?: string;
|
|
1510
|
+
tokens?: MarkdownToken[];
|
|
1511
|
+
depth?: number;
|
|
1512
|
+
items?: MarkdownToken[];
|
|
1513
|
+
[key: string]: any;
|
|
1514
|
+
};
|
|
1515
|
+
type MarkdownHelpers = {
|
|
1516
|
+
parseInline: (tokens: MarkdownToken[]) => any[];
|
|
1517
|
+
/**
|
|
1518
|
+
* Render children. The second argument may be a legacy separator string
|
|
1519
|
+
* or a RenderContext (preferred).
|
|
1520
|
+
*/
|
|
1521
|
+
renderChildren: (node: Node[] | Node, ctxOrSeparator?: RenderContext | string) => string;
|
|
1522
|
+
text: (token: MarkdownToken) => any;
|
|
1523
|
+
};
|
|
1524
|
+
/**
|
|
1525
|
+
* Helpers specifically for parsing markdown tokens into blockslides JSON.
|
|
1526
|
+
* These are provided to extension parse handlers.
|
|
1527
|
+
*/
|
|
1528
|
+
type MarkdownParseHelpers = {
|
|
1529
|
+
/** Parse an array of inline tokens into text nodes with marks */
|
|
1530
|
+
parseInline: (tokens: MarkdownToken[]) => JSONContent[];
|
|
1531
|
+
/** Parse an array of block-level tokens */
|
|
1532
|
+
parseChildren: (tokens: MarkdownToken[]) => JSONContent[];
|
|
1533
|
+
/** Create a text node with optional marks */
|
|
1534
|
+
createTextNode: (text: string, marks?: Array<{
|
|
1535
|
+
type: string;
|
|
1536
|
+
attrs?: any;
|
|
1537
|
+
}>) => JSONContent;
|
|
1538
|
+
/** Create any node type with attributes and content */
|
|
1539
|
+
createNode: (type: string, attrs?: any, content?: JSONContent[]) => JSONContent;
|
|
1540
|
+
/** Apply a mark to content (used for inline marks like bold, italic) */
|
|
1541
|
+
applyMark: (markType: string, content: JSONContent[], attrs?: any) => {
|
|
1542
|
+
mark: string;
|
|
1543
|
+
content: JSONContent[];
|
|
1544
|
+
attrs?: any;
|
|
1545
|
+
};
|
|
1546
|
+
};
|
|
1547
|
+
/**
|
|
1548
|
+
* Full runtime helpers object provided by MarkdownManager to handlers.
|
|
1549
|
+
* This includes the small author-facing helpers plus internal helpers
|
|
1550
|
+
* that can be useful for advanced handlers.
|
|
1551
|
+
*/
|
|
1552
|
+
type FullMarkdownHelpers = MarkdownHelpers & {
|
|
1553
|
+
parseChildren: (tokens: MarkdownToken[]) => any[];
|
|
1554
|
+
getExtension: (name: string) => any;
|
|
1555
|
+
createNode: (type: string, attrs?: any, content?: any[]) => any;
|
|
1556
|
+
/** Current render context when calling renderers; undefined during parse. */
|
|
1557
|
+
currentContext?: RenderContext;
|
|
1558
|
+
/** Indent a multi-line string according to the provided RenderContext. */
|
|
1559
|
+
indent: (text: string, ctx?: RenderContext) => string;
|
|
1560
|
+
/** Return the indent string for a given level (e.g. ' ' or '\t'). */
|
|
1561
|
+
getIndentString: (level?: number) => string;
|
|
1562
|
+
};
|
|
1563
|
+
|
|
1564
|
+
/**
|
|
1565
|
+
* Return shape for parser-level `parse` handlers.
|
|
1566
|
+
* - a single JSON-like node
|
|
1567
|
+
* - an array of JSON-like nodes
|
|
1568
|
+
* - or a `{ mark: string, content: JSONLike[] }` shape to apply a mark
|
|
1569
|
+
*/
|
|
1570
|
+
type MarkdownParseResult = JSONContent | JSONContent[] | {
|
|
1571
|
+
mark: string;
|
|
1572
|
+
content: JSONContent[];
|
|
1573
|
+
attrs?: any;
|
|
1574
|
+
};
|
|
1575
|
+
type RenderContext = {
|
|
1576
|
+
index: number;
|
|
1577
|
+
level: number;
|
|
1578
|
+
meta?: Record<string, any>;
|
|
1579
|
+
parentType?: string | null;
|
|
1580
|
+
};
|
|
1581
|
+
/** Extension contract for markdown parsing/serialization. */
|
|
1582
|
+
interface MarkdownExtensionSpec {
|
|
1583
|
+
/** Token name used for parsing (e.g., 'codespan', 'code', 'strong') */
|
|
1584
|
+
tokenName?: string;
|
|
1585
|
+
/** Node/mark name used for rendering (typically the extension name) */
|
|
1586
|
+
nodeName?: string;
|
|
1587
|
+
parseMarkdown?: (token: MarkdownToken, helpers: MarkdownParseHelpers) => MarkdownParseResult;
|
|
1588
|
+
renderMarkdown?: (node: any, helpers: MarkdownRendererHelpers, ctx: RenderContext) => string;
|
|
1589
|
+
isIndenting?: boolean;
|
|
1590
|
+
/** Custom tokenizer for marked.js to handle non-standard markdown syntax */
|
|
1591
|
+
tokenizer?: MarkdownTokenizer;
|
|
1592
|
+
}
|
|
1593
|
+
/**
|
|
1594
|
+
* Configuration object passed to custom marked.js tokenizers
|
|
1595
|
+
*/
|
|
1596
|
+
type MarkdownLexerConfiguration = {
|
|
1597
|
+
/**
|
|
1598
|
+
* Can be used to transform source text into inline tokens - useful while tokenizing child tokens.
|
|
1599
|
+
* @param src
|
|
1600
|
+
* @returns Array of inline tokens
|
|
1601
|
+
*/
|
|
1602
|
+
inlineTokens: (src: string) => MarkdownToken[];
|
|
1603
|
+
/**
|
|
1604
|
+
* Can be used to transform source text into block-level tokens - useful while tokenizing child tokens.
|
|
1605
|
+
* @param src
|
|
1606
|
+
* @returns Array of block-level tokens
|
|
1607
|
+
*/
|
|
1608
|
+
blockTokens: (src: string) => MarkdownToken[];
|
|
1609
|
+
};
|
|
1610
|
+
/** Custom tokenizer function for marked.js extensions */
|
|
1611
|
+
type MarkdownTokenizer = {
|
|
1612
|
+
/** Token name this tokenizer creates */
|
|
1613
|
+
name: string;
|
|
1614
|
+
/** Priority level for tokenizer ordering (higher = earlier) */
|
|
1615
|
+
level?: "block" | "inline";
|
|
1616
|
+
/** A string to look for or a function that returns the start index of the token in the source string */
|
|
1617
|
+
start?: string | ((src: string) => number);
|
|
1618
|
+
/** Function that attempts to parse custom syntax from start of text */
|
|
1619
|
+
tokenize: (src: string, tokens: MarkdownToken[], lexer: MarkdownLexerConfiguration) => MarkdownToken | undefined | void;
|
|
1620
|
+
};
|
|
1621
|
+
type MarkdownRendererHelpers = {
|
|
1622
|
+
/**
|
|
1623
|
+
* Render children nodes to a markdown string, optionally separated by a string.
|
|
1624
|
+
* @param nodes The node or array of nodes to render
|
|
1625
|
+
* @param separator An optional separator string (legacy) or RenderContext
|
|
1626
|
+
* @returns The rendered markdown string
|
|
1627
|
+
*/
|
|
1628
|
+
renderChildren: (nodes: JSONContent | JSONContent[], separator?: string) => string;
|
|
1629
|
+
/**
|
|
1630
|
+
* Render a text token to a markdown string
|
|
1631
|
+
* @param prefix The prefix to add before the content
|
|
1632
|
+
* @param content The content to wrap
|
|
1633
|
+
* @returns The wrapped content
|
|
1634
|
+
*/
|
|
1635
|
+
wrapInBlock: (prefix: string, content: string) => string;
|
|
1636
|
+
/**
|
|
1637
|
+
* Indent a markdown string according to the provided RenderContext
|
|
1638
|
+
* @param content The content to indent
|
|
1639
|
+
* @returns The indented content
|
|
1640
|
+
*/
|
|
1641
|
+
indent: (content: string) => string;
|
|
1642
|
+
};
|
|
1643
|
+
|
|
1644
|
+
/**
|
|
1645
|
+
* Create a new Prosemirror document node from content.
|
|
1646
|
+
* @param content The JSON or HTML content to create the document from
|
|
1647
|
+
* @param schema The Prosemirror schema to use for the document
|
|
1648
|
+
* @param parseOptions Options for the parser
|
|
1649
|
+
* @returns The created Prosemirror document node
|
|
1650
|
+
*/
|
|
1651
|
+
declare function createDocument(content: Content | Node$1 | Fragment$1, schema: Schema, parseOptions?: ParseOptions, options?: {
|
|
1652
|
+
errorOnInvalidContent?: boolean;
|
|
1653
|
+
}): Node$1;
|
|
1654
|
+
|
|
1655
|
+
type CreateNodeFromContentOptions = {
|
|
1656
|
+
slice?: boolean;
|
|
1657
|
+
parseOptions?: ParseOptions;
|
|
1658
|
+
errorOnInvalidContent?: boolean;
|
|
1659
|
+
};
|
|
1660
|
+
/**
|
|
1661
|
+
* Takes a JSON or HTML content and creates a Prosemirror node or fragment from it.
|
|
1662
|
+
* @param content The JSON or HTML content to create the node from
|
|
1663
|
+
* @param schema The Prosemirror schema to use for the node
|
|
1664
|
+
* @param options Options for the parser
|
|
1665
|
+
* @returns The created Prosemirror node or fragment
|
|
1666
|
+
*/
|
|
1667
|
+
declare function createNodeFromContent(content: Content | Node$1 | Fragment$1, schema: Schema, options?: CreateNodeFromContentOptions): Node$1 | Fragment$1;
|
|
1668
|
+
|
|
1669
|
+
/**
|
|
1670
|
+
* Gets the default block type at a given match
|
|
1671
|
+
* @param match The content match to get the default block type from
|
|
1672
|
+
* @returns The default block type or null
|
|
1673
|
+
*/
|
|
1674
|
+
declare function defaultBlockAt(match: ContentMatch): NodeType$1 | null;
|
|
1675
|
+
|
|
1676
|
+
/**
|
|
1677
|
+
* Find children inside a Prosemirror node that match a predicate.
|
|
1678
|
+
* @param node The Prosemirror node to search in
|
|
1679
|
+
* @param predicate The predicate to match
|
|
1680
|
+
* @returns An array of nodes with their positions
|
|
1681
|
+
*/
|
|
1682
|
+
declare function findChildren(node: Node$1, predicate: Predicate): NodeWithPos[];
|
|
1683
|
+
|
|
1684
|
+
/**
|
|
1685
|
+
* Same as `findChildren` but searches only within a `range`.
|
|
1686
|
+
* @param node The Prosemirror node to search in
|
|
1687
|
+
* @param range The range to search in
|
|
1688
|
+
* @param predicate The predicate to match
|
|
1689
|
+
* @returns An array of nodes with their positions
|
|
1690
|
+
*/
|
|
1691
|
+
declare function findChildrenInRange(node: Node$1, range: Range, predicate: Predicate): NodeWithPos[];
|
|
1692
|
+
|
|
1693
|
+
/**
|
|
1694
|
+
* Finds the closest parent node to a resolved position that matches a predicate.
|
|
1695
|
+
* @param $pos The resolved position to search from
|
|
1696
|
+
* @param predicate The predicate to match
|
|
1697
|
+
* @returns The closest parent node to the resolved position that matches the predicate
|
|
1698
|
+
* @example ```js
|
|
1699
|
+
* findParentNodeClosestToPos($from, node => node.type.name === 'paragraph')
|
|
1700
|
+
* ```
|
|
1701
|
+
*/
|
|
1702
|
+
declare function findParentNodeClosestToPos($pos: ResolvedPos, predicate: Predicate): {
|
|
1703
|
+
pos: number;
|
|
1704
|
+
start: number;
|
|
1705
|
+
depth: number;
|
|
1706
|
+
node: Node$1;
|
|
1707
|
+
} | undefined;
|
|
1708
|
+
|
|
1709
|
+
/**
|
|
1710
|
+
* Finds the closest parent node to the current selection that matches a predicate.
|
|
1711
|
+
* @param predicate The predicate to match
|
|
1712
|
+
* @returns A command that finds the closest parent node to the current selection that matches the predicate
|
|
1713
|
+
* @example ```js
|
|
1714
|
+
* findParentNode(node => node.type.name === 'paragraph')
|
|
1715
|
+
* ```
|
|
1716
|
+
*/
|
|
1717
|
+
declare function findParentNode(predicate: Predicate): (selection: Selection) => ReturnType<typeof findParentNodeClosestToPos>;
|
|
1718
|
+
|
|
1719
|
+
/**
|
|
1720
|
+
* Create a flattened array of extensions by traversing the `addExtensions` field.
|
|
1721
|
+
* @param extensions An array of Tiptap extensions
|
|
1722
|
+
* @returns A flattened array of Tiptap extensions
|
|
1723
|
+
*/
|
|
1724
|
+
declare function flattenExtensions(extensions: Extensions): Extensions;
|
|
1725
|
+
|
|
1726
|
+
/**
|
|
1727
|
+
* Generate HTML from a JSONContent
|
|
1728
|
+
* @param doc The JSONContent to generate HTML from
|
|
1729
|
+
* @param extensions The extensions to use for the schema
|
|
1730
|
+
* @returns The generated HTML
|
|
1731
|
+
*/
|
|
1732
|
+
declare function generateHTML(doc: JSONContent, extensions: Extensions): string;
|
|
1733
|
+
|
|
1734
|
+
/**
|
|
1735
|
+
* Generate JSONContent from HTML
|
|
1736
|
+
* @param html The HTML to generate JSONContent from
|
|
1737
|
+
* @param extensions The extensions to use for the schema
|
|
1738
|
+
* @returns The generated JSONContent
|
|
1739
|
+
*/
|
|
1740
|
+
declare function generateJSON(html: string, extensions: Extensions): Record<string, any>;
|
|
1741
|
+
|
|
1742
|
+
/**
|
|
1743
|
+
* Generate raw text from a JSONContent
|
|
1744
|
+
* @param doc The JSONContent to generate text from
|
|
1745
|
+
* @param extensions The extensions to use for the schema
|
|
1746
|
+
* @param options Options for the text generation f.e. blockSeparator or textSerializers
|
|
1747
|
+
* @returns The generated text
|
|
1748
|
+
*/
|
|
1749
|
+
declare function generateText(doc: JSONContent, extensions: Extensions, options?: {
|
|
1750
|
+
blockSeparator?: string;
|
|
1751
|
+
textSerializers?: Record<string, TextSerializer>;
|
|
1752
|
+
}): string;
|
|
1753
|
+
|
|
1754
|
+
/**
|
|
1755
|
+
* Get node or mark attributes by type or name on the current editor state
|
|
1756
|
+
* @param state The current editor state
|
|
1757
|
+
* @param typeOrName The node or mark type or name
|
|
1758
|
+
* @returns The attributes of the node or mark or an empty object
|
|
1759
|
+
*/
|
|
1760
|
+
declare function getAttributes(state: EditorState, typeOrName: string | NodeType$1 | MarkType$1): Record<string, any>;
|
|
1761
|
+
|
|
1762
|
+
/**
|
|
1763
|
+
* Get a list of all extension attributes defined in `addAttribute` and `addGlobalAttribute`.
|
|
1764
|
+
* @param extensions List of extensions
|
|
1765
|
+
*/
|
|
1766
|
+
declare function getAttributesFromExtensions(extensions: Extensions): ExtensionAttribute[];
|
|
1767
|
+
|
|
1768
|
+
type ChangedRange = {
|
|
1769
|
+
oldRange: Range;
|
|
1770
|
+
newRange: Range;
|
|
1771
|
+
};
|
|
1772
|
+
/**
|
|
1773
|
+
* Returns a list of changed ranges
|
|
1774
|
+
* based on the first and last state of all steps.
|
|
1775
|
+
*/
|
|
1776
|
+
declare function getChangedRanges(transform: Transform): ChangedRange[];
|
|
1777
|
+
|
|
1778
|
+
interface DebugJSONContent extends JSONContent {
|
|
1779
|
+
from: number;
|
|
1780
|
+
to: number;
|
|
1781
|
+
}
|
|
1782
|
+
declare function getDebugJSON(node: Node$1, startOffset?: number): DebugJSONContent;
|
|
1783
|
+
|
|
1784
|
+
interface ExtensionConfig<Options = any, Storage = any> extends ExtendableConfig<Options, Storage, ExtensionConfig<Options, Storage>, null> {
|
|
1785
|
+
}
|
|
1786
|
+
declare class Extension<Options = any, Storage = any> extends Extendable<Options, Storage, ExtensionConfig<Options, Storage>> {
|
|
1787
|
+
type: string;
|
|
1788
|
+
/**
|
|
1789
|
+
* Create a new Extension instance
|
|
1790
|
+
* @param config - Extension configuration object or a function that returns a configuration object
|
|
1791
|
+
*/
|
|
1792
|
+
static create<O = any, S = any>(config?: Partial<ExtensionConfig<O, S>> | (() => Partial<ExtensionConfig<O, S>>)): Extension<O, S>;
|
|
1793
|
+
configure(options?: Partial<Options>): Extension<Options, Storage>;
|
|
1794
|
+
extend<ExtendedOptions = Options, ExtendedStorage = Storage, ExtendedConfig = ExtensionConfig<ExtendedOptions, ExtendedStorage>>(extendedConfig?: (() => Partial<ExtendedConfig>) | (Partial<ExtendedConfig> & ThisType<{
|
|
1795
|
+
name: string;
|
|
1796
|
+
options: ExtendedOptions;
|
|
1797
|
+
storage: ExtendedStorage;
|
|
1798
|
+
editor: SlideEditor;
|
|
1799
|
+
type: null;
|
|
1800
|
+
}>)): Extension<ExtendedOptions, ExtendedStorage>;
|
|
1801
|
+
}
|
|
1802
|
+
|
|
1803
|
+
/**
|
|
1804
|
+
* Returns a field from an extension
|
|
1805
|
+
* @param extension The BlockSlides extension
|
|
1806
|
+
* @param field The field, for example `renderHTML` or `priority`
|
|
1807
|
+
* @param context The context object that should be passed as `this` into the function
|
|
1808
|
+
* @returns The field value
|
|
1809
|
+
*/
|
|
1810
|
+
declare function getExtensionField<T = any, E extends AnyExtension = any>(extension: E, field: keyof ExtensionConfig | keyof MarkConfig | keyof NodeConfig, context?: Omit<MaybeThisParameterType<T>, 'parent'>): RemoveThis<T>;
|
|
1811
|
+
|
|
1812
|
+
declare function getHTMLFromFragment(fragment: Fragment$1, schema: Schema): string;
|
|
1813
|
+
|
|
1814
|
+
declare function getMarkAttributes(state: EditorState, typeOrName: string | MarkType$1): Record<string, any>;
|
|
1815
|
+
|
|
1816
|
+
/**
|
|
1817
|
+
* Get the range of a mark at a resolved position.
|
|
1818
|
+
*/
|
|
1819
|
+
declare function getMarkRange(
|
|
1820
|
+
/**
|
|
1821
|
+
* The position to get the mark range for.
|
|
1822
|
+
*/
|
|
1823
|
+
$pos: ResolvedPos,
|
|
1824
|
+
/**
|
|
1825
|
+
* The mark type to get the range for.
|
|
1826
|
+
*/
|
|
1827
|
+
type: MarkType$1,
|
|
1828
|
+
/**
|
|
1829
|
+
* The attributes to match against.
|
|
1830
|
+
* If not provided, only the first mark at the position will be matched.
|
|
1831
|
+
*/
|
|
1832
|
+
attributes?: Record<string, any>): Range | void;
|
|
1833
|
+
|
|
1834
|
+
declare function getMarksBetween(from: number, to: number, doc: Node$1): MarkRange[];
|
|
1835
|
+
|
|
1836
|
+
declare function getMarkType(nameOrType: string | MarkType$1, schema: Schema): MarkType$1;
|
|
1837
|
+
|
|
1838
|
+
/**
|
|
1839
|
+
* Finds the first node of a given type or name in the current selection.
|
|
1840
|
+
* @param state The editor state.
|
|
1841
|
+
* @param typeOrName The node type or name.
|
|
1842
|
+
* @param pos The position to start searching from.
|
|
1843
|
+
* @param maxDepth The maximum depth to search.
|
|
1844
|
+
* @returns The node and the depth as an array.
|
|
1845
|
+
*/
|
|
1846
|
+
declare const getNodeAtPosition: (state: EditorState, typeOrName: string | NodeType$1, pos: number, maxDepth?: number) => [Node$1 | null, number];
|
|
1847
|
+
|
|
1848
|
+
declare function getNodeAttributes(state: EditorState, typeOrName: string | NodeType$1): Record<string, any>;
|
|
1849
|
+
|
|
1850
|
+
declare function getNodeType(nameOrType: string | NodeType$1, schema: Schema): NodeType$1;
|
|
1851
|
+
|
|
1852
|
+
declare function getRenderedAttributes(nodeOrMark: Node$1 | Mark$1, extensionAttributes: ExtensionAttribute[]): Record<string, any>;
|
|
1853
|
+
|
|
1854
|
+
declare function getSchema(extensions: Extensions, editor?: SlideEditor): Schema;
|
|
1855
|
+
|
|
1856
|
+
/**
|
|
1857
|
+
* Creates a new Prosemirror schema based on the given extensions.
|
|
1858
|
+
* @param extensions An array of Tiptap extensions
|
|
1859
|
+
* @param editor The editor instance
|
|
1860
|
+
* @returns A Prosemirror schema
|
|
1861
|
+
*/
|
|
1862
|
+
declare function getSchemaByResolvedExtensions(extensions: Extensions, editor?: SlideEditor): Schema;
|
|
1863
|
+
|
|
1864
|
+
/**
|
|
1865
|
+
* Tries to get a node or mark type by its name.
|
|
1866
|
+
* @param name The name of the node or mark type
|
|
1867
|
+
* @param schema The Prosemiror schema to search in
|
|
1868
|
+
* @returns The node or mark type, or null if it doesn't exist
|
|
1869
|
+
*/
|
|
1870
|
+
declare function getSchemaTypeByName(name: string, schema: Schema): NodeType$1 | MarkType$1 | null;
|
|
1871
|
+
|
|
1872
|
+
/**
|
|
1873
|
+
* Get the type of a schema item by its name.
|
|
1874
|
+
* @param name The name of the schema item
|
|
1875
|
+
* @param schema The Prosemiror schema to search in
|
|
1876
|
+
* @returns The type of the schema item (`node` or `mark`), or null if it doesn't exist
|
|
1877
|
+
*/
|
|
1878
|
+
declare function getSchemaTypeNameByName(name: string, schema: Schema): 'node' | 'mark' | null;
|
|
1879
|
+
|
|
1880
|
+
/**
|
|
1881
|
+
* Return attributes of an extension that should be splitted by keepOnSplit flag
|
|
1882
|
+
* @param extensionAttributes Array of extension attributes
|
|
1883
|
+
* @param typeName The type of the extension
|
|
1884
|
+
* @param attributes The attributes of the extension
|
|
1885
|
+
* @returns The splitted attributes
|
|
1886
|
+
*/
|
|
1887
|
+
declare function getSplittedAttributes(extensionAttributes: ExtensionAttribute[], typeName: string, attributes: Record<string, any>): Record<string, any>;
|
|
1888
|
+
|
|
1889
|
+
/**
|
|
1890
|
+
* Gets the text of a Prosemirror node
|
|
1891
|
+
* @param node The Prosemirror node
|
|
1892
|
+
* @param options Options for the text serializer & block separator
|
|
1893
|
+
* @returns The text of the node
|
|
1894
|
+
* @example ```js
|
|
1895
|
+
* const text = getText(node, { blockSeparator: '\n' })
|
|
1896
|
+
* ```
|
|
1897
|
+
*/
|
|
1898
|
+
declare function getText(node: Node$1, options?: {
|
|
1899
|
+
blockSeparator?: string;
|
|
1900
|
+
textSerializers?: Record<string, TextSerializer>;
|
|
1901
|
+
}): string;
|
|
1902
|
+
|
|
1903
|
+
/**
|
|
1904
|
+
* Gets the text between two positions in a Prosemirror node
|
|
1905
|
+
* and serializes it using the given text serializers and block separator (see getText)
|
|
1906
|
+
* @param startNode The Prosemirror node to start from
|
|
1907
|
+
* @param range The range of the text to get
|
|
1908
|
+
* @param options Options for the text serializer & block separator
|
|
1909
|
+
* @returns The text between the two positions
|
|
1910
|
+
*/
|
|
1911
|
+
declare function getTextBetween(startNode: Node$1, range: Range, options?: {
|
|
1912
|
+
blockSeparator?: string;
|
|
1913
|
+
textSerializers?: Record<string, TextSerializer>;
|
|
1914
|
+
}): string;
|
|
1915
|
+
|
|
1916
|
+
/**
|
|
1917
|
+
* Returns the text content of a resolved prosemirror position
|
|
1918
|
+
* @param $from The resolved position to get the text content from
|
|
1919
|
+
* @param maxMatch The maximum number of characters to match
|
|
1920
|
+
* @returns The text content
|
|
1921
|
+
*/
|
|
1922
|
+
declare const getTextContentFromNodes: ($from: ResolvedPos, maxMatch?: number) => string;
|
|
1923
|
+
|
|
1924
|
+
/**
|
|
1925
|
+
* Find text serializers `toText` in a Prosemirror schema
|
|
1926
|
+
* @param schema The Prosemirror schema to search in
|
|
1927
|
+
* @returns A record of text serializers by node name
|
|
1928
|
+
*/
|
|
1929
|
+
declare function getTextSerializersFromSchema(schema: Schema): Record<string, TextSerializer>;
|
|
1930
|
+
|
|
1931
|
+
/**
|
|
1932
|
+
* This function merges extension attributes into parserule attributes (`attrs` or `getAttrs`).
|
|
1933
|
+
* Cancels when `getAttrs` returned `false`.
|
|
1934
|
+
* @param parseRule ProseMirror ParseRule
|
|
1935
|
+
* @param extensionAttributes List of attributes to inject
|
|
1936
|
+
*/
|
|
1937
|
+
declare function injectExtensionAttributesToParseRule(parseRule: ParseRule, extensionAttributes: ExtensionAttribute[]): ParseRule;
|
|
1938
|
+
|
|
1939
|
+
declare function isActive(state: EditorState, name: string | null, attributes?: Record<string, any>): boolean;
|
|
1940
|
+
|
|
1941
|
+
declare const isAtEndOfNode: (state: EditorState, nodeType?: string) => boolean;
|
|
1942
|
+
|
|
1943
|
+
declare const isAtStartOfNode: (state: EditorState) => boolean;
|
|
1944
|
+
|
|
1945
|
+
declare function isExtensionRulesEnabled(extension: AnyExtension, enabled: EnableRules): boolean;
|
|
1946
|
+
|
|
1947
|
+
declare function isList(name: string, extensions: Extensions): boolean;
|
|
1948
|
+
|
|
1949
|
+
declare function isMarkActive(state: EditorState, typeOrName: MarkType$1 | string | null, attributes?: Record<string, any>): boolean;
|
|
1950
|
+
|
|
1951
|
+
declare function isNodeActive(state: EditorState, typeOrName: NodeType$1 | string | null, attributes?: Record<string, any>): boolean;
|
|
1952
|
+
|
|
1953
|
+
/**
|
|
1954
|
+
* Returns true if the given prosemirror node is empty.
|
|
1955
|
+
*/
|
|
1956
|
+
declare function isNodeEmpty(node: Node$1, { checkChildren, ignoreWhitespace, }?: {
|
|
1957
|
+
/**
|
|
1958
|
+
* When true (default), it will also check if all children are empty.
|
|
1959
|
+
*/
|
|
1960
|
+
checkChildren?: boolean;
|
|
1961
|
+
/**
|
|
1962
|
+
* When true, it will ignore whitespace when checking for emptiness.
|
|
1963
|
+
*/
|
|
1964
|
+
ignoreWhitespace?: boolean;
|
|
1965
|
+
}): boolean;
|
|
1966
|
+
|
|
1967
|
+
declare function isNodeSelection(value: unknown): value is NodeSelection;
|
|
1968
|
+
|
|
1969
|
+
declare function isTextSelection(value: unknown): value is TextSelection;
|
|
1970
|
+
|
|
1971
|
+
declare function posToDOMRect(view: EditorView, from: number, to: number): DOMRect;
|
|
1972
|
+
|
|
1973
|
+
/**
|
|
1974
|
+
* Returns a flattened and sorted extension list while
|
|
1975
|
+
* also checking for duplicated extensions and warns the user.
|
|
1976
|
+
* @param extensions An array of BlockSlides extensions
|
|
1977
|
+
* @returns An flattened and sorted array of BlockSlides extensions
|
|
1978
|
+
*/
|
|
1979
|
+
declare function resolveExtensions(extensions: Extensions): Extensions;
|
|
1980
|
+
|
|
1981
|
+
declare function resolveFocusPosition(doc: Node$1, position?: FocusPosition): Selection | null;
|
|
1982
|
+
|
|
1983
|
+
type RewriteUnknownContentOptions = {
|
|
1984
|
+
/**
|
|
1985
|
+
* If true, unknown nodes will be treated as paragraphs
|
|
1986
|
+
* @default true
|
|
1987
|
+
*/
|
|
1988
|
+
fallbackToParagraph?: boolean;
|
|
1989
|
+
};
|
|
1990
|
+
/**
|
|
1991
|
+
* Rewrite unknown nodes and marks within JSON content
|
|
1992
|
+
* Allowing for user within the editor
|
|
1993
|
+
*/
|
|
1994
|
+
declare function rewriteUnknownContent(
|
|
1995
|
+
/**
|
|
1996
|
+
* The JSON content to clean of unknown nodes and marks
|
|
1997
|
+
*/
|
|
1998
|
+
json: JSONContent,
|
|
1999
|
+
/**
|
|
2000
|
+
* The schema to use for validation
|
|
2001
|
+
*/
|
|
2002
|
+
schema: Schema,
|
|
2003
|
+
/**
|
|
2004
|
+
* Options for the cleaning process
|
|
2005
|
+
*/
|
|
2006
|
+
options?: RewriteUnknownContentOptions): {
|
|
2007
|
+
/**
|
|
2008
|
+
* The cleaned JSON content
|
|
2009
|
+
*/
|
|
2010
|
+
json: JSONContent | null;
|
|
2011
|
+
/**
|
|
2012
|
+
* The array of nodes and marks that were rewritten
|
|
2013
|
+
*/
|
|
2014
|
+
rewrittenContent: {
|
|
2015
|
+
/**
|
|
2016
|
+
* The original JSON content that was rewritten
|
|
2017
|
+
*/
|
|
2018
|
+
original: JSONContent;
|
|
2019
|
+
/**
|
|
2020
|
+
* The name of the node or mark that was unsupported
|
|
2021
|
+
*/
|
|
2022
|
+
unsupported: string;
|
|
2023
|
+
}[];
|
|
2024
|
+
};
|
|
2025
|
+
|
|
2026
|
+
declare function selectionToInsertionEnd(tr: Transaction, startLen: number, bias: number): void;
|
|
2027
|
+
|
|
2028
|
+
/**
|
|
2029
|
+
* Sort extensions by priority.
|
|
2030
|
+
* @param extensions An array of Tiptap extensions
|
|
2031
|
+
* @returns A sorted array of Tiptap extensions by priority
|
|
2032
|
+
*/
|
|
2033
|
+
declare function sortExtensions(extensions: Extensions): Extensions;
|
|
2034
|
+
|
|
2035
|
+
declare function splitExtensions(extensions: Extensions): {
|
|
2036
|
+
baseExtensions: Extension<any, any>[];
|
|
2037
|
+
nodeExtensions: Node<any, any>[];
|
|
2038
|
+
markExtensions: Mark<any, any>[];
|
|
2039
|
+
};
|
|
2040
|
+
|
|
2041
|
+
declare class ExtensionManager {
|
|
2042
|
+
editor: SlideEditor;
|
|
2043
|
+
schema: Schema;
|
|
2044
|
+
/**
|
|
2045
|
+
* A flattened and sorted array of all extensions
|
|
2046
|
+
*/
|
|
2047
|
+
extensions: Extensions;
|
|
2048
|
+
/**
|
|
2049
|
+
* A non-flattened array of base extensions (no sub-extensions)
|
|
2050
|
+
*/
|
|
2051
|
+
baseExtensions: Extensions;
|
|
2052
|
+
splittableMarks: string[];
|
|
2053
|
+
constructor(extensions: Extensions, editor: SlideEditor);
|
|
2054
|
+
static resolve: typeof resolveExtensions;
|
|
2055
|
+
static sort: typeof sortExtensions;
|
|
2056
|
+
static flatten: typeof flattenExtensions;
|
|
2057
|
+
/**
|
|
2058
|
+
* Get all commands from the extensions.
|
|
2059
|
+
* @returns An object with all commands where the key is the command name and the value is the command function
|
|
2060
|
+
*/
|
|
2061
|
+
get commands(): RawCommands;
|
|
2062
|
+
/**
|
|
2063
|
+
* Get all registered Prosemirror plugins from the extensions.
|
|
2064
|
+
* @returns An array of Prosemirror plugins
|
|
2065
|
+
*/
|
|
2066
|
+
get plugins(): Plugin[];
|
|
2067
|
+
/**
|
|
2068
|
+
* Get all attributes from the extensions.
|
|
2069
|
+
* @returns An array of attributes
|
|
2070
|
+
*/
|
|
2071
|
+
get attributes(): ExtensionAttribute[];
|
|
2072
|
+
/**
|
|
2073
|
+
* Get all node views from the extensions.
|
|
2074
|
+
* @returns An object with all node views where the key is the node name and the value is the node view function
|
|
2075
|
+
*/
|
|
2076
|
+
get nodeViews(): Record<string, NodeViewConstructor>;
|
|
2077
|
+
get markViews(): Record<string, MarkViewConstructor>;
|
|
2078
|
+
/**
|
|
2079
|
+
* Go through all extensions, create extension storages & setup marks
|
|
2080
|
+
* & bind editor event listener.
|
|
2081
|
+
*/
|
|
2082
|
+
private setupExtensions;
|
|
2083
|
+
}
|
|
2084
|
+
|
|
2085
|
+
declare class NodePos {
|
|
2086
|
+
private resolvedPos;
|
|
2087
|
+
private isBlock;
|
|
2088
|
+
private editor;
|
|
2089
|
+
private get name();
|
|
2090
|
+
constructor(pos: ResolvedPos, editor: SlideEditor, isBlock?: boolean, node?: Node$1 | null);
|
|
2091
|
+
private currentNode;
|
|
2092
|
+
get node(): Node$1;
|
|
2093
|
+
get element(): HTMLElement;
|
|
2094
|
+
actualDepth: number | null;
|
|
2095
|
+
get depth(): number;
|
|
2096
|
+
get pos(): number;
|
|
2097
|
+
get content(): Fragment$1;
|
|
2098
|
+
set content(content: Content);
|
|
2099
|
+
get attributes(): {
|
|
2100
|
+
[key: string]: any;
|
|
2101
|
+
};
|
|
2102
|
+
get textContent(): string;
|
|
2103
|
+
get size(): number;
|
|
2104
|
+
get from(): number;
|
|
2105
|
+
get range(): Range;
|
|
2106
|
+
get to(): number;
|
|
2107
|
+
get parent(): NodePos | null;
|
|
2108
|
+
get before(): NodePos | null;
|
|
2109
|
+
get after(): NodePos | null;
|
|
2110
|
+
get children(): NodePos[];
|
|
2111
|
+
get firstChild(): NodePos | null;
|
|
2112
|
+
get lastChild(): NodePos | null;
|
|
2113
|
+
closest(selector: string, attributes?: {
|
|
2114
|
+
[key: string]: any;
|
|
2115
|
+
}): NodePos | null;
|
|
2116
|
+
querySelector(selector: string, attributes?: {
|
|
2117
|
+
[key: string]: any;
|
|
2118
|
+
}): NodePos | null;
|
|
2119
|
+
querySelectorAll(selector: string, attributes?: {
|
|
2120
|
+
[key: string]: any;
|
|
2121
|
+
}, firstItemOnly?: boolean): NodePos[];
|
|
2122
|
+
setAttribute(attributes: {
|
|
2123
|
+
[key: string]: any;
|
|
2124
|
+
}): void;
|
|
2125
|
+
}
|
|
2126
|
+
|
|
2127
|
+
type ClipboardTextSerializerOptions = {
|
|
2128
|
+
blockSeparator?: string;
|
|
2129
|
+
};
|
|
2130
|
+
declare const ClipboardTextSerializer: Extension<ClipboardTextSerializerOptions, any>;
|
|
2131
|
+
|
|
2132
|
+
declare module '@blockslides/core' {
|
|
2133
|
+
interface Commands<ReturnType> {
|
|
2134
|
+
blur: {
|
|
2135
|
+
/**
|
|
2136
|
+
* Removes focus from the editor.
|
|
2137
|
+
* @example editor.commands.blur()
|
|
2138
|
+
*/
|
|
2139
|
+
blur: () => ReturnType;
|
|
2140
|
+
};
|
|
2141
|
+
}
|
|
2142
|
+
}
|
|
2143
|
+
declare const blur: RawCommands['blur'];
|
|
2144
|
+
|
|
2145
|
+
declare module '@blockslides/core' {
|
|
2146
|
+
interface Commands<ReturnType> {
|
|
2147
|
+
clearContent: {
|
|
2148
|
+
/**
|
|
2149
|
+
* Clear the whole document.
|
|
2150
|
+
* @example editor.commands.clearContent()
|
|
2151
|
+
*/
|
|
2152
|
+
clearContent: (
|
|
2153
|
+
/**
|
|
2154
|
+
* Whether to emit an update event.
|
|
2155
|
+
* @default true
|
|
2156
|
+
*/
|
|
2157
|
+
emitUpdate?: boolean) => ReturnType;
|
|
2158
|
+
};
|
|
2159
|
+
}
|
|
2160
|
+
}
|
|
2161
|
+
declare const clearContent: RawCommands['clearContent'];
|
|
2162
|
+
|
|
2163
|
+
declare module '@blockslides/core' {
|
|
2164
|
+
interface Commands<ReturnType> {
|
|
2165
|
+
clearNodes: {
|
|
2166
|
+
/**
|
|
2167
|
+
* Normalize nodes to a simple paragraph.
|
|
2168
|
+
* @example editor.commands.clearNodes()
|
|
2169
|
+
*/
|
|
2170
|
+
clearNodes: () => ReturnType;
|
|
2171
|
+
};
|
|
2172
|
+
}
|
|
2173
|
+
}
|
|
2174
|
+
declare const clearNodes: RawCommands['clearNodes'];
|
|
2175
|
+
|
|
2176
|
+
declare module '@blockslides/core' {
|
|
2177
|
+
interface Commands<ReturnType> {
|
|
2178
|
+
command: {
|
|
2179
|
+
/**
|
|
2180
|
+
* Define a command inline.
|
|
2181
|
+
* @param fn The command function.
|
|
2182
|
+
* @example
|
|
2183
|
+
* editor.commands.command(({ tr, state }) => {
|
|
2184
|
+
* ...
|
|
2185
|
+
* return true
|
|
2186
|
+
* })
|
|
2187
|
+
*/
|
|
2188
|
+
command: (fn: (props: Parameters<Command>[0]) => boolean) => ReturnType;
|
|
2189
|
+
};
|
|
2190
|
+
}
|
|
2191
|
+
}
|
|
2192
|
+
declare const command: RawCommands['command'];
|
|
2193
|
+
|
|
2194
|
+
declare module '@blockslides/core' {
|
|
2195
|
+
interface Commands<ReturnType> {
|
|
2196
|
+
createParagraphNear: {
|
|
2197
|
+
/**
|
|
2198
|
+
* Create a paragraph nearby.
|
|
2199
|
+
* @example editor.commands.createParagraphNear()
|
|
2200
|
+
*/
|
|
2201
|
+
createParagraphNear: () => ReturnType;
|
|
2202
|
+
};
|
|
2203
|
+
}
|
|
2204
|
+
}
|
|
2205
|
+
declare const createParagraphNear: RawCommands['createParagraphNear'];
|
|
2206
|
+
|
|
2207
|
+
declare module '@blockslides/core' {
|
|
2208
|
+
interface Commands<ReturnType> {
|
|
2209
|
+
cut: {
|
|
2210
|
+
/**
|
|
2211
|
+
* Cuts content from a range and inserts it at a given position.
|
|
2212
|
+
* @param range The range to cut.
|
|
2213
|
+
* @param range.from The start position of the range.
|
|
2214
|
+
* @param range.to The end position of the range.
|
|
2215
|
+
* @param targetPos The position to insert the content at.
|
|
2216
|
+
* @example editor.commands.cut({ from: 1, to: 3 }, 5)
|
|
2217
|
+
*/
|
|
2218
|
+
cut: ({ from, to }: {
|
|
2219
|
+
from: number;
|
|
2220
|
+
to: number;
|
|
2221
|
+
}, targetPos: number) => ReturnType;
|
|
2222
|
+
};
|
|
2223
|
+
}
|
|
2224
|
+
}
|
|
2225
|
+
declare const cut: RawCommands['cut'];
|
|
2226
|
+
|
|
2227
|
+
declare module '@blockslides/core' {
|
|
2228
|
+
interface Commands<ReturnType> {
|
|
2229
|
+
deleteCurrentNode: {
|
|
2230
|
+
/**
|
|
2231
|
+
* Delete the node that currently has the selection anchor.
|
|
2232
|
+
* @example editor.commands.deleteCurrentNode()
|
|
2233
|
+
*/
|
|
2234
|
+
deleteCurrentNode: () => ReturnType;
|
|
2235
|
+
};
|
|
2236
|
+
}
|
|
2237
|
+
}
|
|
2238
|
+
declare const deleteCurrentNode: RawCommands['deleteCurrentNode'];
|
|
2239
|
+
|
|
2240
|
+
declare module '@blockslides/core' {
|
|
2241
|
+
interface Commands<ReturnType> {
|
|
2242
|
+
deleteNode: {
|
|
2243
|
+
/**
|
|
2244
|
+
* Delete a node with a given type or name.
|
|
2245
|
+
* @param typeOrName The type or name of the node.
|
|
2246
|
+
* @example editor.commands.deleteNode('paragraph')
|
|
2247
|
+
*/
|
|
2248
|
+
deleteNode: (typeOrName: string | NodeType$1) => ReturnType;
|
|
2249
|
+
};
|
|
2250
|
+
}
|
|
2251
|
+
}
|
|
2252
|
+
declare const deleteNode: RawCommands['deleteNode'];
|
|
2253
|
+
|
|
2254
|
+
declare module '@blockslides/core' {
|
|
2255
|
+
interface Commands<ReturnType> {
|
|
2256
|
+
deleteRange: {
|
|
2257
|
+
/**
|
|
2258
|
+
* Delete a given range.
|
|
2259
|
+
* @param range The range to delete.
|
|
2260
|
+
* @example editor.commands.deleteRange({ from: 1, to: 3 })
|
|
2261
|
+
*/
|
|
2262
|
+
deleteRange: (range: Range) => ReturnType;
|
|
2263
|
+
};
|
|
2264
|
+
}
|
|
2265
|
+
}
|
|
2266
|
+
declare const deleteRange: RawCommands['deleteRange'];
|
|
2267
|
+
|
|
2268
|
+
declare module '@blockslides/core' {
|
|
2269
|
+
interface Commands<ReturnType> {
|
|
2270
|
+
deleteSelection: {
|
|
2271
|
+
/**
|
|
2272
|
+
* Delete the selection, if there is one.
|
|
2273
|
+
* @example editor.commands.deleteSelection()
|
|
2274
|
+
*/
|
|
2275
|
+
deleteSelection: () => ReturnType;
|
|
2276
|
+
};
|
|
2277
|
+
}
|
|
2278
|
+
}
|
|
2279
|
+
declare const deleteSelection: RawCommands['deleteSelection'];
|
|
2280
|
+
|
|
2281
|
+
declare module '@blockslides/core' {
|
|
2282
|
+
interface Commands<ReturnType> {
|
|
2283
|
+
enter: {
|
|
2284
|
+
/**
|
|
2285
|
+
* Trigger enter.
|
|
2286
|
+
* @example editor.commands.enter()
|
|
2287
|
+
*/
|
|
2288
|
+
enter: () => ReturnType;
|
|
2289
|
+
};
|
|
2290
|
+
}
|
|
2291
|
+
}
|
|
2292
|
+
declare const enter: RawCommands['enter'];
|
|
2293
|
+
|
|
2294
|
+
declare module '@blockslides/core' {
|
|
2295
|
+
interface Commands<ReturnType> {
|
|
2296
|
+
exitCode: {
|
|
2297
|
+
/**
|
|
2298
|
+
* Exit from a code block.
|
|
2299
|
+
* @example editor.commands.exitCode()
|
|
2300
|
+
*/
|
|
2301
|
+
exitCode: () => ReturnType;
|
|
2302
|
+
};
|
|
2303
|
+
}
|
|
2304
|
+
}
|
|
2305
|
+
declare const exitCode: RawCommands['exitCode'];
|
|
2306
|
+
|
|
2307
|
+
declare module '@blockslides/core' {
|
|
2308
|
+
interface Commands<ReturnType> {
|
|
2309
|
+
extendMarkRange: {
|
|
2310
|
+
/**
|
|
2311
|
+
* Extends the text selection to the current mark by type or name.
|
|
2312
|
+
* @param typeOrName The type or name of the mark.
|
|
2313
|
+
* @param attributes The attributes of the mark.
|
|
2314
|
+
* @example editor.commands.extendMarkRange('bold')
|
|
2315
|
+
* @example editor.commands.extendMarkRange('mention', { userId: "1" })
|
|
2316
|
+
*/
|
|
2317
|
+
extendMarkRange: (
|
|
2318
|
+
/**
|
|
2319
|
+
* The type or name of the mark.
|
|
2320
|
+
*/
|
|
2321
|
+
typeOrName: string | MarkType$1,
|
|
2322
|
+
/**
|
|
2323
|
+
* The attributes of the mark.
|
|
2324
|
+
*/
|
|
2325
|
+
attributes?: Record<string, any>) => ReturnType;
|
|
2326
|
+
};
|
|
2327
|
+
}
|
|
2328
|
+
}
|
|
2329
|
+
declare const extendMarkRange: RawCommands['extendMarkRange'];
|
|
2330
|
+
|
|
2331
|
+
declare module '@blockslides/core' {
|
|
2332
|
+
interface Commands<ReturnType> {
|
|
2333
|
+
first: {
|
|
2334
|
+
/**
|
|
2335
|
+
* Runs one command after the other and stops at the first which returns true.
|
|
2336
|
+
* @param commands The commands to run.
|
|
2337
|
+
* @example editor.commands.first([command1, command2])
|
|
2338
|
+
*/
|
|
2339
|
+
first: (commands: Command[] | ((props: CommandProps) => Command[])) => ReturnType;
|
|
2340
|
+
};
|
|
2341
|
+
}
|
|
2342
|
+
}
|
|
2343
|
+
declare const first: RawCommands['first'];
|
|
2344
|
+
|
|
2345
|
+
declare module "@blockslides/core" {
|
|
2346
|
+
interface Commands<ReturnType> {
|
|
2347
|
+
focus: {
|
|
2348
|
+
/**
|
|
2349
|
+
* Focus the editor at the given position.
|
|
2350
|
+
* @param position The position to focus at.
|
|
2351
|
+
* @param options.scrollIntoView Scroll the focused position into view after focusing
|
|
2352
|
+
* @example editor.commands.focus()
|
|
2353
|
+
* @example editor.commands.focus(32, { scrollIntoView: false })
|
|
2354
|
+
*/
|
|
2355
|
+
focus: (
|
|
2356
|
+
/**
|
|
2357
|
+
* The position to focus at.
|
|
2358
|
+
*/
|
|
2359
|
+
position?: FocusPosition,
|
|
2360
|
+
/**
|
|
2361
|
+
* Optional options
|
|
2362
|
+
* @default { scrollIntoView: true }
|
|
2363
|
+
*/
|
|
2364
|
+
options?: {
|
|
2365
|
+
scrollIntoView?: boolean;
|
|
2366
|
+
}) => ReturnType;
|
|
2367
|
+
};
|
|
2368
|
+
}
|
|
2369
|
+
}
|
|
2370
|
+
declare const focus: RawCommands["focus"];
|
|
2371
|
+
|
|
2372
|
+
declare module '@blockslides/core' {
|
|
2373
|
+
interface Commands<ReturnType> {
|
|
2374
|
+
forEach: {
|
|
2375
|
+
/**
|
|
2376
|
+
* Loop through an array of items.
|
|
2377
|
+
*/
|
|
2378
|
+
forEach: <T>(items: T[], fn: (item: T, props: CommandProps & {
|
|
2379
|
+
index: number;
|
|
2380
|
+
}) => boolean) => ReturnType;
|
|
2381
|
+
};
|
|
2382
|
+
}
|
|
2383
|
+
}
|
|
2384
|
+
declare const forEach: RawCommands['forEach'];
|
|
2385
|
+
|
|
2386
|
+
interface InsertContentOptions {
|
|
2387
|
+
/**
|
|
2388
|
+
* Options for parsing the content.
|
|
2389
|
+
*/
|
|
2390
|
+
parseOptions?: ParseOptions;
|
|
2391
|
+
/**
|
|
2392
|
+
* Whether to update the selection after inserting the content.
|
|
2393
|
+
*/
|
|
2394
|
+
updateSelection?: boolean;
|
|
2395
|
+
applyInputRules?: boolean;
|
|
2396
|
+
applyPasteRules?: boolean;
|
|
2397
|
+
}
|
|
2398
|
+
declare module '@blockslides/core' {
|
|
2399
|
+
interface Commands<ReturnType> {
|
|
2400
|
+
insertContent: {
|
|
2401
|
+
/**
|
|
2402
|
+
* Insert a node or string of HTML at the current position.
|
|
2403
|
+
* @example editor.commands.insertContent('<h1>Example</h1>')
|
|
2404
|
+
* @example editor.commands.insertContent('<h1>Example</h1>', { updateSelection: false })
|
|
2405
|
+
*/
|
|
2406
|
+
insertContent: (
|
|
2407
|
+
/**
|
|
2408
|
+
* The ProseMirror content to insert.
|
|
2409
|
+
*/
|
|
2410
|
+
value: Content | Node$1 | Fragment$1,
|
|
2411
|
+
/**
|
|
2412
|
+
* Optional options
|
|
2413
|
+
*/
|
|
2414
|
+
options?: InsertContentOptions) => ReturnType;
|
|
2415
|
+
};
|
|
2416
|
+
}
|
|
2417
|
+
}
|
|
2418
|
+
declare const insertContent: RawCommands['insertContent'];
|
|
2419
|
+
|
|
2420
|
+
interface InsertContentAtOptions {
|
|
2421
|
+
/**
|
|
2422
|
+
* Options for parsing the content.
|
|
2423
|
+
*/
|
|
2424
|
+
parseOptions?: ParseOptions;
|
|
2425
|
+
/**
|
|
2426
|
+
* Whether to update the selection after inserting the content.
|
|
2427
|
+
*/
|
|
2428
|
+
updateSelection?: boolean;
|
|
2429
|
+
/**
|
|
2430
|
+
* Whether to apply input rules after inserting the content.
|
|
2431
|
+
*/
|
|
2432
|
+
applyInputRules?: boolean;
|
|
2433
|
+
/**
|
|
2434
|
+
* Whether to apply paste rules after inserting the content.
|
|
2435
|
+
*/
|
|
2436
|
+
applyPasteRules?: boolean;
|
|
2437
|
+
/**
|
|
2438
|
+
* Whether to throw an error if the content is invalid.
|
|
2439
|
+
*/
|
|
2440
|
+
errorOnInvalidContent?: boolean;
|
|
2441
|
+
}
|
|
2442
|
+
declare module '@blockslides/core' {
|
|
2443
|
+
interface Commands<ReturnType> {
|
|
2444
|
+
insertContentAt: {
|
|
2445
|
+
/**
|
|
2446
|
+
* Insert a node or string of HTML at a specific position.
|
|
2447
|
+
* @example editor.commands.insertContentAt(0, '<h1>Example</h1>')
|
|
2448
|
+
*/
|
|
2449
|
+
insertContentAt: (
|
|
2450
|
+
/**
|
|
2451
|
+
* The position to insert the content at.
|
|
2452
|
+
*/
|
|
2453
|
+
position: number | Range,
|
|
2454
|
+
/**
|
|
2455
|
+
* The ProseMirror content to insert.
|
|
2456
|
+
*/
|
|
2457
|
+
value: Content | Node$1 | Fragment$1,
|
|
2458
|
+
/**
|
|
2459
|
+
* Optional options
|
|
2460
|
+
*/
|
|
2461
|
+
options?: InsertContentAtOptions) => ReturnType;
|
|
2462
|
+
};
|
|
2463
|
+
}
|
|
2464
|
+
}
|
|
2465
|
+
declare const insertContentAt: RawCommands['insertContentAt'];
|
|
2466
|
+
|
|
2467
|
+
declare module '@blockslides/core' {
|
|
2468
|
+
interface Commands<ReturnType> {
|
|
2469
|
+
joinUp: {
|
|
2470
|
+
/**
|
|
2471
|
+
* Join the selected block or, if there is a text selection, the closest ancestor block of the selection that can be joined, with the sibling above it.
|
|
2472
|
+
* @example editor.commands.joinUp()
|
|
2473
|
+
*/
|
|
2474
|
+
joinUp: () => ReturnType;
|
|
2475
|
+
};
|
|
2476
|
+
joinDown: {
|
|
2477
|
+
/**
|
|
2478
|
+
* Join the selected block, or the closest ancestor of the selection that can be joined, with the sibling after it.
|
|
2479
|
+
* @example editor.commands.joinDown()
|
|
2480
|
+
*/
|
|
2481
|
+
joinDown: () => ReturnType;
|
|
2482
|
+
};
|
|
2483
|
+
joinBackward: {
|
|
2484
|
+
/**
|
|
2485
|
+
* If the selection is empty and at the start of a textblock, try to reduce the distance between that block and the one before it—if there's a block directly before it that can be joined, join them.
|
|
2486
|
+
* If not, try to move the selected block closer to the next one in the document structure by lifting it out of its
|
|
2487
|
+
* parent or moving it into a parent of the previous block. Will use the view for accurate (bidi-aware) start-of-textblock detection if given.
|
|
2488
|
+
* @example editor.commands.joinBackward()
|
|
2489
|
+
*/
|
|
2490
|
+
joinBackward: () => ReturnType;
|
|
2491
|
+
};
|
|
2492
|
+
joinForward: {
|
|
2493
|
+
/**
|
|
2494
|
+
* If the selection is empty and the cursor is at the end of a textblock, try to reduce or remove the boundary between that block and the one after it,
|
|
2495
|
+
* either by joining them or by moving the other block closer to this one in the tree structure.
|
|
2496
|
+
* Will use the view for accurate start-of-textblock detection if given.
|
|
2497
|
+
* @example editor.commands.joinForward()
|
|
2498
|
+
*/
|
|
2499
|
+
joinForward: () => ReturnType;
|
|
2500
|
+
};
|
|
2501
|
+
}
|
|
2502
|
+
}
|
|
2503
|
+
declare const joinUp: RawCommands['joinUp'];
|
|
2504
|
+
declare const joinDown: RawCommands['joinDown'];
|
|
2505
|
+
declare const joinBackward: RawCommands['joinBackward'];
|
|
2506
|
+
declare const joinForward: RawCommands['joinForward'];
|
|
2507
|
+
|
|
2508
|
+
declare module '@blockslides/core' {
|
|
2509
|
+
interface Commands<ReturnType> {
|
|
2510
|
+
joinItemBackward: {
|
|
2511
|
+
/**
|
|
2512
|
+
* Join two items backward.
|
|
2513
|
+
* @example editor.commands.joinItemBackward()
|
|
2514
|
+
*/
|
|
2515
|
+
joinItemBackward: () => ReturnType;
|
|
2516
|
+
};
|
|
2517
|
+
}
|
|
2518
|
+
}
|
|
2519
|
+
declare const joinItemBackward: RawCommands['joinItemBackward'];
|
|
2520
|
+
|
|
2521
|
+
declare module '@blockslides/core' {
|
|
2522
|
+
interface Commands<ReturnType> {
|
|
2523
|
+
joinItemForward: {
|
|
2524
|
+
/**
|
|
2525
|
+
* Join two items Forwards.
|
|
2526
|
+
* @example editor.commands.joinItemForward()
|
|
2527
|
+
*/
|
|
2528
|
+
joinItemForward: () => ReturnType;
|
|
2529
|
+
};
|
|
2530
|
+
}
|
|
2531
|
+
}
|
|
2532
|
+
declare const joinItemForward: RawCommands['joinItemForward'];
|
|
2533
|
+
|
|
2534
|
+
declare module '@blockslides/core' {
|
|
2535
|
+
interface Commands<ReturnType> {
|
|
2536
|
+
joinTextblockBackward: {
|
|
2537
|
+
/**
|
|
2538
|
+
* A more limited form of joinBackward that only tries to join the current textblock to the one before it, if the cursor is at the start of a textblock.
|
|
2539
|
+
*/
|
|
2540
|
+
joinTextblockBackward: () => ReturnType;
|
|
2541
|
+
};
|
|
2542
|
+
}
|
|
2543
|
+
}
|
|
2544
|
+
declare const joinTextblockBackward: RawCommands['joinTextblockBackward'];
|
|
2545
|
+
|
|
2546
|
+
declare module '@blockslides/core' {
|
|
2547
|
+
interface Commands<ReturnType> {
|
|
2548
|
+
joinTextblockForward: {
|
|
2549
|
+
/**
|
|
2550
|
+
* A more limited form of joinForward that only tries to join the current textblock to the one after it, if the cursor is at the end of a textblock.
|
|
2551
|
+
*/
|
|
2552
|
+
joinTextblockForward: () => ReturnType;
|
|
2553
|
+
};
|
|
2554
|
+
}
|
|
2555
|
+
}
|
|
2556
|
+
declare const joinTextblockForward: RawCommands['joinTextblockForward'];
|
|
2557
|
+
|
|
2558
|
+
declare module '@blockslides/core' {
|
|
2559
|
+
interface Commands<ReturnType> {
|
|
2560
|
+
keyboardShortcut: {
|
|
2561
|
+
/**
|
|
2562
|
+
* Trigger a keyboard shortcut.
|
|
2563
|
+
* @param name The name of the keyboard shortcut.
|
|
2564
|
+
* @example editor.commands.keyboardShortcut('Mod-b')
|
|
2565
|
+
*/
|
|
2566
|
+
keyboardShortcut: (name: string) => ReturnType;
|
|
2567
|
+
};
|
|
2568
|
+
}
|
|
2569
|
+
}
|
|
2570
|
+
declare const keyboardShortcut: RawCommands['keyboardShortcut'];
|
|
2571
|
+
|
|
2572
|
+
declare module '@blockslides/core' {
|
|
2573
|
+
interface Commands<ReturnType> {
|
|
2574
|
+
lift: {
|
|
2575
|
+
/**
|
|
2576
|
+
* Removes an existing wrap if possible lifting the node out of it
|
|
2577
|
+
* @param typeOrName The type or name of the node.
|
|
2578
|
+
* @param attributes The attributes of the node.
|
|
2579
|
+
* @example editor.commands.lift('paragraph')
|
|
2580
|
+
* @example editor.commands.lift('heading', { level: 1 })
|
|
2581
|
+
*/
|
|
2582
|
+
lift: (typeOrName: string | NodeType$1, attributes?: Record<string, any>) => ReturnType;
|
|
2583
|
+
};
|
|
2584
|
+
}
|
|
2585
|
+
}
|
|
2586
|
+
declare const lift: RawCommands['lift'];
|
|
2587
|
+
|
|
2588
|
+
declare module '@blockslides/core' {
|
|
2589
|
+
interface Commands<ReturnType> {
|
|
2590
|
+
liftEmptyBlock: {
|
|
2591
|
+
/**
|
|
2592
|
+
* If the cursor is in an empty textblock that can be lifted, lift the block.
|
|
2593
|
+
* @example editor.commands.liftEmptyBlock()
|
|
2594
|
+
*/
|
|
2595
|
+
liftEmptyBlock: () => ReturnType;
|
|
2596
|
+
};
|
|
2597
|
+
}
|
|
2598
|
+
}
|
|
2599
|
+
declare const liftEmptyBlock: RawCommands['liftEmptyBlock'];
|
|
2600
|
+
|
|
2601
|
+
declare module '@blockslides/core' {
|
|
2602
|
+
interface Commands<ReturnType> {
|
|
2603
|
+
liftListItem: {
|
|
2604
|
+
/**
|
|
2605
|
+
* Create a command to lift the list item around the selection up into a wrapping list.
|
|
2606
|
+
* @param typeOrName The type or name of the node.
|
|
2607
|
+
* @example editor.commands.liftListItem('listItem')
|
|
2608
|
+
*/
|
|
2609
|
+
liftListItem: (typeOrName: string | NodeType$1) => ReturnType;
|
|
2610
|
+
};
|
|
2611
|
+
}
|
|
2612
|
+
}
|
|
2613
|
+
declare const liftListItem: RawCommands['liftListItem'];
|
|
2614
|
+
|
|
2615
|
+
declare module '@blockslides/core' {
|
|
2616
|
+
interface Commands<ReturnType> {
|
|
2617
|
+
newlineInCode: {
|
|
2618
|
+
/**
|
|
2619
|
+
* Add a newline character in code.
|
|
2620
|
+
* @example editor.commands.newlineInCode()
|
|
2621
|
+
*/
|
|
2622
|
+
newlineInCode: () => ReturnType;
|
|
2623
|
+
};
|
|
2624
|
+
}
|
|
2625
|
+
}
|
|
2626
|
+
declare const newlineInCode: RawCommands['newlineInCode'];
|
|
2627
|
+
|
|
2628
|
+
declare module '@blockslides/core' {
|
|
2629
|
+
interface Commands<ReturnType> {
|
|
2630
|
+
resetAttributes: {
|
|
2631
|
+
/**
|
|
2632
|
+
* Resets some node attributes to the default value.
|
|
2633
|
+
* @param typeOrName The type or name of the node.
|
|
2634
|
+
* @param attributes The attributes of the node to reset.
|
|
2635
|
+
* @example editor.commands.resetAttributes('heading', 'level')
|
|
2636
|
+
*/
|
|
2637
|
+
resetAttributes: (typeOrName: string | NodeType$1 | MarkType$1, attributes: string | string[]) => ReturnType;
|
|
2638
|
+
};
|
|
2639
|
+
}
|
|
2640
|
+
}
|
|
2641
|
+
declare const resetAttributes: RawCommands['resetAttributes'];
|
|
2642
|
+
|
|
2643
|
+
declare module '@blockslides/core' {
|
|
2644
|
+
interface Commands<ReturnType> {
|
|
2645
|
+
scrollIntoView: {
|
|
2646
|
+
/**
|
|
2647
|
+
* Scroll the selection into view.
|
|
2648
|
+
* @example editor.commands.scrollIntoView()
|
|
2649
|
+
*/
|
|
2650
|
+
scrollIntoView: () => ReturnType;
|
|
2651
|
+
};
|
|
2652
|
+
}
|
|
2653
|
+
}
|
|
2654
|
+
declare const scrollIntoView: RawCommands['scrollIntoView'];
|
|
2655
|
+
|
|
2656
|
+
declare module '@blockslides/core' {
|
|
2657
|
+
interface Commands<ReturnType> {
|
|
2658
|
+
selectAll: {
|
|
2659
|
+
/**
|
|
2660
|
+
* Select the whole document.
|
|
2661
|
+
* @example editor.commands.selectAll()
|
|
2662
|
+
*/
|
|
2663
|
+
selectAll: () => ReturnType;
|
|
2664
|
+
};
|
|
2665
|
+
}
|
|
2666
|
+
}
|
|
2667
|
+
declare const selectAll: RawCommands['selectAll'];
|
|
2668
|
+
|
|
2669
|
+
declare module '@blockslides/core' {
|
|
2670
|
+
interface Commands<ReturnType> {
|
|
2671
|
+
selectNodeBackward: {
|
|
2672
|
+
/**
|
|
2673
|
+
* Select a node backward.
|
|
2674
|
+
* @example editor.commands.selectNodeBackward()
|
|
2675
|
+
*/
|
|
2676
|
+
selectNodeBackward: () => ReturnType;
|
|
2677
|
+
};
|
|
2678
|
+
}
|
|
2679
|
+
}
|
|
2680
|
+
declare const selectNodeBackward: RawCommands['selectNodeBackward'];
|
|
2681
|
+
|
|
2682
|
+
declare module '@blockslides/core' {
|
|
2683
|
+
interface Commands<ReturnType> {
|
|
2684
|
+
selectNodeForward: {
|
|
2685
|
+
/**
|
|
2686
|
+
* Select a node forward.
|
|
2687
|
+
* @example editor.commands.selectNodeForward()
|
|
2688
|
+
*/
|
|
2689
|
+
selectNodeForward: () => ReturnType;
|
|
2690
|
+
};
|
|
2691
|
+
}
|
|
2692
|
+
}
|
|
2693
|
+
declare const selectNodeForward: RawCommands['selectNodeForward'];
|
|
2694
|
+
|
|
2695
|
+
declare module '@blockslides/core' {
|
|
2696
|
+
interface Commands<ReturnType> {
|
|
2697
|
+
selectParentNode: {
|
|
2698
|
+
/**
|
|
2699
|
+
* Select the parent node.
|
|
2700
|
+
* @example editor.commands.selectParentNode()
|
|
2701
|
+
*/
|
|
2702
|
+
selectParentNode: () => ReturnType;
|
|
2703
|
+
};
|
|
2704
|
+
}
|
|
2705
|
+
}
|
|
2706
|
+
declare const selectParentNode: RawCommands['selectParentNode'];
|
|
2707
|
+
|
|
2708
|
+
declare module '@blockslides/core' {
|
|
2709
|
+
interface Commands<ReturnType> {
|
|
2710
|
+
selectTextblockEnd: {
|
|
2711
|
+
/**
|
|
2712
|
+
* Moves the cursor to the end of current text block.
|
|
2713
|
+
* @example editor.commands.selectTextblockEnd()
|
|
2714
|
+
*/
|
|
2715
|
+
selectTextblockEnd: () => ReturnType;
|
|
2716
|
+
};
|
|
2717
|
+
}
|
|
2718
|
+
}
|
|
2719
|
+
declare const selectTextblockEnd: RawCommands['selectTextblockEnd'];
|
|
2720
|
+
|
|
2721
|
+
declare module '@blockslides/core' {
|
|
2722
|
+
interface Commands<ReturnType> {
|
|
2723
|
+
selectTextblockStart: {
|
|
2724
|
+
/**
|
|
2725
|
+
* Moves the cursor to the start of current text block.
|
|
2726
|
+
* @example editor.commands.selectTextblockStart()
|
|
2727
|
+
*/
|
|
2728
|
+
selectTextblockStart: () => ReturnType;
|
|
2729
|
+
};
|
|
2730
|
+
}
|
|
2731
|
+
}
|
|
2732
|
+
declare const selectTextblockStart: RawCommands['selectTextblockStart'];
|
|
2733
|
+
|
|
2734
|
+
interface SetContentOptions {
|
|
2735
|
+
/**
|
|
2736
|
+
* Options for parsing the content.
|
|
2737
|
+
* @default {}
|
|
2738
|
+
*/
|
|
2739
|
+
parseOptions?: ParseOptions;
|
|
2740
|
+
/**
|
|
2741
|
+
* Whether to throw an error if the content is invalid.
|
|
2742
|
+
*/
|
|
2743
|
+
errorOnInvalidContent?: boolean;
|
|
2744
|
+
/**
|
|
2745
|
+
* Whether to emit an update event.
|
|
2746
|
+
* @default true
|
|
2747
|
+
*/
|
|
2748
|
+
emitUpdate?: boolean;
|
|
2749
|
+
}
|
|
2750
|
+
declare module '@blockslides/core' {
|
|
2751
|
+
interface Commands<ReturnType> {
|
|
2752
|
+
setContent: {
|
|
2753
|
+
/**
|
|
2754
|
+
* Replace the whole document with new content.
|
|
2755
|
+
* @param content The new content.
|
|
2756
|
+
* @param emitUpdate Whether to emit an update event.
|
|
2757
|
+
* @param parseOptions Options for parsing the content.
|
|
2758
|
+
* @example editor.commands.setContent('<p>Example text</p>')
|
|
2759
|
+
*/
|
|
2760
|
+
setContent: (
|
|
2761
|
+
/**
|
|
2762
|
+
* The new content.
|
|
2763
|
+
*/
|
|
2764
|
+
content: Content | Fragment$1 | Node$1,
|
|
2765
|
+
/**
|
|
2766
|
+
* Options for `setContent`.
|
|
2767
|
+
*/
|
|
2768
|
+
options?: SetContentOptions) => ReturnType;
|
|
2769
|
+
};
|
|
2770
|
+
}
|
|
2771
|
+
}
|
|
2772
|
+
declare const setContent: RawCommands['setContent'];
|
|
2773
|
+
|
|
2774
|
+
declare module '@blockslides/core' {
|
|
2775
|
+
interface Commands<ReturnType> {
|
|
2776
|
+
setMark: {
|
|
2777
|
+
/**
|
|
2778
|
+
* Add a mark with new attributes.
|
|
2779
|
+
* @param typeOrName The mark type or name.
|
|
2780
|
+
* @example editor.commands.setMark('bold', { level: 1 })
|
|
2781
|
+
*/
|
|
2782
|
+
setMark: (typeOrName: string | MarkType$1, attributes?: Record<string, any>) => ReturnType;
|
|
2783
|
+
};
|
|
2784
|
+
}
|
|
2785
|
+
}
|
|
2786
|
+
declare const setMark: RawCommands['setMark'];
|
|
2787
|
+
|
|
2788
|
+
declare module '@blockslides/core' {
|
|
2789
|
+
interface Commands<ReturnType> {
|
|
2790
|
+
setMeta: {
|
|
2791
|
+
/**
|
|
2792
|
+
* Store a metadata property in the current transaction.
|
|
2793
|
+
* @param key The key of the metadata property.
|
|
2794
|
+
* @param value The value to store.
|
|
2795
|
+
* @example editor.commands.setMeta('foo', 'bar')
|
|
2796
|
+
*/
|
|
2797
|
+
setMeta: (key: string | Plugin | PluginKey, value: any) => ReturnType;
|
|
2798
|
+
};
|
|
2799
|
+
}
|
|
2800
|
+
}
|
|
2801
|
+
declare const setMeta: RawCommands['setMeta'];
|
|
2802
|
+
|
|
2803
|
+
declare module '@blockslides/core' {
|
|
2804
|
+
interface Commands<ReturnType> {
|
|
2805
|
+
setNode: {
|
|
2806
|
+
/**
|
|
2807
|
+
* Replace a given range with a node.
|
|
2808
|
+
* @param typeOrName The type or name of the node
|
|
2809
|
+
* @param attributes The attributes of the node
|
|
2810
|
+
* @example editor.commands.setNode('paragraph')
|
|
2811
|
+
*/
|
|
2812
|
+
setNode: (typeOrName: string | NodeType$1, attributes?: Record<string, any>) => ReturnType;
|
|
2813
|
+
};
|
|
2814
|
+
}
|
|
2815
|
+
}
|
|
2816
|
+
declare const setNode: RawCommands['setNode'];
|
|
2817
|
+
|
|
2818
|
+
declare module '@blockslides/core' {
|
|
2819
|
+
interface Commands<ReturnType> {
|
|
2820
|
+
setNodeSelection: {
|
|
2821
|
+
/**
|
|
2822
|
+
* Creates a NodeSelection.
|
|
2823
|
+
* @param position - Position of the node.
|
|
2824
|
+
* @example editor.commands.setNodeSelection(10)
|
|
2825
|
+
*/
|
|
2826
|
+
setNodeSelection: (position: number) => ReturnType;
|
|
2827
|
+
};
|
|
2828
|
+
}
|
|
2829
|
+
}
|
|
2830
|
+
declare const setNodeSelection: RawCommands['setNodeSelection'];
|
|
2831
|
+
|
|
2832
|
+
declare module '@blockslides/core' {
|
|
2833
|
+
interface Commands<ReturnType> {
|
|
2834
|
+
setTextSelection: {
|
|
2835
|
+
/**
|
|
2836
|
+
* Creates a TextSelection.
|
|
2837
|
+
* @param position The position of the selection.
|
|
2838
|
+
* @example editor.commands.setTextSelection(10)
|
|
2839
|
+
*/
|
|
2840
|
+
setTextSelection: (position: number | Range) => ReturnType;
|
|
2841
|
+
};
|
|
2842
|
+
}
|
|
2843
|
+
}
|
|
2844
|
+
declare const setTextSelection: RawCommands['setTextSelection'];
|
|
2845
|
+
|
|
2846
|
+
declare module '@blockslides/core' {
|
|
2847
|
+
interface Commands<ReturnType> {
|
|
2848
|
+
sinkListItem: {
|
|
2849
|
+
/**
|
|
2850
|
+
* Sink the list item down into an inner list.
|
|
2851
|
+
* @param typeOrName The type or name of the node.
|
|
2852
|
+
* @example editor.commands.sinkListItem('listItem')
|
|
2853
|
+
*/
|
|
2854
|
+
sinkListItem: (typeOrName: string | NodeType$1) => ReturnType;
|
|
2855
|
+
};
|
|
2856
|
+
}
|
|
2857
|
+
}
|
|
2858
|
+
declare const sinkListItem: RawCommands['sinkListItem'];
|
|
2859
|
+
|
|
2860
|
+
declare module '@blockslides/core' {
|
|
2861
|
+
interface Commands<ReturnType> {
|
|
2862
|
+
splitBlock: {
|
|
2863
|
+
/**
|
|
2864
|
+
* Forks a new node from an existing node.
|
|
2865
|
+
* @param options.keepMarks Keep marks from the previous node.
|
|
2866
|
+
* @example editor.commands.splitBlock()
|
|
2867
|
+
* @example editor.commands.splitBlock({ keepMarks: true })
|
|
2868
|
+
*/
|
|
2869
|
+
splitBlock: (options?: {
|
|
2870
|
+
keepMarks?: boolean;
|
|
2871
|
+
}) => ReturnType;
|
|
2872
|
+
};
|
|
2873
|
+
}
|
|
2874
|
+
}
|
|
2875
|
+
declare const splitBlock: RawCommands['splitBlock'];
|
|
2876
|
+
|
|
2877
|
+
declare module '@blockslides/core' {
|
|
2878
|
+
interface Commands<ReturnType> {
|
|
2879
|
+
splitListItem: {
|
|
2880
|
+
/**
|
|
2881
|
+
* Splits one list item into two list items.
|
|
2882
|
+
* @param typeOrName The type or name of the node.
|
|
2883
|
+
* @param overrideAttrs The attributes to ensure on the new node.
|
|
2884
|
+
* @example editor.commands.splitListItem('listItem')
|
|
2885
|
+
*/
|
|
2886
|
+
splitListItem: (typeOrName: string | NodeType$1, overrideAttrs?: Record<string, any>) => ReturnType;
|
|
2887
|
+
};
|
|
2888
|
+
}
|
|
2889
|
+
}
|
|
2890
|
+
declare const splitListItem: RawCommands['splitListItem'];
|
|
2891
|
+
|
|
2892
|
+
declare module '@blockslides/core' {
|
|
2893
|
+
interface Commands<ReturnType> {
|
|
2894
|
+
toggleList: {
|
|
2895
|
+
/**
|
|
2896
|
+
* Toggle between different list types.
|
|
2897
|
+
* @param listTypeOrName The type or name of the list.
|
|
2898
|
+
* @param itemTypeOrName The type or name of the list item.
|
|
2899
|
+
* @param keepMarks Keep marks when toggling.
|
|
2900
|
+
* @param attributes Attributes for the new list.
|
|
2901
|
+
* @example editor.commands.toggleList('bulletList', 'listItem')
|
|
2902
|
+
*/
|
|
2903
|
+
toggleList: (listTypeOrName: string | NodeType$1, itemTypeOrName: string | NodeType$1, keepMarks?: boolean, attributes?: Record<string, any>) => ReturnType;
|
|
2904
|
+
};
|
|
2905
|
+
}
|
|
2906
|
+
}
|
|
2907
|
+
declare const toggleList: RawCommands['toggleList'];
|
|
2908
|
+
|
|
2909
|
+
declare module '@blockslides/core' {
|
|
2910
|
+
interface Commands<ReturnType> {
|
|
2911
|
+
toggleMark: {
|
|
2912
|
+
/**
|
|
2913
|
+
* Toggle a mark on and off.
|
|
2914
|
+
* @param typeOrName The mark type or name.
|
|
2915
|
+
* @param attributes The attributes of the mark.
|
|
2916
|
+
* @param options.extendEmptyMarkRange Removes the mark even across the current selection. Defaults to `false`.
|
|
2917
|
+
* @example editor.commands.toggleMark('bold')
|
|
2918
|
+
*/
|
|
2919
|
+
toggleMark: (
|
|
2920
|
+
/**
|
|
2921
|
+
* The mark type or name.
|
|
2922
|
+
*/
|
|
2923
|
+
typeOrName: string | MarkType$1,
|
|
2924
|
+
/**
|
|
2925
|
+
* The attributes of the mark.
|
|
2926
|
+
*/
|
|
2927
|
+
attributes?: Record<string, any>, options?: {
|
|
2928
|
+
/**
|
|
2929
|
+
* Removes the mark even across the current selection. Defaults to `false`.
|
|
2930
|
+
*/
|
|
2931
|
+
extendEmptyMarkRange?: boolean;
|
|
2932
|
+
}) => ReturnType;
|
|
2933
|
+
};
|
|
2934
|
+
}
|
|
2935
|
+
}
|
|
2936
|
+
declare const toggleMark: RawCommands['toggleMark'];
|
|
2937
|
+
|
|
2938
|
+
declare module '@blockslides/core' {
|
|
2939
|
+
interface Commands<ReturnType> {
|
|
2940
|
+
toggleNode: {
|
|
2941
|
+
/**
|
|
2942
|
+
* Toggle a node with another node.
|
|
2943
|
+
* @param typeOrName The type or name of the node.
|
|
2944
|
+
* @param toggleTypeOrName The type or name of the node to toggle.
|
|
2945
|
+
* @param attributes The attributes of the node.
|
|
2946
|
+
* @example editor.commands.toggleNode('heading', 'paragraph')
|
|
2947
|
+
*/
|
|
2948
|
+
toggleNode: (typeOrName: string | NodeType$1, toggleTypeOrName: string | NodeType$1, attributes?: Record<string, any>) => ReturnType;
|
|
2949
|
+
};
|
|
2950
|
+
}
|
|
2951
|
+
}
|
|
2952
|
+
declare const toggleNode: RawCommands['toggleNode'];
|
|
2953
|
+
|
|
2954
|
+
declare module '@blockslides/core' {
|
|
2955
|
+
interface Commands<ReturnType> {
|
|
2956
|
+
toggleWrap: {
|
|
2957
|
+
/**
|
|
2958
|
+
* Wraps nodes in another node, or removes an existing wrap.
|
|
2959
|
+
* @param typeOrName The type or name of the node.
|
|
2960
|
+
* @param attributes The attributes of the node.
|
|
2961
|
+
* @example editor.commands.toggleWrap('blockquote')
|
|
2962
|
+
*/
|
|
2963
|
+
toggleWrap: (typeOrName: string | NodeType$1, attributes?: Record<string, any>) => ReturnType;
|
|
2964
|
+
};
|
|
2965
|
+
}
|
|
2966
|
+
}
|
|
2967
|
+
declare const toggleWrap: RawCommands['toggleWrap'];
|
|
2968
|
+
|
|
2969
|
+
declare module '@blockslides/core' {
|
|
2970
|
+
interface Commands<ReturnType> {
|
|
2971
|
+
undoInputRule: {
|
|
2972
|
+
/**
|
|
2973
|
+
* Undo an input rule.
|
|
2974
|
+
* @example editor.commands.undoInputRule()
|
|
2975
|
+
*/
|
|
2976
|
+
undoInputRule: () => ReturnType;
|
|
2977
|
+
};
|
|
2978
|
+
}
|
|
2979
|
+
}
|
|
2980
|
+
declare const undoInputRule: RawCommands['undoInputRule'];
|
|
2981
|
+
|
|
2982
|
+
declare module '@blockslides/core' {
|
|
2983
|
+
interface Commands<ReturnType> {
|
|
2984
|
+
unsetAllMarks: {
|
|
2985
|
+
/**
|
|
2986
|
+
* Remove all marks in the current selection.
|
|
2987
|
+
* @example editor.commands.unsetAllMarks()
|
|
2988
|
+
*/
|
|
2989
|
+
unsetAllMarks: () => ReturnType;
|
|
2990
|
+
};
|
|
2991
|
+
}
|
|
2992
|
+
}
|
|
2993
|
+
declare const unsetAllMarks: RawCommands['unsetAllMarks'];
|
|
2994
|
+
|
|
2995
|
+
declare module '@blockslides/core' {
|
|
2996
|
+
interface Commands<ReturnType> {
|
|
2997
|
+
unsetMark: {
|
|
2998
|
+
/**
|
|
2999
|
+
* Remove all marks in the current selection.
|
|
3000
|
+
* @param typeOrName The mark type or name.
|
|
3001
|
+
* @param options.extendEmptyMarkRange Removes the mark even across the current selection. Defaults to `false`.
|
|
3002
|
+
* @example editor.commands.unsetMark('bold')
|
|
3003
|
+
*/
|
|
3004
|
+
unsetMark: (
|
|
3005
|
+
/**
|
|
3006
|
+
* The mark type or name.
|
|
3007
|
+
*/
|
|
3008
|
+
typeOrName: string | MarkType$1, options?: {
|
|
3009
|
+
/**
|
|
3010
|
+
* Removes the mark even across the current selection. Defaults to `false`.
|
|
3011
|
+
*/
|
|
3012
|
+
extendEmptyMarkRange?: boolean;
|
|
3013
|
+
}) => ReturnType;
|
|
3014
|
+
};
|
|
3015
|
+
}
|
|
3016
|
+
}
|
|
3017
|
+
declare const unsetMark: RawCommands['unsetMark'];
|
|
3018
|
+
|
|
3019
|
+
declare module '@blockslides/core' {
|
|
3020
|
+
interface Commands<ReturnType> {
|
|
3021
|
+
updateAttributes: {
|
|
3022
|
+
/**
|
|
3023
|
+
* Update attributes of a node or mark.
|
|
3024
|
+
* @param typeOrName The type or name of the node or mark.
|
|
3025
|
+
* @param attributes The attributes of the node or mark.
|
|
3026
|
+
* @example editor.commands.updateAttributes('mention', { userId: "2" })
|
|
3027
|
+
*/
|
|
3028
|
+
updateAttributes: (
|
|
3029
|
+
/**
|
|
3030
|
+
* The type or name of the node or mark.
|
|
3031
|
+
*/
|
|
3032
|
+
typeOrName: string | NodeType$1 | MarkType$1,
|
|
3033
|
+
/**
|
|
3034
|
+
* The attributes of the node or mark.
|
|
3035
|
+
*/
|
|
3036
|
+
attributes: Record<string, any>) => ReturnType;
|
|
3037
|
+
};
|
|
3038
|
+
}
|
|
3039
|
+
}
|
|
3040
|
+
declare const updateAttributes: RawCommands['updateAttributes'];
|
|
3041
|
+
|
|
3042
|
+
declare module '@blockslides/core' {
|
|
3043
|
+
interface Commands<ReturnType> {
|
|
3044
|
+
wrapIn: {
|
|
3045
|
+
/**
|
|
3046
|
+
* Wraps nodes in another node.
|
|
3047
|
+
* @param typeOrName The type or name of the node.
|
|
3048
|
+
* @param attributes The attributes of the node.
|
|
3049
|
+
* @example editor.commands.wrapIn('blockquote')
|
|
3050
|
+
*/
|
|
3051
|
+
wrapIn: (typeOrName: string | NodeType$1, attributes?: Record<string, any>) => ReturnType;
|
|
3052
|
+
};
|
|
3053
|
+
}
|
|
3054
|
+
}
|
|
3055
|
+
declare const wrapIn: RawCommands['wrapIn'];
|
|
3056
|
+
|
|
3057
|
+
declare module '@blockslides/core' {
|
|
3058
|
+
interface Commands<ReturnType> {
|
|
3059
|
+
wrapInList: {
|
|
3060
|
+
/**
|
|
3061
|
+
* Wrap a node in a list.
|
|
3062
|
+
* @param typeOrName The type or name of the node.
|
|
3063
|
+
* @param attributes The attributes of the node.
|
|
3064
|
+
* @example editor.commands.wrapInList('bulletList')
|
|
3065
|
+
*/
|
|
3066
|
+
wrapInList: (typeOrName: string | NodeType$1, attributes?: Record<string, any>) => ReturnType;
|
|
3067
|
+
};
|
|
3068
|
+
}
|
|
3069
|
+
}
|
|
3070
|
+
declare const wrapInList: RawCommands['wrapInList'];
|
|
3071
|
+
|
|
3072
|
+
type index$2_InsertContentAtOptions = InsertContentAtOptions;
|
|
3073
|
+
type index$2_InsertContentOptions = InsertContentOptions;
|
|
3074
|
+
type index$2_SetContentOptions = SetContentOptions;
|
|
3075
|
+
declare const index$2_blur: typeof blur;
|
|
3076
|
+
declare const index$2_clearContent: typeof clearContent;
|
|
3077
|
+
declare const index$2_clearNodes: typeof clearNodes;
|
|
3078
|
+
declare const index$2_command: typeof command;
|
|
3079
|
+
declare const index$2_createParagraphNear: typeof createParagraphNear;
|
|
3080
|
+
declare const index$2_cut: typeof cut;
|
|
3081
|
+
declare const index$2_deleteCurrentNode: typeof deleteCurrentNode;
|
|
3082
|
+
declare const index$2_deleteNode: typeof deleteNode;
|
|
3083
|
+
declare const index$2_deleteRange: typeof deleteRange;
|
|
3084
|
+
declare const index$2_deleteSelection: typeof deleteSelection;
|
|
3085
|
+
declare const index$2_enter: typeof enter;
|
|
3086
|
+
declare const index$2_exitCode: typeof exitCode;
|
|
3087
|
+
declare const index$2_extendMarkRange: typeof extendMarkRange;
|
|
3088
|
+
declare const index$2_first: typeof first;
|
|
3089
|
+
declare const index$2_focus: typeof focus;
|
|
3090
|
+
declare const index$2_forEach: typeof forEach;
|
|
3091
|
+
declare const index$2_insertContent: typeof insertContent;
|
|
3092
|
+
declare const index$2_insertContentAt: typeof insertContentAt;
|
|
3093
|
+
declare const index$2_joinBackward: typeof joinBackward;
|
|
3094
|
+
declare const index$2_joinDown: typeof joinDown;
|
|
3095
|
+
declare const index$2_joinForward: typeof joinForward;
|
|
3096
|
+
declare const index$2_joinItemBackward: typeof joinItemBackward;
|
|
3097
|
+
declare const index$2_joinItemForward: typeof joinItemForward;
|
|
3098
|
+
declare const index$2_joinTextblockBackward: typeof joinTextblockBackward;
|
|
3099
|
+
declare const index$2_joinTextblockForward: typeof joinTextblockForward;
|
|
3100
|
+
declare const index$2_joinUp: typeof joinUp;
|
|
3101
|
+
declare const index$2_keyboardShortcut: typeof keyboardShortcut;
|
|
3102
|
+
declare const index$2_lift: typeof lift;
|
|
3103
|
+
declare const index$2_liftEmptyBlock: typeof liftEmptyBlock;
|
|
3104
|
+
declare const index$2_liftListItem: typeof liftListItem;
|
|
3105
|
+
declare const index$2_newlineInCode: typeof newlineInCode;
|
|
3106
|
+
declare const index$2_resetAttributes: typeof resetAttributes;
|
|
3107
|
+
declare const index$2_scrollIntoView: typeof scrollIntoView;
|
|
3108
|
+
declare const index$2_selectAll: typeof selectAll;
|
|
3109
|
+
declare const index$2_selectNodeBackward: typeof selectNodeBackward;
|
|
3110
|
+
declare const index$2_selectNodeForward: typeof selectNodeForward;
|
|
3111
|
+
declare const index$2_selectParentNode: typeof selectParentNode;
|
|
3112
|
+
declare const index$2_selectTextblockEnd: typeof selectTextblockEnd;
|
|
3113
|
+
declare const index$2_selectTextblockStart: typeof selectTextblockStart;
|
|
3114
|
+
declare const index$2_setContent: typeof setContent;
|
|
3115
|
+
declare const index$2_setMark: typeof setMark;
|
|
3116
|
+
declare const index$2_setMeta: typeof setMeta;
|
|
3117
|
+
declare const index$2_setNode: typeof setNode;
|
|
3118
|
+
declare const index$2_setNodeSelection: typeof setNodeSelection;
|
|
3119
|
+
declare const index$2_setTextSelection: typeof setTextSelection;
|
|
3120
|
+
declare const index$2_sinkListItem: typeof sinkListItem;
|
|
3121
|
+
declare const index$2_splitBlock: typeof splitBlock;
|
|
3122
|
+
declare const index$2_splitListItem: typeof splitListItem;
|
|
3123
|
+
declare const index$2_toggleList: typeof toggleList;
|
|
3124
|
+
declare const index$2_toggleMark: typeof toggleMark;
|
|
3125
|
+
declare const index$2_toggleNode: typeof toggleNode;
|
|
3126
|
+
declare const index$2_toggleWrap: typeof toggleWrap;
|
|
3127
|
+
declare const index$2_undoInputRule: typeof undoInputRule;
|
|
3128
|
+
declare const index$2_unsetAllMarks: typeof unsetAllMarks;
|
|
3129
|
+
declare const index$2_unsetMark: typeof unsetMark;
|
|
3130
|
+
declare const index$2_updateAttributes: typeof updateAttributes;
|
|
3131
|
+
declare const index$2_wrapIn: typeof wrapIn;
|
|
3132
|
+
declare const index$2_wrapInList: typeof wrapInList;
|
|
3133
|
+
declare namespace index$2 {
|
|
3134
|
+
export { type index$2_InsertContentAtOptions as InsertContentAtOptions, type index$2_InsertContentOptions as InsertContentOptions, type index$2_SetContentOptions as SetContentOptions, index$2_blur as blur, index$2_clearContent as clearContent, index$2_clearNodes as clearNodes, index$2_command as command, index$2_createParagraphNear as createParagraphNear, index$2_cut as cut, index$2_deleteCurrentNode as deleteCurrentNode, index$2_deleteNode as deleteNode, index$2_deleteRange as deleteRange, index$2_deleteSelection as deleteSelection, index$2_enter as enter, index$2_exitCode as exitCode, index$2_extendMarkRange as extendMarkRange, index$2_first as first, index$2_focus as focus, index$2_forEach as forEach, index$2_insertContent as insertContent, index$2_insertContentAt as insertContentAt, index$2_joinBackward as joinBackward, index$2_joinDown as joinDown, index$2_joinForward as joinForward, index$2_joinItemBackward as joinItemBackward, index$2_joinItemForward as joinItemForward, index$2_joinTextblockBackward as joinTextblockBackward, index$2_joinTextblockForward as joinTextblockForward, index$2_joinUp as joinUp, index$2_keyboardShortcut as keyboardShortcut, index$2_lift as lift, index$2_liftEmptyBlock as liftEmptyBlock, index$2_liftListItem as liftListItem, index$2_newlineInCode as newlineInCode, index$2_resetAttributes as resetAttributes, index$2_scrollIntoView as scrollIntoView, index$2_selectAll as selectAll, index$2_selectNodeBackward as selectNodeBackward, index$2_selectNodeForward as selectNodeForward, index$2_selectParentNode as selectParentNode, index$2_selectTextblockEnd as selectTextblockEnd, index$2_selectTextblockStart as selectTextblockStart, index$2_setContent as setContent, index$2_setMark as setMark, index$2_setMeta as setMeta, index$2_setNode as setNode, index$2_setNodeSelection as setNodeSelection, index$2_setTextSelection as setTextSelection, index$2_sinkListItem as sinkListItem, index$2_splitBlock as splitBlock, index$2_splitListItem as splitListItem, index$2_toggleList as toggleList, index$2_toggleMark as toggleMark, index$2_toggleNode as toggleNode, index$2_toggleWrap as toggleWrap, index$2_undoInputRule as undoInputRule, index$2_unsetAllMarks as unsetAllMarks, index$2_unsetMark as unsetMark, index$2_updateAttributes as updateAttributes, index$2_wrapIn as wrapIn, index$2_wrapInList as wrapInList };
|
|
3135
|
+
}
|
|
3136
|
+
|
|
3137
|
+
declare const Commands$1: Extension<any, any>;
|
|
3138
|
+
|
|
3139
|
+
/**
|
|
3140
|
+
* This extension allows you to be notified when the user deletes content you are interested in.
|
|
3141
|
+
*/
|
|
3142
|
+
declare const Delete: Extension<any, any>;
|
|
3143
|
+
|
|
3144
|
+
declare const Drop: Extension<any, any>;
|
|
3145
|
+
|
|
3146
|
+
declare const Editable: Extension<any, any>;
|
|
3147
|
+
|
|
3148
|
+
declare const focusEventsPluginKey: PluginKey<any>;
|
|
3149
|
+
declare const FocusEvents: Extension<any, any>;
|
|
3150
|
+
|
|
3151
|
+
declare const Keymap: Extension<any, any>;
|
|
3152
|
+
|
|
3153
|
+
declare const Paste: Extension<any, any>;
|
|
3154
|
+
|
|
3155
|
+
declare const Tabindex: Extension<any, any>;
|
|
3156
|
+
|
|
3157
|
+
declare const index$1_ClipboardTextSerializer: typeof ClipboardTextSerializer;
|
|
3158
|
+
declare const index$1_Delete: typeof Delete;
|
|
3159
|
+
declare const index$1_Drop: typeof Drop;
|
|
3160
|
+
declare const index$1_Editable: typeof Editable;
|
|
3161
|
+
declare const index$1_FocusEvents: typeof FocusEvents;
|
|
3162
|
+
declare const index$1_Keymap: typeof Keymap;
|
|
3163
|
+
declare const index$1_Paste: typeof Paste;
|
|
3164
|
+
declare const index$1_Tabindex: typeof Tabindex;
|
|
3165
|
+
declare const index$1_focusEventsPluginKey: typeof focusEventsPluginKey;
|
|
3166
|
+
declare namespace index$1 {
|
|
3167
|
+
export { index$1_ClipboardTextSerializer as ClipboardTextSerializer, Commands$1 as Commands, index$1_Delete as Delete, index$1_Drop as Drop, index$1_Editable as Editable, index$1_FocusEvents as FocusEvents, index$1_Keymap as Keymap, index$1_Paste as Paste, index$1_Tabindex as Tabindex, index$1_focusEventsPluginKey as focusEventsPluginKey };
|
|
3168
|
+
}
|
|
3169
|
+
|
|
3170
|
+
interface TiptapEditorHTMLElement extends HTMLElement {
|
|
3171
|
+
editor?: SlideEditor;
|
|
3172
|
+
}
|
|
3173
|
+
declare class SlideEditor extends EventEmitter<EditorEvents> {
|
|
3174
|
+
private commandManager;
|
|
3175
|
+
extensionManager: ExtensionManager;
|
|
3176
|
+
private css;
|
|
3177
|
+
schema: Schema;
|
|
3178
|
+
private editorView;
|
|
3179
|
+
isFocused: boolean;
|
|
3180
|
+
private editorState;
|
|
3181
|
+
/**
|
|
3182
|
+
* The editor is considered initialized after the `create` event has been emitted.
|
|
3183
|
+
*/
|
|
3184
|
+
isInitialized: boolean;
|
|
3185
|
+
extensionStorage: Storage;
|
|
3186
|
+
/**
|
|
3187
|
+
* Resolved editor theme (null if no theme applied)
|
|
3188
|
+
*/
|
|
3189
|
+
private resolvedTheme;
|
|
3190
|
+
/**
|
|
3191
|
+
* A unique ID for this editor instance.
|
|
3192
|
+
*/
|
|
3193
|
+
instanceId: string;
|
|
3194
|
+
options: EditorOptions;
|
|
3195
|
+
constructor(options?: Partial<EditorOptions>);
|
|
3196
|
+
/**
|
|
3197
|
+
* Attach the editor to the DOM, creating a new editor view.
|
|
3198
|
+
*/
|
|
3199
|
+
mount(el: NonNullable<EditorOptions["element"]> & {}): void;
|
|
3200
|
+
/**
|
|
3201
|
+
* Remove the editor from the DOM, but still allow remounting at a different point in time
|
|
3202
|
+
*/
|
|
3203
|
+
unmount(): void;
|
|
3204
|
+
/**
|
|
3205
|
+
* Returns the editor storage.
|
|
3206
|
+
*/
|
|
3207
|
+
get storage(): Storage;
|
|
3208
|
+
/**
|
|
3209
|
+
* An object of all registered commands.
|
|
3210
|
+
*/
|
|
3211
|
+
get commands(): SingleCommands;
|
|
3212
|
+
/**
|
|
3213
|
+
* Create a command chain to call multiple commands at once.
|
|
3214
|
+
*/
|
|
3215
|
+
chain(): ChainedCommands;
|
|
3216
|
+
/**
|
|
3217
|
+
* Check if a command or a command chain can be executed. Without executing it.
|
|
3218
|
+
*/
|
|
3219
|
+
can(): CanCommands;
|
|
3220
|
+
/**
|
|
3221
|
+
* Inject CSS styles.
|
|
3222
|
+
*/
|
|
3223
|
+
private injectCSS;
|
|
3224
|
+
/**
|
|
3225
|
+
* Update editor options.
|
|
3226
|
+
*
|
|
3227
|
+
* @param options A list of options
|
|
3228
|
+
*/
|
|
3229
|
+
setOptions(options?: Partial<EditorOptions>): void;
|
|
3230
|
+
/**
|
|
3231
|
+
* Update editable state of the editor.
|
|
3232
|
+
*/
|
|
3233
|
+
setEditable(editable: boolean, emitUpdate?: boolean): void;
|
|
3234
|
+
/**
|
|
3235
|
+
* Returns whether the editor is editable.
|
|
3236
|
+
*/
|
|
3237
|
+
get isEditable(): boolean;
|
|
3238
|
+
/**
|
|
3239
|
+
* Returns the editor state.
|
|
3240
|
+
*/
|
|
3241
|
+
get view(): EditorView;
|
|
3242
|
+
/**
|
|
3243
|
+
* Returns the editor state.
|
|
3244
|
+
*/
|
|
3245
|
+
get state(): EditorState;
|
|
3246
|
+
/**
|
|
3247
|
+
* Register a ProseMirror plugin.
|
|
3248
|
+
*
|
|
3249
|
+
* @param plugin A ProseMirror plugin
|
|
3250
|
+
* @param handlePlugins Control how to merge the plugin into the existing plugins.
|
|
3251
|
+
* @returns The new editor state
|
|
3252
|
+
*/
|
|
3253
|
+
registerPlugin(plugin: Plugin, handlePlugins?: (newPlugin: Plugin, plugins: Plugin[]) => Plugin[]): EditorState;
|
|
3254
|
+
/**
|
|
3255
|
+
* Unregister a ProseMirror plugin.
|
|
3256
|
+
*
|
|
3257
|
+
* @param nameOrPluginKeyToRemove The plugins name
|
|
3258
|
+
* @returns The new editor state or undefined if the editor is destroyed
|
|
3259
|
+
*/
|
|
3260
|
+
unregisterPlugin(nameOrPluginKeyToRemove: string | PluginKey | (string | PluginKey)[]): EditorState | undefined;
|
|
3261
|
+
/**
|
|
3262
|
+
* Creates an extension manager.
|
|
3263
|
+
*/
|
|
3264
|
+
private createExtensionManager;
|
|
3265
|
+
/**
|
|
3266
|
+
* Creates an command manager.
|
|
3267
|
+
*/
|
|
3268
|
+
private createCommandManager;
|
|
3269
|
+
/**
|
|
3270
|
+
* Creates a ProseMirror schema.
|
|
3271
|
+
*/
|
|
3272
|
+
private createSchema;
|
|
3273
|
+
/**
|
|
3274
|
+
* Creates the initial document.
|
|
3275
|
+
*/
|
|
3276
|
+
private createDoc;
|
|
3277
|
+
/**
|
|
3278
|
+
* Creates a ProseMirror view.
|
|
3279
|
+
*/
|
|
3280
|
+
private createView;
|
|
3281
|
+
/**
|
|
3282
|
+
* Creates all node and mark views.
|
|
3283
|
+
*/
|
|
3284
|
+
createNodeViews(): void;
|
|
3285
|
+
/**
|
|
3286
|
+
* Prepend class name to element.
|
|
3287
|
+
*/
|
|
3288
|
+
prependClass(): void;
|
|
3289
|
+
isCapturingTransaction: boolean;
|
|
3290
|
+
private capturedTransaction;
|
|
3291
|
+
captureTransaction(fn: () => void): Transaction | null;
|
|
3292
|
+
/**
|
|
3293
|
+
* The callback over which to send transactions (state updates) produced by the view.
|
|
3294
|
+
*
|
|
3295
|
+
* @param transaction An editor state transaction
|
|
3296
|
+
*/
|
|
3297
|
+
private dispatchTransaction;
|
|
3298
|
+
/**
|
|
3299
|
+
* Get attributes of the currently selected node or mark.
|
|
3300
|
+
*/
|
|
3301
|
+
getAttributes(nameOrType: string | NodeType$1 | MarkType$1): Record<string, any>;
|
|
3302
|
+
/**
|
|
3303
|
+
* Returns if the currently selected node or mark is active.
|
|
3304
|
+
*
|
|
3305
|
+
* @param name Name of the node or mark
|
|
3306
|
+
* @param attributes Attributes of the node or mark
|
|
3307
|
+
*/
|
|
3308
|
+
isActive(name: string, attributes?: {}): boolean;
|
|
3309
|
+
isActive(attributes: {}): boolean;
|
|
3310
|
+
/**
|
|
3311
|
+
* Get the document as JSON.
|
|
3312
|
+
*/
|
|
3313
|
+
getJSON(): DocumentType<Record<string, any> | undefined, NodeType<string, undefined | Record<string, any>, any, (NodeType | TextType)[]>[]>;
|
|
3314
|
+
/**
|
|
3315
|
+
* Get the document as HTML.
|
|
3316
|
+
*/
|
|
3317
|
+
getHTML(): string;
|
|
3318
|
+
/**
|
|
3319
|
+
* Get the document as text.
|
|
3320
|
+
*/
|
|
3321
|
+
getText(options?: {
|
|
3322
|
+
blockSeparator?: string;
|
|
3323
|
+
textSerializers?: Record<string, TextSerializer>;
|
|
3324
|
+
}): string;
|
|
3325
|
+
/**
|
|
3326
|
+
* Check if there is no content.
|
|
3327
|
+
*/
|
|
3328
|
+
get isEmpty(): boolean;
|
|
3329
|
+
/**
|
|
3330
|
+
* Set or change the editor theme
|
|
3331
|
+
*
|
|
3332
|
+
* @param theme - Theme to apply (string, full theme object, or partial theme)
|
|
3333
|
+
*
|
|
3334
|
+
* @example
|
|
3335
|
+
* // Switch to built-in dark theme
|
|
3336
|
+
* editor.setTheme('dark');
|
|
3337
|
+
*
|
|
3338
|
+
* @example
|
|
3339
|
+
* // Apply custom theme
|
|
3340
|
+
* editor.setTheme({
|
|
3341
|
+
* extends: 'dark',
|
|
3342
|
+
* colors: { background: '#0a0a0a' }
|
|
3343
|
+
* });
|
|
3344
|
+
*/
|
|
3345
|
+
setTheme(theme: typeof this$1.options.theme): void;
|
|
3346
|
+
/**
|
|
3347
|
+
* Get the current theme
|
|
3348
|
+
*
|
|
3349
|
+
* @returns Current resolved theme (null if no theme applied)
|
|
3350
|
+
*/
|
|
3351
|
+
getTheme(): ResolvedTheme;
|
|
3352
|
+
/**
|
|
3353
|
+
* Destroy the editor.
|
|
3354
|
+
*/
|
|
3355
|
+
destroy(): void;
|
|
3356
|
+
/**
|
|
3357
|
+
* Check if the editor is already destroyed.
|
|
3358
|
+
*/
|
|
3359
|
+
get isDestroyed(): boolean;
|
|
3360
|
+
$node(selector: string, attributes?: {
|
|
3361
|
+
[key: string]: any;
|
|
3362
|
+
}): NodePos | null;
|
|
3363
|
+
$nodes(selector: string, attributes?: {
|
|
3364
|
+
[key: string]: any;
|
|
3365
|
+
}): NodePos[] | null;
|
|
3366
|
+
$pos(pos: number): NodePos;
|
|
3367
|
+
get $doc(): NodePos;
|
|
3368
|
+
}
|
|
3369
|
+
|
|
3370
|
+
declare class CommandManager {
|
|
3371
|
+
editor: SlideEditor;
|
|
3372
|
+
rawCommands: AnyCommands;
|
|
3373
|
+
customState?: EditorState;
|
|
3374
|
+
constructor(props: {
|
|
3375
|
+
editor: SlideEditor;
|
|
3376
|
+
state?: EditorState;
|
|
3377
|
+
});
|
|
3378
|
+
get hasCustomState(): boolean;
|
|
3379
|
+
get state(): EditorState;
|
|
3380
|
+
get commands(): SingleCommands;
|
|
3381
|
+
get chain(): () => ChainedCommands;
|
|
3382
|
+
get can(): () => CanCommands;
|
|
3383
|
+
createChain(startTr?: Transaction, shouldDispatch?: boolean): ChainedCommands;
|
|
3384
|
+
createCan(startTr?: Transaction): CanCommands;
|
|
3385
|
+
buildProps(tr: Transaction, shouldDispatch?: boolean): CommandProps;
|
|
3386
|
+
}
|
|
3387
|
+
|
|
3388
|
+
/**
|
|
3389
|
+
* Build an input rule that adds a mark when the
|
|
3390
|
+
* matched text is typed into it.
|
|
3391
|
+
* @see https://tiptap.dev/docs/editor/extensions/custom-extensions/extend-existing#input-rules
|
|
3392
|
+
*/
|
|
3393
|
+
declare function markInputRule(config: {
|
|
3394
|
+
find: InputRuleFinder;
|
|
3395
|
+
type: MarkType$1;
|
|
3396
|
+
undoable?: boolean;
|
|
3397
|
+
getAttributes?: Record<string, any> | ((match: ExtendedRegExpMatchArray) => Record<string, any>) | false | null;
|
|
3398
|
+
}): InputRule;
|
|
3399
|
+
|
|
3400
|
+
/**
|
|
3401
|
+
* Build an input rule that adds a node when the
|
|
3402
|
+
* matched text is typed into it.
|
|
3403
|
+
* @see https://tiptap.dev/docs/editor/extensions/custom-extensions/extend-existing#input-rules
|
|
3404
|
+
*/
|
|
3405
|
+
declare function nodeInputRule(config: {
|
|
3406
|
+
/**
|
|
3407
|
+
* The regex to match.
|
|
3408
|
+
*/
|
|
3409
|
+
find: InputRuleFinder;
|
|
3410
|
+
/**
|
|
3411
|
+
* The node type to add.
|
|
3412
|
+
*/
|
|
3413
|
+
type: NodeType$1;
|
|
3414
|
+
/**
|
|
3415
|
+
* Whether the input rule should be undoable
|
|
3416
|
+
* when the user presses backspace.
|
|
3417
|
+
*/
|
|
3418
|
+
undoable?: boolean;
|
|
3419
|
+
/**
|
|
3420
|
+
* A function that returns the attributes for the node
|
|
3421
|
+
* can also be an object of attributes
|
|
3422
|
+
*/
|
|
3423
|
+
getAttributes?: Record<string, any> | ((match: ExtendedRegExpMatchArray) => Record<string, any>) | false | null;
|
|
3424
|
+
}): InputRule;
|
|
3425
|
+
|
|
3426
|
+
/**
|
|
3427
|
+
* Build an input rule that changes the type of a textblock when the
|
|
3428
|
+
* matched text is typed into it. When using a regular expresion you’ll
|
|
3429
|
+
* probably want the regexp to start with `^`, so that the pattern can
|
|
3430
|
+
* only occur at the start of a textblock.
|
|
3431
|
+
* @see https://tiptap.dev/docs/editor/extensions/custom-extensions/extend-existing#input-rules
|
|
3432
|
+
*/
|
|
3433
|
+
declare function textblockTypeInputRule(config: {
|
|
3434
|
+
find: InputRuleFinder;
|
|
3435
|
+
type: NodeType$1;
|
|
3436
|
+
undoable?: boolean;
|
|
3437
|
+
getAttributes?: Record<string, any> | ((match: ExtendedRegExpMatchArray) => Record<string, any>) | false | null;
|
|
3438
|
+
}): InputRule;
|
|
3439
|
+
|
|
3440
|
+
/**
|
|
3441
|
+
* Build an input rule that replaces text when the
|
|
3442
|
+
* matched text is typed into it.
|
|
3443
|
+
* @see https://tiptap.dev/docs/editor/extensions/custom-extensions/extend-existing#input-rules
|
|
3444
|
+
*/
|
|
3445
|
+
declare function textInputRule(config: {
|
|
3446
|
+
find: InputRuleFinder;
|
|
3447
|
+
replace: string;
|
|
3448
|
+
undoable?: boolean;
|
|
3449
|
+
}): InputRule;
|
|
3450
|
+
|
|
3451
|
+
/**
|
|
3452
|
+
* Build an input rule for automatically wrapping a textblock when a
|
|
3453
|
+
* given string is typed. When using a regular expresion you’ll
|
|
3454
|
+
* probably want the regexp to start with `^`, so that the pattern can
|
|
3455
|
+
* only occur at the start of a textblock.
|
|
3456
|
+
*
|
|
3457
|
+
* `type` is the type of node to wrap in.
|
|
3458
|
+
*
|
|
3459
|
+
* By default, if there’s a node with the same type above the newly
|
|
3460
|
+
* wrapped node, the rule will try to join those
|
|
3461
|
+
* two nodes. You can pass a join predicate, which takes a regular
|
|
3462
|
+
* expression match and the node before the wrapped node, and can
|
|
3463
|
+
* return a boolean to indicate whether a join should happen.
|
|
3464
|
+
* @see https://tiptap.dev/docs/editor/extensions/custom-extensions/extend-existing#input-rules
|
|
3465
|
+
*/
|
|
3466
|
+
declare function wrappingInputRule(config: {
|
|
3467
|
+
find: InputRuleFinder;
|
|
3468
|
+
type: NodeType$1;
|
|
3469
|
+
keepMarks?: boolean;
|
|
3470
|
+
keepAttributes?: boolean;
|
|
3471
|
+
editor?: SlideEditor;
|
|
3472
|
+
undoable?: boolean;
|
|
3473
|
+
getAttributes?: Record<string, any> | ((match: ExtendedRegExpMatchArray) => Record<string, any>) | false | null;
|
|
3474
|
+
joinPredicate?: (match: ExtendedRegExpMatchArray, node: Node$1) => boolean;
|
|
3475
|
+
}): InputRule;
|
|
3476
|
+
|
|
3477
|
+
type Attributes = Record<string, any>;
|
|
3478
|
+
type DOMOutputSpecElement = 0 | Attributes | DOMOutputSpecArray;
|
|
3479
|
+
/**
|
|
3480
|
+
* Better describes the output of a `renderHTML` function in prosemirror
|
|
3481
|
+
* @see https://prosemirror.net/docs/ref/#model.DOMOutputSpec
|
|
3482
|
+
*/
|
|
3483
|
+
type DOMOutputSpecArray = [string] | [string, Attributes] | [string, 0] | [string, Attributes, 0] | [string, Attributes, DOMOutputSpecArray | 0] | [string, DOMOutputSpecArray];
|
|
3484
|
+
type JSXRenderer = (tag: 'slot' | string | ((props?: Attributes) => DOMOutputSpecArray | DOMOutputSpecElement), props?: Attributes, ...children: JSXRenderer[]) => DOMOutputSpecArray | DOMOutputSpecElement;
|
|
3485
|
+
declare function Fragment(props: {
|
|
3486
|
+
children: JSXRenderer[];
|
|
3487
|
+
}): JSXRenderer[];
|
|
3488
|
+
declare const h: JSXRenderer;
|
|
3489
|
+
|
|
3490
|
+
declare function updateMarkViewAttributes(checkMark: Mark$1, editor: SlideEditor, attrs?: Record<string, any>): void;
|
|
3491
|
+
declare class MarkView<Component, Options extends MarkViewRendererOptions = MarkViewRendererOptions> {
|
|
3492
|
+
component: Component;
|
|
3493
|
+
editor: SlideEditor;
|
|
3494
|
+
options: Options;
|
|
3495
|
+
mark: MarkViewProps["mark"];
|
|
3496
|
+
HTMLAttributes: MarkViewProps["HTMLAttributes"];
|
|
3497
|
+
constructor(component: Component, props: MarkViewProps, options?: Partial<Options>);
|
|
3498
|
+
get dom(): HTMLElement;
|
|
3499
|
+
get contentDOM(): HTMLElement | null;
|
|
3500
|
+
/**
|
|
3501
|
+
* Update the attributes of the mark in the document.
|
|
3502
|
+
* @param attrs The attributes to update.
|
|
3503
|
+
*/
|
|
3504
|
+
updateAttributes(attrs: Record<string, any>, checkMark?: Mark$1): void;
|
|
3505
|
+
ignoreMutation(mutation: ViewMutationRecord): boolean;
|
|
3506
|
+
}
|
|
3507
|
+
|
|
3508
|
+
declare class NodeView<Component, NodeEditor extends SlideEditor = SlideEditor, Options extends NodeViewRendererOptions = NodeViewRendererOptions> implements NodeView$1 {
|
|
3509
|
+
component: Component;
|
|
3510
|
+
editor: NodeEditor;
|
|
3511
|
+
options: Options;
|
|
3512
|
+
extension: NodeViewRendererProps["extension"];
|
|
3513
|
+
node: NodeViewRendererProps["node"];
|
|
3514
|
+
decorations: NodeViewRendererProps["decorations"];
|
|
3515
|
+
innerDecorations: NodeViewRendererProps["innerDecorations"];
|
|
3516
|
+
view: NodeViewRendererProps["view"];
|
|
3517
|
+
getPos: NodeViewRendererProps["getPos"];
|
|
3518
|
+
HTMLAttributes: NodeViewRendererProps["HTMLAttributes"];
|
|
3519
|
+
isDragging: boolean;
|
|
3520
|
+
constructor(component: Component, props: NodeViewRendererProps, options?: Partial<Options>);
|
|
3521
|
+
mount(): void;
|
|
3522
|
+
get dom(): HTMLElement;
|
|
3523
|
+
get contentDOM(): HTMLElement | null;
|
|
3524
|
+
onDragStart(event: DragEvent): void;
|
|
3525
|
+
stopEvent(event: Event): boolean;
|
|
3526
|
+
/**
|
|
3527
|
+
* Called when a DOM [mutation](https://developer.mozilla.org/en-US/docs/Web/API/MutationObserver) or a selection change happens within the view.
|
|
3528
|
+
* @return `false` if the editor should re-read the selection or re-parse the range around the mutation
|
|
3529
|
+
* @return `true` if it can safely be ignored.
|
|
3530
|
+
*/
|
|
3531
|
+
ignoreMutation(mutation: ViewMutationRecord): boolean;
|
|
3532
|
+
/**
|
|
3533
|
+
* Update the attributes of the prosemirror node.
|
|
3534
|
+
*/
|
|
3535
|
+
updateAttributes(attributes: Record<string, any>): void;
|
|
3536
|
+
/**
|
|
3537
|
+
* Delete the node.
|
|
3538
|
+
*/
|
|
3539
|
+
deleteNode(): void;
|
|
3540
|
+
}
|
|
3541
|
+
|
|
3542
|
+
/**
|
|
3543
|
+
* Build an paste rule that adds a mark when the
|
|
3544
|
+
* matched text is pasted into it.
|
|
3545
|
+
* @see https://tiptap.dev/docs/editor/extensions/custom-extensions/extend-existing#paste-rules
|
|
3546
|
+
*/
|
|
3547
|
+
declare function markPasteRule(config: {
|
|
3548
|
+
find: PasteRuleFinder;
|
|
3549
|
+
type: MarkType$1;
|
|
3550
|
+
getAttributes?: Record<string, any> | ((match: ExtendedRegExpMatchArray, event: ClipboardEvent) => Record<string, any>) | false | null;
|
|
3551
|
+
}): PasteRule;
|
|
3552
|
+
|
|
3553
|
+
/**
|
|
3554
|
+
* Build an paste rule that adds a node when the
|
|
3555
|
+
* matched text is pasted into it.
|
|
3556
|
+
* @see https://tiptap.dev/docs/editor/api/paste-rules
|
|
3557
|
+
*/
|
|
3558
|
+
declare function nodePasteRule(config: {
|
|
3559
|
+
find: PasteRuleFinder;
|
|
3560
|
+
type: NodeType$1;
|
|
3561
|
+
getAttributes?: Record<string, any> | ((match: ExtendedRegExpMatchArray, event: ClipboardEvent) => Record<string, any>) | false | null;
|
|
3562
|
+
getContent?: JSONContent[] | ((attrs: Record<string, any>) => JSONContent[]) | false | null;
|
|
3563
|
+
}): PasteRule;
|
|
3564
|
+
|
|
3565
|
+
/**
|
|
3566
|
+
* Build an paste rule that replaces text when the
|
|
3567
|
+
* matched text is pasted into it.
|
|
3568
|
+
* @see https://tiptap.dev/docs/editor/extensions/custom-extensions/extend-existing#paste-rules
|
|
3569
|
+
*/
|
|
3570
|
+
declare function textPasteRule(config: {
|
|
3571
|
+
find: PasteRuleFinder;
|
|
3572
|
+
replace: string;
|
|
3573
|
+
}): PasteRule;
|
|
3574
|
+
|
|
3575
|
+
interface TrackerResult {
|
|
3576
|
+
position: number;
|
|
3577
|
+
deleted: boolean;
|
|
3578
|
+
}
|
|
3579
|
+
declare class Tracker {
|
|
3580
|
+
transaction: Transaction;
|
|
3581
|
+
currentStep: number;
|
|
3582
|
+
constructor(transaction: Transaction);
|
|
3583
|
+
map(position: number): TrackerResult;
|
|
3584
|
+
}
|
|
3585
|
+
|
|
3586
|
+
/**
|
|
3587
|
+
* Optionally calls `value` as a function.
|
|
3588
|
+
* Otherwise it is returned directly.
|
|
3589
|
+
* @param value Function or any value.
|
|
3590
|
+
* @param context Optional context to bind to function.
|
|
3591
|
+
* @param props Optional props to pass to function.
|
|
3592
|
+
*/
|
|
3593
|
+
declare function callOrReturn<T>(value: T, context?: any, ...props: any[]): MaybeReturnType<T>;
|
|
3594
|
+
|
|
3595
|
+
declare function canInsertNode(state: EditorState, nodeType: NodeType$1): boolean;
|
|
3596
|
+
|
|
3597
|
+
declare function createStyleTag(style: string, nonce?: string, suffix?: string): HTMLStyleElement;
|
|
3598
|
+
|
|
3599
|
+
/**
|
|
3600
|
+
* Remove a property or an array of properties from an object
|
|
3601
|
+
* @param obj Object
|
|
3602
|
+
* @param key Key to remove
|
|
3603
|
+
*/
|
|
3604
|
+
declare function deleteProps(obj: Record<string, any>, propOrProps: string | string[]): Record<string, any>;
|
|
3605
|
+
|
|
3606
|
+
declare function elementFromString(value: string): HTMLElement;
|
|
3607
|
+
|
|
3608
|
+
declare function escapeForRegEx(string: string): string;
|
|
3609
|
+
|
|
3610
|
+
/**
|
|
3611
|
+
* Find duplicates in an array.
|
|
3612
|
+
*/
|
|
3613
|
+
declare function findDuplicates<T>(items: T[]): T[];
|
|
3614
|
+
|
|
3615
|
+
declare function fromString(value: any): any;
|
|
3616
|
+
|
|
3617
|
+
declare function isAndroid(): boolean;
|
|
3618
|
+
|
|
3619
|
+
declare function isEmptyObject(value?: {}): boolean;
|
|
3620
|
+
|
|
3621
|
+
declare function isFunction(value: any): value is Function;
|
|
3622
|
+
|
|
3623
|
+
declare function isiOS(): boolean;
|
|
3624
|
+
|
|
3625
|
+
declare function isMacOS(): boolean;
|
|
3626
|
+
|
|
3627
|
+
declare function isNumber(value: any): value is number;
|
|
3628
|
+
|
|
3629
|
+
declare function isPlainObject(value: any): value is Record<string, any>;
|
|
3630
|
+
|
|
3631
|
+
declare function isRegExp(value: any): value is RegExp;
|
|
3632
|
+
|
|
3633
|
+
declare function isString(value: any): value is string;
|
|
3634
|
+
|
|
3635
|
+
/**
|
|
3636
|
+
* Layout Parser Utility
|
|
3637
|
+
*
|
|
3638
|
+
* Parses layout strings like '2-1' or '1-1-1' and applies flex ratios to columns.
|
|
3639
|
+
* Handles validation and provides graceful fallback to equal distribution.
|
|
3640
|
+
*
|
|
3641
|
+
* Examples:
|
|
3642
|
+
* - '1' → single column at 100%
|
|
3643
|
+
* - '1-1' → two equal columns (50/50)
|
|
3644
|
+
* - '2-1' → two columns (66.66% / 33.33%)
|
|
3645
|
+
* - '1-2-1' → three columns (25% / 50% / 25%)
|
|
3646
|
+
* - '5-3-2' → three columns (50% / 30% / 20%)
|
|
3647
|
+
*/
|
|
3648
|
+
/**
|
|
3649
|
+
* Parses a layout string and returns flex ratios for each column
|
|
3650
|
+
*
|
|
3651
|
+
* @param layout - Layout string (e.g., '2-1', '1-1-1')
|
|
3652
|
+
* @param columnCount - Number of columns in the row
|
|
3653
|
+
* @returns Array of flex ratio numbers
|
|
3654
|
+
*
|
|
3655
|
+
* @example
|
|
3656
|
+
* parseLayout('2-1', 2) // Returns [2, 1]
|
|
3657
|
+
* parseLayout('1-1-1', 3) // Returns [1, 1, 1]
|
|
3658
|
+
* parseLayout('invalid', 2) // Returns [1, 1] with console warning
|
|
3659
|
+
*/
|
|
3660
|
+
declare function parseLayout(layout: string, columnCount: number): number[];
|
|
3661
|
+
/**
|
|
3662
|
+
* Applies layout ratios to a row's columns by setting flex values
|
|
3663
|
+
*
|
|
3664
|
+
* @param rowElement - The DOM element for the row
|
|
3665
|
+
* @param layout - Layout string (e.g., '2-1')
|
|
3666
|
+
*
|
|
3667
|
+
* @example
|
|
3668
|
+
* const row = document.querySelector('[data-node-type="row"]');
|
|
3669
|
+
* applyLayoutToRow(row, '2-1');
|
|
3670
|
+
* // First column will have flex: 2 1 0%
|
|
3671
|
+
* // Second column will have flex: 1 1 0%
|
|
3672
|
+
*/
|
|
3673
|
+
declare function applyLayoutToRow(rowElement: HTMLElement, layout: string): void;
|
|
3674
|
+
/**
|
|
3675
|
+
* Applies layouts to all rows in the editor
|
|
3676
|
+
* Should be called after editor mount and after content updates
|
|
3677
|
+
*
|
|
3678
|
+
* @param editorElement - The root editor DOM element
|
|
3679
|
+
*/
|
|
3680
|
+
declare function applyAllLayouts(editorElement: HTMLElement): void;
|
|
3681
|
+
|
|
3682
|
+
/**
|
|
3683
|
+
* @fileoverview Utility functions for parsing and serializing markdown attributes.
|
|
3684
|
+
*
|
|
3685
|
+
* These utilities handle the common patterns for parsing attribute strings
|
|
3686
|
+
* in various markdown syntaxes like Pandoc attributes.
|
|
3687
|
+
*/
|
|
3688
|
+
/**
|
|
3689
|
+
* Parses a Pandoc-style attribute string into an object.
|
|
3690
|
+
*
|
|
3691
|
+
* Supports the following patterns:
|
|
3692
|
+
* - Classes: `.className` → `{ class: 'className' }`
|
|
3693
|
+
* - IDs: `#myId` → `{ id: 'myId' }`
|
|
3694
|
+
* - Key-value pairs: `key="value"` → `{ key: 'value' }`
|
|
3695
|
+
* - Boolean attributes: `disabled` → `{ disabled: true }`
|
|
3696
|
+
*
|
|
3697
|
+
* @param attrString - The attribute string to parse
|
|
3698
|
+
* @returns Parsed attributes object
|
|
3699
|
+
*
|
|
3700
|
+
* @example
|
|
3701
|
+
* ```ts
|
|
3702
|
+
* parseAttributes('.btn #submit disabled type="button"')
|
|
3703
|
+
* // → { class: 'btn', id: 'submit', disabled: true, type: 'button' }
|
|
3704
|
+
* ```
|
|
3705
|
+
*/
|
|
3706
|
+
declare function parseAttributes(attrString: string): Record<string, any>;
|
|
3707
|
+
/**
|
|
3708
|
+
* Serializes an attributes object back to a Pandoc-style attribute string.
|
|
3709
|
+
*
|
|
3710
|
+
* @param attributes - The attributes object to serialize
|
|
3711
|
+
* @returns Serialized attribute string
|
|
3712
|
+
*
|
|
3713
|
+
* @example
|
|
3714
|
+
* ```ts
|
|
3715
|
+
* serializeAttributes({ class: 'btn primary', id: 'submit', disabled: true, type: 'button' })
|
|
3716
|
+
* // → '.btn.primary #submit disabled type="button"'
|
|
3717
|
+
* ```
|
|
3718
|
+
*/
|
|
3719
|
+
declare function serializeAttributes(attributes: Record<string, any>): string;
|
|
3720
|
+
|
|
3721
|
+
interface AtomBlockMarkdownSpecOptions {
|
|
3722
|
+
/** The Tiptap node name this spec is for */
|
|
3723
|
+
nodeName: string;
|
|
3724
|
+
/** The markdown syntax name (defaults to nodeName if not provided) */
|
|
3725
|
+
name?: string;
|
|
3726
|
+
/** Function to parse attributes from token attribute string */
|
|
3727
|
+
parseAttributes?: (attrString: string) => Record<string, any>;
|
|
3728
|
+
/** Function to serialize attributes back to string for rendering */
|
|
3729
|
+
serializeAttributes?: (attrs: Record<string, any>) => string;
|
|
3730
|
+
/** Default attributes to apply when parsing */
|
|
3731
|
+
defaultAttributes?: Record<string, any>;
|
|
3732
|
+
/** Required attributes that must be present for successful parsing */
|
|
3733
|
+
requiredAttributes?: string[];
|
|
3734
|
+
/** Attributes that are allowed to be rendered back to markdown (whitelist) */
|
|
3735
|
+
allowedAttributes?: string[];
|
|
3736
|
+
}
|
|
3737
|
+
/**
|
|
3738
|
+
* Creates a complete markdown spec for atomic block nodes using Pandoc syntax.
|
|
3739
|
+
*
|
|
3740
|
+
* The generated spec handles:
|
|
3741
|
+
* - Parsing self-closing blocks with `:::blockName {attributes}`
|
|
3742
|
+
* - Extracting and parsing attributes
|
|
3743
|
+
* - Validating required attributes
|
|
3744
|
+
* - Rendering blocks back to markdown
|
|
3745
|
+
*
|
|
3746
|
+
* @param options - Configuration for the atomic block markdown spec
|
|
3747
|
+
* @returns Complete markdown specification object
|
|
3748
|
+
*
|
|
3749
|
+
* @example
|
|
3750
|
+
* ```ts
|
|
3751
|
+
* const youtubeSpec = createAtomBlockMarkdownSpec({
|
|
3752
|
+
* nodeName: 'youtube',
|
|
3753
|
+
* requiredAttributes: ['src'],
|
|
3754
|
+
* defaultAttributes: { start: 0 },
|
|
3755
|
+
* allowedAttributes: ['src', 'start', 'width', 'height'] // Only these get rendered to markdown
|
|
3756
|
+
* })
|
|
3757
|
+
*
|
|
3758
|
+
* // Usage in extension:
|
|
3759
|
+
* export const Youtube = Node.create({
|
|
3760
|
+
* // ... other config
|
|
3761
|
+
* markdown: youtubeSpec
|
|
3762
|
+
* })
|
|
3763
|
+
* ```
|
|
3764
|
+
*/
|
|
3765
|
+
declare function createAtomBlockMarkdownSpec(options: AtomBlockMarkdownSpecOptions): {
|
|
3766
|
+
parseMarkdown: (token: MarkdownToken, h: MarkdownParseHelpers) => MarkdownParseResult;
|
|
3767
|
+
markdownTokenizer: MarkdownTokenizer;
|
|
3768
|
+
renderMarkdown: (node: JSONContent) => string;
|
|
3769
|
+
};
|
|
3770
|
+
|
|
3771
|
+
interface BlockMarkdownSpecOptions {
|
|
3772
|
+
/** The Tiptap node name this spec is for */
|
|
3773
|
+
nodeName: string;
|
|
3774
|
+
/** The markdown syntax name (defaults to nodeName if not provided) */
|
|
3775
|
+
name?: string;
|
|
3776
|
+
/** Function to extract content from the node for serialization */
|
|
3777
|
+
getContent?: (token: MarkdownToken) => string;
|
|
3778
|
+
/** Function to parse attributes from the attribute string */
|
|
3779
|
+
parseAttributes?: (attrString: string) => Record<string, any>;
|
|
3780
|
+
/** Function to serialize attributes to string */
|
|
3781
|
+
serializeAttributes?: (attrs: Record<string, any>) => string;
|
|
3782
|
+
/** Default attributes to apply when parsing */
|
|
3783
|
+
defaultAttributes?: Record<string, any>;
|
|
3784
|
+
/** Content type: 'block' allows paragraphs/lists/etc, 'inline' only allows bold/italic/links/etc */
|
|
3785
|
+
content?: 'block' | 'inline';
|
|
3786
|
+
/** Allowlist of attributes to include in markdown (if not provided, all attributes are included) */
|
|
3787
|
+
allowedAttributes?: string[];
|
|
3788
|
+
}
|
|
3789
|
+
/**
|
|
3790
|
+
* Creates a complete markdown spec for block-level nodes using Pandoc syntax.
|
|
3791
|
+
*
|
|
3792
|
+
* The generated spec handles:
|
|
3793
|
+
* - Parsing blocks with `:::blockName {attributes}` syntax
|
|
3794
|
+
* - Extracting and parsing attributes
|
|
3795
|
+
* - Rendering blocks back to markdown with proper formatting
|
|
3796
|
+
* - Nested content support
|
|
3797
|
+
*
|
|
3798
|
+
* @param options - Configuration for the block markdown spec
|
|
3799
|
+
* @returns Complete markdown specification object
|
|
3800
|
+
*
|
|
3801
|
+
* @example
|
|
3802
|
+
* ```ts
|
|
3803
|
+
* const calloutSpec = createBlockMarkdownSpec({
|
|
3804
|
+
* nodeName: 'callout',
|
|
3805
|
+
* defaultAttributes: { type: 'info' },
|
|
3806
|
+
* allowedAttributes: ['type', 'title'] // Only these get rendered to markdown
|
|
3807
|
+
* })
|
|
3808
|
+
*
|
|
3809
|
+
* // Usage in extension:
|
|
3810
|
+
* export const Callout = Node.create({
|
|
3811
|
+
* // ... other config
|
|
3812
|
+
* markdown: calloutSpec
|
|
3813
|
+
* })
|
|
3814
|
+
* ```
|
|
3815
|
+
*/
|
|
3816
|
+
declare function createBlockMarkdownSpec(options: BlockMarkdownSpecOptions): {
|
|
3817
|
+
parseMarkdown: (token: MarkdownToken, h: MarkdownParseHelpers) => MarkdownParseResult;
|
|
3818
|
+
markdownTokenizer: MarkdownTokenizer;
|
|
3819
|
+
renderMarkdown: (node: JSONContent, h: MarkdownRendererHelpers) => string;
|
|
3820
|
+
};
|
|
3821
|
+
|
|
3822
|
+
interface InlineMarkdownSpecOptions {
|
|
3823
|
+
/** The Tiptap node name this spec is for */
|
|
3824
|
+
nodeName: string;
|
|
3825
|
+
/** The shortcode name (defaults to nodeName if not provided) */
|
|
3826
|
+
name?: string;
|
|
3827
|
+
/** Function to extract content from the node for serialization */
|
|
3828
|
+
getContent?: (node: any) => string;
|
|
3829
|
+
/** Function to parse attributes from the attribute string */
|
|
3830
|
+
parseAttributes?: (attrString: string) => Record<string, any>;
|
|
3831
|
+
/** Function to serialize attributes to string */
|
|
3832
|
+
serializeAttributes?: (attrs: Record<string, any>) => string;
|
|
3833
|
+
/** Default attributes to apply when parsing */
|
|
3834
|
+
defaultAttributes?: Record<string, any>;
|
|
3835
|
+
/** Whether this is a self-closing shortcode (no content, like [emoji name=party]) */
|
|
3836
|
+
selfClosing?: boolean;
|
|
3837
|
+
/** Allowlist of attributes to include in markdown (if not provided, all attributes are included) */
|
|
3838
|
+
allowedAttributes?: string[];
|
|
3839
|
+
}
|
|
3840
|
+
/**
|
|
3841
|
+
* Creates a complete markdown spec for inline nodes using attribute syntax.
|
|
3842
|
+
*
|
|
3843
|
+
* The generated spec handles:
|
|
3844
|
+
* - Parsing shortcode syntax with `[nodeName attributes]content[/nodeName]` format
|
|
3845
|
+
* - Self-closing shortcodes like `[emoji name=party_popper]`
|
|
3846
|
+
* - Extracting and parsing attributes from the opening tag
|
|
3847
|
+
* - Rendering inline elements back to shortcode markdown
|
|
3848
|
+
* - Supporting both content-based and self-closing inline elements
|
|
3849
|
+
*
|
|
3850
|
+
* @param options - Configuration for the inline markdown spec
|
|
3851
|
+
* @returns Complete markdown specification object
|
|
3852
|
+
*
|
|
3853
|
+
* @example
|
|
3854
|
+
* ```ts
|
|
3855
|
+
* // Self-closing mention: [mention id="madonna" label="Madonna"]
|
|
3856
|
+
* const mentionSpec = createInlineMarkdownSpec({
|
|
3857
|
+
* nodeName: 'mention',
|
|
3858
|
+
* selfClosing: true,
|
|
3859
|
+
* defaultAttributes: { type: 'user' },
|
|
3860
|
+
* allowedAttributes: ['id', 'label'] // Only these get rendered to markdown
|
|
3861
|
+
* })
|
|
3862
|
+
*
|
|
3863
|
+
* // Self-closing emoji: [emoji name="party_popper"]
|
|
3864
|
+
* const emojiSpec = createInlineMarkdownSpec({
|
|
3865
|
+
* nodeName: 'emoji',
|
|
3866
|
+
* selfClosing: true,
|
|
3867
|
+
* allowedAttributes: ['name']
|
|
3868
|
+
* })
|
|
3869
|
+
*
|
|
3870
|
+
* // With content: [highlight color="yellow"]text[/highlight]
|
|
3871
|
+
* const highlightSpec = createInlineMarkdownSpec({
|
|
3872
|
+
* nodeName: 'highlight',
|
|
3873
|
+
* selfClosing: false,
|
|
3874
|
+
* allowedAttributes: ['color', 'style']
|
|
3875
|
+
* })
|
|
3876
|
+
*
|
|
3877
|
+
* // Usage in extension:
|
|
3878
|
+
* export const Mention = Node.create({
|
|
3879
|
+
* name: 'mention', // Must match nodeName
|
|
3880
|
+
* // ... other config
|
|
3881
|
+
* markdown: mentionSpec
|
|
3882
|
+
* })
|
|
3883
|
+
* ```
|
|
3884
|
+
*/
|
|
3885
|
+
declare function createInlineMarkdownSpec(options: InlineMarkdownSpecOptions): {
|
|
3886
|
+
parseMarkdown: (token: MarkdownToken, h: MarkdownParseHelpers) => MarkdownParseResult;
|
|
3887
|
+
markdownTokenizer: MarkdownTokenizer;
|
|
3888
|
+
renderMarkdown: (node: JSONContent) => string;
|
|
3889
|
+
};
|
|
3890
|
+
|
|
3891
|
+
/**
|
|
3892
|
+
* @fileoverview Utility for parsing indented markdown blocks with hierarchical nesting.
|
|
3893
|
+
*
|
|
3894
|
+
* This utility handles the complex logic of parsing markdown blocks that can contain
|
|
3895
|
+
* nested content based on indentation levels, maintaining proper hierarchical structure
|
|
3896
|
+
* for lists, task lists, and other indented block types.
|
|
3897
|
+
*/
|
|
3898
|
+
interface ParsedBlock {
|
|
3899
|
+
type: string;
|
|
3900
|
+
raw: string;
|
|
3901
|
+
mainContent: string;
|
|
3902
|
+
indentLevel: number;
|
|
3903
|
+
nestedContent?: string;
|
|
3904
|
+
nestedTokens?: any[];
|
|
3905
|
+
[key: string]: any;
|
|
3906
|
+
}
|
|
3907
|
+
interface BlockParserConfig {
|
|
3908
|
+
/** Regex pattern to match block items */
|
|
3909
|
+
itemPattern: RegExp;
|
|
3910
|
+
/** Function to extract data from regex match */
|
|
3911
|
+
extractItemData: (match: RegExpMatchArray) => {
|
|
3912
|
+
mainContent: string;
|
|
3913
|
+
indentLevel: number;
|
|
3914
|
+
[key: string]: any;
|
|
3915
|
+
};
|
|
3916
|
+
/** Function to create the final token */
|
|
3917
|
+
createToken: (data: any, nestedTokens?: any[]) => ParsedBlock;
|
|
3918
|
+
/** Base indentation to remove from nested content (default: 2 spaces) */
|
|
3919
|
+
baseIndentSize?: number;
|
|
3920
|
+
/**
|
|
3921
|
+
* Custom parser for nested content. If provided, this will be called instead
|
|
3922
|
+
* of the default lexer.blockTokens() for parsing nested content.
|
|
3923
|
+
* This allows recursive parsing of the same block type.
|
|
3924
|
+
*/
|
|
3925
|
+
customNestedParser?: (dedentedContent: string) => any[] | undefined;
|
|
3926
|
+
}
|
|
3927
|
+
/**
|
|
3928
|
+
* Parses markdown text into hierarchical indented blocks with proper nesting.
|
|
3929
|
+
*
|
|
3930
|
+
* This utility handles:
|
|
3931
|
+
* - Line-by-line parsing with pattern matching
|
|
3932
|
+
* - Hierarchical nesting based on indentation levels
|
|
3933
|
+
* - Nested content collection and parsing
|
|
3934
|
+
* - Empty line handling
|
|
3935
|
+
* - Content dedenting for nested blocks
|
|
3936
|
+
*
|
|
3937
|
+
* The key difference from flat parsing is that this maintains the hierarchical
|
|
3938
|
+
* structure where nested items become `nestedTokens` of their parent items,
|
|
3939
|
+
* rather than being flattened into a single array.
|
|
3940
|
+
*
|
|
3941
|
+
* @param src - The markdown source text to parse
|
|
3942
|
+
* @param config - Configuration object defining how to parse and create tokens
|
|
3943
|
+
* @param lexer - Markdown lexer for parsing nested content
|
|
3944
|
+
* @returns Parsed result with hierarchical items, or undefined if no matches
|
|
3945
|
+
*
|
|
3946
|
+
* @example
|
|
3947
|
+
* ```ts
|
|
3948
|
+
* const result = parseIndentedBlocks(src, {
|
|
3949
|
+
* itemPattern: /^(\s*)([-+*])\s+\[([ xX])\]\s+(.*)$/,
|
|
3950
|
+
* extractItemData: (match) => ({
|
|
3951
|
+
* indentLevel: match[1].length,
|
|
3952
|
+
* mainContent: match[4],
|
|
3953
|
+
* checked: match[3].toLowerCase() === 'x'
|
|
3954
|
+
* }),
|
|
3955
|
+
* createToken: (data, nestedTokens) => ({
|
|
3956
|
+
* type: 'taskItem',
|
|
3957
|
+
* checked: data.checked,
|
|
3958
|
+
* text: data.mainContent,
|
|
3959
|
+
* nestedTokens
|
|
3960
|
+
* })
|
|
3961
|
+
* }, lexer)
|
|
3962
|
+
* ```
|
|
3963
|
+
*/
|
|
3964
|
+
declare function parseIndentedBlocks(src: string, config: BlockParserConfig, lexer: {
|
|
3965
|
+
inlineTokens: (src: string) => any[];
|
|
3966
|
+
blockTokens: (src: string) => any[];
|
|
3967
|
+
}): {
|
|
3968
|
+
items: ParsedBlock[];
|
|
3969
|
+
raw: string;
|
|
3970
|
+
} | undefined;
|
|
3971
|
+
|
|
3972
|
+
/**
|
|
3973
|
+
* @fileoverview Utility functions for rendering nested content in markdown.
|
|
3974
|
+
*
|
|
3975
|
+
* This module provides reusable utilities for extensions that need to render
|
|
3976
|
+
* content with a prefix on the main line and properly indented nested content.
|
|
3977
|
+
*/
|
|
3978
|
+
/**
|
|
3979
|
+
* Utility function for rendering content with a main line prefix and nested indented content.
|
|
3980
|
+
*
|
|
3981
|
+
* This function handles the common pattern of rendering content with:
|
|
3982
|
+
* 1. A main line with a prefix (like "- " for lists, "> " for blockquotes, etc.)
|
|
3983
|
+
* 2. Nested content that gets indented properly
|
|
3984
|
+
*
|
|
3985
|
+
* @param node - The ProseMirror node representing the content
|
|
3986
|
+
* @param h - The markdown renderer helper
|
|
3987
|
+
* @param prefixOrGenerator - Either a string prefix or a function that generates the prefix from context
|
|
3988
|
+
* @param ctx - Optional context object (used when prefixOrGenerator is a function)
|
|
3989
|
+
* @returns The rendered markdown string
|
|
3990
|
+
*
|
|
3991
|
+
* @example
|
|
3992
|
+
* ```ts
|
|
3993
|
+
* // For a bullet list item with static prefix
|
|
3994
|
+
* return renderNestedMarkdownContent(node, h, '- ')
|
|
3995
|
+
*
|
|
3996
|
+
* // For a task item with static prefix
|
|
3997
|
+
* const prefix = `- [${node.attrs?.checked ? 'x' : ' '}] `
|
|
3998
|
+
* return renderNestedMarkdownContent(node, h, prefix)
|
|
3999
|
+
*
|
|
4000
|
+
* // For a blockquote with static prefix
|
|
4001
|
+
* return renderNestedMarkdownContent(node, h, '> ')
|
|
4002
|
+
*
|
|
4003
|
+
* // For content with dynamic prefix based on context
|
|
4004
|
+
* return renderNestedMarkdownContent(node, h, ctx => {
|
|
4005
|
+
* if (ctx.parentType === 'orderedList') {
|
|
4006
|
+
* return `${ctx.index + 1}. `
|
|
4007
|
+
* }
|
|
4008
|
+
* return '- '
|
|
4009
|
+
* }, ctx)
|
|
4010
|
+
*
|
|
4011
|
+
* // Custom extension example
|
|
4012
|
+
* const CustomContainer = Node.create({
|
|
4013
|
+
* name: 'customContainer',
|
|
4014
|
+
* // ... other config
|
|
4015
|
+
* markdown: {
|
|
4016
|
+
* render: (node, h) => {
|
|
4017
|
+
* const type = node.attrs?.type || 'info'
|
|
4018
|
+
* return renderNestedMarkdownContent(node, h, `[${type}] `)
|
|
4019
|
+
* }
|
|
4020
|
+
* }
|
|
4021
|
+
* })
|
|
4022
|
+
* ```
|
|
4023
|
+
*/
|
|
4024
|
+
declare function renderNestedMarkdownContent(node: JSONContent, h: {
|
|
4025
|
+
renderChildren: (nodes: JSONContent[]) => string;
|
|
4026
|
+
indent: (text: string) => string;
|
|
4027
|
+
}, prefixOrGenerator: string | ((ctx: any) => string), ctx?: any): string;
|
|
4028
|
+
|
|
4029
|
+
/**
|
|
4030
|
+
* @fileoverview Markdown utilities for creating standardized markdown specs.
|
|
4031
|
+
*
|
|
4032
|
+
* This module provides utilities for creating complete markdown specifications
|
|
4033
|
+
* for different types of nodes using unified syntax patterns.
|
|
4034
|
+
*/
|
|
4035
|
+
|
|
4036
|
+
type index_AtomBlockMarkdownSpecOptions = AtomBlockMarkdownSpecOptions;
|
|
4037
|
+
type index_BlockMarkdownSpecOptions = BlockMarkdownSpecOptions;
|
|
4038
|
+
type index_BlockParserConfig = BlockParserConfig;
|
|
4039
|
+
type index_InlineMarkdownSpecOptions = InlineMarkdownSpecOptions;
|
|
4040
|
+
type index_ParsedBlock = ParsedBlock;
|
|
4041
|
+
declare const index_createAtomBlockMarkdownSpec: typeof createAtomBlockMarkdownSpec;
|
|
4042
|
+
declare const index_createBlockMarkdownSpec: typeof createBlockMarkdownSpec;
|
|
4043
|
+
declare const index_createInlineMarkdownSpec: typeof createInlineMarkdownSpec;
|
|
4044
|
+
declare const index_parseAttributes: typeof parseAttributes;
|
|
4045
|
+
declare const index_parseIndentedBlocks: typeof parseIndentedBlocks;
|
|
4046
|
+
declare const index_renderNestedMarkdownContent: typeof renderNestedMarkdownContent;
|
|
4047
|
+
declare const index_serializeAttributes: typeof serializeAttributes;
|
|
4048
|
+
declare namespace index {
|
|
4049
|
+
export { type index_AtomBlockMarkdownSpecOptions as AtomBlockMarkdownSpecOptions, type index_BlockMarkdownSpecOptions as BlockMarkdownSpecOptions, type index_BlockParserConfig as BlockParserConfig, type index_InlineMarkdownSpecOptions as InlineMarkdownSpecOptions, type index_ParsedBlock as ParsedBlock, index_createAtomBlockMarkdownSpec as createAtomBlockMarkdownSpec, index_createBlockMarkdownSpec as createBlockMarkdownSpec, index_createInlineMarkdownSpec as createInlineMarkdownSpec, index_parseAttributes as parseAttributes, index_parseIndentedBlocks as parseIndentedBlocks, index_renderNestedMarkdownContent as renderNestedMarkdownContent, index_serializeAttributes as serializeAttributes };
|
|
4050
|
+
}
|
|
4051
|
+
|
|
4052
|
+
declare function mergeAttributes(...objects: Record<string, any>[]): Record<string, any>;
|
|
4053
|
+
|
|
4054
|
+
declare function mergeDeep(target: Record<string, any>, source: Record<string, any>): Record<string, any>;
|
|
4055
|
+
|
|
4056
|
+
declare function minMax(value?: number, min?: number, max?: number): number;
|
|
4057
|
+
|
|
4058
|
+
/**
|
|
4059
|
+
* Check if object1 includes object2
|
|
4060
|
+
* @param object1 Object
|
|
4061
|
+
* @param object2 Object
|
|
4062
|
+
*/
|
|
4063
|
+
declare function objectIncludes(object1: Record<string, any>, object2: Record<string, any>, options?: {
|
|
4064
|
+
strict: boolean;
|
|
4065
|
+
}): boolean;
|
|
4066
|
+
|
|
4067
|
+
/**
|
|
4068
|
+
* Removes duplicated values within an array.
|
|
4069
|
+
* Supports numbers, strings and objects.
|
|
4070
|
+
*/
|
|
4071
|
+
declare function removeDuplicates<T>(array: T[], by?: {
|
|
4072
|
+
(value: any, replacer?: (this: any, key: string, value: any) => any, space?: string | number): string;
|
|
4073
|
+
(value: any, replacer?: (number | string)[] | null, space?: string | number): string;
|
|
4074
|
+
}): T[];
|
|
4075
|
+
|
|
4076
|
+
declare const lightTheme: Theme;
|
|
4077
|
+
|
|
4078
|
+
declare const darkTheme: Theme;
|
|
4079
|
+
|
|
4080
|
+
/**
|
|
4081
|
+
* Resolve theme from various input formats
|
|
4082
|
+
*
|
|
4083
|
+
* Handles:
|
|
4084
|
+
* - String references to built-in themes ('light', 'dark')
|
|
4085
|
+
* - Full custom theme objects
|
|
4086
|
+
* - Partial themes that extend built-in themes
|
|
4087
|
+
* - Undefined/invalid (returns null - no theme applied)
|
|
4088
|
+
*
|
|
4089
|
+
* @param themeInput - Theme configuration
|
|
4090
|
+
* @returns Resolved complete theme or null if no theme should be applied
|
|
4091
|
+
*/
|
|
4092
|
+
declare function resolveTheme(themeInput: ThemeInput): ResolvedTheme;
|
|
4093
|
+
/**
|
|
4094
|
+
* Apply theme to DOM element using CSS custom properties
|
|
4095
|
+
*
|
|
4096
|
+
* Sets CSS variables on the element that can be used by stylesheets.
|
|
4097
|
+
* Also sets a data-theme attribute for additional CSS targeting.
|
|
4098
|
+
* If theme is null, removes all theme-related attributes and CSS variables.
|
|
4099
|
+
*
|
|
4100
|
+
* @param theme - Resolved theme to apply (or null to remove theme)
|
|
4101
|
+
* @param element - DOM element to apply theme to
|
|
4102
|
+
*/
|
|
4103
|
+
declare function applyTheme(theme: ResolvedTheme, element: HTMLElement): void;
|
|
4104
|
+
/**
|
|
4105
|
+
* Register a custom theme globally
|
|
4106
|
+
*
|
|
4107
|
+
* Allows registering custom themes that can be referenced by string name
|
|
4108
|
+
*
|
|
4109
|
+
* @param theme - Theme to register
|
|
4110
|
+
*/
|
|
4111
|
+
declare function registerTheme(theme: Theme): void;
|
|
4112
|
+
/**
|
|
4113
|
+
* Get all registered theme names
|
|
4114
|
+
*
|
|
4115
|
+
* @returns Array of theme names
|
|
4116
|
+
*/
|
|
4117
|
+
declare function getThemeNames(): string[];
|
|
4118
|
+
/**
|
|
4119
|
+
* Get a theme by name
|
|
4120
|
+
*
|
|
4121
|
+
* @param name - Theme name
|
|
4122
|
+
* @returns Theme if found, undefined otherwise
|
|
4123
|
+
*/
|
|
4124
|
+
declare function getTheme(name: string): Theme | undefined;
|
|
4125
|
+
|
|
4126
|
+
interface Commands<ReturnType = any> {
|
|
4127
|
+
}
|
|
4128
|
+
interface Storage {
|
|
4129
|
+
}
|
|
4130
|
+
|
|
4131
|
+
export { type AnyCommands, type AnyConfig, type AnyExtension, type AtomBlockMarkdownSpecOptions, type Attribute, type Attributes$1 as Attributes, type BlockMarkdownSpecOptions, type BlockParserConfig, type CanCommands, type ChainedCommands, type ChangedRange, type Command, CommandManager, type CommandProps, type CommandSpec, type Commands, type Content, type CreateNodeFromContentOptions, type DOMNode, type DOMOutputSpecArray$1 as DOMOutputSpecArray, type DecorationType, type DecorationWithType, type Diff, type Dispatch, type DocumentType, SlideEditor as Editor, type EditorEvents, type EditorOptions, type EnableRules, Extendable, type ExtendableConfig, type ExtendedRegExpMatchArray, Extension, type ExtensionAttribute, type ExtensionConfig, type Extensions, type FocusPosition, Fragment, type FullMarkdownHelpers, type GlobalAttributes, type HTMLContent, type InlineMarkdownSpecOptions, InputRule, type InputRuleFinder, type InputRuleMatch, type InsertContentAtOptions, type InsertContentOptions, type JSONContent, type KeyboardShortcutCommand, type KeysWithTypeOf, Mark, type MarkConfig, type MarkRange, type MarkType, MarkView, type MarkViewProps, type MarkViewRenderer, type MarkViewRendererOptions, type MarkViewRendererProps, type MarkdownExtensionSpec, type MarkdownHelpers, type MarkdownLexerConfiguration, type MarkdownParseHelpers, type MarkdownParseResult, type MarkdownRendererHelpers, type MarkdownToken, type MarkdownTokenizer, type MaybeReturnType, type MaybeThisParameterType, Node, type NodeConfig, NodePos, type NodeRange, type NodeType, NodeView, type NodeViewProps, type NodeViewRenderer, type NodeViewRendererOptions, type NodeViewRendererProps, type NodeWithPos, type Overwrite, type ParentConfig, type ParsedBlock, type PartialTheme, PasteRule, type PasteRuleFinder, type PasteRuleMatch, type PickValue, type Predicate, type Primitive, type Range, type RawCommands, type RemoveThis, type RenderContext, type ResolvedTheme, type SetContentOptions, type SingleCommands, SlideEditor, type Storage, type TextSerializer, type TextType, type Theme, type ThemeConfig, type ThemeInput, type TiptapEditorHTMLElement, Tracker, type TrackerResult, type UnionCommands, type UnionToIntersection, type ValuesOf, applyAllLayouts, applyLayoutToRow, applyTheme, blur, callOrReturn, canInsertNode, clearContent, clearNodes, combineTransactionSteps, command, index$2 as commands, createAtomBlockMarkdownSpec, createBlockMarkdownSpec, createChainableState, createDocument, h as createElement, createInlineMarkdownSpec, createNodeFromContent, createParagraphNear, createStyleTag, cut, darkTheme, defaultBlockAt, deleteCurrentNode, deleteNode, deleteProps, deleteRange, deleteSelection, elementFromString, enter, escapeForRegEx, exitCode, extendMarkRange, index$1 as extensions, findChildren, findChildrenInRange, findDuplicates, findParentNode, findParentNodeClosestToPos, first, flattenExtensions, focus, forEach, fromString, generateHTML, generateJSON, generateText, getAttributes, getAttributesFromExtensions, getChangedRanges, getDebugJSON, getExtensionField, getHTMLFromFragment, getMarkAttributes, getMarkRange, getMarkType, getMarksBetween, getNodeAtPosition, getNodeAttributes, getNodeType, getRenderedAttributes, getSchema, getSchemaByResolvedExtensions, getSchemaTypeByName, getSchemaTypeNameByName, getSplittedAttributes, getText, getTextBetween, getTextContentFromNodes, getTextSerializersFromSchema, getTheme, getThemeNames, h, injectExtensionAttributesToParseRule, inputRulesPlugin, insertContent, insertContentAt, isActive, isAndroid, isAtEndOfNode, isAtStartOfNode, isEmptyObject, isExtensionRulesEnabled, isFunction, isList, isMacOS, isMarkActive, isNodeActive, isNodeEmpty, isNodeSelection, isNumber, isPlainObject, isRegExp, isString, isTextSelection, isiOS, joinBackward, joinDown, joinForward, joinItemBackward, joinItemForward, joinTextblockBackward, joinTextblockForward, joinUp, keyboardShortcut, lift, liftEmptyBlock, liftListItem, lightTheme, markInputRule, markPasteRule, index as markdown, mergeAttributes, mergeDeep, minMax, newlineInCode, nodeInputRule, nodePasteRule, objectIncludes, parseAttributes, parseIndentedBlocks, parseLayout, pasteRulesPlugin, posToDOMRect, registerTheme, removeDuplicates, renderNestedMarkdownContent, resetAttributes, resolveExtensions, resolveFocusPosition, resolveTheme, rewriteUnknownContent, scrollIntoView, selectAll, selectNodeBackward, selectNodeForward, selectParentNode, selectTextblockEnd, selectTextblockStart, selectionToInsertionEnd, serializeAttributes, setContent, setMark, setMeta, setNode, setNodeSelection, setTextSelection, sinkListItem, sortExtensions, splitBlock, splitExtensions, splitListItem, textInputRule, textPasteRule, textblockTypeInputRule, toggleList, toggleMark, toggleNode, toggleWrap, undoInputRule, unsetAllMarks, unsetMark, updateAttributes, updateMarkViewAttributes, wrapIn, wrapInList, wrappingInputRule };
|