@vonaffenfels/slate-editor 1.1.71 → 1.2.10

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 (96) hide show
  1. package/.babelrc +43 -43
  2. package/README.md +5 -5
  3. package/componentLoader.js +93 -93
  4. package/dist/BlockEditor.css +4 -1871
  5. package/dist/BlockEditor.js +336 -3960
  6. package/dist/BlockEditor.js.LICENSE.txt +61 -0
  7. package/dist/Renderer.js +2 -2081
  8. package/dist/Renderer.js.LICENSE.txt +15 -0
  9. package/dist/fromHTML.js +1 -78
  10. package/dist/index.css +4 -1871
  11. package/dist/index.js +336 -4037
  12. package/dist/index.js.LICENSE.txt +69 -0
  13. package/dist/toHTML.js +2 -1689
  14. package/dist/toHTML.js.LICENSE.txt +23 -0
  15. package/dist/toText.js +2 -1689
  16. package/dist/toText.js.LICENSE.txt +23 -0
  17. package/package.json +2 -2
  18. package/postcss.config.js +6 -6
  19. package/scss/demo.scss +148 -148
  20. package/scss/editor.scss +17 -5
  21. package/scss/sidebarEditor.scss +185 -181
  22. package/scss/toolbar.scss +161 -161
  23. package/src/BlockEditor.js +6 -3
  24. package/src/Blocks/EmptyBlock.js +11 -11
  25. package/src/Blocks/EmptyWrapper.js +4 -4
  26. package/src/Blocks/ErrorBoundary.js +40 -40
  27. package/src/Blocks/LayoutBlock.js +274 -274
  28. package/src/Blocks/LayoutSlot.js +90 -90
  29. package/src/CollapsableMenu/CollapsableMenu.js +48 -48
  30. package/src/Context/StorybookContext.js +6 -6
  31. package/src/ElementAutocomplete.js +133 -133
  32. package/src/Loader.js +137 -137
  33. package/src/Nodes/Default.js +158 -158
  34. package/src/Nodes/Leaf.js +54 -54
  35. package/src/Nodes/Text.js +97 -97
  36. package/src/ObjectId.js +3 -3
  37. package/src/Renderer.js +73 -73
  38. package/src/Serializer/Html.js +42 -42
  39. package/src/Serializer/Serializer.js +371 -371
  40. package/src/Serializer/Text.js +17 -17
  41. package/src/Serializer/ads.js +174 -174
  42. package/src/Serializer/index.js +3 -3
  43. package/src/SidebarEditor/AssetList.js +181 -181
  44. package/src/SidebarEditor/Fields/CloudinaryContentSelect.js +89 -89
  45. package/src/SidebarEditor/Fields/ColorPicker.js +89 -89
  46. package/src/SidebarEditor/Fields/ContentfulContentSelect.js +62 -62
  47. package/src/SidebarEditor/Fields/DateTime.js +55 -55
  48. package/src/SidebarEditor/Fields/MVP.js +66 -66
  49. package/src/SidebarEditor/Fields/MultiSelect.js +13 -13
  50. package/src/SidebarEditor/Fields/RemoteMultiSelect.js +40 -40
  51. package/src/SidebarEditor/Fields/RemoteSelect.js +39 -39
  52. package/src/SidebarEditor/Fields/Select.js +47 -47
  53. package/src/SidebarEditor/Fields/StreamSelect.js +15 -15
  54. package/src/SidebarEditor/Fields/Switch.js +34 -34
  55. package/src/SidebarEditor/Fields/Textarea.js +21 -21
  56. package/src/SidebarEditor/Resizable.js +85 -85
  57. package/src/Storybook.js +151 -151
  58. package/src/Toolbar/Align.js +64 -64
  59. package/src/Toolbar/Anchor.js +94 -94
  60. package/src/Toolbar/Block.js +135 -135
  61. package/src/Toolbar/Element.js +44 -44
  62. package/src/Toolbar/Formats.js +71 -71
  63. package/src/Toolbar/Insert.js +28 -28
  64. package/src/Toolbar/Layout.js +399 -399
  65. package/src/Toolbar/Link.js +164 -164
  66. package/src/Toolbar/Toolbar.js +235 -235
  67. package/src/Tools/Margin.js +51 -51
  68. package/src/Translation/TranslationToolbarButton.js +119 -115
  69. package/src/dev/draftToSlate.json +3147 -3147
  70. package/src/dev/index.css +2 -2
  71. package/src/dev/index.html +10 -10
  72. package/src/dev/index.js +4 -4
  73. package/src/dev/sampleValue1.json +4294 -4294
  74. package/src/dev/sampleValueValid.json +410 -410
  75. package/src/dev/testComponents/TestStory.js +74 -74
  76. package/src/dev/testComponents/TestStory.stories.js +216 -216
  77. package/src/dev/testComponents/TestStory2.js +74 -74
  78. package/src/dev/testComponents/TestStory2.stories.js +197 -197
  79. package/src/dev/testComponents/TestStory3.js +74 -74
  80. package/src/dev/testComponents/TestStory3.stories.js +197 -197
  81. package/src/dev/testSampleValue.json +746 -746
  82. package/src/fromHTML.js +4 -4
  83. package/src/helper/array.js +8 -8
  84. package/src/index.js +10 -10
  85. package/src/plugins/ListItem.js +48 -48
  86. package/src/plugins/SoftBreak.js +23 -23
  87. package/src/toHTML.js +6 -6
  88. package/src/toText.js +6 -6
  89. package/src/util/reduceContentfulResponse.js +64 -64
  90. package/src/util.js +19 -19
  91. package/storyLoader.js +47 -47
  92. package/tailwind.config.js +4 -4
  93. package/webpack.config.build.js +55 -55
  94. package/webpack.config.dev.js +60 -60
  95. package/webpack.config.js +130 -130
  96. package/webpack.config.watch.js +4 -4
