tinacms 0.68.15 → 0.69.2

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/index.d.ts CHANGED
@@ -20,7 +20,8 @@ export * from '@tinacms/toolkit';
20
20
  export { TinaAdmin } from './admin';
21
21
  export { RouteMappingPlugin } from './admin/plugins/route-mapping';
22
22
  export { TinaAdminApi } from './admin/api';
23
- import { TinaCMSProvider2, TinaCMSProviderDefaultProps } from './tina-cms';
23
+ import { TinaCMSProvider2 } from './tina-cms';
24
+ import type { TinaCMSProviderDefaultProps } from './types/cms';
24
25
  export type { TinaCMSProviderDefaultProps };
25
26
  export default TinaCMSProvider2;
26
27
  import type { TinaCloudSchema as TinaCloudSchemaBase, TinaCloudCollection as TinaCloudCollectionBase, TinaCloudTemplateBase as TinaTemplate, TinaFieldBase } from '@tinacms/schema-tools';
package/dist/index.es.js CHANGED
@@ -1175,7 +1175,8 @@ const formify = async ({
1175
1175
  return formifyInlineFragmentNode({
1176
1176
  inlineFragmentNode: selectionNode,
1177
1177
  parentType: type,
1178
- path
1178
+ path,
1179
+ showInSidebar: true
1179
1180
  });
1180
1181
  }
1181
1182
  case "Field": {
@@ -1245,7 +1246,8 @@ const formify = async ({
1245
1246
  return formifyInlineFragmentNode({
1246
1247
  inlineFragmentNode: selectionNode,
1247
1248
  parentType: field.type,
1248
- path: fieldPath
1249
+ path: fieldPath,
1250
+ showInSidebar: false
1249
1251
  });
1250
1252
  }
1251
1253
  default:
@@ -1259,7 +1261,8 @@ const formify = async ({
1259
1261
  const formifyInlineFragmentNode = ({
1260
1262
  inlineFragmentNode,
1261
1263
  parentType,
1262
- path
1264
+ path,
1265
+ showInSidebar
1263
1266
  }) => {
1264
1267
  const type = getSelectedUnionType(parentType, inlineFragmentNode);
1265
1268
  if (!type) {
@@ -1270,7 +1273,7 @@ const formify = async ({
1270
1273
  inlineFragmentNode,
1271
1274
  type,
1272
1275
  path,
1273
- showInSidebar: false
1276
+ showInSidebar
1274
1277
  });
1275
1278
  }
1276
1279
  return {
@@ -3854,9 +3857,9 @@ const useDocumentCreatorPlugin = (args) => {
3854
3857
  }
3855
3858
  return true;
3856
3859
  }
3857
- const isValid = /^[_a-zA-Z][-,_a-zA-Z0-9]*$/.test(value);
3860
+ const isValid = /^[_a-zA-Z0-9][\-_a-zA-Z0-9]*$/.test(value);
3858
3861
  if (value && !isValid) {
3859
- return "Must begin with a-z, A-Z, or _ and contain only a-z, A-Z, 0-9, - or _";
3862
+ return "Must begin with a-z, A-Z, 0-9, or _ and contain only a-z, A-Z, 0-9, - or _";
3860
3863
  }
3861
3864
  }
3862
3865
  }
@@ -4016,16 +4019,18 @@ const TinaCMSProvider2 = ({
4016
4019
  ...props
4017
4020
  }) => {
4018
4021
  var _a;
4019
- const validOldSetup = new Boolean(props == null ? void 0 : props.isLocalClient) || new Boolean(props == null ? void 0 : props.clientId) && new Boolean(props == null ? void 0 : props.branch);
4020
- const apiURL = ((_a = props == null ? void 0 : props.client) == null ? void 0 : _a.apiUrl) || (props == null ? void 0 : props.apiURL);
4021
- if (!apiURL && !validOldSetup) {
4022
- throw new Error(`Must provide apiUrl or a client to the TinaWrapper component`);
4022
+ if (props == null ? void 0 : props.apiURL) {
4023
+ console.warn("The apiURL prop is deprecated. Please see https://tina.io/blog/tina-v-0.68.14 for information on how to upgrade to the new API");
4023
4024
  }
4025
+ const apiURL = ((_a = props == null ? void 0 : props.client) == null ? void 0 : _a.apiUrl) || (props == null ? void 0 : props.apiURL);
4024
4026
  const { branch, clientId, isLocalClient } = apiURL ? parseURL(apiURL) : {
4025
4027
  branch: props.branch,
4026
4028
  clientId: props.clientId,
4027
- isLocalClient: props.isLocalClient
4029
+ isLocalClient: props == null ? void 0 : props.isLocalClient
4028
4030
  };
4031
+ if (typeof isLocalClient === "undefined" || !isLocalClient && (!branch || !clientId)) {
4032
+ throw new Error("Invalid setup. See https://tina.io/docs/tina-cloud/connecting-site/ for more information.");
4033
+ }
4029
4034
  if (!schema) {
4030
4035
  throw new Error("`schema` is required to be passed as a property to `TinaProvider`. You can learn more about this change here: https://github.com/tinacms/tinacms/pull/2823");
4031
4036
  }
@@ -4745,9 +4750,10 @@ const useGetCollection = (cms, collectionName, includeDocuments = true, after =
4745
4750
  const [resetState, setResetSate] = useState(0);
4746
4751
  useEffect(() => {
4747
4752
  const fetchCollection = async () => {
4753
+ var _a;
4748
4754
  if (await api.isAuthenticated()) {
4749
4755
  const { name, order } = JSON.parse(sortKey || "{}");
4750
- const validSortKey = collectionExtra.fields.map((x) => x.name).includes(name) ? name : void 0;
4756
+ const validSortKey = ((_a = collectionExtra.fields) == null ? void 0 : _a.map((x) => x.name).includes(name)) ? name : void 0;
4751
4757
  try {
4752
4758
  const collection2 = await api.fetchCollection(collectionName, includeDocuments, after, validSortKey, order);
4753
4759
  setCollection(collection2);
@@ -4855,12 +4861,12 @@ const CollectionListPage = () => {
4855
4861
  startCursor: endCursor,
4856
4862
  sortKey
4857
4863
  }, (collection, _loading, reFetchCollection, collectionExtra) => {
4858
- var _a, _b;
4864
+ var _a, _b, _c;
4859
4865
  const totalCount = collection.documents.totalCount;
4860
4866
  const documents = collection.documents.edges;
4861
4867
  const admin = cms.api.admin;
4862
4868
  const pageInfo = collection.documents.pageInfo;
4863
- const fields = collectionExtra.fields.filter((x) => ["string", "number", "datetime"].includes(x.type));
4869
+ const fields = (_a = collectionExtra.fields) == null ? void 0 : _a.filter((x) => ["string", "number", "datetime"].includes(x.type));
4864
4870
  return /* @__PURE__ */ React.createElement(PageWrapper, null, /* @__PURE__ */ React.createElement(React.Fragment, null, open && /* @__PURE__ */ React.createElement(DeleteModal, {
4865
4871
  filename: vars.relativePath,
4866
4872
  deleteFunc: async () => {
@@ -4876,7 +4882,7 @@ const CollectionListPage = () => {
4876
4882
  },
4877
4883
  close: () => setOpen(false)
4878
4884
  }), /* @__PURE__ */ React.createElement(PageHeader, {
4879
- isLocalMode: (_b = (_a = cms == null ? void 0 : cms.api) == null ? void 0 : _a.tina) == null ? void 0 : _b.isLocalMode
4885
+ isLocalMode: (_c = (_b = cms == null ? void 0 : cms.api) == null ? void 0 : _b.tina) == null ? void 0 : _c.isLocalMode
4880
4886
  }, /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement("div", {
4881
4887
  className: "flex flex-col gap-4"
4882
4888
  }, /* @__PURE__ */ React.createElement("h3", {
@@ -5128,9 +5134,9 @@ const RenderForm$1 = ({ cms, collection, templateName, mutationInfo }) => {
5128
5134
  }
5129
5135
  return true;
5130
5136
  }
5131
- const isValid = /^[_a-zA-Z][\.\-_\/a-zA-Z0-9]*$/.test(value);
5137
+ const isValid = /^[_a-zA-Z0-9][\.\-_\/a-zA-Z0-9]*$/.test(value);
5132
5138
  if (value && !isValid) {
5133
- return "Must begin with a-z, A-Z, or _ and contain only a-z, A-Z, 0-9, -, _, ., or /.";
5139
+ return "Must begin with a-z, A-Z, 0-9, or _ and contain only a-z, A-Z, 0-9, -, _, ., or /.";
5134
5140
  }
5135
5141
  }
5136
5142
  },
package/dist/index.js CHANGED
@@ -1193,7 +1193,8 @@
1193
1193
  return formifyInlineFragmentNode({
1194
1194
  inlineFragmentNode: selectionNode,
1195
1195
  parentType: type,
1196
- path
1196
+ path,
1197
+ showInSidebar: true
1197
1198
  });
1198
1199
  }
1199
1200
  case "Field": {
@@ -1263,7 +1264,8 @@
1263
1264
  return formifyInlineFragmentNode({
1264
1265
  inlineFragmentNode: selectionNode,
1265
1266
  parentType: field.type,
1266
- path: fieldPath
1267
+ path: fieldPath,
1268
+ showInSidebar: false
1267
1269
  });
1268
1270
  }
1269
1271
  default:
@@ -1277,7 +1279,8 @@
1277
1279
  const formifyInlineFragmentNode = ({
1278
1280
  inlineFragmentNode,
1279
1281
  parentType,
1280
- path
1282
+ path,
1283
+ showInSidebar
1281
1284
  }) => {
1282
1285
  const type = getSelectedUnionType(parentType, inlineFragmentNode);
1283
1286
  if (!type) {
@@ -1288,7 +1291,7 @@
1288
1291
  inlineFragmentNode,
1289
1292
  type,
1290
1293
  path,
1291
- showInSidebar: false
1294
+ showInSidebar
1292
1295
  });
1293
1296
  }
1294
1297
  return {
@@ -3872,9 +3875,9 @@ mutation addPendingDocumentMutation(
3872
3875
  }
3873
3876
  return true;
3874
3877
  }
3875
- const isValid = /^[_a-zA-Z][-,_a-zA-Z0-9]*$/.test(value);
3878
+ const isValid = /^[_a-zA-Z0-9][\-_a-zA-Z0-9]*$/.test(value);
3876
3879
  if (value && !isValid) {
3877
- return "Must begin with a-z, A-Z, or _ and contain only a-z, A-Z, 0-9, - or _";
3880
+ return "Must begin with a-z, A-Z, 0-9, or _ and contain only a-z, A-Z, 0-9, - or _";
3878
3881
  }
3879
3882
  }
3880
3883
  }
@@ -4034,16 +4037,18 @@ mutation addPendingDocumentMutation(
4034
4037
  ...props
4035
4038
  }) => {
4036
4039
  var _a;
4037
- const validOldSetup = new Boolean(props == null ? void 0 : props.isLocalClient) || new Boolean(props == null ? void 0 : props.clientId) && new Boolean(props == null ? void 0 : props.branch);
4038
- const apiURL = ((_a = props == null ? void 0 : props.client) == null ? void 0 : _a.apiUrl) || (props == null ? void 0 : props.apiURL);
4039
- if (!apiURL && !validOldSetup) {
4040
- throw new Error(`Must provide apiUrl or a client to the TinaWrapper component`);
4040
+ if (props == null ? void 0 : props.apiURL) {
4041
+ console.warn("The apiURL prop is deprecated. Please see https://tina.io/blog/tina-v-0.68.14 for information on how to upgrade to the new API");
4041
4042
  }
4043
+ const apiURL = ((_a = props == null ? void 0 : props.client) == null ? void 0 : _a.apiUrl) || (props == null ? void 0 : props.apiURL);
4042
4044
  const { branch, clientId, isLocalClient } = apiURL ? parseURL(apiURL) : {
4043
4045
  branch: props.branch,
4044
4046
  clientId: props.clientId,
4045
- isLocalClient: props.isLocalClient
4047
+ isLocalClient: props == null ? void 0 : props.isLocalClient
4046
4048
  };
4049
+ if (typeof isLocalClient === "undefined" || !isLocalClient && (!branch || !clientId)) {
4050
+ throw new Error("Invalid setup. See https://tina.io/docs/tina-cloud/connecting-site/ for more information.");
4051
+ }
4047
4052
  if (!schema) {
4048
4053
  throw new Error("`schema` is required to be passed as a property to `TinaProvider`. You can learn more about this change here: https://github.com/tinacms/tinacms/pull/2823");
4049
4054
  }
@@ -4763,9 +4768,10 @@ This will work when developing locally but NOT when deployed to production.
4763
4768
  const [resetState, setResetSate] = React.useState(0);
4764
4769
  React.useEffect(() => {
4765
4770
  const fetchCollection = async () => {
4771
+ var _a;
4766
4772
  if (await api.isAuthenticated()) {
4767
4773
  const { name, order } = JSON.parse(sortKey || "{}");
4768
- const validSortKey = collectionExtra.fields.map((x) => x.name).includes(name) ? name : void 0;
4774
+ const validSortKey = ((_a = collectionExtra.fields) == null ? void 0 : _a.map((x) => x.name).includes(name)) ? name : void 0;
4769
4775
  try {
4770
4776
  const collection2 = await api.fetchCollection(collectionName, includeDocuments, after, validSortKey, order);
4771
4777
  setCollection(collection2);
@@ -4873,12 +4879,12 @@ This will work when developing locally but NOT when deployed to production.
4873
4879
  startCursor: endCursor,
4874
4880
  sortKey
4875
4881
  }, (collection, _loading, reFetchCollection, collectionExtra) => {
4876
- var _a, _b;
4882
+ var _a, _b, _c;
4877
4883
  const totalCount = collection.documents.totalCount;
4878
4884
  const documents = collection.documents.edges;
4879
4885
  const admin = cms.api.admin;
4880
4886
  const pageInfo = collection.documents.pageInfo;
4881
- const fields = collectionExtra.fields.filter((x) => ["string", "number", "datetime"].includes(x.type));
4887
+ const fields = (_a = collectionExtra.fields) == null ? void 0 : _a.filter((x) => ["string", "number", "datetime"].includes(x.type));
4882
4888
  return /* @__PURE__ */ React__default["default"].createElement(PageWrapper, null, /* @__PURE__ */ React__default["default"].createElement(React__default["default"].Fragment, null, open && /* @__PURE__ */ React__default["default"].createElement(DeleteModal, {
4883
4889
  filename: vars.relativePath,
4884
4890
  deleteFunc: async () => {
@@ -4894,7 +4900,7 @@ This will work when developing locally but NOT when deployed to production.
4894
4900
  },
4895
4901
  close: () => setOpen(false)
4896
4902
  }), /* @__PURE__ */ React__default["default"].createElement(PageHeader, {
4897
- isLocalMode: (_b = (_a = cms == null ? void 0 : cms.api) == null ? void 0 : _a.tina) == null ? void 0 : _b.isLocalMode
4903
+ isLocalMode: (_c = (_b = cms == null ? void 0 : cms.api) == null ? void 0 : _b.tina) == null ? void 0 : _c.isLocalMode
4898
4904
  }, /* @__PURE__ */ React__default["default"].createElement(React__default["default"].Fragment, null, /* @__PURE__ */ React__default["default"].createElement("div", {
4899
4905
  className: "flex flex-col gap-4"
4900
4906
  }, /* @__PURE__ */ React__default["default"].createElement("h3", {
@@ -5146,9 +5152,9 @@ This will work when developing locally but NOT when deployed to production.
5146
5152
  }
5147
5153
  return true;
5148
5154
  }
5149
- const isValid = /^[_a-zA-Z][\.\-_\/a-zA-Z0-9]*$/.test(value);
5155
+ const isValid = /^[_a-zA-Z0-9][\.\-_\/a-zA-Z0-9]*$/.test(value);
5150
5156
  if (value && !isValid) {
5151
- return "Must begin with a-z, A-Z, or _ and contain only a-z, A-Z, 0-9, -, _, ., or /.";
5157
+ return "Must begin with a-z, A-Z, 0-9, or _ and contain only a-z, A-Z, 0-9, -, _, ., or /.";
5152
5158
  }
5153
5159
  }
5154
5160
  },
@@ -74,6 +74,12 @@ declare type BaseComponents = {
74
74
  maybe_mdx?: {
75
75
  children: JSX.Element;
76
76
  };
77
+ html?: {
78
+ value: string;
79
+ };
80
+ html_inline?: {
81
+ value: string;
82
+ };
77
83
  component_missing?: {
78
84
  name: string;
79
85
  };
@@ -0,0 +1,221 @@
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
+ 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
+ return /* @__PURE__ */ React.createElement(React.Fragment, null, props.text);
83
+ };
84
+ const MemoNode = (props) => {
85
+ const MNode = React.useMemo(() => /* @__PURE__ */ React.createElement(Node, {
86
+ ...props
87
+ }), [JSON.stringify(props)]);
88
+ return MNode;
89
+ };
90
+ const Node = ({ components, child }) => {
91
+ const { children, ...props } = child;
92
+ switch (child.type) {
93
+ case "h1":
94
+ case "h2":
95
+ case "h3":
96
+ case "h4":
97
+ case "h5":
98
+ case "h6":
99
+ case "p":
100
+ case "blockquote":
101
+ case "ol":
102
+ case "ul":
103
+ case "li":
104
+ if (components[child.type]) {
105
+ const Component2 = components[child.type];
106
+ return /* @__PURE__ */ React.createElement(Component2, {
107
+ ...props
108
+ }, /* @__PURE__ */ React.createElement(TinaMarkdown, {
109
+ components,
110
+ content: children
111
+ }));
112
+ }
113
+ return React.createElement(child.type, {
114
+ children: /* @__PURE__ */ React.createElement(TinaMarkdown, {
115
+ components,
116
+ content: children
117
+ })
118
+ });
119
+ case "lic":
120
+ return /* @__PURE__ */ React.createElement("div", null, /* @__PURE__ */ React.createElement(TinaMarkdown, {
121
+ components,
122
+ content: child.children
123
+ }));
124
+ case "img":
125
+ if (components[child.type]) {
126
+ const Component2 = components[child.type];
127
+ return /* @__PURE__ */ React.createElement(Component2, {
128
+ ...props
129
+ });
130
+ }
131
+ return /* @__PURE__ */ React.createElement("img", {
132
+ src: child.url,
133
+ alt: child.caption
134
+ });
135
+ case "a":
136
+ if (components[child.type]) {
137
+ const Component2 = components[child.type];
138
+ return /* @__PURE__ */ React.createElement(Component2, {
139
+ ...props
140
+ }, /* @__PURE__ */ React.createElement(TinaMarkdown, {
141
+ components,
142
+ content: children
143
+ }));
144
+ }
145
+ return /* @__PURE__ */ React.createElement("a", {
146
+ href: child.url
147
+ }, /* @__PURE__ */ React.createElement(TinaMarkdown, {
148
+ components,
149
+ content: children
150
+ }));
151
+ case "code_block":
152
+ const value = child.value;
153
+ if (components[child.type]) {
154
+ const Component2 = components[child.type];
155
+ return /* @__PURE__ */ React.createElement(Component2, {
156
+ ...props
157
+ }, value);
158
+ }
159
+ return /* @__PURE__ */ React.createElement("pre", null, /* @__PURE__ */ React.createElement("code", null, value));
160
+ case "hr":
161
+ if (components[child.type]) {
162
+ const Component2 = components[child.type];
163
+ return /* @__PURE__ */ React.createElement(Component2, {
164
+ ...props
165
+ });
166
+ }
167
+ return /* @__PURE__ */ React.createElement("hr", null);
168
+ case "break":
169
+ if (components[child.type]) {
170
+ const Component2 = components[child.type];
171
+ return /* @__PURE__ */ React.createElement(Component2, {
172
+ ...props
173
+ });
174
+ }
175
+ return /* @__PURE__ */ React.createElement("br", null);
176
+ case "text":
177
+ return /* @__PURE__ */ React.createElement(Leaf, {
178
+ components,
179
+ ...child
180
+ });
181
+ case "mdxJsxTextElement":
182
+ case "mdxJsxFlowElement":
183
+ const Component = components[child.name];
184
+ if (Component) {
185
+ const props2 = child.props ? child.props : {};
186
+ return /* @__PURE__ */ React.createElement(Component, {
187
+ ...props2
188
+ });
189
+ } else {
190
+ const ComponentMissing = components["component_missing"];
191
+ if (ComponentMissing) {
192
+ return /* @__PURE__ */ React.createElement(ComponentMissing, {
193
+ name: child.name
194
+ });
195
+ } else {
196
+ return /* @__PURE__ */ React.createElement("span", null, `No component provided for ${child.name}`);
197
+ }
198
+ }
199
+ case "maybe_mdx":
200
+ return null;
201
+ case "html":
202
+ case "html_inline":
203
+ if (components[child.type]) {
204
+ const Component2 = components[child.type];
205
+ return /* @__PURE__ */ React.createElement(Component2, {
206
+ ...props
207
+ });
208
+ }
209
+ return child.value;
210
+ case "invalid_markdown":
211
+ return /* @__PURE__ */ React.createElement("pre", null, child.value);
212
+ default:
213
+ if (typeof child.text === "string") {
214
+ return /* @__PURE__ */ React.createElement(Leaf, {
215
+ components,
216
+ ...child
217
+ });
218
+ }
219
+ }
220
+ };
221
+ export { TinaMarkdown };
@@ -18,150 +18,11 @@
18
18
  return null;
19
19
  }
20
20
  return /* @__PURE__ */ React__default["default"].createElement(React__default["default"].Fragment, null, nodes.map((child, index) => {
21
- const key = index;
22
- const { children, ...props } = child;
23
- switch (child.type) {
24
- case "h1":
25
- case "h2":
26
- case "h3":
27
- case "h4":
28
- case "h5":
29
- case "h6":
30
- case "p":
31
- case "blockquote":
32
- case "ol":
33
- case "ul":
34
- case "li":
35
- if (components[child.type]) {
36
- const Component2 = components[child.type];
37
- return /* @__PURE__ */ React__default["default"].createElement(Component2, {
38
- key,
39
- ...props
40
- }, /* @__PURE__ */ React__default["default"].createElement(TinaMarkdown, {
41
- components,
42
- content: children
43
- }));
44
- }
45
- return React__default["default"].createElement(child.type, {
46
- key,
47
- children: /* @__PURE__ */ React__default["default"].createElement(TinaMarkdown, {
48
- components,
49
- content: children
50
- })
51
- });
52
- case "lic":
53
- return /* @__PURE__ */ React__default["default"].createElement("div", {
54
- key
55
- }, /* @__PURE__ */ React__default["default"].createElement(TinaMarkdown, {
56
- components,
57
- content: child.children
58
- }));
59
- case "img":
60
- if (components[child.type]) {
61
- const Component2 = components[child.type];
62
- return /* @__PURE__ */ React__default["default"].createElement(Component2, {
63
- key,
64
- ...props
65
- });
66
- }
67
- return /* @__PURE__ */ React__default["default"].createElement("img", {
68
- key,
69
- src: child.url,
70
- alt: child.caption
71
- });
72
- case "a":
73
- if (components[child.type]) {
74
- const Component2 = components[child.type];
75
- return /* @__PURE__ */ React__default["default"].createElement(Component2, {
76
- key,
77
- ...props
78
- }, /* @__PURE__ */ React__default["default"].createElement(TinaMarkdown, {
79
- components,
80
- content: children
81
- }));
82
- }
83
- return /* @__PURE__ */ React__default["default"].createElement("a", {
84
- key,
85
- href: child.url
86
- }, /* @__PURE__ */ React__default["default"].createElement(TinaMarkdown, {
87
- components,
88
- content: children
89
- }));
90
- case "code_block":
91
- const value = child.children.map((item) => {
92
- var _a;
93
- return item.children ? ((_a = item.children[0]) == null ? void 0 : _a.text) || "" : "";
94
- }).join("\n");
95
- if (components[child.type]) {
96
- const Component2 = components[child.type];
97
- return /* @__PURE__ */ React__default["default"].createElement(Component2, {
98
- key,
99
- ...props
100
- }, value);
101
- }
102
- return /* @__PURE__ */ React__default["default"].createElement("pre", {
103
- key
104
- }, /* @__PURE__ */ React__default["default"].createElement("code", null, value));
105
- case "hr":
106
- if (components[child.type]) {
107
- const Component2 = components[child.type];
108
- return /* @__PURE__ */ React__default["default"].createElement(Component2, {
109
- key,
110
- ...props
111
- });
112
- }
113
- return /* @__PURE__ */ React__default["default"].createElement("hr", {
114
- key
115
- });
116
- case "break":
117
- if (components[child.type]) {
118
- const Component2 = components[child.type];
119
- return /* @__PURE__ */ React__default["default"].createElement(Component2, {
120
- key,
121
- ...props
122
- });
123
- }
124
- return /* @__PURE__ */ React__default["default"].createElement("br", {
125
- key
126
- });
127
- case "text":
128
- return /* @__PURE__ */ React__default["default"].createElement(Leaf, {
129
- key,
130
- components,
131
- ...child
132
- });
133
- case "mdxJsxTextElement":
134
- case "mdxJsxFlowElement":
135
- const Component = components[child.name];
136
- if (Component) {
137
- const props2 = child.props ? child.props : {};
138
- return /* @__PURE__ */ React__default["default"].createElement(Component, {
139
- key,
140
- ...props2
141
- });
142
- } else {
143
- const ComponentMissing = components["component_missing"];
144
- if (ComponentMissing) {
145
- return /* @__PURE__ */ React__default["default"].createElement(ComponentMissing, {
146
- key,
147
- name: child.name
148
- });
149
- } else {
150
- throw new Error(`No component provided for ${child.name}`);
151
- }
152
- }
153
- case "maybe_mdx":
154
- return null;
155
- default:
156
- if (typeof child.text === "string") {
157
- return /* @__PURE__ */ React__default["default"].createElement(Leaf, {
158
- key,
159
- components,
160
- ...child
161
- });
162
- }
163
- console.log(`No tina renderer for ${child.type}`, child);
164
- }
21
+ return /* @__PURE__ */ React__default["default"].createElement(MemoNode, {
22
+ components,
23
+ key: index,
24
+ child
25
+ });
165
26
  }));
166
27
  };
167
28
  const Leaf = (props) => {
@@ -227,6 +88,143 @@
227
88
  }
228
89
  return /* @__PURE__ */ React__default["default"].createElement(React__default["default"].Fragment, null, props.text);
229
90
  };
91
+ const MemoNode = (props) => {
92
+ const MNode = React__default["default"].useMemo(() => /* @__PURE__ */ React__default["default"].createElement(Node, {
93
+ ...props
94
+ }), [JSON.stringify(props)]);
95
+ return MNode;
96
+ };
97
+ const Node = ({ components, child }) => {
98
+ const { children, ...props } = child;
99
+ switch (child.type) {
100
+ case "h1":
101
+ case "h2":
102
+ case "h3":
103
+ case "h4":
104
+ case "h5":
105
+ case "h6":
106
+ case "p":
107
+ case "blockquote":
108
+ case "ol":
109
+ case "ul":
110
+ case "li":
111
+ if (components[child.type]) {
112
+ const Component2 = components[child.type];
113
+ return /* @__PURE__ */ React__default["default"].createElement(Component2, {
114
+ ...props
115
+ }, /* @__PURE__ */ React__default["default"].createElement(TinaMarkdown, {
116
+ components,
117
+ content: children
118
+ }));
119
+ }
120
+ return React__default["default"].createElement(child.type, {
121
+ children: /* @__PURE__ */ React__default["default"].createElement(TinaMarkdown, {
122
+ components,
123
+ content: children
124
+ })
125
+ });
126
+ case "lic":
127
+ return /* @__PURE__ */ React__default["default"].createElement("div", null, /* @__PURE__ */ React__default["default"].createElement(TinaMarkdown, {
128
+ components,
129
+ content: child.children
130
+ }));
131
+ case "img":
132
+ if (components[child.type]) {
133
+ const Component2 = components[child.type];
134
+ return /* @__PURE__ */ React__default["default"].createElement(Component2, {
135
+ ...props
136
+ });
137
+ }
138
+ return /* @__PURE__ */ React__default["default"].createElement("img", {
139
+ src: child.url,
140
+ alt: child.caption
141
+ });
142
+ case "a":
143
+ if (components[child.type]) {
144
+ const Component2 = components[child.type];
145
+ return /* @__PURE__ */ React__default["default"].createElement(Component2, {
146
+ ...props
147
+ }, /* @__PURE__ */ React__default["default"].createElement(TinaMarkdown, {
148
+ components,
149
+ content: children
150
+ }));
151
+ }
152
+ return /* @__PURE__ */ React__default["default"].createElement("a", {
153
+ href: child.url
154
+ }, /* @__PURE__ */ React__default["default"].createElement(TinaMarkdown, {
155
+ components,
156
+ content: children
157
+ }));
158
+ case "code_block":
159
+ const value = child.value;
160
+ if (components[child.type]) {
161
+ const Component2 = components[child.type];
162
+ return /* @__PURE__ */ React__default["default"].createElement(Component2, {
163
+ ...props
164
+ }, value);
165
+ }
166
+ return /* @__PURE__ */ React__default["default"].createElement("pre", null, /* @__PURE__ */ React__default["default"].createElement("code", null, value));
167
+ case "hr":
168
+ if (components[child.type]) {
169
+ const Component2 = components[child.type];
170
+ return /* @__PURE__ */ React__default["default"].createElement(Component2, {
171
+ ...props
172
+ });
173
+ }
174
+ return /* @__PURE__ */ React__default["default"].createElement("hr", null);
175
+ case "break":
176
+ if (components[child.type]) {
177
+ const Component2 = components[child.type];
178
+ return /* @__PURE__ */ React__default["default"].createElement(Component2, {
179
+ ...props
180
+ });
181
+ }
182
+ return /* @__PURE__ */ React__default["default"].createElement("br", null);
183
+ case "text":
184
+ return /* @__PURE__ */ React__default["default"].createElement(Leaf, {
185
+ components,
186
+ ...child
187
+ });
188
+ case "mdxJsxTextElement":
189
+ case "mdxJsxFlowElement":
190
+ const Component = components[child.name];
191
+ if (Component) {
192
+ const props2 = child.props ? child.props : {};
193
+ return /* @__PURE__ */ React__default["default"].createElement(Component, {
194
+ ...props2
195
+ });
196
+ } else {
197
+ const ComponentMissing = components["component_missing"];
198
+ if (ComponentMissing) {
199
+ return /* @__PURE__ */ React__default["default"].createElement(ComponentMissing, {
200
+ name: child.name
201
+ });
202
+ } else {
203
+ return /* @__PURE__ */ React__default["default"].createElement("span", null, `No component provided for ${child.name}`);
204
+ }
205
+ }
206
+ case "maybe_mdx":
207
+ return null;
208
+ case "html":
209
+ case "html_inline":
210
+ if (components[child.type]) {
211
+ const Component2 = components[child.type];
212
+ return /* @__PURE__ */ React__default["default"].createElement(Component2, {
213
+ ...props
214
+ });
215
+ }
216
+ return child.value;
217
+ case "invalid_markdown":
218
+ return /* @__PURE__ */ React__default["default"].createElement("pre", null, child.value);
219
+ default:
220
+ if (typeof child.text === "string") {
221
+ return /* @__PURE__ */ React__default["default"].createElement(Leaf, {
222
+ components,
223
+ ...child
224
+ });
225
+ }
226
+ }
227
+ };
230
228
  exports2.TinaMarkdown = TinaMarkdown;
231
229
  Object.defineProperties(exports2, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
232
230
  });
@@ -10,107 +10,8 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10
10
  See the License for the specific language governing permissions and
11
11
  limitations under the License.
12
12
  */
13
- import React from 'react';
14
- import type { TinaClient } from './client';
15
- import { TinaCloudMediaStoreClass } from './auth';
16
- import type { TinaCMS } from '@tinacms/toolkit';
17
- import type { TinaCloudSchema } from '@tinacms/schema-tools';
18
- import type { TinaIOConfig } from './internalClient/index';
19
13
  import type { formifyCallback } from './hooks/use-graphql-forms';
20
- import { useDocumentCreatorPlugin } from './hooks/use-content-creator';
21
- declare type APIProviderProps = {
22
- /**
23
- * The API url From this client will be used to make requests.
24
- *
25
- */
26
- client?: never;
27
- /**
28
- * Content API URL
29
- *
30
- */
31
- apiURL: string;
32
- /**
33
- * Point to the local version of GraphQL instead of tina.io
34
- * https://tina.io/docs/tinacms-context/#adding-tina-to-the-sites-frontend
35
- *
36
- * @deprecated use apiURL instead
37
- */
38
- isLocalClient?: never;
39
- /**
40
- * The base branch to pull content from. Note that this is ignored for local development
41
- *
42
- * @deprecated use apiURL instead
43
- */
44
- branch?: never;
45
- /**
46
- * Your clientId from tina.io
47
- *
48
- * @deprecated use apiURL instead
49
- */
50
- clientId?: never;
51
- } | {
52
- /**
53
- * The API url From this client will be used to make requests.
54
- *
55
- */
56
- client: TinaClient<unknown>;
57
- /**
58
- * Content API URL
59
- *
60
- */
61
- apiURL?: never;
62
- /**
63
- * Point to the local version of GraphQL instead of tina.io
64
- * https://tina.io/docs/tinacms-context/#adding-tina-to-the-sites-frontend
65
- *
66
- * @deprecated use apiURL instead
67
- */
68
- isLocalClient?: never;
69
- /**
70
- * The base branch to pull content from. Note that this is ignored for local development
71
- *
72
- * @deprecated use apiURL instead
73
- */
74
- branch?: never;
75
- /**
76
- * Your clientId from tina.io
77
- *
78
- * @deprecated use apiURL instead
79
- */
80
- clientId?: never;
81
- };
82
- interface BaseProviderProps {
83
- /** Callback if you need access to the TinaCMS instance */
84
- cmsCallback?: (cms: TinaCMS) => TinaCMS;
85
- /** Callback if you need access to the "formify" API */
86
- formifyCallback?: formifyCallback;
87
- /** Callback if you need access to the "document creator" API */
88
- documentCreatorCallback?: Parameters<typeof useDocumentCreatorPlugin>[0];
89
- /** TinaCMS media store instance */
90
- mediaStore?: TinaCloudMediaStoreClass | (() => Promise<TinaCloudMediaStoreClass>);
91
- tinaioConfig?: TinaIOConfig;
92
- schema?: TinaCloudSchema<false>;
93
- }
94
- declare type QueryProviderProps = {
95
- /** Your React page component */
96
- children: (props?: any) => React.ReactNode;
97
- /** The query from getStaticProps */
98
- query: string | undefined;
99
- /** Any variables from getStaticProps */
100
- variables: object | undefined;
101
- /** The `data` from getStaticProps */
102
- data: object;
103
- } | {
104
- /** Your React page component */
105
- children: React.ReactNode;
106
- /** The query from getStaticProps */
107
- query?: never;
108
- /** Any variables from getStaticProps */
109
- variables?: never;
110
- /** The `data` from getStaticProps */
111
- data?: never;
112
- };
113
- export declare type TinaCMSProviderDefaultProps = QueryProviderProps & APIProviderProps & BaseProviderProps;
14
+ import { TinaCMSProviderDefaultProps } from './types/cms';
114
15
  export declare const TinaCMSProvider2: ({ query, documentCreatorCallback, formifyCallback, schema, ...props }: TinaCMSProviderDefaultProps) => JSX.Element;
115
16
  export declare const TinaDataProvider: ({ children, formifyCallback, }: {
116
17
  children: any;
@@ -144,4 +45,3 @@ export declare const staticRequest: ({ query, variables, }: {
144
45
  * query or muation
145
46
  */
146
47
  export declare function gql(strings: TemplateStringsArray, ...args: string[]): string;
147
- export {};
@@ -0,0 +1,64 @@
1
+ /**
2
+ Copyright 2021 Forestry.io Holdings, Inc.
3
+ Licensed under the Apache License, Version 2.0 (the "License");
4
+ you may not use this file except in compliance with the License.
5
+ You may obtain a copy of the License at
6
+ http://www.apache.org/licenses/LICENSE-2.0
7
+ Unless required by applicable law or agreed to in writing, software
8
+ distributed under the License is distributed on an "AS IS" BASIS,
9
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10
+ See the License for the specific language governing permissions and
11
+ limitations under the License.
12
+ */
13
+ /// <reference types="react" />
14
+ import type { TinaCMS } from '@tinacms/toolkit';
15
+ import type { TinaCloudSchema, TinaCloudSchemaConfig } from '@tinacms/schema-tools';
16
+ import type { TinaCloudMediaStoreClass } from '../auth';
17
+ import type { useDocumentCreatorPlugin } from '../hooks/use-content-creator';
18
+ import type { formifyCallback } from '../hooks/use-graphql-forms';
19
+ import type { TinaIOConfig } from '../internalClient';
20
+ import type { TinaClient } from '../client';
21
+ declare type APIProviderProps = {
22
+ /**
23
+ * @deprecated Please see https://tina.io/blog/tina-v-0.68.14 for information on how to upgrade to the new API
24
+ *
25
+ */
26
+ apiURL?: string;
27
+ /**
28
+ * The API url From this client will be used to make requests.
29
+ */
30
+ client: TinaClient<unknown>;
31
+ };
32
+ interface BaseProviderProps {
33
+ /** Callback if you need access to the TinaCMS instance */
34
+ cmsCallback?: (cms: TinaCMS) => TinaCMS;
35
+ /** Callback if you need access to the "formify" API */
36
+ formifyCallback?: formifyCallback;
37
+ /** Callback if you need access to the "document creator" API */
38
+ documentCreatorCallback?: Parameters<typeof useDocumentCreatorPlugin>[0];
39
+ /** TinaCMS media store instance */
40
+ mediaStore?: TinaCloudMediaStoreClass | (() => Promise<TinaCloudMediaStoreClass>);
41
+ tinaioConfig?: TinaIOConfig;
42
+ schema?: TinaCloudSchema<false>;
43
+ }
44
+ declare type QueryProviderProps = {
45
+ /** Your React page component */
46
+ children: (props?: any) => React.ReactNode;
47
+ /** The query from getStaticProps */
48
+ query: string | undefined;
49
+ /** Any variables from getStaticProps */
50
+ variables: object | undefined;
51
+ /** The `data` from getStaticProps */
52
+ data: object;
53
+ } | {
54
+ /** Your React page component */
55
+ children: React.ReactNode;
56
+ /** The query from getStaticProps */
57
+ query?: never;
58
+ /** Any variables from getStaticProps */
59
+ variables?: never;
60
+ /** The `data` from getStaticProps */
61
+ data?: never;
62
+ };
63
+ export declare type TinaCMSProviderDefaultProps = QueryProviderProps & APIProviderProps & BaseProviderProps & TinaCloudSchemaConfig;
64
+ export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tinacms",
3
- "version": "0.68.15",
3
+ "version": "0.69.2",
4
4
  "main": "dist/index.js",
5
5
  "module": "./dist/index.es.js",
6
6
  "exports": {
@@ -20,9 +20,14 @@
20
20
  "require": "./dist/edit-state.js"
21
21
  },
22
22
  "./dist/rich-text": {
23
- "types": "./dist/rich-text.d.ts",
24
- "import": "./dist/rich-text.es.js",
25
- "require": "./dist/rich-text.js"
23
+ "types": "./dist/rich-text/index.d.ts",
24
+ "import": "./dist/rich-text/index.es.js",
25
+ "require": "./dist/rich-text/index.js"
26
+ },
27
+ "./dist/rich-text/prism": {
28
+ "types": "./dist/rich-text/prism.d.ts",
29
+ "import": "./dist/rich-text/prism.es.js",
30
+ "require": "./dist/rich-text/prism.js"
26
31
  }
27
32
  },
28
33
  "files": [
@@ -32,7 +37,7 @@
32
37
  "entryPoints": [
33
38
  "src/index.ts",
34
39
  "src/edit-state.tsx",
35
- "src/rich-text.tsx",
40
+ "src/rich-text/index.tsx",
36
41
  "src/client.ts"
37
42
  ]
38
43
  },
@@ -43,15 +48,17 @@
43
48
  "@headlessui/react": "^1.5.0",
44
49
  "@heroicons/react": "^1.0.4",
45
50
  "@react-hook/window-size": "^3.0.7",
46
- "@tinacms/schema-tools": "0.0.9",
51
+ "@tinacms/schema-tools": "0.1.0",
47
52
  "@tinacms/sharedctx": "0.1.2",
48
- "@tinacms/toolkit": "0.56.37",
53
+ "@tinacms/toolkit": "0.57.1",
49
54
  "crypto-js": "^4.0.0",
50
55
  "fetch-ponyfill": "^7.1.0",
51
56
  "final-form": "4.20.1",
52
57
  "graphql": "^15.1.0",
53
58
  "graphql-tag": "^2.11.0",
54
59
  "lodash.set": "^4.3.2",
60
+ "prism-react-renderer": "^1.3.5",
61
+ "prism": "^4.1.2",
55
62
  "react-icons": "^4.3.1",
56
63
  "react-router-dom": "6",
57
64
  "url-pattern": "^1.0.3",
@@ -63,7 +70,7 @@
63
70
  "@testing-library/react": "^12.0.0",
64
71
  "@testing-library/react-hooks": "^7.0.2",
65
72
  "@testing-library/user-event": "^12.7.0",
66
- "@tinacms/scripts": "0.50.9",
73
+ "@tinacms/scripts": "0.51.1",
67
74
  "@types/jest": "^27.0.1",
68
75
  "@types/lodash": "^4.14.169",
69
76
  "@types/node": "^14.0.13",
@@ -73,7 +80,7 @@
73
80
  "isomorphic-fetch": "^3.0.0",
74
81
  "jest": "^27.0.6",
75
82
  "jest-file-snapshot": "^0.5.0",
76
- "next": "9.4.2",
83
+ "next": "12.2.4",
77
84
  "react": "17.0.2",
78
85
  "react-dom": "17.0.2",
79
86
  "react-is": "^17.0.2",
@@ -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 };