tinacms 0.0.0-d69e892-20241003042309 → 0.0.0-d7c5ec1-20250219020924

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (36) hide show
  1. package/dist/admin/api.d.ts +1 -0
  2. package/dist/admin/types.d.ts +3 -0
  3. package/dist/cache/node-cache.d.ts +1 -0
  4. package/dist/client.js +91 -62
  5. package/dist/client.mjs +50 -36
  6. package/dist/index.d.ts +1 -1
  7. package/dist/index.js +2968 -1198
  8. package/dist/index.mjs +2958 -1184
  9. package/dist/node-cache-5e8db9f0.mjs +63 -0
  10. package/dist/rich-text/index.d.ts +3 -0
  11. package/dist/rich-text/index.js +45 -12
  12. package/dist/rich-text/index.mjs +45 -12
  13. package/dist/toolkit/fields/components/reference/reference-select.d.ts +2 -2
  14. package/dist/toolkit/fields/plugins/mdx-field-plugin/index.d.ts +4 -1
  15. package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/components/fixed-toolbar-buttons.d.ts +0 -4
  16. package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/components/plate-ui/icons.d.ts +2 -0
  17. package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/components/plate-ui/mermaid-element.d.ts +11 -0
  18. package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/components/plate-ui/mermaid-toolbar-button.d.ts +20 -0
  19. package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/components/plate-ui/resizable.d.ts +39 -0
  20. package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/components/plate-ui/table-cell-element.d.ts +27 -0
  21. package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/components/plate-ui/table-dropdown-menu.d.ts +3 -0
  22. package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/components/plate-ui/table-element.d.ts +14 -0
  23. package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/components/plate-ui/table-row-element.d.ts +13 -0
  24. package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/components/plate-ui/text-area.d.ts +5 -0
  25. package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/index.d.ts +1 -1
  26. package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/plugins/core/common.d.ts +1 -0
  27. package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/plugins/custom/mermaid-plugin.d.ts +2 -0
  28. package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/plugins/ui/code-block/index.d.ts +4 -2
  29. package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/plugins/ui/components.d.ts +64 -11
  30. package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/toolbar/toolbar-overrides.d.ts +11 -3
  31. package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/toolbar/toolbar-provider.d.ts +3 -3
  32. package/dist/toolkit/fields/plugins/wrap-field-with-meta.d.ts +8 -0
  33. package/dist/unifiedClient/index.d.ts +8 -1
  34. package/package.json +43 -41
  35. package/dist/__vite-browser-external-d06ac358.mjs +0 -4
  36. package/dist/node-cache-7fa2452c.mjs +0 -43
package/dist/index.mjs CHANGED
@@ -6,32 +6,38 @@ var __publicField = (obj, key, value) => {
6
6
  };
7
7
  import { z } from "zod";
8
8
  import * as React from "react";
9
- import React__default, { useState, useCallback, createContext, forwardRef, useContext, useEffect, useMemo, startTransition, useRef, createElement, Component } from "react";
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";
9
+ import React__default, { useState, useCallback, useEffect, useRef, createContext, forwardRef, useContext, useMemo, startTransition } from "react";
10
+ import { createPortal } from "react-dom";
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, createStrikethroughPlugin, createItalicPlugin, createUnderlinePlugin, createCodePlugin, createListPlugin, createIndentListPlugin, createHorizontalRulePlugin, createNodeIdPlugin, createTablePlugin, getListItemEntry, useListToolbarButtonState, useListToolbarButton } from "@udecode/plate";
13
+ import { PlateElement, isCollapsed, findNodePath, getPointAfter, insertNodes, ELEMENT_DEFAULT, focusEditor, getPointBefore, setNodes, isElement, PlateLeaf, createPluginFactory, useComposedRef, useEditorRef, createPointRef, insertText, moveSelection, toggleNodeType, useElement, useRemoveNodeButton, useEditorSelector, isSelectionExpanded, withHOC, normalizeEditor, getBlockAbove, queryNode, getParentNode, isType, someNode, isSelectionAtBlockStart, setElements, insertNode, getPluginType, isBlock, isBlockAboveEmpty, findNode, PlateContent, getNodeEntries, useEditorState, collapseSelection, useMarkToolbarButtonState, useMarkToolbarButton, insertEmptyElement, usePlateSelectors, useEventEditorSelectors, PortalBody, useFormInputProps, createPlugins, Plate } from "@udecode/plate-common";
13
14
  import { ELEMENT_SLASH_INPUT, createSlashPlugin } from "@udecode/plate-slash-command";
14
- import { cn as cn$1, withRef, withVariants, withProps, withCn, createPrimitiveElement } from "@udecode/cn";
15
- import { useComposedRef, useEditorRef, findNodePath, getPointBefore, createPointRef, insertText, moveSelection, PlateElement, toggleNodeType, PlateLeaf, isCollapsed, getPointAfter, insertNodes, ELEMENT_DEFAULT, focusEditor, setNodes, isElement, createPluginFactory, normalizeEditor, getBlockAbove, queryNode, getParentNode, isType, someNode, isSelectionAtBlockStart, setElements, insertNode, getPluginType, isBlock, isBlockAboveEmpty, findNode, PlateContent, useMarkToolbarButtonState, useMarkToolbarButton, useEditorState, useEditorSelector, getNodeEntries, collapseSelection, usePlateSelectors, useEventEditorSelectors, PortalBody, useFormInputProps, createPlugins, Plate } from "@udecode/plate-common";
16
- import { ELEMENT_H1, ELEMENT_H2, ELEMENT_H3, ELEMENT_H4 as ELEMENT_H4$1, ELEMENT_H5 as ELEMENT_H5$1, ELEMENT_H6 as ELEMENT_H6$1 } from "@udecode/plate-heading";
15
+ import { useSelected, useReadOnly, ReactEditor } from "slate-react";
16
+ import { useCodeBlockElementState, useCodeSyntaxLeaf, ELEMENT_CODE_BLOCK as ELEMENT_CODE_BLOCK$1 } from "@udecode/plate-code-block";
17
+ import MonacoEditor, { loader, useMonaco } from "@monaco-editor/react";
18
+ import { Combobox as Combobox$1, ComboboxInput, ComboboxButton, Transition, ComboboxOptions, ComboboxOption, Popover as Popover$3, PopoverButton, PopoverPanel, TransitionChild, Disclosure, DisclosureButton, DisclosurePanel, Menu, MenuButton, MenuItems, MenuItem } from "@headlessui/react";
17
19
  import { cva } from "class-variance-authority";
18
- import { Plus, AlignCenter as AlignCenter$1, AlignJustify, AlignLeft as AlignLeft$1, AlignRight as AlignRight$1, ChevronDown, PaintBucket, Quote, Check, ChevronRight, ChevronsUpDown, X, FileCode, Baseline, RectangleVertical, Combine, Ungroup, MessageSquare, MessageSquarePlus, Trash, GripVertical, Edit2, Smile, ExternalLink, Heading1, Heading2, Heading3, Heading4, Heading5, Heading6, Indent, Keyboard, WrapText, Minus, MoreHorizontal, Outdent, Pilcrow, RotateCcw, RectangleHorizontal, Search, Settings, Strikethrough, Subscript, Superscript, Table, Text, Underline, Link2Off, Eye, Moon, SunMedium, Twitter } from "lucide-react";
19
- import { useComboboxContext, Combobox, useComboboxStore, ComboboxProvider, Portal, ComboboxPopover, ComboboxItem } from "@ariakit/react";
20
+ import { Eye, SquarePen, Plus, AlignCenter as AlignCenter$1, AlignJustify, AlignLeft as AlignLeft$1, AlignRight as AlignRight$1, ChevronDown, PaintBucket, Quote, Check, ChevronRight, ChevronsUpDown, X, FileCode, Baseline, RectangleVertical, Combine, Ungroup, MessageSquare, MessageSquarePlus, Trash, GripVertical, Edit2, Smile, ExternalLink, Heading1, Heading2, Heading3, Heading4, Heading5, Heading6, Indent, Keyboard, WrapText, Minus, MoreHorizontal, Outdent, Pilcrow, RotateCcw, RectangleHorizontal, Search, Settings, Strikethrough, Subscript, Superscript, Table, Text, Underline, Link2Off, Moon, SunMedium, Twitter } from "lucide-react";
21
+ import mermaid from "mermaid";
22
+ import { ELEMENT_H1, ELEMENT_H2, ELEMENT_H3, ELEMENT_H4 as ELEMENT_H4$1, ELEMENT_H5 as ELEMENT_H5$1, ELEMENT_H6 as ELEMENT_H6$1 } from "@udecode/plate-heading";
23
+ import { useComboboxContext, Combobox as Combobox$2, useComboboxStore, ComboboxProvider, Portal, ComboboxPopover, ComboboxItem } from "@ariakit/react";
20
24
  import { useHTMLInputCursorState, useComboboxInput, filterWords } from "@udecode/plate-combobox";
21
- import { useCodeSyntaxLeaf, useCodeBlockElementState, ELEMENT_CODE_BLOCK as ELEMENT_CODE_BLOCK$1 } from "@udecode/plate-code-block";
22
- import MonacoEditor, { loader, useMonaco } from "@monaco-editor/react";
23
- import { Combobox as Combobox$1, ComboboxInput, ComboboxButton, Transition, ComboboxOptions, ComboboxOption, Popover as Popover$2, PopoverButton, PopoverPanel, TransitionChild, Disclosure, DisclosureButton, DisclosurePanel, Menu, MenuButton, MenuItems, MenuItem } from "@headlessui/react";
25
+ import { useTableCellElementState, useTableCellElement, useTableCellElementResizableState, useTableCellElementResizable, useTableBordersDropdownMenuContentState, useTableMergeState, TableProvider, useTableElementState, useTableElement, mergeTableCells, unmergeTableCells, ELEMENT_TABLE as ELEMENT_TABLE$1, getTableColumnCount, insertTable, deleteTable, insertTableColumn, deleteColumn, insertTableRow, deleteRow } from "@udecode/plate-table";
26
+ import { ResizeHandle as ResizeHandle$1 } from "@udecode/plate-resizable";
27
+ import * as PopoverPrimitive from "@radix-ui/react-popover";
28
+ import { PopoverAnchor } from "@radix-ui/react-popover";
29
+ import { Slot } from "@radix-ui/react-slot";
30
+ import * as DropdownMenuPrimitive from "@radix-ui/react-dropdown-menu";
31
+ import * as SeparatorPrimitive from "@radix-ui/react-separator";
24
32
  import arrayMutators from "final-form-arrays";
25
33
  import setFieldData from "final-form-set-field-data";
26
34
  import { FORM_ERROR, createForm, getIn } from "final-form";
27
35
  import { Field, Form as Form$1 } from "react-final-form";
28
36
  import PropTypes from "prop-types";
29
37
  import { Droppable, Draggable, DragDropContext } from "react-beautiful-dnd";
30
- import * as PopoverPrimitive from "@radix-ui/react-popover";
31
38
  import * as pkg$1 from "react-color";
32
39
  import * as pkg from "color-string";
33
40
  import * as dropzone from "react-dropzone";
34
- import { Slot } from "@radix-ui/react-slot";
35
41
  import { clsx } from "clsx";
36
42
  import { twMerge } from "tailwind-merge";
37
43
  import { Command as Command$1 } from "cmdk";
@@ -42,10 +48,8 @@ import moment from "moment";
42
48
  import { formatDistanceToNow } from "date-fns";
43
49
  import { useLinkToolbarButtonState, useLinkToolbarButton, useFloatingLinkInsertState, useFloatingLinkInsert, useFloatingLinkEditState, useFloatingLinkEdit, FloatingLinkUrlInput, LinkOpenButton, createLinkPlugin } from "@udecode/plate-link";
44
50
  import * as ToolbarPrimitive from "@radix-ui/react-toolbar";
45
- import * as SeparatorPrimitive from "@radix-ui/react-separator";
46
51
  import * as TooltipPrimitive from "@radix-ui/react-tooltip";
47
52
  import { ELEMENT_PARAGRAPH as ELEMENT_PARAGRAPH$1 } from "@udecode/plate-paragraph";
48
- import * as DropdownMenuPrimitive from "@radix-ui/react-dropdown-menu";
49
53
  import { ELEMENT_BLOCKQUOTE as ELEMENT_BLOCKQUOTE$1 } from "@udecode/plate-block-quote";
50
54
  import { useFloatingToolbarState, offset, flip, useFloatingToolbar } from "@udecode/plate-floating";
51
55
  import { useWindowWidth } from "@react-hook/window-size";
@@ -797,6 +801,22 @@ function wrapFieldsWithMeta(Field2) {
797
801
  );
798
802
  };
799
803
  }
