Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
sagemathinc
GitHub Repository: sagemathinc/cocalc
Path: blob/master/src/packages/frontend/editors/slate/elements/references/index.tsx
1698 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 { register } from "../register";
7
import { References, createReferencesNode } from "./type";
8
export type { References };
9
export { createReferencesNode };
10
11
12
register({
13
slateType: "references",
14
15
toSlate: ({ token }) => {
16
// this doesn't actually happen, since references aren't tokenized,
17
// but are parsed out separately in state.
18
return createReferencesNode(token.content);
19
},
20
21
StaticElement: ({ attributes, element, children }) => {
22
if (element.type != "references") throw Error("bug");
23
return <div {...attributes}>{children}</div>;
24
},
25
});
26
27