tinacms 0.0.0-e0ddb8c-20241004065742 → 0.0.0-e70425b-20241028042614

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.mjs CHANGED
@@ -6,33 +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, insertEmptyElement, 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";
17
- 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, SquarePen, SunMoon } from "lucide-react";
19
- import { useComboboxContext, Combobox, useComboboxStore, ComboboxProvider, Portal, ComboboxPopover, ComboboxItem } from "@ariakit/react";
20
- 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";
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";
22
17
  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";
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";
19
+ import { cva } from "class-variance-authority";
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";
24
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";
24
+ import { useHTMLInputCursorState, useComboboxInput, filterWords } from "@udecode/plate-combobox";
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";
25
32
  import arrayMutators from "final-form-arrays";
26
33
  import setFieldData from "final-form-set-field-data";
27
34
  import { FORM_ERROR, createForm, getIn } from "final-form";
28
35
  import { Field, Form as Form$1 } from "react-final-form";
29
36
  import PropTypes from "prop-types";
30
37
  import { Droppable, Draggable, DragDropContext } from "react-beautiful-dnd";
31
- import * as PopoverPrimitive from "@radix-ui/react-popover";
32
38
  import * as pkg$1 from "react-color";
33
39
  import * as pkg from "color-string";
34
40
  import * as dropzone from "react-dropzone";
35
- import { Slot } from "@radix-ui/react-slot";
36
41
  import { clsx } from "clsx";
37
42
  import { twMerge } from "tailwind-merge";
38
43
  import { Command as Command$1 } from "cmdk";
@@ -43,10 +48,8 @@ import moment from "moment";
43
48
  import { formatDistanceToNow } from "date-fns";
44
49
  import { useLinkToolbarButtonState, useLinkToolbarButton, useFloatingLinkInsertState, useFloatingLinkInsert, useFloatingLinkEditState, useFloatingLinkEdit, FloatingLinkUrlInput, LinkOpenButton, createLinkPlugin } from "@udecode/plate-link";
45
50
  import * as ToolbarPrimitive from "@radix-ui/react-toolbar";
46
- import * as SeparatorPrimitive from "@radix-ui/react-separator";
47
51
  import * as TooltipPrimitive from "@radix-ui/react-tooltip";
48
52
  import { ELEMENT_PARAGRAPH as ELEMENT_PARAGRAPH$1 } from "@udecode/plate-paragraph";
49
- import * as DropdownMenuPrimitive from "@radix-ui/react-dropdown-menu";
50
53
  import { ELEMENT_BLOCKQUOTE as ELEMENT_BLOCKQUOTE$1 } from "@udecode/plate-block-quote";
51
54
  import { useFloatingToolbarState, offset, flip, useFloatingToolbar } from "@udecode/plate-floating";
52
55
  import { useWindowWidth } from "@react-hook/window-size";
@@ -906,6 +909,20 @@ const useEditorContext = () => {
906
909
  const useTemplates = () => {
907
910
  return React__default.useContext(EditorContext);
908
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
+ );
909
926
  function classNames$1(...classes) {
910
927
  return classes.filter(Boolean).join(" ");
911
928
  }
@@ -915,165 +932,662 @@ const uuid = () => {
915
932
  (c) => (c ^ crypto.getRandomValues(new Uint8Array(1))[0] & 15 >> c / 4).toString(16)
916
933
  );
917
934
  };
