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