@vonaffenfels/slate-editor 1.0.30 → 1.0.33
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/BlockEditor.css +2 -2
- package/dist/BlockEditor.js +1 -1
- package/dist/index.css +2 -2
- package/dist/index.js +1 -1
- package/package.json +2 -2
- package/scss/sidebarEditor.scss +6 -1
- package/src/SidebarEditor/AssetList.js +14 -18
- package/src/SidebarEditor/SidebarEditorField.js +14 -3
- package/src/SidebarEditor.js +15 -3
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vonaffenfels/slate-editor",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.33",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -71,7 +71,7 @@
|
|
|
71
71
|
"cssnano": "^5.0.1",
|
|
72
72
|
"escape-html": "^1.0.3"
|
|
73
73
|
},
|
|
74
|
-
"gitHead": "
|
|
74
|
+
"gitHead": "a5d858b33c49e6a1a53f90951749159b06452db5",
|
|
75
75
|
"publishConfig": {
|
|
76
76
|
"access": "public"
|
|
77
77
|
}
|
package/scss/sidebarEditor.scss
CHANGED
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
}
|
|
18
18
|
|
|
19
19
|
label {
|
|
20
|
-
margin: 0 0
|
|
20
|
+
margin: 0 0 2px 0 !important;
|
|
21
21
|
}
|
|
22
22
|
|
|
23
23
|
input[type="text"],
|
|
@@ -37,6 +37,11 @@
|
|
|
37
37
|
width: 100% !important;
|
|
38
38
|
padding: 8px 0.75rem !important;
|
|
39
39
|
}
|
|
40
|
+
|
|
41
|
+
textarea {
|
|
42
|
+
height: 42px;
|
|
43
|
+
max-height: 200px;
|
|
44
|
+
}
|
|
40
45
|
|
|
41
46
|
input[type="color"] {
|
|
42
47
|
padding: 4px !important;
|
|
@@ -59,12 +59,6 @@ export const AssetList = ({
|
|
|
59
59
|
return asset;
|
|
60
60
|
});
|
|
61
61
|
|
|
62
|
-
console.log({
|
|
63
|
-
newAssets,
|
|
64
|
-
newAsset,
|
|
65
|
-
assets,
|
|
66
|
-
});
|
|
67
|
-
|
|
68
62
|
onChange(newAssets);
|
|
69
63
|
};
|
|
70
64
|
|
|
@@ -90,12 +84,12 @@ export const Asset = ({
|
|
|
90
84
|
let mediaAssetId = asset?.fields?.media?.["en-US"]?.sys?.id || asset?.fields?.media?.["de"]?.sys?.id || asset?.fields?.media?.sys?.id;
|
|
91
85
|
|
|
92
86
|
if (cloudinary) {
|
|
93
|
-
title = asset.public_id;
|
|
87
|
+
title = asset.public_id || asset.title;
|
|
94
88
|
}
|
|
95
89
|
|
|
96
90
|
useEffect(() => {
|
|
97
91
|
if (cloudinary) {
|
|
98
|
-
setMediaUrl(asset.url);
|
|
92
|
+
setMediaUrl(asset.url || asset?.media?.url);
|
|
99
93
|
|
|
100
94
|
return;
|
|
101
95
|
}
|
|
@@ -161,16 +155,18 @@ export const Asset = ({
|
|
|
161
155
|
<IconButton size="small" onClick={() => onMoveClick("down")} disabled={index === assetsLength - 1}>↓</IconButton>
|
|
162
156
|
</div>
|
|
163
157
|
)}
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
onChange
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
158
|
+
{!cloudinary && (
|
|
159
|
+
<IconButton
|
|
160
|
+
size="small"
|
|
161
|
+
className="mr-1"
|
|
162
|
+
onClick={() => {
|
|
163
|
+
sdk.navigator.openEntry(id, {slideIn: {waitForClose: true}}).then(({entity}) => {
|
|
164
|
+
if (onChange) {
|
|
165
|
+
onChange(entity);
|
|
166
|
+
}
|
|
167
|
+
});
|
|
168
|
+
}}>✎</IconButton>
|
|
169
|
+
)}
|
|
174
170
|
<IconButton size="small" onClick={onDeleteClick}>⨯</IconButton>
|
|
175
171
|
</div>
|
|
176
172
|
</div>
|
|
@@ -69,10 +69,21 @@ export const SidebarEditorField = ({
|
|
|
69
69
|
|
|
70
70
|
switch (field?.control?.type) {
|
|
71
71
|
case "text":
|
|
72
|
-
return <
|
|
72
|
+
return <textarea
|
|
73
73
|
type="text"
|
|
74
74
|
value={value || ""}
|
|
75
|
-
onChange={e =>
|
|
75
|
+
onChange={e => {
|
|
76
|
+
onChange(fieldKey, e.target.value);
|
|
77
|
+
e.target.style.height = "5px";
|
|
78
|
+
e.target.style.height = e.target.scrollHeight + 2 + "px";
|
|
79
|
+
}}
|
|
80
|
+
onBlur={(e) => {
|
|
81
|
+
e.target.style.height = "42px";
|
|
82
|
+
}}
|
|
83
|
+
onFocus={e => {
|
|
84
|
+
e.target.style.height = "5px";
|
|
85
|
+
e.target.style.height = e.target.scrollHeight + 2 + "px";
|
|
86
|
+
}} />;
|
|
76
87
|
case "boolean":
|
|
77
88
|
return (
|
|
78
89
|
<div>
|
|
@@ -362,7 +373,7 @@ export const SidebarEditorField = ({
|
|
|
362
373
|
</div>
|
|
363
374
|
);
|
|
364
375
|
})}
|
|
365
|
-
<button onClick={() => onChange(fieldKey, [...(storybookElement.attributes[fieldKey] || []), {}])}>Neue Zeile</button>
|
|
376
|
+
<button className="button--secondary" onClick={() => onChange(fieldKey, [...(storybookElement.attributes[fieldKey] || []), {}])}>Neue Zeile</button>
|
|
366
377
|
</div>
|
|
367
378
|
</details>
|
|
368
379
|
);
|
package/src/SidebarEditor.js
CHANGED
|
@@ -8,6 +8,8 @@ import "../scss/sidebarEditor.scss";
|
|
|
8
8
|
import {FontAwesomeIcon} from "@fortawesome/react-fontawesome";
|
|
9
9
|
import {faSpinner} from "@fortawesome/free-solid-svg-icons";
|
|
10
10
|
|
|
11
|
+
const devMode = localStorage.getItem("dev-mode") === "true";
|
|
12
|
+
|
|
11
13
|
const SidebarEditor = ({
|
|
12
14
|
sdk,
|
|
13
15
|
storybookElement,
|
|
@@ -169,7 +171,7 @@ const SidebarEditor = ({
|
|
|
169
171
|
return (
|
|
170
172
|
<div id="sidebar-editor">
|
|
171
173
|
{isLoading ? (
|
|
172
|
-
<div className="
|
|
174
|
+
<div className="flex h-full items-center justify-center">
|
|
173
175
|
<FontAwesomeIcon icon={faSpinner} pulse />
|
|
174
176
|
</div>
|
|
175
177
|
) : (
|
|
@@ -208,7 +210,11 @@ const SidebarEditor = ({
|
|
|
208
210
|
</div>
|
|
209
211
|
<div className="grow overflow-y-auto pr-2 pt-2">
|
|
210
212
|
<div className="mb-2">
|
|
211
|
-
<BlockSelect
|
|
213
|
+
<BlockSelect
|
|
214
|
+
stories={storybookStories}
|
|
215
|
+
active={storybookElement}
|
|
216
|
+
onChange={handleBlockSelectChange}
|
|
217
|
+
storyContext={sdk.parameters.instance.storyContext} />
|
|
212
218
|
</div>
|
|
213
219
|
{storybookElement?.block && (
|
|
214
220
|
<div>
|
|
@@ -362,6 +368,7 @@ const BlockSelect = ({
|
|
|
362
368
|
active,
|
|
363
369
|
onChange,
|
|
364
370
|
className,
|
|
371
|
+
storyContext,
|
|
365
372
|
}) => {
|
|
366
373
|
if (!onChange) {
|
|
367
374
|
return null;
|
|
@@ -388,7 +395,12 @@ const BlockSelect = ({
|
|
|
388
395
|
return;
|
|
389
396
|
}
|
|
390
397
|
|
|
391
|
-
|
|
398
|
+
let splitStoryContext = storyContext.split(",");
|
|
399
|
+
let isItemInContext = splitStoryContext.find(context => {
|
|
400
|
+
return Array.isArray(item.storyContext) ? item.storyContext.includes(context) : context === item.storyContext;
|
|
401
|
+
});
|
|
402
|
+
|
|
403
|
+
if (!devMode && !isItemInContext) {
|
|
392
404
|
return;
|
|
393
405
|
}
|
|
394
406
|
|