@coorax/schema 0.0.0-canary.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/base/classes/component.class.d.ts +23 -0
- package/dist/base/classes/container.class.d.ts +17 -0
- package/dist/base/classes/field.class.d.ts +15 -0
- package/dist/base/classes/tnode.class.d.ts +14 -0
- package/dist/base/index.d.ts +19 -0
- package/dist/base/types/components/components.d.ts +13 -0
- package/dist/base/types/container/container.d.ts +27 -0
- package/dist/base/types/container/division.types.d.ts +3 -0
- package/dist/base/types/container/section.types.d.ts +3 -0
- package/dist/base/types/container/ul-list.types.d.ts +3 -0
- package/dist/base/types/css.types.d.ts +23 -0
- package/dist/base/types/field/divider.types.d.ts +3 -0
- package/dist/base/types/field/field.blockquote.types.d.ts +4 -0
- package/dist/base/types/field/field.caption.types.d.ts +6 -0
- package/dist/base/types/field/field.code.types.d.ts +5 -0
- package/dist/base/types/field/field.d.ts +62 -0
- package/dist/base/types/field/field.document.types.d.ts +3 -0
- package/dist/base/types/field/field.image.types.d.ts +3 -0
- package/dist/base/types/field/field.link.types.d.ts +5 -0
- package/dist/base/types/field/field.media.types.d.ts +5 -0
- package/dist/base/types/field/field.text.types.d.ts +8 -0
- package/dist/base/types/field/field.video.types.d.ts +8 -0
- package/dist/base/types/field/fields.iframe.types.d.ts +7 -0
- package/dist/base/types/field/heading.types.d.ts +3 -0
- package/dist/base/types/field/paragraph.types.d.ts +3 -0
- package/dist/base/types/global.types.d.ts +26 -0
- package/dist/base/types/node/link.types.d.ts +3 -0
- package/dist/base/types/node/node.d.ts +24 -0
- package/dist/base/types/node/span.types.d.ts +3 -0
- package/dist/base/types/tree/tree.d.ts +24 -0
- package/dist/constants/field.constants.d.ts +1 -0
- package/dist/constants/index.d.ts +1 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.js +1230 -0
- package/dist/services/code/code-themes.d.ts +5 -0
- package/dist/services/code/code-tokens.d.ts +5 -0
- package/dist/services/code/index.d.ts +3 -0
- package/dist/services/code/tokenizer.d.ts +7 -0
- package/dist/services/text-marks/index.d.ts +2 -0
- package/dist/services/text-marks/marks.types.d.ts +35 -0
- package/dist/services/text-marks/text.utils.d.ts +6 -0
- package/dist/services/ui/default-styles.d.ts +3 -0
- package/dist/services/ui/pseudo-styles.d.ts +22 -0
- package/dist/services/ui/style.types.d.ts +9 -0
- package/dist/utils/components.utils.d.ts +10 -0
- package/dist/utils/container.utils.d.ts +13 -0
- package/dist/utils/fields.utils.d.ts +33 -0
- package/dist/utils/global.utils.d.ts +47 -0
- package/dist/utils/index.d.ts +6 -0
- package/dist/utils/tnode.utils.d.ts +9 -0
- package/dist/utils/tree.utils.d.ts +11 -0
- package/package.json +46 -0
package/dist/index.js
ADDED
|
@@ -0,0 +1,1230 @@
|
|
|
1
|
+
// src/base/classes/component.class.ts
|
|
2
|
+
class ComponentClass {
|
|
3
|
+
id;
|
|
4
|
+
name;
|
|
5
|
+
tag;
|
|
6
|
+
type;
|
|
7
|
+
props;
|
|
8
|
+
variant = "component";
|
|
9
|
+
order;
|
|
10
|
+
instanceId;
|
|
11
|
+
count;
|
|
12
|
+
updatedAt;
|
|
13
|
+
createdAt;
|
|
14
|
+
constructor(component) {
|
|
15
|
+
this.id = component.id;
|
|
16
|
+
this.name = component.name;
|
|
17
|
+
this.tag = component.tag;
|
|
18
|
+
this.type = component.type;
|
|
19
|
+
this.variant = component.variant;
|
|
20
|
+
this.order = component.order;
|
|
21
|
+
this.props = component.props;
|
|
22
|
+
this.count = component.count;
|
|
23
|
+
this.updatedAt = component.updatedAt;
|
|
24
|
+
this.createdAt = component.createdAt;
|
|
25
|
+
this.instanceId = component.instanceId;
|
|
26
|
+
}
|
|
27
|
+
isInstance() {
|
|
28
|
+
return !!this.instanceId;
|
|
29
|
+
}
|
|
30
|
+
getChildren(_tree) {
|
|
31
|
+
return new Set;
|
|
32
|
+
}
|
|
33
|
+
appendChild(tree) {
|
|
34
|
+
return tree;
|
|
35
|
+
}
|
|
36
|
+
removeChild(tree) {
|
|
37
|
+
return tree;
|
|
38
|
+
}
|
|
39
|
+
getCurrentComponentObject() {
|
|
40
|
+
return {
|
|
41
|
+
id: this.id,
|
|
42
|
+
name: this.name,
|
|
43
|
+
tag: this.tag,
|
|
44
|
+
type: this.type,
|
|
45
|
+
variant: this.variant,
|
|
46
|
+
order: this.order,
|
|
47
|
+
props: this.props,
|
|
48
|
+
count: this.count,
|
|
49
|
+
instanceId: this.instanceId,
|
|
50
|
+
createdAt: this.createdAt,
|
|
51
|
+
updatedAt: this.updatedAt
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
// src/base/classes/container.class.ts
|
|
56
|
+
class ContainerClass {
|
|
57
|
+
id;
|
|
58
|
+
name;
|
|
59
|
+
tag;
|
|
60
|
+
type;
|
|
61
|
+
props;
|
|
62
|
+
variant = "container";
|
|
63
|
+
order;
|
|
64
|
+
constructor(container) {
|
|
65
|
+
this.id = container.id;
|
|
66
|
+
this.name = container.name;
|
|
67
|
+
this.tag = container.tag;
|
|
68
|
+
this.type = container.type;
|
|
69
|
+
this.variant = container.variant;
|
|
70
|
+
this.order = container.order;
|
|
71
|
+
this.props = container.props;
|
|
72
|
+
}
|
|
73
|
+
getChildren(_tree) {
|
|
74
|
+
return new Set;
|
|
75
|
+
}
|
|
76
|
+
appendChild(tree) {
|
|
77
|
+
return tree;
|
|
78
|
+
}
|
|
79
|
+
removeChild(tree) {
|
|
80
|
+
return tree;
|
|
81
|
+
}
|
|
82
|
+
getCurrentContainerObject() {
|
|
83
|
+
return {
|
|
84
|
+
id: this.id,
|
|
85
|
+
name: this.name,
|
|
86
|
+
tag: this.tag,
|
|
87
|
+
type: this.type,
|
|
88
|
+
variant: this.variant,
|
|
89
|
+
order: this.order,
|
|
90
|
+
props: this.props
|
|
91
|
+
};
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
// src/base/classes/field.class.ts
|
|
95
|
+
class FieldClass {
|
|
96
|
+
id;
|
|
97
|
+
name;
|
|
98
|
+
tag;
|
|
99
|
+
type;
|
|
100
|
+
variant = "field";
|
|
101
|
+
containerId;
|
|
102
|
+
props;
|
|
103
|
+
constructor(field) {
|
|
104
|
+
this.id = field.id;
|
|
105
|
+
this.name = field.name;
|
|
106
|
+
this.tag = field.tag;
|
|
107
|
+
this.containerId = field.containerId;
|
|
108
|
+
this.props = field.props;
|
|
109
|
+
this.variant = field.variant;
|
|
110
|
+
this.type = field.type;
|
|
111
|
+
}
|
|
112
|
+
isContainerized() {
|
|
113
|
+
return !!this.containerId;
|
|
114
|
+
}
|
|
115
|
+
getCurrentFieldObject() {
|
|
116
|
+
return {
|
|
117
|
+
id: this.id,
|
|
118
|
+
name: this.name,
|
|
119
|
+
tag: this.tag,
|
|
120
|
+
containerId: this.containerId,
|
|
121
|
+
props: this.props,
|
|
122
|
+
variant: this.variant,
|
|
123
|
+
type: this.type
|
|
124
|
+
};
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
// src/base/classes/tnode.class.ts
|
|
128
|
+
class TNodeClass {
|
|
129
|
+
id;
|
|
130
|
+
tag;
|
|
131
|
+
type;
|
|
132
|
+
name;
|
|
133
|
+
variant;
|
|
134
|
+
fieldId;
|
|
135
|
+
props;
|
|
136
|
+
constructor(tnode) {
|
|
137
|
+
this.id = tnode.id;
|
|
138
|
+
this.name = tnode.name;
|
|
139
|
+
this.variant = tnode.variant;
|
|
140
|
+
this.tag = tnode.tag;
|
|
141
|
+
this.props = tnode.props;
|
|
142
|
+
this.type = tnode.type;
|
|
143
|
+
this.fieldId = tnode.fieldId;
|
|
144
|
+
}
|
|
145
|
+
getCurrentNodeObject() {
|
|
146
|
+
return {
|
|
147
|
+
id: this.id,
|
|
148
|
+
name: this.name,
|
|
149
|
+
variant: this.variant,
|
|
150
|
+
tag: this.tag,
|
|
151
|
+
type: this.type,
|
|
152
|
+
props: this.props,
|
|
153
|
+
fieldId: this.fieldId
|
|
154
|
+
};
|
|
155
|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3JlYXRvclRvb2w+CiA8L3JkZjpEZXNjcmlwdGlvbj4KCiA8cmRmOkRlc2NyaXB0aW9uIHJkZjphYm91dD0nJwogIHhtbG5zOnhtcE1NPSdodHRwOi8vbnMuYWRvYmUuY29tL3hhcC8xLjAvbW0vJz4KICA8eG1wTU06RG9jdW1lbnRJRD54bXAuaWlkOmUzMWNkNzdmLTgzMjgtNDdhYS04NWI0LTRlMDBkZGUwYzI4YjwveG1wTU06RG9jdW1lbnRJRD4KICA8eG1wTU06SW5zdGFuY2VJRD5hZG9iZTpkb2NpZDpzdG9jazo2M2Y2NTBiOC0zMjM3LTQyODktYTgwZS1lMzdjNDlhOWI2MjA8L3htcE1NOkluc3RhbmNlSUQ+CiAgPHhtcE1NOk9yaWdpbmFsRG9jdW1lbnRJRD5hZG9iZTpkb2NpZDpzdG9jazoxNjc5NDQyMTk2PC94bXBNTTpPcmlnaW5hbERvY3VtZW50SUQ+CiA8L3JkZjpEZXNjcmlwdGlvbj4KPC9yZGY6UkRGPgo8L3g6eG1wbWV0YT4KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKPD94cGFja2V0IGVuZD0ndyc/Pv/bAEMAAwICAwICAwMDAwQDAwQFCAUFBAQFCgcHBggMCgwMCwoLCw0OEhANDhEOCwsQFhARExQVFRUMDxcY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AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAH//Z";
|
|
159
|
+
// src/utils/global.utils.ts
|
|
160
|
+
import _ from "lodash";
|
|
161
|
+
function generateRandomId() {
|
|
162
|
+
return `${Date.now().toString(12)}:${crypto.randomUUID()}`;
|
|
163
|
+
}
|
|
164
|
+
function generateId(prefix) {
|
|
165
|
+
return `${prefix}:${crypto.randomUUID()}`;
|
|
166
|
+
}
|
|
167
|
+
function generateFieldId() {
|
|
168
|
+
return generateId("field");
|
|
169
|
+
}
|
|
170
|
+
function generateTNodeId() {
|
|
171
|
+
return generateId("tnode");
|
|
172
|
+
}
|
|
173
|
+
function generateContainerId() {
|
|
174
|
+
return generateId("container");
|
|
175
|
+
}
|
|
176
|
+
function generateComponentId() {
|
|
177
|
+
return generateId("component");
|
|
178
|
+
}
|
|
179
|
+
function generateTreeId() {
|
|
180
|
+
return generateId("tree");
|
|
181
|
+
}
|
|
182
|
+
function generateSubscriberId() {
|
|
183
|
+
return generateId("subscriber");
|
|
184
|
+
}
|
|
185
|
+
function Capitalize(value) {
|
|
186
|
+
return `${value[0].toUpperCase()}${value.slice(1)}`;
|
|
187
|
+
}
|
|
188
|
+
function ObjectEntries(obj) {
|
|
189
|
+
return Object.entries(obj);
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
class CustomObject {
|
|
193
|
+
obj;
|
|
194
|
+
constructor(obj) {
|
|
195
|
+
this.obj = obj;
|
|
196
|
+
}
|
|
197
|
+
filter(predicate) {
|
|
198
|
+
const entries = Object.entries(this.obj);
|
|
199
|
+
const filtered = entries.filter(([key, value]) => predicate(value, key));
|
|
200
|
+
return new CustomObject(Object.fromEntries(filtered));
|
|
201
|
+
}
|
|
202
|
+
pick(...keys) {
|
|
203
|
+
const picked = keys.reduce((acc, key) => {
|
|
204
|
+
acc[key] = this.obj[key];
|
|
205
|
+
return acc;
|
|
206
|
+
}, {});
|
|
207
|
+
return new CustomObject(picked);
|
|
208
|
+
}
|
|
209
|
+
get size() {
|
|
210
|
+
return Object.keys(this.obj).length;
|
|
211
|
+
}
|
|
212
|
+
has(key) {
|
|
213
|
+
return key in this.obj;
|
|
214
|
+
}
|
|
215
|
+
get keys() {
|
|
216
|
+
return Object.keys(this.obj);
|
|
217
|
+
}
|
|
218
|
+
get(key) {
|
|
219
|
+
return this.obj[key];
|
|
220
|
+
}
|
|
221
|
+
baseObject() {
|
|
222
|
+
return this.obj;
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
var isPlainObject = (v) => {
|
|
226
|
+
if (typeof v !== "object" || v === null)
|
|
227
|
+
return false;
|
|
228
|
+
const proto = Object.getPrototypeOf(v);
|
|
229
|
+
return proto === Object.prototype || proto === null;
|
|
230
|
+
};
|
|
231
|
+
function areObjectsTheSame(objA, objB) {
|
|
232
|
+
return _.isEqual(objA, objB);
|
|
233
|
+
}
|
|
234
|
+
var UTILS = {
|
|
235
|
+
generateRandomId,
|
|
236
|
+
generateId,
|
|
237
|
+
generateContainerId,
|
|
238
|
+
generateFieldId,
|
|
239
|
+
generateTreeId,
|
|
240
|
+
generateSubscriberId,
|
|
241
|
+
generateComponentId,
|
|
242
|
+
Capitalize,
|
|
243
|
+
generateTNodeId,
|
|
244
|
+
ObjectEntries,
|
|
245
|
+
isPlainObject
|
|
246
|
+
};
|
|
247
|
+
|
|
248
|
+
// src/utils/components.utils.ts
|
|
249
|
+
function NewComponent(container3, defaultValue) {
|
|
250
|
+
const now = Date.now();
|
|
251
|
+
return new ComponentClass({
|
|
252
|
+
...container3,
|
|
253
|
+
id: UTILS.generateComponentId(),
|
|
254
|
+
variant: "component",
|
|
255
|
+
count: defaultValue?.count ?? 0,
|
|
256
|
+
createdAt: defaultValue?.createdAt ?? now,
|
|
257
|
+
updatedAt: defaultValue?.updatedAt ?? now
|
|
258
|
+
});
|
|
259
|
+
}
|
|
260
|
+
function DeserializeComponent(component2) {
|
|
261
|
+
return new ComponentClass(component2);
|
|
262
|
+
}
|
|
263
|
+
var ComponentsUtils = { NewComponent, DeserializeComponent };
|
|
264
|
+
// src/utils/container.utils.ts
|
|
265
|
+
function NewUlListContainer(defaultValue) {
|
|
266
|
+
return new ContainerClass({
|
|
267
|
+
id: UTILS.generateContainerId(),
|
|
268
|
+
name: "Ul list container",
|
|
269
|
+
type: "list",
|
|
270
|
+
tag: "ul",
|
|
271
|
+
variant: "container",
|
|
272
|
+
props: {},
|
|
273
|
+
order: new Set,
|
|
274
|
+
...defaultValue
|
|
275
|
+
});
|
|
276
|
+
}
|
|
277
|
+
function NewSectionContainer(defaultValue) {
|
|
278
|
+
return new ContainerClass({
|
|
279
|
+
id: UTILS.generateContainerId(),
|
|
280
|
+
name: "Section container",
|
|
281
|
+
type: "section",
|
|
282
|
+
tag: "section",
|
|
283
|
+
variant: "container",
|
|
284
|
+
props: {},
|
|
285
|
+
order: new Set,
|
|
286
|
+
...defaultValue
|
|
287
|
+
});
|
|
288
|
+
}
|
|
289
|
+
function NewContainer(type, defaultValue) {
|
|
290
|
+
switch (type) {
|
|
291
|
+
case "section":
|
|
292
|
+
return NewSectionContainer(defaultValue);
|
|
293
|
+
default:
|
|
294
|
+
return NewUlListContainer(defaultValue);
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
function DeserializeContainer(container3) {
|
|
298
|
+
return new ContainerClass(container3);
|
|
299
|
+
}
|
|
300
|
+
var ContainersUtils = {
|
|
301
|
+
NewContainer,
|
|
302
|
+
DeserializeContainer,
|
|
303
|
+
NewUlListContainer,
|
|
304
|
+
NewSectionContainer
|
|
305
|
+
};
|
|
306
|
+
// src/services/ui/default-styles.ts
|
|
307
|
+
var Text = {
|
|
308
|
+
style: {
|
|
309
|
+
width: "100%",
|
|
310
|
+
color: "var(--foreground)",
|
|
311
|
+
fontSize: "18px",
|
|
312
|
+
minHeight: "32px",
|
|
313
|
+
whiteSpace: "pre-wrap",
|
|
314
|
+
fontWeight: 400,
|
|
315
|
+
lineHeight: 2,
|
|
316
|
+
display: "block",
|
|
317
|
+
alignItems: "center",
|
|
318
|
+
outline: "none",
|
|
319
|
+
border: "none",
|
|
320
|
+
fieldSizing: "content",
|
|
321
|
+
cursor: "default",
|
|
322
|
+
paddingInline: 4,
|
|
323
|
+
userSelect: "none"
|
|
324
|
+
},
|
|
325
|
+
className: "[&:empty:before]:content-[attr(data-placeholder)] [&:empty:before]:text-muted-foreground [&:empty:before]:pointer-events-none"
|
|
326
|
+
};
|
|
327
|
+
var Heading = {
|
|
328
|
+
style: {
|
|
329
|
+
width: "100%",
|
|
330
|
+
maxWidth: "100%",
|
|
331
|
+
color: "var(--foreground)",
|
|
332
|
+
fontSize: "40px",
|
|
333
|
+
minHeight: "48px",
|
|
334
|
+
fontWeight: 400,
|
|
335
|
+
whiteSpace: "pre-wrap",
|
|
336
|
+
display: "block",
|
|
337
|
+
alignItems: "center",
|
|
338
|
+
outline: "none",
|
|
339
|
+
border: "none",
|
|
340
|
+
fieldSizing: "content",
|
|
341
|
+
cursor: "default",
|
|
342
|
+
paddingInline: 4,
|
|
343
|
+
userSelect: "none"
|
|
344
|
+
},
|
|
345
|
+
className: "[&:empty:before]:content-[attr(data-placeholder)] [&:empty:before]:text-muted-foreground [&:empty:before]:pointer-events-none"
|
|
346
|
+
};
|
|
347
|
+
var Image = {
|
|
348
|
+
style: {
|
|
349
|
+
width: "100%",
|
|
350
|
+
objectFit: "cover",
|
|
351
|
+
display: "block",
|
|
352
|
+
alignItems: "center",
|
|
353
|
+
outline: "none",
|
|
354
|
+
border: "none",
|
|
355
|
+
fieldSizing: "content",
|
|
356
|
+
cursor: "default",
|
|
357
|
+
userSelect: "none"
|
|
358
|
+
}
|
|
359
|
+
};
|
|
360
|
+
var Video = {
|
|
361
|
+
style: {
|
|
362
|
+
width: "100%",
|
|
363
|
+
objectFit: "cover",
|
|
364
|
+
display: "block",
|
|
365
|
+
alignItems: "center",
|
|
366
|
+
outline: "none",
|
|
367
|
+
border: "none",
|
|
368
|
+
fieldSizing: "content",
|
|
369
|
+
cursor: "default",
|
|
370
|
+
userSelect: "none"
|
|
371
|
+
}
|
|
372
|
+
};
|
|
373
|
+
var IFrame = {
|
|
374
|
+
style: {
|
|
375
|
+
width: "100%",
|
|
376
|
+
aspectRatio: "5/3",
|
|
377
|
+
objectFit: "cover",
|
|
378
|
+
display: "block",
|
|
379
|
+
alignItems: "center",
|
|
380
|
+
outline: "none",
|
|
381
|
+
border: "none",
|
|
382
|
+
fieldSizing: "content",
|
|
383
|
+
cursor: "default",
|
|
384
|
+
userSelect: "none"
|
|
385
|
+
}
|
|
386
|
+
};
|
|
387
|
+
var Link = {
|
|
388
|
+
style: {
|
|
389
|
+
width: "100%",
|
|
390
|
+
color: "var(--primary)",
|
|
391
|
+
fontSize: "18px",
|
|
392
|
+
minHeight: "32px",
|
|
393
|
+
whiteSpace: "pre-wrap",
|
|
394
|
+
fontWeight: 400,
|
|
395
|
+
display: "inline-flex",
|
|
396
|
+
lineHeight: 2,
|
|
397
|
+
alignItems: "center",
|
|
398
|
+
outline: "none",
|
|
399
|
+
border: "none",
|
|
400
|
+
fieldSizing: "content",
|
|
401
|
+
cursor: "default",
|
|
402
|
+
paddingInline: 4,
|
|
403
|
+
userSelect: "none"
|
|
404
|
+
},
|
|
405
|
+
className: "[&:empty:before]:content-[attr(data-placeholder)] [&:empty:before]:text-muted-foreground [&:empty:before]:pointer-events-none"
|
|
406
|
+
};
|
|
407
|
+
var Blockquote = {
|
|
408
|
+
style: {
|
|
409
|
+
width: "100%",
|
|
410
|
+
maxWidth: "100%",
|
|
411
|
+
color: "var(--muted-foreground)",
|
|
412
|
+
fontSize: "18px",
|
|
413
|
+
minHeight: "32px",
|
|
414
|
+
fontWeight: 400,
|
|
415
|
+
whiteSpace: "pre-wrap",
|
|
416
|
+
fontStyle: "italic",
|
|
417
|
+
display: "block",
|
|
418
|
+
alignItems: "center",
|
|
419
|
+
outline: "none",
|
|
420
|
+
border: "none",
|
|
421
|
+
fieldSizing: "content",
|
|
422
|
+
cursor: "default",
|
|
423
|
+
paddingInline: 4,
|
|
424
|
+
userSelect: "none"
|
|
425
|
+
},
|
|
426
|
+
className: "[&:empty:before]:content-[attr(data-placeholder)] [&:empty:before]:text-muted-foreground [&:empty:before]:pointer-events-none"
|
|
427
|
+
};
|
|
428
|
+
var Divider = {
|
|
429
|
+
style: {
|
|
430
|
+
width: "100%",
|
|
431
|
+
borderTopWidth: 1,
|
|
432
|
+
borderTopStyle: "solid",
|
|
433
|
+
borderTopColor: "var(--color-muted-foreground)",
|
|
434
|
+
marginBlock: 8,
|
|
435
|
+
outline: "none",
|
|
436
|
+
height: 1,
|
|
437
|
+
position: "relative",
|
|
438
|
+
overflow: "visible"
|
|
439
|
+
},
|
|
440
|
+
pseudoStyle: {
|
|
441
|
+
":before": {
|
|
442
|
+
content: '""',
|
|
443
|
+
position: "absolute",
|
|
444
|
+
top: "-8px",
|
|
445
|
+
bottom: "-8px",
|
|
446
|
+
height: 16,
|
|
447
|
+
left: 0,
|
|
448
|
+
right: 0,
|
|
449
|
+
pointerEvents: "auto",
|
|
450
|
+
zIndex: 5
|
|
451
|
+
}
|
|
452
|
+
}
|
|
453
|
+
};
|
|
454
|
+
var Code = {
|
|
455
|
+
style: {
|
|
456
|
+
width: "100%",
|
|
457
|
+
maxWidth: "100%",
|
|
458
|
+
color: "var(--foreground)",
|
|
459
|
+
fontSize: "14px",
|
|
460
|
+
fontFamily: "ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, 'Liberation Mono', monospace",
|
|
461
|
+
minHeight: "40px",
|
|
462
|
+
fontWeight: 400,
|
|
463
|
+
lineHeight: 1.7,
|
|
464
|
+
whiteSpace: "pre-wrap",
|
|
465
|
+
display: "block",
|
|
466
|
+
outline: "none",
|
|
467
|
+
border: "1px solid var(--border)",
|
|
468
|
+
fieldSizing: "content",
|
|
469
|
+
cursor: "default",
|
|
470
|
+
padding: 12,
|
|
471
|
+
userSelect: "none"
|
|
472
|
+
},
|
|
473
|
+
className: "[&:empty:before]:content-[attr(data-placeholder)] [&:empty:before]:text-muted-foreground [&:empty:before]:pointer-events-none bg-foreground dark:bg-transparent"
|
|
474
|
+
};
|
|
475
|
+
var Caption = {
|
|
476
|
+
style: {
|
|
477
|
+
width: "100%",
|
|
478
|
+
maxWidth: "100%",
|
|
479
|
+
color: "var(--muted-foreground)",
|
|
480
|
+
fontSize: "14px",
|
|
481
|
+
minHeight: "24px",
|
|
482
|
+
fontWeight: 400,
|
|
483
|
+
lineHeight: 1.5,
|
|
484
|
+
whiteSpace: "pre-wrap",
|
|
485
|
+
display: "block",
|
|
486
|
+
textAlign: "center",
|
|
487
|
+
outline: "none",
|
|
488
|
+
border: "none",
|
|
489
|
+
fieldSizing: "content",
|
|
490
|
+
cursor: "default",
|
|
491
|
+
paddingInline: 4,
|
|
492
|
+
paddingBottom: 4,
|
|
493
|
+
userSelect: "none"
|
|
494
|
+
},
|
|
495
|
+
className: "[&:empty:before]:content-[attr(data-placeholder)] [&:empty:before]:text-muted-foreground [&:empty:before]:pointer-events-none"
|
|
496
|
+
};
|
|
497
|
+
var DEFAULT_STYLES = {
|
|
498
|
+
text: Text,
|
|
499
|
+
heading: Heading,
|
|
500
|
+
image: Image,
|
|
501
|
+
divider: Divider,
|
|
502
|
+
video: Video,
|
|
503
|
+
iframe: IFrame,
|
|
504
|
+
blockquote: Blockquote,
|
|
505
|
+
link: Link,
|
|
506
|
+
code: Code,
|
|
507
|
+
caption: Caption
|
|
508
|
+
};
|
|
509
|
+
|
|
510
|
+
// src/utils/fields.utils.ts
|
|
511
|
+
function isEditableField(block) {
|
|
512
|
+
return block.variant === "field" && isEditableType(block.type);
|
|
513
|
+
}
|
|
514
|
+
function isEditableType(type) {
|
|
515
|
+
return type === "heading" || type === "text" || type === "blockquote" || type === "link" || type === "code" || type === "caption";
|
|
516
|
+
}
|
|
517
|
+
function isMediaField(block) {
|
|
518
|
+
return block.variant === "field" && isMediaType(block.type);
|
|
519
|
+
}
|
|
520
|
+
function isMediaType(type) {
|
|
521
|
+
return type === "image" || type === "video" || type === "iframe";
|
|
522
|
+
}
|
|
523
|
+
function getIframeSrc(value) {
|
|
524
|
+
const input = value.trim();
|
|
525
|
+
const normalizedInput = input.startsWith("//") ? `https:${input}` : /^[a-z][\w+.-]*:\/\//i.test(input) ? input : `https://${input}`;
|
|
526
|
+
let url;
|
|
527
|
+
try {
|
|
528
|
+
url = new URL(normalizedInput);
|
|
529
|
+
} catch {
|
|
530
|
+
return value;
|
|
531
|
+
}
|
|
532
|
+
const hostname = url.hostname.toLowerCase().replace(/^www\./, "");
|
|
533
|
+
const isYouTube = ["youtube.com", "m.youtube.com", "music.youtube.com", "youtu.be"].includes(hostname);
|
|
534
|
+
if (!isYouTube)
|
|
535
|
+
return value;
|
|
536
|
+
const segments = url.pathname.split("/").filter(Boolean);
|
|
537
|
+
const videoId = hostname === "youtu.be" ? segments[0] : segments[0] === "watch" ? url.searchParams.get("v") : ["embed", "shorts", "live"].includes(segments[0] ?? "") ? segments[1] : undefined;
|
|
538
|
+
if (!videoId || !/^[\w-]{11}$/.test(videoId))
|
|
539
|
+
return null;
|
|
540
|
+
return `https://www.youtube.com/embed/${videoId}`;
|
|
541
|
+
}
|
|
542
|
+
function NewTextField(defaultValue) {
|
|
543
|
+
return new FieldClass({
|
|
544
|
+
id: UTILS.generateFieldId(),
|
|
545
|
+
name: "Text field",
|
|
546
|
+
type: "text",
|
|
547
|
+
tag: "p",
|
|
548
|
+
variant: "field",
|
|
549
|
+
props: {
|
|
550
|
+
children: { text: "", marks: [] },
|
|
551
|
+
"data-text-path": "props.children",
|
|
552
|
+
contentEditable: false,
|
|
553
|
+
...DEFAULT_STYLES["text"]
|
|
554
|
+
},
|
|
555
|
+
...defaultValue
|
|
556
|
+
});
|
|
557
|
+
}
|
|
558
|
+
function NewHeadingField(defaultValue) {
|
|
559
|
+
return new FieldClass({
|
|
560
|
+
id: UTILS.generateFieldId(),
|
|
561
|
+
name: "Heading field",
|
|
562
|
+
type: "heading",
|
|
563
|
+
tag: "h1",
|
|
564
|
+
variant: "field",
|
|
565
|
+
props: {
|
|
566
|
+
children: { text: "", marks: [] },
|
|
567
|
+
"data-text-path": "props.children",
|
|
568
|
+
contentEditable: false,
|
|
569
|
+
...DEFAULT_STYLES["heading"]
|
|
570
|
+
},
|
|
571
|
+
...defaultValue
|
|
572
|
+
});
|
|
573
|
+
}
|
|
574
|
+
function NewImageField(defaultValue) {
|
|
575
|
+
return new FieldClass({
|
|
576
|
+
id: UTILS.generateFieldId(),
|
|
577
|
+
name: "Image field",
|
|
578
|
+
type: "image",
|
|
579
|
+
tag: "img",
|
|
580
|
+
variant: "field",
|
|
581
|
+
props: {
|
|
582
|
+
src: "",
|
|
583
|
+
alt: "image",
|
|
584
|
+
...DEFAULT_STYLES["image"]
|
|
585
|
+
},
|
|
586
|
+
...defaultValue
|
|
587
|
+
});
|
|
588
|
+
}
|
|
589
|
+
function NewVideoField(defaultValue) {
|
|
590
|
+
return new FieldClass({
|
|
591
|
+
id: UTILS.generateFieldId(),
|
|
592
|
+
name: "Video field",
|
|
593
|
+
type: "video",
|
|
594
|
+
tag: "video",
|
|
595
|
+
variant: "field",
|
|
596
|
+
props: {
|
|
597
|
+
src: "",
|
|
598
|
+
alt: "video",
|
|
599
|
+
controlsList: "nodownload nofullscreen noremoteplayback noplaybackrate",
|
|
600
|
+
preload: "metadata",
|
|
601
|
+
controls: true,
|
|
602
|
+
...DEFAULT_STYLES["video"]
|
|
603
|
+
},
|
|
604
|
+
...defaultValue
|
|
605
|
+
});
|
|
606
|
+
}
|
|
607
|
+
function NewIFrameField(defaultValue) {
|
|
608
|
+
return new FieldClass({
|
|
609
|
+
id: UTILS.generateFieldId(),
|
|
610
|
+
name: "IFrame field",
|
|
611
|
+
type: "iframe",
|
|
612
|
+
tag: "iframe",
|
|
613
|
+
variant: "field",
|
|
614
|
+
props: {
|
|
615
|
+
src: "",
|
|
616
|
+
alt: "image",
|
|
617
|
+
allow: "accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share",
|
|
618
|
+
referrerPolicy: "strict-origin-when-cross-origin",
|
|
619
|
+
allowFullScreen: false,
|
|
620
|
+
frameBorder: 0,
|
|
621
|
+
...DEFAULT_STYLES["iframe"]
|
|
622
|
+
},
|
|
623
|
+
...defaultValue
|
|
624
|
+
});
|
|
625
|
+
}
|
|
626
|
+
function NewLinkField(defaultValue) {
|
|
627
|
+
return new FieldClass({
|
|
628
|
+
id: UTILS.generateFieldId(),
|
|
629
|
+
name: "Link field",
|
|
630
|
+
type: "link",
|
|
631
|
+
tag: "a",
|
|
632
|
+
variant: "field",
|
|
633
|
+
props: {
|
|
634
|
+
href: "#",
|
|
635
|
+
alt: "Preview new link",
|
|
636
|
+
"data-text-path": "props.children",
|
|
637
|
+
children: { text: "Preview new link", marks: [] },
|
|
638
|
+
...DEFAULT_STYLES["link"]
|
|
639
|
+
},
|
|
640
|
+
...defaultValue
|
|
641
|
+
});
|
|
642
|
+
}
|
|
643
|
+
function NewBlockquoteField(defaultValue) {
|
|
644
|
+
return new FieldClass({
|
|
645
|
+
id: UTILS.generateFieldId(),
|
|
646
|
+
name: "Blockquote field",
|
|
647
|
+
type: "blockquote",
|
|
648
|
+
tag: "blockquote",
|
|
649
|
+
variant: "field",
|
|
650
|
+
props: {
|
|
651
|
+
"data-text-path": "props.children",
|
|
652
|
+
children: { text: "", marks: [] },
|
|
653
|
+
...DEFAULT_STYLES["blockquote"]
|
|
654
|
+
},
|
|
655
|
+
...defaultValue
|
|
656
|
+
});
|
|
657
|
+
}
|
|
658
|
+
function NewDividerField(defaultValue) {
|
|
659
|
+
return new FieldClass({
|
|
660
|
+
id: UTILS.generateFieldId(),
|
|
661
|
+
name: "Divider field",
|
|
662
|
+
type: "divider",
|
|
663
|
+
tag: "hr",
|
|
664
|
+
variant: "field",
|
|
665
|
+
props: {
|
|
666
|
+
...DEFAULT_STYLES["divider"]
|
|
667
|
+
},
|
|
668
|
+
...defaultValue
|
|
669
|
+
});
|
|
670
|
+
}
|
|
671
|
+
function NewCodeField(defaultValue) {
|
|
672
|
+
return new FieldClass({
|
|
673
|
+
id: UTILS.generateFieldId(),
|
|
674
|
+
name: "Code field",
|
|
675
|
+
type: "code",
|
|
676
|
+
tag: "pre",
|
|
677
|
+
variant: "field",
|
|
678
|
+
props: {
|
|
679
|
+
"data-text-path": "props.children",
|
|
680
|
+
children: { text: "", marks: [] },
|
|
681
|
+
theme: "dark",
|
|
682
|
+
contentEditable: false,
|
|
683
|
+
...DEFAULT_STYLES["code"]
|
|
684
|
+
},
|
|
685
|
+
...defaultValue
|
|
686
|
+
});
|
|
687
|
+
}
|
|
688
|
+
function NewCaptionField(defaultValue) {
|
|
689
|
+
return new FieldClass({
|
|
690
|
+
id: UTILS.generateFieldId(),
|
|
691
|
+
name: "Caption field",
|
|
692
|
+
type: "caption",
|
|
693
|
+
tag: "figcaption",
|
|
694
|
+
variant: "field",
|
|
695
|
+
props: {
|
|
696
|
+
"data-text-path": "props.children",
|
|
697
|
+
children: { text: "", marks: [] },
|
|
698
|
+
contentEditable: false,
|
|
699
|
+
...DEFAULT_STYLES["caption"]
|
|
700
|
+
},
|
|
701
|
+
...defaultValue
|
|
702
|
+
});
|
|
703
|
+
}
|
|
704
|
+
function NewField(type, defaultValue) {
|
|
705
|
+
switch (type) {
|
|
706
|
+
case "text":
|
|
707
|
+
return NewTextField(defaultValue);
|
|
708
|
+
case "heading":
|
|
709
|
+
return NewHeadingField(defaultValue);
|
|
710
|
+
case "image":
|
|
711
|
+
return NewImageField(defaultValue);
|
|
712
|
+
case "video":
|
|
713
|
+
return NewVideoField(defaultValue);
|
|
714
|
+
case "link":
|
|
715
|
+
return NewLinkField(defaultValue);
|
|
716
|
+
case "divider":
|
|
717
|
+
return NewDividerField(defaultValue);
|
|
718
|
+
case "iframe":
|
|
719
|
+
return NewIFrameField(defaultValue);
|
|
720
|
+
case "blockquote":
|
|
721
|
+
return NewBlockquoteField(defaultValue);
|
|
722
|
+
case "code":
|
|
723
|
+
return NewCodeField(defaultValue);
|
|
724
|
+
case "caption":
|
|
725
|
+
return NewCaptionField(defaultValue);
|
|
726
|
+
default:
|
|
727
|
+
return NewTextField(defaultValue);
|
|
728
|
+
}
|
|
729
|
+
}
|
|
730
|
+
function DeserializeField(field4) {
|
|
731
|
+
return new FieldClass(field4);
|
|
732
|
+
}
|
|
733
|
+
var FieldsUtils = {
|
|
734
|
+
NewField,
|
|
735
|
+
DeserializeField,
|
|
736
|
+
NewTextField,
|
|
737
|
+
NewHeadingField,
|
|
738
|
+
NewLinkField,
|
|
739
|
+
NewImageField,
|
|
740
|
+
NewDividerField,
|
|
741
|
+
NewIFrameField,
|
|
742
|
+
NewBlockquoteField,
|
|
743
|
+
NewCodeField,
|
|
744
|
+
NewCaptionField
|
|
745
|
+
};
|
|
746
|
+
// src/utils/tnode.utils.ts
|
|
747
|
+
function NewLinkTNode(defaultValue) {
|
|
748
|
+
return new TNodeClass({
|
|
749
|
+
id: UTILS.generateTNodeId(),
|
|
750
|
+
name: "Link tnode",
|
|
751
|
+
type: "link",
|
|
752
|
+
tag: "a",
|
|
753
|
+
variant: "tnode",
|
|
754
|
+
props: { style: {}, text: "" },
|
|
755
|
+
...defaultValue
|
|
756
|
+
});
|
|
757
|
+
}
|
|
758
|
+
function NewSpanTNode(defaultValue) {
|
|
759
|
+
return new TNodeClass({
|
|
760
|
+
id: UTILS.generateTNodeId(),
|
|
761
|
+
name: "Sub-field tnode",
|
|
762
|
+
type: "sub-field",
|
|
763
|
+
tag: "span",
|
|
764
|
+
variant: "tnode",
|
|
765
|
+
props: { style: {}, text: "" },
|
|
766
|
+
...defaultValue
|
|
767
|
+
});
|
|
768
|
+
}
|
|
769
|
+
function NewTNode(type, defaultValue) {
|
|
770
|
+
switch (type) {
|
|
771
|
+
case "link":
|
|
772
|
+
return NewLinkTNode(defaultValue);
|
|
773
|
+
default:
|
|
774
|
+
return NewSpanTNode(defaultValue);
|
|
775
|
+
}
|
|
776
|
+
}
|
|
777
|
+
function DeserializeTNode(tnode2) {
|
|
778
|
+
return new TNodeClass(tnode2);
|
|
779
|
+
}
|
|
780
|
+
var TNodesUtils = { NewTNode, DeserializeTNode };
|
|
781
|
+
// src/utils/tree.utils.ts
|
|
782
|
+
function SerializeTree(tree2) {
|
|
783
|
+
const newFields = Array.from(tree2.fields.entries()).reduce((prev, [id, currentField]) => {
|
|
784
|
+
prev[id] = currentField.getCurrentFieldObject();
|
|
785
|
+
return prev;
|
|
786
|
+
}, {});
|
|
787
|
+
const newContainers = Array.from(tree2.containers.entries()).reduce((prev, [id, currentContainer]) => {
|
|
788
|
+
prev[id] = currentContainer.getCurrentContainerObject();
|
|
789
|
+
return prev;
|
|
790
|
+
}, {});
|
|
791
|
+
const newComponents = Array.from(tree2.components.entries()).reduce((prev, [id, currentComponent]) => {
|
|
792
|
+
prev[id] = currentComponent.getCurrentComponentObject();
|
|
793
|
+
return prev;
|
|
794
|
+
}, {});
|
|
795
|
+
return {
|
|
796
|
+
id: tree2.id,
|
|
797
|
+
version: tree2.version,
|
|
798
|
+
order: [...tree2.order],
|
|
799
|
+
fields: newFields,
|
|
800
|
+
containers: newContainers,
|
|
801
|
+
components: newComponents
|
|
802
|
+
};
|
|
803
|
+
}
|
|
804
|
+
function DeserializeTree(tree2) {
|
|
805
|
+
const newFields = UTILS.ObjectEntries(tree2.fields).reduce((prev, [id, currentField]) => {
|
|
806
|
+
prev.set(id, FieldsUtils.DeserializeField(currentField));
|
|
807
|
+
return prev;
|
|
808
|
+
}, new Map);
|
|
809
|
+
const newContainers = UTILS.ObjectEntries(tree2.containers).reduce((prev, [id, currentContainer]) => {
|
|
810
|
+
prev.set(id, ContainersUtils.DeserializeContainer(currentContainer));
|
|
811
|
+
return prev;
|
|
812
|
+
}, new Map);
|
|
813
|
+
const newComponents = UTILS.ObjectEntries(tree2.components).reduce((prev, [id, currentComponent]) => {
|
|
814
|
+
prev.set(id, ComponentsUtils.DeserializeComponent(currentComponent));
|
|
815
|
+
return prev;
|
|
816
|
+
}, new Map);
|
|
817
|
+
return {
|
|
818
|
+
id: tree2.id,
|
|
819
|
+
version: tree2.version,
|
|
820
|
+
order: new Set(tree2.order),
|
|
821
|
+
fields: newFields,
|
|
822
|
+
containers: newContainers,
|
|
823
|
+
components: newComponents
|
|
824
|
+
};
|
|
825
|
+
}
|
|
826
|
+
function GetDefaultTree() {
|
|
827
|
+
return {
|
|
828
|
+
id: "root",
|
|
829
|
+
version: "0.0.0",
|
|
830
|
+
order: new Set,
|
|
831
|
+
fields: new Map,
|
|
832
|
+
containers: new Map,
|
|
833
|
+
components: new Map
|
|
834
|
+
};
|
|
835
|
+
}
|
|
836
|
+
var KINDS = ["fields", "containers", "components"];
|
|
837
|
+
function coraxTreeDiffing(prev, next) {
|
|
838
|
+
const added = new Set, removed = new Set, changed = new Set;
|
|
839
|
+
for (const kind of KINDS) {
|
|
840
|
+
const a = prev[kind];
|
|
841
|
+
const b = next[kind];
|
|
842
|
+
if (a === b)
|
|
843
|
+
continue;
|
|
844
|
+
const bKeys = b.keys();
|
|
845
|
+
for (const id of bKeys) {
|
|
846
|
+
if (!a.has(id))
|
|
847
|
+
added.add(id);
|
|
848
|
+
else if (a.get(id) !== b.get(id))
|
|
849
|
+
changed.add(id);
|
|
850
|
+
}
|
|
851
|
+
const aKeys = a.keys();
|
|
852
|
+
for (const id of aKeys)
|
|
853
|
+
if (!b.has(id))
|
|
854
|
+
removed.add(id);
|
|
855
|
+
}
|
|
856
|
+
return { added, removed, changed, orderChanged: prev.order !== next.order };
|
|
857
|
+
}
|
|
858
|
+
// src/services/text-marks/text.utils.ts
|
|
859
|
+
function segments({ text, marks }) {
|
|
860
|
+
if (!text)
|
|
861
|
+
return [];
|
|
862
|
+
const cuts = new Set([0, text.length]);
|
|
863
|
+
for (const m of marks) {
|
|
864
|
+
cuts.add(m.start);
|
|
865
|
+
cuts.add(m.end);
|
|
866
|
+
}
|
|
867
|
+
const points = [...cuts].sort((a, b) => a - b);
|
|
868
|
+
const out = [];
|
|
869
|
+
for (let i = 0;i < points.length - 1; i++) {
|
|
870
|
+
const [s, e] = [points[i], points[i + 1]];
|
|
871
|
+
out.push({
|
|
872
|
+
text: text.slice(s, e),
|
|
873
|
+
marks: marks.filter((m) => m.start <= s && m.end >= e)
|
|
874
|
+
});
|
|
875
|
+
}
|
|
876
|
+
return out;
|
|
877
|
+
}
|
|
878
|
+
// src/services/ui/pseudo-styles.ts
|
|
879
|
+
var UNITLESS = new Set([
|
|
880
|
+
"animationIterationCount",
|
|
881
|
+
"aspectRatio",
|
|
882
|
+
"borderImageOutset",
|
|
883
|
+
"borderImageSlice",
|
|
884
|
+
"borderImageWidth",
|
|
885
|
+
"boxFlex",
|
|
886
|
+
"boxFlexGroup",
|
|
887
|
+
"boxOrdinalGroup",
|
|
888
|
+
"columnCount",
|
|
889
|
+
"columns",
|
|
890
|
+
"flex",
|
|
891
|
+
"flexGrow",
|
|
892
|
+
"flexPositive",
|
|
893
|
+
"flexShrink",
|
|
894
|
+
"flexNegative",
|
|
895
|
+
"flexOrder",
|
|
896
|
+
"gridArea",
|
|
897
|
+
"gridRow",
|
|
898
|
+
"gridRowEnd",
|
|
899
|
+
"gridRowSpan",
|
|
900
|
+
"gridRowStart",
|
|
901
|
+
"gridColumn",
|
|
902
|
+
"gridColumnEnd",
|
|
903
|
+
"gridColumnSpan",
|
|
904
|
+
"gridColumnStart",
|
|
905
|
+
"fontWeight",
|
|
906
|
+
"lineClamp",
|
|
907
|
+
"lineHeight",
|
|
908
|
+
"opacity",
|
|
909
|
+
"order",
|
|
910
|
+
"orphans",
|
|
911
|
+
"scale",
|
|
912
|
+
"tabSize",
|
|
913
|
+
"widows",
|
|
914
|
+
"zIndex",
|
|
915
|
+
"zoom",
|
|
916
|
+
"fillOpacity",
|
|
917
|
+
"floodOpacity",
|
|
918
|
+
"stopOpacity",
|
|
919
|
+
"strokeDasharray",
|
|
920
|
+
"strokeDashoffset",
|
|
921
|
+
"strokeMiterlimit",
|
|
922
|
+
"strokeOpacity",
|
|
923
|
+
"strokeWidth"
|
|
924
|
+
]);
|
|
925
|
+
function toKebab(property) {
|
|
926
|
+
return property.replace(/[A-Z]/g, (m) => `-${m.toLowerCase()}`);
|
|
927
|
+
}
|
|
928
|
+
function toCssValue(property, value) {
|
|
929
|
+
if (Array.isArray(value))
|
|
930
|
+
return value.map((v) => String(v)).join(",");
|
|
931
|
+
if (typeof value === "number" && value !== 0 && !UNITLESS.has(property))
|
|
932
|
+
return `${value}px`;
|
|
933
|
+
return String(value);
|
|
934
|
+
}
|
|
935
|
+
function declarations(style) {
|
|
936
|
+
return Object.entries(style).map(([property, value]) => `${toKebab(property)}:${toCssValue(property, value)}`).join(";");
|
|
937
|
+
}
|
|
938
|
+
function serializeRules(style, selector) {
|
|
939
|
+
const rules = [];
|
|
940
|
+
const own = {};
|
|
941
|
+
for (const [key, value] of Object.entries(style)) {
|
|
942
|
+
if (value && typeof value === "object") {
|
|
943
|
+
rules.push(...serializeRules(value, `${selector}${key}`));
|
|
944
|
+
} else {
|
|
945
|
+
own[key] = value;
|
|
946
|
+
}
|
|
947
|
+
}
|
|
948
|
+
if (Object.keys(own).length > 0)
|
|
949
|
+
rules.push(`${selector}{${declarations(own)}}`);
|
|
950
|
+
return rules;
|
|
951
|
+
}
|
|
952
|
+
function stableStringify(value) {
|
|
953
|
+
if (value === null || typeof value !== "object")
|
|
954
|
+
return JSON.stringify(value) ?? "null";
|
|
955
|
+
if (Array.isArray(value))
|
|
956
|
+
return `[${value.map(stableStringify).join(",")}]`;
|
|
957
|
+
const entries = Object.entries(value).sort(([a], [b]) => a < b ? -1 : a > b ? 1 : 0).map(([k, v]) => `${JSON.stringify(k)}:${stableStringify(v)}`);
|
|
958
|
+
return `{${entries.join(",")}}`;
|
|
959
|
+
}
|
|
960
|
+
function hash(input) {
|
|
961
|
+
let h = 2166136261;
|
|
962
|
+
for (let i = 0;i < input.length; i++) {
|
|
963
|
+
h ^= input.charCodeAt(i);
|
|
964
|
+
h = Math.imul(h, 16777619);
|
|
965
|
+
}
|
|
966
|
+
return (h >>> 0).toString(36);
|
|
967
|
+
}
|
|
968
|
+
var collected = new Map;
|
|
969
|
+
var sink = null;
|
|
970
|
+
function collectCoraxPseudoStyle(style) {
|
|
971
|
+
if (!style || Object.keys(style).length === 0)
|
|
972
|
+
return;
|
|
973
|
+
const className = `corax-p-${hash(stableStringify(style))}`;
|
|
974
|
+
if (collected.has(className))
|
|
975
|
+
return className;
|
|
976
|
+
collected.set(className, serializeRules(style, `.${className}`).join(""));
|
|
977
|
+
sink?.();
|
|
978
|
+
return className;
|
|
979
|
+
}
|
|
980
|
+
function getCollectedStyles() {
|
|
981
|
+
return Array.from(collected.values()).join("");
|
|
982
|
+
}
|
|
983
|
+
function clearCollectedStyles() {
|
|
984
|
+
collected.clear();
|
|
985
|
+
}
|
|
986
|
+
function setCoraxStyleSink(fn) {
|
|
987
|
+
sink = fn;
|
|
988
|
+
fn();
|
|
989
|
+
return () => {
|
|
990
|
+
if (sink === fn)
|
|
991
|
+
sink = null;
|
|
992
|
+
};
|
|
993
|
+
}
|
|
994
|
+
// src/services/code/code-themes.ts
|
|
995
|
+
var CODE_THEMES = {
|
|
996
|
+
dark: {
|
|
997
|
+
plain: "#e6edf3",
|
|
998
|
+
keyword: "#ff7b72",
|
|
999
|
+
string: "#a5d6ff",
|
|
1000
|
+
number: "#79c0ff",
|
|
1001
|
+
comment: "#8b949e",
|
|
1002
|
+
function: "#d2a8ff",
|
|
1003
|
+
punctuation: "#e6edf3",
|
|
1004
|
+
operator: "#ff7b72"
|
|
1005
|
+
},
|
|
1006
|
+
light: {
|
|
1007
|
+
plain: "#24292f",
|
|
1008
|
+
keyword: "#cf222e",
|
|
1009
|
+
string: "#0a3069",
|
|
1010
|
+
number: "#0550ae",
|
|
1011
|
+
comment: "#6e7781",
|
|
1012
|
+
function: "#8250df",
|
|
1013
|
+
punctuation: "#24292f",
|
|
1014
|
+
operator: "#cf222e"
|
|
1015
|
+
}
|
|
1016
|
+
};
|
|
1017
|
+
var CODE_THEME_NAMES = Object.keys(CODE_THEMES);
|
|
1018
|
+
// src/services/code/tokenizer.ts
|
|
1019
|
+
var KEYWORDS = new Set([
|
|
1020
|
+
"const",
|
|
1021
|
+
"let",
|
|
1022
|
+
"var",
|
|
1023
|
+
"function",
|
|
1024
|
+
"class",
|
|
1025
|
+
"extends",
|
|
1026
|
+
"return",
|
|
1027
|
+
"if",
|
|
1028
|
+
"else",
|
|
1029
|
+
"for",
|
|
1030
|
+
"while",
|
|
1031
|
+
"do",
|
|
1032
|
+
"switch",
|
|
1033
|
+
"case",
|
|
1034
|
+
"break",
|
|
1035
|
+
"continue",
|
|
1036
|
+
"new",
|
|
1037
|
+
"typeof",
|
|
1038
|
+
"instanceof",
|
|
1039
|
+
"in",
|
|
1040
|
+
"of",
|
|
1041
|
+
"this",
|
|
1042
|
+
"super",
|
|
1043
|
+
"import",
|
|
1044
|
+
"export",
|
|
1045
|
+
"from",
|
|
1046
|
+
"default",
|
|
1047
|
+
"as",
|
|
1048
|
+
"async",
|
|
1049
|
+
"await",
|
|
1050
|
+
"yield",
|
|
1051
|
+
"try",
|
|
1052
|
+
"catch",
|
|
1053
|
+
"finally",
|
|
1054
|
+
"throw",
|
|
1055
|
+
"delete",
|
|
1056
|
+
"void",
|
|
1057
|
+
"null",
|
|
1058
|
+
"undefined",
|
|
1059
|
+
"true",
|
|
1060
|
+
"false",
|
|
1061
|
+
"interface",
|
|
1062
|
+
"type",
|
|
1063
|
+
"enum",
|
|
1064
|
+
"implements",
|
|
1065
|
+
"public",
|
|
1066
|
+
"private",
|
|
1067
|
+
"protected",
|
|
1068
|
+
"readonly",
|
|
1069
|
+
"static",
|
|
1070
|
+
"get",
|
|
1071
|
+
"set",
|
|
1072
|
+
"declare",
|
|
1073
|
+
"namespace",
|
|
1074
|
+
"abstract",
|
|
1075
|
+
"satisfies",
|
|
1076
|
+
"keyof",
|
|
1077
|
+
"infer",
|
|
1078
|
+
"is",
|
|
1079
|
+
"any",
|
|
1080
|
+
"string",
|
|
1081
|
+
"number",
|
|
1082
|
+
"boolean",
|
|
1083
|
+
"never",
|
|
1084
|
+
"unknown",
|
|
1085
|
+
"object",
|
|
1086
|
+
"symbol",
|
|
1087
|
+
"bigint"
|
|
1088
|
+
]);
|
|
1089
|
+
var isIdentStart = (c) => /[A-Za-z_$]/.test(c);
|
|
1090
|
+
var isIdentPart = (c) => /[A-Za-z0-9_$]/.test(c);
|
|
1091
|
+
var isDigit = (c) => c >= "0" && c <= "9";
|
|
1092
|
+
function tokenizeCode(input) {
|
|
1093
|
+
const tokens = [];
|
|
1094
|
+
const push = (type, value) => {
|
|
1095
|
+
if (!value)
|
|
1096
|
+
return;
|
|
1097
|
+
const last = tokens[tokens.length - 1];
|
|
1098
|
+
if (last && last.type === type)
|
|
1099
|
+
last.value += value;
|
|
1100
|
+
else
|
|
1101
|
+
tokens.push({ type, value });
|
|
1102
|
+
};
|
|
1103
|
+
let i = 0;
|
|
1104
|
+
const n = input.length;
|
|
1105
|
+
while (i < n) {
|
|
1106
|
+
const c = input[i];
|
|
1107
|
+
const next = input[i + 1];
|
|
1108
|
+
if (/\s/.test(c)) {
|
|
1109
|
+
let j = i + 1;
|
|
1110
|
+
while (j < n && /\s/.test(input[j]))
|
|
1111
|
+
j++;
|
|
1112
|
+
push("plain", input.slice(i, j));
|
|
1113
|
+
i = j;
|
|
1114
|
+
continue;
|
|
1115
|
+
}
|
|
1116
|
+
if (c === "/" && next === "/") {
|
|
1117
|
+
let j = i + 2;
|
|
1118
|
+
while (j < n && input[j] !== `
|
|
1119
|
+
`)
|
|
1120
|
+
j++;
|
|
1121
|
+
push("comment", input.slice(i, j));
|
|
1122
|
+
i = j;
|
|
1123
|
+
continue;
|
|
1124
|
+
}
|
|
1125
|
+
if (c === "/" && next === "*") {
|
|
1126
|
+
let j = i + 2;
|
|
1127
|
+
while (j < n && !(input[j] === "*" && input[j + 1] === "/"))
|
|
1128
|
+
j++;
|
|
1129
|
+
j = Math.min(n, j + 2);
|
|
1130
|
+
push("comment", input.slice(i, j));
|
|
1131
|
+
i = j;
|
|
1132
|
+
continue;
|
|
1133
|
+
}
|
|
1134
|
+
if (c === '"' || c === "'" || c === "`") {
|
|
1135
|
+
let j = i + 1;
|
|
1136
|
+
while (j < n) {
|
|
1137
|
+
if (input[j] === "\\") {
|
|
1138
|
+
j += 2;
|
|
1139
|
+
continue;
|
|
1140
|
+
}
|
|
1141
|
+
if (input[j] === c) {
|
|
1142
|
+
j++;
|
|
1143
|
+
break;
|
|
1144
|
+
}
|
|
1145
|
+
if (c !== "`" && input[j] === `
|
|
1146
|
+
`)
|
|
1147
|
+
break;
|
|
1148
|
+
j++;
|
|
1149
|
+
}
|
|
1150
|
+
push("string", input.slice(i, j));
|
|
1151
|
+
i = j;
|
|
1152
|
+
continue;
|
|
1153
|
+
}
|
|
1154
|
+
if (isDigit(c)) {
|
|
1155
|
+
let j = i;
|
|
1156
|
+
while (j < n && /[0-9a-fA-FxXoObBeE._]/.test(input[j]))
|
|
1157
|
+
j++;
|
|
1158
|
+
if (j < n && (input[j] === "+" || input[j] === "-") && /[eE]/.test(input[j - 1]))
|
|
1159
|
+
j++;
|
|
1160
|
+
while (j < n && isDigit(input[j]))
|
|
1161
|
+
j++;
|
|
1162
|
+
push("number", input.slice(i, j));
|
|
1163
|
+
i = j;
|
|
1164
|
+
continue;
|
|
1165
|
+
}
|
|
1166
|
+
if (isIdentStart(c)) {
|
|
1167
|
+
let j = i + 1;
|
|
1168
|
+
while (j < n && isIdentPart(input[j]))
|
|
1169
|
+
j++;
|
|
1170
|
+
const word = input.slice(i, j);
|
|
1171
|
+
let k = j;
|
|
1172
|
+
while (k < n && /\s/.test(input[k]))
|
|
1173
|
+
k++;
|
|
1174
|
+
if (KEYWORDS.has(word))
|
|
1175
|
+
push("keyword", word);
|
|
1176
|
+
else if (input[k] === "(")
|
|
1177
|
+
push("function", word);
|
|
1178
|
+
else
|
|
1179
|
+
push("plain", word);
|
|
1180
|
+
i = j;
|
|
1181
|
+
continue;
|
|
1182
|
+
}
|
|
1183
|
+
if (/[{}()[\];,.]/.test(c)) {
|
|
1184
|
+
push("punctuation", c);
|
|
1185
|
+
i++;
|
|
1186
|
+
continue;
|
|
1187
|
+
}
|
|
1188
|
+
if (/[=+\-*/%<>!&|^~?:]/.test(c)) {
|
|
1189
|
+
push("operator", c);
|
|
1190
|
+
i++;
|
|
1191
|
+
continue;
|
|
1192
|
+
}
|
|
1193
|
+
push("plain", c);
|
|
1194
|
+
i++;
|
|
1195
|
+
}
|
|
1196
|
+
return tokens;
|
|
1197
|
+
}
|
|
1198
|
+
export {
|
|
1199
|
+
tokenizeCode,
|
|
1200
|
+
setCoraxStyleSink,
|
|
1201
|
+
segments,
|
|
1202
|
+
isMediaType,
|
|
1203
|
+
isMediaField,
|
|
1204
|
+
isEditableType,
|
|
1205
|
+
isEditableField,
|
|
1206
|
+
getIframeSrc,
|
|
1207
|
+
getCollectedStyles,
|
|
1208
|
+
coraxTreeDiffing,
|
|
1209
|
+
hash as coraxStyleHash,
|
|
1210
|
+
collectCoraxPseudoStyle,
|
|
1211
|
+
clearCollectedStyles,
|
|
1212
|
+
areObjectsTheSame,
|
|
1213
|
+
UTILS,
|
|
1214
|
+
TNodesUtils,
|
|
1215
|
+
TNodeClass,
|
|
1216
|
+
SerializeTree,
|
|
1217
|
+
GetDefaultTree,
|
|
1218
|
+
FieldsUtils,
|
|
1219
|
+
FieldClass,
|
|
1220
|
+
DeserializeTree,
|
|
1221
|
+
DEFAULT_STYLES,
|
|
1222
|
+
DEFAULT_IMAGE_PREVIEW,
|
|
1223
|
+
CustomObject,
|
|
1224
|
+
ContainersUtils,
|
|
1225
|
+
ContainerClass,
|
|
1226
|
+
ComponentsUtils,
|
|
1227
|
+
ComponentClass,
|
|
1228
|
+
CODE_THEME_NAMES,
|
|
1229
|
+
CODE_THEMES
|
|
1230
|
+
};
|