@meowdown/react 0.83.2 → 0.85.0

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.
Files changed (3) hide show
  1. package/dist/index.js +1002 -251
  2. package/dist/style.css +15 -86
  3. package/package.json +3 -4
package/dist/index.js CHANGED
@@ -1,19 +1,19 @@
1
1
  import { c } from "react/compiler-runtime";
2
2
  import { clsx } from "clsx/lite";
3
3
  import { Fragment, ViewTransition, cloneElement, createContext, createElement, memo, startTransition, use, useDeferredValue, useEffect, useId, useImperativeHandle, useLayoutEffect, useReducer, useRef, useState } from "react";
4
- import { buildFileMarkdown, codeBlockLanguages, collectReferenceDefinitions, defaultResolveImageUrl, defaultResolveXPost, defaultResolveYouTubeVideo, defineCodeBlockPreviewPlugin, defineEditorExtension, defineLinkEditKeymap, defineLinkHoverHandler, definePendingReplacementHandler, defineSearchStatusHandler, defineVirtualCaret, defineWikilinkHoverHandler, dismissLinkHover, docToMarkdown, docToParagraphMarkdown, formatFileSize, getCodeTokens, getFileKind, getLinkText, getMarkBuilders, getPendingReplacement, getSearchStatus, getSelectedText, getTableColumnAlign, getTextblockDisplayText, getVirtualElementFromRange, inlineTextToMarkChunksWithContext, isCodeBlockPreviewHiddenDecoration, isLinkTextForHref, isModEvent, isNodeOfType, isReferenceDefinitionNode, isSelectionInTableCell, loadKaTeX, markdownToDoc, normalizeHref, paragraphMarkdownToDoc, parsePostEmbedSnapshot, renderMathInto, updateEditorConfig } from "@meowdown/core";
4
+ import { buildFileMarkdown, codeBlockLanguages, collectReferenceDefinitions, convertEmbedToLink, defaultResolveImageUrl, defaultResolveXPost, defaultResolveYouTubeVideo, defineCodeBlockPreviewPlugin, defineEditorExtension, defineEmbedMenuHandler, defineLinkEditKeymap, defineLinkHoverHandler, definePendingReplacementHandler, defineSearchStatusHandler, defineVirtualCaret, defineWikilinkHoverHandler, deleteBlock, deleteEmbed, dismissLinkHover, docToMarkdown, docToParagraphMarkdown, formatFileSize, getCodeTokens, getFileKind, getLinkText, getMarkBuilders, getPendingReplacement, getSearchStatus, getSelectedText, getTableColumnAlign, getTextblockDisplayText, getVirtualElementFromRange, inlineTextToMarkChunksWithContext, isCodeBlockPreviewHiddenDecoration, isLinkTextForHref, isModEvent, isNodeOfType, isReferenceDefinitionNode, isSelectionInTableCell, loadKaTeX, markdownToDoc, normalizeHref, paragraphMarkdownToDoc, parsePostEmbedSnapshot, renderMathInto, updateEditorConfig } from "@meowdown/core";
5
5
  import { clamp } from "@ocavue/utils";
6
- import { canUseRegexLookbehind, createEditor, defineDocChangeHandler, defineUpdateHandler, isTextSelection, union } from "@prosekit/core";
6
+ import { canUseRegexLookbehind, createEditor, defineDocChangeHandler, defineKeymap, defineUpdateHandler, isApple, isTextSelection, union } from "@prosekit/core";
7
7
  import { Selection, TextSelection } from "@prosekit/pm/state";
8
8
  import { ProseKit, defineReactNodeView, useEditor, useEditor as useEditor$1, useEditorDerivedValue, useExtension, useExtension as useExtension$1, useKeymap } from "@prosekit/react";
9
9
  import GithubSlugger from "github-slugger";
10
10
  import { Combobox } from "@base-ui/react/combobox";
11
- import { CheckIcon, ChevronsUpDownIcon, CopyIcon, Globe2Icon, GripHorizontalIcon, GripVerticalIcon, PencilIcon, SparklesIcon, UnlinkIcon } from "lucide-react";
11
+ import { Menu } from "@base-ui/react/menu";
12
12
  import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
13
13
  import { BlockHandleDraggable, BlockHandlePopup, BlockHandlePositioner, BlockHandleRoot } from "@prosekit/react/block-handle";
14
14
  import { DropIndicator } from "@prosekit/react/drop-indicator";
15
- import { Popover } from "@base-ui/react/popover";
16
15
  import { queueExtension } from "@prosekit/web";
16
+ import { Popover } from "@base-ui/react/popover";
17
17
  import { AutocompleteEmpty, AutocompleteItem, AutocompletePopup, AutocompletePositioner, AutocompleteRoot } from "@prosekit/react/autocomplete";
18
18
  import { MenuItem, MenuPopup, MenuPositioner } from "@prosekit/react/menu";
19
19
  import { TableHandleColumnMenuRoot, TableHandleColumnMenuTrigger, TableHandleColumnPopup, TableHandleColumnPositioner, TableHandleDragPreview, TableHandleDropIndicator, TableHandleRoot, TableHandleRowMenuRoot, TableHandleRowMenuTrigger, TableHandleRowPopup, TableHandleRowPositioner } from "@prosekit/react/table-handle";
@@ -24,6 +24,83 @@ import { Mark } from "@prosekit/pm/model";
24
24
  import { BOOLEAN, OVERLOADED_BOOLEAN, getPropertyInfo, possibleStandardNames } from "react-property";
25
25
  import { PreviewCard } from "@base-ui/react/preview-card";
26
26
 
27
+ // \0rolldown/runtime.js
28
+ var __defProp = Object.defineProperty;
29
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
30
+ var __getOwnPropNames = Object.getOwnPropertyNames;
31
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
32
+ var __exportAll = (all, no_symbols) => {
33
+ let target = {};
34
+ for (var name in all) {
35
+ __defProp(target, name, {
36
+ get: all[name],
37
+ enumerable: true
38
+ });
39
+ }
40
+ if (!no_symbols) {
41
+ __defProp(target, Symbol.toStringTag, { value: "Module" });
42
+ }
43
+ return target;
44
+ };
45
+ var __copyProps = (to, from, except, desc) => {
46
+ if (from && typeof from === "object" || typeof from === "function") {
47
+ for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
48
+ key = keys[i];
49
+ if (!__hasOwnProp.call(to, key) && key !== except) {
50
+ __defProp(to, key, {
51
+ get: ((k) => from[k]).bind(null, key),
52
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
53
+ });
54
+ }
55
+ }
56
+ }
57
+ return to;
58
+ };
59
+ var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
60
+
61
+ // src/class-names.ts
62
+ var class_names_exports = /* @__PURE__ */ __exportAll({
63
+ LIGHTBOX_DIALOG_TRANSITION_CLASS: () => LIGHTBOX_DIALOG_TRANSITION_CLASS,
64
+ ROOT_CLASS: () => ROOT_CLASS
65
+ });
66
+ import * as import__meowdown_core_internal_class_names from "@meowdown/core/internal/class-names";
67
+ __reExport(class_names_exports, import__meowdown_core_internal_class_names);
68
+ /**
69
+ * The outer wrapper of the editor.
70
+ */
71
+ const ROOT_CLASS = "meowdown";
72
+ /**
73
+ * The view transition class of the lightbox dialog.
74
+ */
75
+ const LIGHTBOX_DIALOG_TRANSITION_CLASS = "meowdown-lightbox-dialog";
76
+
77
+ // src/extensions/block-menu.ts
78
+ const caretMenuOpeners = /* @__PURE__ */ new WeakMap();
79
+ /**
80
+ * Sets the function that opens the menu of the code block that holds the
81
+ * caret, so that `Mod-/` can open it. Returns a function that clears it.
82
+ */
83
+ function setCaretCodeBlockMenu(view, open) {
84
+ caretMenuOpeners.set(view, open);
85
+ return () => {
86
+ if (caretMenuOpeners.get(view) === open) caretMenuOpeners.delete(view);
87
+ };
88
+ }
89
+ const openCodeBlockMenu = (state, dispatch, view) => {
90
+ const { $from, $to } = state.selection;
91
+ if (!isNodeOfType($from.parent, "codeBlock") || !$from.sameParent($to) || view == null) return false;
92
+ const open = caretMenuOpeners.get(view);
93
+ if (open == null) return false;
94
+ if (dispatch) open();
95
+ return true;
96
+ };
97
+ /**
98
+ * Opens the menu of the code block that holds the selection with `Mod-/`.
99
+ */
100
+ function defineCodeBlockMenuKeymap() {
101
+ return defineKeymap({ "Mod-/": openCodeBlockMenu });
102
+ }
103
+
27
104
  // src/hooks/use-katex.ts
