@vonaffenfels/slate-editor 1.0.43 → 1.0.45
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 +24 -47
- package/scss/sidebarEditor.scss +1 -1
- package/src/BlockEditor.js +11 -0
- package/src/Blocks/LayoutBlock.js +34 -3
- package/src/Blocks/LayoutSlot.js +1 -1
- package/src/Serializer/Serializer.js +2 -2
- package/src/SidebarEditor/SidebarEditorField.js +2 -0
- package/src/Toolbar/Layout.js +3 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vonaffenfels/slate-editor",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.45",
|
|
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": "5ed8507a56e4cb65baa44dd3d5cbb9853a45f05d",
|
|
75
75
|
"publishConfig": {
|
|
76
76
|
"access": "public"
|
|
77
77
|
}
|
package/scss/editor.scss
CHANGED
|
@@ -303,9 +303,20 @@
|
|
|
303
303
|
}
|
|
304
304
|
}
|
|
305
305
|
|
|
306
|
+
.layout-block-auto-fill {
|
|
307
|
+
grid-template-columns: auto 1fr;
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
.layout-block-fill-auto {
|
|
311
|
+
grid-template-columns: 1fr auto;
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
.layout-block-auto-fill-auto {
|
|
315
|
+
grid-template-columns: auto 1fr auto;
|
|
316
|
+
}
|
|
317
|
+
|
|
306
318
|
.layout-block {
|
|
307
|
-
display:
|
|
308
|
-
flex-direction: row;
|
|
319
|
+
display: grid;
|
|
309
320
|
|
|
310
321
|
&.article-width {
|
|
311
322
|
width: 44.44444444435556%;
|
|
@@ -321,6 +332,14 @@
|
|
|
321
332
|
position: relative;
|
|
322
333
|
outline: 1px dashed grey;
|
|
323
334
|
|
|
335
|
+
.storybook-element-component {
|
|
336
|
+
display: block;
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
.layout-slot-content {
|
|
340
|
+
flex-grow: 1;
|
|
341
|
+
}
|
|
342
|
+
|
|
324
343
|
.layout-slot-options {
|
|
325
344
|
background-color: grey;
|
|
326
345
|
color: white;
|
|
@@ -339,53 +358,11 @@
|
|
|
339
358
|
text-transform: uppercase;
|
|
340
359
|
display: inline-block;
|
|
341
360
|
}
|
|
342
|
-
|
|
343
|
-
}
|
|
344
|
-
|
|
345
|
-
.layout-slot-content {
|
|
346
|
-
}
|
|
347
|
-
|
|
348
|
-
&.layout-slot-widecol {
|
|
349
|
-
flex-grow: 1;
|
|
350
|
-
}
|
|
351
|
-
|
|
352
|
-
&.layout-slot-maincol {
|
|
353
|
-
flex-grow: 1;
|
|
354
|
-
}
|
|
355
|
-
|
|
356
|
-
&.layout-slot-sidecol {
|
|
357
|
-
flex-grow: 0;
|
|
358
|
-
width: 30%;
|
|
359
|
-
}
|
|
360
|
-
|
|
361
|
-
&.layout-slot-grid-half {
|
|
362
|
-
flex-grow: 0;
|
|
363
|
-
width: 50%;
|
|
364
|
-
}
|
|
365
|
-
|
|
366
|
-
&.layout-slot-grid-3 {
|
|
367
|
-
flex-grow: 0;
|
|
368
|
-
width: 100%;
|
|
369
|
-
}
|
|
370
|
-
|
|
371
|
-
&.layout-slot-grid-2 {
|
|
372
|
-
flex-grow: 0;
|
|
373
|
-
width: 66.6666666666%;
|
|
374
|
-
}
|
|
375
|
-
|
|
376
|
-
&.layout-slot-grid-1 {
|
|
377
|
-
flex-grow: 0;
|
|
378
|
-
width: 33.3333333333%;
|
|
379
|
-
}
|
|
380
|
-
|
|
381
|
-
&.layout-slot-grid-fill {
|
|
382
|
-
flex-grow: 1;
|
|
383
361
|
}
|
|
362
|
+
}
|
|
384
363
|
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
width: auto;
|
|
388
|
-
}
|
|
364
|
+
@media only screen and (max-width: 360px) {
|
|
365
|
+
grid-template-columns: 1fr;
|
|
389
366
|
}
|
|
390
367
|
}
|
|
391
368
|
}
|
package/scss/sidebarEditor.scss
CHANGED
package/src/BlockEditor.js
CHANGED
|
@@ -218,6 +218,17 @@ export default function BlockEditor({
|
|
|
218
218
|
}
|
|
219
219
|
|
|
220
220
|
try {
|
|
221
|
+
editor.selection = {
|
|
222
|
+
anchor: {
|
|
223
|
+
offset: 0,
|
|
224
|
+
path,
|
|
225
|
+
},
|
|
226
|
+
focus: {
|
|
227
|
+
offset: 0,
|
|
228
|
+
path,
|
|
229
|
+
},
|
|
230
|
+
};
|
|
231
|
+
|
|
221
232
|
Transforms.moveNodes(editor, {
|
|
222
233
|
from: [path[0]],
|
|
223
234
|
match: node => {
|
|
@@ -171,6 +171,27 @@ export const LayoutBlock = ({
|
|
|
171
171
|
}, {at: path});
|
|
172
172
|
};
|
|
173
173
|
|
|
174
|
+
const switchMobileColumnSpan = () => {
|
|
175
|
+
let node = ReactEditor.toSlateNode(editor, attributes.ref.current);
|
|
176
|
+
let fromPath = ReactEditor.findPath(editor, node);
|
|
177
|
+
|
|
178
|
+
if (!fromPath) {
|
|
179
|
+
return;
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
let mobileColumnSpan = element?.attributes?.mobileColumnSpan === 1 ? 2 : 1;
|
|
183
|
+
|
|
184
|
+
Transforms.setNodes(editor, {
|
|
185
|
+
type: "layout",
|
|
186
|
+
attributes: {
|
|
187
|
+
...(element.attributes || {}),
|
|
188
|
+
mobileColumnSpan,
|
|
189
|
+
},
|
|
190
|
+
}, {at: fromPath});
|
|
191
|
+
};
|
|
192
|
+
|
|
193
|
+
console.log({element});
|
|
194
|
+
|
|
174
195
|
return <div className="options-wrapper" onClick={() => onElementClick(element)}>
|
|
175
196
|
<div className="options-container">
|
|
176
197
|
<span className="options-container-option options-container-option-remove" onClick={onRemoveClick}>
|
|
@@ -212,19 +233,29 @@ export const LayoutBlock = ({
|
|
|
212
233
|
<span>Rahmen</span>
|
|
213
234
|
)}
|
|
214
235
|
</span>
|
|
236
|
+
<span className="mx-2 cursor-pointer" onClick={switchMobileColumnSpan}>
|
|
237
|
+
<span>Mobile Spalten: {element?.attributes?.mobileColumnSpan || 1}</span>
|
|
238
|
+
</span>
|
|
215
239
|
<ToolMargin margin={element?.attributes?.margin} onChange={onMarginChange}/>
|
|
216
240
|
</div>
|
|
217
241
|
<div
|
|
218
|
-
className={`layout-block layout-grid layout-grid-cols-${children.length} ` + classNames({
|
|
242
|
+
className={`layout-block layout-grid layout-grid-cols-${children.length} ${element?.attributes?.className || ""} ` + classNames({
|
|
219
243
|
[classNameArticle + " article-width"]: element?.attributes?.width === "article" || !element?.attributes?.width,
|
|
220
244
|
[classNameSite + " site-width"]: element?.attributes?.width === "full",
|
|
221
245
|
"block-editor-table-border-wrapper": element?.attributes?.tableBorder,
|
|
222
|
-
"
|
|
223
|
-
"
|
|
246
|
+
"mx-auto": element?.attributes?.justifyCenter,
|
|
247
|
+
"gap-4": element?.attributes?.spacing,
|
|
224
248
|
"editor-mt-large": element?.attributes?.margin?.top,
|
|
225
249
|
"editor-mr-large": element?.attributes?.margin?.right,
|
|
226
250
|
"editor-mb-large": element?.attributes?.margin?.bottom,
|
|
227
251
|
"editor-ml-large": element?.attributes?.margin?.left,
|
|
252
|
+
"md:grid-cols-1": element?.children?.length === 1,
|
|
253
|
+
"md:grid-cols-2": element?.children?.length === 2,
|
|
254
|
+
"md:grid-cols-3": element?.children?.length === 3,
|
|
255
|
+
"md:grid-cols-4": element?.children?.length === 4,
|
|
256
|
+
"md:grid-cols-5": element?.children?.length === 5,
|
|
257
|
+
"grid-cols-1": element?.attributes?.mobileColumnSpan === 1,
|
|
258
|
+
"grid-cols-2": element?.attributes?.mobileColumnSpan === 2,
|
|
228
259
|
})}
|
|
229
260
|
{...attributes}
|
|
230
261
|
>
|
package/src/Blocks/LayoutSlot.js
CHANGED
|
@@ -30,7 +30,7 @@ export const LayoutSlot = ({
|
|
|
30
30
|
|
|
31
31
|
return <div
|
|
32
32
|
className={classNames({
|
|
33
|
-
["layout-slot
|
|
33
|
+
["layout-slot"]: true,
|
|
34
34
|
"editor-mt-4": element?.attributes?.margin?.top,
|
|
35
35
|
"editor-mr-4": element?.attributes?.margin?.right,
|
|
36
36
|
"editor-mb-4": element?.attributes?.margin?.bottom,
|
|
@@ -130,7 +130,7 @@ export function Serializer({
|
|
|
130
130
|
return <Wrapper>
|
|
131
131
|
<div
|
|
132
132
|
data-cols={props.children.length}
|
|
133
|
-
className={classNames({
|
|
133
|
+
className={classNames(props?.attributes?.className || "", {
|
|
134
134
|
"block-editor-layout": true,
|
|
135
135
|
"md:space-x-4": props.attributes?.spacing,
|
|
136
136
|
"mt-16": props?.attributes?.margin?.top,
|
|
@@ -138,7 +138,7 @@ export function Serializer({
|
|
|
138
138
|
"mb-16": props?.attributes?.margin?.bottom,
|
|
139
139
|
"ml-16": props?.attributes?.margin?.left,
|
|
140
140
|
"block-editor-table-border-wrapper": props?.attributes?.tableBorder,
|
|
141
|
-
"
|
|
141
|
+
"mx-auto": props?.attributes?.justifyCenter,
|
|
142
142
|
[typeProps.classNameSite + " site-width"]: !isInSlot && (props.attributes?.width === "site" || props.attributes?.width === "full"),
|
|
143
143
|
[typeProps.classNameArticle + " article-width"]: !isInSlot && (props.attributes?.width === "article" || !props.attributes?.width),
|
|
144
144
|
})}
|
|
@@ -88,9 +88,11 @@ export const SidebarEditorField = ({
|
|
|
88
88
|
return (
|
|
89
89
|
<div>
|
|
90
90
|
<input
|
|
91
|
+
id={fieldKey}
|
|
91
92
|
type="checkbox"
|
|
92
93
|
checked={value}
|
|
93
94
|
onChange={e => onChange(fieldKey, e.target.checked)} />
|
|
95
|
+
<label htmlFor={fieldKey}>{value ? "Ja" : "Nein"}</label>
|
|
94
96
|
</div>
|
|
95
97
|
);
|
|
96
98
|
case "select":
|
package/src/Toolbar/Layout.js
CHANGED
|
@@ -273,6 +273,7 @@ export const InsertGridButton = () => {
|
|
|
273
273
|
</InsertLayoutButton>
|
|
274
274
|
<InsertLayoutButton insert={{
|
|
275
275
|
"type": "layout",
|
|
276
|
+
"attributes": {"className": "layout-block-auto-fill"},
|
|
276
277
|
"children": [
|
|
277
278
|
{
|
|
278
279
|
"type": "layout-slot",
|
|
@@ -304,6 +305,7 @@ export const InsertGridButton = () => {
|
|
|
304
305
|
</InsertLayoutButton>
|
|
305
306
|
<InsertLayoutButton insert={{
|
|
306
307
|
"type": "layout",
|
|
308
|
+
"attributes": {"className": "layout-block-fill-auto"},
|
|
307
309
|
"children": [
|
|
308
310
|
{
|
|
309
311
|
"type": "layout-slot",
|
|
@@ -335,6 +337,7 @@ export const InsertGridButton = () => {
|
|
|
335
337
|
</InsertLayoutButton>
|
|
336
338
|
<InsertLayoutButton insert={{
|
|
337
339
|
"type": "layout",
|
|
340
|
+
"attributes": {"className": "layout-block-auto-fill-auto"},
|
|
338
341
|
"children": [
|
|
339
342
|
{
|
|
340
343
|
"type": "layout-slot",
|