tinacms 2.2.9 → 2.3.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 (22) hide show
  1. package/dist/index.js +1525 -899
  2. package/dist/index.mjs +1494 -864
  3. package/dist/rich-text/index.d.ts +3 -0
  4. package/dist/rich-text/index.js +45 -12
  5. package/dist/rich-text/index.mjs +45 -12
  6. package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/components/fixed-toolbar-buttons.d.ts +0 -4
  7. package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/components/plate-ui/icons.d.ts +2 -0
  8. package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/components/plate-ui/mermaid-element.d.ts +11 -0
  9. package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/components/plate-ui/mermaid-toolbar-button.d.ts +20 -0
  10. package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/components/plate-ui/resizable.d.ts +39 -0
  11. package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/components/plate-ui/table-cell-element.d.ts +27 -0
  12. package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/components/plate-ui/table-dropdown-menu.d.ts +3 -0
  13. package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/components/plate-ui/table-element.d.ts +14 -0
  14. package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/components/plate-ui/table-row-element.d.ts +13 -0
  15. package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/components/plate-ui/text-area.d.ts +5 -0
  16. package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/plugins/core/common.d.ts +1 -0
  17. package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/plugins/custom/mermaid-plugin.d.ts +2 -0
  18. package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/plugins/ui/code-block/index.d.ts +4 -2
  19. package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/plugins/ui/components.d.ts +58 -0
  20. package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/toolbar/toolbar-overrides.d.ts +7 -3
  21. package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/toolbar/toolbar-provider.d.ts +1 -1
  22. package/package.json +8 -6
package/dist/index.mjs CHANGED
@@ -6,32 +6,38 @@ var __publicField = (obj, key, value) => {
6
6
  };
7
7
  import { z } from "zod";
8
8
  import * as React from "react";
9
- import React__default, { useState, useCallback, createContext, forwardRef, useContext, useEffect, useMemo, startTransition, useRef, createElement, Component } from "react";
9
+ import React__default, { useState, useCallback, useEffect, useRef, createContext, forwardRef, useContext, useMemo, startTransition, createElement, Component } from "react";
10
10
  import { createPortal, findDOMNode } from "react-dom";
11
- import { toggleList, ELEMENT_UL, ELEMENT_OL, ELEMENT_H1 as ELEMENT_H1$1, ELEMENT_H2 as ELEMENT_H2$1, ELEMENT_H3 as ELEMENT_H3$1, ELEMENT_H4, ELEMENT_H5, ELEMENT_H6, ELEMENT_PARAGRAPH, ELEMENT_BLOCKQUOTE, ELEMENT_CODE_BLOCK, ELEMENT_CODE_LINE, ELEMENT_CODE_SYNTAX, ELEMENT_LI, ELEMENT_LINK, MARK_CODE, MARK_UNDERLINE, MARK_STRIKETHROUGH, MARK_ITALIC, MARK_BOLD, ELEMENT_HR, unwrapList, ELEMENT_TODO_LI, createTrailingBlockPlugin, createAutoformatPlugin, createExitBreakPlugin, KEYS_HEADING, createResetNodePlugin, createHeadingPlugin, createParagraphPlugin, createBlockquotePlugin, createBoldPlugin, createItalicPlugin, createUnderlinePlugin, createCodePlugin, createListPlugin, createIndentPlugin, createIndentListPlugin, createHorizontalRulePlugin, createNodeIdPlugin, getListItemEntry, useListToolbarButtonState, useListToolbarButton } from "@udecode/plate";
12
- import { useSelected, ReactEditor } from "slate-react";
11
+ import { withRef, cn as cn$1, withVariants, withProps, withCn, createPrimitiveElement } from "@udecode/cn";
12
+ import { toggleList, ELEMENT_UL, ELEMENT_OL, ELEMENT_H1 as ELEMENT_H1$1, ELEMENT_H2 as ELEMENT_H2$1, ELEMENT_H3 as ELEMENT_H3$1, ELEMENT_H4, ELEMENT_H5, ELEMENT_H6, ELEMENT_PARAGRAPH, ELEMENT_BLOCKQUOTE, ELEMENT_CODE_BLOCK, ELEMENT_CODE_LINE, ELEMENT_CODE_SYNTAX, ELEMENT_LI, ELEMENT_LINK, MARK_CODE, MARK_UNDERLINE, MARK_STRIKETHROUGH, MARK_ITALIC, MARK_BOLD, ELEMENT_HR, ELEMENT_TABLE, ELEMENT_TR, ELEMENT_TD, ELEMENT_TH, unwrapList, ELEMENT_TODO_LI, createTrailingBlockPlugin, createAutoformatPlugin, createExitBreakPlugin, KEYS_HEADING, createResetNodePlugin, createHeadingPlugin, createParagraphPlugin, createBlockquotePlugin, createBoldPlugin, createItalicPlugin, createUnderlinePlugin, createCodePlugin, createListPlugin, createIndentListPlugin, createHorizontalRulePlugin, createNodeIdPlugin, createTablePlugin, getListItemEntry, useListToolbarButtonState, useListToolbarButton } from "@udecode/plate";
13
+ import { PlateElement, isCollapsed, findNodePath, getPointAfter, insertNodes, ELEMENT_DEFAULT, focusEditor, getPointBefore, setNodes, isElement, PlateLeaf, createPluginFactory, useComposedRef, useEditorRef, createPointRef, insertText, moveSelection, toggleNodeType, useElement, useRemoveNodeButton, useEditorSelector, isSelectionExpanded, withHOC, normalizeEditor, getBlockAbove, queryNode, getParentNode, isType, someNode, isSelectionAtBlockStart, setElements, insertNode, getPluginType, isBlock, isBlockAboveEmpty, findNode, PlateContent, getNodeEntries, useEditorState, collapseSelection, useMarkToolbarButtonState, useMarkToolbarButton, insertEmptyElement, usePlateSelectors, useEventEditorSelectors, PortalBody, useFormInputProps, createPlugins, Plate } from "@udecode/plate-common";
13
14
  import { ELEMENT_SLASH_INPUT, createSlashPlugin } from "@udecode/plate-slash-command";
14
- import { cn as cn$1, withRef, withVariants, withProps, withCn, createPrimitiveElement } from "@udecode/cn";
15
- import { useComposedRef, useEditorRef, findNodePath, getPointBefore, createPointRef, insertText, moveSelection, PlateElement, toggleNodeType, PlateLeaf, isCollapsed, getPointAfter, insertNodes, ELEMENT_DEFAULT, focusEditor, setNodes, isElement, createPluginFactory, normalizeEditor, getBlockAbove, queryNode, getParentNode, isType, someNode, isSelectionAtBlockStart, setElements, insertNode, getPluginType, isBlock, isBlockAboveEmpty, findNode, PlateContent, useMarkToolbarButtonState, useMarkToolbarButton, useEditorState, useEditorSelector, getNodeEntries, collapseSelection, usePlateSelectors, useEventEditorSelectors, PortalBody, useFormInputProps, createPlugins, Plate } from "@udecode/plate-common";
16
- import { ELEMENT_H1, ELEMENT_H2, ELEMENT_H3, ELEMENT_H4 as ELEMENT_H4$1, ELEMENT_H5 as ELEMENT_H5$1, ELEMENT_H6 as ELEMENT_H6$1 } from "@udecode/plate-heading";
15
+ import { useSelected, useReadOnly, ReactEditor } from "slate-react";
16
+ import { useCodeBlockElementState, useCodeSyntaxLeaf, ELEMENT_CODE_BLOCK as ELEMENT_CODE_BLOCK$1 } from "@udecode/plate-code-block";
17
+ import MonacoEditor, { loader, useMonaco } from "@monaco-editor/react";
18
+ import { Combobox, ComboboxInput, ComboboxButton, Transition, ComboboxOptions, ComboboxOption, Popover as Popover$3, PopoverButton, PopoverPanel, TransitionChild, Disclosure, DisclosureButton, DisclosurePanel, Menu, MenuButton, MenuItems, MenuItem } from "@headlessui/react";
17
19
  import { cva } from "class-variance-authority";
18
- import { Plus, AlignCenter as AlignCenter$1, AlignJustify, AlignLeft as AlignLeft$1, AlignRight as AlignRight$1, ChevronDown, PaintBucket, Quote, Check, ChevronRight, ChevronsUpDown, X, FileCode, Baseline, RectangleVertical, Combine, Ungroup, MessageSquare, MessageSquarePlus, Trash, GripVertical, Edit2, Smile, ExternalLink, Heading1, Heading2, Heading3, Heading4, Heading5, Heading6, Indent, Keyboard, WrapText, Minus, MoreHorizontal, Outdent, Pilcrow, RotateCcw, RectangleHorizontal, Search, Settings, Strikethrough, Subscript, Superscript, Table, Text, Underline, Link2Off, Eye, Moon, SunMedium, Twitter } from "lucide-react";
19
- import { useComboboxContext, Combobox, useComboboxStore, ComboboxProvider, Portal, ComboboxPopover, ComboboxItem } from "@ariakit/react";
20
+ import { Eye, SquarePen, Plus, AlignCenter as AlignCenter$1, AlignJustify, AlignLeft as AlignLeft$1, AlignRight as AlignRight$1, ChevronDown, PaintBucket, Quote, Check, ChevronRight, ChevronsUpDown, X, FileCode, Baseline, RectangleVertical, Combine, Ungroup, MessageSquare, MessageSquarePlus, Trash, GripVertical, Edit2, Smile, ExternalLink, Heading1, Heading2, Heading3, Heading4, Heading5, Heading6, Indent, Keyboard, WrapText, Minus, MoreHorizontal, Outdent, Pilcrow, RotateCcw, RectangleHorizontal, Search, Settings, Strikethrough, Subscript, Superscript, Table, Text, Underline, Link2Off, Moon, SunMedium, Twitter } from "lucide-react";
21
+ import mermaid from "mermaid";
22
+ import { ELEMENT_H1, ELEMENT_H2, ELEMENT_H3, ELEMENT_H4 as ELEMENT_H4$1, ELEMENT_H5 as ELEMENT_H5$1, ELEMENT_H6 as ELEMENT_H6$1 } from "@udecode/plate-heading";
23
+ import { useComboboxContext, Combobox as Combobox$1, useComboboxStore, ComboboxProvider, Portal, ComboboxPopover, ComboboxItem } from "@ariakit/react";
20
24
  import { useHTMLInputCursorState, useComboboxInput, filterWords } from "@udecode/plate-combobox";
21
- import { useCodeSyntaxLeaf, useCodeBlockElementState, ELEMENT_CODE_BLOCK as ELEMENT_CODE_BLOCK$1 } from "@udecode/plate-code-block";
22
- import MonacoEditor, { loader, useMonaco } from "@monaco-editor/react";
23
- import { Combobox as Combobox$1, ComboboxInput, ComboboxButton, Transition, ComboboxOptions, ComboboxOption, Popover as Popover$2, PopoverButton, PopoverPanel, TransitionChild, Disclosure, DisclosureButton, DisclosurePanel, Menu, MenuButton, MenuItems, MenuItem } from "@headlessui/react";
25
+ import { useTableCellElementState, useTableCellElement, useTableCellElementResizableState, useTableCellElementResizable, useTableBordersDropdownMenuContentState, useTableMergeState, TableProvider, useTableElementState, useTableElement, mergeTableCells, unmergeTableCells, ELEMENT_TABLE as ELEMENT_TABLE$1, getTableColumnCount, insertTable, deleteTable, insertTableColumn, deleteColumn, insertTableRow, deleteRow } from "@udecode/plate-table";
26
+ import { ResizeHandle as ResizeHandle$1 } from "@udecode/plate-resizable";
27
+ import * as PopoverPrimitive from "@radix-ui/react-popover";
28
+ import { PopoverAnchor } from "@radix-ui/react-popover";
29
+ import { Slot } from "@radix-ui/react-slot";
30
+ import * as DropdownMenuPrimitive from "@radix-ui/react-dropdown-menu";
31
+ import * as SeparatorPrimitive from "@radix-ui/react-separator";
24
32
  import arrayMutators from "final-form-arrays";
25
33
  import setFieldData from "final-form-set-field-data";
26
34
  import { FORM_ERROR, createForm, getIn } from "final-form";
27
35
  import { Field, Form as Form$1 } from "react-final-form";
28
36
  import PropTypes from "prop-types";
29
37
  import { Droppable, Draggable, DragDropContext } from "react-beautiful-dnd";
30
- import * as PopoverPrimitive from "@radix-ui/react-popover";
31
38
  import * as pkg$1 from "react-color";
32
39
  import * as pkg from "color-string";
33
40
  import * as dropzone from "react-dropzone";
34
- import { Slot } from "@radix-ui/react-slot";
35
41
  import { clsx } from "clsx";
36
42
  import { twMerge } from "tailwind-merge";
37
43
  import { Command as Command$1 } from "cmdk";
@@ -42,10 +48,8 @@ import moment from "moment";
42
48
  import { formatDistanceToNow } from "date-fns";
43
49
  import { useLinkToolbarButtonState, useLinkToolbarButton, useFloatingLinkInsertState, useFloatingLinkInsert, useFloatingLinkEditState, useFloatingLinkEdit, FloatingLinkUrlInput, LinkOpenButton, createLinkPlugin } from "@udecode/plate-link";
44
50
  import * as ToolbarPrimitive from "@radix-ui/react-toolbar";
45
- import * as SeparatorPrimitive from "@radix-ui/react-separator";
46
51
  import * as TooltipPrimitive from "@radix-ui/react-tooltip";
47
52
  import { ELEMENT_PARAGRAPH as ELEMENT_PARAGRAPH$1 } from "@udecode/plate-paragraph";
48
- import * as DropdownMenuPrimitive from "@radix-ui/react-dropdown-menu";
49
53
  import { ELEMENT_BLOCKQUOTE as ELEMENT_BLOCKQUOTE$1 } from "@udecode/plate-block-quote";
50
54
  import { useFloatingToolbarState, offset, flip, useFloatingToolbar } from "@udecode/plate-floating";
51
55
  import { useWindowWidth } from "@react-hook/window-size";
@@ -905,6 +909,20 @@ const useEditorContext = () => {
905
909
  const useTemplates = () => {
906
910
  return React__default.useContext(EditorContext);
907
911
  };
912
+ const BlockquoteElement = withRef(
913
+ ({ children, className, ...props }, ref) => {
914
+ return /* @__PURE__ */ React__default.createElement(
915
+ PlateElement,
916
+ {
917
+ asChild: true,
918
+ className: cn$1("my-1 border-l-2 pl-6 italic", className),
919
+ ref,
920
+ ...props
921
+ },
922
+ /* @__PURE__ */ React__default.createElement("blockquote", null, children)
923
+ );
924
+ }
925
+ );
908
926
  function classNames$1(...classes) {
909
927
  return classes.filter(Boolean).join(" ");
910
928
  }
@@ -914,158 +932,678 @@ const uuid = () => {
914
932
  (c) => (c ^ crypto.getRandomValues(new Uint8Array(1))[0] & 15 >> c / 4).toString(16)
915
933
  );
916
934
  };
