@vonaffenfels/slate-editor 1.1.12 → 1.1.14
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 +8 -8
- package/dist/Renderer.js +1 -1
- package/dist/index.css +1 -1
- package/dist/index.js +8 -8
- package/package.json +2 -2
- package/src/Blocks/LayoutSlot.js +32 -2
- package/src/Serializer/Serializer.js +7 -2
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vonaffenfels/slate-editor",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.14",
|
|
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": "105cece6edc0d564f2c1af57a0516f9f99f82e33",
|
|
76
76
|
"publishConfig": {
|
|
77
77
|
"access": "public"
|
|
78
78
|
}
|
package/src/Blocks/LayoutSlot.js
CHANGED
|
@@ -5,6 +5,8 @@ import {Transforms} from "slate";
|
|
|
5
5
|
import {ReactEditor} from "slate-react";
|
|
6
6
|
import classNames from "classnames";
|
|
7
7
|
import {ToolMargin} from "../Tools/Margin";
|
|
8
|
+
import {FontAwesomeIcon} from "@fortawesome/react-fontawesome";
|
|
9
|
+
import {faStickyNote} from "@fortawesome/free-solid-svg-icons";
|
|
8
10
|
|
|
9
11
|
export const LayoutSlotContext = createContext({isInSlot: false});
|
|
10
12
|
|
|
@@ -28,6 +30,25 @@ export const LayoutSlot = ({
|
|
|
28
30
|
}, {at: path});
|
|
29
31
|
};
|
|
30
32
|
|
|
33
|
+
const switchSticky = () => {
|
|
34
|
+
let node = ReactEditor.toSlateNode(editor, attributes.ref.current);
|
|
35
|
+
let path = ReactEditor.findPath(editor, node);
|
|
36
|
+
let stickyTop = element?.attributes?.stickyTop;
|
|
37
|
+
|
|
38
|
+
if (!element.attributes.sticky) {
|
|
39
|
+
stickyTop = prompt("Abstand nach oben, wenn sticky", element?.attributes?.stickyTop || 0);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
Transforms.setNodes(editor, {
|
|
43
|
+
type: "layout-slot",
|
|
44
|
+
attributes: {
|
|
45
|
+
...(element.attributes || {}),
|
|
46
|
+
sticky: !element.attributes.sticky,
|
|
47
|
+
stickyTop: stickyTop || 0,
|
|
48
|
+
},
|
|
49
|
+
}, {at: path});
|
|
50
|
+
};
|
|
51
|
+
|
|
31
52
|
return <div
|
|
32
53
|
className={classNames({
|
|
33
54
|
["layout-slot layout-slot-" + element.attributes.name]: true,
|
|
@@ -51,10 +72,19 @@ export const LayoutSlot = ({
|
|
|
51
72
|
{element.attributes.name}
|
|
52
73
|
</span>
|
|
53
74
|
|
|
54
|
-
<
|
|
75
|
+
<div className="flex items-center">
|
|
76
|
+
{!element?.attributes?.sticky ? (
|
|
77
|
+
<FontAwesomeIcon icon={faStickyNote} color="#000000" size="md" className="mr-2 cursor-pointer" onClick={switchSticky} />
|
|
78
|
+
) : (
|
|
79
|
+
<FontAwesomeIcon icon={faStickyNote} color="#3490f3" size="md" className="mr-2 cursor-pointer" onClick={switchSticky} />
|
|
80
|
+
)}
|
|
81
|
+
<ToolMargin margin={element?.attributes?.margin} onChange={onMarginChange}/>
|
|
82
|
+
</div>
|
|
55
83
|
</div>
|
|
56
84
|
<div className="layout-slot-content">
|
|
57
|
-
{
|
|
85
|
+
<div className={classNames({"sticky top-[80px]": element?.attributes?.sticky})}>
|
|
86
|
+
{children}
|
|
87
|
+
</div>
|
|
58
88
|
</div>
|
|
59
89
|
</LayoutSlotContext.Provider>
|
|
60
90
|
</div>;
|
|
@@ -177,8 +177,13 @@ export function Serializer({
|
|
|
177
177
|
"md:ml-4": props.attributes?.margin?.left,
|
|
178
178
|
})}
|
|
179
179
|
>
|
|
180
|
-
|
|
181
|
-
|
|
180
|
+
<div
|
|
181
|
+
style={{top: props.attributes?.sticky && "80px"}}
|
|
182
|
+
className={classNames({"sticky": props.attributes?.sticky})}>
|
|
183
|
+
{props.children.map((v, i) => <div
|
|
184
|
+
key={"layout-slot-" + i}
|
|
185
|
+
>{serializeNode(v, i, props.attributes.name)}</div>)}
|
|
186
|
+
</div>
|
|
182
187
|
</div>
|
|
183
188
|
</Wrapper>;
|
|
184
189
|
default: {
|