Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
sagemathinc
GitHub Repository: sagemathinc/cocalc
Path: blob/master/src/packages/frontend/editors/slate/plugins.ts
1691 views
1
export const withIsVoid = (editor) => {
2
const { isVoid } = editor;
3
4
editor.isVoid = (element) => {
5
if (element === editor) return false;
6
return element.isVoid != null ? element.isVoid : isVoid(element);
7
};
8
9
return editor;
10
};
11
12
export const withIsInline = (editor) => {
13
const { isInline } = editor;
14
15
editor.isInline = (element) => {
16
// NOTE: we can't just check that element.isInline is not null, since element could be
17
// the whole editor, which has an inline *method*, which is not null, but also not a boolean.
18
// See https://github.com/sagemathinc/cocalc/issues/6394
19
return typeof element.isInline == "boolean"
20
? element.isInline
21
: isInline(element);
22
};
23
24
return editor;
25
};
26
27