foldkit-richtext 0.5.3 → 0.6.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 (100) hide show
  1. package/dist/clipboard.d.ts +224 -0
  2. package/dist/clipboard.d.ts.map +1 -0
  3. package/dist/clipboard.js +208 -0
  4. package/dist/clipboard.js.map +1 -0
  5. package/dist/code.d.ts +27 -0
  6. package/dist/code.d.ts.map +1 -0
  7. package/dist/code.js +45 -0
  8. package/dist/code.js.map +1 -0
  9. package/dist/command.d.ts +300 -0
  10. package/dist/command.d.ts.map +1 -0
  11. package/dist/command.js +1438 -0
  12. package/dist/command.js.map +1 -0
  13. package/dist/decoration.d.ts +44 -0
  14. package/dist/decoration.d.ts.map +1 -0
  15. package/dist/decoration.js +96 -0
  16. package/dist/decoration.js.map +1 -0
  17. package/dist/document.d.ts +1045 -0
  18. package/dist/document.d.ts.map +1 -0
  19. package/dist/document.js +544 -0
  20. package/dist/document.js.map +1 -0
  21. package/dist/footnote.d.ts +35 -0
  22. package/dist/footnote.d.ts.map +1 -0
  23. package/dist/footnote.js +100 -0
  24. package/dist/footnote.js.map +1 -0
  25. package/dist/history.d.ts +470 -0
  26. package/dist/history.d.ts.map +1 -0
  27. package/dist/history.js +81 -0
  28. package/dist/history.js.map +1 -0
  29. package/dist/html.d.ts +27 -0
  30. package/dist/html.d.ts.map +1 -0
  31. package/dist/html.js +99 -0
  32. package/dist/html.js.map +1 -0
  33. package/dist/indent.d.ts +16 -0
  34. package/dist/indent.d.ts.map +1 -0
  35. package/dist/indent.js +101 -0
  36. package/dist/indent.js.map +1 -0
  37. package/dist/index.d.ts +24 -0
  38. package/dist/index.js +24 -0
  39. package/dist/input.d.ts +54 -0
  40. package/dist/input.d.ts.map +1 -0
  41. package/dist/input.js +37 -0
  42. package/dist/input.js.map +1 -0
  43. package/dist/kit.d.ts +179 -0
  44. package/dist/kit.d.ts.map +1 -0
  45. package/dist/kit.js +202 -0
  46. package/dist/kit.js.map +1 -0
  47. package/dist/marks.d.ts +79 -0
  48. package/dist/marks.d.ts.map +1 -0
  49. package/dist/marks.js +127 -0
  50. package/dist/marks.js.map +1 -0
  51. package/dist/media.d.ts +30 -0
  52. package/dist/media.d.ts.map +1 -0
  53. package/dist/media.js +148 -0
  54. package/dist/media.js.map +1 -0
  55. package/dist/migration.d.ts +55 -0
  56. package/dist/migration.d.ts.map +1 -0
  57. package/dist/migration.js +124 -0
  58. package/dist/migration.js.map +1 -0
  59. package/dist/outline.d.ts +15 -0
  60. package/dist/outline.d.ts.map +1 -0
  61. package/dist/outline.js +39 -0
  62. package/dist/outline.js.map +1 -0
  63. package/dist/rendering.d.ts +96 -0
  64. package/dist/rendering.d.ts.map +1 -0
  65. package/dist/rendering.js +106 -0
  66. package/dist/rendering.js.map +1 -0
  67. package/dist/replicated.d.ts +340 -0
  68. package/dist/replicated.d.ts.map +1 -0
  69. package/dist/replicated.js +1727 -0
  70. package/dist/replicated.js.map +1 -0
  71. package/dist/search.d.ts +28 -0
  72. package/dist/search.d.ts.map +1 -0
  73. package/dist/search.js +61 -0
  74. package/dist/search.js.map +1 -0
  75. package/dist/standard.d.ts +61 -0
  76. package/dist/standard.d.ts.map +1 -0
  77. package/dist/standard.js +231 -0
  78. package/dist/standard.js.map +1 -0
  79. package/dist/table.d.ts +38 -0
  80. package/dist/table.d.ts.map +1 -0
  81. package/dist/table.js +160 -0
  82. package/dist/table.js.map +1 -0
  83. package/dist/transaction.d.ts +712 -0
  84. package/dist/transaction.d.ts.map +1 -0
  85. package/dist/transaction.js +993 -0
  86. package/dist/transaction.js.map +1 -0
  87. package/dist/transform.d.ts +48 -0
  88. package/dist/transform.d.ts.map +1 -0
  89. package/dist/transform.js +94 -0
  90. package/dist/transform.js.map +1 -0
  91. package/dist/url.d.ts +16 -0
  92. package/dist/url.d.ts.map +1 -0
  93. package/dist/url.js +32 -0
  94. package/dist/url.js.map +1 -0
  95. package/package.json +6 -6
  96. package/dist/index.d.mts +0 -3787
  97. package/dist/index.d.mts.map +0 -1
  98. package/dist/index.mjs +0 -6688
  99. package/dist/index.mjs.map +0 -1
  100. package/dist/rolldown-runtime-D8jQpDG7.mjs +0 -12
