tinacms 0.0.0-b370466-20241010070714 → 0.0.0-b720fb9-20241203044105

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.
@@ -25,6 +25,9 @@ export interface DocumentNode {
25
25
  }
26
26
  export interface DocumentForm {
27
27
  _values: Object;
28
+ _sys?: {
29
+ hasReferences?: boolean;
30
+ };
28
31
  }
29
32
  export interface DocumentSys {
30
33
  _sys: {
@@ -1,2 +1,3 @@
1
1
  import type { Cache } from './index';
2
+ export declare const makeCacheDir: (dir: string, fs: any, path: any, os: any) => Promise<string>;
2
3
  export declare const NodeCache: (dir: string) => Promise<Cache>;
package/dist/client.js CHANGED
@@ -105,21 +105,27 @@
105
105
  const client = new TinaClient(args);
106
106
  return client;
107
107
  }
108
- const makeCacheDir = async (dir, fs) => {
109
- const path = await Promise.resolve().then(() => __viteBrowserExternal$1);
110
- const os = await Promise.resolve().then(() => __viteBrowserExternal$1);
111
- const parts = dir.split(path.sep).filter(Boolean);
108
+ const makeCacheDir = async (dir, fs, path, os) => {
109
+ const pathParts = dir.split(path.sep).filter(Boolean);
110
+ const cacheHash = pathParts[pathParts.length - 1];
111
+ const rootUser = pathParts[0];
112
112
  let cacheDir = dir;
113
- if (!fs.existsSync(path.join(path.sep, parts[0]))) {
114
- cacheDir = path.join(os.tmpdir(), parts[parts.length - 1]);
113
+ if (!fs.existsSync(path.join(path.sep, rootUser))) {
114
+ cacheDir = path.join(os.tmpdir(), cacheHash);
115
+ }
116
+ try {
117
+ fs.mkdirSync(cacheDir, { recursive: true });
118
+ } catch (error) {
119
+ throw new Error(`Failed to create cache directory: ${error.message}`);
115
120
  }
116
- fs.mkdirSync(cacheDir, { recursive: true });
117
121
  return cacheDir;
118
122
  };
119
123
  const NodeCache = async (dir) => {
120
- const fs = await Promise.resolve().then(() => __viteBrowserExternal$1);
121
- const { createHash } = await Promise.resolve().then(() => __viteBrowserExternal$1);
122
- const cacheDir = await makeCacheDir(dir, fs);
124
+ const fs = require("node:fs");
125
+ const path = require("node:path");
126
+ const os = require("node:os");
127
+ const { createHash } = require("node:crypto");
128
+ const cacheDir = await makeCacheDir(dir, fs, path, os);
123
129
  return {
124
130
  makeKey: (key) => {
125
131
  const input = key && key instanceof Object ? JSON.stringify(key) : key || "";
@@ -147,12 +153,8 @@
147
153
  };
148
154
  const nodeCache = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
149
155
  __proto__: null,
150
- NodeCache
151
- }, Symbol.toStringTag, { value: "Module" }));
152
- const __viteBrowserExternal = {};
153
- const __viteBrowserExternal$1 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
154
- __proto__: null,
155
- default: __viteBrowserExternal
156
+ NodeCache,
157
+ makeCacheDir
156
158
  }, Symbol.toStringTag, { value: "Module" }));
157
159
  exports2.TINA_HOST = TINA_HOST;
158
160
  exports2.TinaClient = TinaClient;
package/dist/client.mjs CHANGED
@@ -24,7 +24,7 @@ class TinaClient {
24
24
  }
25
25
  try {
26
26
  if (this.cacheDir && typeof window === "undefined" && typeof require !== "undefined") {
27
- const { NodeCache } = await import("./node-cache-7fa2452c.mjs");
27
+ const { NodeCache } = await import("./node-cache-4c336858.mjs");
28
28
  this.cache = await NodeCache(this.cacheDir);
29
29
  }
30
30
  } catch (e) {
package/dist/index.d.ts CHANGED
@@ -53,7 +53,7 @@ export type TinaCollection = Collection;
53
53
  export type TinaCloudSchema = Schema;
54
54
  export declare const defineSchema: (config: Schema) => Schema<false>;
55
55
  export declare const defineLegacyConfig: (config: Omit<TinaCMSProviderDefaultProps, "children">) => Omit<TinaCMSProviderDefaultProps, "children">;
56
- interface MediaStoreClass {
56
+ export interface MediaStoreClass {
57
57
  new (...args: any[]): MediaStore;
58
58
  }
59
59
  export declare const defineStaticConfig: (config: Config<(cms: TinaCMS) => TinaCMS, formifyCallback, DocumentCreatorCallback, MediaStoreClass>) => Config<(cms: TinaCMS) => TinaCMS, formifyCallback, import("./hooks/use-content-creator").DocumentCreatorArgs, MediaStoreClass, undefined>;
package/dist/index.js CHANGED
@@ -774,6 +774,22 @@ var __publicField = (obj, key, value) => {
774
774
  );
775
775
  };
776
776
  }
