@vonaffenfels/contentful-slate-editor 1.0.2 → 1.0.4

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,15 +1,14 @@
1
1
  {
2
2
  "name": "@vonaffenfels/contentful-slate-editor",
3
- "version": "1.0.2",
3
+ "version": "1.0.4",
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
- "dependencies": {
11
+ "peerDependencies": {
13
12
  "@babel/core": "^7.20.12",
14
13
  "@babel/plugin-proposal-class-properties": "^7.13.0",
15
14
  "@babel/plugin-syntax-dynamic-import": "^7.8.3",
@@ -22,7 +21,6 @@
22
21
  "@contentful/forma-36-react-components": "^3.88.3",
23
22
  "@contentful/forma-36-tokens": "^0.10.1",
24
23
  "@svgr/webpack": "^5.5.0",
25
- "@vonaffenfels/slate-editor": "^1.0.2",
26
24
  "babel-loader": "^8.2.2",
27
25
  "clean-webpack-plugin": "^3.0.0",
28
26
  "cloudinary": "^1.25.1",
@@ -37,6 +35,7 @@
37
35
  "mini-css-extract-plugin": "^1.5.0",
38
36
  "postcss": "8.4.14",
39
37
  "postcss-loader": "^5.2.0",
38
+ "raw-loader": "^4.0.2",
40
39
  "react": "18.2.0",
41
40
  "react-dom": "18.2.0",
42
41
  "react-uid": "^2.3.1",
@@ -46,11 +45,54 @@
46
45
  "style-loader": "^2.0.0",
47
46
  "tailwindcss": "3.3.2",
48
47
  "url-loader": "^4.1.1",
49
- "webpack": "5.73.0",
50
48
  "webpack-cli": "^4.6.0",
51
49
  "webpack-dev-server": "^4.0.0-beta.2"
52
50
  },
53
- "gitHead": "ae1bfe8cfaf2732b1bc53b28cec08ea1c5d5a842",
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
+ },
91
+ "dependencies": {
92
+ "@vonaffenfels/slate-editor": "^1.0.4",
93
+ "webpack": "5.73.0"
94
+ },
95
+ "gitHead": "ba6d3fea2cca04a822de7e3d7dff5949e62a9d46",
54
96
  "publishConfig": {
55
97
  "access": "public"
56
98
  }
@@ -62,7 +62,19 @@ export default class Config extends Component {
62
62
  backgroundColor: "#FFF",
63
63
  })}>
64
64
  <Form>
65
- <Heading>No Configuration necessary</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
  );
@@ -1,4 +1,6 @@
1
- import React, {useEffect, useState} from '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
- <BlockEditor
39
- storybookStories={loadedStorybookStories}
40
- onChange={setValue}
41
- elementPropsMap={{}}
42
- value={value}
43
- storybookComponentLoader={(block) => {
44
- return componentLoader(block);
45
- }}
46
- storybookComponentDataLoader={async (block, attributes) => {
47
- return {};
48
- }}
49
- />
50
- <div>
51
- <button onClick={saveChanges}>Änderungen speichern</button>
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 = config?.cloudinaryApiKey;
13
- const cloudinaryCloudName = config?.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
 
@@ -1,5 +1,15 @@
1
- import React from '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
- <button onClick={openDialog}>Inhalt bearbeiten</button>
27
- </div>
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
@@ -0,0 +1,4 @@
1
+ import './scss/dev.scss';
2
+ import {BaseContentfulApp} from "./index"
3
+
4
+ BaseContentfulApp();
package/src/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import React from 'react';
2
- import {render} from 'react-dom';
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 root = document.getElementById('root');
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
- render(componentLocationSetting.component, root);
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
@@ -1,3 +1,7 @@
1
+ @tailwind base;
2
+ @tailwind components;
3
+ @tailwind utilities;
4
+
1
5
  html, body, div {
2
6
  margin: 0;
3
7
  padding: 0;
@@ -1,6 +1,5 @@
1
-
2
1
  module.exports = {
3
2
  content: [
4
- './src/**/*.js'
3
+ './src/**/*.js',
5
4
  ],
6
5
  };
@@ -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 + "../../../@vonaffenfels/slate-editor/src/dev/testComponents"),
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
@@ -6,17 +6,18 @@ const {readFileSync} = require("fs");
6
6
  const {CleanWebpackPlugin} = require('clean-webpack-plugin');
7
7
 
8
8
  module.exports = ({
9
- babelConfig = JSON.parse(readFileSync("../../.babelrc").toString()),
10
- componentImportRoot = "@vonaffenfels/slate-editor/src/dev/testComponents",
11
- relativePathToComponents = path.resolve(__dirname + "../../../@vonaffenfels/slate-editor/src/dev/testComponents"),
12
- postCssConfig = {
13
- plugins: {
14
- 'postcss-import': {},
15
- tailwindcss: {},
16
- autoprefixer: {},
17
- },
18
- },
19
- }) => {
9
+ babelConfig = JSON.parse(readFileSync("../../.babelrc").toString()),
10
+ componentImportRoot = "@vonaffenfels/slate-editor/src/dev/testComponents",
11
+ relativePathToComponents = path.resolve(__dirname + "../../../@base/slate-editor/src/dev/testComponents"),
12
+ postCssConfig = {
13
+ plugins: {
14
+ 'postcss-import': {},
15
+ tailwindcss: {},
16
+ autoprefixer: {},
17
+ },
18
+ },
19
+ transpilePaths = [],
20
+ }) => {
20
21
  return {
21
22
  mode: 'production',
22
23
  entry: {index: './src/index.js'},
@@ -32,6 +33,10 @@ module.exports = ({
32
33
  storiesImportRoot: componentImportRoot,
33
34
  },
34
35
  },
36
+ {
37
+ loader: 'babel-loader',
38
+ options: babelConfig,
39
+ },
35
40
  ],
36
41
  },
37
42
  {
@@ -44,6 +49,10 @@ module.exports = ({
44
49
  componentImportRoot: componentImportRoot,
45
50
  },
46
51
  },
52
+ {
53
+ loader: 'babel-loader',
54
+ options: babelConfig,
55
+ },
47
56
  ],
48
57
  },
49
58
  {
@@ -51,6 +60,7 @@ module.exports = ({
51
60
  include: [
52
61
  path.resolve(__dirname, 'src'),
53
62
  relativePathToComponents,
63
+ ...transpilePaths,
54
64
  ],
55
65
  use: [
56
66
  {
@@ -64,12 +74,28 @@ module.exports = ({
64
74
  include: path.resolve(__dirname, 'src', 'scss'),
65
75
  use: [
66
76
  "style-loader",
67
- "css-loader",
77
+ {loader: 'css-loader', options: {importLoaders: 1}},
78
+ {loader: 'postcss-loader', options: {postcssOptions: postCssConfig}},
68
79
  "sass-loader",
69
80
  ],
70
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
+ },
71
96
  {
72
97
  test: /\.css$/i,
98
+ exclude: [/module\.css$/i],
73
99
  use: [
74
100
  'style-loader',
75
101
  {
@@ -107,11 +133,7 @@ module.exports = ({
107
133
  },
108
134
  {
109
135
  test: /\.(graphql|gql)$/,
110
- include: [
111
- path.resolve(__dirname, 'src'),
112
- path.resolve(__dirname, '../../@frontend/components'),
113
- ],
114
- loader: 'graphql-tag/loader',
136
+ loader: 'raw-loader',
115
137
  },
116
138
  ],
117
139
  },