tinacms 0.0.0-a1ff961-20250623024558 → 0.0.0-a23fec8-20251217045135

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.
Files changed (87) hide show
  1. package/dist/admin/api.d.ts +4 -1
  2. package/dist/auth/AuthModal.d.ts +1 -4
  3. package/dist/auth/TinaCloudProvider.d.ts +0 -1
  4. package/dist/cache/node-cache.d.ts +6 -2
  5. package/dist/client.js +240 -181
  6. package/dist/index.js +120164 -118241
  7. package/dist/internalClient/index.d.ts +55 -2
  8. package/dist/react.js +209 -210
  9. package/dist/rich-text/index.d.ts +6 -0
  10. package/dist/rich-text/index.js +234 -230
  11. package/dist/rich-text/prism.js +16 -18
  12. package/dist/rich-text/static.d.ts +154 -0
  13. package/dist/rich-text/{index.mjs → static.js} +90 -96
  14. package/dist/tina-cms.d.ts +1 -1
  15. package/dist/toolkit/components/ProgressBar.d.ts +11 -0
  16. package/dist/toolkit/components/media/media-item.d.ts +10 -0
  17. package/dist/toolkit/components/ui/button.d.ts +11 -0
  18. package/dist/toolkit/components/ui/calendar.d.ts +8 -0
  19. package/dist/toolkit/components/ui/date-time-picker.d.ts +111 -0
  20. package/dist/toolkit/components/ui/input.d.ts +3 -0
  21. package/dist/toolkit/components/ui/popover.d.ts +7 -0
  22. package/dist/toolkit/components/ui/select.d.ts +13 -0
  23. package/dist/toolkit/fields/components/color-picker/block-widget.d.ts +3 -0
  24. package/dist/toolkit/fields/components/color-picker/color-input.d.ts +35 -0
  25. package/dist/toolkit/fields/components/color-picker/color-picker.d.ts +6 -2
  26. package/dist/toolkit/fields/components/color-picker/color-utils.d.ts +37 -0
  27. package/dist/toolkit/fields/components/color-picker/sketch-widget.d.ts +3 -0
  28. package/dist/toolkit/fields/components/select.d.ts +1 -1
  29. package/dist/toolkit/fields/plugins/button-toggle-field-plugin.d.ts +2 -2
  30. package/dist/toolkit/fields/plugins/checkbox-group-field-plugin.d.ts +2 -2
  31. package/dist/toolkit/fields/plugins/color-field-plugin.d.ts +1 -0
  32. package/dist/toolkit/fields/plugins/date-field-plugin.d.ts +0 -2
  33. package/dist/toolkit/fields/plugins/dnd-kit-wrapper.d.ts +49 -0
  34. package/dist/toolkit/fields/plugins/group-list-field-plugin.d.ts +3 -1
  35. package/dist/toolkit/fields/plugins/list-field-plugin.d.ts +3 -0
  36. package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/components/editor.d.ts +2 -2
  37. package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/components/plate-ui/blockquote-element.d.ts +1 -1
  38. package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/components/plate-ui/button.d.ts +2 -2
  39. package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/components/plate-ui/code-block/code-block-element.d.ts +1 -1
  40. package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/components/plate-ui/code-line-element.d.ts +1 -1
  41. package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/components/plate-ui/command.d.ts +7 -7
  42. package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/components/plate-ui/list-element.d.ts +2 -2
  43. package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/components/plate-ui/paragraph-element.d.ts +1 -1
  44. package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/components/plate-ui/slash-input-element.d.ts +1 -1
  45. package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/components/plate-ui/table/table-cell-element.d.ts +2 -2
  46. package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/components/plate-ui/table/table-element.d.ts +1 -1
  47. package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/components/plate-ui/table/table-row-element.d.ts +1 -1
  48. package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/components/plate-ui/use-floating-toolbar-hook.d.ts +1 -1
  49. package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/plugins/ui/components.d.ts +20 -19
  50. package/dist/toolkit/fields/plugins/radio-group-field-plugin.d.ts +2 -2
  51. package/dist/toolkit/fields/plugins/select-field-plugin.d.ts +2 -2
  52. package/dist/toolkit/fields/plugins/toggle-field-plugin.d.ts +2 -2
  53. package/dist/toolkit/form-builder/create-branch-modal.d.ts +13 -0
  54. package/dist/toolkit/form-builder/editorial-workflow-constants.d.ts +17 -0
  55. package/dist/toolkit/form-builder/form-builder.d.ts +0 -11
  56. package/dist/toolkit/form-builder/index.d.ts +1 -0
  57. package/dist/toolkit/icons/TinaExtended.d.ts +4 -0
  58. package/dist/toolkit/icons/index.d.ts +1 -0
  59. package/dist/toolkit/index.d.ts +1 -1
  60. package/dist/toolkit/plugin-branch-switcher/branch-button.d.ts +3 -1
  61. package/dist/toolkit/react-modals/modal/modal-actions.d.ts +2 -1
  62. package/dist/toolkit/react-modals/modal/modal-header.d.ts +1 -1
  63. package/dist/toolkit/react-sidebar/components/NavMenuTrigger.d.ts +11 -0
  64. package/dist/toolkit/react-sidebar/components/VersionInfo.d.ts +2 -0
  65. package/dist/toolkit/react-sidebar/components/badge.d.ts +6 -0
  66. package/dist/toolkit/react-sidebar/components/callout.d.ts +5 -0
  67. package/dist/toolkit/react-sidebar/components/local-warning.d.ts +3 -1
  68. package/dist/toolkit/react-sidebar/components/nav-components.d.ts +11 -0
  69. package/dist/toolkit/react-sidebar/components/nav-context.d.ts +15 -0
  70. package/dist/toolkit/react-sidebar/components/nav.d.ts +3 -2
  71. package/dist/toolkit/react-sidebar/components/sidebar-body.d.ts +26 -1
  72. package/dist/toolkit/react-sidebar/index.d.ts +3 -0
  73. package/dist/toolkit/styles/button.d.ts +1 -1
  74. package/dist/toolkit/styles/dropdown-button.d.ts +75 -0
  75. package/dist/toolkit/styles/index.d.ts +1 -0
  76. package/dist/unifiedClient/index.d.ts +1 -1
  77. package/dist/utils/index.d.ts +1 -0
  78. package/package.json +34 -65
  79. package/dist/admin/pages/IndexingPage.d.ts +0 -2
  80. package/dist/client.mjs +0 -132
  81. package/dist/index.mjs +0 -121720
  82. package/dist/node-cache-5e8db9f0.mjs +0 -63
  83. package/dist/react.mjs +0 -252
  84. package/dist/rich-text/prism.mjs +0 -16
  85. package/dist/toolkit/react-datetime/DateTime.d.ts +0 -135
  86. package/dist/toolkit/react-sidebar/components/alert.d.ts +0 -5
  87. /package/dist/admin/components/{Sidebar.d.ts → AdminNav.d.ts} +0 -0
