tinacms 2.7.8 → 2.7.10
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/admin/components/Page.d.ts +3 -9
- package/dist/admin/components/Sidebar.d.ts +0 -3
- package/dist/admin/pages/CollectionCreatePage.d.ts +1 -1
- package/dist/admin/pages/DashboardPage.d.ts +0 -3
- package/dist/admin/pages/ScreenPage.d.ts +0 -3
- package/dist/index.js +7363 -6711
- package/dist/index.mjs +7467 -6816
- package/dist/internalClient/index.d.ts +6 -0
- package/dist/react.d.ts +13 -6
- package/dist/react.js +60 -52
- package/dist/react.mjs +60 -52
- 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/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/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/form-builder/fields-builder.d.ts +1 -1
- package/dist/toolkit/form-builder/form-builder.d.ts +4 -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/index.d.ts +0 -1
- 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 +3 -7
- 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/styles/button.d.ts +2 -2
- package/dist/toolkit/tina-state.d.ts +11 -0
- package/dist/utils/cn.d.ts +2 -0
- package/package.json +11 -4
- package/dist/toolkit/plugin-branch-switcher/branch-banner.d.ts +0 -2
|
@@ -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
|
@@ -15,16 +15,23 @@ export declare function useEditState(): {
|
|
|
15
15
|
* to signal to Tina which DOM element the field
|
|
16
16
|
* is working with.
|
|
17
17
|
*/
|
|
18
|
-
|
|
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 {
|
|
19
23
|
_content_source?: {
|
|
20
24
|
queryId: string;
|
|
21
25
|
path: (number | string)[];
|
|
22
26
|
};
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
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;
|
|
28
35
|
/**
|
|
29
36
|
* This is a pretty rudimentary approach to hashing the query and variables to
|
|
30
37
|
* ensure we treat multiple queries on the page uniquely. It's possible
|
package/dist/react.js
CHANGED
|
@@ -11,17 +11,23 @@
|
|
|
11
11
|
() => hashFromQuery(stringifiedQuery),
|
|
12
12
|
[stringifiedQuery]
|
|
13
13
|
);
|
|
14
|
-
const
|
|
14
|
+
const processedData = React.useMemo(() => {
|
|
15
|
+
if (props.data) {
|
|
16
|
+
const dataCopy = JSON.parse(JSON.stringify(props.data));
|
|
17
|
+
return addMetadata(id, dataCopy, []);
|
|
18
|
+
}
|
|
19
|
+
}, [props.data, id]);
|
|
20
|
+
const [data, setData] = React.useState(processedData);
|
|
15
21
|
const [isClient, setIsClient] = React.useState(false);
|
|
16
22
|
const [quickEditEnabled, setQuickEditEnabled] = React.useState(false);
|
|
17
23
|
const [isInTinaIframe, setIsInTinaIframe] = React.useState(false);
|
|
18
24
|
React.useEffect(() => {
|
|
19
25
|
setIsClient(true);
|
|
20
|
-
setData(
|
|
26
|
+
setData(processedData);
|
|
21
27
|
parent.postMessage({
|
|
22
28
|
type: "url-changed"
|
|
23
29
|
});
|
|
24
|
-
}, [id]);
|
|
30
|
+
}, [id, processedData]);
|
|
25
31
|
React.useEffect(() => {
|
|
26
32
|
if (quickEditEnabled) {
|
|
27
33
|
let mouseDownHandler = function(e) {
|
|
@@ -113,12 +119,18 @@
|
|
|
113
119
|
React.useEffect(() => {
|
|
114
120
|
const { experimental___selectFormByFormId, ...rest } = props;
|
|
115
121
|
parent.postMessage({ type: "open", ...rest, id }, window.location.origin);
|
|
116
|
-
|
|
122
|
+
const handleMessage = (event) => {
|
|
117
123
|
if (event.data.type === "quickEditEnabled") {
|
|
118
124
|
setQuickEditEnabled(event.data.value);
|
|
119
125
|
}
|
|
120
126
|
if (event.data.id === id && event.data.type === "updateData") {
|
|
121
|
-
|
|
127
|
+
const rawData = event.data.data;
|
|
128
|
+
const newlyProcessedData = addMetadata(
|
|
129
|
+
id,
|
|
130
|
+
JSON.parse(JSON.stringify(rawData)),
|
|
131
|
+
[]
|
|
132
|
+
);
|
|
133
|
+
setData(newlyProcessedData);
|
|
122
134
|
setIsInTinaIframe(true);
|
|
123
135
|
const anyTinaField = document.querySelector("[data-tina-field]");
|
|
124
136
|
if (anyTinaField) {
|
|
@@ -133,8 +145,10 @@
|
|
|
133
145
|
);
|
|
134
146
|
}
|
|
135
147
|
}
|
|
136
|
-
}
|
|
148
|
+
};
|
|
149
|
+
window.addEventListener("message", handleMessage);
|
|
137
150
|
return () => {
|
|
151
|
+
window.removeEventListener("message", handleMessage);
|
|
138
152
|
parent.postMessage({ type: "close", id }, window.location.origin);
|
|
139
153
|
};
|
|
140
154
|
}, [id, setQuickEditEnabled]);
|
|
@@ -156,59 +170,53 @@
|
|
|
156
170
|
return { edit };
|
|
157
171
|
}
|
|
158
172
|
const tinaField = (object, property, index) => {
|
|
159
|
-
|
|
160
|
-
if (!
|
|
173
|
+
const contentSource = object == null ? void 0 : object._content_source;
|
|
174
|
+
if (!contentSource) {
|
|
161
175
|
return "";
|
|
162
176
|
}
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
(_a = object._content_source) == null ? void 0 : _a.queryId,
|
|
167
|
-
object._content_source.path.join(".")
|
|
168
|
-
].join("---");
|
|
169
|
-
}
|
|
170
|
-
if (typeof index === "number") {
|
|
171
|
-
return [
|
|
172
|
-
(_b = object._content_source) == null ? void 0 : _b.queryId,
|
|
173
|
-
[...object._content_source.path, property, index].join(".")
|
|
174
|
-
].join("---");
|
|
175
|
-
}
|
|
176
|
-
return [
|
|
177
|
-
(_c = object._content_source) == null ? void 0 : _c.queryId,
|
|
178
|
-
[...object._content_source.path, property].join(".")
|
|
179
|
-
].join("---");
|
|
177
|
+
const { queryId, path } = contentSource;
|
|
178
|
+
if (!property) {
|
|
179
|
+
return `${queryId}---${path.join(".")}`;
|
|
180
180
|
}
|
|
181
|
-
|
|
181
|
+
const fullPath = typeof index === "number" ? [...path, property, index] : [...path, property];
|
|
182
|
+
return `${queryId}---${fullPath.join(".")}`;
|
|
182
183
|
};
|
|
183
|
-
const addMetadata = (id,
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
184
|
+
const addMetadata = (id, obj, path = []) => {
|
|
185
|
+
if (obj === null) {
|
|
186
|
+
return obj;
|
|
187
|
+
}
|
|
188
|
+
if (isScalarOrUndefined(obj)) {
|
|
189
|
+
return obj;
|
|
190
|
+
}
|
|
191
|
+
if (obj instanceof String) {
|
|
192
|
+
return obj.valueOf();
|
|
193
|
+
}
|
|
194
|
+
if (Array.isArray(obj)) {
|
|
195
|
+
return obj.map(
|
|
196
|
+
(item, index) => addMetadata(id, item, [...path, index])
|
|
197
|
+
);
|
|
198
|
+
}
|
|
199
|
+
const transformedObj = {};
|
|
200
|
+
for (const [key, value] of Object.entries(obj)) {
|
|
201
|
+
const currentPath = [...path, key];
|
|
202
|
+
if ([
|
|
203
|
+
"__typename",
|
|
204
|
+
"_sys",
|
|
205
|
+
"_internalSys",
|
|
206
|
+
"_values",
|
|
207
|
+
"_internalValues",
|
|
208
|
+
"_content_source",
|
|
209
|
+
"_tina_metadata"
|
|
210
|
+
].includes(key)) {
|
|
211
|
+
transformedObj[key] = value;
|
|
196
212
|
} else {
|
|
197
|
-
|
|
198
|
-
return;
|
|
199
|
-
}
|
|
200
|
-
const itemObject = value;
|
|
201
|
-
addMetadata(id, itemObject, [...path, key]);
|
|
213
|
+
transformedObj[key] = addMetadata(id, value, currentPath);
|
|
202
214
|
}
|
|
203
|
-
});
|
|
204
|
-
if ((object == null ? void 0 : object.type) === "root") {
|
|
205
|
-
return;
|
|
206
215
|
}
|
|
207
|
-
object.
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
};
|
|
211
|
-
return object;
|
|
216
|
+
if (transformedObj && typeof transformedObj === "object" && "type" in transformedObj && transformedObj.type === "root") {
|
|
217
|
+
return transformedObj;
|
|
218
|
+
}
|
|
219
|
+
return { ...transformedObj, _content_source: { queryId: id, path } };
|
|
212
220
|
};
|
|
213
221
|
function isScalarOrUndefined(value) {
|
|
214
222
|
const type = typeof value;
|
package/dist/react.mjs
CHANGED
|
@@ -8,17 +8,23 @@ function useTina(props) {
|
|
|
8
8
|
() => hashFromQuery(stringifiedQuery),
|
|
9
9
|
[stringifiedQuery]
|
|
10
10
|
);
|
|
11
|
-
const
|
|
11
|
+
const processedData = React.useMemo(() => {
|
|
12
|
+
if (props.data) {
|
|
13
|
+
const dataCopy = JSON.parse(JSON.stringify(props.data));
|
|
14
|
+
return addMetadata(id, dataCopy, []);
|
|
15
|
+
}
|
|
16
|
+
}, [props.data, id]);
|
|
17
|
+
const [data, setData] = React.useState(processedData);
|
|
12
18
|
const [isClient, setIsClient] = React.useState(false);
|
|
13
19
|
const [quickEditEnabled, setQuickEditEnabled] = React.useState(false);
|
|
14
20
|
const [isInTinaIframe, setIsInTinaIframe] = React.useState(false);
|
|
15
21
|
React.useEffect(() => {
|
|
16
22
|
setIsClient(true);
|
|
17
|
-
setData(
|
|
23
|
+
setData(processedData);
|
|
18
24
|
parent.postMessage({
|
|
19
25
|
type: "url-changed"
|
|
20
26
|
});
|
|
21
|
-
}, [id]);
|
|
27
|
+
}, [id, processedData]);
|
|
22
28
|
React.useEffect(() => {
|
|
23
29
|
if (quickEditEnabled) {
|
|
24
30
|
let mouseDownHandler = function(e) {
|
|
@@ -110,12 +116,18 @@ function useTina(props) {
|
|
|
110
116
|
React.useEffect(() => {
|
|
111
117
|
const { experimental___selectFormByFormId, ...rest } = props;
|
|
112
118
|
parent.postMessage({ type: "open", ...rest, id }, window.location.origin);
|
|
113
|
-
|
|
119
|
+
const handleMessage = (event) => {
|
|
114
120
|
if (event.data.type === "quickEditEnabled") {
|
|
115
121
|
setQuickEditEnabled(event.data.value);
|
|
116
122
|
}
|
|
117
123
|
if (event.data.id === id && event.data.type === "updateData") {
|
|
118
|
-
|
|
124
|
+
const rawData = event.data.data;
|
|
125
|
+
const newlyProcessedData = addMetadata(
|
|
126
|
+
id,
|
|
127
|
+
JSON.parse(JSON.stringify(rawData)),
|
|
128
|
+
[]
|
|
129
|
+
);
|
|
130
|
+
setData(newlyProcessedData);
|
|
119
131
|
setIsInTinaIframe(true);
|
|
120
132
|
const anyTinaField = document.querySelector("[data-tina-field]");
|
|
121
133
|
if (anyTinaField) {
|
|
@@ -130,8 +142,10 @@ function useTina(props) {
|
|
|
130
142
|
);
|
|
131
143
|
}
|
|
132
144
|
}
|
|
133
|
-
}
|
|
145
|
+
};
|
|
146
|
+
window.addEventListener("message", handleMessage);
|
|
134
147
|
return () => {
|
|
148
|
+
window.removeEventListener("message", handleMessage);
|
|
135
149
|
parent.postMessage({ type: "close", id }, window.location.origin);
|
|
136
150
|
};
|
|
137
151
|
}, [id, setQuickEditEnabled]);
|
|
@@ -153,59 +167,53 @@ function useEditState() {
|
|
|
153
167
|
return { edit };
|
|
154
168
|
}
|
|
155
169
|
const tinaField = (object, property, index) => {
|
|
156
|
-
|
|
157
|
-
if (!
|
|
170
|
+
const contentSource = object == null ? void 0 : object._content_source;
|
|
171
|
+
if (!contentSource) {
|
|
158
172
|
return "";
|
|
159
173
|
}
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
(_a = object._content_source) == null ? void 0 : _a.queryId,
|
|
164
|
-
object._content_source.path.join(".")
|
|
165
|
-
].join("---");
|
|
166
|
-
}
|
|
167
|
-
if (typeof index === "number") {
|
|
168
|
-
return [
|
|
169
|
-
(_b = object._content_source) == null ? void 0 : _b.queryId,
|
|
170
|
-
[...object._content_source.path, property, index].join(".")
|
|
171
|
-
].join("---");
|
|
172
|
-
}
|
|
173
|
-
return [
|
|
174
|
-
(_c = object._content_source) == null ? void 0 : _c.queryId,
|
|
175
|
-
[...object._content_source.path, property].join(".")
|
|
176
|
-
].join("---");
|
|
174
|
+
const { queryId, path } = contentSource;
|
|
175
|
+
if (!property) {
|
|
176
|
+
return `${queryId}---${path.join(".")}`;
|
|
177
177
|
}
|
|
178
|
-
|
|
178
|
+
const fullPath = typeof index === "number" ? [...path, property, index] : [...path, property];
|
|
179
|
+
return `${queryId}---${fullPath.join(".")}`;
|
|
179
180
|
};
|
|
180
|
-
const addMetadata = (id,
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
181
|
+
const addMetadata = (id, obj, path = []) => {
|
|
182
|
+
if (obj === null) {
|
|
183
|
+
return obj;
|
|
184
|
+
}
|
|
185
|
+
if (isScalarOrUndefined(obj)) {
|
|
186
|
+
return obj;
|
|
187
|
+
}
|
|
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;
|
|
193
209
|
} else {
|
|
194
|
-
|
|
195
|
-
return;
|
|
196
|
-
}
|
|
197
|
-
const itemObject = value;
|
|
198
|
-
addMetadata(id, itemObject, [...path, key]);
|
|
210
|
+
transformedObj[key] = addMetadata(id, value, currentPath);
|
|
199
211
|
}
|
|
200
|
-
});
|
|
201
|
-
if ((object == null ? void 0 : object.type) === "root") {
|
|
202
|
-
return;
|
|
203
212
|
}
|
|
204
|
-
object.
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
};
|
|
208
|
-
return object;
|
|
213
|
+
if (transformedObj && typeof transformedObj === "object" && "type" in transformedObj && transformedObj.type === "root") {
|
|
214
|
+
return transformedObj;
|
|
215
|
+
}
|
|
216
|
+
return { ...transformedObj, _content_source: { queryId: id, path } };
|
|
209
217
|
};
|
|
210
218
|
function isScalarOrUndefined(value) {
|
|
211
219
|
const type = typeof value;
|
|
@@ -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 {};
|