@vonaffenfels/contentful-slate-editor 1.0.31 → 1.0.34
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 +3 -3
- package/src/components/EditorField.js +29 -23
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vonaffenfels/contentful-slate-editor",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.34",
|
|
4
4
|
"scripts": {
|
|
5
5
|
"prepublish": "yarn run build",
|
|
6
6
|
"dev": "yarn run start",
|
|
@@ -89,10 +89,10 @@
|
|
|
89
89
|
"webpack-dev-server": "^4.0.0-beta.2"
|
|
90
90
|
},
|
|
91
91
|
"dependencies": {
|
|
92
|
-
"@vonaffenfels/slate-editor": "^1.0.
|
|
92
|
+
"@vonaffenfels/slate-editor": "^1.0.34",
|
|
93
93
|
"webpack": "5.88.2"
|
|
94
94
|
},
|
|
95
|
-
"gitHead": "
|
|
95
|
+
"gitHead": "09afee2ada365a370687380dbcb426fdb6e4d51f",
|
|
96
96
|
"publishConfig": {
|
|
97
97
|
"access": "public"
|
|
98
98
|
}
|
|
@@ -12,6 +12,7 @@ import storybookStories from "storybookStories";
|
|
|
12
12
|
import componentLoader from "@vonaffenfels/slate-editor/componentLoader";
|
|
13
13
|
|
|
14
14
|
let isLoadingCountGlobal = 0;
|
|
15
|
+
let loaderTimeout;
|
|
15
16
|
|
|
16
17
|
const EditorField = ({
|
|
17
18
|
fieldSdk,
|
|
@@ -104,32 +105,37 @@ const EditorField = ({
|
|
|
104
105
|
isLoading={isLoadingCount !== 0}
|
|
105
106
|
storybookComponentDataLoader={async (block, attributes) => {
|
|
106
107
|
let loaderResult = {};
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
108
|
+
|
|
109
|
+
clearTimeout(loaderTimeout);
|
|
110
|
+
|
|
111
|
+
loaderTimeout = await setTimeout(async () => {
|
|
112
|
+
setIsLoadingCount(++isLoadingCountGlobal);
|
|
113
|
+
|
|
114
|
+
try {
|
|
115
|
+
const fetchUrl = `/api/loader/?${new URLSearchParams({
|
|
116
|
+
portal: portal,
|
|
117
|
+
block: block,
|
|
118
|
+
variables: JSON.stringify({
|
|
119
|
+
...attributes,
|
|
120
|
+
entries: null,
|
|
121
|
+
items: null,
|
|
122
|
+
}),
|
|
123
|
+
})}`;
|
|
124
|
+
|
|
125
|
+
loaderResult = await fetch(fetchUrl).then(res => res.json());
|
|
126
|
+
|
|
127
|
+
if (loaderResult) {
|
|
128
|
+
for (let key in loaderResult) {
|
|
129
|
+
attributes[key] = loaderResult[key];
|
|
130
|
+
}
|
|
125
131
|
}
|
|
132
|
+
} catch (e) {
|
|
133
|
+
console.error(`Error in loader for ${block}`);
|
|
134
|
+
console.error(e);
|
|
126
135
|
}
|
|
127
|
-
} catch (e) {
|
|
128
|
-
console.error(`Error in loader for ${block}`);
|
|
129
|
-
console.error(e);
|
|
130
|
-
}
|
|
131
136
|
|
|
132
|
-
|
|
137
|
+
setIsLoadingCount(--isLoadingCountGlobal);
|
|
138
|
+
}, 1000);
|
|
133
139
|
|
|
134
140
|
return loaderResult;
|
|
135
141
|
}}
|