917
- const RawMarkdown = () => {
935
+ function ChevronDownIcon(props, svgRef) {
936
+ return /* @__PURE__ */ React.createElement("svg", Object.assign({
937
+ xmlns: "http://www.w3.org/2000/svg",
938
+ viewBox: "0 0 20 20",
939
+ fill: "currentColor",
940
+ "aria-hidden": "true",
941
+ ref: svgRef
942
+ }, props), /* @__PURE__ */ React.createElement("path", {
943
+ fillRule: "evenodd",
944
+ d: "M5.293 7.293a1 1 0 011.414 0L10 10.586l3.293-3.293a1 1 0 111.414 1.414l-4 4a1 1 0 01-1.414 0l-4-4a1 1 0 010-1.414z",
945
+ clipRule: "evenodd"
946
+ }));
947
+ }
948
+ const ForwardRef = React.forwardRef(ChevronDownIcon);
949
+ const ChevronDownIcon$1 = ForwardRef;
950
+ const Autocomplete = ({
951
+ value,
952
+ onChange,
953
+ defaultQuery,
954
+ items: items2
955
+ }) => {
956
+ const [query, setQuery] = React__default.useState(defaultQuery ?? "");
957
+ const filteredItems = React__default.useMemo(() => {
958
+ try {
959
+ const reFilter = new RegExp(query, "i");
960
+ const _items = items2.filter((item) => reFilter.test(item.label));
961
+ if (_items.length === 0)
962
+ return items2;
963
+ return _items;
964
+ } catch (err) {
965
+ return items2;
966
+ }
967
+ }, [items2, query]);
918
968
  return /* @__PURE__ */ React__default.createElement(
919
- "svg",
969
+ Combobox,
920
970
  {
921
- stroke: "currentColor",
922
- fill: "currentColor",
923
- strokeWidth: 0,
924
- role: "img",
925
- className: "h-5 w-5",
926
- viewBox: "0 0 24 24",
927
- height: "1em",
928
- width: "1em",
929
- xmlns: "http://www.w3.org/2000/svg"
971
+ value,
972
+ onChange,
973
+ as: "div",
974
+ className: "relative inline-block text-left z-20"
930
975
  },
931
- /* @__PURE__ */ React__default.createElement("title", null),
932
- /* @__PURE__ */ React__default.createElement("path", { d: "M22.27 19.385H1.73A1.73 1.73 0 010 17.655V6.345a1.73 1.73 0 011.73-1.73h20.54A1.73 1.73 0 0124 6.345v11.308a1.73 1.73 0 01-1.73 1.731zM5.769 15.923v-4.5l2.308 2.885 2.307-2.885v4.5h2.308V8.078h-2.308l-2.307 2.885-2.308-2.885H3.46v7.847zM21.232 12h-2.309V8.077h-2.307V12h-2.308l3.461 4.039z" })
976
+ /* @__PURE__ */ React__default.createElement("div", { className: "mt-1" }, /* @__PURE__ */ React__default.createElement("div", { className: "relative w-full cursor-default overflow-hidden rounded-lg bg-white text-left shadow-md sm:text-sm" }, /* @__PURE__ */ React__default.createElement(
977
+ ComboboxInput,
978
+ {
979
+ className: "w-full border-none py-2 pl-3 pr-10 text-sm leading-5 text-gray-900 focus:ring-0 focus:outline-none focus-visible:ring-2 focus-visible:ring-white focus-visible:ring-opacity-75 focus-visible:ring-offset-2 focus-visible:ring-offset-teal-300",
980
+ displayValue: (item) => (item == null ? void 0 : item.label) ?? "Plain Text",
981
+ onChange: (event) => setQuery(event.target.value),
982
+ onClick: (ev) => ev.stopPropagation()
983
+ }
984
+ ), /* @__PURE__ */ React__default.createElement(ComboboxButton, { className: "absolute inset-y-0 right-0 flex items-center pr-2" }, /* @__PURE__ */ React__default.createElement(
985
+ ChevronDownIcon$1,
986
+ {
987
+ className: "h-5 w-5 text-gray-400",
988
+ "aria-hidden": "true"
989
+ }
990
+ )))),
991
+ /* @__PURE__ */ React__default.createElement(
992
+ Transition,
993
+ {
994
+ enter: "transition ease-out duration-100",
995
+ enterFrom: "transform opacity-0 scale-95",
996
+ enterTo: "transform opacity-100 scale-100",
997
+ leave: "transition ease-in duration-75",
998
+ leaveFrom: "transform opacity-100 scale-100",
999
+ leaveTo: "transform opacity-0 scale-95"
1000
+ },
1001
+ /* @__PURE__ */ React__default.createElement(ComboboxOptions, { className: "origin-top-right absolute right-0 mt-1 w-full max-h-[300px] overflow-y-auto rounded-md shadow-lg bg-white ring-1 ring-black ring-opacity-5 focus:outline-none" }, filteredItems.map((item) => /* @__PURE__ */ React__default.createElement(ComboboxOption, { key: item.key, value: item }, ({ focus }) => /* @__PURE__ */ React__default.createElement(
1002
+ "button",
1003
+ {
1004
+ className: classNames$1(
1005
+ focus ? "bg-gray-100 text-gray-900" : "text-gray-700",
1006
+ "block px-4 py-2 text-xs w-full text-right"
1007
+ )
1008
+ },
1009
+ item.render(item)
1010
+ ))))
1011
+ )
933
1012
  );
934
1013
  };
935
- const borderAll = (props) => /* @__PURE__ */ React__default.createElement(
936
- "svg",
937
- {
938
- viewBox: "0 0 24 24",
939
- height: "48",
940
- width: "48",
941
- focusable: "false",
942
- role: "img",
943
- fill: "currentColor",
944
- xmlns: "http://www.w3.org/2000/svg",
945
- ...props
946
- },
947
- /* @__PURE__ */ React__default.createElement("path", { d: "M3 6a3 3 0 0 1 3-3h12a3 3 0 0 1 3 3v12a3 3 0 0 1-3 3H6a3 3 0 0 1-3-3V6zm10 13h5a1 1 0 0 0 1-1v-5h-6v6zm-2-6H5v5a1 1 0 0 0 1 1h5v-6zm2-2h6V6a1 1 0 0 0-1-1h-5v6zm-2-6H6a1 1 0 0 0-1 1v5h6V5z" })
948
- );
949
- const borderBottom = (props) => /* @__PURE__ */ React__default.createElement(
950
- "svg",
951
- {
952
- viewBox: "0 0 24 24",
953
- height: "48",
954
- width: "48",
955
- focusable: "false",
956
- role: "img",
957
- fill: "currentColor",
958
- xmlns: "http://www.w3.org/2000/svg",
959
- ...props
960
- },
961
- /* @__PURE__ */ React__default.createElement("path", { d: "M13 5a1 1 0 1 0 0-2h-2a1 1 0 1 0 0 2h2zm-8 6a1 1 0 1 0-2 0v2a1 1 0 1 0 2 0v-2zm-2 7a1 1 0 1 1 2 0 1 1 0 0 0 1 1h12a1 1 0 0 0 1-1 1 1 0 1 1 2 0 3 3 0 0 1-3 3H6a3 3 0 0 1-3-3zm17-8a1 1 0 0 0-1 1v2a1 1 0 1 0 2 0v-2a1 1 0 0 0-1-1zM7 4a1 1 0 0 0-1-1 3 3 0 0 0-3 3 1 1 0 0 0 2 0 1 1 0 0 1 1-1 1 1 0 0 0 1-1zm11-1a1 1 0 1 0 0 2 1 1 0 0 1 1 1 1 1 0 1 0 2 0 3 3 0 0 0-3-3z" })
962
- );
963
- const borderLeft = (props) => /* @__PURE__ */ React__default.createElement(
964
- "svg",
965
- {
966
- viewBox: "0 0 24 24",
967
- height: "48",
968
- width: "48",
969
- focusable: "false",
970
- role: "img",
971
- fill: "currentColor",
972
- xmlns: "http://www.w3.org/2000/svg",
973
- ...props
974
- },
975
- /* @__PURE__ */ React__default.createElement("path", { d: "M6 21a1 1 0 1 0 0-2 1 1 0 0 1-1-1V6a1 1 0 0 1 1-1 1 1 0 0 0 0-2 3 3 0 0 0-3 3v12a3 3 0 0 0 3 3zm7-16a1 1 0 1 0 0-2h-2a1 1 0 1 0 0 2h2zm6 6a1 1 0 1 1 2 0v2a1 1 0 1 1-2 0v-2zm-5 9a1 1 0 0 1-1 1h-2a1 1 0 1 1 0-2h2a1 1 0 0 1 1 1zm4-17a1 1 0 1 0 0 2 1 1 0 0 1 1 1 1 1 0 1 0 2 0 3 3 0 0 0-3-3zm-1 17a1 1 0 0 0 1 1 3 3 0 0 0 3-3 1 1 0 1 0-2 0 1 1 0 0 1-1 1 1 1 0 0 0-1 1z" })
976
- );
977
- const borderNone = (props) => /* @__PURE__ */ React__default.createElement(
978
- "svg",
979
- {
980
- viewBox: "0 0 24 24",
981
- height: "48",
982
- width: "48",
983
- focusable: "false",
984
- role: "img",
985
- fill: "currentColor",
986
- xmlns: "http://www.w3.org/2000/svg",
987
- ...props
988
- },
989
- /* @__PURE__ */ React__default.createElement("path", { d: "M14 4a1 1 0 0 1-1 1h-2a1 1 0 1 1 0-2h2a1 1 0 0 1 1 1zm-9 7a1 1 0 1 0-2 0v2a1 1 0 1 0 2 0v-2zm14 0a1 1 0 1 1 2 0v2a1 1 0 1 1-2 0v-2zm-6 10a1 1 0 1 0 0-2h-2a1 1 0 1 0 0 2h2zM7 4a1 1 0 0 0-1-1 3 3 0 0 0-3 3 1 1 0 0 0 2 0 1 1 0 0 1 1-1 1 1 0 0 0 1-1zm11-1a1 1 0 1 0 0 2 1 1 0 0 1 1 1 1 1 0 1 0 2 0 3 3 0 0 0-3-3zM7 20a1 1 0 0 1-1 1 3 3 0 0 1-3-3 1 1 0 1 1 2 0 1 1 0 0 0 1 1 1 1 0 0 1 1 1zm11 1a1 1 0 1 1 0-2 1 1 0 0 0 1-1 1 1 0 1 1 2 0 3 3 0 0 1-3 3z" })
990
- );
991
- const borderRight = (props) => /* @__PURE__ */ React__default.createElement(
992
- "svg",
993
- {
994
- viewBox: "0 0 24 24",
995
- height: "48",
996
- width: "48",
997
- focusable: "false",
998
- role: "img",
999
- fill: "currentColor",
1000
- xmlns: "http://www.w3.org/2000/svg",
1001
- ...props
1002
- },
1003
- /* @__PURE__ */ React__default.createElement("path", { d: "M13 5a1 1 0 1 0 0-2h-2a1 1 0 1 0 0 2h2zm-8 6a1 1 0 1 0-2 0v2a1 1 0 1 0 2 0v-2zm9 9a1 1 0 0 1-1 1h-2a1 1 0 1 1 0-2h2a1 1 0 0 1 1 1zM6 3a1 1 0 0 1 0 2 1 1 0 0 0-1 1 1 1 0 0 1-2 0 3 3 0 0 1 3-3zm1 17a1 1 0 0 1-1 1 3 3 0 0 1-3-3 1 1 0 1 1 2 0 1 1 0 0 0 1 1 1 1 0 0 1 1 1zm11 1a1 1 0 1 1 0-2 1 1 0 0 0 1-1V6a1 1 0 0 0-1-1 1 1 0 1 1 0-2 3 3 0 0 1 3 3v12a3 3 0 0 1-3 3z" })
1004
- );
1005
- const borderTop = (props) => /* @__PURE__ */ React__default.createElement(
1006
- "svg",
1007
- {
1008
- viewBox: "0 0 24 24",
1009
- height: "48",
1010
- width: "48",
1011
- focusable: "false",
1012
- role: "img",
1013
- fill: "currentColor",
1014
- xmlns: "http://www.w3.org/2000/svg",
1015
- ...props
1016
- },
1017
- /* @__PURE__ */ React__default.createElement("path", { d: "M3 6a1 1 0 0 0 2 0 1 1 0 0 1 1-1h12a1 1 0 0 1 1 1 1 1 0 1 0 2 0 3 3 0 0 0-3-3H6a3 3 0 0 0-3 3zm2 5a1 1 0 1 0-2 0v2a1 1 0 1 0 2 0v-2zm14 0a1 1 0 1 1 2 0v2a1 1 0 1 1-2 0v-2zm-5 9a1 1 0 0 1-1 1h-2a1 1 0 1 1 0-2h2a1 1 0 0 1 1 1zm-8 1a1 1 0 1 0 0-2 1 1 0 0 1-1-1 1 1 0 1 0-2 0 3 3 0 0 0 3 3zm11-1a1 1 0 0 0 1 1 3 3 0 0 0 3-3 1 1 0 1 0-2 0 1 1 0 0 1-1 1 1 1 0 0 0-1 1z" })
1018
- );
1019
- cva("", {
1020
- variants: {
1021
- variant: {
1022
- toolbar: "size-5",
1023
- menuItem: "mr-2 size-5"
1024
- },
1025
- size: {
1026
- sm: "mr-2 size-4",
1027
- md: "mr-2 size-6"
1028
- }
1029
- },
1030
- defaultVariants: {}
1014
+ loader.config({
1015
+ paths: { vs: "https://cdn.jsdelivr.net/npm/monaco-editor@0.31.1/min/vs" }
1031
1016
  });
1032
- const DoubleColumnOutlined = (props) => /* @__PURE__ */ React__default.createElement(
1033
- "svg",
1034
- {
1035
- fill: "none",
1036
- height: "16",
1037
- viewBox: "0 0 16 16",
1038
- width: "16",
1039
- xmlns: "http://www.w3.org/2000/svg",
1040
- ...props
1041
- },
1042
- /* @__PURE__ */ React__default.createElement(
1043
- "path",
1044
- {
1045
- clipRule: "evenodd",
1046
- d: "M8.5 3H13V13H8.5V3ZM7.5 2H8.5H13C13.5523 2 14 2.44772 14 3V13C14 13.5523 13.5523 14 13 14H8.5H7.5H3C2.44772 14 2 13.5523 2 13V3C2 2.44772 2.44772 2 3 2H7.5ZM7.5 13H3L3 3H7.5V13Z",
1047
- fill: "#595E6F",
1048
- fillRule: "evenodd"
1017
+ let retryCount = 0;
1018
+ const retryFocus = (ref) => {
1019
+ if (ref.current) {
1020
+ ref.current.focus();
1021
+ } else {
1022
+ if (retryCount < 30) {
1023
+ setTimeout(() => {
1024
+ retryCount = retryCount + 1;
1025
+ retryFocus(ref);
1026
+ }, 100);
1049
1027
  }
1050
- )
1051
- );
1052
- const ThreeColumnOutlined = (props) => /* @__PURE__ */ React__default.createElement(
1053
- "svg",
1054
- {
1055
- fill: "none",
1056
- height: "16",
1057
- viewBox: "0 0 16 16",
1058
- width: "16",
1059
- xmlns: "http://www.w3.org/2000/svg",
1060
- ...props
1061
- },
1062
- /* @__PURE__ */ React__default.createElement(
1063
- "path",
1064
- {
1065
- clipRule: "evenodd",
1066
- d: "M9.25 3H6.75V13H9.25V3ZM9.25 2H6.75H5.75H3C2.44772 2 2 2.44772 2 3V13C2 13.5523 2.44772 14 3 14H5.75H6.75H9.25H10.25H13C13.5523 14 14 13.5523 14 13V3C14 2.44772 13.5523 2 13 2H10.25H9.25ZM10.25 3V13H13V3H10.25ZM3 13H5.75V3H3L3 13Z",
1067
- fill: "#4C5161",
1068
- fillRule: "evenodd"
1028
+ }
1029
+ };
1030
+ const MINIMUM_HEIGHT = 75;
1031
+ const CodeBlock = ({
1032
+ attributes,
1033
+ editor,
1034
+ element,
1035
+ language: restrictLanguage,
1036
+ onChangeCallback,
1037
+ defaultValue,
1038
+ ...props
1039
+ }) => {
1040
+ const [navigateAway, setNavigateAway] = React__default.useState(null);
1041
+ const monaco = useMonaco();
1042
+ const monacoEditorRef = React__default.useRef(null);
1043
+ const selected = useSelected();
1044
+ const [height, setHeight] = React__default.useState(MINIMUM_HEIGHT);
1045
+ React__default.useEffect(() => {
1046
+ if (selected && isCollapsed(editor.selection)) {
1047
+ retryFocus(monacoEditorRef);
1048
+ }
1049
+ }, [selected, monacoEditorRef.current]);
1050
+ const value = element.value || "";
1051
+ if (typeof value !== "string") {
1052
+ throw new Error("Element must be of type string for code block");
1053
+ }
1054
+ const language = restrictLanguage || element.lang;
1055
+ const id = React__default.useMemo(() => uuid(), []);
1056
+ const languages = React__default.useMemo(() => {
1057
+ const defaultLangSet = { "": "plain text" };
1058
+ if (!monaco)
1059
+ return defaultLangSet;
1060
+ return monaco.languages.getLanguages().reduce((ac, cv) => {
1061
+ if (cv.id === "plaintext")
1062
+ return ac;
1063
+ return { ...ac, [cv.id]: cv.id };
1064
+ }, defaultLangSet);
1065
+ }, [monaco]);
1066
+ React__default.useEffect(() => {
1067
+ if (monaco) {
1068
+ monaco.languages.typescript.typescriptDefaults.setEagerModelSync(true);
1069
+ monaco.languages.typescript.typescriptDefaults.setDiagnosticsOptions({
1070
+ // disable errors
1071
+ noSemanticValidation: true,
1072
+ noSyntaxValidation: true
1073
+ });
1074
+ }
1075
+ }, [monaco]);
1076
+ const items2 = Object.entries(languages).map(([key, label]) => ({
1077
+ key,
1078
+ label,
1079
+ render: (item) => item.label
1080
+ }));
1081
+ const currentItem = React__default.useMemo(() => {
1082
+ return items2.find((item) => item.key === language) ?? {
1083
+ key: "",
1084
+ label: "Plain Text"
1085
+ };
1086
+ }, [items2, language]);
1087
+ React__default.useEffect(() => {
1088
+ if (navigateAway) {
1089
+ setNavigateAway(null);
1090
+ switch (navigateAway) {
1091
+ case "remove":
1092
+ {
1093
+ focusEditor(editor);
1094
+ setNodes(
1095
+ editor,
1096
+ {
1097
+ type: "p",
1098
+ children: [{ text: "" }],
1099
+ lang: void 0,
1100
+ value: void 0
1101
+ },
1102
+ {
1103
+ match: (n) => {
1104
+ if (isElement(n) && n.type === element.type) {
1105
+ return true;
1106
+ }
1107
+ }
1108
+ }
1109
+ );
1110
+ }
1111
+ break;
1112
+ case "insertNext":
1113
+ {
1114
+ insertNodes(
1115
+ editor,
1116
+ [
1117
+ {
1118
+ type: ELEMENT_DEFAULT,
1119
+ children: [{ text: "" }],
1120
+ lang: void 0,
1121
+ value: void 0
1122
+ }
1123
+ ],
1124
+ { select: true }
1125
+ );
1126
+ focusEditor(editor);
1127
+ }
1128
+ break;
1129
+ case "up":
1130
+ {
1131
+ const path = findNodePath(editor, element);
1132
+ if (!path) {
1133
+ return;
1134
+ }
1135
+ const previousNodePath = getPointBefore(editor, path);
1136
+ if (!previousNodePath) {
1137
+ focusEditor(editor);
1138
+ insertNodes(
1139
+ editor,
1140
+ [
1141
+ {
1142
+ type: ELEMENT_DEFAULT,
1143
+ children: [{ text: "" }],
1144
+ lang: void 0,
1145
+ value: void 0
1146
+ }
1147
+ ],
1148
+ // Insert a new node at the current path, resulting in the code_block
1149
+ // moving down one block
1150
+ { at: path, select: true }
1151
+ );
1152
+ return;
1153
+ }
1154
+ focusEditor(editor, previousNodePath);
1155
+ }
1156
+ break;
1157
+ case "down": {
1158
+ const path = findNodePath(editor, element);
1159
+ if (!path) {
1160
+ return;
1161
+ }
1162
+ const nextNodePath = getPointAfter(editor, path);
1163
+ if (!nextNodePath) {
1164
+ insertNodes(
1165
+ editor,
1166
+ [
1167
+ {
1168
+ type: ELEMENT_DEFAULT,
1169
+ children: [{ text: "" }],
1170
+ lang: void 0,
1171
+ value: void 0
1172
+ }
1173
+ ],
1174
+ { select: true }
1175
+ );
1176
+ focusEditor(editor);
1177
+ } else {
1178
+ focusEditor(editor, nextNodePath);
1179
+ }
1180
+ break;
1181
+ }
1182
+ }
1183
+ }
1184
+ }, [navigateAway]);
1185
+ function handleEditorDidMount(monacoEditor, monaco2) {
1186
+ monacoEditorRef.current = monacoEditor;
1187
+ monacoEditor.onDidContentSizeChange(() => {
1188
+ setHeight(
1189
+ monacoEditor.getContentHeight() > MINIMUM_HEIGHT ? monacoEditor.getContentHeight() : MINIMUM_HEIGHT
1190
+ );
1191
+ monacoEditor.layout();
1192
+ });
1193
+ setNodes(editor, { value: defaultValue, lang: language });
1194
+ monacoEditor.addCommand(monaco2.KeyMod.Shift | monaco2.KeyCode.Enter, () => {
1195
+ if (monacoEditor.hasTextFocus()) {
1196
+ setNavigateAway("insertNext");
1197
+ }
1198
+ });
1199
+ monacoEditor.onKeyDown((l) => {
1200
+ if (l.code === "ArrowUp") {
1201
+ const selection = monacoEditor.getSelection();
1202
+ if (selection.endLineNumber === 1 && selection.startLineNumber === 1) {
1203
+ setNavigateAway("up");
1204
+ }
1205
+ }
1206
+ if (l.code === "ArrowDown") {
1207
+ const selection = monacoEditor.getSelection();
1208
+ const totalLines = monacoEditor.getModel().getLineCount();
1209
+ if (selection.endLineNumber === totalLines && selection.startLineNumber === totalLines) {
1210
+ setNavigateAway("down");
1211
+ }
1212
+ }
1213
+ if (l.code === "Backspace") {
1214
+ const selection = monacoEditor.getSelection();
1215
+ if (selection.endColumn === 1 && selection.endLineNumber === 1 && selection.positionColumn === 1 && selection.positionLineNumber === 1 && selection.selectionStartColumn === 1 && selection.selectionStartLineNumber === 1 && selection.startColumn === 1 && selection.startLineNumber === 1) {
1216
+ setNavigateAway("remove");
1217
+ }
1218
+ }
1219
+ });
1220
+ }
1221
+ return /* @__PURE__ */ React__default.createElement(
1222
+ "div",
1223
+ {
1224
+ ...attributes,
1225
+ className: "relative mb-2 mt-0.5 rounded-lg shadow-md p-2 border-gray-200 border"
1226
+ },
1227
+ /* @__PURE__ */ React__default.createElement("style", null, `.monaco-editor .editor-widget {
1228
+ display: none !important;
1229
+ visibility: hidden !important;
1230
+ }`),
1231
+ props.children,
1232
+ /* @__PURE__ */ React__default.createElement("div", { contentEditable: false }, !restrictLanguage && /* @__PURE__ */ React__default.createElement("div", { className: "flex justify-between pb-2" }, /* @__PURE__ */ React__default.createElement("div", null), /* @__PURE__ */ React__default.createElement(
1233
+ Autocomplete,
1234
+ {
1235
+ items: items2,
1236
+ value: currentItem,
1237
+ defaultQuery: "plaintext",
1238
+ onChange: (item) => setNodes(editor, { lang: item.key })
1239
+ }
1240
+ )), /* @__PURE__ */ React__default.createElement("div", { style: { height: `${height}px` } }, /* @__PURE__ */ React__default.createElement(
1241
+ MonacoEditor,
1242
+ {
1243
+ path: id,
1244
+ onMount: handleEditorDidMount,
1245
+ options: {
1246
+ scrollBeyondLastLine: false,
1247
+ // automaticLayout: true,
1248
+ tabSize: 2,
1249
+ disableLayerHinting: true,
1250
+ accessibilitySupport: "off",
1251
+ codeLens: false,
1252
+ wordWrap: "on",
1253
+ minimap: {
1254
+ enabled: false
1255
+ },
1256
+ fontSize: 14,
1257
+ lineHeight: 2,
1258
+ formatOnPaste: true,
1259
+ lineNumbers: "off",
1260
+ formatOnType: true,
1261
+ fixedOverflowWidgets: true,
1262
+ // Takes too much horizontal space for iframe
1263
+ folding: false,
1264
+ renderLineHighlight: "none",
1265
+ scrollbar: {
1266
+ verticalScrollbarSize: 1,
1267
+ horizontalScrollbarSize: 1,
1268
+ // https://github.com/microsoft/monaco-editor/issues/2007#issuecomment-644425664
1269
+ alwaysConsumeMouseWheel: false
1270
+ }
1271
+ },
1272
+ language: String(language),
1273
+ value: String(element.value),
1274
+ onChange: (value2) => {
1275
+ onChangeCallback == null ? void 0 : onChangeCallback(value2);
1276
+ setNodes(editor, { value: value2, lang: language });
1277
+ }
1278
+ }
1279
+ )))
1280
+ );
1281
+ };
1282
+ const CodeBlockElement = withRef(
1283
+ ({ className, ...props }, ref) => {
1284
+ const { element } = props;
1285
+ const state = useCodeBlockElementState({ element });
1286
+ return /* @__PURE__ */ React__default.createElement(
1287
+ PlateElement,
1288
+ {
1289
+ className: cn$1("relative py-1", state.className, className),
1290
+ ref,
1291
+ ...props
1292
+ },
1293
+ /* @__PURE__ */ React__default.createElement(CodeBlock, { ...props })
1294
+ );
1295
+ }
1296
+ );
1297
+ const CodeLeaf = withRef(
1298
+ ({ children, className, ...props }, ref) => {
1299
+ return /* @__PURE__ */ React__default.createElement(
1300
+ PlateLeaf,
1301
+ {
1302
+ asChild: true,
1303
+ className: cn$1(
1304
+ "whitespace-pre-wrap rounded-md bg-muted px-[0.3em] py-[0.2em] font-mono text-sm",
1305
+ className
1306
+ ),
1307
+ ref,
1308
+ ...props
1309
+ },
1310
+ /* @__PURE__ */ React__default.createElement("code", null, children)
1311
+ );
1312
+ }
1313
+ );
1314
+ const CodeLineElement = withRef((props, ref) => /* @__PURE__ */ React__default.createElement(PlateElement, { ref, ...props }));
1315
+ const CodeSyntaxLeaf = withRef(
1316
+ ({ children, ...props }, ref) => {
1317
+ const { leaf } = props;
1318
+ const { tokenProps } = useCodeSyntaxLeaf({ leaf });
1319
+ return /* @__PURE__ */ React__default.createElement(PlateLeaf, { ref, ...props }, /* @__PURE__ */ React__default.createElement("span", { ...tokenProps }, children));
1320
+ }
1321
+ );
1322
+ const listVariants = cva("m-0 ps-6", {
1323
+ variants: {
1324
+ variant: {
1325
+ ol: "list-decimal",
1326
+ ul: "list-disc [&_ul]:list-[circle] [&_ul_ul]:list-[square]"
1327
+ }
1328
+ }
1329
+ });
1330
+ const ListElementVariants = withVariants(PlateElement, listVariants, [
1331
+ "variant"
1332
+ ]);
1333
+ const ListElement = withRef(
1334
+ ({ children, variant = "ul", ...props }, ref) => {
1335
+ const Component2 = variant;
1336
+ return /* @__PURE__ */ React__default.createElement(ListElementVariants, { asChild: true, ref, variant, ...props }, /* @__PURE__ */ React__default.createElement(Component2, null, children));
1337
+ }
1338
+ );
1339
+ const ELEMENT_MERMAID = "mermaid";
1340
+ const createMermaidPlugin = createPluginFactory({
1341
+ isElement: true,
1342
+ isVoid: true,
1343
+ isInline: false,
1344
+ key: ELEMENT_MERMAID
1345
+ });
1346
+ const MermaidElementWithRef = ({ config }) => {
1347
+ const mermaidRef = useRef(null);
1348
+ useEffect(() => {
1349
+ if (mermaidRef.current) {
1350
+ mermaid.initialize({ startOnLoad: true });
1351
+ mermaid.init();
1352
+ }
1353
+ }, [config]);
1354
+ return /* @__PURE__ */ React__default.createElement("div", { contentEditable: false, className: "border-border border-b" }, /* @__PURE__ */ React__default.createElement("div", { ref: mermaidRef }, /* @__PURE__ */ React__default.createElement("pre", { className: "mermaid not-tina-prose" }, config)));
1355
+ };
1356
+ const Bubble = ({ children }) => {
1357
+ return /* @__PURE__ */ React__default.createElement("div", { className: "bg-blue-600 rounded-full p-2 transition-transform duration-200 ease-in-out hover:scale-110" }, children);
1358
+ };
1359
+ const ErrorMsg = ({ error }) => {
1360
+ if (error) {
1361
+ return /* @__PURE__ */ React__default.createElement(
1362
+ "div",
1363
+ {
1364
+ contentEditable: false,
1365
+ className: "font-mono bg-red-600 text-white p-2 rounded-md cursor-default"
1366
+ },
1367
+ error
1368
+ );
1369
+ }
1370
+ return null;
1371
+ };
1372
+ const DEFAULT_MERMAID_CONFIG = `%% This won't render without implementing a rendering engine (e.g. mermaid on npm)
1373
+ flowchart TD
1374
+ id1(this is an example flow diagram)
1375
+ --> id2(modify me to see changes!)
1376
+ id2
1377
+ --> id3(Click the top button to preview the changes)
1378
+ --> id4(Learn about mermaid diagrams - mermaid.js.org)`;
1379
+ const MermaidElement = withRef(
1380
+ ({ children, nodeProps, element, ...props }, ref) => {
1381
+ const [mermaidConfig, setMermaidConfig] = useState(
1382
+ element.value || DEFAULT_MERMAID_CONFIG
1383
+ );
1384
+ const [isEditing, setIsEditing] = useState(
1385
+ mermaidConfig === DEFAULT_MERMAID_CONFIG || false
1386
+ );
1387
+ const [mermaidError, setMermaidError] = useState(null);
1388
+ const node = {
1389
+ type: ELEMENT_MERMAID,
1390
+ value: mermaidConfig,
1391
+ children: [{ type: "text", text: "" }]
1392
+ };
1393
+ useEffect(() => {
1394
+ if (mermaid.parse(mermaidConfig)) {
1395
+ setMermaidError(null);
1396
+ }
1397
+ }, [mermaidConfig]);
1398
+ mermaid.parseError = (err) => {
1399
+ setMermaidError(
1400
+ String(err.message) || "An error occurred while parsing the diagram."
1401
+ );
1402
+ };
1403
+ return /* @__PURE__ */ React__default.createElement(PlateElement, { element, ref, ...props }, /* @__PURE__ */ React__default.createElement("div", { className: "relative group" }, /* @__PURE__ */ React__default.createElement("div", { className: "absolute top-2 right-2 z-10 space-y-2 opacity-0 group-hover:opacity-100 transition-opacity duration-200 ease-in-out" }, /* @__PURE__ */ React__default.createElement(Bubble, null, isEditing ? /* @__PURE__ */ React__default.createElement(
1404
+ Eye,
1405
+ {
1406
+ className: "w-5 h-5 fill-white cursor-pointer",
1407
+ onClick: () => {
1408
+ setIsEditing(!isEditing);
1409
+ }
1410
+ }
1411
+ ) : /* @__PURE__ */ React__default.createElement(
1412
+ SquarePen,
1413
+ {
1414
+ className: "w-5 h-5 fill-white cursor-pointer",
1415
+ onClick: () => {
1416
+ setIsEditing(!isEditing);
1417
+ }
1418
+ }
1419
+ ))), isEditing ? /* @__PURE__ */ React__default.createElement(
1420
+ CodeBlock,
1421
+ {
1422
+ children: "",
1423
+ language: "yaml",
1424
+ ...props,
1425
+ element: node,
1426
+ defaultValue: mermaidConfig,
1427
+ onChangeCallback: (value) => setMermaidConfig(value)
1428
+ }
1429
+ ) : /* @__PURE__ */ React__default.createElement(MermaidElementWithRef, { config: mermaidConfig })), children, /* @__PURE__ */ React__default.createElement(ErrorMsg, { error: mermaidError }));
1430
+ }
1431
+ );
1432
+ const RawMarkdown = () => {
1433
+ return /* @__PURE__ */ React__default.createElement(
1434
+ "svg",
1435
+ {
1436
+ stroke: "currentColor",
1437
+ fill: "currentColor",
1438
+ strokeWidth: 0,
1439
+ role: "img",
1440
+ className: "h-5 w-5",
1441
+ viewBox: "0 0 24 24",
1442
+ height: "1em",
1443
+ width: "1em",
1444
+ xmlns: "http://www.w3.org/2000/svg"
1445
+ },
1446
+ /* @__PURE__ */ React__default.createElement("title", null),
1447
+ /* @__PURE__ */ React__default.createElement("path", { d: "M22.27 19.385H1.73A1.73 1.73 0 010 17.655V6.345a1.73 1.73 0 011.73-1.73h20.54A1.73 1.73 0 0124 6.345v11.308a1.73 1.73 0 01-1.73 1.731zM5.769 15.923v-4.5l2.308 2.885 2.307-2.885v4.5h2.308V8.078h-2.308l-2.307 2.885-2.308-2.885H3.46v7.847zM21.232 12h-2.309V8.077h-2.307V12h-2.308l3.461 4.039z" })
1448
+ );
1449
+ };
1450
+ const MermaidIcon = () => /* @__PURE__ */ React__default.createElement(
1451
+ "svg",
1452
+ {
1453
+ width: "100%",
1454
+ height: "100%",
1455
+ viewBox: "0 0 491 491",
1456
+ version: "1.1",
1457
+ xmlns: "http://www.w3.org/2000/svg",
1458
+ fillRule: "evenodd",
1459
+ clipRule: "evenodd",
1460
+ strokeLinejoin: "round",
1461
+ strokeMiterlimit: 2
1462
+ },
1463
+ /* @__PURE__ */ React__default.createElement("path", { d: "M490.16,84.61C490.16,37.912 452.248,0 405.55,0L84.61,0C37.912,0 0,37.912 0,84.61L0,405.55C0,452.248 37.912,490.16 84.61,490.16L405.55,490.16C452.248,490.16 490.16,452.248 490.16,405.55L490.16,84.61Z" }),
1464
+ /* @__PURE__ */ React__default.createElement(
1465
+ "path",
1466
+ {
1467
+ d: "M407.48,111.18C335.587,108.103 269.573,152.338 245.08,220C220.587,152.338 154.573,108.103 82.68,111.18C80.285,168.229 107.577,222.632 154.74,254.82C178.908,271.419 193.35,298.951 193.27,328.27L193.27,379.13L296.9,379.13L296.9,328.27C296.816,298.953 311.255,271.42 335.42,254.82C382.596,222.644 409.892,168.233 407.48,111.18Z",
1468
+ fill: "white",
1469
+ fillRule: "nonzero"
1470
+ }
1471
+ )
1472
+ );
1473
+ const borderAll = (props) => /* @__PURE__ */ React__default.createElement(
1474
+ "svg",
1475
+ {
1476
+ viewBox: "0 0 24 24",
1477
+ height: "48",
1478
+ width: "48",
1479
+ focusable: "false",
1480
+ role: "img",
1481
+ fill: "currentColor",
1482
+ xmlns: "http://www.w3.org/2000/svg",
1483
+ ...props
1484
+ },
1485
+ /* @__PURE__ */ React__default.createElement("path", { d: "M3 6a3 3 0 0 1 3-3h12a3 3 0 0 1 3 3v12a3 3 0 0 1-3 3H6a3 3 0 0 1-3-3V6zm10 13h5a1 1 0 0 0 1-1v-5h-6v6zm-2-6H5v5a1 1 0 0 0 1 1h5v-6zm2-2h6V6a1 1 0 0 0-1-1h-5v6zm-2-6H6a1 1 0 0 0-1 1v5h6V5z" })
1486
+ );
1487
+ const borderBottom = (props) => /* @__PURE__ */ React__default.createElement(
1488
+ "svg",
1489
+ {
1490
+ viewBox: "0 0 24 24",
1491
+ height: "48",
1492
+ width: "48",
1493
+ focusable: "false",
1494
+ role: "img",
1495
+ fill: "currentColor",
1496
+ xmlns: "http://www.w3.org/2000/svg",
1497
+ ...props
1498
+ },
1499
+ /* @__PURE__ */ React__default.createElement("path", { d: "M13 5a1 1 0 1 0 0-2h-2a1 1 0 1 0 0 2h2zm-8 6a1 1 0 1 0-2 0v2a1 1 0 1 0 2 0v-2zm-2 7a1 1 0 1 1 2 0 1 1 0 0 0 1 1h12a1 1 0 0 0 1-1 1 1 0 1 1 2 0 3 3 0 0 1-3 3H6a3 3 0 0 1-3-3zm17-8a1 1 0 0 0-1 1v2a1 1 0 1 0 2 0v-2a1 1 0 0 0-1-1zM7 4a1 1 0 0 0-1-1 3 3 0 0 0-3 3 1 1 0 0 0 2 0 1 1 0 0 1 1-1 1 1 0 0 0 1-1zm11-1a1 1 0 1 0 0 2 1 1 0 0 1 1 1 1 1 0 1 0 2 0 3 3 0 0 0-3-3z" })
1500
+ );
1501
+ const borderLeft = (props) => /* @__PURE__ */ React__default.createElement(
1502
+ "svg",
1503
+ {
1504
+ viewBox: "0 0 24 24",
1505
+ height: "48",
1506
+ width: "48",
1507
+ focusable: "false",
1508
+ role: "img",
1509
+ fill: "currentColor",
1510
+ xmlns: "http://www.w3.org/2000/svg",
1511
+ ...props
1512
+ },
1513
+ /* @__PURE__ */ React__default.createElement("path", { d: "M6 21a1 1 0 1 0 0-2 1 1 0 0 1-1-1V6a1 1 0 0 1 1-1 1 1 0 0 0 0-2 3 3 0 0 0-3 3v12a3 3 0 0 0 3 3zm7-16a1 1 0 1 0 0-2h-2a1 1 0 1 0 0 2h2zm6 6a1 1 0 1 1 2 0v2a1 1 0 1 1-2 0v-2zm-5 9a1 1 0 0 1-1 1h-2a1 1 0 1 1 0-2h2a1 1 0 0 1 1 1zm4-17a1 1 0 1 0 0 2 1 1 0 0 1 1 1 1 1 0 1 0 2 0 3 3 0 0 0-3-3zm-1 17a1 1 0 0 0 1 1 3 3 0 0 0 3-3 1 1 0 1 0-2 0 1 1 0 0 1-1 1 1 1 0 0 0-1 1z" })
1514
+ );
1515
+ const borderNone = (props) => /* @__PURE__ */ React__default.createElement(
1516
+ "svg",
1517
+ {
1518
+ viewBox: "0 0 24 24",
1519
+ height: "48",
1520
+ width: "48",
1521
+ focusable: "false",
1522
+ role: "img",
1523
+ fill: "currentColor",
1524
+ xmlns: "http://www.w3.org/2000/svg",
1525
+ ...props
1526
+ },
1527
+ /* @__PURE__ */ React__default.createElement("path", { d: "M14 4a1 1 0 0 1-1 1h-2a1 1 0 1 1 0-2h2a1 1 0 0 1 1 1zm-9 7a1 1 0 1 0-2 0v2a1 1 0 1 0 2 0v-2zm14 0a1 1 0 1 1 2 0v2a1 1 0 1 1-2 0v-2zm-6 10a1 1 0 1 0 0-2h-2a1 1 0 1 0 0 2h2zM7 4a1 1 0 0 0-1-1 3 3 0 0 0-3 3 1 1 0 0 0 2 0 1 1 0 0 1 1-1 1 1 0 0 0 1-1zm11-1a1 1 0 1 0 0 2 1 1 0 0 1 1 1 1 1 0 1 0 2 0 3 3 0 0 0-3-3zM7 20a1 1 0 0 1-1 1 3 3 0 0 1-3-3 1 1 0 1 1 2 0 1 1 0 0 0 1 1 1 1 0 0 1 1 1zm11 1a1 1 0 1 1 0-2 1 1 0 0 0 1-1 1 1 0 1 1 2 0 3 3 0 0 1-3 3z" })
1528
+ );
1529
+ const borderRight = (props) => /* @__PURE__ */ React__default.createElement(
1530
+ "svg",
1531
+ {
1532
+ viewBox: "0 0 24 24",
1533
+ height: "48",
1534
+ width: "48",
1535
+ focusable: "false",
1536
+ role: "img",
1537
+ fill: "currentColor",
1538
+ xmlns: "http://www.w3.org/2000/svg",
1539
+ ...props
1540
+ },
1541
+ /* @__PURE__ */ React__default.createElement("path", { d: "M13 5a1 1 0 1 0 0-2h-2a1 1 0 1 0 0 2h2zm-8 6a1 1 0 1 0-2 0v2a1 1 0 1 0 2 0v-2zm9 9a1 1 0 0 1-1 1h-2a1 1 0 1 1 0-2h2a1 1 0 0 1 1 1zM6 3a1 1 0 0 1 0 2 1 1 0 0 0-1 1 1 1 0 0 1-2 0 3 3 0 0 1 3-3zm1 17a1 1 0 0 1-1 1 3 3 0 0 1-3-3 1 1 0 1 1 2 0 1 1 0 0 0 1 1 1 1 0 0 1 1 1zm11 1a1 1 0 1 1 0-2 1 1 0 0 0 1-1V6a1 1 0 0 0-1-1 1 1 0 1 1 0-2 3 3 0 0 1 3 3v12a3 3 0 0 1-3 3z" })
1542
+ );
1543
+ const borderTop = (props) => /* @__PURE__ */ React__default.createElement(
1544
+ "svg",
1545
+ {
1546
+ viewBox: "0 0 24 24",
1547
+ height: "48",
1548
+ width: "48",
1549
+ focusable: "false",
1550
+ role: "img",
1551
+ fill: "currentColor",
1552
+ xmlns: "http://www.w3.org/2000/svg",
1553
+ ...props
1554
+ },
1555
+ /* @__PURE__ */ React__default.createElement("path", { d: "M3 6a1 1 0 0 0 2 0 1 1 0 0 1 1-1h12a1 1 0 0 1 1 1 1 1 0 1 0 2 0 3 3 0 0 0-3-3H6a3 3 0 0 0-3 3zm2 5a1 1 0 1 0-2 0v2a1 1 0 1 0 2 0v-2zm14 0a1 1 0 1 1 2 0v2a1 1 0 1 1-2 0v-2zm-5 9a1 1 0 0 1-1 1h-2a1 1 0 1 1 0-2h2a1 1 0 0 1 1 1zm-8 1a1 1 0 1 0 0-2 1 1 0 0 1-1-1 1 1 0 1 0-2 0 3 3 0 0 0 3 3zm11-1a1 1 0 0 0 1 1 3 3 0 0 0 3-3 1 1 0 1 0-2 0 1 1 0 0 1-1 1 1 1 0 0 0-1 1z" })
1556
+ );
1557
+ const iconVariants = cva("", {
1558
+ variants: {
1559
+ variant: {
1560
+ toolbar: "size-5",
1561
+ menuItem: "mr-2 size-5"
1562
+ },
1563
+ size: {
1564
+ sm: "mr-2 size-4",
1565
+ md: "mr-2 size-6"
1566
+ }
1567
+ },
1568
+ defaultVariants: {}
1569
+ });
1570
+ const DoubleColumnOutlined = (props) => /* @__PURE__ */ React__default.createElement(
1571
+ "svg",
1572
+ {
1573
+ fill: "none",
1574
+ height: "16",
1575
+ viewBox: "0 0 16 16",
1576
+ width: "16",
1577
+ xmlns: "http://www.w3.org/2000/svg",
1578
+ ...props
1579
+ },
1580
+ /* @__PURE__ */ React__default.createElement(
1581
+ "path",
1582
+ {
1583
+ clipRule: "evenodd",
1584
+ d: "M8.5 3H13V13H8.5V3ZM7.5 2H8.5H13C13.5523 2 14 2.44772 14 3V13C14 13.5523 13.5523 14 13 14H8.5H7.5H3C2.44772 14 2 13.5523 2 13V3C2 2.44772 2.44772 2 3 2H7.5ZM7.5 13H3L3 3H7.5V13Z",
1585
+ fill: "#595E6F",
1586
+ fillRule: "evenodd"
1587
+ }
1588
+ )
1589
+ );
1590
+ const ThreeColumnOutlined = (props) => /* @__PURE__ */ React__default.createElement(
1591
+ "svg",
1592
+ {
1593
+ fill: "none",
1594
+ height: "16",
1595
+ viewBox: "0 0 16 16",
1596
+ width: "16",
1597
+ xmlns: "http://www.w3.org/2000/svg",
1598
+ ...props
1599
+ },
1600
+ /* @__PURE__ */ React__default.createElement(
1601
+ "path",
1602
+ {
1603
+ clipRule: "evenodd",
1604
+ d: "M9.25 3H6.75V13H9.25V3ZM9.25 2H6.75H5.75H3C2.44772 2 2 2.44772 2 3V13C2 13.5523 2.44772 14 3 14H5.75H6.75H9.25H10.25H13C13.5523 14 14 13.5523 14 13V3C14 2.44772 13.5523 2 13 2H10.25H9.25ZM10.25 3V13H13V3H10.25ZM3 13H5.75V3H3L3 13Z",
1605
+ fill: "#4C5161",
1606
+ fillRule: "evenodd"
1069
1607
  }
1070
1608
  )
1071
1609
  );
@@ -1172,6 +1710,7 @@ const Icons = {
1172
1710
  clear: X,
1173
1711
  close: X,
1174
1712
  // code: Code2,
1713
+ paint: PaintBucket,
1175
1714
  codeblock: FileCode,
1176
1715
  color: Baseline,
1177
1716
  column: RectangleVertical,
@@ -1197,6 +1736,7 @@ const Icons = {
1197
1736
  lineHeight: WrapText,
1198
1737
  // link: Link2,
1199
1738
  minus: Minus,
1739
+ mermaid: MermaidIcon,
1200
1740
  more: MoreHorizontal,
1201
1741
  // ol: ListOrdered,
1202
1742
  outdent: Outdent,
@@ -1607,7 +2147,7 @@ const InlineComboboxInput = forwardRef(({ className, ...props }, propRef) => {
1607
2147
  },
1608
2148
  value || "​"
1609
2149
  ), /* @__PURE__ */ React__default.createElement(
1610
- Combobox,
2150
+ Combobox$1,
1611
2151
  {
1612
2152
  autoSelect: true,
1613
2153
  className: cn$1(
@@ -1767,417 +2307,482 @@ const SlashInputElement = withRef(
1767
2307
  );
1768
2308
  }
1769
2309
  );
1770
- const listVariants = cva("m-0 ps-6", {
1771
- variants: {
1772
- variant: {
1773
- ol: "list-decimal",
1774
- ul: "list-disc [&_ul]:list-[circle] [&_ul_ul]:list-[square]"
1775
- }
1776
- }
1777
- });
1778
- const ListElementVariants = withVariants(PlateElement, listVariants, [
1779
- "variant"
1780
- ]);
1781
- const ListElement = withRef(
1782
- ({ children, variant = "ul", ...props }, ref) => {
1783
- const Component2 = variant;
1784
- return /* @__PURE__ */ React__default.createElement(ListElementVariants, { asChild: true, ref, variant, ...props }, /* @__PURE__ */ React__default.createElement(Component2, null, children));
1785
- }
1786
- );
1787
- const BlockquoteElement = withRef(
1788
- ({ children, className, ...props }, ref) => {
1789
- return /* @__PURE__ */ React__default.createElement(
1790
- PlateElement,
1791
- {
1792
- asChild: true,
1793
- className: cn$1("my-1 border-l-2 pl-6 italic", className),
1794
- ref,
1795
- ...props
1796
- },
1797
- /* @__PURE__ */ React__default.createElement("blockquote", null, children)
1798
- );
1799
- }
1800
- );
1801
- const CodeLeaf = withRef(
1802
- ({ children, className, ...props }, ref) => {
1803
- return /* @__PURE__ */ React__default.createElement(
1804
- PlateLeaf,
1805
- {
1806
- asChild: true,
1807
- className: cn$1(
1808
- "whitespace-pre-wrap rounded-md bg-muted px-[0.3em] py-[0.2em] font-mono text-sm",
1809
- className
1810
- ),
1811
- ref,
1812
- ...props
1813
- },
1814
- /* @__PURE__ */ React__default.createElement("code", null, children)
1815
- );
1816
- }
1817
- );
1818
- const CodeLineElement = withRef((props, ref) => /* @__PURE__ */ React__default.createElement(PlateElement, { ref, ...props }));
1819
- const CodeSyntaxLeaf = withRef(
1820
- ({ children, ...props }, ref) => {
1821
- const { leaf } = props;
1822
- const { tokenProps } = useCodeSyntaxLeaf({ leaf });
1823
- return /* @__PURE__ */ React__default.createElement(PlateLeaf, { ref, ...props }, /* @__PURE__ */ React__default.createElement("span", { ...tokenProps }, children));
1824
- }
1825
- );
1826
- function ChevronDownIcon(props, svgRef) {
1827
- return /* @__PURE__ */ React.createElement("svg", Object.assign({
1828
- xmlns: "http://www.w3.org/2000/svg",
1829
- viewBox: "0 0 20 20",
1830
- fill: "currentColor",
1831
- "aria-hidden": "true",
1832
- ref: svgRef
1833
- }, props), /* @__PURE__ */ React.createElement("path", {
1834
- fillRule: "evenodd",
1835
- d: "M5.293 7.293a1 1 0 011.414 0L10 10.586l3.293-3.293a1 1 0 111.414 1.414l-4 4a1 1 0 01-1.414 0l-4-4a1 1 0 010-1.414z",
1836
- clipRule: "evenodd"
1837
- }));
1838
- }
1839
- const ForwardRef = React.forwardRef(ChevronDownIcon);
1840
- const ChevronDownIcon$1 = ForwardRef;
1841
- const Autocomplete = ({
1842
- value,
1843
- onChange,
1844
- defaultQuery,
1845
- items: items2
1846
- }) => {
1847
- const [query, setQuery] = React__default.useState(defaultQuery ?? "");
1848
- const filteredItems = React__default.useMemo(() => {
1849
- try {
1850
- const reFilter = new RegExp(query, "i");
1851
- const _items = items2.filter((item) => reFilter.test(item.label));
1852
- if (_items.length === 0)
1853
- return items2;
1854
- return _items;
1855
- } catch (err) {
1856
- return items2;
1857
- }
1858
- }, [items2, query]);
2310
+ const TableCellElement = withRef(({ children, className, hideBorder, isHeader, style, ...props }, ref) => {
2311
+ var _a, _b, _c, _d;
2312
+ const { element } = props;
2313
+ const {
2314
+ borders,
2315
+ colIndex,
2316
+ colSpan,
2317
+ hovered,
2318
+ hoveredLeft,
2319
+ isSelectingCell,
2320
+ readOnly,
2321
+ rowIndex,
2322
+ rowSize,
2323
+ selected
2324
+ } = useTableCellElementState();
2325
+ const { props: cellProps } = useTableCellElement({ element: props.element });
2326
+ const resizableState = useTableCellElementResizableState({
2327
+ colIndex,
2328
+ colSpan,
2329
+ rowIndex
2330
+ });
2331
+ const { bottomProps, hiddenLeft, leftProps, rightProps } = useTableCellElementResizable(resizableState);
2332
+ const Cell = isHeader ? "th" : "td";
1859
2333
  return /* @__PURE__ */ React__default.createElement(
1860
- Combobox$1,
2334
+ PlateElement,
1861
2335
  {
1862
- value,
1863
- onChange,
1864
- as: "div",
1865
- className: "relative inline-block text-left z-20"
1866
- },
1867
- /* @__PURE__ */ React__default.createElement("div", { className: "mt-1" }, /* @__PURE__ */ React__default.createElement("div", { className: "relative w-full cursor-default overflow-hidden rounded-lg bg-white text-left shadow-md sm:text-sm" }, /* @__PURE__ */ React__default.createElement(
1868
- ComboboxInput,
1869
- {
1870
- className: "w-full border-none py-2 pl-3 pr-10 text-sm leading-5 text-gray-900 focus:ring-0 focus:outline-none focus-visible:ring-2 focus-visible:ring-white focus-visible:ring-opacity-75 focus-visible:ring-offset-2 focus-visible:ring-offset-teal-300",
1871
- displayValue: (item) => (item == null ? void 0 : item.label) ?? "Plain Text",
1872
- onChange: (event) => setQuery(event.target.value),
1873
- onClick: (ev) => ev.stopPropagation()
2336
+ asChild: true,
2337
+ className: cn$1(
2338
+ "relative h-full overflow-visible border-none bg-background p-0",
2339
+ hideBorder && "before:border-none",
2340
+ element.background ? "bg-[--cellBackground]" : "bg-background",
2341
+ !hideBorder && cn$1(
2342
+ isHeader && "text-left [&_>_*]:m-0",
2343
+ "before:size-full",
2344
+ selected && "before:z-10 before:bg-muted",
2345
+ "before:absolute before:box-border before:select-none before:content-['']",
2346
+ borders && cn$1(
2347
+ ((_a = borders.bottom) == null ? void 0 : _a.size) && `before:border-b before:border-b-border`,
2348
+ ((_b = borders.right) == null ? void 0 : _b.size) && `before:border-r before:border-r-border`,
2349
+ ((_c = borders.left) == null ? void 0 : _c.size) && `before:border-l before:border-l-border`,
2350
+ ((_d = borders.top) == null ? void 0 : _d.size) && `before:border-t before:border-t-border`
2351
+ )
2352
+ ),
2353
+ className
2354
+ ),
2355
+ ref,
2356
+ ...cellProps,
2357
+ ...props,
2358
+ style: {
2359
+ "--cellBackground": element.background,
2360
+ ...style
1874
2361
  }
1875
- ), /* @__PURE__ */ React__default.createElement(ComboboxButton, { className: "absolute inset-y-0 right-0 flex items-center pr-2" }, /* @__PURE__ */ React__default.createElement(
1876
- ChevronDownIcon$1,
2362
+ },
2363
+ /* @__PURE__ */ React__default.createElement(Cell, null, /* @__PURE__ */ React__default.createElement(
2364
+ "div",
1877
2365
  {
1878
- className: "h-5 w-5 text-gray-400",
1879
- "aria-hidden": "true"
1880
- }
1881
- )))),
1882
- /* @__PURE__ */ React__default.createElement(
1883
- Transition,
2366
+ className: "relative z-20 box-border h-full px-3 py-2",
2367
+ style: {
2368
+ minHeight: rowSize
2369
+ }
2370
+ },
2371
+ children
2372
+ ), !isSelectingCell && /* @__PURE__ */ React__default.createElement(
2373
+ "div",
1884
2374
  {
1885
- enter: "transition ease-out duration-100",
1886
- enterFrom: "transform opacity-0 scale-95",
1887
- enterTo: "transform opacity-100 scale-100",
1888
- leave: "transition ease-in duration-75",
1889
- leaveFrom: "transform opacity-100 scale-100",
1890
- leaveTo: "transform opacity-0 scale-95"
2375
+ className: "group absolute top-0 size-full select-none",
2376
+ contentEditable: false,
2377
+ suppressContentEditableWarning: true
1891
2378
  },
1892
- /* @__PURE__ */ React__default.createElement(ComboboxOptions, { className: "origin-top-right absolute right-0 mt-1 w-full max-h-[300px] overflow-y-auto rounded-md shadow-lg bg-white ring-1 ring-black ring-opacity-5 focus:outline-none" }, filteredItems.map((item) => /* @__PURE__ */ React__default.createElement(ComboboxOption, { key: item.key, value: item }, ({ focus }) => /* @__PURE__ */ React__default.createElement(
1893
- "button",
2379
+ !readOnly && /* @__PURE__ */ React__default.createElement(React__default.Fragment, null, /* @__PURE__ */ React__default.createElement(
2380
+ ResizeHandle$1,
1894
2381
  {
1895
- className: classNames$1(
1896
- focus ? "bg-gray-100 text-gray-900" : "text-gray-700",
1897
- "block px-4 py-2 text-xs w-full text-right"
2382
+ ...rightProps,
2383
+ className: "-top-3 right-[-5px] w-[10px]"
2384
+ }
2385
+ ), /* @__PURE__ */ React__default.createElement(
2386
+ ResizeHandle$1,
2387
+ {
2388
+ ...bottomProps,
2389
+ className: "bottom-[-5px] h-[10px]"
2390
+ }
2391
+ ), !hiddenLeft && /* @__PURE__ */ React__default.createElement(
2392
+ ResizeHandle$1,
2393
+ {
2394
+ ...leftProps,
2395
+ className: "-top-3 left-[-5px] w-[10px]"
2396
+ }
2397
+ ), hovered && /* @__PURE__ */ React__default.createElement(
2398
+ "div",
2399
+ {
2400
+ className: cn$1(
2401
+ "absolute -top-3 z-30 h-[calc(100%_+_12px)] w-1 bg-ring",
2402
+ "right-[-1.5px]"
1898
2403
  )
1899
- },
1900
- item.render(item)
1901
- ))))
1902
- )
1903
- );
1904
- };
1905
- loader.config({
1906
- paths: { vs: "https://cdn.jsdelivr.net/npm/monaco-editor@0.31.1/min/vs" }
1907
- });
1908
- let retryCount = 0;
1909
- const retryFocus = (ref) => {
1910
- if (ref.current) {
1911
- ref.current.focus();
1912
- } else {
1913
- if (retryCount < 30) {
1914
- setTimeout(() => {
1915
- retryCount = retryCount + 1;
1916
- retryFocus(ref);
1917
- }, 100);
1918
- }
1919
- }
1920
- };
1921
- const CodeBlock = ({
1922
- attributes,
1923
- editor,
1924
- element,
1925
- language: restrictLanguage,
1926
- ...props
1927
- }) => {
1928
- const [navigateAway, setNavigateAway] = React__default.useState(null);
1929
- const monaco = useMonaco();
1930
- const monacoEditorRef = React__default.useRef(null);
1931
- const selected = useSelected();
1932
- const [height, setHeight] = React__default.useState(28);
1933
- React__default.useEffect(() => {
1934
- if (selected && isCollapsed(editor.selection)) {
1935
- retryFocus(monacoEditorRef);
1936
- }
1937
- }, [selected, monacoEditorRef.current]);
1938
- const value = element.value || "";
1939
- if (typeof value !== "string") {
1940
- throw new Error("Element must be of type string for code block");
1941
- }
1942
- const language = restrictLanguage || element.lang;
1943
- const id = React__default.useMemo(() => uuid(), []);
1944
- const languages = React__default.useMemo(() => {
1945
- const defaultLangSet = { "": "plain text" };
1946
- if (!monaco)
1947
- return defaultLangSet;
1948
- return monaco.languages.getLanguages().reduce((ac, cv) => {
1949
- if (cv.id === "plaintext")
1950
- return ac;
1951
- return { ...ac, [cv.id]: cv.id };
1952
- }, defaultLangSet);
1953
- }, [monaco]);
1954
- React__default.useEffect(() => {
1955
- if (monaco) {
1956
- monaco.languages.typescript.typescriptDefaults.setEagerModelSync(true);
1957
- monaco.languages.typescript.typescriptDefaults.setDiagnosticsOptions({
1958
- // disable errors
1959
- noSemanticValidation: true,
1960
- noSyntaxValidation: true
1961
- });
1962
- }
1963
- }, [monaco]);
1964
- const items2 = Object.entries(languages).map(([key, label]) => ({
1965
- key,
1966
- label,
1967
- render: (item) => item.label
1968
- }));
1969
- const currentItem = React__default.useMemo(() => {
1970
- return items2.find((item) => item.key === language) ?? {
1971
- key: "",
1972
- label: "Plain Text"
1973
- };
1974
- }, [items2, language]);
1975
- React__default.useEffect(() => {
1976
- if (navigateAway) {
1977
- setNavigateAway(null);
1978
- switch (navigateAway) {
1979
- case "remove":
1980
- {
1981
- focusEditor(editor);
1982
- setNodes(
1983
- editor,
1984
- {
1985
- type: "p",
1986
- children: [{ text: "" }],
1987
- lang: void 0,
1988
- value: void 0
1989
- },
1990
- {
1991
- match: (n) => {
1992
- if (isElement(n) && n.type === element.type) {
1993
- return true;
1994
- }
1995
- }
1996
- }
1997
- );
1998
- }
1999
- break;
2000
- case "insertNext":
2001
- {
2002
- insertNodes(
2003
- editor,
2004
- [
2005
- {
2006
- type: ELEMENT_DEFAULT,
2007
- children: [{ text: "" }],
2008
- lang: void 0,
2009
- value: void 0
2010
- }
2011
- ],
2012
- { select: true }
2013
- );
2014
- focusEditor(editor);
2015
- }
2016
- break;
2017
- case "up":
2018
- {
2019
- const path = findNodePath(editor, element);
2020
- if (!path) {
2021
- return;
2022
- }
2023
- const previousNodePath = getPointBefore(editor, path);
2024
- if (!previousNodePath) {
2025
- focusEditor(editor);
2026
- insertNodes(
2027
- editor,
2028
- [
2029
- {
2030
- type: ELEMENT_DEFAULT,
2031
- children: [{ text: "" }],
2032
- lang: void 0,
2033
- value: void 0
2034
- }
2035
- ],
2036
- // Insert a new node at the current path, resulting in the code_block
2037
- // moving down one block
2038
- { at: path, select: true }
2039
- );
2040
- return;
2041
- }
2042
- focusEditor(editor, previousNodePath);
2043
- }
2044
- break;
2045
- case "down": {
2046
- const path = findNodePath(editor, element);
2047
- if (!path) {
2048
- return;
2049
- }
2050
- const nextNodePath = getPointAfter(editor, path);
2051
- if (!nextNodePath) {
2052
- insertNodes(
2053
- editor,
2054
- [
2055
- {
2056
- type: ELEMENT_DEFAULT,
2057
- children: [{ text: "" }],
2058
- lang: void 0,
2059
- value: void 0
2060
- }
2061
- ],
2062
- { select: true }
2063
- );
2064
- focusEditor(editor);
2065
- } else {
2066
- focusEditor(editor, nextNodePath);
2067
- }
2068
- break;
2069
2404
  }
2070
- }
2071
- }
2072
- }, [navigateAway]);
2073
- function handleEditorDidMount(monacoEditor, monaco2) {
2074
- monacoEditorRef.current = monacoEditor;
2075
- monacoEditor.onDidContentSizeChange(() => {
2076
- setHeight(monacoEditor.getContentHeight());
2077
- monacoEditor.layout();
2078
- });
2079
- monacoEditor.addCommand(monaco2.KeyMod.Shift | monaco2.KeyCode.Enter, () => {
2080
- if (monacoEditor.hasTextFocus()) {
2081
- setNavigateAway("insertNext");
2082
- }
2083
- });
2084
- monacoEditor.onKeyDown((l) => {
2085
- if (l.code === "ArrowUp") {
2086
- const selection = monacoEditor.getSelection();
2087
- if (selection.endLineNumber === 1 && selection.startLineNumber === 1) {
2088
- setNavigateAway("up");
2405
+ ), hoveredLeft && /* @__PURE__ */ React__default.createElement(
2406
+ "div",
2407
+ {
2408
+ className: cn$1(
2409
+ "absolute -top-3 z-30 h-[calc(100%_+_12px)] w-1 bg-ring",
2410
+ "left-[-1.5px]"
2411
+ )
2089
2412
  }
2413
+ ))
2414
+ ))
2415
+ );
2416
+ });
2417
+ TableCellElement.displayName = "TableCellElement";
2418
+ const TableCellHeaderElement = withProps(TableCellElement, {
2419
+ isHeader: true
2420
+ });
2421
+ const buttonVariants$1 = cva(
2422
+ "inline-flex items-center justify-center whitespace-nowrap rounded-md text-sm font-medium ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50",
2423
+ {
2424
+ defaultVariants: {
2425
+ size: "default",
2426
+ variant: "default"
2427
+ },
2428
+ variants: {
2429
+ isMenu: {
2430
+ true: "h-auto w-full cursor-pointer justify-start"
2431
+ },
2432
+ size: {
2433
+ default: "h-10 px-4 py-2",
2434
+ icon: "size-10",
2435
+ lg: "h-11 rounded-md px-8",
2436
+ none: "",
2437
+ sm: "h-9 rounded-md px-3",
2438
+ sms: "size-9 rounded-md px-0",
2439
+ xs: "h-8 rounded-md px-3"
2440
+ },
2441
+ variant: {
2442
+ default: "bg-primary text-primary-foreground hover:bg-primary/90",
2443
+ destructive: "bg-destructive text-destructive-foreground hover:bg-destructive/90",
2444
+ ghost: "hover:bg-accent hover:text-accent-foreground",
2445
+ inlineLink: "text-base text-primary underline underline-offset-4",
2446
+ link: "text-primary underline-offset-4 hover:underline",
2447
+ outline: "border border-input bg-background hover:bg-accent hover:text-accent-foreground",
2448
+ secondary: "bg-secondary text-secondary-foreground hover:bg-secondary/80"
2090
2449
  }
2091
- if (l.code === "ArrowDown") {
2092
- const selection = monacoEditor.getSelection();
2093
- const totalLines = monacoEditor.getModel().getLineCount();
2094
- if (selection.endLineNumber === totalLines && selection.startLineNumber === totalLines) {
2095
- setNavigateAway("down");
2096
- }
2450
+ }
2451
+ }
2452
+ );
2453
+ const Button$2 = withRef(({ asChild = false, className, isMenu, size, variant, ...props }, ref) => {
2454
+ const Comp = asChild ? Slot : "button";
2455
+ return /* @__PURE__ */ React.createElement(
2456
+ Comp,
2457
+ {
2458
+ className: cn$1(buttonVariants$1({ className, isMenu, size, variant })),
2459
+ ref,
2460
+ ...props
2461
+ }
2462
+ );
2463
+ });
2464
+ const DropdownMenu = DropdownMenuPrimitive.Root;
2465
+ const DropdownMenuTrigger = DropdownMenuPrimitive.Trigger;
2466
+ const DropdownMenuPortal = DropdownMenuPrimitive.Portal;
2467
+ const DropdownMenuSub = DropdownMenuPrimitive.Sub;
2468
+ const DropdownMenuRadioGroup = DropdownMenuPrimitive.RadioGroup;
2469
+ const DropdownMenuSubTrigger = withRef(({ children, className, inset, ...props }, ref) => /* @__PURE__ */ React__default.createElement(
2470
+ DropdownMenuPrimitive.SubTrigger,
2471
+ {
2472
+ className: cn$1(
2473
+ "flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none focus:bg-accent data-[state=open]:bg-accent",
2474
+ "data-[disabled]:pointer-events-none data-[disabled]:opacity-50",
2475
+ inset && "pl-8",
2476
+ className
2477
+ ),
2478
+ ref,
2479
+ ...props
2480
+ },
2481
+ children,
2482
+ /* @__PURE__ */ React__default.createElement(Icons.chevronRight, { className: "ml-auto size-4" })
2483
+ ));
2484
+ const DropdownMenuSubContent = withCn(
2485
+ DropdownMenuPrimitive.SubContent,
2486
+ "z-[99999] min-w-32 overflow-hidden rounded-md border bg-white p-1 text-black shadow-lg data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2"
2487
+ );
2488
+ const DropdownMenuContentVariants = withProps(DropdownMenuPrimitive.Content, {
2489
+ className: cn$1(
2490
+ "z-[99999] min-w-32 overflow-hidden rounded-md border bg-white p-1 text-black shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2"
2491
+ ),
2492
+ sideOffset: 4
2493
+ });
2494
+ const DropdownMenuContent = withRef(({ ...props }, ref) => /* @__PURE__ */ React__default.createElement(DropdownMenuPrimitive.Portal, null, /* @__PURE__ */ React__default.createElement(DropdownMenuContentVariants, { ref, ...props })));
2495
+ const menuItemVariants = cva(
2496
+ cn$1(
2497
+ "relative flex h-9 cursor-pointer select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none transition-colors",
2498
+ "focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50"
2499
+ ),
2500
+ {
2501
+ variants: {
2502
+ inset: {
2503
+ true: "pl-8"
2097
2504
  }
2098
- if (l.code === "Backspace") {
2099
- const selection = monacoEditor.getSelection();
2100
- if (selection.endColumn === 1 && selection.endLineNumber === 1 && selection.positionColumn === 1 && selection.positionLineNumber === 1 && selection.selectionStartColumn === 1 && selection.selectionStartLineNumber === 1 && selection.startColumn === 1 && selection.startLineNumber === 1) {
2101
- setNavigateAway("remove");
2102
- }
2505
+ }
2506
+ }
2507
+ );
2508
+ const DropdownMenuItem = withVariants(
2509
+ DropdownMenuPrimitive.Item,
2510
+ menuItemVariants,
2511
+ ["inset"]
2512
+ );
2513
+ const DropdownMenuCheckboxItem = withRef(({ children, className, ...props }, ref) => /* @__PURE__ */ React__default.createElement(
2514
+ DropdownMenuPrimitive.CheckboxItem,
2515
+ {
2516
+ className: cn$1(
2517
+ "relative flex select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",
2518
+ "cursor-pointer",
2519
+ className
2520
+ ),
2521
+ ref,
2522
+ ...props
2523
+ },
2524
+ /* @__PURE__ */ React__default.createElement("span", { className: "absolute left-2 flex size-3.5 items-center justify-center" }, /* @__PURE__ */ React__default.createElement(DropdownMenuPrimitive.ItemIndicator, null, /* @__PURE__ */ React__default.createElement(Icons.check, { className: "size-4" }))),
2525
+ children
2526
+ ));
2527
+ const DropdownMenuRadioItem = withRef(({ children, className, hideIcon, ...props }, ref) => /* @__PURE__ */ React__default.createElement(
2528
+ DropdownMenuPrimitive.RadioItem,
2529
+ {
2530
+ className: cn$1(
2531
+ "relative flex select-none items-center rounded-sm pl-8 pr-2 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",
2532
+ "h-9 cursor-pointer px-2 data-[state=checked]:bg-accent data-[state=checked]:text-accent-foreground",
2533
+ className
2534
+ ),
2535
+ ref,
2536
+ ...props
2537
+ },
2538
+ !hideIcon && /* @__PURE__ */ React__default.createElement("span", { className: "absolute right-2 flex size-3.5 items-center justify-center" }, /* @__PURE__ */ React__default.createElement(DropdownMenuPrimitive.ItemIndicator, null, /* @__PURE__ */ React__default.createElement(Icons.check, { className: "size-4" }))),
2539
+ children
2540
+ ));
2541
+ const dropdownMenuLabelVariants = cva(
2542
+ cn$1("select-none px-2 py-1.5 text-sm font-semibold"),
2543
+ {
2544
+ variants: {
2545
+ inset: {
2546
+ true: "pl-8"
2103
2547
  }
2104
- });
2548
+ }
2549
+ }
2550
+ );
2551
+ const DropdownMenuLabel = withVariants(
2552
+ DropdownMenuPrimitive.Label,
2553
+ dropdownMenuLabelVariants,
2554
+ ["inset"]
2555
+ );
2556
+ const DropdownMenuSeparator = withCn(
2557
+ DropdownMenuPrimitive.Separator,
2558
+ "-mx-1 my-1 h-px bg-muted"
2559
+ );
2560
+ withCn(
2561
+ createPrimitiveElement("span"),
2562
+ "ml-auto text-xs tracking-widest opacity-60"
2563
+ );
2564
+ const useOpenState = () => {
2565
+ const [open2, setOpen] = useState(false);
2566
+ const onOpenChange = useCallback(
2567
+ (_value = !open2) => {
2568
+ setOpen(_value);
2569
+ },
2570
+ [open2]
2571
+ );
2572
+ return {
2573
+ onOpenChange,
2574
+ open: open2
2575
+ };
2576
+ };
2577
+ const Popover$2 = PopoverPrimitive.Root;
2578
+ const popoverVariants = cva(
2579
+ "w-72 rounded-md border bg-popover p-4 text-popover-foreground shadow-md outline-none data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 print:hidden"
2580
+ );
2581
+ const PopoverContent$1 = withRef(
2582
+ ({ align = "center", className, sideOffset = 4, style, ...props }, ref) => /* @__PURE__ */ React.createElement(PopoverPrimitive.Portal, null, /* @__PURE__ */ React.createElement(
2583
+ PopoverPrimitive.Content,
2584
+ {
2585
+ align,
2586
+ className: cn$1(popoverVariants(), className),
2587
+ ref,
2588
+ sideOffset,
2589
+ style: { zIndex: 1e3, ...style },
2590
+ ...props
2591
+ }
2592
+ ))
2593
+ );
2594
+ const separatorVariants = cva("shrink-0 bg-border", {
2595
+ defaultVariants: {
2596
+ orientation: "horizontal"
2597
+ },
2598
+ variants: {
2599
+ orientation: {
2600
+ horizontal: "h-px w-full",
2601
+ vertical: "h-full w-px"
2602
+ }
2105
2603
  }
2604
+ });
2605
+ const Separator = withVariants(
2606
+ withProps(SeparatorPrimitive.Root, {
2607
+ decorative: true,
2608
+ orientation: "horizontal"
2609
+ }),
2610
+ separatorVariants
2611
+ );
2612
+ const TableBordersDropdownMenuContent = withRef((props, ref) => {
2613
+ const {
2614
+ getOnSelectTableBorder,
2615
+ hasBottomBorder,
2616
+ hasLeftBorder,
2617
+ hasNoBorders,
2618
+ hasOuterBorders,
2619
+ hasRightBorder,
2620
+ hasTopBorder
2621
+ } = useTableBordersDropdownMenuContentState();
2106
2622
  return /* @__PURE__ */ React__default.createElement(
2107
- "div",
2623
+ DropdownMenuContent,
2108
2624
  {
2109
- ...attributes,
2110
- className: "relative mb-2 mt-0.5 rounded-lg shadow-md p-2 border-gray-200 border"
2625
+ align: "start",
2626
+ className: cn$1("min-w-[220px]"),
2627
+ ref,
2628
+ side: "right",
2629
+ sideOffset: 0,
2630
+ ...props
2111
2631
  },
2112
- /* @__PURE__ */ React__default.createElement("style", null, `.monaco-editor .editor-widget {
2113
- display: none !important;
2114
- visibility: hidden !important;
2115
- }`),
2116
- props.children,
2117
- /* @__PURE__ */ React__default.createElement("div", { contentEditable: false }, !restrictLanguage && /* @__PURE__ */ React__default.createElement("div", { className: "flex justify-between pb-2" }, /* @__PURE__ */ React__default.createElement("div", null), /* @__PURE__ */ React__default.createElement(
2118
- Autocomplete,
2632
+ /* @__PURE__ */ React__default.createElement(
2633
+ DropdownMenuCheckboxItem,
2119
2634
  {
2120
- items: items2,
2121
- value: currentItem,
2122
- defaultQuery: "plaintext",
2123
- onChange: (item) => setNodes(editor, { lang: item.key })
2124
- }
2125
- )), /* @__PURE__ */ React__default.createElement("div", { style: { height: `${height}px` } }, /* @__PURE__ */ React__default.createElement(
2126
- MonacoEditor,
2635
+ checked: hasBottomBorder,
2636
+ onCheckedChange: getOnSelectTableBorder("bottom")
2637
+ },
2638
+ /* @__PURE__ */ React__default.createElement(Icons.borderBottom, { className: iconVariants({ size: "sm" }) }),
2639
+ /* @__PURE__ */ React__default.createElement("div", null, "Bottom Border")
2640
+ ),
2641
+ /* @__PURE__ */ React__default.createElement(
2642
+ DropdownMenuCheckboxItem,
2127
2643
  {
2128
- path: id,
2129
- onMount: handleEditorDidMount,
2130
- options: {
2131
- scrollBeyondLastLine: false,
2132
- // automaticLayout: true,
2133
- tabSize: 2,
2134
- disableLayerHinting: true,
2135
- accessibilitySupport: "off",
2136
- codeLens: false,
2137
- wordWrap: "on",
2138
- minimap: {
2139
- enabled: false
2140
- },
2141
- fontSize: 14,
2142
- lineHeight: 2,
2143
- formatOnPaste: true,
2144
- lineNumbers: "off",
2145
- formatOnType: true,
2146
- fixedOverflowWidgets: true,
2147
- // Takes too much horizontal space for iframe
2148
- folding: false,
2149
- renderLineHighlight: "none",
2150
- scrollbar: {
2151
- verticalScrollbarSize: 1,
2152
- horizontalScrollbarSize: 1,
2153
- // https://github.com/microsoft/monaco-editor/issues/2007#issuecomment-644425664
2154
- alwaysConsumeMouseWheel: false
2155
- }
2156
- },
2157
- language: String(language),
2158
- value: String(element.value),
2159
- onChange: (value2) => {
2160
- setNodes(editor, { value: value2, lang: language });
2161
- }
2162
- }
2163
- )))
2164
- );
2165
- };
2166
- const CodeBlockElement = withRef(
2167
- ({ className, ...props }, ref) => {
2168
- const { element } = props;
2169
- const state = useCodeBlockElementState({ element });
2170
- return /* @__PURE__ */ React__default.createElement(
2171
- PlateElement,
2644
+ checked: hasTopBorder,
2645
+ onCheckedChange: getOnSelectTableBorder("top")
2646
+ },
2647
+ /* @__PURE__ */ React__default.createElement(Icons.borderTop, { className: iconVariants({ size: "sm" }) }),
2648
+ /* @__PURE__ */ React__default.createElement("div", null, "Top Border")
2649
+ ),
2650
+ /* @__PURE__ */ React__default.createElement(
2651
+ DropdownMenuCheckboxItem,
2652
+ {
2653
+ checked: hasLeftBorder,
2654
+ onCheckedChange: getOnSelectTableBorder("left")
2655
+ },
2656
+ /* @__PURE__ */ React__default.createElement(Icons.borderLeft, { className: iconVariants({ size: "sm" }) }),
2657
+ /* @__PURE__ */ React__default.createElement("div", null, "Left Border")
2658
+ ),
2659
+ /* @__PURE__ */ React__default.createElement(
2660
+ DropdownMenuCheckboxItem,
2661
+ {
2662
+ checked: hasRightBorder,
2663
+ onCheckedChange: getOnSelectTableBorder("right")
2664
+ },
2665
+ /* @__PURE__ */ React__default.createElement(Icons.borderRight, { className: iconVariants({ size: "sm" }) }),
2666
+ /* @__PURE__ */ React__default.createElement("div", null, "Right Border")
2667
+ ),
2668
+ /* @__PURE__ */ React__default.createElement(Separator, null),
2669
+ /* @__PURE__ */ React__default.createElement(
2670
+ DropdownMenuCheckboxItem,
2671
+ {
2672
+ checked: hasNoBorders,
2673
+ onCheckedChange: getOnSelectTableBorder("none")
2674
+ },
2675
+ /* @__PURE__ */ React__default.createElement(Icons.borderNone, { className: iconVariants({ size: "sm" }) }),
2676
+ /* @__PURE__ */ React__default.createElement("div", null, "No Border")
2677
+ ),
2678
+ /* @__PURE__ */ React__default.createElement(
2679
+ DropdownMenuCheckboxItem,
2680
+ {
2681
+ checked: hasOuterBorders,
2682
+ onCheckedChange: getOnSelectTableBorder("outer")
2683
+ },
2684
+ /* @__PURE__ */ React__default.createElement(Icons.borderAll, { className: iconVariants({ size: "sm" }) }),
2685
+ /* @__PURE__ */ React__default.createElement("div", null, "Outside Borders")
2686
+ )
2687
+ );
2688
+ });
2689
+ const TableFloatingToolbar = withRef(
2690
+ ({ children, ...props }, ref) => {
2691
+ const element = useElement();
2692
+ const { props: buttonProps } = useRemoveNodeButton({ element });
2693
+ const selectionCollapsed = useEditorSelector(
2694
+ (editor2) => !isSelectionExpanded(editor2),
2695
+ []
2696
+ );
2697
+ const readOnly = useReadOnly();
2698
+ const selected = useSelected();
2699
+ const editor = useEditorRef();
2700
+ const collapsed = !readOnly && selected && selectionCollapsed;
2701
+ const open2 = !readOnly && selected;
2702
+ const { canMerge, canUnmerge } = useTableMergeState();
2703
+ const mergeContent = canMerge && /* @__PURE__ */ React__default.createElement(
2704
+ Button$2,
2172
2705
  {
2173
- className: cn$1("relative py-1", state.className, className),
2706
+ contentEditable: false,
2707
+ isMenu: true,
2708
+ onClick: () => mergeTableCells(editor),
2709
+ variant: "ghost"
2710
+ },
2711
+ /* @__PURE__ */ React__default.createElement(Icons.combine, { className: "mr-2 size-4" }),
2712
+ "Merge"
2713
+ );
2714
+ const unmergeButton = canUnmerge && /* @__PURE__ */ React__default.createElement(
2715
+ Button$2,
2716
+ {
2717
+ contentEditable: false,
2718
+ isMenu: true,
2719
+ onClick: () => unmergeTableCells(editor),
2720
+ variant: "ghost"
2721
+ },
2722
+ /* @__PURE__ */ React__default.createElement(Icons.ungroup, { className: "mr-2 size-4" }),
2723
+ "Unmerge"
2724
+ );
2725
+ const bordersContent = collapsed && /* @__PURE__ */ React__default.createElement(React__default.Fragment, null, /* @__PURE__ */ React__default.createElement(DropdownMenu, { modal: false }, /* @__PURE__ */ React__default.createElement(DropdownMenuTrigger, { asChild: true }, /* @__PURE__ */ React__default.createElement(Button$2, { isMenu: true, variant: "ghost" }, /* @__PURE__ */ React__default.createElement(Icons.borderAll, { className: "mr-2 size-4" }), "Borders")), /* @__PURE__ */ React__default.createElement(DropdownMenuPortal, null, /* @__PURE__ */ React__default.createElement(TableBordersDropdownMenuContent, null))), /* @__PURE__ */ React__default.createElement(Button$2, { contentEditable: false, isMenu: true, variant: "ghost", ...buttonProps }, /* @__PURE__ */ React__default.createElement(Icons.delete, { className: "mr-2 size-4" }), "Delete"));
2726
+ return /* @__PURE__ */ React__default.createElement(Popover$2, { modal: false, open: open2 }, /* @__PURE__ */ React__default.createElement(PopoverAnchor, { asChild: true }, children), (canMerge || canUnmerge || collapsed) && /* @__PURE__ */ React__default.createElement(
2727
+ PopoverContent$1,
2728
+ {
2729
+ className: cn$1(
2730
+ popoverVariants(),
2731
+ "flex w-[220px] flex-col gap-1 p-1"
2732
+ ),
2733
+ onOpenAutoFocus: (e) => e.preventDefault(),
2174
2734
  ref,
2175
2735
  ...props
2176
2736
  },
2177
- /* @__PURE__ */ React__default.createElement(CodeBlock, { ...props })
2178
- );
2737
+ unmergeButton,
2738
+ mergeContent,
2739
+ bordersContent
2740
+ ));
2179
2741
  }
2180
2742
  );
2743
+ const TableElement = withHOC(
2744
+ TableProvider,
2745
+ withRef(({ children, className, ...props }, ref) => {
2746
+ const { colSizes, isSelectingCell, marginLeft, minColumnWidth } = useTableElementState();
2747
+ const { colGroupProps, props: tableProps } = useTableElement();
2748
+ return /* @__PURE__ */ React__default.createElement(TableFloatingToolbar, null, /* @__PURE__ */ React__default.createElement("div", { style: { paddingLeft: marginLeft } }, /* @__PURE__ */ React__default.createElement(
2749
+ PlateElement,
2750
+ {
2751
+ asChild: true,
2752
+ className: cn$1(
2753
+ "my-4 ml-px mr-0 table h-px w-full table-fixed border-collapse",
2754
+ isSelectingCell && "[&_*::selection]:bg-none",
2755
+ className
2756
+ ),
2757
+ ref,
2758
+ ...tableProps,
2759
+ ...props
2760
+ },
2761
+ /* @__PURE__ */ React__default.createElement("table", null, /* @__PURE__ */ React__default.createElement("colgroup", { ...colGroupProps }, colSizes.map((width, index) => /* @__PURE__ */ React__default.createElement(
2762
+ "col",
2763
+ {
2764
+ key: index,
2765
+ style: {
2766
+ minWidth: minColumnWidth,
2767
+ width: width || void 0
2768
+ }
2769
+ }
2770
+ ))), /* @__PURE__ */ React__default.createElement("tbody", { className: "min-w-full" }, children))
2771
+ )));
2772
+ })
2773
+ );
2774
+ const TableRowElement = withRef(({ children, hideBorder, ...props }, ref) => {
2775
+ return /* @__PURE__ */ React__default.createElement(
2776
+ PlateElement,
2777
+ {
2778
+ asChild: true,
2779
+ className: cn$1("h-full", hideBorder && "border-none"),
2780
+ ref,
2781
+ ...props
2782
+ },
2783
+ /* @__PURE__ */ React__default.createElement("tr", null, children)
2784
+ );
2785
+ });
2181
2786
  const blockClasses = "mt-0.5";
2182
2787
  const headerClasses = "font-normal";
2183
2788
  const Components = () => {
@@ -2283,6 +2888,7 @@ const Components = () => {
2283
2888
  }
2284
2889
  )
2285
2890
  ),
2891
+ [ELEMENT_MERMAID]: MermaidElement,
2286
2892
  [ELEMENT_BLOCKQUOTE]: BlockquoteElement,
2287
2893
  [ELEMENT_CODE_BLOCK]: CodeBlockElement,
2288
2894
  [ELEMENT_CODE_LINE]: CodeLineElement,
@@ -2363,7 +2969,11 @@ const Components = () => {
2363
2969
  children,
2364
2970
  selected && /* @__PURE__ */ React__default.createElement("span", { className: "absolute h-4 -top-2 inset-0 ring-2 ring-blue-100 ring-inset rounded-md z-10 pointer-events-none" })
2365
2971
  );
2366
- }
2972
+ },
2973
+ [ELEMENT_TABLE]: TableElement,
2974
+ [ELEMENT_TR]: TableRowElement,
2975
+ [ELEMENT_TD]: TableCellElement,
2976
+ [ELEMENT_TH]: TableCellHeaderElement
2367
2977
  };
2368
2978
  };
2369
2979
  const createCodeBlockPlugin = createPluginFactory({
@@ -2773,7 +3383,9 @@ class Form {
2773
3383
  {
2774
3384
  type: "string",
2775
3385
  label: "Caption",
2776
- name: [templateName.replace(/\.props$/, ""), "caption"].join("."),
3386
+ name: [templateName.replace(/\.props$/, ""), "caption"].join(
3387
+ "."
3388
+ ),
2777
3389
  component: "text"
2778
3390
  }
2779
3391
  ]
@@ -4433,7 +5045,7 @@ const ImageLoadingIndicator = () => /* @__PURE__ */ React.createElement("div", {
4433
5045
  function cn(...inputs) {
4434
5046
  return twMerge(clsx(inputs));
4435
5047
  }
4436
- const buttonVariants$1 = cva(
5048
+ const buttonVariants = cva(
4437
5049
  "inline-flex items-center justify-center whitespace-nowrap rounded-md text-sm font-medium ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50",
4438
5050
  {
4439
5051
  variants: {
@@ -4459,7 +5071,7 @@ const Button = React.forwardRef(
4459
5071
  return /* @__PURE__ */ React.createElement(
4460
5072
  Comp,
4461
5073
  {
4462
- className: cn(buttonVariants$1({ variant, size, className })),
5074
+ className: cn(buttonVariants({ variant, size, className })),
4463
5075
  ref,
4464
5076
  ...props
4465
5077
  }
@@ -5158,7 +5770,7 @@ const BlockSelector = ({
5158
5770
  return template.label ? template.label.toLowerCase().includes(filter.toLowerCase()) || name.toLowerCase().includes(filter.toLowerCase()) : name.toLowerCase().includes(filter.toLowerCase());
5159
5771
  });
5160
5772
  }, [filter]);
5161
- return /* @__PURE__ */ React.createElement(Popover$2, null, ({ open: open2 }) => /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(PopoverButton, { as: "span" }, /* @__PURE__ */ React.createElement(
5773
+ return /* @__PURE__ */ React.createElement(Popover$3, null, ({ open: open2 }) => /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(PopoverButton, { as: "span" }, /* @__PURE__ */ React.createElement(
5162
5774
  IconButton,
5163
5775
  {
5164
5776
  variant: open2 ? "secondary" : "primary",
@@ -9723,7 +10335,7 @@ const SyncStatus = ({ cms, setEventsOpen }) => {
9723
10335
  "Event Log"
9724
10336
  ));
9725
10337
  };
9726
- const version = "2.2.9";
10338
+ const version = "2.3.0";
9727
10339
  const Nav = ({
9728
10340
  isLocalMode,
9729
10341
  className = "",
@@ -12790,7 +13402,7 @@ const EmbedNestedForm = ({
12790
13402
  );
12791
13403
  };
12792
13404
  const DotMenu = ({ onOpen, onRemove }) => {
12793
- return /* @__PURE__ */ React__default.createElement(Popover$2, { as: "span", className: "-ml-px relative block" }, /* @__PURE__ */ React__default.createElement(
13405
+ return /* @__PURE__ */ React__default.createElement(Popover$3, { as: "span", className: "-ml-px relative block" }, /* @__PURE__ */ React__default.createElement(
12794
13406
  PopoverButton,
12795
13407
  {
12796
13408
  as: "span",
@@ -13230,13 +13842,26 @@ const plugins = [
13230
13842
  createUnderlinePlugin(),
13231
13843
  createCodePlugin(),
13232
13844
  createListPlugin(),
13233
- createIndentPlugin(),
13234
13845
  createIndentListPlugin(),
13235
13846
  createHorizontalRulePlugin(),
13236
13847
  // Allows us to do things like copy/paste, remembering the state of the element (like mdx)
13237
13848
  createNodeIdPlugin(),
13238
- createSlashPlugin()
13849
+ createSlashPlugin(),
13850
+ createTablePlugin()
13239
13851
  ];
13852
+ const unsupportedItemsInTable = /* @__PURE__ */ new Set([
13853
+ "Code Block",
13854
+ "Unordered List",
13855
+ "Ordered List",
13856
+ "Quote",
13857
+ "Mermaid",
13858
+ "Heading 1",
13859
+ "Heading 2",
13860
+ "Heading 3",
13861
+ "Heading 4",
13862
+ "Heading 5",
13863
+ "Heading 6"
13864
+ ]);
13240
13865
  const isNodeActive = (editor, type) => {
13241
13866
  const pluginType = getPluginType(editor, type);
13242
13867
  return !!(editor == null ? void 0 : editor.selection) && someNode(editor, { match: { type: pluginType } });
@@ -13421,24 +14046,6 @@ const Editor = React__default.forwardRef(
13421
14046
  }
13422
14047
  );
13423
14048
  Editor.displayName = "Editor";
13424
- const separatorVariants = cva("shrink-0 bg-border", {
13425
- defaultVariants: {
13426
- orientation: "horizontal"
13427
- },
13428
- variants: {
13429
- orientation: {
13430
- horizontal: "h-px w-full",
13431
- vertical: "h-full w-px"
13432
- }
13433
- }
13434
- });
13435
- const Separator = withVariants(
13436
- withProps(SeparatorPrimitive.Root, {
13437
- decorative: true,
13438
- orientation: "horizontal"
13439
- }),
13440
- separatorVariants
13441
- );
13442
14049
  const TooltipProvider = TooltipPrimitive.Provider;
13443
14050
  const Tooltip = TooltipPrimitive.Root;
13444
14051
  const TooltipTrigger = TooltipPrimitive.Trigger;
@@ -13447,7 +14054,7 @@ const TooltipContent = withCn(
13447
14054
  withProps(TooltipPrimitive.Content, {
13448
14055
  sideOffset: 4
13449
14056
  }),
13450
- "z-50 overflow-hidden rounded-md border bg-popover px-3 py-1.5 text-sm text-popover-foreground shadow-md"
14057
+ "z-[9999] overflow-hidden rounded-md border bg-popover px-3 py-1.5 text-sm text-popover-foreground shadow-md"
13451
14058
  );
13452
14059
  function withTooltip(Component2) {
13453
14060
  return React__default.forwardRef(function ExtendComponent({ tooltip, tooltipContentProps, tooltipProps, ...props }, ref) {
@@ -13573,140 +14180,41 @@ const FixedToolbar = withCn(
13573
14180
  Toolbar,
13574
14181
  "p-1 sticky left-0 top-0 z-50 w-full justify-between overflow-x-auto border border-border bg-background"
13575
14182
  );
13576
- const MarkToolbarButton = withRef(({ clear, nodeType, ...rest }, ref) => {
13577
- const state = useMarkToolbarButtonState({ clear, nodeType });
13578
- const { props } = useMarkToolbarButton(state);
13579
- return /* @__PURE__ */ React__default.createElement(ToolbarButton, { ref, ...props, ...rest });
13580
- });
13581
- const IndentListToolbarButton = withRef(({ nodeType = ELEMENT_UL }, ref) => {
13582
- const editor = useEditorState();
13583
- const state = useListToolbarButtonState({ nodeType });
13584
- const { props } = useListToolbarButton(state);
13585
- return /* @__PURE__ */ React__default.createElement(
13586
- ToolbarButton,
13587
- {
13588
- ref,
13589
- tooltip: nodeType === ELEMENT_UL ? "Bulleted List" : "Numbered List",
13590
- ...props,
13591
- onClick: (e) => {
13592
- e.preventDefault();
13593
- e.stopPropagation();
13594
- toggleList(editor, { type: nodeType });
13595
- }
13596
- },
13597
- nodeType === ELEMENT_UL ? /* @__PURE__ */ React__default.createElement(Icons.ul, null) : /* @__PURE__ */ React__default.createElement(Icons.ol, null)
13598
- );
13599
- });
13600
- const DropdownMenu = DropdownMenuPrimitive.Root;
13601
- const DropdownMenuTrigger = DropdownMenuPrimitive.Trigger;
13602
- const DropdownMenuRadioGroup = DropdownMenuPrimitive.RadioGroup;
13603
- withRef(({ children, className, inset, ...props }, ref) => /* @__PURE__ */ React__default.createElement(
13604
- DropdownMenuPrimitive.SubTrigger,
13605
- {
13606
- className: cn$1(
13607
- "flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none focus:bg-accent data-[state=open]:bg-accent",
13608
- "data-[disabled]:pointer-events-none data-[disabled]:opacity-50",
13609
- inset && "pl-8",
13610
- className
13611
- ),
13612
- ref,
13613
- ...props
13614
- },
13615
- children,
13616
- /* @__PURE__ */ React__default.createElement(Icons.chevronRight, { className: "ml-auto size-4" })
13617
- ));
13618
- withCn(
13619
- DropdownMenuPrimitive.SubContent,
13620
- "z-[99999] min-w-32 overflow-hidden rounded-md border bg-white p-1 text-black shadow-lg data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2"
13621
- );
13622
- const DropdownMenuContentVariants = withProps(DropdownMenuPrimitive.Content, {
13623
- className: cn$1(
13624
- "z-[99999] min-w-32 overflow-hidden rounded-md border bg-white p-1 text-black shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2"
13625
- ),
13626
- sideOffset: 4
13627
- });
13628
- const DropdownMenuContent = withRef(({ ...props }, ref) => /* @__PURE__ */ React__default.createElement(DropdownMenuPrimitive.Portal, null, /* @__PURE__ */ React__default.createElement(DropdownMenuContentVariants, { ref, ...props })));
13629
- const menuItemVariants = cva(
13630
- cn$1(
13631
- "relative flex h-9 cursor-pointer select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none transition-colors",
13632
- "focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50"
13633
- ),
13634
- {
13635
- variants: {
13636
- inset: {
13637
- true: "pl-8"
14183
+ const useResize = (ref, callback) => {
14184
+ React__default.useEffect(() => {
14185
+ const resizeObserver = new ResizeObserver((entries) => {
14186
+ for (const entry of entries) {
14187
+ callback(entry);
13638
14188
  }
14189
+ });
14190
+ if (ref.current) {
14191
+ resizeObserver.observe(ref.current);
13639
14192
  }
13640
- }
13641
- );
13642
- const DropdownMenuItem = withVariants(
13643
- DropdownMenuPrimitive.Item,
13644
- menuItemVariants,
13645
- ["inset"]
13646
- );
13647
- withRef(({ children, className, ...props }, ref) => /* @__PURE__ */ React__default.createElement(
13648
- DropdownMenuPrimitive.CheckboxItem,
13649
- {
13650
- className: cn$1(
13651
- "relative flex select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",
13652
- "cursor-pointer",
13653
- className
13654
- ),
13655
- ref,
13656
- ...props
13657
- },
13658
- /* @__PURE__ */ React__default.createElement("span", { className: "absolute left-2 flex size-3.5 items-center justify-center" }, /* @__PURE__ */ React__default.createElement(DropdownMenuPrimitive.ItemIndicator, null, /* @__PURE__ */ React__default.createElement(Icons.check, { className: "size-4" }))),
13659
- children
13660
- ));
13661
- const DropdownMenuRadioItem = withRef(({ children, className, hideIcon, ...props }, ref) => /* @__PURE__ */ React__default.createElement(
13662
- DropdownMenuPrimitive.RadioItem,
13663
- {
13664
- className: cn$1(
13665
- "relative flex select-none items-center rounded-sm pl-8 pr-2 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",
13666
- "h-9 cursor-pointer px-2 data-[state=checked]:bg-accent data-[state=checked]:text-accent-foreground",
13667
- className
13668
- ),
13669
- ref,
13670
- ...props
13671
- },
13672
- !hideIcon && /* @__PURE__ */ React__default.createElement("span", { className: "absolute right-2 flex size-3.5 items-center justify-center" }, /* @__PURE__ */ React__default.createElement(DropdownMenuPrimitive.ItemIndicator, null, /* @__PURE__ */ React__default.createElement(Icons.check, { className: "size-4" }))),
14193
+ return () => resizeObserver.disconnect();
14194
+ }, [ref.current]);
14195
+ };
14196
+ const STANDARD_ICON_WIDTH = 32;
14197
+ const HEADING_ICON_WITH_TEXT = 127;
14198
+ const HEADING_ICON_ONLY = 58;
14199
+ const EMBED_ICON_WIDTH = 78;
14200
+ const CONTAINER_MD_BREAKPOINT = 448;
14201
+ const FLOAT_BUTTON_WIDTH = 25;
14202
+ const HEADING_LABEL = "Headings";
14203
+ const ToolbarContext = createContext(void 0);
14204
+ const ToolbarProvider = ({
14205
+ tinaForm,
14206
+ templates,
14207
+ overrides,
13673
14208
  children
13674
- ));
13675
- const dropdownMenuLabelVariants = cva(
13676
- cn$1("select-none px-2 py-1.5 text-sm font-semibold"),
13677
- {
13678
- variants: {
13679
- inset: {
13680
- true: "pl-8"
13681
- }
13682
- }
14209
+ }) => {
14210
+ return /* @__PURE__ */ React__default.createElement(ToolbarContext.Provider, { value: { tinaForm, templates, overrides } }, children);
14211
+ };
14212
+ const useToolbarContext = () => {
14213
+ const context = useContext(ToolbarContext);
14214
+ if (!context) {
14215
+ throw new Error("useToolbarContext must be used within a ToolbarProvider");
13683
14216
  }
13684
- );
13685
- const DropdownMenuLabel = withVariants(
13686
- DropdownMenuPrimitive.Label,
13687
- dropdownMenuLabelVariants,
13688
- ["inset"]
13689
- );
13690
- const DropdownMenuSeparator = withCn(
13691
- DropdownMenuPrimitive.Separator,
13692
- "-mx-1 my-1 h-px bg-muted"
13693
- );
13694
- withCn(
13695
- createPrimitiveElement("span"),
13696
- "ml-auto text-xs tracking-widest opacity-60"
13697
- );
13698
- const useOpenState = () => {
13699
- const [open2, setOpen] = useState(false);
13700
- const onOpenChange = useCallback(
13701
- (_value = !open2) => {
13702
- setOpen(_value);
13703
- },
13704
- [open2]
13705
- );
13706
- return {
13707
- onOpenChange,
13708
- open: open2
13709
- };
14217
+ return context;
13710
14218
  };
13711
14219
  const items$1 = [
13712
14220
  {
@@ -13772,7 +14280,9 @@ function HeadingsMenu(props) {
13772
14280
  return allNodesMatchInitialNodeType ? initialNodeType : ELEMENT_PARAGRAPH$1;
13773
14281
  }, []);
13774
14282
  const editor = useEditorRef();
14283
+ const editorState = useEditorState();
13775
14284
  const openState = useOpenState();
14285
+ const userInTable = helpers.isNodeActive(editorState, ELEMENT_TABLE$1);
13776
14286
  const selectedItem = items$1.find((item) => item.value === value) ?? defaultItem$1;
13777
14287
  const { icon: SelectedItemIcon, label: selectedItemLabel } = selectedItem;
13778
14288
  return /* @__PURE__ */ React__default.createElement(DropdownMenu, { modal: false, ...openState, ...props }, /* @__PURE__ */ React__default.createElement(DropdownMenuTrigger, { asChild: true }, /* @__PURE__ */ React__default.createElement(
@@ -13784,7 +14294,7 @@ function HeadingsMenu(props) {
13784
14294
  tooltip: "Headings"
13785
14295
  },
13786
14296
  /* @__PURE__ */ React__default.createElement(SelectedItemIcon, { className: "size-5" }),
13787
- /* @__PURE__ */ React__default.createElement("span", { className: "hidden 2xl:flex" }, selectedItemLabel)
14297
+ /* @__PURE__ */ React__default.createElement("span", { className: "@md/toolbar:flex hidden" }, selectedItemLabel)
13788
14298
  )), /* @__PURE__ */ React__default.createElement(DropdownMenuContent, { align: "start", className: "min-w-0" }, /* @__PURE__ */ React__default.createElement(
13789
14299
  DropdownMenuRadioGroup,
13790
14300
  {
@@ -13796,7 +14306,12 @@ function HeadingsMenu(props) {
13796
14306
  },
13797
14307
  value
13798
14308
  },
13799
- items$1.map(({ icon: Icon, label, value: itemValue }) => /* @__PURE__ */ React__default.createElement(
14309
+ items$1.filter((item) => {
14310
+ if (userInTable) {
14311
+ return !unsupportedItemsInTable.has(item.label);
14312
+ }
14313
+ return true;
14314
+ }).map(({ icon: Icon, label, value: itemValue }) => /* @__PURE__ */ React__default.createElement(
13800
14315
  DropdownMenuRadioItem,
13801
14316
  {
13802
14317
  className: "min-w-[180px]",
@@ -13808,42 +14323,6 @@ function HeadingsMenu(props) {
13808
14323
  ))
13809
14324
  )));
13810
14325
  }
13811
- const LinkToolbarButton = withRef((rest, ref) => {
13812
- const state = useLinkToolbarButtonState();
13813
- const { props } = useLinkToolbarButton(state);
13814
- return /* @__PURE__ */ React__default.createElement(ToolbarButton, { ref, tooltip: "Link", ...props, ...rest }, /* @__PURE__ */ React__default.createElement(Icons.link, null));
13815
- });
13816
- const useBlockQuoteToolbarButtonState = () => {
13817
- const editor = useEditorState();
13818
- const isBlockActive = () => helpers.isNodeActive(editor, ELEMENT_BLOCKQUOTE$1);
13819
- return {
13820
- pressed: isBlockActive()
13821
- };
13822
- };
13823
- const useBlockQuoteToolbarButton = (state) => {
13824
- const editor = useEditorState();
13825
- const onClick = () => {
13826
- toggleNodeType(editor, {
13827
- activeType: ELEMENT_BLOCKQUOTE$1
13828
- });
13829
- };
13830
- const onMouseDown = (e) => {
13831
- e.preventDefault();
13832
- e.stopPropagation();
13833
- };
13834
- return {
13835
- props: {
13836
- onClick,
13837
- onMouseDown,
13838
- pressed: state.pressed
13839
- }
13840
- };
13841
- };
13842
- const QuoteToolbarButton = withRef(({ clear, ...rest }, ref) => {
13843
- const state = useBlockQuoteToolbarButtonState();
13844
- const { props } = useBlockQuoteToolbarButton(state);
13845
- return /* @__PURE__ */ React__default.createElement(ToolbarButton, { ref, tooltip: "Link", ...rest, ...props }, /* @__PURE__ */ React__default.createElement(Icons.quote, null));
13846
- });
13847
14326
  const useCodeBlockToolbarButtonState = () => {
13848
14327
  const editor = useEditorState();
13849
14328
  const isBlockActive = () => helpers.isNodeActive(editor, ELEMENT_CODE_BLOCK$1);
@@ -13905,6 +14384,115 @@ const ImageToolbarButton = withRef(({ clear, ...rest }, ref) => {
13905
14384
  const { props } = useImageToolbarButton(state);
13906
14385
  return /* @__PURE__ */ React__default.createElement(ToolbarButton, { ref, tooltip: "Link", ...rest, ...props }, /* @__PURE__ */ React__default.createElement(Icons.image, null));
13907
14386
  });
14387
+ const IndentListToolbarButton = withRef(({ nodeType = ELEMENT_UL }, ref) => {
14388
+ const editor = useEditorState();
14389
+ const state = useListToolbarButtonState({ nodeType });
14390
+ const { props } = useListToolbarButton(state);
14391
+ return /* @__PURE__ */ React__default.createElement(
14392
+ ToolbarButton,
14393
+ {
14394
+ ref,
14395
+ tooltip: nodeType === ELEMENT_UL ? "Bulleted List" : "Numbered List",
14396
+ ...props,
14397
+ onClick: (e) => {
14398
+ e.preventDefault();
14399
+ e.stopPropagation();
14400
+ toggleList(editor, { type: nodeType });
14401
+ }
14402
+ },
14403
+ nodeType === ELEMENT_UL ? /* @__PURE__ */ React__default.createElement(Icons.ul, null) : /* @__PURE__ */ React__default.createElement(Icons.ol, null)
14404
+ );
14405
+ });
14406
+ const LinkToolbarButton = withRef((rest, ref) => {
14407
+ const state = useLinkToolbarButtonState();
14408
+ const { props } = useLinkToolbarButton(state);
14409
+ return /* @__PURE__ */ React__default.createElement(ToolbarButton, { ref, tooltip: "Link", ...props, ...rest }, /* @__PURE__ */ React__default.createElement(Icons.link, null));
14410
+ });
14411
+ const MarkToolbarButton = withRef(({ clear, nodeType, ...rest }, ref) => {
14412
+ const state = useMarkToolbarButtonState({ clear, nodeType });
14413
+ const { props } = useMarkToolbarButton(state);
14414
+ return /* @__PURE__ */ React__default.createElement(ToolbarButton, { ref, ...props, ...rest });
14415
+ });
14416
+ const useMermaidToolbarButtonState = () => {
14417
+ const editor = useEditorState();
14418
+ const isBlockActive = () => helpers.isNodeActive(editor, ELEMENT_MERMAID);
14419
+ return {
14420
+ pressed: isBlockActive()
14421
+ };
14422
+ };
14423
+ const useMermaidToolbarButton = (state) => {
14424
+ const editor = useEditorState();
14425
+ const onClick = () => {
14426
+ insertEmptyElement(editor, ELEMENT_MERMAID, {
14427
+ nextBlock: true,
14428
+ select: true
14429
+ });
14430
+ };
14431
+ const onMouseDown = (e) => {
14432
+ e.preventDefault();
14433
+ e.stopPropagation();
14434
+ };
14435
+ return {
14436
+ props: {
14437
+ onClick,
14438
+ onMouseDown,
14439
+ pressed: state.pressed
14440
+ }
14441
+ };
14442
+ };
14443
+ const MermaidToolbarButton = withRef(({ clear, ...rest }, ref) => {
14444
+ const state = useMermaidToolbarButtonState();
14445
+ const { props } = useMermaidToolbarButton(state);
14446
+ return /* @__PURE__ */ React__default.createElement(ToolbarButton, { ref, tooltip: "Mermaid", ...rest, ...props }, /* @__PURE__ */ React__default.createElement(Icons.mermaid, null));
14447
+ });
14448
+ function OverflowMenu({
14449
+ children,
14450
+ ...props
14451
+ }) {
14452
+ const openState = useOpenState();
14453
+ return /* @__PURE__ */ React__default.createElement(DropdownMenu, { modal: false, ...openState, ...props }, /* @__PURE__ */ React__default.createElement(DropdownMenuTrigger, { asChild: true }, /* @__PURE__ */ React__default.createElement(
14454
+ ToolbarButton,
14455
+ {
14456
+ showArrow: false,
14457
+ className: "lg:min-w-[130px]",
14458
+ isDropdown: true,
14459
+ pressed: openState.open,
14460
+ tooltip: "Headings"
14461
+ },
14462
+ /* @__PURE__ */ React__default.createElement(Icons.overflow, { className: "size-5" })
14463
+ )), /* @__PURE__ */ React__default.createElement(DropdownMenuContent, { align: "start", className: "min-w-0 flex flex-grow" }, children));
14464
+ }
14465
+ const useBlockQuoteToolbarButtonState = () => {
14466
+ const editor = useEditorState();
14467
+ const isBlockActive = () => helpers.isNodeActive(editor, ELEMENT_BLOCKQUOTE$1);
14468
+ return {
14469
+ pressed: isBlockActive()
14470
+ };
14471
+ };
14472
+ const useBlockQuoteToolbarButton = (state) => {
14473
+ const editor = useEditorState();
14474
+ const onClick = () => {
14475
+ toggleNodeType(editor, {
14476
+ activeType: ELEMENT_BLOCKQUOTE$1
14477
+ });
14478
+ };
14479
+ const onMouseDown = (e) => {
14480
+ e.preventDefault();
14481
+ e.stopPropagation();
14482
+ };
14483
+ return {
14484
+ props: {
14485
+ onClick,
14486
+ onMouseDown,
14487
+ pressed: state.pressed
14488
+ }
14489
+ };
14490
+ };
14491
+ const QuoteToolbarButton = withRef(({ clear, ...rest }, ref) => {
14492
+ const state = useBlockQuoteToolbarButtonState();
14493
+ const { props } = useBlockQuoteToolbarButton(state);
14494
+ return /* @__PURE__ */ React__default.createElement(ToolbarButton, { ref, tooltip: "Link", ...rest, ...props }, /* @__PURE__ */ React__default.createElement(Icons.quote, null));
14495
+ });
13908
14496
  const useRawMarkdownToolbarButton = () => {
13909
14497
  const { setRawMode } = useEditorContext();
13910
14498
  const onMouseDown = (e) => {
@@ -13921,29 +14509,111 @@ const RawMarkdownToolbarButton = withRef(({ clear, ...rest }, ref) => {
13921
14509
  const { props } = useRawMarkdownToolbarButton();
13922
14510
  return /* @__PURE__ */ React__default.createElement(ToolbarButton, { ref, tooltip: "Link", ...rest, ...props }, /* @__PURE__ */ React__default.createElement(Icons.raw, null));
13923
14511
  });
13924
- const ToolbarContext = createContext(void 0);
13925
- const ToolbarProvider = ({
13926
- tinaForm,
13927
- templates,
13928
- overrides,
13929
- children
13930
- }) => {
13931
- return /* @__PURE__ */ React__default.createElement(ToolbarContext.Provider, { value: { tinaForm, templates, overrides } }, children);
13932
- };
13933
- const useToolbarContext = () => {
13934
- const context = useContext(ToolbarContext);
13935
- if (!context) {
13936
- throw new Error("useToolbarContext must be used within a ToolbarProvider");
13937
- }
13938
- return context;
13939
- };
14512
+ function TableDropdownMenu(props) {
14513
+ const tableSelected = useEditorSelector(
14514
+ (editor2) => someNode(editor2, { match: { type: ELEMENT_TABLE$1 } }),
14515
+ []
14516
+ );
14517
+ const [enableDeleteColumn, enableDeleteRow] = useEditorSelector((editor2) => {
14518
+ const tableNodeEntry = findNode(editor2, { match: { type: ELEMENT_TABLE$1 } });
14519
+ if (!tableNodeEntry)
14520
+ return [false, false];
14521
+ const [tableNode] = tableNodeEntry;
14522
+ if (!isElement(tableNode))
14523
+ return [false, false];
14524
+ const columnCount = getTableColumnCount(tableNode);
14525
+ const rowCount = tableNode.children.length;
14526
+ return [columnCount > 1, rowCount > 1];
14527
+ }, []);
14528
+ const editor = useEditorRef();
14529
+ const openState = useOpenState();
14530
+ return /* @__PURE__ */ React__default.createElement(DropdownMenu, { modal: false, ...openState, ...props }, /* @__PURE__ */ React__default.createElement(DropdownMenuTrigger, { asChild: true }, /* @__PURE__ */ React__default.createElement(ToolbarButton, { isDropdown: true, pressed: openState.open, tooltip: "Table" }, /* @__PURE__ */ React__default.createElement(Icons.table, null))), /* @__PURE__ */ React__default.createElement(
14531
+ DropdownMenuContent,
14532
+ {
14533
+ align: "start",
14534
+ className: "flex w-[180px] min-w-0 flex-col gap-0.5"
14535
+ },
14536
+ /* @__PURE__ */ React__default.createElement(
14537
+ DropdownMenuItem,
14538
+ {
14539
+ className: "min-w-[180px]",
14540
+ disabled: tableSelected,
14541
+ onSelect: () => {
14542
+ insertTable(editor);
14543
+ focusEditor(editor);
14544
+ }
14545
+ },
14546
+ /* @__PURE__ */ React__default.createElement(Icons.add, { className: iconVariants({ variant: "menuItem" }) }),
14547
+ "Insert table"
14548
+ ),
14549
+ /* @__PURE__ */ React__default.createElement(
14550
+ DropdownMenuItem,
14551
+ {
14552
+ className: "min-w-[180px]",
14553
+ disabled: !tableSelected,
14554
+ onSelect: () => {
14555
+ deleteTable(editor);
14556
+ focusEditor(editor);
14557
+ }
14558
+ },
14559
+ /* @__PURE__ */ React__default.createElement(Icons.minus, { className: iconVariants({ variant: "menuItem" }) }),
14560
+ "Delete table"
14561
+ ),
14562
+ /* @__PURE__ */ React__default.createElement(DropdownMenuSub, null, /* @__PURE__ */ React__default.createElement(DropdownMenuSubTrigger, { disabled: !tableSelected }, /* @__PURE__ */ React__default.createElement(Icons.column, { className: iconVariants({ variant: "menuItem" }) }), /* @__PURE__ */ React__default.createElement("span", null, "Column")), /* @__PURE__ */ React__default.createElement(DropdownMenuSubContent, null, /* @__PURE__ */ React__default.createElement(
14563
+ DropdownMenuItem,
14564
+ {
14565
+ className: "min-w-[180px]",
14566
+ disabled: !tableSelected,
14567
+ onSelect: () => {
14568
+ insertTableColumn(editor);
14569
+ focusEditor(editor);
14570
+ }
14571
+ },
14572
+ /* @__PURE__ */ React__default.createElement(Icons.add, { className: iconVariants({ variant: "menuItem" }) }),
14573
+ "Insert column after"
14574
+ ), /* @__PURE__ */ React__default.createElement(
14575
+ DropdownMenuItem,
14576
+ {
14577
+ className: "min-w-[180px]",
14578
+ disabled: !enableDeleteColumn,
14579
+ onSelect: () => {
14580
+ deleteColumn(editor);
14581
+ focusEditor(editor);
14582
+ }
14583
+ },
14584
+ /* @__PURE__ */ React__default.createElement(Icons.minus, { className: iconVariants({ variant: "menuItem" }) }),
14585
+ "Delete column"
14586
+ ))),
14587
+ /* @__PURE__ */ React__default.createElement(DropdownMenuSub, null, /* @__PURE__ */ React__default.createElement(DropdownMenuSubTrigger, { disabled: !tableSelected }, /* @__PURE__ */ React__default.createElement(Icons.row, { className: iconVariants({ variant: "menuItem" }) }), /* @__PURE__ */ React__default.createElement("span", null, "Row")), /* @__PURE__ */ React__default.createElement(DropdownMenuSubContent, null, /* @__PURE__ */ React__default.createElement(
14588
+ DropdownMenuItem,
14589
+ {
14590
+ className: "min-w-[180px]",
14591
+ disabled: !tableSelected,
14592
+ onSelect: () => {
14593
+ insertTableRow(editor);
14594
+ focusEditor(editor);
14595
+ }
14596
+ },
14597
+ /* @__PURE__ */ React__default.createElement(Icons.add, { className: iconVariants({ variant: "menuItem" }) }),
14598
+ "Insert row after"
14599
+ ), /* @__PURE__ */ React__default.createElement(
14600
+ DropdownMenuItem,
14601
+ {
14602
+ className: "min-w-[180px]",
14603
+ disabled: !enableDeleteRow,
14604
+ onSelect: () => {
14605
+ deleteRow(editor);
14606
+ focusEditor(editor);
14607
+ }
14608
+ },
14609
+ /* @__PURE__ */ React__default.createElement(Icons.minus, { className: iconVariants({ variant: "menuItem" }) }),
14610
+ "Delete row"
14611
+ )))
14612
+ ));
14613
+ }
13940
14614
  function TemplatesToolbarButton() {
13941
14615
  const { templates } = useToolbarContext();
13942
- const showEmbed = templates.length > 0;
13943
14616
  const editor = useEditorState();
13944
- if (!showEmbed) {
13945
- return null;
13946
- }
13947
14617
  return /* @__PURE__ */ React__default.createElement(EmbedButton, { templates, editor });
13948
14618
  }
13949
14619
  const EmbedButton = ({ editor, templates }) => {
@@ -13984,99 +14654,113 @@ const EmbedButton = ({ editor, templates }) => {
13984
14654
  template.label || template.name
13985
14655
  ))));
13986
14656
  };
13987
- const ICON_WIDTH = 32;
13988
- const EMBED_ICON_WIDTH = 78;
13989
- const useResize = (ref, callback) => {
13990
- React__default.useEffect(() => {
13991
- const resizeObserver = new ResizeObserver((entries) => {
13992
- for (const entry of entries) {
13993
- callback(entry);
13994
- }
13995
- });
13996
- if (ref.current) {
13997
- resizeObserver.observe(ref.current);
13998
- }
13999
- return () => resizeObserver.disconnect();
14000
- }, [ref.current]);
14001
- };
14002
- function OverflowMenu({
14003
- children,
14004
- ...props
14005
- }) {
14006
- const openState = useOpenState();
14007
- return /* @__PURE__ */ React__default.createElement(DropdownMenu, { modal: false, ...openState, ...props }, /* @__PURE__ */ React__default.createElement(DropdownMenuTrigger, { asChild: true }, /* @__PURE__ */ React__default.createElement(
14008
- ToolbarButton,
14009
- {
14010
- showArrow: false,
14011
- className: "lg:min-w-[130px]",
14012
- isDropdown: true,
14013
- pressed: openState.open,
14014
- tooltip: "Headings"
14015
- },
14016
- /* @__PURE__ */ React__default.createElement(Icons.overflow, { className: "size-5" })
14017
- )), /* @__PURE__ */ React__default.createElement(DropdownMenuContent, { align: "start", className: "min-w-0 flex flex-grow" }, children));
14018
- }
14019
14657
  const toolbarItems = {
14020
14658
  heading: {
14021
- label: "Headings",
14659
+ label: HEADING_LABEL,
14660
+ width: (paragraphIconExists) => paragraphIconExists ? HEADING_ICON_WITH_TEXT : HEADING_ICON_ONLY,
14661
+ // Dynamically handle width based on paragraph icon
14022
14662
  Component: /* @__PURE__ */ React__default.createElement(ToolbarGroup, { noSeparator: true }, /* @__PURE__ */ React__default.createElement(HeadingsMenu, null))
14023
14663
  },
14024
14664
  link: {
14025
14665
  label: "Link",
14666
+ width: () => STANDARD_ICON_WIDTH,
14026
14667
  Component: /* @__PURE__ */ React__default.createElement(LinkToolbarButton, null)
14027
14668
  },
14028
14669
  image: {
14029
14670
  label: "Image",
14671
+ width: () => STANDARD_ICON_WIDTH,
14030
14672
  Component: /* @__PURE__ */ React__default.createElement(ImageToolbarButton, null)
14031
14673
  },
14032
14674
  quote: {
14033
14675
  label: "Quote",
14676
+ width: () => STANDARD_ICON_WIDTH,
14034
14677
  Component: /* @__PURE__ */ React__default.createElement(QuoteToolbarButton, { tooltip: "Quote Quote (⌘+⇧+.)" })
14035
14678
  },
14036
14679
  ul: {
14037
14680
  label: "Unordered List",
14681
+ width: () => STANDARD_ICON_WIDTH,
14038
14682
  Component: /* @__PURE__ */ React__default.createElement(IndentListToolbarButton, { nodeType: ELEMENT_UL })
14039
14683
  },
14040
14684
  ol: {
14041
14685
  label: "Ordered List",
14686
+ width: () => STANDARD_ICON_WIDTH,
14042
14687
  Component: /* @__PURE__ */ React__default.createElement(IndentListToolbarButton, { nodeType: ELEMENT_OL })
14043
14688
  },
14044
14689
  bold: {
14045
14690
  label: "Bold",
14691
+ width: () => STANDARD_ICON_WIDTH,
14046
14692
  Component: /* @__PURE__ */ React__default.createElement(MarkToolbarButton, { tooltip: "Bold (⌘+B)", nodeType: MARK_BOLD }, /* @__PURE__ */ React__default.createElement(Icons.bold, null))
14047
14693
  },
14048
14694
  italic: {
14049
14695
  label: "Italic",
14696
+ width: () => STANDARD_ICON_WIDTH,
14050
14697
  Component: /* @__PURE__ */ React__default.createElement(MarkToolbarButton, { tooltip: "Italic (⌘+I)", nodeType: MARK_ITALIC }, /* @__PURE__ */ React__default.createElement(Icons.italic, null))
14051
14698
  },
14052
14699
  code: {
14053
14700
  label: "Code",
14701
+ width: () => STANDARD_ICON_WIDTH,
14054
14702
  Component: /* @__PURE__ */ React__default.createElement(MarkToolbarButton, { tooltip: "Code (⌘+E)", nodeType: MARK_CODE }, /* @__PURE__ */ React__default.createElement(Icons.code, null))
14055
14703
  },
14056
14704
  codeBlock: {
14057
14705
  label: "Code Block",
14706
+ width: () => STANDARD_ICON_WIDTH,
14058
14707
  Component: /* @__PURE__ */ React__default.createElement(CodeBlockToolbarButton, null)
14059
14708
  },
14709
+ mermaid: {
14710
+ label: "Mermaid",
14711
+ width: () => STANDARD_ICON_WIDTH,
14712
+ Component: /* @__PURE__ */ React__default.createElement(MermaidToolbarButton, null)
14713
+ },
14714
+ table: {
14715
+ label: "Table",
14716
+ width: () => STANDARD_ICON_WIDTH,
14717
+ Component: /* @__PURE__ */ React__default.createElement(TableDropdownMenu, null)
14718
+ },
14060
14719
  raw: {
14061
14720
  label: "Raw Markdown",
14721
+ width: () => STANDARD_ICON_WIDTH,
14062
14722
  Component: /* @__PURE__ */ React__default.createElement(RawMarkdownToolbarButton, null)
14063
14723
  },
14064
14724
  embed: {
14065
14725
  label: "Templates",
14726
+ width: () => EMBED_ICON_WIDTH,
14066
14727
  Component: /* @__PURE__ */ React__default.createElement(TemplatesToolbarButton, null)
14067
14728
  }
14068
14729
  };
14069
14730
  function FixedToolbarButtons() {
14070
14731
  const toolbarRef = React__default.useRef(null);
14071
14732
  const [itemsShown, setItemsShown] = React__default.useState(11);
14072
- const { overrides } = useToolbarContext();
14733
+ const { overrides, templates } = useToolbarContext();
14734
+ const showEmbedButton = templates.length > 0;
14735
+ let items2 = overrides === void 0 ? Object.values(toolbarItems) : overrides.map((item) => toolbarItems[item]).filter((item) => item !== void 0);
14736
+ if (!showEmbedButton) {
14737
+ items2 = items2.filter((item) => item.label !== toolbarItems.embed.label);
14738
+ }
14739
+ const editorState = useEditorState();
14740
+ const userInTable = helpers.isNodeActive(editorState, ELEMENT_TABLE);
14741
+ if (userInTable) {
14742
+ items2 = items2.filter((item) => !unsupportedItemsInTable.has(item.label));
14743
+ }
14073
14744
  useResize(toolbarRef, (entry) => {
14074
14745
  const width = entry.target.getBoundingClientRect().width;
14075
- const itemsShown2 = (width - EMBED_ICON_WIDTH) / ICON_WIDTH;
14076
- setItemsShown(Math.floor(itemsShown2));
14746
+ const headingButton = items2.find((item) => item.label === HEADING_LABEL);
14747
+ const headingWidth = headingButton ? headingButton.width(width > CONTAINER_MD_BREAKPOINT) : 0;
14748
+ const availableWidth = width - headingWidth - FLOAT_BUTTON_WIDTH;
14749
+ const { itemFitCount } = items2.reduce(
14750
+ (acc, item) => {
14751
+ if (item.label !== HEADING_LABEL && acc.totalItemsWidth + item.width() <= availableWidth) {
14752
+ return {
14753
+ totalItemsWidth: acc.totalItemsWidth + item.width(),
14754
+ itemFitCount: acc.itemFitCount + 1
14755
+ };
14756
+ }
14757
+ return acc;
14758
+ },
14759
+ { totalItemsWidth: 0, itemFitCount: 1 }
14760
+ );
14761
+ setItemsShown(itemFitCount);
14077
14762
  });
14078
- const toolbarItemsArray = overrides === void 0 ? Object.values(toolbarItems) : overrides.map((item) => toolbarItems[item]).filter((item) => item !== void 0);
14079
- return /* @__PURE__ */ React__default.createElement("div", { className: "w-full overflow-hidden", ref: toolbarRef }, /* @__PURE__ */ React__default.createElement(
14763
+ return /* @__PURE__ */ React__default.createElement("div", { className: "w-full overflow-hidden @container/toolbar", ref: toolbarRef }, /* @__PURE__ */ React__default.createElement(
14080
14764
  "div",
14081
14765
  {
14082
14766
  className: "flex",
@@ -14084,7 +14768,7 @@ function FixedToolbarButtons() {
14084
14768
  transform: "translateX(calc(-1px))"
14085
14769
  }
14086
14770
  },
14087
- /* @__PURE__ */ React__default.createElement(React__default.Fragment, null, toolbarItemsArray.slice(0, itemsShown).map((item, index) => /* @__PURE__ */ React__default.createElement(React__default.Fragment, { key: item.label }, item.Component)), toolbarItemsArray.length > itemsShown && /* @__PURE__ */ React__default.createElement(OverflowMenu, null, toolbarItemsArray.slice(itemsShown).flatMap((c) => /* @__PURE__ */ React__default.createElement(React__default.Fragment, { key: c.label }, c.Component))))
14771
+ /* @__PURE__ */ React__default.createElement(React__default.Fragment, null, items2.slice(0, itemsShown).map((item) => /* @__PURE__ */ React__default.createElement(React__default.Fragment, { key: item.label }, item.Component)), items2.length > itemsShown && /* @__PURE__ */ React__default.createElement(OverflowMenu, null, items2.slice(itemsShown).flatMap((c) => /* @__PURE__ */ React__default.createElement(React__default.Fragment, { key: c.label }, c.Component))))
14088
14772
  ));
14089
14773
  }
14090
14774
  const FloatingToolbar = withRef(({ children, state, ...props }, componentRef) => {
@@ -14199,6 +14883,10 @@ function TurnIntoDropdownMenu(props) {
14199
14883
  const openState = useOpenState();
14200
14884
  const selectedItem = items.find((item) => item.value === value) ?? defaultItem;
14201
14885
  const { icon: SelectedItemIcon, label: selectedItemLabel } = selectedItem;
14886
+ const editorState = useEditorState();
14887
+ const userInTable = helpers.isNodeActive(editorState, ELEMENT_TABLE$1);
14888
+ if (userInTable)
14889
+ return null;
14202
14890
  return /* @__PURE__ */ React__default.createElement(DropdownMenu, { modal: false, ...openState, ...props }, /* @__PURE__ */ React__default.createElement(DropdownMenuTrigger, { asChild: true }, /* @__PURE__ */ React__default.createElement(
14203
14891
  ToolbarButton,
14204
14892
  {
@@ -14240,49 +14928,6 @@ function TurnIntoDropdownMenu(props) {
14240
14928
  function FloatingToolbarButtons() {
14241
14929
  return /* @__PURE__ */ React__default.createElement(React__default.Fragment, null, /* @__PURE__ */ React__default.createElement(TurnIntoDropdownMenu, null));
14242
14930
  }
14243
- const buttonVariants = cva(
14244
- "inline-flex items-center justify-center whitespace-nowrap rounded-md text-sm font-medium ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50",
14245
- {
14246
- defaultVariants: {
14247
- size: "default",
14248
- variant: "default"
14249
- },
14250
- variants: {
14251
- isMenu: {
14252
- true: "h-auto w-full cursor-pointer justify-start"
14253
- },
14254
- size: {
14255
- default: "h-10 px-4 py-2",
14256
- icon: "size-10",
14257
- lg: "h-11 rounded-md px-8",
14258
- none: "",
14259
- sm: "h-9 rounded-md px-3",
14260
- sms: "size-9 rounded-md px-0",
14261
- xs: "h-8 rounded-md px-3"
14262
- },
14263
- variant: {
14264
- default: "bg-primary text-primary-foreground hover:bg-primary/90",
14265
- destructive: "bg-destructive text-destructive-foreground hover:bg-destructive/90",
14266
- ghost: "hover:bg-accent hover:text-accent-foreground",
14267
- inlineLink: "text-base text-primary underline underline-offset-4",
14268
- link: "text-primary underline-offset-4 hover:underline",
14269
- outline: "border border-input bg-background hover:bg-accent hover:text-accent-foreground",
14270
- secondary: "bg-secondary text-secondary-foreground hover:bg-secondary/80"
14271
- }
14272
- }
14273
- }
14274
- );
14275
- withRef(({ asChild = false, className, isMenu, size, variant, ...props }, ref) => {
14276
- const Comp = asChild ? Slot : "button";
14277
- return /* @__PURE__ */ React.createElement(
14278
- Comp,
14279
- {
14280
- className: cn$1(buttonVariants({ className, isMenu, size, variant })),
14281
- ref,
14282
- ...props
14283
- }
14284
- );
14285
- });
14286
14931
  const inputVariants = cva(
14287
14932
  "flex w-full rounded-md bg-transparent text-sm file:border-0 file:bg-background file:text-sm file:font-medium placeholder:text-muted-foreground focus-visible:outline-none disabled:cursor-not-allowed disabled:opacity-50",
14288
14933
  {
@@ -14303,22 +14948,6 @@ const inputVariants = cva(
14303
14948
  }
14304
14949
  );
14305
14950
  withVariants("input", inputVariants, ["variant", "h"]);
14306
- const popoverVariants = cva(
14307
- "w-72 rounded-md border bg-popover p-4 text-popover-foreground shadow-md outline-none data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 print:hidden"
14308
- );
14309
- withRef(
14310
- ({ align = "center", className, sideOffset = 4, style, ...props }, ref) => /* @__PURE__ */ React.createElement(PopoverPrimitive.Portal, null, /* @__PURE__ */ React.createElement(
14311
- PopoverPrimitive.Content,
14312
- {
14313
- align,
14314
- className: cn$1(popoverVariants(), className),
14315
- ref,
14316
- sideOffset,
14317
- style: { zIndex: 1e3, ...style },
14318
- ...props
14319
- }
14320
- ))
14321
- );
14322
14951
  const floatingOptions = {
14323
14952
  middleware: [
14324
14953
  offset(12),
@@ -14378,7 +15007,7 @@ function LinkFloatingToolbar({ state }) {
14378
15007
  const editContent = editState.isEditing ? input : /* @__PURE__ */ React__default.createElement("div", { className: "box-content flex h-9 items-center gap-1" }, /* @__PURE__ */ React__default.createElement(
14379
15008
  "button",
14380
15009
  {
14381
- className: buttonVariants({ size: "sm", variant: "ghost" }),
15010
+ className: buttonVariants$1({ size: "sm", variant: "ghost" }),
14382
15011
  type: "button",
14383
15012
  ...editButtonProps
14384
15013
  },
@@ -14386,7 +15015,7 @@ function LinkFloatingToolbar({ state }) {
14386
15015
  ), /* @__PURE__ */ React__default.createElement(Separator, { orientation: "vertical" }), /* @__PURE__ */ React__default.createElement(
14387
15016
  LinkOpenButton,
14388
15017
  {
14389
- className: buttonVariants({
15018
+ className: buttonVariants$1({
14390
15019
  size: "sms",
14391
15020
  variant: "ghost"
14392
15021
  })
@@ -14395,7 +15024,7 @@ function LinkFloatingToolbar({ state }) {
14395
15024
  ), /* @__PURE__ */ React__default.createElement(Separator, { orientation: "vertical" }), /* @__PURE__ */ React__default.createElement(
14396
15025
  "button",
14397
15026
  {
14398
- className: buttonVariants({
15027
+ className: buttonVariants$1({
14399
15028
  size: "sms",
14400
15029
  variant: "ghost"
14401
15030
  }),
@@ -14469,6 +15098,7 @@ const RichEditor = (props) => {
14469
15098
  createMdxBlockPlugin(),
14470
15099
  createMdxInlinePlugin(),
14471
15100
  createImgPlugin(),
15101
+ createMermaidPlugin(),
14472
15102
  createInvalidMarkdownPlugin(),
14473
15103
  createLinkPlugin({
14474
15104
  options: {