@markweave/react 0.7.3 → 0.7.4

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
@@ -2,14 +2,14 @@ import { createMarkweaveEditorExtensions as e } from "markweave/internal/editor-
2
2
  import { getMarkweaveMessages as t, normalizeMarkweaveLang as n } from "markweave/internal/i18n";
3
3
  import { createMarkweaveAdapterMediaExtensions as r } from "markweave/internal/plugins/media/media-extension-factory";
4
4
  import { EditorContent as i, NodeViewWrapper as a, ReactNodeViewRenderer as o, useCurrentEditor as s, useEditor as c } from "@tiptap/react";
5
- import { AlertTriangle as l, AlignCenter as u, AlignJustify as d, AlignLeft as f, AlignRight as p, AlignVerticalJustifyCenter as m, AlignVerticalJustifyEnd as h, AlignVerticalJustifyStart as g, ArrowDown as _, ArrowDownAZ as v, ArrowLeft as y, ArrowRight as b, ArrowUp as x, ArrowUpZA as S, BetweenHorizontalEnd as C, BetweenHorizontalStart as w, BetweenVerticalEnd as T, BetweenVerticalStart as E, Bold as D, Braces as O, Captions as k, Check as A, CheckCircle2 as j, ChevronDown as ee, ChevronRight as M, ChevronUp as te, CircleX as ne, Code2 as re, Copy as ie, CornerDownLeft as ae, Download as N, ExternalLink as P, Eye as oe, Heading1 as se, Heading2 as F, Heading3 as I, Image as L, ImageUp as R, IndentDecrease as z, IndentIncrease as ce, Info as le, Italic as ue, Lightbulb as de, Link2 as fe, List as B, ListChecks as V, ListOrdered as H, Minus as pe, MoreVertical as me, PaintBucket as he, Paperclip as ge, Pencil as _e, Plus as ve, Quote as ye, Replace as be, RotateCcw as xe, Sigma as Se, SmilePlus as Ce, Sparkles as we, Square as U, SquareX as Te, Strikethrough as Ee, Subscript as De, Superscript as Oe, Table2 as ke, TableCellsMerge as Ae, TableCellsSplit as je, Text as Me, Trash2 as Ne, Type as Pe, Underline as Fe, Upload as Ie, Video as Le, X as Re } from "lucide-react";
5
+ import { AlertTriangle as l, AlignCenter as u, AlignJustify as d, AlignLeft as f, AlignRight as p, AlignVerticalJustifyCenter as m, AlignVerticalJustifyEnd as h, AlignVerticalJustifyStart as g, ArrowDown as _, ArrowDownAZ as v, ArrowLeft as y, ArrowRight as b, ArrowUp as x, ArrowUpZA as S, BetweenHorizontalEnd as C, BetweenHorizontalStart as w, BetweenVerticalEnd as T, BetweenVerticalStart as E, Bold as D, Braces as O, Captions as k, Check as A, CheckCircle2 as j, ChevronDown as M, ChevronRight as N, ChevronUp as ee, CircleX as P, Code2 as te, Copy as ne, CornerDownLeft as re, Download as F, ExternalLink as I, Eye as ie, Heading1 as ae, Heading2 as L, Heading3 as oe, Image as R, ImageUp as z, IndentDecrease as B, IndentIncrease as se, Info as ce, Italic as le, Lightbulb as ue, Link2 as de, List as V, ListChecks as fe, ListOrdered as H, Minus as pe, MoreVertical as me, PaintBucket as he, Paperclip as ge, Pencil as _e, Plus as ve, Quote as ye, Replace as be, RotateCcw as xe, Sigma as Se, SmilePlus as Ce, Sparkles as we, Square as Te, SquareX as Ee, Strikethrough as De, Subscript as Oe, Superscript as ke, Table2 as Ae, TableCellsMerge as je, TableCellsSplit as Me, Text as Ne, Trash2 as U, Type as Pe, Underline as Fe, Upload as Ie, Video as Le, X as Re } from "lucide-react";
6
6
  import ze, { useCallback as W, useEffect as G, useLayoutEffect as Be, useMemo as K, useRef as q, useState as J, useSyncExternalStore as Ve } from "react";
7
7
  import { getMarkweaveEditorModeState as He, isMarkweaveEditorLiveEditable as Ue, normalizeMarkweaveEditorMode as We, setMarkweaveEditorModeState as Ge, subscribeToMarkweaveEditorMode as Ke } from "markweave/internal/core/editor-mode-state";
8
8
  import { activateMarkweaveAttachmentDownload as qe, attrsFromMarkweaveAttachmentUploadResult as Je, createMarkweaveAttachmentRefFromAttrs as Ye, createMarkweaveAttachmentUploadRequest as Xe, formatMarkweaveAttachmentSize as Ze } from "markweave/internal/plugins/media/attachment-download";
9
- import { MarkweaveCoreImage as Qe, MarkweaveCoreVideo as $e, attrsFromMarkweaveImageUploadResult as et, attrsFromMarkweaveVideoUploadResult as tt, attrsFromMarkweaveVideoUrl as nt, clampMarkweaveImageWidth as rt, createMarkweaveImageUploadRequest as it, createMarkweaveVideoUploadRequest as Y, downloadMarkweaveImage as at, markweaveVideoIframeAllow as ot, normalizeMarkweaveCoreImageAlign as st, normalizeMarkweaveVideoEmbedUrl as ct, numberAttribute as lt, stringAttribute as ut } from "markweave/internal/plugins/media/core-media-nodes";
9
+ import { MarkweaveCoreImage as Qe, MarkweaveCoreVideo as $e, attrsFromMarkweaveImageUploadResult as et, attrsFromMarkweaveVideoUploadResult as tt, attrsFromMarkweaveVideoUrl as nt, clampMarkweaveImageWidth as rt, createMarkweaveImageUploadRequest as it, createMarkweaveVideoUploadRequest as at, downloadMarkweaveImage as ot, markweaveVideoIframeAllow as st, normalizeMarkweaveCoreImageAlign as ct, normalizeMarkweaveVideoEmbedUrl as lt, numberAttribute as ut, stringAttribute as Y } from "markweave/internal/plugins/media/core-media-nodes";
10
10
  import { MarkweaveAttachment as dt } from "markweave/internal/plugins/media/media-nodes";
11
- import { detectUploadSource as ft, getDirectUploadResult as pt, resolveMarkweaveUploadResult as mt } from "markweave/internal/plugins/slash-command/upload";
12
- import { Fragment as X, jsx as Z, jsxs as Q } from "react/jsx-runtime";
11
+ import { detectUploadSource as ft, getDirectUploadResult as pt, resolveMarkweaveUploadResult as X } from "markweave/internal/plugins/slash-command/upload";
12
+ import { Fragment as mt, jsx as Z, jsxs as Q } from "react/jsx-runtime";
13
13
  import { openMarkweaveImagePreview as ht } from "markweave/internal/plugins/media/image-preview";
14
14
  import { createMarkweaveLightweightImageNodeViewRenderer as gt } from "markweave/internal/plugins/media/lightweight-image-node-view";
15
15
  import { resolveMarkweaveMediaSource as _t } from "markweave/internal/plugins/media/media-source";
