tinacms 0.0.0-bef6c5d-20250131012808 → 0.0.0-c0f1b7d-20250702023438
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/README.md +1 -1
- package/dist/admin/api.d.ts +1 -0
- package/dist/admin/components/GetCollection.d.ts +2 -2
- package/dist/admin/components/Page.d.ts +3 -9
- package/dist/admin/components/Sidebar.d.ts +0 -3
- package/dist/admin/components/ui/tooltip.d.ts +7 -0
- package/dist/admin/pages/CollectionCreatePage.d.ts +1 -1
- package/dist/admin/pages/CollectionListPage.d.ts +2 -2
- package/dist/admin/pages/DashboardPage.d.ts +0 -3
- package/dist/admin/pages/ScreenPage.d.ts +0 -3
- package/dist/auth/TinaCloudProvider.d.ts +1 -1
- package/dist/client.js +10 -1
- package/dist/client.mjs +10 -1
- package/dist/hooks/create-page-plugin.d.ts +1 -1
- package/dist/index.js +10228 -8183
- package/dist/index.mjs +10350 -8306
- package/dist/internalClient/index.d.ts +9 -3
- package/dist/react.d.ts +14 -6
- package/dist/react.js +71 -53
- package/dist/react.mjs +71 -53
- package/dist/rich-text/prism.js +1 -1
- package/dist/rich-text/prism.mjs +1 -1
- package/dist/rich-text/static.d.ts +148 -0
- package/dist/rich-text/static.js +239 -0
- package/dist/rich-text/static.mjs +236 -0
- package/dist/toolkit/components/media/media-item.d.ts +1 -1
- package/dist/toolkit/components/media/media-manager.d.ts +1 -1
- package/dist/toolkit/components/ui/breadcrumb.d.ts +11 -0
- package/dist/toolkit/components/ui/dropdown-menu.d.ts +25 -0
- package/dist/toolkit/fields/components/password-field.d.ts +1 -1
- package/dist/toolkit/fields/components/reference/components/button.d.ts +1 -1
- package/dist/toolkit/fields/components/reference/components/popover.d.ts +1 -1
- package/dist/toolkit/fields/components/reference/model/reference-link-props.d.ts +2 -0
- package/dist/toolkit/fields/components/reference/reference-select.d.ts +2 -2
- package/dist/toolkit/fields/components/select.d.ts +2 -2
- package/dist/toolkit/fields/components/text-field.d.ts +1 -1
- package/dist/toolkit/fields/plugins/group-field-plugin.d.ts +1 -1
- package/dist/toolkit/fields/plugins/list-field-meta.d.ts +1 -1
- package/dist/toolkit/fields/plugins/mdx-field-plugin/index.d.ts +2 -2
- package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/components/plate-ui/indent-list-toolbar-button.d.ts +17 -5
- package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/components/plate-ui/mark-toolbar-button.d.ts +4 -18
- package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/plugins/ui/components.d.ts +6 -11
- package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/toolbar/toolbar-overrides.d.ts +1 -1
- package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/transforms/is-url.d.ts +1 -2
- package/dist/toolkit/form-builder/fields-builder.d.ts +1 -1
- package/dist/toolkit/form-builder/form-builder.d.ts +15 -5
- package/dist/toolkit/forms/field.d.ts +3 -0
- package/dist/toolkit/forms/form.d.ts +22 -3
- package/dist/toolkit/git-client/git-client.d.ts +25 -2
- package/dist/toolkit/git-client/git-file.d.ts +18 -0
- package/dist/toolkit/git-client/git-media-store.d.ts +13 -0
- package/dist/toolkit/git-client/use-git-file.d.ts +4 -0
- package/dist/toolkit/icons/Tina.d.ts +0 -5
- package/dist/toolkit/index.d.ts +1 -1
- package/dist/toolkit/plugin-branch-switcher/branch-button.d.ts +1 -0
- package/dist/toolkit/plugin-branch-switcher/branch-switcher-legacy.d.ts +1 -1
- package/dist/toolkit/plugin-branch-switcher/branch-switcher.d.ts +1 -1
- package/dist/toolkit/plugin-branch-switcher/index.d.ts +0 -1
- package/dist/toolkit/react-cloud-config/cloud-config-plugin.d.ts +3 -3
- package/dist/toolkit/react-sidebar/components/VersionInfo.d.ts +2 -0
- package/dist/toolkit/react-sidebar/components/alert.d.ts +5 -0
- package/dist/toolkit/react-sidebar/components/form-list.d.ts +1 -1
- package/dist/toolkit/react-sidebar/components/nav.d.ts +5 -3
- package/dist/toolkit/react-sidebar/components/resize-handle.d.ts +0 -5
- package/dist/toolkit/react-sidebar/components/sidebar-body.d.ts +7 -10
- package/dist/toolkit/react-sidebar/components/sidebar-loading-placeholder.d.ts +2 -0
- package/dist/toolkit/react-sidebar/components/sidebar-no-forms-placeholder.d.ts +2 -0
- package/dist/toolkit/react-sidebar/components/sidebar.d.ts +0 -7
- package/dist/toolkit/react-sidebar/components/sync-status.d.ts +5 -8
- package/dist/toolkit/react-sidebar/index.d.ts +1 -1
- package/dist/toolkit/react-sidebar/sidebar.d.ts +2 -2
- package/dist/toolkit/styles/button.d.ts +2 -2
- package/dist/toolkit/tina-cms.d.ts +3 -3
- package/dist/toolkit/tina-state.d.ts +15 -0
- package/dist/unifiedClient/index.d.ts +1 -1
- package/dist/utils/cn.d.ts +2 -0
- package/package.json +42 -35
- package/dist/toolkit/plugin-branch-switcher/branch-banner.d.ts +0 -2
- package/dist/toolkit/react-sidebar/components/no-forms-placeholder.d.ts +0 -8
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { TokenObject } from '../auth/authenticate';
|
|
2
1
|
import { BranchData, EventBus } from '@tinacms/toolkit';
|
|
3
2
|
import { DocumentNode, GraphQLSchema } from 'graphql';
|
|
3
|
+
import { TokenObject } from '../auth/authenticate';
|
|
4
|
+
import { AuthProvider, Schema, TinaSchema } from '@tinacms/schema-tools';
|
|
5
|
+
import { SearchClient } from '@tinacms/search/dist/index-client';
|
|
4
6
|
import gql from 'graphql-tag';
|
|
5
|
-
import { TinaSchema, Schema, AuthProvider } from '@tinacms/schema-tools';
|
|
6
7
|
import { TinaCloudProject } from './types';
|
|
7
|
-
import { SearchClient } from '@tinacms/search/dist/index-client';
|
|
8
8
|
export * from './authProvider';
|
|
9
9
|
export type OnLoginFunc = (args: {
|
|
10
10
|
token?: TokenObject;
|
|
@@ -141,6 +141,7 @@ export declare class Client {
|
|
|
141
141
|
}[]>;
|
|
142
142
|
usingProtectedBranch(): boolean;
|
|
143
143
|
createBranch({ baseBranch, branchName }: BranchData): Promise<string>;
|
|
144
|
+
getLatestVersion(): Promise<LatestVersionResponse>;
|
|
144
145
|
}
|
|
145
146
|
export declare const DEFAULT_LOCAL_TINA_GQL_SERVER_URL = "http://localhost:4001/graphql";
|
|
146
147
|
export declare class LocalClient extends Client {
|
|
@@ -185,3 +186,8 @@ export declare class LocalSearchClient implements SearchClient {
|
|
|
185
186
|
put(docs: any[]): Promise<any>;
|
|
186
187
|
supportsClientSideIndexing(): boolean;
|
|
187
188
|
}
|
|
189
|
+
export type PackageVersionInfo = {
|
|
190
|
+
version: string;
|
|
191
|
+
publishedAt: string;
|
|
192
|
+
};
|
|
193
|
+
export type LatestVersionResponse = Record<string, PackageVersionInfo>;
|
package/dist/react.d.ts
CHANGED
|
@@ -2,6 +2,7 @@ export declare function useTina<T extends object>(props: {
|
|
|
2
2
|
query: string;
|
|
3
3
|
variables: object;
|
|
4
4
|
data: T;
|
|
5
|
+
experimental___selectFormByFormId?: () => string | false | undefined;
|
|
5
6
|
}): {
|
|
6
7
|
data: T;
|
|
7
8
|
isClient: boolean;
|
|
@@ -14,16 +15,23 @@ export declare function useEditState(): {
|
|
|
14
15
|
* to signal to Tina which DOM element the field
|
|
15
16
|
* is working with.
|
|
16
17
|
*/
|
|
17
|
-
|
|
18
|
+
/**
|
|
19
|
+
* Generate a field identifier for Tina to associate DOM elements with form fields.
|
|
20
|
+
* Format: "queryId---path.to.field" or "queryId---path.to.array.index"
|
|
21
|
+
*/
|
|
22
|
+
export declare const tinaField: <T extends {
|
|
18
23
|
_content_source?: {
|
|
19
24
|
queryId: string;
|
|
20
25
|
path: (number | string)[];
|
|
21
26
|
};
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
+
} | Record<string, unknown> | null | undefined>(object: T, property?: keyof Omit<NonNullable<T>, "__typename" | "_sys">, index?: number) => string;
|
|
28
|
+
/**
|
|
29
|
+
* FIX: This function is updated to be more robust. It explicitly checks for
|
|
30
|
+
* `null` and `String` objects to prevent them from being processed as
|
|
31
|
+
* iterable objects, which is the root cause of the "Objects are not valid
|
|
32
|
+
* as a React child" error.
|
|
33
|
+
*/
|
|
34
|
+
export declare const addMetadata: <T extends object>(id: string, obj: T, path?: (string | number)[]) => T;
|
|
27
35
|
/**
|
|
28
36
|
* This is a pretty rudimentary approach to hashing the query and variables to
|
|
29
37
|
* ensure we treat multiple queries on the page uniquely. It's possible
|
package/dist/react.js
CHANGED
|
@@ -11,14 +11,21 @@
|
|
|
11
11
|
() => hashFromQuery(stringifiedQuery),
|
|
12
12
|
[stringifiedQuery]
|
|
13
13
|
);
|
|
14
|
-
const
|
|
14
|
+
const processedData = React.useMemo(() => {
|
|
15
|
+
const dataCopy = JSON.parse(JSON.stringify(props.data));
|
|
16
|
+
return addMetadata(id, dataCopy, []);
|
|
17
|
+
}, [props.data, id]);
|
|
18
|
+
const [data, setData] = React.useState(processedData);
|
|
15
19
|
const [isClient, setIsClient] = React.useState(false);
|
|
16
20
|
const [quickEditEnabled, setQuickEditEnabled] = React.useState(false);
|
|
17
21
|
const [isInTinaIframe, setIsInTinaIframe] = React.useState(false);
|
|
18
22
|
React.useEffect(() => {
|
|
19
23
|
setIsClient(true);
|
|
20
|
-
setData(
|
|
21
|
-
|
|
24
|
+
setData(processedData);
|
|
25
|
+
parent.postMessage({
|
|
26
|
+
type: "url-changed"
|
|
27
|
+
});
|
|
28
|
+
}, [id, processedData]);
|
|
22
29
|
React.useEffect(() => {
|
|
23
30
|
if (quickEditEnabled) {
|
|
24
31
|
let mouseDownHandler = function(e) {
|
|
@@ -100,13 +107,28 @@
|
|
|
100
107
|
}
|
|
101
108
|
}, [quickEditEnabled, isInTinaIframe]);
|
|
102
109
|
React.useEffect(() => {
|
|
103
|
-
|
|
104
|
-
|
|
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) => {
|
|
105
121
|
if (event.data.type === "quickEditEnabled") {
|
|
106
122
|
setQuickEditEnabled(event.data.value);
|
|
107
123
|
}
|
|
108
124
|
if (event.data.id === id && event.data.type === "updateData") {
|
|
109
|
-
|
|
125
|
+
const rawData = event.data.data;
|
|
126
|
+
const newlyProcessedData = addMetadata(
|
|
127
|
+
id,
|
|
128
|
+
JSON.parse(JSON.stringify(rawData)),
|
|
129
|
+
[]
|
|
130
|
+
);
|
|
131
|
+
setData(newlyProcessedData);
|
|
110
132
|
setIsInTinaIframe(true);
|
|
111
133
|
const anyTinaField = document.querySelector("[data-tina-field]");
|
|
112
134
|
if (anyTinaField) {
|
|
@@ -121,8 +143,10 @@
|
|
|
121
143
|
);
|
|
122
144
|
}
|
|
123
145
|
}
|
|
124
|
-
}
|
|
146
|
+
};
|
|
147
|
+
window.addEventListener("message", handleMessage);
|
|
125
148
|
return () => {
|
|
149
|
+
window.removeEventListener("message", handleMessage);
|
|
126
150
|
parent.postMessage({ type: "close", id }, window.location.origin);
|
|
127
151
|
};
|
|
128
152
|
}, [id, setQuickEditEnabled]);
|
|
@@ -144,59 +168,53 @@
|
|
|
144
168
|
return { edit };
|
|
145
169
|
}
|
|
146
170
|
const tinaField = (object, property, index) => {
|
|
147
|
-
|
|
148
|
-
if (!
|
|
171
|
+
const contentSource = object == null ? void 0 : object._content_source;
|
|
172
|
+
if (!contentSource) {
|
|
149
173
|
return "";
|
|
150
174
|
}
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
(_a = object._content_source) == null ? void 0 : _a.queryId,
|
|
155
|
-
object._content_source.path.join(".")
|
|
156
|
-
].join("---");
|
|
157
|
-
}
|
|
158
|
-
if (typeof index === "number") {
|
|
159
|
-
return [
|
|
160
|
-
(_b = object._content_source) == null ? void 0 : _b.queryId,
|
|
161
|
-
[...object._content_source.path, property, index].join(".")
|
|
162
|
-
].join("---");
|
|
163
|
-
}
|
|
164
|
-
return [
|
|
165
|
-
(_c = object._content_source) == null ? void 0 : _c.queryId,
|
|
166
|
-
[...object._content_source.path, property].join(".")
|
|
167
|
-
].join("---");
|
|
175
|
+
const { queryId, path } = contentSource;
|
|
176
|
+
if (!property) {
|
|
177
|
+
return `${queryId}---${path.join(".")}`;
|
|
168
178
|
}
|
|
169
|
-
|
|
179
|
+
const fullPath = typeof index === "number" ? [...path, property, index] : [...path, property];
|
|
180
|
+
return `${queryId}---${fullPath.join(".")}`;
|
|
170
181
|
};
|
|
171
|
-
const addMetadata = (id,
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
182
|
+
const addMetadata = (id, obj, path = []) => {
|
|
183
|
+
if (obj === null) {
|
|
184
|
+
return obj;
|
|
185
|
+
}
|
|
186
|
+
if (isScalarOrUndefined(obj)) {
|
|
187
|
+
return obj;
|
|
188
|
+
}
|
|
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
|
+
);
|
|
196
|
+
}
|
|
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;
|
|
184
210
|
} else {
|
|
185
|
-
|
|
186
|
-
return;
|
|
187
|
-
}
|
|
188
|
-
const itemObject = value;
|
|
189
|
-
addMetadata(id, itemObject, [...path, key]);
|
|
211
|
+
transformedObj[key] = addMetadata(id, value, currentPath);
|
|
190
212
|
}
|
|
191
|
-
});
|
|
192
|
-
if ((object == null ? void 0 : object.type) === "root") {
|
|
193
|
-
return;
|
|
194
213
|
}
|
|
195
|
-
object.
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
};
|
|
199
|
-
return object;
|
|
214
|
+
if (transformedObj && typeof transformedObj === "object" && "type" in transformedObj && transformedObj.type === "root") {
|
|
215
|
+
return transformedObj;
|
|
216
|
+
}
|
|
217
|
+
return { ...transformedObj, _content_source: { queryId: id, path } };
|
|
200
218
|
};
|
|
201
219
|
function isScalarOrUndefined(value) {
|
|
202
220
|
const type = typeof value;
|
package/dist/react.mjs
CHANGED
|
@@ -8,14 +8,21 @@ function useTina(props) {
|
|
|
8
8
|
() => hashFromQuery(stringifiedQuery),
|
|
9
9
|
[stringifiedQuery]
|
|
10
10
|
);
|
|
11
|
-
const
|
|
11
|
+
const processedData = React.useMemo(() => {
|
|
12
|
+
const dataCopy = JSON.parse(JSON.stringify(props.data));
|
|
13
|
+
return addMetadata(id, dataCopy, []);
|
|
14
|
+
}, [props.data, id]);
|
|
15
|
+
const [data, setData] = React.useState(processedData);
|
|
12
16
|
const [isClient, setIsClient] = React.useState(false);
|
|
13
17
|
const [quickEditEnabled, setQuickEditEnabled] = React.useState(false);
|
|
14
18
|
const [isInTinaIframe, setIsInTinaIframe] = React.useState(false);
|
|
15
19
|
React.useEffect(() => {
|
|
16
20
|
setIsClient(true);
|
|
17
|
-
setData(
|
|
18
|
-
|
|
21
|
+
setData(processedData);
|
|
22
|
+
parent.postMessage({
|
|
23
|
+
type: "url-changed"
|
|
24
|
+
});
|
|
25
|
+
}, [id, processedData]);
|
|
19
26
|
React.useEffect(() => {
|
|
20
27
|
if (quickEditEnabled) {
|
|
21
28
|
let mouseDownHandler = function(e) {
|
|
@@ -97,13 +104,28 @@ function useTina(props) {
|
|
|
97
104
|
}
|
|
98
105
|
}, [quickEditEnabled, isInTinaIframe]);
|
|
99
106
|
React.useEffect(() => {
|
|
100
|
-
|
|
101
|
-
|
|
107
|
+
if (props == null ? void 0 : props.experimental___selectFormByFormId) {
|
|
108
|
+
parent.postMessage({
|
|
109
|
+
type: "user-select-form",
|
|
110
|
+
formId: props.experimental___selectFormByFormId()
|
|
111
|
+
});
|
|
112
|
+
}
|
|
113
|
+
}, [id]);
|
|
114
|
+
React.useEffect(() => {
|
|
115
|
+
const { experimental___selectFormByFormId, ...rest } = props;
|
|
116
|
+
parent.postMessage({ type: "open", ...rest, id }, window.location.origin);
|
|
117
|
+
const handleMessage = (event) => {
|
|
102
118
|
if (event.data.type === "quickEditEnabled") {
|
|
103
119
|
setQuickEditEnabled(event.data.value);
|
|
104
120
|
}
|
|
105
121
|
if (event.data.id === id && event.data.type === "updateData") {
|
|
106
|
-
|
|
122
|
+
const rawData = event.data.data;
|
|
123
|
+
const newlyProcessedData = addMetadata(
|
|
124
|
+
id,
|
|
125
|
+
JSON.parse(JSON.stringify(rawData)),
|
|
126
|
+
[]
|
|
127
|
+
);
|
|
128
|
+
setData(newlyProcessedData);
|
|
107
129
|
setIsInTinaIframe(true);
|
|
108
130
|
const anyTinaField = document.querySelector("[data-tina-field]");
|
|
109
131
|
if (anyTinaField) {
|
|
@@ -118,8 +140,10 @@ function useTina(props) {
|
|
|
118
140
|
);
|
|
119
141
|
}
|
|
120
142
|
}
|
|
121
|
-
}
|
|
143
|
+
};
|
|
144
|
+
window.addEventListener("message", handleMessage);
|
|
122
145
|
return () => {
|
|
146
|
+
window.removeEventListener("message", handleMessage);
|
|
123
147
|
parent.postMessage({ type: "close", id }, window.location.origin);
|
|
124
148
|
};
|
|
125
149
|
}, [id, setQuickEditEnabled]);
|
|
@@ -141,59 +165,53 @@ function useEditState() {
|
|
|
141
165
|
return { edit };
|
|
142
166
|
}
|
|
143
167
|
const tinaField = (object, property, index) => {
|
|
144
|
-
|
|
145
|
-
if (!
|
|
168
|
+
const contentSource = object == null ? void 0 : object._content_source;
|
|
169
|
+
if (!contentSource) {
|
|
146
170
|
return "";
|
|
147
171
|
}
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
(_a = object._content_source) == null ? void 0 : _a.queryId,
|
|
152
|
-
object._content_source.path.join(".")
|
|
153
|
-
].join("---");
|
|
154
|
-
}
|
|
155
|
-
if (typeof index === "number") {
|
|
156
|
-
return [
|
|
157
|
-
(_b = object._content_source) == null ? void 0 : _b.queryId,
|
|
158
|
-
[...object._content_source.path, property, index].join(".")
|
|
159
|
-
].join("---");
|
|
160
|
-
}
|
|
161
|
-
return [
|
|
162
|
-
(_c = object._content_source) == null ? void 0 : _c.queryId,
|
|
163
|
-
[...object._content_source.path, property].join(".")
|
|
164
|
-
].join("---");
|
|
172
|
+
const { queryId, path } = contentSource;
|
|
173
|
+
if (!property) {
|
|
174
|
+
return `${queryId}---${path.join(".")}`;
|
|
165
175
|
}
|
|
166
|
-
|
|
176
|
+
const fullPath = typeof index === "number" ? [...path, property, index] : [...path, property];
|
|
177
|
+
return `${queryId}---${fullPath.join(".")}`;
|
|
167
178
|
};
|
|
168
|
-
const addMetadata = (id,
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
179
|
+
const addMetadata = (id, obj, path = []) => {
|
|
180
|
+
if (obj === null) {
|
|
181
|
+
return obj;
|
|
182
|
+
}
|
|
183
|
+
if (isScalarOrUndefined(obj)) {
|
|
184
|
+
return obj;
|
|
185
|
+
}
|
|
186
|
+
if (obj instanceof String) {
|
|
187
|
+
return obj.valueOf();
|
|
188
|
+
}
|
|
189
|
+
if (Array.isArray(obj)) {
|
|
190
|
+
return obj.map(
|
|
191
|
+
(item, index) => addMetadata(id, item, [...path, index])
|
|
192
|
+
);
|
|
193
|
+
}
|
|
194
|
+
const transformedObj = {};
|
|
195
|
+
for (const [key, value] of Object.entries(obj)) {
|
|
196
|
+
const currentPath = [...path, key];
|
|
197
|
+
if ([
|
|
198
|
+
"__typename",
|
|
199
|
+
"_sys",
|
|
200
|
+
"_internalSys",
|
|
201
|
+
"_values",
|
|
202
|
+
"_internalValues",
|
|
203
|
+
"_content_source",
|
|
204
|
+
"_tina_metadata"
|
|
205
|
+
].includes(key)) {
|
|
206
|
+
transformedObj[key] = value;
|
|
181
207
|
} else {
|
|
182
|
-
|
|
183
|
-
return;
|
|
184
|
-
}
|
|
185
|
-
const itemObject = value;
|
|
186
|
-
addMetadata(id, itemObject, [...path, key]);
|
|
208
|
+
transformedObj[key] = addMetadata(id, value, currentPath);
|
|
187
209
|
}
|
|
188
|
-
});
|
|
189
|
-
if ((object == null ? void 0 : object.type) === "root") {
|
|
190
|
-
return;
|
|
191
210
|
}
|
|
192
|
-
object.
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
};
|
|
196
|
-
return object;
|
|
211
|
+
if (transformedObj && typeof transformedObj === "object" && "type" in transformedObj && transformedObj.type === "root") {
|
|
212
|
+
return transformedObj;
|
|
213
|
+
}
|
|
214
|
+
return { ...transformedObj, _content_source: { queryId: id, path } };
|
|
197
215
|
};
|
|
198
216
|
function isScalarOrUndefined(value) {
|
|
199
217
|
const type = typeof value;
|
package/dist/rich-text/prism.js
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
prismReactRenderer.Highlight,
|
|
8
8
|
{
|
|
9
9
|
theme: prismReactRenderer.themes[props.theme || "github"],
|
|
10
|
-
code: props.value,
|
|
10
|
+
code: props.value || "",
|
|
11
11
|
language: props.lang || ""
|
|
12
12
|
},
|
|
13
13
|
({ className, style, tokens, getLineProps, getTokenProps }) => /* @__PURE__ */ React.createElement("pre", { className, style }, tokens.map((line, i) => /* @__PURE__ */ React.createElement("div", { ...getLineProps({ line, key: i }) }, line.map((token, key) => /* @__PURE__ */ React.createElement("span", { ...getTokenProps({ token, key }) })))))
|
package/dist/rich-text/prism.mjs
CHANGED
|
@@ -5,7 +5,7 @@ const Prism = (props) => {
|
|
|
5
5
|
Highlight,
|
|
6
6
|
{
|
|
7
7
|
theme: themes[props.theme || "github"],
|
|
8
|
-
code: props.value,
|
|
8
|
+
code: props.value || "",
|
|
9
9
|
language: props.lang || ""
|
|
10
10
|
},
|
|
11
11
|
({ className, style, tokens, getLineProps, getTokenProps }) => /* @__PURE__ */ React.createElement("pre", { className, style }, tokens.map((line, i) => /* @__PURE__ */ React.createElement("div", { ...getLineProps({ line, key: i }) }, line.map((token, key) => /* @__PURE__ */ React.createElement("span", { ...getTokenProps({ token, key }) })))))
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This is a static-ready version of the TinaMarkdown component.
|
|
3
|
+
* The primary change is the removal of the `MemoNode` wrapper, which used
|
|
4
|
+
* the `React.useMemo` hook. This hook is for client-side performance
|
|
5
|
+
* optimization and is not needed for server-side rendering (SSR).
|
|
6
|
+
* By rendering the `Node` component directly, the component becomes
|
|
7
|
+
* fully static and can be rendered on the server.
|
|
8
|
+
*/
|
|
9
|
+
import React from 'react';
|
|
10
|
+
type BaseComponents = {
|
|
11
|
+
h1?: {
|
|
12
|
+
children: JSX.Element;
|
|
13
|
+
};
|
|
14
|
+
h2?: {
|
|
15
|
+
children: JSX.Element;
|
|
16
|
+
};
|
|
17
|
+
h3?: {
|
|
18
|
+
children: JSX.Element;
|
|
19
|
+
};
|
|
20
|
+
h4?: {
|
|
21
|
+
children: JSX.Element;
|
|
22
|
+
};
|
|
23
|
+
h5?: {
|
|
24
|
+
children: JSX.Element;
|
|
25
|
+
};
|
|
26
|
+
h6?: {
|
|
27
|
+
children: JSX.Element;
|
|
28
|
+
};
|
|
29
|
+
p?: {
|
|
30
|
+
children: JSX.Element;
|
|
31
|
+
};
|
|
32
|
+
a?: {
|
|
33
|
+
url: string;
|
|
34
|
+
children: JSX.Element;
|
|
35
|
+
};
|
|
36
|
+
italic?: {
|
|
37
|
+
children: JSX.Element;
|
|
38
|
+
};
|
|
39
|
+
bold?: {
|
|
40
|
+
children: JSX.Element;
|
|
41
|
+
};
|
|
42
|
+
strikethrough?: {
|
|
43
|
+
children: JSX.Element;
|
|
44
|
+
};
|
|
45
|
+
underline?: {
|
|
46
|
+
children: JSX.Element;
|
|
47
|
+
};
|
|
48
|
+
code?: {
|
|
49
|
+
children: JSX.Element;
|
|
50
|
+
};
|
|
51
|
+
text?: {
|
|
52
|
+
children: string;
|
|
53
|
+
};
|
|
54
|
+
ul?: {
|
|
55
|
+
children: JSX.Element;
|
|
56
|
+
};
|
|
57
|
+
ol?: {
|
|
58
|
+
children: JSX.Element;
|
|
59
|
+
};
|
|
60
|
+
li?: {
|
|
61
|
+
children: JSX.Element;
|
|
62
|
+
};
|
|
63
|
+
lic?: {
|
|
64
|
+
children: JSX.Element;
|
|
65
|
+
};
|
|
66
|
+
block_quote?: {
|
|
67
|
+
children: JSX.Element;
|
|
68
|
+
};
|
|
69
|
+
code_block?: {
|
|
70
|
+
lang?: string;
|
|
71
|
+
value: string;
|
|
72
|
+
};
|
|
73
|
+
mermaid?: {
|
|
74
|
+
value: string;
|
|
75
|
+
};
|
|
76
|
+
img?: {
|
|
77
|
+
url: string;
|
|
78
|
+
caption?: string;
|
|
79
|
+
alt?: string;
|
|
80
|
+
};
|
|
81
|
+
hr?: {};
|
|
82
|
+
break?: {};
|
|
83
|
+
maybe_mdx?: {
|
|
84
|
+
children: JSX.Element;
|
|
85
|
+
};
|
|
86
|
+
html?: {
|
|
87
|
+
value: string;
|
|
88
|
+
};
|
|
89
|
+
html_inline?: {
|
|
90
|
+
value: string;
|
|
91
|
+
};
|
|
92
|
+
table?: {
|
|
93
|
+
align?: ('left' | 'right' | 'center')[];
|
|
94
|
+
tableRows: {
|
|
95
|
+
tableCells: {
|
|
96
|
+
value: TinaMarkdownContent;
|
|
97
|
+
}[];
|
|
98
|
+
}[];
|
|
99
|
+
};
|
|
100
|
+
component_missing?: {
|
|
101
|
+
name: string;
|
|
102
|
+
};
|
|
103
|
+
};
|
|
104
|
+
type BaseComponentSignature = {
|
|
105
|
+
[BK in keyof BaseComponents]: (props: BaseComponents[BK]) => JSX.Element;
|
|
106
|
+
};
|
|
107
|
+
/**
|
|
108
|
+
* Define the allowed components and their props
|
|
109
|
+
* ```ts
|
|
110
|
+
* const components:
|
|
111
|
+
* Components<{
|
|
112
|
+
* BlockQuote: {
|
|
113
|
+
* children: TinaMarkdownContent;
|
|
114
|
+
* authorName: string;
|
|
115
|
+
* };
|
|
116
|
+
* }> = {
|
|
117
|
+
* BlockQuote: (props: {
|
|
118
|
+
* children: TinaMarkdownContent;
|
|
119
|
+
* authorName: string;
|
|
120
|
+
* }) => {
|
|
121
|
+
* return (
|
|
122
|
+
* <div>
|
|
123
|
+
* <blockquote>
|
|
124
|
+
* <TinaMarkdown content={props.children} />
|
|
125
|
+
* {props.authorName}
|
|
126
|
+
* </blockquote>
|
|
127
|
+
* </div>
|
|
128
|
+
* );
|
|
129
|
+
* }
|
|
130
|
+
* }
|
|
131
|
+
* }
|
|
132
|
+
* ```
|
|
133
|
+
*/
|
|
134
|
+
export type Components<ComponentAndProps extends object> = {
|
|
135
|
+
[K in keyof ComponentAndProps]: (props: ComponentAndProps[K]) => JSX.Element;
|
|
136
|
+
} & BaseComponentSignature;
|
|
137
|
+
export type TinaMarkdownContent = {
|
|
138
|
+
type: string;
|
|
139
|
+
children: TinaMarkdownContent[];
|
|
140
|
+
[key: string]: any;
|
|
141
|
+
};
|
|
142
|
+
export declare const StaticTinaMarkdown: <CustomComponents extends {
|
|
143
|
+
[key: string]: object;
|
|
144
|
+
} = any>({ content, components, }: {
|
|
145
|
+
content: TinaMarkdownContent | TinaMarkdownContent[];
|
|
146
|
+
components?: Components<{}> | Components<{ [BK in keyof CustomComponents]: (props: CustomComponents[BK]) => JSX.Element; }>;
|
|
147
|
+
}) => React.JSX.Element;
|
|
148
|
+
export {};
|