1 | 'use strict';
|
2 |
|
3 | Object.defineProperty(exports, "__esModule", {
|
4 | value: true
|
5 | });
|
6 |
|
7 | var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
|
8 |
|
9 | var _slate = require('slate');
|
10 |
|
11 | var _immutable = require('immutable');
|
12 |
|
13 | function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
14 |
|
15 | function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
|
16 |
|
17 | function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
|
18 |
|
19 | var DEFAULTS = {
|
20 | containerType: 'code_block',
|
21 | lineType: 'code_line',
|
22 | exitBlockType: 'paragraph',
|
23 | selectAll: true,
|
24 | allowMarks: false,
|
25 | getIndent: null,
|
26 | onExit: null
|
27 | };
|
28 |
|
29 |
|
30 |
|
31 |
|
32 |
|
33 | var Options = function (_Record) {
|
34 | _inherits(Options, _Record);
|
35 |
|
36 | function Options() {
|
37 | _classCallCheck(this, Options);
|
38 |
|
39 | return _possibleConstructorReturn(this, (Options.__proto__ || Object.getPrototypeOf(Options)).apply(this, arguments));
|
40 | }
|
41 |
|
42 | _createClass(Options, [{
|
43 | key: 'resolvedOnExit',
|
44 | value: function resolvedOnExit(change) {
|
45 | if (this.onExit) {
|
46 |
|
47 | return this.onExit(change);
|
48 | }
|
49 |
|
50 | var range = change.value.selection;
|
51 |
|
52 | var exitBlock = _slate.Block.create({
|
53 | type: this.exitBlockType,
|
54 | nodes: [_slate.Text.create()]
|
55 | });
|
56 |
|
57 | change.deleteAtRange(range, { normalize: false });
|
58 | change.insertBlockAtRange(change.value.selection, exitBlock, {
|
59 | normalize: false
|
60 | });
|
61 |
|
62 | change.unwrapNodeByKey(exitBlock.key);
|
63 |
|
64 | return change.collapseToStartOf(exitBlock);
|
65 | }
|
66 | }]);
|
67 |
|
68 | return Options;
|
69 | }((0, _immutable.Record)(DEFAULTS));
|
70 |
|
71 | exports.default = Options; |
\ | No newline at end of file |