@vonaffenfels/contentful-slate-editor 1.1.32 → 1.1.34
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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vonaffenfels/contentful-slate-editor",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.34",
|
|
4
4
|
"scripts": {
|
|
5
5
|
"prepublish": "yarn run build",
|
|
6
6
|
"dev": "yarn run start",
|
|
@@ -15,6 +15,8 @@
|
|
|
15
15
|
"@babel/preset-env": "^7.13.15",
|
|
16
16
|
"@babel/preset-react": "^7.13.13",
|
|
17
17
|
"@contentful/app-sdk": "^3.33.0",
|
|
18
|
+
"@contentful/f36-components": "^4.56.2",
|
|
19
|
+
"@contentful/f36-multiselect": "^4.21.0",
|
|
18
20
|
"@contentful/field-editor-single-line": "^0.14.1",
|
|
19
21
|
"@contentful/field-editor-test-utils": "^0.11.1",
|
|
20
22
|
"@contentful/forma-36-fcss": "^0.3.1",
|
|
@@ -93,10 +95,10 @@
|
|
|
93
95
|
"webpack-watch-files-plugin": "^1.2.1"
|
|
94
96
|
},
|
|
95
97
|
"dependencies": {
|
|
96
|
-
"@vonaffenfels/slate-editor": "^1.1.
|
|
98
|
+
"@vonaffenfels/slate-editor": "^1.1.34",
|
|
97
99
|
"webpack": "5.88.2"
|
|
98
100
|
},
|
|
99
|
-
"gitHead": "
|
|
101
|
+
"gitHead": "1e3ea5ff0c721c70b372b3507f1c2ee1f4ff270c",
|
|
100
102
|
"publishConfig": {
|
|
101
103
|
"access": "public"
|
|
102
104
|
}
|
|
@@ -148,6 +148,13 @@ const EditorField = ({
|
|
|
148
148
|
});
|
|
149
149
|
};
|
|
150
150
|
|
|
151
|
+
const slug = sdk?.entry?.fields?.slug?.getForLocale(locale)?.getValue();
|
|
152
|
+
let liveLink = slug ? `${activeConfig.domain}/${slug}` : null;
|
|
153
|
+
|
|
154
|
+
if (slug && sdk?.locales?.default !== locale) {
|
|
155
|
+
liveLink = `${activeConfig.domain}/${locale}/${slug}`;
|
|
156
|
+
}
|
|
157
|
+
|
|
151
158
|
return <div ref={wrapperRef} className="editor-field h-full">
|
|
152
159
|
<BlockEditor
|
|
153
160
|
onChange={onChange}
|
|
@@ -162,7 +169,7 @@ const EditorField = ({
|
|
|
162
169
|
isLoading={isLoadingCount !== 0}
|
|
163
170
|
storybookComponentDataLoader={async (block, attributes) => await getLoaderResult(block, attributes)}
|
|
164
171
|
onStorybookElementClick={onStorybookElementClick}
|
|
165
|
-
|
|
172
|
+
liveLink={liveLink}
|
|
166
173
|
/>
|
|
167
174
|
</div>;
|
|
168
175
|
};
|
|
@@ -22,6 +22,23 @@ const OpenProdPageLink = ({
|
|
|
22
22
|
sdk,
|
|
23
23
|
}) => {
|
|
24
24
|
const [slug, setSlug] = useState(sdk?.entry?.fields?.slug?.getValue());
|
|
25
|
+
const [locale, setLocale] = useState(sdk.locales.default);
|
|
26
|
+
|
|
27
|
+
useEffect(() => {
|
|
28
|
+
const detachHandler = sdk.editor.onLocaleSettingsChanged((loc) => {
|
|
29
|
+
setLocale(loc?.focused || sdk.locales.default);
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
return () => {
|
|
33
|
+
detachHandler();
|
|
34
|
+
};
|
|
35
|
+
}, [sdk]);
|
|
36
|
+
|
|
37
|
+
useEffect(() => {
|
|
38
|
+
if (locale) {
|
|
39
|
+
setSlug(sdk?.entry?.fields?.slug.getForLocale(locale).getValue());
|
|
40
|
+
}
|
|
41
|
+
}, [locale]);
|
|
25
42
|
|
|
26
43
|
useEffect(() => {
|
|
27
44
|
if (sdk?.entry?.fields?.slug) {
|
|
@@ -30,12 +47,17 @@ const OpenProdPageLink = ({
|
|
|
30
47
|
}, [sdk]);
|
|
31
48
|
|
|
32
49
|
const disabled = !activeConfig?.domain || !slug;
|
|
33
|
-
|
|
50
|
+
let link = `${activeConfig.domain}/${slug}`;
|
|
51
|
+
|
|
52
|
+
if (sdk?.locales?.default !== locale) {
|
|
53
|
+
link = `${activeConfig.domain}/${locale}/${slug}`;
|
|
54
|
+
}
|
|
34
55
|
|
|
35
56
|
const onClick = () => {
|
|
36
57
|
if (disabled) {
|
|
37
58
|
return;
|
|
38
59
|
}
|
|
60
|
+
|
|
39
61
|
window.open(link, "_blank");
|
|
40
62
|
};
|
|
41
63
|
|