@vonaffenfels/slate-editor 1.1.49 → 1.1.50
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.js +9 -9
- package/dist/Renderer.js +1 -1
- package/dist/index.js +9 -9
- package/package.json +2 -2
- package/src/Nodes/Leaf.js +18 -3
- package/src/Nodes/Text.js +38 -7
- package/src/Toolbar/Formats.js +15 -3
- package/src/Toolbar/Toolbar.js +2 -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.50",
|
|
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": "0cede70748584b53424ae59e9d81271db780745c",
|
|
76
76
|
"publishConfig": {
|
|
77
77
|
"access": "public"
|
|
78
78
|
}
|
package/src/Nodes/Leaf.js
CHANGED
|
@@ -1,8 +1,16 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
2
|
+
import {
|
|
3
|
+
Bold, Italic, Text, Underlined, Strikethrough, Small, SuperscriptUp,
|
|
4
|
+
} from "./Text";
|
|
5
5
|
|
|
6
|
+
export const Leaf = ({
|
|
7
|
+
attributes,
|
|
8
|
+
children,
|
|
9
|
+
leaf,
|
|
10
|
+
isRenderer,
|
|
11
|
+
typeProps,
|
|
12
|
+
...props
|
|
13
|
+
}) => {
|
|
6
14
|
if (leaf.bold) {
|
|
7
15
|
children = <Bold typeProps={typeProps} attributes={attributes}><Text
|
|
8
16
|
attributes={attributes}
|
|
@@ -36,5 +44,12 @@ export const Leaf = ({attributes, children, leaf, isRenderer, typeProps, ...prop
|
|
|
36
44
|
isRenderer={isRenderer}>{children}</Text></Small>;
|
|
37
45
|
}
|
|
38
46
|
|
|
47
|
+
if (leaf.superscriptUp) {
|
|
48
|
+
children = <SuperscriptUp typeProps={typeProps} attributes={attributes}><Text
|
|
49
|
+
attributes={attributes}
|
|
50
|
+
typeProps={typeProps}
|
|
51
|
+
isRenderer={isRenderer}>{children}</Text></SuperscriptUp>;
|
|
52
|
+
}
|
|
53
|
+
|
|
39
54
|
return <Text attributes={attributes} typeProps={typeProps} isRenderer={isRenderer}>{children}</Text>;
|
|
40
55
|
};
|
package/src/Nodes/Text.js
CHANGED
|
@@ -2,7 +2,12 @@ import React, {Fragment} from "react";
|
|
|
2
2
|
|
|
3
3
|
const EmptyWrapper = ({children}) => <>{children}</>;
|
|
4
4
|
|
|
5
|
-
export const Text = ({
|
|
5
|
+
export const Text = ({
|
|
6
|
+
isRenderer,
|
|
7
|
+
attributes,
|
|
8
|
+
children,
|
|
9
|
+
typeProps,
|
|
10
|
+
}) => {
|
|
6
11
|
if (isRenderer) {
|
|
7
12
|
if (!children) {
|
|
8
13
|
return null;
|
|
@@ -23,7 +28,6 @@ export const Text = ({isRenderer, attributes, children, typeProps}) => {
|
|
|
23
28
|
{children}
|
|
24
29
|
</Fragment>;
|
|
25
30
|
}
|
|
26
|
-
|
|
27
31
|
}
|
|
28
32
|
|
|
29
33
|
return <span {...attributes}>{children}</span>;
|
|
@@ -46,22 +50,49 @@ function renderTextLine(text, typeProps) {
|
|
|
46
50
|
return text;
|
|
47
51
|
}
|
|
48
52
|
|
|
49
|
-
export const Bold = ({
|
|
53
|
+
export const Bold = ({
|
|
54
|
+
attributes,
|
|
55
|
+
children,
|
|
56
|
+
}) => {
|
|
50
57
|
return <strong {...attributes}>{children}</strong>;
|
|
51
58
|
};
|
|
52
59
|
|
|
53
|
-
export const Italic = ({
|
|
60
|
+
export const Italic = ({
|
|
61
|
+
attributes,
|
|
62
|
+
children,
|
|
63
|
+
}) => {
|
|
54
64
|
return <i {...attributes}>{children}</i>;
|
|
55
65
|
};
|
|
56
66
|
|
|
57
|
-
export const Underlined = ({
|
|
67
|
+
export const Underlined = ({
|
|
68
|
+
attributes,
|
|
69
|
+
children,
|
|
70
|
+
}) => {
|
|
58
71
|
return <u {...attributes}>{children}</u>;
|
|
59
72
|
};
|
|
60
73
|
|
|
61
|
-
export const Strikethrough = ({
|
|
74
|
+
export const Strikethrough = ({
|
|
75
|
+
attributes,
|
|
76
|
+
children,
|
|
77
|
+
}) => {
|
|
62
78
|
return <del {...attributes}>{children}</del>;
|
|
63
79
|
};
|
|
64
80
|
|
|
65
|
-
export const Small = ({
|
|
81
|
+
export const Small = ({
|
|
82
|
+
attributes,
|
|
83
|
+
children,
|
|
84
|
+
}) => {
|
|
66
85
|
return <small {...attributes}>{children}</small>;
|
|
86
|
+
};
|
|
87
|
+
|
|
88
|
+
export const SuperscriptUp = ({
|
|
89
|
+
attributes,
|
|
90
|
+
children,
|
|
91
|
+
}) => {
|
|
92
|
+
return <span
|
|
93
|
+
style={{
|
|
94
|
+
fontSize: "60%",
|
|
95
|
+
verticalAlign: "top",
|
|
96
|
+
}}
|
|
97
|
+
{...attributes}>{children}</span>;
|
|
67
98
|
};
|
package/src/Toolbar/Formats.js
CHANGED
|
@@ -2,10 +2,18 @@ import {useSlate} from "slate-react";
|
|
|
2
2
|
import {FontAwesomeIcon} from "@fortawesome/react-fontawesome";
|
|
3
3
|
import React, {useState} from "react";
|
|
4
4
|
import classNames from "classnames";
|
|
5
|
-
import {
|
|
6
|
-
|
|
5
|
+
import {
|
|
6
|
+
Editor, Text, Transforms,
|
|
7
|
+
} from "slate";
|
|
8
|
+
import {
|
|
9
|
+
faBold, faItalic, faUnderline, faStrikethrough, faSuperscript,
|
|
10
|
+
} from "@fortawesome/free-solid-svg-icons";
|
|
7
11
|
|
|
8
|
-
export const FormatButton = ({
|
|
12
|
+
export const FormatButton = ({
|
|
13
|
+
format,
|
|
14
|
+
icon,
|
|
15
|
+
children,
|
|
16
|
+
}) => {
|
|
9
17
|
const editor = useSlate();
|
|
10
18
|
const onClick = (event) => {
|
|
11
19
|
event.preventDefault();
|
|
@@ -57,4 +65,8 @@ export const FormatButtonUnderline = () => {
|
|
|
57
65
|
|
|
58
66
|
export const FormatButtonStrikethrough = () => {
|
|
59
67
|
return <FormatButton format="strikethrough" icon={faStrikethrough}/>;
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
export const FormatButtonSuperscriptUp = () => {
|
|
71
|
+
return <FormatButton format="superscriptUp" icon={faSuperscript}/>;
|
|
60
72
|
};
|
package/src/Toolbar/Toolbar.js
CHANGED
|
@@ -8,7 +8,7 @@ import classNames from "classnames";
|
|
|
8
8
|
// eslint-disable-next-line import/no-unresolved
|
|
9
9
|
import "scss/toolbar.scss";
|
|
10
10
|
import {
|
|
11
|
-
FormatButtonBold, FormatButtonItalic, FormatButtonStrikethrough, FormatButtonUnderline,
|
|
11
|
+
FormatButtonBold, FormatButtonItalic, FormatButtonStrikethrough, FormatButtonSuperscriptUp, FormatButtonUnderline,
|
|
12
12
|
} from "./Formats";
|
|
13
13
|
import {
|
|
14
14
|
AlignButtonLeft, AlignButtonCenter, AlignButtonRight,
|
|
@@ -144,6 +144,7 @@ export const Toolbar = ({
|
|
|
144
144
|
<FormatButtonItalic/>
|
|
145
145
|
<FormatButtonUnderline/>
|
|
146
146
|
<FormatButtonStrikethrough/>
|
|
147
|
+
<FormatButtonSuperscriptUp />
|
|
147
148
|
|
|
148
149
|
<LinkButton/>
|
|
149
150
|
|