Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
sagemathinc
GitHub Repository: sagemathinc/cocalc
Path: blob/master/src/packages/frontend/editors/slate/edit-bar/component.tsx
1697 views
1
/*
2
* This file is part of CoCalc: Copyright © 2020 Sagemath, Inc.
3
* License: MS-RSL – see LICENSE.md for details
4
*/
5
6
import React from "react";
7
8
import { SlateEditor } from "../editable-markdown";
9
import { LinkEdit } from "./link-edit";
10
import { ListProperties } from "./list";
11
import { ListEdit } from "./list-edit";
12
import { Marks } from "./marks";
13
import { MarksBar } from "./marks-bar";
14
15
interface Props {
16
Search: React.JSX.Element;
17
isCurrent?: boolean;
18
marks: Marks;
19
linkURL: string | undefined;
20
listProperties: ListProperties | undefined;
21
editor: SlateEditor;
22
style?: React.CSSProperties;
23
hideSearch?: boolean; // often on SMALL docs, e.g., when embedding in chat, it's pointless to have our own find.
24
}
25
26
const HEIGHT = "25px";
27
28
export const EditBar: React.FC<Props> = (props: Props) => {
29
const {
30
isCurrent,
31
Search,
32
marks,
33
linkURL,
34
listProperties,
35
editor,
36
style,
37
hideSearch,
38
} = props;
39
40
function renderContent() {
41
return (
42
<>
43
<MarksBar marks={marks} editor={editor} />
44
<LinkEdit linkURL={linkURL} editor={editor} />
45
<ListEdit listProperties={listProperties} editor={editor} />
46
{!hideSearch && (
47
<div style={{ flex: 1, maxWidth: "50ex", marginRight: "15px" }}>
48
{Search}
49
</div>
50
)}
51
</>
52
);
53
}
54
55
return (
56
<div
57
style={{
58
borderBottom: isCurrent
59
? "1px solid lightgray"
60
: "1px solid transparent",
61
height: HEIGHT,
62
display: "flex",
63
flexDirection: "row",
64
overflow: "hidden",
65
...style,
66
}}
67
>
68
{isCurrent && renderContent()}
69
</div>
70
);
71
};
72
73