tinacms 0.0.0-ad8dbc0-20241003000436 → 0.0.0-ad9a889-20250218035304

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 (38) hide show
  1. package/dist/admin/types.d.ts +3 -0
  2. package/dist/cache/node-cache.d.ts +1 -0
  3. package/dist/client.js +91 -62
  4. package/dist/client.mjs +50 -36
  5. package/dist/index.d.ts +1 -1
  6. package/dist/index.js +1687 -1099
  7. package/dist/index.mjs +1677 -1085
  8. package/dist/node-cache-5e8db9f0.mjs +63 -0
  9. package/dist/react.d.ts +1 -0
  10. package/dist/react.js +10 -1
  11. package/dist/react.mjs +10 -1
  12. package/dist/rich-text/index.d.ts +3 -0
  13. package/dist/rich-text/index.js +45 -12
  14. package/dist/rich-text/index.mjs +45 -12
  15. package/dist/toolkit/fields/components/reference/reference-select.d.ts +2 -2
  16. package/dist/toolkit/fields/plugins/mdx-field-plugin/index.d.ts +4 -1
  17. package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/components/fixed-toolbar-buttons.d.ts +0 -4
  18. package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/components/plate-ui/icons.d.ts +2 -0
  19. package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/components/plate-ui/mermaid-element.d.ts +11 -0
  20. package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/components/plate-ui/mermaid-toolbar-button.d.ts +20 -0
  21. package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/components/plate-ui/resizable.d.ts +39 -0
  22. package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/components/plate-ui/table-cell-element.d.ts +27 -0
  23. package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/components/plate-ui/table-dropdown-menu.d.ts +3 -0
  24. package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/components/plate-ui/table-element.d.ts +14 -0
  25. package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/components/plate-ui/table-row-element.d.ts +13 -0
  26. package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/components/plate-ui/text-area.d.ts +5 -0
  27. package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/index.d.ts +1 -1
  28. package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/plugins/core/common.d.ts +1 -0
  29. package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/plugins/custom/mermaid-plugin.d.ts +2 -0
  30. package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/plugins/ui/code-block/index.d.ts +4 -2
  31. package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/plugins/ui/components.d.ts +58 -0
  32. package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/toolbar/toolbar-overrides.d.ts +11 -3
  33. package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/toolbar/toolbar-provider.d.ts +3 -3
  34. package/dist/toolkit/fields/plugins/wrap-field-with-meta.d.ts +8 -0
  35. package/dist/unifiedClient/index.d.ts +8 -1
  36. package/package.json +30 -28
  37. package/dist/__vite-browser-external-d06ac358.mjs +0 -4
  38. package/dist/node-cache-7fa2452c.mjs +0 -43
