@tinacms/vercel-previews 0.2.4 → 0.2.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +1 -27
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -1,32 +1,6 @@
|
|
|
1
1
|
import { vercelStegaCombine } from "@vercel/stega";
|
|
2
2
|
import React, { useCallback, useEffect } from "react";
|
|
3
|
-
|
|
4
|
-
const [edit, setEdit] = React.useState(false);
|
|
5
|
-
React.useEffect(() => {
|
|
6
|
-
if (typeof window !== "undefined") {
|
|
7
|
-
parent.postMessage({ type: "isEditMode" }, window.location.origin);
|
|
8
|
-
window.addEventListener("message", (event) => {
|
|
9
|
-
var _a;
|
|
10
|
-
if (((_a = event.data) == null ? void 0 : _a.type) === "tina:editMode") {
|
|
11
|
-
setEdit(true);
|
|
12
|
-
}
|
|
13
|
-
});
|
|
14
|
-
}
|
|
15
|
-
}, []);
|
|
16
|
-
return { edit };
|
|
17
|
-
}
|
|
18
|
-
const tinaField = (object, property, index) => {
|
|
19
|
-
const contentSource = object == null ? void 0 : object._content_source;
|
|
20
|
-
if (!contentSource) {
|
|
21
|
-
return "";
|
|
22
|
-
}
|
|
23
|
-
const { queryId, path } = contentSource;
|
|
24
|
-
if (!property) {
|
|
25
|
-
return `${queryId}---${path.join(".")}`;
|
|
26
|
-
}
|
|
27
|
-
const fullPath = typeof index === "number" ? [...path, property, index] : [...path, property];
|
|
28
|
-
return `${queryId}---${fullPath.join(".")}`;
|
|
29
|
-
};
|
|
3
|
+
import { tinaField, useEditState } from "tinacms/react";
|
|
30
4
|
const vercelEditInfo = (obj, field, index) => {
|
|
31
5
|
const fieldName = tinaField(obj, field, index);
|
|
32
6
|
return JSON.stringify({ origin: "tinacms", data: { fieldName } });
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tinacms/vercel-previews",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.2.
|
|
4
|
+
"version": "0.2.6",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
7
7
|
"keywords": [
|
|
@@ -30,11 +30,11 @@
|
|
|
30
30
|
"@types/react": "^18.3.18",
|
|
31
31
|
"react": "^18.3.1",
|
|
32
32
|
"typescript": "^5.7.3",
|
|
33
|
-
"@tinacms/scripts": "1.6.
|
|
33
|
+
"@tinacms/scripts": "1.6.1"
|
|
34
34
|
},
|
|
35
35
|
"dependencies": {
|
|
36
36
|
"@vercel/stega": "^0.0.5",
|
|
37
|
-
"tinacms": "3.7.
|
|
37
|
+
"tinacms": "3.7.6"
|
|
38
38
|
},
|
|
39
39
|
"peerDependencies": {
|
|
40
40
|
"react": ">=16.14"
|