@vonaffenfels/contentful-slate-editor 1.1.26 → 1.1.28
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.28",
|
|
4
4
|
"scripts": {
|
|
5
5
|
"prepublish": "yarn run build",
|
|
6
6
|
"dev": "yarn run start",
|
|
@@ -56,6 +56,8 @@
|
|
|
56
56
|
"@babel/preset-env": "^7.13.15",
|
|
57
57
|
"@babel/preset-react": "^7.13.13",
|
|
58
58
|
"@contentful/app-sdk": "^3.33.0",
|
|
59
|
+
"@contentful/f36-components": "^4.56.2",
|
|
60
|
+
"@contentful/f36-multiselect": "^4.21.0",
|
|
59
61
|
"@contentful/field-editor-single-line": "^0.14.1",
|
|
60
62
|
"@contentful/field-editor-test-utils": "^0.11.1",
|
|
61
63
|
"@contentful/forma-36-fcss": "^0.3.1",
|
|
@@ -91,10 +93,10 @@
|
|
|
91
93
|
"webpack-watch-files-plugin": "^1.2.1"
|
|
92
94
|
},
|
|
93
95
|
"dependencies": {
|
|
94
|
-
"@vonaffenfels/slate-editor": "^1.1.
|
|
96
|
+
"@vonaffenfels/slate-editor": "^1.1.28",
|
|
95
97
|
"webpack": "5.88.2"
|
|
96
98
|
},
|
|
97
|
-
"gitHead": "
|
|
99
|
+
"gitHead": "a600552bfcbd6e605f8ababe0f4ef6f3222ac58a",
|
|
98
100
|
"publishConfig": {
|
|
99
101
|
"access": "public"
|
|
100
102
|
}
|
|
@@ -1,83 +1,112 @@
|
|
|
1
|
-
import React, {
|
|
1
|
+
import React, {
|
|
2
|
+
useEffect, useState,
|
|
3
|
+
} from 'react';
|
|
2
4
|
import {
|
|
3
|
-
Heading, Form, TextField, Workbench,
|
|
5
|
+
Heading, Form, TextField, Workbench,
|
|
4
6
|
} from '@contentful/forma-36-react-components';
|
|
7
|
+
import {FormControl} from '@contentful/f36-components';
|
|
8
|
+
import {Multiselect} from '@contentful/f36-multiselect';
|
|
5
9
|
import {css} from 'emotion';
|
|
6
10
|
|
|
7
|
-
|
|
11
|
+
const Config = ({sdk}) => {
|
|
12
|
+
const [params, setParams] = useState({
|
|
13
|
+
translationService: "",
|
|
14
|
+
usersWithTranslation: [],
|
|
15
|
+
});
|
|
16
|
+
const [spaceUsers, setSpaceUsers] = useState([]);
|
|
8
17
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
this.state = {parameters: {}};
|
|
18
|
+
const onConfigure = async () => {
|
|
19
|
+
const currentState = await sdk.app.getCurrentState();
|
|
12
20
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
async componentDidMount() {
|
|
20
|
-
// Get current parameters of the app.
|
|
21
|
-
// If the app is not installed yet, `parameters` will be `null`.
|
|
22
|
-
const parameters = await this.props.sdk.app.getParameters();
|
|
21
|
+
return {
|
|
22
|
+
parameters: params,
|
|
23
|
+
targetState: currentState,
|
|
24
|
+
};
|
|
25
|
+
};
|
|
23
26
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
27
|
+
const onFieldChanged = (value, field) => {
|
|
28
|
+
setParams({
|
|
29
|
+
...params,
|
|
30
|
+
[field]: value,
|
|
28
31
|
});
|
|
29
|
-
}
|
|
32
|
+
};
|
|
30
33
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
34
|
+
useEffect(() => {
|
|
35
|
+
if (sdk) {
|
|
36
|
+
sdk.app.getParameters().then(params => {
|
|
37
|
+
setParams(params);
|
|
38
|
+
sdk.app.setReady();
|
|
39
|
+
});
|
|
40
|
+
sdk.space.getUsers().then(users => {
|
|
41
|
+
setSpaceUsers(users.items.map(v => v.email));
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
}, [sdk]);
|
|
35
45
|
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
46
|
+
useEffect(() => {
|
|
47
|
+
if (sdk) {
|
|
48
|
+
sdk.app.onConfigure(() => onConfigure());
|
|
49
|
+
}
|
|
50
|
+
}, [sdk, params]);
|
|
39
51
|
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
52
|
+
const handleSelectItem = (event) => {
|
|
53
|
+
const {
|
|
54
|
+
checked,
|
|
55
|
+
value,
|
|
56
|
+
} = event.target;
|
|
57
|
+
|
|
58
|
+
let newValue = params?.usersWithTranslation || [];
|
|
59
|
+
if (checked) {
|
|
60
|
+
newValue = [...newValue, value];
|
|
61
|
+
} else {
|
|
62
|
+
newValue = newValue.filter((email) => email !== value);
|
|
63
|
+
}
|
|
48
64
|
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
...this.state.parameters,
|
|
53
|
-
[field]: value,
|
|
54
|
-
},
|
|
65
|
+
setParams({
|
|
66
|
+
...params,
|
|
67
|
+
usersWithTranslation: newValue,
|
|
55
68
|
});
|
|
56
|
-
}
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
return (
|
|
73
|
+
<Workbench className={css({
|
|
74
|
+
padding: '80px',
|
|
75
|
+
backgroundColor: "#FFF",
|
|
76
|
+
})}>
|
|
77
|
+
<Form>
|
|
78
|
+
<Heading>Configuration</Heading>
|
|
57
79
|
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
</
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
80
|
+
<FormControl>
|
|
81
|
+
<FormControl.Label>Benutzer mit Übersetzung im Editor</FormControl.Label>
|
|
82
|
+
<Multiselect
|
|
83
|
+
currentSelection={params.usersWithTranslation}
|
|
84
|
+
popoverProps={{isFullWidth: true}}
|
|
85
|
+
>
|
|
86
|
+
{spaceUsers.map((userEmail) => {
|
|
87
|
+
const val = userEmail.toLowerCase().replace(/\s/g, '-');
|
|
88
|
+
return (
|
|
89
|
+
<Multiselect.Option
|
|
90
|
+
key={`user-${val}}`}
|
|
91
|
+
itemId={val}
|
|
92
|
+
value={userEmail}
|
|
93
|
+
label={userEmail}
|
|
94
|
+
onSelectItem={handleSelectItem}
|
|
95
|
+
isChecked={params.usersWithTranslation?.includes(userEmail)}
|
|
96
|
+
/>
|
|
97
|
+
);
|
|
98
|
+
})}
|
|
99
|
+
</Multiselect>
|
|
100
|
+
</FormControl>
|
|
101
|
+
<TextField
|
|
102
|
+
value={params.translationService}
|
|
103
|
+
onChange={e => onFieldChanged(e.target.value, "translationService")}
|
|
104
|
+
labelText="Translation Service URL"
|
|
105
|
+
required
|
|
106
|
+
/>
|
|
107
|
+
</Form>
|
|
108
|
+
</Workbench>
|
|
109
|
+
);
|
|
110
|
+
};
|
|
82
111
|
|
|
83
|
-
|
|
112
|
+
export default Config;
|
|
@@ -22,6 +22,7 @@ const EditorField = ({
|
|
|
22
22
|
sdk,
|
|
23
23
|
portal,
|
|
24
24
|
locale,
|
|
25
|
+
setLocale,
|
|
25
26
|
onStorybookElementClick,
|
|
26
27
|
elementPropsMap,
|
|
27
28
|
activeConfig,
|
|
@@ -151,6 +152,8 @@ const EditorField = ({
|
|
|
151
152
|
<BlockEditor
|
|
152
153
|
onChange={onChange}
|
|
153
154
|
value={validateValue(value)}
|
|
155
|
+
locale={locale}
|
|
156
|
+
setLocale={setLocale}
|
|
154
157
|
contentfulSdk={sdk}
|
|
155
158
|
config={JSON.parse("{}")}
|
|
156
159
|
elementPropsMap={elementPropsMap}
|