1 | 'use strict';
|
2 |
|
3 | Object.defineProperty(exports, "__esModule", {
|
4 | value: true
|
5 | });
|
6 |
|
7 | require('slate');
|
8 |
|
9 |
|
10 |
|
11 |
|
12 | function dedentLines(opts, change,
|
13 | // Indent to remove
|
14 | indent) {
|
15 | var value = change.value;
|
16 | var document = value.document,
|
17 | selection = value.selection;
|
18 |
|
19 | var lines = document.getBlocksAtRange(selection).filter(function (node) {
|
20 | return node.type === opts.lineType;
|
21 | });
|
22 |
|
23 | return lines.reduce(function (c, line) {
|
24 |
|
25 | var text = line.nodes.first();
|
26 | var lengthToRemove = text.characters.takeWhile(function (char, index) {
|
27 | return indent.charAt(index) === char.text;
|
28 | }).count();
|
29 | return c.removeTextByKey(text.key, 0, lengthToRemove);
|
30 | }, change);
|
31 | }
|
32 | exports.default = dedentLines; |
\ | No newline at end of file |