tinacms 0.0.0-b012b6c-20250808011625 → 0.0.0-b0f55b5-20251228232811

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.
Files changed (90) hide show
  1. package/dist/admin/api.d.ts +1 -1
  2. package/dist/auth/AuthModal.d.ts +1 -4
  3. package/dist/auth/TinaCloudProvider.d.ts +0 -1
  4. package/dist/cache/node-cache.d.ts +6 -2
  5. package/dist/client.js +240 -181
  6. package/dist/index.js +118272 -117469
  7. package/dist/internalClient/index.d.ts +1 -1
  8. package/dist/react.js +297 -206
  9. package/dist/rich-text/index.d.ts +6 -0
  10. package/dist/rich-text/index.js +234 -230
  11. package/dist/rich-text/prism.js +16 -18
  12. package/dist/rich-text/static.d.ts +6 -0
  13. package/dist/rich-text/static.js +229 -225
  14. package/dist/tina-cms.d.ts +1 -1
  15. package/dist/toolkit/components/active-field-indicator.d.ts +1 -0
  16. package/dist/toolkit/components/ui/button.d.ts +11 -0
  17. package/dist/toolkit/components/ui/calendar.d.ts +8 -0
  18. package/dist/toolkit/components/ui/date-time-picker.d.ts +111 -0
  19. package/dist/toolkit/components/ui/input.d.ts +3 -0
  20. package/dist/toolkit/components/ui/popover.d.ts +7 -0
  21. package/dist/toolkit/components/ui/select.d.ts +13 -0
  22. package/dist/toolkit/fields/components/color-picker/block-widget.d.ts +3 -0
  23. package/dist/toolkit/fields/components/color-picker/color-input.d.ts +35 -0
  24. package/dist/toolkit/fields/components/color-picker/color-picker.d.ts +6 -2
  25. package/dist/toolkit/fields/components/color-picker/color-utils.d.ts +37 -0
  26. package/dist/toolkit/fields/components/color-picker/sketch-widget.d.ts +3 -0
  27. package/dist/toolkit/fields/components/password-field.d.ts +1 -1
  28. package/dist/toolkit/fields/components/select.d.ts +1 -1
  29. package/dist/toolkit/fields/components/text-field.d.ts +1 -1
  30. package/dist/toolkit/fields/plugins/button-toggle-field-plugin.d.ts +2 -2
  31. package/dist/toolkit/fields/plugins/checkbox-group-field-plugin.d.ts +2 -2
  32. package/dist/toolkit/fields/plugins/color-field-plugin.d.ts +1 -0
  33. package/dist/toolkit/fields/plugins/date-field-plugin.d.ts +0 -2
  34. package/dist/toolkit/fields/plugins/dnd-kit-wrapper.d.ts +49 -0
  35. package/dist/toolkit/fields/plugins/group-list-field-plugin.d.ts +2 -1
  36. package/dist/toolkit/fields/plugins/list-field-plugin.d.ts +2 -0
  37. package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/components/editor.d.ts +2 -2
  38. package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/components/plate-ui/blockquote-element.d.ts +1 -1
  39. package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/components/plate-ui/button.d.ts +2 -2
  40. package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/components/plate-ui/code-block/code-block-element.d.ts +1 -1
  41. package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/components/plate-ui/code-line-element.d.ts +1 -1
  42. package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/components/plate-ui/command.d.ts +7 -7
  43. package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/components/plate-ui/list-element.d.ts +2 -2
  44. package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/components/plate-ui/paragraph-element.d.ts +1 -1
  45. package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/components/plate-ui/slash-input-element.d.ts +1 -1
  46. package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/components/plate-ui/table/table-cell-element.d.ts +2 -2
  47. package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/components/plate-ui/table/table-element.d.ts +1 -1
  48. package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/components/plate-ui/table/table-row-element.d.ts +1 -1
  49. package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/components/plate-ui/use-floating-toolbar-hook.d.ts +1 -1
  50. package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/plugins/ui/components.d.ts +18 -18
  51. package/dist/toolkit/fields/plugins/radio-group-field-plugin.d.ts +2 -2
  52. package/dist/toolkit/fields/plugins/select-field-plugin.d.ts +2 -2
  53. package/dist/toolkit/fields/plugins/toggle-field-plugin.d.ts +2 -2
  54. package/dist/toolkit/fields/plugins/wrap-field-with-meta.d.ts +6 -2
  55. package/dist/toolkit/form-builder/create-branch-modal.d.ts +13 -0
  56. package/dist/toolkit/form-builder/fields-builder.d.ts +2 -1
  57. package/dist/toolkit/form-builder/form-builder.d.ts +1 -11
  58. package/dist/toolkit/form-builder/index.d.ts +1 -0
  59. package/dist/toolkit/forms/field.d.ts +3 -2
  60. package/dist/toolkit/icons/TinaExtended.d.ts +4 -0
  61. package/dist/toolkit/icons/index.d.ts +1 -0
  62. package/dist/toolkit/index.d.ts +1 -1
  63. package/dist/toolkit/plugin-branch-switcher/branch-button.d.ts +3 -1
  64. package/dist/toolkit/react-modals/modal/modal-actions.d.ts +2 -1
  65. package/dist/toolkit/react-modals/modal/modal-header.d.ts +1 -1
  66. package/dist/toolkit/react-sidebar/components/NavMenuTrigger.d.ts +11 -0
  67. package/dist/toolkit/react-sidebar/components/badge.d.ts +6 -0
  68. package/dist/toolkit/react-sidebar/components/callout.d.ts +5 -0
  69. package/dist/toolkit/react-sidebar/components/local-warning.d.ts +3 -1
  70. package/dist/toolkit/react-sidebar/components/nav-components.d.ts +11 -0
  71. package/dist/toolkit/react-sidebar/components/nav-context.d.ts +15 -0
  72. package/dist/toolkit/react-sidebar/components/nav.d.ts +3 -3
  73. package/dist/toolkit/react-sidebar/components/sidebar-body.d.ts +26 -1
  74. package/dist/toolkit/react-sidebar/index.d.ts +3 -0
  75. package/dist/toolkit/styles/dropdown-button.d.ts +75 -0
  76. package/dist/toolkit/styles/index.d.ts +1 -0
  77. package/dist/toolkit/tina-state.d.ts +42 -16
  78. package/dist/unifiedClient/index.d.ts +1 -1
  79. package/dist/utils/index.d.ts +1 -0
  80. package/package.json +34 -71
  81. package/dist/client.mjs +0 -132
  82. package/dist/index.mjs +0 -122706
  83. package/dist/node-cache-5e8db9f0.mjs +0 -63
  84. package/dist/react.mjs +0 -254
  85. package/dist/rich-text/index.mjs +0 -249
  86. package/dist/rich-text/prism.mjs +0 -16
  87. package/dist/rich-text/static.mjs +0 -236
  88. package/dist/toolkit/react-datetime/DateTime.d.ts +0 -135
  89. package/dist/toolkit/react-sidebar/components/alert.d.ts +0 -5
  90. /package/dist/admin/components/{Sidebar.d.ts → AdminNav.d.ts} +0 -0
