1 | 'use strict';
|
2 |
|
3 | var unwrapList = require('./changes/unwrapList');
|
4 | var splitListItem = require('./changes/splitListItem');
|
5 | var decreaseItemDepth = require('./changes/decreaseItemDepth');
|
6 | var getCurrentItem = require('./getCurrentItem');
|
7 | var getItemDepth = require('./getItemDepth');
|
8 |
|
9 |
|
10 |
|
11 |
|
12 |
|
13 |
|
14 |
|
15 |
|
16 | function onEnter(event, change, editor, opts) {
|
17 |
|
18 |
|
19 | if (event.shiftKey) {
|
20 | return null;
|
21 | }
|
22 |
|
23 | var value = change.value;
|
24 |
|
25 | var currentItem = getCurrentItem(opts, value);
|
26 |
|
27 |
|
28 | if (!currentItem) {
|
29 | return null;
|
30 | }
|
31 |
|
32 | event.preventDefault();
|
33 | if (currentItem.isEmpty) {
|
34 |
|
35 | if (getItemDepth(opts, value) > 1) {
|
36 | return decreaseItemDepth(opts, change);
|
37 | } else {
|
38 |
|
39 | return unwrapList(opts, change);
|
40 | }
|
41 | } else {
|
42 |
|
43 | return splitListItem(opts, change);
|
44 | }
|
45 | }
|
46 |
|
47 | module.exports = onEnter; |
\ | No newline at end of file |