Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
sagemathinc
GitHub Repository: sagemathinc/cocalc
Path: blob/master/src/packages/frontend/editors/slate/keyboard/tab.ts
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
/*
7
What happens when you hit the tab key.
8
*/
9
10
import { register } from "./register";
11
import { indentListItem, unindentListItem } from "../format/indent";
12
13
register({ key: "Tab", shift: true }, ({editor}) => {
14
if (unindentListItem(editor)) {
15
return true;
16
}
17
// for now... but maybe remove it later
18
editor.insertText(" ");
19
return true;
20
});
21
22
register({ key: "Tab" }, ({editor}) => {
23
if (indentListItem(editor)) {
24
return true;
25
}
26
27
// Markdown doesn't have a notion of tabs in text, so
28
// putting in four spaces for now, but is this optimal?
29
editor.insertText(" ");
30
return true;
31
});
32
33