UNPKG

671 BJavaScriptView Raw
1'use strict';
2
3Object.defineProperty(exports, "__esModule", {
4 value: true
5});
6
7require('slate');
8
9/**
10 * Indent all lines in selection
11 */
12function indentLines(opts, change,
13// Indent to add
14indent) {
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 // Insert an indent at start of line
25 var text = line.nodes.first();
26 return c.insertTextByKey(text.key, 0, indent);
27 }, change);
28}
29exports.default = indentLines;
\No newline at end of file