@vonaffenfels/contentful-slate-editor 1.0.3 → 1.0.5
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 +44 -5
- package/src/components/ConfigScreen.js +13 -1
- package/src/components/Dialog.js +21 -18
- package/src/components/DialogCloudinary.js +2 -2
- package/src/components/Field.js +46 -8
- package/src/dev.js +4 -0
- package/src/index.js +5 -3
- package/src/scss/dev.scss +0 -0
- package/src/scss/index.scss +4 -0
- package/tailwind.config.js +1 -2
- package/webpack.config.dev.js +4 -1
- package/webpack.config.js +18 -2
package/package.json
CHANGED
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vonaffenfels/contentful-slate-editor",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.5",
|
|
4
4
|
"scripts": {
|
|
5
5
|
"prepublish": "yarn run build",
|
|
6
6
|
"dev": "yarn run start",
|
|
7
7
|
"test": "echo \"Error: no test specified\" && exit 1",
|
|
8
8
|
"build": "echo \"Don't build this module!\"",
|
|
9
|
-
"start": "webpack serve --config webpack.config.dev.js"
|
|
10
|
-
"vercelDev": "cp ./.vercel.project.json ../../.vercel/project.json && cd ../../ && vercel dev"
|
|
9
|
+
"start": "webpack serve --config webpack.config.dev.js"
|
|
11
10
|
},
|
|
12
11
|
"peerDependencies": {
|
|
13
12
|
"@babel/core": "^7.20.12",
|
|
@@ -49,11 +48,51 @@
|
|
|
49
48
|
"webpack-cli": "^4.6.0",
|
|
50
49
|
"webpack-dev-server": "^4.0.0-beta.2"
|
|
51
50
|
},
|
|
51
|
+
"devDependencies": {
|
|
52
|
+
"@babel/core": "^7.20.12",
|
|
53
|
+
"@babel/plugin-proposal-class-properties": "^7.13.0",
|
|
54
|
+
"@babel/plugin-syntax-dynamic-import": "^7.8.3",
|
|
55
|
+
"@babel/preset-env": "^7.13.15",
|
|
56
|
+
"@babel/preset-react": "^7.13.13",
|
|
57
|
+
"@contentful/app-sdk": "^3.33.0",
|
|
58
|
+
"@contentful/field-editor-single-line": "^0.14.1",
|
|
59
|
+
"@contentful/field-editor-test-utils": "^0.11.1",
|
|
60
|
+
"@contentful/forma-36-fcss": "^0.3.1",
|
|
61
|
+
"@contentful/forma-36-react-components": "^3.88.3",
|
|
62
|
+
"@contentful/forma-36-tokens": "^0.10.1",
|
|
63
|
+
"@svgr/webpack": "^5.5.0",
|
|
64
|
+
"babel-loader": "^8.2.2",
|
|
65
|
+
"clean-webpack-plugin": "^3.0.0",
|
|
66
|
+
"cloudinary": "^1.25.1",
|
|
67
|
+
"contentful-management": "^7.17.0",
|
|
68
|
+
"copy-webpack-plugin": "^8.1.1",
|
|
69
|
+
"cross-env": "^7.0.3",
|
|
70
|
+
"css-loader": "^5.2.4",
|
|
71
|
+
"cssnano": "^5.0.1",
|
|
72
|
+
"dotenv-webpack": "^7.0.2",
|
|
73
|
+
"file-loader": "^6.2.0",
|
|
74
|
+
"html-webpack-plugin": "^5.3.1",
|
|
75
|
+
"mini-css-extract-plugin": "^1.5.0",
|
|
76
|
+
"postcss": "8.4.14",
|
|
77
|
+
"postcss-loader": "^5.2.0",
|
|
78
|
+
"raw-loader": "^4.0.2",
|
|
79
|
+
"react": "18.2.0",
|
|
80
|
+
"react-dom": "18.2.0",
|
|
81
|
+
"react-uid": "^2.3.1",
|
|
82
|
+
"sass": "^1.32.11",
|
|
83
|
+
"sass-loader": "^11.0.1",
|
|
84
|
+
"speakingurl": "^14.0.1",
|
|
85
|
+
"style-loader": "^2.0.0",
|
|
86
|
+
"tailwindcss": "3.3.2",
|
|
87
|
+
"url-loader": "^4.1.1",
|
|
88
|
+
"webpack-cli": "^4.6.0",
|
|
89
|
+
"webpack-dev-server": "^4.0.0-beta.2"
|
|
90
|
+
},
|
|
52
91
|
"dependencies": {
|
|
53
|
-
"@vonaffenfels/slate-editor": "^1.0.
|
|
92
|
+
"@vonaffenfels/slate-editor": "^1.0.5",
|
|
54
93
|
"webpack": "5.73.0"
|
|
55
94
|
},
|
|
56
|
-
"gitHead": "
|
|
95
|
+
"gitHead": "718a65757ab690aa3e2df05274a9c401ce466b6e",
|
|
57
96
|
"publishConfig": {
|
|
58
97
|
"access": "public"
|
|
59
98
|
}
|
|
@@ -62,7 +62,19 @@ export default class Config extends Component {
|
|
|
62
62
|
backgroundColor: "#FFF",
|
|
63
63
|
})}>
|
|
64
64
|
<Form>
|
|
65
|
-
<Heading>
|
|
65
|
+
<Heading>Configuration</Heading>
|
|
66
|
+
<TextField
|
|
67
|
+
value={this.state.parameters.cloudinaryApiKey}
|
|
68
|
+
onChange={e => this.onFieldChanged(e.target.value, "cloudinaryApiKey")}
|
|
69
|
+
labelText="Cloudinary API Key"
|
|
70
|
+
required
|
|
71
|
+
/>
|
|
72
|
+
<TextField
|
|
73
|
+
value={this.state.parameters.cloudinaryCloudName}
|
|
74
|
+
onChange={e => this.onFieldChanged(e.target.value, "cloudinaryCloudName")}
|
|
75
|
+
labelText="Cloudinary Cloud Name"
|
|
76
|
+
required
|
|
77
|
+
/>
|
|
66
78
|
</Form>
|
|
67
79
|
</Workbench>
|
|
68
80
|
);
|
package/src/components/Dialog.js
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
import React, {
|
|
1
|
+
import React, {
|
|
2
|
+
useEffect, useState,
|
|
3
|
+
} from 'react';
|
|
2
4
|
import DialogCloudinary from "./DialogCloudinary";
|
|
3
5
|
import componentLoader from "@vonaffenfels/slate-editor/componentLoader";
|
|
4
6
|
// eslint-disable-next-line import/no-unresolved
|
|
@@ -24,7 +26,7 @@ const Dialog = ({sdk}) => {
|
|
|
24
26
|
|
|
25
27
|
const saveChanges = () => {
|
|
26
28
|
sdk.close(value);
|
|
27
|
-
}
|
|
29
|
+
};
|
|
28
30
|
|
|
29
31
|
useEffect(() => {
|
|
30
32
|
loadStories();
|
|
@@ -34,23 +36,24 @@ const Dialog = ({sdk}) => {
|
|
|
34
36
|
case "cloudinary":
|
|
35
37
|
return <DialogCloudinary sdk={sdk} config={sdk.parameters.invocation}/>;
|
|
36
38
|
default:
|
|
37
|
-
return <div>
|
|
38
|
-
<
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
39
|
+
return <div className="relative flex h-full max-h-full justify-between">
|
|
40
|
+
<div className="grow">
|
|
41
|
+
<BlockEditor
|
|
42
|
+
storybookStories={loadedStorybookStories}
|
|
43
|
+
onChange={setValue}
|
|
44
|
+
elementPropsMap={{}}
|
|
45
|
+
value={value}
|
|
46
|
+
storybookComponentLoader={(block) => {
|
|
47
|
+
return componentLoader(block);
|
|
48
|
+
}}
|
|
49
|
+
storybookComponentDataLoader={async (block, attributes) => {
|
|
50
|
+
return {};
|
|
51
|
+
}}
|
|
52
|
+
contentfulSdk={sdk}
|
|
53
|
+
onSaveClick={saveChanges}
|
|
54
|
+
/>
|
|
52
55
|
</div>
|
|
53
|
-
</div
|
|
56
|
+
</div>;
|
|
54
57
|
}
|
|
55
58
|
};
|
|
56
59
|
|
|
@@ -9,8 +9,8 @@ const DialogCloudinary = ({
|
|
|
9
9
|
sdk,
|
|
10
10
|
config,
|
|
11
11
|
}) => {
|
|
12
|
-
const cloudinaryApiKey =
|
|
13
|
-
const cloudinaryCloudName =
|
|
12
|
+
const cloudinaryApiKey = sdk?.parameters?.installation?.cloudinaryApiKey;
|
|
13
|
+
const cloudinaryCloudName = sdk?.parameters?.installation?.cloudinaryCloudName;
|
|
14
14
|
|
|
15
15
|
const cloudinaryRef = useRef(null);
|
|
16
16
|
|
package/src/components/Field.js
CHANGED
|
@@ -1,5 +1,15 @@
|
|
|
1
|
-
import React
|
|
1
|
+
import React, {
|
|
2
|
+
useEffect, useRef, useState,
|
|
3
|
+
} from 'react';
|
|
4
|
+
import Renderer from "@vonaffenfels/slate-editor/dist/Renderer";
|
|
5
|
+
import componentLoader from "@vonaffenfels/slate-editor/componentLoader.js";
|
|
6
|
+
|
|
7
|
+
const FIELD_HEIGHT = 300;
|
|
8
|
+
|
|
2
9
|
const Field = ({sdk}) => {
|
|
10
|
+
const [value, setValue] = useState(sdk.field.getValue());
|
|
11
|
+
const wrapperRef = useRef();
|
|
12
|
+
|
|
3
13
|
const openDialog = () => {
|
|
4
14
|
console.log("KIENZ_DEBUG: :14 / openDialog", sdk.field.getValue());
|
|
5
15
|
|
|
@@ -11,20 +21,48 @@ const Field = ({sdk}) => {
|
|
|
11
21
|
shouldCloseOnOverlayClick: false,
|
|
12
22
|
shouldCloseOnEscapePress: false,
|
|
13
23
|
minHeight: 500,
|
|
14
|
-
parameters: {
|
|
15
|
-
value: sdk.field.getValue(),
|
|
16
|
-
},
|
|
24
|
+
parameters: {value: sdk.field.getValue()},
|
|
17
25
|
}).then((data) => {
|
|
18
26
|
console.log("KIENZ_DEBUG: :26 / ANON", data);
|
|
19
27
|
if (data) {
|
|
20
28
|
sdk.field.setValue(data);
|
|
21
29
|
}
|
|
22
30
|
});
|
|
23
|
-
}
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
useEffect(() => {
|
|
34
|
+
sdk.window.updateHeight(FIELD_HEIGHT);
|
|
35
|
+
|
|
36
|
+
sdk.field.onValueChanged(handleValueChanged);
|
|
37
|
+
|
|
38
|
+
console.log({sdk});
|
|
39
|
+
}, []);
|
|
40
|
+
|
|
41
|
+
const handleValueChanged = value => {
|
|
42
|
+
setValue(value);
|
|
43
|
+
|
|
44
|
+
setInterval(() => {
|
|
45
|
+
if (wrapperRef.current) {
|
|
46
|
+
sdk.window.updateHeight(wrapperRef.current.clientHeight);
|
|
47
|
+
}
|
|
48
|
+
}, 500);
|
|
49
|
+
};
|
|
24
50
|
|
|
25
|
-
return <div
|
|
26
|
-
|
|
27
|
-
|
|
51
|
+
return <div
|
|
52
|
+
ref={wrapperRef}
|
|
53
|
+
>
|
|
54
|
+
<button onClick={openDialog} className="mb-2 w-full">Inhalt bearbeiten</button>
|
|
55
|
+
<div style={{
|
|
56
|
+
overflowY: "auto",
|
|
57
|
+
maxHeight: "500px",
|
|
58
|
+
}}>
|
|
59
|
+
<Renderer
|
|
60
|
+
value={value}
|
|
61
|
+
storybookComponentLoader={(block) => {
|
|
62
|
+
return componentLoader(block);
|
|
63
|
+
}}/>
|
|
64
|
+
</div>
|
|
65
|
+
</div>;
|
|
28
66
|
};
|
|
29
67
|
|
|
30
68
|
export default Field;
|
package/src/dev.js
ADDED
package/src/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import {
|
|
2
|
+
import {createRoot} from 'react-dom/client';
|
|
3
3
|
|
|
4
4
|
import {
|
|
5
5
|
init,
|
|
@@ -8,6 +8,7 @@ import {
|
|
|
8
8
|
import '@contentful/forma-36-react-components/dist/styles.css';
|
|
9
9
|
import '@contentful/forma-36-fcss/dist/styles.css';
|
|
10
10
|
import '@contentful/forma-36-tokens/dist/css/index.css';
|
|
11
|
+
import '@vonaffenfels/slate-editor/dist/index.css';
|
|
11
12
|
import './scss/index.scss';
|
|
12
13
|
|
|
13
14
|
import EntryEditor from './components/EntryEditor';
|
|
@@ -17,7 +18,7 @@ import Dialog from "./components/Dialog";
|
|
|
17
18
|
|
|
18
19
|
export const BaseContentfulApp = () => {
|
|
19
20
|
init((sdk) => {
|
|
20
|
-
const
|
|
21
|
+
const rootContainer = document.getElementById('root');
|
|
21
22
|
|
|
22
23
|
const ComponentLocationSettings = [
|
|
23
24
|
{
|
|
@@ -46,7 +47,8 @@ export const BaseContentfulApp = () => {
|
|
|
46
47
|
|
|
47
48
|
ComponentLocationSettings.forEach((componentLocationSetting) => {
|
|
48
49
|
if (sdk.location.is(componentLocationSetting.location)) {
|
|
49
|
-
|
|
50
|
+
const root = createRoot(rootContainer); // createRoot(container!) if you use TypeScript
|
|
51
|
+
root.render(componentLocationSetting.component);
|
|
50
52
|
}
|
|
51
53
|
});
|
|
52
54
|
});
|
|
File without changes
|
package/src/scss/index.scss
CHANGED
package/tailwind.config.js
CHANGED
package/webpack.config.dev.js
CHANGED
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
const path = require('path');
|
|
2
2
|
let config = require("./webpack.config")({
|
|
3
3
|
componentImportRoot: "@vonaffenfels/slate-editor/src/dev/testComponents",
|
|
4
|
-
relativePathToComponents: path.resolve(__dirname + "../../../@
|
|
4
|
+
relativePathToComponents: path.resolve(__dirname + "../../../@base/slate-editor/src/dev/testComponents"),
|
|
5
5
|
});
|
|
6
6
|
|
|
7
|
+
|
|
8
|
+
config.entry = {index: './src/dev.js'};
|
|
9
|
+
|
|
7
10
|
config.mode = "development";
|
|
8
11
|
config.watch = true;
|
|
9
12
|
config.watchOptions = {ignored: ['dist/**', 'node_modules/**']};
|
package/webpack.config.js
CHANGED
|
@@ -8,7 +8,7 @@ const {CleanWebpackPlugin} = require('clean-webpack-plugin');
|
|
|
8
8
|
module.exports = ({
|
|
9
9
|
babelConfig = JSON.parse(readFileSync("../../.babelrc").toString()),
|
|
10
10
|
componentImportRoot = "@vonaffenfels/slate-editor/src/dev/testComponents",
|
|
11
|
-
relativePathToComponents = path.resolve(__dirname + "../../../@
|
|
11
|
+
relativePathToComponents = path.resolve(__dirname + "../../../@base/slate-editor/src/dev/testComponents"),
|
|
12
12
|
postCssConfig = {
|
|
13
13
|
plugins: {
|
|
14
14
|
'postcss-import': {},
|
|
@@ -74,12 +74,28 @@ module.exports = ({
|
|
|
74
74
|
include: path.resolve(__dirname, 'src', 'scss'),
|
|
75
75
|
use: [
|
|
76
76
|
"style-loader",
|
|
77
|
-
|
|
77
|
+
{loader: 'css-loader', options: {importLoaders: 1}},
|
|
78
|
+
{loader: 'postcss-loader', options: {postcssOptions: postCssConfig}},
|
|
78
79
|
"sass-loader",
|
|
79
80
|
],
|
|
80
81
|
},
|
|
82
|
+
{
|
|
83
|
+
test: /module\.css$/i,
|
|
84
|
+
use: [
|
|
85
|
+
'style-loader',
|
|
86
|
+
{
|
|
87
|
+
loader: 'css-loader',
|
|
88
|
+
options: {
|
|
89
|
+
importLoaders: 1,
|
|
90
|
+
modules: {exportLocalsConvention: "camelCase"},
|
|
91
|
+
},
|
|
92
|
+
},
|
|
93
|
+
{loader: 'postcss-loader', options: {postcssOptions: postCssConfig}},
|
|
94
|
+
],
|
|
95
|
+
},
|
|
81
96
|
{
|
|
82
97
|
test: /\.css$/i,
|
|
98
|
+
exclude: [/module\.css$/i],
|
|
83
99
|
use: [
|
|
84
100
|
'style-loader',
|
|
85
101
|
{
|