Advertisement
Guest User

Untitled

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