tinacms 0.0.0-c5dad82-20241009225242 → 0.0.0-c72bb45-20241118014046
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/admin/types.d.ts +3 -0
- package/dist/cache/node-cache.d.ts +1 -0
- package/dist/client.js +18 -16
- package/dist/client.mjs +1 -1
- package/dist/index.js +1287 -1010
- package/dist/index.mjs +1262 -984
- package/dist/{node-cache-7fa2452c.mjs → node-cache-4c336858.mjs} +18 -11
- package/dist/rich-text/index.d.ts +3 -0
- package/dist/rich-text/index.js +3 -1
- package/dist/rich-text/index.mjs +3 -1
- package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/components/fixed-toolbar-buttons.d.ts +0 -4
- package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/components/plate-ui/icons.d.ts +2 -0
- package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/components/plate-ui/mermaid-element.d.ts +11 -0
- package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/components/plate-ui/mermaid-toolbar-button.d.ts +20 -0
- package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/components/plate-ui/text-area.d.ts +5 -0
- package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/plugins/custom/mermaid-plugin.d.ts +2 -0
- package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/plugins/ui/code-block/index.d.ts +4 -2
- package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/plugins/ui/components.d.ts +10 -0
- package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/toolbar/toolbar-overrides.d.ts +7 -3
- package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/toolbar/toolbar-provider.d.ts +1 -1
- package/dist/toolkit/fields/plugins/wrap-field-with-meta.d.ts +8 -0
- package/package.json +29 -25
- 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("
|
|
3
|
-
})(this, function(exports2, zod, React, reactDom, plate,
|
|
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) => {
|
|
@@ -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(
|
|
@@ -850,9 +866,9 @@ var __publicField = (obj, key, value) => {
|
|
|
850
866
|
"span",
|
|
851
867
|
{
|
|
852
868
|
className: `block font-sans text-xs italic font-light text-gray-400 pt-0.5 whitespace-normal m-0 ${className}`,
|
|
853
|
-
...props
|
|
854
|
-
|
|
855
|
-
|
|
869
|
+
...props,
|
|
870
|
+
dangerouslySetInnerHTML: { __html: children }
|
|
871
|
+
}
|
|
856
872
|
);
|
|
857
873
|
};
|
|
858
874
|
const FieldError = ({
|
|
@@ -882,6 +898,20 @@ var __publicField = (obj, key, value) => {
|
|
|
882
898
|
const useTemplates = () => {
|
|
883
899
|
return React.useContext(EditorContext);
|
|
884
900
|
};
|
|
901
|
+
const BlockquoteElement = cn$1.withRef(
|
|
902
|
+
({ children, className, ...props }, ref) => {
|
|
903
|
+
return /* @__PURE__ */ React.createElement(
|
|
904
|
+
plateCommon.PlateElement,
|
|
905
|
+
{
|
|
906
|
+
asChild: true,
|
|
907
|
+
className: cn$1.cn("my-1 border-l-2 pl-6 italic", className),
|
|
908
|
+
ref,
|
|
909
|
+
...props
|
|
910
|
+
},
|
|
911
|
+
/* @__PURE__ */ React.createElement("blockquote", null, children)
|
|
912
|
+
);
|
|
913
|
+
}
|
|
914
|
+
);
|
|
885
915
|
function classNames$1(...classes) {
|
|
886
916
|
return classes.filter(Boolean).join(" ");
|
|
887
917
|
}
|
|
@@ -891,6 +921,503 @@ var __publicField = (obj, key, value) => {
|
|
|
891
921
|
(c) => (c ^ crypto.getRandomValues(new Uint8Array(1))[0] & 15 >> c / 4).toString(16)
|
|
892
922
|
);
|
|
893
923
|
};
|
|
924
|
+
function ChevronDownIcon(props, svgRef) {
|
|
925
|
+
return /* @__PURE__ */ React__namespace.createElement("svg", Object.assign({
|
|
926
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
927
|
+
viewBox: "0 0 20 20",
|
|
928
|
+
fill: "currentColor",
|
|
929
|
+
"aria-hidden": "true",
|
|
930
|
+
ref: svgRef
|
|
931
|
+
}, props), /* @__PURE__ */ React__namespace.createElement("path", {
|
|
932
|
+
fillRule: "evenodd",
|
|
933
|
+
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",
|
|
934
|
+
clipRule: "evenodd"
|
|
935
|
+
}));
|
|
936
|
+
}
|
|
937
|
+
const ForwardRef = React__namespace.forwardRef(ChevronDownIcon);
|
|
938
|
+
const ChevronDownIcon$1 = ForwardRef;
|
|
939
|
+
const Autocomplete = ({
|
|
940
|
+
value,
|
|
941
|
+
onChange,
|
|
942
|
+
defaultQuery,
|
|
943
|
+
items: items2
|
|
944
|
+
}) => {
|
|
945
|
+
const [query, setQuery] = React.useState(defaultQuery ?? "");
|
|
946
|
+
const filteredItems = React.useMemo(() => {
|
|
947
|
+
try {
|
|
948
|
+
const reFilter = new RegExp(query, "i");
|
|
949
|
+
const _items = items2.filter((item) => reFilter.test(item.label));
|
|
950
|
+
if (_items.length === 0)
|
|
951
|
+
return items2;
|
|
952
|
+
return _items;
|
|
953
|
+
} catch (err) {
|
|
954
|
+
return items2;
|
|
955
|
+
}
|
|
956
|
+
}, [items2, query]);
|
|
957
|
+
return /* @__PURE__ */ React.createElement(
|
|
958
|
+
react.Combobox,
|
|
959
|
+
{
|
|
960
|
+
value,
|
|
961
|
+
onChange,
|
|
962
|
+
as: "div",
|
|
963
|
+
className: "relative inline-block text-left z-20"
|
|
964
|
+
},
|
|
965
|
+
/* @__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(
|
|
966
|
+
react.ComboboxInput,
|
|
967
|
+
{
|
|
968
|
+
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",
|
|
969
|
+
displayValue: (item) => (item == null ? void 0 : item.label) ?? "Plain Text",
|
|
970
|
+
onChange: (event) => setQuery(event.target.value),
|
|
971
|
+
onClick: (ev) => ev.stopPropagation()
|
|
972
|
+
}
|
|
973
|
+
), /* @__PURE__ */ React.createElement(react.ComboboxButton, { className: "absolute inset-y-0 right-0 flex items-center pr-2" }, /* @__PURE__ */ React.createElement(
|
|
974
|
+
ChevronDownIcon$1,
|
|
975
|
+
{
|
|
976
|
+
className: "h-5 w-5 text-gray-400",
|
|
977
|
+
"aria-hidden": "true"
|
|
978
|
+
}
|
|
979
|
+
)))),
|
|
980
|
+
/* @__PURE__ */ React.createElement(
|
|
981
|
+
react.Transition,
|
|
982
|
+
{
|
|
983
|
+
enter: "transition ease-out duration-100",
|
|
984
|
+
enterFrom: "transform opacity-0 scale-95",
|
|
985
|
+
enterTo: "transform opacity-100 scale-100",
|
|
986
|
+
leave: "transition ease-in duration-75",
|
|
987
|
+
leaveFrom: "transform opacity-100 scale-100",
|
|
988
|
+
leaveTo: "transform opacity-0 scale-95"
|
|
989
|
+
},
|
|
990
|
+
/* @__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(
|
|
991
|
+
"button",
|
|
992
|
+
{
|
|
993
|
+
className: classNames$1(
|
|
994
|
+
focus ? "bg-gray-100 text-gray-900" : "text-gray-700",
|
|
995
|
+
"block px-4 py-2 text-xs w-full text-right"
|
|
996
|
+
)
|
|
997
|
+
},
|
|
998
|
+
item.render(item)
|
|
999
|
+
))))
|
|
1000
|
+
)
|
|
1001
|
+
);
|
|
1002
|
+
};
|
|
1003
|
+
MonacoEditor.loader.config({
|
|
1004
|
+
paths: { vs: "https://cdn.jsdelivr.net/npm/monaco-editor@0.31.1/min/vs" }
|
|
1005
|
+
});
|
|
1006
|
+
let retryCount = 0;
|
|
1007
|
+
const retryFocus = (ref) => {
|
|
1008
|
+
if (ref.current) {
|
|
1009
|
+
ref.current.focus();
|
|
1010
|
+
} else {
|
|
1011
|
+
if (retryCount < 30) {
|
|
1012
|
+
setTimeout(() => {
|
|
1013
|
+
retryCount = retryCount + 1;
|
|
1014
|
+
retryFocus(ref);
|
|
1015
|
+
}, 100);
|
|
1016
|
+
}
|
|
1017
|
+
}
|
|
1018
|
+
};
|
|
1019
|
+
const MINIMUM_HEIGHT = 75;
|
|
1020
|
+
const CodeBlock = ({
|
|
1021
|
+
attributes,
|
|
1022
|
+
editor,
|
|
1023
|
+
element,
|
|
1024
|
+
language: restrictLanguage,
|
|
1025
|
+
onChangeCallback,
|
|
1026
|
+
defaultValue,
|
|
1027
|
+
...props
|
|
1028
|
+
}) => {
|
|
1029
|
+
const [navigateAway, setNavigateAway] = React.useState(null);
|
|
1030
|
+
const monaco = MonacoEditor.useMonaco();
|
|
1031
|
+
const monacoEditorRef = React.useRef(null);
|
|
1032
|
+
const selected = slateReact.useSelected();
|
|
1033
|
+
const [height, setHeight] = React.useState(MINIMUM_HEIGHT);
|
|
1034
|
+
React.useEffect(() => {
|
|
1035
|
+
if (selected && plateCommon.isCollapsed(editor.selection)) {
|
|
1036
|
+
retryFocus(monacoEditorRef);
|
|
1037
|
+
}
|
|
1038
|
+
}, [selected, monacoEditorRef.current]);
|
|
1039
|
+
const value = element.value || "";
|
|
1040
|
+
if (typeof value !== "string") {
|
|
1041
|
+
throw new Error("Element must be of type string for code block");
|
|
1042
|
+
}
|
|
1043
|
+
const language = restrictLanguage || element.lang;
|
|
1044
|
+
const id = React.useMemo(() => uuid(), []);
|
|
1045
|
+
const languages = React.useMemo(() => {
|
|
1046
|
+
const defaultLangSet = { "": "plain text" };
|
|
1047
|
+
if (!monaco)
|
|
1048
|
+
return defaultLangSet;
|
|
1049
|
+
return monaco.languages.getLanguages().reduce((ac, cv) => {
|
|
1050
|
+
if (cv.id === "plaintext")
|
|
1051
|
+
return ac;
|
|
1052
|
+
return { ...ac, [cv.id]: cv.id };
|
|
1053
|
+
}, defaultLangSet);
|
|
1054
|
+
}, [monaco]);
|
|
1055
|
+
React.useEffect(() => {
|
|
1056
|
+
if (monaco) {
|
|
1057
|
+
monaco.languages.typescript.typescriptDefaults.setEagerModelSync(true);
|
|
1058
|
+
monaco.languages.typescript.typescriptDefaults.setDiagnosticsOptions({
|
|
1059
|
+
// disable errors
|
|
1060
|
+
noSemanticValidation: true,
|
|
1061
|
+
noSyntaxValidation: true
|
|
1062
|
+
});
|
|
1063
|
+
}
|
|
1064
|
+
}, [monaco]);
|
|
1065
|
+
const items2 = Object.entries(languages).map(([key, label]) => ({
|
|
1066
|
+
key,
|
|
1067
|
+
label,
|
|
1068
|
+
render: (item) => item.label
|
|
1069
|
+
}));
|
|
1070
|
+
const currentItem = React.useMemo(() => {
|
|
1071
|
+
return items2.find((item) => item.key === language) ?? {
|
|
1072
|
+
key: "",
|
|
1073
|
+
label: "Plain Text"
|
|
1074
|
+
};
|
|
1075
|
+
}, [items2, language]);
|
|
1076
|
+
React.useEffect(() => {
|
|
1077
|
+
if (navigateAway) {
|
|
1078
|
+
setNavigateAway(null);
|
|
1079
|
+
switch (navigateAway) {
|
|
1080
|
+
case "remove":
|
|
1081
|
+
{
|
|
1082
|
+
plateCommon.focusEditor(editor);
|
|
1083
|
+
plateCommon.setNodes(
|
|
1084
|
+
editor,
|
|
1085
|
+
{
|
|
1086
|
+
type: "p",
|
|
1087
|
+
children: [{ text: "" }],
|
|
1088
|
+
lang: void 0,
|
|
1089
|
+
value: void 0
|
|
1090
|
+
},
|
|
1091
|
+
{
|
|
1092
|
+
match: (n) => {
|
|
1093
|
+
if (plateCommon.isElement(n) && n.type === element.type) {
|
|
1094
|
+
return true;
|
|
1095
|
+
}
|
|
1096
|
+
}
|
|
1097
|
+
}
|
|
1098
|
+
);
|
|
1099
|
+
}
|
|
1100
|
+
break;
|
|
1101
|
+
case "insertNext":
|
|
1102
|
+
{
|
|
1103
|
+
plateCommon.insertNodes(
|
|
1104
|
+
editor,
|
|
1105
|
+
[
|
|
1106
|
+
{
|
|
1107
|
+
type: plateCommon.ELEMENT_DEFAULT,
|
|
1108
|
+
children: [{ text: "" }],
|
|
1109
|
+
lang: void 0,
|
|
1110
|
+
value: void 0
|
|
1111
|
+
}
|
|
1112
|
+
],
|
|
1113
|
+
{ select: true }
|
|
1114
|
+
);
|
|
1115
|
+
plateCommon.focusEditor(editor);
|
|
1116
|
+
}
|
|
1117
|
+
break;
|
|
1118
|
+
case "up":
|
|
1119
|
+
{
|
|
1120
|
+
const path = plateCommon.findNodePath(editor, element);
|
|
1121
|
+
if (!path) {
|
|
1122
|
+
return;
|
|
1123
|
+
}
|
|
1124
|
+
const previousNodePath = plateCommon.getPointBefore(editor, path);
|
|
1125
|
+
if (!previousNodePath) {
|
|
1126
|
+
plateCommon.focusEditor(editor);
|
|
1127
|
+
plateCommon.insertNodes(
|
|
1128
|
+
editor,
|
|
1129
|
+
[
|
|
1130
|
+
{
|
|
1131
|
+
type: plateCommon.ELEMENT_DEFAULT,
|
|
1132
|
+
children: [{ text: "" }],
|
|
1133
|
+
lang: void 0,
|
|
1134
|
+
value: void 0
|
|
1135
|
+
}
|
|
1136
|
+
],
|
|
1137
|
+
// Insert a new node at the current path, resulting in the code_block
|
|
1138
|
+
// moving down one block
|
|
1139
|
+
{ at: path, select: true }
|
|
1140
|
+
);
|
|
1141
|
+
return;
|
|
1142
|
+
}
|
|
1143
|
+
plateCommon.focusEditor(editor, previousNodePath);
|
|
1144
|
+
}
|
|
1145
|
+
break;
|
|
1146
|
+
case "down": {
|
|
1147
|
+
const path = plateCommon.findNodePath(editor, element);
|
|
1148
|
+
if (!path) {
|
|
1149
|
+
return;
|
|
1150
|
+
}
|
|
1151
|
+
const nextNodePath = plateCommon.getPointAfter(editor, path);
|
|
1152
|
+
if (!nextNodePath) {
|
|
1153
|
+
plateCommon.insertNodes(
|
|
1154
|
+
editor,
|
|
1155
|
+
[
|
|
1156
|
+
{
|
|
1157
|
+
type: plateCommon.ELEMENT_DEFAULT,
|
|
1158
|
+
children: [{ text: "" }],
|
|
1159
|
+
lang: void 0,
|
|
1160
|
+
value: void 0
|
|
1161
|
+
}
|
|
1162
|
+
],
|
|
1163
|
+
{ select: true }
|
|
1164
|
+
);
|
|
1165
|
+
plateCommon.focusEditor(editor);
|
|
1166
|
+
} else {
|
|
1167
|
+
plateCommon.focusEditor(editor, nextNodePath);
|
|
1168
|
+
}
|
|
1169
|
+
break;
|
|
1170
|
+
}
|
|
1171
|
+
}
|
|
1172
|
+
}
|
|
1173
|
+
}, [navigateAway]);
|
|
1174
|
+
function handleEditorDidMount(monacoEditor, monaco2) {
|
|
1175
|
+
monacoEditorRef.current = monacoEditor;
|
|
1176
|
+
monacoEditor.onDidContentSizeChange(() => {
|
|
1177
|
+
setHeight(
|
|
1178
|
+
monacoEditor.getContentHeight() > MINIMUM_HEIGHT ? monacoEditor.getContentHeight() : MINIMUM_HEIGHT
|
|
1179
|
+
);
|
|
1180
|
+
monacoEditor.layout();
|
|
1181
|
+
});
|
|
1182
|
+
plateCommon.setNodes(editor, { value: defaultValue, lang: language });
|
|
1183
|
+
monacoEditor.addCommand(monaco2.KeyMod.Shift | monaco2.KeyCode.Enter, () => {
|
|
1184
|
+
if (monacoEditor.hasTextFocus()) {
|
|
1185
|
+
setNavigateAway("insertNext");
|
|
1186
|
+
}
|
|
1187
|
+
});
|
|
1188
|
+
monacoEditor.onKeyDown((l) => {
|
|
1189
|
+
if (l.code === "ArrowUp") {
|
|
1190
|
+
const selection = monacoEditor.getSelection();
|
|
1191
|
+
if (selection.endLineNumber === 1 && selection.startLineNumber === 1) {
|
|
1192
|
+
setNavigateAway("up");
|
|
1193
|
+
}
|
|
1194
|
+
}
|
|
1195
|
+
if (l.code === "ArrowDown") {
|
|
1196
|
+
const selection = monacoEditor.getSelection();
|
|
1197
|
+
const totalLines = monacoEditor.getModel().getLineCount();
|
|
1198
|
+
if (selection.endLineNumber === totalLines && selection.startLineNumber === totalLines) {
|
|
1199
|
+
setNavigateAway("down");
|
|
1200
|
+
}
|
|
1201
|
+
}
|
|
1202
|
+
if (l.code === "Backspace") {
|
|
1203
|
+
const selection = monacoEditor.getSelection();
|
|
1204
|
+
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) {
|
|
1205
|
+
setNavigateAway("remove");
|
|
1206
|
+
}
|
|
1207
|
+
}
|
|
1208
|
+
});
|
|
1209
|
+
}
|
|
1210
|
+
return /* @__PURE__ */ React.createElement(
|
|
1211
|
+
"div",
|
|
1212
|
+
{
|
|
1213
|
+
...attributes,
|
|
1214
|
+
className: "relative mb-2 mt-0.5 rounded-lg shadow-md p-2 border-gray-200 border"
|
|
1215
|
+
},
|
|
1216
|
+
/* @__PURE__ */ React.createElement("style", null, `.monaco-editor .editor-widget {
|
|
1217
|
+
display: none !important;
|
|
1218
|
+
visibility: hidden !important;
|
|
1219
|
+
}`),
|
|
1220
|
+
props.children,
|
|
1221
|
+
/* @__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(
|
|
1222
|
+
Autocomplete,
|
|
1223
|
+
{
|
|
1224
|
+
items: items2,
|
|
1225
|
+
value: currentItem,
|
|
1226
|
+
defaultQuery: "plaintext",
|
|
1227
|
+
onChange: (item) => plateCommon.setNodes(editor, { lang: item.key })
|
|
1228
|
+
}
|
|
1229
|
+
)), /* @__PURE__ */ React.createElement("div", { style: { height: `${height}px` } }, /* @__PURE__ */ React.createElement(
|
|
1230
|
+
MonacoEditor,
|
|
1231
|
+
{
|
|
1232
|
+
path: id,
|
|
1233
|
+
onMount: handleEditorDidMount,
|
|
1234
|
+
options: {
|
|
1235
|
+
scrollBeyondLastLine: false,
|
|
1236
|
+
// automaticLayout: true,
|
|
1237
|
+
tabSize: 2,
|
|
1238
|
+
disableLayerHinting: true,
|
|
1239
|
+
accessibilitySupport: "off",
|
|
1240
|
+
codeLens: false,
|
|
1241
|
+
wordWrap: "on",
|
|
1242
|
+
minimap: {
|
|
1243
|
+
enabled: false
|
|
1244
|
+
},
|
|
1245
|
+
fontSize: 14,
|
|
1246
|
+
lineHeight: 2,
|
|
1247
|
+
formatOnPaste: true,
|
|
1248
|
+
lineNumbers: "off",
|
|
1249
|
+
formatOnType: true,
|
|
1250
|
+
fixedOverflowWidgets: true,
|
|
1251
|
+
// Takes too much horizontal space for iframe
|
|
1252
|
+
folding: false,
|
|
1253
|
+
renderLineHighlight: "none",
|
|
1254
|
+
scrollbar: {
|
|
1255
|
+
verticalScrollbarSize: 1,
|
|
1256
|
+
horizontalScrollbarSize: 1,
|
|
1257
|
+
// https://github.com/microsoft/monaco-editor/issues/2007#issuecomment-644425664
|
|
1258
|
+
alwaysConsumeMouseWheel: false
|
|
1259
|
+
}
|
|
1260
|
+
},
|
|
1261
|
+
language: String(language),
|
|
1262
|
+
value: String(element.value),
|
|
1263
|
+
onChange: (value2) => {
|
|
1264
|
+
onChangeCallback == null ? void 0 : onChangeCallback(value2);
|
|
1265
|
+
plateCommon.setNodes(editor, { value: value2, lang: language });
|
|
1266
|
+
}
|
|
1267
|
+
}
|
|
1268
|
+
)))
|
|
1269
|
+
);
|
|
1270
|
+
};
|
|
1271
|
+
const CodeBlockElement = cn$1.withRef(
|
|
1272
|
+
({ className, ...props }, ref) => {
|
|
1273
|
+
const { element } = props;
|
|
1274
|
+
const state = plateCodeBlock.useCodeBlockElementState({ element });
|
|
1275
|
+
return /* @__PURE__ */ React.createElement(
|
|
1276
|
+
plateCommon.PlateElement,
|
|
1277
|
+
{
|
|
1278
|
+
className: cn$1.cn("relative py-1", state.className, className),
|
|
1279
|
+
ref,
|
|
1280
|
+
...props
|
|
1281
|
+
},
|
|
1282
|
+
/* @__PURE__ */ React.createElement(CodeBlock, { ...props })
|
|
1283
|
+
);
|
|
1284
|
+
}
|
|
1285
|
+
);
|
|
1286
|
+
const CodeLeaf = cn$1.withRef(
|
|
1287
|
+
({ children, className, ...props }, ref) => {
|
|
1288
|
+
return /* @__PURE__ */ React.createElement(
|
|
1289
|
+
plateCommon.PlateLeaf,
|
|
1290
|
+
{
|
|
1291
|
+
asChild: true,
|
|
1292
|
+
className: cn$1.cn(
|
|
1293
|
+
"whitespace-pre-wrap rounded-md bg-muted px-[0.3em] py-[0.2em] font-mono text-sm",
|
|
1294
|
+
className
|
|
1295
|
+
),
|
|
1296
|
+
ref,
|
|
1297
|
+
...props
|
|
1298
|
+
},
|
|
1299
|
+
/* @__PURE__ */ React.createElement("code", null, children)
|
|
1300
|
+
);
|
|
1301
|
+
}
|
|
1302
|
+
);
|
|
1303
|
+
const CodeLineElement = cn$1.withRef((props, ref) => /* @__PURE__ */ React.createElement(plateCommon.PlateElement, { ref, ...props }));
|
|
1304
|
+
const CodeSyntaxLeaf = cn$1.withRef(
|
|
1305
|
+
({ children, ...props }, ref) => {
|
|
1306
|
+
const { leaf } = props;
|
|
1307
|
+
const { tokenProps } = plateCodeBlock.useCodeSyntaxLeaf({ leaf });
|
|
1308
|
+
return /* @__PURE__ */ React.createElement(plateCommon.PlateLeaf, { ref, ...props }, /* @__PURE__ */ React.createElement("span", { ...tokenProps }, children));
|
|
1309
|
+
}
|
|
1310
|
+
);
|
|
1311
|
+
const listVariants = classVarianceAuthority.cva("m-0 ps-6", {
|
|
1312
|
+
variants: {
|
|
1313
|
+
variant: {
|
|
1314
|
+
ol: "list-decimal",
|
|
1315
|
+
ul: "list-disc [&_ul]:list-[circle] [&_ul_ul]:list-[square]"
|
|
1316
|
+
}
|
|
1317
|
+
}
|
|
1318
|
+
});
|
|
1319
|
+
const ListElementVariants = cn$1.withVariants(plateCommon.PlateElement, listVariants, [
|
|
1320
|
+
"variant"
|
|
1321
|
+
]);
|
|
1322
|
+
const ListElement = cn$1.withRef(
|
|
1323
|
+
({ children, variant = "ul", ...props }, ref) => {
|
|
1324
|
+
const Component = variant;
|
|
1325
|
+
return /* @__PURE__ */ React.createElement(ListElementVariants, { asChild: true, ref, variant, ...props }, /* @__PURE__ */ React.createElement(Component, null, children));
|
|
1326
|
+
}
|
|
1327
|
+
);
|
|
1328
|
+
const ELEMENT_MERMAID = "mermaid";
|
|
1329
|
+
const createMermaidPlugin = plateCommon.createPluginFactory({
|
|
1330
|
+
isElement: true,
|
|
1331
|
+
isVoid: true,
|
|
1332
|
+
isInline: false,
|
|
1333
|
+
key: ELEMENT_MERMAID
|
|
1334
|
+
});
|
|
1335
|
+
const MermaidElementWithRef = ({ config }) => {
|
|
1336
|
+
const mermaidRef = React.useRef(null);
|
|
1337
|
+
React.useEffect(() => {
|
|
1338
|
+
if (mermaidRef.current) {
|
|
1339
|
+
mermaid.initialize({ startOnLoad: true });
|
|
1340
|
+
mermaid.init();
|
|
1341
|
+
}
|
|
1342
|
+
}, [config]);
|
|
1343
|
+
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)));
|
|
1344
|
+
};
|
|
1345
|
+
const Bubble = ({ children }) => {
|
|
1346
|
+
return /* @__PURE__ */ React.createElement("div", { className: "bg-blue-600 rounded-full p-2 transition-transform duration-200 ease-in-out hover:scale-110" }, children);
|
|
1347
|
+
};
|
|
1348
|
+
const ErrorMsg = ({ error }) => {
|
|
1349
|
+
if (error) {
|
|
1350
|
+
return /* @__PURE__ */ React.createElement(
|
|
1351
|
+
"div",
|
|
1352
|
+
{
|
|
1353
|
+
contentEditable: false,
|
|
1354
|
+
className: "font-mono bg-red-600 text-white p-2 rounded-md cursor-default"
|
|
1355
|
+
},
|
|
1356
|
+
error
|
|
1357
|
+
);
|
|
1358
|
+
}
|
|
1359
|
+
return null;
|
|
1360
|
+
};
|
|
1361
|
+
const DEFAULT_MERMAID_CONFIG = `%% This won't render without implementing a rendering engine (e.g. mermaid on npm)
|
|
1362
|
+
flowchart TD
|
|
1363
|
+
id1(this is an example flow diagram)
|
|
1364
|
+
--> id2(modify me to see changes!)
|
|
1365
|
+
id2
|
|
1366
|
+
--> id3(Click the top button to preview the changes)
|
|
1367
|
+
--> id4(Learn about mermaid diagrams - mermaid.js.org)`;
|
|
1368
|
+
const MermaidElement = cn$1.withRef(
|
|
1369
|
+
({ children, nodeProps, element, ...props }, ref) => {
|
|
1370
|
+
const [mermaidConfig, setMermaidConfig] = React.useState(
|
|
1371
|
+
element.value || DEFAULT_MERMAID_CONFIG
|
|
1372
|
+
);
|
|
1373
|
+
const [isEditing, setIsEditing] = React.useState(
|
|
1374
|
+
mermaidConfig === DEFAULT_MERMAID_CONFIG || false
|
|
1375
|
+
);
|
|
1376
|
+
const [mermaidError, setMermaidError] = React.useState(null);
|
|
1377
|
+
const node = {
|
|
1378
|
+
type: ELEMENT_MERMAID,
|
|
1379
|
+
value: mermaidConfig,
|
|
1380
|
+
children: [{ type: "text", text: "" }]
|
|
1381
|
+
};
|
|
1382
|
+
React.useEffect(() => {
|
|
1383
|
+
if (mermaid.parse(mermaidConfig)) {
|
|
1384
|
+
setMermaidError(null);
|
|
1385
|
+
}
|
|
1386
|
+
}, [mermaidConfig]);
|
|
1387
|
+
mermaid.parseError = (err) => {
|
|
1388
|
+
setMermaidError(
|
|
1389
|
+
String(err.message) || "An error occurred while parsing the diagram."
|
|
1390
|
+
);
|
|
1391
|
+
};
|
|
1392
|
+
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(
|
|
1393
|
+
lucideReact.Eye,
|
|
1394
|
+
{
|
|
1395
|
+
className: "w-5 h-5 fill-white cursor-pointer",
|
|
1396
|
+
onClick: () => {
|
|
1397
|
+
setIsEditing(!isEditing);
|
|
1398
|
+
}
|
|
1399
|
+
}
|
|
1400
|
+
) : /* @__PURE__ */ React.createElement(
|
|
1401
|
+
lucideReact.SquarePen,
|
|
1402
|
+
{
|
|
1403
|
+
className: "w-5 h-5 fill-white cursor-pointer",
|
|
1404
|
+
onClick: () => {
|
|
1405
|
+
setIsEditing(!isEditing);
|
|
1406
|
+
}
|
|
1407
|
+
}
|
|
1408
|
+
))), isEditing ? /* @__PURE__ */ React.createElement(
|
|
1409
|
+
CodeBlock,
|
|
1410
|
+
{
|
|
1411
|
+
children: "",
|
|
1412
|
+
language: "yaml",
|
|
1413
|
+
...props,
|
|
1414
|
+
element: node,
|
|
1415
|
+
defaultValue: mermaidConfig,
|
|
1416
|
+
onChangeCallback: (value) => setMermaidConfig(value)
|
|
1417
|
+
}
|
|
1418
|
+
) : /* @__PURE__ */ React.createElement(MermaidElementWithRef, { config: mermaidConfig })), children, /* @__PURE__ */ React.createElement(ErrorMsg, { error: mermaidError }));
|
|
1419
|
+
}
|
|
1420
|
+
);
|
|
894
1421
|
const RawMarkdown = () => {
|
|
895
1422
|
return /* @__PURE__ */ React.createElement(
|
|
896
1423
|
"svg",
|
|
@@ -909,6 +1436,29 @@ var __publicField = (obj, key, value) => {
|
|
|
909
1436
|
/* @__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
1437
|
);
|
|
911
1438
|
};
|
|
1439
|
+
const MermaidIcon = () => /* @__PURE__ */ React.createElement(
|
|
1440
|
+
"svg",
|
|
1441
|
+
{
|
|
1442
|
+
width: "100%",
|
|
1443
|
+
height: "100%",
|
|
1444
|
+
viewBox: "0 0 491 491",
|
|
1445
|
+
version: "1.1",
|
|
1446
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
1447
|
+
fillRule: "evenodd",
|
|
1448
|
+
clipRule: "evenodd",
|
|
1449
|
+
strokeLinejoin: "round",
|
|
1450
|
+
strokeMiterlimit: 2
|
|
1451
|
+
},
|
|
1452
|
+
/* @__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" }),
|
|
1453
|
+
/* @__PURE__ */ React.createElement(
|
|
1454
|
+
"path",
|
|
1455
|
+
{
|
|
1456
|
+
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",
|
|
1457
|
+
fill: "white",
|
|
1458
|
+
fillRule: "nonzero"
|
|
1459
|
+
}
|
|
1460
|
+
)
|
|
1461
|
+
);
|
|
912
1462
|
const borderAll = (props) => /* @__PURE__ */ React.createElement(
|
|
913
1463
|
"svg",
|
|
914
1464
|
{
|
|
@@ -1149,6 +1699,7 @@ var __publicField = (obj, key, value) => {
|
|
|
1149
1699
|
clear: lucideReact.X,
|
|
1150
1700
|
close: lucideReact.X,
|
|
1151
1701
|
// code: Code2,
|
|
1702
|
+
paint: lucideReact.PaintBucket,
|
|
1152
1703
|
codeblock: lucideReact.FileCode,
|
|
1153
1704
|
color: lucideReact.Baseline,
|
|
1154
1705
|
column: lucideReact.RectangleVertical,
|
|
@@ -1174,6 +1725,7 @@ var __publicField = (obj, key, value) => {
|
|
|
1174
1725
|
lineHeight: lucideReact.WrapText,
|
|
1175
1726
|
// link: Link2,
|
|
1176
1727
|
minus: lucideReact.Minus,
|
|
1728
|
+
mermaid: MermaidIcon,
|
|
1177
1729
|
more: lucideReact.MoreHorizontal,
|
|
1178
1730
|
// ol: ListOrdered,
|
|
1179
1731
|
outdent: lucideReact.Outdent,
|
|
@@ -1548,7 +2100,7 @@ var __publicField = (obj, key, value) => {
|
|
|
1548
2100
|
setHasEmpty
|
|
1549
2101
|
]
|
|
1550
2102
|
);
|
|
1551
|
-
const store = react.useComboboxStore({
|
|
2103
|
+
const store = react$1.useComboboxStore({
|
|
1552
2104
|
setValue: (newValue) => React.startTransition(() => setValue(newValue))
|
|
1553
2105
|
});
|
|
1554
2106
|
const items2 = store.useState("items");
|
|
@@ -1558,7 +2110,7 @@ var __publicField = (obj, key, value) => {
|
|
|
1558
2110
|
}
|
|
1559
2111
|
}, [items2, store]);
|
|
1560
2112
|
return /* @__PURE__ */ React.createElement("span", { contentEditable: false }, /* @__PURE__ */ React.createElement(
|
|
1561
|
-
react.ComboboxProvider,
|
|
2113
|
+
react$1.ComboboxProvider,
|
|
1562
2114
|
{
|
|
1563
2115
|
open: (items2.length > 0 || hasEmpty) && (!hideWhenNoValue || value.length > 0),
|
|
1564
2116
|
store
|
|
@@ -1573,7 +2125,7 @@ var __publicField = (obj, key, value) => {
|
|
|
1573
2125
|
showTrigger,
|
|
1574
2126
|
trigger
|
|
1575
2127
|
} = React.useContext(InlineComboboxContext);
|
|
1576
|
-
const store = react.useComboboxContext();
|
|
2128
|
+
const store = react$1.useComboboxContext();
|
|
1577
2129
|
const value = store.useState("value");
|
|
1578
2130
|
const ref = plateCommon.useComposedRef(propRef, contextRef);
|
|
1579
2131
|
return /* @__PURE__ */ React.createElement(React.Fragment, null, showTrigger && trigger, /* @__PURE__ */ React.createElement("span", { className: "relative min-h-[1lh]" }, /* @__PURE__ */ React.createElement(
|
|
@@ -1584,7 +2136,7 @@ var __publicField = (obj, key, value) => {
|
|
|
1584
2136
|
},
|
|
1585
2137
|
value || ""
|
|
1586
2138
|
), /* @__PURE__ */ React.createElement(
|
|
1587
|
-
react.Combobox,
|
|
2139
|
+
react$1.Combobox,
|
|
1588
2140
|
{
|
|
1589
2141
|
autoSelect: true,
|
|
1590
2142
|
className: cn$1.cn(
|
|
@@ -1603,8 +2155,8 @@ var __publicField = (obj, key, value) => {
|
|
|
1603
2155
|
className,
|
|
1604
2156
|
...props
|
|
1605
2157
|
}) => {
|
|
1606
|
-
return /* @__PURE__ */ React.createElement(react.Portal, null, /* @__PURE__ */ React.createElement(
|
|
1607
|
-
react.ComboboxPopover,
|
|
2158
|
+
return /* @__PURE__ */ React.createElement(react$1.Portal, null, /* @__PURE__ */ React.createElement(
|
|
2159
|
+
react$1.ComboboxPopover,
|
|
1608
2160
|
{
|
|
1609
2161
|
className: cn$1.cn(
|
|
1610
2162
|
"z-[9999999] max-h-[288px] w-[300px] overflow-y-auto rounded-md bg-white shadow-md",
|
|
@@ -1636,7 +2188,7 @@ var __publicField = (obj, key, value) => {
|
|
|
1636
2188
|
}) => {
|
|
1637
2189
|
const { value } = props;
|
|
1638
2190
|
const { filter, removeInput } = React.useContext(InlineComboboxContext);
|
|
1639
|
-
const store = react.useComboboxContext();
|
|
2191
|
+
const store = react$1.useComboboxContext();
|
|
1640
2192
|
const search = filter && store.useState("value");
|
|
1641
2193
|
const visible = React.useMemo(
|
|
1642
2194
|
() => !filter || filter({ keywords, value }, search),
|
|
@@ -1645,7 +2197,7 @@ var __publicField = (obj, key, value) => {
|
|
|
1645
2197
|
if (!visible)
|
|
1646
2198
|
return null;
|
|
1647
2199
|
return /* @__PURE__ */ React.createElement(
|
|
1648
|
-
react.ComboboxItem,
|
|
2200
|
+
react$1.ComboboxItem,
|
|
1649
2201
|
{
|
|
1650
2202
|
className: cn$1.cn(comboboxItemVariants(), className),
|
|
1651
2203
|
onClick: (event) => {
|
|
@@ -1661,7 +2213,7 @@ var __publicField = (obj, key, value) => {
|
|
|
1661
2213
|
className
|
|
1662
2214
|
}) => {
|
|
1663
2215
|
const { setHasEmpty } = React.useContext(InlineComboboxContext);
|
|
1664
|
-
const store = react.useComboboxContext();
|
|
2216
|
+
const store = react$1.useComboboxContext();
|
|
1665
2217
|
const items2 = store.useState("items");
|
|
1666
2218
|
React.useEffect(() => {
|
|
1667
2219
|
setHasEmpty(true);
|
|
@@ -1744,782 +2296,6 @@ var __publicField = (obj, key, value) => {
|
|
|
1744
2296
|
);
|
|
1745
2297
|
}
|
|
1746
2298
|
);
|
|
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]);
|
|
1836
|
-
return /* @__PURE__ */ React.createElement(
|
|
1837
|
-
react$1.Combobox,
|
|
1838
|
-
{
|
|
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()
|
|
1851
|
-
}
|
|
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,
|
|
1854
|
-
{
|
|
1855
|
-
className: "h-5 w-5 text-gray-400",
|
|
1856
|
-
"aria-hidden": "true"
|
|
1857
|
-
}
|
|
1858
|
-
)))),
|
|
1859
|
-
/* @__PURE__ */ React.createElement(
|
|
1860
|
-
react$1.Transition,
|
|
1861
|
-
{
|
|
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"
|
|
1868
|
-
},
|
|
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",
|
|
1871
|
-
{
|
|
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"
|
|
1875
|
-
)
|
|
1876
|
-
},
|
|
1877
|
-
item.render(item)
|
|
1878
|
-
))))
|
|
1879
|
-
)
|
|
1880
|
-
);
|
|
1881
|
-
};
|
|
1882
|
-
MonacoEditor.loader.config({
|
|
1883
|
-
paths: { vs: "https://cdn.jsdelivr.net/npm/monaco-editor@0.31.1/min/vs" }
|
|
1884
|
-
});
|
|
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);
|
|
1913
|
-
}
|
|
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
|
-
}
|
|
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
|
-
});
|
|
1939
|
-
}
|
|
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
|
-
}
|
|
2047
|
-
}
|
|
2048
|
-
}
|
|
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
|
-
}
|
|
2080
|
-
}
|
|
2081
|
-
});
|
|
2082
|
-
}
|
|
2083
|
-
return /* @__PURE__ */ React.createElement(
|
|
2084
|
-
"div",
|
|
2085
|
-
{
|
|
2086
|
-
...attributes,
|
|
2087
|
-
className: "relative mb-2 mt-0.5 rounded-lg shadow-md p-2 border-gray-200 border"
|
|
2088
|
-
},
|
|
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,
|
|
2096
|
-
{
|
|
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,
|
|
2104
|
-
{
|
|
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
|
-
)))
|
|
2141
|
-
);
|
|
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,
|
|
2149
|
-
{
|
|
2150
|
-
className: cn$1.cn("relative py-1", state.className, className),
|
|
2151
|
-
ref,
|
|
2152
|
-
...props
|
|
2153
|
-
},
|
|
2154
|
-
/* @__PURE__ */ React.createElement(CodeBlock, { ...props })
|
|
2155
|
-
);
|
|
2156
|
-
}
|
|
2157
|
-
);
|
|
2158
|
-
const buttonVariants$1 = classVarianceAuthority.cva(
|
|
2159
|
-
"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",
|
|
2160
|
-
{
|
|
2161
|
-
defaultVariants: {
|
|
2162
|
-
size: "default",
|
|
2163
|
-
variant: "default"
|
|
2164
|
-
},
|
|
2165
|
-
variants: {
|
|
2166
|
-
isMenu: {
|
|
2167
|
-
true: "h-auto w-full cursor-pointer justify-start"
|
|
2168
|
-
},
|
|
2169
|
-
size: {
|
|
2170
|
-
default: "h-10 px-4 py-2",
|
|
2171
|
-
icon: "size-10",
|
|
2172
|
-
lg: "h-11 rounded-md px-8",
|
|
2173
|
-
none: "",
|
|
2174
|
-
sm: "h-9 rounded-md px-3",
|
|
2175
|
-
sms: "size-9 rounded-md px-0",
|
|
2176
|
-
xs: "h-8 rounded-md px-3"
|
|
2177
|
-
},
|
|
2178
|
-
variant: {
|
|
2179
|
-
default: "bg-primary text-primary-foreground hover:bg-primary/90",
|
|
2180
|
-
destructive: "bg-destructive text-destructive-foreground hover:bg-destructive/90",
|
|
2181
|
-
ghost: "hover:bg-accent hover:text-accent-foreground",
|
|
2182
|
-
inlineLink: "text-base text-primary underline underline-offset-4",
|
|
2183
|
-
link: "text-primary underline-offset-4 hover:underline",
|
|
2184
|
-
outline: "border border-input bg-background hover:bg-accent hover:text-accent-foreground",
|
|
2185
|
-
secondary: "bg-secondary text-secondary-foreground hover:bg-secondary/80"
|
|
2186
|
-
}
|
|
2187
|
-
}
|
|
2188
|
-
}
|
|
2189
|
-
);
|
|
2190
|
-
const Button$2 = cn$1.withRef(({ asChild = false, className, isMenu, size, variant, ...props }, ref) => {
|
|
2191
|
-
const Comp = asChild ? reactSlot.Slot : "button";
|
|
2192
|
-
return /* @__PURE__ */ React__namespace.createElement(
|
|
2193
|
-
Comp,
|
|
2194
|
-
{
|
|
2195
|
-
className: cn$1.cn(buttonVariants$1({ className, isMenu, size, variant })),
|
|
2196
|
-
ref,
|
|
2197
|
-
...props
|
|
2198
|
-
}
|
|
2199
|
-
);
|
|
2200
|
-
});
|
|
2201
|
-
const DropdownMenu = DropdownMenuPrimitive__namespace.Root;
|
|
2202
|
-
const DropdownMenuTrigger = DropdownMenuPrimitive__namespace.Trigger;
|
|
2203
|
-
const DropdownMenuPortal = DropdownMenuPrimitive__namespace.Portal;
|
|
2204
|
-
const DropdownMenuSub = DropdownMenuPrimitive__namespace.Sub;
|
|
2205
|
-
const DropdownMenuRadioGroup = DropdownMenuPrimitive__namespace.RadioGroup;
|
|
2206
|
-
const DropdownMenuSubTrigger = cn$1.withRef(({ children, className, inset, ...props }, ref) => /* @__PURE__ */ React.createElement(
|
|
2207
|
-
DropdownMenuPrimitive__namespace.SubTrigger,
|
|
2208
|
-
{
|
|
2209
|
-
className: cn$1.cn(
|
|
2210
|
-
"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",
|
|
2211
|
-
"data-[disabled]:pointer-events-none data-[disabled]:opacity-50",
|
|
2212
|
-
inset && "pl-8",
|
|
2213
|
-
className
|
|
2214
|
-
),
|
|
2215
|
-
ref,
|
|
2216
|
-
...props
|
|
2217
|
-
},
|
|
2218
|
-
children,
|
|
2219
|
-
/* @__PURE__ */ React.createElement(Icons.chevronRight, { className: "ml-auto size-4" })
|
|
2220
|
-
));
|
|
2221
|
-
const DropdownMenuSubContent = cn$1.withCn(
|
|
2222
|
-
DropdownMenuPrimitive__namespace.SubContent,
|
|
2223
|
-
"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"
|
|
2224
|
-
);
|
|
2225
|
-
const DropdownMenuContentVariants = cn$1.withProps(DropdownMenuPrimitive__namespace.Content, {
|
|
2226
|
-
className: cn$1.cn(
|
|
2227
|
-
"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"
|
|
2228
|
-
),
|
|
2229
|
-
sideOffset: 4
|
|
2230
|
-
});
|
|
2231
|
-
const DropdownMenuContent = cn$1.withRef(({ ...props }, ref) => /* @__PURE__ */ React.createElement(DropdownMenuPrimitive__namespace.Portal, null, /* @__PURE__ */ React.createElement(DropdownMenuContentVariants, { ref, ...props })));
|
|
2232
|
-
const menuItemVariants = classVarianceAuthority.cva(
|
|
2233
|
-
cn$1.cn(
|
|
2234
|
-
"relative flex h-9 cursor-pointer select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none transition-colors",
|
|
2235
|
-
"focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50"
|
|
2236
|
-
),
|
|
2237
|
-
{
|
|
2238
|
-
variants: {
|
|
2239
|
-
inset: {
|
|
2240
|
-
true: "pl-8"
|
|
2241
|
-
}
|
|
2242
|
-
}
|
|
2243
|
-
}
|
|
2244
|
-
);
|
|
2245
|
-
const DropdownMenuItem = cn$1.withVariants(
|
|
2246
|
-
DropdownMenuPrimitive__namespace.Item,
|
|
2247
|
-
menuItemVariants,
|
|
2248
|
-
["inset"]
|
|
2249
|
-
);
|
|
2250
|
-
const DropdownMenuCheckboxItem = cn$1.withRef(({ children, className, ...props }, ref) => /* @__PURE__ */ React.createElement(
|
|
2251
|
-
DropdownMenuPrimitive__namespace.CheckboxItem,
|
|
2252
|
-
{
|
|
2253
|
-
className: cn$1.cn(
|
|
2254
|
-
"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",
|
|
2255
|
-
"cursor-pointer",
|
|
2256
|
-
className
|
|
2257
|
-
),
|
|
2258
|
-
ref,
|
|
2259
|
-
...props
|
|
2260
|
-
},
|
|
2261
|
-
/* @__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" }))),
|
|
2262
|
-
children
|
|
2263
|
-
));
|
|
2264
|
-
const DropdownMenuRadioItem = cn$1.withRef(({ children, className, hideIcon, ...props }, ref) => /* @__PURE__ */ React.createElement(
|
|
2265
|
-
DropdownMenuPrimitive__namespace.RadioItem,
|
|
2266
|
-
{
|
|
2267
|
-
className: cn$1.cn(
|
|
2268
|
-
"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",
|
|
2269
|
-
"h-9 cursor-pointer px-2 data-[state=checked]:bg-accent data-[state=checked]:text-accent-foreground",
|
|
2270
|
-
className
|
|
2271
|
-
),
|
|
2272
|
-
ref,
|
|
2273
|
-
...props
|
|
2274
|
-
},
|
|
2275
|
-
!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" }))),
|
|
2276
|
-
children
|
|
2277
|
-
));
|
|
2278
|
-
const dropdownMenuLabelVariants = classVarianceAuthority.cva(
|
|
2279
|
-
cn$1.cn("select-none px-2 py-1.5 text-sm font-semibold"),
|
|
2280
|
-
{
|
|
2281
|
-
variants: {
|
|
2282
|
-
inset: {
|
|
2283
|
-
true: "pl-8"
|
|
2284
|
-
}
|
|
2285
|
-
}
|
|
2286
|
-
}
|
|
2287
|
-
);
|
|
2288
|
-
const DropdownMenuLabel = cn$1.withVariants(
|
|
2289
|
-
DropdownMenuPrimitive__namespace.Label,
|
|
2290
|
-
dropdownMenuLabelVariants,
|
|
2291
|
-
["inset"]
|
|
2292
|
-
);
|
|
2293
|
-
const DropdownMenuSeparator = cn$1.withCn(
|
|
2294
|
-
DropdownMenuPrimitive__namespace.Separator,
|
|
2295
|
-
"-mx-1 my-1 h-px bg-muted"
|
|
2296
|
-
);
|
|
2297
|
-
cn$1.withCn(
|
|
2298
|
-
cn$1.createPrimitiveElement("span"),
|
|
2299
|
-
"ml-auto text-xs tracking-widest opacity-60"
|
|
2300
|
-
);
|
|
2301
|
-
const useOpenState = () => {
|
|
2302
|
-
const [open2, setOpen] = React.useState(false);
|
|
2303
|
-
const onOpenChange = React.useCallback(
|
|
2304
|
-
(_value = !open2) => {
|
|
2305
|
-
setOpen(_value);
|
|
2306
|
-
},
|
|
2307
|
-
[open2]
|
|
2308
|
-
);
|
|
2309
|
-
return {
|
|
2310
|
-
onOpenChange,
|
|
2311
|
-
open: open2
|
|
2312
|
-
};
|
|
2313
|
-
};
|
|
2314
|
-
const Popover$2 = PopoverPrimitive__namespace.Root;
|
|
2315
|
-
const popoverVariants = classVarianceAuthority.cva(
|
|
2316
|
-
"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"
|
|
2317
|
-
);
|
|
2318
|
-
const PopoverContent$1 = cn$1.withRef(
|
|
2319
|
-
({ align = "center", className, sideOffset = 4, style, ...props }, ref) => /* @__PURE__ */ React__namespace.createElement(PopoverPrimitive__namespace.Portal, null, /* @__PURE__ */ React__namespace.createElement(
|
|
2320
|
-
PopoverPrimitive__namespace.Content,
|
|
2321
|
-
{
|
|
2322
|
-
align,
|
|
2323
|
-
className: cn$1.cn(popoverVariants(), className),
|
|
2324
|
-
ref,
|
|
2325
|
-
sideOffset,
|
|
2326
|
-
style: { zIndex: 1e3, ...style },
|
|
2327
|
-
...props
|
|
2328
|
-
}
|
|
2329
|
-
))
|
|
2330
|
-
);
|
|
2331
|
-
const separatorVariants = classVarianceAuthority.cva("shrink-0 bg-border", {
|
|
2332
|
-
defaultVariants: {
|
|
2333
|
-
orientation: "horizontal"
|
|
2334
|
-
},
|
|
2335
|
-
variants: {
|
|
2336
|
-
orientation: {
|
|
2337
|
-
horizontal: "h-px w-full",
|
|
2338
|
-
vertical: "h-full w-px"
|
|
2339
|
-
}
|
|
2340
|
-
}
|
|
2341
|
-
});
|
|
2342
|
-
const Separator = cn$1.withVariants(
|
|
2343
|
-
cn$1.withProps(SeparatorPrimitive__namespace.Root, {
|
|
2344
|
-
decorative: true,
|
|
2345
|
-
orientation: "horizontal"
|
|
2346
|
-
}),
|
|
2347
|
-
separatorVariants
|
|
2348
|
-
);
|
|
2349
|
-
const TableBordersDropdownMenuContent = cn$1.withRef((props, ref) => {
|
|
2350
|
-
const {
|
|
2351
|
-
getOnSelectTableBorder,
|
|
2352
|
-
hasBottomBorder,
|
|
2353
|
-
hasLeftBorder,
|
|
2354
|
-
hasNoBorders,
|
|
2355
|
-
hasOuterBorders,
|
|
2356
|
-
hasRightBorder,
|
|
2357
|
-
hasTopBorder
|
|
2358
|
-
} = plateTable.useTableBordersDropdownMenuContentState();
|
|
2359
|
-
return /* @__PURE__ */ React.createElement(
|
|
2360
|
-
DropdownMenuContent,
|
|
2361
|
-
{
|
|
2362
|
-
align: "start",
|
|
2363
|
-
className: cn$1.cn("min-w-[220px]"),
|
|
2364
|
-
ref,
|
|
2365
|
-
side: "right",
|
|
2366
|
-
sideOffset: 0,
|
|
2367
|
-
...props
|
|
2368
|
-
},
|
|
2369
|
-
/* @__PURE__ */ React.createElement(
|
|
2370
|
-
DropdownMenuCheckboxItem,
|
|
2371
|
-
{
|
|
2372
|
-
checked: hasBottomBorder,
|
|
2373
|
-
onCheckedChange: getOnSelectTableBorder("bottom")
|
|
2374
|
-
},
|
|
2375
|
-
/* @__PURE__ */ React.createElement(Icons.borderBottom, { className: iconVariants({ size: "sm" }) }),
|
|
2376
|
-
/* @__PURE__ */ React.createElement("div", null, "Bottom Border")
|
|
2377
|
-
),
|
|
2378
|
-
/* @__PURE__ */ React.createElement(
|
|
2379
|
-
DropdownMenuCheckboxItem,
|
|
2380
|
-
{
|
|
2381
|
-
checked: hasTopBorder,
|
|
2382
|
-
onCheckedChange: getOnSelectTableBorder("top")
|
|
2383
|
-
},
|
|
2384
|
-
/* @__PURE__ */ React.createElement(Icons.borderTop, { className: iconVariants({ size: "sm" }) }),
|
|
2385
|
-
/* @__PURE__ */ React.createElement("div", null, "Top Border")
|
|
2386
|
-
),
|
|
2387
|
-
/* @__PURE__ */ React.createElement(
|
|
2388
|
-
DropdownMenuCheckboxItem,
|
|
2389
|
-
{
|
|
2390
|
-
checked: hasLeftBorder,
|
|
2391
|
-
onCheckedChange: getOnSelectTableBorder("left")
|
|
2392
|
-
},
|
|
2393
|
-
/* @__PURE__ */ React.createElement(Icons.borderLeft, { className: iconVariants({ size: "sm" }) }),
|
|
2394
|
-
/* @__PURE__ */ React.createElement("div", null, "Left Border")
|
|
2395
|
-
),
|
|
2396
|
-
/* @__PURE__ */ React.createElement(
|
|
2397
|
-
DropdownMenuCheckboxItem,
|
|
2398
|
-
{
|
|
2399
|
-
checked: hasRightBorder,
|
|
2400
|
-
onCheckedChange: getOnSelectTableBorder("right")
|
|
2401
|
-
},
|
|
2402
|
-
/* @__PURE__ */ React.createElement(Icons.borderRight, { className: iconVariants({ size: "sm" }) }),
|
|
2403
|
-
/* @__PURE__ */ React.createElement("div", null, "Right Border")
|
|
2404
|
-
),
|
|
2405
|
-
/* @__PURE__ */ React.createElement(Separator, null),
|
|
2406
|
-
/* @__PURE__ */ React.createElement(
|
|
2407
|
-
DropdownMenuCheckboxItem,
|
|
2408
|
-
{
|
|
2409
|
-
checked: hasNoBorders,
|
|
2410
|
-
onCheckedChange: getOnSelectTableBorder("none")
|
|
2411
|
-
},
|
|
2412
|
-
/* @__PURE__ */ React.createElement(Icons.borderNone, { className: iconVariants({ size: "sm" }) }),
|
|
2413
|
-
/* @__PURE__ */ React.createElement("div", null, "No Border")
|
|
2414
|
-
),
|
|
2415
|
-
/* @__PURE__ */ React.createElement(
|
|
2416
|
-
DropdownMenuCheckboxItem,
|
|
2417
|
-
{
|
|
2418
|
-
checked: hasOuterBorders,
|
|
2419
|
-
onCheckedChange: getOnSelectTableBorder("outer")
|
|
2420
|
-
},
|
|
2421
|
-
/* @__PURE__ */ React.createElement(Icons.borderAll, { className: iconVariants({ size: "sm" }) }),
|
|
2422
|
-
/* @__PURE__ */ React.createElement("div", null, "Outside Borders")
|
|
2423
|
-
)
|
|
2424
|
-
);
|
|
2425
|
-
});
|
|
2426
|
-
const TableFloatingToolbar = cn$1.withRef(
|
|
2427
|
-
({ children, ...props }, ref) => {
|
|
2428
|
-
const element = plateCommon.useElement();
|
|
2429
|
-
const { props: buttonProps } = plateCommon.useRemoveNodeButton({ element });
|
|
2430
|
-
const selectionCollapsed = plateCommon.useEditorSelector(
|
|
2431
|
-
(editor2) => !plateCommon.isSelectionExpanded(editor2),
|
|
2432
|
-
[]
|
|
2433
|
-
);
|
|
2434
|
-
const readOnly = slateReact.useReadOnly();
|
|
2435
|
-
const selected = slateReact.useSelected();
|
|
2436
|
-
const editor = plateCommon.useEditorRef();
|
|
2437
|
-
const collapsed = !readOnly && selected && selectionCollapsed;
|
|
2438
|
-
const open2 = !readOnly && selected;
|
|
2439
|
-
const { canMerge, canUnmerge } = plateTable.useTableMergeState();
|
|
2440
|
-
const mergeContent = canMerge && /* @__PURE__ */ React.createElement(
|
|
2441
|
-
Button$2,
|
|
2442
|
-
{
|
|
2443
|
-
contentEditable: false,
|
|
2444
|
-
isMenu: true,
|
|
2445
|
-
onClick: () => plateTable.mergeTableCells(editor),
|
|
2446
|
-
variant: "ghost"
|
|
2447
|
-
},
|
|
2448
|
-
/* @__PURE__ */ React.createElement(Icons.combine, { className: "mr-2 size-4" }),
|
|
2449
|
-
"Merge"
|
|
2450
|
-
);
|
|
2451
|
-
const unmergeButton = canUnmerge && /* @__PURE__ */ React.createElement(
|
|
2452
|
-
Button$2,
|
|
2453
|
-
{
|
|
2454
|
-
contentEditable: false,
|
|
2455
|
-
isMenu: true,
|
|
2456
|
-
onClick: () => plateTable.unmergeTableCells(editor),
|
|
2457
|
-
variant: "ghost"
|
|
2458
|
-
},
|
|
2459
|
-
/* @__PURE__ */ React.createElement(Icons.ungroup, { className: "mr-2 size-4" }),
|
|
2460
|
-
"Unmerge"
|
|
2461
|
-
);
|
|
2462
|
-
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"));
|
|
2463
|
-
return /* @__PURE__ */ React.createElement(Popover$2, { modal: false, open: open2 }, /* @__PURE__ */ React.createElement(PopoverPrimitive.PopoverAnchor, { asChild: true }, children), (canMerge || canUnmerge || collapsed) && /* @__PURE__ */ React.createElement(
|
|
2464
|
-
PopoverContent$1,
|
|
2465
|
-
{
|
|
2466
|
-
className: cn$1.cn(
|
|
2467
|
-
popoverVariants(),
|
|
2468
|
-
"flex w-[220px] flex-col gap-1 p-1"
|
|
2469
|
-
),
|
|
2470
|
-
onOpenAutoFocus: (e) => e.preventDefault(),
|
|
2471
|
-
ref,
|
|
2472
|
-
...props
|
|
2473
|
-
},
|
|
2474
|
-
unmergeButton,
|
|
2475
|
-
mergeContent,
|
|
2476
|
-
bordersContent
|
|
2477
|
-
));
|
|
2478
|
-
}
|
|
2479
|
-
);
|
|
2480
|
-
const TableElement = plateCommon.withHOC(
|
|
2481
|
-
plateTable.TableProvider,
|
|
2482
|
-
cn$1.withRef(({ children, className, ...props }, ref) => {
|
|
2483
|
-
const { colSizes, isSelectingCell, marginLeft, minColumnWidth } = plateTable.useTableElementState();
|
|
2484
|
-
const { colGroupProps, props: tableProps } = plateTable.useTableElement();
|
|
2485
|
-
return /* @__PURE__ */ React.createElement(TableFloatingToolbar, null, /* @__PURE__ */ React.createElement("div", { style: { paddingLeft: marginLeft } }, /* @__PURE__ */ React.createElement(
|
|
2486
|
-
plateCommon.PlateElement,
|
|
2487
|
-
{
|
|
2488
|
-
asChild: true,
|
|
2489
|
-
className: cn$1.cn(
|
|
2490
|
-
"my-4 ml-px mr-0 table h-px w-full table-fixed border-collapse",
|
|
2491
|
-
isSelectingCell && "[&_*::selection]:bg-none",
|
|
2492
|
-
className
|
|
2493
|
-
),
|
|
2494
|
-
ref,
|
|
2495
|
-
...tableProps,
|
|
2496
|
-
...props
|
|
2497
|
-
},
|
|
2498
|
-
/* @__PURE__ */ React.createElement("table", null, /* @__PURE__ */ React.createElement("colgroup", { ...colGroupProps }, colSizes.map((width, index) => /* @__PURE__ */ React.createElement(
|
|
2499
|
-
"col",
|
|
2500
|
-
{
|
|
2501
|
-
key: index,
|
|
2502
|
-
style: {
|
|
2503
|
-
minWidth: minColumnWidth,
|
|
2504
|
-
width: width || void 0
|
|
2505
|
-
}
|
|
2506
|
-
}
|
|
2507
|
-
))), /* @__PURE__ */ React.createElement("tbody", { className: "min-w-full" }, children))
|
|
2508
|
-
)));
|
|
2509
|
-
})
|
|
2510
|
-
);
|
|
2511
|
-
const TableRowElement = cn$1.withRef(({ children, hideBorder, ...props }, ref) => {
|
|
2512
|
-
return /* @__PURE__ */ React.createElement(
|
|
2513
|
-
plateCommon.PlateElement,
|
|
2514
|
-
{
|
|
2515
|
-
asChild: true,
|
|
2516
|
-
className: cn$1.cn("h-full", hideBorder && "border-none"),
|
|
2517
|
-
ref,
|
|
2518
|
-
...props
|
|
2519
|
-
},
|
|
2520
|
-
/* @__PURE__ */ React.createElement("tr", null, children)
|
|
2521
|
-
);
|
|
2522
|
-
});
|
|
2523
2299
|
const TableCellElement = cn$1.withRef(({ children, className, hideBorder, isHeader, style, ...props }, ref) => {
|
|
2524
2300
|
var _a, _b, _c, _d;
|
|
2525
2301
|
const { element } = props;
|
|
@@ -2631,6 +2407,371 @@ var __publicField = (obj, key, value) => {
|
|
|
2631
2407
|
const TableCellHeaderElement = cn$1.withProps(TableCellElement, {
|
|
2632
2408
|
isHeader: true
|
|
2633
2409
|
});
|
|
2410
|
+
const buttonVariants$1 = classVarianceAuthority.cva(
|
|
2411
|
+
"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",
|
|
2412
|
+
{
|
|
2413
|
+
defaultVariants: {
|
|
2414
|
+
size: "default",
|
|
2415
|
+
variant: "default"
|
|
2416
|
+
},
|
|
2417
|
+
variants: {
|
|
2418
|
+
isMenu: {
|
|
2419
|
+
true: "h-auto w-full cursor-pointer justify-start"
|
|
2420
|
+
},
|
|
2421
|
+
size: {
|
|
2422
|
+
default: "h-10 px-4 py-2",
|
|
2423
|
+
icon: "size-10",
|
|
2424
|
+
lg: "h-11 rounded-md px-8",
|
|
2425
|
+
none: "",
|
|
2426
|
+
sm: "h-9 rounded-md px-3",
|
|
2427
|
+
sms: "size-9 rounded-md px-0",
|
|
2428
|
+
xs: "h-8 rounded-md px-3"
|
|
2429
|
+
},
|
|
2430
|
+
variant: {
|
|
2431
|
+
default: "bg-primary text-primary-foreground hover:bg-primary/90",
|
|
2432
|
+
destructive: "bg-destructive text-destructive-foreground hover:bg-destructive/90",
|
|
2433
|
+
ghost: "hover:bg-accent hover:text-accent-foreground",
|
|
2434
|
+
inlineLink: "text-base text-primary underline underline-offset-4",
|
|
2435
|
+
link: "text-primary underline-offset-4 hover:underline",
|
|
2436
|
+
outline: "border border-input bg-background hover:bg-accent hover:text-accent-foreground",
|
|
2437
|
+
secondary: "bg-secondary text-secondary-foreground hover:bg-secondary/80"
|
|
2438
|
+
}
|
|
2439
|
+
}
|
|
2440
|
+
}
|
|
2441
|
+
);
|
|
2442
|
+
const Button$2 = cn$1.withRef(({ asChild = false, className, isMenu, size, variant, ...props }, ref) => {
|
|
2443
|
+
const Comp = asChild ? reactSlot.Slot : "button";
|
|
2444
|
+
return /* @__PURE__ */ React__namespace.createElement(
|
|
2445
|
+
Comp,
|
|
2446
|
+
{
|
|
2447
|
+
className: cn$1.cn(buttonVariants$1({ className, isMenu, size, variant })),
|
|
2448
|
+
ref,
|
|
2449
|
+
...props
|
|
2450
|
+
}
|
|
2451
|
+
);
|
|
2452
|
+
});
|
|
2453
|
+
const DropdownMenu = DropdownMenuPrimitive__namespace.Root;
|
|
2454
|
+
const DropdownMenuTrigger = DropdownMenuPrimitive__namespace.Trigger;
|
|
2455
|
+
const DropdownMenuPortal = DropdownMenuPrimitive__namespace.Portal;
|
|
2456
|
+
const DropdownMenuSub = DropdownMenuPrimitive__namespace.Sub;
|
|
2457
|
+
const DropdownMenuRadioGroup = DropdownMenuPrimitive__namespace.RadioGroup;
|
|
2458
|
+
const DropdownMenuSubTrigger = cn$1.withRef(({ children, className, inset, ...props }, ref) => /* @__PURE__ */ React.createElement(
|
|
2459
|
+
DropdownMenuPrimitive__namespace.SubTrigger,
|
|
2460
|
+
{
|
|
2461
|
+
className: cn$1.cn(
|
|
2462
|
+
"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",
|
|
2463
|
+
"data-[disabled]:pointer-events-none data-[disabled]:opacity-50",
|
|
2464
|
+
inset && "pl-8",
|
|
2465
|
+
className
|
|
2466
|
+
),
|
|
2467
|
+
ref,
|
|
2468
|
+
...props
|
|
2469
|
+
},
|
|
2470
|
+
children,
|
|
2471
|
+
/* @__PURE__ */ React.createElement(Icons.chevronRight, { className: "ml-auto size-4" })
|
|
2472
|
+
));
|
|
2473
|
+
const DropdownMenuSubContent = cn$1.withCn(
|
|
2474
|
+
DropdownMenuPrimitive__namespace.SubContent,
|
|
2475
|
+
"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"
|
|
2476
|
+
);
|
|
2477
|
+
const DropdownMenuContentVariants = cn$1.withProps(DropdownMenuPrimitive__namespace.Content, {
|
|
2478
|
+
className: cn$1.cn(
|
|
2479
|
+
"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"
|
|
2480
|
+
),
|
|
2481
|
+
sideOffset: 4
|
|
2482
|
+
});
|
|
2483
|
+
const DropdownMenuContent = cn$1.withRef(({ ...props }, ref) => /* @__PURE__ */ React.createElement(DropdownMenuPrimitive__namespace.Portal, null, /* @__PURE__ */ React.createElement(DropdownMenuContentVariants, { ref, ...props })));
|
|
2484
|
+
const menuItemVariants = classVarianceAuthority.cva(
|
|
2485
|
+
cn$1.cn(
|
|
2486
|
+
"relative flex h-9 cursor-pointer select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none transition-colors",
|
|
2487
|
+
"focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50"
|
|
2488
|
+
),
|
|
2489
|
+
{
|
|
2490
|
+
variants: {
|
|
2491
|
+
inset: {
|
|
2492
|
+
true: "pl-8"
|
|
2493
|
+
}
|
|
2494
|
+
}
|
|
2495
|
+
}
|
|
2496
|
+
);
|
|
2497
|
+
const DropdownMenuItem = cn$1.withVariants(
|
|
2498
|
+
DropdownMenuPrimitive__namespace.Item,
|
|
2499
|
+
menuItemVariants,
|
|
2500
|
+
["inset"]
|
|
2501
|
+
);
|
|
2502
|
+
const DropdownMenuCheckboxItem = cn$1.withRef(({ children, className, ...props }, ref) => /* @__PURE__ */ React.createElement(
|
|
2503
|
+
DropdownMenuPrimitive__namespace.CheckboxItem,
|
|
2504
|
+
{
|
|
2505
|
+
className: cn$1.cn(
|
|
2506
|
+
"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",
|
|
2507
|
+
"cursor-pointer",
|
|
2508
|
+
className
|
|
2509
|
+
),
|
|
2510
|
+
ref,
|
|
2511
|
+
...props
|
|
2512
|
+
},
|
|
2513
|
+
/* @__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" }))),
|
|
2514
|
+
children
|
|
2515
|
+
));
|
|
2516
|
+
const DropdownMenuRadioItem = cn$1.withRef(({ children, className, hideIcon, ...props }, ref) => /* @__PURE__ */ React.createElement(
|
|
2517
|
+
DropdownMenuPrimitive__namespace.RadioItem,
|
|
2518
|
+
{
|
|
2519
|
+
className: cn$1.cn(
|
|
2520
|
+
"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",
|
|
2521
|
+
"h-9 cursor-pointer px-2 data-[state=checked]:bg-accent data-[state=checked]:text-accent-foreground",
|
|
2522
|
+
className
|
|
2523
|
+
),
|
|
2524
|
+
ref,
|
|
2525
|
+
...props
|
|
2526
|
+
},
|
|
2527
|
+
!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" }))),
|
|
2528
|
+
children
|
|
2529
|
+
));
|
|
2530
|
+
const dropdownMenuLabelVariants = classVarianceAuthority.cva(
|
|
2531
|
+
cn$1.cn("select-none px-2 py-1.5 text-sm font-semibold"),
|
|
2532
|
+
{
|
|
2533
|
+
variants: {
|
|
2534
|
+
inset: {
|
|
2535
|
+
true: "pl-8"
|
|
2536
|
+
}
|
|
2537
|
+
}
|
|
2538
|
+
}
|
|
2539
|
+
);
|
|
2540
|
+
const DropdownMenuLabel = cn$1.withVariants(
|
|
2541
|
+
DropdownMenuPrimitive__namespace.Label,
|
|
2542
|
+
dropdownMenuLabelVariants,
|
|
2543
|
+
["inset"]
|
|
2544
|
+
);
|
|
2545
|
+
const DropdownMenuSeparator = cn$1.withCn(
|
|
2546
|
+
DropdownMenuPrimitive__namespace.Separator,
|
|
2547
|
+
"-mx-1 my-1 h-px bg-muted"
|
|
2548
|
+
);
|
|
2549
|
+
cn$1.withCn(
|
|
2550
|
+
cn$1.createPrimitiveElement("span"),
|
|
2551
|
+
"ml-auto text-xs tracking-widest opacity-60"
|
|
2552
|
+
);
|
|
2553
|
+
const useOpenState = () => {
|
|
2554
|
+
const [open2, setOpen] = React.useState(false);
|
|
2555
|
+
const onOpenChange = React.useCallback(
|
|
2556
|
+
(_value = !open2) => {
|
|
2557
|
+
setOpen(_value);
|
|
2558
|
+
},
|
|
2559
|
+
[open2]
|
|
2560
|
+
);
|
|
2561
|
+
return {
|
|
2562
|
+
onOpenChange,
|
|
2563
|
+
open: open2
|
|
2564
|
+
};
|
|
2565
|
+
};
|
|
2566
|
+
const Popover$2 = PopoverPrimitive__namespace.Root;
|
|
2567
|
+
const popoverVariants = classVarianceAuthority.cva(
|
|
2568
|
+
"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"
|
|
2569
|
+
);
|
|
2570
|
+
const PopoverContent$1 = cn$1.withRef(
|
|
2571
|
+
({ align = "center", className, sideOffset = 4, style, ...props }, ref) => /* @__PURE__ */ React__namespace.createElement(PopoverPrimitive__namespace.Portal, null, /* @__PURE__ */ React__namespace.createElement(
|
|
2572
|
+
PopoverPrimitive__namespace.Content,
|
|
2573
|
+
{
|
|
2574
|
+
align,
|
|
2575
|
+
className: cn$1.cn(popoverVariants(), className),
|
|
2576
|
+
ref,
|
|
2577
|
+
sideOffset,
|
|
2578
|
+
style: { zIndex: 1e3, ...style },
|
|
2579
|
+
...props
|
|
2580
|
+
}
|
|
2581
|
+
))
|
|
2582
|
+
);
|
|
2583
|
+
const separatorVariants = classVarianceAuthority.cva("shrink-0 bg-border", {
|
|
2584
|
+
defaultVariants: {
|
|
2585
|
+
orientation: "horizontal"
|
|
2586
|
+
},
|
|
2587
|
+
variants: {
|
|
2588
|
+
orientation: {
|
|
2589
|
+
horizontal: "h-px w-full",
|
|
2590
|
+
vertical: "h-full w-px"
|
|
2591
|
+
}
|
|
2592
|
+
}
|
|
2593
|
+
});
|
|
2594
|
+
const Separator = cn$1.withVariants(
|
|
2595
|
+
cn$1.withProps(SeparatorPrimitive__namespace.Root, {
|
|
2596
|
+
decorative: true,
|
|
2597
|
+
orientation: "horizontal"
|
|
2598
|
+
}),
|
|
2599
|
+
separatorVariants
|
|
2600
|
+
);
|
|
2601
|
+
const TableBordersDropdownMenuContent = cn$1.withRef((props, ref) => {
|
|
2602
|
+
const {
|
|
2603
|
+
getOnSelectTableBorder,
|
|
2604
|
+
hasBottomBorder,
|
|
2605
|
+
hasLeftBorder,
|
|
2606
|
+
hasNoBorders,
|
|
2607
|
+
hasOuterBorders,
|
|
2608
|
+
hasRightBorder,
|
|
2609
|
+
hasTopBorder
|
|
2610
|
+
} = plateTable.useTableBordersDropdownMenuContentState();
|
|
2611
|
+
return /* @__PURE__ */ React.createElement(
|
|
2612
|
+
DropdownMenuContent,
|
|
2613
|
+
{
|
|
2614
|
+
align: "start",
|
|
2615
|
+
className: cn$1.cn("min-w-[220px]"),
|
|
2616
|
+
ref,
|
|
2617
|
+
side: "right",
|
|
2618
|
+
sideOffset: 0,
|
|
2619
|
+
...props
|
|
2620
|
+
},
|
|
2621
|
+
/* @__PURE__ */ React.createElement(
|
|
2622
|
+
DropdownMenuCheckboxItem,
|
|
2623
|
+
{
|
|
2624
|
+
checked: hasBottomBorder,
|
|
2625
|
+
onCheckedChange: getOnSelectTableBorder("bottom")
|
|
2626
|
+
},
|
|
2627
|
+
/* @__PURE__ */ React.createElement(Icons.borderBottom, { className: iconVariants({ size: "sm" }) }),
|
|
2628
|
+
/* @__PURE__ */ React.createElement("div", null, "Bottom Border")
|
|
2629
|
+
),
|
|
2630
|
+
/* @__PURE__ */ React.createElement(
|
|
2631
|
+
DropdownMenuCheckboxItem,
|
|
2632
|
+
{
|
|
2633
|
+
checked: hasTopBorder,
|
|
2634
|
+
onCheckedChange: getOnSelectTableBorder("top")
|
|
2635
|
+
},
|
|
2636
|
+
/* @__PURE__ */ React.createElement(Icons.borderTop, { className: iconVariants({ size: "sm" }) }),
|
|
2637
|
+
/* @__PURE__ */ React.createElement("div", null, "Top Border")
|
|
2638
|
+
),
|
|
2639
|
+
/* @__PURE__ */ React.createElement(
|
|
2640
|
+
DropdownMenuCheckboxItem,
|
|
2641
|
+
{
|
|
2642
|
+
checked: hasLeftBorder,
|
|
2643
|
+
onCheckedChange: getOnSelectTableBorder("left")
|
|
2644
|
+
},
|
|
2645
|
+
/* @__PURE__ */ React.createElement(Icons.borderLeft, { className: iconVariants({ size: "sm" }) }),
|
|
2646
|
+
/* @__PURE__ */ React.createElement("div", null, "Left Border")
|
|
2647
|
+
),
|
|
2648
|
+
/* @__PURE__ */ React.createElement(
|
|
2649
|
+
DropdownMenuCheckboxItem,
|
|
2650
|
+
{
|
|
2651
|
+
checked: hasRightBorder,
|
|
2652
|
+
onCheckedChange: getOnSelectTableBorder("right")
|
|
2653
|
+
},
|
|
2654
|
+
/* @__PURE__ */ React.createElement(Icons.borderRight, { className: iconVariants({ size: "sm" }) }),
|
|
2655
|
+
/* @__PURE__ */ React.createElement("div", null, "Right Border")
|
|
2656
|
+
),
|
|
2657
|
+
/* @__PURE__ */ React.createElement(Separator, null),
|
|
2658
|
+
/* @__PURE__ */ React.createElement(
|
|
2659
|
+
DropdownMenuCheckboxItem,
|
|
2660
|
+
{
|
|
2661
|
+
checked: hasNoBorders,
|
|
2662
|
+
onCheckedChange: getOnSelectTableBorder("none")
|
|
2663
|
+
},
|
|
2664
|
+
/* @__PURE__ */ React.createElement(Icons.borderNone, { className: iconVariants({ size: "sm" }) }),
|
|
2665
|
+
/* @__PURE__ */ React.createElement("div", null, "No Border")
|
|
2666
|
+
),
|
|
2667
|
+
/* @__PURE__ */ React.createElement(
|
|
2668
|
+
DropdownMenuCheckboxItem,
|
|
2669
|
+
{
|
|
2670
|
+
checked: hasOuterBorders,
|
|
2671
|
+
onCheckedChange: getOnSelectTableBorder("outer")
|
|
2672
|
+
},
|
|
2673
|
+
/* @__PURE__ */ React.createElement(Icons.borderAll, { className: iconVariants({ size: "sm" }) }),
|
|
2674
|
+
/* @__PURE__ */ React.createElement("div", null, "Outside Borders")
|
|
2675
|
+
)
|
|
2676
|
+
);
|
|
2677
|
+
});
|
|
2678
|
+
const TableFloatingToolbar = cn$1.withRef(
|
|
2679
|
+
({ children, ...props }, ref) => {
|
|
2680
|
+
const element = plateCommon.useElement();
|
|
2681
|
+
const { props: buttonProps } = plateCommon.useRemoveNodeButton({ element });
|
|
2682
|
+
const selectionCollapsed = plateCommon.useEditorSelector(
|
|
2683
|
+
(editor2) => !plateCommon.isSelectionExpanded(editor2),
|
|
2684
|
+
[]
|
|
2685
|
+
);
|
|
2686
|
+
const readOnly = slateReact.useReadOnly();
|
|
2687
|
+
const selected = slateReact.useSelected();
|
|
2688
|
+
const editor = plateCommon.useEditorRef();
|
|
2689
|
+
const collapsed = !readOnly && selected && selectionCollapsed;
|
|
2690
|
+
const open2 = !readOnly && selected;
|
|
2691
|
+
const { canMerge, canUnmerge } = plateTable.useTableMergeState();
|
|
2692
|
+
const mergeContent = canMerge && /* @__PURE__ */ React.createElement(
|
|
2693
|
+
Button$2,
|
|
2694
|
+
{
|
|
2695
|
+
contentEditable: false,
|
|
2696
|
+
isMenu: true,
|
|
2697
|
+
onClick: () => plateTable.mergeTableCells(editor),
|
|
2698
|
+
variant: "ghost"
|
|
2699
|
+
},
|
|
2700
|
+
/* @__PURE__ */ React.createElement(Icons.combine, { className: "mr-2 size-4" }),
|
|
2701
|
+
"Merge"
|
|
2702
|
+
);
|
|
2703
|
+
const unmergeButton = canUnmerge && /* @__PURE__ */ React.createElement(
|
|
2704
|
+
Button$2,
|
|
2705
|
+
{
|
|
2706
|
+
contentEditable: false,
|
|
2707
|
+
isMenu: true,
|
|
2708
|
+
onClick: () => plateTable.unmergeTableCells(editor),
|
|
2709
|
+
variant: "ghost"
|
|
2710
|
+
},
|
|
2711
|
+
/* @__PURE__ */ React.createElement(Icons.ungroup, { className: "mr-2 size-4" }),
|
|
2712
|
+
"Unmerge"
|
|
2713
|
+
);
|
|
2714
|
+
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"));
|
|
2715
|
+
return /* @__PURE__ */ React.createElement(Popover$2, { modal: false, open: open2 }, /* @__PURE__ */ React.createElement(PopoverPrimitive.PopoverAnchor, { asChild: true }, children), (canMerge || canUnmerge || collapsed) && /* @__PURE__ */ React.createElement(
|
|
2716
|
+
PopoverContent$1,
|
|
2717
|
+
{
|
|
2718
|
+
className: cn$1.cn(
|
|
2719
|
+
popoverVariants(),
|
|
2720
|
+
"flex w-[220px] flex-col gap-1 p-1"
|
|
2721
|
+
),
|
|
2722
|
+
onOpenAutoFocus: (e) => e.preventDefault(),
|
|
2723
|
+
ref,
|
|
2724
|
+
...props
|
|
2725
|
+
},
|
|
2726
|
+
unmergeButton,
|
|
2727
|
+
mergeContent,
|
|
2728
|
+
bordersContent
|
|
2729
|
+
));
|
|
2730
|
+
}
|
|
2731
|
+
);
|
|
2732
|
+
const TableElement = plateCommon.withHOC(
|
|
2733
|
+
plateTable.TableProvider,
|
|
2734
|
+
cn$1.withRef(({ children, className, ...props }, ref) => {
|
|
2735
|
+
const { colSizes, isSelectingCell, marginLeft, minColumnWidth } = plateTable.useTableElementState();
|
|
2736
|
+
const { colGroupProps, props: tableProps } = plateTable.useTableElement();
|
|
2737
|
+
return /* @__PURE__ */ React.createElement(TableFloatingToolbar, null, /* @__PURE__ */ React.createElement("div", { style: { paddingLeft: marginLeft } }, /* @__PURE__ */ React.createElement(
|
|
2738
|
+
plateCommon.PlateElement,
|
|
2739
|
+
{
|
|
2740
|
+
asChild: true,
|
|
2741
|
+
className: cn$1.cn(
|
|
2742
|
+
"my-4 ml-px mr-0 table h-px w-full table-fixed border-collapse",
|
|
2743
|
+
isSelectingCell && "[&_*::selection]:bg-none",
|
|
2744
|
+
className
|
|
2745
|
+
),
|
|
2746
|
+
ref,
|
|
2747
|
+
...tableProps,
|
|
2748
|
+
...props
|
|
2749
|
+
},
|
|
2750
|
+
/* @__PURE__ */ React.createElement("table", null, /* @__PURE__ */ React.createElement("colgroup", { ...colGroupProps }, colSizes.map((width, index) => /* @__PURE__ */ React.createElement(
|
|
2751
|
+
"col",
|
|
2752
|
+
{
|
|
2753
|
+
key: index,
|
|
2754
|
+
style: {
|
|
2755
|
+
minWidth: minColumnWidth,
|
|
2756
|
+
width: width || void 0
|
|
2757
|
+
}
|
|
2758
|
+
}
|
|
2759
|
+
))), /* @__PURE__ */ React.createElement("tbody", { className: "min-w-full" }, children))
|
|
2760
|
+
)));
|
|
2761
|
+
})
|
|
2762
|
+
);
|
|
2763
|
+
const TableRowElement = cn$1.withRef(({ children, hideBorder, ...props }, ref) => {
|
|
2764
|
+
return /* @__PURE__ */ React.createElement(
|
|
2765
|
+
plateCommon.PlateElement,
|
|
2766
|
+
{
|
|
2767
|
+
asChild: true,
|
|
2768
|
+
className: cn$1.cn("h-full", hideBorder && "border-none"),
|
|
2769
|
+
ref,
|
|
2770
|
+
...props
|
|
2771
|
+
},
|
|
2772
|
+
/* @__PURE__ */ React.createElement("tr", null, children)
|
|
2773
|
+
);
|
|
2774
|
+
});
|
|
2634
2775
|
const blockClasses = "mt-0.5";
|
|
2635
2776
|
const headerClasses = "font-normal";
|
|
2636
2777
|
const Components = () => {
|
|
@@ -2736,6 +2877,7 @@ var __publicField = (obj, key, value) => {
|
|
|
2736
2877
|
}
|
|
2737
2878
|
)
|
|
2738
2879
|
),
|
|
2880
|
+
[ELEMENT_MERMAID]: MermaidElement,
|
|
2739
2881
|
[plate.ELEMENT_BLOCKQUOTE]: BlockquoteElement,
|
|
2740
2882
|
[plate.ELEMENT_CODE_BLOCK]: CodeBlockElement,
|
|
2741
2883
|
[plate.ELEMENT_CODE_LINE]: CodeLineElement,
|
|
@@ -3230,7 +3372,9 @@ var __publicField = (obj, key, value) => {
|
|
|
3230
3372
|
{
|
|
3231
3373
|
type: "string",
|
|
3232
3374
|
label: "Caption",
|
|
3233
|
-
name: [templateName.replace(/\.props$/, ""), "caption"].join(
|
|
3375
|
+
name: [templateName.replace(/\.props$/, ""), "caption"].join(
|
|
3376
|
+
"."
|
|
3377
|
+
),
|
|
3234
3378
|
component: "text"
|
|
3235
3379
|
}
|
|
3236
3380
|
]
|
|
@@ -3548,7 +3692,7 @@ var __publicField = (obj, key, value) => {
|
|
|
3548
3692
|
};
|
|
3549
3693
|
const sizeClasses = {
|
|
3550
3694
|
small: `text-xs h-8 px-3`,
|
|
3551
|
-
medium: `text-sm h-10 px-
|
|
3695
|
+
medium: `text-sm h-10 px-8`,
|
|
3552
3696
|
custom: ``
|
|
3553
3697
|
};
|
|
3554
3698
|
return /* @__PURE__ */ React__namespace.createElement(
|
|
@@ -5582,10 +5726,11 @@ var __publicField = (obj, key, value) => {
|
|
|
5582
5726
|
return /* @__PURE__ */ React.createElement(
|
|
5583
5727
|
"button",
|
|
5584
5728
|
{
|
|
5585
|
-
|
|
5729
|
+
type: "button",
|
|
5730
|
+
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"}`,
|
|
5586
5731
|
onClick
|
|
5587
5732
|
},
|
|
5588
|
-
/* @__PURE__ */ React.createElement(TrashIcon, { className: "fill-current transition-colors ease-out
|
|
5733
|
+
/* @__PURE__ */ React.createElement(TrashIcon, { className: "h-5 w-auto fill-current text-red-500 transition-colors duration-150 ease-out" })
|
|
5589
5734
|
);
|
|
5590
5735
|
};
|
|
5591
5736
|
const DragHandle = ({ isDragging }) => {
|
|
@@ -5615,7 +5760,7 @@ var __publicField = (obj, key, value) => {
|
|
|
5615
5760
|
return template.label ? template.label.toLowerCase().includes(filter.toLowerCase()) || name.toLowerCase().includes(filter.toLowerCase()) : name.toLowerCase().includes(filter.toLowerCase());
|
|
5616
5761
|
});
|
|
5617
5762
|
}, [filter]);
|
|
5618
|
-
return /* @__PURE__ */ React__namespace.createElement(react
|
|
5763
|
+
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(
|
|
5619
5764
|
IconButton,
|
|
5620
5765
|
{
|
|
5621
5766
|
variant: open2 ? "secondary" : "primary",
|
|
@@ -5624,7 +5769,7 @@ var __publicField = (obj, key, value) => {
|
|
|
5624
5769
|
},
|
|
5625
5770
|
/* @__PURE__ */ React__namespace.createElement(AddIcon, { className: "w-5/6 h-auto" })
|
|
5626
5771
|
)), /* @__PURE__ */ React__namespace.createElement("div", { className: "transform translate-y-full absolute -bottom-1 right-0 z-50" }, /* @__PURE__ */ React__namespace.createElement(
|
|
5627
|
-
react
|
|
5772
|
+
react.Transition,
|
|
5628
5773
|
{
|
|
5629
5774
|
enter: "transition duration-150 ease-out",
|
|
5630
5775
|
enterFrom: "transform opacity-0 -translate-y-2",
|
|
@@ -5633,7 +5778,7 @@ var __publicField = (obj, key, value) => {
|
|
|
5633
5778
|
leaveFrom: "transform opacity-100 translate-y-0",
|
|
5634
5779
|
leaveTo: "transform opacity-0 -translate-y-2"
|
|
5635
5780
|
},
|
|
5636
|
-
/* @__PURE__ */ React__namespace.createElement(react
|
|
5781
|
+
/* @__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(
|
|
5637
5782
|
"input",
|
|
5638
5783
|
{
|
|
5639
5784
|
type: "text",
|
|
@@ -5663,27 +5808,35 @@ var __publicField = (obj, key, value) => {
|
|
|
5663
5808
|
))))
|
|
5664
5809
|
))));
|
|
5665
5810
|
};
|
|
5666
|
-
const Group =
|
|
5667
|
-
|
|
5668
|
-
|
|
5669
|
-
|
|
5670
|
-
|
|
5671
|
-
|
|
5672
|
-
|
|
5673
|
-
|
|
5674
|
-
|
|
5675
|
-
|
|
5676
|
-
|
|
5811
|
+
const Group = wrapFieldWithNoHeader(
|
|
5812
|
+
({ tinaForm, field }) => {
|
|
5813
|
+
const cms = useCMS$1();
|
|
5814
|
+
return /* @__PURE__ */ React__namespace.createElement(React__namespace.Fragment, null, /* @__PURE__ */ React__namespace.createElement(
|
|
5815
|
+
Header,
|
|
5816
|
+
{
|
|
5817
|
+
onClick: () => {
|
|
5818
|
+
const state = tinaForm.finalForm.getState();
|
|
5819
|
+
if (state.invalid === true) {
|
|
5820
|
+
cms.alerts.error("Cannot navigate away from an invalid form.");
|
|
5821
|
+
return;
|
|
5822
|
+
}
|
|
5823
|
+
cms.dispatch({
|
|
5824
|
+
type: "forms:set-active-field-name",
|
|
5825
|
+
value: { formId: tinaForm.id, fieldName: field.name }
|
|
5826
|
+
});
|
|
5677
5827
|
}
|
|
5678
|
-
|
|
5679
|
-
|
|
5680
|
-
|
|
5681
|
-
|
|
5682
|
-
|
|
5683
|
-
|
|
5684
|
-
|
|
5685
|
-
|
|
5686
|
-
|
|
5828
|
+
},
|
|
5829
|
+
field.label || field.name,
|
|
5830
|
+
field.description && /* @__PURE__ */ React__namespace.createElement(
|
|
5831
|
+
"span",
|
|
5832
|
+
{
|
|
5833
|
+
className: `block font-sans text-xs italic font-light text-gray-400 pt-0.5 whitespace-normal m-0`,
|
|
5834
|
+
dangerouslySetInnerHTML: { __html: field.description }
|
|
5835
|
+
}
|
|
5836
|
+
)
|
|
5837
|
+
));
|
|
5838
|
+
}
|
|
5839
|
+
);
|
|
5687
5840
|
const Header = ({ onClick, children }) => {
|
|
5688
5841
|
return /* @__PURE__ */ React__namespace.createElement("div", { className: "pt-1 mb-5" }, /* @__PURE__ */ React__namespace.createElement(
|
|
5689
5842
|
"button",
|
|
@@ -5810,8 +5963,8 @@ var __publicField = (obj, key, value) => {
|
|
|
5810
5963
|
onClick: () => setPickerIsOpen(!pickerIsOpen)
|
|
5811
5964
|
},
|
|
5812
5965
|
/* @__PURE__ */ React__namespace.createElement(AddIcon, { className: "w-5/6 h-auto" })
|
|
5813
|
-
), /* @__PURE__ */ React__namespace.createElement(FormPortal, null, ({ zIndexShift }) => /* @__PURE__ */ React__namespace.createElement(react
|
|
5814
|
-
react
|
|
5966
|
+
), /* @__PURE__ */ React__namespace.createElement(FormPortal, null, ({ zIndexShift }) => /* @__PURE__ */ React__namespace.createElement(react.Transition, { show: pickerIsOpen }, /* @__PURE__ */ React__namespace.createElement(
|
|
5967
|
+
react.TransitionChild,
|
|
5815
5968
|
{
|
|
5816
5969
|
enter: "transform transition-all ease-out duration-200",
|
|
5817
5970
|
enterFrom: "opacity-0 -translate-x-1/2",
|
|
@@ -5898,14 +6051,14 @@ var __publicField = (obj, key, value) => {
|
|
|
5898
6051
|
};
|
|
5899
6052
|
const BlockGroup = ({ category, templates, close: close2, isLast = false }) => {
|
|
5900
6053
|
return /* @__PURE__ */ React__namespace.createElement(
|
|
5901
|
-
react
|
|
6054
|
+
react.Disclosure,
|
|
5902
6055
|
{
|
|
5903
6056
|
defaultOpen: true,
|
|
5904
6057
|
as: "div",
|
|
5905
6058
|
className: `left-0 right-0 relative`
|
|
5906
6059
|
},
|
|
5907
6060
|
({ open: open2 }) => /* @__PURE__ */ React__namespace.createElement(React__namespace.Fragment, null, /* @__PURE__ */ React__namespace.createElement(
|
|
5908
|
-
react
|
|
6061
|
+
react.DisclosureButton,
|
|
5909
6062
|
{
|
|
5910
6063
|
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`}`
|
|
5911
6064
|
},
|
|
@@ -5923,7 +6076,7 @@ var __publicField = (obj, key, value) => {
|
|
|
5923
6076
|
}
|
|
5924
6077
|
)
|
|
5925
6078
|
), /* @__PURE__ */ React__namespace.createElement(
|
|
5926
|
-
react
|
|
6079
|
+
react.Transition,
|
|
5927
6080
|
{
|
|
5928
6081
|
enter: "transition duration-100 ease-out",
|
|
5929
6082
|
enterFrom: "transform scale-95 opacity-0",
|
|
@@ -5932,7 +6085,7 @@ var __publicField = (obj, key, value) => {
|
|
|
5932
6085
|
leaveFrom: "transform scale-100 opacity-100",
|
|
5933
6086
|
leaveTo: "transform scale-95 opacity-0"
|
|
5934
6087
|
},
|
|
5935
|
-
/* @__PURE__ */ React__namespace.createElement(react
|
|
6088
|
+
/* @__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(
|
|
5936
6089
|
BlockCard,
|
|
5937
6090
|
{
|
|
5938
6091
|
key: index,
|
|
@@ -9751,7 +9904,7 @@ var __publicField = (obj, key, value) => {
|
|
|
9751
9904
|
const FormLists = (props) => {
|
|
9752
9905
|
const cms = useCMS();
|
|
9753
9906
|
return /* @__PURE__ */ React__namespace.createElement(
|
|
9754
|
-
react
|
|
9907
|
+
react.Transition,
|
|
9755
9908
|
{
|
|
9756
9909
|
appear: true,
|
|
9757
9910
|
show: true,
|
|
@@ -10180,7 +10333,7 @@ var __publicField = (obj, key, value) => {
|
|
|
10180
10333
|
"Event Log"
|
|
10181
10334
|
));
|
|
10182
10335
|
};
|
|
10183
|
-
const version = "2.
|
|
10336
|
+
const version = "2.4.0";
|
|
10184
10337
|
const Nav = ({
|
|
10185
10338
|
isLocalMode,
|
|
10186
10339
|
className = "",
|
|
@@ -10234,8 +10387,8 @@ var __publicField = (obj, key, value) => {
|
|
|
10234
10387
|
style: { maxWidth: `${sidebarWidth}px` },
|
|
10235
10388
|
...props
|
|
10236
10389
|
},
|
|
10237
|
-
/* @__PURE__ */ React__namespace.createElement("div", { className: "border-b border-gray-200" }, /* @__PURE__ */ React__namespace.createElement(react
|
|
10238
|
-
react
|
|
10390
|
+
/* @__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(
|
|
10391
|
+
react.MenuButton,
|
|
10239
10392
|
{
|
|
10240
10393
|
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"}`
|
|
10241
10394
|
},
|
|
@@ -10258,7 +10411,7 @@ var __publicField = (obj, key, value) => {
|
|
|
10258
10411
|
}
|
|
10259
10412
|
)
|
|
10260
10413
|
), /* @__PURE__ */ React__namespace.createElement("div", { className: "transform translate-y-full absolute bottom-3 right-5 z-50" }, /* @__PURE__ */ React__namespace.createElement(
|
|
10261
|
-
react
|
|
10414
|
+
react.Transition,
|
|
10262
10415
|
{
|
|
10263
10416
|
enter: "transition duration-150 ease-out",
|
|
10264
10417
|
enterFrom: "transform opacity-0 -translate-y-2",
|
|
@@ -10267,7 +10420,7 @@ var __publicField = (obj, key, value) => {
|
|
|
10267
10420
|
leaveFrom: "transform opacity-100 translate-y-0",
|
|
10268
10421
|
leaveTo: "transform opacity-0 -translate-y-2"
|
|
10269
10422
|
},
|
|
10270
|
-
/* @__PURE__ */ React__namespace.createElement(react
|
|
10423
|
+
/* @__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(
|
|
10271
10424
|
"button",
|
|
10272
10425
|
{
|
|
10273
10426
|
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`,
|
|
@@ -10300,7 +10453,7 @@ var __publicField = (obj, key, value) => {
|
|
|
10300
10453
|
},
|
|
10301
10454
|
/* @__PURE__ */ React__namespace.createElement(BiExit, { className: "w-6 h-auto mr-2 text-blue-400" }),
|
|
10302
10455
|
" Log Out"
|
|
10303
|
-
)), /* @__PURE__ */ React__namespace.createElement(react
|
|
10456
|
+
)), /* @__PURE__ */ React__namespace.createElement(react.MenuItem, null, /* @__PURE__ */ React__namespace.createElement(
|
|
10304
10457
|
WrappedSyncStatus,
|
|
10305
10458
|
{
|
|
10306
10459
|
cms,
|
|
@@ -10646,8 +10799,8 @@ var __publicField = (obj, key, value) => {
|
|
|
10646
10799
|
screen: activeScreen,
|
|
10647
10800
|
close: () => setActiveView(null)
|
|
10648
10801
|
}
|
|
10649
|
-
)), /* @__PURE__ */ React__namespace.createElement(ResizeHandle, null)), renderMobileNav && /* @__PURE__ */ React__namespace.createElement(react
|
|
10650
|
-
react
|
|
10802
|
+
)), /* @__PURE__ */ React__namespace.createElement(ResizeHandle, null)), renderMobileNav && /* @__PURE__ */ React__namespace.createElement(react.Transition, { show: menuIsOpen, as: "div" }, /* @__PURE__ */ React__namespace.createElement(
|
|
10803
|
+
react.TransitionChild,
|
|
10651
10804
|
{
|
|
10652
10805
|
enter: "transform transition-all ease-out duration-300",
|
|
10653
10806
|
enterFrom: "opacity-0 -translate-x-full",
|
|
@@ -10712,7 +10865,7 @@ var __publicField = (obj, key, value) => {
|
|
|
10712
10865
|
))
|
|
10713
10866
|
))
|
|
10714
10867
|
), /* @__PURE__ */ React__namespace.createElement(
|
|
10715
|
-
react
|
|
10868
|
+
react.TransitionChild,
|
|
10716
10869
|
{
|
|
10717
10870
|
enter: "ease-out duration-300",
|
|
10718
10871
|
enterFrom: "opacity-0",
|
|
@@ -12711,15 +12864,14 @@ var __publicField = (obj, key, value) => {
|
|
|
12711
12864
|
fields: fieldGroup.fields
|
|
12712
12865
|
}
|
|
12713
12866
|
) : /* @__PURE__ */ React__namespace.createElement(NoFieldsPlaceholder, null)
|
|
12714
|
-
)), !hideFooter && /* @__PURE__ */ React__namespace.createElement("div", { className: "relative flex-none w-full h-16 px-
|
|
12867
|
+
)), !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(
|
|
12715
12868
|
ResetForm,
|
|
12716
12869
|
{
|
|
12717
12870
|
pristine,
|
|
12718
12871
|
reset: async () => {
|
|
12719
12872
|
finalForm2.reset();
|
|
12720
12873
|
await tinaForm.reset();
|
|
12721
|
-
}
|
|
12722
|
-
style: { flexGrow: 1 }
|
|
12874
|
+
}
|
|
12723
12875
|
},
|
|
12724
12876
|
tinaForm.buttons.reset
|
|
12725
12877
|
), /* @__PURE__ */ React__namespace.createElement(
|
|
@@ -12728,8 +12880,7 @@ var __publicField = (obj, key, value) => {
|
|
|
12728
12880
|
onClick: safeHandleSubmit,
|
|
12729
12881
|
disabled: !canSubmit,
|
|
12730
12882
|
busy: submitting,
|
|
12731
|
-
variant: "primary"
|
|
12732
|
-
style: { flexGrow: 3 }
|
|
12883
|
+
variant: "primary"
|
|
12733
12884
|
},
|
|
12734
12885
|
submitting && /* @__PURE__ */ React__namespace.createElement(LoadingDots, null),
|
|
12735
12886
|
!submitting && tinaForm.buttons.save
|
|
@@ -13247,15 +13398,15 @@ var __publicField = (obj, key, value) => {
|
|
|
13247
13398
|
);
|
|
13248
13399
|
};
|
|
13249
13400
|
const DotMenu = ({ onOpen, onRemove }) => {
|
|
13250
|
-
return /* @__PURE__ */ React.createElement(react
|
|
13251
|
-
react
|
|
13401
|
+
return /* @__PURE__ */ React.createElement(react.Popover, { as: "span", className: "-ml-px relative block" }, /* @__PURE__ */ React.createElement(
|
|
13402
|
+
react.PopoverButton,
|
|
13252
13403
|
{
|
|
13253
13404
|
as: "span",
|
|
13254
13405
|
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"
|
|
13255
13406
|
},
|
|
13256
13407
|
/* @__PURE__ */ React.createElement(EllipsisIcon, { title: "Open options" })
|
|
13257
13408
|
), /* @__PURE__ */ React.createElement(
|
|
13258
|
-
react
|
|
13409
|
+
react.Transition,
|
|
13259
13410
|
{
|
|
13260
13411
|
enter: "transition ease-out duration-100",
|
|
13261
13412
|
enterFrom: "transform opacity-0 scale-95",
|
|
@@ -13264,7 +13415,7 @@ var __publicField = (obj, key, value) => {
|
|
|
13264
13415
|
leaveFrom: "transform opacity-100 scale-100",
|
|
13265
13416
|
leaveTo: "transform opacity-0 scale-95"
|
|
13266
13417
|
},
|
|
13267
|
-
/* @__PURE__ */ React.createElement(react
|
|
13418
|
+
/* @__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(
|
|
13268
13419
|
"span",
|
|
13269
13420
|
{
|
|
13270
13421
|
onClick: onOpen,
|
|
@@ -13699,6 +13850,7 @@ var __publicField = (obj, key, value) => {
|
|
|
13699
13850
|
"Unordered List",
|
|
13700
13851
|
"Ordered List",
|
|
13701
13852
|
"Quote",
|
|
13853
|
+
"Mermaid",
|
|
13702
13854
|
"Heading 1",
|
|
13703
13855
|
"Heading 2",
|
|
13704
13856
|
"Heading 3",
|
|
@@ -13898,7 +14050,7 @@ var __publicField = (obj, key, value) => {
|
|
|
13898
14050
|
cn$1.withProps(TooltipPrimitive__namespace.Content, {
|
|
13899
14051
|
sideOffset: 4
|
|
13900
14052
|
}),
|
|
13901
|
-
"z-
|
|
14053
|
+
"z-[9999] overflow-hidden rounded-md border bg-popover px-3 py-1.5 text-sm text-popover-foreground shadow-md"
|
|
13902
14054
|
);
|
|
13903
14055
|
function withTooltip(Component) {
|
|
13904
14056
|
return React.forwardRef(function ExtendComponent({ tooltip, tooltipContentProps, tooltipProps, ...props }, ref) {
|
|
@@ -14024,30 +14176,42 @@ var __publicField = (obj, key, value) => {
|
|
|
14024
14176
|
Toolbar,
|
|
14025
14177
|
"p-1 sticky left-0 top-0 z-50 w-full justify-between overflow-x-auto border border-border bg-background"
|
|
14026
14178
|
);
|
|
14027
|
-
const
|
|
14028
|
-
|
|
14029
|
-
|
|
14030
|
-
|
|
14031
|
-
|
|
14032
|
-
const IndentListToolbarButton = cn$1.withRef(({ nodeType = plate.ELEMENT_UL }, ref) => {
|
|
14033
|
-
const editor = plateCommon.useEditorState();
|
|
14034
|
-
const state = plate.useListToolbarButtonState({ nodeType });
|
|
14035
|
-
const { props } = plate.useListToolbarButton(state);
|
|
14036
|
-
return /* @__PURE__ */ React.createElement(
|
|
14037
|
-
ToolbarButton,
|
|
14038
|
-
{
|
|
14039
|
-
ref,
|
|
14040
|
-
tooltip: nodeType === plate.ELEMENT_UL ? "Bulleted List" : "Numbered List",
|
|
14041
|
-
...props,
|
|
14042
|
-
onClick: (e) => {
|
|
14043
|
-
e.preventDefault();
|
|
14044
|
-
e.stopPropagation();
|
|
14045
|
-
plate.toggleList(editor, { type: nodeType });
|
|
14179
|
+
const useResize = (ref, callback) => {
|
|
14180
|
+
React.useEffect(() => {
|
|
14181
|
+
const resizeObserver = new ResizeObserver((entries) => {
|
|
14182
|
+
for (const entry of entries) {
|
|
14183
|
+
callback(entry);
|
|
14046
14184
|
}
|
|
14047
|
-
}
|
|
14048
|
-
|
|
14049
|
-
|
|
14050
|
-
|
|
14185
|
+
});
|
|
14186
|
+
if (ref.current) {
|
|
14187
|
+
resizeObserver.observe(ref.current);
|
|
14188
|
+
}
|
|
14189
|
+
return () => resizeObserver.disconnect();
|
|
14190
|
+
}, [ref.current]);
|
|
14191
|
+
};
|
|
14192
|
+
const STANDARD_ICON_WIDTH = 32;
|
|
14193
|
+
const HEADING_ICON_WITH_TEXT = 127;
|
|
14194
|
+
const HEADING_ICON_ONLY = 58;
|
|
14195
|
+
const EMBED_ICON_WIDTH = 78;
|
|
14196
|
+
const CONTAINER_MD_BREAKPOINT = 448;
|
|
14197
|
+
const FLOAT_BUTTON_WIDTH = 25;
|
|
14198
|
+
const HEADING_LABEL = "Headings";
|
|
14199
|
+
const ToolbarContext = React.createContext(void 0);
|
|
14200
|
+
const ToolbarProvider = ({
|
|
14201
|
+
tinaForm,
|
|
14202
|
+
templates,
|
|
14203
|
+
overrides,
|
|
14204
|
+
children
|
|
14205
|
+
}) => {
|
|
14206
|
+
return /* @__PURE__ */ React.createElement(ToolbarContext.Provider, { value: { tinaForm, templates, overrides } }, children);
|
|
14207
|
+
};
|
|
14208
|
+
const useToolbarContext = () => {
|
|
14209
|
+
const context = React.useContext(ToolbarContext);
|
|
14210
|
+
if (!context) {
|
|
14211
|
+
throw new Error("useToolbarContext must be used within a ToolbarProvider");
|
|
14212
|
+
}
|
|
14213
|
+
return context;
|
|
14214
|
+
};
|
|
14051
14215
|
const items$1 = [
|
|
14052
14216
|
{
|
|
14053
14217
|
description: "Paragraph",
|
|
@@ -14126,7 +14290,7 @@ var __publicField = (obj, key, value) => {
|
|
|
14126
14290
|
tooltip: "Headings"
|
|
14127
14291
|
},
|
|
14128
14292
|
/* @__PURE__ */ React.createElement(SelectedItemIcon, { className: "size-5" }),
|
|
14129
|
-
/* @__PURE__ */ React.createElement("span", { className: "
|
|
14293
|
+
/* @__PURE__ */ React.createElement("span", { className: "@md/toolbar:flex hidden" }, selectedItemLabel)
|
|
14130
14294
|
)), /* @__PURE__ */ React.createElement(DropdownMenuContent, { align: "start", className: "min-w-0" }, /* @__PURE__ */ React.createElement(
|
|
14131
14295
|
DropdownMenuRadioGroup,
|
|
14132
14296
|
{
|
|
@@ -14155,42 +14319,6 @@ var __publicField = (obj, key, value) => {
|
|
|
14155
14319
|
))
|
|
14156
14320
|
)));
|
|
14157
14321
|
}
|
|
14158
|
-
const LinkToolbarButton = cn$1.withRef((rest, ref) => {
|
|
14159
|
-
const state = plateLink.useLinkToolbarButtonState();
|
|
14160
|
-
const { props } = plateLink.useLinkToolbarButton(state);
|
|
14161
|
-
return /* @__PURE__ */ React.createElement(ToolbarButton, { ref, tooltip: "Link", ...props, ...rest }, /* @__PURE__ */ React.createElement(Icons.link, null));
|
|
14162
|
-
});
|
|
14163
|
-
const useBlockQuoteToolbarButtonState = () => {
|
|
14164
|
-
const editor = plateCommon.useEditorState();
|
|
14165
|
-
const isBlockActive = () => helpers.isNodeActive(editor, plateBlockQuote.ELEMENT_BLOCKQUOTE);
|
|
14166
|
-
return {
|
|
14167
|
-
pressed: isBlockActive()
|
|
14168
|
-
};
|
|
14169
|
-
};
|
|
14170
|
-
const useBlockQuoteToolbarButton = (state) => {
|
|
14171
|
-
const editor = plateCommon.useEditorState();
|
|
14172
|
-
const onClick = () => {
|
|
14173
|
-
plateCommon.toggleNodeType(editor, {
|
|
14174
|
-
activeType: plateBlockQuote.ELEMENT_BLOCKQUOTE
|
|
14175
|
-
});
|
|
14176
|
-
};
|
|
14177
|
-
const onMouseDown = (e) => {
|
|
14178
|
-
e.preventDefault();
|
|
14179
|
-
e.stopPropagation();
|
|
14180
|
-
};
|
|
14181
|
-
return {
|
|
14182
|
-
props: {
|
|
14183
|
-
onClick,
|
|
14184
|
-
onMouseDown,
|
|
14185
|
-
pressed: state.pressed
|
|
14186
|
-
}
|
|
14187
|
-
};
|
|
14188
|
-
};
|
|
14189
|
-
const QuoteToolbarButton = cn$1.withRef(({ clear, ...rest }, ref) => {
|
|
14190
|
-
const state = useBlockQuoteToolbarButtonState();
|
|
14191
|
-
const { props } = useBlockQuoteToolbarButton(state);
|
|
14192
|
-
return /* @__PURE__ */ React.createElement(ToolbarButton, { ref, tooltip: "Link", ...rest, ...props }, /* @__PURE__ */ React.createElement(Icons.quote, null));
|
|
14193
|
-
});
|
|
14194
14322
|
const useCodeBlockToolbarButtonState = () => {
|
|
14195
14323
|
const editor = plateCommon.useEditorState();
|
|
14196
14324
|
const isBlockActive = () => helpers.isNodeActive(editor, plateCodeBlock.ELEMENT_CODE_BLOCK);
|
|
@@ -14252,100 +14380,67 @@ var __publicField = (obj, key, value) => {
|
|
|
14252
14380
|
const { props } = useImageToolbarButton(state);
|
|
14253
14381
|
return /* @__PURE__ */ React.createElement(ToolbarButton, { ref, tooltip: "Link", ...rest, ...props }, /* @__PURE__ */ React.createElement(Icons.image, null));
|
|
14254
14382
|
});
|
|
14255
|
-
const
|
|
14256
|
-
const
|
|
14383
|
+
const IndentListToolbarButton = cn$1.withRef(({ nodeType = plate.ELEMENT_UL }, ref) => {
|
|
14384
|
+
const editor = plateCommon.useEditorState();
|
|
14385
|
+
const state = plate.useListToolbarButtonState({ nodeType });
|
|
14386
|
+
const { props } = plate.useListToolbarButton(state);
|
|
14387
|
+
return /* @__PURE__ */ React.createElement(
|
|
14388
|
+
ToolbarButton,
|
|
14389
|
+
{
|
|
14390
|
+
ref,
|
|
14391
|
+
tooltip: nodeType === plate.ELEMENT_UL ? "Bulleted List" : "Numbered List",
|
|
14392
|
+
...props,
|
|
14393
|
+
onClick: (e) => {
|
|
14394
|
+
e.preventDefault();
|
|
14395
|
+
e.stopPropagation();
|
|
14396
|
+
plate.toggleList(editor, { type: nodeType });
|
|
14397
|
+
}
|
|
14398
|
+
},
|
|
14399
|
+
nodeType === plate.ELEMENT_UL ? /* @__PURE__ */ React.createElement(Icons.ul, null) : /* @__PURE__ */ React.createElement(Icons.ol, null)
|
|
14400
|
+
);
|
|
14401
|
+
});
|
|
14402
|
+
const LinkToolbarButton = cn$1.withRef((rest, ref) => {
|
|
14403
|
+
const state = plateLink.useLinkToolbarButtonState();
|
|
14404
|
+
const { props } = plateLink.useLinkToolbarButton(state);
|
|
14405
|
+
return /* @__PURE__ */ React.createElement(ToolbarButton, { ref, tooltip: "Link", ...props, ...rest }, /* @__PURE__ */ React.createElement(Icons.link, null));
|
|
14406
|
+
});
|
|
14407
|
+
const MarkToolbarButton = cn$1.withRef(({ clear, nodeType, ...rest }, ref) => {
|
|
14408
|
+
const state = plateCommon.useMarkToolbarButtonState({ clear, nodeType });
|
|
14409
|
+
const { props } = plateCommon.useMarkToolbarButton(state);
|
|
14410
|
+
return /* @__PURE__ */ React.createElement(ToolbarButton, { ref, ...props, ...rest });
|
|
14411
|
+
});
|
|
14412
|
+
const useMermaidToolbarButtonState = () => {
|
|
14413
|
+
const editor = plateCommon.useEditorState();
|
|
14414
|
+
const isBlockActive = () => helpers.isNodeActive(editor, ELEMENT_MERMAID);
|
|
14415
|
+
return {
|
|
14416
|
+
pressed: isBlockActive()
|
|
14417
|
+
};
|
|
14418
|
+
};
|
|
14419
|
+
const useMermaidToolbarButton = (state) => {
|
|
14420
|
+
const editor = plateCommon.useEditorState();
|
|
14421
|
+
const onClick = () => {
|
|
14422
|
+
plateCommon.insertEmptyElement(editor, ELEMENT_MERMAID, {
|
|
14423
|
+
nextBlock: true,
|
|
14424
|
+
select: true
|
|
14425
|
+
});
|
|
14426
|
+
};
|
|
14257
14427
|
const onMouseDown = (e) => {
|
|
14258
|
-
|
|
14428
|
+
e.preventDefault();
|
|
14429
|
+
e.stopPropagation();
|
|
14259
14430
|
};
|
|
14260
14431
|
return {
|
|
14261
14432
|
props: {
|
|
14433
|
+
onClick,
|
|
14262
14434
|
onMouseDown,
|
|
14263
|
-
pressed:
|
|
14435
|
+
pressed: state.pressed
|
|
14264
14436
|
}
|
|
14265
14437
|
};
|
|
14266
14438
|
};
|
|
14267
|
-
const
|
|
14268
|
-
const
|
|
14269
|
-
|
|
14439
|
+
const MermaidToolbarButton = cn$1.withRef(({ clear, ...rest }, ref) => {
|
|
14440
|
+
const state = useMermaidToolbarButtonState();
|
|
14441
|
+
const { props } = useMermaidToolbarButton(state);
|
|
14442
|
+
return /* @__PURE__ */ React.createElement(ToolbarButton, { ref, tooltip: "Mermaid", ...rest, ...props }, /* @__PURE__ */ React.createElement(Icons.mermaid, null));
|
|
14270
14443
|
});
|
|
14271
|
-
const ToolbarContext = React.createContext(void 0);
|
|
14272
|
-
const ToolbarProvider = ({
|
|
14273
|
-
tinaForm,
|
|
14274
|
-
templates,
|
|
14275
|
-
overrides,
|
|
14276
|
-
children
|
|
14277
|
-
}) => {
|
|
14278
|
-
return /* @__PURE__ */ React.createElement(ToolbarContext.Provider, { value: { tinaForm, templates, overrides } }, children);
|
|
14279
|
-
};
|
|
14280
|
-
const useToolbarContext = () => {
|
|
14281
|
-
const context = React.useContext(ToolbarContext);
|
|
14282
|
-
if (!context) {
|
|
14283
|
-
throw new Error("useToolbarContext must be used within a ToolbarProvider");
|
|
14284
|
-
}
|
|
14285
|
-
return context;
|
|
14286
|
-
};
|
|
14287
|
-
function TemplatesToolbarButton() {
|
|
14288
|
-
const { templates } = useToolbarContext();
|
|
14289
|
-
const showEmbed = templates.length > 0;
|
|
14290
|
-
const editor = plateCommon.useEditorState();
|
|
14291
|
-
if (!showEmbed) {
|
|
14292
|
-
return null;
|
|
14293
|
-
}
|
|
14294
|
-
return /* @__PURE__ */ React.createElement(EmbedButton, { templates, editor });
|
|
14295
|
-
}
|
|
14296
|
-
const EmbedButton = ({ editor, templates }) => {
|
|
14297
|
-
const [open2, setOpen] = React.useState(false);
|
|
14298
|
-
const [filteredTemplates, setFilteredTemplates] = React.useState(templates);
|
|
14299
|
-
const filterChange = (e) => {
|
|
14300
|
-
const filterText = e.target.value.toLowerCase();
|
|
14301
|
-
setFilteredTemplates(
|
|
14302
|
-
templates.filter(
|
|
14303
|
-
(template) => template.name.toLowerCase().includes(filterText)
|
|
14304
|
-
)
|
|
14305
|
-
);
|
|
14306
|
-
};
|
|
14307
|
-
return /* @__PURE__ */ React.createElement(DropdownMenu, { open: open2, onOpenChange: setOpen }, /* @__PURE__ */ React.createElement(DropdownMenuTrigger, { className: "inline-flex items-center 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 [&_svg:not([data-icon])]:size-5 h-9 px-2 bg-transparent hover:bg-muted hover:text-muted-foreground aria-checked:bg-accent aria-checked:text-accent-foreground my-1 justify-between pr-1" }, /* @__PURE__ */ React.createElement("span", { className: "flex" }, "Embed"), /* @__PURE__ */ React.createElement(
|
|
14308
|
-
PlusIcon,
|
|
14309
|
-
{
|
|
14310
|
-
className: `origin-center transition-all ease-out duration-150 ${open2 ? "rotate-45" : ""}`
|
|
14311
|
-
}
|
|
14312
|
-
)), /* @__PURE__ */ React.createElement(DropdownMenuContent, { className: "max-h-48 overflow-y-auto" }, templates.length > 10 && /* @__PURE__ */ React.createElement(
|
|
14313
|
-
"input",
|
|
14314
|
-
{
|
|
14315
|
-
type: "text",
|
|
14316
|
-
placeholder: "Filter templates...",
|
|
14317
|
-
className: "w-full p-2 border border-gray-300 rounded-md",
|
|
14318
|
-
onChange: filterChange
|
|
14319
|
-
}
|
|
14320
|
-
), /* @__PURE__ */ React.createElement(DropdownMenuSeparator, null), filteredTemplates.map((template) => /* @__PURE__ */ React.createElement(
|
|
14321
|
-
DropdownMenuItem,
|
|
14322
|
-
{
|
|
14323
|
-
key: template.name,
|
|
14324
|
-
onMouseDown: (e) => {
|
|
14325
|
-
e.preventDefault();
|
|
14326
|
-
close();
|
|
14327
|
-
insertMDX(editor, template);
|
|
14328
|
-
},
|
|
14329
|
-
className: ""
|
|
14330
|
-
},
|
|
14331
|
-
template.label || template.name
|
|
14332
|
-
))));
|
|
14333
|
-
};
|
|
14334
|
-
const ICON_WIDTH = 32;
|
|
14335
|
-
const EMBED_ICON_WIDTH = 78;
|
|
14336
|
-
const useResize = (ref, callback) => {
|
|
14337
|
-
React.useEffect(() => {
|
|
14338
|
-
const resizeObserver = new ResizeObserver((entries) => {
|
|
14339
|
-
for (const entry of entries) {
|
|
14340
|
-
callback(entry);
|
|
14341
|
-
}
|
|
14342
|
-
});
|
|
14343
|
-
if (ref.current) {
|
|
14344
|
-
resizeObserver.observe(ref.current);
|
|
14345
|
-
}
|
|
14346
|
-
return () => resizeObserver.disconnect();
|
|
14347
|
-
}, [ref.current]);
|
|
14348
|
-
};
|
|
14349
14444
|
function OverflowMenu({
|
|
14350
14445
|
children,
|
|
14351
14446
|
...props
|
|
@@ -14355,6 +14450,7 @@ var __publicField = (obj, key, value) => {
|
|
|
14355
14450
|
ToolbarButton,
|
|
14356
14451
|
{
|
|
14357
14452
|
showArrow: false,
|
|
14453
|
+
"data-testid": "rich-text-editor-overflow-menu-button",
|
|
14358
14454
|
className: "lg:min-w-[130px]",
|
|
14359
14455
|
isDropdown: true,
|
|
14360
14456
|
pressed: openState.open,
|
|
@@ -14363,6 +14459,63 @@ var __publicField = (obj, key, value) => {
|
|
|
14363
14459
|
/* @__PURE__ */ React.createElement(Icons.overflow, { className: "size-5" })
|
|
14364
14460
|
)), /* @__PURE__ */ React.createElement(DropdownMenuContent, { align: "start", className: "min-w-0 flex flex-grow" }, children));
|
|
14365
14461
|
}
|
|
14462
|
+
const useBlockQuoteToolbarButtonState = () => {
|
|
14463
|
+
const editor = plateCommon.useEditorState();
|
|
14464
|
+
const isBlockActive = () => helpers.isNodeActive(editor, plateBlockQuote.ELEMENT_BLOCKQUOTE);
|
|
14465
|
+
return {
|
|
14466
|
+
pressed: isBlockActive()
|
|
14467
|
+
};
|
|
14468
|
+
};
|
|
14469
|
+
const useBlockQuoteToolbarButton = (state) => {
|
|
14470
|
+
const editor = plateCommon.useEditorState();
|
|
14471
|
+
const onClick = () => {
|
|
14472
|
+
plateCommon.toggleNodeType(editor, {
|
|
14473
|
+
activeType: plateBlockQuote.ELEMENT_BLOCKQUOTE
|
|
14474
|
+
});
|
|
14475
|
+
};
|
|
14476
|
+
const onMouseDown = (e) => {
|
|
14477
|
+
e.preventDefault();
|
|
14478
|
+
e.stopPropagation();
|
|
14479
|
+
};
|
|
14480
|
+
return {
|
|
14481
|
+
props: {
|
|
14482
|
+
onClick,
|
|
14483
|
+
onMouseDown,
|
|
14484
|
+
pressed: state.pressed
|
|
14485
|
+
}
|
|
14486
|
+
};
|
|
14487
|
+
};
|
|
14488
|
+
const QuoteToolbarButton = cn$1.withRef(({ clear, ...rest }, ref) => {
|
|
14489
|
+
const state = useBlockQuoteToolbarButtonState();
|
|
14490
|
+
const { props } = useBlockQuoteToolbarButton(state);
|
|
14491
|
+
return /* @__PURE__ */ React.createElement(ToolbarButton, { ref, tooltip: "Link", ...rest, ...props }, /* @__PURE__ */ React.createElement(Icons.quote, null));
|
|
14492
|
+
});
|
|
14493
|
+
const useRawMarkdownToolbarButton = () => {
|
|
14494
|
+
const { setRawMode } = useEditorContext();
|
|
14495
|
+
const onMouseDown = (e) => {
|
|
14496
|
+
setRawMode(true);
|
|
14497
|
+
};
|
|
14498
|
+
return {
|
|
14499
|
+
props: {
|
|
14500
|
+
onMouseDown,
|
|
14501
|
+
pressed: false
|
|
14502
|
+
}
|
|
14503
|
+
};
|
|
14504
|
+
};
|
|
14505
|
+
const RawMarkdownToolbarButton = cn$1.withRef(({ clear, ...rest }, ref) => {
|
|
14506
|
+
const { props } = useRawMarkdownToolbarButton();
|
|
14507
|
+
return /* @__PURE__ */ React.createElement(
|
|
14508
|
+
ToolbarButton,
|
|
14509
|
+
{
|
|
14510
|
+
ref,
|
|
14511
|
+
tooltip: "Link",
|
|
14512
|
+
...rest,
|
|
14513
|
+
...props,
|
|
14514
|
+
"data-testid": "markdown-button"
|
|
14515
|
+
},
|
|
14516
|
+
/* @__PURE__ */ React.createElement(Icons.raw, null)
|
|
14517
|
+
);
|
|
14518
|
+
});
|
|
14366
14519
|
function TableDropdownMenu(props) {
|
|
14367
14520
|
const tableSelected = plateCommon.useEditorSelector(
|
|
14368
14521
|
(editor2) => plateCommon.someNode(editor2, { match: { type: plateTable.ELEMENT_TABLE } }),
|
|
@@ -14465,78 +14618,156 @@ var __publicField = (obj, key, value) => {
|
|
|
14465
14618
|
)))
|
|
14466
14619
|
));
|
|
14467
14620
|
}
|
|
14621
|
+
function TemplatesToolbarButton() {
|
|
14622
|
+
const { templates } = useToolbarContext();
|
|
14623
|
+
const editor = plateCommon.useEditorState();
|
|
14624
|
+
return /* @__PURE__ */ React.createElement(EmbedButton, { templates, editor });
|
|
14625
|
+
}
|
|
14626
|
+
const EmbedButton = ({ editor, templates }) => {
|
|
14627
|
+
const [open2, setOpen] = React.useState(false);
|
|
14628
|
+
const [filteredTemplates, setFilteredTemplates] = React.useState(templates);
|
|
14629
|
+
const filterChange = (e) => {
|
|
14630
|
+
const filterText = e.target.value.toLowerCase();
|
|
14631
|
+
setFilteredTemplates(
|
|
14632
|
+
templates.filter(
|
|
14633
|
+
(template) => template.name.toLowerCase().includes(filterText)
|
|
14634
|
+
)
|
|
14635
|
+
);
|
|
14636
|
+
};
|
|
14637
|
+
return /* @__PURE__ */ React.createElement(DropdownMenu, { open: open2, onOpenChange: setOpen }, /* @__PURE__ */ React.createElement(DropdownMenuTrigger, { className: "inline-flex items-center 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 [&_svg:not([data-icon])]:size-5 h-9 px-2 bg-transparent hover:bg-muted hover:text-muted-foreground aria-checked:bg-accent aria-checked:text-accent-foreground my-1 justify-between pr-1" }, /* @__PURE__ */ React.createElement("span", { className: "flex" }, "Embed"), /* @__PURE__ */ React.createElement(
|
|
14638
|
+
PlusIcon,
|
|
14639
|
+
{
|
|
14640
|
+
className: `origin-center transition-all ease-out duration-150 ${open2 ? "rotate-45" : ""}`
|
|
14641
|
+
}
|
|
14642
|
+
)), /* @__PURE__ */ React.createElement(DropdownMenuContent, { className: "max-h-48 overflow-y-auto" }, templates.length > 10 && /* @__PURE__ */ React.createElement(
|
|
14643
|
+
"input",
|
|
14644
|
+
{
|
|
14645
|
+
type: "text",
|
|
14646
|
+
placeholder: "Filter templates...",
|
|
14647
|
+
className: "w-full p-2 border border-gray-300 rounded-md",
|
|
14648
|
+
onChange: filterChange
|
|
14649
|
+
}
|
|
14650
|
+
), /* @__PURE__ */ React.createElement(DropdownMenuSeparator, null), filteredTemplates.map((template) => /* @__PURE__ */ React.createElement(
|
|
14651
|
+
DropdownMenuItem,
|
|
14652
|
+
{
|
|
14653
|
+
key: template.name,
|
|
14654
|
+
onMouseDown: (e) => {
|
|
14655
|
+
e.preventDefault();
|
|
14656
|
+
close();
|
|
14657
|
+
insertMDX(editor, template);
|
|
14658
|
+
},
|
|
14659
|
+
className: ""
|
|
14660
|
+
},
|
|
14661
|
+
template.label || template.name
|
|
14662
|
+
))));
|
|
14663
|
+
};
|
|
14468
14664
|
const toolbarItems = {
|
|
14469
14665
|
heading: {
|
|
14470
|
-
label:
|
|
14666
|
+
label: HEADING_LABEL,
|
|
14667
|
+
width: (paragraphIconExists) => paragraphIconExists ? HEADING_ICON_WITH_TEXT : HEADING_ICON_ONLY,
|
|
14668
|
+
// Dynamically handle width based on paragraph icon
|
|
14471
14669
|
Component: /* @__PURE__ */ React.createElement(ToolbarGroup, { noSeparator: true }, /* @__PURE__ */ React.createElement(HeadingsMenu, null))
|
|
14472
14670
|
},
|
|
14473
14671
|
link: {
|
|
14474
14672
|
label: "Link",
|
|
14673
|
+
width: () => STANDARD_ICON_WIDTH,
|
|
14475
14674
|
Component: /* @__PURE__ */ React.createElement(LinkToolbarButton, null)
|
|
14476
14675
|
},
|
|
14477
14676
|
image: {
|
|
14478
14677
|
label: "Image",
|
|
14678
|
+
width: () => STANDARD_ICON_WIDTH,
|
|
14479
14679
|
Component: /* @__PURE__ */ React.createElement(ImageToolbarButton, null)
|
|
14480
14680
|
},
|
|
14481
14681
|
quote: {
|
|
14482
14682
|
label: "Quote",
|
|
14683
|
+
width: () => STANDARD_ICON_WIDTH,
|
|
14483
14684
|
Component: /* @__PURE__ */ React.createElement(QuoteToolbarButton, { tooltip: "Quote Quote (⌘+⇧+.)" })
|
|
14484
14685
|
},
|
|
14485
14686
|
ul: {
|
|
14486
14687
|
label: "Unordered List",
|
|
14688
|
+
width: () => STANDARD_ICON_WIDTH,
|
|
14487
14689
|
Component: /* @__PURE__ */ React.createElement(IndentListToolbarButton, { nodeType: plate.ELEMENT_UL })
|
|
14488
14690
|
},
|
|
14489
14691
|
ol: {
|
|
14490
14692
|
label: "Ordered List",
|
|
14693
|
+
width: () => STANDARD_ICON_WIDTH,
|
|
14491
14694
|
Component: /* @__PURE__ */ React.createElement(IndentListToolbarButton, { nodeType: plate.ELEMENT_OL })
|
|
14492
14695
|
},
|
|
14493
14696
|
bold: {
|
|
14494
14697
|
label: "Bold",
|
|
14698
|
+
width: () => STANDARD_ICON_WIDTH,
|
|
14495
14699
|
Component: /* @__PURE__ */ React.createElement(MarkToolbarButton, { tooltip: "Bold (⌘+B)", nodeType: plate.MARK_BOLD }, /* @__PURE__ */ React.createElement(Icons.bold, null))
|
|
14496
14700
|
},
|
|
14497
14701
|
italic: {
|
|
14498
14702
|
label: "Italic",
|
|
14703
|
+
width: () => STANDARD_ICON_WIDTH,
|
|
14499
14704
|
Component: /* @__PURE__ */ React.createElement(MarkToolbarButton, { tooltip: "Italic (⌘+I)", nodeType: plate.MARK_ITALIC }, /* @__PURE__ */ React.createElement(Icons.italic, null))
|
|
14500
14705
|
},
|
|
14501
14706
|
code: {
|
|
14502
14707
|
label: "Code",
|
|
14708
|
+
width: () => STANDARD_ICON_WIDTH,
|
|
14503
14709
|
Component: /* @__PURE__ */ React.createElement(MarkToolbarButton, { tooltip: "Code (⌘+E)", nodeType: plate.MARK_CODE }, /* @__PURE__ */ React.createElement(Icons.code, null))
|
|
14504
14710
|
},
|
|
14505
14711
|
codeBlock: {
|
|
14506
14712
|
label: "Code Block",
|
|
14713
|
+
width: () => STANDARD_ICON_WIDTH,
|
|
14507
14714
|
Component: /* @__PURE__ */ React.createElement(CodeBlockToolbarButton, null)
|
|
14508
14715
|
},
|
|
14716
|
+
mermaid: {
|
|
14717
|
+
label: "Mermaid",
|
|
14718
|
+
width: () => STANDARD_ICON_WIDTH,
|
|
14719
|
+
Component: /* @__PURE__ */ React.createElement(MermaidToolbarButton, null)
|
|
14720
|
+
},
|
|
14509
14721
|
table: {
|
|
14510
14722
|
label: "Table",
|
|
14723
|
+
width: () => STANDARD_ICON_WIDTH,
|
|
14511
14724
|
Component: /* @__PURE__ */ React.createElement(TableDropdownMenu, null)
|
|
14512
14725
|
},
|
|
14513
14726
|
raw: {
|
|
14514
14727
|
label: "Raw Markdown",
|
|
14728
|
+
width: () => STANDARD_ICON_WIDTH,
|
|
14515
14729
|
Component: /* @__PURE__ */ React.createElement(RawMarkdownToolbarButton, null)
|
|
14516
14730
|
},
|
|
14517
14731
|
embed: {
|
|
14518
14732
|
label: "Templates",
|
|
14733
|
+
width: () => EMBED_ICON_WIDTH,
|
|
14519
14734
|
Component: /* @__PURE__ */ React.createElement(TemplatesToolbarButton, null)
|
|
14520
14735
|
}
|
|
14521
14736
|
};
|
|
14522
14737
|
function FixedToolbarButtons() {
|
|
14523
14738
|
const toolbarRef = React.useRef(null);
|
|
14524
14739
|
const [itemsShown, setItemsShown] = React.useState(11);
|
|
14525
|
-
const { overrides } = useToolbarContext();
|
|
14526
|
-
|
|
14527
|
-
|
|
14528
|
-
|
|
14529
|
-
|
|
14530
|
-
}
|
|
14531
|
-
let toolbarItemsArray = overrides === void 0 ? Object.values(toolbarItems) : overrides.map((item) => toolbarItems[item]).filter((item) => item !== void 0);
|
|
14740
|
+
const { overrides, templates } = useToolbarContext();
|
|
14741
|
+
const showEmbedButton = templates.length > 0;
|
|
14742
|
+
let items2 = overrides === void 0 ? Object.values(toolbarItems) : overrides.map((item) => toolbarItems[item]).filter((item) => item !== void 0);
|
|
14743
|
+
if (!showEmbedButton) {
|
|
14744
|
+
items2 = items2.filter((item) => item.label !== toolbarItems.embed.label);
|
|
14745
|
+
}
|
|
14532
14746
|
const editorState = plateCommon.useEditorState();
|
|
14533
|
-
const userInTable = helpers.isNodeActive(editorState,
|
|
14747
|
+
const userInTable = helpers.isNodeActive(editorState, plate.ELEMENT_TABLE);
|
|
14534
14748
|
if (userInTable) {
|
|
14535
|
-
|
|
14536
|
-
(item) => !unsupportedItemsInTable.has(item.label)
|
|
14537
|
-
);
|
|
14749
|
+
items2 = items2.filter((item) => !unsupportedItemsInTable.has(item.label));
|
|
14538
14750
|
}
|
|
14539
|
-
|
|
14751
|
+
useResize(toolbarRef, (entry) => {
|
|
14752
|
+
const width = entry.target.getBoundingClientRect().width;
|
|
14753
|
+
const headingButton = items2.find((item) => item.label === HEADING_LABEL);
|
|
14754
|
+
const headingWidth = headingButton ? headingButton.width(width > CONTAINER_MD_BREAKPOINT) : 0;
|
|
14755
|
+
const availableWidth = width - headingWidth - FLOAT_BUTTON_WIDTH;
|
|
14756
|
+
const { itemFitCount } = items2.reduce(
|
|
14757
|
+
(acc, item) => {
|
|
14758
|
+
if (item.label !== HEADING_LABEL && acc.totalItemsWidth + item.width() <= availableWidth) {
|
|
14759
|
+
return {
|
|
14760
|
+
totalItemsWidth: acc.totalItemsWidth + item.width(),
|
|
14761
|
+
itemFitCount: acc.itemFitCount + 1
|
|
14762
|
+
};
|
|
14763
|
+
}
|
|
14764
|
+
return acc;
|
|
14765
|
+
},
|
|
14766
|
+
{ totalItemsWidth: 0, itemFitCount: 1 }
|
|
14767
|
+
);
|
|
14768
|
+
setItemsShown(itemFitCount);
|
|
14769
|
+
});
|
|
14770
|
+
return /* @__PURE__ */ React.createElement("div", { className: "w-full overflow-hidden @container/toolbar", ref: toolbarRef }, /* @__PURE__ */ React.createElement(
|
|
14540
14771
|
"div",
|
|
14541
14772
|
{
|
|
14542
14773
|
className: "flex",
|
|
@@ -14544,7 +14775,7 @@ var __publicField = (obj, key, value) => {
|
|
|
14544
14775
|
transform: "translateX(calc(-1px))"
|
|
14545
14776
|
}
|
|
14546
14777
|
},
|
|
14547
|
-
/* @__PURE__ */ React.createElement(React.Fragment, null,
|
|
14778
|
+
/* @__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))))
|
|
14548
14779
|
));
|
|
14549
14780
|
}
|
|
14550
14781
|
const FloatingToolbar = cn$1.withRef(({ children, state, ...props }, componentRef) => {
|
|
@@ -14874,6 +15105,7 @@ var __publicField = (obj, key, value) => {
|
|
|
14874
15105
|
createMdxBlockPlugin(),
|
|
14875
15106
|
createMdxInlinePlugin(),
|
|
14876
15107
|
createImgPlugin(),
|
|
15108
|
+
createMermaidPlugin(),
|
|
14877
15109
|
createInvalidMarkdownPlugin(),
|
|
14878
15110
|
plateLink.createLinkPlugin({
|
|
14879
15111
|
options: {
|
|
@@ -29881,6 +30113,7 @@ mutation addPendingDocumentMutation(
|
|
|
29881
30113
|
relativePath
|
|
29882
30114
|
filename
|
|
29883
30115
|
extension
|
|
30116
|
+
hasReferences
|
|
29884
30117
|
}
|
|
29885
30118
|
}
|
|
29886
30119
|
}
|
|
@@ -29972,6 +30205,9 @@ mutation addPendingDocumentMutation(
|
|
|
29972
30205
|
document(collection:$collection, relativePath:$relativePath) {
|
|
29973
30206
|
... on Document {
|
|
29974
30207
|
_values
|
|
30208
|
+
_sys {
|
|
30209
|
+
hasReferences
|
|
30210
|
+
}
|
|
29975
30211
|
}
|
|
29976
30212
|
}
|
|
29977
30213
|
}`;
|
|
@@ -30996,8 +31232,8 @@ This will work when developing locally but NOT when deployed to production.
|
|
|
30996
31232
|
}
|
|
30997
31233
|
)
|
|
30998
31234
|
}
|
|
30999
|
-
), !renderDesktopNav && /* @__PURE__ */ React.createElement(react
|
|
31000
|
-
react
|
|
31235
|
+
), !renderDesktopNav && /* @__PURE__ */ React.createElement(react.Transition, { show: menuIsOpen }, /* @__PURE__ */ React.createElement(
|
|
31236
|
+
react.TransitionChild,
|
|
31001
31237
|
{
|
|
31002
31238
|
enter: "transform transition-all ease-out duration-300",
|
|
31003
31239
|
enterFrom: "opacity-0 -translate-x-full",
|
|
@@ -31066,7 +31302,7 @@ This will work when developing locally but NOT when deployed to production.
|
|
|
31066
31302
|
))
|
|
31067
31303
|
))
|
|
31068
31304
|
), /* @__PURE__ */ React.createElement(
|
|
31069
|
-
react
|
|
31305
|
+
react.TransitionChild,
|
|
31070
31306
|
{
|
|
31071
31307
|
enter: "ease-out duration-300",
|
|
31072
31308
|
enterFrom: "opacity-0",
|
|
@@ -31520,8 +31756,8 @@ This will work when developing locally but NOT when deployed to production.
|
|
|
31520
31756
|
folder,
|
|
31521
31757
|
collectionName
|
|
31522
31758
|
}) => {
|
|
31523
|
-
return /* @__PURE__ */ React.createElement(react
|
|
31524
|
-
react
|
|
31759
|
+
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(
|
|
31760
|
+
react.Transition,
|
|
31525
31761
|
{
|
|
31526
31762
|
enter: "transition ease-out duration-100",
|
|
31527
31763
|
enterFrom: "transform opacity-0 scale-95",
|
|
@@ -31530,7 +31766,7 @@ This will work when developing locally but NOT when deployed to production.
|
|
|
31530
31766
|
leaveFrom: "transform opacity-100 scale-100",
|
|
31531
31767
|
leaveTo: "transform opacity-0 scale-95"
|
|
31532
31768
|
},
|
|
31533
|
-
/* @__PURE__ */ React.createElement(react
|
|
31769
|
+
/* @__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(
|
|
31534
31770
|
reactRouterDom.Link,
|
|
31535
31771
|
{
|
|
31536
31772
|
to: `/${folder.fullyQualifiedName ? [
|
|
@@ -31698,6 +31934,23 @@ This will work when developing locally but NOT when deployed to production.
|
|
|
31698
31934
|
DeleteModal,
|
|
31699
31935
|
{
|
|
31700
31936
|
filename: vars.relativePath,
|
|
31937
|
+
checkRefsFunc: async () => {
|
|
31938
|
+
var _a2, _b2;
|
|
31939
|
+
try {
|
|
31940
|
+
const doc = await admin.fetchDocument(
|
|
31941
|
+
collection.name,
|
|
31942
|
+
vars.relativePath,
|
|
31943
|
+
true
|
|
31944
|
+
);
|
|
31945
|
+
return (_b2 = (_a2 = doc == null ? void 0 : doc.document) == null ? void 0 : _a2._sys) == null ? void 0 : _b2.hasReferences;
|
|
31946
|
+
} catch (error) {
|
|
31947
|
+
cms.alerts.error(
|
|
31948
|
+
"Document was not found, ask a developer for help or check the console for an error message"
|
|
31949
|
+
);
|
|
31950
|
+
console.error(error);
|
|
31951
|
+
throw error;
|
|
31952
|
+
}
|
|
31953
|
+
},
|
|
31701
31954
|
deleteFunc: async () => {
|
|
31702
31955
|
try {
|
|
31703
31956
|
await admin.deleteDocument(vars);
|
|
@@ -31706,6 +31959,12 @@ This will work when developing locally but NOT when deployed to production.
|
|
|
31706
31959
|
);
|
|
31707
31960
|
reFetchCollection();
|
|
31708
31961
|
} catch (error) {
|
|
31962
|
+
if (error.message.indexOf("has references")) {
|
|
31963
|
+
cms.alerts.error(
|
|
31964
|
+
error.message.split("\n ").filter(Boolean)[1]
|
|
31965
|
+
);
|
|
31966
|
+
return;
|
|
31967
|
+
}
|
|
31709
31968
|
cms.alerts.warn(
|
|
31710
31969
|
"Document was not deleted, ask a developer for help or check the console for an error message"
|
|
31711
31970
|
);
|
|
@@ -31757,6 +32016,12 @@ This will work when developing locally but NOT when deployed to production.
|
|
|
31757
32016
|
cms.alerts.info("Document was successfully renamed");
|
|
31758
32017
|
reFetchCollection();
|
|
31759
32018
|
} catch (error) {
|
|
32019
|
+
if (error.message.indexOf("has references")) {
|
|
32020
|
+
cms.alerts.error(
|
|
32021
|
+
error.message.split("\n ").filter(Boolean)[1]
|
|
32022
|
+
);
|
|
32023
|
+
return;
|
|
32024
|
+
}
|
|
31760
32025
|
cms.alerts.warn(
|
|
31761
32026
|
"Document was not renamed, ask a developer for help or check the console for an error message"
|
|
31762
32027
|
);
|
|
@@ -32230,8 +32495,19 @@ This will work when developing locally but NOT when deployed to production.
|
|
|
32230
32495
|
const NoDocumentsPlaceholder = () => {
|
|
32231
32496
|
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."));
|
|
32232
32497
|
};
|
|
32233
|
-
const DeleteModal = ({
|
|
32234
|
-
|
|
32498
|
+
const DeleteModal = ({
|
|
32499
|
+
close: close2,
|
|
32500
|
+
deleteFunc,
|
|
32501
|
+
checkRefsFunc,
|
|
32502
|
+
filename
|
|
32503
|
+
}) => {
|
|
32504
|
+
const [hasRefs, setHasRefs] = React.useState();
|
|
32505
|
+
React.useEffect(() => {
|
|
32506
|
+
checkRefsFunc().then((result) => {
|
|
32507
|
+
setHasRefs(result);
|
|
32508
|
+
});
|
|
32509
|
+
}, [filename, checkRefsFunc]);
|
|
32510
|
+
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(
|
|
32235
32511
|
Button$1,
|
|
32236
32512
|
{
|
|
32237
32513
|
style: { flexGrow: 3 },
|
|
@@ -33598,6 +33874,7 @@ This will work when developing locally but NOT when deployed to production.
|
|
|
33598
33874
|
exports2.useScreenPlugin = useScreenPlugin;
|
|
33599
33875
|
exports2.useTinaAuthRedirect = useTinaAuthRedirect;
|
|
33600
33876
|
exports2.wrapFieldWithError = wrapFieldWithError;
|
|
33877
|
+
exports2.wrapFieldWithNoHeader = wrapFieldWithNoHeader;
|
|
33601
33878
|
exports2.wrapFieldsWithMeta = wrapFieldsWithMeta;
|
|
33602
33879
|
Object.defineProperties(exports2, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
|
|
33603
33880
|
});
|