@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.
Files changed (176) hide show
  1. package/LICENSE +48 -0
  2. package/README.md +117 -1
  3. package/dist/_virtual/_rolldown/runtime.js +12 -0
  4. package/dist/commands/commands.d.ts +323 -0
  5. package/dist/commands/commands.js +722 -0
  6. package/dist/commands/internal.js +43 -0
  7. package/dist/commands/keymaps.d.ts +46 -0
  8. package/dist/commands/keymaps.js +64 -0
  9. package/dist/commands.d.ts +3 -0
  10. package/dist/commands.js +3 -0
  11. package/dist/compat/commands.d.ts +250 -0
  12. package/dist/compat/commands.js +275 -0
  13. package/dist/compat/internal/core.d.ts +20 -0
  14. package/dist/compat/internal/core.js +148 -0
  15. package/dist/compat/internal/props.js +82 -0
  16. package/dist/compat/keymap.d.ts +21 -0
  17. package/dist/compat/keymap.js +38 -0
  18. package/dist/compat/model.d.ts +893 -0
  19. package/dist/compat/model.js +1212 -0
  20. package/dist/compat/orderedmap.d.ts +74 -0
  21. package/dist/compat/orderedmap.js +124 -0
  22. package/dist/compat/schema-basic.d.ts +38 -0
  23. package/dist/compat/schema-basic.js +238 -0
  24. package/dist/compat/schema-list.d.ts +81 -0
  25. package/dist/compat/schema-list.js +156 -0
  26. package/dist/compat/state.d.ts +415 -0
  27. package/dist/compat/state.js +689 -0
  28. package/dist/compat/test-builder.d.ts +98 -0
  29. package/dist/compat/test-builder.js +197 -0
  30. package/dist/compat/transform.d.ts +458 -0
  31. package/dist/compat/transform.js +803 -0
  32. package/dist/compat/view.d.ts +411 -0
  33. package/dist/compat/view.js +409 -0
  34. package/dist/dropcursor.d.ts +46 -0
  35. package/dist/dropcursor.js +176 -0
  36. package/dist/extensions/defaults.d.ts +716 -0
  37. package/dist/extensions/defaults.js +209 -0
  38. package/dist/extensions/editor.d.ts +246 -0
  39. package/dist/extensions/editor.js +271 -0
  40. package/dist/extensions/extension.d.ts +375 -0
  41. package/dist/extensions/extension.js +233 -0
  42. package/dist/extensions.d.ts +4 -0
  43. package/dist/extensions.js +4 -0
  44. package/dist/gapcursor.d.ts +66 -0
  45. package/dist/gapcursor.js +273 -0
  46. package/dist/history.d.ts +178 -0
  47. package/dist/history.js +412 -0
  48. package/dist/html.d.ts +158 -0
  49. package/dist/html.js +164 -0
  50. package/dist/inputrules.d.ts +271 -0
  51. package/dist/inputrules.js +321 -0
  52. package/dist/internal/attempt.js +15 -0
  53. package/dist/internal/json.js +29 -0
  54. package/dist/keymap/keymap.d.ts +130 -0
  55. package/dist/keymap/keymap.js +159 -0
  56. package/dist/keymap.d.ts +2 -0
  57. package/dist/keymap.js +1 -0
  58. package/dist/markdown/errors.d.ts +23 -0
  59. package/dist/markdown/errors.js +26 -0
  60. package/dist/markdown/from_markdown.d.ts +185 -0
  61. package/dist/markdown/from_markdown.js +266 -0
  62. package/dist/markdown/schema.d.ts +522 -0
  63. package/dist/markdown/schema.js +292 -0
  64. package/dist/markdown/to_markdown.d.ts +251 -0
  65. package/dist/markdown/to_markdown.js +413 -0
  66. package/dist/markdown.d.ts +5 -0
  67. package/dist/markdown.js +5 -0
  68. package/dist/model/attrsCodec.js +48 -0
  69. package/dist/model/comparedeep.js +17 -0
  70. package/dist/model/content.d.ts +232 -0
  71. package/dist/model/content.js +630 -0
  72. package/dist/model/diff.js +66 -0
  73. package/dist/model/dom.d.ts +3 -0
  74. package/dist/model/errors.d.ts +90 -0
  75. package/dist/model/errors.js +76 -0
  76. package/dist/model/fragment.d.ts +131 -0
  77. package/dist/model/fragment.js +262 -0
  78. package/dist/model/from_dom.d.ts +299 -0
  79. package/dist/model/from_dom.js +618 -0
  80. package/dist/model/json.d.ts +37 -0
  81. package/dist/model/json.js +126 -0
  82. package/dist/model/mark.d.ts +73 -0
  83. package/dist/model/mark.js +121 -0
  84. package/dist/model/node.d.ts +267 -0
  85. package/dist/model/node.js +434 -0
  86. package/dist/model/replace.d.ts +78 -0
  87. package/dist/model/replace.js +207 -0
  88. package/dist/model/resolvedpos.d.ts +196 -0
  89. package/dist/model/resolvedpos.js +305 -0
  90. package/dist/model/schema.d.ts +740 -0
  91. package/dist/model/schema.js +451 -0
  92. package/dist/model/to_dom.d.ts +169 -0
  93. package/dist/model/to_dom.js +238 -0
  94. package/dist/model.d.ts +12 -0
  95. package/dist/model.js +12 -0
  96. package/dist/placeholder.d.ts +53 -0
  97. package/dist/placeholder.js +79 -0
  98. package/dist/reactive/observer.d.ts +54 -0
  99. package/dist/reactive/observer.js +61 -0
  100. package/dist/reactive/selectors.d.ts +22 -0
  101. package/dist/reactive/selectors.js +61 -0
  102. package/dist/reactive/stateref.d.ts +72 -0
  103. package/dist/reactive/stateref.js +71 -0
  104. package/dist/reactive/streams.d.ts +83 -0
  105. package/dist/reactive/streams.js +85 -0
  106. package/dist/reactive.d.ts +16 -0
  107. package/dist/reactive.js +26 -0
  108. package/dist/schema-basic.d.ts +448 -0
  109. package/dist/schema-basic.js +269 -0
  110. package/dist/schema-list/commands.d.ts +66 -0
  111. package/dist/schema-list/commands.js +203 -0
  112. package/dist/schema-list.d.ts +92 -0
  113. package/dist/schema-list.js +100 -0
  114. package/dist/state/errors.d.ts +39 -0
  115. package/dist/state/errors.js +32 -0
  116. package/dist/state/plugin.d.ts +232 -0
  117. package/dist/state/plugin.js +82 -0
  118. package/dist/state/selection.d.ts +297 -0
  119. package/dist/state/selection.js +486 -0
  120. package/dist/state/state.d.ts +212 -0
  121. package/dist/state/state.js +489 -0
  122. package/dist/state/transaction.d.ts +145 -0
  123. package/dist/state/transaction.js +195 -0
  124. package/dist/state.d.ts +6 -0
  125. package/dist/state.js +6 -0
  126. package/dist/test-builder.d.ts +3582 -0
  127. package/dist/test-builder.js +239 -0
  128. package/dist/transform/attr_step.d.ts +60 -0
  129. package/dist/transform/attr_step.js +105 -0
  130. package/dist/transform/errors.d.ts +50 -0
  131. package/dist/transform/errors.js +35 -0
  132. package/dist/transform/map.d.ts +182 -0
  133. package/dist/transform/map.js +280 -0
  134. package/dist/transform/mark.js +98 -0
  135. package/dist/transform/mark_set_step.js +69 -0
  136. package/dist/transform/mark_step.d.ts +113 -0
  137. package/dist/transform/mark_step.js +225 -0
  138. package/dist/transform/replace.d.ts +18 -0
  139. package/dist/transform/replace.js +381 -0
  140. package/dist/transform/replace_step.d.ts +109 -0
  141. package/dist/transform/replace_step.js +175 -0
  142. package/dist/transform/step.d.ts +157 -0
  143. package/dist/transform/step.js +168 -0
  144. package/dist/transform/structure.d.ts +89 -0
  145. package/dist/transform/structure.js +350 -0
  146. package/dist/transform/transform.d.ts +248 -0
  147. package/dist/transform/transform.js +373 -0
  148. package/dist/transform.d.ts +10 -0
  149. package/dist/transform.js +10 -0
  150. package/dist/view/browser.js +39 -0
  151. package/dist/view/capturekeys.js +282 -0
  152. package/dist/view/clipboard.d.ts +8 -0
  153. package/dist/view/clipboard.js +245 -0
  154. package/dist/view/decoration.d.ts +339 -0
  155. package/dist/view/decoration.js +566 -0
  156. package/dist/view/dom.d.ts +18 -0
  157. package/dist/view/dom.js +140 -0
  158. package/dist/view/domchange.js +295 -0
  159. package/dist/view/domcoords.d.ts +22 -0
  160. package/dist/view/domcoords.js +448 -0
  161. package/dist/view/domobserver.d.ts +47 -0
  162. package/dist/view/domobserver.js +328 -0
  163. package/dist/view/errors.d.ts +18 -0
  164. package/dist/view/errors.js +21 -0
  165. package/dist/view/input.d.ts +58 -0
  166. package/dist/view/input.js +704 -0
  167. package/dist/view/selection.js +198 -0
  168. package/dist/view/view.d.ts +699 -0
  169. package/dist/view/view.js +623 -0
  170. package/dist/view/viewdesc.d.ts +236 -0
  171. package/dist/view/viewdesc.js +1205 -0
  172. package/dist/view-css.d.ts +43 -0
  173. package/dist/view-css.js +124 -0
  174. package/dist/view.d.ts +6 -0
  175. package/dist/view.js +4 -0
  176. 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 };