@uniformdev/canvas-react 19.38.2 → 19.38.3-alpha.78
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/index.d.mts +35 -3
- package/dist/index.d.ts +35 -3
- package/dist/index.esm.js +99 -48
- package/dist/index.js +117 -64
- package/dist/index.mjs +99 -48
- package/package.json +7 -7
package/dist/index.js
CHANGED
|
@@ -34,6 +34,8 @@ __export(src_exports, {
|
|
|
34
34
|
NOT_IMPLEMENTED_COMPONENT: () => NOT_IMPLEMENTED_COMPONENT,
|
|
35
35
|
UniformComponent: () => UniformComponent,
|
|
36
36
|
UniformComposition: () => UniformComposition,
|
|
37
|
+
UniformCompositionContext: () => UniformCompositionContext,
|
|
38
|
+
UniformPlayground: () => UniformPlayground,
|
|
37
39
|
UniformRichText: () => UniformRichText,
|
|
38
40
|
UniformRichTextNode: () => UniformRichTextNode,
|
|
39
41
|
UniformSlot: () => UniformSlot,
|
|
@@ -362,9 +364,10 @@ function ContextualEditingComponentWrapper({
|
|
|
362
364
|
emptyPlaceholder,
|
|
363
365
|
children
|
|
364
366
|
}) {
|
|
365
|
-
var _a, _b, _c, _d;
|
|
367
|
+
var _a, _b, _c, _d, _e;
|
|
366
368
|
const isPlaceholder = (component == null ? void 0 : component._id) === import_canvas4.PLACEHOLDER_ID;
|
|
367
369
|
const { isContextualEditing } = useUniformCurrentComposition();
|
|
370
|
+
const isReadOnly = ((_a = component == null ? void 0 : component._contextualEditing) == null ? void 0 : _a.isEditable) ? void 0 : "true";
|
|
368
371
|
return !isContextualEditing ? /* @__PURE__ */ import_react4.default.createElement(import_react4.default.Fragment, null, children) : isPlaceholder && emptyPlaceholder === null ? null : /* @__PURE__ */ import_react4.default.createElement(import_react4.default.Fragment, null, /* @__PURE__ */ import_react4.default.createElement(
|
|
369
372
|
"script",
|
|
370
373
|
{
|
|
@@ -377,8 +380,9 @@ function ContextualEditingComponentWrapper({
|
|
|
377
380
|
"data-total-components": slotChildrenCount != null ? slotChildrenCount : "",
|
|
378
381
|
"data-component-name": component == null ? void 0 : component.type,
|
|
379
382
|
"data-is-placeholder": isPlaceholder ? "true" : void 0,
|
|
380
|
-
"data-is-localized": ((
|
|
381
|
-
"data-component-title": (
|
|
383
|
+
"data-is-localized": ((_b = component == null ? void 0 : component.parameters) == null ? void 0 : _b[import_canvas4.CANVAS_LOCALE_TAG_PARAM]) ? "true" : void 0,
|
|
384
|
+
"data-component-title": (_e = (_d = (_c = component == null ? void 0 : component.parameters) == null ? void 0 : _c.title) == null ? void 0 : _d.value) != null ? _e : "",
|
|
385
|
+
"data-is-readonly": isReadOnly
|
|
382
386
|
}
|
|
383
387
|
), isPlaceholder && emptyPlaceholder !== void 0 ? emptyPlaceholder : children, /* @__PURE__ */ import_react4.default.createElement("script", { "data-role": import_canvas4.IN_CONTEXT_EDITOR_COMPONENT_END_ROLE }));
|
|
384
388
|
}
|
|
@@ -388,7 +392,8 @@ function UniformSlot({
|
|
|
388
392
|
name,
|
|
389
393
|
resolveRenderer,
|
|
390
394
|
children,
|
|
391
|
-
emptyPlaceholder
|
|
395
|
+
emptyPlaceholder,
|
|
396
|
+
wrapperComponent
|
|
392
397
|
}) {
|
|
393
398
|
var _a;
|
|
394
399
|
const { data: parentData, resolveRenderer: parentResolveRenderer } = useUniformCurrentComponent();
|
|
@@ -406,12 +411,10 @@ function UniformSlot({
|
|
|
406
411
|
return null;
|
|
407
412
|
}
|
|
408
413
|
const resolver = resolveRenderer != null ? resolveRenderer : parentResolveRenderer;
|
|
409
|
-
const systemResolver = defaultSystemComponentResolver;
|
|
410
414
|
const finalChildren = slot.map((component, index) => {
|
|
411
415
|
const child = renderComponent({
|
|
412
416
|
component,
|
|
413
417
|
resolveRenderer: resolver,
|
|
414
|
-
resolveSystem: systemResolver,
|
|
415
418
|
key: `inner-${index}`,
|
|
416
419
|
indexInSlot: index,
|
|
417
420
|
slotName: name,
|
|
@@ -422,12 +425,15 @@ function UniformSlot({
|
|
|
422
425
|
const elements = children ? children({ child, component, key: `wrapped-inner-${index}` }) : child;
|
|
423
426
|
return import_react5.default.createElement(import_react5.default.Fragment, { key: index }, elements);
|
|
424
427
|
});
|
|
425
|
-
|
|
428
|
+
if (!wrapperComponent) {
|
|
429
|
+
return import_react5.default.createElement(import_react5.default.Fragment, void 0, finalChildren);
|
|
430
|
+
}
|
|
431
|
+
const Wrapper = wrapperComponent;
|
|
432
|
+
return /* @__PURE__ */ import_react5.default.createElement(Wrapper, { items: finalChildren, slotName: name });
|
|
426
433
|
}
|
|
427
434
|
function renderComponent({
|
|
428
435
|
component,
|
|
429
436
|
resolveRenderer,
|
|
430
|
-
resolveSystem,
|
|
431
437
|
key = 0,
|
|
432
438
|
indexInSlot,
|
|
433
439
|
slotName,
|
|
@@ -437,7 +443,7 @@ function renderComponent({
|
|
|
437
443
|
}) {
|
|
438
444
|
const RenderComponent = resolveRenderer == null ? void 0 : resolveRenderer(component);
|
|
439
445
|
if (component.type === import_canvas5.CANVAS_TEST_TYPE) {
|
|
440
|
-
const testComponent =
|
|
446
|
+
const testComponent = defaultSystemComponentResolver.test(
|
|
441
447
|
component,
|
|
442
448
|
key,
|
|
443
449
|
(variantComponent, key2) => {
|
|
@@ -445,7 +451,6 @@ function renderComponent({
|
|
|
445
451
|
return renderComponent({
|
|
446
452
|
component: variantComponent,
|
|
447
453
|
resolveRenderer,
|
|
448
|
-
resolveSystem,
|
|
449
454
|
key: key2,
|
|
450
455
|
parentComponent: component,
|
|
451
456
|
slotName: import_canvas5.CANVAS_TEST_SLOT,
|
|
@@ -469,7 +474,7 @@ function renderComponent({
|
|
|
469
474
|
testComponent
|
|
470
475
|
);
|
|
471
476
|
} else if (component.type === import_canvas5.CANVAS_PERSONALIZE_TYPE) {
|
|
472
|
-
const personalizationComponent =
|
|
477
|
+
const personalizationComponent = defaultSystemComponentResolver.personalization(
|
|
473
478
|
component,
|
|
474
479
|
key,
|
|
475
480
|
(variantComponent, key2) => {
|
|
@@ -477,7 +482,6 @@ function renderComponent({
|
|
|
477
482
|
return renderComponent({
|
|
478
483
|
component: variantComponent,
|
|
479
484
|
resolveRenderer,
|
|
480
|
-
resolveSystem,
|
|
481
485
|
key: key2,
|
|
482
486
|
parentComponent: component,
|
|
483
487
|
slotName: import_canvas5.CANVAS_PERSONALIZE_SLOT,
|
|
@@ -588,57 +592,107 @@ function resolveChildren({
|
|
|
588
592
|
return renderChildren;
|
|
589
593
|
}
|
|
590
594
|
|
|
595
|
+
// src/components/UniformPlayground.tsx
|
|
596
|
+
var import_canvas7 = require("@uniformdev/canvas");
|
|
597
|
+
var import_react7 = __toESM(require("react"));
|
|
598
|
+
var UniformPlayground = ({
|
|
599
|
+
resolveRenderer,
|
|
600
|
+
decorators = [],
|
|
601
|
+
contextualEditingEnhancer,
|
|
602
|
+
behaviorTracking,
|
|
603
|
+
contextualEditingDefaultPlaceholder,
|
|
604
|
+
children
|
|
605
|
+
}) => {
|
|
606
|
+
const { composition, isContextualEditing } = useUniformContextualEditing({
|
|
607
|
+
initialCompositionValue: import_canvas7.EMPTY_COMPOSITION,
|
|
608
|
+
enhance: contextualEditingEnhancer
|
|
609
|
+
});
|
|
610
|
+
const renderedComponent = (0, import_react7.useMemo)(() => {
|
|
611
|
+
if (!composition) {
|
|
612
|
+
return null;
|
|
613
|
+
}
|
|
614
|
+
let component = /* @__PURE__ */ import_react7.default.createElement(
|
|
615
|
+
UniformComponent,
|
|
616
|
+
{
|
|
617
|
+
data: composition,
|
|
618
|
+
behaviorTracking,
|
|
619
|
+
resolveRenderer,
|
|
620
|
+
contextualEditingDefaultPlaceholder
|
|
621
|
+
},
|
|
622
|
+
children
|
|
623
|
+
);
|
|
624
|
+
decorators.forEach((Decorator) => {
|
|
625
|
+
component = /* @__PURE__ */ import_react7.default.createElement(Decorator, { data: composition }, component);
|
|
626
|
+
});
|
|
627
|
+
return component;
|
|
628
|
+
}, [
|
|
629
|
+
children,
|
|
630
|
+
resolveRenderer,
|
|
631
|
+
decorators,
|
|
632
|
+
composition,
|
|
633
|
+
behaviorTracking,
|
|
634
|
+
contextualEditingDefaultPlaceholder
|
|
635
|
+
]);
|
|
636
|
+
return /* @__PURE__ */ import_react7.default.createElement(
|
|
637
|
+
UniformCompositionContext.Provider,
|
|
638
|
+
{
|
|
639
|
+
value: { data: composition, behaviorTracking, resolveRenderer, isContextualEditing }
|
|
640
|
+
},
|
|
641
|
+
/* @__PURE__ */ import_react7.default.createElement(ContextualEditingComponentWrapper, { component: composition }, renderedComponent)
|
|
642
|
+
);
|
|
643
|
+
};
|
|
644
|
+
|
|
591
645
|
// src/components/UniformRichText/UniformRichText.tsx
|
|
592
646
|
var import_richtext5 = require("@uniformdev/richtext");
|
|
593
|
-
var
|
|
647
|
+
var import_react17 = __toESM(require("react"));
|
|
594
648
|
|
|
595
649
|
// src/components/UniformRichText/UniformRichTextNode.tsx
|
|
596
650
|
var import_richtext4 = require("@uniformdev/richtext");
|
|
597
|
-
var
|
|
651
|
+
var import_react16 = __toESM(require("react"));
|
|
598
652
|
|
|
599
653
|
// src/components/UniformRichText/nodes/HeadingRichTextNode.tsx
|
|
600
|
-
var
|
|
654
|
+
var import_react8 = __toESM(require("react"));
|
|
601
655
|
var HeadingRichTextNode = ({ children, node }) => {
|
|
602
656
|
const { tag } = node;
|
|
603
657
|
const HTag = tag != null ? tag : "h1";
|
|
604
|
-
return /* @__PURE__ */
|
|
658
|
+
return /* @__PURE__ */ import_react8.default.createElement(HTag, null, children);
|
|
605
659
|
};
|
|
606
660
|
|
|
607
661
|
// src/components/UniformRichText/nodes/LinebreakRichTextNode.tsx
|
|
608
|
-
var
|
|
662
|
+
var import_react9 = __toESM(require("react"));
|
|
609
663
|
var LinebreakRichTextNode = () => {
|
|
610
|
-
return /* @__PURE__ */
|
|
664
|
+
return /* @__PURE__ */ import_react9.default.createElement("br", null);
|
|
611
665
|
};
|
|
612
666
|
|
|
613
667
|
// src/components/UniformRichText/nodes/LinkRichTextNode.tsx
|
|
614
668
|
var import_richtext = require("@uniformdev/richtext");
|
|
615
|
-
var
|
|
669
|
+
var import_react10 = __toESM(require("react"));
|
|
616
670
|
var LinkRichTextNode = ({ children, node }) => {
|
|
617
671
|
const { link } = node;
|
|
618
|
-
return /* @__PURE__ */
|
|
672
|
+
return /* @__PURE__ */ import_react10.default.createElement("a", { href: (0, import_richtext.linkParamValueToHref)(link) }, children);
|
|
619
673
|
};
|
|
620
674
|
|
|
621
675
|
// src/components/UniformRichText/nodes/ListItemRichTextNode.tsx
|
|
622
|
-
var
|
|
676
|
+
var import_react11 = __toESM(require("react"));
|
|
623
677
|
var ListItemRichTextNode = ({ children, node }) => {
|
|
624
678
|
const { value } = node;
|
|
625
|
-
return /* @__PURE__ */
|
|
679
|
+
return /* @__PURE__ */ import_react11.default.createElement("li", { value: Number.isFinite(value) && value > 0 ? value : void 0 }, children);
|
|
626
680
|
};
|
|
627
681
|
|
|
628
682
|
// src/components/UniformRichText/nodes/ListRichTextNode.tsx
|
|
629
|
-
var
|
|
683
|
+
var import_react12 = __toESM(require("react"));
|
|
630
684
|
var ListRichTextNode = ({ children, node }) => {
|
|
631
685
|
const { tag, start } = node;
|
|
632
686
|
const ListTag = tag != null ? tag : "ul";
|
|
633
|
-
return /* @__PURE__ */
|
|
687
|
+
return /* @__PURE__ */ import_react12.default.createElement(ListTag, { start: Number.isFinite(start) && start > 0 ? start : void 0 }, children);
|
|
634
688
|
};
|
|
635
689
|
|
|
636
690
|
// src/components/UniformRichText/nodes/ParagraphRichTextNode.tsx
|
|
637
691
|
var import_richtext2 = require("@uniformdev/richtext");
|
|
638
|
-
var
|
|
692
|
+
var import_react13 = __toESM(require("react"));
|
|
639
693
|
var ParagraphRichTextNode = ({ children, node }) => {
|
|
640
694
|
const { format, direction } = node;
|
|
641
|
-
return /* @__PURE__ */
|
|
695
|
+
return /* @__PURE__ */ import_react13.default.createElement(
|
|
642
696
|
"p",
|
|
643
697
|
{
|
|
644
698
|
dir: (0, import_richtext2.isPureDirection)(direction) ? direction : void 0,
|
|
@@ -649,18 +703,18 @@ var ParagraphRichTextNode = ({ children, node }) => {
|
|
|
649
703
|
};
|
|
650
704
|
|
|
651
705
|
// src/components/UniformRichText/nodes/TabRichTextNode.tsx
|
|
652
|
-
var
|
|
706
|
+
var import_react14 = __toESM(require("react"));
|
|
653
707
|
var TabRichTextNode = () => {
|
|
654
|
-
return /* @__PURE__ */
|
|
708
|
+
return /* @__PURE__ */ import_react14.default.createElement(import_react14.default.Fragment, null, " ");
|
|
655
709
|
};
|
|
656
710
|
|
|
657
711
|
// src/components/UniformRichText/nodes/TextRichTextNode.tsx
|
|
658
712
|
var import_richtext3 = require("@uniformdev/richtext");
|
|
659
|
-
var
|
|
713
|
+
var import_react15 = __toESM(require("react"));
|
|
660
714
|
var TextRichTextNode = ({ node }) => {
|
|
661
715
|
const { text, format } = node;
|
|
662
716
|
const tags = (0, import_richtext3.getRichTextTagsFromTextFormat)(format);
|
|
663
|
-
return /* @__PURE__ */
|
|
717
|
+
return /* @__PURE__ */ import_react15.default.createElement(import_react15.default.Fragment, null, tags.length > 0 ? tags.reduceRight((children, Tag) => /* @__PURE__ */ import_react15.default.createElement(Tag, null, children), text) : text);
|
|
664
718
|
};
|
|
665
719
|
|
|
666
720
|
// src/components/UniformRichText/UniformRichTextNode.tsx
|
|
@@ -675,8 +729,8 @@ function UniformRichTextNode({ node, ...props }) {
|
|
|
675
729
|
if (!NodeRenderer) {
|
|
676
730
|
return null;
|
|
677
731
|
}
|
|
678
|
-
const children = node.children ? node.children.map((childNode, i) => /* @__PURE__ */
|
|
679
|
-
return /* @__PURE__ */
|
|
732
|
+
const children = node.children ? node.children.map((childNode, i) => /* @__PURE__ */ import_react16.default.createElement(UniformRichTextNode, { ...props, key: i, node: childNode })) : null;
|
|
733
|
+
return /* @__PURE__ */ import_react16.default.createElement(NodeRenderer, { node }, children);
|
|
680
734
|
}
|
|
681
735
|
var rendererMap = /* @__PURE__ */ new Map([
|
|
682
736
|
["heading", HeadingRichTextNode],
|
|
@@ -685,12 +739,12 @@ var rendererMap = /* @__PURE__ */ new Map([
|
|
|
685
739
|
["list", ListRichTextNode],
|
|
686
740
|
["listitem", ListItemRichTextNode],
|
|
687
741
|
["paragraph", ParagraphRichTextNode],
|
|
688
|
-
["quote", ({ children }) => /* @__PURE__ */
|
|
742
|
+
["quote", ({ children }) => /* @__PURE__ */ import_react16.default.createElement("blockquote", null, children)],
|
|
689
743
|
[
|
|
690
744
|
"code",
|
|
691
|
-
({ children }) => /* @__PURE__ */
|
|
745
|
+
({ children }) => /* @__PURE__ */ import_react16.default.createElement("pre", null, /* @__PURE__ */ import_react16.default.createElement("code", null, children))
|
|
692
746
|
],
|
|
693
|
-
["root", ({ children }) => /* @__PURE__ */
|
|
747
|
+
["root", ({ children }) => /* @__PURE__ */ import_react16.default.createElement(import_react16.default.Fragment, null, children)],
|
|
694
748
|
["text", TextRichTextNode],
|
|
695
749
|
["tab", TabRichTextNode]
|
|
696
750
|
]);
|
|
@@ -699,20 +753,20 @@ var resolveRichTextDefaultRenderer = (node) => {
|
|
|
699
753
|
};
|
|
700
754
|
|
|
701
755
|
// src/components/UniformRichText/UniformRichText.tsx
|
|
702
|
-
var UniformRichText =
|
|
756
|
+
var UniformRichText = import_react17.default.forwardRef(function UniformRichText2({ parameterId, resolveRichTextRenderer, as: Tag = "div", ...props }, ref) {
|
|
703
757
|
const { data: componentData } = useUniformCurrentComponent();
|
|
704
|
-
const parameter = (0,
|
|
758
|
+
const parameter = (0, import_react17.useMemo)(() => {
|
|
705
759
|
var _a;
|
|
706
760
|
return (_a = componentData == null ? void 0 : componentData.parameters) == null ? void 0 : _a[parameterId];
|
|
707
761
|
}, [componentData, parameterId]);
|
|
708
|
-
const value = (0,
|
|
762
|
+
const value = (0, import_react17.useMemo)(() => parameter == null ? void 0 : parameter.value, [parameter]);
|
|
709
763
|
if (!value || !(0, import_richtext5.isRichTextValue)(value) || (0, import_richtext5.isRichTextValueConsideredEmpty)(value))
|
|
710
764
|
return null;
|
|
711
|
-
return Tag === null ? /* @__PURE__ */
|
|
765
|
+
return Tag === null ? /* @__PURE__ */ import_react17.default.createElement(UniformRichTextNode, { node: value.root, resolveRichTextRenderer }) : /* @__PURE__ */ import_react17.default.createElement(Tag, { ref, ...props }, /* @__PURE__ */ import_react17.default.createElement(UniformRichTextNode, { node: value.root, resolveRichTextRenderer }));
|
|
712
766
|
});
|
|
713
767
|
|
|
714
768
|
// src/components/UniformText.tsx
|
|
715
|
-
var
|
|
769
|
+
var import_react18 = __toESM(require("react"));
|
|
716
770
|
var UniformText = ({
|
|
717
771
|
as: Tag = "span",
|
|
718
772
|
parameterId,
|
|
@@ -724,32 +778,29 @@ var UniformText = ({
|
|
|
724
778
|
var _a, _b;
|
|
725
779
|
const { data: componentData, contextualEditingDefaultPlaceholder } = useUniformCurrentComponent();
|
|
726
780
|
const { isContextualEditing } = useUniformCurrentComposition();
|
|
727
|
-
const [isFocused, setIsFocused] = (0,
|
|
728
|
-
const parameter = (0,
|
|
781
|
+
const [isFocused, setIsFocused] = (0, import_react18.useState)(false);
|
|
782
|
+
const parameter = (0, import_react18.useMemo)(() => {
|
|
729
783
|
var _a2;
|
|
730
784
|
return (_a2 = componentData == null ? void 0 : componentData.parameters) == null ? void 0 : _a2[parameterId];
|
|
731
785
|
}, [componentData, parameterId]);
|
|
732
786
|
const value = parameter == null ? void 0 : parameter.value;
|
|
733
787
|
const isEditable = (_b = (_a = parameter == null ? void 0 : parameter._contextualEditing) == null ? void 0 : _a.isEditable) != null ? _b : false;
|
|
734
788
|
const shouldSkipCustomRendering = isFocused && isEditable;
|
|
735
|
-
const handleOnFocus = (0,
|
|
789
|
+
const handleOnFocus = (0, import_react18.useCallback)(() => {
|
|
736
790
|
setIsFocused(true);
|
|
737
791
|
}, [setIsFocused]);
|
|
738
|
-
const handleOnBlur = (0,
|
|
792
|
+
const handleOnBlur = (0, import_react18.useCallback)(() => {
|
|
739
793
|
setIsFocused(false);
|
|
740
794
|
}, [setIsFocused]);
|
|
741
795
|
if (!parameter) {
|
|
742
|
-
console.warn(
|
|
743
|
-
`UniformText: The parameterId "${parameterId}" was not found in the component of type "${componentData == null ? void 0 : componentData.type}"`
|
|
744
|
-
);
|
|
745
796
|
return null;
|
|
746
797
|
}
|
|
747
798
|
if (!isContextualEditing) {
|
|
748
|
-
return /* @__PURE__ */
|
|
799
|
+
return /* @__PURE__ */ import_react18.default.createElement(Tag, { style: isMultiline ? { whiteSpace: "pre-wrap" } : {}, ...props }, render(value));
|
|
749
800
|
}
|
|
750
801
|
const placeholderProp = placeholder != null ? placeholder : contextualEditingDefaultPlaceholder;
|
|
751
802
|
const computedPlaceholder = typeof placeholderProp === "function" ? placeholderProp({ id: parameterId }) : placeholderProp;
|
|
752
|
-
return /* @__PURE__ */
|
|
803
|
+
return /* @__PURE__ */ import_react18.default.createElement(
|
|
753
804
|
Tag,
|
|
754
805
|
{
|
|
755
806
|
...props,
|
|
@@ -769,35 +820,35 @@ var UniformText = ({
|
|
|
769
820
|
};
|
|
770
821
|
|
|
771
822
|
// src/helpers/getParameterAttributes.ts
|
|
772
|
-
var
|
|
823
|
+
var import_canvas8 = require("@uniformdev/canvas");
|
|
773
824
|
var getParameterAttributes = (options) => {
|
|
774
825
|
return {
|
|
775
|
-
...(0,
|
|
826
|
+
...(0, import_canvas8.getParameterAttributes)(options),
|
|
776
827
|
suppressContentEditableWarning: true
|
|
777
828
|
};
|
|
778
829
|
};
|
|
779
830
|
|
|
780
831
|
// src/hooks/useCompositionEventEffect.ts
|
|
781
|
-
var
|
|
782
|
-
var
|
|
832
|
+
var import_canvas9 = require("@uniformdev/canvas");
|
|
833
|
+
var import_react19 = require("react");
|
|
783
834
|
function useCompositionEventEffect({
|
|
784
835
|
enabled,
|
|
785
836
|
projectId,
|
|
786
837
|
compositionId,
|
|
787
838
|
effect
|
|
788
839
|
}) {
|
|
789
|
-
(0,
|
|
840
|
+
(0, import_react19.useEffect)(() => {
|
|
790
841
|
if (!enabled || !compositionId || !projectId) {
|
|
791
842
|
return;
|
|
792
843
|
}
|
|
793
844
|
let goodbye = void 0;
|
|
794
845
|
const loadEffect = async () => {
|
|
795
|
-
const eventBus = await (0,
|
|
846
|
+
const eventBus = await (0, import_canvas9.createEventBus)();
|
|
796
847
|
if (eventBus) {
|
|
797
|
-
goodbye = (0,
|
|
848
|
+
goodbye = (0, import_canvas9.subscribeToComposition)({
|
|
798
849
|
eventBus,
|
|
799
850
|
compositionId,
|
|
800
|
-
compositionState:
|
|
851
|
+
compositionState: import_canvas9.CANVAS_DRAFT_STATE,
|
|
801
852
|
projectId,
|
|
802
853
|
callback: effect,
|
|
803
854
|
event: "updated"
|
|
@@ -814,31 +865,31 @@ function useCompositionEventEffect({
|
|
|
814
865
|
}
|
|
815
866
|
|
|
816
867
|
// src/hooks/useUniformContextualEditingState.ts
|
|
817
|
-
var
|
|
818
|
-
var
|
|
868
|
+
var import_canvas10 = require("@uniformdev/canvas");
|
|
869
|
+
var import_react20 = require("react");
|
|
819
870
|
var useUniformContextualEditingState = ({
|
|
820
871
|
global = false
|
|
821
872
|
} = {}) => {
|
|
822
873
|
const { isContextualEditing } = useUniformCurrentComposition();
|
|
823
874
|
const { data: componentData } = useUniformCurrentComponent();
|
|
824
|
-
const [selectedComponentReference, setSelectedComponentReference] = (0,
|
|
825
|
-
const channel = (0,
|
|
875
|
+
const [selectedComponentReference, setSelectedComponentReference] = (0, import_react20.useState)();
|
|
876
|
+
const channel = (0, import_react20.useMemo)(() => {
|
|
826
877
|
if (!isContextualEditing) {
|
|
827
878
|
return;
|
|
828
879
|
}
|
|
829
|
-
const channel2 = (0,
|
|
880
|
+
const channel2 = (0, import_canvas10.createCanvasChannel)({
|
|
830
881
|
broadcastTo: [window],
|
|
831
882
|
listenTo: [window]
|
|
832
883
|
});
|
|
833
884
|
return channel2;
|
|
834
885
|
}, [isContextualEditing]);
|
|
835
|
-
(0,
|
|
886
|
+
(0, import_react20.useEffect)(() => {
|
|
836
887
|
if (!channel) {
|
|
837
888
|
return;
|
|
838
889
|
}
|
|
839
890
|
const unsubscribe = channel.on("update-contextual-editing-state-internal", async (message) => {
|
|
840
891
|
var _a;
|
|
841
|
-
if (!(0,
|
|
892
|
+
if (!(0, import_canvas10.isUpdateContextualEditingStateInternalMessage)(message)) {
|
|
842
893
|
return;
|
|
843
894
|
}
|
|
844
895
|
if (!global && (componentData == null ? void 0 : componentData._id) !== ((_a = message.state.selectedComponentReference) == null ? void 0 : _a.parentId)) {
|
|
@@ -862,6 +913,8 @@ var useUniformContextualEditingState = ({
|
|
|
862
913
|
NOT_IMPLEMENTED_COMPONENT,
|
|
863
914
|
UniformComponent,
|
|
864
915
|
UniformComposition,
|
|
916
|
+
UniformCompositionContext,
|
|
917
|
+
UniformPlayground,
|
|
865
918
|
UniformRichText,
|
|
866
919
|
UniformRichTextNode,
|
|
867
920
|
UniformSlot,
|