tinacms 0.0.0-c8b1d84-20241003015733 → 0.0.0-cef656e-20250119001929

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 (32) 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 +23 -24
  4. package/dist/client.mjs +4 -8
  5. package/dist/index.d.ts +1 -1
  6. package/dist/index.js +1589 -1029
  7. package/dist/index.mjs +1579 -1015
  8. package/dist/{node-cache-7fa2452c.mjs → node-cache-4c336858.mjs} +18 -11
  9. package/dist/rich-text/index.d.ts +3 -0
  10. package/dist/rich-text/index.js +45 -12
  11. package/dist/rich-text/index.mjs +45 -12
  12. package/dist/toolkit/fields/plugins/mdx-field-plugin/index.d.ts +4 -1
  13. package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/components/fixed-toolbar-buttons.d.ts +0 -4
  14. package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/components/plate-ui/icons.d.ts +2 -0
  15. package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/components/plate-ui/mermaid-element.d.ts +11 -0
  16. package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/components/plate-ui/mermaid-toolbar-button.d.ts +20 -0
  17. package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/components/plate-ui/resizable.d.ts +39 -0
  18. package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/components/plate-ui/table-cell-element.d.ts +27 -0
  19. package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/components/plate-ui/table-dropdown-menu.d.ts +3 -0
  20. package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/components/plate-ui/table-element.d.ts +14 -0
  21. package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/components/plate-ui/table-row-element.d.ts +13 -0
  22. package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/components/plate-ui/text-area.d.ts +5 -0
  23. package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/index.d.ts +1 -1
  24. package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/plugins/core/common.d.ts +1 -0
  25. package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/plugins/custom/mermaid-plugin.d.ts +2 -0
  26. package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/plugins/ui/code-block/index.d.ts +4 -2
  27. package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/plugins/ui/components.d.ts +58 -0
  28. package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/toolbar/toolbar-overrides.d.ts +11 -3
  29. package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/toolbar/toolbar-provider.d.ts +3 -3
  30. package/dist/toolkit/fields/plugins/wrap-field-with-meta.d.ts +8 -0
  31. package/package.json +29 -28
  32. package/dist/__vite-browser-external-d06ac358.mjs +0 -4
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
+ }
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
+ }
2082
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
  }
@@ -5102,10 +5757,11 @@ var __publicField = (obj, key, value) => {
5102
5757
  return /* @__PURE__ */ React.createElement(
5103
5758
  "button",
5104
5759
  {
5105
- 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"}`,
5760
+ type: "button",
5761
+ 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"}`,
5106
5762
  onClick
5107
5763
  },
5108
- /* @__PURE__ */ React.createElement(TrashIcon, { className: "fill-current transition-colors ease-out duration-100" })
5764
+ /* @__PURE__ */ React.createElement(TrashIcon, { className: "h-5 w-auto fill-current text-red-500 transition-colors duration-150 ease-out" })
5109
5765
  );
5110
5766
  };
5111
5767
  const DragHandle = ({ isDragging }) => {
@@ -5135,7 +5791,7 @@ var __publicField = (obj, key, value) => {
5135
5791
  return template.label ? template.label.toLowerCase().includes(filter.toLowerCase()) || name.toLowerCase().includes(filter.toLowerCase()) : name.toLowerCase().includes(filter.toLowerCase());
5136
5792
  });
5137
5793
  }, [filter]);
