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