1 | 'use strict';
|
2 |
|
3 | Object.defineProperty(exports, "__esModule", {
|
4 | value: true
|
5 | });
|
6 |
|
7 | require('slate');
|
8 |
|
9 | var _utils = require('../utils');
|
10 |
|
11 |
|
12 |
|
13 |
|
14 | function wrapCodeBlockByKey(opts, change, key) {
|
15 | var value = change.value;
|
16 | var document = value.document;
|
17 |
|
18 |
|
19 | var startBlock = document.getDescendant(key);
|
20 | var text = startBlock.text;
|
21 |
|
22 |
|
23 | startBlock.nodes.forEach(function (node) {
|
24 | change.removeNodeByKey(node.key, { normalize: false });
|
25 | });
|
26 |
|
27 |
|
28 | var toInsert = (0, _utils.deserializeCode)(opts, text);
|
29 |
|
30 | toInsert.nodes.forEach(function (node, i) {
|
31 | change.insertNodeByKey(startBlock.key, i, node, { normalize: false });
|
32 | });
|
33 |
|
34 |
|
35 | change.setNodeByKey(startBlock.key, {
|
36 | type: opts.containerType
|
37 | });
|
38 |
|
39 | return change;
|
40 | }
|
41 |
|
42 | exports.default = wrapCodeBlockByKey; |
\ | No newline at end of file |