@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 CHANGED
@@ -3927,7 +3927,10 @@ function OhhwellsBridge() {
3927
3927
  if (timer !== void 0) {
3928
3928
  clearTimeout(timer);
3929
3929
  autoSaveTimers.current.delete(key);
3930
- const html = sanitizeHtml(el.innerHTML);
3930
+ }
3931
+ const html = sanitizeHtml(el.innerHTML);
3932
+ const original = originalContentRef.current ?? "";
3933
+ if (html !== sanitizeHtml(original)) {
3931
3934
  postToParentRef.current({ type: "ow:change", nodes: [{ key, text: html }] });
3932
3935
  const h = document.documentElement.scrollHeight;
3933
3936
  if (h > 50) postToParentRef.current({ type: "ow:height", height: h });
@@ -3943,6 +3946,10 @@ function OhhwellsBridge() {
3943
3946
  const activate = (0, import_react.useCallback)((el) => {
3944
3947
  if (activeElRef.current === el) return;
3945
3948
  deactivate();
3949
+ if (hoveredImageRef.current) {
3950
+ hoveredImageRef.current = null;
3951
+ postToParentRef.current({ type: "ow:image-unhover" });
3952
+ }
3946
3953
  el.setAttribute("contenteditable", "true");
3947
3954
  el.removeAttribute("data-ohw-hovered");
3948
3955
  activeElRef.current = el;
@@ -4261,7 +4268,8 @@ function OhhwellsBridge() {
4261
4268
  }
4262
4269
  return smallest;
4263
4270
  };
4264
- const probeImageAt = (clientX, clientY, isDragOver = false, fromParentViewport = false, fromOverlay = false) => {
4271
+ const probeImageAt = (clientX, clientY, isDragOver = false, fromParentViewport = false) => {
4272
+ if (activeElRef.current) return;
4265
4273
  const toggleEl = document.querySelector("[data-ohw-state-toggle]");
4266
4274
  if (toggleEl) {
4267
4275
  const { x, y } = toProbeCoords(clientX, clientY, fromParentViewport);
@@ -4289,7 +4297,6 @@ function OhhwellsBridge() {
4289
4297
  }
4290
4298
  const topEditable = topEl?.closest("[data-ohw-editable]");
4291
4299
  if (topEditable && topEditable.dataset.ohwEditable !== "image" && topEditable.dataset.ohwEditable !== "bg-image") {
4292
- if (topEditable.hasAttribute("contenteditable") && fromOverlay) return;
4293
4300
  if (hoveredImageRef.current) {
4294
4301
  hoveredImageRef.current = null;
4295
4302
  resumeAnimTracks();
@@ -4361,9 +4368,9 @@ function OhhwellsBridge() {
4361
4368
  };
4362
4369
  const handlePointerSync = (e) => {
4363
4370
  if (e.data?.type !== "ow:pointer-sync") return;
4364
- const { clientX, clientY, fromOverlay } = e.data;
4371
+ const { clientX, clientY } = e.data;
4365
4372
  if (typeof clientX !== "number" || typeof clientY !== "number") return;
4366
- probeImageAt(clientX, clientY, false, false, fromOverlay ?? false);
4373
+ probeImageAt(clientX, clientY);
4367
4374
  probeHoverCardsAt(clientX, clientY);
4368
4375
  };
4369
4376
  const handleDragOver = (e) => {