@vonaffenfels/contentful-slate-editor 1.0.56 → 1.0.58

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.56",
3
+ "version": "1.0.58",
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.56",
94
+ "@vonaffenfels/slate-editor": "^1.0.58",
95
95
  "webpack": "5.88.2"
96
96
  },
97
- "gitHead": "46c4cdded137ff7fdd53011ee6b999972131dd9c",
97
+ "gitHead": "e85142a8a7b6863ad2aa7a1ded8ee89a5f4d64aa",
98
98
  "publishConfig": {
99
99
  "access": "public"
100
100
  }
@@ -29,7 +29,7 @@ const Dialog = ({
29
29
 
30
30
  switch (sdk.parameters.invocation.type) {
31
31
  case "cloudinary":
32
- return <DialogCloudinary sdk={sdk} config={activeConfig} />;
32
+ return <DialogCloudinary sdk={sdk} config={sdk.parameters.invocation} activeConfig={activeConfig} />;
33
33
  default:
34
34
  return <div className="relative flex h-full max-h-full justify-between">
35
35
  <BlockEditor
@@ -8,9 +8,10 @@ import "../scss/dialog-cloudinary.scss";
8
8
  const DialogCloudinary = ({
9
9
  sdk,
10
10
  config,
11
+ activeConfig,
11
12
  }) => {
12
- const cloudinaryApiKey = config?.env?.CLOUDINARY_CLOUD_NAME;
13
- const cloudinaryCloudName = config?.env?.CLOUDINARY_API_KEY;
13
+ const cloudinaryApiKey = activeConfig?.env?.CLOUDINARY_API_KEY;
14
+ const cloudinaryCloudName = activeConfig?.env?.CLOUDINARY_CLOUD_NAME;
14
15
 
15
16
  const cloudinaryRef = useRef(null);
16
17
 
@@ -98,21 +98,18 @@ const EditorField = ({
98
98
  setIsLoadingCount(++isLoadingCountGlobal);
99
99
 
100
100
  try {
101
- const fetchUrl = `/api/loader/?${new URLSearchParams({
102
- portal: portal,
103
- block: block,
104
- variables: JSON.stringify({
105
- ...attributes,
106
- entries: null,
107
- items: null,
101
+ console.log("KIENZ_DEBUG: :101 / executeLoader", sdk, sdk?.entry?.sys?.id);
102
+ const loaderResult = await fetch(`/api/loader/?portal=${portal}&block=${block}`, {
103
+ method: "POST",
104
+ body: JSON.stringify({
105
+ variables: {
106
+ ...(attributes || {}),
107
+ },
108
+ context: {activeContent: {sys: {id: sdk?.entry?.sys?.id}}},
108
109
  }),
109
- })}`;
110
-
111
- loaderResult = await fetch(fetchUrl)
112
- .then(res => res.json())
113
- .catch(err => {
114
- console.error(err);
115
- });
110
+ }).then(res => res.json()).catch(err => {
111
+ console.error(err);
112
+ });
116
113
 
117
114
  if (loaderResult) {
118
115
  for (let key in loaderResult) {
package/src/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import React from 'react';
1
+ import React, {useState} from 'react';
2
2
  import {createRoot} from 'react-dom/client';
3
3
 
4
4
  import {
@@ -16,7 +16,7 @@ import Field from './components/Field';
16
16
  import Dialog from "./components/Dialog";
17
17
 
18
18
  export const BaseContentfulApp = (props) => {
19
- init((sdk) => {
19
+ init(async (sdk) => {
20
20
  const rootContainer = document.getElementById('root');
21
21
  const RendererWrapperComponent = props?.RendererWrapperComponent || (({children}) => <div className="h-full">{children}</div>);
22
22
  const wrapperProps = {
@@ -26,7 +26,12 @@ export const BaseContentfulApp = (props) => {
26
26
  contentType: sdk.parameters?.invocation?.contentType || sdk?.entry?.getSys()?.contentType?.sys?.id,
27
27
  };
28
28
  const elementPropsMap = props?.getElementPropsMap?.(wrapperProps.contentType) || props?.elementPropsMap;
29
- const activeConfig = props?.getActiveConfig?.() || props?.activeConfig;
29
+
30
+ let config;
31
+
32
+ if (sdk.parameters?.invocation?.portal) {
33
+ config = await props.getByPortal(sdk.parameters?.invocation?.portal);
34
+ }
30
35
 
31
36
  const ComponentLocationSettings = [
32
37
  {
@@ -50,7 +55,7 @@ export const BaseContentfulApp = (props) => {
50
55
  },
51
56
  {
52
57
  location: locations.LOCATION_DIALOG,
53
- component: <RendererWrapperComponent {...wrapperProps} ><Dialog sdk={sdk} elementPropsMap={elementPropsMap} activeConfig={activeConfig} /></RendererWrapperComponent>,
58
+ component: <Dialog sdk={sdk} elementPropsMap={elementPropsMap} activeConfig={config} />,
54
59
  },
55
60
  ];
56
61