777
+ function wrapFieldWithNoHeader(Field) {
778
+ return (props) => {
779
+ return /* @__PURE__ */ React__namespace.createElement(
780
+ FieldMeta,
781
+ {
782
+ name: props.input.name,
783
+ label: false,
784
+ description: "",
785
+ error: props.meta.error,
786
+ index: props.index,
787
+ tinaForm: props.tinaForm
788
+ },
789
+ /* @__PURE__ */ React__namespace.createElement(Field, { ...props })
790
+ );
791
+ };
792
+ }
777
793
  function wrapFieldWithError(Field) {
778
794
  return (props) => {
779
795
  return /* @__PURE__ */ React__namespace.createElement(
@@ -846,6 +862,16 @@ var __publicField = (obj, key, value) => {
846
862
  className,
847
863
  ...props
848
864
  }) => {
865
+ if (typeof children === "string") {
866
+ return /* @__PURE__ */ React__namespace.createElement(
867
+ "span",
868
+ {
869
+ className: `block font-sans text-xs italic font-light text-gray-400 pt-0.5 whitespace-normal m-0 ${className}`,
870
+ ...props,
871
+ dangerouslySetInnerHTML: { __html: children }
872
+ }
873
+ );
874
+ }
849
875
  return /* @__PURE__ */ React__namespace.createElement(
850
876
  "span",
851
877
  {
@@ -1321,7 +1347,7 @@ var __publicField = (obj, key, value) => {
1321
1347
  React.useEffect(() => {
1322
1348
  if (mermaidRef.current) {
1323
1349
  mermaid.initialize({ startOnLoad: true });
1324
- mermaid.run();
1350
+ mermaid.init();
1325
1351
  }
1326
1352
  }, [config]);
1327
1353
  return /* @__PURE__ */ React.createElement("div", { contentEditable: false, className: "border-border border-b" }, /* @__PURE__ */ React.createElement("div", { ref: mermaidRef }, /* @__PURE__ */ React.createElement("pre", { className: "mermaid not-tina-prose" }, config)));
@@ -1348,7 +1374,7 @@ flowchart TD
1348
1374
  --> id2(modify me to see changes!)
1349
1375
  id2
1350
1376
  --> id3(Click the top button to preview the changes)
1351
- --> id4(Learn about mermaid diagrams @ mermaid.js.org)`;
1377
+ --> id4(Learn about mermaid diagrams - mermaid.js.org)`;
1352
1378
  const MermaidElement = cn$1.withRef(
1353
1379
  ({ children, nodeProps, element, ...props }, ref) => {
1354
1380
  const [mermaidConfig, setMermaidConfig] = React.useState(
@@ -1364,7 +1390,7 @@ flowchart TD
1364
1390
  children: [{ type: "text", text: "" }]
1365
1391
  };
1366
1392
  React.useEffect(() => {
1367
- if (mermaid.parse(mermaidConfig, { suppressErrors: false })) {
1393
+ if (mermaid.parse(mermaidConfig)) {
1368
1394
  setMermaidError(null);
1369
1395
  }
1370
1396
  }, [mermaidConfig]);
@@ -3676,7 +3702,7 @@ flowchart TD
3676
3702
  };
3677
3703
  const sizeClasses = {
3678
3704
  small: `text-xs h-8 px-3`,
3679
- medium: `text-sm h-10 px-4`,
3705
+ medium: `text-sm h-10 px-8`,
3680
3706
  custom: ``
3681
3707
  };
3682
3708
  return /* @__PURE__ */ React__namespace.createElement(
@@ -5710,10 +5736,11 @@ flowchart TD
5710
5736
  return /* @__PURE__ */ React.createElement(
5711
5737
  "button",
5712
5738
  {
5713
- className: `w-8 px-1 py-2.5 flex items-center justify-center hover:bg-gray-50 text-gray-200 hover:text-red-500 ${disabled && "pointer-events-none opacity-30 cursor-not-allowed"}`,
5739
+ type: "button",
5740
+ 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"}`,
5714
5741
  onClick
5715
5742
  },
5716
- /* @__PURE__ */ React.createElement(TrashIcon, { className: "fill-current transition-colors ease-out duration-100" })
5743
+ /* @__PURE__ */ React.createElement(TrashIcon, { className: "h-5 w-auto fill-current text-red-500 transition-colors duration-150 ease-out" })
5717
5744
  );
5718
5745
  };
5719
5746
  const DragHandle = ({ isDragging }) => {
@@ -5791,27 +5818,35 @@ flowchart TD
5791
5818
  ))))
5792
5819
  ))));
5793
5820
  };
