@vonaffenfels/contentful-slate-editor 1.0.1 → 1.0.2
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 +13 -15
- package/src/index.js +32 -30
- package/webpack.config.js +127 -118
package/package.json
CHANGED
|
@@ -1,7 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vonaffenfels/contentful-slate-editor",
|
|
3
|
-
"version": "1.0.
|
|
4
|
-
"
|
|
3
|
+
"version": "1.0.2",
|
|
4
|
+
"scripts": {
|
|
5
|
+
"prepublish": "yarn run build",
|
|
6
|
+
"dev": "yarn run start",
|
|
7
|
+
"test": "echo \"Error: no test specified\" && exit 1",
|
|
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"
|
|
11
|
+
},
|
|
12
|
+
"dependencies": {
|
|
5
13
|
"@babel/core": "^7.20.12",
|
|
6
14
|
"@babel/plugin-proposal-class-properties": "^7.13.0",
|
|
7
15
|
"@babel/plugin-syntax-dynamic-import": "^7.8.3",
|
|
@@ -14,6 +22,7 @@
|
|
|
14
22
|
"@contentful/forma-36-react-components": "^3.88.3",
|
|
15
23
|
"@contentful/forma-36-tokens": "^0.10.1",
|
|
16
24
|
"@svgr/webpack": "^5.5.0",
|
|
25
|
+
"@vonaffenfels/slate-editor": "^1.0.2",
|
|
17
26
|
"babel-loader": "^8.2.2",
|
|
18
27
|
"clean-webpack-plugin": "^3.0.0",
|
|
19
28
|
"cloudinary": "^1.25.1",
|
|
@@ -37,22 +46,11 @@
|
|
|
37
46
|
"style-loader": "^2.0.0",
|
|
38
47
|
"tailwindcss": "3.3.2",
|
|
39
48
|
"url-loader": "^4.1.1",
|
|
49
|
+
"webpack": "5.73.0",
|
|
40
50
|
"webpack-cli": "^4.6.0",
|
|
41
51
|
"webpack-dev-server": "^4.0.0-beta.2"
|
|
42
52
|
},
|
|
43
|
-
"
|
|
44
|
-
"prepublish": "yarn run build",
|
|
45
|
-
"dev": "yarn run start",
|
|
46
|
-
"test": "echo \"Error: no test specified\" && exit 1",
|
|
47
|
-
"build": "echo \"Don't build this module!\"",
|
|
48
|
-
"start": "webpack serve --config webpack.config.dev.js",
|
|
49
|
-
"vercelDev": "cp ./.vercel.project.json ../../.vercel/project.json && cd ../../ && vercel dev"
|
|
50
|
-
},
|
|
51
|
-
"dependencies": {
|
|
52
|
-
"@vonaffenfels/slate-editor": "^1.0.1",
|
|
53
|
-
"webpack": "5.73.0"
|
|
54
|
-
},
|
|
55
|
-
"gitHead": "06971175660ea52650bfb65a3d68b34a7926475e",
|
|
53
|
+
"gitHead": "ae1bfe8cfaf2732b1bc53b28cec08ea1c5d5a842",
|
|
56
54
|
"publishConfig": {
|
|
57
55
|
"access": "public"
|
|
58
56
|
}
|
package/src/index.js
CHANGED
|
@@ -15,37 +15,39 @@ import Config from './components/ConfigScreen';
|
|
|
15
15
|
import Field from './components/Field';
|
|
16
16
|
import Dialog from "./components/Dialog";
|
|
17
17
|
|
|
18
|
-
|
|
19
|
-
|
|
18
|
+
export const BaseContentfulApp = () => {
|
|
19
|
+
init((sdk) => {
|
|
20
|
+
const root = document.getElementById('root');
|
|
20
21
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
22
|
+
const ComponentLocationSettings = [
|
|
23
|
+
{
|
|
24
|
+
location: locations.LOCATION_APP_CONFIG,
|
|
25
|
+
component: <Config sdk={sdk}/>,
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
location: locations.LOCATION_ENTRY_FIELD,
|
|
29
|
+
component: <Field sdk={sdk}/>,
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
location: locations.LOCATION_ENTRY_EDITOR,
|
|
33
|
+
component: <EntryEditor
|
|
34
|
+
sdk={sdk}
|
|
35
|
+
onStorybookElementClick={element => {
|
|
36
|
+
const storybookElementChangeEvent = new CustomEvent("storybookElementChange", {detail: element});
|
|
36
37
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
38
|
+
window.parent.document.dispatchEvent(storybookElementChangeEvent);
|
|
39
|
+
}}/>,
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
location: locations.LOCATION_DIALOG,
|
|
43
|
+
component: <Dialog sdk={sdk}/>,
|
|
44
|
+
},
|
|
45
|
+
];
|
|
45
46
|
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
47
|
+
ComponentLocationSettings.forEach((componentLocationSetting) => {
|
|
48
|
+
if (sdk.location.is(componentLocationSetting.location)) {
|
|
49
|
+
render(componentLocationSetting.component, root);
|
|
50
|
+
}
|
|
51
|
+
});
|
|
50
52
|
});
|
|
51
|
-
}
|
|
53
|
+
};
|
package/webpack.config.js
CHANGED
|
@@ -3,132 +3,141 @@ const MiniCssExtractPlugin = require('mini-css-extract-plugin');
|
|
|
3
3
|
const HtmlWebpackPlugin = require('html-webpack-plugin');
|
|
4
4
|
const webpack = require("webpack");
|
|
5
5
|
const {readFileSync} = require("fs");
|
|
6
|
-
const babelConfig = JSON.parse(readFileSync("../../.babelrc").toString());
|
|
7
6
|
const {CleanWebpackPlugin} = require('clean-webpack-plugin');
|
|
8
7
|
|
|
9
8
|
module.exports = ({
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
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
|
+
}) => {
|
|
20
|
+
return {
|
|
21
|
+
mode: 'production',
|
|
22
|
+
entry: {index: './src/index.js'},
|
|
23
|
+
module: {
|
|
24
|
+
rules: [
|
|
25
|
+
{
|
|
26
|
+
test: /storyLoader.js/i,
|
|
27
|
+
use: [
|
|
28
|
+
{
|
|
29
|
+
loader: "@vonaffenfels/slate-editor/storyLoader.js",
|
|
30
|
+
options: {
|
|
31
|
+
storiesRoot: relativePathToComponents,
|
|
32
|
+
storiesImportRoot: componentImportRoot,
|
|
33
|
+
},
|
|
25
34
|
},
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
35
|
+
],
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
test: /componentLoader.js/i,
|
|
39
|
+
use: [
|
|
40
|
+
{
|
|
41
|
+
loader: "@vonaffenfels/slate-editor/componentLoader.js",
|
|
42
|
+
options: {
|
|
43
|
+
componentRoot: relativePathToComponents,
|
|
44
|
+
componentImportRoot: componentImportRoot,
|
|
45
|
+
},
|
|
37
46
|
},
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
options: babelConfig,
|
|
51
|
-
},
|
|
52
|
-
],
|
|
53
|
-
},
|
|
54
|
-
{
|
|
55
|
-
test: /\.s[ac]ss$/i,
|
|
56
|
-
include: path.resolve(__dirname, 'src', 'scss'),
|
|
57
|
-
use: [
|
|
58
|
-
"style-loader",
|
|
59
|
-
"css-loader",
|
|
60
|
-
"sass-loader",
|
|
61
|
-
],
|
|
62
|
-
},
|
|
63
|
-
{
|
|
64
|
-
test: /\.css$/i,
|
|
65
|
-
use: [
|
|
66
|
-
'style-loader',
|
|
67
|
-
{
|
|
68
|
-
loader: 'css-loader',
|
|
69
|
-
options: {importLoaders: 1},
|
|
70
|
-
},
|
|
71
|
-
{loader: 'postcss-loader'},
|
|
72
|
-
],
|
|
73
|
-
},
|
|
74
|
-
{
|
|
75
|
-
test: /\.svg$/,
|
|
76
|
-
resourceQuery: {not: [/url/]}, // exclude react component if *.svg?url
|
|
77
|
-
use: [
|
|
78
|
-
{
|
|
79
|
-
loader: '@svgr/webpack',
|
|
80
|
-
options: {
|
|
81
|
-
dimensions: false,
|
|
82
|
-
svgo: false,
|
|
47
|
+
],
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
test: /\.js$/,
|
|
51
|
+
include: [
|
|
52
|
+
path.resolve(__dirname, 'src'),
|
|
53
|
+
relativePathToComponents,
|
|
54
|
+
],
|
|
55
|
+
use: [
|
|
56
|
+
{
|
|
57
|
+
loader: 'babel-loader',
|
|
58
|
+
options: babelConfig,
|
|
83
59
|
},
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
60
|
+
],
|
|
61
|
+
},
|
|
62
|
+
{
|
|
63
|
+
test: /\.s[ac]ss$/i,
|
|
64
|
+
include: path.resolve(__dirname, 'src', 'scss'),
|
|
65
|
+
use: [
|
|
66
|
+
"style-loader",
|
|
67
|
+
"css-loader",
|
|
68
|
+
"sass-loader",
|
|
69
|
+
],
|
|
70
|
+
},
|
|
71
|
+
{
|
|
72
|
+
test: /\.css$/i,
|
|
73
|
+
use: [
|
|
74
|
+
'style-loader',
|
|
75
|
+
{
|
|
76
|
+
loader: 'css-loader',
|
|
77
|
+
options: {importLoaders: 1},
|
|
96
78
|
},
|
|
97
|
-
|
|
98
|
-
|
|
79
|
+
{loader: 'postcss-loader', options: {postcssOptions: postCssConfig}},
|
|
80
|
+
],
|
|
81
|
+
},
|
|
82
|
+
{
|
|
83
|
+
test: /\.svg$/,
|
|
84
|
+
resourceQuery: {not: [/url/]}, // exclude react component if *.svg?url
|
|
85
|
+
use: [
|
|
86
|
+
{
|
|
87
|
+
loader: '@svgr/webpack',
|
|
88
|
+
options: {
|
|
89
|
+
dimensions: false,
|
|
90
|
+
svgo: false,
|
|
91
|
+
},
|
|
92
|
+
},
|
|
93
|
+
'url-loader',
|
|
94
|
+
],
|
|
95
|
+
},
|
|
96
|
+
{
|
|
97
|
+
test: /\.(woff(2)?|ttf|eot|png)(\?v=\d+\.\d+\.\d+)?$/,
|
|
98
|
+
use: [
|
|
99
|
+
{
|
|
100
|
+
loader: 'file-loader',
|
|
101
|
+
options: {
|
|
102
|
+
name: '[name].[ext]',
|
|
103
|
+
outputPath: 'fonts/',
|
|
104
|
+
},
|
|
105
|
+
},
|
|
106
|
+
],
|
|
107
|
+
},
|
|
108
|
+
{
|
|
109
|
+
test: /\.(graphql|gql)$/,
|
|
110
|
+
include: [
|
|
111
|
+
path.resolve(__dirname, 'src'),
|
|
112
|
+
path.resolve(__dirname, '../../@frontend/components'),
|
|
113
|
+
],
|
|
114
|
+
loader: 'graphql-tag/loader',
|
|
115
|
+
},
|
|
116
|
+
],
|
|
117
|
+
},
|
|
118
|
+
plugins: [
|
|
119
|
+
new CleanWebpackPlugin(),
|
|
120
|
+
new HtmlWebpackPlugin({template: path.join(__dirname, 'src', 'index.html')}),
|
|
121
|
+
new MiniCssExtractPlugin({}),
|
|
122
|
+
new webpack.DefinePlugin({'process.env': JSON.stringify(process.env)}),
|
|
123
|
+
],
|
|
124
|
+
resolve: {
|
|
125
|
+
extensions: ['.json', '.js', '.jsx'],
|
|
126
|
+
fallback: {
|
|
127
|
+
stream: false,
|
|
128
|
+
path: false,
|
|
129
|
+
timers: false,
|
|
99
130
|
},
|
|
100
|
-
{
|
|
101
|
-
|
|
102
|
-
include: [
|
|
103
|
-
path.resolve(__dirname, 'src'),
|
|
104
|
-
path.resolve(__dirname, '../../@frontend/components'),
|
|
105
|
-
],
|
|
106
|
-
loader: 'graphql-tag/loader',
|
|
131
|
+
alias: {
|
|
132
|
+
storybookStories: '@vonaffenfels/slate-editor/storyLoader.js',
|
|
107
133
|
},
|
|
108
|
-
],
|
|
109
|
-
},
|
|
110
|
-
plugins: [
|
|
111
|
-
new CleanWebpackPlugin(),
|
|
112
|
-
new HtmlWebpackPlugin({template: path.join(__dirname, 'src', 'index.html')}),
|
|
113
|
-
new MiniCssExtractPlugin({}),
|
|
114
|
-
new webpack.DefinePlugin({'process.env': JSON.stringify(process.env)}),
|
|
115
|
-
],
|
|
116
|
-
resolve: {
|
|
117
|
-
extensions: ['.json', '.js', '.jsx'],
|
|
118
|
-
fallback: {
|
|
119
|
-
stream: false,
|
|
120
|
-
path: false,
|
|
121
|
-
timers: false,
|
|
122
134
|
},
|
|
123
|
-
|
|
124
|
-
|
|
135
|
+
output: {
|
|
136
|
+
filename: '[name].js',
|
|
137
|
+
libraryTarget: "umd",
|
|
138
|
+
publicPath: "/",
|
|
139
|
+
globalObject: "this",
|
|
140
|
+
path: path.resolve(__dirname, 'dist'),
|
|
125
141
|
},
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
filename: '[name].js',
|
|
129
|
-
libraryTarget: "umd",
|
|
130
|
-
publicPath: "/",
|
|
131
|
-
globalObject: "this",
|
|
132
|
-
path: path.resolve(__dirname, 'dist'),
|
|
133
|
-
},
|
|
134
|
-
});
|
|
142
|
+
};
|
|
143
|
+
};
|