@uniformdev/canvas-next-rsc-client 19.55.2-alpha.52 → 19.55.2-alpha.54
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.esm.js +21 -2
- package/dist/index.js +20 -1
- package/dist/index.mjs +21 -2
- package/package.json +5 -5
package/dist/index.esm.js
CHANGED
|
@@ -139,11 +139,12 @@ import {
|
|
|
139
139
|
isAllowedReferrer
|
|
140
140
|
} from "@uniformdev/canvas";
|
|
141
141
|
import { useRouter, useSearchParams as useSearchParams3 } from "next/navigation";
|
|
142
|
-
import { useEffect as useEffect6, useMemo } from "react";
|
|
142
|
+
import { useEffect as useEffect6, useMemo, useRef } from "react";
|
|
143
143
|
import { Fragment as Fragment5, jsx as jsx3 } from "react/jsx-runtime";
|
|
144
144
|
var UniformScript = () => {
|
|
145
145
|
const router = useRouter();
|
|
146
146
|
const params = useSearchParams3();
|
|
147
|
+
const needsToRefreshRef = useRef(false);
|
|
147
148
|
const enabled = params.get(IN_CONTEXT_EDITOR_QUERY_STRING_PARAM2) === "true";
|
|
148
149
|
const channel = useMemo(() => {
|
|
149
150
|
var _a;
|
|
@@ -161,7 +162,13 @@ var UniformScript = () => {
|
|
|
161
162
|
return;
|
|
162
163
|
}
|
|
163
164
|
const unsubscribeFromEditorUpdates = channel.on("editor-state-updated", () => {
|
|
164
|
-
|
|
165
|
+
const el = document.activeElement;
|
|
166
|
+
const isActiveElementEditable = el == null ? void 0 : el.isContentEditable;
|
|
167
|
+
if (!isActiveElementEditable) {
|
|
168
|
+
router.refresh();
|
|
169
|
+
} else {
|
|
170
|
+
needsToRefreshRef.current = true;
|
|
171
|
+
}
|
|
165
172
|
});
|
|
166
173
|
return () => {
|
|
167
174
|
unsubscribeFromEditorUpdates();
|
|
@@ -188,6 +195,18 @@ var UniformScript = () => {
|
|
|
188
195
|
existing.remove();
|
|
189
196
|
}
|
|
190
197
|
}, [enabled]);
|
|
198
|
+
useEffect6(() => {
|
|
199
|
+
const handleBlurChange = () => {
|
|
200
|
+
if (needsToRefreshRef.current) {
|
|
201
|
+
router.refresh();
|
|
202
|
+
needsToRefreshRef.current = false;
|
|
203
|
+
}
|
|
204
|
+
};
|
|
205
|
+
document.addEventListener("blur", handleBlurChange, true);
|
|
206
|
+
return () => {
|
|
207
|
+
document.removeEventListener("focus", handleBlurChange, true);
|
|
208
|
+
};
|
|
209
|
+
}, [router]);
|
|
191
210
|
return /* @__PURE__ */ jsx3(Fragment5, {});
|
|
192
211
|
};
|
|
193
212
|
|
package/dist/index.js
CHANGED
|
@@ -170,6 +170,7 @@ var import_jsx_runtime3 = require("react/jsx-runtime");
|
|
|
170
170
|
var UniformScript = () => {
|
|
171
171
|
const router = (0, import_navigation3.useRouter)();
|
|
172
172
|
const params = (0, import_navigation3.useSearchParams)();
|
|
173
|
+
const needsToRefreshRef = (0, import_react7.useRef)(false);
|
|
173
174
|
const enabled = params.get(import_canvas4.IN_CONTEXT_EDITOR_QUERY_STRING_PARAM) === "true";
|
|
174
175
|
const channel = (0, import_react7.useMemo)(() => {
|
|
175
176
|
var _a;
|
|
@@ -187,7 +188,13 @@ var UniformScript = () => {
|
|
|
187
188
|
return;
|
|
188
189
|
}
|
|
189
190
|
const unsubscribeFromEditorUpdates = channel.on("editor-state-updated", () => {
|
|
190
|
-
|
|
191
|
+
const el = document.activeElement;
|
|
192
|
+
const isActiveElementEditable = el == null ? void 0 : el.isContentEditable;
|
|
193
|
+
if (!isActiveElementEditable) {
|
|
194
|
+
router.refresh();
|
|
195
|
+
} else {
|
|
196
|
+
needsToRefreshRef.current = true;
|
|
197
|
+
}
|
|
191
198
|
});
|
|
192
199
|
return () => {
|
|
193
200
|
unsubscribeFromEditorUpdates();
|
|
@@ -214,6 +221,18 @@ var UniformScript = () => {
|
|
|
214
221
|
existing.remove();
|
|
215
222
|
}
|
|
216
223
|
}, [enabled]);
|
|
224
|
+
(0, import_react7.useEffect)(() => {
|
|
225
|
+
const handleBlurChange = () => {
|
|
226
|
+
if (needsToRefreshRef.current) {
|
|
227
|
+
router.refresh();
|
|
228
|
+
needsToRefreshRef.current = false;
|
|
229
|
+
}
|
|
230
|
+
};
|
|
231
|
+
document.addEventListener("blur", handleBlurChange, true);
|
|
232
|
+
return () => {
|
|
233
|
+
document.removeEventListener("focus", handleBlurChange, true);
|
|
234
|
+
};
|
|
235
|
+
}, [router]);
|
|
217
236
|
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_jsx_runtime3.Fragment, {});
|
|
218
237
|
};
|
|
219
238
|
|
package/dist/index.mjs
CHANGED
|
@@ -139,11 +139,12 @@ import {
|
|
|
139
139
|
isAllowedReferrer
|
|
140
140
|
} from "@uniformdev/canvas";
|
|
141
141
|
import { useRouter, useSearchParams as useSearchParams3 } from "next/navigation";
|
|
142
|
-
import { useEffect as useEffect6, useMemo } from "react";
|
|
142
|
+
import { useEffect as useEffect6, useMemo, useRef } from "react";
|
|
143
143
|
import { Fragment as Fragment5, jsx as jsx3 } from "react/jsx-runtime";
|
|
144
144
|
var UniformScript = () => {
|
|
145
145
|
const router = useRouter();
|
|
146
146
|
const params = useSearchParams3();
|
|
147
|
+
const needsToRefreshRef = useRef(false);
|
|
147
148
|
const enabled = params.get(IN_CONTEXT_EDITOR_QUERY_STRING_PARAM2) === "true";
|
|
148
149
|
const channel = useMemo(() => {
|
|
149
150
|
var _a;
|
|
@@ -161,7 +162,13 @@ var UniformScript = () => {
|
|
|
161
162
|
return;
|
|
162
163
|
}
|
|
163
164
|
const unsubscribeFromEditorUpdates = channel.on("editor-state-updated", () => {
|
|
164
|
-
|
|
165
|
+
const el = document.activeElement;
|
|
166
|
+
const isActiveElementEditable = el == null ? void 0 : el.isContentEditable;
|
|
167
|
+
if (!isActiveElementEditable) {
|
|
168
|
+
router.refresh();
|
|
169
|
+
} else {
|
|
170
|
+
needsToRefreshRef.current = true;
|
|
171
|
+
}
|
|
165
172
|
});
|
|
166
173
|
return () => {
|
|
167
174
|
unsubscribeFromEditorUpdates();
|
|
@@ -188,6 +195,18 @@ var UniformScript = () => {
|
|
|
188
195
|
existing.remove();
|
|
189
196
|
}
|
|
190
197
|
}, [enabled]);
|
|
198
|
+
useEffect6(() => {
|
|
199
|
+
const handleBlurChange = () => {
|
|
200
|
+
if (needsToRefreshRef.current) {
|
|
201
|
+
router.refresh();
|
|
202
|
+
needsToRefreshRef.current = false;
|
|
203
|
+
}
|
|
204
|
+
};
|
|
205
|
+
document.addEventListener("blur", handleBlurChange, true);
|
|
206
|
+
return () => {
|
|
207
|
+
document.removeEventListener("focus", handleBlurChange, true);
|
|
208
|
+
};
|
|
209
|
+
}, [router]);
|
|
191
210
|
return /* @__PURE__ */ jsx3(Fragment5, {});
|
|
192
211
|
};
|
|
193
212
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@uniformdev/canvas-next-rsc-client",
|
|
3
|
-
"version": "19.55.2-alpha.
|
|
3
|
+
"version": "19.55.2-alpha.54+5c0508742",
|
|
4
4
|
"license": "SEE LICENSE IN LICENSE.txt",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"build": "tsup",
|
|
@@ -32,9 +32,9 @@
|
|
|
32
32
|
"react-dom": "18.2.0"
|
|
33
33
|
},
|
|
34
34
|
"dependencies": {
|
|
35
|
-
"@uniformdev/canvas": "19.55.2-alpha.
|
|
36
|
-
"@uniformdev/canvas-next-rsc-shared": "^19.55.2-alpha.
|
|
37
|
-
"@uniformdev/canvas-react": "^19.55.2-alpha.
|
|
35
|
+
"@uniformdev/canvas": "19.55.2-alpha.54+5c0508742",
|
|
36
|
+
"@uniformdev/canvas-next-rsc-shared": "^19.55.2-alpha.54+5c0508742",
|
|
37
|
+
"@uniformdev/canvas-react": "^19.55.2-alpha.54+5c0508742"
|
|
38
38
|
},
|
|
39
39
|
"engines": {
|
|
40
40
|
"node": ">=16.14.0"
|
|
@@ -47,5 +47,5 @@
|
|
|
47
47
|
"publishConfig": {
|
|
48
48
|
"access": "public"
|
|
49
49
|
},
|
|
50
|
-
"gitHead": "
|
|
50
|
+
"gitHead": "5c0508742475c257e8e24003c4515dd06252045b"
|
|
51
51
|
}
|