@@ -2,7 +2,7 @@ import { BranchData, EventBus } from '@tinacms/toolkit';
2
2
  import { DocumentNode, GraphQLSchema } from 'graphql';
3
3
  import { TokenObject } from '../auth/authenticate';
4
4
  import { AuthProvider, Schema, TinaSchema } from '@tinacms/schema-tools';
5
- import { SearchClient } from '@tinacms/search/dist/index-client';
5
+ import { SearchClient } from '@tinacms/search/index-client';
6
6
  import gql from 'graphql-tag';
7
7
  import { TinaCloudProject } from './types';
8
8
  export * from './authProvider';
@@ -141,6 +141,26 @@ export declare class Client {
141
141
  }[]>;
142
142
  usingProtectedBranch(): boolean;
143
143
  createBranch({ baseBranch, branchName }: BranchData): Promise<string>;
144
+ getLatestVersion(): Promise<LatestVersionResponse>;
145
+ /**
146
+ * Initiate and poll for the results of an editorial workflow operation
147
+ *
148
+ * @param options Editorial workflow options
149
+ * @returns Object with branch and PR info when complete
150
+ */
151
+ executeEditorialWorkflow(options: {
152
+ branchName: string;
153
+ baseBranch: string;
154
+ prTitle?: string;
155
+ graphQLContentOp?: {
156
+ query: string;
157
+ variables: Record<string, unknown>;
158
+ };
159
+ onStatusUpdate?: (status: {
160
+ status: string;
161
+ message?: string;
162
+ }) => void;
163
+ }): Promise<any>;
144
164
  }
