1 | 'use strict';
|
2 |
|
3 | var unwrapList = require('./changes/unwrapList');
|
4 | var getCurrentItem = require('./getCurrentItem');
|
5 |
|
6 |
|
7 |
|
8 |
|
9 | function onBackspace(event, change, editor, opts) {
|
10 | var value = change.value;
|
11 | var startOffset = value.startOffset,
|
12 | selection = value.selection;
|
13 |
|
14 |
|
15 |
|
16 |
|
17 | if (selection.isExpanded) return;
|
18 |
|
19 |
|
20 | if (startOffset > 0) return;
|
21 |
|
22 | var currentItem = getCurrentItem(opts, value);
|
23 | if (!currentItem) return;
|
24 |
|
25 | if (!selection.isAtStartOf(currentItem)) return;
|
26 |
|
27 | event.preventDefault();
|
28 | return unwrapList(opts, change);
|
29 | }
|
30 |
|
31 | module.exports = onBackspace; |
\ | No newline at end of file |