tinacms 0.0.0-d7c745e-20250102002342 → 0.0.0-d9672bc-20250218033222

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  (function(global, factory) {
2
- typeof exports === "object" && typeof module !== "undefined" ? factory(exports) : typeof define === "function" && define.amd ? define(["exports"], factory) : (global = typeof globalThis !== "undefined" ? globalThis : global || self, factory(global.tinacms = {}));
3
- })(this, function(exports2) {
2
+ typeof exports === "object" && typeof module !== "undefined" ? factory(exports, require("async-lock")) : typeof define === "function" && define.amd ? define(["exports", "async-lock"], factory) : (global = typeof globalThis !== "undefined" ? globalThis : global || self, factory(global.tinacms = {}, global.NOOP));
3
+ })(this, function(exports2, AsyncLock) {
4
4
  "use strict";
5
5
  const TINA_HOST = "content.tinajs.io";
6
6
  class TinaClient {
@@ -26,6 +26,7 @@
26
26
  if (this.cacheDir && typeof window === "undefined" && typeof require !== "undefined") {
27
27
  const { NodeCache: NodeCache2 } = await Promise.resolve().then(() => nodeCache);
28
28
  this.cache = await NodeCache2(this.cacheDir);
29
+ this.cacheLock = new AsyncLock();
29
30
  }
30
31
  } catch (e) {
31
32
  console.error(e);
@@ -62,42 +63,58 @@
62
63
  ...providedFetchOptions
63
64
  };
64
65
  let key = "";
66
+ let result;
65
67
  if (this.cache) {
66
68
  key = this.cache.makeKey(bodyString);
67
- const value = await this.cache.get(key);
68
- if (value) {
69
- return value;
70
- }
71
- }
72
- const res = await fetch(url, optionsObject);
73
- if (!res.ok) {
74
- let additionalInfo = "";
75
- if (res.status === 401) {
76
- additionalInfo = "Please check that your client ID, URL and read only token are configured properly.";
77
- }
78
- throw new Error(
79
- `Server responded with status code ${res.status}, ${res.statusText}. ${additionalInfo ? additionalInfo : ""} Please see our FAQ for more information: https://tina.io/docs/errors/faq/`
80
- );
81
- }
82
- const json = await res.json();
83
- if (json.errors && errorPolicyDefined === "throw") {
84
- throw new Error(
85
- `Unable to fetch, please see our FAQ for more information: https://tina.io/docs/errors/faq/
86
- Errors:
87
- ${json.errors.map((error) => error.message).join("\n")}`
69
+ await this.cacheLock.acquire(key, async () => {
70
+ result = await this.cache.get(key);
71
+ if (!result) {
72
+ result = await requestFromServer(
73
+ url,
74
+ args.query,
75
+ optionsObject,
76
+ errorPolicyDefined
77
+ );
78
+ await this.cache.set(key, result);
79
+ }
80
+ });
81
+ } else {
82
+ result = await requestFromServer(
83
+ url,
84
+ args.query,
85
+ optionsObject,
86
+ errorPolicyDefined
88
87
  );
89
88
  }
90
- const result = {
91
- data: json == null ? void 0 : json.data,
92
- errors: (json == null ? void 0 : json.errors) || null,
93
- query: args.query
94
- };
95
- if (this.cache) {
96
- await this.cache.set(key, result);
97
- }
98
89
  return result;
99
90
  }
100
91
  }
92
+ async function requestFromServer(url, query, optionsObject, errorPolicyDefined) {
93
+ const res = await fetch(url, optionsObject);
94
+ if (!res.ok) {
95
+ let additionalInfo = "";
96
+ if (res.status === 401) {
97
+ additionalInfo = "Please check that your client ID, URL and read only token are configured properly.";
98
+ }
99
+ throw new Error(
100
+ `Server responded with status code ${res.status}, ${res.statusText}. ${additionalInfo ? additionalInfo : ""} Please see our FAQ for more information: https://tina.io/docs/errors/faq/`
101
+ );
102
+ }
103
+ const json = await res.json();
104
+ if (json.errors && errorPolicyDefined === "throw") {
105
+ throw new Error(
106
+ `Unable to fetch, please see our FAQ for more information: https://tina.io/docs/errors/faq/
107
+ Errors:
108
+ ${json.errors.map((error) => error.message).join("\n")}`
109
+ );
110
+ }
111
+ const result = {
112
+ data: json == null ? void 0 : json.data,
113
+ errors: (json == null ? void 0 : json.errors) || null,
114
+ query
115
+ };
116
+ return result;
117
+ }
101
118
  function createClient(args) {
102
119
  const client = new TinaClient(args);
103
120
  return client;
@@ -129,22 +146,35 @@
129
146
  return createHash("sha256").update(input).digest("hex");
130
147
  },
131
148
  get: async (key) => {
149
+ let readValue;
150
+ const cacheFilename = `${cacheDir}/${key}`;
132
151
  try {
133
- const data = await fs.promises.readFile(`${cacheDir}/${key}`, "utf-8");
134
- return JSON.parse(data);
152
+ const data = await fs.promises.readFile(cacheFilename, "utf-8");
153
+ readValue = JSON.parse(data);
135
154
  } catch (e) {
136
- if (e.code === "ENOENT") {
137
- return void 0;
155
+ if (e.code !== "ENOENT") {
156
+ console.error(
157
+ `Failed to read cache file to ${cacheFilename}: ${e.message}`
158
+ );
138
159
  }
139
- throw e;
140
160
  }
161
+ return readValue;
141
162
  },
142
163
  set: async (key, value) => {
143
- await fs.promises.writeFile(
144
- `${cacheDir}/${key}`,
145
- JSON.stringify(value),
146
- "utf-8"
147
- );
164
+ const cacheFilename = `${cacheDir}/${key}`;
165
+ try {
166
+ await fs.promises.writeFile(cacheFilename, JSON.stringify(value), {
167
+ encoding: "utf-8",
168
+ flag: "wx"
169
+ // Don't overwrite existing caches
170
+ });
171
+ } catch (e) {
172
+ if (e.code !== "EEXIST") {
173
+ console.error(
174
+ `Failed to write cache file to ${cacheFilename}: ${e.message}`
175
+ );
176
+ }
177
+ }
148
178
  }
149
179
  };
150
180
  };
package/dist/client.mjs CHANGED
@@ -1,3 +1,4 @@
1
+ import AsyncLock from "async-lock";
1
2
  const TINA_HOST = "content.tinajs.io";
