@vonaffenfels/slate-editor 1.2.41 → 1.2.42

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.
Files changed (79) hide show
  1. package/.babelrc +43 -43
  2. package/README.md +5 -5
  3. package/componentLoader.js +93 -93
  4. package/package.json +2 -2
  5. package/postcss.config.js +6 -6
  6. package/scss/demo.scss +148 -148
  7. package/scss/sidebarEditor.scss +185 -185
  8. package/scss/toolbar.scss +162 -162
  9. package/src/Blocks/EmptyBlock.js +11 -11
  10. package/src/Blocks/EmptyWrapper.js +4 -4
  11. package/src/Blocks/ErrorBoundary.js +40 -40
  12. package/src/Blocks/LayoutBlock.js +274 -274
  13. package/src/Blocks/LayoutSlot.js +90 -90
  14. package/src/CollapsableMenu/CollapsableMenu.js +48 -48
  15. package/src/Context/StorybookContext.js +6 -6
  16. package/src/ElementAutocomplete.js +134 -134
  17. package/src/Loader.js +137 -137
  18. package/src/Nodes/Default.js +162 -162
  19. package/src/Nodes/Leaf.js +54 -54
  20. package/src/Nodes/Text.js +97 -97
  21. package/src/ObjectId.js +3 -3
  22. package/src/Renderer.js +73 -73
  23. package/src/Serializer/Html.js +42 -42
  24. package/src/Serializer/Serializer.js +374 -374
  25. package/src/Serializer/Text.js +17 -17
  26. package/src/Serializer/ads.js +187 -187
  27. package/src/Serializer/index.js +3 -3
  28. package/src/SidebarEditor/Fields/CloudinaryContentSelect.js +89 -89
  29. package/src/SidebarEditor/Fields/ColorPicker.js +89 -89
  30. package/src/SidebarEditor/Fields/DateTime.js +55 -55
  31. package/src/SidebarEditor/Fields/MVP.js +66 -66
  32. package/src/SidebarEditor/Fields/MultiSelect.js +13 -13
  33. package/src/SidebarEditor/Fields/RemoteMultiSelect.js +40 -40
  34. package/src/SidebarEditor/Fields/RemoteSelect.js +39 -39
  35. package/src/SidebarEditor/Fields/Select.js +47 -47
  36. package/src/SidebarEditor/Fields/StreamSelect.js +15 -15
  37. package/src/SidebarEditor/Fields/Switch.js +34 -34
  38. package/src/SidebarEditor/Fields/Textarea.js +21 -21
  39. package/src/SidebarEditor/Resizable.js +85 -85
  40. package/src/Storybook.js +151 -151
  41. package/src/Toolbar/Align.js +64 -64
  42. package/src/Toolbar/Anchor.js +94 -94
  43. package/src/Toolbar/Block.js +135 -135
  44. package/src/Toolbar/Element.js +44 -44
  45. package/src/Toolbar/Formats.js +71 -71
  46. package/src/Toolbar/Insert.js +28 -28
  47. package/src/Toolbar/Layout.js +399 -399
  48. package/src/Toolbar/Link.js +164 -164
  49. package/src/Toolbar/Toolbar.js +235 -235
  50. package/src/Tools/Margin.js +51 -51
  51. package/src/Translation/TranslationToolbarButton.js +119 -119
  52. package/src/dev/draftToSlate.json +3147 -3147
  53. package/src/dev/index.css +2 -2
  54. package/src/dev/index.html +10 -10
  55. package/src/dev/index.js +4 -4
  56. package/src/dev/sampleValue1.json +4294 -4294
  57. package/src/dev/sampleValueValid.json +410 -410
  58. package/src/dev/testComponents/TestStory.js +74 -74
  59. package/src/dev/testComponents/TestStory.stories.js +216 -216
  60. package/src/dev/testComponents/TestStory2.js +74 -74
  61. package/src/dev/testComponents/TestStory2.stories.js +197 -197
  62. package/src/dev/testComponents/TestStory3.js +74 -74
  63. package/src/dev/testComponents/TestStory3.stories.js +197 -197
  64. package/src/dev/testSampleValue.json +746 -746
  65. package/src/fromHTML.js +4 -4
  66. package/src/helper/array.js +8 -8
  67. package/src/index.js +10 -10
  68. package/src/plugins/ListItem.js +48 -48
  69. package/src/plugins/SoftBreak.js +23 -23
  70. package/src/toHTML.js +6 -6
  71. package/src/toText.js +6 -6
  72. package/src/util/reduceContentfulResponse.js +64 -64
  73. package/src/util.js +19 -19
  74. package/storyLoader.js +47 -47
  75. package/tailwind.config.js +4 -4
  76. package/webpack.config.build.js +55 -55
  77. package/webpack.config.dev.js +60 -60
  78. package/webpack.config.js +130 -130
  79. package/webpack.config.watch.js +4 -4