@@ -1,63 +0,0 @@
1
- const makeCacheDir = async (dir, fs, path, os) => {
2
- const pathParts = dir.split(path.sep).filter(Boolean);
3
- const cacheHash = pathParts[pathParts.length - 1];
4
- const rootUser = pathParts[0];
5
- let cacheDir = dir;
6
- if (!fs.existsSync(path.join(path.sep, rootUser))) {
7
- cacheDir = path.join(os.tmpdir(), cacheHash);
8
- }
9
- try {
10
- fs.mkdirSync(cacheDir, { recursive: true });
11
- } catch (error) {
12
- throw new Error(`Failed to create cache directory: ${error.message}`);
13
- }
14
- return cacheDir;
15
- };
16
- const NodeCache = async (dir) => {
17
- const fs = require("node:fs");
18
- const path = require("node:path");
19
- const os = require("node:os");
20
- const { createHash } = require("node:crypto");
21
- const cacheDir = await makeCacheDir(dir, fs, path, os);
22
- return {
23
- makeKey: (key) => {
24
- const input = key && key instanceof Object ? JSON.stringify(key) : key || "";
25
- return createHash("sha256").update(input).digest("hex");
26
- },
27
- get: async (key) => {
28
- let readValue;
29
- const cacheFilename = `${cacheDir}/${key}`;
30
- try {
31
- const data = await fs.promises.readFile(cacheFilename, "utf-8");
32
- readValue = JSON.parse(data);
33
- } catch (e) {
34
- if (e.code !== "ENOENT") {
35
- console.error(
36
- `Failed to read cache file to ${cacheFilename}: ${e.message}`
37
- );
38
- }
39
- }
40
- return readValue;
41
- },
42
- set: async (key, value) => {
43
- const cacheFilename = `${cacheDir}/${key}`;
44
- try {
45
- await fs.promises.writeFile(cacheFilename, JSON.stringify(value), {
46
- encoding: "utf-8",
47
- flag: "wx"
48
- // Don't overwrite existing caches
49
- });
50
- } catch (e) {
51
- if (e.code !== "EEXIST") {
52
- console.error(
53
- `Failed to write cache file to ${cacheFilename}: ${e.message}`
54
- );
55
- }
56
- }
57
- }
58
- };
59
- };
60
- export {
61
- NodeCache,
62
- makeCacheDir
63
- };
package/dist/react.mjs DELETED
@@ -1,254 +0,0 @@
1
- import React from "react";
2
- function useTina(props) {
3
- const stringifiedQuery = JSON.stringify({
4
- query: props.query,
5
- variables: props.variables
6
- });
7
- const id = React.useMemo(
8
- () => hashFromQuery(stringifiedQuery),
9
- [stringifiedQuery]
10
- );
11
- const processedData = React.useMemo(() => {
12
- if (props.data) {
13
- const dataCopy = JSON.parse(JSON.stringify(props.data));
14
- return addMetadata(id, dataCopy, []);
15
- }
16
- }, [props.data, id]);
17
- const [data, setData] = React.useState(processedData);
18
- const [isClient, setIsClient] = React.useState(false);
19
- const [quickEditEnabled, setQuickEditEnabled] = React.useState(false);
20
- const [isInTinaIframe, setIsInTinaIframe] = React.useState(false);
21
- React.useEffect(() => {
22
- setIsClient(true);
23
- setData(processedData);
24
- parent.postMessage({
25
- type: "url-changed"
26
- });
27
- }, [id, processedData]);
28
- React.useEffect(() => {
29
- if (quickEditEnabled) {
30
- let mouseDownHandler = function(e) {
31
- const attributeNames = e.target.getAttributeNames();
32
- const tinaAttribute = attributeNames.find(
33
- (name) => name.startsWith("data-tina-field")
34
- );
35
- let fieldName;
36
- if (tinaAttribute) {
37
- e.preventDefault();
38
- e.stopPropagation();
39
- fieldName = e.target.getAttribute(tinaAttribute);
40
- } else {
41
- const ancestor = e.target.closest(
42
- "[data-tina-field], [data-tina-field-overlay]"
43
- );
44
- if (ancestor) {
45
- const attributeNames2 = ancestor.getAttributeNames();
46
- const tinaAttribute2 = attributeNames2.find(
47
- (name) => name.startsWith("data-tina-field")
48
- );
49
- if (tinaAttribute2) {
50
- e.preventDefault();
51
- e.stopPropagation();
52
- fieldName = ancestor.getAttribute(tinaAttribute2);
53
- }
54
- }
55
- }
56
- if (fieldName) {
57
- if (isInTinaIframe) {
58
- parent.postMessage(
59
- { type: "field:selected", fieldName },
60
- window.location.origin
61
- );
62
- }
63
- }
64
- };
65
- const style = document.createElement("style");
66
- style.type = "text/css";
67
- style.textContent = `
68
- [data-tina-field] {
69
- outline: 2px dashed rgba(34,150,254,0.5);
70
- transition: box-shadow ease-out 150ms;
71
- }
72
- [data-tina-field]:hover {
73
- box-shadow: inset 100vi 100vh rgba(34,150,254,0.3);
74
- outline: 2px solid rgba(34,150,254,1);
75
- cursor: pointer;
76
- }
77
- [data-tina-field-overlay] {
78
- outline: 2px dashed rgba(34,150,254,0.5);
79
- position: relative;
80
- }
81
- [data-tina-field-overlay]:hover {
82
- cursor: pointer;
83
- outline: 2px solid rgba(34,150,254,1);
84
- }
85
- [data-tina-field-overlay]::after {
86
- content: '';
87
- position: absolute;
88
- inset: 0;
89
- z-index: 20;
90
- transition: opacity ease-out 150ms;
91
- background-color: rgba(34,150,254,0.3);
92
- opacity: 0;
93
- }
94
- [data-tina-field-overlay]:hover::after {
95
- opacity: 1;
96
- }
97
- `;
98
- document.head.appendChild(style);
99
- document.body.classList.add("__tina-quick-editing-enabled");
100
- document.addEventListener("click", mouseDownHandler, true);
101
- return () => {
102
- document.removeEventListener("click", mouseDownHandler, true);
103
- document.body.classList.remove("__tina-quick-editing-enabled");
104
- style.remove();
105
- };
106
- }
107
- }, [quickEditEnabled, isInTinaIframe]);
108
- React.useEffect(() => {
109
- if (props == null ? void 0 : props.experimental___selectFormByFormId) {
110
- parent.postMessage({
111
- type: "user-select-form",
112
- formId: props.experimental___selectFormByFormId()
113
- });
114
- }
115
- }, [id]);
116
- React.useEffect(() => {
117
- const { experimental___selectFormByFormId, ...rest } = props;
118
- parent.postMessage({ type: "open", ...rest, id }, window.location.origin);
119
- const handleMessage = (event) => {
120
- if (event.data.type === "quickEditEnabled") {
121
- setQuickEditEnabled(event.data.value);
122
- }
123
- if (event.data.id === id && event.data.type === "updateData") {
124
- const rawData = event.data.data;
125
- const newlyProcessedData = addMetadata(
126
- id,
127
- JSON.parse(JSON.stringify(rawData)),
128
- []
129
- );
130
- setData(newlyProcessedData);
131
- setIsInTinaIframe(true);
132
- const anyTinaField = document.querySelector("[data-tina-field]");
133
- if (anyTinaField) {
134
- parent.postMessage(
135
- { type: "quick-edit", value: true },
136
- window.location.origin
137
- );
138
- } else {
139
- parent.postMessage(
140
- { type: "quick-edit", value: false },
141
- window.location.origin
142
- );
143
- }
144
- }
145
- };
146
- window.addEventListener("message", handleMessage);
147
- return () => {
148
- window.removeEventListener("message", handleMessage);
149
- parent.postMessage({ type: "close", id }, window.location.origin);
150
- };
151
- }, [id, setQuickEditEnabled]);
152
- return { data, isClient };
153
- }
154
- function useEditState() {
155
- const [edit, setEdit] = React.useState(false);
156
- React.useEffect(() => {
157
- if (typeof window !== "undefined") {
158
- parent.postMessage({ type: "isEditMode" }, window.location.origin);
159
- window.addEventListener("message", (event) => {
160
- var _a;
161
- if (((_a = event.data) == null ? void 0 : _a.type) === "tina:editMode") {
162
- setEdit(true);
163
- }
164
- });
165
- }
166
- }, []);
167
- return { edit };
168
- }
169
- const tinaField = (object, property, index) => {
170
- const contentSource = object == null ? void 0 : object._content_source;
171
- if (!contentSource) {
172
- return "";
173
- }
174
- const { queryId, path } = contentSource;
175
- if (!property) {
176
- return `${queryId}---${path.join(".")}`;
177
- }
178
- const fullPath = typeof index === "number" ? [...path, property, index] : [...path, property];
179
- return `${queryId}---${fullPath.join(".")}`;
180
- };
181
- const addMetadata = (id, obj, path = []) => {
182
- if (obj === null) {
183
- return obj;
184
- }
185
- if (isScalarOrUndefined(obj)) {
186
- return obj;
187
- }
188
- if (obj instanceof String) {
189
- return obj.valueOf();
190
- }
191
- if (Array.isArray(obj)) {
192
- return obj.map(
193
- (item, index) => addMetadata(id, item, [...path, index])
194
- );
195
- }
196
- const transformedObj = {};
197
- for (const [key, value] of Object.entries(obj)) {
198
- const currentPath = [...path, key];
199
- if ([
200
- "__typename",
201
- "_sys",
202
- "_internalSys",
203
- "_values",
204
- "_internalValues",
205
- "_content_source",
206
- "_tina_metadata"
207
- ].includes(key)) {
208
- transformedObj[key] = value;
209
- } else {
210
- transformedObj[key] = addMetadata(id, value, currentPath);
211
- }
212
- }
213
- if (transformedObj && typeof transformedObj === "object" && "type" in transformedObj && transformedObj.type === "root") {
214
- return transformedObj;
215
- }
216
- return { ...transformedObj, _content_source: { queryId: id, path } };
217
- };
218
- function isScalarOrUndefined(value) {
219
- const type = typeof value;
220
- if (type === "string")
221
- return true;
222
- if (type === "number")
223
- return true;
224
- if (type === "boolean")
225
- return true;
226
- if (type === "undefined")
227
- return true;
228
- if (value == null)
229
- return true;
230
- if (value instanceof String)
231
- return true;
232
- if (value instanceof Number)
233
- return true;
234
- if (value instanceof Boolean)
235
- return true;
236
- return false;
237
- }
238
- const hashFromQuery = (input) => {
239
- let hash = 0;
240
- for (let i = 0; i < input.length; i++) {
241
- const char = input.charCodeAt(i);
242
- hash = (hash << 5) - hash + char & 4294967295;
243
- }
244
- const nonNegativeHash = Math.abs(hash);
245
- const alphanumericHash = nonNegativeHash.toString(36);
246
- return alphanumericHash;
247
- };
248
- export {
249
- addMetadata,
250
- hashFromQuery,
251
- tinaField,
252
- useEditState,
253
- useTina
254
- };
@@ -1,249 +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
- return /* @__PURE__ */ React.createElement(MemoNode, { components, key: index, child });
15
- }));
16
- };
17
- const Leaf = (props) => {
18
- if (props.bold) {
19
- const { bold, ...rest } = props;
20
- if (props.components.bold) {
21
- const Component = props.components.bold;
22
- return /* @__PURE__ */ React.createElement(Component, null, /* @__PURE__ */ React.createElement(Leaf, { ...rest }));
23
- }
24
- return /* @__PURE__ */ React.createElement("strong", null, /* @__PURE__ */ React.createElement(Leaf, { ...rest }));
25
- }
26
- if (props.italic) {
27
- const { italic, ...rest } = props;
28
- if (props.components.italic) {
29
- const Component = props.components.italic;
30
- return /* @__PURE__ */ React.createElement(Component, null, /* @__PURE__ */ React.createElement(Leaf, { ...rest }));
31
- }
32
- return /* @__PURE__ */ React.createElement("em", null, /* @__PURE__ */ React.createElement(Leaf, { ...rest }));
33
- }
34
- if (props.underline) {
35
- const { underline, ...rest } = props;
36
- if (props.components.underline) {
37
- const Component = props.components.underline;
38
- return /* @__PURE__ */ React.createElement(Component, null, /* @__PURE__ */ React.createElement(Leaf, { ...rest }));
39
- }
40
- return /* @__PURE__ */ React.createElement("u", null, /* @__PURE__ */ React.createElement(Leaf, { ...rest }));
41
- }
42
- if (props.strikethrough) {
43
- const { strikethrough, ...rest } = props;
44
- if (props.components.strikethrough) {
45
- const Component = props.components.strikethrough;
46
- return /* @__PURE__ */ React.createElement(Component, null, /* @__PURE__ */ React.createElement(Leaf, { ...rest }));
47
- }
48
- return /* @__PURE__ */ React.createElement("s", null, /* @__PURE__ */ React.createElement(Leaf, { ...rest }));
49
- }
50
- if (props.code) {
51
- const { code, ...rest } = props;
52
- if (props.components.code) {
53
- const Component = props.components.code;
54
- return /* @__PURE__ */ React.createElement(Component, null, /* @__PURE__ */ React.createElement(Leaf, { ...rest }));
55
- }
56
- return /* @__PURE__ */ React.createElement("code", null, /* @__PURE__ */ React.createElement(Leaf, { ...rest }));
57
- }
58
- if (props.components.text) {
59
- const Component = props.components.text;
60
- return /* @__PURE__ */ React.createElement(Component, null, props.text);
61
- }
62
- return /* @__PURE__ */ React.createElement(React.Fragment, null, props.text);
63
- };
64
- const MemoNode = (props) => {
65
- const MNode = React.useMemo(
66
- () => /* @__PURE__ */ React.createElement(Node, { ...props }),
67
- [JSON.stringify(props)]
68
- );
69
- return MNode;
70
- };
71
- const Node = ({ components, child }) => {
72
- var _a, _b, _c, _d, _e, _f, _g;
73
- const { children, ...props } = child;
74
- switch (child.type) {
75
- case "h1":
76
- case "h2":
77
- case "h3":
78
- case "h4":
79
- case "h5":
80
- case "h6":
81
- case "p":
82
- case "blockquote":
83
- case "ol":
84
- case "ul":
85
- case "li":
86
- if (components[child.type]) {
87
- const Component2 = components[child.type];
88
- return /* @__PURE__ */ React.createElement(Component2, { ...props }, /* @__PURE__ */ React.createElement(TinaMarkdown, { components, content: children }));
89
- }
90
- return React.createElement(child.type, {
91
- children: /* @__PURE__ */ React.createElement(TinaMarkdown, { components, content: children })
92
- });
93
- case "lic":
94
- if (components.lic) {
95
- const Component2 = components.lic;
96
- return /* @__PURE__ */ React.createElement(Component2, { ...props }, /* @__PURE__ */ React.createElement(TinaMarkdown, { components, content: children }));
97
- }
98
- return /* @__PURE__ */ React.createElement("div", null, /* @__PURE__ */ React.createElement(TinaMarkdown, { components, content: child.children }));
99
- case "img":
100
- if (components[child.type]) {
101
- const Component2 = components[child.type];
102
- return /* @__PURE__ */ React.createElement(Component2, { ...props });
103
- }
104
- return /* @__PURE__ */ React.createElement("img", { src: child.url, alt: child.alt });
105
- case "a":
106
- if (components[child.type]) {
107
- const Component2 = components[child.type];
108
- return (
109
- // @ts-ignore FIXME: TinaMarkdownContent needs to be a union of all possible node types
110
- /* @__PURE__ */ React.createElement(Component2, { ...props }, /* @__PURE__ */ React.createElement(TinaMarkdown, { components, content: children }))
111
- );
112
- }
113
- return (
114
- // @ts-ignore FIXME: TinaMarkdownContent needs to be a union of all possible node types
115
- /* @__PURE__ */ React.createElement("a", { href: child.url }, /* @__PURE__ */ React.createElement(TinaMarkdown, { components, content: children }))
116
- );
117
- case "code_block": {
118
- let codeString = "";
119
- if (Array.isArray(child.children)) {
120
- codeString = child.children.map(
121
- (line) => Array.isArray(line.children) ? line.children.map((t) => t.text).join("") : ""
122
- ).join("\n");
123
- } else if (typeof child.value === "string") {
124
- codeString = child.value;
125
- }
126
- if (components[child.type]) {
127
- const Component2 = components[child.type];
128
- return (
129
- // @ts-ignore FIXME: TinaMarkdownContent needs to be a union of all possible node types
130
- /* @__PURE__ */ React.createElement(Component2, { ...props, value: codeString })
131
- );
132
- }
133
- return /* @__PURE__ */ React.createElement("pre", null, /* @__PURE__ */ React.createElement("code", null, codeString));
134
- }
135
- case "hr":
136
- if (components[child.type]) {
137
- const Component2 = components[child.type];
138
- return /* @__PURE__ */ React.createElement(Component2, { ...props });
139
- }
140
- return /* @__PURE__ */ React.createElement("hr", null);
141
- case "break":
142
- if (components[child.type]) {
143
- const Component2 = components[child.type];
144
- return /* @__PURE__ */ React.createElement(Component2, { ...props });
145
- }
146
- return /* @__PURE__ */ React.createElement("br", null);
147
- case "text":
148
- return /* @__PURE__ */ React.createElement(Leaf, { components, ...child });
149
- case "mdxJsxTextElement":
150
- case "mdxJsxFlowElement":
151
- const Component = components[child.name];
152
- if (Component) {
153
- const props2 = child.props ? child.props : {};
154
- return /* @__PURE__ */ React.createElement(Component, { ...props2 });
155
- } else {
156
- if (child.name === "table") {
157
- const firstRowHeader = (_a = child.props) == null ? void 0 : _a.firstRowHeader;
158
- const rows2 = (firstRowHeader ? (_b = child.props) == null ? void 0 : _b.tableRows.filter((_, i) => i !== 0) : (_c = child.props) == null ? void 0 : _c.tableRows) || [];
159
- const header = (_e = (_d = child.props) == null ? void 0 : _d.tableRows) == null ? void 0 : _e.at(0);
160
- const TableComponent2 = components["table"] || ((props2) => /* @__PURE__ */ React.createElement("table", { ...props2 }));
161
- const TrComponent2 = components["tr"] || ((props2) => /* @__PURE__ */ React.createElement("tr", { ...props2 }));
162
- const ThComponent = components["th"] || ((props2) => /* @__PURE__ */ React.createElement("th", { style: { textAlign: (props2 == null ? void 0 : props2.align) || "auto" }, ...props2 }));
163
- const TdComponent2 = components["td"] || ((props2) => /* @__PURE__ */ React.createElement("td", { style: { textAlign: (props2 == null ? void 0 : props2.align) || "auto" }, ...props2 }));
164
- const align2 = ((_f = child.props) == null ? void 0 : _f.align) || [];
165
- return /* @__PURE__ */ React.createElement(TableComponent2, null, firstRowHeader && /* @__PURE__ */ React.createElement("thead", null, /* @__PURE__ */ React.createElement(TrComponent2, null, header.tableCells.map((c, i) => {
166
- return /* @__PURE__ */ React.createElement(
167
- TinaMarkdown,
168
- {
169
- key: i,
170
- components: {
171
- p: (props2) => /* @__PURE__ */ React.createElement(ThComponent, { align: align2[i], ...props2 })
172
- },
173
- content: c.value
174
- }
175
- );
176
- }))), /* @__PURE__ */ React.createElement("tbody", null, rows2.map((row, i) => {
177
- var _a2;
178
- return /* @__PURE__ */ React.createElement(TrComponent2, { key: i }, (_a2 = row == null ? void 0 : row.tableCells) == null ? void 0 : _a2.map((c, i2) => {
179
- return /* @__PURE__ */ React.createElement(
180
- TinaMarkdown,
181
- {
182
- key: i2,
183
- components: {
184
- p: (props2) => /* @__PURE__ */ React.createElement(TdComponent2, { align: align2[i2], ...props2 })
185
- },
186
- content: c.value
187
- }
188
- );
189
- }));
190
- })));
191
- }
192
- const ComponentMissing = components["component_missing"];
193
- if (ComponentMissing) {
194
- return /* @__PURE__ */ React.createElement(ComponentMissing, { name: child.name });
195
- } else {
196
- return /* @__PURE__ */ React.createElement("span", null, `No component provided for ${child.name}`);
197
- }
198
- }
199
- case "table":
200
- const rows = child.children || [];
201
- const TableComponent = components["table"] || ((props2) => /* @__PURE__ */ React.createElement("table", { style: { border: "1px solid #EDECF3" }, ...props2 }));
202
- const TrComponent = components["tr"] || ((props2) => /* @__PURE__ */ React.createElement("tr", { ...props2 }));
203
- const TdComponent = components["td"] || ((props2) => /* @__PURE__ */ React.createElement(
204
- "td",
205
- {
206
- style: {
207
- textAlign: (props2 == null ? void 0 : props2.align) || "auto",
208
- border: "1px solid #EDECF3",
209
- padding: "0.25rem"
210
- },
211
- ...props2
212
- }
213
- ));
214
- const align = ((_g = child.props) == null ? void 0 : _g.align) || [];
215
- return /* @__PURE__ */ React.createElement(TableComponent, null, /* @__PURE__ */ React.createElement("tbody", null, rows.map((row, i) => {
216
- var _a2;
217
- return /* @__PURE__ */ React.createElement(TrComponent, { key: i }, (_a2 = row.children) == null ? void 0 : _a2.map((cell, i2) => {
218
- return /* @__PURE__ */ React.createElement(
219
- TinaMarkdown,
220
- {
221
- key: i2,
222
- components: {
223
- p: (props2) => /* @__PURE__ */ React.createElement(TdComponent, { align: align[i2], ...props2 })
224
- },
225
- content: cell.children
226
- }
227
- );
228
- }));
229
- })));
230
- case "maybe_mdx":
231
- return null;
232
- case "html":
233
- case "html_inline":
234
- if (components[child.type]) {
235
- const Component2 = components[child.type];
236
- return /* @__PURE__ */ React.createElement(Component2, { ...props });
237
- }
238
- return child.value;
239
- case "invalid_markdown":
240
- return /* @__PURE__ */ React.createElement("pre", null, child.value);
241
- default:
242
- if (typeof child.text === "string") {
243
- return /* @__PURE__ */ React.createElement(Leaf, { components, ...child });
244
- }
245
- }
246
- };
247
- export {
248
- TinaMarkdown
249
- };
@@ -1,16 +0,0 @@
1
- import React from "react";
2
- import { Highlight, themes } from "prism-react-renderer";
3
- const Prism = (props) => {
4
- return /* @__PURE__ */ React.createElement(
5
- Highlight,
6
- {
7
- theme: themes[props.theme || "github"],
8
- code: props.value || "",
9
- language: props.lang || ""
10
- },
11
- ({ className, style, tokens, getLineProps, getTokenProps }) => /* @__PURE__ */ React.createElement("pre", { className, style }, tokens.map((line, i) => /* @__PURE__ */ React.createElement("div", { ...getLineProps({ line, key: i }) }, line.map((token, key) => /* @__PURE__ */ React.createElement("span", { ...getTokenProps({ token, key }) })))))
12
- );
13
- };
14
- export {
15
- Prism
16
- };