2
3
  class TinaClient {
3
4
  constructor({
@@ -20,8 +21,9 @@ class TinaClient {
20
21
  }
21
22
  try {
22
23
  if (this.cacheDir && typeof window === "undefined" && typeof require !== "undefined") {
23
- const { NodeCache } = await import("./node-cache-4c336858.mjs");
24
+ const { NodeCache } = await import("./node-cache-5e8db9f0.mjs");
24
25
  this.cache = await NodeCache(this.cacheDir);
26
+ this.cacheLock = new AsyncLock();
25
27
  }
26
28
  } catch (e) {
27
29
  console.error(e);
@@ -58,42 +60,58 @@ class TinaClient {
58
60
  ...providedFetchOptions
59
61
  };
60
62
  let key = "";
63
+ let result;
61
64
  if (this.cache) {
62
65
  key = this.cache.makeKey(bodyString);
63
- const value = await this.cache.get(key);
64
- if (value) {
65
- return value;
66
- }
67
- }
68
- const res = await fetch(url, optionsObject);
69
- if (!res.ok) {
70
- let additionalInfo = "";
71
- if (res.status === 401) {
72
- additionalInfo = "Please check that your client ID, URL and read only token are configured properly.";
73
- }
74
- throw new Error(
75
- `Server responded with status code ${res.status}, ${res.statusText}. ${additionalInfo ? additionalInfo : ""} Please see our FAQ for more information: https://tina.io/docs/errors/faq/`
66
+ await this.cacheLock.acquire(key, async () => {
67
+ result = await this.cache.get(key);
68
+ if (!result) {
69
+ result = await requestFromServer(
70
+ url,
71
+ args.query,
72
+ optionsObject,
73
+ errorPolicyDefined
74
+ );
75
+ await this.cache.set(key, result);
76
+ }
77
+ });
78
+ } else {
79
+ result = await requestFromServer(
80
+ url,
81
+ args.query,
82
+ optionsObject,
83
+ errorPolicyDefined
76
84
  );
77
85
  }
78
- const json = await res.json();
79
- if (json.errors && errorPolicyDefined === "throw") {
80
- throw new Error(
81
- `Unable to fetch, please see our FAQ for more information: https://tina.io/docs/errors/faq/
82
- Errors:
83
- ${json.errors.map((error) => error.message).join("\n")}`
84
- );
85
- }
86
- const result = {
87
- data: json == null ? void 0 : json.data,
88
- errors: (json == null ? void 0 : json.errors) || null,
89
- query: args.query
90
- };
91
- if (this.cache) {
92
- await this.cache.set(key, result);
93
- }
94
86
  return result;
95
87
  }
96
88
  }
89
+ async function requestFromServer(url, query, optionsObject, errorPolicyDefined) {
90
+ const res = await fetch(url, optionsObject);
91
+ if (!res.ok) {
92
+ let additionalInfo = "";
93
+ if (res.status === 401) {
94
+ additionalInfo = "Please check that your client ID, URL and read only token are configured properly.";
95
+ }
96
+ throw new Error(
97
+ `Server responded with status code ${res.status}, ${res.statusText}. ${additionalInfo ? additionalInfo : ""} Please see our FAQ for more information: https://tina.io/docs/errors/faq/`
98
+ );
99
+ }
100
+ const json = await res.json();
101
+ if (json.errors && errorPolicyDefined === "throw") {
102
+ throw new Error(
103
+ `Unable to fetch, please see our FAQ for more information: https://tina.io/docs/errors/faq/
104
+ Errors:
105
+ ${json.errors.map((error) => error.message).join("\n")}`
106
+ );
107
+ }
108
+ const result = {
109
+ data: json == null ? void 0 : json.data,
110
+ errors: (json == null ? void 0 : json.errors) || null,
111
+ query
112
+ };
113
+ return result;
114
+ }
97
115
  function createClient(args) {
98
116
  const client = new TinaClient(args);
99
117
  return client;
package/dist/index.js CHANGED
@@ -5197,7 +5197,7 @@ flowchart TD
5197
5197
  side: "bottom",
5198
5198
  className: cn(
5199
5199
  "rounded-md border bg-white p-4 text-popover-foreground shadow-md outline-none data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",
5200
- "max-h-[30vh] max-w-[30vh] overflow-y-auto",
5200
+ "max-h-[30vh] max-w-[30vw] overflow-y-auto",
5201
5201
  className
5202
5202
  ),
5203
5203
  ...props
@@ -5289,11 +5289,7 @@ flowchart TD
5289
5289
  const node = nodes.find((node2) => node2.id === value);
5290
5290
  return node ? node._internalSys.filename : null;
5291
5291
  };
5292
- const ComboboxDemo = ({
5293
- cms,
5294
- input,
5295
- field
5296
- }) => {
5292
+ const Combobox = ({ cms, input, field }) => {
5297
5293
  const [open2, setOpen] = React__namespace.useState(false);
5298
5294
  const [value, setValue] = React__namespace.useState(input.value);
5299
5295
  const [displayText, setDisplayText] = React__namespace.useState(null);
@@ -5317,17 +5313,17 @@ flowchart TD
5317
5313
  if (loading === true) {
5318
5314
  return /* @__PURE__ */ React__namespace.createElement(LoadingDots, { color: "var(--tina-color-primary)" });
5319
5315
  }
5320
- return /* @__PURE__ */ React__namespace.createElement(React__namespace.Fragment, null, /* @__PURE__ */ React__namespace.createElement(Popover, { open: open2, onOpenChange: setOpen }, /* @__PURE__ */ React__namespace.createElement(PopoverTrigger, { asChild: true }, /* @__PURE__ */ React__namespace.createElement(
5316
+ return /* @__PURE__ */ React__namespace.createElement(Popover, { open: open2, onOpenChange: setOpen }, /* @__PURE__ */ React__namespace.createElement(PopoverTrigger, { asChild: true }, /* @__PURE__ */ React__namespace.createElement(
5321
5317
  Button,
5322
5318
  {
5323
5319
  variant: "outline",
5324
5320
  role: "combobox",
5325
5321
  "aria-expanded": open2,
5326
- className: "w-52 justify-between"
5322
+ className: "w-full justify-between"
5327
5323
  },
5328
5324
  /* @__PURE__ */ React__namespace.createElement("p", { className: "truncate" }, displayText ?? "Choose an option..."),
5329
5325
  open2 ? /* @__PURE__ */ React__namespace.createElement(IoMdArrowDropup, { size: 20 }) : /* @__PURE__ */ React__namespace.createElement(IoMdArrowDropdown, { size: 20 })
5330
- )), /* @__PURE__ */ React__namespace.createElement(PopoverContent, { className: "p-0 relative" }, /* @__PURE__ */ React__namespace.createElement(
5326
+ )), /* @__PURE__ */ React__namespace.createElement(PopoverContent, { className: "p-0 relative min-w-[var(--radix-popover-trigger-width)]" }, /* @__PURE__ */ React__namespace.createElement(
5331
5327
  Command,
5332
5328
  {
5333
5329
  shouldFilter: !field.experimental___filter,
@@ -5351,32 +5347,25 @@ flowchart TD
5351
5347
  }
5352
5348
  ),
5353
5349
  /* @__PURE__ */ React__namespace.createElement(CommandEmpty, null, "No reference found"),
5354
- /* @__PURE__ */ React__namespace.createElement(CommandList, null, filteredOptionsList.length > 0 && (filteredOptionsList == null ? void 0 : filteredOptionsList.map(({ collection, edges }) => /* @__PURE__ */ React__namespace.createElement(
5355
- CommandGroup,
5356
- {
5357
- key: `${collection}-group`,
5358
- heading: collection
5359
- },
5360
- /* @__PURE__ */ React__namespace.createElement(CommandList, null, edges == null ? void 0 : edges.map(({ node }) => {
5361
- const { id, _values } = node;
5362
- return /* @__PURE__ */ React__namespace.createElement(
5363
- OptionComponent,
5364
- {
5365
- id,
5366
- key: id,
5367
- value,
5368
- field,
5369
- _values,
5370
- node,
5371
- onSelect: (currentValue) => {
5372
- setValue(currentValue);
5373
- setOpen(false);
5374
- }
5350
+ /* @__PURE__ */ React__namespace.createElement(CommandList, null, filteredOptionsList.length > 0 && (filteredOptionsList == null ? void 0 : filteredOptionsList.map(({ collection, edges }) => /* @__PURE__ */ React__namespace.createElement(CommandGroup, { key: `${collection}-group`, heading: collection }, /* @__PURE__ */ React__namespace.createElement(CommandList, null, edges == null ? void 0 : edges.map(({ node }) => {
5351
+ const { id, _values } = node;
5352
+ return /* @__PURE__ */ React__namespace.createElement(
5353
+ OptionComponent,
5354
+ {
5355
+ id,
5356
+ key: id,
5357
+ value,
5358
+ field,
5359
+ _values,
5360
+ node,
5361
+ onSelect: (currentValue) => {
5362
+ setValue(currentValue);
5363
+ setOpen(false);
5375
5364
  }
5376
- );
5377
- }))
5378
- ))))
5379
- ))));
5365
+ }
5366
+ );
5367
+ }))))))
5368
+ )));
5380
5369
  };
5381
5370
  const useGetNode = (cms, id) => {
5382
5371
  const [document2, setDocument] = React__namespace.useState(
@@ -5449,7 +5438,7 @@ flowchart TD
5449
5438
  };
5450
5439
  const Reference = ({ input, field }) => {
5451
5440
  const cms = useCMS();
5452
- return /* @__PURE__ */ React__namespace.createElement("div", null, /* @__PURE__ */ React__namespace.createElement("div", { className: "relative group" }, /* @__PURE__ */ React__namespace.createElement(ComboboxDemo, { cms, input, field })), /* @__PURE__ */ React__namespace.createElement(ReferenceLink, { cms, input }));
5441
+ return /* @__PURE__ */ React__namespace.createElement(React__namespace.Fragment, null, /* @__PURE__ */ React__namespace.createElement("div", { className: "relative group" }, /* @__PURE__ */ React__namespace.createElement(Combobox, { cms, input, field })), /* @__PURE__ */ React__namespace.createElement(ReferenceLink, { cms, input }));
5453
5442
  };
5454
5443
  const ButtonToggle = ({
5455
5444
  input,
@@ -9300,6 +9289,19 @@ flowchart TD
9300
9289
  }
9301
9290
  }
9302
9291
  }
9292
+ const encodeUrlIfNeeded = (url) => {
9293
+ if (url) {
9294
+ try {
9295
+ const parsed = new URL(url);
9296
+ parsed.pathname = parsed.pathname.split("/").filter((part) => part !== "").map(encodeURIComponent).join("/");
9297
+ return parsed.toString();
9298
+ } catch (e) {
9299
+ return url;
9300
+ }
9301
+ } else {
9302
+ return url;
9303
+ }
9304
+ };
9303
9305
  let MediaManager$1 = class MediaManager {
9304
9306
  constructor(store, events) {
9305
9307
  this.store = store;
@@ -9372,6 +9374,20 @@ flowchart TD
9372
9374
  try {
9373
9375
  this.events.dispatch({ type: "media:list:start", ...options });
9374
9376
  const media = await this.store.list(options);
9377
+ media.items = media.items.map((item) => {
9378
+ if (item.type === "dir") {
9379
+ return item;
9380
+ }
9381
+ if (item.thumbnails) {
9382
+ for (const [size, src] of Object.entries(item.thumbnails)) {
9383
+ item.thumbnails[size] = encodeUrlIfNeeded(src);
9384
+ }
9385
+ }
9386
+ return {
9387
+ ...item,
9388
+ src: encodeUrlIfNeeded(item.src)
9389
+ };
9390
+ });
9375
9391
  this.events.dispatch({ type: "media:list:success", ...options, media });
9376
9392
  return media;
9377
9393
  } catch (error) {
@@ -10179,7 +10195,7 @@ flowchart TD
10179
10195
  "Event Log"
10180
10196
  ));
10181
10197
  };
10182
- const version = "2.5.2";
10198
+ const version = "2.6.4";
10183
10199
  const Nav = ({
10184
10200
  isLocalMode,
10185
10201
  className = "",
@@ -14499,7 +14515,7 @@ flowchart TD
14499
14515
  key: template.name,
14500
14516
  onMouseDown: (e) => {
14501
14517
  e.preventDefault();
14502
- close();
14518
+ setOpen(false);
14503
14519
  insertMDX(editor, template);
14504
14520
  },
14505
14521
  className: ""
@@ -14585,7 +14601,12 @@ flowchart TD
14585
14601
  const [itemsShown, setItemsShown] = React.useState(11);
14586
14602
  const { overrides, templates } = useToolbarContext();
14587
14603
  const showEmbedButton = templates.length > 0;
14588
- let items2 = overrides === void 0 ? Object.values(toolbarItems) : overrides.map((item) => toolbarItems[item]).filter((item) => item !== void 0);
14604
+ let items2 = [];
14605
+ if (Array.isArray(overrides)) {
14606
+ items2 = overrides === void 0 ? Object.values(toolbarItems) : overrides.map((item) => toolbarItems[item]).filter((item) => item !== void 0);
14607
+ } else {
14608
+ items2 = (overrides == null ? void 0 : overrides.toolbar) === void 0 ? Object.values(toolbarItems) : overrides.toolbar.map((item) => toolbarItems[item]).filter((item) => item !== void 0);
14609
+ }
14589
14610
  if (!showEmbedButton) {
14590
14611
  items2 = items2.filter((item) => item.label !== toolbarItems.embed.label);
14591
14612
  }
@@ -14913,6 +14934,9 @@ flowchart TD
14913
14934
  if (typeof string !== "string") {
14914
14935
  return false;
14915
14936
  }
14937
+ if (string.startsWith("#")) {
14938
+ return true;
14939
+ }
14916
14940
  const generalMatch = string.match(protocolAndDomainRE);
14917
14941
  const emailLinkMatch = string.match(emailLintRE);
14918
14942
  const localUrlMatch = string.match(localUrlRE);
@@ -14934,12 +14958,12 @@ flowchart TD
14934
14958
  }
14935
14959
  return localhostDomainRE.test(everythingAfterProtocol) || nonLocalhostDomainRE.test(everythingAfterProtocol);
14936
14960
  };
14937
- const RichEditor = (props) => {
14961
+ const RichEditor = ({ input, tinaForm, field }) => {
14938
14962
  var _a;
14939
14963
  const initialValue = React.useMemo(
14940
14964
  () => {
14941
14965
  var _a2, _b;
14942
- return ((_b = (_a2 = props.input.value) == null ? void 0 : _a2.children) == null ? void 0 : _b.length) ? props.input.value.children.map(helpers.normalize) : [{ type: "p", children: [{ type: "text", text: "" }] }];
14966
+ return ((_b = (_a2 = input.value) == null ? void 0 : _a2.children) == null ? void 0 : _b.length) ? input.value.children.map(helpers.normalize) : [{ type: "p", children: [{ type: "text", text: "" }] }];
14943
14967
  },
14944
14968
  []
14945
14969
  );
@@ -14967,7 +14991,7 @@ flowchart TD
14967
14991
  ),
14968
14992
  []
14969
14993
  );
14970
- const tempId = [props.tinaForm.id, props.input.name].join(".");
14994
+ const tempId = [tinaForm.id, input.name].join(".");
14971
14995
  const id = React.useMemo(() => uuid() + tempId, [tempId]);
14972
14996
  const ref = React.useRef(null);
14973
14997
  React.useEffect(() => {
@@ -14977,13 +15001,13 @@ flowchart TD
14977
15001
  const plateElement = (_a2 = ref.current) == null ? void 0 : _a2.querySelector(
14978
15002
  '[role="textbox"]'
14979
15003
  );
14980
- if (props.field.experimental_focusIntent && plateElement) {
15004
+ if (field.experimental_focusIntent && plateElement) {
14981
15005
  if (plateElement)
14982
15006
  plateElement.focus();
14983
15007
  }
14984
15008
  }, 100);
14985
15009
  }
14986
- }, [props.field.experimental_focusIntent, ref]);
15010
+ }, [field.experimental_focusIntent, ref]);
14987
15011
  return /* @__PURE__ */ React.createElement("div", { ref }, /* @__PURE__ */ React.createElement(
14988
15012
  plateCommon.Plate,
14989
15013
  {
@@ -14991,7 +15015,7 @@ flowchart TD
14991
15015
  initialValue,
14992
15016
  plugins: plugins$2,
14993
15017
  onChange: (value) => {
14994
- props.input.onChange({
15018
+ input.onChange({
14995
15019
  type: "root",
14996
15020
  children: value
14997
15021
  });
@@ -15000,12 +15024,12 @@ flowchart TD
15000
15024
  /* @__PURE__ */ React.createElement(TooltipProvider, null, /* @__PURE__ */ React.createElement(
15001
15025
  ToolbarProvider,
15002
15026
  {
15003
- tinaForm: props.tinaForm,
15004
- templates: props.field.templates,
15005
- overrides: (_a = props.field) == null ? void 0 : _a.toolbarOverride
15027
+ tinaForm,
15028
+ templates: field.templates,
15029
+ overrides: (field == null ? void 0 : field.toolbarOverride) ? field.toolbarOverride : field.overrides
15006
15030
  },
15007
15031
  /* @__PURE__ */ React.createElement(FixedToolbar, null, /* @__PURE__ */ React.createElement(FixedToolbarButtons, null)),
15008
- /* @__PURE__ */ React.createElement(FloatingToolbar, null, /* @__PURE__ */ React.createElement(FloatingToolbarButtons, null))
15032
+ ((_a = field == null ? void 0 : field.overrides) == null ? void 0 : _a.showFloatingToolbar) !== false ? /* @__PURE__ */ React.createElement(FloatingToolbar, null, /* @__PURE__ */ React.createElement(FloatingToolbarButtons, null)) : null
15009
15033
  ), /* @__PURE__ */ React.createElement(Editor, null))
15010
15034
  ));
15011
15035
  };
@@ -33085,15 +33109,24 @@ This will work when developing locally but NOT when deployed to production.
33085
33109
  }
33086
33110
  }
33087
33111
  if (state === "creatingPR") {
33088
- const foo = await tinaApi.createPullRequest({
33089
- baseBranch,
33090
- branch,
33091
- title: `${branch.replace("tina/", "").replace("-", " ")} (PR from TinaCMS)`
33092
- });
33093
- console.log("PR created", foo);
33094
- cms.alerts.success("Pull request created.");
33095
- localStorage.setItem("tina.createBranchState", "done");
33096
- setState("done");
33112
+ try {
33113
+ const foo = await tinaApi.createPullRequest({
33114
+ baseBranch,
33115
+ branch,
33116
+ title: `${branch.replace("tina/", "").replace("-", " ")} (PR from TinaCMS)`
33117
+ });
33118
+ console.log("PR created", foo);
33119
+ cms.alerts.success("Pull request created.");
33120
+ localStorage.setItem("tina.createBranchState", "done");
33121
+ setState("done");
33122
+ } catch (e) {
33123
+ console.error(e);
33124
+ cms.alerts.error("Failed to create PR");
33125
+ setErrorMessage(
33126
+ "Failed to create PR, please try again. If the problem persists please contact support."
33127
+ );
33128
+ setState("error");
33129
+ }
33097
33130
  }
33098
33131
  if (state === "done") {
33099
33132
  window.location.href = back;
package/dist/index.mjs CHANGED
@@ -15,12 +15,12 @@ import { ELEMENT_SLASH_INPUT, createSlashPlugin } from "@udecode/plate-slash-com
15
15
  import { useSelected, useReadOnly, ReactEditor } from "slate-react";
16
16
  import { useCodeBlockElementState, useCodeSyntaxLeaf, ELEMENT_CODE_BLOCK as ELEMENT_CODE_BLOCK$1 } from "@udecode/plate-code-block";
17
17
  import MonacoEditor, { loader, useMonaco } from "@monaco-editor/react";
18
- import { Combobox, ComboboxInput, ComboboxButton, Transition, ComboboxOptions, ComboboxOption, Popover as Popover$3, PopoverButton, PopoverPanel, TransitionChild, Disclosure, DisclosureButton, DisclosurePanel, Menu, MenuButton, MenuItems, MenuItem } from "@headlessui/react";
18
+ import { Combobox as Combobox$1, ComboboxInput, ComboboxButton, Transition, ComboboxOptions, ComboboxOption, Popover as Popover$3, PopoverButton, PopoverPanel, TransitionChild, Disclosure, DisclosureButton, DisclosurePanel, Menu, MenuButton, MenuItems, MenuItem } from "@headlessui/react";
19
19
  import { cva } from "class-variance-authority";
20
20
  import { Eye, SquarePen, Plus, AlignCenter as AlignCenter$1, AlignJustify, AlignLeft as AlignLeft$1, AlignRight as AlignRight$1, ChevronDown, PaintBucket, Quote, Check, ChevronRight, ChevronsUpDown, X, FileCode, Baseline, RectangleVertical, Combine, Ungroup, MessageSquare, MessageSquarePlus, Trash, GripVertical, Edit2, Smile, ExternalLink, Heading1, Heading2, Heading3, Heading4, Heading5, Heading6, Indent, Keyboard, WrapText, Minus, MoreHorizontal, Outdent, Pilcrow, RotateCcw, RectangleHorizontal, Search, Settings, Strikethrough, Subscript, Superscript, Table, Text, Underline, Link2Off, Moon, SunMedium, Twitter } from "lucide-react";
21
21
  import mermaid from "mermaid";
22
22
  import { ELEMENT_H1, ELEMENT_H2, ELEMENT_H3, ELEMENT_H4 as ELEMENT_H4$1, ELEMENT_H5 as ELEMENT_H5$1, ELEMENT_H6 as ELEMENT_H6$1 } from "@udecode/plate-heading";
23
- import { useComboboxContext, Combobox as Combobox$1, useComboboxStore, ComboboxProvider, Portal, ComboboxPopover, ComboboxItem } from "@ariakit/react";
23
+ import { useComboboxContext, Combobox as Combobox$2, useComboboxStore, ComboboxProvider, Portal, ComboboxPopover, ComboboxItem } from "@ariakit/react";
24
24
  import { useHTMLInputCursorState, useComboboxInput, filterWords } from "@udecode/plate-combobox";
25
25
  import { useTableCellElementState, useTableCellElement, useTableCellElementResizableState, useTableCellElementResizable, useTableBordersDropdownMenuContentState, useTableMergeState, TableProvider, useTableElementState, useTableElement, mergeTableCells, unmergeTableCells, ELEMENT_TABLE as ELEMENT_TABLE$1, getTableColumnCount, insertTable, deleteTable, insertTableColumn, deleteColumn, insertTableRow, deleteRow } from "@udecode/plate-table";
26
26
  import { ResizeHandle as ResizeHandle$1 } from "@udecode/plate-resizable";
@@ -992,7 +992,7 @@ const Autocomplete = ({
992
992
  }
993
993
  }, [items2, query]);
994
994
  return /* @__PURE__ */ React__default.createElement(
995
- Combobox,
995
+ Combobox$1,
996
996
  {
997
997
  value,
998
998
  onChange,
@@ -2173,7 +2173,7 @@ const InlineComboboxInput = forwardRef(({ className, ...props }, propRef) => {
2173
2173
  },
2174
2174
  value || "​"
2175
2175
  ), /* @__PURE__ */ React__default.createElement(
2176
- Combobox$1,
2176
+ Combobox$2,
2177
2177
  {
2178
2178
  autoSelect: true,
2179
2179
  className: cn$1(
@@ -5224,7 +5224,7 @@ const PopoverContent = React.forwardRef(({ className, align = "center", sideOffs
5224
5224
  side: "bottom",
5225
5225
  className: cn(
5226
5226
  "rounded-md border bg-white p-4 text-popover-foreground shadow-md outline-none data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",
5227
- "max-h-[30vh] max-w-[30vh] overflow-y-auto",
5227
+ "max-h-[30vh] max-w-[30vw] overflow-y-auto",
5228
5228
  className
5229
5229
  ),
5230
5230
  ...props
@@ -5316,11 +5316,7 @@ const getFilename = (optionSets, value) => {
5316
5316
  const node = nodes.find((node2) => node2.id === value);
5317
5317
  return node ? node._internalSys.filename : null;
5318
5318
  };
5319
- const ComboboxDemo = ({
5320
- cms,
5321
- input,
5322
- field
5323
- }) => {
5319
+ const Combobox = ({ cms, input, field }) => {
5324
5320
  const [open2, setOpen] = React.useState(false);
5325
5321
  const [value, setValue] = React.useState(input.value);
5326
5322
  const [displayText, setDisplayText] = React.useState(null);
@@ -5344,17 +5340,17 @@ const ComboboxDemo = ({
5344
5340
  if (loading === true) {
5345
5341
  return /* @__PURE__ */ React.createElement(LoadingDots, { color: "var(--tina-color-primary)" });
5346
5342
  }
5347
- return /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(Popover, { open: open2, onOpenChange: setOpen }, /* @__PURE__ */ React.createElement(PopoverTrigger, { asChild: true }, /* @__PURE__ */ React.createElement(
5343
+ return /* @__PURE__ */ React.createElement(Popover, { open: open2, onOpenChange: setOpen }, /* @__PURE__ */ React.createElement(PopoverTrigger, { asChild: true }, /* @__PURE__ */ React.createElement(
5348
5344
  Button,
5349
5345
  {
5350
5346
  variant: "outline",
5351
5347
  role: "combobox",
5352
5348
  "aria-expanded": open2,
5353
- className: "w-52 justify-between"
5349
+ className: "w-full justify-between"
5354
5350
  },
5355
5351
  /* @__PURE__ */ React.createElement("p", { className: "truncate" }, displayText ?? "Choose an option..."),
5356
5352
  open2 ? /* @__PURE__ */ React.createElement(IoMdArrowDropup, { size: 20 }) : /* @__PURE__ */ React.createElement(IoMdArrowDropdown, { size: 20 })
5357
- )), /* @__PURE__ */ React.createElement(PopoverContent, { className: "p-0 relative" }, /* @__PURE__ */ React.createElement(
5353
+ )), /* @__PURE__ */ React.createElement(PopoverContent, { className: "p-0 relative min-w-[var(--radix-popover-trigger-width)]" }, /* @__PURE__ */ React.createElement(
5358
5354
  Command,
5359
5355
  {
5360
5356
  shouldFilter: !field.experimental___filter,
@@ -5378,32 +5374,25 @@ const ComboboxDemo = ({
5378
5374
  }
5379
5375
  ),
5380
5376
  /* @__PURE__ */ React.createElement(CommandEmpty, null, "No reference found"),
5381
- /* @__PURE__ */ React.createElement(CommandList, null, filteredOptionsList.length > 0 && (filteredOptionsList == null ? void 0 : filteredOptionsList.map(({ collection, edges }) => /* @__PURE__ */ React.createElement(
5382
- CommandGroup,
5383
- {
5384
- key: `${collection}-group`,
5385
- heading: collection
5386
- },
5387
- /* @__PURE__ */ React.createElement(CommandList, null, edges == null ? void 0 : edges.map(({ node }) => {
5388
- const { id, _values } = node;
5389
- return /* @__PURE__ */ React.createElement(
5390
- OptionComponent,
5391
- {
5392
- id,
5393
- key: id,
5394
- value,
5395
- field,
5396
- _values,
5397
- node,
5398
- onSelect: (currentValue) => {
5399
- setValue(currentValue);
5400
- setOpen(false);
5401
- }
5377
+ /* @__PURE__ */ React.createElement(CommandList, null, filteredOptionsList.length > 0 && (filteredOptionsList == null ? void 0 : filteredOptionsList.map(({ collection, edges }) => /* @__PURE__ */ React.createElement(CommandGroup, { key: `${collection}-group`, heading: collection }, /* @__PURE__ */ React.createElement(CommandList, null, edges == null ? void 0 : edges.map(({ node }) => {
5378
+ const { id, _values } = node;
5379
+ return /* @__PURE__ */ React.createElement(
5380
+ OptionComponent,
5381
+ {
5382
+ id,
5383
+ key: id,
5384
+ value,
5385
+ field,
5386
+ _values,
5387
+ node,
5388
+ onSelect: (currentValue) => {
5389
+ setValue(currentValue);
5390
+ setOpen(false);
5402
5391
  }
5403
- );
5404
- }))
5405
- ))))
5406
- ))));
5392
+ }
5393
+ );
5394
+ }))))))
5395
+ )));
5407
5396
  };
5408
5397
  const useGetNode = (cms, id) => {
5409
5398
  const [document2, setDocument] = React.useState(
@@ -5476,7 +5465,7 @@ const ReferenceLink = ({ cms, input }) => {
5476
5465
  };
5477
5466
  const Reference = ({ input, field }) => {
5478
5467
  const cms = useCMS();
5479
- return /* @__PURE__ */ React.createElement("div", null, /* @__PURE__ */ React.createElement("div", { className: "relative group" }, /* @__PURE__ */ React.createElement(ComboboxDemo, { cms, input, field })), /* @__PURE__ */ React.createElement(ReferenceLink, { cms, input }));
5468
+ return /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement("div", { className: "relative group" }, /* @__PURE__ */ React.createElement(Combobox, { cms, input, field })), /* @__PURE__ */ React.createElement(ReferenceLink, { cms, input }));
5480
5469
  };
5481
5470
  const ButtonToggle = ({
5482
5471
  input,
@@ -9327,6 +9316,19 @@ class TinaMediaStore {
9327
9316
  }
9328
9317
  }
9329
9318
  }
9319
+ const encodeUrlIfNeeded = (url) => {
9320
+ if (url) {
9321
+ try {
9322
+ const parsed = new URL(url);
9323
+ parsed.pathname = parsed.pathname.split("/").filter((part) => part !== "").map(encodeURIComponent).join("/");
9324
+ return parsed.toString();
9325
+ } catch (e) {
9326
+ return url;
9327
+ }
9328
+ } else {
9329
+ return url;
9330
+ }
9331
+ };
9330
9332
  let MediaManager$1 = class MediaManager {
9331
9333
  constructor(store, events) {
9332
9334
  this.store = store;
@@ -9399,6 +9401,20 @@ let MediaManager$1 = class MediaManager {
9399
9401
  try {
9400
9402
  this.events.dispatch({ type: "media:list:start", ...options });
9401
9403
  const media = await this.store.list(options);
9404
+ media.items = media.items.map((item) => {
9405
+ if (item.type === "dir") {
9406
+ return item;
9407
+ }
9408
+ if (item.thumbnails) {
9409
+ for (const [size, src] of Object.entries(item.thumbnails)) {
9410
+ item.thumbnails[size] = encodeUrlIfNeeded(src);
9411
+ }
9412
+ }
9413
+ return {
9414
+ ...item,
9415
+ src: encodeUrlIfNeeded(item.src)
9416
+ };
9417
+ });
9402
9418
  this.events.dispatch({ type: "media:list:success", ...options, media });
9403
9419
  return media;
9404
9420
  } catch (error) {
@@ -10206,7 +10222,7 @@ const SyncStatus = ({ cms, setEventsOpen }) => {
10206
10222
  "Event Log"
10207
10223
  ));
10208
10224
  };
10209
- const version = "2.5.2";
10225
+ const version = "2.6.4";
10210
10226
  const Nav = ({
10211
10227
  isLocalMode,
10212
10228
  className = "",
@@ -14526,7 +14542,7 @@ const EmbedButton = ({ editor, templates }) => {
14526
14542
  key: template.name,
14527
14543
  onMouseDown: (e) => {
14528
14544
  e.preventDefault();
14529
- close();
14545
+ setOpen(false);
14530
14546
  insertMDX(editor, template);
14531
14547
  },
14532
14548
  className: ""
@@ -14612,7 +14628,12 @@ function FixedToolbarButtons() {
14612
14628
  const [itemsShown, setItemsShown] = React__default.useState(11);
14613
14629
  const { overrides, templates } = useToolbarContext();
14614
14630
  const showEmbedButton = templates.length > 0;
14615
- let items2 = overrides === void 0 ? Object.values(toolbarItems) : overrides.map((item) => toolbarItems[item]).filter((item) => item !== void 0);
14631
+ let items2 = [];
14632
+ if (Array.isArray(overrides)) {
14633
+ items2 = overrides === void 0 ? Object.values(toolbarItems) : overrides.map((item) => toolbarItems[item]).filter((item) => item !== void 0);
14634
+ } else {
14635
+ items2 = (overrides == null ? void 0 : overrides.toolbar) === void 0 ? Object.values(toolbarItems) : overrides.toolbar.map((item) => toolbarItems[item]).filter((item) => item !== void 0);
14636
+ }
14616
14637
  if (!showEmbedButton) {
14617
14638
  items2 = items2.filter((item) => item.label !== toolbarItems.embed.label);
14618
14639
  }
@@ -14940,6 +14961,9 @@ const isUrl = (string) => {
14940
14961
  if (typeof string !== "string") {
14941
14962
  return false;
14942
14963
  }
14964
+ if (string.startsWith("#")) {
14965
+ return true;
14966
+ }
14943
14967
  const generalMatch = string.match(protocolAndDomainRE);
14944
14968
  const emailLinkMatch = string.match(emailLintRE);
14945
14969
  const localUrlMatch = string.match(localUrlRE);
@@ -14961,12 +14985,12 @@ const isUrl = (string) => {
14961
14985
  }
14962
14986
  return localhostDomainRE.test(everythingAfterProtocol) || nonLocalhostDomainRE.test(everythingAfterProtocol);
14963
14987
  };
14964
- const RichEditor = (props) => {
14988
+ const RichEditor = ({ input, tinaForm, field }) => {
14965
14989
  var _a;
14966
14990
  const initialValue = React__default.useMemo(
14967
14991
  () => {
14968
14992
  var _a2, _b;
14969
- return ((_b = (_a2 = props.input.value) == null ? void 0 : _a2.children) == null ? void 0 : _b.length) ? props.input.value.children.map(helpers.normalize) : [{ type: "p", children: [{ type: "text", text: "" }] }];
14993
+ return ((_b = (_a2 = input.value) == null ? void 0 : _a2.children) == null ? void 0 : _b.length) ? input.value.children.map(helpers.normalize) : [{ type: "p", children: [{ type: "text", text: "" }] }];
14970
14994
  },
14971
14995
  []
14972
14996
  );
@@ -14994,7 +15018,7 @@ const RichEditor = (props) => {
14994
15018
  ),
14995
15019
  []
14996
15020
  );
14997
- const tempId = [props.tinaForm.id, props.input.name].join(".");
15021
+ const tempId = [tinaForm.id, input.name].join(".");
14998
15022
  const id = React__default.useMemo(() => uuid() + tempId, [tempId]);
14999
15023
  const ref = React__default.useRef(null);
15000
15024
  React__default.useEffect(() => {
@@ -15004,13 +15028,13 @@ const RichEditor = (props) => {
15004
15028
  const plateElement = (_a2 = ref.current) == null ? void 0 : _a2.querySelector(
15005
15029
  '[role="textbox"]'
15006
15030
  );
15007
- if (props.field.experimental_focusIntent && plateElement) {
15031
+ if (field.experimental_focusIntent && plateElement) {
15008
15032
  if (plateElement)
15009
15033
  plateElement.focus();
15010
15034
  }
15011
15035
  }, 100);
15012
15036
  }
15013
- }, [props.field.experimental_focusIntent, ref]);
15037
+ }, [field.experimental_focusIntent, ref]);
15014
15038
  return /* @__PURE__ */ React__default.createElement("div", { ref }, /* @__PURE__ */ React__default.createElement(
15015
15039
  Plate,
15016
15040
  {
@@ -15018,7 +15042,7 @@ const RichEditor = (props) => {
15018
15042
  initialValue,
15019
15043
  plugins: plugins$2,
15020
15044
  onChange: (value) => {
15021
- props.input.onChange({
15045
+ input.onChange({
15022
15046
  type: "root",
15023
15047
  children: value
15024
15048
  });
@@ -15027,12 +15051,12 @@ const RichEditor = (props) => {
15027
15051
  /* @__PURE__ */ React__default.createElement(TooltipProvider, null, /* @__PURE__ */ React__default.createElement(
15028
15052
  ToolbarProvider,
15029
15053
  {
15030
- tinaForm: props.tinaForm,
15031
- templates: props.field.templates,
15032
- overrides: (_a = props.field) == null ? void 0 : _a.toolbarOverride
15054
+ tinaForm,
15055
+ templates: field.templates,
15056
+ overrides: (field == null ? void 0 : field.toolbarOverride) ? field.toolbarOverride : field.overrides
15033
15057
  },
15034
15058
  /* @__PURE__ */ React__default.createElement(FixedToolbar, null, /* @__PURE__ */ React__default.createElement(FixedToolbarButtons, null)),
15035
- /* @__PURE__ */ React__default.createElement(FloatingToolbar, null, /* @__PURE__ */ React__default.createElement(FloatingToolbarButtons, null))
15059
+ ((_a = field == null ? void 0 : field.overrides) == null ? void 0 : _a.showFloatingToolbar) !== false ? /* @__PURE__ */ React__default.createElement(FloatingToolbar, null, /* @__PURE__ */ React__default.createElement(FloatingToolbarButtons, null)) : null
15036
15060
  ), /* @__PURE__ */ React__default.createElement(Editor, null))
15037
15061
  ));
15038
15062
  };
@@ -33112,15 +33136,24 @@ const IndexingPage = () => {
33112
33136
  }
33113
33137
  }
33114
33138
  if (state === "creatingPR") {
33115
- const foo = await tinaApi.createPullRequest({
33116
- baseBranch,
33117
- branch,
33118
- title: `${branch.replace("tina/", "").replace("-", " ")} (PR from TinaCMS)`
33119
- });
33120
- console.log("PR created", foo);
33121
- cms.alerts.success("Pull request created.");
33122
- localStorage.setItem("tina.createBranchState", "done");
33123
- setState("done");
33139
+ try {
33140
+ const foo = await tinaApi.createPullRequest({
33141
+ baseBranch,
33142
+ branch,
33143
+ title: `${branch.replace("tina/", "").replace("-", " ")} (PR from TinaCMS)`
33144
+ });
33145
+ console.log("PR created", foo);
33146
+ cms.alerts.success("Pull request created.");
33147
+ localStorage.setItem("tina.createBranchState", "done");
33148
+ setState("done");
33149
+ } catch (e) {
33150
+ console.error(e);
33151
+ cms.alerts.error("Failed to create PR");
33152
+ setErrorMessage(
33153
+ "Failed to create PR, please try again. If the problem persists please contact support."
33154
+ );
33155
+ setState("error");
33156
+ }
33124
33157
  }
33125
33158
  if (state === "done") {
33126
33159
  window.location.href = back;
@@ -25,22 +25,35 @@ const NodeCache = async (dir) => {
25
25
  return createHash("sha256").update(input).digest("hex");
26
26
  },
27
27
  get: async (key) => {
28
+ let readValue;
29
+ const cacheFilename = `${cacheDir}/${key}`;
28
30
  try {
29
- const data = await fs.promises.readFile(`${cacheDir}/${key}`, "utf-8");
30
- return JSON.parse(data);
31
+ const data = await fs.promises.readFile(cacheFilename, "utf-8");
32
+ readValue = JSON.parse(data);
31
33
  } catch (e) {
32
- if (e.code === "ENOENT") {
33
- return void 0;
34
+ if (e.code !== "ENOENT") {
35
+ console.error(
36
+ `Failed to read cache file to ${cacheFilename}: ${e.message}`
37
+ );
34
38
  }
35
- throw e;
36
39
  }
40
+ return readValue;
37
41
  },
38
42
  set: async (key, value) => {
39
- await fs.promises.writeFile(
40
- `${cacheDir}/${key}`,
41
- JSON.stringify(value),
42
- "utf-8"
43
- );
43
+ const cacheFilename = `${cacheDir}/${key}`;
44
+ try {
45
+ await fs.promises.writeFile(cacheFilename, JSON.stringify(value), {
46
+ encoding: "utf-8",
47
+ flag: "wx"
48
+ // Don't overwrite existing caches
49
+ });
50
+ } catch (e) {
51
+ if (e.code !== "EEXIST") {
52
+ console.error(
53
+ `Failed to write cache file to ${cacheFilename}: ${e.message}`
54
+ );
55
+ }
56
+ }
44
57
  }
45
58
  };
46
59
  };
@@ -7,5 +7,5 @@ interface ReferenceSelectProps {
7
7
  input: any;
8
8
  field: ReferenceFieldProps & Field;
9
9
  }
10
- declare const ComboboxDemo: React.FC<ReferenceSelectProps>;
11
- export default ComboboxDemo;
10
+ declare const Combobox: React.FC<ReferenceSelectProps>;
11
+ export default Combobox;
@@ -2,16 +2,18 @@ import React from 'react';
2
2
  import { type InputFieldType } from '../wrap-field-with-meta';
3
3
  import type { MdxTemplate } from './plate/types';
4
4
  import type { InputProps } from '../../../fields/components';
5
- import type { ToolbarOverrideType } from './plate/toolbar/toolbar-overrides';
5
+ import type { ToolbarOverrides, ToolbarOverrideType } from './plate/toolbar/toolbar-overrides';
6
6
  export type RichTextType = React.PropsWithChildren<InputFieldType<InputProps, {
7
7
  templates: MdxTemplate[];
8
8
  toolbarOverride?: ToolbarOverrideType[];
9
+ overrides?: ToolbarOverrides;
9
10
  }>>;
10
11
  export declare const MdxFieldPlugin: {
11
12
  name: string;
12
13
  Component: (props: InputFieldType<InputProps, {
13
14
  templates: MdxTemplate[];
14
15
  toolbarOverride?: ToolbarOverrideType[];
16
+ overrides?: ToolbarOverrides;
15
17
  }>) => React.JSX.Element;
16
18
  };
17
19
  export declare const MdxFieldPluginExtendible: {
@@ -20,5 +22,6 @@ export declare const MdxFieldPluginExtendible: {
20
22
  Component: (props: InputFieldType<InputProps, {
21
23
  templates: MdxTemplate[];
22
24
  toolbarOverride?: ToolbarOverrideType[];
25
+ overrides?: ToolbarOverrides;
23
26
  }>) => React.JSX.Element;
24
27
  };
@@ -1,3 +1,3 @@
1
1
  import React from 'react';
2
2
  import type { RichTextType } from '..';
3
- export declare const RichEditor: (props: RichTextType) => React.JSX.Element;
3
+ export declare const RichEditor: ({ input, tinaForm, field }: RichTextType) => React.JSX.Element;
@@ -6,3 +6,7 @@ export declare const EMBED_ICON_WIDTH = 78;
6
6
  export declare const CONTAINER_MD_BREAKPOINT = 448;
7
7
  export declare const FLOAT_BUTTON_WIDTH = 25;
8
8
  export declare const HEADING_LABEL = "Headings";
9
+ export type ToolbarOverrides = {
10
+ toolbar?: ToolbarOverrideType[];
11
+ showFloatingToolbar?: boolean;
12
+ };
@@ -2,11 +2,11 @@ import React from 'react';
2
2
  import { type ReactNode } from 'react';
3
3
  import type { Form } from '../../../../../forms';
4
4
  import type { MdxTemplate } from '../types';
5
- import type { ToolbarOverrideType } from './toolbar-overrides';
5
+ import type { ToolbarOverrides, ToolbarOverrideType } from './toolbar-overrides';
6
6
  interface ToolbarContextProps {
7
7
  tinaForm: Form;
8
8
  templates: MdxTemplate[];
9
- overrides: ToolbarOverrideType[];
9
+ overrides: ToolbarOverrideType[] | ToolbarOverrides;
10
10
  }
11
11
  interface ToolbarProviderProps extends ToolbarContextProps {
12
12
  children: ReactNode;
@@ -1,3 +1,5 @@
1
+ import AsyncLock from 'async-lock';
2
+ import type { GraphQLError } from 'graphql';
1
3
  import type { Config } from '@tinacms/schema-tools';
2
4
  import type { Cache } from '../cache/index';
3
5
  export declare const TINA_HOST = "content.tinajs.io";
@@ -25,12 +27,17 @@ export declare class TinaClient<GenQueries> {
25
27
  queries: GenQueries;
26
28
  errorPolicy: Config['client']['errorPolicy'];
27
29
  initialized: boolean;
30
+ cacheLock: AsyncLock | undefined;
28
31
  cacheDir: string;
29
32
  cache: Cache;
30
33
  constructor({ token, url, queries, errorPolicy, cacheDir, }: TinaClientArgs<GenQueries>);
31
34
  init(): Promise<void>;
32
35
  request<DataType extends Record<string, any> = any>({ errorPolicy, ...args }: TinaClientRequestArgs, options: {
33
36
  fetchOptions?: Parameters<typeof fetch>[1];
34
- }): Promise<any>;
37
+ }): Promise<{
38
+ data: DataType;
39
+ errors: GraphQLError[] | null;
40
+ query: string;
41
+ }>;
35
42
  }
36
43
  export declare function createClient<GenQueries>(args: TinaClientArgs<GenQueries>): TinaClient<GenQueries>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tinacms",
3
- "version": "0.0.0-d7c745e-20250102002342",
3
+ "version": "0.0.0-d9672bc-20250218033222",
4
4
  "main": "dist/index.js",
5
5
  "module": "./dist/index.mjs",
6
6
  "exports": {
@@ -92,6 +92,7 @@
92
92
  "@udecode/plate-resizable": "36.0.0",
93
93
  "@udecode/plate-slash-command": "^36.0.0",
94
94
  "@udecode/plate-table": "36.5.8",
95
+ "async-lock": "^1.4.1",
95
96
  "class-variance-authority": "^0.7.0",
96
97
  "clsx": "^2.1.1",
97
98
  "cmdk": "^1.0.4",
@@ -128,9 +129,9 @@
128
129
  "webfontloader": "1.6.28",
129
130
  "yup": "^1.4.0",
130
131
  "zod": "^3.23.8",
131
- "@tinacms/mdx": "0.0.0-d7c745e-20250102002342",
132
- "@tinacms/schema-tools": "1.6.9",
133
- "@tinacms/search": "0.0.0-d7c745e-20250102002342"
132
+ "@tinacms/mdx": "0.0.0-d9672bc-20250218033222",
133
+ "@tinacms/schema-tools": "0.0.0-d9672bc-20250218033222",
134
+ "@tinacms/search": "0.0.0-d9672bc-20250218033222"
134
135
  },
135
136
  "devDependencies": {
136
137
  "@graphql-tools/utils": "^10.5.6",