@thomasfosterau/effect-richtext 0.0.0 → 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 +117 -1
- 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 +200 -4
|
@@ -0,0 +1,411 @@
|
|
|
1
|
+
import { Decoration as Decoration$1, DecorationSet as DecorationSet$1, DecorationSource as DecorationSource$1 } from "../view/decoration.js";
|
|
2
|
+
import { EditorView as EditorView$1 } from "../view/view.js";
|
|
3
|
+
import "../view.js";
|
|
4
|
+
import { CORE } from "./internal/core.js";
|
|
5
|
+
import { DOMParser, DOMSerializer, Mark, Node, ResolvedPos, Slice } from "./model.js";
|
|
6
|
+
import { EditorState, Plugin, Selection, Transaction } from "./state.js";
|
|
7
|
+
import { Mapping } from "./transform.js";
|
|
8
|
+
/**
|
|
9
|
+
* A DOM node.
|
|
10
|
+
*
|
|
11
|
+
* @since 0.1.0
|
|
12
|
+
* @category models
|
|
13
|
+
*/
|
|
14
|
+
export type DOMNode = globalThis.Node;
|
|
15
|
+
/**
|
|
16
|
+
* A rectangle.
|
|
17
|
+
*
|
|
18
|
+
* @since 0.1.0
|
|
19
|
+
* @category models
|
|
20
|
+
*/
|
|
21
|
+
export type Rect = {
|
|
22
|
+
left: number;
|
|
23
|
+
right: number;
|
|
24
|
+
top: number;
|
|
25
|
+
bottom: number;
|
|
26
|
+
};
|
|
27
|
+
/**
|
|
28
|
+
* A record of a DOM mutation.
|
|
29
|
+
*
|
|
30
|
+
* @since 0.1.0
|
|
31
|
+
* @category models
|
|
32
|
+
*/
|
|
33
|
+
export type ViewMutationRecord = MutationRecord | {
|
|
34
|
+
type: "selection";
|
|
35
|
+
target: DOMNode;
|
|
36
|
+
};
|
|
37
|
+
/**
|
|
38
|
+
* A set of attributes to add to a decorated node.
|
|
39
|
+
*
|
|
40
|
+
* @since 0.1.0
|
|
41
|
+
* @category models
|
|
42
|
+
*/
|
|
43
|
+
export type DecorationAttrs = {
|
|
44
|
+
nodeName?: string;
|
|
45
|
+
class?: string;
|
|
46
|
+
style?: string;
|
|
47
|
+
[attribute: string]: string | undefined;
|
|
48
|
+
};
|
|
49
|
+
/**
|
|
50
|
+
* Decoration objects can be provided to the view through the
|
|
51
|
+
* `decorations` prop.
|
|
52
|
+
*
|
|
53
|
+
* @since 0.1.0
|
|
54
|
+
* @category models
|
|
55
|
+
*/
|
|
56
|
+
export declare class Decoration {
|
|
57
|
+
/** @internal */
|
|
58
|
+
readonly [CORE]: Decoration$1;
|
|
59
|
+
/** The start position of the decoration. */
|
|
60
|
+
get from(): number;
|
|
61
|
+
/** The end position. Will be the same as `from` for widget decorations. */
|
|
62
|
+
get to(): number;
|
|
63
|
+
/** @internal */
|
|
64
|
+
get type(): any;
|
|
65
|
+
/** The spec provided when creating this decoration. */
|
|
66
|
+
get spec(): any;
|
|
67
|
+
/** @internal */
|
|
68
|
+
get inline(): boolean;
|
|
69
|
+
/** @internal */
|
|
70
|
+
get widget(): boolean;
|
|
71
|
+
/** @internal */
|
|
72
|
+
eq(other: Decoration, offset?: number): boolean;
|
|
73
|
+
/** Creates a widget decoration, which is a DOM node that's shown in the document at the given position. */
|
|
74
|
+
static widget(pos: number, toDOM: ((view: EditorView, getPos: () => number | undefined) => DOMNode) | DOMNode, spec?: {
|
|
75
|
+
side?: number;
|
|
76
|
+
relaxedSide?: boolean;
|
|
77
|
+
marks?: ReadonlyArray<Mark>;
|
|
78
|
+
stopEvent?: (event: Event) => boolean;
|
|
79
|
+
ignoreSelection?: boolean;
|
|
80
|
+
key?: string;
|
|
81
|
+
destroy?: (node: DOMNode) => void;
|
|
82
|
+
[key: string]: any;
|
|
83
|
+
}): Decoration;
|
|
84
|
+
/** Creates an inline decoration, which adds the given attributes to each inline node between `from` and `to`. */
|
|
85
|
+
static inline(from: number, to: number, attrs: DecorationAttrs, spec?: {
|
|
86
|
+
inclusiveStart?: boolean;
|
|
87
|
+
inclusiveEnd?: boolean;
|
|
88
|
+
[key: string]: any;
|
|
89
|
+
}): Decoration;
|
|
90
|
+
/** Creates a node decoration. */
|
|
91
|
+
static node(from: number, to: number, attrs: DecorationAttrs, spec?: any): Decoration;
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* An object that can provide decorations.
|
|
95
|
+
*
|
|
96
|
+
* @since 0.1.0
|
|
97
|
+
* @category models
|
|
98
|
+
*/
|
|
99
|
+
export interface DecorationSource {
|
|
100
|
+
map: (mapping: Mapping, node: Node) => DecorationSource;
|
|
101
|
+
forChild(offset: number, child: Node): DecorationSource;
|
|
102
|
+
eq(other: DecorationSource): boolean;
|
|
103
|
+
forEachSet(f: (set: DecorationSet) => void): void;
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* A collection of decorations, organized in such a way that the
|
|
107
|
+
* drawing algorithm can efficiently use and compare them.
|
|
108
|
+
*
|
|
109
|
+
* @since 0.1.0
|
|
110
|
+
* @category models
|
|
111
|
+
*/
|
|
112
|
+
export declare class DecorationSet implements DecorationSource {
|
|
113
|
+
/** @internal */
|
|
114
|
+
readonly [CORE]: DecorationSet$1;
|
|
115
|
+
/** Create a set of decorations, using the structure of the given document. */
|
|
116
|
+
static create(doc: Node, decorations: Array<Decoration>): DecorationSet;
|
|
117
|
+
/** Find all decorations in this set which touch the given range (including decorations that start or end directly at the boundaries) and match the given predicate on their spec. */
|
|
118
|
+
find(start?: number, end?: number, predicate?: (spec: any) => boolean): Array<Decoration>;
|
|
119
|
+
/** Map the set of decorations in response to a change in the document. */
|
|
120
|
+
map(mapping: Mapping, doc: Node, options?: {
|
|
121
|
+
onRemove?: (decorationSpec: any) => void;
|
|
122
|
+
}): DecorationSet;
|
|
123
|
+
/** Add the given array of decorations to the ones in the set, producing a new set. */
|
|
124
|
+
add(doc: Node, decorations: Array<Decoration>): DecorationSet;
|
|
125
|
+
/** Create a new set that contains the decorations in this set, minus the ones in the given array. */
|
|
126
|
+
remove(decorations: Array<Decoration>): DecorationSet;
|
|
127
|
+
/** @internal */
|
|
128
|
+
forChild(offset: number, node: Node): DecorationSource;
|
|
129
|
+
/** @internal */
|
|
130
|
+
eq(other: DecorationSource): boolean;
|
|
131
|
+
/** @internal */
|
|
132
|
+
locals(node: Node): ReadonlyArray<Decoration>;
|
|
133
|
+
/** @internal */
|
|
134
|
+
forEachSet(f: (set: DecorationSet) => void): void;
|
|
135
|
+
/** The empty set of decorations. */
|
|
136
|
+
static empty: DecorationSet;
|
|
137
|
+
/** @internal */
|
|
138
|
+
get local(): ReadonlyArray<Decoration>;
|
|
139
|
+
/** @internal */
|
|
140
|
+
get children(): ReadonlyArray<number | DecorationSet>;
|
|
141
|
+
/** @internal */
|
|
142
|
+
static removeOverlap(spans: ReadonlyArray<Decoration>): ReadonlyArray<Decoration>;
|
|
143
|
+
}
|
|
144
|
+
/**
|
|
145
|
+
* By default, document nodes are rendered using the result of the
|
|
146
|
+
* `toDOM` method of their spec, and managed entirely by the editor.
|
|
147
|
+
* For some use cases you want more control; node views allow that.
|
|
148
|
+
*
|
|
149
|
+
* @since 0.1.0
|
|
150
|
+
* @category models
|
|
151
|
+
*/
|
|
152
|
+
export interface NodeView {
|
|
153
|
+
dom: DOMNode;
|
|
154
|
+
contentDOM?: HTMLElement | null | undefined;
|
|
155
|
+
update?: ((node: Node, decorations: ReadonlyArray<Decoration>, innerDecorations: DecorationSource) => boolean) | undefined;
|
|
156
|
+
multiType?: boolean | undefined;
|
|
157
|
+
selectNode?: (() => void) | undefined;
|
|
158
|
+
deselectNode?: (() => void) | undefined;
|
|
159
|
+
setSelection?: ((anchor: number, head: number, root: Document | ShadowRoot) => void) | undefined;
|
|
160
|
+
stopEvent?: ((event: Event) => boolean) | undefined;
|
|
161
|
+
ignoreMutation?: ((mutation: ViewMutationRecord) => boolean) | undefined;
|
|
162
|
+
destroy?: (() => void) | undefined;
|
|
163
|
+
}
|
|
164
|
+
/**
|
|
165
|
+
* Objects returned as mark views.
|
|
166
|
+
*
|
|
167
|
+
* @since 0.1.0
|
|
168
|
+
* @category models
|
|
169
|
+
*/
|
|
170
|
+
export interface MarkView {
|
|
171
|
+
dom: HTMLElement;
|
|
172
|
+
contentDOM?: HTMLElement | null | undefined;
|
|
173
|
+
ignoreMutation?: ((mutation: ViewMutationRecord) => boolean) | undefined;
|
|
174
|
+
destroy?: (() => void) | undefined;
|
|
175
|
+
}
|
|
176
|
+
/**
|
|
177
|
+
* The type of function provided to create node views.
|
|
178
|
+
*
|
|
179
|
+
* @since 0.1.0
|
|
180
|
+
* @category models
|
|
181
|
+
*/
|
|
182
|
+
export type NodeViewConstructor = (node: Node, view: EditorView, getPos: () => number | undefined, decorations: ReadonlyArray<Decoration>, innerDecorations: DecorationSource) => NodeView;
|
|
183
|
+
/**
|
|
184
|
+
* The function types used to create mark views.
|
|
185
|
+
*
|
|
186
|
+
* @since 0.1.0
|
|
187
|
+
* @category models
|
|
188
|
+
*/
|
|
189
|
+
export type MarkViewConstructor = (mark: Mark, view: EditorView, inline: boolean) => MarkView;
|
|
190
|
+
/**
|
|
191
|
+
* Helper type that maps event names to event object types.
|
|
192
|
+
*
|
|
193
|
+
* @since 0.1.0
|
|
194
|
+
* @category models
|
|
195
|
+
*/
|
|
196
|
+
export interface DOMEventMap extends HTMLElementEventMap {
|
|
197
|
+
[event: string]: any;
|
|
198
|
+
}
|
|
199
|
+
/**
|
|
200
|
+
* Props are configuration values that can be passed to an editor view
|
|
201
|
+
* or included in a plugin.
|
|
202
|
+
*
|
|
203
|
+
* @since 0.1.0
|
|
204
|
+
* @category models
|
|
205
|
+
*/
|
|
206
|
+
export interface EditorProps<P = any> {
|
|
207
|
+
handleDOMEvents?: { [event in keyof DOMEventMap]?: (this: P, view: EditorView, event: DOMEventMap[event]) => boolean | void; };
|
|
208
|
+
handleKeyDown?: ((this: P, view: EditorView, event: KeyboardEvent) => boolean | void) | undefined;
|
|
209
|
+
handleKeyPress?: ((this: P, view: EditorView, event: KeyboardEvent) => boolean | void) | undefined;
|
|
210
|
+
handleTextInput?: (this: P, view: EditorView, from: number, to: number, text: string, deflt: () => Transaction) => boolean | void;
|
|
211
|
+
handleClickOn?: (this: P, view: EditorView, pos: number, node: Node, nodePos: number, event: MouseEvent, direct: boolean) => boolean | void;
|
|
212
|
+
handleClick?: ((this: P, view: EditorView, pos: number, event: MouseEvent) => boolean | void) | undefined;
|
|
213
|
+
handleDoubleClickOn?: (this: P, view: EditorView, pos: number, node: Node, nodePos: number, event: MouseEvent, direct: boolean) => boolean | void;
|
|
214
|
+
handleDoubleClick?: ((this: P, view: EditorView, pos: number, event: MouseEvent) => boolean | void) | undefined;
|
|
215
|
+
handleTripleClickOn?: (this: P, view: EditorView, pos: number, node: Node, nodePos: number, event: MouseEvent, direct: boolean) => boolean | void;
|
|
216
|
+
handleTripleClick?: ((this: P, view: EditorView, pos: number, event: MouseEvent) => boolean | void) | undefined;
|
|
217
|
+
handlePaste?: ((this: P, view: EditorView, event: ClipboardEvent, slice: Slice) => boolean | void) | undefined;
|
|
218
|
+
handleDrop?: ((this: P, view: EditorView, event: DragEvent, slice: Slice, moved: boolean) => boolean | void) | undefined;
|
|
219
|
+
handleScrollToSelection?: ((this: P, view: EditorView) => boolean) | undefined;
|
|
220
|
+
dragCopies?: ((event: DragEvent) => boolean) | undefined;
|
|
221
|
+
createSelectionBetween?: (this: P, view: EditorView, anchor: ResolvedPos, head: ResolvedPos) => Selection | null | undefined;
|
|
222
|
+
domParser?: DOMParser | undefined;
|
|
223
|
+
transformPastedHTML?: ((this: P, html: string, view: EditorView) => string) | undefined;
|
|
224
|
+
clipboardParser?: DOMParser | undefined;
|
|
225
|
+
transformPastedText?: ((this: P, text: string, plain: boolean, view: EditorView) => string) | undefined;
|
|
226
|
+
clipboardTextParser?: (this: P, text: string, $context: ResolvedPos, plain: boolean, view: EditorView) => Slice | null | undefined;
|
|
227
|
+
transformPasted?: ((this: P, slice: Slice, view: EditorView, plain: boolean) => Slice) | undefined;
|
|
228
|
+
transformCopied?: ((this: P, slice: Slice, view: EditorView) => Slice) | undefined;
|
|
229
|
+
nodeViews?: {
|
|
230
|
+
[node: string]: NodeViewConstructor;
|
|
231
|
+
} | undefined;
|
|
232
|
+
markViews?: {
|
|
233
|
+
[mark: string]: MarkViewConstructor;
|
|
234
|
+
} | undefined;
|
|
235
|
+
clipboardSerializer?: DOMSerializer | undefined;
|
|
236
|
+
clipboardTextSerializer?: ((this: P, content: Slice, view: EditorView) => string) | undefined;
|
|
237
|
+
decorations?: ((this: P, state: EditorState) => DecorationSource | null | undefined) | undefined;
|
|
238
|
+
editable?: ((this: P, state: EditorState) => boolean) | undefined;
|
|
239
|
+
attributes?: ({
|
|
240
|
+
[name: string]: string;
|
|
241
|
+
} | ((state: EditorState) => {
|
|
242
|
+
[name: string]: string;
|
|
243
|
+
})) | undefined;
|
|
244
|
+
scrollThreshold?: number | {
|
|
245
|
+
top: number;
|
|
246
|
+
right: number;
|
|
247
|
+
bottom: number;
|
|
248
|
+
left: number;
|
|
249
|
+
} | undefined;
|
|
250
|
+
scrollMargin?: number | {
|
|
251
|
+
top: number;
|
|
252
|
+
right: number;
|
|
253
|
+
bottom: number;
|
|
254
|
+
left: number;
|
|
255
|
+
} | undefined;
|
|
256
|
+
}
|
|
257
|
+
/**
|
|
258
|
+
* The props object given directly to the editor view supports some
|
|
259
|
+
* fields that can't be used in plugins.
|
|
260
|
+
*
|
|
261
|
+
* @since 0.1.0
|
|
262
|
+
* @category models
|
|
263
|
+
*/
|
|
264
|
+
export interface DirectEditorProps extends EditorProps {
|
|
265
|
+
state: EditorState;
|
|
266
|
+
plugins?: ReadonlyArray<Plugin> | undefined;
|
|
267
|
+
dispatchTransaction?: ((this: EditorView, tr: Transaction) => void) | undefined;
|
|
268
|
+
}
|
|
269
|
+
/**
|
|
270
|
+
* An editor view manages the DOM structure that represents an editable
|
|
271
|
+
* document.
|
|
272
|
+
*
|
|
273
|
+
* @since 0.1.0
|
|
274
|
+
* @category models
|
|
275
|
+
*/
|
|
276
|
+
export declare class EditorView {
|
|
277
|
+
/** @internal */
|
|
278
|
+
readonly [CORE]: EditorView$1<any, any, any>;
|
|
279
|
+
/** @internal */
|
|
280
|
+
_props: DirectEditorProps;
|
|
281
|
+
/** @internal */
|
|
282
|
+
private propsCache;
|
|
283
|
+
/** Create a view. */
|
|
284
|
+
constructor(place: null | DOMNode | ((editor: HTMLElement) => void) | {
|
|
285
|
+
mount: HTMLElement;
|
|
286
|
+
}, props: DirectEditorProps);
|
|
287
|
+
private propsToCore;
|
|
288
|
+
/** The view's current state. */
|
|
289
|
+
get state(): EditorState;
|
|
290
|
+
/** An editable DOM node containing the document. */
|
|
291
|
+
get dom(): HTMLElement;
|
|
292
|
+
/** Indicates whether the editor is currently editable. */
|
|
293
|
+
get editable(): boolean;
|
|
294
|
+
/** When editor content is being dragged, this object contains information about the dragged slice and whether it is being copied or moved. */
|
|
295
|
+
get dragging(): null | {
|
|
296
|
+
readonly slice: Slice;
|
|
297
|
+
readonly move: boolean;
|
|
298
|
+
};
|
|
299
|
+
set dragging(value: null | {
|
|
300
|
+
readonly slice: Slice;
|
|
301
|
+
readonly move: boolean;
|
|
302
|
+
});
|
|
303
|
+
/** Holds `true` when a composition is active. */
|
|
304
|
+
get composing(): boolean;
|
|
305
|
+
/** The view's current props. */
|
|
306
|
+
get props(): DirectEditorProps;
|
|
307
|
+
/** Update the view's props. Will immediately cause an update to the DOM. */
|
|
308
|
+
update(props: DirectEditorProps): void;
|
|
309
|
+
/** Update the view by updating existing props object with the object given as argument. */
|
|
310
|
+
setProps(props: Partial<DirectEditorProps>): void;
|
|
311
|
+
/** Update the editor's `state` prop, without touching any of the other props. */
|
|
312
|
+
updateState(state: EditorState): void;
|
|
313
|
+
/** Goes over the values of a prop, first those provided directly, then those from plugins given to the view, then from plugins in the state (in order), and calls `f` every time a non-undefined value is found. */
|
|
314
|
+
someProp<PropName extends keyof EditorProps, Result>(propName: PropName, f: (value: NonNullable<EditorProps[PropName]>) => Result): Result | undefined;
|
|
315
|
+
someProp<PropName extends keyof EditorProps>(propName: PropName): NonNullable<EditorProps[PropName]> | undefined;
|
|
316
|
+
/** Query whether the view has focus. */
|
|
317
|
+
hasFocus(): boolean;
|
|
318
|
+
/** Focus the editor. */
|
|
319
|
+
focus(): void;
|
|
320
|
+
/** Get the document root in which the editor exists. */
|
|
321
|
+
get root(): Document | ShadowRoot;
|
|
322
|
+
/** When an existing editor view is moved to a new document or shadow tree, call this to make it recompute its root. */
|
|
323
|
+
updateRoot(): void;
|
|
324
|
+
/** Given a pair of viewport coordinates, return the document position that corresponds to them. */
|
|
325
|
+
posAtCoords(coords: {
|
|
326
|
+
left: number;
|
|
327
|
+
top: number;
|
|
328
|
+
}): {
|
|
329
|
+
pos: number;
|
|
330
|
+
inside: number;
|
|
331
|
+
} | null;
|
|
332
|
+
/** Returns the viewport rectangle at a given document position. */
|
|
333
|
+
coordsAtPos(pos: number, side?: number): Rect;
|
|
334
|
+
/** Find the DOM position that corresponds to the given document position. */
|
|
335
|
+
domAtPos(pos: number, side?: number): {
|
|
336
|
+
node: DOMNode;
|
|
337
|
+
offset: number;
|
|
338
|
+
};
|
|
339
|
+
/** Find the DOM node that represents the document node after the given position. */
|
|
340
|
+
nodeDOM(pos: number): DOMNode | null;
|
|
341
|
+
/** Find the document position that corresponds to a given DOM position. */
|
|
342
|
+
posAtDOM(node: DOMNode, offset: number, bias?: number): number;
|
|
343
|
+
/** Find out whether the selection is at the end of a textblock when moving in a given direction. */
|
|
344
|
+
endOfTextblock(dir: "up" | "down" | "left" | "right" | "forward" | "backward", state?: EditorState): boolean;
|
|
345
|
+
/** Run the editor's paste logic with the given HTML string. */
|
|
346
|
+
pasteHTML(html: string, event?: ClipboardEvent): boolean;
|
|
347
|
+
/** Run the editor's paste logic with the given plain-text input. */
|
|
348
|
+
pasteText(text: string, event?: ClipboardEvent): boolean;
|
|
349
|
+
/** Serialize the given slice as it would be if it was copied from this editor. */
|
|
350
|
+
serializeForClipboard(slice: Slice): {
|
|
351
|
+
dom: HTMLElement;
|
|
352
|
+
text: string;
|
|
353
|
+
slice: Slice;
|
|
354
|
+
};
|
|
355
|
+
/** Removes the editor from the DOM and destroys all node views. */
|
|
356
|
+
destroy(): void;
|
|
357
|
+
/** This is true when the view has been destroyed (and thus should not be used anymore). */
|
|
358
|
+
get isDestroyed(): boolean;
|
|
359
|
+
/** Used for testing. */
|
|
360
|
+
dispatchEvent(event: Event): void;
|
|
361
|
+
/** Dispatch a transaction. */
|
|
362
|
+
dispatch(tr: Transaction): void;
|
|
363
|
+
/** @internal */
|
|
364
|
+
domSelectionRange(): any;
|
|
365
|
+
/** @internal */
|
|
366
|
+
domSelection(): globalThis.Selection | null;
|
|
367
|
+
/** @internal */
|
|
368
|
+
scrollToSelection(): void;
|
|
369
|
+
/** @internal */
|
|
370
|
+
get domObserver(): any;
|
|
371
|
+
/** @internal */
|
|
372
|
+
get docView(): any;
|
|
373
|
+
/** @internal */
|
|
374
|
+
get input(): any;
|
|
375
|
+
/** @internal */
|
|
376
|
+
get focused(): boolean;
|
|
377
|
+
/** @internal */
|
|
378
|
+
get markCursor(): ReadonlyArray<Mark> | null;
|
|
379
|
+
/** @internal */
|
|
380
|
+
get cursorWrapper(): any;
|
|
381
|
+
/** @internal */
|
|
382
|
+
get lastSelectedViewDesc(): any;
|
|
383
|
+
/** @internal */
|
|
384
|
+
get trackWrites(): DOMNode | null;
|
|
385
|
+
/** @internal */
|
|
386
|
+
get nodeViews(): any;
|
|
387
|
+
}
|
|
388
|
+
/** @internal */
|
|
389
|
+
export declare const __parseFromClipboard: (view: EditorView, text: string, html: string | null, plainText: boolean, $context: ResolvedPos) => Slice | null;
|
|
390
|
+
/** @internal */
|
|
391
|
+
export declare const __endComposition: (view: EditorView, restarting?: boolean) => boolean;
|
|
392
|
+
/**
|
|
393
|
+
* Get the core (Effect API) object behind a facade.
|
|
394
|
+
*
|
|
395
|
+
* @since 0.1.0
|
|
396
|
+
* @category conversions
|
|
397
|
+
*/
|
|
398
|
+
export declare function toCore(view: EditorView): EditorView$1<any, any, any>;
|
|
399
|
+
export declare function toCore(decoration: Decoration): Decoration$1;
|
|
400
|
+
export declare function toCore(set: DecorationSet): DecorationSet$1;
|
|
401
|
+
export declare function toCore(source: DecorationSource): DecorationSource$1;
|
|
402
|
+
/**
|
|
403
|
+
* Get the facade for a core (Effect API) object.
|
|
404
|
+
*
|
|
405
|
+
* @since 0.1.0
|
|
406
|
+
* @category conversions
|
|
407
|
+
*/
|
|
408
|
+
export declare function fromCore(view: EditorView$1<any, any, any>): EditorView;
|
|
409
|
+
export declare function fromCore(decoration: Decoration$1): Decoration;
|
|
410
|
+
export declare function fromCore(set: DecorationSet$1): DecorationSet;
|
|
411
|
+
export declare function fromCore(source: DecorationSource$1): DecorationSource;
|