1 | ;
|
2 |
|
3 | var getIndent = require('./getIndent');
|
4 |
|
5 | /**
|
6 | * User pressed Enter in an editor:
|
7 | * Insert a new code line and start it with the indentation from previous line
|
8 | */
|
9 | function onEnter(event, data, change, opts) {
|
10 | var state = change.state;
|
11 |
|
12 | if (!state.isCollapsed) {
|
13 | return;
|
14 | }
|
15 |
|
16 | event.preventDefault();
|
17 |
|
18 | var startBlock = state.startBlock;
|
19 |
|
20 | var currentLineText = startBlock.text;
|
21 | var indent = getIndent(currentLineText, '');
|
22 |
|
23 | return change.splitBlock().insertText(indent).focus();
|
24 | }
|
25 |
|
26 | module.exports = onEnter; |
\ | No newline at end of file |