804
+ function wrapFieldWithNoHeader(Field2) {
805
+ return (props) => {
806
+ return /* @__PURE__ */ React.createElement(
807
+ FieldMeta,
808
+ {
809
+ name: props.input.name,
810
+ label: false,
811
+ description: "",
812
+ error: props.meta.error,
813
+ index: props.index,
814
+ tinaForm: props.tinaForm
815
+ },
816
+ /* @__PURE__ */ React.createElement(Field2, { ...props })
817
+ );
818
+ };
819
+ }
800
820
  function wrapFieldWithError(Field2) {
801
821
  return (props) => {
802
822
  return /* @__PURE__ */ React.createElement(
@@ -869,6 +889,16 @@ const FieldDescription = ({
869
889
  className,
870
890
  ...props
871
891
  }) => {
892
+ if (typeof children === "string") {
893
+ return /* @__PURE__ */ React.createElement(
894
+ "span",
895
+ {
896
+ className: `block font-sans text-xs italic font-light text-gray-400 pt-0.5 whitespace-normal m-0 ${className}`,
897
+ ...props,
898
+ dangerouslySetInnerHTML: { __html: children }
899
+ }
900
+ );
901
+ }
872
902
  return /* @__PURE__ */ React.createElement(
873
903
  "span",
874
904
  {
@@ -905,6 +935,20 @@ const useEditorContext = () => {
905
935
  const useTemplates = () => {
906
936
  return React__default.useContext(EditorContext);
907
937
  };
938
+ const BlockquoteElement = withRef(
939
+ ({ children, className, ...props }, ref) => {
940
+ return /* @__PURE__ */ React__default.createElement(
941
+ PlateElement,
942
+ {
943
+ asChild: true,
944
+ className: cn$1("my-1 border-l-2 pl-6 italic", className),
945
+ ref,
946
+ ...props
947
+ },
948
+ /* @__PURE__ */ React__default.createElement("blockquote", null, children)
949
+ );
950
+ }
951
+ );
908
952
  function classNames$1(...classes) {
909
953
  return classes.filter(Boolean).join(" ");
910
954
  }
@@ -914,6 +958,503 @@ const uuid = () => {
914
958
  (c) => (c ^ crypto.getRandomValues(new Uint8Array(1))[0] & 15 >> c / 4).toString(16)
915
959
  );
916
960
  };
961
+ function ChevronDownIcon(props, svgRef) {
962
+ return /* @__PURE__ */ React.createElement("svg", Object.assign({
963
+ xmlns: "http://www.w3.org/2000/svg",
964
+ viewBox: "0 0 20 20",
965
+ fill: "currentColor",
966
+ "aria-hidden": "true",
967
+ ref: svgRef
968
+ }, props), /* @__PURE__ */ React.createElement("path", {
969
+ fillRule: "evenodd",
970
+ 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",
971
+ clipRule: "evenodd"
972
+ }));
973
+ }
974
+ const ForwardRef = React.forwardRef(ChevronDownIcon);
975
+ const ChevronDownIcon$1 = ForwardRef;
976
+ const Autocomplete = ({
977
+ value,
978
+ onChange,
979
+ defaultQuery,
980
+ items: items2
981
+ }) => {
982
+ const [query, setQuery] = React__default.useState(defaultQuery ?? "");
983
+ const filteredItems = React__default.useMemo(() => {
984
+ try {
985
+ const reFilter = new RegExp(query, "i");
986
+ const _items = items2.filter((item) => reFilter.test(item.label));
987
+ if (_items.length === 0)
988
+ return items2;
989
+ return _items;
990
+ } catch (err) {
991
+ return items2;
992
+ }
993
+ }, [items2, query]);
994
+ return /* @__PURE__ */ React__default.createElement(
995
+ Combobox$1,
996
+ {
997
+ value,
998
+ onChange,
999
+ as: "div",
1000
+ className: "relative inline-block text-left z-20"
1001
+ },
1002
+ /* @__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(
1003
+ ComboboxInput,
1004
+ {
1005
+ 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",
1006
+ displayValue: (item) => (item == null ? void 0 : item.label) ?? "Plain Text",
1007
+ onChange: (event) => setQuery(event.target.value),
1008
+ onClick: (ev) => ev.stopPropagation()
1009
+ }
1010
+ ), /* @__PURE__ */ React__default.createElement(ComboboxButton, { className: "absolute inset-y-0 right-0 flex items-center pr-2" }, /* @__PURE__ */ React__default.createElement(
1011
+ ChevronDownIcon$1,
1012
+ {
1013
+ className: "h-5 w-5 text-gray-400",
1014
+ "aria-hidden": "true"
1015
+ }
1016
+ )))),
1017
+ /* @__PURE__ */ React__default.createElement(
1018
+ Transition,
1019
+ {
1020
+ enter: "transition ease-out duration-100",
1021
+ enterFrom: "transform opacity-0 scale-95",
1022
+ enterTo: "transform opacity-100 scale-100",
1023
+ leave: "transition ease-in duration-75",
1024
+ leaveFrom: "transform opacity-100 scale-100",
1025
+ leaveTo: "transform opacity-0 scale-95"
1026
+ },
1027
+ /* @__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(
1028
+ "button",
1029
+ {
1030
+ className: classNames$1(
1031
+ focus ? "bg-gray-100 text-gray-900" : "text-gray-700",
1032
+ "block px-4 py-2 text-xs w-full text-right"
1033
+ )
1034
+ },
1035
+ item.render(item)
1036
+ ))))
1037
+ )
1038
+ );
1039
+ };
1040
+ loader.config({
1041
+ paths: { vs: "https://cdn.jsdelivr.net/npm/monaco-editor@0.31.1/min/vs" }
1042
+ });
1043
+ let retryCount = 0;
1044
+ const retryFocus = (ref) => {
1045
+ if (ref.current) {
1046
+ ref.current.focus();
1047
+ } else {
1048
+ if (retryCount < 30) {
1049
+ setTimeout(() => {
1050
+ retryCount = retryCount + 1;
1051
+ retryFocus(ref);
1052
+ }, 100);
1053
+ }
1054
+ }
1055
+ };
1056
+ const MINIMUM_HEIGHT = 75;
1057
+ const CodeBlock = ({
1058
+ attributes,
1059
+ editor,
1060
+ element,
1061
+ language: restrictLanguage,
1062
+ onChangeCallback,
1063
+ defaultValue,
1064
+ ...props
1065
+ }) => {
1066
+ const [navigateAway, setNavigateAway] = React__default.useState(null);
1067
+ const monaco = useMonaco();
1068
+ const monacoEditorRef = React__default.useRef(null);
1069
+ const selected = useSelected();
1070
+ const [height, setHeight] = React__default.useState(MINIMUM_HEIGHT);
1071
+ React__default.useEffect(() => {
1072
+ if (selected && isCollapsed(editor.selection)) {
1073
+ retryFocus(monacoEditorRef);
1074
+ }
1075
+ }, [selected, monacoEditorRef.current]);
1076
+ const value = element.value || "";
1077
+ if (typeof value !== "string") {
1078
+ throw new Error("Element must be of type string for code block");
1079
+ }
1080
+ const language = restrictLanguage || element.lang;
1081
+ const id = React__default.useMemo(() => uuid(), []);
1082
+ const languages = React__default.useMemo(() => {
1083
+ const defaultLangSet = { "": "plain text" };
1084
+ if (!monaco)
1085
+ return defaultLangSet;
1086
+ return monaco.languages.getLanguages().reduce((ac, cv) => {
1087
+ if (cv.id === "plaintext")
1088
+ return ac;
1089
+ return { ...ac, [cv.id]: cv.id };
1090
+ }, defaultLangSet);
1091
+ }, [monaco]);
1092
+ React__default.useEffect(() => {
1093
+ if (monaco) {
1094
+ monaco.languages.typescript.typescriptDefaults.setEagerModelSync(true);
1095
+ monaco.languages.typescript.typescriptDefaults.setDiagnosticsOptions({
1096
+ // disable errors
1097
+ noSemanticValidation: true,
1098
+ noSyntaxValidation: true
1099
+ });
1100
+ }
1101
+ }, [monaco]);
1102
+ const items2 = Object.entries(languages).map(([key, label]) => ({
1103
+ key,
1104
+ label,
1105
+ render: (item) => item.label
1106
+ }));
1107
+ const currentItem = React__default.useMemo(() => {
1108
+ return items2.find((item) => item.key === language) ?? {
1109
+ key: "",
1110
+ label: "Plain Text"
1111
+ };
1112
+ }, [items2, language]);
1113
+ React__default.useEffect(() => {
1114
+ if (navigateAway) {
1115
+ setNavigateAway(null);
1116
+ switch (navigateAway) {
1117
+ case "remove":
1118
+ {
1119
+ focusEditor(editor);
1120
+ setNodes(
1121
+ editor,
1122
+ {
1123
+ type: "p",
1124
+ children: [{ text: "" }],
1125
+ lang: void 0,
1126
+ value: void 0
1127
+ },
1128
+ {
1129
+ match: (n) => {
1130
+ if (isElement(n) && n.type === element.type) {
1131
+ return true;
1132
+ }
1133
+ }
1134
+ }
1135
+ );
1136
+ }
1137
+ break;
1138
+ case "insertNext":
1139
+ {
1140
+ insertNodes(
1141
+ editor,
1142
+ [
1143
+ {
1144
+ type: ELEMENT_DEFAULT,
1145
+ children: [{ text: "" }],
1146
+ lang: void 0,
1147
+ value: void 0
1148
+ }
1149
+ ],
1150
+ { select: true }
1151
+ );
1152
+ focusEditor(editor);
1153
+ }
1154
+ break;
1155
+ case "up":
1156
+ {
1157
+ const path = findNodePath(editor, element);
1158
+ if (!path) {
1159
+ return;
1160
+ }
1161
+ const previousNodePath = getPointBefore(editor, path);
1162
+ if (!previousNodePath) {
1163
+ focusEditor(editor);
1164
+ insertNodes(
1165
+ editor,
1166
+ [
1167
+ {
1168
+ type: ELEMENT_DEFAULT,
1169
+ children: [{ text: "" }],
1170
+ lang: void 0,
1171
+ value: void 0
1172
+ }
1173
+ ],
1174
+ // Insert a new node at the current path, resulting in the code_block
1175
+ // moving down one block
1176
+ { at: path, select: true }
1177
+ );
1178
+ return;
1179
+ }
1180
+ focusEditor(editor, previousNodePath);
1181
+ }
1182
+ break;
1183
+ case "down": {
1184
+ const path = findNodePath(editor, element);
1185
+ if (!path) {
1186
+ return;
1187
+ }
1188
+ const nextNodePath = getPointAfter(editor, path);
1189
+ if (!nextNodePath) {
1190
+ insertNodes(
1191
+ editor,
1192
+ [
1193
+ {
1194
+ type: ELEMENT_DEFAULT,
1195
+ children: [{ text: "" }],
1196
+ lang: void 0,
1197
+ value: void 0
1198
+ }
1199
+ ],
1200
+ { select: true }
1201
+ );
1202
+ focusEditor(editor);
1203
+ } else {
1204
+ focusEditor(editor, nextNodePath);
1205
+ }
1206
+ break;
1207
+ }
1208
+ }
1209
+ }
1210
+ }, [navigateAway]);
1211
+ function handleEditorDidMount(monacoEditor, monaco2) {
1212
+ monacoEditorRef.current = monacoEditor;
1213
+ monacoEditor.onDidContentSizeChange(() => {
1214
+ setHeight(
1215
+ monacoEditor.getContentHeight() > MINIMUM_HEIGHT ? monacoEditor.getContentHeight() : MINIMUM_HEIGHT
1216
+ );
1217
+ monacoEditor.layout();
1218
+ });
1219
+ setNodes(editor, { value: defaultValue, lang: language });
1220
+ monacoEditor.addCommand(monaco2.KeyMod.Shift | monaco2.KeyCode.Enter, () => {
1221
+ if (monacoEditor.hasTextFocus()) {
1222
+ setNavigateAway("insertNext");
1223
+ }
1224
+ });
1225
+ monacoEditor.onKeyDown((l) => {
1226
+ if (l.code === "ArrowUp") {
1227
+ const selection = monacoEditor.getSelection();
1228
+ if (selection.endLineNumber === 1 && selection.startLineNumber === 1) {
1229
+ setNavigateAway("up");
1230
+ }
1231
+ }
1232
+ if (l.code === "ArrowDown") {
1233
+ const selection = monacoEditor.getSelection();
1234
+ const totalLines = monacoEditor.getModel().getLineCount();
1235
+ if (selection.endLineNumber === totalLines && selection.startLineNumber === totalLines) {
1236
+ setNavigateAway("down");
1237
+ }
1238
+ }
1239
+ if (l.code === "Backspace") {
1240
+ const selection = monacoEditor.getSelection();
1241
+ 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) {
1242
+ setNavigateAway("remove");
1243
+ }
1244
+ }
1245
+ });
1246
+ }
1247
+ return /* @__PURE__ */ React__default.createElement(
1248
+ "div",
1249
+ {
1250
+ ...attributes,
1251
+ className: "relative mb-2 mt-0.5 rounded-lg shadow-md p-2 border-gray-200 border"
1252
+ },
1253
+ /* @__PURE__ */ React__default.createElement("style", null, `.monaco-editor .editor-widget {
1254
+ display: none !important;
1255
+ visibility: hidden !important;
1256
+ }`),
1257
+ props.children,
1258
+ /* @__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(
1259
+ Autocomplete,
1260
+ {
1261
+ items: items2,
1262
+ value: currentItem,
1263
+ defaultQuery: "plaintext",
1264
+ onChange: (item) => setNodes(editor, { lang: item.key })
1265
+ }
1266
+ )), /* @__PURE__ */ React__default.createElement("div", { style: { height: `${height}px` } }, /* @__PURE__ */ React__default.createElement(
1267
+ MonacoEditor,
1268
+ {
1269
+ path: id,
1270
+ onMount: handleEditorDidMount,
1271
+ options: {
1272
+ scrollBeyondLastLine: false,
1273
+ // automaticLayout: true,
1274
+ tabSize: 2,
1275
+ disableLayerHinting: true,
1276
+ accessibilitySupport: "off",
1277
+ codeLens: false,
1278
+ wordWrap: "on",
1279
+ minimap: {
1280
+ enabled: false
1281
+ },
1282
+ fontSize: 14,
1283
+ lineHeight: 2,
1284
+ formatOnPaste: true,
1285
+ lineNumbers: "off",
1286
+ formatOnType: true,
1287
+ fixedOverflowWidgets: true,
1288
+ // Takes too much horizontal space for iframe
1289
+ folding: false,
1290
+ renderLineHighlight: "none",
1291
+ scrollbar: {
1292
+ verticalScrollbarSize: 1,
1293
+ horizontalScrollbarSize: 1,
1294
+ // https://github.com/microsoft/monaco-editor/issues/2007#issuecomment-644425664
1295
+ alwaysConsumeMouseWheel: false
1296
+ }
1297
+ },
1298
+ language: String(language),
1299
+ value: String(element.value),
1300
+ onChange: (value2) => {
1301
+ onChangeCallback == null ? void 0 : onChangeCallback(value2);
1302
+ setNodes(editor, { value: value2, lang: language });
1303
+ }
1304
+ }
1305
+ )))
1306
+ );
1307
+ };
1308
+ const CodeBlockElement = withRef(
1309
+ ({ className, ...props }, ref) => {
1310
+ const { element } = props;
1311
+ const state = useCodeBlockElementState({ element });
1312
+ return /* @__PURE__ */ React__default.createElement(
1313
+ PlateElement,
1314
+ {
1315
+ className: cn$1("relative py-1", state.className, className),
1316
+ ref,
1317
+ ...props
1318
+ },
1319
+ /* @__PURE__ */ React__default.createElement(CodeBlock, { ...props })
1320
+ );
1321
+ }
1322
+ );
1323
+ const CodeLeaf = withRef(
1324
+ ({ children, className, ...props }, ref) => {
1325
+ return /* @__PURE__ */ React__default.createElement(
1326
+ PlateLeaf,
1327
+ {
1328
+ asChild: true,
1329
+ className: cn$1(
1330
+ "whitespace-pre-wrap rounded-md bg-muted px-[0.3em] py-[0.2em] font-mono text-sm",
1331
+ className
1332
+ ),
1333
+ ref,
1334
+ ...props
1335
+ },
1336
+ /* @__PURE__ */ React__default.createElement("code", null, children)
1337
+ );
1338
+ }
1339
+ );
1340
+ const CodeLineElement = withRef((props, ref) => /* @__PURE__ */ React__default.createElement(PlateElement, { ref, ...props }));
1341
+ const CodeSyntaxLeaf = withRef(
1342
+ ({ children, ...props }, ref) => {
1343
+ const { leaf } = props;
1344
+ const { tokenProps } = useCodeSyntaxLeaf({ leaf });
1345
+ return /* @__PURE__ */ React__default.createElement(PlateLeaf, { ref, ...props }, /* @__PURE__ */ React__default.createElement("span", { ...tokenProps }, children));
1346
+ }
1347
+ );
1348
+ const listVariants = cva("m-0 ps-6", {
1349
+ variants: {
1350
+ variant: {
1351
+ ol: "list-decimal",
1352
+ ul: "list-disc [&_ul]:list-[circle] [&_ul_ul]:list-[square]"
1353
+ }
1354
+ }
1355
+ });
1356
+ const ListElementVariants = withVariants(PlateElement, listVariants, [
1357
+ "variant"
1358
+ ]);
1359
+ const ListElement = withRef(
1360
+ ({ children, variant = "ul", ...props }, ref) => {
1361
+ const Component = variant;
1362
+ return /* @__PURE__ */ React__default.createElement(ListElementVariants, { asChild: true, ref, variant, ...props }, /* @__PURE__ */ React__default.createElement(Component, null, children));
1363
+ }
1364
+ );
1365
+ const ELEMENT_MERMAID = "mermaid";
1366
+ const createMermaidPlugin = createPluginFactory({
1367
+ isElement: true,
1368
+ isVoid: true,
1369
+ isInline: false,
1370
+ key: ELEMENT_MERMAID
1371
+ });
1372
+ const MermaidElementWithRef = ({ config }) => {
1373
+ const mermaidRef = useRef(null);
1374
+ useEffect(() => {
1375
+ if (mermaidRef.current) {
1376
+ mermaid.initialize({ startOnLoad: true });
1377
+ mermaid.init();
1378
+ }
1379
+ }, [config]);
1380
+ 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)));
1381
+ };
1382
+ const Bubble = ({ children }) => {
1383
+ 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);
1384
+ };
1385
+ const ErrorMsg = ({ error }) => {
1386
+ if (error) {
1387
+ return /* @__PURE__ */ React__default.createElement(
1388
+ "div",
1389
+ {
1390
+ contentEditable: false,
1391
+ className: "font-mono bg-red-600 text-white p-2 rounded-md cursor-default"
1392
+ },
1393
+ error
1394
+ );
1395
+ }
1396
+ return null;
1397
+ };
1398
+ const DEFAULT_MERMAID_CONFIG = `%% This won't render without implementing a rendering engine (e.g. mermaid on npm)
1399
+ flowchart TD
1400
+ id1(this is an example flow diagram)
1401
+ --> id2(modify me to see changes!)
1402
+ id2
1403
+ --> id3(Click the top button to preview the changes)
1404
+ --> id4(Learn about mermaid diagrams - mermaid.js.org)`;
1405
+ const MermaidElement = withRef(
1406
+ ({ children, nodeProps, element, ...props }, ref) => {
1407
+ const [mermaidConfig, setMermaidConfig] = useState(
1408
+ element.value || DEFAULT_MERMAID_CONFIG
1409
+ );
1410
+ const [isEditing, setIsEditing] = useState(
1411
+ mermaidConfig === DEFAULT_MERMAID_CONFIG || false
1412
+ );
1413
+ const [mermaidError, setMermaidError] = useState(null);
1414
+ const node = {
1415
+ type: ELEMENT_MERMAID,
1416
+ value: mermaidConfig,
1417
+ children: [{ type: "text", text: "" }]
1418
+ };
1419
+ useEffect(() => {
1420
+ if (mermaid.parse(mermaidConfig)) {
1421
+ setMermaidError(null);
1422
+ }
1423
+ }, [mermaidConfig]);
1424
+ mermaid.parseError = (err) => {
1425
+ setMermaidError(
1426
+ String(err.message) || "An error occurred while parsing the diagram."
1427
+ );
1428
+ };
1429
+ 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(
1430
+ Eye,
1431
+ {
1432
+ className: "w-5 h-5 fill-white cursor-pointer",
1433
+ onClick: () => {
1434
+ setIsEditing(!isEditing);
1435
+ }
1436
+ }
1437
+ ) : /* @__PURE__ */ React__default.createElement(
1438
+ SquarePen,
1439
+ {
1440
+ className: "w-5 h-5 fill-white cursor-pointer",
1441
+ onClick: () => {
1442
+ setIsEditing(!isEditing);
1443
+ }
1444
+ }
1445
+ ))), isEditing ? /* @__PURE__ */ React__default.createElement(
1446
+ CodeBlock,
1447
+ {
1448
+ children: "",
1449
+ language: "yaml",
1450
+ ...props,
1451
+ element: node,
1452
+ defaultValue: mermaidConfig,
1453
+ onChangeCallback: (value) => setMermaidConfig(value)
1454
+ }
1455
+ ) : /* @__PURE__ */ React__default.createElement(MermaidElementWithRef, { config: mermaidConfig })), children, /* @__PURE__ */ React__default.createElement(ErrorMsg, { error: mermaidError }));
1456
+ }
1457
+ );
917
1458
  const RawMarkdown = () => {
918
1459
  return /* @__PURE__ */ React__default.createElement(
919
1460
  "svg",
@@ -932,6 +1473,29 @@ const RawMarkdown = () => {
932
1473
  /* @__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" })
933
1474
  );
934
1475
  };
1476
+ const MermaidIcon = () => /* @__PURE__ */ React__default.createElement(
1477
+ "svg",
1478
+ {
1479
+ width: "100%",
1480
+ height: "100%",
1481
+ viewBox: "0 0 491 491",
1482
+ version: "1.1",
1483
+ xmlns: "http://www.w3.org/2000/svg",
1484
+ fillRule: "evenodd",
1485
+ clipRule: "evenodd",
1486
+ strokeLinejoin: "round",
1487
+ strokeMiterlimit: 2
1488
+ },
1489
+ /* @__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" }),
1490
+ /* @__PURE__ */ React__default.createElement(
1491
+ "path",
1492
+ {
1493
+ 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",
1494
+ fill: "white",
1495
+ fillRule: "nonzero"
1496
+ }
1497
+ )
1498
+ );
935
1499
  const borderAll = (props) => /* @__PURE__ */ React__default.createElement(
936
1500
  "svg",
937
1501
  {
@@ -1016,7 +1580,7 @@ const borderTop = (props) => /* @__PURE__ */ React__default.createElement(
1016
1580
  },
1017
1581
  /* @__PURE__ */ React__default.createElement("path", { d: "M3 6a1 1 0 0 0 2 0 1 1 0 0 1 1-1h12a1 1 0 0 1 1 1 1 1 0 1 0 2 0 3 3 0 0 0-3-3H6a3 3 0 0 0-3 3zm2 5a1 1 0 1 0-2 0v2a1 1 0 1 0 2 0v-2zm14 0a1 1 0 1 1 2 0v2a1 1 0 1 1-2 0v-2zm-5 9a1 1 0 0 1-1 1h-2a1 1 0 1 1 0-2h2a1 1 0 0 1 1 1zm-8 1a1 1 0 1 0 0-2 1 1 0 0 1-1-1 1 1 0 1 0-2 0 3 3 0 0 0 3 3zm11-1a1 1 0 0 0 1 1 3 3 0 0 0 3-3 1 1 0 1 0-2 0 1 1 0 0 1-1 1 1 1 0 0 0-1 1z" })
1018
1582
  );
1019
- cva("", {
1583
+ const iconVariants = cva("", {
1020
1584
  variants: {
1021
1585
  variant: {
1022
1586
  toolbar: "size-5",
@@ -1172,6 +1736,7 @@ const Icons = {
1172
1736
  clear: X,
1173
1737
  close: X,
1174
1738
  // code: Code2,
1739
+ paint: PaintBucket,
1175
1740
  codeblock: FileCode,
1176
1741
  color: Baseline,
1177
1742
  column: RectangleVertical,
@@ -1197,6 +1762,7 @@ const Icons = {
1197
1762
  lineHeight: WrapText,
1198
1763
  // link: Link2,
1199
1764
  minus: Minus,
1765
+ mermaid: MermaidIcon,
1200
1766
  more: MoreHorizontal,
1201
1767
  // ol: ListOrdered,
1202
1768
  outdent: Outdent,
@@ -1607,7 +2173,7 @@ const InlineComboboxInput = forwardRef(({ className, ...props }, propRef) => {
1607
2173
  },
1608
2174
  value || "​"
1609
2175
  ), /* @__PURE__ */ React__default.createElement(
1610
- Combobox,
2176
+ Combobox$2,
1611
2177
  {
1612
2178
  autoSelect: true,
1613
2179
  className: cn$1(
@@ -1767,417 +2333,482 @@ const SlashInputElement = withRef(
1767
2333
  );
1768
2334
  }
1769
2335
  );
1770
- const listVariants = cva("m-0 ps-6", {
1771
- variants: {
1772
- variant: {
1773
- ol: "list-decimal",
1774
- ul: "list-disc [&_ul]:list-[circle] [&_ul_ul]:list-[square]"
1775
- }
1776
- }
1777
- });
1778
- const ListElementVariants = withVariants(PlateElement, listVariants, [
1779
- "variant"
1780
- ]);
1781
- const ListElement = withRef(
1782
- ({ children, variant = "ul", ...props }, ref) => {
1783
- const Component2 = variant;
1784
- return /* @__PURE__ */ React__default.createElement(ListElementVariants, { asChild: true, ref, variant, ...props }, /* @__PURE__ */ React__default.createElement(Component2, null, children));
1785
- }
1786
- );
1787
- const BlockquoteElement = withRef(
1788
- ({ children, className, ...props }, ref) => {
1789
- return /* @__PURE__ */ React__default.createElement(
1790
- PlateElement,
1791
- {
1792
- asChild: true,
1793
- className: cn$1("my-1 border-l-2 pl-6 italic", className),
1794
- ref,
1795
- ...props
1796
- },
1797
- /* @__PURE__ */ React__default.createElement("blockquote", null, children)
1798
- );
1799
- }
1800
- );
1801
- const CodeLeaf = withRef(
1802
- ({ children, className, ...props }, ref) => {
1803
- return /* @__PURE__ */ React__default.createElement(
1804
- PlateLeaf,
1805
- {
1806
- asChild: true,
1807
- className: cn$1(
1808
- "whitespace-pre-wrap rounded-md bg-muted px-[0.3em] py-[0.2em] font-mono text-sm",
1809
- className
1810
- ),
1811
- ref,
1812
- ...props
1813
- },
1814
- /* @__PURE__ */ React__default.createElement("code", null, children)
1815
- );
1816
- }
1817
- );
1818
- const CodeLineElement = withRef((props, ref) => /* @__PURE__ */ React__default.createElement(PlateElement, { ref, ...props }));
1819
- const CodeSyntaxLeaf = withRef(
1820
- ({ children, ...props }, ref) => {
1821
- const { leaf } = props;
1822
- const { tokenProps } = useCodeSyntaxLeaf({ leaf });
1823
- return /* @__PURE__ */ React__default.createElement(PlateLeaf, { ref, ...props }, /* @__PURE__ */ React__default.createElement("span", { ...tokenProps }, children));
1824
- }
1825
- );
1826
- function ChevronDownIcon(props, svgRef) {
1827
- return /* @__PURE__ */ React.createElement("svg", Object.assign({
1828
- xmlns: "http://www.w3.org/2000/svg",
1829
- viewBox: "0 0 20 20",
1830
- fill: "currentColor",
1831
- "aria-hidden": "true",
1832
- ref: svgRef
1833
- }, props), /* @__PURE__ */ React.createElement("path", {
1834
- fillRule: "evenodd",
1835
- d: "M5.293 7.293a1 1 0 011.414 0L10 10.586l3.293-3.293a1 1 0 111.414 1.414l-4 4a1 1 0 01-1.414 0l-4-4a1 1 0 010-1.414z",
1836
- clipRule: "evenodd"
1837
- }));
1838
- }
1839
- const ForwardRef = React.forwardRef(ChevronDownIcon);
1840
- const ChevronDownIcon$1 = ForwardRef;
1841
- const Autocomplete = ({
1842
- value,
1843
- onChange,
1844
- defaultQuery,
1845
- items: items2
1846
- }) => {
1847
- const [query, setQuery] = React__default.useState(defaultQuery ?? "");
1848
- const filteredItems = React__default.useMemo(() => {
1849
- try {
1850
- const reFilter = new RegExp(query, "i");
1851
- const _items = items2.filter((item) => reFilter.test(item.label));
1852
- if (_items.length === 0)
1853
- return items2;
1854
- return _items;
1855
- } catch (err) {
1856
- return items2;
1857
- }
1858
- }, [items2, query]);
2336
+ const TableCellElement = withRef(({ children, className, hideBorder, isHeader, style, ...props }, ref) => {
2337
+ var _a, _b, _c, _d;
2338
+ const { element } = props;
2339
+ const {
2340
+ borders,
2341
+ colIndex,
2342
+ colSpan,
2343
+ hovered,
2344
+ hoveredLeft,
2345
+ isSelectingCell,
2346
+ readOnly,
2347
+ rowIndex,
2348
+ rowSize,
2349
+ selected
2350
+ } = useTableCellElementState();
2351
+ const { props: cellProps } = useTableCellElement({ element: props.element });
2352
+ const resizableState = useTableCellElementResizableState({
2353
+ colIndex,
2354
+ colSpan,
2355
+ rowIndex
2356
+ });
2357
+ const { bottomProps, hiddenLeft, leftProps, rightProps } = useTableCellElementResizable(resizableState);
2358
+ const Cell = isHeader ? "th" : "td";
1859
2359
  return /* @__PURE__ */ React__default.createElement(
1860
- Combobox$1,
2360
+ PlateElement,
1861
2361
  {
1862
- value,
1863
- onChange,
1864
- as: "div",
1865
- className: "relative inline-block text-left z-20"
1866
- },
1867
- /* @__PURE__ */ React__default.createElement("div", { className: "mt-1" }, /* @__PURE__ */ React__default.createElement("div", { className: "relative w-full cursor-default overflow-hidden rounded-lg bg-white text-left shadow-md sm:text-sm" }, /* @__PURE__ */ React__default.createElement(
1868
- ComboboxInput,
1869
- {
1870
- className: "w-full border-none py-2 pl-3 pr-10 text-sm leading-5 text-gray-900 focus:ring-0 focus:outline-none focus-visible:ring-2 focus-visible:ring-white focus-visible:ring-opacity-75 focus-visible:ring-offset-2 focus-visible:ring-offset-teal-300",
1871
- displayValue: (item) => (item == null ? void 0 : item.label) ?? "Plain Text",
1872
- onChange: (event) => setQuery(event.target.value),
1873
- onClick: (ev) => ev.stopPropagation()
2362
+ asChild: true,
2363
+ className: cn$1(
2364
+ "relative h-full overflow-visible border-none bg-background p-0",
2365
+ hideBorder && "before:border-none",
2366
+ element.background ? "bg-[--cellBackground]" : "bg-background",
2367
+ !hideBorder && cn$1(
2368
+ isHeader && "text-left [&_>_*]:m-0",
2369
+ "before:size-full",
2370
+ selected && "before:z-10 before:bg-muted",
2371
+ "before:absolute before:box-border before:select-none before:content-['']",
2372
+ borders && cn$1(
2373
+ ((_a = borders.bottom) == null ? void 0 : _a.size) && `before:border-b before:border-b-border`,
2374
+ ((_b = borders.right) == null ? void 0 : _b.size) && `before:border-r before:border-r-border`,
2375
+ ((_c = borders.left) == null ? void 0 : _c.size) && `before:border-l before:border-l-border`,
2376
+ ((_d = borders.top) == null ? void 0 : _d.size) && `before:border-t before:border-t-border`
2377
+ )
2378
+ ),
2379
+ className
2380
+ ),
2381
+ ref,
2382
+ ...cellProps,
2383
+ ...props,
2384
+ style: {
2385
+ "--cellBackground": element.background,
2386
+ ...style
1874
2387
  }
1875
- ), /* @__PURE__ */ React__default.createElement(ComboboxButton, { className: "absolute inset-y-0 right-0 flex items-center pr-2" }, /* @__PURE__ */ React__default.createElement(
1876
- ChevronDownIcon$1,
2388
+ },
2389
+ /* @__PURE__ */ React__default.createElement(Cell, null, /* @__PURE__ */ React__default.createElement(
2390
+ "div",
1877
2391
  {
1878
- className: "h-5 w-5 text-gray-400",
1879
- "aria-hidden": "true"
1880
- }
1881
- )))),
1882
- /* @__PURE__ */ React__default.createElement(
1883
- Transition,
2392
+ className: "relative z-20 box-border h-full px-3 py-2",
2393
+ style: {
2394
+ minHeight: rowSize
2395
+ }
2396
+ },
2397
+ children
2398
+ ), !isSelectingCell && /* @__PURE__ */ React__default.createElement(
2399
+ "div",
1884
2400
  {
1885
- enter: "transition ease-out duration-100",
1886
- enterFrom: "transform opacity-0 scale-95",
1887
- enterTo: "transform opacity-100 scale-100",
1888
- leave: "transition ease-in duration-75",
1889
- leaveFrom: "transform opacity-100 scale-100",
1890
- leaveTo: "transform opacity-0 scale-95"
2401
+ className: "group absolute top-0 size-full select-none",
2402
+ contentEditable: false,
2403
+ suppressContentEditableWarning: true
1891
2404
  },
1892
- /* @__PURE__ */ React__default.createElement(ComboboxOptions, { className: "origin-top-right absolute right-0 mt-1 w-full max-h-[300px] overflow-y-auto rounded-md shadow-lg bg-white ring-1 ring-black ring-opacity-5 focus:outline-none" }, filteredItems.map((item) => /* @__PURE__ */ React__default.createElement(ComboboxOption, { key: item.key, value: item }, ({ focus }) => /* @__PURE__ */ React__default.createElement(
1893
- "button",
2405
+ !readOnly && /* @__PURE__ */ React__default.createElement(React__default.Fragment, null, /* @__PURE__ */ React__default.createElement(
2406
+ ResizeHandle$1,
1894
2407
  {
1895
- className: classNames$1(
1896
- focus ? "bg-gray-100 text-gray-900" : "text-gray-700",
1897
- "block px-4 py-2 text-xs w-full text-right"
2408
+ ...rightProps,
2409
+ className: "-top-3 right-[-5px] w-[10px]"
2410
+ }
2411
+ ), /* @__PURE__ */ React__default.createElement(
2412
+ ResizeHandle$1,
2413
+ {
2414
+ ...bottomProps,
2415
+ className: "bottom-[-5px] h-[10px]"
2416
+ }
2417
+ ), !hiddenLeft && /* @__PURE__ */ React__default.createElement(
2418
+ ResizeHandle$1,
2419
+ {
2420
+ ...leftProps,
2421
+ className: "-top-3 left-[-5px] w-[10px]"
2422
+ }
2423
+ ), hovered && /* @__PURE__ */ React__default.createElement(
2424
+ "div",
2425
+ {
2426
+ className: cn$1(
2427
+ "absolute -top-3 z-30 h-[calc(100%_+_12px)] w-1 bg-ring",
2428
+ "right-[-1.5px]"
1898
2429
  )
1899
- },
1900
- item.render(item)
1901
- ))))
1902
- )
2430
+ }
2431
+ ), hoveredLeft && /* @__PURE__ */ React__default.createElement(
2432
+ "div",
2433
+ {
2434
+ className: cn$1(
2435
+ "absolute -top-3 z-30 h-[calc(100%_+_12px)] w-1 bg-ring",
2436
+ "left-[-1.5px]"
2437
+ )
2438
+ }
2439
+ ))
2440
+ ))
1903
2441
  );
1904
- };
1905
- loader.config({
1906
- paths: { vs: "https://cdn.jsdelivr.net/npm/monaco-editor@0.31.1/min/vs" }
1907
2442
  });
1908
- let retryCount = 0;
1909
- const retryFocus = (ref) => {
1910
- if (ref.current) {
1911
- ref.current.focus();
1912
- } else {
1913
- if (retryCount < 30) {
1914
- setTimeout(() => {
1915
- retryCount = retryCount + 1;
1916
- retryFocus(ref);
1917
- }, 100);
1918
- }
1919
- }
1920
- };
1921
- const CodeBlock = ({
1922
- attributes,
1923
- editor,
1924
- element,
1925
- language: restrictLanguage,
1926
- ...props
1927
- }) => {
1928
- const [navigateAway, setNavigateAway] = React__default.useState(null);
1929
- const monaco = useMonaco();
1930
- const monacoEditorRef = React__default.useRef(null);
1931
- const selected = useSelected();
1932
- const [height, setHeight] = React__default.useState(28);
1933
- React__default.useEffect(() => {
1934
- if (selected && isCollapsed(editor.selection)) {
1935
- retryFocus(monacoEditorRef);
2443
+ TableCellElement.displayName = "TableCellElement";
2444
+ const TableCellHeaderElement = withProps(TableCellElement, {
2445
+ isHeader: true
2446
+ });
2447
+ const buttonVariants$1 = cva(
2448
+ "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",
2449
+ {
2450
+ defaultVariants: {
2451
+ size: "default",
2452
+ variant: "default"
2453
+ },
2454
+ variants: {
2455
+ isMenu: {
2456
+ true: "h-auto w-full cursor-pointer justify-start"
2457
+ },
2458
+ size: {
2459
+ default: "h-10 px-4 py-2",
2460
+ icon: "size-10",
2461
+ lg: "h-11 rounded-md px-8",
2462
+ none: "",
2463
+ sm: "h-9 rounded-md px-3",
2464
+ sms: "size-9 rounded-md px-0",
2465
+ xs: "h-8 rounded-md px-3"
2466
+ },
2467
+ variant: {
2468
+ default: "bg-primary text-primary-foreground hover:bg-primary/90",
2469
+ destructive: "bg-destructive text-destructive-foreground hover:bg-destructive/90",
2470
+ ghost: "hover:bg-accent hover:text-accent-foreground",
2471
+ inlineLink: "text-base text-primary underline underline-offset-4",
2472
+ link: "text-primary underline-offset-4 hover:underline",
2473
+ outline: "border border-input bg-background hover:bg-accent hover:text-accent-foreground",
2474
+ secondary: "bg-secondary text-secondary-foreground hover:bg-secondary/80"
2475
+ }
1936
2476
  }
1937
- }, [selected, monacoEditorRef.current]);
1938
- const value = element.value || "";
1939
- if (typeof value !== "string") {
1940
- throw new Error("Element must be of type string for code block");
1941
2477
  }
1942
- const language = restrictLanguage || element.lang;
1943
- const id = React__default.useMemo(() => uuid(), []);
1944
- const languages = React__default.useMemo(() => {
1945
- const defaultLangSet = { "": "plain text" };
1946
- if (!monaco)
1947
- return defaultLangSet;
1948
- return monaco.languages.getLanguages().reduce((ac, cv) => {
1949
- if (cv.id === "plaintext")
1950
- return ac;
1951
- return { ...ac, [cv.id]: cv.id };
1952
- }, defaultLangSet);
1953
- }, [monaco]);
1954
- React__default.useEffect(() => {
1955
- if (monaco) {
1956
- monaco.languages.typescript.typescriptDefaults.setEagerModelSync(true);
1957
- monaco.languages.typescript.typescriptDefaults.setDiagnosticsOptions({
1958
- // disable errors
1959
- noSemanticValidation: true,
1960
- noSyntaxValidation: true
1961
- });
2478
+ );
2479
+ const Button$2 = withRef(({ asChild = false, className, isMenu, size, variant, ...props }, ref) => {
2480
+ const Comp = asChild ? Slot : "button";
2481
+ return /* @__PURE__ */ React.createElement(
2482
+ Comp,
2483
+ {
2484
+ className: cn$1(buttonVariants$1({ className, isMenu, size, variant })),
2485
+ ref,
2486
+ ...props
1962
2487
  }
1963
- }, [monaco]);
1964
- const items2 = Object.entries(languages).map(([key, label]) => ({
1965
- key,
1966
- label,
1967
- render: (item) => item.label
1968
- }));
1969
- const currentItem = React__default.useMemo(() => {
1970
- return items2.find((item) => item.key === language) ?? {
1971
- key: "",
1972
- label: "Plain Text"
1973
- };
1974
- }, [items2, language]);
1975
- React__default.useEffect(() => {
1976
- if (navigateAway) {
1977
- setNavigateAway(null);
1978
- switch (navigateAway) {
1979
- case "remove":
1980
- {
1981
- focusEditor(editor);
1982
- setNodes(
1983
- editor,
1984
- {
1985
- type: "p",
1986
- children: [{ text: "" }],
1987
- lang: void 0,
1988
- value: void 0
1989
- },
1990
- {
1991
- match: (n) => {
1992
- if (isElement(n) && n.type === element.type) {
1993
- return true;
1994
- }
1995
- }
1996
- }
1997
- );
1998
- }
1999
- break;
2000
- case "insertNext":
2001
- {
2002
- insertNodes(
2003
- editor,
2004
- [
2005
- {
2006
- type: ELEMENT_DEFAULT,
2007
- children: [{ text: "" }],
2008
- lang: void 0,
2009
- value: void 0
2010
- }
2011
- ],
2012
- { select: true }
2013
- );
2014
- focusEditor(editor);
2015
- }
2016
- break;
2017
- case "up":
2018
- {
2019
- const path = findNodePath(editor, element);
2020
- if (!path) {
2021
- return;
2022
- }
2023
- const previousNodePath = getPointBefore(editor, path);
2024
- if (!previousNodePath) {
2025
- focusEditor(editor);
2026
- insertNodes(
2027
- editor,
2028
- [
2029
- {
2030
- type: ELEMENT_DEFAULT,
2031
- children: [{ text: "" }],
2032
- lang: void 0,
2033
- value: void 0
2034
- }
2035
- ],
2036
- // Insert a new node at the current path, resulting in the code_block
2037
- // moving down one block
2038
- { at: path, select: true }
2039
- );
2040
- return;
2041
- }
2042
- focusEditor(editor, previousNodePath);
2043
- }
2044
- break;
2045
- case "down": {
2046
- const path = findNodePath(editor, element);
2047
- if (!path) {
2048
- return;
2049
- }
2050
- const nextNodePath = getPointAfter(editor, path);
2051
- if (!nextNodePath) {
2052
- insertNodes(
2053
- editor,
2054
- [
2055
- {
2056
- type: ELEMENT_DEFAULT,
2057
- children: [{ text: "" }],
2058
- lang: void 0,
2059
- value: void 0
2060
- }
2061
- ],
2062
- { select: true }
2063
- );
2064
- focusEditor(editor);
2065
- } else {
2066
- focusEditor(editor, nextNodePath);
2067
- }
2068
- break;
2069
- }
2488
+ );
2489
+ });
2490
+ const DropdownMenu = DropdownMenuPrimitive.Root;
2491
+ const DropdownMenuTrigger = DropdownMenuPrimitive.Trigger;
2492
+ const DropdownMenuPortal = DropdownMenuPrimitive.Portal;
2493
+ const DropdownMenuSub = DropdownMenuPrimitive.Sub;
2494
+ const DropdownMenuRadioGroup = DropdownMenuPrimitive.RadioGroup;
2495
+ const DropdownMenuSubTrigger = withRef(({ children, className, inset, ...props }, ref) => /* @__PURE__ */ React__default.createElement(
2496
+ DropdownMenuPrimitive.SubTrigger,
2497
+ {
2498
+ className: cn$1(
2499
+ "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",
2500
+ "data-[disabled]:pointer-events-none data-[disabled]:opacity-50",
2501
+ inset && "pl-8",
2502
+ className
2503
+ ),
2504
+ ref,
2505
+ ...props
2506
+ },
2507
+ children,
2508
+ /* @__PURE__ */ React__default.createElement(Icons.chevronRight, { className: "ml-auto size-4" })
2509
+ ));
2510
+ const DropdownMenuSubContent = withCn(
2511
+ DropdownMenuPrimitive.SubContent,
2512
+ "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"
2513
+ );
2514
+ const DropdownMenuContentVariants = withProps(DropdownMenuPrimitive.Content, {
2515
+ className: cn$1(
2516
+ "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"
2517
+ ),
2518
+ sideOffset: 4
2519
+ });
2520
+ const DropdownMenuContent = withRef(({ ...props }, ref) => /* @__PURE__ */ React__default.createElement(DropdownMenuPrimitive.Portal, null, /* @__PURE__ */ React__default.createElement(DropdownMenuContentVariants, { ref, ...props })));
2521
+ const menuItemVariants = cva(
2522
+ cn$1(
2523
+ "relative flex h-9 cursor-pointer select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none transition-colors",
2524
+ "focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50"
2525
+ ),
2526
+ {
2527
+ variants: {
2528
+ inset: {
2529
+ true: "pl-8"
2070
2530
  }
2071
2531
  }
2072
- }, [navigateAway]);
2073
- function handleEditorDidMount(monacoEditor, monaco2) {
2074
- monacoEditorRef.current = monacoEditor;
2075
- monacoEditor.onDidContentSizeChange(() => {
2076
- setHeight(monacoEditor.getContentHeight());
2077
- monacoEditor.layout();
2078
- });
2079
- monacoEditor.addCommand(monaco2.KeyMod.Shift | monaco2.KeyCode.Enter, () => {
2080
- if (monacoEditor.hasTextFocus()) {
2081
- setNavigateAway("insertNext");
2082
- }
2083
- });
2084
- monacoEditor.onKeyDown((l) => {
2085
- if (l.code === "ArrowUp") {
2086
- const selection = monacoEditor.getSelection();
2087
- if (selection.endLineNumber === 1 && selection.startLineNumber === 1) {
2088
- setNavigateAway("up");
2089
- }
2090
- }
2091
- if (l.code === "ArrowDown") {
2092
- const selection = monacoEditor.getSelection();
2093
- const totalLines = monacoEditor.getModel().getLineCount();
2094
- if (selection.endLineNumber === totalLines && selection.startLineNumber === totalLines) {
2095
- setNavigateAway("down");
2096
- }
2097
- }
2098
- if (l.code === "Backspace") {
2099
- const selection = monacoEditor.getSelection();
2100
- if (selection.endColumn === 1 && selection.endLineNumber === 1 && selection.positionColumn === 1 && selection.positionLineNumber === 1 && selection.selectionStartColumn === 1 && selection.selectionStartLineNumber === 1 && selection.startColumn === 1 && selection.startLineNumber === 1) {
2101
- setNavigateAway("remove");
2102
- }
2532
+ }
2533
+ );
2534
+ const DropdownMenuItem = withVariants(
2535
+ DropdownMenuPrimitive.Item,
2536
+ menuItemVariants,
2537
+ ["inset"]
2538
+ );
2539
+ const DropdownMenuCheckboxItem = withRef(({ children, className, ...props }, ref) => /* @__PURE__ */ React__default.createElement(
2540
+ DropdownMenuPrimitive.CheckboxItem,
2541
+ {
2542
+ className: cn$1(
2543
+ "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",
2544
+ "cursor-pointer",
2545
+ className
2546
+ ),
2547
+ ref,
2548
+ ...props
2549
+ },
2550
+ /* @__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" }))),
2551
+ children
2552
+ ));
2553
+ const DropdownMenuRadioItem = withRef(({ children, className, hideIcon, ...props }, ref) => /* @__PURE__ */ React__default.createElement(
2554
+ DropdownMenuPrimitive.RadioItem,
2555
+ {
2556
+ className: cn$1(
2557
+ "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",
2558
+ "h-9 cursor-pointer px-2 data-[state=checked]:bg-accent data-[state=checked]:text-accent-foreground",
2559
+ className
2560
+ ),
2561
+ ref,
2562
+ ...props
2563
+ },
2564
+ !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" }))),
2565
+ children
2566
+ ));
2567
+ const dropdownMenuLabelVariants = cva(
2568
+ cn$1("select-none px-2 py-1.5 text-sm font-semibold"),
2569
+ {
2570
+ variants: {
2571
+ inset: {
2572
+ true: "pl-8"
2103
2573
  }
2104
- });
2574
+ }
2575
+ }
2576
+ );
2577
+ const DropdownMenuLabel = withVariants(
2578
+ DropdownMenuPrimitive.Label,
2579
+ dropdownMenuLabelVariants,
2580
+ ["inset"]
2581
+ );
2582
+ const DropdownMenuSeparator = withCn(
2583
+ DropdownMenuPrimitive.Separator,
2584
+ "-mx-1 my-1 h-px bg-muted"
2585
+ );
2586
+ withCn(
2587
+ createPrimitiveElement("span"),
2588
+ "ml-auto text-xs tracking-widest opacity-60"
2589
+ );
2590
+ const useOpenState = () => {
2591
+ const [open2, setOpen] = useState(false);
2592
+ const onOpenChange = useCallback(
2593
+ (_value = !open2) => {
2594
+ setOpen(_value);
2595
+ },
2596
+ [open2]
2597
+ );
2598
+ return {
2599
+ onOpenChange,
2600
+ open: open2
2601
+ };
2602
+ };
2603
+ const Popover$2 = PopoverPrimitive.Root;
2604
+ const popoverVariants = cva(
2605
+ "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"
2606
+ );
2607
+ const PopoverContent$1 = withRef(
2608
+ ({ align = "center", className, sideOffset = 4, style, ...props }, ref) => /* @__PURE__ */ React.createElement(PopoverPrimitive.Portal, null, /* @__PURE__ */ React.createElement(
2609
+ PopoverPrimitive.Content,
2610
+ {
2611
+ align,
2612
+ className: cn$1(popoverVariants(), className),
2613
+ ref,
2614
+ sideOffset,
2615
+ style: { zIndex: 1e3, ...style },
2616
+ ...props
2617
+ }
2618
+ ))
2619
+ );
2620
+ const separatorVariants = cva("shrink-0 bg-border", {
2621
+ defaultVariants: {
2622
+ orientation: "horizontal"
2623
+ },
2624
+ variants: {
2625
+ orientation: {
2626
+ horizontal: "h-px w-full",
2627
+ vertical: "h-full w-px"
2628
+ }
2105
2629
  }
2630
+ });
2631
+ const Separator = withVariants(
2632
+ withProps(SeparatorPrimitive.Root, {
2633
+ decorative: true,
2634
+ orientation: "horizontal"
2635
+ }),
2636
+ separatorVariants
2637
+ );
2638
+ const TableBordersDropdownMenuContent = withRef((props, ref) => {
2639
+ const {
2640
+ getOnSelectTableBorder,
2641
+ hasBottomBorder,
2642
+ hasLeftBorder,
2643
+ hasNoBorders,
2644
+ hasOuterBorders,
2645
+ hasRightBorder,
2646
+ hasTopBorder
2647
+ } = useTableBordersDropdownMenuContentState();
2106
2648
  return /* @__PURE__ */ React__default.createElement(
2107
- "div",
2649
+ DropdownMenuContent,
2108
2650
  {
2109
- ...attributes,
2110
- className: "relative mb-2 mt-0.5 rounded-lg shadow-md p-2 border-gray-200 border"
2651
+ align: "start",
2652
+ className: cn$1("min-w-[220px]"),
2653
+ ref,
2654
+ side: "right",
2655
+ sideOffset: 0,
2656
+ ...props
2111
2657
  },
2112
- /* @__PURE__ */ React__default.createElement("style", null, `.monaco-editor .editor-widget {
2113
- display: none !important;
2114
- visibility: hidden !important;
2115
- }`),
2116
- props.children,
2117
- /* @__PURE__ */ React__default.createElement("div", { contentEditable: false }, !restrictLanguage && /* @__PURE__ */ React__default.createElement("div", { className: "flex justify-between pb-2" }, /* @__PURE__ */ React__default.createElement("div", null), /* @__PURE__ */ React__default.createElement(
2118
- Autocomplete,
2658
+ /* @__PURE__ */ React__default.createElement(
2659
+ DropdownMenuCheckboxItem,
2119
2660
  {
2120
- items: items2,
2121
- value: currentItem,
2122
- defaultQuery: "plaintext",
2123
- onChange: (item) => setNodes(editor, { lang: item.key })
2124
- }
2125
- )), /* @__PURE__ */ React__default.createElement("div", { style: { height: `${height}px` } }, /* @__PURE__ */ React__default.createElement(
2126
- MonacoEditor,
2661
+ checked: hasBottomBorder,
2662
+ onCheckedChange: getOnSelectTableBorder("bottom")
2663
+ },
2664
+ /* @__PURE__ */ React__default.createElement(Icons.borderBottom, { className: iconVariants({ size: "sm" }) }),
2665
+ /* @__PURE__ */ React__default.createElement("div", null, "Bottom Border")
2666
+ ),
2667
+ /* @__PURE__ */ React__default.createElement(
2668
+ DropdownMenuCheckboxItem,
2127
2669
  {
2128
- path: id,
2129
- onMount: handleEditorDidMount,
2130
- options: {
2131
- scrollBeyondLastLine: false,
2132
- // automaticLayout: true,
2133
- tabSize: 2,
2134
- disableLayerHinting: true,
2135
- accessibilitySupport: "off",
2136
- codeLens: false,
2137
- wordWrap: "on",
2138
- minimap: {
2139
- enabled: false
2140
- },
2141
- fontSize: 14,
2142
- lineHeight: 2,
2143
- formatOnPaste: true,
2144
- lineNumbers: "off",
2145
- formatOnType: true,
2146
- fixedOverflowWidgets: true,
2147
- // Takes too much horizontal space for iframe
2148
- folding: false,
2149
- renderLineHighlight: "none",
2150
- scrollbar: {
2151
- verticalScrollbarSize: 1,
2152
- horizontalScrollbarSize: 1,
2153
- // https://github.com/microsoft/monaco-editor/issues/2007#issuecomment-644425664
2154
- alwaysConsumeMouseWheel: false
2155
- }
2156
- },
2157
- language: String(language),
2158
- value: String(element.value),
2159
- onChange: (value2) => {
2160
- setNodes(editor, { value: value2, lang: language });
2161
- }
2162
- }
2163
- )))
2670
+ checked: hasTopBorder,
2671
+ onCheckedChange: getOnSelectTableBorder("top")
2672
+ },
2673
+ /* @__PURE__ */ React__default.createElement(Icons.borderTop, { className: iconVariants({ size: "sm" }) }),
2674
+ /* @__PURE__ */ React__default.createElement("div", null, "Top Border")
2675
+ ),
2676
+ /* @__PURE__ */ React__default.createElement(
2677
+ DropdownMenuCheckboxItem,
2678
+ {
2679
+ checked: hasLeftBorder,
2680
+ onCheckedChange: getOnSelectTableBorder("left")
2681
+ },
2682
+ /* @__PURE__ */ React__default.createElement(Icons.borderLeft, { className: iconVariants({ size: "sm" }) }),
2683
+ /* @__PURE__ */ React__default.createElement("div", null, "Left Border")
2684
+ ),
2685
+ /* @__PURE__ */ React__default.createElement(
2686
+ DropdownMenuCheckboxItem,
2687
+ {
2688
+ checked: hasRightBorder,
2689
+ onCheckedChange: getOnSelectTableBorder("right")
2690
+ },
2691
+ /* @__PURE__ */ React__default.createElement(Icons.borderRight, { className: iconVariants({ size: "sm" }) }),
2692
+ /* @__PURE__ */ React__default.createElement("div", null, "Right Border")
2693
+ ),
2694
+ /* @__PURE__ */ React__default.createElement(Separator, null),
2695
+ /* @__PURE__ */ React__default.createElement(
2696
+ DropdownMenuCheckboxItem,
2697
+ {
2698
+ checked: hasNoBorders,
2699
+ onCheckedChange: getOnSelectTableBorder("none")
2700
+ },
2701
+ /* @__PURE__ */ React__default.createElement(Icons.borderNone, { className: iconVariants({ size: "sm" }) }),
2702
+ /* @__PURE__ */ React__default.createElement("div", null, "No Border")
2703
+ ),
2704
+ /* @__PURE__ */ React__default.createElement(
2705
+ DropdownMenuCheckboxItem,
2706
+ {
2707
+ checked: hasOuterBorders,
2708
+ onCheckedChange: getOnSelectTableBorder("outer")
2709
+ },
2710
+ /* @__PURE__ */ React__default.createElement(Icons.borderAll, { className: iconVariants({ size: "sm" }) }),
2711
+ /* @__PURE__ */ React__default.createElement("div", null, "Outside Borders")
2712
+ )
2164
2713
  );
2165
- };
2166
- const CodeBlockElement = withRef(
2167
- ({ className, ...props }, ref) => {
2168
- const { element } = props;
2169
- const state = useCodeBlockElementState({ element });
2170
- return /* @__PURE__ */ React__default.createElement(
2171
- PlateElement,
2714
+ });
2715
+ const TableFloatingToolbar = withRef(
2716
+ ({ children, ...props }, ref) => {
2717
+ const element = useElement();
2718
+ const { props: buttonProps } = useRemoveNodeButton({ element });
2719
+ const selectionCollapsed = useEditorSelector(
2720
+ (editor2) => !isSelectionExpanded(editor2),
2721
+ []
2722
+ );
2723
+ const readOnly = useReadOnly();
2724
+ const selected = useSelected();
2725
+ const editor = useEditorRef();
2726
+ const collapsed = !readOnly && selected && selectionCollapsed;
2727
+ const open2 = !readOnly && selected;
2728
+ const { canMerge, canUnmerge } = useTableMergeState();
2729
+ const mergeContent = canMerge && /* @__PURE__ */ React__default.createElement(
2730
+ Button$2,
2172
2731
  {
2173
- className: cn$1("relative py-1", state.className, className),
2732
+ contentEditable: false,
2733
+ isMenu: true,
2734
+ onClick: () => mergeTableCells(editor),
2735
+ variant: "ghost"
2736
+ },
2737
+ /* @__PURE__ */ React__default.createElement(Icons.combine, { className: "mr-2 size-4" }),
2738
+ "Merge"
2739
+ );
2740
+ const unmergeButton = canUnmerge && /* @__PURE__ */ React__default.createElement(
2741
+ Button$2,
2742
+ {
2743
+ contentEditable: false,
2744
+ isMenu: true,
2745
+ onClick: () => unmergeTableCells(editor),
2746
+ variant: "ghost"
2747
+ },
2748
+ /* @__PURE__ */ React__default.createElement(Icons.ungroup, { className: "mr-2 size-4" }),
2749
+ "Unmerge"
2750
+ );
2751
+ 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"));
2752
+ 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(
2753
+ PopoverContent$1,
2754
+ {
2755
+ className: cn$1(
2756
+ popoverVariants(),
2757
+ "flex w-[220px] flex-col gap-1 p-1"
2758
+ ),
2759
+ onOpenAutoFocus: (e) => e.preventDefault(),
2174
2760
  ref,
2175
2761
  ...props
2176
2762
  },
2177
- /* @__PURE__ */ React__default.createElement(CodeBlock, { ...props })
2178
- );
2763
+ unmergeButton,
2764
+ mergeContent,
2765
+ bordersContent
2766
+ ));
2179
2767
  }
2180
2768
  );
2769
+ const TableElement = withHOC(
2770
+ TableProvider,
2771
+ withRef(({ children, className, ...props }, ref) => {
2772
+ const { colSizes, isSelectingCell, marginLeft, minColumnWidth } = useTableElementState();
2773
+ const { colGroupProps, props: tableProps } = useTableElement();
2774
+ return /* @__PURE__ */ React__default.createElement(TableFloatingToolbar, null, /* @__PURE__ */ React__default.createElement("div", { style: { paddingLeft: marginLeft } }, /* @__PURE__ */ React__default.createElement(
2775
+ PlateElement,
2776
+ {
2777
+ asChild: true,
2778
+ className: cn$1(
2779
+ "my-4 ml-px mr-0 table h-px w-full table-fixed border-collapse",
2780
+ isSelectingCell && "[&_*::selection]:bg-none",
2781
+ className
2782
+ ),
2783
+ ref,
2784
+ ...tableProps,
2785
+ ...props
2786
+ },
2787
+ /* @__PURE__ */ React__default.createElement("table", null, /* @__PURE__ */ React__default.createElement("colgroup", { ...colGroupProps }, colSizes.map((width, index) => /* @__PURE__ */ React__default.createElement(
2788
+ "col",
2789
+ {
2790
+ key: index,
2791
+ style: {
2792
+ minWidth: minColumnWidth,
2793
+ width: width || void 0
2794
+ }
2795
+ }
2796
+ ))), /* @__PURE__ */ React__default.createElement("tbody", { className: "min-w-full" }, children))
2797
+ )));
2798
+ })
2799
+ );
2800
+ const TableRowElement = withRef(({ children, hideBorder, ...props }, ref) => {
2801
+ return /* @__PURE__ */ React__default.createElement(
2802
+ PlateElement,
2803
+ {
2804
+ asChild: true,
2805
+ className: cn$1("h-full", hideBorder && "border-none"),
2806
+ ref,
2807
+ ...props
2808
+ },
2809
+ /* @__PURE__ */ React__default.createElement("tr", null, children)
2810
+ );
2811
+ });
2181
2812
  const blockClasses = "mt-0.5";
2182
2813
  const headerClasses = "font-normal";
2183
2814
  const Components = () => {
@@ -2283,6 +2914,7 @@ const Components = () => {
2283
2914
  }
2284
2915
  )
2285
2916
  ),
2917
+ [ELEMENT_MERMAID]: MermaidElement,
2286
2918
  [ELEMENT_BLOCKQUOTE]: BlockquoteElement,
2287
2919
  [ELEMENT_CODE_BLOCK]: CodeBlockElement,
2288
2920
  [ELEMENT_CODE_LINE]: CodeLineElement,
@@ -2338,7 +2970,7 @@ const Components = () => {
2338
2970
  ),
2339
2971
  [MARK_CODE]: CodeLeaf,
2340
2972
  [MARK_UNDERLINE]: withProps(PlateLeaf, { as: "u" }),
2341
- [MARK_STRIKETHROUGH]: withProps(PlateLeaf, { as: "s" }),
2973
+ [MARK_STRIKETHROUGH]: ({ editor, leaf, text, ...props }) => /* @__PURE__ */ React__default.createElement("s", { ...props.attributes, ...props }),
2342
2974
  [MARK_ITALIC]: withProps(PlateLeaf, { as: "em" }),
2343
2975
  [MARK_BOLD]: ({ editor, leaf, text, ...props }) => /* @__PURE__ */ React__default.createElement("strong", { ...props.attributes, ...props }),
2344
2976
  [ELEMENT_HR]: ({
@@ -2363,7 +2995,11 @@ const Components = () => {
2363
2995
  children,
2364
2996
  selected && /* @__PURE__ */ React__default.createElement("span", { className: "absolute h-4 -top-2 inset-0 ring-2 ring-blue-100 ring-inset rounded-md z-10 pointer-events-none" })
2365
2997
  );
2366
- }
2998
+ },
2999
+ [ELEMENT_TABLE]: TableElement,
3000
+ [ELEMENT_TR]: TableRowElement,
3001
+ [ELEMENT_TD]: TableCellElement,
3002
+ [ELEMENT_TH]: TableCellHeaderElement
2367
3003
  };
2368
3004
  };
2369
3005
  const createCodeBlockPlugin = createPluginFactory({
@@ -2773,7 +3409,9 @@ class Form {
2773
3409
  {
2774
3410
  type: "string",
2775
3411
  label: "Caption",
2776
- name: [templateName.replace(/\.props$/, ""), "caption"].join("."),
3412
+ name: [templateName.replace(/\.props$/, ""), "caption"].join(
3413
+ "."
3414
+ ),
2777
3415
  component: "text"
2778
3416
  }
2779
3417
  ]
@@ -3041,7 +3679,7 @@ function TinaForm({ form, children }) {
3041
3679
  }));
3042
3680
  }
3043
3681
  function TinaField({
3044
- Component: Component2,
3682
+ Component,
3045
3683
  children,
3046
3684
  ...fieldProps
3047
3685
  }) {
@@ -3049,7 +3687,7 @@ function TinaField({
3049
3687
  if (!isEditing)
3050
3688
  return children || null;
3051
3689
  return /* @__PURE__ */ React.createElement(Field, { ...fieldProps }, ({ input, meta }) => {
3052
- return /* @__PURE__ */ React.createElement(Component2, { input, meta, ...fieldProps });
3690
+ return /* @__PURE__ */ React.createElement(Component, { input, meta, ...fieldProps });
3053
3691
  });
3054
3692
  }
3055
3693
  TinaField.propTypes = {
@@ -3091,7 +3729,7 @@ const Button$1 = ({
3091
3729
  };
3092
3730
  const sizeClasses = {
3093
3731
  small: `text-xs h-8 px-3`,
3094
- medium: `text-sm h-10 px-4`,
3732
+ medium: `text-sm h-10 px-8`,
3095
3733
  custom: ``
3096
3734
  };
3097
3735
  return /* @__PURE__ */ React.createElement(
@@ -3219,7 +3857,7 @@ var _excluded = ["attr", "size", "title"];
3219
3857
  function _objectWithoutProperties(source, excluded) {
3220
3858
  if (source == null)
3221
3859
  return {};
3222
- var target = _objectWithoutPropertiesLoose$1(source, excluded);
3860
+ var target = _objectWithoutPropertiesLoose(source, excluded);
3223
3861
  var key, i;
3224
3862
  if (Object.getOwnPropertySymbols) {
3225
3863
  var sourceSymbolKeys = Object.getOwnPropertySymbols(source);
@@ -3234,7 +3872,7 @@ function _objectWithoutProperties(source, excluded) {
3234
3872
  }
3235
3873
  return target;
3236
3874
  }
3237
- function _objectWithoutPropertiesLoose$1(source, excluded) {
3875
+ function _objectWithoutPropertiesLoose(source, excluded) {
3238
3876
  if (source == null)
3239
3877
  return {};
3240
3878
  var target = {};
@@ -4324,7 +4962,28 @@ const NumberInput = ({
4324
4962
  onChange,
4325
4963
  value,
4326
4964
  step
4327
- }) => /* @__PURE__ */ React.createElement(Input, { type: "number", step, value, onChange });
4965
+ }) => /* @__PURE__ */ React.createElement(
4966
+ Input,
4967
+ {
4968
+ type: "number",
4969
+ step,
4970
+ value,
4971
+ onChange: (event) => {
4972
+ const inputValue = event.target.value;
4973
+ const newValue = inputValue === "" ? void 0 : inputValue;
4974
+ if (onChange) {
4975
+ const syntheticEvent = {
4976
+ ...event,
4977
+ target: {
4978
+ ...event.target,
4979
+ value: newValue
4980
+ }
4981
+ };
4982
+ onChange(syntheticEvent);
4983
+ }
4984
+ }
4985
+ }
4986
+ );
4328
4987
  function useCMS() {
4329
4988
  return useCMS$1();
4330
4989
  }
@@ -4433,7 +5092,7 @@ const ImageLoadingIndicator = () => /* @__PURE__ */ React.createElement("div", {
4433
5092
  function cn(...inputs) {
4434
5093
  return twMerge(clsx(inputs));
4435
5094
  }
4436
- const buttonVariants$1 = cva(
5095
+ const buttonVariants = cva(
4437
5096
  "inline-flex items-center justify-center whitespace-nowrap rounded-md text-sm font-medium ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50",
4438
5097
  {
4439
5098
  variants: {
@@ -4459,7 +5118,7 @@ const Button = React.forwardRef(
4459
5118
  return /* @__PURE__ */ React.createElement(
4460
5119
  Comp,
4461
5120
  {
4462
- className: cn(buttonVariants$1({ variant, size, className })),
5121
+ className: cn(buttonVariants({ variant, size, className })),
4463
5122
  ref,
4464
5123
  ...props
4465
5124
  }
@@ -4565,7 +5224,7 @@ const PopoverContent = React.forwardRef(({ className, align = "center", sideOffs
4565
5224
  side: "bottom",
4566
5225
  className: cn(
4567
5226
  "rounded-md border bg-white 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",
4568
- "max-h-[30vh] max-w-[30vh] overflow-y-auto",
5227
+ "max-h-[30vh] max-w-[30vw] overflow-y-auto",
4569
5228
  className
4570
5229
  ),
4571
5230
  ...props
@@ -4657,11 +5316,7 @@ const getFilename = (optionSets, value) => {
4657
5316
  const node = nodes.find((node2) => node2.id === value);
4658
5317
  return node ? node._internalSys.filename : null;
4659
5318
  };
4660
- const ComboboxDemo = ({
4661
- cms,
4662
- input,
4663
- field
4664
- }) => {
5319
+ const Combobox = ({ cms, input, field }) => {
4665
5320
  const [open2, setOpen] = React.useState(false);
4666
5321
  const [value, setValue] = React.useState(input.value);
4667
5322
  const [displayText, setDisplayText] = React.useState(null);
@@ -4685,17 +5340,17 @@ const ComboboxDemo = ({
4685
5340
  if (loading === true) {
4686
5341
  return /* @__PURE__ */ React.createElement(LoadingDots, { color: "var(--tina-color-primary)" });
4687
5342
  }
4688
- return /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(Popover, { open: open2, onOpenChange: setOpen }, /* @__PURE__ */ React.createElement(PopoverTrigger, { asChild: true }, /* @__PURE__ */ React.createElement(
5343
+ return /* @__PURE__ */ React.createElement(Popover, { open: open2, onOpenChange: setOpen }, /* @__PURE__ */ React.createElement(PopoverTrigger, { asChild: true }, /* @__PURE__ */ React.createElement(
4689
5344
  Button,
4690
5345
  {
4691
5346
  variant: "outline",
4692
5347
  role: "combobox",
4693
5348
  "aria-expanded": open2,
4694
- className: "w-52 justify-between"
5349
+ className: "w-full justify-between"
4695
5350
  },
4696
5351
  /* @__PURE__ */ React.createElement("p", { className: "truncate" }, displayText ?? "Choose an option..."),
4697
5352
  open2 ? /* @__PURE__ */ React.createElement(IoMdArrowDropup, { size: 20 }) : /* @__PURE__ */ React.createElement(IoMdArrowDropdown, { size: 20 })
4698
- )), /* @__PURE__ */ React.createElement(PopoverContent, { className: "p-0 relative" }, /* @__PURE__ */ React.createElement(
5353
+ )), /* @__PURE__ */ React.createElement(PopoverContent, { className: "p-0 relative min-w-[var(--radix-popover-trigger-width)]" }, /* @__PURE__ */ React.createElement(
4699
5354
  Command,
4700
5355
  {
4701
5356
  shouldFilter: !field.experimental___filter,
@@ -4719,32 +5374,25 @@ const ComboboxDemo = ({
4719
5374
  }
4720
5375
  ),
4721
5376
  /* @__PURE__ */ React.createElement(CommandEmpty, null, "No reference found"),
4722
- /* @__PURE__ */ React.createElement(CommandList, null, filteredOptionsList.length > 0 && (filteredOptionsList == null ? void 0 : filteredOptionsList.map(({ collection, edges }) => /* @__PURE__ */ React.createElement(
4723
- CommandGroup,
4724
- {
4725
- key: `${collection}-group`,
4726
- heading: collection
4727
- },
4728
- /* @__PURE__ */ React.createElement(CommandList, null, edges == null ? void 0 : edges.map(({ node }) => {
4729
- const { id, _values } = node;
4730
- return /* @__PURE__ */ React.createElement(
4731
- OptionComponent,
4732
- {
4733
- id,
4734
- key: id,
4735
- value,
4736
- field,
4737
- _values,
4738
- node,
4739
- onSelect: (currentValue) => {
4740
- setValue(currentValue);
4741
- setOpen(false);
4742
- }
5377
+ /* @__PURE__ */ React.createElement(CommandList, null, filteredOptionsList.length > 0 && (filteredOptionsList == null ? void 0 : filteredOptionsList.map(({ collection, edges }) => /* @__PURE__ */ React.createElement(CommandGroup, { key: `${collection}-group`, heading: collection }, /* @__PURE__ */ React.createElement(CommandList, null, edges == null ? void 0 : edges.map(({ node }) => {
5378
+ const { id, _values } = node;
5379
+ return /* @__PURE__ */ React.createElement(
5380
+ OptionComponent,
5381
+ {
5382
+ id,
5383
+ key: id,
5384
+ value,
5385
+ field,
5386
+ _values,
5387
+ node,
5388
+ onSelect: (currentValue) => {
5389
+ setValue(currentValue);
5390
+ setOpen(false);
4743
5391
  }
4744
- );
4745
- }))
4746
- ))))
4747
- ))));
5392
+ }
5393
+ );
5394
+ }))))))
5395
+ )));
4748
5396
  };
4749
5397
  const useGetNode = (cms, id) => {
4750
5398
  const [document2, setDocument] = React.useState(
@@ -4817,7 +5465,7 @@ const ReferenceLink = ({ cms, input }) => {
4817
5465
  };
4818
5466
  const Reference = ({ input, field }) => {
4819
5467
  const cms = useCMS();
4820
- return /* @__PURE__ */ React.createElement("div", null, /* @__PURE__ */ React.createElement("div", { className: "relative group" }, /* @__PURE__ */ React.createElement(ComboboxDemo, { cms, input, field })), /* @__PURE__ */ React.createElement(ReferenceLink, { cms, input }));
5468
+ return /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement("div", { className: "relative group" }, /* @__PURE__ */ React.createElement(Combobox, { cms, input, field })), /* @__PURE__ */ React.createElement(ReferenceLink, { cms, input }));
4821
5469
  };
4822
5470
  const ButtonToggle = ({
4823
5471
  input,
@@ -5125,10 +5773,11 @@ const ItemDeleteButton = ({ onClick, disabled = false }) => {
5125
5773
  return /* @__PURE__ */ React__default.createElement(
5126
5774
  "button",
5127
5775
  {
5128
- className: `w-8 px-1 py-2.5 flex items-center justify-center hover:bg-gray-50 text-gray-200 hover:text-red-500 ${disabled && "pointer-events-none opacity-30 cursor-not-allowed"}`,
5776
+ type: "button",
5777
+ className: `w-8 px-1 py-2.5 flex items-center justify-center text-gray-200 hover:opacity-100 opacity-30 hover:bg-gray-50 ${disabled && "pointer-events-none opacity-30 cursor-not-allowed"}`,
5129
5778
  onClick
5130
5779
  },
5131
- /* @__PURE__ */ React__default.createElement(TrashIcon, { className: "fill-current transition-colors ease-out duration-100" })
5780
+ /* @__PURE__ */ React__default.createElement(TrashIcon, { className: "h-5 w-auto fill-current text-red-500 transition-colors duration-150 ease-out" })
5132
5781
  );
5133
5782
  };
5134
5783
  const DragHandle = ({ isDragging }) => {
@@ -5158,7 +5807,7 @@ const BlockSelector = ({
5158
5807
  return template.label ? template.label.toLowerCase().includes(filter.toLowerCase()) || name.toLowerCase().includes(filter.toLowerCase()) : name.toLowerCase().includes(filter.toLowerCase());
5159
5808
  });
5160
5809
  }, [filter]);
5161
- return /* @__PURE__ */ React.createElement(Popover$2, null, ({ open: open2 }) => /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(PopoverButton, { as: "span" }, /* @__PURE__ */ React.createElement(
5810
+ return /* @__PURE__ */ React.createElement(Popover$3, null, ({ open: open2 }) => /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(PopoverButton, { as: "span" }, /* @__PURE__ */ React.createElement(
5162
5811
  IconButton,
5163
5812
  {
5164
5813
  variant: open2 ? "secondary" : "primary",
@@ -5206,27 +5855,35 @@ const BlockSelector = ({
5206
5855
  ))))
5207
5856
  ))));
5208
5857
  };
5209
- const Group = wrapFieldWithError(({ tinaForm, field }) => {
5210
- const cms = useCMS$1();
5211
- React.useState(false);
5212
- return /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(
5213
- Header,
5214
- {
5215
- onClick: () => {
5216
- const state = tinaForm.finalForm.getState();
5217
- if (state.invalid === true) {
5218
- cms.alerts.error("Cannot navigate away from an invalid form.");
5219
- return;
5858
+ const Group = wrapFieldWithNoHeader(
5859
+ ({ tinaForm, field }) => {
5860
+ const cms = useCMS$1();
5861
+ return /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(
5862
+ Header,
5863
+ {
5864
+ onClick: () => {
5865
+ const state = tinaForm.finalForm.getState();
5866
+ if (state.invalid === true) {
5867
+ cms.alerts.error("Cannot navigate away from an invalid form.");
5868
+ return;
5869
+ }
5870
+ cms.dispatch({
5871
+ type: "forms:set-active-field-name",
5872
+ value: { formId: tinaForm.id, fieldName: field.name }
5873
+ });
5220
5874
  }
5221
- cms.dispatch({
5222
- type: "forms:set-active-field-name",
5223
- value: { formId: tinaForm.id, fieldName: field.name }
5224
- });
5225
- }
5226
- },
5227
- field.label || field.name
5228
- ));
5229
- });
5875
+ },
5876
+ field.label || field.name,
5877
+ field.description && /* @__PURE__ */ React.createElement(
5878
+ "span",
5879
+ {
5880
+ className: `block font-sans text-xs italic font-light text-gray-400 pt-0.5 whitespace-normal m-0`,
5881
+ dangerouslySetInnerHTML: { __html: field.description }
5882
+ }
5883
+ )
5884
+ ));
5885
+ }
5886
+ );
5230
5887
  const Header = ({ onClick, children }) => {
5231
5888
  return /* @__PURE__ */ React.createElement("div", { className: "pt-1 mb-5" }, /* @__PURE__ */ React.createElement(
5232
5889
  "button",
@@ -6568,244 +7225,65 @@ function pad(type, value) {
6568
7225
  str = "0" + str;
6569
7226
  return str;
6570
7227
  }
6571
- function _inheritsLoose(subClass, superClass) {
6572
- subClass.prototype = Object.create(superClass.prototype);
6573
- subClass.prototype.constructor = subClass;
6574
- _setPrototypeOf(subClass, superClass);
6575
- }
6576
- function _setPrototypeOf(o, p) {
6577
- _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf2(o2, p2) {
6578
- o2.__proto__ = p2;
6579
- return o2;
6580
- };
6581
- return _setPrototypeOf(o, p);
6582
- }
6583
- function _objectWithoutPropertiesLoose(source, excluded) {
6584
- if (source == null)
6585
- return {};
6586
- var target = {};
6587
- var sourceKeys = Object.keys(source);
6588
- var key, i;
6589
- for (i = 0; i < sourceKeys.length; i++) {
6590
- key = sourceKeys[i];
6591
- if (excluded.indexOf(key) >= 0)
6592
- continue;
6593
- target[key] = source[key];
6594
- }
6595
- return target;
6596
- }
6597
- function _assertThisInitialized(self) {
6598
- if (self === void 0) {
6599
- throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
6600
- }
6601
- return self;
6602
- }
6603
- function isNodeFound(current, componentNode, ignoreClass) {
6604
- if (current === componentNode) {
6605
- return true;
7228
+ var useClickAway$1 = {};
7229
+ var util = {};
7230
+ Object.defineProperty(util, "__esModule", { value: true });
7231
+ util.isNavigator = util.isBrowser = util.off = util.on = util.noop = void 0;
7232
+ var noop = function() {
7233
+ };
7234
+ util.noop = noop;
7235
+ function on(obj) {
7236
+ var args = [];
7237
+ for (var _i = 1; _i < arguments.length; _i++) {
7238
+ args[_i - 1] = arguments[_i];
6606
7239
  }
6607
- if (current.correspondingElement) {
6608
- return current.correspondingElement.classList.contains(ignoreClass);
7240
+ if (obj && obj.addEventListener) {
7241
+ obj.addEventListener.apply(obj, args);
6609
7242
  }
6610
- return current.classList.contains(ignoreClass);
6611
7243
  }
6612
- function findHighest(current, componentNode, ignoreClass) {
6613
- if (current === componentNode) {
6614
- return true;
7244
+ util.on = on;
7245
+ function off(obj) {
7246
+ var args = [];
7247
+ for (var _i = 1; _i < arguments.length; _i++) {
7248
+ args[_i - 1] = arguments[_i];
6615
7249
  }
6616
- while (current.parentNode || current.host) {
6617
- if (current.parentNode && isNodeFound(current, componentNode, ignoreClass)) {
6618
- return true;
6619
- }
6620
- current = current.parentNode || current.host;
7250
+ if (obj && obj.removeEventListener) {
7251
+ obj.removeEventListener.apply(obj, args);
6621
7252
  }
6622
- return current;
6623
- }
6624
- function clickedScrollbar(evt) {
6625
- return document.documentElement.clientWidth <= evt.clientX || document.documentElement.clientHeight <= evt.clientY;
6626
7253
  }
6627
- var testPassiveEventSupport = function testPassiveEventSupport2() {
6628
- if (typeof window === "undefined" || typeof window.addEventListener !== "function") {
6629
- return;
6630
- }
6631
- var passive = false;
6632
- var options = Object.defineProperty({}, "passive", {
6633
- get: function get2() {
6634
- passive = true;
6635
- }
6636
- });
6637
- var noop = function noop2() {
6638
- };
6639
- window.addEventListener("testPassiveEventSupport", noop, options);
6640
- window.removeEventListener("testPassiveEventSupport", noop, options);
6641
- return passive;
6642
- };
6643
- function autoInc(seed) {
6644
- if (seed === void 0) {
6645
- seed = 0;
6646
- }
6647
- return function() {
6648
- return ++seed;
6649
- };
6650
- }
6651
- var uid = autoInc();
6652
- var passiveEventSupport;
6653
- var handlersMap = {};
6654
- var enabledInstances = {};
6655
- var touchEvents = ["touchstart", "touchmove"];
6656
- var IGNORE_CLASS_NAME = "ignore-react-onclickoutside";
6657
- function getEventHandlerOptions(instance, eventName) {
6658
- var handlerOptions = {};
6659
- var isTouchEvent = touchEvents.indexOf(eventName) !== -1;
6660
- if (isTouchEvent && passiveEventSupport) {
6661
- handlerOptions.passive = !instance.props.preventDefault;
6662
- }
6663
- return handlerOptions;
6664
- }
6665
- function onClickOutsideHOC(WrappedComponent, config) {
6666
- var _class, _temp;
6667
- var componentName = WrappedComponent.displayName || WrappedComponent.name || "Component";
6668
- return _temp = _class = /* @__PURE__ */ function(_Component) {
6669
- _inheritsLoose(onClickOutside, _Component);
6670
- function onClickOutside(props) {
6671
- var _this;
6672
- _this = _Component.call(this, props) || this;
6673
- _this.__outsideClickHandler = function(event) {
6674
- if (typeof _this.__clickOutsideHandlerProp === "function") {
6675
- _this.__clickOutsideHandlerProp(event);
6676
- return;
6677
- }
6678
- var instance = _this.getInstance();
6679
- if (typeof instance.props.handleClickOutside === "function") {
6680
- instance.props.handleClickOutside(event);
6681
- return;
6682
- }
6683
- if (typeof instance.handleClickOutside === "function") {
6684
- instance.handleClickOutside(event);
6685
- return;
6686
- }
6687
- throw new Error("WrappedComponent: " + componentName + " lacks a handleClickOutside(event) function for processing outside click events.");
6688
- };
6689
- _this.__getComponentNode = function() {
6690
- var instance = _this.getInstance();
6691
- if (config && typeof config.setClickOutsideRef === "function") {
6692
- return config.setClickOutsideRef()(instance);
6693
- }
6694
- if (typeof instance.setClickOutsideRef === "function") {
6695
- return instance.setClickOutsideRef();
6696
- }
6697
- return findDOMNode(instance);
6698
- };
6699
- _this.enableOnClickOutside = function() {
6700
- if (typeof document === "undefined" || enabledInstances[_this._uid]) {
6701
- return;
6702
- }
6703
- if (typeof passiveEventSupport === "undefined") {
6704
- passiveEventSupport = testPassiveEventSupport();
6705
- }
6706
- enabledInstances[_this._uid] = true;
6707
- var events = _this.props.eventTypes;
6708
- if (!events.forEach) {
6709
- events = [events];
6710
- }
6711
- handlersMap[_this._uid] = function(event) {
6712
- if (_this.componentNode === null)
6713
- return;
6714
- if (_this.initTimeStamp > event.timeStamp)
6715
- return;
6716
- if (_this.props.preventDefault) {
6717
- event.preventDefault();
6718
- }
6719
- if (_this.props.stopPropagation) {
6720
- event.stopPropagation();
6721
- }
6722
- if (_this.props.excludeScrollbar && clickedScrollbar(event))
6723
- return;
6724
- var current = event.composed && event.composedPath && event.composedPath().shift() || event.target;
6725
- if (findHighest(current, _this.componentNode, _this.props.outsideClickIgnoreClass) !== document) {
6726
- return;
6727
- }
6728
- _this.__outsideClickHandler(event);
6729
- };
6730
- events.forEach(function(eventName) {
6731
- document.addEventListener(eventName, handlersMap[_this._uid], getEventHandlerOptions(_assertThisInitialized(_this), eventName));
6732
- });
6733
- };
6734
- _this.disableOnClickOutside = function() {
6735
- delete enabledInstances[_this._uid];
6736
- var fn = handlersMap[_this._uid];
6737
- if (fn && typeof document !== "undefined") {
6738
- var events = _this.props.eventTypes;
6739
- if (!events.forEach) {
6740
- events = [events];
6741
- }
6742
- events.forEach(function(eventName) {
6743
- return document.removeEventListener(eventName, fn, getEventHandlerOptions(_assertThisInitialized(_this), eventName));
6744
- });
6745
- delete handlersMap[_this._uid];
6746
- }
6747
- };
6748
- _this.getRef = function(ref) {
6749
- return _this.instanceRef = ref;
6750
- };
6751
- _this._uid = uid();
6752
- _this.initTimeStamp = performance.now();
6753
- return _this;
6754
- }
6755
- var _proto = onClickOutside.prototype;
6756
- _proto.getInstance = function getInstance() {
6757
- if (WrappedComponent.prototype && !WrappedComponent.prototype.isReactComponent) {
6758
- return this;
6759
- }
6760
- var ref = this.instanceRef;
6761
- return ref.getInstance ? ref.getInstance() : ref;
6762
- };
6763
- _proto.componentDidMount = function componentDidMount() {
6764
- if (typeof document === "undefined" || !document.createElement) {
6765
- return;
6766
- }
6767
- var instance = this.getInstance();
6768
- if (config && typeof config.handleClickOutside === "function") {
6769
- this.__clickOutsideHandlerProp = config.handleClickOutside(instance);
6770
- if (typeof this.__clickOutsideHandlerProp !== "function") {
6771
- throw new Error("WrappedComponent: " + componentName + " lacks a function for processing outside click events specified by the handleClickOutside config option.");
6772
- }
6773
- }
6774
- this.componentNode = this.__getComponentNode();
6775
- if (this.props.disableOnClickOutside)
6776
- return;
6777
- this.enableOnClickOutside();
7254
+ util.off = off;
7255
+ util.isBrowser = typeof window !== "undefined";
7256
+ util.isNavigator = typeof navigator !== "undefined";
7257
+ Object.defineProperty(useClickAway$1, "__esModule", { value: true });
7258
+ var react_1 = React__default;
7259
+ var util_1 = util;
7260
+ var defaultEvents = ["mousedown", "touchstart"];
7261
+ var useClickAway = function(ref, onClickAway, events) {
7262
+ if (events === void 0) {
7263
+ events = defaultEvents;
7264
+ }
7265
+ var savedCallback = react_1.useRef(onClickAway);
7266
+ react_1.useEffect(function() {
7267
+ savedCallback.current = onClickAway;
7268
+ }, [onClickAway]);
7269
+ react_1.useEffect(function() {
7270
+ var handler = function(event) {
7271
+ var el = ref.current;
7272
+ el && !el.contains(event.target) && savedCallback.current(event);
6778
7273
  };
6779
- _proto.componentDidUpdate = function componentDidUpdate() {
6780
- this.componentNode = this.__getComponentNode();
6781
- };
6782
- _proto.componentWillUnmount = function componentWillUnmount() {
6783
- this.disableOnClickOutside();
6784
- };
6785
- _proto.render = function render() {
6786
- var _this$props = this.props;
6787
- _this$props.excludeScrollbar;
6788
- var props = _objectWithoutPropertiesLoose(_this$props, ["excludeScrollbar"]);
6789
- if (WrappedComponent.prototype && WrappedComponent.prototype.isReactComponent) {
6790
- props.ref = this.getRef;
6791
- } else {
6792
- props.wrappedRef = this.getRef;
7274
+ for (var _i = 0, events_1 = events; _i < events_1.length; _i++) {
7275
+ var eventName = events_1[_i];
7276
+ util_1.on(document, eventName, handler);
7277
+ }
7278
+ return function() {
7279
+ for (var _i2 = 0, events_2 = events; _i2 < events_2.length; _i2++) {
7280
+ var eventName2 = events_2[_i2];
7281
+ util_1.off(document, eventName2, handler);
6793
7282
  }
6794
- props.disableOnClickOutside = this.disableOnClickOutside;
6795
- props.enableOnClickOutside = this.enableOnClickOutside;
6796
- return createElement(WrappedComponent, props);
6797
7283
  };
6798
- return onClickOutside;
6799
- }(Component), _class.displayName = "OnClickOutside(" + componentName + ")", _class.defaultProps = {
6800
- eventTypes: ["mousedown", "touchstart"],
6801
- excludeScrollbar: config && config.excludeScrollbar || false,
6802
- outsideClickIgnoreClass: IGNORE_CLASS_NAME,
6803
- preventDefault: false,
6804
- stopPropagation: false
6805
- }, _class.getClass = function() {
6806
- return WrappedComponent.getClass ? WrappedComponent.getClass() : WrappedComponent;
6807
- }, _temp;
6808
- }
7284
+ }, [events, ref]);
7285
+ };
7286
+ var _default = useClickAway$1.default = useClickAway;
6809
7287
  const viewModes = {
6810
7288
  YEARS: "years",
6811
7289
  MONTHS: "months",
@@ -7334,22 +7812,13 @@ function log(message, method) {
7334
7812
  }
7335
7813
  con[method]("***react-datetime:" + message);
7336
7814
  }
7337
- class ClickOutBase extends React__default.Component {
7338
- constructor() {
7339
- super(...arguments);
7340
- __publicField(this, "container", React__default.createRef());
7341
- }
7342
- render() {
7343
- return /* @__PURE__ */ React__default.createElement("div", { className: this.props.className, ref: this.container }, this.props.children);
7344
- }
7345
- handleClickOutside(e) {
7346
- this.props.onClickOut(e);
7347
- }
7348
- setClickOutsideRef() {
7349
- return this.container.current;
7350
- }
7815
+ function ClickableWrapper({ className, onClickOut, children }) {
7816
+ const containerRef = useRef(null);
7817
+ _default(containerRef, (event) => {
7818
+ onClickOut(event);
7819
+ });
7820
+ return /* @__PURE__ */ React__default.createElement("div", { className, ref: containerRef }, children);
7351
7821
  }
7352
- const ClickableWrapper = onClickOutsideHOC(ClickOutBase);
7353
7822
  const DEFAULT_DATE_DISPLAY_FORMAT = "MMM DD, YYYY";
7354
7823
  const DEFAULT_TIME_DISPLAY_FORMAT = "h:mm A";
7355
7824
  const format$1 = (val, _name, field) => {
@@ -7392,7 +7861,10 @@ const DateField = wrapFieldsWithMeta(
7392
7861
  ReactDateTimeWithStyles,
7393
7862
  {
7394
7863
  value: input.value,
7395
- onChange: input.onChange,
7864
+ onChange: (value) => {
7865
+ const newValue = value === "" ? void 0 : value;
7866
+ input.onChange(newValue);
7867
+ },
7396
7868
  dateFormat: dateFormat || DEFAULT_DATE_DISPLAY_FORMAT,
7397
7869
  timeFormat: timeFormat || false,
7398
7870
  inputProps: { className: textFieldClasses },
@@ -8844,6 +9316,19 @@ class TinaMediaStore {
8844
9316
  }
8845
9317
  }
8846
9318
  }
9319
+ const encodeUrlIfNeeded = (url) => {
9320
+ if (url) {
9321
+ try {
9322
+ const parsed = new URL(url);
9323
+ parsed.pathname = parsed.pathname.split("/").filter((part) => part !== "").map(encodeURIComponent).join("/");
9324
+ return parsed.toString();
9325
+ } catch (e) {
9326
+ return url;
9327
+ }
9328
+ } else {
9329
+ return url;
9330
+ }
9331
+ };
8847
9332
  let MediaManager$1 = class MediaManager {
8848
9333
  constructor(store, events) {
8849
9334
  this.store = store;
@@ -8916,6 +9401,20 @@ let MediaManager$1 = class MediaManager {
8916
9401
  try {
8917
9402
  this.events.dispatch({ type: "media:list:start", ...options });
8918
9403
  const media = await this.store.list(options);
9404
+ media.items = media.items.map((item) => {
9405
+ if (item.type === "dir") {
9406
+ return item;
9407
+ }
9408
+ if (item.thumbnails) {
9409
+ for (const [size, src] of Object.entries(item.thumbnails)) {
9410
+ item.thumbnails[size] = encodeUrlIfNeeded(src);
9411
+ }
9412
+ }
9413
+ return {
9414
+ ...item,
9415
+ src: encodeUrlIfNeeded(item.src)
9416
+ };
9417
+ });
8919
9418
  this.events.dispatch({ type: "media:list:success", ...options, media });
8920
9419
  return media;
8921
9420
  } catch (error) {
@@ -9203,7 +9702,7 @@ class SidebarState {
9203
9702
  }
9204
9703
  }
9205
9704
  function createScreen({
9206
- Component: Component2,
9705
+ Component,
9207
9706
  props,
9208
9707
  ...options
9209
9708
  }) {
@@ -9212,7 +9711,7 @@ function createScreen({
9212
9711
  layout: "popup",
9213
9712
  ...options,
9214
9713
  Component(screenProps) {
9215
- return /* @__PURE__ */ React__default.createElement(Component2, { ...screenProps, ...props });
9714
+ return /* @__PURE__ */ React__default.createElement(Component, { ...screenProps, ...props });
9216
9715
  }
9217
9716
  };
9218
9717
  }
@@ -9723,7 +10222,7 @@ const SyncStatus = ({ cms, setEventsOpen }) => {
9723
10222
  "Event Log"
9724
10223
  ));
9725
10224
  };
9726
- const version = "2.2.8";
10225
+ const version = "2.6.4";
9727
10226
  const Nav = ({
9728
10227
  isLocalMode,
9729
10228
  className = "",
@@ -12254,15 +12753,14 @@ const FormBuilder = ({
12254
12753
  fields: fieldGroup.fields
12255
12754
  }
12256
12755
  ) : /* @__PURE__ */ React.createElement(NoFieldsPlaceholder, null)
12257
- )), !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(
12756
+ )), !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(
12258
12757
  ResetForm,
12259
12758
  {
12260
12759
  pristine,
12261
12760
  reset: async () => {
12262
12761
  finalForm.reset();
12263
12762
  await tinaForm.reset();
12264
- },
12265
- style: { flexGrow: 1 }
12763
+ }
12266
12764
  },
12267
12765
  tinaForm.buttons.reset
12268
12766
  ), /* @__PURE__ */ React.createElement(
@@ -12271,8 +12769,7 @@ const FormBuilder = ({
12271
12769
  onClick: safeHandleSubmit,
12272
12770
  disabled: !canSubmit,
12273
12771
  busy: submitting,
12274
- variant: "primary",
12275
- style: { flexGrow: 3 }
12772
+ variant: "primary"
12276
12773
  },
12277
12774
  submitting && /* @__PURE__ */ React.createElement(LoadingDots, null),
12278
12775
  !submitting && tinaForm.buttons.save
@@ -12654,9 +13151,9 @@ const EllipsisIcon = ({ title }) => {
12654
13151
  ));
12655
13152
  };
12656
13153
  const Wrapper$1 = ({ inline, children }) => {
12657
- const Component2 = inline ? "span" : "div";
13154
+ const Component = inline ? "span" : "div";
12658
13155
  return /* @__PURE__ */ React__default.createElement(
12659
- Component2,
13156
+ Component,
12660
13157
  {
12661
13158
  contentEditable: false,
12662
13159
  style: { userSelect: "none" },
@@ -12790,7 +13287,7 @@ const EmbedNestedForm = ({
12790
13287
  );
12791
13288
  };
12792
13289
  const DotMenu = ({ onOpen, onRemove }) => {
12793
- return /* @__PURE__ */ React__default.createElement(Popover$2, { as: "span", className: "-ml-px relative block" }, /* @__PURE__ */ React__default.createElement(
13290
+ return /* @__PURE__ */ React__default.createElement(Popover$3, { as: "span", className: "-ml-px relative block" }, /* @__PURE__ */ React__default.createElement(
12794
13291
  PopoverButton,
12795
13292
  {
12796
13293
  as: "span",
@@ -13226,17 +13723,31 @@ const plugins = [
13226
13723
  createHTMLInlinePlugin(),
13227
13724
  createBlockquotePlugin(),
13228
13725
  createBoldPlugin(),
13726
+ createStrikethroughPlugin(),
13229
13727
  createItalicPlugin(),
13230
13728
  createUnderlinePlugin(),
13231
13729
  createCodePlugin(),
13232
13730
  createListPlugin(),
13233
- createIndentPlugin(),
13234
13731
  createIndentListPlugin(),
13235
13732
  createHorizontalRulePlugin(),
13236
13733
  // Allows us to do things like copy/paste, remembering the state of the element (like mdx)
13237
13734
  createNodeIdPlugin(),
13238
- createSlashPlugin()
13735
+ createSlashPlugin(),
13736
+ createTablePlugin()
13239
13737
  ];
13738
+ const unsupportedItemsInTable = /* @__PURE__ */ new Set([
13739
+ "Code Block",
13740
+ "Unordered List",
13741
+ "Ordered List",
13742
+ "Quote",
13743
+ "Mermaid",
13744
+ "Heading 1",
13745
+ "Heading 2",
13746
+ "Heading 3",
13747
+ "Heading 4",
13748
+ "Heading 5",
13749
+ "Heading 6"
13750
+ ]);
13240
13751
  const isNodeActive = (editor, type) => {
13241
13752
  const pluginType = getPluginType(editor, type);
13242
13753
  return !!(editor == null ? void 0 : editor.selection) && someNode(editor, { match: { type: pluginType } });
@@ -13421,24 +13932,6 @@ const Editor = React__default.forwardRef(
13421
13932
  }
13422
13933
  );
13423
13934
  Editor.displayName = "Editor";
13424
- const separatorVariants = cva("shrink-0 bg-border", {
13425
- defaultVariants: {
13426
- orientation: "horizontal"
13427
- },
13428
- variants: {
13429
- orientation: {
13430
- horizontal: "h-px w-full",
13431
- vertical: "h-full w-px"
13432
- }
13433
- }
13434
- });
13435
- const Separator = withVariants(
13436
- withProps(SeparatorPrimitive.Root, {
13437
- decorative: true,
13438
- orientation: "horizontal"
13439
- }),
13440
- separatorVariants
13441
- );
13442
13935
  const TooltipProvider = TooltipPrimitive.Provider;
13443
13936
  const Tooltip = TooltipPrimitive.Root;
13444
13937
  const TooltipTrigger = TooltipPrimitive.Trigger;
@@ -13447,15 +13940,15 @@ const TooltipContent = withCn(
13447
13940
  withProps(TooltipPrimitive.Content, {
13448
13941
  sideOffset: 4
13449
13942
  }),
13450
- "z-50 overflow-hidden rounded-md border bg-popover px-3 py-1.5 text-sm text-popover-foreground shadow-md"
13943
+ "z-[9999] overflow-hidden rounded-md border bg-popover px-3 py-1.5 text-sm text-popover-foreground shadow-md"
13451
13944
  );
13452
- function withTooltip(Component2) {
13945
+ function withTooltip(Component) {
13453
13946
  return React__default.forwardRef(function ExtendComponent({ tooltip, tooltipContentProps, tooltipProps, ...props }, ref) {
13454
13947
  const [mounted, setMounted] = React__default.useState(false);
13455
13948
  React__default.useEffect(() => {
13456
13949
  setMounted(true);
13457
13950
  }, []);
13458
- const component = /* @__PURE__ */ React__default.createElement(Component2, { ref, ...props });
13951
+ const component = /* @__PURE__ */ React__default.createElement(Component, { ref, ...props });
13459
13952
  if (tooltip && mounted) {
13460
13953
  return /* @__PURE__ */ React__default.createElement(Tooltip, { ...tooltipProps }, /* @__PURE__ */ React__default.createElement(TooltipTrigger, { asChild: true }, component), /* @__PURE__ */ React__default.createElement(TooltipPortal, null, /* @__PURE__ */ React__default.createElement(TooltipContent, { ...tooltipContentProps }, tooltip)));
13461
13954
  }
@@ -13573,140 +14066,41 @@ const FixedToolbar = withCn(
13573
14066
  Toolbar,
13574
14067
  "p-1 sticky left-0 top-0 z-50 w-full justify-between overflow-x-auto border border-border bg-background"
13575
14068
  );
13576
- const MarkToolbarButton = withRef(({ clear, nodeType, ...rest }, ref) => {
13577
- const state = useMarkToolbarButtonState({ clear, nodeType });
13578
- const { props } = useMarkToolbarButton(state);
13579
- return /* @__PURE__ */ React__default.createElement(ToolbarButton, { ref, ...props, ...rest });
13580
- });
13581
- const IndentListToolbarButton = withRef(({ nodeType = ELEMENT_UL }, ref) => {
13582
- const editor = useEditorState();
13583
- const state = useListToolbarButtonState({ nodeType });
13584
- const { props } = useListToolbarButton(state);
13585
- return /* @__PURE__ */ React__default.createElement(
13586
- ToolbarButton,
13587
- {
13588
- ref,
13589
- tooltip: nodeType === ELEMENT_UL ? "Bulleted List" : "Numbered List",
13590
- ...props,
13591
- onClick: (e) => {
13592
- e.preventDefault();
13593
- e.stopPropagation();
13594
- toggleList(editor, { type: nodeType });
13595
- }
13596
- },
13597
- nodeType === ELEMENT_UL ? /* @__PURE__ */ React__default.createElement(Icons.ul, null) : /* @__PURE__ */ React__default.createElement(Icons.ol, null)
13598
- );
13599
- });
13600
- const DropdownMenu = DropdownMenuPrimitive.Root;
13601
- const DropdownMenuTrigger = DropdownMenuPrimitive.Trigger;
13602
- const DropdownMenuRadioGroup = DropdownMenuPrimitive.RadioGroup;
13603
- withRef(({ children, className, inset, ...props }, ref) => /* @__PURE__ */ React__default.createElement(
13604
- DropdownMenuPrimitive.SubTrigger,
13605
- {
13606
- className: cn$1(
13607
- "flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none focus:bg-accent data-[state=open]:bg-accent",
13608
- "data-[disabled]:pointer-events-none data-[disabled]:opacity-50",
13609
- inset && "pl-8",
13610
- className
13611
- ),
13612
- ref,
13613
- ...props
13614
- },
13615
- children,
13616
- /* @__PURE__ */ React__default.createElement(Icons.chevronRight, { className: "ml-auto size-4" })
13617
- ));
13618
- withCn(
13619
- DropdownMenuPrimitive.SubContent,
13620
- "z-[99999] min-w-32 overflow-hidden rounded-md border bg-white p-1 text-black shadow-lg data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2"
13621
- );
13622
- const DropdownMenuContentVariants = withProps(DropdownMenuPrimitive.Content, {
13623
- className: cn$1(
13624
- "z-[99999] min-w-32 overflow-hidden rounded-md border bg-white p-1 text-black shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2"
13625
- ),
13626
- sideOffset: 4
13627
- });
13628
- const DropdownMenuContent = withRef(({ ...props }, ref) => /* @__PURE__ */ React__default.createElement(DropdownMenuPrimitive.Portal, null, /* @__PURE__ */ React__default.createElement(DropdownMenuContentVariants, { ref, ...props })));
13629
- const menuItemVariants = cva(
13630
- cn$1(
13631
- "relative flex h-9 cursor-pointer select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none transition-colors",
13632
- "focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50"
13633
- ),
13634
- {
13635
- variants: {
13636
- inset: {
13637
- true: "pl-8"
14069
+ const useResize = (ref, callback) => {
14070
+ React__default.useEffect(() => {
14071
+ const resizeObserver = new ResizeObserver((entries) => {
14072
+ for (const entry of entries) {
14073
+ callback(entry);
13638
14074
  }
14075
+ });
14076
+ if (ref.current) {
14077
+ resizeObserver.observe(ref.current);
13639
14078
  }
13640
- }
13641
- );
13642
- const DropdownMenuItem = withVariants(
13643
- DropdownMenuPrimitive.Item,
13644
- menuItemVariants,
13645
- ["inset"]
13646
- );
13647
- withRef(({ children, className, ...props }, ref) => /* @__PURE__ */ React__default.createElement(
13648
- DropdownMenuPrimitive.CheckboxItem,
13649
- {
13650
- className: cn$1(
13651
- "relative flex select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",
13652
- "cursor-pointer",
13653
- className
13654
- ),
13655
- ref,
13656
- ...props
13657
- },
13658
- /* @__PURE__ */ React__default.createElement("span", { className: "absolute left-2 flex size-3.5 items-center justify-center" }, /* @__PURE__ */ React__default.createElement(DropdownMenuPrimitive.ItemIndicator, null, /* @__PURE__ */ React__default.createElement(Icons.check, { className: "size-4" }))),
13659
- children
13660
- ));
13661
- const DropdownMenuRadioItem = withRef(({ children, className, hideIcon, ...props }, ref) => /* @__PURE__ */ React__default.createElement(
13662
- DropdownMenuPrimitive.RadioItem,
13663
- {
13664
- className: cn$1(
13665
- "relative flex select-none items-center rounded-sm pl-8 pr-2 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",
13666
- "h-9 cursor-pointer px-2 data-[state=checked]:bg-accent data-[state=checked]:text-accent-foreground",
13667
- className
13668
- ),
13669
- ref,
13670
- ...props
13671
- },
13672
- !hideIcon && /* @__PURE__ */ React__default.createElement("span", { className: "absolute right-2 flex size-3.5 items-center justify-center" }, /* @__PURE__ */ React__default.createElement(DropdownMenuPrimitive.ItemIndicator, null, /* @__PURE__ */ React__default.createElement(Icons.check, { className: "size-4" }))),
14079
+ return () => resizeObserver.disconnect();
14080
+ }, [ref.current]);
14081
+ };
14082
+ const STANDARD_ICON_WIDTH = 32;
14083
+ const HEADING_ICON_WITH_TEXT = 127;
14084
+ const HEADING_ICON_ONLY = 58;
14085
+ const EMBED_ICON_WIDTH = 78;
14086
+ const CONTAINER_MD_BREAKPOINT = 448;
14087
+ const FLOAT_BUTTON_WIDTH = 25;
14088
+ const HEADING_LABEL = "Headings";
14089
+ const ToolbarContext = createContext(void 0);
14090
+ const ToolbarProvider = ({
14091
+ tinaForm,
14092
+ templates,
14093
+ overrides,
13673
14094
  children
13674
- ));
13675
- const dropdownMenuLabelVariants = cva(
13676
- cn$1("select-none px-2 py-1.5 text-sm font-semibold"),
13677
- {
13678
- variants: {
13679
- inset: {
13680
- true: "pl-8"
13681
- }
13682
- }
14095
+ }) => {
14096
+ return /* @__PURE__ */ React__default.createElement(ToolbarContext.Provider, { value: { tinaForm, templates, overrides } }, children);
14097
+ };
14098
+ const useToolbarContext = () => {
14099
+ const context = useContext(ToolbarContext);
14100
+ if (!context) {
14101
+ throw new Error("useToolbarContext must be used within a ToolbarProvider");
13683
14102
  }
13684
- );
13685
- const DropdownMenuLabel = withVariants(
13686
- DropdownMenuPrimitive.Label,
13687
- dropdownMenuLabelVariants,
13688
- ["inset"]
13689
- );
13690
- const DropdownMenuSeparator = withCn(
13691
- DropdownMenuPrimitive.Separator,
13692
- "-mx-1 my-1 h-px bg-muted"
13693
- );
13694
- withCn(
13695
- createPrimitiveElement("span"),
13696
- "ml-auto text-xs tracking-widest opacity-60"
13697
- );
13698
- const useOpenState = () => {
13699
- const [open2, setOpen] = useState(false);
13700
- const onOpenChange = useCallback(
13701
- (_value = !open2) => {
13702
- setOpen(_value);
13703
- },
13704
- [open2]
13705
- );
13706
- return {
13707
- onOpenChange,
13708
- open: open2
13709
- };
14103
+ return context;
13710
14104
  };
13711
14105
  const items$1 = [
13712
14106
  {
@@ -13772,7 +14166,9 @@ function HeadingsMenu(props) {
13772
14166
  return allNodesMatchInitialNodeType ? initialNodeType : ELEMENT_PARAGRAPH$1;
13773
14167
  }, []);
13774
14168
  const editor = useEditorRef();
14169
+ const editorState = useEditorState();
13775
14170
  const openState = useOpenState();
14171
+ const userInTable = helpers.isNodeActive(editorState, ELEMENT_TABLE$1);
13776
14172
  const selectedItem = items$1.find((item) => item.value === value) ?? defaultItem$1;
13777
14173
  const { icon: SelectedItemIcon, label: selectedItemLabel } = selectedItem;
13778
14174
  return /* @__PURE__ */ React__default.createElement(DropdownMenu, { modal: false, ...openState, ...props }, /* @__PURE__ */ React__default.createElement(DropdownMenuTrigger, { asChild: true }, /* @__PURE__ */ React__default.createElement(
@@ -13784,7 +14180,7 @@ function HeadingsMenu(props) {
13784
14180
  tooltip: "Headings"
13785
14181
  },
13786
14182
  /* @__PURE__ */ React__default.createElement(SelectedItemIcon, { className: "size-5" }),
13787
- /* @__PURE__ */ React__default.createElement("span", { className: "hidden 2xl:flex" }, selectedItemLabel)
14183
+ /* @__PURE__ */ React__default.createElement("span", { className: "@md/toolbar:flex hidden" }, selectedItemLabel)
13788
14184
  )), /* @__PURE__ */ React__default.createElement(DropdownMenuContent, { align: "start", className: "min-w-0" }, /* @__PURE__ */ React__default.createElement(
13789
14185
  DropdownMenuRadioGroup,
13790
14186
  {
@@ -13796,7 +14192,12 @@ function HeadingsMenu(props) {
13796
14192
  },
13797
14193
  value
13798
14194
  },
13799
- items$1.map(({ icon: Icon, label, value: itemValue }) => /* @__PURE__ */ React__default.createElement(
14195
+ items$1.filter((item) => {
14196
+ if (userInTable) {
14197
+ return !unsupportedItemsInTable.has(item.label);
14198
+ }
14199
+ return true;
14200
+ }).map(({ icon: Icon, label, value: itemValue }) => /* @__PURE__ */ React__default.createElement(
13800
14201
  DropdownMenuRadioItem,
13801
14202
  {
13802
14203
  className: "min-w-[180px]",
@@ -13808,42 +14209,6 @@ function HeadingsMenu(props) {
13808
14209
  ))
13809
14210
  )));
13810
14211
  }
13811
- const LinkToolbarButton = withRef((rest, ref) => {
13812
- const state = useLinkToolbarButtonState();
13813
- const { props } = useLinkToolbarButton(state);
13814
- return /* @__PURE__ */ React__default.createElement(ToolbarButton, { ref, tooltip: "Link", ...props, ...rest }, /* @__PURE__ */ React__default.createElement(Icons.link, null));
13815
- });
13816
- const useBlockQuoteToolbarButtonState = () => {
13817
- const editor = useEditorState();
13818
- const isBlockActive = () => helpers.isNodeActive(editor, ELEMENT_BLOCKQUOTE$1);
13819
- return {
13820
- pressed: isBlockActive()
13821
- };
13822
- };
13823
- const useBlockQuoteToolbarButton = (state) => {
13824
- const editor = useEditorState();
13825
- const onClick = () => {
13826
- toggleNodeType(editor, {
13827
- activeType: ELEMENT_BLOCKQUOTE$1
13828
- });
13829
- };
13830
- const onMouseDown = (e) => {
13831
- e.preventDefault();
13832
- e.stopPropagation();
13833
- };
13834
- return {
13835
- props: {
13836
- onClick,
13837
- onMouseDown,
13838
- pressed: state.pressed
13839
- }
13840
- };
13841
- };
13842
- const QuoteToolbarButton = withRef(({ clear, ...rest }, ref) => {
13843
- const state = useBlockQuoteToolbarButtonState();
13844
- const { props } = useBlockQuoteToolbarButton(state);
13845
- return /* @__PURE__ */ React__default.createElement(ToolbarButton, { ref, tooltip: "Link", ...rest, ...props }, /* @__PURE__ */ React__default.createElement(Icons.quote, null));
13846
- });
13847
14212
  const useCodeBlockToolbarButtonState = () => {
13848
14213
  const editor = useEditorState();
13849
14214
  const isBlockActive = () => helpers.isNodeActive(editor, ELEMENT_CODE_BLOCK$1);
@@ -13905,6 +14270,116 @@ const ImageToolbarButton = withRef(({ clear, ...rest }, ref) => {
13905
14270
  const { props } = useImageToolbarButton(state);
13906
14271
  return /* @__PURE__ */ React__default.createElement(ToolbarButton, { ref, tooltip: "Link", ...rest, ...props }, /* @__PURE__ */ React__default.createElement(Icons.image, null));
13907
14272
  });
14273
+ const IndentListToolbarButton = withRef(({ nodeType = ELEMENT_UL }, ref) => {
14274
+ const editor = useEditorState();
14275
+ const state = useListToolbarButtonState({ nodeType });
14276
+ const { props } = useListToolbarButton(state);
14277
+ return /* @__PURE__ */ React__default.createElement(
14278
+ ToolbarButton,
14279
+ {
14280
+ ref,
14281
+ tooltip: nodeType === ELEMENT_UL ? "Bulleted List" : "Numbered List",
14282
+ ...props,
14283
+ onClick: (e) => {
14284
+ e.preventDefault();
14285
+ e.stopPropagation();
14286
+ toggleList(editor, { type: nodeType });
14287
+ }
14288
+ },
14289
+ nodeType === ELEMENT_UL ? /* @__PURE__ */ React__default.createElement(Icons.ul, null) : /* @__PURE__ */ React__default.createElement(Icons.ol, null)
14290
+ );
14291
+ });
14292
+ const LinkToolbarButton = withRef((rest, ref) => {
14293
+ const state = useLinkToolbarButtonState();
14294
+ const { props } = useLinkToolbarButton(state);
14295
+ return /* @__PURE__ */ React__default.createElement(ToolbarButton, { ref, tooltip: "Link", ...props, ...rest }, /* @__PURE__ */ React__default.createElement(Icons.link, null));
14296
+ });
14297
+ const MarkToolbarButton = withRef(({ clear, nodeType, ...rest }, ref) => {
14298
+ const state = useMarkToolbarButtonState({ clear, nodeType });
14299
+ const { props } = useMarkToolbarButton(state);
14300
+ return /* @__PURE__ */ React__default.createElement(ToolbarButton, { ref, ...props, ...rest });
14301
+ });
14302
+ const useMermaidToolbarButtonState = () => {
14303
+ const editor = useEditorState();
14304
+ const isBlockActive = () => helpers.isNodeActive(editor, ELEMENT_MERMAID);
14305
+ return {
14306
+ pressed: isBlockActive()
14307
+ };
14308
+ };
14309
+ const useMermaidToolbarButton = (state) => {
14310
+ const editor = useEditorState();
14311
+ const onClick = () => {
14312
+ insertEmptyElement(editor, ELEMENT_MERMAID, {
14313
+ nextBlock: true,
14314
+ select: true
14315
+ });
14316
+ };
14317
+ const onMouseDown = (e) => {
14318
+ e.preventDefault();
14319
+ e.stopPropagation();
14320
+ };
14321
+ return {
14322
+ props: {
14323
+ onClick,
14324
+ onMouseDown,
14325
+ pressed: state.pressed
14326
+ }
14327
+ };
14328
+ };
14329
+ const MermaidToolbarButton = withRef(({ clear, ...rest }, ref) => {
14330
+ const state = useMermaidToolbarButtonState();
14331
+ const { props } = useMermaidToolbarButton(state);
14332
+ return /* @__PURE__ */ React__default.createElement(ToolbarButton, { ref, tooltip: "Mermaid", ...rest, ...props }, /* @__PURE__ */ React__default.createElement(Icons.mermaid, null));
14333
+ });
14334
+ function OverflowMenu({
14335
+ children,
14336
+ ...props
14337
+ }) {
14338
+ const openState = useOpenState();
14339
+ return /* @__PURE__ */ React__default.createElement(DropdownMenu, { modal: false, ...openState, ...props }, /* @__PURE__ */ React__default.createElement(DropdownMenuTrigger, { asChild: true }, /* @__PURE__ */ React__default.createElement(
14340
+ ToolbarButton,
14341
+ {
14342
+ showArrow: false,
14343
+ "data-testid": "rich-text-editor-overflow-menu-button",
14344
+ className: "lg:min-w-[130px]",
14345
+ isDropdown: true,
14346
+ pressed: openState.open,
14347
+ tooltip: "Headings"
14348
+ },
14349
+ /* @__PURE__ */ React__default.createElement(Icons.overflow, { className: "size-5" })
14350
+ )), /* @__PURE__ */ React__default.createElement(DropdownMenuContent, { align: "start", className: "min-w-0 flex flex-grow" }, children));
14351
+ }
14352
+ const useBlockQuoteToolbarButtonState = () => {
14353
+ const editor = useEditorState();
14354
+ const isBlockActive = () => helpers.isNodeActive(editor, ELEMENT_BLOCKQUOTE$1);
14355
+ return {
14356
+ pressed: isBlockActive()
14357
+ };
14358
+ };
14359
+ const useBlockQuoteToolbarButton = (state) => {
14360
+ const editor = useEditorState();
14361
+ const onClick = () => {
14362
+ toggleNodeType(editor, {
14363
+ activeType: ELEMENT_BLOCKQUOTE$1
14364
+ });
14365
+ };
14366
+ const onMouseDown = (e) => {
14367
+ e.preventDefault();
14368
+ e.stopPropagation();
14369
+ };
14370
+ return {
14371
+ props: {
14372
+ onClick,
14373
+ onMouseDown,
14374
+ pressed: state.pressed
14375
+ }
14376
+ };
14377
+ };
14378
+ const QuoteToolbarButton = withRef(({ clear, ...rest }, ref) => {
14379
+ const state = useBlockQuoteToolbarButtonState();
14380
+ const { props } = useBlockQuoteToolbarButton(state);
14381
+ return /* @__PURE__ */ React__default.createElement(ToolbarButton, { ref, tooltip: "Link", ...rest, ...props }, /* @__PURE__ */ React__default.createElement(Icons.quote, null));
14382
+ });
13908
14383
  const useRawMarkdownToolbarButton = () => {
13909
14384
  const { setRawMode } = useEditorContext();
13910
14385
  const onMouseDown = (e) => {
@@ -13919,31 +14394,123 @@ const useRawMarkdownToolbarButton = () => {
13919
14394
  };
13920
14395
  const RawMarkdownToolbarButton = withRef(({ clear, ...rest }, ref) => {
13921
14396
  const { props } = useRawMarkdownToolbarButton();
13922
- return /* @__PURE__ */ React__default.createElement(ToolbarButton, { ref, tooltip: "Link", ...rest, ...props }, /* @__PURE__ */ React__default.createElement(Icons.raw, null));
14397
+ return /* @__PURE__ */ React__default.createElement(
14398
+ ToolbarButton,
14399
+ {
14400
+ ref,
14401
+ tooltip: "Link",
14402
+ ...rest,
14403
+ ...props,
14404
+ "data-testid": "markdown-button"
14405
+ },
14406
+ /* @__PURE__ */ React__default.createElement(Icons.raw, null)
14407
+ );
13923
14408
  });
13924
- const ToolbarContext = createContext(void 0);
13925
- const ToolbarProvider = ({
13926
- tinaForm,
13927
- templates,
13928
- overrides,
13929
- children
13930
- }) => {
13931
- return /* @__PURE__ */ React__default.createElement(ToolbarContext.Provider, { value: { tinaForm, templates, overrides } }, children);
13932
- };
13933
- const useToolbarContext = () => {
13934
- const context = useContext(ToolbarContext);
13935
- if (!context) {
13936
- throw new Error("useToolbarContext must be used within a ToolbarProvider");
13937
- }
13938
- return context;
13939
- };
14409
+ function TableDropdownMenu(props) {
14410
+ const tableSelected = useEditorSelector(
14411
+ (editor2) => someNode(editor2, { match: { type: ELEMENT_TABLE$1 } }),
14412
+ []
14413
+ );
14414
+ const [enableDeleteColumn, enableDeleteRow] = useEditorSelector((editor2) => {
14415
+ const tableNodeEntry = findNode(editor2, { match: { type: ELEMENT_TABLE$1 } });
14416
+ if (!tableNodeEntry)
14417
+ return [false, false];
14418
+ const [tableNode] = tableNodeEntry;
14419
+ if (!isElement(tableNode))
14420
+ return [false, false];
14421
+ const columnCount = getTableColumnCount(tableNode);
14422
+ const rowCount = tableNode.children.length;
14423
+ return [columnCount > 1, rowCount > 1];
14424
+ }, []);
14425
+ const editor = useEditorRef();
14426
+ const openState = useOpenState();
14427
+ 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(
14428
+ DropdownMenuContent,
14429
+ {
14430
+ align: "start",
14431
+ className: "flex w-[180px] min-w-0 flex-col gap-0.5"
14432
+ },
14433
+ /* @__PURE__ */ React__default.createElement(
14434
+ DropdownMenuItem,
14435
+ {
14436
+ className: "min-w-[180px]",
14437
+ disabled: tableSelected,
14438
+ onSelect: () => {
14439
+ insertTable(editor);
14440
+ focusEditor(editor);
14441
+ }
14442
+ },
14443
+ /* @__PURE__ */ React__default.createElement(Icons.add, { className: iconVariants({ variant: "menuItem" }) }),
14444
+ "Insert table"
14445
+ ),
14446
+ /* @__PURE__ */ React__default.createElement(
14447
+ DropdownMenuItem,
14448
+ {
14449
+ className: "min-w-[180px]",
14450
+ disabled: !tableSelected,
14451
+ onSelect: () => {
14452
+ deleteTable(editor);
14453
+ focusEditor(editor);
14454
+ }
14455
+ },
14456
+ /* @__PURE__ */ React__default.createElement(Icons.minus, { className: iconVariants({ variant: "menuItem" }) }),
14457
+ "Delete table"
14458
+ ),
14459
+ /* @__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(
14460
+ DropdownMenuItem,
14461
+ {
14462
+ className: "min-w-[180px]",
14463
+ disabled: !tableSelected,
14464
+ onSelect: () => {
14465
+ insertTableColumn(editor);
14466
+ focusEditor(editor);
14467
+ }
14468
+ },
14469
+ /* @__PURE__ */ React__default.createElement(Icons.add, { className: iconVariants({ variant: "menuItem" }) }),
14470
+ "Insert column after"
14471
+ ), /* @__PURE__ */ React__default.createElement(
14472
+ DropdownMenuItem,
14473
+ {
14474
+ className: "min-w-[180px]",
14475
+ disabled: !enableDeleteColumn,
14476
+ onSelect: () => {
14477
+ deleteColumn(editor);
14478
+ focusEditor(editor);
14479
+ }
14480
+ },
14481
+ /* @__PURE__ */ React__default.createElement(Icons.minus, { className: iconVariants({ variant: "menuItem" }) }),
14482
+ "Delete column"
14483
+ ))),
14484
+ /* @__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(
14485
+ DropdownMenuItem,
14486
+ {
14487
+ className: "min-w-[180px]",
14488
+ disabled: !tableSelected,
14489
+ onSelect: () => {
14490
+ insertTableRow(editor);
14491
+ focusEditor(editor);
14492
+ }
14493
+ },
14494
+ /* @__PURE__ */ React__default.createElement(Icons.add, { className: iconVariants({ variant: "menuItem" }) }),
14495
+ "Insert row after"
14496
+ ), /* @__PURE__ */ React__default.createElement(
14497
+ DropdownMenuItem,
14498
+ {
14499
+ className: "min-w-[180px]",
14500
+ disabled: !enableDeleteRow,
14501
+ onSelect: () => {
14502
+ deleteRow(editor);
14503
+ focusEditor(editor);
14504
+ }
14505
+ },
14506
+ /* @__PURE__ */ React__default.createElement(Icons.minus, { className: iconVariants({ variant: "menuItem" }) }),
14507
+ "Delete row"
14508
+ )))
14509
+ ));
14510
+ }
13940
14511
  function TemplatesToolbarButton() {
13941
14512
  const { templates } = useToolbarContext();
13942
- const showEmbed = templates.length > 0;
13943
14513
  const editor = useEditorState();
13944
- if (!showEmbed) {
13945
- return null;
13946
- }
13947
14514
  return /* @__PURE__ */ React__default.createElement(EmbedButton, { templates, editor });
13948
14515
  }
13949
14516
  const EmbedButton = ({ editor, templates }) => {
@@ -13976,7 +14543,7 @@ const EmbedButton = ({ editor, templates }) => {
13976
14543
  key: template.name,
13977
14544
  onMouseDown: (e) => {
13978
14545
  e.preventDefault();
13979
- close();
14546
+ setOpen(false);
13980
14547
  insertMDX(editor, template);
13981
14548
  },
13982
14549
  className: ""
@@ -13984,99 +14551,123 @@ const EmbedButton = ({ editor, templates }) => {
13984
14551
  template.label || template.name
13985
14552
  ))));
13986
14553
  };
13987
- const ICON_WIDTH = 32;
13988
- const EMBED_ICON_WIDTH = 78;
13989
- const useResize = (ref, callback) => {
13990
- React__default.useEffect(() => {
13991
- const resizeObserver = new ResizeObserver((entries) => {
13992
- for (const entry of entries) {
13993
- callback(entry);
13994
- }
13995
- });
13996
- if (ref.current) {
13997
- resizeObserver.observe(ref.current);
13998
- }
13999
- return () => resizeObserver.disconnect();
14000
- }, [ref.current]);
14001
- };
14002
- function OverflowMenu({
14003
- children,
14004
- ...props
14005
- }) {
14006
- const openState = useOpenState();
14007
- return /* @__PURE__ */ React__default.createElement(DropdownMenu, { modal: false, ...openState, ...props }, /* @__PURE__ */ React__default.createElement(DropdownMenuTrigger, { asChild: true }, /* @__PURE__ */ React__default.createElement(
14008
- ToolbarButton,
14009
- {
14010
- showArrow: false,
14011
- className: "lg:min-w-[130px]",
14012
- isDropdown: true,
14013
- pressed: openState.open,
14014
- tooltip: "Headings"
14015
- },
14016
- /* @__PURE__ */ React__default.createElement(Icons.overflow, { className: "size-5" })
14017
- )), /* @__PURE__ */ React__default.createElement(DropdownMenuContent, { align: "start", className: "min-w-0 flex flex-grow" }, children));
14018
- }
14019
14554
  const toolbarItems = {
14020
14555
  heading: {
14021
- label: "Headings",
14556
+ label: HEADING_LABEL,
14557
+ width: (paragraphIconExists) => paragraphIconExists ? HEADING_ICON_WITH_TEXT : HEADING_ICON_ONLY,
14558
+ // Dynamically handle width based on paragraph icon
14022
14559
  Component: /* @__PURE__ */ React__default.createElement(ToolbarGroup, { noSeparator: true }, /* @__PURE__ */ React__default.createElement(HeadingsMenu, null))
14023
14560
  },
14024
14561
  link: {
14025
14562
  label: "Link",
14563
+ width: () => STANDARD_ICON_WIDTH,
14026
14564
  Component: /* @__PURE__ */ React__default.createElement(LinkToolbarButton, null)
14027
14565
  },
14028
14566
  image: {
14029
14567
  label: "Image",
14568
+ width: () => STANDARD_ICON_WIDTH,
14030
14569
  Component: /* @__PURE__ */ React__default.createElement(ImageToolbarButton, null)
14031
14570
  },
14032
14571
  quote: {
14033
14572
  label: "Quote",
14573
+ width: () => STANDARD_ICON_WIDTH,
14034
14574
  Component: /* @__PURE__ */ React__default.createElement(QuoteToolbarButton, { tooltip: "Quote Quote (⌘+⇧+.)" })
14035
14575
  },
14036
14576
  ul: {
14037
14577
  label: "Unordered List",
14578
+ width: () => STANDARD_ICON_WIDTH,
14038
14579
  Component: /* @__PURE__ */ React__default.createElement(IndentListToolbarButton, { nodeType: ELEMENT_UL })
14039
14580
  },
14040
14581
  ol: {
14041
14582
  label: "Ordered List",
14583
+ width: () => STANDARD_ICON_WIDTH,
14042
14584
  Component: /* @__PURE__ */ React__default.createElement(IndentListToolbarButton, { nodeType: ELEMENT_OL })
14043
14585
  },
14044
14586
  bold: {
14045
14587
  label: "Bold",
14588
+ width: () => STANDARD_ICON_WIDTH,
14046
14589
  Component: /* @__PURE__ */ React__default.createElement(MarkToolbarButton, { tooltip: "Bold (⌘+B)", nodeType: MARK_BOLD }, /* @__PURE__ */ React__default.createElement(Icons.bold, null))
14047
14590
  },
14591
+ strikethrough: {
14592
+ label: "Strikethrough",
14593
+ width: () => STANDARD_ICON_WIDTH,
14594
+ Component: /* @__PURE__ */ React__default.createElement(MarkToolbarButton, { tooltip: "Strikethrough ", nodeType: MARK_STRIKETHROUGH }, /* @__PURE__ */ React__default.createElement(Icons.strikethrough, null))
14595
+ },
14048
14596
  italic: {
14049
14597
  label: "Italic",
14598
+ width: () => STANDARD_ICON_WIDTH,
14050
14599
  Component: /* @__PURE__ */ React__default.createElement(MarkToolbarButton, { tooltip: "Italic (⌘+I)", nodeType: MARK_ITALIC }, /* @__PURE__ */ React__default.createElement(Icons.italic, null))
14051
14600
  },
14052
14601
  code: {
14053
14602
  label: "Code",
14603
+ width: () => STANDARD_ICON_WIDTH,
14054
14604
  Component: /* @__PURE__ */ React__default.createElement(MarkToolbarButton, { tooltip: "Code (⌘+E)", nodeType: MARK_CODE }, /* @__PURE__ */ React__default.createElement(Icons.code, null))
14055
14605
  },
14056
14606
  codeBlock: {
14057
14607
  label: "Code Block",
14608
+ width: () => STANDARD_ICON_WIDTH,
14058
14609
  Component: /* @__PURE__ */ React__default.createElement(CodeBlockToolbarButton, null)
14059
14610
  },
14611
+ mermaid: {
14612
+ label: "Mermaid",
14613
+ width: () => STANDARD_ICON_WIDTH,
14614
+ Component: /* @__PURE__ */ React__default.createElement(MermaidToolbarButton, null)
14615
+ },
14616
+ table: {
14617
+ label: "Table",
14618
+ width: () => STANDARD_ICON_WIDTH,
14619
+ Component: /* @__PURE__ */ React__default.createElement(TableDropdownMenu, null)
14620
+ },
14060
14621
  raw: {
14061
14622
  label: "Raw Markdown",
14623
+ width: () => STANDARD_ICON_WIDTH,
14062
14624
  Component: /* @__PURE__ */ React__default.createElement(RawMarkdownToolbarButton, null)
14063
14625
  },
14064
14626
  embed: {
14065
14627
  label: "Templates",
14628
+ width: () => EMBED_ICON_WIDTH,
14066
14629
  Component: /* @__PURE__ */ React__default.createElement(TemplatesToolbarButton, null)
14067
14630
  }
14068
14631
  };
14069
14632
  function FixedToolbarButtons() {
14070
14633
  const toolbarRef = React__default.useRef(null);
14071
14634
  const [itemsShown, setItemsShown] = React__default.useState(11);
14072
- const { overrides } = useToolbarContext();
14635
+ const { overrides, templates } = useToolbarContext();
14636
+ const showEmbedButton = templates.length > 0;
14637
+ let items2 = [];
14638
+ if (Array.isArray(overrides)) {
14639
+ items2 = overrides === void 0 ? Object.values(toolbarItems) : overrides.map((item) => toolbarItems[item]).filter((item) => item !== void 0);
14640
+ } else {
14641
+ items2 = (overrides == null ? void 0 : overrides.toolbar) === void 0 ? Object.values(toolbarItems) : overrides.toolbar.map((item) => toolbarItems[item]).filter((item) => item !== void 0);
14642
+ }
14643
+ if (!showEmbedButton) {
14644
+ items2 = items2.filter((item) => item.label !== toolbarItems.embed.label);
14645
+ }
14646
+ const editorState = useEditorState();
14647
+ const userInTable = helpers.isNodeActive(editorState, ELEMENT_TABLE);
14648
+ if (userInTable) {
14649
+ items2 = items2.filter((item) => !unsupportedItemsInTable.has(item.label));
14650
+ }
14073
14651
  useResize(toolbarRef, (entry) => {
14074
14652
  const width = entry.target.getBoundingClientRect().width;
14075
- const itemsShown2 = (width - EMBED_ICON_WIDTH) / ICON_WIDTH;
14076
- setItemsShown(Math.floor(itemsShown2));
14653
+ const headingButton = items2.find((item) => item.label === HEADING_LABEL);
14654
+ const headingWidth = headingButton ? headingButton.width(width > CONTAINER_MD_BREAKPOINT) : 0;
14655
+ const availableWidth = width - headingWidth - FLOAT_BUTTON_WIDTH;
14656
+ const { itemFitCount } = items2.reduce(
14657
+ (acc, item) => {
14658
+ if (item.label !== HEADING_LABEL && acc.totalItemsWidth + item.width() <= availableWidth) {
14659
+ return {
14660
+ totalItemsWidth: acc.totalItemsWidth + item.width(),
14661
+ itemFitCount: acc.itemFitCount + 1
14662
+ };
14663
+ }
14664
+ return acc;
14665
+ },
14666
+ { totalItemsWidth: 0, itemFitCount: 1 }
14667
+ );
14668
+ setItemsShown(itemFitCount);
14077
14669
  });
14078
- const toolbarItemsArray = overrides === void 0 ? Object.values(toolbarItems) : overrides.map((item) => toolbarItems[item]).filter((item) => item !== void 0);
14079
- return /* @__PURE__ */ React__default.createElement("div", { className: "w-full overflow-hidden", ref: toolbarRef }, /* @__PURE__ */ React__default.createElement(
14670
+ return /* @__PURE__ */ React__default.createElement("div", { className: "w-full overflow-hidden @container/toolbar", ref: toolbarRef }, /* @__PURE__ */ React__default.createElement(
14080
14671
  "div",
14081
14672
  {
14082
14673
  className: "flex",
@@ -14084,7 +14675,7 @@ function FixedToolbarButtons() {
14084
14675
  transform: "translateX(calc(-1px))"
14085
14676
  }
14086
14677
  },
14087
- /* @__PURE__ */ React__default.createElement(React__default.Fragment, null, toolbarItemsArray.slice(0, itemsShown).map((item, index) => /* @__PURE__ */ React__default.createElement(React__default.Fragment, { key: item.label }, item.Component)), toolbarItemsArray.length > itemsShown && /* @__PURE__ */ React__default.createElement(OverflowMenu, null, toolbarItemsArray.slice(itemsShown).flatMap((c) => /* @__PURE__ */ React__default.createElement(React__default.Fragment, { key: c.label }, c.Component))))
14678
+ /* @__PURE__ */ React__default.createElement(React__default.Fragment, null, items2.slice(0, itemsShown).map((item) => /* @__PURE__ */ React__default.createElement(React__default.Fragment, { key: item.label }, item.Component)), items2.length > itemsShown && /* @__PURE__ */ React__default.createElement(OverflowMenu, null, items2.slice(itemsShown).flatMap((c) => /* @__PURE__ */ React__default.createElement(React__default.Fragment, { key: c.label }, c.Component))))
14088
14679
  ));
14089
14680
  }
14090
14681
  const FloatingToolbar = withRef(({ children, state, ...props }, componentRef) => {
@@ -14199,6 +14790,10 @@ function TurnIntoDropdownMenu(props) {
14199
14790
  const openState = useOpenState();
14200
14791
  const selectedItem = items.find((item) => item.value === value) ?? defaultItem;
14201
14792
  const { icon: SelectedItemIcon, label: selectedItemLabel } = selectedItem;
14793
+ const editorState = useEditorState();
14794
+ const userInTable = helpers.isNodeActive(editorState, ELEMENT_TABLE$1);
14795
+ if (userInTable)
14796
+ return null;
14202
14797
  return /* @__PURE__ */ React__default.createElement(DropdownMenu, { modal: false, ...openState, ...props }, /* @__PURE__ */ React__default.createElement(DropdownMenuTrigger, { asChild: true }, /* @__PURE__ */ React__default.createElement(
14203
14798
  ToolbarButton,
14204
14799
  {
@@ -14240,49 +14835,6 @@ function TurnIntoDropdownMenu(props) {
14240
14835
  function FloatingToolbarButtons() {
14241
14836
  return /* @__PURE__ */ React__default.createElement(React__default.Fragment, null, /* @__PURE__ */ React__default.createElement(TurnIntoDropdownMenu, null));
14242
14837
  }
14243
- const buttonVariants = cva(
14244
- "inline-flex items-center justify-center whitespace-nowrap rounded-md text-sm font-medium ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50",
14245
- {
14246
- defaultVariants: {
14247
- size: "default",
14248
- variant: "default"
14249
- },
14250
- variants: {
14251
- isMenu: {
14252
- true: "h-auto w-full cursor-pointer justify-start"
14253
- },
14254
- size: {
14255
- default: "h-10 px-4 py-2",
14256
- icon: "size-10",
14257
- lg: "h-11 rounded-md px-8",
14258
- none: "",
14259
- sm: "h-9 rounded-md px-3",
14260
- sms: "size-9 rounded-md px-0",
14261
- xs: "h-8 rounded-md px-3"
14262
- },
14263
- variant: {
14264
- default: "bg-primary text-primary-foreground hover:bg-primary/90",
14265
- destructive: "bg-destructive text-destructive-foreground hover:bg-destructive/90",
14266
- ghost: "hover:bg-accent hover:text-accent-foreground",
14267
- inlineLink: "text-base text-primary underline underline-offset-4",
14268
- link: "text-primary underline-offset-4 hover:underline",
14269
- outline: "border border-input bg-background hover:bg-accent hover:text-accent-foreground",
14270
- secondary: "bg-secondary text-secondary-foreground hover:bg-secondary/80"
14271
- }
14272
- }
14273
- }
14274
- );
14275
- withRef(({ asChild = false, className, isMenu, size, variant, ...props }, ref) => {
14276
- const Comp = asChild ? Slot : "button";
14277
- return /* @__PURE__ */ React.createElement(
14278
- Comp,
14279
- {
14280
- className: cn$1(buttonVariants({ className, isMenu, size, variant })),
14281
- ref,
14282
- ...props
14283
- }
14284
- );
14285
- });
14286
14838
  const inputVariants = cva(
14287
14839
  "flex w-full rounded-md bg-transparent text-sm file:border-0 file:bg-background file:text-sm file:font-medium placeholder:text-muted-foreground focus-visible:outline-none disabled:cursor-not-allowed disabled:opacity-50",
14288
14840
  {
@@ -14303,22 +14855,6 @@ const inputVariants = cva(
14303
14855
  }
14304
14856
  );
14305
14857
  withVariants("input", inputVariants, ["variant", "h"]);
14306
- const popoverVariants = cva(
14307
- "w-72 rounded-md border bg-popover p-4 text-popover-foreground shadow-md outline-none data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 print:hidden"
14308
- );
14309
- withRef(
14310
- ({ align = "center", className, sideOffset = 4, style, ...props }, ref) => /* @__PURE__ */ React.createElement(PopoverPrimitive.Portal, null, /* @__PURE__ */ React.createElement(
14311
- PopoverPrimitive.Content,
14312
- {
14313
- align,
14314
- className: cn$1(popoverVariants(), className),
14315
- ref,
14316
- sideOffset,
14317
- style: { zIndex: 1e3, ...style },
14318
- ...props
14319
- }
14320
- ))
14321
- );
14322
14858
  const floatingOptions = {
14323
14859
  middleware: [
14324
14860
  offset(12),
@@ -14378,7 +14914,7 @@ function LinkFloatingToolbar({ state }) {
14378
14914
  const editContent = editState.isEditing ? input : /* @__PURE__ */ React__default.createElement("div", { className: "box-content flex h-9 items-center gap-1" }, /* @__PURE__ */ React__default.createElement(
14379
14915
  "button",
14380
14916
  {
14381
- className: buttonVariants({ size: "sm", variant: "ghost" }),
14917
+ className: buttonVariants$1({ size: "sm", variant: "ghost" }),
14382
14918
  type: "button",
14383
14919
  ...editButtonProps
14384
14920
  },
@@ -14386,7 +14922,7 @@ function LinkFloatingToolbar({ state }) {
14386
14922
  ), /* @__PURE__ */ React__default.createElement(Separator, { orientation: "vertical" }), /* @__PURE__ */ React__default.createElement(
14387
14923
  LinkOpenButton,
14388
14924
  {
14389
- className: buttonVariants({
14925
+ className: buttonVariants$1({
14390
14926
  size: "sms",
14391
14927
  variant: "ghost"
14392
14928
  })
@@ -14395,7 +14931,7 @@ function LinkFloatingToolbar({ state }) {
14395
14931
  ), /* @__PURE__ */ React__default.createElement(Separator, { orientation: "vertical" }), /* @__PURE__ */ React__default.createElement(
14396
14932
  "button",
14397
14933
  {
14398
- className: buttonVariants({
14934
+ className: buttonVariants$1({
14399
14935
  size: "sms",
14400
14936
  variant: "ghost"
14401
14937
  }),
@@ -14431,6 +14967,9 @@ const isUrl = (string) => {
14431
14967
  if (typeof string !== "string") {
14432
14968
  return false;
14433
14969
  }
14970
+ if (string.startsWith("#")) {
14971
+ return true;
14972
+ }
14434
14973
  const generalMatch = string.match(protocolAndDomainRE);
14435
14974
  const emailLinkMatch = string.match(emailLintRE);
14436
14975
  const localUrlMatch = string.match(localUrlRE);
@@ -14452,12 +14991,12 @@ const isUrl = (string) => {
14452
14991
  }
14453
14992
  return localhostDomainRE.test(everythingAfterProtocol) || nonLocalhostDomainRE.test(everythingAfterProtocol);
14454
14993
  };
14455
- const RichEditor = (props) => {
14994
+ const RichEditor = ({ input, tinaForm, field }) => {
14456
14995
  var _a;
14457
14996
  const initialValue = React__default.useMemo(
14458
14997
  () => {
14459
14998
  var _a2, _b;
14460
- return ((_b = (_a2 = props.input.value) == null ? void 0 : _a2.children) == null ? void 0 : _b.length) ? props.input.value.children.map(helpers.normalize) : [{ type: "p", children: [{ type: "text", text: "" }] }];
14999
+ return ((_b = (_a2 = input.value) == null ? void 0 : _a2.children) == null ? void 0 : _b.length) ? input.value.children.map(helpers.normalize) : [{ type: "p", children: [{ type: "text", text: "" }] }];
14461
15000
  },
14462
15001
  []
14463
15002
  );
@@ -14469,6 +15008,7 @@ const RichEditor = (props) => {
14469
15008
  createMdxBlockPlugin(),
14470
15009
  createMdxInlinePlugin(),
14471
15010
  createImgPlugin(),
15011
+ createMermaidPlugin(),
14472
15012
  createInvalidMarkdownPlugin(),
14473
15013
  createLinkPlugin({
14474
15014
  options: {
@@ -14484,7 +15024,7 @@ const RichEditor = (props) => {
14484
15024
  ),
14485
15025
  []
14486
15026
  );
14487
- const tempId = [props.tinaForm.id, props.input.name].join(".");
15027
+ const tempId = [tinaForm.id, input.name].join(".");
14488
15028
  const id = React__default.useMemo(() => uuid() + tempId, [tempId]);
14489
15029
  const ref = React__default.useRef(null);
14490
15030
  React__default.useEffect(() => {
@@ -14494,13 +15034,13 @@ const RichEditor = (props) => {
14494
15034
  const plateElement = (_a2 = ref.current) == null ? void 0 : _a2.querySelector(
14495
15035
  '[role="textbox"]'
14496
15036
  );
14497
- if (props.field.experimental_focusIntent && plateElement) {
15037
+ if (field.experimental_focusIntent && plateElement) {
14498
15038
  if (plateElement)
14499
15039
  plateElement.focus();
14500
15040
  }
14501
15041
  }, 100);
14502
15042
  }
14503
- }, [props.field.experimental_focusIntent, ref]);
15043
+ }, [field.experimental_focusIntent, ref]);
14504
15044
  return /* @__PURE__ */ React__default.createElement("div", { ref }, /* @__PURE__ */ React__default.createElement(
14505
15045
  Plate,
14506
15046
  {
@@ -14508,7 +15048,7 @@ const RichEditor = (props) => {
14508
15048
  initialValue,
14509
15049
  plugins: plugins$2,
14510
15050
  onChange: (value) => {
14511
- props.input.onChange({
15051
+ input.onChange({
14512
15052
  type: "root",
14513
15053
  children: value
14514
15054
  });
@@ -14517,12 +15057,12 @@ const RichEditor = (props) => {
14517
15057
  /* @__PURE__ */ React__default.createElement(TooltipProvider, null, /* @__PURE__ */ React__default.createElement(
14518
15058
  ToolbarProvider,
14519
15059
  {
14520
- tinaForm: props.tinaForm,
14521
- templates: props.field.templates,
14522
- overrides: (_a = props.field) == null ? void 0 : _a.toolbarOverride
15060
+ tinaForm,
15061
+ templates: field.templates,
15062
+ overrides: (field == null ? void 0 : field.toolbarOverride) ? field.toolbarOverride : field.overrides
14523
15063
  },
14524
15064
  /* @__PURE__ */ React__default.createElement(FixedToolbar, null, /* @__PURE__ */ React__default.createElement(FixedToolbarButtons, null)),
14525
- /* @__PURE__ */ React__default.createElement(FloatingToolbar, null, /* @__PURE__ */ React__default.createElement(FloatingToolbarButtons, null))
15065
+ ((_a = field == null ? void 0 : field.overrides) == null ? void 0 : _a.showFloatingToolbar) !== false ? /* @__PURE__ */ React__default.createElement(FloatingToolbar, null, /* @__PURE__ */ React__default.createElement(FloatingToolbarButtons, null)) : null
14526
15066
  ), /* @__PURE__ */ React__default.createElement(Editor, null))
14527
15067
  ));
14528
15068
  };
@@ -15710,132 +16250,1209 @@ const ben = [
15710
16250
  "হয়"
15711
16251
  ];
15712
16252
  const bre = [
16253
+ "'blam",
16254
+ "'d",
16255
+ "'m",
16256
+ "'r",
16257
+ "'ta",
16258
+ "'vat",
16259
+ "'z",
16260
+ "'zo",
15713
16261
  "a",
15714
- "ainda",
15715
- "alem",
15716
- "ambas",
15717
- "ambos",
15718
- "antes",
15719
- "ao",
15720
- "aonde",
15721
- "aos",
15722
- "apos",
15723
- "aquele",
15724
- "aqueles",
15725
- "as",
15726
- "assim",
15727
- "com",
15728
- "como",
15729
- "contra",
15730
- "contudo",
15731
- "cuja",
15732
- "cujas",
15733
- "cujo",
15734
- "cujos",
16262
+ "a:",
16263
+ "aba",
16264
+ "abalamour",
16265
+ "abaoe",
16266
+ "ac'hane",
16267
+ "ac'hanoc'h",
16268
+ "ac'hanomp",
16269
+ "ac'hanon",
16270
+ "ac'hanout",
16271
+ "adal",
16272
+ "adalek",
16273
+ "adarre",
16274
+ "ae",
16275
+ "aec'h",
16276
+ "aed",
16277
+ "aemp",
16278
+ "aen",
16279
+ "aent",
16280
+ "aes",
16281
+ "afe",
16282
+ "afec'h",
16283
+ "afed",
16284
+ "afemp",
16285
+ "afen",
16286
+ "afent",
16287
+ "afes",
16288
+ "ag",
16289
+ "ah",
16290
+ "aimp",
16291
+ "aint",
16292
+ "aio",
16293
+ "aiou",
16294
+ "aje",
16295
+ "ajec'h",
16296
+ "ajed",
16297
+ "ajemp",
16298
+ "ajen",
16299
+ "ajent",
16300
+ "ajes",
16301
+ "al",
16302
+ "alato",
16303
+ "alies",
16304
+ "aliesañ",
16305
+ "alkent",
16306
+ "all",
16307
+ "allas",
16308
+ "allo",
16309
+ "allô",
16310
+ "am",
16311
+ "amañ",
16312
+ "amzer",
16313
+ "an",
16314
+ "anezhañ",
16315
+ "anezhe",
16316
+ "anezhi",
16317
+ "anezho",
16318
+ "anvet",
16319
+ "aon",
16320
+ "aotren",
16321
+ "ar",
16322
+ "arall",
16323
+ "araok",
16324
+ "araoki",
16325
+ "araozañ",
16326
+ "araozo",
16327
+ "araozoc'h",
16328
+ "araozomp",
16329
+ "araozon",
16330
+ "araozor",
16331
+ "araozout",
16332
+ "arbenn",
16333
+ "arre",
16334
+ "atalek",
16335
+ "atav",
16336
+ "az",
16337
+ "azalek",
16338
+ "azirazañ",
16339
+ "azirazi",
16340
+ "azirazo",
16341
+ "azirazoc'h",
16342
+ "azirazomp",
16343
+ "azirazon",
16344
+ "azirazor",
16345
+ "azirazout",
16346
+ "b:",
16347
+ "ba",
16348
+ "ba'l",
16349
+ "ba'n",
16350
+ "ba'r",
16351
+ "bad",
16352
+ "bah",
16353
+ "bal",
16354
+ "ban",
16355
+ "bar",
16356
+ "bastañ",
16357
+ "befe",
16358
+ "bell",
16359
+ "benaos",
16360
+ "benn",
16361
+ "bennag",
16362
+ "bennak",
16363
+ "bennozh",
16364
+ "bep",
16365
+ "bepred",
16366
+ "berr",
16367
+ "berzh",
16368
+ "bet",
16369
+ "betek",
16370
+ "betra",
16371
+ "bev",
16372
+ "bevet",
16373
+ "bez",
16374
+ "bezañ",
16375
+ "beze",
16376
+ "bezent",
16377
+ "bezet",
16378
+ "bezh",
16379
+ "bezit",
16380
+ "bezomp",
16381
+ "bihan",
16382
+ "bije",
16383
+ "biou",
16384
+ "biskoazh",
16385
+ "blam",
16386
+ "bo",
16387
+ "boa",
16388
+ "bominapl",
16389
+ "boudoudom",
16390
+ "bouez",
16391
+ "boull",
16392
+ "boum",
16393
+ "bout",
16394
+ "bras",
16395
+ "brasañ",
16396
+ "brav",
16397
+ "bravo",
16398
+ "bremañ",
16399
+ "bres",
16400
+ "brokenn",
16401
+ "bronn",
16402
+ "brrr",
16403
+ "brutal",
16404
+ "buhezek",
16405
+ "c'h:",
16406
+ "c'haout",
16407
+ "c'he",
16408
+ "c'hem",
16409
+ "c'herz",
16410
+ "c'heñver",
16411
+ "c'hichen",
16412
+ "c'hiz",
16413
+ "c'hoazh",
16414
+ "c'horre",
16415
+ "c'houde",
16416
+ "c'houst",
16417
+ "c'hreiz",
16418
+ "c'hwec'h",
16419
+ "c'hwec'hvet",
16420
+ "c'hwezek",
16421
+ "c'hwi",
16422
+ "ch:",
16423
+ "chaous",
16424
+ "chik",
16425
+ "chit",
16426
+ "chom",
16427
+ "chut",
16428
+ "d'",
16429
+ "d'al",
16430
+ "d'an",
16431
+ "d'ar",
16432
+ "d'az",
16433
+ "d'e",
16434
+ "d'he",
16435
+ "d'ho",
16436
+ "d'hol",
16437
+ "d'hon",
16438
+ "d'hor",
16439
+ "d'o",
16440
+ "d'ober",
16441
+ "d'ul",
16442
+ "d'un",
16443
+ "d'ur",
16444
+ "d:",
15735
16445
  "da",
15736
- "das",
15737
- "de",
15738
- "dela",
15739
- "dele",
15740
- "deles",
15741
- "demais",
15742
- "depois",
15743
- "desde",
15744
- "desta",
15745
- "deste",
15746
- "dispoe",
15747
- "dispoem",
15748
- "diversa",
15749
- "diversas",
15750
- "diversos",
16446
+ "dak",
16447
+ "daka",
16448
+ "dal",
16449
+ "dalbezh",
16450
+ "dalc'hmat",
16451
+ "dalit",
16452
+ "damdost",
16453
+ "damheñvel",
16454
+ "damm",
16455
+ "dan",
16456
+ "danvez",
16457
+ "dao",
16458
+ "daol",
16459
+ "daonet",
16460
+ "daou",
16461
+ "daoust",
16462
+ "daouzek",
16463
+ "daouzekvet",
16464
+ "darn",
16465
+ "dastrewiñ",
16466
+ "dav",
16467
+ "davedoc'h",
16468
+ "davedomp",
16469
+ "davedon",
16470
+ "davedor",
16471
+ "davedout",
16472
+ "davet",
16473
+ "davetañ",
16474
+ "davete",
16475
+ "daveti",
16476
+ "daveto",
16477
+ "defe",
16478
+ "dehou",
16479
+ "dek",
16480
+ "dekvet",
16481
+ "den",
16482
+ "deoc'h",
16483
+ "deomp",
16484
+ "deor",
16485
+ "derc'hel",
16486
+ "deus",
16487
+ "dez",
16488
+ "deze",
16489
+ "dezhañ",
16490
+ "dezhe",
16491
+ "dezhi",
16492
+ "dezho",
16493
+ "di",
16494
+ "diabarzh",
16495
+ "diagent",
16496
+ "diar",
16497
+ "diaraok",
16498
+ "diavaez",
16499
+ "dibaoe",
16500
+ "dibaot",
16501
+ "dibar",
16502
+ "dic'halañ",
16503
+ "didiac'h",
16504
+ "dienn",
16505
+ "difer",
16506
+ "diganeoc'h",
16507
+ "diganeomp",
16508
+ "diganeor",
16509
+ "diganimp",
16510
+ "diganin",
16511
+ "diganit",
16512
+ "digant",
16513
+ "digantañ",
16514
+ "digante",
16515
+ "diganti",
16516
+ "diganto",
16517
+ "digemmesk",
16518
+ "diget",
16519
+ "digor",
16520
+ "digoret",
16521
+ "dija",
16522
+ "dije",
16523
+ "dimp",
16524
+ "din",
16525
+ "dinaou",
16526
+ "dindan",
16527
+ "dindanañ",
16528
+ "dindani",
16529
+ "dindano",
16530
+ "dindanoc'h",
16531
+ "dindanomp",
16532
+ "dindanon",
16533
+ "dindanor",
16534
+ "dindanout",
16535
+ "dioutañ",
16536
+ "dioute",
16537
+ "diouti",
16538
+ "diouto",
16539
+ "diouzh",
16540
+ "diouzhin",
16541
+ "diouzhit",
16542
+ "diouzhoc'h",
16543
+ "diouzhomp",
16544
+ "diouzhor",
16545
+ "dirak",
16546
+ "dirazañ",
16547
+ "dirazi",
16548
+ "dirazo",
16549
+ "dirazoc'h",
16550
+ "dirazomp",
16551
+ "dirazon",
16552
+ "dirazor",
16553
+ "dirazout",
16554
+ "disheñvel",
16555
+ "dispar",
16556
+ "distank",
16557
+ "dister",
16558
+ "disterañ",
16559
+ "disterig",
16560
+ "distro",
16561
+ "dit",
16562
+ "divaez",
16563
+ "diwar",
16564
+ "diwezhat",
16565
+ "diwezhañ",
15751
16566
  "do",
15752
- "dos",
15753
- "durante",
16567
+ "doa",
16568
+ "doare",
16569
+ "dont",
16570
+ "dost",
16571
+ "doue",
16572
+ "douetus",
16573
+ "douez",
16574
+ "doug",
16575
+ "draou",
16576
+ "draoñ",
16577
+ "dre",
16578
+ "drede",
16579
+ "dreist",
16580
+ "dreistañ",
16581
+ "dreisti",
16582
+ "dreisto",
16583
+ "dreistoc'h",
16584
+ "dreistomp",
16585
+ "dreiston",
16586
+ "dreistor",
16587
+ "dreistout",
16588
+ "drek",
16589
+ "dreñv",
16590
+ "dring",
16591
+ "dro",
16592
+ "du",
15754
16593
  "e",
15755
- "ela",
15756
- "elas",
15757
- "ele",
15758
- "eles",
16594
+ "e:",
16595
+ "eas",
16596
+ "ebet",
16597
+ "ec'h",
16598
+ "edo",
16599
+ "edoc'h",
16600
+ "edod",
16601
+ "edomp",
16602
+ "edon",
16603
+ "edont",
16604
+ "edos",
16605
+ "eer",
16606
+ "eeun",
16607
+ "efed",
16608
+ "egedoc'h",
16609
+ "egedomp",
16610
+ "egedon",
16611
+ "egedor",
16612
+ "egedout",
16613
+ "eget",
16614
+ "egetañ",
16615
+ "egete",
16616
+ "egeti",
16617
+ "egeto",
16618
+ "eh",
16619
+ "eil",
16620
+ "eilvet",
16621
+ "eizh",
16622
+ "eizhvet",
16623
+ "ejoc'h",
16624
+ "ejod",
16625
+ "ejomp",
16626
+ "ejont",
16627
+ "ejout",
16628
+ "el",
15759
16629
  "em",
15760
- "entao",
15761
- "entre",
15762
- "essa",
15763
- "essas",
15764
- "esse",
15765
- "esses",
15766
- "esta",
15767
- "estas",
15768
- "este",
15769
- "estes",
16630
+ "emaint",
16631
+ "emaoc'h",
16632
+ "emaomp",
16633
+ "emaon",
16634
+ "emaout",
16635
+ "emañ",
16636
+ "eme",
16637
+ "emeur",
16638
+ "emezañ",
16639
+ "emezi",
16640
+ "emezo",
16641
+ "emezoc'h",
16642
+ "emezomp",
16643
+ "emezon",
16644
+ "emezout",
16645
+ "emporzhiañ",
16646
+ "en",
16647
+ "end",
16648
+ "endan",
16649
+ "endra",
16650
+ "enep",
16651
+ "ennañ",
16652
+ "enni",
16653
+ "enno",
16654
+ "ennoc'h",
16655
+ "ennomp",
16656
+ "ennon",
16657
+ "ennor",
16658
+ "ennout",
16659
+ "enta",
16660
+ "eo",
16661
+ "eomp",
16662
+ "eont",
16663
+ "eor",
16664
+ "eot",
16665
+ "er",
16666
+ "erbet",
16667
+ "erfin",
16668
+ "esa",
16669
+ "esae",
16670
+ "espar",
16671
+ "estlamm",
16672
+ "estrañj",
16673
+ "eta",
16674
+ "etre",
16675
+ "etreoc'h",
16676
+ "etrezo",
16677
+ "etrezoc'h",
16678
+ "etrezomp",
16679
+ "etrezor",
16680
+ "euh",
16681
+ "eur",
16682
+ "eus",
16683
+ "evel",
16684
+ "evelato",
16685
+ "eveldoc'h",
16686
+ "eveldomp",
16687
+ "eveldon",
16688
+ "eveldor",
16689
+ "eveldout",
16690
+ "evelkent",
16691
+ "eveltañ",
16692
+ "evelte",
16693
+ "evelti",
16694
+ "evelto",
16695
+ "evidoc'h",
16696
+ "evidomp",
16697
+ "evidon",
16698
+ "evidor",
16699
+ "evidout",
16700
+ "evit",
16701
+ "evitañ",
16702
+ "evite",
16703
+ "eviti",
16704
+ "evito",
16705
+ "ez",
16706
+ "eñ",
16707
+ "f:",
16708
+ "fac'h",
16709
+ "fall",
16710
+ "fed",
16711
+ "feiz",
16712
+ "fenn",
16713
+ "fezh",
16714
+ "fin",
16715
+ "finsalvet",
16716
+ "foei",
16717
+ "fouilhezañ",
16718
+ "g:",
16719
+ "gallout",
16720
+ "ganeoc'h",
16721
+ "ganeomp",
16722
+ "ganin",
16723
+ "ganit",
16724
+ "gant",
16725
+ "gantañ",
16726
+ "ganti",
16727
+ "ganto",
16728
+ "gaout",
16729
+ "gast",
16730
+ "gein",
16731
+ "gellout",
16732
+ "genndost",
16733
+ "gentañ",
16734
+ "ger",
16735
+ "gerz",
16736
+ "get",
16737
+ "geñver",
16738
+ "gichen",
16739
+ "gin",
16740
+ "giz",
16741
+ "glan",
16742
+ "gloev",
16743
+ "goll",
16744
+ "gorre",
16745
+ "goude",
16746
+ "gouez",
16747
+ "gouezit",
16748
+ "gouezomp",
16749
+ "goulz",
16750
+ "gounnar",
16751
+ "gour",
16752
+ "goust",
16753
+ "gouze",
16754
+ "gouzout",
16755
+ "gra",
16756
+ "grak",
16757
+ "grec'h",
16758
+ "greiz",
16759
+ "grenn",
16760
+ "greomp",
16761
+ "grit",
16762
+ "groñs",
16763
+ "gutez",
16764
+ "gwall",
16765
+ "gwashoc'h",
16766
+ "gwazh",
16767
+ "gwech",
16768
+ "gwechall",
16769
+ "gwechoù",
16770
+ "gwell",
16771
+ "gwezh",
16772
+ "gwezhall",
16773
+ "gwezharall",
16774
+ "gwezhoù",
16775
+ "gwig",
16776
+ "gwirionez",
16777
+ "gwitibunan",
16778
+ "gêr",
16779
+ "h:",
15770
16780
  "ha",
15771
- "isso",
15772
- "isto",
15773
- "logo",
15774
- "mais",
15775
- "mas",
15776
- "mediante",
15777
- "menos",
15778
- "mesma",
15779
- "mesmas",
15780
- "mesmo",
15781
- "mesmos",
16781
+ "hag",
16782
+ "han",
16783
+ "hanter",
16784
+ "hanterc'hantad",
16785
+ "hanterkantved",
16786
+ "harz",
16787
+ "hañ",
16788
+ "hañval",
16789
+ "he",
16790
+ "hebioù",
16791
+ "hec'h",
16792
+ "hei",
16793
+ "hein",
16794
+ "hem",
16795
+ "hemañ",
16796
+ "hen",
16797
+ "hend",
16798
+ "henhont",
16799
+ "henn",
16800
+ "hennezh",
16801
+ "hent",
16802
+ "hep",
16803
+ "hervez",
16804
+ "hervezañ",
16805
+ "hervezi",
16806
+ "hervezo",
16807
+ "hervezoc'h",
16808
+ "hervezomp",
16809
+ "hervezon",
16810
+ "hervezor",
16811
+ "hervezout",
16812
+ "heul",
16813
+ "heuliañ",
16814
+ "hevelep",
16815
+ "heverk",
16816
+ "heñvel",
16817
+ "heñvelat",
16818
+ "heñvelañ",
16819
+ "heñveliñ",
16820
+ "heñveloc'h",
16821
+ "heñvelout",
16822
+ "hi",
16823
+ "hilh",
16824
+ "hini",
16825
+ "hirie",
16826
+ "hirio",
16827
+ "hiziv",
16828
+ "hiziviken",
16829
+ "ho",
16830
+ "hoaliñ",
16831
+ "hoc'h",
16832
+ "hogen",
16833
+ "hogos",
16834
+ "hogozik",
16835
+ "hol",
16836
+ "holl",
16837
+ "holà",
16838
+ "homañ",
16839
+ "hon",
16840
+ "honhont",
16841
+ "honnezh",
16842
+ "hont",
16843
+ "hop",
16844
+ "hopala",
16845
+ "hor",
16846
+ "hou",
16847
+ "houp",
16848
+ "hudu",
16849
+ "hue",
16850
+ "hui",
16851
+ "hum",
16852
+ "hurrah",
16853
+ "i",
16854
+ "i:",
16855
+ "in",
16856
+ "int",
16857
+ "is",
16858
+ "ispisial",
16859
+ "isurzhiet",
16860
+ "it",
16861
+ "ivez",
16862
+ "izelañ",
16863
+ "j:",
16864
+ "just",
16865
+ "k:",
16866
+ "kae",
16867
+ "kaer",
16868
+ "kalon",
16869
+ "kalz",
16870
+ "kant",
16871
+ "kaout",
16872
+ "kar",
16873
+ "kazi",
16874
+ "keid",
16875
+ "kein",
16876
+ "keit",
16877
+ "kel",
16878
+ "kellies",
16879
+ "keloù",
16880
+ "kement",
16881
+ "ken",
16882
+ "kenkent",
16883
+ "kenkoulz",
16884
+ "kenment",
16885
+ "kent",
16886
+ "kentañ",
16887
+ "kentizh",
16888
+ "kentoc'h",
16889
+ "kentre",
16890
+ "ker",
16891
+ "kerkent",
16892
+ "kerz",
16893
+ "kerzh",
16894
+ "ket",
16895
+ "keta",
16896
+ "keñver",
16897
+ "keñverel",
16898
+ "keñverius",
16899
+ "kichen",
16900
+ "kichenik",
16901
+ "kit",
16902
+ "kiz",
16903
+ "klak",
16904
+ "klek",
16905
+ "klik",
16906
+ "komprenet",
16907
+ "komz",
16908
+ "kont",
16909
+ "korf",
16910
+ "korre",
16911
+ "koulskoude",
16912
+ "koulz",
16913
+ "koust",
16914
+ "krak",
16915
+ "krampouezh",
16916
+ "krec'h",
16917
+ "kreiz",
16918
+ "kuit",
16919
+ "kwir",
16920
+ "l:",
16921
+ "la",
16922
+ "laez",
16923
+ "laoskel",
16924
+ "laouen",
16925
+ "lavar",
16926
+ "lavaret",
16927
+ "lavarout",
16928
+ "lec'h",
16929
+ "lein",
16930
+ "leizh",
16931
+ "lerc'h",
16932
+ "leun",
16933
+ "leuskel",
16934
+ "lew",
16935
+ "lies",
16936
+ "liesañ",
16937
+ "lod",
16938
+ "lusk",
16939
+ "lâr",
16940
+ "lârout",
16941
+ "m:",
16942
+ "ma",
16943
+ "ma'z",
16944
+ "mac'h",
16945
+ "mac'hat",
16946
+ "mac'hañ",
16947
+ "mac'hoc'h",
16948
+ "mad",
16949
+ "maez",
16950
+ "maksimal",
16951
+ "mann",
16952
+ "mar",
16953
+ "mard",
16954
+ "marg",
16955
+ "marzh",
16956
+ "mat",
16957
+ "mañ",
16958
+ "me",
16959
+ "memes",
16960
+ "memestra",
16961
+ "merkapl",
16962
+ "mersi",
16963
+ "mes",
16964
+ "mesk",
16965
+ "met",
16966
+ "meur",
16967
+ "mil",
16968
+ "minimal",
16969
+ "moan",
16970
+ "moaniaat",
16971
+ "mod",
16972
+ "mont",
16973
+ "mout",
16974
+ "mui",
16975
+ "muiañ",
16976
+ "muioc'h",
16977
+ "n",
16978
+ "n'",
16979
+ "n:",
15782
16980
  "na",
15783
- "nao",
15784
- "nas",
15785
- "nem",
15786
- "nesse",
15787
- "neste",
15788
- "nos",
16981
+ "nag",
16982
+ "naontek",
16983
+ "naturel",
16984
+ "nav",
16985
+ "navet",
16986
+ "ne",
16987
+ "nebeudig",
16988
+ "nebeut",
16989
+ "nebeutañ",
16990
+ "nebeutoc'h",
16991
+ "neketa",
16992
+ "nemedoc'h",
16993
+ "nemedomp",
16994
+ "nemedon",
16995
+ "nemedor",
16996
+ "nemedout",
16997
+ "nemet",
16998
+ "nemetañ",
16999
+ "nemete",
17000
+ "nemeti",
17001
+ "nemeto",
17002
+ "nemeur",
17003
+ "neoac'h",
17004
+ "nepell",
17005
+ "nerzh",
17006
+ "nes",
17007
+ "neseser",
17008
+ "netra",
17009
+ "neubeudoù",
17010
+ "neuhe",
17011
+ "neuze",
17012
+ "nevez",
17013
+ "newazh",
17014
+ "nez",
17015
+ "ni",
17016
+ "nikun",
17017
+ "niverus",
17018
+ "nul",
15789
17019
  "o",
15790
- "os",
15791
- "ou",
15792
- "outra",
15793
- "outras",
15794
- "outro",
15795
- "outros",
15796
- "pelas",
15797
- "pelo",
15798
- "pelos",
15799
- "perante",
15800
- "pois",
15801
- "por",
15802
- "porque",
15803
- "portanto",
15804
- "propios",
15805
- "proprio",
15806
- "quais",
15807
- "qual",
15808
- "qualquer",
15809
- "quando",
15810
- "quanto",
15811
- "que",
15812
- "quem",
15813
- "quer",
17020
+ "o:",
17021
+ "oa",
17022
+ "oac'h",
17023
+ "oad",
17024
+ "oamp",
17025
+ "oan",
17026
+ "oant",
17027
+ "oar",
17028
+ "oas",
17029
+ "ober",
17030
+ "oc'h",
17031
+ "oc'ho",
17032
+ "oc'hola",
17033
+ "oc'hpenn",
17034
+ "oh",
17035
+ "ohe",
17036
+ "ollé",
17037
+ "olole",
17038
+ "olé",
17039
+ "omp",
17040
+ "on",
17041
+ "ordin",
17042
+ "ordinal",
17043
+ "ouejoc'h",
17044
+ "ouejod",
17045
+ "ouejomp",
17046
+ "ouejont",
17047
+ "ouejout",
17048
+ "ouek",
17049
+ "ouezas",
17050
+ "ouezi",
17051
+ "ouezimp",
17052
+ "ouezin",
17053
+ "ouezint",
17054
+ "ouezis",
17055
+ "ouezo",
17056
+ "ouezoc'h",
17057
+ "ouezor",
17058
+ "ouf",
17059
+ "oufe",
17060
+ "oufec'h",
17061
+ "oufed",
17062
+ "oufemp",
17063
+ "oufen",
17064
+ "oufent",
17065
+ "oufes",
17066
+ "ouie",
17067
+ "ouiec'h",
17068
+ "ouied",
17069
+ "ouiemp",
17070
+ "ouien",
17071
+ "ouient",
17072
+ "ouies",
17073
+ "ouije",
17074
+ "ouijec'h",
17075
+ "ouijed",
17076
+ "ouijemp",
17077
+ "ouijen",
17078
+ "ouijent",
17079
+ "ouijes",
17080
+ "out",
17081
+ "outañ",
17082
+ "outi",
17083
+ "outo",
17084
+ "ouzer",
17085
+ "ouzh",
17086
+ "ouzhin",
17087
+ "ouzhit",
17088
+ "ouzhoc'h",
17089
+ "ouzhomp",
17090
+ "ouzhor",
17091
+ "ouzhpenn",
17092
+ "ouzhpennik",
17093
+ "ouzoc'h",
17094
+ "ouzomp",
17095
+ "ouzon",
17096
+ "ouzont",
17097
+ "ouzout",
17098
+ "p'",
17099
+ "p:",
17100
+ "pa",
17101
+ "pad",
17102
+ "padal",
17103
+ "paf",
17104
+ "pan",
17105
+ "panevedeoc'h",
17106
+ "panevedo",
17107
+ "panevedomp",
17108
+ "panevedon",
17109
+ "panevedout",
17110
+ "panevet",
17111
+ "panevetañ",
17112
+ "paneveti",
17113
+ "pas",
17114
+ "paseet",
17115
+ "pe",
17116
+ "peadra",
17117
+ "peder",
17118
+ "pedervet",
17119
+ "pedervetvet",
17120
+ "pefe",
17121
+ "pegeit",
17122
+ "pegement",
17123
+ "pegen",
17124
+ "pegiz",
17125
+ "pegoulz",
17126
+ "pehini",
17127
+ "pelec'h",
17128
+ "pell",
17129
+ "pemod",
17130
+ "pemp",
17131
+ "pempved",
17132
+ "pemzek",
17133
+ "penaos",
17134
+ "penn",
17135
+ "peogwir",
17136
+ "peotramant",
17137
+ "pep",
17138
+ "perak",
17139
+ "perc'hennañ",
17140
+ "pergen",
17141
+ "permetiñ",
17142
+ "peseurt",
17143
+ "pet",
17144
+ "petiaoul",
17145
+ "petoare",
17146
+ "petra",
17147
+ "peur",
17148
+ "peurgetket",
17149
+ "peurheñvel",
17150
+ "peurliesañ",
17151
+ "peurvuiañ",
17152
+ "peus",
17153
+ "peustost",
17154
+ "peuz",
17155
+ "pevar",
17156
+ "pevare",
17157
+ "pevarevet",
17158
+ "pevarzek",
17159
+ "pez",
17160
+ "peze",
17161
+ "pezh",
17162
+ "pff",
17163
+ "pfft",
17164
+ "pfut",
17165
+ "picher",
17166
+ "pif",
17167
+ "pife",
17168
+ "pign",
17169
+ "pije",
17170
+ "pikol",
17171
+ "pitiaoul",
17172
+ "piv",
17173
+ "plaouf",
17174
+ "plok",
17175
+ "plouf",
17176
+ "po",
17177
+ "poa",
17178
+ "poelladus",
17179
+ "pof",
17180
+ "pok",
17181
+ "posupl",
17182
+ "pouah",
17183
+ "pourc'henn",
17184
+ "prest",
17185
+ "prestik",
17186
+ "prim",
17187
+ "prin",
17188
+ "provostapl",
17189
+ "pst",
17190
+ "pu",
17191
+ "pur",
17192
+ "r:",
17193
+ "ra",
17194
+ "rae",
17195
+ "raec'h",
17196
+ "raed",
17197
+ "raemp",
17198
+ "raen",
17199
+ "raent",
17200
+ "raes",
17201
+ "rafe",
17202
+ "rafec'h",
17203
+ "rafed",
17204
+ "rafemp",
17205
+ "rafen",
17206
+ "rafent",
17207
+ "rafes",
17208
+ "rag",
17209
+ "raimp",
17210
+ "raint",
17211
+ "raio",
17212
+ "raje",
17213
+ "rajec'h",
17214
+ "rajed",
17215
+ "rajemp",
17216
+ "rajen",
17217
+ "rajent",
17218
+ "rajes",
17219
+ "rak",
17220
+ "ral",
17221
+ "ran",
17222
+ "rankout",
17223
+ "raok",
17224
+ "razh",
17225
+ "re",
17226
+ "reas",
17227
+ "reer",
17228
+ "regennoù",
17229
+ "reiñ",
17230
+ "rejoc'h",
17231
+ "rejod",
17232
+ "rejomp",
17233
+ "rejont",
17234
+ "rejout",
17235
+ "rener",
17236
+ "rentañ",
17237
+ "reoc'h",
17238
+ "reomp",
17239
+ "reont",
17240
+ "reor",
17241
+ "reot",
17242
+ "resis",
17243
+ "ret",
17244
+ "reve",
17245
+ "rez",
17246
+ "ri",
17247
+ "rik",
17248
+ "rin",
17249
+ "ris",
17250
+ "rit",
17251
+ "rouez",
17252
+ "s:",
17253
+ "sac'h",
17254
+ "sant",
17255
+ "sav",
17256
+ "sañset",
15814
17257
  "se",
15815
- "seja",
15816
- "sem",
15817
- "sendo",
15818
- "seu",
15819
- "seus",
15820
- "sob",
15821
- "sobre",
15822
- "sua",
15823
- "suas",
17258
+ "sed",
17259
+ "seitek",
17260
+ "seizh",
17261
+ "seizhvet",
17262
+ "sell",
17263
+ "sellit",
17264
+ "ser",
17265
+ "setu",
17266
+ "seul",
17267
+ "seurt",
17268
+ "siwazh",
17269
+ "skignañ",
17270
+ "skoaz",
17271
+ "skouer",
17272
+ "sort",
17273
+ "souden",
17274
+ "souvitañ",
17275
+ "soñj",
17276
+ "speriañ",
17277
+ "spririñ",
17278
+ "stad",
17279
+ "stlabezañ",
17280
+ "stop",
17281
+ "stranañ",
17282
+ "strewiñ",
17283
+ "strishaat",
17284
+ "stumm",
17285
+ "sujed",
17286
+ "surtoud",
17287
+ "t:",
17288
+ "ta",
17289
+ "taer",
17290
+ "tailh",
17291
+ "tak",
15824
17292
  "tal",
15825
- "tambem",
15826
- "teu",
17293
+ "talvoudegezh",
17294
+ "tamm",
17295
+ "tanav",
17296
+ "taol",
17297
+ "te",
17298
+ "techet",
17299
+ "teir",
17300
+ "teirvet",
17301
+ "telt",
17302
+ "teltenn",
15827
17303
  "teus",
15828
- "toda",
15829
- "todas",
15830
- "todo",
15831
- "todos",
15832
- "tua",
15833
- "tuas",
15834
- "tudo",
15835
- "um",
15836
- "uma",
15837
- "umas",
15838
- "uns"
17304
+ "teut",
17305
+ "teuteu",
17306
+ "ti",
17307
+ "tik",
17308
+ "toa",
17309
+ "tok",
17310
+ "tost",
17311
+ "tostig",
17312
+ "toud",
17313
+ "touesk",
17314
+ "touez",
17315
+ "toull",
17316
+ "tra",
17317
+ "trantenn",
17318
+ "traoñ",
17319
+ "trawalc'h",
17320
+ "tre",
17321
+ "trede",
17322
+ "tregont",
17323
+ "tremenet",
17324
+ "tri",
17325
+ "trivet",
17326
+ "triwec'h",
17327
+ "trizek",
17328
+ "tro",
17329
+ "trugarez",
17330
+ "trumm",
17331
+ "tsoin",
17332
+ "tsouin",
17333
+ "tu",
17334
+ "tud",
17335
+ "u:",
17336
+ "ugent",
17337
+ "uhel",
17338
+ "uhelañ",
17339
+ "ul",
17340
+ "un",
17341
+ "unan",
17342
+ "unanez",
17343
+ "unanig",
17344
+ "unnek",
17345
+ "unnekvet",
17346
+ "ur",
17347
+ "urzh",
17348
+ "us",
17349
+ "v:",
17350
+ "va",
17351
+ "vale",
17352
+ "van",
17353
+ "vare",
17354
+ "vat",
17355
+ "vefe",
17356
+ "vefec'h",
17357
+ "vefed",
17358
+ "vefemp",
17359
+ "vefen",
17360
+ "vefent",
17361
+ "vefes",
17362
+ "vesk",
17363
+ "vete",
17364
+ "vez",
17365
+ "vezan",
17366
+ "vezañ",
17367
+ "veze",
17368
+ "vezec'h",
17369
+ "vezed",
17370
+ "vezemp",
17371
+ "vezen",
17372
+ "vezent",
17373
+ "vezer",
17374
+ "vezes",
17375
+ "vezez",
17376
+ "vezit",
17377
+ "vezomp",
17378
+ "vezont",
17379
+ "vi",
17380
+ "vihan",
17381
+ "vihanañ",
17382
+ "vije",
17383
+ "vijec'h",
17384
+ "vijed",
17385
+ "vijemp",
17386
+ "vijen",
17387
+ "vijent",
17388
+ "vijes",
17389
+ "viken",
17390
+ "vimp",
17391
+ "vin",
17392
+ "vint",
17393
+ "vior",
17394
+ "viot",
17395
+ "virviken",
17396
+ "viskoazh",
17397
+ "vlan",
17398
+ "vlaou",
17399
+ "vo",
17400
+ "vod",
17401
+ "voe",
17402
+ "voec'h",
17403
+ "voed",
17404
+ "voemp",
17405
+ "voen",
17406
+ "voent",
17407
+ "voes",
17408
+ "vont",
17409
+ "vostapl",
17410
+ "vrac'h",
17411
+ "vrasañ",
17412
+ "vremañ",
17413
+ "w:",
17414
+ "walc'h",
17415
+ "war",
17416
+ "warnañ",
17417
+ "warni",
17418
+ "warno",
17419
+ "warnoc'h",
17420
+ "warnomp",
17421
+ "warnon",
17422
+ "warnor",
17423
+ "warnout",
17424
+ "wazh",
17425
+ "wech",
17426
+ "wechoù",
17427
+ "well",
17428
+ "y:",
17429
+ "you",
17430
+ "youadenn",
17431
+ "youc'hadenn",
17432
+ "youc'hou",
17433
+ "z:",
17434
+ "za",
17435
+ "zan",
17436
+ "zaw",
17437
+ "zeu",
17438
+ "zi",
17439
+ "ziar",
17440
+ "zigarez",
17441
+ "ziget",
17442
+ "zindan",
17443
+ "zioc'h",
17444
+ "ziouzh",
17445
+ "zirak",
17446
+ "zivout",
17447
+ "ziwar",
17448
+ "ziwezhañ",
17449
+ "zo",
17450
+ "zoken",
17451
+ "zokenoc'h",
17452
+ "zouesk",
17453
+ "zouez",
17454
+ "zro",
17455
+ "zu"
15839
17456
  ];
15840
17457
  const bul = [
15841
17458
  "а",
@@ -27491,22 +29108,32 @@ const tur = [
27491
29108
  "şöyle"
27492
29109
  ];
27493
29110
  const ukr = [
29111
+ "а",
29112
+ "або",
27494
29113
  "авжеж",
27495
29114
  "адже",
29115
+ "аж",
27496
29116
  "але",
29117
+ "ані",
27497
29118
  "б",
27498
29119
  "без",
29120
+ "би",
29121
+ "бо",
27499
29122
  "був",
27500
29123
  "була",
27501
29124
  "були",
27502
29125
  "було",
27503
29126
  "бути",
27504
29127
  "більш",
29128
+ "в",
27505
29129
  "вам",
29130
+ "вами",
27506
29131
  "вас",
27507
29132
  "весь",
29133
+ "вже",
27508
29134
  "вздовж",
27509
29135
  "ви",
29136
+ "від",
27510
29137
  "вниз",
27511
29138
  "внизу",
27512
29139
  "вона",
@@ -27515,55 +29142,138 @@ const ukr = [
27515
29142
  "все",
27516
29143
  "всередині",
27517
29144
  "всіх",
29145
+ "вся",
27518
29146
  "від",
27519
29147
  "він",
27520
29148
  "да",
27521
29149
  "давай",
27522
29150
  "давати",
27523
29151
  "де",
29152
+ "десь",
27524
29153
  "дещо",
27525
29154
  "для",
27526
29155
  "до",
29156
+ "є",
29157
+ "ж",
29158
+ "же",
27527
29159
  "з",
29160
+ "за",
27528
29161
  "завжди",
27529
29162
  "замість",
29163
+ "зі",
29164
+ "і",
29165
+ "із",
29166
+ "інших",
29167
+ "її",
29168
+ "їй",
29169
+ "їм",
29170
+ "їх",
27530
29171
  "й",
29172
+ "його",
29173
+ "йому",
27531
29174
  "коли",
27532
29175
  "ледве",
29176
+ "лиш",
27533
29177
  "майже",
29178
+ "мене",
29179
+ "мені",
27534
29180
  "ми",
29181
+ "між",
29182
+ "мій",
29183
+ "мною",
29184
+ "мов",
29185
+ "мого",
29186
+ "моєї",
29187
+ "моє",
29188
+ "може",
29189
+ "мої",
29190
+ "моїх",
29191
+ "моя",
29192
+ "на",
29193
+ "над",
27535
29194
  "навколо",
27536
29195
  "навіть",
27537
29196
  "нам",
29197
+ "нами",
29198
+ "нас",
29199
+ "наче",
29200
+ "наш",
29201
+ "не",
29202
+ "нє",
29203
+ "неї",
29204
+ "нема",
29205
+ "немов",
29206
+ "неначе",
29207
+ "нею",
29208
+ "ним",
29209
+ "ними",
29210
+ "них",
29211
+ "ні",
29212
+ "ніби",
29213
+ "ніщо",
29214
+ "нього",
29215
+ "о",
29216
+ "ось",
27538
29217
  "от",
27539
29218
  "отже",
27540
29219
  "отож",
29220
+ "під",
29221
+ "по",
27541
29222
  "поза",
27542
29223
  "про",
27543
29224
  "під",
29225
+ "сам",
29226
+ "сама",
29227
+ "свій",
29228
+ "свої",
29229
+ "своя",
29230
+ "свою",
29231
+ "себе",
29232
+ "собі",
27544
29233
  "та",
29234
+ "там",
27545
29235
  "так",
29236
+ "така",
27546
29237
  "такий",
27547
29238
  "також",
29239
+ "твій",
29240
+ "твого",
29241
+ "твоєї",
29242
+ "твої",
29243
+ "твоя",
27548
29244
  "те",
29245
+ "тебе",
27549
29246
  "ти",
29247
+ "ті",
29248
+ "тільки",
29249
+ "то",
29250
+ "тобі",
29251
+ "тобою",
27550
29252
  "тобто",
29253
+ "тоді",
27551
29254
  "тож",
29255
+ "той",
27552
29256
  "тощо",
29257
+ "тут",
29258
+ "у",
29259
+ "хіба",
29260
+ "хоч",
27553
29261
  "хоча",
27554
29262
  "це",
27555
29263
  "цей",
29264
+ "ці",
29265
+ "ця",
27556
29266
  "чи",
27557
29267
  "чого",
29268
+ "ще",
27558
29269
  "що",
29270
+ "щоб",
29271
+ "щось",
29272
+ "я",
27559
29273
  "як",
29274
+ "яка",
27560
29275
  "який",
27561
- "якої",
27562
- "є",
27563
- "із",
27564
- "інших",
27565
- "їх",
27566
- "її"
29276
+ "якої"
27567
29277
  ];
27568
29278
  const urd = [
27569
29279
  "آئی",
@@ -29476,6 +31186,7 @@ class TinaAdminApi {
29476
31186
  relativePath
29477
31187
  filename
29478
31188
  extension
31189
+ hasReferences
29479
31190
  }
29480
31191
  }
29481
31192
  }
@@ -29567,6 +31278,9 @@ class TinaAdminApi {
29567
31278
  document(collection:$collection, relativePath:$relativePath) {
29568
31279
  ... on Document {
29569
31280
  _values
31281
+ _sys {
31282
+ hasReferences
31283
+ }
29570
31284
  }
29571
31285
  }
29572
31286
  }`;
@@ -31190,6 +32904,7 @@ const CollectionListPage = () => {
31190
32904
  const [vars, setVars] = React__default.useState({
31191
32905
  collection: collectionName,
31192
32906
  relativePath: "",
32907
+ relativePathWithoutExtension: "",
31193
32908
  newRelativePath: "",
31194
32909
  filterField: "",
31195
32910
  folderName: "",
@@ -31231,6 +32946,7 @@ const CollectionListPage = () => {
31231
32946
  ...old,
31232
32947
  collection: collectionName,
31233
32948
  relativePath: "",
32949
+ relativePathWithoutExtension: "",
31234
32950
  newRelativePath: "",
31235
32951
  filterField: "",
31236
32952
  startsWith: "",
@@ -31256,6 +32972,7 @@ const CollectionListPage = () => {
31256
32972
  collectionName === vars.collection ? vars : {
31257
32973
  collection: collectionName,
31258
32974
  relativePath: "",
32975
+ relativePathWithoutExtension: "",
31259
32976
  newRelativePath: "",
31260
32977
  filterField: "",
31261
32978
  startsWith: "",
@@ -31293,6 +33010,23 @@ const CollectionListPage = () => {
31293
33010
  DeleteModal,
31294
33011
  {
31295
33012
  filename: vars.relativePath,
33013
+ checkRefsFunc: async () => {
33014
+ var _a2, _b2;
33015
+ try {
33016
+ const doc = await admin.fetchDocument(
33017
+ collection.name,
33018
+ vars.relativePath,
33019
+ true
33020
+ );
33021
+ return (_b2 = (_a2 = doc == null ? void 0 : doc.document) == null ? void 0 : _a2._sys) == null ? void 0 : _b2.hasReferences;
33022
+ } catch (error) {
33023
+ cms.alerts.error(
33024
+ "Document was not found, ask a developer for help or check the console for an error message"
33025
+ );
33026
+ console.error(error);
33027
+ throw error;
33028
+ }
33029
+ },
31296
33030
  deleteFunc: async () => {
31297
33031
  try {
31298
33032
  await admin.deleteDocument(vars);
@@ -31301,6 +33035,12 @@ const CollectionListPage = () => {
31301
33035
  );
31302
33036
  reFetchCollection();
31303
33037
  } catch (error) {
33038
+ if (error.message.indexOf("has references")) {
33039
+ cms.alerts.error(
33040
+ error.message.split("\n ").filter(Boolean)[1]
33041
+ );
33042
+ return;
33043
+ }
31304
33044
  cms.alerts.warn(
31305
33045
  "Document was not deleted, ask a developer for help or check the console for an error message"
31306
33046
  );
@@ -31334,7 +33074,7 @@ const CollectionListPage = () => {
31334
33074
  ), renameModalOpen && /* @__PURE__ */ React__default.createElement(
31335
33075
  RenameModal,
31336
33076
  {
31337
- filename: vars.relativePath,
33077
+ filename: vars.relativePathWithoutExtension,
31338
33078
  newRelativePath: vars.newRelativePath,
31339
33079
  setNewRelativePath: (newRelativePath) => {
31340
33080
  setVars((vars2) => {
@@ -31352,6 +33092,12 @@ const CollectionListPage = () => {
31352
33092
  cms.alerts.info("Document was successfully renamed");
31353
33093
  reFetchCollection();
31354
33094
  } catch (error) {
33095
+ if (error.message.indexOf("has references")) {
33096
+ cms.alerts.error(
33097
+ error.message.split("\n ").filter(Boolean)[1]
33098
+ );
33099
+ return;
33100
+ }
31355
33101
  cms.alerts.warn(
31356
33102
  "Document was not renamed, ask a developer for help or check the console for an error message"
31357
33103
  );
@@ -31649,6 +33395,9 @@ const CollectionListPage = () => {
31649
33395
  setVars((old) => ({
31650
33396
  ...old,
31651
33397
  collection: collectionName,
33398
+ relativePathWithoutExtension: document2.node._sys.breadcrumbs.join(
33399
+ "/"
33400
+ ),
31652
33401
  relativePath: document2.node._sys.breadcrumbs.join(
31653
33402
  "/"
31654
33403
  ) + document2.node._sys.extension,
@@ -31671,6 +33420,9 @@ const CollectionListPage = () => {
31671
33420
  setVars((old) => ({
31672
33421
  ...old,
31673
33422
  collection: collectionName,
33423
+ relativePathWithoutExtension: document2.node._sys.breadcrumbs.join(
33424
+ "/"
33425
+ ),
31674
33426
  relativePath: document2.node._sys.breadcrumbs.join(
31675
33427
  "/"
31676
33428
  ) + document2.node._sys.extension,
@@ -31825,8 +33577,19 @@ const Breadcrumb = ({ folder, navigate, collectionName }) => {
31825
33577
  const NoDocumentsPlaceholder = () => {
31826
33578
  return /* @__PURE__ */ React__default.createElement("div", { className: "text-center px-5 py-3 flex flex-col items-center justify-center shadow border border-gray-100 bg-gray-50 border-b border-gray-200 w-full max-w-full rounded-lg" }, /* @__PURE__ */ React__default.createElement("p", { className: "text-base italic font-medium text-gray-300" }, "No documents found."));
31827
33579
  };
31828
- const DeleteModal = ({ close: close2, deleteFunc, filename }) => {
31829
- return /* @__PURE__ */ React__default.createElement(Modal, null, /* @__PURE__ */ React__default.createElement(PopupModal, null, /* @__PURE__ */ React__default.createElement(ModalHeader, { close: close2 }, "Delete ", filename), /* @__PURE__ */ React__default.createElement(ModalBody, { padded: true }, /* @__PURE__ */ React__default.createElement("p", null, `Are you sure you want to delete ${filename}?`)), /* @__PURE__ */ React__default.createElement(ModalActions, null, /* @__PURE__ */ React__default.createElement(Button$1, { style: { flexGrow: 2 }, onClick: close2 }, "Cancel"), /* @__PURE__ */ React__default.createElement(
33580
+ const DeleteModal = ({
33581
+ close: close2,
33582
+ deleteFunc,
33583
+ checkRefsFunc,
33584
+ filename
33585
+ }) => {
33586
+ const [hasRefs, setHasRefs] = React__default.useState();
33587
+ useEffect(() => {
33588
+ checkRefsFunc().then((result) => {
33589
+ setHasRefs(result);
33590
+ });
33591
+ }, [filename, checkRefsFunc]);
33592
+ return /* @__PURE__ */ React__default.createElement(Modal, null, /* @__PURE__ */ React__default.createElement(PopupModal, null, /* @__PURE__ */ React__default.createElement(ModalHeader, { close: close2 }, "Delete ", filename), /* @__PURE__ */ React__default.createElement(ModalBody, { padded: true }, /* @__PURE__ */ React__default.createElement("p", null, `Are you sure you want to delete ${filename}?${hasRefs ? " References to this document will also be deleted." : ""}`)), /* @__PURE__ */ React__default.createElement(ModalActions, null, /* @__PURE__ */ React__default.createElement(Button$1, { style: { flexGrow: 2 }, onClick: close2 }, "Cancel"), /* @__PURE__ */ React__default.createElement(
31830
33593
  Button$1,
31831
33594
  {
31832
33595
  style: { flexGrow: 3 },
@@ -31872,7 +33635,7 @@ const RenameModal = ({
31872
33635
  newRelativePath,
31873
33636
  setNewRelativePath
31874
33637
  }) => {
31875
- return /* @__PURE__ */ React__default.createElement(Modal, null, /* @__PURE__ */ React__default.createElement(PopupModal, null, /* @__PURE__ */ React__default.createElement(ModalHeader, { close: close2 }, "Rename ", filename), /* @__PURE__ */ React__default.createElement(ModalBody, { padded: true }, /* @__PURE__ */ React__default.createElement(React__default.Fragment, null, /* @__PURE__ */ React__default.createElement("p", { className: "mb-4" }, "Are you sure you want to rename ", /* @__PURE__ */ React__default.createElement("strong", null, filename), "? TinaCMS uses the filename as the ID; renaming this file could result in unresolved references."), /* @__PURE__ */ React__default.createElement(
33638
+ return /* @__PURE__ */ React__default.createElement(Modal, null, /* @__PURE__ */ React__default.createElement(PopupModal, null, /* @__PURE__ */ React__default.createElement(ModalHeader, { close: close2 }, "Rename ", filename), /* @__PURE__ */ React__default.createElement(ModalBody, { padded: true }, /* @__PURE__ */ React__default.createElement(React__default.Fragment, null, /* @__PURE__ */ React__default.createElement("p", { className: "mb-4" }, "Are you sure you want to rename ", /* @__PURE__ */ React__default.createElement("strong", null, filename), "?"), /* @__PURE__ */ React__default.createElement(
31876
33639
  BaseTextField,
31877
33640
  {
31878
33641
  placeholder: "Enter a new name for the document's file",
@@ -31887,7 +33650,8 @@ const RenameModal = ({
31887
33650
  onClick: async () => {
31888
33651
  await renameFunc();
31889
33652
  close2();
31890
- }
33653
+ },
33654
+ disabled: !newRelativePath || newRelativePath === filename
31891
33655
  },
31892
33656
  "Rename"
31893
33657
  ))));
@@ -32558,15 +34322,24 @@ const IndexingPage = () => {
32558
34322
  }
32559
34323
  }
32560
34324
  if (state === "creatingPR") {
32561
- const foo = await tinaApi.createPullRequest({
32562
- baseBranch,
32563
- branch,
32564
- title: `${branch.replace("tina/", "").replace("-", " ")} (PR from TinaCMS)`
32565
- });
32566
- console.log("PR created", foo);
32567
- cms.alerts.success("Pull request created.");
32568
- localStorage.setItem("tina.createBranchState", "done");
32569
- setState("done");
34325
+ try {
34326
+ const foo = await tinaApi.createPullRequest({
34327
+ baseBranch,
34328
+ branch,
34329
+ title: `${branch.replace("tina/", "").replace("-", " ")} (PR from TinaCMS)`
34330
+ });
34331
+ console.log("PR created", foo);
34332
+ cms.alerts.success("Pull request created.");
34333
+ localStorage.setItem("tina.createBranchState", "done");
34334
+ setState("done");
34335
+ } catch (e) {
34336
+ console.error(e);
34337
+ cms.alerts.error("Failed to create PR");
34338
+ setErrorMessage(
34339
+ "Failed to create PR, please try again. If the problem persists please contact support."
34340
+ );
34341
+ setState("error");
34342
+ }
32570
34343
  }
32571
34344
  if (state === "done") {
32572
34345
  window.location.href = back;
@@ -33188,5 +34961,6 @@ export {
33188
34961
  useScreenPlugin,
33189
34962
  useTinaAuthRedirect,
33190
34963
  wrapFieldWithError,
34964
+ wrapFieldWithNoHeader,
33191
34965
  wrapFieldsWithMeta
33192
34966
  };