UNPKG

301 kBJavaScriptView Raw
1/*!
2 * Quill Editor v1.3.3
3 * https://quilljs.com/
4 * Copyright (c) 2014, Jason Chen
5 * Copyright (c) 2013, salesforce.com
6 */
7(function webpackUniversalModuleDefinition(root, factory) {
8 if(typeof exports === 'object' && typeof module === 'object')
9 module.exports = factory();
10 else if(typeof define === 'function' && define.amd)
11 define([], factory);
12 else if(typeof exports === 'object')
13 exports["Quill"] = factory();
14 else
15 root["Quill"] = factory();
16})(this, function() {
17return /******/ (function(modules) { // webpackBootstrap
18/******/ // The module cache
19/******/ var installedModules = {};
20/******/
21/******/ // The require function
22/******/ function __webpack_require__(moduleId) {
23/******/
24/******/ // Check if module is in cache
25/******/ if(installedModules[moduleId]) {
26/******/ return installedModules[moduleId].exports;
27/******/ }
28/******/ // Create a new module (and put it into the cache)
29/******/ var module = installedModules[moduleId] = {
30/******/ i: moduleId,
31/******/ l: false,
32/******/ exports: {}
33/******/ };
34/******/
35/******/ // Execute the module function
36/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
37/******/
38/******/ // Flag the module as loaded
39/******/ module.l = true;
40/******/
41/******/ // Return the exports of the module
42/******/ return module.exports;
43/******/ }
44/******/
45/******/
46/******/ // expose the modules object (__webpack_modules__)
47/******/ __webpack_require__.m = modules;
48/******/
49/******/ // expose the module cache
50/******/ __webpack_require__.c = installedModules;
51/******/
52/******/ // define getter function for harmony exports
53/******/ __webpack_require__.d = function(exports, name, getter) {
54/******/ if(!__webpack_require__.o(exports, name)) {
55/******/ Object.defineProperty(exports, name, {
56/******/ configurable: false,
57/******/ enumerable: true,
58/******/ get: getter
59/******/ });
60/******/ }
61/******/ };
62/******/
63/******/ // getDefaultExport function for compatibility with non-harmony modules
64/******/ __webpack_require__.n = function(module) {
65/******/ var getter = module && module.__esModule ?
66/******/ function getDefault() { return module['default']; } :
67/******/ function getModuleExports() { return module; };
68/******/ __webpack_require__.d(getter, 'a', getter);
69/******/ return getter;
70/******/ };
71/******/
72/******/ // Object.prototype.hasOwnProperty.call
73/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
74/******/
75/******/ // __webpack_public_path__
76/******/ __webpack_require__.p = "";
77/******/
78/******/ // Load entry module and return exports
79/******/ return __webpack_require__(__webpack_require__.s = 110);
80/******/ })
81/************************************************************************/
82/******/ ([
83/* 0 */
84/***/ (function(module, exports, __webpack_require__) {
85
86"use strict";
87
88Object.defineProperty(exports, "__esModule", { value: true });
89var container_1 = __webpack_require__(17);
90var format_1 = __webpack_require__(18);
91var leaf_1 = __webpack_require__(19);
92var scroll_1 = __webpack_require__(45);
93var inline_1 = __webpack_require__(46);
94var block_1 = __webpack_require__(47);
95var embed_1 = __webpack_require__(48);
96var text_1 = __webpack_require__(49);
97var attributor_1 = __webpack_require__(12);
98var class_1 = __webpack_require__(32);
99var style_1 = __webpack_require__(33);
100var store_1 = __webpack_require__(31);
101var Registry = __webpack_require__(1);
102var Parchment = {
103 Scope: Registry.Scope,
104 create: Registry.create,
105 find: Registry.find,
106 query: Registry.query,
107 register: Registry.register,
108 Container: container_1.default,
109 Format: format_1.default,
110 Leaf: leaf_1.default,
111 Embed: embed_1.default,
112 Scroll: scroll_1.default,
113 Block: block_1.default,
114 Inline: inline_1.default,
115 Text: text_1.default,
116 Attributor: {
117 Attribute: attributor_1.default,
118 Class: class_1.default,
119 Style: style_1.default,
120 Store: store_1.default
121 }
122};
123exports.default = Parchment;
124
125
126/***/ }),
127/* 1 */
128/***/ (function(module, exports, __webpack_require__) {
129
130"use strict";
131
132var __extends = (this && this.__extends) || (function () {
133 var extendStatics = Object.setPrototypeOf ||
134 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
135 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
136 return function (d, b) {
137 extendStatics(d, b);
138 function __() { this.constructor = d; }
139 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
140 };
141})();
142Object.defineProperty(exports, "__esModule", { value: true });
143var ParchmentError = /** @class */ (function (_super) {
144 __extends(ParchmentError, _super);
145 function ParchmentError(message) {
146 var _this = this;
147 message = '[Parchment] ' + message;
148 _this = _super.call(this, message) || this;
149 _this.message = message;
150 _this.name = _this.constructor.name;
151 return _this;
152 }
153 return ParchmentError;
154}(Error));
155exports.ParchmentError = ParchmentError;
156var attributes = {};
157var classes = {};
158var tags = {};
159var types = {};
160exports.DATA_KEY = '__blot';
161var Scope;
162(function (Scope) {
163 Scope[Scope["TYPE"] = 3] = "TYPE";
164 Scope[Scope["LEVEL"] = 12] = "LEVEL";
165 Scope[Scope["ATTRIBUTE"] = 13] = "ATTRIBUTE";
166 Scope[Scope["BLOT"] = 14] = "BLOT";
167 Scope[Scope["INLINE"] = 7] = "INLINE";
168 Scope[Scope["BLOCK"] = 11] = "BLOCK";
169 Scope[Scope["BLOCK_BLOT"] = 10] = "BLOCK_BLOT";
170 Scope[Scope["INLINE_BLOT"] = 6] = "INLINE_BLOT";
171 Scope[Scope["BLOCK_ATTRIBUTE"] = 9] = "BLOCK_ATTRIBUTE";
172 Scope[Scope["INLINE_ATTRIBUTE"] = 5] = "INLINE_ATTRIBUTE";
173 Scope[Scope["ANY"] = 15] = "ANY";
174})(Scope = exports.Scope || (exports.Scope = {}));
175;
176function create(input, value) {
177 var match = query(input);
178 if (match == null) {
179 throw new ParchmentError("Unable to create " + input + " blot");
180 }
181 var BlotClass = match;
182 var node = (input instanceof Node || input['nodeType'] === Node.TEXT_NODE) ?
183 input :
184 BlotClass.create(value);
185 return new BlotClass(node, value);
186}
187exports.create = create;
188function find(node, bubble) {
189 if (bubble === void 0) { bubble = false; }
190 if (node == null)
191 return null;
192 if (node[exports.DATA_KEY] != null)
193 return node[exports.DATA_KEY].blot;
194 if (bubble)
195 return find(node.parentNode, bubble);
196 return null;
197}
198exports.find = find;
199function query(query, scope) {
200 if (scope === void 0) { scope = Scope.ANY; }
201 var match;
202 if (typeof query === 'string') {
203 match = types[query] || attributes[query];
204 }
205 else if (query instanceof Text || query['nodeType'] === Node.TEXT_NODE) {
206 match = types['text'];
207 }
208 else if (typeof query === 'number') {
209 if (query & Scope.LEVEL & Scope.BLOCK) {
210 match = types['block'];
211 }
212 else if (query & Scope.LEVEL & Scope.INLINE) {
213 match = types['inline'];
214 }
215 }
216 else if (query instanceof HTMLElement) {
217 var names = (query.getAttribute('class') || '').split(/\s+/);
218 for (var i in names) {
219 match = classes[names[i]];
220 if (match)
221 break;
222 }
223 match = match || tags[query.tagName];
224 }
225 if (match == null)
226 return null;
227 if ((scope & Scope.LEVEL & match.scope) && (scope & Scope.TYPE & match.scope))
228 return match;
229 return null;
230}
231exports.query = query;
232function register() {
233 var Definitions = [];
234 for (var _i = 0; _i < arguments.length; _i++) {
235 Definitions[_i] = arguments[_i];
236 }
237 if (Definitions.length > 1) {
238 return Definitions.map(function (d) {
239 return register(d);
240 });
241 }
242 var Definition = Definitions[0];
243 if (typeof Definition.blotName !== 'string' && typeof Definition.attrName !== 'string') {
244 throw new ParchmentError('Invalid definition');
245 }
246 else if (Definition.blotName === 'abstract') {
247 throw new ParchmentError('Cannot register abstract class');
248 }
249 types[Definition.blotName || Definition.attrName] = Definition;
250 if (typeof Definition.keyName === 'string') {
251 attributes[Definition.keyName] = Definition;
252 }
253 else {
254 if (Definition.className != null) {
255 classes[Definition.className] = Definition;
256 }
257 if (Definition.tagName != null) {
258 if (Array.isArray(Definition.tagName)) {
259 Definition.tagName = Definition.tagName.map(function (tagName) {
260 return tagName.toUpperCase();
261 });
262 }
263 else {
264 Definition.tagName = Definition.tagName.toUpperCase();
265 }
266 var tagNames = Array.isArray(Definition.tagName) ? Definition.tagName : [Definition.tagName];
267 tagNames.forEach(function (tag) {
268 if (tags[tag] == null || Definition.className == null) {
269 tags[tag] = Definition;
270 }
271 });
272 }
273 }
274 return Definition;
275}
276exports.register = register;
277
278
279/***/ }),
280/* 2 */
281/***/ (function(module, exports, __webpack_require__) {
282
283var diff = __webpack_require__(51);
284var equal = __webpack_require__(11);
285var extend = __webpack_require__(3);
286var op = __webpack_require__(20);
287
288
289var NULL_CHARACTER = String.fromCharCode(0); // Placeholder char for embed in diff()
290
291
292var Delta = function (ops) {
293 // Assume we are given a well formed ops
294 if (Array.isArray(ops)) {
295 this.ops = ops;
296 } else if (ops != null && Array.isArray(ops.ops)) {
297 this.ops = ops.ops;
298 } else {
299 this.ops = [];
300 }
301};
302
303
304Delta.prototype.insert = function (text, attributes) {
305 var newOp = {};
306 if (text.length === 0) return this;
307 newOp.insert = text;
308 if (attributes != null && typeof attributes === 'object' && Object.keys(attributes).length > 0) {
309 newOp.attributes = attributes;
310 }
311 return this.push(newOp);
312};
313
314Delta.prototype['delete'] = function (length) {
315 if (length <= 0) return this;
316 return this.push({ 'delete': length });
317};
318
319Delta.prototype.retain = function (length, attributes) {
320 if (length <= 0) return this;
321 var newOp = { retain: length };
322 if (attributes != null && typeof attributes === 'object' && Object.keys(attributes).length > 0) {
323 newOp.attributes = attributes;
324 }
325 return this.push(newOp);
326};
327
328Delta.prototype.push = function (newOp) {
329 var index = this.ops.length;
330 var lastOp = this.ops[index - 1];
331 newOp = extend(true, {}, newOp);
332 if (typeof lastOp === 'object') {
333 if (typeof newOp['delete'] === 'number' && typeof lastOp['delete'] === 'number') {
334 this.ops[index - 1] = { 'delete': lastOp['delete'] + newOp['delete'] };
335 return this;
336 }
337 // Since it does not matter if we insert before or after deleting at the same index,
338 // always prefer to insert first
339 if (typeof lastOp['delete'] === 'number' && newOp.insert != null) {
340 index -= 1;
341 lastOp = this.ops[index - 1];
342 if (typeof lastOp !== 'object') {
343 this.ops.unshift(newOp);
344 return this;
345 }
346 }
347 if (equal(newOp.attributes, lastOp.attributes)) {
348 if (typeof newOp.insert === 'string' && typeof lastOp.insert === 'string') {
349 this.ops[index - 1] = { insert: lastOp.insert + newOp.insert };
350 if (typeof newOp.attributes === 'object') this.ops[index - 1].attributes = newOp.attributes
351 return this;
352 } else if (typeof newOp.retain === 'number' && typeof lastOp.retain === 'number') {
353 this.ops[index - 1] = { retain: lastOp.retain + newOp.retain };
354 if (typeof newOp.attributes === 'object') this.ops[index - 1].attributes = newOp.attributes
355 return this;
356 }
357 }
358 }
359 if (index === this.ops.length) {
360 this.ops.push(newOp);
361 } else {
362 this.ops.splice(index, 0, newOp);
363 }
364 return this;
365};
366
367Delta.prototype.chop = function () {
368 var lastOp = this.ops[this.ops.length - 1];
369 if (lastOp && lastOp.retain && !lastOp.attributes) {
370 this.ops.pop();
371 }
372 return this;
373};
374
375Delta.prototype.filter = function (predicate) {
376 return this.ops.filter(predicate);
377};
378
379Delta.prototype.forEach = function (predicate) {
380 this.ops.forEach(predicate);
381};
382
383Delta.prototype.map = function (predicate) {
384 return this.ops.map(predicate);
385};
386
387Delta.prototype.partition = function (predicate) {
388 var passed = [], failed = [];
389 this.forEach(function(op) {
390 var target = predicate(op) ? passed : failed;
391 target.push(op);
392 });
393 return [passed, failed];
394};
395
396Delta.prototype.reduce = function (predicate, initial) {
397 return this.ops.reduce(predicate, initial);
398};
399
400Delta.prototype.changeLength = function () {
401 return this.reduce(function (length, elem) {
402 if (elem.insert) {
403 return length + op.length(elem);
404 } else if (elem.delete) {
405 return length - elem.delete;
406 }
407 return length;
408 }, 0);
409};
410
411Delta.prototype.length = function () {
412 return this.reduce(function (length, elem) {
413 return length + op.length(elem);
414 }, 0);
415};
416
417Delta.prototype.slice = function (start, end) {
418 start = start || 0;
419 if (typeof end !== 'number') end = Infinity;
420 var ops = [];
421 var iter = op.iterator(this.ops);
422 var index = 0;
423 while (index < end && iter.hasNext()) {
424 var nextOp;
425 if (index < start) {
426 nextOp = iter.next(start - index);
427 } else {
428 nextOp = iter.next(end - index);
429 ops.push(nextOp);
430 }
431 index += op.length(nextOp);
432 }
433 return new Delta(ops);
434};
435
436
437Delta.prototype.compose = function (other) {
438 var thisIter = op.iterator(this.ops);
439 var otherIter = op.iterator(other.ops);
440 var delta = new Delta();
441 while (thisIter.hasNext() || otherIter.hasNext()) {
442 if (otherIter.peekType() === 'insert') {
443 delta.push(otherIter.next());
444 } else if (thisIter.peekType() === 'delete') {
445 delta.push(thisIter.next());
446 } else {
447 var length = Math.min(thisIter.peekLength(), otherIter.peekLength());
448 var thisOp = thisIter.next(length);
449 var otherOp = otherIter.next(length);
450 if (typeof otherOp.retain === 'number') {
451 var newOp = {};
452 if (typeof thisOp.retain === 'number') {
453 newOp.retain = length;
454 } else {
455 newOp.insert = thisOp.insert;
456 }
457 // Preserve null when composing with a retain, otherwise remove it for inserts
458 var attributes = op.attributes.compose(thisOp.attributes, otherOp.attributes, typeof thisOp.retain === 'number');
459 if (attributes) newOp.attributes = attributes;
460 delta.push(newOp);
461 // Other op should be delete, we could be an insert or retain
462 // Insert + delete cancels out
463 } else if (typeof otherOp['delete'] === 'number' && typeof thisOp.retain === 'number') {
464 delta.push(otherOp);
465 }
466 }
467 }
468 return delta.chop();
469};
470
471Delta.prototype.concat = function (other) {
472 var delta = new Delta(this.ops.slice());
473 if (other.ops.length > 0) {
474 delta.push(other.ops[0]);
475 delta.ops = delta.ops.concat(other.ops.slice(1));
476 }
477 return delta;
478};
479
480Delta.prototype.diff = function (other, index) {
481 if (this.ops === other.ops) {
482 return new Delta();
483 }
484 var strings = [this, other].map(function (delta) {
485 return delta.map(function (op) {
486 if (op.insert != null) {
487 return typeof op.insert === 'string' ? op.insert : NULL_CHARACTER;
488 }
489 var prep = (delta === other) ? 'on' : 'with';
490 throw new Error('diff() called ' + prep + ' non-document');
491 }).join('');
492 });
493 var delta = new Delta();
494 var diffResult = diff(strings[0], strings[1], index);
495 var thisIter = op.iterator(this.ops);
496 var otherIter = op.iterator(other.ops);
497 diffResult.forEach(function (component) {
498 var length = component[1].length;
499 while (length > 0) {
500 var opLength = 0;
501 switch (component[0]) {
502 case diff.INSERT:
503 opLength = Math.min(otherIter.peekLength(), length);
504 delta.push(otherIter.next(opLength));
505 break;
506 case diff.DELETE:
507 opLength = Math.min(length, thisIter.peekLength());
508 thisIter.next(opLength);
509 delta['delete'](opLength);
510 break;
511 case diff.EQUAL:
512 opLength = Math.min(thisIter.peekLength(), otherIter.peekLength(), length);
513 var thisOp = thisIter.next(opLength);
514 var otherOp = otherIter.next(opLength);
515 if (equal(thisOp.insert, otherOp.insert)) {
516 delta.retain(opLength, op.attributes.diff(thisOp.attributes, otherOp.attributes));
517 } else {
518 delta.push(otherOp)['delete'](opLength);
519 }
520 break;
521 }
522 length -= opLength;
523 }
524 });
525 return delta.chop();
526};
527
528Delta.prototype.eachLine = function (predicate, newline) {
529 newline = newline || '\n';
530 var iter = op.iterator(this.ops);
531 var line = new Delta();
532 var i = 0;
533 while (iter.hasNext()) {
534 if (iter.peekType() !== 'insert') return;
535 var thisOp = iter.peek();
536 var start = op.length(thisOp) - iter.peekLength();
537 var index = typeof thisOp.insert === 'string' ?
538 thisOp.insert.indexOf(newline, start) - start : -1;
539 if (index < 0) {
540 line.push(iter.next());
541 } else if (index > 0) {
542 line.push(iter.next(index));
543 } else {
544 if (predicate(line, iter.next(1).attributes || {}, i) === false) {
545 return;
546 }
547 i += 1;
548 line = new Delta();
549 }
550 }
551 if (line.length() > 0) {
552 predicate(line, {}, i);
553 }
554};
555
556Delta.prototype.transform = function (other, priority) {
557 priority = !!priority;
558 if (typeof other === 'number') {
559 return this.transformPosition(other, priority);
560 }
561 var thisIter = op.iterator(this.ops);
562 var otherIter = op.iterator(other.ops);
563 var delta = new Delta();
564 while (thisIter.hasNext() || otherIter.hasNext()) {
565 if (thisIter.peekType() === 'insert' && (priority || otherIter.peekType() !== 'insert')) {
566 delta.retain(op.length(thisIter.next()));
567 } else if (otherIter.peekType() === 'insert') {
568 delta.push(otherIter.next());
569 } else {
570 var length = Math.min(thisIter.peekLength(), otherIter.peekLength());
571 var thisOp = thisIter.next(length);
572 var otherOp = otherIter.next(length);
573 if (thisOp['delete']) {
574 // Our delete either makes their delete redundant or removes their retain
575 continue;
576 } else if (otherOp['delete']) {
577 delta.push(otherOp);
578 } else {
579 // We retain either their retain or insert
580 delta.retain(length, op.attributes.transform(thisOp.attributes, otherOp.attributes, priority));
581 }
582 }
583 }
584 return delta.chop();
585};
586
587Delta.prototype.transformPosition = function (index, priority) {
588 priority = !!priority;
589 var thisIter = op.iterator(this.ops);
590 var offset = 0;
591 while (thisIter.hasNext() && offset <= index) {
592 var length = thisIter.peekLength();
593 var nextType = thisIter.peekType();
594 thisIter.next();
595 if (nextType === 'delete') {
596 index -= Math.min(length, index - offset);
597 continue;
598 } else if (nextType === 'insert' && (offset < index || !priority)) {
599 index += length;
600 }
601 offset += length;
602 }
603 return index;
604};
605
606
607module.exports = Delta;
608
609
610/***/ }),
611/* 3 */
612/***/ (function(module, exports) {
613
614'use strict';
615
616var hasOwn = Object.prototype.hasOwnProperty;
617var toStr = Object.prototype.toString;
618
619var isArray = function isArray(arr) {
620 if (typeof Array.isArray === 'function') {
621 return Array.isArray(arr);
622 }
623
624 return toStr.call(arr) === '[object Array]';
625};
626
627var isPlainObject = function isPlainObject(obj) {
628 if (!obj || toStr.call(obj) !== '[object Object]') {
629 return false;
630 }
631
632 var hasOwnConstructor = hasOwn.call(obj, 'constructor');
633 var hasIsPrototypeOf = obj.constructor && obj.constructor.prototype && hasOwn.call(obj.constructor.prototype, 'isPrototypeOf');
634 // Not own constructor property must be Object
635 if (obj.constructor && !hasOwnConstructor && !hasIsPrototypeOf) {
636 return false;
637 }
638
639 // Own properties are enumerated firstly, so to speed up,
640 // if last one is own, then all properties are own.
641 var key;
642 for (key in obj) { /**/ }
643
644 return typeof key === 'undefined' || hasOwn.call(obj, key);
645};
646
647module.exports = function extend() {
648 var options, name, src, copy, copyIsArray, clone;
649 var target = arguments[0];
650 var i = 1;
651 var length = arguments.length;
652 var deep = false;
653
654 // Handle a deep copy situation
655 if (typeof target === 'boolean') {
656 deep = target;
657 target = arguments[1] || {};
658 // skip the boolean and the target
659 i = 2;
660 }
661 if (target == null || (typeof target !== 'object' && typeof target !== 'function')) {
662 target = {};
663 }
664
665 for (; i < length; ++i) {
666 options = arguments[i];
667 // Only deal with non-null/undefined values
668 if (options != null) {
669 // Extend the base object
670 for (name in options) {
671 src = target[name];
672 copy = options[name];
673
674 // Prevent never-ending loop
675 if (target !== copy) {
676 // Recurse if we're merging plain objects or arrays
677 if (deep && copy && (isPlainObject(copy) || (copyIsArray = isArray(copy)))) {
678 if (copyIsArray) {
679 copyIsArray = false;
680 clone = src && isArray(src) ? src : [];
681 } else {
682 clone = src && isPlainObject(src) ? src : {};
683 }
684
685 // Never move original objects, clone them
686 target[name] = extend(deep, clone, copy);
687
688 // Don't bring in undefined values
689 } else if (typeof copy !== 'undefined') {
690 target[name] = copy;
691 }
692 }
693 }
694 }
695 }
696
697 // Return the modified object
698 return target;
699};
700
701
702/***/ }),
703/* 4 */
704/***/ (function(module, exports, __webpack_require__) {
705
706"use strict";
707
708
709Object.defineProperty(exports, "__esModule", {
710 value: true
711});
712exports.default = exports.BlockEmbed = exports.bubbleFormats = undefined;
713
714var _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; }; }();
715
716var _get = function get(object, property, receiver) { if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { return get(parent, property, receiver); } } else if ("value" in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } };
717
718var _extend = __webpack_require__(3);
719
720var _extend2 = _interopRequireDefault(_extend);
721
722var _quillDelta = __webpack_require__(2);
723
724var _quillDelta2 = _interopRequireDefault(_quillDelta);
725
726var _parchment = __webpack_require__(0);
727
728var _parchment2 = _interopRequireDefault(_parchment);
729
730var _break = __webpack_require__(16);
731
732var _break2 = _interopRequireDefault(_break);
733
734var _inline = __webpack_require__(6);
735
736var _inline2 = _interopRequireDefault(_inline);
737
738var _text = __webpack_require__(7);
739
740var _text2 = _interopRequireDefault(_text);
741
742function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
743
744function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
745
746function _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; }
747
748function _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; }
749
750var NEWLINE_LENGTH = 1;
751
752var BlockEmbed = function (_Parchment$Embed) {
753 _inherits(BlockEmbed, _Parchment$Embed);
754
755 function BlockEmbed() {
756 _classCallCheck(this, BlockEmbed);
757
758 return _possibleConstructorReturn(this, (BlockEmbed.__proto__ || Object.getPrototypeOf(BlockEmbed)).apply(this, arguments));
759 }
760
761 _createClass(BlockEmbed, [{
762 key: 'attach',
763 value: function attach() {
764 _get(BlockEmbed.prototype.__proto__ || Object.getPrototypeOf(BlockEmbed.prototype), 'attach', this).call(this);
765 this.attributes = new _parchment2.default.Attributor.Store(this.domNode);
766 }
767 }, {
768 key: 'delta',
769 value: function delta() {
770 return new _quillDelta2.default().insert(this.value(), (0, _extend2.default)(this.formats(), this.attributes.values()));
771 }
772 }, {
773 key: 'format',
774 value: function format(name, value) {
775 var attribute = _parchment2.default.query(name, _parchment2.default.Scope.BLOCK_ATTRIBUTE);
776 if (attribute != null) {
777 this.attributes.attribute(attribute, value);
778 }
779 }
780 }, {
781 key: 'formatAt',
782 value: function formatAt(index, length, name, value) {
783 this.format(name, value);
784 }
785 }, {
786 key: 'insertAt',
787 value: function insertAt(index, value, def) {
788 if (typeof value === 'string' && value.endsWith('\n')) {
789 var block = _parchment2.default.create(Block.blotName);
790 this.parent.insertBefore(block, index === 0 ? this : this.next);
791 block.insertAt(0, value.slice(0, -1));
792 } else {
793 _get(BlockEmbed.prototype.__proto__ || Object.getPrototypeOf(BlockEmbed.prototype), 'insertAt', this).call(this, index, value, def);
794 }
795 }
796 }]);
797
798 return BlockEmbed;
799}(_parchment2.default.Embed);
800
801BlockEmbed.scope = _parchment2.default.Scope.BLOCK_BLOT;
802// It is important for cursor behavior BlockEmbeds use tags that are block level elements
803
804
805var Block = function (_Parchment$Block) {
806 _inherits(Block, _Parchment$Block);
807
808 function Block(domNode) {
809 _classCallCheck(this, Block);
810
811 var _this2 = _possibleConstructorReturn(this, (Block.__proto__ || Object.getPrototypeOf(Block)).call(this, domNode));
812
813 _this2.cache = {};
814 return _this2;
815 }
816
817 _createClass(Block, [{
818 key: 'delta',
819 value: function delta() {
820 if (this.cache.delta == null) {
821 this.cache.delta = this.descendants(_parchment2.default.Leaf).reduce(function (delta, leaf) {
822 if (leaf.length() === 0) {
823 return delta;
824 } else {
825 return delta.insert(leaf.value(), bubbleFormats(leaf));
826 }
827 }, new _quillDelta2.default()).insert('\n', bubbleFormats(this));
828 }
829 return this.cache.delta;
830 }
831 }, {
832 key: 'deleteAt',
833 value: function deleteAt(index, length) {
834 _get(Block.prototype.__proto__ || Object.getPrototypeOf(Block.prototype), 'deleteAt', this).call(this, index, length);
835 this.cache = {};
836 }
837 }, {
838 key: 'formatAt',
839 value: function formatAt(index, length, name, value) {
840 if (length <= 0) return;
841 if (_parchment2.default.query(name, _parchment2.default.Scope.BLOCK)) {
842 if (index + length === this.length()) {
843 this.format(name, value);
844 }
845 } else {
846 _get(Block.prototype.__proto__ || Object.getPrototypeOf(Block.prototype), 'formatAt', this).call(this, index, Math.min(length, this.length() - index - 1), name, value);
847 }
848 this.cache = {};
849 }
850 }, {
851 key: 'insertAt',
852 value: function insertAt(index, value, def) {
853 if (def != null) return _get(Block.prototype.__proto__ || Object.getPrototypeOf(Block.prototype), 'insertAt', this).call(this, index, value, def);
854 if (value.length === 0) return;
855 var lines = value.split('\n');
856 var text = lines.shift();
857 if (text.length > 0) {
858 if (index < this.length() - 1 || this.children.tail == null) {
859 _get(Block.prototype.__proto__ || Object.getPrototypeOf(Block.prototype), 'insertAt', this).call(this, Math.min(index, this.length() - 1), text);
860 } else {
861 this.children.tail.insertAt(this.children.tail.length(), text);
862 }
863 this.cache = {};
864 }
865 var block = this;
866 lines.reduce(function (index, line) {
867 block = block.split(index, true);
868 block.insertAt(0, line);
869 return line.length;
870 }, index + text.length);
871 }
872 }, {
873 key: 'insertBefore',
874 value: function insertBefore(blot, ref) {
875 var head = this.children.head;
876 _get(Block.prototype.__proto__ || Object.getPrototypeOf(Block.prototype), 'insertBefore', this).call(this, blot, ref);
877 if (head instanceof _break2.default) {
878 head.remove();
879 }
880 this.cache = {};
881 }
882 }, {
883 key: 'length',
884 value: function length() {
885 if (this.cache.length == null) {
886 this.cache.length = _get(Block.prototype.__proto__ || Object.getPrototypeOf(Block.prototype), 'length', this).call(this) + NEWLINE_LENGTH;
887 }
888 return this.cache.length;
889 }
890 }, {
891 key: 'moveChildren',
892 value: function moveChildren(target, ref) {
893 _get(Block.prototype.__proto__ || Object.getPrototypeOf(Block.prototype), 'moveChildren', this).call(this, target, ref);
894 this.cache = {};
895 }
896 }, {
897 key: 'optimize',
898 value: function optimize(context) {
899 _get(Block.prototype.__proto__ || Object.getPrototypeOf(Block.prototype), 'optimize', this).call(this, context);
900 this.cache = {};
901 }
902 }, {
903 key: 'path',
904 value: function path(index) {
905 return _get(Block.prototype.__proto__ || Object.getPrototypeOf(Block.prototype), 'path', this).call(this, index, true);
906 }
907 }, {
908 key: 'removeChild',
909 value: function removeChild(child) {
910 _get(Block.prototype.__proto__ || Object.getPrototypeOf(Block.prototype), 'removeChild', this).call(this, child);
911 this.cache = {};
912 }
913 }, {
914 key: 'split',
915 value: function split(index) {
916 var force = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
917
918 if (force && (index === 0 || index >= this.length() - NEWLINE_LENGTH)) {
919 var clone = this.clone();
920 if (index === 0) {
921 this.parent.insertBefore(clone, this);
922 return this;
923 } else {
924 this.parent.insertBefore(clone, this.next);
925 return clone;
926 }
927 } else {
928 var next = _get(Block.prototype.__proto__ || Object.getPrototypeOf(Block.prototype), 'split', this).call(this, index, force);
929 this.cache = {};
930 return next;
931 }
932 }
933 }]);
934
935 return Block;
936}(_parchment2.default.Block);
937
938Block.blotName = 'block';
939Block.tagName = 'P';
940Block.defaultChild = 'break';
941Block.allowedChildren = [_inline2.default, _parchment2.default.Embed, _text2.default];
942
943function bubbleFormats(blot) {
944 var formats = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
945
946 if (blot == null) return formats;
947 if (typeof blot.formats === 'function') {
948 formats = (0, _extend2.default)(formats, blot.formats());
949 }
950 if (blot.parent == null || blot.parent.blotName == 'scroll' || blot.parent.statics.scope !== blot.statics.scope) {
951 return formats;
952 }
953 return bubbleFormats(blot.parent, formats);
954}
955
956exports.bubbleFormats = bubbleFormats;
957exports.BlockEmbed = BlockEmbed;
958exports.default = Block;
959
960/***/ }),
961/* 5 */
962/***/ (function(module, exports, __webpack_require__) {
963
964"use strict";
965
966
967Object.defineProperty(exports, "__esModule", {
968 value: true
969});
970exports.default = exports.overload = exports.expandConfig = undefined;
971
972var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
973
974var _slicedToArray = function () { function sliceIterator(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"]) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } return function (arr, i) { if (Array.isArray(arr)) { return arr; } else if (Symbol.iterator in Object(arr)) { return sliceIterator(arr, i); } else { throw new TypeError("Invalid attempt to destructure non-iterable instance"); } }; }();
975
976var _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; }; }();
977
978__webpack_require__(50);
979
980var _quillDelta = __webpack_require__(2);
981
982var _quillDelta2 = _interopRequireDefault(_quillDelta);
983
984var _editor = __webpack_require__(14);
985
986var _editor2 = _interopRequireDefault(_editor);
987
988var _emitter3 = __webpack_require__(8);
989
990var _emitter4 = _interopRequireDefault(_emitter3);
991
992var _module = __webpack_require__(9);
993
994var _module2 = _interopRequireDefault(_module);
995
996var _parchment = __webpack_require__(0);
997
998var _parchment2 = _interopRequireDefault(_parchment);
999
1000var _selection = __webpack_require__(15);
1001
1002var _selection2 = _interopRequireDefault(_selection);
1003
1004var _extend = __webpack_require__(3);
1005
1006var _extend2 = _interopRequireDefault(_extend);
1007
1008var _logger = __webpack_require__(10);
1009
1010var _logger2 = _interopRequireDefault(_logger);
1011
1012var _theme = __webpack_require__(34);
1013
1014var _theme2 = _interopRequireDefault(_theme);
1015
1016function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
1017
1018function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
1019
1020function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
1021
1022var debug = (0, _logger2.default)('quill');
1023
1024var Quill = function () {
1025 _createClass(Quill, null, [{
1026 key: 'debug',
1027 value: function debug(limit) {
1028 if (limit === true) {
1029 limit = 'log';
1030 }
1031 _logger2.default.level(limit);
1032 }
1033 }, {
1034 key: 'find',
1035 value: function find(node) {
1036 return node.__quill || _parchment2.default.find(node);
1037 }
1038 }, {
1039 key: 'import',
1040 value: function _import(name) {
1041 if (this.imports[name] == null) {
1042 debug.error('Cannot import ' + name + '. Are you sure it was registered?');
1043 }
1044 return this.imports[name];
1045 }
1046 }, {
1047 key: 'register',
1048 value: function register(path, target) {
1049 var _this = this;
1050
1051 var overwrite = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
1052
1053 if (typeof path !== 'string') {
1054 var name = path.attrName || path.blotName;
1055 if (typeof name === 'string') {
1056 // register(Blot | Attributor, overwrite)
1057 this.register('formats/' + name, path, target);
1058 } else {
1059 Object.keys(path).forEach(function (key) {
1060 _this.register(key, path[key], target);
1061 });
1062 }
1063 } else {
1064 if (this.imports[path] != null && !overwrite) {
1065 debug.warn('Overwriting ' + path + ' with', target);
1066 }
1067 this.imports[path] = target;
1068 if ((path.startsWith('blots/') || path.startsWith('formats/')) && target.blotName !== 'abstract') {
1069 _parchment2.default.register(target);
1070 } else if (path.startsWith('modules') && typeof target.register === 'function') {
1071 target.register();
1072 }
1073 }
1074 }
1075 }]);
1076
1077 function Quill(container) {
1078 var _this2 = this;
1079
1080 var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
1081
1082 _classCallCheck(this, Quill);
1083
1084 this.options = expandConfig(container, options);
1085 this.container = this.options.container;
1086 if (this.container == null) {
1087 return debug.error('Invalid Quill container', container);
1088 }
1089 if (this.options.debug) {
1090 Quill.debug(this.options.debug);
1091 }
1092 var html = this.container.innerHTML.trim();
1093 this.container.classList.add('ql-container');
1094 this.container.innerHTML = '';
1095 this.container.__quill = this;
1096 this.root = this.addContainer('ql-editor');
1097 this.root.classList.add('ql-blank');
1098 this.root.setAttribute('data-gramm', false);
1099 this.scrollingContainer = this.options.scrollingContainer || this.root;
1100 this.emitter = new _emitter4.default();
1101 this.scroll = _parchment2.default.create(this.root, {
1102 emitter: this.emitter,
1103 whitelist: this.options.formats
1104 });
1105 this.editor = new _editor2.default(this.scroll);
1106 this.selection = new _selection2.default(this.scroll, this.emitter);
1107 this.theme = new this.options.theme(this, this.options);
1108 this.keyboard = this.theme.addModule('keyboard');
1109 this.clipboard = this.theme.addModule('clipboard');
1110 this.history = this.theme.addModule('history');
1111 this.theme.init();
1112 this.emitter.on(_emitter4.default.events.EDITOR_CHANGE, function (type) {
1113 if (type === _emitter4.default.events.TEXT_CHANGE) {
1114 _this2.root.classList.toggle('ql-blank', _this2.editor.isBlank());
1115 }
1116 });
1117 this.emitter.on(_emitter4.default.events.SCROLL_UPDATE, function (source, mutations) {
1118 var range = _this2.selection.lastRange;
1119 var index = range && range.length === 0 ? range.index : undefined;
1120 modify.call(_this2, function () {
1121 return _this2.editor.update(null, mutations, index);
1122 }, source);
1123 });
1124 var contents = this.clipboard.convert('<div class=\'ql-editor\' style="white-space: normal;">' + html + '<p><br></p></div>');
1125 this.setContents(contents);
1126 this.history.clear();
1127 if (this.options.placeholder) {
1128 this.root.setAttribute('data-placeholder', this.options.placeholder);
1129 }
1130 if (this.options.readOnly) {
1131 this.disable();
1132 }
1133 }
1134
1135 _createClass(Quill, [{
1136 key: 'addContainer',
1137 value: function addContainer(container) {
1138 var refNode = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
1139
1140 if (typeof container === 'string') {
1141 var className = container;
1142 container = document.createElement('div');
1143 container.classList.add(className);
1144 }
1145 this.container.insertBefore(container, refNode);
1146 return container;
1147 }
1148 }, {
1149 key: 'blur',
1150 value: function blur() {
1151 this.selection.setRange(null);
1152 }
1153 }, {
1154 key: 'deleteText',
1155 value: function deleteText(index, length, source) {
1156 var _this3 = this;
1157
1158 var _overload = overload(index, length, source);
1159
1160 var _overload2 = _slicedToArray(_overload, 4);
1161
1162 index = _overload2[0];
1163 length = _overload2[1];
1164 source = _overload2[3];
1165
1166 return modify.call(this, function () {
1167 return _this3.editor.deleteText(index, length);
1168 }, source, index, -1 * length);
1169 }
1170 }, {
1171 key: 'disable',
1172 value: function disable() {
1173 this.enable(false);
1174 }
1175 }, {
1176 key: 'enable',
1177 value: function enable() {
1178 var enabled = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
1179
1180 this.scroll.enable(enabled);
1181 this.container.classList.toggle('ql-disabled', !enabled);
1182 }
1183 }, {
1184 key: 'focus',
1185 value: function focus() {
1186 var scrollTop = this.scrollingContainer.scrollTop;
1187 this.selection.focus();
1188 this.scrollingContainer.scrollTop = scrollTop;
1189 this.scrollIntoView();
1190 }
1191 }, {
1192 key: 'format',
1193 value: function format(name, value) {
1194 var _this4 = this;
1195
1196 var source = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : _emitter4.default.sources.API;
1197
1198 return modify.call(this, function () {
1199 var range = _this4.getSelection(true);
1200 var change = new _quillDelta2.default();
1201 if (range == null) {
1202 return change;
1203 } else if (_parchment2.default.query(name, _parchment2.default.Scope.BLOCK)) {
1204 change = _this4.editor.formatLine(range.index, range.length, _defineProperty({}, name, value));
1205 } else if (range.length === 0) {
1206 _this4.selection.format(name, value);
1207 return change;
1208 } else {
1209 change = _this4.editor.formatText(range.index, range.length, _defineProperty({}, name, value));
1210 }
1211 _this4.setSelection(range, _emitter4.default.sources.SILENT);
1212 return change;
1213 }, source);
1214 }
1215 }, {
1216 key: 'formatLine',
1217 value: function formatLine(index, length, name, value, source) {
1218 var _this5 = this;
1219
1220 var formats = void 0;
1221
1222 var _overload3 = overload(index, length, name, value, source);
1223
1224 var _overload4 = _slicedToArray(_overload3, 4);
1225
1226 index = _overload4[0];
1227 length = _overload4[1];
1228 formats = _overload4[2];
1229 source = _overload4[3];
1230
1231 return modify.call(this, function () {
1232 return _this5.editor.formatLine(index, length, formats);
1233 }, source, index, 0);
1234 }
1235 }, {
1236 key: 'formatText',
1237 value: function formatText(index, length, name, value, source) {
1238 var _this6 = this;
1239
1240 var formats = void 0;
1241
1242 var _overload5 = overload(index, length, name, value, source);
1243
1244 var _overload6 = _slicedToArray(_overload5, 4);
1245
1246 index = _overload6[0];
1247 length = _overload6[1];
1248 formats = _overload6[2];
1249 source = _overload6[3];
1250
1251 return modify.call(this, function () {
1252 return _this6.editor.formatText(index, length, formats);
1253 }, source, index, 0);
1254 }
1255 }, {
1256 key: 'getBounds',
1257 value: function getBounds(index) {
1258 var length = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
1259
1260 var bounds = void 0;
1261 if (typeof index === 'number') {
1262 bounds = this.selection.getBounds(index, length);
1263 } else {
1264 bounds = this.selection.getBounds(index.index, index.length);
1265 }
1266 var containerBounds = this.container.getBoundingClientRect();
1267 return {
1268 bottom: bounds.bottom - containerBounds.top,
1269 height: bounds.height,
1270 left: bounds.left - containerBounds.left,
1271 right: bounds.right - containerBounds.left,
1272 top: bounds.top - containerBounds.top,
1273 width: bounds.width
1274 };
1275 }
1276 }, {
1277 key: 'getContents',
1278 value: function getContents() {
1279 var index = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
1280 var length = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : this.getLength() - index;
1281
1282 var _overload7 = overload(index, length);
1283
1284 var _overload8 = _slicedToArray(_overload7, 2);
1285
1286 index = _overload8[0];
1287 length = _overload8[1];
1288
1289 return this.editor.getContents(index, length);
1290 }
1291 }, {
1292 key: 'getFormat',
1293 value: function getFormat() {
1294 var index = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : this.getSelection(true);
1295 var length = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
1296
1297 if (typeof index === 'number') {
1298 return this.editor.getFormat(index, length);
1299 } else {
1300 return this.editor.getFormat(index.index, index.length);
1301 }
1302 }
1303 }, {
1304 key: 'getIndex',
1305 value: function getIndex(blot) {
1306 return blot.offset(this.scroll);
1307 }
1308 }, {
1309 key: 'getLength',
1310 value: function getLength() {
1311 return this.scroll.length();
1312 }
1313 }, {
1314 key: 'getLeaf',
1315 value: function getLeaf(index) {
1316 return this.scroll.leaf(index);
1317 }
1318 }, {
1319 key: 'getLine',
1320 value: function getLine(index) {
1321 return this.scroll.line(index);
1322 }
1323 }, {
1324 key: 'getLines',
1325 value: function getLines() {
1326 var index = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
1327 var length = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : Number.MAX_VALUE;
1328
1329 if (typeof index !== 'number') {
1330 return this.scroll.lines(index.index, index.length);
1331 } else {
1332 return this.scroll.lines(index, length);
1333 }
1334 }
1335 }, {
1336 key: 'getModule',
1337 value: function getModule(name) {
1338 return this.theme.modules[name];
1339 }
1340 }, {
1341 key: 'getSelection',
1342 value: function getSelection() {
1343 var focus = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
1344
1345 if (focus) this.focus();
1346 this.update(); // Make sure we access getRange with editor in consistent state
1347 return this.selection.getRange()[0];
1348 }
1349 }, {
1350 key: 'getText',
1351 value: function getText() {
1352 var index = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
1353 var length = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : this.getLength() - index;
1354
1355 var _overload9 = overload(index, length);
1356
1357 var _overload10 = _slicedToArray(_overload9, 2);
1358
1359 index = _overload10[0];
1360 length = _overload10[1];
1361
1362 return this.editor.getText(index, length);
1363 }
1364 }, {
1365 key: 'hasFocus',
1366 value: function hasFocus() {
1367 return this.selection.hasFocus();
1368 }
1369 }, {
1370 key: 'insertEmbed',
1371 value: function insertEmbed(index, embed, value) {
1372 var _this7 = this;
1373
1374 var source = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : Quill.sources.API;
1375
1376 return modify.call(this, function () {
1377 return _this7.editor.insertEmbed(index, embed, value);
1378 }, source, index);
1379 }
1380 }, {
1381 key: 'insertText',
1382 value: function insertText(index, text, name, value, source) {
1383 var _this8 = this;
1384
1385 var formats = void 0;
1386
1387 var _overload11 = overload(index, 0, name, value, source);
1388
1389 var _overload12 = _slicedToArray(_overload11, 4);
1390
1391 index = _overload12[0];
1392 formats = _overload12[2];
1393 source = _overload12[3];
1394
1395 return modify.call(this, function () {
1396 return _this8.editor.insertText(index, text, formats);
1397 }, source, index, text.length);
1398 }
1399 }, {
1400 key: 'isEnabled',
1401 value: function isEnabled() {
1402 return !this.container.classList.contains('ql-disabled');
1403 }
1404 }, {
1405 key: 'off',
1406 value: function off() {
1407 return this.emitter.off.apply(this.emitter, arguments);
1408 }
1409 }, {
1410 key: 'on',
1411 value: function on() {
1412 return this.emitter.on.apply(this.emitter, arguments);
1413 }
1414 }, {
1415 key: 'once',
1416 value: function once() {
1417 return this.emitter.once.apply(this.emitter, arguments);
1418 }
1419 }, {
1420 key: 'pasteHTML',
1421 value: function pasteHTML(index, html, source) {
1422 this.clipboard.dangerouslyPasteHTML(index, html, source);
1423 }
1424 }, {
1425 key: 'removeFormat',
1426 value: function removeFormat(index, length, source) {
1427 var _this9 = this;
1428
1429 var _overload13 = overload(index, length, source);
1430
1431 var _overload14 = _slicedToArray(_overload13, 4);
1432
1433 index = _overload14[0];
1434 length = _overload14[1];
1435 source = _overload14[3];
1436
1437 return modify.call(this, function () {
1438 return _this9.editor.removeFormat(index, length);
1439 }, source, index);
1440 }
1441 }, {
1442 key: 'scrollIntoView',
1443 value: function scrollIntoView() {
1444 this.selection.scrollIntoView(this.scrollingContainer);
1445 }
1446 }, {
1447 key: 'setContents',
1448 value: function setContents(delta) {
1449 var _this10 = this;
1450
1451 var source = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : _emitter4.default.sources.API;
1452
1453 return modify.call(this, function () {
1454 delta = new _quillDelta2.default(delta);
1455 var length = _this10.getLength();
1456 var deleted = _this10.editor.deleteText(0, length);
1457 var applied = _this10.editor.applyDelta(delta);
1458 var lastOp = applied.ops[applied.ops.length - 1];
1459 if (lastOp != null && typeof lastOp.insert === 'string' && lastOp.insert[lastOp.insert.length - 1] === '\n') {
1460 _this10.editor.deleteText(_this10.getLength() - 1, 1);
1461 applied.delete(1);
1462 }
1463 var ret = deleted.compose(applied);
1464 return ret;
1465 }, source);
1466 }
1467 }, {
1468 key: 'setSelection',
1469 value: function setSelection(index, length, source) {
1470 if (index == null) {
1471 this.selection.setRange(null, length || Quill.sources.API);
1472 } else {
1473 var _overload15 = overload(index, length, source);
1474
1475 var _overload16 = _slicedToArray(_overload15, 4);
1476
1477 index = _overload16[0];
1478 length = _overload16[1];
1479 source = _overload16[3];
1480
1481 this.selection.setRange(new _selection.Range(index, length), source);
1482 if (source !== _emitter4.default.sources.SILENT) {
1483 this.selection.scrollIntoView(this.scrollingContainer);
1484 }
1485 }
1486 }
1487 }, {
1488 key: 'setText',
1489 value: function setText(text) {
1490 var source = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : _emitter4.default.sources.API;
1491
1492 var delta = new _quillDelta2.default().insert(text);
1493 return this.setContents(delta, source);
1494 }
1495 }, {
1496 key: 'update',
1497 value: function update() {
1498 var source = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : _emitter4.default.sources.USER;
1499
1500 var change = this.scroll.update(source); // Will update selection before selection.update() does if text changes
1501 this.selection.update(source);
1502 return change;
1503 }
1504 }, {
1505 key: 'updateContents',
1506 value: function updateContents(delta) {
1507 var _this11 = this;
1508
1509 var source = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : _emitter4.default.sources.API;
1510
1511 return modify.call(this, function () {
1512 delta = new _quillDelta2.default(delta);
1513 return _this11.editor.applyDelta(delta, source);
1514 }, source, true);
1515 }
1516 }]);
1517
1518 return Quill;
1519}();
1520
1521Quill.DEFAULTS = {
1522 bounds: null,
1523 formats: null,
1524 modules: {},
1525 placeholder: '',
1526 readOnly: false,
1527 scrollingContainer: null,
1528 strict: true,
1529 theme: 'default'
1530};
1531Quill.events = _emitter4.default.events;
1532Quill.sources = _emitter4.default.sources;
1533// eslint-disable-next-line no-undef
1534Quill.version = false ? 'dev' : "1.3.3";
1535
1536Quill.imports = {
1537 'delta': _quillDelta2.default,
1538 'parchment': _parchment2.default,
1539 'core/module': _module2.default,
1540 'core/theme': _theme2.default
1541};
1542
1543function expandConfig(container, userConfig) {
1544 userConfig = (0, _extend2.default)(true, {
1545 container: container,
1546 modules: {
1547 clipboard: true,
1548 keyboard: true,
1549 history: true
1550 }
1551 }, userConfig);
1552 if (!userConfig.theme || userConfig.theme === Quill.DEFAULTS.theme) {
1553 userConfig.theme = _theme2.default;
1554 } else {
1555 userConfig.theme = Quill.import('themes/' + userConfig.theme);
1556 if (userConfig.theme == null) {
1557 throw new Error('Invalid theme ' + userConfig.theme + '. Did you register it?');
1558 }
1559 }
1560 var themeConfig = (0, _extend2.default)(true, {}, userConfig.theme.DEFAULTS);
1561 [themeConfig, userConfig].forEach(function (config) {
1562 config.modules = config.modules || {};
1563 Object.keys(config.modules).forEach(function (module) {
1564 if (config.modules[module] === true) {
1565 config.modules[module] = {};
1566 }
1567 });
1568 });
1569 var moduleNames = Object.keys(themeConfig.modules).concat(Object.keys(userConfig.modules));
1570 var moduleConfig = moduleNames.reduce(function (config, name) {
1571 var moduleClass = Quill.import('modules/' + name);
1572 if (moduleClass == null) {
1573 debug.error('Cannot load ' + name + ' module. Are you sure you registered it?');
1574 } else {
1575 config[name] = moduleClass.DEFAULTS || {};
1576 }
1577 return config;
1578 }, {});
1579 // Special case toolbar shorthand
1580 if (userConfig.modules != null && userConfig.modules.toolbar && userConfig.modules.toolbar.constructor !== Object) {
1581 userConfig.modules.toolbar = {
1582 container: userConfig.modules.toolbar
1583 };
1584 }
1585 userConfig = (0, _extend2.default)(true, {}, Quill.DEFAULTS, { modules: moduleConfig }, themeConfig, userConfig);
1586 ['bounds', 'container', 'scrollingContainer'].forEach(function (key) {
1587 if (typeof userConfig[key] === 'string') {
1588 userConfig[key] = document.querySelector(userConfig[key]);
1589 }
1590 });
1591 userConfig.modules = Object.keys(userConfig.modules).reduce(function (config, name) {
1592 if (userConfig.modules[name]) {
1593 config[name] = userConfig.modules[name];
1594 }
1595 return config;
1596 }, {});
1597 return userConfig;
1598}
1599
1600// Handle selection preservation and TEXT_CHANGE emission
1601// common to modification APIs
1602function modify(modifier, source, index, shift) {
1603 if (this.options.strict && !this.isEnabled() && source === _emitter4.default.sources.USER) {
1604 return new _quillDelta2.default();
1605 }
1606 var range = index == null ? null : this.getSelection();
1607 var oldDelta = this.editor.delta;
1608 var change = modifier();
1609 if (range != null) {
1610 if (index === true) index = range.index;
1611 if (shift == null) {
1612 range = shiftRange(range, change, source);
1613 } else if (shift !== 0) {
1614 range = shiftRange(range, index, shift, source);
1615 }
1616 this.setSelection(range, _emitter4.default.sources.SILENT);
1617 }
1618 if (change.length() > 0) {
1619 var _emitter;
1620
1621 var args = [_emitter4.default.events.TEXT_CHANGE, change, oldDelta, source];
1622 (_emitter = this.emitter).emit.apply(_emitter, [_emitter4.default.events.EDITOR_CHANGE].concat(args));
1623 if (source !== _emitter4.default.sources.SILENT) {
1624 var _emitter2;
1625
1626 (_emitter2 = this.emitter).emit.apply(_emitter2, args);
1627 }
1628 }
1629 return change;
1630}
1631
1632function overload(index, length, name, value, source) {
1633 var formats = {};
1634 if (typeof index.index === 'number' && typeof index.length === 'number') {
1635 // Allow for throwaway end (used by insertText/insertEmbed)
1636 if (typeof length !== 'number') {
1637 source = value, value = name, name = length, length = index.length, index = index.index;
1638 } else {
1639 length = index.length, index = index.index;
1640 }
1641 } else if (typeof length !== 'number') {
1642 source = value, value = name, name = length, length = 0;
1643 }
1644 // Handle format being object, two format name/value strings or excluded
1645 if ((typeof name === 'undefined' ? 'undefined' : _typeof(name)) === 'object') {
1646 formats = name;
1647 source = value;
1648 } else if (typeof name === 'string') {
1649 if (value != null) {
1650 formats[name] = value;
1651 } else {
1652 source = name;
1653 }
1654 }
1655 // Handle optional source
1656 source = source || _emitter4.default.sources.API;
1657 return [index, length, formats, source];
1658}
1659
1660function shiftRange(range, index, length, source) {
1661 if (range == null) return null;
1662 var start = void 0,
1663 end = void 0;
1664 if (index instanceof _quillDelta2.default) {
1665 var _map = [range.index, range.index + range.length].map(function (pos) {
1666 return index.transformPosition(pos, source !== _emitter4.default.sources.USER);
1667 });
1668
1669 var _map2 = _slicedToArray(_map, 2);
1670
1671 start = _map2[0];
1672 end = _map2[1];
1673 } else {
1674 var _map3 = [range.index, range.index + range.length].map(function (pos) {
1675 if (pos < index || pos === index && source === _emitter4.default.sources.USER) return pos;
1676 if (length >= 0) {
1677 return pos + length;
1678 } else {
1679 return Math.max(index, pos + length);
1680 }
1681 });
1682
1683 var _map4 = _slicedToArray(_map3, 2);
1684
1685 start = _map4[0];
1686 end = _map4[1];
1687 }
1688 return new _selection.Range(start, end - start);
1689}
1690
1691exports.expandConfig = expandConfig;
1692exports.overload = overload;
1693exports.default = Quill;
1694
1695/***/ }),
1696/* 6 */
1697/***/ (function(module, exports, __webpack_require__) {
1698
1699"use strict";
1700
1701
1702Object.defineProperty(exports, "__esModule", {
1703 value: true
1704});
1705
1706var _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; }; }();
1707
1708var _get = function get(object, property, receiver) { if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { return get(parent, property, receiver); } } else if ("value" in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } };
1709
1710var _text = __webpack_require__(7);
1711
1712var _text2 = _interopRequireDefault(_text);
1713
1714var _parchment = __webpack_require__(0);
1715
1716var _parchment2 = _interopRequireDefault(_parchment);
1717
1718function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
1719
1720function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
1721
1722function _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; }
1723
1724function _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; }
1725
1726var Inline = function (_Parchment$Inline) {
1727 _inherits(Inline, _Parchment$Inline);
1728
1729 function Inline() {
1730 _classCallCheck(this, Inline);
1731
1732 return _possibleConstructorReturn(this, (Inline.__proto__ || Object.getPrototypeOf(Inline)).apply(this, arguments));
1733 }
1734
1735 _createClass(Inline, [{
1736 key: 'formatAt',
1737 value: function formatAt(index, length, name, value) {
1738 if (Inline.compare(this.statics.blotName, name) < 0 && _parchment2.default.query(name, _parchment2.default.Scope.BLOT)) {
1739 var blot = this.isolate(index, length);
1740 if (value) {
1741 blot.wrap(name, value);
1742 }
1743 } else {
1744 _get(Inline.prototype.__proto__ || Object.getPrototypeOf(Inline.prototype), 'formatAt', this).call(this, index, length, name, value);
1745 }
1746 }
1747 }, {
1748 key: 'optimize',
1749 value: function optimize(context) {
1750 _get(Inline.prototype.__proto__ || Object.getPrototypeOf(Inline.prototype), 'optimize', this).call(this, context);
1751 if (this.parent instanceof Inline && Inline.compare(this.statics.blotName, this.parent.statics.blotName) > 0) {
1752 var parent = this.parent.isolate(this.offset(), this.length());
1753 this.moveChildren(parent);
1754 parent.wrap(this);
1755 }
1756 }
1757 }], [{
1758 key: 'compare',
1759 value: function compare(self, other) {
1760 var selfIndex = Inline.order.indexOf(self);
1761 var otherIndex = Inline.order.indexOf(other);
1762 if (selfIndex >= 0 || otherIndex >= 0) {
1763 return selfIndex - otherIndex;
1764 } else if (self === other) {
1765 return 0;
1766 } else if (self < other) {
1767 return -1;
1768 } else {
1769 return 1;
1770 }
1771 }
1772 }]);
1773
1774 return Inline;
1775}(_parchment2.default.Inline);
1776
1777Inline.allowedChildren = [Inline, _parchment2.default.Embed, _text2.default];
1778// Lower index means deeper in the DOM tree, since not found (-1) is for embeds
1779Inline.order = ['cursor', 'inline', // Must be lower
1780'underline', 'strike', 'italic', 'bold', 'script', 'link', 'code' // Must be higher
1781];
1782
1783exports.default = Inline;
1784
1785/***/ }),
1786/* 7 */
1787/***/ (function(module, exports, __webpack_require__) {
1788
1789"use strict";
1790
1791
1792Object.defineProperty(exports, "__esModule", {
1793 value: true
1794});
1795
1796var _parchment = __webpack_require__(0);
1797
1798var _parchment2 = _interopRequireDefault(_parchment);
1799
1800function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
1801
1802function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
1803
1804function _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; }
1805
1806function _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; }
1807
1808var TextBlot = function (_Parchment$Text) {
1809 _inherits(TextBlot, _Parchment$Text);
1810
1811 function TextBlot() {
1812 _classCallCheck(this, TextBlot);
1813
1814 return _possibleConstructorReturn(this, (TextBlot.__proto__ || Object.getPrototypeOf(TextBlot)).apply(this, arguments));
1815 }
1816
1817 return TextBlot;
1818}(_parchment2.default.Text);
1819
1820exports.default = TextBlot;
1821
1822/***/ }),
1823/* 8 */
1824/***/ (function(module, exports, __webpack_require__) {
1825
1826"use strict";
1827
1828
1829Object.defineProperty(exports, "__esModule", {
1830 value: true
1831});
1832
1833var _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; }; }();
1834
1835var _get = function get(object, property, receiver) { if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { return get(parent, property, receiver); } } else if ("value" in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } };
1836
1837var _eventemitter = __webpack_require__(54);
1838
1839var _eventemitter2 = _interopRequireDefault(_eventemitter);
1840
1841var _logger = __webpack_require__(10);
1842
1843var _logger2 = _interopRequireDefault(_logger);
1844
1845function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
1846
1847function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
1848
1849function _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; }
1850
1851function _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; }
1852
1853var debug = (0, _logger2.default)('quill:events');
1854
1855var EVENTS = ['selectionchange', 'mousedown', 'mouseup'];
1856
1857EVENTS.forEach(function (eventName) {
1858 document.addEventListener(eventName, function () {
1859 for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {
1860 args[_key] = arguments[_key];
1861 }
1862
1863 [].slice.call(document.querySelectorAll('.ql-container')).forEach(function (node) {
1864 // TODO use WeakMap
1865 if (node.__quill && node.__quill.emitter) {
1866 var _node$__quill$emitter;
1867
1868 (_node$__quill$emitter = node.__quill.emitter).handleDOM.apply(_node$__quill$emitter, args);
1869 }
1870 });
1871 });
1872});
1873
1874var Emitter = function (_EventEmitter) {
1875 _inherits(Emitter, _EventEmitter);
1876
1877 function Emitter() {
1878 _classCallCheck(this, Emitter);
1879
1880 var _this = _possibleConstructorReturn(this, (Emitter.__proto__ || Object.getPrototypeOf(Emitter)).call(this));
1881
1882 _this.listeners = {};
1883 _this.on('error', debug.error);
1884 return _this;
1885 }
1886
1887 _createClass(Emitter, [{
1888 key: 'emit',
1889 value: function emit() {
1890 debug.log.apply(debug, arguments);
1891 _get(Emitter.prototype.__proto__ || Object.getPrototypeOf(Emitter.prototype), 'emit', this).apply(this, arguments);
1892 }
1893 }, {
1894 key: 'handleDOM',
1895 value: function handleDOM(event) {
1896 for (var _len2 = arguments.length, args = Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
1897 args[_key2 - 1] = arguments[_key2];
1898 }
1899
1900 (this.listeners[event.type] || []).forEach(function (_ref) {
1901 var node = _ref.node,
1902 handler = _ref.handler;
1903
1904 if (event.target === node || node.contains(event.target)) {
1905 handler.apply(undefined, [event].concat(args));
1906 }
1907 });
1908 }
1909 }, {
1910 key: 'listenDOM',
1911 value: function listenDOM(eventName, node, handler) {
1912 if (!this.listeners[eventName]) {
1913 this.listeners[eventName] = [];
1914 }
1915 this.listeners[eventName].push({ node: node, handler: handler });
1916 }
1917 }]);
1918
1919 return Emitter;
1920}(_eventemitter2.default);
1921
1922Emitter.events = {
1923 EDITOR_CHANGE: 'editor-change',
1924 SCROLL_BEFORE_UPDATE: 'scroll-before-update',
1925 SCROLL_OPTIMIZE: 'scroll-optimize',
1926 SCROLL_UPDATE: 'scroll-update',
1927 SELECTION_CHANGE: 'selection-change',
1928 TEXT_CHANGE: 'text-change'
1929};
1930Emitter.sources = {
1931 API: 'api',
1932 SILENT: 'silent',
1933 USER: 'user'
1934};
1935
1936exports.default = Emitter;
1937
1938/***/ }),
1939/* 9 */
1940/***/ (function(module, exports, __webpack_require__) {
1941
1942"use strict";
1943
1944
1945Object.defineProperty(exports, "__esModule", {
1946 value: true
1947});
1948
1949function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
1950
1951var Module = function Module(quill) {
1952 var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
1953
1954 _classCallCheck(this, Module);
1955
1956 this.quill = quill;
1957 this.options = options;
1958};
1959
1960Module.DEFAULTS = {};
1961
1962exports.default = Module;
1963
1964/***/ }),
1965/* 10 */
1966/***/ (function(module, exports, __webpack_require__) {
1967
1968"use strict";
1969
1970
1971Object.defineProperty(exports, "__esModule", {
1972 value: true
1973});
1974var levels = ['error', 'warn', 'log', 'info'];
1975var level = 'warn';
1976
1977function debug(method) {
1978 if (levels.indexOf(method) <= levels.indexOf(level)) {
1979 var _console;
1980
1981 for (var _len = arguments.length, args = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
1982 args[_key - 1] = arguments[_key];
1983 }
1984
1985 (_console = console)[method].apply(_console, args); // eslint-disable-line no-console
1986 }
1987}
1988
1989function namespace(ns) {
1990 return levels.reduce(function (logger, method) {
1991 logger[method] = debug.bind(console, method, ns);
1992 return logger;
1993 }, {});
1994}
1995
1996debug.level = namespace.level = function (newLevel) {
1997 level = newLevel;
1998};
1999
2000exports.default = namespace;
2001
2002/***/ }),
2003/* 11 */
2004/***/ (function(module, exports, __webpack_require__) {
2005
2006var pSlice = Array.prototype.slice;
2007var objectKeys = __webpack_require__(52);
2008var isArguments = __webpack_require__(53);
2009
2010var deepEqual = module.exports = function (actual, expected, opts) {
2011 if (!opts) opts = {};
2012 // 7.1. All identical values are equivalent, as determined by ===.
2013 if (actual === expected) {
2014 return true;
2015
2016 } else if (actual instanceof Date && expected instanceof Date) {
2017 return actual.getTime() === expected.getTime();
2018
2019 // 7.3. Other pairs that do not both pass typeof value == 'object',
2020 // equivalence is determined by ==.
2021 } else if (!actual || !expected || typeof actual != 'object' && typeof expected != 'object') {
2022 return opts.strict ? actual === expected : actual == expected;
2023
2024 // 7.4. For all other Object pairs, including Array objects, equivalence is
2025 // determined by having the same number of owned properties (as verified
2026 // with Object.prototype.hasOwnProperty.call), the same set of keys
2027 // (although not necessarily the same order), equivalent values for every
2028 // corresponding key, and an identical 'prototype' property. Note: this
2029 // accounts for both named and indexed properties on Arrays.
2030 } else {
2031 return objEquiv(actual, expected, opts);
2032 }
2033}
2034
2035function isUndefinedOrNull(value) {
2036 return value === null || value === undefined;
2037}
2038
2039function isBuffer (x) {
2040 if (!x || typeof x !== 'object' || typeof x.length !== 'number') return false;
2041 if (typeof x.copy !== 'function' || typeof x.slice !== 'function') {
2042 return false;
2043 }
2044 if (x.length > 0 && typeof x[0] !== 'number') return false;
2045 return true;
2046}
2047
2048function objEquiv(a, b, opts) {
2049 var i, key;
2050 if (isUndefinedOrNull(a) || isUndefinedOrNull(b))
2051 return false;
2052 // an identical 'prototype' property.
2053 if (a.prototype !== b.prototype) return false;
2054 //~~~I've managed to break Object.keys through screwy arguments passing.
2055 // Converting to array solves the problem.
2056 if (isArguments(a)) {
2057 if (!isArguments(b)) {
2058 return false;
2059 }
2060 a = pSlice.call(a);
2061 b = pSlice.call(b);
2062 return deepEqual(a, b, opts);
2063 }
2064 if (isBuffer(a)) {
2065 if (!isBuffer(b)) {
2066 return false;
2067 }
2068 if (a.length !== b.length) return false;
2069 for (i = 0; i < a.length; i++) {
2070 if (a[i] !== b[i]) return false;
2071 }
2072 return true;
2073 }
2074 try {
2075 var ka = objectKeys(a),
2076 kb = objectKeys(b);
2077 } catch (e) {//happens when one is a string literal and the other isn't
2078 return false;
2079 }
2080 // having the same number of owned properties (keys incorporates
2081 // hasOwnProperty)
2082 if (ka.length != kb.length)
2083 return false;
2084 //the same set of keys (although not necessarily the same order),
2085 ka.sort();
2086 kb.sort();
2087 //~~~cheap key test
2088 for (i = ka.length - 1; i >= 0; i--) {
2089 if (ka[i] != kb[i])
2090 return false;
2091 }
2092 //equivalent values for every corresponding key, and
2093 //~~~possibly expensive deep test
2094 for (i = ka.length - 1; i >= 0; i--) {
2095 key = ka[i];
2096 if (!deepEqual(a[key], b[key], opts)) return false;
2097 }
2098 return typeof a === typeof b;
2099}
2100
2101
2102/***/ }),
2103/* 12 */
2104/***/ (function(module, exports, __webpack_require__) {
2105
2106"use strict";
2107
2108Object.defineProperty(exports, "__esModule", { value: true });
2109var Registry = __webpack_require__(1);
2110var Attributor = /** @class */ (function () {
2111 function Attributor(attrName, keyName, options) {
2112 if (options === void 0) { options = {}; }
2113 this.attrName = attrName;
2114 this.keyName = keyName;
2115 var attributeBit = Registry.Scope.TYPE & Registry.Scope.ATTRIBUTE;
2116 if (options.scope != null) {
2117 // Ignore type bits, force attribute bit
2118 this.scope = (options.scope & Registry.Scope.LEVEL) | attributeBit;
2119 }
2120 else {
2121 this.scope = Registry.Scope.ATTRIBUTE;
2122 }
2123 if (options.whitelist != null)
2124 this.whitelist = options.whitelist;
2125 }
2126 Attributor.keys = function (node) {
2127 return [].map.call(node.attributes, function (item) {
2128 return item.name;
2129 });
2130 };
2131 Attributor.prototype.add = function (node, value) {
2132 if (!this.canAdd(node, value))
2133 return false;
2134 node.setAttribute(this.keyName, value);
2135 return true;
2136 };
2137 Attributor.prototype.canAdd = function (node, value) {
2138 var match = Registry.query(node, Registry.Scope.BLOT & (this.scope | Registry.Scope.TYPE));
2139 if (match != null && (this.whitelist == null || this.whitelist.indexOf(value) > -1)) {
2140 return true;
2141 }
2142 return false;
2143 };
2144 Attributor.prototype.remove = function (node) {
2145 node.removeAttribute(this.keyName);
2146 };
2147 Attributor.prototype.value = function (node) {
2148 var value = node.getAttribute(this.keyName);
2149 return this.canAdd(node, value) ? value : '';
2150 };
2151 return Attributor;
2152}());
2153exports.default = Attributor;
2154
2155
2156/***/ }),
2157/* 13 */
2158/***/ (function(module, exports, __webpack_require__) {
2159
2160"use strict";
2161
2162
2163Object.defineProperty(exports, "__esModule", {
2164 value: true
2165});
2166exports.default = exports.Code = undefined;
2167
2168var _slicedToArray = function () { function sliceIterator(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"]) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } return function (arr, i) { if (Array.isArray(arr)) { return arr; } else if (Symbol.iterator in Object(arr)) { return sliceIterator(arr, i); } else { throw new TypeError("Invalid attempt to destructure non-iterable instance"); } }; }();
2169
2170var _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; }; }();
2171
2172var _get = function get(object, property, receiver) { if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { return get(parent, property, receiver); } } else if ("value" in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } };
2173
2174var _quillDelta = __webpack_require__(2);
2175
2176var _quillDelta2 = _interopRequireDefault(_quillDelta);
2177
2178var _parchment = __webpack_require__(0);
2179
2180var _parchment2 = _interopRequireDefault(_parchment);
2181
2182var _block = __webpack_require__(4);
2183
2184var _block2 = _interopRequireDefault(_block);
2185
2186var _inline = __webpack_require__(6);
2187
2188var _inline2 = _interopRequireDefault(_inline);
2189
2190var _text = __webpack_require__(7);
2191
2192var _text2 = _interopRequireDefault(_text);
2193
2194function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
2195
2196function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
2197
2198function _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; }
2199
2200function _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; }
2201
2202var Code = function (_Inline) {
2203 _inherits(Code, _Inline);
2204
2205 function Code() {
2206 _classCallCheck(this, Code);
2207
2208 return _possibleConstructorReturn(this, (Code.__proto__ || Object.getPrototypeOf(Code)).apply(this, arguments));
2209 }
2210
2211 return Code;
2212}(_inline2.default);
2213
2214Code.blotName = 'code';
2215Code.tagName = 'CODE';
2216
2217var CodeBlock = function (_Block) {
2218 _inherits(CodeBlock, _Block);
2219
2220 function CodeBlock() {
2221 _classCallCheck(this, CodeBlock);
2222
2223 return _possibleConstructorReturn(this, (CodeBlock.__proto__ || Object.getPrototypeOf(CodeBlock)).apply(this, arguments));
2224 }
2225
2226 _createClass(CodeBlock, [{
2227 key: 'delta',
2228 value: function delta() {
2229 var _this3 = this;
2230
2231 var text = this.domNode.textContent;
2232 if (text.endsWith('\n')) {
2233 // Should always be true
2234 text = text.slice(0, -1);
2235 }
2236 return text.split('\n').reduce(function (delta, frag) {
2237 return delta.insert(frag).insert('\n', _this3.formats());
2238 }, new _quillDelta2.default());
2239 }
2240 }, {
2241 key: 'format',
2242 value: function format(name, value) {
2243 if (name === this.statics.blotName && value) return;
2244
2245 var _descendant = this.descendant(_text2.default, this.length() - 1),
2246 _descendant2 = _slicedToArray(_descendant, 1),
2247 text = _descendant2[0];
2248
2249 if (text != null) {
2250 text.deleteAt(text.length() - 1, 1);
2251 }
2252 _get(CodeBlock.prototype.__proto__ || Object.getPrototypeOf(CodeBlock.prototype), 'format', this).call(this, name, value);
2253 }
2254 }, {
2255 key: 'formatAt',
2256 value: function formatAt(index, length, name, value) {
2257 if (length === 0) return;
2258 if (_parchment2.default.query(name, _parchment2.default.Scope.BLOCK) == null || name === this.statics.blotName && value === this.statics.formats(this.domNode)) {
2259 return;
2260 }
2261 var nextNewline = this.newlineIndex(index);
2262 if (nextNewline < 0 || nextNewline >= index + length) return;
2263 var prevNewline = this.newlineIndex(index, true) + 1;
2264 var isolateLength = nextNewline - prevNewline + 1;
2265 var blot = this.isolate(prevNewline, isolateLength);
2266 var next = blot.next;
2267 blot.format(name, value);
2268 if (next instanceof CodeBlock) {
2269 next.formatAt(0, index - prevNewline + length - isolateLength, name, value);
2270 }
2271 }
2272 }, {
2273 key: 'insertAt',
2274 value: function insertAt(index, value, def) {
2275 if (def != null) return;
2276
2277 var _descendant3 = this.descendant(_text2.default, index),
2278 _descendant4 = _slicedToArray(_descendant3, 2),
2279 text = _descendant4[0],
2280 offset = _descendant4[1];
2281
2282 text.insertAt(offset, value);
2283 }
2284 }, {
2285 key: 'length',
2286 value: function length() {
2287 var length = this.domNode.textContent.length;
2288 if (!this.domNode.textContent.endsWith('\n')) {
2289 return length + 1;
2290 }
2291 return length;
2292 }
2293 }, {
2294 key: 'newlineIndex',
2295 value: function newlineIndex(searchIndex) {
2296 var reverse = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
2297
2298 if (!reverse) {
2299 var offset = this.domNode.textContent.slice(searchIndex).indexOf('\n');
2300 return offset > -1 ? searchIndex + offset : -1;
2301 } else {
2302 return this.domNode.textContent.slice(0, searchIndex).lastIndexOf('\n');
2303 }
2304 }
2305 }, {
2306 key: 'optimize',
2307 value: function optimize(context) {
2308 if (!this.domNode.textContent.endsWith('\n')) {
2309 this.appendChild(_parchment2.default.create('text', '\n'));
2310 }
2311 _get(CodeBlock.prototype.__proto__ || Object.getPrototypeOf(CodeBlock.prototype), 'optimize', this).call(this, context);
2312 var next = this.next;
2313 if (next != null && next.prev === this && next.statics.blotName === this.statics.blotName && this.statics.formats(this.domNode) === next.statics.formats(next.domNode)) {
2314 next.optimize(context);
2315 next.moveChildren(this);
2316 next.remove();
2317 }
2318 }
2319 }, {
2320 key: 'replace',
2321 value: function replace(target) {
2322 _get(CodeBlock.prototype.__proto__ || Object.getPrototypeOf(CodeBlock.prototype), 'replace', this).call(this, target);
2323 [].slice.call(this.domNode.querySelectorAll('*')).forEach(function (node) {
2324 var blot = _parchment2.default.find(node);
2325 if (blot == null) {
2326 node.parentNode.removeChild(node);
2327 } else if (blot instanceof _parchment2.default.Embed) {
2328 blot.remove();
2329 } else {
2330 blot.unwrap();
2331 }
2332 });
2333 }
2334 }], [{
2335 key: 'create',
2336 value: function create(value) {
2337 var domNode = _get(CodeBlock.__proto__ || Object.getPrototypeOf(CodeBlock), 'create', this).call(this, value);
2338 domNode.setAttribute('spellcheck', false);
2339 return domNode;
2340 }
2341 }, {
2342 key: 'formats',
2343 value: function formats() {
2344 return true;
2345 }
2346 }]);
2347
2348 return CodeBlock;
2349}(_block2.default);
2350
2351CodeBlock.blotName = 'code-block';
2352CodeBlock.tagName = 'PRE';
2353CodeBlock.TAB = ' ';
2354
2355exports.Code = Code;
2356exports.default = CodeBlock;
2357
2358/***/ }),
2359/* 14 */
2360/***/ (function(module, exports, __webpack_require__) {
2361
2362"use strict";
2363
2364
2365Object.defineProperty(exports, "__esModule", {
2366 value: true
2367});
2368
2369var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
2370
2371var _slicedToArray = function () { function sliceIterator(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"]) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } return function (arr, i) { if (Array.isArray(arr)) { return arr; } else if (Symbol.iterator in Object(arr)) { return sliceIterator(arr, i); } else { throw new TypeError("Invalid attempt to destructure non-iterable instance"); } }; }();
2372
2373var _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; }; }();
2374
2375var _quillDelta = __webpack_require__(2);
2376
2377var _quillDelta2 = _interopRequireDefault(_quillDelta);
2378
2379var _op = __webpack_require__(20);
2380
2381var _op2 = _interopRequireDefault(_op);
2382
2383var _parchment = __webpack_require__(0);
2384
2385var _parchment2 = _interopRequireDefault(_parchment);
2386
2387var _code = __webpack_require__(13);
2388
2389var _code2 = _interopRequireDefault(_code);
2390
2391var _cursor = __webpack_require__(23);
2392
2393var _cursor2 = _interopRequireDefault(_cursor);
2394
2395var _block = __webpack_require__(4);
2396
2397var _block2 = _interopRequireDefault(_block);
2398
2399var _break = __webpack_require__(16);
2400
2401var _break2 = _interopRequireDefault(_break);
2402
2403var _clone = __webpack_require__(21);
2404
2405var _clone2 = _interopRequireDefault(_clone);
2406
2407var _deepEqual = __webpack_require__(11);
2408
2409var _deepEqual2 = _interopRequireDefault(_deepEqual);
2410
2411var _extend = __webpack_require__(3);
2412
2413var _extend2 = _interopRequireDefault(_extend);
2414
2415function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
2416
2417function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
2418
2419function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
2420
2421var ASCII = /^[ -~]*$/;
2422
2423var Editor = function () {
2424 function Editor(scroll) {
2425 _classCallCheck(this, Editor);
2426
2427 this.scroll = scroll;
2428 this.delta = this.getDelta();
2429 }
2430
2431 _createClass(Editor, [{
2432 key: 'applyDelta',
2433 value: function applyDelta(delta) {
2434 var _this = this;
2435
2436 var consumeNextNewline = false;
2437 this.scroll.update();
2438 var scrollLength = this.scroll.length();
2439 this.scroll.batchStart();
2440 delta = normalizeDelta(delta);
2441 delta.reduce(function (index, op) {
2442 var length = op.retain || op.delete || op.insert.length || 1;
2443 var attributes = op.attributes || {};
2444 if (op.insert != null) {
2445 if (typeof op.insert === 'string') {
2446 var text = op.insert;
2447 if (text.endsWith('\n') && consumeNextNewline) {
2448 consumeNextNewline = false;
2449 text = text.slice(0, -1);
2450 }
2451 if (index >= scrollLength && !text.endsWith('\n')) {
2452 consumeNextNewline = true;
2453 }
2454 _this.scroll.insertAt(index, text);
2455
2456 var _scroll$line = _this.scroll.line(index),
2457 _scroll$line2 = _slicedToArray(_scroll$line, 2),
2458 line = _scroll$line2[0],
2459 offset = _scroll$line2[1];
2460
2461 var formats = (0, _extend2.default)({}, (0, _block.bubbleFormats)(line));
2462 if (line instanceof _block2.default) {
2463 var _line$descendant = line.descendant(_parchment2.default.Leaf, offset),
2464 _line$descendant2 = _slicedToArray(_line$descendant, 1),
2465 leaf = _line$descendant2[0];
2466
2467 formats = (0, _extend2.default)(formats, (0, _block.bubbleFormats)(leaf));
2468 }
2469 attributes = _op2.default.attributes.diff(formats, attributes) || {};
2470 } else if (_typeof(op.insert) === 'object') {
2471 var key = Object.keys(op.insert)[0]; // There should only be one key
2472 if (key == null) return index;
2473 _this.scroll.insertAt(index, key, op.insert[key]);
2474 }
2475 scrollLength += length;
2476 }
2477 Object.keys(attributes).forEach(function (name) {
2478 _this.scroll.formatAt(index, length, name, attributes[name]);
2479 });
2480 return index + length;
2481 }, 0);
2482 delta.reduce(function (index, op) {
2483 if (typeof op.delete === 'number') {
2484 _this.scroll.deleteAt(index, op.delete);
2485 return index;
2486 }
2487 return index + (op.retain || op.insert.length || 1);
2488 }, 0);
2489 this.scroll.batchEnd();
2490 return this.update(delta);
2491 }
2492 }, {
2493 key: 'deleteText',
2494 value: function deleteText(index, length) {
2495 this.scroll.deleteAt(index, length);
2496 return this.update(new _quillDelta2.default().retain(index).delete(length));
2497 }
2498 }, {
2499 key: 'formatLine',
2500 value: function formatLine(index, length) {
2501 var _this2 = this;
2502
2503 var formats = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
2504
2505 this.scroll.update();
2506 Object.keys(formats).forEach(function (format) {
2507 if (_this2.scroll.whitelist != null && !_this2.scroll.whitelist[format]) return;
2508 var lines = _this2.scroll.lines(index, Math.max(length, 1));
2509 var lengthRemaining = length;
2510 lines.forEach(function (line) {
2511 var lineLength = line.length();
2512 if (!(line instanceof _code2.default)) {
2513 line.format(format, formats[format]);
2514 } else {
2515 var codeIndex = index - line.offset(_this2.scroll);
2516 var codeLength = line.newlineIndex(codeIndex + lengthRemaining) - codeIndex + 1;
2517 line.formatAt(codeIndex, codeLength, format, formats[format]);
2518 }
2519 lengthRemaining -= lineLength;
2520 });
2521 });
2522 this.scroll.optimize();
2523 return this.update(new _quillDelta2.default().retain(index).retain(length, (0, _clone2.default)(formats)));
2524 }
2525 }, {
2526 key: 'formatText',
2527 value: function formatText(index, length) {
2528 var _this3 = this;
2529
2530 var formats = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
2531
2532 Object.keys(formats).forEach(function (format) {
2533 _this3.scroll.formatAt(index, length, format, formats[format]);
2534 });
2535 return this.update(new _quillDelta2.default().retain(index).retain(length, (0, _clone2.default)(formats)));
2536 }
2537 }, {
2538 key: 'getContents',
2539 value: function getContents(index, length) {
2540 return this.delta.slice(index, index + length);
2541 }
2542 }, {
2543 key: 'getDelta',
2544 value: function getDelta() {
2545 return this.scroll.lines().reduce(function (delta, line) {
2546 return delta.concat(line.delta());
2547 }, new _quillDelta2.default());
2548 }
2549 }, {
2550 key: 'getFormat',
2551 value: function getFormat(index) {
2552 var length = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
2553
2554 var lines = [],
2555 leaves = [];
2556 if (length === 0) {
2557 this.scroll.path(index).forEach(function (path) {
2558 var _path = _slicedToArray(path, 1),
2559 blot = _path[0];
2560
2561 if (blot instanceof _block2.default) {
2562 lines.push(blot);
2563 } else if (blot instanceof _parchment2.default.Leaf) {
2564 leaves.push(blot);
2565 }
2566 });
2567 } else {
2568 lines = this.scroll.lines(index, length);
2569 leaves = this.scroll.descendants(_parchment2.default.Leaf, index, length);
2570 }
2571 var formatsArr = [lines, leaves].map(function (blots) {
2572 if (blots.length === 0) return {};
2573 var formats = (0, _block.bubbleFormats)(blots.shift());
2574 while (Object.keys(formats).length > 0) {
2575 var blot = blots.shift();
2576 if (blot == null) return formats;
2577 formats = combineFormats((0, _block.bubbleFormats)(blot), formats);
2578 }
2579 return formats;
2580 });
2581 return _extend2.default.apply(_extend2.default, formatsArr);
2582 }
2583 }, {
2584 key: 'getText',
2585 value: function getText(index, length) {
2586 return this.getContents(index, length).filter(function (op) {
2587 return typeof op.insert === 'string';
2588 }).map(function (op) {
2589 return op.insert;
2590 }).join('');
2591 }
2592 }, {
2593 key: 'insertEmbed',
2594 value: function insertEmbed(index, embed, value) {
2595 this.scroll.insertAt(index, embed, value);
2596 return this.update(new _quillDelta2.default().retain(index).insert(_defineProperty({}, embed, value)));
2597 }
2598 }, {
2599 key: 'insertText',
2600 value: function insertText(index, text) {
2601 var _this4 = this;
2602
2603 var formats = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
2604
2605 text = text.replace(/\r\n/g, '\n').replace(/\r/g, '\n');
2606 this.scroll.insertAt(index, text);
2607 Object.keys(formats).forEach(function (format) {
2608 _this4.scroll.formatAt(index, text.length, format, formats[format]);
2609 });
2610 return this.update(new _quillDelta2.default().retain(index).insert(text, (0, _clone2.default)(formats)));
2611 }
2612 }, {
2613 key: 'isBlank',
2614 value: function isBlank() {
2615 if (this.scroll.children.length == 0) return true;
2616 if (this.scroll.children.length > 1) return false;
2617 var block = this.scroll.children.head;
2618 if (block.statics.blotName !== _block2.default.blotName) return false;
2619 if (block.children.length > 1) return false;
2620 return block.children.head instanceof _break2.default;
2621 }
2622 }, {
2623 key: 'removeFormat',
2624 value: function removeFormat(index, length) {
2625 var text = this.getText(index, length);
2626
2627 var _scroll$line3 = this.scroll.line(index + length),
2628 _scroll$line4 = _slicedToArray(_scroll$line3, 2),
2629 line = _scroll$line4[0],
2630 offset = _scroll$line4[1];
2631
2632 var suffixLength = 0,
2633 suffix = new _quillDelta2.default();
2634 if (line != null) {
2635 if (!(line instanceof _code2.default)) {
2636 suffixLength = line.length() - offset;
2637 } else {
2638 suffixLength = line.newlineIndex(offset) - offset + 1;
2639 }
2640 suffix = line.delta().slice(offset, offset + suffixLength - 1).insert('\n');
2641 }
2642 var contents = this.getContents(index, length + suffixLength);
2643 var diff = contents.diff(new _quillDelta2.default().insert(text).concat(suffix));
2644 var delta = new _quillDelta2.default().retain(index).concat(diff);
2645 return this.applyDelta(delta);
2646 }
2647 }, {
2648 key: 'update',
2649 value: function update(change) {
2650 var mutations = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
2651 var cursorIndex = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : undefined;
2652
2653 var oldDelta = this.delta;
2654 if (mutations.length === 1 && mutations[0].type === 'characterData' && mutations[0].target.data.match(ASCII) && _parchment2.default.find(mutations[0].target)) {
2655 // Optimization for character changes
2656 var textBlot = _parchment2.default.find(mutations[0].target);
2657 var formats = (0, _block.bubbleFormats)(textBlot);
2658 var index = textBlot.offset(this.scroll);
2659 var oldValue = mutations[0].oldValue.replace(_cursor2.default.CONTENTS, '');
2660 var oldText = new _quillDelta2.default().insert(oldValue);
2661 var newText = new _quillDelta2.default().insert(textBlot.value());
2662 var diffDelta = new _quillDelta2.default().retain(index).concat(oldText.diff(newText, cursorIndex));
2663 change = diffDelta.reduce(function (delta, op) {
2664 if (op.insert) {
2665 return delta.insert(op.insert, formats);
2666 } else {
2667 return delta.push(op);
2668 }
2669 }, new _quillDelta2.default());
2670 this.delta = oldDelta.compose(change);
2671 } else {
2672 this.delta = this.getDelta();
2673 if (!change || !(0, _deepEqual2.default)(oldDelta.compose(change), this.delta)) {
2674 change = oldDelta.diff(this.delta, cursorIndex);
2675 }
2676 }
2677 return change;
2678 }
2679 }]);
2680
2681 return Editor;
2682}();
2683
2684function combineFormats(formats, combined) {
2685 return Object.keys(combined).reduce(function (merged, name) {
2686 if (formats[name] == null) return merged;
2687 if (combined[name] === formats[name]) {
2688 merged[name] = combined[name];
2689 } else if (Array.isArray(combined[name])) {
2690 if (combined[name].indexOf(formats[name]) < 0) {
2691 merged[name] = combined[name].concat([formats[name]]);
2692 }
2693 } else {
2694 merged[name] = [combined[name], formats[name]];
2695 }
2696 return merged;
2697 }, {});
2698}
2699
2700function normalizeDelta(delta) {
2701 return delta.reduce(function (delta, op) {
2702 if (op.insert === 1) {
2703 var attributes = (0, _clone2.default)(op.attributes);
2704 delete attributes['image'];
2705 return delta.insert({ image: op.attributes.image }, attributes);
2706 }
2707 if (op.attributes != null && (op.attributes.list === true || op.attributes.bullet === true)) {
2708 op = (0, _clone2.default)(op);
2709 if (op.attributes.list) {
2710 op.attributes.list = 'ordered';
2711 } else {
2712 op.attributes.list = 'bullet';
2713 delete op.attributes.bullet;
2714 }
2715 }
2716 if (typeof op.insert === 'string') {
2717 var text = op.insert.replace(/\r\n/g, '\n').replace(/\r/g, '\n');
2718 return delta.insert(text, op.attributes);
2719 }
2720 return delta.push(op);
2721 }, new _quillDelta2.default());
2722}
2723
2724exports.default = Editor;
2725
2726/***/ }),
2727/* 15 */
2728/***/ (function(module, exports, __webpack_require__) {
2729
2730"use strict";
2731
2732
2733Object.defineProperty(exports, "__esModule", {
2734 value: true
2735});
2736exports.default = exports.Range = undefined;
2737
2738var _slicedToArray = function () { function sliceIterator(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"]) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } return function (arr, i) { if (Array.isArray(arr)) { return arr; } else if (Symbol.iterator in Object(arr)) { return sliceIterator(arr, i); } else { throw new TypeError("Invalid attempt to destructure non-iterable instance"); } }; }();
2739
2740var _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; }; }();
2741
2742var _parchment = __webpack_require__(0);
2743
2744var _parchment2 = _interopRequireDefault(_parchment);
2745
2746var _clone = __webpack_require__(21);
2747
2748var _clone2 = _interopRequireDefault(_clone);
2749
2750var _deepEqual = __webpack_require__(11);
2751
2752var _deepEqual2 = _interopRequireDefault(_deepEqual);
2753
2754var _emitter3 = __webpack_require__(8);
2755
2756var _emitter4 = _interopRequireDefault(_emitter3);
2757
2758var _logger = __webpack_require__(10);
2759
2760var _logger2 = _interopRequireDefault(_logger);
2761
2762function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
2763
2764function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } }
2765
2766function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
2767
2768var debug = (0, _logger2.default)('quill:selection');
2769
2770var Range = function Range(index) {
2771 var length = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
2772
2773 _classCallCheck(this, Range);
2774
2775 this.index = index;
2776 this.length = length;
2777};
2778
2779var Selection = function () {
2780 function Selection(scroll, emitter) {
2781 var _this = this;
2782
2783 _classCallCheck(this, Selection);
2784
2785 this.emitter = emitter;
2786 this.scroll = scroll;
2787 this.composing = false;
2788 this.mouseDown = false;
2789 this.root = this.scroll.domNode;
2790 this.cursor = _parchment2.default.create('cursor', this);
2791 // savedRange is last non-null range
2792 this.lastRange = this.savedRange = new Range(0, 0);
2793 this.handleComposition();
2794 this.handleDragging();
2795 this.emitter.listenDOM('selectionchange', document, function () {
2796 if (!_this.mouseDown) {
2797 setTimeout(_this.update.bind(_this, _emitter4.default.sources.USER), 1);
2798 }
2799 });
2800 this.emitter.on(_emitter4.default.events.EDITOR_CHANGE, function (type, delta) {
2801 if (type === _emitter4.default.events.TEXT_CHANGE && delta.length() > 0) {
2802 _this.update(_emitter4.default.sources.SILENT);
2803 }
2804 });
2805 this.emitter.on(_emitter4.default.events.SCROLL_BEFORE_UPDATE, function () {
2806 if (!_this.hasFocus()) return;
2807 var native = _this.getNativeRange();
2808 if (native == null) return;
2809 if (native.start.node === _this.cursor.textNode) return; // cursor.restore() will handle
2810 // TODO unclear if this has negative side effects
2811 _this.emitter.once(_emitter4.default.events.SCROLL_UPDATE, function () {
2812 try {
2813 _this.setNativeRange(native.start.node, native.start.offset, native.end.node, native.end.offset);
2814 } catch (ignored) {}
2815 });
2816 });
2817 this.emitter.on(_emitter4.default.events.SCROLL_OPTIMIZE, function (mutations, context) {
2818 if (context.range) {
2819 var _context$range = context.range,
2820 startNode = _context$range.startNode,
2821 startOffset = _context$range.startOffset,
2822 endNode = _context$range.endNode,
2823 endOffset = _context$range.endOffset;
2824
2825 _this.setNativeRange(startNode, startOffset, endNode, endOffset);
2826 }
2827 });
2828 this.update(_emitter4.default.sources.SILENT);
2829 }
2830
2831 _createClass(Selection, [{
2832 key: 'handleComposition',
2833 value: function handleComposition() {
2834 var _this2 = this;
2835
2836 this.root.addEventListener('compositionstart', function () {
2837 _this2.composing = true;
2838 });
2839 this.root.addEventListener('compositionend', function () {
2840 _this2.composing = false;
2841 if (_this2.cursor.parent) {
2842 var range = _this2.cursor.restore();
2843 if (!range) return;
2844 setTimeout(function () {
2845 _this2.setNativeRange(range.startNode, range.startOffset, range.endNode, range.endOffset);
2846 }, 1);
2847 }
2848 });
2849 }
2850 }, {
2851 key: 'handleDragging',
2852 value: function handleDragging() {
2853 var _this3 = this;
2854
2855 this.emitter.listenDOM('mousedown', document.body, function () {
2856 _this3.mouseDown = true;
2857 });
2858 this.emitter.listenDOM('mouseup', document.body, function () {
2859 _this3.mouseDown = false;
2860 _this3.update(_emitter4.default.sources.USER);
2861 });
2862 }
2863 }, {
2864 key: 'focus',
2865 value: function focus() {
2866 if (this.hasFocus()) return;
2867 this.root.focus();
2868 this.setRange(this.savedRange);
2869 }
2870 }, {
2871 key: 'format',
2872 value: function format(_format, value) {
2873 if (this.scroll.whitelist != null && !this.scroll.whitelist[_format]) return;
2874 this.scroll.update();
2875 var nativeRange = this.getNativeRange();
2876 if (nativeRange == null || !nativeRange.native.collapsed || _parchment2.default.query(_format, _parchment2.default.Scope.BLOCK)) return;
2877 if (nativeRange.start.node !== this.cursor.textNode) {
2878 var blot = _parchment2.default.find(nativeRange.start.node, false);
2879 if (blot == null) return;
2880 // TODO Give blot ability to not split
2881 if (blot instanceof _parchment2.default.Leaf) {
2882 var after = blot.split(nativeRange.start.offset);
2883 blot.parent.insertBefore(this.cursor, after);
2884 } else {
2885 blot.insertBefore(this.cursor, nativeRange.start.node); // Should never happen
2886 }
2887 this.cursor.attach();
2888 }
2889 this.cursor.format(_format, value);
2890 this.scroll.optimize();
2891 this.setNativeRange(this.cursor.textNode, this.cursor.textNode.data.length);
2892 this.update();
2893 }
2894 }, {
2895 key: 'getBounds',
2896 value: function getBounds(index) {
2897 var length = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
2898
2899 var scrollLength = this.scroll.length();
2900 index = Math.min(index, scrollLength - 1);
2901 length = Math.min(index + length, scrollLength - 1) - index;
2902 var node = void 0,
2903 _scroll$leaf = this.scroll.leaf(index),
2904 _scroll$leaf2 = _slicedToArray(_scroll$leaf, 2),
2905 leaf = _scroll$leaf2[0],
2906 offset = _scroll$leaf2[1];
2907 if (leaf == null) return null;
2908
2909 var _leaf$position = leaf.position(offset, true);
2910
2911 var _leaf$position2 = _slicedToArray(_leaf$position, 2);
2912
2913 node = _leaf$position2[0];
2914 offset = _leaf$position2[1];
2915
2916 var range = document.createRange();
2917 if (length > 0) {
2918 range.setStart(node, offset);
2919
2920 var _scroll$leaf3 = this.scroll.leaf(index + length);
2921
2922 var _scroll$leaf4 = _slicedToArray(_scroll$leaf3, 2);
2923
2924 leaf = _scroll$leaf4[0];
2925 offset = _scroll$leaf4[1];
2926
2927 if (leaf == null) return null;
2928
2929 var _leaf$position3 = leaf.position(offset, true);
2930
2931 var _leaf$position4 = _slicedToArray(_leaf$position3, 2);
2932
2933 node = _leaf$position4[0];
2934 offset = _leaf$position4[1];
2935
2936 range.setEnd(node, offset);
2937 return range.getBoundingClientRect();
2938 } else {
2939 var side = 'left';
2940 var rect = void 0;
2941 if (node instanceof Text) {
2942 if (offset < node.data.length) {
2943 range.setStart(node, offset);
2944 range.setEnd(node, offset + 1);
2945 } else {
2946 range.setStart(node, offset - 1);
2947 range.setEnd(node, offset);
2948 side = 'right';
2949 }
2950 rect = range.getBoundingClientRect();
2951 } else {
2952 rect = leaf.domNode.getBoundingClientRect();
2953 if (offset > 0) side = 'right';
2954 }
2955 return {
2956 bottom: rect.top + rect.height,
2957 height: rect.height,
2958 left: rect[side],
2959 right: rect[side],
2960 top: rect.top,
2961 width: 0
2962 };
2963 }
2964 }
2965 }, {
2966 key: 'getNativeRange',
2967 value: function getNativeRange() {
2968 var selection = document.getSelection();
2969 if (selection == null || selection.rangeCount <= 0) return null;
2970 var nativeRange = selection.getRangeAt(0);
2971 if (nativeRange == null) return null;
2972 var range = this.normalizeNative(nativeRange);
2973 debug.info('getNativeRange', range);
2974 return range;
2975 }
2976 }, {
2977 key: 'getRange',
2978 value: function getRange() {
2979 var normalized = this.getNativeRange();
2980 if (normalized == null) return [null, null];
2981 var range = this.normalizedToRange(normalized);
2982 return [range, normalized];
2983 }
2984 }, {
2985 key: 'hasFocus',
2986 value: function hasFocus() {
2987 return document.activeElement === this.root;
2988 }
2989 }, {
2990 key: 'normalizedToRange',
2991 value: function normalizedToRange(range) {
2992 var _this4 = this;
2993
2994 var positions = [[range.start.node, range.start.offset]];
2995 if (!range.native.collapsed) {
2996 positions.push([range.end.node, range.end.offset]);
2997 }
2998 var indexes = positions.map(function (position) {
2999 var _position = _slicedToArray(position, 2),
3000 node = _position[0],
3001 offset = _position[1];
3002
3003 var blot = _parchment2.default.find(node, true);
3004 var index = blot.offset(_this4.scroll);
3005 if (offset === 0) {
3006 return index;
3007 } else if (blot instanceof _parchment2.default.Container) {
3008 return index + blot.length();
3009 } else {
3010 return index + blot.index(node, offset);
3011 }
3012 });
3013 var end = Math.min(Math.max.apply(Math, _toConsumableArray(indexes)), this.scroll.length() - 1);
3014 var start = Math.min.apply(Math, [end].concat(_toConsumableArray(indexes)));
3015 return new Range(start, end - start);
3016 }
3017 }, {
3018 key: 'normalizeNative',
3019 value: function normalizeNative(nativeRange) {
3020 if (!contains(this.root, nativeRange.startContainer) || !nativeRange.collapsed && !contains(this.root, nativeRange.endContainer)) {
3021 return null;
3022 }
3023 var range = {
3024 start: { node: nativeRange.startContainer, offset: nativeRange.startOffset },
3025 end: { node: nativeRange.endContainer, offset: nativeRange.endOffset },
3026 native: nativeRange
3027 };
3028 [range.start, range.end].forEach(function (position) {
3029 var node = position.node,
3030 offset = position.offset;
3031 while (!(node instanceof Text) && node.childNodes.length > 0) {
3032 if (node.childNodes.length > offset) {
3033 node = node.childNodes[offset];
3034 offset = 0;
3035 } else if (node.childNodes.length === offset) {
3036 node = node.lastChild;
3037 offset = node instanceof Text ? node.data.length : node.childNodes.length + 1;
3038 } else {
3039 break;
3040 }
3041 }
3042 position.node = node, position.offset = offset;
3043 });
3044 return range;
3045 }
3046 }, {
3047 key: 'rangeToNative',
3048 value: function rangeToNative(range) {
3049 var _this5 = this;
3050
3051 var indexes = range.collapsed ? [range.index] : [range.index, range.index + range.length];
3052 var args = [];
3053 var scrollLength = this.scroll.length();
3054 indexes.forEach(function (index, i) {
3055 index = Math.min(scrollLength - 1, index);
3056 var node = void 0,
3057 _scroll$leaf5 = _this5.scroll.leaf(index),
3058 _scroll$leaf6 = _slicedToArray(_scroll$leaf5, 2),
3059 leaf = _scroll$leaf6[0],
3060 offset = _scroll$leaf6[1];
3061 var _leaf$position5 = leaf.position(offset, i !== 0);
3062
3063 var _leaf$position6 = _slicedToArray(_leaf$position5, 2);
3064
3065 node = _leaf$position6[0];
3066 offset = _leaf$position6[1];
3067
3068 args.push(node, offset);
3069 });
3070 if (args.length < 2) {
3071 args = args.concat(args);
3072 }
3073 return args;
3074 }
3075 }, {
3076 key: 'scrollIntoView',
3077 value: function scrollIntoView(scrollingContainer) {
3078 var range = this.lastRange;
3079 if (range == null) return;
3080 var bounds = this.getBounds(range.index, range.length);
3081 if (bounds == null) return;
3082 var limit = this.scroll.length() - 1;
3083
3084 var _scroll$line = this.scroll.line(Math.min(range.index, limit)),
3085 _scroll$line2 = _slicedToArray(_scroll$line, 1),
3086 first = _scroll$line2[0];
3087
3088 var last = first;
3089 if (range.length > 0) {
3090 var _scroll$line3 = this.scroll.line(Math.min(range.index + range.length, limit));
3091
3092 var _scroll$line4 = _slicedToArray(_scroll$line3, 1);
3093
3094 last = _scroll$line4[0];
3095 }
3096 if (first == null || last == null) return;
3097 var scrollBounds = scrollingContainer.getBoundingClientRect();
3098 if (bounds.top < scrollBounds.top) {
3099 scrollingContainer.scrollTop -= scrollBounds.top - bounds.top;
3100 } else if (bounds.bottom > scrollBounds.bottom) {
3101 scrollingContainer.scrollTop += bounds.bottom - scrollBounds.bottom;
3102 }
3103 }
3104 }, {
3105 key: 'setNativeRange',
3106 value: function setNativeRange(startNode, startOffset) {
3107 var endNode = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : startNode;
3108 var endOffset = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : startOffset;
3109 var force = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : false;
3110
3111 debug.info('setNativeRange', startNode, startOffset, endNode, endOffset);
3112 if (startNode != null && (this.root.parentNode == null || startNode.parentNode == null || endNode.parentNode == null)) {
3113 return;
3114 }
3115 var selection = document.getSelection();
3116 if (selection == null) return;
3117 if (startNode != null) {
3118 if (!this.hasFocus()) this.root.focus();
3119 var native = (this.getNativeRange() || {}).native;
3120 if (native == null || force || startNode !== native.startContainer || startOffset !== native.startOffset || endNode !== native.endContainer || endOffset !== native.endOffset) {
3121
3122 if (startNode.tagName == "BR") {
3123 startOffset = [].indexOf.call(startNode.parentNode.childNodes, startNode);
3124 startNode = startNode.parentNode;
3125 }
3126 if (endNode.tagName == "BR") {
3127 endOffset = [].indexOf.call(endNode.parentNode.childNodes, endNode);
3128 endNode = endNode.parentNode;
3129 }
3130 var range = document.createRange();
3131 range.setStart(startNode, startOffset);
3132 range.setEnd(endNode, endOffset);
3133 selection.removeAllRanges();
3134 selection.addRange(range);
3135 }
3136 } else {
3137 selection.removeAllRanges();
3138 this.root.blur();
3139 document.body.focus(); // root.blur() not enough on IE11+Travis+SauceLabs (but not local VMs)
3140 }
3141 }
3142 }, {
3143 key: 'setRange',
3144 value: function setRange(range) {
3145 var force = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
3146 var source = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : _emitter4.default.sources.API;
3147
3148 if (typeof force === 'string') {
3149 source = force;
3150 force = false;
3151 }
3152 debug.info('setRange', range);
3153 if (range != null) {
3154 var args = this.rangeToNative(range);
3155 this.setNativeRange.apply(this, _toConsumableArray(args).concat([force]));
3156 } else {
3157 this.setNativeRange(null);
3158 }
3159 this.update(source);
3160 }
3161 }, {
3162 key: 'update',
3163 value: function update() {
3164 var source = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : _emitter4.default.sources.USER;
3165
3166 var oldRange = this.lastRange;
3167
3168 var _getRange = this.getRange(),
3169 _getRange2 = _slicedToArray(_getRange, 2),
3170 lastRange = _getRange2[0],
3171 nativeRange = _getRange2[1];
3172
3173 this.lastRange = lastRange;
3174 if (this.lastRange != null) {
3175 this.savedRange = this.lastRange;
3176 }
3177 if (!(0, _deepEqual2.default)(oldRange, this.lastRange)) {
3178 var _emitter;
3179
3180 if (!this.composing && nativeRange != null && nativeRange.native.collapsed && nativeRange.start.node !== this.cursor.textNode) {
3181 this.cursor.restore();
3182 }
3183 var args = [_emitter4.default.events.SELECTION_CHANGE, (0, _clone2.default)(this.lastRange), (0, _clone2.default)(oldRange), source];
3184 (_emitter = this.emitter).emit.apply(_emitter, [_emitter4.default.events.EDITOR_CHANGE].concat(args));
3185 if (source !== _emitter4.default.sources.SILENT) {
3186 var _emitter2;
3187
3188 (_emitter2 = this.emitter).emit.apply(_emitter2, args);
3189 }
3190 }
3191 }
3192 }]);
3193
3194 return Selection;
3195}();
3196
3197function contains(parent, descendant) {
3198 try {
3199 // Firefox inserts inaccessible nodes around video elements
3200 descendant.parentNode;
3201 } catch (e) {
3202 return false;
3203 }
3204 // IE11 has bug with Text nodes
3205 // https://connect.microsoft.com/IE/feedback/details/780874/node-contains-is-incorrect
3206 if (descendant instanceof Text) {
3207 descendant = descendant.parentNode;
3208 }
3209 return parent.contains(descendant);
3210}
3211
3212exports.Range = Range;
3213exports.default = Selection;
3214
3215/***/ }),
3216/* 16 */
3217/***/ (function(module, exports, __webpack_require__) {
3218
3219"use strict";
3220
3221
3222Object.defineProperty(exports, "__esModule", {
3223 value: true
3224});
3225
3226var _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; }; }();
3227
3228var _get = function get(object, property, receiver) { if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { return get(parent, property, receiver); } } else if ("value" in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } };
3229
3230var _parchment = __webpack_require__(0);
3231
3232var _parchment2 = _interopRequireDefault(_parchment);
3233
3234function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
3235
3236function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
3237
3238function _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; }
3239
3240function _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; }
3241
3242var Break = function (_Parchment$Embed) {
3243 _inherits(Break, _Parchment$Embed);
3244
3245 function Break() {
3246 _classCallCheck(this, Break);
3247
3248 return _possibleConstructorReturn(this, (Break.__proto__ || Object.getPrototypeOf(Break)).apply(this, arguments));
3249 }
3250
3251 _createClass(Break, [{
3252 key: 'insertInto',
3253 value: function insertInto(parent, ref) {
3254 if (parent.children.length === 0) {
3255 _get(Break.prototype.__proto__ || Object.getPrototypeOf(Break.prototype), 'insertInto', this).call(this, parent, ref);
3256 } else {
3257 this.remove();
3258 }
3259 }
3260 }, {
3261 key: 'length',
3262 value: function length() {
3263 return 0;
3264 }
3265 }, {
3266 key: 'value',
3267 value: function value() {
3268 return '';
3269 }
3270 }], [{
3271 key: 'value',
3272 value: function value() {
3273 return undefined;
3274 }
3275 }]);
3276
3277 return Break;
3278}(_parchment2.default.Embed);
3279
3280Break.blotName = 'break';
3281Break.tagName = 'BR';
3282
3283exports.default = Break;
3284
3285/***/ }),
3286/* 17 */
3287/***/ (function(module, exports, __webpack_require__) {
3288
3289"use strict";
3290
3291var __extends = (this && this.__extends) || (function () {
3292 var extendStatics = Object.setPrototypeOf ||
3293 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
3294 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
3295 return function (d, b) {
3296 extendStatics(d, b);
3297 function __() { this.constructor = d; }
3298 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
3299 };
3300})();
3301Object.defineProperty(exports, "__esModule", { value: true });
3302var linked_list_1 = __webpack_require__(44);
3303var shadow_1 = __webpack_require__(30);
3304var Registry = __webpack_require__(1);
3305var ContainerBlot = /** @class */ (function (_super) {
3306 __extends(ContainerBlot, _super);
3307 function ContainerBlot() {
3308 return _super !== null && _super.apply(this, arguments) || this;
3309 }
3310 ContainerBlot.prototype.appendChild = function (other) {
3311 this.insertBefore(other);
3312 };
3313 ContainerBlot.prototype.attach = function () {
3314 var _this = this;
3315 _super.prototype.attach.call(this);
3316 this.children = new linked_list_1.default();
3317 // Need to be reversed for if DOM nodes already in order
3318 [].slice.call(this.domNode.childNodes).reverse().forEach(function (node) {
3319 try {
3320 var child = makeBlot(node);
3321 _this.insertBefore(child, _this.children.head);
3322 }
3323 catch (err) {
3324 if (err instanceof Registry.ParchmentError)
3325 return;
3326 else
3327 throw err;
3328 }
3329 });
3330 };
3331 ContainerBlot.prototype.deleteAt = function (index, length) {
3332 if (index === 0 && length === this.length()) {
3333 return this.remove();
3334 }
3335 this.children.forEachAt(index, length, function (child, offset, length) {
3336 child.deleteAt(offset, length);
3337 });
3338 };
3339 ContainerBlot.prototype.descendant = function (criteria, index) {
3340 var _a = this.children.find(index), child = _a[0], offset = _a[1];
3341 if ((criteria.blotName == null && criteria(child)) ||
3342 (criteria.blotName != null && child instanceof criteria)) {
3343 return [child, offset];
3344 }
3345 else if (child instanceof ContainerBlot) {
3346 return child.descendant(criteria, offset);
3347 }
3348 else {
3349 return [null, -1];
3350 }
3351 };
3352 ContainerBlot.prototype.descendants = function (criteria, index, length) {
3353 if (index === void 0) { index = 0; }
3354 if (length === void 0) { length = Number.MAX_VALUE; }
3355 var descendants = [], lengthLeft = length;
3356 this.children.forEachAt(index, length, function (child, index, length) {
3357 if ((criteria.blotName == null && criteria(child)) ||
3358 (criteria.blotName != null && child instanceof criteria)) {
3359 descendants.push(child);
3360 }
3361 if (child instanceof ContainerBlot) {
3362 descendants = descendants.concat(child.descendants(criteria, index, lengthLeft));
3363 }
3364 lengthLeft -= length;
3365 });
3366 return descendants;
3367 };
3368 ContainerBlot.prototype.detach = function () {
3369 this.children.forEach(function (child) {
3370 child.detach();
3371 });
3372 _super.prototype.detach.call(this);
3373 };
3374 ContainerBlot.prototype.formatAt = function (index, length, name, value) {
3375 this.children.forEachAt(index, length, function (child, offset, length) {
3376 child.formatAt(offset, length, name, value);
3377 });
3378 };
3379 ContainerBlot.prototype.insertAt = function (index, value, def) {
3380 var _a = this.children.find(index), child = _a[0], offset = _a[1];
3381 if (child) {
3382 child.insertAt(offset, value, def);
3383 }
3384 else {
3385 var blot = (def == null) ? Registry.create('text', value) : Registry.create(value, def);
3386 this.appendChild(blot);
3387 }
3388 };
3389 ContainerBlot.prototype.insertBefore = function (childBlot, refBlot) {
3390 if (this.statics.allowedChildren != null && !this.statics.allowedChildren.some(function (child) {
3391 return childBlot instanceof child;
3392 })) {
3393 throw new Registry.ParchmentError("Cannot insert " + childBlot.statics.blotName + " into " + this.statics.blotName);
3394 }
3395 childBlot.insertInto(this, refBlot);
3396 };
3397 ContainerBlot.prototype.length = function () {
3398 return this.children.reduce(function (memo, child) {
3399 return memo + child.length();
3400 }, 0);
3401 };
3402 ContainerBlot.prototype.moveChildren = function (targetParent, refNode) {
3403 this.children.forEach(function (child) {
3404 targetParent.insertBefore(child, refNode);
3405 });
3406 };
3407 ContainerBlot.prototype.optimize = function (context) {
3408 _super.prototype.optimize.call(this, context);
3409 if (this.children.length === 0) {
3410 if (this.statics.defaultChild != null) {
3411 var child = Registry.create(this.statics.defaultChild);
3412 this.appendChild(child);
3413 child.optimize(context);
3414 }
3415 else {
3416 this.remove();
3417 }
3418 }
3419 };
3420 ContainerBlot.prototype.path = function (index, inclusive) {
3421 if (inclusive === void 0) { inclusive = false; }
3422 var _a = this.children.find(index, inclusive), child = _a[0], offset = _a[1];
3423 var position = [[this, index]];
3424 if (child instanceof ContainerBlot) {
3425 return position.concat(child.path(offset, inclusive));
3426 }
3427 else if (child != null) {
3428 position.push([child, offset]);
3429 }
3430 return position;
3431 };
3432 ContainerBlot.prototype.removeChild = function (child) {
3433 this.children.remove(child);
3434 };
3435 ContainerBlot.prototype.replace = function (target) {
3436 if (target instanceof ContainerBlot) {
3437 target.moveChildren(this);
3438 }
3439 _super.prototype.replace.call(this, target);
3440 };
3441 ContainerBlot.prototype.split = function (index, force) {
3442 if (force === void 0) { force = false; }
3443 if (!force) {
3444 if (index === 0)
3445 return this;
3446 if (index === this.length())
3447 return this.next;
3448 }
3449 var after = this.clone();
3450 this.parent.insertBefore(after, this.next);
3451 this.children.forEachAt(index, this.length(), function (child, offset, length) {
3452 child = child.split(offset, force);
3453 after.appendChild(child);
3454 });
3455 return after;
3456 };
3457 ContainerBlot.prototype.unwrap = function () {
3458 this.moveChildren(this.parent, this.next);
3459 this.remove();
3460 };
3461 ContainerBlot.prototype.update = function (mutations, context) {
3462 var _this = this;
3463 var addedNodes = [], removedNodes = [];
3464 mutations.forEach(function (mutation) {
3465 if (mutation.target === _this.domNode && mutation.type === 'childList') {
3466 addedNodes.push.apply(addedNodes, mutation.addedNodes);
3467 removedNodes.push.apply(removedNodes, mutation.removedNodes);
3468 }
3469 });
3470 removedNodes.forEach(function (node) {
3471 // Check node has actually been removed
3472 // One exception is Chrome does not immediately remove IFRAMEs
3473 // from DOM but MutationRecord is correct in its reported removal
3474 if (node.parentNode != null && node.tagName !== 'IFRAME' &&
3475 (document.body.compareDocumentPosition(node) & Node.DOCUMENT_POSITION_CONTAINED_BY)) {
3476 return;
3477 }
3478 var blot = Registry.find(node);
3479 if (blot == null)
3480 return;
3481 if (blot.domNode.parentNode == null || blot.domNode.parentNode === _this.domNode) {
3482 blot.detach();
3483 }
3484 });
3485 addedNodes.filter(function (node) {
3486 return node.parentNode == _this.domNode;
3487 }).sort(function (a, b) {
3488 if (a === b)
3489 return 0;
3490 if (a.compareDocumentPosition(b) & Node.DOCUMENT_POSITION_FOLLOWING) {
3491 return 1;
3492 }
3493 return -1;
3494 }).forEach(function (node) {
3495 var refBlot = null;
3496 if (node.nextSibling != null) {
3497 refBlot = Registry.find(node.nextSibling);
3498 }
3499 var blot = makeBlot(node);
3500 if (blot.next != refBlot || blot.next == null) {
3501 if (blot.parent != null) {
3502 blot.parent.removeChild(_this);
3503 }
3504 _this.insertBefore(blot, refBlot);
3505 }
3506 });
3507 };
3508 return ContainerBlot;
3509}(shadow_1.default));
3510function makeBlot(node) {
3511 var blot = Registry.find(node);
3512 if (blot == null) {
3513 try {
3514 blot = Registry.create(node);
3515 }
3516 catch (e) {
3517 blot = Registry.create(Registry.Scope.INLINE);
3518 [].slice.call(node.childNodes).forEach(function (child) {
3519 blot.domNode.appendChild(child);
3520 });
3521 node.parentNode.replaceChild(blot.domNode, node);
3522 blot.attach();
3523 }
3524 }
3525 return blot;
3526}
3527exports.default = ContainerBlot;
3528
3529
3530/***/ }),
3531/* 18 */
3532/***/ (function(module, exports, __webpack_require__) {
3533
3534"use strict";
3535
3536var __extends = (this && this.__extends) || (function () {
3537 var extendStatics = Object.setPrototypeOf ||
3538 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
3539 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
3540 return function (d, b) {
3541 extendStatics(d, b);
3542 function __() { this.constructor = d; }
3543 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
3544 };
3545})();
3546Object.defineProperty(exports, "__esModule", { value: true });
3547var attributor_1 = __webpack_require__(12);
3548var store_1 = __webpack_require__(31);
3549var container_1 = __webpack_require__(17);
3550var Registry = __webpack_require__(1);
3551var FormatBlot = /** @class */ (function (_super) {
3552 __extends(FormatBlot, _super);
3553 function FormatBlot() {
3554 return _super !== null && _super.apply(this, arguments) || this;
3555 }
3556 FormatBlot.formats = function (domNode) {
3557 if (typeof this.tagName === 'string') {
3558 return true;
3559 }
3560 else if (Array.isArray(this.tagName)) {
3561 return domNode.tagName.toLowerCase();
3562 }
3563 return undefined;
3564 };
3565 FormatBlot.prototype.attach = function () {
3566 _super.prototype.attach.call(this);
3567 this.attributes = new store_1.default(this.domNode);
3568 };
3569 FormatBlot.prototype.format = function (name, value) {
3570 var format = Registry.query(name);
3571 if (format instanceof attributor_1.default) {
3572 this.attributes.attribute(format, value);
3573 }
3574 else if (value) {
3575 if (format != null && (name !== this.statics.blotName || this.formats()[name] !== value)) {
3576 this.replaceWith(name, value);
3577 }
3578 }
3579 };
3580 FormatBlot.prototype.formats = function () {
3581 var formats = this.attributes.values();
3582 var format = this.statics.formats(this.domNode);
3583 if (format != null) {
3584 formats[this.statics.blotName] = format;
3585 }
3586 return formats;
3587 };
3588 FormatBlot.prototype.replaceWith = function (name, value) {
3589 var replacement = _super.prototype.replaceWith.call(this, name, value);
3590 this.attributes.copy(replacement);
3591 return replacement;
3592 };
3593 FormatBlot.prototype.update = function (mutations, context) {
3594 var _this = this;
3595 _super.prototype.update.call(this, mutations, context);
3596 if (mutations.some(function (mutation) {
3597 return mutation.target === _this.domNode && mutation.type === 'attributes';
3598 })) {
3599 this.attributes.build();
3600 }
3601 };
3602 FormatBlot.prototype.wrap = function (name, value) {
3603 var wrapper = _super.prototype.wrap.call(this, name, value);
3604 if (wrapper instanceof FormatBlot && wrapper.statics.scope === this.statics.scope) {
3605 this.attributes.move(wrapper);
3606 }
3607 return wrapper;
3608 };
3609 return FormatBlot;
3610}(container_1.default));
3611exports.default = FormatBlot;
3612
3613
3614/***/ }),
3615/* 19 */
3616/***/ (function(module, exports, __webpack_require__) {
3617
3618"use strict";
3619
3620var __extends = (this && this.__extends) || (function () {
3621 var extendStatics = Object.setPrototypeOf ||
3622 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
3623 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
3624 return function (d, b) {
3625 extendStatics(d, b);
3626 function __() { this.constructor = d; }
3627 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
3628 };
3629})();
3630Object.defineProperty(exports, "__esModule", { value: true });
3631var shadow_1 = __webpack_require__(30);
3632var Registry = __webpack_require__(1);
3633var LeafBlot = /** @class */ (function (_super) {
3634 __extends(LeafBlot, _super);
3635 function LeafBlot() {
3636 return _super !== null && _super.apply(this, arguments) || this;
3637 }
3638 LeafBlot.value = function (domNode) {
3639 return true;
3640 };
3641 LeafBlot.prototype.index = function (node, offset) {
3642 if (this.domNode === node ||
3643 this.domNode.compareDocumentPosition(node) & Node.DOCUMENT_POSITION_CONTAINED_BY) {
3644 return Math.min(offset, 1);
3645 }
3646 return -1;
3647 };
3648 LeafBlot.prototype.position = function (index, inclusive) {
3649 var offset = [].indexOf.call(this.parent.domNode.childNodes, this.domNode);
3650 if (index > 0)
3651 offset += 1;
3652 return [this.parent.domNode, offset];
3653 };
3654 LeafBlot.prototype.value = function () {
3655 return _a = {}, _a[this.statics.blotName] = this.statics.value(this.domNode) || true, _a;
3656 var _a;
3657 };
3658 LeafBlot.scope = Registry.Scope.INLINE_BLOT;
3659 return LeafBlot;
3660}(shadow_1.default));
3661exports.default = LeafBlot;
3662
3663
3664/***/ }),
3665/* 20 */
3666/***/ (function(module, exports, __webpack_require__) {
3667
3668var equal = __webpack_require__(11);
3669var extend = __webpack_require__(3);
3670
3671
3672var lib = {
3673 attributes: {
3674 compose: function (a, b, keepNull) {
3675 if (typeof a !== 'object') a = {};
3676 if (typeof b !== 'object') b = {};
3677 var attributes = extend(true, {}, b);
3678 if (!keepNull) {
3679 attributes = Object.keys(attributes).reduce(function (copy, key) {
3680 if (attributes[key] != null) {
3681 copy[key] = attributes[key];
3682 }
3683 return copy;
3684 }, {});
3685 }
3686 for (var key in a) {
3687 if (a[key] !== undefined && b[key] === undefined) {
3688 attributes[key] = a[key];
3689 }
3690 }
3691 return Object.keys(attributes).length > 0 ? attributes : undefined;
3692 },
3693
3694 diff: function(a, b) {
3695 if (typeof a !== 'object') a = {};
3696 if (typeof b !== 'object') b = {};
3697 var attributes = Object.keys(a).concat(Object.keys(b)).reduce(function (attributes, key) {
3698 if (!equal(a[key], b[key])) {
3699 attributes[key] = b[key] === undefined ? null : b[key];
3700 }
3701 return attributes;
3702 }, {});
3703 return Object.keys(attributes).length > 0 ? attributes : undefined;
3704 },
3705
3706 transform: function (a, b, priority) {
3707 if (typeof a !== 'object') return b;
3708 if (typeof b !== 'object') return undefined;
3709 if (!priority) return b; // b simply overwrites us without priority
3710 var attributes = Object.keys(b).reduce(function (attributes, key) {
3711 if (a[key] === undefined) attributes[key] = b[key]; // null is a valid value
3712 return attributes;
3713 }, {});
3714 return Object.keys(attributes).length > 0 ? attributes : undefined;
3715 }
3716 },
3717
3718 iterator: function (ops) {
3719 return new Iterator(ops);
3720 },
3721
3722 length: function (op) {
3723 if (typeof op['delete'] === 'number') {
3724 return op['delete'];
3725 } else if (typeof op.retain === 'number') {
3726 return op.retain;
3727 } else {
3728 return typeof op.insert === 'string' ? op.insert.length : 1;
3729 }
3730 }
3731};
3732
3733
3734function Iterator(ops) {
3735 this.ops = ops;
3736 this.index = 0;
3737 this.offset = 0;
3738};
3739
3740Iterator.prototype.hasNext = function () {
3741 return this.peekLength() < Infinity;
3742};
3743
3744Iterator.prototype.next = function (length) {
3745 if (!length) length = Infinity;
3746 var nextOp = this.ops[this.index];
3747 if (nextOp) {
3748 var offset = this.offset;
3749 var opLength = lib.length(nextOp)
3750 if (length >= opLength - offset) {
3751 length = opLength - offset;
3752 this.index += 1;
3753 this.offset = 0;
3754 } else {
3755 this.offset += length;
3756 }
3757 if (typeof nextOp['delete'] === 'number') {
3758 return { 'delete': length };
3759 } else {
3760 var retOp = {};
3761 if (nextOp.attributes) {
3762 retOp.attributes = nextOp.attributes;
3763 }
3764 if (typeof nextOp.retain === 'number') {
3765 retOp.retain = length;
3766 } else if (typeof nextOp.insert === 'string') {
3767 retOp.insert = nextOp.insert.substr(offset, length);
3768 } else {
3769 // offset should === 0, length should === 1
3770 retOp.insert = nextOp.insert;
3771 }
3772 return retOp;
3773 }
3774 } else {
3775 return { retain: Infinity };
3776 }
3777};
3778
3779Iterator.prototype.peek = function () {
3780 return this.ops[this.index];
3781};
3782
3783Iterator.prototype.peekLength = function () {
3784 if (this.ops[this.index]) {
3785 // Should never return 0 if our index is being managed correctly
3786 return lib.length(this.ops[this.index]) - this.offset;
3787 } else {
3788 return Infinity;
3789 }
3790};
3791
3792Iterator.prototype.peekType = function () {
3793 if (this.ops[this.index]) {
3794 if (typeof this.ops[this.index]['delete'] === 'number') {
3795 return 'delete';
3796 } else if (typeof this.ops[this.index].retain === 'number') {
3797 return 'retain';
3798 } else {
3799 return 'insert';
3800 }
3801 }
3802 return 'retain';
3803};
3804
3805
3806module.exports = lib;
3807
3808
3809/***/ }),
3810/* 21 */
3811/***/ (function(module, exports) {
3812
3813var clone = (function() {
3814'use strict';
3815
3816function _instanceof(obj, type) {
3817 return type != null && obj instanceof type;
3818}
3819
3820var nativeMap;
3821try {
3822 nativeMap = Map;
3823} catch(_) {
3824 // maybe a reference error because no `Map`. Give it a dummy value that no
3825 // value will ever be an instanceof.
3826 nativeMap = function() {};
3827}
3828
3829var nativeSet;
3830try {
3831 nativeSet = Set;
3832} catch(_) {
3833 nativeSet = function() {};
3834}
3835
3836var nativePromise;
3837try {
3838 nativePromise = Promise;
3839} catch(_) {
3840 nativePromise = function() {};
3841}
3842
3843/**
3844 * Clones (copies) an Object using deep copying.
3845 *
3846 * This function supports circular references by default, but if you are certain
3847 * there are no circular references in your object, you can save some CPU time
3848 * by calling clone(obj, false).
3849 *
3850 * Caution: if `circular` is false and `parent` contains circular references,
3851 * your program may enter an infinite loop and crash.
3852 *
3853 * @param `parent` - the object to be cloned
3854 * @param `circular` - set to true if the object to be cloned may contain
3855 * circular references. (optional - true by default)
3856 * @param `depth` - set to a number if the object is only to be cloned to
3857 * a particular depth. (optional - defaults to Infinity)
3858 * @param `prototype` - sets the prototype to be used when cloning an object.
3859 * (optional - defaults to parent prototype).
3860 * @param `includeNonEnumerable` - set to true if the non-enumerable properties
3861 * should be cloned as well. Non-enumerable properties on the prototype
3862 * chain will be ignored. (optional - false by default)
3863*/
3864function clone(parent, circular, depth, prototype, includeNonEnumerable) {
3865 if (typeof circular === 'object') {
3866 depth = circular.depth;
3867 prototype = circular.prototype;
3868 includeNonEnumerable = circular.includeNonEnumerable;
3869 circular = circular.circular;
3870 }
3871 // maintain two arrays for circular references, where corresponding parents
3872 // and children have the same index
3873 var allParents = [];
3874 var allChildren = [];
3875
3876 var useBuffer = typeof Buffer != 'undefined';
3877
3878 if (typeof circular == 'undefined')
3879 circular = true;
3880
3881 if (typeof depth == 'undefined')
3882 depth = Infinity;
3883
3884 // recurse this function so we don't reset allParents and allChildren
3885 function _clone(parent, depth) {
3886 // cloning null always returns null
3887 if (parent === null)
3888 return null;
3889
3890 if (depth === 0)
3891 return parent;
3892
3893 var child;
3894 var proto;
3895 if (typeof parent != 'object') {
3896 return parent;
3897 }
3898
3899 if (_instanceof(parent, nativeMap)) {
3900 child = new nativeMap();
3901 } else if (_instanceof(parent, nativeSet)) {
3902 child = new nativeSet();
3903 } else if (_instanceof(parent, nativePromise)) {
3904 child = new nativePromise(function (resolve, reject) {
3905 parent.then(function(value) {
3906 resolve(_clone(value, depth - 1));
3907 }, function(err) {
3908 reject(_clone(err, depth - 1));
3909 });
3910 });
3911 } else if (clone.__isArray(parent)) {
3912 child = [];
3913 } else if (clone.__isRegExp(parent)) {
3914 child = new RegExp(parent.source, __getRegExpFlags(parent));
3915 if (parent.lastIndex) child.lastIndex = parent.lastIndex;
3916 } else if (clone.__isDate(parent)) {
3917 child = new Date(parent.getTime());
3918 } else if (useBuffer && Buffer.isBuffer(parent)) {
3919 child = new Buffer(parent.length);
3920 parent.copy(child);
3921 return child;
3922 } else if (_instanceof(parent, Error)) {
3923 child = Object.create(parent);
3924 } else {
3925 if (typeof prototype == 'undefined') {
3926 proto = Object.getPrototypeOf(parent);
3927 child = Object.create(proto);
3928 }
3929 else {
3930 child = Object.create(prototype);
3931 proto = prototype;
3932 }
3933 }
3934
3935 if (circular) {
3936 var index = allParents.indexOf(parent);
3937
3938 if (index != -1) {
3939 return allChildren[index];
3940 }
3941 allParents.push(parent);
3942 allChildren.push(child);
3943 }
3944
3945 if (_instanceof(parent, nativeMap)) {
3946 parent.forEach(function(value, key) {
3947 var keyChild = _clone(key, depth - 1);
3948 var valueChild = _clone(value, depth - 1);
3949 child.set(keyChild, valueChild);
3950 });
3951 }
3952 if (_instanceof(parent, nativeSet)) {
3953 parent.forEach(function(value) {
3954 var entryChild = _clone(value, depth - 1);
3955 child.add(entryChild);
3956 });
3957 }
3958
3959 for (var i in parent) {
3960 var attrs;
3961 if (proto) {
3962 attrs = Object.getOwnPropertyDescriptor(proto, i);
3963 }
3964
3965 if (attrs && attrs.set == null) {
3966 continue;
3967 }
3968 child[i] = _clone(parent[i], depth - 1);
3969 }
3970
3971 if (Object.getOwnPropertySymbols) {
3972 var symbols = Object.getOwnPropertySymbols(parent);
3973 for (var i = 0; i < symbols.length; i++) {
3974 // Don't need to worry about cloning a symbol because it is a primitive,
3975 // like a number or string.
3976 var symbol = symbols[i];
3977 var descriptor = Object.getOwnPropertyDescriptor(parent, symbol);
3978 if (descriptor && !descriptor.enumerable && !includeNonEnumerable) {
3979 continue;
3980 }
3981 child[symbol] = _clone(parent[symbol], depth - 1);
3982 if (!descriptor.enumerable) {
3983 Object.defineProperty(child, symbol, {
3984 enumerable: false
3985 });
3986 }
3987 }
3988 }
3989
3990 if (includeNonEnumerable) {
3991 var allPropertyNames = Object.getOwnPropertyNames(parent);
3992 for (var i = 0; i < allPropertyNames.length; i++) {
3993 var propertyName = allPropertyNames[i];
3994 var descriptor = Object.getOwnPropertyDescriptor(parent, propertyName);
3995 if (descriptor && descriptor.enumerable) {
3996 continue;
3997 }
3998 child[propertyName] = _clone(parent[propertyName], depth - 1);
3999 Object.defineProperty(child, propertyName, {
4000 enumerable: false
4001 });
4002 }
4003 }
4004
4005 return child;
4006 }
4007
4008 return _clone(parent, depth);
4009}
4010
4011/**
4012 * Simple flat clone using prototype, accepts only objects, usefull for property
4013 * override on FLAT configuration object (no nested props).
4014 *
4015 * USE WITH CAUTION! This may not behave as you wish if you do not know how this
4016 * works.
4017 */
4018clone.clonePrototype = function clonePrototype(parent) {
4019 if (parent === null)
4020 return null;
4021
4022 var c = function () {};
4023 c.prototype = parent;
4024 return new c();
4025};
4026
4027// private utility functions
4028
4029function __objToStr(o) {
4030 return Object.prototype.toString.call(o);
4031}
4032clone.__objToStr = __objToStr;
4033
4034function __isDate(o) {
4035 return typeof o === 'object' && __objToStr(o) === '[object Date]';
4036}
4037clone.__isDate = __isDate;
4038
4039function __isArray(o) {
4040 return typeof o === 'object' && __objToStr(o) === '[object Array]';
4041}
4042clone.__isArray = __isArray;
4043
4044function __isRegExp(o) {
4045 return typeof o === 'object' && __objToStr(o) === '[object RegExp]';
4046}
4047clone.__isRegExp = __isRegExp;
4048
4049function __getRegExpFlags(re) {
4050 var flags = '';
4051 if (re.global) flags += 'g';
4052 if (re.ignoreCase) flags += 'i';
4053 if (re.multiline) flags += 'm';
4054 return flags;
4055}
4056clone.__getRegExpFlags = __getRegExpFlags;
4057
4058return clone;
4059})();
4060
4061if (typeof module === 'object' && module.exports) {
4062 module.exports = clone;
4063}
4064
4065
4066/***/ }),
4067/* 22 */
4068/***/ (function(module, exports, __webpack_require__) {
4069
4070"use strict";
4071
4072
4073Object.defineProperty(exports, "__esModule", {
4074 value: true
4075});
4076
4077var _slicedToArray = function () { function sliceIterator(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"]) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } return function (arr, i) { if (Array.isArray(arr)) { return arr; } else if (Symbol.iterator in Object(arr)) { return sliceIterator(arr, i); } else { throw new TypeError("Invalid attempt to destructure non-iterable instance"); } }; }();
4078
4079var _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; }; }();
4080
4081var _get = function get(object, property, receiver) { if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { return get(parent, property, receiver); } } else if ("value" in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } };
4082
4083var _parchment = __webpack_require__(0);
4084
4085var _parchment2 = _interopRequireDefault(_parchment);
4086
4087var _emitter = __webpack_require__(8);
4088
4089var _emitter2 = _interopRequireDefault(_emitter);
4090
4091var _block = __webpack_require__(4);
4092
4093var _block2 = _interopRequireDefault(_block);
4094
4095var _break = __webpack_require__(16);
4096
4097var _break2 = _interopRequireDefault(_break);
4098
4099var _code = __webpack_require__(13);
4100
4101var _code2 = _interopRequireDefault(_code);
4102
4103var _container = __webpack_require__(24);
4104
4105var _container2 = _interopRequireDefault(_container);
4106
4107function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
4108
4109function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
4110
4111function _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; }
4112
4113function _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; }
4114
4115function isLine(blot) {
4116 return blot instanceof _block2.default || blot instanceof _block.BlockEmbed;
4117}
4118
4119var Scroll = function (_Parchment$Scroll) {
4120 _inherits(Scroll, _Parchment$Scroll);
4121
4122 function Scroll(domNode, config) {
4123 _classCallCheck(this, Scroll);
4124
4125 var _this = _possibleConstructorReturn(this, (Scroll.__proto__ || Object.getPrototypeOf(Scroll)).call(this, domNode));
4126
4127 _this.emitter = config.emitter;
4128 if (Array.isArray(config.whitelist)) {
4129 _this.whitelist = config.whitelist.reduce(function (whitelist, format) {
4130 whitelist[format] = true;
4131 return whitelist;
4132 }, {});
4133 }
4134 // Some reason fixes composition issues with character languages in Windows/Chrome, Safari
4135 _this.domNode.addEventListener('DOMNodeInserted', function () {});
4136 _this.optimize();
4137 _this.enable();
4138 return _this;
4139 }
4140
4141 _createClass(Scroll, [{
4142 key: 'batchStart',
4143 value: function batchStart() {
4144 this.batch = true;
4145 }
4146 }, {
4147 key: 'batchEnd',
4148 value: function batchEnd() {
4149 this.batch = false;
4150 this.optimize();
4151 }
4152 }, {
4153 key: 'deleteAt',
4154 value: function deleteAt(index, length) {
4155 var _line = this.line(index),
4156 _line2 = _slicedToArray(_line, 2),
4157 first = _line2[0],
4158 offset = _line2[1];
4159
4160 var _line3 = this.line(index + length),
4161 _line4 = _slicedToArray(_line3, 1),
4162 last = _line4[0];
4163
4164 _get(Scroll.prototype.__proto__ || Object.getPrototypeOf(Scroll.prototype), 'deleteAt', this).call(this, index, length);
4165 if (last != null && first !== last && offset > 0) {
4166 if (first instanceof _block.BlockEmbed || last instanceof _block.BlockEmbed) {
4167 this.optimize();
4168 return;
4169 }
4170 if (first instanceof _code2.default) {
4171 var newlineIndex = first.newlineIndex(first.length(), true);
4172 if (newlineIndex > -1) {
4173 first = first.split(newlineIndex + 1);
4174 if (first === last) {
4175 this.optimize();
4176 return;
4177 }
4178 }
4179 } else if (last instanceof _code2.default) {
4180 var _newlineIndex = last.newlineIndex(0);
4181 if (_newlineIndex > -1) {
4182 last.split(_newlineIndex + 1);
4183 }
4184 }
4185 var ref = last.children.head instanceof _break2.default ? null : last.children.head;
4186 first.moveChildren(last, ref);
4187 first.remove();
4188 }
4189 this.optimize();
4190 }
4191 }, {
4192 key: 'enable',
4193 value: function enable() {
4194 var enabled = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
4195
4196 this.domNode.setAttribute('contenteditable', enabled);
4197 }
4198 }, {
4199 key: 'formatAt',
4200 value: function formatAt(index, length, format, value) {
4201 if (this.whitelist != null && !this.whitelist[format]) return;
4202 _get(Scroll.prototype.__proto__ || Object.getPrototypeOf(Scroll.prototype), 'formatAt', this).call(this, index, length, format, value);
4203 this.optimize();
4204 }
4205 }, {
4206 key: 'insertAt',
4207 value: function insertAt(index, value, def) {
4208 if (def != null && this.whitelist != null && !this.whitelist[value]) return;
4209 if (index >= this.length()) {
4210 if (def == null || _parchment2.default.query(value, _parchment2.default.Scope.BLOCK) == null) {
4211 var blot = _parchment2.default.create(this.statics.defaultChild);
4212 this.appendChild(blot);
4213 if (def == null && value.endsWith('\n')) {
4214 value = value.slice(0, -1);
4215 }
4216 blot.insertAt(0, value, def);
4217 } else {
4218 var embed = _parchment2.default.create(value, def);
4219 this.appendChild(embed);
4220 }
4221 } else {
4222 _get(Scroll.prototype.__proto__ || Object.getPrototypeOf(Scroll.prototype), 'insertAt', this).call(this, index, value, def);
4223 }
4224 this.optimize();
4225 }
4226 }, {
4227 key: 'insertBefore',
4228 value: function insertBefore(blot, ref) {
4229 if (blot.statics.scope === _parchment2.default.Scope.INLINE_BLOT) {
4230 var wrapper = _parchment2.default.create(this.statics.defaultChild);
4231 wrapper.appendChild(blot);
4232 blot = wrapper;
4233 }
4234 _get(Scroll.prototype.__proto__ || Object.getPrototypeOf(Scroll.prototype), 'insertBefore', this).call(this, blot, ref);
4235 }
4236 }, {
4237 key: 'leaf',
4238 value: function leaf(index) {
4239 return this.path(index).pop() || [null, -1];
4240 }
4241 }, {
4242 key: 'line',
4243 value: function line(index) {
4244 if (index === this.length()) {
4245 return this.line(index - 1);
4246 }
4247 return this.descendant(isLine, index);
4248 }
4249 }, {
4250 key: 'lines',
4251 value: function lines() {
4252 var index = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
4253 var length = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : Number.MAX_VALUE;
4254
4255 var getLines = function getLines(blot, index, length) {
4256 var lines = [],
4257 lengthLeft = length;
4258 blot.children.forEachAt(index, length, function (child, index, length) {
4259 if (isLine(child)) {
4260 lines.push(child);
4261 } else if (child instanceof _parchment2.default.Container) {
4262 lines = lines.concat(getLines(child, index, lengthLeft));
4263 }
4264 lengthLeft -= length;
4265 });
4266 return lines;
4267 };
4268 return getLines(this, index, length);
4269 }
4270 }, {
4271 key: 'optimize',
4272 value: function optimize() {
4273 var mutations = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
4274 var context = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
4275
4276 if (this.batch === true) return;
4277 _get(Scroll.prototype.__proto__ || Object.getPrototypeOf(Scroll.prototype), 'optimize', this).call(this, mutations, context);
4278 if (mutations.length > 0) {
4279 this.emitter.emit(_emitter2.default.events.SCROLL_OPTIMIZE, mutations, context);
4280 }
4281 }
4282 }, {
4283 key: 'path',
4284 value: function path(index) {
4285 return _get(Scroll.prototype.__proto__ || Object.getPrototypeOf(Scroll.prototype), 'path', this).call(this, index).slice(1); // Exclude self
4286 }
4287 }, {
4288 key: 'update',
4289 value: function update(mutations) {
4290 if (this.batch === true) return;
4291 var source = _emitter2.default.sources.USER;
4292 if (typeof mutations === 'string') {
4293 source = mutations;
4294 }
4295 if (!Array.isArray(mutations)) {
4296 mutations = this.observer.takeRecords();
4297 }
4298 if (mutations.length > 0) {
4299 this.emitter.emit(_emitter2.default.events.SCROLL_BEFORE_UPDATE, source, mutations);
4300 }
4301 _get(Scroll.prototype.__proto__ || Object.getPrototypeOf(Scroll.prototype), 'update', this).call(this, mutations.concat([])); // pass copy
4302 if (mutations.length > 0) {
4303 this.emitter.emit(_emitter2.default.events.SCROLL_UPDATE, source, mutations);
4304 }
4305 }
4306 }]);
4307
4308 return Scroll;
4309}(_parchment2.default.Scroll);
4310
4311Scroll.blotName = 'scroll';
4312Scroll.className = 'ql-editor';
4313Scroll.tagName = 'DIV';
4314Scroll.defaultChild = 'block';
4315Scroll.allowedChildren = [_block2.default, _block.BlockEmbed, _container2.default];
4316
4317exports.default = Scroll;
4318
4319/***/ }),
4320/* 23 */
4321/***/ (function(module, exports, __webpack_require__) {
4322
4323"use strict";
4324
4325
4326Object.defineProperty(exports, "__esModule", {
4327 value: true
4328});
4329
4330var _slicedToArray = function () { function sliceIterator(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"]) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } return function (arr, i) { if (Array.isArray(arr)) { return arr; } else if (Symbol.iterator in Object(arr)) { return sliceIterator(arr, i); } else { throw new TypeError("Invalid attempt to destructure non-iterable instance"); } }; }();
4331
4332var _get = function get(object, property, receiver) { if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { return get(parent, property, receiver); } } else if ("value" in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } };
4333
4334var _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; }; }();
4335
4336var _parchment = __webpack_require__(0);
4337
4338var _parchment2 = _interopRequireDefault(_parchment);
4339
4340var _text = __webpack_require__(7);
4341
4342var _text2 = _interopRequireDefault(_text);
4343
4344function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
4345
4346function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
4347
4348function _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; }
4349
4350function _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; }
4351
4352var Cursor = function (_Parchment$Embed) {
4353 _inherits(Cursor, _Parchment$Embed);
4354
4355 _createClass(Cursor, null, [{
4356 key: 'value',
4357 value: function value() {
4358 return undefined;
4359 }
4360 }]);
4361
4362 function Cursor(domNode, selection) {
4363 _classCallCheck(this, Cursor);
4364
4365 var _this = _possibleConstructorReturn(this, (Cursor.__proto__ || Object.getPrototypeOf(Cursor)).call(this, domNode));
4366
4367 _this.selection = selection;
4368 _this.textNode = document.createTextNode(Cursor.CONTENTS);
4369 _this.domNode.appendChild(_this.textNode);
4370 _this._length = 0;
4371 return _this;
4372 }
4373
4374 _createClass(Cursor, [{
4375 key: 'detach',
4376 value: function detach() {
4377 // super.detach() will also clear domNode.__blot
4378 if (this.parent != null) this.parent.removeChild(this);
4379 }
4380 }, {
4381 key: 'format',
4382 value: function format(name, value) {
4383 if (this._length !== 0) {
4384 return _get(Cursor.prototype.__proto__ || Object.getPrototypeOf(Cursor.prototype), 'format', this).call(this, name, value);
4385 }
4386 var target = this,
4387 index = 0;
4388 while (target != null && target.statics.scope !== _parchment2.default.Scope.BLOCK_BLOT) {
4389 index += target.offset(target.parent);
4390 target = target.parent;
4391 }
4392 if (target != null) {
4393 this._length = Cursor.CONTENTS.length;
4394 target.optimize();
4395 target.formatAt(index, Cursor.CONTENTS.length, name, value);
4396 this._length = 0;
4397 }
4398 }
4399 }, {
4400 key: 'index',
4401 value: function index(node, offset) {
4402 if (node === this.textNode) return 0;
4403 return _get(Cursor.prototype.__proto__ || Object.getPrototypeOf(Cursor.prototype), 'index', this).call(this, node, offset);
4404 }
4405 }, {
4406 key: 'length',
4407 value: function length() {
4408 return this._length;
4409 }
4410 }, {
4411 key: 'position',
4412 value: function position() {
4413 return [this.textNode, this.textNode.data.length];
4414 }
4415 }, {
4416 key: 'remove',
4417 value: function remove() {
4418 _get(Cursor.prototype.__proto__ || Object.getPrototypeOf(Cursor.prototype), 'remove', this).call(this);
4419 this.parent = null;
4420 }
4421 }, {
4422 key: 'restore',
4423 value: function restore() {
4424 if (this.selection.composing || this.parent == null) return;
4425 var textNode = this.textNode;
4426 var range = this.selection.getNativeRange();
4427 var restoreText = void 0,
4428 start = void 0,
4429 end = void 0;
4430 if (range != null && range.start.node === textNode && range.end.node === textNode) {
4431 var _ref = [textNode, range.start.offset, range.end.offset];
4432 restoreText = _ref[0];
4433 start = _ref[1];
4434 end = _ref[2];
4435 }
4436 // Link format will insert text outside of anchor tag
4437 while (this.domNode.lastChild != null && this.domNode.lastChild !== this.textNode) {
4438 this.domNode.parentNode.insertBefore(this.domNode.lastChild, this.domNode);
4439 }
4440 if (this.textNode.data !== Cursor.CONTENTS) {
4441 var text = this.textNode.data.split(Cursor.CONTENTS).join('');
4442 if (this.next instanceof _text2.default) {
4443 restoreText = this.next.domNode;
4444 this.next.insertAt(0, text);
4445 this.textNode.data = Cursor.CONTENTS;
4446 } else {
4447 this.textNode.data = text;
4448 this.parent.insertBefore(_parchment2.default.create(this.textNode), this);
4449 this.textNode = document.createTextNode(Cursor.CONTENTS);
4450 this.domNode.appendChild(this.textNode);
4451 }
4452 }
4453 this.remove();
4454 if (start != null) {
4455 var _map = [start, end].map(function (offset) {
4456 return Math.max(0, Math.min(restoreText.data.length, offset - 1));
4457 });
4458
4459 var _map2 = _slicedToArray(_map, 2);
4460
4461 start = _map2[0];
4462 end = _map2[1];
4463
4464 return {
4465 startNode: restoreText,
4466 startOffset: start,
4467 endNode: restoreText,
4468 endOffset: end
4469 };
4470 }
4471 }
4472 }, {
4473 key: 'update',
4474 value: function update(mutations, context) {
4475 var _this2 = this;
4476
4477 if (mutations.some(function (mutation) {
4478 return mutation.type === 'characterData' && mutation.target === _this2.textNode;
4479 })) {
4480 var range = this.restore();
4481 if (range) context.range = range;
4482 }
4483 }
4484 }, {
4485 key: 'value',
4486 value: function value() {
4487 return '';
4488 }
4489 }]);
4490
4491 return Cursor;
4492}(_parchment2.default.Embed);
4493
4494Cursor.blotName = 'cursor';
4495Cursor.className = 'ql-cursor';
4496Cursor.tagName = 'span';
4497Cursor.CONTENTS = '\uFEFF'; // Zero width no break space
4498
4499
4500exports.default = Cursor;
4501
4502/***/ }),
4503/* 24 */
4504/***/ (function(module, exports, __webpack_require__) {
4505
4506"use strict";
4507
4508
4509Object.defineProperty(exports, "__esModule", {
4510 value: true
4511});
4512
4513var _parchment = __webpack_require__(0);
4514
4515var _parchment2 = _interopRequireDefault(_parchment);
4516
4517var _block = __webpack_require__(4);
4518
4519var _block2 = _interopRequireDefault(_block);
4520
4521function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
4522
4523function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
4524
4525function _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; }
4526
4527function _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; }
4528
4529var Container = function (_Parchment$Container) {
4530 _inherits(Container, _Parchment$Container);
4531
4532 function Container() {
4533 _classCallCheck(this, Container);
4534
4535 return _possibleConstructorReturn(this, (Container.__proto__ || Object.getPrototypeOf(Container)).apply(this, arguments));
4536 }
4537
4538 return Container;
4539}(_parchment2.default.Container);
4540
4541Container.allowedChildren = [_block2.default, _block.BlockEmbed, Container];
4542
4543exports.default = Container;
4544
4545/***/ }),
4546/* 25 */
4547/***/ (function(module, exports, __webpack_require__) {
4548
4549"use strict";
4550
4551
4552Object.defineProperty(exports, "__esModule", {
4553 value: true
4554});
4555
4556var _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; }; }();
4557
4558var _get = function get(object, property, receiver) { if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { return get(parent, property, receiver); } } else if ("value" in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } };
4559
4560var _parchment = __webpack_require__(0);
4561
4562var _parchment2 = _interopRequireDefault(_parchment);
4563
4564var _text = __webpack_require__(7);
4565
4566var _text2 = _interopRequireDefault(_text);
4567
4568function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
4569
4570function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
4571
4572function _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; }
4573
4574function _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; }
4575
4576var GUARD_TEXT = '\uFEFF';
4577
4578var Embed = function (_Parchment$Embed) {
4579 _inherits(Embed, _Parchment$Embed);
4580
4581 function Embed(node) {
4582 _classCallCheck(this, Embed);
4583
4584 var _this = _possibleConstructorReturn(this, (Embed.__proto__ || Object.getPrototypeOf(Embed)).call(this, node));
4585
4586 _this.contentNode = document.createElement('span');
4587 _this.contentNode.setAttribute('contenteditable', false);
4588 [].slice.call(_this.domNode.childNodes).forEach(function (childNode) {
4589 _this.contentNode.appendChild(childNode);
4590 });
4591 _this.leftGuard = document.createTextNode(GUARD_TEXT);
4592 _this.rightGuard = document.createTextNode(GUARD_TEXT);
4593 _this.domNode.appendChild(_this.leftGuard);
4594 _this.domNode.appendChild(_this.contentNode);
4595 _this.domNode.appendChild(_this.rightGuard);
4596 return _this;
4597 }
4598
4599 _createClass(Embed, [{
4600 key: 'index',
4601 value: function index(node, offset) {
4602 if (node === this.leftGuard) return 0;
4603 if (node === this.rightGuard) return 1;
4604 return _get(Embed.prototype.__proto__ || Object.getPrototypeOf(Embed.prototype), 'index', this).call(this, node, offset);
4605 }
4606 }, {
4607 key: 'restore',
4608 value: function restore(node) {
4609 var range = void 0,
4610 textNode = void 0;
4611 var text = node.data.split(GUARD_TEXT).join('');
4612 if (node === this.leftGuard) {
4613 if (this.prev instanceof _text2.default) {
4614 var prevLength = this.prev.length();
4615 this.prev.insertAt(prevLength, text);
4616 range = {
4617 startNode: this.prev.domNode,
4618 startOffset: prevLength + text.length
4619 };
4620 } else {
4621 textNode = document.createTextNode(text);
4622 this.parent.insertBefore(_parchment2.default.create(textNode), this);
4623 range = {
4624 startNode: textNode,
4625 startOffset: text.length
4626 };
4627 }
4628 } else if (node === this.rightGuard) {
4629 if (this.next instanceof _text2.default) {
4630 this.next.insertAt(0, text);
4631 range = {
4632 startNode: this.next.domNode,
4633 startOffset: text.length
4634 };
4635 } else {
4636 textNode = document.createTextNode(text);
4637 this.parent.insertBefore(_parchment2.default.create(textNode), this.next);
4638 range = {
4639 startNode: textNode,
4640 startOffset: text.length
4641 };
4642 }
4643 }
4644 node.data = GUARD_TEXT;
4645 return range;
4646 }
4647 }, {
4648 key: 'update',
4649 value: function update(mutations, context) {
4650 var _this2 = this;
4651
4652 mutations.forEach(function (mutation) {
4653 if (mutation.type === 'characterData' && (mutation.target === _this2.leftGuard || mutation.target === _this2.rightGuard)) {
4654 var range = _this2.restore(mutation.target);
4655 if (range) context.range = range;
4656 }
4657 });
4658 }
4659 }]);
4660
4661 return Embed;
4662}(_parchment2.default.Embed);
4663
4664exports.default = Embed;
4665
4666/***/ }),
4667/* 26 */
4668/***/ (function(module, exports, __webpack_require__) {
4669
4670"use strict";
4671
4672
4673Object.defineProperty(exports, "__esModule", {
4674 value: true
4675});
4676exports.ColorStyle = exports.ColorClass = exports.ColorAttributor = undefined;
4677
4678var _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; }; }();
4679
4680var _get = function get(object, property, receiver) { if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { return get(parent, property, receiver); } } else if ("value" in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } };
4681
4682var _parchment = __webpack_require__(0);
4683
4684var _parchment2 = _interopRequireDefault(_parchment);
4685
4686function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
4687
4688function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
4689
4690function _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; }
4691
4692function _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; }
4693
4694var ColorAttributor = function (_Parchment$Attributor) {
4695 _inherits(ColorAttributor, _Parchment$Attributor);
4696
4697 function ColorAttributor() {
4698 _classCallCheck(this, ColorAttributor);
4699
4700 return _possibleConstructorReturn(this, (ColorAttributor.__proto__ || Object.getPrototypeOf(ColorAttributor)).apply(this, arguments));
4701 }
4702
4703 _createClass(ColorAttributor, [{
4704 key: 'value',
4705 value: function value(domNode) {
4706 var value = _get(ColorAttributor.prototype.__proto__ || Object.getPrototypeOf(ColorAttributor.prototype), 'value', this).call(this, domNode);
4707 if (!value.startsWith('rgb(')) return value;
4708 value = value.replace(/^[^\d]+/, '').replace(/[^\d]+$/, '');
4709 return '#' + value.split(',').map(function (component) {
4710 return ('00' + parseInt(component).toString(16)).slice(-2);
4711 }).join('');
4712 }
4713 }]);
4714
4715 return ColorAttributor;
4716}(_parchment2.default.Attributor.Style);
4717
4718var ColorClass = new _parchment2.default.Attributor.Class('color', 'ql-color', {
4719 scope: _parchment2.default.Scope.INLINE
4720});
4721var ColorStyle = new ColorAttributor('color', 'color', {
4722 scope: _parchment2.default.Scope.INLINE
4723});
4724
4725exports.ColorAttributor = ColorAttributor;
4726exports.ColorClass = ColorClass;
4727exports.ColorStyle = ColorStyle;
4728
4729/***/ }),
4730/* 27 */,
4731/* 28 */,
4732/* 29 */
4733/***/ (function(module, exports, __webpack_require__) {
4734
4735"use strict";
4736
4737
4738var _parchment = __webpack_require__(0);
4739
4740var _parchment2 = _interopRequireDefault(_parchment);
4741
4742var _quill = __webpack_require__(5);
4743
4744var _quill2 = _interopRequireDefault(_quill);
4745
4746var _block = __webpack_require__(4);
4747
4748var _block2 = _interopRequireDefault(_block);
4749
4750var _break = __webpack_require__(16);
4751
4752var _break2 = _interopRequireDefault(_break);
4753
4754var _container = __webpack_require__(24);
4755
4756var _container2 = _interopRequireDefault(_container);
4757
4758var _cursor = __webpack_require__(23);
4759
4760var _cursor2 = _interopRequireDefault(_cursor);
4761
4762var _embed = __webpack_require__(25);
4763
4764var _embed2 = _interopRequireDefault(_embed);
4765
4766var _inline = __webpack_require__(6);
4767
4768var _inline2 = _interopRequireDefault(_inline);
4769
4770var _scroll = __webpack_require__(22);
4771
4772var _scroll2 = _interopRequireDefault(_scroll);
4773
4774var _text = __webpack_require__(7);
4775
4776var _text2 = _interopRequireDefault(_text);
4777
4778var _clipboard = __webpack_require__(55);
4779
4780var _clipboard2 = _interopRequireDefault(_clipboard);
4781
4782var _history = __webpack_require__(42);
4783
4784var _history2 = _interopRequireDefault(_history);
4785
4786var _keyboard = __webpack_require__(35);
4787
4788var _keyboard2 = _interopRequireDefault(_keyboard);
4789
4790function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
4791
4792_quill2.default.register({
4793 'blots/block': _block2.default,
4794 'blots/block/embed': _block.BlockEmbed,
4795 'blots/break': _break2.default,
4796 'blots/container': _container2.default,
4797 'blots/cursor': _cursor2.default,
4798 'blots/embed': _embed2.default,
4799 'blots/inline': _inline2.default,
4800 'blots/scroll': _scroll2.default,
4801 'blots/text': _text2.default,
4802
4803 'modules/clipboard': _clipboard2.default,
4804 'modules/history': _history2.default,
4805 'modules/keyboard': _keyboard2.default
4806});
4807
4808_parchment2.default.register(_block2.default, _break2.default, _cursor2.default, _inline2.default, _scroll2.default, _text2.default);
4809
4810module.exports = _quill2.default;
4811
4812/***/ }),
4813/* 30 */
4814/***/ (function(module, exports, __webpack_require__) {
4815
4816"use strict";
4817
4818Object.defineProperty(exports, "__esModule", { value: true });
4819var Registry = __webpack_require__(1);
4820var ShadowBlot = /** @class */ (function () {
4821 function ShadowBlot(domNode) {
4822 this.domNode = domNode;
4823 this.attach();
4824 }
4825 Object.defineProperty(ShadowBlot.prototype, "statics", {
4826 // Hack for accessing inherited static methods
4827 get: function () {
4828 return this.constructor;
4829 },
4830 enumerable: true,
4831 configurable: true
4832 });
4833 ShadowBlot.create = function (value) {
4834 if (this.tagName == null) {
4835 throw new Registry.ParchmentError('Blot definition missing tagName');
4836 }
4837 var node;
4838 if (Array.isArray(this.tagName)) {
4839 if (typeof value === 'string') {
4840 value = value.toUpperCase();
4841 if (parseInt(value).toString() === value) {
4842 value = parseInt(value);
4843 }
4844 }
4845 if (typeof value === 'number') {
4846 node = document.createElement(this.tagName[value - 1]);
4847 }
4848 else if (this.tagName.indexOf(value) > -1) {
4849 node = document.createElement(value);
4850 }
4851 else {
4852 node = document.createElement(this.tagName[0]);
4853 }
4854 }
4855 else {
4856 node = document.createElement(this.tagName);
4857 }
4858 if (this.className) {
4859 node.classList.add(this.className);
4860 }
4861 return node;
4862 };
4863 ShadowBlot.prototype.attach = function () {
4864 this.domNode[Registry.DATA_KEY] = { blot: this };
4865 };
4866 ShadowBlot.prototype.clone = function () {
4867 var domNode = this.domNode.cloneNode(false);
4868 return Registry.create(domNode);
4869 };
4870 ShadowBlot.prototype.detach = function () {
4871 if (this.parent != null)
4872 this.parent.removeChild(this);
4873 delete this.domNode[Registry.DATA_KEY];
4874 };
4875 ShadowBlot.prototype.deleteAt = function (index, length) {
4876 var blot = this.isolate(index, length);
4877 blot.remove();
4878 };
4879 ShadowBlot.prototype.formatAt = function (index, length, name, value) {
4880 var blot = this.isolate(index, length);
4881 if (Registry.query(name, Registry.Scope.BLOT) != null && value) {
4882 blot.wrap(name, value);
4883 }
4884 else if (Registry.query(name, Registry.Scope.ATTRIBUTE) != null) {
4885 var parent = Registry.create(this.statics.scope);
4886 blot.wrap(parent);
4887 parent.format(name, value);
4888 }
4889 };
4890 ShadowBlot.prototype.insertAt = function (index, value, def) {
4891 var blot = (def == null) ? Registry.create('text', value) : Registry.create(value, def);
4892 var ref = this.split(index);
4893 this.parent.insertBefore(blot, ref);
4894 };
4895 ShadowBlot.prototype.insertInto = function (parentBlot, refBlot) {
4896 if (this.parent != null) {
4897 this.parent.children.remove(this);
4898 }
4899 parentBlot.children.insertBefore(this, refBlot);
4900 if (refBlot != null) {
4901 var refDomNode = refBlot.domNode;
4902 }
4903 if (this.next == null || this.domNode.nextSibling != refDomNode) {
4904 parentBlot.domNode.insertBefore(this.domNode, (typeof refDomNode !== 'undefined') ? refDomNode : null);
4905 }
4906 this.parent = parentBlot;
4907 };
4908 ShadowBlot.prototype.isolate = function (index, length) {
4909 var target = this.split(index);
4910 target.split(length);
4911 return target;
4912 };
4913 ShadowBlot.prototype.length = function () {
4914 return 1;
4915 };
4916 ;
4917 ShadowBlot.prototype.offset = function (root) {
4918 if (root === void 0) { root = this.parent; }
4919 if (this.parent == null || this == root)
4920 return 0;
4921 return this.parent.children.offset(this) + this.parent.offset(root);
4922 };
4923 ShadowBlot.prototype.optimize = function (context) {
4924 // TODO clean up once we use WeakMap
4925 if (this.domNode[Registry.DATA_KEY] != null) {
4926 delete this.domNode[Registry.DATA_KEY].mutations;
4927 }
4928 };
4929 ShadowBlot.prototype.remove = function () {
4930 if (this.domNode.parentNode != null) {
4931 this.domNode.parentNode.removeChild(this.domNode);
4932 }
4933 this.detach();
4934 };
4935 ShadowBlot.prototype.replace = function (target) {
4936 if (target.parent == null)
4937 return;
4938 target.parent.insertBefore(this, target.next);
4939 target.remove();
4940 };
4941 ShadowBlot.prototype.replaceWith = function (name, value) {
4942 var replacement = typeof name === 'string' ? Registry.create(name, value) : name;
4943 replacement.replace(this);
4944 return replacement;
4945 };
4946 ShadowBlot.prototype.split = function (index, force) {
4947 return index === 0 ? this : this.next;
4948 };
4949 ShadowBlot.prototype.update = function (mutations, context) {
4950 // Nothing to do by default
4951 };
4952 ShadowBlot.prototype.wrap = function (name, value) {
4953 var wrapper = typeof name === 'string' ? Registry.create(name, value) : name;
4954 if (this.parent != null) {
4955 this.parent.insertBefore(wrapper, this.next);
4956 }
4957 wrapper.appendChild(this);
4958 return wrapper;
4959 };
4960 ShadowBlot.blotName = 'abstract';
4961 return ShadowBlot;
4962}());
4963exports.default = ShadowBlot;
4964
4965
4966/***/ }),
4967/* 31 */
4968/***/ (function(module, exports, __webpack_require__) {
4969
4970"use strict";
4971
4972Object.defineProperty(exports, "__esModule", { value: true });
4973var attributor_1 = __webpack_require__(12);
4974var class_1 = __webpack_require__(32);
4975var style_1 = __webpack_require__(33);
4976var Registry = __webpack_require__(1);
4977var AttributorStore = /** @class */ (function () {
4978 function AttributorStore(domNode) {
4979 this.attributes = {};
4980 this.domNode = domNode;
4981 this.build();
4982 }
4983 AttributorStore.prototype.attribute = function (attribute, value) {
4984 if (value) {
4985 if (attribute.add(this.domNode, value)) {
4986 if (attribute.value(this.domNode) != null) {
4987 this.attributes[attribute.attrName] = attribute;
4988 }
4989 else {
4990 delete this.attributes[attribute.attrName];
4991 }
4992 }
4993 }
4994 else {
4995 attribute.remove(this.domNode);
4996 delete this.attributes[attribute.attrName];
4997 }
4998 };
4999 AttributorStore.prototype.build = function () {
5000 var _this = this;
5001 this.attributes = {};
5002 var attributes = attributor_1.default.keys(this.domNode);
5003 var classes = class_1.default.keys(this.domNode);
5004 var styles = style_1.default.keys(this.domNode);
5005 attributes.concat(classes).concat(styles).forEach(function (name) {
5006 var attr = Registry.query(name, Registry.Scope.ATTRIBUTE);
5007 if (attr instanceof attributor_1.default) {
5008 _this.attributes[attr.attrName] = attr;
5009 }
5010 });
5011 };
5012 AttributorStore.prototype.copy = function (target) {
5013 var _this = this;
5014 Object.keys(this.attributes).forEach(function (key) {
5015 var value = _this.attributes[key].value(_this.domNode);
5016 target.format(key, value);
5017 });
5018 };
5019 AttributorStore.prototype.move = function (target) {
5020 var _this = this;
5021 this.copy(target);
5022 Object.keys(this.attributes).forEach(function (key) {
5023 _this.attributes[key].remove(_this.domNode);
5024 });
5025 this.attributes = {};
5026 };
5027 AttributorStore.prototype.values = function () {
5028 var _this = this;
5029 return Object.keys(this.attributes).reduce(function (attributes, name) {
5030 attributes[name] = _this.attributes[name].value(_this.domNode);
5031 return attributes;
5032 }, {});
5033 };
5034 return AttributorStore;
5035}());
5036exports.default = AttributorStore;
5037
5038
5039/***/ }),
5040/* 32 */
5041/***/ (function(module, exports, __webpack_require__) {
5042
5043"use strict";
5044
5045var __extends = (this && this.__extends) || (function () {
5046 var extendStatics = Object.setPrototypeOf ||
5047 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
5048 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
5049 return function (d, b) {
5050 extendStatics(d, b);
5051 function __() { this.constructor = d; }
5052 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
5053 };
5054})();
5055Object.defineProperty(exports, "__esModule", { value: true });
5056var attributor_1 = __webpack_require__(12);
5057function match(node, prefix) {
5058 var className = node.getAttribute('class') || '';
5059 return className.split(/\s+/).filter(function (name) {
5060 return name.indexOf(prefix + "-") === 0;
5061 });
5062}
5063var ClassAttributor = /** @class */ (function (_super) {
5064 __extends(ClassAttributor, _super);
5065 function ClassAttributor() {
5066 return _super !== null && _super.apply(this, arguments) || this;
5067 }
5068 ClassAttributor.keys = function (node) {
5069 return (node.getAttribute('class') || '').split(/\s+/).map(function (name) {
5070 return name.split('-').slice(0, -1).join('-');
5071 });
5072 };
5073 ClassAttributor.prototype.add = function (node, value) {
5074 if (!this.canAdd(node, value))
5075 return false;
5076 this.remove(node);
5077 node.classList.add(this.keyName + "-" + value);
5078 return true;
5079 };
5080 ClassAttributor.prototype.remove = function (node) {
5081 var matches = match(node, this.keyName);
5082 matches.forEach(function (name) {
5083 node.classList.remove(name);
5084 });
5085 if (node.classList.length === 0) {
5086 node.removeAttribute('class');
5087 }
5088 };
5089 ClassAttributor.prototype.value = function (node) {
5090 var result = match(node, this.keyName)[0] || '';
5091 var value = result.slice(this.keyName.length + 1); // +1 for hyphen
5092 return this.canAdd(node, value) ? value : '';
5093 };
5094 return ClassAttributor;
5095}(attributor_1.default));
5096exports.default = ClassAttributor;
5097
5098
5099/***/ }),
5100/* 33 */
5101/***/ (function(module, exports, __webpack_require__) {
5102
5103"use strict";
5104
5105var __extends = (this && this.__extends) || (function () {
5106 var extendStatics = Object.setPrototypeOf ||
5107 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
5108 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
5109 return function (d, b) {
5110 extendStatics(d, b);
5111 function __() { this.constructor = d; }
5112 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
5113 };
5114})();
5115Object.defineProperty(exports, "__esModule", { value: true });
5116var attributor_1 = __webpack_require__(12);
5117function camelize(name) {
5118 var parts = name.split('-');
5119 var rest = parts.slice(1).map(function (part) {
5120 return part[0].toUpperCase() + part.slice(1);
5121 }).join('');
5122 return parts[0] + rest;
5123}
5124var StyleAttributor = /** @class */ (function (_super) {
5125 __extends(StyleAttributor, _super);
5126 function StyleAttributor() {
5127 return _super !== null && _super.apply(this, arguments) || this;
5128 }
5129 StyleAttributor.keys = function (node) {
5130 return (node.getAttribute('style') || '').split(';').map(function (value) {
5131 var arr = value.split(':');
5132 return arr[0].trim();
5133 });
5134 };
5135 StyleAttributor.prototype.add = function (node, value) {
5136 if (!this.canAdd(node, value))
5137 return false;
5138 node.style[camelize(this.keyName)] = value;
5139 return true;
5140 };
5141 StyleAttributor.prototype.remove = function (node) {
5142 node.style[camelize(this.keyName)] = '';
5143 if (!node.getAttribute('style')) {
5144 node.removeAttribute('style');
5145 }
5146 };
5147 StyleAttributor.prototype.value = function (node) {
5148 var value = node.style[camelize(this.keyName)];
5149 return this.canAdd(node, value) ? value : '';
5150 };
5151 return StyleAttributor;
5152}(attributor_1.default));
5153exports.default = StyleAttributor;
5154
5155
5156/***/ }),
5157/* 34 */
5158/***/ (function(module, exports, __webpack_require__) {
5159
5160"use strict";
5161
5162
5163Object.defineProperty(exports, "__esModule", {
5164 value: true
5165});
5166
5167var _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; }; }();
5168
5169function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
5170
5171var Theme = function () {
5172 function Theme(quill, options) {
5173 _classCallCheck(this, Theme);
5174
5175 this.quill = quill;
5176 this.options = options;
5177 this.modules = {};
5178 }
5179
5180 _createClass(Theme, [{
5181 key: 'init',
5182 value: function init() {
5183 var _this = this;
5184
5185 Object.keys(this.options.modules).forEach(function (name) {
5186 if (_this.modules[name] == null) {
5187 _this.addModule(name);
5188 }
5189 });
5190 }
5191 }, {
5192 key: 'addModule',
5193 value: function addModule(name) {
5194 var moduleClass = this.quill.constructor.import('modules/' + name);
5195 this.modules[name] = new moduleClass(this.quill, this.options.modules[name] || {});
5196 return this.modules[name];
5197 }
5198 }]);
5199
5200 return Theme;
5201}();
5202
5203Theme.DEFAULTS = {
5204 modules: {}
5205};
5206Theme.themes = {
5207 'default': Theme
5208};
5209
5210exports.default = Theme;
5211
5212/***/ }),
5213/* 35 */
5214/***/ (function(module, exports, __webpack_require__) {
5215
5216"use strict";
5217
5218
5219Object.defineProperty(exports, "__esModule", {
5220 value: true
5221});
5222exports.SHORTKEY = exports.default = undefined;
5223
5224var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
5225
5226var _slicedToArray = function () { function sliceIterator(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"]) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } return function (arr, i) { if (Array.isArray(arr)) { return arr; } else if (Symbol.iterator in Object(arr)) { return sliceIterator(arr, i); } else { throw new TypeError("Invalid attempt to destructure non-iterable instance"); } }; }();
5227
5228var _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; }; }();
5229
5230var _clone = __webpack_require__(21);
5231
5232var _clone2 = _interopRequireDefault(_clone);
5233
5234var _deepEqual = __webpack_require__(11);
5235
5236var _deepEqual2 = _interopRequireDefault(_deepEqual);
5237
5238var _extend = __webpack_require__(3);
5239
5240var _extend2 = _interopRequireDefault(_extend);
5241
5242var _quillDelta = __webpack_require__(2);
5243
5244var _quillDelta2 = _interopRequireDefault(_quillDelta);
5245
5246var _op = __webpack_require__(20);
5247
5248var _op2 = _interopRequireDefault(_op);
5249
5250var _parchment = __webpack_require__(0);
5251
5252var _parchment2 = _interopRequireDefault(_parchment);
5253
5254var _embed = __webpack_require__(25);
5255
5256var _embed2 = _interopRequireDefault(_embed);
5257
5258var _quill = __webpack_require__(5);
5259
5260var _quill2 = _interopRequireDefault(_quill);
5261
5262var _logger = __webpack_require__(10);
5263
5264var _logger2 = _interopRequireDefault(_logger);
5265
5266var _module = __webpack_require__(9);
5267
5268var _module2 = _interopRequireDefault(_module);
5269
5270function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
5271
5272function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
5273
5274function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
5275
5276function _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; }
5277
5278function _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; }
5279
5280var debug = (0, _logger2.default)('quill:keyboard');
5281
5282var SHORTKEY = /Mac/i.test(navigator.platform) ? 'metaKey' : 'ctrlKey';
5283
5284var Keyboard = function (_Module) {
5285 _inherits(Keyboard, _Module);
5286
5287 _createClass(Keyboard, null, [{
5288 key: 'match',
5289 value: function match(evt, binding) {
5290 binding = normalize(binding);
5291 if (['altKey', 'ctrlKey', 'metaKey', 'shiftKey'].some(function (key) {
5292 return !!binding[key] !== evt[key] && binding[key] !== null;
5293 })) {
5294 return false;
5295 }
5296 return binding.key === (evt.which || evt.keyCode);
5297 }
5298 }]);
5299
5300 function Keyboard(quill, options) {
5301 _classCallCheck(this, Keyboard);
5302
5303 var _this = _possibleConstructorReturn(this, (Keyboard.__proto__ || Object.getPrototypeOf(Keyboard)).call(this, quill, options));
5304
5305 _this.bindings = {};
5306 Object.keys(_this.options.bindings).forEach(function (name) {
5307 if (name === 'list autofill' && quill.scroll.whitelist != null && !quill.scroll.whitelist['list']) {
5308 return;
5309 }
5310 if (_this.options.bindings[name]) {
5311 _this.addBinding(_this.options.bindings[name]);
5312 }
5313 });
5314 _this.addBinding({ key: Keyboard.keys.ENTER, shiftKey: null }, handleEnter);
5315 _this.addBinding({ key: Keyboard.keys.ENTER, metaKey: null, ctrlKey: null, altKey: null }, function () {});
5316 if (/Firefox/i.test(navigator.userAgent)) {
5317 // Need to handle delete and backspace for Firefox in the general case #1171
5318 _this.addBinding({ key: Keyboard.keys.BACKSPACE }, { collapsed: true }, handleBackspace);
5319 _this.addBinding({ key: Keyboard.keys.DELETE }, { collapsed: true }, handleDelete);
5320 } else {
5321 _this.addBinding({ key: Keyboard.keys.BACKSPACE }, { collapsed: true, prefix: /^.?$/ }, handleBackspace);
5322 _this.addBinding({ key: Keyboard.keys.DELETE }, { collapsed: true, suffix: /^.?$/ }, handleDelete);
5323 }
5324 _this.addBinding({ key: Keyboard.keys.BACKSPACE }, { collapsed: false }, handleDeleteRange);
5325 _this.addBinding({ key: Keyboard.keys.DELETE }, { collapsed: false }, handleDeleteRange);
5326 _this.addBinding({ key: Keyboard.keys.BACKSPACE, altKey: null, ctrlKey: null, metaKey: null, shiftKey: null }, { collapsed: true, offset: 0 }, handleBackspace);
5327 _this.listen();
5328 return _this;
5329 }
5330
5331 _createClass(Keyboard, [{
5332 key: 'addBinding',
5333 value: function addBinding(key) {
5334 var context = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
5335 var handler = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
5336
5337 var binding = normalize(key);
5338 if (binding == null || binding.key == null) {
5339 return debug.warn('Attempted to add invalid keyboard binding', binding);
5340 }
5341 if (typeof context === 'function') {
5342 context = { handler: context };
5343 }
5344 if (typeof handler === 'function') {
5345 handler = { handler: handler };
5346 }
5347 binding = (0, _extend2.default)(binding, context, handler);
5348 this.bindings[binding.key] = this.bindings[binding.key] || [];
5349 this.bindings[binding.key].push(binding);
5350 }
5351 }, {
5352 key: 'listen',
5353 value: function listen() {
5354 var _this2 = this;
5355
5356 this.quill.root.addEventListener('keydown', function (evt) {
5357 if (evt.defaultPrevented) return;
5358 var which = evt.which || evt.keyCode;
5359 var bindings = (_this2.bindings[which] || []).filter(function (binding) {
5360 return Keyboard.match(evt, binding);
5361 });
5362 if (bindings.length === 0) return;
5363 var range = _this2.quill.getSelection();
5364 if (range == null || !_this2.quill.hasFocus()) return;
5365
5366 var _quill$getLine = _this2.quill.getLine(range.index),
5367 _quill$getLine2 = _slicedToArray(_quill$getLine, 2),
5368 line = _quill$getLine2[0],
5369 offset = _quill$getLine2[1];
5370
5371 var _quill$getLeaf = _this2.quill.getLeaf(range.index),
5372 _quill$getLeaf2 = _slicedToArray(_quill$getLeaf, 2),
5373 leafStart = _quill$getLeaf2[0],
5374 offsetStart = _quill$getLeaf2[1];
5375
5376 var _ref = range.length === 0 ? [leafStart, offsetStart] : _this2.quill.getLeaf(range.index + range.length),
5377 _ref2 = _slicedToArray(_ref, 2),
5378 leafEnd = _ref2[0],
5379 offsetEnd = _ref2[1];
5380
5381 var prefixText = leafStart instanceof _parchment2.default.Text ? leafStart.value().slice(0, offsetStart) : '';
5382 var suffixText = leafEnd instanceof _parchment2.default.Text ? leafEnd.value().slice(offsetEnd) : '';
5383 var curContext = {
5384 collapsed: range.length === 0,
5385 empty: range.length === 0 && line.length() <= 1,
5386 format: _this2.quill.getFormat(range),
5387 offset: offset,
5388 prefix: prefixText,
5389 suffix: suffixText
5390 };
5391 var prevented = bindings.some(function (binding) {
5392 if (binding.collapsed != null && binding.collapsed !== curContext.collapsed) return false;
5393 if (binding.empty != null && binding.empty !== curContext.empty) return false;
5394 if (binding.offset != null && binding.offset !== curContext.offset) return false;
5395 if (Array.isArray(binding.format)) {
5396 // any format is present
5397 if (binding.format.every(function (name) {
5398 return curContext.format[name] == null;
5399 })) {
5400 return false;
5401 }
5402 } else if (_typeof(binding.format) === 'object') {
5403 // all formats must match
5404 if (!Object.keys(binding.format).every(function (name) {
5405 if (binding.format[name] === true) return curContext.format[name] != null;
5406 if (binding.format[name] === false) return curContext.format[name] == null;
5407 return (0, _deepEqual2.default)(binding.format[name], curContext.format[name]);
5408 })) {
5409 return false;
5410 }
5411 }
5412 if (binding.prefix != null && !binding.prefix.test(curContext.prefix)) return false;
5413 if (binding.suffix != null && !binding.suffix.test(curContext.suffix)) return false;
5414 return binding.handler.call(_this2, range, curContext) !== true;
5415 });
5416 if (prevented) {
5417 evt.preventDefault();
5418 }
5419 });
5420 }
5421 }]);
5422
5423 return Keyboard;
5424}(_module2.default);
5425
5426Keyboard.keys = {
5427 BACKSPACE: 8,
5428 TAB: 9,
5429 ENTER: 13,
5430 ESCAPE: 27,
5431 LEFT: 37,
5432 UP: 38,
5433 RIGHT: 39,
5434 DOWN: 40,
5435 DELETE: 46
5436};
5437
5438Keyboard.DEFAULTS = {
5439 bindings: {
5440 'bold': makeFormatHandler('bold'),
5441 'italic': makeFormatHandler('italic'),
5442 'underline': makeFormatHandler('underline'),
5443 'indent': {
5444 // highlight tab or tab at beginning of list, indent or blockquote
5445 key: Keyboard.keys.TAB,
5446 format: ['blockquote', 'indent', 'list'],
5447 handler: function handler(range, context) {
5448 if (context.collapsed && context.offset !== 0) return true;
5449 this.quill.format('indent', '+1', _quill2.default.sources.USER);
5450 }
5451 },
5452 'outdent': {
5453 key: Keyboard.keys.TAB,
5454 shiftKey: true,
5455 format: ['blockquote', 'indent', 'list'],
5456 // highlight tab or tab at beginning of list, indent or blockquote
5457 handler: function handler(range, context) {
5458 if (context.collapsed && context.offset !== 0) return true;
5459 this.quill.format('indent', '-1', _quill2.default.sources.USER);
5460 }
5461 },
5462 'outdent backspace': {
5463 key: Keyboard.keys.BACKSPACE,
5464 collapsed: true,
5465 shiftKey: null,
5466 metaKey: null,
5467 ctrlKey: null,
5468 altKey: null,
5469 format: ['indent', 'list'],
5470 offset: 0,
5471 handler: function handler(range, context) {
5472 if (context.format.indent != null) {
5473 this.quill.format('indent', '-1', _quill2.default.sources.USER);
5474 } else if (context.format.list != null) {
5475 this.quill.format('list', false, _quill2.default.sources.USER);
5476 }
5477 }
5478 },
5479 'indent code-block': makeCodeBlockHandler(true),
5480 'outdent code-block': makeCodeBlockHandler(false),
5481 'remove tab': {
5482 key: Keyboard.keys.TAB,
5483 shiftKey: true,
5484 collapsed: true,
5485 prefix: /\t$/,
5486 handler: function handler(range) {
5487 this.quill.deleteText(range.index - 1, 1, _quill2.default.sources.USER);
5488 }
5489 },
5490 'tab': {
5491 key: Keyboard.keys.TAB,
5492 handler: function handler(range) {
5493 this.quill.history.cutoff();
5494 var delta = new _quillDelta2.default().retain(range.index).delete(range.length).insert('\t');
5495 this.quill.updateContents(delta, _quill2.default.sources.USER);
5496 this.quill.history.cutoff();
5497 this.quill.setSelection(range.index + 1, _quill2.default.sources.SILENT);
5498 }
5499 },
5500 'list empty enter': {
5501 key: Keyboard.keys.ENTER,
5502 collapsed: true,
5503 format: ['list'],
5504 empty: true,
5505 handler: function handler(range, context) {
5506 this.quill.format('list', false, _quill2.default.sources.USER);
5507 if (context.format.indent) {
5508 this.quill.format('indent', false, _quill2.default.sources.USER);
5509 }
5510 }
5511 },
5512 'checklist enter': {
5513 key: Keyboard.keys.ENTER,
5514 collapsed: true,
5515 format: { list: 'checked' },
5516 handler: function handler(range) {
5517 var _quill$getLine3 = this.quill.getLine(range.index),
5518 _quill$getLine4 = _slicedToArray(_quill$getLine3, 2),
5519 line = _quill$getLine4[0],
5520 offset = _quill$getLine4[1];
5521
5522 var delta = new _quillDelta2.default().retain(range.index).insert('\n', { list: 'checked' }).retain(line.length() - offset - 1).retain(1, { list: 'unchecked' });
5523 this.quill.updateContents(delta, _quill2.default.sources.USER);
5524 this.quill.setSelection(range.index + 1, _quill2.default.sources.SILENT);
5525 this.quill.scrollIntoView();
5526 }
5527 },
5528 'header enter': {
5529 key: Keyboard.keys.ENTER,
5530 collapsed: true,
5531 format: ['header'],
5532 suffix: /^$/,
5533 handler: function handler(range, context) {
5534 var _quill$getLine5 = this.quill.getLine(range.index),
5535 _quill$getLine6 = _slicedToArray(_quill$getLine5, 2),
5536 line = _quill$getLine6[0],
5537 offset = _quill$getLine6[1];
5538
5539 var delta = new _quillDelta2.default().retain(range.index).insert('\n', context.format).retain(line.length() - offset - 1).retain(1, { header: null });
5540 this.quill.updateContents(delta, _quill2.default.sources.USER);
5541 this.quill.setSelection(range.index + 1, _quill2.default.sources.SILENT);
5542 this.quill.scrollIntoView();
5543 }
5544 },
5545 'list autofill': {
5546 key: ' ',
5547 collapsed: true,
5548 format: { list: false },
5549 prefix: /^\s*?(1\.|-|\[ ?\]|\[x\])$/,
5550 handler: function handler(range, context) {
5551 var length = context.prefix.length;
5552
5553 var _quill$getLine7 = this.quill.getLine(range.index),
5554 _quill$getLine8 = _slicedToArray(_quill$getLine7, 2),
5555 line = _quill$getLine8[0],
5556 offset = _quill$getLine8[1];
5557
5558 if (offset > length) return true;
5559 var value = void 0;
5560 switch (context.prefix.trim()) {
5561 case '[]':case '[ ]':
5562 value = 'unchecked';
5563 break;
5564 case '[x]':
5565 value = 'checked';
5566 break;
5567 case '-':
5568 value = 'bullet';
5569 break;
5570 default:
5571 value = 'ordered';
5572 }
5573 this.quill.insertText(range.index, ' ', _quill2.default.sources.USER);
5574 this.quill.history.cutoff();
5575 var delta = new _quillDelta2.default().retain(range.index - offset).delete(length + 1).retain(line.length() - 2 - offset).retain(1, { list: value });
5576 this.quill.updateContents(delta, _quill2.default.sources.USER);
5577 this.quill.history.cutoff();
5578 this.quill.setSelection(range.index - length, _quill2.default.sources.SILENT);
5579 }
5580 },
5581 'code exit': {
5582 key: Keyboard.keys.ENTER,
5583 collapsed: true,
5584 format: ['code-block'],
5585 prefix: /\n\n$/,
5586 suffix: /^\s+$/,
5587 handler: function handler(range) {
5588 var _quill$getLine9 = this.quill.getLine(range.index),
5589 _quill$getLine10 = _slicedToArray(_quill$getLine9, 2),
5590 line = _quill$getLine10[0],
5591 offset = _quill$getLine10[1];
5592
5593 var delta = new _quillDelta2.default().retain(range.index + line.length() - offset - 2).retain(1, { 'code-block': null }).delete(1);
5594 this.quill.updateContents(delta, _quill2.default.sources.USER);
5595 }
5596 },
5597 'embed left': makeEmbedArrowHandler(Keyboard.keys.LEFT, false),
5598 'embed left shift': makeEmbedArrowHandler(Keyboard.keys.LEFT, true),
5599 'embed right': makeEmbedArrowHandler(Keyboard.keys.RIGHT, false),
5600 'embed right shift': makeEmbedArrowHandler(Keyboard.keys.RIGHT, true)
5601 }
5602};
5603
5604function makeEmbedArrowHandler(key, shiftKey) {
5605 var _ref3;
5606
5607 var where = key === Keyboard.keys.LEFT ? 'prefix' : 'suffix';
5608 return _ref3 = {
5609 key: key,
5610 shiftKey: shiftKey
5611 }, _defineProperty(_ref3, where, /^$/), _defineProperty(_ref3, 'handler', function handler(range) {
5612 var index = range.index;
5613 if (key === Keyboard.keys.RIGHT) {
5614 index += range.length + 1;
5615 }
5616
5617 var _quill$getLeaf3 = this.quill.getLeaf(index),
5618 _quill$getLeaf4 = _slicedToArray(_quill$getLeaf3, 1),
5619 leaf = _quill$getLeaf4[0];
5620
5621 if (!(leaf instanceof _embed2.default)) return true;
5622 if (key === Keyboard.keys.LEFT) {
5623 if (shiftKey) {
5624 this.quill.setSelection(range.index - 1, range.length + 1, _quill2.default.sources.USER);
5625 } else {
5626 this.quill.setSelection(range.index - 1, _quill2.default.sources.USER);
5627 }
5628 } else {
5629 if (shiftKey) {
5630 this.quill.setSelection(range.index, range.length + 1, _quill2.default.sources.USER);
5631 } else {
5632 this.quill.setSelection(range.index + range.length + 1, _quill2.default.sources.USER);
5633 }
5634 }
5635 return false;
5636 }), _ref3;
5637}
5638
5639function handleBackspace(range, context) {
5640 if (range.index === 0 || this.quill.getLength() <= 1) return;
5641
5642 var _quill$getLine11 = this.quill.getLine(range.index),
5643 _quill$getLine12 = _slicedToArray(_quill$getLine11, 1),
5644 line = _quill$getLine12[0];
5645
5646 var formats = {};
5647 if (context.offset === 0) {
5648 var _quill$getLine13 = this.quill.getLine(range.index - 1),
5649 _quill$getLine14 = _slicedToArray(_quill$getLine13, 1),
5650 prev = _quill$getLine14[0];
5651
5652 if (prev != null && prev.length() > 1) {
5653 var curFormats = line.formats();
5654 var prevFormats = this.quill.getFormat(range.index - 1, 1);
5655 formats = _op2.default.attributes.diff(curFormats, prevFormats) || {};
5656 }
5657 }
5658 // Check for astral symbols
5659 var length = /[\uD800-\uDBFF][\uDC00-\uDFFF]$/.test(context.prefix) ? 2 : 1;
5660 this.quill.deleteText(range.index - length, length, _quill2.default.sources.USER);
5661 if (Object.keys(formats).length > 0) {
5662 this.quill.formatLine(range.index - length, length, formats, _quill2.default.sources.USER);
5663 }
5664 this.quill.focus();
5665}
5666
5667function handleDelete(range, context) {
5668 // Check for astral symbols
5669 var length = /^[\uD800-\uDBFF][\uDC00-\uDFFF]/.test(context.suffix) ? 2 : 1;
5670 if (range.index >= this.quill.getLength() - length) return;
5671 var formats = {},
5672 nextLength = 0;
5673
5674 var _quill$getLine15 = this.quill.getLine(range.index),
5675 _quill$getLine16 = _slicedToArray(_quill$getLine15, 1),
5676 line = _quill$getLine16[0];
5677
5678 if (context.offset >= line.length() - 1) {
5679 var _quill$getLine17 = this.quill.getLine(range.index + 1),
5680 _quill$getLine18 = _slicedToArray(_quill$getLine17, 1),
5681 next = _quill$getLine18[0];
5682
5683 if (next) {
5684 var curFormats = line.formats();
5685 var nextFormats = this.quill.getFormat(range.index, 1);
5686 formats = _op2.default.attributes.diff(curFormats, nextFormats) || {};
5687 nextLength = next.length();
5688 }
5689 }
5690 this.quill.deleteText(range.index, length, _quill2.default.sources.USER);
5691 if (Object.keys(formats).length > 0) {
5692 this.quill.formatLine(range.index + nextLength - 1, length, formats, _quill2.default.sources.USER);
5693 }
5694}
5695
5696function handleDeleteRange(range) {
5697 var lines = this.quill.getLines(range);
5698 var formats = {};
5699 if (lines.length > 1) {
5700 var firstFormats = lines[0].formats();
5701 var lastFormats = lines[lines.length - 1].formats();
5702 formats = _op2.default.attributes.diff(lastFormats, firstFormats) || {};
5703 }
5704 this.quill.deleteText(range, _quill2.default.sources.USER);
5705 if (Object.keys(formats).length > 0) {
5706 this.quill.formatLine(range.index, 1, formats, _quill2.default.sources.USER);
5707 }
5708 this.quill.setSelection(range.index, _quill2.default.sources.SILENT);
5709 this.quill.focus();
5710}
5711
5712function handleEnter(range, context) {
5713 var _this3 = this;
5714
5715 if (range.length > 0) {
5716 this.quill.scroll.deleteAt(range.index, range.length); // So we do not trigger text-change
5717 }
5718 var lineFormats = Object.keys(context.format).reduce(function (lineFormats, format) {
5719 if (_parchment2.default.query(format, _parchment2.default.Scope.BLOCK) && !Array.isArray(context.format[format])) {
5720 lineFormats[format] = context.format[format];
5721 }
5722 return lineFormats;
5723 }, {});
5724 this.quill.insertText(range.index, '\n', lineFormats, _quill2.default.sources.USER);
5725 // Earlier scroll.deleteAt might have messed up our selection,
5726 // so insertText's built in selection preservation is not reliable
5727 this.quill.setSelection(range.index + 1, _quill2.default.sources.SILENT);
5728 this.quill.focus();
5729 Object.keys(context.format).forEach(function (name) {
5730 if (lineFormats[name] != null) return;
5731 if (Array.isArray(context.format[name])) return;
5732 if (name === 'link') return;
5733 _this3.quill.format(name, context.format[name], _quill2.default.sources.USER);
5734 });
5735}
5736
5737function makeCodeBlockHandler(indent) {
5738 return {
5739 key: Keyboard.keys.TAB,
5740 shiftKey: !indent,
5741 format: { 'code-block': true },
5742 handler: function handler(range) {
5743 var CodeBlock = _parchment2.default.query('code-block');
5744 var index = range.index,
5745 length = range.length;
5746
5747 var _quill$scroll$descend = this.quill.scroll.descendant(CodeBlock, index),
5748 _quill$scroll$descend2 = _slicedToArray(_quill$scroll$descend, 2),
5749 block = _quill$scroll$descend2[0],
5750 offset = _quill$scroll$descend2[1];
5751
5752 if (block == null) return;
5753 var scrollIndex = this.quill.getIndex(block);
5754 var start = block.newlineIndex(offset, true) + 1;
5755 var end = block.newlineIndex(scrollIndex + offset + length);
5756 var lines = block.domNode.textContent.slice(start, end).split('\n');
5757 offset = 0;
5758 lines.forEach(function (line, i) {
5759 if (indent) {
5760 block.insertAt(start + offset, CodeBlock.TAB);
5761 offset += CodeBlock.TAB.length;
5762 if (i === 0) {
5763 index += CodeBlock.TAB.length;
5764 } else {
5765 length += CodeBlock.TAB.length;
5766 }
5767 } else if (line.startsWith(CodeBlock.TAB)) {
5768 block.deleteAt(start + offset, CodeBlock.TAB.length);
5769 offset -= CodeBlock.TAB.length;
5770 if (i === 0) {
5771 index -= CodeBlock.TAB.length;
5772 } else {
5773 length -= CodeBlock.TAB.length;
5774 }
5775 }
5776 offset += line.length + 1;
5777 });
5778 this.quill.update(_quill2.default.sources.USER);
5779 this.quill.setSelection(index, length, _quill2.default.sources.SILENT);
5780 }
5781 };
5782}
5783
5784function makeFormatHandler(format) {
5785 return {
5786 key: format[0].toUpperCase(),
5787 shortKey: true,
5788 handler: function handler(range, context) {
5789 this.quill.format(format, !context.format[format], _quill2.default.sources.USER);
5790 }
5791 };
5792}
5793
5794function normalize(binding) {
5795 if (typeof binding === 'string' || typeof binding === 'number') {
5796 return normalize({ key: binding });
5797 }
5798 if ((typeof binding === 'undefined' ? 'undefined' : _typeof(binding)) === 'object') {
5799 binding = (0, _clone2.default)(binding, false);
5800 }
5801 if (typeof binding.key === 'string') {
5802 if (Keyboard.keys[binding.key.toUpperCase()] != null) {
5803 binding.key = Keyboard.keys[binding.key.toUpperCase()];
5804 } else if (binding.key.length === 1) {
5805 binding.key = binding.key.toUpperCase().charCodeAt(0);
5806 } else {
5807 return null;
5808 }
5809 }
5810 if (binding.shortKey) {
5811 binding[SHORTKEY] = binding.shortKey;
5812 delete binding.shortKey;
5813 }
5814 return binding;
5815}
5816
5817exports.default = Keyboard;
5818exports.SHORTKEY = SHORTKEY;
5819
5820/***/ }),
5821/* 36 */
5822/***/ (function(module, exports, __webpack_require__) {
5823
5824"use strict";
5825
5826
5827Object.defineProperty(exports, "__esModule", {
5828 value: true
5829});
5830exports.AlignStyle = exports.AlignClass = exports.AlignAttribute = undefined;
5831
5832var _parchment = __webpack_require__(0);
5833
5834var _parchment2 = _interopRequireDefault(_parchment);
5835
5836function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
5837
5838var config = {
5839 scope: _parchment2.default.Scope.BLOCK,
5840 whitelist: ['right', 'center', 'justify']
5841};
5842
5843var AlignAttribute = new _parchment2.default.Attributor.Attribute('align', 'align', config);
5844var AlignClass = new _parchment2.default.Attributor.Class('align', 'ql-align', config);
5845var AlignStyle = new _parchment2.default.Attributor.Style('align', 'text-align', config);
5846
5847exports.AlignAttribute = AlignAttribute;
5848exports.AlignClass = AlignClass;
5849exports.AlignStyle = AlignStyle;
5850
5851/***/ }),
5852/* 37 */
5853/***/ (function(module, exports, __webpack_require__) {
5854
5855"use strict";
5856
5857
5858Object.defineProperty(exports, "__esModule", {
5859 value: true
5860});
5861exports.BackgroundStyle = exports.BackgroundClass = undefined;
5862
5863var _parchment = __webpack_require__(0);
5864
5865var _parchment2 = _interopRequireDefault(_parchment);
5866
5867var _color = __webpack_require__(26);
5868
5869function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
5870
5871var BackgroundClass = new _parchment2.default.Attributor.Class('background', 'ql-bg', {
5872 scope: _parchment2.default.Scope.INLINE
5873});
5874var BackgroundStyle = new _color.ColorAttributor('background', 'background-color', {
5875 scope: _parchment2.default.Scope.INLINE
5876});
5877
5878exports.BackgroundClass = BackgroundClass;
5879exports.BackgroundStyle = BackgroundStyle;
5880
5881/***/ }),
5882/* 38 */
5883/***/ (function(module, exports, __webpack_require__) {
5884
5885"use strict";
5886
5887
5888Object.defineProperty(exports, "__esModule", {
5889 value: true
5890});
5891exports.DirectionStyle = exports.DirectionClass = exports.DirectionAttribute = undefined;
5892
5893var _parchment = __webpack_require__(0);
5894
5895var _parchment2 = _interopRequireDefault(_parchment);
5896
5897function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
5898
5899var config = {
5900 scope: _parchment2.default.Scope.BLOCK,
5901 whitelist: ['rtl']
5902};
5903
5904var DirectionAttribute = new _parchment2.default.Attributor.Attribute('direction', 'dir', config);
5905var DirectionClass = new _parchment2.default.Attributor.Class('direction', 'ql-direction', config);
5906var DirectionStyle = new _parchment2.default.Attributor.Style('direction', 'direction', config);
5907
5908exports.DirectionAttribute = DirectionAttribute;
5909exports.DirectionClass = DirectionClass;
5910exports.DirectionStyle = DirectionStyle;
5911
5912/***/ }),
5913/* 39 */
5914/***/ (function(module, exports, __webpack_require__) {
5915
5916"use strict";
5917
5918
5919Object.defineProperty(exports, "__esModule", {
5920 value: true
5921});
5922exports.FontClass = exports.FontStyle = undefined;
5923
5924var _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; }; }();
5925
5926var _get = function get(object, property, receiver) { if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { return get(parent, property, receiver); } } else if ("value" in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } };
5927
5928var _parchment = __webpack_require__(0);
5929
5930var _parchment2 = _interopRequireDefault(_parchment);
5931
5932function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
5933
5934function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
5935
5936function _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; }
5937
5938function _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; }
5939
5940var config = {
5941 scope: _parchment2.default.Scope.INLINE,
5942 whitelist: ['serif', 'monospace']
5943};
5944
5945var FontClass = new _parchment2.default.Attributor.Class('font', 'ql-font', config);
5946
5947var FontStyleAttributor = function (_Parchment$Attributor) {
5948 _inherits(FontStyleAttributor, _Parchment$Attributor);
5949
5950 function FontStyleAttributor() {
5951 _classCallCheck(this, FontStyleAttributor);
5952
5953 return _possibleConstructorReturn(this, (FontStyleAttributor.__proto__ || Object.getPrototypeOf(FontStyleAttributor)).apply(this, arguments));
5954 }
5955
5956 _createClass(FontStyleAttributor, [{
5957 key: 'value',
5958 value: function value(node) {
5959 return _get(FontStyleAttributor.prototype.__proto__ || Object.getPrototypeOf(FontStyleAttributor.prototype), 'value', this).call(this, node).replace(/["']/g, '');
5960 }
5961 }]);
5962
5963 return FontStyleAttributor;
5964}(_parchment2.default.Attributor.Style);
5965
5966var FontStyle = new FontStyleAttributor('font', 'font-family', config);
5967
5968exports.FontStyle = FontStyle;
5969exports.FontClass = FontClass;
5970
5971/***/ }),
5972/* 40 */
5973/***/ (function(module, exports, __webpack_require__) {
5974
5975"use strict";
5976
5977
5978Object.defineProperty(exports, "__esModule", {
5979 value: true
5980});
5981exports.SizeStyle = exports.SizeClass = undefined;
5982
5983var _parchment = __webpack_require__(0);
5984
5985var _parchment2 = _interopRequireDefault(_parchment);
5986
5987function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
5988
5989var SizeClass = new _parchment2.default.Attributor.Class('size', 'ql-size', {
5990 scope: _parchment2.default.Scope.INLINE,
5991 whitelist: ['small', 'large', 'huge']
5992});
5993var SizeStyle = new _parchment2.default.Attributor.Style('size', 'font-size', {
5994 scope: _parchment2.default.Scope.INLINE,
5995 whitelist: ['10px', '18px', '32px']
5996});
5997
5998exports.SizeClass = SizeClass;
5999exports.SizeStyle = SizeStyle;
6000
6001/***/ }),
6002/* 41 */,
6003/* 42 */
6004/***/ (function(module, exports, __webpack_require__) {
6005
6006"use strict";
6007
6008
6009Object.defineProperty(exports, "__esModule", {
6010 value: true
6011});
6012exports.getLastChangeIndex = exports.default = undefined;
6013
6014var _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; }; }();
6015
6016var _parchment = __webpack_require__(0);
6017
6018var _parchment2 = _interopRequireDefault(_parchment);
6019
6020var _quill = __webpack_require__(5);
6021
6022var _quill2 = _interopRequireDefault(_quill);
6023
6024var _module = __webpack_require__(9);
6025
6026var _module2 = _interopRequireDefault(_module);
6027
6028function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
6029
6030function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
6031
6032function _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; }
6033
6034function _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; }
6035
6036var History = function (_Module) {
6037 _inherits(History, _Module);
6038
6039 function History(quill, options) {
6040 _classCallCheck(this, History);
6041
6042 var _this = _possibleConstructorReturn(this, (History.__proto__ || Object.getPrototypeOf(History)).call(this, quill, options));
6043
6044 _this.lastRecorded = 0;
6045 _this.ignoreChange = false;
6046 _this.clear();
6047 _this.quill.on(_quill2.default.events.EDITOR_CHANGE, function (eventName, delta, oldDelta, source) {
6048 if (eventName !== _quill2.default.events.TEXT_CHANGE || _this.ignoreChange) return;
6049 if (!_this.options.userOnly || source === _quill2.default.sources.USER) {
6050 _this.record(delta, oldDelta);
6051 } else {
6052 _this.transform(delta);
6053 }
6054 });
6055 _this.quill.keyboard.addBinding({ key: 'Z', shortKey: true }, _this.undo.bind(_this));
6056 _this.quill.keyboard.addBinding({ key: 'Z', shortKey: true, shiftKey: true }, _this.redo.bind(_this));
6057 if (/Win/i.test(navigator.platform)) {
6058 _this.quill.keyboard.addBinding({ key: 'Y', shortKey: true }, _this.redo.bind(_this));
6059 }
6060 return _this;
6061 }
6062
6063 _createClass(History, [{
6064 key: 'change',
6065 value: function change(source, dest) {
6066 if (this.stack[source].length === 0) return;
6067 var delta = this.stack[source].pop();
6068 this.lastRecorded = 0;
6069 this.ignoreChange = true;
6070 this.quill.updateContents(delta[source], _quill2.default.sources.USER);
6071 this.ignoreChange = false;
6072 var index = getLastChangeIndex(delta[source]);
6073 this.quill.setSelection(index);
6074 this.stack[dest].push(delta);
6075 }
6076 }, {
6077 key: 'clear',
6078 value: function clear() {
6079 this.stack = { undo: [], redo: [] };
6080 }
6081 }, {
6082 key: 'cutoff',
6083 value: function cutoff() {
6084 this.lastRecorded = 0;
6085 }
6086 }, {
6087 key: 'record',
6088 value: function record(changeDelta, oldDelta) {
6089 if (changeDelta.ops.length === 0) return;
6090 this.stack.redo = [];
6091 var undoDelta = this.quill.getContents().diff(oldDelta);
6092 var timestamp = Date.now();
6093 if (this.lastRecorded + this.options.delay > timestamp && this.stack.undo.length > 0) {
6094 var delta = this.stack.undo.pop();
6095 undoDelta = undoDelta.compose(delta.undo);
6096 changeDelta = delta.redo.compose(changeDelta);
6097 } else {
6098 this.lastRecorded = timestamp;
6099 }
6100 this.stack.undo.push({
6101 redo: changeDelta,
6102 undo: undoDelta
6103 });
6104 if (this.stack.undo.length > this.options.maxStack) {
6105 this.stack.undo.shift();
6106 }
6107 }
6108 }, {
6109 key: 'redo',
6110 value: function redo() {
6111 this.change('redo', 'undo');
6112 }
6113 }, {
6114 key: 'transform',
6115 value: function transform(delta) {
6116 this.stack.undo.forEach(function (change) {
6117 change.undo = delta.transform(change.undo, true);
6118 change.redo = delta.transform(change.redo, true);
6119 });
6120 this.stack.redo.forEach(function (change) {
6121 change.undo = delta.transform(change.undo, true);
6122 change.redo = delta.transform(change.redo, true);
6123 });
6124 }
6125 }, {
6126 key: 'undo',
6127 value: function undo() {
6128 this.change('undo', 'redo');
6129 }
6130 }]);
6131
6132 return History;
6133}(_module2.default);
6134
6135History.DEFAULTS = {
6136 delay: 1000,
6137 maxStack: 100,
6138 userOnly: false
6139};
6140
6141function endsWithNewlineChange(delta) {
6142 var lastOp = delta.ops[delta.ops.length - 1];
6143 if (lastOp == null) return false;
6144 if (lastOp.insert != null) {
6145 return typeof lastOp.insert === 'string' && lastOp.insert.endsWith('\n');
6146 }
6147 if (lastOp.attributes != null) {
6148 return Object.keys(lastOp.attributes).some(function (attr) {
6149 return _parchment2.default.query(attr, _parchment2.default.Scope.BLOCK) != null;
6150 });
6151 }
6152 return false;
6153}
6154
6155function getLastChangeIndex(delta) {
6156 var deleteLength = delta.reduce(function (length, op) {
6157 length += op.delete || 0;
6158 return length;
6159 }, 0);
6160 var changeIndex = delta.length() - deleteLength;
6161 if (endsWithNewlineChange(delta)) {
6162 changeIndex -= 1;
6163 }
6164 return changeIndex;
6165}
6166
6167exports.default = History;
6168exports.getLastChangeIndex = getLastChangeIndex;
6169
6170/***/ }),
6171/* 43 */,
6172/* 44 */
6173/***/ (function(module, exports, __webpack_require__) {
6174
6175"use strict";
6176
6177Object.defineProperty(exports, "__esModule", { value: true });
6178var LinkedList = /** @class */ (function () {
6179 function LinkedList() {
6180 this.head = this.tail = undefined;
6181 this.length = 0;
6182 }
6183 LinkedList.prototype.append = function () {
6184 var nodes = [];
6185 for (var _i = 0; _i < arguments.length; _i++) {
6186 nodes[_i] = arguments[_i];
6187 }
6188 this.insertBefore(nodes[0], undefined);
6189 if (nodes.length > 1) {
6190 this.append.apply(this, nodes.slice(1));
6191 }
6192 };
6193 LinkedList.prototype.contains = function (node) {
6194 var cur, next = this.iterator();
6195 while (cur = next()) {
6196 if (cur === node)
6197 return true;
6198 }
6199 return false;
6200 };
6201 LinkedList.prototype.insertBefore = function (node, refNode) {
6202 node.next = refNode;
6203 if (refNode != null) {
6204 node.prev = refNode.prev;
6205 if (refNode.prev != null) {
6206 refNode.prev.next = node;
6207 }
6208 refNode.prev = node;
6209 if (refNode === this.head) {
6210 this.head = node;
6211 }
6212 }
6213 else if (this.tail != null) {
6214 this.tail.next = node;
6215 node.prev = this.tail;
6216 this.tail = node;
6217 }
6218 else {
6219 node.prev = undefined;
6220 this.head = this.tail = node;
6221 }
6222 this.length += 1;
6223 };
6224 LinkedList.prototype.offset = function (target) {
6225 var index = 0, cur = this.head;
6226 while (cur != null) {
6227 if (cur === target)
6228 return index;
6229 index += cur.length();
6230 cur = cur.next;
6231 }
6232 return -1;
6233 };
6234 LinkedList.prototype.remove = function (node) {
6235 if (!this.contains(node))
6236 return;
6237 if (node.prev != null)
6238 node.prev.next = node.next;
6239 if (node.next != null)
6240 node.next.prev = node.prev;
6241 if (node === this.head)
6242 this.head = node.next;
6243 if (node === this.tail)
6244 this.tail = node.prev;
6245 this.length -= 1;
6246 };
6247 LinkedList.prototype.iterator = function (curNode) {
6248 if (curNode === void 0) { curNode = this.head; }
6249 // TODO use yield when we can
6250 return function () {
6251 var ret = curNode;
6252 if (curNode != null)
6253 curNode = curNode.next;
6254 return ret;
6255 };
6256 };
6257 LinkedList.prototype.find = function (index, inclusive) {
6258 if (inclusive === void 0) { inclusive = false; }
6259 var cur, next = this.iterator();
6260 while (cur = next()) {
6261 var length = cur.length();
6262 if (index < length || (inclusive && index === length && (cur.next == null || cur.next.length() !== 0))) {
6263 return [cur, index];
6264 }
6265 index -= length;
6266 }
6267 return [null, 0];
6268 };
6269 LinkedList.prototype.forEach = function (callback) {
6270 var cur, next = this.iterator();
6271 while (cur = next()) {
6272 callback(cur);
6273 }
6274 };
6275 LinkedList.prototype.forEachAt = function (index, length, callback) {
6276 if (length <= 0)
6277 return;
6278 var _a = this.find(index), startNode = _a[0], offset = _a[1];
6279 var cur, curIndex = index - offset, next = this.iterator(startNode);
6280 while ((cur = next()) && curIndex < index + length) {
6281 var curLength = cur.length();
6282 if (index > curIndex) {
6283 callback(cur, index - curIndex, Math.min(length, curIndex + curLength - index));
6284 }
6285 else {
6286 callback(cur, 0, Math.min(curLength, index + length - curIndex));
6287 }
6288 curIndex += curLength;
6289 }
6290 };
6291 LinkedList.prototype.map = function (callback) {
6292 return this.reduce(function (memo, cur) {
6293 memo.push(callback(cur));
6294 return memo;
6295 }, []);
6296 };
6297 LinkedList.prototype.reduce = function (callback, memo) {
6298 var cur, next = this.iterator();
6299 while (cur = next()) {
6300 memo = callback(memo, cur);
6301 }
6302 return memo;
6303 };
6304 return LinkedList;
6305}());
6306exports.default = LinkedList;
6307
6308
6309/***/ }),
6310/* 45 */
6311/***/ (function(module, exports, __webpack_require__) {
6312
6313"use strict";
6314
6315var __extends = (this && this.__extends) || (function () {
6316 var extendStatics = Object.setPrototypeOf ||
6317 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
6318 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
6319 return function (d, b) {
6320 extendStatics(d, b);
6321 function __() { this.constructor = d; }
6322 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
6323 };
6324})();
6325Object.defineProperty(exports, "__esModule", { value: true });
6326var container_1 = __webpack_require__(17);
6327var Registry = __webpack_require__(1);
6328var OBSERVER_CONFIG = {
6329 attributes: true,
6330 characterData: true,
6331 characterDataOldValue: true,
6332 childList: true,
6333 subtree: true
6334};
6335var MAX_OPTIMIZE_ITERATIONS = 100;
6336var ScrollBlot = /** @class */ (function (_super) {
6337 __extends(ScrollBlot, _super);
6338 function ScrollBlot(node) {
6339 var _this = _super.call(this, node) || this;
6340 _this.parent = null;
6341 _this.observer = new MutationObserver(function (mutations) {
6342 _this.update(mutations);
6343 });
6344 _this.observer.observe(_this.domNode, OBSERVER_CONFIG);
6345 return _this;
6346 }
6347 ScrollBlot.prototype.detach = function () {
6348 _super.prototype.detach.call(this);
6349 this.observer.disconnect();
6350 };
6351 ScrollBlot.prototype.deleteAt = function (index, length) {
6352 this.update();
6353 if (index === 0 && length === this.length()) {
6354 this.children.forEach(function (child) {
6355 child.remove();
6356 });
6357 }
6358 else {
6359 _super.prototype.deleteAt.call(this, index, length);
6360 }
6361 };
6362 ScrollBlot.prototype.formatAt = function (index, length, name, value) {
6363 this.update();
6364 _super.prototype.formatAt.call(this, index, length, name, value);
6365 };
6366 ScrollBlot.prototype.insertAt = function (index, value, def) {
6367 this.update();
6368 _super.prototype.insertAt.call(this, index, value, def);
6369 };
6370 ScrollBlot.prototype.optimize = function (mutations, context) {
6371 var _this = this;
6372 if (mutations === void 0) { mutations = []; }
6373 if (context === void 0) { context = {}; }
6374 _super.prototype.optimize.call(this, context);
6375 // We must modify mutations directly, cannot make copy and then modify
6376 var records = [].slice.call(this.observer.takeRecords());
6377 // Array.push currently seems to be implemented by a non-tail recursive function
6378 // so we cannot just mutations.push.apply(mutations, this.observer.takeRecords());
6379 while (records.length > 0)
6380 mutations.push(records.pop());
6381 // TODO use WeakMap
6382 var mark = function (blot, markParent) {
6383 if (markParent === void 0) { markParent = true; }
6384 if (blot == null || blot === _this)
6385 return;
6386 if (blot.domNode.parentNode == null)
6387 return;
6388 if (blot.domNode[Registry.DATA_KEY].mutations == null) {
6389 blot.domNode[Registry.DATA_KEY].mutations = [];
6390 }
6391 if (markParent)
6392 mark(blot.parent);
6393 };
6394 var optimize = function (blot) {
6395 if (blot.domNode[Registry.DATA_KEY] == null || blot.domNode[Registry.DATA_KEY].mutations == null) {
6396 return;
6397 }
6398 if (blot instanceof container_1.default) {
6399 blot.children.forEach(optimize);
6400 }
6401 blot.optimize(context);
6402 };
6403 var remaining = mutations;
6404 for (var i = 0; remaining.length > 0; i += 1) {
6405 if (i >= MAX_OPTIMIZE_ITERATIONS) {
6406 throw new Error('[Parchment] Maximum optimize iterations reached');
6407 }
6408 remaining.forEach(function (mutation) {
6409 var blot = Registry.find(mutation.target, true);
6410 if (blot == null)
6411 return;
6412 if (blot.domNode === mutation.target) {
6413 if (mutation.type === 'childList') {
6414 mark(Registry.find(mutation.previousSibling, false));
6415 [].forEach.call(mutation.addedNodes, function (node) {
6416 var child = Registry.find(node, false);
6417 mark(child, false);
6418 if (child instanceof container_1.default) {
6419 child.children.forEach(function (grandChild) {
6420 mark(grandChild, false);
6421 });
6422 }
6423 });
6424 }
6425 else if (mutation.type === 'attributes') {
6426 mark(blot.prev);
6427 }
6428 }
6429 mark(blot);
6430 });
6431 this.children.forEach(optimize);
6432 remaining = [].slice.call(this.observer.takeRecords());
6433 records = remaining.slice();
6434 while (records.length > 0)
6435 mutations.push(records.pop());
6436 }
6437 };
6438 ScrollBlot.prototype.update = function (mutations, context) {
6439 var _this = this;
6440 if (context === void 0) { context = {}; }
6441 mutations = mutations || this.observer.takeRecords();
6442 // TODO use WeakMap
6443 mutations.map(function (mutation) {
6444 var blot = Registry.find(mutation.target, true);
6445 if (blot == null)
6446 return;
6447 if (blot.domNode[Registry.DATA_KEY].mutations == null) {
6448 blot.domNode[Registry.DATA_KEY].mutations = [mutation];
6449 return blot;
6450 }
6451 else {
6452 blot.domNode[Registry.DATA_KEY].mutations.push(mutation);
6453 return null;
6454 }
6455 }).forEach(function (blot) {
6456 if (blot == null || blot === _this || blot.domNode[Registry.DATA_KEY] == null)
6457 return;
6458 blot.update(blot.domNode[Registry.DATA_KEY].mutations || [], context);
6459 });
6460 if (this.domNode[Registry.DATA_KEY].mutations != null) {
6461 _super.prototype.update.call(this, this.domNode[Registry.DATA_KEY].mutations, context);
6462 }
6463 this.optimize(mutations, context);
6464 };
6465 ScrollBlot.blotName = 'scroll';
6466 ScrollBlot.defaultChild = 'block';
6467 ScrollBlot.scope = Registry.Scope.BLOCK_BLOT;
6468 ScrollBlot.tagName = 'DIV';
6469 return ScrollBlot;
6470}(container_1.default));
6471exports.default = ScrollBlot;
6472
6473
6474/***/ }),
6475/* 46 */
6476/***/ (function(module, exports, __webpack_require__) {
6477
6478"use strict";
6479
6480var __extends = (this && this.__extends) || (function () {
6481 var extendStatics = Object.setPrototypeOf ||
6482 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
6483 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
6484 return function (d, b) {
6485 extendStatics(d, b);
6486 function __() { this.constructor = d; }
6487 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
6488 };
6489})();
6490Object.defineProperty(exports, "__esModule", { value: true });
6491var format_1 = __webpack_require__(18);
6492var Registry = __webpack_require__(1);
6493// Shallow object comparison
6494function isEqual(obj1, obj2) {
6495 if (Object.keys(obj1).length !== Object.keys(obj2).length)
6496 return false;
6497 for (var prop in obj1) {
6498 if (obj1[prop] !== obj2[prop])
6499 return false;
6500 }
6501 return true;
6502}
6503var InlineBlot = /** @class */ (function (_super) {
6504 __extends(InlineBlot, _super);
6505 function InlineBlot() {
6506 return _super !== null && _super.apply(this, arguments) || this;
6507 }
6508 InlineBlot.formats = function (domNode) {
6509 if (domNode.tagName === InlineBlot.tagName)
6510 return undefined;
6511 return _super.formats.call(this, domNode);
6512 };
6513 InlineBlot.prototype.format = function (name, value) {
6514 var _this = this;
6515 if (name === this.statics.blotName && !value) {
6516 this.children.forEach(function (child) {
6517 if (!(child instanceof format_1.default)) {
6518 child = child.wrap(InlineBlot.blotName, true);
6519 }
6520 _this.attributes.copy(child);
6521 });
6522 this.unwrap();
6523 }
6524 else {
6525 _super.prototype.format.call(this, name, value);
6526 }
6527 };
6528 InlineBlot.prototype.formatAt = function (index, length, name, value) {
6529 if (this.formats()[name] != null || Registry.query(name, Registry.Scope.ATTRIBUTE)) {
6530 var blot = this.isolate(index, length);
6531 blot.format(name, value);
6532 }
6533 else {
6534 _super.prototype.formatAt.call(this, index, length, name, value);
6535 }
6536 };
6537 InlineBlot.prototype.optimize = function (context) {
6538 _super.prototype.optimize.call(this, context);
6539 var formats = this.formats();
6540 if (Object.keys(formats).length === 0) {
6541 return this.unwrap(); // unformatted span
6542 }
6543 var next = this.next;
6544 if (next instanceof InlineBlot && next.prev === this && isEqual(formats, next.formats())) {
6545 next.moveChildren(this);
6546 next.remove();
6547 }
6548 };
6549 InlineBlot.blotName = 'inline';
6550 InlineBlot.scope = Registry.Scope.INLINE_BLOT;
6551 InlineBlot.tagName = 'SPAN';
6552 return InlineBlot;
6553}(format_1.default));
6554exports.default = InlineBlot;
6555
6556
6557/***/ }),
6558/* 47 */
6559/***/ (function(module, exports, __webpack_require__) {
6560
6561"use strict";
6562
6563var __extends = (this && this.__extends) || (function () {
6564 var extendStatics = Object.setPrototypeOf ||
6565 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
6566 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
6567 return function (d, b) {
6568 extendStatics(d, b);
6569 function __() { this.constructor = d; }
6570 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
6571 };
6572})();
6573Object.defineProperty(exports, "__esModule", { value: true });
6574var format_1 = __webpack_require__(18);
6575var Registry = __webpack_require__(1);
6576var BlockBlot = /** @class */ (function (_super) {
6577 __extends(BlockBlot, _super);
6578 function BlockBlot() {
6579 return _super !== null && _super.apply(this, arguments) || this;
6580 }
6581 BlockBlot.formats = function (domNode) {
6582 var tagName = Registry.query(BlockBlot.blotName).tagName;
6583 if (domNode.tagName === tagName)
6584 return undefined;
6585 return _super.formats.call(this, domNode);
6586 };
6587 BlockBlot.prototype.format = function (name, value) {
6588 if (Registry.query(name, Registry.Scope.BLOCK) == null) {
6589 return;
6590 }
6591 else if (name === this.statics.blotName && !value) {
6592 this.replaceWith(BlockBlot.blotName);
6593 }
6594 else {
6595 _super.prototype.format.call(this, name, value);
6596 }
6597 };
6598 BlockBlot.prototype.formatAt = function (index, length, name, value) {
6599 if (Registry.query(name, Registry.Scope.BLOCK) != null) {
6600 this.format(name, value);
6601 }
6602 else {
6603 _super.prototype.formatAt.call(this, index, length, name, value);
6604 }
6605 };
6606 BlockBlot.prototype.insertAt = function (index, value, def) {
6607 if (def == null || Registry.query(value, Registry.Scope.INLINE) != null) {
6608 // Insert text or inline
6609 _super.prototype.insertAt.call(this, index, value, def);
6610 }
6611 else {
6612 var after = this.split(index);
6613 var blot = Registry.create(value, def);
6614 after.parent.insertBefore(blot, after);
6615 }
6616 };
6617 BlockBlot.prototype.update = function (mutations, context) {
6618 if (navigator.userAgent.match(/Trident/)) {
6619 this.attach();
6620 }
6621 else {
6622 _super.prototype.update.call(this, mutations, context);
6623 }
6624 };
6625 BlockBlot.blotName = 'block';
6626 BlockBlot.scope = Registry.Scope.BLOCK_BLOT;
6627 BlockBlot.tagName = 'P';
6628 return BlockBlot;
6629}(format_1.default));
6630exports.default = BlockBlot;
6631
6632
6633/***/ }),
6634/* 48 */
6635/***/ (function(module, exports, __webpack_require__) {
6636
6637"use strict";
6638
6639var __extends = (this && this.__extends) || (function () {
6640 var extendStatics = Object.setPrototypeOf ||
6641 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
6642 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
6643 return function (d, b) {
6644 extendStatics(d, b);
6645 function __() { this.constructor = d; }
6646 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
6647 };
6648})();
6649Object.defineProperty(exports, "__esModule", { value: true });
6650var leaf_1 = __webpack_require__(19);
6651var EmbedBlot = /** @class */ (function (_super) {
6652 __extends(EmbedBlot, _super);
6653 function EmbedBlot() {
6654 return _super !== null && _super.apply(this, arguments) || this;
6655 }
6656 EmbedBlot.formats = function (domNode) {
6657 return undefined;
6658 };
6659 EmbedBlot.prototype.format = function (name, value) {
6660 // super.formatAt wraps, which is what we want in general,
6661 // but this allows subclasses to overwrite for formats
6662 // that just apply to particular embeds
6663 _super.prototype.formatAt.call(this, 0, this.length(), name, value);
6664 };
6665 EmbedBlot.prototype.formatAt = function (index, length, name, value) {
6666 if (index === 0 && length === this.length()) {
6667 this.format(name, value);
6668 }
6669 else {
6670 _super.prototype.formatAt.call(this, index, length, name, value);
6671 }
6672 };
6673 EmbedBlot.prototype.formats = function () {
6674 return this.statics.formats(this.domNode);
6675 };
6676 return EmbedBlot;
6677}(leaf_1.default));
6678exports.default = EmbedBlot;
6679
6680
6681/***/ }),
6682/* 49 */
6683/***/ (function(module, exports, __webpack_require__) {
6684
6685"use strict";
6686
6687var __extends = (this && this.__extends) || (function () {
6688 var extendStatics = Object.setPrototypeOf ||
6689 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
6690 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
6691 return function (d, b) {
6692 extendStatics(d, b);
6693 function __() { this.constructor = d; }
6694 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
6695 };
6696})();
6697Object.defineProperty(exports, "__esModule", { value: true });
6698var leaf_1 = __webpack_require__(19);
6699var Registry = __webpack_require__(1);
6700var TextBlot = /** @class */ (function (_super) {
6701 __extends(TextBlot, _super);
6702 function TextBlot(node) {
6703 var _this = _super.call(this, node) || this;
6704 _this.text = _this.statics.value(_this.domNode);
6705 return _this;
6706 }
6707 TextBlot.create = function (value) {
6708 return document.createTextNode(value);
6709 };
6710 TextBlot.value = function (domNode) {
6711 var text = domNode.data;
6712 if (text["normalize"])
6713 text = text["normalize"]();
6714 return text;
6715 };
6716 TextBlot.prototype.deleteAt = function (index, length) {
6717 this.domNode.data = this.text = this.text.slice(0, index) + this.text.slice(index + length);
6718 };
6719 TextBlot.prototype.index = function (node, offset) {
6720 if (this.domNode === node) {
6721 return offset;
6722 }
6723 return -1;
6724 };
6725 TextBlot.prototype.insertAt = function (index, value, def) {
6726 if (def == null) {
6727 this.text = this.text.slice(0, index) + value + this.text.slice(index);
6728 this.domNode.data = this.text;
6729 }
6730 else {
6731 _super.prototype.insertAt.call(this, index, value, def);
6732 }
6733 };
6734 TextBlot.prototype.length = function () {
6735 return this.text.length;
6736 };
6737 TextBlot.prototype.optimize = function (context) {
6738 _super.prototype.optimize.call(this, context);
6739 this.text = this.statics.value(this.domNode);
6740 if (this.text.length === 0) {
6741 this.remove();
6742 }
6743 else if (this.next instanceof TextBlot && this.next.prev === this) {
6744 this.insertAt(this.length(), this.next.value());
6745 this.next.remove();
6746 }
6747 };
6748 TextBlot.prototype.position = function (index, inclusive) {
6749 if (inclusive === void 0) { inclusive = false; }
6750 return [this.domNode, index];
6751 };
6752 TextBlot.prototype.split = function (index, force) {
6753 if (force === void 0) { force = false; }
6754 if (!force) {
6755 if (index === 0)
6756 return this;
6757 if (index === this.length())
6758 return this.next;
6759 }
6760 var after = Registry.create(this.domNode.splitText(index));
6761 this.parent.insertBefore(after, this.next);
6762 this.text = this.statics.value(this.domNode);
6763 return after;
6764 };
6765 TextBlot.prototype.update = function (mutations, context) {
6766 var _this = this;
6767 if (mutations.some(function (mutation) {
6768 return mutation.type === 'characterData' && mutation.target === _this.domNode;
6769 })) {
6770 this.text = this.statics.value(this.domNode);
6771 }
6772 };
6773 TextBlot.prototype.value = function () {
6774 return this.text;
6775 };
6776 TextBlot.blotName = 'text';
6777 TextBlot.scope = Registry.Scope.INLINE_BLOT;
6778 return TextBlot;
6779}(leaf_1.default));
6780exports.default = TextBlot;
6781
6782
6783/***/ }),
6784/* 50 */
6785/***/ (function(module, exports, __webpack_require__) {
6786
6787"use strict";
6788
6789
6790var elem = document.createElement('div');
6791elem.classList.toggle('test-class', false);
6792if (elem.classList.contains('test-class')) {
6793 var _toggle = DOMTokenList.prototype.toggle;
6794 DOMTokenList.prototype.toggle = function (token, force) {
6795 if (arguments.length > 1 && !this.contains(token) === !force) {
6796 return force;
6797 } else {
6798 return _toggle.call(this, token);
6799 }
6800 };
6801}
6802
6803if (!String.prototype.startsWith) {
6804 String.prototype.startsWith = function (searchString, position) {
6805 position = position || 0;
6806 return this.substr(position, searchString.length) === searchString;
6807 };
6808}
6809
6810if (!String.prototype.endsWith) {
6811 String.prototype.endsWith = function (searchString, position) {
6812 var subjectString = this.toString();
6813 if (typeof position !== 'number' || !isFinite(position) || Math.floor(position) !== position || position > subjectString.length) {
6814 position = subjectString.length;
6815 }
6816 position -= searchString.length;
6817 var lastIndex = subjectString.indexOf(searchString, position);
6818 return lastIndex !== -1 && lastIndex === position;
6819 };
6820}
6821
6822if (!Array.prototype.find) {
6823 Object.defineProperty(Array.prototype, "find", {
6824 value: function value(predicate) {
6825 if (this === null) {
6826 throw new TypeError('Array.prototype.find called on null or undefined');
6827 }
6828 if (typeof predicate !== 'function') {
6829 throw new TypeError('predicate must be a function');
6830 }
6831 var list = Object(this);
6832 var length = list.length >>> 0;
6833 var thisArg = arguments[1];
6834 var value;
6835
6836 for (var i = 0; i < length; i++) {
6837 value = list[i];
6838 if (predicate.call(thisArg, value, i, list)) {
6839 return value;
6840 }
6841 }
6842 return undefined;
6843 }
6844 });
6845}
6846
6847document.addEventListener("DOMContentLoaded", function () {
6848 // Disable resizing in Firefox
6849 document.execCommand("enableObjectResizing", false, false);
6850 // Disable automatic linkifying in IE11
6851 document.execCommand("autoUrlDetect", false, false);
6852});
6853
6854/***/ }),
6855/* 51 */
6856/***/ (function(module, exports) {
6857
6858/**
6859 * This library modifies the diff-patch-match library by Neil Fraser
6860 * by removing the patch and match functionality and certain advanced
6861 * options in the diff function. The original license is as follows:
6862 *
6863 * ===
6864 *
6865 * Diff Match and Patch
6866 *
6867 * Copyright 2006 Google Inc.
6868 * http://code.google.com/p/google-diff-match-patch/
6869 *
6870 * Licensed under the Apache License, Version 2.0 (the "License");
6871 * you may not use this file except in compliance with the License.
6872 * You may obtain a copy of the License at
6873 *
6874 * http://www.apache.org/licenses/LICENSE-2.0
6875 *
6876 * Unless required by applicable law or agreed to in writing, software
6877 * distributed under the License is distributed on an "AS IS" BASIS,
6878 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
6879 * See the License for the specific language governing permissions and
6880 * limitations under the License.
6881 */
6882
6883
6884/**
6885 * The data structure representing a diff is an array of tuples:
6886 * [[DIFF_DELETE, 'Hello'], [DIFF_INSERT, 'Goodbye'], [DIFF_EQUAL, ' world.']]
6887 * which means: delete 'Hello', add 'Goodbye' and keep ' world.'
6888 */
6889var DIFF_DELETE = -1;
6890var DIFF_INSERT = 1;
6891var DIFF_EQUAL = 0;
6892
6893
6894/**
6895 * Find the differences between two texts. Simplifies the problem by stripping
6896 * any common prefix or suffix off the texts before diffing.
6897 * @param {string} text1 Old string to be diffed.
6898 * @param {string} text2 New string to be diffed.
6899 * @param {Int} cursor_pos Expected edit position in text1 (optional)
6900 * @return {Array} Array of diff tuples.
6901 */
6902function diff_main(text1, text2, cursor_pos) {
6903 // Check for equality (speedup).
6904 if (text1 == text2) {
6905 if (text1) {
6906 return [[DIFF_EQUAL, text1]];
6907 }
6908 return [];
6909 }
6910
6911 // Check cursor_pos within bounds
6912 if (cursor_pos < 0 || text1.length < cursor_pos) {
6913 cursor_pos = null;
6914 }
6915
6916 // Trim off common prefix (speedup).
6917 var commonlength = diff_commonPrefix(text1, text2);
6918 var commonprefix = text1.substring(0, commonlength);
6919 text1 = text1.substring(commonlength);
6920 text2 = text2.substring(commonlength);
6921
6922 // Trim off common suffix (speedup).
6923 commonlength = diff_commonSuffix(text1, text2);
6924 var commonsuffix = text1.substring(text1.length - commonlength);
6925 text1 = text1.substring(0, text1.length - commonlength);
6926 text2 = text2.substring(0, text2.length - commonlength);
6927
6928 // Compute the diff on the middle block.
6929 var diffs = diff_compute_(text1, text2);
6930
6931 // Restore the prefix and suffix.
6932 if (commonprefix) {
6933 diffs.unshift([DIFF_EQUAL, commonprefix]);
6934 }
6935 if (commonsuffix) {
6936 diffs.push([DIFF_EQUAL, commonsuffix]);
6937 }
6938 diff_cleanupMerge(diffs);
6939 if (cursor_pos != null) {
6940 diffs = fix_cursor(diffs, cursor_pos);
6941 }
6942 return diffs;
6943};
6944
6945
6946/**
6947 * Find the differences between two texts. Assumes that the texts do not
6948 * have any common prefix or suffix.
6949 * @param {string} text1 Old string to be diffed.
6950 * @param {string} text2 New string to be diffed.
6951 * @return {Array} Array of diff tuples.
6952 */
6953function diff_compute_(text1, text2) {
6954 var diffs;
6955
6956 if (!text1) {
6957 // Just add some text (speedup).
6958 return [[DIFF_INSERT, text2]];
6959 }
6960
6961 if (!text2) {
6962 // Just delete some text (speedup).
6963 return [[DIFF_DELETE, text1]];
6964 }
6965
6966 var longtext = text1.length > text2.length ? text1 : text2;
6967 var shorttext = text1.length > text2.length ? text2 : text1;
6968 var i = longtext.indexOf(shorttext);
6969 if (i != -1) {
6970 // Shorter text is inside the longer text (speedup).
6971 diffs = [[DIFF_INSERT, longtext.substring(0, i)],
6972 [DIFF_EQUAL, shorttext],
6973 [DIFF_INSERT, longtext.substring(i + shorttext.length)]];
6974 // Swap insertions for deletions if diff is reversed.
6975 if (text1.length > text2.length) {
6976 diffs[0][0] = diffs[2][0] = DIFF_DELETE;
6977 }
6978 return diffs;
6979 }
6980
6981 if (shorttext.length == 1) {
6982 // Single character string.
6983 // After the previous speedup, the character can't be an equality.
6984 return [[DIFF_DELETE, text1], [DIFF_INSERT, text2]];
6985 }
6986
6987 // Check to see if the problem can be split in two.
6988 var hm = diff_halfMatch_(text1, text2);
6989 if (hm) {
6990 // A half-match was found, sort out the return data.
6991 var text1_a = hm[0];
6992 var text1_b = hm[1];
6993 var text2_a = hm[2];
6994 var text2_b = hm[3];
6995 var mid_common = hm[4];
6996 // Send both pairs off for separate processing.
6997 var diffs_a = diff_main(text1_a, text2_a);
6998 var diffs_b = diff_main(text1_b, text2_b);
6999 // Merge the results.
7000 return diffs_a.concat([[DIFF_EQUAL, mid_common]], diffs_b);
7001 }
7002
7003 return diff_bisect_(text1, text2);
7004};
7005
7006
7007/**
7008 * Find the 'middle snake' of a diff, split the problem in two
7009 * and return the recursively constructed diff.
7010 * See Myers 1986 paper: An O(ND) Difference Algorithm and Its Variations.
7011 * @param {string} text1 Old string to be diffed.
7012 * @param {string} text2 New string to be diffed.
7013 * @return {Array} Array of diff tuples.
7014 * @private
7015 */
7016function diff_bisect_(text1, text2) {
7017 // Cache the text lengths to prevent multiple calls.
7018 var text1_length = text1.length;
7019 var text2_length = text2.length;
7020 var max_d = Math.ceil((text1_length + text2_length) / 2);
7021 var v_offset = max_d;
7022 var v_length = 2 * max_d;
7023 var v1 = new Array(v_length);
7024 var v2 = new Array(v_length);
7025 // Setting all elements to -1 is faster in Chrome & Firefox than mixing
7026 // integers and undefined.
7027 for (var x = 0; x < v_length; x++) {
7028 v1[x] = -1;
7029 v2[x] = -1;
7030 }
7031 v1[v_offset + 1] = 0;
7032 v2[v_offset + 1] = 0;
7033 var delta = text1_length - text2_length;
7034 // If the total number of characters is odd, then the front path will collide
7035 // with the reverse path.
7036 var front = (delta % 2 != 0);
7037 // Offsets for start and end of k loop.
7038 // Prevents mapping of space beyond the grid.
7039 var k1start = 0;
7040 var k1end = 0;
7041 var k2start = 0;
7042 var k2end = 0;
7043 for (var d = 0; d < max_d; d++) {
7044 // Walk the front path one step.
7045 for (var k1 = -d + k1start; k1 <= d - k1end; k1 += 2) {
7046 var k1_offset = v_offset + k1;
7047 var x1;
7048 if (k1 == -d || (k1 != d && v1[k1_offset - 1] < v1[k1_offset + 1])) {
7049 x1 = v1[k1_offset + 1];
7050 } else {
7051 x1 = v1[k1_offset - 1] + 1;
7052 }
7053 var y1 = x1 - k1;
7054 while (x1 < text1_length && y1 < text2_length &&
7055 text1.charAt(x1) == text2.charAt(y1)) {
7056 x1++;
7057 y1++;
7058 }
7059 v1[k1_offset] = x1;
7060 if (x1 > text1_length) {
7061 // Ran off the right of the graph.
7062 k1end += 2;
7063 } else if (y1 > text2_length) {
7064 // Ran off the bottom of the graph.
7065 k1start += 2;
7066 } else if (front) {
7067 var k2_offset = v_offset + delta - k1;
7068 if (k2_offset >= 0 && k2_offset < v_length && v2[k2_offset] != -1) {
7069 // Mirror x2 onto top-left coordinate system.
7070 var x2 = text1_length - v2[k2_offset];
7071 if (x1 >= x2) {
7072 // Overlap detected.
7073 return diff_bisectSplit_(text1, text2, x1, y1);
7074 }
7075 }
7076 }
7077 }
7078
7079 // Walk the reverse path one step.
7080 for (var k2 = -d + k2start; k2 <= d - k2end; k2 += 2) {
7081 var k2_offset = v_offset + k2;
7082 var x2;
7083 if (k2 == -d || (k2 != d && v2[k2_offset - 1] < v2[k2_offset + 1])) {
7084 x2 = v2[k2_offset + 1];
7085 } else {
7086 x2 = v2[k2_offset - 1] + 1;
7087 }
7088 var y2 = x2 - k2;
7089 while (x2 < text1_length && y2 < text2_length &&
7090 text1.charAt(text1_length - x2 - 1) ==
7091 text2.charAt(text2_length - y2 - 1)) {
7092 x2++;
7093 y2++;
7094 }
7095 v2[k2_offset] = x2;
7096 if (x2 > text1_length) {
7097 // Ran off the left of the graph.
7098 k2end += 2;
7099 } else if (y2 > text2_length) {
7100 // Ran off the top of the graph.
7101 k2start += 2;
7102 } else if (!front) {
7103 var k1_offset = v_offset + delta - k2;
7104 if (k1_offset >= 0 && k1_offset < v_length && v1[k1_offset] != -1) {
7105 var x1 = v1[k1_offset];
7106 var y1 = v_offset + x1 - k1_offset;
7107 // Mirror x2 onto top-left coordinate system.
7108 x2 = text1_length - x2;
7109 if (x1 >= x2) {
7110 // Overlap detected.
7111 return diff_bisectSplit_(text1, text2, x1, y1);
7112 }
7113 }
7114 }
7115 }
7116 }
7117 // Diff took too long and hit the deadline or
7118 // number of diffs equals number of characters, no commonality at all.
7119 return [[DIFF_DELETE, text1], [DIFF_INSERT, text2]];
7120};
7121
7122
7123/**
7124 * Given the location of the 'middle snake', split the diff in two parts
7125 * and recurse.
7126 * @param {string} text1 Old string to be diffed.
7127 * @param {string} text2 New string to be diffed.
7128 * @param {number} x Index of split point in text1.
7129 * @param {number} y Index of split point in text2.
7130 * @return {Array} Array of diff tuples.
7131 */
7132function diff_bisectSplit_(text1, text2, x, y) {
7133 var text1a = text1.substring(0, x);
7134 var text2a = text2.substring(0, y);
7135 var text1b = text1.substring(x);
7136 var text2b = text2.substring(y);
7137
7138 // Compute both diffs serially.
7139 var diffs = diff_main(text1a, text2a);
7140 var diffsb = diff_main(text1b, text2b);
7141
7142 return diffs.concat(diffsb);
7143};
7144
7145
7146/**
7147 * Determine the common prefix of two strings.
7148 * @param {string} text1 First string.
7149 * @param {string} text2 Second string.
7150 * @return {number} The number of characters common to the start of each
7151 * string.
7152 */
7153function diff_commonPrefix(text1, text2) {
7154 // Quick check for common null cases.
7155 if (!text1 || !text2 || text1.charAt(0) != text2.charAt(0)) {
7156 return 0;
7157 }
7158 // Binary search.
7159 // Performance analysis: http://neil.fraser.name/news/2007/10/09/
7160 var pointermin = 0;
7161 var pointermax = Math.min(text1.length, text2.length);
7162 var pointermid = pointermax;
7163 var pointerstart = 0;
7164 while (pointermin < pointermid) {
7165 if (text1.substring(pointerstart, pointermid) ==
7166 text2.substring(pointerstart, pointermid)) {
7167 pointermin = pointermid;
7168 pointerstart = pointermin;
7169 } else {
7170 pointermax = pointermid;
7171 }
7172 pointermid = Math.floor((pointermax - pointermin) / 2 + pointermin);
7173 }
7174 return pointermid;
7175};
7176
7177
7178/**
7179 * Determine the common suffix of two strings.
7180 * @param {string} text1 First string.
7181 * @param {string} text2 Second string.
7182 * @return {number} The number of characters common to the end of each string.
7183 */
7184function diff_commonSuffix(text1, text2) {
7185 // Quick check for common null cases.
7186 if (!text1 || !text2 ||
7187 text1.charAt(text1.length - 1) != text2.charAt(text2.length - 1)) {
7188 return 0;
7189 }
7190 // Binary search.
7191 // Performance analysis: http://neil.fraser.name/news/2007/10/09/
7192 var pointermin = 0;
7193 var pointermax = Math.min(text1.length, text2.length);
7194 var pointermid = pointermax;
7195 var pointerend = 0;
7196 while (pointermin < pointermid) {
7197 if (text1.substring(text1.length - pointermid, text1.length - pointerend) ==
7198 text2.substring(text2.length - pointermid, text2.length - pointerend)) {
7199 pointermin = pointermid;
7200 pointerend = pointermin;
7201 } else {
7202 pointermax = pointermid;
7203 }
7204 pointermid = Math.floor((pointermax - pointermin) / 2 + pointermin);
7205 }
7206 return pointermid;
7207};
7208
7209
7210/**
7211 * Do the two texts share a substring which is at least half the length of the
7212 * longer text?
7213 * This speedup can produce non-minimal diffs.
7214 * @param {string} text1 First string.
7215 * @param {string} text2 Second string.
7216 * @return {Array.<string>} Five element Array, containing the prefix of
7217 * text1, the suffix of text1, the prefix of text2, the suffix of
7218 * text2 and the common middle. Or null if there was no match.
7219 */
7220function diff_halfMatch_(text1, text2) {
7221 var longtext = text1.length > text2.length ? text1 : text2;
7222 var shorttext = text1.length > text2.length ? text2 : text1;
7223 if (longtext.length < 4 || shorttext.length * 2 < longtext.length) {
7224 return null; // Pointless.
7225 }
7226
7227 /**
7228 * Does a substring of shorttext exist within longtext such that the substring
7229 * is at least half the length of longtext?
7230 * Closure, but does not reference any external variables.
7231 * @param {string} longtext Longer string.
7232 * @param {string} shorttext Shorter string.
7233 * @param {number} i Start index of quarter length substring within longtext.
7234 * @return {Array.<string>} Five element Array, containing the prefix of
7235 * longtext, the suffix of longtext, the prefix of shorttext, the suffix
7236 * of shorttext and the common middle. Or null if there was no match.
7237 * @private
7238 */
7239 function diff_halfMatchI_(longtext, shorttext, i) {
7240 // Start with a 1/4 length substring at position i as a seed.
7241 var seed = longtext.substring(i, i + Math.floor(longtext.length / 4));
7242 var j = -1;
7243 var best_common = '';
7244 var best_longtext_a, best_longtext_b, best_shorttext_a, best_shorttext_b;
7245 while ((j = shorttext.indexOf(seed, j + 1)) != -1) {
7246 var prefixLength = diff_commonPrefix(longtext.substring(i),
7247 shorttext.substring(j));
7248 var suffixLength = diff_commonSuffix(longtext.substring(0, i),
7249 shorttext.substring(0, j));
7250 if (best_common.length < suffixLength + prefixLength) {
7251 best_common = shorttext.substring(j - suffixLength, j) +
7252 shorttext.substring(j, j + prefixLength);
7253 best_longtext_a = longtext.substring(0, i - suffixLength);
7254 best_longtext_b = longtext.substring(i + prefixLength);
7255 best_shorttext_a = shorttext.substring(0, j - suffixLength);
7256 best_shorttext_b = shorttext.substring(j + prefixLength);
7257 }
7258 }
7259 if (best_common.length * 2 >= longtext.length) {
7260 return [best_longtext_a, best_longtext_b,
7261 best_shorttext_a, best_shorttext_b, best_common];
7262 } else {
7263 return null;
7264 }
7265 }
7266
7267 // First check if the second quarter is the seed for a half-match.
7268 var hm1 = diff_halfMatchI_(longtext, shorttext,
7269 Math.ceil(longtext.length / 4));
7270 // Check again based on the third quarter.
7271 var hm2 = diff_halfMatchI_(longtext, shorttext,
7272 Math.ceil(longtext.length / 2));
7273 var hm;
7274 if (!hm1 && !hm2) {
7275 return null;
7276 } else if (!hm2) {
7277 hm = hm1;
7278 } else if (!hm1) {
7279 hm = hm2;
7280 } else {
7281 // Both matched. Select the longest.
7282 hm = hm1[4].length > hm2[4].length ? hm1 : hm2;
7283 }
7284
7285 // A half-match was found, sort out the return data.
7286 var text1_a, text1_b, text2_a, text2_b;
7287 if (text1.length > text2.length) {
7288 text1_a = hm[0];
7289 text1_b = hm[1];
7290 text2_a = hm[2];
7291 text2_b = hm[3];
7292 } else {
7293 text2_a = hm[0];
7294 text2_b = hm[1];
7295 text1_a = hm[2];
7296 text1_b = hm[3];
7297 }
7298 var mid_common = hm[4];
7299 return [text1_a, text1_b, text2_a, text2_b, mid_common];
7300};
7301
7302
7303/**
7304 * Reorder and merge like edit sections. Merge equalities.
7305 * Any edit section can move as long as it doesn't cross an equality.
7306 * @param {Array} diffs Array of diff tuples.
7307 */
7308function diff_cleanupMerge(diffs) {
7309 diffs.push([DIFF_EQUAL, '']); // Add a dummy entry at the end.
7310 var pointer = 0;
7311 var count_delete = 0;
7312 var count_insert = 0;
7313 var text_delete = '';
7314 var text_insert = '';
7315 var commonlength;
7316 while (pointer < diffs.length) {
7317 switch (diffs[pointer][0]) {
7318 case DIFF_INSERT:
7319 count_insert++;
7320 text_insert += diffs[pointer][1];
7321 pointer++;
7322 break;
7323 case DIFF_DELETE:
7324 count_delete++;
7325 text_delete += diffs[pointer][1];
7326 pointer++;
7327 break;
7328 case DIFF_EQUAL:
7329 // Upon reaching an equality, check for prior redundancies.
7330 if (count_delete + count_insert > 1) {
7331 if (count_delete !== 0 && count_insert !== 0) {
7332 // Factor out any common prefixies.
7333 commonlength = diff_commonPrefix(text_insert, text_delete);
7334 if (commonlength !== 0) {
7335 if ((pointer - count_delete - count_insert) > 0 &&
7336 diffs[pointer - count_delete - count_insert - 1][0] ==
7337 DIFF_EQUAL) {
7338 diffs[pointer - count_delete - count_insert - 1][1] +=
7339 text_insert.substring(0, commonlength);
7340 } else {
7341 diffs.splice(0, 0, [DIFF_EQUAL,
7342 text_insert.substring(0, commonlength)]);
7343 pointer++;
7344 }
7345 text_insert = text_insert.substring(commonlength);
7346 text_delete = text_delete.substring(commonlength);
7347 }
7348 // Factor out any common suffixies.
7349 commonlength = diff_commonSuffix(text_insert, text_delete);
7350 if (commonlength !== 0) {
7351 diffs[pointer][1] = text_insert.substring(text_insert.length -
7352 commonlength) + diffs[pointer][1];
7353 text_insert = text_insert.substring(0, text_insert.length -
7354 commonlength);
7355 text_delete = text_delete.substring(0, text_delete.length -
7356 commonlength);
7357 }
7358 }
7359 // Delete the offending records and add the merged ones.
7360 if (count_delete === 0) {
7361 diffs.splice(pointer - count_insert,
7362 count_delete + count_insert, [DIFF_INSERT, text_insert]);
7363 } else if (count_insert === 0) {
7364 diffs.splice(pointer - count_delete,
7365 count_delete + count_insert, [DIFF_DELETE, text_delete]);
7366 } else {
7367 diffs.splice(pointer - count_delete - count_insert,
7368 count_delete + count_insert, [DIFF_DELETE, text_delete],
7369 [DIFF_INSERT, text_insert]);
7370 }
7371 pointer = pointer - count_delete - count_insert +
7372 (count_delete ? 1 : 0) + (count_insert ? 1 : 0) + 1;
7373 } else if (pointer !== 0 && diffs[pointer - 1][0] == DIFF_EQUAL) {
7374 // Merge this equality with the previous one.
7375 diffs[pointer - 1][1] += diffs[pointer][1];
7376 diffs.splice(pointer, 1);
7377 } else {
7378 pointer++;
7379 }
7380 count_insert = 0;
7381 count_delete = 0;
7382 text_delete = '';
7383 text_insert = '';
7384 break;
7385 }
7386 }
7387 if (diffs[diffs.length - 1][1] === '') {
7388 diffs.pop(); // Remove the dummy entry at the end.
7389 }
7390
7391 // Second pass: look for single edits surrounded on both sides by equalities
7392 // which can be shifted sideways to eliminate an equality.
7393 // e.g: A<ins>BA</ins>C -> <ins>AB</ins>AC
7394 var changes = false;
7395 pointer = 1;
7396 // Intentionally ignore the first and last element (don't need checking).
7397 while (pointer < diffs.length - 1) {
7398 if (diffs[pointer - 1][0] == DIFF_EQUAL &&
7399 diffs[pointer + 1][0] == DIFF_EQUAL) {
7400 // This is a single edit surrounded by equalities.
7401 if (diffs[pointer][1].substring(diffs[pointer][1].length -
7402 diffs[pointer - 1][1].length) == diffs[pointer - 1][1]) {
7403 // Shift the edit over the previous equality.
7404 diffs[pointer][1] = diffs[pointer - 1][1] +
7405 diffs[pointer][1].substring(0, diffs[pointer][1].length -
7406 diffs[pointer - 1][1].length);
7407 diffs[pointer + 1][1] = diffs[pointer - 1][1] + diffs[pointer + 1][1];
7408 diffs.splice(pointer - 1, 1);
7409 changes = true;
7410 } else if (diffs[pointer][1].substring(0, diffs[pointer + 1][1].length) ==
7411 diffs[pointer + 1][1]) {
7412 // Shift the edit over the next equality.
7413 diffs[pointer - 1][1] += diffs[pointer + 1][1];
7414 diffs[pointer][1] =
7415 diffs[pointer][1].substring(diffs[pointer + 1][1].length) +
7416 diffs[pointer + 1][1];
7417 diffs.splice(pointer + 1, 1);
7418 changes = true;
7419 }
7420 }
7421 pointer++;
7422 }
7423 // If shifts were made, the diff needs reordering and another shift sweep.
7424 if (changes) {
7425 diff_cleanupMerge(diffs);
7426 }
7427};
7428
7429
7430var diff = diff_main;
7431diff.INSERT = DIFF_INSERT;
7432diff.DELETE = DIFF_DELETE;
7433diff.EQUAL = DIFF_EQUAL;
7434
7435module.exports = diff;
7436
7437/*
7438 * Modify a diff such that the cursor position points to the start of a change:
7439 * E.g.
7440 * cursor_normalize_diff([[DIFF_EQUAL, 'abc']], 1)
7441 * => [1, [[DIFF_EQUAL, 'a'], [DIFF_EQUAL, 'bc']]]
7442 * cursor_normalize_diff([[DIFF_INSERT, 'new'], [DIFF_DELETE, 'xyz']], 2)
7443 * => [2, [[DIFF_INSERT, 'new'], [DIFF_DELETE, 'xy'], [DIFF_DELETE, 'z']]]
7444 *
7445 * @param {Array} diffs Array of diff tuples
7446 * @param {Int} cursor_pos Suggested edit position. Must not be out of bounds!
7447 * @return {Array} A tuple [cursor location in the modified diff, modified diff]
7448 */
7449function cursor_normalize_diff (diffs, cursor_pos) {
7450 if (cursor_pos === 0) {
7451 return [DIFF_EQUAL, diffs];
7452 }
7453 for (var current_pos = 0, i = 0; i < diffs.length; i++) {
7454 var d = diffs[i];
7455 if (d[0] === DIFF_DELETE || d[0] === DIFF_EQUAL) {
7456 var next_pos = current_pos + d[1].length;
7457 if (cursor_pos === next_pos) {
7458 return [i + 1, diffs];
7459 } else if (cursor_pos < next_pos) {
7460 // copy to prevent side effects
7461 diffs = diffs.slice();
7462 // split d into two diff changes
7463 var split_pos = cursor_pos - current_pos;
7464 var d_left = [d[0], d[1].slice(0, split_pos)];
7465 var d_right = [d[0], d[1].slice(split_pos)];
7466 diffs.splice(i, 1, d_left, d_right);
7467 return [i + 1, diffs];
7468 } else {
7469 current_pos = next_pos;
7470 }
7471 }
7472 }
7473 throw new Error('cursor_pos is out of bounds!')
7474}
7475
7476/*
7477 * Modify a diff such that the edit position is "shifted" to the proposed edit location (cursor_position).
7478 *
7479 * Case 1)
7480 * Check if a naive shift is possible:
7481 * [0, X], [ 1, Y] -> [ 1, Y], [0, X] (if X + Y === Y + X)
7482 * [0, X], [-1, Y] -> [-1, Y], [0, X] (if X + Y === Y + X) - holds same result
7483 * Case 2)
7484 * Check if the following shifts are possible:
7485 * [0, 'pre'], [ 1, 'prefix'] -> [ 1, 'pre'], [0, 'pre'], [ 1, 'fix']
7486 * [0, 'pre'], [-1, 'prefix'] -> [-1, 'pre'], [0, 'pre'], [-1, 'fix']
7487 * ^ ^
7488 * d d_next
7489 *
7490 * @param {Array} diffs Array of diff tuples
7491 * @param {Int} cursor_pos Suggested edit position. Must not be out of bounds!
7492 * @return {Array} Array of diff tuples
7493 */
7494function fix_cursor (diffs, cursor_pos) {
7495 var norm = cursor_normalize_diff(diffs, cursor_pos);
7496 var ndiffs = norm[1];
7497 var cursor_pointer = norm[0];
7498 var d = ndiffs[cursor_pointer];
7499 var d_next = ndiffs[cursor_pointer + 1];
7500
7501 if (d == null) {
7502 // Text was deleted from end of original string,
7503 // cursor is now out of bounds in new string
7504 return diffs;
7505 } else if (d[0] !== DIFF_EQUAL) {
7506 // A modification happened at the cursor location.
7507 // This is the expected outcome, so we can return the original diff.
7508 return diffs;
7509 } else {
7510 if (d_next != null && d[1] + d_next[1] === d_next[1] + d[1]) {
7511 // Case 1)
7512 // It is possible to perform a naive shift
7513 ndiffs.splice(cursor_pointer, 2, d_next, d)
7514 return merge_tuples(ndiffs, cursor_pointer, 2)
7515 } else if (d_next != null && d_next[1].indexOf(d[1]) === 0) {
7516 // Case 2)
7517 // d[1] is a prefix of d_next[1]
7518 // We can assume that d_next[0] !== 0, since d[0] === 0
7519 // Shift edit locations..
7520 ndiffs.splice(cursor_pointer, 2, [d_next[0], d[1]], [0, d[1]]);
7521 var suffix = d_next[1].slice(d[1].length);
7522 if (suffix.length > 0) {
7523 ndiffs.splice(cursor_pointer + 2, 0, [d_next[0], suffix]);
7524 }
7525 return merge_tuples(ndiffs, cursor_pointer, 3)
7526 } else {
7527 // Not possible to perform any modification
7528 return diffs;
7529 }
7530 }
7531
7532}
7533
7534/*
7535 * Try to merge tuples with their neigbors in a given range.
7536 * E.g. [0, 'a'], [0, 'b'] -> [0, 'ab']
7537 *
7538 * @param {Array} diffs Array of diff tuples.
7539 * @param {Int} start Position of the first element to merge (diffs[start] is also merged with diffs[start - 1]).
7540 * @param {Int} length Number of consecutive elements to check.
7541 * @return {Array} Array of merged diff tuples.
7542 */
7543function merge_tuples (diffs, start, length) {
7544 // Check from (start-1) to (start+length).
7545 for (var i = start + length - 1; i >= 0 && i >= start - 1; i--) {
7546 if (i + 1 < diffs.length) {
7547 var left_d = diffs[i];
7548 var right_d = diffs[i+1];
7549 if (left_d[0] === right_d[1]) {
7550 diffs.splice(i, 2, [left_d[0], left_d[1] + right_d[1]]);
7551 }
7552 }
7553 }
7554 return diffs;
7555}
7556
7557
7558/***/ }),
7559/* 52 */
7560/***/ (function(module, exports) {
7561
7562exports = module.exports = typeof Object.keys === 'function'
7563 ? Object.keys : shim;
7564
7565exports.shim = shim;
7566function shim (obj) {
7567 var keys = [];
7568 for (var key in obj) keys.push(key);
7569 return keys;
7570}
7571
7572
7573/***/ }),
7574/* 53 */
7575/***/ (function(module, exports) {
7576
7577var supportsArgumentsClass = (function(){
7578 return Object.prototype.toString.call(arguments)
7579})() == '[object Arguments]';
7580
7581exports = module.exports = supportsArgumentsClass ? supported : unsupported;
7582
7583exports.supported = supported;
7584function supported(object) {
7585 return Object.prototype.toString.call(object) == '[object Arguments]';
7586};
7587
7588exports.unsupported = unsupported;
7589function unsupported(object){
7590 return object &&
7591 typeof object == 'object' &&
7592 typeof object.length == 'number' &&
7593 Object.prototype.hasOwnProperty.call(object, 'callee') &&
7594 !Object.prototype.propertyIsEnumerable.call(object, 'callee') ||
7595 false;
7596};
7597
7598
7599/***/ }),
7600/* 54 */
7601/***/ (function(module, exports) {
7602
7603'use strict';
7604
7605var has = Object.prototype.hasOwnProperty
7606 , prefix = '~';
7607
7608/**
7609 * Constructor to create a storage for our `EE` objects.
7610 * An `Events` instance is a plain object whose properties are event names.
7611 *
7612 * @constructor
7613 * @api private
7614 */
7615function Events() {}
7616
7617//
7618// We try to not inherit from `Object.prototype`. In some engines creating an
7619// instance in this way is faster than calling `Object.create(null)` directly.
7620// If `Object.create(null)` is not supported we prefix the event names with a
7621// character to make sure that the built-in object properties are not
7622// overridden or used as an attack vector.
7623//
7624if (Object.create) {
7625 Events.prototype = Object.create(null);
7626
7627 //
7628 // This hack is needed because the `__proto__` property is still inherited in
7629 // some old browsers like Android 4, iPhone 5.1, Opera 11 and Safari 5.
7630 //
7631 if (!new Events().__proto__) prefix = false;
7632}
7633
7634/**
7635 * Representation of a single event listener.
7636 *
7637 * @param {Function} fn The listener function.
7638 * @param {Mixed} context The context to invoke the listener with.
7639 * @param {Boolean} [once=false] Specify if the listener is a one-time listener.
7640 * @constructor
7641 * @api private
7642 */
7643function EE(fn, context, once) {
7644 this.fn = fn;
7645 this.context = context;
7646 this.once = once || false;
7647}
7648
7649/**
7650 * Minimal `EventEmitter` interface that is molded against the Node.js
7651 * `EventEmitter` interface.
7652 *
7653 * @constructor
7654 * @api public
7655 */
7656function EventEmitter() {
7657 this._events = new Events();
7658 this._eventsCount = 0;
7659}
7660
7661/**
7662 * Return an array listing the events for which the emitter has registered
7663 * listeners.
7664 *
7665 * @returns {Array}
7666 * @api public
7667 */
7668EventEmitter.prototype.eventNames = function eventNames() {
7669 var names = []
7670 , events
7671 , name;
7672
7673 if (this._eventsCount === 0) return names;
7674
7675 for (name in (events = this._events)) {
7676 if (has.call(events, name)) names.push(prefix ? name.slice(1) : name);
7677 }
7678
7679 if (Object.getOwnPropertySymbols) {
7680 return names.concat(Object.getOwnPropertySymbols(events));
7681 }
7682
7683 return names;
7684};
7685
7686/**
7687 * Return the listeners registered for a given event.
7688 *
7689 * @param {String|Symbol} event The event name.
7690 * @param {Boolean} exists Only check if there are listeners.
7691 * @returns {Array|Boolean}
7692 * @api public
7693 */
7694EventEmitter.prototype.listeners = function listeners(event, exists) {
7695 var evt = prefix ? prefix + event : event
7696 , available = this._events[evt];
7697
7698 if (exists) return !!available;
7699 if (!available) return [];
7700 if (available.fn) return [available.fn];
7701
7702 for (var i = 0, l = available.length, ee = new Array(l); i < l; i++) {
7703 ee[i] = available[i].fn;
7704 }
7705
7706 return ee;
7707};
7708
7709/**
7710 * Calls each of the listeners registered for a given event.
7711 *
7712 * @param {String|Symbol} event The event name.
7713 * @returns {Boolean} `true` if the event had listeners, else `false`.
7714 * @api public
7715 */
7716EventEmitter.prototype.emit = function emit(event, a1, a2, a3, a4, a5) {
7717 var evt = prefix ? prefix + event : event;
7718
7719 if (!this._events[evt]) return false;
7720
7721 var listeners = this._events[evt]
7722 , len = arguments.length
7723 , args
7724 , i;
7725
7726 if (listeners.fn) {
7727 if (listeners.once) this.removeListener(event, listeners.fn, undefined, true);
7728
7729 switch (len) {
7730 case 1: return listeners.fn.call(listeners.context), true;
7731 case 2: return listeners.fn.call(listeners.context, a1), true;
7732 case 3: return listeners.fn.call(listeners.context, a1, a2), true;
7733 case 4: return listeners.fn.call(listeners.context, a1, a2, a3), true;
7734 case 5: return listeners.fn.call(listeners.context, a1, a2, a3, a4), true;
7735 case 6: return listeners.fn.call(listeners.context, a1, a2, a3, a4, a5), true;
7736 }
7737
7738 for (i = 1, args = new Array(len -1); i < len; i++) {
7739 args[i - 1] = arguments[i];
7740 }
7741
7742 listeners.fn.apply(listeners.context, args);
7743 } else {
7744 var length = listeners.length
7745 , j;
7746
7747 for (i = 0; i < length; i++) {
7748 if (listeners[i].once) this.removeListener(event, listeners[i].fn, undefined, true);
7749
7750 switch (len) {
7751 case 1: listeners[i].fn.call(listeners[i].context); break;
7752 case 2: listeners[i].fn.call(listeners[i].context, a1); break;
7753 case 3: listeners[i].fn.call(listeners[i].context, a1, a2); break;
7754 case 4: listeners[i].fn.call(listeners[i].context, a1, a2, a3); break;
7755 default:
7756 if (!args) for (j = 1, args = new Array(len -1); j < len; j++) {
7757 args[j - 1] = arguments[j];
7758 }
7759
7760 listeners[i].fn.apply(listeners[i].context, args);
7761 }
7762 }
7763 }
7764
7765 return true;
7766};
7767
7768/**
7769 * Add a listener for a given event.
7770 *
7771 * @param {String|Symbol} event The event name.
7772 * @param {Function} fn The listener function.
7773 * @param {Mixed} [context=this] The context to invoke the listener with.
7774 * @returns {EventEmitter} `this`.
7775 * @api public
7776 */
7777EventEmitter.prototype.on = function on(event, fn, context) {
7778 var listener = new EE(fn, context || this)
7779 , evt = prefix ? prefix + event : event;
7780
7781 if (!this._events[evt]) this._events[evt] = listener, this._eventsCount++;
7782 else if (!this._events[evt].fn) this._events[evt].push(listener);
7783 else this._events[evt] = [this._events[evt], listener];
7784
7785 return this;
7786};
7787
7788/**
7789 * Add a one-time listener for a given event.
7790 *
7791 * @param {String|Symbol} event The event name.
7792 * @param {Function} fn The listener function.
7793 * @param {Mixed} [context=this] The context to invoke the listener with.
7794 * @returns {EventEmitter} `this`.
7795 * @api public
7796 */
7797EventEmitter.prototype.once = function once(event, fn, context) {
7798 var listener = new EE(fn, context || this, true)
7799 , evt = prefix ? prefix + event : event;
7800
7801 if (!this._events[evt]) this._events[evt] = listener, this._eventsCount++;
7802 else if (!this._events[evt].fn) this._events[evt].push(listener);
7803 else this._events[evt] = [this._events[evt], listener];
7804
7805 return this;
7806};
7807
7808/**
7809 * Remove the listeners of a given event.
7810 *
7811 * @param {String|Symbol} event The event name.
7812 * @param {Function} fn Only remove the listeners that match this function.
7813 * @param {Mixed} context Only remove the listeners that have this context.
7814 * @param {Boolean} once Only remove one-time listeners.
7815 * @returns {EventEmitter} `this`.
7816 * @api public
7817 */
7818EventEmitter.prototype.removeListener = function removeListener(event, fn, context, once) {
7819 var evt = prefix ? prefix + event : event;
7820
7821 if (!this._events[evt]) return this;
7822 if (!fn) {
7823 if (--this._eventsCount === 0) this._events = new Events();
7824 else delete this._events[evt];
7825 return this;
7826 }
7827
7828 var listeners = this._events[evt];
7829
7830 if (listeners.fn) {
7831 if (
7832 listeners.fn === fn
7833 && (!once || listeners.once)
7834 && (!context || listeners.context === context)
7835 ) {
7836 if (--this._eventsCount === 0) this._events = new Events();
7837 else delete this._events[evt];
7838 }
7839 } else {
7840 for (var i = 0, events = [], length = listeners.length; i < length; i++) {
7841 if (
7842 listeners[i].fn !== fn
7843 || (once && !listeners[i].once)
7844 || (context && listeners[i].context !== context)
7845 ) {
7846 events.push(listeners[i]);
7847 }
7848 }
7849
7850 //
7851 // Reset the array, or remove it completely if we have no more listeners.
7852 //
7853 if (events.length) this._events[evt] = events.length === 1 ? events[0] : events;
7854 else if (--this._eventsCount === 0) this._events = new Events();
7855 else delete this._events[evt];
7856 }
7857
7858 return this;
7859};
7860
7861/**
7862 * Remove all listeners, or those of the specified event.
7863 *
7864 * @param {String|Symbol} [event] The event name.
7865 * @returns {EventEmitter} `this`.
7866 * @api public
7867 */
7868EventEmitter.prototype.removeAllListeners = function removeAllListeners(event) {
7869 var evt;
7870
7871 if (event) {
7872 evt = prefix ? prefix + event : event;
7873 if (this._events[evt]) {
7874 if (--this._eventsCount === 0) this._events = new Events();
7875 else delete this._events[evt];
7876 }
7877 } else {
7878 this._events = new Events();
7879 this._eventsCount = 0;
7880 }
7881
7882 return this;
7883};
7884
7885//
7886// Alias methods names because people roll like that.
7887//
7888EventEmitter.prototype.off = EventEmitter.prototype.removeListener;
7889EventEmitter.prototype.addListener = EventEmitter.prototype.on;
7890
7891//
7892// This function doesn't apply anymore.
7893//
7894EventEmitter.prototype.setMaxListeners = function setMaxListeners() {
7895 return this;
7896};
7897
7898//
7899// Expose the prefix.
7900//
7901EventEmitter.prefixed = prefix;
7902
7903//
7904// Allow `EventEmitter` to be imported as module namespace.
7905//
7906EventEmitter.EventEmitter = EventEmitter;
7907
7908//
7909// Expose the module.
7910//
7911if ('undefined' !== typeof module) {
7912 module.exports = EventEmitter;
7913}
7914
7915
7916/***/ }),
7917/* 55 */
7918/***/ (function(module, exports, __webpack_require__) {
7919
7920"use strict";
7921
7922
7923Object.defineProperty(exports, "__esModule", {
7924 value: true
7925});
7926exports.matchText = exports.matchSpacing = exports.matchNewline = exports.matchBlot = exports.matchAttributor = exports.default = undefined;
7927
7928var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
7929
7930var _slicedToArray = function () { function sliceIterator(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"]) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } return function (arr, i) { if (Array.isArray(arr)) { return arr; } else if (Symbol.iterator in Object(arr)) { return sliceIterator(arr, i); } else { throw new TypeError("Invalid attempt to destructure non-iterable instance"); } }; }();
7931
7932var _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; }; }();
7933
7934var _extend2 = __webpack_require__(3);
7935
7936var _extend3 = _interopRequireDefault(_extend2);
7937
7938var _quillDelta = __webpack_require__(2);
7939
7940var _quillDelta2 = _interopRequireDefault(_quillDelta);
7941
7942var _parchment = __webpack_require__(0);
7943
7944var _parchment2 = _interopRequireDefault(_parchment);
7945
7946var _quill = __webpack_require__(5);
7947
7948var _quill2 = _interopRequireDefault(_quill);
7949
7950var _logger = __webpack_require__(10);
7951
7952var _logger2 = _interopRequireDefault(_logger);
7953
7954var _module = __webpack_require__(9);
7955
7956var _module2 = _interopRequireDefault(_module);
7957
7958var _align = __webpack_require__(36);
7959
7960var _background = __webpack_require__(37);
7961
7962var _code = __webpack_require__(13);
7963
7964var _code2 = _interopRequireDefault(_code);
7965
7966var _color = __webpack_require__(26);
7967
7968var _direction = __webpack_require__(38);
7969
7970var _font = __webpack_require__(39);
7971
7972var _size = __webpack_require__(40);
7973
7974function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
7975
7976function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
7977
7978function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
7979
7980function _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; }
7981
7982function _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; }
7983
7984var debug = (0, _logger2.default)('quill:clipboard');
7985
7986var DOM_KEY = '__ql-matcher';
7987
7988var CLIPBOARD_CONFIG = [[Node.TEXT_NODE, matchText], [Node.TEXT_NODE, matchNewline], ['br', matchBreak], [Node.ELEMENT_NODE, matchNewline], [Node.ELEMENT_NODE, matchBlot], [Node.ELEMENT_NODE, matchSpacing], [Node.ELEMENT_NODE, matchAttributor], [Node.ELEMENT_NODE, matchStyles], ['li', matchIndent], ['b', matchAlias.bind(matchAlias, 'bold')], ['i', matchAlias.bind(matchAlias, 'italic')], ['style', matchIgnore]];
7989
7990var ATTRIBUTE_ATTRIBUTORS = [_align.AlignAttribute, _direction.DirectionAttribute].reduce(function (memo, attr) {
7991 memo[attr.keyName] = attr;
7992 return memo;
7993}, {});
7994
7995var STYLE_ATTRIBUTORS = [_align.AlignStyle, _background.BackgroundStyle, _color.ColorStyle, _direction.DirectionStyle, _font.FontStyle, _size.SizeStyle].reduce(function (memo, attr) {
7996 memo[attr.keyName] = attr;
7997 return memo;
7998}, {});
7999
8000var Clipboard = function (_Module) {
8001 _inherits(Clipboard, _Module);
8002
8003 function Clipboard(quill, options) {
8004 _classCallCheck(this, Clipboard);
8005
8006 var _this = _possibleConstructorReturn(this, (Clipboard.__proto__ || Object.getPrototypeOf(Clipboard)).call(this, quill, options));
8007
8008 _this.quill.root.addEventListener('paste', _this.onPaste.bind(_this));
8009 _this.container = _this.quill.addContainer('ql-clipboard');
8010 _this.container.setAttribute('contenteditable', true);
8011 _this.container.setAttribute('tabindex', -1);
8012 _this.matchers = [];
8013 CLIPBOARD_CONFIG.concat(_this.options.matchers).forEach(function (_ref) {
8014 var _ref2 = _slicedToArray(_ref, 2),
8015 selector = _ref2[0],
8016 matcher = _ref2[1];
8017
8018 if (!options.matchVisual && matcher === matchSpacing) return;
8019 _this.addMatcher(selector, matcher);
8020 });
8021 return _this;
8022 }
8023
8024 _createClass(Clipboard, [{
8025 key: 'addMatcher',
8026 value: function addMatcher(selector, matcher) {
8027 this.matchers.push([selector, matcher]);
8028 }
8029 }, {
8030 key: 'convert',
8031 value: function convert(html) {
8032 if (typeof html === 'string') {
8033 this.container.innerHTML = html.replace(/\>\r?\n +\</g, '><'); // Remove spaces between tags
8034 return this.convert();
8035 }
8036 var formats = this.quill.getFormat(this.quill.selection.savedRange.index);
8037 if (formats[_code2.default.blotName]) {
8038 var text = this.container.innerText;
8039 this.container.innerHTML = '';
8040 return new _quillDelta2.default().insert(text, _defineProperty({}, _code2.default.blotName, formats[_code2.default.blotName]));
8041 }
8042
8043 var _prepareMatching = this.prepareMatching(),
8044 _prepareMatching2 = _slicedToArray(_prepareMatching, 2),
8045 elementMatchers = _prepareMatching2[0],
8046 textMatchers = _prepareMatching2[1];
8047
8048 var delta = traverse(this.container, elementMatchers, textMatchers);
8049 // Remove trailing newline
8050 if (deltaEndsWith(delta, '\n') && delta.ops[delta.ops.length - 1].attributes == null) {
8051 delta = delta.compose(new _quillDelta2.default().retain(delta.length() - 1).delete(1));
8052 }
8053 debug.log('convert', this.container.innerHTML, delta);
8054 this.container.innerHTML = '';
8055 return delta;
8056 }
8057 }, {
8058 key: 'dangerouslyPasteHTML',
8059 value: function dangerouslyPasteHTML(index, html) {
8060 var source = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : _quill2.default.sources.API;
8061
8062 if (typeof index === 'string') {
8063 return this.quill.setContents(this.convert(index), html);
8064 } else {
8065 var paste = this.convert(html);
8066 return this.quill.updateContents(new _quillDelta2.default().retain(index).concat(paste), source);
8067 }
8068 }
8069 }, {
8070 key: 'onPaste',
8071 value: function onPaste(e) {
8072 var _this2 = this;
8073
8074 if (e.defaultPrevented || !this.quill.isEnabled()) return;
8075 var range = this.quill.getSelection();
8076 var delta = new _quillDelta2.default().retain(range.index);
8077 var scrollTop = this.quill.scrollingContainer.scrollTop;
8078 this.container.focus();
8079 this.quill.selection.update(_quill2.default.sources.SILENT);
8080 setTimeout(function () {
8081 delta = delta.concat(_this2.convert()).delete(range.length);
8082 _this2.quill.updateContents(delta, _quill2.default.sources.USER);
8083 // range.length contributes to delta.length()
8084 _this2.quill.setSelection(delta.length() - range.length, _quill2.default.sources.SILENT);
8085 _this2.quill.scrollingContainer.scrollTop = scrollTop;
8086 _this2.quill.focus();
8087 }, 1);
8088 }
8089 }, {
8090 key: 'prepareMatching',
8091 value: function prepareMatching() {
8092 var _this3 = this;
8093
8094 var elementMatchers = [],
8095 textMatchers = [];
8096 this.matchers.forEach(function (pair) {
8097 var _pair = _slicedToArray(pair, 2),
8098 selector = _pair[0],
8099 matcher = _pair[1];
8100
8101 switch (selector) {
8102 case Node.TEXT_NODE:
8103 textMatchers.push(matcher);
8104 break;
8105 case Node.ELEMENT_NODE:
8106 elementMatchers.push(matcher);
8107 break;
8108 default:
8109 [].forEach.call(_this3.container.querySelectorAll(selector), function (node) {
8110 // TODO use weakmap
8111 node[DOM_KEY] = node[DOM_KEY] || [];
8112 node[DOM_KEY].push(matcher);
8113 });
8114 break;
8115 }
8116 });
8117 return [elementMatchers, textMatchers];
8118 }
8119 }]);
8120
8121 return Clipboard;
8122}(_module2.default);
8123
8124Clipboard.DEFAULTS = {
8125 matchers: [],
8126 matchVisual: true
8127};
8128
8129function applyFormat(delta, format, value) {
8130 if ((typeof format === 'undefined' ? 'undefined' : _typeof(format)) === 'object') {
8131 return Object.keys(format).reduce(function (delta, key) {
8132 return applyFormat(delta, key, format[key]);
8133 }, delta);
8134 } else {
8135 return delta.reduce(function (delta, op) {
8136 if (op.attributes && op.attributes[format]) {
8137 return delta.push(op);
8138 } else {
8139 return delta.insert(op.insert, (0, _extend3.default)({}, _defineProperty({}, format, value), op.attributes));
8140 }
8141 }, new _quillDelta2.default());
8142 }
8143}
8144
8145function computeStyle(node) {
8146 if (node.nodeType !== Node.ELEMENT_NODE) return {};
8147 var DOM_KEY = '__ql-computed-style';
8148 return node[DOM_KEY] || (node[DOM_KEY] = window.getComputedStyle(node));
8149}
8150
8151function deltaEndsWith(delta, text) {
8152 var endText = "";
8153 for (var i = delta.ops.length - 1; i >= 0 && endText.length < text.length; --i) {
8154 var op = delta.ops[i];
8155 if (typeof op.insert !== 'string') break;
8156 endText = op.insert + endText;
8157 }
8158 return endText.slice(-1 * text.length) === text;
8159}
8160
8161function isLine(node) {
8162 if (node.childNodes.length === 0) return false; // Exclude embed blocks
8163 var style = computeStyle(node);
8164 return ['block', 'list-item'].indexOf(style.display) > -1;
8165}
8166
8167function traverse(node, elementMatchers, textMatchers) {
8168 // Post-order
8169 if (node.nodeType === node.TEXT_NODE) {
8170 return textMatchers.reduce(function (delta, matcher) {
8171 return matcher(node, delta);
8172 }, new _quillDelta2.default());
8173 } else if (node.nodeType === node.ELEMENT_NODE) {
8174 return [].reduce.call(node.childNodes || [], function (delta, childNode) {
8175 var childrenDelta = traverse(childNode, elementMatchers, textMatchers);
8176 if (childNode.nodeType === node.ELEMENT_NODE) {
8177 childrenDelta = elementMatchers.reduce(function (childrenDelta, matcher) {
8178 return matcher(childNode, childrenDelta);
8179 }, childrenDelta);
8180 childrenDelta = (childNode[DOM_KEY] || []).reduce(function (childrenDelta, matcher) {
8181 return matcher(childNode, childrenDelta);
8182 }, childrenDelta);
8183 }
8184 return delta.concat(childrenDelta);
8185 }, new _quillDelta2.default());
8186 } else {
8187 return new _quillDelta2.default();
8188 }
8189}
8190
8191function matchAlias(format, node, delta) {
8192 return applyFormat(delta, format, true);
8193}
8194
8195function matchAttributor(node, delta) {
8196 var attributes = _parchment2.default.Attributor.Attribute.keys(node);
8197 var classes = _parchment2.default.Attributor.Class.keys(node);
8198 var styles = _parchment2.default.Attributor.Style.keys(node);
8199 var formats = {};
8200 attributes.concat(classes).concat(styles).forEach(function (name) {
8201 var attr = _parchment2.default.query(name, _parchment2.default.Scope.ATTRIBUTE);
8202 if (attr != null) {
8203 formats[attr.attrName] = attr.value(node);
8204 if (formats[attr.attrName]) return;
8205 }
8206 attr = ATTRIBUTE_ATTRIBUTORS[name];
8207 if (attr != null && attr.attrName === name) {
8208 formats[attr.attrName] = attr.value(node) || undefined;
8209 }
8210 attr = STYLE_ATTRIBUTORS[name];
8211 if (attr != null && attr.attrName === name) {
8212 attr = STYLE_ATTRIBUTORS[name];
8213 formats[attr.attrName] = attr.value(node) || undefined;
8214 }
8215 });
8216 if (Object.keys(formats).length > 0) {
8217 delta = applyFormat(delta, formats);
8218 }
8219 return delta;
8220}
8221
8222function matchBlot(node, delta) {
8223 var match = _parchment2.default.query(node);
8224 if (match == null) return delta;
8225 if (match.prototype instanceof _parchment2.default.Embed) {
8226 var embed = {};
8227 var value = match.value(node);
8228 if (value != null) {
8229 embed[match.blotName] = value;
8230 delta = new _quillDelta2.default().insert(embed, match.formats(node));
8231 }
8232 } else if (typeof match.formats === 'function') {
8233 delta = applyFormat(delta, match.blotName, match.formats(node));
8234 }
8235 return delta;
8236}
8237
8238function matchBreak(node, delta) {
8239 if (!deltaEndsWith(delta, '\n')) {
8240 delta.insert('\n');
8241 }
8242 return delta;
8243}
8244
8245function matchIgnore() {
8246 return new _quillDelta2.default();
8247}
8248
8249function matchIndent(node, delta) {
8250 var match = _parchment2.default.query(node);
8251 if (match == null || match.blotName !== 'list-item' || !deltaEndsWith(delta, '\n')) {
8252 return delta;
8253 }
8254 var indent = -1,
8255 parent = node.parentNode;
8256 while (!parent.classList.contains('ql-clipboard')) {
8257 if ((_parchment2.default.query(parent) || {}).blotName === 'list') {
8258 indent += 1;
8259 }
8260 parent = parent.parentNode;
8261 }
8262 if (indent <= 0) return delta;
8263 return delta.compose(new _quillDelta2.default().retain(delta.length() - 1).retain(1, { indent: indent }));
8264}
8265
8266function matchNewline(node, delta) {
8267 if (!deltaEndsWith(delta, '\n')) {
8268 if (isLine(node) || delta.length() > 0 && node.nextSibling && isLine(node.nextSibling)) {
8269 delta.insert('\n');
8270 }
8271 }
8272 return delta;
8273}
8274
8275function matchSpacing(node, delta) {
8276 if (isLine(node) && node.nextElementSibling != null && !deltaEndsWith(delta, '\n\n')) {
8277 var nodeHeight = node.offsetHeight + parseFloat(computeStyle(node).marginTop) + parseFloat(computeStyle(node).marginBottom);
8278 if (node.nextElementSibling.offsetTop > node.offsetTop + nodeHeight * 1.5) {
8279 delta.insert('\n');
8280 }
8281 }
8282 return delta;
8283}
8284
8285function matchStyles(node, delta) {
8286 var formats = {};
8287 var style = node.style || {};
8288 if (style.fontStyle && computeStyle(node).fontStyle === 'italic') {
8289 formats.italic = true;
8290 }
8291 if (style.fontWeight && (computeStyle(node).fontWeight.startsWith('bold') || parseInt(computeStyle(node).fontWeight) >= 700)) {
8292 formats.bold = true;
8293 }
8294 if (Object.keys(formats).length > 0) {
8295 delta = applyFormat(delta, formats);
8296 }
8297 if (parseFloat(style.textIndent || 0) > 0) {
8298 // Could be 0.5in
8299 delta = new _quillDelta2.default().insert('\t').concat(delta);
8300 }
8301 return delta;
8302}
8303
8304function matchText(node, delta) {
8305 var text = node.data;
8306 // Word represents empty line with <o:p>&nbsp;</o:p>
8307 if (node.parentNode.tagName === 'O:P') {
8308 return delta.insert(text.trim());
8309 }
8310 if (text.trim().length === 0 && node.parentNode.classList.contains('ql-clipboard')) {
8311 return delta;
8312 }
8313 if (!computeStyle(node.parentNode).whiteSpace.startsWith('pre')) {
8314 // eslint-disable-next-line func-style
8315 var replacer = function replacer(collapse, match) {
8316 match = match.replace(/[^\u00a0]/g, ''); // \u00a0 is nbsp;
8317 return match.length < 1 && collapse ? ' ' : match;
8318 };
8319 text = text.replace(/\r\n/g, ' ').replace(/\n/g, ' ');
8320 text = text.replace(/\s\s+/g, replacer.bind(replacer, true)); // collapse whitespace
8321 if (node.previousSibling == null && isLine(node.parentNode) || node.previousSibling != null && isLine(node.previousSibling)) {
8322 text = text.replace(/^\s+/, replacer.bind(replacer, false));
8323 }
8324 if (node.nextSibling == null && isLine(node.parentNode) || node.nextSibling != null && isLine(node.nextSibling)) {
8325 text = text.replace(/\s+$/, replacer.bind(replacer, false));
8326 }
8327 }
8328 return delta.insert(text);
8329}
8330
8331exports.default = Clipboard;
8332exports.matchAttributor = matchAttributor;
8333exports.matchBlot = matchBlot;
8334exports.matchNewline = matchNewline;
8335exports.matchSpacing = matchSpacing;
8336exports.matchText = matchText;
8337
8338/***/ }),
8339/* 56 */,
8340/* 57 */,
8341/* 58 */,
8342/* 59 */,
8343/* 60 */,
8344/* 61 */,
8345/* 62 */,
8346/* 63 */,
8347/* 64 */,
8348/* 65 */,
8349/* 66 */,
8350/* 67 */,
8351/* 68 */,
8352/* 69 */,
8353/* 70 */,
8354/* 71 */,
8355/* 72 */,
8356/* 73 */,
8357/* 74 */,
8358/* 75 */,
8359/* 76 */,
8360/* 77 */,
8361/* 78 */,
8362/* 79 */,
8363/* 80 */,
8364/* 81 */,
8365/* 82 */,
8366/* 83 */,
8367/* 84 */,
8368/* 85 */,
8369/* 86 */,
8370/* 87 */,
8371/* 88 */,
8372/* 89 */,
8373/* 90 */,
8374/* 91 */,
8375/* 92 */,
8376/* 93 */,
8377/* 94 */,
8378/* 95 */,
8379/* 96 */,
8380/* 97 */,
8381/* 98 */,
8382/* 99 */,
8383/* 100 */,
8384/* 101 */,
8385/* 102 */,
8386/* 103 */,
8387/* 104 */,
8388/* 105 */,
8389/* 106 */,
8390/* 107 */,
8391/* 108 */,
8392/* 109 */,
8393/* 110 */
8394/***/ (function(module, exports, __webpack_require__) {
8395
8396module.exports = __webpack_require__(29);
8397
8398
8399/***/ })
8400/******/ ]);
8401});
\No newline at end of file