tinacms 0.0.0-d94de9b-20250707010010 → 0.0.0-d9ccf29-20251222052725

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 (156) hide show
  1. package/dist/admin/api.d.ts +4 -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 +122235 -34368
  7. package/dist/internalClient/index.d.ts +20 -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 -224
  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/ProgressBar.d.ts +11 -0
  16. package/dist/toolkit/components/active-field-indicator.d.ts +1 -0
  17. package/dist/toolkit/components/media/media-item.d.ts +10 -0
  18. package/dist/toolkit/components/ui/button.d.ts +11 -0
  19. package/dist/toolkit/components/ui/calendar.d.ts +8 -0
  20. package/dist/toolkit/components/ui/date-time-picker.d.ts +111 -0
  21. package/dist/toolkit/components/ui/input.d.ts +3 -0
  22. package/dist/toolkit/components/ui/popover.d.ts +7 -0
  23. package/dist/toolkit/components/ui/select.d.ts +13 -0
  24. package/dist/toolkit/fields/components/color-picker/block-widget.d.ts +3 -0
  25. package/dist/toolkit/fields/components/color-picker/color-input.d.ts +35 -0
  26. package/dist/toolkit/fields/components/color-picker/color-picker.d.ts +6 -2
  27. package/dist/toolkit/fields/components/color-picker/color-utils.d.ts +37 -0
  28. package/dist/toolkit/fields/components/color-picker/sketch-widget.d.ts +3 -0
  29. package/dist/toolkit/fields/components/password-field.d.ts +1 -1
  30. package/dist/toolkit/fields/components/reference/components/button.d.ts +1 -1
  31. package/dist/toolkit/fields/components/reference/components/command.d.ts +21 -33
  32. package/dist/toolkit/fields/components/select.d.ts +1 -1
  33. package/dist/toolkit/fields/components/text-field.d.ts +1 -1
  34. package/dist/toolkit/fields/plugins/button-toggle-field-plugin.d.ts +2 -2
  35. package/dist/toolkit/fields/plugins/checkbox-group-field-plugin.d.ts +2 -2
  36. package/dist/toolkit/fields/plugins/color-field-plugin.d.ts +1 -0
  37. package/dist/toolkit/fields/plugins/date-field-plugin.d.ts +0 -2
  38. package/dist/toolkit/fields/plugins/dnd-kit-wrapper.d.ts +49 -0
  39. package/dist/toolkit/fields/plugins/group-list-field-plugin.d.ts +3 -1
  40. package/dist/toolkit/fields/plugins/list-field-plugin.d.ts +3 -0
  41. package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/components/editor.d.ts +20 -18
  42. package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/components/plate-ui/blockquote-element.d.ts +14 -10
  43. package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/components/plate-ui/button.d.ts +5 -5
  44. package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/components/plate-ui/code-block/code-block-element.d.ts +17 -0
  45. package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/components/plate-ui/code-block/error-message.d.ts +6 -0
  46. package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/components/plate-ui/code-block-combobox.d.ts +6 -0
  47. package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/components/plate-ui/code-block-toolbar-button.d.ts +6 -6
  48. package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/components/plate-ui/code-leaf.d.ts +2 -11
  49. package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/components/plate-ui/code-line-element.d.ts +14 -10
  50. package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/components/plate-ui/code-syntax-leaf.d.ts +2 -11
  51. package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/components/plate-ui/command.d.ts +112 -0
  52. package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/components/plate-ui/dialog.d.ts +12 -0
  53. package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/components/plate-ui/dropdown-menu.d.ts +10 -10
  54. package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/components/plate-ui/floating-toolbar.d.ts +2 -2
  55. package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/components/plate-ui/hr-element.d.ts +3 -0
  56. package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/components/plate-ui/hr-toolbar-button.d.ts +18 -0
  57. package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/components/plate-ui/icons.d.ts +2 -1
  58. package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/components/plate-ui/image-toolbar-button.d.ts +6 -6
  59. package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/components/plate-ui/indent-list-toolbar-button.d.ts +6 -19
  60. package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/components/plate-ui/inline-combobox.d.ts +1 -1
  61. package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/components/plate-ui/input.d.ts +3 -3
  62. package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/components/plate-ui/link-element.d.ts +4 -11
  63. package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/components/plate-ui/link-floating-toolbar.d.ts +4 -5
  64. package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/components/plate-ui/link-toolbar-button.d.ts +4 -4
  65. package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/components/plate-ui/list-element.d.ts +28 -11
  66. package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/components/plate-ui/mermaid-element.d.ts +3 -10
  67. package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/components/plate-ui/mermaid-toolbar-button.d.ts +6 -8
  68. package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/components/plate-ui/paragraph-element.d.ts +15 -0
  69. package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/components/plate-ui/popover.d.ts +7 -2
  70. package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/components/plate-ui/quote-toolbar-button.d.ts +6 -6
  71. package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/components/plate-ui/raw-markdown-toolbar-button.d.ts +6 -6
  72. package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/components/plate-ui/resizable.d.ts +24 -21
  73. package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/components/plate-ui/separator.d.ts +2 -2
  74. package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/components/plate-ui/slash-input-element.d.ts +15 -11
  75. package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/components/plate-ui/table/block-selection.d.ts +6 -0
  76. package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/components/plate-ui/table/table-cell-element.d.ts +33 -0
  77. package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/components/plate-ui/{table-dropdown-menu.d.ts → table/table-dropdown-menu.d.ts} +1 -0
  78. package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/components/plate-ui/table/table-element.d.ts +20 -0
  79. package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/components/plate-ui/table/table-row-element.d.ts +15 -0
  80. package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/components/plate-ui/toolbar.d.ts +7 -7
  81. package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/components/plate-ui/use-floating-toolbar-hook.d.ts +10 -0
  82. package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/components/plate-ui/use-floating-toolbar-state.d.ts +22 -0
  83. package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/hooks/use-create-editor.d.ts +6 -0
  84. package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/plugins/core/autoformat/autoformat-block.d.ts +1 -1
  85. package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/plugins/core/autoformat/autoformat-lists.d.ts +1 -1
  86. package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/plugins/core/autoformat/autoformat-marks.d.ts +1 -1
  87. package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/plugins/core/autoformat/autoformat-utils.d.ts +3 -5
  88. package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/plugins/core/common.d.ts +11 -6
  89. package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/plugins/core/formatting.d.ts +18 -2
  90. package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/plugins/core/index.d.ts +0 -1
  91. package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/plugins/create-html-block/index.d.ts +6 -0
  92. package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/plugins/create-img-plugin/index.d.ts +2 -2
  93. package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/plugins/create-invalid-markdown-plugin/index.d.ts +5 -5
  94. package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/plugins/create-mdx-plugins/component.d.ts +7 -4
  95. package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/plugins/create-mdx-plugins/index.d.ts +3 -5
  96. package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/plugins/editor-plugins.d.ts +520 -0
  97. package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/plugins/ui/components.d.ts +262 -207
  98. package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/plugins/ui/floating-toolbar-plugin.d.ts +1 -0
  99. package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/toolbar/toolbar-overrides.d.ts +1 -1
  100. package/dist/toolkit/fields/plugins/radio-group-field-plugin.d.ts +2 -2
  101. package/dist/toolkit/fields/plugins/select-field-plugin.d.ts +2 -2
  102. package/dist/toolkit/fields/plugins/toggle-field-plugin.d.ts +2 -2
  103. package/dist/toolkit/fields/plugins/wrap-field-with-meta.d.ts +6 -2
  104. package/dist/toolkit/form-builder/create-branch-modal.d.ts +13 -0
  105. package/dist/toolkit/form-builder/editorial-workflow-constants.d.ts +17 -0
  106. package/dist/toolkit/form-builder/fields-builder.d.ts +2 -1
  107. package/dist/toolkit/form-builder/form-builder.d.ts +1 -11
  108. package/dist/toolkit/form-builder/index.d.ts +1 -0
  109. package/dist/toolkit/forms/field.d.ts +3 -2
  110. package/dist/toolkit/icons/TinaExtended.d.ts +4 -0
  111. package/dist/toolkit/icons/index.d.ts +1 -0
  112. package/dist/toolkit/index.d.ts +1 -1
  113. package/dist/toolkit/plugin-branch-switcher/branch-button.d.ts +3 -1
  114. package/dist/toolkit/react-modals/modal/modal-actions.d.ts +2 -1
  115. package/dist/toolkit/react-modals/modal/modal-header.d.ts +1 -1
  116. package/dist/toolkit/react-sidebar/components/NavMenuTrigger.d.ts +11 -0
  117. package/dist/toolkit/react-sidebar/components/badge.d.ts +6 -0
  118. package/dist/toolkit/react-sidebar/components/callout.d.ts +5 -0
  119. package/dist/toolkit/react-sidebar/components/local-warning.d.ts +3 -1
  120. package/dist/toolkit/react-sidebar/components/nav-components.d.ts +11 -0
  121. package/dist/toolkit/react-sidebar/components/nav-context.d.ts +15 -0
  122. package/dist/toolkit/react-sidebar/components/nav.d.ts +3 -2
  123. package/dist/toolkit/react-sidebar/components/sidebar-body.d.ts +26 -1
  124. package/dist/toolkit/react-sidebar/index.d.ts +3 -0
  125. package/dist/toolkit/styles/button.d.ts +1 -1
  126. package/dist/toolkit/styles/dropdown-button.d.ts +75 -0
  127. package/dist/toolkit/styles/index.d.ts +1 -0
  128. package/dist/toolkit/tina-state.d.ts +42 -16
  129. package/dist/unifiedClient/index.d.ts +1 -1
  130. package/dist/utils/index.d.ts +1 -0
  131. package/package.json +56 -87
  132. package/dist/admin/pages/IndexingPage.d.ts +0 -2
  133. package/dist/client.mjs +0 -132
  134. package/dist/index.mjs +0 -35827
  135. package/dist/node-cache-5e8db9f0.mjs +0 -63
  136. package/dist/react.mjs +0 -254
  137. package/dist/rich-text/index.mjs +0 -243
  138. package/dist/rich-text/prism.mjs +0 -16
  139. package/dist/rich-text/static.mjs +0 -236
  140. package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/components/plate-ui/code-block-element.d.ts +0 -11
  141. package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/components/plate-ui/table-cell-element.d.ts +0 -27
  142. package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/components/plate-ui/table-element.d.ts +0 -14
  143. package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/components/plate-ui/table-row-element.d.ts +0 -13
  144. package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/plugins/core/with-correct-void-behavior.d.ts +0 -8
  145. package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/plugins/create-code-block/index.d.ts +0 -3
  146. package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/plugins/create-link-plugin/index.d.ts +0 -15
  147. package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/plugins/custom/mermaid-plugin.d.ts +0 -2
  148. package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/plugins/soft-break/create-soft-break-plugin.d.ts +0 -7
  149. package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/plugins/soft-break/index.d.ts +0 -6
  150. package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/plugins/soft-break/on-key-down-soft-break.d.ts +0 -5
  151. package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/plugins/soft-break/types.d.ts +0 -11
  152. package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/plugins/ui/code-block/index.d.ts +0 -11
  153. package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/transforms/insert-empty-block.d.ts +0 -2
  154. package/dist/toolkit/react-datetime/DateTime.d.ts +0 -135
  155. package/dist/toolkit/react-sidebar/components/alert.d.ts +0 -5
  156. /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,243 +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 "mermaid":
