@coorax/core 0.0.0-canary.1 → 0.0.0-canary.2
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/types/field/field.blockquote.types.d.ts +4 -0
- package/dist/base/types/field/field.d.ts +14 -3
- package/dist/base/types/field/field.image.types.d.ts +3 -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/global.types.d.ts +2 -0
- package/dist/base/types/tree/tree.d.ts +2 -1
- package/dist/constants/field.constants.d.ts +1 -0
- package/dist/constants/index.d.ts +1 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1174 -388
- package/dist/modules/caption/caption.module.d.ts +35 -0
- package/dist/modules/caption/caption.test.d.ts +1 -0
- package/dist/modules/code/code.module.d.ts +37 -0
- package/dist/modules/deletion/deletion.module.d.ts +26 -0
- package/dist/modules/focus/focus.module.d.ts +1 -1
- package/dist/modules/history/history.module.d.ts +14 -0
- package/dist/modules/hover/hover.module.d.ts +1 -1
- package/dist/modules/index.d.ts +3 -1
- package/dist/modules/insertion/insertion.module.d.ts +18 -1
- package/dist/modules/modules-manager.d.ts +2 -0
- package/dist/modules/selection/selection.module.d.ts +1 -1
- package/dist/modules/text-editing/text-editing.constants.d.ts +1 -1
- package/dist/modules/text-editing/text-editing.module.d.ts +1 -2
- package/dist/modules/text-editing/text-editing.utils.d.ts +1 -1
- package/dist/services/document/document.d.ts +1 -2
- package/dist/services/eventbus/eventbus.d.ts +4 -4
- package/dist/services/eventbus/eventbus.test.d.ts +1 -1
- package/dist/services/eventbus/subscriber.d.ts +4 -4
- package/dist/services/mutations/mutations.d.ts +10 -5
- package/dist/services/tasks/tasks.service.d.ts +1 -1
- package/dist/services/text-marks/index.d.ts +0 -1
- package/dist/services/text-marks/text-marks.d.ts +1 -1
- package/dist/services/ui/contributions.types.d.ts +79 -0
- package/dist/services/ui/default-styles.d.ts +1 -1
- package/dist/services/ui/index.d.ts +0 -1
- package/dist/services/ui/ui.d.ts +7 -6
- package/dist/services/ui/ui.types.d.ts +7 -95
- package/dist/styles.css +1 -536
- package/dist/utils/fields.utils.d.ts +10 -2
- package/dist/utils/index.d.ts +0 -6
- package/package.json +6 -2
- package/styles.css +4 -2
package/dist/index.js
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
//
|
|
1
|
+
// ../schema/dist/index.js
|
|
2
|
+
import _ from "lodash";
|
|
3
|
+
|
|
2
4
|
class ComponentClass {
|
|
3
5
|
id;
|
|
4
6
|
name;
|
|
@@ -52,7 +54,7 @@ class ComponentClass {
|
|
|
52
54
|
};
|
|
53
55
|
}
|
|
54
56
|
}
|
|
55
|
-
|
|
57
|
+
|
|
56
58
|
class ContainerClass {
|
|
57
59
|
id;
|
|
58
60
|
name;
|
|
@@ -91,7 +93,7 @@ class ContainerClass {
|
|
|
91
93
|
};
|
|
92
94
|
}
|
|
93
95
|
}
|
|
94
|
-
|
|
96
|
+
|
|
95
97
|
class FieldClass {
|
|
96
98
|
id;
|
|
97
99
|
name;
|
|
@@ -124,7 +126,7 @@ class FieldClass {
|
|
|
124
126
|
};
|
|
125
127
|
}
|
|
126
128
|
}
|
|
127
|
-
|
|
129
|
+
|
|
128
130
|
class TNodeClass {
|
|
129
131
|
id;
|
|
130
132
|
tag;
|
|
@@ -154,7 +156,7 @@ class TNodeClass {
|
|
|
154
156
|
};
|
|
155
157
|
}
|
|
156
158
|
}
|
|
157
|
-
// src/utils/global.utils.ts
|
|
159
|
+
var DEFAULT_IMAGE_PREVIEW = "data:image/jpeg;base64,/9j/4AAQSkZJRgABAQEBLAEsAAD/4QBWRXhpZgAATU0AKgAAAAgABAEaAAUAAAABAAAAPgEbAAUAAAABAAAARgEoAAMAAAABAAIAAAITAAMAAAABAAEAAAAAAAAAAAEsAAAAAQAAASwAAAAB/+0ALFBob3Rvc2hvcCAzLjAAOEJJTQQEAAAAAAAPHAFaAAMbJUccAQAAA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5hZG9iZTpkb2NpZDpzdG9jazo2M2Y2NTBiOC0zMjM3LTQyODktYTgwZS1lMzdjNDlhOWI2MjA8L3htcE1NOkluc3RhbmNlSUQ+CiAgPHhtcE1NOk9yaWdpbmFsRG9jdW1lbnRJRD5hZG9iZTpkb2NpZDpzdG9jazoxNjc5NDQyMTk2PC94bXBNTTpPcmlnaW5hbERvY3VtZW50SUQ+CiA8L3JkZjpEZXNjcmlwdGlvbj4KPC9yZGY6UkRGPgo8L3g6eG1wbWV0YT4KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKPD94cGFja2V0IGVuZD0ndyc/Pv/bAEMAAwICAwICAwMDAwQDAwQFCAUFBAQFCgcHBggMCgwMCwoLCw0OEhANDhEOCwsQFhARExQVFRUMDxcYFhQYEhQVFP/bAEMBAwQEBQQFCQUFCRQNCw0UFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFP/AABEIAPACbwMBEQACEQEDEQH/xAAdAAEBAAICAwEAAAAAAAAAAAAACAYHAQUCAwQJ/8QARBABAAEDAgIDCwoFAwMFAAAAAAECAwQFBgcREiFBCBcYMVFUVmFxlLMTIjI2OEJzgZOhFBUWI5EzcrFDU2KCorLR8f/EABcBAQEBAQAAAAAAAAAAA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XP8AfazTmHgqbB81z/fazTmHgqbB81z/AH2s05h4KmwfNc/32s05h4KmwfNc/wB9rNOYeCpsHzXP99rNOYeCpsHzXP8AfazTmHgqbB81z/fazTmHgqbB81z/AH2s05h4KmwfNc/32s05h4KmwfNc/wB9rNOY92L3LmwMa9FdWn5WREfcvZlyaZ9vKYNOY2PoG2dK2tg04WkYGPp+NH/Tx7cUxM+WfLPrlxUmOzHQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAH//Z";
|
|
158
160
|
function generateRandomId() {
|
|
159
161
|
return `${Date.now().toString(12)}:${crypto.randomUUID()}`;
|
|
160
162
|
}
|
|
@@ -226,14 +228,7 @@ var isPlainObject = (v) => {
|
|
|
226
228
|
return proto === Object.prototype || proto === null;
|
|
227
229
|
};
|
|
228
230
|
function areObjectsTheSame(objA, objB) {
|
|
229
|
-
|
|
230
|
-
if (Object.prototype.hasOwnProperty.call(objA, key)) {
|
|
231
|
-
if (objA[key] !== objB[key]) {
|
|
232
|
-
return false;
|
|
233
|
-
}
|
|
234
|
-
}
|
|
235
|
-
}
|
|
236
|
-
return true;
|
|
231
|
+
return _.isEqual(objA, objB);
|
|
237
232
|
}
|
|
238
233
|
var UTILS = {
|
|
239
234
|
generateRandomId,
|
|
@@ -248,8 +243,6 @@ var UTILS = {
|
|
|
248
243
|
ObjectEntries,
|
|
249
244
|
isPlainObject
|
|
250
245
|
};
|
|
251
|
-
|
|
252
|
-
// src/utils/components.utils.ts
|
|
253
246
|
function NewComponent(container3, defaultValue) {
|
|
254
247
|
const now = Date.now();
|
|
255
248
|
return new ComponentClass({
|
|
@@ -265,7 +258,6 @@ function DeserializeComponent(component2) {
|
|
|
265
258
|
return new ComponentClass(component2);
|
|
266
259
|
}
|
|
267
260
|
var ComponentsUtils = { NewComponent, DeserializeComponent };
|
|
268
|
-
// src/utils/container.utils.ts
|
|
269
261
|
function NewUlListContainer(defaultValue) {
|
|
270
262
|
return new ContainerClass({
|
|
271
263
|
id: UTILS.generateContainerId(),
|
|
@@ -307,9 +299,238 @@ var ContainersUtils = {
|
|
|
307
299
|
NewUlListContainer,
|
|
308
300
|
NewSectionContainer
|
|
309
301
|
};
|
|
310
|
-
|
|
302
|
+
var Text = {
|
|
303
|
+
style: {
|
|
304
|
+
width: "100%",
|
|
305
|
+
color: "var(--foreground)",
|
|
306
|
+
fontSize: "18px",
|
|
307
|
+
minHeight: "32px",
|
|
308
|
+
whiteSpace: "pre-wrap",
|
|
309
|
+
fontWeight: 400,
|
|
310
|
+
lineHeight: 2,
|
|
311
|
+
display: "block",
|
|
312
|
+
alignItems: "center",
|
|
313
|
+
outline: "none",
|
|
314
|
+
border: "none",
|
|
315
|
+
fieldSizing: "content",
|
|
316
|
+
cursor: "default",
|
|
317
|
+
paddingInline: 4,
|
|
318
|
+
userSelect: "none"
|
|
319
|
+
},
|
|
320
|
+
className: "[&:empty:before]:content-[attr(data-placeholder)] [&:empty:before]:text-muted-foreground [&:empty:before]:pointer-events-none"
|
|
321
|
+
};
|
|
322
|
+
var Heading = {
|
|
323
|
+
style: {
|
|
324
|
+
width: "100%",
|
|
325
|
+
maxWidth: "100%",
|
|
326
|
+
color: "var(--foreground)",
|
|
327
|
+
fontSize: "40px",
|
|
328
|
+
minHeight: "48px",
|
|
329
|
+
fontWeight: 400,
|
|
330
|
+
whiteSpace: "pre-wrap",
|
|
331
|
+
display: "block",
|
|
332
|
+
alignItems: "center",
|
|
333
|
+
outline: "none",
|
|
334
|
+
border: "none",
|
|
335
|
+
fieldSizing: "content",
|
|
336
|
+
cursor: "default",
|
|
337
|
+
paddingInline: 4,
|
|
338
|
+
userSelect: "none"
|
|
339
|
+
},
|
|
340
|
+
className: "[&:empty:before]:content-[attr(data-placeholder)] [&:empty:before]:text-muted-foreground [&:empty:before]:pointer-events-none"
|
|
341
|
+
};
|
|
342
|
+
var Image = {
|
|
343
|
+
style: {
|
|
344
|
+
width: "100%",
|
|
345
|
+
objectFit: "cover",
|
|
346
|
+
display: "block",
|
|
347
|
+
alignItems: "center",
|
|
348
|
+
outline: "none",
|
|
349
|
+
border: "none",
|
|
350
|
+
fieldSizing: "content",
|
|
351
|
+
cursor: "default",
|
|
352
|
+
userSelect: "none"
|
|
353
|
+
}
|
|
354
|
+
};
|
|
355
|
+
var Video = {
|
|
356
|
+
style: {
|
|
357
|
+
width: "100%",
|
|
358
|
+
objectFit: "cover",
|
|
359
|
+
display: "block",
|
|
360
|
+
alignItems: "center",
|
|
361
|
+
outline: "none",
|
|
362
|
+
border: "none",
|
|
363
|
+
fieldSizing: "content",
|
|
364
|
+
cursor: "default",
|
|
365
|
+
userSelect: "none"
|
|
366
|
+
}
|
|
367
|
+
};
|
|
368
|
+
var IFrame = {
|
|
369
|
+
style: {
|
|
370
|
+
width: "100%",
|
|
371
|
+
aspectRatio: "5/3",
|
|
372
|
+
objectFit: "cover",
|
|
373
|
+
display: "block",
|
|
374
|
+
alignItems: "center",
|
|
375
|
+
outline: "none",
|
|
376
|
+
border: "none",
|
|
377
|
+
fieldSizing: "content",
|
|
378
|
+
cursor: "default",
|
|
379
|
+
userSelect: "none"
|
|
380
|
+
}
|
|
381
|
+
};
|
|
382
|
+
var Link = {
|
|
383
|
+
style: {
|
|
384
|
+
width: "100%",
|
|
385
|
+
color: "var(--primary)",
|
|
386
|
+
fontSize: "18px",
|
|
387
|
+
minHeight: "32px",
|
|
388
|
+
whiteSpace: "pre-wrap",
|
|
389
|
+
fontWeight: 400,
|
|
390
|
+
display: "inline-flex",
|
|
391
|
+
lineHeight: 2,
|
|
392
|
+
alignItems: "center",
|
|
393
|
+
outline: "none",
|
|
394
|
+
border: "none",
|
|
395
|
+
fieldSizing: "content",
|
|
396
|
+
cursor: "default",
|
|
397
|
+
paddingInline: 4,
|
|
398
|
+
userSelect: "none"
|
|
399
|
+
},
|
|
400
|
+
className: "[&:empty:before]:content-[attr(data-placeholder)] [&:empty:before]:text-muted-foreground [&:empty:before]:pointer-events-none"
|
|
401
|
+
};
|
|
402
|
+
var Blockquote = {
|
|
403
|
+
style: {
|
|
404
|
+
width: "100%",
|
|
405
|
+
maxWidth: "100%",
|
|
406
|
+
color: "var(--muted-foreground)",
|
|
407
|
+
fontSize: "18px",
|
|
408
|
+
minHeight: "32px",
|
|
409
|
+
fontWeight: 400,
|
|
410
|
+
whiteSpace: "pre-wrap",
|
|
411
|
+
fontStyle: "italic",
|
|
412
|
+
display: "block",
|
|
413
|
+
alignItems: "center",
|
|
414
|
+
outline: "none",
|
|
415
|
+
border: "none",
|
|
416
|
+
fieldSizing: "content",
|
|
417
|
+
cursor: "default",
|
|
418
|
+
paddingInline: 4,
|
|
419
|
+
userSelect: "none"
|
|
420
|
+
},
|
|
421
|
+
className: "[&:empty:before]:content-[attr(data-placeholder)] [&:empty:before]:text-muted-foreground [&:empty:before]:pointer-events-none"
|
|
422
|
+
};
|
|
423
|
+
var Divider = {
|
|
424
|
+
style: {
|
|
425
|
+
width: "100%",
|
|
426
|
+
borderTopWidth: 1,
|
|
427
|
+
borderTopStyle: "solid",
|
|
428
|
+
borderTopColor: "var(--color-muted-foreground)",
|
|
429
|
+
marginBlock: 8,
|
|
430
|
+
outline: "none",
|
|
431
|
+
height: 1,
|
|
432
|
+
position: "relative",
|
|
433
|
+
overflow: "visible"
|
|
434
|
+
},
|
|
435
|
+
pseudoStyle: {
|
|
436
|
+
":before": {
|
|
437
|
+
content: '""',
|
|
438
|
+
position: "absolute",
|
|
439
|
+
top: "-8px",
|
|
440
|
+
bottom: "-8px",
|
|
441
|
+
height: 16,
|
|
442
|
+
left: 0,
|
|
443
|
+
right: 0,
|
|
444
|
+
pointerEvents: "auto",
|
|
445
|
+
zIndex: 5
|
|
446
|
+
}
|
|
447
|
+
}
|
|
448
|
+
};
|
|
449
|
+
var Code = {
|
|
450
|
+
style: {
|
|
451
|
+
width: "100%",
|
|
452
|
+
maxWidth: "100%",
|
|
453
|
+
color: "var(--foreground)",
|
|
454
|
+
fontSize: "14px",
|
|
455
|
+
fontFamily: "ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, 'Liberation Mono', monospace",
|
|
456
|
+
minHeight: "40px",
|
|
457
|
+
fontWeight: 400,
|
|
458
|
+
lineHeight: 1.7,
|
|
459
|
+
whiteSpace: "pre-wrap",
|
|
460
|
+
display: "block",
|
|
461
|
+
outline: "none",
|
|
462
|
+
border: "1px solid var(--border)",
|
|
463
|
+
fieldSizing: "content",
|
|
464
|
+
cursor: "default",
|
|
465
|
+
padding: 12,
|
|
466
|
+
userSelect: "none"
|
|
467
|
+
},
|
|
468
|
+
className: "[&:empty:before]:content-[attr(data-placeholder)] [&:empty:before]:text-muted-foreground [&:empty:before]:pointer-events-none bg-foreground dark:bg-transparent"
|
|
469
|
+
};
|
|
470
|
+
var Caption = {
|
|
471
|
+
style: {
|
|
472
|
+
width: "100%",
|
|
473
|
+
maxWidth: "100%",
|
|
474
|
+
color: "var(--muted-foreground)",
|
|
475
|
+
fontSize: "14px",
|
|
476
|
+
minHeight: "24px",
|
|
477
|
+
fontWeight: 400,
|
|
478
|
+
lineHeight: 1.5,
|
|
479
|
+
whiteSpace: "pre-wrap",
|
|
480
|
+
display: "block",
|
|
481
|
+
textAlign: "center",
|
|
482
|
+
outline: "none",
|
|
483
|
+
border: "none",
|
|
484
|
+
fieldSizing: "content",
|
|
485
|
+
cursor: "default",
|
|
486
|
+
paddingInline: 4,
|
|
487
|
+
paddingBottom: 4,
|
|
488
|
+
userSelect: "none"
|
|
489
|
+
},
|
|
490
|
+
className: "[&:empty:before]:content-[attr(data-placeholder)] [&:empty:before]:text-muted-foreground [&:empty:before]:pointer-events-none"
|
|
491
|
+
};
|
|
492
|
+
var DEFAULT_STYLES = {
|
|
493
|
+
text: Text,
|
|
494
|
+
heading: Heading,
|
|
495
|
+
image: Image,
|
|
496
|
+
divider: Divider,
|
|
497
|
+
video: Video,
|
|
498
|
+
iframe: IFrame,
|
|
499
|
+
blockquote: Blockquote,
|
|
500
|
+
link: Link,
|
|
501
|
+
code: Code,
|
|
502
|
+
caption: Caption
|
|
503
|
+
};
|
|
311
504
|
function isEditableField(block) {
|
|
312
|
-
return block.variant === "field" && (block.type
|
|
505
|
+
return block.variant === "field" && isEditableType(block.type);
|
|
506
|
+
}
|
|
507
|
+
function isEditableType(type) {
|
|
508
|
+
return type === "heading" || type === "text" || type === "blockquote" || type === "link" || type === "code" || type === "caption";
|
|
509
|
+
}
|
|
510
|
+
function isMediaField(block) {
|
|
511
|
+
return block.variant === "field" && isMediaType(block.type);
|
|
512
|
+
}
|
|
513
|
+
function isMediaType(type) {
|
|
514
|
+
return type === "image" || type === "video" || type === "iframe";
|
|
515
|
+
}
|
|
516
|
+
function getIframeSrc(value) {
|
|
517
|
+
const input = value.trim();
|
|
518
|
+
const normalizedInput = input.startsWith("//") ? `https:${input}` : /^[a-z][\w+.-]*:\/\//i.test(input) ? input : `https://${input}`;
|
|
519
|
+
let url;
|
|
520
|
+
try {
|
|
521
|
+
url = new URL(normalizedInput);
|
|
522
|
+
} catch {
|
|
523
|
+
return value;
|
|
524
|
+
}
|
|
525
|
+
const hostname = url.hostname.toLowerCase().replace(/^www\./, "");
|
|
526
|
+
const isYouTube = ["youtube.com", "m.youtube.com", "music.youtube.com", "youtu.be"].includes(hostname);
|
|
527
|
+
if (!isYouTube)
|
|
528
|
+
return value;
|
|
529
|
+
const segments = url.pathname.split("/").filter(Boolean);
|
|
530
|
+
const videoId = hostname === "youtu.be" ? segments[0] : segments[0] === "watch" ? url.searchParams.get("v") : ["embed", "shorts", "live"].includes(segments[0] ?? "") ? segments[1] : undefined;
|
|
531
|
+
if (!videoId || !/^[\w-]{11}$/.test(videoId))
|
|
532
|
+
return null;
|
|
533
|
+
return `https://www.youtube.com/embed/${videoId}`;
|
|
313
534
|
}
|
|
314
535
|
function NewTextField(defaultValue) {
|
|
315
536
|
return new FieldClass({
|
|
@@ -321,7 +542,8 @@ function NewTextField(defaultValue) {
|
|
|
321
542
|
props: {
|
|
322
543
|
children: { text: "", marks: [] },
|
|
323
544
|
"data-text-path": "props.children",
|
|
324
|
-
contentEditable: false
|
|
545
|
+
contentEditable: false,
|
|
546
|
+
...DEFAULT_STYLES["text"]
|
|
325
547
|
},
|
|
326
548
|
...defaultValue
|
|
327
549
|
});
|
|
@@ -336,7 +558,8 @@ function NewHeadingField(defaultValue) {
|
|
|
336
558
|
props: {
|
|
337
559
|
children: { text: "", marks: [] },
|
|
338
560
|
"data-text-path": "props.children",
|
|
339
|
-
contentEditable: false
|
|
561
|
+
contentEditable: false,
|
|
562
|
+
...DEFAULT_STYLES["heading"]
|
|
340
563
|
},
|
|
341
564
|
...defaultValue
|
|
342
565
|
});
|
|
@@ -348,7 +571,11 @@ function NewImageField(defaultValue) {
|
|
|
348
571
|
type: "image",
|
|
349
572
|
tag: "img",
|
|
350
573
|
variant: "field",
|
|
351
|
-
props: {
|
|
574
|
+
props: {
|
|
575
|
+
src: "",
|
|
576
|
+
alt: "image",
|
|
577
|
+
...DEFAULT_STYLES["image"]
|
|
578
|
+
},
|
|
352
579
|
...defaultValue
|
|
353
580
|
});
|
|
354
581
|
}
|
|
@@ -359,18 +586,111 @@ function NewVideoField(defaultValue) {
|
|
|
359
586
|
type: "video",
|
|
360
587
|
tag: "video",
|
|
361
588
|
variant: "field",
|
|
362
|
-
props: {
|
|
589
|
+
props: {
|
|
590
|
+
src: "",
|
|
591
|
+
alt: "video",
|
|
592
|
+
controlsList: "nodownload nofullscreen noremoteplayback noplaybackrate",
|
|
593
|
+
preload: "metadata",
|
|
594
|
+
controls: true,
|
|
595
|
+
...DEFAULT_STYLES["video"]
|
|
596
|
+
},
|
|
597
|
+
...defaultValue
|
|
598
|
+
});
|
|
599
|
+
}
|
|
600
|
+
function NewIFrameField(defaultValue) {
|
|
601
|
+
return new FieldClass({
|
|
602
|
+
id: UTILS.generateFieldId(),
|
|
603
|
+
name: "IFrame field",
|
|
604
|
+
type: "iframe",
|
|
605
|
+
tag: "iframe",
|
|
606
|
+
variant: "field",
|
|
607
|
+
props: {
|
|
608
|
+
src: "",
|
|
609
|
+
alt: "image",
|
|
610
|
+
allow: "accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share",
|
|
611
|
+
referrerPolicy: "strict-origin-when-cross-origin",
|
|
612
|
+
allowFullScreen: false,
|
|
613
|
+
frameBorder: 0,
|
|
614
|
+
...DEFAULT_STYLES["iframe"]
|
|
615
|
+
},
|
|
616
|
+
...defaultValue
|
|
617
|
+
});
|
|
618
|
+
}
|
|
619
|
+
function NewLinkField(defaultValue) {
|
|
620
|
+
return new FieldClass({
|
|
621
|
+
id: UTILS.generateFieldId(),
|
|
622
|
+
name: "Link field",
|
|
623
|
+
type: "link",
|
|
624
|
+
tag: "a",
|
|
625
|
+
variant: "field",
|
|
626
|
+
props: {
|
|
627
|
+
href: "#",
|
|
628
|
+
alt: "Preview new link",
|
|
629
|
+
"data-text-path": "props.children",
|
|
630
|
+
children: { text: "Preview new link", marks: [] },
|
|
631
|
+
...DEFAULT_STYLES["link"]
|
|
632
|
+
},
|
|
633
|
+
...defaultValue
|
|
634
|
+
});
|
|
635
|
+
}
|
|
636
|
+
function NewBlockquoteField(defaultValue) {
|
|
637
|
+
return new FieldClass({
|
|
638
|
+
id: UTILS.generateFieldId(),
|
|
639
|
+
name: "Blockquote field",
|
|
640
|
+
type: "blockquote",
|
|
641
|
+
tag: "blockquote",
|
|
642
|
+
variant: "field",
|
|
643
|
+
props: {
|
|
644
|
+
"data-text-path": "props.children",
|
|
645
|
+
children: { text: "", marks: [] },
|
|
646
|
+
...DEFAULT_STYLES["blockquote"]
|
|
647
|
+
},
|
|
363
648
|
...defaultValue
|
|
364
649
|
});
|
|
365
650
|
}
|
|
366
651
|
function NewDividerField(defaultValue) {
|
|
367
652
|
return new FieldClass({
|
|
368
653
|
id: UTILS.generateFieldId(),
|
|
369
|
-
name: "
|
|
654
|
+
name: "Divider field",
|
|
370
655
|
type: "divider",
|
|
371
656
|
tag: "hr",
|
|
372
657
|
variant: "field",
|
|
373
|
-
props: {
|
|
658
|
+
props: {
|
|
659
|
+
...DEFAULT_STYLES["divider"]
|
|
660
|
+
},
|
|
661
|
+
...defaultValue
|
|
662
|
+
});
|
|
663
|
+
}
|
|
664
|
+
function NewCodeField(defaultValue) {
|
|
665
|
+
return new FieldClass({
|
|
666
|
+
id: UTILS.generateFieldId(),
|
|
667
|
+
name: "Code field",
|
|
668
|
+
type: "code",
|
|
669
|
+
tag: "pre",
|
|
670
|
+
variant: "field",
|
|
671
|
+
props: {
|
|
672
|
+
"data-text-path": "props.children",
|
|
673
|
+
children: { text: "", marks: [] },
|
|
674
|
+
theme: "dark",
|
|
675
|
+
contentEditable: false,
|
|
676
|
+
...DEFAULT_STYLES["code"]
|
|
677
|
+
},
|
|
678
|
+
...defaultValue
|
|
679
|
+
});
|
|
680
|
+
}
|
|
681
|
+
function NewCaptionField(defaultValue) {
|
|
682
|
+
return new FieldClass({
|
|
683
|
+
id: UTILS.generateFieldId(),
|
|
684
|
+
name: "Caption field",
|
|
685
|
+
type: "caption",
|
|
686
|
+
tag: "figcaption",
|
|
687
|
+
variant: "field",
|
|
688
|
+
props: {
|
|
689
|
+
"data-text-path": "props.children",
|
|
690
|
+
children: { text: "", marks: [] },
|
|
691
|
+
contentEditable: false,
|
|
692
|
+
...DEFAULT_STYLES["caption"]
|
|
693
|
+
},
|
|
374
694
|
...defaultValue
|
|
375
695
|
});
|
|
376
696
|
}
|
|
@@ -384,111 +704,38 @@ function NewField(type, defaultValue) {
|
|
|
384
704
|
return NewImageField(defaultValue);
|
|
385
705
|
case "video":
|
|
386
706
|
return NewVideoField(defaultValue);
|
|
707
|
+
case "link":
|
|
708
|
+
return NewLinkField(defaultValue);
|
|
387
709
|
case "divider":
|
|
388
710
|
return NewDividerField(defaultValue);
|
|
711
|
+
case "iframe":
|
|
712
|
+
return NewIFrameField(defaultValue);
|
|
713
|
+
case "blockquote":
|
|
714
|
+
return NewBlockquoteField(defaultValue);
|
|
715
|
+
case "code":
|
|
716
|
+
return NewCodeField(defaultValue);
|
|
717
|
+
case "caption":
|
|
718
|
+
return NewCaptionField(defaultValue);
|
|
389
719
|
default:
|
|
390
720
|
return NewTextField(defaultValue);
|
|
391
721
|
}
|
|
392
722
|
}
|
|
393
|
-
function DeserializeField(
|
|
394
|
-
return new FieldClass(
|
|
723
|
+
function DeserializeField(field4) {
|
|
724
|
+
return new FieldClass(field4);
|
|
395
725
|
}
|
|
396
726
|
var FieldsUtils = {
|
|
397
727
|
NewField,
|
|
398
728
|
DeserializeField,
|
|
399
729
|
NewTextField,
|
|
400
730
|
NewHeadingField,
|
|
731
|
+
NewLinkField,
|
|
401
732
|
NewImageField,
|
|
402
|
-
NewDividerField
|
|
733
|
+
NewDividerField,
|
|
734
|
+
NewIFrameField,
|
|
735
|
+
NewBlockquoteField,
|
|
736
|
+
NewCodeField,
|
|
737
|
+
NewCaptionField
|
|
403
738
|
};
|
|
404
|
-
// src/utils/modules.utils.ts
|
|
405
|
-
function createScopedTCtx(engine, moduleName) {
|
|
406
|
-
const disposers = [];
|
|
407
|
-
function trackFn(disposer) {
|
|
408
|
-
let done = false;
|
|
409
|
-
const safe = () => {
|
|
410
|
-
if (!done) {
|
|
411
|
-
done = true;
|
|
412
|
-
disposer();
|
|
413
|
-
}
|
|
414
|
-
};
|
|
415
|
-
disposers.push(safe);
|
|
416
|
-
return disposer;
|
|
417
|
-
}
|
|
418
|
-
const ctx = {
|
|
419
|
-
events: {
|
|
420
|
-
on: (ev, handler) => trackFn(engine.events.on(ev, handler)),
|
|
421
|
-
emit: (ev, props) => engine.events.emit(ev, props),
|
|
422
|
-
batch: (evs) => engine.events.batch(evs)
|
|
423
|
-
},
|
|
424
|
-
commands: {
|
|
425
|
-
register: (cmd, handler) => trackFn(engine.commands.register(cmd, handler)),
|
|
426
|
-
registerAsync: (cmd, handler) => trackFn(engine.commands.registerAsync(cmd, handler)),
|
|
427
|
-
tryExecute: (cmd, payload) => engine.commands.tryExecute(cmd, payload),
|
|
428
|
-
tryExecuteAsync: (cmd, payload) => engine.commands.tryExecuteAsync(cmd, payload),
|
|
429
|
-
execute: (cmd, payload) => engine.commands.execute(cmd, payload),
|
|
430
|
-
executeAsync: (cmd, payload) => engine.commands.executeAsync(cmd, payload),
|
|
431
|
-
before: (cmd, next) => trackFn(engine.commands.before(cmd, next)),
|
|
432
|
-
beforeAsync: (cmd, next) => trackFn(engine.commands.beforeAsync(cmd, next)),
|
|
433
|
-
after: (cmd, callback) => trackFn(engine.commands.after(cmd, callback)),
|
|
434
|
-
afterAsync: (cmd, callback) => trackFn(engine.commands.afterAsync(cmd, callback)),
|
|
435
|
-
has: (cmd) => engine.commands.has(cmd)
|
|
436
|
-
},
|
|
437
|
-
state: {
|
|
438
|
-
defineSlice: (name2, initial) => {
|
|
439
|
-
return trackFn(engine.state.defineSlice(name2, initial));
|
|
440
|
-
},
|
|
441
|
-
get: (name2) => engine.state.get(name2),
|
|
442
|
-
set: (name2, next) => {
|
|
443
|
-
engine.state.set(name2, next);
|
|
444
|
-
},
|
|
445
|
-
subscribe: (name2, fn) => trackFn(engine.state.subscribe(name2, fn))
|
|
446
|
-
},
|
|
447
|
-
document: engine.document,
|
|
448
|
-
mutations: engine.mutations,
|
|
449
|
-
shortcuts: engine.shortcuts,
|
|
450
|
-
text: {
|
|
451
|
-
registerMark: (type, behavior) => trackFn(engine.text.registerMark(type, behavior)),
|
|
452
|
-
toggleMark: (c, o) => engine.text.toggleMark(c, o),
|
|
453
|
-
insertText: (c, at, t, o) => engine.text.insertText(c, at, t, o),
|
|
454
|
-
deleteRange: (c, s, e) => engine.text.deleteRange(c, s, e),
|
|
455
|
-
replaceRange: (c, s, e, t, o) => engine.text.replaceRange(c, s, e, t, o),
|
|
456
|
-
isInclusive: (t) => engine.text.isInclusive(t)
|
|
457
|
-
},
|
|
458
|
-
ui: {
|
|
459
|
-
contribute: (slotName, c) => trackFn(engine.ui.contribute(slotName, {
|
|
460
|
-
...c,
|
|
461
|
-
id: `${moduleName}.${c.id}`,
|
|
462
|
-
when: c.when
|
|
463
|
-
})),
|
|
464
|
-
subscribe: (slotName, fn) => trackFn(engine.ui.subscribe(slotName, fn)),
|
|
465
|
-
getSlots: (slotName) => engine.ui.getSlots(slotName),
|
|
466
|
-
registerStyle: (styleName, css2) => trackFn(engine.ui.registerStyle(styleName, css2)),
|
|
467
|
-
patchStyle: (styleName, patch) => trackFn(engine.ui.patchStyle(styleName, patch)),
|
|
468
|
-
getStyle: (styleName) => engine.ui.getStyle(styleName),
|
|
469
|
-
interceptPayload: (id, fn) => trackFn(engine.ui.interceptPayload(id, fn)),
|
|
470
|
-
runContribution: (c, ui) => engine.ui.runContribution(c, ui)
|
|
471
|
-
},
|
|
472
|
-
tasks: {
|
|
473
|
-
schedule: (name2, delay, fn) => trackFn(engine.tasks.schedule(name2, delay, fn)),
|
|
474
|
-
cancel: (name2) => engine.tasks.cancel(name2),
|
|
475
|
-
isPending: (name2) => engine.tasks.isPending(name2),
|
|
476
|
-
isRunning: (name2) => engine.tasks.isRunning(name2),
|
|
477
|
-
getStatus: (name2) => engine.tasks.getStatus(name2),
|
|
478
|
-
getState: (name2) => engine.tasks.getState(name2),
|
|
479
|
-
subscribe: (name2, fn) => trackFn(engine.tasks.subscribe(name2, fn)),
|
|
480
|
-
flush: (name2) => engine.tasks.flush(name2),
|
|
481
|
-
cancelAll: () => engine.tasks.cancelAll(),
|
|
482
|
-
dispose: () => engine.tasks.dispose()
|
|
483
|
-
}
|
|
484
|
-
};
|
|
485
|
-
return {
|
|
486
|
-
ctx,
|
|
487
|
-
dispose: () => disposers.splice(0).reverse().forEach((dp) => dp())
|
|
488
|
-
};
|
|
489
|
-
}
|
|
490
|
-
var ModuleUtils = { createScopedTCtx };
|
|
491
|
-
// src/utils/tnode.utils.ts
|
|
492
739
|
function NewLinkTNode(defaultValue) {
|
|
493
740
|
return new TNodeClass({
|
|
494
741
|
id: UTILS.generateTNodeId(),
|
|
@@ -523,7 +770,6 @@ function DeserializeTNode(tnode2) {
|
|
|
523
770
|
return new TNodeClass(tnode2);
|
|
524
771
|
}
|
|
525
772
|
var TNodesUtils = { NewTNode, DeserializeTNode };
|
|
526
|
-
// src/utils/tree.utils.ts
|
|
527
773
|
function SerializeTree(tree2) {
|
|
528
774
|
const newFields = Array.from(tree2.fields.entries()).reduce((prev, [id, currentField]) => {
|
|
529
775
|
prev[id] = currentField.getCurrentFieldObject();
|
|
@@ -540,7 +786,7 @@ function SerializeTree(tree2) {
|
|
|
540
786
|
return {
|
|
541
787
|
id: tree2.id,
|
|
542
788
|
version: tree2.version,
|
|
543
|
-
order: tree2.order,
|
|
789
|
+
order: [...tree2.order],
|
|
544
790
|
fields: newFields,
|
|
545
791
|
containers: newContainers,
|
|
546
792
|
components: newComponents
|
|
@@ -550,56 +796,479 @@ function DeserializeTree(tree2) {
|
|
|
550
796
|
const newFields = UTILS.ObjectEntries(tree2.fields).reduce((prev, [id, currentField]) => {
|
|
551
797
|
prev.set(id, FieldsUtils.DeserializeField(currentField));
|
|
552
798
|
return prev;
|
|
553
|
-
},
|
|
799
|
+
}, new Map);
|
|
554
800
|
const newContainers = UTILS.ObjectEntries(tree2.containers).reduce((prev, [id, currentContainer]) => {
|
|
555
801
|
prev.set(id, ContainersUtils.DeserializeContainer(currentContainer));
|
|
556
802
|
return prev;
|
|
557
|
-
},
|
|
803
|
+
}, new Map);
|
|
558
804
|
const newComponents = UTILS.ObjectEntries(tree2.components).reduce((prev, [id, currentComponent]) => {
|
|
559
805
|
prev.set(id, ComponentsUtils.DeserializeComponent(currentComponent));
|
|
560
806
|
return prev;
|
|
561
|
-
},
|
|
807
|
+
}, new Map);
|
|
562
808
|
return {
|
|
563
809
|
id: tree2.id,
|
|
564
810
|
version: tree2.version,
|
|
565
|
-
order: tree2.order,
|
|
811
|
+
order: new Set(tree2.order),
|
|
566
812
|
fields: newFields,
|
|
567
813
|
containers: newContainers,
|
|
568
814
|
components: newComponents
|
|
569
815
|
};
|
|
570
|
-
}
|
|
571
|
-
function GetDefaultTree() {
|
|
816
|
+
}
|
|
817
|
+
function GetDefaultTree() {
|
|
818
|
+
return {
|
|
819
|
+
id: "root",
|
|
820
|
+
version: "0.0.0",
|
|
821
|
+
order: new Set,
|
|
822
|
+
fields: new Map,
|
|
823
|
+
containers: new Map,
|
|
824
|
+
components: new Map
|
|
825
|
+
};
|
|
826
|
+
}
|
|
827
|
+
var KINDS = ["fields", "containers", "components"];
|
|
828
|
+
function coraxTreeDiffing(prev, next) {
|
|
829
|
+
const added = new Set, removed = new Set, changed = new Set;
|
|
830
|
+
for (const kind of KINDS) {
|
|
831
|
+
const a = prev[kind];
|
|
832
|
+
const b = next[kind];
|
|
833
|
+
if (a === b)
|
|
834
|
+
continue;
|
|
835
|
+
const bKeys = b.keys();
|
|
836
|
+
for (const id of bKeys) {
|
|
837
|
+
if (!a.has(id))
|
|
838
|
+
added.add(id);
|
|
839
|
+
else if (a.get(id) !== b.get(id))
|
|
840
|
+
changed.add(id);
|
|
841
|
+
}
|
|
842
|
+
const aKeys = a.keys();
|
|
843
|
+
for (const id of aKeys)
|
|
844
|
+
if (!b.has(id))
|
|
845
|
+
removed.add(id);
|
|
846
|
+
}
|
|
847
|
+
return { added, removed, changed, orderChanged: prev.order !== next.order };
|
|
848
|
+
}
|
|
849
|
+
function segments({ text, marks }) {
|
|
850
|
+
if (!text)
|
|
851
|
+
return [];
|
|
852
|
+
const cuts = new Set([0, text.length]);
|
|
853
|
+
for (const m of marks) {
|
|
854
|
+
cuts.add(m.start);
|
|
855
|
+
cuts.add(m.end);
|
|
856
|
+
}
|
|
857
|
+
const points = [...cuts].sort((a, b) => a - b);
|
|
858
|
+
const out = [];
|
|
859
|
+
for (let i = 0;i < points.length - 1; i++) {
|
|
860
|
+
const [s, e] = [points[i], points[i + 1]];
|
|
861
|
+
out.push({
|
|
862
|
+
text: text.slice(s, e),
|
|
863
|
+
marks: marks.filter((m) => m.start <= s && m.end >= e)
|
|
864
|
+
});
|
|
865
|
+
}
|
|
866
|
+
return out;
|
|
867
|
+
}
|
|
868
|
+
var UNITLESS = new Set([
|
|
869
|
+
"animationIterationCount",
|
|
870
|
+
"aspectRatio",
|
|
871
|
+
"borderImageOutset",
|
|
872
|
+
"borderImageSlice",
|
|
873
|
+
"borderImageWidth",
|
|
874
|
+
"boxFlex",
|
|
875
|
+
"boxFlexGroup",
|
|
876
|
+
"boxOrdinalGroup",
|
|
877
|
+
"columnCount",
|
|
878
|
+
"columns",
|
|
879
|
+
"flex",
|
|
880
|
+
"flexGrow",
|
|
881
|
+
"flexPositive",
|
|
882
|
+
"flexShrink",
|
|
883
|
+
"flexNegative",
|
|
884
|
+
"flexOrder",
|
|
885
|
+
"gridArea",
|
|
886
|
+
"gridRow",
|
|
887
|
+
"gridRowEnd",
|
|
888
|
+
"gridRowSpan",
|
|
889
|
+
"gridRowStart",
|
|
890
|
+
"gridColumn",
|
|
891
|
+
"gridColumnEnd",
|
|
892
|
+
"gridColumnSpan",
|
|
893
|
+
"gridColumnStart",
|
|
894
|
+
"fontWeight",
|
|
895
|
+
"lineClamp",
|
|
896
|
+
"lineHeight",
|
|
897
|
+
"opacity",
|
|
898
|
+
"order",
|
|
899
|
+
"orphans",
|
|
900
|
+
"scale",
|
|
901
|
+
"tabSize",
|
|
902
|
+
"widows",
|
|
903
|
+
"zIndex",
|
|
904
|
+
"zoom",
|
|
905
|
+
"fillOpacity",
|
|
906
|
+
"floodOpacity",
|
|
907
|
+
"stopOpacity",
|
|
908
|
+
"strokeDasharray",
|
|
909
|
+
"strokeDashoffset",
|
|
910
|
+
"strokeMiterlimit",
|
|
911
|
+
"strokeOpacity",
|
|
912
|
+
"strokeWidth"
|
|
913
|
+
]);
|
|
914
|
+
function toKebab(property) {
|
|
915
|
+
return property.replace(/[A-Z]/g, (m) => `-${m.toLowerCase()}`);
|
|
916
|
+
}
|
|
917
|
+
function toCssValue(property, value) {
|
|
918
|
+
if (Array.isArray(value))
|
|
919
|
+
return value.map((v) => String(v)).join(",");
|
|
920
|
+
if (typeof value === "number" && value !== 0 && !UNITLESS.has(property))
|
|
921
|
+
return `${value}px`;
|
|
922
|
+
return String(value);
|
|
923
|
+
}
|
|
924
|
+
function declarations(style) {
|
|
925
|
+
return Object.entries(style).map(([property, value]) => `${toKebab(property)}:${toCssValue(property, value)}`).join(";");
|
|
926
|
+
}
|
|
927
|
+
function serializeRules(style, selector) {
|
|
928
|
+
const rules = [];
|
|
929
|
+
const own = {};
|
|
930
|
+
for (const [key, value] of Object.entries(style)) {
|
|
931
|
+
if (value && typeof value === "object") {
|
|
932
|
+
rules.push(...serializeRules(value, `${selector}${key}`));
|
|
933
|
+
} else {
|
|
934
|
+
own[key] = value;
|
|
935
|
+
}
|
|
936
|
+
}
|
|
937
|
+
if (Object.keys(own).length > 0)
|
|
938
|
+
rules.push(`${selector}{${declarations(own)}}`);
|
|
939
|
+
return rules;
|
|
940
|
+
}
|
|
941
|
+
function stableStringify(value) {
|
|
942
|
+
if (value === null || typeof value !== "object")
|
|
943
|
+
return JSON.stringify(value) ?? "null";
|
|
944
|
+
if (Array.isArray(value))
|
|
945
|
+
return `[${value.map(stableStringify).join(",")}]`;
|
|
946
|
+
const entries = Object.entries(value).sort(([a], [b]) => a < b ? -1 : a > b ? 1 : 0).map(([k, v]) => `${JSON.stringify(k)}:${stableStringify(v)}`);
|
|
947
|
+
return `{${entries.join(",")}}`;
|
|
948
|
+
}
|
|
949
|
+
function hash(input) {
|
|
950
|
+
let h = 2166136261;
|
|
951
|
+
for (let i = 0;i < input.length; i++) {
|
|
952
|
+
h ^= input.charCodeAt(i);
|
|
953
|
+
h = Math.imul(h, 16777619);
|
|
954
|
+
}
|
|
955
|
+
return (h >>> 0).toString(36);
|
|
956
|
+
}
|
|
957
|
+
var collected = new Map;
|
|
958
|
+
var sink = null;
|
|
959
|
+
function collectCoraxPseudoStyle(style) {
|
|
960
|
+
if (!style || Object.keys(style).length === 0)
|
|
961
|
+
return;
|
|
962
|
+
const className = `corax-p-${hash(stableStringify(style))}`;
|
|
963
|
+
if (collected.has(className))
|
|
964
|
+
return className;
|
|
965
|
+
collected.set(className, serializeRules(style, `.${className}`).join(""));
|
|
966
|
+
sink?.();
|
|
967
|
+
return className;
|
|
968
|
+
}
|
|
969
|
+
function getCollectedStyles() {
|
|
970
|
+
return Array.from(collected.values()).join("");
|
|
971
|
+
}
|
|
972
|
+
function clearCollectedStyles() {
|
|
973
|
+
collected.clear();
|
|
974
|
+
}
|
|
975
|
+
function setCoraxStyleSink(fn) {
|
|
976
|
+
sink = fn;
|
|
977
|
+
fn();
|
|
978
|
+
return () => {
|
|
979
|
+
if (sink === fn)
|
|
980
|
+
sink = null;
|
|
981
|
+
};
|
|
982
|
+
}
|
|
983
|
+
var CODE_THEMES = {
|
|
984
|
+
dark: {
|
|
985
|
+
plain: "#e6edf3",
|
|
986
|
+
keyword: "#ff7b72",
|
|
987
|
+
string: "#a5d6ff",
|
|
988
|
+
number: "#79c0ff",
|
|
989
|
+
comment: "#8b949e",
|
|
990
|
+
function: "#d2a8ff",
|
|
991
|
+
punctuation: "#e6edf3",
|
|
992
|
+
operator: "#ff7b72"
|
|
993
|
+
},
|
|
994
|
+
light: {
|
|
995
|
+
plain: "#24292f",
|
|
996
|
+
keyword: "#cf222e",
|
|
997
|
+
string: "#0a3069",
|
|
998
|
+
number: "#0550ae",
|
|
999
|
+
comment: "#6e7781",
|
|
1000
|
+
function: "#8250df",
|
|
1001
|
+
punctuation: "#24292f",
|
|
1002
|
+
operator: "#cf222e"
|
|
1003
|
+
}
|
|
1004
|
+
};
|
|
1005
|
+
var CODE_THEME_NAMES = Object.keys(CODE_THEMES);
|
|
1006
|
+
var KEYWORDS = new Set([
|
|
1007
|
+
"const",
|
|
1008
|
+
"let",
|
|
1009
|
+
"var",
|
|
1010
|
+
"function",
|
|
1011
|
+
"class",
|
|
1012
|
+
"extends",
|
|
1013
|
+
"return",
|
|
1014
|
+
"if",
|
|
1015
|
+
"else",
|
|
1016
|
+
"for",
|
|
1017
|
+
"while",
|
|
1018
|
+
"do",
|
|
1019
|
+
"switch",
|
|
1020
|
+
"case",
|
|
1021
|
+
"break",
|
|
1022
|
+
"continue",
|
|
1023
|
+
"new",
|
|
1024
|
+
"typeof",
|
|
1025
|
+
"instanceof",
|
|
1026
|
+
"in",
|
|
1027
|
+
"of",
|
|
1028
|
+
"this",
|
|
1029
|
+
"super",
|
|
1030
|
+
"import",
|
|
1031
|
+
"export",
|
|
1032
|
+
"from",
|
|
1033
|
+
"default",
|
|
1034
|
+
"as",
|
|
1035
|
+
"async",
|
|
1036
|
+
"await",
|
|
1037
|
+
"yield",
|
|
1038
|
+
"try",
|
|
1039
|
+
"catch",
|
|
1040
|
+
"finally",
|
|
1041
|
+
"throw",
|
|
1042
|
+
"delete",
|
|
1043
|
+
"void",
|
|
1044
|
+
"null",
|
|
1045
|
+
"undefined",
|
|
1046
|
+
"true",
|
|
1047
|
+
"false",
|
|
1048
|
+
"interface",
|
|
1049
|
+
"type",
|
|
1050
|
+
"enum",
|
|
1051
|
+
"implements",
|
|
1052
|
+
"public",
|
|
1053
|
+
"private",
|
|
1054
|
+
"protected",
|
|
1055
|
+
"readonly",
|
|
1056
|
+
"static",
|
|
1057
|
+
"get",
|
|
1058
|
+
"set",
|
|
1059
|
+
"declare",
|
|
1060
|
+
"namespace",
|
|
1061
|
+
"abstract",
|
|
1062
|
+
"satisfies",
|
|
1063
|
+
"keyof",
|
|
1064
|
+
"infer",
|
|
1065
|
+
"is",
|
|
1066
|
+
"any",
|
|
1067
|
+
"string",
|
|
1068
|
+
"number",
|
|
1069
|
+
"boolean",
|
|
1070
|
+
"never",
|
|
1071
|
+
"unknown",
|
|
1072
|
+
"object",
|
|
1073
|
+
"symbol",
|
|
1074
|
+
"bigint"
|
|
1075
|
+
]);
|
|
1076
|
+
var isIdentStart = (c) => /[A-Za-z_$]/.test(c);
|
|
1077
|
+
var isIdentPart = (c) => /[A-Za-z0-9_$]/.test(c);
|
|
1078
|
+
var isDigit = (c) => c >= "0" && c <= "9";
|
|
1079
|
+
function tokenizeCode(input) {
|
|
1080
|
+
const tokens = [];
|
|
1081
|
+
const push = (type, value) => {
|
|
1082
|
+
if (!value)
|
|
1083
|
+
return;
|
|
1084
|
+
const last = tokens[tokens.length - 1];
|
|
1085
|
+
if (last && last.type === type)
|
|
1086
|
+
last.value += value;
|
|
1087
|
+
else
|
|
1088
|
+
tokens.push({ type, value });
|
|
1089
|
+
};
|
|
1090
|
+
let i = 0;
|
|
1091
|
+
const n = input.length;
|
|
1092
|
+
while (i < n) {
|
|
1093
|
+
const c = input[i];
|
|
1094
|
+
const next = input[i + 1];
|
|
1095
|
+
if (/\s/.test(c)) {
|
|
1096
|
+
let j = i + 1;
|
|
1097
|
+
while (j < n && /\s/.test(input[j]))
|
|
1098
|
+
j++;
|
|
1099
|
+
push("plain", input.slice(i, j));
|
|
1100
|
+
i = j;
|
|
1101
|
+
continue;
|
|
1102
|
+
}
|
|
1103
|
+
if (c === "/" && next === "/") {
|
|
1104
|
+
let j = i + 2;
|
|
1105
|
+
while (j < n && input[j] !== `
|
|
1106
|
+
`)
|
|
1107
|
+
j++;
|
|
1108
|
+
push("comment", input.slice(i, j));
|
|
1109
|
+
i = j;
|
|
1110
|
+
continue;
|
|
1111
|
+
}
|
|
1112
|
+
if (c === "/" && next === "*") {
|
|
1113
|
+
let j = i + 2;
|
|
1114
|
+
while (j < n && !(input[j] === "*" && input[j + 1] === "/"))
|
|
1115
|
+
j++;
|
|
1116
|
+
j = Math.min(n, j + 2);
|
|
1117
|
+
push("comment", input.slice(i, j));
|
|
1118
|
+
i = j;
|
|
1119
|
+
continue;
|
|
1120
|
+
}
|
|
1121
|
+
if (c === '"' || c === "'" || c === "`") {
|
|
1122
|
+
let j = i + 1;
|
|
1123
|
+
while (j < n) {
|
|
1124
|
+
if (input[j] === "\\") {
|
|
1125
|
+
j += 2;
|
|
1126
|
+
continue;
|
|
1127
|
+
}
|
|
1128
|
+
if (input[j] === c) {
|
|
1129
|
+
j++;
|
|
1130
|
+
break;
|
|
1131
|
+
}
|
|
1132
|
+
if (c !== "`" && input[j] === `
|
|
1133
|
+
`)
|
|
1134
|
+
break;
|
|
1135
|
+
j++;
|
|
1136
|
+
}
|
|
1137
|
+
push("string", input.slice(i, j));
|
|
1138
|
+
i = j;
|
|
1139
|
+
continue;
|
|
1140
|
+
}
|
|
1141
|
+
if (isDigit(c)) {
|
|
1142
|
+
let j = i;
|
|
1143
|
+
while (j < n && /[0-9a-fA-FxXoObBeE._]/.test(input[j]))
|
|
1144
|
+
j++;
|
|
1145
|
+
if (j < n && (input[j] === "+" || input[j] === "-") && /[eE]/.test(input[j - 1]))
|
|
1146
|
+
j++;
|
|
1147
|
+
while (j < n && isDigit(input[j]))
|
|
1148
|
+
j++;
|
|
1149
|
+
push("number", input.slice(i, j));
|
|
1150
|
+
i = j;
|
|
1151
|
+
continue;
|
|
1152
|
+
}
|
|
1153
|
+
if (isIdentStart(c)) {
|
|
1154
|
+
let j = i + 1;
|
|
1155
|
+
while (j < n && isIdentPart(input[j]))
|
|
1156
|
+
j++;
|
|
1157
|
+
const word = input.slice(i, j);
|
|
1158
|
+
let k = j;
|
|
1159
|
+
while (k < n && /\s/.test(input[k]))
|
|
1160
|
+
k++;
|
|
1161
|
+
if (KEYWORDS.has(word))
|
|
1162
|
+
push("keyword", word);
|
|
1163
|
+
else if (input[k] === "(")
|
|
1164
|
+
push("function", word);
|
|
1165
|
+
else
|
|
1166
|
+
push("plain", word);
|
|
1167
|
+
i = j;
|
|
1168
|
+
continue;
|
|
1169
|
+
}
|
|
1170
|
+
if (/[{}()[\];,.]/.test(c)) {
|
|
1171
|
+
push("punctuation", c);
|
|
1172
|
+
i++;
|
|
1173
|
+
continue;
|
|
1174
|
+
}
|
|
1175
|
+
if (/[=+\-*/%<>!&|^~?:]/.test(c)) {
|
|
1176
|
+
push("operator", c);
|
|
1177
|
+
i++;
|
|
1178
|
+
continue;
|
|
1179
|
+
}
|
|
1180
|
+
push("plain", c);
|
|
1181
|
+
i++;
|
|
1182
|
+
}
|
|
1183
|
+
return tokens;
|
|
1184
|
+
}
|
|
1185
|
+
// src/utils/modules.utils.ts
|
|
1186
|
+
function createScopedTCtx(engine, moduleName) {
|
|
1187
|
+
const disposers = [];
|
|
1188
|
+
function trackFn(disposer) {
|
|
1189
|
+
let done = false;
|
|
1190
|
+
const safe = () => {
|
|
1191
|
+
if (!done) {
|
|
1192
|
+
done = true;
|
|
1193
|
+
disposer();
|
|
1194
|
+
}
|
|
1195
|
+
};
|
|
1196
|
+
disposers.push(safe);
|
|
1197
|
+
return disposer;
|
|
1198
|
+
}
|
|
1199
|
+
const ctx = {
|
|
1200
|
+
events: {
|
|
1201
|
+
on: (ev, handler) => trackFn(engine.events.on(ev, handler)),
|
|
1202
|
+
emit: (ev, props) => engine.events.emit(ev, props),
|
|
1203
|
+
batch: (evs) => engine.events.batch(evs)
|
|
1204
|
+
},
|
|
1205
|
+
commands: {
|
|
1206
|
+
register: (cmd, handler) => trackFn(engine.commands.register(cmd, handler)),
|
|
1207
|
+
registerAsync: (cmd, handler) => trackFn(engine.commands.registerAsync(cmd, handler)),
|
|
1208
|
+
tryExecute: (cmd, payload) => engine.commands.tryExecute(cmd, payload),
|
|
1209
|
+
tryExecuteAsync: (cmd, payload) => engine.commands.tryExecuteAsync(cmd, payload),
|
|
1210
|
+
execute: (cmd, payload) => engine.commands.execute(cmd, payload),
|
|
1211
|
+
executeAsync: (cmd, payload) => engine.commands.executeAsync(cmd, payload),
|
|
1212
|
+
before: (cmd, next) => trackFn(engine.commands.before(cmd, next)),
|
|
1213
|
+
beforeAsync: (cmd, next) => trackFn(engine.commands.beforeAsync(cmd, next)),
|
|
1214
|
+
after: (cmd, callback) => trackFn(engine.commands.after(cmd, callback)),
|
|
1215
|
+
afterAsync: (cmd, callback) => trackFn(engine.commands.afterAsync(cmd, callback)),
|
|
1216
|
+
has: (cmd) => engine.commands.has(cmd)
|
|
1217
|
+
},
|
|
1218
|
+
state: {
|
|
1219
|
+
defineSlice: (name2, initial) => {
|
|
1220
|
+
return trackFn(engine.state.defineSlice(name2, initial));
|
|
1221
|
+
},
|
|
1222
|
+
get: (name2) => engine.state.get(name2),
|
|
1223
|
+
set: (name2, next) => {
|
|
1224
|
+
engine.state.set(name2, next);
|
|
1225
|
+
},
|
|
1226
|
+
subscribe: (name2, fn) => trackFn(engine.state.subscribe(name2, fn))
|
|
1227
|
+
},
|
|
1228
|
+
document: engine.document,
|
|
1229
|
+
mutations: engine.mutations,
|
|
1230
|
+
shortcuts: engine.shortcuts,
|
|
1231
|
+
text: {
|
|
1232
|
+
registerMark: (type, behavior) => trackFn(engine.text.registerMark(type, behavior)),
|
|
1233
|
+
toggleMark: (c, o) => engine.text.toggleMark(c, o),
|
|
1234
|
+
insertText: (c, at, t, o) => engine.text.insertText(c, at, t, o),
|
|
1235
|
+
deleteRange: (c, s, e) => engine.text.deleteRange(c, s, e),
|
|
1236
|
+
replaceRange: (c, s, e, t, o) => engine.text.replaceRange(c, s, e, t, o),
|
|
1237
|
+
isInclusive: (t) => engine.text.isInclusive(t)
|
|
1238
|
+
},
|
|
1239
|
+
ui: {
|
|
1240
|
+
contribute: (c) => trackFn(engine.ui.contribute({
|
|
1241
|
+
...c,
|
|
1242
|
+
id: `${moduleName}.${c.id}`,
|
|
1243
|
+
when: c.when
|
|
1244
|
+
})),
|
|
1245
|
+
subscribe: (slotName, fn) => trackFn(engine.ui.subscribe(slotName, fn)),
|
|
1246
|
+
getSlots: (slotName) => engine.ui.getSlots(slotName),
|
|
1247
|
+
registerStyle: (styleName, css) => trackFn(engine.ui.registerStyle(styleName, css)),
|
|
1248
|
+
patchStyle: (styleName, patch) => trackFn(engine.ui.patchStyle(styleName, patch)),
|
|
1249
|
+
getStyle: (styleName) => engine.ui.getStyle(styleName),
|
|
1250
|
+
interceptPayload: (id, fn) => trackFn(engine.ui.interceptPayload(id, fn)),
|
|
1251
|
+
runContribution: (c, ui) => engine.ui.runContribution(c, ui)
|
|
1252
|
+
},
|
|
1253
|
+
tasks: {
|
|
1254
|
+
schedule: (name2, delay, fn) => trackFn(engine.tasks.schedule(name2, delay, fn)),
|
|
1255
|
+
cancel: (name2) => engine.tasks.cancel(name2),
|
|
1256
|
+
isPending: (name2) => engine.tasks.isPending(name2),
|
|
1257
|
+
isRunning: (name2) => engine.tasks.isRunning(name2),
|
|
1258
|
+
getStatus: (name2) => engine.tasks.getStatus(name2),
|
|
1259
|
+
getState: (name2) => engine.tasks.getState(name2),
|
|
1260
|
+
subscribe: (name2, fn) => trackFn(engine.tasks.subscribe(name2, fn)),
|
|
1261
|
+
flush: (name2) => engine.tasks.flush(name2),
|
|
1262
|
+
cancelAll: () => engine.tasks.cancelAll(),
|
|
1263
|
+
dispose: () => engine.tasks.dispose()
|
|
1264
|
+
}
|
|
1265
|
+
};
|
|
572
1266
|
return {
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
order: new Set,
|
|
576
|
-
fields: new Map,
|
|
577
|
-
containers: new Map,
|
|
578
|
-
components: new Map
|
|
1267
|
+
ctx,
|
|
1268
|
+
dispose: () => disposers.splice(0).reverse().forEach((dp) => dp())
|
|
579
1269
|
};
|
|
580
1270
|
}
|
|
581
|
-
var
|
|
582
|
-
function coraxTreeDiffing(prev, next) {
|
|
583
|
-
const added = new Set, removed = new Set, changed = new Set;
|
|
584
|
-
for (const kind of KINDS) {
|
|
585
|
-
const a = prev[kind];
|
|
586
|
-
const b = next[kind];
|
|
587
|
-
if (a === b)
|
|
588
|
-
continue;
|
|
589
|
-
const bKeys = b.keys();
|
|
590
|
-
for (const id of bKeys) {
|
|
591
|
-
if (!a.has(id))
|
|
592
|
-
added.add(id);
|
|
593
|
-
else if (a.get(id) !== b.get(id))
|
|
594
|
-
changed.add(id);
|
|
595
|
-
}
|
|
596
|
-
const aKeys = a.keys();
|
|
597
|
-
for (const id of aKeys)
|
|
598
|
-
if (!b.has(id))
|
|
599
|
-
removed.add(id);
|
|
600
|
-
}
|
|
601
|
-
return { added, removed, changed, orderChanged: prev.order !== next.order };
|
|
602
|
-
}
|
|
1271
|
+
var ModuleUtils = { createScopedTCtx };
|
|
603
1272
|
// src/modules/modules-manager.ts
|
|
604
1273
|
class ModuleManager {
|
|
605
1274
|
registry = new Map;
|
|
@@ -619,6 +1288,9 @@ class ModuleManager {
|
|
|
619
1288
|
isEnabled(name2) {
|
|
620
1289
|
return this.active.has(name2);
|
|
621
1290
|
}
|
|
1291
|
+
isRegistered(name2) {
|
|
1292
|
+
return this.registry.has(name2);
|
|
1293
|
+
}
|
|
622
1294
|
enable(name2) {
|
|
623
1295
|
this.enableRec(name2, []);
|
|
624
1296
|
}
|
|
@@ -1047,28 +1719,28 @@ class MutationPrototypeError extends MutationError {
|
|
|
1047
1719
|
var FORBIDDEN = new Set(["__proto__", "constructor", "prototype"]);
|
|
1048
1720
|
|
|
1049
1721
|
class MutationsService {
|
|
1050
|
-
insertField(
|
|
1051
|
-
const hasField =
|
|
1722
|
+
insertField(tree, _field, index) {
|
|
1723
|
+
const hasField = tree.order.has(_field.id);
|
|
1052
1724
|
if (hasField) {
|
|
1053
1725
|
throw new MutationError(`Field ${_field.name} with ID (${_field.id}) already exists`);
|
|
1054
1726
|
}
|
|
1055
|
-
const
|
|
1056
|
-
if (!(
|
|
1057
|
-
throw new MutationPrototypeError(
|
|
1727
|
+
const field = _field instanceof FieldClass ? _field : new FieldClass(_field);
|
|
1728
|
+
if (!(field instanceof FieldClass)) {
|
|
1729
|
+
throw new MutationPrototypeError(field.name);
|
|
1058
1730
|
}
|
|
1059
1731
|
if (index === 0) {
|
|
1060
1732
|
throw new MutationError(`Cannot delete the first field!`);
|
|
1061
1733
|
}
|
|
1062
|
-
if (
|
|
1063
|
-
const hasContainer =
|
|
1064
|
-
const hasContainerInOrder =
|
|
1734
|
+
if (field.containerId) {
|
|
1735
|
+
const hasContainer = tree.containers.has(field.containerId);
|
|
1736
|
+
const hasContainerInOrder = tree.order.has(field.containerId);
|
|
1065
1737
|
if (!hasContainer || !hasContainerInOrder) {
|
|
1066
|
-
throw new MutationError(`Insert of Field ${
|
|
1738
|
+
throw new MutationError(`Insert of Field ${field.name} with ID (${field.id}) failed. Container ${field.containerId} does not exist`);
|
|
1067
1739
|
}
|
|
1068
|
-
|
|
1069
|
-
id:
|
|
1740
|
+
tree = this.mutateContainer(tree, {
|
|
1741
|
+
id: field.containerId,
|
|
1070
1742
|
keyValuePairs: {
|
|
1071
|
-
order: new Set([
|
|
1743
|
+
order: new Set([field.id])
|
|
1072
1744
|
}
|
|
1073
1745
|
});
|
|
1074
1746
|
}
|
|
@@ -1077,45 +1749,54 @@ class MutationsService {
|
|
|
1077
1749
|
if (index < 0) {
|
|
1078
1750
|
console.warn(`Mutation: negative index detected '${index}'`);
|
|
1079
1751
|
}
|
|
1080
|
-
const orderArray = Array.from(
|
|
1081
|
-
|
|
1752
|
+
const orderArray = Array.from(tree.order);
|
|
1753
|
+
let targetIndex = index;
|
|
1754
|
+
while (targetIndex > 0 && targetIndex < orderArray.length) {
|
|
1755
|
+
const previous = tree.fields.get(orderArray[targetIndex - 1]);
|
|
1756
|
+
const current = tree.fields.get(orderArray[targetIndex]);
|
|
1757
|
+
const isAttachedCaption = !!previous && isMediaType(previous.type) && !!current && current.type === "caption" && current.props.mediaId === previous.id;
|
|
1758
|
+
if (!isAttachedCaption)
|
|
1759
|
+
break;
|
|
1760
|
+
targetIndex++;
|
|
1761
|
+
}
|
|
1762
|
+
orderArray.splice(targetIndex, 0, field.id);
|
|
1082
1763
|
order = new Set(orderArray);
|
|
1083
1764
|
} else {
|
|
1084
|
-
order = new Set(
|
|
1085
|
-
order.add(
|
|
1765
|
+
order = new Set(tree.order);
|
|
1766
|
+
order.add(field.id);
|
|
1086
1767
|
}
|
|
1087
|
-
const
|
|
1088
|
-
|
|
1768
|
+
const fields = new Map(tree.fields);
|
|
1769
|
+
fields.set(field.id, field);
|
|
1089
1770
|
return {
|
|
1090
|
-
...
|
|
1771
|
+
...tree,
|
|
1091
1772
|
order,
|
|
1092
|
-
fields
|
|
1773
|
+
fields
|
|
1093
1774
|
};
|
|
1094
1775
|
}
|
|
1095
|
-
deleteField(
|
|
1096
|
-
const hasField =
|
|
1776
|
+
deleteField(tree, fieldId) {
|
|
1777
|
+
const hasField = tree.order.has(fieldId);
|
|
1097
1778
|
if (!hasField) {
|
|
1098
1779
|
throw new MutationError(`Field with ID (${fieldId}) not found`);
|
|
1099
1780
|
}
|
|
1100
|
-
const
|
|
1101
|
-
const order = new Set(
|
|
1781
|
+
const field = tree.fields.get(fieldId);
|
|
1782
|
+
const order = new Set(tree.order);
|
|
1102
1783
|
order.delete(fieldId);
|
|
1103
|
-
const
|
|
1104
|
-
|
|
1784
|
+
const fields = new Map(tree.fields);
|
|
1785
|
+
fields.delete(fieldId);
|
|
1105
1786
|
let updatedTree = {
|
|
1106
|
-
...
|
|
1787
|
+
...tree,
|
|
1107
1788
|
order,
|
|
1108
|
-
fields
|
|
1789
|
+
fields
|
|
1109
1790
|
};
|
|
1110
|
-
const hasContainer =
|
|
1791
|
+
const hasContainer = field?.containerId && updatedTree.containers.has(field.containerId);
|
|
1111
1792
|
if (hasContainer) {
|
|
1112
|
-
const
|
|
1113
|
-
const containerHasField =
|
|
1114
|
-
if (
|
|
1115
|
-
const containerOrder = new Set(
|
|
1793
|
+
const container = updatedTree.containers.get(field.containerId);
|
|
1794
|
+
const containerHasField = container?.order.has(fieldId);
|
|
1795
|
+
if (container && containerHasField) {
|
|
1796
|
+
const containerOrder = new Set(container.order);
|
|
1116
1797
|
containerOrder.delete(fieldId);
|
|
1117
1798
|
updatedTree = this.mutateContainer(updatedTree, {
|
|
1118
|
-
id:
|
|
1799
|
+
id: field.containerId,
|
|
1119
1800
|
keyValuePairs: {
|
|
1120
1801
|
order: containerOrder
|
|
1121
1802
|
},
|
|
@@ -1123,14 +1804,44 @@ class MutationsService {
|
|
|
1123
1804
|
});
|
|
1124
1805
|
}
|
|
1125
1806
|
}
|
|
1807
|
+
const attachedCaptions = [];
|
|
1808
|
+
for (const [id, f] of updatedTree.fields) {
|
|
1809
|
+
if (f.type === "caption" && f.props.mediaId === fieldId) {
|
|
1810
|
+
attachedCaptions.push(id);
|
|
1811
|
+
}
|
|
1812
|
+
}
|
|
1813
|
+
for (const captionId of attachedCaptions) {
|
|
1814
|
+
updatedTree = this.deleteField(updatedTree, captionId);
|
|
1815
|
+
}
|
|
1126
1816
|
return updatedTree;
|
|
1127
1817
|
}
|
|
1128
|
-
|
|
1129
|
-
const
|
|
1818
|
+
changeField(tree, { fieldId, type }) {
|
|
1819
|
+
const hasField = tree.order.has(fieldId) && tree.fields.has(fieldId);
|
|
1820
|
+
if (!hasField) {
|
|
1821
|
+
throw new MutationError(`Field with ID (${fieldId}) not found`);
|
|
1822
|
+
}
|
|
1823
|
+
const _field = tree.fields.get(fieldId);
|
|
1824
|
+
const field = _field instanceof FieldClass ? _field : new FieldClass(_field);
|
|
1825
|
+
if (!(field instanceof FieldClass)) {
|
|
1826
|
+
throw new MutationPrototypeError(field.name);
|
|
1827
|
+
}
|
|
1828
|
+
if (!isEditableField(field) || field.type === type) {
|
|
1829
|
+
return tree;
|
|
1830
|
+
}
|
|
1831
|
+
const hasContent = !!field.props.children.text.length;
|
|
1832
|
+
if (hasContent) {
|
|
1833
|
+
return tree;
|
|
1834
|
+
}
|
|
1835
|
+
const order = new Set(tree.order);
|
|
1836
|
+
const pos = [...order].indexOf(fieldId);
|
|
1837
|
+
return this.insertField(this.deleteField(tree, fieldId), FieldsUtils.NewField(type, { id: field.id }), pos);
|
|
1838
|
+
}
|
|
1839
|
+
mutateField(tree, { id, keyValuePairs, autoMerge }) {
|
|
1840
|
+
const hasFieldInOrder = tree.order.has(id);
|
|
1130
1841
|
if (!hasFieldInOrder) {
|
|
1131
1842
|
throw new MutationError(`Field ${id} doesn't exist on the tree`);
|
|
1132
1843
|
}
|
|
1133
|
-
const existingField =
|
|
1844
|
+
const existingField = tree.fields.get(id);
|
|
1134
1845
|
if (!existingField || !(existingField instanceof FieldClass)) {
|
|
1135
1846
|
throw new MutationPrototypeError(existingField?.name ?? id);
|
|
1136
1847
|
}
|
|
@@ -1141,12 +1852,12 @@ class MutationsService {
|
|
|
1141
1852
|
id
|
|
1142
1853
|
});
|
|
1143
1854
|
if (updatedField === currentField)
|
|
1144
|
-
return
|
|
1145
|
-
const
|
|
1146
|
-
|
|
1855
|
+
return tree;
|
|
1856
|
+
const fields = new Map(tree.fields);
|
|
1857
|
+
fields.set(id, new FieldClass(updatedField));
|
|
1147
1858
|
return {
|
|
1148
|
-
...
|
|
1149
|
-
fields
|
|
1859
|
+
...tree,
|
|
1860
|
+
fields
|
|
1150
1861
|
};
|
|
1151
1862
|
}
|
|
1152
1863
|
canMerge(autoMerge, value, current) {
|
|
@@ -1194,11 +1905,11 @@ class MutationsService {
|
|
|
1194
1905
|
}
|
|
1195
1906
|
return result;
|
|
1196
1907
|
}
|
|
1197
|
-
mutateContainer(
|
|
1198
|
-
if (!
|
|
1908
|
+
mutateContainer(tree, { keyValuePairs, id, autoMerge = true }) {
|
|
1909
|
+
if (!tree.order.has(id)) {
|
|
1199
1910
|
throw new MutationError(`Container ${id} doesn't exist on the tree`);
|
|
1200
1911
|
}
|
|
1201
|
-
const existingContainer =
|
|
1912
|
+
const existingContainer = tree.containers.get(id);
|
|
1202
1913
|
if (!existingContainer || !(existingContainer instanceof ContainerClass)) {
|
|
1203
1914
|
throw new MutationPrototypeError(existingContainer?.name ?? "ContainerNotFound");
|
|
1204
1915
|
}
|
|
@@ -1209,11 +1920,11 @@ class MutationsService {
|
|
|
1209
1920
|
id
|
|
1210
1921
|
});
|
|
1211
1922
|
if (currentContainer === updatedContainer)
|
|
1212
|
-
return
|
|
1213
|
-
const containers = new Map(
|
|
1923
|
+
return tree;
|
|
1924
|
+
const containers = new Map(tree.containers);
|
|
1214
1925
|
containers.set(id, new ContainerClass(updatedContainer));
|
|
1215
1926
|
return {
|
|
1216
|
-
...
|
|
1927
|
+
...tree,
|
|
1217
1928
|
containers
|
|
1218
1929
|
};
|
|
1219
1930
|
}
|
|
@@ -1432,91 +2143,6 @@ class TextMarksService {
|
|
|
1432
2143
|
}
|
|
1433
2144
|
}
|
|
1434
2145
|
|
|
1435
|
-
// src/services/ui/default-styles.ts
|
|
1436
|
-
var Text = {
|
|
1437
|
-
style: {
|
|
1438
|
-
width: "100%",
|
|
1439
|
-
color: "var(--text-foreground)",
|
|
1440
|
-
fontSize: "18px",
|
|
1441
|
-
minHeight: "32px",
|
|
1442
|
-
whiteSpace: "pre",
|
|
1443
|
-
fontWeight: 400,
|
|
1444
|
-
display: "block",
|
|
1445
|
-
alignItems: "center",
|
|
1446
|
-
outline: "none",
|
|
1447
|
-
border: "none",
|
|
1448
|
-
fieldSizing: "content",
|
|
1449
|
-
cursor: "default",
|
|
1450
|
-
paddingInline: 4,
|
|
1451
|
-
userSelect: "none"
|
|
1452
|
-
},
|
|
1453
|
-
className: "[&:empty:before]:content-[attr(data-placeholder)] [&:empty:before]:text-muted-foreground [&:empty:before]:pointer-events-none"
|
|
1454
|
-
};
|
|
1455
|
-
var Heading = {
|
|
1456
|
-
style: {
|
|
1457
|
-
width: "100%",
|
|
1458
|
-
maxWidth: "100%",
|
|
1459
|
-
color: "var(--text-foreground)",
|
|
1460
|
-
fontSize: "40px",
|
|
1461
|
-
minHeight: "48px",
|
|
1462
|
-
fontWeight: 400,
|
|
1463
|
-
whiteSpace: "pre",
|
|
1464
|
-
display: "block",
|
|
1465
|
-
alignItems: "center",
|
|
1466
|
-
outline: "none",
|
|
1467
|
-
border: "none",
|
|
1468
|
-
fieldSizing: "content",
|
|
1469
|
-
cursor: "default",
|
|
1470
|
-
paddingInline: 4,
|
|
1471
|
-
userSelect: "none"
|
|
1472
|
-
},
|
|
1473
|
-
className: "[&:empty:before]:content-[attr(data-placeholder)] [&:empty:before]:text-muted-foreground [&:empty:before]:pointer-events-none"
|
|
1474
|
-
};
|
|
1475
|
-
var Image = {
|
|
1476
|
-
style: {
|
|
1477
|
-
width: "100%",
|
|
1478
|
-
objectFit: "cover",
|
|
1479
|
-
display: "block",
|
|
1480
|
-
alignItems: "center",
|
|
1481
|
-
outline: "none",
|
|
1482
|
-
border: "none",
|
|
1483
|
-
fieldSizing: "content",
|
|
1484
|
-
cursor: "default",
|
|
1485
|
-
userSelect: "none"
|
|
1486
|
-
}
|
|
1487
|
-
};
|
|
1488
|
-
var Divider = {
|
|
1489
|
-
style: {
|
|
1490
|
-
width: "100%",
|
|
1491
|
-
borderTopWidth: 1,
|
|
1492
|
-
borderTopStyle: "solid",
|
|
1493
|
-
borderTopColor: "var(--color-muted-foreground)",
|
|
1494
|
-
marginBlock: 8,
|
|
1495
|
-
height: 1,
|
|
1496
|
-
position: "relative",
|
|
1497
|
-
overflow: "visible"
|
|
1498
|
-
},
|
|
1499
|
-
pseudoStyle: {
|
|
1500
|
-
":before": {
|
|
1501
|
-
content: '""',
|
|
1502
|
-
position: "absolute",
|
|
1503
|
-
top: "-8px",
|
|
1504
|
-
bottom: "-8px",
|
|
1505
|
-
height: 16,
|
|
1506
|
-
left: 0,
|
|
1507
|
-
right: 0,
|
|
1508
|
-
pointerEvents: "auto",
|
|
1509
|
-
zIndex: 5
|
|
1510
|
-
}
|
|
1511
|
-
}
|
|
1512
|
-
};
|
|
1513
|
-
var STYLES = {
|
|
1514
|
-
text: Text,
|
|
1515
|
-
heading: Heading,
|
|
1516
|
-
image: Image,
|
|
1517
|
-
divider: Divider
|
|
1518
|
-
};
|
|
1519
|
-
|
|
1520
2146
|
// src/services/ui/ui.errors.ts
|
|
1521
2147
|
class UiError extends Error {
|
|
1522
2148
|
constructor(message) {
|
|
@@ -1528,11 +2154,9 @@ class UiError extends Error {
|
|
|
1528
2154
|
// src/services/ui/ui.ts
|
|
1529
2155
|
import { cn } from "cn";
|
|
1530
2156
|
|
|
1531
|
-
// src/services/ui/
|
|
1532
|
-
|
|
1533
|
-
|
|
1534
|
-
}
|
|
1535
|
-
|
|
2157
|
+
// src/services/ui/contributions.types.ts
|
|
2158
|
+
var defineButton = (c) => c;
|
|
2159
|
+
var defineComponent = (c) => c;
|
|
1536
2160
|
// src/services/ui/ui.ts
|
|
1537
2161
|
class UiService {
|
|
1538
2162
|
commands;
|
|
@@ -1543,7 +2167,7 @@ class UiService {
|
|
|
1543
2167
|
interceptors = new Map;
|
|
1544
2168
|
constructor(commands) {
|
|
1545
2169
|
this.commands = commands;
|
|
1546
|
-
for (const [key, value] of UTILS.ObjectEntries(
|
|
2170
|
+
for (const [key, value] of UTILS.ObjectEntries(DEFAULT_STYLES)) {
|
|
1547
2171
|
this.styles.set(key, value);
|
|
1548
2172
|
}
|
|
1549
2173
|
}
|
|
@@ -1562,7 +2186,8 @@ class UiService {
|
|
|
1562
2186
|
}
|
|
1563
2187
|
this.commands.execute(c.command, payload);
|
|
1564
2188
|
}
|
|
1565
|
-
contribute(
|
|
2189
|
+
contribute(c) {
|
|
2190
|
+
const slotName = c.slot;
|
|
1566
2191
|
const prevContribution = this.bySlot.get(slotName) ?? [];
|
|
1567
2192
|
if (prevContribution.some((x) => x.id === c.id)) {
|
|
1568
2193
|
throw new UiError(`Contribution with id ${c.id} already exists`);
|
|
@@ -1594,7 +2219,7 @@ class UiService {
|
|
|
1594
2219
|
}
|
|
1595
2220
|
this.styles.set(styleName, style);
|
|
1596
2221
|
return () => {
|
|
1597
|
-
this.styles.set(styleName, this.outdatedStyles.get(styleName) ??
|
|
2222
|
+
this.styles.set(styleName, this.outdatedStyles.get(styleName) ?? DEFAULT_STYLES[styleName]);
|
|
1598
2223
|
this.outdatedStyles.delete(styleName);
|
|
1599
2224
|
};
|
|
1600
2225
|
}
|
|
@@ -1613,7 +2238,7 @@ class UiService {
|
|
|
1613
2238
|
className: cn(prevStyle.className, style.className)
|
|
1614
2239
|
});
|
|
1615
2240
|
return () => {
|
|
1616
|
-
this.styles.set(styleName, this.outdatedStyles.get(styleName) ??
|
|
2241
|
+
this.styles.set(styleName, this.outdatedStyles.get(styleName) ?? DEFAULT_STYLES[styleName]);
|
|
1617
2242
|
this.outdatedStyles.delete(styleName);
|
|
1618
2243
|
};
|
|
1619
2244
|
}
|
|
@@ -1819,15 +2444,20 @@ var InsertionModule = {
|
|
|
1819
2444
|
ctx.state.set("insertion", isOpen);
|
|
1820
2445
|
ctx.events.emit("actions:toggle", isOpen);
|
|
1821
2446
|
});
|
|
2447
|
+
ctx.commands.register("fields.change", ({ fieldId, type }) => {
|
|
2448
|
+
ctx.document.apply((tree) => ctx.mutations.changeField(tree, { fieldId, type }), { origin: isMediaType(type) ? "history" : "user" });
|
|
2449
|
+
ctx.state.set("insertion", false);
|
|
2450
|
+
ctx.events.emit("fields:change", { fieldId, type });
|
|
2451
|
+
});
|
|
1822
2452
|
ctx.commands.register("blocks.insert", ({ block, pos }) => {
|
|
1823
2453
|
const isNotMedia = block.type !== "image" && block.type !== "video";
|
|
1824
2454
|
const hasSrcInProps = "src" in block.props && !!block.props.src.trim();
|
|
1825
2455
|
const shouldEmitEvent = isNotMedia || hasSrcInProps;
|
|
1826
|
-
ctx.document.apply((
|
|
2456
|
+
ctx.document.apply((tree) => {
|
|
1827
2457
|
if (block.variant === "field") {
|
|
1828
|
-
return ctx.mutations.insertField(
|
|
2458
|
+
return ctx.mutations.insertField(tree, block, pos);
|
|
1829
2459
|
}
|
|
1830
|
-
return
|
|
2460
|
+
return tree;
|
|
1831
2461
|
}, { shouldEmitEvent });
|
|
1832
2462
|
ctx.state.set("insertion", false);
|
|
1833
2463
|
ctx.events.emit("blocks:insert", { block, pos });
|
|
@@ -1836,35 +2466,46 @@ var InsertionModule = {
|
|
|
1836
2466
|
const isFieldBlock = blockId.startsWith("field:");
|
|
1837
2467
|
if (!isFieldBlock)
|
|
1838
2468
|
return;
|
|
1839
|
-
ctx.document.apply((
|
|
2469
|
+
ctx.document.apply((tree) => ctx.mutations.deleteField(tree, blockId));
|
|
1840
2470
|
ctx.events.emit("blocks:delete", { blockId });
|
|
1841
2471
|
});
|
|
1842
|
-
function actionButton(id,
|
|
1843
|
-
ctx.ui.contribute(
|
|
2472
|
+
function actionButton(id, type, icon, order) {
|
|
2473
|
+
ctx.ui.contribute(defineButton({
|
|
1844
2474
|
id,
|
|
1845
2475
|
order,
|
|
1846
2476
|
icon,
|
|
1847
2477
|
kind: "button",
|
|
1848
2478
|
slot: "block-actions",
|
|
1849
|
-
command: "
|
|
2479
|
+
command: "fields.change",
|
|
1850
2480
|
name: "BlockActionButton",
|
|
1851
2481
|
getProps() {
|
|
1852
|
-
return { variant: "
|
|
2482
|
+
return { variant: "secondary", size: "icon-sm" };
|
|
2483
|
+
},
|
|
2484
|
+
getPayload: () => {
|
|
2485
|
+
const focus = ctx.state.get("focus_memory")?.blocks?.[0];
|
|
2486
|
+
if (!focus) {
|
|
2487
|
+
throw new Error("Empty focus memory...");
|
|
2488
|
+
}
|
|
2489
|
+
return { fieldId: focus.id, type };
|
|
1853
2490
|
},
|
|
1854
|
-
getPayload: () => ({ block }),
|
|
1855
2491
|
when() {
|
|
1856
2492
|
return true;
|
|
1857
2493
|
}
|
|
1858
|
-
});
|
|
2494
|
+
}));
|
|
1859
2495
|
}
|
|
1860
|
-
ctx.ui.contribute(
|
|
2496
|
+
ctx.ui.contribute({
|
|
1861
2497
|
...ActionsOpenerContribution,
|
|
1862
2498
|
getPayload: () => !ctx.state.get("insertion")
|
|
1863
2499
|
});
|
|
1864
|
-
actionButton("insert-heading",
|
|
1865
|
-
actionButton("insert-text",
|
|
1866
|
-
actionButton("insert-image",
|
|
1867
|
-
actionButton("insert-
|
|
2500
|
+
actionButton("insert-heading", "heading", "HeadingIcon", 1);
|
|
2501
|
+
actionButton("insert-text", "text", "TextIcon", 2);
|
|
2502
|
+
actionButton("insert-image", "image", "ImagePlus", 3);
|
|
2503
|
+
actionButton("insert-video", "video", "TvMinimalPlayIcon", 4);
|
|
2504
|
+
actionButton("insert-iframe", "iframe", "YoutubeIcon", 5);
|
|
2505
|
+
actionButton("insert-doc", "link", "FileTextIcon", 6);
|
|
2506
|
+
actionButton("insert-blockquote", "blockquote", "QuoteIcon", 7);
|
|
2507
|
+
actionButton("insert-code", "code", "CodeIcon", 8);
|
|
2508
|
+
actionButton("insert-divider", "divider", "DividerIcon", 9);
|
|
1868
2509
|
}
|
|
1869
2510
|
};
|
|
1870
2511
|
// src/modules/editor/editor.module.ts
|
|
@@ -1963,8 +2604,8 @@ function sameBlocks(a, b) {
|
|
|
1963
2604
|
}
|
|
1964
2605
|
return true;
|
|
1965
2606
|
}
|
|
1966
|
-
function selectionOverlayPropsFromUICtx(
|
|
1967
|
-
const rects = Array.from(
|
|
2607
|
+
function selectionOverlayPropsFromUICtx(ui4, editorRect, order) {
|
|
2608
|
+
const rects = Array.from(ui4?.selection?.blocks?.entries() ?? []).map(([id, rect]) => order.has(id) ? rect : null).filter(Boolean);
|
|
1968
2609
|
return overlayPositionFromBlockRects(rects, editorRect);
|
|
1969
2610
|
}
|
|
1970
2611
|
var SelectionModule = {
|
|
@@ -1973,22 +2614,22 @@ var SelectionModule = {
|
|
|
1973
2614
|
requires: [],
|
|
1974
2615
|
install(ctx) {
|
|
1975
2616
|
ctx.state.defineSlice("selection", { blocks: new Map });
|
|
1976
|
-
ctx.ui.contribute(
|
|
2617
|
+
ctx.ui.contribute(defineComponent({
|
|
1977
2618
|
id: "selection-overlay",
|
|
1978
2619
|
slot: "overlay",
|
|
1979
2620
|
order: 1000,
|
|
1980
2621
|
kind: "component",
|
|
1981
2622
|
name: "SelectionOverlay",
|
|
1982
|
-
when: (
|
|
1983
|
-
getProps: (
|
|
2623
|
+
when: (ui4) => ui4.selection.blocks.size > 0,
|
|
2624
|
+
getProps: (ui4) => {
|
|
1984
2625
|
const editorState = ctx.state.get("editor") ?? { editorRect: null };
|
|
1985
|
-
const position = selectionOverlayPropsFromUICtx(
|
|
2626
|
+
const position = selectionOverlayPropsFromUICtx(ui4, editorState?.editorRect, ctx.document.get().order);
|
|
1986
2627
|
return {
|
|
1987
2628
|
position,
|
|
1988
|
-
hidden: !Array.from(
|
|
2629
|
+
hidden: !Array.from(ui4.selection.blocks.keys()).length || !position
|
|
1989
2630
|
};
|
|
1990
2631
|
}
|
|
1991
|
-
});
|
|
2632
|
+
}));
|
|
1992
2633
|
const apply = (next) => {
|
|
1993
2634
|
const previous = ctx.state.get("selection").blocks;
|
|
1994
2635
|
if (sameBlocks(previous, next))
|
|
@@ -2010,9 +2651,9 @@ var SelectionModule = {
|
|
|
2010
2651
|
}
|
|
2011
2652
|
};
|
|
2012
2653
|
// src/modules/focus/focus.module.ts
|
|
2013
|
-
import
|
|
2014
|
-
function focusOverlayPropsFromUICtx(
|
|
2015
|
-
const rect =
|
|
2654
|
+
import _2 from "lodash";
|
|
2655
|
+
function focusOverlayPropsFromUICtx(ui4, editorRect) {
|
|
2656
|
+
const rect = ui4.focus?.rect;
|
|
2016
2657
|
if (!rect)
|
|
2017
2658
|
return null;
|
|
2018
2659
|
return overlayPositionFromBlockRects([rect], editorRect);
|
|
@@ -2024,36 +2665,29 @@ var FocusModule = {
|
|
|
2024
2665
|
install(ctx) {
|
|
2025
2666
|
ctx.state.defineSlice("focus", null);
|
|
2026
2667
|
ctx.state.defineSlice("focus_memory", { blocks: [], count: 3 });
|
|
2027
|
-
ctx.ui.contribute(
|
|
2668
|
+
ctx.ui.contribute(defineComponent({
|
|
2028
2669
|
id: "focus-overlay",
|
|
2029
2670
|
slot: "overlay",
|
|
2030
2671
|
order: 1001,
|
|
2031
2672
|
kind: "component",
|
|
2032
2673
|
name: "FocusOverlay",
|
|
2033
|
-
when: (
|
|
2034
|
-
getProps: (
|
|
2674
|
+
when: (ui4) => !!ui4.focus?.id,
|
|
2675
|
+
getProps: (ui4) => {
|
|
2035
2676
|
const editorState = ctx.state.get("editor") ?? { editorRect: null };
|
|
2036
|
-
const position = focusOverlayPropsFromUICtx(
|
|
2677
|
+
const position = focusOverlayPropsFromUICtx(ui4, editorState?.editorRect);
|
|
2037
2678
|
const document = ctx.state.get("document");
|
|
2038
2679
|
return {
|
|
2039
2680
|
position,
|
|
2040
|
-
hidden: !
|
|
2681
|
+
hidden: !ui4.focus?.id || !position || !document?.order.has(ui4?.focus?.id)
|
|
2041
2682
|
};
|
|
2042
2683
|
}
|
|
2043
|
-
});
|
|
2684
|
+
}));
|
|
2044
2685
|
ctx.commands.register("blocks.focus", (payload) => {
|
|
2045
|
-
if (payload && !isEditableField(ctx.document.getBlock(payload.id))) {
|
|
2046
|
-
ctx.commands.execute("blocks.select", {
|
|
2047
|
-
blocks: new Map().set(payload.id, payload.rect),
|
|
2048
|
-
mode: "replace"
|
|
2049
|
-
});
|
|
2050
|
-
return;
|
|
2051
|
-
}
|
|
2052
2686
|
const { id: focusedId = null, rect = null } = payload ?? {};
|
|
2053
2687
|
const prev = ctx.state.get("focus");
|
|
2054
2688
|
if (focusedId !== null && !ctx.document.has(focusedId))
|
|
2055
2689
|
return;
|
|
2056
|
-
if (focusedId === prev?.id &&
|
|
2690
|
+
if (focusedId === prev?.id && _2.isEqual(rect, prev.rect))
|
|
2057
2691
|
return;
|
|
2058
2692
|
const prevFocusedId = prev?.id;
|
|
2059
2693
|
const shouldUnfocusPrev = Boolean(prevFocusedId && prevFocusedId !== focusedId && (() => {
|
|
@@ -2065,8 +2699,8 @@ var FocusModule = {
|
|
|
2065
2699
|
return b && isEditableField(b);
|
|
2066
2700
|
})());
|
|
2067
2701
|
if (shouldUnfocusPrev || shouldFocusCurrent) {
|
|
2068
|
-
ctx.document.apply((
|
|
2069
|
-
let nextTree =
|
|
2702
|
+
ctx.document.apply((tree) => {
|
|
2703
|
+
let nextTree = tree;
|
|
2070
2704
|
if (shouldUnfocusPrev && prevFocusedId) {
|
|
2071
2705
|
nextTree = ctx.mutations.mutateField(nextTree, {
|
|
2072
2706
|
keyValuePairs: {
|
|
@@ -2102,7 +2736,7 @@ var FocusModule = {
|
|
|
2102
2736
|
const { blocks: _memoBlocks, count } = ctx.state.get("focus_memory");
|
|
2103
2737
|
if (focusedId && rect) {
|
|
2104
2738
|
ctx.state.set("focus_memory", {
|
|
2105
|
-
blocks: [
|
|
2739
|
+
blocks: [{ id: focusedId, rect }, ...[..._memoBlocks].reverse()].slice(0, count),
|
|
2106
2740
|
count
|
|
2107
2741
|
});
|
|
2108
2742
|
}
|
|
@@ -2111,8 +2745,8 @@ var FocusModule = {
|
|
|
2111
2745
|
}
|
|
2112
2746
|
};
|
|
2113
2747
|
// src/modules/hover/hover.module.ts
|
|
2114
|
-
function hoverOverlayPropsFromUICtx(
|
|
2115
|
-
const rect =
|
|
2748
|
+
function hoverOverlayPropsFromUICtx(ui4, editorRect) {
|
|
2749
|
+
const rect = ui4.hover?.rect;
|
|
2116
2750
|
if (!rect)
|
|
2117
2751
|
return null;
|
|
2118
2752
|
return overlayPositionFromBlockRects([rect], editorRect);
|
|
@@ -2124,24 +2758,24 @@ var HoverModule = {
|
|
|
2124
2758
|
install(ctx) {
|
|
2125
2759
|
ctx.state.defineSlice("hover", null);
|
|
2126
2760
|
ctx.state.defineSlice("hover_memory", { blocks: [], count: 3 });
|
|
2127
|
-
ctx.ui.contribute(
|
|
2761
|
+
ctx.ui.contribute(defineComponent({
|
|
2128
2762
|
id: "hover-overlay",
|
|
2129
2763
|
slot: "overlay",
|
|
2130
2764
|
order: 999,
|
|
2131
2765
|
kind: "component",
|
|
2132
2766
|
name: "HoverOverlay",
|
|
2133
|
-
when: (
|
|
2134
|
-
getProps: (
|
|
2767
|
+
when: (ui4) => !!ui4.hover?.id,
|
|
2768
|
+
getProps: (ui4) => {
|
|
2135
2769
|
const editorState = ctx.state.get("editor") ?? { editorRect: null };
|
|
2136
2770
|
const selection = ctx.state.get("selection");
|
|
2137
2771
|
const document = ctx.state.get("document");
|
|
2138
|
-
const position = hoverOverlayPropsFromUICtx(
|
|
2772
|
+
const position = hoverOverlayPropsFromUICtx(ui4, editorState?.editorRect);
|
|
2139
2773
|
return {
|
|
2140
2774
|
position,
|
|
2141
|
-
hidden: !
|
|
2775
|
+
hidden: !ui4.hover?.id || !position || !!selection && selection.blocks.has(ui4.hover?.id) || !document?.order.has(ui4.hover?.id)
|
|
2142
2776
|
};
|
|
2143
2777
|
}
|
|
2144
|
-
});
|
|
2778
|
+
}));
|
|
2145
2779
|
ctx.commands.register("blocks.hover", (payload) => {
|
|
2146
2780
|
if (!payload) {
|
|
2147
2781
|
ctx.state.set("hover", null);
|
|
@@ -2176,10 +2810,17 @@ var HistoryModule = {
|
|
|
2176
2810
|
let stack = [ctx.document.get()];
|
|
2177
2811
|
let cursor = 0;
|
|
2178
2812
|
ctx.state.defineSlice("history", { canUndo: false, canRedo: false });
|
|
2179
|
-
|
|
2180
|
-
|
|
2181
|
-
|
|
2182
|
-
|
|
2813
|
+
ctx.state.defineSlice("history:stack", { size: 0, cursor: 0 });
|
|
2814
|
+
const sync = () => {
|
|
2815
|
+
ctx.state.set("history", {
|
|
2816
|
+
canUndo: cursor > 0,
|
|
2817
|
+
canRedo: cursor < stack.length - 1
|
|
2818
|
+
});
|
|
2819
|
+
ctx.state.set("history:stack", {
|
|
2820
|
+
size: stack.length,
|
|
2821
|
+
cursor
|
|
2822
|
+
});
|
|
2823
|
+
};
|
|
2183
2824
|
ctx.events.on("document:changed", ({ value }) => {
|
|
2184
2825
|
if (value.origin === "history")
|
|
2185
2826
|
return;
|
|
@@ -2193,11 +2834,20 @@ var HistoryModule = {
|
|
|
2193
2834
|
cursor = to;
|
|
2194
2835
|
ctx.document.apply(() => stack[cursor], { origin: "history" });
|
|
2195
2836
|
sync();
|
|
2196
|
-
if (
|
|
2837
|
+
if (ctx.state.get("focus"))
|
|
2197
2838
|
ctx.commands.tryExecute("blocks.focus", null);
|
|
2198
2839
|
};
|
|
2199
2840
|
ctx.commands.register("history.undo", () => go(cursor - 1));
|
|
2200
2841
|
ctx.commands.register("history.redo", () => go(cursor + 1));
|
|
2842
|
+
ctx.commands.register("history.move", ({ cursor: cursor2 }) => go(cursor2));
|
|
2843
|
+
ctx.commands.register("history.cleanup", () => {
|
|
2844
|
+
stack = [stack[cursor]];
|
|
2845
|
+
cursor = 0;
|
|
2846
|
+
ctx.state.set("history:stack", {
|
|
2847
|
+
size: 1,
|
|
2848
|
+
cursor: 0
|
|
2849
|
+
});
|
|
2850
|
+
});
|
|
2201
2851
|
}
|
|
2202
2852
|
};
|
|
2203
2853
|
// src/modules/text-editing/text-editing.constants.ts
|
|
@@ -2231,7 +2881,7 @@ var TextEditingModule = {
|
|
|
2231
2881
|
if (!sel)
|
|
2232
2882
|
return null;
|
|
2233
2883
|
const block = ctx.document.getBlock(sel.blockId);
|
|
2234
|
-
if (!block ||
|
|
2884
|
+
if (!block || !isEditableField(block))
|
|
2235
2885
|
return null;
|
|
2236
2886
|
const content = getIn(block, sel.path);
|
|
2237
2887
|
if (!isTextContent(content))
|
|
@@ -2239,13 +2889,13 @@ var TextEditingModule = {
|
|
|
2239
2889
|
return { sel, content };
|
|
2240
2890
|
};
|
|
2241
2891
|
const write = (sel, next) => {
|
|
2242
|
-
ctx.document.apply((
|
|
2892
|
+
ctx.document.apply((tree) => ctx.mutations.mutateField(tree, {
|
|
2243
2893
|
id: sel.blockId,
|
|
2244
2894
|
keyValuePairs: { [sel.path]: next },
|
|
2245
2895
|
autoMerge: false
|
|
2246
2896
|
}));
|
|
2247
2897
|
const curBlock = ctx.document.getBlock(sel.blockId);
|
|
2248
|
-
if (!curBlock || !
|
|
2898
|
+
if (!curBlock || !isEditableField(curBlock))
|
|
2249
2899
|
return;
|
|
2250
2900
|
ctx.state.set("currentMarks", currentMarks([...curBlock.props.children.marks], sel));
|
|
2251
2901
|
};
|
|
@@ -2267,7 +2917,7 @@ var TextEditingModule = {
|
|
|
2267
2917
|
if (samePlace)
|
|
2268
2918
|
return;
|
|
2269
2919
|
const curBlock = ctx.document.getBlock(next.blockId);
|
|
2270
|
-
if (!curBlock || !
|
|
2920
|
+
if (!curBlock || !isEditableField(curBlock))
|
|
2271
2921
|
return;
|
|
2272
2922
|
ctx.state.set("textSelection", { ...next, pendingMarks: null });
|
|
2273
2923
|
ctx.state.set("currentMarks", currentMarks([...curBlock.props.children.marks], next));
|
|
@@ -2335,16 +2985,24 @@ var TextEditingModule = {
|
|
|
2335
2985
|
chars = direction === "backward" ? chars.slice(0, sel.start) : chars.slice(sel.start);
|
|
2336
2986
|
const sideWhiteSpacePos = direction === "backward" && chars[chars.length - 1] === " " ? "end" : direction === "forward" && chars[0] === " " ? "start" : "none";
|
|
2337
2987
|
if (sideWhiteSpacePos === "start") {
|
|
2338
|
-
|
|
2988
|
+
const position = chars.findIndex((char) => char !== " ");
|
|
2989
|
+
chars = chars.slice(position);
|
|
2339
2990
|
} else if (sideWhiteSpacePos === "end") {
|
|
2340
|
-
|
|
2991
|
+
let count = 0;
|
|
2992
|
+
for (let i = chars.length - 1;i >= 0; i--) {
|
|
2993
|
+
if (chars[i] !== " ") {
|
|
2994
|
+
break;
|
|
2995
|
+
}
|
|
2996
|
+
count++;
|
|
2997
|
+
}
|
|
2998
|
+
chars = chars.slice(0, -count);
|
|
2341
2999
|
}
|
|
2342
3000
|
const firstWhiteSpaceIndex = chars.findIndex((char) => char === " ");
|
|
2343
3001
|
const lastWhiteSpaceIndex = chars.findLastIndex((char) => char === " ");
|
|
2344
|
-
if (direction === "backward"
|
|
2345
|
-
start = lastWhiteSpaceIndex + 1;
|
|
2346
|
-
} else if (direction === "forward"
|
|
2347
|
-
end = firstWhiteSpaceIndex + (content.text.length - chars.length);
|
|
3002
|
+
if (direction === "backward") {
|
|
3003
|
+
start = lastWhiteSpaceIndex !== -1 ? lastWhiteSpaceIndex + 1 : 0;
|
|
3004
|
+
} else if (direction === "forward") {
|
|
3005
|
+
end = firstWhiteSpaceIndex !== -1 ? firstWhiteSpaceIndex + (content.text.length - chars.length) : content.text.length;
|
|
2348
3006
|
}
|
|
2349
3007
|
}
|
|
2350
3008
|
}
|
|
@@ -2354,7 +3012,7 @@ var TextEditingModule = {
|
|
|
2354
3012
|
write(sel, next);
|
|
2355
3013
|
setCaret(sel, Math.max(0, start));
|
|
2356
3014
|
});
|
|
2357
|
-
const formatButton = (format, icon, order) => ctx.ui.contribute(
|
|
3015
|
+
const formatButton = (format, icon, order) => ctx.ui.contribute(defineButton({
|
|
2358
3016
|
id: `format-${format}`,
|
|
2359
3017
|
slot: "toolbar",
|
|
2360
3018
|
order,
|
|
@@ -2363,12 +3021,12 @@ var TextEditingModule = {
|
|
|
2363
3021
|
command: "text.format",
|
|
2364
3022
|
name: "ToolBarButton",
|
|
2365
3023
|
getPayload: () => ({ format, attrs: MARK_DEFAULT_ATTRS[format] ?? {} }),
|
|
2366
|
-
getProps(
|
|
2367
|
-
const focusedBlock =
|
|
3024
|
+
getProps(ui4) {
|
|
3025
|
+
const focusedBlock = ui4.focus;
|
|
2368
3026
|
if (!focusedBlock?.id)
|
|
2369
3027
|
return { isActive: false };
|
|
2370
3028
|
const block = ctx.document.getBlock(focusedBlock.id);
|
|
2371
|
-
if (!block || !
|
|
3029
|
+
if (!block || !isEditableField(block))
|
|
2372
3030
|
return { isActive: false };
|
|
2373
3031
|
const children = block.props.children;
|
|
2374
3032
|
const curSel = ctx.state.get("textSelection");
|
|
@@ -2381,48 +3039,170 @@ var TextEditingModule = {
|
|
|
2381
3039
|
isActive: correspondingMark.start === curSel.start && correspondingMark.end === curSel.end
|
|
2382
3040
|
};
|
|
2383
3041
|
},
|
|
2384
|
-
when: (
|
|
2385
|
-
if (!
|
|
3042
|
+
when: (ui4) => {
|
|
3043
|
+
if (!ui4.focus?.id)
|
|
2386
3044
|
return false;
|
|
2387
|
-
const block = ctx.document.getBlock(
|
|
3045
|
+
const block = ctx.document.getBlock(ui4.focus.id);
|
|
2388
3046
|
if (!block)
|
|
2389
3047
|
return false;
|
|
2390
3048
|
const sel = ctx.state.get("textSelection");
|
|
2391
|
-
return isEditableField(block) && !!sel && sel.start !== sel.end;
|
|
3049
|
+
return isEditableField(block) && !!sel && sel.start !== sel.end && block.type !== "code";
|
|
2392
3050
|
}
|
|
2393
|
-
});
|
|
3051
|
+
}));
|
|
2394
3052
|
formatButton("bold", "BoldIcon", 10);
|
|
2395
3053
|
formatButton("italic", "ItalicIcon", 20);
|
|
2396
3054
|
formatButton("link", "LinkIcon", 30);
|
|
2397
3055
|
formatButton("underline", "UnderlineIcon", 40);
|
|
2398
3056
|
}
|
|
2399
3057
|
};
|
|
2400
|
-
// src/modules/
|
|
2401
|
-
|
|
2402
|
-
|
|
2403
|
-
|
|
2404
|
-
|
|
2405
|
-
|
|
2406
|
-
|
|
2407
|
-
|
|
3058
|
+
// src/modules/code/code.module.ts
|
|
3059
|
+
var CodeModule = {
|
|
3060
|
+
name: "code",
|
|
3061
|
+
version: "1.0.0",
|
|
3062
|
+
requires: [],
|
|
3063
|
+
install(ctx) {
|
|
3064
|
+
ctx.commands.register("code.toggleTheme", ({ fieldId }) => {
|
|
3065
|
+
const block = ctx.document.getBlock(fieldId);
|
|
3066
|
+
if (!block || block.type !== "code")
|
|
3067
|
+
return;
|
|
3068
|
+
const current = block.props.theme ?? "dark";
|
|
3069
|
+
const index = CODE_THEME_NAMES.indexOf(current);
|
|
3070
|
+
const next = CODE_THEME_NAMES[(index + 1) % CODE_THEME_NAMES.length];
|
|
3071
|
+
ctx.document.apply((tree) => ctx.mutations.mutateField(tree, {
|
|
3072
|
+
id: fieldId,
|
|
3073
|
+
keyValuePairs: { "props.theme": next }
|
|
3074
|
+
}));
|
|
3075
|
+
ctx.events.emit("code:toggleTheme", { fieldId });
|
|
3076
|
+
});
|
|
2408
3077
|
}
|
|
2409
|
-
|
|
2410
|
-
|
|
2411
|
-
|
|
2412
|
-
|
|
2413
|
-
|
|
2414
|
-
|
|
2415
|
-
|
|
3078
|
+
};
|
|
3079
|
+
// src/modules/caption/caption.module.ts
|
|
3080
|
+
var hasCaptionFor = (fields, mediaId) => {
|
|
3081
|
+
for (const field of fields) {
|
|
3082
|
+
if (field.type !== "caption")
|
|
3083
|
+
continue;
|
|
3084
|
+
if (field.props.mediaId === mediaId)
|
|
3085
|
+
return true;
|
|
3086
|
+
}
|
|
3087
|
+
return false;
|
|
3088
|
+
};
|
|
3089
|
+
var CaptionModule = {
|
|
3090
|
+
name: "caption",
|
|
3091
|
+
version: "1.0.0",
|
|
3092
|
+
requires: [],
|
|
3093
|
+
install(ctx) {
|
|
3094
|
+
const addCaption = (mediaId) => {
|
|
3095
|
+
const media = ctx.document.getBlock(mediaId);
|
|
3096
|
+
if (!media || !isMediaField(media))
|
|
3097
|
+
return;
|
|
3098
|
+
if (hasCaptionFor(ctx.document.get().fields.values(), mediaId))
|
|
3099
|
+
return;
|
|
3100
|
+
const pos = [...ctx.document.get().order].indexOf(mediaId);
|
|
3101
|
+
if (pos === -1)
|
|
3102
|
+
return;
|
|
3103
|
+
const caption = FieldsUtils.NewCaptionField();
|
|
3104
|
+
if (caption.props?.mediaId) {
|
|
3105
|
+
caption.props.mediaId = mediaId;
|
|
3106
|
+
}
|
|
3107
|
+
ctx.document.apply((tree) => ctx.mutations.insertField(tree, caption, pos + 1));
|
|
3108
|
+
ctx.events.emit("caption:add", { mediaId });
|
|
3109
|
+
};
|
|
3110
|
+
ctx.commands.register("caption.add", ({ mediaId }) => addCaption(mediaId));
|
|
3111
|
+
ctx.events.on("fields:change", ({ value }) => {
|
|
3112
|
+
if (!isMediaType(value.type))
|
|
3113
|
+
return;
|
|
3114
|
+
addCaption(value.fieldId);
|
|
3115
|
+
});
|
|
3116
|
+
ctx.events.on("blocks:insert", ({ value }) => {
|
|
3117
|
+
const block = value.block;
|
|
3118
|
+
if (block.variant !== "field" || !isMediaType(block.type))
|
|
3119
|
+
return;
|
|
3120
|
+
addCaption(block.id);
|
|
2416
3121
|
});
|
|
3122
|
+
ctx.ui.contribute(defineButton({
|
|
3123
|
+
id: "insert-caption",
|
|
3124
|
+
slot: "toolbar",
|
|
3125
|
+
order: 100,
|
|
3126
|
+
kind: "button",
|
|
3127
|
+
icon: "CaptionsIcon",
|
|
3128
|
+
command: "caption.add",
|
|
3129
|
+
name: "CaptionButton",
|
|
3130
|
+
label: "Add caption",
|
|
3131
|
+
getPayload: (ui4) => {
|
|
3132
|
+
const mediaId = [...ui4.selection?.blocks?.keys() ?? []][0];
|
|
3133
|
+
if (!mediaId)
|
|
3134
|
+
throw new Error("Empty selection...");
|
|
3135
|
+
return { mediaId };
|
|
3136
|
+
},
|
|
3137
|
+
getProps: () => ({}),
|
|
3138
|
+
when: (ui4) => {
|
|
3139
|
+
const blocks = ui4.selection?.blocks;
|
|
3140
|
+
if (!blocks || blocks.size !== 1)
|
|
3141
|
+
return false;
|
|
3142
|
+
const mediaId = [...blocks.keys()][0];
|
|
3143
|
+
const media = ctx.document.getBlock(mediaId);
|
|
3144
|
+
if (!media || !isMediaField(media))
|
|
3145
|
+
return false;
|
|
3146
|
+
return !hasCaptionFor(ctx.document.get().fields.values(), mediaId);
|
|
3147
|
+
}
|
|
3148
|
+
}));
|
|
2417
3149
|
}
|
|
2418
|
-
|
|
2419
|
-
|
|
3150
|
+
};
|
|
3151
|
+
// src/modules/deletion/deletion.module.ts
|
|
3152
|
+
var DeletionModule = {
|
|
3153
|
+
name: "deletion",
|
|
3154
|
+
version: "1.0.0",
|
|
3155
|
+
requires: [],
|
|
3156
|
+
install(ctx) {
|
|
3157
|
+
ctx.commands.register("blocks.deleteSelection", () => {
|
|
3158
|
+
const blocks = ctx.state.get("selection")?.blocks ?? new Map;
|
|
3159
|
+
const ids = [...blocks.keys()].filter((id) => id.startsWith("field:"));
|
|
3160
|
+
if (!ids.length)
|
|
3161
|
+
return;
|
|
3162
|
+
ctx.document.apply((tree) => {
|
|
3163
|
+
let next = tree;
|
|
3164
|
+
for (const id of ids) {
|
|
3165
|
+
if (next.fields.has(id))
|
|
3166
|
+
next = ctx.mutations.deleteField(next, id);
|
|
3167
|
+
}
|
|
3168
|
+
return next;
|
|
3169
|
+
});
|
|
3170
|
+
ctx.commands.execute("blocks.clearSelection", undefined);
|
|
3171
|
+
});
|
|
3172
|
+
ctx.ui.contribute(defineButton({
|
|
3173
|
+
id: "delete-blocks",
|
|
3174
|
+
slot: "toolbar",
|
|
3175
|
+
order: 200,
|
|
3176
|
+
kind: "button",
|
|
3177
|
+
icon: "TrashIcon",
|
|
3178
|
+
command: "blocks.deleteSelection",
|
|
3179
|
+
name: "DeleteButton",
|
|
3180
|
+
label: "Delete",
|
|
3181
|
+
getPayload: () => {
|
|
3182
|
+
return;
|
|
3183
|
+
},
|
|
3184
|
+
getProps: () => ({}),
|
|
3185
|
+
when: (ui4) => (ui4.selection?.blocks?.size ?? 0) > 0
|
|
3186
|
+
}));
|
|
3187
|
+
}
|
|
3188
|
+
};
|
|
2420
3189
|
export {
|
|
3190
|
+
tokenizeCode,
|
|
3191
|
+
setCoraxStyleSink,
|
|
2421
3192
|
segments,
|
|
2422
3193
|
overlayPositionFromBlockRects,
|
|
3194
|
+
isMediaType,
|
|
3195
|
+
isMediaField,
|
|
3196
|
+
isEditableType,
|
|
2423
3197
|
isEditableField,
|
|
2424
|
-
|
|
3198
|
+
getIframeSrc,
|
|
3199
|
+
getCollectedStyles,
|
|
3200
|
+
defineComponent,
|
|
3201
|
+
defineButton,
|
|
2425
3202
|
coraxTreeDiffing,
|
|
3203
|
+
hash as coraxStyleHash,
|
|
3204
|
+
collectCoraxPseudoStyle,
|
|
3205
|
+
clearCollectedStyles,
|
|
2426
3206
|
areObjectsTheSame,
|
|
2427
3207
|
UiService,
|
|
2428
3208
|
UiError,
|
|
@@ -2438,7 +3218,6 @@ export {
|
|
|
2438
3218
|
StateError,
|
|
2439
3219
|
SerializeTree,
|
|
2440
3220
|
SelectionModule,
|
|
2441
|
-
STYLES,
|
|
2442
3221
|
MutationsService,
|
|
2443
3222
|
MutationPrototypeError,
|
|
2444
3223
|
MutationError,
|
|
@@ -2456,11 +3235,18 @@ export {
|
|
|
2456
3235
|
EditorModule,
|
|
2457
3236
|
DocumentService,
|
|
2458
3237
|
DeserializeTree,
|
|
3238
|
+
DeletionModule,
|
|
3239
|
+
DEFAULT_STYLES,
|
|
3240
|
+
DEFAULT_IMAGE_PREVIEW,
|
|
2459
3241
|
CustomObject,
|
|
2460
3242
|
ContainersUtils,
|
|
2461
3243
|
ContainerClass,
|
|
2462
3244
|
ComponentsUtils,
|
|
2463
3245
|
ComponentClass,
|
|
2464
3246
|
CommandsBusService,
|
|
2465
|
-
|
|
3247
|
+
CodeModule,
|
|
3248
|
+
CmdNotFoundError,
|
|
3249
|
+
CaptionModule,
|
|
3250
|
+
CODE_THEME_NAMES,
|
|
3251
|
+
CODE_THEMES
|
|
2466
3252
|
};
|