918
- 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]);
919
968
  return /* @__PURE__ */ React__default.createElement(
920
- "svg",
969
+ Combobox,
921
970
  {
922
- stroke: "currentColor",
923
- fill: "currentColor",
924
- strokeWidth: 0,
925
- role: "img",
926
- className: "h-5 w-5",
927
- viewBox: "0 0 24 24",
928
- height: "1em",
929
- width: "1em",
930
- xmlns: "http://www.w3.org/2000/svg"
971
+ value,
972
+ onChange,
973
+ as: "div",
974
+ className: "relative inline-block text-left z-20"
931
975
  },
932
- /* @__PURE__ */ React__default.createElement("title", null),
933
- /* @__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
+ )
934
1012
  );
935
1013
  };
936
- const MermaidIcon = () => /* @__PURE__ */ React__default.createElement(
937
- "svg",
938
- {
939
- width: "100%",
940
- height: "100%",
941
- viewBox: "0 0 491 491",
942
- version: "1.1",
943
- xmlns: "http://www.w3.org/2000/svg",
944
- fillRule: "evenodd",
945
- clipRule: "evenodd",
946
- strokeLinejoin: "round",
947
- strokeMiterlimit: 2
948
- },
949
- /* @__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" }),
950
- /* @__PURE__ */ React__default.createElement(
951
- "path",
952
- {
953
- 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",
954
- fill: "white",
955
- fillRule: "nonzero"
956
- }
957
- )
958
- );
959
- const borderAll = (props) => /* @__PURE__ */ React__default.createElement(
960
- "svg",
961
- {
962
- viewBox: "0 0 24 24",
963
- height: "48",
964
- width: "48",
965
- focusable: "false",
966
- role: "img",
967
- fill: "currentColor",
968
- xmlns: "http://www.w3.org/2000/svg",
969
- ...props
970
- },
971
- /* @__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" })
972
- );
973
- const borderBottom = (props) => /* @__PURE__ */ React__default.createElement(
974
- "svg",
975
- {
976
- viewBox: "0 0 24 24",
977
- height: "48",
978
- width: "48",
979
- focusable: "false",
980
- role: "img",
981
- fill: "currentColor",
982
- xmlns: "http://www.w3.org/2000/svg",
983
- ...props
984
- },
985
- /* @__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" })
986
- );
987
- const borderLeft = (props) => /* @__PURE__ */ React__default.createElement(
988
- "svg",
989
- {
990
- viewBox: "0 0 24 24",
991
- height: "48",
992
- width: "48",
993
- focusable: "false",
994
- role: "img",
995
- fill: "currentColor",
996
- xmlns: "http://www.w3.org/2000/svg",
997
- ...props
998
- },
999
- /* @__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" })
1000
- );
1001
- const borderNone = (props) => /* @__PURE__ */ React__default.createElement(
1002
- "svg",
1003
- {
1004
- viewBox: "0 0 24 24",
1005
- height: "48",
1006
- width: "48",
1007
- focusable: "false",
1008
- role: "img",
1009
- fill: "currentColor",
1010
- xmlns: "http://www.w3.org/2000/svg",
1011
- ...props
1012
- },
1013
- /* @__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" })
1014
- );
1015
- const borderRight = (props) => /* @__PURE__ */ React__default.createElement(
1016
- "svg",
1017
- {
1018
- viewBox: "0 0 24 24",
1019
- height: "48",
1020
- width: "48",
1021
- focusable: "false",
1022
- role: "img",
1023
- fill: "currentColor",
1024
- xmlns: "http://www.w3.org/2000/svg",
1025
- ...props
1026
- },
1027
- /* @__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" })
1028
- );
1029
- const borderTop = (props) => /* @__PURE__ */ React__default.createElement(
1030
- "svg",
1031
- {
1032
- viewBox: "0 0 24 24",
1033
- height: "48",
1034
- width: "48",
1035
- focusable: "false",
1036
- role: "img",
1037
- fill: "currentColor",
1038
- xmlns: "http://www.w3.org/2000/svg",
1039
- ...props
1040
- },
1041
- /* @__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" })
1042
- );
1043
- cva("", {
1044
- variants: {
1045
- variant: {
1046
- toolbar: "size-5",
1047
- menuItem: "mr-2 size-5"
1048
- },
1049
- size: {
1050
- sm: "mr-2 size-4",
1051
- md: "mr-2 size-6"
1052
- }
1053
- },
1054
- defaultVariants: {}
1014
+ loader.config({
1015
+ paths: { vs: "https://cdn.jsdelivr.net/npm/monaco-editor@0.31.1/min/vs" }
1055
1016
  });
1056
- const DoubleColumnOutlined = (props) => /* @__PURE__ */ React__default.createElement(
1057
- "svg",
1058
- {
1059
- fill: "none",
1060
- height: "16",
1061
- viewBox: "0 0 16 16",
1062
- width: "16",
1063
- xmlns: "http://www.w3.org/2000/svg",
1064
- ...props
1065
- },
1066
- /* @__PURE__ */ React__default.createElement(
1067
- "path",
1068
- {
1069
- clipRule: "evenodd",
1070
- 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",
1071
- fill: "#595E6F",
1072
- fillRule: "evenodd"
1073
- }
1074
- )
1075
- );
1076
- const ThreeColumnOutlined = (props) => /* @__PURE__ */ React__default.createElement(
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);
1027
+ }
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(
1077
1591
  "svg",
1078
1592
  {
1079
1593
  fill: "none",
@@ -1518,803 +2032,757 @@ function PlusIcon({ className = "" }) {
1518
2032
  const InlineComboboxContext = createContext(
1519
2033
  null
1520
2034
  );
1521
- const defaultFilter = ({ keywords = [], value }, search) => [value, ...keywords].some((keyword) => filterWords(keyword, search));
1522
- const InlineCombobox = ({
1523
- children,
1524
- element,
1525
- filter = defaultFilter,
1526
- hideWhenNoValue = false,
1527
- setValue: setValueProp,
1528
- showTrigger = true,
1529
- trigger,
1530
- value: valueProp
1531
- }) => {
1532
- const editor = useEditorRef();
1533
- const inputRef = React__default.useRef(null);
1534
- const cursorState = useHTMLInputCursorState(inputRef);
1535
- const [valueState, setValueState] = useState("");
1536
- const hasValueProp = valueProp !== void 0;
1537
- const value = hasValueProp ? valueProp : valueState;
1538
- const setValue = useCallback(
1539
- (newValue) => {
1540
- setValueProp == null ? void 0 : setValueProp(newValue);
1541
- if (!hasValueProp) {
1542
- setValueState(newValue);
1543
- }
1544
- },
1545
- [setValueProp, hasValueProp]
1546
- );
1547
- const [insertPoint, setInsertPoint] = useState(null);
1548
- useEffect(() => {
1549
- const path = findNodePath(editor, element);
1550
- if (!path)
1551
- return;
1552
- const point = getPointBefore(editor, path);
1553
- if (!point)
1554
- return;
1555
- const pointRef = createPointRef(editor, point);
1556
- setInsertPoint(pointRef);
1557
- return () => {
1558
- pointRef.unref();
1559
- };
1560
- }, [editor, element]);
1561
- const { props: inputProps, removeInput } = useComboboxInput({
1562
- cancelInputOnBlur: false,
1563
- cursorState,
1564
- onCancelInput: (cause) => {
1565
- if (cause !== "backspace") {
1566
- insertText(editor, trigger + value, {
1567
- at: (insertPoint == null ? void 0 : insertPoint.current) ?? void 0
1568
- });
1569
- }
1570
- if (cause === "arrowLeft" || cause === "arrowRight") {
1571
- moveSelection(editor, {
1572
- distance: 1,
1573
- reverse: cause === "arrowLeft"
1574
- });
1575
- }
1576
- },
1577
- ref: inputRef
1578
- });
1579
- const [hasEmpty, setHasEmpty] = useState(false);
1580
- const contextValue = useMemo(
1581
- () => ({
1582
- filter,
1583
- inputProps,
1584
- inputRef,
1585
- removeInput,
1586
- setHasEmpty,
1587
- showTrigger,
1588
- trigger
1589
- }),
1590
- [
1591
- trigger,
1592
- showTrigger,
1593
- filter,
1594
- inputRef,
1595
- inputProps,
1596
- removeInput,
1597
- setHasEmpty
1598
- ]
1599
- );
1600
- const store = useComboboxStore({
1601
- setValue: (newValue) => startTransition(() => setValue(newValue))
1602
- });
1603
- const items2 = store.useState("items");
1604
- useEffect(() => {
1605
- if (!store.getState().activeId) {
1606
- store.setActiveId(store.first());
1607
- }
1608
- }, [items2, store]);
1609
- return /* @__PURE__ */ React__default.createElement("span", { contentEditable: false }, /* @__PURE__ */ React__default.createElement(
1610
- ComboboxProvider,
1611
- {
1612
- open: (items2.length > 0 || hasEmpty) && (!hideWhenNoValue || value.length > 0),
1613
- store
1614
- },
1615
- /* @__PURE__ */ React__default.createElement(InlineComboboxContext.Provider, { value: contextValue }, children)
1616
- ));
1617
- };
1618
- const InlineComboboxInput = forwardRef(({ className, ...props }, propRef) => {
1619
- const {
1620
- inputProps,
1621
- inputRef: contextRef,
1622
- showTrigger,
1623
- trigger
1624
- } = useContext(InlineComboboxContext);
1625
- const store = useComboboxContext();
1626
- const value = store.useState("value");
1627
- const ref = useComposedRef(propRef, contextRef);
1628
- return /* @__PURE__ */ React__default.createElement(React__default.Fragment, null, showTrigger && trigger, /* @__PURE__ */ React__default.createElement("span", { className: "relative min-h-[1lh]" }, /* @__PURE__ */ React__default.createElement(
1629
- "span",
1630
- {
1631
- "aria-hidden": "true",
1632
- className: "invisible overflow-hidden text-nowrap"
1633
- },
1634
- value || "​"
1635
- ), /* @__PURE__ */ React__default.createElement(
1636
- Combobox,
1637
- {
1638
- autoSelect: true,
1639
- className: cn$1(
1640
- "absolute left-0 top-0 size-full bg-transparent outline-none",
1641
- className
1642
- ),
1643
- ref,
1644
- value,
1645
- ...inputProps,
1646
- ...props
1647
- }
1648
- )));
1649
- });
1650
- InlineComboboxInput.displayName = "InlineComboboxInput";
1651
- const InlineComboboxContent = ({
1652
- className,
1653
- ...props
1654
- }) => {
1655
- return /* @__PURE__ */ React__default.createElement(Portal, null, /* @__PURE__ */ React__default.createElement(
1656
- ComboboxPopover,
1657
- {
1658
- className: cn$1(
1659
- "z-[9999999] max-h-[288px] w-[300px] overflow-y-auto rounded-md bg-white shadow-md",
1660
- className
1661
- ),
1662
- ...props
1663
- }
1664
- ));
1665
- };
1666
- const comboboxItemVariants = cva(
1667
- "relative flex h-9 select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none",
1668
- {
1669
- defaultVariants: {
1670
- interactive: true
1671
- },
1672
- variants: {
1673
- interactive: {
1674
- false: "",
1675
- true: "cursor-pointer transition-colors hover:bg-blue-500 hover:text-black data-[active-item=true]:bg-orange-400 data-[active-item=true]:text-black"
1676
- }
1677
- }
1678
- }
1679
- );
1680
- const InlineComboboxItem = ({
1681
- className,
1682
- keywords,
1683
- onClick,
1684
- ...props
1685
- }) => {
1686
- const { value } = props;
1687
- const { filter, removeInput } = useContext(InlineComboboxContext);
1688
- const store = useComboboxContext();
1689
- const search = filter && store.useState("value");
1690
- const visible = useMemo(
1691
- () => !filter || filter({ keywords, value }, search),
1692
- [filter, value, keywords, search]
1693
- );
1694
- if (!visible)
1695
- return null;
1696
- return /* @__PURE__ */ React__default.createElement(
1697
- ComboboxItem,
1698
- {
1699
- className: cn$1(comboboxItemVariants(), className),
1700
- onClick: (event) => {
1701
- removeInput(true);
1702
- onClick == null ? void 0 : onClick(event);
1703
- },
1704
- ...props
1705
- }
1706
- );
1707
- };
1708
- const InlineComboboxEmpty = ({
2035
+ const defaultFilter = ({ keywords = [], value }, search) => [value, ...keywords].some((keyword) => filterWords(keyword, search));
2036
+ const InlineCombobox = ({
1709
2037
  children,
1710
- className
2038
+ element,
2039
+ filter = defaultFilter,
2040
+ hideWhenNoValue = false,
2041
+ setValue: setValueProp,
2042
+ showTrigger = true,
2043
+ trigger,
2044
+ value: valueProp
1711
2045
  }) => {
1712
- const { setHasEmpty } = useContext(InlineComboboxContext);
1713
- const store = useComboboxContext();
1714
- const items2 = store.useState("items");
2046
+ const editor = useEditorRef();
2047
+ const inputRef = React__default.useRef(null);
2048
+ const cursorState = useHTMLInputCursorState(inputRef);
2049
+ const [valueState, setValueState] = useState("");
2050
+ const hasValueProp = valueProp !== void 0;
2051
+ const value = hasValueProp ? valueProp : valueState;
2052
+ const setValue = useCallback(
2053
+ (newValue) => {
2054
+ setValueProp == null ? void 0 : setValueProp(newValue);
2055
+ if (!hasValueProp) {
2056
+ setValueState(newValue);
2057
+ }
2058
+ },
2059
+ [setValueProp, hasValueProp]
2060
+ );
2061
+ const [insertPoint, setInsertPoint] = useState(null);
1715
2062
  useEffect(() => {
1716
- setHasEmpty(true);
2063
+ const path = findNodePath(editor, element);
2064
+ if (!path)
2065
+ return;
2066
+ const point = getPointBefore(editor, path);
2067
+ if (!point)
2068
+ return;
2069
+ const pointRef = createPointRef(editor, point);
2070
+ setInsertPoint(pointRef);
1717
2071
  return () => {
1718
- setHasEmpty(false);
2072
+ pointRef.unref();
1719
2073
  };
1720
- }, [setHasEmpty]);
1721
- if (items2.length > 0)
1722
- return null;
1723
- return /* @__PURE__ */ React__default.createElement(
1724
- "div",
1725
- {
1726
- className: cn$1(comboboxItemVariants({ interactive: false }), className)
2074
+ }, [editor, element]);
2075
+ const { props: inputProps, removeInput } = useComboboxInput({
2076
+ cancelInputOnBlur: false,
2077
+ cursorState,
2078
+ onCancelInput: (cause) => {
2079
+ if (cause !== "backspace") {
2080
+ insertText(editor, trigger + value, {
2081
+ at: (insertPoint == null ? void 0 : insertPoint.current) ?? void 0
2082
+ });
2083
+ }
2084
+ if (cause === "arrowLeft" || cause === "arrowRight") {
2085
+ moveSelection(editor, {
2086
+ distance: 1,
2087
+ reverse: cause === "arrowLeft"
2088
+ });
2089
+ }
1727
2090
  },
1728
- children
2091
+ ref: inputRef
2092
+ });
2093
+ const [hasEmpty, setHasEmpty] = useState(false);
2094
+ const contextValue = useMemo(
2095
+ () => ({
2096
+ filter,
2097
+ inputProps,
2098
+ inputRef,
2099
+ removeInput,
2100
+ setHasEmpty,
2101
+ showTrigger,
2102
+ trigger
2103
+ }),
2104
+ [
2105
+ trigger,
2106
+ showTrigger,
2107
+ filter,
2108
+ inputRef,
2109
+ inputProps,
2110
+ removeInput,
2111
+ setHasEmpty
2112
+ ]
1729
2113
  );
1730
- };
1731
- const rules = [
1732
- {
1733
- icon: Icons.h1,
1734
- onSelect: (editor) => {
1735
- toggleNodeType(editor, { activeType: ELEMENT_H1 });
1736
- },
1737
- value: "Heading 1"
1738
- },
1739
- {
1740
- icon: Icons.h2,
1741
- onSelect: (editor) => {
1742
- toggleNodeType(editor, { activeType: ELEMENT_H2 });
1743
- },
1744
- value: "Heading 2"
1745
- },
1746
- {
1747
- icon: Icons.h3,
1748
- onSelect: (editor) => {
1749
- toggleNodeType(editor, { activeType: ELEMENT_H3 });
1750
- },
1751
- value: "Heading 3"
1752
- },
1753
- {
1754
- icon: Icons.ul,
1755
- keywords: ["ul", "unordered list"],
1756
- onSelect: (editor) => {
1757
- toggleList(editor, { type: ELEMENT_UL });
1758
- },
1759
- value: "Bulleted list"
1760
- },
1761
- {
1762
- icon: Icons.ol,
1763
- keywords: ["ol", "ordered list"],
1764
- onSelect: (editor) => {
1765
- toggleList(editor, { type: ELEMENT_OL });
1766
- },
1767
- value: "Numbered list"
1768
- }
1769
- ];
1770
- const SlashInputElement = withRef(
1771
- ({ className, ...props }, ref) => {
1772
- const { children, editor, element } = props;
1773
- return /* @__PURE__ */ React__default.createElement(
1774
- PlateElement,
1775
- {
1776
- as: "span",
1777
- "data-slate-value": element.value,
1778
- ref,
1779
- ...props
1780
- },
1781
- /* @__PURE__ */ React__default.createElement(InlineCombobox, { element, trigger: "/" }, /* @__PURE__ */ React__default.createElement(InlineComboboxInput, null), /* @__PURE__ */ React__default.createElement(InlineComboboxContent, null, /* @__PURE__ */ React__default.createElement(InlineComboboxEmpty, null, "No matching commands found"), rules.map(({ icon: Icon, keywords, onSelect, value }) => /* @__PURE__ */ React__default.createElement(
1782
- InlineComboboxItem,
1783
- {
1784
- key: value,
1785
- keywords,
1786
- onClick: () => onSelect(editor),
1787
- value
1788
- },
1789
- /* @__PURE__ */ React__default.createElement(Icon, { "aria-hidden": true, className: "mr-2 size-4" }),
1790
- value
1791
- )))),
1792
- children
1793
- );
1794
- }
1795
- );
1796
- const listVariants = cva("m-0 ps-6", {
1797
- variants: {
1798
- variant: {
1799
- ol: "list-decimal",
1800
- ul: "list-disc [&_ul]:list-[circle] [&_ul_ul]:list-[square]"
1801
- }
1802
- }
1803
- });
1804
- const ListElementVariants = withVariants(PlateElement, listVariants, [
1805
- "variant"
1806
- ]);
1807
- const ListElement = withRef(
1808
- ({ children, variant = "ul", ...props }, ref) => {
1809
- const Component2 = variant;
1810
- return /* @__PURE__ */ React__default.createElement(ListElementVariants, { asChild: true, ref, variant, ...props }, /* @__PURE__ */ React__default.createElement(Component2, null, children));
1811
- }
1812
- );
1813
- const BlockquoteElement = withRef(
1814
- ({ children, className, ...props }, ref) => {
1815
- return /* @__PURE__ */ React__default.createElement(
1816
- PlateElement,
1817
- {
1818
- asChild: true,
1819
- className: cn$1("my-1 border-l-2 pl-6 italic", className),
1820
- ref,
1821
- ...props
1822
- },
1823
- /* @__PURE__ */ React__default.createElement("blockquote", null, children)
1824
- );
1825
- }
1826
- );
1827
- const CodeLeaf = withRef(
1828
- ({ children, className, ...props }, ref) => {
1829
- return /* @__PURE__ */ React__default.createElement(
1830
- PlateLeaf,
1831
- {
1832
- asChild: true,
1833
- className: cn$1(
1834
- "whitespace-pre-wrap rounded-md bg-muted px-[0.3em] py-[0.2em] font-mono text-sm",
1835
- className
1836
- ),
1837
- ref,
1838
- ...props
1839
- },
1840
- /* @__PURE__ */ React__default.createElement("code", null, children)
1841
- );
1842
- }
1843
- );
1844
- const CodeLineElement = withRef((props, ref) => /* @__PURE__ */ React__default.createElement(PlateElement, { ref, ...props }));
1845
- const CodeSyntaxLeaf = withRef(
1846
- ({ children, ...props }, ref) => {
1847
- const { leaf } = props;
1848
- const { tokenProps } = useCodeSyntaxLeaf({ leaf });
1849
- return /* @__PURE__ */ React__default.createElement(PlateLeaf, { ref, ...props }, /* @__PURE__ */ React__default.createElement("span", { ...tokenProps }, children));
1850
- }
1851
- );
1852
- function ChevronDownIcon(props, svgRef) {
1853
- return /* @__PURE__ */ React.createElement("svg", Object.assign({
1854
- xmlns: "http://www.w3.org/2000/svg",
1855
- viewBox: "0 0 20 20",
1856
- fill: "currentColor",
1857
- "aria-hidden": "true",
1858
- ref: svgRef
1859
- }, props), /* @__PURE__ */ React.createElement("path", {
1860
- fillRule: "evenodd",
1861
- 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",
1862
- clipRule: "evenodd"
1863
- }));
1864
- }
1865
- const ForwardRef = React.forwardRef(ChevronDownIcon);
1866
- const ChevronDownIcon$1 = ForwardRef;
1867
- const Autocomplete = ({
1868
- value,
1869
- onChange,
1870
- defaultQuery,
1871
- items: items2
1872
- }) => {
1873
- const [query, setQuery] = React__default.useState(defaultQuery ?? "");
1874
- const filteredItems = React__default.useMemo(() => {
1875
- try {
1876
- const reFilter = new RegExp(query, "i");
1877
- const _items = items2.filter((item) => reFilter.test(item.label));
1878
- if (_items.length === 0)
1879
- return items2;
1880
- return _items;
1881
- } catch (err) {
1882
- return items2;
2114
+ const store = useComboboxStore({
2115
+ setValue: (newValue) => startTransition(() => setValue(newValue))
2116
+ });
2117
+ const items2 = store.useState("items");
2118
+ useEffect(() => {
2119
+ if (!store.getState().activeId) {
2120
+ store.setActiveId(store.first());
1883
2121
  }
1884
- }, [items2, query]);
1885
- return /* @__PURE__ */ React__default.createElement(
2122
+ }, [items2, store]);
2123
+ return /* @__PURE__ */ React__default.createElement("span", { contentEditable: false }, /* @__PURE__ */ React__default.createElement(
2124
+ ComboboxProvider,
2125
+ {
2126
+ open: (items2.length > 0 || hasEmpty) && (!hideWhenNoValue || value.length > 0),
2127
+ store
2128
+ },
2129
+ /* @__PURE__ */ React__default.createElement(InlineComboboxContext.Provider, { value: contextValue }, children)
2130
+ ));
2131
+ };
2132
+ const InlineComboboxInput = forwardRef(({ className, ...props }, propRef) => {
2133
+ const {
2134
+ inputProps,
2135
+ inputRef: contextRef,
2136
+ showTrigger,
2137
+ trigger
2138
+ } = useContext(InlineComboboxContext);
2139
+ const store = useComboboxContext();
2140
+ const value = store.useState("value");
2141
+ const ref = useComposedRef(propRef, contextRef);
2142
+ return /* @__PURE__ */ React__default.createElement(React__default.Fragment, null, showTrigger && trigger, /* @__PURE__ */ React__default.createElement("span", { className: "relative min-h-[1lh]" }, /* @__PURE__ */ React__default.createElement(
2143
+ "span",
2144
+ {
2145
+ "aria-hidden": "true",
2146
+ className: "invisible overflow-hidden text-nowrap"
2147
+ },
2148
+ value || "​"
2149
+ ), /* @__PURE__ */ React__default.createElement(
1886
2150
  Combobox$1,
1887
2151
  {
2152
+ autoSelect: true,
2153
+ className: cn$1(
2154
+ "absolute left-0 top-0 size-full bg-transparent outline-none",
2155
+ className
2156
+ ),
2157
+ ref,
1888
2158
  value,
1889
- onChange,
1890
- as: "div",
1891
- className: "relative inline-block text-left z-20"
1892
- },
1893
- /* @__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(
1894
- ComboboxInput,
1895
- {
1896
- 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",
1897
- displayValue: (item) => (item == null ? void 0 : item.label) ?? "Plain Text",
1898
- onChange: (event) => setQuery(event.target.value),
1899
- onClick: (ev) => ev.stopPropagation()
1900
- }
1901
- ), /* @__PURE__ */ React__default.createElement(ComboboxButton, { className: "absolute inset-y-0 right-0 flex items-center pr-2" }, /* @__PURE__ */ React__default.createElement(
1902
- ChevronDownIcon$1,
1903
- {
1904
- className: "h-5 w-5 text-gray-400",
1905
- "aria-hidden": "true"
1906
- }
1907
- )))),
1908
- /* @__PURE__ */ React__default.createElement(
1909
- Transition,
1910
- {
1911
- enter: "transition ease-out duration-100",
1912
- enterFrom: "transform opacity-0 scale-95",
1913
- enterTo: "transform opacity-100 scale-100",
1914
- leave: "transition ease-in duration-75",
1915
- leaveFrom: "transform opacity-100 scale-100",
1916
- leaveTo: "transform opacity-0 scale-95"
1917
- },
1918
- /* @__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(
1919
- "button",
1920
- {
1921
- className: classNames$1(
1922
- focus ? "bg-gray-100 text-gray-900" : "text-gray-700",
1923
- "block px-4 py-2 text-xs w-full text-right"
1924
- )
1925
- },
1926
- item.render(item)
1927
- ))))
1928
- )
1929
- );
1930
- };
1931
- loader.config({
1932
- paths: { vs: "https://cdn.jsdelivr.net/npm/monaco-editor@0.31.1/min/vs" }
1933
- });
1934
- let retryCount = 0;
1935
- const retryFocus = (ref) => {
1936
- if (ref.current) {
1937
- ref.current.focus();
1938
- } else {
1939
- if (retryCount < 30) {
1940
- setTimeout(() => {
1941
- retryCount = retryCount + 1;
1942
- retryFocus(ref);
1943
- }, 100);
2159
+ ...inputProps,
2160
+ ...props
1944
2161
  }
1945
- }
1946
- };
1947
- const MINIMUM_HEIGHT = 75;
1948
- const CodeBlock = ({
1949
- attributes,
1950
- editor,
1951
- element,
1952
- language: restrictLanguage,
1953
- onChangeCallback,
1954
- defaultValue,
2162
+ )));
2163
+ });
2164
+ InlineComboboxInput.displayName = "InlineComboboxInput";
2165
+ const InlineComboboxContent = ({
2166
+ className,
1955
2167
  ...props
1956
2168
  }) => {
1957
- const [navigateAway, setNavigateAway] = React__default.useState(null);
1958
- const monaco = useMonaco();
1959
- const monacoEditorRef = React__default.useRef(null);
1960
- const selected = useSelected();
1961
- const [height, setHeight] = React__default.useState(MINIMUM_HEIGHT);
1962
- React__default.useEffect(() => {
1963
- if (selected && isCollapsed(editor.selection)) {
1964
- retryFocus(monacoEditorRef);
1965
- }
1966
- }, [selected, monacoEditorRef.current]);
1967
- const value = element.value || "";
1968
- if (typeof value !== "string") {
1969
- throw new Error("Element must be of type string for code block");
1970
- }
1971
- const language = restrictLanguage || element.lang;
1972
- const id = React__default.useMemo(() => uuid(), []);
1973
- const languages = React__default.useMemo(() => {
1974
- const defaultLangSet = { "": "plain text" };
1975
- if (!monaco)
1976
- return defaultLangSet;
1977
- return monaco.languages.getLanguages().reduce((ac, cv) => {
1978
- if (cv.id === "plaintext")
1979
- return ac;
1980
- return { ...ac, [cv.id]: cv.id };
1981
- }, defaultLangSet);
1982
- }, [monaco]);
1983
- React__default.useEffect(() => {
1984
- if (monaco) {
1985
- monaco.languages.typescript.typescriptDefaults.setEagerModelSync(true);
1986
- monaco.languages.typescript.typescriptDefaults.setDiagnosticsOptions({
1987
- // disable errors
1988
- noSemanticValidation: true,
1989
- noSyntaxValidation: true
1990
- });
2169
+ return /* @__PURE__ */ React__default.createElement(Portal, null, /* @__PURE__ */ React__default.createElement(
2170
+ ComboboxPopover,
2171
+ {
2172
+ className: cn$1(
2173
+ "z-[9999999] max-h-[288px] w-[300px] overflow-y-auto rounded-md bg-white shadow-md",
2174
+ className
2175
+ ),
2176
+ ...props
1991
2177
  }
1992
- }, [monaco]);
1993
- const items2 = Object.entries(languages).map(([key, label]) => ({
1994
- key,
1995
- label,
1996
- render: (item) => item.label
1997
- }));
1998
- const currentItem = React__default.useMemo(() => {
1999
- return items2.find((item) => item.key === language) ?? {
2000
- key: "",
2001
- label: "Plain Text"
2002
- };
2003
- }, [items2, language]);
2004
- React__default.useEffect(() => {
2005
- if (navigateAway) {
2006
- setNavigateAway(null);
2007
- switch (navigateAway) {
2008
- case "remove":
2009
- {
2010
- focusEditor(editor);
2011
- setNodes(
2012
- editor,
2013
- {
2014
- type: "p",
2015
- children: [{ text: "" }],
2016
- lang: void 0,
2017
- value: void 0
2018
- },
2019
- {
2020
- match: (n) => {
2021
- if (isElement(n) && n.type === element.type) {
2022
- return true;
2023
- }
2024
- }
2025
- }
2026
- );
2027
- }
2028
- break;
2029
- case "insertNext":
2030
- {
2031
- insertNodes(
2032
- editor,
2033
- [
2034
- {
2035
- type: ELEMENT_DEFAULT,
2036
- children: [{ text: "" }],
2037
- lang: void 0,
2038
- value: void 0
2039
- }
2040
- ],
2041
- { select: true }
2042
- );
2043
- focusEditor(editor);
2044
- }
2045
- break;
2046
- case "up":
2047
- {
2048
- const path = findNodePath(editor, element);
2049
- if (!path) {
2050
- return;
2051
- }
2052
- const previousNodePath = getPointBefore(editor, path);
2053
- if (!previousNodePath) {
2054
- focusEditor(editor);
2055
- insertNodes(
2056
- editor,
2057
- [
2058
- {
2059
- type: ELEMENT_DEFAULT,
2060
- children: [{ text: "" }],
2061
- lang: void 0,
2062
- value: void 0
2063
- }
2064
- ],
2065
- // Insert a new node at the current path, resulting in the code_block
2066
- // moving down one block
2067
- { at: path, select: true }
2068
- );
2069
- return;
2070
- }
2071
- focusEditor(editor, previousNodePath);
2072
- }
2073
- break;
2074
- case "down": {
2075
- const path = findNodePath(editor, element);
2076
- if (!path) {
2077
- return;
2078
- }
2079
- const nextNodePath = getPointAfter(editor, path);
2080
- if (!nextNodePath) {
2081
- insertNodes(
2082
- editor,
2083
- [
2084
- {
2085
- type: ELEMENT_DEFAULT,
2086
- children: [{ text: "" }],
2087
- lang: void 0,
2088
- value: void 0
2089
- }
2090
- ],
2091
- { select: true }
2092
- );
2093
- focusEditor(editor);
2094
- } else {
2095
- focusEditor(editor, nextNodePath);
2096
- }
2097
- break;
2098
- }
2178
+ ));
2179
+ };
2180
+ const comboboxItemVariants = cva(
2181
+ "relative flex h-9 select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none",
2182
+ {
2183
+ defaultVariants: {
2184
+ interactive: true
2185
+ },
2186
+ variants: {
2187
+ interactive: {
2188
+ false: "",
2189
+ true: "cursor-pointer transition-colors hover:bg-blue-500 hover:text-black data-[active-item=true]:bg-orange-400 data-[active-item=true]:text-black"
2099
2190
  }
2100
2191
  }
2101
- }, [navigateAway]);
2102
- function handleEditorDidMount(monacoEditor, monaco2) {
2103
- monacoEditorRef.current = monacoEditor;
2104
- monacoEditor.onDidContentSizeChange(() => {
2105
- setHeight(
2106
- monacoEditor.getContentHeight() > MINIMUM_HEIGHT ? monacoEditor.getContentHeight() : MINIMUM_HEIGHT
2107
- );
2108
- monacoEditor.layout();
2109
- });
2110
- setNodes(editor, { value: defaultValue, lang: language });
2111
- monacoEditor.addCommand(monaco2.KeyMod.Shift | monaco2.KeyCode.Enter, () => {
2112
- if (monacoEditor.hasTextFocus()) {
2113
- setNavigateAway("insertNext");
2114
- }
2115
- });
2116
- monacoEditor.onKeyDown((l) => {
2117
- if (l.code === "ArrowUp") {
2118
- const selection = monacoEditor.getSelection();
2119
- if (selection.endLineNumber === 1 && selection.startLineNumber === 1) {
2120
- setNavigateAway("up");
2121
- }
2122
- }
2123
- if (l.code === "ArrowDown") {
2124
- const selection = monacoEditor.getSelection();
2125
- const totalLines = monacoEditor.getModel().getLineCount();
2126
- if (selection.endLineNumber === totalLines && selection.startLineNumber === totalLines) {
2127
- setNavigateAway("down");
2128
- }
2129
- }
2130
- if (l.code === "Backspace") {
2131
- const selection = monacoEditor.getSelection();
2132
- 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) {
2133
- setNavigateAway("remove");
2134
- }
2135
- }
2136
- });
2137
2192
  }
2193
+ );
2194
+ const InlineComboboxItem = ({
2195
+ className,
2196
+ keywords,
2197
+ onClick,
2198
+ ...props
2199
+ }) => {
2200
+ const { value } = props;
2201
+ const { filter, removeInput } = useContext(InlineComboboxContext);
2202
+ const store = useComboboxContext();
2203
+ const search = filter && store.useState("value");
2204
+ const visible = useMemo(
2205
+ () => !filter || filter({ keywords, value }, search),
2206
+ [filter, value, keywords, search]
2207
+ );
2208
+ if (!visible)
2209
+ return null;
2210
+ return /* @__PURE__ */ React__default.createElement(
2211
+ ComboboxItem,
2212
+ {
2213
+ className: cn$1(comboboxItemVariants(), className),
2214
+ onClick: (event) => {
2215
+ removeInput(true);
2216
+ onClick == null ? void 0 : onClick(event);
2217
+ },
2218
+ ...props
2219
+ }
2220
+ );
2221
+ };
2222
+ const InlineComboboxEmpty = ({
2223
+ children,
2224
+ className
2225
+ }) => {
2226
+ const { setHasEmpty } = useContext(InlineComboboxContext);
2227
+ const store = useComboboxContext();
2228
+ const items2 = store.useState("items");
2229
+ useEffect(() => {
2230
+ setHasEmpty(true);
2231
+ return () => {
2232
+ setHasEmpty(false);
2233
+ };
2234
+ }, [setHasEmpty]);
2235
+ if (items2.length > 0)
2236
+ return null;
2138
2237
  return /* @__PURE__ */ React__default.createElement(
2139
2238
  "div",
2140
2239
  {
2141
- ...attributes,
2142
- className: "relative mb-2 mt-0.5 rounded-lg shadow-md p-2 border-gray-200 border"
2240
+ className: cn$1(comboboxItemVariants({ interactive: false }), className)
2143
2241
  },
2144
- /* @__PURE__ */ React__default.createElement("style", null, `.monaco-editor .editor-widget {
2145
- display: none !important;
2146
- visibility: hidden !important;
2147
- }`),
2148
- props.children,
2149
- /* @__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(
2150
- Autocomplete,
2151
- {
2152
- items: items2,
2153
- value: currentItem,
2154
- defaultQuery: "plaintext",
2155
- onChange: (item) => setNodes(editor, { lang: item.key })
2156
- }
2157
- )), /* @__PURE__ */ React__default.createElement("div", { style: { height: `${height}px` } }, /* @__PURE__ */ React__default.createElement(
2158
- MonacoEditor,
2159
- {
2160
- path: id,
2161
- onMount: handleEditorDidMount,
2162
- options: {
2163
- scrollBeyondLastLine: false,
2164
- // automaticLayout: true,
2165
- tabSize: 2,
2166
- disableLayerHinting: true,
2167
- accessibilitySupport: "off",
2168
- codeLens: false,
2169
- wordWrap: "on",
2170
- minimap: {
2171
- enabled: false
2172
- },
2173
- fontSize: 14,
2174
- lineHeight: 2,
2175
- formatOnPaste: true,
2176
- lineNumbers: "off",
2177
- formatOnType: true,
2178
- fixedOverflowWidgets: true,
2179
- // Takes too much horizontal space for iframe
2180
- folding: false,
2181
- renderLineHighlight: "none",
2182
- scrollbar: {
2183
- verticalScrollbarSize: 1,
2184
- horizontalScrollbarSize: 1,
2185
- // https://github.com/microsoft/monaco-editor/issues/2007#issuecomment-644425664
2186
- alwaysConsumeMouseWheel: false
2187
- }
2188
- },
2189
- language: String(language),
2190
- value: String(element.value),
2191
- onChange: (value2) => {
2192
- onChangeCallback == null ? void 0 : onChangeCallback(value2);
2193
- setNodes(editor, { value: value2, lang: language });
2194
- }
2195
- }
2196
- )))
2242
+ children
2197
2243
  );
2198
2244
  };
2199
- const CodeBlockElement = withRef(
2245
+ const rules = [
2246
+ {
2247
+ icon: Icons.h1,
2248
+ onSelect: (editor) => {
2249
+ toggleNodeType(editor, { activeType: ELEMENT_H1 });
2250
+ },
2251
+ value: "Heading 1"
2252
+ },
2253
+ {
2254
+ icon: Icons.h2,
2255
+ onSelect: (editor) => {
2256
+ toggleNodeType(editor, { activeType: ELEMENT_H2 });
2257
+ },
2258
+ value: "Heading 2"
2259
+ },
2260
+ {
2261
+ icon: Icons.h3,
2262
+ onSelect: (editor) => {
2263
+ toggleNodeType(editor, { activeType: ELEMENT_H3 });
2264
+ },
2265
+ value: "Heading 3"
2266
+ },
2267
+ {
2268
+ icon: Icons.ul,
2269
+ keywords: ["ul", "unordered list"],
2270
+ onSelect: (editor) => {
2271
+ toggleList(editor, { type: ELEMENT_UL });
2272
+ },
2273
+ value: "Bulleted list"
2274
+ },
2275
+ {
2276
+ icon: Icons.ol,
2277
+ keywords: ["ol", "ordered list"],
2278
+ onSelect: (editor) => {
2279
+ toggleList(editor, { type: ELEMENT_OL });
2280
+ },
2281
+ value: "Numbered list"
2282
+ }
2283
+ ];
2284
+ const SlashInputElement = withRef(
2200
2285
  ({ className, ...props }, ref) => {
2201
- const { element } = props;
2202
- const state = useCodeBlockElementState({ element });
2286
+ const { children, editor, element } = props;
2203
2287
  return /* @__PURE__ */ React__default.createElement(
2204
2288
  PlateElement,
2205
2289
  {
2206
- className: cn$1("relative py-1", state.className, className),
2290
+ as: "span",
2291
+ "data-slate-value": element.value,
2207
2292
  ref,
2208
2293
  ...props
2209
2294
  },
2210
- /* @__PURE__ */ React__default.createElement(CodeBlock, { ...props })
2211
- );
2295
+ /* @__PURE__ */ React__default.createElement(InlineCombobox, { element, trigger: "/" }, /* @__PURE__ */ React__default.createElement(InlineComboboxInput, null), /* @__PURE__ */ React__default.createElement(InlineComboboxContent, null, /* @__PURE__ */ React__default.createElement(InlineComboboxEmpty, null, "No matching commands found"), rules.map(({ icon: Icon, keywords, onSelect, value }) => /* @__PURE__ */ React__default.createElement(
2296
+ InlineComboboxItem,
2297
+ {
2298
+ key: value,
2299
+ keywords,
2300
+ onClick: () => onSelect(editor),
2301
+ value
2302
+ },
2303
+ /* @__PURE__ */ React__default.createElement(Icon, { "aria-hidden": true, className: "mr-2 size-4" }),
2304
+ value
2305
+ )))),
2306
+ children
2307
+ );
2308
+ }
2309
+ );
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";
2333
+ return /* @__PURE__ */ React__default.createElement(
2334
+ PlateElement,
2335
+ {
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
2361
+ }
2362
+ },
2363
+ /* @__PURE__ */ React__default.createElement(Cell, null, /* @__PURE__ */ React__default.createElement(
2364
+ "div",
2365
+ {
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",
2374
+ {
2375
+ className: "group absolute top-0 size-full select-none",
2376
+ contentEditable: false,
2377
+ suppressContentEditableWarning: true
2378
+ },
2379
+ !readOnly && /* @__PURE__ */ React__default.createElement(React__default.Fragment, null, /* @__PURE__ */ React__default.createElement(
2380
+ ResizeHandle$1,
2381
+ {
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]"
2403
+ )
2404
+ }
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
+ )
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"
2449
+ }
2450
+ }
2212
2451
  }
2213
2452
  );
2214
- const ELEMENT_MERMAID = "mermaid";
2215
- const createMermaidPlugin = createPluginFactory({
2216
- isElement: true,
2217
- isVoid: true,
2218
- isInline: false,
2219
- key: ELEMENT_MERMAID
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
+ );
2220
2463
  });
2221
- const useMermaidElement = () => {
2222
- const mermaidRef = useRef(null);
2223
- useEffect(() => {
2224
- if (mermaidRef.current) {
2225
- mermaid.initialize({ startOnLoad: true });
2226
- mermaid.run();
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"
2504
+ }
2227
2505
  }
2228
- }, []);
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"
2547
+ }
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
+ );
2229
2572
  return {
2230
- mermaidRef
2573
+ onOpenChange,
2574
+ open: open2
2231
2575
  };
2232
2576
  };
2233
- const LightModeComponent = ({ onToggleMode }) => {
2234
- const [isLightMode, setIsLightMode] = useState(true);
2235
- const handleToggle = (e) => {
2236
- e.preventDefault();
2237
- setIsLightMode((prevMode) => !prevMode);
2238
- };
2239
- useEffect(() => {
2240
- const modeClass = isLightMode ? "not-tina-prose" : "";
2241
- if (onToggleMode) {
2242
- onToggleMode(modeClass);
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
2243
2591
  }
2244
- }, [isLightMode, onToggleMode]);
2245
- return /* @__PURE__ */ React__default.createElement("div", null, /* @__PURE__ */ React__default.createElement(
2246
- "button",
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
+ }
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();
2622
+ return /* @__PURE__ */ React__default.createElement(
2623
+ DropdownMenuContent,
2247
2624
  {
2248
- type: "button",
2249
- onClick: handleToggle,
2250
- className: "flex items-center w-5 h-5 cursor-pointer"
2625
+ align: "start",
2626
+ className: cn$1("min-w-[220px]"),
2627
+ ref,
2628
+ side: "right",
2629
+ sideOffset: 0,
2630
+ ...props
2251
2631
  },
2252
- isLightMode ? /* @__PURE__ */ React__default.createElement(Moon, { className: "fill-white" }) : /* @__PURE__ */ React__default.createElement(SunMoon, { className: "fill-white" })
2253
- ));
2254
- };
2255
- const MermaidElementWithRef = ({ config, lightMode }) => {
2256
- const { mermaidRef } = useMermaidElement();
2257
- 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: `${lightMode} mermaid` }, config)));
2258
- };
2259
- const Bubble = ({ children }) => {
2260
- 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);
2261
- };
2262
- const DEFAULT_MERMAID_CONFIG = `%% This won't render without implementing a rendering engine <TODO: Link to tina docs>
2263
- flowchart TD
2264
- id1(this is an example flow diagram)
2265
- --> id2(modify me to see changes!)
2266
- id2
2267
- --> id3(Click the top button to preview the changes)
2268
- --> id4(Learn about mermaid diagrams @ mermaid.js.org)`;
2269
- const MermaidElement = withRef(
2270
- ({ children, nodeProps, element, ...props }, ref) => {
2271
- const [mermaidConfig, setMermaidConfig] = React__default.useState(
2272
- element.value || DEFAULT_MERMAID_CONFIG
2273
- );
2274
- const [isEditing, setIsEditing] = React__default.useState(
2275
- mermaidConfig === DEFAULT_MERMAID_CONFIG || false
2276
- );
2277
- const [lightModeClass, setLightModeClass] = React__default.useState("");
2278
- const node = {
2279
- type: ELEMENT_MERMAID,
2280
- value: mermaidConfig,
2281
- children: [{ type: "text", text: "" }]
2282
- };
2283
- 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(
2284
- Eye,
2632
+ /* @__PURE__ */ React__default.createElement(
2633
+ DropdownMenuCheckboxItem,
2285
2634
  {
2286
- className: "w-5 h-5 fill-white cursor-pointer",
2287
- onClick: () => {
2288
- setIsEditing(!isEditing);
2289
- }
2290
- }
2291
- ) : /* @__PURE__ */ React__default.createElement(
2292
- SquarePen,
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,
2293
2643
  {
2294
- className: "w-5 h-5 fill-white cursor-pointer",
2295
- onClick: () => {
2296
- setIsEditing(!isEditing);
2297
- }
2298
- }
2299
- )), /* @__PURE__ */ React__default.createElement(Bubble, null, /* @__PURE__ */ React__default.createElement(LightModeComponent, { onToggleMode: (v) => setLightModeClass(v) }))), isEditing ? /* @__PURE__ */ React__default.createElement(
2300
- CodeBlock,
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,
2705
+ {
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,
2301
2716
  {
2302
- children: "",
2303
- language: "yaml",
2304
- ...props,
2305
- element: node,
2306
- defaultValue: mermaidConfig,
2307
- onChangeCallback: (value) => setMermaidConfig(value)
2308
- }
2309
- ) : /* @__PURE__ */ React__default.createElement(
2310
- MermaidElementWithRef,
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,
2311
2728
  {
2312
- config: mermaidConfig,
2313
- lightMode: lightModeClass
2314
- }
2315
- ), children));
2729
+ className: cn$1(
2730
+ popoverVariants(),
2731
+ "flex w-[220px] flex-col gap-1 p-1"
2732
+ ),
2733
+ onOpenAutoFocus: (e) => e.preventDefault(),
2734
+ ref,
2735
+ ...props
2736
+ },
2737
+ unmergeButton,
2738
+ mergeContent,
2739
+ bordersContent
2740
+ ));
2316
2741
  }
