@ohhwells/bridge 0.1.7 → 0.1.9
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.cjs +12 -5
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +12 -5
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -3888,7 +3888,10 @@ function OhhwellsBridge() {
|
|
|
3888
3888
|
if (timer !== void 0) {
|
|
3889
3889
|
clearTimeout(timer);
|
|
3890
3890
|
autoSaveTimers.current.delete(key);
|
|
3891
|
-
|
|
3891
|
+
}
|
|
3892
|
+
const html = sanitizeHtml(el.innerHTML);
|
|
3893
|
+
const original = originalContentRef.current ?? "";
|
|
3894
|
+
if (html !== sanitizeHtml(original)) {
|
|
3892
3895
|
postToParentRef.current({ type: "ow:change", nodes: [{ key, text: html }] });
|
|
3893
3896
|
const h = document.documentElement.scrollHeight;
|
|
3894
3897
|
if (h > 50) postToParentRef.current({ type: "ow:height", height: h });
|
|
@@ -3904,6 +3907,10 @@ function OhhwellsBridge() {
|
|
|
3904
3907
|
const activate = useCallback((el) => {
|
|
3905
3908
|
if (activeElRef.current === el) return;
|
|
3906
3909
|
deactivate();
|
|
3910
|
+
if (hoveredImageRef.current) {
|
|
3911
|
+
hoveredImageRef.current = null;
|
|
3912
|
+
postToParentRef.current({ type: "ow:image-unhover" });
|
|
3913
|
+
}
|
|
3907
3914
|
el.setAttribute("contenteditable", "true");
|
|
3908
3915
|
el.removeAttribute("data-ohw-hovered");
|
|
3909
3916
|
activeElRef.current = el;
|
|
@@ -4222,7 +4229,8 @@ function OhhwellsBridge() {
|
|
|
4222
4229
|
}
|
|
4223
4230
|
return smallest;
|
|
4224
4231
|
};
|
|
4225
|
-
const probeImageAt = (clientX, clientY, isDragOver = false, fromParentViewport = false
|
|
4232
|
+
const probeImageAt = (clientX, clientY, isDragOver = false, fromParentViewport = false) => {
|
|
4233
|
+
if (activeElRef.current) return;
|
|
4226
4234
|
const toggleEl = document.querySelector("[data-ohw-state-toggle]");
|
|
4227
4235
|
if (toggleEl) {
|
|
4228
4236
|
const { x, y } = toProbeCoords(clientX, clientY, fromParentViewport);
|
|
@@ -4250,7 +4258,6 @@ function OhhwellsBridge() {
|
|
|
4250
4258
|
}
|
|
4251
4259
|
const topEditable = topEl?.closest("[data-ohw-editable]");
|
|
4252
4260
|
if (topEditable && topEditable.dataset.ohwEditable !== "image" && topEditable.dataset.ohwEditable !== "bg-image") {
|
|
4253
|
-
if (topEditable.hasAttribute("contenteditable") && fromOverlay) return;
|
|
4254
4261
|
if (hoveredImageRef.current) {
|
|
4255
4262
|
hoveredImageRef.current = null;
|
|
4256
4263
|
resumeAnimTracks();
|
|
@@ -4322,9 +4329,9 @@ function OhhwellsBridge() {
|
|
|
4322
4329
|
};
|
|
4323
4330
|
const handlePointerSync = (e) => {
|
|
4324
4331
|
if (e.data?.type !== "ow:pointer-sync") return;
|
|
4325
|
-
const { clientX, clientY
|
|
4332
|
+
const { clientX, clientY } = e.data;
|
|
4326
4333
|
if (typeof clientX !== "number" || typeof clientY !== "number") return;
|
|
4327
|
-
probeImageAt(clientX, clientY
|
|
4334
|
+
probeImageAt(clientX, clientY);
|
|
4328
4335
|
probeHoverCardsAt(clientX, clientY);
|
|
4329
4336
|
};
|
|
4330
4337
|
const handleDragOver = (e) => {
|