5138
- 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(
5794
+ 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(
5139
5795
  IconButton,
5140
5796
  {
5141
5797
  variant: open2 ? "secondary" : "primary",
@@ -5144,7 +5800,7 @@ var __publicField = (obj, key, value) => {
5144
5800
  },
5145
5801
  /* @__PURE__ */ React__namespace.createElement(AddIcon, { className: "w-5/6 h-auto" })
5146
5802
  )), /* @__PURE__ */ React__namespace.createElement("div", { className: "transform translate-y-full absolute -bottom-1 right-0 z-50" }, /* @__PURE__ */ React__namespace.createElement(
5147
- react$1.Transition,
5803
+ react.Transition,
5148
5804
  {
5149
5805
  enter: "transition duration-150 ease-out",
5150
5806
  enterFrom: "transform opacity-0 -translate-y-2",
@@ -5153,7 +5809,7 @@ var __publicField = (obj, key, value) => {
5153
5809
  leaveFrom: "transform opacity-100 translate-y-0",
5154
5810
  leaveTo: "transform opacity-0 -translate-y-2"
5155
5811
  },
5156
- /* @__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(
5812
+ /* @__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(
5157
5813
  "input",
5158
5814
  {
5159
5815
  type: "text",
@@ -5183,27 +5839,35 @@ var __publicField = (obj, key, value) => {
5183
5839
  ))))
5184
5840
  ))));
5185
5841
  };
5186
- const Group = wrapFieldWithError(({ tinaForm, field }) => {
5187
- const cms = useCMS$1();
5188
- React__namespace.useState(false);
5189
- return /* @__PURE__ */ React__namespace.createElement(React__namespace.Fragment, null, /* @__PURE__ */ React__namespace.createElement(
5190
- Header,
5191
- {
5192
- onClick: () => {
5193
- const state = tinaForm.finalForm.getState();
5194
- if (state.invalid === true) {
5195
- cms.alerts.error("Cannot navigate away from an invalid form.");
5196
- return;
5842
+ const Group = wrapFieldWithNoHeader(
5843
+ ({ tinaForm, field }) => {
5844
+ const cms = useCMS$1();
5845
+ return /* @__PURE__ */ React__namespace.createElement(React__namespace.Fragment, null, /* @__PURE__ */ React__namespace.createElement(
5846
+ Header,
5847
+ {
5848
+ onClick: () => {
5849
+ const state = tinaForm.finalForm.getState();
5850
+ if (state.invalid === true) {
5851
+ cms.alerts.error("Cannot navigate away from an invalid form.");
5852
+ return;
5853
+ }
5854
+ cms.dispatch({
5855
+ type: "forms:set-active-field-name",
5856
+ value: { formId: tinaForm.id, fieldName: field.name }
5857
+ });
5197
5858
  }
5198
- cms.dispatch({
5199
- type: "forms:set-active-field-name",
5200
- value: { formId: tinaForm.id, fieldName: field.name }
5201
- });
5202
- }
5203
- },
5204
- field.label || field.name
5205
- ));
5206
- });
5859
+ },
5860
+ field.label || field.name,
5861
+ field.description && /* @__PURE__ */ React__namespace.createElement(
5862
+ "span",
5863
+ {
5864
+ className: `block font-sans text-xs italic font-light text-gray-400 pt-0.5 whitespace-normal m-0`,
5865
+ dangerouslySetInnerHTML: { __html: field.description }
5866
+ }
5867
+ )
5868
+ ));
5869
+ }
5870
+ );
5207
5871
  const Header = ({ onClick, children }) => {
5208
5872
  return /* @__PURE__ */ React__namespace.createElement("div", { className: "pt-1 mb-5" }, /* @__PURE__ */ React__namespace.createElement(
5209
5873
  "button",
@@ -5330,8 +5994,8 @@ var __publicField = (obj, key, value) => {
5330
5994
  onClick: () => setPickerIsOpen(!pickerIsOpen)
5331
5995
  },
5332
5996
  /* @__PURE__ */ React__namespace.createElement(AddIcon, { className: "w-5/6 h-auto" })
5333
- ), /* @__PURE__ */ React__namespace.createElement(FormPortal, null, ({ zIndexShift }) => /* @__PURE__ */ React__namespace.createElement(react$1.Transition, { show: pickerIsOpen }, /* @__PURE__ */ React__namespace.createElement(
5334
- react$1.TransitionChild,
5997
+ ), /* @__PURE__ */ React__namespace.createElement(FormPortal, null, ({ zIndexShift }) => /* @__PURE__ */ React__namespace.createElement(react.Transition, { show: pickerIsOpen }, /* @__PURE__ */ React__namespace.createElement(
5998
+ react.TransitionChild,
5335
5999
  {
5336
6000
  enter: "transform transition-all ease-out duration-200",
5337
6001
  enterFrom: "opacity-0 -translate-x-1/2",
@@ -5418,14 +6082,14 @@ var __publicField = (obj, key, value) => {
5418
6082
  };
5419
6083
  const BlockGroup = ({ category, templates, close: close2, isLast = false }) => {
5420
6084
  return /* @__PURE__ */ React__namespace.createElement(
5421
- react$1.Disclosure,
6085
+ react.Disclosure,
5422
6086
  {
5423
6087
  defaultOpen: true,
5424
6088
  as: "div",
5425
6089
  className: `left-0 right-0 relative`
5426
6090
  },
5427
6091
  ({ open: open2 }) => /* @__PURE__ */ React__namespace.createElement(React__namespace.Fragment, null, /* @__PURE__ */ React__namespace.createElement(
5428
- react$1.DisclosureButton,
6092
+ react.DisclosureButton,
5429
6093
  {
5430
6094
  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`}`
5431
6095
  },
@@ -5443,7 +6107,7 @@ var __publicField = (obj, key, value) => {
5443
6107
  }
5444
6108
  )
5445
6109
  ), /* @__PURE__ */ React__namespace.createElement(
5446
- react$1.Transition,
6110
+ react.Transition,
5447
6111
  {
5448
6112
  enter: "transition duration-100 ease-out",
5449
6113
  enterFrom: "transform scale-95 opacity-0",
@@ -5452,7 +6116,7 @@ var __publicField = (obj, key, value) => {
5452
6116
  leaveFrom: "transform scale-100 opacity-100",
5453
6117
  leaveTo: "transform scale-95 opacity-0"
5454
6118
  },
5455
- /* @__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(
6119
+ /* @__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(
5456
6120
  BlockCard,
5457
6121
  {
5458
6122
  key: index,
@@ -6545,244 +7209,65 @@ var __publicField = (obj, key, value) => {
6545
7209
  str = "0" + str;
6546
7210
  return str;
6547
7211
  }
6548
- function _inheritsLoose(subClass, superClass) {
6549
- subClass.prototype = Object.create(superClass.prototype);
6550
- subClass.prototype.constructor = subClass;
6551
- _setPrototypeOf(subClass, superClass);
6552
- }
6553
- function _setPrototypeOf(o, p) {
6554
- _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf2(o2, p2) {
6555
- o2.__proto__ = p2;
6556
- return o2;
6557
- };
6558
- return _setPrototypeOf(o, p);
6559
- }
6560
- function _objectWithoutPropertiesLoose(source, excluded) {
6561
- if (source == null)
6562
- return {};
6563
- var target = {};
6564
- var sourceKeys = Object.keys(source);
6565
- var key, i;
6566
- for (i = 0; i < sourceKeys.length; i++) {
6567
- key = sourceKeys[i];
6568
- if (excluded.indexOf(key) >= 0)
6569
- continue;
6570
- target[key] = source[key];
6571
- }
6572
- return target;
6573
- }
6574
- function _assertThisInitialized(self2) {
6575
- if (self2 === void 0) {
6576
- throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
6577
- }
6578
- return self2;
6579
- }
6580
- function isNodeFound(current, componentNode, ignoreClass) {
6581
- if (current === componentNode) {
6582
- return true;
6583
- }
6584
- if (current.correspondingElement) {
6585
- return current.correspondingElement.classList.contains(ignoreClass);
6586
- }
6587
- return current.classList.contains(ignoreClass);
6588
- }
6589
- function findHighest(current, componentNode, ignoreClass) {
6590
- if (current === componentNode) {
6591
- return true;
7212
+ var useClickAway$1 = {};
7213
+ var util = {};
7214
+ Object.defineProperty(util, "__esModule", { value: true });
7215
+ util.isNavigator = util.isBrowser = util.off = util.on = util.noop = void 0;
7216
+ var noop = function() {
7217
+ };
7218
+ util.noop = noop;
7219
+ function on(obj) {
7220
+ var args = [];
7221
+ for (var _i = 1; _i < arguments.length; _i++) {
7222
+ args[_i - 1] = arguments[_i];
6592
7223
  }
6593
- while (current.parentNode || current.host) {
6594
- if (current.parentNode && isNodeFound(current, componentNode, ignoreClass)) {
6595
- return true;
6596
- }
6597
- current = current.parentNode || current.host;
7224
+ if (obj && obj.addEventListener) {
7225
+ obj.addEventListener.apply(obj, args);
6598
7226
  }
6599
- return current;
6600
7227
  }
6601
- function clickedScrollbar(evt) {
6602
- return document.documentElement.clientWidth <= evt.clientX || document.documentElement.clientHeight <= evt.clientY;
6603
- }
6604
- var testPassiveEventSupport = function testPassiveEventSupport2() {
6605
- if (typeof window === "undefined" || typeof window.addEventListener !== "function") {
6606
- return;
7228
+ util.on = on;
7229
+ function off(obj) {
7230
+ var args = [];
7231
+ for (var _i = 1; _i < arguments.length; _i++) {
7232
+ args[_i - 1] = arguments[_i];
6607
7233
  }
6608
- var passive = false;
6609
- var options = Object.defineProperty({}, "passive", {
6610
- get: function get2() {
6611
- passive = true;
6612
- }
6613
- });
6614
- var noop = function noop2() {
6615
- };
6616
- window.addEventListener("testPassiveEventSupport", noop, options);
6617
- window.removeEventListener("testPassiveEventSupport", noop, options);
6618
- return passive;
6619
- };
6620
- function autoInc(seed) {
6621
- if (seed === void 0) {
6622
- seed = 0;
7234
+ if (obj && obj.removeEventListener) {
7235
+ obj.removeEventListener.apply(obj, args);
6623
7236
  }
6624
- return function() {
6625
- return ++seed;
6626
- };
6627
7237
  }
6628
- var uid = autoInc();
6629
- var passiveEventSupport;
6630
- var handlersMap = {};
6631
- var enabledInstances = {};
6632
- var touchEvents = ["touchstart", "touchmove"];
6633
- var IGNORE_CLASS_NAME = "ignore-react-onclickoutside";
6634
- function getEventHandlerOptions(instance, eventName) {
6635
- var handlerOptions = {};
6636
- var isTouchEvent = touchEvents.indexOf(eventName) !== -1;
6637
- if (isTouchEvent && passiveEventSupport) {
6638
- handlerOptions.passive = !instance.props.preventDefault;
6639
- }
6640
- return handlerOptions;
6641
- }
6642
- function onClickOutsideHOC(WrappedComponent, config) {
6643
- var _class, _temp;
6644
- var componentName = WrappedComponent.displayName || WrappedComponent.name || "Component";
6645
- return _temp = _class = /* @__PURE__ */ function(_Component) {
6646
- _inheritsLoose(onClickOutside, _Component);
6647
- function onClickOutside(props) {
6648
- var _this;
6649
- _this = _Component.call(this, props) || this;
6650
- _this.__outsideClickHandler = function(event) {
6651
- if (typeof _this.__clickOutsideHandlerProp === "function") {
6652
- _this.__clickOutsideHandlerProp(event);
6653
- return;
6654
- }
6655
- var instance = _this.getInstance();
6656
- if (typeof instance.props.handleClickOutside === "function") {
6657
- instance.props.handleClickOutside(event);
6658
- return;
6659
- }
6660
- if (typeof instance.handleClickOutside === "function") {
6661
- instance.handleClickOutside(event);
6662
- return;
6663
- }
6664
- throw new Error("WrappedComponent: " + componentName + " lacks a handleClickOutside(event) function for processing outside click events.");
6665
- };
6666
- _this.__getComponentNode = function() {
6667
- var instance = _this.getInstance();
6668
- if (config && typeof config.setClickOutsideRef === "function") {
6669
- return config.setClickOutsideRef()(instance);
6670
- }
6671
- if (typeof instance.setClickOutsideRef === "function") {
6672
- return instance.setClickOutsideRef();
6673
- }
6674
- return reactDom.findDOMNode(instance);
6675
- };
6676
- _this.enableOnClickOutside = function() {
6677
- if (typeof document === "undefined" || enabledInstances[_this._uid]) {
6678
- return;
6679
- }
6680
- if (typeof passiveEventSupport === "undefined") {
6681
- passiveEventSupport = testPassiveEventSupport();
6682
- }
6683
- enabledInstances[_this._uid] = true;
6684
- var events = _this.props.eventTypes;
6685
- if (!events.forEach) {
6686
- events = [events];
6687
- }
6688
- handlersMap[_this._uid] = function(event) {
6689
- if (_this.componentNode === null)
6690
- return;
6691
- if (_this.initTimeStamp > event.timeStamp)
6692
- return;
6693
- if (_this.props.preventDefault) {
6694
- event.preventDefault();
6695
- }
6696
- if (_this.props.stopPropagation) {
6697
- event.stopPropagation();
6698
- }
6699
- if (_this.props.excludeScrollbar && clickedScrollbar(event))
6700
- return;
6701
- var current = event.composed && event.composedPath && event.composedPath().shift() || event.target;
6702
- if (findHighest(current, _this.componentNode, _this.props.outsideClickIgnoreClass) !== document) {
6703
- return;
6704
- }
6705
- _this.__outsideClickHandler(event);
6706
- };
6707
- events.forEach(function(eventName) {
6708
- document.addEventListener(eventName, handlersMap[_this._uid], getEventHandlerOptions(_assertThisInitialized(_this), eventName));
6709
- });
6710
- };
6711
- _this.disableOnClickOutside = function() {
6712
- delete enabledInstances[_this._uid];
6713
- var fn = handlersMap[_this._uid];
6714
- if (fn && typeof document !== "undefined") {
6715
- var events = _this.props.eventTypes;
6716
- if (!events.forEach) {
6717
- events = [events];
6718
- }
6719
- events.forEach(function(eventName) {
6720
- return document.removeEventListener(eventName, fn, getEventHandlerOptions(_assertThisInitialized(_this), eventName));
6721
- });
6722
- delete handlersMap[_this._uid];
6723
- }
6724
- };
6725
- _this.getRef = function(ref) {
6726
- return _this.instanceRef = ref;
6727
- };
6728
- _this._uid = uid();
6729
- _this.initTimeStamp = performance.now();
6730
- return _this;
6731
- }
6732
- var _proto = onClickOutside.prototype;
6733
- _proto.getInstance = function getInstance() {
6734
- if (WrappedComponent.prototype && !WrappedComponent.prototype.isReactComponent) {
6735
- return this;
6736
- }
6737
- var ref = this.instanceRef;
6738
- return ref.getInstance ? ref.getInstance() : ref;
6739
- };
6740
- _proto.componentDidMount = function componentDidMount() {
6741
- if (typeof document === "undefined" || !document.createElement) {
6742
- return;
6743
- }
6744
- var instance = this.getInstance();
6745
- if (config && typeof config.handleClickOutside === "function") {
6746
- this.__clickOutsideHandlerProp = config.handleClickOutside(instance);
6747
- if (typeof this.__clickOutsideHandlerProp !== "function") {
6748
- throw new Error("WrappedComponent: " + componentName + " lacks a function for processing outside click events specified by the handleClickOutside config option.");
6749
- }
6750
- }
6751
- this.componentNode = this.__getComponentNode();
6752
- if (this.props.disableOnClickOutside)
6753
- return;
6754
- this.enableOnClickOutside();
6755
- };
6756
- _proto.componentDidUpdate = function componentDidUpdate() {
6757
- this.componentNode = this.__getComponentNode();
6758
- };
6759
- _proto.componentWillUnmount = function componentWillUnmount() {
6760
- this.disableOnClickOutside();
7238
+ util.off = off;
7239
+ util.isBrowser = typeof window !== "undefined";
7240
+ util.isNavigator = typeof navigator !== "undefined";
7241
+ Object.defineProperty(useClickAway$1, "__esModule", { value: true });
7242
+ var react_1 = React;
7243
+ var util_1 = util;
7244
+ var defaultEvents = ["mousedown", "touchstart"];
7245
+ var useClickAway = function(ref, onClickAway, events) {
7246
+ if (events === void 0) {
7247
+ events = defaultEvents;
7248
+ }
7249
+ var savedCallback = react_1.useRef(onClickAway);
7250
+ react_1.useEffect(function() {
7251
+ savedCallback.current = onClickAway;
7252
+ }, [onClickAway]);
7253
+ react_1.useEffect(function() {
7254
+ var handler = function(event) {
7255
+ var el = ref.current;
7256
+ el && !el.contains(event.target) && savedCallback.current(event);
6761
7257
  };
6762
- _proto.render = function render() {
6763
- var _this$props = this.props;
6764
- _this$props.excludeScrollbar;
6765
- var props = _objectWithoutPropertiesLoose(_this$props, ["excludeScrollbar"]);
6766
- if (WrappedComponent.prototype && WrappedComponent.prototype.isReactComponent) {
6767
- props.ref = this.getRef;
6768
- } else {
6769
- props.wrappedRef = this.getRef;
7258
+ for (var _i = 0, events_1 = events; _i < events_1.length; _i++) {
7259
+ var eventName = events_1[_i];
7260
+ util_1.on(document, eventName, handler);
7261
+ }
7262
+ return function() {
7263
+ for (var _i2 = 0, events_2 = events; _i2 < events_2.length; _i2++) {
7264
+ var eventName2 = events_2[_i2];
7265
+ util_1.off(document, eventName2, handler);
6770
7266
  }
6771
- props.disableOnClickOutside = this.disableOnClickOutside;
6772
- props.enableOnClickOutside = this.enableOnClickOutside;
6773
- return React.createElement(WrappedComponent, props);
6774
7267
  };
6775
- return onClickOutside;
6776
- }(React.Component), _class.displayName = "OnClickOutside(" + componentName + ")", _class.defaultProps = {
6777
- eventTypes: ["mousedown", "touchstart"],
6778
- excludeScrollbar: config && config.excludeScrollbar || false,
6779
- outsideClickIgnoreClass: IGNORE_CLASS_NAME,
6780
- preventDefault: false,
6781
- stopPropagation: false
6782
- }, _class.getClass = function() {
6783
- return WrappedComponent.getClass ? WrappedComponent.getClass() : WrappedComponent;
6784
- }, _temp;
6785
- }
7268
+ }, [events, ref]);
7269
+ };
7270
+ var _default = useClickAway$1.default = useClickAway;
6786
7271
  const viewModes = {
6787
7272
  YEARS: "years",
6788
7273
  MONTHS: "months",
@@ -7311,22 +7796,13 @@ var __publicField = (obj, key, value) => {
7311
7796
  }
7312
7797
  con[method]("***react-datetime:" + message);
7313
7798
  }
7314
- class ClickOutBase extends React.Component {
7315
- constructor() {
7316
- super(...arguments);
7317
- __publicField(this, "container", React.createRef());
7318
- }
7319
- render() {
7320
- return /* @__PURE__ */ React.createElement("div", { className: this.props.className, ref: this.container }, this.props.children);
7321
- }
7322
- handleClickOutside(e) {
7323
- this.props.onClickOut(e);
7324
- }
7325
- setClickOutsideRef() {
7326
- return this.container.current;
7327
- }
7799
+ function ClickableWrapper({ className, onClickOut, children }) {
7800
+ const containerRef = React.useRef(null);
7801
+ _default(containerRef, (event) => {
7802
+ onClickOut(event);
7803
+ });
7804
+ return /* @__PURE__ */ React.createElement("div", { className, ref: containerRef }, children);
7328
7805
  }
7329
- const ClickableWrapper = onClickOutsideHOC(ClickOutBase);
7330
7806
  const DEFAULT_DATE_DISPLAY_FORMAT = "MMM DD, YYYY";
7331
7807
  const DEFAULT_TIME_DISPLAY_FORMAT = "h:mm A";
7332
7808
  const format$1 = (val, _name, field) => {
@@ -7369,7 +7845,10 @@ var __publicField = (obj, key, value) => {
7369
7845
  ReactDateTimeWithStyles,
7370
7846
  {
7371
7847
  value: input.value,
7372
- onChange: input.onChange,
7848
+ onChange: (value) => {
7849
+ const newValue = value === "" ? void 0 : value;
7850
+ input.onChange(newValue);
7851
+ },
7373
7852
  dateFormat: dateFormat || DEFAULT_DATE_DISPLAY_FORMAT,
7374
7853
  timeFormat: timeFormat || false,
7375
7854
  inputProps: { className: textFieldClasses },
@@ -9271,7 +9750,7 @@ var __publicField = (obj, key, value) => {
9271
9750
  const FormLists = (props) => {
9272
9751
  const cms = useCMS();
9273
9752
  return /* @__PURE__ */ React__namespace.createElement(
9274
- react$1.Transition,
9753
+ react.Transition,
9275
9754
  {
9276
9755
  appear: true,
9277
9756
  show: true,
@@ -9700,7 +10179,7 @@ var __publicField = (obj, key, value) => {
9700
10179
  "Event Log"
9701
10180
  ));
9702
10181
  };
9703
- const version = "2.2.8";
10182
+ const version = "2.6.0";
9704
10183
  const Nav = ({
9705
10184
  isLocalMode,
9706
10185
  className = "",
@@ -9754,8 +10233,8 @@ var __publicField = (obj, key, value) => {
9754
10233
  style: { maxWidth: `${sidebarWidth}px` },
9755
10234
  ...props
9756
10235
  },
9757
- /* @__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(
9758
- react$1.MenuButton,
10236
+ /* @__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(
10237
+ react.MenuButton,
9759
10238
  {
9760
10239
  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"}`
9761
10240
  },
@@ -9778,7 +10257,7 @@ var __publicField = (obj, key, value) => {
9778
10257
  }
9779
10258
  )
9780
10259
  ), /* @__PURE__ */ React__namespace.createElement("div", { className: "transform translate-y-full absolute bottom-3 right-5 z-50" }, /* @__PURE__ */ React__namespace.createElement(
9781
- react$1.Transition,
10260
+ react.Transition,
9782
10261
  {
9783
10262
  enter: "transition duration-150 ease-out",
9784
10263
  enterFrom: "transform opacity-0 -translate-y-2",
@@ -9787,7 +10266,7 @@ var __publicField = (obj, key, value) => {
9787
10266
  leaveFrom: "transform opacity-100 translate-y-0",
9788
10267
  leaveTo: "transform opacity-0 -translate-y-2"
9789
10268
  },
9790
- /* @__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(
10269
+ /* @__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(
9791
10270
  "button",
9792
10271
  {
9793
10272
  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`,
@@ -9820,7 +10299,7 @@ var __publicField = (obj, key, value) => {
9820
10299
  },
9821
10300
  /* @__PURE__ */ React__namespace.createElement(BiExit, { className: "w-6 h-auto mr-2 text-blue-400" }),
9822
10301
  " Log Out"
9823
- )), /* @__PURE__ */ React__namespace.createElement(react$1.MenuItem, null, /* @__PURE__ */ React__namespace.createElement(
10302
+ )), /* @__PURE__ */ React__namespace.createElement(react.MenuItem, null, /* @__PURE__ */ React__namespace.createElement(
9824
10303
  WrappedSyncStatus,
9825
10304
  {
9826
10305
  cms,
@@ -10166,8 +10645,8 @@ var __publicField = (obj, key, value) => {
10166
10645
  screen: activeScreen,
10167
10646
  close: () => setActiveView(null)
10168
10647
  }
10169
- )), /* @__PURE__ */ React__namespace.createElement(ResizeHandle, null)), renderMobileNav && /* @__PURE__ */ React__namespace.createElement(react$1.Transition, { show: menuIsOpen, as: "div" }, /* @__PURE__ */ React__namespace.createElement(
10170
- react$1.TransitionChild,
10648
+ )), /* @__PURE__ */ React__namespace.createElement(ResizeHandle, null)), renderMobileNav && /* @__PURE__ */ React__namespace.createElement(react.Transition, { show: menuIsOpen, as: "div" }, /* @__PURE__ */ React__namespace.createElement(
10649
+ react.TransitionChild,
10171
10650
  {
10172
10651
  enter: "transform transition-all ease-out duration-300",
10173
10652
  enterFrom: "opacity-0 -translate-x-full",
@@ -10232,7 +10711,7 @@ var __publicField = (obj, key, value) => {
10232
10711
  ))
10233
10712
  ))
10234
10713
  ), /* @__PURE__ */ React__namespace.createElement(
10235
- react$1.TransitionChild,
10714
+ react.TransitionChild,
10236
10715
  {
10237
10716
  enter: "ease-out duration-300",
10238
10717
  enterFrom: "opacity-0",
@@ -12231,15 +12710,14 @@ var __publicField = (obj, key, value) => {
12231
12710
  fields: fieldGroup.fields
12232
12711
  }
12233
12712
  ) : /* @__PURE__ */ React__namespace.createElement(NoFieldsPlaceholder, null)
12234
- )), !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(
12713
+ )), !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(
12235
12714
  ResetForm,
12236
12715
  {
12237
12716
  pristine,
12238
12717
  reset: async () => {
12239
12718
  finalForm2.reset();
12240
12719
  await tinaForm.reset();
12241
- },
12242
- style: { flexGrow: 1 }
12720
+ }
12243
12721
  },
12244
12722
  tinaForm.buttons.reset
12245
12723
  ), /* @__PURE__ */ React__namespace.createElement(
@@ -12248,8 +12726,7 @@ var __publicField = (obj, key, value) => {
12248
12726
  onClick: safeHandleSubmit,
12249
12727
  disabled: !canSubmit,
12250
12728
  busy: submitting,
12251
- variant: "primary",
12252
- style: { flexGrow: 3 }
12729
+ variant: "primary"
12253
12730
  },
12254
12731
  submitting && /* @__PURE__ */ React__namespace.createElement(LoadingDots, null),
12255
12732
  !submitting && tinaForm.buttons.save
@@ -12767,15 +13244,15 @@ var __publicField = (obj, key, value) => {
12767
13244
  );
12768
13245
  };
12769
13246
  const DotMenu = ({ onOpen, onRemove }) => {
12770
- return /* @__PURE__ */ React.createElement(react$1.Popover, { as: "span", className: "-ml-px relative block" }, /* @__PURE__ */ React.createElement(
12771
- react$1.PopoverButton,
13247
+ return /* @__PURE__ */ React.createElement(react.Popover, { as: "span", className: "-ml-px relative block" }, /* @__PURE__ */ React.createElement(
13248
+ react.PopoverButton,
12772
13249
  {
12773
13250
  as: "span",
12774
13251
  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"
12775
13252
  },
12776
13253
  /* @__PURE__ */ React.createElement(EllipsisIcon, { title: "Open options" })
12777
13254
  ), /* @__PURE__ */ React.createElement(
12778
- react$1.Transition,
13255
+ react.Transition,
12779
13256
  {
12780
13257
  enter: "transition ease-out duration-100",
12781
13258
  enterFrom: "transform opacity-0 scale-95",
@@ -12784,7 +13261,7 @@ var __publicField = (obj, key, value) => {
12784
13261
  leaveFrom: "transform opacity-100 scale-100",
12785
13262
  leaveTo: "transform opacity-0 scale-95"
12786
13263
  },
12787
- /* @__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(
13264
+ /* @__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(
12788
13265
  "span",
12789
13266
  {
12790
13267
  onClick: onOpen,
@@ -13207,13 +13684,26 @@ var __publicField = (obj, key, value) => {
13207
13684
  plate.createUnderlinePlugin(),
13208
13685
  plate.createCodePlugin(),
13209
13686
  plate.createListPlugin(),
13210
- plate.createIndentPlugin(),
13211
13687
  plate.createIndentListPlugin(),
13212
13688
  plate.createHorizontalRulePlugin(),
13213
13689
  // Allows us to do things like copy/paste, remembering the state of the element (like mdx)
13214
13690
  plate.createNodeIdPlugin(),
13215
- plateSlashCommand.createSlashPlugin()
13691
+ plateSlashCommand.createSlashPlugin(),
13692
+ plate.createTablePlugin()
13216
13693
  ];
13694
+ const unsupportedItemsInTable = /* @__PURE__ */ new Set([
13695
+ "Code Block",
13696
+ "Unordered List",
13697
+ "Ordered List",
13698
+ "Quote",
13699
+ "Mermaid",
13700
+ "Heading 1",
13701
+ "Heading 2",
13702
+ "Heading 3",
13703
+ "Heading 4",
13704
+ "Heading 5",
13705
+ "Heading 6"
13706
+ ]);
13217
13707
  const isNodeActive = (editor, type) => {
13218
13708
  const pluginType = plateCommon.getPluginType(editor, type);
13219
13709
  return !!(editor == null ? void 0 : editor.selection) && plateCommon.someNode(editor, { match: { type: pluginType } });
@@ -13398,24 +13888,6 @@ var __publicField = (obj, key, value) => {
13398
13888
  }
13399
13889
  );
13400
13890
  Editor.displayName = "Editor";
13401
- const separatorVariants = classVarianceAuthority.cva("shrink-0 bg-border", {
13402
- defaultVariants: {
13403
- orientation: "horizontal"
13404
- },
13405
- variants: {
13406
- orientation: {
13407
- horizontal: "h-px w-full",
13408
- vertical: "h-full w-px"
13409
- }
13410
- }
13411
- });
13412
- const Separator = cn$1.withVariants(
13413
- cn$1.withProps(SeparatorPrimitive__namespace.Root, {
13414
- decorative: true,
13415
- orientation: "horizontal"
13416
- }),
13417
- separatorVariants
13418
- );
13419
13891
  const TooltipProvider = TooltipPrimitive__namespace.Provider;
13420
13892
  const Tooltip = TooltipPrimitive__namespace.Root;
13421
13893
  const TooltipTrigger = TooltipPrimitive__namespace.Trigger;
@@ -13424,7 +13896,7 @@ var __publicField = (obj, key, value) => {
13424
13896
  cn$1.withProps(TooltipPrimitive__namespace.Content, {
13425
13897
  sideOffset: 4
13426
13898
  }),
13427
- "z-50 overflow-hidden rounded-md border bg-popover px-3 py-1.5 text-sm text-popover-foreground shadow-md"
13899
+ "z-[9999] overflow-hidden rounded-md border bg-popover px-3 py-1.5 text-sm text-popover-foreground shadow-md"
13428
13900
  );
13429
13901
  function withTooltip(Component) {
13430
13902
  return React.forwardRef(function ExtendComponent({ tooltip, tooltipContentProps, tooltipProps, ...props }, ref) {
@@ -13550,140 +14022,41 @@ var __publicField = (obj, key, value) => {
13550
14022
  Toolbar,
13551
14023
  "p-1 sticky left-0 top-0 z-50 w-full justify-between overflow-x-auto border border-border bg-background"
13552
14024
  );
13553
- const MarkToolbarButton = cn$1.withRef(({ clear, nodeType, ...rest }, ref) => {
13554
- const state = plateCommon.useMarkToolbarButtonState({ clear, nodeType });
13555
- const { props } = plateCommon.useMarkToolbarButton(state);
13556
- return /* @__PURE__ */ React.createElement(ToolbarButton, { ref, ...props, ...rest });
13557
- });
13558
- const IndentListToolbarButton = cn$1.withRef(({ nodeType = plate.ELEMENT_UL }, ref) => {
13559
- const editor = plateCommon.useEditorState();
13560
- const state = plate.useListToolbarButtonState({ nodeType });
13561
- const { props } = plate.useListToolbarButton(state);
13562
- return /* @__PURE__ */ React.createElement(
13563
- ToolbarButton,
13564
- {
13565
- ref,
13566
- tooltip: nodeType === plate.ELEMENT_UL ? "Bulleted List" : "Numbered List",
13567
- ...props,
13568
- onClick: (e) => {
13569
- e.preventDefault();
13570
- e.stopPropagation();
13571
- plate.toggleList(editor, { type: nodeType });
13572
- }
13573
- },
13574
- nodeType === plate.ELEMENT_UL ? /* @__PURE__ */ React.createElement(Icons.ul, null) : /* @__PURE__ */ React.createElement(Icons.ol, null)
13575
- );
13576
- });
13577
- const DropdownMenu = DropdownMenuPrimitive__namespace.Root;
13578
- const DropdownMenuTrigger = DropdownMenuPrimitive__namespace.Trigger;
13579
- const DropdownMenuRadioGroup = DropdownMenuPrimitive__namespace.RadioGroup;
13580
- cn$1.withRef(({ children, className, inset, ...props }, ref) => /* @__PURE__ */ React.createElement(
13581
- DropdownMenuPrimitive__namespace.SubTrigger,
13582
- {
13583
- className: cn$1.cn(
13584
- "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",
13585
- "data-[disabled]:pointer-events-none data-[disabled]:opacity-50",
13586
- inset && "pl-8",
13587
- className
13588
- ),
13589
- ref,
13590
- ...props
13591
- },
13592
- children,
13593
- /* @__PURE__ */ React.createElement(Icons.chevronRight, { className: "ml-auto size-4" })
13594
- ));
13595
- cn$1.withCn(
13596
- DropdownMenuPrimitive__namespace.SubContent,
13597
- "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"
13598
- );
13599
- const DropdownMenuContentVariants = cn$1.withProps(DropdownMenuPrimitive__namespace.Content, {
13600
- className: cn$1.cn(
13601
- "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"
13602
- ),
13603
- sideOffset: 4
13604
- });
13605
- const DropdownMenuContent = cn$1.withRef(({ ...props }, ref) => /* @__PURE__ */ React.createElement(DropdownMenuPrimitive__namespace.Portal, null, /* @__PURE__ */ React.createElement(DropdownMenuContentVariants, { ref, ...props })));
13606
- const menuItemVariants = classVarianceAuthority.cva(
13607
- cn$1.cn(
13608
- "relative flex h-9 cursor-pointer select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none transition-colors",
13609
- "focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50"
13610
- ),
13611
- {
13612
- variants: {
13613
- inset: {
13614
- true: "pl-8"
14025
+ const useResize = (ref, callback) => {
14026
+ React.useEffect(() => {
14027
+ const resizeObserver = new ResizeObserver((entries) => {
14028
+ for (const entry of entries) {
14029
+ callback(entry);
13615
14030
  }
14031
+ });
14032
+ if (ref.current) {
14033
+ resizeObserver.observe(ref.current);
13616
14034
  }
13617
- }
13618
- );
13619
- const DropdownMenuItem = cn$1.withVariants(
13620
- DropdownMenuPrimitive__namespace.Item,
13621
- menuItemVariants,
13622
- ["inset"]
13623
- );
13624
- cn$1.withRef(({ children, className, ...props }, ref) => /* @__PURE__ */ React.createElement(
13625
- DropdownMenuPrimitive__namespace.CheckboxItem,
13626
- {
13627
- className: cn$1.cn(
13628
- "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",
13629
- "cursor-pointer",
13630
- className
13631
- ),
13632
- ref,
13633
- ...props
13634
- },
13635
- /* @__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" }))),
13636
- children
13637
- ));
13638
- const DropdownMenuRadioItem = cn$1.withRef(({ children, className, hideIcon, ...props }, ref) => /* @__PURE__ */ React.createElement(
13639
- DropdownMenuPrimitive__namespace.RadioItem,
13640
- {
13641
- className: cn$1.cn(
13642
- "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",
13643
- "h-9 cursor-pointer px-2 data-[state=checked]:bg-accent data-[state=checked]:text-accent-foreground",
13644
- className
13645
- ),
13646
- ref,
13647
- ...props
13648
- },
13649
- !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" }))),
14035
+ return () => resizeObserver.disconnect();
14036
+ }, [ref.current]);
14037
+ };
14038
+ const STANDARD_ICON_WIDTH = 32;
14039
+ const HEADING_ICON_WITH_TEXT = 127;
14040
+ const HEADING_ICON_ONLY = 58;
14041
+ const EMBED_ICON_WIDTH = 78;
14042
+ const CONTAINER_MD_BREAKPOINT = 448;
14043
+ const FLOAT_BUTTON_WIDTH = 25;
14044
+ const HEADING_LABEL = "Headings";
14045
+ const ToolbarContext = React.createContext(void 0);
14046
+ const ToolbarProvider = ({
14047
+ tinaForm,
14048
+ templates,
14049
+ overrides,
13650
14050
  children
13651
- ));
13652
- const dropdownMenuLabelVariants = classVarianceAuthority.cva(
13653
- cn$1.cn("select-none px-2 py-1.5 text-sm font-semibold"),
13654
- {
13655
- variants: {
13656
- inset: {
13657
- true: "pl-8"
13658
- }
13659
- }
14051
+ }) => {
14052
+ return /* @__PURE__ */ React.createElement(ToolbarContext.Provider, { value: { tinaForm, templates, overrides } }, children);
14053
+ };
14054
+ const useToolbarContext = () => {
14055
+ const context = React.useContext(ToolbarContext);
14056
+ if (!context) {
14057
+ throw new Error("useToolbarContext must be used within a ToolbarProvider");
13660
14058
  }
13661
- );
13662
- const DropdownMenuLabel = cn$1.withVariants(
13663
- DropdownMenuPrimitive__namespace.Label,
13664
- dropdownMenuLabelVariants,
13665
- ["inset"]
13666
- );
13667
- const DropdownMenuSeparator = cn$1.withCn(
13668
- DropdownMenuPrimitive__namespace.Separator,
13669
- "-mx-1 my-1 h-px bg-muted"
13670
- );
13671
- cn$1.withCn(
13672
- cn$1.createPrimitiveElement("span"),
13673
- "ml-auto text-xs tracking-widest opacity-60"
13674
- );
13675
- const useOpenState = () => {
13676
- const [open2, setOpen] = React.useState(false);
13677
- const onOpenChange = React.useCallback(
13678
- (_value = !open2) => {
13679
- setOpen(_value);
13680
- },
13681
- [open2]
13682
- );
13683
- return {
13684
- onOpenChange,
13685
- open: open2
13686
- };
14059
+ return context;
13687
14060
  };
13688
14061
  const items$1 = [
13689
14062
  {
@@ -13749,7 +14122,9 @@ var __publicField = (obj, key, value) => {
13749
14122
  return allNodesMatchInitialNodeType ? initialNodeType : plateParagraph.ELEMENT_PARAGRAPH;
13750
14123
  }, []);
13751
14124
  const editor = plateCommon.useEditorRef();
14125
+ const editorState = plateCommon.useEditorState();
13752
14126
  const openState = useOpenState();
14127
+ const userInTable = helpers.isNodeActive(editorState, plateTable.ELEMENT_TABLE);
13753
14128
  const selectedItem = items$1.find((item) => item.value === value) ?? defaultItem$1;
13754
14129
  const { icon: SelectedItemIcon, label: selectedItemLabel } = selectedItem;
13755
14130
  return /* @__PURE__ */ React.createElement(DropdownMenu, { modal: false, ...openState, ...props }, /* @__PURE__ */ React.createElement(DropdownMenuTrigger, { asChild: true }, /* @__PURE__ */ React.createElement(
@@ -13761,7 +14136,7 @@ var __publicField = (obj, key, value) => {
13761
14136
  tooltip: "Headings"
13762
14137
  },
13763
14138
  /* @__PURE__ */ React.createElement(SelectedItemIcon, { className: "size-5" }),
13764
- /* @__PURE__ */ React.createElement("span", { className: "hidden 2xl:flex" }, selectedItemLabel)
14139
+ /* @__PURE__ */ React.createElement("span", { className: "@md/toolbar:flex hidden" }, selectedItemLabel)
13765
14140
  )), /* @__PURE__ */ React.createElement(DropdownMenuContent, { align: "start", className: "min-w-0" }, /* @__PURE__ */ React.createElement(
13766
14141
  DropdownMenuRadioGroup,
13767
14142
  {
@@ -13773,7 +14148,12 @@ var __publicField = (obj, key, value) => {
13773
14148
  },
13774
14149
  value
13775
14150
  },
13776
- items$1.map(({ icon: Icon, label, value: itemValue }) => /* @__PURE__ */ React.createElement(
14151
+ items$1.filter((item) => {
14152
+ if (userInTable) {
14153
+ return !unsupportedItemsInTable.has(item.label);
14154
+ }
14155
+ return true;
14156
+ }).map(({ icon: Icon, label, value: itemValue }) => /* @__PURE__ */ React.createElement(
13777
14157
  DropdownMenuRadioItem,
13778
14158
  {
13779
14159
  className: "min-w-[180px]",
@@ -13785,42 +14165,6 @@ var __publicField = (obj, key, value) => {
13785
14165
  ))
13786
14166
  )));
13787
14167
  }
13788
- const LinkToolbarButton = cn$1.withRef((rest, ref) => {
13789
- const state = plateLink.useLinkToolbarButtonState();
13790
- const { props } = plateLink.useLinkToolbarButton(state);
13791
- return /* @__PURE__ */ React.createElement(ToolbarButton, { ref, tooltip: "Link", ...props, ...rest }, /* @__PURE__ */ React.createElement(Icons.link, null));
13792
- });
13793
- const useBlockQuoteToolbarButtonState = () => {
13794
- const editor = plateCommon.useEditorState();
13795
- const isBlockActive = () => helpers.isNodeActive(editor, plateBlockQuote.ELEMENT_BLOCKQUOTE);
13796
- return {
13797
- pressed: isBlockActive()
13798
- };
13799
- };
13800
- const useBlockQuoteToolbarButton = (state) => {
13801
- const editor = plateCommon.useEditorState();
13802
- const onClick = () => {
13803
- plateCommon.toggleNodeType(editor, {
13804
- activeType: plateBlockQuote.ELEMENT_BLOCKQUOTE
13805
- });
13806
- };
13807
- const onMouseDown = (e) => {
13808
- e.preventDefault();
13809
- e.stopPropagation();
13810
- };
13811
- return {
13812
- props: {
13813
- onClick,
13814
- onMouseDown,
13815
- pressed: state.pressed
13816
- }
13817
- };
13818
- };
13819
- const QuoteToolbarButton = cn$1.withRef(({ clear, ...rest }, ref) => {
13820
- const state = useBlockQuoteToolbarButtonState();
13821
- const { props } = useBlockQuoteToolbarButton(state);
13822
- return /* @__PURE__ */ React.createElement(ToolbarButton, { ref, tooltip: "Link", ...rest, ...props }, /* @__PURE__ */ React.createElement(Icons.quote, null));
13823
- });
13824
14168
  const useCodeBlockToolbarButtonState = () => {
13825
14169
  const editor = plateCommon.useEditorState();
13826
14170
  const isBlockActive = () => helpers.isNodeActive(editor, plateCodeBlock.ELEMENT_CODE_BLOCK);
@@ -13882,6 +14226,116 @@ var __publicField = (obj, key, value) => {
13882
14226
  const { props } = useImageToolbarButton(state);
13883
14227
  return /* @__PURE__ */ React.createElement(ToolbarButton, { ref, tooltip: "Link", ...rest, ...props }, /* @__PURE__ */ React.createElement(Icons.image, null));
13884
14228
  });
14229
+ const IndentListToolbarButton = cn$1.withRef(({ nodeType = plate.ELEMENT_UL }, ref) => {
14230
+ const editor = plateCommon.useEditorState();
14231
+ const state = plate.useListToolbarButtonState({ nodeType });
14232
+ const { props } = plate.useListToolbarButton(state);
14233
+ return /* @__PURE__ */ React.createElement(
14234
+ ToolbarButton,
14235
+ {
14236
+ ref,
14237
+ tooltip: nodeType === plate.ELEMENT_UL ? "Bulleted List" : "Numbered List",
14238
+ ...props,
14239
+ onClick: (e) => {
14240
+ e.preventDefault();
14241
+ e.stopPropagation();
14242
+ plate.toggleList(editor, { type: nodeType });
14243
+ }
14244
+ },
14245
+ nodeType === plate.ELEMENT_UL ? /* @__PURE__ */ React.createElement(Icons.ul, null) : /* @__PURE__ */ React.createElement(Icons.ol, null)
14246
+ );
14247
+ });
14248
+ const LinkToolbarButton = cn$1.withRef((rest, ref) => {
14249
+ const state = plateLink.useLinkToolbarButtonState();
14250
+ const { props } = plateLink.useLinkToolbarButton(state);
14251
+ return /* @__PURE__ */ React.createElement(ToolbarButton, { ref, tooltip: "Link", ...props, ...rest }, /* @__PURE__ */ React.createElement(Icons.link, null));
14252
+ });
14253
+ const MarkToolbarButton = cn$1.withRef(({ clear, nodeType, ...rest }, ref) => {
14254
+ const state = plateCommon.useMarkToolbarButtonState({ clear, nodeType });
14255
+ const { props } = plateCommon.useMarkToolbarButton(state);
14256
+ return /* @__PURE__ */ React.createElement(ToolbarButton, { ref, ...props, ...rest });
14257
+ });
14258
+ const useMermaidToolbarButtonState = () => {
14259
+ const editor = plateCommon.useEditorState();
14260
+ const isBlockActive = () => helpers.isNodeActive(editor, ELEMENT_MERMAID);
14261
+ return {
14262
+ pressed: isBlockActive()
14263
+ };
14264
+ };
14265
+ const useMermaidToolbarButton = (state) => {
14266
+ const editor = plateCommon.useEditorState();
14267
+ const onClick = () => {
14268
+ plateCommon.insertEmptyElement(editor, ELEMENT_MERMAID, {
14269
+ nextBlock: true,
14270
+ select: true
14271
+ });
14272
+ };
14273
+ const onMouseDown = (e) => {
14274
+ e.preventDefault();
14275
+ e.stopPropagation();
14276
+ };
14277
+ return {
14278
+ props: {
14279
+ onClick,
14280
+ onMouseDown,
14281
+ pressed: state.pressed
14282
+ }
14283
+ };
14284
+ };
14285
+ const MermaidToolbarButton = cn$1.withRef(({ clear, ...rest }, ref) => {
14286
+ const state = useMermaidToolbarButtonState();
14287
+ const { props } = useMermaidToolbarButton(state);
14288
+ return /* @__PURE__ */ React.createElement(ToolbarButton, { ref, tooltip: "Mermaid", ...rest, ...props }, /* @__PURE__ */ React.createElement(Icons.mermaid, null));
14289
+ });
14290
+ function OverflowMenu({
14291
+ children,
14292
+ ...props
14293
+ }) {
14294
+ const openState = useOpenState();
14295
+ return /* @__PURE__ */ React.createElement(DropdownMenu, { modal: false, ...openState, ...props }, /* @__PURE__ */ React.createElement(DropdownMenuTrigger, { asChild: true }, /* @__PURE__ */ React.createElement(
14296
+ ToolbarButton,
14297
+ {
14298
+ showArrow: false,
14299
+ "data-testid": "rich-text-editor-overflow-menu-button",
14300
+ className: "lg:min-w-[130px]",
14301
+ isDropdown: true,
14302
+ pressed: openState.open,
14303
+ tooltip: "Headings"
14304
+ },
14305
+ /* @__PURE__ */ React.createElement(Icons.overflow, { className: "size-5" })
14306
+ )), /* @__PURE__ */ React.createElement(DropdownMenuContent, { align: "start", className: "min-w-0 flex flex-grow" }, children));
14307
+ }
14308
+ const useBlockQuoteToolbarButtonState = () => {
14309
+ const editor = plateCommon.useEditorState();
14310
+ const isBlockActive = () => helpers.isNodeActive(editor, plateBlockQuote.ELEMENT_BLOCKQUOTE);
14311
+ return {
14312
+ pressed: isBlockActive()
14313
+ };
14314
+ };
14315
+ const useBlockQuoteToolbarButton = (state) => {
14316
+ const editor = plateCommon.useEditorState();
14317
+ const onClick = () => {
14318
+ plateCommon.toggleNodeType(editor, {
14319
+ activeType: plateBlockQuote.ELEMENT_BLOCKQUOTE
14320
+ });
14321
+ };
14322
+ const onMouseDown = (e) => {
14323
+ e.preventDefault();
14324
+ e.stopPropagation();
14325
+ };
14326
+ return {
14327
+ props: {
14328
+ onClick,
14329
+ onMouseDown,
14330
+ pressed: state.pressed
14331
+ }
14332
+ };
14333
+ };
14334
+ const QuoteToolbarButton = cn$1.withRef(({ clear, ...rest }, ref) => {
14335
+ const state = useBlockQuoteToolbarButtonState();
14336
+ const { props } = useBlockQuoteToolbarButton(state);
14337
+ return /* @__PURE__ */ React.createElement(ToolbarButton, { ref, tooltip: "Link", ...rest, ...props }, /* @__PURE__ */ React.createElement(Icons.quote, null));
14338
+ });
13885
14339
  const useRawMarkdownToolbarButton = () => {
13886
14340
  const { setRawMode } = useEditorContext();
13887
14341
  const onMouseDown = (e) => {
@@ -13896,31 +14350,123 @@ var __publicField = (obj, key, value) => {
13896
14350
  };
13897
14351
  const RawMarkdownToolbarButton = cn$1.withRef(({ clear, ...rest }, ref) => {
13898
14352
  const { props } = useRawMarkdownToolbarButton();
13899
- return /* @__PURE__ */ React.createElement(ToolbarButton, { ref, tooltip: "Link", ...rest, ...props }, /* @__PURE__ */ React.createElement(Icons.raw, null));
14353
+ return /* @__PURE__ */ React.createElement(
14354
+ ToolbarButton,
14355
+ {
14356
+ ref,
14357
+ tooltip: "Link",
14358
+ ...rest,
14359
+ ...props,
14360
+ "data-testid": "markdown-button"
14361
+ },
14362
+ /* @__PURE__ */ React.createElement(Icons.raw, null)
14363
+ );
13900
14364
  });
13901
- const ToolbarContext = React.createContext(void 0);
13902
- const ToolbarProvider = ({
13903
- tinaForm,
13904
- templates,
13905
- overrides,
13906
- children
13907
- }) => {
13908
- return /* @__PURE__ */ React.createElement(ToolbarContext.Provider, { value: { tinaForm, templates, overrides } }, children);
13909
- };
13910
- const useToolbarContext = () => {
13911
- const context = React.useContext(ToolbarContext);
13912
- if (!context) {
13913
- throw new Error("useToolbarContext must be used within a ToolbarProvider");
13914
- }
13915
- return context;
13916
- };
14365
+ function TableDropdownMenu(props) {
14366
+ const tableSelected = plateCommon.useEditorSelector(
14367
+ (editor2) => plateCommon.someNode(editor2, { match: { type: plateTable.ELEMENT_TABLE } }),
14368
+ []
14369
+ );
14370
+ const [enableDeleteColumn, enableDeleteRow] = plateCommon.useEditorSelector((editor2) => {
14371
+ const tableNodeEntry = plateCommon.findNode(editor2, { match: { type: plateTable.ELEMENT_TABLE } });
14372
+ if (!tableNodeEntry)
14373
+ return [false, false];
14374
+ const [tableNode] = tableNodeEntry;
14375
+ if (!plateCommon.isElement(tableNode))
14376
+ return [false, false];
14377
+ const columnCount = plateTable.getTableColumnCount(tableNode);
14378
+ const rowCount = tableNode.children.length;
14379
+ return [columnCount > 1, rowCount > 1];
14380
+ }, []);
14381
+ const editor = plateCommon.useEditorRef();
14382
+ const openState = useOpenState();
14383
+ 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(
14384
+ DropdownMenuContent,
14385
+ {
14386
+ align: "start",
14387
+ className: "flex w-[180px] min-w-0 flex-col gap-0.5"
14388
+ },
14389
+ /* @__PURE__ */ React.createElement(
14390
+ DropdownMenuItem,
14391
+ {
14392
+ className: "min-w-[180px]",
14393
+ disabled: tableSelected,
14394
+ onSelect: () => {
14395
+ plateTable.insertTable(editor);
14396
+ plateCommon.focusEditor(editor);
14397
+ }
14398
+ },
14399
+ /* @__PURE__ */ React.createElement(Icons.add, { className: iconVariants({ variant: "menuItem" }) }),
14400
+ "Insert table"
14401
+ ),
14402
+ /* @__PURE__ */ React.createElement(
14403
+ DropdownMenuItem,
14404
+ {
14405
+ className: "min-w-[180px]",
14406
+ disabled: !tableSelected,
14407
+ onSelect: () => {
14408
+ plateTable.deleteTable(editor);
14409
+ plateCommon.focusEditor(editor);
14410
+ }
14411
+ },
14412
+ /* @__PURE__ */ React.createElement(Icons.minus, { className: iconVariants({ variant: "menuItem" }) }),
14413
+ "Delete table"
14414
+ ),
14415
+ /* @__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(
14416
+ DropdownMenuItem,
14417
+ {
14418
+ className: "min-w-[180px]",
14419
+ disabled: !tableSelected,
14420
+ onSelect: () => {
14421
+ plateTable.insertTableColumn(editor);
14422
+ plateCommon.focusEditor(editor);
14423
+ }
14424
+ },
14425
+ /* @__PURE__ */ React.createElement(Icons.add, { className: iconVariants({ variant: "menuItem" }) }),
14426
+ "Insert column after"
14427
+ ), /* @__PURE__ */ React.createElement(
14428
+ DropdownMenuItem,
14429
+ {
14430
+ className: "min-w-[180px]",
14431
+ disabled: !enableDeleteColumn,
14432
+ onSelect: () => {
14433
+ plateTable.deleteColumn(editor);
14434
+ plateCommon.focusEditor(editor);
14435
+ }
14436
+ },
14437
+ /* @__PURE__ */ React.createElement(Icons.minus, { className: iconVariants({ variant: "menuItem" }) }),
14438
+ "Delete column"
14439
+ ))),
14440
+ /* @__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(
14441
+ DropdownMenuItem,
14442
+ {
14443
+ className: "min-w-[180px]",
14444
+ disabled: !tableSelected,
14445
+ onSelect: () => {
14446
+ plateTable.insertTableRow(editor);
14447
+ plateCommon.focusEditor(editor);
14448
+ }
14449
+ },
14450
+ /* @__PURE__ */ React.createElement(Icons.add, { className: iconVariants({ variant: "menuItem" }) }),
14451
+ "Insert row after"
14452
+ ), /* @__PURE__ */ React.createElement(
14453
+ DropdownMenuItem,
14454
+ {
14455
+ className: "min-w-[180px]",
14456
+ disabled: !enableDeleteRow,
14457
+ onSelect: () => {
14458
+ plateTable.deleteRow(editor);
14459
+ plateCommon.focusEditor(editor);
14460
+ }
14461
+ },
14462
+ /* @__PURE__ */ React.createElement(Icons.minus, { className: iconVariants({ variant: "menuItem" }) }),
14463
+ "Delete row"
14464
+ )))
14465
+ ));
14466
+ }
13917
14467
  function TemplatesToolbarButton() {
13918
14468
  const { templates } = useToolbarContext();
13919
- const showEmbed = templates.length > 0;
13920
14469
  const editor = plateCommon.useEditorState();
13921
- if (!showEmbed) {
13922
- return null;
13923
- }
13924
14470
  return /* @__PURE__ */ React.createElement(EmbedButton, { templates, editor });
13925
14471
  }
13926
14472
  const EmbedButton = ({ editor, templates }) => {
@@ -13961,99 +14507,118 @@ var __publicField = (obj, key, value) => {
13961
14507
  template.label || template.name
13962
14508
  ))));
13963
14509
  };
13964
- const ICON_WIDTH = 32;
13965
- const EMBED_ICON_WIDTH = 78;
13966
- const useResize = (ref, callback) => {
13967
- React.useEffect(() => {
13968
- const resizeObserver = new ResizeObserver((entries) => {
13969
- for (const entry of entries) {
13970
- callback(entry);
13971
- }
13972
- });
13973
- if (ref.current) {
13974
- resizeObserver.observe(ref.current);
13975
- }
13976
- return () => resizeObserver.disconnect();
13977
- }, [ref.current]);
13978
- };
13979
- function OverflowMenu({
13980
- children,
13981
- ...props
13982
- }) {
13983
- const openState = useOpenState();
13984
- return /* @__PURE__ */ React.createElement(DropdownMenu, { modal: false, ...openState, ...props }, /* @__PURE__ */ React.createElement(DropdownMenuTrigger, { asChild: true }, /* @__PURE__ */ React.createElement(
13985
- ToolbarButton,
13986
- {
13987
- showArrow: false,
13988
- className: "lg:min-w-[130px]",
13989
- isDropdown: true,
13990
- pressed: openState.open,
13991
- tooltip: "Headings"
13992
- },
13993
- /* @__PURE__ */ React.createElement(Icons.overflow, { className: "size-5" })
13994
- )), /* @__PURE__ */ React.createElement(DropdownMenuContent, { align: "start", className: "min-w-0 flex flex-grow" }, children));
13995
- }
13996
14510
  const toolbarItems = {
13997
14511
  heading: {
13998
- label: "Headings",
14512
+ label: HEADING_LABEL,
14513
+ width: (paragraphIconExists) => paragraphIconExists ? HEADING_ICON_WITH_TEXT : HEADING_ICON_ONLY,
14514
+ // Dynamically handle width based on paragraph icon
13999
14515
  Component: /* @__PURE__ */ React.createElement(ToolbarGroup, { noSeparator: true }, /* @__PURE__ */ React.createElement(HeadingsMenu, null))
14000
14516
  },
14001
14517
  link: {
14002
14518
  label: "Link",
14519
+ width: () => STANDARD_ICON_WIDTH,
14003
14520
  Component: /* @__PURE__ */ React.createElement(LinkToolbarButton, null)
14004
14521
  },
14005
14522
  image: {
14006
14523
  label: "Image",
14524
+ width: () => STANDARD_ICON_WIDTH,
14007
14525
  Component: /* @__PURE__ */ React.createElement(ImageToolbarButton, null)
14008
14526
  },
14009
14527
  quote: {
14010
14528
  label: "Quote",
14529
+ width: () => STANDARD_ICON_WIDTH,
14011
14530
  Component: /* @__PURE__ */ React.createElement(QuoteToolbarButton, { tooltip: "Quote Quote (⌘+⇧+.)" })
14012
14531
  },
14013
14532
  ul: {
14014
14533
  label: "Unordered List",
14534
+ width: () => STANDARD_ICON_WIDTH,
14015
14535
  Component: /* @__PURE__ */ React.createElement(IndentListToolbarButton, { nodeType: plate.ELEMENT_UL })
14016
14536
  },
14017
14537
  ol: {
14018
14538
  label: "Ordered List",
14539
+ width: () => STANDARD_ICON_WIDTH,
14019
14540
  Component: /* @__PURE__ */ React.createElement(IndentListToolbarButton, { nodeType: plate.ELEMENT_OL })
14020
14541
  },
14021
14542
  bold: {
14022
14543
  label: "Bold",
14544
+ width: () => STANDARD_ICON_WIDTH,
14023
14545
  Component: /* @__PURE__ */ React.createElement(MarkToolbarButton, { tooltip: "Bold (⌘+B)", nodeType: plate.MARK_BOLD }, /* @__PURE__ */ React.createElement(Icons.bold, null))
14024
14546
  },
14025
14547
  italic: {
14026
14548
  label: "Italic",
14549
+ width: () => STANDARD_ICON_WIDTH,
14027
14550
  Component: /* @__PURE__ */ React.createElement(MarkToolbarButton, { tooltip: "Italic (⌘+I)", nodeType: plate.MARK_ITALIC }, /* @__PURE__ */ React.createElement(Icons.italic, null))
14028
14551
  },
14029
14552
  code: {
14030
14553
  label: "Code",
14554
+ width: () => STANDARD_ICON_WIDTH,
14031
14555
  Component: /* @__PURE__ */ React.createElement(MarkToolbarButton, { tooltip: "Code (⌘+E)", nodeType: plate.MARK_CODE }, /* @__PURE__ */ React.createElement(Icons.code, null))
14032
14556
  },
14033
14557
  codeBlock: {
14034
14558
  label: "Code Block",
14559
+ width: () => STANDARD_ICON_WIDTH,
14035
14560
  Component: /* @__PURE__ */ React.createElement(CodeBlockToolbarButton, null)
14036
14561
  },
14562
+ mermaid: {
14563
+ label: "Mermaid",
14564
+ width: () => STANDARD_ICON_WIDTH,
14565
+ Component: /* @__PURE__ */ React.createElement(MermaidToolbarButton, null)
14566
+ },
14567
+ table: {
14568
+ label: "Table",
14569
+ width: () => STANDARD_ICON_WIDTH,
14570
+ Component: /* @__PURE__ */ React.createElement(TableDropdownMenu, null)
14571
+ },
14037
14572
  raw: {
14038
14573
  label: "Raw Markdown",
14574
+ width: () => STANDARD_ICON_WIDTH,
14039
14575
  Component: /* @__PURE__ */ React.createElement(RawMarkdownToolbarButton, null)
14040
14576
  },
14041
14577
  embed: {
14042
14578
  label: "Templates",
14579
+ width: () => EMBED_ICON_WIDTH,
14043
14580
  Component: /* @__PURE__ */ React.createElement(TemplatesToolbarButton, null)
14044
14581
  }
14045
14582
  };
14046
14583
  function FixedToolbarButtons() {
14047
14584
  const toolbarRef = React.useRef(null);
14048
14585
  const [itemsShown, setItemsShown] = React.useState(11);
14049
- const { overrides } = useToolbarContext();
14586
+ const { overrides, templates } = useToolbarContext();
14587
+ const showEmbedButton = templates.length > 0;
14588
+ let items2 = [];
14589
+ if (Array.isArray(overrides)) {
14590
+ items2 = overrides === void 0 ? Object.values(toolbarItems) : overrides.map((item) => toolbarItems[item]).filter((item) => item !== void 0);
14591
+ } else {
14592
+ items2 = (overrides == null ? void 0 : overrides.toolbar) === void 0 ? Object.values(toolbarItems) : overrides.toolbar.map((item) => toolbarItems[item]).filter((item) => item !== void 0);
14593
+ }
14594
+ if (!showEmbedButton) {
14595
+ items2 = items2.filter((item) => item.label !== toolbarItems.embed.label);
14596
+ }
14597
+ const editorState = plateCommon.useEditorState();
14598
+ const userInTable = helpers.isNodeActive(editorState, plate.ELEMENT_TABLE);
14599
+ if (userInTable) {
14600
+ items2 = items2.filter((item) => !unsupportedItemsInTable.has(item.label));
14601
+ }
14050
14602
  useResize(toolbarRef, (entry) => {
14051
14603
  const width = entry.target.getBoundingClientRect().width;
14052
- const itemsShown2 = (width - EMBED_ICON_WIDTH) / ICON_WIDTH;
14053
- setItemsShown(Math.floor(itemsShown2));
14604
+ const headingButton = items2.find((item) => item.label === HEADING_LABEL);
14605
+ const headingWidth = headingButton ? headingButton.width(width > CONTAINER_MD_BREAKPOINT) : 0;
14606
+ const availableWidth = width - headingWidth - FLOAT_BUTTON_WIDTH;
14607
+ const { itemFitCount } = items2.reduce(
14608
+ (acc, item) => {
14609
+ if (item.label !== HEADING_LABEL && acc.totalItemsWidth + item.width() <= availableWidth) {
14610
+ return {
14611
+ totalItemsWidth: acc.totalItemsWidth + item.width(),
14612
+ itemFitCount: acc.itemFitCount + 1
14613
+ };
14614
+ }
14615
+ return acc;
14616
+ },
14617
+ { totalItemsWidth: 0, itemFitCount: 1 }
14618
+ );
14619
+ setItemsShown(itemFitCount);
14054
14620
  });
14055
- const toolbarItemsArray = overrides === void 0 ? Object.values(toolbarItems) : overrides.map((item) => toolbarItems[item]).filter((item) => item !== void 0);
14056
- return /* @__PURE__ */ React.createElement("div", { className: "w-full overflow-hidden", ref: toolbarRef }, /* @__PURE__ */ React.createElement(
14621
+ return /* @__PURE__ */ React.createElement("div", { className: "w-full overflow-hidden @container/toolbar", ref: toolbarRef }, /* @__PURE__ */ React.createElement(
14057
14622
  "div",
14058
14623
  {
14059
14624
  className: "flex",
@@ -14061,7 +14626,7 @@ var __publicField = (obj, key, value) => {
14061
14626
  transform: "translateX(calc(-1px))"
14062
14627
  }
14063
14628
  },
14064
- /* @__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))))
14629
+ /* @__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))))
14065
14630
  ));
14066
14631
  }
14067
14632
  const FloatingToolbar = cn$1.withRef(({ children, state, ...props }, componentRef) => {
@@ -14176,6 +14741,10 @@ var __publicField = (obj, key, value) => {
14176
14741
  const openState = useOpenState();
14177
14742
  const selectedItem = items.find((item) => item.value === value) ?? defaultItem;
14178
14743
  const { icon: SelectedItemIcon, label: selectedItemLabel } = selectedItem;
14744
+ const editorState = plateCommon.useEditorState();
14745
+ const userInTable = helpers.isNodeActive(editorState, plateTable.ELEMENT_TABLE);
14746
+ if (userInTable)
14747
+ return null;
14179
14748
  return /* @__PURE__ */ React.createElement(DropdownMenu, { modal: false, ...openState, ...props }, /* @__PURE__ */ React.createElement(DropdownMenuTrigger, { asChild: true }, /* @__PURE__ */ React.createElement(
14180
14749
  ToolbarButton,
14181
14750
  {
@@ -14217,49 +14786,6 @@ var __publicField = (obj, key, value) => {
14217
14786
  function FloatingToolbarButtons() {
14218
14787
  return /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(TurnIntoDropdownMenu, null));
14219
14788
  }
14220
- const buttonVariants = classVarianceAuthority.cva(
14221
- "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",
14222
- {
14223
- defaultVariants: {
14224
- size: "default",
14225
- variant: "default"
14226
- },
14227
- variants: {
14228
- isMenu: {
14229
- true: "h-auto w-full cursor-pointer justify-start"
14230
- },
14231
- size: {
14232
- default: "h-10 px-4 py-2",
14233
- icon: "size-10",
14234
- lg: "h-11 rounded-md px-8",
14235
- none: "",
14236
- sm: "h-9 rounded-md px-3",
14237
- sms: "size-9 rounded-md px-0",
14238
- xs: "h-8 rounded-md px-3"
14239
- },
14240
- variant: {
14241
- default: "bg-primary text-primary-foreground hover:bg-primary/90",
14242
- destructive: "bg-destructive text-destructive-foreground hover:bg-destructive/90",
14243
- ghost: "hover:bg-accent hover:text-accent-foreground",
14244
- inlineLink: "text-base text-primary underline underline-offset-4",
14245
- link: "text-primary underline-offset-4 hover:underline",
14246
- outline: "border border-input bg-background hover:bg-accent hover:text-accent-foreground",
14247
- secondary: "bg-secondary text-secondary-foreground hover:bg-secondary/80"
14248
- }
14249
- }
14250
- }
14251
- );
14252
- cn$1.withRef(({ asChild = false, className, isMenu, size, variant, ...props }, ref) => {
14253
- const Comp = asChild ? reactSlot.Slot : "button";
14254
- return /* @__PURE__ */ React__namespace.createElement(
14255
- Comp,
14256
- {
14257
- className: cn$1.cn(buttonVariants({ className, isMenu, size, variant })),
14258
- ref,
14259
- ...props
14260
- }
14261
- );
14262
- });
14263
14789
  const inputVariants = classVarianceAuthority.cva(
14264
14790
  "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",
14265
14791
  {
@@ -14280,22 +14806,6 @@ var __publicField = (obj, key, value) => {
14280
14806
  }
14281
14807
  );
14282
14808
  cn$1.withVariants("input", inputVariants, ["variant", "h"]);
14283
- const popoverVariants = classVarianceAuthority.cva(
14284
- "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"
14285
- );
14286
- cn$1.withRef(
14287
- ({ align = "center", className, sideOffset = 4, style, ...props }, ref) => /* @__PURE__ */ React__namespace.createElement(PopoverPrimitive__namespace.Portal, null, /* @__PURE__ */ React__namespace.createElement(
14288
- PopoverPrimitive__namespace.Content,
14289
- {
14290
- align,
14291
- className: cn$1.cn(popoverVariants(), className),
14292
- ref,
14293
- sideOffset,
14294
- style: { zIndex: 1e3, ...style },
14295
- ...props
14296
- }
14297
- ))
14298
- );
14299
14809
  const floatingOptions = {
14300
14810
  middleware: [
14301
14811
  plateFloating.offset(12),
@@ -14355,7 +14865,7 @@ var __publicField = (obj, key, value) => {
14355
14865
  const editContent = editState.isEditing ? input : /* @__PURE__ */ React.createElement("div", { className: "box-content flex h-9 items-center gap-1" }, /* @__PURE__ */ React.createElement(
14356
14866
  "button",
14357
14867
  {
14358
- className: buttonVariants({ size: "sm", variant: "ghost" }),
14868
+ className: buttonVariants$1({ size: "sm", variant: "ghost" }),
14359
14869
  type: "button",
14360
14870
  ...editButtonProps
14361
14871
  },
@@ -14363,7 +14873,7 @@ var __publicField = (obj, key, value) => {
14363
14873
  ), /* @__PURE__ */ React.createElement(Separator, { orientation: "vertical" }), /* @__PURE__ */ React.createElement(
14364
14874
  plateLink.LinkOpenButton,
14365
14875
  {
14366
- className: buttonVariants({
14876
+ className: buttonVariants$1({
14367
14877
  size: "sms",
14368
14878
  variant: "ghost"
14369
14879
  })
@@ -14372,7 +14882,7 @@ var __publicField = (obj, key, value) => {
14372
14882
  ), /* @__PURE__ */ React.createElement(Separator, { orientation: "vertical" }), /* @__PURE__ */ React.createElement(
14373
14883
  "button",
14374
14884
  {
14375
- className: buttonVariants({
14885
+ className: buttonVariants$1({
14376
14886
  size: "sms",
14377
14887
  variant: "ghost"
14378
14888
  }),
@@ -14408,6 +14918,9 @@ var __publicField = (obj, key, value) => {
14408
14918
  if (typeof string !== "string") {
14409
14919
  return false;
14410
14920
  }
14921
+ if (string.startsWith("#")) {
14922
+ return true;
14923
+ }
14411
14924
  const generalMatch = string.match(protocolAndDomainRE);
14412
14925
  const emailLinkMatch = string.match(emailLintRE);
14413
14926
  const localUrlMatch = string.match(localUrlRE);
@@ -14429,12 +14942,12 @@ var __publicField = (obj, key, value) => {
14429
14942
  }
14430
14943
  return localhostDomainRE.test(everythingAfterProtocol) || nonLocalhostDomainRE.test(everythingAfterProtocol);
14431
14944
  };
14432
- const RichEditor = (props) => {
14945
+ const RichEditor = ({ input, tinaForm, field }) => {
14433
14946
  var _a;
14434
14947
  const initialValue = React.useMemo(
14435
14948
  () => {
14436
14949
  var _a2, _b;
14437
- 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: "" }] }];
14950
+ 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: "" }] }];
14438
14951
  },
14439
14952
  []
14440
14953
  );
@@ -14446,6 +14959,7 @@ var __publicField = (obj, key, value) => {
14446
14959
  createMdxBlockPlugin(),
14447
14960
  createMdxInlinePlugin(),
14448
14961
  createImgPlugin(),
14962
+ createMermaidPlugin(),
14449
14963
  createInvalidMarkdownPlugin(),
14450
14964
  plateLink.createLinkPlugin({
14451
14965
  options: {
@@ -14461,7 +14975,7 @@ var __publicField = (obj, key, value) => {
14461
14975
  ),
14462
14976
  []
14463
14977
  );
14464
- const tempId = [props.tinaForm.id, props.input.name].join(".");
14978
+ const tempId = [tinaForm.id, input.name].join(".");
14465
14979
  const id = React.useMemo(() => uuid() + tempId, [tempId]);
14466
14980
  const ref = React.useRef(null);
14467
14981
  React.useEffect(() => {
@@ -14471,13 +14985,13 @@ var __publicField = (obj, key, value) => {
14471
14985
  const plateElement = (_a2 = ref.current) == null ? void 0 : _a2.querySelector(
14472
14986
  '[role="textbox"]'
14473
14987
  );
14474
- if (props.field.experimental_focusIntent && plateElement) {
14988
+ if (field.experimental_focusIntent && plateElement) {
14475
14989
  if (plateElement)
14476
14990
  plateElement.focus();
14477
14991
  }
14478
14992
  }, 100);
14479
14993
  }
14480
- }, [props.field.experimental_focusIntent, ref]);
14994
+ }, [field.experimental_focusIntent, ref]);
14481
14995
  return /* @__PURE__ */ React.createElement("div", { ref }, /* @__PURE__ */ React.createElement(
14482
14996
  plateCommon.Plate,
14483
14997
  {
@@ -14485,21 +14999,22 @@ var __publicField = (obj, key, value) => {
14485
14999
  initialValue,
14486
15000
  plugins: plugins$2,
14487
15001
  onChange: (value) => {
14488
- props.input.onChange({
15002
+ input.onChange({
14489
15003
  type: "root",
14490
- children: value
15004
+ children: value,
15005
+ embedCode: input.value.embedCode
14491
15006
  });
14492
15007
  }
14493
15008
  },
14494
15009
  /* @__PURE__ */ React.createElement(TooltipProvider, null, /* @__PURE__ */ React.createElement(
14495
15010
  ToolbarProvider,
14496
15011
  {
14497
- tinaForm: props.tinaForm,
14498
- templates: props.field.templates,
14499
- overrides: (_a = props.field) == null ? void 0 : _a.toolbarOverride
15012
+ tinaForm,
15013
+ templates: field.templates,
15014
+ overrides: (field == null ? void 0 : field.toolbarOverride) ? field.toolbarOverride : field.overrides
14500
15015
  },
14501
15016
  /* @__PURE__ */ React.createElement(FixedToolbar, null, /* @__PURE__ */ React.createElement(FixedToolbarButtons, null)),
14502
- /* @__PURE__ */ React.createElement(FloatingToolbar, null, /* @__PURE__ */ React.createElement(FloatingToolbarButtons, null))
15017
+ ((_a = field == null ? void 0 : field.overrides) == null ? void 0 : _a.showFloatingToolbar) !== false ? /* @__PURE__ */ React.createElement(FloatingToolbar, null, /* @__PURE__ */ React.createElement(FloatingToolbarButtons, null)) : null
14503
15018
  ), /* @__PURE__ */ React.createElement(Editor, null))
14504
15019
  ));
14505
15020
  };
@@ -29453,6 +29968,7 @@ mutation addPendingDocumentMutation(
29453
29968
  relativePath
29454
29969
  filename
29455
29970
  extension
29971
+ hasReferences
29456
29972
  }
29457
29973
  }
29458
29974
  }
@@ -29544,6 +30060,9 @@ mutation addPendingDocumentMutation(
29544
30060
  document(collection:$collection, relativePath:$relativePath) {
29545
30061
  ... on Document {
29546
30062
  _values
30063
+ _sys {
30064
+ hasReferences
30065
+ }
29547
30066
  }
29548
30067
  }
29549
30068
  }`;
@@ -30568,8 +31087,8 @@ This will work when developing locally but NOT when deployed to production.
30568
31087
  }
30569
31088
  )
30570
31089
  }
30571
- ), !renderDesktopNav && /* @__PURE__ */ React.createElement(react$1.Transition, { show: menuIsOpen }, /* @__PURE__ */ React.createElement(
30572
- react$1.TransitionChild,
31090
+ ), !renderDesktopNav && /* @__PURE__ */ React.createElement(react.Transition, { show: menuIsOpen }, /* @__PURE__ */ React.createElement(
31091
+ react.TransitionChild,
30573
31092
  {
30574
31093
  enter: "transform transition-all ease-out duration-300",
30575
31094
  enterFrom: "opacity-0 -translate-x-full",
@@ -30638,7 +31157,7 @@ This will work when developing locally but NOT when deployed to production.
30638
31157
  ))
30639
31158
  ))
30640
31159
  ), /* @__PURE__ */ React.createElement(
30641
- react$1.TransitionChild,
31160
+ react.TransitionChild,
30642
31161
  {
30643
31162
  enter: "ease-out duration-300",
30644
31163
  enterFrom: "opacity-0",
@@ -31092,8 +31611,8 @@ This will work when developing locally but NOT when deployed to production.
31092
31611
  folder,
31093
31612
  collectionName
31094
31613
  }) => {
31095
- 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(
31096
- react$1.Transition,
31614
+ 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(
31615
+ react.Transition,
31097
31616
  {
31098
31617
  enter: "transition ease-out duration-100",
31099
31618
  enterFrom: "transform opacity-0 scale-95",
@@ -31102,7 +31621,7 @@ This will work when developing locally but NOT when deployed to production.
31102
31621
  leaveFrom: "transform opacity-100 scale-100",
31103
31622
  leaveTo: "transform opacity-0 scale-95"
31104
31623
  },
31105
- /* @__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(
31624
+ /* @__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(
31106
31625
  reactRouterDom.Link,
31107
31626
  {
31108
31627
  to: `/${folder.fullyQualifiedName ? [
@@ -31270,6 +31789,23 @@ This will work when developing locally but NOT when deployed to production.
31270
31789
  DeleteModal,
31271
31790
  {
31272
31791
  filename: vars.relativePath,
31792
+ checkRefsFunc: async () => {
31793
+ var _a2, _b2;
31794
+ try {
31795
+ const doc = await admin.fetchDocument(
31796
+ collection.name,
31797
+ vars.relativePath,
31798
+ true
31799
+ );
31800
+ return (_b2 = (_a2 = doc == null ? void 0 : doc.document) == null ? void 0 : _a2._sys) == null ? void 0 : _b2.hasReferences;
31801
+ } catch (error) {
31802
+ cms.alerts.error(
31803
+ "Document was not found, ask a developer for help or check the console for an error message"
31804
+ );
31805
+ console.error(error);
31806
+ throw error;
31807
+ }
31808
+ },
31273
31809
  deleteFunc: async () => {
31274
31810
  try {
31275
31811
  await admin.deleteDocument(vars);
@@ -31278,6 +31814,12 @@ This will work when developing locally but NOT when deployed to production.
31278
31814
  );
31279
31815
  reFetchCollection();
31280
31816
  } catch (error) {
31817
+ if (error.message.indexOf("has references")) {
31818
+ cms.alerts.error(
31819
+ error.message.split("\n ").filter(Boolean)[1]
31820
+ );
31821
+ return;
31822
+ }
31281
31823
  cms.alerts.warn(
31282
31824
  "Document was not deleted, ask a developer for help or check the console for an error message"
31283
31825
  );
@@ -31329,6 +31871,12 @@ This will work when developing locally but NOT when deployed to production.
31329
31871
  cms.alerts.info("Document was successfully renamed");
31330
31872
  reFetchCollection();
31331
31873
  } catch (error) {
31874
+ if (error.message.indexOf("has references")) {
31875
+ cms.alerts.error(
31876
+ error.message.split("\n ").filter(Boolean)[1]
31877
+ );
31878
+ return;
31879
+ }
31332
31880
  cms.alerts.warn(
31333
31881
  "Document was not renamed, ask a developer for help or check the console for an error message"
31334
31882
  );
@@ -31802,8 +32350,19 @@ This will work when developing locally but NOT when deployed to production.
31802
32350
  const NoDocumentsPlaceholder = () => {
31803
32351
  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."));
31804
32352
  };
31805
- const DeleteModal = ({ close: close2, deleteFunc, filename }) => {
31806
- 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(
32353
+ const DeleteModal = ({
32354
+ close: close2,
32355
+ deleteFunc,
32356
+ checkRefsFunc,
32357
+ filename
32358
+ }) => {
32359
+ const [hasRefs, setHasRefs] = React.useState();
32360
+ React.useEffect(() => {
32361
+ checkRefsFunc().then((result) => {
32362
+ setHasRefs(result);
32363
+ });
32364
+ }, [filename, checkRefsFunc]);
32365
+ 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(
31807
32366
  Button$1,
31808
32367
  {
31809
32368
  style: { flexGrow: 3 },
@@ -33170,6 +33729,7 @@ This will work when developing locally but NOT when deployed to production.
33170
33729
  exports2.useScreenPlugin = useScreenPlugin;
33171
33730
  exports2.useTinaAuthRedirect = useTinaAuthRedirect;
33172
33731
  exports2.wrapFieldWithError = wrapFieldWithError;
33732
+ exports2.wrapFieldWithNoHeader = wrapFieldWithNoHeader;
33173
33733
  exports2.wrapFieldsWithMeta = wrapFieldsWithMeta;
33174
33734
  Object.defineProperties(exports2, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
33175
33735
  });