tinacms 0.68.14 → 0.69.1

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.
@@ -1,223 +0,0 @@
1
- import React 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
- const key = index;
15
- const { children, ...props } = child;
16
- switch (child.type) {
17
- case "h1":
18
- case "h2":
19
- case "h3":
20
- case "h4":
21
- case "h5":
22
- case "h6":
23
- case "p":
24
- case "blockquote":
25
- case "ol":
26
- case "ul":
27
- case "li":
28
- if (components[child.type]) {
29
- const Component2 = components[child.type];
30
- return /* @__PURE__ */ React.createElement(Component2, {
31
- key,
32
- ...props
33
- }, /* @__PURE__ */ React.createElement(TinaMarkdown, {
34
- components,
35
- content: children
36
- }));
37
- }
38
- return React.createElement(child.type, {
39
- key,
40
- children: /* @__PURE__ */ React.createElement(TinaMarkdown, {
41
- components,
42
- content: children
43
- })
44
- });
45
- case "lic":
46
- return /* @__PURE__ */ React.createElement("div", {
47
- key
48
- }, /* @__PURE__ */ React.createElement(TinaMarkdown, {
49
- components,
50
- content: child.children
51
- }));
52
- case "img":
53
- if (components[child.type]) {
54
- const Component2 = components[child.type];
55
- return /* @__PURE__ */ React.createElement(Component2, {
56
- key,
57
- ...props
58
- });
59
- }
60
- return /* @__PURE__ */ React.createElement("img", {
61
- key,
62
- src: child.url,
63
- alt: child.caption
64
- });
65
- case "a":
66
- if (components[child.type]) {
67
- const Component2 = components[child.type];
68
- return /* @__PURE__ */ React.createElement(Component2, {
69
- key,
70
- ...props
71
- }, /* @__PURE__ */ React.createElement(TinaMarkdown, {
72
- components,
73
- content: children
74
- }));
75
- }
76
- return /* @__PURE__ */ React.createElement("a", {
77
- key,
78
- href: child.url
79
- }, /* @__PURE__ */ React.createElement(TinaMarkdown, {
80
- components,
81
- content: children
82
- }));
83
- case "code_block":
84
- const value = child.children.map((item) => {
85
- var _a;
86
- return item.children ? ((_a = item.children[0]) == null ? void 0 : _a.text) || "" : "";
87
- }).join("\n");
88
- if (components[child.type]) {
89
- const Component2 = components[child.type];
90
- return /* @__PURE__ */ React.createElement(Component2, {
91
- key,
92
- ...props
93
- }, value);
94
- }
95
- return /* @__PURE__ */ React.createElement("pre", {
96
- key
97
- }, /* @__PURE__ */ React.createElement("code", null, value));
98
- case "hr":
99
- if (components[child.type]) {
100
- const Component2 = components[child.type];
101
- return /* @__PURE__ */ React.createElement(Component2, {
102
- key,
103
- ...props
104
- });
105
- }
106
- return /* @__PURE__ */ React.createElement("hr", {
107
- key
108
- });
109
- case "break":
110
- if (components[child.type]) {
111
- const Component2 = components[child.type];
112
- return /* @__PURE__ */ React.createElement(Component2, {
113
- key,
114
- ...props
115
- });
116
- }
117
- return /* @__PURE__ */ React.createElement("br", {
118
- key
119
- });
120
- case "text":
121
- return /* @__PURE__ */ React.createElement(Leaf, {
122
- key,
123
- components,
124
- ...child
125
- });
126
- case "mdxJsxTextElement":
127
- case "mdxJsxFlowElement":
128
- const Component = components[child.name];
129
- if (Component) {
130
- const props2 = child.props ? child.props : {};
131
- return /* @__PURE__ */ React.createElement(Component, {
132
- key,
133
- ...props2
134
- });
135
- } else {
136
- const ComponentMissing = components["component_missing"];
137
- if (ComponentMissing) {
138
- return /* @__PURE__ */ React.createElement(ComponentMissing, {
139
- key,
140
- name: child.name
141
- });
142
- } else {
143
- throw new Error(`No component provided for ${child.name}`);
144
- }
145
- }
146
- case "maybe_mdx":
147
- return null;
148
- default:
149
- if (typeof child.text === "string") {
150
- return /* @__PURE__ */ React.createElement(Leaf, {
151
- key,
152
- components,
153
- ...child
154
- });
155
- }
156
- console.log(`No tina renderer for ${child.type}`, child);
157
- }
158
- }));
159
- };
160
- const Leaf = (props) => {
161
- if (props.bold) {
162
- const { bold, ...rest } = props;
163
- if (props.components.bold) {
164
- const Component = props.components.bold;
165
- return /* @__PURE__ */ React.createElement(Component, null, /* @__PURE__ */ React.createElement(Leaf, {
166
- ...rest
167
- }));
168
- }
169
- return /* @__PURE__ */ React.createElement("strong", null, /* @__PURE__ */ React.createElement(Leaf, {
170
- ...rest
171
- }));
172
- }
173
- if (props.italic) {
174
- const { italic, ...rest } = props;
175
- if (props.components.italic) {
176
- const Component = props.components.italic;
177
- return /* @__PURE__ */ React.createElement(Component, null, /* @__PURE__ */ React.createElement(Leaf, {
178
- ...rest
179
- }));
180
- }
181
- return /* @__PURE__ */ React.createElement("em", null, /* @__PURE__ */ React.createElement(Leaf, {
182
- ...rest
183
- }));
184
- }
185
- if (props.underline) {
186
- const { underline, ...rest } = props;
187
- if (props.components.underline) {
188
- const Component = props.components.underline;
189
- return /* @__PURE__ */ React.createElement(Component, null, /* @__PURE__ */ React.createElement(Leaf, {
190
- ...rest
191
- }));
192
- }
193
- return /* @__PURE__ */ React.createElement("u", null, /* @__PURE__ */ React.createElement(Leaf, {
194
- ...rest
195
- }));
196
- }
197
- if (props.strikethrough) {
198
- const { strikethrough, ...rest } = props;
199
- if (props.components.strikethrough) {
200
- const Component = props.components.strikethrough;
201
- return /* @__PURE__ */ React.createElement(Component, null, /* @__PURE__ */ React.createElement(Leaf, {
202
- ...rest
203
- }));
204
- }
205
- return /* @__PURE__ */ React.createElement("s", null, /* @__PURE__ */ React.createElement(Leaf, {
206
- ...rest
207
- }));
208
- }
209
- if (props.code) {
210
- const { code, ...rest } = props;
211
- if (props.components.code) {
212
- const Component = props.components.code;
213
- return /* @__PURE__ */ React.createElement(Component, null, /* @__PURE__ */ React.createElement(Leaf, {
214
- ...rest
215
- }));
216
- }
217
- return /* @__PURE__ */ React.createElement("code", null, /* @__PURE__ */ React.createElement(Leaf, {
218
- ...rest
219
- }));
220
- }
221
- return /* @__PURE__ */ React.createElement(React.Fragment, null, props.text);
222
- };
223
- export { TinaMarkdown };