patent-editor 0.2.10 → 0.2.11

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/lib.d.ts CHANGED
@@ -322,7 +322,7 @@ declare interface EditorState {
322
322
  chatSessionAPI: ChatSessionAPI | null;
323
323
  chatSessionId: string | null;
324
324
  rightPanel: RightPanelState;
325
- setEditor: (editor: Editor) => void;
325
+ setEditor: (editor: Editor | null) => void;
326
326
  setDocument: (document: JSONContent) => void;
327
327
  setSelection: (selection: {
328
328
  from: number;
package/dist/lib.js CHANGED
@@ -929,7 +929,7 @@ class va {
929
929
  });
930
930
  }
931
931
  notifyStateChange(t) {
932
- this.getOrderedPlugins().forEach((n) => {
932
+ t.isDestroyed || this.getOrderedPlugins().forEach((n) => {
933
933
  n.onStateChange && n.onStateChange(t);
934
934
  });
935
935
  }
@@ -1266,7 +1266,7 @@ const Ie = () => {
1266
1266
  typeof I == "number" && e.commands.command(({ tr: A, dispatch: D }) => (A.setNodeMarkup(I, void 0, { ...r.attrs, ...C }), D && D(A), !0));
1267
1267
  };
1268
1268
  let y = "";
1269
- const w = async (C) => {
1269
+ const x = async (C) => {
1270
1270
  const I = C.trim();
1271
1271
  if (I !== y) {
1272
1272
  if (!I) {
@@ -1284,7 +1284,7 @@ const Ie = () => {
1284
1284
  Ie();
1285
1285
  }
1286
1286
  }
1287
- }, x = () => {
1287
+ }, w = () => {
1288
1288
  a || (a = !0, d.value = typeof r.attrs.code == "string" ? r.attrs.code : "", m.textContent = "", m.style.display = "none", E(), requestAnimationFrame(() => d.focus()));
1289
1289
  }, T = () => {
1290
1290
  a = !1, E();
@@ -1307,7 +1307,7 @@ const Ie = () => {
1307
1307
  h({ code: C }), a = !1, E();
1308
1308
  };
1309
1309
  s.addEventListener("dblclick", (C) => {
1310
- C.preventDefault(), C.stopPropagation(), x();
1310
+ C.preventDefault(), C.stopPropagation(), w();
1311
1311
  }), p.addEventListener("click", (C) => {
1312
1312
  C.stopPropagation(), v();
1313
1313
  }), f.addEventListener("click", (C) => {
@@ -1317,7 +1317,7 @@ const Ie = () => {
1317
1317
  const C = N.getState().editorLanguage, I = H(C), A = typeof r.attrs.code == "string" ? r.attrs.code : "";
1318
1318
  s.style.display = a ? "none" : "block", l.style.display = a ? "block" : "none", p.textContent = I.mermaidSaveAndRender || "保存并渲染", f.textContent = I.mermaidCancel || "取消";
1319
1319
  const D = A.trim().length > 0, z = o.querySelector("svg") !== null;
1320
- a || (D && z ? (c.textContent = I.mermaidDoubleClickToEdit || "双击编辑", c.className = "mermaid-view-hint mermaid-view-hint--subtle") : (c.textContent = I.mermaidDoubleClickToCreate || "双击编辑 Mermaid 图表", c.className = "mermaid-view-hint mermaid-view-hint--empty")), !a && A.trim() !== y && w(A);
1320
+ a || (D && z ? (c.textContent = I.mermaidDoubleClickToEdit || "双击编辑", c.className = "mermaid-view-hint mermaid-view-hint--subtle") : (c.textContent = I.mermaidDoubleClickToCreate || "双击编辑 Mermaid 图表", c.className = "mermaid-view-hint mermaid-view-hint--empty")), !a && A.trim() !== y && x(A);
1321
1321
  };
1322
1322
  let _ = N.getState().editorLanguage;
1323
1323
  const b = N.subscribe((C) => {
@@ -1392,22 +1392,22 @@ const Ie = () => {
1392
1392
  o.className = "drawio-preview-img", o.style.display = "none";
1393
1393
  const c = document.createElement("div");
1394
1394
  c.className = "drawio-view-hint", s.append(o, c), i.append(s);
1395
- const l = (x) => {
1395
+ const l = (w) => {
1396
1396
  const T = typeof n == "function" ? n() : null;
1397
- typeof T == "number" && e.commands.command(({ tr: v, dispatch: E }) => (v.setNodeMarkup(T, void 0, { ...r.attrs, ...x }), E && E(v), !0));
1397
+ typeof T == "number" && e.commands.command(({ tr: v, dispatch: E }) => (v.setNodeMarkup(T, void 0, { ...r.attrs, ...w }), E && E(v), !0));
1398
1398
  };
1399
1399
  let d = null, u = null, m = null;
1400
1400
  const f = () => {
1401
1401
  if (a) return;
1402
1402
  a = !0, u = document.createElement("div"), u.className = "drawio-modal-overlay";
1403
- const x = document.createElement("div");
1404
- x.className = "drawio-modal-content";
1403
+ const w = document.createElement("div");
1404
+ w.className = "drawio-modal-content";
1405
1405
  const T = document.createElement("div");
1406
1406
  T.className = "drawio-modal-header";
1407
1407
  const v = N.getState().editorLanguage, E = document.createElement("span");
1408
1408
  E.textContent = v === "en" ? "Edit Draw.io Diagram" : "编辑 Draw.io 图表", E.className = "drawio-modal-title";
1409
1409
  const _ = document.createElement("button");
1410
- _.className = "drawio-modal-close-btn", _.textContent = "✕", _.type = "button", _.addEventListener("click", () => p()), T.append(E, _), m = document.createElement("iframe"), m.className = "drawio-modal-iframe", m.setAttribute("frameborder", "0"), x.append(T, m), u.appendChild(x), document.body.appendChild(u);
1410
+ _.className = "drawio-modal-close-btn", _.textContent = "✕", _.type = "button", _.addEventListener("click", () => p()), T.append(E, _), m = document.createElement("iframe"), m.className = "drawio-modal-iframe", m.setAttribute("frameborder", "0"), w.append(T, m), u.appendChild(w), document.body.appendChild(u);
1411
1411
  const b = v === "en" ? "en" : "zh";
1412
1412
  m.src = `${Ve}/?embed=1&proto=json&spin=1&lang=${b}`;
1413
1413
  const C = m;
@@ -1440,23 +1440,23 @@ const Ie = () => {
1440
1440
  }, p = () => {
1441
1441
  a = !1, d && (window.removeEventListener("message", d), d = null), m && (m.src = "about:blank", m = null), u && (u.remove(), u = null), h();
1442
1442
  };
1443
- s.addEventListener("dblclick", (x) => {
1444
- x.preventDefault(), x.stopPropagation(), f();
1443
+ s.addEventListener("dblclick", (w) => {
1444
+ w.preventDefault(), w.stopPropagation(), f();
1445
1445
  });
1446
1446
  const h = () => {
1447
- const x = N.getState().editorLanguage, T = H(x), v = typeof r.attrs.svg == "string" ? r.attrs.svg : "";
1447
+ const w = N.getState().editorLanguage, T = H(w), v = typeof r.attrs.svg == "string" ? r.attrs.svg : "";
1448
1448
  v ? (o.src = v, o.style.display = "block") : (o.src = "", o.style.display = "none"), v ? (c.textContent = T.mermaidDoubleClickToEdit || "双击编辑", c.className = "drawio-view-hint drawio-view-hint--subtle") : (c.textContent = T.drawioDoubleClickToEdit || "双击编辑 Draw.io 图表", c.className = "drawio-view-hint drawio-view-hint--empty");
1449
1449
  };
1450
1450
  let y = N.getState().editorLanguage;
1451
- const w = N.subscribe((x) => {
1452
- x.editorLanguage !== y && (y = x.editorLanguage, h());
1451
+ const x = N.subscribe((w) => {
1452
+ w.editorLanguage !== y && (y = w.editorLanguage, h());
1453
1453
  });
1454
1454
  return h(), {
1455
1455
  dom: i,
1456
1456
  ignoreMutation: () => !0,
1457
- update: (x) => x.type.name !== "drawio" ? !1 : (r = x, h(), !0),
1457
+ update: (w) => w.type.name !== "drawio" ? !1 : (r = w, h(), !0),
1458
1458
  destroy: () => {
1459
- w(), d && (window.removeEventListener("message", d), d = null), m && (m.src = "about:blank", m = null), u && (u.remove(), u = null);
1459
+ x(), d && (window.removeEventListener("message", d), d = null), m && (m.src = "about:blank", m = null), u && (u.remove(), u = null);
1460
1460
  }
1461
1461
  };
1462
1462
  };
@@ -1511,8 +1511,8 @@ const Ie = () => {
1511
1511
  l.current({ latex: p }), s(!1), (y = globalThis.mathVirtualKeyboard) == null || y.hide({ animate: !0 });
1512
1512
  }, []);
1513
1513
  M(() => {
1514
- var h, y, w;
1515
- const p = !!((w = (y = (h = r == null ? void 0 : r.view) == null ? void 0 : h.state) == null ? void 0 : y.selection) != null && w.empty);
1514
+ var h, y, x;
1515
+ const p = !!((x = (y = (h = r == null ? void 0 : r.view) == null ? void 0 : h.state) == null ? void 0 : y.selection) != null && x.empty);
1516
1516
  n && p && u();
1517
1517
  }, [n, u]), M(() => {
1518
1518
  i && requestAnimationFrame(() => {
@@ -1526,13 +1526,13 @@ const Ie = () => {
1526
1526
  if (!p) return;
1527
1527
  const h = () => {
1528
1528
  setTimeout(() => {
1529
- var x, T, v;
1529
+ var w, T, v;
1530
1530
  if (!c.current) return;
1531
- const w = document.activeElement;
1532
- (w == null ? void 0 : w.tagName) === "MATH-FIELD" || (x = w == null ? void 0 : w.closest) != null && x.call(w, "math-field") || (T = w == null ? void 0 : w.closest) != null && T.call(w, ".ML__keyboard") || (v = document.querySelector(".ML__keyboard")) != null && v.contains(w) || m();
1531
+ const x = document.activeElement;
1532
+ (x == null ? void 0 : x.tagName) === "MATH-FIELD" || (w = x == null ? void 0 : x.closest) != null && w.call(x, "math-field") || (T = x == null ? void 0 : x.closest) != null && T.call(x, ".ML__keyboard") || (v = document.querySelector(".ML__keyboard")) != null && v.contains(x) || m();
1533
1533
  }, 300);
1534
- }, y = (w) => {
1535
- w.key === "Escape" && m();
1534
+ }, y = (x) => {
1535
+ x.key === "Escape" && m();
1536
1536
  };
1537
1537
  return p.addEventListener("focusout", h), p.addEventListener("keydown", y), () => {
1538
1538
  p.removeEventListener("focusout", h), p.removeEventListener("keydown", y);
@@ -1853,16 +1853,16 @@ const Le = () => {
1853
1853
  h.className = "figure-mermaid-view-hint", f.append(p, h);
1854
1854
  const y = document.createElement("div");
1855
1855
  y.className = "figure-mermaid-edit";
1856
- const w = document.createElement("textarea");
1857
- w.className = "figure-mermaid-editor", w.spellcheck = !1;
1858
- const x = document.createElement("div");
1859
- x.className = "figure-mermaid-toolbar";
1856
+ const x = document.createElement("textarea");
1857
+ x.className = "figure-mermaid-editor", x.spellcheck = !1;
1858
+ const w = document.createElement("div");
1859
+ w.className = "figure-mermaid-toolbar";
1860
1860
  const T = document.createElement("button");
1861
1861
  T.className = "figure-mermaid-save-btn", T.type = "button";
1862
1862
  const v = document.createElement("button");
1863
1863
  v.className = "figure-mermaid-cancel-btn", v.type = "button";
1864
1864
  const E = document.createElement("span");
1865
- E.className = "figure-mermaid-error-inline", x.append(E, v, T), y.append(w, x);
1865
+ E.className = "figure-mermaid-error-inline", w.append(E, v, T), y.append(x, w);
1866
1866
  const _ = document.createElement("div");
1867
1867
  _.className = "figure-drawio-view", _.contentEditable = "false";
1868
1868
  const b = document.createElement("img");
@@ -1898,11 +1898,11 @@ const Le = () => {
1898
1898
  l.classList.remove("figure-upload-area--dragover"), r.attrs.contentType === "image" && (S.preventDefault(), S.stopPropagation(), Q(((k = S.dataTransfer) == null ? void 0 : k.files) ?? null));
1899
1899
  });
1900
1900
  const gn = () => {
1901
- a || (a = !0, w.value = typeof r.attrs.mermaidCode == "string" ? r.attrs.mermaidCode : "", E.textContent = "", E.style.display = "none", J(), requestAnimationFrame(() => w.focus()));
1901
+ a || (a = !0, x.value = typeof r.attrs.mermaidCode == "string" ? r.attrs.mermaidCode : "", E.textContent = "", E.style.display = "none", J(), requestAnimationFrame(() => x.focus()));
1902
1902
  }, fn = () => {
1903
1903
  a = !1, J();
1904
1904
  }, pn = async () => {
1905
- const S = w.value;
1905
+ const S = x.value;
1906
1906
  E.textContent = "", E.style.display = "none";
1907
1907
  const k = S.trim();
1908
1908
  if (k)
@@ -1925,7 +1925,7 @@ const Le = () => {
1925
1925
  S.stopPropagation(), pn();
1926
1926
  }), v.addEventListener("click", (S) => {
1927
1927
  S.stopPropagation(), fn();
1928
- }), w.addEventListener("mousedown", (S) => S.stopPropagation()), w.addEventListener("keydown", (S) => S.stopPropagation()), w.addEventListener("keypress", (S) => S.stopPropagation());
1928
+ }), x.addEventListener("mousedown", (S) => S.stopPropagation()), x.addEventListener("keydown", (S) => S.stopPropagation()), x.addEventListener("keypress", (S) => S.stopPropagation());
1929
1929
  let ee = null, G = null, U = null;
1930
1930
  const hn = () => {
1931
1931
  if (i) return;
@@ -1974,7 +1974,7 @@ const Le = () => {
1974
1974
  S.preventDefault(), S.stopPropagation(), hn();
1975
1975
  }), s.addEventListener("mousedown", (S) => {
1976
1976
  const k = S.target;
1977
- if (!(k instanceof HTMLElement) || k === D || D.contains(k) || k === w || y.contains(k) || k === l || l.contains(k) || k === m || k === u || f.contains(k) || _.contains(k)) return;
1977
+ if (!(k instanceof HTMLElement) || k === D || D.contains(k) || k === x || y.contains(k) || k === l || l.contains(k) || k === m || k === u || f.contains(k) || _.contains(k)) return;
1978
1978
  const P = typeof n == "function" ? n() : null;
1979
1979
  if (typeof P != "number") return;
1980
1980
  const O = P + r.nodeSize - 1, R = Zn.create(e.state.doc, O);
@@ -2030,7 +2030,7 @@ const Le = () => {
2030
2030
  contentDOM: D,
2031
2031
  stopEvent: (S) => {
2032
2032
  const k = S.target;
2033
- return !!(k === w || y.contains(k) || k === u);
2033
+ return !!(k === x || y.contains(k) || k === u);
2034
2034
  },
2035
2035
  ignoreMutation: (S) => {
2036
2036
  const k = S.target;
@@ -2213,15 +2213,15 @@ const Le = () => {
2213
2213
  };
2214
2214
  s.addEventListener("click", d), o.addEventListener("focusin", l), o.addEventListener("click", l);
2215
2215
  const u = () => {
2216
- const h = N.getState(), y = H(h.editorLanguage), w = typeof y.bookTitle_description == "string" ? y.bookTitle_description : "说明书", x = typeof y.patentTitlePlaceholder == "string" ? y.patentTitlePlaceholder : "专利名称";
2217
- i.textContent = w;
2216
+ const h = N.getState(), y = H(h.editorLanguage), x = typeof y.bookTitle_description == "string" ? y.bookTitle_description : "说明书", w = typeof y.patentTitlePlaceholder == "string" ? y.patentTitlePlaceholder : "专利名称";
2217
+ i.textContent = x;
2218
2218
  const T = ot(r), v = h.rightPanel.activeSectionPos === c();
2219
- s.textContent = `[${x}]`, s.style.display = T ? "none" : "", s.classList.toggle("ps-placeholder--active", v && !T), o.classList.toggle("pt-title-content--has-content", T);
2219
+ s.textContent = `[${w}]`, s.style.display = T ? "none" : "", s.classList.toggle("ps-placeholder--active", v && !T), o.classList.toggle("pt-title-content--has-content", T);
2220
2220
  };
2221
2221
  let m = N.getState().editorLanguage, f = N.getState().rightPanel.activeSectionPos;
2222
2222
  const p = N.subscribe((h) => {
2223
- const y = h.editorLanguage !== m, w = h.rightPanel.activeSectionPos !== f;
2224
- m = h.editorLanguage, f = h.rightPanel.activeSectionPos, (y || w) && u();
2223
+ const y = h.editorLanguage !== m, x = h.rightPanel.activeSectionPos !== f;
2224
+ m = h.editorLanguage, f = h.rightPanel.activeSectionPos, (y || x) && u();
2225
2225
  });
2226
2226
  return u(), {
2227
2227
  dom: a,
@@ -2318,13 +2318,13 @@ const Le = () => {
2318
2318
  };
2319
2319
  o.addEventListener("click", u), c.addEventListener("focusin", d), c.addEventListener("click", d);
2320
2320
  const m = () => {
2321
- const y = N.getState(), w = H(y.editorLanguage), x = Object.keys(wt).includes(r.attrs.sectionType) ? r.attrs.sectionType : "technical_field", T = Ma.has(x), v = Fa.has(x), E = wt[x], _ = typeof w[E] == "string" ? w[E] : x, b = ot(r), C = y.rightPanel.activeSectionPos === l();
2322
- a.className = `ps${b ? "" : " ps--empty"}${v ? " ps--sub" : ""}`, a.setAttribute("data-section-type", x), i.className = T ? "pb-heading" : "ps-heading ps-heading--sub", i.textContent = _, o.textContent = `[${_}]`, o.style.display = b ? "none" : "", o.classList.toggle("ps-placeholder--active", C && !b), c.classList.toggle("ps-content--has-content", b);
2321
+ const y = N.getState(), x = H(y.editorLanguage), w = Object.keys(wt).includes(r.attrs.sectionType) ? r.attrs.sectionType : "technical_field", T = Ma.has(w), v = Fa.has(w), E = wt[w], _ = typeof x[E] == "string" ? x[E] : w, b = ot(r), C = y.rightPanel.activeSectionPos === l();
2322
+ a.className = `ps${b ? "" : " ps--empty"}${v ? " ps--sub" : ""}`, a.setAttribute("data-section-type", w), i.className = T ? "pb-heading" : "ps-heading ps-heading--sub", i.textContent = _, o.textContent = `[${_}]`, o.style.display = b ? "none" : "", o.classList.toggle("ps-placeholder--active", C && !b), c.classList.toggle("ps-content--has-content", b);
2323
2323
  };
2324
2324
  let f = N.getState().editorLanguage, p = N.getState().rightPanel.activeSectionPos;
2325
2325
  const h = N.subscribe((y) => {
2326
- const w = y.editorLanguage !== f, x = y.rightPanel.activeSectionPos !== p;
2327
- f = y.editorLanguage, p = y.rightPanel.activeSectionPos, (w || x) && m();
2326
+ const x = y.editorLanguage !== f, w = y.rightPanel.activeSectionPos !== p;
2327
+ f = y.editorLanguage, p = y.rightPanel.activeSectionPos, (x || w) && m();
2328
2328
  });
2329
2329
  return m(), {
2330
2330
  dom: a,
@@ -2589,7 +2589,7 @@ const Le = () => {
2589
2589
  }
2590
2590
  },
2591
2591
  onStateChange: (e) => {
2592
- Ga(e), Je(e);
2592
+ e.isDestroyed || (Ga(e), Je(e));
2593
2593
  }
2594
2594
  }, Ja = [xa, Ta, ka, Va];
2595
2595
  Ja.forEach((e) => B.register(e));
@@ -3032,7 +3032,7 @@ const Ka = (e = {}) => {
3032
3032
  d.execCommand(b.command);
3033
3033
  }
3034
3034
  };
3035
- }), h = [...m, ...p], y = h.map((b) => b.group).filter((b, C, I) => I.indexOf(b) === C && !t.includes(b)), x = [...t, ...y].map((b) => ({
3035
+ }), h = [...m, ...p], y = h.map((b) => b.group).filter((b, C, I) => I.indexOf(b) === C && !t.includes(b)), w = [...t, ...y].map((b) => ({
3036
3036
  group: b,
3037
3037
  items: h.filter((C) => C.group === b)
3038
3038
  })).filter((b) => b.items.length > 0), T = (b) => {
@@ -3089,7 +3089,7 @@ const Ka = (e = {}) => {
3089
3089
  }
3090
3090
  )
3091
3091
  ] }),
3092
- x.map((b) => {
3092
+ w.map((b) => {
3093
3093
  const C = a.has(b.group);
3094
3094
  return /* @__PURE__ */ L("div", { className: "flex items-center gap-1 pr-2 mr-2 border-r border-gray-200 last:border-r-0 last:mr-0 last:pr-0", children: [
3095
3095
  n && /* @__PURE__ */ g(
@@ -3122,9 +3122,9 @@ const Ka = (e = {}) => {
3122
3122
  const E = typeof v.attrs.id == "string" ? v.attrs.id.trim() : "";
3123
3123
  return E && c.push({ id: E, label: E }), !0;
3124
3124
  });
3125
- const l = o.findAncestorNode("figure"), d = !!l, u = l && typeof l.node.attrs.id == "string" ? l.node.attrs.id.trim() : "", m = l && typeof l.node.attrs.contentType == "string" ? l.node.attrs.contentType : "image", [f, p] = F(""), h = W(null), y = W(null), w = (l == null ? void 0 : l.pos) ?? null;
3126
- w !== y.current && (y.current = w, d && u !== f && p(u));
3127
- const x = (v) => {
3125
+ const l = o.findAncestorNode("figure"), d = !!l, u = l && typeof l.node.attrs.id == "string" ? l.node.attrs.id.trim() : "", m = l && typeof l.node.attrs.contentType == "string" ? l.node.attrs.contentType : "image", [f, p] = F(""), h = W(null), y = W(null), x = (l == null ? void 0 : l.pos) ?? null;
3126
+ x !== y.current && (y.current = x, d && u !== f && p(u));
3127
+ const w = (v) => {
3128
3128
  l && o.execCommand("patent.updateFigure", {
3129
3129
  position: l.pos,
3130
3130
  contentType: v
@@ -3191,7 +3191,7 @@ const Ka = (e = {}) => {
3191
3191
  "select",
3192
3192
  {
3193
3193
  value: m,
3194
- onChange: (v) => x(v.target.value),
3194
+ onChange: (v) => w(v.target.value),
3195
3195
  className: "text-xs border border-gray-200 rounded px-2 py-1 bg-white",
3196
3196
  children: [
3197
3197
  /* @__PURE__ */ g("option", { value: "image", children: s.figureContentTypeImage }),
@@ -3429,8 +3429,8 @@ const ni = ({ editor: e, onSelectionOptimize: t }) => {
3429
3429
  }
3430
3430
  );
3431
3431
  }, ri = ({ editor: e }) => {
3432
- var x;
3433
- const [t, n] = F(!1), [r, a] = F(!1), [i, s] = F(""), [o, c] = F(""), [l, d] = F(!1), u = W(null), m = e.extensionStorage.searchReplace, f = ((x = m == null ? void 0 : m.results) == null ? void 0 : x.length) ?? 0, p = (m == null ? void 0 : m.currentIndex) ?? -1;
3432
+ var w;
3433
+ const [t, n] = F(!1), [r, a] = F(!1), [i, s] = F(""), [o, c] = F(""), [l, d] = F(!1), u = W(null), m = e.extensionStorage.searchReplace, f = ((w = m == null ? void 0 : m.results) == null ? void 0 : w.length) ?? 0, p = (m == null ? void 0 : m.currentIndex) ?? -1;
3434
3434
  M(() => {
3435
3435
  const T = (v) => {
3436
3436
  n(!0);
@@ -3456,7 +3456,7 @@ const ni = ({ editor: e, onSelectionOptimize: t }) => {
3456
3456
  };
3457
3457
  return window.addEventListener("keydown", T), () => window.removeEventListener("keydown", T);
3458
3458
  }, [t, y]);
3459
- const w = () => {
3459
+ const x = () => {
3460
3460
  const T = !l;
3461
3461
  d(T), e.commands.setCaseSensitive(T);
3462
3462
  };
@@ -3482,7 +3482,7 @@ const ni = ({ editor: e, onSelectionOptimize: t }) => {
3482
3482
  /* @__PURE__ */ g(
3483
3483
  "button",
3484
3484
  {
3485
- onClick: w,
3485
+ onClick: x,
3486
3486
  className: Y("find-replace-btn", l && "find-replace-btn--active"),
3487
3487
  title: "Case Sensitive",
3488
3488
  children: /* @__PURE__ */ g(Ur, { size: 15 })
@@ -3584,12 +3584,12 @@ const ni = ({ editor: e, onSelectionOptimize: t }) => {
3584
3584
  }), !1;
3585
3585
  }
3586
3586
  if (d.type.name === "patent_section") {
3587
- const m = d.attrs.sectionType, f = oi.has(m), p = `sectionTitle_${m}`, h = typeof n[p] == "string" ? n[p] : m, y = d.textContent || "", w = y.trim().length > 0;
3587
+ const m = d.attrs.sectionType, f = oi.has(m), p = `sectionTitle_${m}`, h = typeof n[p] == "string" ? n[p] : m, y = d.textContent || "", x = y.trim().length > 0;
3588
3588
  return c.push({
3589
3589
  type: "section",
3590
3590
  pos: u,
3591
3591
  title: h,
3592
- state: w ? "filled" : "empty",
3592
+ state: x ? "filled" : "empty",
3593
3593
  charCount: y.replace(/\s/g, "").length,
3594
3594
  indent: f
3595
3595
  }), !1;
@@ -3697,20 +3697,20 @@ const ni = ({ editor: e, onSelectionOptimize: t }) => {
3697
3697
  content: [{ type: "text", text: "" }]
3698
3698
  }
3699
3699
  ]
3700
- }, w = ae((_) => {
3700
+ }, x = ae((_) => {
3701
3701
  try {
3702
3702
  f("saving"), localStorage.setItem(cn, JSON.stringify(_)), f("saved"), p(/* @__PURE__ */ new Date());
3703
3703
  } catch {
3704
3704
  f("error");
3705
3705
  }
3706
- }, [f, p]), x = Nn(
3706
+ }, [f, p]), w = Nn(
3707
3707
  Ka({
3708
3708
  extensions: [fa.configure({ editorId: o })],
3709
3709
  content: y,
3710
3710
  onUpdate: ({ editor: _ }) => {
3711
3711
  const b = _.getJSON();
3712
3712
  l(b), B.notifyStateChange(_), t && t(b), t || (h.current && clearTimeout(h.current), h.current = setTimeout(() => {
3713
- w(b);
3713
+ x(b);
3714
3714
  }, di));
3715
3715
  },
3716
3716
  onCreate: ({ editor: _ }) => {
@@ -3727,39 +3727,39 @@ const ni = ({ editor: e, onSelectionOptimize: t }) => {
3727
3727
  })
3728
3728
  ), T = W(!1);
3729
3729
  if (M(() => {
3730
- if (!(!x || !e)) {
3730
+ if (!(!w || !e)) {
3731
3731
  if (!T.current) {
3732
3732
  T.current = !0;
3733
3733
  return;
3734
3734
  }
3735
- x.commands.setContent(e);
3735
+ w.commands.setContent(e);
3736
3736
  }
3737
- }, [x, e]), M(() => () => {
3738
- h.current && clearTimeout(h.current), x && (B.destroyPlugins(x), x.destroy());
3739
- }, [x]), M(() => {
3740
- x && B.notifyStateChange(x);
3741
- }, [x, d]), !x)
3737
+ }, [w, e]), M(() => () => {
3738
+ h.current && clearTimeout(h.current), w && (c(null), B.destroyPlugins(w), w.destroy());
3739
+ }, [w, c]), M(() => {
3740
+ !w || w.isDestroyed || B.notifyStateChange(w);
3741
+ }, [w, d]), !w)
3742
3742
  return null;
3743
3743
  const v = H(d), E = u === "saving" ? v.autoSaveSaving : u === "saved" ? v.autoSaveSaved : u === "error" ? v.autoSaveError : "";
3744
3744
  return /* @__PURE__ */ L("div", { className: `editor-container flex flex-col h-full ${n}`, children: [
3745
3745
  !r && /* @__PURE__ */ L("div", { className: "flex items-center", children: [
3746
- /* @__PURE__ */ g(Za, { editor: x }),
3746
+ /* @__PURE__ */ g(Za, { editor: w }),
3747
3747
  E && /* @__PURE__ */ g("span", { className: `auto-save-indicator auto-save-indicator--${u} ml-2`, children: E })
3748
3748
  ] }),
3749
- !r && x && /* @__PURE__ */ g(Qa, { editor: x }),
3750
- !r && x && /* @__PURE__ */ g(ni, { editor: x, onSelectionOptimize: s }),
3751
- !r && x && /* @__PURE__ */ g(ri, { editor: x }),
3749
+ !r && w && /* @__PURE__ */ g(Qa, { editor: w }),
3750
+ !r && w && /* @__PURE__ */ g(ni, { editor: w, onSelectionOptimize: s }),
3751
+ !r && w && /* @__PURE__ */ g(ri, { editor: w }),
3752
3752
  /* @__PURE__ */ L("div", { className: "flex flex-1 overflow-hidden", children: [
3753
- !r && x && /* @__PURE__ */ g(ci, { editor: x }),
3753
+ !r && w && /* @__PURE__ */ g(ci, { editor: w }),
3754
3754
  /* @__PURE__ */ g("div", { className: "flex-1 overflow-y-auto bg-white p-4 relative", children: /* @__PURE__ */ g(
3755
3755
  li,
3756
3756
  {
3757
- editor: x,
3757
+ editor: w,
3758
3758
  mode: r || !a || m.status === "streaming" && m.activeSectionType === "claims" ? "readonly" : "edit"
3759
3759
  }
3760
3760
  ) })
3761
3761
  ] }),
3762
- !r && /* @__PURE__ */ g(ai, { editor: x })
3762
+ !r && /* @__PURE__ */ g(ai, { editor: w })
3763
3763
  ] });
3764
3764
  };
3765
3765
  function ln(e) {
@@ -3892,8 +3892,8 @@ function fi(e, t) {
3892
3892
  }
3893
3893
  const pi = It(
3894
3894
  ({ initialContent: e, patentType: t, onChange: n, className: r, readOnly: a = !1, editable: i = !0, language: s, aiService: o, chatSessionAPI: c, aiBaseUrl: l, aiHeaders: d, onSelectionOptimize: u, patchEditorId: m }, f) => {
3895
- const { setEditorLanguage: p, setAIService: h, setChatSessionAPI: y } = N(), w = W(null), x = ae((v) => {
3896
- w.current = v;
3895
+ const { setEditorLanguage: p, setAIService: h, setChatSessionAPI: y } = N(), x = W(null), w = ae((v) => {
3896
+ x.current = v;
3897
3897
  }, []), T = Ee.useMemo(() => {
3898
3898
  if (e) return e;
3899
3899
  if (t) return tn(t);
@@ -3907,24 +3907,24 @@ const pi = It(
3907
3907
  }, [c, l, d, y]), Nt(f, () => ({
3908
3908
  getContent: () => {
3909
3909
  var v;
3910
- return ((v = w.current) == null ? void 0 : v.getJSON()) ?? null;
3910
+ return ((v = x.current) == null ? void 0 : v.getJSON()) ?? null;
3911
3911
  },
3912
3912
  setContent: (v) => {
3913
3913
  var E;
3914
- (E = w.current) == null || E.commands.setContent(v);
3914
+ (E = x.current) == null || E.commands.setContent(v);
3915
3915
  },
3916
- getEditor: () => w.current,
3917
- execCommand: async (v, E) => w.current ? ct(w.current).execCommand(v, E) : null,
3916
+ getEditor: () => x.current,
3917
+ execCommand: async (v, E) => x.current ? ct(x.current).execCommand(v, E) : null,
3918
3918
  focus: () => {
3919
3919
  var v;
3920
- (v = w.current) == null || v.commands.focus();
3920
+ (v = x.current) == null || v.commands.focus();
3921
3921
  }
3922
3922
  })), /* @__PURE__ */ g(
3923
3923
  mi,
3924
3924
  {
3925
3925
  initialContent: T,
3926
3926
  onChange: n,
3927
- onEditorReady: x,
3927
+ onEditorReady: w,
3928
3928
  className: r,
3929
3929
  readOnly: a,
3930
3930
  editable: i,
@@ -3970,14 +3970,14 @@ async function js(e, t, n, r) {
3970
3970
  const p = (s = f.body) == null ? void 0 : s.getReader();
3971
3971
  if (!p) throw new Error("No response body");
3972
3972
  const h = new TextDecoder();
3973
- let y = dn(e, r), w = "";
3973
+ let y = dn(e, r), x = "";
3974
3974
  for (; ; ) {
3975
- const { done: x, value: T } = await p.read();
3976
- if (x) break;
3977
- w += h.decode(T, { stream: !0 });
3978
- const v = w.split(`
3975
+ const { done: w, value: T } = await p.read();
3976
+ if (w) break;
3977
+ x += h.decode(T, { stream: !0 });
3978
+ const v = x.split(`
3979
3979
  `);
3980
- w = v.pop() || "";
3980
+ x = v.pop() || "";
3981
3981
  for (const E of v) {
3982
3982
  if (!E.startsWith("data: ")) continue;
3983
3983
  const _ = E.slice(6).trim();
@@ -4413,11 +4413,11 @@ function Ks(e, t) {
4413
4413
  if (p >= f.length) break;
4414
4414
  const h = p;
4415
4415
  for (; p < f.length && f[p] !== "\0"; ) p++;
4416
- const y = ye(i, l + h), w = ye(i, l + p);
4417
- if (y >= 0 && w >= 0 && w > y)
4418
- for (const x of Si(n, y, w))
4416
+ const y = ye(i, l + h), x = ye(i, l + p);
4417
+ if (y >= 0 && x >= 0 && x > y)
4418
+ for (const w of Si(n, y, x))
4419
4419
  c.push(
4420
- re.inline(x.from, x.to, { class: "patch-diff-insert-inline" })
4420
+ re.inline(w.from, w.to, { class: "patch-diff-insert-inline" })
4421
4421
  );
4422
4422
  }
4423
4423
  l += f.length;