@uniformdev/canvas-react 19.173.1-alpha.17 → 19.173.2-alpha.258

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.mjs CHANGED
@@ -695,59 +695,70 @@ import {
695
695
  ATTRIBUTE_PARAMETER_ID,
696
696
  ATTRIBUTE_PARAMETER_TYPE
697
697
  } from "@uniformdev/canvas";
698
- import {
699
- isRichTextValue,
700
- isRichTextValueConsideredEmpty
701
- } from "@uniformdev/richtext";
702
- import React18, { useMemo as useMemo5 } from "react";
698
+ import { isRichTextValue, isRichTextValueConsideredEmpty } from "@uniformdev/richtext";
699
+ import React20 from "react";
703
700
 
704
701
  // src/components/UniformRichText/UniformRichTextNode.tsx
705
702
  import { isRichTextNode } from "@uniformdev/richtext";
706
- import React17 from "react";
703
+ import React19 from "react";
707
704
 
708
- // src/components/UniformRichText/nodes/HeadingRichTextNode.tsx
705
+ // src/components/UniformRichText/nodes/AssetRichTextNode.tsx
709
706
  import React9 from "react";
707
+ var AssetRichTextNode = ({ node }) => {
708
+ var _a, _b;
709
+ const { __asset } = node;
710
+ if (__asset === void 0) {
711
+ return null;
712
+ }
713
+ if (__asset.type !== "image") {
714
+ return null;
715
+ }
716
+ return /* @__PURE__ */ React9.createElement("figure", null, /* @__PURE__ */ React9.createElement("img", { src: __asset.fields.url.value, alt: (_a = __asset.fields.title) == null ? void 0 : _a.value }), ((_b = __asset.fields.description) == null ? void 0 : _b.value) ? /* @__PURE__ */ React9.createElement("figcaption", null, __asset.fields.description.value) : null);
717
+ };
718
+
719
+ // src/components/UniformRichText/nodes/HeadingRichTextNode.tsx
720
+ import React10 from "react";
710
721
  var HeadingRichTextNode = ({ children, node }) => {
711
722
  const { tag } = node;
712
723
  const HTag = tag != null ? tag : "h1";
713
- return /* @__PURE__ */ React9.createElement(HTag, null, children);
724
+ return /* @__PURE__ */ React10.createElement(HTag, null, children);
714
725
  };
715
726
 
716
727
  // src/components/UniformRichText/nodes/LinebreakRichTextNode.tsx
717
- import React10 from "react";
728
+ import React11 from "react";
718
729
  var LinebreakRichTextNode = () => {
719
- return /* @__PURE__ */ React10.createElement("br", null);
730
+ return /* @__PURE__ */ React11.createElement("br", null);
720
731
  };
721
732
 
722
733
  // src/components/UniformRichText/nodes/LinkRichTextNode.tsx
723
734
  import { linkParamValueToHref } from "@uniformdev/richtext";
724
- import React11 from "react";
735
+ import React12 from "react";
725
736
  var LinkRichTextNode = ({ children, node }) => {
726
737
  const { link } = node;
727
- return /* @__PURE__ */ React11.createElement("a", { href: linkParamValueToHref(link) }, children);
738
+ return /* @__PURE__ */ React12.createElement("a", { href: linkParamValueToHref(link) }, children);
728
739
  };
729
740
 
730
741
  // src/components/UniformRichText/nodes/ListItemRichTextNode.tsx
731
- import React12 from "react";
742
+ import React13 from "react";
732
743
  var ListItemRichTextNode = ({ children, node }) => {
733
744
  const { value } = node;
734
- return /* @__PURE__ */ React12.createElement("li", { value: Number.isFinite(value) && value > 0 ? value : void 0 }, children);
745
+ return /* @__PURE__ */ React13.createElement("li", { value: Number.isFinite(value) && value > 0 ? value : void 0 }, children);
735
746
  };
736
747
 
737
748
  // src/components/UniformRichText/nodes/ListRichTextNode.tsx
738
- import React13 from "react";
749
+ import React14 from "react";
739
750
  var ListRichTextNode = ({ children, node }) => {
740
751
  const { tag, start } = node;
741
752
  const ListTag = tag != null ? tag : "ul";
742
- return /* @__PURE__ */ React13.createElement(ListTag, { start: Number.isFinite(start) && start > 0 ? start : void 0 }, children);
753
+ return /* @__PURE__ */ React14.createElement(ListTag, { start: Number.isFinite(start) && start > 0 ? start : void 0 }, children);
743
754
  };
744
755
 
