@vonaffenfels/slate-editor 1.1.36 → 1.1.37
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 +9 -9
- package/dist/Renderer.js +1 -1
- package/dist/index.css +2 -2
- package/dist/index.js +9 -9
- package/package.json +2 -2
- package/scss/sidebarEditor.scss +1 -0
- package/src/Nodes/Storybook.js +3 -0
- package/src/Nodes/StorybookDisplay.js +10 -0
- package/src/SidebarEditor/Fields/DateTime.js +55 -0
- package/src/SidebarEditor.js +6 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vonaffenfels/slate-editor",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.37",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -72,7 +72,7 @@
|
|
|
72
72
|
"cssnano": "^5.0.1",
|
|
73
73
|
"escape-html": "^1.0.3"
|
|
74
74
|
},
|
|
75
|
-
"gitHead": "
|
|
75
|
+
"gitHead": "23bd1926bceee0ce73a5d25f021c544ead009f77",
|
|
76
76
|
"publishConfig": {
|
|
77
77
|
"access": "public"
|
|
78
78
|
}
|
package/scss/sidebarEditor.scss
CHANGED
package/src/Nodes/Storybook.js
CHANGED
|
@@ -144,6 +144,9 @@ const StorybookNodeComponent = ({
|
|
|
144
144
|
title="Klicken, um das Element zu konfigurieren"
|
|
145
145
|
onClick={onEditClick}>
|
|
146
146
|
<div className="absolute right-0 top-0 m-2">
|
|
147
|
+
<span className="mr-2">
|
|
148
|
+
{[element?.attributes?.visibleFromDate, element?.attributes?.visibleToDate].filter(Boolean).map((date) => new Date(date).toLocaleString?.()).join(" - ")}
|
|
149
|
+
</span>
|
|
147
150
|
<FontAwesomeIcon
|
|
148
151
|
icon={faDesktop}
|
|
149
152
|
color={element?.attributes?.hideOnDesktop ? "lightgray" : "black"}
|
|
@@ -36,6 +36,16 @@ export const StorybookDisplay = (props) => {
|
|
|
36
36
|
};
|
|
37
37
|
}, [elRef.current]);
|
|
38
38
|
|
|
39
|
+
let currentDate = new Date();
|
|
40
|
+
|
|
41
|
+
if (!isEditor && element?.attributes?.visibleFromDate && new Date(element?.attributes?.visibleFromDate) > currentDate) {
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
if (!isEditor && element?.attributes?.visibleToDate && new Date(element?.attributes?.visibleToDate) < currentDate) {
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
|
|
39
49
|
if (element.isEmpty || !element.block) {
|
|
40
50
|
return <EmptyBlock {...element.attributes} />;
|
|
41
51
|
}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import classNames from "classnames";
|
|
2
|
+
|
|
3
|
+
export const DateTime = ({
|
|
4
|
+
value,
|
|
5
|
+
onChange,
|
|
6
|
+
className,
|
|
7
|
+
inline,
|
|
8
|
+
...props
|
|
9
|
+
}) => {
|
|
10
|
+
// Separate date and time values
|
|
11
|
+
const dateValue = value ? value.split("T")[0] : "";
|
|
12
|
+
const timeValue = value ? value.split("T")[1] : "";
|
|
13
|
+
|
|
14
|
+
// Handle changes for date and time inputs
|
|
15
|
+
const handleDateChange = (e) => {
|
|
16
|
+
const newDate = e.target.value;
|
|
17
|
+
const newDateTime = `${newDate}T${timeValue || "00:00"}`;
|
|
18
|
+
onChange(newDateTime);
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
const handleTimeChange = (e) => {
|
|
22
|
+
const newTime = e.target.value;
|
|
23
|
+
const newDateTime = `${dateValue || "1970-01-01"}T${newTime}`;
|
|
24
|
+
onChange(newDateTime);
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
return (
|
|
28
|
+
<div className={classNames(className, "grid gap-2", {
|
|
29
|
+
"grid-cols-2": inline,
|
|
30
|
+
"grid-cols-1": !inline,
|
|
31
|
+
})}>
|
|
32
|
+
{/* Date input */}
|
|
33
|
+
<input
|
|
34
|
+
type="date"
|
|
35
|
+
className="w-full"
|
|
36
|
+
value={dateValue}
|
|
37
|
+
onChange={handleDateChange}
|
|
38
|
+
{...props}
|
|
39
|
+
/>
|
|
40
|
+
|
|
41
|
+
{/* Time input */}
|
|
42
|
+
<input
|
|
43
|
+
type="time"
|
|
44
|
+
className="w-full"
|
|
45
|
+
value={timeValue}
|
|
46
|
+
onChange={handleTimeChange}
|
|
47
|
+
{...props}
|
|
48
|
+
/>
|
|
49
|
+
|
|
50
|
+
{!!value && (
|
|
51
|
+
<button className="button button--tertiary" onClick={() => onChange(undefined)}>Zurücksetzen</button>
|
|
52
|
+
)}
|
|
53
|
+
</div>
|
|
54
|
+
);
|
|
55
|
+
};
|
package/src/SidebarEditor.js
CHANGED
|
@@ -9,6 +9,7 @@ import {
|
|
|
9
9
|
CollapsableMenu, CollapsableMenuItem,
|
|
10
10
|
} from "./CollapsableMenu/CollapsableMenu";
|
|
11
11
|
import {Switch} from "./SidebarEditor/Fields/Switch";
|
|
12
|
+
import {DateTime} from "./SidebarEditor/Fields/DateTime";
|
|
12
13
|
|
|
13
14
|
const SidebarEditor = ({
|
|
14
15
|
sdk,
|
|
@@ -379,7 +380,7 @@ const SidebarEditor = ({
|
|
|
379
380
|
hinzufügen</CollapsableMenuItem>
|
|
380
381
|
<CollapsableMenuItem onClick={handleInfoClick}>Info</CollapsableMenuItem>
|
|
381
382
|
<div className="px-4 pb-2 pt-1">
|
|
382
|
-
<b className="mb-1 block text-sm">
|
|
383
|
+
<b className="mb-1 block text-sm">Sichtbarkeit</b>
|
|
383
384
|
<Switch
|
|
384
385
|
value={!storybookElement.attributes.hideOnDesktop}
|
|
385
386
|
label="Desktop"
|
|
@@ -395,6 +396,10 @@ const SidebarEditor = ({
|
|
|
395
396
|
label="Smartphone"
|
|
396
397
|
className="mb-2"
|
|
397
398
|
onClick={() => handleFieldValueChange("hideOnSmartphone", !storybookElement.attributes.hideOnSmartphone)}/>
|
|
399
|
+
<label className="mb-1 block">Sichtbar von</label>
|
|
400
|
+
<DateTime className="mb-2" value={storybookElement.attributes.visibleFromDate} onChange={v => handleFieldValueChange("visibleFromDate", v)} />
|
|
401
|
+
<label className="mb-1 block">Sichtbar bis</label>
|
|
402
|
+
<DateTime className="mb-2" value={storybookElement.attributes.visibleToDate} onChange={v => handleFieldValueChange("visibleToDate", v)} />
|
|
398
403
|
</div>
|
|
399
404
|
</CollapsableMenu>
|
|
400
405
|
</div>
|