Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
sagemathinc
GitHub Repository: sagemathinc/cocalc
Path: blob/master/src/packages/frontend/editors/slate/elements/hr/editable.tsx
1702 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 { FOCUSED_COLOR } from "../../util";
7
import { register } from "../register";
8
import { useFocused, useSelected } from "../hooks";
9
10
register({
11
slateType: "hr",
12
13
Element: ({ attributes, children }) => {
14
const focused = useFocused();
15
const selected = useSelected();
16
17
// The borderTop on the hr is just "fighting back" against a dumb thing
18
// that is imposed by bootstrap3... (it's in scaffolding.less). Someday
19
// we'll get rid of bootstrap css entirely!
20
return (
21
<div {...attributes}>
22
<div
23
contentEditable={false}
24
style={{
25
border: `2px solid ${
26
focused && selected ? FOCUSED_COLOR : "transparent"
27
}`,
28
}}
29
>
30
<hr style={{ borderTop: "1px solid #aaa" }} />
31
</div>
32
{children}
33
</div>
34
);
35
},
36
37
fromSlate: () => "---\n\n",
38
});
39
40