@uniformdev/canvas-react 19.48.0 → 19.48.1-alpha.8
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 +20 -1
- package/dist/index.d.ts +20 -1
- package/dist/index.esm.js +85 -33
- package/dist/index.js +103 -49
- package/dist/index.mjs +85 -33
- package/package.json +6 -6
package/dist/index.d.mts
CHANGED
|
@@ -257,6 +257,7 @@ type UniformCompositionContextValue = {
|
|
|
257
257
|
behaviorTracking?: UniformCompositionProps['behaviorTracking'];
|
|
258
258
|
isContextualEditing: boolean;
|
|
259
259
|
};
|
|
260
|
+
declare const UniformCompositionContext: React$1.Context<UniformCompositionContextValue>;
|
|
260
261
|
/**
|
|
261
262
|
* Gets the data of the closest `<UniformComposition />` ancestor.
|
|
262
263
|
*/
|
|
@@ -268,6 +269,24 @@ declare function useUniformCurrentComposition(): UniformCompositionContextValue;
|
|
|
268
269
|
*/
|
|
269
270
|
declare function UniformComposition<TRenderProps = unknown>({ data, behaviorTracking, children, resolveRenderer, contextualEditingEnhancer, contextualEditingDefaultPlaceholder, }: UniformCompositionProps<TRenderProps>): React$1.JSX.Element;
|
|
270
271
|
|
|
272
|
+
type UniformPlaygroundDecorator = (options: {
|
|
273
|
+
children: React$1.ReactNode;
|
|
274
|
+
data: ComponentInstance | RootComponentInstance;
|
|
275
|
+
}) => React$1.ReactElement;
|
|
276
|
+
type UniformPlaygroundProps = {
|
|
277
|
+
/**
|
|
278
|
+
* Allows wrapping the playground in custom components.
|
|
279
|
+
* Useful to customize the playground to allow previewing the components in realistic scenarios
|
|
280
|
+
* (e.g. different background color, different parent size)
|
|
281
|
+
* @deprecated This feature is not stable yet and might be changed or removed in a minor release. Do not use it in production environments.
|
|
282
|
+
*/
|
|
283
|
+
decorators?: UniformPlaygroundDecorator[];
|
|
284
|
+
} & Omit<UniformCompositionProps, 'data'>;
|
|
285
|
+
/**
|
|
286
|
+
* Playground where you can freely live preview your components and pattern.
|
|
287
|
+
*/
|
|
288
|
+
declare const UniformPlayground: ({ resolveRenderer, decorators, contextualEditingEnhancer, behaviorTracking, contextualEditingDefaultPlaceholder, children, }: UniformPlaygroundProps) => React$1.JSX.Element;
|
|
289
|
+
|
|
271
290
|
type RichTextComponentProps<TNode extends RichTextNode = RichTextNode> = {
|
|
272
291
|
node: TNode;
|
|
273
292
|
};
|
|
@@ -404,4 +423,4 @@ declare const createComponentStoreResolver: (options: {
|
|
|
404
423
|
defaultComponent?: React$1.ComponentType<ComponentProps<any>>;
|
|
405
424
|
}) => RenderComponentResolver;
|
|
406
425
|
|
|
407
|
-
export { ComponentProps, ComponentStore, CustomSlotChildRenderFunc, DefaultNotImplementedComponent, NOT_IMPLEMENTED_COMPONENT, RenderComponentResolver, RenderRichTextComponentResolver, RichTextComponentProps, RichTextRendererComponent, SystemRenderConfig, SystemRenderFunction, UniformComponent, UniformComponentContextValue, UniformComponentProps, UniformComposition, UniformCompositionProps, UniformRichText, UniformRichTextNode, UniformRichTextNodeProps, UniformRichTextProps, UniformSlot, UniformSlotProps, UniformSlotWrapperComponentProps, UniformText, UniformTextProps, UseCompositionEventEffectOptions, UseUniformContextualEditingProps, UseUniformContextualEditingStateProps, componentStore, componentStoreResolver, createComponentStore, createComponentStoreResolver, getParameterAttributes, registerUniformComponent, useCompositionEventEffect, useUniformContextualEditing, useUniformContextualEditingState, useUniformCurrentComponent, useUniformCurrentComposition };
|
|
426
|
+
export { ComponentProps, ComponentStore, CustomSlotChildRenderFunc, DefaultNotImplementedComponent, NOT_IMPLEMENTED_COMPONENT, RenderComponentResolver, RenderRichTextComponentResolver, RichTextComponentProps, RichTextRendererComponent, SystemRenderConfig, SystemRenderFunction, UniformComponent, UniformComponentContextValue, UniformComponentProps, UniformComposition, UniformCompositionContext, UniformCompositionProps, UniformPlayground, UniformPlaygroundDecorator, UniformPlaygroundProps, UniformRichText, UniformRichTextNode, UniformRichTextNodeProps, UniformRichTextProps, UniformSlot, UniformSlotProps, UniformSlotWrapperComponentProps, UniformText, UniformTextProps, UseCompositionEventEffectOptions, UseUniformContextualEditingProps, UseUniformContextualEditingStateProps, componentStore, componentStoreResolver, createComponentStore, createComponentStoreResolver, getParameterAttributes, registerUniformComponent, useCompositionEventEffect, useUniformContextualEditing, useUniformContextualEditingState, useUniformCurrentComponent, useUniformCurrentComposition };
|
package/dist/index.d.ts
CHANGED
|
@@ -257,6 +257,7 @@ type UniformCompositionContextValue = {
|
|
|
257
257
|
behaviorTracking?: UniformCompositionProps['behaviorTracking'];
|
|
258
258
|
isContextualEditing: boolean;
|
|
259
259
|
};
|
|
260
|
+
declare const UniformCompositionContext: React$1.Context<UniformCompositionContextValue>;
|
|
260
261
|
/**
|
|
261
262
|
* Gets the data of the closest `<UniformComposition />` ancestor.
|
|
262
263
|
*/
|
|
@@ -268,6 +269,24 @@ declare function useUniformCurrentComposition(): UniformCompositionContextValue;
|
|
|
268
269
|
*/
|
|
269
270
|
declare function UniformComposition<TRenderProps = unknown>({ data, behaviorTracking, children, resolveRenderer, contextualEditingEnhancer, contextualEditingDefaultPlaceholder, }: UniformCompositionProps<TRenderProps>): React$1.JSX.Element;
|
|
270
271
|
|
|
272
|
+
type UniformPlaygroundDecorator = (options: {
|
|
273
|
+
children: React$1.ReactNode;
|
|
274
|
+
data: ComponentInstance | RootComponentInstance;
|
|
275
|
+
}) => React$1.ReactElement;
|
|
276
|
+
type UniformPlaygroundProps = {
|
|
277
|
+
/**
|
|
278
|
+
* Allows wrapping the playground in custom components.
|
|
279
|
+
* Useful to customize the playground to allow previewing the components in realistic scenarios
|
|
280
|
+
* (e.g. different background color, different parent size)
|
|
281
|
+
* @deprecated This feature is not stable yet and might be changed or removed in a minor release. Do not use it in production environments.
|
|
282
|
+
*/
|
|
283
|
+
decorators?: UniformPlaygroundDecorator[];
|
|
284
|
+
} & Omit<UniformCompositionProps, 'data'>;
|
|
285
|
+
/**
|
|
286
|
+
* Playground where you can freely live preview your components and pattern.
|
|
287
|
+
*/
|
|
288
|
+
declare const UniformPlayground: ({ resolveRenderer, decorators, contextualEditingEnhancer, behaviorTracking, contextualEditingDefaultPlaceholder, children, }: UniformPlaygroundProps) => React$1.JSX.Element;
|
|
289
|
+
|
|
271
290
|
type RichTextComponentProps<TNode extends RichTextNode = RichTextNode> = {
|
|
272
291
|
node: TNode;
|
|
273
292
|
};
|
|
@@ -404,4 +423,4 @@ declare const createComponentStoreResolver: (options: {
|
|
|
404
423
|
defaultComponent?: React$1.ComponentType<ComponentProps<any>>;
|
|
405
424
|
}) => RenderComponentResolver;
|
|
406
425
|
|
|
407
|
-
export { ComponentProps, ComponentStore, CustomSlotChildRenderFunc, DefaultNotImplementedComponent, NOT_IMPLEMENTED_COMPONENT, RenderComponentResolver, RenderRichTextComponentResolver, RichTextComponentProps, RichTextRendererComponent, SystemRenderConfig, SystemRenderFunction, UniformComponent, UniformComponentContextValue, UniformComponentProps, UniformComposition, UniformCompositionProps, UniformRichText, UniformRichTextNode, UniformRichTextNodeProps, UniformRichTextProps, UniformSlot, UniformSlotProps, UniformSlotWrapperComponentProps, UniformText, UniformTextProps, UseCompositionEventEffectOptions, UseUniformContextualEditingProps, UseUniformContextualEditingStateProps, componentStore, componentStoreResolver, createComponentStore, createComponentStoreResolver, getParameterAttributes, registerUniformComponent, useCompositionEventEffect, useUniformContextualEditing, useUniformContextualEditingState, useUniformCurrentComponent, useUniformCurrentComposition };
|
|
426
|
+
export { ComponentProps, ComponentStore, CustomSlotChildRenderFunc, DefaultNotImplementedComponent, NOT_IMPLEMENTED_COMPONENT, RenderComponentResolver, RenderRichTextComponentResolver, RichTextComponentProps, RichTextRendererComponent, SystemRenderConfig, SystemRenderFunction, UniformComponent, UniformComponentContextValue, UniformComponentProps, UniformComposition, UniformCompositionContext, UniformCompositionProps, UniformPlayground, UniformPlaygroundDecorator, UniformPlaygroundProps, UniformRichText, UniformRichTextNode, UniformRichTextNodeProps, UniformRichTextProps, UniformSlot, UniformSlotProps, UniformSlotWrapperComponentProps, UniformText, UniformTextProps, UseCompositionEventEffectOptions, UseUniformContextualEditingProps, UseUniformContextualEditingStateProps, componentStore, componentStoreResolver, createComponentStore, createComponentStoreResolver, getParameterAttributes, registerUniformComponent, useCompositionEventEffect, useUniformContextualEditing, useUniformContextualEditingState, useUniformCurrentComponent, useUniformCurrentComposition };
|
package/dist/index.esm.js
CHANGED
|
@@ -558,60 +558,110 @@ function resolveChildren({
|
|
|
558
558
|
return renderChildren;
|
|
559
559
|
}
|
|
560
560
|
|
|
561
|
+
// src/components/UniformPlayground.tsx
|
|
562
|
+
import { EMPTY_COMPOSITION as EMPTY_COMPOSITION3 } from "@uniformdev/canvas";
|
|
563
|
+
import React7, { useMemo as useMemo2 } from "react";
|
|
564
|
+
var UniformPlayground = ({
|
|
565
|
+
resolveRenderer,
|
|
566
|
+
decorators = [],
|
|
567
|
+
contextualEditingEnhancer,
|
|
568
|
+
behaviorTracking,
|
|
569
|
+
contextualEditingDefaultPlaceholder,
|
|
570
|
+
children
|
|
571
|
+
}) => {
|
|
572
|
+
const { composition, isContextualEditing } = useUniformContextualEditing({
|
|
573
|
+
initialCompositionValue: EMPTY_COMPOSITION3,
|
|
574
|
+
enhance: contextualEditingEnhancer
|
|
575
|
+
});
|
|
576
|
+
const renderedComponent = useMemo2(() => {
|
|
577
|
+
if (!composition) {
|
|
578
|
+
return null;
|
|
579
|
+
}
|
|
580
|
+
let component = /* @__PURE__ */ React7.createElement(
|
|
581
|
+
UniformComponent,
|
|
582
|
+
{
|
|
583
|
+
data: composition,
|
|
584
|
+
behaviorTracking,
|
|
585
|
+
resolveRenderer,
|
|
586
|
+
contextualEditingDefaultPlaceholder
|
|
587
|
+
},
|
|
588
|
+
children
|
|
589
|
+
);
|
|
590
|
+
decorators.forEach((Decorator) => {
|
|
591
|
+
component = /* @__PURE__ */ React7.createElement(Decorator, { data: composition }, component);
|
|
592
|
+
});
|
|
593
|
+
return component;
|
|
594
|
+
}, [
|
|
595
|
+
children,
|
|
596
|
+
resolveRenderer,
|
|
597
|
+
decorators,
|
|
598
|
+
composition,
|
|
599
|
+
behaviorTracking,
|
|
600
|
+
contextualEditingDefaultPlaceholder
|
|
601
|
+
]);
|
|
602
|
+
return /* @__PURE__ */ React7.createElement(
|
|
603
|
+
UniformCompositionContext.Provider,
|
|
604
|
+
{
|
|
605
|
+
value: { data: composition, behaviorTracking, resolveRenderer, isContextualEditing }
|
|
606
|
+
},
|
|
607
|
+
/* @__PURE__ */ React7.createElement(ContextualEditingComponentWrapper, { component: composition }, renderedComponent)
|
|
608
|
+
);
|
|
609
|
+
};
|
|
610
|
+
|
|
561
611
|
// src/components/UniformRichText/UniformRichText.tsx
|
|
562
612
|
import {
|
|
563
613
|
isRichTextValue,
|
|
564
614
|
isRichTextValueConsideredEmpty
|
|
565
615
|
} from "@uniformdev/richtext";
|
|
566
|
-
import
|
|
616
|
+
import React17, { useMemo as useMemo3 } from "react";
|
|
567
617
|
|
|
568
618
|
// src/components/UniformRichText/UniformRichTextNode.tsx
|
|
569
619
|
import { isRichTextNode } from "@uniformdev/richtext";
|
|
570
|
-
import
|
|
620
|
+
import React16 from "react";
|
|
571
621
|
|
|
572
622
|
// src/components/UniformRichText/nodes/HeadingRichTextNode.tsx
|
|
573
|
-
import
|
|
623
|
+
import React8 from "react";
|
|
574
624
|
var HeadingRichTextNode = ({ children, node }) => {
|
|
575
625
|
const { tag } = node;
|
|
576
626
|
const HTag = tag != null ? tag : "h1";
|
|
577
|
-
return /* @__PURE__ */
|
|
627
|
+
return /* @__PURE__ */ React8.createElement(HTag, null, children);
|
|
578
628
|
};
|
|
579
629
|
|
|
580
630
|
// src/components/UniformRichText/nodes/LinebreakRichTextNode.tsx
|
|
581
|
-
import
|
|
631
|
+
import React9 from "react";
|
|
582
632
|
var LinebreakRichTextNode = () => {
|
|
583
|
-
return /* @__PURE__ */
|
|
633
|
+
return /* @__PURE__ */ React9.createElement("br", null);
|
|
584
634
|
};
|
|
585
635
|
|
|
586
636
|
// src/components/UniformRichText/nodes/LinkRichTextNode.tsx
|
|
587
637
|
import { linkParamValueToHref } from "@uniformdev/richtext";
|
|
588
|
-
import
|
|
638
|
+
import React10 from "react";
|
|
589
639
|
var LinkRichTextNode = ({ children, node }) => {
|
|
590
640
|
const { link } = node;
|
|
591
|
-
return /* @__PURE__ */
|
|
641
|
+
return /* @__PURE__ */ React10.createElement("a", { href: linkParamValueToHref(link) }, children);
|
|
592
642
|
};
|
|
593
643
|
|
|
594
644
|
// src/components/UniformRichText/nodes/ListItemRichTextNode.tsx
|
|
595
|
-
import
|
|
645
|
+
import React11 from "react";
|
|
596
646
|
var ListItemRichTextNode = ({ children, node }) => {
|
|
597
647
|
const { value } = node;
|
|
598
|
-
return /* @__PURE__ */
|
|
648
|
+
return /* @__PURE__ */ React11.createElement("li", { value: Number.isFinite(value) && value > 0 ? value : void 0 }, children);
|
|
599
649
|
};
|
|
600
650
|
|
|
601
651
|
// src/components/UniformRichText/nodes/ListRichTextNode.tsx
|
|
602
|
-
import
|
|
652
|
+
import React12 from "react";
|
|
603
653
|
var ListRichTextNode = ({ children, node }) => {
|
|
604
654
|
const { tag, start } = node;
|
|
605
655
|
const ListTag = tag != null ? tag : "ul";
|
|
606
|
-
return /* @__PURE__ */
|
|
656
|
+
return /* @__PURE__ */ React12.createElement(ListTag, { start: Number.isFinite(start) && start > 0 ? start : void 0 }, children);
|
|
607
657
|
};
|
|
608
658
|
|
|
609
659
|
// src/components/UniformRichText/nodes/ParagraphRichTextNode.tsx
|
|
610
660
|
import { isPureDirection, isPureTextAlign } from "@uniformdev/richtext";
|
|
611
|
-
import
|
|
661
|
+
import React13 from "react";
|
|
612
662
|
var ParagraphRichTextNode = ({ children, node }) => {
|
|
613
663
|
const { format, direction } = node;
|
|
614
|
-
return /* @__PURE__ */
|
|
664
|
+
return /* @__PURE__ */ React13.createElement(
|
|
615
665
|
"p",
|
|
616
666
|
{
|
|
617
667
|
dir: isPureDirection(direction) ? direction : void 0,
|
|
@@ -622,18 +672,18 @@ var ParagraphRichTextNode = ({ children, node }) => {
|
|
|
622
672
|
};
|
|
623
673
|
|
|
624
674
|
// src/components/UniformRichText/nodes/TabRichTextNode.tsx
|
|
625
|
-
import
|
|
675
|
+
import React14 from "react";
|
|
626
676
|
var TabRichTextNode = () => {
|
|
627
|
-
return /* @__PURE__ */
|
|
677
|
+
return /* @__PURE__ */ React14.createElement(React14.Fragment, null, " ");
|
|
628
678
|
};
|
|
629
679
|
|
|
630
680
|
// src/components/UniformRichText/nodes/TextRichTextNode.tsx
|
|
631
681
|
import { getRichTextTagsFromTextFormat } from "@uniformdev/richtext";
|
|
632
|
-
import
|
|
682
|
+
import React15 from "react";
|
|
633
683
|
var TextRichTextNode = ({ node }) => {
|
|
634
684
|
const { text, format } = node;
|
|
635
685
|
const tags = getRichTextTagsFromTextFormat(format);
|
|
636
|
-
return /* @__PURE__ */
|
|
686
|
+
return /* @__PURE__ */ React15.createElement(React15.Fragment, null, tags.length > 0 ? tags.reduceRight((children, Tag) => /* @__PURE__ */ React15.createElement(Tag, null, children), text) : text);
|
|
637
687
|
};
|
|
638
688
|
|
|
639
689
|
// src/components/UniformRichText/UniformRichTextNode.tsx
|
|
@@ -648,8 +698,8 @@ function UniformRichTextNode({ node, ...props }) {
|
|
|
648
698
|
if (!NodeRenderer) {
|
|
649
699
|
return null;
|
|
650
700
|
}
|
|
651
|
-
const children = node.children ? node.children.map((childNode, i) => /* @__PURE__ */
|
|
652
|
-
return /* @__PURE__ */
|
|
701
|
+
const children = node.children ? node.children.map((childNode, i) => /* @__PURE__ */ React16.createElement(UniformRichTextNode, { ...props, key: i, node: childNode })) : null;
|
|
702
|
+
return /* @__PURE__ */ React16.createElement(NodeRenderer, { node }, children);
|
|
653
703
|
}
|
|
654
704
|
var rendererMap = /* @__PURE__ */ new Map([
|
|
655
705
|
["heading", HeadingRichTextNode],
|
|
@@ -658,12 +708,12 @@ var rendererMap = /* @__PURE__ */ new Map([
|
|
|
658
708
|
["list", ListRichTextNode],
|
|
659
709
|
["listitem", ListItemRichTextNode],
|
|
660
710
|
["paragraph", ParagraphRichTextNode],
|
|
661
|
-
["quote", ({ children }) => /* @__PURE__ */
|
|
711
|
+
["quote", ({ children }) => /* @__PURE__ */ React16.createElement("blockquote", null, children)],
|
|
662
712
|
[
|
|
663
713
|
"code",
|
|
664
|
-
({ children }) => /* @__PURE__ */
|
|
714
|
+
({ children }) => /* @__PURE__ */ React16.createElement("pre", null, /* @__PURE__ */ React16.createElement("code", null, children))
|
|
665
715
|
],
|
|
666
|
-
["root", ({ children }) => /* @__PURE__ */
|
|
716
|
+
["root", ({ children }) => /* @__PURE__ */ React16.createElement(React16.Fragment, null, children)],
|
|
667
717
|
["text", TextRichTextNode],
|
|
668
718
|
["tab", TabRichTextNode]
|
|
669
719
|
]);
|
|
@@ -672,20 +722,20 @@ var resolveRichTextDefaultRenderer = (node) => {
|
|
|
672
722
|
};
|
|
673
723
|
|
|
674
724
|
// src/components/UniformRichText/UniformRichText.tsx
|
|
675
|
-
var UniformRichText =
|
|
725
|
+
var UniformRichText = React17.forwardRef(function UniformRichText2({ parameterId, resolveRichTextRenderer, as: Tag = "div", ...props }, ref) {
|
|
676
726
|
const { data: componentData } = useUniformCurrentComponent();
|
|
677
|
-
const parameter =
|
|
727
|
+
const parameter = useMemo3(() => {
|
|
678
728
|
var _a;
|
|
679
729
|
return (_a = componentData == null ? void 0 : componentData.parameters) == null ? void 0 : _a[parameterId];
|
|
680
730
|
}, [componentData, parameterId]);
|
|
681
|
-
const value =
|
|
731
|
+
const value = useMemo3(() => parameter == null ? void 0 : parameter.value, [parameter]);
|
|
682
732
|
if (!value || !isRichTextValue(value) || isRichTextValueConsideredEmpty(value))
|
|
683
733
|
return null;
|
|
684
|
-
return Tag === null ? /* @__PURE__ */
|
|
734
|
+
return Tag === null ? /* @__PURE__ */ React17.createElement(UniformRichTextNode, { node: value.root, resolveRichTextRenderer }) : /* @__PURE__ */ React17.createElement(Tag, { ref, ...props }, /* @__PURE__ */ React17.createElement(UniformRichTextNode, { node: value.root, resolveRichTextRenderer }));
|
|
685
735
|
});
|
|
686
736
|
|
|
687
737
|
// src/components/UniformText.tsx
|
|
688
|
-
import
|
|
738
|
+
import React18, { useCallback, useMemo as useMemo4, useState as useState2 } from "react";
|
|
689
739
|
var UniformText = ({
|
|
690
740
|
as: Tag = "span",
|
|
691
741
|
parameterId,
|
|
@@ -698,7 +748,7 @@ var UniformText = ({
|
|
|
698
748
|
const { data: componentData, contextualEditingDefaultPlaceholder } = useUniformCurrentComponent();
|
|
699
749
|
const { isContextualEditing } = useUniformCurrentComposition();
|
|
700
750
|
const [isFocused, setIsFocused] = useState2(false);
|
|
701
|
-
const parameter =
|
|
751
|
+
const parameter = useMemo4(() => {
|
|
702
752
|
var _a2;
|
|
703
753
|
return (_a2 = componentData == null ? void 0 : componentData.parameters) == null ? void 0 : _a2[parameterId];
|
|
704
754
|
}, [componentData, parameterId]);
|
|
@@ -715,11 +765,11 @@ var UniformText = ({
|
|
|
715
765
|
return null;
|
|
716
766
|
}
|
|
717
767
|
if (!isContextualEditing) {
|
|
718
|
-
return /* @__PURE__ */
|
|
768
|
+
return /* @__PURE__ */ React18.createElement(Tag, { style: isMultiline ? { whiteSpace: "pre-wrap" } : {}, ...props }, render(value));
|
|
719
769
|
}
|
|
720
770
|
const placeholderProp = placeholder != null ? placeholder : contextualEditingDefaultPlaceholder;
|
|
721
771
|
const computedPlaceholder = typeof placeholderProp === "function" ? placeholderProp({ id: parameterId }) : placeholderProp;
|
|
722
|
-
return /* @__PURE__ */
|
|
772
|
+
return /* @__PURE__ */ React18.createElement(
|
|
723
773
|
Tag,
|
|
724
774
|
{
|
|
725
775
|
...props,
|
|
@@ -794,14 +844,14 @@ import {
|
|
|
794
844
|
createCanvasChannel as createCanvasChannel2,
|
|
795
845
|
isUpdateContextualEditingStateInternalMessage
|
|
796
846
|
} from "@uniformdev/canvas";
|
|
797
|
-
import { useEffect as useEffect3, useMemo as
|
|
847
|
+
import { useEffect as useEffect3, useMemo as useMemo5, useState as useState3 } from "react";
|
|
798
848
|
var useUniformContextualEditingState = ({
|
|
799
849
|
global = false
|
|
800
850
|
} = {}) => {
|
|
801
851
|
const { isContextualEditing } = useUniformCurrentComposition();
|
|
802
852
|
const { data: componentData } = useUniformCurrentComponent();
|
|
803
853
|
const [selectedComponentReference, setSelectedComponentReference] = useState3();
|
|
804
|
-
const channel =
|
|
854
|
+
const channel = useMemo5(() => {
|
|
805
855
|
if (!isContextualEditing) {
|
|
806
856
|
return;
|
|
807
857
|
}
|
|
@@ -840,6 +890,8 @@ export {
|
|
|
840
890
|
NOT_IMPLEMENTED_COMPONENT,
|
|
841
891
|
UniformComponent,
|
|
842
892
|
UniformComposition,
|
|
893
|
+
UniformCompositionContext,
|
|
894
|
+
UniformPlayground,
|
|
843
895
|
UniformRichText,
|
|
844
896
|
UniformRichTextNode,
|
|
845
897
|
UniformSlot,
|
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,
|
|
@@ -590,57 +592,107 @@ function resolveChildren({
|
|
|
590
592
|
return renderChildren;
|
|
591
593
|
}
|
|
592
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
|
+
|
|
593
645
|
// src/components/UniformRichText/UniformRichText.tsx
|
|
594
646
|
var import_richtext5 = require("@uniformdev/richtext");
|
|
595
|
-
var
|
|
647
|
+
var import_react17 = __toESM(require("react"));
|
|
596
648
|
|
|
597
649
|
// src/components/UniformRichText/UniformRichTextNode.tsx
|
|
598
650
|
var import_richtext4 = require("@uniformdev/richtext");
|
|
599
|
-
var
|
|
651
|
+
var import_react16 = __toESM(require("react"));
|
|
600
652
|
|
|
601
653
|
// src/components/UniformRichText/nodes/HeadingRichTextNode.tsx
|
|
602
|
-
var
|
|
654
|
+
var import_react8 = __toESM(require("react"));
|
|
603
655
|
var HeadingRichTextNode = ({ children, node }) => {
|
|
604
656
|
const { tag } = node;
|
|
605
657
|
const HTag = tag != null ? tag : "h1";
|
|
606
|
-
return /* @__PURE__ */
|
|
658
|
+
return /* @__PURE__ */ import_react8.default.createElement(HTag, null, children);
|
|
607
659
|
};
|
|
608
660
|
|
|
609
661
|
// src/components/UniformRichText/nodes/LinebreakRichTextNode.tsx
|
|
610
|
-
var
|
|
662
|
+
var import_react9 = __toESM(require("react"));
|
|
611
663
|
var LinebreakRichTextNode = () => {
|
|
612
|
-
return /* @__PURE__ */
|
|
664
|
+
return /* @__PURE__ */ import_react9.default.createElement("br", null);
|
|
613
665
|
};
|
|
614
666
|
|
|
615
667
|
// src/components/UniformRichText/nodes/LinkRichTextNode.tsx
|
|
616
668
|
var import_richtext = require("@uniformdev/richtext");
|
|
617
|
-
var
|
|
669
|
+
var import_react10 = __toESM(require("react"));
|
|
618
670
|
var LinkRichTextNode = ({ children, node }) => {
|
|
619
671
|
const { link } = node;
|
|
620
|
-
return /* @__PURE__ */
|
|
672
|
+
return /* @__PURE__ */ import_react10.default.createElement("a", { href: (0, import_richtext.linkParamValueToHref)(link) }, children);
|
|
621
673
|
};
|
|
622
674
|
|
|
623
675
|
// src/components/UniformRichText/nodes/ListItemRichTextNode.tsx
|
|
624
|
-
var
|
|
676
|
+
var import_react11 = __toESM(require("react"));
|
|
625
677
|
var ListItemRichTextNode = ({ children, node }) => {
|
|
626
678
|
const { value } = node;
|
|
627
|
-
return /* @__PURE__ */
|
|
679
|
+
return /* @__PURE__ */ import_react11.default.createElement("li", { value: Number.isFinite(value) && value > 0 ? value : void 0 }, children);
|
|
628
680
|
};
|
|
629
681
|
|
|
630
682
|
// src/components/UniformRichText/nodes/ListRichTextNode.tsx
|
|
631
|
-
var
|
|
683
|
+
var import_react12 = __toESM(require("react"));
|
|
632
684
|
var ListRichTextNode = ({ children, node }) => {
|
|
633
685
|
const { tag, start } = node;
|
|
634
686
|
const ListTag = tag != null ? tag : "ul";
|
|
635
|
-
return /* @__PURE__ */
|
|
687
|
+
return /* @__PURE__ */ import_react12.default.createElement(ListTag, { start: Number.isFinite(start) && start > 0 ? start : void 0 }, children);
|
|
636
688
|
};
|
|
637
689
|
|
|
638
690
|
// src/components/UniformRichText/nodes/ParagraphRichTextNode.tsx
|
|
639
691
|
var import_richtext2 = require("@uniformdev/richtext");
|
|
640
|
-
var
|
|
692
|
+
var import_react13 = __toESM(require("react"));
|
|
641
693
|
var ParagraphRichTextNode = ({ children, node }) => {
|
|
642
694
|
const { format, direction } = node;
|
|
643
|
-
return /* @__PURE__ */
|
|
695
|
+
return /* @__PURE__ */ import_react13.default.createElement(
|
|
644
696
|
"p",
|
|
645
697
|
{
|
|
646
698
|
dir: (0, import_richtext2.isPureDirection)(direction) ? direction : void 0,
|
|
@@ -651,18 +703,18 @@ var ParagraphRichTextNode = ({ children, node }) => {
|
|
|
651
703
|
};
|
|
652
704
|
|
|
653
705
|
// src/components/UniformRichText/nodes/TabRichTextNode.tsx
|
|
654
|
-
var
|
|
706
|
+
var import_react14 = __toESM(require("react"));
|
|
655
707
|
var TabRichTextNode = () => {
|
|
656
|
-
return /* @__PURE__ */
|
|
708
|
+
return /* @__PURE__ */ import_react14.default.createElement(import_react14.default.Fragment, null, " ");
|
|
657
709
|
};
|
|
658
710
|
|
|
659
711
|
// src/components/UniformRichText/nodes/TextRichTextNode.tsx
|
|
660
712
|
var import_richtext3 = require("@uniformdev/richtext");
|
|
661
|
-
var
|
|
713
|
+
var import_react15 = __toESM(require("react"));
|
|
662
714
|
var TextRichTextNode = ({ node }) => {
|
|
663
715
|
const { text, format } = node;
|
|
664
716
|
const tags = (0, import_richtext3.getRichTextTagsFromTextFormat)(format);
|
|
665
|
-
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);
|
|
666
718
|
};
|
|
667
719
|
|
|
668
720
|
// src/components/UniformRichText/UniformRichTextNode.tsx
|
|
@@ -677,8 +729,8 @@ function UniformRichTextNode({ node, ...props }) {
|
|
|
677
729
|
if (!NodeRenderer) {
|
|
678
730
|
return null;
|
|
679
731
|
}
|
|
680
|
-
const children = node.children ? node.children.map((childNode, i) => /* @__PURE__ */
|
|
681
|
-
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);
|
|
682
734
|
}
|
|
683
735
|
var rendererMap = /* @__PURE__ */ new Map([
|
|
684
736
|
["heading", HeadingRichTextNode],
|
|
@@ -687,12 +739,12 @@ var rendererMap = /* @__PURE__ */ new Map([
|
|
|
687
739
|
["list", ListRichTextNode],
|
|
688
740
|
["listitem", ListItemRichTextNode],
|
|
689
741
|
["paragraph", ParagraphRichTextNode],
|
|
690
|
-
["quote", ({ children }) => /* @__PURE__ */
|
|
742
|
+
["quote", ({ children }) => /* @__PURE__ */ import_react16.default.createElement("blockquote", null, children)],
|
|
691
743
|
[
|
|
692
744
|
"code",
|
|
693
|
-
({ children }) => /* @__PURE__ */
|
|
745
|
+
({ children }) => /* @__PURE__ */ import_react16.default.createElement("pre", null, /* @__PURE__ */ import_react16.default.createElement("code", null, children))
|
|
694
746
|
],
|
|
695
|
-
["root", ({ children }) => /* @__PURE__ */
|
|
747
|
+
["root", ({ children }) => /* @__PURE__ */ import_react16.default.createElement(import_react16.default.Fragment, null, children)],
|
|
696
748
|
["text", TextRichTextNode],
|
|
697
749
|
["tab", TabRichTextNode]
|
|
698
750
|
]);
|
|
@@ -701,20 +753,20 @@ var resolveRichTextDefaultRenderer = (node) => {
|
|
|
701
753
|
};
|
|
702
754
|
|
|
703
755
|
// src/components/UniformRichText/UniformRichText.tsx
|
|
704
|
-
var UniformRichText =
|
|
756
|
+
var UniformRichText = import_react17.default.forwardRef(function UniformRichText2({ parameterId, resolveRichTextRenderer, as: Tag = "div", ...props }, ref) {
|
|
705
757
|
const { data: componentData } = useUniformCurrentComponent();
|
|
706
|
-
const parameter = (0,
|
|
758
|
+
const parameter = (0, import_react17.useMemo)(() => {
|
|
707
759
|
var _a;
|
|
708
760
|
return (_a = componentData == null ? void 0 : componentData.parameters) == null ? void 0 : _a[parameterId];
|
|
709
761
|
}, [componentData, parameterId]);
|
|
710
|
-
const value = (0,
|
|
762
|
+
const value = (0, import_react17.useMemo)(() => parameter == null ? void 0 : parameter.value, [parameter]);
|
|
711
763
|
if (!value || !(0, import_richtext5.isRichTextValue)(value) || (0, import_richtext5.isRichTextValueConsideredEmpty)(value))
|
|
712
764
|
return null;
|
|
713
|
-
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 }));
|
|
714
766
|
});
|
|
715
767
|
|
|
716
768
|
// src/components/UniformText.tsx
|
|
717
|
-
var
|
|
769
|
+
var import_react18 = __toESM(require("react"));
|
|
718
770
|
var UniformText = ({
|
|
719
771
|
as: Tag = "span",
|
|
720
772
|
parameterId,
|
|
@@ -726,29 +778,29 @@ var UniformText = ({
|
|
|
726
778
|
var _a, _b;
|
|
727
779
|
const { data: componentData, contextualEditingDefaultPlaceholder } = useUniformCurrentComponent();
|
|
728
780
|
const { isContextualEditing } = useUniformCurrentComposition();
|
|
729
|
-
const [isFocused, setIsFocused] = (0,
|
|
730
|
-
const parameter = (0,
|
|
781
|
+
const [isFocused, setIsFocused] = (0, import_react18.useState)(false);
|
|
782
|
+
const parameter = (0, import_react18.useMemo)(() => {
|
|
731
783
|
var _a2;
|
|
732
784
|
return (_a2 = componentData == null ? void 0 : componentData.parameters) == null ? void 0 : _a2[parameterId];
|
|
733
785
|
}, [componentData, parameterId]);
|
|
734
786
|
const value = parameter == null ? void 0 : parameter.value;
|
|
735
787
|
const isEditable = (_b = (_a = parameter == null ? void 0 : parameter._contextualEditing) == null ? void 0 : _a.isEditable) != null ? _b : false;
|
|
736
788
|
const shouldSkipCustomRendering = isFocused && isEditable;
|
|
737
|
-
const handleOnFocus = (0,
|
|
789
|
+
const handleOnFocus = (0, import_react18.useCallback)(() => {
|
|
738
790
|
setIsFocused(true);
|
|
739
791
|
}, [setIsFocused]);
|
|
740
|
-
const handleOnBlur = (0,
|
|
792
|
+
const handleOnBlur = (0, import_react18.useCallback)(() => {
|
|
741
793
|
setIsFocused(false);
|
|
742
794
|
}, [setIsFocused]);
|
|
743
795
|
if (!parameter) {
|
|
744
796
|
return null;
|
|
745
797
|
}
|
|
746
798
|
if (!isContextualEditing) {
|
|
747
|
-
return /* @__PURE__ */
|
|
799
|
+
return /* @__PURE__ */ import_react18.default.createElement(Tag, { style: isMultiline ? { whiteSpace: "pre-wrap" } : {}, ...props }, render(value));
|
|
748
800
|
}
|
|
749
801
|
const placeholderProp = placeholder != null ? placeholder : contextualEditingDefaultPlaceholder;
|
|
750
802
|
const computedPlaceholder = typeof placeholderProp === "function" ? placeholderProp({ id: parameterId }) : placeholderProp;
|
|
751
|
-
return /* @__PURE__ */
|
|
803
|
+
return /* @__PURE__ */ import_react18.default.createElement(
|
|
752
804
|
Tag,
|
|
753
805
|
{
|
|
754
806
|
...props,
|
|
@@ -768,35 +820,35 @@ var UniformText = ({
|
|
|
768
820
|
};
|
|
769
821
|
|
|
770
822
|
// src/helpers/getParameterAttributes.ts
|
|
771
|
-
var
|
|
823
|
+
var import_canvas8 = require("@uniformdev/canvas");
|
|
772
824
|
var getParameterAttributes = (options) => {
|
|
773
825
|
return {
|
|
774
|
-
...(0,
|
|
826
|
+
...(0, import_canvas8.getParameterAttributes)(options),
|
|
775
827
|
suppressContentEditableWarning: true
|
|
776
828
|
};
|
|
777
829
|
};
|
|
778
830
|
|
|
779
831
|
// src/hooks/useCompositionEventEffect.ts
|
|
780
|
-
var
|
|
781
|
-
var
|
|
832
|
+
var import_canvas9 = require("@uniformdev/canvas");
|
|
833
|
+
var import_react19 = require("react");
|
|
782
834
|
function useCompositionEventEffect({
|
|
783
835
|
enabled,
|
|
784
836
|
projectId,
|
|
785
837
|
compositionId,
|
|
786
838
|
effect
|
|
787
839
|
}) {
|
|
788
|
-
(0,
|
|
840
|
+
(0, import_react19.useEffect)(() => {
|
|
789
841
|
if (!enabled || !compositionId || !projectId) {
|
|
790
842
|
return;
|
|
791
843
|
}
|
|
792
844
|
let goodbye = void 0;
|
|
793
845
|
const loadEffect = async () => {
|
|
794
|
-
const eventBus = await (0,
|
|
846
|
+
const eventBus = await (0, import_canvas9.createEventBus)();
|
|
795
847
|
if (eventBus) {
|
|
796
|
-
goodbye = (0,
|
|
848
|
+
goodbye = (0, import_canvas9.subscribeToComposition)({
|
|
797
849
|
eventBus,
|
|
798
850
|
compositionId,
|
|
799
|
-
compositionState:
|
|
851
|
+
compositionState: import_canvas9.CANVAS_DRAFT_STATE,
|
|
800
852
|
projectId,
|
|
801
853
|
callback: effect,
|
|
802
854
|
event: "updated"
|
|
@@ -813,31 +865,31 @@ function useCompositionEventEffect({
|
|
|
813
865
|
}
|
|
814
866
|
|
|
815
867
|
// src/hooks/useUniformContextualEditingState.ts
|
|
816
|
-
var
|
|
817
|
-
var
|
|
868
|
+
var import_canvas10 = require("@uniformdev/canvas");
|
|
869
|
+
var import_react20 = require("react");
|
|
818
870
|
var useUniformContextualEditingState = ({
|
|
819
871
|
global = false
|
|
820
872
|
} = {}) => {
|
|
821
873
|
const { isContextualEditing } = useUniformCurrentComposition();
|
|
822
874
|
const { data: componentData } = useUniformCurrentComponent();
|
|
823
|
-
const [selectedComponentReference, setSelectedComponentReference] = (0,
|
|
824
|
-
const channel = (0,
|
|
875
|
+
const [selectedComponentReference, setSelectedComponentReference] = (0, import_react20.useState)();
|
|
876
|
+
const channel = (0, import_react20.useMemo)(() => {
|
|
825
877
|
if (!isContextualEditing) {
|
|
826
878
|
return;
|
|
827
879
|
}
|
|
828
|
-
const channel2 = (0,
|
|
880
|
+
const channel2 = (0, import_canvas10.createCanvasChannel)({
|
|
829
881
|
broadcastTo: [window],
|
|
830
882
|
listenTo: [window]
|
|
831
883
|
});
|
|
832
884
|
return channel2;
|
|
833
885
|
}, [isContextualEditing]);
|
|
834
|
-
(0,
|
|
886
|
+
(0, import_react20.useEffect)(() => {
|
|
835
887
|
if (!channel) {
|
|
836
888
|
return;
|
|
837
889
|
}
|
|
838
890
|
const unsubscribe = channel.on("update-contextual-editing-state-internal", async (message) => {
|
|
839
891
|
var _a;
|
|
840
|
-
if (!(0,
|
|
892
|
+
if (!(0, import_canvas10.isUpdateContextualEditingStateInternalMessage)(message)) {
|
|
841
893
|
return;
|
|
842
894
|
}
|
|
843
895
|
if (!global && (componentData == null ? void 0 : componentData._id) !== ((_a = message.state.selectedComponentReference) == null ? void 0 : _a.parentId)) {
|
|
@@ -861,6 +913,8 @@ var useUniformContextualEditingState = ({
|
|
|
861
913
|
NOT_IMPLEMENTED_COMPONENT,
|
|
862
914
|
UniformComponent,
|
|
863
915
|
UniformComposition,
|
|
916
|
+
UniformCompositionContext,
|
|
917
|
+
UniformPlayground,
|
|
864
918
|
UniformRichText,
|
|
865
919
|
UniformRichTextNode,
|
|
866
920
|
UniformSlot,
|
package/dist/index.mjs
CHANGED
|
@@ -558,60 +558,110 @@ function resolveChildren({
|
|
|
558
558
|
return renderChildren;
|
|
559
559
|
}
|
|
560
560
|
|
|
561
|
+
// src/components/UniformPlayground.tsx
|
|
562
|
+
import { EMPTY_COMPOSITION as EMPTY_COMPOSITION3 } from "@uniformdev/canvas";
|
|
563
|
+
import React7, { useMemo as useMemo2 } from "react";
|
|
564
|
+
var UniformPlayground = ({
|
|
565
|
+
resolveRenderer,
|
|
566
|
+
decorators = [],
|
|
567
|
+
contextualEditingEnhancer,
|
|
568
|
+
behaviorTracking,
|
|
569
|
+
contextualEditingDefaultPlaceholder,
|
|
570
|
+
children
|
|
571
|
+
}) => {
|
|
572
|
+
const { composition, isContextualEditing } = useUniformContextualEditing({
|
|
573
|
+
initialCompositionValue: EMPTY_COMPOSITION3,
|
|
574
|
+
enhance: contextualEditingEnhancer
|
|
575
|
+
});
|
|
576
|
+
const renderedComponent = useMemo2(() => {
|
|
577
|
+
if (!composition) {
|
|
578
|
+
return null;
|
|
579
|
+
}
|
|
580
|
+
let component = /* @__PURE__ */ React7.createElement(
|
|
581
|
+
UniformComponent,
|
|
582
|
+
{
|
|
583
|
+
data: composition,
|
|
584
|
+
behaviorTracking,
|
|
585
|
+
resolveRenderer,
|
|
586
|
+
contextualEditingDefaultPlaceholder
|
|
587
|
+
},
|
|
588
|
+
children
|
|
589
|
+
);
|
|
590
|
+
decorators.forEach((Decorator) => {
|
|
591
|
+
component = /* @__PURE__ */ React7.createElement(Decorator, { data: composition }, component);
|
|
592
|
+
});
|
|
593
|
+
return component;
|
|
594
|
+
}, [
|
|
595
|
+
children,
|
|
596
|
+
resolveRenderer,
|
|
597
|
+
decorators,
|
|
598
|
+
composition,
|
|
599
|
+
behaviorTracking,
|
|
600
|
+
contextualEditingDefaultPlaceholder
|
|
601
|
+
]);
|
|
602
|
+
return /* @__PURE__ */ React7.createElement(
|
|
603
|
+
UniformCompositionContext.Provider,
|
|
604
|
+
{
|
|
605
|
+
value: { data: composition, behaviorTracking, resolveRenderer, isContextualEditing }
|
|
606
|
+
},
|
|
607
|
+
/* @__PURE__ */ React7.createElement(ContextualEditingComponentWrapper, { component: composition }, renderedComponent)
|
|
608
|
+
);
|
|
609
|
+
};
|
|
610
|
+
|
|
561
611
|
// src/components/UniformRichText/UniformRichText.tsx
|
|
562
612
|
import {
|
|
563
613
|
isRichTextValue,
|
|
564
614
|
isRichTextValueConsideredEmpty
|
|
565
615
|
} from "@uniformdev/richtext";
|
|
566
|
-
import
|
|
616
|
+
import React17, { useMemo as useMemo3 } from "react";
|
|
567
617
|
|
|
568
618
|
// src/components/UniformRichText/UniformRichTextNode.tsx
|
|
569
619
|
import { isRichTextNode } from "@uniformdev/richtext";
|
|
570
|
-
import
|
|
620
|
+
import React16 from "react";
|
|
571
621
|
|
|
572
622
|
// src/components/UniformRichText/nodes/HeadingRichTextNode.tsx
|
|
573
|
-
import
|
|
623
|
+
import React8 from "react";
|
|
574
624
|
var HeadingRichTextNode = ({ children, node }) => {
|
|
575
625
|
const { tag } = node;
|
|
576
626
|
const HTag = tag != null ? tag : "h1";
|
|
577
|
-
return /* @__PURE__ */
|
|
627
|
+
return /* @__PURE__ */ React8.createElement(HTag, null, children);
|
|
578
628
|
};
|
|
579
629
|
|
|
580
630
|
// src/components/UniformRichText/nodes/LinebreakRichTextNode.tsx
|
|
581
|
-
import
|
|
631
|
+
import React9 from "react";
|
|
582
632
|
var LinebreakRichTextNode = () => {
|
|
583
|
-
return /* @__PURE__ */
|
|
633
|
+
return /* @__PURE__ */ React9.createElement("br", null);
|
|
584
634
|
};
|
|
585
635
|
|
|
586
636
|
// src/components/UniformRichText/nodes/LinkRichTextNode.tsx
|
|
587
637
|
import { linkParamValueToHref } from "@uniformdev/richtext";
|
|
588
|
-
import
|
|
638
|
+
import React10 from "react";
|
|
589
639
|
var LinkRichTextNode = ({ children, node }) => {
|
|
590
640
|
const { link } = node;
|
|
591
|
-
return /* @__PURE__ */
|
|
641
|
+
return /* @__PURE__ */ React10.createElement("a", { href: linkParamValueToHref(link) }, children);
|
|
592
642
|
};
|
|
593
643
|
|
|
594
644
|
// src/components/UniformRichText/nodes/ListItemRichTextNode.tsx
|
|
595
|
-
import
|
|
645
|
+
import React11 from "react";
|
|
596
646
|
var ListItemRichTextNode = ({ children, node }) => {
|
|
597
647
|
const { value } = node;
|
|
598
|
-
return /* @__PURE__ */
|
|
648
|
+
return /* @__PURE__ */ React11.createElement("li", { value: Number.isFinite(value) && value > 0 ? value : void 0 }, children);
|
|
599
649
|
};
|
|
600
650
|
|
|
601
651
|
// src/components/UniformRichText/nodes/ListRichTextNode.tsx
|
|
602
|
-
import
|
|
652
|
+
import React12 from "react";
|
|
603
653
|
var ListRichTextNode = ({ children, node }) => {
|
|
604
654
|
const { tag, start } = node;
|
|
605
655
|
const ListTag = tag != null ? tag : "ul";
|
|
606
|
-
return /* @__PURE__ */
|
|
656
|
+
return /* @__PURE__ */ React12.createElement(ListTag, { start: Number.isFinite(start) && start > 0 ? start : void 0 }, children);
|
|
607
657
|
};
|
|
608
658
|
|
|
609
659
|
// src/components/UniformRichText/nodes/ParagraphRichTextNode.tsx
|
|
610
660
|
import { isPureDirection, isPureTextAlign } from "@uniformdev/richtext";
|
|
611
|
-
import
|
|
661
|
+
import React13 from "react";
|
|
612
662
|
var ParagraphRichTextNode = ({ children, node }) => {
|
|
613
663
|
const { format, direction } = node;
|
|
614
|
-
return /* @__PURE__ */
|
|
664
|
+
return /* @__PURE__ */ React13.createElement(
|
|
615
665
|
"p",
|
|
616
666
|
{
|
|
617
667
|
dir: isPureDirection(direction) ? direction : void 0,
|
|
@@ -622,18 +672,18 @@ var ParagraphRichTextNode = ({ children, node }) => {
|
|
|
622
672
|
};
|
|
623
673
|
|
|
624
674
|
// src/components/UniformRichText/nodes/TabRichTextNode.tsx
|
|
625
|
-
import
|
|
675
|
+
import React14 from "react";
|
|
626
676
|
var TabRichTextNode = () => {
|
|
627
|
-
return /* @__PURE__ */
|
|
677
|
+
return /* @__PURE__ */ React14.createElement(React14.Fragment, null, " ");
|
|
628
678
|
};
|
|
629
679
|
|
|
630
680
|
// src/components/UniformRichText/nodes/TextRichTextNode.tsx
|
|
631
681
|
import { getRichTextTagsFromTextFormat } from "@uniformdev/richtext";
|
|
632
|
-
import
|
|
682
|
+
import React15 from "react";
|
|
633
683
|
var TextRichTextNode = ({ node }) => {
|
|
634
684
|
const { text, format } = node;
|
|
635
685
|
const tags = getRichTextTagsFromTextFormat(format);
|
|
636
|
-
return /* @__PURE__ */
|
|
686
|
+
return /* @__PURE__ */ React15.createElement(React15.Fragment, null, tags.length > 0 ? tags.reduceRight((children, Tag) => /* @__PURE__ */ React15.createElement(Tag, null, children), text) : text);
|
|
637
687
|
};
|
|
638
688
|
|
|
639
689
|
// src/components/UniformRichText/UniformRichTextNode.tsx
|
|
@@ -648,8 +698,8 @@ function UniformRichTextNode({ node, ...props }) {
|
|
|
648
698
|
if (!NodeRenderer) {
|
|
649
699
|
return null;
|
|
650
700
|
}
|
|
651
|
-
const children = node.children ? node.children.map((childNode, i) => /* @__PURE__ */
|
|
652
|
-
return /* @__PURE__ */
|
|
701
|
+
const children = node.children ? node.children.map((childNode, i) => /* @__PURE__ */ React16.createElement(UniformRichTextNode, { ...props, key: i, node: childNode })) : null;
|
|
702
|
+
return /* @__PURE__ */ React16.createElement(NodeRenderer, { node }, children);
|
|
653
703
|
}
|
|
654
704
|
var rendererMap = /* @__PURE__ */ new Map([
|
|
655
705
|
["heading", HeadingRichTextNode],
|
|
@@ -658,12 +708,12 @@ var rendererMap = /* @__PURE__ */ new Map([
|
|
|
658
708
|
["list", ListRichTextNode],
|
|
659
709
|
["listitem", ListItemRichTextNode],
|
|
660
710
|
["paragraph", ParagraphRichTextNode],
|
|
661
|
-
["quote", ({ children }) => /* @__PURE__ */
|
|
711
|
+
["quote", ({ children }) => /* @__PURE__ */ React16.createElement("blockquote", null, children)],
|
|
662
712
|
[
|
|
663
713
|
"code",
|
|
664
|
-
({ children }) => /* @__PURE__ */
|
|
714
|
+
({ children }) => /* @__PURE__ */ React16.createElement("pre", null, /* @__PURE__ */ React16.createElement("code", null, children))
|
|
665
715
|
],
|
|
666
|
-
["root", ({ children }) => /* @__PURE__ */
|
|
716
|
+
["root", ({ children }) => /* @__PURE__ */ React16.createElement(React16.Fragment, null, children)],
|
|
667
717
|
["text", TextRichTextNode],
|
|
668
718
|
["tab", TabRichTextNode]
|
|
669
719
|
]);
|
|
@@ -672,20 +722,20 @@ var resolveRichTextDefaultRenderer = (node) => {
|
|
|
672
722
|
};
|
|
673
723
|
|
|
674
724
|
// src/components/UniformRichText/UniformRichText.tsx
|
|
675
|
-
var UniformRichText =
|
|
725
|
+
var UniformRichText = React17.forwardRef(function UniformRichText2({ parameterId, resolveRichTextRenderer, as: Tag = "div", ...props }, ref) {
|
|
676
726
|
const { data: componentData } = useUniformCurrentComponent();
|
|
677
|
-
const parameter =
|
|
727
|
+
const parameter = useMemo3(() => {
|
|
678
728
|
var _a;
|
|
679
729
|
return (_a = componentData == null ? void 0 : componentData.parameters) == null ? void 0 : _a[parameterId];
|
|
680
730
|
}, [componentData, parameterId]);
|
|
681
|
-
const value =
|
|
731
|
+
const value = useMemo3(() => parameter == null ? void 0 : parameter.value, [parameter]);
|
|
682
732
|
if (!value || !isRichTextValue(value) || isRichTextValueConsideredEmpty(value))
|
|
683
733
|
return null;
|
|
684
|
-
return Tag === null ? /* @__PURE__ */
|
|
734
|
+
return Tag === null ? /* @__PURE__ */ React17.createElement(UniformRichTextNode, { node: value.root, resolveRichTextRenderer }) : /* @__PURE__ */ React17.createElement(Tag, { ref, ...props }, /* @__PURE__ */ React17.createElement(UniformRichTextNode, { node: value.root, resolveRichTextRenderer }));
|
|
685
735
|
});
|
|
686
736
|
|
|
687
737
|
// src/components/UniformText.tsx
|
|
688
|
-
import
|
|
738
|
+
import React18, { useCallback, useMemo as useMemo4, useState as useState2 } from "react";
|
|
689
739
|
var UniformText = ({
|
|
690
740
|
as: Tag = "span",
|
|
691
741
|
parameterId,
|
|
@@ -698,7 +748,7 @@ var UniformText = ({
|
|
|
698
748
|
const { data: componentData, contextualEditingDefaultPlaceholder } = useUniformCurrentComponent();
|
|
699
749
|
const { isContextualEditing } = useUniformCurrentComposition();
|
|
700
750
|
const [isFocused, setIsFocused] = useState2(false);
|
|
701
|
-
const parameter =
|
|
751
|
+
const parameter = useMemo4(() => {
|
|
702
752
|
var _a2;
|
|
703
753
|
return (_a2 = componentData == null ? void 0 : componentData.parameters) == null ? void 0 : _a2[parameterId];
|
|
704
754
|
}, [componentData, parameterId]);
|
|
@@ -715,11 +765,11 @@ var UniformText = ({
|
|
|
715
765
|
return null;
|
|
716
766
|
}
|
|
717
767
|
if (!isContextualEditing) {
|
|
718
|
-
return /* @__PURE__ */
|
|
768
|
+
return /* @__PURE__ */ React18.createElement(Tag, { style: isMultiline ? { whiteSpace: "pre-wrap" } : {}, ...props }, render(value));
|
|
719
769
|
}
|
|
720
770
|
const placeholderProp = placeholder != null ? placeholder : contextualEditingDefaultPlaceholder;
|
|
721
771
|
const computedPlaceholder = typeof placeholderProp === "function" ? placeholderProp({ id: parameterId }) : placeholderProp;
|
|
722
|
-
return /* @__PURE__ */
|
|
772
|
+
return /* @__PURE__ */ React18.createElement(
|
|
723
773
|
Tag,
|
|
724
774
|
{
|
|
725
775
|
...props,
|
|
@@ -794,14 +844,14 @@ import {
|
|
|
794
844
|
createCanvasChannel as createCanvasChannel2,
|
|
795
845
|
isUpdateContextualEditingStateInternalMessage
|
|
796
846
|
} from "@uniformdev/canvas";
|
|
797
|
-
import { useEffect as useEffect3, useMemo as
|
|
847
|
+
import { useEffect as useEffect3, useMemo as useMemo5, useState as useState3 } from "react";
|
|
798
848
|
var useUniformContextualEditingState = ({
|
|
799
849
|
global = false
|
|
800
850
|
} = {}) => {
|
|
801
851
|
const { isContextualEditing } = useUniformCurrentComposition();
|
|
802
852
|
const { data: componentData } = useUniformCurrentComponent();
|
|
803
853
|
const [selectedComponentReference, setSelectedComponentReference] = useState3();
|
|
804
|
-
const channel =
|
|
854
|
+
const channel = useMemo5(() => {
|
|
805
855
|
if (!isContextualEditing) {
|
|
806
856
|
return;
|
|
807
857
|
}
|
|
@@ -840,6 +890,8 @@ export {
|
|
|
840
890
|
NOT_IMPLEMENTED_COMPONENT,
|
|
841
891
|
UniformComponent,
|
|
842
892
|
UniformComposition,
|
|
893
|
+
UniformCompositionContext,
|
|
894
|
+
UniformPlayground,
|
|
843
895
|
UniformRichText,
|
|
844
896
|
UniformRichTextNode,
|
|
845
897
|
UniformSlot,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@uniformdev/canvas-react",
|
|
3
|
-
"version": "19.48.
|
|
3
|
+
"version": "19.48.1-alpha.8+0418d546a",
|
|
4
4
|
"description": "React SDK for Uniform Canvas",
|
|
5
5
|
"license": "SEE LICENSE IN LICENSE.txt",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -25,10 +25,10 @@
|
|
|
25
25
|
"document": "api-extractor run --local"
|
|
26
26
|
},
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"@uniformdev/canvas": "19.48.
|
|
29
|
-
"@uniformdev/context": "19.48.
|
|
30
|
-
"@uniformdev/context-react": "19.48.
|
|
31
|
-
"@uniformdev/richtext": "19.48.
|
|
28
|
+
"@uniformdev/canvas": "19.48.1-alpha.8+0418d546a",
|
|
29
|
+
"@uniformdev/context": "19.48.1-alpha.8+0418d546a",
|
|
30
|
+
"@uniformdev/context-react": "19.48.1-alpha.8+0418d546a",
|
|
31
|
+
"@uniformdev/richtext": "19.48.1-alpha.8+0418d546a"
|
|
32
32
|
},
|
|
33
33
|
"peerDependencies": {
|
|
34
34
|
"react": ">= 16 || 17 || 18",
|
|
@@ -45,5 +45,5 @@
|
|
|
45
45
|
"publishConfig": {
|
|
46
46
|
"access": "public"
|
|
47
47
|
},
|
|
48
|
-
"gitHead": "
|
|
48
|
+
"gitHead": "0418d546ad78898515544d07f095ff03809c611c"
|
|
49
49
|
}
|