@windoc/react 0.3.6 → 0.3.8

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.js CHANGED
@@ -2140,6 +2140,8 @@ function EditorInner({
2140
2140
  } = useFooter();
2141
2141
  (0, import_react21.useEffect)(() => {
2142
2142
  let instance = null;
2143
+ let cancelled = false;
2144
+ let closeDropdowns = null;
2143
2145
  const initEditor = async () => {
2144
2146
  if (!containerRef.current) return;
2145
2147
  const {
@@ -2151,6 +2153,7 @@ function EditorInner({
2151
2153
  Dialog,
2152
2154
  Signature
2153
2155
  } = await import("@windoc/core");
2156
+ if (cancelled) return;
2154
2157
  const data = defaultValue ?? { main: [] };
2155
2158
  instance = new EditorClass(
2156
2159
  containerRef.current,
@@ -2250,7 +2253,7 @@ function EditorInner({
2250
2253
  }
2251
2254
  }
2252
2255
  ]);
2253
- const closeDropdowns = (evt) => {
2256
+ closeDropdowns = (evt) => {
2254
2257
  const visibleDom = document.querySelector(".visible");
2255
2258
  if (!visibleDom) return;
2256
2259
  const parent = visibleDom.parentElement;
@@ -2264,7 +2267,13 @@ function EditorInner({
2264
2267
  };
2265
2268
  initEditor();
2266
2269
  return () => {
2270
+ cancelled = true;
2267
2271
  instance?.destroy();
2272
+ editorRef.current = null;
2273
+ if (closeDropdowns) {
2274
+ window.removeEventListener("click", closeDropdowns, { capture: true });
2275
+ closeDropdowns = null;
2276
+ }
2268
2277
  };
2269
2278
  }, []);
2270
2279
  const handleDrop = (e) => {