tinacms 1.5.10 → 1.5.12
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/pages/IndexingPage.d.ts +2 -0
- package/dist/dev-tools.d.ts +21 -0
- package/dist/dev-tools.es.js +486 -0
- package/dist/dev-tools.js +496 -0
- package/dist/index.es.js +714 -98
- package/dist/index.js +713 -97
- package/dist/internalClient/index.d.ts +18 -11
- package/dist/internalClient/types.d.ts +52 -0
- package/dist/react.d.ts +1 -1
- package/dist/react.es.js +3 -0
- package/dist/react.js +3 -0
- package/dist/style.css +412 -26
- package/package.json +11 -5
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import type { TinaMarkdownContent } from './rich-text';
|
|
3
|
+
declare type RenderValue = (args: {
|
|
4
|
+
value: unknown;
|
|
5
|
+
keyName: string;
|
|
6
|
+
parentValue: object | object[];
|
|
7
|
+
parentKeyName: string;
|
|
8
|
+
}) => JSX.Element;
|
|
9
|
+
declare type RenderRichText = (args: {
|
|
10
|
+
value: TinaMarkdownContent;
|
|
11
|
+
}) => JSX.Element;
|
|
12
|
+
export declare const Explorer: (props: {
|
|
13
|
+
value: object;
|
|
14
|
+
renderValue: RenderValue;
|
|
15
|
+
renderRichText: RenderRichText;
|
|
16
|
+
}) => JSX.Element;
|
|
17
|
+
export declare function Json({ src, withDataTinaFieldState, }: {
|
|
18
|
+
src: object;
|
|
19
|
+
withDataTinaFieldState?: boolean;
|
|
20
|
+
}): JSX.Element;
|
|
21
|
+
export {};
|
|
@@ -0,0 +1,486 @@
|
|
|
1
|
+
import React, { useContext, useState, useEffect, Suspense } from "react";
|
|
2
|
+
const TinaMarkdown = ({
|
|
3
|
+
content,
|
|
4
|
+
components = {}
|
|
5
|
+
}) => {
|
|
6
|
+
if (!content) {
|
|
7
|
+
return null;
|
|
8
|
+
}
|
|
9
|
+
const nodes = Array.isArray(content) ? content : content.children;
|
|
10
|
+
if (!nodes) {
|
|
11
|
+
return null;
|
|
12
|
+
}
|
|
13
|
+
return /* @__PURE__ */ React.createElement(React.Fragment, null, nodes.map((child, index) => {
|
|
14
|
+
return /* @__PURE__ */ React.createElement(MemoNode, {
|
|
15
|
+
components,
|
|
16
|
+
key: index,
|
|
17
|
+
child
|
|
18
|
+
});
|
|
19
|
+
}));
|
|
20
|
+
};
|
|
21
|
+
const Leaf = (props) => {
|
|
22
|
+
if (props.bold) {
|
|
23
|
+
const { bold, ...rest } = props;
|
|
24
|
+
if (props.components.bold) {
|
|
25
|
+
const Component = props.components.bold;
|
|
26
|
+
return /* @__PURE__ */ React.createElement(Component, null, /* @__PURE__ */ React.createElement(Leaf, {
|
|
27
|
+
...rest
|
|
28
|
+
}));
|
|
29
|
+
}
|
|
30
|
+
return /* @__PURE__ */ React.createElement("strong", null, /* @__PURE__ */ React.createElement(Leaf, {
|
|
31
|
+
...rest
|
|
32
|
+
}));
|
|
33
|
+
}
|
|
34
|
+
if (props.italic) {
|
|
35
|
+
const { italic, ...rest } = props;
|
|
36
|
+
if (props.components.italic) {
|
|
37
|
+
const Component = props.components.italic;
|
|
38
|
+
return /* @__PURE__ */ React.createElement(Component, null, /* @__PURE__ */ React.createElement(Leaf, {
|
|
39
|
+
...rest
|
|
40
|
+
}));
|
|
41
|
+
}
|
|
42
|
+
return /* @__PURE__ */ React.createElement("em", null, /* @__PURE__ */ React.createElement(Leaf, {
|
|
43
|
+
...rest
|
|
44
|
+
}));
|
|
45
|
+
}
|
|
46
|
+
if (props.underline) {
|
|
47
|
+
const { underline, ...rest } = props;
|
|
48
|
+
if (props.components.underline) {
|
|
49
|
+
const Component = props.components.underline;
|
|
50
|
+
return /* @__PURE__ */ React.createElement(Component, null, /* @__PURE__ */ React.createElement(Leaf, {
|
|
51
|
+
...rest
|
|
52
|
+
}));
|
|
53
|
+
}
|
|
54
|
+
return /* @__PURE__ */ React.createElement("u", null, /* @__PURE__ */ React.createElement(Leaf, {
|
|
55
|
+
...rest
|
|
56
|
+
}));
|
|
57
|
+
}
|
|
58
|
+
if (props.strikethrough) {
|
|
59
|
+
const { strikethrough, ...rest } = props;
|
|
60
|
+
if (props.components.strikethrough) {
|
|
61
|
+
const Component = props.components.strikethrough;
|
|
62
|
+
return /* @__PURE__ */ React.createElement(Component, null, /* @__PURE__ */ React.createElement(Leaf, {
|
|
63
|
+
...rest
|
|
64
|
+
}));
|
|
65
|
+
}
|
|
66
|
+
return /* @__PURE__ */ React.createElement("s", null, /* @__PURE__ */ React.createElement(Leaf, {
|
|
67
|
+
...rest
|
|
68
|
+
}));
|
|
69
|
+
}
|
|
70
|
+
if (props.code) {
|
|
71
|
+
const { code, ...rest } = props;
|
|
72
|
+
if (props.components.code) {
|
|
73
|
+
const Component = props.components.code;
|
|
74
|
+
return /* @__PURE__ */ React.createElement(Component, null, /* @__PURE__ */ React.createElement(Leaf, {
|
|
75
|
+
...rest
|
|
76
|
+
}));
|
|
77
|
+
}
|
|
78
|
+
return /* @__PURE__ */ React.createElement("code", null, /* @__PURE__ */ React.createElement(Leaf, {
|
|
79
|
+
...rest
|
|
80
|
+
}));
|
|
81
|
+
}
|
|
82
|
+
if (props.components.text) {
|
|
83
|
+
const Component = props.components.text;
|
|
84
|
+
return /* @__PURE__ */ React.createElement(Component, null, props.text);
|
|
85
|
+
}
|
|
86
|
+
return /* @__PURE__ */ React.createElement(React.Fragment, null, props.text);
|
|
87
|
+
};
|
|
88
|
+
const MemoNode = (props) => {
|
|
89
|
+
const MNode = React.useMemo(() => /* @__PURE__ */ React.createElement(Node, {
|
|
90
|
+
...props
|
|
91
|
+
}), [JSON.stringify(props)]);
|
|
92
|
+
return MNode;
|
|
93
|
+
};
|
|
94
|
+
const Node = ({ components, child }) => {
|
|
95
|
+
const { children, ...props } = child;
|
|
96
|
+
switch (child.type) {
|
|
97
|
+
case "h1":
|
|
98
|
+
case "h2":
|
|
99
|
+
case "h3":
|
|
100
|
+
case "h4":
|
|
101
|
+
case "h5":
|
|
102
|
+
case "h6":
|
|
103
|
+
case "p":
|
|
104
|
+
case "blockquote":
|
|
105
|
+
case "ol":
|
|
106
|
+
case "ul":
|
|
107
|
+
case "li":
|
|
108
|
+
if (components[child.type]) {
|
|
109
|
+
const Component2 = components[child.type];
|
|
110
|
+
return /* @__PURE__ */ React.createElement(Component2, {
|
|
111
|
+
...props
|
|
112
|
+
}, /* @__PURE__ */ React.createElement(TinaMarkdown, {
|
|
113
|
+
components,
|
|
114
|
+
content: children
|
|
115
|
+
}));
|
|
116
|
+
}
|
|
117
|
+
return React.createElement(child.type, {
|
|
118
|
+
children: /* @__PURE__ */ React.createElement(TinaMarkdown, {
|
|
119
|
+
components,
|
|
120
|
+
content: children
|
|
121
|
+
})
|
|
122
|
+
});
|
|
123
|
+
case "lic":
|
|
124
|
+
if (components.lic) {
|
|
125
|
+
const Component2 = components.lic;
|
|
126
|
+
return /* @__PURE__ */ React.createElement(Component2, {
|
|
127
|
+
...props
|
|
128
|
+
}, /* @__PURE__ */ React.createElement(TinaMarkdown, {
|
|
129
|
+
components,
|
|
130
|
+
content: children
|
|
131
|
+
}));
|
|
132
|
+
}
|
|
133
|
+
return /* @__PURE__ */ React.createElement("div", null, /* @__PURE__ */ React.createElement(TinaMarkdown, {
|
|
134
|
+
components,
|
|
135
|
+
content: child.children
|
|
136
|
+
}));
|
|
137
|
+
case "img":
|
|
138
|
+
if (components[child.type]) {
|
|
139
|
+
const Component2 = components[child.type];
|
|
140
|
+
return /* @__PURE__ */ React.createElement(Component2, {
|
|
141
|
+
...props
|
|
142
|
+
});
|
|
143
|
+
}
|
|
144
|
+
return /* @__PURE__ */ React.createElement("img", {
|
|
145
|
+
src: child.url,
|
|
146
|
+
alt: child.caption
|
|
147
|
+
});
|
|
148
|
+
case "a":
|
|
149
|
+
if (components[child.type]) {
|
|
150
|
+
const Component2 = components[child.type];
|
|
151
|
+
return /* @__PURE__ */ React.createElement(Component2, {
|
|
152
|
+
...props
|
|
153
|
+
}, /* @__PURE__ */ React.createElement(TinaMarkdown, {
|
|
154
|
+
components,
|
|
155
|
+
content: children
|
|
156
|
+
}));
|
|
157
|
+
}
|
|
158
|
+
return /* @__PURE__ */ React.createElement("a", {
|
|
159
|
+
href: child.url
|
|
160
|
+
}, /* @__PURE__ */ React.createElement(TinaMarkdown, {
|
|
161
|
+
components,
|
|
162
|
+
content: children
|
|
163
|
+
}));
|
|
164
|
+
case "code_block":
|
|
165
|
+
const value = child.value;
|
|
166
|
+
if (components[child.type]) {
|
|
167
|
+
const Component2 = components[child.type];
|
|
168
|
+
return /* @__PURE__ */ React.createElement(Component2, {
|
|
169
|
+
...props
|
|
170
|
+
});
|
|
171
|
+
}
|
|
172
|
+
return /* @__PURE__ */ React.createElement("pre", null, /* @__PURE__ */ React.createElement("code", null, value));
|
|
173
|
+
case "hr":
|
|
174
|
+
if (components[child.type]) {
|
|
175
|
+
const Component2 = components[child.type];
|
|
176
|
+
return /* @__PURE__ */ React.createElement(Component2, {
|
|
177
|
+
...props
|
|
178
|
+
});
|
|
179
|
+
}
|
|
180
|
+
return /* @__PURE__ */ React.createElement("hr", null);
|
|
181
|
+
case "break":
|
|
182
|
+
if (components[child.type]) {
|
|
183
|
+
const Component2 = components[child.type];
|
|
184
|
+
return /* @__PURE__ */ React.createElement(Component2, {
|
|
185
|
+
...props
|
|
186
|
+
});
|
|
187
|
+
}
|
|
188
|
+
return /* @__PURE__ */ React.createElement("br", null);
|
|
189
|
+
case "text":
|
|
190
|
+
return /* @__PURE__ */ React.createElement(Leaf, {
|
|
191
|
+
components,
|
|
192
|
+
...child
|
|
193
|
+
});
|
|
194
|
+
case "mdxJsxTextElement":
|
|
195
|
+
case "mdxJsxFlowElement":
|
|
196
|
+
const Component = components[child.name];
|
|
197
|
+
if (Component) {
|
|
198
|
+
const props2 = child.props ? child.props : {};
|
|
199
|
+
return /* @__PURE__ */ React.createElement(Component, {
|
|
200
|
+
...props2
|
|
201
|
+
});
|
|
202
|
+
} else {
|
|
203
|
+
const ComponentMissing = components["component_missing"];
|
|
204
|
+
if (ComponentMissing) {
|
|
205
|
+
return /* @__PURE__ */ React.createElement(ComponentMissing, {
|
|
206
|
+
name: child.name
|
|
207
|
+
});
|
|
208
|
+
} else {
|
|
209
|
+
return /* @__PURE__ */ React.createElement("span", null, `No component provided for ${child.name}`);
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
case "maybe_mdx":
|
|
213
|
+
return null;
|
|
214
|
+
case "html":
|
|
215
|
+
case "html_inline":
|
|
216
|
+
if (components[child.type]) {
|
|
217
|
+
const Component2 = components[child.type];
|
|
218
|
+
return /* @__PURE__ */ React.createElement(Component2, {
|
|
219
|
+
...props
|
|
220
|
+
});
|
|
221
|
+
}
|
|
222
|
+
return child.value;
|
|
223
|
+
case "invalid_markdown":
|
|
224
|
+
return /* @__PURE__ */ React.createElement("pre", null, child.value);
|
|
225
|
+
default:
|
|
226
|
+
if (typeof child.text === "string") {
|
|
227
|
+
return /* @__PURE__ */ React.createElement(Leaf, {
|
|
228
|
+
components,
|
|
229
|
+
...child
|
|
230
|
+
});
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
};
|
|
234
|
+
const tinaField = (object, property, index) => {
|
|
235
|
+
var _a, _b, _c;
|
|
236
|
+
if (!object) {
|
|
237
|
+
return "";
|
|
238
|
+
}
|
|
239
|
+
if (object._content_source) {
|
|
240
|
+
if (!property) {
|
|
241
|
+
return [
|
|
242
|
+
(_a = object._content_source) == null ? void 0 : _a.queryId,
|
|
243
|
+
object._content_source.path.join(".")
|
|
244
|
+
].join("---");
|
|
245
|
+
}
|
|
246
|
+
if (typeof index === "number") {
|
|
247
|
+
return [
|
|
248
|
+
(_b = object._content_source) == null ? void 0 : _b.queryId,
|
|
249
|
+
[...object._content_source.path, property, index].join(".")
|
|
250
|
+
].join("---");
|
|
251
|
+
}
|
|
252
|
+
return [
|
|
253
|
+
(_c = object._content_source) == null ? void 0 : _c.queryId,
|
|
254
|
+
[...object._content_source.path, property].join(".")
|
|
255
|
+
].join("---");
|
|
256
|
+
}
|
|
257
|
+
return "";
|
|
258
|
+
};
|
|
259
|
+
const Explorer = (props) => {
|
|
260
|
+
return /* @__PURE__ */ React.createElement("div", {
|
|
261
|
+
className: "font-mono"
|
|
262
|
+
}, /* @__PURE__ */ React.createElement(ObjectValueRenderer, {
|
|
263
|
+
...props
|
|
264
|
+
}));
|
|
265
|
+
};
|
|
266
|
+
const ObjectValueRenderer = (props) => {
|
|
267
|
+
const subEntries = Object.entries(props.value).map(([keyName, subValue]) => {
|
|
268
|
+
return /* @__PURE__ */ React.createElement("div", {
|
|
269
|
+
key: keyName,
|
|
270
|
+
className: "gap-2"
|
|
271
|
+
}, /* @__PURE__ */ React.createElement(UnknownRenderer, {
|
|
272
|
+
keyName,
|
|
273
|
+
value: subValue,
|
|
274
|
+
parentValue: props.value,
|
|
275
|
+
parentKeyName: props.parentKeyName,
|
|
276
|
+
renderValue: props.renderValue,
|
|
277
|
+
renderRichText: props.renderRichText,
|
|
278
|
+
showMetaFields: props.showMetaFields
|
|
279
|
+
}));
|
|
280
|
+
});
|
|
281
|
+
return /* @__PURE__ */ React.createElement("div", null, subEntries);
|
|
282
|
+
};
|
|
283
|
+
const UnknownRenderer = ({
|
|
284
|
+
keyName,
|
|
285
|
+
value,
|
|
286
|
+
parentValue,
|
|
287
|
+
parentKeyName,
|
|
288
|
+
renderValue,
|
|
289
|
+
renderRichText,
|
|
290
|
+
showMetaFields
|
|
291
|
+
}) => {
|
|
292
|
+
const typeOfValue = typeof value;
|
|
293
|
+
const [expanded, setExpanded] = React.useState((value == null ? void 0 : value.type) === "root" ? false : true);
|
|
294
|
+
if (!showMetaFields) {
|
|
295
|
+
if ([
|
|
296
|
+
"_sys",
|
|
297
|
+
"__typename",
|
|
298
|
+
"_internalValues",
|
|
299
|
+
"_internalSys"
|
|
300
|
+
].includes(keyName)) {
|
|
301
|
+
return;
|
|
302
|
+
}
|
|
303
|
+
}
|
|
304
|
+
if (Array.isArray(value)) {
|
|
305
|
+
return /* @__PURE__ */ React.createElement("div", null, /* @__PURE__ */ React.createElement("button", {
|
|
306
|
+
onClick: () => setExpanded((exp) => !exp),
|
|
307
|
+
className: "min-w-[48px] flex justify-start gap-2"
|
|
308
|
+
}, keyName, ": ", "[", !expanded && `...]`), expanded && /* @__PURE__ */ React.createElement("div", {
|
|
309
|
+
className: "pl-4"
|
|
310
|
+
}, value.map((item, index) => /* @__PURE__ */ React.createElement(UnknownRenderer, {
|
|
311
|
+
key: String(index),
|
|
312
|
+
keyName: String(index),
|
|
313
|
+
value: item,
|
|
314
|
+
parentKeyName: keyName,
|
|
315
|
+
parentValue,
|
|
316
|
+
renderValue,
|
|
317
|
+
renderRichText
|
|
318
|
+
}))), expanded && /* @__PURE__ */ React.createElement("div", null, "]"));
|
|
319
|
+
}
|
|
320
|
+
if (typeOfValue === "object") {
|
|
321
|
+
if ((value == null ? void 0 : value.type) === "root" && renderRichText) {
|
|
322
|
+
return /* @__PURE__ */ React.createElement("div", {
|
|
323
|
+
className: "flex gap-2"
|
|
324
|
+
}, /* @__PURE__ */ React.createElement("button", {
|
|
325
|
+
onClick: () => setExpanded((exp) => !exp),
|
|
326
|
+
className: "min-w-[48px] flex justify-start gap-2"
|
|
327
|
+
}, keyName, ": ", !expanded && "{...}"), /* @__PURE__ */ React.createElement("div", null, expanded && renderRichText({ value, keyName, parentValue, parentKeyName })));
|
|
328
|
+
}
|
|
329
|
+
return /* @__PURE__ */ React.createElement(ObjectRenderer, {
|
|
330
|
+
keyName,
|
|
331
|
+
value,
|
|
332
|
+
parentValue,
|
|
333
|
+
parentKeyName,
|
|
334
|
+
renderValue,
|
|
335
|
+
renderRichText
|
|
336
|
+
});
|
|
337
|
+
}
|
|
338
|
+
return /* @__PURE__ */ React.createElement(Value, {
|
|
339
|
+
keyName,
|
|
340
|
+
value,
|
|
341
|
+
parentValue,
|
|
342
|
+
parentKeyName,
|
|
343
|
+
renderValue
|
|
344
|
+
});
|
|
345
|
+
};
|
|
346
|
+
const Value = ({
|
|
347
|
+
keyName,
|
|
348
|
+
value,
|
|
349
|
+
parentValue,
|
|
350
|
+
parentKeyName,
|
|
351
|
+
renderValue
|
|
352
|
+
}) => {
|
|
353
|
+
const keyDisplay = isNaN(Number(keyName)) ? `${keyName}: ` : ``;
|
|
354
|
+
return /* @__PURE__ */ React.createElement("div", {
|
|
355
|
+
className: "flex gap-2"
|
|
356
|
+
}, /* @__PURE__ */ React.createElement("div", null, keyDisplay), /* @__PURE__ */ React.createElement("div", null, renderValue({ value, keyName, parentValue, parentKeyName })));
|
|
357
|
+
};
|
|
358
|
+
const ObjectRenderer = ({
|
|
359
|
+
keyName,
|
|
360
|
+
value,
|
|
361
|
+
parentValue,
|
|
362
|
+
parentKeyName,
|
|
363
|
+
renderValue,
|
|
364
|
+
renderRichText
|
|
365
|
+
}) => {
|
|
366
|
+
const { withDataTinaFieldState } = useContext(JsonContext);
|
|
367
|
+
const [showMetaFields, setShowMetaFields] = React.useState(false);
|
|
368
|
+
const [expanded, setExpanded] = React.useState(true);
|
|
369
|
+
const v = value;
|
|
370
|
+
const keyDisplay = isNaN(Number(keyName)) ? `${keyName}: ` : ``;
|
|
371
|
+
if (value === null) {
|
|
372
|
+
return /* @__PURE__ */ React.createElement("div", null, /* @__PURE__ */ React.createElement("div", {
|
|
373
|
+
className: "flex gap-2"
|
|
374
|
+
}, /* @__PURE__ */ React.createElement("div", {
|
|
375
|
+
className: ""
|
|
376
|
+
}, keyDisplay), /* @__PURE__ */ React.createElement("div", {
|
|
377
|
+
className: "text-gray-400"
|
|
378
|
+
}, "null")));
|
|
379
|
+
} else {
|
|
380
|
+
const fieldName = tinaField(v);
|
|
381
|
+
const extraProps = {};
|
|
382
|
+
if (fieldName !== "undefined#undefined" && withDataTinaFieldState) {
|
|
383
|
+
extraProps["data-tina-field"] = fieldName;
|
|
384
|
+
}
|
|
385
|
+
return /* @__PURE__ */ React.createElement("div", null, /* @__PURE__ */ React.createElement("div", {
|
|
386
|
+
className: "flex justify-between"
|
|
387
|
+
}, /* @__PURE__ */ React.createElement("button", {
|
|
388
|
+
onClick: () => setExpanded((exp) => !exp),
|
|
389
|
+
className: "min-w-[48px] flex justify-start gap-2"
|
|
390
|
+
}, keyDisplay, "{", !expanded && `...}`), expanded && /* @__PURE__ */ React.createElement("button", {
|
|
391
|
+
onClick: () => {
|
|
392
|
+
setShowMetaFields((show) => !show);
|
|
393
|
+
},
|
|
394
|
+
className: "min-w-[48px] text-sm text-gray-400"
|
|
395
|
+
}, showMetaFields ? "Hide meta fields" : "Show meta fields")), expanded && /* @__PURE__ */ React.createElement("div", {
|
|
396
|
+
className: "pl-4",
|
|
397
|
+
...extraProps
|
|
398
|
+
}, /* @__PURE__ */ React.createElement(ObjectValueRenderer, {
|
|
399
|
+
value: v,
|
|
400
|
+
parentValue,
|
|
401
|
+
parentKeyName,
|
|
402
|
+
renderValue,
|
|
403
|
+
renderRichText,
|
|
404
|
+
showMetaFields
|
|
405
|
+
})), expanded && /* @__PURE__ */ React.createElement("div", null, "}"));
|
|
406
|
+
}
|
|
407
|
+
};
|
|
408
|
+
const JsonContext = React.createContext({ withDataTinaFieldState: true });
|
|
409
|
+
function Json({
|
|
410
|
+
src,
|
|
411
|
+
withDataTinaFieldState = true
|
|
412
|
+
}) {
|
|
413
|
+
const [isClient, setIsClient] = useState(false);
|
|
414
|
+
useEffect(() => {
|
|
415
|
+
setIsClient(true);
|
|
416
|
+
}, []);
|
|
417
|
+
if (!isClient) {
|
|
418
|
+
return null;
|
|
419
|
+
}
|
|
420
|
+
return /* @__PURE__ */ React.createElement(Suspense, {
|
|
421
|
+
fallback: /* @__PURE__ */ React.createElement("div", {
|
|
422
|
+
className: ""
|
|
423
|
+
}, "Loading...")
|
|
424
|
+
}, /* @__PURE__ */ React.createElement(JsonContext.Provider, {
|
|
425
|
+
value: {
|
|
426
|
+
withDataTinaFieldState: withDataTinaFieldState === false ? false : true
|
|
427
|
+
}
|
|
428
|
+
}, /* @__PURE__ */ React.createElement("div", {
|
|
429
|
+
className: "px-4"
|
|
430
|
+
}, /* @__PURE__ */ React.createElement("div", {
|
|
431
|
+
className: "mx-auto my-8 border rounded-lg p-8 shadow-lg max-w-5xl mx-auto shadow-lg"
|
|
432
|
+
}, /* @__PURE__ */ React.createElement("div", {
|
|
433
|
+
className: "h-full overflow-scroll"
|
|
434
|
+
}, /* @__PURE__ */ React.createElement(Explorer, {
|
|
435
|
+
value: src,
|
|
436
|
+
renderRichText: ({
|
|
437
|
+
value,
|
|
438
|
+
keyName,
|
|
439
|
+
parentValue,
|
|
440
|
+
parentKeyName
|
|
441
|
+
}) => {
|
|
442
|
+
let fieldName = "";
|
|
443
|
+
if (!isNaN(Number(keyName))) {
|
|
444
|
+
fieldName = `${tinaField(parentValue, parentKeyName)}.${keyName}`;
|
|
445
|
+
} else {
|
|
446
|
+
fieldName = tinaField(parentValue, keyName);
|
|
447
|
+
}
|
|
448
|
+
const extraProps = {};
|
|
449
|
+
if (fieldName !== "undefined#undefined") {
|
|
450
|
+
if (fieldName && withDataTinaFieldState) {
|
|
451
|
+
extraProps["data-tina-field"] = fieldName;
|
|
452
|
+
}
|
|
453
|
+
}
|
|
454
|
+
return /* @__PURE__ */ React.createElement("div", {
|
|
455
|
+
className: "font-sans px-2 border-l-2 bg-gray-50 w-full prose",
|
|
456
|
+
...extraProps
|
|
457
|
+
}, /* @__PURE__ */ React.createElement(TinaMarkdown, {
|
|
458
|
+
content: value
|
|
459
|
+
}));
|
|
460
|
+
},
|
|
461
|
+
renderValue: ({
|
|
462
|
+
value,
|
|
463
|
+
keyName,
|
|
464
|
+
parentValue,
|
|
465
|
+
parentKeyName
|
|
466
|
+
}) => {
|
|
467
|
+
let fieldName = "";
|
|
468
|
+
if (!isNaN(Number(keyName))) {
|
|
469
|
+
fieldName = `${tinaField(parentValue, parentKeyName)}.${keyName}`;
|
|
470
|
+
} else {
|
|
471
|
+
fieldName = tinaField(parentValue, keyName);
|
|
472
|
+
}
|
|
473
|
+
const extraProps = {};
|
|
474
|
+
if (fieldName !== "undefined#undefined") {
|
|
475
|
+
if (fieldName && withDataTinaFieldState) {
|
|
476
|
+
extraProps["data-tina-field"] = fieldName;
|
|
477
|
+
}
|
|
478
|
+
}
|
|
479
|
+
return /* @__PURE__ */ React.createElement("span", {
|
|
480
|
+
className: "text-orange-600",
|
|
481
|
+
...extraProps
|
|
482
|
+
}, value);
|
|
483
|
+
}
|
|
484
|
+
}))))));
|
|
485
|
+
}
|
|
486
|
+
export { Explorer, Json };
|