@springmicro/rte 0.1.3 → 0.1.10
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/README.md +50 -5
- package/dist/index.js +7361 -7279
- package/package.json +7 -3
- package/.eslintrc.cjs +0 -18
- package/dist/index.d.ts +0 -10
- package/dist/index.umd.cjs +0 -469
- package/index.html +0 -13
- package/src/App.css +0 -42
- package/src/App.tsx +0 -10
- package/src/contexts/color-context.tsx +0 -53
- package/src/hooks/useSimpleFormik.tsx +0 -74
- package/src/index.css +0 -68
- package/src/index.tsx +0 -3
- package/src/main.tsx +0 -10
- package/src/slate/base-editor.stories.tsx +0 -16
- package/src/slate/base-editor.tsx +0 -116
- package/src/slate/blog-rte.stories.tsx +0 -16
- package/src/slate/blog-rte.tsx +0 -126
- package/src/slate/common/button.tsx +0 -35
- package/src/slate/common/element.tsx +0 -13
- package/src/slate/common/icon.jsx +0 -97
- package/src/slate/components/code-to-text/CodeToTextButton.jsx +0 -19
- package/src/slate/components/code-to-text/HtmlCode.jsx +0 -64
- package/src/slate/components/code-to-text/HtmlContextMenu.jsx +0 -39
- package/src/slate/components/code-to-text/index.jsx +0 -111
- package/src/slate/components/color-picker/color-cursor.stories.tsx +0 -16
- package/src/slate/components/color-picker/color-cursor.tsx +0 -34
- package/src/slate/components/color-picker/color-formats-view.stories.tsx +0 -25
- package/src/slate/components/color-picker/color-formats-view.tsx +0 -115
- package/src/slate/components/color-picker/color-gradient.stories.tsx +0 -48
- package/src/slate/components/color-picker/color-gradient.tsx +0 -128
- package/src/slate/components/color-picker/color-hue.stories.tsx +0 -41
- package/src/slate/components/color-picker/color-hue.tsx +0 -110
- package/src/slate/components/color-picker/color-picker.stories.tsx +0 -25
- package/src/slate/components/color-picker/color-picker.tsx +0 -41
- package/src/slate/components/color-picker/color-popover.stories.tsx +0 -26
- package/src/slate/components/color-picker/color-popover.tsx +0 -58
- package/src/slate/components/color-picker/color-swatch.stories.tsx +0 -16
- package/src/slate/components/color-picker/color-swatch.tsx +0 -76
- package/src/slate/components/color-picker/default-colors.ts +0 -38
- package/src/slate/components/color-picker/slate-color-button.tsx +0 -128
- package/src/slate/components/embed/Embed.jsx +0 -96
- package/src/slate/components/embed/Image.jsx +0 -45
- package/src/slate/components/embed/Video.jsx +0 -65
- package/src/slate/components/equation/Equation.jsx +0 -19
- package/src/slate/components/equation/EquationButton.jsx +0 -68
- package/src/slate/components/id/Id.jsx +0 -57
- package/src/slate/components/image/image.stories.tsx +0 -17
- package/src/slate/components/image/image.tsx +0 -62
- package/src/slate/components/image/insert-image-button.stories.tsx +0 -83
- package/src/slate/components/image/insert-image-button.tsx +0 -132
- package/src/slate/components/image/types.ts +0 -9
- package/src/slate/components/link/Link.jsx +0 -56
- package/src/slate/components/link/LinkButton.tsx +0 -106
- package/src/slate/components/table/Table.jsx +0 -11
- package/src/slate/components/table/TableSelector.jsx +0 -97
- package/src/slate/components/table-context-menu/TableContextMenu.tsx +0 -106
- package/src/slate/custom-types.d.ts +0 -152
- package/src/slate/editor.module.css +0 -226
- package/src/slate/paper-rte.stories.tsx +0 -16
- package/src/slate/paper-rte.tsx +0 -47
- package/src/slate/plugins/withEmbeds.js +0 -33
- package/src/slate/plugins/withEquation.js +0 -8
- package/src/slate/plugins/withImages.ts +0 -69
- package/src/slate/plugins/withLinks.js +0 -9
- package/src/slate/plugins/withTable.js +0 -74
- package/src/slate/serializers/generic.ts +0 -44
- package/src/slate/serializers/types.ts +0 -20
- package/src/slate/toolbar/index.tsx +0 -186
- package/src/slate/toolbar/paper-toolbar.tsx +0 -494
- package/src/slate/toolbar/shortcuts.tsx +0 -77
- package/src/slate/toolbar/toolbar-groups.ts +0 -213
- package/src/slate/types/index.ts +0 -0
- package/src/slate/utils/customHooks/useContextMenu.js +0 -42
- package/src/slate/utils/customHooks/useFormat.js +0 -26
- package/src/slate/utils/customHooks/usePopup.jsx +0 -26
- package/src/slate/utils/customHooks/useResize.js +0 -27
- package/src/slate/utils/embed.js +0 -18
- package/src/slate/utils/equation.js +0 -22
- package/src/slate/utils/index.jsx +0 -267
- package/src/slate/utils/link.js +0 -44
- package/src/slate/utils/p.js +0 -4
- package/src/slate/utils/table.js +0 -131
- package/src/vite-env.d.ts +0 -1
- package/tsconfig.json +0 -32
- package/tsconfig.node.json +0 -10
- package/vite.config.ts +0 -41
|
@@ -1,106 +0,0 @@
|
|
|
1
|
-
import { useRef, useState, MouseEvent, ChangeEvent, FormEvent } from "react";
|
|
2
|
-
import { insertLink } from "../../utils/link";
|
|
3
|
-
import Button from "../../common/button";
|
|
4
|
-
import Icon from "../../common/icon";
|
|
5
|
-
import { Box, Menu, MenuItem, TextField } from "@mui/material";
|
|
6
|
-
import { isBlockActive } from "../../utils";
|
|
7
|
-
import { IconButton, FormControlLabel, Checkbox } from "@mui/material";
|
|
8
|
-
import usePopup from "../../utils/customHooks/usePopup";
|
|
9
|
-
import { BaseEditor, BaseSelection, Location, Transforms } from "slate";
|
|
10
|
-
import { useShortcut } from "../../toolbar/shortcuts";
|
|
11
|
-
import { CustomEditor } from "../../custom-types";
|
|
12
|
-
|
|
13
|
-
export type LinkButtonProps = {
|
|
14
|
-
active: boolean;
|
|
15
|
-
editor: CustomEditor;
|
|
16
|
-
};
|
|
17
|
-
|
|
18
|
-
const LinkButton = (props: LinkButtonProps) => {
|
|
19
|
-
const { editor } = props;
|
|
20
|
-
const [anchorEl, setAnchorEl] = useState<null | Element>(null);
|
|
21
|
-
const open = Boolean(anchorEl);
|
|
22
|
-
const [url, setUrl] = useState("");
|
|
23
|
-
const [showInNewTab, setShowInNewTab] = useState(false);
|
|
24
|
-
const [selection, setSelection] = useState<BaseSelection | Location>();
|
|
25
|
-
|
|
26
|
-
const handleClick = (event?: MouseEvent<HTMLButtonElement>) => {
|
|
27
|
-
const el = event?.currentTarget
|
|
28
|
-
? event.currentTarget
|
|
29
|
-
: document.querySelector("#link-menu-button");
|
|
30
|
-
setSelection(editor.selection);
|
|
31
|
-
if (anchorEl) setAnchorEl(null);
|
|
32
|
-
else if (el) setAnchorEl(el);
|
|
33
|
-
};
|
|
34
|
-
|
|
35
|
-
// const handleClose = () => {
|
|
36
|
-
// setAnchorEl(null)
|
|
37
|
-
// }
|
|
38
|
-
|
|
39
|
-
const handleInsertLink = (e: FormEvent) => {
|
|
40
|
-
e.preventDefault();
|
|
41
|
-
if (selection === undefined) return;
|
|
42
|
-
Transforms.select(editor, selection!);
|
|
43
|
-
insertLink(editor, { url, showInNewTab });
|
|
44
|
-
setUrl("");
|
|
45
|
-
handleClick();
|
|
46
|
-
setShowInNewTab(false);
|
|
47
|
-
};
|
|
48
|
-
|
|
49
|
-
const handleInputChange = ({ target }: ChangeEvent<HTMLInputElement>) => {
|
|
50
|
-
if (target?.type === "checkbox") {
|
|
51
|
-
setShowInNewTab((prev) => !prev);
|
|
52
|
-
} else {
|
|
53
|
-
setUrl(target?.value);
|
|
54
|
-
}
|
|
55
|
-
};
|
|
56
|
-
|
|
57
|
-
useShortcut("link", () => handleClick());
|
|
58
|
-
|
|
59
|
-
return (
|
|
60
|
-
<>
|
|
61
|
-
<Button
|
|
62
|
-
id="link-menu-button"
|
|
63
|
-
aria-controls={open ? "basic-menu" : undefined}
|
|
64
|
-
aria-haspopup="true"
|
|
65
|
-
aria-expanded={open ? "true" : undefined}
|
|
66
|
-
onClick={handleClick}
|
|
67
|
-
format="link"
|
|
68
|
-
style={{ backgroundColor: "#f9fafc" }}
|
|
69
|
-
>
|
|
70
|
-
<Icon icon="link" />
|
|
71
|
-
</Button>
|
|
72
|
-
<Menu
|
|
73
|
-
id="basic-menu"
|
|
74
|
-
anchorEl={anchorEl}
|
|
75
|
-
open={open}
|
|
76
|
-
onClose={() => handleClick()}
|
|
77
|
-
MenuListProps={{
|
|
78
|
-
"aria-labelledby": "link-menu-button",
|
|
79
|
-
}}
|
|
80
|
-
>
|
|
81
|
-
<form onSubmit={handleInsertLink}>
|
|
82
|
-
<Box sx={{ display: "flex", gap: 1, px: 1 }}>
|
|
83
|
-
<TextField
|
|
84
|
-
aria-label="url"
|
|
85
|
-
type="text"
|
|
86
|
-
placeholder="https://springmicrohost.com"
|
|
87
|
-
value={url}
|
|
88
|
-
onChange={handleInputChange}
|
|
89
|
-
size="small"
|
|
90
|
-
/>
|
|
91
|
-
<IconButton type="submit" aria-label="add link" size="small">
|
|
92
|
-
<Icon icon="add" />
|
|
93
|
-
</IconButton>
|
|
94
|
-
</Box>
|
|
95
|
-
<FormControlLabel
|
|
96
|
-
control={<Checkbox onChange={handleInputChange} />}
|
|
97
|
-
label="Open in new tab"
|
|
98
|
-
sx={{ px: 2 }}
|
|
99
|
-
/>
|
|
100
|
-
</form>
|
|
101
|
-
</Menu>
|
|
102
|
-
</>
|
|
103
|
-
);
|
|
104
|
-
};
|
|
105
|
-
|
|
106
|
-
export default LinkButton;
|
|
@@ -1,97 +0,0 @@
|
|
|
1
|
-
import React, { useEffect, useRef, useState } from "react";
|
|
2
|
-
import Icon from "../../common/icon";
|
|
3
|
-
import usePopup from "../../utils/customHooks/usePopup";
|
|
4
|
-
import { Transforms } from "slate";
|
|
5
|
-
import { TableUtil } from "../../utils/table";
|
|
6
|
-
|
|
7
|
-
const TableSelector = ({ editor }) => {
|
|
8
|
-
const tableOptionsRef = useRef();
|
|
9
|
-
const [selection, setSelection] = useState();
|
|
10
|
-
const [showOptions, setShowOptions] = usePopup(tableOptionsRef);
|
|
11
|
-
const [tableData, setTableData] = useState({
|
|
12
|
-
row: 0,
|
|
13
|
-
column: 0,
|
|
14
|
-
});
|
|
15
|
-
const [tableInput, setTableInput] = useState(
|
|
16
|
-
Array.from({ length: 6 }, () =>
|
|
17
|
-
Array.from({ length: 6 }, (v, i) => ({
|
|
18
|
-
bg: "lightGray",
|
|
19
|
-
column: i,
|
|
20
|
-
}))
|
|
21
|
-
)
|
|
22
|
-
);
|
|
23
|
-
|
|
24
|
-
useEffect(() => {
|
|
25
|
-
const newTable = Array.from({ length: 6 }, (obj, row) =>
|
|
26
|
-
Array.from({ length: 6 }, (v, col) => ({
|
|
27
|
-
bg:
|
|
28
|
-
row + 1 <= tableData.row && col + 1 <= tableData.column
|
|
29
|
-
? "orange"
|
|
30
|
-
: "lightgray",
|
|
31
|
-
column: col,
|
|
32
|
-
}))
|
|
33
|
-
);
|
|
34
|
-
setTableInput(newTable);
|
|
35
|
-
}, [tableData]);
|
|
36
|
-
useEffect(() => {
|
|
37
|
-
if (!showOptions) {
|
|
38
|
-
setTableData({
|
|
39
|
-
row: 0,
|
|
40
|
-
column: 0,
|
|
41
|
-
});
|
|
42
|
-
}
|
|
43
|
-
}, [showOptions]);
|
|
44
|
-
const table = new TableUtil(editor);
|
|
45
|
-
|
|
46
|
-
const handleButtonClick = () => {
|
|
47
|
-
setSelection(editor.selection);
|
|
48
|
-
setShowOptions((prev) => !prev);
|
|
49
|
-
};
|
|
50
|
-
const handleInsert = () => {
|
|
51
|
-
selection && Transforms.select(editor, selection);
|
|
52
|
-
setTableData({ row: -1, column: -1 });
|
|
53
|
-
table.insertTable(tableData.row, tableData.column);
|
|
54
|
-
setShowOptions(false);
|
|
55
|
-
};
|
|
56
|
-
return (
|
|
57
|
-
<div ref={tableOptionsRef} className="popup-wrapper">
|
|
58
|
-
<button
|
|
59
|
-
style={{ border: showOptions ? "1px solid lightgray" : "none" }}
|
|
60
|
-
title="table"
|
|
61
|
-
onClick={handleButtonClick}
|
|
62
|
-
>
|
|
63
|
-
<Icon icon="table" />
|
|
64
|
-
</button>
|
|
65
|
-
{showOptions && (
|
|
66
|
-
<div className="popup">
|
|
67
|
-
{
|
|
68
|
-
<span style={{ fontSize: "0.85em" }}>
|
|
69
|
-
<i>{`Insert a ${
|
|
70
|
-
tableData.row >= 1
|
|
71
|
-
? `${tableData.row} x ${tableData.column}`
|
|
72
|
-
: ""
|
|
73
|
-
} table`}</i>
|
|
74
|
-
</span>
|
|
75
|
-
}
|
|
76
|
-
<div className="table-input">
|
|
77
|
-
{tableInput.map((grp, row) =>
|
|
78
|
-
grp.map(({ column, bg }, col) => (
|
|
79
|
-
<div
|
|
80
|
-
key={row + col}
|
|
81
|
-
onClick={() => handleInsert()}
|
|
82
|
-
onMouseOver={() =>
|
|
83
|
-
setTableData({ row: row + 1, column: column + 1 })
|
|
84
|
-
}
|
|
85
|
-
className="table-unit"
|
|
86
|
-
style={{ border: `1px solid ${bg}` }}
|
|
87
|
-
></div>
|
|
88
|
-
))
|
|
89
|
-
)}
|
|
90
|
-
</div>
|
|
91
|
-
</div>
|
|
92
|
-
)}
|
|
93
|
-
</div>
|
|
94
|
-
);
|
|
95
|
-
};
|
|
96
|
-
|
|
97
|
-
export default TableSelector;
|
|
@@ -1,106 +0,0 @@
|
|
|
1
|
-
import React, { useEffect, useState } from "react";
|
|
2
|
-
import useContextMenu from "../../utils/customHooks/useContextMenu";
|
|
3
|
-
import Icon from "../../common/icon";
|
|
4
|
-
import { TableUtil } from "../../utils/table";
|
|
5
|
-
import { BaseEditor, Location, Transforms } from "slate";
|
|
6
|
-
import { ReactEditor } from "slate-react";
|
|
7
|
-
import { CustomEditor } from "../../custom-types";
|
|
8
|
-
|
|
9
|
-
type Action = { type: string; position?: string };
|
|
10
|
-
|
|
11
|
-
const TableContextMenu = (props: { editor: CustomEditor }) => {
|
|
12
|
-
const { editor } = props;
|
|
13
|
-
const [selection, setSelection] = useState<Location>();
|
|
14
|
-
const [showMenu, { top, left }] = useContextMenu(
|
|
15
|
-
editor,
|
|
16
|
-
"table",
|
|
17
|
-
setSelection
|
|
18
|
-
) as [
|
|
19
|
-
boolean,
|
|
20
|
-
{
|
|
21
|
-
top: string;
|
|
22
|
-
left: string;
|
|
23
|
-
}
|
|
24
|
-
];
|
|
25
|
-
const table = new TableUtil(editor);
|
|
26
|
-
|
|
27
|
-
const menu = [
|
|
28
|
-
{
|
|
29
|
-
icon: "insertColumnRight",
|
|
30
|
-
text: "Insert Columns to the Right",
|
|
31
|
-
action: {
|
|
32
|
-
type: "insertColumn",
|
|
33
|
-
position: "after",
|
|
34
|
-
},
|
|
35
|
-
},
|
|
36
|
-
{
|
|
37
|
-
icon: "insertColumnLeft",
|
|
38
|
-
text: "Insert Columns to the Left",
|
|
39
|
-
action: {
|
|
40
|
-
type: "insertColumn",
|
|
41
|
-
position: "at",
|
|
42
|
-
},
|
|
43
|
-
},
|
|
44
|
-
{
|
|
45
|
-
icon: "insertRowAbove",
|
|
46
|
-
text: "Insert Row Above",
|
|
47
|
-
action: {
|
|
48
|
-
type: "insertRow",
|
|
49
|
-
positon: "at",
|
|
50
|
-
},
|
|
51
|
-
},
|
|
52
|
-
{
|
|
53
|
-
icon: "insertRowBelow",
|
|
54
|
-
text: "Insert Row Below",
|
|
55
|
-
action: {
|
|
56
|
-
type: "insertRow",
|
|
57
|
-
position: "after",
|
|
58
|
-
},
|
|
59
|
-
},
|
|
60
|
-
{
|
|
61
|
-
icon: "trashCan",
|
|
62
|
-
text: "Remove Table",
|
|
63
|
-
action: {
|
|
64
|
-
type: "remove",
|
|
65
|
-
},
|
|
66
|
-
},
|
|
67
|
-
];
|
|
68
|
-
|
|
69
|
-
const handleInsert = ({ type, position }: Action) => {
|
|
70
|
-
if (selection === undefined) return;
|
|
71
|
-
Transforms.select(editor, selection);
|
|
72
|
-
switch (type) {
|
|
73
|
-
case "insertRow":
|
|
74
|
-
table.insertRow(position);
|
|
75
|
-
break;
|
|
76
|
-
case "insertColumn":
|
|
77
|
-
table.insertColumn(position);
|
|
78
|
-
break;
|
|
79
|
-
case "remove":
|
|
80
|
-
table.removeTable();
|
|
81
|
-
break;
|
|
82
|
-
default:
|
|
83
|
-
return;
|
|
84
|
-
}
|
|
85
|
-
ReactEditor.focus(editor as ReactEditor);
|
|
86
|
-
};
|
|
87
|
-
|
|
88
|
-
return showMenu ? (
|
|
89
|
-
<div className="contextMenu" style={{ top, left }}>
|
|
90
|
-
{menu.map(({ icon, text, action }, index) => (
|
|
91
|
-
<div
|
|
92
|
-
className="menuOption"
|
|
93
|
-
key={index}
|
|
94
|
-
onClick={() => handleInsert(action)}
|
|
95
|
-
>
|
|
96
|
-
<Icon icon={icon} />
|
|
97
|
-
<span>{text}</span>
|
|
98
|
-
</div>
|
|
99
|
-
))}
|
|
100
|
-
</div>
|
|
101
|
-
) : (
|
|
102
|
-
<></>
|
|
103
|
-
);
|
|
104
|
-
};
|
|
105
|
-
|
|
106
|
-
export default TableContextMenu;
|
|
@@ -1,152 +0,0 @@
|
|
|
1
|
-
import { Descendant, BaseEditor, BaseRange, Range, Element } from "slate";
|
|
2
|
-
import { ReactEditor } from "slate-react";
|
|
3
|
-
import { HistoryEditor } from "slate-history";
|
|
4
|
-
import { Node } from "domhandler";
|
|
5
|
-
|
|
6
|
-
export type BlockQuoteElement = {
|
|
7
|
-
type: "block-quote";
|
|
8
|
-
align?: string;
|
|
9
|
-
children: Descendant[];
|
|
10
|
-
};
|
|
11
|
-
|
|
12
|
-
export type BulletedListElement = {
|
|
13
|
-
type: "unorderedList";
|
|
14
|
-
align?: string;
|
|
15
|
-
children: Descendant[];
|
|
16
|
-
};
|
|
17
|
-
|
|
18
|
-
export type CheckListItemElement = {
|
|
19
|
-
type: "check-list-item";
|
|
20
|
-
checked: boolean;
|
|
21
|
-
children: Descendant[];
|
|
22
|
-
};
|
|
23
|
-
|
|
24
|
-
export type EditableVoidElement = {
|
|
25
|
-
type: "editable-void";
|
|
26
|
-
children: EmptyText[];
|
|
27
|
-
};
|
|
28
|
-
|
|
29
|
-
export type HeadingElement = {
|
|
30
|
-
type: "h1";
|
|
31
|
-
align?: string;
|
|
32
|
-
children: Descendant[];
|
|
33
|
-
};
|
|
34
|
-
|
|
35
|
-
export type HeadingTwoElement = {
|
|
36
|
-
type: "h2";
|
|
37
|
-
align?: string;
|
|
38
|
-
children: Descendant[];
|
|
39
|
-
};
|
|
40
|
-
|
|
41
|
-
export type HeadingThreeElement = {
|
|
42
|
-
type: "h3";
|
|
43
|
-
align?: string;
|
|
44
|
-
children: Descendant[];
|
|
45
|
-
};
|
|
46
|
-
|
|
47
|
-
export type ImageElement = {
|
|
48
|
-
type: "image";
|
|
49
|
-
url: string;
|
|
50
|
-
children: EmptyText[];
|
|
51
|
-
};
|
|
52
|
-
|
|
53
|
-
export type LinkElement = {
|
|
54
|
-
type: "link";
|
|
55
|
-
href: string;
|
|
56
|
-
target?: string;
|
|
57
|
-
children: Descendant[];
|
|
58
|
-
};
|
|
59
|
-
|
|
60
|
-
export type ButtonElement = { type: "button"; children: Descendant[] };
|
|
61
|
-
|
|
62
|
-
export type BadgeElement = { type: "badge"; children: Descendant[] };
|
|
63
|
-
|
|
64
|
-
export type ListItemElement = { type: "li"; children: Descendant[] };
|
|
65
|
-
|
|
66
|
-
export type MentionElement = {
|
|
67
|
-
type: "mention";
|
|
68
|
-
character: string;
|
|
69
|
-
children: CustomText[];
|
|
70
|
-
};
|
|
71
|
-
|
|
72
|
-
export type ParagraphElement = {
|
|
73
|
-
type: "p";
|
|
74
|
-
align?: string;
|
|
75
|
-
children: Descendant[];
|
|
76
|
-
};
|
|
77
|
-
|
|
78
|
-
export type TableElement = { type: "table"; children: TableRow[] };
|
|
79
|
-
|
|
80
|
-
export type TableCellElement = { type: "table-cell"; children: CustomText[] };
|
|
81
|
-
|
|
82
|
-
export type TableRowElement = { type: "table-row"; children: TableCell[] };
|
|
83
|
-
|
|
84
|
-
export type TitleElement = { type: "title"; children: Descendant[] };
|
|
85
|
-
|
|
86
|
-
export type VideoElement = {
|
|
87
|
-
type: "video";
|
|
88
|
-
url: string;
|
|
89
|
-
children: EmptyText[];
|
|
90
|
-
};
|
|
91
|
-
|
|
92
|
-
export type CodeBlockElement = {
|
|
93
|
-
type: "code-block";
|
|
94
|
-
language: string;
|
|
95
|
-
children: Descendant[];
|
|
96
|
-
};
|
|
97
|
-
|
|
98
|
-
export type CodeLineElement = {
|
|
99
|
-
type: "code-line";
|
|
100
|
-
children: Descendant[];
|
|
101
|
-
};
|
|
102
|
-
|
|
103
|
-
type CustomElement =
|
|
104
|
-
| BlockQuoteElement
|
|
105
|
-
| BulletedListElement
|
|
106
|
-
| CheckListItemElement
|
|
107
|
-
| EditableVoidElement
|
|
108
|
-
| HeadingElement
|
|
109
|
-
| HeadingTwoElement
|
|
110
|
-
| HeadingThreeElement
|
|
111
|
-
| ImageElement
|
|
112
|
-
| LinkElement
|
|
113
|
-
| ButtonElement
|
|
114
|
-
| BadgeElement
|
|
115
|
-
| ListItemElement
|
|
116
|
-
| MentionElement
|
|
117
|
-
| ParagraphElement
|
|
118
|
-
| TableElement
|
|
119
|
-
| TableRowElement
|
|
120
|
-
| TableCellElement
|
|
121
|
-
| TitleElement
|
|
122
|
-
| VideoElement
|
|
123
|
-
| CodeBlockElement
|
|
124
|
-
| CodeLineElement;
|
|
125
|
-
|
|
126
|
-
export type CustomText = {
|
|
127
|
-
bold?: boolean;
|
|
128
|
-
italic?: boolean;
|
|
129
|
-
code?: boolean;
|
|
130
|
-
text: string;
|
|
131
|
-
};
|
|
132
|
-
|
|
133
|
-
export type EmptyText = {
|
|
134
|
-
text: string;
|
|
135
|
-
};
|
|
136
|
-
|
|
137
|
-
export type CustomEditor = BaseEditor &
|
|
138
|
-
ReactEditor &
|
|
139
|
-
HistoryEditor & {
|
|
140
|
-
nodeToDecorations?: Map<Element, Range[]>;
|
|
141
|
-
};
|
|
142
|
-
|
|
143
|
-
declare module "slate" {
|
|
144
|
-
interface CustomTypes {
|
|
145
|
-
Editor: CustomEditor;
|
|
146
|
-
Element: CustomElement;
|
|
147
|
-
Text: CustomText | EmptyText;
|
|
148
|
-
Range: BaseRange & {
|
|
149
|
-
[key: string]: unknown;
|
|
150
|
-
};
|
|
151
|
-
}
|
|
152
|
-
}
|
|
@@ -1,226 +0,0 @@
|
|
|
1
|
-
/* In Use */
|
|
2
|
-
.popupWrapper {
|
|
3
|
-
display: inline;
|
|
4
|
-
position: relative;
|
|
5
|
-
}
|
|
6
|
-
.popup {
|
|
7
|
-
position: absolute;
|
|
8
|
-
left: 0;
|
|
9
|
-
background-color: white;
|
|
10
|
-
padding: 6px 10px;
|
|
11
|
-
border: 1px solid #e6e8f0;
|
|
12
|
-
height: fit-content;
|
|
13
|
-
z-index: 1000;
|
|
14
|
-
}
|
|
15
|
-
.editorWrapper {
|
|
16
|
-
border-radius: 8px;
|
|
17
|
-
min-height: 100px;
|
|
18
|
-
min-width: 100%;
|
|
19
|
-
width: fit-content;
|
|
20
|
-
height: fit-content;
|
|
21
|
-
margin-top: 6px;
|
|
22
|
-
border: 1px solid #e6e8f0;
|
|
23
|
-
padding: 0 10px;
|
|
24
|
-
}
|
|
25
|
-
.editorWrapper > div:focus-visible {
|
|
26
|
-
border: none;
|
|
27
|
-
outline: none;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
.slate blockquote {
|
|
31
|
-
border-left: 2px solid #ddd;
|
|
32
|
-
margin-left: 0;
|
|
33
|
-
margin-right: 0;
|
|
34
|
-
padding-left: 10px;
|
|
35
|
-
color: #aaa;
|
|
36
|
-
font-style: italic;
|
|
37
|
-
}
|
|
38
|
-
.slate table,
|
|
39
|
-
.slate th,
|
|
40
|
-
.slate td {
|
|
41
|
-
border: 1px solid black;
|
|
42
|
-
}
|
|
43
|
-
.slate table {
|
|
44
|
-
border-collapse: collapse;
|
|
45
|
-
}
|
|
46
|
-
.slate button {
|
|
47
|
-
background-color: white;
|
|
48
|
-
border: none;
|
|
49
|
-
opacity: 0.5;
|
|
50
|
-
}
|
|
51
|
-
.slate .btnActive {
|
|
52
|
-
opacity: 1;
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
.slate table {
|
|
56
|
-
width: 100%;
|
|
57
|
-
}
|
|
58
|
-
.slate td {
|
|
59
|
-
height: 50px;
|
|
60
|
-
padding: 0 5px;
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
.slate ul,
|
|
64
|
-
.slate ol {
|
|
65
|
-
padding-left: 1rem;
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
.slate button {
|
|
69
|
-
cursor: pointer;
|
|
70
|
-
}
|
|
71
|
-
.slate code {
|
|
72
|
-
font-family: source-code-pro, Menlo, Monaco, Consolas, "Courier New",
|
|
73
|
-
monospace;
|
|
74
|
-
}
|
|
75
|
-
.slate [data-slate-node="element"]:not(li) {
|
|
76
|
-
margin: 10px 0;
|
|
77
|
-
}
|
|
78
|
-
/* CodeToText.css */
|
|
79
|
-
.slate .code-wrapper {
|
|
80
|
-
position: fixed;
|
|
81
|
-
top: 0;
|
|
82
|
-
left: 0;
|
|
83
|
-
width: 100vw;
|
|
84
|
-
height: 100vh;
|
|
85
|
-
background: rgba(0, 0, 0, 0.9);
|
|
86
|
-
z-index: 2;
|
|
87
|
-
display: flex;
|
|
88
|
-
justify-content: center;
|
|
89
|
-
align-items: center;
|
|
90
|
-
}
|
|
91
|
-
.slate .codeToTextWrapper {
|
|
92
|
-
width: 80%;
|
|
93
|
-
height: 80%;
|
|
94
|
-
grid-template-columns: 45% 10% 45%;
|
|
95
|
-
}
|
|
96
|
-
.slate .codeToText {
|
|
97
|
-
width: 100%;
|
|
98
|
-
height: 90%;
|
|
99
|
-
display: grid;
|
|
100
|
-
grid-template-columns: 45% 10% 45%;
|
|
101
|
-
}
|
|
102
|
-
.slate .codeToText textarea,
|
|
103
|
-
.textOutput {
|
|
104
|
-
border-radius: 15px;
|
|
105
|
-
padding: 10px;
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
.slate .codeToText textarea {
|
|
109
|
-
resize: none;
|
|
110
|
-
}
|
|
111
|
-
.slate .codeToText textarea:focus {
|
|
112
|
-
outline: none;
|
|
113
|
-
}
|
|
114
|
-
.slate .textOutput {
|
|
115
|
-
background: #fff;
|
|
116
|
-
overflow: scroll;
|
|
117
|
-
}
|
|
118
|
-
.slate .codeToTextWrapper button {
|
|
119
|
-
margin: 3% 1%;
|
|
120
|
-
padding: 10px 37px;
|
|
121
|
-
cursor: pointer;
|
|
122
|
-
border-radius: 5px;
|
|
123
|
-
opacity: 1;
|
|
124
|
-
font-weight: bolder;
|
|
125
|
-
}
|
|
126
|
-
.slate .done {
|
|
127
|
-
background: #3fc79a;
|
|
128
|
-
color: #fff;
|
|
129
|
-
}
|
|
130
|
-
.slate .clear {
|
|
131
|
-
background: #fff;
|
|
132
|
-
color: #a9a4a4;
|
|
133
|
-
border: 1px solid #e6e8f0;
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
/* Embed.css */
|
|
137
|
-
.slate .embed {
|
|
138
|
-
width: fit-content;
|
|
139
|
-
position: relative;
|
|
140
|
-
margin-right: 20px;
|
|
141
|
-
}
|
|
142
|
-
.slate .embed img,
|
|
143
|
-
.slate .embed iframe {
|
|
144
|
-
width: 100%;
|
|
145
|
-
height: 100%;
|
|
146
|
-
}
|
|
147
|
-
.slate .embed button {
|
|
148
|
-
position: absolute;
|
|
149
|
-
bottom: -6px;
|
|
150
|
-
right: 0;
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
/* Equation */
|
|
154
|
-
.slate .equation-inline {
|
|
155
|
-
display: inline;
|
|
156
|
-
position: relative;
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
/* TableSelector.css */
|
|
160
|
-
.slate .table-option {
|
|
161
|
-
display: flex;
|
|
162
|
-
margin: 5px 2px;
|
|
163
|
-
gap: 5px;
|
|
164
|
-
}
|
|
165
|
-
.slate .table-option {
|
|
166
|
-
white-space: nowrap;
|
|
167
|
-
}
|
|
168
|
-
.slate .table-input {
|
|
169
|
-
display: grid;
|
|
170
|
-
grid-template-columns: auto auto auto auto auto auto;
|
|
171
|
-
gap: 3px;
|
|
172
|
-
}
|
|
173
|
-
.slate .table-unit {
|
|
174
|
-
width: 15px;
|
|
175
|
-
height: 15px;
|
|
176
|
-
border: 1px solid #e6e8f0;
|
|
177
|
-
}
|
|
178
|
-
|
|
179
|
-
/* TableContextMenu */
|
|
180
|
-
.slate .contextMenu {
|
|
181
|
-
width: fit-content;
|
|
182
|
-
height: fit-content;
|
|
183
|
-
position: fixed;
|
|
184
|
-
background: white;
|
|
185
|
-
border: 1px solid #e6e8f0;
|
|
186
|
-
border-radius: 10px;
|
|
187
|
-
padding: 0.5%;
|
|
188
|
-
display: flex;
|
|
189
|
-
gap: 15px;
|
|
190
|
-
flex-direction: column;
|
|
191
|
-
cursor: pointer;
|
|
192
|
-
}
|
|
193
|
-
.slate .menuOption {
|
|
194
|
-
display: flex;
|
|
195
|
-
gap: 15px;
|
|
196
|
-
}
|
|
197
|
-
|
|
198
|
-
/* Toolbar */
|
|
199
|
-
.slate .toolbar {
|
|
200
|
-
border-radius: 10px;
|
|
201
|
-
background: #ffffff;
|
|
202
|
-
box-shadow: -8px 8px 13px #ededed, 8px -8px 13px #ffffff;
|
|
203
|
-
margin: 5% 0;
|
|
204
|
-
display: flex;
|
|
205
|
-
flex-direction: row;
|
|
206
|
-
flex-wrap: wrap;
|
|
207
|
-
align-items: center;
|
|
208
|
-
padding: 15px 10px;
|
|
209
|
-
row-gap: 15px;
|
|
210
|
-
position: -webkit-sticky;
|
|
211
|
-
position: sticky;
|
|
212
|
-
top: 0;
|
|
213
|
-
z-index: 2;
|
|
214
|
-
}
|
|
215
|
-
.slate .toolbar-grp > * {
|
|
216
|
-
margin-right: 10px;
|
|
217
|
-
cursor: pointer;
|
|
218
|
-
}
|
|
219
|
-
.slate .toolbar-grp {
|
|
220
|
-
margin: 0 10px;
|
|
221
|
-
}
|
|
222
|
-
.slate select {
|
|
223
|
-
height: 30px;
|
|
224
|
-
border: none;
|
|
225
|
-
width: 6.9rem;
|
|
226
|
-
}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { PaperEditor, PaperEditorProps } from "./paper-rte"
|
|
2
|
-
import React from "react"
|
|
3
|
-
import { StoryFn, Meta } from "@storybook/react"
|
|
4
|
-
|
|
5
|
-
export default {
|
|
6
|
-
/* 👇 The title prop is optional.
|
|
7
|
-
* See https://storybook.js.org/docs/react/configure/overview#configure-story-loading
|
|
8
|
-
* to learn how to generate automatic titles
|
|
9
|
-
*/
|
|
10
|
-
title: "Slate/Paper Editor",
|
|
11
|
-
component: PaperEditor,
|
|
12
|
-
} as Meta<typeof PaperEditor>
|
|
13
|
-
|
|
14
|
-
export const Primary = {
|
|
15
|
-
args: {} as PaperEditorProps,
|
|
16
|
-
}
|