@thomasfosterau/effect-richtext 0.0.0 → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +48 -0
- package/README.md +117 -1
- package/dist/_virtual/_rolldown/runtime.js +12 -0
- package/dist/commands/commands.d.ts +323 -0
- package/dist/commands/commands.js +722 -0
- package/dist/commands/internal.js +43 -0
- package/dist/commands/keymaps.d.ts +46 -0
- package/dist/commands/keymaps.js +64 -0
- package/dist/commands.d.ts +3 -0
- package/dist/commands.js +3 -0
- package/dist/compat/commands.d.ts +250 -0
- package/dist/compat/commands.js +275 -0
- package/dist/compat/internal/core.d.ts +20 -0
- package/dist/compat/internal/core.js +148 -0
- package/dist/compat/internal/props.js +82 -0
- package/dist/compat/keymap.d.ts +21 -0
- package/dist/compat/keymap.js +38 -0
- package/dist/compat/model.d.ts +893 -0
- package/dist/compat/model.js +1212 -0
- package/dist/compat/orderedmap.d.ts +74 -0
- package/dist/compat/orderedmap.js +124 -0
- package/dist/compat/schema-basic.d.ts +38 -0
- package/dist/compat/schema-basic.js +238 -0
- package/dist/compat/schema-list.d.ts +81 -0
- package/dist/compat/schema-list.js +156 -0
- package/dist/compat/state.d.ts +415 -0
- package/dist/compat/state.js +689 -0
- package/dist/compat/test-builder.d.ts +98 -0
- package/dist/compat/test-builder.js +197 -0
- package/dist/compat/transform.d.ts +458 -0
- package/dist/compat/transform.js +803 -0
- package/dist/compat/view.d.ts +411 -0
- package/dist/compat/view.js +409 -0
- package/dist/dropcursor.d.ts +46 -0
- package/dist/dropcursor.js +176 -0
- package/dist/extensions/defaults.d.ts +716 -0
- package/dist/extensions/defaults.js +209 -0
- package/dist/extensions/editor.d.ts +246 -0
- package/dist/extensions/editor.js +271 -0
- package/dist/extensions/extension.d.ts +375 -0
- package/dist/extensions/extension.js +233 -0
- package/dist/extensions.d.ts +4 -0
- package/dist/extensions.js +4 -0
- package/dist/gapcursor.d.ts +66 -0
- package/dist/gapcursor.js +273 -0
- package/dist/history.d.ts +178 -0
- package/dist/history.js +412 -0
- package/dist/html.d.ts +158 -0
- package/dist/html.js +164 -0
- package/dist/inputrules.d.ts +271 -0
- package/dist/inputrules.js +321 -0
- package/dist/internal/attempt.js +15 -0
- package/dist/internal/json.js +29 -0
- package/dist/keymap/keymap.d.ts +130 -0
- package/dist/keymap/keymap.js +159 -0
- package/dist/keymap.d.ts +2 -0
- package/dist/keymap.js +1 -0
- package/dist/markdown/errors.d.ts +23 -0
- package/dist/markdown/errors.js +26 -0
- package/dist/markdown/from_markdown.d.ts +185 -0
- package/dist/markdown/from_markdown.js +266 -0
- package/dist/markdown/schema.d.ts +522 -0
- package/dist/markdown/schema.js +292 -0
- package/dist/markdown/to_markdown.d.ts +251 -0
- package/dist/markdown/to_markdown.js +413 -0
- package/dist/markdown.d.ts +5 -0
- package/dist/markdown.js +5 -0
- package/dist/model/attrsCodec.js +48 -0
- package/dist/model/comparedeep.js +17 -0
- package/dist/model/content.d.ts +232 -0
- package/dist/model/content.js +630 -0
- package/dist/model/diff.js +66 -0
- package/dist/model/dom.d.ts +3 -0
- package/dist/model/errors.d.ts +90 -0
- package/dist/model/errors.js +76 -0
- package/dist/model/fragment.d.ts +131 -0
- package/dist/model/fragment.js +262 -0
- package/dist/model/from_dom.d.ts +299 -0
- package/dist/model/from_dom.js +618 -0
- package/dist/model/json.d.ts +37 -0
- package/dist/model/json.js +126 -0
- package/dist/model/mark.d.ts +73 -0
- package/dist/model/mark.js +121 -0
- package/dist/model/node.d.ts +267 -0
- package/dist/model/node.js +434 -0
- package/dist/model/replace.d.ts +78 -0
- package/dist/model/replace.js +207 -0
- package/dist/model/resolvedpos.d.ts +196 -0
- package/dist/model/resolvedpos.js +305 -0
- package/dist/model/schema.d.ts +740 -0
- package/dist/model/schema.js +451 -0
- package/dist/model/to_dom.d.ts +169 -0
- package/dist/model/to_dom.js +238 -0
- package/dist/model.d.ts +12 -0
- package/dist/model.js +12 -0
- package/dist/placeholder.d.ts +53 -0
- package/dist/placeholder.js +79 -0
- package/dist/reactive/observer.d.ts +54 -0
- package/dist/reactive/observer.js +61 -0
- package/dist/reactive/selectors.d.ts +22 -0
- package/dist/reactive/selectors.js +61 -0
- package/dist/reactive/stateref.d.ts +72 -0
- package/dist/reactive/stateref.js +71 -0
- package/dist/reactive/streams.d.ts +83 -0
- package/dist/reactive/streams.js +85 -0
- package/dist/reactive.d.ts +16 -0
- package/dist/reactive.js +26 -0
- package/dist/schema-basic.d.ts +448 -0
- package/dist/schema-basic.js +269 -0
- package/dist/schema-list/commands.d.ts +66 -0
- package/dist/schema-list/commands.js +203 -0
- package/dist/schema-list.d.ts +92 -0
- package/dist/schema-list.js +100 -0
- package/dist/state/errors.d.ts +39 -0
- package/dist/state/errors.js +32 -0
- package/dist/state/plugin.d.ts +232 -0
- package/dist/state/plugin.js +82 -0
- package/dist/state/selection.d.ts +297 -0
- package/dist/state/selection.js +486 -0
- package/dist/state/state.d.ts +212 -0
- package/dist/state/state.js +489 -0
- package/dist/state/transaction.d.ts +145 -0
- package/dist/state/transaction.js +195 -0
- package/dist/state.d.ts +6 -0
- package/dist/state.js +6 -0
- package/dist/test-builder.d.ts +3582 -0
- package/dist/test-builder.js +239 -0
- package/dist/transform/attr_step.d.ts +60 -0
- package/dist/transform/attr_step.js +105 -0
- package/dist/transform/errors.d.ts +50 -0
- package/dist/transform/errors.js +35 -0
- package/dist/transform/map.d.ts +182 -0
- package/dist/transform/map.js +280 -0
- package/dist/transform/mark.js +98 -0
- package/dist/transform/mark_set_step.js +69 -0
- package/dist/transform/mark_step.d.ts +113 -0
- package/dist/transform/mark_step.js +225 -0
- package/dist/transform/replace.d.ts +18 -0
- package/dist/transform/replace.js +381 -0
- package/dist/transform/replace_step.d.ts +109 -0
- package/dist/transform/replace_step.js +175 -0
- package/dist/transform/step.d.ts +157 -0
- package/dist/transform/step.js +168 -0
- package/dist/transform/structure.d.ts +89 -0
- package/dist/transform/structure.js +350 -0
- package/dist/transform/transform.d.ts +248 -0
- package/dist/transform/transform.js +373 -0
- package/dist/transform.d.ts +10 -0
- package/dist/transform.js +10 -0
- package/dist/view/browser.js +39 -0
- package/dist/view/capturekeys.js +282 -0
- package/dist/view/clipboard.d.ts +8 -0
- package/dist/view/clipboard.js +245 -0
- package/dist/view/decoration.d.ts +339 -0
- package/dist/view/decoration.js +566 -0
- package/dist/view/dom.d.ts +18 -0
- package/dist/view/dom.js +140 -0
- package/dist/view/domchange.js +295 -0
- package/dist/view/domcoords.d.ts +22 -0
- package/dist/view/domcoords.js +448 -0
- package/dist/view/domobserver.d.ts +47 -0
- package/dist/view/domobserver.js +328 -0
- package/dist/view/errors.d.ts +18 -0
- package/dist/view/errors.js +21 -0
- package/dist/view/input.d.ts +58 -0
- package/dist/view/input.js +704 -0
- package/dist/view/selection.js +198 -0
- package/dist/view/view.d.ts +699 -0
- package/dist/view/view.js +623 -0
- package/dist/view/viewdesc.d.ts +236 -0
- package/dist/view/viewdesc.js +1205 -0
- package/dist/view-css.d.ts +43 -0
- package/dist/view-css.js +124 -0
- package/dist/view.d.ts +6 -0
- package/dist/view.js +4 -0
- package/package.json +200 -4
|
@@ -0,0 +1,232 @@
|
|
|
1
|
+
import { Fragment } from "./fragment.js";
|
|
2
|
+
import { NodeType } from "./schema.js";
|
|
3
|
+
import * as Option from "effect/Option";
|
|
4
|
+
declare namespace content_d_exports {
|
|
5
|
+
export { ContentExpr, ContentInput, ContentMatch, ExprAST, MatchEdge, Refs, SpecRefs, choice, format, isContentExpr, oneOrMore, optional, parse, ref, repeat, seq, zeroOrMore };
|
|
6
|
+
}
|
|
7
|
+
declare const TypeId = "~effect-richtext/model/ContentExpr";
|
|
8
|
+
/**
|
|
9
|
+
* The unresolved syntax tree of a content expression.
|
|
10
|
+
*
|
|
11
|
+
* @since 0.1.0
|
|
12
|
+
* @category models
|
|
13
|
+
*/
|
|
14
|
+
export type ExprAST = {
|
|
15
|
+
readonly _tag: "Choice";
|
|
16
|
+
readonly exprs: ReadonlyArray<ExprAST>;
|
|
17
|
+
} | {
|
|
18
|
+
readonly _tag: "Seq";
|
|
19
|
+
readonly exprs: ReadonlyArray<ExprAST>;
|
|
20
|
+
} | {
|
|
21
|
+
readonly _tag: "Plus";
|
|
22
|
+
readonly expr: ExprAST;
|
|
23
|
+
} | {
|
|
24
|
+
readonly _tag: "Star";
|
|
25
|
+
readonly expr: ExprAST;
|
|
26
|
+
} | {
|
|
27
|
+
readonly _tag: "Opt";
|
|
28
|
+
readonly expr: ExprAST;
|
|
29
|
+
} | {
|
|
30
|
+
readonly _tag: "Range";
|
|
31
|
+
readonly min: number;
|
|
32
|
+
readonly max: number;
|
|
33
|
+
readonly expr: ExprAST;
|
|
34
|
+
} | {
|
|
35
|
+
readonly _tag: "Name";
|
|
36
|
+
readonly name: string;
|
|
37
|
+
};
|
|
38
|
+
/**
|
|
39
|
+
* A content expression referring to the node or group names `Refs`.
|
|
40
|
+
*
|
|
41
|
+
* @since 0.1.0
|
|
42
|
+
* @category models
|
|
43
|
+
*/
|
|
44
|
+
export interface ContentExpr<out Refs extends string = string> {
|
|
45
|
+
readonly [TypeId]: {
|
|
46
|
+
readonly _Refs: (_: never) => Refs;
|
|
47
|
+
};
|
|
48
|
+
readonly ast: ExprAST;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Anything that can be used where a content expression is expected: an
|
|
52
|
+
* expression or a bare node/group name.
|
|
53
|
+
*
|
|
54
|
+
* @since 0.1.0
|
|
55
|
+
* @category models
|
|
56
|
+
*/
|
|
57
|
+
export type ContentInput<Refs extends string = string> = ContentExpr<Refs> | Refs;
|
|
58
|
+
/**
|
|
59
|
+
* Extract the referenced names from a content input.
|
|
60
|
+
*
|
|
61
|
+
* @since 0.1.0
|
|
62
|
+
* @category type-level
|
|
63
|
+
*/
|
|
64
|
+
export type Refs<C> = C extends ContentExpr<infer R> ? R : C extends string ? C : never;
|
|
65
|
+
type SyntaxChar = " " | "+" | "*" | "?" | "|" | "(" | ")" | "{" | "}" | ",";
|
|
66
|
+
/**
|
|
67
|
+
* The names referenced by a spec's `content` field. Plain strings are
|
|
68
|
+
* ProseMirror content-expression syntax: a bare name is tracked
|
|
69
|
+
* precisely, anything more complex (`"paragraph+"`) is untyped
|
|
70
|
+
* (`string`).
|
|
71
|
+
*
|
|
72
|
+
* @since 0.1.0
|
|
73
|
+
* @category type-level
|
|
74
|
+
*/
|
|
75
|
+
export type SpecRefs<C> = C extends ContentExpr<infer R> ? R : C extends `${string}${SyntaxChar}${string}` ? string : C extends string ? C : never;
|
|
76
|
+
/**
|
|
77
|
+
* @since 0.1.0
|
|
78
|
+
* @category guards
|
|
79
|
+
*/
|
|
80
|
+
export declare const isContentExpr: (u: unknown) => u is ContentExpr<string>;
|
|
81
|
+
/**
|
|
82
|
+
* Reference a single node type or group by name.
|
|
83
|
+
*
|
|
84
|
+
* @since 0.1.0
|
|
85
|
+
* @category constructors
|
|
86
|
+
*/
|
|
87
|
+
export declare const ref: <const Name extends string>(name: Name) => ContentExpr<Name>;
|
|
88
|
+
/**
|
|
89
|
+
* A sequence of expressions that must appear in order.
|
|
90
|
+
*
|
|
91
|
+
* @since 0.1.0
|
|
92
|
+
* @category combinators
|
|
93
|
+
*/
|
|
94
|
+
export declare const seq: <const Items extends ReadonlyArray<ContentInput<string>>>(...items: Items) => ContentExpr<Refs<Items[number]>>;
|
|
95
|
+
/**
|
|
96
|
+
* Any one of the given expressions.
|
|
97
|
+
*
|
|
98
|
+
* @since 0.1.0
|
|
99
|
+
* @category combinators
|
|
100
|
+
*/
|
|
101
|
+
export declare const choice: <const Items extends ReadonlyArray<ContentInput<string>>>(...items: Items) => ContentExpr<Refs<Items[number]>>;
|
|
102
|
+
/**
|
|
103
|
+
* Zero or more repetitions (`expr*`).
|
|
104
|
+
*
|
|
105
|
+
* @since 0.1.0
|
|
106
|
+
* @category combinators
|
|
107
|
+
*/
|
|
108
|
+
export declare const zeroOrMore: <const C extends ContentInput<string>>(item: C) => ContentExpr<Refs<C>>;
|
|
109
|
+
/**
|
|
110
|
+
* One or more repetitions (`expr+`).
|
|
111
|
+
*
|
|
112
|
+
* @since 0.1.0
|
|
113
|
+
* @category combinators
|
|
114
|
+
*/
|
|
115
|
+
export declare const oneOrMore: <const C extends ContentInput<string>>(item: C) => ContentExpr<Refs<C>>;
|
|
116
|
+
/**
|
|
117
|
+
* Zero or one occurrence (`expr?`).
|
|
118
|
+
*
|
|
119
|
+
* @since 0.1.0
|
|
120
|
+
* @category combinators
|
|
121
|
+
*/
|
|
122
|
+
export declare const optional: <const C extends ContentInput<string>>(item: C) => ContentExpr<Refs<C>>;
|
|
123
|
+
/**
|
|
124
|
+
* Between `min` and `max` repetitions (`expr{min,max}`). When `max` is
|
|
125
|
+
* omitted it defaults to `min`; pass `Infinity` for no upper bound.
|
|
126
|
+
*
|
|
127
|
+
* @since 0.1.0
|
|
128
|
+
* @category combinators
|
|
129
|
+
*/
|
|
130
|
+
export declare const repeat: <const C extends ContentInput<string>>(item: C, min: number, max?: number) => ContentExpr<Refs<C>>;
|
|
131
|
+
/**
|
|
132
|
+
* Parse a ProseMirror-style content expression string, such as
|
|
133
|
+
* `"paragraph block*"`. The referenced names are not tracked at the
|
|
134
|
+
* type level.
|
|
135
|
+
*
|
|
136
|
+
* Syntax errors throw a `SchemaDefinitionError` immediately; unknown names
|
|
137
|
+
* and other semantic errors are reported when the schema is compiled.
|
|
138
|
+
*
|
|
139
|
+
* @since 0.1.0
|
|
140
|
+
* @category constructors
|
|
141
|
+
*/
|
|
142
|
+
export declare const parse: (source: string) => ContentExpr<string>;
|
|
143
|
+
/**
|
|
144
|
+
* Render a content expression in ProseMirror's string syntax.
|
|
145
|
+
*
|
|
146
|
+
* @since 0.1.0
|
|
147
|
+
* @category utils
|
|
148
|
+
*/
|
|
149
|
+
export declare const format: (expr: ContentInput<string>) => string;
|
|
150
|
+
/**
|
|
151
|
+
* An edge in the content automaton.
|
|
152
|
+
*
|
|
153
|
+
* @since 0.1.0
|
|
154
|
+
* @category models
|
|
155
|
+
*/
|
|
156
|
+
export interface MatchEdge {
|
|
157
|
+
readonly type: NodeType;
|
|
158
|
+
readonly next: ContentMatch;
|
|
159
|
+
}
|
|
160
|
+
/**
|
|
161
|
+
* Instances of this class represent a match state of a node type's
|
|
162
|
+
* content expression, and can be used to find out whether further
|
|
163
|
+
* content matches here, and whether a given position is a valid end of
|
|
164
|
+
* the node.
|
|
165
|
+
*
|
|
166
|
+
* @since 0.1.0
|
|
167
|
+
* @category models
|
|
168
|
+
*/
|
|
169
|
+
export declare class ContentMatch {
|
|
170
|
+
/** True when this match state represents a valid end of the node. */
|
|
171
|
+
readonly validEnd: boolean;
|
|
172
|
+
/** @internal */
|
|
173
|
+
readonly next: Array<MatchEdge>;
|
|
174
|
+
/** @internal */
|
|
175
|
+
readonly wrapCache: Array<NodeType | ReadonlyArray<NodeType> | null>;
|
|
176
|
+
/** @internal */
|
|
177
|
+
constructor(
|
|
178
|
+
/** True when this match state represents a valid end of the node. */
|
|
179
|
+
validEnd: boolean);
|
|
180
|
+
/** @internal */
|
|
181
|
+
static compile(content: ContentInput<string> | undefined, nodeTypes: Readonly<Partial<Record<string, NodeType>>>, typeName: string): ContentMatch;
|
|
182
|
+
/**
|
|
183
|
+
* Match a node type, returning a match after that node if
|
|
184
|
+
* successful.
|
|
185
|
+
*/
|
|
186
|
+
matchType(type: NodeType): Option.Option<ContentMatch>;
|
|
187
|
+
/** @internal */
|
|
188
|
+
matchTypeOrNull(type: NodeType): ContentMatch | null;
|
|
189
|
+
/** Try to match a fragment. Returns the resulting match when successful. */
|
|
190
|
+
matchFragment(frag: Fragment, start?: number, end?: number): Option.Option<ContentMatch>;
|
|
191
|
+
/** @internal */
|
|
192
|
+
matchFragmentOrNull(frag: Fragment, start?: number, end?: number): ContentMatch | null;
|
|
193
|
+
/** @internal */
|
|
194
|
+
get inlineContent(): boolean;
|
|
195
|
+
/** Get the first matching node type at this match position that can be generated. */
|
|
196
|
+
get defaultType(): Option.Option<NodeType>;
|
|
197
|
+
/** @internal */
|
|
198
|
+
get defaultTypeOrNull(): NodeType | null;
|
|
199
|
+
/** @internal */
|
|
200
|
+
compatible(other: ContentMatch): boolean;
|
|
201
|
+
/**
|
|
202
|
+
* Try to match the given fragment, and if that fails, see if it can
|
|
203
|
+
* be made to match by inserting nodes in front of it. When
|
|
204
|
+
* successful, return a fragment of inserted nodes (which may be
|
|
205
|
+
* empty if nothing had to be inserted). When `toEnd` is true, only
|
|
206
|
+
* return a fragment if the resulting match goes to the end of the
|
|
207
|
+
* content expression.
|
|
208
|
+
*/
|
|
209
|
+
fillBefore(after: Fragment, toEnd?: boolean, startIndex?: number): Option.Option<Fragment>;
|
|
210
|
+
/** @internal */
|
|
211
|
+
fillBeforeOrNull(after: Fragment, toEnd?: boolean, startIndex?: number): Fragment | null;
|
|
212
|
+
/**
|
|
213
|
+
* Find a set of wrapping node types that would allow a node of the
|
|
214
|
+
* given type to appear at this position. The result may be empty
|
|
215
|
+
* (when it fits directly) and will be `None` when no such wrapping
|
|
216
|
+
* exists.
|
|
217
|
+
*/
|
|
218
|
+
findWrapping(target: NodeType): Option.Option<ReadonlyArray<NodeType>>;
|
|
219
|
+
/** @internal */
|
|
220
|
+
findWrappingOrNull(target: NodeType): ReadonlyArray<NodeType> | null;
|
|
221
|
+
/** @internal */
|
|
222
|
+
computeWrapping(target: NodeType): ReadonlyArray<NodeType> | null;
|
|
223
|
+
/** The number of outgoing edges this node has in the content automaton. */
|
|
224
|
+
get edgeCount(): number;
|
|
225
|
+
/** Get the _n_th outgoing edge from this node in the content automaton. */
|
|
226
|
+
edge(n: number): Option.Option<MatchEdge>;
|
|
227
|
+
/** @internal */
|
|
228
|
+
toString(): string;
|
|
229
|
+
/** The match state of nodes that allow no content. */
|
|
230
|
+
static readonly empty: ContentMatch;
|
|
231
|
+
}
|
|
232
|
+
export { content_d_exports };
|