tinacms 0.0.0-d69e892-20241003042309 → 0.0.0-e0ddb8c-20241004065742
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/client.js +1 -1
- package/dist/client.mjs +1 -1
- package/dist/index.js +182 -6
- package/dist/index.mjs +183 -6
- package/dist/rich-text/index.d.ts +3 -0
- package/dist/rich-text/index.js +3 -1
- package/dist/rich-text/index.mjs +3 -1
- package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/components/plate-ui/icons.d.ts +2 -0
- package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/components/plate-ui/mermaid-element.d.ts +11 -0
- package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/components/plate-ui/mermaid-toolbar-button.d.ts +20 -0
- package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/components/plate-ui/text-area.d.ts +5 -0
- package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/hooks/use-mermaid-element.d.ts +3 -0
- package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/plugins/custom/mermaid-plugin.d.ts +2 -0
- package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/plugins/ui/code-block/index.d.ts +4 -2
- package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/plugins/ui/components.d.ts +10 -0
- package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/toolbar/toolbar-overrides.d.ts +1 -1
- package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/toolbar/toolbar-provider.d.ts +1 -1
- package/package.json +5 -4
package/dist/client.js
CHANGED
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
return;
|
|
27
27
|
}
|
|
28
28
|
try {
|
|
29
|
-
if (this.cacheDir && window ===
|
|
29
|
+
if (this.cacheDir && typeof window === "undefined" && typeof require !== "undefined") {
|
|
30
30
|
const { NodeCache: NodeCache2 } = await Promise.resolve().then(() => nodeCache);
|
|
31
31
|
this.cache = await NodeCache2(this.cacheDir);
|
|
32
32
|
}
|
package/dist/client.mjs
CHANGED
|
@@ -23,7 +23,7 @@ class TinaClient {
|
|
|
23
23
|
return;
|
|
24
24
|
}
|
|
25
25
|
try {
|
|
26
|
-
if (this.cacheDir && window ===
|
|
26
|
+
if (this.cacheDir && typeof window === "undefined" && typeof require !== "undefined") {
|
|
27
27
|
const { NodeCache } = await import("./node-cache-7fa2452c.mjs");
|
|
28
28
|
this.cache = await NodeCache(this.cacheDir);
|
|
29
29
|
}
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
(function(global, factory) {
|
|
2
|
-
typeof exports === "object" && typeof module !== "undefined" ? factory(exports, require("zod"), require("react"), require("react-dom"), require("@udecode/plate"), require("slate-react"), require("@udecode/plate-slash-command"), require("@udecode/cn"), require("@udecode/plate-common"), require("@udecode/plate-heading"), require("class-variance-authority"), require("lucide-react"), require("@ariakit/react"), require("@udecode/plate-combobox"), require("@udecode/plate-code-block"), require("@monaco-editor/react"), require("@headlessui/react"), require("final-form-arrays"), require("final-form-set-field-data"), require("final-form"), require("react-final-form"), require("prop-types"), require("react-beautiful-dnd"), require("@radix-ui/react-popover"), require("react-color"), require("color-string"), require("react-dropzone"), require("@radix-ui/react-slot"), require("clsx"), require("tailwind-merge"), require("cmdk"), require("is-hotkey"), require("slate"), require("lodash.get"), require("moment"), require("date-fns"), require("@udecode/plate-link"), require("@radix-ui/react-toolbar"), require("@radix-ui/react-separator"), require("@radix-ui/react-tooltip"), require("@udecode/plate-paragraph"), require("@radix-ui/react-dropdown-menu"), require("@udecode/plate-block-quote"), require("@udecode/plate-floating"), require("@react-hook/window-size"), require("graphql"), require("graphql-tag"), require("@tinacms/schema-tools"), require("yup"), require("@graphql-inspector/core"), require("react-router-dom"), require("@tinacms/mdx")) : typeof define === "function" && define.amd ? define(["exports", "zod", "react", "react-dom", "@udecode/plate", "slate-react", "@udecode/plate-slash-command", "@udecode/cn", "@udecode/plate-common", "@udecode/plate-heading", "class-variance-authority", "lucide-react", "@ariakit/react", "@udecode/plate-combobox", "@udecode/plate-code-block", "@monaco-editor/react", "@headlessui/react", "final-form-arrays", "final-form-set-field-data", "final-form", "react-final-form", "prop-types", "react-beautiful-dnd", "@radix-ui/react-popover", "react-color", "color-string", "react-dropzone", "@radix-ui/react-slot", "clsx", "tailwind-merge", "cmdk", "is-hotkey", "slate", "lodash.get", "moment", "date-fns", "@udecode/plate-link", "@radix-ui/react-toolbar", "@radix-ui/react-separator", "@radix-ui/react-tooltip", "@udecode/plate-paragraph", "@radix-ui/react-dropdown-menu", "@udecode/plate-block-quote", "@udecode/plate-floating", "@react-hook/window-size", "graphql", "graphql-tag", "@tinacms/schema-tools", "yup", "@graphql-inspector/core", "react-router-dom", "@tinacms/mdx"], factory) : (global = typeof globalThis !== "undefined" ? globalThis : global || self, factory(global.tinacms = {}, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP));
|
|
3
|
-
})(this, function(exports2, zod, React, reactDom, plate, slateReact, plateSlashCommand, cn$1, plateCommon, plateHeading, classVarianceAuthority, lucideReact, react, plateCombobox, plateCodeBlock, MonacoEditor, react$1, arrayMutators, setFieldData, finalForm, reactFinalForm, PropTypes, reactBeautifulDnd, PopoverPrimitive, pkg$1, pkg, dropzone, reactSlot, clsx, tailwindMerge, cmdk, isHotkey, slate, get, moment, dateFns, plateLink, ToolbarPrimitive, SeparatorPrimitive, TooltipPrimitive, plateParagraph, DropdownMenuPrimitive, plateBlockQuote, plateFloating, windowSize, graphql, gql, schemaTools, yup, core, reactRouterDom, mdx) {
|
|
2
|
+
typeof exports === "object" && typeof module !== "undefined" ? factory(exports, require("zod"), require("react"), require("react-dom"), require("@udecode/plate"), require("slate-react"), require("@udecode/plate-slash-command"), require("@udecode/cn"), require("@udecode/plate-common"), require("@udecode/plate-heading"), require("class-variance-authority"), require("lucide-react"), require("@ariakit/react"), require("@udecode/plate-combobox"), require("@udecode/plate-code-block"), require("@monaco-editor/react"), require("@headlessui/react"), require("mermaid"), require("final-form-arrays"), require("final-form-set-field-data"), require("final-form"), require("react-final-form"), require("prop-types"), require("react-beautiful-dnd"), require("@radix-ui/react-popover"), require("react-color"), require("color-string"), require("react-dropzone"), require("@radix-ui/react-slot"), require("clsx"), require("tailwind-merge"), require("cmdk"), require("is-hotkey"), require("slate"), require("lodash.get"), require("moment"), require("date-fns"), require("@udecode/plate-link"), require("@radix-ui/react-toolbar"), require("@radix-ui/react-separator"), require("@radix-ui/react-tooltip"), require("@udecode/plate-paragraph"), require("@radix-ui/react-dropdown-menu"), require("@udecode/plate-block-quote"), require("@udecode/plate-floating"), require("@react-hook/window-size"), require("graphql"), require("graphql-tag"), require("@tinacms/schema-tools"), require("yup"), require("@graphql-inspector/core"), require("react-router-dom"), require("@tinacms/mdx")) : typeof define === "function" && define.amd ? define(["exports", "zod", "react", "react-dom", "@udecode/plate", "slate-react", "@udecode/plate-slash-command", "@udecode/cn", "@udecode/plate-common", "@udecode/plate-heading", "class-variance-authority", "lucide-react", "@ariakit/react", "@udecode/plate-combobox", "@udecode/plate-code-block", "@monaco-editor/react", "@headlessui/react", "mermaid", "final-form-arrays", "final-form-set-field-data", "final-form", "react-final-form", "prop-types", "react-beautiful-dnd", "@radix-ui/react-popover", "react-color", "color-string", "react-dropzone", "@radix-ui/react-slot", "clsx", "tailwind-merge", "cmdk", "is-hotkey", "slate", "lodash.get", "moment", "date-fns", "@udecode/plate-link", "@radix-ui/react-toolbar", "@radix-ui/react-separator", "@radix-ui/react-tooltip", "@udecode/plate-paragraph", "@radix-ui/react-dropdown-menu", "@udecode/plate-block-quote", "@udecode/plate-floating", "@react-hook/window-size", "graphql", "graphql-tag", "@tinacms/schema-tools", "yup", "@graphql-inspector/core", "react-router-dom", "@tinacms/mdx"], factory) : (global = typeof globalThis !== "undefined" ? globalThis : global || self, factory(global.tinacms = {}, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP));
|
|
3
|
+
})(this, function(exports2, zod, React, reactDom, plate, slateReact, plateSlashCommand, cn$1, plateCommon, plateHeading, classVarianceAuthority, lucideReact, react, plateCombobox, plateCodeBlock, MonacoEditor, react$1, mermaid, arrayMutators, setFieldData, finalForm, reactFinalForm, PropTypes, reactBeautifulDnd, PopoverPrimitive, pkg$1, pkg, dropzone, reactSlot, clsx, tailwindMerge, cmdk, isHotkey, slate, get, moment, dateFns, plateLink, ToolbarPrimitive, SeparatorPrimitive, TooltipPrimitive, plateParagraph, DropdownMenuPrimitive, plateBlockQuote, plateFloating, windowSize, graphql, gql, schemaTools, yup, core, reactRouterDom, mdx) {
|
|
4
4
|
"use strict";var __defProp = Object.defineProperty;
|
|
5
5
|
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
6
6
|
var __publicField = (obj, key, value) => {
|
|
@@ -909,6 +909,29 @@ var __publicField = (obj, key, value) => {
|
|
|
909
909
|
/* @__PURE__ */ React.createElement("path", { d: "M22.27 19.385H1.73A1.73 1.73 0 010 17.655V6.345a1.73 1.73 0 011.73-1.73h20.54A1.73 1.73 0 0124 6.345v11.308a1.73 1.73 0 01-1.73 1.731zM5.769 15.923v-4.5l2.308 2.885 2.307-2.885v4.5h2.308V8.078h-2.308l-2.307 2.885-2.308-2.885H3.46v7.847zM21.232 12h-2.309V8.077h-2.307V12h-2.308l3.461 4.039z" })
|
|
910
910
|
);
|
|
911
911
|
};
|
|
912
|
+
const MermaidIcon = () => /* @__PURE__ */ React.createElement(
|
|
913
|
+
"svg",
|
|
914
|
+
{
|
|
915
|
+
width: "100%",
|
|
916
|
+
height: "100%",
|
|
917
|
+
viewBox: "0 0 491 491",
|
|
918
|
+
version: "1.1",
|
|
919
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
920
|
+
fillRule: "evenodd",
|
|
921
|
+
clipRule: "evenodd",
|
|
922
|
+
strokeLinejoin: "round",
|
|
923
|
+
strokeMiterlimit: 2
|
|
924
|
+
},
|
|
925
|
+
/* @__PURE__ */ React.createElement("path", { d: "M490.16,84.61C490.16,37.912 452.248,0 405.55,0L84.61,0C37.912,0 0,37.912 0,84.61L0,405.55C0,452.248 37.912,490.16 84.61,490.16L405.55,490.16C452.248,490.16 490.16,452.248 490.16,405.55L490.16,84.61Z" }),
|
|
926
|
+
/* @__PURE__ */ React.createElement(
|
|
927
|
+
"path",
|
|
928
|
+
{
|
|
929
|
+
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",
|
|
930
|
+
fill: "white",
|
|
931
|
+
fillRule: "nonzero"
|
|
932
|
+
}
|
|
933
|
+
)
|
|
934
|
+
);
|
|
912
935
|
const borderAll = (props) => /* @__PURE__ */ React.createElement(
|
|
913
936
|
"svg",
|
|
914
937
|
{
|
|
@@ -1149,6 +1172,7 @@ var __publicField = (obj, key, value) => {
|
|
|
1149
1172
|
clear: lucideReact.X,
|
|
1150
1173
|
close: lucideReact.X,
|
|
1151
1174
|
// code: Code2,
|
|
1175
|
+
paint: lucideReact.PaintBucket,
|
|
1152
1176
|
codeblock: lucideReact.FileCode,
|
|
1153
1177
|
color: lucideReact.Baseline,
|
|
1154
1178
|
column: lucideReact.RectangleVertical,
|
|
@@ -1174,6 +1198,7 @@ var __publicField = (obj, key, value) => {
|
|
|
1174
1198
|
lineHeight: lucideReact.WrapText,
|
|
1175
1199
|
// link: Link2,
|
|
1176
1200
|
minus: lucideReact.Minus,
|
|
1201
|
+
mermaid: MermaidIcon,
|
|
1177
1202
|
more: lucideReact.MoreHorizontal,
|
|
1178
1203
|
// ol: ListOrdered,
|
|
1179
1204
|
outdent: lucideReact.Outdent,
|
|
@@ -1895,18 +1920,21 @@ var __publicField = (obj, key, value) => {
|
|
|
1895
1920
|
}
|
|
1896
1921
|
}
|
|
1897
1922
|
};
|
|
1923
|
+
const MINIMUM_HEIGHT = 75;
|
|
1898
1924
|
const CodeBlock = ({
|
|
1899
1925
|
attributes,
|
|
1900
1926
|
editor,
|
|
1901
1927
|
element,
|
|
1902
1928
|
language: restrictLanguage,
|
|
1929
|
+
onChangeCallback,
|
|
1930
|
+
defaultValue,
|
|
1903
1931
|
...props
|
|
1904
1932
|
}) => {
|
|
1905
1933
|
const [navigateAway, setNavigateAway] = React.useState(null);
|
|
1906
1934
|
const monaco = MonacoEditor.useMonaco();
|
|
1907
1935
|
const monacoEditorRef = React.useRef(null);
|
|
1908
1936
|
const selected = slateReact.useSelected();
|
|
1909
|
-
const [height, setHeight] = React.useState(
|
|
1937
|
+
const [height, setHeight] = React.useState(MINIMUM_HEIGHT);
|
|
1910
1938
|
React.useEffect(() => {
|
|
1911
1939
|
if (selected && plateCommon.isCollapsed(editor.selection)) {
|
|
1912
1940
|
retryFocus(monacoEditorRef);
|
|
@@ -2050,9 +2078,12 @@ var __publicField = (obj, key, value) => {
|
|
|
2050
2078
|
function handleEditorDidMount(monacoEditor, monaco2) {
|
|
2051
2079
|
monacoEditorRef.current = monacoEditor;
|
|
2052
2080
|
monacoEditor.onDidContentSizeChange(() => {
|
|
2053
|
-
setHeight(
|
|
2081
|
+
setHeight(
|
|
2082
|
+
monacoEditor.getContentHeight() > MINIMUM_HEIGHT ? monacoEditor.getContentHeight() : MINIMUM_HEIGHT
|
|
2083
|
+
);
|
|
2054
2084
|
monacoEditor.layout();
|
|
2055
2085
|
});
|
|
2086
|
+
plateCommon.setNodes(editor, { value: defaultValue, lang: language });
|
|
2056
2087
|
monacoEditor.addCommand(monaco2.KeyMod.Shift | monaco2.KeyCode.Enter, () => {
|
|
2057
2088
|
if (monacoEditor.hasTextFocus()) {
|
|
2058
2089
|
setNavigateAway("insertNext");
|
|
@@ -2134,6 +2165,7 @@ var __publicField = (obj, key, value) => {
|
|
|
2134
2165
|
language: String(language),
|
|
2135
2166
|
value: String(element.value),
|
|
2136
2167
|
onChange: (value2) => {
|
|
2168
|
+
onChangeCallback == null ? void 0 : onChangeCallback(value2);
|
|
2137
2169
|
plateCommon.setNodes(editor, { value: value2, lang: language });
|
|
2138
2170
|
}
|
|
2139
2171
|
}
|
|
@@ -2155,6 +2187,110 @@ var __publicField = (obj, key, value) => {
|
|
|
2155
2187
|
);
|
|
2156
2188
|
}
|
|
2157
2189
|
);
|
|
2190
|
+
const ELEMENT_MERMAID = "mermaid";
|
|
2191
|
+
const createMermaidPlugin = plateCommon.createPluginFactory({
|
|
2192
|
+
isElement: true,
|
|
2193
|
+
isVoid: true,
|
|
2194
|
+
isInline: false,
|
|
2195
|
+
key: ELEMENT_MERMAID
|
|
2196
|
+
});
|
|
2197
|
+
const useMermaidElement = () => {
|
|
2198
|
+
const mermaidRef = React.useRef(null);
|
|
2199
|
+
React.useEffect(() => {
|
|
2200
|
+
if (mermaidRef.current) {
|
|
2201
|
+
mermaid.initialize({ startOnLoad: true });
|
|
2202
|
+
mermaid.run();
|
|
2203
|
+
}
|
|
2204
|
+
}, []);
|
|
2205
|
+
return {
|
|
2206
|
+
mermaidRef
|
|
2207
|
+
};
|
|
2208
|
+
};
|
|
2209
|
+
const LightModeComponent = ({ onToggleMode }) => {
|
|
2210
|
+
const [isLightMode, setIsLightMode] = React.useState(true);
|
|
2211
|
+
const handleToggle = (e) => {
|
|
2212
|
+
e.preventDefault();
|
|
2213
|
+
setIsLightMode((prevMode) => !prevMode);
|
|
2214
|
+
};
|
|
2215
|
+
React.useEffect(() => {
|
|
2216
|
+
const modeClass = isLightMode ? "not-tina-prose" : "";
|
|
2217
|
+
if (onToggleMode) {
|
|
2218
|
+
onToggleMode(modeClass);
|
|
2219
|
+
}
|
|
2220
|
+
}, [isLightMode, onToggleMode]);
|
|
2221
|
+
return /* @__PURE__ */ React.createElement("div", null, /* @__PURE__ */ React.createElement(
|
|
2222
|
+
"button",
|
|
2223
|
+
{
|
|
2224
|
+
type: "button",
|
|
2225
|
+
onClick: handleToggle,
|
|
2226
|
+
className: "flex items-center w-5 h-5 cursor-pointer"
|
|
2227
|
+
},
|
|
2228
|
+
isLightMode ? /* @__PURE__ */ React.createElement(lucideReact.Moon, { className: "fill-white" }) : /* @__PURE__ */ React.createElement(lucideReact.SunMoon, { className: "fill-white" })
|
|
2229
|
+
));
|
|
2230
|
+
};
|
|
2231
|
+
const MermaidElementWithRef = ({ config, lightMode }) => {
|
|
2232
|
+
const { mermaidRef } = useMermaidElement();
|
|
2233
|
+
return /* @__PURE__ */ React.createElement("div", { contentEditable: false, className: "border-border border-b" }, /* @__PURE__ */ React.createElement("div", { ref: mermaidRef }, /* @__PURE__ */ React.createElement("pre", { className: `${lightMode} mermaid` }, config)));
|
|
2234
|
+
};
|
|
2235
|
+
const Bubble = ({ children }) => {
|
|
2236
|
+
return /* @__PURE__ */ React.createElement("div", { className: "bg-blue-600 rounded-full p-2 transition-transform duration-200 ease-in-out hover:scale-110" }, children);
|
|
2237
|
+
};
|
|
2238
|
+
const DEFAULT_MERMAID_CONFIG = `%% This won't render without implementing a rendering engine <TODO: Link to tina docs>
|
|
2239
|
+
flowchart TD
|
|
2240
|
+
id1(this is an example flow diagram)
|
|
2241
|
+
--> id2(modify me to see changes!)
|
|
2242
|
+
id2
|
|
2243
|
+
--> id3(Click the top button to preview the changes)
|
|
2244
|
+
--> id4(Learn about mermaid diagrams @ mermaid.js.org)`;
|
|
2245
|
+
const MermaidElement = cn$1.withRef(
|
|
2246
|
+
({ children, nodeProps, element, ...props }, ref) => {
|
|
2247
|
+
const [mermaidConfig, setMermaidConfig] = React.useState(
|
|
2248
|
+
element.value || DEFAULT_MERMAID_CONFIG
|
|
2249
|
+
);
|
|
2250
|
+
const [isEditing, setIsEditing] = React.useState(
|
|
2251
|
+
mermaidConfig === DEFAULT_MERMAID_CONFIG || false
|
|
2252
|
+
);
|
|
2253
|
+
const [lightModeClass, setLightModeClass] = React.useState("");
|
|
2254
|
+
const node = {
|
|
2255
|
+
type: ELEMENT_MERMAID,
|
|
2256
|
+
value: mermaidConfig,
|
|
2257
|
+
children: [{ type: "text", text: "" }]
|
|
2258
|
+
};
|
|
2259
|
+
return /* @__PURE__ */ React.createElement(plateCommon.PlateElement, { element, ref, ...props }, /* @__PURE__ */ React.createElement("div", { className: "relative group" }, /* @__PURE__ */ React.createElement("div", { className: "absolute top-2 right-2 z-10 space-y-2 opacity-0 group-hover:opacity-100 transition-opacity duration-200 ease-in-out" }, /* @__PURE__ */ React.createElement(Bubble, null, isEditing ? /* @__PURE__ */ React.createElement(
|
|
2260
|
+
lucideReact.Eye,
|
|
2261
|
+
{
|
|
2262
|
+
className: "w-5 h-5 fill-white cursor-pointer",
|
|
2263
|
+
onClick: () => {
|
|
2264
|
+
setIsEditing(!isEditing);
|
|
2265
|
+
}
|
|
2266
|
+
}
|
|
2267
|
+
) : /* @__PURE__ */ React.createElement(
|
|
2268
|
+
lucideReact.SquarePen,
|
|
2269
|
+
{
|
|
2270
|
+
className: "w-5 h-5 fill-white cursor-pointer",
|
|
2271
|
+
onClick: () => {
|
|
2272
|
+
setIsEditing(!isEditing);
|
|
2273
|
+
}
|
|
2274
|
+
}
|
|
2275
|
+
)), /* @__PURE__ */ React.createElement(Bubble, null, /* @__PURE__ */ React.createElement(LightModeComponent, { onToggleMode: (v) => setLightModeClass(v) }))), isEditing ? /* @__PURE__ */ React.createElement(
|
|
2276
|
+
CodeBlock,
|
|
2277
|
+
{
|
|
2278
|
+
children: "",
|
|
2279
|
+
language: "yaml",
|
|
2280
|
+
...props,
|
|
2281
|
+
element: node,
|
|
2282
|
+
defaultValue: mermaidConfig,
|
|
2283
|
+
onChangeCallback: (value) => setMermaidConfig(value)
|
|
2284
|
+
}
|
|
2285
|
+
) : /* @__PURE__ */ React.createElement(
|
|
2286
|
+
MermaidElementWithRef,
|
|
2287
|
+
{
|
|
2288
|
+
config: mermaidConfig,
|
|
2289
|
+
lightMode: lightModeClass
|
|
2290
|
+
}
|
|
2291
|
+
), children));
|
|
2292
|
+
}
|
|
2293
|
+
);
|
|
2158
2294
|
const blockClasses = "mt-0.5";
|
|
2159
2295
|
const headerClasses = "font-normal";
|
|
2160
2296
|
const Components = () => {
|
|
@@ -2260,6 +2396,7 @@ var __publicField = (obj, key, value) => {
|
|
|
2260
2396
|
}
|
|
2261
2397
|
)
|
|
2262
2398
|
),
|
|
2399
|
+
[ELEMENT_MERMAID]: MermaidElement,
|
|
2263
2400
|
[plate.ELEMENT_BLOCKQUOTE]: BlockquoteElement,
|
|
2264
2401
|
[plate.ELEMENT_CODE_BLOCK]: CodeBlockElement,
|
|
2265
2402
|
[plate.ELEMENT_CODE_LINE]: CodeLineElement,
|
|
@@ -2750,7 +2887,9 @@ var __publicField = (obj, key, value) => {
|
|
|
2750
2887
|
{
|
|
2751
2888
|
type: "string",
|
|
2752
2889
|
label: "Caption",
|
|
2753
|
-
name: [templateName.replace(/\.props$/, ""), "caption"].join(
|
|
2890
|
+
name: [templateName.replace(/\.props$/, ""), "caption"].join(
|
|
2891
|
+
"."
|
|
2892
|
+
),
|
|
2754
2893
|
component: "text"
|
|
2755
2894
|
}
|
|
2756
2895
|
]
|
|
@@ -13424,7 +13563,7 @@ var __publicField = (obj, key, value) => {
|
|
|
13424
13563
|
cn$1.withProps(TooltipPrimitive__namespace.Content, {
|
|
13425
13564
|
sideOffset: 4
|
|
13426
13565
|
}),
|
|
13427
|
-
"z-
|
|
13566
|
+
"z-[9999] overflow-hidden rounded-md border bg-popover px-3 py-1.5 text-sm text-popover-foreground shadow-md"
|
|
13428
13567
|
);
|
|
13429
13568
|
function withTooltip(Component) {
|
|
13430
13569
|
return React.forwardRef(function ExtendComponent({ tooltip, tooltipContentProps, tooltipProps, ...props }, ref) {
|
|
@@ -13850,6 +13989,38 @@ var __publicField = (obj, key, value) => {
|
|
|
13850
13989
|
const { props } = useCodeBlockToolbarButton(state);
|
|
13851
13990
|
return /* @__PURE__ */ React.createElement(ToolbarButton, { ref, tooltip: "Link", ...rest, ...props }, /* @__PURE__ */ React.createElement(Icons.codeBlock, null));
|
|
13852
13991
|
});
|
|
13992
|
+
const useMermaidToolbarButtonState = () => {
|
|
13993
|
+
const editor = plateCommon.useEditorState();
|
|
13994
|
+
const isBlockActive = () => helpers.isNodeActive(editor, ELEMENT_MERMAID);
|
|
13995
|
+
return {
|
|
13996
|
+
pressed: isBlockActive()
|
|
13997
|
+
};
|
|
13998
|
+
};
|
|
13999
|
+
const useMermaidToolbarButton = (state) => {
|
|
14000
|
+
const editor = plateCommon.useEditorState();
|
|
14001
|
+
const onClick = () => {
|
|
14002
|
+
plateCommon.insertEmptyElement(editor, ELEMENT_MERMAID, {
|
|
14003
|
+
nextBlock: true,
|
|
14004
|
+
select: true
|
|
14005
|
+
});
|
|
14006
|
+
};
|
|
14007
|
+
const onMouseDown = (e) => {
|
|
14008
|
+
e.preventDefault();
|
|
14009
|
+
e.stopPropagation();
|
|
14010
|
+
};
|
|
14011
|
+
return {
|
|
14012
|
+
props: {
|
|
14013
|
+
onClick,
|
|
14014
|
+
onMouseDown,
|
|
14015
|
+
pressed: state.pressed
|
|
14016
|
+
}
|
|
14017
|
+
};
|
|
14018
|
+
};
|
|
14019
|
+
const MermaidToolbarButton = cn$1.withRef(({ clear, ...rest }, ref) => {
|
|
14020
|
+
const state = useMermaidToolbarButtonState();
|
|
14021
|
+
const { props } = useMermaidToolbarButton(state);
|
|
14022
|
+
return /* @__PURE__ */ React.createElement(ToolbarButton, { ref, tooltip: "Mermaid", ...rest, ...props }, /* @__PURE__ */ React.createElement(Icons.mermaid, null));
|
|
14023
|
+
});
|
|
13853
14024
|
const useImageToolbarButtonState = () => {
|
|
13854
14025
|
const editor = plateCommon.useEditorState();
|
|
13855
14026
|
const isBlockActive = () => helpers.isNodeActive(editor, ELEMENT_IMG);
|
|
@@ -14034,6 +14205,10 @@ var __publicField = (obj, key, value) => {
|
|
|
14034
14205
|
label: "Code Block",
|
|
14035
14206
|
Component: /* @__PURE__ */ React.createElement(CodeBlockToolbarButton, null)
|
|
14036
14207
|
},
|
|
14208
|
+
mermaid: {
|
|
14209
|
+
label: "Mermaid",
|
|
14210
|
+
Component: /* @__PURE__ */ React.createElement(MermaidToolbarButton, null)
|
|
14211
|
+
},
|
|
14037
14212
|
raw: {
|
|
14038
14213
|
label: "Raw Markdown",
|
|
14039
14214
|
Component: /* @__PURE__ */ React.createElement(RawMarkdownToolbarButton, null)
|
|
@@ -14446,6 +14621,7 @@ var __publicField = (obj, key, value) => {
|
|
|
14446
14621
|
createMdxBlockPlugin(),
|
|
14447
14622
|
createMdxInlinePlugin(),
|
|
14448
14623
|
createImgPlugin(),
|
|
14624
|
+
createMermaidPlugin(),
|
|
14449
14625
|
createInvalidMarkdownPlugin(),
|
|
14450
14626
|
plateLink.createLinkPlugin({
|
|
14451
14627
|
options: {
|
package/dist/index.mjs
CHANGED
|
@@ -12,15 +12,16 @@ import { toggleList, ELEMENT_UL, ELEMENT_OL, ELEMENT_H1 as ELEMENT_H1$1, ELEMENT
|
|
|
12
12
|
import { useSelected, ReactEditor } from "slate-react";
|
|
13
13
|
import { ELEMENT_SLASH_INPUT, createSlashPlugin } from "@udecode/plate-slash-command";
|
|
14
14
|
import { cn as cn$1, withRef, withVariants, withProps, withCn, createPrimitiveElement } from "@udecode/cn";
|
|
15
|
-
import { useComposedRef, useEditorRef, findNodePath, getPointBefore, createPointRef, insertText, moveSelection, PlateElement, toggleNodeType, PlateLeaf, isCollapsed, getPointAfter, insertNodes, ELEMENT_DEFAULT, focusEditor, setNodes, isElement, createPluginFactory, normalizeEditor, getBlockAbove, queryNode, getParentNode, isType, someNode, isSelectionAtBlockStart, setElements, insertNode, getPluginType, isBlock, isBlockAboveEmpty, findNode, PlateContent, useMarkToolbarButtonState, useMarkToolbarButton, useEditorState, useEditorSelector, getNodeEntries, collapseSelection, usePlateSelectors, useEventEditorSelectors, PortalBody, useFormInputProps, createPlugins, Plate } from "@udecode/plate-common";
|
|
15
|
+
import { useComposedRef, useEditorRef, findNodePath, getPointBefore, createPointRef, insertText, moveSelection, PlateElement, toggleNodeType, PlateLeaf, isCollapsed, getPointAfter, insertNodes, ELEMENT_DEFAULT, focusEditor, setNodes, isElement, createPluginFactory, normalizeEditor, getBlockAbove, queryNode, getParentNode, isType, someNode, isSelectionAtBlockStart, setElements, insertNode, getPluginType, isBlock, isBlockAboveEmpty, findNode, PlateContent, useMarkToolbarButtonState, useMarkToolbarButton, useEditorState, useEditorSelector, getNodeEntries, collapseSelection, insertEmptyElement, usePlateSelectors, useEventEditorSelectors, PortalBody, useFormInputProps, createPlugins, Plate } from "@udecode/plate-common";
|
|
16
16
|
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";
|
|
17
17
|
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, Eye, Moon, SunMedium, Twitter } from "lucide-react";
|
|
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, Eye, Moon, SunMedium, Twitter, SquarePen, SunMoon } from "lucide-react";
|
|
19
19
|
import { useComboboxContext, Combobox, useComboboxStore, ComboboxProvider, Portal, ComboboxPopover, ComboboxItem } from "@ariakit/react";
|
|
20
20
|
import { useHTMLInputCursorState, useComboboxInput, filterWords } from "@udecode/plate-combobox";
|
|
21
21
|
import { useCodeSyntaxLeaf, useCodeBlockElementState, ELEMENT_CODE_BLOCK as ELEMENT_CODE_BLOCK$1 } from "@udecode/plate-code-block";
|
|
22
22
|
import MonacoEditor, { loader, useMonaco } from "@monaco-editor/react";
|
|
23
23
|
import { Combobox as Combobox$1, ComboboxInput, ComboboxButton, Transition, ComboboxOptions, ComboboxOption, Popover as Popover$2, PopoverButton, PopoverPanel, TransitionChild, Disclosure, DisclosureButton, DisclosurePanel, Menu, MenuButton, MenuItems, MenuItem } from "@headlessui/react";
|
|
24
|
+
import mermaid from "mermaid";
|
|
24
25
|
import arrayMutators from "final-form-arrays";
|
|
25
26
|
import setFieldData from "final-form-set-field-data";
|
|
26
27
|
import { FORM_ERROR, createForm, getIn } from "final-form";
|
|
@@ -932,6 +933,29 @@ const RawMarkdown = () => {
|
|
|
932
933
|
/* @__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
934
|
);
|
|
934
935
|
};
|
|
936
|
+
const MermaidIcon = () => /* @__PURE__ */ React__default.createElement(
|
|
937
|
+
"svg",
|
|
938
|
+
{
|
|
939
|
+
width: "100%",
|
|
940
|
+
height: "100%",
|
|
941
|
+
viewBox: "0 0 491 491",
|
|
942
|
+
version: "1.1",
|
|
943
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
944
|
+
fillRule: "evenodd",
|
|
945
|
+
clipRule: "evenodd",
|
|
946
|
+
strokeLinejoin: "round",
|
|
947
|
+
strokeMiterlimit: 2
|
|
948
|
+
},
|
|
949
|
+
/* @__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" }),
|
|
950
|
+
/* @__PURE__ */ React__default.createElement(
|
|
951
|
+
"path",
|
|
952
|
+
{
|
|
953
|
+
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",
|
|
954
|
+
fill: "white",
|
|
955
|
+
fillRule: "nonzero"
|
|
956
|
+
}
|
|
957
|
+
)
|
|
958
|
+
);
|
|
935
959
|
const borderAll = (props) => /* @__PURE__ */ React__default.createElement(
|
|
936
960
|
"svg",
|
|
937
961
|
{
|
|
@@ -1172,6 +1196,7 @@ const Icons = {
|
|
|
1172
1196
|
clear: X,
|
|
1173
1197
|
close: X,
|
|
1174
1198
|
// code: Code2,
|
|
1199
|
+
paint: PaintBucket,
|
|
1175
1200
|
codeblock: FileCode,
|
|
1176
1201
|
color: Baseline,
|
|
1177
1202
|
column: RectangleVertical,
|
|
@@ -1197,6 +1222,7 @@ const Icons = {
|
|
|
1197
1222
|
lineHeight: WrapText,
|
|
1198
1223
|
// link: Link2,
|
|
1199
1224
|
minus: Minus,
|
|
1225
|
+
mermaid: MermaidIcon,
|
|
1200
1226
|
more: MoreHorizontal,
|
|
1201
1227
|
// ol: ListOrdered,
|
|
1202
1228
|
outdent: Outdent,
|
|
@@ -1918,18 +1944,21 @@ const retryFocus = (ref) => {
|
|
|
1918
1944
|
}
|
|
1919
1945
|
}
|
|
1920
1946
|
};
|
|
1947
|
+
const MINIMUM_HEIGHT = 75;
|
|
1921
1948
|
const CodeBlock = ({
|
|
1922
1949
|
attributes,
|
|
1923
1950
|
editor,
|
|
1924
1951
|
element,
|
|
1925
1952
|
language: restrictLanguage,
|
|
1953
|
+
onChangeCallback,
|
|
1954
|
+
defaultValue,
|
|
1926
1955
|
...props
|
|
1927
1956
|
}) => {
|
|
1928
1957
|
const [navigateAway, setNavigateAway] = React__default.useState(null);
|
|
1929
1958
|
const monaco = useMonaco();
|
|
1930
1959
|
const monacoEditorRef = React__default.useRef(null);
|
|
1931
1960
|
const selected = useSelected();
|
|
1932
|
-
const [height, setHeight] = React__default.useState(
|
|
1961
|
+
const [height, setHeight] = React__default.useState(MINIMUM_HEIGHT);
|
|
1933
1962
|
React__default.useEffect(() => {
|
|
1934
1963
|
if (selected && isCollapsed(editor.selection)) {
|
|
1935
1964
|
retryFocus(monacoEditorRef);
|
|
@@ -2073,9 +2102,12 @@ const CodeBlock = ({
|
|
|
2073
2102
|
function handleEditorDidMount(monacoEditor, monaco2) {
|
|
2074
2103
|
monacoEditorRef.current = monacoEditor;
|
|
2075
2104
|
monacoEditor.onDidContentSizeChange(() => {
|
|
2076
|
-
setHeight(
|
|
2105
|
+
setHeight(
|
|
2106
|
+
monacoEditor.getContentHeight() > MINIMUM_HEIGHT ? monacoEditor.getContentHeight() : MINIMUM_HEIGHT
|
|
2107
|
+
);
|
|
2077
2108
|
monacoEditor.layout();
|
|
2078
2109
|
});
|
|
2110
|
+
setNodes(editor, { value: defaultValue, lang: language });
|
|
2079
2111
|
monacoEditor.addCommand(monaco2.KeyMod.Shift | monaco2.KeyCode.Enter, () => {
|
|
2080
2112
|
if (monacoEditor.hasTextFocus()) {
|
|
2081
2113
|
setNavigateAway("insertNext");
|
|
@@ -2157,6 +2189,7 @@ const CodeBlock = ({
|
|
|
2157
2189
|
language: String(language),
|
|
2158
2190
|
value: String(element.value),
|
|
2159
2191
|
onChange: (value2) => {
|
|
2192
|
+
onChangeCallback == null ? void 0 : onChangeCallback(value2);
|
|
2160
2193
|
setNodes(editor, { value: value2, lang: language });
|
|
2161
2194
|
}
|
|
2162
2195
|
}
|
|
@@ -2178,6 +2211,110 @@ const CodeBlockElement = withRef(
|
|
|
2178
2211
|
);
|
|
2179
2212
|
}
|
|
2180
2213
|
);
|
|
2214
|
+
const ELEMENT_MERMAID = "mermaid";
|
|
2215
|
+
const createMermaidPlugin = createPluginFactory({
|
|
2216
|
+
isElement: true,
|
|
2217
|
+
isVoid: true,
|
|
2218
|
+
isInline: false,
|
|
2219
|
+
key: ELEMENT_MERMAID
|
|
2220
|
+
});
|
|
2221
|
+
const useMermaidElement = () => {
|
|
2222
|
+
const mermaidRef = useRef(null);
|
|
2223
|
+
useEffect(() => {
|
|
2224
|
+
if (mermaidRef.current) {
|
|
2225
|
+
mermaid.initialize({ startOnLoad: true });
|
|
2226
|
+
mermaid.run();
|
|
2227
|
+
}
|
|
2228
|
+
}, []);
|
|
2229
|
+
return {
|
|
2230
|
+
mermaidRef
|
|
2231
|
+
};
|
|
2232
|
+
};
|
|
2233
|
+
const LightModeComponent = ({ onToggleMode }) => {
|
|
2234
|
+
const [isLightMode, setIsLightMode] = useState(true);
|
|
2235
|
+
const handleToggle = (e) => {
|
|
2236
|
+
e.preventDefault();
|
|
2237
|
+
setIsLightMode((prevMode) => !prevMode);
|
|
2238
|
+
};
|
|
2239
|
+
useEffect(() => {
|
|
2240
|
+
const modeClass = isLightMode ? "not-tina-prose" : "";
|
|
2241
|
+
if (onToggleMode) {
|
|
2242
|
+
onToggleMode(modeClass);
|
|
2243
|
+
}
|
|
2244
|
+
}, [isLightMode, onToggleMode]);
|
|
2245
|
+
return /* @__PURE__ */ React__default.createElement("div", null, /* @__PURE__ */ React__default.createElement(
|
|
2246
|
+
"button",
|
|
2247
|
+
{
|
|
2248
|
+
type: "button",
|
|
2249
|
+
onClick: handleToggle,
|
|
2250
|
+
className: "flex items-center w-5 h-5 cursor-pointer"
|
|
2251
|
+
},
|
|
2252
|
+
isLightMode ? /* @__PURE__ */ React__default.createElement(Moon, { className: "fill-white" }) : /* @__PURE__ */ React__default.createElement(SunMoon, { className: "fill-white" })
|
|
2253
|
+
));
|
|
2254
|
+
};
|
|
2255
|
+
const MermaidElementWithRef = ({ config, lightMode }) => {
|
|
2256
|
+
const { mermaidRef } = useMermaidElement();
|
|
2257
|
+
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: `${lightMode} mermaid` }, config)));
|
|
2258
|
+
};
|
|
2259
|
+
const Bubble = ({ children }) => {
|
|
2260
|
+
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);
|
|
2261
|
+
};
|
|
2262
|
+
const DEFAULT_MERMAID_CONFIG = `%% This won't render without implementing a rendering engine <TODO: Link to tina docs>
|
|
2263
|
+
flowchart TD
|
|
2264
|
+
id1(this is an example flow diagram)
|
|
2265
|
+
--> id2(modify me to see changes!)
|
|
2266
|
+
id2
|
|
2267
|
+
--> id3(Click the top button to preview the changes)
|
|
2268
|
+
--> id4(Learn about mermaid diagrams @ mermaid.js.org)`;
|
|
2269
|
+
const MermaidElement = withRef(
|
|
2270
|
+
({ children, nodeProps, element, ...props }, ref) => {
|
|
2271
|
+
const [mermaidConfig, setMermaidConfig] = React__default.useState(
|
|
2272
|
+
element.value || DEFAULT_MERMAID_CONFIG
|
|
2273
|
+
);
|
|
2274
|
+
const [isEditing, setIsEditing] = React__default.useState(
|
|
2275
|
+
mermaidConfig === DEFAULT_MERMAID_CONFIG || false
|
|
2276
|
+
);
|
|
2277
|
+
const [lightModeClass, setLightModeClass] = React__default.useState("");
|
|
2278
|
+
const node = {
|
|
2279
|
+
type: ELEMENT_MERMAID,
|
|
2280
|
+
value: mermaidConfig,
|
|
2281
|
+
children: [{ type: "text", text: "" }]
|
|
2282
|
+
};
|
|
2283
|
+
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(
|
|
2284
|
+
Eye,
|
|
2285
|
+
{
|
|
2286
|
+
className: "w-5 h-5 fill-white cursor-pointer",
|
|
2287
|
+
onClick: () => {
|
|
2288
|
+
setIsEditing(!isEditing);
|
|
2289
|
+
}
|
|
2290
|
+
}
|
|
2291
|
+
) : /* @__PURE__ */ React__default.createElement(
|
|
2292
|
+
SquarePen,
|
|
2293
|
+
{
|
|
2294
|
+
className: "w-5 h-5 fill-white cursor-pointer",
|
|
2295
|
+
onClick: () => {
|
|
2296
|
+
setIsEditing(!isEditing);
|
|
2297
|
+
}
|
|
2298
|
+
}
|
|
2299
|
+
)), /* @__PURE__ */ React__default.createElement(Bubble, null, /* @__PURE__ */ React__default.createElement(LightModeComponent, { onToggleMode: (v) => setLightModeClass(v) }))), isEditing ? /* @__PURE__ */ React__default.createElement(
|
|
2300
|
+
CodeBlock,
|
|
2301
|
+
{
|
|
2302
|
+
children: "",
|
|
2303
|
+
language: "yaml",
|
|
2304
|
+
...props,
|
|
2305
|
+
element: node,
|
|
2306
|
+
defaultValue: mermaidConfig,
|
|
2307
|
+
onChangeCallback: (value) => setMermaidConfig(value)
|
|
2308
|
+
}
|
|
2309
|
+
) : /* @__PURE__ */ React__default.createElement(
|
|
2310
|
+
MermaidElementWithRef,
|
|
2311
|
+
{
|
|
2312
|
+
config: mermaidConfig,
|
|
2313
|
+
lightMode: lightModeClass
|
|
2314
|
+
}
|
|
2315
|
+
), children));
|
|
2316
|
+
}
|
|
2317
|
+
);
|
|
2181
2318
|
const blockClasses = "mt-0.5";
|
|
2182
2319
|
const headerClasses = "font-normal";
|
|
2183
2320
|
const Components = () => {
|
|
@@ -2283,6 +2420,7 @@ const Components = () => {
|
|
|
2283
2420
|
}
|
|
2284
2421
|
)
|
|
2285
2422
|
),
|
|
2423
|
+
[ELEMENT_MERMAID]: MermaidElement,
|
|
2286
2424
|
[ELEMENT_BLOCKQUOTE]: BlockquoteElement,
|
|
2287
2425
|
[ELEMENT_CODE_BLOCK]: CodeBlockElement,
|
|
2288
2426
|
[ELEMENT_CODE_LINE]: CodeLineElement,
|
|
@@ -2773,7 +2911,9 @@ class Form {
|
|
|
2773
2911
|
{
|
|
2774
2912
|
type: "string",
|
|
2775
2913
|
label: "Caption",
|
|
2776
|
-
name: [templateName.replace(/\.props$/, ""), "caption"].join(
|
|
2914
|
+
name: [templateName.replace(/\.props$/, ""), "caption"].join(
|
|
2915
|
+
"."
|
|
2916
|
+
),
|
|
2777
2917
|
component: "text"
|
|
2778
2918
|
}
|
|
2779
2919
|
]
|
|
@@ -13447,7 +13587,7 @@ const TooltipContent = withCn(
|
|
|
13447
13587
|
withProps(TooltipPrimitive.Content, {
|
|
13448
13588
|
sideOffset: 4
|
|
13449
13589
|
}),
|
|
13450
|
-
"z-
|
|
13590
|
+
"z-[9999] overflow-hidden rounded-md border bg-popover px-3 py-1.5 text-sm text-popover-foreground shadow-md"
|
|
13451
13591
|
);
|
|
13452
13592
|
function withTooltip(Component2) {
|
|
13453
13593
|
return React__default.forwardRef(function ExtendComponent({ tooltip, tooltipContentProps, tooltipProps, ...props }, ref) {
|
|
@@ -13873,6 +14013,38 @@ const CodeBlockToolbarButton = withRef(({ clear, ...rest }, ref) => {
|
|
|
13873
14013
|
const { props } = useCodeBlockToolbarButton(state);
|
|
13874
14014
|
return /* @__PURE__ */ React__default.createElement(ToolbarButton, { ref, tooltip: "Link", ...rest, ...props }, /* @__PURE__ */ React__default.createElement(Icons.codeBlock, null));
|
|
13875
14015
|
});
|
|
14016
|
+
const useMermaidToolbarButtonState = () => {
|
|
14017
|
+
const editor = useEditorState();
|
|
14018
|
+
const isBlockActive = () => helpers.isNodeActive(editor, ELEMENT_MERMAID);
|
|
14019
|
+
return {
|
|
14020
|
+
pressed: isBlockActive()
|
|
14021
|
+
};
|
|
14022
|
+
};
|
|
14023
|
+
const useMermaidToolbarButton = (state) => {
|
|
14024
|
+
const editor = useEditorState();
|
|
14025
|
+
const onClick = () => {
|
|
14026
|
+
insertEmptyElement(editor, ELEMENT_MERMAID, {
|
|
14027
|
+
nextBlock: true,
|
|
14028
|
+
select: true
|
|
14029
|
+
});
|
|
14030
|
+
};
|
|
14031
|
+
const onMouseDown = (e) => {
|
|
14032
|
+
e.preventDefault();
|
|
14033
|
+
e.stopPropagation();
|
|
14034
|
+
};
|
|
14035
|
+
return {
|
|
14036
|
+
props: {
|
|
14037
|
+
onClick,
|
|
14038
|
+
onMouseDown,
|
|
14039
|
+
pressed: state.pressed
|
|
14040
|
+
}
|
|
14041
|
+
};
|
|
14042
|
+
};
|
|
14043
|
+
const MermaidToolbarButton = withRef(({ clear, ...rest }, ref) => {
|
|
14044
|
+
const state = useMermaidToolbarButtonState();
|
|
14045
|
+
const { props } = useMermaidToolbarButton(state);
|
|
14046
|
+
return /* @__PURE__ */ React__default.createElement(ToolbarButton, { ref, tooltip: "Mermaid", ...rest, ...props }, /* @__PURE__ */ React__default.createElement(Icons.mermaid, null));
|
|
14047
|
+
});
|
|
13876
14048
|
const useImageToolbarButtonState = () => {
|
|
13877
14049
|
const editor = useEditorState();
|
|
13878
14050
|
const isBlockActive = () => helpers.isNodeActive(editor, ELEMENT_IMG);
|
|
@@ -14057,6 +14229,10 @@ const toolbarItems = {
|
|
|
14057
14229
|
label: "Code Block",
|
|
14058
14230
|
Component: /* @__PURE__ */ React__default.createElement(CodeBlockToolbarButton, null)
|
|
14059
14231
|
},
|
|
14232
|
+
mermaid: {
|
|
14233
|
+
label: "Mermaid",
|
|
14234
|
+
Component: /* @__PURE__ */ React__default.createElement(MermaidToolbarButton, null)
|
|
14235
|
+
},
|
|
14060
14236
|
raw: {
|
|
14061
14237
|
label: "Raw Markdown",
|
|
14062
14238
|
Component: /* @__PURE__ */ React__default.createElement(RawMarkdownToolbarButton, null)
|
|
@@ -14469,6 +14645,7 @@ const RichEditor = (props) => {
|
|
|
14469
14645
|
createMdxBlockPlugin(),
|
|
14470
14646
|
createMdxInlinePlugin(),
|
|
14471
14647
|
createImgPlugin(),
|
|
14648
|
+
createMermaidPlugin(),
|
|
14472
14649
|
createInvalidMarkdownPlugin(),
|
|
14473
14650
|
createLinkPlugin({
|
|
14474
14651
|
options: {
|
package/dist/rich-text/index.js
CHANGED
|
@@ -117,7 +117,8 @@
|
|
|
117
117
|
// @ts-ignore FIXME: TinaMarkdownContent needs to be a union of all possible node types
|
|
118
118
|
/* @__PURE__ */ React.createElement("a", { href: child.url }, /* @__PURE__ */ React.createElement(TinaMarkdown, { components, content: children }))
|
|
119
119
|
);
|
|
120
|
-
case "
|
|
120
|
+
case "mermaid":
|
|
121
|
+
case "code_block": {
|
|
121
122
|
const value = child.value;
|
|
122
123
|
if (components[child.type]) {
|
|
123
124
|
const Component2 = components[child.type];
|
|
@@ -127,6 +128,7 @@
|
|
|
127
128
|
);
|
|
128
129
|
}
|
|
129
130
|
return /* @__PURE__ */ React.createElement("pre", null, /* @__PURE__ */ React.createElement("code", null, value));
|
|
131
|
+
}
|
|
130
132
|
case "hr":
|
|
131
133
|
if (components[child.type]) {
|
|
132
134
|
const Component2 = components[child.type];
|
package/dist/rich-text/index.mjs
CHANGED
|
@@ -114,7 +114,8 @@ const Node = ({ components, child }) => {
|
|
|
114
114
|
// @ts-ignore FIXME: TinaMarkdownContent needs to be a union of all possible node types
|
|
115
115
|
/* @__PURE__ */ React.createElement("a", { href: child.url }, /* @__PURE__ */ React.createElement(TinaMarkdown, { components, content: children }))
|
|
116
116
|
);
|
|
117
|
-
case "
|
|
117
|
+
case "mermaid":
|
|
118
|
+
case "code_block": {
|
|
118
119
|
const value = child.value;
|
|
119
120
|
if (components[child.type]) {
|
|
120
121
|
const Component2 = components[child.type];
|
|
@@ -124,6 +125,7 @@ const Node = ({ components, child }) => {
|
|
|
124
125
|
);
|
|
125
126
|
}
|
|
126
127
|
return /* @__PURE__ */ React.createElement("pre", null, /* @__PURE__ */ React.createElement("code", null, value));
|
|
128
|
+
}
|
|
127
129
|
case "hr":
|
|
128
130
|
if (components[child.type]) {
|
|
129
131
|
const Component2 = components[child.type];
|
|
@@ -33,6 +33,7 @@ export declare const Icons: {
|
|
|
33
33
|
chevronsUpDown: React.ForwardRefExoticComponent<Omit<LucideProps, "ref"> & React.RefAttributes<SVGSVGElement>>;
|
|
34
34
|
clear: React.ForwardRefExoticComponent<Omit<LucideProps, "ref"> & React.RefAttributes<SVGSVGElement>>;
|
|
35
35
|
close: React.ForwardRefExoticComponent<Omit<LucideProps, "ref"> & React.RefAttributes<SVGSVGElement>>;
|
|
36
|
+
paint: React.ForwardRefExoticComponent<Omit<LucideProps, "ref"> & React.RefAttributes<SVGSVGElement>>;
|
|
36
37
|
codeblock: React.ForwardRefExoticComponent<Omit<LucideProps, "ref"> & React.RefAttributes<SVGSVGElement>>;
|
|
37
38
|
color: React.ForwardRefExoticComponent<Omit<LucideProps, "ref"> & React.RefAttributes<SVGSVGElement>>;
|
|
38
39
|
column: React.ForwardRefExoticComponent<Omit<LucideProps, "ref"> & React.RefAttributes<SVGSVGElement>>;
|
|
@@ -55,6 +56,7 @@ export declare const Icons: {
|
|
|
55
56
|
kbd: React.ForwardRefExoticComponent<Omit<LucideProps, "ref"> & React.RefAttributes<SVGSVGElement>>;
|
|
56
57
|
lineHeight: React.ForwardRefExoticComponent<Omit<LucideProps, "ref"> & React.RefAttributes<SVGSVGElement>>;
|
|
57
58
|
minus: React.ForwardRefExoticComponent<Omit<LucideProps, "ref"> & React.RefAttributes<SVGSVGElement>>;
|
|
59
|
+
mermaid: () => React.JSX.Element;
|
|
58
60
|
more: React.ForwardRefExoticComponent<Omit<LucideProps, "ref"> & React.RefAttributes<SVGSVGElement>>;
|
|
59
61
|
outdent: React.ForwardRefExoticComponent<Omit<LucideProps, "ref"> & React.RefAttributes<SVGSVGElement>>;
|
|
60
62
|
paragraph: React.ForwardRefExoticComponent<Omit<LucideProps, "ref"> & React.RefAttributes<SVGSVGElement>>;
|
package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/components/plate-ui/mermaid-element.d.ts
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
export declare const MermaidElement: React.ForwardRefExoticComponent<Omit<Omit<{
|
|
3
|
+
elementToAttributes?: (element: import("@udecode/plate-common").TElement) => any;
|
|
4
|
+
} & Omit<{
|
|
5
|
+
as?: React.ElementType<any, keyof React.JSX.IntrinsicElements> | undefined;
|
|
6
|
+
asChild?: boolean | undefined;
|
|
7
|
+
} & Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & React.RefAttributes<any>, "ref"> & {
|
|
8
|
+
ref?: React.Ref<any>;
|
|
9
|
+
} & import("@udecode/plate-common").PlateRenderNodeProps<import("@udecode/plate-common").Value, import("@udecode/plate-common").PlateEditor<import("@udecode/plate-common").Value>> & {
|
|
10
|
+
element: import("@udecode/plate-common").TElement;
|
|
11
|
+
} & Omit<import("slate-react").RenderElementProps, "element"> & React.RefAttributes<HTMLDivElement>, "ref">, never> & React.RefAttributes<any>>;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { type PlateEditor } from '@udecode/plate-common';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
export declare const insertEmptyMermaid: (editor: PlateEditor) => void;
|
|
4
|
+
export declare const MermaidToolbarButton: React.ForwardRefExoticComponent<{
|
|
5
|
+
clear?: string | string[];
|
|
6
|
+
} & Omit<Omit<{
|
|
7
|
+
tooltip?: React.ReactNode;
|
|
8
|
+
tooltipContentProps?: Omit<React.ComponentPropsWithoutRef<React.ForwardRefExoticComponent<import("@radix-ui/react-tooltip").TooltipContentProps & React.RefAttributes<HTMLDivElement>>>, "children">;
|
|
9
|
+
tooltipProps?: Omit<React.ComponentPropsWithoutRef<React.FC<import("@radix-ui/react-tooltip").TooltipProps>>, "children">;
|
|
10
|
+
} & Omit<{
|
|
11
|
+
isDropdown?: boolean;
|
|
12
|
+
pressed?: boolean;
|
|
13
|
+
showArrow?: boolean;
|
|
14
|
+
} & Omit<Omit<Omit<import("@radix-ui/react-toolbar").ToolbarToggleItemProps & React.RefAttributes<HTMLButtonElement>, "ref"> & import("class-variance-authority").VariantProps<(props?: {
|
|
15
|
+
size?: "default" | "sm" | "lg";
|
|
16
|
+
variant?: "default" | "outline";
|
|
17
|
+
} & import("class-variance-authority/dist/types").ClassProp) => string> & React.RefAttributes<HTMLButtonElement>, "ref">, "value" | "asChild"> & import("class-variance-authority").VariantProps<(props?: {
|
|
18
|
+
size?: "default" | "sm" | "lg";
|
|
19
|
+
variant?: "default" | "outline";
|
|
20
|
+
} & import("class-variance-authority/dist/types").ClassProp) => string> & React.RefAttributes<HTMLButtonElement>, "ref"> & React.RefAttributes<HTMLButtonElement>, "ref">, "clear"> & React.RefAttributes<HTMLButtonElement>>;
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
export declare const ELEMENT_MERMAID = "mermaid";
|
|
2
|
+
export declare const createMermaidPlugin: <OP = import("@udecode/plate-common").AnyObject, OV extends import("@udecode/plate-common").Value = import("@udecode/plate-common").Value, OE extends import("@udecode/plate-common").PlateEditor<OV> = import("@udecode/plate-common").PlateEditor<OV>>(override?: Partial<import("@udecode/plate-common").PlatePlugin<import("@udecode/plate-common").NoInfer<OP>, OV, OE>>, overrideByKey?: import("@udecode/plate-common").OverrideByKey<OV, OE>) => import("@udecode/plate-common").PlatePlugin<import("@udecode/plate-common").NoInfer<OP>, OV, OE>;
|
|
@@ -1,9 +1,11 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
1
|
import { type PlateEditor, type TElement } from '@udecode/plate-common';
|
|
3
|
-
|
|
2
|
+
import React from 'react';
|
|
3
|
+
export declare const CodeBlock: ({ attributes, editor, element, language: restrictLanguage, onChangeCallback, defaultValue, ...props }: {
|
|
4
4
|
attributes: Record<string, unknown>;
|
|
5
5
|
element: TElement;
|
|
6
6
|
editor: PlateEditor;
|
|
7
7
|
language?: string;
|
|
8
8
|
children: React.ReactNode;
|
|
9
|
+
defaultValue?: unknown;
|
|
10
|
+
onChangeCallback?: (value: string) => void;
|
|
9
11
|
}) => React.JSX.Element;
|
|
@@ -60,6 +60,16 @@ export declare const Components: () => {
|
|
|
60
60
|
editor: any;
|
|
61
61
|
element: any;
|
|
62
62
|
}) => React.JSX.Element;
|
|
63
|
+
mermaid: React.ForwardRefExoticComponent<Omit<Omit<{
|
|
64
|
+
elementToAttributes?: (element: import("@udecode/plate-common").TElement) => any;
|
|
65
|
+
} & Omit<{
|
|
66
|
+
as?: React.ElementType<any, keyof React.JSX.IntrinsicElements> | undefined;
|
|
67
|
+
asChild?: boolean | undefined;
|
|
68
|
+
} & Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & React.RefAttributes<any>, "ref"> & {
|
|
69
|
+
ref?: React.Ref<any>;
|
|
70
|
+
} & import("@udecode/plate-common").PlateRenderNodeProps<import("@udecode/plate-common").Value, import("@udecode/plate-common").PlateEditor<import("@udecode/plate-common").Value>> & {
|
|
71
|
+
element: import("@udecode/plate-common").TElement;
|
|
72
|
+
} & Omit<import("slate-react").RenderElementProps, "element"> & React.RefAttributes<HTMLDivElement>, "ref">, never> & React.RefAttributes<any>>;
|
|
63
73
|
blockquote: React.ForwardRefExoticComponent<Omit<Omit<{
|
|
64
74
|
elementToAttributes?: (element: import("@udecode/plate-common").TElement) => any;
|
|
65
75
|
} & Omit<{
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export type ToolbarOverrideType = 'heading' | 'link' | 'image' | 'quote' | 'ul' | 'ol' | 'code' | 'codeBlock' | 'bold' | 'italic' | 'raw' | 'embed';
|
|
1
|
+
export type ToolbarOverrideType = 'heading' | 'link' | 'image' | 'quote' | 'ul' | 'ol' | 'code' | 'codeBlock' | 'bold' | 'italic' | 'mermaid' | 'raw' | 'embed';
|
|
2
2
|
export declare const ICON_WIDTH = 32;
|
|
3
3
|
export declare const EMBED_ICON_WIDTH = 78;
|
|
4
4
|
export declare const HEADING = 138;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { type ReactNode } from 'react';
|
|
3
|
-
import type { MdxTemplate } from '../types';
|
|
4
3
|
import type { Form } from '../../../../../forms';
|
|
4
|
+
import type { MdxTemplate } from '../types';
|
|
5
5
|
import type { ToolbarOverrideType } from './toolbar-overrides';
|
|
6
6
|
interface ToolbarContextProps {
|
|
7
7
|
tinaForm: Form;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "tinacms",
|
|
3
|
-
"version": "0.0.0-
|
|
3
|
+
"version": "0.0.0-e0ddb8c-20241004065742",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"module": "./dist/index.mjs",
|
|
6
6
|
"exports": {
|
|
@@ -107,6 +107,7 @@
|
|
|
107
107
|
"lodash.get": "^4.4.2",
|
|
108
108
|
"lodash.set": "^4.3.2",
|
|
109
109
|
"lucide-react": "^0.424.0",
|
|
110
|
+
"mermaid": "^10.9.1",
|
|
110
111
|
"moment": "2.29.4",
|
|
111
112
|
"monaco-editor": "0.31.0",
|
|
112
113
|
"prism-react-renderer": "^2.4.0",
|
|
@@ -127,9 +128,9 @@
|
|
|
127
128
|
"webfontloader": "1.6.28",
|
|
128
129
|
"yup": "^1.4.0",
|
|
129
130
|
"zod": "^3.23.8",
|
|
130
|
-
"@tinacms/
|
|
131
|
-
"@tinacms/search": "0.0.0-
|
|
132
|
-
"@tinacms/
|
|
131
|
+
"@tinacms/schema-tools": "0.0.0-e0ddb8c-20241004065742",
|
|
132
|
+
"@tinacms/search": "0.0.0-e0ddb8c-20241004065742",
|
|
133
|
+
"@tinacms/mdx": "0.0.0-e0ddb8c-20241004065742"
|
|
133
134
|
},
|
|
134
135
|
"devDependencies": {
|
|
135
136
|
"@graphql-tools/utils": "^10.5.4",
|