@thomasfosterau/prosekit-utilities 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 +21 -0
- package/README.md +446 -1
- package/dist/derive-BtbsOqS7.js +479 -0
- package/dist/derive.d.ts +2 -0
- package/dist/derive.js +1 -0
- package/dist/document-shape-CrKjPIEf.d.ts +195 -0
- package/dist/drizzle.d.ts +76 -0
- package/dist/drizzle.js +95 -0
- package/dist/envelope-DQS7tt8f.js +87 -0
- package/dist/index-DlgceBHe.d.ts +266 -0
- package/dist/index.d.ts +203 -0
- package/dist/index.js +723 -0
- package/dist/prosekit.d.ts +3218 -0
- package/dist/prosekit.js +827 -0
- package/dist/rolldown-runtime-D8jQpDG7.js +12 -0
- package/package.json +66 -6
|
@@ -0,0 +1,3218 @@
|
|
|
1
|
+
import { n as RegistryCache, y as RequiredAttribute } from "./index-DlgceBHe.js";
|
|
2
|
+
import { f as NodeJSON, n as DocumentShape, u as DocumentJSON } from "./document-shape-CrKjPIEf.js";
|
|
3
|
+
import * as Effect from "effect/Effect";
|
|
4
|
+
import * as Schema$2 from "effect/Schema";
|
|
5
|
+
import { Extension } from "prosekit/core";
|
|
6
|
+
import { BoldExtension, defineBold } from "prosekit/extensions/bold";
|
|
7
|
+
import { CodeExtension, defineCode } from "prosekit/extensions/code";
|
|
8
|
+
import { ItalicExtension, defineItalic } from "prosekit/extensions/italic";
|
|
9
|
+
import { LinkExtension, defineLink } from "prosekit/extensions/link";
|
|
10
|
+
import { StrikeExtension, defineStrike } from "prosekit/extensions/strike";
|
|
11
|
+
import { UnderlineExtension, defineUnderline } from "prosekit/extensions/underline";
|
|
12
|
+
import { DocExtension, defineDoc } from "prosekit/extensions/doc";
|
|
13
|
+
import { TextExtension, defineText } from "prosekit/extensions/text";
|
|
14
|
+
import { ParagraphExtension, defineParagraph } from "prosekit/extensions/paragraph";
|
|
15
|
+
import { HeadingExtension, defineHeading } from "prosekit/extensions/heading";
|
|
16
|
+
import { ListExtension, defineList } from "prosekit/extensions/list";
|
|
17
|
+
import { BlockquoteExtension, defineBlockquote } from "prosekit/extensions/blockquote";
|
|
18
|
+
import { ImageExtension, defineImage } from "prosekit/extensions/image";
|
|
19
|
+
import { HorizontalRuleExtension, defineHorizontalRule } from "prosekit/extensions/horizontal-rule";
|
|
20
|
+
import { HardBreakExtension, defineHardBreak } from "prosekit/extensions/hard-break";
|
|
21
|
+
import { TableExtension, defineTable } from "prosekit/extensions/table";
|
|
22
|
+
import { CodeBlockExtension, defineCodeBlock } from "prosekit/extensions/code-block";
|
|
23
|
+
import { Attrs, MarkType, NodeType, ProseMirrorNode, Schema } from "@prosekit/pm/model";
|
|
24
|
+
import "@prosekit/pm/state";
|
|
25
|
+
import "@prosekit/pm/view";
|
|
26
|
+
import "@prosekit/pm/inputrules";
|
|
27
|
+
/**
|
|
28
|
+
* The record `attributeOverlay()` consumes: node or mark name, then attribute
|
|
29
|
+
* name, then the Effect Schema for that attribute's value — optionally
|
|
30
|
+
* wrapped in `required(…)`.
|
|
31
|
+
*/
|
|
32
|
+
type AttributeOverrides = Readonly<Record<string, Readonly<Record<string, Schema$2.Top | RequiredAttribute>>>>;
|
|
33
|
+
/**
|
|
34
|
+
* The overlay for ProseKit's stock nodes — the default when
|
|
35
|
+
* `defineDocumentSchema` is given no `attributes`.
|
|
36
|
+
*
|
|
37
|
+
* Every entry here is either a value type ProseMirror cannot express or a
|
|
38
|
+
* required-ness correction, and nothing else needs one: `link`'s
|
|
39
|
+
* `href`/`target`/`rel`, `list`'s `checked`/`collapsed` and the table cells'
|
|
40
|
+
* `colspan`/`rowspan` all derive correctly from ProseMirror's own `validate`
|
|
41
|
+
* string or default value.
|
|
42
|
+
*
|
|
43
|
+
* **Why `required(…)`.** ProseMirror's rule is that *any* attribute with a
|
|
44
|
+
* `default` — even one this overlay supplies a value type for — becomes an
|
|
45
|
+
* omissible key. But `heading.level`, `list.kind`, `image.src`/`width`/`height`
|
|
46
|
+
* and `codeBlock.language` are attributes a live editor always serialises:
|
|
47
|
+
* `Node.toJSON()` includes every attr, defaulted or not, so an
|
|
48
|
+
* editor-produced document always carries them. Leaving them omissible would
|
|
49
|
+
* let a machine-authored document skip the very value it was supposed to
|
|
50
|
+
* specify — a heading with no level, an image with no source — and still
|
|
51
|
+
* validate. `required(…)` closes that gap. `colwidth` is deliberately *not*
|
|
52
|
+
* wrapped: a cell that has never been resized genuinely has none.
|
|
53
|
+
*/
|
|
54
|
+
export declare const STANDARD_ATTRIBUTE_OVERRIDES: AttributeOverrides;
|
|
55
|
+
/**
|
|
56
|
+
* The overlay entry for `defineMention()`, to merge over
|
|
57
|
+
* {@link STANDARD_ATTRIBUTE_OVERRIDES} when a grammar includes the mention
|
|
58
|
+
* node.
|
|
59
|
+
*
|
|
60
|
+
* Both attributes are `required(…)` for the reason above: a mention the editor
|
|
61
|
+
* produced always carries an id and a label, and a mention without an id
|
|
62
|
+
* resolves to nothing.
|
|
63
|
+
*/
|
|
64
|
+
export declare const MENTION_ATTRIBUTE_OVERRIDES: AttributeOverrides;
|
|
65
|
+
/**
|
|
66
|
+
* Merges overlays left to right, per node and then per attribute; a later
|
|
67
|
+
* entry wins.
|
|
68
|
+
*
|
|
69
|
+
* ```ts
|
|
70
|
+
* const attributes = mergeAttributeOverrides(
|
|
71
|
+
* STANDARD_ATTRIBUTE_OVERRIDES,
|
|
72
|
+
* MENTION_ATTRIBUTE_OVERRIDES,
|
|
73
|
+
* );
|
|
74
|
+
* ```
|
|
75
|
+
*
|
|
76
|
+
* The merge is shallow *per node*: two overlays that both name `image` end up
|
|
77
|
+
* with the union of their attribute entries rather than one replacing the
|
|
78
|
+
* other, so an application can override `image.src` alone without restating
|
|
79
|
+
* `width` and `height`. Nothing is mutated — every call returns a new record.
|
|
80
|
+
*/
|
|
81
|
+
export declare const mergeAttributeOverrides: (...overrides: ReadonlyArray<AttributeOverrides>) => AttributeOverrides;
|
|
82
|
+
declare const DocumentDecodeError_base: Schema$2.Class<DocumentDecodeError, Schema$2.TaggedStruct<"DocumentDecodeError", {
|
|
83
|
+
readonly document: Schema$2.String;
|
|
84
|
+
readonly issue: Schema$2.Defect;
|
|
85
|
+
}>, import("effect/Cause").YieldableError>;
|
|
86
|
+
/**
|
|
87
|
+
* A decode that failed, as a tagged error rather than a thrown
|
|
88
|
+
* `SchemaError` — for a caller that wants the failure in an `Effect` channel
|
|
89
|
+
* it can catch by tag.
|
|
90
|
+
*
|
|
91
|
+
* `document` is the shape's name, so one handler can tell a rejected title
|
|
92
|
+
* from a rejected body. `issue` is the underlying `SchemaError` carried
|
|
93
|
+
* through `Schema.Defect()`, which is JSON-encodable, so the error survives a
|
|
94
|
+
* wire hop to a client or a log sink.
|
|
95
|
+
*/
|
|
96
|
+
export declare class DocumentDecodeError extends /* @__PURE__ */ DocumentDecodeError_base {}
|
|
97
|
+
/** How {@link defineDocumentSchema} builds a document schema. */
|
|
98
|
+
interface DocumentSchemaOptions {
|
|
99
|
+
/**
|
|
100
|
+
* The grammar, as a factory. Called at most once, the first time a document
|
|
101
|
+
* is actually validated — see {@link DocumentSchema.schema}.
|
|
102
|
+
*/
|
|
103
|
+
readonly extension: () => Extension;
|
|
104
|
+
/**
|
|
105
|
+
* The attribute overlay. Defaults to `STANDARD_ATTRIBUTE_OVERRIDES`; an
|
|
106
|
+
* application with opt-in nodes passes
|
|
107
|
+
* `mergeAttributeOverrides(STANDARD_ATTRIBUTE_OVERRIDES, …)`.
|
|
108
|
+
*/
|
|
109
|
+
readonly attributes?: AttributeOverrides | undefined;
|
|
110
|
+
/**
|
|
111
|
+
* A `RegistryCache` to share with other document schemas built from
|
|
112
|
+
* overlapping extensions. Defaults to a cache private to this schema.
|
|
113
|
+
*
|
|
114
|
+
* Share one only between grammars whose mark sets match and whose same-named
|
|
115
|
+
* types are defined identically; otherwise the first schema forced decides
|
|
116
|
+
* the shared `text` node's marks for the others. See
|
|
117
|
+
* {@link defineDocumentSchema} for the failure this causes.
|
|
118
|
+
*/
|
|
119
|
+
readonly registryCache?: RegistryCache | undefined;
|
|
120
|
+
}
|
|
121
|
+
/** One document surface's ProseKit half: the grammar, the wire schema and the guard. */
|
|
122
|
+
interface DocumentSchema<Name extends string> {
|
|
123
|
+
/** The shape this schema was declared against, and which {@link install} upgrades. */
|
|
124
|
+
readonly shape: DocumentShape<Name>;
|
|
125
|
+
/** The grammar factory, as passed in. */
|
|
126
|
+
readonly extension: () => Extension;
|
|
127
|
+
/** The compiled ProseMirror schema, built on first use and cached (see `lazySchema`). */
|
|
128
|
+
readonly schema: () => Schema;
|
|
129
|
+
/** The derived wire schema: the envelope, with `shape.name` in place of ProseMirror's `doc`. */
|
|
130
|
+
readonly Document: Schema$2.Codec<DocumentJSON<Name>>;
|
|
131
|
+
/** A whole-document type guard over {@link Document}, with a defect net. */
|
|
132
|
+
readonly is: (value: unknown) => value is DocumentJSON<Name>;
|
|
133
|
+
/** {@link Document}'s decode in an `Effect`, failing with a {@link DocumentDecodeError}. */
|
|
134
|
+
readonly decode: (value: unknown) => Effect.Effect<DocumentJSON<Name>, DocumentDecodeError>;
|
|
135
|
+
/** Installs {@link is} as {@link shape}'s grammar guard, for the life of the isolate. */
|
|
136
|
+
readonly install: () => void;
|
|
137
|
+
}
|
|
138
|
+
/**
|
|
139
|
+
* Declares the ProseKit half of a document surface.
|
|
140
|
+
*
|
|
141
|
+
* ```ts
|
|
142
|
+
* const blockDocument = defineDocumentShape({ name: 'blockDocument' }); // root entry
|
|
143
|
+
* const cache = createRegistryCache(); // ./derive
|
|
144
|
+
*
|
|
145
|
+
* export const blockDocumentSchema = defineDocumentSchema(blockDocument, {
|
|
146
|
+
* extension: () => defineBlockDocumentExtension(defineMention()),
|
|
147
|
+
* attributes: mergeAttributeOverrides(STANDARD_ATTRIBUTE_OVERRIDES, MENTION_ATTRIBUTE_OVERRIDES),
|
|
148
|
+
* registryCache: cache,
|
|
149
|
+
* });
|
|
150
|
+
* ```
|
|
151
|
+
*
|
|
152
|
+
* ## Lazy, all the way down
|
|
153
|
+
*
|
|
154
|
+
* Nothing here compiles or derives anything at declaration time.
|
|
155
|
+
* {@link DocumentSchema.schema} is a `lazySchema` thunk, and `Document` is
|
|
156
|
+
* wrapped in `Schema.suspend`, which defers its body until the schema is first
|
|
157
|
+
* used and memoises it thereafter. So importing the module that declares a
|
|
158
|
+
* document surface — as a model layer or a route module does — never pays for
|
|
159
|
+
* a ProseMirror compile or for building the derived Effect Schema graph unless
|
|
160
|
+
* a document is actually validated (PERF-CPU-001 in the source applications).
|
|
161
|
+
*
|
|
162
|
+
* ## Sharing derivation without coupling
|
|
163
|
+
*
|
|
164
|
+
* Two document schemas built from overlapping extensions — a block grammar and
|
|
165
|
+
* an inline grammar both composing `defineStandardMarks()` and `defineText()` —
|
|
166
|
+
* derive the same mark schemas and the same `text` node schema. Passing both
|
|
167
|
+
* the same `registryCache` means whichever is forced *first* builds that shared
|
|
168
|
+
* structure and the other reuses it.
|
|
169
|
+
*
|
|
170
|
+
* They nonetheless stay **independently lazy and independent failure
|
|
171
|
+
* domains**: validating one never forces compiling or deriving the other, and
|
|
172
|
+
* a defect in one's derivation cannot break the other. That is why this is not
|
|
173
|
+
* `deriveDocumentSchemas`, which batches N schemas in one eager call — it would
|
|
174
|
+
* force compiling every grammar up front and couple their failure domains, for
|
|
175
|
+
* exactly the same sharing benefit this gets without either cost.
|
|
176
|
+
*
|
|
177
|
+
* ## When two grammars may share a cache
|
|
178
|
+
*
|
|
179
|
+
* Only when their **mark sets match** and every node or mark type they both
|
|
180
|
+
* name is defined identically (the same spec and the same attribute overlay).
|
|
181
|
+
* The cache memoises derived schemas by type *name*, and an inline node's
|
|
182
|
+
* derived `marks` field is the union of every mark its grammar's textblocks
|
|
183
|
+
* admit. So two grammars that compose the same `text` node but different marks
|
|
184
|
+
* do not derive the same `text` schema, and whichever is forced first decides
|
|
185
|
+
* it for both.
|
|
186
|
+
*
|
|
187
|
+
* Concretely: a block grammar that adds `defineCitation()` and an inline
|
|
188
|
+
* grammar that does not must not share a cache. If they do, forcing the block
|
|
189
|
+
* schema first makes the inline schema accept a `citation` mark it never
|
|
190
|
+
* declared, and forcing the inline schema first makes the block schema reject
|
|
191
|
+
* its own `citation` marks. Neither order raises an error. Give such grammars
|
|
192
|
+
* separate caches (or none: the default is a private cache).
|
|
193
|
+
*/
|
|
194
|
+
export declare function defineDocumentSchema<Name extends string>(shape: DocumentShape<Name>, options: DocumentSchemaOptions): DocumentSchema<Name>;
|
|
195
|
+
/**
|
|
196
|
+
* Installs every schema's grammar guard onto its shape — the persistence
|
|
197
|
+
* layer's one call.
|
|
198
|
+
*
|
|
199
|
+
* ```ts
|
|
200
|
+
* installDocumentGrammars(blockDocumentSchema, inlineDocumentSchema);
|
|
201
|
+
* ```
|
|
202
|
+
*
|
|
203
|
+
* Put it at module scope in the module a server runtime loads before handling
|
|
204
|
+
* a request and no browser bundle can reach (the one that declares the
|
|
205
|
+
* document columns). Installing is cheap — it stores a function reference and
|
|
206
|
+
* forces nothing — and every shape stays permissive until it happens, so a
|
|
207
|
+
* runtime that never installs under-checks rather than wrongly rejects.
|
|
208
|
+
*/
|
|
209
|
+
export declare const installDocumentGrammars: (...schemas: ReadonlyArray<DocumentSchema<string>>) => void;
|
|
210
|
+
declare const HtmlRenderError_base: Schema$2.Class<HtmlRenderError, Schema$2.TaggedStruct<"HtmlRenderError", {
|
|
211
|
+
readonly reason: Schema$2.Literals<readonly ["dom-unavailable", "serialise"]>;
|
|
212
|
+
readonly cause: Schema$2.Defect;
|
|
213
|
+
}>, import("effect/Cause").YieldableError>;
|
|
214
|
+
/**
|
|
215
|
+
* A render that failed.
|
|
216
|
+
*
|
|
217
|
+
* `dom-unavailable` means no `Document` could be obtained: there is no global
|
|
218
|
+
* one and `linkedom` could not be imported (or a caller-supplied `document`
|
|
219
|
+
* thunk rejected). `serialise` means the document itself could not be turned
|
|
220
|
+
* into HTML — most often a node or mark the compiled schema does not know,
|
|
221
|
+
* which is what `htmlFromJSON` throws on. `cause` carries the original through
|
|
222
|
+
* `Schema.Defect()`, so the error is JSON-encodable and survives a log sink.
|
|
223
|
+
*/
|
|
224
|
+
export declare class HtmlRenderError extends /* @__PURE__ */ HtmlRenderError_base {}
|
|
225
|
+
/**
|
|
226
|
+
* A copy of a document tree with every unsafe URL removed: `link` marks whose
|
|
227
|
+
* `href` fails {@link isSafeHref} are dropped from the node that carries them,
|
|
228
|
+
* and `image` children whose `src` fails it are dropped from their parent's
|
|
229
|
+
* content. Recursive, and non-mutating.
|
|
230
|
+
*
|
|
231
|
+
* Dropping the mark rather than the text keeps the prose — an unsafe link
|
|
232
|
+
* renders as plain words — while dropping the whole `image` node is the only
|
|
233
|
+
* option for a leaf whose entire content is its URL.
|
|
234
|
+
*
|
|
235
|
+
* Exported because the same pass belongs at any boundary that hands a document
|
|
236
|
+
* to something which will render it, not only to {@link createHtmlRenderer}.
|
|
237
|
+
*/
|
|
238
|
+
export declare function sanitiseDocument(node: NodeJSON): NodeJSON;
|
|
239
|
+
/** How {@link createHtmlRenderer} builds a renderer. */
|
|
240
|
+
interface HtmlRendererOptions {
|
|
241
|
+
/**
|
|
242
|
+
* The compiled ProseMirror schema to serialise against — pass a
|
|
243
|
+
* `DocumentSchema`'s own `schema` thunk, or a `lazySchema` one. Called per
|
|
244
|
+
* render, so it must be the caching kind.
|
|
245
|
+
*/
|
|
246
|
+
readonly schema: () => Schema;
|
|
247
|
+
/**
|
|
248
|
+
* A pass over the rendered HTML string, given the same `Document` the render
|
|
249
|
+
* used. This is where a node that serialises to a placeholder element gets
|
|
250
|
+
* its real payload — a diagram block replacing its own `innerHTML` with a
|
|
251
|
+
* server-rendered SVG, say. Runs after serialisation and before the string
|
|
252
|
+
* is returned.
|
|
253
|
+
*/
|
|
254
|
+
readonly postProcess?: ((html: string, document: Document) => string) | undefined;
|
|
255
|
+
/**
|
|
256
|
+
* Where the `Document` comes from. Defaults to capability detection: the
|
|
257
|
+
* global `document` if there is one, otherwise linkedom. Resolved once per
|
|
258
|
+
* renderer and cached.
|
|
259
|
+
*/
|
|
260
|
+
readonly document?: (() => Promise<Document>) | undefined;
|
|
261
|
+
}
|
|
262
|
+
/** What {@link createHtmlRenderer} returns. */
|
|
263
|
+
interface HtmlRenderer {
|
|
264
|
+
/** Renders a document to HTML, failing with an {@link HtmlRenderError}. */
|
|
265
|
+
readonly render: (doc: NodeJSON | DocumentJSON) => Effect.Effect<string, HtmlRenderError>;
|
|
266
|
+
/**
|
|
267
|
+
* {@link render} as a promise, rejecting with the {@link HtmlRenderError}
|
|
268
|
+
* itself — for a caller outside Effect, such as a component.
|
|
269
|
+
*/
|
|
270
|
+
readonly renderPromise: (doc: NodeJSON | DocumentJSON) => Promise<string>;
|
|
271
|
+
}
|
|
272
|
+
/**
|
|
273
|
+
* Builds a renderer bound to one compiled schema.
|
|
274
|
+
*
|
|
275
|
+
* ```ts
|
|
276
|
+
* const renderer = createHtmlRenderer({ schema: blockDocumentSchema.schema });
|
|
277
|
+
* const html = await renderer.renderPromise(document);
|
|
278
|
+
* ```
|
|
279
|
+
*
|
|
280
|
+
* A renderer is cheap to create and holds the resolved `Document` promise, so
|
|
281
|
+
* create one per grammar at module scope rather than one per render.
|
|
282
|
+
*
|
|
283
|
+
* Every render sanitises first ({@link sanitiseDocument}), then rewrites the
|
|
284
|
+
* envelope's `type` back to `doc` — the surface name is a persistence rename,
|
|
285
|
+
* and a compiled schema's top node is always `doc`, so feeding the stored
|
|
286
|
+
* shape straight in throws `RangeError: Unknown node type`.
|
|
287
|
+
*/
|
|
288
|
+
export declare function createHtmlRenderer(options: HtmlRendererOptions): HtmlRenderer;
|
|
289
|
+
/**
|
|
290
|
+
* Wraps an extension factory in a compile-once, cache-forever thunk.
|
|
291
|
+
*
|
|
292
|
+
* ```ts
|
|
293
|
+
* const schema = lazySchema(() => defineBlockDocumentExtension(defineMention()));
|
|
294
|
+
* schema() === schema(); // the same compiled instance, for the life of the isolate
|
|
295
|
+
* ```
|
|
296
|
+
*
|
|
297
|
+
* **Why lazy.** Compiling a ProseMirror schema builds the whole node and mark
|
|
298
|
+
* registry and the content-match automata for every content expression in it.
|
|
299
|
+
* It is expensive, and the result never changes at runtime. Doing it at module
|
|
300
|
+
* scope would charge that cost to every bundle that so much as names a
|
|
301
|
+
* document type; doing it per call charges it per use.
|
|
302
|
+
*
|
|
303
|
+
* **Why this matters more than it sounds (PERF-CPU-001 in the source
|
|
304
|
+
* applications).** Before this cache existed there, schema validation called
|
|
305
|
+
* `createEditor(...)` on every call — once per jsonb document column on every
|
|
306
|
+
* database row read, and once per server-side document render. An O(1) cost
|
|
307
|
+
* had become O(rows). Anything on a per-row or per-render path must go
|
|
308
|
+
* through a thunk like this one, never `createEditor` directly.
|
|
309
|
+
*
|
|
310
|
+
* The cache is an `Option` rather than a nullable so a schema is never
|
|
311
|
+
* recompiled because a falsy-looking value was cached, and the thunk is a
|
|
312
|
+
* closure rather than a module-scope slot so two grammars never share one.
|
|
313
|
+
*/
|
|
314
|
+
export declare function lazySchema(define: () => Extension): () => Schema;
|
|
315
|
+
declare class OrderedMap<T = any> {
|
|
316
|
+
private constructor(content: Array<string | T>);
|
|
317
|
+
get(key: string): T | undefined;
|
|
318
|
+
update(key: string, value: T, newKey?: string): OrderedMap<T>;
|
|
319
|
+
remove(key: string): OrderedMap<T>;
|
|
320
|
+
addToStart(key: string, value: T): OrderedMap<T>;
|
|
321
|
+
addToEnd(key: string, value: T): OrderedMap<T>;
|
|
322
|
+
addBefore(place: string, key: string, value: T): OrderedMap<T>;
|
|
323
|
+
forEach(fn: (key: string, value: T) => any): void;
|
|
324
|
+
prepend(map: MapLike<T>): OrderedMap<T>;
|
|
325
|
+
append(map: MapLike<T>): OrderedMap<T>;
|
|
326
|
+
subtract(map: MapLike<T>): OrderedMap<T>;
|
|
327
|
+
toObject(): Record<string, T>;
|
|
328
|
+
readonly size: number;
|
|
329
|
+
static from<T>(map: MapLike<T>): OrderedMap<T>;
|
|
330
|
+
}
|
|
331
|
+
type MapLike<T = any> = Record<string, T> | OrderedMap<T>;
|
|
332
|
+
/**
|
|
333
|
+
A mark is a piece of information that can be attached to a node,
|
|
334
|
+
such as it being emphasized, in code font, or a link. It has a
|
|
335
|
+
type and optionally a set of attributes that provide further
|
|
336
|
+
information (such as the target of the link). Marks are created
|
|
337
|
+
through a `Schema`, which controls which types exist and which
|
|
338
|
+
attributes they have.
|
|
339
|
+
*/
|
|
340
|
+
declare class Mark {
|
|
341
|
+
/**
|
|
342
|
+
The type of this mark.
|
|
343
|
+
*/
|
|
344
|
+
readonly type: MarkType$1;
|
|
345
|
+
/**
|
|
346
|
+
The attributes associated with this mark.
|
|
347
|
+
*/
|
|
348
|
+
readonly attrs: Attrs$1;
|
|
349
|
+
/**
|
|
350
|
+
Given a set of marks, create a new set which contains this one as
|
|
351
|
+
well, in the right position. If this mark is already in the set,
|
|
352
|
+
the set itself is returned. If any marks that are set to be
|
|
353
|
+
[exclusive](https://prosemirror.net/docs/ref/#model.MarkSpec.excludes) with this mark are present,
|
|
354
|
+
those are replaced by this one.
|
|
355
|
+
*/
|
|
356
|
+
addToSet(set: readonly Mark[]): readonly Mark[];
|
|
357
|
+
/**
|
|
358
|
+
Remove this mark from the given set, returning a new set. If this
|
|
359
|
+
mark is not in the set, the set itself is returned.
|
|
360
|
+
*/
|
|
361
|
+
removeFromSet(set: readonly Mark[]): readonly Mark[];
|
|
362
|
+
/**
|
|
363
|
+
Test whether this mark is in the given set of marks.
|
|
364
|
+
*/
|
|
365
|
+
isInSet(set: readonly Mark[]): boolean;
|
|
366
|
+
/**
|
|
367
|
+
Test whether this mark has the same type and attributes as
|
|
368
|
+
another mark.
|
|
369
|
+
*/
|
|
370
|
+
eq(other: Mark): boolean;
|
|
371
|
+
/**
|
|
372
|
+
Convert this mark to a JSON-serializeable representation.
|
|
373
|
+
*/
|
|
374
|
+
toJSON(): any;
|
|
375
|
+
/**
|
|
376
|
+
Deserialize a mark from JSON.
|
|
377
|
+
*/
|
|
378
|
+
static fromJSON(schema: Schema$1, json: any): Mark;
|
|
379
|
+
/**
|
|
380
|
+
Test whether two sets of marks are identical.
|
|
381
|
+
*/
|
|
382
|
+
static sameSet(a: readonly Mark[], b: readonly Mark[]): boolean;
|
|
383
|
+
/**
|
|
384
|
+
Create a properly sorted mark set from null, a single mark, or an
|
|
385
|
+
unsorted array of marks.
|
|
386
|
+
*/
|
|
387
|
+
static setFrom(marks?: Mark | readonly Mark[] | null): readonly Mark[];
|
|
388
|
+
/**
|
|
389
|
+
The empty set of marks.
|
|
390
|
+
*/
|
|
391
|
+
static none: readonly Mark[];
|
|
392
|
+
}
|
|
393
|
+
/**
|
|
394
|
+
A description of a DOM structure. Can be either a DOM element, a
|
|
395
|
+
`{dom, contentDOM}` object, or an array.
|
|
396
|
+
|
|
397
|
+
An array describes a DOM element. The first value in the array
|
|
398
|
+
should be a string—the name of the DOM element, optionally
|
|
399
|
+
prefixed by a namespace URL and a space. If the second element is
|
|
400
|
+
plain object, it is interpreted as a set of attributes for the
|
|
401
|
+
element. Any elements after that (including the 2nd if it's not an
|
|
402
|
+
attribute object) are interpreted as children of the DOM elements,
|
|
403
|
+
and must either be valid `DOMOutputSpec` values, strings (for text
|
|
404
|
+
nodes), or the number zero.
|
|
405
|
+
|
|
406
|
+
The number zero (pronounced “hole”) is used to indicate the place
|
|
407
|
+
where a node's child nodes should be inserted. If it occurs in an
|
|
408
|
+
output spec, it should be the only child element in its parent
|
|
409
|
+
node.
|
|
410
|
+
*/
|
|
411
|
+
type DOMOutputSpec = HTMLElement | {
|
|
412
|
+
dom: HTMLElement;
|
|
413
|
+
contentDOM?: HTMLElement;
|
|
414
|
+
} | readonly [string, ...any[]];
|
|
415
|
+
/**
|
|
416
|
+
You can [_resolve_](https://prosemirror.net/docs/ref/#model.Node.resolve) a position to get more
|
|
417
|
+
information about it. Objects of this class represent such a
|
|
418
|
+
resolved position, providing various pieces of context
|
|
419
|
+
information, and some helper methods.
|
|
420
|
+
|
|
421
|
+
Throughout this interface, methods that take an optional `depth`
|
|
422
|
+
parameter will interpret undefined as `this.depth` and negative
|
|
423
|
+
numbers as `this.depth + value`.
|
|
424
|
+
*/
|
|
425
|
+
declare class ResolvedPos {
|
|
426
|
+
/**
|
|
427
|
+
The position that was resolved.
|
|
428
|
+
*/
|
|
429
|
+
readonly pos: number;
|
|
430
|
+
/**
|
|
431
|
+
The offset this position has into its parent node.
|
|
432
|
+
*/
|
|
433
|
+
readonly parentOffset: number;
|
|
434
|
+
/**
|
|
435
|
+
The number of levels the parent node is from the root. If this
|
|
436
|
+
position points directly into the root node, it is 0. If it
|
|
437
|
+
points into a top-level paragraph, 1, and so on.
|
|
438
|
+
*/
|
|
439
|
+
depth: number;
|
|
440
|
+
/**
|
|
441
|
+
The parent node that the position points into. Note that even if
|
|
442
|
+
a position points into a text node, that node is not considered
|
|
443
|
+
the parent—text nodes are ‘flat’ in this model, and have no content.
|
|
444
|
+
*/
|
|
445
|
+
get parent(): Node;
|
|
446
|
+
/**
|
|
447
|
+
The root node in which the position was resolved.
|
|
448
|
+
*/
|
|
449
|
+
get doc(): Node;
|
|
450
|
+
/**
|
|
451
|
+
The ancestor node at the given level. `p.node(p.depth)` is the
|
|
452
|
+
same as `p.parent`.
|
|
453
|
+
*/
|
|
454
|
+
node(depth?: number | null): Node;
|
|
455
|
+
/**
|
|
456
|
+
The index into the ancestor at the given level. If this points
|
|
457
|
+
at the 3rd node in the 2nd paragraph on the top level, for
|
|
458
|
+
example, `p.index(0)` is 1 and `p.index(1)` is 2.
|
|
459
|
+
*/
|
|
460
|
+
index(depth?: number | null): number;
|
|
461
|
+
/**
|
|
462
|
+
The index pointing after this position into the ancestor at the
|
|
463
|
+
given level.
|
|
464
|
+
*/
|
|
465
|
+
indexAfter(depth?: number | null): number;
|
|
466
|
+
/**
|
|
467
|
+
The (absolute) position at the start of the node at the given
|
|
468
|
+
level.
|
|
469
|
+
*/
|
|
470
|
+
start(depth?: number | null): number;
|
|
471
|
+
/**
|
|
472
|
+
The (absolute) position at the end of the node at the given
|
|
473
|
+
level.
|
|
474
|
+
*/
|
|
475
|
+
end(depth?: number | null): number;
|
|
476
|
+
/**
|
|
477
|
+
The (absolute) position directly before the wrapping node at the
|
|
478
|
+
given level, or, when `depth` is `this.depth + 1`, the original
|
|
479
|
+
position.
|
|
480
|
+
*/
|
|
481
|
+
before(depth?: number | null): number;
|
|
482
|
+
/**
|
|
483
|
+
The (absolute) position directly after the wrapping node at the
|
|
484
|
+
given level, or the original position when `depth` is `this.depth + 1`.
|
|
485
|
+
*/
|
|
486
|
+
after(depth?: number | null): number;
|
|
487
|
+
/**
|
|
488
|
+
When this position points into a text node, this returns the
|
|
489
|
+
distance between the position and the start of the text node.
|
|
490
|
+
Will be zero for positions that point between nodes.
|
|
491
|
+
*/
|
|
492
|
+
get textOffset(): number;
|
|
493
|
+
/**
|
|
494
|
+
Get the node directly after the position, if any. If the position
|
|
495
|
+
points into a text node, only the part of that node after the
|
|
496
|
+
position is returned.
|
|
497
|
+
*/
|
|
498
|
+
get nodeAfter(): Node | null;
|
|
499
|
+
/**
|
|
500
|
+
Get the node directly before the position, if any. If the
|
|
501
|
+
position points into a text node, only the part of that node
|
|
502
|
+
before the position is returned.
|
|
503
|
+
*/
|
|
504
|
+
get nodeBefore(): Node | null;
|
|
505
|
+
/**
|
|
506
|
+
Get the position at the given index in the parent node at the
|
|
507
|
+
given depth (which defaults to `this.depth`).
|
|
508
|
+
*/
|
|
509
|
+
posAtIndex(index: number, depth?: number | null): number;
|
|
510
|
+
/**
|
|
511
|
+
Get the marks at this position, factoring in the surrounding
|
|
512
|
+
marks' [`inclusive`](https://prosemirror.net/docs/ref/#model.MarkSpec.inclusive) property. If the
|
|
513
|
+
position is at the start of a non-empty node, the marks of the
|
|
514
|
+
node after it (if any) are returned.
|
|
515
|
+
*/
|
|
516
|
+
marks(): readonly Mark[];
|
|
517
|
+
/**
|
|
518
|
+
Get the marks after the current position, if any, except those
|
|
519
|
+
that are non-inclusive and not present at position `$end`. This
|
|
520
|
+
is mostly useful for getting the set of marks to preserve after a
|
|
521
|
+
deletion. Will return `null` if this position is at the end of
|
|
522
|
+
its parent node or its parent node isn't a textblock (in which
|
|
523
|
+
case no marks should be preserved).
|
|
524
|
+
*/
|
|
525
|
+
marksAcross($end: ResolvedPos): readonly Mark[] | null;
|
|
526
|
+
/**
|
|
527
|
+
The depth up to which this position and the given (non-resolved)
|
|
528
|
+
position share the same parent nodes.
|
|
529
|
+
*/
|
|
530
|
+
sharedDepth(pos: number): number;
|
|
531
|
+
/**
|
|
532
|
+
Returns a range based on the place where this position and the
|
|
533
|
+
given position diverge around block content. If both point into
|
|
534
|
+
the same textblock, for example, a range around that textblock
|
|
535
|
+
will be returned. If they point into different blocks, the range
|
|
536
|
+
around those blocks in their shared ancestor is returned. You can
|
|
537
|
+
pass in an optional predicate that will be called with a parent
|
|
538
|
+
node to see if a range into that parent is acceptable.
|
|
539
|
+
*/
|
|
540
|
+
blockRange(other?: ResolvedPos, pred?: (node: Node) => boolean): NodeRange | null;
|
|
541
|
+
/**
|
|
542
|
+
Query whether the given position shares the same parent node.
|
|
543
|
+
*/
|
|
544
|
+
sameParent(other: ResolvedPos): boolean;
|
|
545
|
+
/**
|
|
546
|
+
Return the greater of this and the given position.
|
|
547
|
+
*/
|
|
548
|
+
max(other: ResolvedPos): ResolvedPos;
|
|
549
|
+
/**
|
|
550
|
+
Return the smaller of this and the given position.
|
|
551
|
+
*/
|
|
552
|
+
min(other: ResolvedPos): ResolvedPos;
|
|
553
|
+
}
|
|
554
|
+
/**
|
|
555
|
+
Represents a flat range of content, i.e. one that starts and
|
|
556
|
+
ends in the same node.
|
|
557
|
+
*/
|
|
558
|
+
declare class NodeRange {
|
|
559
|
+
/**
|
|
560
|
+
A resolved position along the start of the content. May have a
|
|
561
|
+
`depth` greater than this object's `depth` property, since
|
|
562
|
+
these are the positions that were used to compute the range,
|
|
563
|
+
not re-resolved positions directly at its boundaries.
|
|
564
|
+
*/
|
|
565
|
+
readonly $from: ResolvedPos;
|
|
566
|
+
/**
|
|
567
|
+
A position along the end of the content. See
|
|
568
|
+
caveat for [`$from`](https://prosemirror.net/docs/ref/#model.NodeRange.$from).
|
|
569
|
+
*/
|
|
570
|
+
readonly $to: ResolvedPos;
|
|
571
|
+
/**
|
|
572
|
+
The depth of the node that this range points into.
|
|
573
|
+
*/
|
|
574
|
+
readonly depth: number;
|
|
575
|
+
/**
|
|
576
|
+
Construct a node range. `$from` and `$to` should point into the
|
|
577
|
+
same node until at least the given `depth`, since a node range
|
|
578
|
+
denotes an adjacent set of nodes in a single parent node.
|
|
579
|
+
*/
|
|
580
|
+
constructor(
|
|
581
|
+
/**
|
|
582
|
+
A resolved position along the start of the content. May have a
|
|
583
|
+
`depth` greater than this object's `depth` property, since
|
|
584
|
+
these are the positions that were used to compute the range,
|
|
585
|
+
not re-resolved positions directly at its boundaries.
|
|
586
|
+
*/
|
|
587
|
+
$from: ResolvedPos,
|
|
588
|
+
/**
|
|
589
|
+
A position along the end of the content. See
|
|
590
|
+
caveat for [`$from`](https://prosemirror.net/docs/ref/#model.NodeRange.$from).
|
|
591
|
+
*/
|
|
592
|
+
$to: ResolvedPos,
|
|
593
|
+
/**
|
|
594
|
+
The depth of the node that this range points into.
|
|
595
|
+
*/
|
|
596
|
+
depth: number);
|
|
597
|
+
/**
|
|
598
|
+
The position at the start of the range.
|
|
599
|
+
*/
|
|
600
|
+
get start(): number;
|
|
601
|
+
/**
|
|
602
|
+
The position at the end of the range.
|
|
603
|
+
*/
|
|
604
|
+
get end(): number;
|
|
605
|
+
/**
|
|
606
|
+
The parent node that the range points into.
|
|
607
|
+
*/
|
|
608
|
+
get parent(): Node;
|
|
609
|
+
/**
|
|
610
|
+
The start index of the range in the parent node.
|
|
611
|
+
*/
|
|
612
|
+
get startIndex(): number;
|
|
613
|
+
/**
|
|
614
|
+
The end index of the range in the parent node.
|
|
615
|
+
*/
|
|
616
|
+
get endIndex(): number;
|
|
617
|
+
}
|
|
618
|
+
/**
|
|
619
|
+
A slice represents a piece cut out of a larger document. It
|
|
620
|
+
stores not only a fragment, but also the depth up to which nodes on
|
|
621
|
+
both side are ‘open’ (cut through).
|
|
622
|
+
*/
|
|
623
|
+
declare class Slice {
|
|
624
|
+
/**
|
|
625
|
+
The slice's content.
|
|
626
|
+
*/
|
|
627
|
+
readonly content: Fragment;
|
|
628
|
+
/**
|
|
629
|
+
The open depth at the start of the fragment.
|
|
630
|
+
*/
|
|
631
|
+
readonly openStart: number;
|
|
632
|
+
/**
|
|
633
|
+
The open depth at the end.
|
|
634
|
+
*/
|
|
635
|
+
readonly openEnd: number;
|
|
636
|
+
/**
|
|
637
|
+
Create a slice. When specifying a non-zero open depth, you must
|
|
638
|
+
make sure that there are nodes of at least that depth at the
|
|
639
|
+
appropriate side of the fragment—i.e. if the fragment is an
|
|
640
|
+
empty paragraph node, `openStart` and `openEnd` can't be greater
|
|
641
|
+
than 1.
|
|
642
|
+
|
|
643
|
+
It is not necessary for the content of open nodes to conform to
|
|
644
|
+
the schema's content constraints, though it should be a valid
|
|
645
|
+
start/end/middle for such a node, depending on which sides are
|
|
646
|
+
open.
|
|
647
|
+
*/
|
|
648
|
+
constructor(
|
|
649
|
+
/**
|
|
650
|
+
The slice's content.
|
|
651
|
+
*/
|
|
652
|
+
content: Fragment,
|
|
653
|
+
/**
|
|
654
|
+
The open depth at the start of the fragment.
|
|
655
|
+
*/
|
|
656
|
+
openStart: number,
|
|
657
|
+
/**
|
|
658
|
+
The open depth at the end.
|
|
659
|
+
*/
|
|
660
|
+
openEnd: number);
|
|
661
|
+
/**
|
|
662
|
+
The size this slice would add when inserted into a document.
|
|
663
|
+
*/
|
|
664
|
+
get size(): number;
|
|
665
|
+
/**
|
|
666
|
+
Tests whether this slice is equal to another slice.
|
|
667
|
+
*/
|
|
668
|
+
eq(other: Slice): boolean;
|
|
669
|
+
/**
|
|
670
|
+
Convert a slice to a JSON-serializable representation.
|
|
671
|
+
*/
|
|
672
|
+
toJSON(): any;
|
|
673
|
+
/**
|
|
674
|
+
Deserialize a slice from its JSON representation.
|
|
675
|
+
*/
|
|
676
|
+
static fromJSON(schema: Schema$1, json: any): Slice;
|
|
677
|
+
/**
|
|
678
|
+
Create a slice from a fragment by taking the maximum possible
|
|
679
|
+
open value on both side of the fragment.
|
|
680
|
+
*/
|
|
681
|
+
static maxOpen(fragment: Fragment, openIsolating?: boolean): Slice;
|
|
682
|
+
/**
|
|
683
|
+
The empty slice.
|
|
684
|
+
*/
|
|
685
|
+
static empty: Slice;
|
|
686
|
+
}
|
|
687
|
+
type DOMNode = InstanceType<typeof window.Node>;
|
|
688
|
+
/**
|
|
689
|
+
Fields that may be present in both [tag](https://prosemirror.net/docs/ref/#model.TagParseRule) and
|
|
690
|
+
[style](https://prosemirror.net/docs/ref/#model.StyleParseRule) parse rules.
|
|
691
|
+
*/
|
|
692
|
+
interface GenericParseRule {
|
|
693
|
+
/**
|
|
694
|
+
Can be used to change the order in which the parse rules in a
|
|
695
|
+
schema are tried. Those with higher priority come first. Rules
|
|
696
|
+
without a priority are counted as having priority 50. This
|
|
697
|
+
property is only meaningful in a schema—when directly
|
|
698
|
+
constructing a parser, the order of the rule array is used.
|
|
699
|
+
*/
|
|
700
|
+
priority?: number;
|
|
701
|
+
/**
|
|
702
|
+
By default, when a rule matches an element or style, no further
|
|
703
|
+
rules get a chance to match it. By setting this to `false`, you
|
|
704
|
+
indicate that even when this rule matches, other rules that come
|
|
705
|
+
after it should also run.
|
|
706
|
+
*/
|
|
707
|
+
consuming?: boolean;
|
|
708
|
+
/**
|
|
709
|
+
When given, restricts this rule to only match when the current
|
|
710
|
+
context—the parent nodes into which the content is being
|
|
711
|
+
parsed—matches this expression. Should contain one or more node
|
|
712
|
+
names or node group names followed by single or double slashes.
|
|
713
|
+
For example `"paragraph/"` means the rule only matches when the
|
|
714
|
+
parent node is a paragraph, `"blockquote/paragraph/"` restricts
|
|
715
|
+
it to be in a paragraph that is inside a blockquote, and
|
|
716
|
+
`"section//"` matches any position inside a section—a double
|
|
717
|
+
slash matches any sequence of ancestor nodes. To allow multiple
|
|
718
|
+
different contexts, they can be separated by a pipe (`|`)
|
|
719
|
+
character, as in `"blockquote/|list_item/"`.
|
|
720
|
+
*/
|
|
721
|
+
context?: string;
|
|
722
|
+
/**
|
|
723
|
+
The name of the mark type to wrap the matched content in.
|
|
724
|
+
*/
|
|
725
|
+
mark?: string;
|
|
726
|
+
/**
|
|
727
|
+
When true, ignore content that matches this rule. Any `<head>`,
|
|
728
|
+
`<noscript>`, `<script>`, `<object>`, `<style>`, or `<title>`
|
|
729
|
+
tags encountered are automatically ignored when no rules match
|
|
730
|
+
them..
|
|
731
|
+
*/
|
|
732
|
+
ignore?: boolean;
|
|
733
|
+
/**
|
|
734
|
+
When true, finding an element that matches this rule will close
|
|
735
|
+
the current node.
|
|
736
|
+
*/
|
|
737
|
+
closeParent?: boolean;
|
|
738
|
+
/**
|
|
739
|
+
When true, ignore the node that matches this rule, but do parse
|
|
740
|
+
its content.
|
|
741
|
+
*/
|
|
742
|
+
skip?: boolean;
|
|
743
|
+
/**
|
|
744
|
+
Attributes for the node or mark created by this rule. When
|
|
745
|
+
`getAttrs` is provided, it takes precedence.
|
|
746
|
+
*/
|
|
747
|
+
attrs?: Attrs$1;
|
|
748
|
+
}
|
|
749
|
+
/**
|
|
750
|
+
Parse rule targeting a DOM element.
|
|
751
|
+
*/
|
|
752
|
+
interface TagParseRule extends GenericParseRule {
|
|
753
|
+
/**
|
|
754
|
+
A CSS selector describing the kind of DOM elements to match.
|
|
755
|
+
*/
|
|
756
|
+
tag: string;
|
|
757
|
+
/**
|
|
758
|
+
The namespace to match. Nodes are only matched when the
|
|
759
|
+
namespace matches or this property is null.
|
|
760
|
+
*/
|
|
761
|
+
namespace?: string;
|
|
762
|
+
/**
|
|
763
|
+
The name of the node type to create when this rule matches. Each
|
|
764
|
+
rule should have either a `node`, `mark`, or `ignore` property
|
|
765
|
+
(except when it appears in a [node](https://prosemirror.net/docs/ref/#model.NodeSpec.parseDOM) or
|
|
766
|
+
[mark spec](https://prosemirror.net/docs/ref/#model.MarkSpec.parseDOM), in which case the `node`
|
|
767
|
+
or `mark` property will be derived from its position).
|
|
768
|
+
*/
|
|
769
|
+
node?: string;
|
|
770
|
+
/**
|
|
771
|
+
A function used to compute the attributes for the node or mark
|
|
772
|
+
created by this rule. Can also be used to describe further
|
|
773
|
+
conditions the DOM element or style must match. When it returns
|
|
774
|
+
`false`, the rule won't match. When it returns null or undefined,
|
|
775
|
+
that is interpreted as an empty/default set of attributes.
|
|
776
|
+
*/
|
|
777
|
+
getAttrs?: (node: HTMLElement) => Attrs$1 | false | null;
|
|
778
|
+
/**
|
|
779
|
+
For rules that produce non-leaf nodes, by default the content of
|
|
780
|
+
the DOM element is parsed as content of the node. If the child
|
|
781
|
+
nodes are in a descendent node, this may be a CSS selector
|
|
782
|
+
string that the parser must use to find the actual content
|
|
783
|
+
element, or a function that returns the actual content element
|
|
784
|
+
to the parser.
|
|
785
|
+
*/
|
|
786
|
+
contentElement?: string | HTMLElement | ((node: HTMLElement) => HTMLElement);
|
|
787
|
+
/**
|
|
788
|
+
Can be used to override the content of a matched node. When
|
|
789
|
+
present, instead of parsing the node's child nodes, the result of
|
|
790
|
+
this function is used.
|
|
791
|
+
*/
|
|
792
|
+
getContent?: (node: DOMNode, schema: Schema$1) => Fragment;
|
|
793
|
+
/**
|
|
794
|
+
Controls whether whitespace should be preserved when parsing the
|
|
795
|
+
content inside the matched element. `false` means whitespace may
|
|
796
|
+
be collapsed, `true` means that whitespace should be preserved
|
|
797
|
+
but newlines normalized to spaces, and `"full"` means that
|
|
798
|
+
newlines should also be preserved.
|
|
799
|
+
*/
|
|
800
|
+
preserveWhitespace?: boolean | "full";
|
|
801
|
+
}
|
|
802
|
+
/**
|
|
803
|
+
A parse rule targeting a style property.
|
|
804
|
+
*/
|
|
805
|
+
interface StyleParseRule extends GenericParseRule {
|
|
806
|
+
/**
|
|
807
|
+
A CSS property name to match. This rule will match inline styles
|
|
808
|
+
that list that property. May also have the form
|
|
809
|
+
`"property=value"`, in which case the rule only matches if the
|
|
810
|
+
property's value exactly matches the given value. (For more
|
|
811
|
+
complicated filters, use [`getAttrs`](https://prosemirror.net/docs/ref/#model.StyleParseRule.getAttrs)
|
|
812
|
+
and return false to indicate that the match failed.) Rules
|
|
813
|
+
matching styles may only produce [marks](https://prosemirror.net/docs/ref/#model.GenericParseRule.mark),
|
|
814
|
+
not nodes.
|
|
815
|
+
*/
|
|
816
|
+
style: string;
|
|
817
|
+
/**
|
|
818
|
+
Given to make TS see ParseRule as a tagged union @hide
|
|
819
|
+
*/
|
|
820
|
+
tag?: undefined;
|
|
821
|
+
/**
|
|
822
|
+
Style rules can remove marks from the set of active marks.
|
|
823
|
+
*/
|
|
824
|
+
clearMark?: (mark: Mark) => boolean;
|
|
825
|
+
/**
|
|
826
|
+
A function used to compute the attributes for the node or mark
|
|
827
|
+
created by this rule. Called with the style's value.
|
|
828
|
+
*/
|
|
829
|
+
getAttrs?: (node: string) => Attrs$1 | false | null;
|
|
830
|
+
}
|
|
831
|
+
/**
|
|
832
|
+
A value that describes how to parse a given DOM node or inline
|
|
833
|
+
style as a ProseMirror node or mark.
|
|
834
|
+
*/
|
|
835
|
+
type ParseRule = TagParseRule | StyleParseRule;
|
|
836
|
+
/**
|
|
837
|
+
An object holding the attributes of a node.
|
|
838
|
+
*/
|
|
839
|
+
type Attrs$1 = {
|
|
840
|
+
readonly [attr: string]: any;
|
|
841
|
+
};
|
|
842
|
+
/**
|
|
843
|
+
Node types are objects allocated once per `Schema` and used to
|
|
844
|
+
[tag](https://prosemirror.net/docs/ref/#model.Node.type) `Node` instances. They contain information
|
|
845
|
+
about the node type, such as its name and what kind of node it
|
|
846
|
+
represents.
|
|
847
|
+
*/
|
|
848
|
+
declare class NodeType$1 {
|
|
849
|
+
/**
|
|
850
|
+
The name the node type has in this schema.
|
|
851
|
+
*/
|
|
852
|
+
readonly name: string;
|
|
853
|
+
/**
|
|
854
|
+
A link back to the `Schema` the node type belongs to.
|
|
855
|
+
*/
|
|
856
|
+
readonly schema: Schema$1;
|
|
857
|
+
/**
|
|
858
|
+
The spec that this type is based on
|
|
859
|
+
*/
|
|
860
|
+
readonly spec: NodeSpec;
|
|
861
|
+
/**
|
|
862
|
+
True if this node type has inline content.
|
|
863
|
+
*/
|
|
864
|
+
inlineContent: boolean;
|
|
865
|
+
/**
|
|
866
|
+
True if this is a block type
|
|
867
|
+
*/
|
|
868
|
+
isBlock: boolean;
|
|
869
|
+
/**
|
|
870
|
+
True if this is the text node type.
|
|
871
|
+
*/
|
|
872
|
+
isText: boolean;
|
|
873
|
+
/**
|
|
874
|
+
True if this is an inline type.
|
|
875
|
+
*/
|
|
876
|
+
get isInline(): boolean;
|
|
877
|
+
/**
|
|
878
|
+
True if this is a textblock type, a block that contains inline
|
|
879
|
+
content.
|
|
880
|
+
*/
|
|
881
|
+
get isTextblock(): boolean;
|
|
882
|
+
/**
|
|
883
|
+
True for node types that allow no content.
|
|
884
|
+
*/
|
|
885
|
+
get isLeaf(): boolean;
|
|
886
|
+
/**
|
|
887
|
+
True when this node is an atom, i.e. when it does not have
|
|
888
|
+
directly editable content.
|
|
889
|
+
*/
|
|
890
|
+
get isAtom(): boolean;
|
|
891
|
+
/**
|
|
892
|
+
Return true when this node type is part of the given
|
|
893
|
+
[group](https://prosemirror.net/docs/ref/#model.NodeSpec.group).
|
|
894
|
+
*/
|
|
895
|
+
isInGroup(group: string): boolean;
|
|
896
|
+
/**
|
|
897
|
+
The starting match of the node type's content expression.
|
|
898
|
+
*/
|
|
899
|
+
contentMatch: ContentMatch;
|
|
900
|
+
/**
|
|
901
|
+
The set of marks allowed in this node. `null` means all marks
|
|
902
|
+
are allowed.
|
|
903
|
+
*/
|
|
904
|
+
markSet: readonly MarkType$1[] | null;
|
|
905
|
+
/**
|
|
906
|
+
The node type's [whitespace](https://prosemirror.net/docs/ref/#model.NodeSpec.whitespace) option.
|
|
907
|
+
*/
|
|
908
|
+
get whitespace(): "pre" | "normal";
|
|
909
|
+
/**
|
|
910
|
+
Tells you whether this node type has any required attributes.
|
|
911
|
+
*/
|
|
912
|
+
hasRequiredAttrs(): boolean;
|
|
913
|
+
/**
|
|
914
|
+
Indicates whether this node allows some of the same content as
|
|
915
|
+
the given node type.
|
|
916
|
+
*/
|
|
917
|
+
compatibleContent(other: NodeType$1): boolean;
|
|
918
|
+
/**
|
|
919
|
+
Create a `Node` of this type. The given attributes are
|
|
920
|
+
checked and defaulted (you can pass `null` to use the type's
|
|
921
|
+
defaults entirely, if no required attributes exist). `content`
|
|
922
|
+
may be a `Fragment`, a node, an array of nodes, or
|
|
923
|
+
`null`. Similarly `marks` may be `null` to default to the empty
|
|
924
|
+
set of marks.
|
|
925
|
+
*/
|
|
926
|
+
create(attrs?: Attrs$1 | null, content?: Fragment | Node | readonly Node[] | null, marks?: readonly Mark[]): Node;
|
|
927
|
+
/**
|
|
928
|
+
Like [`create`](https://prosemirror.net/docs/ref/#model.NodeType.create), but check the given content
|
|
929
|
+
against the node type's content restrictions, and throw an error
|
|
930
|
+
if it doesn't match.
|
|
931
|
+
*/
|
|
932
|
+
createChecked(attrs?: Attrs$1 | null, content?: Fragment | Node | readonly Node[] | null, marks?: readonly Mark[]): Node;
|
|
933
|
+
/**
|
|
934
|
+
Like [`create`](https://prosemirror.net/docs/ref/#model.NodeType.create), but see if it is
|
|
935
|
+
necessary to add nodes to the start or end of the given fragment
|
|
936
|
+
to make it fit the node. If no fitting wrapping can be found,
|
|
937
|
+
return null. Note that, due to the fact that required nodes can
|
|
938
|
+
always be created, this will always succeed if you pass null or
|
|
939
|
+
`Fragment.empty` as content.
|
|
940
|
+
*/
|
|
941
|
+
createAndFill(attrs?: Attrs$1 | null, content?: Fragment | Node | readonly Node[] | null, marks?: readonly Mark[]): Node | null;
|
|
942
|
+
/**
|
|
943
|
+
Returns true if the given fragment is valid content for this node
|
|
944
|
+
type.
|
|
945
|
+
*/
|
|
946
|
+
validContent(content: Fragment): boolean;
|
|
947
|
+
/**
|
|
948
|
+
Check whether the given mark type is allowed in this node.
|
|
949
|
+
*/
|
|
950
|
+
allowsMarkType(markType: MarkType$1): boolean;
|
|
951
|
+
/**
|
|
952
|
+
Test whether the given set of marks are allowed in this node.
|
|
953
|
+
*/
|
|
954
|
+
allowsMarks(marks: readonly Mark[]): boolean;
|
|
955
|
+
/**
|
|
956
|
+
Removes the marks that are not allowed in this node from the given set.
|
|
957
|
+
*/
|
|
958
|
+
allowedMarks(marks: readonly Mark[]): readonly Mark[];
|
|
959
|
+
}
|
|
960
|
+
/**
|
|
961
|
+
Like nodes, marks (which are associated with nodes to signify
|
|
962
|
+
things like emphasis or being part of a link) are
|
|
963
|
+
[tagged](https://prosemirror.net/docs/ref/#model.Mark.type) with type objects, which are
|
|
964
|
+
instantiated once per `Schema`.
|
|
965
|
+
*/
|
|
966
|
+
declare class MarkType$1 {
|
|
967
|
+
/**
|
|
968
|
+
The name of the mark type.
|
|
969
|
+
*/
|
|
970
|
+
readonly name: string;
|
|
971
|
+
/**
|
|
972
|
+
The schema that this mark type instance is part of.
|
|
973
|
+
*/
|
|
974
|
+
readonly schema: Schema$1;
|
|
975
|
+
/**
|
|
976
|
+
The spec on which the type is based.
|
|
977
|
+
*/
|
|
978
|
+
readonly spec: MarkSpec;
|
|
979
|
+
/**
|
|
980
|
+
Create a mark of this type. `attrs` may be `null` or an object
|
|
981
|
+
containing only some of the mark's attributes. The others, if
|
|
982
|
+
they have defaults, will be added.
|
|
983
|
+
*/
|
|
984
|
+
create(attrs?: Attrs$1 | null): Mark;
|
|
985
|
+
/**
|
|
986
|
+
When there is a mark of this type in the given set, a new set
|
|
987
|
+
without it is returned. Otherwise, the input set is returned.
|
|
988
|
+
*/
|
|
989
|
+
removeFromSet(set: readonly Mark[]): readonly Mark[];
|
|
990
|
+
/**
|
|
991
|
+
Tests whether there is a mark of this type in the given set.
|
|
992
|
+
*/
|
|
993
|
+
isInSet(set: readonly Mark[]): Mark | undefined;
|
|
994
|
+
/**
|
|
995
|
+
Queries whether a given mark type is
|
|
996
|
+
[excluded](https://prosemirror.net/docs/ref/#model.MarkSpec.excludes) by this one.
|
|
997
|
+
*/
|
|
998
|
+
excludes(other: MarkType$1): boolean;
|
|
999
|
+
}
|
|
1000
|
+
/**
|
|
1001
|
+
An object describing a schema, as passed to the [`Schema`](https://prosemirror.net/docs/ref/#model.Schema)
|
|
1002
|
+
constructor.
|
|
1003
|
+
*/
|
|
1004
|
+
interface SchemaSpec<Nodes extends string = any, Marks extends string = any> {
|
|
1005
|
+
/**
|
|
1006
|
+
The node types in this schema. Maps names to
|
|
1007
|
+
[`NodeSpec`](https://prosemirror.net/docs/ref/#model.NodeSpec) objects that describe the node type
|
|
1008
|
+
associated with that name. Their order is significant—it
|
|
1009
|
+
determines which [parse rules](https://prosemirror.net/docs/ref/#model.NodeSpec.parseDOM) take
|
|
1010
|
+
precedence by default, and which nodes come first in a given
|
|
1011
|
+
[group](https://prosemirror.net/docs/ref/#model.NodeSpec.group).
|
|
1012
|
+
*/
|
|
1013
|
+
nodes: { [name in Nodes]: NodeSpec; } | OrderedMap<NodeSpec>;
|
|
1014
|
+
/**
|
|
1015
|
+
The mark types that exist in this schema. The order in which they
|
|
1016
|
+
are provided determines the order in which [mark
|
|
1017
|
+
sets](https://prosemirror.net/docs/ref/#model.Mark.addToSet) are sorted and in which [parse
|
|
1018
|
+
rules](https://prosemirror.net/docs/ref/#model.MarkSpec.parseDOM) are tried.
|
|
1019
|
+
*/
|
|
1020
|
+
marks?: { [name in Marks]: MarkSpec; } | OrderedMap<MarkSpec>;
|
|
1021
|
+
/**
|
|
1022
|
+
The name of the default top-level node for the schema. Defaults
|
|
1023
|
+
to `"doc"`.
|
|
1024
|
+
*/
|
|
1025
|
+
topNode?: string;
|
|
1026
|
+
}
|
|
1027
|
+
/**
|
|
1028
|
+
A description of a node type, used when defining a schema.
|
|
1029
|
+
*/
|
|
1030
|
+
interface NodeSpec {
|
|
1031
|
+
/**
|
|
1032
|
+
The content expression for this node, as described in the [schema
|
|
1033
|
+
guide](https://prosemirror.net/docs/guide/#schema.content_expressions). When not given,
|
|
1034
|
+
the node does not allow any content.
|
|
1035
|
+
*/
|
|
1036
|
+
content?: string;
|
|
1037
|
+
/**
|
|
1038
|
+
The marks that are allowed inside of this node. May be a
|
|
1039
|
+
space-separated string referring to mark names or groups, `"_"`
|
|
1040
|
+
to explicitly allow all marks, or `""` to disallow marks. When
|
|
1041
|
+
not given, nodes with inline content default to allowing all
|
|
1042
|
+
marks, other nodes default to not allowing marks.
|
|
1043
|
+
*/
|
|
1044
|
+
marks?: string;
|
|
1045
|
+
/**
|
|
1046
|
+
The group or space-separated groups to which this node belongs,
|
|
1047
|
+
which can be referred to in the content expressions for the
|
|
1048
|
+
schema.
|
|
1049
|
+
*/
|
|
1050
|
+
group?: string;
|
|
1051
|
+
/**
|
|
1052
|
+
Should be set to true for inline nodes. (Implied for text nodes.)
|
|
1053
|
+
*/
|
|
1054
|
+
inline?: boolean;
|
|
1055
|
+
/**
|
|
1056
|
+
Can be set to true to indicate that, though this isn't a [leaf
|
|
1057
|
+
node](https://prosemirror.net/docs/ref/#model.NodeType.isLeaf), it doesn't have directly editable
|
|
1058
|
+
content and should be treated as a single unit in the view.
|
|
1059
|
+
*/
|
|
1060
|
+
atom?: boolean;
|
|
1061
|
+
/**
|
|
1062
|
+
The attributes that nodes of this type get.
|
|
1063
|
+
*/
|
|
1064
|
+
attrs?: {
|
|
1065
|
+
[name: string]: AttributeSpec$1;
|
|
1066
|
+
};
|
|
1067
|
+
/**
|
|
1068
|
+
Controls whether nodes of this type can be selected as a [node
|
|
1069
|
+
selection](https://prosemirror.net/docs/ref/#state.NodeSelection). Defaults to true for non-text
|
|
1070
|
+
nodes.
|
|
1071
|
+
*/
|
|
1072
|
+
selectable?: boolean;
|
|
1073
|
+
/**
|
|
1074
|
+
Determines whether nodes of this type can be dragged without
|
|
1075
|
+
being selected. Defaults to false.
|
|
1076
|
+
*/
|
|
1077
|
+
draggable?: boolean;
|
|
1078
|
+
/**
|
|
1079
|
+
Can be used to indicate that this node contains code, which
|
|
1080
|
+
causes some commands to behave differently.
|
|
1081
|
+
*/
|
|
1082
|
+
code?: boolean;
|
|
1083
|
+
/**
|
|
1084
|
+
Controls way whitespace in this a node is parsed. The default is
|
|
1085
|
+
`"normal"`, which causes the [DOM parser](https://prosemirror.net/docs/ref/#model.DOMParser) to
|
|
1086
|
+
collapse whitespace in normal mode, and normalize it (replacing
|
|
1087
|
+
newlines and such with spaces) otherwise. `"pre"` causes the
|
|
1088
|
+
parser to preserve spaces inside the node. When this option isn't
|
|
1089
|
+
given, but [`code`](https://prosemirror.net/docs/ref/#model.NodeSpec.code) is true, `whitespace`
|
|
1090
|
+
will default to `"pre"`. Note that this option doesn't influence
|
|
1091
|
+
the way the node is rendered—that should be handled by `toDOM`
|
|
1092
|
+
and/or styling.
|
|
1093
|
+
*/
|
|
1094
|
+
whitespace?: "pre" | "normal";
|
|
1095
|
+
/**
|
|
1096
|
+
Determines whether this node is considered an important parent
|
|
1097
|
+
node during replace operations (such as paste). Non-defining (the
|
|
1098
|
+
default) nodes get dropped when their entire content is replaced,
|
|
1099
|
+
whereas defining nodes persist and wrap the inserted content.
|
|
1100
|
+
*/
|
|
1101
|
+
definingAsContext?: boolean;
|
|
1102
|
+
/**
|
|
1103
|
+
In inserted content the defining parents of the content are
|
|
1104
|
+
preserved when possible. Typically, non-default-paragraph
|
|
1105
|
+
textblock types, and possibly list items, are marked as defining.
|
|
1106
|
+
*/
|
|
1107
|
+
definingForContent?: boolean;
|
|
1108
|
+
/**
|
|
1109
|
+
When enabled, enables both
|
|
1110
|
+
[`definingAsContext`](https://prosemirror.net/docs/ref/#model.NodeSpec.definingAsContext) and
|
|
1111
|
+
[`definingForContent`](https://prosemirror.net/docs/ref/#model.NodeSpec.definingForContent).
|
|
1112
|
+
*/
|
|
1113
|
+
defining?: boolean;
|
|
1114
|
+
/**
|
|
1115
|
+
When enabled (default is false), the sides of nodes of this type
|
|
1116
|
+
count as boundaries that regular editing operations, like
|
|
1117
|
+
backspacing or lifting, won't cross. An example of a node that
|
|
1118
|
+
should probably have this enabled is a table cell.
|
|
1119
|
+
*/
|
|
1120
|
+
isolating?: boolean;
|
|
1121
|
+
/**
|
|
1122
|
+
Defines the default way a node of this type should be serialized
|
|
1123
|
+
to DOM/HTML (as used by
|
|
1124
|
+
[`DOMSerializer.fromSchema`](https://prosemirror.net/docs/ref/#model.DOMSerializer^fromSchema)).
|
|
1125
|
+
Should return a DOM node or an [array
|
|
1126
|
+
structure](https://prosemirror.net/docs/ref/#model.DOMOutputSpec) that describes one, with an
|
|
1127
|
+
optional number zero (“hole”) in it to indicate where the node's
|
|
1128
|
+
content should be inserted.
|
|
1129
|
+
|
|
1130
|
+
For text nodes, the default is to create a text DOM node. Though
|
|
1131
|
+
it is possible to create a serializer where text is rendered
|
|
1132
|
+
differently, this is not supported inside the editor, so you
|
|
1133
|
+
shouldn't override that in your text node spec.
|
|
1134
|
+
*/
|
|
1135
|
+
toDOM?: (node: Node) => DOMOutputSpec;
|
|
1136
|
+
/**
|
|
1137
|
+
Associates DOM parser information with this node, which can be
|
|
1138
|
+
used by [`DOMParser.fromSchema`](https://prosemirror.net/docs/ref/#model.DOMParser^fromSchema) to
|
|
1139
|
+
automatically derive a parser. The `node` field in the rules is
|
|
1140
|
+
implied (the name of this node will be filled in automatically).
|
|
1141
|
+
If you supply your own parser, you do not need to also specify
|
|
1142
|
+
parsing rules in your schema.
|
|
1143
|
+
*/
|
|
1144
|
+
parseDOM?: readonly TagParseRule[];
|
|
1145
|
+
/**
|
|
1146
|
+
Defines the default way a node of this type should be serialized
|
|
1147
|
+
to a string representation for debugging (e.g. in error messages).
|
|
1148
|
+
*/
|
|
1149
|
+
toDebugString?: (node: Node) => string;
|
|
1150
|
+
/**
|
|
1151
|
+
Defines the default way a [leaf node](https://prosemirror.net/docs/ref/#model.NodeType.isLeaf) of
|
|
1152
|
+
this type should be serialized to a string (as used by
|
|
1153
|
+
[`Node.textBetween`](https://prosemirror.net/docs/ref/#model.Node.textBetween) and
|
|
1154
|
+
[`Node.textContent`](https://prosemirror.net/docs/ref/#model.Node.textContent)).
|
|
1155
|
+
*/
|
|
1156
|
+
leafText?: (node: Node) => string;
|
|
1157
|
+
/**
|
|
1158
|
+
A single inline node in a schema can be set to be a linebreak
|
|
1159
|
+
equivalent. When converting between block types that support the
|
|
1160
|
+
node and block types that don't but have
|
|
1161
|
+
[`whitespace`](https://prosemirror.net/docs/ref/#model.NodeSpec.whitespace) set to `"pre"`,
|
|
1162
|
+
[`setBlockType`](https://prosemirror.net/docs/ref/#transform.Transform.setBlockType) will convert
|
|
1163
|
+
between newline characters to or from linebreak nodes as
|
|
1164
|
+
appropriate.
|
|
1165
|
+
*/
|
|
1166
|
+
linebreakReplacement?: boolean;
|
|
1167
|
+
/**
|
|
1168
|
+
Node specs may include arbitrary properties that can be read by
|
|
1169
|
+
other code via [`NodeType.spec`](https://prosemirror.net/docs/ref/#model.NodeType.spec).
|
|
1170
|
+
*/
|
|
1171
|
+
[key: string]: any;
|
|
1172
|
+
}
|
|
1173
|
+
/**
|
|
1174
|
+
Used to define marks when creating a schema.
|
|
1175
|
+
*/
|
|
1176
|
+
interface MarkSpec {
|
|
1177
|
+
/**
|
|
1178
|
+
The attributes that marks of this type get.
|
|
1179
|
+
*/
|
|
1180
|
+
attrs?: {
|
|
1181
|
+
[name: string]: AttributeSpec$1;
|
|
1182
|
+
};
|
|
1183
|
+
/**
|
|
1184
|
+
Whether this mark should be active when the cursor is positioned
|
|
1185
|
+
at its end (or at its start when that is also the start of the
|
|
1186
|
+
parent node). Defaults to true.
|
|
1187
|
+
*/
|
|
1188
|
+
inclusive?: boolean;
|
|
1189
|
+
/**
|
|
1190
|
+
Determines which other marks this mark can coexist with. Should
|
|
1191
|
+
be a space-separated strings naming other marks or groups of marks.
|
|
1192
|
+
When a mark is [added](https://prosemirror.net/docs/ref/#model.Mark.addToSet) to a set, all marks
|
|
1193
|
+
that it excludes are removed in the process. If the set contains
|
|
1194
|
+
any mark that excludes the new mark but is not, itself, excluded
|
|
1195
|
+
by the new mark, the mark can not be added an the set. You can
|
|
1196
|
+
use the value `"_"` to indicate that the mark excludes all
|
|
1197
|
+
marks in the schema.
|
|
1198
|
+
|
|
1199
|
+
Defaults to only being exclusive with marks of the same type. You
|
|
1200
|
+
can set it to an empty string (or any string not containing the
|
|
1201
|
+
mark's own name) to allow multiple marks of a given type to
|
|
1202
|
+
coexist (as long as they have different attributes).
|
|
1203
|
+
*/
|
|
1204
|
+
excludes?: string;
|
|
1205
|
+
/**
|
|
1206
|
+
The group or space-separated groups to which this mark belongs.
|
|
1207
|
+
*/
|
|
1208
|
+
group?: string;
|
|
1209
|
+
/**
|
|
1210
|
+
Determines whether marks of this type can span multiple adjacent
|
|
1211
|
+
nodes when serialized to DOM/HTML. Defaults to true.
|
|
1212
|
+
*/
|
|
1213
|
+
spanning?: boolean;
|
|
1214
|
+
/**
|
|
1215
|
+
Marks the content of this span as being code, which causes some
|
|
1216
|
+
commands and extensions to treat it differently.
|
|
1217
|
+
*/
|
|
1218
|
+
code?: boolean;
|
|
1219
|
+
/**
|
|
1220
|
+
Defines the default way marks of this type should be serialized
|
|
1221
|
+
to DOM/HTML. When the resulting spec contains a hole, that is
|
|
1222
|
+
where the marked content is placed. Otherwise, it is appended to
|
|
1223
|
+
the top node.
|
|
1224
|
+
*/
|
|
1225
|
+
toDOM?: (mark: Mark, inline: boolean) => DOMOutputSpec;
|
|
1226
|
+
/**
|
|
1227
|
+
Associates DOM parser information with this mark (see the
|
|
1228
|
+
corresponding [node spec field](https://prosemirror.net/docs/ref/#model.NodeSpec.parseDOM)). The
|
|
1229
|
+
`mark` field in the rules is implied.
|
|
1230
|
+
*/
|
|
1231
|
+
parseDOM?: readonly ParseRule[];
|
|
1232
|
+
/**
|
|
1233
|
+
Mark specs can include additional properties that can be
|
|
1234
|
+
inspected through [`MarkType.spec`](https://prosemirror.net/docs/ref/#model.MarkType.spec) when
|
|
1235
|
+
working with the mark.
|
|
1236
|
+
*/
|
|
1237
|
+
[key: string]: any;
|
|
1238
|
+
}
|
|
1239
|
+
/**
|
|
1240
|
+
Used to [define](https://prosemirror.net/docs/ref/#model.NodeSpec.attrs) attributes on nodes or
|
|
1241
|
+
marks.
|
|
1242
|
+
*/
|
|
1243
|
+
interface AttributeSpec$1 {
|
|
1244
|
+
/**
|
|
1245
|
+
The default value for this attribute, to use when no explicit
|
|
1246
|
+
value is provided. Attributes that have no default must be
|
|
1247
|
+
provided whenever a node or mark of a type that has them is
|
|
1248
|
+
created.
|
|
1249
|
+
*/
|
|
1250
|
+
default?: any;
|
|
1251
|
+
/**
|
|
1252
|
+
A function or type name used to validate values of this
|
|
1253
|
+
attribute. This will be used when deserializing the attribute
|
|
1254
|
+
from JSON, and when running [`Node.check`](https://prosemirror.net/docs/ref/#model.Node.check).
|
|
1255
|
+
When a function, it should raise an exception if the value isn't
|
|
1256
|
+
of the expected type or shape. When a string, it should be a
|
|
1257
|
+
`|`-separated string of primitive types (`"number"`, `"string"`,
|
|
1258
|
+
`"boolean"`, `"null"`, and `"undefined"`), and the library will
|
|
1259
|
+
raise an error when the value is not one of those types.
|
|
1260
|
+
*/
|
|
1261
|
+
validate?: string | ((value: any) => void);
|
|
1262
|
+
}
|
|
1263
|
+
/**
|
|
1264
|
+
A document schema. Holds [node](https://prosemirror.net/docs/ref/#model.NodeType) and [mark
|
|
1265
|
+
type](https://prosemirror.net/docs/ref/#model.MarkType) objects for the nodes and marks that may
|
|
1266
|
+
occur in conforming documents, and provides functionality for
|
|
1267
|
+
creating and deserializing such documents.
|
|
1268
|
+
|
|
1269
|
+
When given, the type parameters provide the names of the nodes and
|
|
1270
|
+
marks in this schema.
|
|
1271
|
+
*/
|
|
1272
|
+
declare class Schema$1<Nodes extends string = any, Marks extends string = any> {
|
|
1273
|
+
/**
|
|
1274
|
+
The [spec](https://prosemirror.net/docs/ref/#model.SchemaSpec) on which the schema is based,
|
|
1275
|
+
with the added guarantee that its `nodes` and `marks`
|
|
1276
|
+
properties are
|
|
1277
|
+
[`OrderedMap`](https://code.haverbeke.berlin/marijn/orderedmap) instances
|
|
1278
|
+
(not raw objects).
|
|
1279
|
+
*/
|
|
1280
|
+
spec: {
|
|
1281
|
+
nodes: OrderedMap<NodeSpec>;
|
|
1282
|
+
marks: OrderedMap<MarkSpec>;
|
|
1283
|
+
topNode?: string;
|
|
1284
|
+
};
|
|
1285
|
+
/**
|
|
1286
|
+
An object mapping the schema's node names to node type objects.
|
|
1287
|
+
*/
|
|
1288
|
+
nodes: { readonly [name in Nodes]: NodeType$1; } & {
|
|
1289
|
+
readonly [key: string]: NodeType$1;
|
|
1290
|
+
};
|
|
1291
|
+
/**
|
|
1292
|
+
A map from mark names to mark type objects.
|
|
1293
|
+
*/
|
|
1294
|
+
marks: { readonly [name in Marks]: MarkType$1; } & {
|
|
1295
|
+
readonly [key: string]: MarkType$1;
|
|
1296
|
+
};
|
|
1297
|
+
/**
|
|
1298
|
+
The [linebreak
|
|
1299
|
+
replacement](https://prosemirror.net/docs/ref/#model.NodeSpec.linebreakReplacement) node defined
|
|
1300
|
+
in this schema, if any.
|
|
1301
|
+
*/
|
|
1302
|
+
linebreakReplacement: NodeType$1 | null;
|
|
1303
|
+
/**
|
|
1304
|
+
Construct a schema from a schema [specification](https://prosemirror.net/docs/ref/#model.SchemaSpec).
|
|
1305
|
+
*/
|
|
1306
|
+
constructor(spec: SchemaSpec<Nodes, Marks>);
|
|
1307
|
+
/**
|
|
1308
|
+
The type of the [default top node](https://prosemirror.net/docs/ref/#model.SchemaSpec.topNode)
|
|
1309
|
+
for this schema.
|
|
1310
|
+
*/
|
|
1311
|
+
topNodeType: NodeType$1;
|
|
1312
|
+
/**
|
|
1313
|
+
An object for storing whatever values modules may want to
|
|
1314
|
+
compute and cache per schema. (If you want to store something
|
|
1315
|
+
in it, try to use property names unlikely to clash.)
|
|
1316
|
+
*/
|
|
1317
|
+
cached: {
|
|
1318
|
+
[key: string]: any;
|
|
1319
|
+
};
|
|
1320
|
+
/**
|
|
1321
|
+
Create a node in this schema. The `type` may be a string or a
|
|
1322
|
+
`NodeType` instance. Attributes will be extended with defaults,
|
|
1323
|
+
`content` may be a `Fragment`, `null`, a `Node`, or an array of
|
|
1324
|
+
nodes.
|
|
1325
|
+
*/
|
|
1326
|
+
node(type: string | NodeType$1, attrs?: Attrs$1 | null, content?: Fragment | Node | readonly Node[], marks?: readonly Mark[]): Node;
|
|
1327
|
+
/**
|
|
1328
|
+
Create a text node in the schema. Empty text nodes are not
|
|
1329
|
+
allowed.
|
|
1330
|
+
*/
|
|
1331
|
+
text(text: string, marks?: readonly Mark[] | null): Node;
|
|
1332
|
+
/**
|
|
1333
|
+
Create a mark with the given type and attributes.
|
|
1334
|
+
*/
|
|
1335
|
+
mark(type: string | MarkType$1, attrs?: Attrs$1 | null): Mark;
|
|
1336
|
+
/**
|
|
1337
|
+
Deserialize a node from its JSON representation. This method is
|
|
1338
|
+
bound.
|
|
1339
|
+
*/
|
|
1340
|
+
nodeFromJSON: (json: any) => Node;
|
|
1341
|
+
/**
|
|
1342
|
+
Deserialize a mark from its JSON representation. This method is
|
|
1343
|
+
bound.
|
|
1344
|
+
*/
|
|
1345
|
+
markFromJSON: (json: any) => Mark;
|
|
1346
|
+
}
|
|
1347
|
+
/**
|
|
1348
|
+
A fragment represents a node's collection of child nodes.
|
|
1349
|
+
|
|
1350
|
+
Like nodes, fragments are persistent data structures, and you
|
|
1351
|
+
should not mutate them or their content. Rather, you create new
|
|
1352
|
+
instances whenever needed. The API tries to make this easy.
|
|
1353
|
+
*/
|
|
1354
|
+
declare class Fragment {
|
|
1355
|
+
/**
|
|
1356
|
+
The child nodes in this fragment.
|
|
1357
|
+
*/
|
|
1358
|
+
readonly content: readonly Node[];
|
|
1359
|
+
/**
|
|
1360
|
+
The size of the fragment, which is the total of the size of
|
|
1361
|
+
its content nodes.
|
|
1362
|
+
*/
|
|
1363
|
+
readonly size: number;
|
|
1364
|
+
/**
|
|
1365
|
+
Invoke a callback for all descendant nodes between the given two
|
|
1366
|
+
positions (relative to start of this fragment). Doesn't descend
|
|
1367
|
+
into a node when the callback returns `false`.
|
|
1368
|
+
*/
|
|
1369
|
+
nodesBetween(from: number, to: number, f: (node: Node, start: number, parent: Node | null, index: number) => boolean | void, nodeStart?: number, parent?: Node): void;
|
|
1370
|
+
/**
|
|
1371
|
+
Call the given callback for every descendant node. `pos` will be
|
|
1372
|
+
relative to the start of the fragment. The callback may return
|
|
1373
|
+
`false` to prevent traversal of a given node's children.
|
|
1374
|
+
*/
|
|
1375
|
+
descendants(f: (node: Node, pos: number, parent: Node | null, index: number) => boolean | void): void;
|
|
1376
|
+
/**
|
|
1377
|
+
Extract the text between `from` and `to`. See the same method on
|
|
1378
|
+
[`Node`](https://prosemirror.net/docs/ref/#model.Node.textBetween).
|
|
1379
|
+
*/
|
|
1380
|
+
textBetween(from: number, to: number, blockSeparator?: string | null, leafText?: string | null | ((leafNode: Node) => string)): string;
|
|
1381
|
+
/**
|
|
1382
|
+
Create a new fragment containing the combined content of this
|
|
1383
|
+
fragment and the other.
|
|
1384
|
+
*/
|
|
1385
|
+
append(other: Fragment): Fragment;
|
|
1386
|
+
/**
|
|
1387
|
+
Cut out the sub-fragment between the two given positions.
|
|
1388
|
+
*/
|
|
1389
|
+
cut(from: number, to?: number): Fragment;
|
|
1390
|
+
/**
|
|
1391
|
+
Create a new fragment in which the node at the given index is
|
|
1392
|
+
replaced by the given node.
|
|
1393
|
+
*/
|
|
1394
|
+
replaceChild(index: number, node: Node): Fragment;
|
|
1395
|
+
/**
|
|
1396
|
+
Create a new fragment by prepending the given node to this
|
|
1397
|
+
fragment.
|
|
1398
|
+
*/
|
|
1399
|
+
addToStart(node: Node): Fragment;
|
|
1400
|
+
/**
|
|
1401
|
+
Create a new fragment by appending the given node to this
|
|
1402
|
+
fragment.
|
|
1403
|
+
*/
|
|
1404
|
+
addToEnd(node: Node): Fragment;
|
|
1405
|
+
/**
|
|
1406
|
+
Compare this fragment to another one.
|
|
1407
|
+
*/
|
|
1408
|
+
eq(other: Fragment): boolean;
|
|
1409
|
+
/**
|
|
1410
|
+
The first child of the fragment, or `null` if it is empty.
|
|
1411
|
+
*/
|
|
1412
|
+
get firstChild(): Node | null;
|
|
1413
|
+
/**
|
|
1414
|
+
The last child of the fragment, or `null` if it is empty.
|
|
1415
|
+
*/
|
|
1416
|
+
get lastChild(): Node | null;
|
|
1417
|
+
/**
|
|
1418
|
+
The number of child nodes in this fragment.
|
|
1419
|
+
*/
|
|
1420
|
+
get childCount(): number;
|
|
1421
|
+
/**
|
|
1422
|
+
Get the child node at the given index. Raise an error when the
|
|
1423
|
+
index is out of range.
|
|
1424
|
+
*/
|
|
1425
|
+
child(index: number): Node;
|
|
1426
|
+
/**
|
|
1427
|
+
Get the child node at the given index, if it exists.
|
|
1428
|
+
*/
|
|
1429
|
+
maybeChild(index: number): Node | null;
|
|
1430
|
+
/**
|
|
1431
|
+
Call `f` for every child node, passing the node, its offset
|
|
1432
|
+
into this parent node, and its index.
|
|
1433
|
+
*/
|
|
1434
|
+
forEach(f: (node: Node, offset: number, index: number) => void): void;
|
|
1435
|
+
/**
|
|
1436
|
+
Find the first position at which this fragment and another
|
|
1437
|
+
fragment differ, or `null` if they are the same.
|
|
1438
|
+
*/
|
|
1439
|
+
findDiffStart(other: Fragment, pos?: number): number | null;
|
|
1440
|
+
/**
|
|
1441
|
+
Find the first position, searching from the end, at which this
|
|
1442
|
+
fragment and the given fragment differ, or `null` if they are
|
|
1443
|
+
the same. Since this position will not be the same in both
|
|
1444
|
+
nodes, an object with two separate positions is returned.
|
|
1445
|
+
*/
|
|
1446
|
+
findDiffEnd(other: Fragment, pos?: number, otherPos?: number): {
|
|
1447
|
+
a: number;
|
|
1448
|
+
b: number;
|
|
1449
|
+
} | null;
|
|
1450
|
+
/**
|
|
1451
|
+
Return a debugging string that describes this fragment.
|
|
1452
|
+
*/
|
|
1453
|
+
toString(): string;
|
|
1454
|
+
/**
|
|
1455
|
+
Create a JSON-serializeable representation of this fragment.
|
|
1456
|
+
*/
|
|
1457
|
+
toJSON(): any;
|
|
1458
|
+
/**
|
|
1459
|
+
Deserialize a fragment from its JSON representation.
|
|
1460
|
+
*/
|
|
1461
|
+
static fromJSON(schema: Schema$1, value: any): Fragment;
|
|
1462
|
+
/**
|
|
1463
|
+
Build a fragment from an array of nodes. Ensures that adjacent
|
|
1464
|
+
text nodes with the same marks are joined together.
|
|
1465
|
+
*/
|
|
1466
|
+
static fromArray(array: readonly Node[]): Fragment;
|
|
1467
|
+
/**
|
|
1468
|
+
Create a fragment from something that can be interpreted as a
|
|
1469
|
+
set of nodes. For `null`, it returns the empty fragment. For a
|
|
1470
|
+
fragment, the fragment itself. For a node or array of nodes, a
|
|
1471
|
+
fragment containing those nodes.
|
|
1472
|
+
*/
|
|
1473
|
+
static from(nodes?: Fragment | Node | readonly Node[] | null): Fragment;
|
|
1474
|
+
/**
|
|
1475
|
+
An empty fragment. Intended to be reused whenever a node doesn't
|
|
1476
|
+
contain anything (rather than allocating a new empty fragment for
|
|
1477
|
+
each leaf node).
|
|
1478
|
+
*/
|
|
1479
|
+
static empty: Fragment;
|
|
1480
|
+
}
|
|
1481
|
+
type MatchEdge = {
|
|
1482
|
+
type: NodeType$1;
|
|
1483
|
+
next: ContentMatch;
|
|
1484
|
+
};
|
|
1485
|
+
/**
|
|
1486
|
+
Instances of this class represent a match state of a node type's
|
|
1487
|
+
[content expression](https://prosemirror.net/docs/ref/#model.NodeSpec.content), and can be used to
|
|
1488
|
+
find out whether further content matches here, and whether a given
|
|
1489
|
+
position is a valid end of the node.
|
|
1490
|
+
*/
|
|
1491
|
+
declare class ContentMatch {
|
|
1492
|
+
/**
|
|
1493
|
+
True when this match state represents a valid end of the node.
|
|
1494
|
+
*/
|
|
1495
|
+
readonly validEnd: boolean;
|
|
1496
|
+
/**
|
|
1497
|
+
Match a node type, returning a match after that node if
|
|
1498
|
+
successful.
|
|
1499
|
+
*/
|
|
1500
|
+
matchType(type: NodeType$1): ContentMatch | null;
|
|
1501
|
+
/**
|
|
1502
|
+
Try to match a fragment. Returns the resulting match when
|
|
1503
|
+
successful.
|
|
1504
|
+
*/
|
|
1505
|
+
matchFragment(frag: Fragment, start?: number, end?: number): ContentMatch | null;
|
|
1506
|
+
/**
|
|
1507
|
+
Get the first matching node type at this match position that can
|
|
1508
|
+
be generated.
|
|
1509
|
+
*/
|
|
1510
|
+
get defaultType(): NodeType$1 | null;
|
|
1511
|
+
/**
|
|
1512
|
+
Try to match the given fragment, and if that fails, see if it can
|
|
1513
|
+
be made to match by inserting nodes in front of it. When
|
|
1514
|
+
successful, return a fragment of inserted nodes (which may be
|
|
1515
|
+
empty if nothing had to be inserted). When `toEnd` is true, only
|
|
1516
|
+
return a fragment if the resulting match goes to the end of the
|
|
1517
|
+
content expression.
|
|
1518
|
+
*/
|
|
1519
|
+
fillBefore(after: Fragment, toEnd?: boolean, startIndex?: number): Fragment | null;
|
|
1520
|
+
/**
|
|
1521
|
+
Find a set of wrapping node types that would allow a node of the
|
|
1522
|
+
given type to appear at this position. The result may be empty
|
|
1523
|
+
(when it fits directly) and will be null when no such wrapping
|
|
1524
|
+
exists.
|
|
1525
|
+
*/
|
|
1526
|
+
findWrapping(target: NodeType$1): readonly NodeType$1[] | null;
|
|
1527
|
+
/**
|
|
1528
|
+
The number of outgoing edges this node has in the finite
|
|
1529
|
+
automaton that describes the content expression.
|
|
1530
|
+
*/
|
|
1531
|
+
get edgeCount(): number;
|
|
1532
|
+
/**
|
|
1533
|
+
Get the _n_th outgoing edge from this node in the finite
|
|
1534
|
+
automaton that describes the content expression.
|
|
1535
|
+
*/
|
|
1536
|
+
edge(n: number): MatchEdge;
|
|
1537
|
+
}
|
|
1538
|
+
/**
|
|
1539
|
+
This class represents a node in the tree that makes up a
|
|
1540
|
+
ProseMirror document. So a document is an instance of `Node`, with
|
|
1541
|
+
children that are also instances of `Node`.
|
|
1542
|
+
|
|
1543
|
+
Nodes are persistent data structures. Instead of changing them, you
|
|
1544
|
+
create new ones with the content you want. Old ones keep pointing
|
|
1545
|
+
at the old document shape. This is made cheaper by sharing
|
|
1546
|
+
structure between the old and new data as much as possible, which a
|
|
1547
|
+
tree shape like this (without back pointers) makes easy.
|
|
1548
|
+
|
|
1549
|
+
**Do not** directly mutate the properties of a `Node` object. See
|
|
1550
|
+
[the guide](https://prosemirror.net/docs/guide/#doc) for more information.
|
|
1551
|
+
*/
|
|
1552
|
+
declare class Node {
|
|
1553
|
+
/**
|
|
1554
|
+
The type of node that this is.
|
|
1555
|
+
*/
|
|
1556
|
+
readonly type: NodeType$1;
|
|
1557
|
+
/**
|
|
1558
|
+
An object mapping attribute names to values. The kind of
|
|
1559
|
+
attributes allowed and required are
|
|
1560
|
+
[determined](https://prosemirror.net/docs/ref/#model.NodeSpec.attrs) by the node type.
|
|
1561
|
+
*/
|
|
1562
|
+
readonly attrs: Attrs$1;
|
|
1563
|
+
/**
|
|
1564
|
+
The marks (things like whether it is emphasized or part of a
|
|
1565
|
+
link) applied to this node.
|
|
1566
|
+
*/
|
|
1567
|
+
readonly marks: readonly Mark[];
|
|
1568
|
+
/**
|
|
1569
|
+
A container holding the node's children.
|
|
1570
|
+
*/
|
|
1571
|
+
readonly content: Fragment;
|
|
1572
|
+
/**
|
|
1573
|
+
The array of this node's child nodes.
|
|
1574
|
+
*/
|
|
1575
|
+
get children(): readonly Node[];
|
|
1576
|
+
/**
|
|
1577
|
+
For text nodes, this contains the node's text content.
|
|
1578
|
+
*/
|
|
1579
|
+
readonly text: string | undefined;
|
|
1580
|
+
/**
|
|
1581
|
+
The size of this node, as defined by the integer-based [indexing
|
|
1582
|
+
scheme](https://prosemirror.net/docs/guide/#doc.indexing). For text nodes, this is the
|
|
1583
|
+
amount of characters. For other leaf nodes, it is one. For
|
|
1584
|
+
non-leaf nodes, it is the size of the content plus two (the
|
|
1585
|
+
start and end token).
|
|
1586
|
+
*/
|
|
1587
|
+
get nodeSize(): number;
|
|
1588
|
+
/**
|
|
1589
|
+
The number of children that the node has.
|
|
1590
|
+
*/
|
|
1591
|
+
get childCount(): number;
|
|
1592
|
+
/**
|
|
1593
|
+
Get the child node at the given index. Raises an error when the
|
|
1594
|
+
index is out of range.
|
|
1595
|
+
*/
|
|
1596
|
+
child(index: number): Node;
|
|
1597
|
+
/**
|
|
1598
|
+
Get the child node at the given index, if it exists.
|
|
1599
|
+
*/
|
|
1600
|
+
maybeChild(index: number): Node | null;
|
|
1601
|
+
/**
|
|
1602
|
+
Call `f` for every child node, passing the node, its offset
|
|
1603
|
+
into this parent node, and its index.
|
|
1604
|
+
*/
|
|
1605
|
+
forEach(f: (node: Node, offset: number, index: number) => void): void;
|
|
1606
|
+
/**
|
|
1607
|
+
Invoke a callback for all descendant nodes recursively overlapping
|
|
1608
|
+
the given two positions that are relative to start of this
|
|
1609
|
+
node's content. This includes all ancestors of the nodes
|
|
1610
|
+
containing the two positions. The callback is invoked with the
|
|
1611
|
+
node, its position relative to the original node (method receiver),
|
|
1612
|
+
its parent node, and its child index. When the callback returns
|
|
1613
|
+
false for a given node, that node's children will not be
|
|
1614
|
+
recursed over. The last parameter can be used to specify a
|
|
1615
|
+
starting position to count from.
|
|
1616
|
+
*/
|
|
1617
|
+
nodesBetween(from: number, to: number, f: (node: Node, pos: number, parent: Node | null, index: number) => void | boolean, startPos?: number): void;
|
|
1618
|
+
/**
|
|
1619
|
+
Call the given callback for every descendant node. Doesn't
|
|
1620
|
+
descend into a node when the callback returns `false`.
|
|
1621
|
+
*/
|
|
1622
|
+
descendants(f: (node: Node, pos: number, parent: Node | null, index: number) => void | boolean): void;
|
|
1623
|
+
/**
|
|
1624
|
+
Concatenates all the text nodes found in this fragment and its
|
|
1625
|
+
children.
|
|
1626
|
+
*/
|
|
1627
|
+
get textContent(): string;
|
|
1628
|
+
/**
|
|
1629
|
+
Get all text between positions `from` and `to`. When
|
|
1630
|
+
`blockSeparator` is given, it will be inserted to separate text
|
|
1631
|
+
from different block nodes. If `leafText` is given, it'll be
|
|
1632
|
+
inserted for every non-text leaf node encountered, otherwise
|
|
1633
|
+
[`leafText`](https://prosemirror.net/docs/ref/#model.NodeSpec.leafText) will be used.
|
|
1634
|
+
*/
|
|
1635
|
+
textBetween(from: number, to: number, blockSeparator?: string | null, leafText?: null | string | ((leafNode: Node) => string)): string;
|
|
1636
|
+
/**
|
|
1637
|
+
Returns this node's first child, or `null` if there are no
|
|
1638
|
+
children.
|
|
1639
|
+
*/
|
|
1640
|
+
get firstChild(): Node | null;
|
|
1641
|
+
/**
|
|
1642
|
+
Returns this node's last child, or `null` if there are no
|
|
1643
|
+
children.
|
|
1644
|
+
*/
|
|
1645
|
+
get lastChild(): Node | null;
|
|
1646
|
+
/**
|
|
1647
|
+
Test whether two nodes represent the same piece of document.
|
|
1648
|
+
*/
|
|
1649
|
+
eq(other: Node): boolean;
|
|
1650
|
+
/**
|
|
1651
|
+
Compare the markup (type, attributes, and marks) of this node to
|
|
1652
|
+
those of another. Returns `true` if both have the same markup.
|
|
1653
|
+
*/
|
|
1654
|
+
sameMarkup(other: Node): boolean;
|
|
1655
|
+
/**
|
|
1656
|
+
Check whether this node's markup correspond to the given type,
|
|
1657
|
+
attributes, and marks.
|
|
1658
|
+
*/
|
|
1659
|
+
hasMarkup(type: NodeType$1, attrs?: Attrs$1 | null, marks?: readonly Mark[]): boolean;
|
|
1660
|
+
/**
|
|
1661
|
+
Create a new node with the same markup as this node, containing
|
|
1662
|
+
the given content (or empty, if no content is given).
|
|
1663
|
+
*/
|
|
1664
|
+
copy(content?: Fragment | null): Node;
|
|
1665
|
+
/**
|
|
1666
|
+
Create a copy of this node, with the given set of marks instead
|
|
1667
|
+
of the node's own marks.
|
|
1668
|
+
*/
|
|
1669
|
+
mark(marks: readonly Mark[]): Node;
|
|
1670
|
+
/**
|
|
1671
|
+
Create a copy of this node with only the content between the
|
|
1672
|
+
given positions. If `to` is not given, it defaults to the end of
|
|
1673
|
+
the node.
|
|
1674
|
+
*/
|
|
1675
|
+
cut(from: number, to?: number): Node;
|
|
1676
|
+
/**
|
|
1677
|
+
Cut out the part of the document between the given positions, and
|
|
1678
|
+
return it as a `Slice` object.
|
|
1679
|
+
*/
|
|
1680
|
+
slice(from: number, to?: number, includeParents?: boolean): Slice;
|
|
1681
|
+
/**
|
|
1682
|
+
Replace the part of the document between the given positions with
|
|
1683
|
+
the given slice. The slice must 'fit', meaning its open sides
|
|
1684
|
+
must be able to connect to the surrounding content, and its
|
|
1685
|
+
content nodes must be valid children for the node they are placed
|
|
1686
|
+
into. If any of this is violated, an error of type
|
|
1687
|
+
[`ReplaceError`](https://prosemirror.net/docs/ref/#model.ReplaceError) is thrown.
|
|
1688
|
+
*/
|
|
1689
|
+
replace(from: number, to: number, slice: Slice): Node;
|
|
1690
|
+
/**
|
|
1691
|
+
Find the node directly after the given position.
|
|
1692
|
+
*/
|
|
1693
|
+
nodeAt(pos: number): Node | null;
|
|
1694
|
+
/**
|
|
1695
|
+
Find the (direct) child node after the given offset, if any,
|
|
1696
|
+
and return it along with its index and offset relative to this
|
|
1697
|
+
node.
|
|
1698
|
+
*/
|
|
1699
|
+
childAfter(pos: number): {
|
|
1700
|
+
node: Node | null;
|
|
1701
|
+
index: number;
|
|
1702
|
+
offset: number;
|
|
1703
|
+
};
|
|
1704
|
+
/**
|
|
1705
|
+
Find the (direct) child node before the given offset, if any,
|
|
1706
|
+
and return it along with its index and offset relative to this
|
|
1707
|
+
node.
|
|
1708
|
+
*/
|
|
1709
|
+
childBefore(pos: number): {
|
|
1710
|
+
node: Node | null;
|
|
1711
|
+
index: number;
|
|
1712
|
+
offset: number;
|
|
1713
|
+
};
|
|
1714
|
+
/**
|
|
1715
|
+
Resolve the given position in the document, returning an
|
|
1716
|
+
[object](https://prosemirror.net/docs/ref/#model.ResolvedPos) with information about its context.
|
|
1717
|
+
*/
|
|
1718
|
+
resolve(pos: number): ResolvedPos;
|
|
1719
|
+
/**
|
|
1720
|
+
Test whether a given mark or mark type occurs in this document
|
|
1721
|
+
between the two given positions.
|
|
1722
|
+
*/
|
|
1723
|
+
rangeHasMark(from: number, to: number, type: Mark | MarkType$1): boolean;
|
|
1724
|
+
/**
|
|
1725
|
+
True when this is a block (non-inline node)
|
|
1726
|
+
*/
|
|
1727
|
+
get isBlock(): boolean;
|
|
1728
|
+
/**
|
|
1729
|
+
True when this is a textblock node, a block node with inline
|
|
1730
|
+
content.
|
|
1731
|
+
*/
|
|
1732
|
+
get isTextblock(): boolean;
|
|
1733
|
+
/**
|
|
1734
|
+
True when this node allows inline content.
|
|
1735
|
+
*/
|
|
1736
|
+
get inlineContent(): boolean;
|
|
1737
|
+
/**
|
|
1738
|
+
True when this is an inline node (a text node or a node that can
|
|
1739
|
+
appear among text).
|
|
1740
|
+
*/
|
|
1741
|
+
get isInline(): boolean;
|
|
1742
|
+
/**
|
|
1743
|
+
True when this is a text node.
|
|
1744
|
+
*/
|
|
1745
|
+
get isText(): boolean;
|
|
1746
|
+
/**
|
|
1747
|
+
True when this is a leaf node.
|
|
1748
|
+
*/
|
|
1749
|
+
get isLeaf(): boolean;
|
|
1750
|
+
/**
|
|
1751
|
+
True when this is an atom, i.e. when it does not have directly
|
|
1752
|
+
editable content. This is usually the same as `isLeaf`, but can
|
|
1753
|
+
be configured with the [`atom` property](https://prosemirror.net/docs/ref/#model.NodeSpec.atom)
|
|
1754
|
+
on a node's spec (typically used when the node is displayed as
|
|
1755
|
+
an uneditable [node view](https://prosemirror.net/docs/ref/#view.NodeView)).
|
|
1756
|
+
*/
|
|
1757
|
+
get isAtom(): boolean;
|
|
1758
|
+
/**
|
|
1759
|
+
Return a string representation of this node for debugging
|
|
1760
|
+
purposes.
|
|
1761
|
+
*/
|
|
1762
|
+
toString(): string;
|
|
1763
|
+
/**
|
|
1764
|
+
Get the content match in this node at the given index.
|
|
1765
|
+
*/
|
|
1766
|
+
contentMatchAt(index: number): ContentMatch;
|
|
1767
|
+
/**
|
|
1768
|
+
Test whether replacing the range between `from` and `to` (by
|
|
1769
|
+
child index) with the given replacement fragment (which defaults
|
|
1770
|
+
to the empty fragment) would leave the node's content valid. You
|
|
1771
|
+
can optionally pass `start` and `end` indices into the
|
|
1772
|
+
replacement fragment.
|
|
1773
|
+
*/
|
|
1774
|
+
canReplace(from: number, to: number, replacement?: Fragment, start?: number, end?: number): boolean;
|
|
1775
|
+
/**
|
|
1776
|
+
Test whether replacing the range `from` to `to` (by index) with
|
|
1777
|
+
a node of the given type would leave the node's content valid.
|
|
1778
|
+
*/
|
|
1779
|
+
canReplaceWith(from: number, to: number, type: NodeType$1, marks?: readonly Mark[]): boolean;
|
|
1780
|
+
/**
|
|
1781
|
+
Test whether the given node's content could be appended to this
|
|
1782
|
+
node. If that node is empty, this will only return true if there
|
|
1783
|
+
is at least one node type that can appear in both nodes (to avoid
|
|
1784
|
+
merging completely incompatible nodes).
|
|
1785
|
+
*/
|
|
1786
|
+
canAppend(other: Node): boolean;
|
|
1787
|
+
/**
|
|
1788
|
+
Check whether this node and its descendants conform to the
|
|
1789
|
+
schema, and raise an exception when they do not.
|
|
1790
|
+
*/
|
|
1791
|
+
check(): void;
|
|
1792
|
+
/**
|
|
1793
|
+
Return a JSON-serializeable representation of this node.
|
|
1794
|
+
*/
|
|
1795
|
+
toJSON(): any;
|
|
1796
|
+
/**
|
|
1797
|
+
Deserialize a node from its JSON representation.
|
|
1798
|
+
*/
|
|
1799
|
+
static fromJSON(schema: Schema$1, json: any): Node;
|
|
1800
|
+
}
|
|
1801
|
+
/**
|
|
1802
|
+
Convert a union type to an intersection type.
|
|
1803
|
+
|
|
1804
|
+
Inspired by [this Stack Overflow answer](https://stackoverflow.com/a/50375286/2172153).
|
|
1805
|
+
|
|
1806
|
+
@example
|
|
1807
|
+
```
|
|
1808
|
+
import type {UnionToIntersection} from 'type-fest';
|
|
1809
|
+
|
|
1810
|
+
type Union = {the(): void} | {great(arg: string): void} | {escape: boolean};
|
|
1811
|
+
|
|
1812
|
+
type Intersection = UnionToIntersection<Union>;
|
|
1813
|
+
//=> {the(): void} & {great(arg: string): void} & {escape: boolean}
|
|
1814
|
+
```
|
|
1815
|
+
|
|
1816
|
+
@category Type
|
|
1817
|
+
*/
|
|
1818
|
+
type UnionToIntersection<Union> = (
|
|
1819
|
+
// `extends unknown` is always going to be the case and is used to convert the
|
|
1820
|
+
// `Union` into a [distributive conditional
|
|
1821
|
+
// type](https://www.typescriptlang.org/docs/handbook/release-notes/typescript-2-8.html#distributive-conditional-types).
|
|
1822
|
+
Union extends unknown ?
|
|
1823
|
+
// The union type is used as the only argument to a function since the union
|
|
1824
|
+
// of function arguments is an intersection.
|
|
1825
|
+
(distributedUnion: Union) => void :
|
|
1826
|
+
// This won't happen.
|
|
1827
|
+
never
|
|
1828
|
+
// Infer the `Intersection` type since TypeScript represents the positional
|
|
1829
|
+
// arguments of unions of functions as an intersection of the union.
|
|
1830
|
+
) extends ((mergedIntersection: infer Intersection) => void) ?
|
|
1831
|
+
// The `& Union` is to ensure result of `UnionToIntersection<A | B>` is always assignable to `A | B`
|
|
1832
|
+
Intersection & Union : never;
|
|
1833
|
+
/**
|
|
1834
|
+
Useful to flatten the type output to improve type hints shown in editors. And also to transform an interface into a type to aide with assignability.
|
|
1835
|
+
|
|
1836
|
+
@example
|
|
1837
|
+
```
|
|
1838
|
+
import type {Simplify} from 'type-fest';
|
|
1839
|
+
|
|
1840
|
+
type PositionProps = {
|
|
1841
|
+
top: number;
|
|
1842
|
+
left: number;
|
|
1843
|
+
};
|
|
1844
|
+
|
|
1845
|
+
type SizeProps = {
|
|
1846
|
+
width: number;
|
|
1847
|
+
height: number;
|
|
1848
|
+
};
|
|
1849
|
+
|
|
1850
|
+
// In your editor, hovering over `Props` will show a flattened object with all the properties.
|
|
1851
|
+
type Props = Simplify<PositionProps & SizeProps>;
|
|
1852
|
+
```
|
|
1853
|
+
|
|
1854
|
+
Sometimes it is desired to pass a value as a function argument that has a different type. At first inspection it may seem assignable, and then you discover it is not because the `value`'s type definition was defined as an interface. In the following example, `fn` requires an argument of type `Record<string, unknown>`. If the value is defined as a literal, then it is assignable. And if the `value` is defined as type using the `Simplify` utility the value is assignable. But if the `value` is defined as an interface, it is not assignable because the interface is not sealed and elsewhere a non-string property could be added to the interface.
|
|
1855
|
+
|
|
1856
|
+
If the type definition must be an interface (perhaps it was defined in a third-party npm package), then the `value` can be defined as `const value: Simplify<SomeInterface> = ...`. Then `value` will be assignable to the `fn` argument. Or the `value` can be cast as `Simplify<SomeInterface>` if you can't re-declare the `value`.
|
|
1857
|
+
|
|
1858
|
+
@example
|
|
1859
|
+
```
|
|
1860
|
+
import type {Simplify} from 'type-fest';
|
|
1861
|
+
|
|
1862
|
+
interface SomeInterface {
|
|
1863
|
+
foo: number;
|
|
1864
|
+
bar?: string;
|
|
1865
|
+
baz: number | undefined;
|
|
1866
|
+
}
|
|
1867
|
+
|
|
1868
|
+
type SomeType = {
|
|
1869
|
+
foo: number;
|
|
1870
|
+
bar?: string;
|
|
1871
|
+
baz: number | undefined;
|
|
1872
|
+
};
|
|
1873
|
+
|
|
1874
|
+
const literal = {foo: 123, bar: 'hello', baz: 456};
|
|
1875
|
+
const someType: SomeType = literal;
|
|
1876
|
+
const someInterface: SomeInterface = literal;
|
|
1877
|
+
|
|
1878
|
+
declare function fn(object: Record<string, unknown>): void;
|
|
1879
|
+
|
|
1880
|
+
fn(literal); // Good: literal object type is sealed
|
|
1881
|
+
fn(someType); // Good: type is sealed
|
|
1882
|
+
// @ts-expect-error
|
|
1883
|
+
fn(someInterface); // Error: Index signature for type 'string' is missing in type 'someInterface'. Because `interface` can be re-opened
|
|
1884
|
+
fn(someInterface as Simplify<SomeInterface>); // Good: transform an `interface` into a `type`
|
|
1885
|
+
```
|
|
1886
|
+
|
|
1887
|
+
@link https://github.com/microsoft/TypeScript/issues/15300
|
|
1888
|
+
@see {@link SimplifyDeep}
|
|
1889
|
+
@category Object
|
|
1890
|
+
*/
|
|
1891
|
+
type Simplify<T> = { [KeyType in keyof T]: T[KeyType]; } & {};
|
|
1892
|
+
/**
|
|
1893
|
+
* @internal
|
|
1894
|
+
*/
|
|
1895
|
+
interface CommandTyping {
|
|
1896
|
+
[name: string]: any[];
|
|
1897
|
+
}
|
|
1898
|
+
/**
|
|
1899
|
+
* @internal
|
|
1900
|
+
*/
|
|
1901
|
+
interface MarkTyping {
|
|
1902
|
+
[name: string]: Record<string, any>;
|
|
1903
|
+
}
|
|
1904
|
+
/**
|
|
1905
|
+
* @internal
|
|
1906
|
+
*/
|
|
1907
|
+
interface NodeTyping {
|
|
1908
|
+
[name: string]: Record<string, any>;
|
|
1909
|
+
}
|
|
1910
|
+
/**
|
|
1911
|
+
* @internal
|
|
1912
|
+
*/
|
|
1913
|
+
type PickSubType<Type, ParentType> = Type extends ParentType ? [ParentType] extends [Type] ? never : Type : never;
|
|
1914
|
+
/**
|
|
1915
|
+
* ProseKit extension priority.
|
|
1916
|
+
*
|
|
1917
|
+
* There are five priority levels available:
|
|
1918
|
+
*
|
|
1919
|
+
* - `Priority.lowest`
|
|
1920
|
+
* - `Priority.low`
|
|
1921
|
+
* - `Priority.default`
|
|
1922
|
+
* - `Priority.high`
|
|
1923
|
+
* - `Priority.highest`
|
|
1924
|
+
*
|
|
1925
|
+
* @example
|
|
1926
|
+
*
|
|
1927
|
+
* ```ts
|
|
1928
|
+
* import { withPriority, Priority } from 'prosekit/core'
|
|
1929
|
+
* import { myExtension } from './my-extension.js'
|
|
1930
|
+
*
|
|
1931
|
+
* const myExtensionWithHighPriority = withPriority(myExtension, Priority.high)
|
|
1932
|
+
* ```
|
|
1933
|
+
*/
|
|
1934
|
+
declare const Priority: {
|
|
1935
|
+
readonly lowest: 0;
|
|
1936
|
+
readonly low: 1;
|
|
1937
|
+
readonly default: 2;
|
|
1938
|
+
readonly high: 3;
|
|
1939
|
+
readonly highest: 4;
|
|
1940
|
+
};
|
|
1941
|
+
/**
|
|
1942
|
+
* ProseKit extension priority.
|
|
1943
|
+
*
|
|
1944
|
+
* There are five priority levels available:
|
|
1945
|
+
*
|
|
1946
|
+
* - `Priority.lowest`
|
|
1947
|
+
* - `Priority.low`
|
|
1948
|
+
* - `Priority.default`
|
|
1949
|
+
* - `Priority.high`
|
|
1950
|
+
* - `Priority.highest`
|
|
1951
|
+
*
|
|
1952
|
+
* @example
|
|
1953
|
+
*
|
|
1954
|
+
* ```ts
|
|
1955
|
+
* import { withPriority, Priority } from 'prosekit/core'
|
|
1956
|
+
* import { myExtension } from './my-extension.js'
|
|
1957
|
+
*
|
|
1958
|
+
* const myExtensionWithHighPriority = withPriority(myExtension, Priority.high)
|
|
1959
|
+
* ```
|
|
1960
|
+
*/
|
|
1961
|
+
type Priority = typeof Priority[keyof typeof Priority];
|
|
1962
|
+
/**
|
|
1963
|
+
* @internal
|
|
1964
|
+
*/
|
|
1965
|
+
type SimplifyDeeper<T> = { [KeyType in keyof T]: Simplify<T[KeyType]>; };
|
|
1966
|
+
/**
|
|
1967
|
+
* @internal
|
|
1968
|
+
*/
|
|
1969
|
+
type SimplifyUnion<T> = Simplify<UnionToIntersection<T extends undefined ? never : T>>;
|
|
1970
|
+
/**
|
|
1971
|
+
* @internal
|
|
1972
|
+
*/
|
|
1973
|
+
interface ExtensionTyping<N extends NodeTyping = never, M extends MarkTyping = never, C extends CommandTyping = never> {
|
|
1974
|
+
Nodes?: N;
|
|
1975
|
+
Marks?: M;
|
|
1976
|
+
Commands?: C;
|
|
1977
|
+
}
|
|
1978
|
+
interface Extension$1<T extends ExtensionTyping<any, any, any> = ExtensionTyping<any, any, any>> {
|
|
1979
|
+
extension: Extension$1 | Extension$1[];
|
|
1980
|
+
priority?: Priority;
|
|
1981
|
+
/**
|
|
1982
|
+
* The schema that this extension represents.
|
|
1983
|
+
*/
|
|
1984
|
+
schema: Schema | null;
|
|
1985
|
+
/** @internal */
|
|
1986
|
+
_type?: T;
|
|
1987
|
+
}
|
|
1988
|
+
/**
|
|
1989
|
+
* @internal
|
|
1990
|
+
*/
|
|
1991
|
+
type ExtractTyping<E extends Extension$1> = E extends Extension$1<ExtensionTyping<infer N, infer M, infer C>> ? ExtensionTyping<PickSubType<N, NodeTyping>, PickSubType<M, MarkTyping>, PickSubType<C, CommandTyping>> : never;
|
|
1992
|
+
/**
|
|
1993
|
+
* An extension that does not define any nodes, marks, or commands.
|
|
1994
|
+
*
|
|
1995
|
+
* @internal
|
|
1996
|
+
*/
|
|
1997
|
+
type PlainExtension = Extension$1<{
|
|
1998
|
+
Nodes: never;
|
|
1999
|
+
Marks: never;
|
|
2000
|
+
Commands: never;
|
|
2001
|
+
}>;
|
|
2002
|
+
type ExtractNodes<E extends Extension$1> = SimplifyDeeper<SimplifyUnion<ExtractTyping<E>['Nodes']>>;
|
|
2003
|
+
type ExtractMarks<E extends Extension$1> = SimplifyDeeper<SimplifyUnion<ExtractTyping<E>['Marks']>>;
|
|
2004
|
+
/**
|
|
2005
|
+
* @internal
|
|
2006
|
+
*/
|
|
2007
|
+
type ExtractCommands<E extends Extension$1> = SimplifyUnion<ExtractTyping<E>['Commands']>;
|
|
2008
|
+
/**
|
|
2009
|
+
* @internal
|
|
2010
|
+
*/
|
|
2011
|
+
type Union<E extends readonly Extension$1[]> = Extension$1<{
|
|
2012
|
+
Nodes: ExtractNodes<E[number]>;
|
|
2013
|
+
Marks: ExtractMarks<E[number]>;
|
|
2014
|
+
Commands: ExtractCommands<E[number]>;
|
|
2015
|
+
}>;
|
|
2016
|
+
interface AddMarkOptions {
|
|
2017
|
+
/**
|
|
2018
|
+
* The type of the mark to add.
|
|
2019
|
+
*/
|
|
2020
|
+
type: string | MarkType;
|
|
2021
|
+
/**
|
|
2022
|
+
* The attributes of the mark to add.
|
|
2023
|
+
*/
|
|
2024
|
+
attrs?: Attrs | null;
|
|
2025
|
+
/**
|
|
2026
|
+
* The start position of the document. By default it will be the start position of current selection.
|
|
2027
|
+
*/
|
|
2028
|
+
from?: number;
|
|
2029
|
+
/**
|
|
2030
|
+
* The end position of the document. By default it will be the end position of current selection.
|
|
2031
|
+
*/
|
|
2032
|
+
to?: number;
|
|
2033
|
+
}
|
|
2034
|
+
interface InsertDefaultBlockOptions {
|
|
2035
|
+
/**
|
|
2036
|
+
* The position to insert the node at. By default it will insert after the
|
|
2037
|
+
* current selection.
|
|
2038
|
+
*/
|
|
2039
|
+
pos?: number;
|
|
2040
|
+
}
|
|
2041
|
+
interface InsertNodeOptions {
|
|
2042
|
+
/**
|
|
2043
|
+
* The node to insert. Either this or `type` must be provided.
|
|
2044
|
+
*/
|
|
2045
|
+
node?: ProseMirrorNode;
|
|
2046
|
+
/**
|
|
2047
|
+
* The type of the node to insert. Either this or `node` must be provided.
|
|
2048
|
+
*/
|
|
2049
|
+
type?: string | NodeType;
|
|
2050
|
+
/**
|
|
2051
|
+
* When `type` is provided, the attributes of the node to insert.
|
|
2052
|
+
*/
|
|
2053
|
+
attrs?: Attrs;
|
|
2054
|
+
/**
|
|
2055
|
+
* The position to insert the node at. By default it will be the anchor
|
|
2056
|
+
* position of current selection.
|
|
2057
|
+
*/
|
|
2058
|
+
pos?: number;
|
|
2059
|
+
}
|
|
2060
|
+
interface RemoveMarkOptions {
|
|
2061
|
+
/**
|
|
2062
|
+
* The type of the mark to remove.
|
|
2063
|
+
*/
|
|
2064
|
+
type: string | MarkType;
|
|
2065
|
+
/**
|
|
2066
|
+
* If attrs is given, remove precisely the mark with the given attrs. Otherwise, remove all marks of the given type.
|
|
2067
|
+
*/
|
|
2068
|
+
attrs?: Attrs | null;
|
|
2069
|
+
/**
|
|
2070
|
+
* The start position of the document. By default it will be the start position of current selection.
|
|
2071
|
+
*/
|
|
2072
|
+
from?: number;
|
|
2073
|
+
/**
|
|
2074
|
+
* The end position of the document. By default it will be the end position of current selection.
|
|
2075
|
+
*/
|
|
2076
|
+
to?: number;
|
|
2077
|
+
}
|
|
2078
|
+
interface RemoveNodeOptions {
|
|
2079
|
+
/**
|
|
2080
|
+
* The type of the node to remove.
|
|
2081
|
+
*/
|
|
2082
|
+
type: string | NodeType;
|
|
2083
|
+
/**
|
|
2084
|
+
* The document position to start searching for the node. By default, it will
|
|
2085
|
+
* use the anchor position of current selection.
|
|
2086
|
+
*/
|
|
2087
|
+
pos?: number;
|
|
2088
|
+
}
|
|
2089
|
+
interface SetBlockTypeOptions {
|
|
2090
|
+
type: NodeType | string;
|
|
2091
|
+
attrs?: Attrs | null;
|
|
2092
|
+
from?: number;
|
|
2093
|
+
to?: number;
|
|
2094
|
+
}
|
|
2095
|
+
interface SetNodeAttrsBetweenOptions {
|
|
2096
|
+
/**
|
|
2097
|
+
* The type of node to set the attributes of.
|
|
2098
|
+
*/
|
|
2099
|
+
type: string | NodeType | string[] | NodeType[];
|
|
2100
|
+
/**
|
|
2101
|
+
* The attributes to set.
|
|
2102
|
+
*/
|
|
2103
|
+
attrs: Attrs;
|
|
2104
|
+
/**
|
|
2105
|
+
* The position to start searching for nodes. By default, the selection from position will be used.
|
|
2106
|
+
*/
|
|
2107
|
+
from?: number;
|
|
2108
|
+
/**
|
|
2109
|
+
* The position to end searching for nodes. By default, the selection to position will be used.
|
|
2110
|
+
*/
|
|
2111
|
+
to?: number;
|
|
2112
|
+
}
|
|
2113
|
+
interface SetNodeAttrsOptions {
|
|
2114
|
+
/**
|
|
2115
|
+
* The type of node to set the attributes of.
|
|
2116
|
+
*/
|
|
2117
|
+
type: string | NodeType | string[] | NodeType[];
|
|
2118
|
+
/**
|
|
2119
|
+
* The attributes to set.
|
|
2120
|
+
*/
|
|
2121
|
+
attrs: Attrs;
|
|
2122
|
+
/**
|
|
2123
|
+
* The document position of the node to update. If not provided, the command
|
|
2124
|
+
* will find the closest ancestor node that matches the type based on the
|
|
2125
|
+
* anchor position of the selection.
|
|
2126
|
+
*/
|
|
2127
|
+
pos?: number;
|
|
2128
|
+
}
|
|
2129
|
+
interface ToggleWrapOptions {
|
|
2130
|
+
/**
|
|
2131
|
+
* The type of the node to toggle.
|
|
2132
|
+
*/
|
|
2133
|
+
type: string | NodeType;
|
|
2134
|
+
/**
|
|
2135
|
+
* The attributes of the node to toggle.
|
|
2136
|
+
*/
|
|
2137
|
+
attrs?: Attrs | null;
|
|
2138
|
+
}
|
|
2139
|
+
interface UnsetBlockTypeOptions {
|
|
2140
|
+
/**
|
|
2141
|
+
* The start position of the document. By default it will be the start position of current selection.
|
|
2142
|
+
*/
|
|
2143
|
+
from?: number;
|
|
2144
|
+
/**
|
|
2145
|
+
* The end position of the document. By default it will be the end position of current selection.
|
|
2146
|
+
*/
|
|
2147
|
+
to?: number;
|
|
2148
|
+
}
|
|
2149
|
+
/**
|
|
2150
|
+
* Options for {@link unsetMark}.
|
|
2151
|
+
*/
|
|
2152
|
+
interface UnsetMarkOptions {
|
|
2153
|
+
/**
|
|
2154
|
+
* The start position of the document. By default it will be the start position of current selection.
|
|
2155
|
+
*/
|
|
2156
|
+
from?: number;
|
|
2157
|
+
/**
|
|
2158
|
+
* The end position of the document. By default it will be the end position of current selection.
|
|
2159
|
+
*/
|
|
2160
|
+
to?: number;
|
|
2161
|
+
}
|
|
2162
|
+
interface WrapOptions {
|
|
2163
|
+
/**
|
|
2164
|
+
* The node type to wrap the selected textblock with.
|
|
2165
|
+
*/
|
|
2166
|
+
type: NodeType | string;
|
|
2167
|
+
/**
|
|
2168
|
+
* Optional attributes to apply to the node.
|
|
2169
|
+
*/
|
|
2170
|
+
attrs?: Attrs | null;
|
|
2171
|
+
}
|
|
2172
|
+
type InsertTextOptions = {
|
|
2173
|
+
text: string;
|
|
2174
|
+
from?: number;
|
|
2175
|
+
to?: number;
|
|
2176
|
+
};
|
|
2177
|
+
/**
|
|
2178
|
+
* @internal
|
|
2179
|
+
*/
|
|
2180
|
+
type BaseCommandsExtension = Extension$1<{
|
|
2181
|
+
Commands: {
|
|
2182
|
+
insertText: [options: InsertTextOptions];
|
|
2183
|
+
insertNode: [options: InsertNodeOptions];
|
|
2184
|
+
removeNode: [options: RemoveNodeOptions];
|
|
2185
|
+
wrap: [options: WrapOptions];
|
|
2186
|
+
toggleWrap: [options: ToggleWrapOptions];
|
|
2187
|
+
setBlockType: [options: SetBlockTypeOptions];
|
|
2188
|
+
setNodeAttrs: [options: SetNodeAttrsOptions];
|
|
2189
|
+
setNodeAttrsBetween: [options: SetNodeAttrsBetweenOptions];
|
|
2190
|
+
insertDefaultBlock: [options?: InsertDefaultBlockOptions];
|
|
2191
|
+
selectAll: [];
|
|
2192
|
+
selectBlock: [];
|
|
2193
|
+
addMark: [options: AddMarkOptions];
|
|
2194
|
+
removeMark: [options: RemoveMarkOptions];
|
|
2195
|
+
unsetBlockType: [options?: UnsetBlockTypeOptions];
|
|
2196
|
+
unsetMark: [options?: UnsetMarkOptions];
|
|
2197
|
+
};
|
|
2198
|
+
}>;
|
|
2199
|
+
/**
|
|
2200
|
+
* @internal
|
|
2201
|
+
*/
|
|
2202
|
+
type HistoryExtension = Extension$1<{
|
|
2203
|
+
Commands: {
|
|
2204
|
+
undo: [];
|
|
2205
|
+
redo: [];
|
|
2206
|
+
};
|
|
2207
|
+
}>;
|
|
2208
|
+
/**
|
|
2209
|
+
* @internal
|
|
2210
|
+
*/
|
|
2211
|
+
type BoldCommandsExtension = Extension$1<{
|
|
2212
|
+
Commands: {
|
|
2213
|
+
toggleBold: [];
|
|
2214
|
+
};
|
|
2215
|
+
}>;
|
|
2216
|
+
/**
|
|
2217
|
+
* @internal
|
|
2218
|
+
*/
|
|
2219
|
+
type BoldSpecExtension = Extension$1<{
|
|
2220
|
+
Marks: {
|
|
2221
|
+
bold: Attrs;
|
|
2222
|
+
};
|
|
2223
|
+
}>;
|
|
2224
|
+
/**
|
|
2225
|
+
* @internal
|
|
2226
|
+
*/
|
|
2227
|
+
type BoldExtension$1 = Union<[BoldSpecExtension, BoldCommandsExtension]>;
|
|
2228
|
+
/**
|
|
2229
|
+
* @internal
|
|
2230
|
+
*/
|
|
2231
|
+
type ItalicCommandsExtension = Extension$1<{
|
|
2232
|
+
Commands: {
|
|
2233
|
+
toggleItalic: [];
|
|
2234
|
+
};
|
|
2235
|
+
}>;
|
|
2236
|
+
/**
|
|
2237
|
+
* @internal
|
|
2238
|
+
*/
|
|
2239
|
+
type ItalicSpecExtension = Extension$1<{
|
|
2240
|
+
Marks: {
|
|
2241
|
+
italic: Attrs;
|
|
2242
|
+
};
|
|
2243
|
+
}>;
|
|
2244
|
+
/**
|
|
2245
|
+
* @internal
|
|
2246
|
+
*/
|
|
2247
|
+
type ItalicExtension$1 = Union<[ItalicSpecExtension, ItalicCommandsExtension]>;
|
|
2248
|
+
/**
|
|
2249
|
+
* @internal
|
|
2250
|
+
*/
|
|
2251
|
+
type UnderlineSpecExtension = Extension$1<{
|
|
2252
|
+
Marks: {
|
|
2253
|
+
underline: Attrs;
|
|
2254
|
+
};
|
|
2255
|
+
}>;
|
|
2256
|
+
/**
|
|
2257
|
+
* @internal
|
|
2258
|
+
*/
|
|
2259
|
+
type UnderlineCommandsExtension = Extension$1<{
|
|
2260
|
+
Commands: {
|
|
2261
|
+
toggleUnderline: [];
|
|
2262
|
+
};
|
|
2263
|
+
}>;
|
|
2264
|
+
/**
|
|
2265
|
+
* @internal
|
|
2266
|
+
*/
|
|
2267
|
+
type UnderlineExtension$1 = Union<[UnderlineSpecExtension, UnderlineCommandsExtension]>;
|
|
2268
|
+
/**
|
|
2269
|
+
* @internal
|
|
2270
|
+
*/
|
|
2271
|
+
type StrikeSpecExtension = Extension$1<{
|
|
2272
|
+
Marks: {
|
|
2273
|
+
strike: Attrs;
|
|
2274
|
+
};
|
|
2275
|
+
}>;
|
|
2276
|
+
/**
|
|
2277
|
+
* @internal
|
|
2278
|
+
*/
|
|
2279
|
+
type StrikeCommandsExtension = Extension$1<{
|
|
2280
|
+
Commands: {
|
|
2281
|
+
toggleStrike: [];
|
|
2282
|
+
};
|
|
2283
|
+
}>;
|
|
2284
|
+
/**
|
|
2285
|
+
* @internal
|
|
2286
|
+
*/
|
|
2287
|
+
type StrikeExtension$1 = Union<[StrikeSpecExtension, StrikeCommandsExtension]>;
|
|
2288
|
+
/**
|
|
2289
|
+
* @internal
|
|
2290
|
+
*/
|
|
2291
|
+
type CodeCommandsExtension = Extension$1<{
|
|
2292
|
+
Commands: {
|
|
2293
|
+
toggleCode: [];
|
|
2294
|
+
};
|
|
2295
|
+
}>;
|
|
2296
|
+
/**
|
|
2297
|
+
* @internal
|
|
2298
|
+
*/
|
|
2299
|
+
type CodeSpecExtension = Extension$1<{
|
|
2300
|
+
Marks: {
|
|
2301
|
+
code: Attrs;
|
|
2302
|
+
};
|
|
2303
|
+
}>;
|
|
2304
|
+
/**
|
|
2305
|
+
* @internal
|
|
2306
|
+
*/
|
|
2307
|
+
type CodeExtension$1 = Union<[CodeSpecExtension, CodeCommandsExtension]>;
|
|
2308
|
+
interface LinkAttrs {
|
|
2309
|
+
href: string;
|
|
2310
|
+
target?: string | null;
|
|
2311
|
+
rel?: string | null;
|
|
2312
|
+
}
|
|
2313
|
+
/**
|
|
2314
|
+
* @internal
|
|
2315
|
+
*/
|
|
2316
|
+
type LinkSpecExtension = Extension$1<{
|
|
2317
|
+
Marks: {
|
|
2318
|
+
link: LinkAttrs;
|
|
2319
|
+
};
|
|
2320
|
+
}>;
|
|
2321
|
+
/**
|
|
2322
|
+
* @internal
|
|
2323
|
+
*/
|
|
2324
|
+
type LinkCommandsExtension = Extension$1<{
|
|
2325
|
+
Commands: {
|
|
2326
|
+
addLink: [attrs: LinkAttrs];
|
|
2327
|
+
removeLink: [];
|
|
2328
|
+
toggleLink: [attrs: LinkAttrs];
|
|
2329
|
+
expandLink: [];
|
|
2330
|
+
};
|
|
2331
|
+
}>;
|
|
2332
|
+
/**
|
|
2333
|
+
* @internal
|
|
2334
|
+
*/
|
|
2335
|
+
type LinkExtension$1 = Union<[LinkSpecExtension, LinkCommandsExtension]>;
|
|
2336
|
+
/** The `highlight` mark: a run of text marked for attention, rendered `<mark>`. */
|
|
2337
|
+
export declare function defineHighlight(): Extension$1<{
|
|
2338
|
+
Marks: {
|
|
2339
|
+
highlight: Attrs$1;
|
|
2340
|
+
};
|
|
2341
|
+
}>;
|
|
2342
|
+
/**
|
|
2343
|
+
* The `subscript` mark, rendered `<sub>`.
|
|
2344
|
+
*
|
|
2345
|
+
* Excludes {@link defineSuperscript}'s mark: a run of text is one or the
|
|
2346
|
+
* other, never both, and ProseMirror enforces that at the model level rather
|
|
2347
|
+
* than leaving it to the toolbar.
|
|
2348
|
+
*/
|
|
2349
|
+
export declare function defineSubscript(): Extension$1<{
|
|
2350
|
+
Marks: {
|
|
2351
|
+
subscript: Attrs$1;
|
|
2352
|
+
};
|
|
2353
|
+
}>;
|
|
2354
|
+
/** The `superscript` mark, rendered `<sup>`; excludes `subscript` — see {@link defineSubscript}. */
|
|
2355
|
+
export declare function defineSuperscript(): Extension$1<{
|
|
2356
|
+
Marks: {
|
|
2357
|
+
superscript: Attrs$1;
|
|
2358
|
+
};
|
|
2359
|
+
}>;
|
|
2360
|
+
/**
|
|
2361
|
+
* An inline mark binding a run of text to a cited work by id, rendered
|
|
2362
|
+
* `<cite data-work-id>`.
|
|
2363
|
+
*
|
|
2364
|
+
* A mark rather than a node, deliberately: marks carry no content, so a
|
|
2365
|
+
* citation annotates a run of prose and can never swallow structure the way a
|
|
2366
|
+
* footnote node could. `workId` is a caller-owned handle and is emitted as a
|
|
2367
|
+
* data attribute, never as a URL.
|
|
2368
|
+
*
|
|
2369
|
+
* Opt-in: not part of {@link defineStandardMarks}, because adding it changes
|
|
2370
|
+
* what the derived wire schema accepts.
|
|
2371
|
+
*/
|
|
2372
|
+
export declare function defineCitation(): Extension$1<{
|
|
2373
|
+
Marks: {
|
|
2374
|
+
citation: {
|
|
2375
|
+
workId: string;
|
|
2376
|
+
};
|
|
2377
|
+
};
|
|
2378
|
+
}>;
|
|
2379
|
+
/**
|
|
2380
|
+
* The nine marks both presets in `./presets.ts` compose: ProseKit's `bold`,
|
|
2381
|
+
* `italic`, `underline`, `strike`, `code` and `link`, plus this library's
|
|
2382
|
+
* `highlight`, `subscript` and `superscript`.
|
|
2383
|
+
*
|
|
2384
|
+
* `citation` is not in the set — it is opt-in, and an application that wants
|
|
2385
|
+
* it passes `defineCitation()` as an extra to the preset.
|
|
2386
|
+
*/
|
|
2387
|
+
export declare function defineStandardMarks(): Union<readonly [BoldExtension$1, ItalicExtension$1, UnderlineExtension$1, StrikeExtension$1, CodeExtension$1, LinkExtension$1, Extension$1<{
|
|
2388
|
+
Marks: {
|
|
2389
|
+
highlight: Attrs$1;
|
|
2390
|
+
};
|
|
2391
|
+
}>, Extension$1<{
|
|
2392
|
+
Marks: {
|
|
2393
|
+
subscript: Attrs$1;
|
|
2394
|
+
};
|
|
2395
|
+
}>, Extension$1<{
|
|
2396
|
+
Marks: {
|
|
2397
|
+
superscript: Attrs$1;
|
|
2398
|
+
};
|
|
2399
|
+
}>]>;
|
|
2400
|
+
/**
|
|
2401
|
+
* A `doc` top node that accepts inline content only (`content: "inline*"`).
|
|
2402
|
+
*
|
|
2403
|
+
* The shape a single-line rich-text field wants: marks and text, no
|
|
2404
|
+
* paragraphs, no blocks. Each compiled schema owns its own node registry, so
|
|
2405
|
+
* this never conflicts with the stock `defineDoc()` (`content: "block+"`) —
|
|
2406
|
+
* the two simply belong to different extensions.
|
|
2407
|
+
*/
|
|
2408
|
+
export declare function defineInlineDoc(): Extension$1<{
|
|
2409
|
+
Nodes: {
|
|
2410
|
+
doc: Attrs$1;
|
|
2411
|
+
};
|
|
2412
|
+
}>;
|
|
2413
|
+
/**
|
|
2414
|
+
* An inline atom that points at an entity by id and carries the text to
|
|
2415
|
+
* render for it — the `@name` shape.
|
|
2416
|
+
*
|
|
2417
|
+
* `id` is the stable handle a consumer resolves (a notification fan-out, a
|
|
2418
|
+
* profile link); `label` is display text and is untrusted, which is why
|
|
2419
|
+
* `toDOM` emits it as a text child rather than as markup. The node is an
|
|
2420
|
+
* atom, so nothing can be typed inside it and the label only ever changes by
|
|
2421
|
+
* replacing the whole node.
|
|
2422
|
+
*
|
|
2423
|
+
* This is deliberately **not** `prosekit/extensions/mention`: ProseKit's stock
|
|
2424
|
+
* mention carries a different attribute shape, and this one is wire-identical
|
|
2425
|
+
* to documents the source applications have already persisted.
|
|
2426
|
+
*/
|
|
2427
|
+
export declare function defineMention(): Extension$1<{
|
|
2428
|
+
Nodes: {
|
|
2429
|
+
mention: {
|
|
2430
|
+
id: string;
|
|
2431
|
+
label: string;
|
|
2432
|
+
};
|
|
2433
|
+
};
|
|
2434
|
+
}>;
|
|
2435
|
+
/**
|
|
2436
|
+
* The caption half of a figure: inline content only.
|
|
2437
|
+
*
|
|
2438
|
+
* `content: "inline*"` rather than `block+` is what stops a caption nesting a
|
|
2439
|
+
* paragraph, a list, or another figure — a caption is a line of prose, and
|
|
2440
|
+
* the derived wire schema enforces exactly that because it reads this content
|
|
2441
|
+
* expression off the compiled schema.
|
|
2442
|
+
*
|
|
2443
|
+
* The derived wire schema does not, however, require a figure to carry a
|
|
2444
|
+
* caption: see {@link defineFigureNode} for what it does and does not enforce
|
|
2445
|
+
* about the pair.
|
|
2446
|
+
*/
|
|
2447
|
+
export declare function defineFigcaption(): Extension$1<{
|
|
2448
|
+
Nodes: {
|
|
2449
|
+
figcaption: Attrs$1;
|
|
2450
|
+
};
|
|
2451
|
+
}>;
|
|
2452
|
+
/**
|
|
2453
|
+
* A captioned image block: in the editor, exactly one `image` followed by
|
|
2454
|
+
* exactly one `figcaption`.
|
|
2455
|
+
*
|
|
2456
|
+
* The fixed content expression is the point — a figure is a pair, not a
|
|
2457
|
+
* container, so ProseMirror's DOM parser and its editing transactions never
|
|
2458
|
+
* let either half be dropped or duplicated. `defining` keeps the figure as its
|
|
2459
|
+
* own context on paste rather than dissolving into the surrounding block.
|
|
2460
|
+
*
|
|
2461
|
+
* Loading JSON is not checked the same way: ProseMirror's
|
|
2462
|
+
* `schema.nodeFromJSON` validates attributes but not content, and ProseKit's
|
|
2463
|
+
* `defaultContent` goes through it, so a stored captionless figure loads into
|
|
2464
|
+
* an editor unchecked. A consumer that wants the content expression enforced
|
|
2465
|
+
* on a loaded document calls `node.check()`, which ProseKit's
|
|
2466
|
+
* `editor.setContent` already does.
|
|
2467
|
+
*
|
|
2468
|
+
* The derived wire schema is deliberately laxer. Derivation reads the set of
|
|
2469
|
+
* admissible children and the empty-vs-non-empty distinction off the compiled
|
|
2470
|
+
* content expression, not the ordered sequence (see `derive/Content`), so a
|
|
2471
|
+
* stored `figure` decodes when its `content` is any non-empty array of `image`
|
|
2472
|
+
* and `figcaption` nodes: a figure without a figcaption, a figcaption alone,
|
|
2473
|
+
* the halves reordered or one duplicated all decode. An empty figure and any
|
|
2474
|
+
* other child type are still rejected. A consumer that needs the pair enforced
|
|
2475
|
+
* at the wire adds its own check, for example `node.check()` on the node it
|
|
2476
|
+
* builds from the decoded JSON.
|
|
2477
|
+
*
|
|
2478
|
+
* Use {@link defineFigure} unless you are composing the two halves yourself:
|
|
2479
|
+
* this node is unusable without {@link defineFigcaption} in the same
|
|
2480
|
+
* extension, and the stock `image` node besides.
|
|
2481
|
+
*/
|
|
2482
|
+
export declare function defineFigureNode(): Extension$1<{
|
|
2483
|
+
Nodes: {
|
|
2484
|
+
figure: Attrs$1;
|
|
2485
|
+
};
|
|
2486
|
+
}>;
|
|
2487
|
+
/** {@link defineFigureNode} together with its {@link defineFigcaption} child. */
|
|
2488
|
+
export declare function defineFigure(): Union<readonly [Extension$1<{
|
|
2489
|
+
Nodes: {
|
|
2490
|
+
figure: Attrs$1;
|
|
2491
|
+
};
|
|
2492
|
+
}>, Extension$1<{
|
|
2493
|
+
Nodes: {
|
|
2494
|
+
figcaption: Attrs$1;
|
|
2495
|
+
};
|
|
2496
|
+
}>]>;
|
|
2497
|
+
/**
|
|
2498
|
+
* An inline aside that sits alongside the body prose — a reference note the
|
|
2499
|
+
* reader can take or leave, rendered in the margin on wide viewports and as a
|
|
2500
|
+
* footnote-like inline block on narrow ones.
|
|
2501
|
+
*
|
|
2502
|
+
* The note holds **rich inline content** (text plus the surrounding marks),
|
|
2503
|
+
* not a plain-text attribute, so a link or emphasis inside a note round-trips
|
|
2504
|
+
* through the node's own children on every surface: the editor, the HTML
|
|
2505
|
+
* serialiser, the Markdown walk and paste.
|
|
2506
|
+
*
|
|
2507
|
+
* It is `inline: true` but deliberately **not** `atom`: that is what lets the
|
|
2508
|
+
* cursor enter the note and edit its content in place with the same toolbar
|
|
2509
|
+
* that styles body prose, with no nested editor and no node view. An `atom`
|
|
2510
|
+
* inline node cannot hold editable inline children without one. `selectable`
|
|
2511
|
+
* makes the whole note pickable; `defining` keeps its boundary on paste.
|
|
2512
|
+
*
|
|
2513
|
+
* Its content is `(text | hardBreak)*` — the two text-like inline nodes by
|
|
2514
|
+
* name, not the broad `inline` group — so **a note can never nest a note**.
|
|
2515
|
+
* `sidenote` is itself in group `inline`, so `content: "inline*"` would admit
|
|
2516
|
+
* `^[…^[…]…]`, which has no valid inline-footnote rendering in Markdown; the
|
|
2517
|
+
* derived wire schema reads this very expression off the compiled schema and
|
|
2518
|
+
* rejects the nesting for free.
|
|
2519
|
+
*
|
|
2520
|
+
* Placement is a render-time, CSS-only concern: the node is layout-agnostic
|
|
2521
|
+
* and ships no styles.
|
|
2522
|
+
*/
|
|
2523
|
+
export declare function defineSidenote(): Extension$1<{
|
|
2524
|
+
Nodes: {
|
|
2525
|
+
sidenote: Attrs$1;
|
|
2526
|
+
};
|
|
2527
|
+
}>;
|
|
2528
|
+
/**
|
|
2529
|
+
* @internal
|
|
2530
|
+
*/
|
|
2531
|
+
type DocExtension$1 = Extension$1<{
|
|
2532
|
+
Nodes: {
|
|
2533
|
+
doc: Attrs;
|
|
2534
|
+
};
|
|
2535
|
+
}>;
|
|
2536
|
+
/**
|
|
2537
|
+
* @internal
|
|
2538
|
+
*/
|
|
2539
|
+
type TextExtension$1 = Extension$1<{
|
|
2540
|
+
Nodes: {
|
|
2541
|
+
text: Attrs;
|
|
2542
|
+
};
|
|
2543
|
+
}>;
|
|
2544
|
+
/**
|
|
2545
|
+
* @internal
|
|
2546
|
+
*/
|
|
2547
|
+
type ParagraphCommandsExtension = Extension$1<{
|
|
2548
|
+
Commands: {
|
|
2549
|
+
setParagraph: [];
|
|
2550
|
+
};
|
|
2551
|
+
}>;
|
|
2552
|
+
/**
|
|
2553
|
+
* @internal
|
|
2554
|
+
*/
|
|
2555
|
+
type ParagraphSpecExtension = Extension$1<{
|
|
2556
|
+
Nodes: {
|
|
2557
|
+
paragraph: Attrs;
|
|
2558
|
+
};
|
|
2559
|
+
}>;
|
|
2560
|
+
/**
|
|
2561
|
+
* @internal
|
|
2562
|
+
*/
|
|
2563
|
+
type ParagraphExtension$1 = Union<[ParagraphSpecExtension, ParagraphCommandsExtension]>;
|
|
2564
|
+
interface HeadingAttrs {
|
|
2565
|
+
level: number;
|
|
2566
|
+
}
|
|
2567
|
+
/**
|
|
2568
|
+
* @internal
|
|
2569
|
+
*/
|
|
2570
|
+
type HeadingCommandsExtension = Extension$1<{
|
|
2571
|
+
Commands: {
|
|
2572
|
+
setHeading: [attrs?: HeadingAttrs | undefined];
|
|
2573
|
+
insertHeading: [attrs?: HeadingAttrs | undefined];
|
|
2574
|
+
toggleHeading: [attrs?: HeadingAttrs | undefined];
|
|
2575
|
+
};
|
|
2576
|
+
}>;
|
|
2577
|
+
/**
|
|
2578
|
+
* @internal
|
|
2579
|
+
*/
|
|
2580
|
+
type HeadingSpecExtension = Extension$1<{
|
|
2581
|
+
Nodes: {
|
|
2582
|
+
heading: HeadingAttrs;
|
|
2583
|
+
};
|
|
2584
|
+
}>;
|
|
2585
|
+
/**
|
|
2586
|
+
* @internal
|
|
2587
|
+
*/
|
|
2588
|
+
type HeadingExtension$1 = Union<[HeadingSpecExtension, HeadingCommandsExtension]>;
|
|
2589
|
+
declare global {
|
|
2590
|
+
interface Node {}
|
|
2591
|
+
}
|
|
2592
|
+
//#region src/commands/dedent-list.d.ts
|
|
2593
|
+
/**
|
|
2594
|
+
* @public
|
|
2595
|
+
*
|
|
2596
|
+
* @group Commands
|
|
2597
|
+
*/
|
|
2598
|
+
interface DedentListOptions {
|
|
2599
|
+
/**
|
|
2600
|
+
* A optional from position to indent.
|
|
2601
|
+
*
|
|
2602
|
+
* @defaultValue `state.selection.from`
|
|
2603
|
+
*/
|
|
2604
|
+
from?: number;
|
|
2605
|
+
/**
|
|
2606
|
+
* A optional to position to indent.
|
|
2607
|
+
*
|
|
2608
|
+
* @defaultValue `state.selection.to`
|
|
2609
|
+
*/
|
|
2610
|
+
to?: number;
|
|
2611
|
+
/**
|
|
2612
|
+
* When `true`, the command never leaves a list node whose first child is a
|
|
2613
|
+
* list node (a list node with a hidden marker). The blocks after the
|
|
2614
|
+
* dedented block move one level up with it instead of keeping their depth
|
|
2615
|
+
* inside such a node, so a block is never more than one level deeper than
|
|
2616
|
+
* the block before it.
|
|
2617
|
+
*
|
|
2618
|
+
* @defaultValue `false`
|
|
2619
|
+
*/
|
|
2620
|
+
strict?: boolean;
|
|
2621
|
+
}
|
|
2622
|
+
//#endregion
|
|
2623
|
+
//#region src/commands/indent-list.d.ts
|
|
2624
|
+
/**
|
|
2625
|
+
* @public
|
|
2626
|
+
*
|
|
2627
|
+
* @group Commands
|
|
2628
|
+
*/
|
|
2629
|
+
interface IndentListOptions {
|
|
2630
|
+
/**
|
|
2631
|
+
* A optional from position to indent.
|
|
2632
|
+
*
|
|
2633
|
+
* @defaultValue `state.selection.from`
|
|
2634
|
+
*/
|
|
2635
|
+
from?: number;
|
|
2636
|
+
/**
|
|
2637
|
+
* A optional to position to indent.
|
|
2638
|
+
*
|
|
2639
|
+
* @defaultValue `state.selection.to`
|
|
2640
|
+
*/
|
|
2641
|
+
to?: number;
|
|
2642
|
+
/**
|
|
2643
|
+
* When `true`, the command never leaves a list node whose first child is a
|
|
2644
|
+
* list node (a list node with a hidden marker). It returns `false` instead
|
|
2645
|
+
* of indenting a block that has no previous list sibling to move into, so a
|
|
2646
|
+
* block is never more than one level deeper than the block before it.
|
|
2647
|
+
*
|
|
2648
|
+
* @defaultValue `false`
|
|
2649
|
+
*/
|
|
2650
|
+
strict?: boolean;
|
|
2651
|
+
}
|
|
2652
|
+
//#endregion
|
|
2653
|
+
//#region src/commands/split-list.d.ts
|
|
2654
|
+
/**
|
|
2655
|
+
* @public
|
|
2656
|
+
*
|
|
2657
|
+
* @group Commands
|
|
2658
|
+
*/
|
|
2659
|
+
interface SplitListOptions {
|
|
2660
|
+
/**
|
|
2661
|
+
* When `true`, the command never leaves a list node whose first child is a
|
|
2662
|
+
* list node (a list node with a hidden marker). `Enter` in an empty list
|
|
2663
|
+
* node dedents it, so this is the `strict` option of
|
|
2664
|
+
* `createDedentListCommand`.
|
|
2665
|
+
*
|
|
2666
|
+
* @defaultValue `false`
|
|
2667
|
+
*/
|
|
2668
|
+
strict?: boolean;
|
|
2669
|
+
}
|
|
2670
|
+
/**
|
|
2671
|
+
* @public
|
|
2672
|
+
*
|
|
2673
|
+
* @group Schema
|
|
2674
|
+
*/
|
|
2675
|
+
interface ListAttributes {
|
|
2676
|
+
kind?: string;
|
|
2677
|
+
order?: number | null;
|
|
2678
|
+
checked?: boolean;
|
|
2679
|
+
collapsed?: boolean;
|
|
2680
|
+
}
|
|
2681
|
+
//#endregion
|
|
2682
|
+
//#region src/commands/toggle-collapsed.d.ts
|
|
2683
|
+
/**
|
|
2684
|
+
* @public
|
|
2685
|
+
*
|
|
2686
|
+
* @group Commands
|
|
2687
|
+
*/
|
|
2688
|
+
interface ToggleCollapsedOptions {
|
|
2689
|
+
/**
|
|
2690
|
+
* If this value exists, the command will set the `collapsed` attribute to
|
|
2691
|
+
* this value instead of toggle it.
|
|
2692
|
+
*/
|
|
2693
|
+
collapsed?: boolean;
|
|
2694
|
+
/**
|
|
2695
|
+
* An optional function to accept a list node and return whether or not this
|
|
2696
|
+
* node can toggle its `collapsed` attribute.
|
|
2697
|
+
*/
|
|
2698
|
+
isToggleable?: (node: Node) => boolean;
|
|
2699
|
+
}
|
|
2700
|
+
//#endregion
|
|
2701
|
+
//#region src/commands/unwrap-list.d.ts
|
|
2702
|
+
/**
|
|
2703
|
+
* @public
|
|
2704
|
+
*
|
|
2705
|
+
* @group Commands
|
|
2706
|
+
*/
|
|
2707
|
+
interface UnwrapListOptions {
|
|
2708
|
+
/**
|
|
2709
|
+
* If given, only this kind of list will be unwrap.
|
|
2710
|
+
*/
|
|
2711
|
+
kind?: string;
|
|
2712
|
+
}
|
|
2713
|
+
/**
|
|
2714
|
+
* @internal
|
|
2715
|
+
*/
|
|
2716
|
+
type ListCommandsExtension = Extension$1<{
|
|
2717
|
+
Commands: {
|
|
2718
|
+
dedentList: [options?: DedentListOptions];
|
|
2719
|
+
indentList: [options?: IndentListOptions];
|
|
2720
|
+
moveList: [direction: 'up' | 'down'];
|
|
2721
|
+
splitList: [options?: SplitListOptions];
|
|
2722
|
+
toggleCollapsed: [options?: ToggleCollapsedOptions];
|
|
2723
|
+
unwrapList: [options?: UnwrapListOptions];
|
|
2724
|
+
toggleList: [attrs?: ListAttributes];
|
|
2725
|
+
wrapInList: [attrs?: ListAttributes];
|
|
2726
|
+
insertList: [attrs?: ListAttributes];
|
|
2727
|
+
};
|
|
2728
|
+
}>;
|
|
2729
|
+
/**
|
|
2730
|
+
* The attributes of a list node.
|
|
2731
|
+
*/
|
|
2732
|
+
interface ListAttrs {
|
|
2733
|
+
/**
|
|
2734
|
+
* The kind of list node.
|
|
2735
|
+
*/
|
|
2736
|
+
kind?: 'bullet' | 'ordered' | 'task' | 'toggle';
|
|
2737
|
+
/**
|
|
2738
|
+
* The optional order of the list node.
|
|
2739
|
+
*/
|
|
2740
|
+
order?: number | null;
|
|
2741
|
+
/**
|
|
2742
|
+
* Whether the list node is checked if its `kind` is `"task"`.
|
|
2743
|
+
*/
|
|
2744
|
+
checked?: boolean;
|
|
2745
|
+
/**
|
|
2746
|
+
* Whether the list node is collapsed if its `kind` is `"toggle"`.
|
|
2747
|
+
*/
|
|
2748
|
+
collapsed?: boolean;
|
|
2749
|
+
}
|
|
2750
|
+
/**
|
|
2751
|
+
* @internal
|
|
2752
|
+
*/
|
|
2753
|
+
type ListSpecExtension = Extension$1<{
|
|
2754
|
+
Nodes: {
|
|
2755
|
+
list: ListAttrs;
|
|
2756
|
+
};
|
|
2757
|
+
}>;
|
|
2758
|
+
/**
|
|
2759
|
+
* @internal
|
|
2760
|
+
*/
|
|
2761
|
+
type ListExtension$1 = Union<[ListSpecExtension, ListCommandsExtension]>;
|
|
2762
|
+
type BlockquoteCommandsExtension = Extension$1<{
|
|
2763
|
+
Commands: {
|
|
2764
|
+
setBlockquote: [];
|
|
2765
|
+
insertBlockquote: [];
|
|
2766
|
+
toggleBlockquote: [];
|
|
2767
|
+
};
|
|
2768
|
+
}>;
|
|
2769
|
+
type BlockquoteSpecExtension = Extension$1<{
|
|
2770
|
+
Nodes: {
|
|
2771
|
+
blockquote: Attrs;
|
|
2772
|
+
};
|
|
2773
|
+
}>;
|
|
2774
|
+
/**
|
|
2775
|
+
* @internal
|
|
2776
|
+
*/
|
|
2777
|
+
type BlockquoteExtension$1 = Union<[BlockquoteSpecExtension, BlockquoteCommandsExtension]>;
|
|
2778
|
+
/**
|
|
2779
|
+
* An interface representing the upload progress.
|
|
2780
|
+
*/
|
|
2781
|
+
interface UploadProgress {
|
|
2782
|
+
loaded: number;
|
|
2783
|
+
total: number;
|
|
2784
|
+
}
|
|
2785
|
+
interface UploaderOptions {
|
|
2786
|
+
/**
|
|
2787
|
+
* The file to be uploaded.
|
|
2788
|
+
*/
|
|
2789
|
+
file: File;
|
|
2790
|
+
/**
|
|
2791
|
+
* A callback function that should be called with the upload progress updates.
|
|
2792
|
+
*/
|
|
2793
|
+
onProgress: (progress: UploadProgress) => void;
|
|
2794
|
+
}
|
|
2795
|
+
/**
|
|
2796
|
+
* The implementation of the actual upload function. You need to implement this
|
|
2797
|
+
* function to upload files to your desired destination.
|
|
2798
|
+
*/
|
|
2799
|
+
type Uploader<Result> = (options: UploaderOptions) => Promise<Result>;
|
|
2800
|
+
/**
|
|
2801
|
+
* A class that represents a upload task.
|
|
2802
|
+
*/
|
|
2803
|
+
declare class UploadTask<Result> {
|
|
2804
|
+
/**
|
|
2805
|
+
* An [object URL](https://developer.mozilla.org/en-US/docs/Web/API/URL/createObjectURL)
|
|
2806
|
+
* representing the file to be uploaded. This URL will be revoked once the
|
|
2807
|
+
* upload is complete successfully.
|
|
2808
|
+
*/
|
|
2809
|
+
readonly objectURL: string;
|
|
2810
|
+
/**
|
|
2811
|
+
* A boolean indicating whether the upload is complete (either successfully or with an error).
|
|
2812
|
+
*/
|
|
2813
|
+
protected done: boolean;
|
|
2814
|
+
/**
|
|
2815
|
+
* If the upload is complete successfully, this will be the result of the upload.
|
|
2816
|
+
*/
|
|
2817
|
+
protected result: Result | undefined;
|
|
2818
|
+
/**
|
|
2819
|
+
* If the upload is complete with an error, this will be the error that occurred.
|
|
2820
|
+
*/
|
|
2821
|
+
protected error: Error | undefined;
|
|
2822
|
+
/**
|
|
2823
|
+
* A promise that fulfills once the upload is complete, or rejects if an error occurs.
|
|
2824
|
+
*/
|
|
2825
|
+
readonly finished: Promise<Result>;
|
|
2826
|
+
private subscribers;
|
|
2827
|
+
/**
|
|
2828
|
+
* Creates a new upload task. You can find the upload task by its object URL
|
|
2829
|
+
* later using `UploadTask.get()`.
|
|
2830
|
+
*
|
|
2831
|
+
* @param options - The options for the upload task.
|
|
2832
|
+
*/
|
|
2833
|
+
constructor({ file, uploader }: {
|
|
2834
|
+
file: File;
|
|
2835
|
+
uploader: Uploader<Result>;
|
|
2836
|
+
});
|
|
2837
|
+
/**
|
|
2838
|
+
* Subscribes to progress updates. Returns a function to unsubscribe.
|
|
2839
|
+
*/
|
|
2840
|
+
subscribeProgress(callback: (progress: UploadProgress) => void): VoidFunction;
|
|
2841
|
+
/**
|
|
2842
|
+
* Finds an upload task from the global store by its object URL.
|
|
2843
|
+
*/
|
|
2844
|
+
static get<Result = unknown>(objectURL: string): UploadTask<Result> | undefined;
|
|
2845
|
+
/**
|
|
2846
|
+
* Deletes an upload task from the global store by its object URL.
|
|
2847
|
+
*/
|
|
2848
|
+
static delete(objectURL: string): void;
|
|
2849
|
+
}
|
|
2850
|
+
/**
|
|
2851
|
+
* Options for {@link uploadImage}.
|
|
2852
|
+
*/
|
|
2853
|
+
interface UploadImageOptions {
|
|
2854
|
+
/**
|
|
2855
|
+
* The uploader used to upload the file. It should return a promise that
|
|
2856
|
+
* resolves to the URL of the uploaded image.
|
|
2857
|
+
*/
|
|
2858
|
+
uploader: Uploader<string>;
|
|
2859
|
+
/**
|
|
2860
|
+
* The file that will be uploaded.
|
|
2861
|
+
*/
|
|
2862
|
+
file: File;
|
|
2863
|
+
/**
|
|
2864
|
+
* The position where the image should be inserted. If not provided, the
|
|
2865
|
+
* image is inserted at the current selection.
|
|
2866
|
+
*/
|
|
2867
|
+
pos?: number;
|
|
2868
|
+
/**
|
|
2869
|
+
* If the image should replace the existing image at the given position. This
|
|
2870
|
+
* is only used if `pos` is provided.
|
|
2871
|
+
*
|
|
2872
|
+
* @default false
|
|
2873
|
+
*/
|
|
2874
|
+
replace?: boolean;
|
|
2875
|
+
/**
|
|
2876
|
+
* A handler to be called when an error occurs during the upload.
|
|
2877
|
+
*/
|
|
2878
|
+
onError?: ImageUploadErrorHandler;
|
|
2879
|
+
}
|
|
2880
|
+
/**
|
|
2881
|
+
* Options for the {@link ImageUploadErrorHandler} callback.
|
|
2882
|
+
*/
|
|
2883
|
+
interface ImageUploadErrorHandlerOptions {
|
|
2884
|
+
/**
|
|
2885
|
+
* The file that was uploaded.
|
|
2886
|
+
*/
|
|
2887
|
+
file: File;
|
|
2888
|
+
/**
|
|
2889
|
+
* The error that occurred during the upload.
|
|
2890
|
+
*/
|
|
2891
|
+
error: unknown;
|
|
2892
|
+
/**
|
|
2893
|
+
* The upload task that was used to upload the file.
|
|
2894
|
+
*/
|
|
2895
|
+
uploadTask: UploadTask<string>;
|
|
2896
|
+
}
|
|
2897
|
+
/**
|
|
2898
|
+
* A handler to be called when an error occurs during the upload.
|
|
2899
|
+
*/
|
|
2900
|
+
type ImageUploadErrorHandler = (options: ImageUploadErrorHandlerOptions) => void;
|
|
2901
|
+
interface ImageAttrs {
|
|
2902
|
+
src?: string | null;
|
|
2903
|
+
width?: number | null;
|
|
2904
|
+
height?: number | null;
|
|
2905
|
+
}
|
|
2906
|
+
/**
|
|
2907
|
+
* @internal
|
|
2908
|
+
*/
|
|
2909
|
+
type ImageSpecExtension = Extension$1<{
|
|
2910
|
+
Nodes: {
|
|
2911
|
+
image: ImageAttrs;
|
|
2912
|
+
};
|
|
2913
|
+
}>;
|
|
2914
|
+
/**
|
|
2915
|
+
* @internal
|
|
2916
|
+
*/
|
|
2917
|
+
type ImageCommandsExtension = Extension$1<{
|
|
2918
|
+
Commands: {
|
|
2919
|
+
insertImage: [attrs?: ImageAttrs];
|
|
2920
|
+
uploadImage: [options: UploadImageOptions];
|
|
2921
|
+
};
|
|
2922
|
+
}>;
|
|
2923
|
+
/**
|
|
2924
|
+
* @internal
|
|
2925
|
+
*/
|
|
2926
|
+
type ImageExtension$1 = Union<[ImageSpecExtension, ImageCommandsExtension]>;
|
|
2927
|
+
type HorizontalRuleCommandsExtension = Extension$1<{
|
|
2928
|
+
Commands: {
|
|
2929
|
+
insertHorizontalRule: [];
|
|
2930
|
+
};
|
|
2931
|
+
}>;
|
|
2932
|
+
type HorizontalRuleSpecExtension = Extension$1<{
|
|
2933
|
+
Nodes: {
|
|
2934
|
+
horizontalRule: Attrs;
|
|
2935
|
+
};
|
|
2936
|
+
}>;
|
|
2937
|
+
type HorizontalRuleExtension$1 = Union<[HorizontalRuleSpecExtension, HorizontalRuleCommandsExtension]>;
|
|
2938
|
+
/**
|
|
2939
|
+
* @internal
|
|
2940
|
+
*/
|
|
2941
|
+
type HardBreakCommandsExtension = Extension$1<{
|
|
2942
|
+
Commands: {
|
|
2943
|
+
insertHardBreak: [];
|
|
2944
|
+
};
|
|
2945
|
+
}>;
|
|
2946
|
+
/**
|
|
2947
|
+
* @internal
|
|
2948
|
+
*/
|
|
2949
|
+
type HardBreakSpecExtension = Extension$1<{
|
|
2950
|
+
Nodes: {
|
|
2951
|
+
hardBreak: Attrs;
|
|
2952
|
+
};
|
|
2953
|
+
}>;
|
|
2954
|
+
/**
|
|
2955
|
+
* @internal
|
|
2956
|
+
*/
|
|
2957
|
+
type HardBreakExtension$1 = Union<[HardBreakSpecExtension, HardBreakCommandsExtension]>;
|
|
2958
|
+
/**
|
|
2959
|
+
* Options for moveTableRow
|
|
2960
|
+
*
|
|
2961
|
+
* @public
|
|
2962
|
+
*/
|
|
2963
|
+
interface MoveTableRowOptions {
|
|
2964
|
+
/**
|
|
2965
|
+
* The source row index to move from.
|
|
2966
|
+
*/
|
|
2967
|
+
from: number;
|
|
2968
|
+
/**
|
|
2969
|
+
* The destination row index to move to.
|
|
2970
|
+
*/
|
|
2971
|
+
to: number;
|
|
2972
|
+
/**
|
|
2973
|
+
* Whether to select the moved row after the operation.
|
|
2974
|
+
*
|
|
2975
|
+
* @default true
|
|
2976
|
+
*/
|
|
2977
|
+
select?: boolean;
|
|
2978
|
+
/**
|
|
2979
|
+
* Optional position to resolve table from. If not provided, uses the current selection.
|
|
2980
|
+
*/
|
|
2981
|
+
pos?: number;
|
|
2982
|
+
}
|
|
2983
|
+
/**
|
|
2984
|
+
* Options for moveTableColumn
|
|
2985
|
+
*
|
|
2986
|
+
* @public
|
|
2987
|
+
*/
|
|
2988
|
+
interface MoveTableColumnOptions {
|
|
2989
|
+
/**
|
|
2990
|
+
* The source column index to move from.
|
|
2991
|
+
*/
|
|
2992
|
+
from: number;
|
|
2993
|
+
/**
|
|
2994
|
+
* The destination column index to move to.
|
|
2995
|
+
*/
|
|
2996
|
+
to: number;
|
|
2997
|
+
/**
|
|
2998
|
+
* Whether to select the moved column after the operation.
|
|
2999
|
+
*
|
|
3000
|
+
* @default true
|
|
3001
|
+
*/
|
|
3002
|
+
select?: boolean;
|
|
3003
|
+
/**
|
|
3004
|
+
* Optional position to resolve table from. If not provided, uses the current selection.
|
|
3005
|
+
*/
|
|
3006
|
+
pos?: number;
|
|
3007
|
+
}
|
|
3008
|
+
interface InsertTableOptions {
|
|
3009
|
+
/**
|
|
3010
|
+
* The number of rows in the table.
|
|
3011
|
+
*/
|
|
3012
|
+
row: number;
|
|
3013
|
+
/**
|
|
3014
|
+
* The number of columns in the table.
|
|
3015
|
+
*/
|
|
3016
|
+
col: number;
|
|
3017
|
+
/**
|
|
3018
|
+
* Whether the table has a header row.
|
|
3019
|
+
*
|
|
3020
|
+
* @default false
|
|
3021
|
+
*/
|
|
3022
|
+
header?: boolean;
|
|
3023
|
+
}
|
|
3024
|
+
interface SelectTableCellOptions {
|
|
3025
|
+
/**
|
|
3026
|
+
* A hit position of the table cell to select from. By default, the selection
|
|
3027
|
+
* anchor will be used.
|
|
3028
|
+
*/
|
|
3029
|
+
pos?: number;
|
|
3030
|
+
}
|
|
3031
|
+
interface SelectTableColumnOptions {
|
|
3032
|
+
/**
|
|
3033
|
+
* A hit position of the table cell to select from. By default, the selection
|
|
3034
|
+
* anchor will be used.
|
|
3035
|
+
*/
|
|
3036
|
+
anchor?: number;
|
|
3037
|
+
/**
|
|
3038
|
+
* A hit position of the table cell to select to. By default, the selection
|
|
3039
|
+
* head will be used.
|
|
3040
|
+
*/
|
|
3041
|
+
head?: number;
|
|
3042
|
+
}
|
|
3043
|
+
interface SelectTableRowOptions {
|
|
3044
|
+
/**
|
|
3045
|
+
* A hit position of the table cell to select from. By default, the selection
|
|
3046
|
+
* anchor will be used.
|
|
3047
|
+
*/
|
|
3048
|
+
anchor?: number;
|
|
3049
|
+
/**
|
|
3050
|
+
* A hit position of the table cell to select to. By default, the selection
|
|
3051
|
+
* head will be used.
|
|
3052
|
+
*/
|
|
3053
|
+
head?: number;
|
|
3054
|
+
}
|
|
3055
|
+
interface SelectTableOptions {
|
|
3056
|
+
/**
|
|
3057
|
+
* A hit position of the table to select from. By default, the selection
|
|
3058
|
+
* anchor will be used.
|
|
3059
|
+
*/
|
|
3060
|
+
pos?: number;
|
|
3061
|
+
}
|
|
3062
|
+
/**
|
|
3063
|
+
* @internal
|
|
3064
|
+
*/
|
|
3065
|
+
type TableCommandsExtension = Extension$1<{
|
|
3066
|
+
Commands: {
|
|
3067
|
+
insertTable: [options: InsertTableOptions];
|
|
3068
|
+
exitTable: [];
|
|
3069
|
+
selectTable: [options?: SelectTableOptions];
|
|
3070
|
+
selectTableCell: [options?: SelectTableCellOptions];
|
|
3071
|
+
selectTableColumn: [options?: SelectTableColumnOptions];
|
|
3072
|
+
selectTableRow: [options?: SelectTableRowOptions];
|
|
3073
|
+
addTableColumnBefore: [];
|
|
3074
|
+
addTableColumnAfter: [];
|
|
3075
|
+
addTableRowAbove: [];
|
|
3076
|
+
addTableRowBelow: [];
|
|
3077
|
+
deleteTable: [];
|
|
3078
|
+
deleteTableColumn: [];
|
|
3079
|
+
deleteTableRow: [];
|
|
3080
|
+
deleteCellSelection: [];
|
|
3081
|
+
mergeTableCells: [];
|
|
3082
|
+
splitTableCell: [];
|
|
3083
|
+
moveTableRow: [options: MoveTableRowOptions];
|
|
3084
|
+
moveTableColumn: [options: MoveTableColumnOptions];
|
|
3085
|
+
};
|
|
3086
|
+
}>;
|
|
3087
|
+
interface CellAttrs {
|
|
3088
|
+
colspan?: number;
|
|
3089
|
+
rowspan?: number;
|
|
3090
|
+
colwidth?: number[] | null;
|
|
3091
|
+
}
|
|
3092
|
+
/**
|
|
3093
|
+
* @internal
|
|
3094
|
+
*/
|
|
3095
|
+
type TableSpecExtension = Extension$1<{
|
|
3096
|
+
Nodes: {
|
|
3097
|
+
table: Attrs;
|
|
3098
|
+
};
|
|
3099
|
+
}>;
|
|
3100
|
+
/**
|
|
3101
|
+
* @internal
|
|
3102
|
+
*/
|
|
3103
|
+
type TableRowSpecExtension = Extension$1<{
|
|
3104
|
+
Nodes: {
|
|
3105
|
+
tableRow: Attrs;
|
|
3106
|
+
};
|
|
3107
|
+
}>;
|
|
3108
|
+
/**
|
|
3109
|
+
* @internal
|
|
3110
|
+
*/
|
|
3111
|
+
type TableCellSpecExtension = Extension$1<{
|
|
3112
|
+
Nodes: {
|
|
3113
|
+
tableCell: CellAttrs;
|
|
3114
|
+
};
|
|
3115
|
+
}>;
|
|
3116
|
+
/**
|
|
3117
|
+
* @internal
|
|
3118
|
+
*/
|
|
3119
|
+
type TableHeaderCellSpecExtension = Extension$1<{
|
|
3120
|
+
Nodes: {
|
|
3121
|
+
tableHeaderCell: CellAttrs;
|
|
3122
|
+
};
|
|
3123
|
+
}>;
|
|
3124
|
+
/**
|
|
3125
|
+
* @internal
|
|
3126
|
+
*/
|
|
3127
|
+
type TableExtension$1 = Union<[TableSpecExtension, TableRowSpecExtension, TableCellSpecExtension, TableHeaderCellSpecExtension, TableCommandsExtension]>;
|
|
3128
|
+
/**
|
|
3129
|
+
* The attributes for the `codeBlock` node.
|
|
3130
|
+
*/
|
|
3131
|
+
interface CodeBlockAttrs {
|
|
3132
|
+
language: string;
|
|
3133
|
+
}
|
|
3134
|
+
/**
|
|
3135
|
+
* @internal
|
|
3136
|
+
*/
|
|
3137
|
+
type CodeBlockCommandsExtension = Extension$1<{
|
|
3138
|
+
Commands: {
|
|
3139
|
+
setCodeBlock: [attrs?: CodeBlockAttrs];
|
|
3140
|
+
insertCodeBlock: [attrs?: CodeBlockAttrs];
|
|
3141
|
+
toggleCodeBlock: [attrs?: CodeBlockAttrs];
|
|
3142
|
+
setCodeBlockAttrs: [attrs: CodeBlockAttrs];
|
|
3143
|
+
};
|
|
3144
|
+
}>;
|
|
3145
|
+
/**
|
|
3146
|
+
* @internal
|
|
3147
|
+
*/
|
|
3148
|
+
type CodeBlockSpecExtension = Extension$1<{
|
|
3149
|
+
Nodes: {
|
|
3150
|
+
codeBlock: CodeBlockAttrs;
|
|
3151
|
+
};
|
|
3152
|
+
}>;
|
|
3153
|
+
/**
|
|
3154
|
+
* @internal
|
|
3155
|
+
*/
|
|
3156
|
+
type CodeBlockExtension$1 = Union<[CodeBlockSpecExtension, CodeBlockCommandsExtension]>;
|
|
3157
|
+
/**
|
|
3158
|
+
* The interaction tail every editor wants and no document shape depends on:
|
|
3159
|
+
* the base keymap, the base commands, undo/redo history, the gap cursor, the
|
|
3160
|
+
* virtual selection and mod-click prevention.
|
|
3161
|
+
*
|
|
3162
|
+
* None of these registers a node or a mark, so including them changes nothing
|
|
3163
|
+
* about what a derived wire schema accepts — which is why compiling a schema
|
|
3164
|
+
* for validation alone can include them without consequence, and why they are
|
|
3165
|
+
* a separate export rather than baked into the node lists.
|
|
3166
|
+
*/
|
|
3167
|
+
export declare function defineEditorBehaviour(): Union<readonly [PlainExtension, BaseCommandsExtension, HistoryExtension, PlainExtension, PlainExtension, PlainExtension]>;
|
|
3168
|
+
/**
|
|
3169
|
+
* The block-document grammar: a `block+` top node, text, ProseKit's stock
|
|
3170
|
+
* block set (paragraph, heading, list, blockquote, image, horizontal rule,
|
|
3171
|
+
* hard break, table, code block), {@link defineStandardMarks} and
|
|
3172
|
+
* {@link defineEditorBehaviour}, plus whatever `extra` extensions the caller
|
|
3173
|
+
* composes in.
|
|
3174
|
+
*/
|
|
3175
|
+
export declare function defineBlockDocumentExtension(...extra: ReadonlyArray<Extension>): Union<readonly [DocExtension$1, TextExtension$1, ParagraphExtension$1, HeadingExtension$1, ListExtension$1, BlockquoteExtension$1, ImageExtension$1, HorizontalRuleExtension$1, HardBreakExtension$1, TableExtension$1, CodeBlockExtension$1, Union<readonly [BoldExtension$1, ItalicExtension$1, UnderlineExtension$1, StrikeExtension$1, CodeExtension$1, LinkExtension$1, Extension<{
|
|
3176
|
+
Marks: {
|
|
3177
|
+
highlight: Attrs$1;
|
|
3178
|
+
};
|
|
3179
|
+
}>, Extension<{
|
|
3180
|
+
Marks: {
|
|
3181
|
+
subscript: Attrs$1;
|
|
3182
|
+
};
|
|
3183
|
+
}>, Extension<{
|
|
3184
|
+
Marks: {
|
|
3185
|
+
superscript: Attrs$1;
|
|
3186
|
+
};
|
|
3187
|
+
}>]>, Union<readonly [PlainExtension, BaseCommandsExtension, HistoryExtension, PlainExtension, PlainExtension, PlainExtension]>, ...Extension<ExtensionTyping<any, any, any>>[]]>;
|
|
3188
|
+
/** The extension {@link defineBlockDocumentExtension} returns with no extras. */
|
|
3189
|
+
type BlockDocumentExtension = ReturnType<typeof defineBlockDocumentExtension>;
|
|
3190
|
+
/**
|
|
3191
|
+
* The inline-document grammar: an `inline*` top node
|
|
3192
|
+
* ({@link defineInlineDoc}), text, {@link defineStandardMarks} and
|
|
3193
|
+
* {@link defineEditorBehaviour}, plus whatever `extra` extensions the caller
|
|
3194
|
+
* composes in.
|
|
3195
|
+
*
|
|
3196
|
+
* No block node is registered at all, so a paragraph is not merely
|
|
3197
|
+
* unreachable from the toolbar — it fails to decode.
|
|
3198
|
+
*/
|
|
3199
|
+
export declare function defineInlineDocumentExtension(...extra: ReadonlyArray<Extension>): Union<readonly [Extension<{
|
|
3200
|
+
Nodes: {
|
|
3201
|
+
doc: Attrs$1;
|
|
3202
|
+
};
|
|
3203
|
+
}>, TextExtension$1, Union<readonly [BoldExtension$1, ItalicExtension$1, UnderlineExtension$1, StrikeExtension$1, CodeExtension$1, LinkExtension$1, Extension<{
|
|
3204
|
+
Marks: {
|
|
3205
|
+
highlight: Attrs$1;
|
|
3206
|
+
};
|
|
3207
|
+
}>, Extension<{
|
|
3208
|
+
Marks: {
|
|
3209
|
+
subscript: Attrs$1;
|
|
3210
|
+
};
|
|
3211
|
+
}>, Extension<{
|
|
3212
|
+
Marks: {
|
|
3213
|
+
superscript: Attrs$1;
|
|
3214
|
+
};
|
|
3215
|
+
}>]>, Union<readonly [PlainExtension, BaseCommandsExtension, HistoryExtension, PlainExtension, PlainExtension, PlainExtension]>, ...Extension<ExtensionTyping<any, any, any>>[]]>;
|
|
3216
|
+
/** The extension {@link defineInlineDocumentExtension} returns with no extras. */
|
|
3217
|
+
type InlineDocumentExtension = ReturnType<typeof defineInlineDocumentExtension>;
|
|
3218
|
+
export { type AttributeOverrides, type BlockDocumentExtension, type BlockquoteExtension, type BoldExtension, type CodeBlockExtension, type CodeExtension, type DocExtension, type DocumentSchema, type DocumentSchemaOptions, type HardBreakExtension, type HeadingExtension, type HorizontalRuleExtension, type HtmlRenderer, type HtmlRendererOptions, type ImageExtension, type InlineDocumentExtension, type ItalicExtension, type LinkExtension, type ListExtension, type ParagraphExtension, type StrikeExtension, type TableExtension, type TextExtension, type UnderlineExtension, defineBlockquote, defineBold, defineCode, defineCodeBlock, defineDoc, defineHardBreak, defineHeading, defineHorizontalRule, defineImage, defineItalic, defineLink, defineList, defineParagraph, defineStrike, defineTable, defineText, defineUnderline };
|