@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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vonaffenfels/contentful-slate-editor",
3
- "version": "1.0.31",
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.31",
92
+ "@vonaffenfels/slate-editor": "^1.0.34",
93
93
  "webpack": "5.88.2"
94
94
  },
95
- "gitHead": "007715e3b949cf0368e7b4d70626d2931c7b7829",
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
- setIsLoadingCount(++isLoadingCountGlobal);
108
-
109
- try {
110
- const fetchUrl = `/api/loader/?${new URLSearchParams({
111
- portal: portal,
112
- block: block,
113
- variables: JSON.stringify({
114
- ...attributes,
115
- entries: null,
116
- items: null,
117
- }),
118
- })}`;
119
-
120
- loaderResult = await fetch(fetchUrl).then(res => res.json());
121
-
122
- if (loaderResult) {
123
- for (let key in loaderResult) {
124
- attributes[key] = loaderResult[key];
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
- setIsLoadingCount(--isLoadingCountGlobal);
137
+ setIsLoadingCount(--isLoadingCountGlobal);
138
+ }, 1000);
133
139
 
134
140
  return loaderResult;
135
141
  }}