28
105
  /**
29
106
  * The lazily loaded KaTeX render function, or `undefined` while it loads (or when
@@ -104,9 +181,179 @@ const NON_PROSE_PROPS = {
104
181
  writingsuggestions: "false"
105
182
  };
106
183
 
184
+ // src/utils/write-clipboard-text.ts
185
+ /**
186
+ * Writes `text` to the clipboard. Returns whether the write succeeded.
187
+ */
188
+ async function writeClipboardText(text) {
189
+ try {
190
+ await navigator.clipboard.writeText(text);
191
+ return true;
192
+ } catch (error) {
193
+ console.warn("[meowdown] Failed to copy:", error);
194
+ return false;
195
+ }
196
+ }
197
+
198
+ // src/components/collision-boundary.ts
199
+ /**
200
+ * See `EditorProps.collisionBoundary`.
201
+ */
202
+ const CollisionBoundaryContext = createContext(void 0);
203
+ /**
204
+ * Converts a {@link CollisionBoundary} to the `boundary` prop of ProseKit
205
+ * positioners, which spell the keyword the floating-ui way.
206
+ */
207
+ function toFloatingBoundary(boundary) {
208
+ return boundary === "clipping-ancestors" ? "clippingAncestors" : boundary;
209
+ }
210
+
211
+ // src/components/icon.tsx
212
+ /**
213
+ * A decorative Lucide icon, drawn in `currentColor` by the core stylesheet.
214
+ */
215
+ function Icon(t0) {
216
+ const $ = c(4);
217
+ const { name } = t0;
218
+ let t1;
219
+ if ($[0] !== name) {
220
+ t1 = (0, class_names_exports.getIconClass)(name);
221
+ $[0] = name;
222
+ $[1] = t1;
223
+ } else t1 = $[1];
224
+ const t2 = `${class_names_exports.ICON_CLASS} ${t1}`;
225
+ let t3;
226
+ if ($[2] !== t2) {
227
+ t3 = /* @__PURE__ */ jsx("span", {
228
+ className: t2,
229
+ "aria-hidden": "true"
230
+ });
231
+ $[2] = t2;
232
+ $[3] = t3;
233
+ } else t3 = $[3];
234
+ return t3;
235
+ }
236
+
237
+ // src/components/action-menu.tsx
238
+ /**
239
+ * The popup of an action menu, such as the code block menu or the embed
240
+ * menu, placed below its trigger or `anchor`.
241
+ */
242
+ function ActionMenuPopup(t0) {
243
+ const $ = c(8);
244
+ const { anchor, finalFocus, testId, children } = t0;
245
+ const collisionBoundary = use(CollisionBoundaryContext);
246
+ let t1;
247
+ if ($[0] !== children || $[1] !== finalFocus || $[2] !== testId) {
248
+ t1 = /* @__PURE__ */ jsx(Menu.Popup, {
249
+ className: class_names_exports.MENU_POPUP_CLASS,
250
+ finalFocus,
251
+ "data-testid": testId,
252
+ children
253
+ });
254
+ $[0] = children;
255
+ $[1] = finalFocus;
256
+ $[2] = testId;
257
+ $[3] = t1;
258
+ } else t1 = $[3];
259
+ let t2;
260
+ if ($[4] !== anchor || $[5] !== collisionBoundary || $[6] !== t1) {
261
+ t2 = /* @__PURE__ */ jsx(Menu.Portal, { children: /* @__PURE__ */ jsx(Menu.Positioner, {
262
+ anchor,
263
+ className: class_names_exports.MENU_POSITIONER_CLASS,
264
+ sideOffset: 4,
265
+ align: "start",
266
+ collisionBoundary,
267
+ children: t1
268
+ }) });
269
+ $[4] = anchor;
270
+ $[5] = collisionBoundary;
271
+ $[6] = t1;
272
+ $[7] = t2;
273
+ } else t2 = $[7];
274
+ return t2;
275
+ }
276
+ /**
277
+ * A row of an action menu: an icon and a label.
278
+ */
279
+ function ActionMenuItem(t0) {
280
+ const $ = c(9);
281
+ const { icon, label, onClick, testId } = t0;
282
+ let t1;
283
+ if ($[0] !== icon) {
284
+ t1 = /* @__PURE__ */ jsx(Icon, { name: icon });
285
+ $[0] = icon;
286
+ $[1] = t1;
287
+ } else t1 = $[1];
288
+ let t2;
289
+ if ($[2] !== label) {
290
+ t2 = /* @__PURE__ */ jsx("span", { children: label });
291
+ $[2] = label;
292
+ $[3] = t2;
293
+ } else t2 = $[3];
294
+ let t3;
295
+ if ($[4] !== onClick || $[5] !== t1 || $[6] !== t2 || $[7] !== testId) {
296
+ t3 = /* @__PURE__ */ jsxs(Menu.Item, {
297
+ className: class_names_exports.MENU_ITEM_CLASS,
298
+ onClick,
299
+ "data-testid": testId,
300
+ children: [t1, t2]
301
+ });
302
+ $[4] = onClick;
303
+ $[5] = t1;
304
+ $[6] = t2;
305
+ $[7] = testId;
306
+ $[8] = t3;
307
+ } else t3 = $[8];
308
+ return t3;
309
+ }
310
+
311
+ // src/components/code-block-toolbar-state.ts
312
+ const CODE_BLOCK_TOOLBAR_IDLE = {
313
+ open: void 0,
314
+ closing: [],
315
+ focusReturn: "trigger"
316
+ };
317
+ function switchPopup(state, popup, focusReturn) {
318
+ const closing = state.closing.filter((item) => item !== popup);
319
+ if (state.open != null && state.open !== popup) closing.push(state.open);
320
+ return {
321
+ open: popup,
322
+ closing,
323
+ focusReturn
324
+ };
325
+ }
326
+ function reduceCodeBlockToolbar(state, event) {
327
+ switch (event.type) {
328
+ case "open": return switchPopup(state, event.popup, event.focusReturn);
329
+ case "handOver": return state.open === "menu" ? switchPopup(state, "language", state.focusReturn) : state;
330
+ case "close": return state.open === event.popup ? {
331
+ ...state,
332
+ open: void 0,
333
+ closing: [...state.closing, event.popup]
334
+ } : state;
335
+ case "closed": return state.closing.includes(event.popup) ? {
336
+ ...state,
337
+ closing: state.closing.filter((item) => item !== event.popup)
338
+ } : state;
339
+ }
340
+ }
341
+ /**
342
+ * Whether the toolbar stays shown: a popup is open or plays its exit animation.
343
+ */
344
+ function isCodeBlockToolbarActive(state) {
345
+ return state.open != null || state.closing.length > 0;
346
+ }
347
+ /**
348
+ * Where a closing popup sends the focus. `undefined` when another popup is
349
+ * open and owns the focus.
350
+ */
351
+ function getCodeBlockToolbarFinalFocus(state) {
352
+ return state.open == null ? state.focusReturn : void 0;
353
+ }
354
+
107
355
  // src/components/code-block-view.module.css
