@vonaffenfels/slate-editor 1.0.71 → 1.0.72

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vonaffenfels/slate-editor",
3
- "version": "1.0.71",
3
+ "version": "1.0.72",
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": "ff4d8d5cebc25ef55b2fd66c35e85634f614048b",
74
+ "gitHead": "4ea4a78911a1476352df5de28932c291bcc4770f",
75
75
  "publishConfig": {
76
76
  "access": "public"
77
77
  }
@@ -12,8 +12,11 @@ export const CollapsableMenu = ({
12
12
  props: {
13
13
  ...child.props,
14
14
  onClick: () => {
15
- child.props.onClick();
16
- setCollapsed(true);
15
+ if (child.props.onClick) {
16
+ child.props.onClick();
17
+
18
+ setCollapsed(true);
19
+ }
17
20
  },
18
21
  },
19
22
  }));
@@ -3,7 +3,7 @@ import React, {
3
3
  } from "react";
4
4
  import {FontAwesomeIcon} from "@fortawesome/react-fontawesome";
5
5
  import {
6
- faCog, faArrowUp, faArrowDown, faTimes, faCompress,
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}>Klicken, um das Element zu konfigurieren</span>
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}
@@ -157,6 +157,9 @@ export function Serializer({
157
157
  "mb-16": props?.attributes?.margin?.bottom,
158
158
  "ml-16": props?.attributes?.margin?.left,
159
159
  "justify-center": props?.attributes?.justifyCenter,
160
+ "lg:!hidden": props?.attributes?.hideOnDesktop,
161
+ "sm:max-lg:!hidden": props?.attributes?.hideOnTablet,
162
+ "max-sm:!hidden": props?.attributes?.hideOnSmartphone,
160
163
  [typeProps.classNameSite + " site-width"]: !isInSlot && (props.attributes?.width === "site" || props.attributes?.width === "full"),
161
164
  [typeProps.classNameArticle + " article-width"]: !isInSlot && (props.attributes?.width === "article" || !props.attributes?.width),
162
165
  })}
@@ -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
- <button
10
- onClick={onClick}
11
- type="button"
12
- role="switch"
13
- aria-checked="false"
14
- className={classNames({
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
- "translate-x-5": value,
24
- "translate-x-0": !value,
18
+ "bg-green-500": value,
19
+ "bg-gray-200": !value,
25
20
  },
26
- "pointer-events-none inline-block h-5 w-5 rounded-full bg-white shadow ring-0 transition duration-100 ease-in-out")}
27
- />
28
- </button>
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
  };
@@ -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
  )}