tinacms 0.0.0-c6915ea-20250421012527 → 0.0.0-c706b9f-20251222081038

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 (189) hide show
  1. package/dist/admin/api.d.ts +4 -1
  2. package/dist/admin/components/{Sidebar.d.ts → AdminNav.d.ts} +0 -3
  3. package/dist/admin/components/Page.d.ts +3 -9
  4. package/dist/admin/components/ui/tooltip.d.ts +7 -0
  5. package/dist/admin/pages/CollectionCreatePage.d.ts +1 -1
  6. package/dist/admin/pages/CollectionListPage.d.ts +2 -2
  7. package/dist/admin/pages/DashboardPage.d.ts +0 -3
  8. package/dist/admin/pages/ScreenPage.d.ts +0 -3
  9. package/dist/auth/AuthModal.d.ts +1 -4
  10. package/dist/auth/TinaCloudProvider.d.ts +0 -1
  11. package/dist/auth/authenticate.d.ts +1 -1
  12. package/dist/cache/node-cache.d.ts +6 -2
  13. package/dist/client.d.ts +4 -1
  14. package/dist/client.js +240 -181
  15. package/dist/index.d.ts +61 -1
  16. package/dist/index.js +122387 -33769
  17. package/dist/internalClient/authProvider.d.ts +0 -2
  18. package/dist/internalClient/index.d.ts +48 -30
  19. package/dist/react.d.ts +41 -1
  20. package/dist/react.js +295 -196
  21. package/dist/rich-text/index.d.ts +148 -1
  22. package/dist/rich-text/index.js +234 -224
  23. package/dist/rich-text/prism.d.ts +10 -1
  24. package/dist/rich-text/prism.js +16 -18
  25. package/dist/rich-text/static.d.ts +154 -0
  26. package/dist/rich-text/{index.mjs → static.js} +99 -99
  27. package/dist/tina-cms.d.ts +1 -1
  28. package/dist/toolkit/components/ProgressBar.d.ts +11 -0
  29. package/dist/toolkit/components/active-field-indicator.d.ts +1 -0
  30. package/dist/toolkit/components/media/media-item.d.ts +11 -1
  31. package/dist/toolkit/components/ui/breadcrumb.d.ts +11 -0
  32. package/dist/toolkit/components/ui/button.d.ts +11 -0
  33. package/dist/toolkit/components/ui/calendar.d.ts +8 -0
  34. package/dist/toolkit/components/ui/date-time-picker.d.ts +111 -0
  35. package/dist/toolkit/components/ui/dropdown-menu.d.ts +25 -0
  36. package/dist/toolkit/components/ui/input.d.ts +3 -0
  37. package/dist/toolkit/components/ui/popover.d.ts +7 -0
  38. package/dist/toolkit/components/ui/select.d.ts +13 -0
  39. package/dist/toolkit/fields/components/color-picker/block-widget.d.ts +3 -0
  40. package/dist/toolkit/fields/components/color-picker/color-input.d.ts +35 -0
  41. package/dist/toolkit/fields/components/color-picker/color-picker.d.ts +6 -2
  42. package/dist/toolkit/fields/components/color-picker/color-utils.d.ts +37 -0
  43. package/dist/toolkit/fields/components/color-picker/sketch-widget.d.ts +3 -0
  44. package/dist/toolkit/fields/components/password-field.d.ts +1 -1
  45. package/dist/toolkit/fields/components/reference/components/button.d.ts +2 -2
  46. package/dist/toolkit/fields/components/reference/components/command.d.ts +21 -33
  47. package/dist/toolkit/fields/components/reference/components/popover.d.ts +1 -1
  48. package/dist/toolkit/fields/components/reference/model/reference-link-props.d.ts +2 -0
  49. package/dist/toolkit/fields/components/select.d.ts +2 -2
  50. package/dist/toolkit/fields/components/text-field.d.ts +1 -1
  51. package/dist/toolkit/fields/plugins/button-toggle-field-plugin.d.ts +2 -2
  52. package/dist/toolkit/fields/plugins/checkbox-group-field-plugin.d.ts +2 -2
  53. package/dist/toolkit/fields/plugins/color-field-plugin.d.ts +1 -0
  54. package/dist/toolkit/fields/plugins/date-field-plugin.d.ts +0 -2
  55. package/dist/toolkit/fields/plugins/dnd-kit-wrapper.d.ts +49 -0
  56. package/dist/toolkit/fields/plugins/group-field-plugin.d.ts +1 -1
  57. package/dist/toolkit/fields/plugins/group-list-field-plugin.d.ts +3 -1
  58. package/dist/toolkit/fields/plugins/list-field-meta.d.ts +1 -1
  59. package/dist/toolkit/fields/plugins/list-field-plugin.d.ts +3 -0
  60. package/dist/toolkit/fields/plugins/mdx-field-plugin/index.d.ts +2 -2
  61. package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/components/editor.d.ts +20 -18
  62. package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/components/plate-ui/blockquote-element.d.ts +14 -10
  63. package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/components/plate-ui/button.d.ts +5 -5
  64. package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/components/plate-ui/code-block/code-block-element.d.ts +17 -0
  65. package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/components/plate-ui/code-block/error-message.d.ts +6 -0
  66. package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/components/plate-ui/code-block-combobox.d.ts +6 -0
  67. package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/components/plate-ui/code-block-toolbar-button.d.ts +6 -6
  68. package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/components/plate-ui/code-leaf.d.ts +2 -11
  69. package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/components/plate-ui/code-line-element.d.ts +14 -10
  70. package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/components/plate-ui/code-syntax-leaf.d.ts +2 -11
  71. package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/components/plate-ui/command.d.ts +112 -0
  72. package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/components/plate-ui/dialog.d.ts +12 -0
  73. package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/components/plate-ui/dropdown-menu.d.ts +10 -10
  74. package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/components/plate-ui/floating-toolbar.d.ts +2 -2
  75. package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/components/plate-ui/hr-element.d.ts +3 -0
  76. package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/components/plate-ui/hr-toolbar-button.d.ts +18 -0
  77. package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/components/plate-ui/icons.d.ts +2 -1
  78. package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/components/plate-ui/image-toolbar-button.d.ts +6 -6
  79. package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/components/plate-ui/indent-list-toolbar-button.d.ts +6 -19
  80. package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/components/plate-ui/inline-combobox.d.ts +1 -1
  81. package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/components/plate-ui/input.d.ts +3 -3
  82. package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/components/plate-ui/link-element.d.ts +4 -11
  83. package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/components/plate-ui/link-floating-toolbar.d.ts +4 -5
  84. package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/components/plate-ui/link-toolbar-button.d.ts +4 -4
  85. package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/components/plate-ui/list-element.d.ts +28 -11
  86. package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/components/plate-ui/mermaid-element.d.ts +3 -10
  87. package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/components/plate-ui/mermaid-toolbar-button.d.ts +6 -8
  88. package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/components/plate-ui/paragraph-element.d.ts +15 -0
  89. package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/components/plate-ui/popover.d.ts +7 -2
  90. package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/components/plate-ui/quote-toolbar-button.d.ts +6 -6
  91. package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/components/plate-ui/raw-markdown-toolbar-button.d.ts +6 -6
  92. package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/components/plate-ui/resizable.d.ts +24 -21
  93. package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/components/plate-ui/separator.d.ts +2 -2
  94. package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/components/plate-ui/slash-input-element.d.ts +15 -11
  95. package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/components/plate-ui/table/block-selection.d.ts +6 -0
  96. package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/components/plate-ui/table/table-cell-element.d.ts +33 -0
  97. 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
  98. package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/components/plate-ui/table/table-element.d.ts +20 -0
  99. package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/components/plate-ui/table/table-row-element.d.ts +15 -0
  100. package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/components/plate-ui/toolbar.d.ts +7 -7
  101. package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/components/plate-ui/use-floating-toolbar-hook.d.ts +10 -0
  102. package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/components/plate-ui/use-floating-toolbar-state.d.ts +22 -0
  103. package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/hooks/use-create-editor.d.ts +6 -0
  104. package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/plugins/core/autoformat/autoformat-block.d.ts +1 -1
  105. package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/plugins/core/autoformat/autoformat-lists.d.ts +1 -1
  106. package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/plugins/core/autoformat/autoformat-marks.d.ts +1 -1
  107. package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/plugins/core/autoformat/autoformat-utils.d.ts +3 -5
  108. package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/plugins/core/common.d.ts +11 -6
  109. package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/plugins/core/formatting.d.ts +18 -2
  110. package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/plugins/core/index.d.ts +0 -1
  111. package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/plugins/create-html-block/index.d.ts +6 -0
  112. package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/plugins/create-img-plugin/index.d.ts +2 -2
  113. package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/plugins/create-invalid-markdown-plugin/index.d.ts +5 -5
  114. package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/plugins/create-mdx-plugins/component.d.ts +7 -4
  115. package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/plugins/create-mdx-plugins/index.d.ts +3 -5
  116. package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/plugins/editor-plugins.d.ts +520 -0
  117. package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/plugins/ui/components.d.ts +263 -207
  118. package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/plugins/ui/floating-toolbar-plugin.d.ts +1 -0
  119. package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/toolbar/toolbar-overrides.d.ts +1 -1
  120. package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/transforms/is-url.d.ts +1 -2
  121. package/dist/toolkit/fields/plugins/radio-group-field-plugin.d.ts +2 -2
  122. package/dist/toolkit/fields/plugins/select-field-plugin.d.ts +2 -2
  123. package/dist/toolkit/fields/plugins/toggle-field-plugin.d.ts +2 -2
  124. package/dist/toolkit/fields/plugins/wrap-field-with-meta.d.ts +6 -2
  125. package/dist/toolkit/form-builder/create-branch-modal.d.ts +13 -0
  126. package/dist/toolkit/form-builder/editorial-workflow-constants.d.ts +17 -0
  127. package/dist/toolkit/form-builder/fields-builder.d.ts +3 -2
  128. package/dist/toolkit/form-builder/form-builder.d.ts +9 -9
  129. package/dist/toolkit/form-builder/index.d.ts +1 -0
  130. package/dist/toolkit/forms/field.d.ts +6 -2
  131. package/dist/toolkit/forms/form.d.ts +22 -3
  132. package/dist/toolkit/git-client/git-client.d.ts +25 -2
  133. package/dist/toolkit/git-client/git-file.d.ts +18 -0
  134. package/dist/toolkit/git-client/git-media-store.d.ts +13 -0
  135. package/dist/toolkit/git-client/use-git-file.d.ts +4 -0
  136. package/dist/toolkit/icons/Tina.d.ts +0 -5
  137. package/dist/toolkit/icons/TinaExtended.d.ts +4 -0
  138. package/dist/toolkit/icons/index.d.ts +1 -0
  139. package/dist/toolkit/index.d.ts +1 -1
  140. package/dist/toolkit/plugin-branch-switcher/branch-button.d.ts +4 -1
  141. package/dist/toolkit/plugin-branch-switcher/index.d.ts +0 -1
  142. package/dist/toolkit/react-modals/modal/modal-actions.d.ts +2 -1
  143. package/dist/toolkit/react-modals/modal/modal-header.d.ts +1 -1
  144. package/dist/toolkit/react-sidebar/components/NavMenuTrigger.d.ts +11 -0
  145. package/dist/toolkit/react-sidebar/components/VersionInfo.d.ts +2 -0
  146. package/dist/toolkit/react-sidebar/components/badge.d.ts +6 -0
  147. package/dist/toolkit/react-sidebar/components/callout.d.ts +5 -0
  148. package/dist/toolkit/react-sidebar/components/form-list.d.ts +1 -1
  149. package/dist/toolkit/react-sidebar/components/local-warning.d.ts +3 -1
  150. package/dist/toolkit/react-sidebar/components/nav-components.d.ts +11 -0
  151. package/dist/toolkit/react-sidebar/components/nav-context.d.ts +15 -0
  152. package/dist/toolkit/react-sidebar/components/nav.d.ts +6 -3
  153. package/dist/toolkit/react-sidebar/components/resize-handle.d.ts +0 -5
  154. package/dist/toolkit/react-sidebar/components/sidebar-body.d.ts +28 -7
  155. package/dist/toolkit/react-sidebar/components/sidebar.d.ts +0 -7
  156. package/dist/toolkit/react-sidebar/components/sync-status.d.ts +5 -8
  157. package/dist/toolkit/react-sidebar/index.d.ts +4 -1
  158. package/dist/toolkit/styles/button.d.ts +2 -2
  159. package/dist/toolkit/styles/dropdown-button.d.ts +75 -0
  160. package/dist/toolkit/styles/index.d.ts +1 -0
  161. package/dist/toolkit/tina-cms.d.ts +3 -3
  162. package/dist/toolkit/tina-state.d.ts +53 -16
  163. package/dist/unifiedClient/index.d.ts +1 -1
  164. package/dist/utils/cn.d.ts +2 -0
  165. package/dist/utils/index.d.ts +1 -0
  166. package/package.json +59 -83
  167. package/dist/admin/components/AuthCallback.d.ts +0 -5
  168. package/dist/admin/pages/IndexingPage.d.ts +0 -2
  169. package/dist/client.mjs +0 -132
  170. package/dist/index.mjs +0 -35202
  171. package/dist/node-cache-5e8db9f0.mjs +0 -63
  172. package/dist/react.mjs +0 -246
  173. package/dist/rich-text/prism.mjs +0 -16
  174. package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/components/plate-ui/code-block-element.d.ts +0 -11
  175. package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/components/plate-ui/table-cell-element.d.ts +0 -27
  176. package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/components/plate-ui/table-element.d.ts +0 -14
  177. package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/components/plate-ui/table-row-element.d.ts +0 -13
  178. package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/plugins/core/with-correct-void-behavior.d.ts +0 -8
  179. package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/plugins/create-code-block/index.d.ts +0 -3
  180. package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/plugins/create-link-plugin/index.d.ts +0 -15
  181. package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/plugins/custom/mermaid-plugin.d.ts +0 -2
  182. package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/plugins/soft-break/create-soft-break-plugin.d.ts +0 -7
  183. package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/plugins/soft-break/index.d.ts +0 -6
  184. package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/plugins/soft-break/on-key-down-soft-break.d.ts +0 -5
  185. package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/plugins/soft-break/types.d.ts +0 -11
  186. package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/plugins/ui/code-block/index.d.ts +0 -11
  187. package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/transforms/insert-empty-block.d.ts +0 -2
  188. package/dist/toolkit/plugin-branch-switcher/branch-banner.d.ts +0 -2
  189. package/dist/toolkit/react-datetime/DateTime.d.ts +0 -135