package/scss/toolbar.scss CHANGED
@@ -1,162 +1,162 @@
1
- .toolbar {
2
- background-color: rgba(255, 255, 255, 0.95);
3
- border-bottom: 1px solid rgba(0, 0, 0, 0.3);
4
- display: none;
5
- flex-direction: row;
6
- justify-content: space-between;
7
- font-family: Arial, sans-serif;
8
- padding: 5px;
9
- position: absolute;
10
- z-index: 500;
11
-
12
- &.toolbar-static {
13
- display: block;
14
- position: fixed;
15
- width: 100%;
16
- max-width: 100%;
17
- top: 0px;
18
- left: 0px;
19
- }
20
-
21
- &.active {
22
- display: block;
23
- }
24
-
25
- .toolbar-btns {
26
- display: flex;
27
- align-items: center;
28
- }
29
-
30
- .toolbar-btn {
31
- border-radius: 3px;
32
- color: black;
33
- cursor: pointer;
34
- font-weight: bold;
35
- margin-right: 5px;
36
- padding: 5px 7px;
37
- z-index: 500;
38
- position: relative;
39
- display: block;
40
-
41
- &.active {
42
- background-color: rgba(0, 0, 0, 0.3);
43
- }
44
-
45
- &:last-child {
46
- margin-right: 0px;
47
- }
48
-
49
- &:hover, &:active {
50
- background-color: rgba(0, 0, 0, 0.2);
51
-
52
- .toolbar-btn-config {
53
- display: block;
54
- }
55
- }
56
-
57
- .toolbar-btn-config {
58
- position: absolute;
59
- top: 28px;
60
- left: 0px;
61
- display: none;
62
- background-color: rgba(255, 255, 255, 0.95);
63
- border-bottom: 1px solid rgba(0, 0, 0, 0.3);
64
- padding: 5px 7px;
65
-
66
- .toolbar-btn-config-inner {
67
- display: flex;
68
- flex-direction: column;
69
-
70
- .toolbar-btn-config-row {
71
- min-width: 250px;
72
- padding: 5px 7px;
73
- display: flex;
74
- flex-direction: row;
75
-
76
- .toolbar-form-label {
77
- flex-grow: 0;
78
- padding: 0 7px 0 0;
79
- }
80
-
81
- .toolbar-form-input {
82
- flex-grow: 1;
83
-
84
- input {
85
- padding: 5px;
86
- border: 1px solid grey;
87
- background-color: white;
88
- color: black;
89
-
90
- &[type="checkbox"] {
91
- &:checked {
92
- color: white;
93
- background-color: black;
94
- }
95
- }
96
- }
97
- }
98
-
99
- .toolbar-btn {
100
- display: flex;
101
- flex-grow: 1;
102
- border: 1px solid black;
103
- }
104
- }
105
- }
106
- }
107
- }
108
-
109
- .toolbar-btn-expand {
110
- z-index: 500;
111
- display: block;
112
- max-height: 28px;
113
- overflow: hidden;
114
-
115
- .toolbar-btn-expand-inner {
116
- display: flex;
117
- flex-direction: column;
118
-
119
- .toolbar-btn.active {
120
- order: -1;
121
- }
122
- }
123
-
124
- &:hover {
125
- .toolbar-btn-expand-inner {
126
- background-color: rgba(255, 255, 255, 0.95);
127
- border-bottom: 1px solid rgba(0, 0, 0, 0.3);
128
- }
129
-
130
- overflow: visible;
131
- }
132
-
133
- }
134
-
135
-
136
- .toolbar-btn-expand-right {
137
- z-index: 500;
138
- display: block;
139
- max-height: 28px;
140
- overflow: hidden;
141
-
142
- .toolbar-btn-expand-inner {
143
- left: 100%;
144
- display: flex;
145
- flex-direction: column;
146
-
147
- .toolbar-btn.active {
148
- order: -1;
149
- }
150
- }
151
-
152
- &:hover {
153
- .toolbar-btn-expand-inner {
154
- background-color: rgba(255, 255, 255, 0.95);
155
- border-bottom: 1px solid rgba(0, 0, 0, 0.3);
156
- }
157
-
158
- overflow: visible;
159
- }
160
-
161
- }
1
+ .toolbar {
2
+ background-color: rgba(255, 255, 255, 0.95);
3
+ border-bottom: 1px solid rgba(0, 0, 0, 0.3);
4
+ display: none;
5
+ flex-direction: row;
6
+ justify-content: space-between;
7
+ font-family: Arial, sans-serif;
8
+ padding: 5px;
9
+ position: absolute;
10
+ z-index: 500;
11
+
12
+ &.toolbar-static {
13
+ display: block;
14
+ position: fixed;
15
+ width: 100%;
16
+ max-width: 100%;
17
+ top: 0px;
18
+ left: 0px;
19
+ }
20
+
21
+ &.active {
22
+ display: block;
23
+ }
24
+
25
+ .toolbar-btns {
26
+ display: flex;
27
+ align-items: center;
28
+ }
29
+
30
+ .toolbar-btn {
31
+ border-radius: 3px;
32
+ color: black;
33
+ cursor: pointer;
34
+ font-weight: bold;
35
+ margin-right: 5px;
36
+ padding: 5px 7px;
37
+ z-index: 500;
38
+ position: relative;
39
+ display: block;
40
+
41
+ &.active {
42
+ background-color: rgba(0, 0, 0, 0.3);
43
+ }
44
+
45
+ &:last-child {
46
+ margin-right: 0px;
47
+ }
48
+
49
+ &:hover, &:active {
50
+ background-color: rgba(0, 0, 0, 0.2);
51
+
52
+ .toolbar-btn-config {
53
+ display: block;
54
+ }
55
+ }
56
+
57
+ .toolbar-btn-config {
58
+ position: absolute;
59
+ top: 28px;
60
+ left: 0px;
61
+ display: none;
62
+ background-color: rgba(255, 255, 255, 0.95);
63
+ border-bottom: 1px solid rgba(0, 0, 0, 0.3);
64
+ padding: 5px 7px;
65
+
66
+ .toolbar-btn-config-inner {
67
+ display: flex;
68
+ flex-direction: column;
69
+
70
+ .toolbar-btn-config-row {
71
+ min-width: 250px;
72
+ padding: 5px 7px;
73
+ display: flex;
74
+ flex-direction: row;
75
+
76
+ .toolbar-form-label {
77
+ flex-grow: 0;
78
+ padding: 0 7px 0 0;
79
+ }
80
+
81
+ .toolbar-form-input {
82
+ flex-grow: 1;
83
+
84
+ input {
85
+ padding: 5px;
86
+ border: 1px solid grey;
87
+ background-color: white;
88
+ color: black;
89
+
90
+ &[type="checkbox"] {
91
+ &:checked {
92
+ color: white;
93
+ background-color: black;
94
+ }
95
+ }
96
+ }
97
+ }
98
+
99
+ .toolbar-btn {
100
+ display: flex;
101
+ flex-grow: 1;
102
+ border: 1px solid black;
103
+ }
104
+ }
105
+ }
106
+ }
107
+ }
108
+
109
+ .toolbar-btn-expand {
110
+ z-index: 500;
111
+ display: block;
112
+ max-height: 28px;
113
+ overflow: hidden;
114
+
115
+ .toolbar-btn-expand-inner {
116
+ display: flex;
117
+ flex-direction: column;
118
+
119
+ .toolbar-btn.active {
120
+ order: -1;
121
+ }
122
+ }
123
+
124
+ &:hover {
125
+ .toolbar-btn-expand-inner {
126
+ background-color: rgba(255, 255, 255, 0.95);
127
+ border-bottom: 1px solid rgba(0, 0, 0, 0.3);
128
+ }
129
+
130
+ overflow: visible;
131
+ }
132
+
133
+ }
134
+
135
+
136
+ .toolbar-btn-expand-right {
137
+ z-index: 500;
138
+ display: block;
139
+ max-height: 28px;
140
+ overflow: hidden;
141
+
142
+ .toolbar-btn-expand-inner {
143
+ left: 100%;
144
+ display: flex;
145
+ flex-direction: column;
146
+
147
+ .toolbar-btn.active {
148
+ order: -1;
149
+ }
150
+ }
151
+
152
+ &:hover {
153
+ .toolbar-btn-expand-inner {
154
+ background-color: rgba(255, 255, 255, 0.95);
155
+ border-bottom: 1px solid rgba(0, 0, 0, 0.3);
156
+ }
157
+
158
+ overflow: visible;
159
+ }
160
+
161
+ }
162
162
  }
@@ -17,7 +17,9 @@ import "../scss/editor.scss";
17
17
  import {ListItemPlugin} from "./plugins/ListItem";
18
18
  import ErrorBoundary from "../src/Blocks/ErrorBoundary";
19
19
  import SidebarEditor from './SidebarEditor';
20
- import {Spinner} from '@contentful/forma-36-react-components';
20
+ import {
21
+ Button, Spinner,
22
+ } from '@contentful/forma-36-react-components';
21
23
  import {ObjectId} from "./ObjectId";
22
24
  import {Resizable} from "./SidebarEditor/Resizable";
23
25
  import {Loader} from "./Loader";
@@ -421,10 +423,11 @@ export default function BlockEditor({
421
423
  sdk={contentfulSdk}
422
424
  setEditorValue={onSlateChange}
423
425
  locale={locale}
426
+ className="shrink-0"
424
427
  setLocale={setLocale}/>
425
428
  {liveLink && (
426
- <a href={liveLink} target="_blank" rel="noreferrer">
427
- <button className='button button--secondary'>Live-Seite öffnen</button>
429
+ <a href={liveLink} target="_blank" rel="noreferrer" className='shrink-0'>
430
+ <Button className='whitespace-nowrap' icon="ExternalLink" buttonType='naked'>Live ansehen</Button>
428
431
  </a>
429
432
  )}
430
433
  </div>}/>
@@ -1,12 +1,12 @@
1
- import React from "react";
2
-
3
- export const EmptyBlock = () => {
4
- if (process.env.NEXT_PUBLIC_VERCEL_ENV === "production") {
5
- // hide this in production
6
- return null;
7
- }
8
-
9
- return <span className="editor-empty-element" style={{minHeight: 200, display: "inline-block"}}>
10
- Unbekanntes Element
11
- </span>;
1
+ import React from "react";
2
+
3
+ export const EmptyBlock = () => {
4
+ if (process.env.NEXT_PUBLIC_VERCEL_ENV === "production") {
5
+ // hide this in production
6
+ return null;
7
+ }
8
+
9
+ return <span className="editor-empty-element" style={{minHeight: 200, display: "inline-block"}}>
10
+ Unbekanntes Element
11
+ </span>;
12
12
  };
@@ -1,5 +1,5 @@
1
- import React from "react";
2
-
3
- export const EmptyWrapper = ({children}) => {
4
- return <>{children}</>;
1
+ import React from "react";
2
+
3
+ export const EmptyWrapper = ({children}) => {
4
+ return <>{children}</>;
5
5
  };
@@ -1,41 +1,41 @@
1
- import React from "react";
2
-
3
- export default class ErrorBoundary extends React.Component {
4
- constructor(props) {
5
- super(props);
6
- this.state = {
7
- hasError: false,
8
- };
9
- }
10
-
11
- static getDerivedStateFromError(error) {
12
- return {hasError: true};
13
- }
14
-
15
- componentDidCatch(error, errorInfo) {
16
- const groupName = `Error in ${this.props.name}`;
17
- console.groupCollapsed(groupName);
18
- console.error("Error", error);
19
- console.error("Info", errorInfo);
20
- console.groupEnd(groupName);
21
- }
22
-
23
- render() {
24
- if (this.state.hasError) {
25
-
26
- if (this.props.fallback) {
27
- return this.props.fallback;
28
- }
29
-
30
- if (this.props.isEditor) {
31
- return <div className="storybook-element-error">
32
- <p>Error in Element {this.props.name}</p>
33
- </div>;
34
- }
35
-
36
- return null;
37
- }
38
-
39
- return this.props.children;
40
- }
1
+ import React from "react";
2
+
3
+ export default class ErrorBoundary extends React.Component {
4
+ constructor(props) {
5
+ super(props);
6
+ this.state = {
7
+ hasError: false,
8
+ };
9
+ }
10
+
11
+ static getDerivedStateFromError(error) {
12
+ return {hasError: true};
13
+ }
14
+
15
+ componentDidCatch(error, errorInfo) {
16
+ const groupName = `Error in ${this.props.name}`;
17
+ console.groupCollapsed(groupName);
18
+ console.error("Error", error);
19
+ console.error("Info", errorInfo);
20
+ console.groupEnd(groupName);
21
+ }
22
+
23
+ render() {
24
+ if (this.state.hasError) {
25
+
26
+ if (this.props.fallback) {
27
+ return this.props.fallback;
28
+ }
29
+
30
+ if (this.props.isEditor) {
31
+ return <div className="storybook-element-error">
32
+ <p>Error in Element {this.props.name}</p>
33
+ </div>;
34
+ }
35
+
36
+ return null;
37
+ }
38
+
39
+ return this.props.children;
40
+ }
41
41
  }