Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
sagemathinc
GitHub Repository: sagemathinc/cocalc
Path: blob/master/src/packages/frontend/editors/slate/leaf-with-cursor.tsx
1691 views
1
import { Cursor } from "@cocalc/frontend/jupyter/cursors";
2
import Leaf from "./leaf";
3
import type { RenderLeafProps } from "./slate-react";
4
5
export default function LeafWithCursor({
6
attributes,
7
children,
8
leaf,
9
text,
10
}: RenderLeafProps) {
11
if ((leaf as any).cursor == null) {
12
return (
13
<Leaf leaf={leaf} text={text} attributes={attributes}>
14
{children}
15
</Leaf>
16
);
17
}
18
const { name, color, paddingText } = (leaf as any).cursor;
19
return (
20
<Leaf leaf={leaf} text={text} attributes={attributes}>
21
<span>
22
<span contentEditable={false}>
23
<Cursor name={name} color={color} paddingText={paddingText} />
24
</span>
25
{children}
26
</span>
27
</Leaf>
28
);
29
}
30
31