@thomasfosterau/effect-richtext 0.0.0-stage → 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 +48 -0
- package/README.md +118 -2
- package/dist/_virtual/_rolldown/runtime.js +12 -0
- package/dist/commands/commands.d.ts +323 -0
- package/dist/commands/commands.js +722 -0
- package/dist/commands/internal.js +43 -0
- package/dist/commands/keymaps.d.ts +46 -0
- package/dist/commands/keymaps.js +64 -0
- package/dist/commands.d.ts +3 -0
- package/dist/commands.js +3 -0
- package/dist/compat/commands.d.ts +250 -0
- package/dist/compat/commands.js +275 -0
- package/dist/compat/internal/core.d.ts +20 -0
- package/dist/compat/internal/core.js +148 -0
- package/dist/compat/internal/props.js +82 -0
- package/dist/compat/keymap.d.ts +21 -0
- package/dist/compat/keymap.js +38 -0
- package/dist/compat/model.d.ts +893 -0
- package/dist/compat/model.js +1212 -0
- package/dist/compat/orderedmap.d.ts +74 -0
- package/dist/compat/orderedmap.js +124 -0
- package/dist/compat/schema-basic.d.ts +38 -0
- package/dist/compat/schema-basic.js +238 -0
- package/dist/compat/schema-list.d.ts +81 -0
- package/dist/compat/schema-list.js +156 -0
- package/dist/compat/state.d.ts +415 -0
- package/dist/compat/state.js +689 -0
- package/dist/compat/test-builder.d.ts +98 -0
- package/dist/compat/test-builder.js +197 -0
- package/dist/compat/transform.d.ts +458 -0
- package/dist/compat/transform.js +803 -0
- package/dist/compat/view.d.ts +411 -0
- package/dist/compat/view.js +409 -0
- package/dist/dropcursor.d.ts +46 -0
- package/dist/dropcursor.js +176 -0
- package/dist/extensions/defaults.d.ts +716 -0
- package/dist/extensions/defaults.js +209 -0
- package/dist/extensions/editor.d.ts +246 -0
- package/dist/extensions/editor.js +271 -0
- package/dist/extensions/extension.d.ts +375 -0
- package/dist/extensions/extension.js +233 -0
- package/dist/extensions.d.ts +4 -0
- package/dist/extensions.js +4 -0
- package/dist/gapcursor.d.ts +66 -0
- package/dist/gapcursor.js +273 -0
- package/dist/history.d.ts +178 -0
- package/dist/history.js +412 -0
- package/dist/html.d.ts +158 -0
- package/dist/html.js +164 -0
- package/dist/inputrules.d.ts +271 -0
- package/dist/inputrules.js +321 -0
- package/dist/internal/attempt.js +15 -0
- package/dist/internal/json.js +29 -0
- package/dist/keymap/keymap.d.ts +130 -0
- package/dist/keymap/keymap.js +159 -0
- package/dist/keymap.d.ts +2 -0
- package/dist/keymap.js +1 -0
- package/dist/markdown/errors.d.ts +23 -0
- package/dist/markdown/errors.js +26 -0
- package/dist/markdown/from_markdown.d.ts +185 -0
- package/dist/markdown/from_markdown.js +266 -0
- package/dist/markdown/schema.d.ts +522 -0
- package/dist/markdown/schema.js +292 -0
- package/dist/markdown/to_markdown.d.ts +251 -0
- package/dist/markdown/to_markdown.js +413 -0
- package/dist/markdown.d.ts +5 -0
- package/dist/markdown.js +5 -0
- package/dist/model/attrsCodec.js +48 -0
- package/dist/model/comparedeep.js +17 -0
- package/dist/model/content.d.ts +232 -0
- package/dist/model/content.js +630 -0
- package/dist/model/diff.js +66 -0
- package/dist/model/dom.d.ts +3 -0
- package/dist/model/errors.d.ts +90 -0
- package/dist/model/errors.js +76 -0
- package/dist/model/fragment.d.ts +131 -0
- package/dist/model/fragment.js +262 -0
- package/dist/model/from_dom.d.ts +299 -0
- package/dist/model/from_dom.js +618 -0
- package/dist/model/json.d.ts +37 -0
- package/dist/model/json.js +126 -0
- package/dist/model/mark.d.ts +73 -0
- package/dist/model/mark.js +121 -0
- package/dist/model/node.d.ts +267 -0
- package/dist/model/node.js +434 -0
- package/dist/model/replace.d.ts +78 -0
- package/dist/model/replace.js +207 -0
- package/dist/model/resolvedpos.d.ts +196 -0
- package/dist/model/resolvedpos.js +305 -0
- package/dist/model/schema.d.ts +740 -0
- package/dist/model/schema.js +451 -0
- package/dist/model/to_dom.d.ts +169 -0
- package/dist/model/to_dom.js +238 -0
- package/dist/model.d.ts +12 -0
- package/dist/model.js +12 -0
- package/dist/placeholder.d.ts +53 -0
- package/dist/placeholder.js +79 -0
- package/dist/reactive/observer.d.ts +54 -0
- package/dist/reactive/observer.js +61 -0
- package/dist/reactive/selectors.d.ts +22 -0
- package/dist/reactive/selectors.js +61 -0
- package/dist/reactive/stateref.d.ts +72 -0
- package/dist/reactive/stateref.js +71 -0
- package/dist/reactive/streams.d.ts +83 -0
- package/dist/reactive/streams.js +85 -0
- package/dist/reactive.d.ts +16 -0
- package/dist/reactive.js +26 -0
- package/dist/schema-basic.d.ts +448 -0
- package/dist/schema-basic.js +269 -0
- package/dist/schema-list/commands.d.ts +66 -0
- package/dist/schema-list/commands.js +203 -0
- package/dist/schema-list.d.ts +92 -0
- package/dist/schema-list.js +100 -0
- package/dist/state/errors.d.ts +39 -0
- package/dist/state/errors.js +32 -0
- package/dist/state/plugin.d.ts +232 -0
- package/dist/state/plugin.js +82 -0
- package/dist/state/selection.d.ts +297 -0
- package/dist/state/selection.js +486 -0
- package/dist/state/state.d.ts +212 -0
- package/dist/state/state.js +489 -0
- package/dist/state/transaction.d.ts +145 -0
- package/dist/state/transaction.js +195 -0
- package/dist/state.d.ts +6 -0
- package/dist/state.js +6 -0
- package/dist/test-builder.d.ts +3582 -0
- package/dist/test-builder.js +239 -0
- package/dist/transform/attr_step.d.ts +60 -0
- package/dist/transform/attr_step.js +105 -0
- package/dist/transform/errors.d.ts +50 -0
- package/dist/transform/errors.js +35 -0
- package/dist/transform/map.d.ts +182 -0
- package/dist/transform/map.js +280 -0
- package/dist/transform/mark.js +98 -0
- package/dist/transform/mark_set_step.js +69 -0
- package/dist/transform/mark_step.d.ts +113 -0
- package/dist/transform/mark_step.js +225 -0
- package/dist/transform/replace.d.ts +18 -0
- package/dist/transform/replace.js +381 -0
- package/dist/transform/replace_step.d.ts +109 -0
- package/dist/transform/replace_step.js +175 -0
- package/dist/transform/step.d.ts +157 -0
- package/dist/transform/step.js +168 -0
- package/dist/transform/structure.d.ts +89 -0
- package/dist/transform/structure.js +350 -0
- package/dist/transform/transform.d.ts +248 -0
- package/dist/transform/transform.js +373 -0
- package/dist/transform.d.ts +10 -0
- package/dist/transform.js +10 -0
- package/dist/view/browser.js +39 -0
- package/dist/view/capturekeys.js +282 -0
- package/dist/view/clipboard.d.ts +8 -0
- package/dist/view/clipboard.js +245 -0
- package/dist/view/decoration.d.ts +339 -0
- package/dist/view/decoration.js +566 -0
- package/dist/view/dom.d.ts +18 -0
- package/dist/view/dom.js +140 -0
- package/dist/view/domchange.js +295 -0
- package/dist/view/domcoords.d.ts +22 -0
- package/dist/view/domcoords.js +448 -0
- package/dist/view/domobserver.d.ts +47 -0
- package/dist/view/domobserver.js +328 -0
- package/dist/view/errors.d.ts +18 -0
- package/dist/view/errors.js +21 -0
- package/dist/view/input.d.ts +58 -0
- package/dist/view/input.js +704 -0
- package/dist/view/selection.js +198 -0
- package/dist/view/view.d.ts +699 -0
- package/dist/view/view.js +623 -0
- package/dist/view/viewdesc.d.ts +236 -0
- package/dist/view/viewdesc.js +1205 -0
- package/dist/view-css.d.ts +43 -0
- package/dist/view-css.js +124 -0
- package/dist/view.d.ts +6 -0
- package/dist/view.js +4 -0
- package/package.json +206 -3
|
@@ -0,0 +1,415 @@
|
|
|
1
|
+
import { Mappable } from "../transform/map.js";
|
|
2
|
+
import { Command as Command$1, Transaction as Transaction$1 } from "../state/transaction.js";
|
|
3
|
+
import { AllSelection as AllSelection$1, NodeSelection as NodeSelection$1, Selection as Selection$1, SelectionBookmark as SelectionBookmark$1, SelectionRange as SelectionRange$1, TextSelection as TextSelection$1 } from "../state/selection.js";
|
|
4
|
+
import { EditorState as EditorState$1 } from "../state/state.js";
|
|
5
|
+
import { Plugin as Plugin$1, PluginKey as PluginKey$1 } from "../state/plugin.js";
|
|
6
|
+
import "../state.js";
|
|
7
|
+
import { CORE } from "./internal/core.js";
|
|
8
|
+
import { Mark, MarkType, Node, ResolvedPos, Schema, Slice } from "./model.js";
|
|
9
|
+
import { Transform } from "./transform.js";
|
|
10
|
+
import { EditorProps, EditorView } from "./view.js";
|
|
11
|
+
/**
|
|
12
|
+
* Represents a selected range in a document.
|
|
13
|
+
*
|
|
14
|
+
* @since 0.1.0
|
|
15
|
+
* @category models
|
|
16
|
+
*/
|
|
17
|
+
export declare class SelectionRange {
|
|
18
|
+
/** @internal */
|
|
19
|
+
readonly [CORE]: SelectionRange$1;
|
|
20
|
+
/** Create a range. */
|
|
21
|
+
constructor($from: ResolvedPos, $to: ResolvedPos);
|
|
22
|
+
/** The lower bound of the range. */
|
|
23
|
+
get $from(): ResolvedPos;
|
|
24
|
+
/** The upper bound of the range. */
|
|
25
|
+
get $to(): ResolvedPos;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* A lightweight, document-independent representation of a selection.
|
|
29
|
+
*
|
|
30
|
+
* @since 0.1.0
|
|
31
|
+
* @category models
|
|
32
|
+
*/
|
|
33
|
+
export interface SelectionBookmark {
|
|
34
|
+
map(mapping: Mappable): SelectionBookmark;
|
|
35
|
+
resolve(doc: Node): Selection;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Superclass for editor selections. Subclass it to define custom
|
|
39
|
+
* selection types: subclasses are adapted into core selections.
|
|
40
|
+
*
|
|
41
|
+
* @since 0.1.0
|
|
42
|
+
* @category models
|
|
43
|
+
*/
|
|
44
|
+
export declare abstract class Selection {
|
|
45
|
+
/** @internal */
|
|
46
|
+
readonly [CORE]: Selection$1;
|
|
47
|
+
/** Initialize a selection with the head and anchor and ranges. */
|
|
48
|
+
constructor($anchor: ResolvedPos, $head: ResolvedPos, ranges?: ReadonlyArray<SelectionRange>);
|
|
49
|
+
/** The ranges covered by the selection. */
|
|
50
|
+
get ranges(): ReadonlyArray<SelectionRange>;
|
|
51
|
+
/** The resolved anchor of the selection. */
|
|
52
|
+
get $anchor(): ResolvedPos;
|
|
53
|
+
/** The resolved head of the selection. */
|
|
54
|
+
get $head(): ResolvedPos;
|
|
55
|
+
/** The selection's anchor, as an unresolved position. */
|
|
56
|
+
get anchor(): number;
|
|
57
|
+
/** The selection's head. */
|
|
58
|
+
get head(): number;
|
|
59
|
+
/** The lower bound of the selection's main range. */
|
|
60
|
+
get from(): number;
|
|
61
|
+
/** The upper bound of the selection's main range. */
|
|
62
|
+
get to(): number;
|
|
63
|
+
/** The resolved lower bound of the selection's main range. */
|
|
64
|
+
get $from(): ResolvedPos;
|
|
65
|
+
/** The resolved upper bound of the selection's main range. */
|
|
66
|
+
get $to(): ResolvedPos;
|
|
67
|
+
/** Indicates whether the selection contains any content. */
|
|
68
|
+
get empty(): boolean;
|
|
69
|
+
/** Controls whether, when a selection of this type is active in the browser, the selected range should be visible to the user. */
|
|
70
|
+
get visible(): boolean;
|
|
71
|
+
/** Test whether the selection is the same as another selection. */
|
|
72
|
+
abstract eq(selection: Selection): boolean;
|
|
73
|
+
/** Map this selection through a mappable thing. */
|
|
74
|
+
abstract map(doc: Node, mapping: Mappable): Selection;
|
|
75
|
+
/** Get the content of this selection as a slice. */
|
|
76
|
+
content(): Slice;
|
|
77
|
+
/** Replace the selection with a slice or, if no slice is given, delete the selection. */
|
|
78
|
+
replace(tr: Transaction, content?: Slice): void;
|
|
79
|
+
/** Replace the selection with the given node, appending the changes to the given transaction. */
|
|
80
|
+
replaceWith(tr: Transaction, node: Node): void;
|
|
81
|
+
/** Convert the selection to a JSON representation. */
|
|
82
|
+
abstract toJSON(): any;
|
|
83
|
+
/** Find a valid cursor or leaf node selection starting at the given position and searching back if `dir` is negative, and forward if positive. */
|
|
84
|
+
static findFrom($pos: ResolvedPos, dir: number, textOnly?: boolean): Selection | null;
|
|
85
|
+
/** Find a valid cursor or leaf node selection near the given position. */
|
|
86
|
+
static near($pos: ResolvedPos, bias?: number): Selection;
|
|
87
|
+
/** Find the cursor or leaf node selection closest to the start of the given document. */
|
|
88
|
+
static atStart(doc: Node): Selection;
|
|
89
|
+
/** Find the cursor or leaf node selection closest to the end of the given document. */
|
|
90
|
+
static atEnd(doc: Node): Selection;
|
|
91
|
+
/** Deserialize the JSON representation of a selection. */
|
|
92
|
+
static fromJSON(doc: Node, json: any): Selection;
|
|
93
|
+
/** To be able to deserialize selections from JSON, custom selection classes must register themselves with an ID string. */
|
|
94
|
+
static jsonID(id: string, selectionClass: {
|
|
95
|
+
fromJSON(doc: Node, json: any): Selection;
|
|
96
|
+
}): any;
|
|
97
|
+
/** Get a bookmark for this selection. */
|
|
98
|
+
getBookmark(): SelectionBookmark;
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* A text selection represents a classical editor selection, with a
|
|
102
|
+
* head (the moving side) and anchor (immobile side), both of which
|
|
103
|
+
* point into textblock nodes.
|
|
104
|
+
*
|
|
105
|
+
* @since 0.1.0
|
|
106
|
+
* @category models
|
|
107
|
+
*/
|
|
108
|
+
export declare class TextSelection extends Selection {
|
|
109
|
+
/** @internal */
|
|
110
|
+
readonly [CORE]: TextSelection$1;
|
|
111
|
+
/** Construct a text selection between the given points. */
|
|
112
|
+
constructor($anchor: ResolvedPos, $head?: ResolvedPos);
|
|
113
|
+
/** Returns a resolved position if this is a cursor selection (an empty text selection), and null otherwise. */
|
|
114
|
+
get $cursor(): ResolvedPos | null;
|
|
115
|
+
map(doc: Node, mapping: Mappable): Selection;
|
|
116
|
+
eq(other: Selection): boolean;
|
|
117
|
+
toJSON(): any;
|
|
118
|
+
/** @internal */
|
|
119
|
+
static fromJSON(doc: Node, json: any): TextSelection;
|
|
120
|
+
/** Create a text selection from non-resolved positions. */
|
|
121
|
+
static create(doc: Node, anchor: number, head?: number): TextSelection;
|
|
122
|
+
/** Return a text selection that spans the given positions or, if they aren't text positions, find a text selection near them. */
|
|
123
|
+
static between($anchor: ResolvedPos, $head: ResolvedPos, bias?: number): Selection;
|
|
124
|
+
}
|
|
125
|
+
/**
|
|
126
|
+
* A node selection is a selection that points at a single node.
|
|
127
|
+
*
|
|
128
|
+
* @since 0.1.0
|
|
129
|
+
* @category models
|
|
130
|
+
*/
|
|
131
|
+
export declare class NodeSelection extends Selection {
|
|
132
|
+
/** @internal */
|
|
133
|
+
readonly [CORE]: NodeSelection$1;
|
|
134
|
+
/** Create a node selection. Does not verify the validity of its argument. */
|
|
135
|
+
constructor($pos: ResolvedPos);
|
|
136
|
+
/** The selected node. */
|
|
137
|
+
get node(): Node;
|
|
138
|
+
map(doc: Node, mapping: Mappable): Selection;
|
|
139
|
+
eq(other: Selection): boolean;
|
|
140
|
+
toJSON(): any;
|
|
141
|
+
/** @internal */
|
|
142
|
+
static fromJSON(doc: Node, json: any): NodeSelection;
|
|
143
|
+
/** Create a node selection from non-resolved positions. */
|
|
144
|
+
static create(doc: Node, from: number): NodeSelection;
|
|
145
|
+
/** Determines whether the given node may be selected as a node selection. */
|
|
146
|
+
static isSelectable(node: Node): boolean;
|
|
147
|
+
}
|
|
148
|
+
/**
|
|
149
|
+
* A selection type that represents selecting the whole document.
|
|
150
|
+
*
|
|
151
|
+
* @since 0.1.0
|
|
152
|
+
* @category models
|
|
153
|
+
*/
|
|
154
|
+
export declare class AllSelection extends Selection {
|
|
155
|
+
/** @internal */
|
|
156
|
+
readonly [CORE]: AllSelection$1;
|
|
157
|
+
/** Create an all-selection over the given document. */
|
|
158
|
+
constructor(doc: Node);
|
|
159
|
+
map(doc: Node): Selection;
|
|
160
|
+
eq(other: Selection): boolean;
|
|
161
|
+
toJSON(): any;
|
|
162
|
+
}
|
|
163
|
+
/**
|
|
164
|
+
* Commands are functions that take a state and a an optional
|
|
165
|
+
* transaction dispatch function and determine whether they are
|
|
166
|
+
* applicable for the given state.
|
|
167
|
+
*
|
|
168
|
+
* @since 0.1.0
|
|
169
|
+
* @category models
|
|
170
|
+
*/
|
|
171
|
+
export type Command = (state: EditorState, dispatch?: (tr: Transaction) => void, view?: EditorView) => boolean;
|
|
172
|
+
/**
|
|
173
|
+
* An editor state transaction, which can be applied to a state to
|
|
174
|
+
* create an updated state.
|
|
175
|
+
*
|
|
176
|
+
* @since 0.1.0
|
|
177
|
+
* @category models
|
|
178
|
+
*/
|
|
179
|
+
export declare class Transaction extends Transform {
|
|
180
|
+
/** @internal */
|
|
181
|
+
readonly [CORE]: Transaction$1;
|
|
182
|
+
/** @internal */
|
|
183
|
+
private constructor();
|
|
184
|
+
/** The timestamp associated with this transaction. */
|
|
185
|
+
get time(): number;
|
|
186
|
+
set time(value: number);
|
|
187
|
+
/** The stored marks set by this transaction, if any. */
|
|
188
|
+
get storedMarks(): ReadonlyArray<Mark> | null;
|
|
189
|
+
/** The transaction's current selection. */
|
|
190
|
+
get selection(): Selection;
|
|
191
|
+
/** Update the transaction's current selection. */
|
|
192
|
+
setSelection(selection: Selection): this;
|
|
193
|
+
/** Whether the selection was explicitly updated by this transaction. */
|
|
194
|
+
get selectionSet(): boolean;
|
|
195
|
+
/** Set the current stored marks. */
|
|
196
|
+
setStoredMarks(marks: ReadonlyArray<Mark> | null): this;
|
|
197
|
+
/** Make sure the current stored marks or, if that is null, the marks at the selection, match the given set of marks. */
|
|
198
|
+
ensureMarks(marks: ReadonlyArray<Mark>): this;
|
|
199
|
+
/** Add a mark to the set of stored marks. */
|
|
200
|
+
addStoredMark(mark: Mark): this;
|
|
201
|
+
/** Remove a mark or mark type from the set of stored marks. */
|
|
202
|
+
removeStoredMark(mark: Mark | MarkType): this;
|
|
203
|
+
/** Whether the stored marks were explicitly set for this transaction. */
|
|
204
|
+
get storedMarksSet(): boolean;
|
|
205
|
+
/** Update the timestamp for the transaction. */
|
|
206
|
+
setTime(time: number): this;
|
|
207
|
+
/** Replace the current selection with the given slice. */
|
|
208
|
+
replaceSelection(slice: Slice): this;
|
|
209
|
+
/** Replace the selection with the given node. */
|
|
210
|
+
replaceSelectionWith(node: Node, inheritMarks?: boolean): this;
|
|
211
|
+
/** Delete the selection. */
|
|
212
|
+
deleteSelection(): this;
|
|
213
|
+
/** Replace the given range, or the selection if no range is given, with a text node containing the given string. */
|
|
214
|
+
insertText(text: string, from?: number, to?: number): this;
|
|
215
|
+
/** Store a metadata property in this transaction, keyed either by name or by plugin. */
|
|
216
|
+
setMeta(key: string | Plugin | PluginKey, value: any): this;
|
|
217
|
+
/** Retrieve a metadata property for a given name or plugin. */
|
|
218
|
+
getMeta(key: string | Plugin | PluginKey): any;
|
|
219
|
+
/** Returns true if this transaction doesn't contain any metadata, and can thus safely be extended. */
|
|
220
|
+
get isGeneric(): boolean;
|
|
221
|
+
/** Indicate that the editor should scroll the selection into view when updated to the state produced by this transaction. */
|
|
222
|
+
scrollIntoView(): this;
|
|
223
|
+
/** True when this transaction has had `scrollIntoView` called on it. */
|
|
224
|
+
get scrolledIntoView(): boolean;
|
|
225
|
+
}
|
|
226
|
+
/**
|
|
227
|
+
* A plugin's state field.
|
|
228
|
+
*
|
|
229
|
+
* @since 0.1.0
|
|
230
|
+
* @category models
|
|
231
|
+
*/
|
|
232
|
+
export interface StateField<T> {
|
|
233
|
+
init: (config: EditorStateConfig, instance: EditorState) => T;
|
|
234
|
+
apply: (tr: Transaction, value: T, oldState: EditorState, newState: EditorState) => T;
|
|
235
|
+
toJSON?: ((value: T) => any) | undefined;
|
|
236
|
+
fromJSON?: ((config: EditorStateConfig, value: any, state: EditorState) => T) | undefined;
|
|
237
|
+
}
|
|
238
|
+
/**
|
|
239
|
+
* A stateful object that can be installed in an editor by a plugin.
|
|
240
|
+
*
|
|
241
|
+
* @since 0.1.0
|
|
242
|
+
* @category models
|
|
243
|
+
*/
|
|
244
|
+
export type PluginView = {
|
|
245
|
+
update?: (view: EditorView, prevState: EditorState) => void;
|
|
246
|
+
destroy?: () => void;
|
|
247
|
+
};
|
|
248
|
+
/**
|
|
249
|
+
* This is the type passed to the `Plugin` constructor.
|
|
250
|
+
*
|
|
251
|
+
* @since 0.1.0
|
|
252
|
+
* @category models
|
|
253
|
+
*/
|
|
254
|
+
export interface PluginSpec<PluginState> {
|
|
255
|
+
props?: EditorProps<Plugin<PluginState>> | undefined;
|
|
256
|
+
state?: StateField<PluginState> | undefined;
|
|
257
|
+
key?: PluginKey | undefined;
|
|
258
|
+
view?: ((view: EditorView) => PluginView) | undefined;
|
|
259
|
+
filterTransaction?: ((tr: Transaction, state: EditorState) => boolean) | undefined;
|
|
260
|
+
appendTransaction?: (transactions: ReadonlyArray<Transaction>, oldState: EditorState, newState: EditorState) => Transaction | null | undefined | void;
|
|
261
|
+
[key: string]: any;
|
|
262
|
+
}
|
|
263
|
+
/**
|
|
264
|
+
* Plugins bundle functionality that can be added to an editor.
|
|
265
|
+
*
|
|
266
|
+
* @since 0.1.0
|
|
267
|
+
* @category models
|
|
268
|
+
*/
|
|
269
|
+
export declare class Plugin<PluginState = any> {
|
|
270
|
+
/** @internal */
|
|
271
|
+
readonly [CORE]: Plugin$1<any, any, any, any>;
|
|
272
|
+
/** The props exported by this plugin. */
|
|
273
|
+
readonly props: EditorProps<Plugin<PluginState>>;
|
|
274
|
+
/** The plugin's spec object. */
|
|
275
|
+
readonly spec: PluginSpec<PluginState>;
|
|
276
|
+
/** Create a plugin. */
|
|
277
|
+
constructor(spec: PluginSpec<PluginState>);
|
|
278
|
+
/** @internal */
|
|
279
|
+
get key(): string;
|
|
280
|
+
/** Extract the plugin's state field from an editor state. */
|
|
281
|
+
getState(state: EditorState): PluginState | undefined;
|
|
282
|
+
}
|
|
283
|
+
/**
|
|
284
|
+
* A key is used to tag plugins in a way that makes it possible to find
|
|
285
|
+
* them, given an editor state.
|
|
286
|
+
*
|
|
287
|
+
* @since 0.1.0
|
|
288
|
+
* @category models
|
|
289
|
+
*/
|
|
290
|
+
export declare class PluginKey<PluginState = any> {
|
|
291
|
+
/** @internal */
|
|
292
|
+
readonly [CORE]: PluginKey$1<PluginState>;
|
|
293
|
+
/** Create a plugin key. */
|
|
294
|
+
constructor(name?: string);
|
|
295
|
+
/** @internal */
|
|
296
|
+
get key(): string;
|
|
297
|
+
/** Get the active plugin with this key, if any, from an editor state. */
|
|
298
|
+
get(state: EditorState): Plugin<PluginState> | undefined;
|
|
299
|
+
/** Get the plugin's state from an editor state. */
|
|
300
|
+
getState(state: EditorState): PluginState | undefined;
|
|
301
|
+
}
|
|
302
|
+
/**
|
|
303
|
+
* The type of object passed to `EditorState.create`.
|
|
304
|
+
*
|
|
305
|
+
* @since 0.1.0
|
|
306
|
+
* @category models
|
|
307
|
+
*/
|
|
308
|
+
export interface EditorStateConfig {
|
|
309
|
+
schema?: Schema | undefined;
|
|
310
|
+
doc?: Node | undefined;
|
|
311
|
+
selection?: Selection | undefined;
|
|
312
|
+
storedMarks?: ReadonlyArray<Mark> | null | undefined;
|
|
313
|
+
plugins?: ReadonlyArray<Plugin> | undefined;
|
|
314
|
+
}
|
|
315
|
+
/**
|
|
316
|
+
* The state of a ProseMirror editor.
|
|
317
|
+
*
|
|
318
|
+
* @since 0.1.0
|
|
319
|
+
* @category models
|
|
320
|
+
*/
|
|
321
|
+
export declare class EditorState {
|
|
322
|
+
/** @internal */
|
|
323
|
+
readonly [CORE]: EditorState$1<any, any, any>;
|
|
324
|
+
/** @internal */
|
|
325
|
+
private constructor();
|
|
326
|
+
/** The current document. */
|
|
327
|
+
get doc(): Node;
|
|
328
|
+
/** The selection. */
|
|
329
|
+
get selection(): Selection;
|
|
330
|
+
/** A set of marks to apply to the next input. Will be null when no explicit marks have been set. */
|
|
331
|
+
get storedMarks(): ReadonlyArray<Mark> | null;
|
|
332
|
+
/** @internal */
|
|
333
|
+
get scrollToSelection(): number;
|
|
334
|
+
/** The schema of the state's document. */
|
|
335
|
+
get schema(): Schema;
|
|
336
|
+
/** The plugins that are active in this state. */
|
|
337
|
+
get plugins(): ReadonlyArray<Plugin>;
|
|
338
|
+
/** Apply the given transaction to produce a new state. */
|
|
339
|
+
apply(tr: Transaction): EditorState;
|
|
340
|
+
/** @internal */
|
|
341
|
+
filterTransaction(tr: Transaction, ignore?: number): boolean;
|
|
342
|
+
/** Verbose variant of `apply` that returns the precise transactions that were applied and the new state. */
|
|
343
|
+
applyTransaction(rootTr: Transaction): {
|
|
344
|
+
state: EditorState;
|
|
345
|
+
transactions: ReadonlyArray<Transaction>;
|
|
346
|
+
};
|
|
347
|
+
/** Start a transaction from this state. */
|
|
348
|
+
get tr(): Transaction;
|
|
349
|
+
/** Create a new state based on this one, but with an adjusted set of active plugins. */
|
|
350
|
+
reconfigure(config: {
|
|
351
|
+
plugins?: ReadonlyArray<Plugin>;
|
|
352
|
+
}): EditorState;
|
|
353
|
+
/** Serialize this state to JSON. */
|
|
354
|
+
toJSON(pluginFields?: {
|
|
355
|
+
[propName: string]: Plugin;
|
|
356
|
+
}): any;
|
|
357
|
+
/** Create a new state. */
|
|
358
|
+
static create(config: EditorStateConfig): EditorState;
|
|
359
|
+
/** Deserialize a JSON representation of a state. */
|
|
360
|
+
static fromJSON(config: {
|
|
361
|
+
schema: Schema;
|
|
362
|
+
plugins?: ReadonlyArray<Plugin>;
|
|
363
|
+
}, json: any, pluginFields?: {
|
|
364
|
+
[propName: string]: Plugin;
|
|
365
|
+
}): EditorState;
|
|
366
|
+
}
|
|
367
|
+
/**
|
|
368
|
+
* Convert a core (Effect) command into a ProseMirror-style command. The
|
|
369
|
+
* command is run synchronously; failures are thrown.
|
|
370
|
+
*
|
|
371
|
+
* @since 0.1.0
|
|
372
|
+
* @category conversions
|
|
373
|
+
*/
|
|
374
|
+
export declare const fromCoreCommand: (command: Command$1<any, any, never>) => Command;
|
|
375
|
+
/**
|
|
376
|
+
* Convert a ProseMirror-style command into a core (Effect) command.
|
|
377
|
+
*
|
|
378
|
+
* @since 0.1.0
|
|
379
|
+
* @category conversions
|
|
380
|
+
*/
|
|
381
|
+
export declare const toCoreCommand: (command: Command) => Command$1<any>;
|
|
382
|
+
/**
|
|
383
|
+
* Get the core (Effect API) object behind a facade. For a user-defined
|
|
384
|
+
* `Selection` subclass, this is a core selection that delegates to it.
|
|
385
|
+
*
|
|
386
|
+
* @since 0.1.0
|
|
387
|
+
* @category conversions
|
|
388
|
+
*/
|
|
389
|
+
export declare function toCore(state: EditorState): EditorState$1<any, never, any>;
|
|
390
|
+
export declare function toCore(tr: Transaction): Transaction$1;
|
|
391
|
+
export declare function toCore(selection: TextSelection): TextSelection$1;
|
|
392
|
+
export declare function toCore(selection: NodeSelection): NodeSelection$1;
|
|
393
|
+
export declare function toCore(selection: AllSelection): AllSelection$1;
|
|
394
|
+
export declare function toCore(selection: Selection): Selection$1;
|
|
395
|
+
export declare function toCore(range: SelectionRange): SelectionRange$1;
|
|
396
|
+
export declare function toCore(plugin: Plugin): Plugin$1<any, any, never, never>;
|
|
397
|
+
export declare function toCore(key: PluginKey): PluginKey$1;
|
|
398
|
+
export declare function toCore(bookmark: SelectionBookmark): SelectionBookmark$1;
|
|
399
|
+
export declare function toCore(command: Command): Command$1<any>;
|
|
400
|
+
/**
|
|
401
|
+
* Get the facade for a core (Effect API) object.
|
|
402
|
+
*
|
|
403
|
+
* @since 0.1.0
|
|
404
|
+
* @category conversions
|
|
405
|
+
*/
|
|
406
|
+
export declare function fromCore(state: EditorState$1<any, any, any>): EditorState;
|
|
407
|
+
export declare function fromCore(tr: Transaction$1<any>): Transaction;
|
|
408
|
+
export declare function fromCore(selection: TextSelection$1<any>): TextSelection;
|
|
409
|
+
export declare function fromCore(selection: NodeSelection$1<any>): NodeSelection;
|
|
410
|
+
export declare function fromCore(selection: AllSelection$1<any>): AllSelection;
|
|
411
|
+
export declare function fromCore(selection: Selection$1<any>): Selection;
|
|
412
|
+
export declare function fromCore(range: SelectionRange$1<any>): SelectionRange;
|
|
413
|
+
export declare function fromCore(plugin: Plugin$1<any, any, any, any>): Plugin;
|
|
414
|
+
export declare function fromCore(key: PluginKey$1<any>): PluginKey;
|
|
415
|
+
export declare function fromCore(command: Command$1<any, any, never>): Command;
|