145
165
  export declare const DEFAULT_LOCAL_TINA_GQL_SERVER_URL = "http://localhost:4001/graphql";
146
166
  export declare class LocalClient extends Client {
@@ -153,17 +173,30 @@ export declare class LocalClient extends Client {
153
173
  export declare class TinaCMSSearchClient implements SearchClient {
154
174
  private client;
155
175
  private tinaSearchConfig?;
176
+ private fuzzyEnabled;
177
+ private defaultFuzzyOptions?;
156
178
  constructor(client: Client, tinaSearchConfig?: {
157
179
  stopwordLanguages?: string[];
180
+ fuzzyEnabled?: boolean;
181
+ fuzzyOptions?: {
182
+ maxDistance?: number;
183
+ minSimilarity?: number;
184
+ maxResults?: number;
185
+ useTranspositions?: boolean;
186
+ caseSensitive?: boolean;
187
+ };
158
188
  });
159
189
  query(query: string, options?: {
160
190
  limit?: number;
161
191
  cursor?: string;
192
+ fuzzy?: boolean;
193
+ fuzzyOptions?: any;
162
194
  }): Promise<{
163
195
  results: any[];
164
196
  nextCursor: string | null;
165
197
  total: number;
166
198
  prevCursor: string | null;
199
+ fuzzyMatches?: Record<string, any[]>;
167
200
  }>;
168
201
  del(ids: string[]): Promise<any>;
169
202
  put(docs: any[]): Promise<any>;
@@ -171,17 +204,37 @@ export declare class TinaCMSSearchClient implements SearchClient {
171
204
  }
172
205
  export declare class LocalSearchClient implements SearchClient {
173
206
  private client;
174
- constructor(client: Client);
207
+ private tinaSearchConfig?;
208
+ private fuzzyEnabled;
209
+ private defaultFuzzyOptions?;
210
+ constructor(client: Client, tinaSearchConfig?: {
211
+ fuzzyEnabled?: boolean;
212
+ fuzzyOptions?: {
213
+ maxDistance?: number;
214
+ minSimilarity?: number;
215
+ maxResults?: number;
216
+ useTranspositions?: boolean;
217
+ caseSensitive?: boolean;
218
+ };
219
+ });
175
220
  query(query: string, options?: {
176
221
  limit?: number;
177
222
  cursor?: string;
223
+ fuzzy?: boolean;
224
+ fuzzyOptions?: any;
178
225
  }): Promise<{
179
226
  results: any[];
180
227
  nextCursor: string | null;
181
228
  total: number;
182
229
  prevCursor: string | null;
230
+ fuzzyMatches?: Record<string, any[]>;
183
231
  }>;
184
232
  del(ids: string[]): Promise<any>;
185
233
  put(docs: any[]): Promise<any>;
186
234
  supportsClientSideIndexing(): boolean;
187
235
  }
236
+ export type PackageVersionInfo = {
237
+ version: string;
238
+ publishedAt: string;
239
+ };
240
+ export type LatestVersionResponse = Record<string, PackageVersionInfo>;
package/dist/react.js CHANGED
@@ -1,71 +1,70 @@
1
- (function(global, factory) {
2
- typeof exports === "object" && typeof module !== "undefined" ? factory(exports, require("react")) : typeof define === "function" && define.amd ? define(["exports", "react"], factory) : (global = typeof globalThis !== "undefined" ? globalThis : global || self, factory(global.tinacms = {}, global.NOOP));
3
- })(this, function(exports2, React) {
4
- "use strict";
5
- function useTina(props) {
6
- const stringifiedQuery = JSON.stringify({
7
- query: props.query,
8
- variables: props.variables
9
- });
10
- const id = React.useMemo(
11
- () => hashFromQuery(stringifiedQuery),
12
- [stringifiedQuery]
13
- );
14
- const processedData = React.useMemo(() => {
1
+ import React from "react";
2
+ function useTina(props) {
3
+ const stringifiedQuery = JSON.stringify({
4
+ query: props.query,
5
+ variables: props.variables
6
+ });
7
+ const id = React.useMemo(
8
+ () => hashFromQuery(stringifiedQuery),
9
+ [stringifiedQuery]
10
+ );
11
+ const processedData = React.useMemo(() => {
12
+ if (props.data) {
15
13
  const dataCopy = JSON.parse(JSON.stringify(props.data));
16
14
  return addMetadata(id, dataCopy, []);
17
- }, [props.data, id]);
18
- const [data, setData] = React.useState(processedData);
19
- const [isClient, setIsClient] = React.useState(false);
20
- const [quickEditEnabled, setQuickEditEnabled] = React.useState(false);
21
- const [isInTinaIframe, setIsInTinaIframe] = React.useState(false);
22
- React.useEffect(() => {
23
- setIsClient(true);
24
- setData(processedData);
25
- parent.postMessage({
26
- type: "url-changed"
27
- });
28
- }, [id, processedData]);
29
- React.useEffect(() => {
30
- if (quickEditEnabled) {
31
- let mouseDownHandler = function(e) {
32
- const attributeNames = e.target.getAttributeNames();
33
- const tinaAttribute = attributeNames.find(
34
- (name) => name.startsWith("data-tina-field")
15
+ }
16
+ }, [props.data, id]);
17
+ const [data, setData] = React.useState(processedData);
18
+ const [isClient, setIsClient] = React.useState(false);
19
+ const [quickEditEnabled, setQuickEditEnabled] = React.useState(false);
20
+ const [isInTinaIframe, setIsInTinaIframe] = React.useState(false);
21
+ React.useEffect(() => {
22
+ setIsClient(true);
23
+ setData(processedData);
24
+ parent.postMessage({
25
+ type: "url-changed"
26
+ });
27
+ }, [id, processedData]);
28
+ React.useEffect(() => {
29
+ if (quickEditEnabled) {
30
+ let mouseDownHandler = function(e) {
31
+ const attributeNames = e.target.getAttributeNames();
32
+ const tinaAttribute = attributeNames.find(
33
+ (name) => name.startsWith("data-tina-field")
34
+ );
35
+ let fieldName;
36
+ if (tinaAttribute) {
37
+ e.preventDefault();
38
+ e.stopPropagation();
39
+ fieldName = e.target.getAttribute(tinaAttribute);
40
+ } else {
41
+ const ancestor = e.target.closest(
42
+ "[data-tina-field], [data-tina-field-overlay]"
35
43
  );
36
- let fieldName;
37
- if (tinaAttribute) {
38
- e.preventDefault();
39
- e.stopPropagation();
40
- fieldName = e.target.getAttribute(tinaAttribute);
41
- } else {
42
- const ancestor = e.target.closest(
43
- "[data-tina-field], [data-tina-field-overlay]"
44
+ if (ancestor) {
45
+ const attributeNames2 = ancestor.getAttributeNames();
46
+ const tinaAttribute2 = attributeNames2.find(
47
+ (name) => name.startsWith("data-tina-field")
44
48
  );
45
- if (ancestor) {
46
- const attributeNames2 = ancestor.getAttributeNames();
47
- const tinaAttribute2 = attributeNames2.find(
48
- (name) => name.startsWith("data-tina-field")
49
- );
50
- if (tinaAttribute2) {
51
- e.preventDefault();
52
- e.stopPropagation();
53
- fieldName = ancestor.getAttribute(tinaAttribute2);
54
- }
49
+ if (tinaAttribute2) {
50
+ e.preventDefault();
51
+ e.stopPropagation();
52
+ fieldName = ancestor.getAttribute(tinaAttribute2);
55
53
  }
56
54
  }
57
- if (fieldName) {
58
- if (isInTinaIframe) {
59
- parent.postMessage(
60
- { type: "field:selected", fieldName },
61
- window.location.origin
62
- );
63
- }
55
+ }
56
+ if (fieldName) {
57
+ if (isInTinaIframe) {
58
+ parent.postMessage(
59
+ { type: "field:selected", fieldName },
60
+ window.location.origin
61
+ );
64
62
  }
65
- };
66
- const style = document.createElement("style");
67
- style.type = "text/css";
68
- style.textContent = `
63
+ }
64
+ };
65
+ const style = document.createElement("style");
66
+ style.type = "text/css";
67
+ style.textContent = `
69
68
  [data-tina-field] {
70
69
  outline: 2px dashed rgba(34,150,254,0.5);
71
70
  transition: box-shadow ease-out 150ms;
@@ -96,160 +95,160 @@
96
95
  opacity: 1;
97
96
  }
98
97
  `;
99
- document.head.appendChild(style);
100
- document.body.classList.add("__tina-quick-editing-enabled");
101
- document.addEventListener("click", mouseDownHandler, true);
102
- return () => {
103
- document.removeEventListener("click", mouseDownHandler, true);
104
- document.body.classList.remove("__tina-quick-editing-enabled");
105
- style.remove();
106
- };
107
- }
108
- }, [quickEditEnabled, isInTinaIframe]);
109
- React.useEffect(() => {
110
- if (props == null ? void 0 : props.experimental___selectFormByFormId) {
111
- parent.postMessage({
112
- type: "user-select-form",
113
- formId: props.experimental___selectFormByFormId()
114
- });
115
- }
116
- }, [id]);
117
- React.useEffect(() => {
118
- const { experimental___selectFormByFormId, ...rest } = props;
119
- parent.postMessage({ type: "open", ...rest, id }, window.location.origin);
120
- const handleMessage = (event) => {
121
- if (event.data.type === "quickEditEnabled") {
122
- setQuickEditEnabled(event.data.value);
123
- }
124
- if (event.data.id === id && event.data.type === "updateData") {
125
- const rawData = event.data.data;
126
- const newlyProcessedData = addMetadata(
127
- id,
128
- JSON.parse(JSON.stringify(rawData)),
129
- []
130
- );
131
- setData(newlyProcessedData);
132
- setIsInTinaIframe(true);
133
- const anyTinaField = document.querySelector("[data-tina-field]");
134
- if (anyTinaField) {
135
- parent.postMessage(
136
- { type: "quick-edit", value: true },
137
- window.location.origin
138
- );
139
- } else {
140
- parent.postMessage(
141
- { type: "quick-edit", value: false },
142
- window.location.origin
143
- );
144
- }
145
- }
146
- };
147
- window.addEventListener("message", handleMessage);
98
+ document.head.appendChild(style);
99
+ document.body.classList.add("__tina-quick-editing-enabled");
100
+ document.addEventListener("click", mouseDownHandler, true);
148
101
  return () => {
149
- window.removeEventListener("message", handleMessage);
150
- parent.postMessage({ type: "close", id }, window.location.origin);
102
+ document.removeEventListener("click", mouseDownHandler, true);
103
+ document.body.classList.remove("__tina-quick-editing-enabled");
104
+ style.remove();
151
105
  };
152
- }, [id, setQuickEditEnabled]);
153
- return { data, isClient };
154
- }
155
- function useEditState() {
156
- const [edit, setEdit] = React.useState(false);
157
- React.useEffect(() => {
158
- if (typeof window !== "undefined") {
159
- parent.postMessage({ type: "isEditMode" }, window.location.origin);
160
- window.addEventListener("message", (event) => {
161
- var _a;
162
- if (((_a = event.data) == null ? void 0 : _a.type) === "tina:editMode") {
163
- setEdit(true);
164
- }
165
- });
166
- }
167
- }, []);
168
- return { edit };
169
- }
170
- const tinaField = (object, property, index) => {
171
- const contentSource = object == null ? void 0 : object._content_source;
172
- if (!contentSource) {
173
- return "";
174
- }
175
- const { queryId, path } = contentSource;
176
- if (!property) {
177
- return `${queryId}---${path.join(".")}`;
178
- }
179
- const fullPath = typeof index === "number" ? [...path, property, index] : [...path, property];
180
- return `${queryId}---${fullPath.join(".")}`;
181
- };
182
- const addMetadata = (id, obj, path = []) => {
183
- if (obj === null) {
184
- return obj;
185
- }
186
- if (isScalarOrUndefined(obj)) {
187
- return obj;
188
106
  }
189
- if (obj instanceof String) {
190
- return obj.valueOf();
191
- }
192
- if (Array.isArray(obj)) {
193
- return obj.map(
194
- (item, index) => addMetadata(id, item, [...path, index])
195
- );
107
+ }, [quickEditEnabled, isInTinaIframe]);
108
+ React.useEffect(() => {
109
+ if (props == null ? void 0 : props.experimental___selectFormByFormId) {
110
+ parent.postMessage({
111
+ type: "user-select-form",
112
+ formId: props.experimental___selectFormByFormId()
113
+ });
196
114
  }
197
- const transformedObj = {};
198
- for (const [key, value] of Object.entries(obj)) {
199
- const currentPath = [...path, key];
200
- if ([
201
- "__typename",
202
- "_sys",
203
- "_internalSys",
204
- "_values",
205
- "_internalValues",
206
- "_content_source",
207
- "_tina_metadata"
208
- ].includes(key)) {
209
- transformedObj[key] = value;
210
- } else {
211
- transformedObj[key] = addMetadata(id, value, currentPath);
115
+ }, [id]);
116
+ React.useEffect(() => {
117
+ const { experimental___selectFormByFormId, ...rest } = props;
118
+ parent.postMessage({ type: "open", ...rest, id }, window.location.origin);
119
+ const handleMessage = (event) => {
120
+ if (event.data.type === "quickEditEnabled") {
121
+ setQuickEditEnabled(event.data.value);
212
122
  }
123
+ if (event.data.id === id && event.data.type === "updateData") {
124
+ const rawData = event.data.data;
125
+ const newlyProcessedData = addMetadata(
126
+ id,
127
+ JSON.parse(JSON.stringify(rawData)),
128
+ []
129
+ );
130
+ setData(newlyProcessedData);
131
+ setIsInTinaIframe(true);
132
+ const anyTinaField = document.querySelector("[data-tina-field]");
133
+ if (anyTinaField) {
134
+ parent.postMessage(
135
+ { type: "quick-edit", value: true },
136
+ window.location.origin
137
+ );
138
+ } else {
139
+ parent.postMessage(
140
+ { type: "quick-edit", value: false },
141
+ window.location.origin
142
+ );
143
+ }
144
+ }
145
+ };
146
+ window.addEventListener("message", handleMessage);
147
+ return () => {
148
+ window.removeEventListener("message", handleMessage);
149
+ parent.postMessage({ type: "close", id }, window.location.origin);
150
+ };
151
+ }, [id, setQuickEditEnabled]);
152
+ return { data, isClient };
153
+ }
154
+ function useEditState() {
155
+ const [edit, setEdit] = React.useState(false);
156
+ React.useEffect(() => {
157
+ if (typeof window !== "undefined") {
158
+ parent.postMessage({ type: "isEditMode" }, window.location.origin);
159
+ window.addEventListener("message", (event) => {
160
+ var _a;
161
+ if (((_a = event.data) == null ? void 0 : _a.type) === "tina:editMode") {
162
+ setEdit(true);
163
+ }
164
+ });
213
165
  }
214
- if (transformedObj && typeof transformedObj === "object" && "type" in transformedObj && transformedObj.type === "root") {
215
- return transformedObj;
216
- }
217
- return { ...transformedObj, _content_source: { queryId: id, path } };
218
- };
219
- function isScalarOrUndefined(value) {
220
- const type = typeof value;
221
- if (type === "string")
222
- return true;
223
- if (type === "number")
224
- return true;
225
- if (type === "boolean")
226
- return true;
227
- if (type === "undefined")
228
- return true;
229
- if (value == null)
230
- return true;
231
- if (value instanceof String)
232
- return true;
233
- if (value instanceof Number)
234
- return true;
235
- if (value instanceof Boolean)
236
- return true;
237
- return false;
166
+ }, []);
167
+ return { edit };
168
+ }
169
+ const tinaField = (object, property, index) => {
170
+ const contentSource = object == null ? void 0 : object._content_source;
171
+ if (!contentSource) {
172
+ return "";
173
+ }
174
+ const { queryId, path } = contentSource;
175
+ if (!property) {
176
+ return `${queryId}---${path.join(".")}`;
177
+ }
178
+ const fullPath = typeof index === "number" ? [...path, property, index] : [...path, property];
179
+ return `${queryId}---${fullPath.join(".")}`;
180
+ };
181
+ const addMetadata = (id, obj, path = []) => {
182
+ if (obj === null) {
183
+ return obj;
184
+ }
185
+ if (isScalarOrUndefined(obj)) {
186
+ return obj;
238
187
  }
239
- const hashFromQuery = (input) => {
240
- let hash = 0;
241
- for (let i = 0; i < input.length; i++) {
242
- const char = input.charCodeAt(i);
243
- hash = (hash << 5) - hash + char & 4294967295;
188
+ if (obj instanceof String) {
189
+ return obj.valueOf();
190
+ }
191
+ if (Array.isArray(obj)) {
192
+ return obj.map(
193
+ (item, index) => addMetadata(id, item, [...path, index])
194
+ );
195
+ }
196
+ const transformedObj = {};
197
+ for (const [key, value] of Object.entries(obj)) {
198
+ const currentPath = [...path, key];
199
+ if ([
200
+ "__typename",
201
+ "_sys",
202
+ "_internalSys",
203
+ "_values",
204
+ "_internalValues",
205
+ "_content_source",
206
+ "_tina_metadata"
207
+ ].includes(key)) {
208
+ transformedObj[key] = value;
209
+ } else {
210
+ transformedObj[key] = addMetadata(id, value, currentPath);
244
211
  }
245
- const nonNegativeHash = Math.abs(hash);
246
- const alphanumericHash = nonNegativeHash.toString(36);
247
- return alphanumericHash;
248
- };
249
- exports2.addMetadata = addMetadata;
250
- exports2.hashFromQuery = hashFromQuery;
251
- exports2.tinaField = tinaField;
252
- exports2.useEditState = useEditState;
253
- exports2.useTina = useTina;
254
- Object.defineProperty(exports2, Symbol.toStringTag, { value: "Module" });
255
- });
212
+ }
213
+ if (transformedObj && typeof transformedObj === "object" && "type" in transformedObj && transformedObj.type === "root") {
214
+ return transformedObj;
215
+ }
216
+ return { ...transformedObj, _content_source: { queryId: id, path } };
217
+ };
218
+ function isScalarOrUndefined(value) {
219
+ const type = typeof value;
220
+ if (type === "string")
221
+ return true;
222
+ if (type === "number")
223
+ return true;
224
+ if (type === "boolean")
225
+ return true;
226
+ if (type === "undefined")
227
+ return true;
228
+ if (value == null)
229
+ return true;
230
+ if (value instanceof String)
231
+ return true;
232
+ if (value instanceof Number)
233
+ return true;
234
+ if (value instanceof Boolean)
235
+ return true;
236
+ return false;
237
+ }
238
+ const hashFromQuery = (input) => {
239
+ let hash = 0;
240
+ for (let i = 0; i < input.length; i++) {
241
+ const char = input.charCodeAt(i);
242
+ hash = (hash << 5) - hash + char & 4294967295;
243
+ }
244
+ const nonNegativeHash = Math.abs(hash);
245
+ const alphanumericHash = nonNegativeHash.toString(36);
246
+ return alphanumericHash;
247
+ };
248
+ export {
249
+ addMetadata,
250
+ hashFromQuery,
251
+ tinaField,
252
+ useEditState,
253
+ useTina
254
+ };
@@ -58,9 +58,15 @@ type BaseComponents = {
58
58
  lic?: {
59
59
  children: JSX.Element;
60
60
  };
61
+ /**
62
+ * @deprecated Use `blockquote` instead. This was incorrectly named and will be removed in a future version.
63
+ */
61
64
  block_quote?: {
62
65
  children: JSX.Element;
63
66
  };
67
+ blockquote?: {
68
+ children: JSX.Element;
69
+ };
64
70
  code_block?: {
65
71
  lang?: string;
66
72
  value: string;