@ohhwells/bridge 0.1.5 → 0.1.7
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 +13 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +14 -0
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
1
3
|
// src/OhhwellsBridge.tsx
|
|
2
4
|
import React2, { useCallback, useEffect, useLayoutEffect, useRef, useState } from "react";
|
|
3
5
|
|
|
@@ -3880,6 +3882,18 @@ function OhhwellsBridge() {
|
|
|
3880
3882
|
const deactivate = useCallback(() => {
|
|
3881
3883
|
const el = activeElRef.current;
|
|
3882
3884
|
if (!el) return;
|
|
3885
|
+
const key = el.dataset.ohwKey;
|
|
3886
|
+
if (key) {
|
|
3887
|
+
const timer = autoSaveTimers.current.get(key);
|
|
3888
|
+
if (timer !== void 0) {
|
|
3889
|
+
clearTimeout(timer);
|
|
3890
|
+
autoSaveTimers.current.delete(key);
|
|
3891
|
+
const html = sanitizeHtml(el.innerHTML);
|
|
3892
|
+
postToParentRef.current({ type: "ow:change", nodes: [{ key, text: html }] });
|
|
3893
|
+
const h = document.documentElement.scrollHeight;
|
|
3894
|
+
if (h > 50) postToParentRef.current({ type: "ow:height", height: h });
|
|
3895
|
+
}
|
|
3896
|
+
}
|
|
3883
3897
|
el.removeAttribute("contenteditable");
|
|
3884
3898
|
activeElRef.current = null;
|
|
3885
3899
|
setToolbarRect(null);
|