@uniformdev/canvas-react 19.62.0 → 19.62.1-alpha.127
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/LICENSE.txt +1 -1
- package/dist/PureUniformText-B3GAm6Dc.d.mts +41 -0
- package/dist/PureUniformText-B3GAm6Dc.d.ts +41 -0
- package/dist/core.d.mts +14 -39
- package/dist/core.d.ts +14 -39
- package/dist/core.js +41 -5
- package/dist/core.mjs +43 -3
- package/dist/index.d.mts +89 -22
- package/dist/index.d.ts +89 -22
- package/dist/index.esm.js +136 -85
- package/dist/index.js +183 -134
- package/dist/index.mjs +136 -85
- package/package.json +7 -7
package/dist/index.mjs
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
1
3
|
// src/components/DefaultNotImplementedComponent.tsx
|
|
2
|
-
import { CANVAS_LOCALIZATION_TYPE } from "@uniformdev/canvas";
|
|
4
|
+
import { CANVAS_LOCALIZATION_TYPE, EMPTY_COMPOSITION } from "@uniformdev/canvas";
|
|
3
5
|
import React from "react";
|
|
4
6
|
var wrapperStyles = {
|
|
5
7
|
display: "flex",
|
|
@@ -19,6 +21,9 @@ function DefaultNotImplementedComponent(props) {
|
|
|
19
21
|
if (!componentType) {
|
|
20
22
|
return null;
|
|
21
23
|
}
|
|
24
|
+
if (componentType === EMPTY_COMPOSITION.type) {
|
|
25
|
+
return /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement("style", null, `@keyframes _uniformDelayedFadeIn { 0%,75% { opacity: 0; } to { opacity: 1; } }`), /* @__PURE__ */ React.createElement("p", { style: { animation: "_uniformDelayedFadeIn 3s" } }, "This component only works inside Uniform Canvas editor.", /* @__PURE__ */ React.createElement("br", null), "If you think this is an error, try", " ", /* @__PURE__ */ React.createElement("a", { href: "", style: { fontWeight: "bolder", textDecoration: "underline" } }, "reloading the page"), "."));
|
|
26
|
+
}
|
|
22
27
|
if (componentType === CANVAS_LOCALIZATION_TYPE) {
|
|
23
28
|
return /* @__PURE__ */ React.createElement("div", { style: wrapperStyles }, /* @__PURE__ */ React.createElement("p", null, "Seems like localization is not enabled in your application. Please read our documentation on how to", " ", /* @__PURE__ */ React.createElement(
|
|
24
29
|
"a",
|
|
@@ -73,7 +78,7 @@ import {
|
|
|
73
78
|
CANVAS_ENRICHMENT_TAG_PARAM
|
|
74
79
|
} from "@uniformdev/canvas";
|
|
75
80
|
import { Track, TrackFragment, useUniformContext } from "@uniformdev/context-react";
|
|
76
|
-
import
|
|
81
|
+
import React7, { createContext as createContext2, useContext as useContext2 } from "react";
|
|
77
82
|
|
|
78
83
|
// src/helpers/convertComponentToProps.ts
|
|
79
84
|
function convertComponentToProps(component) {
|
|
@@ -102,7 +107,8 @@ var createComponentStore = () => {
|
|
|
102
107
|
},
|
|
103
108
|
get: (type, variantId) => {
|
|
104
109
|
return components.get(getTypeWithVariant(type, variantId));
|
|
105
|
-
}
|
|
110
|
+
},
|
|
111
|
+
getComponentsMap: () => new Map(components)
|
|
106
112
|
};
|
|
107
113
|
};
|
|
108
114
|
var createComponentStoreResolver = ({ store, defaultComponent = DefaultNotImplementedComponent }) => {
|
|
@@ -136,9 +142,9 @@ import {
|
|
|
136
142
|
CANVAS_PERSONALIZE_TYPE,
|
|
137
143
|
CANVAS_TEST_SLOT,
|
|
138
144
|
CANVAS_TEST_TYPE,
|
|
139
|
-
EMPTY_COMPOSITION as
|
|
145
|
+
EMPTY_COMPOSITION as EMPTY_COMPOSITION3
|
|
140
146
|
} from "@uniformdev/canvas";
|
|
141
|
-
import
|
|
147
|
+
import React6 from "react";
|
|
142
148
|
|
|
143
149
|
// src/defaultSystemComponentResolver.tsx
|
|
144
150
|
import {
|
|
@@ -182,22 +188,56 @@ var defaultSystemComponentResolver = {
|
|
|
182
188
|
};
|
|
183
189
|
|
|
184
190
|
// src/components/ContextualEditingComponentWrapper.tsx
|
|
191
|
+
import {
|
|
192
|
+
isComponentPlaceholderId
|
|
193
|
+
} from "@uniformdev/canvas";
|
|
194
|
+
import React5 from "react";
|
|
195
|
+
|
|
196
|
+
// src/components/PureContextualEditingComponentWrapper.tsx
|
|
185
197
|
import {
|
|
186
198
|
CANVAS_LOCALE_TAG_PARAM,
|
|
187
199
|
IN_CONTEXT_EDITOR_COMPONENT_END_ROLE,
|
|
188
|
-
IN_CONTEXT_EDITOR_COMPONENT_START_ROLE
|
|
189
|
-
isComponentPlaceholderId
|
|
200
|
+
IN_CONTEXT_EDITOR_COMPONENT_START_ROLE
|
|
190
201
|
} from "@uniformdev/canvas";
|
|
191
|
-
import
|
|
202
|
+
import React3 from "react";
|
|
203
|
+
var PureContextualEditingComponentWrapper = ({
|
|
204
|
+
children,
|
|
205
|
+
isPlaceholder,
|
|
206
|
+
parentComponent,
|
|
207
|
+
component,
|
|
208
|
+
slotName,
|
|
209
|
+
indexInSlot,
|
|
210
|
+
slotChildrenCount,
|
|
211
|
+
isReadOnly
|
|
212
|
+
}) => {
|
|
213
|
+
var _a, _b, _c, _d;
|
|
214
|
+
return /* @__PURE__ */ React3.createElement(React3.Fragment, null, /* @__PURE__ */ React3.createElement(
|
|
215
|
+
"script",
|
|
216
|
+
{
|
|
217
|
+
"data-role": IN_CONTEXT_EDITOR_COMPONENT_START_ROLE,
|
|
218
|
+
"data-parent-id": parentComponent == null ? void 0 : parentComponent._id,
|
|
219
|
+
"data-parent-type": parentComponent == null ? void 0 : parentComponent.type,
|
|
220
|
+
"data-component-id": component == null ? void 0 : component._id,
|
|
221
|
+
"data-slot-name": slotName != null ? slotName : "",
|
|
222
|
+
"data-component-index": indexInSlot != null ? indexInSlot : "",
|
|
223
|
+
"data-total-components": slotChildrenCount != null ? slotChildrenCount : "",
|
|
224
|
+
"data-component-name": component == null ? void 0 : component.type,
|
|
225
|
+
"data-is-placeholder": isPlaceholder ? "true" : void 0,
|
|
226
|
+
"data-is-localized": ((_a = component == null ? void 0 : component.parameters) == null ? void 0 : _a[CANVAS_LOCALE_TAG_PARAM]) ? "true" : void 0,
|
|
227
|
+
"data-component-title": (_d = (_c = (_b = component == null ? void 0 : component.parameters) == null ? void 0 : _b.title) == null ? void 0 : _c.value) != null ? _d : "",
|
|
228
|
+
"data-is-readonly": isReadOnly
|
|
229
|
+
}
|
|
230
|
+
), children, /* @__PURE__ */ React3.createElement("script", { "data-role": IN_CONTEXT_EDITOR_COMPONENT_END_ROLE }));
|
|
231
|
+
};
|
|
192
232
|
|
|
193
233
|
// src/components/UniformComposition.tsx
|
|
194
|
-
import
|
|
234
|
+
import React4, { createContext, useContext } from "react";
|
|
195
235
|
|
|
196
236
|
// src/hooks/useUniformContextualEditing.ts
|
|
197
237
|
import {
|
|
198
238
|
createCanvasChannel,
|
|
199
239
|
createUniformApiEnhancer,
|
|
200
|
-
EMPTY_COMPOSITION,
|
|
240
|
+
EMPTY_COMPOSITION as EMPTY_COMPOSITION2,
|
|
201
241
|
IN_CONTEXT_EDITOR_EMBED_SCRIPT_ID,
|
|
202
242
|
IN_CONTEXT_EDITOR_QUERY_STRING_PARAM,
|
|
203
243
|
isAllowedReferrer,
|
|
@@ -222,7 +262,7 @@ var useUniformContextualEditing = ({
|
|
|
222
262
|
return channel2;
|
|
223
263
|
}, []);
|
|
224
264
|
useEffect(() => {
|
|
225
|
-
if ((contextualComposition == null ? void 0 : contextualComposition._id) && (initialCompositionValue == null ? void 0 : initialCompositionValue._id) !==
|
|
265
|
+
if ((contextualComposition == null ? void 0 : contextualComposition._id) && (initialCompositionValue == null ? void 0 : initialCompositionValue._id) !== EMPTY_COMPOSITION2._id && (initialCompositionValue == null ? void 0 : initialCompositionValue._id) !== (contextualComposition == null ? void 0 : contextualComposition._id)) {
|
|
226
266
|
setContextualComposition(void 0);
|
|
227
267
|
return;
|
|
228
268
|
}
|
|
@@ -262,7 +302,7 @@ var useUniformContextualEditing = ({
|
|
|
262
302
|
document.head.appendChild(script);
|
|
263
303
|
}, [initialCompositionValue == null ? void 0 : initialCompositionValue._id]);
|
|
264
304
|
return {
|
|
265
|
-
composition: contextualComposition
|
|
305
|
+
composition: contextualComposition ? contextualComposition : initialCompositionValue,
|
|
266
306
|
isContextualEditing: Boolean(contextualComposition)
|
|
267
307
|
};
|
|
268
308
|
};
|
|
@@ -300,12 +340,12 @@ function UniformComposition({
|
|
|
300
340
|
initialCompositionValue: data,
|
|
301
341
|
enhance: contextualEditingEnhancer
|
|
302
342
|
});
|
|
303
|
-
return /* @__PURE__ */
|
|
343
|
+
return /* @__PURE__ */ React4.createElement(
|
|
304
344
|
UniformCompositionContext.Provider,
|
|
305
345
|
{
|
|
306
346
|
value: { data: composition, behaviorTracking, resolveRenderer, isContextualEditing }
|
|
307
347
|
},
|
|
308
|
-
/* @__PURE__ */
|
|
348
|
+
/* @__PURE__ */ React4.createElement(ContextualEditingComponentWrapper, { component: composition }, /* @__PURE__ */ React4.createElement(
|
|
309
349
|
UniformComponent,
|
|
310
350
|
{
|
|
311
351
|
data: composition,
|
|
@@ -328,27 +368,29 @@ function ContextualEditingComponentWrapper({
|
|
|
328
368
|
emptyPlaceholder,
|
|
329
369
|
children
|
|
330
370
|
}) {
|
|
331
|
-
var _a
|
|
371
|
+
var _a;
|
|
332
372
|
const isPlaceholder = isComponentPlaceholderId(component == null ? void 0 : component._id);
|
|
333
373
|
const { isContextualEditing } = useUniformCurrentComposition();
|
|
334
374
|
const isReadOnly = ((_a = component == null ? void 0 : component._contextualEditing) == null ? void 0 : _a.isEditable) ? void 0 : "true";
|
|
335
|
-
|
|
336
|
-
|
|
375
|
+
if (!isContextualEditing) {
|
|
376
|
+
return /* @__PURE__ */ React5.createElement(React5.Fragment, null, children);
|
|
377
|
+
}
|
|
378
|
+
if (isPlaceholder && emptyPlaceholder === null) {
|
|
379
|
+
return null;
|
|
380
|
+
}
|
|
381
|
+
return /* @__PURE__ */ React5.createElement(
|
|
382
|
+
PureContextualEditingComponentWrapper,
|
|
337
383
|
{
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
"data-component-title": (_e = (_d = (_c = component == null ? void 0 : component.parameters) == null ? void 0 : _c.title) == null ? void 0 : _d.value) != null ? _e : "",
|
|
349
|
-
"data-is-readonly": isReadOnly
|
|
350
|
-
}
|
|
351
|
-
), isPlaceholder && emptyPlaceholder !== void 0 ? emptyPlaceholder : children, /* @__PURE__ */ React4.createElement("script", { "data-role": IN_CONTEXT_EDITOR_COMPONENT_END_ROLE }));
|
|
384
|
+
isPlaceholder,
|
|
385
|
+
parentComponent,
|
|
386
|
+
component,
|
|
387
|
+
slotName,
|
|
388
|
+
indexInSlot,
|
|
389
|
+
slotChildrenCount,
|
|
390
|
+
isReadOnly
|
|
391
|
+
},
|
|
392
|
+
isPlaceholder && emptyPlaceholder !== void 0 ? emptyPlaceholder : children
|
|
393
|
+
);
|
|
352
394
|
}
|
|
353
395
|
|
|
354
396
|
// src/components/UniformSlot.tsx
|
|
@@ -366,7 +408,7 @@ function UniformSlot({
|
|
|
366
408
|
}
|
|
367
409
|
const slot = (_a = parentData.slots) == null ? void 0 : _a[name];
|
|
368
410
|
if (!slot || !Array.isArray(slot)) {
|
|
369
|
-
if (process.env.NODE_ENV === "development" && parentData.type !==
|
|
411
|
+
if (process.env.NODE_ENV === "development" && parentData.type !== EMPTY_COMPOSITION3.type) {
|
|
370
412
|
console.warn(
|
|
371
413
|
`[canvas-dev] slot '${name}' was rendered, but it was not defined on its component. This is expected if the slot is optional, otherwise it may indicate a typo. Component:`,
|
|
372
414
|
parentData
|
|
@@ -387,13 +429,13 @@ function UniformSlot({
|
|
|
387
429
|
emptyPlaceholder
|
|
388
430
|
});
|
|
389
431
|
const elements = children ? children({ child, component, key: `wrapped-inner-${index}` }) : child;
|
|
390
|
-
return
|
|
432
|
+
return React6.createElement(React6.Fragment, { key: index }, elements);
|
|
391
433
|
});
|
|
392
434
|
if (!wrapperComponent) {
|
|
393
|
-
return
|
|
435
|
+
return React6.createElement(React6.Fragment, void 0, finalChildren);
|
|
394
436
|
}
|
|
395
437
|
const Wrapper = wrapperComponent;
|
|
396
|
-
return /* @__PURE__ */
|
|
438
|
+
return /* @__PURE__ */ React6.createElement(Wrapper, { items: finalChildren, slotName: name });
|
|
397
439
|
}
|
|
398
440
|
function renderComponent({
|
|
399
441
|
component,
|
|
@@ -425,7 +467,7 @@ function renderComponent({
|
|
|
425
467
|
});
|
|
426
468
|
}
|
|
427
469
|
);
|
|
428
|
-
return /* @__PURE__ */
|
|
470
|
+
return /* @__PURE__ */ React6.createElement(
|
|
429
471
|
ContextualEditingComponentWrapper,
|
|
430
472
|
{
|
|
431
473
|
component,
|
|
@@ -456,7 +498,7 @@ function renderComponent({
|
|
|
456
498
|
});
|
|
457
499
|
}
|
|
458
500
|
);
|
|
459
|
-
return /* @__PURE__ */
|
|
501
|
+
return /* @__PURE__ */ React6.createElement(
|
|
460
502
|
ContextualEditingComponentWrapper,
|
|
461
503
|
{
|
|
462
504
|
component,
|
|
@@ -470,7 +512,7 @@ function renderComponent({
|
|
|
470
512
|
);
|
|
471
513
|
} else if (RenderComponent) {
|
|
472
514
|
const props = convertComponentToProps(component);
|
|
473
|
-
return /* @__PURE__ */
|
|
515
|
+
return /* @__PURE__ */ React6.createElement(UniformComponent, { key, data: component, resolveRenderer }, /* @__PURE__ */ React6.createElement(
|
|
474
516
|
ContextualEditingComponentWrapper,
|
|
475
517
|
{
|
|
476
518
|
component,
|
|
@@ -480,7 +522,7 @@ function renderComponent({
|
|
|
480
522
|
slotChildrenCount,
|
|
481
523
|
emptyPlaceholder
|
|
482
524
|
},
|
|
483
|
-
/* @__PURE__ */
|
|
525
|
+
/* @__PURE__ */ React6.createElement(RenderComponent, { ...props })
|
|
484
526
|
));
|
|
485
527
|
} else if (process.env.NODE_ENV !== "production") {
|
|
486
528
|
console.warn(
|
|
@@ -527,9 +569,9 @@ function UniformComponent({
|
|
|
527
569
|
hasParentLayout: Boolean(parentData.data),
|
|
528
570
|
resolveRenderer: contextValue.resolveRenderer
|
|
529
571
|
});
|
|
530
|
-
return /* @__PURE__ */
|
|
572
|
+
return /* @__PURE__ */ React7.createElement(UniformComponentContext.Provider, { value: contextValue }, contextContextProviderPresent ? (
|
|
531
573
|
/* auto-track behavior signals when in a Canvas context */
|
|
532
|
-
/* @__PURE__ */
|
|
574
|
+
/* @__PURE__ */ React7.createElement(TrackComponent, { behavior: enrichmentTags }, resolvedChildren)
|
|
533
575
|
) : resolvedChildren);
|
|
534
576
|
}
|
|
535
577
|
function resolveChildren({
|
|
@@ -542,14 +584,14 @@ function resolveChildren({
|
|
|
542
584
|
if (!children && !hasParentLayout) {
|
|
543
585
|
const topLevelComponent = resolveRenderer({ type: data.type });
|
|
544
586
|
if (topLevelComponent) {
|
|
545
|
-
children =
|
|
587
|
+
children = React7.createElement(topLevelComponent, convertComponentToProps(data));
|
|
546
588
|
} else {
|
|
547
589
|
if (Object.keys((_a = data.slots) != null ? _a : {}).length > 1 && process.env.NODE_ENV === "development") {
|
|
548
590
|
console.warn(
|
|
549
591
|
`[canvas-dev] All the slots in component '${data.type}' are rendered in no particular order. Use '<UniformSlot name={slotName} />' to reliably render the slots.`
|
|
550
592
|
);
|
|
551
593
|
}
|
|
552
|
-
children = Object.keys(data.slots || {}).map((slotName) => /* @__PURE__ */
|
|
594
|
+
children = Object.keys(data.slots || {}).map((slotName) => /* @__PURE__ */ React7.createElement(UniformSlot, { key: slotName, name: slotName }));
|
|
553
595
|
}
|
|
554
596
|
}
|
|
555
597
|
const renderChildren = typeof children === "function" ? children(convertComponentToProps(data)) : children;
|
|
@@ -557,8 +599,8 @@ function resolveChildren({
|
|
|
557
599
|
}
|
|
558
600
|
|
|
559
601
|
// src/components/UniformPlayground.tsx
|
|
560
|
-
import { EMPTY_COMPOSITION as
|
|
561
|
-
import
|
|
602
|
+
import { EMPTY_COMPOSITION as EMPTY_COMPOSITION4 } from "@uniformdev/canvas";
|
|
603
|
+
import React8, { useMemo as useMemo2 } from "react";
|
|
562
604
|
var UniformPlayground = ({
|
|
563
605
|
resolveRenderer,
|
|
564
606
|
decorators = [],
|
|
@@ -568,14 +610,14 @@ var UniformPlayground = ({
|
|
|
568
610
|
children
|
|
569
611
|
}) => {
|
|
570
612
|
const { composition, isContextualEditing } = useUniformContextualEditing({
|
|
571
|
-
initialCompositionValue:
|
|
613
|
+
initialCompositionValue: EMPTY_COMPOSITION4,
|
|
572
614
|
enhance: contextualEditingEnhancer
|
|
573
615
|
});
|
|
574
616
|
const renderedComponent = useMemo2(() => {
|
|
575
617
|
if (!composition) {
|
|
576
618
|
return null;
|
|
577
619
|
}
|
|
578
|
-
let component = /* @__PURE__ */
|
|
620
|
+
let component = /* @__PURE__ */ React8.createElement(ContextualEditingComponentWrapper, { component: composition }, /* @__PURE__ */ React8.createElement(
|
|
579
621
|
UniformComponent,
|
|
580
622
|
{
|
|
581
623
|
data: composition,
|
|
@@ -586,7 +628,7 @@ var UniformPlayground = ({
|
|
|
586
628
|
children
|
|
587
629
|
));
|
|
588
630
|
decorators.forEach((Decorator) => {
|
|
589
|
-
component = /* @__PURE__ */
|
|
631
|
+
component = /* @__PURE__ */ React8.createElement(Decorator, { data: composition }, component);
|
|
590
632
|
});
|
|
591
633
|
return component;
|
|
592
634
|
}, [
|
|
@@ -597,7 +639,7 @@ var UniformPlayground = ({
|
|
|
597
639
|
behaviorTracking,
|
|
598
640
|
contextualEditingDefaultPlaceholder
|
|
599
641
|
]);
|
|
600
|
-
return /* @__PURE__ */
|
|
642
|
+
return /* @__PURE__ */ React8.createElement(
|
|
601
643
|
UniformCompositionContext.Provider,
|
|
602
644
|
{
|
|
603
645
|
value: { data: composition, behaviorTracking, resolveRenderer, isContextualEditing }
|
|
@@ -616,55 +658,55 @@ import {
|
|
|
616
658
|
isRichTextValue,
|
|
617
659
|
isRichTextValueConsideredEmpty
|
|
618
660
|
} from "@uniformdev/richtext";
|
|
619
|
-
import
|
|
661
|
+
import React18, { useMemo as useMemo3 } from "react";
|
|
620
662
|
|
|
621
663
|
// src/components/UniformRichText/UniformRichTextNode.tsx
|
|
622
664
|
import { isRichTextNode } from "@uniformdev/richtext";
|
|
623
|
-
import
|
|
665
|
+
import React17 from "react";
|
|
624
666
|
|
|
625
667
|
// src/components/UniformRichText/nodes/HeadingRichTextNode.tsx
|
|
626
|
-
import
|
|
668
|
+
import React9 from "react";
|
|
627
669
|
var HeadingRichTextNode = ({ children, node }) => {
|
|
628
670
|
const { tag } = node;
|
|
629
671
|
const HTag = tag != null ? tag : "h1";
|
|
630
|
-
return /* @__PURE__ */
|
|
672
|
+
return /* @__PURE__ */ React9.createElement(HTag, null, children);
|
|
631
673
|
};
|
|
632
674
|
|
|
633
675
|
// src/components/UniformRichText/nodes/LinebreakRichTextNode.tsx
|
|
634
|
-
import
|
|
676
|
+
import React10 from "react";
|
|
635
677
|
var LinebreakRichTextNode = () => {
|
|
636
|
-
return /* @__PURE__ */
|
|
678
|
+
return /* @__PURE__ */ React10.createElement("br", null);
|
|
637
679
|
};
|
|
638
680
|
|
|
639
681
|
// src/components/UniformRichText/nodes/LinkRichTextNode.tsx
|
|
640
682
|
import { linkParamValueToHref } from "@uniformdev/richtext";
|
|
641
|
-
import
|
|
683
|
+
import React11 from "react";
|
|
642
684
|
var LinkRichTextNode = ({ children, node }) => {
|
|
643
685
|
const { link } = node;
|
|
644
|
-
return /* @__PURE__ */
|
|
686
|
+
return /* @__PURE__ */ React11.createElement("a", { href: linkParamValueToHref(link) }, children);
|
|
645
687
|
};
|
|
646
688
|
|
|
647
689
|
// src/components/UniformRichText/nodes/ListItemRichTextNode.tsx
|
|
648
|
-
import
|
|
690
|
+
import React12 from "react";
|
|
649
691
|
var ListItemRichTextNode = ({ children, node }) => {
|
|
650
692
|
const { value } = node;
|
|
651
|
-
return /* @__PURE__ */
|
|
693
|
+
return /* @__PURE__ */ React12.createElement("li", { value: Number.isFinite(value) && value > 0 ? value : void 0 }, children);
|
|
652
694
|
};
|
|
653
695
|
|
|
654
696
|
// src/components/UniformRichText/nodes/ListRichTextNode.tsx
|
|
655
|
-
import
|
|
697
|
+
import React13 from "react";
|
|
656
698
|
var ListRichTextNode = ({ children, node }) => {
|
|
657
699
|
const { tag, start } = node;
|
|
658
700
|
const ListTag = tag != null ? tag : "ul";
|
|
659
|
-
return /* @__PURE__ */
|
|
701
|
+
return /* @__PURE__ */ React13.createElement(ListTag, { start: Number.isFinite(start) && start > 0 ? start : void 0 }, children);
|
|
660
702
|
};
|
|
661
703
|
|
|
662
704
|
// src/components/UniformRichText/nodes/ParagraphRichTextNode.tsx
|
|
663
705
|
import { isPureDirection, isPureTextAlign } from "@uniformdev/richtext";
|
|
664
|
-
import
|
|
706
|
+
import React14 from "react";
|
|
665
707
|
var ParagraphRichTextNode = ({ children, node }) => {
|
|
666
708
|
const { format, direction } = node;
|
|
667
|
-
return /* @__PURE__ */
|
|
709
|
+
return /* @__PURE__ */ React14.createElement(
|
|
668
710
|
"p",
|
|
669
711
|
{
|
|
670
712
|
dir: isPureDirection(direction) ? direction : void 0,
|
|
@@ -675,18 +717,18 @@ var ParagraphRichTextNode = ({ children, node }) => {
|
|
|
675
717
|
};
|
|
676
718
|
|
|
677
719
|
// src/components/UniformRichText/nodes/TabRichTextNode.tsx
|
|
678
|
-
import
|
|
720
|
+
import React15 from "react";
|
|
679
721
|
var TabRichTextNode = () => {
|
|
680
|
-
return /* @__PURE__ */
|
|
722
|
+
return /* @__PURE__ */ React15.createElement(React15.Fragment, null, " ");
|
|
681
723
|
};
|
|
682
724
|
|
|
683
725
|
// src/components/UniformRichText/nodes/TextRichTextNode.tsx
|
|
684
726
|
import { getRichTextTagsFromTextFormat } from "@uniformdev/richtext";
|
|
685
|
-
import
|
|
727
|
+
import React16 from "react";
|
|
686
728
|
var TextRichTextNode = ({ node }) => {
|
|
687
729
|
const { text, format } = node;
|
|
688
730
|
const tags = getRichTextTagsFromTextFormat(format);
|
|
689
|
-
return /* @__PURE__ */
|
|
731
|
+
return /* @__PURE__ */ React16.createElement(React16.Fragment, null, tags.length > 0 ? tags.reduceRight((children, Tag) => /* @__PURE__ */ React16.createElement(Tag, null, children), text) : text);
|
|
690
732
|
};
|
|
691
733
|
|
|
692
734
|
// src/components/UniformRichText/UniformRichTextNode.tsx
|
|
@@ -701,8 +743,8 @@ function UniformRichTextNode({ node, ...props }) {
|
|
|
701
743
|
if (!NodeRenderer) {
|
|
702
744
|
return null;
|
|
703
745
|
}
|
|
704
|
-
const children = node.children ? node.children.map((childNode, i) => /* @__PURE__ */
|
|
705
|
-
return /* @__PURE__ */
|
|
746
|
+
const children = node.children ? node.children.map((childNode, i) => /* @__PURE__ */ React17.createElement(UniformRichTextNode, { ...props, key: i, node: childNode })) : null;
|
|
747
|
+
return /* @__PURE__ */ React17.createElement(NodeRenderer, { node }, children);
|
|
706
748
|
}
|
|
707
749
|
var rendererMap = /* @__PURE__ */ new Map([
|
|
708
750
|
["heading", HeadingRichTextNode],
|
|
@@ -711,12 +753,12 @@ var rendererMap = /* @__PURE__ */ new Map([
|
|
|
711
753
|
["list", ListRichTextNode],
|
|
712
754
|
["listitem", ListItemRichTextNode],
|
|
713
755
|
["paragraph", ParagraphRichTextNode],
|
|
714
|
-
["quote", ({ children }) => /* @__PURE__ */
|
|
756
|
+
["quote", ({ children }) => /* @__PURE__ */ React17.createElement("blockquote", null, children)],
|
|
715
757
|
[
|
|
716
758
|
"code",
|
|
717
|
-
({ children }) => /* @__PURE__ */
|
|
759
|
+
({ children }) => /* @__PURE__ */ React17.createElement("pre", null, /* @__PURE__ */ React17.createElement("code", null, children))
|
|
718
760
|
],
|
|
719
|
-
["root", ({ children }) => /* @__PURE__ */
|
|
761
|
+
["root", ({ children }) => /* @__PURE__ */ React17.createElement(React17.Fragment, null, children)],
|
|
720
762
|
["text", TextRichTextNode],
|
|
721
763
|
["tab", TabRichTextNode]
|
|
722
764
|
]);
|
|
@@ -725,7 +767,7 @@ var resolveRichTextDefaultRenderer = (node) => {
|
|
|
725
767
|
};
|
|
726
768
|
|
|
727
769
|
// src/components/UniformRichText/UniformRichText.tsx
|
|
728
|
-
var UniformRichText =
|
|
770
|
+
var UniformRichText = React18.forwardRef(function UniformRichText2({ parameterId, resolveRichTextRenderer, as: Tag = "div", ...props }, ref) {
|
|
729
771
|
const { data: componentData } = useUniformCurrentComponent();
|
|
730
772
|
const parameter = useMemo3(() => {
|
|
731
773
|
var _a;
|
|
@@ -734,7 +776,7 @@ var UniformRichText = React17.forwardRef(function UniformRichText2({ parameterId
|
|
|
734
776
|
const value = useMemo3(() => parameter == null ? void 0 : parameter.value, [parameter]);
|
|
735
777
|
if (!value || !isRichTextValue(value) || isRichTextValueConsideredEmpty(value))
|
|
736
778
|
return null;
|
|
737
|
-
return Tag === null ? /* @__PURE__ */
|
|
779
|
+
return Tag === null ? /* @__PURE__ */ React18.createElement(UniformRichTextNode, { node: value.root, resolveRichTextRenderer }) : /* @__PURE__ */ React18.createElement(
|
|
738
780
|
Tag,
|
|
739
781
|
{
|
|
740
782
|
ref,
|
|
@@ -745,15 +787,15 @@ var UniformRichText = React17.forwardRef(function UniformRichText2({ parameterId
|
|
|
745
787
|
[ATTRIBUTE_PARAMETER_TYPE]: "richText"
|
|
746
788
|
}
|
|
747
789
|
},
|
|
748
|
-
/* @__PURE__ */
|
|
790
|
+
/* @__PURE__ */ React18.createElement(UniformRichTextNode, { node: value.root, resolveRichTextRenderer })
|
|
749
791
|
);
|
|
750
792
|
});
|
|
751
793
|
|
|
752
794
|
// src/components/UniformText.tsx
|
|
753
|
-
import
|
|
795
|
+
import React20, { useState as useState2 } from "react";
|
|
754
796
|
|
|
755
797
|
// src/components/PureUniformText.tsx
|
|
756
|
-
import
|
|
798
|
+
import React19 from "react";
|
|
757
799
|
var PureUniformText = ({
|
|
758
800
|
as: Tag = "span",
|
|
759
801
|
parameterId,
|
|
@@ -772,10 +814,10 @@ var PureUniformText = ({
|
|
|
772
814
|
return null;
|
|
773
815
|
}
|
|
774
816
|
if (!isContextualEditing) {
|
|
775
|
-
return /* @__PURE__ */
|
|
817
|
+
return /* @__PURE__ */ React19.createElement(Tag, { style: isMultiline ? { whiteSpace: "pre-wrap" } : {}, ...props }, render(value));
|
|
776
818
|
}
|
|
777
819
|
const computedPlaceholder = typeof placeholder === "function" ? placeholder({ id: parameterId }) : placeholder;
|
|
778
|
-
return /* @__PURE__ */
|
|
820
|
+
return /* @__PURE__ */ React19.createElement(
|
|
779
821
|
Tag,
|
|
780
822
|
{
|
|
781
823
|
...props,
|
|
@@ -813,7 +855,7 @@ var UniformText = ({
|
|
|
813
855
|
}
|
|
814
856
|
const placeholderProp = placeholder != null ? placeholder : contextualEditingDefaultPlaceholder;
|
|
815
857
|
const computedPlaceholder = typeof placeholderProp === "function" ? placeholderProp({ id: parameterId }) : placeholderProp;
|
|
816
|
-
return /* @__PURE__ */
|
|
858
|
+
return /* @__PURE__ */ React20.createElement(
|
|
817
859
|
PureUniformText,
|
|
818
860
|
{
|
|
819
861
|
...props,
|
|
@@ -898,6 +940,9 @@ var useUniformContextualEditingState = ({
|
|
|
898
940
|
const { isContextualEditing } = useUniformCurrentComposition();
|
|
899
941
|
const { data: componentData } = useUniformCurrentComponent();
|
|
900
942
|
const [selectedComponentReference, setSelectedComponentReference] = useState3();
|
|
943
|
+
const [previewMode, setPreviewMode] = useState3(
|
|
944
|
+
isContextualEditing ? "editor" : void 0
|
|
945
|
+
);
|
|
901
946
|
const channel = useMemo4(() => {
|
|
902
947
|
if (!isContextualEditing) {
|
|
903
948
|
return;
|
|
@@ -909,15 +954,20 @@ var useUniformContextualEditingState = ({
|
|
|
909
954
|
return channel2;
|
|
910
955
|
}, [isContextualEditing]);
|
|
911
956
|
useEffect3(() => {
|
|
957
|
+
var _a, _b;
|
|
912
958
|
if (!channel) {
|
|
913
959
|
return;
|
|
914
960
|
}
|
|
961
|
+
if (typeof window !== "undefined") {
|
|
962
|
+
setPreviewMode((_b = (_a = window.__UNIFORM_CONTEXTUAL_EDITING__) == null ? void 0 : _a.state) == null ? void 0 : _b.previewMode);
|
|
963
|
+
}
|
|
915
964
|
const unsubscribe = channel.on("update-contextual-editing-state-internal", async (message) => {
|
|
916
|
-
var
|
|
965
|
+
var _a2;
|
|
917
966
|
if (!isUpdateContextualEditingStateInternalMessage(message)) {
|
|
918
967
|
return;
|
|
919
968
|
}
|
|
920
|
-
|
|
969
|
+
setPreviewMode(message.state.previewMode);
|
|
970
|
+
if (!global && (componentData == null ? void 0 : componentData._id) !== ((_a2 = message.state.selectedComponentReference) == null ? void 0 : _a2.parentId)) {
|
|
921
971
|
setSelectedComponentReference(void 0);
|
|
922
972
|
return;
|
|
923
973
|
}
|
|
@@ -926,13 +976,14 @@ var useUniformContextualEditingState = ({
|
|
|
926
976
|
return () => {
|
|
927
977
|
unsubscribe();
|
|
928
978
|
};
|
|
929
|
-
}, [global, channel, componentData == null ? void 0 : componentData._id, setSelectedComponentReference]);
|
|
979
|
+
}, [global, channel, componentData == null ? void 0 : componentData._id, setSelectedComponentReference, setPreviewMode]);
|
|
930
980
|
return useMemo4(
|
|
931
981
|
() => ({
|
|
932
982
|
isContextualEditing,
|
|
933
|
-
selectedComponentReference
|
|
983
|
+
selectedComponentReference,
|
|
984
|
+
previewMode
|
|
934
985
|
}),
|
|
935
|
-
[isContextualEditing, selectedComponentReference]
|
|
986
|
+
[isContextualEditing, selectedComponentReference, previewMode]
|
|
936
987
|
);
|
|
937
988
|
};
|
|
938
989
|
export {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@uniformdev/canvas-react",
|
|
3
|
-
"version": "19.62.
|
|
3
|
+
"version": "19.62.1-alpha.127+d49e5a0782",
|
|
4
4
|
"description": "React SDK for Uniform Canvas",
|
|
5
5
|
"license": "SEE LICENSE IN LICENSE.txt",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -45,17 +45,17 @@
|
|
|
45
45
|
"document": "api-extractor run --local"
|
|
46
46
|
},
|
|
47
47
|
"dependencies": {
|
|
48
|
-
"@uniformdev/canvas": "19.62.
|
|
49
|
-
"@uniformdev/context": "19.62.
|
|
50
|
-
"@uniformdev/context-react": "19.62.
|
|
51
|
-
"@uniformdev/richtext": "19.62.
|
|
48
|
+
"@uniformdev/canvas": "19.62.1-alpha.127+d49e5a0782",
|
|
49
|
+
"@uniformdev/context": "19.62.1-alpha.127+d49e5a0782",
|
|
50
|
+
"@uniformdev/context-react": "19.62.1-alpha.127+d49e5a0782",
|
|
51
|
+
"@uniformdev/richtext": "19.62.1-alpha.127+d49e5a0782"
|
|
52
52
|
},
|
|
53
53
|
"peerDependencies": {
|
|
54
54
|
"react": ">= 16 || 17 || 18",
|
|
55
55
|
"react-dom": ">=16"
|
|
56
56
|
},
|
|
57
57
|
"devDependencies": {
|
|
58
|
-
"@types/react": "18.2.
|
|
58
|
+
"@types/react": "18.2.40",
|
|
59
59
|
"react": "18.2.0",
|
|
60
60
|
"react-dom": "18.2.0"
|
|
61
61
|
},
|
|
@@ -65,5 +65,5 @@
|
|
|
65
65
|
"publishConfig": {
|
|
66
66
|
"access": "public"
|
|
67
67
|
},
|
|
68
|
-
"gitHead": "
|
|
68
|
+
"gitHead": "d49e5a07824d69e5df3a92ff10bc9acd88d0bc22"
|
|
69
69
|
}
|