5794
- const Group = wrapFieldWithError(({ tinaForm, field }) => {
5795
- const cms = useCMS$1();
5796
- React__namespace.useState(false);
5797
- return /* @__PURE__ */ React__namespace.createElement(React__namespace.Fragment, null, /* @__PURE__ */ React__namespace.createElement(
5798
- Header,
5799
- {
5800
- onClick: () => {
5801
- const state = tinaForm.finalForm.getState();
5802
- if (state.invalid === true) {
5803
- cms.alerts.error("Cannot navigate away from an invalid form.");
5804
- return;
5821
+ const Group = wrapFieldWithNoHeader(
5822
+ ({ tinaForm, field }) => {
5823
+ const cms = useCMS$1();
5824
+ return /* @__PURE__ */ React__namespace.createElement(React__namespace.Fragment, null, /* @__PURE__ */ React__namespace.createElement(
5825
+ Header,
5826
+ {
5827
+ onClick: () => {
5828
+ const state = tinaForm.finalForm.getState();
5829
+ if (state.invalid === true) {
5830
+ cms.alerts.error("Cannot navigate away from an invalid form.");
5831
+ return;
5832
+ }
5833
+ cms.dispatch({
5834
+ type: "forms:set-active-field-name",
5835
+ value: { formId: tinaForm.id, fieldName: field.name }
5836
+ });
5805
5837
  }
5806
- cms.dispatch({
5807
- type: "forms:set-active-field-name",
5808
- value: { formId: tinaForm.id, fieldName: field.name }
5809
- });
5810
- }
5811
- },
5812
- field.label || field.name
5813
- ));
5814
- });
5838
+ },
5839
+ field.label || field.name,
5840
+ field.description && /* @__PURE__ */ React__namespace.createElement(
5841
+ "span",
5842
+ {
5843
+ className: `block font-sans text-xs italic font-light text-gray-400 pt-0.5 whitespace-normal m-0`,
5844
+ dangerouslySetInnerHTML: { __html: field.description }
5845
+ }
5846
+ )
5847
+ ));
5848
+ }
5849
+ );
5815
5850
  const Header = ({ onClick, children }) => {
5816
5851
  return /* @__PURE__ */ React__namespace.createElement("div", { className: "pt-1 mb-5" }, /* @__PURE__ */ React__namespace.createElement(
5817
5852
  "button",
@@ -10308,7 +10343,7 @@ flowchart TD
10308
10343
  "Event Log"
10309
10344
  ));
10310
10345
  };
10311
- const version = "2.2.9";
10346
+ const version = "2.5.0";
10312
10347
  const Nav = ({
10313
10348
  isLocalMode,
10314
10349
  className = "",
@@ -12839,15 +12874,14 @@ flowchart TD
12839
12874
  fields: fieldGroup.fields
12840
12875
  }
12841
12876
  ) : /* @__PURE__ */ React__namespace.createElement(NoFieldsPlaceholder, null)
12842
- )), !hideFooter && /* @__PURE__ */ React__namespace.createElement("div", { className: "relative flex-none w-full h-16 px-6 bg-white border-t border-gray-100 flex items-center justify-center" }, /* @__PURE__ */ React__namespace.createElement("div", { className: "flex-1 w-full flex justify-between gap-4 items-center max-w-form" }, tinaForm.reset && /* @__PURE__ */ React__namespace.createElement(
12877
+ )), !hideFooter && /* @__PURE__ */ React__namespace.createElement("div", { className: "relative flex-none w-full h-16 px-12 bg-white border-t border-gray-100 flex items-center justify-end" }, /* @__PURE__ */ React__namespace.createElement("div", { className: "flex-1 w-full justify-end gap-2 flex items-center max-w-form" }, tinaForm.reset && /* @__PURE__ */ React__namespace.createElement(
12843
12878
  ResetForm,
12844
12879
  {
12845
12880
  pristine,
12846
12881
  reset: async () => {
12847
12882
  finalForm2.reset();
12848
12883
  await tinaForm.reset();
12849
- },
12850
- style: { flexGrow: 1 }
12884
+ }
12851
12885
  },
12852
12886
  tinaForm.buttons.reset
12853
12887
  ), /* @__PURE__ */ React__namespace.createElement(
@@ -12856,8 +12890,7 @@ flowchart TD
12856
12890
  onClick: safeHandleSubmit,
12857
12891
  disabled: !canSubmit,
12858
12892
  busy: submitting,
12859
- variant: "primary",
12860
- style: { flexGrow: 3 }
12893
+ variant: "primary"
12861
12894
  },
12862
12895
  submitting && /* @__PURE__ */ React__namespace.createElement(LoadingDots, null),
12863
12896
  !submitting && tinaForm.buttons.save
@@ -13827,6 +13860,7 @@ flowchart TD
13827
13860
  "Unordered List",
13828
13861
  "Ordered List",
13829
13862
  "Quote",
13863
+ "Mermaid",
13830
13864
  "Heading 1",
13831
13865
  "Heading 2",
13832
13866
  "Heading 3",
@@ -14426,6 +14460,7 @@ flowchart TD
14426
14460
  ToolbarButton,
14427
14461
  {
14428
14462
  showArrow: false,
14463
+ "data-testid": "rich-text-editor-overflow-menu-button",
14429
14464
  className: "lg:min-w-[130px]",
14430
14465
  isDropdown: true,
14431
14466
  pressed: openState.open,
@@ -14479,7 +14514,17 @@ flowchart TD
14479
14514
  };
14480
14515
  const RawMarkdownToolbarButton = cn$1.withRef(({ clear, ...rest }, ref) => {
14481
14516
  const { props } = useRawMarkdownToolbarButton();
14482
- return /* @__PURE__ */ React.createElement(ToolbarButton, { ref, tooltip: "Link", ...rest, ...props }, /* @__PURE__ */ React.createElement(Icons.raw, null));
14517
+ return /* @__PURE__ */ React.createElement(
14518
+ ToolbarButton,
14519
+ {
14520
+ ref,
14521
+ tooltip: "Link",
14522
+ ...rest,
14523
+ ...props,
14524
+ "data-testid": "markdown-button"
14525
+ },
14526
+ /* @__PURE__ */ React.createElement(Icons.raw, null)
14527
+ );
14483
14528
  });
14484
14529
  function TableDropdownMenu(props) {
14485
14530
  const tableSelected = plateCommon.useEditorSelector(
@@ -30078,6 +30123,7 @@ mutation addPendingDocumentMutation(
30078
30123
  relativePath
30079
30124
  filename
30080
30125
  extension
30126
+ hasReferences
30081
30127
  }
30082
30128
  }
30083
30129
  }
@@ -30169,6 +30215,9 @@ mutation addPendingDocumentMutation(
30169
30215
  document(collection:$collection, relativePath:$relativePath) {
30170
30216
  ... on Document {
30171
30217
  _values
30218
+ _sys {
30219
+ hasReferences
30220
+ }
30172
30221
  }
30173
30222
  }
30174
30223
  }`;
@@ -31895,6 +31944,23 @@ This will work when developing locally but NOT when deployed to production.
31895
31944
  DeleteModal,
31896
31945
  {
31897
31946
  filename: vars.relativePath,
31947
+ checkRefsFunc: async () => {
31948
+ var _a2, _b2;
31949
+ try {
31950
+ const doc = await admin.fetchDocument(
31951
+ collection.name,
31952
+ vars.relativePath,
31953
+ true
31954
+ );
31955
+ return (_b2 = (_a2 = doc == null ? void 0 : doc.document) == null ? void 0 : _a2._sys) == null ? void 0 : _b2.hasReferences;
31956
+ } catch (error) {
31957
+ cms.alerts.error(
31958
+ "Document was not found, ask a developer for help or check the console for an error message"
31959
+ );
31960
+ console.error(error);
31961
+ throw error;
31962
+ }
31963
+ },
31898
31964
  deleteFunc: async () => {
31899
31965
  try {
31900
31966
  await admin.deleteDocument(vars);
@@ -31903,6 +31969,12 @@ This will work when developing locally but NOT when deployed to production.
31903
31969
  );
31904
31970
  reFetchCollection();
31905
31971
  } catch (error) {
31972
+ if (error.message.indexOf("has references")) {
31973
+ cms.alerts.error(
31974
+ error.message.split("\n ").filter(Boolean)[1]
31975
+ );
31976
+ return;
31977
+ }
31906
31978
  cms.alerts.warn(
31907
31979
  "Document was not deleted, ask a developer for help or check the console for an error message"
31908
31980
  );
@@ -31954,6 +32026,12 @@ This will work when developing locally but NOT when deployed to production.
31954
32026
  cms.alerts.info("Document was successfully renamed");
31955
32027
  reFetchCollection();
31956
32028
  } catch (error) {
32029
+ if (error.message.indexOf("has references")) {
32030
+ cms.alerts.error(
32031
+ error.message.split("\n ").filter(Boolean)[1]
32032
+ );
32033
+ return;
32034
+ }
31957
32035
  cms.alerts.warn(
31958
32036
  "Document was not renamed, ask a developer for help or check the console for an error message"
31959
32037
  );
@@ -32427,8 +32505,19 @@ This will work when developing locally but NOT when deployed to production.
32427
32505
  const NoDocumentsPlaceholder = () => {
32428
32506
  return /* @__PURE__ */ React.createElement("div", { className: "text-center px-5 py-3 flex flex-col items-center justify-center shadow border border-gray-100 bg-gray-50 border-b border-gray-200 w-full max-w-full rounded-lg" }, /* @__PURE__ */ React.createElement("p", { className: "text-base italic font-medium text-gray-300" }, "No documents found."));
32429
32507
  };
32430
- const DeleteModal = ({ close: close2, deleteFunc, filename }) => {
32431
- return /* @__PURE__ */ React.createElement(Modal, null, /* @__PURE__ */ React.createElement(PopupModal, null, /* @__PURE__ */ React.createElement(ModalHeader, { close: close2 }, "Delete ", filename), /* @__PURE__ */ React.createElement(ModalBody, { padded: true }, /* @__PURE__ */ React.createElement("p", null, `Are you sure you want to delete ${filename}?`)), /* @__PURE__ */ React.createElement(ModalActions, null, /* @__PURE__ */ React.createElement(Button$1, { style: { flexGrow: 2 }, onClick: close2 }, "Cancel"), /* @__PURE__ */ React.createElement(
32508
+ const DeleteModal = ({
32509
+ close: close2,
32510
+ deleteFunc,
32511
+ checkRefsFunc,
32512
+ filename
32513
+ }) => {
32514
+ const [hasRefs, setHasRefs] = React.useState();
32515
+ React.useEffect(() => {
32516
+ checkRefsFunc().then((result) => {
32517
+ setHasRefs(result);
32518
+ });
32519
+ }, [filename, checkRefsFunc]);
32520
+ return /* @__PURE__ */ React.createElement(Modal, null, /* @__PURE__ */ React.createElement(PopupModal, null, /* @__PURE__ */ React.createElement(ModalHeader, { close: close2 }, "Delete ", filename), /* @__PURE__ */ React.createElement(ModalBody, { padded: true }, /* @__PURE__ */ React.createElement("p", null, `Are you sure you want to delete ${filename}?${hasRefs ? " References to this document will also be deleted." : ""}`)), /* @__PURE__ */ React.createElement(ModalActions, null, /* @__PURE__ */ React.createElement(Button$1, { style: { flexGrow: 2 }, onClick: close2 }, "Cancel"), /* @__PURE__ */ React.createElement(
32432
32521
  Button$1,
32433
32522
  {
32434
32523
  style: { flexGrow: 3 },
@@ -33795,6 +33884,7 @@ This will work when developing locally but NOT when deployed to production.
33795
33884
  exports2.useScreenPlugin = useScreenPlugin;
33796
33885
  exports2.useTinaAuthRedirect = useTinaAuthRedirect;
33797
33886
  exports2.wrapFieldWithError = wrapFieldWithError;
33887
+ exports2.wrapFieldWithNoHeader = wrapFieldWithNoHeader;
33798
33888
  exports2.wrapFieldsWithMeta = wrapFieldsWithMeta;
33799
33889
  Object.defineProperties(exports2, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
33800
33890
  });
package/dist/index.mjs CHANGED
@@ -801,6 +801,22 @@ function wrapFieldsWithMeta(Field2) {
801
801
  );
802
802
  };
803
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
+ }
804
820
  function wrapFieldWithError(Field2) {
805
821
  return (props) => {
806
822
  return /* @__PURE__ */ React.createElement(
@@ -873,6 +889,16 @@ const FieldDescription = ({
873
889
  className,
874
890
  ...props
875
891
  }) => {
892
+ if (typeof children === "string") {
893
+ return /* @__PURE__ */ React.createElement(
894
+ "span",
895
+ {
896
+ className: `block font-sans text-xs italic font-light text-gray-400 pt-0.5 whitespace-normal m-0 ${className}`,
897
+ ...props,
898
+ dangerouslySetInnerHTML: { __html: children }
899
+ }
900
+ );
901
+ }
876
902
  return /* @__PURE__ */ React.createElement(
877
903
  "span",
878
904
  {
@@ -1348,7 +1374,7 @@ const MermaidElementWithRef = ({ config }) => {
1348
1374
  useEffect(() => {
1349
1375
  if (mermaidRef.current) {
1350
1376
  mermaid.initialize({ startOnLoad: true });
1351
- mermaid.run();
1377
+ mermaid.init();
1352
1378
  }
1353
1379
  }, [config]);
1354
1380
  return /* @__PURE__ */ React__default.createElement("div", { contentEditable: false, className: "border-border border-b" }, /* @__PURE__ */ React__default.createElement("div", { ref: mermaidRef }, /* @__PURE__ */ React__default.createElement("pre", { className: "mermaid not-tina-prose" }, config)));
@@ -1375,7 +1401,7 @@ flowchart TD
1375
1401
  --> id2(modify me to see changes!)
1376
1402
  id2
1377
1403
  --> id3(Click the top button to preview the changes)
1378
- --> id4(Learn about mermaid diagrams @ mermaid.js.org)`;
1404
+ --> id4(Learn about mermaid diagrams - mermaid.js.org)`;
1379
1405
  const MermaidElement = withRef(
1380
1406
  ({ children, nodeProps, element, ...props }, ref) => {
1381
1407
  const [mermaidConfig, setMermaidConfig] = useState(
@@ -1391,7 +1417,7 @@ const MermaidElement = withRef(
1391
1417
  children: [{ type: "text", text: "" }]
1392
1418
  };
1393
1419
  useEffect(() => {
1394
- if (mermaid.parse(mermaidConfig, { suppressErrors: false })) {
1420
+ if (mermaid.parse(mermaidConfig)) {
1395
1421
  setMermaidError(null);
1396
1422
  }
1397
1423
  }, [mermaidConfig]);
@@ -3703,7 +3729,7 @@ const Button$1 = ({
3703
3729
  };
3704
3730
  const sizeClasses = {
3705
3731
  small: `text-xs h-8 px-3`,
3706
- medium: `text-sm h-10 px-4`,
3732
+ medium: `text-sm h-10 px-8`,
3707
3733
  custom: ``
3708
3734
  };
3709
3735
  return /* @__PURE__ */ React.createElement(
@@ -5737,10 +5763,11 @@ const ItemDeleteButton = ({ onClick, disabled = false }) => {
5737
5763
  return /* @__PURE__ */ React__default.createElement(
5738
5764
  "button",
5739
5765
  {
5740
- className: `w-8 px-1 py-2.5 flex items-center justify-center hover:bg-gray-50 text-gray-200 hover:text-red-500 ${disabled && "pointer-events-none opacity-30 cursor-not-allowed"}`,
5766
+ type: "button",
5767
+ 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"}`,
5741
5768
  onClick
5742
5769
  },
5743
- /* @__PURE__ */ React__default.createElement(TrashIcon, { className: "fill-current transition-colors ease-out duration-100" })
5770
+ /* @__PURE__ */ React__default.createElement(TrashIcon, { className: "h-5 w-auto fill-current text-red-500 transition-colors duration-150 ease-out" })
5744
5771
  );