2317
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
+ });
2318
2786
  const blockClasses = "mt-0.5";
2319
2787
  const headerClasses = "font-normal";
2320
2788
  const Components = () => {
@@ -2501,7 +2969,11 @@ const Components = () => {
2501
2969
  children,
2502
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" })
2503
2971
  );
2504
- }
2972
+ },
2973
+ [ELEMENT_TABLE]: TableElement,
2974
+ [ELEMENT_TR]: TableRowElement,
2975
+ [ELEMENT_TD]: TableCellElement,
2976
+ [ELEMENT_TH]: TableCellHeaderElement
2505
2977
  };
2506
2978
  };
2507
2979
  const createCodeBlockPlugin = createPluginFactory({
@@ -3231,7 +3703,7 @@ const Button$1 = ({
3231
3703
  };
3232
3704
  const sizeClasses = {
3233
3705
  small: `text-xs h-8 px-3`,
3234
- medium: `text-sm h-10 px-4`,
3706
+ medium: `text-sm h-10 px-8`,
3235
3707
  custom: ``
3236
3708
  };
3237
3709
  return /* @__PURE__ */ React.createElement(
@@ -4573,7 +5045,7 @@ const ImageLoadingIndicator = () => /* @__PURE__ */ React.createElement("div", {
4573
5045
  function cn(...inputs) {
4574
5046
  return twMerge(clsx(inputs));
4575
5047
  }
4576
- const buttonVariants$1 = cva(
5048
+ const buttonVariants = cva(
4577
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",
4578
5050
  {
4579
5051
  variants: {
@@ -4599,7 +5071,7 @@ const Button = React.forwardRef(
4599
5071
  return /* @__PURE__ */ React.createElement(
4600
5072
  Comp,
4601
5073
  {
4602
- className: cn(buttonVariants$1({ variant, size, className })),
5074
+ className: cn(buttonVariants({ variant, size, className })),
4603
5075
  ref,
4604
5076
  ...props
4605
5077
  }
@@ -5298,7 +5770,7 @@ const BlockSelector = ({
5298
5770
  return template.label ? template.label.toLowerCase().includes(filter.toLowerCase()) || name.toLowerCase().includes(filter.toLowerCase()) : name.toLowerCase().includes(filter.toLowerCase());
5299
5771
  });
5300
5772
  }, [filter]);
5301
- 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(
5302
5774
  IconButton,
5303
5775
  {
5304
5776
  variant: open2 ? "secondary" : "primary",
@@ -9863,7 +10335,7 @@ const SyncStatus = ({ cms, setEventsOpen }) => {
9863
10335
  "Event Log"
9864
10336
  ));
9865
10337
  };
9866
- const version = "2.2.8";
10338
+ const version = "2.3.0";
9867
10339
  const Nav = ({
9868
10340
  isLocalMode,
9869
10341
  className = "",
@@ -12394,15 +12866,14 @@ const FormBuilder = ({
12394
12866
  fields: fieldGroup.fields
12395
12867
  }
12396
12868
  ) : /* @__PURE__ */ React.createElement(NoFieldsPlaceholder, null)
12397
- )), !hideFooter && /* @__PURE__ */ React.createElement("div", { className: "relative flex-none w-full h-16 px-6 bg-white border-t border-gray-100 flex items-center justify-center" }, /* @__PURE__ */ React.createElement("div", { className: "flex-1 w-full flex justify-between gap-4 items-center max-w-form" }, tinaForm.reset && /* @__PURE__ */ React.createElement(
12869
+ )), !hideFooter && /* @__PURE__ */ React.createElement("div", { className: "relative flex-none w-full h-16 px-12 bg-white border-t border-gray-100 flex items-center justify-end" }, /* @__PURE__ */ React.createElement("div", { className: "flex-1 w-full justify-end gap-2 flex items-center max-w-form" }, tinaForm.reset && /* @__PURE__ */ React.createElement(
12398
12870
  ResetForm,
12399
12871
  {
12400
12872
  pristine,
12401
12873
  reset: async () => {
12402
12874
  finalForm.reset();
12403
12875
  await tinaForm.reset();
12404
- },
12405
- style: { flexGrow: 1 }
12876
+ }
12406
12877
  },
12407
12878
  tinaForm.buttons.reset
12408
12879
  ), /* @__PURE__ */ React.createElement(
@@ -12411,8 +12882,7 @@ const FormBuilder = ({
12411
12882
  onClick: safeHandleSubmit,
12412
12883
  disabled: !canSubmit,
12413
12884
  busy: submitting,
12414
- variant: "primary",
12415
- style: { flexGrow: 3 }
12885
+ variant: "primary"
12416
12886
  },
12417
12887
  submitting && /* @__PURE__ */ React.createElement(LoadingDots, null),
12418
12888
  !submitting && tinaForm.buttons.save
@@ -12930,7 +13400,7 @@ const EmbedNestedForm = ({
12930
13400
  );
12931
13401
  };
12932
13402
  const DotMenu = ({ onOpen, onRemove }) => {
12933
- return /* @__PURE__ */ React__default.createElement(Popover$2, { as: "span", className: "-ml-px relative block" }, /* @__PURE__ */ React__default.createElement(
13403
+ return /* @__PURE__ */ React__default.createElement(Popover$3, { as: "span", className: "-ml-px relative block" }, /* @__PURE__ */ React__default.createElement(
12934
13404
  PopoverButton,
12935
13405
  {
12936
13406
  as: "span",
@@ -13370,13 +13840,26 @@ const plugins = [
13370
13840
  createUnderlinePlugin(),
13371
13841
  createCodePlugin(),
13372
13842
  createListPlugin(),
13373
- createIndentPlugin(),
13374
13843
  createIndentListPlugin(),
13375
13844
  createHorizontalRulePlugin(),
13376
13845
  // Allows us to do things like copy/paste, remembering the state of the element (like mdx)
13377
13846
  createNodeIdPlugin(),
13378
- createSlashPlugin()
13847
+ createSlashPlugin(),
13848
+ createTablePlugin()
13379
13849
  ];
13850
+ const unsupportedItemsInTable = /* @__PURE__ */ new Set([
13851
+ "Code Block",
13852
+ "Unordered List",
13853
+ "Ordered List",
13854
+ "Quote",
13855
+ "Mermaid",
13856
+ "Heading 1",
13857
+ "Heading 2",
13858
+ "Heading 3",
13859
+ "Heading 4",
13860
+ "Heading 5",
13861
+ "Heading 6"
13862
+ ]);
13380
13863
  const isNodeActive = (editor, type) => {
13381
13864
  const pluginType = getPluginType(editor, type);
13382
13865
  return !!(editor == null ? void 0 : editor.selection) && someNode(editor, { match: { type: pluginType } });
@@ -13561,24 +14044,6 @@ const Editor = React__default.forwardRef(
13561
14044
  }
13562
14045
  );
13563
14046
  Editor.displayName = "Editor";
13564
- const separatorVariants = cva("shrink-0 bg-border", {
13565
- defaultVariants: {
13566
- orientation: "horizontal"
13567
- },
13568
- variants: {
13569
- orientation: {
13570
- horizontal: "h-px w-full",
13571
- vertical: "h-full w-px"
13572
- }
13573
- }
13574
- });
13575
- const Separator = withVariants(
13576
- withProps(SeparatorPrimitive.Root, {
13577
- decorative: true,
13578
- orientation: "horizontal"
13579
- }),
13580
- separatorVariants
13581
- );
13582
14047
  const TooltipProvider = TooltipPrimitive.Provider;
13583
14048
  const Tooltip = TooltipPrimitive.Root;
13584
14049
  const TooltipTrigger = TooltipPrimitive.Trigger;
@@ -13713,140 +14178,41 @@ const FixedToolbar = withCn(
13713
14178
  Toolbar,
13714
14179
  "p-1 sticky left-0 top-0 z-50 w-full justify-between overflow-x-auto border border-border bg-background"
13715
14180
  );
13716
- const MarkToolbarButton = withRef(({ clear, nodeType, ...rest }, ref) => {
13717
- const state = useMarkToolbarButtonState({ clear, nodeType });
13718
- const { props } = useMarkToolbarButton(state);
13719
- return /* @__PURE__ */ React__default.createElement(ToolbarButton, { ref, ...props, ...rest });
13720
- });
13721
- const IndentListToolbarButton = withRef(({ nodeType = ELEMENT_UL }, ref) => {
13722
- const editor = useEditorState();
13723
- const state = useListToolbarButtonState({ nodeType });
13724
- const { props } = useListToolbarButton(state);
13725
- return /* @__PURE__ */ React__default.createElement(
13726
- ToolbarButton,
13727
- {
13728
- ref,
13729
- tooltip: nodeType === ELEMENT_UL ? "Bulleted List" : "Numbered List",
13730
- ...props,
13731
- onClick: (e) => {
13732
- e.preventDefault();
13733
- e.stopPropagation();
13734
- toggleList(editor, { type: nodeType });
13735
- }
13736
- },
13737
- nodeType === ELEMENT_UL ? /* @__PURE__ */ React__default.createElement(Icons.ul, null) : /* @__PURE__ */ React__default.createElement(Icons.ol, null)
13738
- );
13739
- });
13740
- const DropdownMenu = DropdownMenuPrimitive.Root;
13741
- const DropdownMenuTrigger = DropdownMenuPrimitive.Trigger;
13742
- const DropdownMenuRadioGroup = DropdownMenuPrimitive.RadioGroup;
13743
- withRef(({ children, className, inset, ...props }, ref) => /* @__PURE__ */ React__default.createElement(
13744
- DropdownMenuPrimitive.SubTrigger,
13745
- {
13746
- className: cn$1(
13747
- "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",
13748
- "data-[disabled]:pointer-events-none data-[disabled]:opacity-50",
13749
- inset && "pl-8",
13750
- className
13751
- ),
13752
- ref,
13753
- ...props
13754
- },
13755
- children,
13756
- /* @__PURE__ */ React__default.createElement(Icons.chevronRight, { className: "ml-auto size-4" })
13757
- ));
13758
- withCn(
13759
- DropdownMenuPrimitive.SubContent,
13760
- "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"
13761
- );
13762
- const DropdownMenuContentVariants = withProps(DropdownMenuPrimitive.Content, {
13763
- className: cn$1(
13764
- "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"
13765
- ),
13766
- sideOffset: 4
13767
- });
13768
- const DropdownMenuContent = withRef(({ ...props }, ref) => /* @__PURE__ */ React__default.createElement(DropdownMenuPrimitive.Portal, null, /* @__PURE__ */ React__default.createElement(DropdownMenuContentVariants, { ref, ...props })));
13769
- const menuItemVariants = cva(
13770
- cn$1(
13771
- "relative flex h-9 cursor-pointer select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none transition-colors",
13772
- "focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50"
13773
- ),
13774
- {
13775
- variants: {
13776
- inset: {
13777
- true: "pl-8"
14181
+ const useResize = (ref, callback) => {
14182
+ React__default.useEffect(() => {
14183
+ const resizeObserver = new ResizeObserver((entries) => {
14184
+ for (const entry of entries) {
14185
+ callback(entry);
13778
14186
  }
14187
+ });
14188
+ if (ref.current) {
14189
+ resizeObserver.observe(ref.current);
13779
14190
  }
13780
- }
13781
- );
13782
- const DropdownMenuItem = withVariants(
13783
- DropdownMenuPrimitive.Item,
13784
- menuItemVariants,
13785
- ["inset"]
13786
- );
13787
- withRef(({ children, className, ...props }, ref) => /* @__PURE__ */ React__default.createElement(
13788
- DropdownMenuPrimitive.CheckboxItem,
13789
- {
13790
- className: cn$1(
13791
- "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",
13792
- "cursor-pointer",
13793
- className
13794
- ),
13795
- ref,
13796
- ...props
13797
- },
13798
- /* @__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" }))),
13799
- children
13800
- ));
13801
- const DropdownMenuRadioItem = withRef(({ children, className, hideIcon, ...props }, ref) => /* @__PURE__ */ React__default.createElement(
13802
- DropdownMenuPrimitive.RadioItem,
13803
- {
13804
- className: cn$1(
13805
- "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",
13806
- "h-9 cursor-pointer px-2 data-[state=checked]:bg-accent data-[state=checked]:text-accent-foreground",
13807
- className
13808
- ),
13809
- ref,
13810
- ...props
13811
- },
13812
- !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" }))),
14191
+ return () => resizeObserver.disconnect();
14192
+ }, [ref.current]);
14193
+ };
14194
+ const STANDARD_ICON_WIDTH = 32;
14195
+ const HEADING_ICON_WITH_TEXT = 127;
14196
+ const HEADING_ICON_ONLY = 58;
14197
+ const EMBED_ICON_WIDTH = 78;
14198
+ const CONTAINER_MD_BREAKPOINT = 448;
14199
+ const FLOAT_BUTTON_WIDTH = 25;
14200
+ const HEADING_LABEL = "Headings";
14201
+ const ToolbarContext = createContext(void 0);
14202
+ const ToolbarProvider = ({
14203
+ tinaForm,
14204
+ templates,
14205
+ overrides,
13813
14206
  children
13814
- ));
13815
- const dropdownMenuLabelVariants = cva(
13816
- cn$1("select-none px-2 py-1.5 text-sm font-semibold"),
13817
- {
13818
- variants: {
13819
- inset: {
13820
- true: "pl-8"
13821
- }
13822
- }
14207
+ }) => {
14208
+ return /* @__PURE__ */ React__default.createElement(ToolbarContext.Provider, { value: { tinaForm, templates, overrides } }, children);
14209
+ };
14210
+ const useToolbarContext = () => {
14211
+ const context = useContext(ToolbarContext);
14212
+ if (!context) {
14213
+ throw new Error("useToolbarContext must be used within a ToolbarProvider");
13823
14214
  }
13824
- );
13825
- const DropdownMenuLabel = withVariants(
13826
- DropdownMenuPrimitive.Label,
13827
- dropdownMenuLabelVariants,
13828
- ["inset"]
13829
- );
13830
- const DropdownMenuSeparator = withCn(
13831
- DropdownMenuPrimitive.Separator,
13832
- "-mx-1 my-1 h-px bg-muted"
13833
- );
13834
- withCn(
13835
- createPrimitiveElement("span"),
13836
- "ml-auto text-xs tracking-widest opacity-60"
13837
- );
13838
- const useOpenState = () => {
13839
- const [open2, setOpen] = useState(false);
13840
- const onOpenChange = useCallback(
13841
- (_value = !open2) => {
13842
- setOpen(_value);
13843
- },
13844
- [open2]
13845
- );
13846
- return {
13847
- onOpenChange,
13848
- open: open2
13849
- };
14215
+ return context;
13850
14216
  };
13851
14217
  const items$1 = [
13852
14218
  {
@@ -13912,7 +14278,9 @@ function HeadingsMenu(props) {
13912
14278
  return allNodesMatchInitialNodeType ? initialNodeType : ELEMENT_PARAGRAPH$1;
13913
14279
  }, []);
13914
14280
  const editor = useEditorRef();
14281
+ const editorState = useEditorState();
13915
14282
  const openState = useOpenState();
14283
+ const userInTable = helpers.isNodeActive(editorState, ELEMENT_TABLE$1);
13916
14284
  const selectedItem = items$1.find((item) => item.value === value) ?? defaultItem$1;
13917
14285
  const { icon: SelectedItemIcon, label: selectedItemLabel } = selectedItem;
13918
14286
  return /* @__PURE__ */ React__default.createElement(DropdownMenu, { modal: false, ...openState, ...props }, /* @__PURE__ */ React__default.createElement(DropdownMenuTrigger, { asChild: true }, /* @__PURE__ */ React__default.createElement(
@@ -13924,7 +14292,7 @@ function HeadingsMenu(props) {
13924
14292
  tooltip: "Headings"
13925
14293
  },
13926
14294
  /* @__PURE__ */ React__default.createElement(SelectedItemIcon, { className: "size-5" }),
13927
- /* @__PURE__ */ React__default.createElement("span", { className: "hidden 2xl:flex" }, selectedItemLabel)
14295
+ /* @__PURE__ */ React__default.createElement("span", { className: "@md/toolbar:flex hidden" }, selectedItemLabel)
13928
14296
  )), /* @__PURE__ */ React__default.createElement(DropdownMenuContent, { align: "start", className: "min-w-0" }, /* @__PURE__ */ React__default.createElement(
13929
14297
  DropdownMenuRadioGroup,
13930
14298
  {
@@ -13936,7 +14304,12 @@ function HeadingsMenu(props) {
13936
14304
  },
13937
14305
  value
13938
14306
  },
13939
- items$1.map(({ icon: Icon, label, value: itemValue }) => /* @__PURE__ */ React__default.createElement(
14307
+ items$1.filter((item) => {
14308
+ if (userInTable) {
14309
+ return !unsupportedItemsInTable.has(item.label);
14310
+ }
14311
+ return true;
14312
+ }).map(({ icon: Icon, label, value: itemValue }) => /* @__PURE__ */ React__default.createElement(
13940
14313
  DropdownMenuRadioItem,
13941
14314
  {
13942
14315
  className: "min-w-[180px]",
@@ -13948,24 +14321,17 @@ function HeadingsMenu(props) {
13948
14321
  ))
13949
14322
  )));
13950
14323
  }
13951
- const LinkToolbarButton = withRef((rest, ref) => {
13952
- const state = useLinkToolbarButtonState();
13953
- const { props } = useLinkToolbarButton(state);
13954
- return /* @__PURE__ */ React__default.createElement(ToolbarButton, { ref, tooltip: "Link", ...props, ...rest }, /* @__PURE__ */ React__default.createElement(Icons.link, null));
13955
- });
13956
- const useBlockQuoteToolbarButtonState = () => {
14324
+ const useCodeBlockToolbarButtonState = () => {
13957
14325
  const editor = useEditorState();
13958
- const isBlockActive = () => helpers.isNodeActive(editor, ELEMENT_BLOCKQUOTE$1);
14326
+ const isBlockActive = () => helpers.isNodeActive(editor, ELEMENT_CODE_BLOCK$1);
13959
14327
  return {
13960
14328
  pressed: isBlockActive()
13961
14329
  };
13962
14330
  };
13963
- const useBlockQuoteToolbarButton = (state) => {
14331
+ const useCodeBlockToolbarButton = (state) => {
13964
14332
  const editor = useEditorState();
13965
14333
  const onClick = () => {
13966
- toggleNodeType(editor, {
13967
- activeType: ELEMENT_BLOCKQUOTE$1
13968
- });
14334
+ insertEmptyCodeBlock(editor);
13969
14335
  };
13970
14336
  const onMouseDown = (e) => {
13971
14337
  e.preventDefault();
@@ -13979,39 +14345,71 @@ const useBlockQuoteToolbarButton = (state) => {
13979
14345
  }
13980
14346
  };
13981
14347
  };
13982
- const QuoteToolbarButton = withRef(({ clear, ...rest }, ref) => {
13983
- const state = useBlockQuoteToolbarButtonState();
13984
- const { props } = useBlockQuoteToolbarButton(state);
13985
- return /* @__PURE__ */ React__default.createElement(ToolbarButton, { ref, tooltip: "Link", ...rest, ...props }, /* @__PURE__ */ React__default.createElement(Icons.quote, null));
14348
+ const CodeBlockToolbarButton = withRef(({ clear, ...rest }, ref) => {
14349
+ const state = useCodeBlockToolbarButtonState();
14350
+ const { props } = useCodeBlockToolbarButton(state);
14351
+ return /* @__PURE__ */ React__default.createElement(ToolbarButton, { ref, tooltip: "Link", ...rest, ...props }, /* @__PURE__ */ React__default.createElement(Icons.codeBlock, null));
13986
14352
  });
13987
- const useCodeBlockToolbarButtonState = () => {
14353
+ const useImageToolbarButtonState = () => {
13988
14354
  const editor = useEditorState();
13989
- const isBlockActive = () => helpers.isNodeActive(editor, ELEMENT_CODE_BLOCK$1);
14355
+ const isBlockActive = () => helpers.isNodeActive(editor, ELEMENT_IMG);
13990
14356
  return {
13991
14357
  pressed: isBlockActive()
13992
14358
  };
13993
14359
  };
13994
- const useCodeBlockToolbarButton = (state) => {
13995
- const editor = useEditorState();
13996
- const onClick = () => {
13997
- insertEmptyCodeBlock(editor);
13998
- };
14360
+ const useImageToolbarButton = (state) => {
14361
+ const editor = useEditorState();
14362
+ const cms = useCMS$1();
13999
14363
  const onMouseDown = (e) => {
14000
14364
  e.preventDefault();
14001
- e.stopPropagation();
14365
+ cms.media.open({
14366
+ allowDelete: true,
14367
+ directory: "",
14368
+ onSelect: (media) => {
14369
+ insertImg(editor, media);
14370
+ }
14371
+ });
14002
14372
  };
14003
14373
  return {
14004
14374
  props: {
14005
- onClick,
14006
14375
  onMouseDown,
14007
14376
  pressed: state.pressed
14008
14377
  }
14009
14378
  };
14010
14379
  };
14011
- const CodeBlockToolbarButton = withRef(({ clear, ...rest }, ref) => {
14012
- const state = useCodeBlockToolbarButtonState();
14013
- const { props } = useCodeBlockToolbarButton(state);
14014
- return /* @__PURE__ */ React__default.createElement(ToolbarButton, { ref, tooltip: "Link", ...rest, ...props }, /* @__PURE__ */ React__default.createElement(Icons.codeBlock, null));
14380
+ const ImageToolbarButton = withRef(({ clear, ...rest }, ref) => {
14381
+ const state = useImageToolbarButtonState();
14382
+ const { props } = useImageToolbarButton(state);
14383
+ return /* @__PURE__ */ React__default.createElement(ToolbarButton, { ref, tooltip: "Link", ...rest, ...props }, /* @__PURE__ */ React__default.createElement(Icons.image, null));
14384
+ });
14385
+ const IndentListToolbarButton = withRef(({ nodeType = ELEMENT_UL }, ref) => {
14386
+ const editor = useEditorState();
14387
+ const state = useListToolbarButtonState({ nodeType });
14388
+ const { props } = useListToolbarButton(state);
14389
+ return /* @__PURE__ */ React__default.createElement(
14390
+ ToolbarButton,
14391
+ {
14392
+ ref,
14393
+ tooltip: nodeType === ELEMENT_UL ? "Bulleted List" : "Numbered List",
14394
+ ...props,
14395
+ onClick: (e) => {
14396
+ e.preventDefault();
14397
+ e.stopPropagation();
14398
+ toggleList(editor, { type: nodeType });
14399
+ }
14400
+ },
14401
+ nodeType === ELEMENT_UL ? /* @__PURE__ */ React__default.createElement(Icons.ul, null) : /* @__PURE__ */ React__default.createElement(Icons.ol, null)
14402
+ );
14403
+ });
14404
+ const LinkToolbarButton = withRef((rest, ref) => {
14405
+ const state = useLinkToolbarButtonState();
14406
+ const { props } = useLinkToolbarButton(state);
14407
+ return /* @__PURE__ */ React__default.createElement(ToolbarButton, { ref, tooltip: "Link", ...props, ...rest }, /* @__PURE__ */ React__default.createElement(Icons.link, null));
14408
+ });
14409
+ const MarkToolbarButton = withRef(({ clear, nodeType, ...rest }, ref) => {
14410
+ const state = useMarkToolbarButtonState({ clear, nodeType });
14411
+ const { props } = useMarkToolbarButton(state);
14412
+ return /* @__PURE__ */ React__default.createElement(ToolbarButton, { ref, ...props, ...rest });
14015
14413
  });
14016
14414
  const useMermaidToolbarButtonState = () => {
14017
14415
  const editor = useEditorState();
@@ -14045,37 +14443,54 @@ const MermaidToolbarButton = withRef(({ clear, ...rest }, ref) => {
14045
14443
  const { props } = useMermaidToolbarButton(state);
14046
14444
  return /* @__PURE__ */ React__default.createElement(ToolbarButton, { ref, tooltip: "Mermaid", ...rest, ...props }, /* @__PURE__ */ React__default.createElement(Icons.mermaid, null));
14047
14445
  });
14048
- const useImageToolbarButtonState = () => {
14446
+ function OverflowMenu({
14447
+ children,
14448
+ ...props
14449
+ }) {
14450
+ const openState = useOpenState();
14451
+ return /* @__PURE__ */ React__default.createElement(DropdownMenu, { modal: false, ...openState, ...props }, /* @__PURE__ */ React__default.createElement(DropdownMenuTrigger, { asChild: true }, /* @__PURE__ */ React__default.createElement(
14452
+ ToolbarButton,
14453
+ {
14454
+ showArrow: false,
14455
+ "data-testid": "rich-text-editor-overflow-menu-button",
14456
+ className: "lg:min-w-[130px]",
14457
+ isDropdown: true,
14458
+ pressed: openState.open,
14459
+ tooltip: "Headings"
14460
+ },
14461
+ /* @__PURE__ */ React__default.createElement(Icons.overflow, { className: "size-5" })
14462
+ )), /* @__PURE__ */ React__default.createElement(DropdownMenuContent, { align: "start", className: "min-w-0 flex flex-grow" }, children));
14463
+ }
14464
+ const useBlockQuoteToolbarButtonState = () => {
14049
14465
  const editor = useEditorState();
14050
- const isBlockActive = () => helpers.isNodeActive(editor, ELEMENT_IMG);
14466
+ const isBlockActive = () => helpers.isNodeActive(editor, ELEMENT_BLOCKQUOTE$1);
14051
14467
  return {
14052
14468
  pressed: isBlockActive()
14053
14469
  };
14054
14470
  };
14055
- const useImageToolbarButton = (state) => {
14471
+ const useBlockQuoteToolbarButton = (state) => {
14056
14472
  const editor = useEditorState();
14057
- const cms = useCMS$1();
14473
+ const onClick = () => {
14474
+ toggleNodeType(editor, {
14475
+ activeType: ELEMENT_BLOCKQUOTE$1
14476
+ });
14477
+ };
14058
14478
  const onMouseDown = (e) => {
14059
14479
  e.preventDefault();
14060
- cms.media.open({
14061
- allowDelete: true,
14062
- directory: "",
14063
- onSelect: (media) => {
14064
- insertImg(editor, media);
14065
- }
14066
- });
14480
+ e.stopPropagation();
14067
14481
  };
14068
14482
  return {
14069
14483
  props: {
14484
+ onClick,
14070
14485
  onMouseDown,
14071
14486
  pressed: state.pressed
14072
14487
  }
14073
14488
  };
14074
14489
  };
14075
- const ImageToolbarButton = withRef(({ clear, ...rest }, ref) => {
14076
- const state = useImageToolbarButtonState();
14077
- const { props } = useImageToolbarButton(state);
14078
- return /* @__PURE__ */ React__default.createElement(ToolbarButton, { ref, tooltip: "Link", ...rest, ...props }, /* @__PURE__ */ React__default.createElement(Icons.image, null));
14490
+ const QuoteToolbarButton = withRef(({ clear, ...rest }, ref) => {
14491
+ const state = useBlockQuoteToolbarButtonState();
14492
+ const { props } = useBlockQuoteToolbarButton(state);
14493
+ return /* @__PURE__ */ React__default.createElement(ToolbarButton, { ref, tooltip: "Link", ...rest, ...props }, /* @__PURE__ */ React__default.createElement(Icons.quote, null));
14079
14494
  });
14080
14495
  const useRawMarkdownToolbarButton = () => {
14081
14496
  const { setRawMode } = useEditorContext();
@@ -14091,31 +14506,123 @@ const useRawMarkdownToolbarButton = () => {
14091
14506
  };
14092
14507
  const RawMarkdownToolbarButton = withRef(({ clear, ...rest }, ref) => {
14093
14508
  const { props } = useRawMarkdownToolbarButton();
14094
- return /* @__PURE__ */ React__default.createElement(ToolbarButton, { ref, tooltip: "Link", ...rest, ...props }, /* @__PURE__ */ React__default.createElement(Icons.raw, null));
14509
+ return /* @__PURE__ */ React__default.createElement(
14510
+ ToolbarButton,
14511
+ {
14512
+ ref,
14513
+ tooltip: "Link",
14514
+ ...rest,
14515
+ ...props,
14516
+ "data-testid": "markdown-button"
14517
+ },
14518
+ /* @__PURE__ */ React__default.createElement(Icons.raw, null)
14519
+ );
14095
14520
  });
14096
- const ToolbarContext = createContext(void 0);
14097
- const ToolbarProvider = ({
14098
- tinaForm,
14099
- templates,
14100
- overrides,
14101
- children
14102
- }) => {
14103
- return /* @__PURE__ */ React__default.createElement(ToolbarContext.Provider, { value: { tinaForm, templates, overrides } }, children);
14104
- };
14105
- const useToolbarContext = () => {
14106
- const context = useContext(ToolbarContext);
14107
- if (!context) {
14108
- throw new Error("useToolbarContext must be used within a ToolbarProvider");
14109
- }
14110
- return context;
14111
- };
14521
+ function TableDropdownMenu(props) {
14522
+ const tableSelected = useEditorSelector(
14523
+ (editor2) => someNode(editor2, { match: { type: ELEMENT_TABLE$1 } }),
14524
+ []
14525
+ );
14526
+ const [enableDeleteColumn, enableDeleteRow] = useEditorSelector((editor2) => {
14527
+ const tableNodeEntry = findNode(editor2, { match: { type: ELEMENT_TABLE$1 } });
14528
+ if (!tableNodeEntry)
14529
+ return [false, false];
14530
+ const [tableNode] = tableNodeEntry;
14531
+ if (!isElement(tableNode))
14532
+ return [false, false];
14533
+ const columnCount = getTableColumnCount(tableNode);
14534
+ const rowCount = tableNode.children.length;
14535
+ return [columnCount > 1, rowCount > 1];
14536
+ }, []);
14537
+ const editor = useEditorRef();
14538
+ const openState = useOpenState();
14539
+ 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(
14540
+ DropdownMenuContent,
14541
+ {
14542
+ align: "start",
14543
+ className: "flex w-[180px] min-w-0 flex-col gap-0.5"
14544
+ },
14545
+ /* @__PURE__ */ React__default.createElement(
14546
+ DropdownMenuItem,
14547
+ {
14548
+ className: "min-w-[180px]",
14549
+ disabled: tableSelected,
14550
+ onSelect: () => {
14551
+ insertTable(editor);
14552
+ focusEditor(editor);
14553
+ }
14554
+ },
14555
+ /* @__PURE__ */ React__default.createElement(Icons.add, { className: iconVariants({ variant: "menuItem" }) }),
14556
+ "Insert table"
14557
+ ),
14558
+ /* @__PURE__ */ React__default.createElement(
14559
+ DropdownMenuItem,
14560
+ {
14561
+ className: "min-w-[180px]",
14562
+ disabled: !tableSelected,
14563
+ onSelect: () => {
14564
+ deleteTable(editor);
14565
+ focusEditor(editor);
14566
+ }
14567
+ },
14568
+ /* @__PURE__ */ React__default.createElement(Icons.minus, { className: iconVariants({ variant: "menuItem" }) }),
14569
+ "Delete table"
14570
+ ),
14571
+ /* @__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(
14572
+ DropdownMenuItem,
14573
+ {
14574
+ className: "min-w-[180px]",
14575
+ disabled: !tableSelected,
14576
+ onSelect: () => {
14577
+ insertTableColumn(editor);
14578
+ focusEditor(editor);
14579
+ }
14580
+ },
14581
+ /* @__PURE__ */ React__default.createElement(Icons.add, { className: iconVariants({ variant: "menuItem" }) }),
14582
+ "Insert column after"
14583
+ ), /* @__PURE__ */ React__default.createElement(
14584
+ DropdownMenuItem,
14585
+ {
14586
+ className: "min-w-[180px]",
14587
+ disabled: !enableDeleteColumn,
14588
+ onSelect: () => {
14589
+ deleteColumn(editor);
14590
+ focusEditor(editor);
14591
+ }
14592
+ },
14593
+ /* @__PURE__ */ React__default.createElement(Icons.minus, { className: iconVariants({ variant: "menuItem" }) }),
14594
+ "Delete column"
14595
+ ))),
14596
+ /* @__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(
14597
+ DropdownMenuItem,
14598
+ {
14599
+ className: "min-w-[180px]",
14600
+ disabled: !tableSelected,
14601
+ onSelect: () => {
14602
+ insertTableRow(editor);
14603
+ focusEditor(editor);
14604
+ }
14605
+ },
14606
+ /* @__PURE__ */ React__default.createElement(Icons.add, { className: iconVariants({ variant: "menuItem" }) }),
14607
+ "Insert row after"
14608
+ ), /* @__PURE__ */ React__default.createElement(
14609
+ DropdownMenuItem,
14610
+ {
14611
+ className: "min-w-[180px]",
14612
+ disabled: !enableDeleteRow,
14613
+ onSelect: () => {
14614
+ deleteRow(editor);
14615
+ focusEditor(editor);
14616
+ }
14617
+ },
14618
+ /* @__PURE__ */ React__default.createElement(Icons.minus, { className: iconVariants({ variant: "menuItem" }) }),
14619
+ "Delete row"
14620
+ )))
14621
+ ));
14622
+ }
14112
14623
  function TemplatesToolbarButton() {
14113
14624
  const { templates } = useToolbarContext();
14114
- const showEmbed = templates.length > 0;
14115
14625
  const editor = useEditorState();
14116
- if (!showEmbed) {
14117
- return null;
14118
- }
14119
14626
  return /* @__PURE__ */ React__default.createElement(EmbedButton, { templates, editor });
14120
14627
  }
14121
14628
  const EmbedButton = ({ editor, templates }) => {
@@ -14156,103 +14663,113 @@ const EmbedButton = ({ editor, templates }) => {
14156
14663
  template.label || template.name
14157
14664
  ))));
14158
14665
  };
14159
- const ICON_WIDTH = 32;
14160
- const EMBED_ICON_WIDTH = 78;
14161
- const useResize = (ref, callback) => {
14162
- React__default.useEffect(() => {
14163
- const resizeObserver = new ResizeObserver((entries) => {
14164
- for (const entry of entries) {
14165
- callback(entry);
14166
- }
14167
- });
14168
- if (ref.current) {
14169
- resizeObserver.observe(ref.current);
14170
- }
14171
- return () => resizeObserver.disconnect();
14172
- }, [ref.current]);
14173
- };
14174
- function OverflowMenu({
14175
- children,
14176
- ...props
14177
- }) {
14178
- const openState = useOpenState();
14179
- return /* @__PURE__ */ React__default.createElement(DropdownMenu, { modal: false, ...openState, ...props }, /* @__PURE__ */ React__default.createElement(DropdownMenuTrigger, { asChild: true }, /* @__PURE__ */ React__default.createElement(
14180
- ToolbarButton,
14181
- {
14182
- showArrow: false,
14183
- className: "lg:min-w-[130px]",
14184
- isDropdown: true,
14185
- pressed: openState.open,
14186
- tooltip: "Headings"
14187
- },
14188
- /* @__PURE__ */ React__default.createElement(Icons.overflow, { className: "size-5" })
14189
- )), /* @__PURE__ */ React__default.createElement(DropdownMenuContent, { align: "start", className: "min-w-0 flex flex-grow" }, children));
14190
- }
14191
14666
  const toolbarItems = {
14192
14667
  heading: {
14193
- label: "Headings",
14668
+ label: HEADING_LABEL,
14669
+ width: (paragraphIconExists) => paragraphIconExists ? HEADING_ICON_WITH_TEXT : HEADING_ICON_ONLY,
14670
+ // Dynamically handle width based on paragraph icon
14194
14671
  Component: /* @__PURE__ */ React__default.createElement(ToolbarGroup, { noSeparator: true }, /* @__PURE__ */ React__default.createElement(HeadingsMenu, null))
14195
14672
  },
14196
14673
  link: {
14197
14674
  label: "Link",
14675
+ width: () => STANDARD_ICON_WIDTH,
14198
14676
  Component: /* @__PURE__ */ React__default.createElement(LinkToolbarButton, null)
14199
14677
  },
14200
14678
  image: {
14201
14679
  label: "Image",
14680
+ width: () => STANDARD_ICON_WIDTH,
14202
14681
  Component: /* @__PURE__ */ React__default.createElement(ImageToolbarButton, null)
14203
14682
  },
14204
14683
  quote: {
14205
14684
  label: "Quote",
14685
+ width: () => STANDARD_ICON_WIDTH,
14206
14686
  Component: /* @__PURE__ */ React__default.createElement(QuoteToolbarButton, { tooltip: "Quote Quote (⌘+⇧+.)" })
14207
14687
  },
14208
14688
  ul: {
14209
14689
  label: "Unordered List",
14690
+ width: () => STANDARD_ICON_WIDTH,
14210
14691
  Component: /* @__PURE__ */ React__default.createElement(IndentListToolbarButton, { nodeType: ELEMENT_UL })
14211
14692
  },
14212
14693
  ol: {
14213
14694
  label: "Ordered List",
14695
+ width: () => STANDARD_ICON_WIDTH,
14214
14696
  Component: /* @__PURE__ */ React__default.createElement(IndentListToolbarButton, { nodeType: ELEMENT_OL })
14215
14697
  },
14216
14698
  bold: {
14217
14699
  label: "Bold",
14700
+ width: () => STANDARD_ICON_WIDTH,
14218
14701
  Component: /* @__PURE__ */ React__default.createElement(MarkToolbarButton, { tooltip: "Bold (⌘+B)", nodeType: MARK_BOLD }, /* @__PURE__ */ React__default.createElement(Icons.bold, null))
14219
14702
  },
14220
14703
  italic: {
14221
14704
  label: "Italic",
14705
+ width: () => STANDARD_ICON_WIDTH,
14222
14706
  Component: /* @__PURE__ */ React__default.createElement(MarkToolbarButton, { tooltip: "Italic (⌘+I)", nodeType: MARK_ITALIC }, /* @__PURE__ */ React__default.createElement(Icons.italic, null))
14223
14707
  },
14224
14708
  code: {
14225
14709
  label: "Code",
14710
+ width: () => STANDARD_ICON_WIDTH,
14226
14711
  Component: /* @__PURE__ */ React__default.createElement(MarkToolbarButton, { tooltip: "Code (⌘+E)", nodeType: MARK_CODE }, /* @__PURE__ */ React__default.createElement(Icons.code, null))
14227
14712
  },
14228
14713
  codeBlock: {
14229
14714
  label: "Code Block",
14715
+ width: () => STANDARD_ICON_WIDTH,
14230
14716
  Component: /* @__PURE__ */ React__default.createElement(CodeBlockToolbarButton, null)
14231
14717
  },
14232
14718
  mermaid: {
14233
14719
  label: "Mermaid",
14720
+ width: () => STANDARD_ICON_WIDTH,
14234
14721
  Component: /* @__PURE__ */ React__default.createElement(MermaidToolbarButton, null)
14235
14722
  },
14723
+ table: {
14724
+ label: "Table",
14725
+ width: () => STANDARD_ICON_WIDTH,
14726
+ Component: /* @__PURE__ */ React__default.createElement(TableDropdownMenu, null)
14727
+ },
14236
14728
  raw: {
14237
14729
  label: "Raw Markdown",
14730
+ width: () => STANDARD_ICON_WIDTH,
14238
14731
  Component: /* @__PURE__ */ React__default.createElement(RawMarkdownToolbarButton, null)
14239
14732
  },
14240
14733
  embed: {
14241
14734
  label: "Templates",
14735
+ width: () => EMBED_ICON_WIDTH,
14242
14736
  Component: /* @__PURE__ */ React__default.createElement(TemplatesToolbarButton, null)
14243
14737
  }
14244
14738
  };
14245
14739
  function FixedToolbarButtons() {
14246
14740
  const toolbarRef = React__default.useRef(null);
14247
14741
  const [itemsShown, setItemsShown] = React__default.useState(11);
14248
- const { overrides } = useToolbarContext();
14742
+ const { overrides, templates } = useToolbarContext();
14743
+ const showEmbedButton = templates.length > 0;
14744
+ let items2 = overrides === void 0 ? Object.values(toolbarItems) : overrides.map((item) => toolbarItems[item]).filter((item) => item !== void 0);
14745
+ if (!showEmbedButton) {
14746
+ items2 = items2.filter((item) => item.label !== toolbarItems.embed.label);
14747
+ }
14748
+ const editorState = useEditorState();
14749
+ const userInTable = helpers.isNodeActive(editorState, ELEMENT_TABLE);
14750
+ if (userInTable) {
14751
+ items2 = items2.filter((item) => !unsupportedItemsInTable.has(item.label));
14752
+ }
14249
14753
  useResize(toolbarRef, (entry) => {
14250
14754
  const width = entry.target.getBoundingClientRect().width;
14251
- const itemsShown2 = (width - EMBED_ICON_WIDTH) / ICON_WIDTH;
14252
- setItemsShown(Math.floor(itemsShown2));
14755
+ const headingButton = items2.find((item) => item.label === HEADING_LABEL);
14756
+ const headingWidth = headingButton ? headingButton.width(width > CONTAINER_MD_BREAKPOINT) : 0;
14757
+ const availableWidth = width - headingWidth - FLOAT_BUTTON_WIDTH;
14758
+ const { itemFitCount } = items2.reduce(
14759
+ (acc, item) => {
14760
+ if (item.label !== HEADING_LABEL && acc.totalItemsWidth + item.width() <= availableWidth) {
14761
+ return {
14762
+ totalItemsWidth: acc.totalItemsWidth + item.width(),
14763
+ itemFitCount: acc.itemFitCount + 1
14764
+ };
14765
+ }
14766
+ return acc;
14767
+ },
14768
+ { totalItemsWidth: 0, itemFitCount: 1 }
14769
+ );
14770
+ setItemsShown(itemFitCount);
14253
14771
  });
14254
- const toolbarItemsArray = overrides === void 0 ? Object.values(toolbarItems) : overrides.map((item) => toolbarItems[item]).filter((item) => item !== void 0);
14255
- return /* @__PURE__ */ React__default.createElement("div", { className: "w-full overflow-hidden", ref: toolbarRef }, /* @__PURE__ */ React__default.createElement(
14772
+ return /* @__PURE__ */ React__default.createElement("div", { className: "w-full overflow-hidden @container/toolbar", ref: toolbarRef }, /* @__PURE__ */ React__default.createElement(
14256
14773
  "div",
14257
14774
  {
14258
14775
  className: "flex",
@@ -14260,7 +14777,7 @@ function FixedToolbarButtons() {
14260
14777
  transform: "translateX(calc(-1px))"
14261
14778
  }
14262
14779
  },
14263
- /* @__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))))
14780
+ /* @__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))))
14264
14781
  ));
14265
14782
  }
14266
14783
  const FloatingToolbar = withRef(({ children, state, ...props }, componentRef) => {
@@ -14375,6 +14892,10 @@ function TurnIntoDropdownMenu(props) {
14375
14892
  const openState = useOpenState();
14376
14893
  const selectedItem = items.find((item) => item.value === value) ?? defaultItem;
14377
14894
  const { icon: SelectedItemIcon, label: selectedItemLabel } = selectedItem;
14895
+ const editorState = useEditorState();
14896
+ const userInTable = helpers.isNodeActive(editorState, ELEMENT_TABLE$1);
14897
+ if (userInTable)
14898
+ return null;
14378
14899
  return /* @__PURE__ */ React__default.createElement(DropdownMenu, { modal: false, ...openState, ...props }, /* @__PURE__ */ React__default.createElement(DropdownMenuTrigger, { asChild: true }, /* @__PURE__ */ React__default.createElement(
14379
14900
  ToolbarButton,
14380
14901
  {
@@ -14416,49 +14937,6 @@ function TurnIntoDropdownMenu(props) {
14416
14937
  function FloatingToolbarButtons() {
14417
14938
  return /* @__PURE__ */ React__default.createElement(React__default.Fragment, null, /* @__PURE__ */ React__default.createElement(TurnIntoDropdownMenu, null));
14418
14939
  }
14419
- const buttonVariants = cva(
14420
- "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",
14421
- {
14422
- defaultVariants: {
14423
- size: "default",
14424
- variant: "default"
14425
- },
14426
- variants: {
14427
- isMenu: {
14428
- true: "h-auto w-full cursor-pointer justify-start"
14429
- },
14430
- size: {
14431
- default: "h-10 px-4 py-2",
14432
- icon: "size-10",
14433
- lg: "h-11 rounded-md px-8",
14434
- none: "",
14435
- sm: "h-9 rounded-md px-3",
14436
- sms: "size-9 rounded-md px-0",
14437
- xs: "h-8 rounded-md px-3"
14438
- },
14439
- variant: {
14440
- default: "bg-primary text-primary-foreground hover:bg-primary/90",
14441
- destructive: "bg-destructive text-destructive-foreground hover:bg-destructive/90",
14442
- ghost: "hover:bg-accent hover:text-accent-foreground",
14443
- inlineLink: "text-base text-primary underline underline-offset-4",
14444
- link: "text-primary underline-offset-4 hover:underline",
14445
- outline: "border border-input bg-background hover:bg-accent hover:text-accent-foreground",
14446
- secondary: "bg-secondary text-secondary-foreground hover:bg-secondary/80"
14447
- }
14448
- }
14449
- }
14450
- );
14451
- withRef(({ asChild = false, className, isMenu, size, variant, ...props }, ref) => {
14452
- const Comp = asChild ? Slot : "button";
14453
- return /* @__PURE__ */ React.createElement(
14454
- Comp,
14455
- {
14456
- className: cn$1(buttonVariants({ className, isMenu, size, variant })),
14457
- ref,
14458
- ...props
14459
- }
14460
- );
14461
- });
14462
14940
  const inputVariants = cva(
14463
14941
  "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",
14464
14942
  {
@@ -14479,22 +14957,6 @@ const inputVariants = cva(
14479
14957
  }
14480
14958
  );
14481
14959
  withVariants("input", inputVariants, ["variant", "h"]);
14482
- const popoverVariants = cva(
14483
- "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"
14484
- );
14485
- withRef(
14486
- ({ align = "center", className, sideOffset = 4, style, ...props }, ref) => /* @__PURE__ */ React.createElement(PopoverPrimitive.Portal, null, /* @__PURE__ */ React.createElement(
14487
- PopoverPrimitive.Content,
14488
- {
14489
- align,
14490
- className: cn$1(popoverVariants(), className),
14491
- ref,
14492
- sideOffset,
14493
- style: { zIndex: 1e3, ...style },
14494
- ...props
14495
- }
14496
- ))
14497
- );
14498
14960
  const floatingOptions = {
14499
14961
  middleware: [
14500
14962
  offset(12),
@@ -14554,7 +15016,7 @@ function LinkFloatingToolbar({ state }) {
14554
15016
  const editContent = editState.isEditing ? input : /* @__PURE__ */ React__default.createElement("div", { className: "box-content flex h-9 items-center gap-1" }, /* @__PURE__ */ React__default.createElement(
14555
15017
  "button",
14556
15018
  {
14557
- className: buttonVariants({ size: "sm", variant: "ghost" }),
15019
+ className: buttonVariants$1({ size: "sm", variant: "ghost" }),
14558
15020
  type: "button",
14559
15021
  ...editButtonProps
14560
15022
  },
@@ -14562,7 +15024,7 @@ function LinkFloatingToolbar({ state }) {
14562
15024
  ), /* @__PURE__ */ React__default.createElement(Separator, { orientation: "vertical" }), /* @__PURE__ */ React__default.createElement(
14563
15025
  LinkOpenButton,
14564
15026
  {
14565
- className: buttonVariants({
15027
+ className: buttonVariants$1({
14566
15028
  size: "sms",
14567
15029
  variant: "ghost"
14568
15030
  })
@@ -14571,7 +15033,7 @@ function LinkFloatingToolbar({ state }) {
14571
15033
  ), /* @__PURE__ */ React__default.createElement(Separator, { orientation: "vertical" }), /* @__PURE__ */ React__default.createElement(
14572
15034
  "button",
14573
15035
  {
14574
- className: buttonVariants({
15036
+ className: buttonVariants$1({
14575
15037
  size: "sms",
14576
15038
  variant: "ghost"
14577
15039
  }),