108
356
  var code_block_view_module_default = {
109
- "CopyButton": "meow_CopyButton_D3j_9q",
110
357
  "Empty": "meow_Empty_D3j_9q",
111
358
  "Item": "meow_Item_D3j_9q",
112
359
  "ItemIndicator": "meow_ItemIndicator_D3j_9q",
@@ -114,7 +361,6 @@ var code_block_view_module_default = {
114
361
  "List": "meow_List_D3j_9q",
115
362
  "MermaidPreview": "meow_MermaidPreview_D3j_9q",
116
363
  "Popup": "meow_Popup_D3j_9q",
117
- "Positioner": "meow_Positioner_D3j_9q",
118
364
  "Preview": "meow_Preview_D3j_9q",
119
365
  "Root": "meow_Root_D3j_9q",
120
366
  "Search": "meow_Search_D3j_9q",
@@ -124,19 +370,6 @@ var code_block_view_module_default = {
124
370
  "TriggerIcon": "meow_TriggerIcon_D3j_9q"
125
371
  };
126
372
 
127
- // src/components/collision-boundary.ts
128
- /**
129
- * See `EditorProps.collisionBoundary`.
130
- */
131
- const CollisionBoundaryContext = createContext(void 0);
132
- /**
133
- * Converts a {@link CollisionBoundary} to the `boundary` prop of ProseKit
134
- * positioners, which spell the keyword the floating-ui way.
135
- */
136
- function toFloatingBoundary(boundary) {
137
- return boundary === "clipping-ancestors" ? "clippingAncestors" : boundary;
138
- }
139
-
140
373
  // src/components/copy-button.tsx
141
374
  const COPIED_RESET_MS = 1500;
142
375
  /**
@@ -170,12 +403,7 @@ function CopyButton(t0) {
170
403
  let t1;
171
404
  if ($[6] !== getText || $[7] !== onCopy) {
172
405
  t1 = async () => {
173
- try {
174
- await navigator.clipboard.writeText(getText());
175
- } catch (t2) {
176
- console.warn("[meowdown] Failed to copy:", t2);
177
- return;
178
- }
406
+ if (!await writeClipboardText(getText())) return;
179
407
  setCopied(true);
180
408
  clearTimeout(resetTimerRef.current);
181
409
  resetTimerRef.current = setTimeout(() => setCopied(false), COPIED_RESET_MS);
@@ -191,7 +419,7 @@ function CopyButton(t0) {
191
419
  const t4 = copied ? "Copied" : label;
192
420
  let t5;
193
421
  if ($[9] !== copied) {
194
- t5 = copied ? /* @__PURE__ */ jsx(CheckIcon, {}) : /* @__PURE__ */ jsx(CopyIcon, {});
422
+ t5 = copied ? /* @__PURE__ */ jsx(Icon, { name: "check" }) : /* @__PURE__ */ jsx(Icon, { name: "copy" });
195
423
  $[9] = copied;
196
424
  $[10] = t5;
197
425
  } else t5 = $[10];
@@ -383,7 +611,7 @@ function MermaidRender(props) {
383
611
 
384
612
  // src/components/code-block-view.tsx
385
613
  function CodeBlockView(props) {
386
- const $ = c(36);
614
+ const $ = c(39);
387
615
  const { node, view, getPos, decorations, selected, setAttrs, contentRef } = props;
388
616
  const language = node.attrs.language || "";
389
617
  const isMath = language === "math";
@@ -450,20 +678,26 @@ function CodeBlockView(props) {
450
678
  $[13] = t6;
451
679
  } else t6 = $[13];
452
680
  let t7;
453
- if ($[14] !== code || $[15] !== language || $[16] !== selected || $[17] !== setLanguage) {
681
+ if ($[14] !== caretInside || $[15] !== code || $[16] !== getPos || $[17] !== language || $[18] !== selected || $[19] !== setLanguage || $[20] !== view) {
454
682
  t7 = selected ? null : /* @__PURE__ */ jsx(CodeBlockToolbar, {
455
683
  code,
456
684
  language,
457
- setLanguage
685
+ setLanguage,
686
+ view,
687
+ getPos,
688
+ caretInside
458
689
  });
459
- $[14] = code;
460
- $[15] = language;
461
- $[16] = selected;
462
- $[17] = setLanguage;
463
- $[18] = t7;
464
- } else t7 = $[18];
690
+ $[14] = caretInside;
691
+ $[15] = code;
692
+ $[16] = getPos;
693
+ $[17] = language;
694
+ $[18] = selected;
695
+ $[19] = setLanguage;
696
+ $[20] = view;
697
+ $[21] = t7;
698
+ } else t7 = $[21];
465
699
  let t8;
466
- if ($[19] !== focusSource || $[20] !== katex || $[21] !== previewCode || $[22] !== showMathPreview) {
700
+ if ($[22] !== focusSource || $[23] !== katex || $[24] !== previewCode || $[25] !== showMathPreview) {
467
701
  t8 = showMathPreview && /* @__PURE__ */ jsx(MathRender, {
468
702
  katex,
469
703
  formula: previewCode,
@@ -473,30 +707,30 @@ function CodeBlockView(props) {
473
707
  "data-scroll-x": true,
474
708
  onMouseDown: focusSource
475
709
  });
476
- $[19] = focusSource;
477
- $[20] = katex;
478
- $[21] = previewCode;
479
- $[22] = showMathPreview;
480
- $[23] = t8;
481
- } else t8 = $[23];
710
+ $[22] = focusSource;
711
+ $[23] = katex;
712
+ $[24] = previewCode;
713
+ $[25] = showMathPreview;
714
+ $[26] = t8;
715
+ } else t8 = $[26];
482
716
  let t9;
483
- if ($[24] !== focusSource || $[25] !== mermaid || $[26] !== previewCode || $[27] !== showMermaidPreview) {
717
+ if ($[27] !== focusSource || $[28] !== mermaid || $[29] !== previewCode || $[30] !== showMermaidPreview) {
484
718
  t9 = showMermaidPreview && /* @__PURE__ */ jsx(MermaidRender, {
485
719
  renderer: mermaid,
486
720
  source: previewCode,
487
- className: `${code_block_view_module_default.Preview} ${code_block_view_module_default.MermaidPreview}`,
721
+ className: clsx(code_block_view_module_default.Preview, code_block_view_module_default.MermaidPreview),
488
722
  "data-testid": "code-block-mermaid-preview",
489
723
  "data-scroll-x": true,
490
724
  onMouseDown: focusSource
491
725
  });
492
- $[24] = focusSource;
493
- $[25] = mermaid;
494
- $[26] = previewCode;
495
- $[27] = showMermaidPreview;
496
- $[28] = t9;
497
- } else t9 = $[28];
726
+ $[27] = focusSource;
727
+ $[28] = mermaid;
728
+ $[29] = previewCode;
729
+ $[30] = showMermaidPreview;
730
+ $[31] = t9;
731
+ } else t9 = $[31];
498
732
  let t10;
499
- if ($[29] !== t4 || $[30] !== t5 || $[31] !== t6 || $[32] !== t7 || $[33] !== t8 || $[34] !== t9) {
733
+ if ($[32] !== t4 || $[33] !== t5 || $[34] !== t6 || $[35] !== t7 || $[36] !== t8 || $[37] !== t9) {
500
734
  t10 = /* @__PURE__ */ jsxs("div", {
501
735
  className: code_block_view_module_default.Root,
502
736
  "data-preview": t4,
@@ -509,61 +743,329 @@ function CodeBlockView(props) {
509
743
  t9
510
744
  ]
511
745
  });
512
- $[29] = t4;
513
- $[30] = t5;
514
- $[31] = t6;
515
- $[32] = t7;
516
- $[33] = t8;
517
- $[34] = t9;
518
- $[35] = t10;
519
- } else t10 = $[35];
746
+ $[32] = t4;
747
+ $[33] = t5;
748
+ $[34] = t6;
749
+ $[35] = t7;
750
+ $[36] = t8;
751
+ $[37] = t9;
752
+ $[38] = t10;
753
+ } else t10 = $[38];
520
754
  return t10;
521
755
  }
522
756
  function CodeBlockToolbar(t0) {
523
- const $ = c(9);
524
- const { code, language, setLanguage } = t0;
525
- const [comboboxOpen, setComboboxOpen] = useState(false);
526
- const t1 = comboboxOpen || void 0;
757
+ const $ = c(41);
758
+ const { code, language, setLanguage, view, getPos, caretInside } = t0;
759
+ const [state, dispatch] = useReducer(reduceCodeBlockToolbar, CODE_BLOCK_TOOLBAR_IDLE);
760
+ let t1;
761
+ if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
762
+ t1 = (open) => {
763
+ dispatch(open ? {
764
+ type: "open",
765
+ popup: "menu",
766
+ focusReturn: "trigger"
767
+ } : {
768
+ type: "close",
769
+ popup: "menu"
770
+ });
771
+ };
772
+ $[0] = t1;
773
+ } else t1 = $[0];
774
+ const changeMenuOpen = t1;
527
775
  let t2;
528
- if ($[0] !== language || $[1] !== setLanguage) {
529
- t2 = /* @__PURE__ */ jsx(CodeBlockLanguagePickerMemo, {
776
+ if ($[1] === Symbol.for("react.memo_cache_sentinel")) {
777
+ t2 = (open_0) => {
778
+ if (!open_0) dispatch({
779
+ type: "closed",
780
+ popup: "menu"
781
+ });
782
+ };
783
+ $[1] = t2;
784
+ } else t2 = $[1];
785
+ const completeMenuOpenChange = t2;
786
+ let t3;
787
+ if ($[2] === Symbol.for("react.memo_cache_sentinel")) {
788
+ t3 = (open_1) => {
789
+ dispatch(open_1 ? {
790
+ type: "open",
791
+ popup: "language",
792
+ focusReturn: "trigger"
793
+ } : {
794
+ type: "close",
795
+ popup: "language"
796
+ });
797
+ };
798
+ $[2] = t3;
799
+ } else t3 = $[2];
800
+ const changeLanguageOpen = t3;
801
+ let t4;
802
+ if ($[3] === Symbol.for("react.memo_cache_sentinel")) {
803
+ t4 = (open_2) => {
804
+ if (!open_2) dispatch({
805
+ type: "closed",
806
+ popup: "language"
807
+ });
808
+ };
809
+ $[3] = t4;
810
+ } else t4 = $[3];
811
+ const completeLanguageOpenChange = t4;
812
+ let t5;
813
+ let t6;
814
+ if ($[4] !== caretInside || $[5] !== view) {
815
+ t5 = () => {
816
+ if (!caretInside) return;
817
+ return setCaretCodeBlockMenu(view, () => {
818
+ dispatch({
819
+ type: "open",
820
+ popup: "menu",
821
+ focusReturn: "editor"
822
+ });
823
+ });
824
+ };
825
+ t6 = [caretInside, view];
826
+ $[4] = caretInside;
827
+ $[5] = view;
828
+ $[6] = t5;
829
+ $[7] = t6;
830
+ } else {
831
+ t5 = $[6];
832
+ t6 = $[7];
833
+ }
834
+ useEffect(t5, t6);
835
+ let t7;
836
+ if ($[8] !== state) {
837
+ t7 = getCodeBlockToolbarFinalFocus(state);
838
+ $[8] = state;
839
+ $[9] = t7;
840
+ } else t7 = $[9];
841
+ const finalFocus = t7;
842
+ let t8;
843
+ if ($[10] !== finalFocus || $[11] !== view) {
844
+ t8 = () => {
845
+ if (finalFocus !== "editor") return finalFocus === "trigger";
846
+ view.focus();
847
+ return false;
848
+ };
849
+ $[10] = finalFocus;
850
+ $[11] = view;
851
+ $[12] = t8;
852
+ } else t8 = $[12];
853
+ const getFinalFocus = t8;
854
+ let t9;
855
+ if ($[13] === Symbol.for("react.memo_cache_sentinel")) {
856
+ t9 = () => {
857
+ dispatch({ type: "handOver" });
858
+ };
859
+ $[13] = t9;
860
+ } else t9 = $[13];
861
+ const handOverToLanguagePicker = t9;
862
+ let t10;
863
+ if ($[14] !== code) {
864
+ t10 = () => {
865
+ writeClipboardText(code);
866
+ };
867
+ $[14] = code;
868
+ $[15] = t10;
869
+ } else t10 = $[15];
870
+ const copyCode = t10;
871
+ let t11;
872
+ if ($[16] !== getPos || $[17] !== view) {
873
+ t11 = () => {
874
+ const pos = getPos();
875
+ if (pos == null) return;
876
+ deleteBlock(pos)(view.state, view.dispatch);
877
+ view.focus();
878
+ };
879
+ $[16] = getPos;
880
+ $[17] = view;
881
+ $[18] = t11;
882
+ } else t11 = $[18];
883
+ const deleteCodeBlock = t11;
884
+ let t12;
885
+ if ($[19] !== view.editable) {
886
+ t12 = () => view.editable;
887
+ $[19] = view.editable;
888
+ $[20] = t12;
889
+ } else t12 = $[20];
890
+ const canDeleteCodeBlock = t12;
891
+ let t13;
892
+ if ($[21] !== state) {
893
+ t13 = isCodeBlockToolbarActive(state) || void 0;
894
+ $[21] = state;
895
+ $[22] = t13;
896
+ } else t13 = $[22];
897
+ const t14 = state.open === "language";
898
+ let t15;
899
+ if ($[23] !== getFinalFocus || $[24] !== language || $[25] !== setLanguage || $[26] !== t14) {
900
+ t15 = /* @__PURE__ */ jsx(CodeBlockLanguagePickerMemo, {
530
901
  language,
531
902
  setLanguage,
532
- onShownChange: setComboboxOpen
903
+ open: t14,
904
+ onOpenChange: changeLanguageOpen,
905
+ onOpenChangeComplete: completeLanguageOpenChange,
906
+ getFinalFocus
533
907
  });
534
- $[0] = language;
535
- $[1] = setLanguage;
536
- $[2] = t2;
537
- } else t2 = $[2];
538
- let t3;
539
- if ($[3] !== code) {
540
- t3 = /* @__PURE__ */ jsx(CopyButton, {
908
+ $[23] = getFinalFocus;
909
+ $[24] = language;
910
+ $[25] = setLanguage;
911
+ $[26] = t14;
912
+ $[27] = t15;
913
+ } else t15 = $[27];
914
+ let t16;
915
+ if ($[28] !== code) {
916
+ t16 = /* @__PURE__ */ jsx(CopyButton, {
541
917
  getText: () => code,
542
918
  label: "Copy code",
543
- className: code_block_view_module_default.CopyButton,
919
+ className: class_names_exports.ICON_BUTTON_CLASS,
544
920
  "data-testid": "code-block-copy"
545
921
  });
546
- $[3] = code;
547
- $[4] = t3;
548
- } else t3 = $[4];
549
- let t4;
550
- if ($[5] !== t1 || $[6] !== t2 || $[7] !== t3) {
551
- t4 = /* @__PURE__ */ jsxs("div", {
922
+ $[28] = code;
923
+ $[29] = t16;
924
+ } else t16 = $[29];
925
+ const t17 = state.open === "menu";
926
+ let t18;
927
+ if ($[30] !== canDeleteCodeBlock || $[31] !== copyCode || $[32] !== deleteCodeBlock || $[33] !== getFinalFocus || $[34] !== t17) {
928
+ t18 = /* @__PURE__ */ jsx(CodeBlockMenu, {
929
+ open: t17,
930
+ onOpenChange: changeMenuOpen,
931
+ onOpenChangeComplete: completeMenuOpenChange,
932
+ getFinalFocus,
933
+ onChangeLanguage: handOverToLanguagePicker,
934
+ onCopyCode: copyCode,
935
+ onDelete: deleteCodeBlock,
936
+ canDelete: canDeleteCodeBlock
937
+ });
938
+ $[30] = canDeleteCodeBlock;
939
+ $[31] = copyCode;
940
+ $[32] = deleteCodeBlock;
941
+ $[33] = getFinalFocus;
942
+ $[34] = t17;
943
+ $[35] = t18;
944
+ } else t18 = $[35];
945
+ let t19;
946
+ if ($[36] !== t13 || $[37] !== t15 || $[38] !== t16 || $[39] !== t18) {
947
+ t19 = /* @__PURE__ */ jsxs("div", {
552
948
  className: code_block_view_module_default.Toolbar,
553
949
  contentEditable: false,
554
- "data-open": t1,
555
- children: [t2, t3]
950
+ "data-open": t13,
951
+ children: [
952
+ t15,
953
+ t16,
954
+ t18
955
+ ]
556
956
  });
557
- $[5] = t1;
957
+ $[36] = t13;
958
+ $[37] = t15;
959
+ $[38] = t16;
960
+ $[39] = t18;
961
+ $[40] = t19;
962
+ } else t19 = $[40];
963
+ return t19;
964
+ }
965
+ function CodeBlockMenu(t0) {
966
+ const $ = c(12);
967
+ const { open, onOpenChange, onOpenChangeComplete, getFinalFocus, onChangeLanguage, onCopyCode, onDelete, canDelete } = t0;
968
+ let t1;
969
+ if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
970
+ t1 = /* @__PURE__ */ jsx(Menu.Trigger, {
971
+ className: class_names_exports.ICON_BUTTON_CLASS,
972
+ "aria-label": "More",
973
+ title: `More (${isApple ? "⌘/" : "Ctrl+/"})`,
974
+ "data-testid": "code-block-menu",
975
+ children: /* @__PURE__ */ jsx(Icon, { name: "ellipsis" })
976
+ });
977
+ $[0] = t1;
978
+ } else t1 = $[0];
979
+ let t2;
980
+ if ($[1] !== canDelete || $[2] !== getFinalFocus || $[3] !== onChangeLanguage || $[4] !== onCopyCode || $[5] !== onDelete) {
981
+ t2 = /* @__PURE__ */ jsx(CodeBlockMenuPopup, {
982
+ getFinalFocus,
983
+ onChangeLanguage,
984
+ onCopyCode,
985
+ onDelete,
986
+ canDelete
987
+ });
988
+ $[1] = canDelete;
989
+ $[2] = getFinalFocus;
990
+ $[3] = onChangeLanguage;
991
+ $[4] = onCopyCode;
992
+ $[5] = onDelete;
558
993
  $[6] = t2;
559
- $[7] = t3;
560
- $[8] = t4;
561
- } else t4 = $[8];
994
+ } else t2 = $[6];
995
+ let t3;
996
+ if ($[7] !== onOpenChange || $[8] !== onOpenChangeComplete || $[9] !== open || $[10] !== t2) {
997
+ t3 = /* @__PURE__ */ jsxs(Menu.Root, {
998
+ open,
999
+ onOpenChange,
1000
+ onOpenChangeComplete,
1001
+ children: [t1, t2]
1002
+ });
1003
+ $[7] = onOpenChange;
1004
+ $[8] = onOpenChangeComplete;
1005
+ $[9] = open;
1006
+ $[10] = t2;
1007
+ $[11] = t3;
1008
+ } else t3 = $[11];
1009
+ return t3;
1010
+ }
1011
+ function CodeBlockMenuPopup(t0) {
1012
+ const $ = c(12);
1013
+ const { getFinalFocus, onChangeLanguage, onCopyCode, onDelete, canDelete } = t0;
1014
+ let t1;
1015
+ if ($[0] !== onChangeLanguage) {
1016
+ t1 = /* @__PURE__ */ jsx(ActionMenuItem, {
1017
+ icon: "braces",
1018
+ label: "Change language",
1019
+ onClick: onChangeLanguage,
1020
+ testId: "code-block-menu-language"
1021
+ });
1022
+ $[0] = onChangeLanguage;
1023
+ $[1] = t1;
1024
+ } else t1 = $[1];
1025
+ let t2;
1026
+ if ($[2] !== onCopyCode) {
1027
+ t2 = /* @__PURE__ */ jsx(ActionMenuItem, {
1028
+ icon: "copy",
1029
+ label: "Copy code",
1030
+ onClick: onCopyCode,
1031
+ testId: "code-block-menu-copy"
1032
+ });
1033
+ $[2] = onCopyCode;
1034
+ $[3] = t2;
1035
+ } else t2 = $[3];
1036
+ let t3;
1037
+ if ($[4] !== canDelete || $[5] !== onDelete) {
1038
+ t3 = canDelete() && /* @__PURE__ */ jsx(ActionMenuItem, {
1039
+ icon: "trash-2",
1040
+ label: "Delete",
1041
+ onClick: onDelete,
1042
+ testId: "code-block-menu-delete"
1043
+ });
1044
+ $[4] = canDelete;
1045
+ $[5] = onDelete;
1046
+ $[6] = t3;
1047
+ } else t3 = $[6];
1048
+ let t4;
1049
+ if ($[7] !== getFinalFocus || $[8] !== t1 || $[9] !== t2 || $[10] !== t3) {
1050
+ t4 = /* @__PURE__ */ jsxs(ActionMenuPopup, {
1051
+ finalFocus: getFinalFocus,
1052
+ children: [
1053
+ t1,
1054
+ t2,
1055
+ t3
1056
+ ]
1057
+ });
1058
+ $[7] = getFinalFocus;
1059
+ $[8] = t1;
1060
+ $[9] = t2;
1061
+ $[10] = t3;
1062
+ $[11] = t4;
1063
+ } else t4 = $[11];
562
1064
  return t4;
563
1065
  }
564
1066
  function CodeBlockLanguagePicker(t0) {
565
- const $ = c(22);
566
- const { language, setLanguage, onShownChange } = t0;
1067
+ const $ = c(28);
1068
+ const { language, setLanguage, open, onOpenChange, onOpenChangeComplete, getFinalFocus } = t0;
567
1069
  const collisionBoundary = use(CollisionBoundaryContext);
568
1070
  let t1;
569
1071
  if ($[0] !== language) {
@@ -601,105 +1103,123 @@ function CodeBlockLanguagePicker(t0) {
601
1103
  $[5] = t3;
602
1104
  } else t3 = $[5];
603
1105
  let t4;
604
- let t5;
605
- if ($[6] !== onShownChange) {
606
- t4 = (open) => {
607
- if (open) onShownChange(true);
608
- else setQuery("");
1106
+ if ($[6] !== onOpenChangeComplete) {
1107
+ t4 = (open_0) => {
1108
+ onOpenChangeComplete(open_0);
1109
+ if (!open_0) setQuery("");
609
1110
  };
610
- t5 = (open_0) => {
611
- if (!open_0) onShownChange(false);
612
- };
613
- $[6] = onShownChange;
1111
+ $[6] = onOpenChangeComplete;
614
1112
  $[7] = t4;
1113
+ } else t4 = $[7];
1114
+ let t5;
1115
+ if ($[8] === Symbol.for("react.memo_cache_sentinel")) {
1116
+ t5 = /* @__PURE__ */ jsx(Combobox.Value, { placeholder: "Plain Text" });
615
1117
  $[8] = t5;
616
- } else {
617
- t4 = $[7];
618
- t5 = $[8];
619
- }
1118
+ } else t5 = $[8];
620
1119
  let t6;
621
1120
  if ($[9] === Symbol.for("react.memo_cache_sentinel")) {
622
- t6 = /* @__PURE__ */ jsx(Combobox.Value, { placeholder: "Plain Text" });
623
- $[9] = t6;
624
- } else t6 = $[9];
625
- let t7;
626
- if ($[10] === Symbol.for("react.memo_cache_sentinel")) {
627
- t7 = /* @__PURE__ */ jsxs(Combobox.Trigger, {
1121
+ t6 = /* @__PURE__ */ jsxs(Combobox.Trigger, {
628
1122
  className: code_block_view_module_default.Trigger,
629
1123
  "data-testid": "code-block-language",
630
- children: [t6, /* @__PURE__ */ jsx(Combobox.Icon, {
1124
+ children: [t5, /* @__PURE__ */ jsx(Combobox.Icon, {
631
1125
  className: code_block_view_module_default.TriggerIcon,
632
- children: /* @__PURE__ */ jsx(ChevronsUpDownIcon, {})
1126
+ children: /* @__PURE__ */ jsx(Icon, { name: "chevrons-up-down" })
633
1127
  })]
634
1128
  });
1129
+ $[9] = t6;
1130
+ } else t6 = $[9];
1131
+ let t7;
1132
+ if ($[10] === Symbol.for("react.memo_cache_sentinel")) {
1133
+ t7 = clsx(class_names_exports.MENU_POPUP_CLASS, code_block_view_module_default.Popup);
635
1134
  $[10] = t7;
636
1135
  } else t7 = $[10];
1136
+ let t10;
637
1137
  let t8;
1138
+ let t9;
638
1139
  if ($[11] === Symbol.for("react.memo_cache_sentinel")) {
639
- t8 = /* @__PURE__ */ jsxs(Combobox.Popup, {
640
- className: code_block_view_module_default.Popup,
1140
+ t8 = /* @__PURE__ */ jsx("div", {
1141
+ className: code_block_view_module_default.SearchRow,
1142
+ children: /* @__PURE__ */ jsx(Combobox.Input, {
1143
+ className: code_block_view_module_default.Search,
1144
+ placeholder: "Search or type a language",
1145
+ "data-testid": "code-block-language-search"
1146
+ })
1147
+ });
1148
+ t9 = /* @__PURE__ */ jsx(Combobox.Empty, {
1149
+ className: code_block_view_module_default.Empty,
1150
+ children: "No languages found."
1151
+ });
1152
+ t10 = /* @__PURE__ */ jsx(Combobox.List, {
1153
+ className: code_block_view_module_default.List,
1154
+ children: _temp$3
1155
+ });
1156
+ $[11] = t10;
1157
+ $[12] = t8;
1158
+ $[13] = t9;
1159
+ } else {
1160
+ t10 = $[11];
1161
+ t8 = $[12];
1162
+ t9 = $[13];
1163
+ }
1164
+ let t11;
1165
+ if ($[14] !== getFinalFocus) {
1166
+ t11 = /* @__PURE__ */ jsxs(Combobox.Popup, {
1167
+ className: t7,
1168
+ finalFocus: getFinalFocus,
641
1169
  children: [
642
- /* @__PURE__ */ jsx("div", {
643
- className: code_block_view_module_default.SearchRow,
644
- children: /* @__PURE__ */ jsx(Combobox.Input, {
645
- className: code_block_view_module_default.Search,
646
- placeholder: "Search or type a language",
647
- "data-testid": "code-block-language-search"
648
- })
649
- }),
650
- /* @__PURE__ */ jsx(Combobox.Empty, {
651
- className: code_block_view_module_default.Empty,
652
- children: "No languages found."
653
- }),
654
- /* @__PURE__ */ jsx(Combobox.List, {
655
- className: code_block_view_module_default.List,
656
- children: _temp$3
657
- })
1170
+ t8,
1171
+ t9,
1172
+ t10
658
1173
  ]
659
1174
  });
660
- $[11] = t8;
661
- } else t8 = $[11];
662
- let t9;
663
- if ($[12] !== collisionBoundary) {
664
- t9 = /* @__PURE__ */ jsx(Combobox.Portal, { children: /* @__PURE__ */ jsx(Combobox.Positioner, {
665
- className: code_block_view_module_default.Positioner,
1175
+ $[14] = getFinalFocus;
1176
+ $[15] = t11;
1177
+ } else t11 = $[15];
1178
+ let t12;
1179
+ if ($[16] !== collisionBoundary || $[17] !== t11) {
1180
+ t12 = /* @__PURE__ */ jsx(Combobox.Portal, { children: /* @__PURE__ */ jsx(Combobox.Positioner, {
1181
+ className: class_names_exports.MENU_POSITIONER_CLASS,
666
1182
  sideOffset: 4,
667
1183
  collisionBoundary,
668
- children: t8
1184
+ children: t11
669
1185
  }) });
670
- $[12] = collisionBoundary;
671
- $[13] = t9;
672
- } else t9 = $[13];
673
- let t10;
674
- if ($[14] !== itemsForView || $[15] !== query || $[16] !== selected || $[17] !== t3 || $[18] !== t4 || $[19] !== t5 || $[20] !== t9) {
675
- t10 = /* @__PURE__ */ jsxs(Combobox.Root, {
1186
+ $[16] = collisionBoundary;
1187
+ $[17] = t11;
1188
+ $[18] = t12;
1189
+ } else t12 = $[18];
1190
+ let t13;
1191
+ if ($[19] !== itemsForView || $[20] !== onOpenChange || $[21] !== open || $[22] !== query || $[23] !== selected || $[24] !== t12 || $[25] !== t3 || $[26] !== t4) {
1192
+ t13 = /* @__PURE__ */ jsxs(Combobox.Root, {
676
1193
  items: itemsForView,
1194
+ autoHighlight: true,
677
1195
  value: selected,
678
1196
  onValueChange: t3,
679
1197
  inputValue: query,
680
1198
  onInputValueChange: setQuery,
681
- onOpenChange: t4,
682
- onOpenChangeComplete: t5,
683
- children: [t7, t9]
1199
+ open,
1200
+ onOpenChange,
1201
+ onOpenChangeComplete: t4,
1202
+ children: [t6, t12]
684
1203
  });
685
- $[14] = itemsForView;
686
- $[15] = query;
687
- $[16] = selected;
688
- $[17] = t3;
689
- $[18] = t4;
690
- $[19] = t5;
691
- $[20] = t9;
692
- $[21] = t10;
693
- } else t10 = $[21];
694
- return t10;
1204
+ $[19] = itemsForView;
1205
+ $[20] = onOpenChange;
1206
+ $[21] = open;
1207
+ $[22] = query;
1208
+ $[23] = selected;
1209
+ $[24] = t12;
1210
+ $[25] = t3;
1211
+ $[26] = t4;
1212
+ $[27] = t13;
1213
+ } else t13 = $[27];
1214
+ return t13;
695
1215
  }
696
1216
  function _temp$3(item_2) {
697
1217
  return /* @__PURE__ */ jsxs(Combobox.Item, {
698
1218
  value: item_2,
699
- className: code_block_view_module_default.Item,
1219
+ className: clsx(class_names_exports.MENU_ITEM_CLASS, code_block_view_module_default.Item),
700
1220
  children: [/* @__PURE__ */ jsx(Combobox.ItemIndicator, {
701
- className: code_block_view_module_default.ItemIndicator,
702
- children: /* @__PURE__ */ jsx(CheckIcon, {})
1221
+ className: clsx(class_names_exports.MENU_ITEM_INDICATOR_CLASS, code_block_view_module_default.ItemIndicator),
1222
+ children: /* @__PURE__ */ jsx(Icon, { name: "check" })
703
1223
  }), /* @__PURE__ */ jsx("span", {
704
1224
  className: code_block_view_module_default.ItemText,
705
1225
  children: item_2.label
@@ -715,7 +1235,7 @@ function defineCodeBlockView(component = CodeBlockView) {
715
1235
  as: createCodeBlockRoot,
716
1236
  contentAs: "code",
717
1237
  component
718
- }), defineCodeBlockPreviewPlugin());
1238
+ }), defineCodeBlockPreviewPlugin(), defineCodeBlockMenuKeymap());
719
1239
  }
720
1240
  function createCodeBlockRoot() {
721
1241
  const element = document.createElement("div");
@@ -743,7 +1263,7 @@ function BlockHandle() {
743
1263
  children: /* @__PURE__ */ jsx(BlockHandleDraggable, {
744
1264
  className: block_handle_module_default.Draggable,
745
1265
  "data-testid": "block-handle-drag",
746
- children: /* @__PURE__ */ jsx(GripVerticalIcon, {})
1266
+ children: /* @__PURE__ */ jsx(Icon, { name: "grip-vertical" })
747
1267
  })
748
1268
  })
749
1269
  }) });
@@ -844,6 +1364,225 @@ function EditorExtensions(t0) {
844
1364
  return null;
845
1365
  }
846
1366
 
1367
+ // src/components/embed-menu-state.ts
1368
+ const EMBED_MENU_IDLE = { phase: "idle" };
1369
+ function reduceEmbedMenu(state, event) {
1370
+ switch (event.type) {
1371
+ case "toggle":
1372
+ if (state.phase === "open" && state.button === event.button) return {
1373
+ ...state,
1374
+ phase: "closing"
1375
+ };
1376
+ return {
1377
+ phase: "open",
1378
+ embed: event.embed,
1379
+ button: event.button
1380
+ };
1381
+ case "close": return state.phase === "open" ? {
1382
+ ...state,
1383
+ phase: "closing"
1384
+ } : state;
1385
+ case "closed": return state.phase === "closing" ? EMBED_MENU_IDLE : state;
1386
+ }
1387
+ }
1388
+
1389
+ // src/components/embed-menu.tsx
1390
+ /**
1391
+ * The menu of images, X post cards, and YouTube cards, opened from their menu
1392
+ * button or with `Mod-/` while one is selected. One instance serves them all.
1393
+ */
1394
+ function EmbedMenu(t0) {
1395
+ const $ = c(43);
1396
+ const { readOnly: t1 } = t0;
1397
+ const readOnly = t1 === void 0 ? false : t1;
1398
+ const editor = useEditor$1();
1399
+ const [state, dispatch] = useReducer(reduceEmbedMenu, EMBED_MENU_IDLE);
1400
+ let t2;
1401
+ let t3;
1402
+ if ($[0] !== editor) {
1403
+ t2 = () => {
1404
+ const extension = defineEmbedMenuHandler((embed, button) => {
1405
+ dispatch({
1406
+ type: "toggle",
1407
+ embed,
1408
+ button
1409
+ });
1410
+ });
1411
+ return queueExtension(editor, extension);
1412
+ };
1413
+ t3 = [editor];
1414
+ $[0] = editor;
1415
+ $[1] = t2;
1416
+ $[2] = t3;
1417
+ } else {
1418
+ t2 = $[1];
1419
+ t3 = $[2];
1420
+ }
1421
+ useEffect(t2, t3);
1422
+ const open = state.phase === "open";
1423
+ const button_0 = state.phase === "idle" ? void 0 : state.button;
1424
+ const embed_0 = state.phase === "idle" ? void 0 : state.embed;
1425
+ let t4;
1426
+ let t5;
1427
+ if ($[3] !== button_0 || $[4] !== open) {
1428
+ t4 = () => {
1429
+ if (!button_0) return;
1430
+ button_0.setAttribute("aria-expanded", String(open));
1431
+ return () => button_0.removeAttribute("aria-expanded");
1432
+ };
1433
+ t5 = [button_0, open];
1434
+ $[3] = button_0;
1435
+ $[4] = open;
1436
+ $[5] = t4;
1437
+ $[6] = t5;
1438
+ } else {
1439
+ t4 = $[5];
1440
+ t5 = $[6];
1441
+ }
1442
+ useEffect(t4, t5);
1443
+ let t6;
1444
+ if ($[7] !== button_0) {
1445
+ t6 = (next, details) => {
1446
+ if (next) return;
1447
+ const target = details.event.target;
1448
+ if (details.reason === "outside-press" && target instanceof Node && button_0?.contains(target)) {
1449
+ details.cancel();
1450
+ return;
1451
+ }
1452
+ dispatch({ type: "close" });
1453
+ };
1454
+ $[7] = button_0;
1455
+ $[8] = t6;
1456
+ } else t6 = $[8];
1457
+ const changeOpen = t6;
1458
+ let t7;
1459
+ if ($[9] === Symbol.for("react.memo_cache_sentinel")) {
1460
+ t7 = (next_0) => {
1461
+ if (!next_0) dispatch({ type: "closed" });
1462
+ };
1463
+ $[9] = t7;
1464
+ } else t7 = $[9];
1465
+ const completeOpenChange = t7;
1466
+ let t8;
1467
+ if ($[10] !== editor) {
1468
+ t8 = () => {
1469
+ editor.focus();
1470
+ return false;
1471
+ };
1472
+ $[10] = editor;
1473
+ $[11] = t8;
1474
+ } else t8 = $[11];
1475
+ const getFinalFocus = t8;
1476
+ let t9;
1477
+ if ($[12] !== editor || $[13] !== embed_0) {
1478
+ t9 = () => {
1479
+ if (embed_0) editor.exec(convertEmbedToLink(embed_0.from));
1480
+ };
1481
+ $[12] = editor;
1482
+ $[13] = embed_0;
1483
+ $[14] = t9;
1484
+ } else t9 = $[14];
1485
+ const convertToLink = t9;
1486
+ let t10;
1487
+ if ($[15] !== embed_0) {
1488
+ t10 = () => {
1489
+ if (embed_0) writeClipboardText(embed_0.src);
1490
+ };
1491
+ $[15] = embed_0;
1492
+ $[16] = t10;
1493
+ } else t10 = $[16];
1494
+ const copyLink = t10;
1495
+ let t11;
1496
+ if ($[17] !== editor || $[18] !== embed_0) {
1497
+ t11 = () => {
1498
+ if (embed_0) editor.exec(deleteEmbed(embed_0.from));
1499
+ };
1500
+ $[17] = editor;
1501
+ $[18] = embed_0;
1502
+ $[19] = t11;
1503
+ } else t11 = $[19];
1504
+ const remove = t11;
1505
+ let t12;
1506
+ if ($[20] !== editor.state || $[21] !== embed_0 || $[22] !== readOnly) {
1507
+ t12 = !readOnly && embed_0 != null && convertEmbedToLink(embed_0.from)(editor.state);
1508
+ $[20] = editor.state;
1509
+ $[21] = embed_0;
1510
+ $[22] = readOnly;
1511
+ $[23] = t12;
1512
+ } else t12 = $[23];
1513
+ const canConvert = t12;
1514
+ let t13;
1515
+ if ($[24] !== canConvert || $[25] !== convertToLink) {
1516
+ t13 = canConvert && /* @__PURE__ */ jsx(ActionMenuItem, {
1517
+ icon: "link-2",
1518
+ label: "Convert to link",
1519
+ onClick: convertToLink,
1520
+ testId: "embed-menu-convert"
1521
+ });
1522
+ $[24] = canConvert;
1523
+ $[25] = convertToLink;
1524
+ $[26] = t13;
1525
+ } else t13 = $[26];
1526
+ const t14 = embed_0?.kind === "image" ? "Copy image link" : "Copy link";
1527
+ let t15;
1528
+ if ($[27] !== copyLink || $[28] !== t14) {
1529
+ t15 = /* @__PURE__ */ jsx(ActionMenuItem, {
1530
+ icon: "copy",
1531
+ label: t14,
1532
+ onClick: copyLink,
1533
+ testId: "embed-menu-copy"
1534
+ });
1535
+ $[27] = copyLink;
1536
+ $[28] = t14;
1537
+ $[29] = t15;
1538
+ } else t15 = $[29];
1539
+ let t16;
1540
+ if ($[30] !== readOnly || $[31] !== remove) {
1541
+ t16 = !readOnly && /* @__PURE__ */ jsx(ActionMenuItem, {
1542
+ icon: "trash-2",
1543
+ label: "Delete",
1544
+ onClick: remove,
1545
+ testId: "embed-menu-delete"
1546
+ });
1547
+ $[30] = readOnly;
1548
+ $[31] = remove;
1549
+ $[32] = t16;
1550
+ } else t16 = $[32];
1551
+ let t17;
1552
+ if ($[33] !== button_0 || $[34] !== getFinalFocus || $[35] !== t13 || $[36] !== t15 || $[37] !== t16) {
1553
+ t17 = /* @__PURE__ */ jsxs(ActionMenuPopup, {
1554
+ anchor: button_0,
1555
+ finalFocus: getFinalFocus,
1556
+ testId: "embed-menu-popup",
1557
+ children: [
1558
+ t13,
1559
+ t15,
1560
+ t16
1561
+ ]
1562
+ });
1563
+ $[33] = button_0;
1564
+ $[34] = getFinalFocus;
1565
+ $[35] = t13;
1566
+ $[36] = t15;
1567
+ $[37] = t16;
1568
+ $[38] = t17;
1569
+ } else t17 = $[38];
1570
+ let t18;
1571
+ if ($[39] !== changeOpen || $[40] !== open || $[41] !== t17) {
1572
+ t18 = /* @__PURE__ */ jsx(Menu.Root, {
1573
+ open,
1574
+ onOpenChange: changeOpen,
1575
+ onOpenChangeComplete: completeOpenChange,
1576
+ children: t17
1577
+ });
1578
+ $[39] = changeOpen;
1579
+ $[40] = open;
1580
+ $[41] = t17;
1581
+ $[42] = t18;
1582
+ } else t18 = $[42];
1583
+ return t18;
1584
+ }
1585
+
847
1586
  // src/components/link-menu-state.ts
848
1587
  const LINK_MENU_IDLE = { kind: "idle" };
849
1588
  /**
@@ -1129,7 +1868,7 @@ function LinkActions(t0) {
1129
1868
  title: "Edit link",
1130
1869
  "aria-label": "Edit link",
1131
1870
  onClick: onEdit,
1132
- children: /* @__PURE__ */ jsx(PencilIcon, {})
1871
+ children: /* @__PURE__ */ jsx(Icon, { name: "pencil" })
1133
1872
  });
1134
1873
  $[8] = onEdit;
1135
1874
  $[9] = t4;
@@ -1142,7 +1881,7 @@ function LinkActions(t0) {
1142
1881
  title: "Remove link",
1143
1882
  "aria-label": "Remove link",
1144
1883
  onClick: onRemove,
1145
- children: /* @__PURE__ */ jsx(UnlinkIcon, {})
1884
+ children: /* @__PURE__ */ jsx(Icon, { name: "unlink" })
1146
1885
  });
1147
1886
  $[10] = onRemove;
1148
1887
  $[11] = t5;
@@ -1171,7 +1910,7 @@ function PreviewIcon(t0) {
1171
1910
  if (!preview.iconSrc || failed) {
1172
1911
  let t1;
1173
1912
  if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
1174
- t1 = /* @__PURE__ */ jsx(Globe2Icon, { "aria-hidden": "true" });
1913
+ t1 = /* @__PURE__ */ jsx(Icon, { name: "earth" });
1175
1914
  $[0] = t1;
1176
1915
  } else t1 = $[0];
1177
1916
  return t1;
@@ -1295,7 +2034,7 @@ function LinkInfoContent(t0) {
1295
2034
  t9 = onUseTitle && /* @__PURE__ */ jsxs("div", {
1296
2035
  className: link_menu_module_default.ReplaceRow,
1297
2036
  children: [
1298
- /* @__PURE__ */ jsx(SparklesIcon, { "aria-hidden": "true" }),
2037
+ /* @__PURE__ */ jsx(Icon, { name: "sparkles" }),
1299
2038
  /* @__PURE__ */ jsx("span", { children: "Replace URL with its title?" }),
1300
2039
  /* @__PURE__ */ jsx("button", {
1301
2040
  type: "button",
@@ -2298,7 +3037,7 @@ function SelectionMenu(t0) {
2298
3037
  if (affordanceVisible && showAffordance) {
2299
3038
  let t6;
2300
3039
  if ($[24] === Symbol.for("react.memo_cache_sentinel")) {
2301
- t6 = /* @__PURE__ */ jsx(SparklesIcon, {});
3040
+ t6 = /* @__PURE__ */ jsx(Icon, { name: "sparkles" });
2302
3041
  $[24] = t6;
2303
3042
  } else t6 = $[24];
2304
3043
  let t7;
@@ -3091,7 +3830,7 @@ function TableMenuAlignItem(t0) {
3091
3830
  } else t3 = $[5];
3092
3831
  let t4;
3093
3832
  if ($[6] !== active) {
3094
- t4 = active && /* @__PURE__ */ jsx(CheckIcon, {});
3833
+ t4 = active && /* @__PURE__ */ jsx(Icon, { name: "check" });
3095
3834
  $[6] = active;
3096
3835
  $[7] = t4;
3097
3836
  } else t4 = $[7];
@@ -3452,7 +4191,7 @@ function TableHandle() {
3452
4191
  t2 = /* @__PURE__ */ jsx(TableHandleColumnMenuTrigger, {
3453
4192
  className: table_handle_module_default.Trigger,
3454
4193
  "data-testid": "table-handle-column",
3455
- children: /* @__PURE__ */ jsx(GripHorizontalIcon, {})
4194
+ children: /* @__PURE__ */ jsx(Icon, { name: "grip-horizontal" })
3456
4195
  });
3457
4196
  $[2] = t2;
3458
4197
  } else t2 = $[2];
@@ -3501,7 +4240,7 @@ function TableHandle() {
3501
4240
  t6 = /* @__PURE__ */ jsx(TableHandleRowMenuTrigger, {
3502
4241
  className: table_handle_module_default.Trigger,
3503
4242
  "data-testid": "table-handle-row",
3504
- children: /* @__PURE__ */ jsx(GripVerticalIcon, {})
4243
+ children: /* @__PURE__ */ jsx(Icon, { name: "grip-vertical" })
3505
4244
  });
3506
4245
  $[13] = t6;
3507
4246
  } else t6 = $[13];
@@ -3921,7 +4660,7 @@ function findHeadingPosition(doc, fragment) {
3921
4660
  return match;
3922
4661
  }
3923
4662
  function ProseKitEditor(t0) {
3924
- const $ = c(117);
4663
+ const $ = c(120);
3925
4664
  const { markMode: t1, initialMarkdown, singleParagraph: t2, referenceDefinitions, onDocChange, onSlashMenuSearch, onTagSearch, onWikilinkSearch, onSelectionMenuSearch, selectionMenuAffordance: t3, collisionBoundary, pendingReplacementActions, onPendingReplacementResolve, onWikilinkClick, onLinkClick, onLinkCopy, resolveLinkPreview, onTagClick, onExitBoundary, resolveImageUrl, resolveFileLink, resolveWikiEmbed, resolveWikilink, resolveFileInfo, resolveXPost, mediaUrlProtocols, resolveYouTubeVideo, onFileClick, onFilePaste, onFileSaveError, onImageClick, onXPostMediaClick, onYouTubeVideoClick, embedPaste, linkPaste, bulletAfterHeading, backspaceDeletesEmptyFirstBlock, substitution: t4, frontmatter: t5, blockHandle: t6, placeholder, readOnly, spellCheck, writingSuggestions, autoCorrect, autoCapitalize, enterKeyHint, dir, lang, ariaLabel, searchQuery: t7, onSearchChange, timeFormat, editorClassName, CodeBlockView, ref, children } = t0;
3926
4665
  const markMode = t1 === void 0 ? "focus" : t1;
3927
4666
  const singleParagraph = t2 === void 0 ? false : t2;
@@ -4285,7 +5024,7 @@ function ProseKitEditor(t0) {
4285
5024
  $[78] = timeFormat;
4286
5025
  $[79] = t22;
4287
5026
  } else t22 = $[79];
4288
- const t23 = String(readOnly);
5027
+ const t23 = readOnly ? 1 : 0;
4289
5028
  let t24;
4290
5029
  if ($[80] !== onLinkClick || $[81] !== onLinkCopy || $[82] !== readOnly || $[83] !== resolveLinkPreview || $[84] !== t23) {
4291
5030
  t24 = /* @__PURE__ */ jsx(LinkMenu, {
@@ -4302,47 +5041,53 @@ function ProseKitEditor(t0) {
4302
5041
  $[85] = t24;
4303
5042
  } else t24 = $[85];
4304
5043
  let t25;
4305
- if ($[86] !== onTagSearch) {
4306
- t25 = onTagSearch && /* @__PURE__ */ jsx(TagMenu, { onTagSearch });
4307
- $[86] = onTagSearch;
5044
+ if ($[86] !== readOnly) {
5045
+ t25 = /* @__PURE__ */ jsx(EmbedMenu, { readOnly });
5046
+ $[86] = readOnly;
4308
5047
  $[87] = t25;
4309
5048
  } else t25 = $[87];
4310
5049
  let t26;
4311
- if ($[88] !== onWikilinkSearch) {
4312
- t26 = onWikilinkSearch && /* @__PURE__ */ jsx(WikilinkMenu, { onWikilinkSearch });
4313
- $[88] = onWikilinkSearch;
5050
+ if ($[88] !== onTagSearch) {
5051
+ t26 = onTagSearch && /* @__PURE__ */ jsx(TagMenu, { onTagSearch });
5052
+ $[88] = onTagSearch;
4314
5053
  $[89] = t26;
4315
5054
  } else t26 = $[89];
4316
5055
  let t27;
4317
- if ($[90] !== onSelectionMenuSearch || $[91] !== openSelectionMenu || $[92] !== readOnly || $[93] !== selectionMenuAffordance || $[94] !== selectionMenuContext) {
4318
- t27 = onSelectionMenuSearch && !readOnly && /* @__PURE__ */ jsx(SelectionMenu, {
5056
+ if ($[90] !== onWikilinkSearch) {
5057
+ t27 = onWikilinkSearch && /* @__PURE__ */ jsx(WikilinkMenu, { onWikilinkSearch });
5058
+ $[90] = onWikilinkSearch;
5059
+ $[91] = t27;
5060
+ } else t27 = $[91];
5061
+ let t28;
5062
+ if ($[92] !== onSelectionMenuSearch || $[93] !== openSelectionMenu || $[94] !== readOnly || $[95] !== selectionMenuAffordance || $[96] !== selectionMenuContext) {
5063
+ t28 = onSelectionMenuSearch && !readOnly && /* @__PURE__ */ jsx(SelectionMenu, {
4319
5064
  onSelectionMenuSearch,
4320
5065
  context: selectionMenuContext,
4321
5066
  onOpen: openSelectionMenu,
4322
5067
  onClose: closeSelectionMenu,
4323
5068
  affordance: selectionMenuAffordance
4324
5069
  });
4325
- $[90] = onSelectionMenuSearch;
4326
- $[91] = openSelectionMenu;
4327
- $[92] = readOnly;
4328
- $[93] = selectionMenuAffordance;
4329
- $[94] = selectionMenuContext;
4330
- $[95] = t27;
4331
- } else t27 = $[95];
4332
- let t28;
4333
- if ($[96] !== onPendingReplacementResolve || $[97] !== pendingReplacementActions || $[98] !== readOnly) {
4334
- t28 = !readOnly && /* @__PURE__ */ jsx(PendingReplacementPreview, {
5070
+ $[92] = onSelectionMenuSearch;
5071
+ $[93] = openSelectionMenu;
5072
+ $[94] = readOnly;
5073
+ $[95] = selectionMenuAffordance;
5074
+ $[96] = selectionMenuContext;
5075
+ $[97] = t28;
5076
+ } else t28 = $[97];
5077
+ let t29;
5078
+ if ($[98] !== onPendingReplacementResolve || $[99] !== pendingReplacementActions || $[100] !== readOnly) {
5079
+ t29 = !readOnly && /* @__PURE__ */ jsx(PendingReplacementPreview, {
4335
5080
  actions: pendingReplacementActions,
4336
5081
  onResolve: onPendingReplacementResolve
4337
5082
  });
4338
- $[96] = onPendingReplacementResolve;
4339
- $[97] = pendingReplacementActions;
4340
- $[98] = readOnly;
4341
- $[99] = t28;
4342
- } else t28 = $[99];
4343
- let t29;
4344
- if ($[100] !== children || $[101] !== editor_0 || $[102] !== t17 || $[103] !== t18 || $[104] !== t19 || $[105] !== t20 || $[106] !== t21 || $[107] !== t22 || $[108] !== t24 || $[109] !== t25 || $[110] !== t26 || $[111] !== t27 || $[112] !== t28) {
4345
- t29 = /* @__PURE__ */ jsxs(ProseKit, {
5083
+ $[98] = onPendingReplacementResolve;
5084
+ $[99] = pendingReplacementActions;
5085
+ $[100] = readOnly;
5086
+ $[101] = t29;
5087
+ } else t29 = $[101];
5088
+ let t30;
5089
+ if ($[102] !== children || $[103] !== editor_0 || $[104] !== t17 || $[105] !== t18 || $[106] !== t19 || $[107] !== t20 || $[108] !== t21 || $[109] !== t22 || $[110] !== t24 || $[111] !== t25 || $[112] !== t26 || $[113] !== t27 || $[114] !== t28 || $[115] !== t29) {
5090
+ t30 = /* @__PURE__ */ jsxs(ProseKit, {
4346
5091
  editor: editor_0,
4347
5092
  children: [
4348
5093
  t16,
@@ -4357,35 +5102,37 @@ function ProseKitEditor(t0) {
4357
5102
  t26,
4358
5103
  t27,
4359
5104
  t28,
5105
+ t29,
4360
5106
  children
4361
5107
  ]
4362
5108
  });
4363
- $[100] = children;
4364
- $[101] = editor_0;
4365
- $[102] = t17;
4366
- $[103] = t18;
4367
- $[104] = t19;
4368
- $[105] = t20;
4369
- $[106] = t21;
4370
- $[107] = t22;
4371
- $[108] = t24;
4372
- $[109] = t25;
4373
- $[110] = t26;
4374
- $[111] = t27;
4375
- $[112] = t28;
4376
- $[113] = t29;
4377
- } else t29 = $[113];
4378
- let t30;
4379
- if ($[114] !== collisionBoundary || $[115] !== t29) {
4380
- t30 = /* @__PURE__ */ jsx(CollisionBoundaryContext, {
4381
- value: collisionBoundary,
4382
- children: t29
4383
- });
4384
- $[114] = collisionBoundary;
5109
+ $[102] = children;
5110
+ $[103] = editor_0;
5111
+ $[104] = t17;
5112
+ $[105] = t18;
5113
+ $[106] = t19;
5114
+ $[107] = t20;
5115
+ $[108] = t21;
5116
+ $[109] = t22;
5117
+ $[110] = t24;
5118
+ $[111] = t25;
5119
+ $[112] = t26;
5120
+ $[113] = t27;
5121
+ $[114] = t28;
4385
5122
  $[115] = t29;
4386
5123
  $[116] = t30;
4387
5124
  } else t30 = $[116];
4388
- return t30;
5125
+ let t31;
5126
+ if ($[117] !== collisionBoundary || $[118] !== t30) {
5127
+ t31 = /* @__PURE__ */ jsx(CollisionBoundaryContext, {
5128
+ value: collisionBoundary,
5129
+ children: t30
5130
+ });
5131
+ $[117] = collisionBoundary;
5132
+ $[118] = t30;
5133
+ $[119] = t31;
5134
+ } else t31 = $[119];
5135
+ return t31;
4389
5136
  }
4390
5137
 
4391
5138
  // src/components/editor.tsx
@@ -4498,7 +5245,7 @@ function MarkdownEditor(t0) {
4498
5245
  useImperativeHandle(handleRef, t11, t12);
4499
5246
  let t13;
4500
5247
  if ($[2] !== wrapperClassName) {
4501
- t13 = clsx("meowdown", wrapperClassName);
5248
+ t13 = clsx(ROOT_CLASS, wrapperClassName);
4502
5249
  $[2] = wrapperClassName;
4503
5250
  $[3] = t13;
4504
5251
  } else t13 = $[3];
@@ -4798,7 +5545,7 @@ function WikilinkChip(props) {
4798
5545
  let t2;
4799
5546
  if ($[3] !== t1) {
4800
5547
  t2 = /* @__PURE__ */ jsx("span", {
4801
- className: "md-wikilink-view-label",
5548
+ className: class_names_exports.WIKILINK_VIEW_LABEL_CLASS,
4802
5549
  contentEditable: false,
4803
5550
  children: t1
4804
5551
  });
@@ -4808,7 +5555,7 @@ function WikilinkChip(props) {
4808
5555
  let t3;
4809
5556
  if ($[5] !== handleClick || $[6] !== t2) {
4810
5557
  t3 = /* @__PURE__ */ jsx("span", {
4811
- className: "md-wikilink-view-preview md-atom-view-preview",
5558
+ className: `${class_names_exports.WIKILINK_VIEW_PREVIEW_CLASS} ${class_names_exports.ATOM_VIEW_PREVIEW_CLASS}`,
4812
5559
  "data-testid": "wikilink",
4813
5560
  contentEditable: false,
4814
5561
  onClick: handleClick,
@@ -4821,7 +5568,7 @@ function WikilinkChip(props) {
4821
5568
  let t4;
4822
5569
  if ($[8] !== children) {
4823
5570
  t4 = /* @__PURE__ */ jsx("span", {
4824
- className: "md-wikilink-view-content md-atom-view-content",
5571
+ className: `${class_names_exports.WIKILINK_VIEW_CONTENT_CLASS} ${class_names_exports.ATOM_VIEW_CONTENT_CLASS}`,
4825
5572
  children
4826
5573
  });
4827
5574
  $[8] = children;
@@ -4830,7 +5577,7 @@ function WikilinkChip(props) {
4830
5577
  let t5;
4831
5578
  if ($[10] !== t3 || $[11] !== t4) {
4832
5579
  t5 = /* @__PURE__ */ jsxs("span", {
4833
- className: "md-wikilink-view md-atom-view",
5580
+ className: `${class_names_exports.WIKILINK_VIEW_CLASS} ${class_names_exports.ATOM_VIEW_CLASS}`,
4834
5581
  children: [t3, t4]
4835
5582
  });
4836
5583
  $[10] = t3;
@@ -4851,7 +5598,7 @@ function PostEmbed(props) {
4851
5598
  let t4;
4852
5599
  if ($[0] !== kind || $[1] !== mediaUrlProtocols || $[2] !== resolveXPost || $[3] !== resolveYouTubeVideo || $[4] !== snapshot || $[5] !== src || $[6] !== width) {
4853
5600
  const saved = snapshot == null ? void 0 : parsePostEmbedSnapshot(snapshot);
4854
- t0 = "md-image-view-preview md-atom-view-preview";
5601
+ t0 = `${class_names_exports.IMAGE_VIEW_PREVIEW_CLASS} ${class_names_exports.ATOM_VIEW_PREVIEW_CLASS}`;
4855
5602
  t1 = false;
4856
5603
  t2 = `${kind}-embed`;
4857
5604
  t3 = kind;
@@ -4959,11 +5706,11 @@ function ImagePreview(props) {
4959
5706
  let t4;
4960
5707
  if ($[14] !== t2 || $[15] !== t3) {
4961
5708
  t4 = /* @__PURE__ */ jsx("span", {
4962
- className: "md-image-view-preview md-atom-view-preview",
5709
+ className: `${class_names_exports.IMAGE_VIEW_PREVIEW_CLASS} ${class_names_exports.ATOM_VIEW_PREVIEW_CLASS}`,
4963
5710
  "data-testid": "image-preview",
4964
5711
  contentEditable: false,
4965
5712
  children: /* @__PURE__ */ jsx("span", {
4966
- className: "md-image-resizable",
5713
+ className: class_names_exports.IMAGE_RESIZABLE_CLASS,
4967
5714
  "data-testid": "image-resizable",
4968
5715
  "data-loading": "",
4969
5716
  style: {
@@ -5004,7 +5751,7 @@ function ImagePreview(props) {
5004
5751
  let t4;
5005
5752
  if ($[23] !== alt || $[24] !== handleClick || $[25] !== t3 || $[26] !== url) {
5006
5753
  t4 = /* @__PURE__ */ jsx("span", {
5007
- className: "md-image-view-preview md-atom-view-preview",
5754
+ className: `${class_names_exports.IMAGE_VIEW_PREVIEW_CLASS} ${class_names_exports.ATOM_VIEW_PREVIEW_CLASS}`,
5008
5755
  "data-testid": "image-preview",
5009
5756
  contentEditable: false,
5010
5757
  children: /* @__PURE__ */ jsx("img", {
@@ -5057,7 +5804,7 @@ function ImageView(props) {
5057
5804
  let t1;
5058
5805
  if ($[12] !== children) {
5059
5806
  t1 = /* @__PURE__ */ jsx("span", {
5060
- className: "md-image-view-content md-atom-view-content",
5807
+ className: `${class_names_exports.IMAGE_VIEW_CONTENT_CLASS} ${class_names_exports.ATOM_VIEW_CONTENT_CLASS}`,
5061
5808
  children
5062
5809
  });
5063
5810
  $[12] = children;
@@ -5066,7 +5813,7 @@ function ImageView(props) {
5066
5813
  let t2;
5067
5814
  if ($[14] !== t0 || $[15] !== t1) {
5068
5815
  t2 = /* @__PURE__ */ jsxs("span", {
5069
- className: "md-image-view md-atom-view",
5816
+ className: `${class_names_exports.IMAGE_VIEW_CLASS} ${class_names_exports.ATOM_VIEW_CLASS}`,
5070
5817
  children: [t0, t1]
5071
5818
  });
5072
5819
  $[14] = t0;
@@ -5142,7 +5889,7 @@ function FileView(props) {
5142
5889
  let t4;
5143
5890
  if ($[10] === Symbol.for("react.memo_cache_sentinel")) {
5144
5891
  t4 = /* @__PURE__ */ jsxs("svg", {
5145
- className: "md-file-view-icon",
5892
+ className: class_names_exports.FILE_VIEW_ICON_CLASS,
5146
5893
  viewBox: "0 0 24 24",
5147
5894
  "aria-hidden": "true",
5148
5895
  fill: "none",
@@ -5157,7 +5904,7 @@ function FileView(props) {
5157
5904
  let t5;
5158
5905
  if ($[11] !== name) {
5159
5906
  t5 = /* @__PURE__ */ jsx("span", {
5160
- className: "md-file-view-name",
5907
+ className: class_names_exports.FILE_VIEW_NAME_CLASS,
5161
5908
  children: name
5162
5909
  });
5163
5910
  $[11] = name;
@@ -5166,7 +5913,7 @@ function FileView(props) {
5166
5913
  let t6;
5167
5914
  if ($[13] !== size) {
5168
5915
  t6 = /* @__PURE__ */ jsx("span", {
5169
- className: "md-file-view-size",
5916
+ className: class_names_exports.FILE_VIEW_SIZE_CLASS,
5170
5917
  "data-testid": "file-pill-size",
5171
5918
  children: size
5172
5919
  });
@@ -5176,7 +5923,7 @@ function FileView(props) {
5176
5923
  let t7;
5177
5924
  if ($[15] !== handleClick || $[16] !== name || $[17] !== t3 || $[18] !== t5 || $[19] !== t6) {
5178
5925
  t7 = /* @__PURE__ */ jsxs("span", {
5179
- className: "md-file-view-preview md-atom-view-preview",
5926
+ className: `${class_names_exports.FILE_VIEW_PREVIEW_CLASS} ${class_names_exports.ATOM_VIEW_PREVIEW_CLASS}`,
5180
5927
  "data-testid": "file-pill",
5181
5928
  "data-file-kind": t3,
5182
5929
  contentEditable: false,
@@ -5198,7 +5945,7 @@ function FileView(props) {
5198
5945
  let t8;
5199
5946
  if ($[21] !== children) {
5200
5947
  t8 = /* @__PURE__ */ jsx("span", {
5201
- className: "md-file-view-content md-atom-view-content",
5948
+ className: `${class_names_exports.FILE_VIEW_CONTENT_CLASS} ${class_names_exports.ATOM_VIEW_CONTENT_CLASS}`,
5202
5949
  children
5203
5950
  });
5204
5951
  $[21] = children;
@@ -5207,7 +5954,7 @@ function FileView(props) {
5207
5954
  let t9;
5208
5955
  if ($[23] !== t7 || $[24] !== t8) {
5209
5956
  t9 = /* @__PURE__ */ jsxs("span", {
5210
- className: "md-file-view md-atom-view",
5957
+ className: `${class_names_exports.FILE_VIEW_CLASS} ${class_names_exports.ATOM_VIEW_CLASS}`,
5211
5958
  children: [t7, t8]
5212
5959
  });
5213
5960
  $[23] = t7;
@@ -5295,7 +6042,7 @@ function MathView(props) {
5295
6042
  katex,
5296
6043
  formula,
5297
6044
  displayMode: false,
5298
- className: "md-math-view-preview",
6045
+ className: class_names_exports.MATH_VIEW_PREVIEW_CLASS,
5299
6046
  "data-testid": "math-preview"
5300
6047
  });
5301
6048
  $[2] = formula;
@@ -5305,7 +6052,7 @@ function MathView(props) {
5305
6052
  let t1;
5306
6053
  if ($[5] !== children) {
5307
6054
  t1 = /* @__PURE__ */ jsx("span", {
5308
- className: "md-math-view-content",
6055
+ className: class_names_exports.MATH_VIEW_CONTENT_CLASS,
5309
6056
  children
5310
6057
  });
5311
6058
  $[5] = children;
@@ -5314,7 +6061,7 @@ function MathView(props) {
5314
6061
  let t2;
5315
6062
  if ($[7] !== t0 || $[8] !== t1) {
5316
6063
  t2 = /* @__PURE__ */ jsxs("span", {
5317
- className: "md-math-view",
6064
+ className: class_names_exports.MATH_VIEW_CLASS,
5318
6065
  children: [t0, t1]
5319
6066
  });
5320
6067
  $[7] = t0;
@@ -5359,7 +6106,7 @@ function MathCodeBlock(t0) {
5359
6106
  return t1;
5360
6107
  }
5361
6108
  function MermaidCodeBlock(t0) {
5362
- const $ = c(5);
6109
+ const $ = c(6);
5363
6110
  const { code } = t0;
5364
6111
  const renderer = usePele(true);
5365
6112
  if (!renderer || code.trim() === "") {
@@ -5375,19 +6122,24 @@ function MermaidCodeBlock(t0) {
5375
6122
  return t1;
5376
6123
  }
5377
6124
  let t1;
5378
- if ($[2] !== code || $[3] !== renderer) {
5379
- t1 = /* @__PURE__ */ jsx(MermaidRender, {
6125
+ if ($[2] === Symbol.for("react.memo_cache_sentinel")) {
6126
+ t1 = clsx(code_block_view_module_default.Preview, code_block_view_module_default.MermaidPreview);
6127
+ $[2] = t1;
6128
+ } else t1 = $[2];
6129
+ let t2;
6130
+ if ($[3] !== code || $[4] !== renderer) {
6131
+ t2 = /* @__PURE__ */ jsx(MermaidRender, {
5380
6132
  renderer,
5381
6133
  source: code,
5382
- className: `${code_block_view_module_default.Preview} ${code_block_view_module_default.MermaidPreview}`,
6134
+ className: t1,
5383
6135
  "data-testid": "code-block-mermaid-preview",
5384
6136
  "data-scroll-x": true
5385
6137
  });
5386
- $[2] = code;
5387
- $[3] = renderer;
5388
- $[4] = t1;
5389
- } else t1 = $[4];
5390
- return t1;
6138
+ $[3] = code;
6139
+ $[4] = renderer;
6140
+ $[5] = t2;
6141
+ } else t2 = $[5];
6142
+ return t2;
5391
6143
  }
5392
6144
  /**
5393
6145
  * Wrap inline `children` in one mark, special-casing the view/link marks.
@@ -5434,7 +6186,7 @@ function wrapMark(mark, children, context) {
5434
6186
  case "mdLinkText": {
5435
6187
  const attrs = mark.attrs;
5436
6188
  if (!context.interactive) return /* @__PURE__ */ jsx("span", {
5437
- className: "md-link",
6189
+ className: class_names_exports.LINK_TEXT_MARK_CLASS,
5438
6190
  children
5439
6191
  });
5440
6192
  const handleClick = context.onLinkClick ? (event) => {
@@ -5446,7 +6198,7 @@ function wrapMark(mark, children, context) {
5446
6198
  });
5447
6199
  } : void 0;
5448
6200
  return /* @__PURE__ */ jsx("a", {
5449
- className: "md-link",
6201
+ className: class_names_exports.LINK_TEXT_MARK_CLASS,
5450
6202
  href: attrs.href,
5451
6203
  onClick: handleClick,
5452
6204
  children
@@ -5727,7 +6479,7 @@ function MarkdownView(t0) {
5727
6479
  const rootRef = t16;
5728
6480
  let t17;
5729
6481
  if ($[31] !== className) {
5730
- t17 = clsx("ProseMirror", "meowdown-content", className);
6482
+ t17 = clsx("ProseMirror", class_names_exports.CONTENT_CLASS, className);
5731
6483
  $[31] = className;
5732
6484
  $[32] = t17;
5733
6485
  } else t17 = $[32];
@@ -6008,7 +6760,6 @@ function LightboxImage(t0) {
6008
6760
  }
6009
6761
 
6010
6762
  // src/components/lightbox-root.tsx
6011
- const DIALOG_TRANSITION_CLASS = "meowdown-lightbox-dialog";
6012
6763
  function showModal(dialog) {
6013
6764
  const active = document.activeElement;
6014
6765
  if (active instanceof HTMLElement && active.isContentEditable) active.blur();
@@ -6099,7 +6850,7 @@ function LightboxRoot(t0) {
6099
6850
  let t8;
6100
6851
  if ($[22] !== t1 || $[23] !== t7) {
6101
6852
  t8 = /* @__PURE__ */ jsx(ViewTransition, {
6102
- default: DIALOG_TRANSITION_CLASS,
6853
+ default: LIGHTBOX_DIALOG_TRANSITION_CLASS,
6103
6854
  onExit: t1,
6104
6855
  children: t7
6105
6856
  });