@@ -0,0 +1,470 @@
1
+ import { Schema } from "effect";
2
+ import { EditorState } from "./document.js";
3
+ import { Command } from "./command.js";
4
+ /**
5
+ * Local undo history over editor snapshots. Snapshots are `EditorState` values
6
+ * (document plus selection), so undo restores what the user saw, including the
7
+ * caret. History is interaction state: it belongs in the application Model
8
+ * beside the selection, never in published content, and collaborative undo is a
9
+ * different operation (§§65–66).
10
+ */
11
+ export declare const History: Schema.Struct<{
12
+ /** States to return to, oldest first. */
13
+ readonly past: Schema.$Array<Schema.Struct<{
14
+ readonly document: Schema.Struct<{
15
+ readonly version: Schema.Literal<1>;
16
+ readonly children: Schema.$Array<Schema.Union<readonly [Schema.Struct<{
17
+ readonly type: Schema.Literal<"Paragraph">;
18
+ readonly id: Schema.brand<Schema.NonEmptyString, "foldkit-richtext/NodeId">;
19
+ readonly children: Schema.$Array<Schema.Struct<{
20
+ readonly type: Schema.Literal<"Text">;
21
+ readonly id: Schema.brand<Schema.NonEmptyString, "foldkit-richtext/NodeId">;
22
+ readonly text: Schema.String;
23
+ readonly marks: Schema.$Array<Schema.Union<readonly [Schema.NonEmptyString, Schema.Struct<{
24
+ readonly name: Schema.NonEmptyString;
25
+ readonly props: Schema.optionalKey<Schema.$Record<Schema.String, Schema.Codec<Schema.Json, Schema.Json, never, never>>>;
26
+ }>]>>;
27
+ }>>;
28
+ }>, Schema.Struct<{
29
+ readonly type: Schema.Literal<"Heading">;
30
+ readonly id: Schema.brand<Schema.NonEmptyString, "foldkit-richtext/NodeId">;
31
+ readonly level: Schema.Literals<readonly [1, 2, 3, 4, 5, 6]>;
32
+ readonly children: Schema.$Array<Schema.Struct<{
33
+ readonly type: Schema.Literal<"Text">;
34
+ readonly id: Schema.brand<Schema.NonEmptyString, "foldkit-richtext/NodeId">;
35
+ readonly text: Schema.String;
36
+ readonly marks: Schema.$Array<Schema.Union<readonly [Schema.NonEmptyString, Schema.Struct<{
37
+ readonly name: Schema.NonEmptyString;
38
+ readonly props: Schema.optionalKey<Schema.$Record<Schema.String, Schema.Codec<Schema.Json, Schema.Json, never, never>>>;
39
+ }>]>>;
40
+ }>>;
41
+ }>, Schema.Struct<{
42
+ readonly type: Schema.Literal<"Node">;
43
+ readonly kind: Schema.NonEmptyString;
44
+ readonly id: Schema.brand<Schema.NonEmptyString, "foldkit-richtext/NodeId">;
45
+ readonly props: Schema.$Record<Schema.String, Schema.Codec<Schema.Json, Schema.Json, never, never>>;
46
+ readonly children: Schema.$Array<Schema.Struct<{
47
+ readonly type: Schema.Literal<"Text">;
48
+ readonly id: Schema.brand<Schema.NonEmptyString, "foldkit-richtext/NodeId">;
49
+ readonly text: Schema.String;
50
+ readonly marks: Schema.$Array<Schema.Union<readonly [Schema.NonEmptyString, Schema.Struct<{
51
+ readonly name: Schema.NonEmptyString;
52
+ readonly props: Schema.optionalKey<Schema.$Record<Schema.String, Schema.Codec<Schema.Json, Schema.Json, never, never>>>;
53
+ }>]>>;
54
+ }>>;
55
+ readonly blocks: Schema.optionalKey<Schema.suspend<Schema.Codec<readonly import("./document.js").Block[], readonly ({
56
+ readonly type: 'Node';
57
+ readonly kind: string;
58
+ readonly id: string;
59
+ readonly props: {
60
+ readonly [x: string]: string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | /*elided*/ any | /*elided*/ any | null)[] | /*elided*/ any | null)[] | /*elided*/ any | null)[] | /*elided*/ any | null)[] | /*elided*/ any | null)[] | /*elided*/ any | null)[] | /*elided*/ any | null)[] | /*elided*/ any | null)[] | /*elided*/ any | null)[] | /*elided*/ any | null)[] | /*elided*/ any | null;
61
+ };
62
+ readonly children: readonly {
63
+ readonly type: "Text";
64
+ readonly id: string;
65
+ readonly text: string;
66
+ readonly marks: readonly (string | {
67
+ readonly name: string;
68
+ readonly props?: {
69
+ readonly [x: string]: string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | any | any | null)[] | any | null)[] | any | null)[] | any | null)[] | any | null)[] | any | null)[] | any | null)[] | any | null)[] | any | null)[] | any | null)[] | {
70
+ readonly [x: string]: string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | any | any | null)[] | any | null)[] | any | null)[] | any | null)[] | any | null)[] | any | null)[] | any | null)[] | any | null)[] | any | null)[] | any | null)[] | any | null;
71
+ } | null;
72
+ };
73
+ })[];
74
+ }[];
75
+ readonly blocks?: readonly ( /*elided*/ any | {
76
+ readonly type: "Paragraph";
77
+ readonly id: string;
78
+ readonly children: readonly {
79
+ readonly type: "Text";
80
+ readonly id: string;
81
+ readonly text: string;
82
+ readonly marks: readonly (string | {
83
+ readonly name: string;
84
+ readonly props?: {
85
+ readonly [x: string]: string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | any | any | null)[] | any | null)[] | any | null)[] | any | null)[] | any | null)[] | any | null)[] | any | null)[] | any | null)[] | any | null)[] | any | null)[] | {
86
+ readonly [x: string]: string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | any | any | null)[] | any | null)[] | any | null)[] | any | null)[] | any | null)[] | any | null)[] | any | null)[] | any | null)[] | any | null)[] | any | null)[] | any | null;
87
+ } | null;
88
+ };
89
+ })[];
90
+ }[];
91
+ } | {
92
+ readonly type: "Heading";
93
+ readonly id: string;
94
+ readonly level: 1 | 2 | 3 | 4 | 5 | 6;
95
+ readonly children: readonly {
96
+ readonly type: "Text";
97
+ readonly id: string;
98
+ readonly text: string;
99
+ readonly marks: readonly (string | {
100
+ readonly name: string;
101
+ readonly props?: {
102
+ readonly [x: string]: string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | any | any | null)[] | any | null)[] | any | null)[] | any | null)[] | any | null)[] | any | null)[] | any | null)[] | any | null)[] | any | null)[] | any | null)[] | {
103
+ readonly [x: string]: string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | any | any | null)[] | any | null)[] | any | null)[] | any | null)[] | any | null)[] | any | null)[] | any | null)[] | any | null)[] | any | null)[] | any | null)[] | any | null;
104
+ } | null;
105
+ };
106
+ })[];
107
+ }[];
108
+ } | {
109
+ readonly type: "Unknown";
110
+ readonly id: string;
111
+ readonly originalType: string;
112
+ readonly props: {
113
+ readonly [x: string]: string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | any | any | null)[] | any | null)[] | any | null)[] | any | null)[] | any | null)[] | any | null)[] | any | null)[] | any | null)[] | any | null)[] | any | null)[] | {
114
+ readonly [x: string]: string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | any | any | null)[] | any | null)[] | any | null)[] | any | null)[] | any | null)[] | any | null)[] | any | null)[] | any | null)[] | any | null)[] | any | null)[] | any | null;
115
+ } | null;
116
+ };
117
+ readonly children: readonly {
118
+ readonly type: "Text";
119
+ readonly id: string;
120
+ readonly text: string;
121
+ readonly marks: readonly (string | {
122
+ readonly name: string;
123
+ readonly props?: {
124
+ readonly [x: string]: string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | any | any | null)[] | any | null)[] | any | null)[] | any | null)[] | any | null)[] | any | null)[] | any | null)[] | any | null)[] | any | null)[] | any | null)[] | {
125
+ readonly [x: string]: string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | any | any | null)[] | any | null)[] | any | null)[] | any | null)[] | any | null)[] | any | null)[] | any | null)[] | any | null)[] | any | null)[] | any | null)[] | any | null;
126
+ } | null;
127
+ };
128
+ })[];
129
+ }[];
130
+ })[];
131
+ } | {
132
+ readonly type: "Paragraph";
133
+ readonly id: string;
134
+ readonly children: readonly {
135
+ readonly type: "Text";
136
+ readonly id: string;
137
+ readonly text: string;
138
+ readonly marks: readonly (string | {
139
+ readonly name: string;
140
+ readonly props?: {
141
+ readonly [x: string]: string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | any | any | null)[] | any | null)[] | any | null)[] | any | null)[] | any | null)[] | any | null)[] | any | null)[] | any | null)[] | any | null)[] | any | null)[] | {
142
+ readonly [x: string]: string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | any | any | null)[] | any | null)[] | any | null)[] | any | null)[] | any | null)[] | any | null)[] | any | null)[] | any | null)[] | any | null)[] | any | null)[] | any | null;
143
+ } | null;
144
+ };
145
+ })[];
146
+ }[];
147
+ } | {
148
+ readonly type: "Heading";
149
+ readonly id: string;
150
+ readonly level: 1 | 2 | 3 | 4 | 5 | 6;
151
+ readonly children: readonly {
152
+ readonly type: "Text";
153
+ readonly id: string;
154
+ readonly text: string;
155
+ readonly marks: readonly (string | {
156
+ readonly name: string;
157
+ readonly props?: {
158
+ readonly [x: string]: string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | any | any | null)[] | any | null)[] | any | null)[] | any | null)[] | any | null)[] | any | null)[] | any | null)[] | any | null)[] | any | null)[] | any | null)[] | {
159
+ readonly [x: string]: string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | any | any | null)[] | any | null)[] | any | null)[] | any | null)[] | any | null)[] | any | null)[] | any | null)[] | any | null)[] | any | null)[] | any | null)[] | any | null;
160
+ } | null;
161
+ };
162
+ })[];
163
+ }[];
164
+ } | {
165
+ readonly type: "Unknown";
166
+ readonly id: string;
167
+ readonly originalType: string;
168
+ readonly props: {
169
+ readonly [x: string]: string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | any | any | null)[] | any | null)[] | any | null)[] | any | null)[] | any | null)[] | any | null)[] | any | null)[] | any | null)[] | any | null)[] | any | null)[] | {
170
+ readonly [x: string]: string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | any | any | null)[] | any | null)[] | any | null)[] | any | null)[] | any | null)[] | any | null)[] | any | null)[] | any | null)[] | any | null)[] | any | null)[] | any | null;
171
+ } | null;
172
+ };
173
+ readonly children: readonly {
174
+ readonly type: "Text";
175
+ readonly id: string;
176
+ readonly text: string;
177
+ readonly marks: readonly (string | {
178
+ readonly name: string;
179
+ readonly props?: {
180
+ readonly [x: string]: string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | any | any | null)[] | any | null)[] | any | null)[] | any | null)[] | any | null)[] | any | null)[] | any | null)[] | any | null)[] | any | null)[] | any | null)[] | {
181
+ readonly [x: string]: string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | any | any | null)[] | any | null)[] | any | null)[] | any | null)[] | any | null)[] | any | null)[] | any | null)[] | any | null)[] | any | null)[] | any | null)[] | any | null;
182
+ } | null;
183
+ };
184
+ })[];
185
+ }[];
186
+ })[], never, never>>>;
187
+ }>, Schema.Struct<{
188
+ readonly type: Schema.Literal<"Unknown">;
189
+ readonly id: Schema.brand<Schema.NonEmptyString, "foldkit-richtext/NodeId">;
190
+ readonly originalType: Schema.NonEmptyString;
191
+ readonly props: Schema.$Record<Schema.String, Schema.Codec<Schema.Json, Schema.Json, never, never>>;
192
+ readonly children: Schema.$Array<Schema.Struct<{
193
+ readonly type: Schema.Literal<"Text">;
194
+ readonly id: Schema.brand<Schema.NonEmptyString, "foldkit-richtext/NodeId">;
195
+ readonly text: Schema.String;
196
+ readonly marks: Schema.$Array<Schema.Union<readonly [Schema.NonEmptyString, Schema.Struct<{
197
+ readonly name: Schema.NonEmptyString;
198
+ readonly props: Schema.optionalKey<Schema.$Record<Schema.String, Schema.Codec<Schema.Json, Schema.Json, never, never>>>;
199
+ }>]>>;
200
+ }>>;
201
+ }>]>>;
202
+ }>;
203
+ readonly selection: Schema.NullOr<Schema.Union<readonly [Schema.Struct<{
204
+ readonly type: Schema.Literal<"Range">;
205
+ readonly anchor: Schema.Struct<{
206
+ readonly node: Schema.brand<Schema.NonEmptyString, "foldkit-richtext/NodeId">;
207
+ readonly offset: Schema.Number;
208
+ readonly affinity: Schema.Literals<readonly ["before", "after"]>;
209
+ }>;
210
+ readonly focus: Schema.Struct<{
211
+ readonly node: Schema.brand<Schema.NonEmptyString, "foldkit-richtext/NodeId">;
212
+ readonly offset: Schema.Number;
213
+ readonly affinity: Schema.Literals<readonly ["before", "after"]>;
214
+ }>;
215
+ }>, Schema.Struct<{
216
+ readonly type: Schema.Literal<"Node">;
217
+ readonly node: Schema.brand<Schema.NonEmptyString, "foldkit-richtext/NodeId">;
218
+ }>]>>;
219
+ }>>;
220
+ /** States undone from, nearest first. */
221
+ readonly future: Schema.$Array<Schema.Struct<{
222
+ readonly document: Schema.Struct<{
223
+ readonly version: Schema.Literal<1>;
224
+ readonly children: Schema.$Array<Schema.Union<readonly [Schema.Struct<{
225
+ readonly type: Schema.Literal<"Paragraph">;
226
+ readonly id: Schema.brand<Schema.NonEmptyString, "foldkit-richtext/NodeId">;
227
+ readonly children: Schema.$Array<Schema.Struct<{
228
+ readonly type: Schema.Literal<"Text">;
229
+ readonly id: Schema.brand<Schema.NonEmptyString, "foldkit-richtext/NodeId">;
230
+ readonly text: Schema.String;
231
+ readonly marks: Schema.$Array<Schema.Union<readonly [Schema.NonEmptyString, Schema.Struct<{
232
+ readonly name: Schema.NonEmptyString;
233
+ readonly props: Schema.optionalKey<Schema.$Record<Schema.String, Schema.Codec<Schema.Json, Schema.Json, never, never>>>;
234
+ }>]>>;
235
+ }>>;
236
+ }>, Schema.Struct<{
237
+ readonly type: Schema.Literal<"Heading">;
238
+ readonly id: Schema.brand<Schema.NonEmptyString, "foldkit-richtext/NodeId">;
239
+ readonly level: Schema.Literals<readonly [1, 2, 3, 4, 5, 6]>;
240
+ readonly children: Schema.$Array<Schema.Struct<{
241
+ readonly type: Schema.Literal<"Text">;
242
+ readonly id: Schema.brand<Schema.NonEmptyString, "foldkit-richtext/NodeId">;
243
+ readonly text: Schema.String;
244
+ readonly marks: Schema.$Array<Schema.Union<readonly [Schema.NonEmptyString, Schema.Struct<{
245
+ readonly name: Schema.NonEmptyString;
246
+ readonly props: Schema.optionalKey<Schema.$Record<Schema.String, Schema.Codec<Schema.Json, Schema.Json, never, never>>>;
247
+ }>]>>;
248
+ }>>;
249
+ }>, Schema.Struct<{
250
+ readonly type: Schema.Literal<"Node">;
251
+ readonly kind: Schema.NonEmptyString;
252
+ readonly id: Schema.brand<Schema.NonEmptyString, "foldkit-richtext/NodeId">;
253
+ readonly props: Schema.$Record<Schema.String, Schema.Codec<Schema.Json, Schema.Json, never, never>>;
254
+ readonly children: Schema.$Array<Schema.Struct<{
255
+ readonly type: Schema.Literal<"Text">;
256
+ readonly id: Schema.brand<Schema.NonEmptyString, "foldkit-richtext/NodeId">;
257
+ readonly text: Schema.String;
258
+ readonly marks: Schema.$Array<Schema.Union<readonly [Schema.NonEmptyString, Schema.Struct<{
259
+ readonly name: Schema.NonEmptyString;
260
+ readonly props: Schema.optionalKey<Schema.$Record<Schema.String, Schema.Codec<Schema.Json, Schema.Json, never, never>>>;
261
+ }>]>>;
262
+ }>>;
263
+ readonly blocks: Schema.optionalKey<Schema.suspend<Schema.Codec<readonly import("./document.js").Block[], readonly ({
264
+ readonly type: 'Node';
265
+ readonly kind: string;
266
+ readonly id: string;
267
+ readonly props: {
268
+ readonly [x: string]: string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | any | any | null)[] | any | null)[] | any | null)[] | any | null)[] | any | null)[] | any | null)[] | any | null)[] | any | null)[] | any | null)[] | any | null)[] | any | null;
269
+ };
270
+ readonly children: readonly {
271
+ readonly type: "Text";
272
+ readonly id: string;
273
+ readonly text: string;
274
+ readonly marks: readonly (string | {
275
+ readonly name: string;
276
+ readonly props?: {
277
+ readonly [x: string]: string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | any | any | null)[] | any | null)[] | any | null)[] | any | null)[] | any | null)[] | any | null)[] | any | null)[] | any | null)[] | any | null)[] | any | null)[] | {
278
+ readonly [x: string]: string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | any | any | null)[] | any | null)[] | any | null)[] | any | null)[] | any | null)[] | any | null)[] | any | null)[] | any | null)[] | any | null)[] | any | null)[] | any | null;
279
+ } | null;
280
+ };
281
+ })[];
282
+ }[];
283
+ readonly blocks?: readonly (any | {
284
+ readonly type: "Paragraph";
285
+ readonly id: string;
286
+ readonly children: readonly {
287
+ readonly type: "Text";
288
+ readonly id: string;
289
+ readonly text: string;
290
+ readonly marks: readonly (string | {
291
+ readonly name: string;
292
+ readonly props?: {
293
+ readonly [x: string]: string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | any | any | null)[] | any | null)[] | any | null)[] | any | null)[] | any | null)[] | any | null)[] | any | null)[] | any | null)[] | any | null)[] | any | null)[] | {
294
+ readonly [x: string]: string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | any | any | null)[] | any | null)[] | any | null)[] | any | null)[] | any | null)[] | any | null)[] | any | null)[] | any | null)[] | any | null)[] | any | null)[] | any | null;
295
+ } | null;
296
+ };
297
+ })[];
298
+ }[];
299
+ } | {
300
+ readonly type: "Heading";
301
+ readonly id: string;
302
+ readonly level: 1 | 2 | 3 | 4 | 5 | 6;
303
+ readonly children: readonly {
304
+ readonly type: "Text";
305
+ readonly id: string;
306
+ readonly text: string;
307
+ readonly marks: readonly (string | {
308
+ readonly name: string;
309
+ readonly props?: {
310
+ readonly [x: string]: string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | any | any | null)[] | any | null)[] | any | null)[] | any | null)[] | any | null)[] | any | null)[] | any | null)[] | any | null)[] | any | null)[] | any | null)[] | {
311
+ readonly [x: string]: string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | any | any | null)[] | any | null)[] | any | null)[] | any | null)[] | any | null)[] | any | null)[] | any | null)[] | any | null)[] | any | null)[] | any | null)[] | any | null;
312
+ } | null;
313
+ };
314
+ })[];
315
+ }[];
316
+ } | {
317
+ readonly type: "Unknown";
318
+ readonly id: string;
319
+ readonly originalType: string;
320
+ readonly props: {
321
+ readonly [x: string]: string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | any | any | null)[] | any | null)[] | any | null)[] | any | null)[] | any | null)[] | any | null)[] | any | null)[] | any | null)[] | any | null)[] | any | null)[] | {
322
+ readonly [x: string]: string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | any | any | null)[] | any | null)[] | any | null)[] | any | null)[] | any | null)[] | any | null)[] | any | null)[] | any | null)[] | any | null)[] | any | null)[] | any | null;
323
+ } | null;
324
+ };
325
+ readonly children: readonly {
326
+ readonly type: "Text";
327
+ readonly id: string;
328
+ readonly text: string;
329
+ readonly marks: readonly (string | {
330
+ readonly name: string;
331
+ readonly props?: {
332
+ readonly [x: string]: string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | any | any | null)[] | any | null)[] | any | null)[] | any | null)[] | any | null)[] | any | null)[] | any | null)[] | any | null)[] | any | null)[] | any | null)[] | {
333
+ readonly [x: string]: string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | any | any | null)[] | any | null)[] | any | null)[] | any | null)[] | any | null)[] | any | null)[] | any | null)[] | any | null)[] | any | null)[] | any | null)[] | any | null;
334
+ } | null;
335
+ };
336
+ })[];
337
+ }[];
338
+ })[];
339
+ } | {
340
+ readonly type: "Paragraph";
341
+ readonly id: string;
342
+ readonly children: readonly {
343
+ readonly type: "Text";
344
+ readonly id: string;
345
+ readonly text: string;
346
+ readonly marks: readonly (string | {
347
+ readonly name: string;
348
+ readonly props?: {
349
+ readonly [x: string]: string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | any | any | null)[] | any | null)[] | any | null)[] | any | null)[] | any | null)[] | any | null)[] | any | null)[] | any | null)[] | any | null)[] | any | null)[] | {
350
+ readonly [x: string]: string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | any | any | null)[] | any | null)[] | any | null)[] | any | null)[] | any | null)[] | any | null)[] | any | null)[] | any | null)[] | any | null)[] | any | null)[] | any | null;
351
+ } | null;
352
+ };
353
+ })[];
354
+ }[];
355
+ } | {
356
+ readonly type: "Heading";
357
+ readonly id: string;
358
+ readonly level: 1 | 2 | 3 | 4 | 5 | 6;
359
+ readonly children: readonly {
360
+ readonly type: "Text";
361
+ readonly id: string;
362
+ readonly text: string;
363
+ readonly marks: readonly (string | {
364
+ readonly name: string;
365
+ readonly props?: {
366
+ readonly [x: string]: string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | any | any | null)[] | any | null)[] | any | null)[] | any | null)[] | any | null)[] | any | null)[] | any | null)[] | any | null)[] | any | null)[] | any | null)[] | {
367
+ readonly [x: string]: string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | any | any | null)[] | any | null)[] | any | null)[] | any | null)[] | any | null)[] | any | null)[] | any | null)[] | any | null)[] | any | null)[] | any | null)[] | any | null;
368
+ } | null;
369
+ };
370
+ })[];
371
+ }[];
372
+ } | {
373
+ readonly type: "Unknown";
374
+ readonly id: string;
375
+ readonly originalType: string;
376
+ readonly props: {
377
+ readonly [x: string]: string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | any | any | null)[] | any | null)[] | any | null)[] | any | null)[] | any | null)[] | any | null)[] | any | null)[] | any | null)[] | any | null)[] | any | null)[] | {
378
+ readonly [x: string]: string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | any | any | null)[] | any | null)[] | any | null)[] | any | null)[] | any | null)[] | any | null)[] | any | null)[] | any | null)[] | any | null)[] | any | null)[] | any | null;
379
+ } | null;
380
+ };
381
+ readonly children: readonly {
382
+ readonly type: "Text";
383
+ readonly id: string;
384
+ readonly text: string;
385
+ readonly marks: readonly (string | {
386
+ readonly name: string;
387
+ readonly props?: {
388
+ readonly [x: string]: string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | any | any | null)[] | any | null)[] | any | null)[] | any | null)[] | any | null)[] | any | null)[] | any | null)[] | any | null)[] | any | null)[] | any | null)[] | {
389
+ readonly [x: string]: string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | any | any | null)[] | any | null)[] | any | null)[] | any | null)[] | any | null)[] | any | null)[] | any | null)[] | any | null)[] | any | null)[] | any | null)[] | any | null;
390
+ } | null;
391
+ };
392
+ })[];
393
+ }[];
394
+ })[], never, never>>>;
395
+ }>, Schema.Struct<{
396
+ readonly type: Schema.Literal<"Unknown">;
397
+ readonly id: Schema.brand<Schema.NonEmptyString, "foldkit-richtext/NodeId">;
398
+ readonly originalType: Schema.NonEmptyString;
399
+ readonly props: Schema.$Record<Schema.String, Schema.Codec<Schema.Json, Schema.Json, never, never>>;
400
+ readonly children: Schema.$Array<Schema.Struct<{
401
+ readonly type: Schema.Literal<"Text">;
402
+ readonly id: Schema.brand<Schema.NonEmptyString, "foldkit-richtext/NodeId">;
403
+ readonly text: Schema.String;
404
+ readonly marks: Schema.$Array<Schema.Union<readonly [Schema.NonEmptyString, Schema.Struct<{
405
+ readonly name: Schema.NonEmptyString;
406
+ readonly props: Schema.optionalKey<Schema.$Record<Schema.String, Schema.Codec<Schema.Json, Schema.Json, never, never>>>;
407
+ }>]>>;
408
+ }>>;
409
+ }>]>>;
410
+ }>;
411
+ readonly selection: Schema.NullOr<Schema.Union<readonly [Schema.Struct<{
412
+ readonly type: Schema.Literal<"Range">;
413
+ readonly anchor: Schema.Struct<{
414
+ readonly node: Schema.brand<Schema.NonEmptyString, "foldkit-richtext/NodeId">;
415
+ readonly offset: Schema.Number;
416
+ readonly affinity: Schema.Literals<readonly ["before", "after"]>;
417
+ }>;
418
+ readonly focus: Schema.Struct<{
419
+ readonly node: Schema.brand<Schema.NonEmptyString, "foldkit-richtext/NodeId">;
420
+ readonly offset: Schema.Number;
421
+ readonly affinity: Schema.Literals<readonly ["before", "after"]>;
422
+ }>;
423
+ }>, Schema.Struct<{
424
+ readonly type: Schema.Literal<"Node">;
425
+ readonly node: Schema.brand<Schema.NonEmptyString, "foldkit-richtext/NodeId">;
426
+ }>]>>;
427
+ }>>;
428
+ /** The group the last commit joined, if any. */
429
+ readonly group: Schema.optional<Schema.String>;
430
+ }>;
431
+ export type History = typeof History.Type;
432
+ export declare const emptyHistory: History;
433
+ export interface CommitOptions {
434
+ /**
435
+ * Joins the previous step when it used the same group. Consecutive typing
436
+ * shares one undo step; omit the group and every commit stands alone.
437
+ */
438
+ readonly group?: string | undefined;
439
+ /** Most steps to keep; the oldest is dropped beyond this. Default 200. */
440
+ readonly capacity?: number;
441
+ }
442
+ /**
443
+ * Typing continues one undo step; every other command is its own step. Callers
444
+ * pass this to `commit`, so grouping policy lives with the editor vocabulary
445
+ * rather than being reinvented per adapter.
446
+ */
447
+ export declare const groupFor: (command: Command) => string | undefined;
448
+ /**
449
+ * Records a committed transition. `previous` is the state before the command
450
+ * and `next` the state after it; only `previous` is stored, because the caller
451
+ * already holds `next`.
452
+ */
453
+ export declare const commit: (history: History, previous: EditorState, options?: CommitOptions) => History;
454
+ export interface Restore {
455
+ readonly history: History;
456
+ readonly state: EditorState;
457
+ }
458
+ /** Steps back one group. Returns undefined when there is nothing to undo. */
459
+ export declare const undo: (history: History, current: EditorState) => Restore | undefined;
460
+ /** Steps forward again. Returns undefined when there is nothing to redo. */
461
+ export declare const redo: (history: History, current: EditorState) => Restore | undefined;
462
+ export declare const canUndo: (history: History) => boolean;
463
+ export declare const canRedo: (history: History) => boolean;
464
+ /** Structural summary for tooling and tests. */
465
+ export declare const inspectHistory: (history: History) => {
466
+ past: number;
467
+ future: number;
468
+ group: string | null;
469
+ };
470
+ //# sourceMappingURL=history.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"history.d.ts","names":[],"sources":["../src/history.ts"],"mappings":";;;;;;;;;;qBAWa,SAAO,OAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;YAQR,iBAAiB,QAAQ;qBAExB,cAAc;iBAEV;;;;;WAKN;;WAEA;;;;;;;qBAQE,WAAQ,SAAa;;;;;;qBAerB,SAAM,SACR,SAAO,UACN,aAAW,UACZ,kBACR;iBAQc;WACN,SAAS;WACT,OAAO;;;qBAIL,OAAI,SAAa,SAAO,SAAW,gBAAc;;qBAUjD,OAAI,SAAa,SAAO,SAAW,gBAAc;qBAajD,UAAO,SAAa;qBACpB,UAAO,SAAa;;qBAGpB,iBAAc,SAAa;EACtC;EACA;EACA"}
@@ -0,0 +1,81 @@
1
+ import { Schema } from "effect";
2
+ import { EditorState } from "./document.js";
3
+ // src/history.ts
4
+ /**
5
+ * Local undo history over editor snapshots. Snapshots are `EditorState` values
6
+ * (document plus selection), so undo restores what the user saw, including the
7
+ * caret. History is interaction state: it belongs in the application Model
8
+ * beside the selection, never in published content, and collaborative undo is a
9
+ * different operation (§§65–66).
10
+ */
11
+ const History = Schema.Struct({
12
+ /** States to return to, oldest first. */
13
+ past: Schema.Array(EditorState),
14
+ /** States undone from, nearest first. */
15
+ future: Schema.Array(EditorState),
16
+ /** The group the last commit joined, if any. */
17
+ group: Schema.optional(Schema.String)
18
+ });
19
+ const emptyHistory = Object.freeze({
20
+ past: [],
21
+ future: []
22
+ });
23
+ /**
24
+ * Typing continues one undo step; every other command is its own step. Callers
25
+ * pass this to `commit`, so grouping policy lives with the editor vocabulary
26
+ * rather than being reinvented per adapter.
27
+ */
28
+ const groupFor = (command) => command.type === "InsertText" || command.type === "DeleteBackward" || command.type === "DeleteForward" ? "typing" : void 0;
29
+ const bounded = (past, capacity) => past.length > capacity ? past.slice(past.length - capacity) : past;
30
+ /**
31
+ * Records a committed transition. `previous` is the state before the command
32
+ * and `next` the state after it; only `previous` is stored, because the caller
33
+ * already holds `next`.
34
+ */
35
+ const commit = (history, previous, options = {}) => {
36
+ const past = options.group !== void 0 && history.group === options.group ? history.past : bounded([...history.past, previous], options.capacity ?? 200);
37
+ return options.group === void 0 ? {
38
+ past,
39
+ future: []
40
+ } : {
41
+ past,
42
+ future: [],
43
+ group: options.group
44
+ };
45
+ };
46
+ /** Steps back one group. Returns undefined when there is nothing to undo. */
47
+ const undo = (history, current) => {
48
+ const previous = history.past[history.past.length - 1];
49
+ if (previous === void 0) return void 0;
50
+ return {
51
+ history: {
52
+ past: history.past.slice(0, -1),
53
+ future: [current, ...history.future]
54
+ },
55
+ state: previous
56
+ };
57
+ };
58
+ /** Steps forward again. Returns undefined when there is nothing to redo. */
59
+ const redo = (history, current) => {
60
+ const next = history.future[0];
61
+ if (next === void 0) return void 0;
62
+ return {
63
+ history: {
64
+ past: [...history.past, current],
65
+ future: history.future.slice(1),
66
+ group: history.group
67
+ },
68
+ state: next
69
+ };
70
+ };
71
+ const canUndo = (history) => history.past.length > 0;
72
+ const canRedo = (history) => history.future.length > 0;
73
+ /** Structural summary for tooling and tests. */
74
+ const inspectHistory = (history) => ({
75
+ past: history.past.length,
76
+ future: history.future.length,
77
+ group: history.group ?? null
78
+ });
79
+ export { History, canRedo, canUndo, commit, emptyHistory, groupFor, inspectHistory, redo, undo };
80
+
81
+ //# sourceMappingURL=history.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"history.js","names":[],"sources":["../src/history.ts"],"sourcesContent":["import { Schema } from 'effect'\nimport type { Command } from './command.js'\nimport { EditorState } from './document.js'\n\n/**\n * Local undo history over editor snapshots. Snapshots are `EditorState` values\n * (document plus selection), so undo restores what the user saw, including the\n * caret. History is interaction state: it belongs in the application Model\n * beside the selection, never in published content, and collaborative undo is a\n * different operation (§§65–66).\n */\nexport const History = Schema.Struct({\n /** States to return to, oldest first. */\n past: Schema.Array(EditorState),\n /** States undone from, nearest first. */\n future: Schema.Array(EditorState),\n /** The group the last commit joined, if any. */\n group: Schema.optional(Schema.String),\n})\nexport type History = typeof History.Type\n\nexport const emptyHistory: History = Object.freeze({ past: [], future: [] })\n\nexport interface CommitOptions {\n /**\n * Joins the previous step when it used the same group. Consecutive typing\n * shares one undo step; omit the group and every commit stands alone.\n */\n readonly group?: string | undefined\n /** Most steps to keep; the oldest is dropped beyond this. Default 200. */\n readonly capacity?: number\n}\n\n/**\n * Typing continues one undo step; every other command is its own step. Callers\n * pass this to `commit`, so grouping policy lives with the editor vocabulary\n * rather than being reinvented per adapter.\n */\nexport const groupFor = (command: Command): string | undefined =>\n command.type === 'InsertText' ||\n command.type === 'DeleteBackward' ||\n command.type === 'DeleteForward'\n ? 'typing'\n : undefined\n\nconst bounded = (past: ReadonlyArray<EditorState>, capacity: number): ReadonlyArray<EditorState> =>\n past.length > capacity ? past.slice(past.length - capacity) : past\n\n/**\n * Records a committed transition. `previous` is the state before the command\n * and `next` the state after it; only `previous` is stored, because the caller\n * already holds `next`.\n */\nexport const commit = (\n history: History,\n previous: EditorState,\n options: CommitOptions = {},\n): History => {\n const joins = options.group !== undefined && history.group === options.group\n const past = joins ? history.past : bounded([...history.past, previous], options.capacity ?? 200)\n return options.group === undefined\n ? { past, future: [] }\n : { past, future: [], group: options.group }\n}\n\nexport interface Restore {\n readonly history: History\n readonly state: EditorState\n}\n\n/** Steps back one group. Returns undefined when there is nothing to undo. */\nexport const undo = (history: History, current: EditorState): Restore | undefined => {\n const previous = history.past[history.past.length - 1]\n if (previous === undefined) return undefined\n return {\n history: { past: history.past.slice(0, -1), future: [current, ...history.future] },\n state: previous,\n }\n}\n\n/** Steps forward again. Returns undefined when there is nothing to redo. */\nexport const redo = (history: History, current: EditorState): Restore | undefined => {\n const next = history.future[0]\n if (next === undefined) return undefined\n return {\n history: {\n past: [...history.past, current],\n future: history.future.slice(1),\n group: history.group,\n },\n state: next,\n }\n}\n\nexport const canUndo = (history: History): boolean => history.past.length > 0\nexport const canRedo = (history: History): boolean => history.future.length > 0\n\n/** Structural summary for tooling and tests. */\nexport const inspectHistory = (history: History) => ({\n past: history.past.length,\n future: history.future.length,\n group: history.group ?? null,\n})\n"],"mappings":";;;;;;;;;;AAWA,MAAa,UAAU,OAAO,OAAO;;CAEnC,MAAM,OAAO,MAAM,WAAW;;CAE9B,QAAQ,OAAO,MAAM,WAAW;;CAEhC,OAAO,OAAO,SAAS,OAAO,MAAM;AACtC,CAAC;AAGD,MAAa,eAAwB,OAAO,OAAO;CAAE,MAAM,CAAC;CAAG,QAAQ,CAAC;AAAE,CAAC;;;;;;AAiB3E,MAAa,YAAY,YACvB,QAAQ,SAAS,gBACjB,QAAQ,SAAS,oBACjB,QAAQ,SAAS,kBACb,WACA,KAAA;AAEN,MAAM,WAAW,MAAkC,aACjD,KAAK,SAAS,WAAW,KAAK,MAAM,KAAK,SAAS,QAAQ,IAAI;;;;;;AAOhE,MAAa,UACX,SACA,UACA,UAAyB,CAAC,MACd;CAEZ,MAAM,OADQ,QAAQ,UAAU,KAAA,KAAa,QAAQ,UAAU,QAAQ,QAClD,QAAQ,OAAO,QAAQ,CAAC,GAAG,QAAQ,MAAM,QAAQ,GAAG,QAAQ,YAAY,GAAG;CAChG,OAAO,QAAQ,UAAU,KAAA,IACrB;EAAE;EAAM,QAAQ,CAAC;CAAE,IACnB;EAAE;EAAM,QAAQ,CAAC;EAAG,OAAO,QAAQ;CAAM;AAC/C;;AAQA,MAAa,QAAQ,SAAkB,YAA8C;CACnF,MAAM,WAAW,QAAQ,KAAK,QAAQ,KAAK,SAAS;CACpD,IAAI,aAAa,KAAA,GAAW,OAAO,KAAA;CACnC,OAAO;EACL,SAAS;GAAE,MAAM,QAAQ,KAAK,MAAM,GAAG,EAAE;GAAG,QAAQ,CAAC,SAAS,GAAG,QAAQ,MAAM;EAAE;EACjF,OAAO;CACT;AACF;;AAGA,MAAa,QAAQ,SAAkB,YAA8C;CACnF,MAAM,OAAO,QAAQ,OAAO;CAC5B,IAAI,SAAS,KAAA,GAAW,OAAO,KAAA;CAC/B,OAAO;EACL,SAAS;GACP,MAAM,CAAC,GAAG,QAAQ,MAAM,OAAO;GAC/B,QAAQ,QAAQ,OAAO,MAAM,CAAC;GAC9B,OAAO,QAAQ;EACjB;EACA,OAAO;CACT;AACF;AAEA,MAAa,WAAW,YAA8B,QAAQ,KAAK,SAAS;AAC5E,MAAa,WAAW,YAA8B,QAAQ,OAAO,SAAS;;AAG9E,MAAa,kBAAkB,aAAsB;CACnD,MAAM,QAAQ,KAAK;CACnB,QAAQ,QAAQ,OAAO;CACvB,OAAO,QAAQ,SAAS;AAC1B"}
package/dist/html.d.ts ADDED
@@ -0,0 +1,27 @@
1
+ import { Block, Document } from "./document.js";
2
+ import { Rendering } from "./rendering.js";
3
+ /**
4
+ * HTML is an interchange format, not the document model (§70). This serializer
5
+ * exists so a copy can offer HTML to other applications and a preview can be
6
+ * read by anything; nothing here is ever parsed back into authority. Unknown
7
+ * marks survive as `data-marks` on a span and unknown blocks as a placeholder
8
+ * carrying their original type, so a round trip through HTML cannot silently
9
+ * invent formatting the document never had.
10
+ *
11
+ * A renderer (§121) decides which element a declared mark or node kind produces,
12
+ * which is how a Link's `href` becomes a real attribute. Without one, this
13
+ * fallback still carries mark *names*, and a mark's props travel in the slice
14
+ * format, which is the lossless path.
15
+ */
16
+ export type BlockList = ReadonlyArray<Block>;
17
+ /** Serializes blocks as HTML, with text and attributes escaped. */
18
+ export declare const toHtml: (blocks: BlockList, renderer?: Rendering) => string;
19
+ /**
20
+ * Plain text of blocks, one line per text block; unknown blocks keep a
21
+ * placeholder and a container contributes its children's lines.
22
+ */
23
+ export declare const toText: (blocks: BlockList) => string;
24
+ /** Convenience for a whole document, whose blocks are its children. */
25
+ export declare const documentToHtml: (document: Document, renderer?: Rendering) => string;
26
+ export declare const documentToText: (document: Document) => string;
27
+ //# sourceMappingURL=html.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"html.d.ts","names":[],"sources":["../src/html.ts"],"mappings":";;;;;;;;;;;;;;;YAuBY,YAAY,cAAc;;qBAiGzB,SAAM,QAAY,WAAS,WAAY;;;;;qBAOvC,SAAM,QAAY;;qBAoBlB,iBAAc,UAAc,UAAQ,WAAa;qBAEjD,iBAAc,UAAc"}