package/.babelrc CHANGED
@@ -1,44 +1,44 @@
1
- {
2
- "presets": [
3
- "next/babel",
4
- [
5
- "@babel/preset-env",
6
- {
7
- "modules": false,
8
- "targets": {
9
- "browsers": [
10
- "last 2 Chrome versions",
11
- "last 2 Firefox versions",
12
- "last 2 Safari versions",
13
- "last 2 iOS versions",
14
- "last 1 Android version",
15
- "last 1 ChromeAndroid version",
16
- "ie 11"
17
- ]
18
- }
19
- }
20
- ],
21
- "@babel/preset-react"
22
- ],
23
- "plugins": [
24
- [
25
- "@babel/plugin-proposal-private-methods",
26
- {
27
- "loose": true
28
- }
29
- ],
30
- [
31
- "@babel/plugin-proposal-private-property-in-object",
32
- {
33
- "loose": true
34
- }
35
- ],
36
- [
37
- "@babel/plugin-proposal-class-properties",
38
- {
39
- "loose": true
40
- }
41
- ],
42
- "@babel/plugin-syntax-dynamic-import"
43
- ]
1
+ {
2
+ "presets": [
3
+ "next/babel",
4
+ [
5
+ "@babel/preset-env",
6
+ {
7
+ "modules": false,
8
+ "targets": {
9
+ "browsers": [
10
+ "last 2 Chrome versions",
11
+ "last 2 Firefox versions",
12
+ "last 2 Safari versions",
13
+ "last 2 iOS versions",
14
+ "last 1 Android version",
15
+ "last 1 ChromeAndroid version",
16
+ "ie 11"
17
+ ]
18
+ }
19
+ }
20
+ ],
21
+ "@babel/preset-react"
22
+ ],
23
+ "plugins": [
24
+ [
25
+ "@babel/plugin-proposal-private-methods",
26
+ {
27
+ "loose": true
28
+ }
29
+ ],
30
+ [
31
+ "@babel/plugin-proposal-private-property-in-object",
32
+ {
33
+ "loose": true
34
+ }
35
+ ],
36
+ [
37
+ "@babel/plugin-proposal-class-properties",
38
+ {
39
+ "loose": true
40
+ }
41
+ ],
42
+ "@babel/plugin-syntax-dynamic-import"
43
+ ]
44
44
  }
package/README.md CHANGED
@@ -1,5 +1,5 @@
1
- # dev
2
-
3
- run config EDITOR :: DEV or in repo root yarn devEditor
4
-
5
- http://localhost:9000/dist/
1
+ # dev
2
+
3
+ run config EDITOR :: DEV or in repo root yarn devEditor
4
+
5
+ http://localhost:9000/dist/
@@ -1,94 +1,94 @@
1
- const walkSync = require("walk-sync");
2
-
3
- module.exports = async function componentLoader() {
4
- const options = this.getOptions();
5
- const files = walkSync(options.componentRoot, {
6
- directories: false,
7
- globs: ["**/*.js", "**/*.jsx", "**/*.ts", "**/*.tsx"],
8
- ignore: [
9
- "**/*.stories.js",
10
- "**/*.stories.jsx",
11
- "**/*.stories.ts",
12
- "**/*.loader.js",
13
- "**/*.loader.jsx",
14
- "**/*.loader.ts",
15
- "**/streams/*.js",
16
- "**/streams/*.jsx",
17
- "**/streams/*.ts",
18
- "**/atomic/**/*",
19
- ],
20
- });
21
-
22
- // this.addContextDependency(options.componentRoot);
23
-
24
- console.log(`Found ${files.length} components in ${options.componentRoot}`);
25
- const components = files.map(file => {
26
- let componentNameParts = file.split(".");
27
- componentNameParts.pop();
28
-
29
- const exportName = componentNameParts.join("").split("/").pop();
30
-
31
- return {
32
- name: componentNameParts.join("").split("/").join(""),
33
- exportName,
34
- namePath: componentNameParts.join(""),
35
- file: `${options.componentImportRoot}/${file}`,
36
- };
37
- });
38
-
39
- const nonDynamicComponentImports = [];
40
- const componentImports = components.map(component => {
41
- let allowSSR = !(options.nonSSRComponents || []).map(v => String(v).toLowerCase()).includes(String(component.name).toLowerCase());
42
-
43
- if (!allowSSR) {
44
- // console.log(`Disabled SSR for ${component.file}`);
45
- }
46
-
47
- let isDynamic = !(options.nonDynamicComponents || []).map(v => String(v).toLowerCase()).includes(String(component.name).toLowerCase());
48
-
49
- if (isDynamic) {
50
- return `COMPONENT_REGISTRY["${component.namePath.toLowerCase()}"] = dynamic(() => import(/* webpackChunkName: "${component.name}" */"${component.file}").then(v => makeExport(v, ["${component.exportName}", "${component.name}"]))${!allowSSR ? ",{ssr: false}" : ""});`;
51
- } else {
52
- nonDynamicComponentImports.push(`import {default as ${component.name}} from "${component.file}";`);
53
- return `COMPONENT_REGISTRY["${component.namePath.toLowerCase()}"] = ${component.name};`;
54
- }
55
- });
56
-
57
- const fileContent = `
58
- ${nonDynamicComponentImports.join("\n")}
59
- import dynamic from 'next/dynamic';
60
-
61
- const COMPONENT_REGISTRY = {};
62
- const MissingComponent = () => null;
63
- const makeExport = (component, names) => {
64
- const ElementComponent = [...names, "default"].reduce((acc, name) => acc || component[name], null);
65
-
66
- if(!ElementComponent) {
67
- console.debug(\`Missing export for \${names.join(" / ")}\`);
68
- return MissingComponent;
69
- }
70
-
71
- return ElementComponent;
72
- }
73
-
74
- ${componentImports.join("\n")}
75
-
76
- export default function componentLoader(block) {
77
- const localBlock = String(block).toLowerCase();
78
-
79
- if(!COMPONENT_REGISTRY[localBlock]) {
80
- console.warn(\`No Component found for \${block}\`);
81
- return MissingComponent;
82
- }
83
-
84
- return COMPONENT_REGISTRY[localBlock];
85
- }
86
- `;
87
-
88
- /*
89
- const writeFileSync = require("fs").writeFileSync;
90
- writeFileSync("./componentLoader.static.DEBUG.js", fileContent);
91
- */
92
-
93
- return fileContent;
1
+ const walkSync = require("walk-sync");
2
+
3
+ module.exports = async function componentLoader() {
4
+ const options = this.getOptions();
5
+ const files = walkSync(options.componentRoot, {
6
+ directories: false,
7
+ globs: ["**/*.js", "**/*.jsx", "**/*.ts", "**/*.tsx"],
8
+ ignore: [
9
+ "**/*.stories.js",
10
+ "**/*.stories.jsx",
11
+ "**/*.stories.ts",
12
+ "**/*.loader.js",
13
+ "**/*.loader.jsx",
14
+ "**/*.loader.ts",
15
+ "**/streams/*.js",
16
+ "**/streams/*.jsx",
17
+ "**/streams/*.ts",
18
+ "**/atomic/**/*",
19
+ ],
20
+ });
21
+
22
+ // this.addContextDependency(options.componentRoot);
23
+
24
+ console.log(`Found ${files.length} components in ${options.componentRoot}`);
25
+ const components = files.map(file => {
26
+ let componentNameParts = file.split(".");
27
+ componentNameParts.pop();
28
+
29
+ const exportName = componentNameParts.join("").split("/").pop();
30
+
31
+ return {
32
+ name: componentNameParts.join("").split("/").join(""),
33
+ exportName,
34
+ namePath: componentNameParts.join(""),
35
+ file: `${options.componentImportRoot}/${file}`,
36
+ };
37
+ });
38
+
39
+ const nonDynamicComponentImports = [];
40
+ const componentImports = components.map(component => {
41
+ let allowSSR = !(options.nonSSRComponents || []).map(v => String(v).toLowerCase()).includes(String(component.name).toLowerCase());
42
+
43
+ if (!allowSSR) {
44
+ // console.log(`Disabled SSR for ${component.file}`);
45
+ }
46
+
47
+ let isDynamic = !(options.nonDynamicComponents || []).map(v => String(v).toLowerCase()).includes(String(component.name).toLowerCase());
48
+
49
+ if (isDynamic) {
50
+ return `COMPONENT_REGISTRY["${component.namePath.toLowerCase()}"] = dynamic(() => import(/* webpackChunkName: "${component.name}" */"${component.file}").then(v => makeExport(v, ["${component.exportName}", "${component.name}"]))${!allowSSR ? ",{ssr: false}" : ""});`;
51
+ } else {
52
+ nonDynamicComponentImports.push(`import {default as ${component.name}} from "${component.file}";`);
53
+ return `COMPONENT_REGISTRY["${component.namePath.toLowerCase()}"] = ${component.name};`;
54
+ }
55
+ });
56
+
57
+ const fileContent = `
58
+ ${nonDynamicComponentImports.join("\n")}
59
+ import dynamic from 'next/dynamic';
60
+
61
+ const COMPONENT_REGISTRY = {};
62
+ const MissingComponent = () => null;
63
+ const makeExport = (component, names) => {
64
+ const ElementComponent = [...names, "default"].reduce((acc, name) => acc || component[name], null);
65
+
66
+ if(!ElementComponent) {
67
+ console.debug(\`Missing export for \${names.join(" / ")}\`);
68
+ return MissingComponent;
69
+ }
70
+
71
+ return ElementComponent;
72
+ }
73
+
74
+ ${componentImports.join("\n")}
75
+
76
+ export default function componentLoader(block) {
77
+ const localBlock = String(block).toLowerCase();
78
+
79
+ if(!COMPONENT_REGISTRY[localBlock]) {
80
+ console.warn(\`No Component found for \${block}\`);
81
+ return MissingComponent;
82
+ }
83
+
84
+ return COMPONENT_REGISTRY[localBlock];
85
+ }
86
+ `;
87
+
88
+ /*
89
+ const writeFileSync = require("fs").writeFileSync;
90
+ writeFileSync("./componentLoader.static.DEBUG.js", fileContent);
91
+ */
92
+
93
+ return fileContent;
94
94
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vonaffenfels/slate-editor",
3
- "version": "1.2.41",
3
+ "version": "1.2.42",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {
@@ -72,7 +72,7 @@
72
72
  "cssnano": "^5.0.1",
73
73
  "escape-html": "^1.0.3"
74
74
  },
75
- "gitHead": "5eeb733acccf6de22fe63f38203d2595b95a0308",
75
+ "gitHead": "9870eaacf5845710b7e89cdd2dcc23f6563a381d",
76
76
  "publishConfig": {
77
77
  "access": "public"
78
78
  }
package/postcss.config.js CHANGED
@@ -1,7 +1,7 @@
1
- module.exports = {
2
- plugins: {
3
- 'postcss-import': {},
4
- tailwindcss: {},
5
- autoprefixer: {},
6
- },
1
+ module.exports = {
2
+ plugins: {
3
+ 'postcss-import': {},
4
+ tailwindcss: {},
5
+ autoprefixer: {},
6
+ },
7
7
  };
package/scss/demo.scss CHANGED
@@ -1,149 +1,149 @@
1
- html, body, #root {
2
- height: 100%;
3
- width: 100%;
4
- }
5
-
6
- @media (prefers-color-scheme: dark) {
7
- .slate-editor {
8
- color: white;
9
- background-color: #1c1c27;
10
- }
11
- }
12
-
13
- .editor-demo-wrapper {
14
- display: flex;
15
- height: 100%;
16
- justify-content: center;
17
- width: 100%;
18
- flex-direction: column;
19
-
20
- .editor-demo-output {
21
- display: none;
22
- width: 100%;
23
- }
24
-
25
- .editor-demo {
26
- display: block;
27
- flex: 1;
28
- height: 100%;
29
- width: 100%;
30
- position: relative;
31
-
32
- .editor-demo-editor {
33
- display: flex;
34
- height: 100%;
35
- position: relative;
36
- width: 100%;
37
- padding-top: 40px;
38
-
39
- &.container {
40
- display: flex;
41
- flex: 1;
42
- justify-content: center;
43
- min-width: 100%;
44
- min-height: 100%;
45
- position: relative;
46
-
47
- &.block-editor-wrapper {
48
- flex-grow: 1;
49
- //max-width: 703px;
50
- //width: 703px; // contentful editor default width
51
- }
52
- }
53
-
54
- &.value {
55
- textarea {
56
- max-height: 50px;
57
- }
58
- }
59
- }
60
- }
61
- }
62
-
63
- .test-block {
64
- background-color: #fefefe;
65
- border: 1px solid black;
66
- color: black;
67
- padding: 5px;
68
- }
69
-
70
- .block-editor-content {
71
- font-family: "Helvetica Neue Light", "HelveticaNeue-Light", "Helvetica Neue", Calibri, Helvetica, Arial, sans-serif;
72
- line-height: 1em;
73
- }
74
-
75
- .block-editor-content p {
76
- margin-bottom: 20px;
77
- }
78
-
79
- .block-editor-content h1 {
80
- font-size: 2em;
81
- margin-bottom: 2em;
82
- }
83
-
84
- .block-editor-content h2 {
85
- font-size: 1.5em;
86
- margin-bottom: 1em;
87
- }
88
-
89
- .block-editor-content h3 {
90
- font-size: 1.3em;
91
- margin-bottom: 1em;
92
- }
93
-
94
- .block-editor-content h4 {
95
- font-size: 1.1em;
96
- margin-bottom: 1em;
97
- }
98
-
99
- .block-editor-content h5,
100
- .block-editor-content h6 {
101
- font-size: 1em;
102
- margin-bottom: 1em;
103
- }
104
-
105
- .block-editor-content ul, .block-editor-content ol {
106
- margin-block-start: 1em;
107
- margin-block-end: 1em;
108
- margin-inline-start: 0px;
109
- margin-inline-end: 0px;
110
- padding-inline-start: 40px;
111
- }
112
-
113
- .block-editor-content ul {
114
- list-style-type: disc;
115
- }
116
-
117
- .block-editor-content ol {
118
- list-style-type: decimal;
119
- }
120
-
121
- .block-editor-content blockquote {
122
- display: block;
123
- background-color: grey;
124
- padding: 1em;
125
- }
126
-
127
- .block-editor-content a,
128
- .block-editor-content a:visited {
129
- color: blue;
130
- cursor: pointer;
131
- }
132
-
133
-
134
- .block-editor-content a:hover {
135
- text-decoration: underline;
136
- }
137
-
138
- .editor-mt-16 {
139
- @apply pt-16 block;
140
- }
141
- .editor-mr-16 {
142
- @apply md:pr-16 block;
143
- }
144
- .editor-mb-16 {
145
- @apply pb-16 block;
146
- }
147
- .editor-ml-16 {
148
- @apply md:pl-16 block;
1
+ html, body, #root {
2
+ height: 100%;
3
+ width: 100%;
4
+ }
5
+
6
+ @media (prefers-color-scheme: dark) {
7
+ .slate-editor {
8
+ color: white;
9
+ background-color: #1c1c27;
10
+ }
11
+ }
12
+
13
+ .editor-demo-wrapper {
14
+ display: flex;
15
+ height: 100%;
16
+ justify-content: center;
17
+ width: 100%;
18
+ flex-direction: column;
19
+
20
+ .editor-demo-output {
21
+ display: none;
22
+ width: 100%;
23
+ }
24
+
25
+ .editor-demo {
26
+ display: block;
27
+ flex: 1;
28
+ height: 100%;
29
+ width: 100%;
30
+ position: relative;
31
+
32
+ .editor-demo-editor {
33
+ display: flex;
34
+ height: 100%;
35
+ position: relative;
36
+ width: 100%;
37
+ padding-top: 40px;
38
+
39
+ &.container {
40
+ display: flex;
41
+ flex: 1;
42
+ justify-content: center;
43
+ min-width: 100%;
44
+ min-height: 100%;
45
+ position: relative;
46
+
47
+ &.block-editor-wrapper {
48
+ flex-grow: 1;
49
+ //max-width: 703px;
50
+ //width: 703px; // contentful editor default width
51
+ }
52
+ }
53
+
54
+ &.value {
55
+ textarea {
56
+ max-height: 50px;
57
+ }
58
+ }
59
+ }
60
+ }
61
+ }
62
+
63
+ .test-block {
64
+ background-color: #fefefe;
65
+ border: 1px solid black;
66
+ color: black;
67
+ padding: 5px;
68
+ }
69
+
70
+ .block-editor-content {
71
+ font-family: "Helvetica Neue Light", "HelveticaNeue-Light", "Helvetica Neue", Calibri, Helvetica, Arial, sans-serif;
72
+ line-height: 1em;
73
+ }
74
+
75
+ .block-editor-content p {
76
+ margin-bottom: 20px;
77
+ }
78
+
79
+ .block-editor-content h1 {
80
+ font-size: 2em;
81
+ margin-bottom: 2em;
82
+ }
83
+
84
+ .block-editor-content h2 {
85
+ font-size: 1.5em;
86
+ margin-bottom: 1em;
87
+ }
88
+
89
+ .block-editor-content h3 {
90
+ font-size: 1.3em;
91
+ margin-bottom: 1em;
92
+ }
93
+
94
+ .block-editor-content h4 {
95
+ font-size: 1.1em;
96
+ margin-bottom: 1em;
97
+ }
98
+
99
+ .block-editor-content h5,
100
+ .block-editor-content h6 {
101
+ font-size: 1em;
102
+ margin-bottom: 1em;
103
+ }
104
+
105
+ .block-editor-content ul, .block-editor-content ol {
106
+ margin-block-start: 1em;
107
+ margin-block-end: 1em;
108
+ margin-inline-start: 0px;
109
+ margin-inline-end: 0px;
110
+ padding-inline-start: 40px;
111
+ }
112
+
113
+ .block-editor-content ul {
114
+ list-style-type: disc;
115
+ }
116
+
117
+ .block-editor-content ol {
118
+ list-style-type: decimal;
119
+ }
120
+
121
+ .block-editor-content blockquote {
122
+ display: block;
123
+ background-color: grey;
124
+ padding: 1em;
125
+ }
126
+
127
+ .block-editor-content a,
128
+ .block-editor-content a:visited {
129
+ color: blue;
130
+ cursor: pointer;
131
+ }
132
+
133
+
134
+ .block-editor-content a:hover {
135
+ text-decoration: underline;
136
+ }
137
+
138
+ .editor-mt-16 {
139
+ @apply pt-16 block;
140
+ }
141
+ .editor-mr-16 {
142
+ @apply md:pr-16 block;
143
+ }
144
+ .editor-mb-16 {
145
+ @apply pb-16 block;
146
+ }
147
+ .editor-ml-16 {
148
+ @apply md:pl-16 block;
149
149
  }