package/dist/react.js CHANGED
@@ -1,67 +1,113 @@
1
- (function(global, factory) {
2
- typeof exports === "object" && typeof module !== "undefined" ? factory(exports, require("react")) : typeof define === "function" && define.amd ? define(["exports", "react"], factory) : (global = typeof globalThis !== "undefined" ? globalThis : global || self, factory(global.tinacms = {}, global.NOOP));
3
- })(this, function(exports2, React) {
4
- "use strict";
5
- function useTina(props) {
6
- const stringifiedQuery = JSON.stringify({
7
- query: props.query,
8
- variables: props.variables
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"
9
26
  });
10
- const id = React.useMemo(
11
- () => hashFromQuery(stringifiedQuery),
12
- [stringifiedQuery]
13
- );
14
- const [data, setData] = React.useState(props.data);
15
- const [isClient, setIsClient] = React.useState(false);
16
- const [quickEditEnabled, setQuickEditEnabled] = React.useState(false);
17
- const [isInTinaIframe, setIsInTinaIframe] = React.useState(false);
18
- React.useEffect(() => {
19
- setIsClient(true);
20
- setData(props.data);
21
- parent.postMessage({
22
- type: "url-changed"
23
- });
24
- }, [id]);
25
- React.useEffect(() => {
26
- if (quickEditEnabled) {
27
- let mouseDownHandler = function(e) {
28
- const attributeNames = e.target.getAttributeNames();
29
- const tinaAttribute = attributeNames.find(
30
- (name) => name.startsWith("data-tina-field")
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]"
31
43
  );
32
- let fieldName;
33
- if (tinaAttribute) {
34
- e.preventDefault();
35
- e.stopPropagation();
36
- fieldName = e.target.getAttribute(tinaAttribute);
37
- } else {
38
- const ancestor = e.target.closest(
39
- "[data-tina-field], [data-tina-field-overlay]"
44
+ if (ancestor) {
45
+ const attributeNames2 = ancestor.getAttributeNames();
46
+ const tinaAttribute2 = attributeNames2.find(
47
+ (name) => name.startsWith("data-tina-field")
40
48
  );
41
- if (ancestor) {
42
- const attributeNames2 = ancestor.getAttributeNames();
43
- const tinaAttribute2 = attributeNames2.find(
44
- (name) => name.startsWith("data-tina-field")
45
- );
46
- if (tinaAttribute2) {
47
- e.preventDefault();
48
- e.stopPropagation();
49
- fieldName = ancestor.getAttribute(tinaAttribute2);
50
- }
49
+ if (tinaAttribute2) {
50
+ e.preventDefault();
51
+ e.stopPropagation();
52
+ fieldName = ancestor.getAttribute(tinaAttribute2);
51
53
  }
52
54
  }
53
- if (fieldName) {
55
+ }
56
+ if (fieldName) {
57
+ if (lastHoveredField !== null) {
58
+ lastHoveredField = null;
54
59
  if (isInTinaIframe) {
55
60
  parent.postMessage(
56
- { type: "field:selected", fieldName },
61
+ { type: "field:hovered", fieldName: null },
57
62
  window.location.origin
58
63
  );
59
64
  }
60
65
  }
61
- };
62
- const style = document.createElement("style");
63
- style.type = "text/css";
64
- style.textContent = `
66
+ if (isInTinaIframe) {
67
+ parent.postMessage(
68
+ { type: "field:selected", fieldName },
69
+ window.location.origin
70
+ );
71
+ }
72
+ }
73
+ }, mouseEnterHandler = function(e) {
74
+ if (!(e.target instanceof Element)) {
75
+ return;
76
+ }
77
+ const attributeNames = e.target.getAttributeNames();
78
+ const tinaAttribute = attributeNames.find(
79
+ (name) => name.startsWith("data-tina-field")
80
+ );
81
+ let fieldName;
82
+ if (tinaAttribute) {
83
+ fieldName = e.target.getAttribute(tinaAttribute);
84
+ } else {
85
+ const ancestor = e.target.closest(
86
+ "[data-tina-field], [data-tina-field-overlay]"
87
+ );
88
+ if (ancestor) {
89
+ const attributeNames2 = ancestor.getAttributeNames();
90
+ const tinaAttribute2 = attributeNames2.find(
91
+ (name) => name.startsWith("data-tina-field")
92
+ );
93
+ if (tinaAttribute2) {
94
+ fieldName = ancestor.getAttribute(tinaAttribute2);
95
+ }
96
+ }
97
+ }
98
+ if (fieldName && fieldName !== lastHoveredField) {
99
+ lastHoveredField = fieldName;
100
+ if (isInTinaIframe) {
101
+ parent.postMessage(
102
+ { type: "field:hovered", fieldName },
103
+ window.location.origin
104
+ );
105
+ }
106
+ }
107
+ };
108
+ const style = document.createElement("style");
109
+ style.type = "text/css";
110
+ style.textContent = `
65
111
  [data-tina-field] {
66
112
  outline: 2px dashed rgba(34,150,254,0.5);
67
113
  transition: box-shadow ease-out 150ms;
@@ -71,6 +117,15 @@
71
117
  outline: 2px solid rgba(34,150,254,1);
72
118
  cursor: pointer;
73
119
  }
120
+ [data-tina-field-focused] {
121
+ outline: 2px dashed #C2410C !important;
122
+ box-shadow: none !important;
123
+ }
124
+ [data-tina-field-focused]:hover {
125
+ box-shadow: inset 100vi 100vh rgba(194, 65, 12, 0.3) !important;
126
+ outline: 2px solid #C2410C !important;
127
+ cursor: pointer;
128
+ }
74
129
  [data-tina-field-overlay] {
75
130
  outline: 2px dashed rgba(34,150,254,0.5);
76
131
  position: relative;
@@ -91,159 +146,203 @@
91
146
  [data-tina-field-overlay]:hover::after {
92
147
  opacity: 1;
93
148
  }
94
- `;
95
- document.head.appendChild(style);
96
- document.body.classList.add("__tina-quick-editing-enabled");
97
- document.addEventListener("click", mouseDownHandler, true);
98
- return () => {
99
- document.removeEventListener("click", mouseDownHandler, true);
100
- document.body.classList.remove("__tina-quick-editing-enabled");
101
- style.remove();
102
- };
103
- }
104
- }, [quickEditEnabled, isInTinaIframe]);
105
- React.useEffect(() => {
106
- if (props == null ? void 0 : props.experimental___selectFormByFormId) {
107
- parent.postMessage({
108
- type: "user-select-form",
109
- formId: props.experimental___selectFormByFormId()
110
- });
111
- }
112
- }, [id]);
113
- React.useEffect(() => {
114
- const { experimental___selectFormByFormId, ...rest } = props;
115
- parent.postMessage({ type: "open", ...rest, id }, window.location.origin);
116
- window.addEventListener("message", (event) => {
117
- if (event.data.type === "quickEditEnabled") {
118
- setQuickEditEnabled(event.data.value);
119
- }
120
- if (event.data.id === id && event.data.type === "updateData") {
121
- setData(event.data.data);
122
- setIsInTinaIframe(true);
123
- const anyTinaField = document.querySelector("[data-tina-field]");
124
- if (anyTinaField) {
125
- parent.postMessage(
126
- { type: "quick-edit", value: true },
127
- window.location.origin
128
- );
129
- } else {
130
- parent.postMessage(
131
- { type: "quick-edit", value: false },
132
- window.location.origin
133
- );
134
- }
149
+ [data-tina-field-overlay][data-tina-field-focused]::after {
150
+ background-color: rgba(194, 65, 12, 0.3);
151
+ opacity: 1;
135
152
  }
136
- });
153
+ `;
154
+ document.head.appendChild(style);
155
+ document.body.classList.add("__tina-quick-editing-enabled");
156
+ let lastHoveredField = null;
157
+ document.addEventListener("click", mouseDownHandler, true);
158
+ document.addEventListener("mouseenter", mouseEnterHandler, true);
137
159
  return () => {
138
- parent.postMessage({ type: "close", id }, window.location.origin);
160
+ document.removeEventListener("click", mouseDownHandler, true);
161
+ document.removeEventListener("mouseenter", mouseEnterHandler, true);
162
+ document.body.classList.remove("__tina-quick-editing-enabled");
163
+ style.remove();
139
164
  };
140
- }, [id, setQuickEditEnabled]);
141
- return { data, isClient };
142
- }
143
- function useEditState() {
144
- const [edit, setEdit] = React.useState(false);
145
- React.useEffect(() => {
146
- if (typeof window !== "undefined") {
147
- parent.postMessage({ type: "isEditMode" }, window.location.origin);
148
- window.addEventListener("message", (event) => {
149
- var _a;
150
- if (((_a = event.data) == null ? void 0 : _a.type) === "tina:editMode") {
151
- setEdit(true);
152
- }
153
- });
154
- }
155
- }, []);
156
- return { edit };
157
- }
158
- const tinaField = (object, property, index) => {
159
- var _a, _b, _c;
160
- if (!object) {
161
- return "";
162
165
  }
163
- if (object._content_source) {
164
- if (!property) {
165
- return [
166
- (_a = object._content_source) == null ? void 0 : _a.queryId,
167
- object._content_source.path.join(".")
168
- ].join("---");
166
+ }, [quickEditEnabled, isInTinaIframe]);
167
+ React.useEffect(() => {
168
+ if (props == null ? void 0 : props.experimental___selectFormByFormId) {
169
+ parent.postMessage({
170
+ type: "user-select-form",
171
+ formId: props.experimental___selectFormByFormId()
172
+ });
173
+ }
174
+ }, [id]);
175
+ const lastFocusedFieldRef = React.useRef(null);
176
+ React.useEffect(() => {
177
+ const { experimental___selectFormByFormId, ...rest } = props;
178
+ parent.postMessage({ type: "open", ...rest, id }, window.location.origin);
179
+ const handleMessage = (event) => {
180
+ if (event.data.type === "quickEditEnabled") {
181
+ setQuickEditEnabled(event.data.value);
169
182
  }
170
- if (typeof index === "number") {
171
- return [
172
- (_b = object._content_source) == null ? void 0 : _b.queryId,
173
- [...object._content_source.path, property, index].join(".")
174
- ].join("---");
183
+ if (event.data.id === id && event.data.type === "updateData") {
184
+ const rawData = event.data.data;
185
+ const newlyProcessedData = addMetadata(
186
+ id,
187
+ JSON.parse(JSON.stringify(rawData)),
188
+ []
189
+ );
190
+ setData(newlyProcessedData);
191
+ setIsInTinaIframe(true);
192
+ const anyTinaField = document.querySelector("[data-tina-field]");
193
+ if (anyTinaField) {
194
+ parent.postMessage(
195
+ { type: "quick-edit", value: true },
196
+ window.location.origin
197
+ );
198
+ } else {
199
+ parent.postMessage(
200
+ { type: "quick-edit", value: false },
201
+ window.location.origin
202
+ );
203
+ }
175
204
  }
176
- return [
177
- (_c = object._content_source) == null ? void 0 : _c.queryId,
178
- [...object._content_source.path, property].join(".")
179
- ].join("---");
180
- }
181
- return "";
182
- };
183
- const addMetadata = (id, object, path) => {
184
- Object.entries(object).forEach(([key, value]) => {
185
- if (Array.isArray(value)) {
186
- value.forEach((item, index) => {
187
- if (isScalarOrUndefined(item)) {
188
- return;
205
+ if (event.data.type === "field:set-focused") {
206
+ const newFieldName = event.data.fieldName;
207
+ if (newFieldName === lastFocusedFieldRef.current) {
208
+ return;
209
+ }
210
+ lastFocusedFieldRef.current = newFieldName;
211
+ const allTinaFields = document.querySelectorAll("[data-tina-field]");
212
+ allTinaFields.forEach((el) => {
213
+ el.removeAttribute("data-tina-field-focused");
214
+ });
215
+ if (newFieldName) {
216
+ let targetElement = document.querySelector(
217
+ `[data-tina-field="${newFieldName}"]`
218
+ );
219
+ if (!targetElement) {
220
+ const allFields = Array.from(allTinaFields);
221
+ targetElement = allFields.find((el) => {
222
+ const fieldValue = el.getAttribute("data-tina-field");
223
+ return fieldValue && fieldValue.endsWith(newFieldName.split("---")[1]);
224
+ });
189
225
  }
190
- if (Array.isArray(item)) {
191
- return;
226
+ if (targetElement) {
227
+ targetElement.setAttribute("data-tina-field-focused", "true");
228
+ const rect = targetElement.getBoundingClientRect();
229
+ const isInViewport = rect.top >= 0 && rect.left >= 0 && rect.bottom <= window.innerHeight && rect.right <= window.innerWidth;
230
+ if (!isInViewport) {
231
+ targetElement.scrollIntoView({
232
+ behavior: "smooth",
233
+ block: "center"
234
+ });
235
+ }
192
236
  }
193
- const itemObject = item;
194
- addMetadata(id, itemObject, [...path, key, index]);
195
- });
196
- } else {
197
- if (isScalarOrUndefined(value)) {
198
- return;
199
237
  }
200
- const itemObject = value;
201
- addMetadata(id, itemObject, [...path, key]);
202
238
  }
203
- });
204
- if ((object == null ? void 0 : object.type) === "root") {
205
- return;
206
- }
207
- object._content_source = {
208
- queryId: id,
209
- path
210
239
  };
211
- return object;
212
- };
213
- function isScalarOrUndefined(value) {
214
- const type = typeof value;
215
- if (type === "string")
216
- return true;
217
- if (type === "number")
218
- return true;
219
- if (type === "boolean")
220
- return true;
221
- if (type === "undefined")
222
- return true;
223
- if (value == null)
224
- return true;
225
- if (value instanceof String)
226
- return true;
227
- if (value instanceof Number)
228
- return true;
229
- if (value instanceof Boolean)
230
- return true;
231
- return false;
240
+ window.addEventListener("message", handleMessage);
241
+ return () => {
242
+ window.removeEventListener("message", handleMessage);
243
+ parent.postMessage({ type: "close", id }, window.location.origin);
244
+ };
245
+ }, [id, setQuickEditEnabled]);
246
+ return { data, isClient };
247
+ }
248
+ function useEditState() {
249
+ const [edit, setEdit] = React.useState(false);
250
+ React.useEffect(() => {
251
+ if (typeof window !== "undefined") {
252
+ parent.postMessage({ type: "isEditMode" }, window.location.origin);
253
+ window.addEventListener("message", (event) => {
254
+ var _a;
255
+ if (((_a = event.data) == null ? void 0 : _a.type) === "tina:editMode") {
256
+ setEdit(true);
257
+ }
258
+ });
259
+ }
260
+ }, []);
261
+ return { edit };
262
+ }
263
+ const tinaField = (object, property, index) => {
264
+ const contentSource = object == null ? void 0 : object._content_source;
265
+ if (!contentSource) {
266
+ return "";
232
267
  }
233
- const hashFromQuery = (input) => {
234
- let hash = 0;
235
- for (let i = 0; i < input.length; i++) {
236
- const char = input.charCodeAt(i);
237
- hash = (hash << 5) - hash + char & 4294967295;
268
+ const { queryId, path } = contentSource;
269
+ if (!property) {
270
+ return `${queryId}---${path.join(".")}`;
271
+ }
272
+ const fullPath = typeof index === "number" ? [...path, property, index] : [...path, property];
273
+ return `${queryId}---${fullPath.join(".")}`;
274
+ };
275
+ const addMetadata = (id, obj, path = []) => {
276
+ if (obj === null) {
277
+ return obj;
278
+ }
279
+ if (isScalarOrUndefined(obj)) {
280
+ return obj;
281
+ }
282
+ if (obj instanceof String) {
283
+ return obj.valueOf();
284
+ }
285
+ if (Array.isArray(obj)) {
286
+ return obj.map(
287
+ (item, index) => addMetadata(id, item, [...path, index])
288
+ );
289
+ }
290
+ const transformedObj = {};
291
+ for (const [key, value] of Object.entries(obj)) {
292
+ const currentPath = [...path, key];
293
+ if ([
294
+ "__typename",
295
+ "_sys",
296
+ "_internalSys",
297
+ "_values",
298
+ "_internalValues",
299
+ "_content_source",
300
+ "_tina_metadata"
301
+ ].includes(key)) {
302
+ transformedObj[key] = value;
303
+ } else {
304
+ transformedObj[key] = addMetadata(id, value, currentPath);
238
305
  }
239
- const nonNegativeHash = Math.abs(hash);
240
- const alphanumericHash = nonNegativeHash.toString(36);
241
- return alphanumericHash;
242
- };
243
- exports2.addMetadata = addMetadata;
244
- exports2.hashFromQuery = hashFromQuery;
245
- exports2.tinaField = tinaField;
246
- exports2.useEditState = useEditState;
247
- exports2.useTina = useTina;
248
- Object.defineProperty(exports2, Symbol.toStringTag, { value: "Module" });
249
- });
306
+ }
307
+ if (transformedObj && typeof transformedObj === "object" && "type" in transformedObj && transformedObj.type === "root") {
308
+ return transformedObj;
309
+ }
310
+ return { ...transformedObj, _content_source: { queryId: id, path } };
311
+ };
312
+ function isScalarOrUndefined(value) {
313
+ const type = typeof value;
314
+ if (type === "string")
315
+ return true;
316
+ if (type === "number")
317
+ return true;
318
+ if (type === "boolean")
319
+ return true;
320
+ if (type === "undefined")
321
+ return true;
322
+ if (value == null)
323
+ return true;
324
+ if (value instanceof String)
325
+ return true;
326
+ if (value instanceof Number)
327
+ return true;
328
+ if (value instanceof Boolean)
329
+ return true;
330
+ return false;
331
+ }
332
+ const hashFromQuery = (input) => {
333
+ let hash = 0;
334
+ for (let i = 0; i < input.length; i++) {
335
+ const char = input.charCodeAt(i);
336
+ hash = (hash << 5) - hash + char & 4294967295;
337
+ }
338
+ const nonNegativeHash = Math.abs(hash);
339
+ const alphanumericHash = nonNegativeHash.toString(36);
340
+ return alphanumericHash;
341
+ };
342
+ export {
343
+ addMetadata,
344
+ hashFromQuery,
345
+ tinaField,
346
+ useEditState,
347
+ useTina
348
+ };
@@ -1 +1,148 @@
1
- export * from "../../src/rich-text/index"
1
+ /**
2
+
3
+ */
4
+ import React from 'react';
5
+ type BaseComponents = {
6
+ h1?: {
7
+ children: JSX.Element;
8
+ };
9
+ h2?: {
10
+ children: JSX.Element;
11
+ };
12
+ h3?: {
13
+ children: JSX.Element;
14
+ };
15
+ h4?: {
16
+ children: JSX.Element;
17
+ };
18
+ h5?: {
19
+ children: JSX.Element;
20
+ };
21
+ h6?: {
22
+ children: JSX.Element;
23
+ };
24
+ p?: {
25
+ children: JSX.Element;
26
+ };
27
+ a?: {
28
+ url: string;
29
+ children: JSX.Element;
30
+ };
31
+ italic?: {
32
+ children: JSX.Element;
33
+ };
34
+ bold?: {
35
+ children: JSX.Element;
36
+ };
37
+ strikethrough?: {
38
+ children: JSX.Element;
39
+ };
40
+ underline?: {
41
+ children: JSX.Element;
42
+ };
43
+ code?: {
44
+ children: JSX.Element;
45
+ };
46
+ text?: {
47
+ children: string;
48
+ };
49
+ ul?: {
50
+ children: JSX.Element;
51
+ };
52
+ ol?: {
53
+ children: JSX.Element;
54
+ };
55
+ li?: {
56
+ children: JSX.Element;
57
+ };
58
+ lic?: {
59
+ children: JSX.Element;
60
+ };
61
+ /**
62
+ * @deprecated Use `blockquote` instead. This was incorrectly named and will be removed in a future version.
63
+ */
64
+ block_quote?: {
65
+ children: JSX.Element;
66
+ };
67
+ blockquote?: {
68
+ children: JSX.Element;
69
+ };
70
+ code_block?: {
71
+ lang?: string;
72
+ value: string;
73
+ };
74
+ mermaid?: {
75
+ value: string;
76
+ };
77
+ img?: {
78
+ url: string;
79
+ caption?: string;
80
+ alt?: string;
81
+ };
82
+ hr?: {};
83
+ break?: {};
84
+ maybe_mdx?: {
85
+ children: JSX.Element;
86
+ };
87
+ html?: {
88
+ value: string;
89
+ };
90
+ html_inline?: {
91
+ value: string;
92
+ };
93
+ table?: {
94
+ align?: ('left' | 'right' | 'center')[];
95
+ tableRows: {
96
+ tableCells: {
97
+ value: TinaMarkdownContent;
98
+ }[];
99
+ }[];
100
+ };
101
+ component_missing?: {
102
+ name: string;
103
+ };
104
+ };
105
+ type BaseComponentSignature = {
106
+ [BK in keyof BaseComponents]: (props: BaseComponents[BK]) => JSX.Element;
107
+ };
108
+ /**
109
+ * Define the allowed components and their props
110
+ * ```ts
111
+ * const components:
112
+ * Components<{
113
+ * BlockQuote: {
114
+ * children: TinaMarkdownContent;
115
+ * authorName: string;
116
+ * };
117
+ * }> = {
118
+ * BlockQuote: (props: {
119
+ * children: TinaMarkdownContent;
120
+ * authorName: string;
121
+ * }) => {
122
+ * return (
123
+ * <div>
124
+ * <blockquote>
125
+ * <TinaMarkdown content={props.children} />
126
+ * {props.authorName}
127
+ * </blockquote>
128
+ * </div>
129
+ * );
130
+ * }
131
+ * }
132
+ * }
133
+ * ```
134
+ */
135
+ export type Components<ComponentAndProps extends object> = {
136
+ [K in keyof ComponentAndProps]: (props: ComponentAndProps[K]) => JSX.Element;
137
+ } & BaseComponentSignature;
138
+ export type TinaMarkdownContent = {
139
+ type: string;
140
+ children: TinaMarkdownContent[];
141
+ };
142
+ export declare const TinaMarkdown: <CustomComponents extends {
143
+ [key: string]: object;
144
+ } = any>({ content, components, }: {
145
+ content: TinaMarkdownContent | TinaMarkdownContent[];
146
+ components?: Components<{}> | Components<{ [BK in keyof CustomComponents]: (props: CustomComponents[BK]) => JSX.Element; }>;
147
+ }) => React.JSX.Element;
148
+ export {};