tinacms 0.0.0-ea9b54c-20241003003029 → 0.0.0-ebe1b69-20250211022853
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 +91 -62
- package/dist/client.mjs +50 -36
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1686 -1098
- package/dist/index.mjs +1676 -1084
- package/dist/node-cache-5e8db9f0.mjs +63 -0
- package/dist/rich-text/index.d.ts +3 -0
- package/dist/rich-text/index.js +45 -12
- package/dist/rich-text/index.mjs +45 -12
- package/dist/toolkit/fields/components/reference/reference-select.d.ts +2 -2
- package/dist/toolkit/fields/plugins/mdx-field-plugin/index.d.ts +4 -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/resizable.d.ts +39 -0
- package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/components/plate-ui/table-cell-element.d.ts +27 -0
- package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/components/plate-ui/table-dropdown-menu.d.ts +3 -0
- package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/components/plate-ui/table-element.d.ts +14 -0
- package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/components/plate-ui/table-row-element.d.ts +13 -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/index.d.ts +1 -1
- package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/plugins/core/common.d.ts +1 -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 +58 -0
- package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/toolbar/toolbar-overrides.d.ts +11 -3
- package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/toolbar/toolbar-provider.d.ts +3 -3
- package/dist/toolkit/fields/plugins/wrap-field-with-meta.d.ts +8 -0
- package/dist/unifiedClient/index.d.ts +8 -1
- package/package.json +30 -28
- package/dist/__vite-browser-external-d06ac358.mjs +0 -4
- package/dist/node-cache-7fa2452c.mjs +0 -43
package/dist/index.mjs
CHANGED
|
@@ -6,32 +6,38 @@ var __publicField = (obj, key, value) => {
|
|
|
6
6
|
};
|
|
7
7
|
import { z } from "zod";
|
|
8
8
|
import * as React from "react";
|
|
9
|
-
import React__default, { useState, useCallback, createContext, forwardRef, useContext,
|
|
10
|
-
import { createPortal
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
9
|
+
import React__default, { useState, useCallback, useEffect, useRef, createContext, forwardRef, useContext, useMemo, startTransition } from "react";
|
|
10
|
+
import { createPortal } from "react-dom";
|
|
11
|
+
import { withRef, cn as cn$1, withVariants, withProps, withCn, createPrimitiveElement } from "@udecode/cn";
|
|
12
|
+
import { toggleList, ELEMENT_UL, ELEMENT_OL, ELEMENT_H1 as ELEMENT_H1$1, ELEMENT_H2 as ELEMENT_H2$1, ELEMENT_H3 as ELEMENT_H3$1, ELEMENT_H4, ELEMENT_H5, ELEMENT_H6, ELEMENT_PARAGRAPH, ELEMENT_BLOCKQUOTE, ELEMENT_CODE_BLOCK, ELEMENT_CODE_LINE, ELEMENT_CODE_SYNTAX, ELEMENT_LI, ELEMENT_LINK, MARK_CODE, MARK_UNDERLINE, MARK_STRIKETHROUGH, MARK_ITALIC, MARK_BOLD, ELEMENT_HR, ELEMENT_TABLE, ELEMENT_TR, ELEMENT_TD, ELEMENT_TH, unwrapList, ELEMENT_TODO_LI, createTrailingBlockPlugin, createAutoformatPlugin, createExitBreakPlugin, KEYS_HEADING, createResetNodePlugin, createHeadingPlugin, createParagraphPlugin, createBlockquotePlugin, createBoldPlugin, createItalicPlugin, createUnderlinePlugin, createCodePlugin, createListPlugin, createIndentListPlugin, createHorizontalRulePlugin, createNodeIdPlugin, createTablePlugin, getListItemEntry, useListToolbarButtonState, useListToolbarButton } from "@udecode/plate";
|
|
13
|
+
import { PlateElement, isCollapsed, findNodePath, getPointAfter, insertNodes, ELEMENT_DEFAULT, focusEditor, getPointBefore, setNodes, isElement, PlateLeaf, createPluginFactory, useComposedRef, useEditorRef, createPointRef, insertText, moveSelection, toggleNodeType, useElement, useRemoveNodeButton, useEditorSelector, isSelectionExpanded, withHOC, normalizeEditor, getBlockAbove, queryNode, getParentNode, isType, someNode, isSelectionAtBlockStart, setElements, insertNode, getPluginType, isBlock, isBlockAboveEmpty, findNode, PlateContent, getNodeEntries, useEditorState, collapseSelection, useMarkToolbarButtonState, useMarkToolbarButton, insertEmptyElement, usePlateSelectors, useEventEditorSelectors, PortalBody, useFormInputProps, createPlugins, Plate } from "@udecode/plate-common";
|
|
13
14
|
import { ELEMENT_SLASH_INPUT, createSlashPlugin } from "@udecode/plate-slash-command";
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
16
|
-
import
|
|
15
|
+
import { useSelected, useReadOnly, ReactEditor } from "slate-react";
|
|
16
|
+
import { useCodeBlockElementState, useCodeSyntaxLeaf, ELEMENT_CODE_BLOCK as ELEMENT_CODE_BLOCK$1 } from "@udecode/plate-code-block";
|
|
17
|
+
import MonacoEditor, { loader, useMonaco } from "@monaco-editor/react";
|
|
18
|
+
import { Combobox as Combobox$1, ComboboxInput, ComboboxButton, Transition, ComboboxOptions, ComboboxOption, Popover as Popover$3, PopoverButton, PopoverPanel, TransitionChild, Disclosure, DisclosureButton, DisclosurePanel, Menu, MenuButton, MenuItems, MenuItem } from "@headlessui/react";
|
|
17
19
|
import { cva } from "class-variance-authority";
|
|
18
|
-
import { Plus, AlignCenter as AlignCenter$1, AlignJustify, AlignLeft as AlignLeft$1, AlignRight as AlignRight$1, ChevronDown, PaintBucket, Quote, Check, ChevronRight, ChevronsUpDown, X, FileCode, Baseline, RectangleVertical, Combine, Ungroup, MessageSquare, MessageSquarePlus, Trash, GripVertical, Edit2, Smile, ExternalLink, Heading1, Heading2, Heading3, Heading4, Heading5, Heading6, Indent, Keyboard, WrapText, Minus, MoreHorizontal, Outdent, Pilcrow, RotateCcw, RectangleHorizontal, Search, Settings, Strikethrough, Subscript, Superscript, Table, Text, Underline, Link2Off,
|
|
19
|
-
import
|
|
20
|
+
import { Eye, SquarePen, Plus, AlignCenter as AlignCenter$1, AlignJustify, AlignLeft as AlignLeft$1, AlignRight as AlignRight$1, ChevronDown, PaintBucket, Quote, Check, ChevronRight, ChevronsUpDown, X, FileCode, Baseline, RectangleVertical, Combine, Ungroup, MessageSquare, MessageSquarePlus, Trash, GripVertical, Edit2, Smile, ExternalLink, Heading1, Heading2, Heading3, Heading4, Heading5, Heading6, Indent, Keyboard, WrapText, Minus, MoreHorizontal, Outdent, Pilcrow, RotateCcw, RectangleHorizontal, Search, Settings, Strikethrough, Subscript, Superscript, Table, Text, Underline, Link2Off, Moon, SunMedium, Twitter } from "lucide-react";
|
|
21
|
+
import mermaid from "mermaid";
|
|
22
|
+
import { ELEMENT_H1, ELEMENT_H2, ELEMENT_H3, ELEMENT_H4 as ELEMENT_H4$1, ELEMENT_H5 as ELEMENT_H5$1, ELEMENT_H6 as ELEMENT_H6$1 } from "@udecode/plate-heading";
|
|
23
|
+
import { useComboboxContext, Combobox as Combobox$2, useComboboxStore, ComboboxProvider, Portal, ComboboxPopover, ComboboxItem } from "@ariakit/react";
|
|
20
24
|
import { useHTMLInputCursorState, useComboboxInput, filterWords } from "@udecode/plate-combobox";
|
|
21
|
-
import {
|
|
22
|
-
import
|
|
23
|
-
import
|
|
25
|
+
import { useTableCellElementState, useTableCellElement, useTableCellElementResizableState, useTableCellElementResizable, useTableBordersDropdownMenuContentState, useTableMergeState, TableProvider, useTableElementState, useTableElement, mergeTableCells, unmergeTableCells, ELEMENT_TABLE as ELEMENT_TABLE$1, getTableColumnCount, insertTable, deleteTable, insertTableColumn, deleteColumn, insertTableRow, deleteRow } from "@udecode/plate-table";
|
|
26
|
+
import { ResizeHandle as ResizeHandle$1 } from "@udecode/plate-resizable";
|
|
27
|
+
import * as PopoverPrimitive from "@radix-ui/react-popover";
|
|
28
|
+
import { PopoverAnchor } from "@radix-ui/react-popover";
|
|
29
|
+
import { Slot } from "@radix-ui/react-slot";
|
|
30
|
+
import * as DropdownMenuPrimitive from "@radix-ui/react-dropdown-menu";
|
|
31
|
+
import * as SeparatorPrimitive from "@radix-ui/react-separator";
|
|
24
32
|
import arrayMutators from "final-form-arrays";
|
|
25
33
|
import setFieldData from "final-form-set-field-data";
|
|
26
34
|
import { FORM_ERROR, createForm, getIn } from "final-form";
|
|
27
35
|
import { Field, Form as Form$1 } from "react-final-form";
|
|
28
36
|
import PropTypes from "prop-types";
|
|
29
37
|
import { Droppable, Draggable, DragDropContext } from "react-beautiful-dnd";
|
|
30
|
-
import * as PopoverPrimitive from "@radix-ui/react-popover";
|
|
31
38
|
import * as pkg$1 from "react-color";
|
|
32
39
|
import * as pkg from "color-string";
|
|
33
40
|
import * as dropzone from "react-dropzone";
|
|
34
|
-
import { Slot } from "@radix-ui/react-slot";
|
|
35
41
|
import { clsx } from "clsx";
|
|
36
42
|
import { twMerge } from "tailwind-merge";
|
|
37
43
|
import { Command as Command$1 } from "cmdk";
|
|
@@ -42,10 +48,8 @@ import moment from "moment";
|
|
|
42
48
|
import { formatDistanceToNow } from "date-fns";
|
|
43
49
|
import { useLinkToolbarButtonState, useLinkToolbarButton, useFloatingLinkInsertState, useFloatingLinkInsert, useFloatingLinkEditState, useFloatingLinkEdit, FloatingLinkUrlInput, LinkOpenButton, createLinkPlugin } from "@udecode/plate-link";
|
|
44
50
|
import * as ToolbarPrimitive from "@radix-ui/react-toolbar";
|
|
45
|
-
import * as SeparatorPrimitive from "@radix-ui/react-separator";
|
|
46
51
|
import * as TooltipPrimitive from "@radix-ui/react-tooltip";
|
|
47
52
|
import { ELEMENT_PARAGRAPH as ELEMENT_PARAGRAPH$1 } from "@udecode/plate-paragraph";
|
|
48
|
-
import * as DropdownMenuPrimitive from "@radix-ui/react-dropdown-menu";
|
|
49
53
|
import { ELEMENT_BLOCKQUOTE as ELEMENT_BLOCKQUOTE$1 } from "@udecode/plate-block-quote";
|
|
50
54
|
import { useFloatingToolbarState, offset, flip, useFloatingToolbar } from "@udecode/plate-floating";
|
|
51
55
|
import { useWindowWidth } from "@react-hook/window-size";
|
|
@@ -797,6 +801,22 @@ function wrapFieldsWithMeta(Field2) {
|
|
|
797
801
|
);
|
|
798
802
|
};
|
|
799
803
|
}
|
|
804
|
+
function wrapFieldWithNoHeader(Field2) {
|
|
805
|
+
return (props) => {
|
|
806
|
+
return /* @__PURE__ */ React.createElement(
|
|
807
|
+
FieldMeta,
|
|
808
|
+
{
|
|
809
|
+
name: props.input.name,
|
|
810
|
+
label: false,
|
|
811
|
+
description: "",
|
|
812
|
+
error: props.meta.error,
|
|
813
|
+
index: props.index,
|
|
814
|
+
tinaForm: props.tinaForm
|
|
815
|
+
},
|
|
816
|
+
/* @__PURE__ */ React.createElement(Field2, { ...props })
|
|
817
|
+
);
|
|
818
|
+
};
|
|
819
|
+
}
|
|
800
820
|
function wrapFieldWithError(Field2) {
|
|
801
821
|
return (props) => {
|
|
802
822
|
return /* @__PURE__ */ React.createElement(
|
|
@@ -869,6 +889,16 @@ const FieldDescription = ({
|
|
|
869
889
|
className,
|
|
870
890
|
...props
|
|
871
891
|
}) => {
|
|
892
|
+
if (typeof children === "string") {
|
|
893
|
+
return /* @__PURE__ */ React.createElement(
|
|
894
|
+
"span",
|
|
895
|
+
{
|
|
896
|
+
className: `block font-sans text-xs italic font-light text-gray-400 pt-0.5 whitespace-normal m-0 ${className}`,
|
|
897
|
+
...props,
|
|
898
|
+
dangerouslySetInnerHTML: { __html: children }
|
|
899
|
+
}
|
|
900
|
+
);
|
|
901
|
+
}
|
|
872
902
|
return /* @__PURE__ */ React.createElement(
|
|
873
903
|
"span",
|
|
874
904
|
{
|
|
@@ -905,6 +935,20 @@ const useEditorContext = () => {
|
|
|
905
935
|
const useTemplates = () => {
|
|
906
936
|
return React__default.useContext(EditorContext);
|
|
907
937
|
};
|
|
938
|
+
const BlockquoteElement = withRef(
|
|
939
|
+
({ children, className, ...props }, ref) => {
|
|
940
|
+
return /* @__PURE__ */ React__default.createElement(
|
|
941
|
+
PlateElement,
|
|
942
|
+
{
|
|
943
|
+
asChild: true,
|
|
944
|
+
className: cn$1("my-1 border-l-2 pl-6 italic", className),
|
|
945
|
+
ref,
|
|
946
|
+
...props
|
|
947
|
+
},
|
|
948
|
+
/* @__PURE__ */ React__default.createElement("blockquote", null, children)
|
|
949
|
+
);
|
|
950
|
+
}
|
|
951
|
+
);
|
|
908
952
|
function classNames$1(...classes) {
|
|
909
953
|
return classes.filter(Boolean).join(" ");
|
|
910
954
|
}
|
|
@@ -914,6 +958,503 @@ const uuid = () => {
|
|
|
914
958
|
(c) => (c ^ crypto.getRandomValues(new Uint8Array(1))[0] & 15 >> c / 4).toString(16)
|
|
915
959
|
);
|
|
916
960
|
};
|
|
961
|
+
function ChevronDownIcon(props, svgRef) {
|
|
962
|
+
return /* @__PURE__ */ React.createElement("svg", Object.assign({
|
|
963
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
964
|
+
viewBox: "0 0 20 20",
|
|
965
|
+
fill: "currentColor",
|
|
966
|
+
"aria-hidden": "true",
|
|
967
|
+
ref: svgRef
|
|
968
|
+
}, props), /* @__PURE__ */ React.createElement("path", {
|
|
969
|
+
fillRule: "evenodd",
|
|
970
|
+
d: "M5.293 7.293a1 1 0 011.414 0L10 10.586l3.293-3.293a1 1 0 111.414 1.414l-4 4a1 1 0 01-1.414 0l-4-4a1 1 0 010-1.414z",
|
|
971
|
+
clipRule: "evenodd"
|
|
972
|
+
}));
|
|
973
|
+
}
|
|
974
|
+
const ForwardRef = React.forwardRef(ChevronDownIcon);
|
|
975
|
+
const ChevronDownIcon$1 = ForwardRef;
|
|
976
|
+
const Autocomplete = ({
|
|
977
|
+
value,
|
|
978
|
+
onChange,
|
|
979
|
+
defaultQuery,
|
|
980
|
+
items: items2
|
|
981
|
+
}) => {
|
|
982
|
+
const [query, setQuery] = React__default.useState(defaultQuery ?? "");
|
|
983
|
+
const filteredItems = React__default.useMemo(() => {
|
|
984
|
+
try {
|
|
985
|
+
const reFilter = new RegExp(query, "i");
|
|
986
|
+
const _items = items2.filter((item) => reFilter.test(item.label));
|
|
987
|
+
if (_items.length === 0)
|
|
988
|
+
return items2;
|
|
989
|
+
return _items;
|
|
990
|
+
} catch (err) {
|
|
991
|
+
return items2;
|
|
992
|
+
}
|
|
993
|
+
}, [items2, query]);
|
|
994
|
+
return /* @__PURE__ */ React__default.createElement(
|
|
995
|
+
Combobox$1,
|
|
996
|
+
{
|
|
997
|
+
value,
|
|
998
|
+
onChange,
|
|
999
|
+
as: "div",
|
|
1000
|
+
className: "relative inline-block text-left z-20"
|
|
1001
|
+
},
|
|
1002
|
+
/* @__PURE__ */ React__default.createElement("div", { className: "mt-1" }, /* @__PURE__ */ React__default.createElement("div", { className: "relative w-full cursor-default overflow-hidden rounded-lg bg-white text-left shadow-md sm:text-sm" }, /* @__PURE__ */ React__default.createElement(
|
|
1003
|
+
ComboboxInput,
|
|
1004
|
+
{
|
|
1005
|
+
className: "w-full border-none py-2 pl-3 pr-10 text-sm leading-5 text-gray-900 focus:ring-0 focus:outline-none focus-visible:ring-2 focus-visible:ring-white focus-visible:ring-opacity-75 focus-visible:ring-offset-2 focus-visible:ring-offset-teal-300",
|
|
1006
|
+
displayValue: (item) => (item == null ? void 0 : item.label) ?? "Plain Text",
|
|
1007
|
+
onChange: (event) => setQuery(event.target.value),
|
|
1008
|
+
onClick: (ev) => ev.stopPropagation()
|
|
1009
|
+
}
|
|
1010
|
+
), /* @__PURE__ */ React__default.createElement(ComboboxButton, { className: "absolute inset-y-0 right-0 flex items-center pr-2" }, /* @__PURE__ */ React__default.createElement(
|
|
1011
|
+
ChevronDownIcon$1,
|
|
1012
|
+
{
|
|
1013
|
+
className: "h-5 w-5 text-gray-400",
|
|
1014
|
+
"aria-hidden": "true"
|
|
1015
|
+
}
|
|
1016
|
+
)))),
|
|
1017
|
+
/* @__PURE__ */ React__default.createElement(
|
|
1018
|
+
Transition,
|
|
1019
|
+
{
|
|
1020
|
+
enter: "transition ease-out duration-100",
|
|
1021
|
+
enterFrom: "transform opacity-0 scale-95",
|
|
1022
|
+
enterTo: "transform opacity-100 scale-100",
|
|
1023
|
+
leave: "transition ease-in duration-75",
|
|
1024
|
+
leaveFrom: "transform opacity-100 scale-100",
|
|
1025
|
+
leaveTo: "transform opacity-0 scale-95"
|
|
1026
|
+
},
|
|
1027
|
+
/* @__PURE__ */ React__default.createElement(ComboboxOptions, { className: "origin-top-right absolute right-0 mt-1 w-full max-h-[300px] overflow-y-auto rounded-md shadow-lg bg-white ring-1 ring-black ring-opacity-5 focus:outline-none" }, filteredItems.map((item) => /* @__PURE__ */ React__default.createElement(ComboboxOption, { key: item.key, value: item }, ({ focus }) => /* @__PURE__ */ React__default.createElement(
|
|
1028
|
+
"button",
|
|
1029
|
+
{
|
|
1030
|
+
className: classNames$1(
|
|
1031
|
+
focus ? "bg-gray-100 text-gray-900" : "text-gray-700",
|
|
1032
|
+
"block px-4 py-2 text-xs w-full text-right"
|
|
1033
|
+
)
|
|
1034
|
+
},
|
|
1035
|
+
item.render(item)
|
|
1036
|
+
))))
|
|
1037
|
+
)
|
|
1038
|
+
);
|
|
1039
|
+
};
|
|
1040
|
+
loader.config({
|
|
1041
|
+
paths: { vs: "https://cdn.jsdelivr.net/npm/monaco-editor@0.31.1/min/vs" }
|
|
1042
|
+
});
|
|
1043
|
+
let retryCount = 0;
|
|
1044
|
+
const retryFocus = (ref) => {
|
|
1045
|
+
if (ref.current) {
|
|
1046
|
+
ref.current.focus();
|
|
1047
|
+
} else {
|
|
1048
|
+
if (retryCount < 30) {
|
|
1049
|
+
setTimeout(() => {
|
|
1050
|
+
retryCount = retryCount + 1;
|
|
1051
|
+
retryFocus(ref);
|
|
1052
|
+
}, 100);
|
|
1053
|
+
}
|
|
1054
|
+
}
|
|
1055
|
+
};
|
|
1056
|
+
const MINIMUM_HEIGHT = 75;
|
|
1057
|
+
const CodeBlock = ({
|
|
1058
|
+
attributes,
|
|
1059
|
+
editor,
|
|
1060
|
+
element,
|
|
1061
|
+
language: restrictLanguage,
|
|
1062
|
+
onChangeCallback,
|
|
1063
|
+
defaultValue,
|
|
1064
|
+
...props
|
|
1065
|
+
}) => {
|
|
1066
|
+
const [navigateAway, setNavigateAway] = React__default.useState(null);
|
|
1067
|
+
const monaco = useMonaco();
|
|
1068
|
+
const monacoEditorRef = React__default.useRef(null);
|
|
1069
|
+
const selected = useSelected();
|
|
1070
|
+
const [height, setHeight] = React__default.useState(MINIMUM_HEIGHT);
|
|
1071
|
+
React__default.useEffect(() => {
|
|
1072
|
+
if (selected && isCollapsed(editor.selection)) {
|
|
1073
|
+
retryFocus(monacoEditorRef);
|
|
1074
|
+
}
|
|
1075
|
+
}, [selected, monacoEditorRef.current]);
|
|
1076
|
+
const value = element.value || "";
|
|
1077
|
+
if (typeof value !== "string") {
|
|
1078
|
+
throw new Error("Element must be of type string for code block");
|
|
1079
|
+
}
|
|
1080
|
+
const language = restrictLanguage || element.lang;
|
|
1081
|
+
const id = React__default.useMemo(() => uuid(), []);
|
|
1082
|
+
const languages = React__default.useMemo(() => {
|
|
1083
|
+
const defaultLangSet = { "": "plain text" };
|
|
1084
|
+
if (!monaco)
|
|
1085
|
+
return defaultLangSet;
|
|
1086
|
+
return monaco.languages.getLanguages().reduce((ac, cv) => {
|
|
1087
|
+
if (cv.id === "plaintext")
|
|
1088
|
+
return ac;
|
|
1089
|
+
return { ...ac, [cv.id]: cv.id };
|
|
1090
|
+
}, defaultLangSet);
|
|
1091
|
+
}, [monaco]);
|
|
1092
|
+
React__default.useEffect(() => {
|
|
1093
|
+
if (monaco) {
|
|
1094
|
+
monaco.languages.typescript.typescriptDefaults.setEagerModelSync(true);
|
|
1095
|
+
monaco.languages.typescript.typescriptDefaults.setDiagnosticsOptions({
|
|
1096
|
+
// disable errors
|
|
1097
|
+
noSemanticValidation: true,
|
|
1098
|
+
noSyntaxValidation: true
|
|
1099
|
+
});
|
|
1100
|
+
}
|
|
1101
|
+
}, [monaco]);
|
|
1102
|
+
const items2 = Object.entries(languages).map(([key, label]) => ({
|
|
1103
|
+
key,
|
|
1104
|
+
label,
|
|
1105
|
+
render: (item) => item.label
|
|
1106
|
+
}));
|
|
1107
|
+
const currentItem = React__default.useMemo(() => {
|
|
1108
|
+
return items2.find((item) => item.key === language) ?? {
|
|
1109
|
+
key: "",
|
|
1110
|
+
label: "Plain Text"
|
|
1111
|
+
};
|
|
1112
|
+
}, [items2, language]);
|
|
1113
|
+
React__default.useEffect(() => {
|
|
1114
|
+
if (navigateAway) {
|
|
1115
|
+
setNavigateAway(null);
|
|
1116
|
+
switch (navigateAway) {
|
|
1117
|
+
case "remove":
|
|
1118
|
+
{
|
|
1119
|
+
focusEditor(editor);
|
|
1120
|
+
setNodes(
|
|
1121
|
+
editor,
|
|
1122
|
+
{
|
|
1123
|
+
type: "p",
|
|
1124
|
+
children: [{ text: "" }],
|
|
1125
|
+
lang: void 0,
|
|
1126
|
+
value: void 0
|
|
1127
|
+
},
|
|
1128
|
+
{
|
|
1129
|
+
match: (n) => {
|
|
1130
|
+
if (isElement(n) && n.type === element.type) {
|
|
1131
|
+
return true;
|
|
1132
|
+
}
|
|
1133
|
+
}
|
|
1134
|
+
}
|
|
1135
|
+
);
|
|
1136
|
+
}
|
|
1137
|
+
break;
|
|
1138
|
+
case "insertNext":
|
|
1139
|
+
{
|
|
1140
|
+
insertNodes(
|
|
1141
|
+
editor,
|
|
1142
|
+
[
|
|
1143
|
+
{
|
|
1144
|
+
type: ELEMENT_DEFAULT,
|
|
1145
|
+
children: [{ text: "" }],
|
|
1146
|
+
lang: void 0,
|
|
1147
|
+
value: void 0
|
|
1148
|
+
}
|
|
1149
|
+
],
|
|
1150
|
+
{ select: true }
|
|
1151
|
+
);
|
|
1152
|
+
focusEditor(editor);
|
|
1153
|
+
}
|
|
1154
|
+
break;
|
|
1155
|
+
case "up":
|
|
1156
|
+
{
|
|
1157
|
+
const path = findNodePath(editor, element);
|
|
1158
|
+
if (!path) {
|
|
1159
|
+
return;
|
|
1160
|
+
}
|
|
1161
|
+
const previousNodePath = getPointBefore(editor, path);
|
|
1162
|
+
if (!previousNodePath) {
|
|
1163
|
+
focusEditor(editor);
|
|
1164
|
+
insertNodes(
|
|
1165
|
+
editor,
|
|
1166
|
+
[
|
|
1167
|
+
{
|
|
1168
|
+
type: ELEMENT_DEFAULT,
|
|
1169
|
+
children: [{ text: "" }],
|
|
1170
|
+
lang: void 0,
|
|
1171
|
+
value: void 0
|
|
1172
|
+
}
|
|
1173
|
+
],
|
|
1174
|
+
// Insert a new node at the current path, resulting in the code_block
|
|
1175
|
+
// moving down one block
|
|
1176
|
+
{ at: path, select: true }
|
|
1177
|
+
);
|
|
1178
|
+
return;
|
|
1179
|
+
}
|
|
1180
|
+
focusEditor(editor, previousNodePath);
|
|
1181
|
+
}
|
|
1182
|
+
break;
|
|
1183
|
+
case "down": {
|
|
1184
|
+
const path = findNodePath(editor, element);
|
|
1185
|
+
if (!path) {
|
|
1186
|
+
return;
|
|
1187
|
+
}
|
|
1188
|
+
const nextNodePath = getPointAfter(editor, path);
|
|
1189
|
+
if (!nextNodePath) {
|
|
1190
|
+
insertNodes(
|
|
1191
|
+
editor,
|
|
1192
|
+
[
|
|
1193
|
+
{
|
|
1194
|
+
type: ELEMENT_DEFAULT,
|
|
1195
|
+
children: [{ text: "" }],
|
|
1196
|
+
lang: void 0,
|
|
1197
|
+
value: void 0
|
|
1198
|
+
}
|
|
1199
|
+
],
|
|
1200
|
+
{ select: true }
|
|
1201
|
+
);
|
|
1202
|
+
focusEditor(editor);
|
|
1203
|
+
} else {
|
|
1204
|
+
focusEditor(editor, nextNodePath);
|
|
1205
|
+
}
|
|
1206
|
+
break;
|
|
1207
|
+
}
|
|
1208
|
+
}
|
|
1209
|
+
}
|
|
1210
|
+
}, [navigateAway]);
|
|
1211
|
+
function handleEditorDidMount(monacoEditor, monaco2) {
|
|
1212
|
+
monacoEditorRef.current = monacoEditor;
|
|
1213
|
+
monacoEditor.onDidContentSizeChange(() => {
|
|
1214
|
+
setHeight(
|
|
1215
|
+
monacoEditor.getContentHeight() > MINIMUM_HEIGHT ? monacoEditor.getContentHeight() : MINIMUM_HEIGHT
|
|
1216
|
+
);
|
|
1217
|
+
monacoEditor.layout();
|
|
1218
|
+
});
|
|
1219
|
+
setNodes(editor, { value: defaultValue, lang: language });
|
|
1220
|
+
monacoEditor.addCommand(monaco2.KeyMod.Shift | monaco2.KeyCode.Enter, () => {
|
|
1221
|
+
if (monacoEditor.hasTextFocus()) {
|
|
1222
|
+
setNavigateAway("insertNext");
|
|
1223
|
+
}
|
|
1224
|
+
});
|
|
1225
|
+
monacoEditor.onKeyDown((l) => {
|
|
1226
|
+
if (l.code === "ArrowUp") {
|
|
1227
|
+
const selection = monacoEditor.getSelection();
|
|
1228
|
+
if (selection.endLineNumber === 1 && selection.startLineNumber === 1) {
|
|
1229
|
+
setNavigateAway("up");
|
|
1230
|
+
}
|
|
1231
|
+
}
|
|
1232
|
+
if (l.code === "ArrowDown") {
|
|
1233
|
+
const selection = monacoEditor.getSelection();
|
|
1234
|
+
const totalLines = monacoEditor.getModel().getLineCount();
|
|
1235
|
+
if (selection.endLineNumber === totalLines && selection.startLineNumber === totalLines) {
|
|
1236
|
+
setNavigateAway("down");
|
|
1237
|
+
}
|
|
1238
|
+
}
|
|
1239
|
+
if (l.code === "Backspace") {
|
|
1240
|
+
const selection = monacoEditor.getSelection();
|
|
1241
|
+
if (selection.endColumn === 1 && selection.endLineNumber === 1 && selection.positionColumn === 1 && selection.positionLineNumber === 1 && selection.selectionStartColumn === 1 && selection.selectionStartLineNumber === 1 && selection.startColumn === 1 && selection.startLineNumber === 1) {
|
|
1242
|
+
setNavigateAway("remove");
|
|
1243
|
+
}
|
|
1244
|
+
}
|
|
1245
|
+
});
|
|
1246
|
+
}
|
|
1247
|
+
return /* @__PURE__ */ React__default.createElement(
|
|
1248
|
+
"div",
|
|
1249
|
+
{
|
|
1250
|
+
...attributes,
|
|
1251
|
+
className: "relative mb-2 mt-0.5 rounded-lg shadow-md p-2 border-gray-200 border"
|
|
1252
|
+
},
|
|
1253
|
+
/* @__PURE__ */ React__default.createElement("style", null, `.monaco-editor .editor-widget {
|
|
1254
|
+
display: none !important;
|
|
1255
|
+
visibility: hidden !important;
|
|
1256
|
+
}`),
|
|
1257
|
+
props.children,
|
|
1258
|
+
/* @__PURE__ */ React__default.createElement("div", { contentEditable: false }, !restrictLanguage && /* @__PURE__ */ React__default.createElement("div", { className: "flex justify-between pb-2" }, /* @__PURE__ */ React__default.createElement("div", null), /* @__PURE__ */ React__default.createElement(
|
|
1259
|
+
Autocomplete,
|
|
1260
|
+
{
|
|
1261
|
+
items: items2,
|
|
1262
|
+
value: currentItem,
|
|
1263
|
+
defaultQuery: "plaintext",
|
|
1264
|
+
onChange: (item) => setNodes(editor, { lang: item.key })
|
|
1265
|
+
}
|
|
1266
|
+
)), /* @__PURE__ */ React__default.createElement("div", { style: { height: `${height}px` } }, /* @__PURE__ */ React__default.createElement(
|
|
1267
|
+
MonacoEditor,
|
|
1268
|
+
{
|
|
1269
|
+
path: id,
|
|
1270
|
+
onMount: handleEditorDidMount,
|
|
1271
|
+
options: {
|
|
1272
|
+
scrollBeyondLastLine: false,
|
|
1273
|
+
// automaticLayout: true,
|
|
1274
|
+
tabSize: 2,
|
|
1275
|
+
disableLayerHinting: true,
|
|
1276
|
+
accessibilitySupport: "off",
|
|
1277
|
+
codeLens: false,
|
|
1278
|
+
wordWrap: "on",
|
|
1279
|
+
minimap: {
|
|
1280
|
+
enabled: false
|
|
1281
|
+
},
|
|
1282
|
+
fontSize: 14,
|
|
1283
|
+
lineHeight: 2,
|
|
1284
|
+
formatOnPaste: true,
|
|
1285
|
+
lineNumbers: "off",
|
|
1286
|
+
formatOnType: true,
|
|
1287
|
+
fixedOverflowWidgets: true,
|
|
1288
|
+
// Takes too much horizontal space for iframe
|
|
1289
|
+
folding: false,
|
|
1290
|
+
renderLineHighlight: "none",
|
|
1291
|
+
scrollbar: {
|
|
1292
|
+
verticalScrollbarSize: 1,
|
|
1293
|
+
horizontalScrollbarSize: 1,
|
|
1294
|
+
// https://github.com/microsoft/monaco-editor/issues/2007#issuecomment-644425664
|
|
1295
|
+
alwaysConsumeMouseWheel: false
|
|
1296
|
+
}
|
|
1297
|
+
},
|
|
1298
|
+
language: String(language),
|
|
1299
|
+
value: String(element.value),
|
|
1300
|
+
onChange: (value2) => {
|
|
1301
|
+
onChangeCallback == null ? void 0 : onChangeCallback(value2);
|
|
1302
|
+
setNodes(editor, { value: value2, lang: language });
|
|
1303
|
+
}
|
|
1304
|
+
}
|
|
1305
|
+
)))
|
|
1306
|
+
);
|
|
1307
|
+
};
|
|
1308
|
+
const CodeBlockElement = withRef(
|
|
1309
|
+
({ className, ...props }, ref) => {
|
|
1310
|
+
const { element } = props;
|
|
1311
|
+
const state = useCodeBlockElementState({ element });
|
|
1312
|
+
return /* @__PURE__ */ React__default.createElement(
|
|
1313
|
+
PlateElement,
|
|
1314
|
+
{
|
|
1315
|
+
className: cn$1("relative py-1", state.className, className),
|
|
1316
|
+
ref,
|
|
1317
|
+
...props
|
|
1318
|
+
},
|
|
1319
|
+
/* @__PURE__ */ React__default.createElement(CodeBlock, { ...props })
|
|
1320
|
+
);
|
|
1321
|
+
}
|
|
1322
|
+
);
|
|
1323
|
+
const CodeLeaf = withRef(
|
|
1324
|
+
({ children, className, ...props }, ref) => {
|
|
1325
|
+
return /* @__PURE__ */ React__default.createElement(
|
|
1326
|
+
PlateLeaf,
|
|
1327
|
+
{
|
|
1328
|
+
asChild: true,
|
|
1329
|
+
className: cn$1(
|
|
1330
|
+
"whitespace-pre-wrap rounded-md bg-muted px-[0.3em] py-[0.2em] font-mono text-sm",
|
|
1331
|
+
className
|
|
1332
|
+
),
|
|
1333
|
+
ref,
|
|
1334
|
+
...props
|
|
1335
|
+
},
|
|
1336
|
+
/* @__PURE__ */ React__default.createElement("code", null, children)
|
|
1337
|
+
);
|
|
1338
|
+
}
|
|
1339
|
+
);
|
|
1340
|
+
const CodeLineElement = withRef((props, ref) => /* @__PURE__ */ React__default.createElement(PlateElement, { ref, ...props }));
|
|
1341
|
+
const CodeSyntaxLeaf = withRef(
|
|
1342
|
+
({ children, ...props }, ref) => {
|
|
1343
|
+
const { leaf } = props;
|
|
1344
|
+
const { tokenProps } = useCodeSyntaxLeaf({ leaf });
|
|
1345
|
+
return /* @__PURE__ */ React__default.createElement(PlateLeaf, { ref, ...props }, /* @__PURE__ */ React__default.createElement("span", { ...tokenProps }, children));
|
|
1346
|
+
}
|
|
1347
|
+
);
|
|
1348
|
+
const listVariants = cva("m-0 ps-6", {
|
|
1349
|
+
variants: {
|
|
1350
|
+
variant: {
|
|
1351
|
+
ol: "list-decimal",
|
|
1352
|
+
ul: "list-disc [&_ul]:list-[circle] [&_ul_ul]:list-[square]"
|
|
1353
|
+
}
|
|
1354
|
+
}
|
|
1355
|
+
});
|
|
1356
|
+
const ListElementVariants = withVariants(PlateElement, listVariants, [
|
|
1357
|
+
"variant"
|
|
1358
|
+
]);
|
|
1359
|
+
const ListElement = withRef(
|
|
1360
|
+
({ children, variant = "ul", ...props }, ref) => {
|
|
1361
|
+
const Component = variant;
|
|
1362
|
+
return /* @__PURE__ */ React__default.createElement(ListElementVariants, { asChild: true, ref, variant, ...props }, /* @__PURE__ */ React__default.createElement(Component, null, children));
|
|
1363
|
+
}
|
|
1364
|
+
);
|
|
1365
|
+
const ELEMENT_MERMAID = "mermaid";
|
|
1366
|
+
const createMermaidPlugin = createPluginFactory({
|
|
1367
|
+
isElement: true,
|
|
1368
|
+
isVoid: true,
|
|
1369
|
+
isInline: false,
|
|
1370
|
+
key: ELEMENT_MERMAID
|
|
1371
|
+
});
|
|
1372
|
+
const MermaidElementWithRef = ({ config }) => {
|
|
1373
|
+
const mermaidRef = useRef(null);
|
|
1374
|
+
useEffect(() => {
|
|
1375
|
+
if (mermaidRef.current) {
|
|
1376
|
+
mermaid.initialize({ startOnLoad: true });
|
|
1377
|
+
mermaid.init();
|
|
1378
|
+
}
|
|
1379
|
+
}, [config]);
|
|
1380
|
+
return /* @__PURE__ */ React__default.createElement("div", { contentEditable: false, className: "border-border border-b" }, /* @__PURE__ */ React__default.createElement("div", { ref: mermaidRef }, /* @__PURE__ */ React__default.createElement("pre", { className: "mermaid not-tina-prose" }, config)));
|
|
1381
|
+
};
|
|
1382
|
+
const Bubble = ({ children }) => {
|
|
1383
|
+
return /* @__PURE__ */ React__default.createElement("div", { className: "bg-blue-600 rounded-full p-2 transition-transform duration-200 ease-in-out hover:scale-110" }, children);
|
|
1384
|
+
};
|
|
1385
|
+
const ErrorMsg = ({ error }) => {
|
|
1386
|
+
if (error) {
|
|
1387
|
+
return /* @__PURE__ */ React__default.createElement(
|
|
1388
|
+
"div",
|
|
1389
|
+
{
|
|
1390
|
+
contentEditable: false,
|
|
1391
|
+
className: "font-mono bg-red-600 text-white p-2 rounded-md cursor-default"
|
|
1392
|
+
},
|
|
1393
|
+
error
|
|
1394
|
+
);
|
|
1395
|
+
}
|
|
1396
|
+
return null;
|
|
1397
|
+
};
|
|
1398
|
+
const DEFAULT_MERMAID_CONFIG = `%% This won't render without implementing a rendering engine (e.g. mermaid on npm)
|
|
1399
|
+
flowchart TD
|
|
1400
|
+
id1(this is an example flow diagram)
|
|
1401
|
+
--> id2(modify me to see changes!)
|
|
1402
|
+
id2
|
|
1403
|
+
--> id3(Click the top button to preview the changes)
|
|
1404
|
+
--> id4(Learn about mermaid diagrams - mermaid.js.org)`;
|
|
1405
|
+
const MermaidElement = withRef(
|
|
1406
|
+
({ children, nodeProps, element, ...props }, ref) => {
|
|
1407
|
+
const [mermaidConfig, setMermaidConfig] = useState(
|
|
1408
|
+
element.value || DEFAULT_MERMAID_CONFIG
|
|
1409
|
+
);
|
|
1410
|
+
const [isEditing, setIsEditing] = useState(
|
|
1411
|
+
mermaidConfig === DEFAULT_MERMAID_CONFIG || false
|
|
1412
|
+
);
|
|
1413
|
+
const [mermaidError, setMermaidError] = useState(null);
|
|
1414
|
+
const node = {
|
|
1415
|
+
type: ELEMENT_MERMAID,
|
|
1416
|
+
value: mermaidConfig,
|
|
1417
|
+
children: [{ type: "text", text: "" }]
|
|
1418
|
+
};
|
|
1419
|
+
useEffect(() => {
|
|
1420
|
+
if (mermaid.parse(mermaidConfig)) {
|
|
1421
|
+
setMermaidError(null);
|
|
1422
|
+
}
|
|
1423
|
+
}, [mermaidConfig]);
|
|
1424
|
+
mermaid.parseError = (err) => {
|
|
1425
|
+
setMermaidError(
|
|
1426
|
+
String(err.message) || "An error occurred while parsing the diagram."
|
|
1427
|
+
);
|
|
1428
|
+
};
|
|
1429
|
+
return /* @__PURE__ */ React__default.createElement(PlateElement, { element, ref, ...props }, /* @__PURE__ */ React__default.createElement("div", { className: "relative group" }, /* @__PURE__ */ React__default.createElement("div", { className: "absolute top-2 right-2 z-10 space-y-2 opacity-0 group-hover:opacity-100 transition-opacity duration-200 ease-in-out" }, /* @__PURE__ */ React__default.createElement(Bubble, null, isEditing ? /* @__PURE__ */ React__default.createElement(
|
|
1430
|
+
Eye,
|
|
1431
|
+
{
|
|
1432
|
+
className: "w-5 h-5 fill-white cursor-pointer",
|
|
1433
|
+
onClick: () => {
|
|
1434
|
+
setIsEditing(!isEditing);
|
|
1435
|
+
}
|
|
1436
|
+
}
|
|
1437
|
+
) : /* @__PURE__ */ React__default.createElement(
|
|
1438
|
+
SquarePen,
|
|
1439
|
+
{
|
|
1440
|
+
className: "w-5 h-5 fill-white cursor-pointer",
|
|
1441
|
+
onClick: () => {
|
|
1442
|
+
setIsEditing(!isEditing);
|
|
1443
|
+
}
|
|
1444
|
+
}
|
|
1445
|
+
))), isEditing ? /* @__PURE__ */ React__default.createElement(
|
|
1446
|
+
CodeBlock,
|
|
1447
|
+
{
|
|
1448
|
+
children: "",
|
|
1449
|
+
language: "yaml",
|
|
1450
|
+
...props,
|
|
1451
|
+
element: node,
|
|
1452
|
+
defaultValue: mermaidConfig,
|
|
1453
|
+
onChangeCallback: (value) => setMermaidConfig(value)
|
|
1454
|
+
}
|
|
1455
|
+
) : /* @__PURE__ */ React__default.createElement(MermaidElementWithRef, { config: mermaidConfig })), children, /* @__PURE__ */ React__default.createElement(ErrorMsg, { error: mermaidError }));
|
|
1456
|
+
}
|
|
1457
|
+
);
|
|
917
1458
|
const RawMarkdown = () => {
|
|
918
1459
|
return /* @__PURE__ */ React__default.createElement(
|
|
919
1460
|
"svg",
|
|
@@ -932,6 +1473,29 @@ const RawMarkdown = () => {
|
|
|
932
1473
|
/* @__PURE__ */ React__default.createElement("path", { d: "M22.27 19.385H1.73A1.73 1.73 0 010 17.655V6.345a1.73 1.73 0 011.73-1.73h20.54A1.73 1.73 0 0124 6.345v11.308a1.73 1.73 0 01-1.73 1.731zM5.769 15.923v-4.5l2.308 2.885 2.307-2.885v4.5h2.308V8.078h-2.308l-2.307 2.885-2.308-2.885H3.46v7.847zM21.232 12h-2.309V8.077h-2.307V12h-2.308l3.461 4.039z" })
|
|
933
1474
|
);
|
|
934
1475
|
};
|
|
1476
|
+
const MermaidIcon = () => /* @__PURE__ */ React__default.createElement(
|
|
1477
|
+
"svg",
|
|
1478
|
+
{
|
|
1479
|
+
width: "100%",
|
|
1480
|
+
height: "100%",
|
|
1481
|
+
viewBox: "0 0 491 491",
|
|
1482
|
+
version: "1.1",
|
|
1483
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
1484
|
+
fillRule: "evenodd",
|
|
1485
|
+
clipRule: "evenodd",
|
|
1486
|
+
strokeLinejoin: "round",
|
|
1487
|
+
strokeMiterlimit: 2
|
|
1488
|
+
},
|
|
1489
|
+
/* @__PURE__ */ React__default.createElement("path", { d: "M490.16,84.61C490.16,37.912 452.248,0 405.55,0L84.61,0C37.912,0 0,37.912 0,84.61L0,405.55C0,452.248 37.912,490.16 84.61,490.16L405.55,490.16C452.248,490.16 490.16,452.248 490.16,405.55L490.16,84.61Z" }),
|
|
1490
|
+
/* @__PURE__ */ React__default.createElement(
|
|
1491
|
+
"path",
|
|
1492
|
+
{
|
|
1493
|
+
d: "M407.48,111.18C335.587,108.103 269.573,152.338 245.08,220C220.587,152.338 154.573,108.103 82.68,111.18C80.285,168.229 107.577,222.632 154.74,254.82C178.908,271.419 193.35,298.951 193.27,328.27L193.27,379.13L296.9,379.13L296.9,328.27C296.816,298.953 311.255,271.42 335.42,254.82C382.596,222.644 409.892,168.233 407.48,111.18Z",
|
|
1494
|
+
fill: "white",
|
|
1495
|
+
fillRule: "nonzero"
|
|
1496
|
+
}
|
|
1497
|
+
)
|
|
1498
|
+
);
|
|
935
1499
|
const borderAll = (props) => /* @__PURE__ */ React__default.createElement(
|
|
936
1500
|
"svg",
|
|
937
1501
|
{
|
|
@@ -1016,7 +1580,7 @@ const borderTop = (props) => /* @__PURE__ */ React__default.createElement(
|
|
|
1016
1580
|
},
|
|
1017
1581
|
/* @__PURE__ */ React__default.createElement("path", { d: "M3 6a1 1 0 0 0 2 0 1 1 0 0 1 1-1h12a1 1 0 0 1 1 1 1 1 0 1 0 2 0 3 3 0 0 0-3-3H6a3 3 0 0 0-3 3zm2 5a1 1 0 1 0-2 0v2a1 1 0 1 0 2 0v-2zm14 0a1 1 0 1 1 2 0v2a1 1 0 1 1-2 0v-2zm-5 9a1 1 0 0 1-1 1h-2a1 1 0 1 1 0-2h2a1 1 0 0 1 1 1zm-8 1a1 1 0 1 0 0-2 1 1 0 0 1-1-1 1 1 0 1 0-2 0 3 3 0 0 0 3 3zm11-1a1 1 0 0 0 1 1 3 3 0 0 0 3-3 1 1 0 1 0-2 0 1 1 0 0 1-1 1 1 1 0 0 0-1 1z" })
|
|
1018
1582
|
);
|
|
1019
|
-
cva("", {
|
|
1583
|
+
const iconVariants = cva("", {
|
|
1020
1584
|
variants: {
|
|
1021
1585
|
variant: {
|
|
1022
1586
|
toolbar: "size-5",
|
|
@@ -1172,6 +1736,7 @@ const Icons = {
|
|
|
1172
1736
|
clear: X,
|
|
1173
1737
|
close: X,
|
|
1174
1738
|
// code: Code2,
|
|
1739
|
+
paint: PaintBucket,
|
|
1175
1740
|
codeblock: FileCode,
|
|
1176
1741
|
color: Baseline,
|
|
1177
1742
|
column: RectangleVertical,
|
|
@@ -1197,6 +1762,7 @@ const Icons = {
|
|
|
1197
1762
|
lineHeight: WrapText,
|
|
1198
1763
|
// link: Link2,
|
|
1199
1764
|
minus: Minus,
|
|
1765
|
+
mermaid: MermaidIcon,
|
|
1200
1766
|
more: MoreHorizontal,
|
|
1201
1767
|
// ol: ListOrdered,
|
|
1202
1768
|
outdent: Outdent,
|
|
@@ -1607,7 +2173,7 @@ const InlineComboboxInput = forwardRef(({ className, ...props }, propRef) => {
|
|
|
1607
2173
|
},
|
|
1608
2174
|
value || ""
|
|
1609
2175
|
), /* @__PURE__ */ React__default.createElement(
|
|
1610
|
-
Combobox,
|
|
2176
|
+
Combobox$2,
|
|
1611
2177
|
{
|
|
1612
2178
|
autoSelect: true,
|
|
1613
2179
|
className: cn$1(
|
|
@@ -1767,417 +2333,482 @@ const SlashInputElement = withRef(
|
|
|
1767
2333
|
);
|
|
1768
2334
|
}
|
|
1769
2335
|
);
|
|
1770
|
-
const
|
|
1771
|
-
|
|
1772
|
-
|
|
1773
|
-
|
|
1774
|
-
|
|
1775
|
-
|
|
1776
|
-
|
|
1777
|
-
|
|
1778
|
-
|
|
1779
|
-
|
|
1780
|
-
|
|
1781
|
-
|
|
1782
|
-
|
|
1783
|
-
|
|
1784
|
-
|
|
1785
|
-
}
|
|
1786
|
-
|
|
1787
|
-
|
|
1788
|
-
|
|
1789
|
-
|
|
1790
|
-
|
|
1791
|
-
|
|
1792
|
-
|
|
1793
|
-
className: cn$1("my-1 border-l-2 pl-6 italic", className),
|
|
1794
|
-
ref,
|
|
1795
|
-
...props
|
|
1796
|
-
},
|
|
1797
|
-
/* @__PURE__ */ React__default.createElement("blockquote", null, children)
|
|
1798
|
-
);
|
|
1799
|
-
}
|
|
1800
|
-
);
|
|
1801
|
-
const CodeLeaf = withRef(
|
|
1802
|
-
({ children, className, ...props }, ref) => {
|
|
1803
|
-
return /* @__PURE__ */ React__default.createElement(
|
|
1804
|
-
PlateLeaf,
|
|
1805
|
-
{
|
|
1806
|
-
asChild: true,
|
|
1807
|
-
className: cn$1(
|
|
1808
|
-
"whitespace-pre-wrap rounded-md bg-muted px-[0.3em] py-[0.2em] font-mono text-sm",
|
|
1809
|
-
className
|
|
1810
|
-
),
|
|
1811
|
-
ref,
|
|
1812
|
-
...props
|
|
1813
|
-
},
|
|
1814
|
-
/* @__PURE__ */ React__default.createElement("code", null, children)
|
|
1815
|
-
);
|
|
1816
|
-
}
|
|
1817
|
-
);
|
|
1818
|
-
const CodeLineElement = withRef((props, ref) => /* @__PURE__ */ React__default.createElement(PlateElement, { ref, ...props }));
|
|
1819
|
-
const CodeSyntaxLeaf = withRef(
|
|
1820
|
-
({ children, ...props }, ref) => {
|
|
1821
|
-
const { leaf } = props;
|
|
1822
|
-
const { tokenProps } = useCodeSyntaxLeaf({ leaf });
|
|
1823
|
-
return /* @__PURE__ */ React__default.createElement(PlateLeaf, { ref, ...props }, /* @__PURE__ */ React__default.createElement("span", { ...tokenProps }, children));
|
|
1824
|
-
}
|
|
1825
|
-
);
|
|
1826
|
-
function ChevronDownIcon(props, svgRef) {
|
|
1827
|
-
return /* @__PURE__ */ React.createElement("svg", Object.assign({
|
|
1828
|
-
xmlns: "http://www.w3.org/2000/svg",
|
|
1829
|
-
viewBox: "0 0 20 20",
|
|
1830
|
-
fill: "currentColor",
|
|
1831
|
-
"aria-hidden": "true",
|
|
1832
|
-
ref: svgRef
|
|
1833
|
-
}, props), /* @__PURE__ */ React.createElement("path", {
|
|
1834
|
-
fillRule: "evenodd",
|
|
1835
|
-
d: "M5.293 7.293a1 1 0 011.414 0L10 10.586l3.293-3.293a1 1 0 111.414 1.414l-4 4a1 1 0 01-1.414 0l-4-4a1 1 0 010-1.414z",
|
|
1836
|
-
clipRule: "evenodd"
|
|
1837
|
-
}));
|
|
1838
|
-
}
|
|
1839
|
-
const ForwardRef = React.forwardRef(ChevronDownIcon);
|
|
1840
|
-
const ChevronDownIcon$1 = ForwardRef;
|
|
1841
|
-
const Autocomplete = ({
|
|
1842
|
-
value,
|
|
1843
|
-
onChange,
|
|
1844
|
-
defaultQuery,
|
|
1845
|
-
items: items2
|
|
1846
|
-
}) => {
|
|
1847
|
-
const [query, setQuery] = React__default.useState(defaultQuery ?? "");
|
|
1848
|
-
const filteredItems = React__default.useMemo(() => {
|
|
1849
|
-
try {
|
|
1850
|
-
const reFilter = new RegExp(query, "i");
|
|
1851
|
-
const _items = items2.filter((item) => reFilter.test(item.label));
|
|
1852
|
-
if (_items.length === 0)
|
|
1853
|
-
return items2;
|
|
1854
|
-
return _items;
|
|
1855
|
-
} catch (err) {
|
|
1856
|
-
return items2;
|
|
1857
|
-
}
|
|
1858
|
-
}, [items2, query]);
|
|
2336
|
+
const TableCellElement = withRef(({ children, className, hideBorder, isHeader, style, ...props }, ref) => {
|
|
2337
|
+
var _a, _b, _c, _d;
|
|
2338
|
+
const { element } = props;
|
|
2339
|
+
const {
|
|
2340
|
+
borders,
|
|
2341
|
+
colIndex,
|
|
2342
|
+
colSpan,
|
|
2343
|
+
hovered,
|
|
2344
|
+
hoveredLeft,
|
|
2345
|
+
isSelectingCell,
|
|
2346
|
+
readOnly,
|
|
2347
|
+
rowIndex,
|
|
2348
|
+
rowSize,
|
|
2349
|
+
selected
|
|
2350
|
+
} = useTableCellElementState();
|
|
2351
|
+
const { props: cellProps } = useTableCellElement({ element: props.element });
|
|
2352
|
+
const resizableState = useTableCellElementResizableState({
|
|
2353
|
+
colIndex,
|
|
2354
|
+
colSpan,
|
|
2355
|
+
rowIndex
|
|
2356
|
+
});
|
|
2357
|
+
const { bottomProps, hiddenLeft, leftProps, rightProps } = useTableCellElementResizable(resizableState);
|
|
2358
|
+
const Cell = isHeader ? "th" : "td";
|
|
1859
2359
|
return /* @__PURE__ */ React__default.createElement(
|
|
1860
|
-
|
|
2360
|
+
PlateElement,
|
|
1861
2361
|
{
|
|
1862
|
-
|
|
1863
|
-
|
|
1864
|
-
|
|
1865
|
-
|
|
1866
|
-
|
|
1867
|
-
|
|
1868
|
-
|
|
1869
|
-
|
|
1870
|
-
|
|
1871
|
-
|
|
1872
|
-
|
|
1873
|
-
|
|
2362
|
+
asChild: true,
|
|
2363
|
+
className: cn$1(
|
|
2364
|
+
"relative h-full overflow-visible border-none bg-background p-0",
|
|
2365
|
+
hideBorder && "before:border-none",
|
|
2366
|
+
element.background ? "bg-[--cellBackground]" : "bg-background",
|
|
2367
|
+
!hideBorder && cn$1(
|
|
2368
|
+
isHeader && "text-left [&_>_*]:m-0",
|
|
2369
|
+
"before:size-full",
|
|
2370
|
+
selected && "before:z-10 before:bg-muted",
|
|
2371
|
+
"before:absolute before:box-border before:select-none before:content-['']",
|
|
2372
|
+
borders && cn$1(
|
|
2373
|
+
((_a = borders.bottom) == null ? void 0 : _a.size) && `before:border-b before:border-b-border`,
|
|
2374
|
+
((_b = borders.right) == null ? void 0 : _b.size) && `before:border-r before:border-r-border`,
|
|
2375
|
+
((_c = borders.left) == null ? void 0 : _c.size) && `before:border-l before:border-l-border`,
|
|
2376
|
+
((_d = borders.top) == null ? void 0 : _d.size) && `before:border-t before:border-t-border`
|
|
2377
|
+
)
|
|
2378
|
+
),
|
|
2379
|
+
className
|
|
2380
|
+
),
|
|
2381
|
+
ref,
|
|
2382
|
+
...cellProps,
|
|
2383
|
+
...props,
|
|
2384
|
+
style: {
|
|
2385
|
+
"--cellBackground": element.background,
|
|
2386
|
+
...style
|
|
1874
2387
|
}
|
|
1875
|
-
|
|
1876
|
-
|
|
2388
|
+
},
|
|
2389
|
+
/* @__PURE__ */ React__default.createElement(Cell, null, /* @__PURE__ */ React__default.createElement(
|
|
2390
|
+
"div",
|
|
1877
2391
|
{
|
|
1878
|
-
className: "h-
|
|
1879
|
-
|
|
1880
|
-
|
|
1881
|
-
|
|
1882
|
-
|
|
1883
|
-
|
|
2392
|
+
className: "relative z-20 box-border h-full px-3 py-2",
|
|
2393
|
+
style: {
|
|
2394
|
+
minHeight: rowSize
|
|
2395
|
+
}
|
|
2396
|
+
},
|
|
2397
|
+
children
|
|
2398
|
+
), !isSelectingCell && /* @__PURE__ */ React__default.createElement(
|
|
2399
|
+
"div",
|
|
1884
2400
|
{
|
|
1885
|
-
|
|
1886
|
-
|
|
1887
|
-
|
|
1888
|
-
leave: "transition ease-in duration-75",
|
|
1889
|
-
leaveFrom: "transform opacity-100 scale-100",
|
|
1890
|
-
leaveTo: "transform opacity-0 scale-95"
|
|
2401
|
+
className: "group absolute top-0 size-full select-none",
|
|
2402
|
+
contentEditable: false,
|
|
2403
|
+
suppressContentEditableWarning: true
|
|
1891
2404
|
},
|
|
1892
|
-
|
|
1893
|
-
|
|
2405
|
+
!readOnly && /* @__PURE__ */ React__default.createElement(React__default.Fragment, null, /* @__PURE__ */ React__default.createElement(
|
|
2406
|
+
ResizeHandle$1,
|
|
1894
2407
|
{
|
|
1895
|
-
|
|
1896
|
-
|
|
1897
|
-
|
|
2408
|
+
...rightProps,
|
|
2409
|
+
className: "-top-3 right-[-5px] w-[10px]"
|
|
2410
|
+
}
|
|
2411
|
+
), /* @__PURE__ */ React__default.createElement(
|
|
2412
|
+
ResizeHandle$1,
|
|
2413
|
+
{
|
|
2414
|
+
...bottomProps,
|
|
2415
|
+
className: "bottom-[-5px] h-[10px]"
|
|
2416
|
+
}
|
|
2417
|
+
), !hiddenLeft && /* @__PURE__ */ React__default.createElement(
|
|
2418
|
+
ResizeHandle$1,
|
|
2419
|
+
{
|
|
2420
|
+
...leftProps,
|
|
2421
|
+
className: "-top-3 left-[-5px] w-[10px]"
|
|
2422
|
+
}
|
|
2423
|
+
), hovered && /* @__PURE__ */ React__default.createElement(
|
|
2424
|
+
"div",
|
|
2425
|
+
{
|
|
2426
|
+
className: cn$1(
|
|
2427
|
+
"absolute -top-3 z-30 h-[calc(100%_+_12px)] w-1 bg-ring",
|
|
2428
|
+
"right-[-1.5px]"
|
|
1898
2429
|
)
|
|
1899
|
-
}
|
|
1900
|
-
|
|
1901
|
-
|
|
1902
|
-
|
|
2430
|
+
}
|
|
2431
|
+
), hoveredLeft && /* @__PURE__ */ React__default.createElement(
|
|
2432
|
+
"div",
|
|
2433
|
+
{
|
|
2434
|
+
className: cn$1(
|
|
2435
|
+
"absolute -top-3 z-30 h-[calc(100%_+_12px)] w-1 bg-ring",
|
|
2436
|
+
"left-[-1.5px]"
|
|
2437
|
+
)
|
|
2438
|
+
}
|
|
2439
|
+
))
|
|
2440
|
+
))
|
|
1903
2441
|
);
|
|
1904
|
-
};
|
|
1905
|
-
loader.config({
|
|
1906
|
-
paths: { vs: "https://cdn.jsdelivr.net/npm/monaco-editor@0.31.1/min/vs" }
|
|
1907
2442
|
});
|
|
1908
|
-
|
|
1909
|
-
const
|
|
1910
|
-
|
|
1911
|
-
|
|
1912
|
-
|
|
1913
|
-
|
|
1914
|
-
|
|
1915
|
-
|
|
1916
|
-
|
|
1917
|
-
|
|
1918
|
-
}
|
|
1919
|
-
|
|
1920
|
-
|
|
1921
|
-
|
|
1922
|
-
|
|
1923
|
-
|
|
1924
|
-
|
|
1925
|
-
|
|
1926
|
-
|
|
1927
|
-
|
|
1928
|
-
|
|
1929
|
-
|
|
1930
|
-
|
|
1931
|
-
|
|
1932
|
-
|
|
1933
|
-
|
|
1934
|
-
|
|
1935
|
-
|
|
2443
|
+
TableCellElement.displayName = "TableCellElement";
|
|
2444
|
+
const TableCellHeaderElement = withProps(TableCellElement, {
|
|
2445
|
+
isHeader: true
|
|
2446
|
+
});
|
|
2447
|
+
const buttonVariants$1 = cva(
|
|
2448
|
+
"inline-flex items-center justify-center whitespace-nowrap rounded-md text-sm font-medium ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50",
|
|
2449
|
+
{
|
|
2450
|
+
defaultVariants: {
|
|
2451
|
+
size: "default",
|
|
2452
|
+
variant: "default"
|
|
2453
|
+
},
|
|
2454
|
+
variants: {
|
|
2455
|
+
isMenu: {
|
|
2456
|
+
true: "h-auto w-full cursor-pointer justify-start"
|
|
2457
|
+
},
|
|
2458
|
+
size: {
|
|
2459
|
+
default: "h-10 px-4 py-2",
|
|
2460
|
+
icon: "size-10",
|
|
2461
|
+
lg: "h-11 rounded-md px-8",
|
|
2462
|
+
none: "",
|
|
2463
|
+
sm: "h-9 rounded-md px-3",
|
|
2464
|
+
sms: "size-9 rounded-md px-0",
|
|
2465
|
+
xs: "h-8 rounded-md px-3"
|
|
2466
|
+
},
|
|
2467
|
+
variant: {
|
|
2468
|
+
default: "bg-primary text-primary-foreground hover:bg-primary/90",
|
|
2469
|
+
destructive: "bg-destructive text-destructive-foreground hover:bg-destructive/90",
|
|
2470
|
+
ghost: "hover:bg-accent hover:text-accent-foreground",
|
|
2471
|
+
inlineLink: "text-base text-primary underline underline-offset-4",
|
|
2472
|
+
link: "text-primary underline-offset-4 hover:underline",
|
|
2473
|
+
outline: "border border-input bg-background hover:bg-accent hover:text-accent-foreground",
|
|
2474
|
+
secondary: "bg-secondary text-secondary-foreground hover:bg-secondary/80"
|
|
2475
|
+
}
|
|
1936
2476
|
}
|
|
1937
|
-
}, [selected, monacoEditorRef.current]);
|
|
1938
|
-
const value = element.value || "";
|
|
1939
|
-
if (typeof value !== "string") {
|
|
1940
|
-
throw new Error("Element must be of type string for code block");
|
|
1941
2477
|
}
|
|
1942
|
-
|
|
1943
|
-
|
|
1944
|
-
const
|
|
1945
|
-
|
|
1946
|
-
|
|
1947
|
-
|
|
1948
|
-
|
|
1949
|
-
|
|
1950
|
-
|
|
1951
|
-
return { ...ac, [cv.id]: cv.id };
|
|
1952
|
-
}, defaultLangSet);
|
|
1953
|
-
}, [monaco]);
|
|
1954
|
-
React__default.useEffect(() => {
|
|
1955
|
-
if (monaco) {
|
|
1956
|
-
monaco.languages.typescript.typescriptDefaults.setEagerModelSync(true);
|
|
1957
|
-
monaco.languages.typescript.typescriptDefaults.setDiagnosticsOptions({
|
|
1958
|
-
// disable errors
|
|
1959
|
-
noSemanticValidation: true,
|
|
1960
|
-
noSyntaxValidation: true
|
|
1961
|
-
});
|
|
2478
|
+
);
|
|
2479
|
+
const Button$2 = withRef(({ asChild = false, className, isMenu, size, variant, ...props }, ref) => {
|
|
2480
|
+
const Comp = asChild ? Slot : "button";
|
|
2481
|
+
return /* @__PURE__ */ React.createElement(
|
|
2482
|
+
Comp,
|
|
2483
|
+
{
|
|
2484
|
+
className: cn$1(buttonVariants$1({ className, isMenu, size, variant })),
|
|
2485
|
+
ref,
|
|
2486
|
+
...props
|
|
1962
2487
|
}
|
|
1963
|
-
|
|
1964
|
-
|
|
1965
|
-
|
|
1966
|
-
|
|
1967
|
-
|
|
1968
|
-
|
|
1969
|
-
|
|
1970
|
-
|
|
1971
|
-
|
|
1972
|
-
|
|
1973
|
-
|
|
1974
|
-
|
|
1975
|
-
|
|
1976
|
-
|
|
1977
|
-
|
|
1978
|
-
|
|
1979
|
-
|
|
1980
|
-
|
|
1981
|
-
|
|
1982
|
-
|
|
1983
|
-
|
|
1984
|
-
|
|
1985
|
-
|
|
1986
|
-
|
|
1987
|
-
|
|
1988
|
-
|
|
1989
|
-
|
|
1990
|
-
|
|
1991
|
-
|
|
1992
|
-
|
|
1993
|
-
|
|
1994
|
-
|
|
1995
|
-
|
|
1996
|
-
|
|
1997
|
-
|
|
1998
|
-
|
|
1999
|
-
|
|
2000
|
-
|
|
2001
|
-
|
|
2002
|
-
|
|
2003
|
-
|
|
2004
|
-
|
|
2005
|
-
{
|
|
2006
|
-
type: ELEMENT_DEFAULT,
|
|
2007
|
-
children: [{ text: "" }],
|
|
2008
|
-
lang: void 0,
|
|
2009
|
-
value: void 0
|
|
2010
|
-
}
|
|
2011
|
-
],
|
|
2012
|
-
{ select: true }
|
|
2013
|
-
);
|
|
2014
|
-
focusEditor(editor);
|
|
2015
|
-
}
|
|
2016
|
-
break;
|
|
2017
|
-
case "up":
|
|
2018
|
-
{
|
|
2019
|
-
const path = findNodePath(editor, element);
|
|
2020
|
-
if (!path) {
|
|
2021
|
-
return;
|
|
2022
|
-
}
|
|
2023
|
-
const previousNodePath = getPointBefore(editor, path);
|
|
2024
|
-
if (!previousNodePath) {
|
|
2025
|
-
focusEditor(editor);
|
|
2026
|
-
insertNodes(
|
|
2027
|
-
editor,
|
|
2028
|
-
[
|
|
2029
|
-
{
|
|
2030
|
-
type: ELEMENT_DEFAULT,
|
|
2031
|
-
children: [{ text: "" }],
|
|
2032
|
-
lang: void 0,
|
|
2033
|
-
value: void 0
|
|
2034
|
-
}
|
|
2035
|
-
],
|
|
2036
|
-
// Insert a new node at the current path, resulting in the code_block
|
|
2037
|
-
// moving down one block
|
|
2038
|
-
{ at: path, select: true }
|
|
2039
|
-
);
|
|
2040
|
-
return;
|
|
2041
|
-
}
|
|
2042
|
-
focusEditor(editor, previousNodePath);
|
|
2043
|
-
}
|
|
2044
|
-
break;
|
|
2045
|
-
case "down": {
|
|
2046
|
-
const path = findNodePath(editor, element);
|
|
2047
|
-
if (!path) {
|
|
2048
|
-
return;
|
|
2049
|
-
}
|
|
2050
|
-
const nextNodePath = getPointAfter(editor, path);
|
|
2051
|
-
if (!nextNodePath) {
|
|
2052
|
-
insertNodes(
|
|
2053
|
-
editor,
|
|
2054
|
-
[
|
|
2055
|
-
{
|
|
2056
|
-
type: ELEMENT_DEFAULT,
|
|
2057
|
-
children: [{ text: "" }],
|
|
2058
|
-
lang: void 0,
|
|
2059
|
-
value: void 0
|
|
2060
|
-
}
|
|
2061
|
-
],
|
|
2062
|
-
{ select: true }
|
|
2063
|
-
);
|
|
2064
|
-
focusEditor(editor);
|
|
2065
|
-
} else {
|
|
2066
|
-
focusEditor(editor, nextNodePath);
|
|
2067
|
-
}
|
|
2068
|
-
break;
|
|
2069
|
-
}
|
|
2488
|
+
);
|
|
2489
|
+
});
|
|
2490
|
+
const DropdownMenu = DropdownMenuPrimitive.Root;
|
|
2491
|
+
const DropdownMenuTrigger = DropdownMenuPrimitive.Trigger;
|
|
2492
|
+
const DropdownMenuPortal = DropdownMenuPrimitive.Portal;
|
|
2493
|
+
const DropdownMenuSub = DropdownMenuPrimitive.Sub;
|
|
2494
|
+
const DropdownMenuRadioGroup = DropdownMenuPrimitive.RadioGroup;
|
|
2495
|
+
const DropdownMenuSubTrigger = withRef(({ children, className, inset, ...props }, ref) => /* @__PURE__ */ React__default.createElement(
|
|
2496
|
+
DropdownMenuPrimitive.SubTrigger,
|
|
2497
|
+
{
|
|
2498
|
+
className: cn$1(
|
|
2499
|
+
"flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none focus:bg-accent data-[state=open]:bg-accent",
|
|
2500
|
+
"data-[disabled]:pointer-events-none data-[disabled]:opacity-50",
|
|
2501
|
+
inset && "pl-8",
|
|
2502
|
+
className
|
|
2503
|
+
),
|
|
2504
|
+
ref,
|
|
2505
|
+
...props
|
|
2506
|
+
},
|
|
2507
|
+
children,
|
|
2508
|
+
/* @__PURE__ */ React__default.createElement(Icons.chevronRight, { className: "ml-auto size-4" })
|
|
2509
|
+
));
|
|
2510
|
+
const DropdownMenuSubContent = withCn(
|
|
2511
|
+
DropdownMenuPrimitive.SubContent,
|
|
2512
|
+
"z-[99999] min-w-32 overflow-hidden rounded-md border bg-white p-1 text-black shadow-lg data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2"
|
|
2513
|
+
);
|
|
2514
|
+
const DropdownMenuContentVariants = withProps(DropdownMenuPrimitive.Content, {
|
|
2515
|
+
className: cn$1(
|
|
2516
|
+
"z-[99999] min-w-32 overflow-hidden rounded-md border bg-white p-1 text-black shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2"
|
|
2517
|
+
),
|
|
2518
|
+
sideOffset: 4
|
|
2519
|
+
});
|
|
2520
|
+
const DropdownMenuContent = withRef(({ ...props }, ref) => /* @__PURE__ */ React__default.createElement(DropdownMenuPrimitive.Portal, null, /* @__PURE__ */ React__default.createElement(DropdownMenuContentVariants, { ref, ...props })));
|
|
2521
|
+
const menuItemVariants = cva(
|
|
2522
|
+
cn$1(
|
|
2523
|
+
"relative flex h-9 cursor-pointer select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none transition-colors",
|
|
2524
|
+
"focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50"
|
|
2525
|
+
),
|
|
2526
|
+
{
|
|
2527
|
+
variants: {
|
|
2528
|
+
inset: {
|
|
2529
|
+
true: "pl-8"
|
|
2070
2530
|
}
|
|
2071
2531
|
}
|
|
2072
|
-
}
|
|
2073
|
-
|
|
2074
|
-
|
|
2075
|
-
|
|
2076
|
-
|
|
2077
|
-
|
|
2078
|
-
|
|
2079
|
-
|
|
2080
|
-
|
|
2081
|
-
|
|
2082
|
-
|
|
2083
|
-
|
|
2084
|
-
|
|
2085
|
-
|
|
2086
|
-
|
|
2087
|
-
|
|
2088
|
-
|
|
2089
|
-
|
|
2090
|
-
|
|
2091
|
-
|
|
2092
|
-
|
|
2093
|
-
|
|
2094
|
-
|
|
2095
|
-
|
|
2096
|
-
|
|
2097
|
-
|
|
2098
|
-
|
|
2099
|
-
|
|
2100
|
-
|
|
2101
|
-
|
|
2102
|
-
|
|
2532
|
+
}
|
|
2533
|
+
);
|
|
2534
|
+
const DropdownMenuItem = withVariants(
|
|
2535
|
+
DropdownMenuPrimitive.Item,
|
|
2536
|
+
menuItemVariants,
|
|
2537
|
+
["inset"]
|
|
2538
|
+
);
|
|
2539
|
+
const DropdownMenuCheckboxItem = withRef(({ children, className, ...props }, ref) => /* @__PURE__ */ React__default.createElement(
|
|
2540
|
+
DropdownMenuPrimitive.CheckboxItem,
|
|
2541
|
+
{
|
|
2542
|
+
className: cn$1(
|
|
2543
|
+
"relative flex select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",
|
|
2544
|
+
"cursor-pointer",
|
|
2545
|
+
className
|
|
2546
|
+
),
|
|
2547
|
+
ref,
|
|
2548
|
+
...props
|
|
2549
|
+
},
|
|
2550
|
+
/* @__PURE__ */ React__default.createElement("span", { className: "absolute left-2 flex size-3.5 items-center justify-center" }, /* @__PURE__ */ React__default.createElement(DropdownMenuPrimitive.ItemIndicator, null, /* @__PURE__ */ React__default.createElement(Icons.check, { className: "size-4" }))),
|
|
2551
|
+
children
|
|
2552
|
+
));
|
|
2553
|
+
const DropdownMenuRadioItem = withRef(({ children, className, hideIcon, ...props }, ref) => /* @__PURE__ */ React__default.createElement(
|
|
2554
|
+
DropdownMenuPrimitive.RadioItem,
|
|
2555
|
+
{
|
|
2556
|
+
className: cn$1(
|
|
2557
|
+
"relative flex select-none items-center rounded-sm pl-8 pr-2 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",
|
|
2558
|
+
"h-9 cursor-pointer px-2 data-[state=checked]:bg-accent data-[state=checked]:text-accent-foreground",
|
|
2559
|
+
className
|
|
2560
|
+
),
|
|
2561
|
+
ref,
|
|
2562
|
+
...props
|
|
2563
|
+
},
|
|
2564
|
+
!hideIcon && /* @__PURE__ */ React__default.createElement("span", { className: "absolute right-2 flex size-3.5 items-center justify-center" }, /* @__PURE__ */ React__default.createElement(DropdownMenuPrimitive.ItemIndicator, null, /* @__PURE__ */ React__default.createElement(Icons.check, { className: "size-4" }))),
|
|
2565
|
+
children
|
|
2566
|
+
));
|
|
2567
|
+
const dropdownMenuLabelVariants = cva(
|
|
2568
|
+
cn$1("select-none px-2 py-1.5 text-sm font-semibold"),
|
|
2569
|
+
{
|
|
2570
|
+
variants: {
|
|
2571
|
+
inset: {
|
|
2572
|
+
true: "pl-8"
|
|
2103
2573
|
}
|
|
2104
|
-
}
|
|
2574
|
+
}
|
|
2105
2575
|
}
|
|
2576
|
+
);
|
|
2577
|
+
const DropdownMenuLabel = withVariants(
|
|
2578
|
+
DropdownMenuPrimitive.Label,
|
|
2579
|
+
dropdownMenuLabelVariants,
|
|
2580
|
+
["inset"]
|
|
2581
|
+
);
|
|
2582
|
+
const DropdownMenuSeparator = withCn(
|
|
2583
|
+
DropdownMenuPrimitive.Separator,
|
|
2584
|
+
"-mx-1 my-1 h-px bg-muted"
|
|
2585
|
+
);
|
|
2586
|
+
withCn(
|
|
2587
|
+
createPrimitiveElement("span"),
|
|
2588
|
+
"ml-auto text-xs tracking-widest opacity-60"
|
|
2589
|
+
);
|
|
2590
|
+
const useOpenState = () => {
|
|
2591
|
+
const [open2, setOpen] = useState(false);
|
|
2592
|
+
const onOpenChange = useCallback(
|
|
2593
|
+
(_value = !open2) => {
|
|
2594
|
+
setOpen(_value);
|
|
2595
|
+
},
|
|
2596
|
+
[open2]
|
|
2597
|
+
);
|
|
2598
|
+
return {
|
|
2599
|
+
onOpenChange,
|
|
2600
|
+
open: open2
|
|
2601
|
+
};
|
|
2602
|
+
};
|
|
2603
|
+
const Popover$2 = PopoverPrimitive.Root;
|
|
2604
|
+
const popoverVariants = cva(
|
|
2605
|
+
"w-72 rounded-md border bg-popover p-4 text-popover-foreground shadow-md outline-none data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 print:hidden"
|
|
2606
|
+
);
|
|
2607
|
+
const PopoverContent$1 = withRef(
|
|
2608
|
+
({ align = "center", className, sideOffset = 4, style, ...props }, ref) => /* @__PURE__ */ React.createElement(PopoverPrimitive.Portal, null, /* @__PURE__ */ React.createElement(
|
|
2609
|
+
PopoverPrimitive.Content,
|
|
2610
|
+
{
|
|
2611
|
+
align,
|
|
2612
|
+
className: cn$1(popoverVariants(), className),
|
|
2613
|
+
ref,
|
|
2614
|
+
sideOffset,
|
|
2615
|
+
style: { zIndex: 1e3, ...style },
|
|
2616
|
+
...props
|
|
2617
|
+
}
|
|
2618
|
+
))
|
|
2619
|
+
);
|
|
2620
|
+
const separatorVariants = cva("shrink-0 bg-border", {
|
|
2621
|
+
defaultVariants: {
|
|
2622
|
+
orientation: "horizontal"
|
|
2623
|
+
},
|
|
2624
|
+
variants: {
|
|
2625
|
+
orientation: {
|
|
2626
|
+
horizontal: "h-px w-full",
|
|
2627
|
+
vertical: "h-full w-px"
|
|
2628
|
+
}
|
|
2629
|
+
}
|
|
2630
|
+
});
|
|
2631
|
+
const Separator = withVariants(
|
|
2632
|
+
withProps(SeparatorPrimitive.Root, {
|
|
2633
|
+
decorative: true,
|
|
2634
|
+
orientation: "horizontal"
|
|
2635
|
+
}),
|
|
2636
|
+
separatorVariants
|
|
2637
|
+
);
|
|
2638
|
+
const TableBordersDropdownMenuContent = withRef((props, ref) => {
|
|
2639
|
+
const {
|
|
2640
|
+
getOnSelectTableBorder,
|
|
2641
|
+
hasBottomBorder,
|
|
2642
|
+
hasLeftBorder,
|
|
2643
|
+
hasNoBorders,
|
|
2644
|
+
hasOuterBorders,
|
|
2645
|
+
hasRightBorder,
|
|
2646
|
+
hasTopBorder
|
|
2647
|
+
} = useTableBordersDropdownMenuContentState();
|
|
2106
2648
|
return /* @__PURE__ */ React__default.createElement(
|
|
2107
|
-
|
|
2649
|
+
DropdownMenuContent,
|
|
2108
2650
|
{
|
|
2109
|
-
|
|
2110
|
-
className: "
|
|
2651
|
+
align: "start",
|
|
2652
|
+
className: cn$1("min-w-[220px]"),
|
|
2653
|
+
ref,
|
|
2654
|
+
side: "right",
|
|
2655
|
+
sideOffset: 0,
|
|
2656
|
+
...props
|
|
2111
2657
|
},
|
|
2112
|
-
/* @__PURE__ */ React__default.createElement(
|
|
2113
|
-
|
|
2114
|
-
visibility: hidden !important;
|
|
2115
|
-
}`),
|
|
2116
|
-
props.children,
|
|
2117
|
-
/* @__PURE__ */ React__default.createElement("div", { contentEditable: false }, !restrictLanguage && /* @__PURE__ */ React__default.createElement("div", { className: "flex justify-between pb-2" }, /* @__PURE__ */ React__default.createElement("div", null), /* @__PURE__ */ React__default.createElement(
|
|
2118
|
-
Autocomplete,
|
|
2658
|
+
/* @__PURE__ */ React__default.createElement(
|
|
2659
|
+
DropdownMenuCheckboxItem,
|
|
2119
2660
|
{
|
|
2120
|
-
|
|
2121
|
-
|
|
2122
|
-
|
|
2123
|
-
|
|
2124
|
-
|
|
2125
|
-
)
|
|
2126
|
-
|
|
2661
|
+
checked: hasBottomBorder,
|
|
2662
|
+
onCheckedChange: getOnSelectTableBorder("bottom")
|
|
2663
|
+
},
|
|
2664
|
+
/* @__PURE__ */ React__default.createElement(Icons.borderBottom, { className: iconVariants({ size: "sm" }) }),
|
|
2665
|
+
/* @__PURE__ */ React__default.createElement("div", null, "Bottom Border")
|
|
2666
|
+
),
|
|
2667
|
+
/* @__PURE__ */ React__default.createElement(
|
|
2668
|
+
DropdownMenuCheckboxItem,
|
|
2127
2669
|
{
|
|
2128
|
-
|
|
2129
|
-
|
|
2130
|
-
|
|
2131
|
-
|
|
2132
|
-
|
|
2133
|
-
|
|
2134
|
-
|
|
2135
|
-
|
|
2136
|
-
|
|
2137
|
-
|
|
2138
|
-
|
|
2139
|
-
|
|
2140
|
-
|
|
2141
|
-
|
|
2142
|
-
|
|
2143
|
-
|
|
2144
|
-
|
|
2145
|
-
|
|
2146
|
-
|
|
2147
|
-
|
|
2148
|
-
|
|
2149
|
-
|
|
2150
|
-
|
|
2151
|
-
|
|
2152
|
-
|
|
2153
|
-
|
|
2154
|
-
|
|
2155
|
-
|
|
2156
|
-
|
|
2157
|
-
|
|
2158
|
-
|
|
2159
|
-
|
|
2160
|
-
|
|
2161
|
-
|
|
2162
|
-
|
|
2163
|
-
|
|
2670
|
+
checked: hasTopBorder,
|
|
2671
|
+
onCheckedChange: getOnSelectTableBorder("top")
|
|
2672
|
+
},
|
|
2673
|
+
/* @__PURE__ */ React__default.createElement(Icons.borderTop, { className: iconVariants({ size: "sm" }) }),
|
|
2674
|
+
/* @__PURE__ */ React__default.createElement("div", null, "Top Border")
|
|
2675
|
+
),
|
|
2676
|
+
/* @__PURE__ */ React__default.createElement(
|
|
2677
|
+
DropdownMenuCheckboxItem,
|
|
2678
|
+
{
|
|
2679
|
+
checked: hasLeftBorder,
|
|
2680
|
+
onCheckedChange: getOnSelectTableBorder("left")
|
|
2681
|
+
},
|
|
2682
|
+
/* @__PURE__ */ React__default.createElement(Icons.borderLeft, { className: iconVariants({ size: "sm" }) }),
|
|
2683
|
+
/* @__PURE__ */ React__default.createElement("div", null, "Left Border")
|
|
2684
|
+
),
|
|
2685
|
+
/* @__PURE__ */ React__default.createElement(
|
|
2686
|
+
DropdownMenuCheckboxItem,
|
|
2687
|
+
{
|
|
2688
|
+
checked: hasRightBorder,
|
|
2689
|
+
onCheckedChange: getOnSelectTableBorder("right")
|
|
2690
|
+
},
|
|
2691
|
+
/* @__PURE__ */ React__default.createElement(Icons.borderRight, { className: iconVariants({ size: "sm" }) }),
|
|
2692
|
+
/* @__PURE__ */ React__default.createElement("div", null, "Right Border")
|
|
2693
|
+
),
|
|
2694
|
+
/* @__PURE__ */ React__default.createElement(Separator, null),
|
|
2695
|
+
/* @__PURE__ */ React__default.createElement(
|
|
2696
|
+
DropdownMenuCheckboxItem,
|
|
2697
|
+
{
|
|
2698
|
+
checked: hasNoBorders,
|
|
2699
|
+
onCheckedChange: getOnSelectTableBorder("none")
|
|
2700
|
+
},
|
|
2701
|
+
/* @__PURE__ */ React__default.createElement(Icons.borderNone, { className: iconVariants({ size: "sm" }) }),
|
|
2702
|
+
/* @__PURE__ */ React__default.createElement("div", null, "No Border")
|
|
2703
|
+
),
|
|
2704
|
+
/* @__PURE__ */ React__default.createElement(
|
|
2705
|
+
DropdownMenuCheckboxItem,
|
|
2706
|
+
{
|
|
2707
|
+
checked: hasOuterBorders,
|
|
2708
|
+
onCheckedChange: getOnSelectTableBorder("outer")
|
|
2709
|
+
},
|
|
2710
|
+
/* @__PURE__ */ React__default.createElement(Icons.borderAll, { className: iconVariants({ size: "sm" }) }),
|
|
2711
|
+
/* @__PURE__ */ React__default.createElement("div", null, "Outside Borders")
|
|
2712
|
+
)
|
|
2164
2713
|
);
|
|
2165
|
-
};
|
|
2166
|
-
const
|
|
2167
|
-
({
|
|
2168
|
-
const
|
|
2169
|
-
const
|
|
2170
|
-
|
|
2171
|
-
|
|
2714
|
+
});
|
|
2715
|
+
const TableFloatingToolbar = withRef(
|
|
2716
|
+
({ children, ...props }, ref) => {
|
|
2717
|
+
const element = useElement();
|
|
2718
|
+
const { props: buttonProps } = useRemoveNodeButton({ element });
|
|
2719
|
+
const selectionCollapsed = useEditorSelector(
|
|
2720
|
+
(editor2) => !isSelectionExpanded(editor2),
|
|
2721
|
+
[]
|
|
2722
|
+
);
|
|
2723
|
+
const readOnly = useReadOnly();
|
|
2724
|
+
const selected = useSelected();
|
|
2725
|
+
const editor = useEditorRef();
|
|
2726
|
+
const collapsed = !readOnly && selected && selectionCollapsed;
|
|
2727
|
+
const open2 = !readOnly && selected;
|
|
2728
|
+
const { canMerge, canUnmerge } = useTableMergeState();
|
|
2729
|
+
const mergeContent = canMerge && /* @__PURE__ */ React__default.createElement(
|
|
2730
|
+
Button$2,
|
|
2172
2731
|
{
|
|
2173
|
-
|
|
2732
|
+
contentEditable: false,
|
|
2733
|
+
isMenu: true,
|
|
2734
|
+
onClick: () => mergeTableCells(editor),
|
|
2735
|
+
variant: "ghost"
|
|
2736
|
+
},
|
|
2737
|
+
/* @__PURE__ */ React__default.createElement(Icons.combine, { className: "mr-2 size-4" }),
|
|
2738
|
+
"Merge"
|
|
2739
|
+
);
|
|
2740
|
+
const unmergeButton = canUnmerge && /* @__PURE__ */ React__default.createElement(
|
|
2741
|
+
Button$2,
|
|
2742
|
+
{
|
|
2743
|
+
contentEditable: false,
|
|
2744
|
+
isMenu: true,
|
|
2745
|
+
onClick: () => unmergeTableCells(editor),
|
|
2746
|
+
variant: "ghost"
|
|
2747
|
+
},
|
|
2748
|
+
/* @__PURE__ */ React__default.createElement(Icons.ungroup, { className: "mr-2 size-4" }),
|
|
2749
|
+
"Unmerge"
|
|
2750
|
+
);
|
|
2751
|
+
const bordersContent = collapsed && /* @__PURE__ */ React__default.createElement(React__default.Fragment, null, /* @__PURE__ */ React__default.createElement(DropdownMenu, { modal: false }, /* @__PURE__ */ React__default.createElement(DropdownMenuTrigger, { asChild: true }, /* @__PURE__ */ React__default.createElement(Button$2, { isMenu: true, variant: "ghost" }, /* @__PURE__ */ React__default.createElement(Icons.borderAll, { className: "mr-2 size-4" }), "Borders")), /* @__PURE__ */ React__default.createElement(DropdownMenuPortal, null, /* @__PURE__ */ React__default.createElement(TableBordersDropdownMenuContent, null))), /* @__PURE__ */ React__default.createElement(Button$2, { contentEditable: false, isMenu: true, variant: "ghost", ...buttonProps }, /* @__PURE__ */ React__default.createElement(Icons.delete, { className: "mr-2 size-4" }), "Delete"));
|
|
2752
|
+
return /* @__PURE__ */ React__default.createElement(Popover$2, { modal: false, open: open2 }, /* @__PURE__ */ React__default.createElement(PopoverAnchor, { asChild: true }, children), (canMerge || canUnmerge || collapsed) && /* @__PURE__ */ React__default.createElement(
|
|
2753
|
+
PopoverContent$1,
|
|
2754
|
+
{
|
|
2755
|
+
className: cn$1(
|
|
2756
|
+
popoverVariants(),
|
|
2757
|
+
"flex w-[220px] flex-col gap-1 p-1"
|
|
2758
|
+
),
|
|
2759
|
+
onOpenAutoFocus: (e) => e.preventDefault(),
|
|
2174
2760
|
ref,
|
|
2175
2761
|
...props
|
|
2176
2762
|
},
|
|
2177
|
-
|
|
2178
|
-
|
|
2763
|
+
unmergeButton,
|
|
2764
|
+
mergeContent,
|
|
2765
|
+
bordersContent
|
|
2766
|
+
));
|
|
2179
2767
|
}
|
|
2180
2768
|
);
|
|
2769
|
+
const TableElement = withHOC(
|
|
2770
|
+
TableProvider,
|
|
2771
|
+
withRef(({ children, className, ...props }, ref) => {
|
|
2772
|
+
const { colSizes, isSelectingCell, marginLeft, minColumnWidth } = useTableElementState();
|
|
2773
|
+
const { colGroupProps, props: tableProps } = useTableElement();
|
|
2774
|
+
return /* @__PURE__ */ React__default.createElement(TableFloatingToolbar, null, /* @__PURE__ */ React__default.createElement("div", { style: { paddingLeft: marginLeft } }, /* @__PURE__ */ React__default.createElement(
|
|
2775
|
+
PlateElement,
|
|
2776
|
+
{
|
|
2777
|
+
asChild: true,
|
|
2778
|
+
className: cn$1(
|
|
2779
|
+
"my-4 ml-px mr-0 table h-px w-full table-fixed border-collapse",
|
|
2780
|
+
isSelectingCell && "[&_*::selection]:bg-none",
|
|
2781
|
+
className
|
|
2782
|
+
),
|
|
2783
|
+
ref,
|
|
2784
|
+
...tableProps,
|
|
2785
|
+
...props
|
|
2786
|
+
},
|
|
2787
|
+
/* @__PURE__ */ React__default.createElement("table", null, /* @__PURE__ */ React__default.createElement("colgroup", { ...colGroupProps }, colSizes.map((width, index) => /* @__PURE__ */ React__default.createElement(
|
|
2788
|
+
"col",
|
|
2789
|
+
{
|
|
2790
|
+
key: index,
|
|
2791
|
+
style: {
|
|
2792
|
+
minWidth: minColumnWidth,
|
|
2793
|
+
width: width || void 0
|
|
2794
|
+
}
|
|
2795
|
+
}
|
|
2796
|
+
))), /* @__PURE__ */ React__default.createElement("tbody", { className: "min-w-full" }, children))
|
|
2797
|
+
)));
|
|
2798
|
+
})
|
|
2799
|
+
);
|
|
2800
|
+
const TableRowElement = withRef(({ children, hideBorder, ...props }, ref) => {
|
|
2801
|
+
return /* @__PURE__ */ React__default.createElement(
|
|
2802
|
+
PlateElement,
|
|
2803
|
+
{
|
|
2804
|
+
asChild: true,
|
|
2805
|
+
className: cn$1("h-full", hideBorder && "border-none"),
|
|
2806
|
+
ref,
|
|
2807
|
+
...props
|
|
2808
|
+
},
|
|
2809
|
+
/* @__PURE__ */ React__default.createElement("tr", null, children)
|
|
2810
|
+
);
|
|
2811
|
+
});
|
|
2181
2812
|
const blockClasses = "mt-0.5";
|
|
2182
2813
|
const headerClasses = "font-normal";
|
|
2183
2814
|
const Components = () => {
|
|
@@ -2283,6 +2914,7 @@ const Components = () => {
|
|
|
2283
2914
|
}
|
|
2284
2915
|
)
|
|
2285
2916
|
),
|
|
2917
|
+
[ELEMENT_MERMAID]: MermaidElement,
|
|
2286
2918
|
[ELEMENT_BLOCKQUOTE]: BlockquoteElement,
|
|
2287
2919
|
[ELEMENT_CODE_BLOCK]: CodeBlockElement,
|
|
2288
2920
|
[ELEMENT_CODE_LINE]: CodeLineElement,
|
|
@@ -2363,7 +2995,11 @@ const Components = () => {
|
|
|
2363
2995
|
children,
|
|
2364
2996
|
selected && /* @__PURE__ */ React__default.createElement("span", { className: "absolute h-4 -top-2 inset-0 ring-2 ring-blue-100 ring-inset rounded-md z-10 pointer-events-none" })
|
|
2365
2997
|
);
|
|
2366
|
-
}
|
|
2998
|
+
},
|
|
2999
|
+
[ELEMENT_TABLE]: TableElement,
|
|
3000
|
+
[ELEMENT_TR]: TableRowElement,
|
|
3001
|
+
[ELEMENT_TD]: TableCellElement,
|
|
3002
|
+
[ELEMENT_TH]: TableCellHeaderElement
|
|
2367
3003
|
};
|
|
2368
3004
|
};
|
|
2369
3005
|
const createCodeBlockPlugin = createPluginFactory({
|
|
@@ -2773,7 +3409,9 @@ class Form {
|
|
|
2773
3409
|
{
|
|
2774
3410
|
type: "string",
|
|
2775
3411
|
label: "Caption",
|
|
2776
|
-
name: [templateName.replace(/\.props$/, ""), "caption"].join(
|
|
3412
|
+
name: [templateName.replace(/\.props$/, ""), "caption"].join(
|
|
3413
|
+
"."
|
|
3414
|
+
),
|
|
2777
3415
|
component: "text"
|
|
2778
3416
|
}
|
|
2779
3417
|
]
|
|
@@ -3041,7 +3679,7 @@ function TinaForm({ form, children }) {
|
|
|
3041
3679
|
}));
|
|
3042
3680
|
}
|
|
3043
3681
|
function TinaField({
|
|
3044
|
-
Component
|
|
3682
|
+
Component,
|
|
3045
3683
|
children,
|
|
3046
3684
|
...fieldProps
|
|
3047
3685
|
}) {
|
|
@@ -3049,7 +3687,7 @@ function TinaField({
|
|
|
3049
3687
|
if (!isEditing)
|
|
3050
3688
|
return children || null;
|
|
3051
3689
|
return /* @__PURE__ */ React.createElement(Field, { ...fieldProps }, ({ input, meta }) => {
|
|
3052
|
-
return /* @__PURE__ */ React.createElement(
|
|
3690
|
+
return /* @__PURE__ */ React.createElement(Component, { input, meta, ...fieldProps });
|
|
3053
3691
|
});
|
|
3054
3692
|
}
|
|
3055
3693
|
TinaField.propTypes = {
|
|
@@ -3091,7 +3729,7 @@ const Button$1 = ({
|
|
|
3091
3729
|
};
|
|
3092
3730
|
const sizeClasses = {
|
|
3093
3731
|
small: `text-xs h-8 px-3`,
|
|
3094
|
-
medium: `text-sm h-10 px-
|
|
3732
|
+
medium: `text-sm h-10 px-8`,
|
|
3095
3733
|
custom: ``
|
|
3096
3734
|
};
|
|
3097
3735
|
return /* @__PURE__ */ React.createElement(
|
|
@@ -3219,7 +3857,7 @@ var _excluded = ["attr", "size", "title"];
|
|
|
3219
3857
|
function _objectWithoutProperties(source, excluded) {
|
|
3220
3858
|
if (source == null)
|
|
3221
3859
|
return {};
|
|
3222
|
-
var target = _objectWithoutPropertiesLoose
|
|
3860
|
+
var target = _objectWithoutPropertiesLoose(source, excluded);
|
|
3223
3861
|
var key, i;
|
|
3224
3862
|
if (Object.getOwnPropertySymbols) {
|
|
3225
3863
|
var sourceSymbolKeys = Object.getOwnPropertySymbols(source);
|
|
@@ -3234,7 +3872,7 @@ function _objectWithoutProperties(source, excluded) {
|
|
|
3234
3872
|
}
|
|
3235
3873
|
return target;
|
|
3236
3874
|
}
|
|
3237
|
-
function _objectWithoutPropertiesLoose
|
|
3875
|
+
function _objectWithoutPropertiesLoose(source, excluded) {
|
|
3238
3876
|
if (source == null)
|
|
3239
3877
|
return {};
|
|
3240
3878
|
var target = {};
|
|
@@ -4324,7 +4962,28 @@ const NumberInput = ({
|
|
|
4324
4962
|
onChange,
|
|
4325
4963
|
value,
|
|
4326
4964
|
step
|
|
4327
|
-
}) => /* @__PURE__ */ React.createElement(
|
|
4965
|
+
}) => /* @__PURE__ */ React.createElement(
|
|
4966
|
+
Input,
|
|
4967
|
+
{
|
|
4968
|
+
type: "number",
|
|
4969
|
+
step,
|
|
4970
|
+
value,
|
|
4971
|
+
onChange: (event) => {
|
|
4972
|
+
const inputValue = event.target.value;
|
|
4973
|
+
const newValue = inputValue === "" ? void 0 : inputValue;
|
|
4974
|
+
if (onChange) {
|
|
4975
|
+
const syntheticEvent = {
|
|
4976
|
+
...event,
|
|
4977
|
+
target: {
|
|
4978
|
+
...event.target,
|
|
4979
|
+
value: newValue
|
|
4980
|
+
}
|
|
4981
|
+
};
|
|
4982
|
+
onChange(syntheticEvent);
|
|
4983
|
+
}
|
|
4984
|
+
}
|
|
4985
|
+
}
|
|
4986
|
+
);
|
|
4328
4987
|
function useCMS() {
|
|
4329
4988
|
return useCMS$1();
|
|
4330
4989
|
}
|
|
@@ -4433,7 +5092,7 @@ const ImageLoadingIndicator = () => /* @__PURE__ */ React.createElement("div", {
|
|
|
4433
5092
|
function cn(...inputs) {
|
|
4434
5093
|
return twMerge(clsx(inputs));
|
|
4435
5094
|
}
|
|
4436
|
-
const buttonVariants
|
|
5095
|
+
const buttonVariants = cva(
|
|
4437
5096
|
"inline-flex items-center justify-center whitespace-nowrap rounded-md text-sm font-medium ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50",
|
|
4438
5097
|
{
|
|
4439
5098
|
variants: {
|
|
@@ -4459,7 +5118,7 @@ const Button = React.forwardRef(
|
|
|
4459
5118
|
return /* @__PURE__ */ React.createElement(
|
|
4460
5119
|
Comp,
|
|
4461
5120
|
{
|
|
4462
|
-
className: cn(buttonVariants
|
|
5121
|
+
className: cn(buttonVariants({ variant, size, className })),
|
|
4463
5122
|
ref,
|
|
4464
5123
|
...props
|
|
4465
5124
|
}
|
|
@@ -4565,7 +5224,7 @@ const PopoverContent = React.forwardRef(({ className, align = "center", sideOffs
|
|
|
4565
5224
|
side: "bottom",
|
|
4566
5225
|
className: cn(
|
|
4567
5226
|
"rounded-md border bg-white p-4 text-popover-foreground shadow-md outline-none data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",
|
|
4568
|
-
"max-h-[30vh] max-w-[
|
|
5227
|
+
"max-h-[30vh] max-w-[30vw] overflow-y-auto",
|
|
4569
5228
|
className
|
|
4570
5229
|
),
|
|
4571
5230
|
...props
|
|
@@ -4628,6 +5287,10 @@ const useGetOptionSets = (cms, collections, collectionFilter) => {
|
|
|
4628
5287
|
edges: response.collection.documents.edges
|
|
4629
5288
|
};
|
|
4630
5289
|
} catch (e) {
|
|
5290
|
+
console.error(
|
|
5291
|
+
"Exception thrown while building and running GraphQL query: ",
|
|
5292
|
+
e
|
|
5293
|
+
);
|
|
4631
5294
|
return {
|
|
4632
5295
|
collection,
|
|
4633
5296
|
edges: []
|
|
@@ -4653,11 +5316,7 @@ const getFilename = (optionSets, value) => {
|
|
|
4653
5316
|
const node = nodes.find((node2) => node2.id === value);
|
|
4654
5317
|
return node ? node._internalSys.filename : null;
|
|
4655
5318
|
};
|
|
4656
|
-
const
|
|
4657
|
-
cms,
|
|
4658
|
-
input,
|
|
4659
|
-
field
|
|
4660
|
-
}) => {
|
|
5319
|
+
const Combobox = ({ cms, input, field }) => {
|
|
4661
5320
|
const [open2, setOpen] = React.useState(false);
|
|
4662
5321
|
const [value, setValue] = React.useState(input.value);
|
|
4663
5322
|
const [displayText, setDisplayText] = React.useState(null);
|
|
@@ -4681,17 +5340,17 @@ const ComboboxDemo = ({
|
|
|
4681
5340
|
if (loading === true) {
|
|
4682
5341
|
return /* @__PURE__ */ React.createElement(LoadingDots, { color: "var(--tina-color-primary)" });
|
|
4683
5342
|
}
|
|
4684
|
-
return /* @__PURE__ */ React.createElement(
|
|
5343
|
+
return /* @__PURE__ */ React.createElement(Popover, { open: open2, onOpenChange: setOpen }, /* @__PURE__ */ React.createElement(PopoverTrigger, { asChild: true }, /* @__PURE__ */ React.createElement(
|
|
4685
5344
|
Button,
|
|
4686
5345
|
{
|
|
4687
5346
|
variant: "outline",
|
|
4688
5347
|
role: "combobox",
|
|
4689
5348
|
"aria-expanded": open2,
|
|
4690
|
-
className: "w-
|
|
5349
|
+
className: "w-full justify-between"
|
|
4691
5350
|
},
|
|
4692
5351
|
/* @__PURE__ */ React.createElement("p", { className: "truncate" }, displayText ?? "Choose an option..."),
|
|
4693
5352
|
open2 ? /* @__PURE__ */ React.createElement(IoMdArrowDropup, { size: 20 }) : /* @__PURE__ */ React.createElement(IoMdArrowDropdown, { size: 20 })
|
|
4694
|
-
)), /* @__PURE__ */ React.createElement(PopoverContent, { className: "p-0 relative" }, /* @__PURE__ */ React.createElement(
|
|
5353
|
+
)), /* @__PURE__ */ React.createElement(PopoverContent, { className: "p-0 relative min-w-[var(--radix-popover-trigger-width)]" }, /* @__PURE__ */ React.createElement(
|
|
4695
5354
|
Command,
|
|
4696
5355
|
{
|
|
4697
5356
|
shouldFilter: !field.experimental___filter,
|
|
@@ -4715,32 +5374,25 @@ const ComboboxDemo = ({
|
|
|
4715
5374
|
}
|
|
4716
5375
|
),
|
|
4717
5376
|
/* @__PURE__ */ React.createElement(CommandEmpty, null, "No reference found"),
|
|
4718
|
-
/* @__PURE__ */ React.createElement(CommandList, null, filteredOptionsList.length > 0 && (filteredOptionsList == null ? void 0 : filteredOptionsList.map(({ collection, edges }) => /* @__PURE__ */ React.createElement(
|
|
4719
|
-
|
|
4720
|
-
|
|
4721
|
-
|
|
4722
|
-
|
|
4723
|
-
|
|
4724
|
-
|
|
4725
|
-
|
|
4726
|
-
|
|
4727
|
-
|
|
4728
|
-
|
|
4729
|
-
|
|
4730
|
-
|
|
4731
|
-
|
|
4732
|
-
field,
|
|
4733
|
-
_values,
|
|
4734
|
-
node,
|
|
4735
|
-
onSelect: (currentValue) => {
|
|
4736
|
-
setValue(currentValue);
|
|
4737
|
-
setOpen(false);
|
|
4738
|
-
}
|
|
5377
|
+
/* @__PURE__ */ React.createElement(CommandList, null, filteredOptionsList.length > 0 && (filteredOptionsList == null ? void 0 : filteredOptionsList.map(({ collection, edges }) => /* @__PURE__ */ React.createElement(CommandGroup, { key: `${collection}-group`, heading: collection }, /* @__PURE__ */ React.createElement(CommandList, null, edges == null ? void 0 : edges.map(({ node }) => {
|
|
5378
|
+
const { id, _values } = node;
|
|
5379
|
+
return /* @__PURE__ */ React.createElement(
|
|
5380
|
+
OptionComponent,
|
|
5381
|
+
{
|
|
5382
|
+
id,
|
|
5383
|
+
key: id,
|
|
5384
|
+
value,
|
|
5385
|
+
field,
|
|
5386
|
+
_values,
|
|
5387
|
+
node,
|
|
5388
|
+
onSelect: (currentValue) => {
|
|
5389
|
+
setValue(currentValue);
|
|
5390
|
+
setOpen(false);
|
|
4739
5391
|
}
|
|
4740
|
-
|
|
4741
|
-
|
|
4742
|
-
))))
|
|
4743
|
-
)))
|
|
5392
|
+
}
|
|
5393
|
+
);
|
|
5394
|
+
}))))))
|
|
5395
|
+
)));
|
|
4744
5396
|
};
|
|
4745
5397
|
const useGetNode = (cms, id) => {
|
|
4746
5398
|
const [document2, setDocument] = React.useState(
|
|
@@ -4813,7 +5465,7 @@ const ReferenceLink = ({ cms, input }) => {
|
|
|
4813
5465
|
};
|
|
4814
5466
|
const Reference = ({ input, field }) => {
|
|
4815
5467
|
const cms = useCMS();
|
|
4816
|
-
return /* @__PURE__ */ React.createElement(
|
|
5468
|
+
return /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement("div", { className: "relative group" }, /* @__PURE__ */ React.createElement(Combobox, { cms, input, field })), /* @__PURE__ */ React.createElement(ReferenceLink, { cms, input }));
|
|
4817
5469
|
};
|
|
4818
5470
|
const ButtonToggle = ({
|
|
4819
5471
|
input,
|
|
@@ -5121,10 +5773,11 @@ const ItemDeleteButton = ({ onClick, disabled = false }) => {
|
|
|
5121
5773
|
return /* @__PURE__ */ React__default.createElement(
|
|
5122
5774
|
"button",
|
|
5123
5775
|
{
|
|
5124
|
-
|
|
5776
|
+
type: "button",
|
|
5777
|
+
className: `w-8 px-1 py-2.5 flex items-center justify-center text-gray-200 hover:opacity-100 opacity-30 hover:bg-gray-50 ${disabled && "pointer-events-none opacity-30 cursor-not-allowed"}`,
|
|
5125
5778
|
onClick
|
|
5126
5779
|
},
|
|
5127
|
-
/* @__PURE__ */ React__default.createElement(TrashIcon, { className: "fill-current transition-colors ease-out
|
|
5780
|
+
/* @__PURE__ */ React__default.createElement(TrashIcon, { className: "h-5 w-auto fill-current text-red-500 transition-colors duration-150 ease-out" })
|
|
5128
5781
|
);
|
|
5129
5782
|
};
|
|
5130
5783
|
const DragHandle = ({ isDragging }) => {
|
|
@@ -5154,7 +5807,7 @@ const BlockSelector = ({
|
|
|
5154
5807
|
return template.label ? template.label.toLowerCase().includes(filter.toLowerCase()) || name.toLowerCase().includes(filter.toLowerCase()) : name.toLowerCase().includes(filter.toLowerCase());
|
|
5155
5808
|
});
|
|
5156
5809
|
}, [filter]);
|
|
5157
|
-
return /* @__PURE__ */ React.createElement(Popover$
|
|
5810
|
+
return /* @__PURE__ */ React.createElement(Popover$3, null, ({ open: open2 }) => /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(PopoverButton, { as: "span" }, /* @__PURE__ */ React.createElement(
|
|
5158
5811
|
IconButton,
|
|
5159
5812
|
{
|
|
5160
5813
|
variant: open2 ? "secondary" : "primary",
|
|
@@ -5202,27 +5855,35 @@ const BlockSelector = ({
|
|
|
5202
5855
|
))))
|
|
5203
5856
|
))));
|
|
5204
5857
|
};
|
|
5205
|
-
const Group =
|
|
5206
|
-
|
|
5207
|
-
|
|
5208
|
-
|
|
5209
|
-
|
|
5210
|
-
|
|
5211
|
-
|
|
5212
|
-
|
|
5213
|
-
|
|
5214
|
-
|
|
5215
|
-
|
|
5858
|
+
const Group = wrapFieldWithNoHeader(
|
|
5859
|
+
({ tinaForm, field }) => {
|
|
5860
|
+
const cms = useCMS$1();
|
|
5861
|
+
return /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(
|
|
5862
|
+
Header,
|
|
5863
|
+
{
|
|
5864
|
+
onClick: () => {
|
|
5865
|
+
const state = tinaForm.finalForm.getState();
|
|
5866
|
+
if (state.invalid === true) {
|
|
5867
|
+
cms.alerts.error("Cannot navigate away from an invalid form.");
|
|
5868
|
+
return;
|
|
5869
|
+
}
|
|
5870
|
+
cms.dispatch({
|
|
5871
|
+
type: "forms:set-active-field-name",
|
|
5872
|
+
value: { formId: tinaForm.id, fieldName: field.name }
|
|
5873
|
+
});
|
|
5216
5874
|
}
|
|
5217
|
-
|
|
5218
|
-
|
|
5219
|
-
|
|
5220
|
-
|
|
5221
|
-
|
|
5222
|
-
|
|
5223
|
-
|
|
5224
|
-
|
|
5225
|
-
|
|
5875
|
+
},
|
|
5876
|
+
field.label || field.name,
|
|
5877
|
+
field.description && /* @__PURE__ */ React.createElement(
|
|
5878
|
+
"span",
|
|
5879
|
+
{
|
|
5880
|
+
className: `block font-sans text-xs italic font-light text-gray-400 pt-0.5 whitespace-normal m-0`,
|
|
5881
|
+
dangerouslySetInnerHTML: { __html: field.description }
|
|
5882
|
+
}
|
|
5883
|
+
)
|
|
5884
|
+
));
|
|
5885
|
+
}
|
|
5886
|
+
);
|
|
5226
5887
|
const Header = ({ onClick, children }) => {
|
|
5227
5888
|
return /* @__PURE__ */ React.createElement("div", { className: "pt-1 mb-5" }, /* @__PURE__ */ React.createElement(
|
|
5228
5889
|
"button",
|
|
@@ -6564,244 +7225,65 @@ function pad(type, value) {
|
|
|
6564
7225
|
str = "0" + str;
|
|
6565
7226
|
return str;
|
|
6566
7227
|
}
|
|
6567
|
-
|
|
6568
|
-
|
|
6569
|
-
|
|
6570
|
-
|
|
6571
|
-
|
|
6572
|
-
|
|
6573
|
-
|
|
6574
|
-
|
|
6575
|
-
|
|
6576
|
-
|
|
6577
|
-
|
|
6578
|
-
}
|
|
6579
|
-
function _objectWithoutPropertiesLoose(source, excluded) {
|
|
6580
|
-
if (source == null)
|
|
6581
|
-
return {};
|
|
6582
|
-
var target = {};
|
|
6583
|
-
var sourceKeys = Object.keys(source);
|
|
6584
|
-
var key, i;
|
|
6585
|
-
for (i = 0; i < sourceKeys.length; i++) {
|
|
6586
|
-
key = sourceKeys[i];
|
|
6587
|
-
if (excluded.indexOf(key) >= 0)
|
|
6588
|
-
continue;
|
|
6589
|
-
target[key] = source[key];
|
|
6590
|
-
}
|
|
6591
|
-
return target;
|
|
6592
|
-
}
|
|
6593
|
-
function _assertThisInitialized(self) {
|
|
6594
|
-
if (self === void 0) {
|
|
6595
|
-
throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
|
|
6596
|
-
}
|
|
6597
|
-
return self;
|
|
6598
|
-
}
|
|
6599
|
-
function isNodeFound(current, componentNode, ignoreClass) {
|
|
6600
|
-
if (current === componentNode) {
|
|
6601
|
-
return true;
|
|
7228
|
+
var useClickAway$1 = {};
|
|
7229
|
+
var util = {};
|
|
7230
|
+
Object.defineProperty(util, "__esModule", { value: true });
|
|
7231
|
+
util.isNavigator = util.isBrowser = util.off = util.on = util.noop = void 0;
|
|
7232
|
+
var noop = function() {
|
|
7233
|
+
};
|
|
7234
|
+
util.noop = noop;
|
|
7235
|
+
function on(obj) {
|
|
7236
|
+
var args = [];
|
|
7237
|
+
for (var _i = 1; _i < arguments.length; _i++) {
|
|
7238
|
+
args[_i - 1] = arguments[_i];
|
|
6602
7239
|
}
|
|
6603
|
-
if (
|
|
6604
|
-
|
|
7240
|
+
if (obj && obj.addEventListener) {
|
|
7241
|
+
obj.addEventListener.apply(obj, args);
|
|
6605
7242
|
}
|
|
6606
|
-
return current.classList.contains(ignoreClass);
|
|
6607
7243
|
}
|
|
6608
|
-
|
|
6609
|
-
|
|
6610
|
-
|
|
7244
|
+
util.on = on;
|
|
7245
|
+
function off(obj) {
|
|
7246
|
+
var args = [];
|
|
7247
|
+
for (var _i = 1; _i < arguments.length; _i++) {
|
|
7248
|
+
args[_i - 1] = arguments[_i];
|
|
6611
7249
|
}
|
|
6612
|
-
|
|
6613
|
-
|
|
6614
|
-
return true;
|
|
6615
|
-
}
|
|
6616
|
-
current = current.parentNode || current.host;
|
|
7250
|
+
if (obj && obj.removeEventListener) {
|
|
7251
|
+
obj.removeEventListener.apply(obj, args);
|
|
6617
7252
|
}
|
|
6618
|
-
return current;
|
|
6619
|
-
}
|
|
6620
|
-
function clickedScrollbar(evt) {
|
|
6621
|
-
return document.documentElement.clientWidth <= evt.clientX || document.documentElement.clientHeight <= evt.clientY;
|
|
6622
7253
|
}
|
|
6623
|
-
|
|
6624
|
-
|
|
6625
|
-
|
|
6626
|
-
|
|
6627
|
-
|
|
6628
|
-
|
|
6629
|
-
|
|
6630
|
-
|
|
6631
|
-
|
|
6632
|
-
|
|
6633
|
-
|
|
6634
|
-
|
|
6635
|
-
|
|
6636
|
-
|
|
6637
|
-
|
|
6638
|
-
|
|
6639
|
-
function
|
|
6640
|
-
|
|
6641
|
-
|
|
6642
|
-
}
|
|
6643
|
-
return function() {
|
|
6644
|
-
return ++seed;
|
|
6645
|
-
};
|
|
6646
|
-
}
|
|
6647
|
-
var uid = autoInc();
|
|
6648
|
-
var passiveEventSupport;
|
|
6649
|
-
var handlersMap = {};
|
|
6650
|
-
var enabledInstances = {};
|
|
6651
|
-
var touchEvents = ["touchstart", "touchmove"];
|
|
6652
|
-
var IGNORE_CLASS_NAME = "ignore-react-onclickoutside";
|
|
6653
|
-
function getEventHandlerOptions(instance, eventName) {
|
|
6654
|
-
var handlerOptions = {};
|
|
6655
|
-
var isTouchEvent = touchEvents.indexOf(eventName) !== -1;
|
|
6656
|
-
if (isTouchEvent && passiveEventSupport) {
|
|
6657
|
-
handlerOptions.passive = !instance.props.preventDefault;
|
|
6658
|
-
}
|
|
6659
|
-
return handlerOptions;
|
|
6660
|
-
}
|
|
6661
|
-
function onClickOutsideHOC(WrappedComponent, config) {
|
|
6662
|
-
var _class, _temp;
|
|
6663
|
-
var componentName = WrappedComponent.displayName || WrappedComponent.name || "Component";
|
|
6664
|
-
return _temp = _class = /* @__PURE__ */ function(_Component) {
|
|
6665
|
-
_inheritsLoose(onClickOutside, _Component);
|
|
6666
|
-
function onClickOutside(props) {
|
|
6667
|
-
var _this;
|
|
6668
|
-
_this = _Component.call(this, props) || this;
|
|
6669
|
-
_this.__outsideClickHandler = function(event) {
|
|
6670
|
-
if (typeof _this.__clickOutsideHandlerProp === "function") {
|
|
6671
|
-
_this.__clickOutsideHandlerProp(event);
|
|
6672
|
-
return;
|
|
6673
|
-
}
|
|
6674
|
-
var instance = _this.getInstance();
|
|
6675
|
-
if (typeof instance.props.handleClickOutside === "function") {
|
|
6676
|
-
instance.props.handleClickOutside(event);
|
|
6677
|
-
return;
|
|
6678
|
-
}
|
|
6679
|
-
if (typeof instance.handleClickOutside === "function") {
|
|
6680
|
-
instance.handleClickOutside(event);
|
|
6681
|
-
return;
|
|
6682
|
-
}
|
|
6683
|
-
throw new Error("WrappedComponent: " + componentName + " lacks a handleClickOutside(event) function for processing outside click events.");
|
|
6684
|
-
};
|
|
6685
|
-
_this.__getComponentNode = function() {
|
|
6686
|
-
var instance = _this.getInstance();
|
|
6687
|
-
if (config && typeof config.setClickOutsideRef === "function") {
|
|
6688
|
-
return config.setClickOutsideRef()(instance);
|
|
6689
|
-
}
|
|
6690
|
-
if (typeof instance.setClickOutsideRef === "function") {
|
|
6691
|
-
return instance.setClickOutsideRef();
|
|
6692
|
-
}
|
|
6693
|
-
return findDOMNode(instance);
|
|
6694
|
-
};
|
|
6695
|
-
_this.enableOnClickOutside = function() {
|
|
6696
|
-
if (typeof document === "undefined" || enabledInstances[_this._uid]) {
|
|
6697
|
-
return;
|
|
6698
|
-
}
|
|
6699
|
-
if (typeof passiveEventSupport === "undefined") {
|
|
6700
|
-
passiveEventSupport = testPassiveEventSupport();
|
|
6701
|
-
}
|
|
6702
|
-
enabledInstances[_this._uid] = true;
|
|
6703
|
-
var events = _this.props.eventTypes;
|
|
6704
|
-
if (!events.forEach) {
|
|
6705
|
-
events = [events];
|
|
6706
|
-
}
|
|
6707
|
-
handlersMap[_this._uid] = function(event) {
|
|
6708
|
-
if (_this.componentNode === null)
|
|
6709
|
-
return;
|
|
6710
|
-
if (_this.initTimeStamp > event.timeStamp)
|
|
6711
|
-
return;
|
|
6712
|
-
if (_this.props.preventDefault) {
|
|
6713
|
-
event.preventDefault();
|
|
6714
|
-
}
|
|
6715
|
-
if (_this.props.stopPropagation) {
|
|
6716
|
-
event.stopPropagation();
|
|
6717
|
-
}
|
|
6718
|
-
if (_this.props.excludeScrollbar && clickedScrollbar(event))
|
|
6719
|
-
return;
|
|
6720
|
-
var current = event.composed && event.composedPath && event.composedPath().shift() || event.target;
|
|
6721
|
-
if (findHighest(current, _this.componentNode, _this.props.outsideClickIgnoreClass) !== document) {
|
|
6722
|
-
return;
|
|
6723
|
-
}
|
|
6724
|
-
_this.__outsideClickHandler(event);
|
|
6725
|
-
};
|
|
6726
|
-
events.forEach(function(eventName) {
|
|
6727
|
-
document.addEventListener(eventName, handlersMap[_this._uid], getEventHandlerOptions(_assertThisInitialized(_this), eventName));
|
|
6728
|
-
});
|
|
6729
|
-
};
|
|
6730
|
-
_this.disableOnClickOutside = function() {
|
|
6731
|
-
delete enabledInstances[_this._uid];
|
|
6732
|
-
var fn = handlersMap[_this._uid];
|
|
6733
|
-
if (fn && typeof document !== "undefined") {
|
|
6734
|
-
var events = _this.props.eventTypes;
|
|
6735
|
-
if (!events.forEach) {
|
|
6736
|
-
events = [events];
|
|
6737
|
-
}
|
|
6738
|
-
events.forEach(function(eventName) {
|
|
6739
|
-
return document.removeEventListener(eventName, fn, getEventHandlerOptions(_assertThisInitialized(_this), eventName));
|
|
6740
|
-
});
|
|
6741
|
-
delete handlersMap[_this._uid];
|
|
6742
|
-
}
|
|
6743
|
-
};
|
|
6744
|
-
_this.getRef = function(ref) {
|
|
6745
|
-
return _this.instanceRef = ref;
|
|
6746
|
-
};
|
|
6747
|
-
_this._uid = uid();
|
|
6748
|
-
_this.initTimeStamp = performance.now();
|
|
6749
|
-
return _this;
|
|
6750
|
-
}
|
|
6751
|
-
var _proto = onClickOutside.prototype;
|
|
6752
|
-
_proto.getInstance = function getInstance() {
|
|
6753
|
-
if (WrappedComponent.prototype && !WrappedComponent.prototype.isReactComponent) {
|
|
6754
|
-
return this;
|
|
6755
|
-
}
|
|
6756
|
-
var ref = this.instanceRef;
|
|
6757
|
-
return ref.getInstance ? ref.getInstance() : ref;
|
|
7254
|
+
util.off = off;
|
|
7255
|
+
util.isBrowser = typeof window !== "undefined";
|
|
7256
|
+
util.isNavigator = typeof navigator !== "undefined";
|
|
7257
|
+
Object.defineProperty(useClickAway$1, "__esModule", { value: true });
|
|
7258
|
+
var react_1 = React__default;
|
|
7259
|
+
var util_1 = util;
|
|
7260
|
+
var defaultEvents = ["mousedown", "touchstart"];
|
|
7261
|
+
var useClickAway = function(ref, onClickAway, events) {
|
|
7262
|
+
if (events === void 0) {
|
|
7263
|
+
events = defaultEvents;
|
|
7264
|
+
}
|
|
7265
|
+
var savedCallback = react_1.useRef(onClickAway);
|
|
7266
|
+
react_1.useEffect(function() {
|
|
7267
|
+
savedCallback.current = onClickAway;
|
|
7268
|
+
}, [onClickAway]);
|
|
7269
|
+
react_1.useEffect(function() {
|
|
7270
|
+
var handler = function(event) {
|
|
7271
|
+
var el = ref.current;
|
|
7272
|
+
el && !el.contains(event.target) && savedCallback.current(event);
|
|
6758
7273
|
};
|
|
6759
|
-
|
|
6760
|
-
|
|
6761
|
-
|
|
6762
|
-
|
|
6763
|
-
|
|
6764
|
-
|
|
6765
|
-
|
|
6766
|
-
|
|
6767
|
-
throw new Error("WrappedComponent: " + componentName + " lacks a function for processing outside click events specified by the handleClickOutside config option.");
|
|
6768
|
-
}
|
|
6769
|
-
}
|
|
6770
|
-
this.componentNode = this.__getComponentNode();
|
|
6771
|
-
if (this.props.disableOnClickOutside)
|
|
6772
|
-
return;
|
|
6773
|
-
this.enableOnClickOutside();
|
|
6774
|
-
};
|
|
6775
|
-
_proto.componentDidUpdate = function componentDidUpdate() {
|
|
6776
|
-
this.componentNode = this.__getComponentNode();
|
|
6777
|
-
};
|
|
6778
|
-
_proto.componentWillUnmount = function componentWillUnmount() {
|
|
6779
|
-
this.disableOnClickOutside();
|
|
6780
|
-
};
|
|
6781
|
-
_proto.render = function render() {
|
|
6782
|
-
var _this$props = this.props;
|
|
6783
|
-
_this$props.excludeScrollbar;
|
|
6784
|
-
var props = _objectWithoutPropertiesLoose(_this$props, ["excludeScrollbar"]);
|
|
6785
|
-
if (WrappedComponent.prototype && WrappedComponent.prototype.isReactComponent) {
|
|
6786
|
-
props.ref = this.getRef;
|
|
6787
|
-
} else {
|
|
6788
|
-
props.wrappedRef = this.getRef;
|
|
7274
|
+
for (var _i = 0, events_1 = events; _i < events_1.length; _i++) {
|
|
7275
|
+
var eventName = events_1[_i];
|
|
7276
|
+
util_1.on(document, eventName, handler);
|
|
7277
|
+
}
|
|
7278
|
+
return function() {
|
|
7279
|
+
for (var _i2 = 0, events_2 = events; _i2 < events_2.length; _i2++) {
|
|
7280
|
+
var eventName2 = events_2[_i2];
|
|
7281
|
+
util_1.off(document, eventName2, handler);
|
|
6789
7282
|
}
|
|
6790
|
-
props.disableOnClickOutside = this.disableOnClickOutside;
|
|
6791
|
-
props.enableOnClickOutside = this.enableOnClickOutside;
|
|
6792
|
-
return createElement(WrappedComponent, props);
|
|
6793
7283
|
};
|
|
6794
|
-
|
|
6795
|
-
|
|
6796
|
-
|
|
6797
|
-
excludeScrollbar: config && config.excludeScrollbar || false,
|
|
6798
|
-
outsideClickIgnoreClass: IGNORE_CLASS_NAME,
|
|
6799
|
-
preventDefault: false,
|
|
6800
|
-
stopPropagation: false
|
|
6801
|
-
}, _class.getClass = function() {
|
|
6802
|
-
return WrappedComponent.getClass ? WrappedComponent.getClass() : WrappedComponent;
|
|
6803
|
-
}, _temp;
|
|
6804
|
-
}
|
|
7284
|
+
}, [events, ref]);
|
|
7285
|
+
};
|
|
7286
|
+
var _default = useClickAway$1.default = useClickAway;
|
|
6805
7287
|
const viewModes = {
|
|
6806
7288
|
YEARS: "years",
|
|
6807
7289
|
MONTHS: "months",
|
|
@@ -7330,22 +7812,13 @@ function log(message, method) {
|
|
|
7330
7812
|
}
|
|
7331
7813
|
con[method]("***react-datetime:" + message);
|
|
7332
7814
|
}
|
|
7333
|
-
|
|
7334
|
-
|
|
7335
|
-
|
|
7336
|
-
|
|
7337
|
-
}
|
|
7338
|
-
|
|
7339
|
-
return /* @__PURE__ */ React__default.createElement("div", { className: this.props.className, ref: this.container }, this.props.children);
|
|
7340
|
-
}
|
|
7341
|
-
handleClickOutside(e) {
|
|
7342
|
-
this.props.onClickOut(e);
|
|
7343
|
-
}
|
|
7344
|
-
setClickOutsideRef() {
|
|
7345
|
-
return this.container.current;
|
|
7346
|
-
}
|
|
7815
|
+
function ClickableWrapper({ className, onClickOut, children }) {
|
|
7816
|
+
const containerRef = useRef(null);
|
|
7817
|
+
_default(containerRef, (event) => {
|
|
7818
|
+
onClickOut(event);
|
|
7819
|
+
});
|
|
7820
|
+
return /* @__PURE__ */ React__default.createElement("div", { className, ref: containerRef }, children);
|
|
7347
7821
|
}
|
|
7348
|
-
const ClickableWrapper = onClickOutsideHOC(ClickOutBase);
|
|
7349
7822
|
const DEFAULT_DATE_DISPLAY_FORMAT = "MMM DD, YYYY";
|
|
7350
7823
|
const DEFAULT_TIME_DISPLAY_FORMAT = "h:mm A";
|
|
7351
7824
|
const format$1 = (val, _name, field) => {
|
|
@@ -7388,7 +7861,10 @@ const DateField = wrapFieldsWithMeta(
|
|
|
7388
7861
|
ReactDateTimeWithStyles,
|
|
7389
7862
|
{
|
|
7390
7863
|
value: input.value,
|
|
7391
|
-
onChange:
|
|
7864
|
+
onChange: (value) => {
|
|
7865
|
+
const newValue = value === "" ? void 0 : value;
|
|
7866
|
+
input.onChange(newValue);
|
|
7867
|
+
},
|
|
7392
7868
|
dateFormat: dateFormat || DEFAULT_DATE_DISPLAY_FORMAT,
|
|
7393
7869
|
timeFormat: timeFormat || false,
|
|
7394
7870
|
inputProps: { className: textFieldClasses },
|
|
@@ -8840,6 +9316,19 @@ class TinaMediaStore {
|
|
|
8840
9316
|
}
|
|
8841
9317
|
}
|
|
8842
9318
|
}
|
|
9319
|
+
const encodeUrlIfNeeded = (url) => {
|
|
9320
|
+
if (url) {
|
|
9321
|
+
try {
|
|
9322
|
+
const parsed = new URL(url);
|
|
9323
|
+
parsed.pathname = parsed.pathname.split("/").filter((part) => part !== "").map(encodeURIComponent).join("/");
|
|
9324
|
+
return parsed.toString();
|
|
9325
|
+
} catch (e) {
|
|
9326
|
+
return url;
|
|
9327
|
+
}
|
|
9328
|
+
} else {
|
|
9329
|
+
return url;
|
|
9330
|
+
}
|
|
9331
|
+
};
|
|
8843
9332
|
let MediaManager$1 = class MediaManager {
|
|
8844
9333
|
constructor(store, events) {
|
|
8845
9334
|
this.store = store;
|
|
@@ -8912,6 +9401,20 @@ let MediaManager$1 = class MediaManager {
|
|
|
8912
9401
|
try {
|
|
8913
9402
|
this.events.dispatch({ type: "media:list:start", ...options });
|
|
8914
9403
|
const media = await this.store.list(options);
|
|
9404
|
+
media.items = media.items.map((item) => {
|
|
9405
|
+
if (item.type === "dir") {
|
|
9406
|
+
return item;
|
|
9407
|
+
}
|
|
9408
|
+
if (item.thumbnails) {
|
|
9409
|
+
for (const [size, src] of Object.entries(item.thumbnails)) {
|
|
9410
|
+
item.thumbnails[size] = encodeUrlIfNeeded(src);
|
|
9411
|
+
}
|
|
9412
|
+
}
|
|
9413
|
+
return {
|
|
9414
|
+
...item,
|
|
9415
|
+
src: encodeUrlIfNeeded(item.src)
|
|
9416
|
+
};
|
|
9417
|
+
});
|
|
8915
9418
|
this.events.dispatch({ type: "media:list:success", ...options, media });
|
|
8916
9419
|
return media;
|
|
8917
9420
|
} catch (error) {
|
|
@@ -9199,7 +9702,7 @@ class SidebarState {
|
|
|
9199
9702
|
}
|
|
9200
9703
|
}
|
|
9201
9704
|
function createScreen({
|
|
9202
|
-
Component
|
|
9705
|
+
Component,
|
|
9203
9706
|
props,
|
|
9204
9707
|
...options
|
|
9205
9708
|
}) {
|
|
@@ -9208,7 +9711,7 @@ function createScreen({
|
|
|
9208
9711
|
layout: "popup",
|
|
9209
9712
|
...options,
|
|
9210
9713
|
Component(screenProps) {
|
|
9211
|
-
return /* @__PURE__ */ React__default.createElement(
|
|
9714
|
+
return /* @__PURE__ */ React__default.createElement(Component, { ...screenProps, ...props });
|
|
9212
9715
|
}
|
|
9213
9716
|
};
|
|
9214
9717
|
}
|
|
@@ -9719,7 +10222,7 @@ const SyncStatus = ({ cms, setEventsOpen }) => {
|
|
|
9719
10222
|
"Event Log"
|
|
9720
10223
|
));
|
|
9721
10224
|
};
|
|
9722
|
-
const version = "2.
|
|
10225
|
+
const version = "2.6.3";
|
|
9723
10226
|
const Nav = ({
|
|
9724
10227
|
isLocalMode,
|
|
9725
10228
|
className = "",
|
|
@@ -12250,15 +12753,14 @@ const FormBuilder = ({
|
|
|
12250
12753
|
fields: fieldGroup.fields
|
|
12251
12754
|
}
|
|
12252
12755
|
) : /* @__PURE__ */ React.createElement(NoFieldsPlaceholder, null)
|
|
12253
|
-
)), !hideFooter && /* @__PURE__ */ React.createElement("div", { className: "relative flex-none w-full h-16 px-
|
|
12756
|
+
)), !hideFooter && /* @__PURE__ */ React.createElement("div", { className: "relative flex-none w-full h-16 px-12 bg-white border-t border-gray-100 flex items-center justify-end" }, /* @__PURE__ */ React.createElement("div", { className: "flex-1 w-full justify-end gap-2 flex items-center max-w-form" }, tinaForm.reset && /* @__PURE__ */ React.createElement(
|
|
12254
12757
|
ResetForm,
|
|
12255
12758
|
{
|
|
12256
12759
|
pristine,
|
|
12257
12760
|
reset: async () => {
|
|
12258
12761
|
finalForm.reset();
|
|
12259
12762
|
await tinaForm.reset();
|
|
12260
|
-
}
|
|
12261
|
-
style: { flexGrow: 1 }
|
|
12763
|
+
}
|
|
12262
12764
|
},
|
|
12263
12765
|
tinaForm.buttons.reset
|
|
12264
12766
|
), /* @__PURE__ */ React.createElement(
|
|
@@ -12267,8 +12769,7 @@ const FormBuilder = ({
|
|
|
12267
12769
|
onClick: safeHandleSubmit,
|
|
12268
12770
|
disabled: !canSubmit,
|
|
12269
12771
|
busy: submitting,
|
|
12270
|
-
variant: "primary"
|
|
12271
|
-
style: { flexGrow: 3 }
|
|
12772
|
+
variant: "primary"
|
|
12272
12773
|
},
|
|
12273
12774
|
submitting && /* @__PURE__ */ React.createElement(LoadingDots, null),
|
|
12274
12775
|
!submitting && tinaForm.buttons.save
|
|
@@ -12650,9 +13151,9 @@ const EllipsisIcon = ({ title }) => {
|
|
|
12650
13151
|
));
|
|
12651
13152
|
};
|
|
12652
13153
|
const Wrapper$1 = ({ inline, children }) => {
|
|
12653
|
-
const
|
|
13154
|
+
const Component = inline ? "span" : "div";
|
|
12654
13155
|
return /* @__PURE__ */ React__default.createElement(
|
|
12655
|
-
|
|
13156
|
+
Component,
|
|
12656
13157
|
{
|
|
12657
13158
|
contentEditable: false,
|
|
12658
13159
|
style: { userSelect: "none" },
|
|
@@ -12786,7 +13287,7 @@ const EmbedNestedForm = ({
|
|
|
12786
13287
|
);
|
|
12787
13288
|
};
|
|
12788
13289
|
const DotMenu = ({ onOpen, onRemove }) => {
|
|
12789
|
-
return /* @__PURE__ */ React__default.createElement(Popover$
|
|
13290
|
+
return /* @__PURE__ */ React__default.createElement(Popover$3, { as: "span", className: "-ml-px relative block" }, /* @__PURE__ */ React__default.createElement(
|
|
12790
13291
|
PopoverButton,
|
|
12791
13292
|
{
|
|
12792
13293
|
as: "span",
|
|
@@ -13226,13 +13727,26 @@ const plugins = [
|
|
|
13226
13727
|
createUnderlinePlugin(),
|
|
13227
13728
|
createCodePlugin(),
|
|
13228
13729
|
createListPlugin(),
|
|
13229
|
-
createIndentPlugin(),
|
|
13230
13730
|
createIndentListPlugin(),
|
|
13231
13731
|
createHorizontalRulePlugin(),
|
|
13232
13732
|
// Allows us to do things like copy/paste, remembering the state of the element (like mdx)
|
|
13233
13733
|
createNodeIdPlugin(),
|
|
13234
|
-
createSlashPlugin()
|
|
13734
|
+
createSlashPlugin(),
|
|
13735
|
+
createTablePlugin()
|
|
13235
13736
|
];
|
|
13737
|
+
const unsupportedItemsInTable = /* @__PURE__ */ new Set([
|
|
13738
|
+
"Code Block",
|
|
13739
|
+
"Unordered List",
|
|
13740
|
+
"Ordered List",
|
|
13741
|
+
"Quote",
|
|
13742
|
+
"Mermaid",
|
|
13743
|
+
"Heading 1",
|
|
13744
|
+
"Heading 2",
|
|
13745
|
+
"Heading 3",
|
|
13746
|
+
"Heading 4",
|
|
13747
|
+
"Heading 5",
|
|
13748
|
+
"Heading 6"
|
|
13749
|
+
]);
|
|
13236
13750
|
const isNodeActive = (editor, type) => {
|
|
13237
13751
|
const pluginType = getPluginType(editor, type);
|
|
13238
13752
|
return !!(editor == null ? void 0 : editor.selection) && someNode(editor, { match: { type: pluginType } });
|
|
@@ -13417,24 +13931,6 @@ const Editor = React__default.forwardRef(
|
|
|
13417
13931
|
}
|
|
13418
13932
|
);
|
|
13419
13933
|
Editor.displayName = "Editor";
|
|
13420
|
-
const separatorVariants = cva("shrink-0 bg-border", {
|
|
13421
|
-
defaultVariants: {
|
|
13422
|
-
orientation: "horizontal"
|
|
13423
|
-
},
|
|
13424
|
-
variants: {
|
|
13425
|
-
orientation: {
|
|
13426
|
-
horizontal: "h-px w-full",
|
|
13427
|
-
vertical: "h-full w-px"
|
|
13428
|
-
}
|
|
13429
|
-
}
|
|
13430
|
-
});
|
|
13431
|
-
const Separator = withVariants(
|
|
13432
|
-
withProps(SeparatorPrimitive.Root, {
|
|
13433
|
-
decorative: true,
|
|
13434
|
-
orientation: "horizontal"
|
|
13435
|
-
}),
|
|
13436
|
-
separatorVariants
|
|
13437
|
-
);
|
|
13438
13934
|
const TooltipProvider = TooltipPrimitive.Provider;
|
|
13439
13935
|
const Tooltip = TooltipPrimitive.Root;
|
|
13440
13936
|
const TooltipTrigger = TooltipPrimitive.Trigger;
|
|
@@ -13443,15 +13939,15 @@ const TooltipContent = withCn(
|
|
|
13443
13939
|
withProps(TooltipPrimitive.Content, {
|
|
13444
13940
|
sideOffset: 4
|
|
13445
13941
|
}),
|
|
13446
|
-
"z-
|
|
13942
|
+
"z-[9999] overflow-hidden rounded-md border bg-popover px-3 py-1.5 text-sm text-popover-foreground shadow-md"
|
|
13447
13943
|
);
|
|
13448
|
-
function withTooltip(
|
|
13944
|
+
function withTooltip(Component) {
|
|
13449
13945
|
return React__default.forwardRef(function ExtendComponent({ tooltip, tooltipContentProps, tooltipProps, ...props }, ref) {
|
|
13450
13946
|
const [mounted, setMounted] = React__default.useState(false);
|
|
13451
13947
|
React__default.useEffect(() => {
|
|
13452
13948
|
setMounted(true);
|
|
13453
13949
|
}, []);
|
|
13454
|
-
const component = /* @__PURE__ */ React__default.createElement(
|
|
13950
|
+
const component = /* @__PURE__ */ React__default.createElement(Component, { ref, ...props });
|
|
13455
13951
|
if (tooltip && mounted) {
|
|
13456
13952
|
return /* @__PURE__ */ React__default.createElement(Tooltip, { ...tooltipProps }, /* @__PURE__ */ React__default.createElement(TooltipTrigger, { asChild: true }, component), /* @__PURE__ */ React__default.createElement(TooltipPortal, null, /* @__PURE__ */ React__default.createElement(TooltipContent, { ...tooltipContentProps }, tooltip)));
|
|
13457
13953
|
}
|
|
@@ -13569,140 +14065,41 @@ const FixedToolbar = withCn(
|
|
|
13569
14065
|
Toolbar,
|
|
13570
14066
|
"p-1 sticky left-0 top-0 z-50 w-full justify-between overflow-x-auto border border-border bg-background"
|
|
13571
14067
|
);
|
|
13572
|
-
const
|
|
13573
|
-
|
|
13574
|
-
|
|
13575
|
-
|
|
13576
|
-
|
|
13577
|
-
const IndentListToolbarButton = withRef(({ nodeType = ELEMENT_UL }, ref) => {
|
|
13578
|
-
const editor = useEditorState();
|
|
13579
|
-
const state = useListToolbarButtonState({ nodeType });
|
|
13580
|
-
const { props } = useListToolbarButton(state);
|
|
13581
|
-
return /* @__PURE__ */ React__default.createElement(
|
|
13582
|
-
ToolbarButton,
|
|
13583
|
-
{
|
|
13584
|
-
ref,
|
|
13585
|
-
tooltip: nodeType === ELEMENT_UL ? "Bulleted List" : "Numbered List",
|
|
13586
|
-
...props,
|
|
13587
|
-
onClick: (e) => {
|
|
13588
|
-
e.preventDefault();
|
|
13589
|
-
e.stopPropagation();
|
|
13590
|
-
toggleList(editor, { type: nodeType });
|
|
13591
|
-
}
|
|
13592
|
-
},
|
|
13593
|
-
nodeType === ELEMENT_UL ? /* @__PURE__ */ React__default.createElement(Icons.ul, null) : /* @__PURE__ */ React__default.createElement(Icons.ol, null)
|
|
13594
|
-
);
|
|
13595
|
-
});
|
|
13596
|
-
const DropdownMenu = DropdownMenuPrimitive.Root;
|
|
13597
|
-
const DropdownMenuTrigger = DropdownMenuPrimitive.Trigger;
|
|
13598
|
-
const DropdownMenuRadioGroup = DropdownMenuPrimitive.RadioGroup;
|
|
13599
|
-
withRef(({ children, className, inset, ...props }, ref) => /* @__PURE__ */ React__default.createElement(
|
|
13600
|
-
DropdownMenuPrimitive.SubTrigger,
|
|
13601
|
-
{
|
|
13602
|
-
className: cn$1(
|
|
13603
|
-
"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",
|
|
13604
|
-
"data-[disabled]:pointer-events-none data-[disabled]:opacity-50",
|
|
13605
|
-
inset && "pl-8",
|
|
13606
|
-
className
|
|
13607
|
-
),
|
|
13608
|
-
ref,
|
|
13609
|
-
...props
|
|
13610
|
-
},
|
|
13611
|
-
children,
|
|
13612
|
-
/* @__PURE__ */ React__default.createElement(Icons.chevronRight, { className: "ml-auto size-4" })
|
|
13613
|
-
));
|
|
13614
|
-
withCn(
|
|
13615
|
-
DropdownMenuPrimitive.SubContent,
|
|
13616
|
-
"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"
|
|
13617
|
-
);
|
|
13618
|
-
const DropdownMenuContentVariants = withProps(DropdownMenuPrimitive.Content, {
|
|
13619
|
-
className: cn$1(
|
|
13620
|
-
"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"
|
|
13621
|
-
),
|
|
13622
|
-
sideOffset: 4
|
|
13623
|
-
});
|
|
13624
|
-
const DropdownMenuContent = withRef(({ ...props }, ref) => /* @__PURE__ */ React__default.createElement(DropdownMenuPrimitive.Portal, null, /* @__PURE__ */ React__default.createElement(DropdownMenuContentVariants, { ref, ...props })));
|
|
13625
|
-
const menuItemVariants = cva(
|
|
13626
|
-
cn$1(
|
|
13627
|
-
"relative flex h-9 cursor-pointer select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none transition-colors",
|
|
13628
|
-
"focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50"
|
|
13629
|
-
),
|
|
13630
|
-
{
|
|
13631
|
-
variants: {
|
|
13632
|
-
inset: {
|
|
13633
|
-
true: "pl-8"
|
|
14068
|
+
const useResize = (ref, callback) => {
|
|
14069
|
+
React__default.useEffect(() => {
|
|
14070
|
+
const resizeObserver = new ResizeObserver((entries) => {
|
|
14071
|
+
for (const entry of entries) {
|
|
14072
|
+
callback(entry);
|
|
13634
14073
|
}
|
|
14074
|
+
});
|
|
14075
|
+
if (ref.current) {
|
|
14076
|
+
resizeObserver.observe(ref.current);
|
|
13635
14077
|
}
|
|
13636
|
-
|
|
13637
|
-
);
|
|
13638
|
-
|
|
13639
|
-
|
|
13640
|
-
|
|
13641
|
-
|
|
13642
|
-
|
|
13643
|
-
|
|
13644
|
-
|
|
13645
|
-
|
|
13646
|
-
|
|
13647
|
-
|
|
13648
|
-
|
|
13649
|
-
|
|
13650
|
-
|
|
13651
|
-
ref,
|
|
13652
|
-
...props
|
|
13653
|
-
},
|
|
13654
|
-
/* @__PURE__ */ React__default.createElement("span", { className: "absolute left-2 flex size-3.5 items-center justify-center" }, /* @__PURE__ */ React__default.createElement(DropdownMenuPrimitive.ItemIndicator, null, /* @__PURE__ */ React__default.createElement(Icons.check, { className: "size-4" }))),
|
|
13655
|
-
children
|
|
13656
|
-
));
|
|
13657
|
-
const DropdownMenuRadioItem = withRef(({ children, className, hideIcon, ...props }, ref) => /* @__PURE__ */ React__default.createElement(
|
|
13658
|
-
DropdownMenuPrimitive.RadioItem,
|
|
13659
|
-
{
|
|
13660
|
-
className: cn$1(
|
|
13661
|
-
"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",
|
|
13662
|
-
"h-9 cursor-pointer px-2 data-[state=checked]:bg-accent data-[state=checked]:text-accent-foreground",
|
|
13663
|
-
className
|
|
13664
|
-
),
|
|
13665
|
-
ref,
|
|
13666
|
-
...props
|
|
13667
|
-
},
|
|
13668
|
-
!hideIcon && /* @__PURE__ */ React__default.createElement("span", { className: "absolute right-2 flex size-3.5 items-center justify-center" }, /* @__PURE__ */ React__default.createElement(DropdownMenuPrimitive.ItemIndicator, null, /* @__PURE__ */ React__default.createElement(Icons.check, { className: "size-4" }))),
|
|
14078
|
+
return () => resizeObserver.disconnect();
|
|
14079
|
+
}, [ref.current]);
|
|
14080
|
+
};
|
|
14081
|
+
const STANDARD_ICON_WIDTH = 32;
|
|
14082
|
+
const HEADING_ICON_WITH_TEXT = 127;
|
|
14083
|
+
const HEADING_ICON_ONLY = 58;
|
|
14084
|
+
const EMBED_ICON_WIDTH = 78;
|
|
14085
|
+
const CONTAINER_MD_BREAKPOINT = 448;
|
|
14086
|
+
const FLOAT_BUTTON_WIDTH = 25;
|
|
14087
|
+
const HEADING_LABEL = "Headings";
|
|
14088
|
+
const ToolbarContext = createContext(void 0);
|
|
14089
|
+
const ToolbarProvider = ({
|
|
14090
|
+
tinaForm,
|
|
14091
|
+
templates,
|
|
14092
|
+
overrides,
|
|
13669
14093
|
children
|
|
13670
|
-
)
|
|
13671
|
-
|
|
13672
|
-
|
|
13673
|
-
|
|
13674
|
-
|
|
13675
|
-
|
|
13676
|
-
|
|
13677
|
-
}
|
|
13678
|
-
}
|
|
14094
|
+
}) => {
|
|
14095
|
+
return /* @__PURE__ */ React__default.createElement(ToolbarContext.Provider, { value: { tinaForm, templates, overrides } }, children);
|
|
14096
|
+
};
|
|
14097
|
+
const useToolbarContext = () => {
|
|
14098
|
+
const context = useContext(ToolbarContext);
|
|
14099
|
+
if (!context) {
|
|
14100
|
+
throw new Error("useToolbarContext must be used within a ToolbarProvider");
|
|
13679
14101
|
}
|
|
13680
|
-
|
|
13681
|
-
const DropdownMenuLabel = withVariants(
|
|
13682
|
-
DropdownMenuPrimitive.Label,
|
|
13683
|
-
dropdownMenuLabelVariants,
|
|
13684
|
-
["inset"]
|
|
13685
|
-
);
|
|
13686
|
-
const DropdownMenuSeparator = withCn(
|
|
13687
|
-
DropdownMenuPrimitive.Separator,
|
|
13688
|
-
"-mx-1 my-1 h-px bg-muted"
|
|
13689
|
-
);
|
|
13690
|
-
withCn(
|
|
13691
|
-
createPrimitiveElement("span"),
|
|
13692
|
-
"ml-auto text-xs tracking-widest opacity-60"
|
|
13693
|
-
);
|
|
13694
|
-
const useOpenState = () => {
|
|
13695
|
-
const [open2, setOpen] = useState(false);
|
|
13696
|
-
const onOpenChange = useCallback(
|
|
13697
|
-
(_value = !open2) => {
|
|
13698
|
-
setOpen(_value);
|
|
13699
|
-
},
|
|
13700
|
-
[open2]
|
|
13701
|
-
);
|
|
13702
|
-
return {
|
|
13703
|
-
onOpenChange,
|
|
13704
|
-
open: open2
|
|
13705
|
-
};
|
|
14102
|
+
return context;
|
|
13706
14103
|
};
|
|
13707
14104
|
const items$1 = [
|
|
13708
14105
|
{
|
|
@@ -13768,7 +14165,9 @@ function HeadingsMenu(props) {
|
|
|
13768
14165
|
return allNodesMatchInitialNodeType ? initialNodeType : ELEMENT_PARAGRAPH$1;
|
|
13769
14166
|
}, []);
|
|
13770
14167
|
const editor = useEditorRef();
|
|
14168
|
+
const editorState = useEditorState();
|
|
13771
14169
|
const openState = useOpenState();
|
|
14170
|
+
const userInTable = helpers.isNodeActive(editorState, ELEMENT_TABLE$1);
|
|
13772
14171
|
const selectedItem = items$1.find((item) => item.value === value) ?? defaultItem$1;
|
|
13773
14172
|
const { icon: SelectedItemIcon, label: selectedItemLabel } = selectedItem;
|
|
13774
14173
|
return /* @__PURE__ */ React__default.createElement(DropdownMenu, { modal: false, ...openState, ...props }, /* @__PURE__ */ React__default.createElement(DropdownMenuTrigger, { asChild: true }, /* @__PURE__ */ React__default.createElement(
|
|
@@ -13780,7 +14179,7 @@ function HeadingsMenu(props) {
|
|
|
13780
14179
|
tooltip: "Headings"
|
|
13781
14180
|
},
|
|
13782
14181
|
/* @__PURE__ */ React__default.createElement(SelectedItemIcon, { className: "size-5" }),
|
|
13783
|
-
/* @__PURE__ */ React__default.createElement("span", { className: "
|
|
14182
|
+
/* @__PURE__ */ React__default.createElement("span", { className: "@md/toolbar:flex hidden" }, selectedItemLabel)
|
|
13784
14183
|
)), /* @__PURE__ */ React__default.createElement(DropdownMenuContent, { align: "start", className: "min-w-0" }, /* @__PURE__ */ React__default.createElement(
|
|
13785
14184
|
DropdownMenuRadioGroup,
|
|
13786
14185
|
{
|
|
@@ -13792,7 +14191,12 @@ function HeadingsMenu(props) {
|
|
|
13792
14191
|
},
|
|
13793
14192
|
value
|
|
13794
14193
|
},
|
|
13795
|
-
items$1.
|
|
14194
|
+
items$1.filter((item) => {
|
|
14195
|
+
if (userInTable) {
|
|
14196
|
+
return !unsupportedItemsInTable.has(item.label);
|
|
14197
|
+
}
|
|
14198
|
+
return true;
|
|
14199
|
+
}).map(({ icon: Icon, label, value: itemValue }) => /* @__PURE__ */ React__default.createElement(
|
|
13796
14200
|
DropdownMenuRadioItem,
|
|
13797
14201
|
{
|
|
13798
14202
|
className: "min-w-[180px]",
|
|
@@ -13804,11 +14208,146 @@ function HeadingsMenu(props) {
|
|
|
13804
14208
|
))
|
|
13805
14209
|
)));
|
|
13806
14210
|
}
|
|
14211
|
+
const useCodeBlockToolbarButtonState = () => {
|
|
14212
|
+
const editor = useEditorState();
|
|
14213
|
+
const isBlockActive = () => helpers.isNodeActive(editor, ELEMENT_CODE_BLOCK$1);
|
|
14214
|
+
return {
|
|
14215
|
+
pressed: isBlockActive()
|
|
14216
|
+
};
|
|
14217
|
+
};
|
|
14218
|
+
const useCodeBlockToolbarButton = (state) => {
|
|
14219
|
+
const editor = useEditorState();
|
|
14220
|
+
const onClick = () => {
|
|
14221
|
+
insertEmptyCodeBlock(editor);
|
|
14222
|
+
};
|
|
14223
|
+
const onMouseDown = (e) => {
|
|
14224
|
+
e.preventDefault();
|
|
14225
|
+
e.stopPropagation();
|
|
14226
|
+
};
|
|
14227
|
+
return {
|
|
14228
|
+
props: {
|
|
14229
|
+
onClick,
|
|
14230
|
+
onMouseDown,
|
|
14231
|
+
pressed: state.pressed
|
|
14232
|
+
}
|
|
14233
|
+
};
|
|
14234
|
+
};
|
|
14235
|
+
const CodeBlockToolbarButton = withRef(({ clear, ...rest }, ref) => {
|
|
14236
|
+
const state = useCodeBlockToolbarButtonState();
|
|
14237
|
+
const { props } = useCodeBlockToolbarButton(state);
|
|
14238
|
+
return /* @__PURE__ */ React__default.createElement(ToolbarButton, { ref, tooltip: "Link", ...rest, ...props }, /* @__PURE__ */ React__default.createElement(Icons.codeBlock, null));
|
|
14239
|
+
});
|
|
14240
|
+
const useImageToolbarButtonState = () => {
|
|
14241
|
+
const editor = useEditorState();
|
|
14242
|
+
const isBlockActive = () => helpers.isNodeActive(editor, ELEMENT_IMG);
|
|
14243
|
+
return {
|
|
14244
|
+
pressed: isBlockActive()
|
|
14245
|
+
};
|
|
14246
|
+
};
|
|
14247
|
+
const useImageToolbarButton = (state) => {
|
|
14248
|
+
const editor = useEditorState();
|
|
14249
|
+
const cms = useCMS$1();
|
|
14250
|
+
const onMouseDown = (e) => {
|
|
14251
|
+
e.preventDefault();
|
|
14252
|
+
cms.media.open({
|
|
14253
|
+
allowDelete: true,
|
|
14254
|
+
directory: "",
|
|
14255
|
+
onSelect: (media) => {
|
|
14256
|
+
insertImg(editor, media);
|
|
14257
|
+
}
|
|
14258
|
+
});
|
|
14259
|
+
};
|
|
14260
|
+
return {
|
|
14261
|
+
props: {
|
|
14262
|
+
onMouseDown,
|
|
14263
|
+
pressed: state.pressed
|
|
14264
|
+
}
|
|
14265
|
+
};
|
|
14266
|
+
};
|
|
14267
|
+
const ImageToolbarButton = withRef(({ clear, ...rest }, ref) => {
|
|
14268
|
+
const state = useImageToolbarButtonState();
|
|
14269
|
+
const { props } = useImageToolbarButton(state);
|
|
14270
|
+
return /* @__PURE__ */ React__default.createElement(ToolbarButton, { ref, tooltip: "Link", ...rest, ...props }, /* @__PURE__ */ React__default.createElement(Icons.image, null));
|
|
14271
|
+
});
|
|
14272
|
+
const IndentListToolbarButton = withRef(({ nodeType = ELEMENT_UL }, ref) => {
|
|
14273
|
+
const editor = useEditorState();
|
|
14274
|
+
const state = useListToolbarButtonState({ nodeType });
|
|
14275
|
+
const { props } = useListToolbarButton(state);
|
|
14276
|
+
return /* @__PURE__ */ React__default.createElement(
|
|
14277
|
+
ToolbarButton,
|
|
14278
|
+
{
|
|
14279
|
+
ref,
|
|
14280
|
+
tooltip: nodeType === ELEMENT_UL ? "Bulleted List" : "Numbered List",
|
|
14281
|
+
...props,
|
|
14282
|
+
onClick: (e) => {
|
|
14283
|
+
e.preventDefault();
|
|
14284
|
+
e.stopPropagation();
|
|
14285
|
+
toggleList(editor, { type: nodeType });
|
|
14286
|
+
}
|
|
14287
|
+
},
|
|
14288
|
+
nodeType === ELEMENT_UL ? /* @__PURE__ */ React__default.createElement(Icons.ul, null) : /* @__PURE__ */ React__default.createElement(Icons.ol, null)
|
|
14289
|
+
);
|
|
14290
|
+
});
|
|
13807
14291
|
const LinkToolbarButton = withRef((rest, ref) => {
|
|
13808
14292
|
const state = useLinkToolbarButtonState();
|
|
13809
14293
|
const { props } = useLinkToolbarButton(state);
|
|
13810
14294
|
return /* @__PURE__ */ React__default.createElement(ToolbarButton, { ref, tooltip: "Link", ...props, ...rest }, /* @__PURE__ */ React__default.createElement(Icons.link, null));
|
|
13811
14295
|
});
|
|
14296
|
+
const MarkToolbarButton = withRef(({ clear, nodeType, ...rest }, ref) => {
|
|
14297
|
+
const state = useMarkToolbarButtonState({ clear, nodeType });
|
|
14298
|
+
const { props } = useMarkToolbarButton(state);
|
|
14299
|
+
return /* @__PURE__ */ React__default.createElement(ToolbarButton, { ref, ...props, ...rest });
|
|
14300
|
+
});
|
|
14301
|
+
const useMermaidToolbarButtonState = () => {
|
|
14302
|
+
const editor = useEditorState();
|
|
14303
|
+
const isBlockActive = () => helpers.isNodeActive(editor, ELEMENT_MERMAID);
|
|
14304
|
+
return {
|
|
14305
|
+
pressed: isBlockActive()
|
|
14306
|
+
};
|
|
14307
|
+
};
|
|
14308
|
+
const useMermaidToolbarButton = (state) => {
|
|
14309
|
+
const editor = useEditorState();
|
|
14310
|
+
const onClick = () => {
|
|
14311
|
+
insertEmptyElement(editor, ELEMENT_MERMAID, {
|
|
14312
|
+
nextBlock: true,
|
|
14313
|
+
select: true
|
|
14314
|
+
});
|
|
14315
|
+
};
|
|
14316
|
+
const onMouseDown = (e) => {
|
|
14317
|
+
e.preventDefault();
|
|
14318
|
+
e.stopPropagation();
|
|
14319
|
+
};
|
|
14320
|
+
return {
|
|
14321
|
+
props: {
|
|
14322
|
+
onClick,
|
|
14323
|
+
onMouseDown,
|
|
14324
|
+
pressed: state.pressed
|
|
14325
|
+
}
|
|
14326
|
+
};
|
|
14327
|
+
};
|
|
14328
|
+
const MermaidToolbarButton = withRef(({ clear, ...rest }, ref) => {
|
|
14329
|
+
const state = useMermaidToolbarButtonState();
|
|
14330
|
+
const { props } = useMermaidToolbarButton(state);
|
|
14331
|
+
return /* @__PURE__ */ React__default.createElement(ToolbarButton, { ref, tooltip: "Mermaid", ...rest, ...props }, /* @__PURE__ */ React__default.createElement(Icons.mermaid, null));
|
|
14332
|
+
});
|
|
14333
|
+
function OverflowMenu({
|
|
14334
|
+
children,
|
|
14335
|
+
...props
|
|
14336
|
+
}) {
|
|
14337
|
+
const openState = useOpenState();
|
|
14338
|
+
return /* @__PURE__ */ React__default.createElement(DropdownMenu, { modal: false, ...openState, ...props }, /* @__PURE__ */ React__default.createElement(DropdownMenuTrigger, { asChild: true }, /* @__PURE__ */ React__default.createElement(
|
|
14339
|
+
ToolbarButton,
|
|
14340
|
+
{
|
|
14341
|
+
showArrow: false,
|
|
14342
|
+
"data-testid": "rich-text-editor-overflow-menu-button",
|
|
14343
|
+
className: "lg:min-w-[130px]",
|
|
14344
|
+
isDropdown: true,
|
|
14345
|
+
pressed: openState.open,
|
|
14346
|
+
tooltip: "Headings"
|
|
14347
|
+
},
|
|
14348
|
+
/* @__PURE__ */ React__default.createElement(Icons.overflow, { className: "size-5" })
|
|
14349
|
+
)), /* @__PURE__ */ React__default.createElement(DropdownMenuContent, { align: "start", className: "min-w-0 flex flex-grow" }, children));
|
|
14350
|
+
}
|
|
13812
14351
|
const useBlockQuoteToolbarButtonState = () => {
|
|
13813
14352
|
const editor = useEditorState();
|
|
13814
14353
|
const isBlockActive = () => helpers.isNodeActive(editor, ELEMENT_BLOCKQUOTE$1);
|
|
@@ -13840,67 +14379,6 @@ const QuoteToolbarButton = withRef(({ clear, ...rest }, ref) => {
|
|
|
13840
14379
|
const { props } = useBlockQuoteToolbarButton(state);
|
|
13841
14380
|
return /* @__PURE__ */ React__default.createElement(ToolbarButton, { ref, tooltip: "Link", ...rest, ...props }, /* @__PURE__ */ React__default.createElement(Icons.quote, null));
|
|
13842
14381
|
});
|
|
13843
|
-
const useCodeBlockToolbarButtonState = () => {
|
|
13844
|
-
const editor = useEditorState();
|
|
13845
|
-
const isBlockActive = () => helpers.isNodeActive(editor, ELEMENT_CODE_BLOCK$1);
|
|
13846
|
-
return {
|
|
13847
|
-
pressed: isBlockActive()
|
|
13848
|
-
};
|
|
13849
|
-
};
|
|
13850
|
-
const useCodeBlockToolbarButton = (state) => {
|
|
13851
|
-
const editor = useEditorState();
|
|
13852
|
-
const onClick = () => {
|
|
13853
|
-
insertEmptyCodeBlock(editor);
|
|
13854
|
-
};
|
|
13855
|
-
const onMouseDown = (e) => {
|
|
13856
|
-
e.preventDefault();
|
|
13857
|
-
e.stopPropagation();
|
|
13858
|
-
};
|
|
13859
|
-
return {
|
|
13860
|
-
props: {
|
|
13861
|
-
onClick,
|
|
13862
|
-
onMouseDown,
|
|
13863
|
-
pressed: state.pressed
|
|
13864
|
-
}
|
|
13865
|
-
};
|
|
13866
|
-
};
|
|
13867
|
-
const CodeBlockToolbarButton = withRef(({ clear, ...rest }, ref) => {
|
|
13868
|
-
const state = useCodeBlockToolbarButtonState();
|
|
13869
|
-
const { props } = useCodeBlockToolbarButton(state);
|
|
13870
|
-
return /* @__PURE__ */ React__default.createElement(ToolbarButton, { ref, tooltip: "Link", ...rest, ...props }, /* @__PURE__ */ React__default.createElement(Icons.codeBlock, null));
|
|
13871
|
-
});
|
|
13872
|
-
const useImageToolbarButtonState = () => {
|
|
13873
|
-
const editor = useEditorState();
|
|
13874
|
-
const isBlockActive = () => helpers.isNodeActive(editor, ELEMENT_IMG);
|
|
13875
|
-
return {
|
|
13876
|
-
pressed: isBlockActive()
|
|
13877
|
-
};
|
|
13878
|
-
};
|
|
13879
|
-
const useImageToolbarButton = (state) => {
|
|
13880
|
-
const editor = useEditorState();
|
|
13881
|
-
const cms = useCMS$1();
|
|
13882
|
-
const onMouseDown = (e) => {
|
|
13883
|
-
e.preventDefault();
|
|
13884
|
-
cms.media.open({
|
|
13885
|
-
allowDelete: true,
|
|
13886
|
-
directory: "",
|
|
13887
|
-
onSelect: (media) => {
|
|
13888
|
-
insertImg(editor, media);
|
|
13889
|
-
}
|
|
13890
|
-
});
|
|
13891
|
-
};
|
|
13892
|
-
return {
|
|
13893
|
-
props: {
|
|
13894
|
-
onMouseDown,
|
|
13895
|
-
pressed: state.pressed
|
|
13896
|
-
}
|
|
13897
|
-
};
|
|
13898
|
-
};
|
|
13899
|
-
const ImageToolbarButton = withRef(({ clear, ...rest }, ref) => {
|
|
13900
|
-
const state = useImageToolbarButtonState();
|
|
13901
|
-
const { props } = useImageToolbarButton(state);
|
|
13902
|
-
return /* @__PURE__ */ React__default.createElement(ToolbarButton, { ref, tooltip: "Link", ...rest, ...props }, /* @__PURE__ */ React__default.createElement(Icons.image, null));
|
|
13903
|
-
});
|
|
13904
14382
|
const useRawMarkdownToolbarButton = () => {
|
|
13905
14383
|
const { setRawMode } = useEditorContext();
|
|
13906
14384
|
const onMouseDown = (e) => {
|
|
@@ -13915,31 +14393,123 @@ const useRawMarkdownToolbarButton = () => {
|
|
|
13915
14393
|
};
|
|
13916
14394
|
const RawMarkdownToolbarButton = withRef(({ clear, ...rest }, ref) => {
|
|
13917
14395
|
const { props } = useRawMarkdownToolbarButton();
|
|
13918
|
-
return /* @__PURE__ */ React__default.createElement(
|
|
14396
|
+
return /* @__PURE__ */ React__default.createElement(
|
|
14397
|
+
ToolbarButton,
|
|
14398
|
+
{
|
|
14399
|
+
ref,
|
|
14400
|
+
tooltip: "Link",
|
|
14401
|
+
...rest,
|
|
14402
|
+
...props,
|
|
14403
|
+
"data-testid": "markdown-button"
|
|
14404
|
+
},
|
|
14405
|
+
/* @__PURE__ */ React__default.createElement(Icons.raw, null)
|
|
14406
|
+
);
|
|
13919
14407
|
});
|
|
13920
|
-
|
|
13921
|
-
const
|
|
13922
|
-
|
|
13923
|
-
|
|
13924
|
-
|
|
13925
|
-
|
|
13926
|
-
|
|
13927
|
-
|
|
13928
|
-
|
|
13929
|
-
const
|
|
13930
|
-
|
|
13931
|
-
|
|
13932
|
-
|
|
13933
|
-
|
|
13934
|
-
|
|
13935
|
-
};
|
|
14408
|
+
function TableDropdownMenu(props) {
|
|
14409
|
+
const tableSelected = useEditorSelector(
|
|
14410
|
+
(editor2) => someNode(editor2, { match: { type: ELEMENT_TABLE$1 } }),
|
|
14411
|
+
[]
|
|
14412
|
+
);
|
|
14413
|
+
const [enableDeleteColumn, enableDeleteRow] = useEditorSelector((editor2) => {
|
|
14414
|
+
const tableNodeEntry = findNode(editor2, { match: { type: ELEMENT_TABLE$1 } });
|
|
14415
|
+
if (!tableNodeEntry)
|
|
14416
|
+
return [false, false];
|
|
14417
|
+
const [tableNode] = tableNodeEntry;
|
|
14418
|
+
if (!isElement(tableNode))
|
|
14419
|
+
return [false, false];
|
|
14420
|
+
const columnCount = getTableColumnCount(tableNode);
|
|
14421
|
+
const rowCount = tableNode.children.length;
|
|
14422
|
+
return [columnCount > 1, rowCount > 1];
|
|
14423
|
+
}, []);
|
|
14424
|
+
const editor = useEditorRef();
|
|
14425
|
+
const openState = useOpenState();
|
|
14426
|
+
return /* @__PURE__ */ React__default.createElement(DropdownMenu, { modal: false, ...openState, ...props }, /* @__PURE__ */ React__default.createElement(DropdownMenuTrigger, { asChild: true }, /* @__PURE__ */ React__default.createElement(ToolbarButton, { isDropdown: true, pressed: openState.open, tooltip: "Table" }, /* @__PURE__ */ React__default.createElement(Icons.table, null))), /* @__PURE__ */ React__default.createElement(
|
|
14427
|
+
DropdownMenuContent,
|
|
14428
|
+
{
|
|
14429
|
+
align: "start",
|
|
14430
|
+
className: "flex w-[180px] min-w-0 flex-col gap-0.5"
|
|
14431
|
+
},
|
|
14432
|
+
/* @__PURE__ */ React__default.createElement(
|
|
14433
|
+
DropdownMenuItem,
|
|
14434
|
+
{
|
|
14435
|
+
className: "min-w-[180px]",
|
|
14436
|
+
disabled: tableSelected,
|
|
14437
|
+
onSelect: () => {
|
|
14438
|
+
insertTable(editor);
|
|
14439
|
+
focusEditor(editor);
|
|
14440
|
+
}
|
|
14441
|
+
},
|
|
14442
|
+
/* @__PURE__ */ React__default.createElement(Icons.add, { className: iconVariants({ variant: "menuItem" }) }),
|
|
14443
|
+
"Insert table"
|
|
14444
|
+
),
|
|
14445
|
+
/* @__PURE__ */ React__default.createElement(
|
|
14446
|
+
DropdownMenuItem,
|
|
14447
|
+
{
|
|
14448
|
+
className: "min-w-[180px]",
|
|
14449
|
+
disabled: !tableSelected,
|
|
14450
|
+
onSelect: () => {
|
|
14451
|
+
deleteTable(editor);
|
|
14452
|
+
focusEditor(editor);
|
|
14453
|
+
}
|
|
14454
|
+
},
|
|
14455
|
+
/* @__PURE__ */ React__default.createElement(Icons.minus, { className: iconVariants({ variant: "menuItem" }) }),
|
|
14456
|
+
"Delete table"
|
|
14457
|
+
),
|
|
14458
|
+
/* @__PURE__ */ React__default.createElement(DropdownMenuSub, null, /* @__PURE__ */ React__default.createElement(DropdownMenuSubTrigger, { disabled: !tableSelected }, /* @__PURE__ */ React__default.createElement(Icons.column, { className: iconVariants({ variant: "menuItem" }) }), /* @__PURE__ */ React__default.createElement("span", null, "Column")), /* @__PURE__ */ React__default.createElement(DropdownMenuSubContent, null, /* @__PURE__ */ React__default.createElement(
|
|
14459
|
+
DropdownMenuItem,
|
|
14460
|
+
{
|
|
14461
|
+
className: "min-w-[180px]",
|
|
14462
|
+
disabled: !tableSelected,
|
|
14463
|
+
onSelect: () => {
|
|
14464
|
+
insertTableColumn(editor);
|
|
14465
|
+
focusEditor(editor);
|
|
14466
|
+
}
|
|
14467
|
+
},
|
|
14468
|
+
/* @__PURE__ */ React__default.createElement(Icons.add, { className: iconVariants({ variant: "menuItem" }) }),
|
|
14469
|
+
"Insert column after"
|
|
14470
|
+
), /* @__PURE__ */ React__default.createElement(
|
|
14471
|
+
DropdownMenuItem,
|
|
14472
|
+
{
|
|
14473
|
+
className: "min-w-[180px]",
|
|
14474
|
+
disabled: !enableDeleteColumn,
|
|
14475
|
+
onSelect: () => {
|
|
14476
|
+
deleteColumn(editor);
|
|
14477
|
+
focusEditor(editor);
|
|
14478
|
+
}
|
|
14479
|
+
},
|
|
14480
|
+
/* @__PURE__ */ React__default.createElement(Icons.minus, { className: iconVariants({ variant: "menuItem" }) }),
|
|
14481
|
+
"Delete column"
|
|
14482
|
+
))),
|
|
14483
|
+
/* @__PURE__ */ React__default.createElement(DropdownMenuSub, null, /* @__PURE__ */ React__default.createElement(DropdownMenuSubTrigger, { disabled: !tableSelected }, /* @__PURE__ */ React__default.createElement(Icons.row, { className: iconVariants({ variant: "menuItem" }) }), /* @__PURE__ */ React__default.createElement("span", null, "Row")), /* @__PURE__ */ React__default.createElement(DropdownMenuSubContent, null, /* @__PURE__ */ React__default.createElement(
|
|
14484
|
+
DropdownMenuItem,
|
|
14485
|
+
{
|
|
14486
|
+
className: "min-w-[180px]",
|
|
14487
|
+
disabled: !tableSelected,
|
|
14488
|
+
onSelect: () => {
|
|
14489
|
+
insertTableRow(editor);
|
|
14490
|
+
focusEditor(editor);
|
|
14491
|
+
}
|
|
14492
|
+
},
|
|
14493
|
+
/* @__PURE__ */ React__default.createElement(Icons.add, { className: iconVariants({ variant: "menuItem" }) }),
|
|
14494
|
+
"Insert row after"
|
|
14495
|
+
), /* @__PURE__ */ React__default.createElement(
|
|
14496
|
+
DropdownMenuItem,
|
|
14497
|
+
{
|
|
14498
|
+
className: "min-w-[180px]",
|
|
14499
|
+
disabled: !enableDeleteRow,
|
|
14500
|
+
onSelect: () => {
|
|
14501
|
+
deleteRow(editor);
|
|
14502
|
+
focusEditor(editor);
|
|
14503
|
+
}
|
|
14504
|
+
},
|
|
14505
|
+
/* @__PURE__ */ React__default.createElement(Icons.minus, { className: iconVariants({ variant: "menuItem" }) }),
|
|
14506
|
+
"Delete row"
|
|
14507
|
+
)))
|
|
14508
|
+
));
|
|
14509
|
+
}
|
|
13936
14510
|
function TemplatesToolbarButton() {
|
|
13937
14511
|
const { templates } = useToolbarContext();
|
|
13938
|
-
const showEmbed = templates.length > 0;
|
|
13939
14512
|
const editor = useEditorState();
|
|
13940
|
-
if (!showEmbed) {
|
|
13941
|
-
return null;
|
|
13942
|
-
}
|
|
13943
14513
|
return /* @__PURE__ */ React__default.createElement(EmbedButton, { templates, editor });
|
|
13944
14514
|
}
|
|
13945
14515
|
const EmbedButton = ({ editor, templates }) => {
|
|
@@ -13972,7 +14542,7 @@ const EmbedButton = ({ editor, templates }) => {
|
|
|
13972
14542
|
key: template.name,
|
|
13973
14543
|
onMouseDown: (e) => {
|
|
13974
14544
|
e.preventDefault();
|
|
13975
|
-
|
|
14545
|
+
setOpen(false);
|
|
13976
14546
|
insertMDX(editor, template);
|
|
13977
14547
|
},
|
|
13978
14548
|
className: ""
|
|
@@ -13980,99 +14550,118 @@ const EmbedButton = ({ editor, templates }) => {
|
|
|
13980
14550
|
template.label || template.name
|
|
13981
14551
|
))));
|
|
13982
14552
|
};
|
|
13983
|
-
const ICON_WIDTH = 32;
|
|
13984
|
-
const EMBED_ICON_WIDTH = 78;
|
|
13985
|
-
const useResize = (ref, callback) => {
|
|
13986
|
-
React__default.useEffect(() => {
|
|
13987
|
-
const resizeObserver = new ResizeObserver((entries) => {
|
|
13988
|
-
for (const entry of entries) {
|
|
13989
|
-
callback(entry);
|
|
13990
|
-
}
|
|
13991
|
-
});
|
|
13992
|
-
if (ref.current) {
|
|
13993
|
-
resizeObserver.observe(ref.current);
|
|
13994
|
-
}
|
|
13995
|
-
return () => resizeObserver.disconnect();
|
|
13996
|
-
}, [ref.current]);
|
|
13997
|
-
};
|
|
13998
|
-
function OverflowMenu({
|
|
13999
|
-
children,
|
|
14000
|
-
...props
|
|
14001
|
-
}) {
|
|
14002
|
-
const openState = useOpenState();
|
|
14003
|
-
return /* @__PURE__ */ React__default.createElement(DropdownMenu, { modal: false, ...openState, ...props }, /* @__PURE__ */ React__default.createElement(DropdownMenuTrigger, { asChild: true }, /* @__PURE__ */ React__default.createElement(
|
|
14004
|
-
ToolbarButton,
|
|
14005
|
-
{
|
|
14006
|
-
showArrow: false,
|
|
14007
|
-
className: "lg:min-w-[130px]",
|
|
14008
|
-
isDropdown: true,
|
|
14009
|
-
pressed: openState.open,
|
|
14010
|
-
tooltip: "Headings"
|
|
14011
|
-
},
|
|
14012
|
-
/* @__PURE__ */ React__default.createElement(Icons.overflow, { className: "size-5" })
|
|
14013
|
-
)), /* @__PURE__ */ React__default.createElement(DropdownMenuContent, { align: "start", className: "min-w-0 flex flex-grow" }, children));
|
|
14014
|
-
}
|
|
14015
14553
|
const toolbarItems = {
|
|
14016
14554
|
heading: {
|
|
14017
|
-
label:
|
|
14555
|
+
label: HEADING_LABEL,
|
|
14556
|
+
width: (paragraphIconExists) => paragraphIconExists ? HEADING_ICON_WITH_TEXT : HEADING_ICON_ONLY,
|
|
14557
|
+
// Dynamically handle width based on paragraph icon
|
|
14018
14558
|
Component: /* @__PURE__ */ React__default.createElement(ToolbarGroup, { noSeparator: true }, /* @__PURE__ */ React__default.createElement(HeadingsMenu, null))
|
|
14019
14559
|
},
|
|
14020
14560
|
link: {
|
|
14021
14561
|
label: "Link",
|
|
14562
|
+
width: () => STANDARD_ICON_WIDTH,
|
|
14022
14563
|
Component: /* @__PURE__ */ React__default.createElement(LinkToolbarButton, null)
|
|
14023
14564
|
},
|
|
14024
14565
|
image: {
|
|
14025
14566
|
label: "Image",
|
|
14567
|
+
width: () => STANDARD_ICON_WIDTH,
|
|
14026
14568
|
Component: /* @__PURE__ */ React__default.createElement(ImageToolbarButton, null)
|
|
14027
14569
|
},
|
|
14028
14570
|
quote: {
|
|
14029
14571
|
label: "Quote",
|
|
14572
|
+
width: () => STANDARD_ICON_WIDTH,
|
|
14030
14573
|
Component: /* @__PURE__ */ React__default.createElement(QuoteToolbarButton, { tooltip: "Quote Quote (⌘+⇧+.)" })
|
|
14031
14574
|
},
|
|
14032
14575
|
ul: {
|
|
14033
14576
|
label: "Unordered List",
|
|
14577
|
+
width: () => STANDARD_ICON_WIDTH,
|
|
14034
14578
|
Component: /* @__PURE__ */ React__default.createElement(IndentListToolbarButton, { nodeType: ELEMENT_UL })
|
|
14035
14579
|
},
|
|
14036
14580
|
ol: {
|
|
14037
14581
|
label: "Ordered List",
|
|
14582
|
+
width: () => STANDARD_ICON_WIDTH,
|
|
14038
14583
|
Component: /* @__PURE__ */ React__default.createElement(IndentListToolbarButton, { nodeType: ELEMENT_OL })
|
|
14039
14584
|
},
|
|
14040
14585
|
bold: {
|
|
14041
14586
|
label: "Bold",
|
|
14587
|
+
width: () => STANDARD_ICON_WIDTH,
|
|
14042
14588
|
Component: /* @__PURE__ */ React__default.createElement(MarkToolbarButton, { tooltip: "Bold (⌘+B)", nodeType: MARK_BOLD }, /* @__PURE__ */ React__default.createElement(Icons.bold, null))
|
|
14043
14589
|
},
|
|
14044
14590
|
italic: {
|
|
14045
14591
|
label: "Italic",
|
|
14592
|
+
width: () => STANDARD_ICON_WIDTH,
|
|
14046
14593
|
Component: /* @__PURE__ */ React__default.createElement(MarkToolbarButton, { tooltip: "Italic (⌘+I)", nodeType: MARK_ITALIC }, /* @__PURE__ */ React__default.createElement(Icons.italic, null))
|
|
14047
14594
|
},
|
|
14048
14595
|
code: {
|
|
14049
14596
|
label: "Code",
|
|
14597
|
+
width: () => STANDARD_ICON_WIDTH,
|
|
14050
14598
|
Component: /* @__PURE__ */ React__default.createElement(MarkToolbarButton, { tooltip: "Code (⌘+E)", nodeType: MARK_CODE }, /* @__PURE__ */ React__default.createElement(Icons.code, null))
|
|
14051
14599
|
},
|
|
14052
14600
|
codeBlock: {
|
|
14053
14601
|
label: "Code Block",
|
|
14602
|
+
width: () => STANDARD_ICON_WIDTH,
|
|
14054
14603
|
Component: /* @__PURE__ */ React__default.createElement(CodeBlockToolbarButton, null)
|
|
14055
14604
|
},
|
|
14605
|
+
mermaid: {
|
|
14606
|
+
label: "Mermaid",
|
|
14607
|
+
width: () => STANDARD_ICON_WIDTH,
|
|
14608
|
+
Component: /* @__PURE__ */ React__default.createElement(MermaidToolbarButton, null)
|
|
14609
|
+
},
|
|
14610
|
+
table: {
|
|
14611
|
+
label: "Table",
|
|
14612
|
+
width: () => STANDARD_ICON_WIDTH,
|
|
14613
|
+
Component: /* @__PURE__ */ React__default.createElement(TableDropdownMenu, null)
|
|
14614
|
+
},
|
|
14056
14615
|
raw: {
|
|
14057
14616
|
label: "Raw Markdown",
|
|
14617
|
+
width: () => STANDARD_ICON_WIDTH,
|
|
14058
14618
|
Component: /* @__PURE__ */ React__default.createElement(RawMarkdownToolbarButton, null)
|
|
14059
14619
|
},
|
|
14060
14620
|
embed: {
|
|
14061
14621
|
label: "Templates",
|
|
14622
|
+
width: () => EMBED_ICON_WIDTH,
|
|
14062
14623
|
Component: /* @__PURE__ */ React__default.createElement(TemplatesToolbarButton, null)
|
|
14063
14624
|
}
|
|
14064
14625
|
};
|
|
14065
14626
|
function FixedToolbarButtons() {
|
|
14066
14627
|
const toolbarRef = React__default.useRef(null);
|
|
14067
14628
|
const [itemsShown, setItemsShown] = React__default.useState(11);
|
|
14068
|
-
const { overrides } = useToolbarContext();
|
|
14629
|
+
const { overrides, templates } = useToolbarContext();
|
|
14630
|
+
const showEmbedButton = templates.length > 0;
|
|
14631
|
+
let items2 = [];
|
|
14632
|
+
if (Array.isArray(overrides)) {
|
|
14633
|
+
items2 = overrides === void 0 ? Object.values(toolbarItems) : overrides.map((item) => toolbarItems[item]).filter((item) => item !== void 0);
|
|
14634
|
+
} else {
|
|
14635
|
+
items2 = (overrides == null ? void 0 : overrides.toolbar) === void 0 ? Object.values(toolbarItems) : overrides.toolbar.map((item) => toolbarItems[item]).filter((item) => item !== void 0);
|
|
14636
|
+
}
|
|
14637
|
+
if (!showEmbedButton) {
|
|
14638
|
+
items2 = items2.filter((item) => item.label !== toolbarItems.embed.label);
|
|
14639
|
+
}
|
|
14640
|
+
const editorState = useEditorState();
|
|
14641
|
+
const userInTable = helpers.isNodeActive(editorState, ELEMENT_TABLE);
|
|
14642
|
+
if (userInTable) {
|
|
14643
|
+
items2 = items2.filter((item) => !unsupportedItemsInTable.has(item.label));
|
|
14644
|
+
}
|
|
14069
14645
|
useResize(toolbarRef, (entry) => {
|
|
14070
14646
|
const width = entry.target.getBoundingClientRect().width;
|
|
14071
|
-
const
|
|
14072
|
-
|
|
14647
|
+
const headingButton = items2.find((item) => item.label === HEADING_LABEL);
|
|
14648
|
+
const headingWidth = headingButton ? headingButton.width(width > CONTAINER_MD_BREAKPOINT) : 0;
|
|
14649
|
+
const availableWidth = width - headingWidth - FLOAT_BUTTON_WIDTH;
|
|
14650
|
+
const { itemFitCount } = items2.reduce(
|
|
14651
|
+
(acc, item) => {
|
|
14652
|
+
if (item.label !== HEADING_LABEL && acc.totalItemsWidth + item.width() <= availableWidth) {
|
|
14653
|
+
return {
|
|
14654
|
+
totalItemsWidth: acc.totalItemsWidth + item.width(),
|
|
14655
|
+
itemFitCount: acc.itemFitCount + 1
|
|
14656
|
+
};
|
|
14657
|
+
}
|
|
14658
|
+
return acc;
|
|
14659
|
+
},
|
|
14660
|
+
{ totalItemsWidth: 0, itemFitCount: 1 }
|
|
14661
|
+
);
|
|
14662
|
+
setItemsShown(itemFitCount);
|
|
14073
14663
|
});
|
|
14074
|
-
|
|
14075
|
-
return /* @__PURE__ */ React__default.createElement("div", { className: "w-full overflow-hidden", ref: toolbarRef }, /* @__PURE__ */ React__default.createElement(
|
|
14664
|
+
return /* @__PURE__ */ React__default.createElement("div", { className: "w-full overflow-hidden @container/toolbar", ref: toolbarRef }, /* @__PURE__ */ React__default.createElement(
|
|
14076
14665
|
"div",
|
|
14077
14666
|
{
|
|
14078
14667
|
className: "flex",
|
|
@@ -14080,7 +14669,7 @@ function FixedToolbarButtons() {
|
|
|
14080
14669
|
transform: "translateX(calc(-1px))"
|
|
14081
14670
|
}
|
|
14082
14671
|
},
|
|
14083
|
-
/* @__PURE__ */ React__default.createElement(React__default.Fragment, null,
|
|
14672
|
+
/* @__PURE__ */ React__default.createElement(React__default.Fragment, null, items2.slice(0, itemsShown).map((item) => /* @__PURE__ */ React__default.createElement(React__default.Fragment, { key: item.label }, item.Component)), items2.length > itemsShown && /* @__PURE__ */ React__default.createElement(OverflowMenu, null, items2.slice(itemsShown).flatMap((c) => /* @__PURE__ */ React__default.createElement(React__default.Fragment, { key: c.label }, c.Component))))
|
|
14084
14673
|
));
|
|
14085
14674
|
}
|
|
14086
14675
|
const FloatingToolbar = withRef(({ children, state, ...props }, componentRef) => {
|
|
@@ -14195,6 +14784,10 @@ function TurnIntoDropdownMenu(props) {
|
|
|
14195
14784
|
const openState = useOpenState();
|
|
14196
14785
|
const selectedItem = items.find((item) => item.value === value) ?? defaultItem;
|
|
14197
14786
|
const { icon: SelectedItemIcon, label: selectedItemLabel } = selectedItem;
|
|
14787
|
+
const editorState = useEditorState();
|
|
14788
|
+
const userInTable = helpers.isNodeActive(editorState, ELEMENT_TABLE$1);
|
|
14789
|
+
if (userInTable)
|
|
14790
|
+
return null;
|
|
14198
14791
|
return /* @__PURE__ */ React__default.createElement(DropdownMenu, { modal: false, ...openState, ...props }, /* @__PURE__ */ React__default.createElement(DropdownMenuTrigger, { asChild: true }, /* @__PURE__ */ React__default.createElement(
|
|
14199
14792
|
ToolbarButton,
|
|
14200
14793
|
{
|
|
@@ -14236,49 +14829,6 @@ function TurnIntoDropdownMenu(props) {
|
|
|
14236
14829
|
function FloatingToolbarButtons() {
|
|
14237
14830
|
return /* @__PURE__ */ React__default.createElement(React__default.Fragment, null, /* @__PURE__ */ React__default.createElement(TurnIntoDropdownMenu, null));
|
|
14238
14831
|
}
|
|
14239
|
-
const buttonVariants = cva(
|
|
14240
|
-
"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",
|
|
14241
|
-
{
|
|
14242
|
-
defaultVariants: {
|
|
14243
|
-
size: "default",
|
|
14244
|
-
variant: "default"
|
|
14245
|
-
},
|
|
14246
|
-
variants: {
|
|
14247
|
-
isMenu: {
|
|
14248
|
-
true: "h-auto w-full cursor-pointer justify-start"
|
|
14249
|
-
},
|
|
14250
|
-
size: {
|
|
14251
|
-
default: "h-10 px-4 py-2",
|
|
14252
|
-
icon: "size-10",
|
|
14253
|
-
lg: "h-11 rounded-md px-8",
|
|
14254
|
-
none: "",
|
|
14255
|
-
sm: "h-9 rounded-md px-3",
|
|
14256
|
-
sms: "size-9 rounded-md px-0",
|
|
14257
|
-
xs: "h-8 rounded-md px-3"
|
|
14258
|
-
},
|
|
14259
|
-
variant: {
|
|
14260
|
-
default: "bg-primary text-primary-foreground hover:bg-primary/90",
|
|
14261
|
-
destructive: "bg-destructive text-destructive-foreground hover:bg-destructive/90",
|
|
14262
|
-
ghost: "hover:bg-accent hover:text-accent-foreground",
|
|
14263
|
-
inlineLink: "text-base text-primary underline underline-offset-4",
|
|
14264
|
-
link: "text-primary underline-offset-4 hover:underline",
|
|
14265
|
-
outline: "border border-input bg-background hover:bg-accent hover:text-accent-foreground",
|
|
14266
|
-
secondary: "bg-secondary text-secondary-foreground hover:bg-secondary/80"
|
|
14267
|
-
}
|
|
14268
|
-
}
|
|
14269
|
-
}
|
|
14270
|
-
);
|
|
14271
|
-
withRef(({ asChild = false, className, isMenu, size, variant, ...props }, ref) => {
|
|
14272
|
-
const Comp = asChild ? Slot : "button";
|
|
14273
|
-
return /* @__PURE__ */ React.createElement(
|
|
14274
|
-
Comp,
|
|
14275
|
-
{
|
|
14276
|
-
className: cn$1(buttonVariants({ className, isMenu, size, variant })),
|
|
14277
|
-
ref,
|
|
14278
|
-
...props
|
|
14279
|
-
}
|
|
14280
|
-
);
|
|
14281
|
-
});
|
|
14282
14832
|
const inputVariants = cva(
|
|
14283
14833
|
"flex w-full rounded-md bg-transparent text-sm file:border-0 file:bg-background file:text-sm file:font-medium placeholder:text-muted-foreground focus-visible:outline-none disabled:cursor-not-allowed disabled:opacity-50",
|
|
14284
14834
|
{
|
|
@@ -14299,22 +14849,6 @@ const inputVariants = cva(
|
|
|
14299
14849
|
}
|
|
14300
14850
|
);
|
|
14301
14851
|
withVariants("input", inputVariants, ["variant", "h"]);
|
|
14302
|
-
const popoverVariants = cva(
|
|
14303
|
-
"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"
|
|
14304
|
-
);
|
|
14305
|
-
withRef(
|
|
14306
|
-
({ align = "center", className, sideOffset = 4, style, ...props }, ref) => /* @__PURE__ */ React.createElement(PopoverPrimitive.Portal, null, /* @__PURE__ */ React.createElement(
|
|
14307
|
-
PopoverPrimitive.Content,
|
|
14308
|
-
{
|
|
14309
|
-
align,
|
|
14310
|
-
className: cn$1(popoverVariants(), className),
|
|
14311
|
-
ref,
|
|
14312
|
-
sideOffset,
|
|
14313
|
-
style: { zIndex: 1e3, ...style },
|
|
14314
|
-
...props
|
|
14315
|
-
}
|
|
14316
|
-
))
|
|
14317
|
-
);
|
|
14318
14852
|
const floatingOptions = {
|
|
14319
14853
|
middleware: [
|
|
14320
14854
|
offset(12),
|
|
@@ -14374,7 +14908,7 @@ function LinkFloatingToolbar({ state }) {
|
|
|
14374
14908
|
const editContent = editState.isEditing ? input : /* @__PURE__ */ React__default.createElement("div", { className: "box-content flex h-9 items-center gap-1" }, /* @__PURE__ */ React__default.createElement(
|
|
14375
14909
|
"button",
|
|
14376
14910
|
{
|
|
14377
|
-
className: buttonVariants({ size: "sm", variant: "ghost" }),
|
|
14911
|
+
className: buttonVariants$1({ size: "sm", variant: "ghost" }),
|
|
14378
14912
|
type: "button",
|
|
14379
14913
|
...editButtonProps
|
|
14380
14914
|
},
|
|
@@ -14382,7 +14916,7 @@ function LinkFloatingToolbar({ state }) {
|
|
|
14382
14916
|
), /* @__PURE__ */ React__default.createElement(Separator, { orientation: "vertical" }), /* @__PURE__ */ React__default.createElement(
|
|
14383
14917
|
LinkOpenButton,
|
|
14384
14918
|
{
|
|
14385
|
-
className: buttonVariants({
|
|
14919
|
+
className: buttonVariants$1({
|
|
14386
14920
|
size: "sms",
|
|
14387
14921
|
variant: "ghost"
|
|
14388
14922
|
})
|
|
@@ -14391,7 +14925,7 @@ function LinkFloatingToolbar({ state }) {
|
|
|
14391
14925
|
), /* @__PURE__ */ React__default.createElement(Separator, { orientation: "vertical" }), /* @__PURE__ */ React__default.createElement(
|
|
14392
14926
|
"button",
|
|
14393
14927
|
{
|
|
14394
|
-
className: buttonVariants({
|
|
14928
|
+
className: buttonVariants$1({
|
|
14395
14929
|
size: "sms",
|
|
14396
14930
|
variant: "ghost"
|
|
14397
14931
|
}),
|
|
@@ -14427,6 +14961,9 @@ const isUrl = (string) => {
|
|
|
14427
14961
|
if (typeof string !== "string") {
|
|
14428
14962
|
return false;
|
|
14429
14963
|
}
|
|
14964
|
+
if (string.startsWith("#")) {
|
|
14965
|
+
return true;
|
|
14966
|
+
}
|
|
14430
14967
|
const generalMatch = string.match(protocolAndDomainRE);
|
|
14431
14968
|
const emailLinkMatch = string.match(emailLintRE);
|
|
14432
14969
|
const localUrlMatch = string.match(localUrlRE);
|
|
@@ -14448,12 +14985,12 @@ const isUrl = (string) => {
|
|
|
14448
14985
|
}
|
|
14449
14986
|
return localhostDomainRE.test(everythingAfterProtocol) || nonLocalhostDomainRE.test(everythingAfterProtocol);
|
|
14450
14987
|
};
|
|
14451
|
-
const RichEditor = (
|
|
14988
|
+
const RichEditor = ({ input, tinaForm, field }) => {
|
|
14452
14989
|
var _a;
|
|
14453
14990
|
const initialValue = React__default.useMemo(
|
|
14454
14991
|
() => {
|
|
14455
14992
|
var _a2, _b;
|
|
14456
|
-
return ((_b = (_a2 =
|
|
14993
|
+
return ((_b = (_a2 = input.value) == null ? void 0 : _a2.children) == null ? void 0 : _b.length) ? input.value.children.map(helpers.normalize) : [{ type: "p", children: [{ type: "text", text: "" }] }];
|
|
14457
14994
|
},
|
|
14458
14995
|
[]
|
|
14459
14996
|
);
|
|
@@ -14465,6 +15002,7 @@ const RichEditor = (props) => {
|
|
|
14465
15002
|
createMdxBlockPlugin(),
|
|
14466
15003
|
createMdxInlinePlugin(),
|
|
14467
15004
|
createImgPlugin(),
|
|
15005
|
+
createMermaidPlugin(),
|
|
14468
15006
|
createInvalidMarkdownPlugin(),
|
|
14469
15007
|
createLinkPlugin({
|
|
14470
15008
|
options: {
|
|
@@ -14480,7 +15018,7 @@ const RichEditor = (props) => {
|
|
|
14480
15018
|
),
|
|
14481
15019
|
[]
|
|
14482
15020
|
);
|
|
14483
|
-
const tempId = [
|
|
15021
|
+
const tempId = [tinaForm.id, input.name].join(".");
|
|
14484
15022
|
const id = React__default.useMemo(() => uuid() + tempId, [tempId]);
|
|
14485
15023
|
const ref = React__default.useRef(null);
|
|
14486
15024
|
React__default.useEffect(() => {
|
|
@@ -14490,13 +15028,13 @@ const RichEditor = (props) => {
|
|
|
14490
15028
|
const plateElement = (_a2 = ref.current) == null ? void 0 : _a2.querySelector(
|
|
14491
15029
|
'[role="textbox"]'
|
|
14492
15030
|
);
|
|
14493
|
-
if (
|
|
15031
|
+
if (field.experimental_focusIntent && plateElement) {
|
|
14494
15032
|
if (plateElement)
|
|
14495
15033
|
plateElement.focus();
|
|
14496
15034
|
}
|
|
14497
15035
|
}, 100);
|
|
14498
15036
|
}
|
|
14499
|
-
}, [
|
|
15037
|
+
}, [field.experimental_focusIntent, ref]);
|
|
14500
15038
|
return /* @__PURE__ */ React__default.createElement("div", { ref }, /* @__PURE__ */ React__default.createElement(
|
|
14501
15039
|
Plate,
|
|
14502
15040
|
{
|
|
@@ -14504,7 +15042,7 @@ const RichEditor = (props) => {
|
|
|
14504
15042
|
initialValue,
|
|
14505
15043
|
plugins: plugins$2,
|
|
14506
15044
|
onChange: (value) => {
|
|
14507
|
-
|
|
15045
|
+
input.onChange({
|
|
14508
15046
|
type: "root",
|
|
14509
15047
|
children: value
|
|
14510
15048
|
});
|
|
@@ -14513,12 +15051,12 @@ const RichEditor = (props) => {
|
|
|
14513
15051
|
/* @__PURE__ */ React__default.createElement(TooltipProvider, null, /* @__PURE__ */ React__default.createElement(
|
|
14514
15052
|
ToolbarProvider,
|
|
14515
15053
|
{
|
|
14516
|
-
tinaForm
|
|
14517
|
-
templates:
|
|
14518
|
-
overrides: (
|
|
15054
|
+
tinaForm,
|
|
15055
|
+
templates: field.templates,
|
|
15056
|
+
overrides: (field == null ? void 0 : field.toolbarOverride) ? field.toolbarOverride : field.overrides
|
|
14519
15057
|
},
|
|
14520
15058
|
/* @__PURE__ */ React__default.createElement(FixedToolbar, null, /* @__PURE__ */ React__default.createElement(FixedToolbarButtons, null)),
|
|
14521
|
-
/* @__PURE__ */ React__default.createElement(FloatingToolbar, null, /* @__PURE__ */ React__default.createElement(FloatingToolbarButtons, null))
|
|
15059
|
+
((_a = field == null ? void 0 : field.overrides) == null ? void 0 : _a.showFloatingToolbar) !== false ? /* @__PURE__ */ React__default.createElement(FloatingToolbar, null, /* @__PURE__ */ React__default.createElement(FloatingToolbarButtons, null)) : null
|
|
14522
15060
|
), /* @__PURE__ */ React__default.createElement(Editor, null))
|
|
14523
15061
|
));
|
|
14524
15062
|
};
|
|
@@ -29472,6 +30010,7 @@ class TinaAdminApi {
|
|
|
29472
30010
|
relativePath
|
|
29473
30011
|
filename
|
|
29474
30012
|
extension
|
|
30013
|
+
hasReferences
|
|
29475
30014
|
}
|
|
29476
30015
|
}
|
|
29477
30016
|
}
|
|
@@ -29563,6 +30102,9 @@ class TinaAdminApi {
|
|
|
29563
30102
|
document(collection:$collection, relativePath:$relativePath) {
|
|
29564
30103
|
... on Document {
|
|
29565
30104
|
_values
|
|
30105
|
+
_sys {
|
|
30106
|
+
hasReferences
|
|
30107
|
+
}
|
|
29566
30108
|
}
|
|
29567
30109
|
}
|
|
29568
30110
|
}`;
|
|
@@ -31289,6 +31831,23 @@ const CollectionListPage = () => {
|
|
|
31289
31831
|
DeleteModal,
|
|
31290
31832
|
{
|
|
31291
31833
|
filename: vars.relativePath,
|
|
31834
|
+
checkRefsFunc: async () => {
|
|
31835
|
+
var _a2, _b2;
|
|
31836
|
+
try {
|
|
31837
|
+
const doc = await admin.fetchDocument(
|
|
31838
|
+
collection.name,
|
|
31839
|
+
vars.relativePath,
|
|
31840
|
+
true
|
|
31841
|
+
);
|
|
31842
|
+
return (_b2 = (_a2 = doc == null ? void 0 : doc.document) == null ? void 0 : _a2._sys) == null ? void 0 : _b2.hasReferences;
|
|
31843
|
+
} catch (error) {
|
|
31844
|
+
cms.alerts.error(
|
|
31845
|
+
"Document was not found, ask a developer for help or check the console for an error message"
|
|
31846
|
+
);
|
|
31847
|
+
console.error(error);
|
|
31848
|
+
throw error;
|
|
31849
|
+
}
|
|
31850
|
+
},
|
|
31292
31851
|
deleteFunc: async () => {
|
|
31293
31852
|
try {
|
|
31294
31853
|
await admin.deleteDocument(vars);
|
|
@@ -31297,6 +31856,12 @@ const CollectionListPage = () => {
|
|
|
31297
31856
|
);
|
|
31298
31857
|
reFetchCollection();
|
|
31299
31858
|
} catch (error) {
|
|
31859
|
+
if (error.message.indexOf("has references")) {
|
|
31860
|
+
cms.alerts.error(
|
|
31861
|
+
error.message.split("\n ").filter(Boolean)[1]
|
|
31862
|
+
);
|
|
31863
|
+
return;
|
|
31864
|
+
}
|
|
31300
31865
|
cms.alerts.warn(
|
|
31301
31866
|
"Document was not deleted, ask a developer for help or check the console for an error message"
|
|
31302
31867
|
);
|
|
@@ -31348,6 +31913,12 @@ const CollectionListPage = () => {
|
|
|
31348
31913
|
cms.alerts.info("Document was successfully renamed");
|
|
31349
31914
|
reFetchCollection();
|
|
31350
31915
|
} catch (error) {
|
|
31916
|
+
if (error.message.indexOf("has references")) {
|
|
31917
|
+
cms.alerts.error(
|
|
31918
|
+
error.message.split("\n ").filter(Boolean)[1]
|
|
31919
|
+
);
|
|
31920
|
+
return;
|
|
31921
|
+
}
|
|
31351
31922
|
cms.alerts.warn(
|
|
31352
31923
|
"Document was not renamed, ask a developer for help or check the console for an error message"
|
|
31353
31924
|
);
|
|
@@ -31821,8 +32392,19 @@ const Breadcrumb = ({ folder, navigate, collectionName }) => {
|
|
|
31821
32392
|
const NoDocumentsPlaceholder = () => {
|
|
31822
32393
|
return /* @__PURE__ */ React__default.createElement("div", { className: "text-center px-5 py-3 flex flex-col items-center justify-center shadow border border-gray-100 bg-gray-50 border-b border-gray-200 w-full max-w-full rounded-lg" }, /* @__PURE__ */ React__default.createElement("p", { className: "text-base italic font-medium text-gray-300" }, "No documents found."));
|
|
31823
32394
|
};
|
|
31824
|
-
const DeleteModal = ({
|
|
31825
|
-
|
|
32395
|
+
const DeleteModal = ({
|
|
32396
|
+
close: close2,
|
|
32397
|
+
deleteFunc,
|
|
32398
|
+
checkRefsFunc,
|
|
32399
|
+
filename
|
|
32400
|
+
}) => {
|
|
32401
|
+
const [hasRefs, setHasRefs] = React__default.useState();
|
|
32402
|
+
useEffect(() => {
|
|
32403
|
+
checkRefsFunc().then((result) => {
|
|
32404
|
+
setHasRefs(result);
|
|
32405
|
+
});
|
|
32406
|
+
}, [filename, checkRefsFunc]);
|
|
32407
|
+
return /* @__PURE__ */ React__default.createElement(Modal, null, /* @__PURE__ */ React__default.createElement(PopupModal, null, /* @__PURE__ */ React__default.createElement(ModalHeader, { close: close2 }, "Delete ", filename), /* @__PURE__ */ React__default.createElement(ModalBody, { padded: true }, /* @__PURE__ */ React__default.createElement("p", null, `Are you sure you want to delete ${filename}?${hasRefs ? " References to this document will also be deleted." : ""}`)), /* @__PURE__ */ React__default.createElement(ModalActions, null, /* @__PURE__ */ React__default.createElement(Button$1, { style: { flexGrow: 2 }, onClick: close2 }, "Cancel"), /* @__PURE__ */ React__default.createElement(
|
|
31826
32408
|
Button$1,
|
|
31827
32409
|
{
|
|
31828
32410
|
style: { flexGrow: 3 },
|
|
@@ -32554,15 +33136,24 @@ const IndexingPage = () => {
|
|
|
32554
33136
|
}
|
|
32555
33137
|
}
|
|
32556
33138
|
if (state === "creatingPR") {
|
|
32557
|
-
|
|
32558
|
-
|
|
32559
|
-
|
|
32560
|
-
|
|
32561
|
-
|
|
32562
|
-
|
|
32563
|
-
|
|
32564
|
-
|
|
32565
|
-
|
|
33139
|
+
try {
|
|
33140
|
+
const foo = await tinaApi.createPullRequest({
|
|
33141
|
+
baseBranch,
|
|
33142
|
+
branch,
|
|
33143
|
+
title: `${branch.replace("tina/", "").replace("-", " ")} (PR from TinaCMS)`
|
|
33144
|
+
});
|
|
33145
|
+
console.log("PR created", foo);
|
|
33146
|
+
cms.alerts.success("Pull request created.");
|
|
33147
|
+
localStorage.setItem("tina.createBranchState", "done");
|
|
33148
|
+
setState("done");
|
|
33149
|
+
} catch (e) {
|
|
33150
|
+
console.error(e);
|
|
33151
|
+
cms.alerts.error("Failed to create PR");
|
|
33152
|
+
setErrorMessage(
|
|
33153
|
+
"Failed to create PR, please try again. If the problem persists please contact support."
|
|
33154
|
+
);
|
|
33155
|
+
setState("error");
|
|
33156
|
+
}
|
|
32566
33157
|
}
|
|
32567
33158
|
if (state === "done") {
|
|
32568
33159
|
window.location.href = back;
|
|
@@ -33184,5 +33775,6 @@ export {
|
|
|
33184
33775
|
useScreenPlugin,
|
|
33185
33776
|
useTinaAuthRedirect,
|
|
33186
33777
|
wrapFieldWithError,
|
|
33778
|
+
wrapFieldWithNoHeader,
|
|
33187
33779
|
wrapFieldsWithMeta
|
|
33188
33780
|
};
|