@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,292 @@
1
+ import { choice, oneOrMore, zeroOrMore } from "../model/content.js";
2
+ import { DocSchema, markSpec, nodeSpec } from "../model/schema.js";
3
+ import * as S from "effect/Schema";
4
+ // src/markdown/schema.ts
5
+ /**
6
+ * The document schema used by CommonMark.
7
+ *
8
+ * @since 0.1.0
9
+ */
10
+ /**
11
+ * The node specs of the Markdown schema.
12
+ *
13
+ * @since 0.1.0
14
+ * @category specs
15
+ */
16
+ const nodes = {
17
+ doc: nodeSpec({ content: oneOrMore("block") }),
18
+ paragraph: nodeSpec({
19
+ content: zeroOrMore("inline"),
20
+ group: "block",
21
+ parseDOM: [{ tag: "p" }],
22
+ toDOM() {
23
+ return ["p", 0];
24
+ }
25
+ }),
26
+ blockquote: nodeSpec({
27
+ content: oneOrMore("block"),
28
+ group: "block",
29
+ parseDOM: [{ tag: "blockquote" }],
30
+ toDOM() {
31
+ return ["blockquote", 0];
32
+ }
33
+ }),
34
+ horizontal_rule: nodeSpec({
35
+ group: "block",
36
+ parseDOM: [{ tag: "hr" }],
37
+ toDOM() {
38
+ return ["div", ["hr"]];
39
+ }
40
+ }),
41
+ heading: nodeSpec({
42
+ attrs: { level: {
43
+ schema: S.Number,
44
+ default: 1
45
+ } },
46
+ content: zeroOrMore(choice("text", "image")),
47
+ group: "block",
48
+ defining: true,
49
+ parseDOM: [
50
+ {
51
+ tag: "h1",
52
+ attrs: { level: 1 }
53
+ },
54
+ {
55
+ tag: "h2",
56
+ attrs: { level: 2 }
57
+ },
58
+ {
59
+ tag: "h3",
60
+ attrs: { level: 3 }
61
+ },
62
+ {
63
+ tag: "h4",
64
+ attrs: { level: 4 }
65
+ },
66
+ {
67
+ tag: "h5",
68
+ attrs: { level: 5 }
69
+ },
70
+ {
71
+ tag: "h6",
72
+ attrs: { level: 6 }
73
+ }
74
+ ],
75
+ toDOM(node) {
76
+ return ["h" + node.attrs.level, 0];
77
+ }
78
+ }),
79
+ code_block: nodeSpec({
80
+ content: zeroOrMore("text"),
81
+ group: "block",
82
+ code: true,
83
+ defining: true,
84
+ marks: "",
85
+ attrs: { params: {
86
+ schema: S.String,
87
+ default: ""
88
+ } },
89
+ parseDOM: [{
90
+ tag: "pre",
91
+ preserveWhitespace: "full",
92
+ getAttrs: (node) => ({ params: node.getAttribute("data-params") || "" })
93
+ }],
94
+ toDOM(node) {
95
+ return [
96
+ "pre",
97
+ node.attrs.params ? { "data-params": node.attrs.params } : {},
98
+ ["code", 0]
99
+ ];
100
+ }
101
+ }),
102
+ ordered_list: nodeSpec({
103
+ content: oneOrMore("list_item"),
104
+ group: "block",
105
+ attrs: {
106
+ order: {
107
+ schema: S.Number,
108
+ default: 1
109
+ },
110
+ tight: {
111
+ schema: S.Boolean,
112
+ default: false
113
+ }
114
+ },
115
+ parseDOM: [{
116
+ tag: "ol",
117
+ getAttrs(dom) {
118
+ return {
119
+ order: dom.hasAttribute("start") ? +dom.getAttribute("start") : 1,
120
+ tight: dom.hasAttribute("data-tight")
121
+ };
122
+ }
123
+ }],
124
+ toDOM(node) {
125
+ return [
126
+ "ol",
127
+ {
128
+ start: node.attrs.order == 1 ? null : node.attrs.order,
129
+ "data-tight": node.attrs.tight ? "true" : null
130
+ },
131
+ 0
132
+ ];
133
+ }
134
+ }),
135
+ bullet_list: nodeSpec({
136
+ content: oneOrMore("list_item"),
137
+ group: "block",
138
+ attrs: { tight: {
139
+ schema: S.Boolean,
140
+ default: false
141
+ } },
142
+ parseDOM: [{
143
+ tag: "ul",
144
+ getAttrs: (dom) => ({ tight: dom.hasAttribute("data-tight") })
145
+ }],
146
+ toDOM(node) {
147
+ return [
148
+ "ul",
149
+ { "data-tight": node.attrs.tight ? "true" : null },
150
+ 0
151
+ ];
152
+ }
153
+ }),
154
+ list_item: nodeSpec({
155
+ content: oneOrMore("block"),
156
+ defining: true,
157
+ parseDOM: [{ tag: "li" }],
158
+ toDOM() {
159
+ return ["li", 0];
160
+ }
161
+ }),
162
+ text: nodeSpec({ group: "inline" }),
163
+ image: nodeSpec({
164
+ inline: true,
165
+ attrs: {
166
+ src: S.String,
167
+ alt: {
168
+ schema: S.NullOr(S.String),
169
+ default: null
170
+ },
171
+ title: {
172
+ schema: S.NullOr(S.String),
173
+ default: null
174
+ }
175
+ },
176
+ group: "inline",
177
+ draggable: true,
178
+ parseDOM: [{
179
+ tag: "img[src]",
180
+ getAttrs(dom) {
181
+ return {
182
+ src: dom.getAttribute("src"),
183
+ title: dom.getAttribute("title"),
184
+ alt: dom.getAttribute("alt")
185
+ };
186
+ }
187
+ }],
188
+ toDOM(node) {
189
+ const { alt, src, title } = node.attrs;
190
+ return ["img", {
191
+ src,
192
+ alt,
193
+ title
194
+ }];
195
+ }
196
+ }),
197
+ hard_break: nodeSpec({
198
+ inline: true,
199
+ group: "inline",
200
+ selectable: false,
201
+ parseDOM: [{ tag: "br" }],
202
+ toDOM() {
203
+ return ["br"];
204
+ }
205
+ })
206
+ };
207
+ /**
208
+ * The mark specs of the Markdown schema.
209
+ *
210
+ * @since 0.1.0
211
+ * @category specs
212
+ */
213
+ const marks = {
214
+ em: markSpec({
215
+ parseDOM: [
216
+ { tag: "i" },
217
+ { tag: "em" },
218
+ { style: "font-style=italic" },
219
+ {
220
+ style: "font-style=normal",
221
+ clearMark: (m) => m.type.name === "em"
222
+ }
223
+ ],
224
+ toDOM() {
225
+ return ["em"];
226
+ }
227
+ }),
228
+ strong: markSpec({
229
+ parseDOM: [
230
+ { tag: "strong" },
231
+ {
232
+ tag: "b",
233
+ getAttrs: (node) => node.style.fontWeight !== "normal" && null
234
+ },
235
+ {
236
+ style: "font-weight=400",
237
+ clearMark: (m) => m.type.name === "strong"
238
+ },
239
+ {
240
+ style: "font-weight",
241
+ getAttrs: (value) => /^(bold(er)?|[5-9]\d{2,})$/.test(value) && null
242
+ }
243
+ ],
244
+ toDOM() {
245
+ return ["strong"];
246
+ }
247
+ }),
248
+ link: markSpec({
249
+ attrs: {
250
+ href: S.String,
251
+ title: {
252
+ schema: S.NullOr(S.String),
253
+ default: null
254
+ }
255
+ },
256
+ inclusive: false,
257
+ parseDOM: [{
258
+ tag: "a[href]",
259
+ getAttrs(dom) {
260
+ return {
261
+ href: dom.getAttribute("href"),
262
+ title: dom.getAttribute("title")
263
+ };
264
+ }
265
+ }],
266
+ toDOM(node) {
267
+ const { href, title } = node.attrs;
268
+ return ["a", {
269
+ href,
270
+ title
271
+ }];
272
+ }
273
+ }),
274
+ code: markSpec({
275
+ code: true,
276
+ parseDOM: [{ tag: "code" }],
277
+ toDOM() {
278
+ return ["code"];
279
+ }
280
+ })
281
+ };
282
+ /**
283
+ * Document schema for the data model used by CommonMark.
284
+ *
285
+ * @since 0.1.0
286
+ * @category schemas
287
+ */
288
+ const schema = DocSchema.makeUnsafe({
289
+ nodes,
290
+ marks
291
+ });
292
+ export { marks, nodes, schema };
@@ -0,0 +1,251 @@
1
+ import { AnySchema } from "../model/schema.js";
2
+ import { Mark } from "../model/mark.js";
3
+ import { Node } from "../model/node.js";
4
+ import "../model.js";
5
+ /**
6
+ * A function serializing a node to Markdown, by calling methods on the
7
+ * serializer state.
8
+ *
9
+ * @since 0.1.0
10
+ * @category models
11
+ */
12
+ export type NodeSerializer<Sc extends AnySchema = AnySchema> = (state: MarkdownSerializerState<Sc>, node: Node<Sc, any>, parent: Node<Sc, any>, index: number) => void;
13
+ /**
14
+ * Describes how to serialize a mark to Markdown.
15
+ *
16
+ * @since 0.1.0
17
+ * @category models
18
+ */
19
+ export interface MarkSerializerSpec<Sc extends AnySchema = AnySchema> {
20
+ /**
21
+ * The string that should appear before a piece of content marked by
22
+ * this mark, either directly or as a function that returns an
23
+ * appropriate string.
24
+ */
25
+ readonly open: string | ((state: MarkdownSerializerState<Sc>, mark: Mark<Sc, any>, parent: Node<Sc, any>, index: number) => string);
26
+ /** The string that should appear after a piece of content marked by this mark. */
27
+ readonly close: string | ((state: MarkdownSerializerState<Sc>, mark: Mark<Sc, any>, parent: Node<Sc, any>, index: number) => string);
28
+ /**
29
+ * When `true`, this indicates that the order in which the mark's
30
+ * opening and closing syntax appears relative to other mixable marks
31
+ * can be varied. (For example, you can say `**a *b***` and `*a **b***`,
32
+ * but not `` `a *b*` ``.)
33
+ */
34
+ readonly mixable?: boolean | undefined;
35
+ /**
36
+ * When enabled, causes the serializer to move enclosing whitespace
37
+ * from inside the marks to outside the marks. This is necessary for
38
+ * emphasis marks as CommonMark does not permit enclosing whitespace
39
+ * inside emphasis marks, see:
40
+ * http://spec.commonmark.org/0.26/#example-330
41
+ */
42
+ readonly expelEnclosingWhitespace?: boolean | undefined;
43
+ /**
44
+ * Can be set to `false` to disable character escaping in a mark. A
45
+ * non-escaping mark has to have the highest precedence (must always
46
+ * be the innermost mark).
47
+ */
48
+ readonly escape?: boolean | undefined;
49
+ }
50
+ /**
51
+ * Options for a `MarkdownSerializer`.
52
+ *
53
+ * @since 0.1.0
54
+ * @category models
55
+ */
56
+ export interface MarkdownSerializerOptions {
57
+ /**
58
+ * Extra characters can be added for escaping. This is passed directly
59
+ * to `String.replace()`, and the matching characters are preceded by
60
+ * a backslash.
61
+ */
62
+ readonly escapeExtraCharacters?: RegExp | undefined;
63
+ /** Specify the node name of hard breaks. Defaults to `"hard_break"`. */
64
+ readonly hardBreakNodeName?: string | undefined;
65
+ /**
66
+ * By default, the serializer throws a `MarkdownError` when it finds a
67
+ * node or mark type for which no serializer is defined. Set this to
68
+ * `false` to make it just ignore such elements, rendering only their
69
+ * content.
70
+ */
71
+ readonly strict?: boolean | undefined;
72
+ }
73
+ /**
74
+ * Options for `MarkdownSerializer.serialize`.
75
+ *
76
+ * @since 0.1.0
77
+ * @category models
78
+ */
79
+ export interface MarkdownSerializeOptions {
80
+ /**
81
+ * Whether to render lists in a tight style. This can be overridden on
82
+ * a node level by specifying a tight attribute on the node. Defaults
83
+ * to false.
84
+ */
85
+ readonly tightLists?: boolean | undefined;
86
+ }
87
+ /**
88
+ * The options available on a `MarkdownSerializerState`.
89
+ *
90
+ * @since 0.1.0
91
+ * @category models
92
+ */
93
+ export interface MarkdownSerializerStateOptions extends MarkdownSerializerOptions {
94
+ readonly tightLists: boolean;
95
+ readonly hardBreakNodeName: string;
96
+ }
97
+ /**
98
+ * A specification for serializing a document as Markdown/CommonMark
99
+ * text.
100
+ *
101
+ * @since 0.1.0
102
+ * @category models
103
+ */
104
+ export declare class MarkdownSerializer<Sc extends AnySchema = AnySchema> {
105
+ /** The node serializer functions for this serializer. */
106
+ readonly nodes: {
107
+ readonly [node: string]: NodeSerializer<Sc>;
108
+ };
109
+ /** The mark serializer info. */
110
+ readonly marks: {
111
+ readonly [mark: string]: MarkSerializerSpec<Sc>;
112
+ };
113
+ readonly options: MarkdownSerializerOptions;
114
+ /**
115
+ * Construct a serializer with the given configuration. The `nodes`
116
+ * object should map node names in a given schema to function that
117
+ * take a serializer state and such a node, and serialize the node.
118
+ */
119
+ constructor(
120
+ /** The node serializer functions for this serializer. */
121
+ nodes: {
122
+ readonly [node: string]: NodeSerializer<Sc>;
123
+ },
124
+ /** The mark serializer info. */
125
+ marks: {
126
+ readonly [mark: string]: MarkSerializerSpec<Sc>;
127
+ }, options?: MarkdownSerializerOptions);
128
+ /**
129
+ * Serialize the content of the given node to
130
+ * [CommonMark](http://commonmark.org/).
131
+ *
132
+ * Serialization can't fail for nodes that the serializer knows; in
133
+ * strict mode (the default) an unknown node or mark type is a
134
+ * programming error and throws a `MarkdownError`.
135
+ */
136
+ serialize(content: Node<Sc, any>, options?: MarkdownSerializeOptions): string;
137
+ }
138
+ /**
139
+ * A serializer for the Markdown schema (or any schema using the same
140
+ * node and mark names).
141
+ *
142
+ * @since 0.1.0
143
+ * @category serializers
144
+ */
145
+ export declare const defaultMarkdownSerializer: MarkdownSerializer;
146
+ /**
147
+ * This is an object used to track state and expose methods related to
148
+ * markdown serialization. Instances are passed to node and mark
149
+ * serialization methods.
150
+ *
151
+ * @since 0.1.0
152
+ * @category models
153
+ */
154
+ export declare class MarkdownSerializerState<Sc extends AnySchema = AnySchema> {
155
+ /** @internal */
156
+ readonly nodes: {
157
+ readonly [node: string]: NodeSerializer<Sc>;
158
+ };
159
+ /** @internal */
160
+ readonly marks: {
161
+ readonly [mark: string]: MarkSerializerSpec<Sc>;
162
+ };
163
+ /** @internal */
164
+ delim: string;
165
+ /** @internal */
166
+ out: string;
167
+ /** @internal */
168
+ closed: Node<Sc, any> | null;
169
+ /** @internal */
170
+ inAutolink: boolean | undefined;
171
+ /** @internal */
172
+ atBlockStart: boolean;
173
+ /** @internal */
174
+ inTightList: boolean;
175
+ /** The options passed to the serializer. */
176
+ readonly options: MarkdownSerializerStateOptions;
177
+ /** @internal */
178
+ constructor(
179
+ /** @internal */
180
+ nodes: {
181
+ readonly [node: string]: NodeSerializer<Sc>;
182
+ },
183
+ /** @internal */
184
+ marks: {
185
+ readonly [mark: string]: MarkSerializerSpec<Sc>;
186
+ }, options: MarkdownSerializerOptions & MarkdownSerializeOptions);
187
+ /** @internal */
188
+ flushClose(size?: number): void;
189
+ /** @internal */
190
+ getMark(name: string): MarkSerializerSpec<Sc>;
191
+ /**
192
+ * Render a block, prefixing each line with `delim`, and the first line
193
+ * in `firstDelim`. `node` should be the node that is closed at the end
194
+ * of the block, and `f` is a function that renders the content of the
195
+ * block.
196
+ */
197
+ wrapBlock(delim: string, firstDelim: string | null, node: Node<Sc, any>, f: () => void): void;
198
+ /** @internal */
199
+ atBlank(): boolean;
200
+ /** Ensure the current content ends with a newline. */
201
+ ensureNewLine(): void;
202
+ /**
203
+ * Prepare the state for writing output (closing closed paragraphs,
204
+ * adding delimiters, and so on), and then optionally add content
205
+ * (unescaped) to the output.
206
+ */
207
+ write(content?: string): void;
208
+ /** Close the block for the given node. */
209
+ closeBlock(node: Node<Sc, any>): void;
210
+ /** Add the given text to the document. When escape is not `false`, it will be escaped. */
211
+ text(text: string, escape?: boolean): void;
212
+ /**
213
+ * Render the given node as a block. In strict mode, throws a
214
+ * `MarkdownError` for node types without a serializer.
215
+ */
216
+ render(node: Node<Sc, any>, parent: Node<Sc, any>, index: number): void;
217
+ /** Render the contents of `parent` as block nodes. */
218
+ renderContent(parent: Node<Sc, any>): void;
219
+ /** Render the contents of `parent` as inline content. */
220
+ renderInline(parent: Node<Sc, any>, fromBlockStart?: boolean): void;
221
+ /**
222
+ * Render a node's content as a list. `delim` should be the extra
223
+ * indentation added to all lines except the first in an item,
224
+ * `firstDelim` is a function going from an item index to a delimiter
225
+ * for the first line of the item.
226
+ */
227
+ renderList(node: Node<Sc, any>, delim: string, firstDelim: (index: number) => string): void;
228
+ /**
229
+ * Escape the given string so that it can safely appear in Markdown
230
+ * content. If `startOfLine` is true, also escape characters that have
231
+ * special meaning only at the start of the line.
232
+ */
233
+ esc(str: string, startOfLine?: boolean): string;
234
+ /** @internal */
235
+ quote(str: string): string;
236
+ /** Repeat the given string `n` times. */
237
+ repeat(str: string, n: number): string;
238
+ /** Get the markdown string for a given opening or closing mark. */
239
+ markString(mark: Mark<Sc, any>, open: boolean, parent: Node<Sc, any>, index: number): string;
240
+ /**
241
+ * Get leading and trailing whitespace from a string. Values of leading
242
+ * or trailing property of the return object will be undefined if there
243
+ * is no match.
244
+ */
245
+ getEnclosingWhitespace(text: string): {
246
+ leading?: string | undefined;
247
+ trailing?: string | undefined;
248
+ };
249
+ /** @internal */
250
+ isMarkAhead(parent: Node<Sc, any>, index: number, marks: ReadonlyArray<Mark<Sc, any>>): boolean;
251
+ }