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.
- package/dist/admin/api.d.ts +4 -1
- package/dist/auth/AuthModal.d.ts +1 -4
- package/dist/auth/TinaCloudProvider.d.ts +0 -1
- package/dist/cache/node-cache.d.ts +6 -2
- package/dist/client.js +240 -181
- package/dist/index.js +122235 -34368
- package/dist/internalClient/index.d.ts +20 -1
- package/dist/react.js +297 -206
- package/dist/rich-text/index.d.ts +6 -0
- package/dist/rich-text/index.js +234 -224
- package/dist/rich-text/prism.js +16 -18
- package/dist/rich-text/static.d.ts +6 -0
- package/dist/rich-text/static.js +229 -225
- package/dist/tina-cms.d.ts +1 -1
- package/dist/toolkit/components/ProgressBar.d.ts +11 -0
- package/dist/toolkit/components/active-field-indicator.d.ts +1 -0
- package/dist/toolkit/components/media/media-item.d.ts +10 -0
- package/dist/toolkit/components/ui/button.d.ts +11 -0
- package/dist/toolkit/components/ui/calendar.d.ts +8 -0
- package/dist/toolkit/components/ui/date-time-picker.d.ts +111 -0
- package/dist/toolkit/components/ui/input.d.ts +3 -0
- package/dist/toolkit/components/ui/popover.d.ts +7 -0
- package/dist/toolkit/components/ui/select.d.ts +13 -0
- package/dist/toolkit/fields/components/color-picker/block-widget.d.ts +3 -0
- package/dist/toolkit/fields/components/color-picker/color-input.d.ts +35 -0
- package/dist/toolkit/fields/components/color-picker/color-picker.d.ts +6 -2
- package/dist/toolkit/fields/components/color-picker/color-utils.d.ts +37 -0
- package/dist/toolkit/fields/components/color-picker/sketch-widget.d.ts +3 -0
- package/dist/toolkit/fields/components/password-field.d.ts +1 -1
- package/dist/toolkit/fields/components/reference/components/button.d.ts +1 -1
- package/dist/toolkit/fields/components/reference/components/command.d.ts +21 -33
- package/dist/toolkit/fields/components/select.d.ts +1 -1
- package/dist/toolkit/fields/components/text-field.d.ts +1 -1
- package/dist/toolkit/fields/plugins/button-toggle-field-plugin.d.ts +2 -2
- package/dist/toolkit/fields/plugins/checkbox-group-field-plugin.d.ts +2 -2
- package/dist/toolkit/fields/plugins/color-field-plugin.d.ts +1 -0
- package/dist/toolkit/fields/plugins/date-field-plugin.d.ts +0 -2
- package/dist/toolkit/fields/plugins/dnd-kit-wrapper.d.ts +49 -0
- package/dist/toolkit/fields/plugins/group-list-field-plugin.d.ts +3 -1
- package/dist/toolkit/fields/plugins/list-field-plugin.d.ts +3 -0
- package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/components/editor.d.ts +20 -18
- package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/components/plate-ui/blockquote-element.d.ts +14 -10
- package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/components/plate-ui/button.d.ts +5 -5
- package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/components/plate-ui/code-block/code-block-element.d.ts +17 -0
- package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/components/plate-ui/code-block/error-message.d.ts +6 -0
- package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/components/plate-ui/code-block-combobox.d.ts +6 -0
- package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/components/plate-ui/code-block-toolbar-button.d.ts +6 -6
- package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/components/plate-ui/code-leaf.d.ts +2 -11
- package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/components/plate-ui/code-line-element.d.ts +14 -10
- package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/components/plate-ui/code-syntax-leaf.d.ts +2 -11
- package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/components/plate-ui/command.d.ts +112 -0
- package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/components/plate-ui/dialog.d.ts +12 -0
- package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/components/plate-ui/dropdown-menu.d.ts +10 -10
- package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/components/plate-ui/floating-toolbar.d.ts +2 -2
- package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/components/plate-ui/hr-element.d.ts +3 -0
- package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/components/plate-ui/hr-toolbar-button.d.ts +18 -0
- package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/components/plate-ui/icons.d.ts +2 -1
- package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/components/plate-ui/image-toolbar-button.d.ts +6 -6
- package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/components/plate-ui/indent-list-toolbar-button.d.ts +6 -19
- package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/components/plate-ui/inline-combobox.d.ts +1 -1
- package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/components/plate-ui/input.d.ts +3 -3
- package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/components/plate-ui/link-element.d.ts +4 -11
- package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/components/plate-ui/link-floating-toolbar.d.ts +4 -5
- package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/components/plate-ui/link-toolbar-button.d.ts +4 -4
- package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/components/plate-ui/list-element.d.ts +28 -11
- package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/components/plate-ui/mermaid-element.d.ts +3 -10
- package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/components/plate-ui/mermaid-toolbar-button.d.ts +6 -8
- package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/components/plate-ui/paragraph-element.d.ts +15 -0
- package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/components/plate-ui/popover.d.ts +7 -2
- package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/components/plate-ui/quote-toolbar-button.d.ts +6 -6
- package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/components/plate-ui/raw-markdown-toolbar-button.d.ts +6 -6
- package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/components/plate-ui/resizable.d.ts +24 -21
- package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/components/plate-ui/separator.d.ts +2 -2
- package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/components/plate-ui/slash-input-element.d.ts +15 -11
- package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/components/plate-ui/table/block-selection.d.ts +6 -0
- package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/components/plate-ui/table/table-cell-element.d.ts +33 -0
- 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
- package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/components/plate-ui/table/table-element.d.ts +20 -0
- package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/components/plate-ui/table/table-row-element.d.ts +15 -0
- package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/components/plate-ui/toolbar.d.ts +7 -7
- package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/components/plate-ui/use-floating-toolbar-hook.d.ts +10 -0
- package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/components/plate-ui/use-floating-toolbar-state.d.ts +22 -0
- package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/hooks/use-create-editor.d.ts +6 -0
- package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/plugins/core/autoformat/autoformat-block.d.ts +1 -1
- package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/plugins/core/autoformat/autoformat-lists.d.ts +1 -1
- package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/plugins/core/autoformat/autoformat-marks.d.ts +1 -1
- package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/plugins/core/autoformat/autoformat-utils.d.ts +3 -5
- package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/plugins/core/common.d.ts +11 -6
- package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/plugins/core/formatting.d.ts +18 -2
- package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/plugins/core/index.d.ts +0 -1
- package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/plugins/create-html-block/index.d.ts +6 -0
- package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/plugins/create-img-plugin/index.d.ts +2 -2
- package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/plugins/create-invalid-markdown-plugin/index.d.ts +5 -5
- package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/plugins/create-mdx-plugins/component.d.ts +7 -4
- package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/plugins/create-mdx-plugins/index.d.ts +3 -5
- package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/plugins/editor-plugins.d.ts +520 -0
- package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/plugins/ui/components.d.ts +262 -207
- package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/plugins/ui/floating-toolbar-plugin.d.ts +1 -0
- package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/toolbar/toolbar-overrides.d.ts +1 -1
- package/dist/toolkit/fields/plugins/radio-group-field-plugin.d.ts +2 -2
- package/dist/toolkit/fields/plugins/select-field-plugin.d.ts +2 -2
- package/dist/toolkit/fields/plugins/toggle-field-plugin.d.ts +2 -2
- package/dist/toolkit/fields/plugins/wrap-field-with-meta.d.ts +6 -2
- package/dist/toolkit/form-builder/create-branch-modal.d.ts +13 -0
- package/dist/toolkit/form-builder/editorial-workflow-constants.d.ts +17 -0
- package/dist/toolkit/form-builder/fields-builder.d.ts +2 -1
- package/dist/toolkit/form-builder/form-builder.d.ts +1 -11
- package/dist/toolkit/form-builder/index.d.ts +1 -0
- package/dist/toolkit/forms/field.d.ts +3 -2
- package/dist/toolkit/icons/TinaExtended.d.ts +4 -0
- package/dist/toolkit/icons/index.d.ts +1 -0
- package/dist/toolkit/index.d.ts +1 -1
- package/dist/toolkit/plugin-branch-switcher/branch-button.d.ts +3 -1
- package/dist/toolkit/react-modals/modal/modal-actions.d.ts +2 -1
- package/dist/toolkit/react-modals/modal/modal-header.d.ts +1 -1
- package/dist/toolkit/react-sidebar/components/NavMenuTrigger.d.ts +11 -0
- package/dist/toolkit/react-sidebar/components/badge.d.ts +6 -0
- package/dist/toolkit/react-sidebar/components/callout.d.ts +5 -0
- package/dist/toolkit/react-sidebar/components/local-warning.d.ts +3 -1
- package/dist/toolkit/react-sidebar/components/nav-components.d.ts +11 -0
- package/dist/toolkit/react-sidebar/components/nav-context.d.ts +15 -0
- package/dist/toolkit/react-sidebar/components/nav.d.ts +3 -2
- package/dist/toolkit/react-sidebar/components/sidebar-body.d.ts +26 -1
- package/dist/toolkit/react-sidebar/index.d.ts +3 -0
- package/dist/toolkit/styles/button.d.ts +1 -1
- package/dist/toolkit/styles/dropdown-button.d.ts +75 -0
- package/dist/toolkit/styles/index.d.ts +1 -0
- package/dist/toolkit/tina-state.d.ts +42 -16
- package/dist/unifiedClient/index.d.ts +1 -1
- package/dist/utils/index.d.ts +1 -0
- package/package.json +56 -87
- package/dist/admin/pages/IndexingPage.d.ts +0 -2
- package/dist/client.mjs +0 -132
- package/dist/index.mjs +0 -35827
- package/dist/node-cache-5e8db9f0.mjs +0 -63
- package/dist/react.mjs +0 -254
- package/dist/rich-text/index.mjs +0 -243
- package/dist/rich-text/prism.mjs +0 -16
- package/dist/rich-text/static.mjs +0 -236
- package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/components/plate-ui/code-block-element.d.ts +0 -11
- package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/components/plate-ui/table-cell-element.d.ts +0 -27
- package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/components/plate-ui/table-element.d.ts +0 -14
- package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/components/plate-ui/table-row-element.d.ts +0 -13
- package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/plugins/core/with-correct-void-behavior.d.ts +0 -8
- package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/plugins/create-code-block/index.d.ts +0 -3
- package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/plugins/create-link-plugin/index.d.ts +0 -15
- package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/plugins/custom/mermaid-plugin.d.ts +0 -2
- package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/plugins/soft-break/create-soft-break-plugin.d.ts +0 -7
- package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/plugins/soft-break/index.d.ts +0 -6
- package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/plugins/soft-break/on-key-down-soft-break.d.ts +0 -5
- package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/plugins/soft-break/types.d.ts +0 -11
- package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/plugins/ui/code-block/index.d.ts +0 -11
- package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/transforms/insert-empty-block.d.ts +0 -2
- package/dist/toolkit/react-datetime/DateTime.d.ts +0 -135
- package/dist/toolkit/react-sidebar/components/alert.d.ts +0 -5
- /package/dist/admin/components/{Sidebar.d.ts → AdminNav.d.ts} +0 -0
|
@@ -2,7 +2,7 @@ import { BranchData, EventBus } from '@tinacms/toolkit';
|
|
|
2
2
|
import { DocumentNode, GraphQLSchema } from 'graphql';
|
|
3
3
|
import { TokenObject } from '../auth/authenticate';
|
|
4
4
|
import { AuthProvider, Schema, TinaSchema } from '@tinacms/schema-tools';
|
|
5
|
-
import { SearchClient } from '@tinacms/search/
|
|
5
|
+
import { SearchClient } from '@tinacms/search/index-client';
|
|
6
6
|
import gql from 'graphql-tag';
|
|
7
7
|
import { TinaCloudProject } from './types';
|
|
8
8
|
export * from './authProvider';
|
|
@@ -142,6 +142,25 @@ export declare class Client {
|
|
|
142
142
|
usingProtectedBranch(): boolean;
|
|
143
143
|
createBranch({ baseBranch, branchName }: BranchData): Promise<string>;
|
|
144
144
|
getLatestVersion(): Promise<LatestVersionResponse>;
|
|
145
|
+
/**
|
|
146
|
+
* Initiate and poll for the results of an editorial workflow operation
|
|
147
|
+
*
|
|
148
|
+
* @param options Editorial workflow options
|
|
149
|
+
* @returns Object with branch and PR info when complete
|
|
150
|
+
*/
|
|
151
|
+
executeEditorialWorkflow(options: {
|
|
152
|
+
branchName: string;
|
|
153
|
+
baseBranch: string;
|
|
154
|
+
prTitle?: string;
|
|
155
|
+
graphQLContentOp?: {
|
|
156
|
+
query: string;
|
|
157
|
+
variables: Record<string, unknown>;
|
|
158
|
+
};
|
|
159
|
+
onStatusUpdate?: (status: {
|
|
160
|
+
status: string;
|
|
161
|
+
message?: string;
|
|
162
|
+
}) => void;
|
|
163
|
+
}): Promise<any>;
|
|
145
164
|
}
|
|
146
165
|
export declare const DEFAULT_LOCAL_TINA_GQL_SERVER_URL = "http://localhost:4001/graphql";
|
|
147
166
|
export declare class LocalClient extends Client {
|
package/dist/react.js
CHANGED
|
@@ -1,73 +1,113 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
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
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
setData(processedData);
|
|
27
|
-
parent.postMessage({
|
|
28
|
-
type: "url-changed"
|
|
29
|
-
});
|
|
30
|
-
}, [id, processedData]);
|
|
31
|
-
React.useEffect(() => {
|
|
32
|
-
if (quickEditEnabled) {
|
|
33
|
-
let mouseDownHandler = function(e) {
|
|
34
|
-
const attributeNames = e.target.getAttributeNames();
|
|
35
|
-
const tinaAttribute = attributeNames.find(
|
|
36
|
-
(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]"
|
|
37
43
|
);
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
fieldName = e.target.getAttribute(tinaAttribute);
|
|
43
|
-
} else {
|
|
44
|
-
const ancestor = e.target.closest(
|
|
45
|
-
"[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")
|
|
46
48
|
);
|
|
47
|
-
if (
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
);
|
|
52
|
-
if (tinaAttribute2) {
|
|
53
|
-
e.preventDefault();
|
|
54
|
-
e.stopPropagation();
|
|
55
|
-
fieldName = ancestor.getAttribute(tinaAttribute2);
|
|
56
|
-
}
|
|
49
|
+
if (tinaAttribute2) {
|
|
50
|
+
e.preventDefault();
|
|
51
|
+
e.stopPropagation();
|
|
52
|
+
fieldName = ancestor.getAttribute(tinaAttribute2);
|
|
57
53
|
}
|
|
58
54
|
}
|
|
59
|
-
|
|
55
|
+
}
|
|
56
|
+
if (fieldName) {
|
|
57
|
+
if (lastHoveredField !== null) {
|
|
58
|
+
lastHoveredField = null;
|
|
60
59
|
if (isInTinaIframe) {
|
|
61
60
|
parent.postMessage(
|
|
62
|
-
{ type: "field:
|
|
61
|
+
{ type: "field:hovered", fieldName: null },
|
|
63
62
|
window.location.origin
|
|
64
63
|
);
|
|
65
64
|
}
|
|
66
65
|
}
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
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 = `
|
|
71
111
|
[data-tina-field] {
|
|
72
112
|
outline: 2px dashed rgba(34,150,254,0.5);
|
|
73
113
|
transition: box-shadow ease-out 150ms;
|
|
@@ -77,6 +117,15 @@
|
|
|
77
117
|
outline: 2px solid rgba(34,150,254,1);
|
|
78
118
|
cursor: pointer;
|
|
79
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
|
+
}
|
|
80
129
|
[data-tina-field-overlay] {
|
|
81
130
|
outline: 2px dashed rgba(34,150,254,0.5);
|
|
82
131
|
position: relative;
|
|
@@ -97,161 +146,203 @@
|
|
|
97
146
|
[data-tina-field-overlay]:hover::after {
|
|
98
147
|
opacity: 1;
|
|
99
148
|
}
|
|
149
|
+
[data-tina-field-overlay][data-tina-field-focused]::after {
|
|
150
|
+
background-color: rgba(194, 65, 12, 0.3);
|
|
151
|
+
opacity: 1;
|
|
152
|
+
}
|
|
100
153
|
`;
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
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);
|
|
159
|
+
return () => {
|
|
160
|
+
document.removeEventListener("click", mouseDownHandler, true);
|
|
161
|
+
document.removeEventListener("mouseenter", mouseEnterHandler, true);
|
|
162
|
+
document.body.classList.remove("__tina-quick-editing-enabled");
|
|
163
|
+
style.remove();
|
|
164
|
+
};
|
|
165
|
+
}
|
|
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);
|
|
109
182
|
}
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
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
|
+
}
|
|
117
204
|
}
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
const handleMessage = (event) => {
|
|
123
|
-
if (event.data.type === "quickEditEnabled") {
|
|
124
|
-
setQuickEditEnabled(event.data.value);
|
|
205
|
+
if (event.data.type === "field:set-focused") {
|
|
206
|
+
const newFieldName = event.data.fieldName;
|
|
207
|
+
if (newFieldName === lastFocusedFieldRef.current) {
|
|
208
|
+
return;
|
|
125
209
|
}
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
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}"]`
|
|
132
218
|
);
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
window.location.origin
|
|
140
|
-
);
|
|
141
|
-
} else {
|
|
142
|
-
parent.postMessage(
|
|
143
|
-
{ type: "quick-edit", value: false },
|
|
144
|
-
window.location.origin
|
|
145
|
-
);
|
|
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
|
+
});
|
|
146
225
|
}
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
function useEditState() {
|
|
158
|
-
const [edit, setEdit] = React.useState(false);
|
|
159
|
-
React.useEffect(() => {
|
|
160
|
-
if (typeof window !== "undefined") {
|
|
161
|
-
parent.postMessage({ type: "isEditMode" }, window.location.origin);
|
|
162
|
-
window.addEventListener("message", (event) => {
|
|
163
|
-
var _a;
|
|
164
|
-
if (((_a = event.data) == null ? void 0 : _a.type) === "tina:editMode") {
|
|
165
|
-
setEdit(true);
|
|
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
|
+
}
|
|
166
236
|
}
|
|
167
|
-
}
|
|
168
|
-
}
|
|
169
|
-
}, []);
|
|
170
|
-
return { edit };
|
|
171
|
-
}
|
|
172
|
-
const tinaField = (object, property, index) => {
|
|
173
|
-
const contentSource = object == null ? void 0 : object._content_source;
|
|
174
|
-
if (!contentSource) {
|
|
175
|
-
return "";
|
|
176
|
-
}
|
|
177
|
-
const { queryId, path } = contentSource;
|
|
178
|
-
if (!property) {
|
|
179
|
-
return `${queryId}---${path.join(".")}`;
|
|
180
|
-
}
|
|
181
|
-
const fullPath = typeof index === "number" ? [...path, property, index] : [...path, property];
|
|
182
|
-
return `${queryId}---${fullPath.join(".")}`;
|
|
183
|
-
};
|
|
184
|
-
const addMetadata = (id, obj, path = []) => {
|
|
185
|
-
if (obj === null) {
|
|
186
|
-
return obj;
|
|
187
|
-
}
|
|
188
|
-
if (isScalarOrUndefined(obj)) {
|
|
189
|
-
return obj;
|
|
190
|
-
}
|
|
191
|
-
if (obj instanceof String) {
|
|
192
|
-
return obj.valueOf();
|
|
193
|
-
}
|
|
194
|
-
if (Array.isArray(obj)) {
|
|
195
|
-
return obj.map(
|
|
196
|
-
(item, index) => addMetadata(id, item, [...path, index])
|
|
197
|
-
);
|
|
198
|
-
}
|
|
199
|
-
const transformedObj = {};
|
|
200
|
-
for (const [key, value] of Object.entries(obj)) {
|
|
201
|
-
const currentPath = [...path, key];
|
|
202
|
-
if ([
|
|
203
|
-
"__typename",
|
|
204
|
-
"_sys",
|
|
205
|
-
"_internalSys",
|
|
206
|
-
"_values",
|
|
207
|
-
"_internalValues",
|
|
208
|
-
"_content_source",
|
|
209
|
-
"_tina_metadata"
|
|
210
|
-
].includes(key)) {
|
|
211
|
-
transformedObj[key] = value;
|
|
212
|
-
} else {
|
|
213
|
-
transformedObj[key] = addMetadata(id, value, currentPath);
|
|
237
|
+
}
|
|
214
238
|
}
|
|
239
|
+
};
|
|
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
|
+
});
|
|
215
259
|
}
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
if (type === "string")
|
|
224
|
-
return true;
|
|
225
|
-
if (type === "number")
|
|
226
|
-
return true;
|
|
227
|
-
if (type === "boolean")
|
|
228
|
-
return true;
|
|
229
|
-
if (type === "undefined")
|
|
230
|
-
return true;
|
|
231
|
-
if (value == null)
|
|
232
|
-
return true;
|
|
233
|
-
if (value instanceof String)
|
|
234
|
-
return true;
|
|
235
|
-
if (value instanceof Number)
|
|
236
|
-
return true;
|
|
237
|
-
if (value instanceof Boolean)
|
|
238
|
-
return true;
|
|
239
|
-
return false;
|
|
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 "";
|
|
240
267
|
}
|
|
241
|
-
const
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
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);
|
|
246
305
|
}
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
return
|
|
250
|
-
}
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
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
|
+
};
|
|
@@ -58,9 +58,15 @@ type BaseComponents = {
|
|
|
58
58
|
lic?: {
|
|
59
59
|
children: JSX.Element;
|
|
60
60
|
};
|
|
61
|
+
/**
|
|
62
|
+
* @deprecated Use `blockquote` instead. This was incorrectly named and will be removed in a future version.
|
|
63
|
+
*/
|
|
61
64
|
block_quote?: {
|
|
62
65
|
children: JSX.Element;
|
|
63
66
|
};
|
|
67
|
+
blockquote?: {
|
|
68
|
+
children: JSX.Element;
|
|
69
|
+
};
|
|
64
70
|
code_block?: {
|
|
65
71
|
lang?: string;
|
|
66
72
|
value: string;
|