tinacms 0.0.0-fe63759-20241004045825 → 0.0.0-feaa40f-20241112045116
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/admin/types.d.ts +3 -0
- package/dist/cache/node-cache.d.ts +1 -0
- package/dist/client.js +18 -16
- package/dist/client.mjs +1 -1
- package/dist/index.js +1476 -773
- package/dist/index.mjs +1457 -750
- package/dist/{node-cache-7fa2452c.mjs → node-cache-4c336858.mjs} +18 -11
- package/dist/rich-text/index.d.ts +3 -0
- package/dist/rich-text/index.js +45 -12
- package/dist/rich-text/index.mjs +45 -12
- 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/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 +7 -3
- package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/toolbar/toolbar-provider.d.ts +1 -1
- package/dist/toolkit/fields/plugins/wrap-field-with-meta.d.ts +8 -0
- package/package.json +9 -7
- package/dist/__vite-browser-external-d06ac358.mjs +0 -4
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,
|
|
9
|
+
import React__default, { useState, useCallback, useEffect, useRef, createContext, forwardRef, useContext, useMemo, startTransition, createElement, Component } from "react";
|
|
10
10
|
import { createPortal, findDOMNode } from "react-dom";
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
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, 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$1, 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(
|
|
@@ -873,9 +893,9 @@ const FieldDescription = ({
|
|
|
873
893
|
"span",
|
|
874
894
|
{
|
|
875
895
|
className: `block font-sans text-xs italic font-light text-gray-400 pt-0.5 whitespace-normal m-0 ${className}`,
|
|
876
|
-
...props
|
|
877
|
-
|
|
878
|
-
|
|
896
|
+
...props,
|
|
897
|
+
dangerouslySetInnerHTML: { __html: children }
|
|
898
|
+
}
|
|
879
899
|
);
|
|
880
900
|
};
|
|
881
901
|
const FieldError = ({
|
|
@@ -905,6 +925,20 @@ const useEditorContext = () => {
|
|
|
905
925
|
const useTemplates = () => {
|
|
906
926
|
return React__default.useContext(EditorContext);
|
|
907
927
|
};
|
|
928
|
+
const BlockquoteElement = withRef(
|
|
929
|
+
({ children, className, ...props }, ref) => {
|
|
930
|
+
return /* @__PURE__ */ React__default.createElement(
|
|
931
|
+
PlateElement,
|
|
932
|
+
{
|
|
933
|
+
asChild: true,
|
|
934
|
+
className: cn$1("my-1 border-l-2 pl-6 italic", className),
|
|
935
|
+
ref,
|
|
936
|
+
...props
|
|
937
|
+
},
|
|
938
|
+
/* @__PURE__ */ React__default.createElement("blockquote", null, children)
|
|
939
|
+
);
|
|
940
|
+
}
|
|
941
|
+
);
|
|
908
942
|
function classNames$1(...classes) {
|
|
909
943
|
return classes.filter(Boolean).join(" ");
|
|
910
944
|
}
|
|
@@ -914,6 +948,503 @@ const uuid = () => {
|
|
|
914
948
|
(c) => (c ^ crypto.getRandomValues(new Uint8Array(1))[0] & 15 >> c / 4).toString(16)
|
|
915
949
|
);
|
|
916
950
|
};
|
|
951
|
+
function ChevronDownIcon(props, svgRef) {
|
|
952
|
+
return /* @__PURE__ */ React.createElement("svg", Object.assign({
|
|
953
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
954
|
+
viewBox: "0 0 20 20",
|
|
955
|
+
fill: "currentColor",
|
|
956
|
+
"aria-hidden": "true",
|
|
957
|
+
ref: svgRef
|
|
958
|
+
}, props), /* @__PURE__ */ React.createElement("path", {
|
|
959
|
+
fillRule: "evenodd",
|
|
960
|
+
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",
|
|
961
|
+
clipRule: "evenodd"
|
|
962
|
+
}));
|
|
963
|
+
}
|
|
964
|
+
const ForwardRef = React.forwardRef(ChevronDownIcon);
|
|
965
|
+
const ChevronDownIcon$1 = ForwardRef;
|
|
966
|
+
const Autocomplete = ({
|
|
967
|
+
value,
|
|
968
|
+
onChange,
|
|
969
|
+
defaultQuery,
|
|
970
|
+
items: items2
|
|
971
|
+
}) => {
|
|
972
|
+
const [query, setQuery] = React__default.useState(defaultQuery ?? "");
|
|
973
|
+
const filteredItems = React__default.useMemo(() => {
|
|
974
|
+
try {
|
|
975
|
+
const reFilter = new RegExp(query, "i");
|
|
976
|
+
const _items = items2.filter((item) => reFilter.test(item.label));
|
|
977
|
+
if (_items.length === 0)
|
|
978
|
+
return items2;
|
|
979
|
+
return _items;
|
|
980
|
+
} catch (err) {
|
|
981
|
+
return items2;
|
|
982
|
+
}
|
|
983
|
+
}, [items2, query]);
|
|
984
|
+
return /* @__PURE__ */ React__default.createElement(
|
|
985
|
+
Combobox,
|
|
986
|
+
{
|
|
987
|
+
value,
|
|
988
|
+
onChange,
|
|
989
|
+
as: "div",
|
|
990
|
+
className: "relative inline-block text-left z-20"
|
|
991
|
+
},
|
|
992
|
+
/* @__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(
|
|
993
|
+
ComboboxInput,
|
|
994
|
+
{
|
|
995
|
+
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",
|
|
996
|
+
displayValue: (item) => (item == null ? void 0 : item.label) ?? "Plain Text",
|
|
997
|
+
onChange: (event) => setQuery(event.target.value),
|
|
998
|
+
onClick: (ev) => ev.stopPropagation()
|
|
999
|
+
}
|
|
1000
|
+
), /* @__PURE__ */ React__default.createElement(ComboboxButton, { className: "absolute inset-y-0 right-0 flex items-center pr-2" }, /* @__PURE__ */ React__default.createElement(
|
|
1001
|
+
ChevronDownIcon$1,
|
|
1002
|
+
{
|
|
1003
|
+
className: "h-5 w-5 text-gray-400",
|
|
1004
|
+
"aria-hidden": "true"
|
|
1005
|
+
}
|
|
1006
|
+
)))),
|
|
1007
|
+
/* @__PURE__ */ React__default.createElement(
|
|
1008
|
+
Transition,
|
|
1009
|
+
{
|
|
1010
|
+
enter: "transition ease-out duration-100",
|
|
1011
|
+
enterFrom: "transform opacity-0 scale-95",
|
|
1012
|
+
enterTo: "transform opacity-100 scale-100",
|
|
1013
|
+
leave: "transition ease-in duration-75",
|
|
1014
|
+
leaveFrom: "transform opacity-100 scale-100",
|
|
1015
|
+
leaveTo: "transform opacity-0 scale-95"
|
|
1016
|
+
},
|
|
1017
|
+
/* @__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(
|
|
1018
|
+
"button",
|
|
1019
|
+
{
|
|
1020
|
+
className: classNames$1(
|
|
1021
|
+
focus ? "bg-gray-100 text-gray-900" : "text-gray-700",
|
|
1022
|
+
"block px-4 py-2 text-xs w-full text-right"
|
|
1023
|
+
)
|
|
1024
|
+
},
|
|
1025
|
+
item.render(item)
|
|
1026
|
+
))))
|
|
1027
|
+
)
|
|
1028
|
+
);
|
|
1029
|
+
};
|
|
1030
|
+
loader.config({
|
|
1031
|
+
paths: { vs: "https://cdn.jsdelivr.net/npm/monaco-editor@0.31.1/min/vs" }
|
|
1032
|
+
});
|
|
1033
|
+
let retryCount = 0;
|
|
1034
|
+
const retryFocus = (ref) => {
|
|
1035
|
+
if (ref.current) {
|
|
1036
|
+
ref.current.focus();
|
|
1037
|
+
} else {
|
|
1038
|
+
if (retryCount < 30) {
|
|
1039
|
+
setTimeout(() => {
|
|
1040
|
+
retryCount = retryCount + 1;
|
|
1041
|
+
retryFocus(ref);
|
|
1042
|
+
}, 100);
|
|
1043
|
+
}
|
|
1044
|
+
}
|
|
1045
|
+
};
|
|
1046
|
+
const MINIMUM_HEIGHT = 75;
|
|
1047
|
+
const CodeBlock = ({
|
|
1048
|
+
attributes,
|
|
1049
|
+
editor,
|
|
1050
|
+
element,
|
|
1051
|
+
language: restrictLanguage,
|
|
1052
|
+
onChangeCallback,
|
|
1053
|
+
defaultValue,
|
|
1054
|
+
...props
|
|
1055
|
+
}) => {
|
|
1056
|
+
const [navigateAway, setNavigateAway] = React__default.useState(null);
|
|
1057
|
+
const monaco = useMonaco();
|
|
1058
|
+
const monacoEditorRef = React__default.useRef(null);
|
|
1059
|
+
const selected = useSelected();
|
|
1060
|
+
const [height, setHeight] = React__default.useState(MINIMUM_HEIGHT);
|
|
1061
|
+
React__default.useEffect(() => {
|
|
1062
|
+
if (selected && isCollapsed(editor.selection)) {
|
|
1063
|
+
retryFocus(monacoEditorRef);
|
|
1064
|
+
}
|
|
1065
|
+
}, [selected, monacoEditorRef.current]);
|
|
1066
|
+
const value = element.value || "";
|
|
1067
|
+
if (typeof value !== "string") {
|
|
1068
|
+
throw new Error("Element must be of type string for code block");
|
|
1069
|
+
}
|
|
1070
|
+
const language = restrictLanguage || element.lang;
|
|
1071
|
+
const id = React__default.useMemo(() => uuid(), []);
|
|
1072
|
+
const languages = React__default.useMemo(() => {
|
|
1073
|
+
const defaultLangSet = { "": "plain text" };
|
|
1074
|
+
if (!monaco)
|
|
1075
|
+
return defaultLangSet;
|
|
1076
|
+
return monaco.languages.getLanguages().reduce((ac, cv) => {
|
|
1077
|
+
if (cv.id === "plaintext")
|
|
1078
|
+
return ac;
|
|
1079
|
+
return { ...ac, [cv.id]: cv.id };
|
|
1080
|
+
}, defaultLangSet);
|
|
1081
|
+
}, [monaco]);
|
|
1082
|
+
React__default.useEffect(() => {
|
|
1083
|
+
if (monaco) {
|
|
1084
|
+
monaco.languages.typescript.typescriptDefaults.setEagerModelSync(true);
|
|
1085
|
+
monaco.languages.typescript.typescriptDefaults.setDiagnosticsOptions({
|
|
1086
|
+
// disable errors
|
|
1087
|
+
noSemanticValidation: true,
|
|
1088
|
+
noSyntaxValidation: true
|
|
1089
|
+
});
|
|
1090
|
+
}
|
|
1091
|
+
}, [monaco]);
|
|
1092
|
+
const items2 = Object.entries(languages).map(([key, label]) => ({
|
|
1093
|
+
key,
|
|
1094
|
+
label,
|
|
1095
|
+
render: (item) => item.label
|
|
1096
|
+
}));
|
|
1097
|
+
const currentItem = React__default.useMemo(() => {
|
|
1098
|
+
return items2.find((item) => item.key === language) ?? {
|
|
1099
|
+
key: "",
|
|
1100
|
+
label: "Plain Text"
|
|
1101
|
+
};
|
|
1102
|
+
}, [items2, language]);
|
|
1103
|
+
React__default.useEffect(() => {
|
|
1104
|
+
if (navigateAway) {
|
|
1105
|
+
setNavigateAway(null);
|
|
1106
|
+
switch (navigateAway) {
|
|
1107
|
+
case "remove":
|
|
1108
|
+
{
|
|
1109
|
+
focusEditor(editor);
|
|
1110
|
+
setNodes(
|
|
1111
|
+
editor,
|
|
1112
|
+
{
|
|
1113
|
+
type: "p",
|
|
1114
|
+
children: [{ text: "" }],
|
|
1115
|
+
lang: void 0,
|
|
1116
|
+
value: void 0
|
|
1117
|
+
},
|
|
1118
|
+
{
|
|
1119
|
+
match: (n) => {
|
|
1120
|
+
if (isElement(n) && n.type === element.type) {
|
|
1121
|
+
return true;
|
|
1122
|
+
}
|
|
1123
|
+
}
|
|
1124
|
+
}
|
|
1125
|
+
);
|
|
1126
|
+
}
|
|
1127
|
+
break;
|
|
1128
|
+
case "insertNext":
|
|
1129
|
+
{
|
|
1130
|
+
insertNodes(
|
|
1131
|
+
editor,
|
|
1132
|
+
[
|
|
1133
|
+
{
|
|
1134
|
+
type: ELEMENT_DEFAULT,
|
|
1135
|
+
children: [{ text: "" }],
|
|
1136
|
+
lang: void 0,
|
|
1137
|
+
value: void 0
|
|
1138
|
+
}
|
|
1139
|
+
],
|
|
1140
|
+
{ select: true }
|
|
1141
|
+
);
|
|
1142
|
+
focusEditor(editor);
|
|
1143
|
+
}
|
|
1144
|
+
break;
|
|
1145
|
+
case "up":
|
|
1146
|
+
{
|
|
1147
|
+
const path = findNodePath(editor, element);
|
|
1148
|
+
if (!path) {
|
|
1149
|
+
return;
|
|
1150
|
+
}
|
|
1151
|
+
const previousNodePath = getPointBefore(editor, path);
|
|
1152
|
+
if (!previousNodePath) {
|
|
1153
|
+
focusEditor(editor);
|
|
1154
|
+
insertNodes(
|
|
1155
|
+
editor,
|
|
1156
|
+
[
|
|
1157
|
+
{
|
|
1158
|
+
type: ELEMENT_DEFAULT,
|
|
1159
|
+
children: [{ text: "" }],
|
|
1160
|
+
lang: void 0,
|
|
1161
|
+
value: void 0
|
|
1162
|
+
}
|
|
1163
|
+
],
|
|
1164
|
+
// Insert a new node at the current path, resulting in the code_block
|
|
1165
|
+
// moving down one block
|
|
1166
|
+
{ at: path, select: true }
|
|
1167
|
+
);
|
|
1168
|
+
return;
|
|
1169
|
+
}
|
|
1170
|
+
focusEditor(editor, previousNodePath);
|
|
1171
|
+
}
|
|
1172
|
+
break;
|
|
1173
|
+
case "down": {
|
|
1174
|
+
const path = findNodePath(editor, element);
|
|
1175
|
+
if (!path) {
|
|
1176
|
+
return;
|
|
1177
|
+
}
|
|
1178
|
+
const nextNodePath = getPointAfter(editor, path);
|
|
1179
|
+
if (!nextNodePath) {
|
|
1180
|
+
insertNodes(
|
|
1181
|
+
editor,
|
|
1182
|
+
[
|
|
1183
|
+
{
|
|
1184
|
+
type: ELEMENT_DEFAULT,
|
|
1185
|
+
children: [{ text: "" }],
|
|
1186
|
+
lang: void 0,
|
|
1187
|
+
value: void 0
|
|
1188
|
+
}
|
|
1189
|
+
],
|
|
1190
|
+
{ select: true }
|
|
1191
|
+
);
|
|
1192
|
+
focusEditor(editor);
|
|
1193
|
+
} else {
|
|
1194
|
+
focusEditor(editor, nextNodePath);
|
|
1195
|
+
}
|
|
1196
|
+
break;
|
|
1197
|
+
}
|
|
1198
|
+
}
|
|
1199
|
+
}
|
|
1200
|
+
}, [navigateAway]);
|
|
1201
|
+
function handleEditorDidMount(monacoEditor, monaco2) {
|
|
1202
|
+
monacoEditorRef.current = monacoEditor;
|
|
1203
|
+
monacoEditor.onDidContentSizeChange(() => {
|
|
1204
|
+
setHeight(
|
|
1205
|
+
monacoEditor.getContentHeight() > MINIMUM_HEIGHT ? monacoEditor.getContentHeight() : MINIMUM_HEIGHT
|
|
1206
|
+
);
|
|
1207
|
+
monacoEditor.layout();
|
|
1208
|
+
});
|
|
1209
|
+
setNodes(editor, { value: defaultValue, lang: language });
|
|
1210
|
+
monacoEditor.addCommand(monaco2.KeyMod.Shift | monaco2.KeyCode.Enter, () => {
|
|
1211
|
+
if (monacoEditor.hasTextFocus()) {
|
|
1212
|
+
setNavigateAway("insertNext");
|
|
1213
|
+
}
|
|
1214
|
+
});
|
|
1215
|
+
monacoEditor.onKeyDown((l) => {
|
|
1216
|
+
if (l.code === "ArrowUp") {
|
|
1217
|
+
const selection = monacoEditor.getSelection();
|
|
1218
|
+
if (selection.endLineNumber === 1 && selection.startLineNumber === 1) {
|
|
1219
|
+
setNavigateAway("up");
|
|
1220
|
+
}
|
|
1221
|
+
}
|
|
1222
|
+
if (l.code === "ArrowDown") {
|
|
1223
|
+
const selection = monacoEditor.getSelection();
|
|
1224
|
+
const totalLines = monacoEditor.getModel().getLineCount();
|
|
1225
|
+
if (selection.endLineNumber === totalLines && selection.startLineNumber === totalLines) {
|
|
1226
|
+
setNavigateAway("down");
|
|
1227
|
+
}
|
|
1228
|
+
}
|
|
1229
|
+
if (l.code === "Backspace") {
|
|
1230
|
+
const selection = monacoEditor.getSelection();
|
|
1231
|
+
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) {
|
|
1232
|
+
setNavigateAway("remove");
|
|
1233
|
+
}
|
|
1234
|
+
}
|
|
1235
|
+
});
|
|
1236
|
+
}
|
|
1237
|
+
return /* @__PURE__ */ React__default.createElement(
|
|
1238
|
+
"div",
|
|
1239
|
+
{
|
|
1240
|
+
...attributes,
|
|
1241
|
+
className: "relative mb-2 mt-0.5 rounded-lg shadow-md p-2 border-gray-200 border"
|
|
1242
|
+
},
|
|
1243
|
+
/* @__PURE__ */ React__default.createElement("style", null, `.monaco-editor .editor-widget {
|
|
1244
|
+
display: none !important;
|
|
1245
|
+
visibility: hidden !important;
|
|
1246
|
+
}`),
|
|
1247
|
+
props.children,
|
|
1248
|
+
/* @__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(
|
|
1249
|
+
Autocomplete,
|
|
1250
|
+
{
|
|
1251
|
+
items: items2,
|
|
1252
|
+
value: currentItem,
|
|
1253
|
+
defaultQuery: "plaintext",
|
|
1254
|
+
onChange: (item) => setNodes(editor, { lang: item.key })
|
|
1255
|
+
}
|
|
1256
|
+
)), /* @__PURE__ */ React__default.createElement("div", { style: { height: `${height}px` } }, /* @__PURE__ */ React__default.createElement(
|
|
1257
|
+
MonacoEditor,
|
|
1258
|
+
{
|
|
1259
|
+
path: id,
|
|
1260
|
+
onMount: handleEditorDidMount,
|
|
1261
|
+
options: {
|
|
1262
|
+
scrollBeyondLastLine: false,
|
|
1263
|
+
// automaticLayout: true,
|
|
1264
|
+
tabSize: 2,
|
|
1265
|
+
disableLayerHinting: true,
|
|
1266
|
+
accessibilitySupport: "off",
|
|
1267
|
+
codeLens: false,
|
|
1268
|
+
wordWrap: "on",
|
|
1269
|
+
minimap: {
|
|
1270
|
+
enabled: false
|
|
1271
|
+
},
|
|
1272
|
+
fontSize: 14,
|
|
1273
|
+
lineHeight: 2,
|
|
1274
|
+
formatOnPaste: true,
|
|
1275
|
+
lineNumbers: "off",
|
|
1276
|
+
formatOnType: true,
|
|
1277
|
+
fixedOverflowWidgets: true,
|
|
1278
|
+
// Takes too much horizontal space for iframe
|
|
1279
|
+
folding: false,
|
|
1280
|
+
renderLineHighlight: "none",
|
|
1281
|
+
scrollbar: {
|
|
1282
|
+
verticalScrollbarSize: 1,
|
|
1283
|
+
horizontalScrollbarSize: 1,
|
|
1284
|
+
// https://github.com/microsoft/monaco-editor/issues/2007#issuecomment-644425664
|
|
1285
|
+
alwaysConsumeMouseWheel: false
|
|
1286
|
+
}
|
|
1287
|
+
},
|
|
1288
|
+
language: String(language),
|
|
1289
|
+
value: String(element.value),
|
|
1290
|
+
onChange: (value2) => {
|
|
1291
|
+
onChangeCallback == null ? void 0 : onChangeCallback(value2);
|
|
1292
|
+
setNodes(editor, { value: value2, lang: language });
|
|
1293
|
+
}
|
|
1294
|
+
}
|
|
1295
|
+
)))
|
|
1296
|
+
);
|
|
1297
|
+
};
|
|
1298
|
+
const CodeBlockElement = withRef(
|
|
1299
|
+
({ className, ...props }, ref) => {
|
|
1300
|
+
const { element } = props;
|
|
1301
|
+
const state = useCodeBlockElementState({ element });
|
|
1302
|
+
return /* @__PURE__ */ React__default.createElement(
|
|
1303
|
+
PlateElement,
|
|
1304
|
+
{
|
|
1305
|
+
className: cn$1("relative py-1", state.className, className),
|
|
1306
|
+
ref,
|
|
1307
|
+
...props
|
|
1308
|
+
},
|
|
1309
|
+
/* @__PURE__ */ React__default.createElement(CodeBlock, { ...props })
|
|
1310
|
+
);
|
|
1311
|
+
}
|
|
1312
|
+
);
|
|
1313
|
+
const CodeLeaf = withRef(
|
|
1314
|
+
({ children, className, ...props }, ref) => {
|
|
1315
|
+
return /* @__PURE__ */ React__default.createElement(
|
|
1316
|
+
PlateLeaf,
|
|
1317
|
+
{
|
|
1318
|
+
asChild: true,
|
|
1319
|
+
className: cn$1(
|
|
1320
|
+
"whitespace-pre-wrap rounded-md bg-muted px-[0.3em] py-[0.2em] font-mono text-sm",
|
|
1321
|
+
className
|
|
1322
|
+
),
|
|
1323
|
+
ref,
|
|
1324
|
+
...props
|
|
1325
|
+
},
|
|
1326
|
+
/* @__PURE__ */ React__default.createElement("code", null, children)
|
|
1327
|
+
);
|
|
1328
|
+
}
|
|
1329
|
+
);
|
|
1330
|
+
const CodeLineElement = withRef((props, ref) => /* @__PURE__ */ React__default.createElement(PlateElement, { ref, ...props }));
|
|
1331
|
+
const CodeSyntaxLeaf = withRef(
|
|
1332
|
+
({ children, ...props }, ref) => {
|
|
1333
|
+
const { leaf } = props;
|
|
1334
|
+
const { tokenProps } = useCodeSyntaxLeaf({ leaf });
|
|
1335
|
+
return /* @__PURE__ */ React__default.createElement(PlateLeaf, { ref, ...props }, /* @__PURE__ */ React__default.createElement("span", { ...tokenProps }, children));
|
|
1336
|
+
}
|
|
1337
|
+
);
|
|
1338
|
+
const listVariants = cva("m-0 ps-6", {
|
|
1339
|
+
variants: {
|
|
1340
|
+
variant: {
|
|
1341
|
+
ol: "list-decimal",
|
|
1342
|
+
ul: "list-disc [&_ul]:list-[circle] [&_ul_ul]:list-[square]"
|
|
1343
|
+
}
|
|
1344
|
+
}
|
|
1345
|
+
});
|
|
1346
|
+
const ListElementVariants = withVariants(PlateElement, listVariants, [
|
|
1347
|
+
"variant"
|
|
1348
|
+
]);
|
|
1349
|
+
const ListElement = withRef(
|
|
1350
|
+
({ children, variant = "ul", ...props }, ref) => {
|
|
1351
|
+
const Component2 = variant;
|
|
1352
|
+
return /* @__PURE__ */ React__default.createElement(ListElementVariants, { asChild: true, ref, variant, ...props }, /* @__PURE__ */ React__default.createElement(Component2, null, children));
|
|
1353
|
+
}
|
|
1354
|
+
);
|
|
1355
|
+
const ELEMENT_MERMAID = "mermaid";
|
|
1356
|
+
const createMermaidPlugin = createPluginFactory({
|
|
1357
|
+
isElement: true,
|
|
1358
|
+
isVoid: true,
|
|
1359
|
+
isInline: false,
|
|
1360
|
+
key: ELEMENT_MERMAID
|
|
1361
|
+
});
|
|
1362
|
+
const MermaidElementWithRef = ({ config }) => {
|
|
1363
|
+
const mermaidRef = useRef(null);
|
|
1364
|
+
useEffect(() => {
|
|
1365
|
+
if (mermaidRef.current) {
|
|
1366
|
+
mermaid.initialize({ startOnLoad: true });
|
|
1367
|
+
mermaid.init();
|
|
1368
|
+
}
|
|
1369
|
+
}, [config]);
|
|
1370
|
+
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)));
|
|
1371
|
+
};
|
|
1372
|
+
const Bubble = ({ children }) => {
|
|
1373
|
+
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);
|
|
1374
|
+
};
|
|
1375
|
+
const ErrorMsg = ({ error }) => {
|
|
1376
|
+
if (error) {
|
|
1377
|
+
return /* @__PURE__ */ React__default.createElement(
|
|
1378
|
+
"div",
|
|
1379
|
+
{
|
|
1380
|
+
contentEditable: false,
|
|
1381
|
+
className: "font-mono bg-red-600 text-white p-2 rounded-md cursor-default"
|
|
1382
|
+
},
|
|
1383
|
+
error
|
|
1384
|
+
);
|
|
1385
|
+
}
|
|
1386
|
+
return null;
|
|
1387
|
+
};
|
|
1388
|
+
const DEFAULT_MERMAID_CONFIG = `%% This won't render without implementing a rendering engine (e.g. mermaid on npm)
|
|
1389
|
+
flowchart TD
|
|
1390
|
+
id1(this is an example flow diagram)
|
|
1391
|
+
--> id2(modify me to see changes!)
|
|
1392
|
+
id2
|
|
1393
|
+
--> id3(Click the top button to preview the changes)
|
|
1394
|
+
--> id4(Learn about mermaid diagrams - mermaid.js.org)`;
|
|
1395
|
+
const MermaidElement = withRef(
|
|
1396
|
+
({ children, nodeProps, element, ...props }, ref) => {
|
|
1397
|
+
const [mermaidConfig, setMermaidConfig] = useState(
|
|
1398
|
+
element.value || DEFAULT_MERMAID_CONFIG
|
|
1399
|
+
);
|
|
1400
|
+
const [isEditing, setIsEditing] = useState(
|
|
1401
|
+
mermaidConfig === DEFAULT_MERMAID_CONFIG || false
|
|
1402
|
+
);
|
|
1403
|
+
const [mermaidError, setMermaidError] = useState(null);
|
|
1404
|
+
const node = {
|
|
1405
|
+
type: ELEMENT_MERMAID,
|
|
1406
|
+
value: mermaidConfig,
|
|
1407
|
+
children: [{ type: "text", text: "" }]
|
|
1408
|
+
};
|
|
1409
|
+
useEffect(() => {
|
|
1410
|
+
if (mermaid.parse(mermaidConfig)) {
|
|
1411
|
+
setMermaidError(null);
|
|
1412
|
+
}
|
|
1413
|
+
}, [mermaidConfig]);
|
|
1414
|
+
mermaid.parseError = (err) => {
|
|
1415
|
+
setMermaidError(
|
|
1416
|
+
String(err.message) || "An error occurred while parsing the diagram."
|
|
1417
|
+
);
|
|
1418
|
+
};
|
|
1419
|
+
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(
|
|
1420
|
+
Eye,
|
|
1421
|
+
{
|
|
1422
|
+
className: "w-5 h-5 fill-white cursor-pointer",
|
|
1423
|
+
onClick: () => {
|
|
1424
|
+
setIsEditing(!isEditing);
|
|
1425
|
+
}
|
|
1426
|
+
}
|
|
1427
|
+
) : /* @__PURE__ */ React__default.createElement(
|
|
1428
|
+
SquarePen,
|
|
1429
|
+
{
|
|
1430
|
+
className: "w-5 h-5 fill-white cursor-pointer",
|
|
1431
|
+
onClick: () => {
|
|
1432
|
+
setIsEditing(!isEditing);
|
|
1433
|
+
}
|
|
1434
|
+
}
|
|
1435
|
+
))), isEditing ? /* @__PURE__ */ React__default.createElement(
|
|
1436
|
+
CodeBlock,
|
|
1437
|
+
{
|
|
1438
|
+
children: "",
|
|
1439
|
+
language: "yaml",
|
|
1440
|
+
...props,
|
|
1441
|
+
element: node,
|
|
1442
|
+
defaultValue: mermaidConfig,
|
|
1443
|
+
onChangeCallback: (value) => setMermaidConfig(value)
|
|
1444
|
+
}
|
|
1445
|
+
) : /* @__PURE__ */ React__default.createElement(MermaidElementWithRef, { config: mermaidConfig })), children, /* @__PURE__ */ React__default.createElement(ErrorMsg, { error: mermaidError }));
|
|
1446
|
+
}
|
|
1447
|
+
);
|
|
917
1448
|
const RawMarkdown = () => {
|
|
918
1449
|
return /* @__PURE__ */ React__default.createElement(
|
|
919
1450
|
"svg",
|
|
@@ -932,6 +1463,29 @@ const RawMarkdown = () => {
|
|
|
932
1463
|
/* @__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
1464
|
);
|
|
934
1465
|
};
|
|
1466
|
+
const MermaidIcon = () => /* @__PURE__ */ React__default.createElement(
|
|
1467
|
+
"svg",
|
|
1468
|
+
{
|
|
1469
|
+
width: "100%",
|
|
1470
|
+
height: "100%",
|
|
1471
|
+
viewBox: "0 0 491 491",
|
|
1472
|
+
version: "1.1",
|
|
1473
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
1474
|
+
fillRule: "evenodd",
|
|
1475
|
+
clipRule: "evenodd",
|
|
1476
|
+
strokeLinejoin: "round",
|
|
1477
|
+
strokeMiterlimit: 2
|
|
1478
|
+
},
|
|
1479
|
+
/* @__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" }),
|
|
1480
|
+
/* @__PURE__ */ React__default.createElement(
|
|
1481
|
+
"path",
|
|
1482
|
+
{
|
|
1483
|
+
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",
|
|
1484
|
+
fill: "white",
|
|
1485
|
+
fillRule: "nonzero"
|
|
1486
|
+
}
|
|
1487
|
+
)
|
|
1488
|
+
);
|
|
935
1489
|
const borderAll = (props) => /* @__PURE__ */ React__default.createElement(
|
|
936
1490
|
"svg",
|
|
937
1491
|
{
|
|
@@ -1016,7 +1570,7 @@ const borderTop = (props) => /* @__PURE__ */ React__default.createElement(
|
|
|
1016
1570
|
},
|
|
1017
1571
|
/* @__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
1572
|
);
|
|
1019
|
-
cva("", {
|
|
1573
|
+
const iconVariants = cva("", {
|
|
1020
1574
|
variants: {
|
|
1021
1575
|
variant: {
|
|
1022
1576
|
toolbar: "size-5",
|
|
@@ -1172,6 +1726,7 @@ const Icons = {
|
|
|
1172
1726
|
clear: X,
|
|
1173
1727
|
close: X,
|
|
1174
1728
|
// code: Code2,
|
|
1729
|
+
paint: PaintBucket,
|
|
1175
1730
|
codeblock: FileCode,
|
|
1176
1731
|
color: Baseline,
|
|
1177
1732
|
column: RectangleVertical,
|
|
@@ -1197,6 +1752,7 @@ const Icons = {
|
|
|
1197
1752
|
lineHeight: WrapText,
|
|
1198
1753
|
// link: Link2,
|
|
1199
1754
|
minus: Minus,
|
|
1755
|
+
mermaid: MermaidIcon,
|
|
1200
1756
|
more: MoreHorizontal,
|
|
1201
1757
|
// ol: ListOrdered,
|
|
1202
1758
|
outdent: Outdent,
|
|
@@ -1607,7 +2163,7 @@ const InlineComboboxInput = forwardRef(({ className, ...props }, propRef) => {
|
|
|
1607
2163
|
},
|
|
1608
2164
|
value || ""
|
|
1609
2165
|
), /* @__PURE__ */ React__default.createElement(
|
|
1610
|
-
Combobox,
|
|
2166
|
+
Combobox$1,
|
|
1611
2167
|
{
|
|
1612
2168
|
autoSelect: true,
|
|
1613
2169
|
className: cn$1(
|
|
@@ -1767,417 +2323,482 @@ const SlashInputElement = withRef(
|
|
|
1767
2323
|
);
|
|
1768
2324
|
}
|
|
1769
2325
|
);
|
|
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]);
|
|
2326
|
+
const TableCellElement = withRef(({ children, className, hideBorder, isHeader, style, ...props }, ref) => {
|
|
2327
|
+
var _a, _b, _c, _d;
|
|
2328
|
+
const { element } = props;
|
|
2329
|
+
const {
|
|
2330
|
+
borders,
|
|
2331
|
+
colIndex,
|
|
2332
|
+
colSpan,
|
|
2333
|
+
hovered,
|
|
2334
|
+
hoveredLeft,
|
|
2335
|
+
isSelectingCell,
|
|
2336
|
+
readOnly,
|
|
2337
|
+
rowIndex,
|
|
2338
|
+
rowSize,
|
|
2339
|
+
selected
|
|
2340
|
+
} = useTableCellElementState();
|
|
2341
|
+
const { props: cellProps } = useTableCellElement({ element: props.element });
|
|
2342
|
+
const resizableState = useTableCellElementResizableState({
|
|
2343
|
+
colIndex,
|
|
2344
|
+
colSpan,
|
|
2345
|
+
rowIndex
|
|
2346
|
+
});
|
|
2347
|
+
const { bottomProps, hiddenLeft, leftProps, rightProps } = useTableCellElementResizable(resizableState);
|
|
2348
|
+
const Cell = isHeader ? "th" : "td";
|
|
1859
2349
|
return /* @__PURE__ */ React__default.createElement(
|
|
1860
|
-
|
|
2350
|
+
PlateElement,
|
|
1861
2351
|
{
|
|
1862
|
-
|
|
1863
|
-
|
|
1864
|
-
|
|
1865
|
-
|
|
1866
|
-
|
|
1867
|
-
|
|
1868
|
-
|
|
1869
|
-
|
|
1870
|
-
|
|
1871
|
-
|
|
1872
|
-
|
|
1873
|
-
|
|
2352
|
+
asChild: true,
|
|
2353
|
+
className: cn$1(
|
|
2354
|
+
"relative h-full overflow-visible border-none bg-background p-0",
|
|
2355
|
+
hideBorder && "before:border-none",
|
|
2356
|
+
element.background ? "bg-[--cellBackground]" : "bg-background",
|
|
2357
|
+
!hideBorder && cn$1(
|
|
2358
|
+
isHeader && "text-left [&_>_*]:m-0",
|
|
2359
|
+
"before:size-full",
|
|
2360
|
+
selected && "before:z-10 before:bg-muted",
|
|
2361
|
+
"before:absolute before:box-border before:select-none before:content-['']",
|
|
2362
|
+
borders && cn$1(
|
|
2363
|
+
((_a = borders.bottom) == null ? void 0 : _a.size) && `before:border-b before:border-b-border`,
|
|
2364
|
+
((_b = borders.right) == null ? void 0 : _b.size) && `before:border-r before:border-r-border`,
|
|
2365
|
+
((_c = borders.left) == null ? void 0 : _c.size) && `before:border-l before:border-l-border`,
|
|
2366
|
+
((_d = borders.top) == null ? void 0 : _d.size) && `before:border-t before:border-t-border`
|
|
2367
|
+
)
|
|
2368
|
+
),
|
|
2369
|
+
className
|
|
2370
|
+
),
|
|
2371
|
+
ref,
|
|
2372
|
+
...cellProps,
|
|
2373
|
+
...props,
|
|
2374
|
+
style: {
|
|
2375
|
+
"--cellBackground": element.background,
|
|
2376
|
+
...style
|
|
1874
2377
|
}
|
|
1875
|
-
|
|
1876
|
-
|
|
2378
|
+
},
|
|
2379
|
+
/* @__PURE__ */ React__default.createElement(Cell, null, /* @__PURE__ */ React__default.createElement(
|
|
2380
|
+
"div",
|
|
1877
2381
|
{
|
|
1878
|
-
className: "h-
|
|
1879
|
-
|
|
1880
|
-
|
|
1881
|
-
|
|
1882
|
-
|
|
1883
|
-
|
|
2382
|
+
className: "relative z-20 box-border h-full px-3 py-2",
|
|
2383
|
+
style: {
|
|
2384
|
+
minHeight: rowSize
|
|
2385
|
+
}
|
|
2386
|
+
},
|
|
2387
|
+
children
|
|
2388
|
+
), !isSelectingCell && /* @__PURE__ */ React__default.createElement(
|
|
2389
|
+
"div",
|
|
1884
2390
|
{
|
|
1885
|
-
|
|
1886
|
-
|
|
1887
|
-
|
|
1888
|
-
leave: "transition ease-in duration-75",
|
|
1889
|
-
leaveFrom: "transform opacity-100 scale-100",
|
|
1890
|
-
leaveTo: "transform opacity-0 scale-95"
|
|
2391
|
+
className: "group absolute top-0 size-full select-none",
|
|
2392
|
+
contentEditable: false,
|
|
2393
|
+
suppressContentEditableWarning: true
|
|
1891
2394
|
},
|
|
1892
|
-
|
|
1893
|
-
|
|
2395
|
+
!readOnly && /* @__PURE__ */ React__default.createElement(React__default.Fragment, null, /* @__PURE__ */ React__default.createElement(
|
|
2396
|
+
ResizeHandle$1,
|
|
1894
2397
|
{
|
|
1895
|
-
|
|
1896
|
-
|
|
1897
|
-
|
|
2398
|
+
...rightProps,
|
|
2399
|
+
className: "-top-3 right-[-5px] w-[10px]"
|
|
2400
|
+
}
|
|
2401
|
+
), /* @__PURE__ */ React__default.createElement(
|
|
2402
|
+
ResizeHandle$1,
|
|
2403
|
+
{
|
|
2404
|
+
...bottomProps,
|
|
2405
|
+
className: "bottom-[-5px] h-[10px]"
|
|
2406
|
+
}
|
|
2407
|
+
), !hiddenLeft && /* @__PURE__ */ React__default.createElement(
|
|
2408
|
+
ResizeHandle$1,
|
|
2409
|
+
{
|
|
2410
|
+
...leftProps,
|
|
2411
|
+
className: "-top-3 left-[-5px] w-[10px]"
|
|
2412
|
+
}
|
|
2413
|
+
), hovered && /* @__PURE__ */ React__default.createElement(
|
|
2414
|
+
"div",
|
|
2415
|
+
{
|
|
2416
|
+
className: cn$1(
|
|
2417
|
+
"absolute -top-3 z-30 h-[calc(100%_+_12px)] w-1 bg-ring",
|
|
2418
|
+
"right-[-1.5px]"
|
|
1898
2419
|
)
|
|
1899
|
-
}
|
|
1900
|
-
|
|
1901
|
-
|
|
1902
|
-
|
|
2420
|
+
}
|
|
2421
|
+
), hoveredLeft && /* @__PURE__ */ React__default.createElement(
|
|
2422
|
+
"div",
|
|
2423
|
+
{
|
|
2424
|
+
className: cn$1(
|
|
2425
|
+
"absolute -top-3 z-30 h-[calc(100%_+_12px)] w-1 bg-ring",
|
|
2426
|
+
"left-[-1.5px]"
|
|
2427
|
+
)
|
|
2428
|
+
}
|
|
2429
|
+
))
|
|
2430
|
+
))
|
|
1903
2431
|
);
|
|
1904
|
-
};
|
|
1905
|
-
loader.config({
|
|
1906
|
-
paths: { vs: "https://cdn.jsdelivr.net/npm/monaco-editor@0.31.1/min/vs" }
|
|
1907
2432
|
});
|
|
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
|
-
|
|
2433
|
+
TableCellElement.displayName = "TableCellElement";
|
|
2434
|
+
const TableCellHeaderElement = withProps(TableCellElement, {
|
|
2435
|
+
isHeader: true
|
|
2436
|
+
});
|
|
2437
|
+
const buttonVariants$1 = cva(
|
|
2438
|
+
"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",
|
|
2439
|
+
{
|
|
2440
|
+
defaultVariants: {
|
|
2441
|
+
size: "default",
|
|
2442
|
+
variant: "default"
|
|
2443
|
+
},
|
|
2444
|
+
variants: {
|
|
2445
|
+
isMenu: {
|
|
2446
|
+
true: "h-auto w-full cursor-pointer justify-start"
|
|
2447
|
+
},
|
|
2448
|
+
size: {
|
|
2449
|
+
default: "h-10 px-4 py-2",
|
|
2450
|
+
icon: "size-10",
|
|
2451
|
+
lg: "h-11 rounded-md px-8",
|
|
2452
|
+
none: "",
|
|
2453
|
+
sm: "h-9 rounded-md px-3",
|
|
2454
|
+
sms: "size-9 rounded-md px-0",
|
|
2455
|
+
xs: "h-8 rounded-md px-3"
|
|
2456
|
+
},
|
|
2457
|
+
variant: {
|
|
2458
|
+
default: "bg-primary text-primary-foreground hover:bg-primary/90",
|
|
2459
|
+
destructive: "bg-destructive text-destructive-foreground hover:bg-destructive/90",
|
|
2460
|
+
ghost: "hover:bg-accent hover:text-accent-foreground",
|
|
2461
|
+
inlineLink: "text-base text-primary underline underline-offset-4",
|
|
2462
|
+
link: "text-primary underline-offset-4 hover:underline",
|
|
2463
|
+
outline: "border border-input bg-background hover:bg-accent hover:text-accent-foreground",
|
|
2464
|
+
secondary: "bg-secondary text-secondary-foreground hover:bg-secondary/80"
|
|
2465
|
+
}
|
|
1936
2466
|
}
|
|
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
2467
|
}
|
|
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
|
-
});
|
|
2468
|
+
);
|
|
2469
|
+
const Button$2 = withRef(({ asChild = false, className, isMenu, size, variant, ...props }, ref) => {
|
|
2470
|
+
const Comp = asChild ? Slot : "button";
|
|
2471
|
+
return /* @__PURE__ */ React.createElement(
|
|
2472
|
+
Comp,
|
|
2473
|
+
{
|
|
2474
|
+
className: cn$1(buttonVariants$1({ className, isMenu, size, variant })),
|
|
2475
|
+
ref,
|
|
2476
|
+
...props
|
|
1962
2477
|
}
|
|
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
|
-
}
|
|
2478
|
+
);
|
|
2479
|
+
});
|
|
2480
|
+
const DropdownMenu = DropdownMenuPrimitive.Root;
|
|
2481
|
+
const DropdownMenuTrigger = DropdownMenuPrimitive.Trigger;
|
|
2482
|
+
const DropdownMenuPortal = DropdownMenuPrimitive.Portal;
|
|
2483
|
+
const DropdownMenuSub = DropdownMenuPrimitive.Sub;
|
|
2484
|
+
const DropdownMenuRadioGroup = DropdownMenuPrimitive.RadioGroup;
|
|
2485
|
+
const DropdownMenuSubTrigger = withRef(({ children, className, inset, ...props }, ref) => /* @__PURE__ */ React__default.createElement(
|
|
2486
|
+
DropdownMenuPrimitive.SubTrigger,
|
|
2487
|
+
{
|
|
2488
|
+
className: cn$1(
|
|
2489
|
+
"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",
|
|
2490
|
+
"data-[disabled]:pointer-events-none data-[disabled]:opacity-50",
|
|
2491
|
+
inset && "pl-8",
|
|
2492
|
+
className
|
|
2493
|
+
),
|
|
2494
|
+
ref,
|
|
2495
|
+
...props
|
|
2496
|
+
},
|
|
2497
|
+
children,
|
|
2498
|
+
/* @__PURE__ */ React__default.createElement(Icons.chevronRight, { className: "ml-auto size-4" })
|
|
2499
|
+
));
|
|
2500
|
+
const DropdownMenuSubContent = withCn(
|
|
2501
|
+
DropdownMenuPrimitive.SubContent,
|
|
2502
|
+
"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"
|
|
2503
|
+
);
|
|
2504
|
+
const DropdownMenuContentVariants = withProps(DropdownMenuPrimitive.Content, {
|
|
2505
|
+
className: cn$1(
|
|
2506
|
+
"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"
|
|
2507
|
+
),
|
|
2508
|
+
sideOffset: 4
|
|
2509
|
+
});
|
|
2510
|
+
const DropdownMenuContent = withRef(({ ...props }, ref) => /* @__PURE__ */ React__default.createElement(DropdownMenuPrimitive.Portal, null, /* @__PURE__ */ React__default.createElement(DropdownMenuContentVariants, { ref, ...props })));
|
|
2511
|
+
const menuItemVariants = cva(
|
|
2512
|
+
cn$1(
|
|
2513
|
+
"relative flex h-9 cursor-pointer select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none transition-colors",
|
|
2514
|
+
"focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50"
|
|
2515
|
+
),
|
|
2516
|
+
{
|
|
2517
|
+
variants: {
|
|
2518
|
+
inset: {
|
|
2519
|
+
true: "pl-8"
|
|
2070
2520
|
}
|
|
2071
2521
|
}
|
|
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
|
-
|
|
2522
|
+
}
|
|
2523
|
+
);
|
|
2524
|
+
const DropdownMenuItem = withVariants(
|
|
2525
|
+
DropdownMenuPrimitive.Item,
|
|
2526
|
+
menuItemVariants,
|
|
2527
|
+
["inset"]
|
|
2528
|
+
);
|
|
2529
|
+
const DropdownMenuCheckboxItem = withRef(({ children, className, ...props }, ref) => /* @__PURE__ */ React__default.createElement(
|
|
2530
|
+
DropdownMenuPrimitive.CheckboxItem,
|
|
2531
|
+
{
|
|
2532
|
+
className: cn$1(
|
|
2533
|
+
"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",
|
|
2534
|
+
"cursor-pointer",
|
|
2535
|
+
className
|
|
2536
|
+
),
|
|
2537
|
+
ref,
|
|
2538
|
+
...props
|
|
2539
|
+
},
|
|
2540
|
+
/* @__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" }))),
|
|
2541
|
+
children
|
|
2542
|
+
));
|
|
2543
|
+
const DropdownMenuRadioItem = withRef(({ children, className, hideIcon, ...props }, ref) => /* @__PURE__ */ React__default.createElement(
|
|
2544
|
+
DropdownMenuPrimitive.RadioItem,
|
|
2545
|
+
{
|
|
2546
|
+
className: cn$1(
|
|
2547
|
+
"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",
|
|
2548
|
+
"h-9 cursor-pointer px-2 data-[state=checked]:bg-accent data-[state=checked]:text-accent-foreground",
|
|
2549
|
+
className
|
|
2550
|
+
),
|
|
2551
|
+
ref,
|
|
2552
|
+
...props
|
|
2553
|
+
},
|
|
2554
|
+
!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" }))),
|
|
2555
|
+
children
|
|
2556
|
+
));
|
|
2557
|
+
const dropdownMenuLabelVariants = cva(
|
|
2558
|
+
cn$1("select-none px-2 py-1.5 text-sm font-semibold"),
|
|
2559
|
+
{
|
|
2560
|
+
variants: {
|
|
2561
|
+
inset: {
|
|
2562
|
+
true: "pl-8"
|
|
2103
2563
|
}
|
|
2104
|
-
}
|
|
2564
|
+
}
|
|
2565
|
+
}
|
|
2566
|
+
);
|
|
2567
|
+
const DropdownMenuLabel = withVariants(
|
|
2568
|
+
DropdownMenuPrimitive.Label,
|
|
2569
|
+
dropdownMenuLabelVariants,
|
|
2570
|
+
["inset"]
|
|
2571
|
+
);
|
|
2572
|
+
const DropdownMenuSeparator = withCn(
|
|
2573
|
+
DropdownMenuPrimitive.Separator,
|
|
2574
|
+
"-mx-1 my-1 h-px bg-muted"
|
|
2575
|
+
);
|
|
2576
|
+
withCn(
|
|
2577
|
+
createPrimitiveElement("span"),
|
|
2578
|
+
"ml-auto text-xs tracking-widest opacity-60"
|
|
2579
|
+
);
|
|
2580
|
+
const useOpenState = () => {
|
|
2581
|
+
const [open2, setOpen] = useState(false);
|
|
2582
|
+
const onOpenChange = useCallback(
|
|
2583
|
+
(_value = !open2) => {
|
|
2584
|
+
setOpen(_value);
|
|
2585
|
+
},
|
|
2586
|
+
[open2]
|
|
2587
|
+
);
|
|
2588
|
+
return {
|
|
2589
|
+
onOpenChange,
|
|
2590
|
+
open: open2
|
|
2591
|
+
};
|
|
2592
|
+
};
|
|
2593
|
+
const Popover$2 = PopoverPrimitive.Root;
|
|
2594
|
+
const popoverVariants = cva(
|
|
2595
|
+
"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"
|
|
2596
|
+
);
|
|
2597
|
+
const PopoverContent$1 = withRef(
|
|
2598
|
+
({ align = "center", className, sideOffset = 4, style, ...props }, ref) => /* @__PURE__ */ React.createElement(PopoverPrimitive.Portal, null, /* @__PURE__ */ React.createElement(
|
|
2599
|
+
PopoverPrimitive.Content,
|
|
2600
|
+
{
|
|
2601
|
+
align,
|
|
2602
|
+
className: cn$1(popoverVariants(), className),
|
|
2603
|
+
ref,
|
|
2604
|
+
sideOffset,
|
|
2605
|
+
style: { zIndex: 1e3, ...style },
|
|
2606
|
+
...props
|
|
2607
|
+
}
|
|
2608
|
+
))
|
|
2609
|
+
);
|
|
2610
|
+
const separatorVariants = cva("shrink-0 bg-border", {
|
|
2611
|
+
defaultVariants: {
|
|
2612
|
+
orientation: "horizontal"
|
|
2613
|
+
},
|
|
2614
|
+
variants: {
|
|
2615
|
+
orientation: {
|
|
2616
|
+
horizontal: "h-px w-full",
|
|
2617
|
+
vertical: "h-full w-px"
|
|
2618
|
+
}
|
|
2105
2619
|
}
|
|
2620
|
+
});
|
|
2621
|
+
const Separator = withVariants(
|
|
2622
|
+
withProps(SeparatorPrimitive.Root, {
|
|
2623
|
+
decorative: true,
|
|
2624
|
+
orientation: "horizontal"
|
|
2625
|
+
}),
|
|
2626
|
+
separatorVariants
|
|
2627
|
+
);
|
|
2628
|
+
const TableBordersDropdownMenuContent = withRef((props, ref) => {
|
|
2629
|
+
const {
|
|
2630
|
+
getOnSelectTableBorder,
|
|
2631
|
+
hasBottomBorder,
|
|
2632
|
+
hasLeftBorder,
|
|
2633
|
+
hasNoBorders,
|
|
2634
|
+
hasOuterBorders,
|
|
2635
|
+
hasRightBorder,
|
|
2636
|
+
hasTopBorder
|
|
2637
|
+
} = useTableBordersDropdownMenuContentState();
|
|
2106
2638
|
return /* @__PURE__ */ React__default.createElement(
|
|
2107
|
-
|
|
2639
|
+
DropdownMenuContent,
|
|
2108
2640
|
{
|
|
2109
|
-
|
|
2110
|
-
className: "
|
|
2641
|
+
align: "start",
|
|
2642
|
+
className: cn$1("min-w-[220px]"),
|
|
2643
|
+
ref,
|
|
2644
|
+
side: "right",
|
|
2645
|
+
sideOffset: 0,
|
|
2646
|
+
...props
|
|
2111
2647
|
},
|
|
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,
|
|
2648
|
+
/* @__PURE__ */ React__default.createElement(
|
|
2649
|
+
DropdownMenuCheckboxItem,
|
|
2119
2650
|
{
|
|
2120
|
-
|
|
2121
|
-
|
|
2122
|
-
|
|
2123
|
-
|
|
2124
|
-
|
|
2125
|
-
)
|
|
2126
|
-
|
|
2651
|
+
checked: hasBottomBorder,
|
|
2652
|
+
onCheckedChange: getOnSelectTableBorder("bottom")
|
|
2653
|
+
},
|
|
2654
|
+
/* @__PURE__ */ React__default.createElement(Icons.borderBottom, { className: iconVariants({ size: "sm" }) }),
|
|
2655
|
+
/* @__PURE__ */ React__default.createElement("div", null, "Bottom Border")
|
|
2656
|
+
),
|
|
2657
|
+
/* @__PURE__ */ React__default.createElement(
|
|
2658
|
+
DropdownMenuCheckboxItem,
|
|
2127
2659
|
{
|
|
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
|
-
|
|
2660
|
+
checked: hasTopBorder,
|
|
2661
|
+
onCheckedChange: getOnSelectTableBorder("top")
|
|
2662
|
+
},
|
|
2663
|
+
/* @__PURE__ */ React__default.createElement(Icons.borderTop, { className: iconVariants({ size: "sm" }) }),
|
|
2664
|
+
/* @__PURE__ */ React__default.createElement("div", null, "Top Border")
|
|
2665
|
+
),
|
|
2666
|
+
/* @__PURE__ */ React__default.createElement(
|
|
2667
|
+
DropdownMenuCheckboxItem,
|
|
2668
|
+
{
|
|
2669
|
+
checked: hasLeftBorder,
|
|
2670
|
+
onCheckedChange: getOnSelectTableBorder("left")
|
|
2671
|
+
},
|
|
2672
|
+
/* @__PURE__ */ React__default.createElement(Icons.borderLeft, { className: iconVariants({ size: "sm" }) }),
|
|
2673
|
+
/* @__PURE__ */ React__default.createElement("div", null, "Left Border")
|
|
2674
|
+
),
|
|
2675
|
+
/* @__PURE__ */ React__default.createElement(
|
|
2676
|
+
DropdownMenuCheckboxItem,
|
|
2677
|
+
{
|
|
2678
|
+
checked: hasRightBorder,
|
|
2679
|
+
onCheckedChange: getOnSelectTableBorder("right")
|
|
2680
|
+
},
|
|
2681
|
+
/* @__PURE__ */ React__default.createElement(Icons.borderRight, { className: iconVariants({ size: "sm" }) }),
|
|
2682
|
+
/* @__PURE__ */ React__default.createElement("div", null, "Right Border")
|
|
2683
|
+
),
|
|
2684
|
+
/* @__PURE__ */ React__default.createElement(Separator, null),
|
|
2685
|
+
/* @__PURE__ */ React__default.createElement(
|
|
2686
|
+
DropdownMenuCheckboxItem,
|
|
2687
|
+
{
|
|
2688
|
+
checked: hasNoBorders,
|
|
2689
|
+
onCheckedChange: getOnSelectTableBorder("none")
|
|
2690
|
+
},
|
|
2691
|
+
/* @__PURE__ */ React__default.createElement(Icons.borderNone, { className: iconVariants({ size: "sm" }) }),
|
|
2692
|
+
/* @__PURE__ */ React__default.createElement("div", null, "No Border")
|
|
2693
|
+
),
|
|
2694
|
+
/* @__PURE__ */ React__default.createElement(
|
|
2695
|
+
DropdownMenuCheckboxItem,
|
|
2696
|
+
{
|
|
2697
|
+
checked: hasOuterBorders,
|
|
2698
|
+
onCheckedChange: getOnSelectTableBorder("outer")
|
|
2699
|
+
},
|
|
2700
|
+
/* @__PURE__ */ React__default.createElement(Icons.borderAll, { className: iconVariants({ size: "sm" }) }),
|
|
2701
|
+
/* @__PURE__ */ React__default.createElement("div", null, "Outside Borders")
|
|
2702
|
+
)
|
|
2164
2703
|
);
|
|
2165
|
-
};
|
|
2166
|
-
const
|
|
2167
|
-
({
|
|
2168
|
-
const
|
|
2169
|
-
const
|
|
2170
|
-
|
|
2171
|
-
|
|
2704
|
+
});
|
|
2705
|
+
const TableFloatingToolbar = withRef(
|
|
2706
|
+
({ children, ...props }, ref) => {
|
|
2707
|
+
const element = useElement();
|
|
2708
|
+
const { props: buttonProps } = useRemoveNodeButton({ element });
|
|
2709
|
+
const selectionCollapsed = useEditorSelector(
|
|
2710
|
+
(editor2) => !isSelectionExpanded(editor2),
|
|
2711
|
+
[]
|
|
2712
|
+
);
|
|
2713
|
+
const readOnly = useReadOnly();
|
|
2714
|
+
const selected = useSelected();
|
|
2715
|
+
const editor = useEditorRef();
|
|
2716
|
+
const collapsed = !readOnly && selected && selectionCollapsed;
|
|
2717
|
+
const open2 = !readOnly && selected;
|
|
2718
|
+
const { canMerge, canUnmerge } = useTableMergeState();
|
|
2719
|
+
const mergeContent = canMerge && /* @__PURE__ */ React__default.createElement(
|
|
2720
|
+
Button$2,
|
|
2172
2721
|
{
|
|
2173
|
-
|
|
2722
|
+
contentEditable: false,
|
|
2723
|
+
isMenu: true,
|
|
2724
|
+
onClick: () => mergeTableCells(editor),
|
|
2725
|
+
variant: "ghost"
|
|
2726
|
+
},
|
|
2727
|
+
/* @__PURE__ */ React__default.createElement(Icons.combine, { className: "mr-2 size-4" }),
|
|
2728
|
+
"Merge"
|
|
2729
|
+
);
|
|
2730
|
+
const unmergeButton = canUnmerge && /* @__PURE__ */ React__default.createElement(
|
|
2731
|
+
Button$2,
|
|
2732
|
+
{
|
|
2733
|
+
contentEditable: false,
|
|
2734
|
+
isMenu: true,
|
|
2735
|
+
onClick: () => unmergeTableCells(editor),
|
|
2736
|
+
variant: "ghost"
|
|
2737
|
+
},
|
|
2738
|
+
/* @__PURE__ */ React__default.createElement(Icons.ungroup, { className: "mr-2 size-4" }),
|
|
2739
|
+
"Unmerge"
|
|
2740
|
+
);
|
|
2741
|
+
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"));
|
|
2742
|
+
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(
|
|
2743
|
+
PopoverContent$1,
|
|
2744
|
+
{
|
|
2745
|
+
className: cn$1(
|
|
2746
|
+
popoverVariants(),
|
|
2747
|
+
"flex w-[220px] flex-col gap-1 p-1"
|
|
2748
|
+
),
|
|
2749
|
+
onOpenAutoFocus: (e) => e.preventDefault(),
|
|
2174
2750
|
ref,
|
|
2175
2751
|
...props
|
|
2176
2752
|
},
|
|
2177
|
-
|
|
2178
|
-
|
|
2753
|
+
unmergeButton,
|
|
2754
|
+
mergeContent,
|
|
2755
|
+
bordersContent
|
|
2756
|
+
));
|
|
2179
2757
|
}
|
|
2180
2758
|
);
|
|
2759
|
+
const TableElement = withHOC(
|
|
2760
|
+
TableProvider,
|
|
2761
|
+
withRef(({ children, className, ...props }, ref) => {
|
|
2762
|
+
const { colSizes, isSelectingCell, marginLeft, minColumnWidth } = useTableElementState();
|
|
2763
|
+
const { colGroupProps, props: tableProps } = useTableElement();
|
|
2764
|
+
return /* @__PURE__ */ React__default.createElement(TableFloatingToolbar, null, /* @__PURE__ */ React__default.createElement("div", { style: { paddingLeft: marginLeft } }, /* @__PURE__ */ React__default.createElement(
|
|
2765
|
+
PlateElement,
|
|
2766
|
+
{
|
|
2767
|
+
asChild: true,
|
|
2768
|
+
className: cn$1(
|
|
2769
|
+
"my-4 ml-px mr-0 table h-px w-full table-fixed border-collapse",
|
|
2770
|
+
isSelectingCell && "[&_*::selection]:bg-none",
|
|
2771
|
+
className
|
|
2772
|
+
),
|
|
2773
|
+
ref,
|
|
2774
|
+
...tableProps,
|
|
2775
|
+
...props
|
|
2776
|
+
},
|
|
2777
|
+
/* @__PURE__ */ React__default.createElement("table", null, /* @__PURE__ */ React__default.createElement("colgroup", { ...colGroupProps }, colSizes.map((width, index) => /* @__PURE__ */ React__default.createElement(
|
|
2778
|
+
"col",
|
|
2779
|
+
{
|
|
2780
|
+
key: index,
|
|
2781
|
+
style: {
|
|
2782
|
+
minWidth: minColumnWidth,
|
|
2783
|
+
width: width || void 0
|
|
2784
|
+
}
|
|
2785
|
+
}
|
|
2786
|
+
))), /* @__PURE__ */ React__default.createElement("tbody", { className: "min-w-full" }, children))
|
|
2787
|
+
)));
|
|
2788
|
+
})
|
|
2789
|
+
);
|
|
2790
|
+
const TableRowElement = withRef(({ children, hideBorder, ...props }, ref) => {
|
|
2791
|
+
return /* @__PURE__ */ React__default.createElement(
|
|
2792
|
+
PlateElement,
|
|
2793
|
+
{
|
|
2794
|
+
asChild: true,
|
|
2795
|
+
className: cn$1("h-full", hideBorder && "border-none"),
|
|
2796
|
+
ref,
|
|
2797
|
+
...props
|
|
2798
|
+
},
|
|
2799
|
+
/* @__PURE__ */ React__default.createElement("tr", null, children)
|
|
2800
|
+
);
|
|
2801
|
+
});
|
|
2181
2802
|
const blockClasses = "mt-0.5";
|
|
2182
2803
|
const headerClasses = "font-normal";
|
|
2183
2804
|
const Components = () => {
|
|
@@ -2283,6 +2904,7 @@ const Components = () => {
|
|
|
2283
2904
|
}
|
|
2284
2905
|
)
|
|
2285
2906
|
),
|
|
2907
|
+
[ELEMENT_MERMAID]: MermaidElement,
|
|
2286
2908
|
[ELEMENT_BLOCKQUOTE]: BlockquoteElement,
|
|
2287
2909
|
[ELEMENT_CODE_BLOCK]: CodeBlockElement,
|
|
2288
2910
|
[ELEMENT_CODE_LINE]: CodeLineElement,
|
|
@@ -2363,7 +2985,11 @@ const Components = () => {
|
|
|
2363
2985
|
children,
|
|
2364
2986
|
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
2987
|
);
|
|
2366
|
-
}
|
|
2988
|
+
},
|
|
2989
|
+
[ELEMENT_TABLE]: TableElement,
|
|
2990
|
+
[ELEMENT_TR]: TableRowElement,
|
|
2991
|
+
[ELEMENT_TD]: TableCellElement,
|
|
2992
|
+
[ELEMENT_TH]: TableCellHeaderElement
|
|
2367
2993
|
};
|
|
2368
2994
|
};
|
|
2369
2995
|
const createCodeBlockPlugin = createPluginFactory({
|
|
@@ -2773,7 +3399,9 @@ class Form {
|
|
|
2773
3399
|
{
|
|
2774
3400
|
type: "string",
|
|
2775
3401
|
label: "Caption",
|
|
2776
|
-
name: [templateName.replace(/\.props$/, ""), "caption"].join(
|
|
3402
|
+
name: [templateName.replace(/\.props$/, ""), "caption"].join(
|
|
3403
|
+
"."
|
|
3404
|
+
),
|
|
2777
3405
|
component: "text"
|
|
2778
3406
|
}
|
|
2779
3407
|
]
|
|
@@ -3091,7 +3719,7 @@ const Button$1 = ({
|
|
|
3091
3719
|
};
|
|
3092
3720
|
const sizeClasses = {
|
|
3093
3721
|
small: `text-xs h-8 px-3`,
|
|
3094
|
-
medium: `text-sm h-10 px-
|
|
3722
|
+
medium: `text-sm h-10 px-8`,
|
|
3095
3723
|
custom: ``
|
|
3096
3724
|
};
|
|
3097
3725
|
return /* @__PURE__ */ React.createElement(
|
|
@@ -4433,7 +5061,7 @@ const ImageLoadingIndicator = () => /* @__PURE__ */ React.createElement("div", {
|
|
|
4433
5061
|
function cn(...inputs) {
|
|
4434
5062
|
return twMerge(clsx(inputs));
|
|
4435
5063
|
}
|
|
4436
|
-
const buttonVariants
|
|
5064
|
+
const buttonVariants = cva(
|
|
4437
5065
|
"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
5066
|
{
|
|
4439
5067
|
variants: {
|
|
@@ -4459,7 +5087,7 @@ const Button = React.forwardRef(
|
|
|
4459
5087
|
return /* @__PURE__ */ React.createElement(
|
|
4460
5088
|
Comp,
|
|
4461
5089
|
{
|
|
4462
|
-
className: cn(buttonVariants
|
|
5090
|
+
className: cn(buttonVariants({ variant, size, className })),
|
|
4463
5091
|
ref,
|
|
4464
5092
|
...props
|
|
4465
5093
|
}
|
|
@@ -5125,10 +5753,11 @@ const ItemDeleteButton = ({ onClick, disabled = false }) => {
|
|
|
5125
5753
|
return /* @__PURE__ */ React__default.createElement(
|
|
5126
5754
|
"button",
|
|
5127
5755
|
{
|
|
5128
|
-
|
|
5756
|
+
type: "button",
|
|
5757
|
+
className: `w-8 px-1 py-2.5 flex items-center justify-center text-gray-200 hover:opacity-100 opacity-30 hover:bg-gray-50 ${disabled && "pointer-events-none opacity-30 cursor-not-allowed"}`,
|
|
5129
5758
|
onClick
|
|
5130
5759
|
},
|
|
5131
|
-
/* @__PURE__ */ React__default.createElement(TrashIcon, { className: "fill-current transition-colors ease-out
|
|
5760
|
+
/* @__PURE__ */ React__default.createElement(TrashIcon, { className: "h-5 w-auto fill-current text-red-500 transition-colors duration-150 ease-out" })
|
|
5132
5761
|
);
|
|
5133
5762
|
};
|
|
5134
5763
|
const DragHandle = ({ isDragging }) => {
|
|
@@ -5158,7 +5787,7 @@ const BlockSelector = ({
|
|
|
5158
5787
|
return template.label ? template.label.toLowerCase().includes(filter.toLowerCase()) || name.toLowerCase().includes(filter.toLowerCase()) : name.toLowerCase().includes(filter.toLowerCase());
|
|
5159
5788
|
});
|
|
5160
5789
|
}, [filter]);
|
|
5161
|
-
return /* @__PURE__ */ React.createElement(Popover$
|
|
5790
|
+
return /* @__PURE__ */ React.createElement(Popover$3, null, ({ open: open2 }) => /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(PopoverButton, { as: "span" }, /* @__PURE__ */ React.createElement(
|
|
5162
5791
|
IconButton,
|
|
5163
5792
|
{
|
|
5164
5793
|
variant: open2 ? "secondary" : "primary",
|
|
@@ -5206,27 +5835,35 @@ const BlockSelector = ({
|
|
|
5206
5835
|
))))
|
|
5207
5836
|
))));
|
|
5208
5837
|
};
|
|
5209
|
-
const Group =
|
|
5210
|
-
|
|
5211
|
-
|
|
5212
|
-
|
|
5213
|
-
|
|
5214
|
-
|
|
5215
|
-
|
|
5216
|
-
|
|
5217
|
-
|
|
5218
|
-
|
|
5219
|
-
|
|
5838
|
+
const Group = wrapFieldWithNoHeader(
|
|
5839
|
+
({ tinaForm, field }) => {
|
|
5840
|
+
const cms = useCMS$1();
|
|
5841
|
+
return /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(
|
|
5842
|
+
Header,
|
|
5843
|
+
{
|
|
5844
|
+
onClick: () => {
|
|
5845
|
+
const state = tinaForm.finalForm.getState();
|
|
5846
|
+
if (state.invalid === true) {
|
|
5847
|
+
cms.alerts.error("Cannot navigate away from an invalid form.");
|
|
5848
|
+
return;
|
|
5849
|
+
}
|
|
5850
|
+
cms.dispatch({
|
|
5851
|
+
type: "forms:set-active-field-name",
|
|
5852
|
+
value: { formId: tinaForm.id, fieldName: field.name }
|
|
5853
|
+
});
|
|
5220
5854
|
}
|
|
5221
|
-
|
|
5222
|
-
|
|
5223
|
-
|
|
5224
|
-
|
|
5225
|
-
|
|
5226
|
-
|
|
5227
|
-
|
|
5228
|
-
|
|
5229
|
-
|
|
5855
|
+
},
|
|
5856
|
+
field.label || field.name,
|
|
5857
|
+
field.description && /* @__PURE__ */ React.createElement(
|
|
5858
|
+
"span",
|
|
5859
|
+
{
|
|
5860
|
+
className: `block font-sans text-xs italic font-light text-gray-400 pt-0.5 whitespace-normal m-0`,
|
|
5861
|
+
dangerouslySetInnerHTML: { __html: field.description }
|
|
5862
|
+
}
|
|
5863
|
+
)
|
|
5864
|
+
));
|
|
5865
|
+
}
|
|
5866
|
+
);
|
|
5230
5867
|
const Header = ({ onClick, children }) => {
|
|
5231
5868
|
return /* @__PURE__ */ React.createElement("div", { className: "pt-1 mb-5" }, /* @__PURE__ */ React.createElement(
|
|
5232
5869
|
"button",
|
|
@@ -9723,7 +10360,7 @@ const SyncStatus = ({ cms, setEventsOpen }) => {
|
|
|
9723
10360
|
"Event Log"
|
|
9724
10361
|
));
|
|
9725
10362
|
};
|
|
9726
|
-
const version = "2.
|
|
10363
|
+
const version = "2.4.0";
|
|
9727
10364
|
const Nav = ({
|
|
9728
10365
|
isLocalMode,
|
|
9729
10366
|
className = "",
|
|
@@ -12254,15 +12891,14 @@ const FormBuilder = ({
|
|
|
12254
12891
|
fields: fieldGroup.fields
|
|
12255
12892
|
}
|
|
12256
12893
|
) : /* @__PURE__ */ React.createElement(NoFieldsPlaceholder, null)
|
|
12257
|
-
)), !hideFooter && /* @__PURE__ */ React.createElement("div", { className: "relative flex-none w-full h-16 px-
|
|
12894
|
+
)), !hideFooter && /* @__PURE__ */ React.createElement("div", { className: "relative flex-none w-full h-16 px-12 bg-white border-t border-gray-100 flex items-center justify-end" }, /* @__PURE__ */ React.createElement("div", { className: "flex-1 w-full justify-end gap-2 flex items-center max-w-form" }, tinaForm.reset && /* @__PURE__ */ React.createElement(
|
|
12258
12895
|
ResetForm,
|
|
12259
12896
|
{
|
|
12260
12897
|
pristine,
|
|
12261
12898
|
reset: async () => {
|
|
12262
12899
|
finalForm.reset();
|
|
12263
12900
|
await tinaForm.reset();
|
|
12264
|
-
}
|
|
12265
|
-
style: { flexGrow: 1 }
|
|
12901
|
+
}
|
|
12266
12902
|
},
|
|
12267
12903
|
tinaForm.buttons.reset
|
|
12268
12904
|
), /* @__PURE__ */ React.createElement(
|
|
@@ -12271,8 +12907,7 @@ const FormBuilder = ({
|
|
|
12271
12907
|
onClick: safeHandleSubmit,
|
|
12272
12908
|
disabled: !canSubmit,
|
|
12273
12909
|
busy: submitting,
|
|
12274
|
-
variant: "primary"
|
|
12275
|
-
style: { flexGrow: 3 }
|
|
12910
|
+
variant: "primary"
|
|
12276
12911
|
},
|
|
12277
12912
|
submitting && /* @__PURE__ */ React.createElement(LoadingDots, null),
|
|
12278
12913
|
!submitting && tinaForm.buttons.save
|
|
@@ -12790,7 +13425,7 @@ const EmbedNestedForm = ({
|
|
|
12790
13425
|
);
|
|
12791
13426
|
};
|
|
12792
13427
|
const DotMenu = ({ onOpen, onRemove }) => {
|
|
12793
|
-
return /* @__PURE__ */ React__default.createElement(Popover$
|
|
13428
|
+
return /* @__PURE__ */ React__default.createElement(Popover$3, { as: "span", className: "-ml-px relative block" }, /* @__PURE__ */ React__default.createElement(
|
|
12794
13429
|
PopoverButton,
|
|
12795
13430
|
{
|
|
12796
13431
|
as: "span",
|
|
@@ -13230,13 +13865,26 @@ const plugins = [
|
|
|
13230
13865
|
createUnderlinePlugin(),
|
|
13231
13866
|
createCodePlugin(),
|
|
13232
13867
|
createListPlugin(),
|
|
13233
|
-
createIndentPlugin(),
|
|
13234
13868
|
createIndentListPlugin(),
|
|
13235
13869
|
createHorizontalRulePlugin(),
|
|
13236
13870
|
// Allows us to do things like copy/paste, remembering the state of the element (like mdx)
|
|
13237
13871
|
createNodeIdPlugin(),
|
|
13238
|
-
createSlashPlugin()
|
|
13872
|
+
createSlashPlugin(),
|
|
13873
|
+
createTablePlugin()
|
|
13239
13874
|
];
|
|
13875
|
+
const unsupportedItemsInTable = /* @__PURE__ */ new Set([
|
|
13876
|
+
"Code Block",
|
|
13877
|
+
"Unordered List",
|
|
13878
|
+
"Ordered List",
|
|
13879
|
+
"Quote",
|
|
13880
|
+
"Mermaid",
|
|
13881
|
+
"Heading 1",
|
|
13882
|
+
"Heading 2",
|
|
13883
|
+
"Heading 3",
|
|
13884
|
+
"Heading 4",
|
|
13885
|
+
"Heading 5",
|
|
13886
|
+
"Heading 6"
|
|
13887
|
+
]);
|
|
13240
13888
|
const isNodeActive = (editor, type) => {
|
|
13241
13889
|
const pluginType = getPluginType(editor, type);
|
|
13242
13890
|
return !!(editor == null ? void 0 : editor.selection) && someNode(editor, { match: { type: pluginType } });
|
|
@@ -13421,24 +14069,6 @@ const Editor = React__default.forwardRef(
|
|
|
13421
14069
|
}
|
|
13422
14070
|
);
|
|
13423
14071
|
Editor.displayName = "Editor";
|
|
13424
|
-
const separatorVariants = cva("shrink-0 bg-border", {
|
|
13425
|
-
defaultVariants: {
|
|
13426
|
-
orientation: "horizontal"
|
|
13427
|
-
},
|
|
13428
|
-
variants: {
|
|
13429
|
-
orientation: {
|
|
13430
|
-
horizontal: "h-px w-full",
|
|
13431
|
-
vertical: "h-full w-px"
|
|
13432
|
-
}
|
|
13433
|
-
}
|
|
13434
|
-
});
|
|
13435
|
-
const Separator = withVariants(
|
|
13436
|
-
withProps(SeparatorPrimitive.Root, {
|
|
13437
|
-
decorative: true,
|
|
13438
|
-
orientation: "horizontal"
|
|
13439
|
-
}),
|
|
13440
|
-
separatorVariants
|
|
13441
|
-
);
|
|
13442
14072
|
const TooltipProvider = TooltipPrimitive.Provider;
|
|
13443
14073
|
const Tooltip = TooltipPrimitive.Root;
|
|
13444
14074
|
const TooltipTrigger = TooltipPrimitive.Trigger;
|
|
@@ -13447,7 +14077,7 @@ const TooltipContent = withCn(
|
|
|
13447
14077
|
withProps(TooltipPrimitive.Content, {
|
|
13448
14078
|
sideOffset: 4
|
|
13449
14079
|
}),
|
|
13450
|
-
"z-
|
|
14080
|
+
"z-[9999] overflow-hidden rounded-md border bg-popover px-3 py-1.5 text-sm text-popover-foreground shadow-md"
|
|
13451
14081
|
);
|
|
13452
14082
|
function withTooltip(Component2) {
|
|
13453
14083
|
return React__default.forwardRef(function ExtendComponent({ tooltip, tooltipContentProps, tooltipProps, ...props }, ref) {
|
|
@@ -13573,140 +14203,41 @@ const FixedToolbar = withCn(
|
|
|
13573
14203
|
Toolbar,
|
|
13574
14204
|
"p-1 sticky left-0 top-0 z-50 w-full justify-between overflow-x-auto border border-border bg-background"
|
|
13575
14205
|
);
|
|
13576
|
-
const
|
|
13577
|
-
|
|
13578
|
-
|
|
13579
|
-
|
|
13580
|
-
|
|
13581
|
-
const IndentListToolbarButton = withRef(({ nodeType = ELEMENT_UL }, ref) => {
|
|
13582
|
-
const editor = useEditorState();
|
|
13583
|
-
const state = useListToolbarButtonState({ nodeType });
|
|
13584
|
-
const { props } = useListToolbarButton(state);
|
|
13585
|
-
return /* @__PURE__ */ React__default.createElement(
|
|
13586
|
-
ToolbarButton,
|
|
13587
|
-
{
|
|
13588
|
-
ref,
|
|
13589
|
-
tooltip: nodeType === ELEMENT_UL ? "Bulleted List" : "Numbered List",
|
|
13590
|
-
...props,
|
|
13591
|
-
onClick: (e) => {
|
|
13592
|
-
e.preventDefault();
|
|
13593
|
-
e.stopPropagation();
|
|
13594
|
-
toggleList(editor, { type: nodeType });
|
|
13595
|
-
}
|
|
13596
|
-
},
|
|
13597
|
-
nodeType === ELEMENT_UL ? /* @__PURE__ */ React__default.createElement(Icons.ul, null) : /* @__PURE__ */ React__default.createElement(Icons.ol, null)
|
|
13598
|
-
);
|
|
13599
|
-
});
|
|
13600
|
-
const DropdownMenu = DropdownMenuPrimitive.Root;
|
|
13601
|
-
const DropdownMenuTrigger = DropdownMenuPrimitive.Trigger;
|
|
13602
|
-
const DropdownMenuRadioGroup = DropdownMenuPrimitive.RadioGroup;
|
|
13603
|
-
withRef(({ children, className, inset, ...props }, ref) => /* @__PURE__ */ React__default.createElement(
|
|
13604
|
-
DropdownMenuPrimitive.SubTrigger,
|
|
13605
|
-
{
|
|
13606
|
-
className: cn$1(
|
|
13607
|
-
"flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none focus:bg-accent data-[state=open]:bg-accent",
|
|
13608
|
-
"data-[disabled]:pointer-events-none data-[disabled]:opacity-50",
|
|
13609
|
-
inset && "pl-8",
|
|
13610
|
-
className
|
|
13611
|
-
),
|
|
13612
|
-
ref,
|
|
13613
|
-
...props
|
|
13614
|
-
},
|
|
13615
|
-
children,
|
|
13616
|
-
/* @__PURE__ */ React__default.createElement(Icons.chevronRight, { className: "ml-auto size-4" })
|
|
13617
|
-
));
|
|
13618
|
-
withCn(
|
|
13619
|
-
DropdownMenuPrimitive.SubContent,
|
|
13620
|
-
"z-[99999] min-w-32 overflow-hidden rounded-md border bg-white p-1 text-black shadow-lg data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2"
|
|
13621
|
-
);
|
|
13622
|
-
const DropdownMenuContentVariants = withProps(DropdownMenuPrimitive.Content, {
|
|
13623
|
-
className: cn$1(
|
|
13624
|
-
"z-[99999] min-w-32 overflow-hidden rounded-md border bg-white p-1 text-black shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2"
|
|
13625
|
-
),
|
|
13626
|
-
sideOffset: 4
|
|
13627
|
-
});
|
|
13628
|
-
const DropdownMenuContent = withRef(({ ...props }, ref) => /* @__PURE__ */ React__default.createElement(DropdownMenuPrimitive.Portal, null, /* @__PURE__ */ React__default.createElement(DropdownMenuContentVariants, { ref, ...props })));
|
|
13629
|
-
const menuItemVariants = cva(
|
|
13630
|
-
cn$1(
|
|
13631
|
-
"relative flex h-9 cursor-pointer select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none transition-colors",
|
|
13632
|
-
"focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50"
|
|
13633
|
-
),
|
|
13634
|
-
{
|
|
13635
|
-
variants: {
|
|
13636
|
-
inset: {
|
|
13637
|
-
true: "pl-8"
|
|
14206
|
+
const useResize = (ref, callback) => {
|
|
14207
|
+
React__default.useEffect(() => {
|
|
14208
|
+
const resizeObserver = new ResizeObserver((entries) => {
|
|
14209
|
+
for (const entry of entries) {
|
|
14210
|
+
callback(entry);
|
|
13638
14211
|
}
|
|
14212
|
+
});
|
|
14213
|
+
if (ref.current) {
|
|
14214
|
+
resizeObserver.observe(ref.current);
|
|
13639
14215
|
}
|
|
13640
|
-
|
|
13641
|
-
);
|
|
13642
|
-
|
|
13643
|
-
|
|
13644
|
-
|
|
13645
|
-
|
|
13646
|
-
|
|
13647
|
-
|
|
13648
|
-
|
|
13649
|
-
|
|
13650
|
-
|
|
13651
|
-
|
|
13652
|
-
|
|
13653
|
-
|
|
13654
|
-
|
|
13655
|
-
ref,
|
|
13656
|
-
...props
|
|
13657
|
-
},
|
|
13658
|
-
/* @__PURE__ */ React__default.createElement("span", { className: "absolute left-2 flex size-3.5 items-center justify-center" }, /* @__PURE__ */ React__default.createElement(DropdownMenuPrimitive.ItemIndicator, null, /* @__PURE__ */ React__default.createElement(Icons.check, { className: "size-4" }))),
|
|
13659
|
-
children
|
|
13660
|
-
));
|
|
13661
|
-
const DropdownMenuRadioItem = withRef(({ children, className, hideIcon, ...props }, ref) => /* @__PURE__ */ React__default.createElement(
|
|
13662
|
-
DropdownMenuPrimitive.RadioItem,
|
|
13663
|
-
{
|
|
13664
|
-
className: cn$1(
|
|
13665
|
-
"relative flex select-none items-center rounded-sm pl-8 pr-2 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",
|
|
13666
|
-
"h-9 cursor-pointer px-2 data-[state=checked]:bg-accent data-[state=checked]:text-accent-foreground",
|
|
13667
|
-
className
|
|
13668
|
-
),
|
|
13669
|
-
ref,
|
|
13670
|
-
...props
|
|
13671
|
-
},
|
|
13672
|
-
!hideIcon && /* @__PURE__ */ React__default.createElement("span", { className: "absolute right-2 flex size-3.5 items-center justify-center" }, /* @__PURE__ */ React__default.createElement(DropdownMenuPrimitive.ItemIndicator, null, /* @__PURE__ */ React__default.createElement(Icons.check, { className: "size-4" }))),
|
|
14216
|
+
return () => resizeObserver.disconnect();
|
|
14217
|
+
}, [ref.current]);
|
|
14218
|
+
};
|
|
14219
|
+
const STANDARD_ICON_WIDTH = 32;
|
|
14220
|
+
const HEADING_ICON_WITH_TEXT = 127;
|
|
14221
|
+
const HEADING_ICON_ONLY = 58;
|
|
14222
|
+
const EMBED_ICON_WIDTH = 78;
|
|
14223
|
+
const CONTAINER_MD_BREAKPOINT = 448;
|
|
14224
|
+
const FLOAT_BUTTON_WIDTH = 25;
|
|
14225
|
+
const HEADING_LABEL = "Headings";
|
|
14226
|
+
const ToolbarContext = createContext(void 0);
|
|
14227
|
+
const ToolbarProvider = ({
|
|
14228
|
+
tinaForm,
|
|
14229
|
+
templates,
|
|
14230
|
+
overrides,
|
|
13673
14231
|
children
|
|
13674
|
-
)
|
|
13675
|
-
|
|
13676
|
-
|
|
13677
|
-
|
|
13678
|
-
|
|
13679
|
-
|
|
13680
|
-
|
|
13681
|
-
}
|
|
13682
|
-
}
|
|
14232
|
+
}) => {
|
|
14233
|
+
return /* @__PURE__ */ React__default.createElement(ToolbarContext.Provider, { value: { tinaForm, templates, overrides } }, children);
|
|
14234
|
+
};
|
|
14235
|
+
const useToolbarContext = () => {
|
|
14236
|
+
const context = useContext(ToolbarContext);
|
|
14237
|
+
if (!context) {
|
|
14238
|
+
throw new Error("useToolbarContext must be used within a ToolbarProvider");
|
|
13683
14239
|
}
|
|
13684
|
-
|
|
13685
|
-
const DropdownMenuLabel = withVariants(
|
|
13686
|
-
DropdownMenuPrimitive.Label,
|
|
13687
|
-
dropdownMenuLabelVariants,
|
|
13688
|
-
["inset"]
|
|
13689
|
-
);
|
|
13690
|
-
const DropdownMenuSeparator = withCn(
|
|
13691
|
-
DropdownMenuPrimitive.Separator,
|
|
13692
|
-
"-mx-1 my-1 h-px bg-muted"
|
|
13693
|
-
);
|
|
13694
|
-
withCn(
|
|
13695
|
-
createPrimitiveElement("span"),
|
|
13696
|
-
"ml-auto text-xs tracking-widest opacity-60"
|
|
13697
|
-
);
|
|
13698
|
-
const useOpenState = () => {
|
|
13699
|
-
const [open2, setOpen] = useState(false);
|
|
13700
|
-
const onOpenChange = useCallback(
|
|
13701
|
-
(_value = !open2) => {
|
|
13702
|
-
setOpen(_value);
|
|
13703
|
-
},
|
|
13704
|
-
[open2]
|
|
13705
|
-
);
|
|
13706
|
-
return {
|
|
13707
|
-
onOpenChange,
|
|
13708
|
-
open: open2
|
|
13709
|
-
};
|
|
14240
|
+
return context;
|
|
13710
14241
|
};
|
|
13711
14242
|
const items$1 = [
|
|
13712
14243
|
{
|
|
@@ -13772,7 +14303,9 @@ function HeadingsMenu(props) {
|
|
|
13772
14303
|
return allNodesMatchInitialNodeType ? initialNodeType : ELEMENT_PARAGRAPH$1;
|
|
13773
14304
|
}, []);
|
|
13774
14305
|
const editor = useEditorRef();
|
|
14306
|
+
const editorState = useEditorState();
|
|
13775
14307
|
const openState = useOpenState();
|
|
14308
|
+
const userInTable = helpers.isNodeActive(editorState, ELEMENT_TABLE$1);
|
|
13776
14309
|
const selectedItem = items$1.find((item) => item.value === value) ?? defaultItem$1;
|
|
13777
14310
|
const { icon: SelectedItemIcon, label: selectedItemLabel } = selectedItem;
|
|
13778
14311
|
return /* @__PURE__ */ React__default.createElement(DropdownMenu, { modal: false, ...openState, ...props }, /* @__PURE__ */ React__default.createElement(DropdownMenuTrigger, { asChild: true }, /* @__PURE__ */ React__default.createElement(
|
|
@@ -13796,7 +14329,12 @@ function HeadingsMenu(props) {
|
|
|
13796
14329
|
},
|
|
13797
14330
|
value
|
|
13798
14331
|
},
|
|
13799
|
-
items$1.
|
|
14332
|
+
items$1.filter((item) => {
|
|
14333
|
+
if (userInTable) {
|
|
14334
|
+
return !unsupportedItemsInTable.has(item.label);
|
|
14335
|
+
}
|
|
14336
|
+
return true;
|
|
14337
|
+
}).map(({ icon: Icon, label, value: itemValue }) => /* @__PURE__ */ React__default.createElement(
|
|
13800
14338
|
DropdownMenuRadioItem,
|
|
13801
14339
|
{
|
|
13802
14340
|
className: "min-w-[180px]",
|
|
@@ -13808,42 +14346,6 @@ function HeadingsMenu(props) {
|
|
|
13808
14346
|
))
|
|
13809
14347
|
)));
|
|
13810
14348
|
}
|
|
13811
|
-
const LinkToolbarButton = withRef((rest, ref) => {
|
|
13812
|
-
const state = useLinkToolbarButtonState();
|
|
13813
|
-
const { props } = useLinkToolbarButton(state);
|
|
13814
|
-
return /* @__PURE__ */ React__default.createElement(ToolbarButton, { ref, tooltip: "Link", ...props, ...rest }, /* @__PURE__ */ React__default.createElement(Icons.link, null));
|
|
13815
|
-
});
|
|
13816
|
-
const useBlockQuoteToolbarButtonState = () => {
|
|
13817
|
-
const editor = useEditorState();
|
|
13818
|
-
const isBlockActive = () => helpers.isNodeActive(editor, ELEMENT_BLOCKQUOTE$1);
|
|
13819
|
-
return {
|
|
13820
|
-
pressed: isBlockActive()
|
|
13821
|
-
};
|
|
13822
|
-
};
|
|
13823
|
-
const useBlockQuoteToolbarButton = (state) => {
|
|
13824
|
-
const editor = useEditorState();
|
|
13825
|
-
const onClick = () => {
|
|
13826
|
-
toggleNodeType(editor, {
|
|
13827
|
-
activeType: ELEMENT_BLOCKQUOTE$1
|
|
13828
|
-
});
|
|
13829
|
-
};
|
|
13830
|
-
const onMouseDown = (e) => {
|
|
13831
|
-
e.preventDefault();
|
|
13832
|
-
e.stopPropagation();
|
|
13833
|
-
};
|
|
13834
|
-
return {
|
|
13835
|
-
props: {
|
|
13836
|
-
onClick,
|
|
13837
|
-
onMouseDown,
|
|
13838
|
-
pressed: state.pressed
|
|
13839
|
-
}
|
|
13840
|
-
};
|
|
13841
|
-
};
|
|
13842
|
-
const QuoteToolbarButton = withRef(({ clear, ...rest }, ref) => {
|
|
13843
|
-
const state = useBlockQuoteToolbarButtonState();
|
|
13844
|
-
const { props } = useBlockQuoteToolbarButton(state);
|
|
13845
|
-
return /* @__PURE__ */ React__default.createElement(ToolbarButton, { ref, tooltip: "Link", ...rest, ...props }, /* @__PURE__ */ React__default.createElement(Icons.quote, null));
|
|
13846
|
-
});
|
|
13847
14349
|
const useCodeBlockToolbarButtonState = () => {
|
|
13848
14350
|
const editor = useEditorState();
|
|
13849
14351
|
const isBlockActive = () => helpers.isNodeActive(editor, ELEMENT_CODE_BLOCK$1);
|
|
@@ -13905,6 +14407,116 @@ const ImageToolbarButton = withRef(({ clear, ...rest }, ref) => {
|
|
|
13905
14407
|
const { props } = useImageToolbarButton(state);
|
|
13906
14408
|
return /* @__PURE__ */ React__default.createElement(ToolbarButton, { ref, tooltip: "Link", ...rest, ...props }, /* @__PURE__ */ React__default.createElement(Icons.image, null));
|
|
13907
14409
|
});
|
|
14410
|
+
const IndentListToolbarButton = withRef(({ nodeType = ELEMENT_UL }, ref) => {
|
|
14411
|
+
const editor = useEditorState();
|
|
14412
|
+
const state = useListToolbarButtonState({ nodeType });
|
|
14413
|
+
const { props } = useListToolbarButton(state);
|
|
14414
|
+
return /* @__PURE__ */ React__default.createElement(
|
|
14415
|
+
ToolbarButton,
|
|
14416
|
+
{
|
|
14417
|
+
ref,
|
|
14418
|
+
tooltip: nodeType === ELEMENT_UL ? "Bulleted List" : "Numbered List",
|
|
14419
|
+
...props,
|
|
14420
|
+
onClick: (e) => {
|
|
14421
|
+
e.preventDefault();
|
|
14422
|
+
e.stopPropagation();
|
|
14423
|
+
toggleList(editor, { type: nodeType });
|
|
14424
|
+
}
|
|
14425
|
+
},
|
|
14426
|
+
nodeType === ELEMENT_UL ? /* @__PURE__ */ React__default.createElement(Icons.ul, null) : /* @__PURE__ */ React__default.createElement(Icons.ol, null)
|
|
14427
|
+
);
|
|
14428
|
+
});
|
|
14429
|
+
const LinkToolbarButton = withRef((rest, ref) => {
|
|
14430
|
+
const state = useLinkToolbarButtonState();
|
|
14431
|
+
const { props } = useLinkToolbarButton(state);
|
|
14432
|
+
return /* @__PURE__ */ React__default.createElement(ToolbarButton, { ref, tooltip: "Link", ...props, ...rest }, /* @__PURE__ */ React__default.createElement(Icons.link, null));
|
|
14433
|
+
});
|
|
14434
|
+
const MarkToolbarButton = withRef(({ clear, nodeType, ...rest }, ref) => {
|
|
14435
|
+
const state = useMarkToolbarButtonState({ clear, nodeType });
|
|
14436
|
+
const { props } = useMarkToolbarButton(state);
|
|
14437
|
+
return /* @__PURE__ */ React__default.createElement(ToolbarButton, { ref, ...props, ...rest });
|
|
14438
|
+
});
|
|
14439
|
+
const useMermaidToolbarButtonState = () => {
|
|
14440
|
+
const editor = useEditorState();
|
|
14441
|
+
const isBlockActive = () => helpers.isNodeActive(editor, ELEMENT_MERMAID);
|
|
14442
|
+
return {
|
|
14443
|
+
pressed: isBlockActive()
|
|
14444
|
+
};
|
|
14445
|
+
};
|
|
14446
|
+
const useMermaidToolbarButton = (state) => {
|
|
14447
|
+
const editor = useEditorState();
|
|
14448
|
+
const onClick = () => {
|
|
14449
|
+
insertEmptyElement(editor, ELEMENT_MERMAID, {
|
|
14450
|
+
nextBlock: true,
|
|
14451
|
+
select: true
|
|
14452
|
+
});
|
|
14453
|
+
};
|
|
14454
|
+
const onMouseDown = (e) => {
|
|
14455
|
+
e.preventDefault();
|
|
14456
|
+
e.stopPropagation();
|
|
14457
|
+
};
|
|
14458
|
+
return {
|
|
14459
|
+
props: {
|
|
14460
|
+
onClick,
|
|
14461
|
+
onMouseDown,
|
|
14462
|
+
pressed: state.pressed
|
|
14463
|
+
}
|
|
14464
|
+
};
|
|
14465
|
+
};
|
|
14466
|
+
const MermaidToolbarButton = withRef(({ clear, ...rest }, ref) => {
|
|
14467
|
+
const state = useMermaidToolbarButtonState();
|
|
14468
|
+
const { props } = useMermaidToolbarButton(state);
|
|
14469
|
+
return /* @__PURE__ */ React__default.createElement(ToolbarButton, { ref, tooltip: "Mermaid", ...rest, ...props }, /* @__PURE__ */ React__default.createElement(Icons.mermaid, null));
|
|
14470
|
+
});
|
|
14471
|
+
function OverflowMenu({
|
|
14472
|
+
children,
|
|
14473
|
+
...props
|
|
14474
|
+
}) {
|
|
14475
|
+
const openState = useOpenState();
|
|
14476
|
+
return /* @__PURE__ */ React__default.createElement(DropdownMenu, { modal: false, ...openState, ...props }, /* @__PURE__ */ React__default.createElement(DropdownMenuTrigger, { asChild: true }, /* @__PURE__ */ React__default.createElement(
|
|
14477
|
+
ToolbarButton,
|
|
14478
|
+
{
|
|
14479
|
+
showArrow: false,
|
|
14480
|
+
"data-testid": "rich-text-editor-overflow-menu-button",
|
|
14481
|
+
className: "lg:min-w-[130px]",
|
|
14482
|
+
isDropdown: true,
|
|
14483
|
+
pressed: openState.open,
|
|
14484
|
+
tooltip: "Headings"
|
|
14485
|
+
},
|
|
14486
|
+
/* @__PURE__ */ React__default.createElement(Icons.overflow, { className: "size-5" })
|
|
14487
|
+
)), /* @__PURE__ */ React__default.createElement(DropdownMenuContent, { align: "start", className: "min-w-0 flex flex-grow" }, children));
|
|
14488
|
+
}
|
|
14489
|
+
const useBlockQuoteToolbarButtonState = () => {
|
|
14490
|
+
const editor = useEditorState();
|
|
14491
|
+
const isBlockActive = () => helpers.isNodeActive(editor, ELEMENT_BLOCKQUOTE$1);
|
|
14492
|
+
return {
|
|
14493
|
+
pressed: isBlockActive()
|
|
14494
|
+
};
|
|
14495
|
+
};
|
|
14496
|
+
const useBlockQuoteToolbarButton = (state) => {
|
|
14497
|
+
const editor = useEditorState();
|
|
14498
|
+
const onClick = () => {
|
|
14499
|
+
toggleNodeType(editor, {
|
|
14500
|
+
activeType: ELEMENT_BLOCKQUOTE$1
|
|
14501
|
+
});
|
|
14502
|
+
};
|
|
14503
|
+
const onMouseDown = (e) => {
|
|
14504
|
+
e.preventDefault();
|
|
14505
|
+
e.stopPropagation();
|
|
14506
|
+
};
|
|
14507
|
+
return {
|
|
14508
|
+
props: {
|
|
14509
|
+
onClick,
|
|
14510
|
+
onMouseDown,
|
|
14511
|
+
pressed: state.pressed
|
|
14512
|
+
}
|
|
14513
|
+
};
|
|
14514
|
+
};
|
|
14515
|
+
const QuoteToolbarButton = withRef(({ clear, ...rest }, ref) => {
|
|
14516
|
+
const state = useBlockQuoteToolbarButtonState();
|
|
14517
|
+
const { props } = useBlockQuoteToolbarButton(state);
|
|
14518
|
+
return /* @__PURE__ */ React__default.createElement(ToolbarButton, { ref, tooltip: "Link", ...rest, ...props }, /* @__PURE__ */ React__default.createElement(Icons.quote, null));
|
|
14519
|
+
});
|
|
13908
14520
|
const useRawMarkdownToolbarButton = () => {
|
|
13909
14521
|
const { setRawMode } = useEditorContext();
|
|
13910
14522
|
const onMouseDown = (e) => {
|
|
@@ -13919,31 +14531,123 @@ const useRawMarkdownToolbarButton = () => {
|
|
|
13919
14531
|
};
|
|
13920
14532
|
const RawMarkdownToolbarButton = withRef(({ clear, ...rest }, ref) => {
|
|
13921
14533
|
const { props } = useRawMarkdownToolbarButton();
|
|
13922
|
-
return /* @__PURE__ */ React__default.createElement(
|
|
14534
|
+
return /* @__PURE__ */ React__default.createElement(
|
|
14535
|
+
ToolbarButton,
|
|
14536
|
+
{
|
|
14537
|
+
ref,
|
|
14538
|
+
tooltip: "Link",
|
|
14539
|
+
...rest,
|
|
14540
|
+
...props,
|
|
14541
|
+
"data-testid": "markdown-button"
|
|
14542
|
+
},
|
|
14543
|
+
/* @__PURE__ */ React__default.createElement(Icons.raw, null)
|
|
14544
|
+
);
|
|
13923
14545
|
});
|
|
13924
|
-
|
|
13925
|
-
const
|
|
13926
|
-
|
|
13927
|
-
|
|
13928
|
-
|
|
13929
|
-
|
|
13930
|
-
|
|
13931
|
-
|
|
13932
|
-
|
|
13933
|
-
const
|
|
13934
|
-
|
|
13935
|
-
|
|
13936
|
-
|
|
13937
|
-
|
|
13938
|
-
|
|
13939
|
-
};
|
|
14546
|
+
function TableDropdownMenu(props) {
|
|
14547
|
+
const tableSelected = useEditorSelector(
|
|
14548
|
+
(editor2) => someNode(editor2, { match: { type: ELEMENT_TABLE$1 } }),
|
|
14549
|
+
[]
|
|
14550
|
+
);
|
|
14551
|
+
const [enableDeleteColumn, enableDeleteRow] = useEditorSelector((editor2) => {
|
|
14552
|
+
const tableNodeEntry = findNode(editor2, { match: { type: ELEMENT_TABLE$1 } });
|
|
14553
|
+
if (!tableNodeEntry)
|
|
14554
|
+
return [false, false];
|
|
14555
|
+
const [tableNode] = tableNodeEntry;
|
|
14556
|
+
if (!isElement(tableNode))
|
|
14557
|
+
return [false, false];
|
|
14558
|
+
const columnCount = getTableColumnCount(tableNode);
|
|
14559
|
+
const rowCount = tableNode.children.length;
|
|
14560
|
+
return [columnCount > 1, rowCount > 1];
|
|
14561
|
+
}, []);
|
|
14562
|
+
const editor = useEditorRef();
|
|
14563
|
+
const openState = useOpenState();
|
|
14564
|
+
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(
|
|
14565
|
+
DropdownMenuContent,
|
|
14566
|
+
{
|
|
14567
|
+
align: "start",
|
|
14568
|
+
className: "flex w-[180px] min-w-0 flex-col gap-0.5"
|
|
14569
|
+
},
|
|
14570
|
+
/* @__PURE__ */ React__default.createElement(
|
|
14571
|
+
DropdownMenuItem,
|
|
14572
|
+
{
|
|
14573
|
+
className: "min-w-[180px]",
|
|
14574
|
+
disabled: tableSelected,
|
|
14575
|
+
onSelect: () => {
|
|
14576
|
+
insertTable(editor);
|
|
14577
|
+
focusEditor(editor);
|
|
14578
|
+
}
|
|
14579
|
+
},
|
|
14580
|
+
/* @__PURE__ */ React__default.createElement(Icons.add, { className: iconVariants({ variant: "menuItem" }) }),
|
|
14581
|
+
"Insert table"
|
|
14582
|
+
),
|
|
14583
|
+
/* @__PURE__ */ React__default.createElement(
|
|
14584
|
+
DropdownMenuItem,
|
|
14585
|
+
{
|
|
14586
|
+
className: "min-w-[180px]",
|
|
14587
|
+
disabled: !tableSelected,
|
|
14588
|
+
onSelect: () => {
|
|
14589
|
+
deleteTable(editor);
|
|
14590
|
+
focusEditor(editor);
|
|
14591
|
+
}
|
|
14592
|
+
},
|
|
14593
|
+
/* @__PURE__ */ React__default.createElement(Icons.minus, { className: iconVariants({ variant: "menuItem" }) }),
|
|
14594
|
+
"Delete table"
|
|
14595
|
+
),
|
|
14596
|
+
/* @__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(
|
|
14597
|
+
DropdownMenuItem,
|
|
14598
|
+
{
|
|
14599
|
+
className: "min-w-[180px]",
|
|
14600
|
+
disabled: !tableSelected,
|
|
14601
|
+
onSelect: () => {
|
|
14602
|
+
insertTableColumn(editor);
|
|
14603
|
+
focusEditor(editor);
|
|
14604
|
+
}
|
|
14605
|
+
},
|
|
14606
|
+
/* @__PURE__ */ React__default.createElement(Icons.add, { className: iconVariants({ variant: "menuItem" }) }),
|
|
14607
|
+
"Insert column after"
|
|
14608
|
+
), /* @__PURE__ */ React__default.createElement(
|
|
14609
|
+
DropdownMenuItem,
|
|
14610
|
+
{
|
|
14611
|
+
className: "min-w-[180px]",
|
|
14612
|
+
disabled: !enableDeleteColumn,
|
|
14613
|
+
onSelect: () => {
|
|
14614
|
+
deleteColumn(editor);
|
|
14615
|
+
focusEditor(editor);
|
|
14616
|
+
}
|
|
14617
|
+
},
|
|
14618
|
+
/* @__PURE__ */ React__default.createElement(Icons.minus, { className: iconVariants({ variant: "menuItem" }) }),
|
|
14619
|
+
"Delete column"
|
|
14620
|
+
))),
|
|
14621
|
+
/* @__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(
|
|
14622
|
+
DropdownMenuItem,
|
|
14623
|
+
{
|
|
14624
|
+
className: "min-w-[180px]",
|
|
14625
|
+
disabled: !tableSelected,
|
|
14626
|
+
onSelect: () => {
|
|
14627
|
+
insertTableRow(editor);
|
|
14628
|
+
focusEditor(editor);
|
|
14629
|
+
}
|
|
14630
|
+
},
|
|
14631
|
+
/* @__PURE__ */ React__default.createElement(Icons.add, { className: iconVariants({ variant: "menuItem" }) }),
|
|
14632
|
+
"Insert row after"
|
|
14633
|
+
), /* @__PURE__ */ React__default.createElement(
|
|
14634
|
+
DropdownMenuItem,
|
|
14635
|
+
{
|
|
14636
|
+
className: "min-w-[180px]",
|
|
14637
|
+
disabled: !enableDeleteRow,
|
|
14638
|
+
onSelect: () => {
|
|
14639
|
+
deleteRow(editor);
|
|
14640
|
+
focusEditor(editor);
|
|
14641
|
+
}
|
|
14642
|
+
},
|
|
14643
|
+
/* @__PURE__ */ React__default.createElement(Icons.minus, { className: iconVariants({ variant: "menuItem" }) }),
|
|
14644
|
+
"Delete row"
|
|
14645
|
+
)))
|
|
14646
|
+
));
|
|
14647
|
+
}
|
|
13940
14648
|
function TemplatesToolbarButton() {
|
|
13941
14649
|
const { templates } = useToolbarContext();
|
|
13942
|
-
const showEmbed = templates.length > 0;
|
|
13943
14650
|
const editor = useEditorState();
|
|
13944
|
-
if (!showEmbed) {
|
|
13945
|
-
return null;
|
|
13946
|
-
}
|
|
13947
14651
|
return /* @__PURE__ */ React__default.createElement(EmbedButton, { templates, editor });
|
|
13948
14652
|
}
|
|
13949
14653
|
const EmbedButton = ({ editor, templates }) => {
|
|
@@ -13984,100 +14688,112 @@ const EmbedButton = ({ editor, templates }) => {
|
|
|
13984
14688
|
template.label || template.name
|
|
13985
14689
|
))));
|
|
13986
14690
|
};
|
|
13987
|
-
const ICON_WIDTH = 32;
|
|
13988
|
-
const EMBED_ICON_WIDTH = 78;
|
|
13989
|
-
const MD_BREAKPOINT = 768;
|
|
13990
|
-
const useResize = (ref, callback) => {
|
|
13991
|
-
React__default.useEffect(() => {
|
|
13992
|
-
const resizeObserver = new ResizeObserver((entries) => {
|
|
13993
|
-
for (const entry of entries) {
|
|
13994
|
-
callback(entry);
|
|
13995
|
-
}
|
|
13996
|
-
});
|
|
13997
|
-
if (ref.current) {
|
|
13998
|
-
resizeObserver.observe(ref.current);
|
|
13999
|
-
}
|
|
14000
|
-
return () => resizeObserver.disconnect();
|
|
14001
|
-
}, [ref.current]);
|
|
14002
|
-
};
|
|
14003
|
-
function OverflowMenu({
|
|
14004
|
-
children,
|
|
14005
|
-
...props
|
|
14006
|
-
}) {
|
|
14007
|
-
const openState = useOpenState();
|
|
14008
|
-
return /* @__PURE__ */ React__default.createElement(DropdownMenu, { modal: false, ...openState, ...props }, /* @__PURE__ */ React__default.createElement(DropdownMenuTrigger, { asChild: true }, /* @__PURE__ */ React__default.createElement(
|
|
14009
|
-
ToolbarButton,
|
|
14010
|
-
{
|
|
14011
|
-
showArrow: false,
|
|
14012
|
-
className: "lg:min-w-[130px]",
|
|
14013
|
-
isDropdown: true,
|
|
14014
|
-
pressed: openState.open,
|
|
14015
|
-
tooltip: "Headings"
|
|
14016
|
-
},
|
|
14017
|
-
/* @__PURE__ */ React__default.createElement(Icons.overflow, { className: "size-5" })
|
|
14018
|
-
)), /* @__PURE__ */ React__default.createElement(DropdownMenuContent, { align: "start", className: "min-w-0 flex flex-grow" }, children));
|
|
14019
|
-
}
|
|
14020
14691
|
const toolbarItems = {
|
|
14021
14692
|
heading: {
|
|
14022
|
-
label:
|
|
14693
|
+
label: HEADING_LABEL,
|
|
14694
|
+
width: (paragraphIconExists) => paragraphIconExists ? HEADING_ICON_WITH_TEXT : HEADING_ICON_ONLY,
|
|
14695
|
+
// Dynamically handle width based on paragraph icon
|
|
14023
14696
|
Component: /* @__PURE__ */ React__default.createElement(ToolbarGroup, { noSeparator: true }, /* @__PURE__ */ React__default.createElement(HeadingsMenu, null))
|
|
14024
14697
|
},
|
|
14025
14698
|
link: {
|
|
14026
14699
|
label: "Link",
|
|
14700
|
+
width: () => STANDARD_ICON_WIDTH,
|
|
14027
14701
|
Component: /* @__PURE__ */ React__default.createElement(LinkToolbarButton, null)
|
|
14028
14702
|
},
|
|
14029
14703
|
image: {
|
|
14030
14704
|
label: "Image",
|
|
14705
|
+
width: () => STANDARD_ICON_WIDTH,
|
|
14031
14706
|
Component: /* @__PURE__ */ React__default.createElement(ImageToolbarButton, null)
|
|
14032
14707
|
},
|
|
14033
14708
|
quote: {
|
|
14034
14709
|
label: "Quote",
|
|
14710
|
+
width: () => STANDARD_ICON_WIDTH,
|
|
14035
14711
|
Component: /* @__PURE__ */ React__default.createElement(QuoteToolbarButton, { tooltip: "Quote Quote (⌘+⇧+.)" })
|
|
14036
14712
|
},
|
|
14037
14713
|
ul: {
|
|
14038
14714
|
label: "Unordered List",
|
|
14715
|
+
width: () => STANDARD_ICON_WIDTH,
|
|
14039
14716
|
Component: /* @__PURE__ */ React__default.createElement(IndentListToolbarButton, { nodeType: ELEMENT_UL })
|
|
14040
14717
|
},
|
|
14041
14718
|
ol: {
|
|
14042
14719
|
label: "Ordered List",
|
|
14720
|
+
width: () => STANDARD_ICON_WIDTH,
|
|
14043
14721
|
Component: /* @__PURE__ */ React__default.createElement(IndentListToolbarButton, { nodeType: ELEMENT_OL })
|
|
14044
14722
|
},
|
|
14045
14723
|
bold: {
|
|
14046
14724
|
label: "Bold",
|
|
14725
|
+
width: () => STANDARD_ICON_WIDTH,
|
|
14047
14726
|
Component: /* @__PURE__ */ React__default.createElement(MarkToolbarButton, { tooltip: "Bold (⌘+B)", nodeType: MARK_BOLD }, /* @__PURE__ */ React__default.createElement(Icons.bold, null))
|
|
14048
14727
|
},
|
|
14049
14728
|
italic: {
|
|
14050
14729
|
label: "Italic",
|
|
14730
|
+
width: () => STANDARD_ICON_WIDTH,
|
|
14051
14731
|
Component: /* @__PURE__ */ React__default.createElement(MarkToolbarButton, { tooltip: "Italic (⌘+I)", nodeType: MARK_ITALIC }, /* @__PURE__ */ React__default.createElement(Icons.italic, null))
|
|
14052
14732
|
},
|
|
14053
14733
|
code: {
|
|
14054
14734
|
label: "Code",
|
|
14735
|
+
width: () => STANDARD_ICON_WIDTH,
|
|
14055
14736
|
Component: /* @__PURE__ */ React__default.createElement(MarkToolbarButton, { tooltip: "Code (⌘+E)", nodeType: MARK_CODE }, /* @__PURE__ */ React__default.createElement(Icons.code, null))
|
|
14056
14737
|
},
|
|
14057
14738
|
codeBlock: {
|
|
14058
14739
|
label: "Code Block",
|
|
14740
|
+
width: () => STANDARD_ICON_WIDTH,
|
|
14059
14741
|
Component: /* @__PURE__ */ React__default.createElement(CodeBlockToolbarButton, null)
|
|
14060
14742
|
},
|
|
14743
|
+
mermaid: {
|
|
14744
|
+
label: "Mermaid",
|
|
14745
|
+
width: () => STANDARD_ICON_WIDTH,
|
|
14746
|
+
Component: /* @__PURE__ */ React__default.createElement(MermaidToolbarButton, null)
|
|
14747
|
+
},
|
|
14748
|
+
table: {
|
|
14749
|
+
label: "Table",
|
|
14750
|
+
width: () => STANDARD_ICON_WIDTH,
|
|
14751
|
+
Component: /* @__PURE__ */ React__default.createElement(TableDropdownMenu, null)
|
|
14752
|
+
},
|
|
14061
14753
|
raw: {
|
|
14062
14754
|
label: "Raw Markdown",
|
|
14755
|
+
width: () => STANDARD_ICON_WIDTH,
|
|
14063
14756
|
Component: /* @__PURE__ */ React__default.createElement(RawMarkdownToolbarButton, null)
|
|
14064
14757
|
},
|
|
14065
14758
|
embed: {
|
|
14066
14759
|
label: "Templates",
|
|
14760
|
+
width: () => EMBED_ICON_WIDTH,
|
|
14067
14761
|
Component: /* @__PURE__ */ React__default.createElement(TemplatesToolbarButton, null)
|
|
14068
14762
|
}
|
|
14069
14763
|
};
|
|
14070
14764
|
function FixedToolbarButtons() {
|
|
14071
14765
|
const toolbarRef = React__default.useRef(null);
|
|
14072
14766
|
const [itemsShown, setItemsShown] = React__default.useState(11);
|
|
14073
|
-
const { overrides } = useToolbarContext();
|
|
14767
|
+
const { overrides, templates } = useToolbarContext();
|
|
14768
|
+
const showEmbedButton = templates.length > 0;
|
|
14769
|
+
let items2 = overrides === void 0 ? Object.values(toolbarItems) : overrides.map((item) => toolbarItems[item]).filter((item) => item !== void 0);
|
|
14770
|
+
if (!showEmbedButton) {
|
|
14771
|
+
items2 = items2.filter((item) => item.label !== toolbarItems.embed.label);
|
|
14772
|
+
}
|
|
14773
|
+
const editorState = useEditorState();
|
|
14774
|
+
const userInTable = helpers.isNodeActive(editorState, ELEMENT_TABLE);
|
|
14775
|
+
if (userInTable) {
|
|
14776
|
+
items2 = items2.filter((item) => !unsupportedItemsInTable.has(item.label));
|
|
14777
|
+
}
|
|
14074
14778
|
useResize(toolbarRef, (entry) => {
|
|
14075
14779
|
const width = entry.target.getBoundingClientRect().width;
|
|
14076
|
-
const
|
|
14077
|
-
const
|
|
14078
|
-
|
|
14780
|
+
const headingButton = items2.find((item) => item.label === HEADING_LABEL);
|
|
14781
|
+
const headingWidth = headingButton ? headingButton.width(width > CONTAINER_MD_BREAKPOINT) : 0;
|
|
14782
|
+
const availableWidth = width - headingWidth - FLOAT_BUTTON_WIDTH;
|
|
14783
|
+
const { itemFitCount } = items2.reduce(
|
|
14784
|
+
(acc, item) => {
|
|
14785
|
+
if (item.label !== HEADING_LABEL && acc.totalItemsWidth + item.width() <= availableWidth) {
|
|
14786
|
+
return {
|
|
14787
|
+
totalItemsWidth: acc.totalItemsWidth + item.width(),
|
|
14788
|
+
itemFitCount: acc.itemFitCount + 1
|
|
14789
|
+
};
|
|
14790
|
+
}
|
|
14791
|
+
return acc;
|
|
14792
|
+
},
|
|
14793
|
+
{ totalItemsWidth: 0, itemFitCount: 1 }
|
|
14794
|
+
);
|
|
14795
|
+
setItemsShown(itemFitCount);
|
|
14079
14796
|
});
|
|
14080
|
-
const toolbarItemsArray = overrides === void 0 ? Object.values(toolbarItems) : overrides.map((item) => toolbarItems[item]).filter((item) => item !== void 0);
|
|
14081
14797
|
return /* @__PURE__ */ React__default.createElement("div", { className: "w-full overflow-hidden @container/toolbar", ref: toolbarRef }, /* @__PURE__ */ React__default.createElement(
|
|
14082
14798
|
"div",
|
|
14083
14799
|
{
|
|
@@ -14086,7 +14802,7 @@ function FixedToolbarButtons() {
|
|
|
14086
14802
|
transform: "translateX(calc(-1px))"
|
|
14087
14803
|
}
|
|
14088
14804
|
},
|
|
14089
|
-
/* @__PURE__ */ React__default.createElement(React__default.Fragment, null,
|
|
14805
|
+
/* @__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))))
|
|
14090
14806
|
));
|
|
14091
14807
|
}
|
|
14092
14808
|
const FloatingToolbar = withRef(({ children, state, ...props }, componentRef) => {
|
|
@@ -14201,6 +14917,10 @@ function TurnIntoDropdownMenu(props) {
|
|
|
14201
14917
|
const openState = useOpenState();
|
|
14202
14918
|
const selectedItem = items.find((item) => item.value === value) ?? defaultItem;
|
|
14203
14919
|
const { icon: SelectedItemIcon, label: selectedItemLabel } = selectedItem;
|
|
14920
|
+
const editorState = useEditorState();
|
|
14921
|
+
const userInTable = helpers.isNodeActive(editorState, ELEMENT_TABLE$1);
|
|
14922
|
+
if (userInTable)
|
|
14923
|
+
return null;
|
|
14204
14924
|
return /* @__PURE__ */ React__default.createElement(DropdownMenu, { modal: false, ...openState, ...props }, /* @__PURE__ */ React__default.createElement(DropdownMenuTrigger, { asChild: true }, /* @__PURE__ */ React__default.createElement(
|
|
14205
14925
|
ToolbarButton,
|
|
14206
14926
|
{
|
|
@@ -14242,49 +14962,6 @@ function TurnIntoDropdownMenu(props) {
|
|
|
14242
14962
|
function FloatingToolbarButtons() {
|
|
14243
14963
|
return /* @__PURE__ */ React__default.createElement(React__default.Fragment, null, /* @__PURE__ */ React__default.createElement(TurnIntoDropdownMenu, null));
|
|
14244
14964
|
}
|
|
14245
|
-
const buttonVariants = cva(
|
|
14246
|
-
"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",
|
|
14247
|
-
{
|
|
14248
|
-
defaultVariants: {
|
|
14249
|
-
size: "default",
|
|
14250
|
-
variant: "default"
|
|
14251
|
-
},
|
|
14252
|
-
variants: {
|
|
14253
|
-
isMenu: {
|
|
14254
|
-
true: "h-auto w-full cursor-pointer justify-start"
|
|
14255
|
-
},
|
|
14256
|
-
size: {
|
|
14257
|
-
default: "h-10 px-4 py-2",
|
|
14258
|
-
icon: "size-10",
|
|
14259
|
-
lg: "h-11 rounded-md px-8",
|
|
14260
|
-
none: "",
|
|
14261
|
-
sm: "h-9 rounded-md px-3",
|
|
14262
|
-
sms: "size-9 rounded-md px-0",
|
|
14263
|
-
xs: "h-8 rounded-md px-3"
|
|
14264
|
-
},
|
|
14265
|
-
variant: {
|
|
14266
|
-
default: "bg-primary text-primary-foreground hover:bg-primary/90",
|
|
14267
|
-
destructive: "bg-destructive text-destructive-foreground hover:bg-destructive/90",
|
|
14268
|
-
ghost: "hover:bg-accent hover:text-accent-foreground",
|
|
14269
|
-
inlineLink: "text-base text-primary underline underline-offset-4",
|
|
14270
|
-
link: "text-primary underline-offset-4 hover:underline",
|
|
14271
|
-
outline: "border border-input bg-background hover:bg-accent hover:text-accent-foreground",
|
|
14272
|
-
secondary: "bg-secondary text-secondary-foreground hover:bg-secondary/80"
|
|
14273
|
-
}
|
|
14274
|
-
}
|
|
14275
|
-
}
|
|
14276
|
-
);
|
|
14277
|
-
withRef(({ asChild = false, className, isMenu, size, variant, ...props }, ref) => {
|
|
14278
|
-
const Comp = asChild ? Slot : "button";
|
|
14279
|
-
return /* @__PURE__ */ React.createElement(
|
|
14280
|
-
Comp,
|
|
14281
|
-
{
|
|
14282
|
-
className: cn$1(buttonVariants({ className, isMenu, size, variant })),
|
|
14283
|
-
ref,
|
|
14284
|
-
...props
|
|
14285
|
-
}
|
|
14286
|
-
);
|
|
14287
|
-
});
|
|
14288
14965
|
const inputVariants = cva(
|
|
14289
14966
|
"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",
|
|
14290
14967
|
{
|
|
@@ -14305,22 +14982,6 @@ const inputVariants = cva(
|
|
|
14305
14982
|
}
|
|
14306
14983
|
);
|
|
14307
14984
|
withVariants("input", inputVariants, ["variant", "h"]);
|
|
14308
|
-
const popoverVariants = cva(
|
|
14309
|
-
"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"
|
|
14310
|
-
);
|
|
14311
|
-
withRef(
|
|
14312
|
-
({ align = "center", className, sideOffset = 4, style, ...props }, ref) => /* @__PURE__ */ React.createElement(PopoverPrimitive.Portal, null, /* @__PURE__ */ React.createElement(
|
|
14313
|
-
PopoverPrimitive.Content,
|
|
14314
|
-
{
|
|
14315
|
-
align,
|
|
14316
|
-
className: cn$1(popoverVariants(), className),
|
|
14317
|
-
ref,
|
|
14318
|
-
sideOffset,
|
|
14319
|
-
style: { zIndex: 1e3, ...style },
|
|
14320
|
-
...props
|
|
14321
|
-
}
|
|
14322
|
-
))
|
|
14323
|
-
);
|
|
14324
14985
|
const floatingOptions = {
|
|
14325
14986
|
middleware: [
|
|
14326
14987
|
offset(12),
|
|
@@ -14380,7 +15041,7 @@ function LinkFloatingToolbar({ state }) {
|
|
|
14380
15041
|
const editContent = editState.isEditing ? input : /* @__PURE__ */ React__default.createElement("div", { className: "box-content flex h-9 items-center gap-1" }, /* @__PURE__ */ React__default.createElement(
|
|
14381
15042
|
"button",
|
|
14382
15043
|
{
|
|
14383
|
-
className: buttonVariants({ size: "sm", variant: "ghost" }),
|
|
15044
|
+
className: buttonVariants$1({ size: "sm", variant: "ghost" }),
|
|
14384
15045
|
type: "button",
|
|
14385
15046
|
...editButtonProps
|
|
14386
15047
|
},
|
|
@@ -14388,7 +15049,7 @@ function LinkFloatingToolbar({ state }) {
|
|
|
14388
15049
|
), /* @__PURE__ */ React__default.createElement(Separator, { orientation: "vertical" }), /* @__PURE__ */ React__default.createElement(
|
|
14389
15050
|
LinkOpenButton,
|
|
14390
15051
|
{
|
|
14391
|
-
className: buttonVariants({
|
|
15052
|
+
className: buttonVariants$1({
|
|
14392
15053
|
size: "sms",
|
|
14393
15054
|
variant: "ghost"
|
|
14394
15055
|
})
|
|
@@ -14397,7 +15058,7 @@ function LinkFloatingToolbar({ state }) {
|
|
|
14397
15058
|
), /* @__PURE__ */ React__default.createElement(Separator, { orientation: "vertical" }), /* @__PURE__ */ React__default.createElement(
|
|
14398
15059
|
"button",
|
|
14399
15060
|
{
|
|
14400
|
-
className: buttonVariants({
|
|
15061
|
+
className: buttonVariants$1({
|
|
14401
15062
|
size: "sms",
|
|
14402
15063
|
variant: "ghost"
|
|
14403
15064
|
}),
|
|
@@ -14471,6 +15132,7 @@ const RichEditor = (props) => {
|
|
|
14471
15132
|
createMdxBlockPlugin(),
|
|
14472
15133
|
createMdxInlinePlugin(),
|
|
14473
15134
|
createImgPlugin(),
|
|
15135
|
+
createMermaidPlugin(),
|
|
14474
15136
|
createInvalidMarkdownPlugin(),
|
|
14475
15137
|
createLinkPlugin({
|
|
14476
15138
|
options: {
|
|
@@ -29478,6 +30140,7 @@ class TinaAdminApi {
|
|
|
29478
30140
|
relativePath
|
|
29479
30141
|
filename
|
|
29480
30142
|
extension
|
|
30143
|
+
hasReferences
|
|
29481
30144
|
}
|
|
29482
30145
|
}
|
|
29483
30146
|
}
|
|
@@ -29569,6 +30232,9 @@ class TinaAdminApi {
|
|
|
29569
30232
|
document(collection:$collection, relativePath:$relativePath) {
|
|
29570
30233
|
... on Document {
|
|
29571
30234
|
_values
|
|
30235
|
+
_sys {
|
|
30236
|
+
hasReferences
|
|
30237
|
+
}
|
|
29572
30238
|
}
|
|
29573
30239
|
}
|
|
29574
30240
|
}`;
|
|
@@ -31295,6 +31961,23 @@ const CollectionListPage = () => {
|
|
|
31295
31961
|
DeleteModal,
|
|
31296
31962
|
{
|
|
31297
31963
|
filename: vars.relativePath,
|
|
31964
|
+
checkRefsFunc: async () => {
|
|
31965
|
+
var _a2, _b2;
|
|
31966
|
+
try {
|
|
31967
|
+
const doc = await admin.fetchDocument(
|
|
31968
|
+
collection.name,
|
|
31969
|
+
vars.relativePath,
|
|
31970
|
+
true
|
|
31971
|
+
);
|
|
31972
|
+
return (_b2 = (_a2 = doc == null ? void 0 : doc.document) == null ? void 0 : _a2._sys) == null ? void 0 : _b2.hasReferences;
|
|
31973
|
+
} catch (error) {
|
|
31974
|
+
cms.alerts.error(
|
|
31975
|
+
"Document was not found, ask a developer for help or check the console for an error message"
|
|
31976
|
+
);
|
|
31977
|
+
console.error(error);
|
|
31978
|
+
throw error;
|
|
31979
|
+
}
|
|
31980
|
+
},
|
|
31298
31981
|
deleteFunc: async () => {
|
|
31299
31982
|
try {
|
|
31300
31983
|
await admin.deleteDocument(vars);
|
|
@@ -31303,6 +31986,12 @@ const CollectionListPage = () => {
|
|
|
31303
31986
|
);
|
|
31304
31987
|
reFetchCollection();
|
|
31305
31988
|
} catch (error) {
|
|
31989
|
+
if (error.message.indexOf("has references")) {
|
|
31990
|
+
cms.alerts.error(
|
|
31991
|
+
error.message.split("\n ").filter(Boolean)[1]
|
|
31992
|
+
);
|
|
31993
|
+
return;
|
|
31994
|
+
}
|
|
31306
31995
|
cms.alerts.warn(
|
|
31307
31996
|
"Document was not deleted, ask a developer for help or check the console for an error message"
|
|
31308
31997
|
);
|
|
@@ -31354,6 +32043,12 @@ const CollectionListPage = () => {
|
|
|
31354
32043
|
cms.alerts.info("Document was successfully renamed");
|
|
31355
32044
|
reFetchCollection();
|
|
31356
32045
|
} catch (error) {
|
|
32046
|
+
if (error.message.indexOf("has references")) {
|
|
32047
|
+
cms.alerts.error(
|
|
32048
|
+
error.message.split("\n ").filter(Boolean)[1]
|
|
32049
|
+
);
|
|
32050
|
+
return;
|
|
32051
|
+
}
|
|
31357
32052
|
cms.alerts.warn(
|
|
31358
32053
|
"Document was not renamed, ask a developer for help or check the console for an error message"
|
|
31359
32054
|
);
|
|
@@ -31827,8 +32522,19 @@ const Breadcrumb = ({ folder, navigate, collectionName }) => {
|
|
|
31827
32522
|
const NoDocumentsPlaceholder = () => {
|
|
31828
32523
|
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."));
|
|
31829
32524
|
};
|
|
31830
|
-
const DeleteModal = ({
|
|
31831
|
-
|
|
32525
|
+
const DeleteModal = ({
|
|
32526
|
+
close: close2,
|
|
32527
|
+
deleteFunc,
|
|
32528
|
+
checkRefsFunc,
|
|
32529
|
+
filename
|
|
32530
|
+
}) => {
|
|
32531
|
+
const [hasRefs, setHasRefs] = React__default.useState();
|
|
32532
|
+
useEffect(() => {
|
|
32533
|
+
checkRefsFunc().then((result) => {
|
|
32534
|
+
setHasRefs(result);
|
|
32535
|
+
});
|
|
32536
|
+
}, [filename, checkRefsFunc]);
|
|
32537
|
+
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(
|
|
31832
32538
|
Button$1,
|
|
31833
32539
|
{
|
|
31834
32540
|
style: { flexGrow: 3 },
|
|
@@ -33190,5 +33896,6 @@ export {
|
|
|
33190
33896
|
useScreenPlugin,
|
|
33191
33897
|
useTinaAuthRedirect,
|
|
33192
33898
|
wrapFieldWithError,
|
|
33899
|
+
wrapFieldWithNoHeader,
|
|
33193
33900
|
wrapFieldsWithMeta
|
|
33194
33901
|
};
|