@@ -80,13 +80,13 @@ function aa(e) {
80
80
  !d || ra(e.target) || (e.preventDefault(), k());
81
81
  }, j = (e) => {
82
82
  d && s && (e.key === "Delete" || e.key === "Backspace") && (e.preventDefault(), n());
83
- }, ee = () => {
83
+ }, M = () => {
84
84
  !d || g || p.current?.click();
85
- }, M = async (e) => {
85
+ }, N = async (e) => {
86
86
  if (!(!d || !e || g)) {
87
87
  y(null), _(!0), x(e.name), C(e.size), T(null);
88
88
  try {
89
- let t = await mt({
89
+ let t = await X({
90
90
  ...Xe({
91
91
  type: "file",
92
92
  file: e,
@@ -103,12 +103,12 @@ function aa(e) {
103
103
  _(!1), x(null), C(null), T(null), p.current && (p.current.value = "");
104
104
  }
105
105
  }
106
- }, te = (e) => {
107
- M(e.currentTarget.files?.[0] ?? null);
108
- }, ne = (e) => {
106
+ }, ee = (e) => {
107
+ N(e.currentTarget.files?.[0] ?? null);
108
+ }, P = (e) => {
109
109
  if (!ra(e.target)) {
110
110
  if (e.preventDefault(), e.stopPropagation(), E) {
111
- ee();
111
+ M();
112
112
  return;
113
113
  }
114
114
  f && qe(f, {
@@ -116,14 +116,14 @@ function aa(e) {
116
116
  event: e.nativeEvent
117
117
  }, l.onDownload);
118
118
  }
119
- }, re = (e) => {
119
+ }, te = (e) => {
120
120
  e.preventDefault(), e.stopPropagation(), f && qe(f, {
121
121
  mode: He(r).mode,
122
122
  event: e.nativeEvent
123
123
  }, l.onDownload);
124
- }, ie = (e) => {
124
+ }, ne = (e) => {
125
125
  e.preventDefault(), e.stopPropagation(), n();
126
- }, ae = f?.name ?? ut(o.attrs.src) ?? u.missingSrc, P = [ut(o.attrs.mimeType), Ze(typeof o.attrs.size == "number" ? o.attrs.size : null)].filter(Boolean), oe = [Ze(S), w === null ? null : `${w}%`].filter(Boolean).join(" · ");
126
+ }, re = f?.name ?? Y(o.attrs.src) ?? u.missingSrc, I = [Y(o.attrs.mimeType), Ze(typeof o.attrs.size == "number" ? o.attrs.size : null)].filter(Boolean), ie = [Ze(S), w === null ? null : `${w}%`].filter(Boolean).join(" · ");
127
127
  return E ? /* @__PURE__ */ Q(a, {
128
128
  as: "div",
129
129
  className: "markweave-attachment markweave-attachment-upload-placeholder",
@@ -139,7 +139,7 @@ function aa(e) {
139
139
  "data-testid": "markweave-attachment-file-input",
140
140
  type: "file",
141
141
  hidden: !0,
142
- onChange: te
142
+ onChange: ee
143
143
  }), /* @__PURE__ */ Q("button", {
144
144
  type: "button",
145
145
  className: "markweave-attachment-upload-trigger",
@@ -147,7 +147,7 @@ function aa(e) {
147
147
  "data-testid": "markweave-attachment-upload-trigger",
148
148
  "aria-label": u.uploadLabel,
149
149
  onMouseDown: (e) => e.preventDefault(),
150
- onClick: ee,
150
+ onClick: M,
151
151
  children: [
152
152
  /* @__PURE__ */ Z("span", {
153
153
  className: "markweave-attachment-icon",
@@ -198,7 +198,7 @@ function aa(e) {
198
198
  children: [/* @__PURE__ */ Z("span", {
199
199
  className: "markweave-attachment-spinner",
200
200
  "aria-hidden": "true"
201
- }), oe || u.uploading]
201
+ }), ie || u.uploading]
202
202
  })]
203
203
  })]
204
204
  }) : /* @__PURE__ */ Q(a, {
@@ -214,7 +214,7 @@ function aa(e) {
214
214
  onMouseLeave: () => h(!1),
215
215
  onMouseDown: A,
216
216
  onKeyDown: j,
217
- onClick: ne,
217
+ onClick: P,
218
218
  children: [
219
219
  /* @__PURE__ */ Z("span", {
220
220
  className: "markweave-attachment-icon",
@@ -228,10 +228,10 @@ function aa(e) {
228
228
  className: "markweave-attachment-body",
229
229
  children: [/* @__PURE__ */ Z("span", {
230
230
  className: "markweave-attachment-name",
231
- children: ae
232
- }), P.length > 0 ? /* @__PURE__ */ Z("span", {
231
+ children: re
232
+ }), I.length > 0 ? /* @__PURE__ */ Z("span", {
233
233
  className: "markweave-attachment-meta",
234
- children: P.join(" · ")
234
+ children: I.join(" · ")
235
235
  }) : null]
236
236
  }),
237
237
  O ? /* @__PURE__ */ Q("span", {
@@ -244,8 +244,8 @@ function aa(e) {
244
244
  "data-testid": "markweave-attachment-download",
245
245
  "aria-label": u.downloadAriaLabel,
246
246
  onMouseDown: (e) => e.preventDefault(),
247
- onClick: re,
248
- children: [/* @__PURE__ */ Z(N, {
247
+ onClick: te,
248
+ children: [/* @__PURE__ */ Z(F, {
249
249
  size: 16,
250
250
  strokeWidth: 1.8
251
251
  }), /* @__PURE__ */ Z("span", {
@@ -260,8 +260,8 @@ function aa(e) {
260
260
  "data-testid": "markweave-attachment-delete",
261
261
  "aria-label": u.deleteAriaLabel,
262
262
  onMouseDown: (e) => e.preventDefault(),
263
- onClick: ie,
264
- children: [/* @__PURE__ */ Z(Ne, {
263
+ onClick: ne,
264
+ children: [/* @__PURE__ */ Z(U, {
265
265
  size: 16,
266
266
  strokeWidth: 1.8
267
267
  }), /* @__PURE__ */ Z("span", {
@@ -287,15 +287,15 @@ var oa = dt.extend({
287
287
  addNodeView() {
288
288
  return typeof document > "u" ? null : o(aa, { stopEvent: ({ event: e }) => ra(e.target) });
289
289
  }
290
- }), sa = st;
290
+ }), sa = ct;
291
291
  function ca(e) {
292
292
  return e instanceof Element && !!e.closest("[data-markweave-image-ui=\"true\"]");
293
293
  }
294
294
  function la(e) {
295
- let { deleteNode: n, editor: r, getPos: i, node: o, selected: s, updateAttributes: c } = e, l = e.extension.options, u = l.messages ?? t("zh"), d = u.image, f = Ue(na(r)), p = ut(o.attrs.src), m = sa(o.attrs.align), h = lt(o.attrs.width), g = ut(o.attrs.caption), _ = q(null), v = ha(p, l.resolveMediaSource, _, s), y = v?.src ?? (l.resolveMediaSource ? null : p), b = q(null), [x, S] = J(!1), [C, w] = J(!1), [T, E] = J(!1), [D, O] = J(""), [k, A] = J(null), [j, ee] = J(!1), [M, te] = J(!!g), [ne, re] = J(g ?? ""), ie = f && (!p || C), ae = () => {
295
+ let { deleteNode: n, editor: r, getPos: i, node: o, selected: s, updateAttributes: c } = e, l = e.extension.options, u = l.messages ?? t("zh"), d = u.image, f = Ue(na(r)), p = Y(o.attrs.src), m = sa(o.attrs.align), h = ut(o.attrs.width), g = Y(o.attrs.caption), _ = q(null), v = ha(p, l.resolveMediaSource, _, s), y = v?.src ?? (l.resolveMediaSource ? null : p), b = q(null), [x, S] = J(!1), [C, w] = J(!1), [T, E] = J(!1), [D, O] = J(""), [k, A] = J(null), [j, M] = J(!1), [N, ee] = J(!!g), [P, te] = J(g ?? ""), ne = f && (!p || C), re = () => {
296
296
  y && ht({
297
297
  src: y,
298
- alt: ut(o.attrs.alt) ?? "",
298
+ alt: Y(o.attrs.alt) ?? "",
299
299
  messages: {
300
300
  dialogAriaLabel: d.previewDialogAriaLabel,
301
301
  zoomOut: d.previewZoomOut,
@@ -306,13 +306,13 @@ function la(e) {
306
306
  });
307
307
  };
308
308
  G(() => {
309
- M || re(g ?? "");
310
- }, [g, M]);
311
- let N = () => {
309
+ N || te(g ?? "");
310
+ }, [g, N]);
311
+ let F = () => {
312
312
  if (!f) return;
313
313
  let e = i();
314
314
  typeof e == "number" && r.chain().focus().setNodeSelection(e).run();
315
- }, P = () => {
315
+ }, I = () => {
316
316
  if (f) {
317
317
  if (O(""), A(null), E(!1), p) {
318
318
  w(!1);
@@ -320,43 +320,43 @@ function la(e) {
320
320
  }
321
321
  n();
322
322
  }
323
- }, se = async (e) => {
323
+ }, ae = async (e) => {
324
324
  if (f) {
325
- A(null), ee(!0);
325
+ A(null), M(!0);
326
326
  try {
327
- let t = await mt(it(e, p && C ? "image-replace" : "image-insert"), l.onUpload);
327
+ let t = await X(it(e, p && C ? "image-replace" : "image-insert"), l.onUpload);
328
328
  c(et(o.attrs, t)), w(!1), O("");
329
329
  } catch (e) {
330
330
  A(e instanceof Error ? e.message : d.uploadFailedError);
331
331
  } finally {
332
- ee(!1), E(!1);
332
+ M(!1), E(!1);
333
333
  }
334
334
  }
335
- }, F = () => {
335
+ }, L = () => {
336
336
  if (f) {
337
337
  if (!D.trim()) {
338
338
  A(d.uploadRequiredError);
339
339
  return;
340
340
  }
341
- se(ft(D));
341
+ ae(ft(D));
342
342
  }
343
- }, I = (e) => {
344
- !f || !e || se({
343
+ }, oe = (e) => {
344
+ !f || !e || ae({
345
345
  type: "file",
346
346
  file: e,
347
347
  mimeType: e.type
348
348
  });
349
- }, L = (e) => {
350
- I(e.currentTarget.files?.[0] ?? null), e.currentTarget.value = "";
351
349
  }, R = (e) => {
352
- e.preventDefault(), e.stopPropagation(), f && I(e.dataTransfer.files?.[0] ?? null);
353
- }, z = () => {
354
- f && (te((e) => !e), M || re(g ?? ""));
355
- }, ce = (e) => {
356
- f && (re(e), c({ caption: e.trim() ? e : null }));
357
- }, le = (e, t) => {
350
+ oe(e.currentTarget.files?.[0] ?? null), e.currentTarget.value = "";
351
+ }, z = (e) => {
352
+ e.preventDefault(), e.stopPropagation(), f && oe(e.dataTransfer.files?.[0] ?? null);
353
+ }, B = () => {
354
+ f && (ee((e) => !e), N || te(g ?? ""));
355
+ }, se = (e) => {
356
+ f && (te(e), c({ caption: e.trim() ? e : null }));
357
+ }, ce = (e, t) => {
358
358
  if (t.preventDefault(), t.stopPropagation(), !f) return;
359
- N();
359
+ F();
360
360
  let n = _.current;
361
361
  if (!n) return;
362
362
  let r = t.clientX, i = n.getBoundingClientRect().width || h || 320, a = n.closest(".markweave-editor-surface")?.getBoundingClientRect().width ?? n.parentElement?.getBoundingClientRect().width ?? i, o = (t) => {
@@ -374,37 +374,37 @@ function la(e) {
374
374
  "data-align": m,
375
375
  "data-selected": f && s ? "true" : "false",
376
376
  "data-hovered": x ? "true" : "false",
377
- "data-empty": ie ? "true" : "false",
377
+ "data-empty": ne ? "true" : "false",
378
378
  onPointerEnter: () => S(!0),
379
379
  onPointerLeave: () => S(!1),
380
380
  onMouseDown: (e) => {
381
- f && !ca(e.target) && N();
381
+ f && !ca(e.target) && F();
382
382
  },
383
- children: ie ? /* @__PURE__ */ Z(ua, {
383
+ children: ne ? /* @__PURE__ */ Z(ua, {
384
384
  dragActive: T,
385
385
  error: k,
386
386
  inputValue: D,
387
387
  isSubmitting: j,
388
388
  fileInputRef: b,
389
389
  messages: u,
390
- onCancel: P,
391
- onDrop: R,
390
+ onCancel: I,
391
+ onDrop: z,
392
392
  onDragActiveChange: E,
393
- onFileChange: L,
393
+ onFileChange: R,
394
394
  onInputChange: O,
395
- onSubmit: F
396
- }) : /* @__PURE__ */ Q(X, { children: [
395
+ onSubmit: L
396
+ }) : /* @__PURE__ */ Q(mt, { children: [
397
397
  f ? /* @__PURE__ */ Z(da, {
398
398
  align: m,
399
- captionActive: M || !!g,
399
+ captionActive: N || !!g,
400
400
  messages: u,
401
401
  onAlign: (e) => c({ align: e }),
402
- onCaption: z,
402
+ onCaption: B,
403
403
  onDelete: n,
404
404
  onDownload: () => {
405
- y && at(y);
405
+ y && ot(y);
406
406
  },
407
- onPreview: ae,
407
+ onPreview: re,
408
408
  onReplace: () => {
409
409
  O(""), A(null), w(!0);
410
410
  }
@@ -420,8 +420,8 @@ function la(e) {
420
420
  y ? /* @__PURE__ */ Z("img", {
421
421
  className: "markweave-image",
422
422
  src: y,
423
- alt: ut(o.attrs.alt) ?? "",
424
- title: ut(o.attrs.title) ?? void 0,
423
+ alt: Y(o.attrs.alt) ?? "",
424
+ title: Y(o.attrs.title) ?? void 0,
425
425
  draggable: !1,
426
426
  loading: "lazy",
427
427
  decoding: "async",
@@ -440,8 +440,8 @@ function la(e) {
440
440
  "aria-label": d.preview,
441
441
  title: d.preview,
442
442
  onMouseDown: (e) => e.preventDefault(),
443
- onClick: ae,
444
- children: [/* @__PURE__ */ Z(oe, {
443
+ onClick: re,
444
+ children: [/* @__PURE__ */ Z(ie, {
445
445
  size: 16,
446
446
  strokeWidth: 1.8
447
447
  }), /* @__PURE__ */ Z("span", {
@@ -453,25 +453,25 @@ function la(e) {
453
453
  f ? /* @__PURE__ */ Z(pa, {
454
454
  side: "left",
455
455
  messages: u,
456
- onPointerDown: le
456
+ onPointerDown: ce
457
457
  }) : null,
458
458
  f ? /* @__PURE__ */ Z(pa, {
459
459
  side: "right",
460
460
  messages: u,
461
- onPointerDown: le
461
+ onPointerDown: ce
462
462
  }) : null
463
463
  ]
464
464
  }),
465
- f && (M || g) ? /* @__PURE__ */ Z("input", {
465
+ f && (N || g) ? /* @__PURE__ */ Z("input", {
466
466
  className: "markweave-image-caption-input",
467
467
  "data-markweave-image-ui": "true",
468
468
  "data-testid": "markweave-image-caption-input",
469
- value: ne,
469
+ value: P,
470
470
  placeholder: d.captionPlaceholder,
471
471
  "aria-label": d.captionAriaLabel,
472
- onChange: (e) => ce(e.currentTarget.value),
472
+ onChange: (e) => se(e.currentTarget.value),
473
473
  onKeyDown: (e) => {
474
- e.key === "Escape" && (e.preventDefault(), te(!1));
474
+ e.key === "Escape" && (e.preventDefault(), ee(!1));
475
475
  }
476
476
  }) : g ? /* @__PURE__ */ Z("figcaption", {
477
477
  className: "markweave-image-caption",
@@ -516,7 +516,7 @@ function ua({ dragActive: e, error: t, fileInputRef: n, inputValue: r, isSubmitt
516
516
  /* @__PURE__ */ Z("span", {
517
517
  className: "markweave-image-upload-icon",
518
518
  "aria-hidden": "true",
519
- children: /* @__PURE__ */ Z(R, {
519
+ children: /* @__PURE__ */ Z(z, {
520
520
  size: 16,
521
521
  strokeWidth: 1.8
522
522
  })
@@ -550,7 +550,7 @@ function ua({ dragActive: e, error: t, fileInputRef: n, inputValue: r, isSubmitt
550
550
  "data-testid": "markweave-image-upload-submit",
551
551
  disabled: i || !r.trim(),
552
552
  onClick: d,
553
- children: [/* @__PURE__ */ Z(R, {
553
+ children: [/* @__PURE__ */ Z(z, {
554
554
  size: 16,
555
555
  strokeWidth: 1.8
556
556
  }), a.common.insert]
@@ -613,13 +613,13 @@ function da({ align: e, captionActive: t, messages: n, onAlign: r, onCaption: i,
613
613
  /* @__PURE__ */ Z(fa, {
614
614
  testId: "markweave-image-preview",
615
615
  label: l.preview,
616
- icon: oe,
616
+ icon: ie,
617
617
  onClick: s
618
618
  }),
619
619
  /* @__PURE__ */ Z(fa, {
620
620
  testId: "markweave-image-download",
621
621
  label: l.download,
622
- icon: N,
622
+ icon: F,
623
623
  onClick: o
624
624
  }),
625
625
  /* @__PURE__ */ Z(fa, {
@@ -635,7 +635,7 @@ function da({ align: e, captionActive: t, messages: n, onAlign: r, onCaption: i,
635
635
  /* @__PURE__ */ Z(fa, {
636
636
  testId: "markweave-image-delete",
637
637
  label: l.delete,
638
- icon: Ne,
638
+ icon: U,
639
639
  onClick: a
640
640
  })
641
641
  ]
@@ -689,7 +689,7 @@ var ma = Qe.extend({
689
689
  onUpload: this.options.onUpload,
690
690
  resolveMediaSource: n
691
691
  });
692
- return (t) => ut(t.node.attrs.src) ? r(t) : e(t);
692
+ return (t) => Y(t.node.attrs.src) ? r(t) : e(t);
693
693
  }
694
694
  });
695
695
  function ha(e, t, n, r) {
@@ -742,7 +742,7 @@ function ga(e) {
742
742
  return e instanceof Element && !!e.closest("[data-markweave-video-ui=\"true\"], iframe[data-markweave-video-embed], video[data-markweave-video]");
743
743
  }
744
744
  function _a(e) {
745
- let { deleteNode: n, editor: r, getPos: i, node: o, selected: s, updateAttributes: c } = e, l = e.extension.options, u = l.messages ?? t("zh"), d = u.video, f = Ue(na(r)), p = ut(o.attrs.src), m = ut(o.attrs.embedUrl), h = ut(o.attrs.provider), g = m ? ct(m, h) : null, _ = ut(o.attrs.mimeType), v = ut(o.attrs.title), y = q(null), [b, x] = J(!1), [S, C] = J(""), [w, T] = J(null), [E, D] = J(!1), O = f && !p, k = () => {
745
+ let { deleteNode: n, editor: r, getPos: i, node: o, selected: s, updateAttributes: c } = e, l = e.extension.options, u = l.messages ?? t("zh"), d = u.video, f = Ue(na(r)), p = Y(o.attrs.src), m = Y(o.attrs.embedUrl), h = Y(o.attrs.provider), g = m ? lt(m, h) : null, _ = Y(o.attrs.mimeType), v = Y(o.attrs.title), y = q(null), [b, x] = J(!1), [S, C] = J(""), [w, T] = J(null), [E, D] = J(!1), O = f && !p, k = () => {
746
746
  if (!f) return;
747
747
  let e = i();
748
748
  typeof e == "number" && r.chain().focus().setNodeSelection(e).run();
@@ -750,11 +750,11 @@ function _a(e) {
750
750
  f && (ga(e.target) || (e.preventDefault(), k()));
751
751
  }, j = (e) => {
752
752
  f && (e.key === "Delete" || e.key === "Backspace") && s && (e.preventDefault(), n());
753
- }, ee = async (e) => {
753
+ }, M = async (e) => {
754
754
  if (!(!f || !e)) {
755
755
  T(null), D(!0);
756
756
  try {
757
- let t = await mt(Y({
757
+ let t = await X(at({
758
758
  type: "file",
759
759
  file: e,
760
760
  mimeType: e.type
@@ -783,10 +783,10 @@ function _a(e) {
783
783
  onCancel: n,
784
784
  onDragActiveChange: x,
785
785
  onDrop: (e) => {
786
- e.preventDefault(), e.stopPropagation(), f && ee(e.dataTransfer.files?.[0] ?? null);
786
+ e.preventDefault(), e.stopPropagation(), f && M(e.dataTransfer.files?.[0] ?? null);
787
787
  },
788
788
  onFileChange: (e) => {
789
- ee(e.currentTarget.files?.[0] ?? null), e.currentTarget.value = "";
789
+ M(e.currentTarget.files?.[0] ?? null), e.currentTarget.value = "";
790
790
  },
791
791
  onInputChange: C,
792
792
  onSubmit: () => {
@@ -820,7 +820,7 @@ function _a(e) {
820
820
  "data-markweave-video-embed": "true",
821
821
  "data-markweave-video-provider": h ?? void 0,
822
822
  "data-markweave-video-src": p ?? void 0,
823
- allow: ot,
823
+ allow: st,
824
824
  loading: "lazy",
825
825
  allowFullScreen: !0
826
826
  }), f ? /* @__PURE__ */ Z("button", {
@@ -1058,13 +1058,13 @@ function wa(e) {
1058
1058
  children: [
1059
1059
  /* @__PURE__ */ Z(Ta, {
1060
1060
  label: u.convertToLink,
1061
- icon: fe,
1061
+ icon: de,
1062
1062
  onClick: T,
1063
1063
  testId: "markweave-link-card-convert"
1064
1064
  }),
1065
1065
  /* @__PURE__ */ Z(Ta, {
1066
1066
  label: u.copyAddress,
1067
- icon: ie,
1067
+ icon: ne,
1068
1068
  onClick: () => void xa(f.href),
1069
1069
  testId: "markweave-link-card-copy"
1070
1070
  }),
@@ -1088,7 +1088,7 @@ function wa(e) {
1088
1088
  }),
1089
1089
  /* @__PURE__ */ Z(Ta, {
1090
1090
  label: u.delete,
1091
- icon: Ne,
1091
+ icon: U,
1092
1092
  onClick: n,
1093
1093
  testId: "markweave-link-card-delete"
1094
1094
  })
@@ -1116,7 +1116,7 @@ function wa(e) {
1116
1116
  type: "submit",
1117
1117
  "aria-label": u.edit,
1118
1118
  disabled: !yt(x),
1119
- children: /* @__PURE__ */ Z(fe, { size: 16 })
1119
+ children: /* @__PURE__ */ Z(de, { size: 16 })
1120
1120
  })
1121
1121
  ]
1122
1122
  }) : null
@@ -1159,6 +1159,8 @@ function Da(n = {}) {
1159
1159
  lang: n.lang,
1160
1160
  onImageUpload: n.onImageUpload,
1161
1161
  tableCapabilities: n.tableCapabilities,
1162
+ referenceSuggestion: n.referenceSuggestion,
1163
+ internalLinkCard: n.internalLinkCard,
1162
1164
  linkCardExtension: Ea.configure({
1163
1165
  lang: n.lang,
1164
1166
  messages: t(n.lang),
@@ -1181,11 +1183,11 @@ function Da(n = {}) {
1181
1183
  //#endregion
1182
1184
  //#region src/ui/codeblock/CodeBlockControls.tsx
1183
1185
  function Oa(e) {
1184
- return e === "clipboard" ? /* @__PURE__ */ Q(X, { children: [/* @__PURE__ */ Z("path", { d: "M9 4.5h6a1.5 1.5 0 0 1 1.5 1.5v11A1.5 1.5 0 0 1 15 18.5H7A1.5 1.5 0 0 1 5.5 17V6A1.5 1.5 0 0 1 7 4.5h2" }), /* @__PURE__ */ Z("path", { d: "M8.5 5.5v-1A1.5 1.5 0 0 1 10 3h2a1.5 1.5 0 0 1 1.5 1.5v1h-5Z" })] }) : e === "search" ? /* @__PURE__ */ Q(X, { children: [/* @__PURE__ */ Z("circle", {
1186
+ return e === "clipboard" ? /* @__PURE__ */ Q(mt, { children: [/* @__PURE__ */ Z("path", { d: "M9 4.5h6a1.5 1.5 0 0 1 1.5 1.5v11A1.5 1.5 0 0 1 15 18.5H7A1.5 1.5 0 0 1 5.5 17V6A1.5 1.5 0 0 1 7 4.5h2" }), /* @__PURE__ */ Z("path", { d: "M8.5 5.5v-1A1.5 1.5 0 0 1 10 3h2a1.5 1.5 0 0 1 1.5 1.5v1h-5Z" })] }) : e === "search" ? /* @__PURE__ */ Q(mt, { children: [/* @__PURE__ */ Z("circle", {
1185
1187
  cx: "10",
1186
1188
  cy: "10",
1187
1189
  r: "5.5"
1188
- }), /* @__PURE__ */ Z("path", { d: "m14 14 4 4" })] }) : e === "check" ? /* @__PURE__ */ Z("path", { d: "m5 11 4 4 8-9" }) : e === "expand" ? /* @__PURE__ */ Q(X, { children: [
1190
+ }), /* @__PURE__ */ Z("path", { d: "m14 14 4 4" })] }) : e === "check" ? /* @__PURE__ */ Z("path", { d: "m5 11 4 4 8-9" }) : e === "expand" ? /* @__PURE__ */ Q(mt, { children: [
1189
1191
  /* @__PURE__ */ Z("path", { d: "M8 4H4v4" }),
1190
1192
  /* @__PURE__ */ Z("path", { d: "M4 4l5 5" }),
1191
1193
  /* @__PURE__ */ Z("path", { d: "M16 4h4v4" }),
@@ -1194,11 +1196,11 @@ function Oa(e) {
1194
1196
  /* @__PURE__ */ Z("path", { d: "m4 20 5-5" }),
1195
1197
  /* @__PURE__ */ Z("path", { d: "M16 20h4v-4" }),
1196
1198
  /* @__PURE__ */ Z("path", { d: "m20 20-5-5" })
1197
- ] }) : e === "download" ? /* @__PURE__ */ Q(X, { children: [
1199
+ ] }) : e === "download" ? /* @__PURE__ */ Q(mt, { children: [
1198
1200
  /* @__PURE__ */ Z("path", { d: "M12 4v10" }),
1199
1201
  /* @__PURE__ */ Z("path", { d: "m8 10 4 4 4-4" }),
1200
1202
  /* @__PURE__ */ Z("path", { d: "M5 19h14" })
1201
- ] }) : e === "close" ? /* @__PURE__ */ Q(X, { children: [/* @__PURE__ */ Z("path", { d: "M6 6l12 12" }), /* @__PURE__ */ Z("path", { d: "M18 6 6 18" })] }) : e === "zoomOut" ? /* @__PURE__ */ Q(X, { children: [
1203
+ ] }) : e === "close" ? /* @__PURE__ */ Q(mt, { children: [/* @__PURE__ */ Z("path", { d: "M6 6l12 12" }), /* @__PURE__ */ Z("path", { d: "M18 6 6 18" })] }) : e === "zoomOut" ? /* @__PURE__ */ Q(mt, { children: [
1202
1204
  /* @__PURE__ */ Z("circle", {
1203
1205
  cx: "10",
1204
1206
  cy: "10",
@@ -1206,7 +1208,7 @@ function Oa(e) {
1206
1208
  }),
1207
1209
  /* @__PURE__ */ Z("path", { d: "M7.5 10h5" }),
1208
1210
  /* @__PURE__ */ Z("path", { d: "m14 14 4 4" })
1209
- ] }) : e === "zoomIn" ? /* @__PURE__ */ Q(X, { children: [
1211
+ ] }) : e === "zoomIn" ? /* @__PURE__ */ Q(mt, { children: [
1210
1212
  /* @__PURE__ */ Z("circle", {
1211
1213
  cx: "10",
1212
1214
  cy: "10",
@@ -1215,7 +1217,7 @@ function Oa(e) {
1215
1217
  /* @__PURE__ */ Z("path", { d: "M7.5 10h5" }),
1216
1218
  /* @__PURE__ */ Z("path", { d: "M10 7.5v5" }),
1217
1219
  /* @__PURE__ */ Z("path", { d: "m14 14 4 4" })
1218
- ] }) : e === "reset" ? /* @__PURE__ */ Q(X, { children: [/* @__PURE__ */ Z("path", { d: "M6.5 8.5A6 6 0 1 1 6 15" }), /* @__PURE__ */ Z("path", { d: "M6.5 8.5H3.5v-3" })] }) : /* @__PURE__ */ Z("path", { d: "m6 9 6 6 6-6" });
1220
+ ] }) : e === "reset" ? /* @__PURE__ */ Q(mt, { children: [/* @__PURE__ */ Z("path", { d: "M6.5 8.5A6 6 0 1 1 6 15" }), /* @__PURE__ */ Z("path", { d: "M6.5 8.5H3.5v-3" })] }) : /* @__PURE__ */ Z("path", { d: "m6 9 6 6 6-6" });
1219
1221
  }
1220
1222
  function ka({ icon: e }) {
1221
1223
  return /* @__PURE__ */ Z("svg", {
@@ -1237,11 +1239,11 @@ function Aa({ active: e, editor: t, mermaidMode: n, onMermaidModeChange: r, read
1237
1239
  active: !1,
1238
1240
  lastX: 0,
1239
1241
  lastY: 0
1240
- }), [f, p] = J(null), [m, h] = J(null), [g, _] = J([]), [v, y] = J(null), [b, x] = J(!1), [S, C] = J(""), [w, T] = J(-1), [E, D] = J(null), [O, k] = J(!1), [A, j] = J(null), [ee, M] = J(null), [te, ne] = J(!1), [re, ie] = J(0), [ae, N] = J(0), P = Kt(t), oe = ir(t, f), se = !i && e && P.active && P.pos !== null ? {
1241
- ...P,
1242
- pos: P.pos,
1242
+ }), [f, p] = J(null), [m, h] = J(null), [g, _] = J([]), [v, y] = J(null), [b, x] = J(!1), [S, C] = J(""), [w, T] = J(-1), [E, D] = J(null), [O, k] = J(!1), [A, j] = J(null), [M, N] = J(null), [ee, P] = J(!1), [te, ne] = J(0), [re, F] = J(0), I = Kt(t), ie = ir(t, f), ae = !i && e && I.active && I.pos !== null ? {
1243
+ ...I,
1244
+ pos: I.pos,
1243
1245
  active: !0
1244
- } : null, F = oe ?? se, I = F !== null, L = F?.language === "mermaid", R = lr(t, F), z = I && F !== null && !R, ce = !i, le = Zn(F ? F.language : "text"), ue = E?.status ?? "idle", de = F?.mermaidPreviewMode ?? n, fe = L && de === "preview", B = sr(t), V = `${ae}|${B.map((e) => `${e.pos}:${e.mermaidPreviewMode}:${e.text.length}`).join("|")}`, H = K(() => tr(S.trim().toLowerCase()), [S]);
1246
+ } : null, L = ie ?? ae, oe = L !== null, R = L?.language === "mermaid", z = lr(t, L), B = oe && L !== null && !z, se = !i, ce = Zn(L ? L.language : "text"), le = E?.status ?? "idle", ue = L?.mermaidPreviewMode ?? n, de = R && ue === "preview", V = sr(t), fe = `${re}|${V.map((e) => `${e.pos}:${e.mermaidPreviewMode}:${e.text.length}`).join("|")}`, H = K(() => tr(S.trim().toLowerCase()), [S]);
1245
1247
  if (G(() => {
1246
1248
  i && (x(!1), C(""), T(-1));
1247
1249
  }, [i]), G(() => {
@@ -1253,15 +1255,15 @@ function Aa({ active: e, editor: t, mermaidMode: n, onMermaidModeChange: r, read
1253
1255
  window.clearTimeout(e);
1254
1256
  };
1255
1257
  }, [E]), G(() => {
1256
- D(null), x(!1), C(""), T(-1), j(null), M(null), ne(!1);
1258
+ D(null), x(!1), C(""), T(-1), j(null), N(null), P(!1);
1257
1259
  }, [
1258
1260
  e,
1259
- F?.language,
1260
- F?.pos,
1261
- F?.text
1261
+ L?.language,
1262
+ L?.pos,
1263
+ L?.text
1262
1264
  ]), G(() => {
1263
1265
  let e = ({ transaction: e }) => {
1264
- e.getMeta(Wt) && ie((e) => e + 1);
1266
+ e.getMeta(Wt) && ne((e) => e + 1);
1265
1267
  };
1266
1268
  return t.on("transaction", e), () => {
1267
1269
  t.off("transaction", e);
@@ -1292,7 +1294,7 @@ function Aa({ active: e, editor: t, mermaidMode: n, onMermaidModeChange: r, read
1292
1294
  ]), G(() => {
1293
1295
  if (!A) return;
1294
1296
  let e = (e) => {
1295
- e.key === "Escape" && (j(null), M(null), ne(!1), d.current = {
1297
+ e.key === "Escape" && (j(null), N(null), P(!1), d.current = {
1296
1298
  active: !1,
1297
1299
  lastX: 0,
1298
1300
  lastY: 0
@@ -1302,7 +1304,7 @@ function Aa({ active: e, editor: t, mermaidMode: n, onMermaidModeChange: r, read
1302
1304
  document.removeEventListener("keydown", e);
1303
1305
  };
1304
1306
  }, [t, A]), G(() => {
1305
- if (!I || !b) return;
1307
+ if (!oe || !b) return;
1306
1308
  let e = (e) => {
1307
1309
  e.key === "Escape" && (x(!1), T(-1), t.view.focus());
1308
1310
  }, n = (e) => {
@@ -1312,22 +1314,22 @@ function Aa({ active: e, editor: t, mermaidMode: n, onMermaidModeChange: r, read
1312
1314
  document.removeEventListener("keydown", e), document.removeEventListener("mousedown", n);
1313
1315
  };
1314
1316
  }, [
1315
- I,
1317
+ oe,
1316
1318
  t,
1317
1319
  b
1318
1320
  ]), Be(() => {
1319
1321
  let e = () => {
1320
1322
  let e = a.current;
1321
1323
  if (!e) return;
1322
- if (!ar(e) || B.length === 0) {
1324
+ if (!ar(e) || V.length === 0) {
1323
1325
  _([]);
1324
1326
  return;
1325
1327
  }
1326
- let n = e.getBoundingClientRect(), r = B.flatMap((e) => {
1328
+ let n = e.getBoundingClientRect(), r = V.flatMap((e) => {
1327
1329
  let r = er($n(t, e.pos, e.mermaidPreviewMode), n);
1328
1330
  return r ? [Yn(e, r, n)] : [];
1329
1331
  });
1330
- _((e) => ur(e, r, B.map((e) => e.pos)));
1332
+ _((e) => ur(e, r, V.map((e) => e.pos)));
1331
1333
  };
1332
1334
  e();
1333
1335
  let n = window.requestAnimationFrame(e);
@@ -1335,23 +1337,23 @@ function Aa({ active: e, editor: t, mermaidMode: n, onMermaidModeChange: r, read
1335
1337
  window.cancelAnimationFrame(n), window.removeEventListener("resize", e), window.removeEventListener("scroll", e, !0);
1336
1338
  };
1337
1339
  }, [
1338
- re,
1340
+ te,
1339
1341
  t,
1340
- V
1342
+ fe
1341
1343
  ]), Be(() => {
1342
- if (!z || !F) {
1344
+ if (!B || !L) {
1343
1345
  h(null), y(null);
1344
1346
  return;
1345
1347
  }
1346
1348
  let e = () => {
1347
1349
  let e = a.current;
1348
1350
  if (!e) return;
1349
- let n = $n(t, F.pos, de), r = e.getBoundingClientRect(), i = er(n, r);
1351
+ let n = $n(t, L.pos, ue), r = e.getBoundingClientRect(), i = er(n, r);
1350
1352
  if (!i) {
1351
- h((e) => e?.pos === F.pos ? e : null), y((e) => b ? e : null);
1353
+ h((e) => e?.pos === L.pos ? e : null), y((e) => b ? e : null);
1352
1354
  return;
1353
1355
  }
1354
- let c = qn(F.pos, i, r);
1356
+ let c = qn(L.pos, i, r);
1355
1357
  if (h(c), b && o.current) {
1356
1358
  let e = o.current.getBoundingClientRect(), t = s.current?.getBoundingClientRect().height;
1357
1359
  y(Hn({
@@ -1367,44 +1369,44 @@ function Aa({ active: e, editor: t, mermaidMode: n, onMermaidModeChange: r, read
1367
1369
  window.removeEventListener("resize", e), window.removeEventListener("scroll", e, !0);
1368
1370
  };
1369
1371
  }, [
1370
- z,
1371
- re,
1372
- F?.pos,
1372
+ B,
1373
+ te,
1374
+ L?.pos,
1373
1375
  t,
1374
1376
  H.length,
1375
1377
  b,
1376
- de
1377
- ]), !z && B.length === 0 && !A) return null;
1378
+ ue
1379
+ ]), !B && V.length === 0 && !A) return null;
1378
1380
  let pe = m ? {
1379
1381
  top: m.top,
1380
1382
  right: m.right
1381
1383
  } : void 0, me = async () => {
1382
1384
  if (i) {
1383
- if (!F) return;
1384
- let e = await Gn(F.text);
1385
- D(qt(F, e ? "copied" : "failed"));
1385
+ if (!L) return;
1386
+ let e = await Gn(L.text);
1387
+ D(qt(L, e ? "copied" : "failed"));
1386
1388
  return;
1387
1389
  }
1388
- if (!Xn(t, F)) return;
1390
+ if (!Xn(t, L)) return;
1389
1391
  let e = await Gt(t);
1390
1392
  D(qt(Kt(t), e ? "copied" : "failed")), t.view.focus();
1391
1393
  }, he = (e, n) => {
1392
1394
  if (i) {
1393
- tn(t, e.pos, n) && N((e) => e + 1);
1395
+ tn(t, e.pos, n) && F((e) => e + 1);
1394
1396
  return;
1395
1397
  }
1396
- let a = P.active && P.pos === e.pos;
1397
- Zt(t, e.pos, n) && (r(n), N((e) => e + 1), a && t.view.focus());
1398
+ let a = I.active && I.pos === e.pos;
1399
+ Zt(t, e.pos, n) && (r(n), F((e) => e + 1), a && t.view.focus());
1398
1400
  }, ge = (e) => {
1399
- if (i || !F) return;
1400
- let n = P.active && P.pos === F.pos;
1401
- Xt(t, F.pos, e) && (e === "mermaid" && Zt(t, F.pos, "preview") && r("preview"), x(!1), C(""), T(-1), N((e) => e + 1), n && t.view.focus());
1401
+ if (i || !L) return;
1402
+ let n = I.active && I.pos === L.pos;
1403
+ Xt(t, L.pos, e) && (e === "mermaid" && Zt(t, L.pos, "preview") && r("preview"), x(!1), C(""), T(-1), F((e) => e + 1), n && t.view.focus());
1402
1404
  }, _e = () => {
1403
1405
  let e = !b;
1404
- e && u.current === null && (u.current = Kn()), T(e ? or(H, F?.language ?? null) : -1), x(e);
1406
+ e && u.current === null && (u.current = Kn()), T(e ? or(H, L?.language ?? null) : -1), x(e);
1405
1407
  }, ve = (e) => {
1406
1408
  let t = tr(e);
1407
- C(e), T(or(t, e.trim() ? null : F?.language ?? null));
1409
+ C(e), T(or(t, e.trim() ? null : L?.language ?? null));
1408
1410
  }, ye = (e) => {
1409
1411
  if (!e.nativeEvent.isComposing) {
1410
1412
  if (e.key === "ArrowDown" || e.key === "ArrowUp") {
@@ -1419,10 +1421,10 @@ function Aa({ active: e, editor: t, mermaidMode: n, onMermaidModeChange: r, read
1419
1421
  e.key === "Escape" && (e.preventDefault(), x(!1), T(-1), t.view.focus());
1420
1422
  }
1421
1423
  }, be = H[w], xe = u.current && be ? nr(u.current, be.language) : void 0, Se = () => {
1422
- i || !F || Yt(t, F.pos, !R) && (ie((e) => e + 1), p(null));
1424
+ i || !L || Yt(t, L.pos, !z) && (ne((e) => e + 1), p(null));
1423
1425
  }, Ce = () => {
1424
- if (!F) return;
1425
- let e = cr(t, F.pos);
1426
+ if (!L) return;
1427
+ let e = cr(t, L.pos);
1426
1428
  e && Vn({
1427
1429
  data: new Blob([e], { type: "image/svg+xml" }),
1428
1430
  fileName: "markweave-mermaid.svg",
@@ -1430,39 +1432,39 @@ function Aa({ active: e, editor: t, mermaidMode: n, onMermaidModeChange: r, read
1430
1432
  ownerDocument: document
1431
1433
  });
1432
1434
  }, we = () => {
1433
- if (!F) return;
1434
- let e = cr(t, F.pos);
1435
- e && (j(Jn(e)), M(null), ne(!1), d.current = {
1435
+ if (!L) return;
1436
+ let e = cr(t, L.pos);
1437
+ e && (j(Jn(e)), N(null), P(!1), d.current = {
1436
1438
  active: !1,
1437
1439
  lastX: 0,
1438
1440
  lastY: 0
1439
1441
  });
1440
- }, U = () => {
1441
- j(null), M(null), ne(!1), d.current = {
1442
+ }, Te = () => {
1443
+ j(null), N(null), P(!1), d.current = {
1442
1444
  active: !1,
1443
1445
  lastX: 0,
1444
1446
  lastY: 0
1445
1447
  }, t.view.focus();
1446
- }, Te = (e) => {
1448
+ }, Ee = (e) => {
1447
1449
  j((t) => t && {
1448
1450
  ...t,
1449
1451
  scale: Un(t.scale + e)
1450
1452
  });
1451
- }, Ee = () => {
1453
+ }, De = () => {
1452
1454
  j((e) => e && Jn(e.svg)), d.current = {
1453
1455
  active: !1,
1454
1456
  lastX: 0,
1455
1457
  lastY: 0
1456
- }, ne(!1);
1457
- }, De = (e) => {
1458
- e.preventDefault(), Te(e.deltaY < 0 ? dr : -dr);
1458
+ }, P(!1);
1459
1459
  }, Oe = (e) => {
1460
+ e.preventDefault(), Ee(e.deltaY < 0 ? dr : -dr);
1461
+ }, ke = (e) => {
1460
1462
  e.button === 0 && (e.preventDefault(), d.current = {
1461
1463
  active: !0,
1462
1464
  lastX: e.clientX,
1463
1465
  lastY: e.clientY
1464
- }, ne(!0));
1465
- }, ke = (e) => {
1466
+ }, P(!0));
1467
+ }, Ae = (e) => {
1466
1468
  let t = d.current;
1467
1469
  if (!t.active) return;
1468
1470
  let n = e.clientX - t.lastX, r = e.clientY - t.lastY;
@@ -1471,12 +1473,12 @@ function Aa({ active: e, editor: t, mermaidMode: n, onMermaidModeChange: r, read
1471
1473
  lastX: e.clientX,
1472
1474
  lastY: e.clientY
1473
1475
  }, j((e) => pr(e, n, r));
1474
- }, Ae = () => {
1476
+ }, je = () => {
1475
1477
  d.current = {
1476
1478
  active: !1,
1477
1479
  lastX: 0,
1478
1480
  lastY: 0
1479
- }, ne(!1);
1481
+ }, P(!1);
1480
1482
  };
1481
1483
  return /* @__PURE__ */ Q("div", {
1482
1484
  ref: a,
@@ -1484,7 +1486,7 @@ function Aa({ active: e, editor: t, mermaidMode: n, onMermaidModeChange: r, read
1484
1486
  "data-testid": "markweave-codeblock-overlay",
1485
1487
  "data-read-only": i ? "true" : "false",
1486
1488
  children: [
1487
- B.map((e) => {
1489
+ V.map((e) => {
1488
1490
  let t = g.find((t) => t.pos === e.pos);
1489
1491
  return /* @__PURE__ */ Z("div", {
1490
1492
  className: "markweave-mermaid-tabs",
@@ -1505,11 +1507,11 @@ function Aa({ active: e, editor: t, mermaidMode: n, onMermaidModeChange: r, read
1505
1507
  }, t))
1506
1508
  }, e.pos);
1507
1509
  }),
1508
- z ? /* @__PURE__ */ Q("div", {
1510
+ B ? /* @__PURE__ */ Q("div", {
1509
1511
  className: "markweave-codeblock-controls",
1510
1512
  "data-testid": "markweave-codeblock-controls",
1511
1513
  "data-positioned": m ? "true" : "false",
1512
- "data-collapsed": R ? "true" : "false",
1514
+ "data-collapsed": z ? "true" : "false",
1513
1515
  "data-read-only": i ? "true" : "false",
1514
1516
  "aria-label": "Code block controls",
1515
1517
  style: pe,
@@ -1518,7 +1520,7 @@ function Aa({ active: e, editor: t, mermaidMode: n, onMermaidModeChange: r, read
1518
1520
  className: "markweave-codeblock-language-button markweave-codeblock-language-label",
1519
1521
  "aria-label": "Code block language",
1520
1522
  "data-testid": "markweave-codeblock-language",
1521
- children: /* @__PURE__ */ Z("span", { children: le })
1523
+ children: /* @__PURE__ */ Z("span", { children: ce })
1522
1524
  }) : /* @__PURE__ */ Q("button", {
1523
1525
  ref: o,
1524
1526
  type: "button",
@@ -1529,15 +1531,15 @@ function Aa({ active: e, editor: t, mermaidMode: n, onMermaidModeChange: r, read
1529
1531
  "data-testid": "markweave-codeblock-language",
1530
1532
  onMouseDown: (e) => e.preventDefault(),
1531
1533
  onClick: _e,
1532
- children: [/* @__PURE__ */ Z("span", { children: le }), /* @__PURE__ */ Z(ka, { icon: "chevron" })]
1534
+ children: [/* @__PURE__ */ Z("span", { children: ce }), /* @__PURE__ */ Z(ka, { icon: "chevron" })]
1533
1535
  }),
1534
- ce ? /* @__PURE__ */ Z("button", {
1536
+ se ? /* @__PURE__ */ Z("button", {
1535
1537
  type: "button",
1536
1538
  className: "markweave-codeblock-icon-button markweave-codeblock-collapse-button",
1537
- "aria-label": R ? "Expand code block" : "Collapse code block",
1538
- title: R ? "Expand code block" : "Collapse code block",
1539
+ "aria-label": z ? "Expand code block" : "Collapse code block",
1540
+ title: z ? "Expand code block" : "Collapse code block",
1539
1541
  "data-testid": "markweave-codeblock-collapse",
1540
- "data-collapsed": R ? "true" : "false",
1542
+ "data-collapsed": z ? "true" : "false",
1541
1543
  onMouseDown: (e) => e.preventDefault(),
1542
1544
  onClick: Se,
1543
1545
  children: /* @__PURE__ */ Z(ka, { icon: "chevron" })
@@ -1549,14 +1551,14 @@ function Aa({ active: e, editor: t, mermaidMode: n, onMermaidModeChange: r, read
1549
1551
  className: "markweave-codeblock-icon-button",
1550
1552
  "aria-label": "Copy to clipboard",
1551
1553
  "data-testid": "markweave-codeblock-copy",
1552
- "data-copy-state": ue,
1554
+ "data-copy-state": le,
1553
1555
  onMouseDown: (e) => e.preventDefault(),
1554
1556
  onMouseEnter: () => k(!0),
1555
1557
  onMouseLeave: () => k(!1),
1556
1558
  onFocus: () => k(!0),
1557
1559
  onBlur: () => k(!1),
1558
1560
  onClick: me,
1559
- children: /* @__PURE__ */ Z(ka, { icon: ue === "copied" ? "check" : "clipboard" })
1561
+ children: /* @__PURE__ */ Z(ka, { icon: le === "copied" ? "check" : "clipboard" })
1560
1562
  }), O ? /* @__PURE__ */ Z("span", {
1561
1563
  className: "markweave-codeblock-tooltip",
1562
1564
  role: "tooltip",
@@ -1564,7 +1566,7 @@ function Aa({ active: e, editor: t, mermaidMode: n, onMermaidModeChange: r, read
1564
1566
  children: "Copy to clipboard"
1565
1567
  }) : null]
1566
1568
  }),
1567
- L && de === "preview" ? /* @__PURE__ */ Q("div", {
1569
+ R && ue === "preview" ? /* @__PURE__ */ Q("div", {
1568
1570
  className: "markweave-mermaid-preview-actions",
1569
1571
  "data-testid": "markweave-mermaid-preview-actions",
1570
1572
  children: [/* @__PURE__ */ Z("button", {
@@ -1572,7 +1574,7 @@ function Aa({ active: e, editor: t, mermaidMode: n, onMermaidModeChange: r, read
1572
1574
  className: "markweave-codeblock-icon-button",
1573
1575
  "aria-label": "Fullscreen Mermaid preview",
1574
1576
  "data-testid": "markweave-mermaid-fullscreen",
1575
- disabled: !fe,
1577
+ disabled: !de,
1576
1578
  onMouseDown: (e) => e.preventDefault(),
1577
1579
  onClick: we,
1578
1580
  children: /* @__PURE__ */ Z(ka, { icon: "expand" })
@@ -1581,7 +1583,7 @@ function Aa({ active: e, editor: t, mermaidMode: n, onMermaidModeChange: r, read
1581
1583
  className: "markweave-codeblock-icon-button",
1582
1584
  "aria-label": "Download Mermaid SVG",
1583
1585
  "data-testid": "markweave-mermaid-download",
1584
- disabled: !fe,
1586
+ disabled: !de,
1585
1587
  onMouseDown: (e) => e.preventDefault(),
1586
1588
  onClick: Ce,
1587
1589
  children: /* @__PURE__ */ Z(ka, { icon: "download" })
@@ -1589,7 +1591,7 @@ function Aa({ active: e, editor: t, mermaidMode: n, onMermaidModeChange: r, read
1589
1591
  }) : null
1590
1592
  ]
1591
1593
  }) : null,
1592
- ce && z && b ? /* @__PURE__ */ Q("div", {
1594
+ se && B && b ? /* @__PURE__ */ Q("div", {
1593
1595
  ref: s,
1594
1596
  className: "markweave-codeblock-language-menu",
1595
1597
  "data-testid": "markweave-codeblock-language-menu",
@@ -1621,7 +1623,7 @@ function Aa({ active: e, editor: t, mermaidMode: n, onMermaidModeChange: r, read
1621
1623
  role: "listbox",
1622
1624
  "aria-label": "Code block languages",
1623
1625
  children: H.map((e, t) => {
1624
- let n = e.language === F.language, r = t === w;
1626
+ let n = e.language === L.language, r = t === w;
1625
1627
  return /* @__PURE__ */ Q("button", {
1626
1628
  id: u.current ? nr(u.current, e.language) : void 0,
1627
1629
  type: "button",
@@ -1655,11 +1657,11 @@ function Aa({ active: e, editor: t, mermaidMode: n, onMermaidModeChange: r, read
1655
1657
  className: "markweave-mermaid-fullscreen-control",
1656
1658
  "aria-label": "Zoom out",
1657
1659
  "data-testid": "markweave-mermaid-fullscreen-zoom-out",
1658
- onMouseEnter: () => M("zoom-out"),
1659
- onMouseLeave: () => M(null),
1660
- onFocus: () => M("zoom-out"),
1661
- onBlur: () => M(null),
1662
- onClick: () => Te(-dr),
1660
+ onMouseEnter: () => N("zoom-out"),
1661
+ onMouseLeave: () => N(null),
1662
+ onFocus: () => N("zoom-out"),
1663
+ onBlur: () => N(null),
1664
+ onClick: () => Ee(-dr),
1663
1665
  children: /* @__PURE__ */ Z(ka, { icon: "zoomOut" })
1664
1666
  }),
1665
1667
  /* @__PURE__ */ Z("span", {
@@ -1672,11 +1674,11 @@ function Aa({ active: e, editor: t, mermaidMode: n, onMermaidModeChange: r, read
1672
1674
  className: "markweave-mermaid-fullscreen-control",
1673
1675
  "aria-label": "Zoom in",
1674
1676
  "data-testid": "markweave-mermaid-fullscreen-zoom-in",
1675
- onMouseEnter: () => M("zoom-in"),
1676
- onMouseLeave: () => M(null),
1677
- onFocus: () => M("zoom-in"),
1678
- onBlur: () => M(null),
1679
- onClick: () => Te(dr),
1677
+ onMouseEnter: () => N("zoom-in"),
1678
+ onMouseLeave: () => N(null),
1679
+ onFocus: () => N("zoom-in"),
1680
+ onBlur: () => N(null),
1681
+ onClick: () => Ee(dr),
1680
1682
  children: /* @__PURE__ */ Z(ka, { icon: "zoomIn" })
1681
1683
  }),
1682
1684
  /* @__PURE__ */ Z("button", {
@@ -1684,18 +1686,18 @@ function Aa({ active: e, editor: t, mermaidMode: n, onMermaidModeChange: r, read
1684
1686
  className: "markweave-mermaid-fullscreen-control",
1685
1687
  "aria-label": "Reset zoom",
1686
1688
  "data-testid": "markweave-mermaid-fullscreen-reset",
1687
- onMouseEnter: () => M("reset"),
1688
- onMouseLeave: () => M(null),
1689
- onFocus: () => M("reset"),
1690
- onBlur: () => M(null),
1691
- onClick: Ee,
1689
+ onMouseEnter: () => N("reset"),
1690
+ onMouseLeave: () => N(null),
1691
+ onFocus: () => N("reset"),
1692
+ onBlur: () => N(null),
1693
+ onClick: De,
1692
1694
  children: /* @__PURE__ */ Z(ka, { icon: "reset" })
1693
1695
  }),
1694
- ee ? /* @__PURE__ */ Z("span", {
1696
+ M ? /* @__PURE__ */ Z("span", {
1695
1697
  className: "markweave-mermaid-fullscreen-tooltip",
1696
1698
  role: "tooltip",
1697
1699
  "data-testid": "markweave-mermaid-fullscreen-tooltip",
1698
- children: ee === "zoom-out" ? "Zoom out" : ee === "zoom-in" ? "Zoom in" : "Reset"
1700
+ children: M === "zoom-out" ? "Zoom out" : M === "zoom-in" ? "Zoom in" : "Reset"
1699
1701
  }) : null
1700
1702
  ]
1701
1703
  }),
@@ -1704,18 +1706,18 @@ function Aa({ active: e, editor: t, mermaidMode: n, onMermaidModeChange: r, read
1704
1706
  className: "markweave-mermaid-fullscreen-close",
1705
1707
  "aria-label": "Close fullscreen Mermaid preview",
1706
1708
  "data-testid": "markweave-mermaid-fullscreen-close",
1707
- onClick: U,
1709
+ onClick: Te,
1708
1710
  children: /* @__PURE__ */ Z(ka, { icon: "close" })
1709
1711
  }),
1710
1712
  /* @__PURE__ */ Z("div", {
1711
1713
  className: "markweave-mermaid-fullscreen-viewport",
1712
1714
  "data-testid": "markweave-mermaid-fullscreen-viewport",
1713
- "data-dragging": te ? "true" : "false",
1714
- onWheel: De,
1715
- onMouseDown: Oe,
1716
- onMouseMove: ke,
1717
- onMouseUp: Ae,
1718
- onMouseLeave: Ae,
1715
+ "data-dragging": ee ? "true" : "false",
1716
+ onWheel: Oe,
1717
+ onMouseDown: ke,
1718
+ onMouseMove: Ae,
1719
+ onMouseUp: je,
1720
+ onMouseLeave: je,
1719
1721
  children: /* @__PURE__ */ Z("div", {
1720
1722
  className: "markweave-mermaid-fullscreen-content",
1721
1723
  "data-testid": "markweave-mermaid-fullscreen-content",
@@ -1964,15 +1966,15 @@ var co = 50, lo = async (e, t, n) => {
1964
1966
  y: r
1965
1967
  }, p = Ka(i), m = Wa(p), h = await o.getDimensions(l), g = p === "y", _ = g ? "top" : "left", v = g ? "bottom" : "right", y = g ? "clientHeight" : "clientWidth", b = a.reference[m] + a.reference[p] - f[p] - a.floating[m], x = f[p] - a.reference[p], S = await (o.getOffsetParent == null ? void 0 : o.getOffsetParent(l)), C = S ? S[y] : 0;
1966
1968
  (!C || !await (o.isElement == null ? void 0 : o.isElement(S))) && (C = s.floating[y] || a.floating[m]);
1967
- let w = b / 2 - x / 2, T = C / 2 - h[m] / 2 - 1, E = Pa(d[_], T), D = Pa(d[v], T), O = E, k = C - h[m] - D, A = C / 2 - h[m] / 2 + w, j = za(O, A, k), ee = !c.arrow && Ha(i) != null && A !== j && a.reference[m] / 2 - (A < O ? E : D) - h[m] / 2 < 0, M = ee ? A < O ? A - O : A - k : 0;
1969
+ let w = b / 2 - x / 2, T = C / 2 - h[m] / 2 - 1, E = Pa(d[_], T), D = Pa(d[v], T), O = E, k = C - h[m] - D, A = C / 2 - h[m] / 2 + w, j = za(O, A, k), M = !c.arrow && Ha(i) != null && A !== j && a.reference[m] / 2 - (A < O ? E : D) - h[m] / 2 < 0, N = M ? A < O ? A - O : A - k : 0;
1968
1970
  return {
1969
- [p]: f[p] + M,
1971
+ [p]: f[p] + N,
1970
1972
  data: {
1971
1973
  [p]: j,
1972
- centerOffset: A - j - M,
1973
- ...ee && { alignmentOffset: M }
1974
+ centerOffset: A - j - N,
1975
+ ...M && { alignmentOffset: N }
1974
1976
  },
1975
- reset: ee
1977
+ reset: M
1976
1978
  };
1977
1979
  }
1978
1980
  });
@@ -2628,7 +2630,7 @@ var Cs = {
2628
2630
  });
2629
2631
  };
2630
2632
  //#endregion
2631
- //#region ../../node_modules/.pnpm/@tiptap+extension-bubble-me_a2cb23ea35a30e616b92f8b342a9c193/node_modules/@tiptap/extension-bubble-menu/dist/index.js
2633
+ //#region ../../node_modules/.pnpm/@tiptap+extension-bubble-menu@3.29.2_@tiptap+core@3.29.2_@tiptap+pm@3.29.2__@tiptap+pm@3.29.2/node_modules/@tiptap/extension-bubble-menu/dist/index.js
2632
2634
  function Ns(e, t) {
2633
2635
  let n = Math.min(e.top, t.top), r = Math.max(e.bottom, t.bottom), i = Math.min(e.left, t.left), a = Math.max(e.right, t.right) - i, o = r - n;
2634
2636
  return new DOMRect(i, n, a, o);
@@ -2814,7 +2816,7 @@ hr.create({
2814
2816
  }
2815
2817
  });
2816
2818
  //#endregion
2817
- //#region ../../node_modules/.pnpm/@tiptap+extension-floating-_11dc7a1711aa26a800505c48cf31983d/node_modules/@tiptap/extension-floating-menu/dist/index.js
2819
+ //#region ../../node_modules/.pnpm/@tiptap+extension-floating-menu@3.29.2_@floating-ui+dom@1.7.6_@tiptap+core@3.29.2_@tiptap+pm@3.29.2__@tiptap+pm@3.29.2/node_modules/@tiptap/extension-floating-menu/dist/index.js
2818
2820
  var Is = class {
2819
2821
  constructor({ editor: e, element: t, view: n, pluginKey: r = "floatingMenu", updateDelay: i = 250, resizeDelay: a = 60, options: o, appendTo: s, shouldShow: c }) {
2820
2822
  this.preventHide = !1, this.isVisible = !1, this.scrollTarget = window, this.shouldShow = ({ view: e, state: t }) => {
@@ -2958,7 +2960,7 @@ hr.create({
2958
2960
  }
2959
2961
  });
2960
2962
  //#endregion
2961
- //#region ../../node_modules/.pnpm/@tiptap+react@3.29.2_@float_2279cac4bf12e5469a1ae6c590eec77f/node_modules/@tiptap/react/dist/menus/index.js
2963
+ //#region ../../node_modules/.pnpm/@tiptap+react@3.29.2_@floating-ui+dom@1.7.6_@tiptap+core@3.29.2_@tiptap+pm@3.29.2__@tip_2279cac4bf12e5469a1ae6c590eec77f/node_modules/@tiptap/react/dist/menus/index.js
2962
2964
  function Rs(e, t) {
2963
2965
  return e ?? new Sr(t);
2964
2966
  }
@@ -3371,14 +3373,14 @@ function kc(e, t, n) {
3371
3373
  }
3372
3374
  var Ac = "markweave-floating-toolbar";
3373
3375
  function jc({ editor: e, lang: t = "zh", messages: n = uc, selectionSnapshot: r, askAi: i, onRewriteSelection: a }) {
3374
- let o = K(() => jr(n), [n]), s = Bt(r, { editable: e.isEditable }), [c, l] = J(s), [u, d] = J(null), [f, p] = J(null), [m, h] = J(null), [g, _] = J("input"), [v, y] = J(""), [b, x] = J(""), [S, C] = J(""), [w, T] = J(""), [E, D] = J(""), [O, k] = J(""), [A, j] = J(null), [ee, M] = J(0), [te, ne] = J(s.boundaryPadding), [re, ie] = J("bottom"), ae = q(0), N = q(null), P = q(null), oe = q(null), se = q(null), F = q(null), I = q(null), L = q(null), R = q(null), z = q(null), ce = q(""), le = i?.enabled === !0 && typeof i.handler == "function", ue = Dr(e, c.variant, n, { askAiEnabled: le }), de = Nr(ue.find((e) => e.id === u) ?? null), fe = si(E), B = W(() => {
3375
- z.current !== null && (window.cancelAnimationFrame(z.current), z.current = null);
3376
- }, []), V = W((t = !0) => {
3377
- L.current?.abort(), L.current = null, R.current = null, B(), t && ni(e), Yr(e), h(null);
3378
- }, [B, e]), H = W(() => {
3379
- let t = N.current, n = e.view.dom.closest(".markweave-editor-frame");
3376
+ let o = K(() => jr(n), [n]), s = Bt(r, { editable: e.isEditable }), [c, l] = J(s), [u, d] = J(null), [f, p] = J(null), [m, h] = J(null), [g, _] = J("input"), [v, y] = J(""), [b, x] = J(""), [S, C] = J(""), [w, T] = J(""), [E, D] = J(""), [O, k] = J(""), [A, j] = J(null), [M, N] = J(0), [ee, P] = J(s.boundaryPadding), [te, ne] = J("bottom"), re = q(0), F = q(null), I = q(null), ie = q(null), ae = q(null), L = q(null), oe = q(null), R = q(null), z = q(null), B = q(null), se = q(""), ce = i?.enabled === !0 && typeof i.handler == "function", le = Dr(e, c.variant, n, { askAiEnabled: ce }), ue = Nr(le.find((e) => e.id === u) ?? null), de = si(E), V = W(() => {
3377
+ B.current !== null && (window.cancelAnimationFrame(B.current), B.current = null);
3378
+ }, []), fe = W((t = !0) => {
3379
+ R.current?.abort(), R.current = null, z.current = null, V(), t && ni(e), Yr(e), h(null);
3380
+ }, [V, e]), H = W(() => {
3381
+ let t = F.current, n = e.view.dom.closest(".markweave-editor-frame");
3380
3382
  if (!t || !(n instanceof HTMLElement)) return;
3381
- let r = t.getBoundingClientRect(), i = n.getBoundingClientRect(), a = pc(t, P.current), o = ae.current, s = Ft({
3383
+ let r = t.getBoundingClientRect(), i = n.getBoundingClientRect(), a = pc(t, I.current), o = re.current, s = Ft({
3382
3384
  toolbarRect: {
3383
3385
  left: r.left - o,
3384
3386
  top: r.top,
@@ -3406,13 +3408,13 @@ function jc({ editor: e, lang: t = "zh", messages: n = uc, selectionSnapshot: r,
3406
3408
  offset: c.offset,
3407
3409
  boundaryPadding: c.boundaryPadding
3408
3410
  });
3409
- t.style.marginLeft = s === 0 ? "" : `${s}px`, t.style.visibility = "visible", t.style.opacity = "1", ae.current = s, M((e) => e === s ? e : s), ne((e) => e === l ? e : l);
3411
+ t.style.marginLeft = s === 0 ? "" : `${s}px`, t.style.visibility = "visible", t.style.opacity = "1", re.current = s, N((e) => e === s ? e : s), P((e) => e === l ? e : l);
3410
3412
  }, [
3411
3413
  e.view.dom,
3412
3414
  c.boundaryPadding,
3413
3415
  c.offset
3414
3416
  ]), pe = W(() => {
3415
- N.current && (N.current.style.visibility = "hidden", N.current.style.opacity = "0");
3417
+ F.current && (F.current.style.visibility = "hidden", F.current.style.opacity = "0");
3416
3418
  }, []), me = W(() => {
3417
3419
  H();
3418
3420
  }, [H]), he = W(() => $r(e)?.target.kind === "table" ? {
@@ -3425,13 +3427,13 @@ function jc({ editor: e, lang: t = "zh", messages: n = uc, selectionSnapshot: r,
3425
3427
  return t ? [hc(t.left, t.top, t.width, t.height)] : [];
3426
3428
  }
3427
3429
  } : Dc(e), [e]), ge = W((e) => {
3428
- oe.current = e, e?.classList.contains("markweave-ask-ai-popover") && (e.dataset.positioned = "false");
3430
+ ie.current = e, e?.classList.contains("markweave-ask-ai-popover") && (e.dataset.positioned = "false");
3429
3431
  }, []), _e = W(() => {
3430
- let t = N.current, n = oe.current, r = e.view.dom.closest(".markweave-editor-frame");
3432
+ let t = F.current, n = ie.current, r = e.view.dom.closest(".markweave-editor-frame");
3431
3433
  if (!m || !t || !n) return;
3432
3434
  let i = t.getBoundingClientRect(), a = n.getBoundingClientRect(), o = r?.getBoundingClientRect() ?? null;
3433
3435
  if (m === "ask-ai") {
3434
- let t = ei(e), r = P.current?.getBoundingClientRect();
3436
+ let t = ei(e), r = I.current?.getBoundingClientRect();
3435
3437
  if (!t || !r) return;
3436
3438
  let i = {
3437
3439
  anchorRect: r,
@@ -3450,7 +3452,7 @@ function jc({ editor: e, lang: t = "zh", messages: n = uc, selectionSnapshot: r,
3450
3452
  n.style.width !== l && (n.style.width = l, s = Kr({
3451
3453
  ...i,
3452
3454
  panelSize: n.getBoundingClientRect()
3453
- })), n.style.left = `${s.left}px`, n.style.top = `${s.top}px`, n.style.bottom = "auto", n.style.maxWidth = `${s.maxWidth}px`, n.style.maxHeight = `${Math.max(0, s.maxHeight)}px`, n.dataset.positioned = "true", ie((e) => e === s.placement ? e : s.placement);
3455
+ })), n.style.left = `${s.left}px`, n.style.top = `${s.top}px`, n.style.bottom = "auto", n.style.maxWidth = `${s.maxWidth}px`, n.style.maxHeight = `${Math.max(0, s.maxHeight)}px`, n.dataset.positioned = "true", ne((e) => e === s.placement ? e : s.placement);
3454
3456
  return;
3455
3457
  }
3456
3458
  let s = It({
@@ -3464,20 +3466,20 @@ function jc({ editor: e, lang: t = "zh", messages: n = uc, selectionSnapshot: r,
3464
3466
  gap: m === "more" ? 8 : 6,
3465
3467
  boundaryPadding: c.boundaryPadding
3466
3468
  });
3467
- ie((e) => e === s.placement ? e : s.placement);
3469
+ ne((e) => e === s.placement ? e : s.placement);
3468
3470
  }, [
3469
3471
  e,
3470
3472
  m,
3471
3473
  c.boundaryPadding
3472
3474
  ]), ve = K(() => ({
3473
- ...zt(c, { topBoundaryPadding: te }),
3475
+ ...zt(c, { topBoundaryPadding: ee }),
3474
3476
  onShow: pe,
3475
3477
  onUpdate: me
3476
3478
  }), [
3477
3479
  pe,
3478
3480
  me,
3479
3481
  c,
3480
- te
3482
+ ee
3481
3483
  ]);
3482
3484
  G(() => {
3483
3485
  let e = dc();
@@ -3507,7 +3509,7 @@ function jc({ editor: e, lang: t = "zh", messages: n = uc, selectionSnapshot: r,
3507
3509
  c.motionStartedAtMs
3508
3510
  ]), Be(() => {
3509
3511
  if (c.visibility !== "visible") {
3510
- ae.current = 0, N.current && (N.current.style.marginLeft = "", N.current.style.visibility = "hidden", N.current.style.opacity = "0"), M(0), ne(c.boundaryPadding);
3512
+ re.current = 0, F.current && (F.current.style.marginLeft = "", F.current.style.visibility = "hidden", F.current.style.opacity = "0"), N(0), P(c.boundaryPadding);
3511
3513
  return;
3512
3514
  }
3513
3515
  let e = Tt(H);
@@ -3522,7 +3524,7 @@ function jc({ editor: e, lang: t = "zh", messages: n = uc, selectionSnapshot: r,
3522
3524
  r?.to,
3523
3525
  c.variant,
3524
3526
  c.visibility,
3525
- ue.length
3527
+ le.length
3526
3528
  ]), Be(() => {
3527
3529
  if (!m) return;
3528
3530
  let e = Tt(_e);
@@ -3536,33 +3538,33 @@ function jc({ editor: e, lang: t = "zh", messages: n = uc, selectionSnapshot: r,
3536
3538
  m,
3537
3539
  _e
3538
3540
  ]), G(() => {
3539
- m === "more" && o.some((e) => e.id === u) || ue.some((e) => e.id === u) || (d(null), p(null));
3541
+ m === "more" && o.some((e) => e.id === u) || le.some((e) => e.id === u) || (d(null), p(null));
3540
3542
  }, [
3541
3543
  o,
3542
3544
  m,
3543
3545
  u,
3544
- ue
3546
+ le
3545
3547
  ]), G(() => {
3546
3548
  if (!m) return;
3547
3549
  let t = (e) => {
3548
- P.current?.contains(e.target) || (m === "ask-ai" ? V(!0) : h(null));
3550
+ I.current?.contains(e.target) || (m === "ask-ai" ? fe(!0) : h(null));
3549
3551
  }, n = (t) => {
3550
- t.key === "Escape" && (t.preventDefault(), m === "ask-ai" ? g === "generating" ? (L.current?.abort(), B(), _("input")) : V(!0) : (h(null), e.commands.focus()));
3552
+ t.key === "Escape" && (t.preventDefault(), m === "ask-ai" ? g === "generating" ? (R.current?.abort(), V(), _("input")) : fe(!0) : (h(null), e.commands.focus()));
3551
3553
  };
3552
3554
  return document.addEventListener("pointerdown", t, !0), document.addEventListener("keydown", n, !0), () => {
3553
3555
  document.removeEventListener("pointerdown", t, !0), document.removeEventListener("keydown", n, !0);
3554
3556
  };
3555
3557
  }, [
3556
3558
  g,
3557
- B,
3558
3559
  V,
3560
+ fe,
3559
3561
  e,
3560
3562
  m
3561
3563
  ]), G(() => {
3562
3564
  let t = () => {
3563
3565
  let t = $r(e);
3564
3566
  if (t?.target.kind === "table" && t.status === "target" && m !== "ask-ai") {
3565
- I.current = t.selection, _("input"), y(""), C(""), T(""), x(""), l((e) => ({
3567
+ oe.current = t.selection, _("input"), y(""), C(""), T(""), x(""), l((e) => ({
3566
3568
  ...e,
3567
3569
  visibility: "visible",
3568
3570
  variant: "default",
@@ -3572,21 +3574,21 @@ function jc({ editor: e, lang: t = "zh", messages: n = uc, selectionSnapshot: r,
3572
3574
  })), h("ask-ai");
3573
3575
  return;
3574
3576
  }
3575
- m === "ask-ai" && t?.status === "conflict" && (L.current?.abort(), B(), _("conflict"));
3577
+ m === "ask-ai" && t?.status === "conflict" && (R.current?.abort(), V(), _("conflict"));
3576
3578
  };
3577
3579
  return e.on("transaction", t), () => {
3578
3580
  e.off("transaction", t);
3579
3581
  };
3580
3582
  }, [
3581
- B,
3583
+ V,
3582
3584
  e,
3583
3585
  m
3584
3586
  ]), G(() => () => {
3585
- L.current?.abort(), B(), Yr(e);
3586
- }, [B, e]), G(() => {
3587
+ R.current?.abort(), V(), Yr(e);
3588
+ }, [V, e]), G(() => {
3587
3589
  if (m !== "link" && m !== "ask-ai") return;
3588
3590
  let e = window.requestAnimationFrame(() => {
3589
- m === "ask-ai" ? F.current?.focus() : (se.current?.focus(), se.current?.select());
3591
+ m === "ask-ai" ? L.current?.focus() : (ae.current?.focus(), ae.current?.select());
3590
3592
  });
3591
3593
  return () => window.cancelAnimationFrame(e);
3592
3594
  }, [m]), G(() => {
@@ -3596,14 +3598,14 @@ function jc({ editor: e, lang: t = "zh", messages: n = uc, selectionSnapshot: r,
3596
3598
  if (Oc(t.id)) {
3597
3599
  let n = t.id;
3598
3600
  if (m === n) {
3599
- n === "ask-ai" ? V(!0) : h(null);
3601
+ n === "ask-ai" ? fe(!0) : h(null);
3600
3602
  return;
3601
3603
  }
3602
- if (m === "ask-ai" && V(!1), n === "ask-ai") {
3603
- if (!le) return;
3604
+ if (m === "ask-ai" && fe(!1), n === "ask-ai") {
3605
+ if (!ce) return;
3604
3606
  let t = oi(e);
3605
3607
  if (!t) return;
3606
- I.current = t, _("input"), C(""), T(""), x("");
3608
+ oe.current = t, _("input"), C(""), T(""), x("");
3607
3609
  }
3608
3610
  if (n === "link") {
3609
3611
  let t = kr(e);
@@ -3621,32 +3623,32 @@ function jc({ editor: e, lang: t = "zh", messages: n = uc, selectionSnapshot: r,
3621
3623
  }
3622
3624
  t.run(), e.commands.focus();
3623
3625
  }, be = W(async (r) => {
3624
- if (!le || i?.enabled !== !0 || !I.current) return;
3626
+ if (!ce || i?.enabled !== !0 || !oe.current) return;
3625
3627
  let a = (r ?? v).trim();
3626
3628
  if (!a) {
3627
3629
  T(n.askAi.emptyPrompt), _("error");
3628
3630
  return;
3629
3631
  }
3630
- let o = Zr(e, I.current);
3632
+ let o = Zr(e, oe.current);
3631
3633
  if (!o) {
3632
3634
  _("conflict");
3633
3635
  return;
3634
3636
  }
3635
- I.current = o, L.current?.abort(), B(), Jr(e);
3637
+ oe.current = o, R.current?.abort(), V(), Jr(e);
3636
3638
  let s = new AbortController(), c = Xr(o, a, t, s.signal, void 0, $r(e)?.target);
3637
- L.current = s, R.current = c.id, x(a), T(""), C(""), _("generating");
3639
+ R.current = s, z.current = c.id, x(a), T(""), C(""), _("generating");
3638
3640
  try {
3639
3641
  let t = await ri(i.handler, c, (t) => {
3640
- R.current !== c.id || s.signal.aborted || (ce.current = t, z.current === null && (z.current = window.requestAnimationFrame(() => {
3641
- z.current = null, ii(e, ce.current), C(ce.current);
3642
+ z.current !== c.id || s.signal.aborted || (se.current = t, B.current === null && (B.current = window.requestAnimationFrame(() => {
3643
+ B.current = null, ii(e, se.current), C(se.current);
3642
3644
  })));
3643
3645
  });
3644
- if (R.current !== c.id || s.signal.aborted) return;
3646
+ if (z.current !== c.id || s.signal.aborted) return;
3645
3647
  if (!ii(e, t)) throw new Wr("invalid-output", "Ask AI output is incompatible with the selected content.");
3646
- B(), C(t), y(""), _($r(e)?.status === "target" ? "result" : "conflict");
3648
+ V(), C(t), y(""), _($r(e)?.status === "target" ? "result" : "conflict");
3647
3649
  } catch (t) {
3648
- if (R.current !== c.id) return;
3649
- if (B(), s.signal.aborted) {
3650
+ if (z.current !== c.id) return;
3651
+ if (V(), s.signal.aborted) {
3650
3652
  Jr(e), _($r(e)?.status === "conflict" ? "conflict" : "input");
3651
3653
  return;
3652
3654
  }
@@ -3654,9 +3656,9 @@ function jc({ editor: e, lang: t = "zh", messages: n = uc, selectionSnapshot: r,
3654
3656
  }
3655
3657
  }, [
3656
3658
  i,
3657
- le,
3659
+ ce,
3658
3660
  v,
3659
- B,
3661
+ V,
3660
3662
  e,
3661
3663
  t,
3662
3664
  n
@@ -3665,7 +3667,7 @@ function jc({ editor: e, lang: t = "zh", messages: n = uc, selectionSnapshot: r,
3665
3667
  _($r(e)?.status === "conflict" ? "conflict" : "error"), T(n.askAi.errorFallback);
3666
3668
  return;
3667
3669
  }
3668
- h(null), R.current = null, window.setTimeout(() => Yr(e), 560), e.commands.focus();
3670
+ h(null), z.current = null, window.setTimeout(() => Yr(e), 560), e.commands.focus();
3669
3671
  }, [
3670
3672
  S,
3671
3673
  e,
@@ -3676,32 +3678,32 @@ function jc({ editor: e, lang: t = "zh", messages: n = uc, selectionSnapshot: r,
3676
3678
  A && e.commands.setTextSelection(A);
3677
3679
  }, we = () => {
3678
3680
  Ce(), Tr(e, E) && Se();
3679
- }, U = () => {
3681
+ }, Te = () => {
3680
3682
  if (Ce(), zr(e)) {
3681
3683
  D(""), k(""), Se();
3682
3684
  return;
3683
3685
  }
3684
3686
  E.trim() && D("");
3685
- }, Te = (e, t) => {
3686
- if (d(e), !e || !t || !P.current) {
3687
+ }, Ee = (e, t) => {
3688
+ if (d(e), !e || !t || !I.current) {
3687
3689
  p(null);
3688
3690
  return;
3689
3691
  }
3690
- let n = t.getBoundingClientRect(), r = P.current.getBoundingClientRect();
3692
+ let n = t.getBoundingClientRect(), r = I.current.getBoundingClientRect();
3691
3693
  p(n.left + n.width / 2 - r.left);
3692
3694
  };
3693
3695
  return /* @__PURE__ */ Z(lc, {
3694
- ref: N,
3696
+ ref: F,
3695
3697
  editor: e,
3696
3698
  pluginKey: Ac,
3697
3699
  className: `markweave-floating-toolbar markweave-floating-toolbar--${c.variant} markweave-floating-toolbar--motion-${c.motionPhase}`,
3698
3700
  "data-motion": c.motionPhase,
3699
3701
  "data-position-strategy": ve.strategy,
3700
3702
  "data-boundary-padding": c.boundaryPadding,
3701
- "data-popover-placement": m ? re : void 0,
3703
+ "data-popover-placement": m ? te : void 0,
3702
3704
  "data-ask-ai-session": m === "ask-ai" ? "open" : "closed",
3703
3705
  "data-testid": "markweave-floating-toolbar",
3704
- style: fc(c, ee),
3706
+ style: fc(c, M),
3705
3707
  updateDelay: 0,
3706
3708
  getReferencedVirtualElement: he,
3707
3709
  options: ve,
@@ -3714,17 +3716,17 @@ function jc({ editor: e, lang: t = "zh", messages: n = uc, selectionSnapshot: r,
3714
3716
  });
3715
3717
  },
3716
3718
  children: /* @__PURE__ */ Q("div", {
3717
- ref: P,
3719
+ ref: I,
3718
3720
  className: "markweave-floating-toolbar-content",
3719
3721
  "data-menu": m ?? "none",
3720
3722
  children: [
3721
- ue.map((e, t) => /* @__PURE__ */ Z(Pc, {
3723
+ le.map((e, t) => /* @__PURE__ */ Z(Pc, {
3722
3724
  button: e,
3723
3725
  expanded: m === e.id,
3724
- showDivider: t > 0 && ue[t - 1].group !== e.group,
3726
+ showDivider: t > 0 && le[t - 1].group !== e.group,
3725
3727
  tooltipActive: u === e.id,
3726
3728
  onPointerDown: Rr,
3727
- onTooltipChange: Te,
3729
+ onTooltipChange: Ee,
3728
3730
  onRun: ye
3729
3731
  }, e.id)),
3730
3732
  m === "block-type" ? /* @__PURE__ */ Z(Ic, {
@@ -3734,7 +3736,7 @@ function jc({ editor: e, lang: t = "zh", messages: n = uc, selectionSnapshot: r,
3734
3736
  onClose: () => h(null)
3735
3737
  }) : null,
3736
3738
  m === "ask-ai" ? /* @__PURE__ */ Z(Nc, {
3737
- inputRef: F,
3739
+ inputRef: L,
3738
3740
  messages: n,
3739
3741
  phase: g,
3740
3742
  prompt: v,
@@ -3743,24 +3745,24 @@ function jc({ editor: e, lang: t = "zh", messages: n = uc, selectionSnapshot: r,
3743
3745
  onPromptChange: y,
3744
3746
  onSubmit: be,
3745
3747
  onStop: () => {
3746
- L.current?.abort(), B(), Jr(e), _("input");
3748
+ R.current?.abort(), V(), Jr(e), _("input");
3747
3749
  },
3748
3750
  onAccept: xe,
3749
3751
  onRetry: () => be(b),
3750
- onDiscard: () => V(!0),
3752
+ onDiscard: () => fe(!0),
3751
3753
  onPopoverRef: ge
3752
3754
  }) : null,
3753
3755
  m === "link" ? /* @__PURE__ */ Z(Mc, {
3754
- inputRef: se,
3756
+ inputRef: ae,
3755
3757
  messages: n,
3756
3758
  value: E,
3757
- canApply: !!fe,
3758
- canOpen: !!fe,
3759
+ canApply: !!de,
3760
+ canOpen: !!de,
3759
3761
  canRemove: !!(O || E.trim()),
3760
3762
  onValueChange: D,
3761
3763
  onApply: we,
3762
3764
  onOpen: () => Lr(E),
3763
- onRemove: U,
3765
+ onRemove: Te,
3764
3766
  onPopoverRef: ge
3765
3767
  }) : null,
3766
3768
  m === "color" ? /* @__PURE__ */ Z(Rc, {
@@ -3777,14 +3779,14 @@ function jc({ editor: e, lang: t = "zh", messages: n = uc, selectionSnapshot: r,
3777
3779
  onTooltipChange: d,
3778
3780
  onClose: () => h(null)
3779
3781
  }) : null,
3780
- de && m === null ? /* @__PURE__ */ Z("div", {
3782
+ ue && m === null ? /* @__PURE__ */ Z("div", {
3781
3783
  className: "markweave-floating-toolbar-tooltip",
3782
3784
  role: "tooltip",
3783
3785
  "data-testid": "markweave-floating-toolbar-tooltip",
3784
- "data-button-id": de.buttonId,
3785
- "data-active": de.active,
3786
+ "data-button-id": ue.buttonId,
3787
+ "data-active": ue.active,
3786
3788
  style: mc(f),
3787
- children: de.label
3789
+ children: ue.label
3788
3790
  }) : null
3789
3791
  ]
3790
3792
  })
@@ -3954,7 +3956,7 @@ function Nc({ inputRef: e, messages: t, phase: n, prompt: r, hasStreamedContent:
3954
3956
  });
3955
3957
  }
3956
3958
  function Pc({ button: e, expanded: t, showDivider: n, tooltipActive: r, onPointerDown: i, onTooltipChange: a, onRun: o }) {
3957
- return /* @__PURE__ */ Q(X, { children: [n ? /* @__PURE__ */ Z("span", {
3959
+ return /* @__PURE__ */ Q(mt, { children: [n ? /* @__PURE__ */ Z("span", {
3958
3960
  className: "markweave-floating-toolbar-divider",
3959
3961
  "aria-hidden": "true"
3960
3962
  }) : null, /* @__PURE__ */ Z("button", {
@@ -4095,7 +4097,7 @@ function Bc({ editor: e, messages: t, activeTooltipId: n, onPopoverRef: r, onToo
4095
4097
  });
4096
4098
  }
4097
4099
  function Vc({ action: e, active: t, tooltipActive: n, showDivider: r, onTooltipChange: i, onRun: a }) {
4098
- return /* @__PURE__ */ Q(X, { children: [r ? /* @__PURE__ */ Z("span", {
4100
+ return /* @__PURE__ */ Q(mt, { children: [r ? /* @__PURE__ */ Z("span", {
4099
4101
  className: "markweave-floating-toolbar-divider",
4100
4102
  "aria-hidden": "true"
4101
4103
  }) : null, /* @__PURE__ */ Q("span", {
@@ -4125,35 +4127,35 @@ var Uc = {
4125
4127
  sparkles: we,
4126
4128
  "arrow-up": x,
4127
4129
  check: A,
4128
- "chevron-down": ee,
4129
- "chevron-up": te,
4130
- "corner-down-left": ae,
4131
- "external-link": P,
4130
+ "chevron-down": M,
4131
+ "chevron-up": ee,
4132
+ "corner-down-left": re,
4133
+ "external-link": I,
4132
4134
  bold: D,
4133
- italic: ue,
4135
+ italic: le,
4134
4136
  underline: Fe,
4135
- strike: Ee,
4136
- "inline-code": re,
4137
- link: fe,
4137
+ strike: De,
4138
+ "inline-code": te,
4139
+ link: de,
4138
4140
  more: me,
4139
4141
  text: Pe,
4140
- "bullet-list": B,
4142
+ "bullet-list": V,
4141
4143
  "numbered-list": H,
4142
- "todo-list": V,
4144
+ "todo-list": fe,
4143
4145
  quote: ye,
4144
4146
  "code-block": O,
4145
- superscript: Oe,
4146
- subscript: De,
4147
+ superscript: ke,
4148
+ subscript: Oe,
4147
4149
  math: Se,
4148
4150
  "align-left": f,
4149
4151
  "align-center": u,
4150
4152
  "align-right": p,
4151
4153
  "align-justify": d,
4152
- "decrease-indent": z,
4153
- "increase-indent": ce,
4154
- trash: Ne,
4154
+ "decrease-indent": B,
4155
+ "increase-indent": se,
4156
+ trash: U,
4155
4157
  "rotate-ccw": xe,
4156
- square: U,
4158
+ square: Te,
4157
4159
  x: Re
4158
4160
  };
4159
4161
  function $({ name: e }) {
@@ -4296,7 +4298,7 @@ function Wc({ editor: e, messages: t, onClose: n, target: r }) {
4296
4298
  className: "markweave-math-block-toolbar",
4297
4299
  children: [
4298
4300
  /* @__PURE__ */ Z("span", { children: u.label }),
4299
- /* @__PURE__ */ Z(re, {
4301
+ /* @__PURE__ */ Z(te, {
4300
4302
  "aria-hidden": "true",
4301
4303
  size: 15,
4302
4304
  strokeWidth: 1.75
@@ -4353,25 +4355,25 @@ function Wc({ editor: e, messages: t, onClose: n, target: r }) {
4353
4355
  //#endregion
4354
4356
  //#region src/ui/slash-command/SlashCommandMenu.tsx
4355
4357
  var Gc = t("zh"), Kc = {
4356
- type: Me,
4357
- "heading-1": se,
4358
- "heading-2": F,
4359
- "heading-3": I,
4360
- "bullet-list": B,
4358
+ type: Ne,
4359
+ "heading-1": ae,
4360
+ "heading-2": L,
4361
+ "heading-3": oe,
4362
+ "bullet-list": V,
4361
4363
  "ordered-list": H,
4362
- "task-list": V,
4364
+ "task-list": fe,
4363
4365
  blockquote: ye,
4364
4366
  "code-block": O,
4365
- info: le,
4366
- tip: de,
4367
+ info: ce,
4368
+ tip: ue,
4367
4369
  warning: l,
4368
- error: ne,
4370
+ error: P,
4369
4371
  success: j,
4370
4372
  emoji: Ce,
4371
4373
  math: Se,
4372
- table: ke,
4374
+ table: Ae,
4373
4375
  separator: pe,
4374
- image: L,
4376
+ image: R,
4375
4377
  video: Le,
4376
4378
  attachment: ge
4377
4379
  };
@@ -4491,7 +4493,7 @@ function Zc({ command: e, messages: t, onBack: n, onSelect: r }) {
4491
4493
  }
4492
4494
  function Qc({ command: e, messages: t, onBack: n, onSelect: r, onUpload: i }) {
4493
4495
  let a = e.uploadKind ?? "attachment", [o, s] = J(""), [c, l] = J(null), [u, d] = J(null), [f, p] = J(!1), m = async (t) => {
4494
- r(e, { uploadResult: await mt({
4496
+ r(e, { uploadResult: await X({
4495
4497
  kind: a,
4496
4498
  source: t,
4497
4499
  trigger: a === "attachment" ? "attachment-insert" : "slash-command"
@@ -4596,7 +4598,7 @@ function $c({ commands: e, messages: t = Gc, state: n, position: r, inputCommand
4596
4598
  maxHeight: r.maxHeight,
4597
4599
  "--markweave-slash-menu-max-height": `${r.maxHeight}px`
4598
4600
  }, h = (e) => o?.(e), g = () => o?.(null);
4599
- return /* @__PURE__ */ Q(X, { children: [/* @__PURE__ */ Z("div", {
4601
+ return /* @__PURE__ */ Q(mt, { children: [/* @__PURE__ */ Z("div", {
4600
4602
  id: "markweave-slash-command-listbox",
4601
4603
  className: "markweave-slash-menu",
4602
4604
  style: m,
@@ -4688,13 +4690,13 @@ var el = t("zh"), tl = {
4688
4690
  "sort-desc": S,
4689
4691
  color: he,
4690
4692
  alignment: f,
4691
- clear: Te,
4692
- duplicate: ie,
4693
- copy: ie,
4694
- merge: Ae,
4695
- split: je,
4693
+ clear: Ee,
4694
+ duplicate: ne,
4695
+ copy: ne,
4696
+ merge: je,
4697
+ split: Me,
4696
4698
  "ask-ai": we,
4697
- delete: Ne
4699
+ delete: U
4698
4700
  }, nl = {
4699
4701
  left: f,
4700
4702
  center: u,
@@ -4704,7 +4706,7 @@ var el = t("zh"), tl = {
4704
4706
  bottom: h
4705
4707
  };
4706
4708
  function rl({ active: e, editor: t, interactionState: n = zn, messages: r = el, onCopyPayload: i, onCommandResult: a, askAi: o }) {
4707
- let [s, c] = J(null), [l, u] = J(null), [d, f] = J("row-edge"), [p, m] = J(null), [h, g] = J(null), [_, v] = J(null), [y, b] = J(null), [x, S] = J(null), [C, w] = J(null), [T, E] = J(null), [, D] = J(0), O = q(null), k = q(null), [A, j] = J(null), ee = q(null), te = q(null), ne = q(null), re = q(null), ie = q(null), ae = q(null), N = q(null), P = e ? Ln(t.state) : null;
4709
+ let [s, c] = J(null), [l, u] = J(null), [d, f] = J("row-edge"), [p, m] = J(null), [h, g] = J(null), [_, v] = J(null), [y, b] = J(null), [x, S] = J(null), [C, w] = J(null), [T, E] = J(null), [, D] = J(0), O = q(null), k = q(null), [A, j] = J(null), M = q(null), ee = q(null), P = q(null), te = q(null), ne = q(null), re = q(null), F = q(null), I = e ? Ln(t.state) : null;
4708
4710
  if (G(() => {
4709
4711
  if (!A) return;
4710
4712
  let e = window.setTimeout(() => {
@@ -4734,7 +4736,7 @@ function rl({ active: e, editor: t, interactionState: n = zn, messages: r = el,
4734
4736
  return;
4735
4737
  }
4736
4738
  let r = () => {
4737
- let e = t.view.dom.closest(".markweave-editor-frame") ?? t.view.dom.parentElement, r = Ti(t, n, "row", P?.activeCellPos ?? null), i = Ti(t, n, "column", P?.activeCellPos ?? null), a = r ? wi(t, r) : null, o = i ? wi(t, i) : null, c = ki(t, "selection").length > 0 ? Ai(t) : null, l = xi(t)?.getBoundingClientRect() ?? null;
4739
+ let e = t.view.dom.closest(".markweave-editor-frame") ?? t.view.dom.parentElement, r = Ti(t, n, "row", I?.activeCellPos ?? null), i = Ti(t, n, "column", I?.activeCellPos ?? null), a = r ? wi(t, r) : null, o = i ? wi(t, i) : null, c = ki(t, "selection").length > 0 ? Ai(t) : null, l = xi(t)?.getBoundingClientRect() ?? null;
4738
4740
  if (!e) {
4739
4741
  v(null), b(null), S(null), w(null), E(null);
4740
4742
  return;
@@ -4770,9 +4772,9 @@ function rl({ active: e, editor: t, interactionState: n = zn, messages: r = el,
4770
4772
  }, [
4771
4773
  e,
4772
4774
  t,
4773
- P?.activeCellPos,
4774
- P?.selectionFrom,
4775
- P?.selectionTo,
4775
+ I?.activeCellPos,
4776
+ I?.selectionFrom,
4777
+ I?.selectionTo,
4776
4778
  n.hoverCellPos,
4777
4779
  n.hoverVisualColumnIndex,
4778
4780
  n.hoverVisualRowIndex,
@@ -4784,7 +4786,7 @@ function rl({ active: e, editor: t, interactionState: n = zn, messages: r = el,
4784
4786
  return;
4785
4787
  }
4786
4788
  let n = () => {
4787
- let e = t.view.dom.closest(".markweave-editor-frame") ?? t.view.dom.parentElement, n = d === "row-edge" ? ie.current : d === "column-edge" ? ae.current : N.current, r = te.current;
4789
+ let e = t.view.dom.closest(".markweave-editor-frame") ?? t.view.dom.parentElement, n = d === "row-edge" ? ne.current : d === "column-edge" ? re.current : F.current, r = ee.current;
4788
4790
  if (!e || !n || !r) {
4789
4791
  m(null);
4790
4792
  return;
@@ -4794,7 +4796,7 @@ function rl({ active: e, editor: t, interactionState: n = zn, messages: r = el,
4794
4796
  top: a.top,
4795
4797
  width: i.width,
4796
4798
  height: i.height
4797
- } : i, c = e.getBoundingClientRect(), l = r.getBoundingClientRect(), u = ne.current?.scrollHeight ?? 0, f = u > 0 ? u + 12 : 0, p = mi({
4799
+ } : i, c = e.getBoundingClientRect(), l = r.getBoundingClientRect(), u = P.current?.scrollHeight ?? 0, f = u > 0 ? u + 12 : 0, p = mi({
4798
4800
  anchorRect: o,
4799
4801
  frameRect: c,
4800
4802
  boundaryRect: Ei(e),
@@ -4823,7 +4825,7 @@ function rl({ active: e, editor: t, interactionState: n = zn, messages: r = el,
4823
4825
  return;
4824
4826
  }
4825
4827
  let n = () => {
4826
- let e = t.view.dom.closest(".markweave-editor-frame") ?? t.view.dom.parentElement, n = te.current, r = re.current, i = n?.querySelector(`[data-submenu-trigger="${l}"]`);
4828
+ let e = t.view.dom.closest(".markweave-editor-frame") ?? t.view.dom.parentElement, n = ee.current, r = te.current, i = n?.querySelector(`[data-submenu-trigger="${l}"]`);
4827
4829
  if (!e || !n || !r || !i) {
4828
4830
  g(null);
4829
4831
  return;
@@ -4840,7 +4842,7 @@ function rl({ active: e, editor: t, interactionState: n = zn, messages: r = el,
4840
4842
  }));
4841
4843
  };
4842
4844
  n();
4843
- let r = ne.current;
4845
+ let r = P.current;
4844
4846
  return r?.addEventListener("scroll", n), window.addEventListener("resize", n), window.addEventListener("scroll", n, !0), () => {
4845
4847
  r?.removeEventListener("scroll", n), window.removeEventListener("resize", n), window.removeEventListener("scroll", n, !0);
4846
4848
  };
@@ -4861,7 +4863,7 @@ function rl({ active: e, editor: t, interactionState: n = zn, messages: r = el,
4861
4863
  c(null), u(null), t.view.focus();
4862
4864
  }
4863
4865
  }, r = (e) => {
4864
- e.target instanceof Node && ee.current?.contains(e.target) || (c(null), u(null));
4866
+ e.target instanceof Node && M.current?.contains(e.target) || (c(null), u(null));
4865
4867
  };
4866
4868
  return document.addEventListener("keydown", n), document.addEventListener("mousedown", r), () => {
4867
4869
  document.removeEventListener("keydown", n), document.removeEventListener("mousedown", r);
@@ -4872,17 +4874,17 @@ function rl({ active: e, editor: t, interactionState: n = zn, messages: r = el,
4872
4874
  s,
4873
4875
  l
4874
4876
  ]), !e) return null;
4875
- let oe = (e, t) => {
4877
+ let ie = (e, t) => {
4876
4878
  let n = s === e && d === t;
4877
4879
  f(t), c(n ? null : e), u(null);
4878
- }, se = () => {
4880
+ }, ae = () => {
4879
4881
  t.view.dispatch(li(t.state.tr, null));
4880
- }, F = (e, r) => {
4881
- let i = n.hoverCellPos ?? P?.activeCellPos ?? null, a = n.hoverCellPos === null ? null : e === "row" ? n.hoverVisualRowIndex : n.hoverVisualColumnIndex;
4882
- i !== null && Ni(t, i, e, { visualIndex: a }), oe(e, r);
4883
- }, I = () => {
4884
- se(), oe("selection", "selection-edge");
4885
- }, L = Ti(t, n, "row", P?.activeCellPos ?? null), R = Ti(t, n, "column", P?.activeCellPos ?? null), z = o?.enabled === !0 && typeof o.handler == "function", ce = ui(t.state, "structure"), le = ki(t, "selection", { askAiEnabled: z }).length > 0, ue = s ? ki(t, s, { askAiEnabled: z }) : [], de = async (e, n) => {
4882
+ }, L = (e, r) => {
4883
+ let i = n.hoverCellPos ?? I?.activeCellPos ?? null, a = n.hoverCellPos === null ? null : e === "row" ? n.hoverVisualRowIndex : n.hoverVisualColumnIndex;
4884
+ i !== null && Ni(t, i, e, { visualIndex: a }), ie(e, r);
4885
+ }, oe = () => {
4886
+ ae(), ie("selection", "selection-edge");
4887
+ }, R = Ti(t, n, "row", I?.activeCellPos ?? null), z = Ti(t, n, "column", I?.activeCellPos ?? null), B = o?.enabled === !0 && typeof o.handler == "function", se = ui(t.state, "structure"), ce = ki(t, "selection", { askAiEnabled: B }).length > 0, le = s ? ki(t, s, { askAiEnabled: B }) : [], ue = async (e, n) => {
4886
4888
  let o = await yi({
4887
4889
  editor: t,
4888
4890
  commandId: e,
@@ -4890,15 +4892,15 @@ function rl({ active: e, editor: t, interactionState: n = zn, messages: r = el,
4890
4892
  messages: r
4891
4893
  });
4892
4894
  return o.copyFeedback ? (j(o.copyFeedback), o.copyPayload && i?.(o.copyPayload)) : j(null), a?.(o.commandResult), o.success;
4893
- }, fe = (e) => {
4894
- !z || !ai(t, e) || (c(null), u(null));
4895
- }, B = (e) => {
4896
- s !== "row" && s !== "column" || e(s) && D((e) => e + 1);
4895
+ }, de = (e) => {
4896
+ !B || !ai(t, e) || (c(null), u(null));
4897
4897
  }, V = (e) => {
4898
- let r = e === "row" ? L : R, i = n.hoverCellPos ?? P?.activeCellPos ?? null;
4899
- !r || i === null || zi(t, i, e, { visualIndex: r.index }) && de(e === "row" ? "add-row-after" : "add-column-after", e);
4898
+ s !== "row" && s !== "column" || e(s) && D((e) => e + 1);
4899
+ }, fe = (e) => {
4900
+ let r = e === "row" ? R : z, i = n.hoverCellPos ?? I?.activeCellPos ?? null;
4901
+ !r || i === null || zi(t, i, e, { visualIndex: r.index }) && ue(e === "row" ? "add-row-after" : "add-column-after", e);
4900
4902
  }, H = (e, t, n) => {
4901
- if (!ce) {
4903
+ if (!se) {
4902
4904
  n.preventDefault();
4903
4905
  return;
4904
4906
  }
@@ -4915,7 +4917,7 @@ function rl({ active: e, editor: t, interactionState: n = zn, messages: r = el,
4915
4917
  }
4916
4918
  }, he = s === "row" || s === "column" ? Ci(t, s) : null;
4917
4919
  return /* @__PURE__ */ Q("div", {
4918
- ref: ee,
4920
+ ref: M,
4919
4921
  className: "markweave-table-controls",
4920
4922
  "data-testid": "markweave-table-controls",
4921
4923
  "aria-label": r.table.controlsAriaLabel,
@@ -4937,30 +4939,30 @@ function rl({ active: e, editor: t, interactionState: n = zn, messages: r = el,
4937
4939
  }) : null,
4938
4940
  _ ? /* @__PURE__ */ Z("button", {
4939
4941
  type: "button",
4940
- ref: ie,
4942
+ ref: ne,
4941
4943
  className: "markweave-table-edge-handle markweave-table-edge-handle--row",
4942
4944
  "aria-label": r.table.activeRowActions,
4943
4945
  "aria-expanded": s === "row" && d === "row-edge",
4944
4946
  "aria-haspopup": "menu",
4945
4947
  title: r.table.rowActions,
4946
4948
  "data-testid": "markweave-table-hover-row-handle",
4947
- "data-axis-index": L?.index ?? "",
4948
- "data-axis-selected-cells": L?.selectedCellCount ?? "",
4949
- "data-axis-visual-cells": L?.visualCellCount ?? "",
4950
- "data-axis-visual-size": L?.visualHeight ?? "",
4949
+ "data-axis-index": R?.index ?? "",
4950
+ "data-axis-selected-cells": R?.selectedCellCount ?? "",
4951
+ "data-axis-visual-cells": R?.visualCellCount ?? "",
4952
+ "data-axis-visual-size": R?.visualHeight ?? "",
4951
4953
  style: {
4952
4954
  left: _.left,
4953
4955
  top: _.top,
4954
4956
  width: _.width,
4955
4957
  height: _.height
4956
4958
  },
4957
- draggable: ce,
4958
- onDragStart: (e) => H("row", L?.index ?? 0, e),
4959
+ draggable: se,
4960
+ onDragStart: (e) => H("row", R?.index ?? 0, e),
4959
4961
  onDragEnd: () => {
4960
4962
  O.current = null, k.current = null;
4961
4963
  },
4962
4964
  onClick: () => {
4963
- F("row", "row-edge");
4965
+ L("row", "row-edge");
4964
4966
  },
4965
4967
  children: /* @__PURE__ */ Z(me, {
4966
4968
  "aria-hidden": "true",
@@ -4969,37 +4971,37 @@ function rl({ active: e, editor: t, interactionState: n = zn, messages: r = el,
4969
4971
  }) : null,
4970
4972
  y ? /* @__PURE__ */ Z("button", {
4971
4973
  type: "button",
4972
- ref: ae,
4974
+ ref: re,
4973
4975
  className: "markweave-table-edge-handle markweave-table-edge-handle--column",
4974
4976
  "aria-label": r.table.activeColumnActions,
4975
4977
  "aria-expanded": s === "column" && d === "column-edge",
4976
4978
  "aria-haspopup": "menu",
4977
4979
  title: r.table.columnActions,
4978
4980
  "data-testid": "markweave-table-hover-column-handle",
4979
- "data-axis-index": R?.index ?? "",
4980
- "data-axis-selected-cells": R?.selectedCellCount ?? "",
4981
- "data-axis-visual-cells": R?.visualCellCount ?? "",
4982
- "data-axis-visual-size": R?.visualWidth ?? "",
4981
+ "data-axis-index": z?.index ?? "",
4982
+ "data-axis-selected-cells": z?.selectedCellCount ?? "",
4983
+ "data-axis-visual-cells": z?.visualCellCount ?? "",
4984
+ "data-axis-visual-size": z?.visualWidth ?? "",
4983
4985
  style: {
4984
4986
  left: y.left,
4985
4987
  top: y.top,
4986
4988
  width: y.width,
4987
4989
  height: y.height
4988
4990
  },
4989
- draggable: ce,
4990
- onDragStart: (e) => H("column", R?.index ?? 0, e),
4991
+ draggable: se,
4992
+ onDragStart: (e) => H("column", z?.index ?? 0, e),
4991
4993
  onDragEnd: () => {
4992
4994
  O.current = null, k.current = null;
4993
4995
  },
4994
4996
  onClick: () => {
4995
- F("column", "column-edge");
4997
+ L("column", "column-edge");
4996
4998
  },
4997
4999
  children: /* @__PURE__ */ Z(me, {
4998
5000
  "aria-hidden": "true",
4999
5001
  size: 14
5000
5002
  })
5001
5003
  }) : null,
5002
- ce && C ? /* @__PURE__ */ Z("button", {
5004
+ se && C ? /* @__PURE__ */ Z("button", {
5003
5005
  type: "button",
5004
5006
  className: "markweave-table-extend-button markweave-table-extend-button--row",
5005
5007
  "aria-label": r.table.addRow,
@@ -5012,13 +5014,13 @@ function rl({ active: e, editor: t, interactionState: n = zn, messages: r = el,
5012
5014
  height: C.height
5013
5015
  },
5014
5016
  onMouseDown: (e) => e.preventDefault(),
5015
- onClick: () => V("row"),
5017
+ onClick: () => fe("row"),
5016
5018
  children: /* @__PURE__ */ Z(ve, {
5017
5019
  "aria-hidden": "true",
5018
5020
  size: 16
5019
5021
  })
5020
5022
  }) : null,
5021
- ce && T ? /* @__PURE__ */ Z("button", {
5023
+ se && T ? /* @__PURE__ */ Z("button", {
5022
5024
  type: "button",
5023
5025
  className: "markweave-table-extend-button markweave-table-extend-button--column",
5024
5026
  "aria-label": r.table.addColumn,
@@ -5031,15 +5033,15 @@ function rl({ active: e, editor: t, interactionState: n = zn, messages: r = el,
5031
5033
  height: T.height
5032
5034
  },
5033
5035
  onMouseDown: (e) => e.preventDefault(),
5034
- onClick: () => V("column"),
5036
+ onClick: () => fe("column"),
5035
5037
  children: /* @__PURE__ */ Z(ve, {
5036
5038
  "aria-hidden": "true",
5037
5039
  size: 16
5038
5040
  })
5039
5041
  }) : null,
5040
- le && x ? /* @__PURE__ */ Z("button", {
5042
+ ce && x ? /* @__PURE__ */ Z("button", {
5041
5043
  type: "button",
5042
- ref: N,
5044
+ ref: F,
5043
5045
  className: "markweave-table-edge-handle markweave-table-edge-handle--selection",
5044
5046
  "aria-label": r.table.selectionActions,
5045
5047
  "aria-expanded": s === "selection" && d === "selection-edge",
@@ -5053,14 +5055,14 @@ function rl({ active: e, editor: t, interactionState: n = zn, messages: r = el,
5053
5055
  height: x.height
5054
5056
  },
5055
5057
  onMouseDown: (e) => e.preventDefault(),
5056
- onClick: I,
5058
+ onClick: oe,
5057
5059
  children: /* @__PURE__ */ Z(me, {
5058
5060
  "aria-hidden": "true",
5059
5061
  size: 14
5060
5062
  })
5061
5063
  }) : null,
5062
5064
  s ? /* @__PURE__ */ Q("div", {
5063
- ref: te,
5065
+ ref: ee,
5064
5066
  className: "markweave-table-menu",
5065
5067
  role: "menu",
5066
5068
  "aria-label": Li(s, r),
@@ -5075,11 +5077,11 @@ function rl({ active: e, editor: t, interactionState: n = zn, messages: r = el,
5075
5077
  onKeyDown: pe,
5076
5078
  children: [
5077
5079
  /* @__PURE__ */ Z("div", {
5078
- ref: ne,
5080
+ ref: P,
5079
5081
  className: "markweave-table-menu-scroll",
5080
5082
  style: p ? { maxHeight: Math.max(1, p.maxHeight - 12) } : void 0,
5081
- children: ue.map((e, n) => {
5082
- let i = Di(e), a = n === 0 ? i : Di(ue[n - 1]), o = n > 0 && a !== i, d = s === "row" || s === "column" ? s : "selection", f = e.submenuId ? !0 : e.id === "edit-with-ai" ? z && qr(t, d) : e.commandId === null ? !1 : vi(t, e.commandId), p = Oi(e, r), m = tl[e.icon];
5083
+ children: le.map((e, n) => {
5084
+ let i = Di(e), a = n === 0 ? i : Di(le[n - 1]), o = n > 0 && a !== i, d = s === "row" || s === "column" ? s : "selection", f = e.submenuId ? !0 : e.id === "edit-with-ai" ? B && qr(t, d) : e.commandId === null ? !1 : vi(t, e.commandId), p = Oi(e, r), m = tl[e.icon];
5083
5085
  return /* @__PURE__ */ Q("button", {
5084
5086
  type: "button",
5085
5087
  role: "menuitem",
@@ -5088,14 +5090,14 @@ function rl({ active: e, editor: t, interactionState: n = zn, messages: r = el,
5088
5090
  "aria-haspopup": e.submenuId ? "menu" : void 0,
5089
5091
  "aria-expanded": e.submenuId ? l === e.submenuId : void 0,
5090
5092
  disabled: !f,
5091
- title: e.id === "edit-with-ai" && z && !f ? r.askAi.tableMergedUnsupported : void 0,
5093
+ title: e.id === "edit-with-ai" && B && !f ? r.askAi.tableMergedUnsupported : void 0,
5092
5094
  "data-menu-group": i,
5093
5095
  "data-starts-group": o ? "true" : "false",
5094
5096
  "data-command-enabled": f ? "true" : "false",
5095
5097
  "data-submenu-trigger": e.submenuId ?? void 0,
5096
5098
  "data-testid": e.commandId ? `markweave-table-menu-command-${e.commandId}` : e.submenuId ? `markweave-table-menu-submenu-${e.submenuId}` : "markweave-table-menu-command-edit-with-ai",
5097
5099
  onMouseDown: (t) => {
5098
- t.preventDefault(), f && e.id === "edit-with-ai" && fe(d);
5100
+ t.preventDefault(), f && e.id === "edit-with-ai" && de(d);
5099
5101
  },
5100
5102
  onMouseEnter: () => u(e.submenuId),
5101
5103
  onClick: (t) => {
@@ -5105,10 +5107,10 @@ function rl({ active: e, editor: t, interactionState: n = zn, messages: r = el,
5105
5107
  return;
5106
5108
  }
5107
5109
  if (e.commandId === null) {
5108
- t.detail === 0 && fe(d);
5110
+ t.detail === 0 && de(d);
5109
5111
  return;
5110
5112
  }
5111
- de(e.commandId).finally(() => {
5113
+ ue(e.commandId).finally(() => {
5112
5114
  c(null), u(null);
5113
5115
  });
5114
5116
  }
@@ -5126,7 +5128,7 @@ function rl({ active: e, editor: t, interactionState: n = zn, messages: r = el,
5126
5128
  className: "markweave-table-menu-item-label",
5127
5129
  children: p
5128
5130
  }),
5129
- e.submenuId ? /* @__PURE__ */ Z(M, {
5131
+ e.submenuId ? /* @__PURE__ */ Z(N, {
5130
5132
  className: "markweave-table-menu-chevron",
5131
5133
  "aria-hidden": "true",
5132
5134
  size: 16
@@ -5136,7 +5138,7 @@ function rl({ active: e, editor: t, interactionState: n = zn, messages: r = el,
5136
5138
  })
5137
5139
  }),
5138
5140
  l === "color" && (s === "row" || s === "column") ? /* @__PURE__ */ Q("div", {
5139
- ref: re,
5141
+ ref: te,
5140
5142
  className: "markweave-table-submenu markweave-table-color-menu",
5141
5143
  role: "menu",
5142
5144
  "aria-label": r.table.submenus.color,
@@ -5161,7 +5163,7 @@ function rl({ active: e, editor: t, interactionState: n = zn, messages: r = el,
5161
5163
  "data-active": he?.textColorId === e.id ? "true" : "false",
5162
5164
  "data-testid": `markweave-table-text-color-${e.id}`,
5163
5165
  onMouseDown: (e) => e.preventDefault(),
5164
- onClick: () => B((n) => pi(t, n, e.id)),
5166
+ onClick: () => V((n) => pi(t, n, e.id)),
5165
5167
  children: [/* @__PURE__ */ Z("span", {
5166
5168
  className: "markweave-table-color-swatch markweave-table-text-color-swatch",
5167
5169
  "aria-hidden": "true",
@@ -5180,7 +5182,7 @@ function rl({ active: e, editor: t, interactionState: n = zn, messages: r = el,
5180
5182
  "data-active": he?.backgroundColorId === e.id ? "true" : "false",
5181
5183
  "data-testid": `markweave-table-background-color-${e.id}`,
5182
5184
  onMouseDown: (e) => e.preventDefault(),
5183
- onClick: () => B((n) => fi(t, n, e.id)),
5185
+ onClick: () => V((n) => fi(t, n, e.id)),
5184
5186
  children: [/* @__PURE__ */ Z("span", {
5185
5187
  className: "markweave-table-color-swatch",
5186
5188
  "aria-hidden": "true",
@@ -5190,7 +5192,7 @@ function rl({ active: e, editor: t, interactionState: n = zn, messages: r = el,
5190
5192
  ]
5191
5193
  }) : null,
5192
5194
  l === "alignment" && (s === "row" || s === "column") ? /* @__PURE__ */ Q("div", {
5193
- ref: re,
5195
+ ref: te,
5194
5196
  className: "markweave-table-submenu markweave-table-alignment-menu",
5195
5197
  role: "menu",
5196
5198
  "aria-label": r.table.submenus.alignment,
@@ -5213,7 +5215,7 @@ function rl({ active: e, editor: t, interactionState: n = zn, messages: r = el,
5213
5215
  "data-active": i ? "true" : "false",
5214
5216
  "data-testid": `markweave-table-alignment-${e}`,
5215
5217
  onMouseDown: (e) => e.preventDefault(),
5216
- onClick: () => B((n) => di(t, n, e)),
5218
+ onClick: () => V((n) => di(t, n, e)),
5217
5219
  children: [/* @__PURE__ */ Z(n, {
5218
5220
  "aria-hidden": "true",
5219
5221
  size: 18,
@@ -5231,7 +5233,7 @@ function rl({ active: e, editor: t, interactionState: n = zn, messages: r = el,
5231
5233
  "data-active": i ? "true" : "false",
5232
5234
  "data-testid": `markweave-table-alignment-${e}`,
5233
5235
  onMouseDown: (e) => e.preventDefault(),
5234
- onClick: () => B((n) => di(t, n, e)),
5236
+ onClick: () => V((n) => di(t, n, e)),
5235
5237
  children: [/* @__PURE__ */ Z(n, {
5236
5238
  "aria-hidden": "true",
5237
5239
  size: 18,
@@ -5390,19 +5392,19 @@ function ml(e, t) {
5390
5392
  return r && e.id === r.id && e.label === r.label && e.description === r.description && e.group === r.group && e.disabled === r.disabled && e.disabledReason === r.disabledReason && JSON.stringify(e.icon) === JSON.stringify(r.icon);
5391
5393
  });
5392
5394
  }
5393
- function hl({ askAi: e, ariaLabel: r, autoFocusFirstTableBodyCell: i = !1, autofocus: a = !1, content: o, contentFormat: s, defaultContent: l = "", defaultContentFormat: u, editable: d = !0, innerToc: f = !0, innerTocPlacement: p, lang: m, mode: h = "live", theme: g, canvasColor: _, onEditWithAi: v, onExtractToNote: y, onRewriteSelection: b, onAiEditControllerChange: x, onRuntimeStateChange: S, onSearchControllerChange: C, commandGroups: w, commands: T, builtinCommands: E, editorExtensions: D, onCommandControllerChange: O, onCommandError: k, onSlashCommandUpload: A, onAttachmentDownload: j, onTableCommandResult: ee, onTableCopyPayload: M, tableCapabilities: te, onTocChange: ne, onUpdate: re, linkCardResolver: ie, resolveMediaSource: ae } = {}) {
5394
- let N = We(h), P = Zi(g), oe = Xi(_), se = Ki(p), F = N === "live" && d !== !1, I = At(o === void 0 ? u : s), L = o ?? l, R = typeof L == "string" && L.length >= 2e5, z = o === void 0 && I === "markdown" && R && typeof L == "string", ce = q(z ? L : null), [le, ue] = J(z), de = q({
5395
- editorMode: N,
5396
- effectiveEditable: F
5395
+ function hl({ askAi: e, ariaLabel: r, autoFocusFirstTableBodyCell: i = !1, autofocus: a = !1, content: o, contentFormat: s, defaultContent: l = "", defaultContentFormat: u, editable: d = !0, innerToc: f = !0, innerTocPlacement: p, lang: m, mode: h = "live", theme: g, canvasColor: _, onEditWithAi: v, onExtractToNote: y, onRewriteSelection: b, onAiEditControllerChange: x, onRuntimeStateChange: S, onSearchControllerChange: C, commandGroups: w, commands: T, builtinCommands: E, editorExtensions: D, onCommandControllerChange: O, onCommandError: k, onSlashCommandUpload: A, onAttachmentDownload: j, onTableCommandResult: M, onTableCopyPayload: N, tableCapabilities: ee, onTocChange: P, onUpdate: te, linkCardResolver: ne, resolveMediaSource: re, referenceSuggestion: F, internalLinkCard: I } = {}) {
5396
+ let ie = We(h), ae = Zi(g), L = Xi(_), oe = Ki(p), R = ie === "live" && d !== !1, z = At(o === void 0 ? u : s), B = o ?? l, se = typeof B == "string" && B.length >= 2e5, ce = o === void 0 && z === "markdown" && se && typeof B == "string", le = q(ce ? B : null), [ue, de] = J(ce), V = q({
5397
+ editorMode: ie,
5398
+ effectiveEditable: R
5397
5399
  });
5398
- de.current = {
5399
- editorMode: N,
5400
- effectiveEditable: F
5400
+ V.current = {
5401
+ editorMode: ie,
5402
+ effectiveEditable: R
5401
5403
  };
5402
5404
  let fe = q(null);
5403
5405
  fe.current === null && (fe.current = n(m));
5404
- let B = fe.current, V = K(() => t(B), [B]), H = K(() => Mn({
5405
- lang: B,
5406
+ let H = fe.current, pe = K(() => t(H), [H]), me = K(() => Mn({
5407
+ lang: H,
5406
5408
  commandGroups: w,
5407
5409
  commands: T,
5408
5410
  builtinCommands: E
@@ -5410,140 +5412,159 @@ function hl({ askAi: e, ariaLabel: r, autoFocusFirstTableBodyCell: i = !1, autof
5410
5412
  E,
5411
5413
  w,
5412
5414
  T,
5413
- B
5414
- ]), pe = q(D), me = q(te);
5415
- me.current = te;
5416
- let he = q(A);
5417
- he.current = A;
5418
- let ge = q(j);
5419
- ge.current = j;
5420
- let _e = q(C);
5421
- _e.current = C;
5422
- let ve = q(x);
5423
- ve.current = x;
5424
- let ye = q(O);
5425
- ye.current = O;
5426
- let be = q(k);
5427
- be.current = k;
5428
- let xe = q(ie);
5429
- xe.current = ie;
5430
- let Se = K(() => Da({
5431
- lang: B,
5415
+ H
5416
+ ]), he = q(D), ge = q(ee);
5417
+ ge.current = ee;
5418
+ let _e = q(A);
5419
+ _e.current = A;
5420
+ let ve = q(j);
5421
+ ve.current = j;
5422
+ let ye = q(C);
5423
+ ye.current = C;
5424
+ let be = q(x);
5425
+ be.current = x;
5426
+ let xe = q(O);
5427
+ xe.current = O;
5428
+ let Se = q(k);
5429
+ Se.current = k;
5430
+ let Ce = q(ne);
5431
+ Ce.current = ne;
5432
+ let we = q(F);
5433
+ we.current = F;
5434
+ let Te = q(!!F), Ee = q(!!F?.render), De = q(!!F?.command), Oe = q(I);
5435
+ Oe.current = I;
5436
+ let ke = q(!!I), Ae = q(!!I?.resolve), je = K(() => Da({
5437
+ lang: H,
5432
5438
  onImageUpload: (e) => {
5433
- if (he.current) return he.current(e);
5439
+ if (_e.current) return _e.current(e);
5434
5440
  let t = pt(e);
5435
5441
  if (!t) throw Error("File upload requires an upload handler.");
5436
5442
  return t;
5437
5443
  },
5438
5444
  onVideoUpload: (e) => {
5439
- if (he.current) return he.current(e);
5445
+ if (_e.current) return _e.current(e);
5440
5446
  let t = pt(e);
5441
5447
  if (!t) throw Error("File upload requires an upload handler.");
5442
5448
  return t;
5443
5449
  },
5444
5450
  onAttachmentUpload: (e) => {
5445
- if (he.current) return he.current(e);
5451
+ if (_e.current) return _e.current(e);
5446
5452
  let t = pt(e);
5447
5453
  if (!t) throw Error("File upload requires an upload handler.");
5448
5454
  return t;
5449
5455
  },
5450
- onAttachmentDownload: (e, t) => ge.current?.(e, t),
5451
- linkCardResolver: (e) => xe.current?.(e) ?? Promise.resolve(null),
5452
- resolveMediaSource: ae,
5453
- tableCapabilities: (e) => me.current?.(e),
5454
- editorExtensions: pe.current
5455
- }), [ae, B]), [Ce, we] = J(null), [U, Te] = J(Nn), [Ee, De] = J(null), [Oe, ke] = J(null), [Ae, je] = J(() => gn(H.commands, B)), [Me, Ne] = J(null), [Pe, Fe] = J("code"), [Ie, Le] = J(null), [Re, ze] = J(zn), [Be, Ve] = J(null), [He, Ue] = J(0), Ke = q(!1), qe = q({
5456
+ onAttachmentDownload: (e, t) => ve.current?.(e, t),
5457
+ linkCardResolver: (e) => Ce.current?.(e) ?? Promise.resolve(null),
5458
+ resolveMediaSource: re,
5459
+ tableCapabilities: (e) => ge.current?.(e),
5460
+ referenceSuggestion: Te.current ? {
5461
+ char: we.current?.char,
5462
+ allowSpaces: we.current?.allowSpaces,
5463
+ allowedPrefixes: we.current?.allowedPrefixes,
5464
+ minQueryLength: we.current?.minQueryLength,
5465
+ debounce: we.current?.debounce,
5466
+ items: (e) => we.current?.items(e) ?? [],
5467
+ render: Ee.current ? () => we.current.render() : void 0,
5468
+ command: De.current ? (e) => we.current.command(e) : void 0,
5469
+ onInsert: (e) => we.current?.onInsert?.(e)
5470
+ } : null,
5471
+ internalLinkCard: ke.current ? {
5472
+ isInternalLink: (e) => Oe.current?.isInternalLink(e) ?? !1,
5473
+ resolve: Ae.current ? (e) => Oe.current.resolve(e) : void 0
5474
+ } : null,
5475
+ editorExtensions: he.current
5476
+ }), [re, H]), [Me, Ne] = J(null), [U, Pe] = J(Nn), [Fe, Ie] = J(null), [Le, Re] = J(null), [ze, Be] = J(() => gn(me.commands, H)), [Ve, He] = J(null), [Ue, Ke] = J("code"), [qe, Je] = J(null), [Ye, Xe] = J(zn), [Ze, Qe] = J(null), [$e, et] = J(0), tt = q(!1), nt = q({
5456
5477
  content: o,
5457
- format: I
5458
- }), Je = q(null), Ye = q(null), Xe = q({ onUpdate: re }), Ze = K(() => _n(U.query, Ae), [Ae, U.query]);
5459
- Xe.current = { onUpdate: re }, qe.current = {
5478
+ format: z
5479
+ }), rt = q(null), it = q(null), at = q({ onUpdate: te }), ot = K(() => _n(U.query, ze), [ze, U.query]);
5480
+ at.current = { onUpdate: te }, nt.current = {
5460
5481
  content: o,
5461
- format: I
5482
+ format: z
5462
5483
  };
5463
- let Qe = W(() => {
5464
- Ye.current !== null && (window.clearTimeout(Ye.current), Ye.current = null), Ue((e) => e + 1);
5465
- }, []), $e = W(() => {
5466
- Ye.current !== null && window.clearTimeout(Ye.current), Ye.current = window.setTimeout(() => {
5467
- Ye.current = null, Ue((e) => e + 1);
5484
+ let st = W(() => {
5485
+ it.current !== null && (window.clearTimeout(it.current), it.current = null), et((e) => e + 1);
5486
+ }, []), ct = W(() => {
5487
+ it.current !== null && window.clearTimeout(it.current), it.current = window.setTimeout(() => {
5488
+ it.current = null, et((e) => e + 1);
5468
5489
  }, Vt);
5469
5490
  }, []);
5470
5491
  G(() => () => {
5471
- Ye.current !== null && window.clearTimeout(Ye.current);
5492
+ it.current !== null && window.clearTimeout(it.current);
5472
5493
  }, []);
5473
- let et = W(() => {
5474
- De(null), ke(null), Te(Nn);
5475
- }, []), tt = W((e) => {
5494
+ let lt = W(() => {
5495
+ Ie(null), Re(null), Pe(Nn);
5496
+ }, []), ut = W((e) => {
5476
5497
  let t = Tn(e.state);
5477
5498
  if (!t) {
5478
- Te((e) => e.name === "idle" ? e : Nn), De(null), ke(null);
5499
+ Pe((e) => e.name === "idle" ? e : Nn), Ie(null), Re(null);
5479
5500
  return;
5480
5501
  }
5481
5502
  let n = e.coordsAtPos(t.cursor), r = e.coordsAtPos(t.triggerFrom), i = e.dom.closest(".markweave-editor-frame")?.getBoundingClientRect();
5482
5503
  if (!Dn(r, { frameRect: i })) {
5483
- De(null), ke(null), Te(Nn);
5504
+ Ie(null), Re(null), Pe(Nn);
5484
5505
  return;
5485
5506
  }
5486
5507
  let a = wn(n, {
5487
5508
  frameRect: i,
5488
5509
  triggerRect: r
5489
5510
  });
5490
- De((e) => Sn(e, a) ? e : a), Te((e) => Cn(e, t));
5491
- }, []), nt = W((e) => tt(e.view), [tt]), rt = W((e) => {
5511
+ Ie((e) => Sn(e, a) ? e : a), Pe((e) => Cn(e, t));
5512
+ }, []), Y = W((e) => ut(e.view), [ut]), dt = W((e) => {
5492
5513
  let t = Rt(e);
5493
- we((e) => Pt(e, t) ? e : t);
5514
+ Ne((e) => Pt(e, t) ? e : t);
5494
5515
  let n = dn(e);
5495
- n && (pn(e, n, !0), Le(n));
5516
+ n && (pn(e, n, !0), Je(n));
5496
5517
  let r = Kt(e);
5497
- r.active && r.language === "mermaid" && Fe(r.mermaidPreviewMode);
5498
- }, []), it = W((e) => {
5499
- ze(ul(e));
5500
- }, []), Y = c({
5518
+ r.active && r.language === "mermaid" && Ke(r.mermaidPreviewMode);
5519
+ }, []), ft = W((e) => {
5520
+ Xe(ul(e));
5521
+ }, []), X = c({
5501
5522
  shouldRerenderOnTransaction: !1,
5502
- extensions: Se,
5503
- content: z ? "" : L,
5504
- contentType: Dt(I),
5505
- editable: F,
5523
+ extensions: je,
5524
+ content: ce ? "" : B,
5525
+ contentType: Dt(z),
5526
+ editable: R,
5506
5527
  autofocus: a,
5507
5528
  editorProps: {
5508
5529
  attributes: {
5509
5530
  class: "markweave-editor-surface",
5510
5531
  "data-testid": "markweave-editor-surface",
5511
- "data-markweave-large-document": R ? "true" : "false",
5532
+ "data-markweave-large-document": se ? "true" : "false",
5512
5533
  autocapitalize: "off",
5513
5534
  autocorrect: "off",
5514
5535
  spellcheck: "false",
5515
5536
  translate: "no"
5516
5537
  },
5517
- handleClick: (e, t, n) => de.current.effectiveEditable ? !1 : jt(n),
5538
+ handleClick: (e, t, n) => V.current.effectiveEditable ? !1 : jt(n),
5518
5539
  handleDOMEvents: {
5519
- compositionstart: () => de.current.effectiveEditable ? (Te((e) => Pn(e, { type: "composition-start" })), De(null), !1) : !1,
5520
- compositionend: (e) => (de.current.effectiveEditable && window.setTimeout(() => tt(e), 0), !1),
5540
+ compositionstart: () => V.current.effectiveEditable ? (Pe((e) => Pn(e, { type: "composition-start" })), Ie(null), !1) : !1,
5541
+ compositionend: (e) => (V.current.effectiveEditable && window.setTimeout(() => ut(e), 0), !1),
5521
5542
  click: (e, t) => {
5522
- if (de.current.effectiveEditable) {
5543
+ if (V.current.effectiveEditable) {
5523
5544
  let n = un(e, t);
5524
- return n ? (t.preventDefault(), t.stopPropagation(), et(), mn(e, n, !0), hn(e, n), Le(n), !0) : (Le(null), !1);
5545
+ return n ? (t.preventDefault(), t.stopPropagation(), lt(), mn(e, n, !0), hn(e, n), Je(n), !0) : (Je(null), !1);
5525
5546
  }
5526
5547
  return jt(t);
5527
5548
  }
5528
5549
  }
5529
5550
  },
5530
5551
  onSelectionUpdate: ({ editor: e }) => {
5531
- rt(e);
5552
+ dt(e);
5532
5553
  },
5533
5554
  onCreate: ({ editor: e }) => {
5534
- i && de.current.effectiveEditable && In(e), it(e), rt(e), Qe();
5555
+ i && V.current.effectiveEditable && In(e), ft(e), dt(e), st();
5535
5556
  },
5536
5557
  onTransaction: ({ editor: e, transaction: t }) => {
5537
- it(e), (t.docChanged || Qt(t)) && $e(), t.docChanged && Le((t) => {
5558
+ ft(e), (t.docChanged || Qt(t)) && ct(), t.docChanged && Je((t) => {
5538
5559
  if (!t) return null;
5539
5560
  let n = ln(e, t.pos);
5540
5561
  return n?.kind === t.kind ? n : null;
5541
5562
  });
5542
5563
  },
5543
5564
  onUpdate: ({ editor: e }) => {
5544
- rt(e), de.current.effectiveEditable && nt(e), Ke.current || Xe.current.onUpdate?.(Et(e, { onContentRead: (t, n) => {
5545
- let r = qe.current;
5546
- r.content !== void 0 && t === r.format && (Je.current = {
5565
+ dt(e), V.current.effectiveEditable && Y(e), tt.current || at.current.onUpdate?.(Et(e, { onContentRead: (t, n) => {
5566
+ let r = nt.current;
5567
+ r.content !== void 0 && t === r.format && (rt.current = {
5547
5568
  content: n,
5548
5569
  format: t,
5549
5570
  doc: e.state.doc
@@ -5552,127 +5573,127 @@ function hl({ askAi: e, ariaLabel: r, autoFocusFirstTableBodyCell: i = !1, autof
5552
5573
  }
5553
5574
  });
5554
5575
  G(() => {
5555
- let e = ce.current;
5556
- if (!Y || !e) return;
5576
+ let e = le.current;
5577
+ if (!X || !e) return;
5557
5578
  let t = !1;
5558
5579
  return (async () => {
5559
- Ke.current = !0;
5580
+ tt.current = !0;
5560
5581
  try {
5561
5582
  let n = !0;
5562
5583
  for (let r of Qi(e)) {
5563
5584
  if (await new Promise((e) => window.setTimeout(e, 0)), t) return;
5564
- let e = Y.markdown?.parse(r);
5585
+ let e = X.markdown?.parse(r);
5565
5586
  if (!e) throw Error("Markdown parser is unavailable.");
5566
- let i = Y.schema.nodeFromJSON(e).content, a = n ? Y.state.tr.replaceWith(0, Y.state.doc.content.size, i) : Y.state.tr.insert(Y.state.doc.content.size, i);
5567
- Y.view.dispatch(a.setMeta("addToHistory", !1)), n = !1;
5587
+ let i = X.schema.nodeFromJSON(e).content, a = n ? X.state.tr.replaceWith(0, X.state.doc.content.size, i) : X.state.tr.insert(X.state.doc.content.size, i);
5588
+ X.view.dispatch(a.setMeta("addToHistory", !1)), n = !1;
5568
5589
  }
5569
5590
  if (t) return;
5570
- rt(Y), it(Y), Qe(), ce.current = null, ue(!1);
5591
+ dt(X), ft(X), st(), le.current = null, de(!1);
5571
5592
  } finally {
5572
- Ke.current = !1;
5593
+ tt.current = !1;
5573
5594
  }
5574
5595
  })().catch(() => {
5575
- t || (Y.commands.setContent(e, {
5596
+ t || (X.commands.setContent(e, {
5576
5597
  contentType: "markdown",
5577
5598
  emitUpdate: !1
5578
- }), ce.current = null, ue(!1));
5599
+ }), le.current = null, de(!1));
5579
5600
  }), () => {
5580
5601
  t = !0;
5581
5602
  };
5582
5603
  }, [
5583
- Y,
5584
- Qe,
5585
- rt,
5586
- it
5604
+ X,
5605
+ st,
5606
+ dt,
5607
+ ft
5587
5608
  ]), G(() => {
5588
- if (Y) return _e.current?.($i(Y)), () => {
5589
- _e.current?.(null);
5609
+ if (X) return ye.current?.($i(X)), () => {
5610
+ ye.current?.(null);
5590
5611
  };
5591
- }, [Y]), G(() => {
5592
- if (Y) return ye.current?.(On(Y)), () => ye.current?.(null);
5593
- }, [Y]), G(() => {
5594
- if (!Y) {
5595
- let e = gn(H.commands, B);
5596
- je((t) => ml(t, e) ? t : e);
5612
+ }, [X]), G(() => {
5613
+ if (X) return xe.current?.(On(X)), () => xe.current?.(null);
5614
+ }, [X]), G(() => {
5615
+ if (!X) {
5616
+ let e = gn(me.commands, H);
5617
+ Be((t) => ml(t, e) ? t : e);
5597
5618
  return;
5598
5619
  }
5599
- jn(Y, H, (e) => {
5600
- Ne(e.message), be.current?.(e);
5601
- }), An(Y, I);
5620
+ jn(X, me, (e) => {
5621
+ He(e.message), Se.current?.(e);
5622
+ }), An(X, z);
5602
5623
  }, [
5603
- I,
5604
- H,
5605
- Y,
5606
- B
5624
+ z,
5625
+ me,
5626
+ X,
5627
+ H
5607
5628
  ]), G(() => {
5608
- if (!Y) return;
5609
- let e = gn(On(Y).getCommands({
5629
+ if (!X) return;
5630
+ let e = gn(On(X).getCommands({
5610
5631
  surface: "slash",
5611
5632
  query: U.query
5612
- }), B);
5613
- je((t) => ml(t, e) ? t : e);
5633
+ }), H);
5634
+ Be((t) => ml(t, e) ? t : e);
5614
5635
  }, [
5636
+ me,
5637
+ X,
5638
+ R,
5615
5639
  H,
5616
- Y,
5617
- F,
5618
- B,
5619
- He,
5620
- Ce,
5640
+ $e,
5641
+ Me,
5621
5642
  U.query
5622
5643
  ]), G(() => {
5623
- if (Y) return ve.current?.(ea(Y)), () => {
5624
- ve.current?.(null);
5644
+ if (X) return be.current?.(ea(X)), () => {
5645
+ be.current?.(null);
5625
5646
  };
5626
- }, [Y]), G(() => {
5627
- if (!Y) return;
5628
- let e = F && !le;
5629
- Y.setEditable(e), Ge(Y, {
5630
- mode: N,
5647
+ }, [X]), G(() => {
5648
+ if (!X) return;
5649
+ let e = R && !ue;
5650
+ X.setEditable(e), Ge(X, {
5651
+ mode: ie,
5631
5652
  editable: e
5632
- }), en(Y, e ? "live" : "view"), Qe(), F || et();
5653
+ }), en(X, e ? "live" : "view"), st(), R || lt();
5633
5654
  }, [
5634
- et,
5635
- Y,
5636
- N,
5637
- F,
5638
- Qe,
5639
- le
5655
+ lt,
5656
+ X,
5657
+ ie,
5658
+ R,
5659
+ st,
5660
+ ue
5640
5661
  ]), G(() => {
5641
- Y && $t(Y, P);
5642
- }, [Y, P]), G(() => {
5662
+ X && $t(X, ae);
5663
+ }, [X, ae]), G(() => {
5643
5664
  let e = At(s);
5644
- if (!(!Y || o === void 0)) {
5645
- if (kt(Y, Je.current, o, e)) {
5646
- Je.current = null;
5665
+ if (!(!X || o === void 0)) {
5666
+ if (kt(X, rt.current, o, e)) {
5667
+ rt.current = null;
5647
5668
  return;
5648
5669
  }
5649
- Je.current = null, !Ot(Y, o, e) && (Ke.current = !0, Y.commands.setContent(o, {
5670
+ rt.current = null, !Ot(X, o, e) && (tt.current = !0, X.commands.setContent(o, {
5650
5671
  contentType: Dt(e),
5651
5672
  emitUpdate: !1
5652
- }), Ke.current = !1, rt(Y), F && nt(Y), it(Y), Qe());
5673
+ }), tt.current = !1, dt(X), R && Y(X), ft(X), st());
5653
5674
  }
5654
5675
  }, [
5655
5676
  o,
5656
5677
  s,
5657
- F,
5678
+ R,
5679
+ X,
5680
+ st,
5681
+ dt,
5658
5682
  Y,
5659
- Qe,
5660
- rt,
5661
- nt,
5662
- it
5683
+ ft
5663
5684
  ]), G(() => {
5664
- if (!Ee) return;
5685
+ if (!Fe) return;
5665
5686
  let e = (e) => {
5666
5687
  let t = e.target;
5667
- t instanceof Element && (t.closest(".markweave-slash-menu") || et());
5688
+ t instanceof Element && (t.closest(".markweave-slash-menu") || lt());
5668
5689
  };
5669
5690
  return document.addEventListener("pointerdown", e, !0), () => document.removeEventListener("pointerdown", e, !0);
5670
- }, [et, Ee]);
5671
- let at = Ee !== null;
5691
+ }, [lt, Fe]);
5692
+ let mt = Fe !== null;
5672
5693
  G(() => {
5673
- if (!Y || !at) return;
5694
+ if (!X || !mt) return;
5674
5695
  let e = Tt(() => {
5675
- Y.isDestroyed || tt(Y.view);
5696
+ X.isDestroyed || ut(X.view);
5676
5697
  }), t = (t) => {
5677
5698
  t?.type === "scroll" && En(t.target) || e.schedule();
5678
5699
  };
@@ -5680,129 +5701,129 @@ function hl({ askAi: e, ariaLabel: r, autoFocusFirstTableBodyCell: i = !1, autof
5680
5701
  e.cancel(), window.removeEventListener("resize", t), window.removeEventListener("scroll", t, !0);
5681
5702
  };
5682
5703
  }, [
5683
- Y,
5684
- at,
5685
- tt
5704
+ X,
5705
+ mt,
5706
+ ut
5686
5707
  ]);
5687
- let ot = K(() => Y ? Kt(Y) : cl, [
5688
- Y,
5689
- He,
5690
- Ce
5691
- ]), st = K(() => Y ? Ln(Y.state) : sl, [
5692
- Y,
5693
- He,
5694
- Ce,
5695
- Re
5696
- ]), ct = Ce?.currentNode === "codeBlock", lt = ct && ot.language === "mermaid", ut = K(() => Y ? nn({
5697
- active: lt,
5698
- mode: Pe,
5699
- source: ot.text
5708
+ let Z = K(() => X ? Kt(X) : cl, [
5709
+ X,
5710
+ $e,
5711
+ Me
5712
+ ]), Q = K(() => X ? Ln(X.state) : sl, [
5713
+ X,
5714
+ $e,
5715
+ Me,
5716
+ Ye
5717
+ ]), ht = Me?.currentNode === "codeBlock", gt = ht && Z.language === "mermaid", _t = K(() => X ? nn({
5718
+ active: gt,
5719
+ mode: Ue,
5720
+ source: Z.text
5700
5721
  }) : ll, [
5701
- ot.text,
5702
- Y,
5703
- lt,
5704
- Pe
5705
- ]), dt = K(() => Y && S ? Fn(Y.state) : null, [
5706
- Y,
5722
+ Z.text,
5723
+ X,
5724
+ gt,
5725
+ Ue
5726
+ ]), vt = K(() => X && S ? Fn(X.state) : null, [
5727
+ X,
5707
5728
  S,
5708
- He
5709
- ]), ft = K(() => Y ? Wi(Y.state) : Vi.items, [Y, He]), mt = K(() => Gi(ft, Be), [Be, ft]), X = K(() => Bi(ft, mt), [mt, ft]), Z = W(() => {
5710
- if (!Y || !ft.length) {
5711
- Ve(null);
5729
+ $e
5730
+ ]), yt = K(() => X ? Wi(X.state) : Vi.items, [X, $e]), bt = K(() => Gi(yt, Ze), [Ze, yt]), xt = K(() => Bi(yt, bt), [bt, yt]), St = W(() => {
5731
+ if (!X || !yt.length) {
5732
+ Qe(null);
5712
5733
  return;
5713
5734
  }
5714
- let e = Hi(Y, ft);
5715
- Ve((t) => t === e ? t : e);
5716
- }, [Y, ft]);
5735
+ let e = Hi(X, yt);
5736
+ Qe((t) => t === e ? t : e);
5737
+ }, [X, yt]);
5717
5738
  G(() => {
5718
- Ve((e) => {
5719
- let t = Gi(ft, e);
5739
+ Qe((e) => {
5740
+ let t = Gi(yt, e);
5720
5741
  return e === t ? e : t;
5721
5742
  });
5722
- }, [ft]), G(() => {
5723
- if (!Y || !ft.length || typeof window > "u") return;
5743
+ }, [yt]), G(() => {
5744
+ if (!X || !yt.length || typeof window > "u") return;
5724
5745
  let e = null, t = () => {
5725
5746
  e !== null && pl(e), e = fl(() => {
5726
- e = null, Z();
5747
+ e = null, St();
5727
5748
  });
5728
- }, n = dl(Y.view.dom);
5749
+ }, n = dl(X.view.dom);
5729
5750
  return window.addEventListener("scroll", t, { passive: !0 }), window.addEventListener("resize", t), n?.addEventListener("scroll", t, { passive: !0 }), t(), () => {
5730
5751
  window.removeEventListener("scroll", t), window.removeEventListener("resize", t), n?.removeEventListener("scroll", t), e !== null && pl(e);
5731
5752
  };
5732
5753
  }, [
5733
- Y,
5734
- ft.length,
5735
- Z
5754
+ X,
5755
+ yt.length,
5756
+ St
5736
5757
  ]);
5737
- let Q = K(() => Mt({
5738
- revision: He,
5739
- mode: N,
5740
- editable: F,
5741
- toc: X,
5742
- selection: Ce,
5758
+ let Ct = K(() => Mt({
5759
+ revision: $e,
5760
+ mode: ie,
5761
+ editable: R,
5762
+ toc: xt,
5763
+ selection: Me,
5743
5764
  slash: U,
5744
- table: st,
5745
- tableInteraction: Re,
5746
- codeBlock: ot,
5747
- mermaid: ut,
5748
- tableDebugSnapshot: dt
5765
+ table: Q,
5766
+ tableInteraction: Ye,
5767
+ codeBlock: Z,
5768
+ mermaid: _t,
5769
+ tableDebugSnapshot: vt
5749
5770
  }), [
5750
- ot,
5751
- N,
5752
- F,
5753
- ut,
5754
- He,
5755
- Ce,
5771
+ Z,
5772
+ ie,
5773
+ R,
5774
+ _t,
5775
+ $e,
5776
+ Me,
5756
5777
  U,
5757
- dt,
5758
- st,
5759
- Re,
5760
- X
5778
+ vt,
5779
+ Q,
5780
+ Ye,
5781
+ xt
5761
5782
  ]);
5762
5783
  G(() => {
5763
- S?.(Q);
5764
- }, [S, Q]), G(() => {
5765
- ne?.(X);
5766
- }, [ne, X]);
5767
- let ht = W((e, t) => {
5768
- if (!Y || !F || !yn(e)) return;
5784
+ S?.(Ct);
5785
+ }, [S, Ct]), G(() => {
5786
+ P?.(xt);
5787
+ }, [P, xt]);
5788
+ let Nt = W((e, t) => {
5789
+ if (!X || !R || !yn(e)) return;
5769
5790
  if (e.inputKind && !t?.emoji && !t?.uploadResult) {
5770
- ke(e);
5791
+ Re(e);
5771
5792
  return;
5772
5793
  }
5773
- let n = Tn(Y.state);
5774
- n && (Ne(null), Te((e) => Pn(e, { type: "execute" })), ke(null), kn(Y, e.id, n, t).then((e) => {
5794
+ let n = Tn(X.state);
5795
+ n && (He(null), Pe((e) => Pn(e, { type: "execute" })), Re(null), kn(X, e.id, n, t).then((e) => {
5775
5796
  if (e.ok && e.outcome === "applied") {
5776
- et();
5797
+ lt();
5777
5798
  return;
5778
5799
  }
5779
- e.ok || Ne(e.message), nt(Y), Y.commands.focus();
5800
+ e.ok || He(e.message), Y(X), X.commands.focus();
5780
5801
  }));
5781
5802
  }, [
5782
- et,
5783
- F,
5784
- Y,
5785
- nt
5786
- ]), gt = W((e) => {
5787
- Te((t) => Pn(t, {
5803
+ lt,
5804
+ R,
5805
+ X,
5806
+ Y
5807
+ ]), Ft = W((e) => {
5808
+ Pe((t) => Pn(t, {
5788
5809
  type: "set-active",
5789
5810
  index: e,
5790
- optionCount: Ze.length
5811
+ optionCount: ot.length
5791
5812
  }));
5792
- }, [Ze.length]), _t = W((e) => {
5793
- if (!Y || Oe || !F) return;
5813
+ }, [ot.length]), It = W((e) => {
5814
+ if (!X || Le || !R) return;
5794
5815
  if (U.name === "executing" && e.key === "Escape") {
5795
- e.preventDefault(), On(Y).cancel(), et();
5816
+ e.preventDefault(), On(X).cancel(), lt();
5796
5817
  return;
5797
5818
  }
5798
- let t = bn(U, Ze, e.key, { isComposing: e.nativeEvent.isComposing || wt(Y.state) });
5819
+ let t = bn(U, ot, e.key, { isComposing: e.nativeEvent.isComposing || wt(X.state) });
5799
5820
  if (t.type !== "ignore") {
5800
5821
  if (t.type === "close") {
5801
- e.preventDefault(), On(Y).cancel(), Te((e) => Pn(e, { type: "escape" })), et();
5822
+ e.preventDefault(), On(X).cancel(), Pe((e) => Pn(e, { type: "escape" })), lt();
5802
5823
  return;
5803
5824
  }
5804
5825
  if (t.type === "move-active") {
5805
- e.preventDefault(), Te((e) => Pn(e, {
5826
+ e.preventDefault(), Pe((e) => Pn(e, {
5806
5827
  type: "move-active",
5807
5828
  delta: t.delta,
5808
5829
  optionCount: t.optionCount
@@ -5810,162 +5831,162 @@ function hl({ askAi: e, ariaLabel: r, autoFocusFirstTableBodyCell: i = !1, autof
5810
5831
  return;
5811
5832
  }
5812
5833
  if (t.type === "set-active") {
5813
- e.preventDefault(), Te((e) => Pn(e, t));
5834
+ e.preventDefault(), Pe((e) => Pn(e, t));
5814
5835
  return;
5815
5836
  }
5816
- t.type === "execute-active" && (e.preventDefault(), ht(t.command));
5837
+ t.type === "execute-active" && (e.preventDefault(), Nt(t.command));
5817
5838
  }
5818
5839
  }, [
5819
- et,
5820
- F,
5821
- Y,
5822
- Ze,
5823
- ht,
5824
- Oe,
5840
+ lt,
5841
+ R,
5842
+ X,
5843
+ ot,
5844
+ Nt,
5845
+ Le,
5825
5846
  U
5826
- ]), vt = K(() => ({
5827
- closeSlashMenu: et,
5828
- focusFirstTableBodyCell: () => Y ? In(Y) : !1,
5847
+ ]), Lt = K(() => ({
5848
+ closeSlashMenu: lt,
5849
+ focusFirstTableBodyCell: () => X ? In(X) : !1,
5829
5850
  setContent: (e, t = {}) => {
5830
- if (!Y) return !1;
5851
+ if (!X) return !1;
5831
5852
  let n = At(t.format);
5832
- return Y.commands.setContent(e, {
5853
+ return X.commands.setContent(e, {
5833
5854
  contentType: Dt(n),
5834
5855
  emitUpdate: t.emitUpdate ?? !1
5835
- }), t.focusFirstTableBodyCell && In(Y), rt(Y), F && nt(Y), it(Y), Qe(), !0;
5856
+ }), t.focusFirstTableBodyCell && In(X), dt(X), R && Y(X), ft(X), st(), !0;
5836
5857
  }
5837
5858
  }), [
5838
- et,
5839
- F,
5859
+ lt,
5860
+ R,
5861
+ X,
5862
+ st,
5863
+ dt,
5840
5864
  Y,
5841
- Qe,
5842
- rt,
5843
- nt,
5844
- it
5865
+ ft
5845
5866
  ]);
5846
5867
  return {
5847
- editor: Y,
5868
+ editor: X,
5848
5869
  frameProps: K(() => ({
5849
5870
  className: "markweave-editor-frame",
5850
5871
  role: "combobox",
5851
- "aria-label": r ?? V.common.editorAriaLabel,
5852
- "aria-expanded": Ee !== null && U.name !== "executing",
5872
+ "aria-label": r ?? pe.common.editorAriaLabel,
5873
+ "aria-expanded": Fe !== null && U.name !== "executing",
5853
5874
  "aria-controls": "markweave-slash-command-listbox",
5854
- "aria-activedescendant": Ze.length && U.name !== "executing" ? `markweave-slash-command-option-${Math.min(Ze.length - 1, Math.max(0, U.activeIndex))}` : void 0,
5875
+ "aria-activedescendant": ot.length && U.name !== "executing" ? `markweave-slash-command-option-${Math.min(ot.length - 1, Math.max(0, U.activeIndex))}` : void 0,
5855
5876
  "data-testid": "markweave-editor-frame",
5856
- "data-markweave-mode": N,
5857
- "aria-busy": le || U.name === "executing",
5858
- "data-markweave-large-document-loading": le ? "true" : "false",
5859
- "data-markweave-theme": P,
5860
- style: oe ? { "--markweave-canvas": oe } : void 0,
5877
+ "data-markweave-mode": ie,
5878
+ "aria-busy": ue || U.name === "executing",
5879
+ "data-markweave-large-document-loading": ue ? "true" : "false",
5880
+ "data-markweave-theme": ae,
5881
+ style: L ? { "--markweave-canvas": L } : void 0,
5861
5882
  "data-markweave-inner-toc": f ? "true" : "false",
5862
- "data-markweave-inner-toc-placement": se,
5863
- "data-mermaid-mode": ut.mode,
5864
- "data-table-focus-mode": st.mode,
5865
- onKeyDownCapture: _t
5883
+ "data-markweave-inner-toc-placement": oe,
5884
+ "data-mermaid-mode": _t.mode,
5885
+ "data-table-focus-mode": Q.mode,
5886
+ onKeyDownCapture: It
5866
5887
  }), [
5867
5888
  r,
5868
- N,
5869
- Ze.length,
5870
- _t,
5889
+ ie,
5890
+ ot.length,
5891
+ It,
5871
5892
  f,
5872
- le,
5873
- ut.mode,
5874
- V.common.editorAriaLabel,
5893
+ ue,
5894
+ _t.mode,
5895
+ pe.common.editorAriaLabel,
5896
+ L,
5875
5897
  oe,
5876
- se,
5877
- P,
5878
- Ee,
5898
+ ae,
5899
+ Fe,
5879
5900
  U.activeIndex,
5880
5901
  U.name,
5881
- st.mode
5902
+ Q.mode
5882
5903
  ]),
5883
5904
  overlayProps: K(() => ({
5884
- floatingToolbar: Y && F ? {
5885
- editor: Y,
5886
- lang: B,
5887
- messages: V,
5888
- selectionSnapshot: Ce,
5905
+ floatingToolbar: X && R ? {
5906
+ editor: X,
5907
+ lang: H,
5908
+ messages: pe,
5909
+ selectionSnapshot: Me,
5889
5910
  askAi: e,
5890
5911
  onRewriteSelection: b,
5891
5912
  onExtractToNote: y
5892
5913
  } : null,
5893
- slashCommandMenu: Y && F ? {
5894
- commands: Ze,
5914
+ slashCommandMenu: X && R ? {
5915
+ commands: ot,
5895
5916
  state: U,
5896
- position: Ee,
5897
- inputCommand: Oe,
5917
+ position: Fe,
5918
+ inputCommand: Le,
5898
5919
  busy: U.name === "executing",
5899
- error: Me,
5900
- messages: V,
5901
- onActiveIndexChange: gt,
5902
- onInputCommandChange: ke,
5903
- onSelect: ht,
5920
+ error: Ve,
5921
+ messages: pe,
5922
+ onActiveIndexChange: Ft,
5923
+ onInputCommandChange: Re,
5924
+ onSelect: Nt,
5904
5925
  onUpload: A
5905
5926
  } : null,
5906
- tableControls: Y && F ? {
5907
- editor: Y,
5908
- active: st.active,
5909
- interactionState: Re,
5910
- messages: V,
5911
- onCopyPayload: M,
5912
- onCommandResult: ee,
5927
+ tableControls: X && R ? {
5928
+ editor: X,
5929
+ active: Q.active,
5930
+ interactionState: Ye,
5931
+ messages: pe,
5932
+ onCopyPayload: N,
5933
+ onCommandResult: M,
5913
5934
  onEditWithAi: v,
5914
5935
  askAi: e
5915
5936
  } : null,
5916
- tableSelectionOverlay: Y && F ? {
5917
- editor: Y,
5918
- focusState: st
5937
+ tableSelectionOverlay: X && R ? {
5938
+ editor: X,
5939
+ focusState: Q
5919
5940
  } : null,
5920
- codeBlockControls: Y ? {
5921
- editor: Y,
5922
- active: F && ct,
5923
- mermaidMode: Pe,
5924
- onMermaidModeChange: Fe,
5925
- readOnly: !F
5941
+ codeBlockControls: X ? {
5942
+ editor: X,
5943
+ active: R && ht,
5944
+ mermaidMode: Ue,
5945
+ onMermaidModeChange: Ke,
5946
+ readOnly: !R
5926
5947
  } : null,
5927
- innerToc: Y && f && X.items.length ? {
5928
- editor: Y,
5929
- editable: F,
5930
- messages: V,
5931
- placement: se,
5932
- state: X
5948
+ innerToc: X && f && xt.items.length ? {
5949
+ editor: X,
5950
+ editable: R,
5951
+ messages: pe,
5952
+ placement: oe,
5953
+ state: xt
5933
5954
  } : null,
5934
- mathEditorPopover: Y && F && Ie ? {
5935
- editor: Y,
5936
- messages: V,
5937
- target: Ie,
5938
- onClose: () => Le(null)
5955
+ mathEditorPopover: X && R && qe ? {
5956
+ editor: X,
5957
+ messages: pe,
5958
+ target: qe,
5959
+ onClose: () => Je(null)
5939
5960
  } : null
5940
5961
  }), [
5941
- F,
5962
+ R,
5942
5963
  e,
5943
- Y,
5944
- Ze,
5964
+ X,
5965
+ ot,
5945
5966
  f,
5946
- ct,
5947
- Pe,
5948
- V,
5949
- Ie,
5967
+ ht,
5968
+ Ue,
5969
+ pe,
5970
+ qe,
5950
5971
  v,
5951
5972
  y,
5952
5973
  b,
5953
5974
  A,
5954
- ee,
5955
5975
  M,
5956
- ht,
5957
- Ce,
5958
- gt,
5959
- Oe,
5976
+ N,
5977
+ Nt,
5960
5978
  Me,
5961
- Ee,
5979
+ Ft,
5980
+ Le,
5981
+ Ve,
5982
+ Fe,
5962
5983
  U,
5963
- st,
5964
- Re,
5965
- X
5984
+ Q,
5985
+ Ye,
5986
+ xt
5966
5987
  ]),
5967
- runtimeSnapshot: Q,
5968
- actions: vt
5988
+ runtimeSnapshot: Ct,
5989
+ actions: Lt
5969
5990
  };
5970
5991
  }
5971
5992
  function gl({ className: e, ...t }) {