@vonaffenfels/slate-editor 1.0.81 → 1.1.3
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/dist/BlockEditor.css +2 -2
- package/dist/BlockEditor.js +1 -1
- package/dist/Renderer.js +1 -1
- package/dist/index.css +2 -2
- package/dist/index.js +1 -1
- package/package.json +2 -2
- package/scss/editor.scss +11 -0
- package/scss/storybook.scss +10 -1
- package/src/BlockEditor.js +49 -4
- package/src/Loader.js +138 -0
- package/src/Nodes/Default.js +48 -40
- package/src/Nodes/Element.js +2 -1
- package/src/Nodes/Storybook.js +48 -7
- package/src/Nodes/StorybookDisplay.js +17 -14
- package/src/Serializer/Serializer.js +3 -3
- package/src/SidebarEditor/Resizable.js +4 -1
- package/src/SidebarEditor.js +8 -0
- package/src/Toolbar/Element.js +0 -4
- package/src/Toolbar/Toolbar.js +0 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vonaffenfels/slate-editor",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.1.3",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -71,7 +71,7 @@
|
|
|
71
71
|
"cssnano": "^5.0.1",
|
|
72
72
|
"escape-html": "^1.0.3"
|
|
73
73
|
},
|
|
74
|
-
"gitHead": "
|
|
74
|
+
"gitHead": "9bb577c35e6bd63588821abb46c9a3d4d400bda2",
|
|
75
75
|
"publishConfig": {
|
|
76
76
|
"access": "public"
|
|
77
77
|
}
|
package/scss/editor.scss
CHANGED
|
@@ -427,11 +427,22 @@
|
|
|
427
427
|
}
|
|
428
428
|
|
|
429
429
|
.resizable {
|
|
430
|
+
|
|
431
|
+
&.enabled {
|
|
432
|
+
.resizable-left {
|
|
433
|
+
max-width: calc(100vw - 300px);
|
|
434
|
+
}
|
|
435
|
+
}
|
|
436
|
+
|
|
430
437
|
.resizable-left {
|
|
438
|
+
scrollbar-width: none;
|
|
439
|
+
max-width: 100vw;
|
|
431
440
|
position: relative;
|
|
432
441
|
}
|
|
433
442
|
|
|
434
443
|
.resizable-right {
|
|
444
|
+
scrollbar-width: none;
|
|
445
|
+
max-width: calc(100vw - 300px);
|
|
435
446
|
position: relative;
|
|
436
447
|
}
|
|
437
448
|
|
package/scss/storybook.scss
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
|
+
.storybook-element-wrapper {
|
|
2
|
+
max-width: 100vw;
|
|
3
|
+
width: 100%;
|
|
4
|
+
margin-left: auto;
|
|
5
|
+
margin-right: auto;
|
|
6
|
+
}
|
|
7
|
+
|
|
1
8
|
.storybook-element {
|
|
2
|
-
display: inline;
|
|
9
|
+
display: inline-block;
|
|
10
|
+
width: 100%;
|
|
3
11
|
|
|
4
12
|
.storybook-element-component-overlay {
|
|
5
13
|
display: none;
|
|
@@ -8,6 +16,7 @@
|
|
|
8
16
|
position: absolute;
|
|
9
17
|
z-index: 20;
|
|
10
18
|
background-color: rgba(255, 255, 255, 0.7);
|
|
19
|
+
backdrop-filter: blur(4px);
|
|
11
20
|
color: black;
|
|
12
21
|
font-size: 1em;
|
|
13
22
|
align-items: center;
|
package/src/BlockEditor.js
CHANGED
|
@@ -20,6 +20,7 @@ import SidebarEditor from './SidebarEditor';
|
|
|
20
20
|
import {Spinner} from '@contentful/forma-36-react-components';
|
|
21
21
|
import {ObjectId} from "./ObjectId";
|
|
22
22
|
import {Resizable} from "./SidebarEditor/Resizable";
|
|
23
|
+
import {Loader} from "./Loader";
|
|
23
24
|
|
|
24
25
|
export default function BlockEditor({
|
|
25
26
|
onChange,
|
|
@@ -86,7 +87,6 @@ export default function BlockEditor({
|
|
|
86
87
|
let loadedStories = await storybookStories();
|
|
87
88
|
|
|
88
89
|
setIsLoadingStories(false);
|
|
89
|
-
|
|
90
90
|
setLoadedStorybookStories(loadedStories);
|
|
91
91
|
};
|
|
92
92
|
|
|
@@ -100,13 +100,46 @@ export default function BlockEditor({
|
|
|
100
100
|
}
|
|
101
101
|
};
|
|
102
102
|
|
|
103
|
+
const fixValue = (newValue) => {
|
|
104
|
+
const fixedValue = [...(newValue || [])];
|
|
105
|
+
|
|
106
|
+
return fixedValue.map(node => {
|
|
107
|
+
// unwrap elements that are inside of a paragraph (that has no text content) so they have been inserted "inline" by mistake
|
|
108
|
+
// this helps preventing a lot of hydration errors!
|
|
109
|
+
if (node?.type === "paragraph") {
|
|
110
|
+
const textContent = node.children.find(v => !v?.type && v?.text);
|
|
111
|
+
if (!textContent) {
|
|
112
|
+
const storybookNodes = node.children.filter(v => v?.type === "storybook");
|
|
113
|
+
// only unwrap if we only have exactly 1 node
|
|
114
|
+
if (storybookNodes.length === 1) {
|
|
115
|
+
const storyNode = storybookNodes.at(0);
|
|
116
|
+
storyNode.isInline = false;
|
|
117
|
+
return storyNode;
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
} else if (node?.type === "storybook") {
|
|
121
|
+
if (node.isInline) {
|
|
122
|
+
// we need to copy the node since its readOnly
|
|
123
|
+
return {
|
|
124
|
+
...node,
|
|
125
|
+
isInline: undefined,
|
|
126
|
+
};
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
return node;
|
|
131
|
+
});
|
|
132
|
+
};
|
|
133
|
+
|
|
103
134
|
const onSlateChange = (newValue) => {
|
|
104
135
|
if (editor.selection) {
|
|
105
136
|
setLastSelection(editor.selection);
|
|
106
137
|
}
|
|
107
138
|
|
|
108
|
-
|
|
109
|
-
|
|
139
|
+
const newValueFixed = fixValue(newValue);
|
|
140
|
+
|
|
141
|
+
if (newValueFixed.length > 0) {
|
|
142
|
+
onChange(newValueFixed);
|
|
110
143
|
} else {
|
|
111
144
|
onChange(emptyValue);
|
|
112
145
|
}
|
|
@@ -322,6 +355,18 @@ export default function BlockEditor({
|
|
|
322
355
|
|
|
323
356
|
const slug = contentfulSdk?.entry?.fields?.slug?.getValue();
|
|
324
357
|
|
|
358
|
+
if (isLoadingStories) {
|
|
359
|
+
return <div style={{
|
|
360
|
+
display: "flex",
|
|
361
|
+
justifyContent: "center",
|
|
362
|
+
alignItems: "center",
|
|
363
|
+
width: "100%",
|
|
364
|
+
height: "100%",
|
|
365
|
+
}}>
|
|
366
|
+
<Loader/>
|
|
367
|
+
</div>;
|
|
368
|
+
}
|
|
369
|
+
|
|
325
370
|
return (
|
|
326
371
|
<div className={classNames({"block-editor-wrapper h-full": true})}>
|
|
327
372
|
<Resizable
|
|
@@ -392,7 +437,7 @@ export default function BlockEditor({
|
|
|
392
437
|
onDuplicate={handleSidebarDuplicateClick}
|
|
393
438
|
onInsert={handleSidebarInsertClick}
|
|
394
439
|
editor={editor}
|
|
395
|
-
lastSelection={lastSelection}
|
|
440
|
+
lastSelection={lastSelection}/>
|
|
396
441
|
}
|
|
397
442
|
/>
|
|
398
443
|
</div>
|
package/src/Loader.js
ADDED
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
export const Loader = ({
|
|
2
|
+
width = "240px",
|
|
3
|
+
height = "240px",
|
|
4
|
+
}) => {
|
|
5
|
+
return <svg
|
|
6
|
+
style={{
|
|
7
|
+
margin: "auto",
|
|
8
|
+
background: "none",
|
|
9
|
+
display: "block",
|
|
10
|
+
shapeRendering: "auto",
|
|
11
|
+
}}
|
|
12
|
+
width={width}
|
|
13
|
+
height={height}
|
|
14
|
+
viewBox="0 0 100 100"
|
|
15
|
+
preserveAspectRatio="xMidYMid">
|
|
16
|
+
<g transform="rotate(0 50 50)">
|
|
17
|
+
<rect x="46.5" y="17.5" rx="3.5" ry="1.5" width="7" height="3" fill="#000000">
|
|
18
|
+
<animate
|
|
19
|
+
attributeName="opacity"
|
|
20
|
+
values="1;0"
|
|
21
|
+
keyTimes="0;1"
|
|
22
|
+
dur="0.9174311926605504s"
|
|
23
|
+
begin="-0.8340283569641368s"
|
|
24
|
+
repeatCount="indefinite" />
|
|
25
|
+
</rect>
|
|
26
|
+
</g>
|
|
27
|
+
<g transform="rotate(32.72727272727273 50 50)">
|
|
28
|
+
<rect x="46.5" y="17.5" rx="3.5" ry="1.5" width="7" height="3" fill="#000000">
|
|
29
|
+
<animate
|
|
30
|
+
attributeName="opacity"
|
|
31
|
+
values="1;0"
|
|
32
|
+
keyTimes="0;1"
|
|
33
|
+
dur="0.9174311926605504s"
|
|
34
|
+
begin="-0.7506255212677231s"
|
|
35
|
+
repeatCount="indefinite" />
|
|
36
|
+
</rect>
|
|
37
|
+
</g>
|
|
38
|
+
<g transform="rotate(65.45454545454545 50 50)">
|
|
39
|
+
<rect x="46.5" y="17.5" rx="3.5" ry="1.5" width="7" height="3" fill="#000000">
|
|
40
|
+
<animate
|
|
41
|
+
attributeName="opacity"
|
|
42
|
+
values="1;0"
|
|
43
|
+
keyTimes="0;1"
|
|
44
|
+
dur="0.9174311926605504s"
|
|
45
|
+
begin="-0.6672226855713094s"
|
|
46
|
+
repeatCount="indefinite" />
|
|
47
|
+
</rect>
|
|
48
|
+
</g>
|
|
49
|
+
<g transform="rotate(98.18181818181819 50 50)">
|
|
50
|
+
<rect x="46.5" y="17.5" rx="3.5" ry="1.5" width="7" height="3" fill="#000000">
|
|
51
|
+
<animate
|
|
52
|
+
attributeName="opacity"
|
|
53
|
+
values="1;0"
|
|
54
|
+
keyTimes="0;1"
|
|
55
|
+
dur="0.9174311926605504s"
|
|
56
|
+
begin="-0.5838198498748958s"
|
|
57
|
+
repeatCount="indefinite" />
|
|
58
|
+
</rect>
|
|
59
|
+
</g>
|
|
60
|
+
<g transform="rotate(130.9090909090909 50 50)">
|
|
61
|
+
<rect x="46.5" y="17.5" rx="3.5" ry="1.5" width="7" height="3" fill="#000000">
|
|
62
|
+
<animate
|
|
63
|
+
attributeName="opacity"
|
|
64
|
+
values="1;0"
|
|
65
|
+
keyTimes="0;1"
|
|
66
|
+
dur="0.9174311926605504s"
|
|
67
|
+
begin="-0.5004170141784821s"
|
|
68
|
+
repeatCount="indefinite" />
|
|
69
|
+
</rect>
|
|
70
|
+
</g>
|
|
71
|
+
<g transform="rotate(163.63636363636363 50 50)">
|
|
72
|
+
<rect x="46.5" y="17.5" rx="3.5" ry="1.5" width="7" height="3" fill="#000000">
|
|
73
|
+
<animate
|
|
74
|
+
attributeName="opacity"
|
|
75
|
+
values="1;0"
|
|
76
|
+
keyTimes="0;1"
|
|
77
|
+
dur="0.9174311926605504s"
|
|
78
|
+
begin="-0.4170141784820684s"
|
|
79
|
+
repeatCount="indefinite" />
|
|
80
|
+
</rect>
|
|
81
|
+
</g>
|
|
82
|
+
<g transform="rotate(196.36363636363637 50 50)">
|
|
83
|
+
<rect x="46.5" y="17.5" rx="3.5" ry="1.5" width="7" height="3" fill="#000000">
|
|
84
|
+
<animate
|
|
85
|
+
attributeName="opacity"
|
|
86
|
+
values="1;0"
|
|
87
|
+
keyTimes="0;1"
|
|
88
|
+
dur="0.9174311926605504s"
|
|
89
|
+
begin="-0.3336113427856547s"
|
|
90
|
+
repeatCount="indefinite" />
|
|
91
|
+
</rect>
|
|
92
|
+
</g>
|
|
93
|
+
<g transform="rotate(229.0909090909091 50 50)">
|
|
94
|
+
<rect x="46.5" y="17.5" rx="3.5" ry="1.5" width="7" height="3" fill="#000000">
|
|
95
|
+
<animate
|
|
96
|
+
attributeName="opacity"
|
|
97
|
+
values="1;0"
|
|
98
|
+
keyTimes="0;1"
|
|
99
|
+
dur="0.9174311926605504s"
|
|
100
|
+
begin="-0.25020850708924103s"
|
|
101
|
+
repeatCount="indefinite" />
|
|
102
|
+
</rect>
|
|
103
|
+
</g>
|
|
104
|
+
<g transform="rotate(261.8181818181818 50 50)">
|
|
105
|
+
<rect x="46.5" y="17.5" rx="3.5" ry="1.5" width="7" height="3" fill="#000000">
|
|
106
|
+
<animate
|
|
107
|
+
attributeName="opacity"
|
|
108
|
+
values="1;0"
|
|
109
|
+
keyTimes="0;1"
|
|
110
|
+
dur="0.9174311926605504s"
|
|
111
|
+
begin="-0.16680567139282734s"
|
|
112
|
+
repeatCount="indefinite" />
|
|
113
|
+
</rect>
|
|
114
|
+
</g>
|
|
115
|
+
<g transform="rotate(294.54545454545456 50 50)">
|
|
116
|
+
<rect x="46.5" y="17.5" rx="3.5" ry="1.5" width="7" height="3" fill="#000000">
|
|
117
|
+
<animate
|
|
118
|
+
attributeName="opacity"
|
|
119
|
+
values="1;0"
|
|
120
|
+
keyTimes="0;1"
|
|
121
|
+
dur="0.9174311926605504s"
|
|
122
|
+
begin="-0.08340283569641367s"
|
|
123
|
+
repeatCount="indefinite" />
|
|
124
|
+
</rect>
|
|
125
|
+
</g>
|
|
126
|
+
<g transform="rotate(327.27272727272725 50 50)">
|
|
127
|
+
<rect x="46.5" y="17.5" rx="3.5" ry="1.5" width="7" height="3" fill="#000000">
|
|
128
|
+
<animate
|
|
129
|
+
attributeName="opacity"
|
|
130
|
+
values="1;0"
|
|
131
|
+
keyTimes="0;1"
|
|
132
|
+
dur="0.9174311926605504s"
|
|
133
|
+
begin="0s"
|
|
134
|
+
repeatCount="indefinite" />
|
|
135
|
+
</rect>
|
|
136
|
+
</g>
|
|
137
|
+
</svg>;
|
|
138
|
+
};
|
package/src/Nodes/Default.js
CHANGED
|
@@ -11,7 +11,8 @@ export const Default = ({
|
|
|
11
11
|
isRenderer,
|
|
12
12
|
isInSlot = false,
|
|
13
13
|
defaultComponentReplacement,
|
|
14
|
-
onElementClick = () => {
|
|
14
|
+
onElementClick = () => {
|
|
15
|
+
},
|
|
15
16
|
...props
|
|
16
17
|
}) => {
|
|
17
18
|
const getPropsForType = (type) => {
|
|
@@ -54,56 +55,52 @@ export const Default = ({
|
|
|
54
55
|
}
|
|
55
56
|
|
|
56
57
|
attributes.onClick = () => onElementClick(element);
|
|
58
|
+
attributes.className = alignedClassname.trim() || undefined;
|
|
57
59
|
|
|
58
60
|
switch (type) {
|
|
59
61
|
case "blockquote":
|
|
60
|
-
return <Wrapper>
|
|
61
|
-
<blockquote {...attributes}
|
|
62
|
+
return <Wrapper type={type}>
|
|
63
|
+
<blockquote {...attributes}>{children}</blockquote>
|
|
62
64
|
</Wrapper>;
|
|
63
65
|
case "list-item":
|
|
64
|
-
return <Wrapper>
|
|
65
|
-
<li {...attributes}
|
|
66
|
+
return <Wrapper type={type}>
|
|
67
|
+
<li {...attributes}>{children}</li>
|
|
66
68
|
</Wrapper>;
|
|
67
69
|
case "unordered-list":
|
|
68
|
-
return <Wrapper>
|
|
69
|
-
<ul {...attributes}
|
|
70
|
+
return <Wrapper type={type}>
|
|
71
|
+
<ul {...attributes}>{children}</ul>
|
|
70
72
|
</Wrapper>;
|
|
71
73
|
case "ordered-list":
|
|
72
|
-
return <Wrapper>
|
|
73
|
-
<ol {...attributes}
|
|
74
|
+
return <Wrapper type={type}>
|
|
75
|
+
<ol {...attributes}>{children}</ol>
|
|
74
76
|
</Wrapper>;
|
|
75
77
|
case "arrow-list":
|
|
76
|
-
return <Wrapper>
|
|
78
|
+
return <Wrapper type={type}>
|
|
77
79
|
<ul
|
|
78
80
|
{...attributes}
|
|
79
|
-
className={classNames({
|
|
80
|
-
...alignedClassname.trim(),
|
|
81
|
-
"arrow-list": true,
|
|
82
|
-
})}>{children}</ul>
|
|
81
|
+
className={classNames("arrow-list", attributes.className)}>{children}</ul>
|
|
83
82
|
</Wrapper>;
|
|
84
83
|
case "code":
|
|
85
84
|
if (isRenderer) {
|
|
86
|
-
return <Wrapper code={element?.attributes?.code} />;
|
|
85
|
+
return <Wrapper code={element?.attributes?.code} type={type}/>;
|
|
87
86
|
} else {
|
|
88
|
-
return <Wrapper
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
return <Wrapper level={element.attributes.level}><h1 {...attributes} id={element?.attributes?.id || undefined} className={alignedClassname.trim() || undefined}>{children}</h1></Wrapper>;
|
|
94
|
-
case 2:
|
|
95
|
-
return <Wrapper level={element.attributes.level}><h2 {...attributes} id={element?.attributes?.id || undefined} className={alignedClassname.trim() || undefined}>{children}</h2></Wrapper>;
|
|
96
|
-
case 3:
|
|
97
|
-
return <Wrapper level={element.attributes.level}><h3 {...attributes} id={element?.attributes?.id || undefined} className={alignedClassname.trim() || undefined}>{children}</h3></Wrapper>;
|
|
98
|
-
case 4:
|
|
99
|
-
return <Wrapper level={element.attributes.level}><h4 {...attributes} id={element?.attributes?.id || undefined} className={alignedClassname.trim() || undefined}>{children}</h4></Wrapper>;
|
|
100
|
-
case 5:
|
|
101
|
-
return <Wrapper level={element.attributes.level}><h5 {...attributes} id={element?.attributes?.id || undefined} className={alignedClassname.trim() || undefined}>{children}</h5></Wrapper>;
|
|
102
|
-
case 6:
|
|
103
|
-
return <Wrapper level={element.attributes.level}><h6 {...attributes} id={element?.attributes?.id || undefined} className={alignedClassname.trim() || undefined}>{children}</h6></Wrapper>;
|
|
104
|
-
default:
|
|
105
|
-
return null;
|
|
87
|
+
return <Wrapper type={type}>
|
|
88
|
+
<div {...attributes} >
|
|
89
|
+
<div dangerouslySetInnerHTML={{__html: element?.attributes?.code}}/>
|
|
90
|
+
</div>
|
|
91
|
+
</Wrapper>;
|
|
106
92
|
}
|
|
93
|
+
case "heading": {
|
|
94
|
+
const HeadingTag = `h${element.attributes.level || 1}`;
|
|
95
|
+
return <Wrapper level={element.attributes.level} type={type}>
|
|
96
|
+
<HeadingTag
|
|
97
|
+
{...attributes}
|
|
98
|
+
id={element?.attributes?.id || undefined}
|
|
99
|
+
>
|
|
100
|
+
{children}
|
|
101
|
+
</HeadingTag>
|
|
102
|
+
</Wrapper>;
|
|
103
|
+
}
|
|
107
104
|
case "link": {
|
|
108
105
|
let relProp = `noopener noreferrer`;
|
|
109
106
|
let {
|
|
@@ -121,29 +118,40 @@ export const Default = ({
|
|
|
121
118
|
let CustomLink = typeof defaultComponentReplacement === "function" ? defaultComponentReplacement(type) : null;
|
|
122
119
|
|
|
123
120
|
if (CustomLink) {
|
|
124
|
-
return <Wrapper
|
|
121
|
+
return <Wrapper type={type}><CustomLink
|
|
122
|
+
{...linkAttributes}
|
|
123
|
+
{...attributes}
|
|
124
|
+
rel={relProp}
|
|
125
|
+
className={alignedClassname.trim()}>{children}</CustomLink></Wrapper>;
|
|
125
126
|
} else {
|
|
126
|
-
return <Wrapper
|
|
127
|
+
return <Wrapper type={type}><a
|
|
128
|
+
{...linkAttributes}
|
|
129
|
+
{...attributes}
|
|
130
|
+
rel={relProp}
|
|
131
|
+
className={alignedClassname.trim()}>{children}</a></Wrapper>;
|
|
127
132
|
}
|
|
128
133
|
}
|
|
129
134
|
case "paragraph":
|
|
130
|
-
return <Wrapper
|
|
135
|
+
return <Wrapper type={type}><p
|
|
136
|
+
{...element.attributes}
|
|
137
|
+
{...attributes}
|
|
138
|
+
className={alignedClassname.trim()}>{children}</p></Wrapper>;
|
|
131
139
|
case "divider":
|
|
132
|
-
return <Wrapper>
|
|
140
|
+
return <Wrapper type={type}>
|
|
133
141
|
<hr {...attributes} />
|
|
134
142
|
{children}
|
|
135
143
|
</Wrapper>;
|
|
136
144
|
case "div":
|
|
137
|
-
return <Wrapper>
|
|
145
|
+
return <Wrapper type={type}>
|
|
138
146
|
<div {...element.attributes} {...attributes}>{children}</div>
|
|
139
147
|
</Wrapper>;
|
|
140
148
|
case "span":
|
|
141
|
-
return <Wrapper>
|
|
149
|
+
return <Wrapper type={type}>
|
|
142
150
|
<span {...element.attributes} {...attributes}>{children}</span>
|
|
143
151
|
</Wrapper>;
|
|
144
152
|
default:
|
|
145
153
|
if (isRenderer) {
|
|
146
|
-
return <Wrapper>{children}</Wrapper>;
|
|
154
|
+
return <Wrapper type={type}>{children}</Wrapper>;
|
|
147
155
|
} else {
|
|
148
156
|
return <span {...attributes} className={alignedClassname.trim()}>{children}</span>;
|
|
149
157
|
}
|
package/src/Nodes/Element.js
CHANGED
|
@@ -37,7 +37,8 @@ export const Element = ({
|
|
|
37
37
|
switch (props.element.type) {
|
|
38
38
|
case 'storybook':
|
|
39
39
|
return <div
|
|
40
|
-
onClick={e => e.stopPropagation()}
|
|
40
|
+
onClick={e => e.stopPropagation()}
|
|
41
|
+
className={"storybook-element-wrapper"}>
|
|
41
42
|
<StorybookNode
|
|
42
43
|
{...props}
|
|
43
44
|
{...typeProps}
|
package/src/Nodes/Storybook.js
CHANGED
|
@@ -124,25 +124,66 @@ const StorybookNodeComponent = ({
|
|
|
124
124
|
})}>
|
|
125
125
|
<span className="options-container">
|
|
126
126
|
{!element.isInline && (<>
|
|
127
|
-
<span
|
|
127
|
+
<span
|
|
128
|
+
className="options-container-option options-container-option-move-up"
|
|
129
|
+
title="Move up"
|
|
130
|
+
onClick={moveUp}>
|
|
128
131
|
<FontAwesomeIcon icon={faArrowUp} size="lg"/>
|
|
129
132
|
</span>
|
|
130
|
-
<span
|
|
133
|
+
<span
|
|
134
|
+
className="options-container-option options-container-option-move-down"
|
|
135
|
+
title="Move down"
|
|
136
|
+
onClick={moveDown}>
|
|
131
137
|
<FontAwesomeIcon icon={faArrowDown} size="lg"/>
|
|
132
138
|
</span>
|
|
133
139
|
</>)}
|
|
134
140
|
</span>
|
|
135
141
|
<span className={classNames({"storybook-element-component": true})}>
|
|
136
|
-
<span
|
|
142
|
+
<span
|
|
143
|
+
className="storybook-element-component-overlay"
|
|
144
|
+
title="Klicken, um das Element zu konfigurieren"
|
|
145
|
+
onClick={onEditClick}>
|
|
137
146
|
<div className="absolute right-0 top-0 m-2">
|
|
138
147
|
<FontAwesomeIcon
|
|
139
148
|
icon={faDesktop}
|
|
140
149
|
color={element?.attributes?.hideOnDesktop ? "lightgray" : "black"}
|
|
141
|
-
className="mr-2"
|
|
142
|
-
<FontAwesomeIcon
|
|
143
|
-
|
|
150
|
+
className="mr-2"/>
|
|
151
|
+
<FontAwesomeIcon
|
|
152
|
+
icon={faTablet}
|
|
153
|
+
color={element?.attributes?.hideOnTablet ? "lightgray" : "black"}
|
|
154
|
+
className="mr-2"/>
|
|
155
|
+
<FontAwesomeIcon
|
|
156
|
+
icon={faMobile}
|
|
157
|
+
color={element?.attributes?.hideOnSmartphone ? "lightgray" : "black"}/>
|
|
144
158
|
</div>
|
|
145
|
-
|
|
159
|
+
<svg
|
|
160
|
+
width="30%"
|
|
161
|
+
height="30%"
|
|
162
|
+
style={{
|
|
163
|
+
minWidth: "20px",
|
|
164
|
+
minHeight: "20px",
|
|
165
|
+
}}
|
|
166
|
+
viewBox="0 0 48 48"
|
|
167
|
+
xmlns="http://www.w3.org/2000/svg">
|
|
168
|
+
<path d="M0 0h48v48H0z" fill="none"/>
|
|
169
|
+
<style dangerouslySetInnerHTML={{
|
|
170
|
+
__html: `
|
|
171
|
+
g { mix-blend-mode: multiply; }
|
|
172
|
+
`,
|
|
173
|
+
}}/>
|
|
174
|
+
<g>
|
|
175
|
+
<path d="M8.706,37.027c2.363-0.585,4.798-1.243,6.545-1.243c0.683,0,1.261,0.101,1.688,0.345c1.474,0.845,2.318,4.268,3.245,7.502
|
|
176
|
+
C21.421,43.866,22.694,44,24,44c1.306,0,2.579-0.134,3.816-0.368c0.926-3.234,1.771-6.657,3.244-7.501
|
|
177
|
+
c0.427-0.245,1.005-0.345,1.688-0.345c1.747,0,4.183,0.658,6.545,1.243c1.605-1.848,2.865-3.99,3.706-6.333
|
|
178
|
+
c-2.344-2.406-4.872-4.891-4.872-6.694c0-1.804,2.528-4.288,4.872-6.694c-0.841-2.343-2.101-4.485-3.706-6.333
|
|
179
|
+
c-2.363,0.585-4.798,1.243-6.545,1.243c-0.683,0-1.261-0.101-1.688-0.345c-1.474-0.845-2.318-4.268-3.245-7.502
|
|
180
|
+
C26.579,4.134,25.306,4,24,4c-1.306,0-2.579,0.134-3.816,0.368c-0.926,3.234-1.771,6.657-3.245,7.501
|
|
181
|
+
c-0.427,0.245-1.005,0.345-1.688,0.345c-1.747,0-4.183-0.658-6.545-1.243C7.101,12.821,5.841,14.962,5,17.306
|
|
182
|
+
C7.344,19.712,9.872,22.196,9.872,24c0,1.804-2.527,4.288-4.872,6.694C5.841,33.037,7.101,35.179,8.706,37.027z M18,24
|
|
183
|
+
c0-3.314,2.686-6,6-6s6,2.686,6,6s-2.686,6-6,6S18,27.314,18,24z"/>
|
|
184
|
+
</g>
|
|
185
|
+
</svg>
|
|
186
|
+
</span>
|
|
146
187
|
<div onClick={onEditClick}>
|
|
147
188
|
<StorybookDisplay
|
|
148
189
|
{...element.attributes}
|
|
@@ -121,20 +121,23 @@ const BlockComponent = ({
|
|
|
121
121
|
}
|
|
122
122
|
}
|
|
123
123
|
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
124
|
+
const WrapperTag = loadedAttributes.isInline ? "span" : "div";
|
|
125
|
+
const wrapperClassName = classNames({
|
|
126
|
+
"block-article-width": loadedAttributes.blockWidth === "article",
|
|
127
|
+
"block-site-width": loadedAttributes.blockWidth === "site",
|
|
128
|
+
"block-small-width": loadedAttributes.blockWidth === "small",
|
|
129
|
+
"editor-mt-large": loadedAttributes?.margin?.top,
|
|
130
|
+
"editor-mr-large": loadedAttributes?.margin?.right,
|
|
131
|
+
"editor-mb-large": loadedAttributes?.margin?.bottom,
|
|
132
|
+
"editor-ml-large": loadedAttributes?.margin?.left,
|
|
133
|
+
"lg:hidden": loadedAttributes?.hideOnDesktop && !isEditor,
|
|
134
|
+
"sm:max-lg:hidden": loadedAttributes?.hideOnTablet && !isEditor,
|
|
135
|
+
"max-sm:hidden": loadedAttributes?.hideOnSmartphone && !isEditor,
|
|
136
|
+
});
|
|
137
|
+
|
|
138
|
+
if (!wrapperClassName) {
|
|
138
139
|
return <LoadedComponent {...loadedAttributes} />;
|
|
139
140
|
}
|
|
141
|
+
|
|
142
|
+
return <WrapperTag className={wrapperClassName}><LoadedComponent {...loadedAttributes} /></WrapperTag>;
|
|
140
143
|
};
|
|
@@ -124,7 +124,7 @@ export function Serializer({
|
|
|
124
124
|
storybookComponentDataLoader: storybookComponentDataLoader,
|
|
125
125
|
};
|
|
126
126
|
|
|
127
|
-
return <Wrapper><StorybookDisplay {...storyProps} /></Wrapper>;
|
|
127
|
+
return <Wrapper type={props.type} block={props.block}><StorybookDisplay {...storyProps} /></Wrapper>;
|
|
128
128
|
}
|
|
129
129
|
case 'layout': {
|
|
130
130
|
let isGrid = true;
|
|
@@ -137,7 +137,7 @@ export function Serializer({
|
|
|
137
137
|
});
|
|
138
138
|
}
|
|
139
139
|
|
|
140
|
-
return <Wrapper>
|
|
140
|
+
return <Wrapper type={props.type}>
|
|
141
141
|
<div
|
|
142
142
|
data-cols={props.children.length}
|
|
143
143
|
className={classNames("block-editor-layout", {
|
|
@@ -167,7 +167,7 @@ export function Serializer({
|
|
|
167
167
|
</Wrapper>;
|
|
168
168
|
}
|
|
169
169
|
case 'layout-slot':
|
|
170
|
-
return <Wrapper>
|
|
170
|
+
return <Wrapper type={props.type}>
|
|
171
171
|
<div
|
|
172
172
|
className={classNames({
|
|
173
173
|
["block-editor-layout-" + props.attributes.name]: true,
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
2
|
useEffect, useRef,
|
|
3
3
|
} from "react";
|
|
4
|
+
import classNames from "classnames";
|
|
4
5
|
|
|
5
6
|
export const Resizable = ({
|
|
6
7
|
left,
|
|
@@ -73,7 +74,9 @@ export const Resizable = ({
|
|
|
73
74
|
}
|
|
74
75
|
}, [right, left]);
|
|
75
76
|
|
|
76
|
-
return <div
|
|
77
|
+
return <div
|
|
78
|
+
className={classNames("resizable flex w-full", {"enabled": !!right})}
|
|
79
|
+
ref={containerRef}>
|
|
77
80
|
<div ref={leftRef} className="resizable-left grow">{left}</div>
|
|
78
81
|
{right && <div ref={rightRef} className="resizable-right shrink-0">
|
|
79
82
|
<div ref={handleRef} className="resizable-x-handle"/>
|
package/src/SidebarEditor.js
CHANGED
|
@@ -40,6 +40,14 @@ const SidebarEditor = ({
|
|
|
40
40
|
|
|
41
41
|
const story = storybookStories?.find(v => storybookElement.block?.toLowerCase() === v.id?.toLowerCase());
|
|
42
42
|
|
|
43
|
+
useEffect(() => {
|
|
44
|
+
const selectedHtmlNode = document.querySelector(".slate-editor-element-selected");
|
|
45
|
+
|
|
46
|
+
if (selectedHtmlNode) {
|
|
47
|
+
selectedHtmlNode.scrollIntoView();
|
|
48
|
+
}
|
|
49
|
+
}, [storybookElement]);
|
|
50
|
+
|
|
43
51
|
if (story?.argTypes) {
|
|
44
52
|
Object.keys(story.argTypes).forEach(key => {
|
|
45
53
|
const argType = story.argTypes[key];
|
package/src/Toolbar/Element.js
CHANGED
|
@@ -41,9 +41,5 @@ export const StorybookButton = () => {
|
|
|
41
41
|
<FontAwesomeIcon icon={faPlus} />
|
|
42
42
|
<span> Element hinzufügen</span>
|
|
43
43
|
</span>
|
|
44
|
-
<span className={"toolbar-btn"} onMouseDown={onClickInline}>
|
|
45
|
-
<FontAwesomeIcon icon={faPlus} />
|
|
46
|
-
<span> Inline Element hinzufügen</span>
|
|
47
|
-
</span>
|
|
48
44
|
</>;
|
|
49
45
|
};
|