118
- case "code_block": {
119
- const value = child.value;
120
- if (components[child.type]) {
121
- const Component2 = components[child.type];
122
- return (
123
- // @ts-ignore FIXME: TinaMarkdownContent needs to be a union of all possible node types
124
- /* @__PURE__ */ React.createElement(Component2, { ...props })
125
- );
126
- }
127
- return /* @__PURE__ */ React.createElement("pre", null, /* @__PURE__ */ React.createElement("code", null, value));
128
- }
129
- case "hr":
130
- if (components[child.type]) {
131
- const Component2 = components[child.type];
132
- return /* @__PURE__ */ React.createElement(Component2, { ...props });
133
- }
134
- return /* @__PURE__ */ React.createElement("hr", null);
135
- case "break":
136
- if (components[child.type]) {
137
- const Component2 = components[child.type];
138
- return /* @__PURE__ */ React.createElement(Component2, { ...props });
139
- }
140
- return /* @__PURE__ */ React.createElement("br", null);
141
- case "text":
142
- return /* @__PURE__ */ React.createElement(Leaf, { components, ...child });
143
- case "mdxJsxTextElement":
144
- case "mdxJsxFlowElement":
145
- const Component = components[child.name];
146
- if (Component) {
147
- const props2 = child.props ? child.props : {};
148
- return /* @__PURE__ */ React.createElement(Component, { ...props2 });
149
- } else {
150
- if (child.name === "table") {
151
- const firstRowHeader = (_a = child.props) == null ? void 0 : _a.firstRowHeader;
152
- const rows2 = (firstRowHeader ? (_b = child.props) == null ? void 0 : _b.tableRows.filter((_, i) => i !== 0) : (_c = child.props) == null ? void 0 : _c.tableRows) || [];
153
- const header = (_e = (_d = child.props) == null ? void 0 : _d.tableRows) == null ? void 0 : _e.at(0);
154
- const TableComponent2 = components["table"] || ((props2) => /* @__PURE__ */ React.createElement("table", { ...props2 }));
155
- const TrComponent2 = components["tr"] || ((props2) => /* @__PURE__ */ React.createElement("tr", { ...props2 }));
156
- const ThComponent = components["th"] || ((props2) => /* @__PURE__ */ React.createElement("th", { style: { textAlign: (props2 == null ? void 0 : props2.align) || "auto" }, ...props2 }));
157
- const TdComponent2 = components["td"] || ((props2) => /* @__PURE__ */ React.createElement("td", { style: { textAlign: (props2 == null ? void 0 : props2.align) || "auto" }, ...props2 }));
158
- const align2 = ((_f = child.props) == null ? void 0 : _f.align) || [];
159
- return /* @__PURE__ */ React.createElement(TableComponent2, null, firstRowHeader && /* @__PURE__ */ React.createElement("thead", null, /* @__PURE__ */ React.createElement(TrComponent2, null, header.tableCells.map((c, i) => {
160
- return /* @__PURE__ */ React.createElement(
161
- TinaMarkdown,
162
- {
163
- key: i,
164
- components: {
165
- p: (props2) => /* @__PURE__ */ React.createElement(ThComponent, { align: align2[i], ...props2 })
166
- },
167
- content: c.value
168
- }
169
- );
170
- }))), /* @__PURE__ */ React.createElement("tbody", null, rows2.map((row, i) => {
171
- var _a2;
172
- return /* @__PURE__ */ React.createElement(TrComponent2, { key: i }, (_a2 = row == null ? void 0 : row.tableCells) == null ? void 0 : _a2.map((c, i2) => {
173
- return /* @__PURE__ */ React.createElement(
174
- TinaMarkdown,
175
- {
176
- key: i2,
177
- components: {
178
- p: (props2) => /* @__PURE__ */ React.createElement(TdComponent2, { align: align2[i2], ...props2 })
179
- },
180
- content: c.value
181
- }
182
- );
183
- }));
184
- })));
185
- }
186
- const ComponentMissing = components["component_missing"];
187
- if (ComponentMissing) {
188
- return /* @__PURE__ */ React.createElement(ComponentMissing, { name: child.name });
189
- } else {
190
- return /* @__PURE__ */ React.createElement("span", null, `No component provided for ${child.name}`);
191
- }
192
- }
193
- case "table":
194
- const rows = child.children || [];
195
- const TableComponent = components["table"] || ((props2) => /* @__PURE__ */ React.createElement("table", { style: { border: "1px solid #EDECF3" }, ...props2 }));
196
- const TrComponent = components["tr"] || ((props2) => /* @__PURE__ */ React.createElement("tr", { ...props2 }));
197
- const TdComponent = components["td"] || ((props2) => /* @__PURE__ */ React.createElement(
198
- "td",
199
- {
200
- style: {
201
- textAlign: (props2 == null ? void 0 : props2.align) || "auto",
202
- border: "1px solid #EDECF3",
203
- padding: "0.25rem"
204
- },
205
- ...props2
206
- }
207
- ));
208
- const align = ((_g = child.props) == null ? void 0 : _g.align) || [];
209
- return /* @__PURE__ */ React.createElement(TableComponent, null, /* @__PURE__ */ React.createElement("tbody", null, rows.map((row, i) => {
210
- var _a2;
211
- return /* @__PURE__ */ React.createElement(TrComponent, { key: i }, (_a2 = row.children) == null ? void 0 : _a2.map((cell, i2) => {
212
- return /* @__PURE__ */ React.createElement(
213
- TinaMarkdown,
214
- {
215
- key: i2,
216
- components: {
217
- p: (props2) => /* @__PURE__ */ React.createElement(TdComponent, { align: align[i2], ...props2 })
218
- },
219
- content: cell.children
220
- }
221
- );
222
- }));
223
- })));
224
- case "maybe_mdx":
225
- return null;
226
- case "html":
227
- case "html_inline":
228
- if (components[child.type]) {
229
- const Component2 = components[child.type];
230
- return /* @__PURE__ */ React.createElement(Component2, { ...props });
231
- }
232
- return child.value;
233
- case "invalid_markdown":
234
- return /* @__PURE__ */ React.createElement("pre", null, child.value);
235
- default:
236
- if (typeof child.text === "string") {
237
- return /* @__PURE__ */ React.createElement(Leaf, { components, ...child });
238
- }
239
- }
240
- };
241
- export {
242
- TinaMarkdown
243
- };
@@ -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
- };