@vonaffenfels/contentful-slate-editor 1.0.80 → 1.1.0

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vonaffenfels/contentful-slate-editor",
3
- "version": "1.0.80",
3
+ "version": "1.1.0",
4
4
  "scripts": {
5
5
  "prepublish": "yarn run build",
6
6
  "dev": "yarn run start",
@@ -91,10 +91,10 @@
91
91
  "webpack-watch-files-plugin": "^1.2.1"
92
92
  },
93
93
  "dependencies": {
94
- "@vonaffenfels/slate-editor": "^1.0.80",
94
+ "@vonaffenfels/slate-editor": "^1.1.0",
95
95
  "webpack": "5.88.2"
96
96
  },
97
- "gitHead": "4fb98b27f14958fc2d5c99f8d95c5010da0c266e",
97
+ "gitHead": "d768183ee1ab268e8c52315f91176ff8d610b81b",
98
98
  "publishConfig": {
99
99
  "access": "public"
100
100
  }
@@ -24,6 +24,7 @@ const EditorField = ({
24
24
  locale,
25
25
  onStorybookElementClick,
26
26
  elementPropsMap,
27
+ activeConfig,
27
28
  }) => {
28
29
  const wrapperRef = useRef();
29
30
  const loadedValue = fieldSdk.getValue(locale);
@@ -98,7 +99,6 @@ const EditorField = ({
98
99
  setIsLoadingCount(++isLoadingCountGlobal);
99
100
 
100
101
  try {
101
- console.log("KIENZ_DEBUG: :101 / executeLoader", sdk, sdk?.entry?.sys?.id);
102
102
  const loaderResult = await fetch(`/api/loader/?portal=${portal}&block=${block}`, {
103
103
  method: "POST",
104
104
  body: JSON.stringify({
@@ -160,6 +160,7 @@ const EditorField = ({
160
160
  isLoading={isLoadingCount !== 0}
161
161
  storybookComponentDataLoader={async (block, attributes) => await getLoaderResult(block, attributes)}
162
162
  onStorybookElementClick={onStorybookElementClick}
163
+ activeConfig={activeConfig}
163
164
  />
164
165
  </div>;
165
166
  };
@@ -7,6 +7,7 @@ const Entry = ({
7
7
  sdk,
8
8
  onStorybookElementClick,
9
9
  elementPropsMap,
10
+ activeConfig,
10
11
  }) => {
11
12
  const field = sdk.parameters.instance.contentField;
12
13
  const fieldSdk = sdk.entry.fields[field];
@@ -42,6 +43,7 @@ const Entry = ({
42
43
  sdk={sdk}
43
44
  portal={portal}
44
45
  onStorybookElementClick={onStorybookElementClick}
46
+ activeConfig={activeConfig}
45
47
  />;
46
48
  };
47
49
 
package/src/index.js CHANGED
@@ -18,7 +18,8 @@ import Dialog from "./components/Dialog";
18
18
  export const BaseContentfulApp = (props) => {
19
19
  init(async (sdk) => {
20
20
  const rootContainer = document.getElementById('root');
21
- const RendererWrapperComponent = props?.RendererWrapperComponent || (({children}) => <div className="h-full">{children}</div>);
21
+ const RendererWrapperComponent = props?.RendererWrapperComponent || (({children}) => <div
22
+ className="h-full">{children}</div>);
22
23
  const wrapperProps = {
23
24
  sdk,
24
25
  value: sdk.parameters?.invocation?.value || sdk?.field?.getValue(),
@@ -27,10 +28,18 @@ export const BaseContentfulApp = (props) => {
27
28
  };
28
29
  const elementPropsMap = props?.getElementPropsMap?.(wrapperProps.contentType) || props?.elementPropsMap;
29
30
 
30
- let config;
31
+ let config = {};
31
32
 
32
- if (sdk.parameters?.invocation?.portal) {
33
- config = await props.getByPortal(sdk.parameters?.invocation?.portal);
33
+ if (wrapperProps.portal) {
34
+ try {
35
+ config = await props.getByPortal(wrapperProps.portal);
36
+
37
+ if (props.getDomain) {
38
+ config.domain = props.getDomain(wrapperProps.portal);
39
+ }
40
+ } catch (e) {
41
+ console.error(`Error in getting config for portal ${wrapperProps.portal}`, e);
42
+ }
34
43
  }
35
44
 
36
45
  const ComponentLocationSettings = [
@@ -40,7 +49,9 @@ export const BaseContentfulApp = (props) => {
40
49
  },
41
50
  {
42
51
  location: locations.LOCATION_ENTRY_FIELD,
43
- component: <RendererWrapperComponent {...wrapperProps}><Field sdk={sdk} elementPropsMap={elementPropsMap}/></RendererWrapperComponent>,
52
+ component: <RendererWrapperComponent {...wrapperProps}><Field
53
+ sdk={sdk}
54
+ elementPropsMap={elementPropsMap}/></RendererWrapperComponent>,
44
55
  },
45
56
  {
46
57
  location: locations.LOCATION_ENTRY_EDITOR,
@@ -51,11 +62,12 @@ export const BaseContentfulApp = (props) => {
51
62
  const storybookElementChangeEvent = new CustomEvent("storybookElementChange", {detail: element});
52
63
 
53
64
  window.parent.document.dispatchEvent(storybookElementChangeEvent);
54
- }}/></RendererWrapperComponent>,
65
+ }}
66
+ activeConfig={config}/></RendererWrapperComponent>,
55
67
  },
56
68
  {
57
69
  location: locations.LOCATION_DIALOG,
58
- component: <Dialog sdk={sdk} elementPropsMap={elementPropsMap} activeConfig={config} />,
70
+ component: <Dialog sdk={sdk} elementPropsMap={elementPropsMap} activeConfig={config}/>,
59
71
  },
60
72
  ];
61
73