5745
5772
  };
5746
5773
  const DragHandle = ({ isDragging }) => {
@@ -5818,27 +5845,35 @@ const BlockSelector = ({
5818
5845
  ))))
5819
5846
  ))));
5820
5847
  };
5821
- const Group = wrapFieldWithError(({ tinaForm, field }) => {
5822
- const cms = useCMS$1();
5823
- React.useState(false);
5824
- return /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(
5825
- Header,
5826
- {
5827
- onClick: () => {
5828
- const state = tinaForm.finalForm.getState();
5829
- if (state.invalid === true) {
5830
- cms.alerts.error("Cannot navigate away from an invalid form.");
5831
- return;
5848
+ const Group = wrapFieldWithNoHeader(
5849
+ ({ tinaForm, field }) => {
5850
+ const cms = useCMS$1();
5851
+ return /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(
5852
+ Header,
5853
+ {
5854
+ onClick: () => {
5855
+ const state = tinaForm.finalForm.getState();
5856
+ if (state.invalid === true) {
5857
+ cms.alerts.error("Cannot navigate away from an invalid form.");
5858
+ return;
5859
+ }
5860
+ cms.dispatch({
5861
+ type: "forms:set-active-field-name",
5862
+ value: { formId: tinaForm.id, fieldName: field.name }
5863
+ });
5832
5864
  }
5833
- cms.dispatch({
5834
- type: "forms:set-active-field-name",
5835
- value: { formId: tinaForm.id, fieldName: field.name }
5836
- });
5837
- }
5838
- },
5839
- field.label || field.name
5840
- ));
5841
- });
5865
+ },
5866
+ field.label || field.name,
5867
+ field.description && /* @__PURE__ */ React.createElement(
5868
+ "span",
5869
+ {
5870
+ className: `block font-sans text-xs italic font-light text-gray-400 pt-0.5 whitespace-normal m-0`,
5871
+ dangerouslySetInnerHTML: { __html: field.description }
5872
+ }
5873
+ )
5874
+ ));
5875
+ }
5876
+ );
5842
5877
  const Header = ({ onClick, children }) => {
5843
5878
  return /* @__PURE__ */ React.createElement("div", { className: "pt-1 mb-5" }, /* @__PURE__ */ React.createElement(
5844
5879
  "button",
@@ -10335,7 +10370,7 @@ const SyncStatus = ({ cms, setEventsOpen }) => {
10335
10370
  "Event Log"
10336
10371
  ));
10337
10372
  };
10338
- const version = "2.2.9";
10373
+ const version = "2.5.0";
10339
10374
  const Nav = ({
10340
10375
  isLocalMode,
10341
10376
  className = "",
@@ -12866,15 +12901,14 @@ const FormBuilder = ({
12866
12901
  fields: fieldGroup.fields
12867
12902
  }
12868
12903
  ) : /* @__PURE__ */ React.createElement(NoFieldsPlaceholder, null)
12869
- )), !hideFooter && /* @__PURE__ */ React.createElement("div", { className: "relative flex-none w-full h-16 px-6 bg-white border-t border-gray-100 flex items-center justify-center" }, /* @__PURE__ */ React.createElement("div", { className: "flex-1 w-full flex justify-between gap-4 items-center max-w-form" }, tinaForm.reset && /* @__PURE__ */ React.createElement(
12904
+ )), !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(
12870
12905
  ResetForm,
12871
12906
  {
12872
12907
  pristine,
12873
12908
  reset: async () => {
12874
12909
  finalForm.reset();
12875
12910
  await tinaForm.reset();
12876
- },
12877
- style: { flexGrow: 1 }
12911
+ }
12878
12912
  },
12879
12913
  tinaForm.buttons.reset
12880
12914
  ), /* @__PURE__ */ React.createElement(
@@ -12883,8 +12917,7 @@ const FormBuilder = ({
12883
12917
  onClick: safeHandleSubmit,
12884
12918
  disabled: !canSubmit,
12885
12919
  busy: submitting,
12886
- variant: "primary",
12887
- style: { flexGrow: 3 }
12920
+ variant: "primary"
12888
12921
  },
12889
12922
  submitting && /* @__PURE__ */ React.createElement(LoadingDots, null),
12890
12923
  !submitting && tinaForm.buttons.save
@@ -13854,6 +13887,7 @@ const unsupportedItemsInTable = /* @__PURE__ */ new Set([
13854
13887
  "Unordered List",
13855
13888
  "Ordered List",
13856
13889
  "Quote",
13890
+ "Mermaid",
13857
13891
  "Heading 1",
13858
13892
  "Heading 2",
13859
13893
  "Heading 3",
@@ -14453,6 +14487,7 @@ function OverflowMenu({
14453
14487
  ToolbarButton,
14454
14488
  {
14455
14489
  showArrow: false,
14490
+ "data-testid": "rich-text-editor-overflow-menu-button",
14456
14491
  className: "lg:min-w-[130px]",
14457
14492
  isDropdown: true,
14458
14493
  pressed: openState.open,
@@ -14506,7 +14541,17 @@ const useRawMarkdownToolbarButton = () => {
14506
14541
  };
14507
14542
  const RawMarkdownToolbarButton = withRef(({ clear, ...rest }, ref) => {
14508
14543
  const { props } = useRawMarkdownToolbarButton();
14509
- return /* @__PURE__ */ React__default.createElement(ToolbarButton, { ref, tooltip: "Link", ...rest, ...props }, /* @__PURE__ */ React__default.createElement(Icons.raw, null));
14544
+ return /* @__PURE__ */ React__default.createElement(
14545
+ ToolbarButton,
14546
+ {
14547
+ ref,
14548
+ tooltip: "Link",
14549
+ ...rest,
14550
+ ...props,
14551
+ "data-testid": "markdown-button"
14552
+ },
14553
+ /* @__PURE__ */ React__default.createElement(Icons.raw, null)
14554
+ );
14510
14555
  });
14511
14556
  function TableDropdownMenu(props) {
14512
14557
  const tableSelected = useEditorSelector(
@@ -30105,6 +30150,7 @@ class TinaAdminApi {
30105
30150
  relativePath
30106
30151
  filename
30107
30152
  extension
30153
+ hasReferences
30108
30154
  }
30109
30155
  }
30110
30156
  }
@@ -30196,6 +30242,9 @@ class TinaAdminApi {
30196
30242
  document(collection:$collection, relativePath:$relativePath) {
30197
30243
  ... on Document {
30198
30244
  _values
30245
+ _sys {
30246
+ hasReferences
30247
+ }
30199
30248
  }
30200
30249
  }
30201
30250
  }`;
@@ -31922,6 +31971,23 @@ const CollectionListPage = () => {
31922
31971
  DeleteModal,
31923
31972
  {
31924
31973
  filename: vars.relativePath,
31974
+ checkRefsFunc: async () => {
31975
+ var _a2, _b2;
31976
+ try {
31977
+ const doc = await admin.fetchDocument(
31978
+ collection.name,
31979
+ vars.relativePath,
31980
+ true
31981
+ );
31982
+ return (_b2 = (_a2 = doc == null ? void 0 : doc.document) == null ? void 0 : _a2._sys) == null ? void 0 : _b2.hasReferences;
31983
+ } catch (error) {
31984
+ cms.alerts.error(
31985
+ "Document was not found, ask a developer for help or check the console for an error message"
31986
+ );
31987
+ console.error(error);
31988
+ throw error;
31989
+ }
31990
+ },
31925
31991
  deleteFunc: async () => {
31926
31992
  try {
31927
31993
  await admin.deleteDocument(vars);
@@ -31930,6 +31996,12 @@ const CollectionListPage = () => {
31930
31996
  );
31931
31997
  reFetchCollection();
31932
31998
  } catch (error) {
31999
+ if (error.message.indexOf("has references")) {
32000
+ cms.alerts.error(
32001
+ error.message.split("\n ").filter(Boolean)[1]
32002
+ );
32003
+ return;
32004
+ }
31933
32005
  cms.alerts.warn(
31934
32006
  "Document was not deleted, ask a developer for help or check the console for an error message"
31935
32007
  );
@@ -31981,6 +32053,12 @@ const CollectionListPage = () => {
31981
32053
  cms.alerts.info("Document was successfully renamed");
31982
32054
  reFetchCollection();
31983
32055
  } catch (error) {
32056
+ if (error.message.indexOf("has references")) {
32057
+ cms.alerts.error(
32058
+ error.message.split("\n ").filter(Boolean)[1]
32059
+ );
32060
+ return;
32061
+ }
31984
32062
  cms.alerts.warn(
31985
32063
  "Document was not renamed, ask a developer for help or check the console for an error message"
31986
32064
  );
@@ -32454,8 +32532,19 @@ const Breadcrumb = ({ folder, navigate, collectionName }) => {
32454
32532
  const NoDocumentsPlaceholder = () => {
32455
32533
  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."));
32456
32534
  };
32457
- const DeleteModal = ({ close: close2, deleteFunc, filename }) => {
32458
- 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}?`)), /* @__PURE__ */ React__default.createElement(ModalActions, null, /* @__PURE__ */ React__default.createElement(Button$1, { style: { flexGrow: 2 }, onClick: close2 }, "Cancel"), /* @__PURE__ */ React__default.createElement(
32535
+ const DeleteModal = ({
32536
+ close: close2,
32537
+ deleteFunc,
32538
+ checkRefsFunc,
32539
+ filename
32540
+ }) => {
32541
+ const [hasRefs, setHasRefs] = React__default.useState();
32542
+ useEffect(() => {
32543
+ checkRefsFunc().then((result) => {
32544
+ setHasRefs(result);
32545
+ });
32546
+ }, [filename, checkRefsFunc]);
32547
+ 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(
32459
32548
  Button$1,
32460
32549
  {
32461
32550
  style: { flexGrow: 3 },
@@ -33817,5 +33906,6 @@ export {
33817
33906
  useScreenPlugin,
33818
33907
  useTinaAuthRedirect,
33819
33908
  wrapFieldWithError,
33909
+ wrapFieldWithNoHeader,
33820
33910
  wrapFieldsWithMeta
33821
33911
  };
@@ -1,18 +1,24 @@
1
- const makeCacheDir = async (dir, fs) => {
2
- const path = await import("./__vite-browser-external-d06ac358.mjs");
3
- const os = await import("./__vite-browser-external-d06ac358.mjs");
4
- const parts = dir.split(path.sep).filter(Boolean);
1
+ const makeCacheDir = async (dir, fs, path, os) => {
2
+ const pathParts = dir.split(path.sep).filter(Boolean);
3
+ const cacheHash = pathParts[pathParts.length - 1];
4
+ const rootUser = pathParts[0];
5
5
  let cacheDir = dir;
6
- if (!fs.existsSync(path.join(path.sep, parts[0]))) {
7
- cacheDir = path.join(os.tmpdir(), parts[parts.length - 1]);
6
+ if (!fs.existsSync(path.join(path.sep, rootUser))) {
7
+ cacheDir = path.join(os.tmpdir(), cacheHash);
8
+ }
9
+ try {
10
+ fs.mkdirSync(cacheDir, { recursive: true });
11
+ } catch (error) {
12
+ throw new Error(`Failed to create cache directory: ${error.message}`);
8
13
  }
9
- fs.mkdirSync(cacheDir, { recursive: true });
10
14
  return cacheDir;
11
15
  };
12
16
  const NodeCache = async (dir) => {
13
- const fs = await import("./__vite-browser-external-d06ac358.mjs");
14
- const { createHash } = await import("./__vite-browser-external-d06ac358.mjs");
15
- const cacheDir = await makeCacheDir(dir, fs);
17
+ const fs = require("node:fs");
18
+ const path = require("node:path");
19
+ const os = require("node:os");
20
+ const { createHash } = require("node:crypto");
21
+ const cacheDir = await makeCacheDir(dir, fs, path, os);
16
22
  return {
17
23
  makeKey: (key) => {
18
24
  const input = key && key instanceof Object ? JSON.stringify(key) : key || "";
@@ -39,5 +45,6 @@ const NodeCache = async (dir) => {
39
45
  };
40
46
  };
41
47
  export {
42
- NodeCache
48
+ NodeCache,
49
+ makeCacheDir
43
50
  };
@@ -3,6 +3,14 @@ import { FieldProps } from './field-props';
3
3
  import { Form } from '../../forms';
4
4
  export type InputFieldType<ExtraFieldProps, InputProps> = FieldProps<InputProps> & ExtraFieldProps;
5
5
  export declare function wrapFieldsWithMeta<ExtraFieldProps = {}, InputProps = {}>(Field: React.FunctionComponent<InputFieldType<ExtraFieldProps, InputProps>> | React.ComponentClass<InputFieldType<ExtraFieldProps, InputProps>>): (props: InputFieldType<ExtraFieldProps, InputProps>) => React.JSX.Element;
6
+ /**
7
+ * Same as wrapFieldsWithMeta but excludes the label, and description useful for fields that render their label and description
8
+ */
9
+ export declare function wrapFieldWithNoHeader<ExtraFieldProps = {}, InputProps = {}>(Field: React.FunctionComponent<InputFieldType<ExtraFieldProps, InputProps>> | React.ComponentClass<InputFieldType<ExtraFieldProps, InputProps>>): (props: InputFieldType<ExtraFieldProps, InputProps>) => React.JSX.Element;
10
+ /**
11
+ * Same as above but excludes the label, useful for fields that have their own label
12
+ * @deprecated This function is deprecated and will be removed in future versions.
13
+ */
6
14
  export declare function wrapFieldWithError<ExtraFieldProps = {}, InputProps = {}>(Field: React.FunctionComponent<InputFieldType<ExtraFieldProps, InputProps>> | React.ComponentClass<InputFieldType<ExtraFieldProps, InputProps>>): (props: InputFieldType<ExtraFieldProps, InputProps>) => React.JSX.Element;
7
15
  interface FieldMetaProps extends React.HTMLAttributes<HTMLElement> {
8
16
  name: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tinacms",
3
- "version": "0.0.0-b370466-20241010070714",
3
+ "version": "0.0.0-b720fb9-20241203044105",
4
4
  "main": "dist/index.js",
5
5
  "module": "./dist/index.mjs",
6
6
  "exports": {
@@ -60,21 +60,21 @@
60
60
  "typings": "dist/index.d.ts",
61
61
  "license": "Apache-2.0",
62
62
  "dependencies": {
63
- "@ariakit/react": "^0.4.11",
64
- "@floating-ui/dom": "^1.6.11",
63
+ "@ariakit/react": "^0.4.13",
64
+ "@floating-ui/dom": "^1.6.12",
65
65
  "@floating-ui/react-dom": "^2.1.2",
66
- "@graphql-inspector/core": "^6.1.0",
66
+ "@graphql-inspector/core": "^6.2.0",
67
67
  "@headlessui/react": "2.1.8",
68
68
  "@heroicons/react": "^1.0.6",
69
69
  "@monaco-editor/react": "4.4.5",
70
- "@radix-ui/react-checkbox": "^1.1.1",
71
- "@radix-ui/react-dialog": "^1.1.1",
72
- "@radix-ui/react-dropdown-menu": "^2.1.1",
73
- "@radix-ui/react-popover": "^1.1.1",
70
+ "@radix-ui/react-checkbox": "^1.1.2",
71
+ "@radix-ui/react-dialog": "^1.1.2",
72
+ "@radix-ui/react-dropdown-menu": "^2.1.2",
73
+ "@radix-ui/react-popover": "^1.1.2",
74
74
  "@radix-ui/react-separator": "^1.1.0",
75
75
  "@radix-ui/react-slot": "^1.1.0",
76
76
  "@radix-ui/react-toolbar": "^1.1.0",
77
- "@radix-ui/react-tooltip": "^1.1.2",
77
+ "@radix-ui/react-tooltip": "^1.1.4",
78
78
  "@react-hook/window-size": "^3.1.1",
79
79
  "@udecode/cn": "^33.0.0",
80
80
  "@udecode/plate": "^36.5.9",
@@ -94,7 +94,7 @@
94
94
  "@udecode/plate-table": "36.5.8",
95
95
  "class-variance-authority": "^0.7.0",
96
96
  "clsx": "^2.1.1",
97
- "cmdk": "^1.0.0",
97
+ "cmdk": "^1.0.4",
98
98
  "color-string": "^1.9.1",
99
99
  "crypto-js": "^4.2.0",
100
100
  "date-fns": "2.30.0",
@@ -108,7 +108,7 @@
108
108
  "lodash.get": "^4.4.2",
109
109
  "lodash.set": "^4.3.2",
110
110
  "lucide-react": "^0.424.0",
111
- "mermaid": "^10.9.1",
111
+ "mermaid": "9.3.0",
112
112
  "moment": "2.29.4",
113
113
  "monaco-editor": "0.31.0",
114
114
  "prism-react-renderer": "^2.4.0",
@@ -125,18 +125,18 @@
125
125
  "slate-history": "^0.100.0",
126
126
  "slate-hyperscript": "^0.100.0",
127
127
  "slate-react": "^0.107.1",
128
- "tailwind-merge": "^2.5.2",
128
+ "tailwind-merge": "^2.5.4",
129
129
  "webfontloader": "1.6.28",
130
130
  "yup": "^1.4.0",
131
131
  "zod": "^3.23.8",
132
- "@tinacms/mdx": "0.0.0-b370466-20241010070714",
133
- "@tinacms/schema-tools": "0.0.0-b370466-20241010070714",
134
- "@tinacms/search": "0.0.0-b370466-20241010070714"
132
+ "@tinacms/mdx": "1.5.2",
133
+ "@tinacms/schema-tools": "1.6.8",
134
+ "@tinacms/search": "1.0.35"
135
135
  },
136
136
  "devDependencies": {
137
- "@graphql-tools/utils": "^10.5.4",
137
+ "@graphql-tools/utils": "^10.5.6",
138
138
  "@testing-library/dom": "^10.4.0",
139
- "@testing-library/jest-dom": "^6.5.0",
139
+ "@testing-library/jest-dom": "^6.6.3",
140
140
  "@testing-library/react": "^16.0.1",
141
141
  "@testing-library/user-event": "^14.5.2",
142
142
  "@types/atob": "^2.1.4",
@@ -144,14 +144,14 @@
144
144
  "@types/color-string": "^1.5.5",
145
145
  "@types/lodash.debounce": "^4.0.9",
146
146
  "@types/lodash.get": "^4.4.9",
147
- "@types/node": "^22.7.4",
147
+ "@types/node": "^22.9.0",
148
148
  "@types/prop-types": "^15.7.13",
149
- "@types/react": "^18.3.10",
149
+ "@types/react": "^18.3.12",
150
150
  "@types/react-beautiful-dnd": "^13.1.8",
151
151
  "@types/react-color": "^3.0.12",
152
- "@types/react-dom": "^18.3.0",
152
+ "@types/react-dom": "^18.3.1",
153
153
  "@types/yup": "^0.32.0",
154
- "happy-dom": "^14.12.3",
154
+ "happy-dom": "15.10.2",
155
155
  "identity-obj-proxy": "^3.0.0",
156
156
  "isomorphic-fetch": "^3.0.0",
157
157
  "jest-file-snapshot": "^0.7.0",
@@ -160,11 +160,11 @@
160
160
  "react-dom": "^18.3.1",
161
161
  "react-is": "^18.3.1",
162
162
  "tsc-alias": "^1.8.10",
163
- "tslib": "^2.7.0",
164
- "typescript": "^5.6.2",
165
- "vite": "^5.4.8",
166
- "vitest": "^2.1.1",
167
- "@tinacms/scripts": "0.0.0-b370466-20241010070714"
163
+ "tslib": "^2.8.1",
164
+ "typescript": "^5.6.3",
165
+ "vite": "^5.4.11",
166
+ "vitest": "^2.1.5",
167
+ "@tinacms/scripts": "1.3.1"
168
168
  },
169
169
  "peerDependencies": {
170
170
  "react": ">=16.14.0",
@@ -1,4 +0,0 @@
1
- const __viteBrowserExternal = {};
2
- export {
3
- __viteBrowserExternal as default
4
- };