745
756
  // src/components/UniformRichText/nodes/ParagraphRichTextNode.tsx
746
757
  import { isPureDirection, isPureTextAlign } from "@uniformdev/richtext";
747
- import React14 from "react";
758
+ import React15 from "react";
748
759
  var ParagraphRichTextNode = ({ children, node }) => {
749
760
  const { format, direction } = node;
750
- return /* @__PURE__ */ React14.createElement(
761
+ return /* @__PURE__ */ React15.createElement(
751
762
  "p",
752
763
  {
753
764
  dir: isPureDirection(direction) ? direction : void 0,
@@ -757,19 +768,28 @@ var ParagraphRichTextNode = ({ children, node }) => {
757
768
  );
758
769
  };
759
770
 
771
+ // src/components/UniformRichText/nodes/TableCellRichTextNode.tsx
772
+ import { getRichTextTagFromTableCellHeaderState } from "@uniformdev/richtext";
773
+ import React16 from "react";
774
+ var TableCellRichTextNode = ({ children, node }) => {
775
+ const { headerState } = node;
776
+ const TableCellTag = getRichTextTagFromTableCellHeaderState(headerState);
777
+ return /* @__PURE__ */ React16.createElement(TableCellTag, null, children);
778
+ };
779
+
760
780
  // src/components/UniformRichText/nodes/TabRichTextNode.tsx
761
- import React15 from "react";
781
+ import React17 from "react";
762
782
  var TabRichTextNode = () => {
763
- return /* @__PURE__ */ React15.createElement(React15.Fragment, null, " ");
783
+ return /* @__PURE__ */ React17.createElement(React17.Fragment, null, " ");
764
784
  };
765
785
 
766
786
  // src/components/UniformRichText/nodes/TextRichTextNode.tsx
767
787
  import { getRichTextTagsFromTextFormat } from "@uniformdev/richtext";
768
- import React16 from "react";
788
+ import React18 from "react";
769
789
  var TextRichTextNode = ({ node }) => {
770
790
  const { text, format } = node;
771
791
  const tags = getRichTextTagsFromTextFormat(format);
772
- return /* @__PURE__ */ React16.createElement(React16.Fragment, null, tags.length > 0 ? tags.reduceRight((children, Tag) => /* @__PURE__ */ React16.createElement(Tag, null, children), text) : text);
792
+ return /* @__PURE__ */ React18.createElement(React18.Fragment, null, tags.length > 0 ? tags.reduceRight((children, Tag) => /* @__PURE__ */ React18.createElement(Tag, null, children), text) : text);
773
793
  };
774
794
 
775
795
  // src/components/UniformRichText/UniformRichTextNode.tsx
@@ -783,8 +803,8 @@ function UniformRichTextNode({ node, ...props }) {
783
803
  if (!NodeRenderer) {
784
804
  return null;
785
805
  }
786
- const children = node.children ? node.children.map((childNode, i) => /* @__PURE__ */ React17.createElement(UniformRichTextNode, { ...props, key: i, node: childNode })) : null;
787
- return /* @__PURE__ */ React17.createElement(NodeRenderer, { node }, children);
806
+ const children = node.children ? node.children.map((childNode, i) => /* @__PURE__ */ React19.createElement(UniformRichTextNode, { ...props, key: i, node: childNode })) : null;
807
+ return /* @__PURE__ */ React19.createElement(NodeRenderer, { node }, children);
788
808
  }
789
809
  var rendererMap = /* @__PURE__ */ new Map([
790
810
  ["heading", HeadingRichTextNode],
@@ -793,48 +813,60 @@ var rendererMap = /* @__PURE__ */ new Map([
793
813
  ["list", ListRichTextNode],
794
814
  ["listitem", ListItemRichTextNode],
795
815
  ["paragraph", ParagraphRichTextNode],
796
- ["quote", ({ children }) => /* @__PURE__ */ React17.createElement("blockquote", null, children)],
816
+ ["quote", ({ children }) => /* @__PURE__ */ React19.createElement("blockquote", null, children)],
797
817
  [
798
818
  "code",
799
- ({ children }) => /* @__PURE__ */ React17.createElement("pre", null, /* @__PURE__ */ React17.createElement("code", null, children))
819
+ ({ children }) => /* @__PURE__ */ React19.createElement("pre", null, /* @__PURE__ */ React19.createElement("code", null, children))
800
820
  ],
801
- ["root", ({ children }) => /* @__PURE__ */ React17.createElement(React17.Fragment, null, children)],
821
+ ["root", ({ children }) => /* @__PURE__ */ React19.createElement(React19.Fragment, null, children)],
802
822
  ["text", TextRichTextNode],
803
- ["tab", TabRichTextNode]
823
+ ["tab", TabRichTextNode],
824
+ [
825
+ "table",
826
+ ({ children }) => /* @__PURE__ */ React19.createElement("table", null, /* @__PURE__ */ React19.createElement("tbody", null, children))
827
+ ],
828
+ ["tablerow", ({ children }) => /* @__PURE__ */ React19.createElement("tr", null, children)],
829
+ ["tablecell", TableCellRichTextNode],
830
+ ["asset", AssetRichTextNode]
804
831
  ]);
805
832
  var resolveRichTextDefaultRenderer = (node) => {
806
833
  return rendererMap.get(node.type);
807
834
  };
808
835
 
809
836
  // src/components/UniformRichText/UniformRichText.tsx
810
- var UniformRichText = React18.forwardRef(function UniformRichText2({ parameterId, resolveRichTextRenderer, as: Tag = "div", ...props }, ref) {
811
- const { data: componentData } = useUniformCurrentComponent();
812
- const parameter = useMemo5(() => {
813
- var _a;
814
- return (_a = componentData == null ? void 0 : componentData.parameters) == null ? void 0 : _a[parameterId];
815
- }, [componentData, parameterId]);
816
- const value = useMemo5(() => parameter == null ? void 0 : parameter.value, [parameter]);
817
- if (!value || !isRichTextValue(value) || isRichTextValueConsideredEmpty(value)) return null;
818
- return Tag === null ? /* @__PURE__ */ React18.createElement(UniformRichTextNode, { node: value.root, resolveRichTextRenderer }) : /* @__PURE__ */ React18.createElement(
837
+ var UniformRichText = React20.forwardRef(function UniformRichText2({ parameterId, resolveRichTextRenderer, as: Tag = "div", placeholder, ...props }, ref) {
838
+ var _a;
839
+ const { data: componentData, contextualEditingDefaultPlaceholder } = useUniformCurrentComponent();
840
+ const { isContextualEditing } = useUniformCurrentComposition();
841
+ const parameter = (_a = componentData == null ? void 0 : componentData.parameters) == null ? void 0 : _a[parameterId];
842
+ if (!parameter) {
843
+ return null;
844
+ }
845
+ const placeholderProp = placeholder != null ? placeholder : contextualEditingDefaultPlaceholder;
846
+ const computedPlaceholder = typeof placeholderProp === "function" ? placeholderProp({ id: parameterId }) : placeholderProp;
847
+ const value = parameter.value;
848
+ if (!value || !isRichTextValue(value)) return null;
849
+ if (!isContextualEditing && isRichTextValueConsideredEmpty(value)) return null;
850
+ return Tag === null ? /* @__PURE__ */ React20.createElement(UniformRichTextNode, { node: value.root, resolveRichTextRenderer }) : /* @__PURE__ */ React20.createElement(
819
851
  Tag,
820
852
  {
821
853
  ref,
822
854
  ...props,
823
- ...{
855
+ ...isContextualEditing ? {
824
856
  [ATTRIBUTE_COMPONENT_ID]: componentData == null ? void 0 : componentData._id,
825
857
  [ATTRIBUTE_PARAMETER_ID]: parameterId,
826
858
  [ATTRIBUTE_PARAMETER_TYPE]: "richText"
827
- }
859
+ } : {}
828
860
  },
829
- /* @__PURE__ */ React18.createElement(UniformRichTextNode, { node: value.root, resolveRichTextRenderer })
861
+ isRichTextValueConsideredEmpty(value) ? /* @__PURE__ */ React20.createElement("p", null, /* @__PURE__ */ React20.createElement("i", null, computedPlaceholder)) : /* @__PURE__ */ React20.createElement(UniformRichTextNode, { node: value.root, resolveRichTextRenderer })
830
862
  );
831
863
  });
832
864
 
833
865
  // src/components/UniformText.tsx
834
- import React20, { useState as useState2 } from "react";
866
+ import React22, { useState as useState2 } from "react";
835
867
 
836
868
  // src/components/PureUniformText.tsx
837
- import React19 from "react";
869
+ import React21 from "react";
838
870
  var PureUniformText = ({
839
871
  as: Tag = "span",
840
872
  parameterId,
@@ -853,10 +885,10 @@ var PureUniformText = ({
853
885
  return null;
854
886
  }
855
887
  if (!isContextualEditing) {
856
- return /* @__PURE__ */ React19.createElement(Tag, { style: isMultiline ? { whiteSpace: "pre-wrap" } : {}, ...props }, render(value));
888
+ return /* @__PURE__ */ React21.createElement(Tag, { style: isMultiline ? { whiteSpace: "pre-wrap" } : {}, ...props }, render(value));
857
889
  }
858
890
  const computedPlaceholder = typeof placeholder === "function" ? placeholder({ id: parameterId }) : placeholder;
859
- return /* @__PURE__ */ React19.createElement(
891
+ return /* @__PURE__ */ React21.createElement(
860
892
  Tag,
861
893
  {
862
894
  ...props,
@@ -894,7 +926,7 @@ var UniformText = ({
894
926
  }
895
927
  const placeholderProp = placeholder != null ? placeholder : contextualEditingDefaultPlaceholder;
896
928
  const computedPlaceholder = typeof placeholderProp === "function" ? placeholderProp({ id: parameterId }) : placeholderProp;
897
- return /* @__PURE__ */ React20.createElement(
929
+ return /* @__PURE__ */ React22.createElement(
898
930
  PureUniformText,
899
931
  {
900
932
  ...props,
@@ -972,7 +1004,7 @@ import {
972
1004
  createCanvasChannel as createCanvasChannel2,
973
1005
  isUpdateContextualEditingStateInternalMessage
974
1006
  } from "@uniformdev/canvas";
975
- import { useEffect as useEffect3, useMemo as useMemo6, useState as useState3 } from "react";
1007
+ import { useEffect as useEffect3, useMemo as useMemo5, useState as useState3 } from "react";
976
1008
  var useUniformContextualEditingState = ({
977
1009
  global = false
978
1010
  } = {}) => {
@@ -982,7 +1014,7 @@ var useUniformContextualEditingState = ({
982
1014
  const [previewMode, setPreviewMode] = useState3(
983
1015
  isContextualEditing ? "editor" : void 0
984
1016
  );
985
- const channel = useMemo6(() => {
1017
+ const channel = useMemo5(() => {
986
1018
  if (!isContextualEditing) {
987
1019
  return;
988
1020
  }
@@ -1016,7 +1048,7 @@ var useUniformContextualEditingState = ({
1016
1048
  unsubscribe();
1017
1049
  };
1018
1050
  }, [global, channel, componentData == null ? void 0 : componentData._id, setSelectedComponentReference, setPreviewMode]);
1019
- return useMemo6(
1051
+ return useMemo5(
1020
1052
  () => ({
1021
1053
  isContextualEditing,
1022
1054
  selectedComponentReference,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@uniformdev/canvas-react",
3
- "version": "19.173.1-alpha.17+25c1176cea",
3
+ "version": "19.173.2-alpha.258+e8775b83de",
4
4
  "description": "React SDK for Uniform Canvas",
5
5
  "license": "SEE LICENSE IN LICENSE.txt",
6
6
  "main": "./dist/index.js",
@@ -45,10 +45,10 @@
45
45
  "document": "api-extractor run --local"
46
46
  },
47
47
  "dependencies": {
48
- "@uniformdev/canvas": "19.173.1-alpha.17+25c1176cea",
49
- "@uniformdev/context": "19.173.1-alpha.17+25c1176cea",
50
- "@uniformdev/context-react": "19.173.1-alpha.17+25c1176cea",
51
- "@uniformdev/richtext": "19.173.1-alpha.17+25c1176cea"
48
+ "@uniformdev/canvas": "19.173.2-alpha.258+e8775b83de",
49
+ "@uniformdev/context": "19.173.2-alpha.258+e8775b83de",
50
+ "@uniformdev/context-react": "19.173.2-alpha.258+e8775b83de",
51
+ "@uniformdev/richtext": "19.173.2-alpha.258+e8775b83de"
52
52
  },
53
53
  "peerDependencies": {
54
54
  "immer": ">= 10",
@@ -56,10 +56,10 @@
56
56
  "react-dom": ">=16"
57
57
  },
58
58
  "devDependencies": {
59
- "@types/react": "18.2.40",
59
+ "@types/react": "18.3.3",
60
60
  "immer": "10.1.1",
61
- "react": "18.2.0",
62
- "react-dom": "18.2.0"
61
+ "react": "18.3.1",
62
+ "react-dom": "18.3.1"
63
63
  },
64
64
  "files": [
65
65
  "/dist"
@@ -67,5 +67,5 @@
67
67
  "publishConfig": {
68
68
  "access": "public"
69
69
  },
70
- "gitHead": "25c1176cea8d5114b92fc75cdd8bba4aa6463a50"
70
+ "gitHead": "e8775b83dec606ce6e2198182152d8b386e15f94"
71
71
  }