@vonaffenfels/slate-editor 1.0.71 → 1.0.73
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 +1 -1
- package/dist/BlockEditor.js +1 -1
- package/dist/Renderer.js +1 -1
- package/dist/index.css +1 -1
- package/dist/index.js +1 -1
- package/package.json +2 -2
- package/src/CollapsableMenu/CollapsableMenu.js +5 -2
- package/src/Nodes/Storybook.js +11 -2
- package/src/Nodes/StorybookDisplay.js +6 -1
- package/src/SidebarEditor/SidebarEditorField.js +1 -1
- package/src/SidebarEditor/Switch.js +25 -20
- package/src/SidebarEditor.js +7 -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.73",
|
|
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": "cb4ea09876ef521af49f2e751d2a9d18ea54ce6a",
|
|
75
75
|
"publishConfig": {
|
|
76
76
|
"access": "public"
|
|
77
77
|
}
|
package/src/Nodes/Storybook.js
CHANGED
|
@@ -3,7 +3,7 @@ import React, {
|
|
|
3
3
|
} from "react";
|
|
4
4
|
import {FontAwesomeIcon} from "@fortawesome/react-fontawesome";
|
|
5
5
|
import {
|
|
6
|
-
|
|
6
|
+
faDesktop, faMobile, faTablet,
|
|
7
7
|
} from "@fortawesome/free-solid-svg-icons";
|
|
8
8
|
import {Storybook} from "../Storybook";
|
|
9
9
|
import {Transforms} from "slate";
|
|
@@ -121,7 +121,16 @@ const StorybookNodeComponent = ({
|
|
|
121
121
|
"storybook-element-float-right": element?.attributes?.float === "right",
|
|
122
122
|
})}>
|
|
123
123
|
<span className={classNames({"storybook-element-component": true})}>
|
|
124
|
-
<span className="storybook-element-component-overlay" title="Klicken, um das Element zu konfigurieren" onClick={onEditClick}>
|
|
124
|
+
<span className="storybook-element-component-overlay" title="Klicken, um das Element zu konfigurieren" onClick={onEditClick}>
|
|
125
|
+
<div className="absolute right-0 top-0 m-2">
|
|
126
|
+
<FontAwesomeIcon
|
|
127
|
+
icon={faDesktop}
|
|
128
|
+
color={element?.attributes?.hideOnDesktop ? "lightgray" : "black"}
|
|
129
|
+
className="mr-2" />
|
|
130
|
+
<FontAwesomeIcon icon={faTablet} color={element?.attributes?.hideOnTablet ? "lightgray" : "black"} className="mr-2" />
|
|
131
|
+
<FontAwesomeIcon icon={faMobile} color={element?.attributes?.hideOnSmartphone ? "lightgray" : "black"} />
|
|
132
|
+
</div>
|
|
133
|
+
Klicken, um das Element zu konfigurieren</span>
|
|
125
134
|
<div onClick={onEditClick}>
|
|
126
135
|
<StorybookDisplay
|
|
127
136
|
{...element.attributes}
|
|
@@ -47,7 +47,8 @@ export const StorybookDisplay = (props) => {
|
|
|
47
47
|
block={element.block}
|
|
48
48
|
storybookComponentLoader={storybookComponentLoader}
|
|
49
49
|
storybookComponentDataLoader={storybookComponentDataLoader}
|
|
50
|
-
attributes={{...element.attributes}}
|
|
50
|
+
attributes={{...element.attributes}}
|
|
51
|
+
isEditor/>
|
|
51
52
|
</span>
|
|
52
53
|
</ErrorBoundary>;
|
|
53
54
|
} else {
|
|
@@ -66,6 +67,7 @@ const BlockComponent = ({
|
|
|
66
67
|
storybookComponentLoader,
|
|
67
68
|
storybookComponentDataLoader,
|
|
68
69
|
attributes,
|
|
70
|
+
isEditor,
|
|
69
71
|
}) => {
|
|
70
72
|
const [loadedAttributes, setLoadedAttributes] = useState(attributes);
|
|
71
73
|
let [LoadedComponent, setLoadedComponent] = useState(storybookComponentLoader(block));
|
|
@@ -128,6 +130,9 @@ const BlockComponent = ({
|
|
|
128
130
|
"editor-mr-large": loadedAttributes?.margin?.right,
|
|
129
131
|
"editor-mb-large": loadedAttributes?.margin?.bottom,
|
|
130
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,
|
|
131
136
|
})}><LoadedComponent {...loadedAttributes} /></span>;
|
|
132
137
|
} else {
|
|
133
138
|
return <LoadedComponent {...loadedAttributes} />;
|
|
@@ -102,8 +102,8 @@ export const SidebarEditorField = ({
|
|
|
102
102
|
<Switch
|
|
103
103
|
type="checkbox"
|
|
104
104
|
value={value}
|
|
105
|
+
label={value ? "Ja" : "Nein"}
|
|
105
106
|
onClick={() => onChange(fieldKey, !value)}/>
|
|
106
|
-
<span className="ml-2">{value ? "Ja" : "Nein"}</span>
|
|
107
107
|
</div>
|
|
108
108
|
);
|
|
109
109
|
case "select":
|
|
@@ -4,27 +4,32 @@ import classNames from "classnames";
|
|
|
4
4
|
export const Switch = ({
|
|
5
5
|
value,
|
|
6
6
|
onClick,
|
|
7
|
+
label,
|
|
8
|
+
className,
|
|
7
9
|
}) => {
|
|
8
|
-
return (
|
|
9
|
-
<
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
"bg-green-500": value,
|
|
16
|
-
"bg-gray-200": !value,
|
|
17
|
-
},
|
|
18
|
-
"relative inline-flex h-6 w-11 shrink-0 cursor-pointer rounded-full border-2 border-transparent transition duration-100 ease-in-out focus:outline-none")}
|
|
19
|
-
>
|
|
20
|
-
<span
|
|
21
|
-
aria-hidden="true"
|
|
10
|
+
return (
|
|
11
|
+
<div className={classNames(className, {"flex items-center": true})}>
|
|
12
|
+
<button
|
|
13
|
+
onClick={onClick}
|
|
14
|
+
type="button"
|
|
15
|
+
role="switch"
|
|
16
|
+
aria-checked="false"
|
|
22
17
|
className={classNames({
|
|
23
|
-
"
|
|
24
|
-
"
|
|
18
|
+
"bg-green-500": value,
|
|
19
|
+
"bg-gray-200": !value,
|
|
25
20
|
},
|
|
26
|
-
"
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
21
|
+
"relative inline-flex h-6 w-11 shrink-0 cursor-pointer rounded-full border-2 border-transparent transition duration-100 ease-in-out focus:outline-none")}
|
|
22
|
+
>
|
|
23
|
+
<span
|
|
24
|
+
aria-hidden="true"
|
|
25
|
+
className={classNames({
|
|
26
|
+
"translate-x-5": value,
|
|
27
|
+
"translate-x-0": !value,
|
|
28
|
+
},
|
|
29
|
+
"pointer-events-none inline-block h-5 w-5 rounded-full bg-white shadow ring-0 transition duration-100 ease-in-out")}
|
|
30
|
+
/>
|
|
31
|
+
</button>
|
|
32
|
+
<span className="ml-2">{label}</span>
|
|
33
|
+
</div>
|
|
34
|
+
);
|
|
30
35
|
};
|
package/src/SidebarEditor.js
CHANGED
|
@@ -9,6 +9,7 @@ import {ElementAutocomplete} from "./ElementAutocomplete";
|
|
|
9
9
|
import {
|
|
10
10
|
CollapsableMenu, CollapsableMenuItem,
|
|
11
11
|
} from "./CollapsableMenu/CollapsableMenu";
|
|
12
|
+
import {Switch} from "./SidebarEditor/Switch";
|
|
12
13
|
|
|
13
14
|
const SidebarEditor = ({
|
|
14
15
|
sdk,
|
|
@@ -317,6 +318,12 @@ const SidebarEditor = ({
|
|
|
317
318
|
<CollapsableMenuItem onClick={onDuplicate}>Duplizieren</CollapsableMenuItem>
|
|
318
319
|
<CollapsableMenuItem onClick={() => onInsert("above")}>Davor hinzufügen</CollapsableMenuItem>
|
|
319
320
|
<CollapsableMenuItem onClick={() => onInsert("below")}>Danach hinzufügen</CollapsableMenuItem>
|
|
321
|
+
<div className="px-4 pb-2 pt-1">
|
|
322
|
+
<b className="mb-1 block text-sm">Responsive:</b>
|
|
323
|
+
<Switch value={!storybookElement.attributes.hideOnDesktop} label="Desktop" className="mb-2" onClick={() => handleFieldValueChange("hideOnDesktop", !storybookElement.attributes.hideOnDesktop)} />
|
|
324
|
+
<Switch value={!storybookElement.attributes.hideOnTablet} label="Tablet" className="mb-2" onClick={() => handleFieldValueChange("hideOnTablet", !storybookElement.attributes.hideOnTablet)} />
|
|
325
|
+
<Switch value={!storybookElement.attributes.hideOnSmartphone} label="Smartphone" className="mb-2" onClick={() => handleFieldValueChange("hideOnSmartphone", !storybookElement.attributes.hideOnSmartphone)} />
|
|
326
|
+
</div>
|
|
320
327
|
</CollapsableMenu>
|
|
321
328
|
</div>
|
|
322
329
|
)}
|