package/dist/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  (function(global, factory) {
2
- typeof exports === "object" && typeof module !== "undefined" ? factory(exports, require("zod"), require("react"), require("react-dom"), require("@udecode/plate"), require("slate-react"), require("@udecode/plate-slash-command"), require("@udecode/cn"), require("@udecode/plate-common"), require("@udecode/plate-heading"), require("class-variance-authority"), require("lucide-react"), require("@ariakit/react"), require("@udecode/plate-combobox"), require("@udecode/plate-code-block"), require("@monaco-editor/react"), require("@headlessui/react"), require("final-form-arrays"), require("final-form-set-field-data"), require("final-form"), require("react-final-form"), require("prop-types"), require("react-beautiful-dnd"), require("@radix-ui/react-popover"), require("react-color"), require("color-string"), require("react-dropzone"), require("@radix-ui/react-slot"), require("clsx"), require("tailwind-merge"), require("cmdk"), require("is-hotkey"), require("slate"), require("lodash.get"), require("moment"), require("date-fns"), require("@udecode/plate-link"), require("@radix-ui/react-toolbar"), require("@radix-ui/react-separator"), require("@radix-ui/react-tooltip"), require("@udecode/plate-paragraph"), require("@radix-ui/react-dropdown-menu"), require("@udecode/plate-block-quote"), require("@udecode/plate-floating"), require("@react-hook/window-size"), require("graphql"), require("graphql-tag"), require("@tinacms/schema-tools"), require("yup"), require("@graphql-inspector/core"), require("react-router-dom"), require("@tinacms/mdx")) : typeof define === "function" && define.amd ? define(["exports", "zod", "react", "react-dom", "@udecode/plate", "slate-react", "@udecode/plate-slash-command", "@udecode/cn", "@udecode/plate-common", "@udecode/plate-heading", "class-variance-authority", "lucide-react", "@ariakit/react", "@udecode/plate-combobox", "@udecode/plate-code-block", "@monaco-editor/react", "@headlessui/react", "final-form-arrays", "final-form-set-field-data", "final-form", "react-final-form", "prop-types", "react-beautiful-dnd", "@radix-ui/react-popover", "react-color", "color-string", "react-dropzone", "@radix-ui/react-slot", "clsx", "tailwind-merge", "cmdk", "is-hotkey", "slate", "lodash.get", "moment", "date-fns", "@udecode/plate-link", "@radix-ui/react-toolbar", "@radix-ui/react-separator", "@radix-ui/react-tooltip", "@udecode/plate-paragraph", "@radix-ui/react-dropdown-menu", "@udecode/plate-block-quote", "@udecode/plate-floating", "@react-hook/window-size", "graphql", "graphql-tag", "@tinacms/schema-tools", "yup", "@graphql-inspector/core", "react-router-dom", "@tinacms/mdx"], factory) : (global = typeof globalThis !== "undefined" ? globalThis : global || self, factory(global.tinacms = {}, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP));
3
- })(this, function(exports2, zod, React, reactDom, plate, slateReact, plateSlashCommand, cn$1, plateCommon, plateHeading, classVarianceAuthority, lucideReact, react, plateCombobox, plateCodeBlock, MonacoEditor, react$1, arrayMutators, setFieldData, finalForm, reactFinalForm, PropTypes, reactBeautifulDnd, PopoverPrimitive, pkg$1, pkg, dropzone, reactSlot, clsx, tailwindMerge, cmdk, isHotkey, slate, get, moment, dateFns, plateLink, ToolbarPrimitive, SeparatorPrimitive, TooltipPrimitive, plateParagraph, DropdownMenuPrimitive, plateBlockQuote, plateFloating, windowSize, graphql, gql, schemaTools, yup, core, reactRouterDom, mdx) {
2
+ typeof exports === "object" && typeof module !== "undefined" ? factory(exports, require("zod"), require("react"), require("react-dom"), require("@udecode/cn"), require("@udecode/plate"), require("@udecode/plate-common"), require("@udecode/plate-slash-command"), require("slate-react"), require("@udecode/plate-code-block"), require("@monaco-editor/react"), require("@headlessui/react"), require("class-variance-authority"), require("lucide-react"), require("mermaid"), require("@udecode/plate-heading"), require("@ariakit/react"), require("@udecode/plate-combobox"), require("@udecode/plate-table"), require("@udecode/plate-resizable"), require("@radix-ui/react-popover"), require("@radix-ui/react-slot"), require("@radix-ui/react-dropdown-menu"), require("@radix-ui/react-separator"), require("final-form-arrays"), require("final-form-set-field-data"), require("final-form"), require("react-final-form"), require("prop-types"), require("react-beautiful-dnd"), require("react-color"), require("color-string"), require("react-dropzone"), require("clsx"), require("tailwind-merge"), require("cmdk"), require("is-hotkey"), require("slate"), require("lodash.get"), require("moment"), require("date-fns"), require("@udecode/plate-link"), require("@radix-ui/react-toolbar"), require("@radix-ui/react-tooltip"), require("@udecode/plate-paragraph"), require("@udecode/plate-block-quote"), require("@udecode/plate-floating"), require("@react-hook/window-size"), require("graphql"), require("graphql-tag"), require("@tinacms/schema-tools"), require("yup"), require("@graphql-inspector/core"), require("react-router-dom"), require("@tinacms/mdx")) : typeof define === "function" && define.amd ? define(["exports", "zod", "react", "react-dom", "@udecode/cn", "@udecode/plate", "@udecode/plate-common", "@udecode/plate-slash-command", "slate-react", "@udecode/plate-code-block", "@monaco-editor/react", "@headlessui/react", "class-variance-authority", "lucide-react", "mermaid", "@udecode/plate-heading", "@ariakit/react", "@udecode/plate-combobox", "@udecode/plate-table", "@udecode/plate-resizable", "@radix-ui/react-popover", "@radix-ui/react-slot", "@radix-ui/react-dropdown-menu", "@radix-ui/react-separator", "final-form-arrays", "final-form-set-field-data", "final-form", "react-final-form", "prop-types", "react-beautiful-dnd", "react-color", "color-string", "react-dropzone", "clsx", "tailwind-merge", "cmdk", "is-hotkey", "slate", "lodash.get", "moment", "date-fns", "@udecode/plate-link", "@radix-ui/react-toolbar", "@radix-ui/react-tooltip", "@udecode/plate-paragraph", "@udecode/plate-block-quote", "@udecode/plate-floating", "@react-hook/window-size", "graphql", "graphql-tag", "@tinacms/schema-tools", "yup", "@graphql-inspector/core", "react-router-dom", "@tinacms/mdx"], factory) : (global = typeof globalThis !== "undefined" ? globalThis : global || self, factory(global.tinacms = {}, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP));
3
+ })(this, function(exports2, zod, React, reactDom, cn$1, plate, plateCommon, plateSlashCommand, slateReact, plateCodeBlock, MonacoEditor, react, classVarianceAuthority, lucideReact, mermaid, plateHeading, react$1, plateCombobox, plateTable, plateResizable, PopoverPrimitive, reactSlot, DropdownMenuPrimitive, SeparatorPrimitive, arrayMutators, setFieldData, finalForm, reactFinalForm, PropTypes, reactBeautifulDnd, pkg$1, pkg, dropzone, clsx, tailwindMerge, cmdk, isHotkey, slate, get, moment, dateFns, plateLink, ToolbarPrimitive, TooltipPrimitive, plateParagraph, plateBlockQuote, plateFloating, windowSize, graphql, gql, schemaTools, yup, core, reactRouterDom, mdx) {
4
4
  "use strict";var __defProp = Object.defineProperty;
5
5
  var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
6
6
  var __publicField = (obj, key, value) => {
@@ -26,13 +26,13 @@ var __publicField = (obj, key, value) => {
26
26
  }
27
27
  const React__namespace = /* @__PURE__ */ _interopNamespaceDefault(React);
28
28
  const PopoverPrimitive__namespace = /* @__PURE__ */ _interopNamespaceDefault(PopoverPrimitive);
29
+ const DropdownMenuPrimitive__namespace = /* @__PURE__ */ _interopNamespaceDefault(DropdownMenuPrimitive);
30
+ const SeparatorPrimitive__namespace = /* @__PURE__ */ _interopNamespaceDefault(SeparatorPrimitive);
29
31
  const pkg__namespace$1 = /* @__PURE__ */ _interopNamespaceDefault(pkg$1);
30
32
  const pkg__namespace = /* @__PURE__ */ _interopNamespaceDefault(pkg);
31
33
  const dropzone__namespace = /* @__PURE__ */ _interopNamespaceDefault(dropzone);
32
34
  const ToolbarPrimitive__namespace = /* @__PURE__ */ _interopNamespaceDefault(ToolbarPrimitive);
33
- const SeparatorPrimitive__namespace = /* @__PURE__ */ _interopNamespaceDefault(SeparatorPrimitive);
34
35
  const TooltipPrimitive__namespace = /* @__PURE__ */ _interopNamespaceDefault(TooltipPrimitive);
35
- const DropdownMenuPrimitive__namespace = /* @__PURE__ */ _interopNamespaceDefault(DropdownMenuPrimitive);
36
36
  const yup__namespace = /* @__PURE__ */ _interopNamespaceDefault(yup);
37
37
  const ModalProvider = ({ children }) => {
38
38
  const [modalRootContainerRef, setModalRootContainerRef] = React.useState(
@@ -774,6 +774,22 @@ var __publicField = (obj, key, value) => {
774
774
  );
775
775
  };
776
776
  }
777
+ function wrapFieldWithNoHeader(Field) {
778
+ return (props) => {
779
+ return /* @__PURE__ */ React__namespace.createElement(
780
+ FieldMeta,
781
+ {
782
+ name: props.input.name,
783
+ label: false,
784
+ description: "",
785
+ error: props.meta.error,
786
+ index: props.index,
787
+ tinaForm: props.tinaForm
788
+ },
789
+ /* @__PURE__ */ React__namespace.createElement(Field, { ...props })
790
+ );
791
+ };
792
+ }
777
793
  function wrapFieldWithError(Field) {
778
794
  return (props) => {
779
795
  return /* @__PURE__ */ React__namespace.createElement(
@@ -846,6 +862,16 @@ var __publicField = (obj, key, value) => {
846
862
  className,
847
863
  ...props
848
864
  }) => {
865
+ if (typeof children === "string") {
866
+ return /* @__PURE__ */ React__namespace.createElement(
867
+ "span",
868
+ {
869
+ className: `block font-sans text-xs italic font-light text-gray-400 pt-0.5 whitespace-normal m-0 ${className}`,
870
+ ...props,
871
+ dangerouslySetInnerHTML: { __html: children }
872
+ }
873
+ );
874
+ }
849
875
  return /* @__PURE__ */ React__namespace.createElement(
850
876
  "span",
851
877
  {
@@ -882,6 +908,20 @@ var __publicField = (obj, key, value) => {
882
908
  const useTemplates = () => {
883
909
  return React.useContext(EditorContext);
884
910
  };
911
+ const BlockquoteElement = cn$1.withRef(
912
+ ({ children, className, ...props }, ref) => {
913
+ return /* @__PURE__ */ React.createElement(
914
+ plateCommon.PlateElement,
915
+ {
916
+ asChild: true,
917
+ className: cn$1.cn("my-1 border-l-2 pl-6 italic", className),
918
+ ref,
919
+ ...props
920
+ },
921
+ /* @__PURE__ */ React.createElement("blockquote", null, children)
922
+ );
923
+ }
924
+ );
885
925
  function classNames$1(...classes) {
886
926
  return classes.filter(Boolean).join(" ");
887
927
  }
@@ -891,6 +931,503 @@ var __publicField = (obj, key, value) => {
891
931
  (c) => (c ^ crypto.getRandomValues(new Uint8Array(1))[0] & 15 >> c / 4).toString(16)
892
932
  );
893
933
  };
934
+ function ChevronDownIcon(props, svgRef) {
935
+ return /* @__PURE__ */ React__namespace.createElement("svg", Object.assign({
936
+ xmlns: "http://www.w3.org/2000/svg",
937
+ viewBox: "0 0 20 20",
938
+ fill: "currentColor",
939
+ "aria-hidden": "true",
940
+ ref: svgRef
941
+ }, props), /* @__PURE__ */ React__namespace.createElement("path", {
942
+ fillRule: "evenodd",
943
+ 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",
944
+ clipRule: "evenodd"
945
+ }));
946
+ }
947
+ const ForwardRef = React__namespace.forwardRef(ChevronDownIcon);
948
+ const ChevronDownIcon$1 = ForwardRef;
949
+ const Autocomplete = ({
950
+ value,
951
+ onChange,
952
+ defaultQuery,
953
+ items: items2
954
+ }) => {
955
+ const [query, setQuery] = React.useState(defaultQuery ?? "");
956
+ const filteredItems = React.useMemo(() => {
957
+ try {
958
+ const reFilter = new RegExp(query, "i");
959
+ const _items = items2.filter((item) => reFilter.test(item.label));
960
+ if (_items.length === 0)
961
+ return items2;
962
+ return _items;
963
+ } catch (err) {
964
+ return items2;
965
+ }
966
+ }, [items2, query]);
967
+ return /* @__PURE__ */ React.createElement(
968
+ react.Combobox,
969
+ {
970
+ value,
971
+ onChange,
972
+ as: "div",
973
+ className: "relative inline-block text-left z-20"
974
+ },
975
+ /* @__PURE__ */ React.createElement("div", { className: "mt-1" }, /* @__PURE__ */ React.createElement("div", { className: "relative w-full cursor-default overflow-hidden rounded-lg bg-white text-left shadow-md sm:text-sm" }, /* @__PURE__ */ React.createElement(
976
+ react.ComboboxInput,
977
+ {
978
+ 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",
979
+ displayValue: (item) => (item == null ? void 0 : item.label) ?? "Plain Text",
980
+ onChange: (event) => setQuery(event.target.value),
981
+ onClick: (ev) => ev.stopPropagation()
982
+ }
983
+ ), /* @__PURE__ */ React.createElement(react.ComboboxButton, { className: "absolute inset-y-0 right-0 flex items-center pr-2" }, /* @__PURE__ */ React.createElement(
984
+ ChevronDownIcon$1,
985
+ {
986
+ className: "h-5 w-5 text-gray-400",
987
+ "aria-hidden": "true"
988
+ }
989
+ )))),
990
+ /* @__PURE__ */ React.createElement(
991
+ react.Transition,
992
+ {
993
+ enter: "transition ease-out duration-100",
994
+ enterFrom: "transform opacity-0 scale-95",
995
+ enterTo: "transform opacity-100 scale-100",
996
+ leave: "transition ease-in duration-75",
997
+ leaveFrom: "transform opacity-100 scale-100",
998
+ leaveTo: "transform opacity-0 scale-95"
999
+ },
1000
+ /* @__PURE__ */ React.createElement(react.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.createElement(react.ComboboxOption, { key: item.key, value: item }, ({ focus }) => /* @__PURE__ */ React.createElement(
1001
+ "button",
1002
+ {
1003
+ className: classNames$1(
1004
+ focus ? "bg-gray-100 text-gray-900" : "text-gray-700",
1005
+ "block px-4 py-2 text-xs w-full text-right"
1006
+ )
1007
+ },
1008
+ item.render(item)
1009
+ ))))
1010
+ )
1011
+ );
1012
+ };
1013
+ MonacoEditor.loader.config({
1014
+ paths: { vs: "https://cdn.jsdelivr.net/npm/monaco-editor@0.31.1/min/vs" }
1015
+ });
1016
+ let retryCount = 0;
1017
+ const retryFocus = (ref) => {
1018
+ if (ref.current) {
1019
+ ref.current.focus();
1020
+ } else {
1021
+ if (retryCount < 30) {
1022
+ setTimeout(() => {
1023
+ retryCount = retryCount + 1;
1024
+ retryFocus(ref);
1025
+ }, 100);
1026
+ }
1027
+ }
1028
+ };
1029
+ const MINIMUM_HEIGHT = 75;
1030
+ const CodeBlock = ({
1031
+ attributes,
1032
+ editor,
1033
+ element,
1034
+ language: restrictLanguage,
1035
+ onChangeCallback,
1036
+ defaultValue,
1037
+ ...props
1038
+ }) => {
1039
+ const [navigateAway, setNavigateAway] = React.useState(null);
1040
+ const monaco = MonacoEditor.useMonaco();
1041
+ const monacoEditorRef = React.useRef(null);
1042
+ const selected = slateReact.useSelected();
1043
+ const [height, setHeight] = React.useState(MINIMUM_HEIGHT);
1044
+ React.useEffect(() => {
1045
+ if (selected && plateCommon.isCollapsed(editor.selection)) {
1046
+ retryFocus(monacoEditorRef);
1047
+ }
1048
+ }, [selected, monacoEditorRef.current]);
1049
+ const value = element.value || "";
1050
+ if (typeof value !== "string") {
1051
+ throw new Error("Element must be of type string for code block");
1052
+ }
1053
+ const language = restrictLanguage || element.lang;
1054
+ const id = React.useMemo(() => uuid(), []);
1055
+ const languages = React.useMemo(() => {
1056
+ const defaultLangSet = { "": "plain text" };
1057
+ if (!monaco)
1058
+ return defaultLangSet;
1059
+ return monaco.languages.getLanguages().reduce((ac, cv) => {
1060
+ if (cv.id === "plaintext")
1061
+ return ac;
1062
+ return { ...ac, [cv.id]: cv.id };
1063
+ }, defaultLangSet);
1064
+ }, [monaco]);
1065
+ React.useEffect(() => {
1066
+ if (monaco) {
1067
+ monaco.languages.typescript.typescriptDefaults.setEagerModelSync(true);
1068
+ monaco.languages.typescript.typescriptDefaults.setDiagnosticsOptions({
1069
+ // disable errors
1070
+ noSemanticValidation: true,
1071
+ noSyntaxValidation: true
1072
+ });
1073
+ }
1074
+ }, [monaco]);
1075
+ const items2 = Object.entries(languages).map(([key, label]) => ({
1076
+ key,
1077
+ label,
1078
+ render: (item) => item.label
1079
+ }));
1080
+ const currentItem = React.useMemo(() => {
1081
+ return items2.find((item) => item.key === language) ?? {
1082
+ key: "",
1083
+ label: "Plain Text"
1084
+ };
1085
+ }, [items2, language]);
1086
+ React.useEffect(() => {
1087
+ if (navigateAway) {
1088
+ setNavigateAway(null);
1089
+ switch (navigateAway) {
1090
+ case "remove":
1091
+ {
1092
+ plateCommon.focusEditor(editor);
1093
+ plateCommon.setNodes(
1094
+ editor,
1095
+ {
1096
+ type: "p",
1097
+ children: [{ text: "" }],
1098
+ lang: void 0,
1099
+ value: void 0
1100
+ },
1101
+ {
1102
+ match: (n) => {
1103
+ if (plateCommon.isElement(n) && n.type === element.type) {
1104
+ return true;
1105
+ }
1106
+ }
1107
+ }
1108
+ );
1109
+ }
1110
+ break;
1111
+ case "insertNext":
1112
+ {
1113
+ plateCommon.insertNodes(
1114
+ editor,
1115
+ [
1116
+ {
1117
+ type: plateCommon.ELEMENT_DEFAULT,
1118
+ children: [{ text: "" }],
1119
+ lang: void 0,
1120
+ value: void 0
1121
+ }
1122
+ ],
1123
+ { select: true }
1124
+ );
1125
+ plateCommon.focusEditor(editor);
1126
+ }
1127
+ break;
1128
+ case "up":
1129
+ {
1130
+ const path = plateCommon.findNodePath(editor, element);
1131
+ if (!path) {
1132
+ return;
1133
+ }
1134
+ const previousNodePath = plateCommon.getPointBefore(editor, path);
1135
+ if (!previousNodePath) {
1136
+ plateCommon.focusEditor(editor);
1137
+ plateCommon.insertNodes(
1138
+ editor,
1139
+ [
1140
+ {
1141
+ type: plateCommon.ELEMENT_DEFAULT,
1142
+ children: [{ text: "" }],
1143
+ lang: void 0,
1144
+ value: void 0
1145
+ }
1146
+ ],
1147
+ // Insert a new node at the current path, resulting in the code_block
1148
+ // moving down one block
1149
+ { at: path, select: true }
1150
+ );
1151
+ return;
1152
+ }
1153
+ plateCommon.focusEditor(editor, previousNodePath);
1154
+ }
1155
+ break;
1156
+ case "down": {
1157
+ const path = plateCommon.findNodePath(editor, element);
1158
+ if (!path) {
1159
+ return;
1160
+ }
1161
+ const nextNodePath = plateCommon.getPointAfter(editor, path);
1162
+ if (!nextNodePath) {
1163
+ plateCommon.insertNodes(
1164
+ editor,
1165
+ [
1166
+ {
1167
+ type: plateCommon.ELEMENT_DEFAULT,
1168
+ children: [{ text: "" }],
1169
+ lang: void 0,
1170
+ value: void 0
1171
+ }
1172
+ ],
1173
+ { select: true }
1174
+ );
1175
+ plateCommon.focusEditor(editor);
1176
+ } else {
1177
+ plateCommon.focusEditor(editor, nextNodePath);
1178
+ }
1179
+ break;
1180
+ }
1181
+ }
1182
+ }
1183
+ }, [navigateAway]);
1184
+ function handleEditorDidMount(monacoEditor, monaco2) {
1185
+ monacoEditorRef.current = monacoEditor;
1186
+ monacoEditor.onDidContentSizeChange(() => {
1187
+ setHeight(
1188
+ monacoEditor.getContentHeight() > MINIMUM_HEIGHT ? monacoEditor.getContentHeight() : MINIMUM_HEIGHT
1189
+ );
1190
+ monacoEditor.layout();
1191
+ });
1192
+ plateCommon.setNodes(editor, { value: defaultValue, lang: language });
1193
+ monacoEditor.addCommand(monaco2.KeyMod.Shift | monaco2.KeyCode.Enter, () => {
1194
+ if (monacoEditor.hasTextFocus()) {
1195
+ setNavigateAway("insertNext");
1196
+ }
1197
+ });
1198
+ monacoEditor.onKeyDown((l) => {
1199
+ if (l.code === "ArrowUp") {
1200
+ const selection = monacoEditor.getSelection();
1201
+ if (selection.endLineNumber === 1 && selection.startLineNumber === 1) {
1202
+ setNavigateAway("up");
1203
+ }
1204
+ }
1205
+ if (l.code === "ArrowDown") {
1206
+ const selection = monacoEditor.getSelection();
1207
+ const totalLines = monacoEditor.getModel().getLineCount();
1208
+ if (selection.endLineNumber === totalLines && selection.startLineNumber === totalLines) {
1209
+ setNavigateAway("down");
1210
+ }
1211
+ }
1212
+ if (l.code === "Backspace") {
1213
+ const selection = monacoEditor.getSelection();
1214
+ 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) {
1215
+ setNavigateAway("remove");
1216
+ }
1217
+ }
1218
+ });
1219
+ }
1220
+ return /* @__PURE__ */ React.createElement(
1221
+ "div",
1222
+ {
1223
+ ...attributes,
1224
+ className: "relative mb-2 mt-0.5 rounded-lg shadow-md p-2 border-gray-200 border"
1225
+ },
1226
+ /* @__PURE__ */ React.createElement("style", null, `.monaco-editor .editor-widget {
1227
+ display: none !important;
1228
+ visibility: hidden !important;
1229
+ }`),
1230
+ props.children,
1231
+ /* @__PURE__ */ React.createElement("div", { contentEditable: false }, !restrictLanguage && /* @__PURE__ */ React.createElement("div", { className: "flex justify-between pb-2" }, /* @__PURE__ */ React.createElement("div", null), /* @__PURE__ */ React.createElement(
1232
+ Autocomplete,
1233
+ {
1234
+ items: items2,
1235
+ value: currentItem,
1236
+ defaultQuery: "plaintext",
1237
+ onChange: (item) => plateCommon.setNodes(editor, { lang: item.key })
1238
+ }
1239
+ )), /* @__PURE__ */ React.createElement("div", { style: { height: `${height}px` } }, /* @__PURE__ */ React.createElement(
1240
+ MonacoEditor,
1241
+ {
1242
+ path: id,
1243
+ onMount: handleEditorDidMount,
1244
+ options: {
1245
+ scrollBeyondLastLine: false,
1246
+ // automaticLayout: true,
1247
+ tabSize: 2,
1248
+ disableLayerHinting: true,
1249
+ accessibilitySupport: "off",
1250
+ codeLens: false,
1251
+ wordWrap: "on",
1252
+ minimap: {
1253
+ enabled: false
1254
+ },
1255
+ fontSize: 14,
1256
+ lineHeight: 2,
1257
+ formatOnPaste: true,
1258
+ lineNumbers: "off",
1259
+ formatOnType: true,
1260
+ fixedOverflowWidgets: true,
1261
+ // Takes too much horizontal space for iframe
1262
+ folding: false,
1263
+ renderLineHighlight: "none",
1264
+ scrollbar: {
1265
+ verticalScrollbarSize: 1,
1266
+ horizontalScrollbarSize: 1,
1267
+ // https://github.com/microsoft/monaco-editor/issues/2007#issuecomment-644425664
1268
+ alwaysConsumeMouseWheel: false
1269
+ }
1270
+ },
1271
+ language: String(language),
1272
+ value: String(element.value),
1273
+ onChange: (value2) => {
1274
+ onChangeCallback == null ? void 0 : onChangeCallback(value2);
1275
+ plateCommon.setNodes(editor, { value: value2, lang: language });
1276
+ }
1277
+ }
1278
+ )))
1279
+ );
1280
+ };
1281
+ const CodeBlockElement = cn$1.withRef(
1282
+ ({ className, ...props }, ref) => {
1283
+ const { element } = props;
1284
+ const state = plateCodeBlock.useCodeBlockElementState({ element });
1285
+ return /* @__PURE__ */ React.createElement(
1286
+ plateCommon.PlateElement,
1287
+ {
1288
+ className: cn$1.cn("relative py-1", state.className, className),
1289
+ ref,
1290
+ ...props
1291
+ },
1292
+ /* @__PURE__ */ React.createElement(CodeBlock, { ...props })
1293
+ );
1294
+ }
1295
+ );
1296
+ const CodeLeaf = cn$1.withRef(
1297
+ ({ children, className, ...props }, ref) => {
1298
+ return /* @__PURE__ */ React.createElement(
1299
+ plateCommon.PlateLeaf,
1300
+ {
1301
+ asChild: true,
1302
+ className: cn$1.cn(
1303
+ "whitespace-pre-wrap rounded-md bg-muted px-[0.3em] py-[0.2em] font-mono text-sm",
1304
+ className
1305
+ ),
1306
+ ref,
1307
+ ...props
1308
+ },
1309
+ /* @__PURE__ */ React.createElement("code", null, children)
1310
+ );
1311
+ }
1312
+ );
1313
+ const CodeLineElement = cn$1.withRef((props, ref) => /* @__PURE__ */ React.createElement(plateCommon.PlateElement, { ref, ...props }));
1314
+ const CodeSyntaxLeaf = cn$1.withRef(
1315
+ ({ children, ...props }, ref) => {
1316
+ const { leaf } = props;
1317
+ const { tokenProps } = plateCodeBlock.useCodeSyntaxLeaf({ leaf });
1318
+ return /* @__PURE__ */ React.createElement(plateCommon.PlateLeaf, { ref, ...props }, /* @__PURE__ */ React.createElement("span", { ...tokenProps }, children));
1319
+ }
1320
+ );
1321
+ const listVariants = classVarianceAuthority.cva("m-0 ps-6", {
1322
+ variants: {
1323
+ variant: {
1324
+ ol: "list-decimal",
1325
+ ul: "list-disc [&_ul]:list-[circle] [&_ul_ul]:list-[square]"
1326
+ }
1327
+ }
1328
+ });
1329
+ const ListElementVariants = cn$1.withVariants(plateCommon.PlateElement, listVariants, [
1330
+ "variant"
1331
+ ]);
1332
+ const ListElement = cn$1.withRef(
1333
+ ({ children, variant = "ul", ...props }, ref) => {
1334
+ const Component = variant;
1335
+ return /* @__PURE__ */ React.createElement(ListElementVariants, { asChild: true, ref, variant, ...props }, /* @__PURE__ */ React.createElement(Component, null, children));
1336
+ }
1337
+ );
1338
+ const ELEMENT_MERMAID = "mermaid";
1339
+ const createMermaidPlugin = plateCommon.createPluginFactory({
1340
+ isElement: true,
1341
+ isVoid: true,
1342
+ isInline: false,
1343
+ key: ELEMENT_MERMAID
1344
+ });
1345
+ const MermaidElementWithRef = ({ config }) => {
1346
+ const mermaidRef = React.useRef(null);
1347
+ React.useEffect(() => {
1348
+ if (mermaidRef.current) {
1349
+ mermaid.initialize({ startOnLoad: true });
1350
+ mermaid.init();
1351
+ }
1352
+ }, [config]);
1353
+ return /* @__PURE__ */ React.createElement("div", { contentEditable: false, className: "border-border border-b" }, /* @__PURE__ */ React.createElement("div", { ref: mermaidRef }, /* @__PURE__ */ React.createElement("pre", { className: "mermaid not-tina-prose" }, config)));
1354
+ };
1355
+ const Bubble = ({ children }) => {
1356
+ return /* @__PURE__ */ React.createElement("div", { className: "bg-blue-600 rounded-full p-2 transition-transform duration-200 ease-in-out hover:scale-110" }, children);
1357
+ };
1358
+ const ErrorMsg = ({ error }) => {
1359
+ if (error) {
1360
+ return /* @__PURE__ */ React.createElement(
1361
+ "div",
1362
+ {
1363
+ contentEditable: false,
1364
+ className: "font-mono bg-red-600 text-white p-2 rounded-md cursor-default"
1365
+ },
1366
+ error
1367
+ );
1368
+ }
1369
+ return null;
1370
+ };
1371
+ const DEFAULT_MERMAID_CONFIG = `%% This won't render without implementing a rendering engine (e.g. mermaid on npm)
1372
+ flowchart TD
1373
+ id1(this is an example flow diagram)
1374
+ --> id2(modify me to see changes!)
1375
+ id2
1376
+ --> id3(Click the top button to preview the changes)
1377
+ --> id4(Learn about mermaid diagrams - mermaid.js.org)`;
1378
+ const MermaidElement = cn$1.withRef(
1379
+ ({ children, nodeProps, element, ...props }, ref) => {
1380
+ const [mermaidConfig, setMermaidConfig] = React.useState(
1381
+ element.value || DEFAULT_MERMAID_CONFIG
1382
+ );
1383
+ const [isEditing, setIsEditing] = React.useState(
1384
+ mermaidConfig === DEFAULT_MERMAID_CONFIG || false
1385
+ );
1386
+ const [mermaidError, setMermaidError] = React.useState(null);
1387
+ const node = {
1388
+ type: ELEMENT_MERMAID,
1389
+ value: mermaidConfig,
1390
+ children: [{ type: "text", text: "" }]
1391
+ };
1392
+ React.useEffect(() => {
1393
+ if (mermaid.parse(mermaidConfig)) {
1394
+ setMermaidError(null);
1395
+ }
1396
+ }, [mermaidConfig]);
1397
+ mermaid.parseError = (err) => {
1398
+ setMermaidError(
1399
+ String(err.message) || "An error occurred while parsing the diagram."
1400
+ );
1401
+ };
1402
+ return /* @__PURE__ */ React.createElement(plateCommon.PlateElement, { element, ref, ...props }, /* @__PURE__ */ React.createElement("div", { className: "relative group" }, /* @__PURE__ */ React.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.createElement(Bubble, null, isEditing ? /* @__PURE__ */ React.createElement(
1403
+ lucideReact.Eye,
1404
+ {
1405
+ className: "w-5 h-5 fill-white cursor-pointer",
1406
+ onClick: () => {
1407
+ setIsEditing(!isEditing);
1408
+ }
1409
+ }
1410
+ ) : /* @__PURE__ */ React.createElement(
1411
+ lucideReact.SquarePen,
1412
+ {
1413
+ className: "w-5 h-5 fill-white cursor-pointer",
1414
+ onClick: () => {
1415
+ setIsEditing(!isEditing);
1416
+ }
1417
+ }
1418
+ ))), isEditing ? /* @__PURE__ */ React.createElement(
1419
+ CodeBlock,
1420
+ {
1421
+ children: "",
1422
+ language: "yaml",
1423
+ ...props,
1424
+ element: node,
1425
+ defaultValue: mermaidConfig,
1426
+ onChangeCallback: (value) => setMermaidConfig(value)
1427
+ }
1428
+ ) : /* @__PURE__ */ React.createElement(MermaidElementWithRef, { config: mermaidConfig })), children, /* @__PURE__ */ React.createElement(ErrorMsg, { error: mermaidError }));
1429
+ }
1430
+ );
894
1431
  const RawMarkdown = () => {
895
1432
  return /* @__PURE__ */ React.createElement(
896
1433
  "svg",
@@ -909,6 +1446,29 @@ var __publicField = (obj, key, value) => {
909
1446
  /* @__PURE__ */ React.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" })
910
1447
  );
911
1448
  };
1449
+ const MermaidIcon = () => /* @__PURE__ */ React.createElement(
1450
+ "svg",
1451
+ {
1452
+ width: "100%",
1453
+ height: "100%",
1454
+ viewBox: "0 0 491 491",
1455
+ version: "1.1",
1456
+ xmlns: "http://www.w3.org/2000/svg",
1457
+ fillRule: "evenodd",
1458
+ clipRule: "evenodd",
1459
+ strokeLinejoin: "round",
1460
+ strokeMiterlimit: 2
1461
+ },
1462
+ /* @__PURE__ */ React.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" }),
1463
+ /* @__PURE__ */ React.createElement(
1464
+ "path",
1465
+ {
1466
+ 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",
1467
+ fill: "white",
1468
+ fillRule: "nonzero"
1469
+ }
1470
+ )
1471
+ );
912
1472
  const borderAll = (props) => /* @__PURE__ */ React.createElement(
913
1473
  "svg",
914
1474
  {
@@ -993,7 +1553,7 @@ var __publicField = (obj, key, value) => {
993
1553
  },
994
1554
  /* @__PURE__ */ React.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" })
995
1555
  );
996
- classVarianceAuthority.cva("", {
1556
+ const iconVariants = classVarianceAuthority.cva("", {
997
1557
  variants: {
998
1558
  variant: {
999
1559
  toolbar: "size-5",
@@ -1149,6 +1709,7 @@ var __publicField = (obj, key, value) => {
1149
1709
  clear: lucideReact.X,
1150
1710
  close: lucideReact.X,
1151
1711
  // code: Code2,
1712
+ paint: lucideReact.PaintBucket,
1152
1713
  codeblock: lucideReact.FileCode,
1153
1714
  color: lucideReact.Baseline,
1154
1715
  column: lucideReact.RectangleVertical,
@@ -1174,6 +1735,7 @@ var __publicField = (obj, key, value) => {
1174
1735
  lineHeight: lucideReact.WrapText,
1175
1736
  // link: Link2,
1176
1737
  minus: lucideReact.Minus,
1738
+ mermaid: MermaidIcon,
1177
1739
  more: lucideReact.MoreHorizontal,
1178
1740
  // ol: ListOrdered,
1179
1741
  outdent: lucideReact.Outdent,
@@ -1548,7 +2110,7 @@ var __publicField = (obj, key, value) => {
1548
2110
  setHasEmpty
1549
2111
  ]
1550
2112
  );
1551
- const store = react.useComboboxStore({
2113
+ const store = react$1.useComboboxStore({
1552
2114
  setValue: (newValue) => React.startTransition(() => setValue(newValue))
1553
2115
  });
1554
2116
  const items2 = store.useState("items");
@@ -1558,7 +2120,7 @@ var __publicField = (obj, key, value) => {
1558
2120
  }
1559
2121
  }, [items2, store]);
1560
2122
  return /* @__PURE__ */ React.createElement("span", { contentEditable: false }, /* @__PURE__ */ React.createElement(
1561
- react.ComboboxProvider,
2123
+ react$1.ComboboxProvider,
1562
2124
  {
1563
2125
  open: (items2.length > 0 || hasEmpty) && (!hideWhenNoValue || value.length > 0),
1564
2126
  store
@@ -1573,7 +2135,7 @@ var __publicField = (obj, key, value) => {
1573
2135
  showTrigger,
1574
2136
  trigger
1575
2137
  } = React.useContext(InlineComboboxContext);
1576
- const store = react.useComboboxContext();
2138
+ const store = react$1.useComboboxContext();
1577
2139
  const value = store.useState("value");
1578
2140
  const ref = plateCommon.useComposedRef(propRef, contextRef);
1579
2141
  return /* @__PURE__ */ React.createElement(React.Fragment, null, showTrigger && trigger, /* @__PURE__ */ React.createElement("span", { className: "relative min-h-[1lh]" }, /* @__PURE__ */ React.createElement(
@@ -1584,7 +2146,7 @@ var __publicField = (obj, key, value) => {
1584
2146
  },
1585
2147
  value || "​"
1586
2148
  ), /* @__PURE__ */ React.createElement(
1587
- react.Combobox,
2149
+ react$1.Combobox,
1588
2150
  {
1589
2151
  autoSelect: true,
1590
2152
  className: cn$1.cn(
@@ -1603,8 +2165,8 @@ var __publicField = (obj, key, value) => {
1603
2165
  className,
1604
2166
  ...props
1605
2167
  }) => {
1606
- return /* @__PURE__ */ React.createElement(react.Portal, null, /* @__PURE__ */ React.createElement(
1607
- react.ComboboxPopover,
2168
+ return /* @__PURE__ */ React.createElement(react$1.Portal, null, /* @__PURE__ */ React.createElement(
2169
+ react$1.ComboboxPopover,
1608
2170
  {
1609
2171
  className: cn$1.cn(
1610
2172
  "z-[9999999] max-h-[288px] w-[300px] overflow-y-auto rounded-md bg-white shadow-md",
@@ -1636,7 +2198,7 @@ var __publicField = (obj, key, value) => {
1636
2198
  }) => {
1637
2199
  const { value } = props;
1638
2200
  const { filter, removeInput } = React.useContext(InlineComboboxContext);
1639
- const store = react.useComboboxContext();
2201
+ const store = react$1.useComboboxContext();
1640
2202
  const search = filter && store.useState("value");
1641
2203
  const visible = React.useMemo(
1642
2204
  () => !filter || filter({ keywords, value }, search),
@@ -1645,7 +2207,7 @@ var __publicField = (obj, key, value) => {
1645
2207
  if (!visible)
1646
2208
  return null;
1647
2209
  return /* @__PURE__ */ React.createElement(
1648
- react.ComboboxItem,
2210
+ react$1.ComboboxItem,
1649
2211
  {
1650
2212
  className: cn$1.cn(comboboxItemVariants(), className),
1651
2213
  onClick: (event) => {
@@ -1661,7 +2223,7 @@ var __publicField = (obj, key, value) => {
1661
2223
  className
1662
2224
  }) => {
1663
2225
  const { setHasEmpty } = React.useContext(InlineComboboxContext);
1664
- const store = react.useComboboxContext();
2226
+ const store = react$1.useComboboxContext();
1665
2227
  const items2 = store.useState("items");
1666
2228
  React.useEffect(() => {
1667
2229
  setHasEmpty(true);
@@ -1744,417 +2306,482 @@ var __publicField = (obj, key, value) => {
1744
2306
  );
1745
2307
  }
1746
2308
  );
1747
- const listVariants = classVarianceAuthority.cva("m-0 ps-6", {
1748
- variants: {
1749
- variant: {
1750
- ol: "list-decimal",
1751
- ul: "list-disc [&_ul]:list-[circle] [&_ul_ul]:list-[square]"
1752
- }
1753
- }
1754
- });
1755
- const ListElementVariants = cn$1.withVariants(plateCommon.PlateElement, listVariants, [
1756
- "variant"
1757
- ]);
1758
- const ListElement = cn$1.withRef(
1759
- ({ children, variant = "ul", ...props }, ref) => {
1760
- const Component = variant;
1761
- return /* @__PURE__ */ React.createElement(ListElementVariants, { asChild: true, ref, variant, ...props }, /* @__PURE__ */ React.createElement(Component, null, children));
1762
- }
1763
- );
1764
- const BlockquoteElement = cn$1.withRef(
1765
- ({ children, className, ...props }, ref) => {
1766
- return /* @__PURE__ */ React.createElement(
1767
- plateCommon.PlateElement,
1768
- {
1769
- asChild: true,
1770
- className: cn$1.cn("my-1 border-l-2 pl-6 italic", className),
1771
- ref,
1772
- ...props
1773
- },
1774
- /* @__PURE__ */ React.createElement("blockquote", null, children)
1775
- );
1776
- }
1777
- );
1778
- const CodeLeaf = cn$1.withRef(
1779
- ({ children, className, ...props }, ref) => {
1780
- return /* @__PURE__ */ React.createElement(
1781
- plateCommon.PlateLeaf,
1782
- {
1783
- asChild: true,
1784
- className: cn$1.cn(
1785
- "whitespace-pre-wrap rounded-md bg-muted px-[0.3em] py-[0.2em] font-mono text-sm",
1786
- className
1787
- ),
1788
- ref,
1789
- ...props
1790
- },
1791
- /* @__PURE__ */ React.createElement("code", null, children)
1792
- );
1793
- }
1794
- );
1795
- const CodeLineElement = cn$1.withRef((props, ref) => /* @__PURE__ */ React.createElement(plateCommon.PlateElement, { ref, ...props }));
1796
- const CodeSyntaxLeaf = cn$1.withRef(
1797
- ({ children, ...props }, ref) => {
1798
- const { leaf } = props;
1799
- const { tokenProps } = plateCodeBlock.useCodeSyntaxLeaf({ leaf });
1800
- return /* @__PURE__ */ React.createElement(plateCommon.PlateLeaf, { ref, ...props }, /* @__PURE__ */ React.createElement("span", { ...tokenProps }, children));
1801
- }
1802
- );
1803
- function ChevronDownIcon(props, svgRef) {
1804
- return /* @__PURE__ */ React__namespace.createElement("svg", Object.assign({
1805
- xmlns: "http://www.w3.org/2000/svg",
1806
- viewBox: "0 0 20 20",
1807
- fill: "currentColor",
1808
- "aria-hidden": "true",
1809
- ref: svgRef
1810
- }, props), /* @__PURE__ */ React__namespace.createElement("path", {
1811
- fillRule: "evenodd",
1812
- 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",
1813
- clipRule: "evenodd"
1814
- }));
1815
- }
1816
- const ForwardRef = React__namespace.forwardRef(ChevronDownIcon);
1817
- const ChevronDownIcon$1 = ForwardRef;
1818
- const Autocomplete = ({
1819
- value,
1820
- onChange,
1821
- defaultQuery,
1822
- items: items2
1823
- }) => {
1824
- const [query, setQuery] = React.useState(defaultQuery ?? "");
1825
- const filteredItems = React.useMemo(() => {
1826
- try {
1827
- const reFilter = new RegExp(query, "i");
1828
- const _items = items2.filter((item) => reFilter.test(item.label));
1829
- if (_items.length === 0)
1830
- return items2;
1831
- return _items;
1832
- } catch (err) {
1833
- return items2;
1834
- }
1835
- }, [items2, query]);
2309
+ const TableCellElement = cn$1.withRef(({ children, className, hideBorder, isHeader, style, ...props }, ref) => {
2310
+ var _a, _b, _c, _d;
2311
+ const { element } = props;
2312
+ const {
2313
+ borders,
2314
+ colIndex,
2315
+ colSpan,
2316
+ hovered,
2317
+ hoveredLeft,
2318
+ isSelectingCell,
2319
+ readOnly,
2320
+ rowIndex,
2321
+ rowSize,
2322
+ selected
2323
+ } = plateTable.useTableCellElementState();
2324
+ const { props: cellProps } = plateTable.useTableCellElement({ element: props.element });
2325
+ const resizableState = plateTable.useTableCellElementResizableState({
2326
+ colIndex,
2327
+ colSpan,
2328
+ rowIndex
2329
+ });
2330
+ const { bottomProps, hiddenLeft, leftProps, rightProps } = plateTable.useTableCellElementResizable(resizableState);
2331
+ const Cell = isHeader ? "th" : "td";
1836
2332
  return /* @__PURE__ */ React.createElement(
1837
- react$1.Combobox,
2333
+ plateCommon.PlateElement,
1838
2334
  {
1839
- value,
1840
- onChange,
1841
- as: "div",
1842
- className: "relative inline-block text-left z-20"
1843
- },
1844
- /* @__PURE__ */ React.createElement("div", { className: "mt-1" }, /* @__PURE__ */ React.createElement("div", { className: "relative w-full cursor-default overflow-hidden rounded-lg bg-white text-left shadow-md sm:text-sm" }, /* @__PURE__ */ React.createElement(
1845
- react$1.ComboboxInput,
1846
- {
1847
- 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",
1848
- displayValue: (item) => (item == null ? void 0 : item.label) ?? "Plain Text",
1849
- onChange: (event) => setQuery(event.target.value),
1850
- onClick: (ev) => ev.stopPropagation()
2335
+ asChild: true,
2336
+ className: cn$1.cn(
2337
+ "relative h-full overflow-visible border-none bg-background p-0",
2338
+ hideBorder && "before:border-none",
2339
+ element.background ? "bg-[--cellBackground]" : "bg-background",
2340
+ !hideBorder && cn$1.cn(
2341
+ isHeader && "text-left [&_>_*]:m-0",
2342
+ "before:size-full",
2343
+ selected && "before:z-10 before:bg-muted",
2344
+ "before:absolute before:box-border before:select-none before:content-['']",
2345
+ borders && cn$1.cn(
2346
+ ((_a = borders.bottom) == null ? void 0 : _a.size) && `before:border-b before:border-b-border`,
2347
+ ((_b = borders.right) == null ? void 0 : _b.size) && `before:border-r before:border-r-border`,
2348
+ ((_c = borders.left) == null ? void 0 : _c.size) && `before:border-l before:border-l-border`,
2349
+ ((_d = borders.top) == null ? void 0 : _d.size) && `before:border-t before:border-t-border`
2350
+ )
2351
+ ),
2352
+ className
2353
+ ),
2354
+ ref,
2355
+ ...cellProps,
2356
+ ...props,
2357
+ style: {
2358
+ "--cellBackground": element.background,
2359
+ ...style
1851
2360
  }
1852
- ), /* @__PURE__ */ React.createElement(react$1.ComboboxButton, { className: "absolute inset-y-0 right-0 flex items-center pr-2" }, /* @__PURE__ */ React.createElement(
1853
- ChevronDownIcon$1,
2361
+ },
2362
+ /* @__PURE__ */ React.createElement(Cell, null, /* @__PURE__ */ React.createElement(
2363
+ "div",
1854
2364
  {
1855
- className: "h-5 w-5 text-gray-400",
1856
- "aria-hidden": "true"
1857
- }
1858
- )))),
1859
- /* @__PURE__ */ React.createElement(
1860
- react$1.Transition,
2365
+ className: "relative z-20 box-border h-full px-3 py-2",
2366
+ style: {
2367
+ minHeight: rowSize
2368
+ }
2369
+ },
2370
+ children
2371
+ ), !isSelectingCell && /* @__PURE__ */ React.createElement(
2372
+ "div",
1861
2373
  {
1862
- enter: "transition ease-out duration-100",
1863
- enterFrom: "transform opacity-0 scale-95",
1864
- enterTo: "transform opacity-100 scale-100",
1865
- leave: "transition ease-in duration-75",
1866
- leaveFrom: "transform opacity-100 scale-100",
1867
- leaveTo: "transform opacity-0 scale-95"
2374
+ className: "group absolute top-0 size-full select-none",
2375
+ contentEditable: false,
2376
+ suppressContentEditableWarning: true
1868
2377
  },
1869
- /* @__PURE__ */ React.createElement(react$1.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.createElement(react$1.ComboboxOption, { key: item.key, value: item }, ({ focus }) => /* @__PURE__ */ React.createElement(
1870
- "button",
2378
+ !readOnly && /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(
2379
+ plateResizable.ResizeHandle,
1871
2380
  {
1872
- className: classNames$1(
1873
- focus ? "bg-gray-100 text-gray-900" : "text-gray-700",
1874
- "block px-4 py-2 text-xs w-full text-right"
2381
+ ...rightProps,
2382
+ className: "-top-3 right-[-5px] w-[10px]"
2383
+ }
2384
+ ), /* @__PURE__ */ React.createElement(
2385
+ plateResizable.ResizeHandle,
2386
+ {
2387
+ ...bottomProps,
2388
+ className: "bottom-[-5px] h-[10px]"
2389
+ }
2390
+ ), !hiddenLeft && /* @__PURE__ */ React.createElement(
2391
+ plateResizable.ResizeHandle,
2392
+ {
2393
+ ...leftProps,
2394
+ className: "-top-3 left-[-5px] w-[10px]"
2395
+ }
2396
+ ), hovered && /* @__PURE__ */ React.createElement(
2397
+ "div",
2398
+ {
2399
+ className: cn$1.cn(
2400
+ "absolute -top-3 z-30 h-[calc(100%_+_12px)] w-1 bg-ring",
2401
+ "right-[-1.5px]"
1875
2402
  )
1876
- },
1877
- item.render(item)
1878
- ))))
1879
- )
2403
+ }
2404
+ ), hoveredLeft && /* @__PURE__ */ React.createElement(
2405
+ "div",
2406
+ {
2407
+ className: cn$1.cn(
2408
+ "absolute -top-3 z-30 h-[calc(100%_+_12px)] w-1 bg-ring",
2409
+ "left-[-1.5px]"
2410
+ )
2411
+ }
2412
+ ))
2413
+ ))
1880
2414
  );
1881
- };
1882
- MonacoEditor.loader.config({
1883
- paths: { vs: "https://cdn.jsdelivr.net/npm/monaco-editor@0.31.1/min/vs" }
1884
2415
  });
1885
- let retryCount = 0;
1886
- const retryFocus = (ref) => {
1887
- if (ref.current) {
1888
- ref.current.focus();
1889
- } else {
1890
- if (retryCount < 30) {
1891
- setTimeout(() => {
1892
- retryCount = retryCount + 1;
1893
- retryFocus(ref);
1894
- }, 100);
1895
- }
1896
- }
1897
- };
1898
- const CodeBlock = ({
1899
- attributes,
1900
- editor,
1901
- element,
1902
- language: restrictLanguage,
1903
- ...props
1904
- }) => {
1905
- const [navigateAway, setNavigateAway] = React.useState(null);
1906
- const monaco = MonacoEditor.useMonaco();
1907
- const monacoEditorRef = React.useRef(null);
1908
- const selected = slateReact.useSelected();
1909
- const [height, setHeight] = React.useState(28);
1910
- React.useEffect(() => {
1911
- if (selected && plateCommon.isCollapsed(editor.selection)) {
1912
- retryFocus(monacoEditorRef);
2416
+ TableCellElement.displayName = "TableCellElement";
2417
+ const TableCellHeaderElement = cn$1.withProps(TableCellElement, {
2418
+ isHeader: true
2419
+ });
2420
+ const buttonVariants$1 = classVarianceAuthority.cva(
2421
+ "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",
2422
+ {
2423
+ defaultVariants: {
2424
+ size: "default",
2425
+ variant: "default"
2426
+ },
2427
+ variants: {
2428
+ isMenu: {
2429
+ true: "h-auto w-full cursor-pointer justify-start"
2430
+ },
2431
+ size: {
2432
+ default: "h-10 px-4 py-2",
2433
+ icon: "size-10",
2434
+ lg: "h-11 rounded-md px-8",
2435
+ none: "",
2436
+ sm: "h-9 rounded-md px-3",
2437
+ sms: "size-9 rounded-md px-0",
2438
+ xs: "h-8 rounded-md px-3"
2439
+ },
2440
+ variant: {
2441
+ default: "bg-primary text-primary-foreground hover:bg-primary/90",
2442
+ destructive: "bg-destructive text-destructive-foreground hover:bg-destructive/90",
2443
+ ghost: "hover:bg-accent hover:text-accent-foreground",
2444
+ inlineLink: "text-base text-primary underline underline-offset-4",
2445
+ link: "text-primary underline-offset-4 hover:underline",
2446
+ outline: "border border-input bg-background hover:bg-accent hover:text-accent-foreground",
2447
+ secondary: "bg-secondary text-secondary-foreground hover:bg-secondary/80"
2448
+ }
1913
2449
  }
1914
- }, [selected, monacoEditorRef.current]);
1915
- const value = element.value || "";
1916
- if (typeof value !== "string") {
1917
- throw new Error("Element must be of type string for code block");
1918
2450
  }
1919
- const language = restrictLanguage || element.lang;
1920
- const id = React.useMemo(() => uuid(), []);
1921
- const languages = React.useMemo(() => {
1922
- const defaultLangSet = { "": "plain text" };
1923
- if (!monaco)
1924
- return defaultLangSet;
1925
- return monaco.languages.getLanguages().reduce((ac, cv) => {
1926
- if (cv.id === "plaintext")
1927
- return ac;
1928
- return { ...ac, [cv.id]: cv.id };
1929
- }, defaultLangSet);
1930
- }, [monaco]);
1931
- React.useEffect(() => {
1932
- if (monaco) {
1933
- monaco.languages.typescript.typescriptDefaults.setEagerModelSync(true);
1934
- monaco.languages.typescript.typescriptDefaults.setDiagnosticsOptions({
1935
- // disable errors
1936
- noSemanticValidation: true,
1937
- noSyntaxValidation: true
1938
- });
2451
+ );
2452
+ const Button$2 = cn$1.withRef(({ asChild = false, className, isMenu, size, variant, ...props }, ref) => {
2453
+ const Comp = asChild ? reactSlot.Slot : "button";
2454
+ return /* @__PURE__ */ React__namespace.createElement(
2455
+ Comp,
2456
+ {
2457
+ className: cn$1.cn(buttonVariants$1({ className, isMenu, size, variant })),
2458
+ ref,
2459
+ ...props
1939
2460
  }
1940
- }, [monaco]);
1941
- const items2 = Object.entries(languages).map(([key, label]) => ({
1942
- key,
1943
- label,
1944
- render: (item) => item.label
1945
- }));
1946
- const currentItem = React.useMemo(() => {
1947
- return items2.find((item) => item.key === language) ?? {
1948
- key: "",
1949
- label: "Plain Text"
1950
- };
1951
- }, [items2, language]);
1952
- React.useEffect(() => {
1953
- if (navigateAway) {
1954
- setNavigateAway(null);
1955
- switch (navigateAway) {
1956
- case "remove":
1957
- {
1958
- plateCommon.focusEditor(editor);
1959
- plateCommon.setNodes(
1960
- editor,
1961
- {
1962
- type: "p",
1963
- children: [{ text: "" }],
1964
- lang: void 0,
1965
- value: void 0
1966
- },
1967
- {
1968
- match: (n) => {
1969
- if (plateCommon.isElement(n) && n.type === element.type) {
1970
- return true;
1971
- }
1972
- }
1973
- }
1974
- );
1975
- }
1976
- break;
1977
- case "insertNext":
1978
- {
1979
- plateCommon.insertNodes(
1980
- editor,
1981
- [
1982
- {
1983
- type: plateCommon.ELEMENT_DEFAULT,
1984
- children: [{ text: "" }],
1985
- lang: void 0,
1986
- value: void 0
1987
- }
1988
- ],
1989
- { select: true }
1990
- );
1991
- plateCommon.focusEditor(editor);
1992
- }
1993
- break;
1994
- case "up":
1995
- {
1996
- const path = plateCommon.findNodePath(editor, element);
1997
- if (!path) {
1998
- return;
1999
- }
2000
- const previousNodePath = plateCommon.getPointBefore(editor, path);
2001
- if (!previousNodePath) {
2002
- plateCommon.focusEditor(editor);
2003
- plateCommon.insertNodes(
2004
- editor,
2005
- [
2006
- {
2007
- type: plateCommon.ELEMENT_DEFAULT,
2008
- children: [{ text: "" }],
2009
- lang: void 0,
2010
- value: void 0
2011
- }
2012
- ],
2013
- // Insert a new node at the current path, resulting in the code_block
2014
- // moving down one block
2015
- { at: path, select: true }
2016
- );
2017
- return;
2018
- }
2019
- plateCommon.focusEditor(editor, previousNodePath);
2020
- }
2021
- break;
2022
- case "down": {
2023
- const path = plateCommon.findNodePath(editor, element);
2024
- if (!path) {
2025
- return;
2026
- }
2027
- const nextNodePath = plateCommon.getPointAfter(editor, path);
2028
- if (!nextNodePath) {
2029
- plateCommon.insertNodes(
2030
- editor,
2031
- [
2032
- {
2033
- type: plateCommon.ELEMENT_DEFAULT,
2034
- children: [{ text: "" }],
2035
- lang: void 0,
2036
- value: void 0
2037
- }
2038
- ],
2039
- { select: true }
2040
- );
2041
- plateCommon.focusEditor(editor);
2042
- } else {
2043
- plateCommon.focusEditor(editor, nextNodePath);
2044
- }
2045
- break;
2046
- }
2461
+ );
2462
+ });
2463
+ const DropdownMenu = DropdownMenuPrimitive__namespace.Root;
2464
+ const DropdownMenuTrigger = DropdownMenuPrimitive__namespace.Trigger;
2465
+ const DropdownMenuPortal = DropdownMenuPrimitive__namespace.Portal;
2466
+ const DropdownMenuSub = DropdownMenuPrimitive__namespace.Sub;
2467
+ const DropdownMenuRadioGroup = DropdownMenuPrimitive__namespace.RadioGroup;
2468
+ const DropdownMenuSubTrigger = cn$1.withRef(({ children, className, inset, ...props }, ref) => /* @__PURE__ */ React.createElement(
2469
+ DropdownMenuPrimitive__namespace.SubTrigger,
2470
+ {
2471
+ className: cn$1.cn(
2472
+ "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",
2473
+ "data-[disabled]:pointer-events-none data-[disabled]:opacity-50",
2474
+ inset && "pl-8",
2475
+ className
2476
+ ),
2477
+ ref,
2478
+ ...props
2479
+ },
2480
+ children,
2481
+ /* @__PURE__ */ React.createElement(Icons.chevronRight, { className: "ml-auto size-4" })
2482
+ ));
2483
+ const DropdownMenuSubContent = cn$1.withCn(
2484
+ DropdownMenuPrimitive__namespace.SubContent,
2485
+ "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"
2486
+ );
2487
+ const DropdownMenuContentVariants = cn$1.withProps(DropdownMenuPrimitive__namespace.Content, {
2488
+ className: cn$1.cn(
2489
+ "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"
2490
+ ),
2491
+ sideOffset: 4
2492
+ });
2493
+ const DropdownMenuContent = cn$1.withRef(({ ...props }, ref) => /* @__PURE__ */ React.createElement(DropdownMenuPrimitive__namespace.Portal, null, /* @__PURE__ */ React.createElement(DropdownMenuContentVariants, { ref, ...props })));
2494
+ const menuItemVariants = classVarianceAuthority.cva(
2495
+ cn$1.cn(
2496
+ "relative flex h-9 cursor-pointer select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none transition-colors",
2497
+ "focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50"
2498
+ ),
2499
+ {
2500
+ variants: {
2501
+ inset: {
2502
+ true: "pl-8"
2047
2503
  }
2048
2504
  }
2049
- }, [navigateAway]);
2050
- function handleEditorDidMount(monacoEditor, monaco2) {
2051
- monacoEditorRef.current = monacoEditor;
2052
- monacoEditor.onDidContentSizeChange(() => {
2053
- setHeight(monacoEditor.getContentHeight());
2054
- monacoEditor.layout();
2055
- });
2056
- monacoEditor.addCommand(monaco2.KeyMod.Shift | monaco2.KeyCode.Enter, () => {
2057
- if (monacoEditor.hasTextFocus()) {
2058
- setNavigateAway("insertNext");
2059
- }
2060
- });
2061
- monacoEditor.onKeyDown((l) => {
2062
- if (l.code === "ArrowUp") {
2063
- const selection = monacoEditor.getSelection();
2064
- if (selection.endLineNumber === 1 && selection.startLineNumber === 1) {
2065
- setNavigateAway("up");
2066
- }
2067
- }
2068
- if (l.code === "ArrowDown") {
2069
- const selection = monacoEditor.getSelection();
2070
- const totalLines = monacoEditor.getModel().getLineCount();
2071
- if (selection.endLineNumber === totalLines && selection.startLineNumber === totalLines) {
2072
- setNavigateAway("down");
2073
- }
2074
- }
2075
- if (l.code === "Backspace") {
2076
- const selection = monacoEditor.getSelection();
2077
- 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) {
2078
- setNavigateAway("remove");
2079
- }
2505
+ }
2506
+ );
2507
+ const DropdownMenuItem = cn$1.withVariants(
2508
+ DropdownMenuPrimitive__namespace.Item,
2509
+ menuItemVariants,
2510
+ ["inset"]
2511
+ );
2512
+ const DropdownMenuCheckboxItem = cn$1.withRef(({ children, className, ...props }, ref) => /* @__PURE__ */ React.createElement(
2513
+ DropdownMenuPrimitive__namespace.CheckboxItem,
2514
+ {
2515
+ className: cn$1.cn(
2516
+ "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",
2517
+ "cursor-pointer",
2518
+ className
2519
+ ),
2520
+ ref,
2521
+ ...props
2522
+ },
2523
+ /* @__PURE__ */ React.createElement("span", { className: "absolute left-2 flex size-3.5 items-center justify-center" }, /* @__PURE__ */ React.createElement(DropdownMenuPrimitive__namespace.ItemIndicator, null, /* @__PURE__ */ React.createElement(Icons.check, { className: "size-4" }))),
2524
+ children
2525
+ ));
2526
+ const DropdownMenuRadioItem = cn$1.withRef(({ children, className, hideIcon, ...props }, ref) => /* @__PURE__ */ React.createElement(
2527
+ DropdownMenuPrimitive__namespace.RadioItem,
2528
+ {
2529
+ className: cn$1.cn(
2530
+ "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",
2531
+ "h-9 cursor-pointer px-2 data-[state=checked]:bg-accent data-[state=checked]:text-accent-foreground",
2532
+ className
2533
+ ),
2534
+ ref,
2535
+ ...props
2536
+ },
2537
+ !hideIcon && /* @__PURE__ */ React.createElement("span", { className: "absolute right-2 flex size-3.5 items-center justify-center" }, /* @__PURE__ */ React.createElement(DropdownMenuPrimitive__namespace.ItemIndicator, null, /* @__PURE__ */ React.createElement(Icons.check, { className: "size-4" }))),
2538
+ children
2539
+ ));
2540
+ const dropdownMenuLabelVariants = classVarianceAuthority.cva(
2541
+ cn$1.cn("select-none px-2 py-1.5 text-sm font-semibold"),
2542
+ {
2543
+ variants: {
2544
+ inset: {
2545
+ true: "pl-8"
2080
2546
  }
2081
- });
2547
+ }
2082
2548
  }
2549
+ );
2550
+ const DropdownMenuLabel = cn$1.withVariants(
2551
+ DropdownMenuPrimitive__namespace.Label,
2552
+ dropdownMenuLabelVariants,
2553
+ ["inset"]
2554
+ );
2555
+ const DropdownMenuSeparator = cn$1.withCn(
2556
+ DropdownMenuPrimitive__namespace.Separator,
2557
+ "-mx-1 my-1 h-px bg-muted"
2558
+ );
2559
+ cn$1.withCn(
2560
+ cn$1.createPrimitiveElement("span"),
2561
+ "ml-auto text-xs tracking-widest opacity-60"
2562
+ );
2563
+ const useOpenState = () => {
2564
+ const [open2, setOpen] = React.useState(false);
2565
+ const onOpenChange = React.useCallback(
2566
+ (_value = !open2) => {
2567
+ setOpen(_value);
2568
+ },
2569
+ [open2]
2570
+ );
2571
+ return {
2572
+ onOpenChange,
2573
+ open: open2
2574
+ };
2575
+ };
2576
+ const Popover$2 = PopoverPrimitive__namespace.Root;
2577
+ const popoverVariants = classVarianceAuthority.cva(
2578
+ "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"
2579
+ );
2580
+ const PopoverContent$1 = cn$1.withRef(
2581
+ ({ align = "center", className, sideOffset = 4, style, ...props }, ref) => /* @__PURE__ */ React__namespace.createElement(PopoverPrimitive__namespace.Portal, null, /* @__PURE__ */ React__namespace.createElement(
2582
+ PopoverPrimitive__namespace.Content,
2583
+ {
2584
+ align,
2585
+ className: cn$1.cn(popoverVariants(), className),
2586
+ ref,
2587
+ sideOffset,
2588
+ style: { zIndex: 1e3, ...style },
2589
+ ...props
2590
+ }
2591
+ ))
2592
+ );
2593
+ const separatorVariants = classVarianceAuthority.cva("shrink-0 bg-border", {
2594
+ defaultVariants: {
2595
+ orientation: "horizontal"
2596
+ },
2597
+ variants: {
2598
+ orientation: {
2599
+ horizontal: "h-px w-full",
2600
+ vertical: "h-full w-px"
2601
+ }
2602
+ }
2603
+ });
2604
+ const Separator = cn$1.withVariants(
2605
+ cn$1.withProps(SeparatorPrimitive__namespace.Root, {
2606
+ decorative: true,
2607
+ orientation: "horizontal"
2608
+ }),
2609
+ separatorVariants
2610
+ );
2611
+ const TableBordersDropdownMenuContent = cn$1.withRef((props, ref) => {
2612
+ const {
2613
+ getOnSelectTableBorder,
2614
+ hasBottomBorder,
2615
+ hasLeftBorder,
2616
+ hasNoBorders,
2617
+ hasOuterBorders,
2618
+ hasRightBorder,
2619
+ hasTopBorder
2620
+ } = plateTable.useTableBordersDropdownMenuContentState();
2083
2621
  return /* @__PURE__ */ React.createElement(
2084
- "div",
2622
+ DropdownMenuContent,
2085
2623
  {
2086
- ...attributes,
2087
- className: "relative mb-2 mt-0.5 rounded-lg shadow-md p-2 border-gray-200 border"
2624
+ align: "start",
2625
+ className: cn$1.cn("min-w-[220px]"),
2626
+ ref,
2627
+ side: "right",
2628
+ sideOffset: 0,
2629
+ ...props
2088
2630
  },
2089
- /* @__PURE__ */ React.createElement("style", null, `.monaco-editor .editor-widget {
2090
- display: none !important;
2091
- visibility: hidden !important;
2092
- }`),
2093
- props.children,
2094
- /* @__PURE__ */ React.createElement("div", { contentEditable: false }, !restrictLanguage && /* @__PURE__ */ React.createElement("div", { className: "flex justify-between pb-2" }, /* @__PURE__ */ React.createElement("div", null), /* @__PURE__ */ React.createElement(
2095
- Autocomplete,
2631
+ /* @__PURE__ */ React.createElement(
2632
+ DropdownMenuCheckboxItem,
2096
2633
  {
2097
- items: items2,
2098
- value: currentItem,
2099
- defaultQuery: "plaintext",
2100
- onChange: (item) => plateCommon.setNodes(editor, { lang: item.key })
2101
- }
2102
- )), /* @__PURE__ */ React.createElement("div", { style: { height: `${height}px` } }, /* @__PURE__ */ React.createElement(
2103
- MonacoEditor,
2634
+ checked: hasBottomBorder,
2635
+ onCheckedChange: getOnSelectTableBorder("bottom")
2636
+ },
2637
+ /* @__PURE__ */ React.createElement(Icons.borderBottom, { className: iconVariants({ size: "sm" }) }),
2638
+ /* @__PURE__ */ React.createElement("div", null, "Bottom Border")
2639
+ ),
2640
+ /* @__PURE__ */ React.createElement(
2641
+ DropdownMenuCheckboxItem,
2104
2642
  {
2105
- path: id,
2106
- onMount: handleEditorDidMount,
2107
- options: {
2108
- scrollBeyondLastLine: false,
2109
- // automaticLayout: true,
2110
- tabSize: 2,
2111
- disableLayerHinting: true,
2112
- accessibilitySupport: "off",
2113
- codeLens: false,
2114
- wordWrap: "on",
2115
- minimap: {
2116
- enabled: false
2117
- },
2118
- fontSize: 14,
2119
- lineHeight: 2,
2120
- formatOnPaste: true,
2121
- lineNumbers: "off",
2122
- formatOnType: true,
2123
- fixedOverflowWidgets: true,
2124
- // Takes too much horizontal space for iframe
2125
- folding: false,
2126
- renderLineHighlight: "none",
2127
- scrollbar: {
2128
- verticalScrollbarSize: 1,
2129
- horizontalScrollbarSize: 1,
2130
- // https://github.com/microsoft/monaco-editor/issues/2007#issuecomment-644425664
2131
- alwaysConsumeMouseWheel: false
2132
- }
2133
- },
2134
- language: String(language),
2135
- value: String(element.value),
2136
- onChange: (value2) => {
2137
- plateCommon.setNodes(editor, { value: value2, lang: language });
2138
- }
2139
- }
2140
- )))
2643
+ checked: hasTopBorder,
2644
+ onCheckedChange: getOnSelectTableBorder("top")
2645
+ },
2646
+ /* @__PURE__ */ React.createElement(Icons.borderTop, { className: iconVariants({ size: "sm" }) }),
2647
+ /* @__PURE__ */ React.createElement("div", null, "Top Border")
2648
+ ),
2649
+ /* @__PURE__ */ React.createElement(
2650
+ DropdownMenuCheckboxItem,
2651
+ {
2652
+ checked: hasLeftBorder,
2653
+ onCheckedChange: getOnSelectTableBorder("left")
2654
+ },
2655
+ /* @__PURE__ */ React.createElement(Icons.borderLeft, { className: iconVariants({ size: "sm" }) }),
2656
+ /* @__PURE__ */ React.createElement("div", null, "Left Border")
2657
+ ),
2658
+ /* @__PURE__ */ React.createElement(
2659
+ DropdownMenuCheckboxItem,
2660
+ {
2661
+ checked: hasRightBorder,
2662
+ onCheckedChange: getOnSelectTableBorder("right")
2663
+ },
2664
+ /* @__PURE__ */ React.createElement(Icons.borderRight, { className: iconVariants({ size: "sm" }) }),
2665
+ /* @__PURE__ */ React.createElement("div", null, "Right Border")
2666
+ ),
2667
+ /* @__PURE__ */ React.createElement(Separator, null),
2668
+ /* @__PURE__ */ React.createElement(
2669
+ DropdownMenuCheckboxItem,
2670
+ {
2671
+ checked: hasNoBorders,
2672
+ onCheckedChange: getOnSelectTableBorder("none")
2673
+ },
2674
+ /* @__PURE__ */ React.createElement(Icons.borderNone, { className: iconVariants({ size: "sm" }) }),
2675
+ /* @__PURE__ */ React.createElement("div", null, "No Border")
2676
+ ),
2677
+ /* @__PURE__ */ React.createElement(
2678
+ DropdownMenuCheckboxItem,
2679
+ {
2680
+ checked: hasOuterBorders,
2681
+ onCheckedChange: getOnSelectTableBorder("outer")
2682
+ },
2683
+ /* @__PURE__ */ React.createElement(Icons.borderAll, { className: iconVariants({ size: "sm" }) }),
2684
+ /* @__PURE__ */ React.createElement("div", null, "Outside Borders")
2685
+ )
2141
2686
  );
2142
- };
2143
- const CodeBlockElement = cn$1.withRef(
2144
- ({ className, ...props }, ref) => {
2145
- const { element } = props;
2146
- const state = plateCodeBlock.useCodeBlockElementState({ element });
2147
- return /* @__PURE__ */ React.createElement(
2148
- plateCommon.PlateElement,
2687
+ });
2688
+ const TableFloatingToolbar = cn$1.withRef(
2689
+ ({ children, ...props }, ref) => {
2690
+ const element = plateCommon.useElement();
2691
+ const { props: buttonProps } = plateCommon.useRemoveNodeButton({ element });
2692
+ const selectionCollapsed = plateCommon.useEditorSelector(
2693
+ (editor2) => !plateCommon.isSelectionExpanded(editor2),
2694
+ []
2695
+ );
2696
+ const readOnly = slateReact.useReadOnly();
2697
+ const selected = slateReact.useSelected();
2698
+ const editor = plateCommon.useEditorRef();
2699
+ const collapsed = !readOnly && selected && selectionCollapsed;
2700
+ const open2 = !readOnly && selected;
2701
+ const { canMerge, canUnmerge } = plateTable.useTableMergeState();
2702
+ const mergeContent = canMerge && /* @__PURE__ */ React.createElement(
2703
+ Button$2,
2149
2704
  {
2150
- className: cn$1.cn("relative py-1", state.className, className),
2705
+ contentEditable: false,
2706
+ isMenu: true,
2707
+ onClick: () => plateTable.mergeTableCells(editor),
2708
+ variant: "ghost"
2709
+ },
2710
+ /* @__PURE__ */ React.createElement(Icons.combine, { className: "mr-2 size-4" }),
2711
+ "Merge"
2712
+ );
2713
+ const unmergeButton = canUnmerge && /* @__PURE__ */ React.createElement(
2714
+ Button$2,
2715
+ {
2716
+ contentEditable: false,
2717
+ isMenu: true,
2718
+ onClick: () => plateTable.unmergeTableCells(editor),
2719
+ variant: "ghost"
2720
+ },
2721
+ /* @__PURE__ */ React.createElement(Icons.ungroup, { className: "mr-2 size-4" }),
2722
+ "Unmerge"
2723
+ );
2724
+ const bordersContent = collapsed && /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(DropdownMenu, { modal: false }, /* @__PURE__ */ React.createElement(DropdownMenuTrigger, { asChild: true }, /* @__PURE__ */ React.createElement(Button$2, { isMenu: true, variant: "ghost" }, /* @__PURE__ */ React.createElement(Icons.borderAll, { className: "mr-2 size-4" }), "Borders")), /* @__PURE__ */ React.createElement(DropdownMenuPortal, null, /* @__PURE__ */ React.createElement(TableBordersDropdownMenuContent, null))), /* @__PURE__ */ React.createElement(Button$2, { contentEditable: false, isMenu: true, variant: "ghost", ...buttonProps }, /* @__PURE__ */ React.createElement(Icons.delete, { className: "mr-2 size-4" }), "Delete"));
2725
+ return /* @__PURE__ */ React.createElement(Popover$2, { modal: false, open: open2 }, /* @__PURE__ */ React.createElement(PopoverPrimitive.PopoverAnchor, { asChild: true }, children), (canMerge || canUnmerge || collapsed) && /* @__PURE__ */ React.createElement(
2726
+ PopoverContent$1,
2727
+ {
2728
+ className: cn$1.cn(
2729
+ popoverVariants(),
2730
+ "flex w-[220px] flex-col gap-1 p-1"
2731
+ ),
2732
+ onOpenAutoFocus: (e) => e.preventDefault(),
2151
2733
  ref,
2152
2734
  ...props
2153
2735
  },
2154
- /* @__PURE__ */ React.createElement(CodeBlock, { ...props })
2155
- );
2736
+ unmergeButton,
2737
+ mergeContent,
2738
+ bordersContent
2739
+ ));
2156
2740
  }
2157
2741
  );
2742
+ const TableElement = plateCommon.withHOC(
2743
+ plateTable.TableProvider,
2744
+ cn$1.withRef(({ children, className, ...props }, ref) => {
2745
+ const { colSizes, isSelectingCell, marginLeft, minColumnWidth } = plateTable.useTableElementState();
2746
+ const { colGroupProps, props: tableProps } = plateTable.useTableElement();
2747
+ return /* @__PURE__ */ React.createElement(TableFloatingToolbar, null, /* @__PURE__ */ React.createElement("div", { style: { paddingLeft: marginLeft } }, /* @__PURE__ */ React.createElement(
2748
+ plateCommon.PlateElement,
2749
+ {
2750
+ asChild: true,
2751
+ className: cn$1.cn(
2752
+ "my-4 ml-px mr-0 table h-px w-full table-fixed border-collapse",
2753
+ isSelectingCell && "[&_*::selection]:bg-none",
2754
+ className
2755
+ ),
2756
+ ref,
2757
+ ...tableProps,
2758
+ ...props
2759
+ },
2760
+ /* @__PURE__ */ React.createElement("table", null, /* @__PURE__ */ React.createElement("colgroup", { ...colGroupProps }, colSizes.map((width, index) => /* @__PURE__ */ React.createElement(
2761
+ "col",
2762
+ {
2763
+ key: index,
2764
+ style: {
2765
+ minWidth: minColumnWidth,
2766
+ width: width || void 0
2767
+ }
2768
+ }
2769
+ ))), /* @__PURE__ */ React.createElement("tbody", { className: "min-w-full" }, children))
2770
+ )));
2771
+ })
2772
+ );
2773
+ const TableRowElement = cn$1.withRef(({ children, hideBorder, ...props }, ref) => {
2774
+ return /* @__PURE__ */ React.createElement(
2775
+ plateCommon.PlateElement,
2776
+ {
2777
+ asChild: true,
2778
+ className: cn$1.cn("h-full", hideBorder && "border-none"),
2779
+ ref,
2780
+ ...props
2781
+ },
2782
+ /* @__PURE__ */ React.createElement("tr", null, children)
2783
+ );
2784
+ });
2158
2785
  const blockClasses = "mt-0.5";
2159
2786
  const headerClasses = "font-normal";
2160
2787
  const Components = () => {
@@ -2260,6 +2887,7 @@ var __publicField = (obj, key, value) => {
2260
2887
  }
2261
2888
  )
2262
2889
  ),
2890
+ [ELEMENT_MERMAID]: MermaidElement,
2263
2891
  [plate.ELEMENT_BLOCKQUOTE]: BlockquoteElement,
2264
2892
  [plate.ELEMENT_CODE_BLOCK]: CodeBlockElement,
2265
2893
  [plate.ELEMENT_CODE_LINE]: CodeLineElement,
@@ -2340,7 +2968,11 @@ var __publicField = (obj, key, value) => {
2340
2968
  children,
2341
2969
  selected && /* @__PURE__ */ React.createElement("span", { className: "absolute h-4 -top-2 inset-0 ring-2 ring-blue-100 ring-inset rounded-md z-10 pointer-events-none" })
2342
2970
  );
2343
- }
2971
+ },
2972
+ [plate.ELEMENT_TABLE]: TableElement,
2973
+ [plate.ELEMENT_TR]: TableRowElement,
2974
+ [plate.ELEMENT_TD]: TableCellElement,
2975
+ [plate.ELEMENT_TH]: TableCellHeaderElement
2344
2976
  };
2345
2977
  };
2346
2978
  const createCodeBlockPlugin = plateCommon.createPluginFactory({
@@ -2750,7 +3382,9 @@ var __publicField = (obj, key, value) => {
2750
3382
  {
2751
3383
  type: "string",
2752
3384
  label: "Caption",
2753
- name: [templateName.replace(/\.props$/, ""), "caption"].join("."),
3385
+ name: [templateName.replace(/\.props$/, ""), "caption"].join(
3386
+ "."
3387
+ ),
2754
3388
  component: "text"
2755
3389
  }
2756
3390
  ]
@@ -3068,7 +3702,7 @@ var __publicField = (obj, key, value) => {
3068
3702
  };
3069
3703
  const sizeClasses = {
3070
3704
  small: `text-xs h-8 px-3`,
3071
- medium: `text-sm h-10 px-4`,
3705
+ medium: `text-sm h-10 px-8`,
3072
3706
  custom: ``
3073
3707
  };
3074
3708
  return /* @__PURE__ */ React__namespace.createElement(
@@ -3196,7 +3830,7 @@ var __publicField = (obj, key, value) => {
3196
3830
  function _objectWithoutProperties(source, excluded) {
3197
3831
  if (source == null)
3198
3832
  return {};
3199
- var target = _objectWithoutPropertiesLoose$1(source, excluded);
3833
+ var target = _objectWithoutPropertiesLoose(source, excluded);
3200
3834
  var key, i;
3201
3835
  if (Object.getOwnPropertySymbols) {
3202
3836
  var sourceSymbolKeys = Object.getOwnPropertySymbols(source);
@@ -3211,7 +3845,7 @@ var __publicField = (obj, key, value) => {
3211
3845
  }
3212
3846
  return target;
3213
3847
  }
3214
- function _objectWithoutPropertiesLoose$1(source, excluded) {
3848
+ function _objectWithoutPropertiesLoose(source, excluded) {
3215
3849
  if (source == null)
3216
3850
  return {};
3217
3851
  var target = {};
@@ -4301,7 +4935,28 @@ var __publicField = (obj, key, value) => {
4301
4935
  onChange,
4302
4936
  value,
4303
4937
  step
4304
- }) => /* @__PURE__ */ React__namespace.createElement(Input, { type: "number", step, value, onChange });
4938
+ }) => /* @__PURE__ */ React__namespace.createElement(
4939
+ Input,
4940
+ {
4941
+ type: "number",
4942
+ step,
4943
+ value,
4944
+ onChange: (event) => {
4945
+ const inputValue = event.target.value;
4946
+ const newValue = inputValue === "" ? void 0 : inputValue;
4947
+ if (onChange) {
4948
+ const syntheticEvent = {
4949
+ ...event,
4950
+ target: {
4951
+ ...event.target,
4952
+ value: newValue
4953
+ }
4954
+ };
4955
+ onChange(syntheticEvent);
4956
+ }
4957
+ }
4958
+ }
4959
+ );
4305
4960
  function useCMS() {
4306
4961
  return useCMS$1();
4307
4962
  }
@@ -4410,7 +5065,7 @@ var __publicField = (obj, key, value) => {
4410
5065
  function cn(...inputs) {
4411
5066
  return tailwindMerge.twMerge(clsx.clsx(inputs));
4412
5067
  }
4413
- const buttonVariants$1 = classVarianceAuthority.cva(
5068
+ const buttonVariants = classVarianceAuthority.cva(
4414
5069
  "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",
4415
5070
  {
4416
5071
  variants: {
@@ -4436,7 +5091,7 @@ var __publicField = (obj, key, value) => {
4436
5091
  return /* @__PURE__ */ React__namespace.createElement(
4437
5092
  Comp,
4438
5093
  {
4439
- className: cn(buttonVariants$1({ variant, size, className })),
5094
+ className: cn(buttonVariants({ variant, size, className })),
4440
5095
  ref,
4441
5096
  ...props
4442
5097
  }
@@ -4542,7 +5197,7 @@ var __publicField = (obj, key, value) => {
4542
5197
  side: "bottom",
4543
5198
  className: cn(
4544
5199
  "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",
4545
- "max-h-[30vh] max-w-[30vh] overflow-y-auto",
5200
+ "max-h-[30vh] max-w-[30vw] overflow-y-auto",
4546
5201
  className
4547
5202
  ),
4548
5203
  ...props
@@ -4569,7 +5224,7 @@ var __publicField = (obj, key, value) => {
4569
5224
  const optionSets2 = await Promise.all(
4570
5225
  collections.map(async (collection) => {
4571
5226
  try {
4572
- const filter = filters[collection] ? filterQueryBuilder(filters[collection], collection) : {};
5227
+ const filter = (filters == null ? void 0 : filters[collection]) ? filterQueryBuilder(filters[collection], collection) : {};
4573
5228
  const response = await cms.api.tina.request(
4574
5229
  `#graphql
4575
5230
  query ($collection: String!, $filter: DocumentFilter) {
@@ -4605,6 +5260,10 @@ var __publicField = (obj, key, value) => {
4605
5260
  edges: response.collection.documents.edges
4606
5261
  };
4607
5262
  } catch (e) {
5263
+ console.error(
5264
+ "Exception thrown while building and running GraphQL query: ",
5265
+ e
5266
+ );
4608
5267
  return {
4609
5268
  collection,
4610
5269
  edges: []
@@ -4630,11 +5289,7 @@ var __publicField = (obj, key, value) => {
4630
5289
  const node = nodes.find((node2) => node2.id === value);
4631
5290
  return node ? node._internalSys.filename : null;
4632
5291
  };
4633
- const ComboboxDemo = ({
4634
- cms,
4635
- input,
4636
- field
4637
- }) => {
5292
+ const Combobox = ({ cms, input, field }) => {
4638
5293
  const [open2, setOpen] = React__namespace.useState(false);
4639
5294
  const [value, setValue] = React__namespace.useState(input.value);
4640
5295
  const [displayText, setDisplayText] = React__namespace.useState(null);
@@ -4658,17 +5313,17 @@ var __publicField = (obj, key, value) => {
4658
5313
  if (loading === true) {
4659
5314
  return /* @__PURE__ */ React__namespace.createElement(LoadingDots, { color: "var(--tina-color-primary)" });
4660
5315
  }
4661
- return /* @__PURE__ */ React__namespace.createElement(React__namespace.Fragment, null, /* @__PURE__ */ React__namespace.createElement(Popover, { open: open2, onOpenChange: setOpen }, /* @__PURE__ */ React__namespace.createElement(PopoverTrigger, { asChild: true }, /* @__PURE__ */ React__namespace.createElement(
5316
+ return /* @__PURE__ */ React__namespace.createElement(Popover, { open: open2, onOpenChange: setOpen }, /* @__PURE__ */ React__namespace.createElement(PopoverTrigger, { asChild: true }, /* @__PURE__ */ React__namespace.createElement(
4662
5317
  Button,
4663
5318
  {
4664
5319
  variant: "outline",
4665
5320
  role: "combobox",
4666
5321
  "aria-expanded": open2,
4667
- className: "w-52 justify-between"
5322
+ className: "w-full justify-between"
4668
5323
  },
4669
5324
  /* @__PURE__ */ React__namespace.createElement("p", { className: "truncate" }, displayText ?? "Choose an option..."),
4670
5325
  open2 ? /* @__PURE__ */ React__namespace.createElement(IoMdArrowDropup, { size: 20 }) : /* @__PURE__ */ React__namespace.createElement(IoMdArrowDropdown, { size: 20 })
4671
- )), /* @__PURE__ */ React__namespace.createElement(PopoverContent, { className: "p-0 relative" }, /* @__PURE__ */ React__namespace.createElement(
5326
+ )), /* @__PURE__ */ React__namespace.createElement(PopoverContent, { className: "p-0 relative min-w-[var(--radix-popover-trigger-width)]" }, /* @__PURE__ */ React__namespace.createElement(
4672
5327
  Command,
4673
5328
  {
4674
5329
  shouldFilter: !field.experimental___filter,
@@ -4692,32 +5347,25 @@ var __publicField = (obj, key, value) => {
4692
5347
  }
4693
5348
  ),
4694
5349
  /* @__PURE__ */ React__namespace.createElement(CommandEmpty, null, "No reference found"),
4695
- /* @__PURE__ */ React__namespace.createElement(CommandList, null, filteredOptionsList.length > 0 && (filteredOptionsList == null ? void 0 : filteredOptionsList.map(({ collection, edges }) => /* @__PURE__ */ React__namespace.createElement(
4696
- CommandGroup,
4697
- {
4698
- key: `${collection}-group`,
4699
- heading: collection
4700
- },
4701
- /* @__PURE__ */ React__namespace.createElement(CommandList, null, edges == null ? void 0 : edges.map(({ node }) => {
4702
- const { id, _values } = node;
4703
- return /* @__PURE__ */ React__namespace.createElement(
4704
- OptionComponent,
4705
- {
4706
- id,
4707
- key: id,
4708
- value,
4709
- field,
4710
- _values,
4711
- node,
4712
- onSelect: (currentValue) => {
4713
- setValue(currentValue);
4714
- setOpen(false);
4715
- }
5350
+ /* @__PURE__ */ React__namespace.createElement(CommandList, null, filteredOptionsList.length > 0 && (filteredOptionsList == null ? void 0 : filteredOptionsList.map(({ collection, edges }) => /* @__PURE__ */ React__namespace.createElement(CommandGroup, { key: `${collection}-group`, heading: collection }, /* @__PURE__ */ React__namespace.createElement(CommandList, null, edges == null ? void 0 : edges.map(({ node }) => {
5351
+ const { id, _values } = node;
5352
+ return /* @__PURE__ */ React__namespace.createElement(
5353
+ OptionComponent,
5354
+ {
5355
+ id,
5356
+ key: id,
5357
+ value,
5358
+ field,
5359
+ _values,
5360
+ node,
5361
+ onSelect: (currentValue) => {
5362
+ setValue(currentValue);
5363
+ setOpen(false);
4716
5364
  }
4717
- );
4718
- }))
4719
- ))))
4720
- ))));
5365
+ }
5366
+ );
5367
+ }))))))
5368
+ )));
4721
5369
  };
4722
5370
  const useGetNode = (cms, id) => {
4723
5371
  const [document2, setDocument] = React__namespace.useState(
@@ -4790,7 +5438,7 @@ var __publicField = (obj, key, value) => {
4790
5438
  };
4791
5439
  const Reference = ({ input, field }) => {
4792
5440
  const cms = useCMS();
4793
- return /* @__PURE__ */ React__namespace.createElement("div", null, /* @__PURE__ */ React__namespace.createElement("div", { className: "relative group" }, /* @__PURE__ */ React__namespace.createElement(ComboboxDemo, { cms, input, field })), /* @__PURE__ */ React__namespace.createElement(ReferenceLink, { cms, input }));
5441
+ return /* @__PURE__ */ React__namespace.createElement(React__namespace.Fragment, null, /* @__PURE__ */ React__namespace.createElement("div", { className: "relative group" }, /* @__PURE__ */ React__namespace.createElement(Combobox, { cms, input, field })), /* @__PURE__ */ React__namespace.createElement(ReferenceLink, { cms, input }));
4794
5442
  };
4795
5443
  const ButtonToggle = ({
4796
5444
  input,
@@ -5098,10 +5746,11 @@ var __publicField = (obj, key, value) => {
5098
5746
  return /* @__PURE__ */ React.createElement(
5099
5747
  "button",
5100
5748
  {
5101
- 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"}`,
5749
+ type: "button",
5750
+ 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"}`,
5102
5751
  onClick
5103
5752
  },
5104
- /* @__PURE__ */ React.createElement(TrashIcon, { className: "fill-current transition-colors ease-out duration-100" })
5753
+ /* @__PURE__ */ React.createElement(TrashIcon, { className: "h-5 w-auto fill-current text-red-500 transition-colors duration-150 ease-out" })
5105
5754
  );
5106
5755
  };
5107
5756
  const DragHandle = ({ isDragging }) => {
@@ -5131,7 +5780,7 @@ var __publicField = (obj, key, value) => {
5131
5780
  return template.label ? template.label.toLowerCase().includes(filter.toLowerCase()) || name.toLowerCase().includes(filter.toLowerCase()) : name.toLowerCase().includes(filter.toLowerCase());
5132
5781
  });
5133
5782
  }, [filter]);
5134
- return /* @__PURE__ */ React__namespace.createElement(react$1.Popover, null, ({ open: open2 }) => /* @__PURE__ */ React__namespace.createElement(React__namespace.Fragment, null, /* @__PURE__ */ React__namespace.createElement(react$1.PopoverButton, { as: "span" }, /* @__PURE__ */ React__namespace.createElement(
5783
+ return /* @__PURE__ */ React__namespace.createElement(react.Popover, null, ({ open: open2 }) => /* @__PURE__ */ React__namespace.createElement(React__namespace.Fragment, null, /* @__PURE__ */ React__namespace.createElement(react.PopoverButton, { as: "span" }, /* @__PURE__ */ React__namespace.createElement(
5135
5784
  IconButton,
5136
5785
  {
5137
5786
  variant: open2 ? "secondary" : "primary",
@@ -5140,7 +5789,7 @@ var __publicField = (obj, key, value) => {
5140
5789
  },
5141
5790
  /* @__PURE__ */ React__namespace.createElement(AddIcon, { className: "w-5/6 h-auto" })
5142
5791
  )), /* @__PURE__ */ React__namespace.createElement("div", { className: "transform translate-y-full absolute -bottom-1 right-0 z-50" }, /* @__PURE__ */ React__namespace.createElement(
5143
- react$1.Transition,
5792
+ react.Transition,
5144
5793
  {
5145
5794
  enter: "transition duration-150 ease-out",
5146
5795
  enterFrom: "transform opacity-0 -translate-y-2",
@@ -5149,7 +5798,7 @@ var __publicField = (obj, key, value) => {
5149
5798
  leaveFrom: "transform opacity-100 translate-y-0",
5150
5799
  leaveTo: "transform opacity-0 -translate-y-2"
5151
5800
  },
5152
- /* @__PURE__ */ React__namespace.createElement(react$1.PopoverPanel, { className: "relative overflow-hidden rounded-lg shadow-lg bg-white border border-gray-100" }, ({ close: close2 }) => /* @__PURE__ */ React__namespace.createElement("div", { className: "min-w-[192px] max-h-[24rem] overflow-y-auto flex flex-col w-full h-full" }, showFilter && /* @__PURE__ */ React__namespace.createElement("div", { className: "sticky top-0 bg-gray-50 p-2 border-b border-gray-100 z-10" }, /* @__PURE__ */ React__namespace.createElement(
5801
+ /* @__PURE__ */ React__namespace.createElement(react.PopoverPanel, { className: "relative overflow-hidden rounded-lg shadow-lg bg-white border border-gray-100" }, ({ close: close2 }) => /* @__PURE__ */ React__namespace.createElement("div", { className: "min-w-[192px] max-h-[24rem] overflow-y-auto flex flex-col w-full h-full" }, showFilter && /* @__PURE__ */ React__namespace.createElement("div", { className: "sticky top-0 bg-gray-50 p-2 border-b border-gray-100 z-10" }, /* @__PURE__ */ React__namespace.createElement(
5153
5802
  "input",
5154
5803
  {
5155
5804
  type: "text",
@@ -5179,27 +5828,35 @@ var __publicField = (obj, key, value) => {
5179
5828
  ))))
5180
5829
  ))));
5181
5830
  };
5182
- const Group = wrapFieldWithError(({ tinaForm, field }) => {
5183
- const cms = useCMS$1();
5184
- React__namespace.useState(false);
5185
- return /* @__PURE__ */ React__namespace.createElement(React__namespace.Fragment, null, /* @__PURE__ */ React__namespace.createElement(
5186
- Header,
5187
- {
5188
- onClick: () => {
5189
- const state = tinaForm.finalForm.getState();
5190
- if (state.invalid === true) {
5191
- cms.alerts.error("Cannot navigate away from an invalid form.");
5192
- return;
5831
+ const Group = wrapFieldWithNoHeader(
5832
+ ({ tinaForm, field }) => {
5833
+ const cms = useCMS$1();
5834
+ return /* @__PURE__ */ React__namespace.createElement(React__namespace.Fragment, null, /* @__PURE__ */ React__namespace.createElement(
5835
+ Header,
5836
+ {
5837
+ onClick: () => {
5838
+ const state = tinaForm.finalForm.getState();
5839
+ if (state.invalid === true) {
5840
+ cms.alerts.error("Cannot navigate away from an invalid form.");
5841
+ return;
5842
+ }
5843
+ cms.dispatch({
5844
+ type: "forms:set-active-field-name",
5845
+ value: { formId: tinaForm.id, fieldName: field.name }
5846
+ });
5193
5847
  }
5194
- cms.dispatch({
5195
- type: "forms:set-active-field-name",
5196
- value: { formId: tinaForm.id, fieldName: field.name }
5197
- });
5198
- }
5199
- },
5200
- field.label || field.name
5201
- ));
5202
- });
5848
+ },
5849
+ field.label || field.name,
5850
+ field.description && /* @__PURE__ */ React__namespace.createElement(
5851
+ "span",
5852
+ {
5853
+ className: `block font-sans text-xs italic font-light text-gray-400 pt-0.5 whitespace-normal m-0`,
5854
+ dangerouslySetInnerHTML: { __html: field.description }
5855
+ }
5856
+ )
5857
+ ));
5858
+ }
5859
+ );
5203
5860
  const Header = ({ onClick, children }) => {
5204
5861
  return /* @__PURE__ */ React__namespace.createElement("div", { className: "pt-1 mb-5" }, /* @__PURE__ */ React__namespace.createElement(
5205
5862
  "button",
@@ -5326,8 +5983,8 @@ var __publicField = (obj, key, value) => {
5326
5983
  onClick: () => setPickerIsOpen(!pickerIsOpen)
5327
5984
  },
5328
5985
  /* @__PURE__ */ React__namespace.createElement(AddIcon, { className: "w-5/6 h-auto" })
5329
- ), /* @__PURE__ */ React__namespace.createElement(FormPortal, null, ({ zIndexShift }) => /* @__PURE__ */ React__namespace.createElement(react$1.Transition, { show: pickerIsOpen }, /* @__PURE__ */ React__namespace.createElement(
5330
- react$1.TransitionChild,
5986
+ ), /* @__PURE__ */ React__namespace.createElement(FormPortal, null, ({ zIndexShift }) => /* @__PURE__ */ React__namespace.createElement(react.Transition, { show: pickerIsOpen }, /* @__PURE__ */ React__namespace.createElement(
5987
+ react.TransitionChild,
5331
5988
  {
5332
5989
  enter: "transform transition-all ease-out duration-200",
5333
5990
  enterFrom: "opacity-0 -translate-x-1/2",
@@ -5414,14 +6071,14 @@ var __publicField = (obj, key, value) => {
5414
6071
  };
5415
6072
  const BlockGroup = ({ category, templates, close: close2, isLast = false }) => {
5416
6073
  return /* @__PURE__ */ React__namespace.createElement(
5417
- react$1.Disclosure,
6074
+ react.Disclosure,
5418
6075
  {
5419
6076
  defaultOpen: true,
5420
6077
  as: "div",
5421
6078
  className: `left-0 right-0 relative`
5422
6079
  },
5423
6080
  ({ open: open2 }) => /* @__PURE__ */ React__namespace.createElement(React__namespace.Fragment, null, /* @__PURE__ */ React__namespace.createElement(
5424
- react$1.DisclosureButton,
6081
+ react.DisclosureButton,
5425
6082
  {
5426
6083
  className: `relative block group text-left w-full text-base font-bold tracking-wide py-2 truncate ${templates.length === 0 ? `pointer-events-none` : ``} ${!isLast && (!open2 || templates.length === 0) && `border-b border-gray-100`}`
5427
6084
  },
@@ -5439,7 +6096,7 @@ var __publicField = (obj, key, value) => {
5439
6096
  }
5440
6097
  )
5441
6098
  ), /* @__PURE__ */ React__namespace.createElement(
5442
- react$1.Transition,
6099
+ react.Transition,
5443
6100
  {
5444
6101
  enter: "transition duration-100 ease-out",
5445
6102
  enterFrom: "transform scale-95 opacity-0",
@@ -5448,7 +6105,7 @@ var __publicField = (obj, key, value) => {
5448
6105
  leaveFrom: "transform scale-100 opacity-100",
5449
6106
  leaveTo: "transform scale-95 opacity-0"
5450
6107
  },
5451
- /* @__PURE__ */ React__namespace.createElement(react$1.DisclosurePanel, null, templates.length > 0 && /* @__PURE__ */ React__namespace.createElement(CardColumns, null, templates.map(([name, template], index) => /* @__PURE__ */ React__namespace.createElement(
6108
+ /* @__PURE__ */ React__namespace.createElement(react.DisclosurePanel, null, templates.length > 0 && /* @__PURE__ */ React__namespace.createElement(CardColumns, null, templates.map(([name, template], index) => /* @__PURE__ */ React__namespace.createElement(
5452
6109
  BlockCard,
5453
6110
  {
5454
6111
  key: index,
@@ -6541,244 +7198,65 @@ var __publicField = (obj, key, value) => {
6541
7198
  str = "0" + str;
6542
7199
  return str;
6543
7200
  }
6544
- function _inheritsLoose(subClass, superClass) {
6545
- subClass.prototype = Object.create(superClass.prototype);
6546
- subClass.prototype.constructor = subClass;
6547
- _setPrototypeOf(subClass, superClass);
6548
- }
6549
- function _setPrototypeOf(o, p) {
6550
- _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf2(o2, p2) {
6551
- o2.__proto__ = p2;
6552
- return o2;
6553
- };
6554
- return _setPrototypeOf(o, p);
6555
- }
6556
- function _objectWithoutPropertiesLoose(source, excluded) {
6557
- if (source == null)
6558
- return {};
6559
- var target = {};
6560
- var sourceKeys = Object.keys(source);
6561
- var key, i;
6562
- for (i = 0; i < sourceKeys.length; i++) {
6563
- key = sourceKeys[i];
6564
- if (excluded.indexOf(key) >= 0)
6565
- continue;
6566
- target[key] = source[key];
6567
- }
6568
- return target;
6569
- }
6570
- function _assertThisInitialized(self2) {
6571
- if (self2 === void 0) {
6572
- throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
6573
- }
6574
- return self2;
6575
- }
6576
- function isNodeFound(current, componentNode, ignoreClass) {
6577
- if (current === componentNode) {
6578
- return true;
7201
+ var useClickAway$1 = {};
7202
+ var util = {};
7203
+ Object.defineProperty(util, "__esModule", { value: true });
7204
+ util.isNavigator = util.isBrowser = util.off = util.on = util.noop = void 0;
7205
+ var noop = function() {
7206
+ };
7207
+ util.noop = noop;
7208
+ function on(obj) {
7209
+ var args = [];
7210
+ for (var _i = 1; _i < arguments.length; _i++) {
7211
+ args[_i - 1] = arguments[_i];
6579
7212
  }
6580
- if (current.correspondingElement) {
6581
- return current.correspondingElement.classList.contains(ignoreClass);
7213
+ if (obj && obj.addEventListener) {
7214
+ obj.addEventListener.apply(obj, args);
6582
7215
  }
6583
- return current.classList.contains(ignoreClass);
6584
7216
  }
6585
- function findHighest(current, componentNode, ignoreClass) {
6586
- if (current === componentNode) {
6587
- return true;
7217
+ util.on = on;
7218
+ function off(obj) {
7219
+ var args = [];
7220
+ for (var _i = 1; _i < arguments.length; _i++) {
7221
+ args[_i - 1] = arguments[_i];
6588
7222
  }
6589
- while (current.parentNode || current.host) {
6590
- if (current.parentNode && isNodeFound(current, componentNode, ignoreClass)) {
6591
- return true;
6592
- }
6593
- current = current.parentNode || current.host;
7223
+ if (obj && obj.removeEventListener) {
7224
+ obj.removeEventListener.apply(obj, args);
6594
7225
  }
6595
- return current;
6596
- }
6597
- function clickedScrollbar(evt) {
6598
- return document.documentElement.clientWidth <= evt.clientX || document.documentElement.clientHeight <= evt.clientY;
6599
7226
  }
6600
- var testPassiveEventSupport = function testPassiveEventSupport2() {
6601
- if (typeof window === "undefined" || typeof window.addEventListener !== "function") {
6602
- return;
6603
- }
6604
- var passive = false;
6605
- var options = Object.defineProperty({}, "passive", {
6606
- get: function get2() {
6607
- passive = true;
6608
- }
6609
- });
6610
- var noop = function noop2() {
6611
- };
6612
- window.addEventListener("testPassiveEventSupport", noop, options);
6613
- window.removeEventListener("testPassiveEventSupport", noop, options);
6614
- return passive;
6615
- };
6616
- function autoInc(seed) {
6617
- if (seed === void 0) {
6618
- seed = 0;
6619
- }
6620
- return function() {
6621
- return ++seed;
6622
- };
6623
- }
6624
- var uid = autoInc();
6625
- var passiveEventSupport;
6626
- var handlersMap = {};
6627
- var enabledInstances = {};
6628
- var touchEvents = ["touchstart", "touchmove"];
6629
- var IGNORE_CLASS_NAME = "ignore-react-onclickoutside";
6630
- function getEventHandlerOptions(instance, eventName) {
6631
- var handlerOptions = {};
6632
- var isTouchEvent = touchEvents.indexOf(eventName) !== -1;
6633
- if (isTouchEvent && passiveEventSupport) {
6634
- handlerOptions.passive = !instance.props.preventDefault;
6635
- }
6636
- return handlerOptions;
6637
- }
6638
- function onClickOutsideHOC(WrappedComponent, config) {
6639
- var _class, _temp;
6640
- var componentName = WrappedComponent.displayName || WrappedComponent.name || "Component";
6641
- return _temp = _class = /* @__PURE__ */ function(_Component) {
6642
- _inheritsLoose(onClickOutside, _Component);
6643
- function onClickOutside(props) {
6644
- var _this;
6645
- _this = _Component.call(this, props) || this;
6646
- _this.__outsideClickHandler = function(event) {
6647
- if (typeof _this.__clickOutsideHandlerProp === "function") {
6648
- _this.__clickOutsideHandlerProp(event);
6649
- return;
6650
- }
6651
- var instance = _this.getInstance();
6652
- if (typeof instance.props.handleClickOutside === "function") {
6653
- instance.props.handleClickOutside(event);
6654
- return;
6655
- }
6656
- if (typeof instance.handleClickOutside === "function") {
6657
- instance.handleClickOutside(event);
6658
- return;
6659
- }
6660
- throw new Error("WrappedComponent: " + componentName + " lacks a handleClickOutside(event) function for processing outside click events.");
6661
- };
6662
- _this.__getComponentNode = function() {
6663
- var instance = _this.getInstance();
6664
- if (config && typeof config.setClickOutsideRef === "function") {
6665
- return config.setClickOutsideRef()(instance);
6666
- }
6667
- if (typeof instance.setClickOutsideRef === "function") {
6668
- return instance.setClickOutsideRef();
6669
- }
6670
- return reactDom.findDOMNode(instance);
6671
- };
6672
- _this.enableOnClickOutside = function() {
6673
- if (typeof document === "undefined" || enabledInstances[_this._uid]) {
6674
- return;
6675
- }
6676
- if (typeof passiveEventSupport === "undefined") {
6677
- passiveEventSupport = testPassiveEventSupport();
6678
- }
6679
- enabledInstances[_this._uid] = true;
6680
- var events = _this.props.eventTypes;
6681
- if (!events.forEach) {
6682
- events = [events];
6683
- }
6684
- handlersMap[_this._uid] = function(event) {
6685
- if (_this.componentNode === null)
6686
- return;
6687
- if (_this.initTimeStamp > event.timeStamp)
6688
- return;
6689
- if (_this.props.preventDefault) {
6690
- event.preventDefault();
6691
- }
6692
- if (_this.props.stopPropagation) {
6693
- event.stopPropagation();
6694
- }
6695
- if (_this.props.excludeScrollbar && clickedScrollbar(event))
6696
- return;
6697
- var current = event.composed && event.composedPath && event.composedPath().shift() || event.target;
6698
- if (findHighest(current, _this.componentNode, _this.props.outsideClickIgnoreClass) !== document) {
6699
- return;
6700
- }
6701
- _this.__outsideClickHandler(event);
6702
- };
6703
- events.forEach(function(eventName) {
6704
- document.addEventListener(eventName, handlersMap[_this._uid], getEventHandlerOptions(_assertThisInitialized(_this), eventName));
6705
- });
6706
- };
6707
- _this.disableOnClickOutside = function() {
6708
- delete enabledInstances[_this._uid];
6709
- var fn = handlersMap[_this._uid];
6710
- if (fn && typeof document !== "undefined") {
6711
- var events = _this.props.eventTypes;
6712
- if (!events.forEach) {
6713
- events = [events];
6714
- }
6715
- events.forEach(function(eventName) {
6716
- return document.removeEventListener(eventName, fn, getEventHandlerOptions(_assertThisInitialized(_this), eventName));
6717
- });
6718
- delete handlersMap[_this._uid];
6719
- }
6720
- };
6721
- _this.getRef = function(ref) {
6722
- return _this.instanceRef = ref;
6723
- };
6724
- _this._uid = uid();
6725
- _this.initTimeStamp = performance.now();
6726
- return _this;
6727
- }
6728
- var _proto = onClickOutside.prototype;
6729
- _proto.getInstance = function getInstance() {
6730
- if (WrappedComponent.prototype && !WrappedComponent.prototype.isReactComponent) {
6731
- return this;
6732
- }
6733
- var ref = this.instanceRef;
6734
- return ref.getInstance ? ref.getInstance() : ref;
7227
+ util.off = off;
7228
+ util.isBrowser = typeof window !== "undefined";
7229
+ util.isNavigator = typeof navigator !== "undefined";
7230
+ Object.defineProperty(useClickAway$1, "__esModule", { value: true });
7231
+ var react_1 = React;
7232
+ var util_1 = util;
7233
+ var defaultEvents = ["mousedown", "touchstart"];
7234
+ var useClickAway = function(ref, onClickAway, events) {
7235
+ if (events === void 0) {
7236
+ events = defaultEvents;
7237
+ }
7238
+ var savedCallback = react_1.useRef(onClickAway);
7239
+ react_1.useEffect(function() {
7240
+ savedCallback.current = onClickAway;
7241
+ }, [onClickAway]);
7242
+ react_1.useEffect(function() {
7243
+ var handler = function(event) {
7244
+ var el = ref.current;
7245
+ el && !el.contains(event.target) && savedCallback.current(event);
6735
7246
  };
6736
- _proto.componentDidMount = function componentDidMount() {
6737
- if (typeof document === "undefined" || !document.createElement) {
6738
- return;
6739
- }
6740
- var instance = this.getInstance();
6741
- if (config && typeof config.handleClickOutside === "function") {
6742
- this.__clickOutsideHandlerProp = config.handleClickOutside(instance);
6743
- if (typeof this.__clickOutsideHandlerProp !== "function") {
6744
- throw new Error("WrappedComponent: " + componentName + " lacks a function for processing outside click events specified by the handleClickOutside config option.");
6745
- }
6746
- }
6747
- this.componentNode = this.__getComponentNode();
6748
- if (this.props.disableOnClickOutside)
6749
- return;
6750
- this.enableOnClickOutside();
6751
- };
6752
- _proto.componentDidUpdate = function componentDidUpdate() {
6753
- this.componentNode = this.__getComponentNode();
6754
- };
6755
- _proto.componentWillUnmount = function componentWillUnmount() {
6756
- this.disableOnClickOutside();
6757
- };
6758
- _proto.render = function render() {
6759
- var _this$props = this.props;
6760
- _this$props.excludeScrollbar;
6761
- var props = _objectWithoutPropertiesLoose(_this$props, ["excludeScrollbar"]);
6762
- if (WrappedComponent.prototype && WrappedComponent.prototype.isReactComponent) {
6763
- props.ref = this.getRef;
6764
- } else {
6765
- props.wrappedRef = this.getRef;
7247
+ for (var _i = 0, events_1 = events; _i < events_1.length; _i++) {
7248
+ var eventName = events_1[_i];
7249
+ util_1.on(document, eventName, handler);
7250
+ }
7251
+ return function() {
7252
+ for (var _i2 = 0, events_2 = events; _i2 < events_2.length; _i2++) {
7253
+ var eventName2 = events_2[_i2];
7254
+ util_1.off(document, eventName2, handler);
6766
7255
  }
6767
- props.disableOnClickOutside = this.disableOnClickOutside;
6768
- props.enableOnClickOutside = this.enableOnClickOutside;
6769
- return React.createElement(WrappedComponent, props);
6770
7256
  };
6771
- return onClickOutside;
6772
- }(React.Component), _class.displayName = "OnClickOutside(" + componentName + ")", _class.defaultProps = {
6773
- eventTypes: ["mousedown", "touchstart"],
6774
- excludeScrollbar: config && config.excludeScrollbar || false,
6775
- outsideClickIgnoreClass: IGNORE_CLASS_NAME,
6776
- preventDefault: false,
6777
- stopPropagation: false
6778
- }, _class.getClass = function() {
6779
- return WrappedComponent.getClass ? WrappedComponent.getClass() : WrappedComponent;
6780
- }, _temp;
6781
- }
7257
+ }, [events, ref]);
7258
+ };
7259
+ var _default = useClickAway$1.default = useClickAway;
6782
7260
  const viewModes = {
6783
7261
  YEARS: "years",
6784
7262
  MONTHS: "months",
@@ -7307,22 +7785,13 @@ var __publicField = (obj, key, value) => {
7307
7785
  }
7308
7786
  con[method]("***react-datetime:" + message);
7309
7787
  }
7310
- class ClickOutBase extends React.Component {
7311
- constructor() {
7312
- super(...arguments);
7313
- __publicField(this, "container", React.createRef());
7314
- }
7315
- render() {
7316
- return /* @__PURE__ */ React.createElement("div", { className: this.props.className, ref: this.container }, this.props.children);
7317
- }
7318
- handleClickOutside(e) {
7319
- this.props.onClickOut(e);
7320
- }
7321
- setClickOutsideRef() {
7322
- return this.container.current;
7323
- }
7788
+ function ClickableWrapper({ className, onClickOut, children }) {
7789
+ const containerRef = React.useRef(null);
7790
+ _default(containerRef, (event) => {
7791
+ onClickOut(event);
7792
+ });
7793
+ return /* @__PURE__ */ React.createElement("div", { className, ref: containerRef }, children);
7324
7794
  }
7325
- const ClickableWrapper = onClickOutsideHOC(ClickOutBase);
7326
7795
  const DEFAULT_DATE_DISPLAY_FORMAT = "MMM DD, YYYY";
7327
7796
  const DEFAULT_TIME_DISPLAY_FORMAT = "h:mm A";
7328
7797
  const format$1 = (val, _name, field) => {
@@ -7365,7 +7834,10 @@ var __publicField = (obj, key, value) => {
7365
7834
  ReactDateTimeWithStyles,
7366
7835
  {
7367
7836
  value: input.value,
7368
- onChange: input.onChange,
7837
+ onChange: (value) => {
7838
+ const newValue = value === "" ? void 0 : value;
7839
+ input.onChange(newValue);
7840
+ },
7369
7841
  dateFormat: dateFormat || DEFAULT_DATE_DISPLAY_FORMAT,
7370
7842
  timeFormat: timeFormat || false,
7371
7843
  inputProps: { className: textFieldClasses },
@@ -8817,6 +9289,19 @@ var __publicField = (obj, key, value) => {
8817
9289
  }
8818
9290
  }
8819
9291
  }
9292
+ const encodeUrlIfNeeded = (url) => {
9293
+ if (url) {
9294
+ try {
9295
+ const parsed = new URL(url);
9296
+ parsed.pathname = parsed.pathname.split("/").filter((part) => part !== "").map(encodeURIComponent).join("/");
9297
+ return parsed.toString();
9298
+ } catch (e) {
9299
+ return url;
9300
+ }
9301
+ } else {
9302
+ return url;
9303
+ }
9304
+ };
8820
9305
  let MediaManager$1 = class MediaManager {
8821
9306
  constructor(store, events) {
8822
9307
  this.store = store;
@@ -8889,6 +9374,20 @@ var __publicField = (obj, key, value) => {
8889
9374
  try {
8890
9375
  this.events.dispatch({ type: "media:list:start", ...options });
8891
9376
  const media = await this.store.list(options);
9377
+ media.items = media.items.map((item) => {
9378
+ if (item.type === "dir") {
9379
+ return item;
9380
+ }
9381
+ if (item.thumbnails) {
9382
+ for (const [size, src] of Object.entries(item.thumbnails)) {
9383
+ item.thumbnails[size] = encodeUrlIfNeeded(src);
9384
+ }
9385
+ }
9386
+ return {
9387
+ ...item,
9388
+ src: encodeUrlIfNeeded(item.src)
9389
+ };
9390
+ });
8892
9391
  this.events.dispatch({ type: "media:list:success", ...options, media });
8893
9392
  return media;
8894
9393
  } catch (error) {
@@ -9267,7 +9766,7 @@ var __publicField = (obj, key, value) => {
9267
9766
  const FormLists = (props) => {
9268
9767
  const cms = useCMS();
9269
9768
  return /* @__PURE__ */ React__namespace.createElement(
9270
- react$1.Transition,
9769
+ react.Transition,
9271
9770
  {
9272
9771
  appear: true,
9273
9772
  show: true,
@@ -9696,7 +10195,7 @@ var __publicField = (obj, key, value) => {
9696
10195
  "Event Log"
9697
10196
  ));
9698
10197
  };
9699
- const version = "2.2.8";
10198
+ const version = "2.6.4";
9700
10199
  const Nav = ({
9701
10200
  isLocalMode,
9702
10201
  className = "",
@@ -9750,8 +10249,8 @@ var __publicField = (obj, key, value) => {
9750
10249
  style: { maxWidth: `${sidebarWidth}px` },
9751
10250
  ...props
9752
10251
  },
9753
- /* @__PURE__ */ React__namespace.createElement("div", { className: "border-b border-gray-200" }, /* @__PURE__ */ React__namespace.createElement(react$1.Menu, { as: "div", className: "relative block" }, ({ open: open2 }) => /* @__PURE__ */ React__namespace.createElement("div", null, /* @__PURE__ */ React__namespace.createElement(
9754
- react$1.MenuButton,
10252
+ /* @__PURE__ */ React__namespace.createElement("div", { className: "border-b border-gray-200" }, /* @__PURE__ */ React__namespace.createElement(react.Menu, { as: "div", className: "relative block" }, ({ open: open2 }) => /* @__PURE__ */ React__namespace.createElement("div", null, /* @__PURE__ */ React__namespace.createElement(
10253
+ react.MenuButton,
9755
10254
  {
9756
10255
  className: `group w-full px-6 py-3 gap-2 flex justify-between items-center transition-colors duration-150 ease-out ${open2 ? "bg-gray-50" : "bg-transparent"}`
9757
10256
  },
@@ -9774,7 +10273,7 @@ var __publicField = (obj, key, value) => {
9774
10273
  }
9775
10274
  )
9776
10275
  ), /* @__PURE__ */ React__namespace.createElement("div", { className: "transform translate-y-full absolute bottom-3 right-5 z-50" }, /* @__PURE__ */ React__namespace.createElement(
9777
- react$1.Transition,
10276
+ react.Transition,
9778
10277
  {
9779
10278
  enter: "transition duration-150 ease-out",
9780
10279
  enterFrom: "transform opacity-0 -translate-y-2",
@@ -9783,7 +10282,7 @@ var __publicField = (obj, key, value) => {
9783
10282
  leaveFrom: "transform opacity-100 translate-y-0",
9784
10283
  leaveTo: "transform opacity-0 -translate-y-2"
9785
10284
  },
9786
- /* @__PURE__ */ React__namespace.createElement(react$1.MenuItems, { className: "bg-white border border-gray-150 rounded-lg shadow-lg flex flex-col items-stretch overflow-hidden" }, /* @__PURE__ */ React__namespace.createElement(react$1.MenuItem, null, /* @__PURE__ */ React__namespace.createElement(
10285
+ /* @__PURE__ */ React__namespace.createElement(react.MenuItems, { className: "bg-white border border-gray-150 rounded-lg shadow-lg flex flex-col items-stretch overflow-hidden" }, /* @__PURE__ */ React__namespace.createElement(react.MenuItem, null, /* @__PURE__ */ React__namespace.createElement(
9787
10286
  "button",
9788
10287
  {
9789
10288
  className: `text-lg px-4 py-2 first:pt-3 last:pb-3 tracking-wide whitespace-nowrap flex items-center opacity-80 text-gray-600 hover:text-blue-400 hover:bg-gray-50 hover:opacity-100`,
@@ -9816,7 +10315,7 @@ var __publicField = (obj, key, value) => {
9816
10315
  },
9817
10316
  /* @__PURE__ */ React__namespace.createElement(BiExit, { className: "w-6 h-auto mr-2 text-blue-400" }),
9818
10317
  " Log Out"
9819
- )), /* @__PURE__ */ React__namespace.createElement(react$1.MenuItem, null, /* @__PURE__ */ React__namespace.createElement(
10318
+ )), /* @__PURE__ */ React__namespace.createElement(react.MenuItem, null, /* @__PURE__ */ React__namespace.createElement(
9820
10319
  WrappedSyncStatus,
9821
10320
  {
9822
10321
  cms,
@@ -10162,8 +10661,8 @@ var __publicField = (obj, key, value) => {
10162
10661
  screen: activeScreen,
10163
10662
  close: () => setActiveView(null)
10164
10663
  }
10165
- )), /* @__PURE__ */ React__namespace.createElement(ResizeHandle, null)), renderMobileNav && /* @__PURE__ */ React__namespace.createElement(react$1.Transition, { show: menuIsOpen, as: "div" }, /* @__PURE__ */ React__namespace.createElement(
10166
- react$1.TransitionChild,
10664
+ )), /* @__PURE__ */ React__namespace.createElement(ResizeHandle, null)), renderMobileNav && /* @__PURE__ */ React__namespace.createElement(react.Transition, { show: menuIsOpen, as: "div" }, /* @__PURE__ */ React__namespace.createElement(
10665
+ react.TransitionChild,
10167
10666
  {
10168
10667
  enter: "transform transition-all ease-out duration-300",
10169
10668
  enterFrom: "opacity-0 -translate-x-full",
@@ -10228,7 +10727,7 @@ var __publicField = (obj, key, value) => {
10228
10727
  ))
10229
10728
  ))
10230
10729
  ), /* @__PURE__ */ React__namespace.createElement(
10231
- react$1.TransitionChild,
10730
+ react.TransitionChild,
10232
10731
  {
10233
10732
  enter: "ease-out duration-300",
10234
10733
  enterFrom: "opacity-0",
@@ -12227,15 +12726,14 @@ var __publicField = (obj, key, value) => {
12227
12726
  fields: fieldGroup.fields
12228
12727
  }
12229
12728
  ) : /* @__PURE__ */ React__namespace.createElement(NoFieldsPlaceholder, null)
12230
- )), !hideFooter && /* @__PURE__ */ React__namespace.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__namespace.createElement("div", { className: "flex-1 w-full flex justify-between gap-4 items-center max-w-form" }, tinaForm.reset && /* @__PURE__ */ React__namespace.createElement(
12729
+ )), !hideFooter && /* @__PURE__ */ React__namespace.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__namespace.createElement("div", { className: "flex-1 w-full justify-end gap-2 flex items-center max-w-form" }, tinaForm.reset && /* @__PURE__ */ React__namespace.createElement(
12231
12730
  ResetForm,
12232
12731
  {
12233
12732
  pristine,
12234
12733
  reset: async () => {
12235
12734
  finalForm2.reset();
12236
12735
  await tinaForm.reset();
12237
- },
12238
- style: { flexGrow: 1 }
12736
+ }
12239
12737
  },
12240
12738
  tinaForm.buttons.reset
12241
12739
  ), /* @__PURE__ */ React__namespace.createElement(
@@ -12244,8 +12742,7 @@ var __publicField = (obj, key, value) => {
12244
12742
  onClick: safeHandleSubmit,
12245
12743
  disabled: !canSubmit,
12246
12744
  busy: submitting,
12247
- variant: "primary",
12248
- style: { flexGrow: 3 }
12745
+ variant: "primary"
12249
12746
  },
12250
12747
  submitting && /* @__PURE__ */ React__namespace.createElement(LoadingDots, null),
12251
12748
  !submitting && tinaForm.buttons.save
@@ -12763,15 +13260,15 @@ var __publicField = (obj, key, value) => {
12763
13260
  );
12764
13261
  };
12765
13262
  const DotMenu = ({ onOpen, onRemove }) => {
12766
- return /* @__PURE__ */ React.createElement(react$1.Popover, { as: "span", className: "-ml-px relative block" }, /* @__PURE__ */ React.createElement(
12767
- react$1.PopoverButton,
13263
+ return /* @__PURE__ */ React.createElement(react.Popover, { as: "span", className: "-ml-px relative block" }, /* @__PURE__ */ React.createElement(
13264
+ react.PopoverButton,
12768
13265
  {
12769
13266
  as: "span",
12770
13267
  className: "cursor-pointer h-full relative inline-flex items-center px-1 py-0.5 rounded-r-md border border-gray-200 bg-white text-gray-500 hover:bg-gray-50 focus:outline-none focus:ring-1 focus:ring-blue-500 focus:border-blue-500"
12771
13268
  },
12772
13269
  /* @__PURE__ */ React.createElement(EllipsisIcon, { title: "Open options" })
12773
13270
  ), /* @__PURE__ */ React.createElement(
12774
- react$1.Transition,
13271
+ react.Transition,
12775
13272
  {
12776
13273
  enter: "transition ease-out duration-100",
12777
13274
  enterFrom: "transform opacity-0 scale-95",
@@ -12780,7 +13277,7 @@ var __publicField = (obj, key, value) => {
12780
13277
  leaveFrom: "transform opacity-100 scale-100",
12781
13278
  leaveTo: "transform opacity-0 scale-95"
12782
13279
  },
12783
- /* @__PURE__ */ React.createElement(react$1.PopoverPanel, { className: "z-30 absolute origin-top-right right-0" }, /* @__PURE__ */ React.createElement("div", { className: "mt-2 -mr-1 rounded-md shadow-lg bg-white ring-1 ring-black ring-opacity-5 focus:outline-none" }, /* @__PURE__ */ React.createElement("div", { className: "py-1" }, /* @__PURE__ */ React.createElement(
13280
+ /* @__PURE__ */ React.createElement(react.PopoverPanel, { className: "z-30 absolute origin-top-right right-0" }, /* @__PURE__ */ React.createElement("div", { className: "mt-2 -mr-1 rounded-md shadow-lg bg-white ring-1 ring-black ring-opacity-5 focus:outline-none" }, /* @__PURE__ */ React.createElement("div", { className: "py-1" }, /* @__PURE__ */ React.createElement(
12784
13281
  "span",
12785
13282
  {
12786
13283
  onClick: onOpen,
@@ -13203,13 +13700,26 @@ var __publicField = (obj, key, value) => {
13203
13700
  plate.createUnderlinePlugin(),
13204
13701
  plate.createCodePlugin(),
13205
13702
  plate.createListPlugin(),
13206
- plate.createIndentPlugin(),
13207
13703
  plate.createIndentListPlugin(),
13208
13704
  plate.createHorizontalRulePlugin(),
13209
13705
  // Allows us to do things like copy/paste, remembering the state of the element (like mdx)
13210
13706
  plate.createNodeIdPlugin(),
13211
- plateSlashCommand.createSlashPlugin()
13707
+ plateSlashCommand.createSlashPlugin(),
13708
+ plate.createTablePlugin()
13212
13709
  ];
13710
+ const unsupportedItemsInTable = /* @__PURE__ */ new Set([
13711
+ "Code Block",
13712
+ "Unordered List",
13713
+ "Ordered List",
13714
+ "Quote",
13715
+ "Mermaid",
13716
+ "Heading 1",
13717
+ "Heading 2",
13718
+ "Heading 3",
13719
+ "Heading 4",
13720
+ "Heading 5",
13721
+ "Heading 6"
13722
+ ]);
13213
13723
  const isNodeActive = (editor, type) => {
13214
13724
  const pluginType = plateCommon.getPluginType(editor, type);
13215
13725
  return !!(editor == null ? void 0 : editor.selection) && plateCommon.someNode(editor, { match: { type: pluginType } });
@@ -13394,24 +13904,6 @@ var __publicField = (obj, key, value) => {
13394
13904
  }
13395
13905
  );
13396
13906
  Editor.displayName = "Editor";
13397
- const separatorVariants = classVarianceAuthority.cva("shrink-0 bg-border", {
13398
- defaultVariants: {
13399
- orientation: "horizontal"
13400
- },
13401
- variants: {
13402
- orientation: {
13403
- horizontal: "h-px w-full",
13404
- vertical: "h-full w-px"
13405
- }
13406
- }
13407
- });
13408
- const Separator = cn$1.withVariants(
13409
- cn$1.withProps(SeparatorPrimitive__namespace.Root, {
13410
- decorative: true,
13411
- orientation: "horizontal"
13412
- }),
13413
- separatorVariants
13414
- );
13415
13907
  const TooltipProvider = TooltipPrimitive__namespace.Provider;
13416
13908
  const Tooltip = TooltipPrimitive__namespace.Root;
13417
13909
  const TooltipTrigger = TooltipPrimitive__namespace.Trigger;
@@ -13420,7 +13912,7 @@ var __publicField = (obj, key, value) => {
13420
13912
  cn$1.withProps(TooltipPrimitive__namespace.Content, {
13421
13913
  sideOffset: 4
13422
13914
  }),
13423
- "z-50 overflow-hidden rounded-md border bg-popover px-3 py-1.5 text-sm text-popover-foreground shadow-md"
13915
+ "z-[9999] overflow-hidden rounded-md border bg-popover px-3 py-1.5 text-sm text-popover-foreground shadow-md"
13424
13916
  );
13425
13917
  function withTooltip(Component) {
13426
13918
  return React.forwardRef(function ExtendComponent({ tooltip, tooltipContentProps, tooltipProps, ...props }, ref) {
@@ -13546,140 +14038,41 @@ var __publicField = (obj, key, value) => {
13546
14038
  Toolbar,
13547
14039
  "p-1 sticky left-0 top-0 z-50 w-full justify-between overflow-x-auto border border-border bg-background"
13548
14040
  );
13549
- const MarkToolbarButton = cn$1.withRef(({ clear, nodeType, ...rest }, ref) => {
13550
- const state = plateCommon.useMarkToolbarButtonState({ clear, nodeType });
13551
- const { props } = plateCommon.useMarkToolbarButton(state);
13552
- return /* @__PURE__ */ React.createElement(ToolbarButton, { ref, ...props, ...rest });
13553
- });
13554
- const IndentListToolbarButton = cn$1.withRef(({ nodeType = plate.ELEMENT_UL }, ref) => {
13555
- const editor = plateCommon.useEditorState();
13556
- const state = plate.useListToolbarButtonState({ nodeType });
13557
- const { props } = plate.useListToolbarButton(state);
13558
- return /* @__PURE__ */ React.createElement(
13559
- ToolbarButton,
13560
- {
13561
- ref,
13562
- tooltip: nodeType === plate.ELEMENT_UL ? "Bulleted List" : "Numbered List",
13563
- ...props,
13564
- onClick: (e) => {
13565
- e.preventDefault();
13566
- e.stopPropagation();
13567
- plate.toggleList(editor, { type: nodeType });
13568
- }
13569
- },
13570
- nodeType === plate.ELEMENT_UL ? /* @__PURE__ */ React.createElement(Icons.ul, null) : /* @__PURE__ */ React.createElement(Icons.ol, null)
13571
- );
13572
- });
13573
- const DropdownMenu = DropdownMenuPrimitive__namespace.Root;
13574
- const DropdownMenuTrigger = DropdownMenuPrimitive__namespace.Trigger;
13575
- const DropdownMenuRadioGroup = DropdownMenuPrimitive__namespace.RadioGroup;
13576
- cn$1.withRef(({ children, className, inset, ...props }, ref) => /* @__PURE__ */ React.createElement(
13577
- DropdownMenuPrimitive__namespace.SubTrigger,
13578
- {
13579
- className: cn$1.cn(
13580
- "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",
13581
- "data-[disabled]:pointer-events-none data-[disabled]:opacity-50",
13582
- inset && "pl-8",
13583
- className
13584
- ),
13585
- ref,
13586
- ...props
13587
- },
13588
- children,
13589
- /* @__PURE__ */ React.createElement(Icons.chevronRight, { className: "ml-auto size-4" })
13590
- ));
13591
- cn$1.withCn(
13592
- DropdownMenuPrimitive__namespace.SubContent,
13593
- "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"
13594
- );
13595
- const DropdownMenuContentVariants = cn$1.withProps(DropdownMenuPrimitive__namespace.Content, {
13596
- className: cn$1.cn(
13597
- "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"
13598
- ),
13599
- sideOffset: 4
13600
- });
13601
- const DropdownMenuContent = cn$1.withRef(({ ...props }, ref) => /* @__PURE__ */ React.createElement(DropdownMenuPrimitive__namespace.Portal, null, /* @__PURE__ */ React.createElement(DropdownMenuContentVariants, { ref, ...props })));
13602
- const menuItemVariants = classVarianceAuthority.cva(
13603
- cn$1.cn(
13604
- "relative flex h-9 cursor-pointer select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none transition-colors",
13605
- "focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50"
13606
- ),
13607
- {
13608
- variants: {
13609
- inset: {
13610
- true: "pl-8"
14041
+ const useResize = (ref, callback) => {
14042
+ React.useEffect(() => {
14043
+ const resizeObserver = new ResizeObserver((entries) => {
14044
+ for (const entry of entries) {
14045
+ callback(entry);
13611
14046
  }
14047
+ });
14048
+ if (ref.current) {
14049
+ resizeObserver.observe(ref.current);
13612
14050
  }
13613
- }
13614
- );
13615
- const DropdownMenuItem = cn$1.withVariants(
13616
- DropdownMenuPrimitive__namespace.Item,
13617
- menuItemVariants,
13618
- ["inset"]
13619
- );
13620
- cn$1.withRef(({ children, className, ...props }, ref) => /* @__PURE__ */ React.createElement(
13621
- DropdownMenuPrimitive__namespace.CheckboxItem,
13622
- {
13623
- className: cn$1.cn(
13624
- "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",
13625
- "cursor-pointer",
13626
- className
13627
- ),
13628
- ref,
13629
- ...props
13630
- },
13631
- /* @__PURE__ */ React.createElement("span", { className: "absolute left-2 flex size-3.5 items-center justify-center" }, /* @__PURE__ */ React.createElement(DropdownMenuPrimitive__namespace.ItemIndicator, null, /* @__PURE__ */ React.createElement(Icons.check, { className: "size-4" }))),
13632
- children
13633
- ));
13634
- const DropdownMenuRadioItem = cn$1.withRef(({ children, className, hideIcon, ...props }, ref) => /* @__PURE__ */ React.createElement(
13635
- DropdownMenuPrimitive__namespace.RadioItem,
13636
- {
13637
- className: cn$1.cn(
13638
- "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",
13639
- "h-9 cursor-pointer px-2 data-[state=checked]:bg-accent data-[state=checked]:text-accent-foreground",
13640
- className
13641
- ),
13642
- ref,
13643
- ...props
13644
- },
13645
- !hideIcon && /* @__PURE__ */ React.createElement("span", { className: "absolute right-2 flex size-3.5 items-center justify-center" }, /* @__PURE__ */ React.createElement(DropdownMenuPrimitive__namespace.ItemIndicator, null, /* @__PURE__ */ React.createElement(Icons.check, { className: "size-4" }))),
14051
+ return () => resizeObserver.disconnect();
14052
+ }, [ref.current]);
14053
+ };
14054
+ const STANDARD_ICON_WIDTH = 32;
14055
+ const HEADING_ICON_WITH_TEXT = 127;
14056
+ const HEADING_ICON_ONLY = 58;
14057
+ const EMBED_ICON_WIDTH = 78;
14058
+ const CONTAINER_MD_BREAKPOINT = 448;
14059
+ const FLOAT_BUTTON_WIDTH = 25;
14060
+ const HEADING_LABEL = "Headings";
14061
+ const ToolbarContext = React.createContext(void 0);
14062
+ const ToolbarProvider = ({
14063
+ tinaForm,
14064
+ templates,
14065
+ overrides,
13646
14066
  children
13647
- ));
13648
- const dropdownMenuLabelVariants = classVarianceAuthority.cva(
13649
- cn$1.cn("select-none px-2 py-1.5 text-sm font-semibold"),
13650
- {
13651
- variants: {
13652
- inset: {
13653
- true: "pl-8"
13654
- }
13655
- }
14067
+ }) => {
14068
+ return /* @__PURE__ */ React.createElement(ToolbarContext.Provider, { value: { tinaForm, templates, overrides } }, children);
14069
+ };
14070
+ const useToolbarContext = () => {
14071
+ const context = React.useContext(ToolbarContext);
14072
+ if (!context) {
14073
+ throw new Error("useToolbarContext must be used within a ToolbarProvider");
13656
14074
  }
13657
- );
13658
- const DropdownMenuLabel = cn$1.withVariants(
13659
- DropdownMenuPrimitive__namespace.Label,
13660
- dropdownMenuLabelVariants,
13661
- ["inset"]
13662
- );
13663
- const DropdownMenuSeparator = cn$1.withCn(
13664
- DropdownMenuPrimitive__namespace.Separator,
13665
- "-mx-1 my-1 h-px bg-muted"
13666
- );
13667
- cn$1.withCn(
13668
- cn$1.createPrimitiveElement("span"),
13669
- "ml-auto text-xs tracking-widest opacity-60"
13670
- );
13671
- const useOpenState = () => {
13672
- const [open2, setOpen] = React.useState(false);
13673
- const onOpenChange = React.useCallback(
13674
- (_value = !open2) => {
13675
- setOpen(_value);
13676
- },
13677
- [open2]
13678
- );
13679
- return {
13680
- onOpenChange,
13681
- open: open2
13682
- };
14075
+ return context;
13683
14076
  };
13684
14077
  const items$1 = [
13685
14078
  {
@@ -13745,7 +14138,9 @@ var __publicField = (obj, key, value) => {
13745
14138
  return allNodesMatchInitialNodeType ? initialNodeType : plateParagraph.ELEMENT_PARAGRAPH;
13746
14139
  }, []);
13747
14140
  const editor = plateCommon.useEditorRef();
14141
+ const editorState = plateCommon.useEditorState();
13748
14142
  const openState = useOpenState();
14143
+ const userInTable = helpers.isNodeActive(editorState, plateTable.ELEMENT_TABLE);
13749
14144
  const selectedItem = items$1.find((item) => item.value === value) ?? defaultItem$1;
13750
14145
  const { icon: SelectedItemIcon, label: selectedItemLabel } = selectedItem;
13751
14146
  return /* @__PURE__ */ React.createElement(DropdownMenu, { modal: false, ...openState, ...props }, /* @__PURE__ */ React.createElement(DropdownMenuTrigger, { asChild: true }, /* @__PURE__ */ React.createElement(
@@ -13757,7 +14152,7 @@ var __publicField = (obj, key, value) => {
13757
14152
  tooltip: "Headings"
13758
14153
  },
13759
14154
  /* @__PURE__ */ React.createElement(SelectedItemIcon, { className: "size-5" }),
13760
- /* @__PURE__ */ React.createElement("span", { className: "hidden 2xl:flex" }, selectedItemLabel)
14155
+ /* @__PURE__ */ React.createElement("span", { className: "@md/toolbar:flex hidden" }, selectedItemLabel)
13761
14156
  )), /* @__PURE__ */ React.createElement(DropdownMenuContent, { align: "start", className: "min-w-0" }, /* @__PURE__ */ React.createElement(
13762
14157
  DropdownMenuRadioGroup,
13763
14158
  {
@@ -13769,7 +14164,12 @@ var __publicField = (obj, key, value) => {
13769
14164
  },
13770
14165
  value
13771
14166
  },
13772
- items$1.map(({ icon: Icon, label, value: itemValue }) => /* @__PURE__ */ React.createElement(
14167
+ items$1.filter((item) => {
14168
+ if (userInTable) {
14169
+ return !unsupportedItemsInTable.has(item.label);
14170
+ }
14171
+ return true;
14172
+ }).map(({ icon: Icon, label, value: itemValue }) => /* @__PURE__ */ React.createElement(
13773
14173
  DropdownMenuRadioItem,
13774
14174
  {
13775
14175
  className: "min-w-[180px]",
@@ -13781,11 +14181,146 @@ var __publicField = (obj, key, value) => {
13781
14181
  ))
13782
14182
  )));
13783
14183
  }
14184
+ const useCodeBlockToolbarButtonState = () => {
14185
+ const editor = plateCommon.useEditorState();
14186
+ const isBlockActive = () => helpers.isNodeActive(editor, plateCodeBlock.ELEMENT_CODE_BLOCK);
14187
+ return {
14188
+ pressed: isBlockActive()
14189
+ };
14190
+ };
14191
+ const useCodeBlockToolbarButton = (state) => {
14192
+ const editor = plateCommon.useEditorState();
14193
+ const onClick = () => {
14194
+ insertEmptyCodeBlock(editor);
14195
+ };
14196
+ const onMouseDown = (e) => {
14197
+ e.preventDefault();
14198
+ e.stopPropagation();
14199
+ };
14200
+ return {
14201
+ props: {
14202
+ onClick,
14203
+ onMouseDown,
14204
+ pressed: state.pressed
14205
+ }
14206
+ };
14207
+ };
14208
+ const CodeBlockToolbarButton = cn$1.withRef(({ clear, ...rest }, ref) => {
14209
+ const state = useCodeBlockToolbarButtonState();
14210
+ const { props } = useCodeBlockToolbarButton(state);
14211
+ return /* @__PURE__ */ React.createElement(ToolbarButton, { ref, tooltip: "Link", ...rest, ...props }, /* @__PURE__ */ React.createElement(Icons.codeBlock, null));
14212
+ });
14213
+ const useImageToolbarButtonState = () => {
14214
+ const editor = plateCommon.useEditorState();
14215
+ const isBlockActive = () => helpers.isNodeActive(editor, ELEMENT_IMG);
14216
+ return {
14217
+ pressed: isBlockActive()
14218
+ };
14219
+ };
14220
+ const useImageToolbarButton = (state) => {
14221
+ const editor = plateCommon.useEditorState();
14222
+ const cms = useCMS$1();
14223
+ const onMouseDown = (e) => {
14224
+ e.preventDefault();
14225
+ cms.media.open({
14226
+ allowDelete: true,
14227
+ directory: "",
14228
+ onSelect: (media) => {
14229
+ insertImg(editor, media);
14230
+ }
14231
+ });
14232
+ };
14233
+ return {
14234
+ props: {
14235
+ onMouseDown,
14236
+ pressed: state.pressed
14237
+ }
14238
+ };
14239
+ };
14240
+ const ImageToolbarButton = cn$1.withRef(({ clear, ...rest }, ref) => {
14241
+ const state = useImageToolbarButtonState();
14242
+ const { props } = useImageToolbarButton(state);
14243
+ return /* @__PURE__ */ React.createElement(ToolbarButton, { ref, tooltip: "Link", ...rest, ...props }, /* @__PURE__ */ React.createElement(Icons.image, null));
14244
+ });
14245
+ const IndentListToolbarButton = cn$1.withRef(({ nodeType = plate.ELEMENT_UL }, ref) => {
14246
+ const editor = plateCommon.useEditorState();
14247
+ const state = plate.useListToolbarButtonState({ nodeType });
14248
+ const { props } = plate.useListToolbarButton(state);
14249
+ return /* @__PURE__ */ React.createElement(
14250
+ ToolbarButton,
14251
+ {
14252
+ ref,
14253
+ tooltip: nodeType === plate.ELEMENT_UL ? "Bulleted List" : "Numbered List",
14254
+ ...props,
14255
+ onClick: (e) => {
14256
+ e.preventDefault();
14257
+ e.stopPropagation();
14258
+ plate.toggleList(editor, { type: nodeType });
14259
+ }
14260
+ },
14261
+ nodeType === plate.ELEMENT_UL ? /* @__PURE__ */ React.createElement(Icons.ul, null) : /* @__PURE__ */ React.createElement(Icons.ol, null)
14262
+ );
14263
+ });
13784
14264
  const LinkToolbarButton = cn$1.withRef((rest, ref) => {
13785
14265
  const state = plateLink.useLinkToolbarButtonState();
13786
14266
  const { props } = plateLink.useLinkToolbarButton(state);
13787
14267
  return /* @__PURE__ */ React.createElement(ToolbarButton, { ref, tooltip: "Link", ...props, ...rest }, /* @__PURE__ */ React.createElement(Icons.link, null));
13788
14268
  });
14269
+ const MarkToolbarButton = cn$1.withRef(({ clear, nodeType, ...rest }, ref) => {
14270
+ const state = plateCommon.useMarkToolbarButtonState({ clear, nodeType });
14271
+ const { props } = plateCommon.useMarkToolbarButton(state);
14272
+ return /* @__PURE__ */ React.createElement(ToolbarButton, { ref, ...props, ...rest });
14273
+ });
14274
+ const useMermaidToolbarButtonState = () => {
14275
+ const editor = plateCommon.useEditorState();
14276
+ const isBlockActive = () => helpers.isNodeActive(editor, ELEMENT_MERMAID);
14277
+ return {
14278
+ pressed: isBlockActive()
14279
+ };
14280
+ };
14281
+ const useMermaidToolbarButton = (state) => {
14282
+ const editor = plateCommon.useEditorState();
14283
+ const onClick = () => {
14284
+ plateCommon.insertEmptyElement(editor, ELEMENT_MERMAID, {
14285
+ nextBlock: true,
14286
+ select: true
14287
+ });
14288
+ };
14289
+ const onMouseDown = (e) => {
14290
+ e.preventDefault();
14291
+ e.stopPropagation();
14292
+ };
14293
+ return {
14294
+ props: {
14295
+ onClick,
14296
+ onMouseDown,
14297
+ pressed: state.pressed
14298
+ }
14299
+ };
14300
+ };
14301
+ const MermaidToolbarButton = cn$1.withRef(({ clear, ...rest }, ref) => {
14302
+ const state = useMermaidToolbarButtonState();
14303
+ const { props } = useMermaidToolbarButton(state);
14304
+ return /* @__PURE__ */ React.createElement(ToolbarButton, { ref, tooltip: "Mermaid", ...rest, ...props }, /* @__PURE__ */ React.createElement(Icons.mermaid, null));
14305
+ });
14306
+ function OverflowMenu({
14307
+ children,
14308
+ ...props
14309
+ }) {
14310
+ const openState = useOpenState();
14311
+ return /* @__PURE__ */ React.createElement(DropdownMenu, { modal: false, ...openState, ...props }, /* @__PURE__ */ React.createElement(DropdownMenuTrigger, { asChild: true }, /* @__PURE__ */ React.createElement(
14312
+ ToolbarButton,
14313
+ {
14314
+ showArrow: false,
14315
+ "data-testid": "rich-text-editor-overflow-menu-button",
14316
+ className: "lg:min-w-[130px]",
14317
+ isDropdown: true,
14318
+ pressed: openState.open,
14319
+ tooltip: "Headings"
14320
+ },
14321
+ /* @__PURE__ */ React.createElement(Icons.overflow, { className: "size-5" })
14322
+ )), /* @__PURE__ */ React.createElement(DropdownMenuContent, { align: "start", className: "min-w-0 flex flex-grow" }, children));
14323
+ }
13789
14324
  const useBlockQuoteToolbarButtonState = () => {
13790
14325
  const editor = plateCommon.useEditorState();
13791
14326
  const isBlockActive = () => helpers.isNodeActive(editor, plateBlockQuote.ELEMENT_BLOCKQUOTE);
@@ -13817,67 +14352,6 @@ var __publicField = (obj, key, value) => {
13817
14352
  const { props } = useBlockQuoteToolbarButton(state);
13818
14353
  return /* @__PURE__ */ React.createElement(ToolbarButton, { ref, tooltip: "Link", ...rest, ...props }, /* @__PURE__ */ React.createElement(Icons.quote, null));
13819
14354
  });
13820
- const useCodeBlockToolbarButtonState = () => {
13821
- const editor = plateCommon.useEditorState();
13822
- const isBlockActive = () => helpers.isNodeActive(editor, plateCodeBlock.ELEMENT_CODE_BLOCK);
13823
- return {
13824
- pressed: isBlockActive()
13825
- };
13826
- };
13827
- const useCodeBlockToolbarButton = (state) => {
13828
- const editor = plateCommon.useEditorState();
13829
- const onClick = () => {
13830
- insertEmptyCodeBlock(editor);
13831
- };
13832
- const onMouseDown = (e) => {
13833
- e.preventDefault();
13834
- e.stopPropagation();
13835
- };
13836
- return {
13837
- props: {
13838
- onClick,
13839
- onMouseDown,
13840
- pressed: state.pressed
13841
- }
13842
- };
13843
- };
13844
- const CodeBlockToolbarButton = cn$1.withRef(({ clear, ...rest }, ref) => {
13845
- const state = useCodeBlockToolbarButtonState();
13846
- const { props } = useCodeBlockToolbarButton(state);
13847
- return /* @__PURE__ */ React.createElement(ToolbarButton, { ref, tooltip: "Link", ...rest, ...props }, /* @__PURE__ */ React.createElement(Icons.codeBlock, null));
13848
- });
13849
- const useImageToolbarButtonState = () => {
13850
- const editor = plateCommon.useEditorState();
13851
- const isBlockActive = () => helpers.isNodeActive(editor, ELEMENT_IMG);
13852
- return {
13853
- pressed: isBlockActive()
13854
- };
13855
- };
13856
- const useImageToolbarButton = (state) => {
13857
- const editor = plateCommon.useEditorState();
13858
- const cms = useCMS$1();
13859
- const onMouseDown = (e) => {
13860
- e.preventDefault();
13861
- cms.media.open({
13862
- allowDelete: true,
13863
- directory: "",
13864
- onSelect: (media) => {
13865
- insertImg(editor, media);
13866
- }
13867
- });
13868
- };
13869
- return {
13870
- props: {
13871
- onMouseDown,
13872
- pressed: state.pressed
13873
- }
13874
- };
13875
- };
13876
- const ImageToolbarButton = cn$1.withRef(({ clear, ...rest }, ref) => {
13877
- const state = useImageToolbarButtonState();
13878
- const { props } = useImageToolbarButton(state);
13879
- return /* @__PURE__ */ React.createElement(ToolbarButton, { ref, tooltip: "Link", ...rest, ...props }, /* @__PURE__ */ React.createElement(Icons.image, null));
13880
- });
13881
14355
  const useRawMarkdownToolbarButton = () => {
13882
14356
  const { setRawMode } = useEditorContext();
13883
14357
  const onMouseDown = (e) => {
@@ -13892,31 +14366,123 @@ var __publicField = (obj, key, value) => {
13892
14366
  };
13893
14367
  const RawMarkdownToolbarButton = cn$1.withRef(({ clear, ...rest }, ref) => {
13894
14368
  const { props } = useRawMarkdownToolbarButton();
13895
- return /* @__PURE__ */ React.createElement(ToolbarButton, { ref, tooltip: "Link", ...rest, ...props }, /* @__PURE__ */ React.createElement(Icons.raw, null));
14369
+ return /* @__PURE__ */ React.createElement(
14370
+ ToolbarButton,
14371
+ {
14372
+ ref,
14373
+ tooltip: "Link",
14374
+ ...rest,
14375
+ ...props,
14376
+ "data-testid": "markdown-button"
14377
+ },
14378
+ /* @__PURE__ */ React.createElement(Icons.raw, null)
14379
+ );
13896
14380
  });
13897
- const ToolbarContext = React.createContext(void 0);
13898
- const ToolbarProvider = ({
13899
- tinaForm,
13900
- templates,
13901
- overrides,
13902
- children
13903
- }) => {
13904
- return /* @__PURE__ */ React.createElement(ToolbarContext.Provider, { value: { tinaForm, templates, overrides } }, children);
13905
- };
13906
- const useToolbarContext = () => {
13907
- const context = React.useContext(ToolbarContext);
13908
- if (!context) {
13909
- throw new Error("useToolbarContext must be used within a ToolbarProvider");
13910
- }
13911
- return context;
13912
- };
14381
+ function TableDropdownMenu(props) {
14382
+ const tableSelected = plateCommon.useEditorSelector(
14383
+ (editor2) => plateCommon.someNode(editor2, { match: { type: plateTable.ELEMENT_TABLE } }),
14384
+ []
14385
+ );
14386
+ const [enableDeleteColumn, enableDeleteRow] = plateCommon.useEditorSelector((editor2) => {
14387
+ const tableNodeEntry = plateCommon.findNode(editor2, { match: { type: plateTable.ELEMENT_TABLE } });
14388
+ if (!tableNodeEntry)
14389
+ return [false, false];
14390
+ const [tableNode] = tableNodeEntry;
14391
+ if (!plateCommon.isElement(tableNode))
14392
+ return [false, false];
14393
+ const columnCount = plateTable.getTableColumnCount(tableNode);
14394
+ const rowCount = tableNode.children.length;
14395
+ return [columnCount > 1, rowCount > 1];
14396
+ }, []);
14397
+ const editor = plateCommon.useEditorRef();
14398
+ const openState = useOpenState();
14399
+ return /* @__PURE__ */ React.createElement(DropdownMenu, { modal: false, ...openState, ...props }, /* @__PURE__ */ React.createElement(DropdownMenuTrigger, { asChild: true }, /* @__PURE__ */ React.createElement(ToolbarButton, { isDropdown: true, pressed: openState.open, tooltip: "Table" }, /* @__PURE__ */ React.createElement(Icons.table, null))), /* @__PURE__ */ React.createElement(
14400
+ DropdownMenuContent,
14401
+ {
14402
+ align: "start",
14403
+ className: "flex w-[180px] min-w-0 flex-col gap-0.5"
14404
+ },
14405
+ /* @__PURE__ */ React.createElement(
14406
+ DropdownMenuItem,
14407
+ {
14408
+ className: "min-w-[180px]",
14409
+ disabled: tableSelected,
14410
+ onSelect: () => {
14411
+ plateTable.insertTable(editor);
14412
+ plateCommon.focusEditor(editor);
14413
+ }
14414
+ },
14415
+ /* @__PURE__ */ React.createElement(Icons.add, { className: iconVariants({ variant: "menuItem" }) }),
14416
+ "Insert table"
14417
+ ),
14418
+ /* @__PURE__ */ React.createElement(
14419
+ DropdownMenuItem,
14420
+ {
14421
+ className: "min-w-[180px]",
14422
+ disabled: !tableSelected,
14423
+ onSelect: () => {
14424
+ plateTable.deleteTable(editor);
14425
+ plateCommon.focusEditor(editor);
14426
+ }
14427
+ },
14428
+ /* @__PURE__ */ React.createElement(Icons.minus, { className: iconVariants({ variant: "menuItem" }) }),
14429
+ "Delete table"
14430
+ ),
14431
+ /* @__PURE__ */ React.createElement(DropdownMenuSub, null, /* @__PURE__ */ React.createElement(DropdownMenuSubTrigger, { disabled: !tableSelected }, /* @__PURE__ */ React.createElement(Icons.column, { className: iconVariants({ variant: "menuItem" }) }), /* @__PURE__ */ React.createElement("span", null, "Column")), /* @__PURE__ */ React.createElement(DropdownMenuSubContent, null, /* @__PURE__ */ React.createElement(
14432
+ DropdownMenuItem,
14433
+ {
14434
+ className: "min-w-[180px]",
14435
+ disabled: !tableSelected,
14436
+ onSelect: () => {
14437
+ plateTable.insertTableColumn(editor);
14438
+ plateCommon.focusEditor(editor);
14439
+ }
14440
+ },
14441
+ /* @__PURE__ */ React.createElement(Icons.add, { className: iconVariants({ variant: "menuItem" }) }),
14442
+ "Insert column after"
14443
+ ), /* @__PURE__ */ React.createElement(
14444
+ DropdownMenuItem,
14445
+ {
14446
+ className: "min-w-[180px]",
14447
+ disabled: !enableDeleteColumn,
14448
+ onSelect: () => {
14449
+ plateTable.deleteColumn(editor);
14450
+ plateCommon.focusEditor(editor);
14451
+ }
14452
+ },
14453
+ /* @__PURE__ */ React.createElement(Icons.minus, { className: iconVariants({ variant: "menuItem" }) }),
14454
+ "Delete column"
14455
+ ))),
14456
+ /* @__PURE__ */ React.createElement(DropdownMenuSub, null, /* @__PURE__ */ React.createElement(DropdownMenuSubTrigger, { disabled: !tableSelected }, /* @__PURE__ */ React.createElement(Icons.row, { className: iconVariants({ variant: "menuItem" }) }), /* @__PURE__ */ React.createElement("span", null, "Row")), /* @__PURE__ */ React.createElement(DropdownMenuSubContent, null, /* @__PURE__ */ React.createElement(
14457
+ DropdownMenuItem,
14458
+ {
14459
+ className: "min-w-[180px]",
14460
+ disabled: !tableSelected,
14461
+ onSelect: () => {
14462
+ plateTable.insertTableRow(editor);
14463
+ plateCommon.focusEditor(editor);
14464
+ }
14465
+ },
14466
+ /* @__PURE__ */ React.createElement(Icons.add, { className: iconVariants({ variant: "menuItem" }) }),
14467
+ "Insert row after"
14468
+ ), /* @__PURE__ */ React.createElement(
14469
+ DropdownMenuItem,
14470
+ {
14471
+ className: "min-w-[180px]",
14472
+ disabled: !enableDeleteRow,
14473
+ onSelect: () => {
14474
+ plateTable.deleteRow(editor);
14475
+ plateCommon.focusEditor(editor);
14476
+ }
14477
+ },
14478
+ /* @__PURE__ */ React.createElement(Icons.minus, { className: iconVariants({ variant: "menuItem" }) }),
14479
+ "Delete row"
14480
+ )))
14481
+ ));
14482
+ }
13913
14483
  function TemplatesToolbarButton() {
13914
14484
  const { templates } = useToolbarContext();
13915
- const showEmbed = templates.length > 0;
13916
14485
  const editor = plateCommon.useEditorState();
13917
- if (!showEmbed) {
13918
- return null;
13919
- }
13920
14486
  return /* @__PURE__ */ React.createElement(EmbedButton, { templates, editor });
13921
14487
  }
13922
14488
  const EmbedButton = ({ editor, templates }) => {
@@ -13949,7 +14515,7 @@ var __publicField = (obj, key, value) => {
13949
14515
  key: template.name,
13950
14516
  onMouseDown: (e) => {
13951
14517
  e.preventDefault();
13952
- close();
14518
+ setOpen(false);
13953
14519
  insertMDX(editor, template);
13954
14520
  },
13955
14521
  className: ""
@@ -13957,99 +14523,118 @@ var __publicField = (obj, key, value) => {
13957
14523
  template.label || template.name
13958
14524
  ))));
13959
14525
  };
13960
- const ICON_WIDTH = 32;
13961
- const EMBED_ICON_WIDTH = 78;
13962
- const useResize = (ref, callback) => {
13963
- React.useEffect(() => {
13964
- const resizeObserver = new ResizeObserver((entries) => {
13965
- for (const entry of entries) {
13966
- callback(entry);
13967
- }
13968
- });
13969
- if (ref.current) {
13970
- resizeObserver.observe(ref.current);
13971
- }
13972
- return () => resizeObserver.disconnect();
13973
- }, [ref.current]);
13974
- };
13975
- function OverflowMenu({
13976
- children,
13977
- ...props
13978
- }) {
13979
- const openState = useOpenState();
13980
- return /* @__PURE__ */ React.createElement(DropdownMenu, { modal: false, ...openState, ...props }, /* @__PURE__ */ React.createElement(DropdownMenuTrigger, { asChild: true }, /* @__PURE__ */ React.createElement(
13981
- ToolbarButton,
13982
- {
13983
- showArrow: false,
13984
- className: "lg:min-w-[130px]",
13985
- isDropdown: true,
13986
- pressed: openState.open,
13987
- tooltip: "Headings"
13988
- },
13989
- /* @__PURE__ */ React.createElement(Icons.overflow, { className: "size-5" })
13990
- )), /* @__PURE__ */ React.createElement(DropdownMenuContent, { align: "start", className: "min-w-0 flex flex-grow" }, children));
13991
- }
13992
14526
  const toolbarItems = {
13993
14527
  heading: {
13994
- label: "Headings",
14528
+ label: HEADING_LABEL,
14529
+ width: (paragraphIconExists) => paragraphIconExists ? HEADING_ICON_WITH_TEXT : HEADING_ICON_ONLY,
14530
+ // Dynamically handle width based on paragraph icon
13995
14531
  Component: /* @__PURE__ */ React.createElement(ToolbarGroup, { noSeparator: true }, /* @__PURE__ */ React.createElement(HeadingsMenu, null))
13996
14532
  },
13997
14533
  link: {
13998
14534
  label: "Link",
14535
+ width: () => STANDARD_ICON_WIDTH,
13999
14536
  Component: /* @__PURE__ */ React.createElement(LinkToolbarButton, null)
14000
14537
  },
14001
14538
  image: {
14002
14539
  label: "Image",
14540
+ width: () => STANDARD_ICON_WIDTH,
14003
14541
  Component: /* @__PURE__ */ React.createElement(ImageToolbarButton, null)
14004
14542
  },
14005
14543
  quote: {
14006
14544
  label: "Quote",
14545
+ width: () => STANDARD_ICON_WIDTH,
14007
14546
  Component: /* @__PURE__ */ React.createElement(QuoteToolbarButton, { tooltip: "Quote Quote (⌘+⇧+.)" })
14008
14547
  },
14009
14548
  ul: {
14010
14549
  label: "Unordered List",
14550
+ width: () => STANDARD_ICON_WIDTH,
14011
14551
  Component: /* @__PURE__ */ React.createElement(IndentListToolbarButton, { nodeType: plate.ELEMENT_UL })
14012
14552
  },
14013
14553
  ol: {
14014
14554
  label: "Ordered List",
14555
+ width: () => STANDARD_ICON_WIDTH,
14015
14556
  Component: /* @__PURE__ */ React.createElement(IndentListToolbarButton, { nodeType: plate.ELEMENT_OL })
14016
14557
  },
14017
14558
  bold: {
14018
14559
  label: "Bold",
14560
+ width: () => STANDARD_ICON_WIDTH,
14019
14561
  Component: /* @__PURE__ */ React.createElement(MarkToolbarButton, { tooltip: "Bold (⌘+B)", nodeType: plate.MARK_BOLD }, /* @__PURE__ */ React.createElement(Icons.bold, null))
14020
14562
  },
14021
14563
  italic: {
14022
14564
  label: "Italic",
14565
+ width: () => STANDARD_ICON_WIDTH,
14023
14566
  Component: /* @__PURE__ */ React.createElement(MarkToolbarButton, { tooltip: "Italic (⌘+I)", nodeType: plate.MARK_ITALIC }, /* @__PURE__ */ React.createElement(Icons.italic, null))
14024
14567
  },
14025
14568
  code: {
14026
14569
  label: "Code",
14570
+ width: () => STANDARD_ICON_WIDTH,
14027
14571
  Component: /* @__PURE__ */ React.createElement(MarkToolbarButton, { tooltip: "Code (⌘+E)", nodeType: plate.MARK_CODE }, /* @__PURE__ */ React.createElement(Icons.code, null))
14028
14572
  },
14029
14573
  codeBlock: {
14030
14574
  label: "Code Block",
14575
+ width: () => STANDARD_ICON_WIDTH,
14031
14576
  Component: /* @__PURE__ */ React.createElement(CodeBlockToolbarButton, null)
14032
14577
  },
14578
+ mermaid: {
14579
+ label: "Mermaid",
14580
+ width: () => STANDARD_ICON_WIDTH,
14581
+ Component: /* @__PURE__ */ React.createElement(MermaidToolbarButton, null)
14582
+ },
14583
+ table: {
14584
+ label: "Table",
14585
+ width: () => STANDARD_ICON_WIDTH,
14586
+ Component: /* @__PURE__ */ React.createElement(TableDropdownMenu, null)
14587
+ },
14033
14588
  raw: {
14034
14589
  label: "Raw Markdown",
14590
+ width: () => STANDARD_ICON_WIDTH,
14035
14591
  Component: /* @__PURE__ */ React.createElement(RawMarkdownToolbarButton, null)
14036
14592
  },
14037
14593
  embed: {
14038
14594
  label: "Templates",
14595
+ width: () => EMBED_ICON_WIDTH,
14039
14596
  Component: /* @__PURE__ */ React.createElement(TemplatesToolbarButton, null)
14040
14597
  }
14041
14598
  };
14042
14599
  function FixedToolbarButtons() {
14043
14600
  const toolbarRef = React.useRef(null);
14044
14601
  const [itemsShown, setItemsShown] = React.useState(11);
14045
- const { overrides } = useToolbarContext();
14602
+ const { overrides, templates } = useToolbarContext();
14603
+ const showEmbedButton = templates.length > 0;
14604
+ let items2 = [];
14605
+ if (Array.isArray(overrides)) {
14606
+ items2 = overrides === void 0 ? Object.values(toolbarItems) : overrides.map((item) => toolbarItems[item]).filter((item) => item !== void 0);
14607
+ } else {
14608
+ items2 = (overrides == null ? void 0 : overrides.toolbar) === void 0 ? Object.values(toolbarItems) : overrides.toolbar.map((item) => toolbarItems[item]).filter((item) => item !== void 0);
14609
+ }
14610
+ if (!showEmbedButton) {
14611
+ items2 = items2.filter((item) => item.label !== toolbarItems.embed.label);
14612
+ }
14613
+ const editorState = plateCommon.useEditorState();
14614
+ const userInTable = helpers.isNodeActive(editorState, plate.ELEMENT_TABLE);
14615
+ if (userInTable) {
14616
+ items2 = items2.filter((item) => !unsupportedItemsInTable.has(item.label));
14617
+ }
14046
14618
  useResize(toolbarRef, (entry) => {
14047
14619
  const width = entry.target.getBoundingClientRect().width;
14048
- const itemsShown2 = (width - EMBED_ICON_WIDTH) / ICON_WIDTH;
14049
- setItemsShown(Math.floor(itemsShown2));
14620
+ const headingButton = items2.find((item) => item.label === HEADING_LABEL);
14621
+ const headingWidth = headingButton ? headingButton.width(width > CONTAINER_MD_BREAKPOINT) : 0;
14622
+ const availableWidth = width - headingWidth - FLOAT_BUTTON_WIDTH;
14623
+ const { itemFitCount } = items2.reduce(
14624
+ (acc, item) => {
14625
+ if (item.label !== HEADING_LABEL && acc.totalItemsWidth + item.width() <= availableWidth) {
14626
+ return {
14627
+ totalItemsWidth: acc.totalItemsWidth + item.width(),
14628
+ itemFitCount: acc.itemFitCount + 1
14629
+ };
14630
+ }
14631
+ return acc;
14632
+ },
14633
+ { totalItemsWidth: 0, itemFitCount: 1 }
14634
+ );
14635
+ setItemsShown(itemFitCount);
14050
14636
  });
14051
- const toolbarItemsArray = overrides === void 0 ? Object.values(toolbarItems) : overrides.map((item) => toolbarItems[item]).filter((item) => item !== void 0);
14052
- return /* @__PURE__ */ React.createElement("div", { className: "w-full overflow-hidden", ref: toolbarRef }, /* @__PURE__ */ React.createElement(
14637
+ return /* @__PURE__ */ React.createElement("div", { className: "w-full overflow-hidden @container/toolbar", ref: toolbarRef }, /* @__PURE__ */ React.createElement(
14053
14638
  "div",
14054
14639
  {
14055
14640
  className: "flex",
@@ -14057,7 +14642,7 @@ var __publicField = (obj, key, value) => {
14057
14642
  transform: "translateX(calc(-1px))"
14058
14643
  }
14059
14644
  },
14060
- /* @__PURE__ */ React.createElement(React.Fragment, null, toolbarItemsArray.slice(0, itemsShown).map((item, index) => /* @__PURE__ */ React.createElement(React.Fragment, { key: item.label }, item.Component)), toolbarItemsArray.length > itemsShown && /* @__PURE__ */ React.createElement(OverflowMenu, null, toolbarItemsArray.slice(itemsShown).flatMap((c) => /* @__PURE__ */ React.createElement(React.Fragment, { key: c.label }, c.Component))))
14645
+ /* @__PURE__ */ React.createElement(React.Fragment, null, items2.slice(0, itemsShown).map((item) => /* @__PURE__ */ React.createElement(React.Fragment, { key: item.label }, item.Component)), items2.length > itemsShown && /* @__PURE__ */ React.createElement(OverflowMenu, null, items2.slice(itemsShown).flatMap((c) => /* @__PURE__ */ React.createElement(React.Fragment, { key: c.label }, c.Component))))
14061
14646
  ));
14062
14647
  }
14063
14648
  const FloatingToolbar = cn$1.withRef(({ children, state, ...props }, componentRef) => {
@@ -14172,6 +14757,10 @@ var __publicField = (obj, key, value) => {
14172
14757
  const openState = useOpenState();
14173
14758
  const selectedItem = items.find((item) => item.value === value) ?? defaultItem;
14174
14759
  const { icon: SelectedItemIcon, label: selectedItemLabel } = selectedItem;
14760
+ const editorState = plateCommon.useEditorState();
14761
+ const userInTable = helpers.isNodeActive(editorState, plateTable.ELEMENT_TABLE);
14762
+ if (userInTable)
14763
+ return null;
14175
14764
  return /* @__PURE__ */ React.createElement(DropdownMenu, { modal: false, ...openState, ...props }, /* @__PURE__ */ React.createElement(DropdownMenuTrigger, { asChild: true }, /* @__PURE__ */ React.createElement(
14176
14765
  ToolbarButton,
14177
14766
  {
@@ -14213,49 +14802,6 @@ var __publicField = (obj, key, value) => {
14213
14802
  function FloatingToolbarButtons() {
14214
14803
  return /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(TurnIntoDropdownMenu, null));
14215
14804
  }
14216
- const buttonVariants = classVarianceAuthority.cva(
14217
- "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",
14218
- {
14219
- defaultVariants: {
14220
- size: "default",
14221
- variant: "default"
14222
- },
14223
- variants: {
14224
- isMenu: {
14225
- true: "h-auto w-full cursor-pointer justify-start"
14226
- },
14227
- size: {
14228
- default: "h-10 px-4 py-2",
14229
- icon: "size-10",
14230
- lg: "h-11 rounded-md px-8",
14231
- none: "",
14232
- sm: "h-9 rounded-md px-3",
14233
- sms: "size-9 rounded-md px-0",
14234
- xs: "h-8 rounded-md px-3"
14235
- },
14236
- variant: {
14237
- default: "bg-primary text-primary-foreground hover:bg-primary/90",
14238
- destructive: "bg-destructive text-destructive-foreground hover:bg-destructive/90",
14239
- ghost: "hover:bg-accent hover:text-accent-foreground",
14240
- inlineLink: "text-base text-primary underline underline-offset-4",
14241
- link: "text-primary underline-offset-4 hover:underline",
14242
- outline: "border border-input bg-background hover:bg-accent hover:text-accent-foreground",
14243
- secondary: "bg-secondary text-secondary-foreground hover:bg-secondary/80"
14244
- }
14245
- }
14246
- }
14247
- );
14248
- cn$1.withRef(({ asChild = false, className, isMenu, size, variant, ...props }, ref) => {
14249
- const Comp = asChild ? reactSlot.Slot : "button";
14250
- return /* @__PURE__ */ React__namespace.createElement(
14251
- Comp,
14252
- {
14253
- className: cn$1.cn(buttonVariants({ className, isMenu, size, variant })),
14254
- ref,
14255
- ...props
14256
- }
14257
- );
14258
- });
14259
14805
  const inputVariants = classVarianceAuthority.cva(
14260
14806
  "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",
14261
14807
  {
@@ -14276,22 +14822,6 @@ var __publicField = (obj, key, value) => {
14276
14822
  }
14277
14823
  );
14278
14824
  cn$1.withVariants("input", inputVariants, ["variant", "h"]);
14279
- const popoverVariants = classVarianceAuthority.cva(
14280
- "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"
14281
- );
14282
- cn$1.withRef(
14283
- ({ align = "center", className, sideOffset = 4, style, ...props }, ref) => /* @__PURE__ */ React__namespace.createElement(PopoverPrimitive__namespace.Portal, null, /* @__PURE__ */ React__namespace.createElement(
14284
- PopoverPrimitive__namespace.Content,
14285
- {
14286
- align,
14287
- className: cn$1.cn(popoverVariants(), className),
14288
- ref,
14289
- sideOffset,
14290
- style: { zIndex: 1e3, ...style },
14291
- ...props
14292
- }
14293
- ))
14294
- );
14295
14825
  const floatingOptions = {
14296
14826
  middleware: [
14297
14827
  plateFloating.offset(12),
@@ -14351,7 +14881,7 @@ var __publicField = (obj, key, value) => {
14351
14881
  const editContent = editState.isEditing ? input : /* @__PURE__ */ React.createElement("div", { className: "box-content flex h-9 items-center gap-1" }, /* @__PURE__ */ React.createElement(
14352
14882
  "button",
14353
14883
  {
14354
- className: buttonVariants({ size: "sm", variant: "ghost" }),
14884
+ className: buttonVariants$1({ size: "sm", variant: "ghost" }),
14355
14885
  type: "button",
14356
14886
  ...editButtonProps
14357
14887
  },
@@ -14359,7 +14889,7 @@ var __publicField = (obj, key, value) => {
14359
14889
  ), /* @__PURE__ */ React.createElement(Separator, { orientation: "vertical" }), /* @__PURE__ */ React.createElement(
14360
14890
  plateLink.LinkOpenButton,
14361
14891
  {
14362
- className: buttonVariants({
14892
+ className: buttonVariants$1({
14363
14893
  size: "sms",
14364
14894
  variant: "ghost"
14365
14895
  })
@@ -14368,7 +14898,7 @@ var __publicField = (obj, key, value) => {
14368
14898
  ), /* @__PURE__ */ React.createElement(Separator, { orientation: "vertical" }), /* @__PURE__ */ React.createElement(
14369
14899
  "button",
14370
14900
  {
14371
- className: buttonVariants({
14901
+ className: buttonVariants$1({
14372
14902
  size: "sms",
14373
14903
  variant: "ghost"
14374
14904
  }),
@@ -14404,6 +14934,9 @@ var __publicField = (obj, key, value) => {
14404
14934
  if (typeof string !== "string") {
14405
14935
  return false;
14406
14936
  }
14937
+ if (string.startsWith("#")) {
14938
+ return true;
14939
+ }
14407
14940
  const generalMatch = string.match(protocolAndDomainRE);
14408
14941
  const emailLinkMatch = string.match(emailLintRE);
14409
14942
  const localUrlMatch = string.match(localUrlRE);
@@ -14425,12 +14958,12 @@ var __publicField = (obj, key, value) => {
14425
14958
  }
14426
14959
  return localhostDomainRE.test(everythingAfterProtocol) || nonLocalhostDomainRE.test(everythingAfterProtocol);
14427
14960
  };
14428
- const RichEditor = (props) => {
14961
+ const RichEditor = ({ input, tinaForm, field }) => {
14429
14962
  var _a;
14430
14963
  const initialValue = React.useMemo(
14431
14964
  () => {
14432
14965
  var _a2, _b;
14433
- 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: "" }] }];
14966
+ 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: "" }] }];
14434
14967
  },
14435
14968
  []
14436
14969
  );
@@ -14442,6 +14975,7 @@ var __publicField = (obj, key, value) => {
14442
14975
  createMdxBlockPlugin(),
14443
14976
  createMdxInlinePlugin(),
14444
14977
  createImgPlugin(),
14978
+ createMermaidPlugin(),
14445
14979
  createInvalidMarkdownPlugin(),
14446
14980
  plateLink.createLinkPlugin({
14447
14981
  options: {
@@ -14457,7 +14991,7 @@ var __publicField = (obj, key, value) => {
14457
14991
  ),
14458
14992
  []
14459
14993
  );
14460
- const tempId = [props.tinaForm.id, props.input.name].join(".");
14994
+ const tempId = [tinaForm.id, input.name].join(".");
14461
14995
  const id = React.useMemo(() => uuid() + tempId, [tempId]);
14462
14996
  const ref = React.useRef(null);
14463
14997
  React.useEffect(() => {
@@ -14467,13 +15001,13 @@ var __publicField = (obj, key, value) => {
14467
15001
  const plateElement = (_a2 = ref.current) == null ? void 0 : _a2.querySelector(
14468
15002
  '[role="textbox"]'
14469
15003
  );
14470
- if (props.field.experimental_focusIntent && plateElement) {
15004
+ if (field.experimental_focusIntent && plateElement) {
14471
15005
  if (plateElement)
14472
15006
  plateElement.focus();
14473
15007
  }
14474
15008
  }, 100);
14475
15009
  }
14476
- }, [props.field.experimental_focusIntent, ref]);
15010
+ }, [field.experimental_focusIntent, ref]);
14477
15011
  return /* @__PURE__ */ React.createElement("div", { ref }, /* @__PURE__ */ React.createElement(
14478
15012
  plateCommon.Plate,
14479
15013
  {
@@ -14481,7 +15015,7 @@ var __publicField = (obj, key, value) => {
14481
15015
  initialValue,
14482
15016
  plugins: plugins$2,
14483
15017
  onChange: (value) => {
14484
- props.input.onChange({
15018
+ input.onChange({
14485
15019
  type: "root",
14486
15020
  children: value
14487
15021
  });
@@ -14490,12 +15024,12 @@ var __publicField = (obj, key, value) => {
14490
15024
  /* @__PURE__ */ React.createElement(TooltipProvider, null, /* @__PURE__ */ React.createElement(
14491
15025
  ToolbarProvider,
14492
15026
  {
14493
- tinaForm: props.tinaForm,
14494
- templates: props.field.templates,
14495
- overrides: (_a = props.field) == null ? void 0 : _a.toolbarOverride
15027
+ tinaForm,
15028
+ templates: field.templates,
15029
+ overrides: (field == null ? void 0 : field.toolbarOverride) ? field.toolbarOverride : field.overrides
14496
15030
  },
14497
15031
  /* @__PURE__ */ React.createElement(FixedToolbar, null, /* @__PURE__ */ React.createElement(FixedToolbarButtons, null)),
14498
- /* @__PURE__ */ React.createElement(FloatingToolbar, null, /* @__PURE__ */ React.createElement(FloatingToolbarButtons, null))
15032
+ ((_a = field == null ? void 0 : field.overrides) == null ? void 0 : _a.showFloatingToolbar) !== false ? /* @__PURE__ */ React.createElement(FloatingToolbar, null, /* @__PURE__ */ React.createElement(FloatingToolbarButtons, null)) : null
14499
15033
  ), /* @__PURE__ */ React.createElement(Editor, null))
14500
15034
  ));
14501
15035
  };
@@ -29449,6 +29983,7 @@ mutation addPendingDocumentMutation(
29449
29983
  relativePath
29450
29984
  filename
29451
29985
  extension
29986
+ hasReferences
29452
29987
  }
29453
29988
  }
29454
29989
  }
@@ -29540,6 +30075,9 @@ mutation addPendingDocumentMutation(
29540
30075
  document(collection:$collection, relativePath:$relativePath) {
29541
30076
  ... on Document {
29542
30077
  _values
30078
+ _sys {
30079
+ hasReferences
30080
+ }
29543
30081
  }
29544
30082
  }
29545
30083
  }`;
@@ -30564,8 +31102,8 @@ This will work when developing locally but NOT when deployed to production.
30564
31102
  }
30565
31103
  )
30566
31104
  }
30567
- ), !renderDesktopNav && /* @__PURE__ */ React.createElement(react$1.Transition, { show: menuIsOpen }, /* @__PURE__ */ React.createElement(
30568
- react$1.TransitionChild,
31105
+ ), !renderDesktopNav && /* @__PURE__ */ React.createElement(react.Transition, { show: menuIsOpen }, /* @__PURE__ */ React.createElement(
31106
+ react.TransitionChild,
30569
31107
  {
30570
31108
  enter: "transform transition-all ease-out duration-300",
30571
31109
  enterFrom: "opacity-0 -translate-x-full",
@@ -30634,7 +31172,7 @@ This will work when developing locally but NOT when deployed to production.
30634
31172
  ))
30635
31173
  ))
30636
31174
  ), /* @__PURE__ */ React.createElement(
30637
- react$1.TransitionChild,
31175
+ react.TransitionChild,
30638
31176
  {
30639
31177
  enter: "ease-out duration-300",
30640
31178
  enterFrom: "opacity-0",
@@ -31088,8 +31626,8 @@ This will work when developing locally but NOT when deployed to production.
31088
31626
  folder,
31089
31627
  collectionName
31090
31628
  }) => {
31091
- return /* @__PURE__ */ React.createElement(react$1.Menu, { as: "div", className: "relative inline-block text-left" }, () => /* @__PURE__ */ React.createElement("div", null, /* @__PURE__ */ React.createElement("div", null, /* @__PURE__ */ React.createElement(react$1.MenuButton, { className: "icon-parent inline-flex items-center font-medium focus:outline-none focus:ring-2 focus:shadow-outline text-center rounded-full justify-center transition-all duration-150 ease-out shadow text-white bg-blue-500 hover:bg-blue-600 focus:ring-blue-500 text-sm h-10 px-6" }, "Create New ", /* @__PURE__ */ React.createElement(BiPlus, { className: "w-5 h-full ml-1 opacity-70" }))), /* @__PURE__ */ React.createElement(
31092
- react$1.Transition,
31629
+ return /* @__PURE__ */ React.createElement(react.Menu, { as: "div", className: "relative inline-block text-left" }, () => /* @__PURE__ */ React.createElement("div", null, /* @__PURE__ */ React.createElement("div", null, /* @__PURE__ */ React.createElement(react.MenuButton, { className: "icon-parent inline-flex items-center font-medium focus:outline-none focus:ring-2 focus:shadow-outline text-center rounded-full justify-center transition-all duration-150 ease-out shadow text-white bg-blue-500 hover:bg-blue-600 focus:ring-blue-500 text-sm h-10 px-6" }, "Create New ", /* @__PURE__ */ React.createElement(BiPlus, { className: "w-5 h-full ml-1 opacity-70" }))), /* @__PURE__ */ React.createElement(
31630
+ react.Transition,
31093
31631
  {
31094
31632
  enter: "transition ease-out duration-100",
31095
31633
  enterFrom: "transform opacity-0 scale-95",
@@ -31098,7 +31636,7 @@ This will work when developing locally but NOT when deployed to production.
31098
31636
  leaveFrom: "transform opacity-100 scale-100",
31099
31637
  leaveTo: "transform opacity-0 scale-95"
31100
31638
  },
31101
- /* @__PURE__ */ React.createElement(react$1.MenuItems, { className: "origin-top-right absolute right-0 mt-2 z-menu w-56 rounded-md shadow-lg bg-white ring-1 ring-black ring-opacity-5 focus:outline-none" }, /* @__PURE__ */ React.createElement("div", { className: "py-1" }, templates.map((template) => /* @__PURE__ */ React.createElement(react$1.MenuItem, { key: `${template.label}-${template.name}` }, ({ focus }) => /* @__PURE__ */ React.createElement(
31639
+ /* @__PURE__ */ React.createElement(react.MenuItems, { className: "origin-top-right absolute right-0 mt-2 z-menu w-56 rounded-md shadow-lg bg-white ring-1 ring-black ring-opacity-5 focus:outline-none" }, /* @__PURE__ */ React.createElement("div", { className: "py-1" }, templates.map((template) => /* @__PURE__ */ React.createElement(react.MenuItem, { key: `${template.label}-${template.name}` }, ({ focus }) => /* @__PURE__ */ React.createElement(
31102
31640
  reactRouterDom.Link,
31103
31641
  {
31104
31642
  to: `/${folder.fullyQualifiedName ? [
@@ -31266,6 +31804,23 @@ This will work when developing locally but NOT when deployed to production.
31266
31804
  DeleteModal,
31267
31805
  {
31268
31806
  filename: vars.relativePath,
31807
+ checkRefsFunc: async () => {
31808
+ var _a2, _b2;
31809
+ try {
31810
+ const doc = await admin.fetchDocument(
31811
+ collection.name,
31812
+ vars.relativePath,
31813
+ true
31814
+ );
31815
+ return (_b2 = (_a2 = doc == null ? void 0 : doc.document) == null ? void 0 : _a2._sys) == null ? void 0 : _b2.hasReferences;
31816
+ } catch (error) {
31817
+ cms.alerts.error(
31818
+ "Document was not found, ask a developer for help or check the console for an error message"
31819
+ );
31820
+ console.error(error);
31821
+ throw error;
31822
+ }
31823
+ },
31269
31824
  deleteFunc: async () => {
31270
31825
  try {
31271
31826
  await admin.deleteDocument(vars);
@@ -31274,6 +31829,12 @@ This will work when developing locally but NOT when deployed to production.
31274
31829
  );
31275
31830
  reFetchCollection();
31276
31831
  } catch (error) {
31832
+ if (error.message.indexOf("has references")) {
31833
+ cms.alerts.error(
31834
+ error.message.split("\n ").filter(Boolean)[1]
31835
+ );
31836
+ return;
31837
+ }
31277
31838
  cms.alerts.warn(
31278
31839
  "Document was not deleted, ask a developer for help or check the console for an error message"
31279
31840
  );
@@ -31325,6 +31886,12 @@ This will work when developing locally but NOT when deployed to production.
31325
31886
  cms.alerts.info("Document was successfully renamed");
31326
31887
  reFetchCollection();
31327
31888
  } catch (error) {
31889
+ if (error.message.indexOf("has references")) {
31890
+ cms.alerts.error(
31891
+ error.message.split("\n ").filter(Boolean)[1]
31892
+ );
31893
+ return;
31894
+ }
31328
31895
  cms.alerts.warn(
31329
31896
  "Document was not renamed, ask a developer for help or check the console for an error message"
31330
31897
  );
@@ -31798,8 +32365,19 @@ This will work when developing locally but NOT when deployed to production.
31798
32365
  const NoDocumentsPlaceholder = () => {
31799
32366
  return /* @__PURE__ */ React.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.createElement("p", { className: "text-base italic font-medium text-gray-300" }, "No documents found."));
31800
32367
  };
31801
- const DeleteModal = ({ close: close2, deleteFunc, filename }) => {
31802
- return /* @__PURE__ */ React.createElement(Modal, null, /* @__PURE__ */ React.createElement(PopupModal, null, /* @__PURE__ */ React.createElement(ModalHeader, { close: close2 }, "Delete ", filename), /* @__PURE__ */ React.createElement(ModalBody, { padded: true }, /* @__PURE__ */ React.createElement("p", null, `Are you sure you want to delete ${filename}?`)), /* @__PURE__ */ React.createElement(ModalActions, null, /* @__PURE__ */ React.createElement(Button$1, { style: { flexGrow: 2 }, onClick: close2 }, "Cancel"), /* @__PURE__ */ React.createElement(
32368
+ const DeleteModal = ({
32369
+ close: close2,
32370
+ deleteFunc,
32371
+ checkRefsFunc,
32372
+ filename
32373
+ }) => {
32374
+ const [hasRefs, setHasRefs] = React.useState();
32375
+ React.useEffect(() => {
32376
+ checkRefsFunc().then((result) => {
32377
+ setHasRefs(result);
32378
+ });
32379
+ }, [filename, checkRefsFunc]);
32380
+ return /* @__PURE__ */ React.createElement(Modal, null, /* @__PURE__ */ React.createElement(PopupModal, null, /* @__PURE__ */ React.createElement(ModalHeader, { close: close2 }, "Delete ", filename), /* @__PURE__ */ React.createElement(ModalBody, { padded: true }, /* @__PURE__ */ React.createElement("p", null, `Are you sure you want to delete ${filename}?${hasRefs ? " References to this document will also be deleted." : ""}`)), /* @__PURE__ */ React.createElement(ModalActions, null, /* @__PURE__ */ React.createElement(Button$1, { style: { flexGrow: 2 }, onClick: close2 }, "Cancel"), /* @__PURE__ */ React.createElement(
31803
32381
  Button$1,
31804
32382
  {
31805
32383
  style: { flexGrow: 3 },
@@ -32531,15 +33109,24 @@ This will work when developing locally but NOT when deployed to production.
32531
33109
  }
32532
33110
  }
32533
33111
  if (state === "creatingPR") {
32534
- const foo = await tinaApi.createPullRequest({
32535
- baseBranch,
32536
- branch,
32537
- title: `${branch.replace("tina/", "").replace("-", " ")} (PR from TinaCMS)`
32538
- });
32539
- console.log("PR created", foo);
32540
- cms.alerts.success("Pull request created.");
32541
- localStorage.setItem("tina.createBranchState", "done");
32542
- setState("done");
33112
+ try {
33113
+ const foo = await tinaApi.createPullRequest({
33114
+ baseBranch,
33115
+ branch,
33116
+ title: `${branch.replace("tina/", "").replace("-", " ")} (PR from TinaCMS)`
33117
+ });
33118
+ console.log("PR created", foo);
33119
+ cms.alerts.success("Pull request created.");
33120
+ localStorage.setItem("tina.createBranchState", "done");
33121
+ setState("done");
33122
+ } catch (e) {
33123
+ console.error(e);
33124
+ cms.alerts.error("Failed to create PR");
33125
+ setErrorMessage(
33126
+ "Failed to create PR, please try again. If the problem persists please contact support."
33127
+ );
33128
+ setState("error");
33129
+ }
32543
33130
  }
32544
33131
  if (state === "done") {
32545
33132
  window.location.href = back;
@@ -33166,6 +33753,7 @@ This will work when developing locally but NOT when deployed to production.
33166
33753
  exports2.useScreenPlugin = useScreenPlugin;
33167
33754
  exports2.useTinaAuthRedirect = useTinaAuthRedirect;
33168
33755
  exports2.wrapFieldWithError = wrapFieldWithError;
33756
+ exports2.wrapFieldWithNoHeader = wrapFieldWithNoHeader;
33169
33757
  exports2.wrapFieldsWithMeta = wrapFieldsWithMeta;
33170
33758
  Object.defineProperties(exports2, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
33171
33759
  });