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 = 109);
|
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 | (function(module, exports, __webpack_require__) {
|
4753 |
|
4754 | "use strict";
|
4755 |
|
4756 |
|
4757 | Object.defineProperty(exports, "__esModule", {
|
4758 | value: true
|
4759 | });
|
4760 | exports.sanitize = exports.default = undefined;
|
4761 |
|
4762 | 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; }; }();
|
4763 |
|
4764 | 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); } };
|
4765 |
|
4766 | var _inline = __webpack_require__(6);
|
4767 |
|
4768 | var _inline2 = _interopRequireDefault(_inline);
|
4769 |
|
4770 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
4771 |
|
4772 | function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
4773 |
|
4774 | 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; }
|
4775 |
|
4776 | 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; }
|
4777 |
|
4778 | var Link = function (_Inline) {
|
4779 | _inherits(Link, _Inline);
|
4780 |
|
4781 | function Link() {
|
4782 | _classCallCheck(this, Link);
|
4783 |
|
4784 | return _possibleConstructorReturn(this, (Link.__proto__ || Object.getPrototypeOf(Link)).apply(this, arguments));
|
4785 | }
|
4786 |
|
4787 | _createClass(Link, [{
|
4788 | key: 'format',
|
4789 | value: function format(name, value) {
|
4790 | if (name !== this.statics.blotName || !value) return _get(Link.prototype.__proto__ || Object.getPrototypeOf(Link.prototype), 'format', this).call(this, name, value);
|
4791 | value = this.constructor.sanitize(value);
|
4792 | this.domNode.setAttribute('href', value);
|
4793 | }
|
4794 | }], [{
|
4795 | key: 'create',
|
4796 | value: function create(value) {
|
4797 | var node = _get(Link.__proto__ || Object.getPrototypeOf(Link), 'create', this).call(this, value);
|
4798 | value = this.sanitize(value);
|
4799 | node.setAttribute('href', value);
|
4800 | node.setAttribute('target', '_blank');
|
4801 | return node;
|
4802 | }
|
4803 | }, {
|
4804 | key: 'formats',
|
4805 | value: function formats(domNode) {
|
4806 | return domNode.getAttribute('href');
|
4807 | }
|
4808 | }, {
|
4809 | key: 'sanitize',
|
4810 | value: function sanitize(url) {
|
4811 | return _sanitize(url, this.PROTOCOL_WHITELIST) ? url : this.SANITIZED_URL;
|
4812 | }
|
4813 | }]);
|
4814 |
|
4815 | return Link;
|
4816 | }(_inline2.default);
|
4817 |
|
4818 | Link.blotName = 'link';
|
4819 | Link.tagName = 'A';
|
4820 | Link.SANITIZED_URL = 'about:blank';
|
4821 | Link.PROTOCOL_WHITELIST = ['http', 'https', 'mailto', 'tel'];
|
4822 |
|
4823 | function _sanitize(url, protocols) {
|
4824 | var anchor = document.createElement('a');
|
4825 | anchor.href = url;
|
4826 | var protocol = anchor.href.slice(0, anchor.href.indexOf(':'));
|
4827 | return protocols.indexOf(protocol) > -1;
|
4828 | }
|
4829 |
|
4830 | exports.default = Link;
|
4831 | exports.sanitize = _sanitize;
|
4832 |
|
4833 | }),
|
4834 |
|
4835 | (function(module, exports, __webpack_require__) {
|
4836 |
|
4837 | "use strict";
|
4838 |
|
4839 |
|
4840 | Object.defineProperty(exports, "__esModule", {
|
4841 | value: true
|
4842 | });
|
4843 |
|
4844 | 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; };
|
4845 |
|
4846 | 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; }; }();
|
4847 |
|
4848 | var _dropdown = __webpack_require__(107);
|
4849 |
|
4850 | var _dropdown2 = _interopRequireDefault(_dropdown);
|
4851 |
|
4852 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
4853 |
|
4854 | function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
4855 |
|
4856 | var Picker = function () {
|
4857 | function Picker(select) {
|
4858 | var _this = this;
|
4859 |
|
4860 | _classCallCheck(this, Picker);
|
4861 |
|
4862 | this.select = select;
|
4863 | this.container = document.createElement('span');
|
4864 | this.buildPicker();
|
4865 | this.select.style.display = 'none';
|
4866 | this.select.parentNode.insertBefore(this.container, this.select);
|
4867 | this.label.addEventListener('mousedown', function () {
|
4868 | _this.container.classList.toggle('ql-expanded');
|
4869 | });
|
4870 | this.select.addEventListener('change', this.update.bind(this));
|
4871 | }
|
4872 |
|
4873 | _createClass(Picker, [{
|
4874 | key: 'buildItem',
|
4875 | value: function buildItem(option) {
|
4876 | var _this2 = this;
|
4877 |
|
4878 | var item = document.createElement('span');
|
4879 | item.classList.add('ql-picker-item');
|
4880 | if (option.hasAttribute('value')) {
|
4881 | item.setAttribute('data-value', option.getAttribute('value'));
|
4882 | }
|
4883 | if (option.textContent) {
|
4884 | item.setAttribute('data-label', option.textContent);
|
4885 | }
|
4886 | item.addEventListener('click', function () {
|
4887 | _this2.selectItem(item, true);
|
4888 | });
|
4889 | return item;
|
4890 | }
|
4891 | }, {
|
4892 | key: 'buildLabel',
|
4893 | value: function buildLabel() {
|
4894 | var label = document.createElement('span');
|
4895 | label.classList.add('ql-picker-label');
|
4896 | label.innerHTML = _dropdown2.default;
|
4897 | this.container.appendChild(label);
|
4898 | return label;
|
4899 | }
|
4900 | }, {
|
4901 | key: 'buildOptions',
|
4902 | value: function buildOptions() {
|
4903 | var _this3 = this;
|
4904 |
|
4905 | var options = document.createElement('span');
|
4906 | options.classList.add('ql-picker-options');
|
4907 | [].slice.call(this.select.options).forEach(function (option) {
|
4908 | var item = _this3.buildItem(option);
|
4909 | options.appendChild(item);
|
4910 | if (option.selected === true) {
|
4911 | _this3.selectItem(item);
|
4912 | }
|
4913 | });
|
4914 | this.container.appendChild(options);
|
4915 | }
|
4916 | }, {
|
4917 | key: 'buildPicker',
|
4918 | value: function buildPicker() {
|
4919 | var _this4 = this;
|
4920 |
|
4921 | [].slice.call(this.select.attributes).forEach(function (item) {
|
4922 | _this4.container.setAttribute(item.name, item.value);
|
4923 | });
|
4924 | this.container.classList.add('ql-picker');
|
4925 | this.label = this.buildLabel();
|
4926 | this.buildOptions();
|
4927 | }
|
4928 | }, {
|
4929 | key: 'close',
|
4930 | value: function close() {
|
4931 | this.container.classList.remove('ql-expanded');
|
4932 | }
|
4933 | }, {
|
4934 | key: 'selectItem',
|
4935 | value: function selectItem(item) {
|
4936 | var trigger = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
4937 |
|
4938 | var selected = this.container.querySelector('.ql-selected');
|
4939 | if (item === selected) return;
|
4940 | if (selected != null) {
|
4941 | selected.classList.remove('ql-selected');
|
4942 | }
|
4943 | if (item == null) return;
|
4944 | item.classList.add('ql-selected');
|
4945 | this.select.selectedIndex = [].indexOf.call(item.parentNode.children, item);
|
4946 | if (item.hasAttribute('data-value')) {
|
4947 | this.label.setAttribute('data-value', item.getAttribute('data-value'));
|
4948 | } else {
|
4949 | this.label.removeAttribute('data-value');
|
4950 | }
|
4951 | if (item.hasAttribute('data-label')) {
|
4952 | this.label.setAttribute('data-label', item.getAttribute('data-label'));
|
4953 | } else {
|
4954 | this.label.removeAttribute('data-label');
|
4955 | }
|
4956 | if (trigger) {
|
4957 | if (typeof Event === 'function') {
|
4958 | this.select.dispatchEvent(new Event('change'));
|
4959 | } else if ((typeof Event === 'undefined' ? 'undefined' : _typeof(Event)) === 'object') {
|
4960 |
|
4961 | var event = document.createEvent('Event');
|
4962 | event.initEvent('change', true, true);
|
4963 | this.select.dispatchEvent(event);
|
4964 | }
|
4965 | this.close();
|
4966 | }
|
4967 | }
|
4968 | }, {
|
4969 | key: 'update',
|
4970 | value: function update() {
|
4971 | var option = void 0;
|
4972 | if (this.select.selectedIndex > -1) {
|
4973 | var item = this.container.querySelector('.ql-picker-options').children[this.select.selectedIndex];
|
4974 | option = this.select.options[this.select.selectedIndex];
|
4975 | this.selectItem(item);
|
4976 | } else {
|
4977 | this.selectItem(null);
|
4978 | }
|
4979 | var isActive = option != null && option !== this.select.querySelector('option[selected]');
|
4980 | this.label.classList.toggle('ql-active', isActive);
|
4981 | }
|
4982 | }]);
|
4983 |
|
4984 | return Picker;
|
4985 | }();
|
4986 |
|
4987 | exports.default = Picker;
|
4988 |
|
4989 | }),
|
4990 |
|
4991 | (function(module, exports, __webpack_require__) {
|
4992 |
|
4993 | "use strict";
|
4994 |
|
4995 |
|
4996 | var _parchment = __webpack_require__(0);
|
4997 |
|
4998 | var _parchment2 = _interopRequireDefault(_parchment);
|
4999 |
|
5000 | var _quill = __webpack_require__(5);
|
5001 |
|
5002 | var _quill2 = _interopRequireDefault(_quill);
|
5003 |
|
5004 | var _block = __webpack_require__(4);
|
5005 |
|
5006 | var _block2 = _interopRequireDefault(_block);
|
5007 |
|
5008 | var _break = __webpack_require__(16);
|
5009 |
|
5010 | var _break2 = _interopRequireDefault(_break);
|
5011 |
|
5012 | var _container = __webpack_require__(24);
|
5013 |
|
5014 | var _container2 = _interopRequireDefault(_container);
|
5015 |
|
5016 | var _cursor = __webpack_require__(23);
|
5017 |
|
5018 | var _cursor2 = _interopRequireDefault(_cursor);
|
5019 |
|
5020 | var _embed = __webpack_require__(25);
|
5021 |
|
5022 | var _embed2 = _interopRequireDefault(_embed);
|
5023 |
|
5024 | var _inline = __webpack_require__(6);
|
5025 |
|
5026 | var _inline2 = _interopRequireDefault(_inline);
|
5027 |
|
5028 | var _scroll = __webpack_require__(22);
|
5029 |
|
5030 | var _scroll2 = _interopRequireDefault(_scroll);
|
5031 |
|
5032 | var _text = __webpack_require__(7);
|
5033 |
|
5034 | var _text2 = _interopRequireDefault(_text);
|
5035 |
|
5036 | var _clipboard = __webpack_require__(55);
|
5037 |
|
5038 | var _clipboard2 = _interopRequireDefault(_clipboard);
|
5039 |
|
5040 | var _history = __webpack_require__(42);
|
5041 |
|
5042 | var _history2 = _interopRequireDefault(_history);
|
5043 |
|
5044 | var _keyboard = __webpack_require__(35);
|
5045 |
|
5046 | var _keyboard2 = _interopRequireDefault(_keyboard);
|
5047 |
|
5048 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
5049 |
|
5050 | _quill2.default.register({
|
5051 | 'blots/block': _block2.default,
|
5052 | 'blots/block/embed': _block.BlockEmbed,
|
5053 | 'blots/break': _break2.default,
|
5054 | 'blots/container': _container2.default,
|
5055 | 'blots/cursor': _cursor2.default,
|
5056 | 'blots/embed': _embed2.default,
|
5057 | 'blots/inline': _inline2.default,
|
5058 | 'blots/scroll': _scroll2.default,
|
5059 | 'blots/text': _text2.default,
|
5060 |
|
5061 | 'modules/clipboard': _clipboard2.default,
|
5062 | 'modules/history': _history2.default,
|
5063 | 'modules/keyboard': _keyboard2.default
|
5064 | });
|
5065 |
|
5066 | _parchment2.default.register(_block2.default, _break2.default, _cursor2.default, _inline2.default, _scroll2.default, _text2.default);
|
5067 |
|
5068 | module.exports = _quill2.default;
|
5069 |
|
5070 | }),
|
5071 |
|
5072 | (function(module, exports, __webpack_require__) {
|
5073 |
|
5074 | "use strict";
|
5075 |
|
5076 | Object.defineProperty(exports, "__esModule", { value: true });
|
5077 | var Registry = __webpack_require__(1);
|
5078 | var ShadowBlot = (function () {
|
5079 | function ShadowBlot(domNode) {
|
5080 | this.domNode = domNode;
|
5081 | this.attach();
|
5082 | }
|
5083 | Object.defineProperty(ShadowBlot.prototype, "statics", {
|
5084 |
|
5085 | get: function () {
|
5086 | return this.constructor;
|
5087 | },
|
5088 | enumerable: true,
|
5089 | configurable: true
|
5090 | });
|
5091 | ShadowBlot.create = function (value) {
|
5092 | if (this.tagName == null) {
|
5093 | throw new Registry.ParchmentError('Blot definition missing tagName');
|
5094 | }
|
5095 | var node;
|
5096 | if (Array.isArray(this.tagName)) {
|
5097 | if (typeof value === 'string') {
|
5098 | value = value.toUpperCase();
|
5099 | if (parseInt(value).toString() === value) {
|
5100 | value = parseInt(value);
|
5101 | }
|
5102 | }
|
5103 | if (typeof value === 'number') {
|
5104 | node = document.createElement(this.tagName[value - 1]);
|
5105 | }
|
5106 | else if (this.tagName.indexOf(value) > -1) {
|
5107 | node = document.createElement(value);
|
5108 | }
|
5109 | else {
|
5110 | node = document.createElement(this.tagName[0]);
|
5111 | }
|
5112 | }
|
5113 | else {
|
5114 | node = document.createElement(this.tagName);
|
5115 | }
|
5116 | if (this.className) {
|
5117 | node.classList.add(this.className);
|
5118 | }
|
5119 | return node;
|
5120 | };
|
5121 | ShadowBlot.prototype.attach = function () {
|
5122 | this.domNode[Registry.DATA_KEY] = { blot: this };
|
5123 | };
|
5124 | ShadowBlot.prototype.clone = function () {
|
5125 | var domNode = this.domNode.cloneNode(false);
|
5126 | return Registry.create(domNode);
|
5127 | };
|
5128 | ShadowBlot.prototype.detach = function () {
|
5129 | if (this.parent != null)
|
5130 | this.parent.removeChild(this);
|
5131 | delete this.domNode[Registry.DATA_KEY];
|
5132 | };
|
5133 | ShadowBlot.prototype.deleteAt = function (index, length) {
|
5134 | var blot = this.isolate(index, length);
|
5135 | blot.remove();
|
5136 | };
|
5137 | ShadowBlot.prototype.formatAt = function (index, length, name, value) {
|
5138 | var blot = this.isolate(index, length);
|
5139 | if (Registry.query(name, Registry.Scope.BLOT) != null && value) {
|
5140 | blot.wrap(name, value);
|
5141 | }
|
5142 | else if (Registry.query(name, Registry.Scope.ATTRIBUTE) != null) {
|
5143 | var parent = Registry.create(this.statics.scope);
|
5144 | blot.wrap(parent);
|
5145 | parent.format(name, value);
|
5146 | }
|
5147 | };
|
5148 | ShadowBlot.prototype.insertAt = function (index, value, def) {
|
5149 | var blot = (def == null) ? Registry.create('text', value) : Registry.create(value, def);
|
5150 | var ref = this.split(index);
|
5151 | this.parent.insertBefore(blot, ref);
|
5152 | };
|
5153 | ShadowBlot.prototype.insertInto = function (parentBlot, refBlot) {
|
5154 | if (this.parent != null) {
|
5155 | this.parent.children.remove(this);
|
5156 | }
|
5157 | parentBlot.children.insertBefore(this, refBlot);
|
5158 | if (refBlot != null) {
|
5159 | var refDomNode = refBlot.domNode;
|
5160 | }
|
5161 | if (this.next == null || this.domNode.nextSibling != refDomNode) {
|
5162 | parentBlot.domNode.insertBefore(this.domNode, (typeof refDomNode !== 'undefined') ? refDomNode : null);
|
5163 | }
|
5164 | this.parent = parentBlot;
|
5165 | };
|
5166 | ShadowBlot.prototype.isolate = function (index, length) {
|
5167 | var target = this.split(index);
|
5168 | target.split(length);
|
5169 | return target;
|
5170 | };
|
5171 | ShadowBlot.prototype.length = function () {
|
5172 | return 1;
|
5173 | };
|
5174 | ;
|
5175 | ShadowBlot.prototype.offset = function (root) {
|
5176 | if (root === void 0) { root = this.parent; }
|
5177 | if (this.parent == null || this == root)
|
5178 | return 0;
|
5179 | return this.parent.children.offset(this) + this.parent.offset(root);
|
5180 | };
|
5181 | ShadowBlot.prototype.optimize = function (context) {
|
5182 |
|
5183 | if (this.domNode[Registry.DATA_KEY] != null) {
|
5184 | delete this.domNode[Registry.DATA_KEY].mutations;
|
5185 | }
|
5186 | };
|
5187 | ShadowBlot.prototype.remove = function () {
|
5188 | if (this.domNode.parentNode != null) {
|
5189 | this.domNode.parentNode.removeChild(this.domNode);
|
5190 | }
|
5191 | this.detach();
|
5192 | };
|
5193 | ShadowBlot.prototype.replace = function (target) {
|
5194 | if (target.parent == null)
|
5195 | return;
|
5196 | target.parent.insertBefore(this, target.next);
|
5197 | target.remove();
|
5198 | };
|
5199 | ShadowBlot.prototype.replaceWith = function (name, value) {
|
5200 | var replacement = typeof name === 'string' ? Registry.create(name, value) : name;
|
5201 | replacement.replace(this);
|
5202 | return replacement;
|
5203 | };
|
5204 | ShadowBlot.prototype.split = function (index, force) {
|
5205 | return index === 0 ? this : this.next;
|
5206 | };
|
5207 | ShadowBlot.prototype.update = function (mutations, context) {
|
5208 |
|
5209 | };
|
5210 | ShadowBlot.prototype.wrap = function (name, value) {
|
5211 | var wrapper = typeof name === 'string' ? Registry.create(name, value) : name;
|
5212 | if (this.parent != null) {
|
5213 | this.parent.insertBefore(wrapper, this.next);
|
5214 | }
|
5215 | wrapper.appendChild(this);
|
5216 | return wrapper;
|
5217 | };
|
5218 | ShadowBlot.blotName = 'abstract';
|
5219 | return ShadowBlot;
|
5220 | }());
|
5221 | exports.default = ShadowBlot;
|
5222 |
|
5223 |
|
5224 | }),
|
5225 |
|
5226 | (function(module, exports, __webpack_require__) {
|
5227 |
|
5228 | "use strict";
|
5229 |
|
5230 | Object.defineProperty(exports, "__esModule", { value: true });
|
5231 | var attributor_1 = __webpack_require__(12);
|
5232 | var class_1 = __webpack_require__(32);
|
5233 | var style_1 = __webpack_require__(33);
|
5234 | var Registry = __webpack_require__(1);
|
5235 | var AttributorStore = (function () {
|
5236 | function AttributorStore(domNode) {
|
5237 | this.attributes = {};
|
5238 | this.domNode = domNode;
|
5239 | this.build();
|
5240 | }
|
5241 | AttributorStore.prototype.attribute = function (attribute, value) {
|
5242 | if (value) {
|
5243 | if (attribute.add(this.domNode, value)) {
|
5244 | if (attribute.value(this.domNode) != null) {
|
5245 | this.attributes[attribute.attrName] = attribute;
|
5246 | }
|
5247 | else {
|
5248 | delete this.attributes[attribute.attrName];
|
5249 | }
|
5250 | }
|
5251 | }
|
5252 | else {
|
5253 | attribute.remove(this.domNode);
|
5254 | delete this.attributes[attribute.attrName];
|
5255 | }
|
5256 | };
|
5257 | AttributorStore.prototype.build = function () {
|
5258 | var _this = this;
|
5259 | this.attributes = {};
|
5260 | var attributes = attributor_1.default.keys(this.domNode);
|
5261 | var classes = class_1.default.keys(this.domNode);
|
5262 | var styles = style_1.default.keys(this.domNode);
|
5263 | attributes.concat(classes).concat(styles).forEach(function (name) {
|
5264 | var attr = Registry.query(name, Registry.Scope.ATTRIBUTE);
|
5265 | if (attr instanceof attributor_1.default) {
|
5266 | _this.attributes[attr.attrName] = attr;
|
5267 | }
|
5268 | });
|
5269 | };
|
5270 | AttributorStore.prototype.copy = function (target) {
|
5271 | var _this = this;
|
5272 | Object.keys(this.attributes).forEach(function (key) {
|
5273 | var value = _this.attributes[key].value(_this.domNode);
|
5274 | target.format(key, value);
|
5275 | });
|
5276 | };
|
5277 | AttributorStore.prototype.move = function (target) {
|
5278 | var _this = this;
|
5279 | this.copy(target);
|
5280 | Object.keys(this.attributes).forEach(function (key) {
|
5281 | _this.attributes[key].remove(_this.domNode);
|
5282 | });
|
5283 | this.attributes = {};
|
5284 | };
|
5285 | AttributorStore.prototype.values = function () {
|
5286 | var _this = this;
|
5287 | return Object.keys(this.attributes).reduce(function (attributes, name) {
|
5288 | attributes[name] = _this.attributes[name].value(_this.domNode);
|
5289 | return attributes;
|
5290 | }, {});
|
5291 | };
|
5292 | return AttributorStore;
|
5293 | }());
|
5294 | exports.default = AttributorStore;
|
5295 |
|
5296 |
|
5297 | }),
|
5298 |
|
5299 | (function(module, exports, __webpack_require__) {
|
5300 |
|
5301 | "use strict";
|
5302 |
|
5303 | var __extends = (this && this.__extends) || (function () {
|
5304 | var extendStatics = Object.setPrototypeOf ||
|
5305 | ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
5306 | function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
|
5307 | return function (d, b) {
|
5308 | extendStatics(d, b);
|
5309 | function __() { this.constructor = d; }
|
5310 | d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
5311 | };
|
5312 | })();
|
5313 | Object.defineProperty(exports, "__esModule", { value: true });
|
5314 | var attributor_1 = __webpack_require__(12);
|
5315 | function match(node, prefix) {
|
5316 | var className = node.getAttribute('class') || '';
|
5317 | return className.split(/\s+/).filter(function (name) {
|
5318 | return name.indexOf(prefix + "-") === 0;
|
5319 | });
|
5320 | }
|
5321 | var ClassAttributor = (function (_super) {
|
5322 | __extends(ClassAttributor, _super);
|
5323 | function ClassAttributor() {
|
5324 | return _super !== null && _super.apply(this, arguments) || this;
|
5325 | }
|
5326 | ClassAttributor.keys = function (node) {
|
5327 | return (node.getAttribute('class') || '').split(/\s+/).map(function (name) {
|
5328 | return name.split('-').slice(0, -1).join('-');
|
5329 | });
|
5330 | };
|
5331 | ClassAttributor.prototype.add = function (node, value) {
|
5332 | if (!this.canAdd(node, value))
|
5333 | return false;
|
5334 | this.remove(node);
|
5335 | node.classList.add(this.keyName + "-" + value);
|
5336 | return true;
|
5337 | };
|
5338 | ClassAttributor.prototype.remove = function (node) {
|
5339 | var matches = match(node, this.keyName);
|
5340 | matches.forEach(function (name) {
|
5341 | node.classList.remove(name);
|
5342 | });
|
5343 | if (node.classList.length === 0) {
|
5344 | node.removeAttribute('class');
|
5345 | }
|
5346 | };
|
5347 | ClassAttributor.prototype.value = function (node) {
|
5348 | var result = match(node, this.keyName)[0] || '';
|
5349 | var value = result.slice(this.keyName.length + 1);
|
5350 | return this.canAdd(node, value) ? value : '';
|
5351 | };
|
5352 | return ClassAttributor;
|
5353 | }(attributor_1.default));
|
5354 | exports.default = ClassAttributor;
|
5355 |
|
5356 |
|
5357 | }),
|
5358 |
|
5359 | (function(module, exports, __webpack_require__) {
|
5360 |
|
5361 | "use strict";
|
5362 |
|
5363 | var __extends = (this && this.__extends) || (function () {
|
5364 | var extendStatics = Object.setPrototypeOf ||
|
5365 | ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
5366 | function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
|
5367 | return function (d, b) {
|
5368 | extendStatics(d, b);
|
5369 | function __() { this.constructor = d; }
|
5370 | d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
5371 | };
|
5372 | })();
|
5373 | Object.defineProperty(exports, "__esModule", { value: true });
|
5374 | var attributor_1 = __webpack_require__(12);
|
5375 | function camelize(name) {
|
5376 | var parts = name.split('-');
|
5377 | var rest = parts.slice(1).map(function (part) {
|
5378 | return part[0].toUpperCase() + part.slice(1);
|
5379 | }).join('');
|
5380 | return parts[0] + rest;
|
5381 | }
|
5382 | var StyleAttributor = (function (_super) {
|
5383 | __extends(StyleAttributor, _super);
|
5384 | function StyleAttributor() {
|
5385 | return _super !== null && _super.apply(this, arguments) || this;
|
5386 | }
|
5387 | StyleAttributor.keys = function (node) {
|
5388 | return (node.getAttribute('style') || '').split(';').map(function (value) {
|
5389 | var arr = value.split(':');
|
5390 | return arr[0].trim();
|
5391 | });
|
5392 | };
|
5393 | StyleAttributor.prototype.add = function (node, value) {
|
5394 | if (!this.canAdd(node, value))
|
5395 | return false;
|
5396 | node.style[camelize(this.keyName)] = value;
|
5397 | return true;
|
5398 | };
|
5399 | StyleAttributor.prototype.remove = function (node) {
|
5400 | node.style[camelize(this.keyName)] = '';
|
5401 | if (!node.getAttribute('style')) {
|
5402 | node.removeAttribute('style');
|
5403 | }
|
5404 | };
|
5405 | StyleAttributor.prototype.value = function (node) {
|
5406 | var value = node.style[camelize(this.keyName)];
|
5407 | return this.canAdd(node, value) ? value : '';
|
5408 | };
|
5409 | return StyleAttributor;
|
5410 | }(attributor_1.default));
|
5411 | exports.default = StyleAttributor;
|
5412 |
|
5413 |
|
5414 | }),
|
5415 |
|
5416 | (function(module, exports, __webpack_require__) {
|
5417 |
|
5418 | "use strict";
|
5419 |
|
5420 |
|
5421 | Object.defineProperty(exports, "__esModule", {
|
5422 | value: true
|
5423 | });
|
5424 |
|
5425 | 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; }; }();
|
5426 |
|
5427 | function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
5428 |
|
5429 | var Theme = function () {
|
5430 | function Theme(quill, options) {
|
5431 | _classCallCheck(this, Theme);
|
5432 |
|
5433 | this.quill = quill;
|
5434 | this.options = options;
|
5435 | this.modules = {};
|
5436 | }
|
5437 |
|
5438 | _createClass(Theme, [{
|
5439 | key: 'init',
|
5440 | value: function init() {
|
5441 | var _this = this;
|
5442 |
|
5443 | Object.keys(this.options.modules).forEach(function (name) {
|
5444 | if (_this.modules[name] == null) {
|
5445 | _this.addModule(name);
|
5446 | }
|
5447 | });
|
5448 | }
|
5449 | }, {
|
5450 | key: 'addModule',
|
5451 | value: function addModule(name) {
|
5452 | var moduleClass = this.quill.constructor.import('modules/' + name);
|
5453 | this.modules[name] = new moduleClass(this.quill, this.options.modules[name] || {});
|
5454 | return this.modules[name];
|
5455 | }
|
5456 | }]);
|
5457 |
|
5458 | return Theme;
|
5459 | }();
|
5460 |
|
5461 | Theme.DEFAULTS = {
|
5462 | modules: {}
|
5463 | };
|
5464 | Theme.themes = {
|
5465 | 'default': Theme
|
5466 | };
|
5467 |
|
5468 | exports.default = Theme;
|
5469 |
|
5470 | }),
|
5471 |
|
5472 | (function(module, exports, __webpack_require__) {
|
5473 |
|
5474 | "use strict";
|
5475 |
|
5476 |
|
5477 | Object.defineProperty(exports, "__esModule", {
|
5478 | value: true
|
5479 | });
|
5480 | exports.SHORTKEY = exports.default = undefined;
|
5481 |
|
5482 | 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; };
|
5483 |
|
5484 | 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"); } }; }();
|
5485 |
|
5486 | 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; }; }();
|
5487 |
|
5488 | var _clone = __webpack_require__(21);
|
5489 |
|
5490 | var _clone2 = _interopRequireDefault(_clone);
|
5491 |
|
5492 | var _deepEqual = __webpack_require__(11);
|
5493 |
|
5494 | var _deepEqual2 = _interopRequireDefault(_deepEqual);
|
5495 |
|
5496 | var _extend = __webpack_require__(3);
|
5497 |
|
5498 | var _extend2 = _interopRequireDefault(_extend);
|
5499 |
|
5500 | var _quillDelta = __webpack_require__(2);
|
5501 |
|
5502 | var _quillDelta2 = _interopRequireDefault(_quillDelta);
|
5503 |
|
5504 | var _op = __webpack_require__(20);
|
5505 |
|
5506 | var _op2 = _interopRequireDefault(_op);
|
5507 |
|
5508 | var _parchment = __webpack_require__(0);
|
5509 |
|
5510 | var _parchment2 = _interopRequireDefault(_parchment);
|
5511 |
|
5512 | var _embed = __webpack_require__(25);
|
5513 |
|
5514 | var _embed2 = _interopRequireDefault(_embed);
|
5515 |
|
5516 | var _quill = __webpack_require__(5);
|
5517 |
|
5518 | var _quill2 = _interopRequireDefault(_quill);
|
5519 |
|
5520 | var _logger = __webpack_require__(10);
|
5521 |
|
5522 | var _logger2 = _interopRequireDefault(_logger);
|
5523 |
|
5524 | var _module = __webpack_require__(9);
|
5525 |
|
5526 | var _module2 = _interopRequireDefault(_module);
|
5527 |
|
5528 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
5529 |
|
5530 | 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; }
|
5531 |
|
5532 | function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
5533 |
|
5534 | 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; }
|
5535 |
|
5536 | 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; }
|
5537 |
|
5538 | var debug = (0, _logger2.default)('quill:keyboard');
|
5539 |
|
5540 | var SHORTKEY = /Mac/i.test(navigator.platform) ? 'metaKey' : 'ctrlKey';
|
5541 |
|
5542 | var Keyboard = function (_Module) {
|
5543 | _inherits(Keyboard, _Module);
|
5544 |
|
5545 | _createClass(Keyboard, null, [{
|
5546 | key: 'match',
|
5547 | value: function match(evt, binding) {
|
5548 | binding = normalize(binding);
|
5549 | if (['altKey', 'ctrlKey', 'metaKey', 'shiftKey'].some(function (key) {
|
5550 | return !!binding[key] !== evt[key] && binding[key] !== null;
|
5551 | })) {
|
5552 | return false;
|
5553 | }
|
5554 | return binding.key === (evt.which || evt.keyCode);
|
5555 | }
|
5556 | }]);
|
5557 |
|
5558 | function Keyboard(quill, options) {
|
5559 | _classCallCheck(this, Keyboard);
|
5560 |
|
5561 | var _this = _possibleConstructorReturn(this, (Keyboard.__proto__ || Object.getPrototypeOf(Keyboard)).call(this, quill, options));
|
5562 |
|
5563 | _this.bindings = {};
|
5564 | Object.keys(_this.options.bindings).forEach(function (name) {
|
5565 | if (name === 'list autofill' && quill.scroll.whitelist != null && !quill.scroll.whitelist['list']) {
|
5566 | return;
|
5567 | }
|
5568 | if (_this.options.bindings[name]) {
|
5569 | _this.addBinding(_this.options.bindings[name]);
|
5570 | }
|
5571 | });
|
5572 | _this.addBinding({ key: Keyboard.keys.ENTER, shiftKey: null }, handleEnter);
|
5573 | _this.addBinding({ key: Keyboard.keys.ENTER, metaKey: null, ctrlKey: null, altKey: null }, function () {});
|
5574 | if (/Firefox/i.test(navigator.userAgent)) {
|
5575 |
|
5576 | _this.addBinding({ key: Keyboard.keys.BACKSPACE }, { collapsed: true }, handleBackspace);
|
5577 | _this.addBinding({ key: Keyboard.keys.DELETE }, { collapsed: true }, handleDelete);
|
5578 | } else {
|
5579 | _this.addBinding({ key: Keyboard.keys.BACKSPACE }, { collapsed: true, prefix: /^.?$/ }, handleBackspace);
|
5580 | _this.addBinding({ key: Keyboard.keys.DELETE }, { collapsed: true, suffix: /^.?$/ }, handleDelete);
|
5581 | }
|
5582 | _this.addBinding({ key: Keyboard.keys.BACKSPACE }, { collapsed: false }, handleDeleteRange);
|
5583 | _this.addBinding({ key: Keyboard.keys.DELETE }, { collapsed: false }, handleDeleteRange);
|
5584 | _this.addBinding({ key: Keyboard.keys.BACKSPACE, altKey: null, ctrlKey: null, metaKey: null, shiftKey: null }, { collapsed: true, offset: 0 }, handleBackspace);
|
5585 | _this.listen();
|
5586 | return _this;
|
5587 | }
|
5588 |
|
5589 | _createClass(Keyboard, [{
|
5590 | key: 'addBinding',
|
5591 | value: function addBinding(key) {
|
5592 | var context = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
5593 | var handler = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
5594 |
|
5595 | var binding = normalize(key);
|
5596 | if (binding == null || binding.key == null) {
|
5597 | return debug.warn('Attempted to add invalid keyboard binding', binding);
|
5598 | }
|
5599 | if (typeof context === 'function') {
|
5600 | context = { handler: context };
|
5601 | }
|
5602 | if (typeof handler === 'function') {
|
5603 | handler = { handler: handler };
|
5604 | }
|
5605 | binding = (0, _extend2.default)(binding, context, handler);
|
5606 | this.bindings[binding.key] = this.bindings[binding.key] || [];
|
5607 | this.bindings[binding.key].push(binding);
|
5608 | }
|
5609 | }, {
|
5610 | key: 'listen',
|
5611 | value: function listen() {
|
5612 | var _this2 = this;
|
5613 |
|
5614 | this.quill.root.addEventListener('keydown', function (evt) {
|
5615 | if (evt.defaultPrevented) return;
|
5616 | var which = evt.which || evt.keyCode;
|
5617 | var bindings = (_this2.bindings[which] || []).filter(function (binding) {
|
5618 | return Keyboard.match(evt, binding);
|
5619 | });
|
5620 | if (bindings.length === 0) return;
|
5621 | var range = _this2.quill.getSelection();
|
5622 | if (range == null || !_this2.quill.hasFocus()) return;
|
5623 |
|
5624 | var _quill$getLine = _this2.quill.getLine(range.index),
|
5625 | _quill$getLine2 = _slicedToArray(_quill$getLine, 2),
|
5626 | line = _quill$getLine2[0],
|
5627 | offset = _quill$getLine2[1];
|
5628 |
|
5629 | var _quill$getLeaf = _this2.quill.getLeaf(range.index),
|
5630 | _quill$getLeaf2 = _slicedToArray(_quill$getLeaf, 2),
|
5631 | leafStart = _quill$getLeaf2[0],
|
5632 | offsetStart = _quill$getLeaf2[1];
|
5633 |
|
5634 | var _ref = range.length === 0 ? [leafStart, offsetStart] : _this2.quill.getLeaf(range.index + range.length),
|
5635 | _ref2 = _slicedToArray(_ref, 2),
|
5636 | leafEnd = _ref2[0],
|
5637 | offsetEnd = _ref2[1];
|
5638 |
|
5639 | var prefixText = leafStart instanceof _parchment2.default.Text ? leafStart.value().slice(0, offsetStart) : '';
|
5640 | var suffixText = leafEnd instanceof _parchment2.default.Text ? leafEnd.value().slice(offsetEnd) : '';
|
5641 | var curContext = {
|
5642 | collapsed: range.length === 0,
|
5643 | empty: range.length === 0 && line.length() <= 1,
|
5644 | format: _this2.quill.getFormat(range),
|
5645 | offset: offset,
|
5646 | prefix: prefixText,
|
5647 | suffix: suffixText
|
5648 | };
|
5649 | var prevented = bindings.some(function (binding) {
|
5650 | if (binding.collapsed != null && binding.collapsed !== curContext.collapsed) return false;
|
5651 | if (binding.empty != null && binding.empty !== curContext.empty) return false;
|
5652 | if (binding.offset != null && binding.offset !== curContext.offset) return false;
|
5653 | if (Array.isArray(binding.format)) {
|
5654 |
|
5655 | if (binding.format.every(function (name) {
|
5656 | return curContext.format[name] == null;
|
5657 | })) {
|
5658 | return false;
|
5659 | }
|
5660 | } else if (_typeof(binding.format) === 'object') {
|
5661 |
|
5662 | if (!Object.keys(binding.format).every(function (name) {
|
5663 | if (binding.format[name] === true) return curContext.format[name] != null;
|
5664 | if (binding.format[name] === false) return curContext.format[name] == null;
|
5665 | return (0, _deepEqual2.default)(binding.format[name], curContext.format[name]);
|
5666 | })) {
|
5667 | return false;
|
5668 | }
|
5669 | }
|
5670 | if (binding.prefix != null && !binding.prefix.test(curContext.prefix)) return false;
|
5671 | if (binding.suffix != null && !binding.suffix.test(curContext.suffix)) return false;
|
5672 | return binding.handler.call(_this2, range, curContext) !== true;
|
5673 | });
|
5674 | if (prevented) {
|
5675 | evt.preventDefault();
|
5676 | }
|
5677 | });
|
5678 | }
|
5679 | }]);
|
5680 |
|
5681 | return Keyboard;
|
5682 | }(_module2.default);
|
5683 |
|
5684 | Keyboard.keys = {
|
5685 | BACKSPACE: 8,
|
5686 | TAB: 9,
|
5687 | ENTER: 13,
|
5688 | ESCAPE: 27,
|
5689 | LEFT: 37,
|
5690 | UP: 38,
|
5691 | RIGHT: 39,
|
5692 | DOWN: 40,
|
5693 | DELETE: 46
|
5694 | };
|
5695 |
|
5696 | Keyboard.DEFAULTS = {
|
5697 | bindings: {
|
5698 | 'bold': makeFormatHandler('bold'),
|
5699 | 'italic': makeFormatHandler('italic'),
|
5700 | 'underline': makeFormatHandler('underline'),
|
5701 | 'indent': {
|
5702 |
|
5703 | key: Keyboard.keys.TAB,
|
5704 | format: ['blockquote', 'indent', 'list'],
|
5705 | handler: function handler(range, context) {
|
5706 | if (context.collapsed && context.offset !== 0) return true;
|
5707 | this.quill.format('indent', '+1', _quill2.default.sources.USER);
|
5708 | }
|
5709 | },
|
5710 | 'outdent': {
|
5711 | key: Keyboard.keys.TAB,
|
5712 | shiftKey: true,
|
5713 | format: ['blockquote', 'indent', 'list'],
|
5714 |
|
5715 | handler: function handler(range, context) {
|
5716 | if (context.collapsed && context.offset !== 0) return true;
|
5717 | this.quill.format('indent', '-1', _quill2.default.sources.USER);
|
5718 | }
|
5719 | },
|
5720 | 'outdent backspace': {
|
5721 | key: Keyboard.keys.BACKSPACE,
|
5722 | collapsed: true,
|
5723 | shiftKey: null,
|
5724 | metaKey: null,
|
5725 | ctrlKey: null,
|
5726 | altKey: null,
|
5727 | format: ['indent', 'list'],
|
5728 | offset: 0,
|
5729 | handler: function handler(range, context) {
|
5730 | if (context.format.indent != null) {
|
5731 | this.quill.format('indent', '-1', _quill2.default.sources.USER);
|
5732 | } else if (context.format.list != null) {
|
5733 | this.quill.format('list', false, _quill2.default.sources.USER);
|
5734 | }
|
5735 | }
|
5736 | },
|
5737 | 'indent code-block': makeCodeBlockHandler(true),
|
5738 | 'outdent code-block': makeCodeBlockHandler(false),
|
5739 | 'remove tab': {
|
5740 | key: Keyboard.keys.TAB,
|
5741 | shiftKey: true,
|
5742 | collapsed: true,
|
5743 | prefix: /\t$/,
|
5744 | handler: function handler(range) {
|
5745 | this.quill.deleteText(range.index - 1, 1, _quill2.default.sources.USER);
|
5746 | }
|
5747 | },
|
5748 | 'tab': {
|
5749 | key: Keyboard.keys.TAB,
|
5750 | handler: function handler(range) {
|
5751 | this.quill.history.cutoff();
|
5752 | var delta = new _quillDelta2.default().retain(range.index).delete(range.length).insert('\t');
|
5753 | this.quill.updateContents(delta, _quill2.default.sources.USER);
|
5754 | this.quill.history.cutoff();
|
5755 | this.quill.setSelection(range.index + 1, _quill2.default.sources.SILENT);
|
5756 | }
|
5757 | },
|
5758 | 'list empty enter': {
|
5759 | key: Keyboard.keys.ENTER,
|
5760 | collapsed: true,
|
5761 | format: ['list'],
|
5762 | empty: true,
|
5763 | handler: function handler(range, context) {
|
5764 | this.quill.format('list', false, _quill2.default.sources.USER);
|
5765 | if (context.format.indent) {
|
5766 | this.quill.format('indent', false, _quill2.default.sources.USER);
|
5767 | }
|
5768 | }
|
5769 | },
|
5770 | 'checklist enter': {
|
5771 | key: Keyboard.keys.ENTER,
|
5772 | collapsed: true,
|
5773 | format: { list: 'checked' },
|
5774 | handler: function handler(range) {
|
5775 | var _quill$getLine3 = this.quill.getLine(range.index),
|
5776 | _quill$getLine4 = _slicedToArray(_quill$getLine3, 2),
|
5777 | line = _quill$getLine4[0],
|
5778 | offset = _quill$getLine4[1];
|
5779 |
|
5780 | var delta = new _quillDelta2.default().retain(range.index).insert('\n', { list: 'checked' }).retain(line.length() - offset - 1).retain(1, { list: 'unchecked' });
|
5781 | this.quill.updateContents(delta, _quill2.default.sources.USER);
|
5782 | this.quill.setSelection(range.index + 1, _quill2.default.sources.SILENT);
|
5783 | this.quill.scrollIntoView();
|
5784 | }
|
5785 | },
|
5786 | 'header enter': {
|
5787 | key: Keyboard.keys.ENTER,
|
5788 | collapsed: true,
|
5789 | format: ['header'],
|
5790 | suffix: /^$/,
|
5791 | handler: function handler(range, context) {
|
5792 | var _quill$getLine5 = this.quill.getLine(range.index),
|
5793 | _quill$getLine6 = _slicedToArray(_quill$getLine5, 2),
|
5794 | line = _quill$getLine6[0],
|
5795 | offset = _quill$getLine6[1];
|
5796 |
|
5797 | var delta = new _quillDelta2.default().retain(range.index).insert('\n', context.format).retain(line.length() - offset - 1).retain(1, { header: null });
|
5798 | this.quill.updateContents(delta, _quill2.default.sources.USER);
|
5799 | this.quill.setSelection(range.index + 1, _quill2.default.sources.SILENT);
|
5800 | this.quill.scrollIntoView();
|
5801 | }
|
5802 | },
|
5803 | 'list autofill': {
|
5804 | key: ' ',
|
5805 | collapsed: true,
|
5806 | format: { list: false },
|
5807 | prefix: /^\s*?(1\.|-|\[ ?\]|\[x\])$/,
|
5808 | handler: function handler(range, context) {
|
5809 | var length = context.prefix.length;
|
5810 | var value = void 0;
|
5811 | switch (context.prefix.trim()) {
|
5812 | case '[]':case '[ ]':
|
5813 | value = 'unchecked';
|
5814 | break;
|
5815 | case '[x]':
|
5816 | value = 'checked';
|
5817 | break;
|
5818 | case '-':
|
5819 | value = 'bullet';
|
5820 | break;
|
5821 | default:
|
5822 | value = 'ordered';
|
5823 | }
|
5824 | this.quill.insertText(range.index, ' ', _quill2.default.sources.USER);
|
5825 | this.quill.history.cutoff();
|
5826 |
|
5827 | var _quill$getLine7 = this.quill.getLine(range.index + 1),
|
5828 | _quill$getLine8 = _slicedToArray(_quill$getLine7, 2),
|
5829 | line = _quill$getLine8[0],
|
5830 | offset = _quill$getLine8[1];
|
5831 |
|
5832 | var delta = new _quillDelta2.default().retain(range.index + 1 - offset).delete(length + 1).retain(line.length() - 1 - offset).retain(1, { list: value });
|
5833 | this.quill.updateContents(delta, _quill2.default.sources.USER);
|
5834 | this.quill.history.cutoff();
|
5835 | this.quill.setSelection(range.index - length, _quill2.default.sources.SILENT);
|
5836 | }
|
5837 | },
|
5838 | 'code exit': {
|
5839 | key: Keyboard.keys.ENTER,
|
5840 | collapsed: true,
|
5841 | format: ['code-block'],
|
5842 | prefix: /\n\n$/,
|
5843 | suffix: /^\s+$/,
|
5844 | handler: function handler(range) {
|
5845 | var _quill$getLine9 = this.quill.getLine(range.index),
|
5846 | _quill$getLine10 = _slicedToArray(_quill$getLine9, 2),
|
5847 | line = _quill$getLine10[0],
|
5848 | offset = _quill$getLine10[1];
|
5849 |
|
5850 | var delta = new _quillDelta2.default().retain(range.index + line.length() - offset - 2).retain(1, { 'code-block': null }).delete(1);
|
5851 | this.quill.updateContents(delta, _quill2.default.sources.USER);
|
5852 | }
|
5853 | },
|
5854 | 'embed left': makeEmbedArrowHandler(Keyboard.keys.LEFT, false),
|
5855 | 'embed left shift': makeEmbedArrowHandler(Keyboard.keys.LEFT, true),
|
5856 | 'embed right': makeEmbedArrowHandler(Keyboard.keys.RIGHT, false),
|
5857 | 'embed right shift': makeEmbedArrowHandler(Keyboard.keys.RIGHT, true)
|
5858 | }
|
5859 | };
|
5860 |
|
5861 | function makeEmbedArrowHandler(key, shiftKey) {
|
5862 | var _ref3;
|
5863 |
|
5864 | var where = key === Keyboard.keys.LEFT ? 'prefix' : 'suffix';
|
5865 | return _ref3 = {
|
5866 | key: key,
|
5867 | shiftKey: shiftKey
|
5868 | }, _defineProperty(_ref3, where, /^$/), _defineProperty(_ref3, 'handler', function handler(range) {
|
5869 | var index = range.index;
|
5870 | if (key === Keyboard.keys.RIGHT) {
|
5871 | index += range.length + 1;
|
5872 | }
|
5873 |
|
5874 | var _quill$getLeaf3 = this.quill.getLeaf(index),
|
5875 | _quill$getLeaf4 = _slicedToArray(_quill$getLeaf3, 1),
|
5876 | leaf = _quill$getLeaf4[0];
|
5877 |
|
5878 | if (!(leaf instanceof _embed2.default)) return true;
|
5879 | if (key === Keyboard.keys.LEFT) {
|
5880 | if (shiftKey) {
|
5881 | this.quill.setSelection(range.index - 1, range.length + 1, _quill2.default.sources.USER);
|
5882 | } else {
|
5883 | this.quill.setSelection(range.index - 1, _quill2.default.sources.USER);
|
5884 | }
|
5885 | } else {
|
5886 | if (shiftKey) {
|
5887 | this.quill.setSelection(range.index, range.length + 1, _quill2.default.sources.USER);
|
5888 | } else {
|
5889 | this.quill.setSelection(range.index + range.length + 1, _quill2.default.sources.USER);
|
5890 | }
|
5891 | }
|
5892 | return false;
|
5893 | }), _ref3;
|
5894 | }
|
5895 |
|
5896 | function handleBackspace(range, context) {
|
5897 | if (range.index === 0 || this.quill.getLength() <= 1) return;
|
5898 |
|
5899 | var _quill$getLine11 = this.quill.getLine(range.index),
|
5900 | _quill$getLine12 = _slicedToArray(_quill$getLine11, 1),
|
5901 | line = _quill$getLine12[0];
|
5902 |
|
5903 | var formats = {};
|
5904 | if (context.offset === 0) {
|
5905 | var _quill$getLine13 = this.quill.getLine(range.index - 1),
|
5906 | _quill$getLine14 = _slicedToArray(_quill$getLine13, 1),
|
5907 | prev = _quill$getLine14[0];
|
5908 |
|
5909 | if (prev != null && prev.length() > 1) {
|
5910 | var curFormats = line.formats();
|
5911 | var prevFormats = this.quill.getFormat(range.index - 1, 1);
|
5912 | formats = _op2.default.attributes.diff(curFormats, prevFormats) || {};
|
5913 | }
|
5914 | }
|
5915 |
|
5916 | var length = /[\uD800-\uDBFF][\uDC00-\uDFFF]$/.test(context.prefix) ? 2 : 1;
|
5917 | this.quill.deleteText(range.index - length, length, _quill2.default.sources.USER);
|
5918 | if (Object.keys(formats).length > 0) {
|
5919 | this.quill.formatLine(range.index - length, length, formats, _quill2.default.sources.USER);
|
5920 | }
|
5921 | this.quill.focus();
|
5922 | }
|
5923 |
|
5924 | function handleDelete(range, context) {
|
5925 |
|
5926 | var length = /^[\uD800-\uDBFF][\uDC00-\uDFFF]/.test(context.suffix) ? 2 : 1;
|
5927 | if (range.index >= this.quill.getLength() - length) return;
|
5928 | var formats = {},
|
5929 | nextLength = 0;
|
5930 |
|
5931 | var _quill$getLine15 = this.quill.getLine(range.index),
|
5932 | _quill$getLine16 = _slicedToArray(_quill$getLine15, 1),
|
5933 | line = _quill$getLine16[0];
|
5934 |
|
5935 | if (context.offset >= line.length() - 1) {
|
5936 | var _quill$getLine17 = this.quill.getLine(range.index + 1),
|
5937 | _quill$getLine18 = _slicedToArray(_quill$getLine17, 1),
|
5938 | next = _quill$getLine18[0];
|
5939 |
|
5940 | if (next) {
|
5941 | var curFormats = line.formats();
|
5942 | var nextFormats = this.quill.getFormat(range.index, 1);
|
5943 | formats = _op2.default.attributes.diff(curFormats, nextFormats) || {};
|
5944 | nextLength = next.length();
|
5945 | }
|
5946 | }
|
5947 | this.quill.deleteText(range.index, length, _quill2.default.sources.USER);
|
5948 | if (Object.keys(formats).length > 0) {
|
5949 | this.quill.formatLine(range.index + nextLength - 1, length, formats, _quill2.default.sources.USER);
|
5950 | }
|
5951 | }
|
5952 |
|
5953 | function handleDeleteRange(range) {
|
5954 | var lines = this.quill.getLines(range);
|
5955 | var formats = {};
|
5956 | if (lines.length > 1) {
|
5957 | var firstFormats = lines[0].formats();
|
5958 | var lastFormats = lines[lines.length - 1].formats();
|
5959 | formats = _op2.default.attributes.diff(lastFormats, firstFormats) || {};
|
5960 | }
|
5961 | this.quill.deleteText(range, _quill2.default.sources.USER);
|
5962 | if (Object.keys(formats).length > 0) {
|
5963 | this.quill.formatLine(range.index, 1, formats, _quill2.default.sources.USER);
|
5964 | }
|
5965 | this.quill.setSelection(range.index, _quill2.default.sources.SILENT);
|
5966 | this.quill.focus();
|
5967 | }
|
5968 |
|
5969 | function handleEnter(range, context) {
|
5970 | var _this3 = this;
|
5971 |
|
5972 | if (range.length > 0) {
|
5973 | this.quill.scroll.deleteAt(range.index, range.length);
|
5974 | }
|
5975 | var lineFormats = Object.keys(context.format).reduce(function (lineFormats, format) {
|
5976 | if (_parchment2.default.query(format, _parchment2.default.Scope.BLOCK) && !Array.isArray(context.format[format])) {
|
5977 | lineFormats[format] = context.format[format];
|
5978 | }
|
5979 | return lineFormats;
|
5980 | }, {});
|
5981 | this.quill.insertText(range.index, '\n', lineFormats, _quill2.default.sources.USER);
|
5982 |
|
5983 |
|
5984 | this.quill.setSelection(range.index + 1, _quill2.default.sources.SILENT);
|
5985 | this.quill.focus();
|
5986 | Object.keys(context.format).forEach(function (name) {
|
5987 | if (lineFormats[name] != null) return;
|
5988 | if (Array.isArray(context.format[name])) return;
|
5989 | if (name === 'link') return;
|
5990 | _this3.quill.format(name, context.format[name], _quill2.default.sources.USER);
|
5991 | });
|
5992 | }
|
5993 |
|
5994 | function makeCodeBlockHandler(indent) {
|
5995 | return {
|
5996 | key: Keyboard.keys.TAB,
|
5997 | shiftKey: !indent,
|
5998 | format: { 'code-block': true },
|
5999 | handler: function handler(range) {
|
6000 | var CodeBlock = _parchment2.default.query('code-block');
|
6001 | var index = range.index,
|
6002 | length = range.length;
|
6003 |
|
6004 | var _quill$scroll$descend = this.quill.scroll.descendant(CodeBlock, index),
|
6005 | _quill$scroll$descend2 = _slicedToArray(_quill$scroll$descend, 2),
|
6006 | block = _quill$scroll$descend2[0],
|
6007 | offset = _quill$scroll$descend2[1];
|
6008 |
|
6009 | if (block == null) return;
|
6010 | var scrollIndex = this.quill.getIndex(block);
|
6011 | var start = block.newlineIndex(offset, true) + 1;
|
6012 | var end = block.newlineIndex(scrollIndex + offset + length);
|
6013 | var lines = block.domNode.textContent.slice(start, end).split('\n');
|
6014 | offset = 0;
|
6015 | lines.forEach(function (line, i) {
|
6016 | if (indent) {
|
6017 | block.insertAt(start + offset, CodeBlock.TAB);
|
6018 | offset += CodeBlock.TAB.length;
|
6019 | if (i === 0) {
|
6020 | index += CodeBlock.TAB.length;
|
6021 | } else {
|
6022 | length += CodeBlock.TAB.length;
|
6023 | }
|
6024 | } else if (line.startsWith(CodeBlock.TAB)) {
|
6025 | block.deleteAt(start + offset, CodeBlock.TAB.length);
|
6026 | offset -= CodeBlock.TAB.length;
|
6027 | if (i === 0) {
|
6028 | index -= CodeBlock.TAB.length;
|
6029 | } else {
|
6030 | length -= CodeBlock.TAB.length;
|
6031 | }
|
6032 | }
|
6033 | offset += line.length + 1;
|
6034 | });
|
6035 | this.quill.update(_quill2.default.sources.USER);
|
6036 | this.quill.setSelection(index, length, _quill2.default.sources.SILENT);
|
6037 | }
|
6038 | };
|
6039 | }
|
6040 |
|
6041 | function makeFormatHandler(format) {
|
6042 | return {
|
6043 | key: format[0].toUpperCase(),
|
6044 | shortKey: true,
|
6045 | handler: function handler(range, context) {
|
6046 | this.quill.format(format, !context.format[format], _quill2.default.sources.USER);
|
6047 | }
|
6048 | };
|
6049 | }
|
6050 |
|
6051 | function normalize(binding) {
|
6052 | if (typeof binding === 'string' || typeof binding === 'number') {
|
6053 | return normalize({ key: binding });
|
6054 | }
|
6055 | if ((typeof binding === 'undefined' ? 'undefined' : _typeof(binding)) === 'object') {
|
6056 | binding = (0, _clone2.default)(binding, false);
|
6057 | }
|
6058 | if (typeof binding.key === 'string') {
|
6059 | if (Keyboard.keys[binding.key.toUpperCase()] != null) {
|
6060 | binding.key = Keyboard.keys[binding.key.toUpperCase()];
|
6061 | } else if (binding.key.length === 1) {
|
6062 | binding.key = binding.key.toUpperCase().charCodeAt(0);
|
6063 | } else {
|
6064 | return null;
|
6065 | }
|
6066 | }
|
6067 | if (binding.shortKey) {
|
6068 | binding[SHORTKEY] = binding.shortKey;
|
6069 | delete binding.shortKey;
|
6070 | }
|
6071 | return binding;
|
6072 | }
|
6073 |
|
6074 | exports.default = Keyboard;
|
6075 | exports.SHORTKEY = SHORTKEY;
|
6076 |
|
6077 | }),
|
6078 |
|
6079 | (function(module, exports, __webpack_require__) {
|
6080 |
|
6081 | "use strict";
|
6082 |
|
6083 |
|
6084 | Object.defineProperty(exports, "__esModule", {
|
6085 | value: true
|
6086 | });
|
6087 | exports.AlignStyle = exports.AlignClass = exports.AlignAttribute = undefined;
|
6088 |
|
6089 | var _parchment = __webpack_require__(0);
|
6090 |
|
6091 | var _parchment2 = _interopRequireDefault(_parchment);
|
6092 |
|
6093 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
6094 |
|
6095 | var config = {
|
6096 | scope: _parchment2.default.Scope.BLOCK,
|
6097 | whitelist: ['right', 'center', 'justify']
|
6098 | };
|
6099 |
|
6100 | var AlignAttribute = new _parchment2.default.Attributor.Attribute('align', 'align', config);
|
6101 | var AlignClass = new _parchment2.default.Attributor.Class('align', 'ql-align', config);
|
6102 | var AlignStyle = new _parchment2.default.Attributor.Style('align', 'text-align', config);
|
6103 |
|
6104 | exports.AlignAttribute = AlignAttribute;
|
6105 | exports.AlignClass = AlignClass;
|
6106 | exports.AlignStyle = AlignStyle;
|
6107 |
|
6108 | }),
|
6109 |
|
6110 | (function(module, exports, __webpack_require__) {
|
6111 |
|
6112 | "use strict";
|
6113 |
|
6114 |
|
6115 | Object.defineProperty(exports, "__esModule", {
|
6116 | value: true
|
6117 | });
|
6118 | exports.BackgroundStyle = exports.BackgroundClass = undefined;
|
6119 |
|
6120 | var _parchment = __webpack_require__(0);
|
6121 |
|
6122 | var _parchment2 = _interopRequireDefault(_parchment);
|
6123 |
|
6124 | var _color = __webpack_require__(26);
|
6125 |
|
6126 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
6127 |
|
6128 | var BackgroundClass = new _parchment2.default.Attributor.Class('background', 'ql-bg', {
|
6129 | scope: _parchment2.default.Scope.INLINE
|
6130 | });
|
6131 | var BackgroundStyle = new _color.ColorAttributor('background', 'background-color', {
|
6132 | scope: _parchment2.default.Scope.INLINE
|
6133 | });
|
6134 |
|
6135 | exports.BackgroundClass = BackgroundClass;
|
6136 | exports.BackgroundStyle = BackgroundStyle;
|
6137 |
|
6138 | }),
|
6139 |
|
6140 | (function(module, exports, __webpack_require__) {
|
6141 |
|
6142 | "use strict";
|
6143 |
|
6144 |
|
6145 | Object.defineProperty(exports, "__esModule", {
|
6146 | value: true
|
6147 | });
|
6148 | exports.DirectionStyle = exports.DirectionClass = exports.DirectionAttribute = undefined;
|
6149 |
|
6150 | var _parchment = __webpack_require__(0);
|
6151 |
|
6152 | var _parchment2 = _interopRequireDefault(_parchment);
|
6153 |
|
6154 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
6155 |
|
6156 | var config = {
|
6157 | scope: _parchment2.default.Scope.BLOCK,
|
6158 | whitelist: ['rtl']
|
6159 | };
|
6160 |
|
6161 | var DirectionAttribute = new _parchment2.default.Attributor.Attribute('direction', 'dir', config);
|
6162 | var DirectionClass = new _parchment2.default.Attributor.Class('direction', 'ql-direction', config);
|
6163 | var DirectionStyle = new _parchment2.default.Attributor.Style('direction', 'direction', config);
|
6164 |
|
6165 | exports.DirectionAttribute = DirectionAttribute;
|
6166 | exports.DirectionClass = DirectionClass;
|
6167 | exports.DirectionStyle = DirectionStyle;
|
6168 |
|
6169 | }),
|
6170 |
|
6171 | (function(module, exports, __webpack_require__) {
|
6172 |
|
6173 | "use strict";
|
6174 |
|
6175 |
|
6176 | Object.defineProperty(exports, "__esModule", {
|
6177 | value: true
|
6178 | });
|
6179 | exports.FontClass = exports.FontStyle = undefined;
|
6180 |
|
6181 | 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; }; }();
|
6182 |
|
6183 | 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); } };
|
6184 |
|
6185 | var _parchment = __webpack_require__(0);
|
6186 |
|
6187 | var _parchment2 = _interopRequireDefault(_parchment);
|
6188 |
|
6189 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
6190 |
|
6191 | function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
6192 |
|
6193 | 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; }
|
6194 |
|
6195 | 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; }
|
6196 |
|
6197 | var config = {
|
6198 | scope: _parchment2.default.Scope.INLINE,
|
6199 | whitelist: ['serif', 'monospace']
|
6200 | };
|
6201 |
|
6202 | var FontClass = new _parchment2.default.Attributor.Class('font', 'ql-font', config);
|
6203 |
|
6204 | var FontStyleAttributor = function (_Parchment$Attributor) {
|
6205 | _inherits(FontStyleAttributor, _Parchment$Attributor);
|
6206 |
|
6207 | function FontStyleAttributor() {
|
6208 | _classCallCheck(this, FontStyleAttributor);
|
6209 |
|
6210 | return _possibleConstructorReturn(this, (FontStyleAttributor.__proto__ || Object.getPrototypeOf(FontStyleAttributor)).apply(this, arguments));
|
6211 | }
|
6212 |
|
6213 | _createClass(FontStyleAttributor, [{
|
6214 | key: 'value',
|
6215 | value: function value(node) {
|
6216 | return _get(FontStyleAttributor.prototype.__proto__ || Object.getPrototypeOf(FontStyleAttributor.prototype), 'value', this).call(this, node).replace(/["']/g, '');
|
6217 | }
|
6218 | }]);
|
6219 |
|
6220 | return FontStyleAttributor;
|
6221 | }(_parchment2.default.Attributor.Style);
|
6222 |
|
6223 | var FontStyle = new FontStyleAttributor('font', 'font-family', config);
|
6224 |
|
6225 | exports.FontStyle = FontStyle;
|
6226 | exports.FontClass = FontClass;
|
6227 |
|
6228 | }),
|
6229 |
|
6230 | (function(module, exports, __webpack_require__) {
|
6231 |
|
6232 | "use strict";
|
6233 |
|
6234 |
|
6235 | Object.defineProperty(exports, "__esModule", {
|
6236 | value: true
|
6237 | });
|
6238 | exports.SizeStyle = exports.SizeClass = undefined;
|
6239 |
|
6240 | var _parchment = __webpack_require__(0);
|
6241 |
|
6242 | var _parchment2 = _interopRequireDefault(_parchment);
|
6243 |
|
6244 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
6245 |
|
6246 | var SizeClass = new _parchment2.default.Attributor.Class('size', 'ql-size', {
|
6247 | scope: _parchment2.default.Scope.INLINE,
|
6248 | whitelist: ['small', 'large', 'huge']
|
6249 | });
|
6250 | var SizeStyle = new _parchment2.default.Attributor.Style('size', 'font-size', {
|
6251 | scope: _parchment2.default.Scope.INLINE,
|
6252 | whitelist: ['10px', '18px', '32px']
|
6253 | });
|
6254 |
|
6255 | exports.SizeClass = SizeClass;
|
6256 | exports.SizeStyle = SizeStyle;
|
6257 |
|
6258 | }),
|
6259 |
|
6260 | (function(module, exports, __webpack_require__) {
|
6261 |
|
6262 | "use strict";
|
6263 |
|
6264 |
|
6265 | module.exports = {
|
6266 | 'align': {
|
6267 | '': __webpack_require__(76),
|
6268 | 'center': __webpack_require__(77),
|
6269 | 'right': __webpack_require__(78),
|
6270 | 'justify': __webpack_require__(79)
|
6271 | },
|
6272 | 'background': __webpack_require__(80),
|
6273 | 'blockquote': __webpack_require__(81),
|
6274 | 'bold': __webpack_require__(82),
|
6275 | 'clean': __webpack_require__(83),
|
6276 | 'code': __webpack_require__(58),
|
6277 | 'code-block': __webpack_require__(58),
|
6278 | 'color': __webpack_require__(84),
|
6279 | 'direction': {
|
6280 | '': __webpack_require__(85),
|
6281 | 'rtl': __webpack_require__(86)
|
6282 | },
|
6283 | 'float': {
|
6284 | 'center': __webpack_require__(87),
|
6285 | 'full': __webpack_require__(88),
|
6286 | 'left': __webpack_require__(89),
|
6287 | 'right': __webpack_require__(90)
|
6288 | },
|
6289 | 'formula': __webpack_require__(91),
|
6290 | 'header': {
|
6291 | '1': __webpack_require__(92),
|
6292 | '2': __webpack_require__(93)
|
6293 | },
|
6294 | 'italic': __webpack_require__(94),
|
6295 | 'image': __webpack_require__(95),
|
6296 | 'indent': {
|
6297 | '+1': __webpack_require__(96),
|
6298 | '-1': __webpack_require__(97)
|
6299 | },
|
6300 | 'link': __webpack_require__(98),
|
6301 | 'list': {
|
6302 | 'ordered': __webpack_require__(99),
|
6303 | 'bullet': __webpack_require__(100),
|
6304 | 'check': __webpack_require__(101)
|
6305 | },
|
6306 | 'script': {
|
6307 | 'sub': __webpack_require__(102),
|
6308 | 'super': __webpack_require__(103)
|
6309 | },
|
6310 | 'strike': __webpack_require__(104),
|
6311 | 'underline': __webpack_require__(105),
|
6312 | 'video': __webpack_require__(106)
|
6313 | };
|
6314 |
|
6315 | }),
|
6316 |
|
6317 | (function(module, exports, __webpack_require__) {
|
6318 |
|
6319 | "use strict";
|
6320 |
|
6321 |
|
6322 | Object.defineProperty(exports, "__esModule", {
|
6323 | value: true
|
6324 | });
|
6325 | exports.getLastChangeIndex = exports.default = undefined;
|
6326 |
|
6327 | 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; }; }();
|
6328 |
|
6329 | var _parchment = __webpack_require__(0);
|
6330 |
|
6331 | var _parchment2 = _interopRequireDefault(_parchment);
|
6332 |
|
6333 | var _quill = __webpack_require__(5);
|
6334 |
|
6335 | var _quill2 = _interopRequireDefault(_quill);
|
6336 |
|
6337 | var _module = __webpack_require__(9);
|
6338 |
|
6339 | var _module2 = _interopRequireDefault(_module);
|
6340 |
|
6341 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
6342 |
|
6343 | function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
6344 |
|
6345 | 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; }
|
6346 |
|
6347 | 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; }
|
6348 |
|
6349 | var History = function (_Module) {
|
6350 | _inherits(History, _Module);
|
6351 |
|
6352 | function History(quill, options) {
|
6353 | _classCallCheck(this, History);
|
6354 |
|
6355 | var _this = _possibleConstructorReturn(this, (History.__proto__ || Object.getPrototypeOf(History)).call(this, quill, options));
|
6356 |
|
6357 | _this.lastRecorded = 0;
|
6358 | _this.ignoreChange = false;
|
6359 | _this.clear();
|
6360 | _this.quill.on(_quill2.default.events.EDITOR_CHANGE, function (eventName, delta, oldDelta, source) {
|
6361 | if (eventName !== _quill2.default.events.TEXT_CHANGE || _this.ignoreChange) return;
|
6362 | if (!_this.options.userOnly || source === _quill2.default.sources.USER) {
|
6363 | _this.record(delta, oldDelta);
|
6364 | } else {
|
6365 | _this.transform(delta);
|
6366 | }
|
6367 | });
|
6368 | _this.quill.keyboard.addBinding({ key: 'Z', shortKey: true }, _this.undo.bind(_this));
|
6369 | _this.quill.keyboard.addBinding({ key: 'Z', shortKey: true, shiftKey: true }, _this.redo.bind(_this));
|
6370 | if (/Win/i.test(navigator.platform)) {
|
6371 | _this.quill.keyboard.addBinding({ key: 'Y', shortKey: true }, _this.redo.bind(_this));
|
6372 | }
|
6373 | return _this;
|
6374 | }
|
6375 |
|
6376 | _createClass(History, [{
|
6377 | key: 'change',
|
6378 | value: function change(source, dest) {
|
6379 | if (this.stack[source].length === 0) return;
|
6380 | var delta = this.stack[source].pop();
|
6381 | this.lastRecorded = 0;
|
6382 | this.ignoreChange = true;
|
6383 | this.quill.updateContents(delta[source], _quill2.default.sources.USER);
|
6384 | this.ignoreChange = false;
|
6385 | var index = getLastChangeIndex(delta[source]);
|
6386 | this.quill.setSelection(index);
|
6387 | this.stack[dest].push(delta);
|
6388 | }
|
6389 | }, {
|
6390 | key: 'clear',
|
6391 | value: function clear() {
|
6392 | this.stack = { undo: [], redo: [] };
|
6393 | }
|
6394 | }, {
|
6395 | key: 'cutoff',
|
6396 | value: function cutoff() {
|
6397 | this.lastRecorded = 0;
|
6398 | }
|
6399 | }, {
|
6400 | key: 'record',
|
6401 | value: function record(changeDelta, oldDelta) {
|
6402 | if (changeDelta.ops.length === 0) return;
|
6403 | this.stack.redo = [];
|
6404 | var undoDelta = this.quill.getContents().diff(oldDelta);
|
6405 | var timestamp = Date.now();
|
6406 | if (this.lastRecorded + this.options.delay > timestamp && this.stack.undo.length > 0) {
|
6407 | var delta = this.stack.undo.pop();
|
6408 | undoDelta = undoDelta.compose(delta.undo);
|
6409 | changeDelta = delta.redo.compose(changeDelta);
|
6410 | } else {
|
6411 | this.lastRecorded = timestamp;
|
6412 | }
|
6413 | this.stack.undo.push({
|
6414 | redo: changeDelta,
|
6415 | undo: undoDelta
|
6416 | });
|
6417 | if (this.stack.undo.length > this.options.maxStack) {
|
6418 | this.stack.undo.shift();
|
6419 | }
|
6420 | }
|
6421 | }, {
|
6422 | key: 'redo',
|
6423 | value: function redo() {
|
6424 | this.change('redo', 'undo');
|
6425 | }
|
6426 | }, {
|
6427 | key: 'transform',
|
6428 | value: function transform(delta) {
|
6429 | this.stack.undo.forEach(function (change) {
|
6430 | change.undo = delta.transform(change.undo, true);
|
6431 | change.redo = delta.transform(change.redo, true);
|
6432 | });
|
6433 | this.stack.redo.forEach(function (change) {
|
6434 | change.undo = delta.transform(change.undo, true);
|
6435 | change.redo = delta.transform(change.redo, true);
|
6436 | });
|
6437 | }
|
6438 | }, {
|
6439 | key: 'undo',
|
6440 | value: function undo() {
|
6441 | this.change('undo', 'redo');
|
6442 | }
|
6443 | }]);
|
6444 |
|
6445 | return History;
|
6446 | }(_module2.default);
|
6447 |
|
6448 | History.DEFAULTS = {
|
6449 | delay: 1000,
|
6450 | maxStack: 100,
|
6451 | userOnly: false
|
6452 | };
|
6453 |
|
6454 | function endsWithNewlineChange(delta) {
|
6455 | var lastOp = delta.ops[delta.ops.length - 1];
|
6456 | if (lastOp == null) return false;
|
6457 | if (lastOp.insert != null) {
|
6458 | return typeof lastOp.insert === 'string' && lastOp.insert.endsWith('\n');
|
6459 | }
|
6460 | if (lastOp.attributes != null) {
|
6461 | return Object.keys(lastOp.attributes).some(function (attr) {
|
6462 | return _parchment2.default.query(attr, _parchment2.default.Scope.BLOCK) != null;
|
6463 | });
|
6464 | }
|
6465 | return false;
|
6466 | }
|
6467 |
|
6468 | function getLastChangeIndex(delta) {
|
6469 | var deleteLength = delta.reduce(function (length, op) {
|
6470 | length += op.delete || 0;
|
6471 | return length;
|
6472 | }, 0);
|
6473 | var changeIndex = delta.length() - deleteLength;
|
6474 | if (endsWithNewlineChange(delta)) {
|
6475 | changeIndex -= 1;
|
6476 | }
|
6477 | return changeIndex;
|
6478 | }
|
6479 |
|
6480 | exports.default = History;
|
6481 | exports.getLastChangeIndex = getLastChangeIndex;
|
6482 |
|
6483 | }),
|
6484 |
|
6485 | (function(module, exports, __webpack_require__) {
|
6486 |
|
6487 | "use strict";
|
6488 |
|
6489 |
|
6490 | Object.defineProperty(exports, "__esModule", {
|
6491 | value: true
|
6492 | });
|
6493 | exports.default = exports.BaseTooltip = undefined;
|
6494 |
|
6495 | 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; }; }();
|
6496 |
|
6497 | 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); } };
|
6498 |
|
6499 | var _extend = __webpack_require__(3);
|
6500 |
|
6501 | var _extend2 = _interopRequireDefault(_extend);
|
6502 |
|
6503 | var _quillDelta = __webpack_require__(2);
|
6504 |
|
6505 | var _quillDelta2 = _interopRequireDefault(_quillDelta);
|
6506 |
|
6507 | var _emitter = __webpack_require__(8);
|
6508 |
|
6509 | var _emitter2 = _interopRequireDefault(_emitter);
|
6510 |
|
6511 | var _keyboard = __webpack_require__(35);
|
6512 |
|
6513 | var _keyboard2 = _interopRequireDefault(_keyboard);
|
6514 |
|
6515 | var _theme = __webpack_require__(34);
|
6516 |
|
6517 | var _theme2 = _interopRequireDefault(_theme);
|
6518 |
|
6519 | var _colorPicker = __webpack_require__(59);
|
6520 |
|
6521 | var _colorPicker2 = _interopRequireDefault(_colorPicker);
|
6522 |
|
6523 | var _iconPicker = __webpack_require__(60);
|
6524 |
|
6525 | var _iconPicker2 = _interopRequireDefault(_iconPicker);
|
6526 |
|
6527 | var _picker = __webpack_require__(28);
|
6528 |
|
6529 | var _picker2 = _interopRequireDefault(_picker);
|
6530 |
|
6531 | var _tooltip = __webpack_require__(61);
|
6532 |
|
6533 | var _tooltip2 = _interopRequireDefault(_tooltip);
|
6534 |
|
6535 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
6536 |
|
6537 | function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
6538 |
|
6539 | 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; }
|
6540 |
|
6541 | 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; }
|
6542 |
|
6543 | var ALIGNS = [false, 'center', 'right', 'justify'];
|
6544 |
|
6545 | var COLORS = ["#000000", "#e60000", "#ff9900", "#ffff00", "#008a00", "#0066cc", "#9933ff", "#ffffff", "#facccc", "#ffebcc", "#ffffcc", "#cce8cc", "#cce0f5", "#ebd6ff", "#bbbbbb", "#f06666", "#ffc266", "#ffff66", "#66b966", "#66a3e0", "#c285ff", "#888888", "#a10000", "#b26b00", "#b2b200", "#006100", "#0047b2", "#6b24b2", "#444444", "#5c0000", "#663d00", "#666600", "#003700", "#002966", "#3d1466"];
|
6546 |
|
6547 | var FONTS = [false, 'serif', 'monospace'];
|
6548 |
|
6549 | var HEADERS = ['1', '2', '3', false];
|
6550 |
|
6551 | var SIZES = ['small', false, 'large', 'huge'];
|
6552 |
|
6553 | var BaseTheme = function (_Theme) {
|
6554 | _inherits(BaseTheme, _Theme);
|
6555 |
|
6556 | function BaseTheme(quill, options) {
|
6557 | _classCallCheck(this, BaseTheme);
|
6558 |
|
6559 | var _this = _possibleConstructorReturn(this, (BaseTheme.__proto__ || Object.getPrototypeOf(BaseTheme)).call(this, quill, options));
|
6560 |
|
6561 | var listener = function listener(e) {
|
6562 | if (!document.body.contains(quill.root)) {
|
6563 | return document.body.removeEventListener('click', listener);
|
6564 | }
|
6565 | if (_this.tooltip != null && !_this.tooltip.root.contains(e.target) && document.activeElement !== _this.tooltip.textbox && !_this.quill.hasFocus()) {
|
6566 | _this.tooltip.hide();
|
6567 | }
|
6568 | if (_this.pickers != null) {
|
6569 | _this.pickers.forEach(function (picker) {
|
6570 | if (!picker.container.contains(e.target)) {
|
6571 | picker.close();
|
6572 | }
|
6573 | });
|
6574 | }
|
6575 | };
|
6576 | document.body.addEventListener('click', listener);
|
6577 | return _this;
|
6578 | }
|
6579 |
|
6580 | _createClass(BaseTheme, [{
|
6581 | key: 'addModule',
|
6582 | value: function addModule(name) {
|
6583 | var module = _get(BaseTheme.prototype.__proto__ || Object.getPrototypeOf(BaseTheme.prototype), 'addModule', this).call(this, name);
|
6584 | if (name === 'toolbar') {
|
6585 | this.extendToolbar(module);
|
6586 | }
|
6587 | return module;
|
6588 | }
|
6589 | }, {
|
6590 | key: 'buildButtons',
|
6591 | value: function buildButtons(buttons, icons) {
|
6592 | buttons.forEach(function (button) {
|
6593 | var className = button.getAttribute('class') || '';
|
6594 | className.split(/\s+/).forEach(function (name) {
|
6595 | if (!name.startsWith('ql-')) return;
|
6596 | name = name.slice('ql-'.length);
|
6597 | if (icons[name] == null) return;
|
6598 | if (name === 'direction') {
|
6599 | button.innerHTML = icons[name][''] + icons[name]['rtl'];
|
6600 | } else if (typeof icons[name] === 'string') {
|
6601 | button.innerHTML = icons[name];
|
6602 | } else {
|
6603 | var value = button.value || '';
|
6604 | if (value != null && icons[name][value]) {
|
6605 | button.innerHTML = icons[name][value];
|
6606 | }
|
6607 | }
|
6608 | });
|
6609 | });
|
6610 | }
|
6611 | }, {
|
6612 | key: 'buildPickers',
|
6613 | value: function buildPickers(selects, icons) {
|
6614 | var _this2 = this;
|
6615 |
|
6616 | this.pickers = selects.map(function (select) {
|
6617 | if (select.classList.contains('ql-align')) {
|
6618 | if (select.querySelector('option') == null) {
|
6619 | fillSelect(select, ALIGNS);
|
6620 | }
|
6621 | return new _iconPicker2.default(select, icons.align);
|
6622 | } else if (select.classList.contains('ql-background') || select.classList.contains('ql-color')) {
|
6623 | var format = select.classList.contains('ql-background') ? 'background' : 'color';
|
6624 | if (select.querySelector('option') == null) {
|
6625 | fillSelect(select, COLORS, format === 'background' ? '#ffffff' : '#000000');
|
6626 | }
|
6627 | return new _colorPicker2.default(select, icons[format]);
|
6628 | } else {
|
6629 | if (select.querySelector('option') == null) {
|
6630 | if (select.classList.contains('ql-font')) {
|
6631 | fillSelect(select, FONTS);
|
6632 | } else if (select.classList.contains('ql-header')) {
|
6633 | fillSelect(select, HEADERS);
|
6634 | } else if (select.classList.contains('ql-size')) {
|
6635 | fillSelect(select, SIZES);
|
6636 | }
|
6637 | }
|
6638 | return new _picker2.default(select);
|
6639 | }
|
6640 | });
|
6641 | var update = function update() {
|
6642 | _this2.pickers.forEach(function (picker) {
|
6643 | picker.update();
|
6644 | });
|
6645 | };
|
6646 | this.quill.on(_emitter2.default.events.EDITOR_CHANGE, update);
|
6647 | }
|
6648 | }]);
|
6649 |
|
6650 | return BaseTheme;
|
6651 | }(_theme2.default);
|
6652 |
|
6653 | BaseTheme.DEFAULTS = (0, _extend2.default)(true, {}, _theme2.default.DEFAULTS, {
|
6654 | modules: {
|
6655 | toolbar: {
|
6656 | handlers: {
|
6657 | formula: function formula() {
|
6658 | this.quill.theme.tooltip.edit('formula');
|
6659 | },
|
6660 | image: function image() {
|
6661 | var _this3 = this;
|
6662 |
|
6663 | var fileInput = this.container.querySelector('input.ql-image[type=file]');
|
6664 | if (fileInput == null) {
|
6665 | fileInput = document.createElement('input');
|
6666 | fileInput.setAttribute('type', 'file');
|
6667 | fileInput.setAttribute('accept', 'image/png, image/gif, image/jpeg, image/bmp, image/x-icon');
|
6668 | fileInput.classList.add('ql-image');
|
6669 | fileInput.addEventListener('change', function () {
|
6670 | if (fileInput.files != null && fileInput.files[0] != null) {
|
6671 | var reader = new FileReader();
|
6672 | reader.onload = function (e) {
|
6673 | var range = _this3.quill.getSelection(true);
|
6674 | _this3.quill.updateContents(new _quillDelta2.default().retain(range.index).delete(range.length).insert({ image: e.target.result }), _emitter2.default.sources.USER);
|
6675 | _this3.quill.setSelection(range.index + 1, _emitter2.default.sources.SILENT);
|
6676 | fileInput.value = "";
|
6677 | };
|
6678 | reader.readAsDataURL(fileInput.files[0]);
|
6679 | }
|
6680 | });
|
6681 | this.container.appendChild(fileInput);
|
6682 | }
|
6683 | fileInput.click();
|
6684 | },
|
6685 | video: function video() {
|
6686 | this.quill.theme.tooltip.edit('video');
|
6687 | }
|
6688 | }
|
6689 | }
|
6690 | }
|
6691 | });
|
6692 |
|
6693 | var BaseTooltip = function (_Tooltip) {
|
6694 | _inherits(BaseTooltip, _Tooltip);
|
6695 |
|
6696 | function BaseTooltip(quill, boundsContainer) {
|
6697 | _classCallCheck(this, BaseTooltip);
|
6698 |
|
6699 | var _this4 = _possibleConstructorReturn(this, (BaseTooltip.__proto__ || Object.getPrototypeOf(BaseTooltip)).call(this, quill, boundsContainer));
|
6700 |
|
6701 | _this4.textbox = _this4.root.querySelector('input[type="text"]');
|
6702 | _this4.listen();
|
6703 | return _this4;
|
6704 | }
|
6705 |
|
6706 | _createClass(BaseTooltip, [{
|
6707 | key: 'listen',
|
6708 | value: function listen() {
|
6709 | var _this5 = this;
|
6710 |
|
6711 | this.textbox.addEventListener('keydown', function (event) {
|
6712 | if (_keyboard2.default.match(event, 'enter')) {
|
6713 | _this5.save();
|
6714 | event.preventDefault();
|
6715 | } else if (_keyboard2.default.match(event, 'escape')) {
|
6716 | _this5.cancel();
|
6717 | event.preventDefault();
|
6718 | }
|
6719 | });
|
6720 | }
|
6721 | }, {
|
6722 | key: 'cancel',
|
6723 | value: function cancel() {
|
6724 | this.hide();
|
6725 | }
|
6726 | }, {
|
6727 | key: 'edit',
|
6728 | value: function edit() {
|
6729 | var mode = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'link';
|
6730 | var preview = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
|
6731 |
|
6732 | this.root.classList.remove('ql-hidden');
|
6733 | this.root.classList.add('ql-editing');
|
6734 | if (preview != null) {
|
6735 | this.textbox.value = preview;
|
6736 | } else if (mode !== this.root.getAttribute('data-mode')) {
|
6737 | this.textbox.value = '';
|
6738 | }
|
6739 | this.position(this.quill.getBounds(this.quill.selection.savedRange));
|
6740 | this.textbox.select();
|
6741 | this.textbox.setAttribute('placeholder', this.textbox.getAttribute('data-' + mode) || '');
|
6742 | this.root.setAttribute('data-mode', mode);
|
6743 | }
|
6744 | }, {
|
6745 | key: 'restoreFocus',
|
6746 | value: function restoreFocus() {
|
6747 | var scrollTop = this.quill.scrollingContainer.scrollTop;
|
6748 | this.quill.focus();
|
6749 | this.quill.scrollingContainer.scrollTop = scrollTop;
|
6750 | }
|
6751 | }, {
|
6752 | key: 'save',
|
6753 | value: function save() {
|
6754 | var value = this.textbox.value;
|
6755 | switch (this.root.getAttribute('data-mode')) {
|
6756 | case 'link':
|
6757 | {
|
6758 | var scrollTop = this.quill.root.scrollTop;
|
6759 | if (this.linkRange) {
|
6760 | this.quill.formatText(this.linkRange, 'link', value, _emitter2.default.sources.USER);
|
6761 | delete this.linkRange;
|
6762 | } else {
|
6763 | this.restoreFocus();
|
6764 | this.quill.format('link', value, _emitter2.default.sources.USER);
|
6765 | }
|
6766 | this.quill.root.scrollTop = scrollTop;
|
6767 | break;
|
6768 | }
|
6769 | case 'video':
|
6770 | {
|
6771 | value = extractVideoUrl(value);
|
6772 | }
|
6773 | case 'formula':
|
6774 | {
|
6775 | if (!value) break;
|
6776 | var range = this.quill.getSelection(true);
|
6777 | if (range != null) {
|
6778 | var index = range.index + range.length;
|
6779 | this.quill.insertEmbed(index, this.root.getAttribute('data-mode'), value, _emitter2.default.sources.USER);
|
6780 | if (this.root.getAttribute('data-mode') === 'formula') {
|
6781 | this.quill.insertText(index + 1, ' ', _emitter2.default.sources.USER);
|
6782 | }
|
6783 | this.quill.setSelection(index + 2, _emitter2.default.sources.USER);
|
6784 | }
|
6785 | break;
|
6786 | }
|
6787 | default:
|
6788 | }
|
6789 | this.textbox.value = '';
|
6790 | this.hide();
|
6791 | }
|
6792 | }]);
|
6793 |
|
6794 | return BaseTooltip;
|
6795 | }(_tooltip2.default);
|
6796 |
|
6797 | function extractVideoUrl(url) {
|
6798 | var match = url.match(/^(?:(https?):\/\/)?(?:(?:www|m)\.)?youtube\.com\/watch.*v=([a-zA-Z0-9_-]+)/) || url.match(/^(?:(https?):\/\/)?(?:(?:www|m)\.)?youtu\.be\/([a-zA-Z0-9_-]+)/);
|
6799 | if (match) {
|
6800 | return (match[1] || 'https') + '://www.youtube.com/embed/' + match[2] + '?showinfo=0';
|
6801 | }
|
6802 | if (match = url.match(/^(?:(https?):\/\/)?(?:www\.)?vimeo\.com\/(\d+)/)) {
|
6803 |
|
6804 | return (match[1] || 'https') + '://player.vimeo.com/video/' + match[2] + '/';
|
6805 | }
|
6806 | return url;
|
6807 | }
|
6808 |
|
6809 | function fillSelect(select, values) {
|
6810 | var defaultValue = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
|
6811 |
|
6812 | values.forEach(function (value) {
|
6813 | var option = document.createElement('option');
|
6814 | if (value === defaultValue) {
|
6815 | option.setAttribute('selected', 'selected');
|
6816 | } else {
|
6817 | option.setAttribute('value', value);
|
6818 | }
|
6819 | select.appendChild(option);
|
6820 | });
|
6821 | }
|
6822 |
|
6823 | exports.BaseTooltip = BaseTooltip;
|
6824 | exports.default = BaseTheme;
|
6825 |
|
6826 | }),
|
6827 |
|
6828 | (function(module, exports, __webpack_require__) {
|
6829 |
|
6830 | "use strict";
|
6831 |
|
6832 | Object.defineProperty(exports, "__esModule", { value: true });
|
6833 | var LinkedList = (function () {
|
6834 | function LinkedList() {
|
6835 | this.head = this.tail = undefined;
|
6836 | this.length = 0;
|
6837 | }
|
6838 | LinkedList.prototype.append = function () {
|
6839 | var nodes = [];
|
6840 | for (var _i = 0; _i < arguments.length; _i++) {
|
6841 | nodes[_i] = arguments[_i];
|
6842 | }
|
6843 | this.insertBefore(nodes[0], undefined);
|
6844 | if (nodes.length > 1) {
|
6845 | this.append.apply(this, nodes.slice(1));
|
6846 | }
|
6847 | };
|
6848 | LinkedList.prototype.contains = function (node) {
|
6849 | var cur, next = this.iterator();
|
6850 | while (cur = next()) {
|
6851 | if (cur === node)
|
6852 | return true;
|
6853 | }
|
6854 | return false;
|
6855 | };
|
6856 | LinkedList.prototype.insertBefore = function (node, refNode) {
|
6857 | node.next = refNode;
|
6858 | if (refNode != null) {
|
6859 | node.prev = refNode.prev;
|
6860 | if (refNode.prev != null) {
|
6861 | refNode.prev.next = node;
|
6862 | }
|
6863 | refNode.prev = node;
|
6864 | if (refNode === this.head) {
|
6865 | this.head = node;
|
6866 | }
|
6867 | }
|
6868 | else if (this.tail != null) {
|
6869 | this.tail.next = node;
|
6870 | node.prev = this.tail;
|
6871 | this.tail = node;
|
6872 | }
|
6873 | else {
|
6874 | node.prev = undefined;
|
6875 | this.head = this.tail = node;
|
6876 | }
|
6877 | this.length += 1;
|
6878 | };
|
6879 | LinkedList.prototype.offset = function (target) {
|
6880 | var index = 0, cur = this.head;
|
6881 | while (cur != null) {
|
6882 | if (cur === target)
|
6883 | return index;
|
6884 | index += cur.length();
|
6885 | cur = cur.next;
|
6886 | }
|
6887 | return -1;
|
6888 | };
|
6889 | LinkedList.prototype.remove = function (node) {
|
6890 | if (!this.contains(node))
|
6891 | return;
|
6892 | if (node.prev != null)
|
6893 | node.prev.next = node.next;
|
6894 | if (node.next != null)
|
6895 | node.next.prev = node.prev;
|
6896 | if (node === this.head)
|
6897 | this.head = node.next;
|
6898 | if (node === this.tail)
|
6899 | this.tail = node.prev;
|
6900 | this.length -= 1;
|
6901 | };
|
6902 | LinkedList.prototype.iterator = function (curNode) {
|
6903 | if (curNode === void 0) { curNode = this.head; }
|
6904 |
|
6905 | return function () {
|
6906 | var ret = curNode;
|
6907 | if (curNode != null)
|
6908 | curNode = curNode.next;
|
6909 | return ret;
|
6910 | };
|
6911 | };
|
6912 | LinkedList.prototype.find = function (index, inclusive) {
|
6913 | if (inclusive === void 0) { inclusive = false; }
|
6914 | var cur, next = this.iterator();
|
6915 | while (cur = next()) {
|
6916 | var length = cur.length();
|
6917 | if (index < length || (inclusive && index === length && (cur.next == null || cur.next.length() !== 0))) {
|
6918 | return [cur, index];
|
6919 | }
|
6920 | index -= length;
|
6921 | }
|
6922 | return [null, 0];
|
6923 | };
|
6924 | LinkedList.prototype.forEach = function (callback) {
|
6925 | var cur, next = this.iterator();
|
6926 | while (cur = next()) {
|
6927 | callback(cur);
|
6928 | }
|
6929 | };
|
6930 | LinkedList.prototype.forEachAt = function (index, length, callback) {
|
6931 | if (length <= 0)
|
6932 | return;
|
6933 | var _a = this.find(index), startNode = _a[0], offset = _a[1];
|
6934 | var cur, curIndex = index - offset, next = this.iterator(startNode);
|
6935 | while ((cur = next()) && curIndex < index + length) {
|
6936 | var curLength = cur.length();
|
6937 | if (index > curIndex) {
|
6938 | callback(cur, index - curIndex, Math.min(length, curIndex + curLength - index));
|
6939 | }
|
6940 | else {
|
6941 | callback(cur, 0, Math.min(curLength, index + length - curIndex));
|
6942 | }
|
6943 | curIndex += curLength;
|
6944 | }
|
6945 | };
|
6946 | LinkedList.prototype.map = function (callback) {
|
6947 | return this.reduce(function (memo, cur) {
|
6948 | memo.push(callback(cur));
|
6949 | return memo;
|
6950 | }, []);
|
6951 | };
|
6952 | LinkedList.prototype.reduce = function (callback, memo) {
|
6953 | var cur, next = this.iterator();
|
6954 | while (cur = next()) {
|
6955 | memo = callback(memo, cur);
|
6956 | }
|
6957 | return memo;
|
6958 | };
|
6959 | return LinkedList;
|
6960 | }());
|
6961 | exports.default = LinkedList;
|
6962 |
|
6963 |
|
6964 | }),
|
6965 |
|
6966 | (function(module, exports, __webpack_require__) {
|
6967 |
|
6968 | "use strict";
|
6969 |
|
6970 | var __extends = (this && this.__extends) || (function () {
|
6971 | var extendStatics = Object.setPrototypeOf ||
|
6972 | ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
6973 | function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
|
6974 | return function (d, b) {
|
6975 | extendStatics(d, b);
|
6976 | function __() { this.constructor = d; }
|
6977 | d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
6978 | };
|
6979 | })();
|
6980 | Object.defineProperty(exports, "__esModule", { value: true });
|
6981 | var container_1 = __webpack_require__(17);
|
6982 | var Registry = __webpack_require__(1);
|
6983 | var OBSERVER_CONFIG = {
|
6984 | attributes: true,
|
6985 | characterData: true,
|
6986 | characterDataOldValue: true,
|
6987 | childList: true,
|
6988 | subtree: true
|
6989 | };
|
6990 | var MAX_OPTIMIZE_ITERATIONS = 100;
|
6991 | var ScrollBlot = (function (_super) {
|
6992 | __extends(ScrollBlot, _super);
|
6993 | function ScrollBlot(node) {
|
6994 | var _this = _super.call(this, node) || this;
|
6995 | _this.parent = null;
|
6996 | _this.observer = new MutationObserver(function (mutations) {
|
6997 | _this.update(mutations);
|
6998 | });
|
6999 | _this.observer.observe(_this.domNode, OBSERVER_CONFIG);
|
7000 | return _this;
|
7001 | }
|
7002 | ScrollBlot.prototype.detach = function () {
|
7003 | _super.prototype.detach.call(this);
|
7004 | this.observer.disconnect();
|
7005 | };
|
7006 | ScrollBlot.prototype.deleteAt = function (index, length) {
|
7007 | this.update();
|
7008 | if (index === 0 && length === this.length()) {
|
7009 | this.children.forEach(function (child) {
|
7010 | child.remove();
|
7011 | });
|
7012 | }
|
7013 | else {
|
7014 | _super.prototype.deleteAt.call(this, index, length);
|
7015 | }
|
7016 | };
|
7017 | ScrollBlot.prototype.formatAt = function (index, length, name, value) {
|
7018 | this.update();
|
7019 | _super.prototype.formatAt.call(this, index, length, name, value);
|
7020 | };
|
7021 | ScrollBlot.prototype.insertAt = function (index, value, def) {
|
7022 | this.update();
|
7023 | _super.prototype.insertAt.call(this, index, value, def);
|
7024 | };
|
7025 | ScrollBlot.prototype.optimize = function (mutations, context) {
|
7026 | var _this = this;
|
7027 | if (mutations === void 0) { mutations = []; }
|
7028 | if (context === void 0) { context = {}; }
|
7029 | _super.prototype.optimize.call(this, context);
|
7030 |
|
7031 | var records = [].slice.call(this.observer.takeRecords());
|
7032 |
|
7033 |
|
7034 | while (records.length > 0)
|
7035 | mutations.push(records.pop());
|
7036 |
|
7037 | var mark = function (blot, markParent) {
|
7038 | if (markParent === void 0) { markParent = true; }
|
7039 | if (blot == null || blot === _this)
|
7040 | return;
|
7041 | if (blot.domNode.parentNode == null)
|
7042 | return;
|
7043 | if (blot.domNode[Registry.DATA_KEY].mutations == null) {
|
7044 | blot.domNode[Registry.DATA_KEY].mutations = [];
|
7045 | }
|
7046 | if (markParent)
|
7047 | mark(blot.parent);
|
7048 | };
|
7049 | var optimize = function (blot) {
|
7050 | if (blot.domNode[Registry.DATA_KEY] == null || blot.domNode[Registry.DATA_KEY].mutations == null) {
|
7051 | return;
|
7052 | }
|
7053 | if (blot instanceof container_1.default) {
|
7054 | blot.children.forEach(optimize);
|
7055 | }
|
7056 | blot.optimize(context);
|
7057 | };
|
7058 | var remaining = mutations;
|
7059 | for (var i = 0; remaining.length > 0; i += 1) {
|
7060 | if (i >= MAX_OPTIMIZE_ITERATIONS) {
|
7061 | throw new Error('[Parchment] Maximum optimize iterations reached');
|
7062 | }
|
7063 | remaining.forEach(function (mutation) {
|
7064 | var blot = Registry.find(mutation.target, true);
|
7065 | if (blot == null)
|
7066 | return;
|
7067 | if (blot.domNode === mutation.target) {
|
7068 | if (mutation.type === 'childList') {
|
7069 | mark(Registry.find(mutation.previousSibling, false));
|
7070 | [].forEach.call(mutation.addedNodes, function (node) {
|
7071 | var child = Registry.find(node, false);
|
7072 | mark(child, false);
|
7073 | if (child instanceof container_1.default) {
|
7074 | child.children.forEach(function (grandChild) {
|
7075 | mark(grandChild, false);
|
7076 | });
|
7077 | }
|
7078 | });
|
7079 | }
|
7080 | else if (mutation.type === 'attributes') {
|
7081 | mark(blot.prev);
|
7082 | }
|
7083 | }
|
7084 | mark(blot);
|
7085 | });
|
7086 | this.children.forEach(optimize);
|
7087 | remaining = [].slice.call(this.observer.takeRecords());
|
7088 | records = remaining.slice();
|
7089 | while (records.length > 0)
|
7090 | mutations.push(records.pop());
|
7091 | }
|
7092 | };
|
7093 | ScrollBlot.prototype.update = function (mutations, context) {
|
7094 | var _this = this;
|
7095 | if (context === void 0) { context = {}; }
|
7096 | mutations = mutations || this.observer.takeRecords();
|
7097 |
|
7098 | mutations.map(function (mutation) {
|
7099 | var blot = Registry.find(mutation.target, true);
|
7100 | if (blot == null)
|
7101 | return;
|
7102 | if (blot.domNode[Registry.DATA_KEY].mutations == null) {
|
7103 | blot.domNode[Registry.DATA_KEY].mutations = [mutation];
|
7104 | return blot;
|
7105 | }
|
7106 | else {
|
7107 | blot.domNode[Registry.DATA_KEY].mutations.push(mutation);
|
7108 | return null;
|
7109 | }
|
7110 | }).forEach(function (blot) {
|
7111 | if (blot == null || blot === _this || blot.domNode[Registry.DATA_KEY] == null)
|
7112 | return;
|
7113 | blot.update(blot.domNode[Registry.DATA_KEY].mutations || [], context);
|
7114 | });
|
7115 | if (this.domNode[Registry.DATA_KEY].mutations != null) {
|
7116 | _super.prototype.update.call(this, this.domNode[Registry.DATA_KEY].mutations, context);
|
7117 | }
|
7118 | this.optimize(mutations, context);
|
7119 | };
|
7120 | ScrollBlot.blotName = 'scroll';
|
7121 | ScrollBlot.defaultChild = 'block';
|
7122 | ScrollBlot.scope = Registry.Scope.BLOCK_BLOT;
|
7123 | ScrollBlot.tagName = 'DIV';
|
7124 | return ScrollBlot;
|
7125 | }(container_1.default));
|
7126 | exports.default = ScrollBlot;
|
7127 |
|
7128 |
|
7129 | }),
|
7130 |
|
7131 | (function(module, exports, __webpack_require__) {
|
7132 |
|
7133 | "use strict";
|
7134 |
|
7135 | var __extends = (this && this.__extends) || (function () {
|
7136 | var extendStatics = Object.setPrototypeOf ||
|
7137 | ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
7138 | function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
|
7139 | return function (d, b) {
|
7140 | extendStatics(d, b);
|
7141 | function __() { this.constructor = d; }
|
7142 | d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
7143 | };
|
7144 | })();
|
7145 | Object.defineProperty(exports, "__esModule", { value: true });
|
7146 | var format_1 = __webpack_require__(18);
|
7147 | var Registry = __webpack_require__(1);
|
7148 |
|
7149 | function isEqual(obj1, obj2) {
|
7150 | if (Object.keys(obj1).length !== Object.keys(obj2).length)
|
7151 | return false;
|
7152 | for (var prop in obj1) {
|
7153 | if (obj1[prop] !== obj2[prop])
|
7154 | return false;
|
7155 | }
|
7156 | return true;
|
7157 | }
|
7158 | var InlineBlot = (function (_super) {
|
7159 | __extends(InlineBlot, _super);
|
7160 | function InlineBlot() {
|
7161 | return _super !== null && _super.apply(this, arguments) || this;
|
7162 | }
|
7163 | InlineBlot.formats = function (domNode) {
|
7164 | if (domNode.tagName === InlineBlot.tagName)
|
7165 | return undefined;
|
7166 | return _super.formats.call(this, domNode);
|
7167 | };
|
7168 | InlineBlot.prototype.format = function (name, value) {
|
7169 | var _this = this;
|
7170 | if (name === this.statics.blotName && !value) {
|
7171 | this.children.forEach(function (child) {
|
7172 | if (!(child instanceof format_1.default)) {
|
7173 | child = child.wrap(InlineBlot.blotName, true);
|
7174 | }
|
7175 | _this.attributes.copy(child);
|
7176 | });
|
7177 | this.unwrap();
|
7178 | }
|
7179 | else {
|
7180 | _super.prototype.format.call(this, name, value);
|
7181 | }
|
7182 | };
|
7183 | InlineBlot.prototype.formatAt = function (index, length, name, value) {
|
7184 | if (this.formats()[name] != null || Registry.query(name, Registry.Scope.ATTRIBUTE)) {
|
7185 | var blot = this.isolate(index, length);
|
7186 | blot.format(name, value);
|
7187 | }
|
7188 | else {
|
7189 | _super.prototype.formatAt.call(this, index, length, name, value);
|
7190 | }
|
7191 | };
|
7192 | InlineBlot.prototype.optimize = function (context) {
|
7193 | _super.prototype.optimize.call(this, context);
|
7194 | var formats = this.formats();
|
7195 | if (Object.keys(formats).length === 0) {
|
7196 | return this.unwrap();
|
7197 | }
|
7198 | var next = this.next;
|
7199 | if (next instanceof InlineBlot && next.prev === this && isEqual(formats, next.formats())) {
|
7200 | next.moveChildren(this);
|
7201 | next.remove();
|
7202 | }
|
7203 | };
|
7204 | InlineBlot.blotName = 'inline';
|
7205 | InlineBlot.scope = Registry.Scope.INLINE_BLOT;
|
7206 | InlineBlot.tagName = 'SPAN';
|
7207 | return InlineBlot;
|
7208 | }(format_1.default));
|
7209 | exports.default = InlineBlot;
|
7210 |
|
7211 |
|
7212 | }),
|
7213 |
|
7214 | (function(module, exports, __webpack_require__) {
|
7215 |
|
7216 | "use strict";
|
7217 |
|
7218 | var __extends = (this && this.__extends) || (function () {
|
7219 | var extendStatics = Object.setPrototypeOf ||
|
7220 | ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
7221 | function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
|
7222 | return function (d, b) {
|
7223 | extendStatics(d, b);
|
7224 | function __() { this.constructor = d; }
|
7225 | d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
7226 | };
|
7227 | })();
|
7228 | Object.defineProperty(exports, "__esModule", { value: true });
|
7229 | var format_1 = __webpack_require__(18);
|
7230 | var Registry = __webpack_require__(1);
|
7231 | var BlockBlot = (function (_super) {
|
7232 | __extends(BlockBlot, _super);
|
7233 | function BlockBlot() {
|
7234 | return _super !== null && _super.apply(this, arguments) || this;
|
7235 | }
|
7236 | BlockBlot.formats = function (domNode) {
|
7237 | var tagName = Registry.query(BlockBlot.blotName).tagName;
|
7238 | if (domNode.tagName === tagName)
|
7239 | return undefined;
|
7240 | return _super.formats.call(this, domNode);
|
7241 | };
|
7242 | BlockBlot.prototype.format = function (name, value) {
|
7243 | if (Registry.query(name, Registry.Scope.BLOCK) == null) {
|
7244 | return;
|
7245 | }
|
7246 | else if (name === this.statics.blotName && !value) {
|
7247 | this.replaceWith(BlockBlot.blotName);
|
7248 | }
|
7249 | else {
|
7250 | _super.prototype.format.call(this, name, value);
|
7251 | }
|
7252 | };
|
7253 | BlockBlot.prototype.formatAt = function (index, length, name, value) {
|
7254 | if (Registry.query(name, Registry.Scope.BLOCK) != null) {
|
7255 | this.format(name, value);
|
7256 | }
|
7257 | else {
|
7258 | _super.prototype.formatAt.call(this, index, length, name, value);
|
7259 | }
|
7260 | };
|
7261 | BlockBlot.prototype.insertAt = function (index, value, def) {
|
7262 | if (def == null || Registry.query(value, Registry.Scope.INLINE) != null) {
|
7263 |
|
7264 | _super.prototype.insertAt.call(this, index, value, def);
|
7265 | }
|
7266 | else {
|
7267 | var after = this.split(index);
|
7268 | var blot = Registry.create(value, def);
|
7269 | after.parent.insertBefore(blot, after);
|
7270 | }
|
7271 | };
|
7272 | BlockBlot.prototype.update = function (mutations, context) {
|
7273 | if (navigator.userAgent.match(/Trident/)) {
|
7274 | this.attach();
|
7275 | }
|
7276 | else {
|
7277 | _super.prototype.update.call(this, mutations, context);
|
7278 | }
|
7279 | };
|
7280 | BlockBlot.blotName = 'block';
|
7281 | BlockBlot.scope = Registry.Scope.BLOCK_BLOT;
|
7282 | BlockBlot.tagName = 'P';
|
7283 | return BlockBlot;
|
7284 | }(format_1.default));
|
7285 | exports.default = BlockBlot;
|
7286 |
|
7287 |
|
7288 | }),
|
7289 |
|
7290 | (function(module, exports, __webpack_require__) {
|
7291 |
|
7292 | "use strict";
|
7293 |
|
7294 | var __extends = (this && this.__extends) || (function () {
|
7295 | var extendStatics = Object.setPrototypeOf ||
|
7296 | ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
7297 | function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
|
7298 | return function (d, b) {
|
7299 | extendStatics(d, b);
|
7300 | function __() { this.constructor = d; }
|
7301 | d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
7302 | };
|
7303 | })();
|
7304 | Object.defineProperty(exports, "__esModule", { value: true });
|
7305 | var leaf_1 = __webpack_require__(19);
|
7306 | var EmbedBlot = (function (_super) {
|
7307 | __extends(EmbedBlot, _super);
|
7308 | function EmbedBlot() {
|
7309 | return _super !== null && _super.apply(this, arguments) || this;
|
7310 | }
|
7311 | EmbedBlot.formats = function (domNode) {
|
7312 | return undefined;
|
7313 | };
|
7314 | EmbedBlot.prototype.format = function (name, value) {
|
7315 |
|
7316 |
|
7317 |
|
7318 | _super.prototype.formatAt.call(this, 0, this.length(), name, value);
|
7319 | };
|
7320 | EmbedBlot.prototype.formatAt = function (index, length, name, value) {
|
7321 | if (index === 0 && length === this.length()) {
|
7322 | this.format(name, value);
|
7323 | }
|
7324 | else {
|
7325 | _super.prototype.formatAt.call(this, index, length, name, value);
|
7326 | }
|
7327 | };
|
7328 | EmbedBlot.prototype.formats = function () {
|
7329 | return this.statics.formats(this.domNode);
|
7330 | };
|
7331 | return EmbedBlot;
|
7332 | }(leaf_1.default));
|
7333 | exports.default = EmbedBlot;
|
7334 |
|
7335 |
|
7336 | }),
|
7337 |
|
7338 | (function(module, exports, __webpack_require__) {
|
7339 |
|
7340 | "use strict";
|
7341 |
|
7342 | var __extends = (this && this.__extends) || (function () {
|
7343 | var extendStatics = Object.setPrototypeOf ||
|
7344 | ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
7345 | function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
|
7346 | return function (d, b) {
|
7347 | extendStatics(d, b);
|
7348 | function __() { this.constructor = d; }
|
7349 | d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
7350 | };
|
7351 | })();
|
7352 | Object.defineProperty(exports, "__esModule", { value: true });
|
7353 | var leaf_1 = __webpack_require__(19);
|
7354 | var Registry = __webpack_require__(1);
|
7355 | var TextBlot = (function (_super) {
|
7356 | __extends(TextBlot, _super);
|
7357 | function TextBlot(node) {
|
7358 | var _this = _super.call(this, node) || this;
|
7359 | _this.text = _this.statics.value(_this.domNode);
|
7360 | return _this;
|
7361 | }
|
7362 | TextBlot.create = function (value) {
|
7363 | return document.createTextNode(value);
|
7364 | };
|
7365 | TextBlot.value = function (domNode) {
|
7366 | var text = domNode.data;
|
7367 | if (text["normalize"])
|
7368 | text = text["normalize"]();
|
7369 | return text;
|
7370 | };
|
7371 | TextBlot.prototype.deleteAt = function (index, length) {
|
7372 | this.domNode.data = this.text = this.text.slice(0, index) + this.text.slice(index + length);
|
7373 | };
|
7374 | TextBlot.prototype.index = function (node, offset) {
|
7375 | if (this.domNode === node) {
|
7376 | return offset;
|
7377 | }
|
7378 | return -1;
|
7379 | };
|
7380 | TextBlot.prototype.insertAt = function (index, value, def) {
|
7381 | if (def == null) {
|
7382 | this.text = this.text.slice(0, index) + value + this.text.slice(index);
|
7383 | this.domNode.data = this.text;
|
7384 | }
|
7385 | else {
|
7386 | _super.prototype.insertAt.call(this, index, value, def);
|
7387 | }
|
7388 | };
|
7389 | TextBlot.prototype.length = function () {
|
7390 | return this.text.length;
|
7391 | };
|
7392 | TextBlot.prototype.optimize = function (context) {
|
7393 | _super.prototype.optimize.call(this, context);
|
7394 | this.text = this.statics.value(this.domNode);
|
7395 | if (this.text.length === 0) {
|
7396 | this.remove();
|
7397 | }
|
7398 | else if (this.next instanceof TextBlot && this.next.prev === this) {
|
7399 | this.insertAt(this.length(), this.next.value());
|
7400 | this.next.remove();
|
7401 | }
|
7402 | };
|
7403 | TextBlot.prototype.position = function (index, inclusive) {
|
7404 | if (inclusive === void 0) { inclusive = false; }
|
7405 | return [this.domNode, index];
|
7406 | };
|
7407 | TextBlot.prototype.split = function (index, force) {
|
7408 | if (force === void 0) { force = false; }
|
7409 | if (!force) {
|
7410 | if (index === 0)
|
7411 | return this;
|
7412 | if (index === this.length())
|
7413 | return this.next;
|
7414 | }
|
7415 | var after = Registry.create(this.domNode.splitText(index));
|
7416 | this.parent.insertBefore(after, this.next);
|
7417 | this.text = this.statics.value(this.domNode);
|
7418 | return after;
|
7419 | };
|
7420 | TextBlot.prototype.update = function (mutations, context) {
|
7421 | var _this = this;
|
7422 | if (mutations.some(function (mutation) {
|
7423 | return mutation.type === 'characterData' && mutation.target === _this.domNode;
|
7424 | })) {
|
7425 | this.text = this.statics.value(this.domNode);
|
7426 | }
|
7427 | };
|
7428 | TextBlot.prototype.value = function () {
|
7429 | return this.text;
|
7430 | };
|
7431 | TextBlot.blotName = 'text';
|
7432 | TextBlot.scope = Registry.Scope.INLINE_BLOT;
|
7433 | return TextBlot;
|
7434 | }(leaf_1.default));
|
7435 | exports.default = TextBlot;
|
7436 |
|
7437 |
|
7438 | }),
|
7439 |
|
7440 | (function(module, exports, __webpack_require__) {
|
7441 |
|
7442 | "use strict";
|
7443 |
|
7444 |
|
7445 | var elem = document.createElement('div');
|
7446 | elem.classList.toggle('test-class', false);
|
7447 | if (elem.classList.contains('test-class')) {
|
7448 | var _toggle = DOMTokenList.prototype.toggle;
|
7449 | DOMTokenList.prototype.toggle = function (token, force) {
|
7450 | if (arguments.length > 1 && !this.contains(token) === !force) {
|
7451 | return force;
|
7452 | } else {
|
7453 | return _toggle.call(this, token);
|
7454 | }
|
7455 | };
|
7456 | }
|
7457 |
|
7458 | if (!String.prototype.startsWith) {
|
7459 | String.prototype.startsWith = function (searchString, position) {
|
7460 | position = position || 0;
|
7461 | return this.substr(position, searchString.length) === searchString;
|
7462 | };
|
7463 | }
|
7464 |
|
7465 | if (!String.prototype.endsWith) {
|
7466 | String.prototype.endsWith = function (searchString, position) {
|
7467 | var subjectString = this.toString();
|
7468 | if (typeof position !== 'number' || !isFinite(position) || Math.floor(position) !== position || position > subjectString.length) {
|
7469 | position = subjectString.length;
|
7470 | }
|
7471 | position -= searchString.length;
|
7472 | var lastIndex = subjectString.indexOf(searchString, position);
|
7473 | return lastIndex !== -1 && lastIndex === position;
|
7474 | };
|
7475 | }
|
7476 |
|
7477 | if (!Array.prototype.find) {
|
7478 | Object.defineProperty(Array.prototype, "find", {
|
7479 | value: function value(predicate) {
|
7480 | if (this === null) {
|
7481 | throw new TypeError('Array.prototype.find called on null or undefined');
|
7482 | }
|
7483 | if (typeof predicate !== 'function') {
|
7484 | throw new TypeError('predicate must be a function');
|
7485 | }
|
7486 | var list = Object(this);
|
7487 | var length = list.length >>> 0;
|
7488 | var thisArg = arguments[1];
|
7489 | var value;
|
7490 |
|
7491 | for (var i = 0; i < length; i++) {
|
7492 | value = list[i];
|
7493 | if (predicate.call(thisArg, value, i, list)) {
|
7494 | return value;
|
7495 | }
|
7496 | }
|
7497 | return undefined;
|
7498 | }
|
7499 | });
|
7500 | }
|
7501 |
|
7502 | document.addEventListener("DOMContentLoaded", function () {
|
7503 |
|
7504 | document.execCommand("enableObjectResizing", false, false);
|
7505 |
|
7506 | document.execCommand("autoUrlDetect", false, false);
|
7507 | });
|
7508 |
|
7509 | }),
|
7510 |
|
7511 | (function(module, exports) {
|
7512 |
|
7513 |
|
7514 |
|
7515 |
|
7516 |
|
7517 |
|
7518 |
|
7519 |
|
7520 |
|
7521 |
|
7522 |
|
7523 |
|
7524 |
|
7525 |
|
7526 |
|
7527 |
|
7528 |
|
7529 |
|
7530 |
|
7531 |
|
7532 |
|
7533 |
|
7534 |
|
7535 |
|
7536 |
|
7537 |
|
7538 |
|
7539 |
|
7540 |
|
7541 |
|
7542 |
|
7543 |
|
7544 | var DIFF_DELETE = -1;
|
7545 | var DIFF_INSERT = 1;
|
7546 | var DIFF_EQUAL = 0;
|
7547 |
|
7548 |
|
7549 |
|
7550 |
|
7551 |
|
7552 |
|
7553 |
|
7554 |
|
7555 |
|
7556 |
|
7557 | function diff_main(text1, text2, cursor_pos) {
|
7558 |
|
7559 | if (text1 == text2) {
|
7560 | if (text1) {
|
7561 | return [[DIFF_EQUAL, text1]];
|
7562 | }
|
7563 | return [];
|
7564 | }
|
7565 |
|
7566 |
|
7567 | if (cursor_pos < 0 || text1.length < cursor_pos) {
|
7568 | cursor_pos = null;
|
7569 | }
|
7570 |
|
7571 |
|
7572 | var commonlength = diff_commonPrefix(text1, text2);
|
7573 | var commonprefix = text1.substring(0, commonlength);
|
7574 | text1 = text1.substring(commonlength);
|
7575 | text2 = text2.substring(commonlength);
|
7576 |
|
7577 |
|
7578 | commonlength = diff_commonSuffix(text1, text2);
|
7579 | var commonsuffix = text1.substring(text1.length - commonlength);
|
7580 | text1 = text1.substring(0, text1.length - commonlength);
|
7581 | text2 = text2.substring(0, text2.length - commonlength);
|
7582 |
|
7583 |
|
7584 | var diffs = diff_compute_(text1, text2);
|
7585 |
|
7586 |
|
7587 | if (commonprefix) {
|
7588 | diffs.unshift([DIFF_EQUAL, commonprefix]);
|
7589 | }
|
7590 | if (commonsuffix) {
|
7591 | diffs.push([DIFF_EQUAL, commonsuffix]);
|
7592 | }
|
7593 | diff_cleanupMerge(diffs);
|
7594 | if (cursor_pos != null) {
|
7595 | diffs = fix_cursor(diffs, cursor_pos);
|
7596 | }
|
7597 | return diffs;
|
7598 | };
|
7599 |
|
7600 |
|
7601 |
|
7602 |
|
7603 |
|
7604 |
|
7605 |
|
7606 |
|
7607 |
|
7608 | function diff_compute_(text1, text2) {
|
7609 | var diffs;
|
7610 |
|
7611 | if (!text1) {
|
7612 |
|
7613 | return [[DIFF_INSERT, text2]];
|
7614 | }
|
7615 |
|
7616 | if (!text2) {
|
7617 |
|
7618 | return [[DIFF_DELETE, text1]];
|
7619 | }
|
7620 |
|
7621 | var longtext = text1.length > text2.length ? text1 : text2;
|
7622 | var shorttext = text1.length > text2.length ? text2 : text1;
|
7623 | var i = longtext.indexOf(shorttext);
|
7624 | if (i != -1) {
|
7625 |
|
7626 | diffs = [[DIFF_INSERT, longtext.substring(0, i)],
|
7627 | [DIFF_EQUAL, shorttext],
|
7628 | [DIFF_INSERT, longtext.substring(i + shorttext.length)]];
|
7629 |
|
7630 | if (text1.length > text2.length) {
|
7631 | diffs[0][0] = diffs[2][0] = DIFF_DELETE;
|
7632 | }
|
7633 | return diffs;
|
7634 | }
|
7635 |
|
7636 | if (shorttext.length == 1) {
|
7637 |
|
7638 |
|
7639 | return [[DIFF_DELETE, text1], [DIFF_INSERT, text2]];
|
7640 | }
|
7641 |
|
7642 |
|
7643 | var hm = diff_halfMatch_(text1, text2);
|
7644 | if (hm) {
|
7645 |
|
7646 | var text1_a = hm[0];
|
7647 | var text1_b = hm[1];
|
7648 | var text2_a = hm[2];
|
7649 | var text2_b = hm[3];
|
7650 | var mid_common = hm[4];
|
7651 |
|
7652 | var diffs_a = diff_main(text1_a, text2_a);
|
7653 | var diffs_b = diff_main(text1_b, text2_b);
|
7654 |
|
7655 | return diffs_a.concat([[DIFF_EQUAL, mid_common]], diffs_b);
|
7656 | }
|
7657 |
|
7658 | return diff_bisect_(text1, text2);
|
7659 | };
|
7660 |
|
7661 |
|
7662 |
|
7663 |
|
7664 |
|
7665 |
|
7666 |
|
7667 |
|
7668 |
|
7669 |
|
7670 |
|
7671 | function diff_bisect_(text1, text2) {
|
7672 |
|
7673 | var text1_length = text1.length;
|
7674 | var text2_length = text2.length;
|
7675 | var max_d = Math.ceil((text1_length + text2_length) / 2);
|
7676 | var v_offset = max_d;
|
7677 | var v_length = 2 * max_d;
|
7678 | var v1 = new Array(v_length);
|
7679 | var v2 = new Array(v_length);
|
7680 |
|
7681 |
|
7682 | for (var x = 0; x < v_length; x++) {
|
7683 | v1[x] = -1;
|
7684 | v2[x] = -1;
|
7685 | }
|
7686 | v1[v_offset + 1] = 0;
|
7687 | v2[v_offset + 1] = 0;
|
7688 | var delta = text1_length - text2_length;
|
7689 |
|
7690 |
|
7691 | var front = (delta % 2 != 0);
|
7692 |
|
7693 |
|
7694 | var k1start = 0;
|
7695 | var k1end = 0;
|
7696 | var k2start = 0;
|
7697 | var k2end = 0;
|
7698 | for (var d = 0; d < max_d; d++) {
|
7699 |
|
7700 | for (var k1 = -d + k1start; k1 <= d - k1end; k1 += 2) {
|
7701 | var k1_offset = v_offset + k1;
|
7702 | var x1;
|
7703 | if (k1 == -d || (k1 != d && v1[k1_offset - 1] < v1[k1_offset + 1])) {
|
7704 | x1 = v1[k1_offset + 1];
|
7705 | } else {
|
7706 | x1 = v1[k1_offset - 1] + 1;
|
7707 | }
|
7708 | var y1 = x1 - k1;
|
7709 | while (x1 < text1_length && y1 < text2_length &&
|
7710 | text1.charAt(x1) == text2.charAt(y1)) {
|
7711 | x1++;
|
7712 | y1++;
|
7713 | }
|
7714 | v1[k1_offset] = x1;
|
7715 | if (x1 > text1_length) {
|
7716 |
|
7717 | k1end += 2;
|
7718 | } else if (y1 > text2_length) {
|
7719 |
|
7720 | k1start += 2;
|
7721 | } else if (front) {
|
7722 | var k2_offset = v_offset + delta - k1;
|
7723 | if (k2_offset >= 0 && k2_offset < v_length && v2[k2_offset] != -1) {
|
7724 |
|
7725 | var x2 = text1_length - v2[k2_offset];
|
7726 | if (x1 >= x2) {
|
7727 |
|
7728 | return diff_bisectSplit_(text1, text2, x1, y1);
|
7729 | }
|
7730 | }
|
7731 | }
|
7732 | }
|
7733 |
|
7734 |
|
7735 | for (var k2 = -d + k2start; k2 <= d - k2end; k2 += 2) {
|
7736 | var k2_offset = v_offset + k2;
|
7737 | var x2;
|
7738 | if (k2 == -d || (k2 != d && v2[k2_offset - 1] < v2[k2_offset + 1])) {
|
7739 | x2 = v2[k2_offset + 1];
|
7740 | } else {
|
7741 | x2 = v2[k2_offset - 1] + 1;
|
7742 | }
|
7743 | var y2 = x2 - k2;
|
7744 | while (x2 < text1_length && y2 < text2_length &&
|
7745 | text1.charAt(text1_length - x2 - 1) ==
|
7746 | text2.charAt(text2_length - y2 - 1)) {
|
7747 | x2++;
|
7748 | y2++;
|
7749 | }
|
7750 | v2[k2_offset] = x2;
|
7751 | if (x2 > text1_length) {
|
7752 |
|
7753 | k2end += 2;
|
7754 | } else if (y2 > text2_length) {
|
7755 |
|
7756 | k2start += 2;
|
7757 | } else if (!front) {
|
7758 | var k1_offset = v_offset + delta - k2;
|
7759 | if (k1_offset >= 0 && k1_offset < v_length && v1[k1_offset] != -1) {
|
7760 | var x1 = v1[k1_offset];
|
7761 | var y1 = v_offset + x1 - k1_offset;
|
7762 |
|
7763 | x2 = text1_length - x2;
|
7764 | if (x1 >= x2) {
|
7765 |
|
7766 | return diff_bisectSplit_(text1, text2, x1, y1);
|
7767 | }
|
7768 | }
|
7769 | }
|
7770 | }
|
7771 | }
|
7772 |
|
7773 |
|
7774 | return [[DIFF_DELETE, text1], [DIFF_INSERT, text2]];
|
7775 | };
|
7776 |
|
7777 |
|
7778 |
|
7779 |
|
7780 |
|
7781 |
|
7782 |
|
7783 |
|
7784 |
|
7785 |
|
7786 |
|
7787 | function diff_bisectSplit_(text1, text2, x, y) {
|
7788 | var text1a = text1.substring(0, x);
|
7789 | var text2a = text2.substring(0, y);
|
7790 | var text1b = text1.substring(x);
|
7791 | var text2b = text2.substring(y);
|
7792 |
|
7793 |
|
7794 | var diffs = diff_main(text1a, text2a);
|
7795 | var diffsb = diff_main(text1b, text2b);
|
7796 |
|
7797 | return diffs.concat(diffsb);
|
7798 | };
|
7799 |
|
7800 |
|
7801 |
|
7802 |
|
7803 |
|
7804 |
|
7805 |
|
7806 |
|
7807 |
|
7808 | function diff_commonPrefix(text1, text2) {
|
7809 |
|
7810 | if (!text1 || !text2 || text1.charAt(0) != text2.charAt(0)) {
|
7811 | return 0;
|
7812 | }
|
7813 |
|
7814 |
|
7815 | var pointermin = 0;
|
7816 | var pointermax = Math.min(text1.length, text2.length);
|
7817 | var pointermid = pointermax;
|
7818 | var pointerstart = 0;
|
7819 | while (pointermin < pointermid) {
|
7820 | if (text1.substring(pointerstart, pointermid) ==
|
7821 | text2.substring(pointerstart, pointermid)) {
|
7822 | pointermin = pointermid;
|
7823 | pointerstart = pointermin;
|
7824 | } else {
|
7825 | pointermax = pointermid;
|
7826 | }
|
7827 | pointermid = Math.floor((pointermax - pointermin) / 2 + pointermin);
|
7828 | }
|
7829 | return pointermid;
|
7830 | };
|
7831 |
|
7832 |
|
7833 |
|
7834 |
|
7835 |
|
7836 |
|
7837 |
|
7838 |
|
7839 | function diff_commonSuffix(text1, text2) {
|
7840 |
|
7841 | if (!text1 || !text2 ||
|
7842 | text1.charAt(text1.length - 1) != text2.charAt(text2.length - 1)) {
|
7843 | return 0;
|
7844 | }
|
7845 |
|
7846 |
|
7847 | var pointermin = 0;
|
7848 | var pointermax = Math.min(text1.length, text2.length);
|
7849 | var pointermid = pointermax;
|
7850 | var pointerend = 0;
|
7851 | while (pointermin < pointermid) {
|
7852 | if (text1.substring(text1.length - pointermid, text1.length - pointerend) ==
|
7853 | text2.substring(text2.length - pointermid, text2.length - pointerend)) {
|
7854 | pointermin = pointermid;
|
7855 | pointerend = pointermin;
|
7856 | } else {
|
7857 | pointermax = pointermid;
|
7858 | }
|
7859 | pointermid = Math.floor((pointermax - pointermin) / 2 + pointermin);
|
7860 | }
|
7861 | return pointermid;
|
7862 | };
|
7863 |
|
7864 |
|
7865 |
|
7866 |
|
7867 |
|
7868 |
|
7869 |
|
7870 |
|
7871 |
|
7872 |
|
7873 |
|
7874 |
|
7875 | function diff_halfMatch_(text1, text2) {
|
7876 | var longtext = text1.length > text2.length ? text1 : text2;
|
7877 | var shorttext = text1.length > text2.length ? text2 : text1;
|
7878 | if (longtext.length < 4 || shorttext.length * 2 < longtext.length) {
|
7879 | return null;
|
7880 | }
|
7881 |
|
7882 | |
7883 |
|
7884 |
|
7885 |
|
7886 |
|
7887 |
|
7888 |
|
7889 |
|
7890 |
|
7891 |
|
7892 |
|
7893 |
|
7894 | function diff_halfMatchI_(longtext, shorttext, i) {
|
7895 |
|
7896 | var seed = longtext.substring(i, i + Math.floor(longtext.length / 4));
|
7897 | var j = -1;
|
7898 | var best_common = '';
|
7899 | var best_longtext_a, best_longtext_b, best_shorttext_a, best_shorttext_b;
|
7900 | while ((j = shorttext.indexOf(seed, j + 1)) != -1) {
|
7901 | var prefixLength = diff_commonPrefix(longtext.substring(i),
|
7902 | shorttext.substring(j));
|
7903 | var suffixLength = diff_commonSuffix(longtext.substring(0, i),
|
7904 | shorttext.substring(0, j));
|
7905 | if (best_common.length < suffixLength + prefixLength) {
|
7906 | best_common = shorttext.substring(j - suffixLength, j) +
|
7907 | shorttext.substring(j, j + prefixLength);
|
7908 | best_longtext_a = longtext.substring(0, i - suffixLength);
|
7909 | best_longtext_b = longtext.substring(i + prefixLength);
|
7910 | best_shorttext_a = shorttext.substring(0, j - suffixLength);
|
7911 | best_shorttext_b = shorttext.substring(j + prefixLength);
|
7912 | }
|
7913 | }
|
7914 | if (best_common.length * 2 >= longtext.length) {
|
7915 | return [best_longtext_a, best_longtext_b,
|
7916 | best_shorttext_a, best_shorttext_b, best_common];
|
7917 | } else {
|
7918 | return null;
|
7919 | }
|
7920 | }
|
7921 |
|
7922 |
|
7923 | var hm1 = diff_halfMatchI_(longtext, shorttext,
|
7924 | Math.ceil(longtext.length / 4));
|
7925 |
|
7926 | var hm2 = diff_halfMatchI_(longtext, shorttext,
|
7927 | Math.ceil(longtext.length / 2));
|
7928 | var hm;
|
7929 | if (!hm1 && !hm2) {
|
7930 | return null;
|
7931 | } else if (!hm2) {
|
7932 | hm = hm1;
|
7933 | } else if (!hm1) {
|
7934 | hm = hm2;
|
7935 | } else {
|
7936 |
|
7937 | hm = hm1[4].length > hm2[4].length ? hm1 : hm2;
|
7938 | }
|
7939 |
|
7940 |
|
7941 | var text1_a, text1_b, text2_a, text2_b;
|
7942 | if (text1.length > text2.length) {
|
7943 | text1_a = hm[0];
|
7944 | text1_b = hm[1];
|
7945 | text2_a = hm[2];
|
7946 | text2_b = hm[3];
|
7947 | } else {
|
7948 | text2_a = hm[0];
|
7949 | text2_b = hm[1];
|
7950 | text1_a = hm[2];
|
7951 | text1_b = hm[3];
|
7952 | }
|
7953 | var mid_common = hm[4];
|
7954 | return [text1_a, text1_b, text2_a, text2_b, mid_common];
|
7955 | };
|
7956 |
|
7957 |
|
7958 |
|
7959 |
|
7960 |
|
7961 |
|
7962 |
|
7963 | function diff_cleanupMerge(diffs) {
|
7964 | diffs.push([DIFF_EQUAL, '']);
|
7965 | var pointer = 0;
|
7966 | var count_delete = 0;
|
7967 | var count_insert = 0;
|
7968 | var text_delete = '';
|
7969 | var text_insert = '';
|
7970 | var commonlength;
|
7971 | while (pointer < diffs.length) {
|
7972 | switch (diffs[pointer][0]) {
|
7973 | case DIFF_INSERT:
|
7974 | count_insert++;
|
7975 | text_insert += diffs[pointer][1];
|
7976 | pointer++;
|
7977 | break;
|
7978 | case DIFF_DELETE:
|
7979 | count_delete++;
|
7980 | text_delete += diffs[pointer][1];
|
7981 | pointer++;
|
7982 | break;
|
7983 | case DIFF_EQUAL:
|
7984 |
|
7985 | if (count_delete + count_insert > 1) {
|
7986 | if (count_delete !== 0 && count_insert !== 0) {
|
7987 |
|
7988 | commonlength = diff_commonPrefix(text_insert, text_delete);
|
7989 | if (commonlength !== 0) {
|
7990 | if ((pointer - count_delete - count_insert) > 0 &&
|
7991 | diffs[pointer - count_delete - count_insert - 1][0] ==
|
7992 | DIFF_EQUAL) {
|
7993 | diffs[pointer - count_delete - count_insert - 1][1] +=
|
7994 | text_insert.substring(0, commonlength);
|
7995 | } else {
|
7996 | diffs.splice(0, 0, [DIFF_EQUAL,
|
7997 | text_insert.substring(0, commonlength)]);
|
7998 | pointer++;
|
7999 | }
|
8000 | text_insert = text_insert.substring(commonlength);
|
8001 | text_delete = text_delete.substring(commonlength);
|
8002 | }
|
8003 |
|
8004 | commonlength = diff_commonSuffix(text_insert, text_delete);
|
8005 | if (commonlength !== 0) {
|
8006 | diffs[pointer][1] = text_insert.substring(text_insert.length -
|
8007 | commonlength) + diffs[pointer][1];
|
8008 | text_insert = text_insert.substring(0, text_insert.length -
|
8009 | commonlength);
|
8010 | text_delete = text_delete.substring(0, text_delete.length -
|
8011 | commonlength);
|
8012 | }
|
8013 | }
|
8014 |
|
8015 | if (count_delete === 0) {
|
8016 | diffs.splice(pointer - count_insert,
|
8017 | count_delete + count_insert, [DIFF_INSERT, text_insert]);
|
8018 | } else if (count_insert === 0) {
|
8019 | diffs.splice(pointer - count_delete,
|
8020 | count_delete + count_insert, [DIFF_DELETE, text_delete]);
|
8021 | } else {
|
8022 | diffs.splice(pointer - count_delete - count_insert,
|
8023 | count_delete + count_insert, [DIFF_DELETE, text_delete],
|
8024 | [DIFF_INSERT, text_insert]);
|
8025 | }
|
8026 | pointer = pointer - count_delete - count_insert +
|
8027 | (count_delete ? 1 : 0) + (count_insert ? 1 : 0) + 1;
|
8028 | } else if (pointer !== 0 && diffs[pointer - 1][0] == DIFF_EQUAL) {
|
8029 |
|
8030 | diffs[pointer - 1][1] += diffs[pointer][1];
|
8031 | diffs.splice(pointer, 1);
|
8032 | } else {
|
8033 | pointer++;
|
8034 | }
|
8035 | count_insert = 0;
|
8036 | count_delete = 0;
|
8037 | text_delete = '';
|
8038 | text_insert = '';
|
8039 | break;
|
8040 | }
|
8041 | }
|
8042 | if (diffs[diffs.length - 1][1] === '') {
|
8043 | diffs.pop();
|
8044 | }
|
8045 |
|
8046 |
|
8047 |
|
8048 |
|
8049 | var changes = false;
|
8050 | pointer = 1;
|
8051 |
|
8052 | while (pointer < diffs.length - 1) {
|
8053 | if (diffs[pointer - 1][0] == DIFF_EQUAL &&
|
8054 | diffs[pointer + 1][0] == DIFF_EQUAL) {
|
8055 |
|
8056 | if (diffs[pointer][1].substring(diffs[pointer][1].length -
|
8057 | diffs[pointer - 1][1].length) == diffs[pointer - 1][1]) {
|
8058 |
|
8059 | diffs[pointer][1] = diffs[pointer - 1][1] +
|
8060 | diffs[pointer][1].substring(0, diffs[pointer][1].length -
|
8061 | diffs[pointer - 1][1].length);
|
8062 | diffs[pointer + 1][1] = diffs[pointer - 1][1] + diffs[pointer + 1][1];
|
8063 | diffs.splice(pointer - 1, 1);
|
8064 | changes = true;
|
8065 | } else if (diffs[pointer][1].substring(0, diffs[pointer + 1][1].length) ==
|
8066 | diffs[pointer + 1][1]) {
|
8067 |
|
8068 | diffs[pointer - 1][1] += diffs[pointer + 1][1];
|
8069 | diffs[pointer][1] =
|
8070 | diffs[pointer][1].substring(diffs[pointer + 1][1].length) +
|
8071 | diffs[pointer + 1][1];
|
8072 | diffs.splice(pointer + 1, 1);
|
8073 | changes = true;
|
8074 | }
|
8075 | }
|
8076 | pointer++;
|
8077 | }
|
8078 |
|
8079 | if (changes) {
|
8080 | diff_cleanupMerge(diffs);
|
8081 | }
|
8082 | };
|
8083 |
|
8084 |
|
8085 | var diff = diff_main;
|
8086 | diff.INSERT = DIFF_INSERT;
|
8087 | diff.DELETE = DIFF_DELETE;
|
8088 | diff.EQUAL = DIFF_EQUAL;
|
8089 |
|
8090 | module.exports = diff;
|
8091 |
|
8092 |
|
8093 |
|
8094 |
|
8095 |
|
8096 |
|
8097 |
|
8098 |
|
8099 |
|
8100 |
|
8101 |
|
8102 |
|
8103 |
|
8104 | function cursor_normalize_diff (diffs, cursor_pos) {
|
8105 | if (cursor_pos === 0) {
|
8106 | return [DIFF_EQUAL, diffs];
|
8107 | }
|
8108 | for (var current_pos = 0, i = 0; i < diffs.length; i++) {
|
8109 | var d = diffs[i];
|
8110 | if (d[0] === DIFF_DELETE || d[0] === DIFF_EQUAL) {
|
8111 | var next_pos = current_pos + d[1].length;
|
8112 | if (cursor_pos === next_pos) {
|
8113 | return [i + 1, diffs];
|
8114 | } else if (cursor_pos < next_pos) {
|
8115 |
|
8116 | diffs = diffs.slice();
|
8117 |
|
8118 | var split_pos = cursor_pos - current_pos;
|
8119 | var d_left = [d[0], d[1].slice(0, split_pos)];
|
8120 | var d_right = [d[0], d[1].slice(split_pos)];
|
8121 | diffs.splice(i, 1, d_left, d_right);
|
8122 | return [i + 1, diffs];
|
8123 | } else {
|
8124 | current_pos = next_pos;
|
8125 | }
|
8126 | }
|
8127 | }
|
8128 | throw new Error('cursor_pos is out of bounds!')
|
8129 | }
|
8130 |
|
8131 |
|
8132 |
|
8133 |
|
8134 |
|
8135 |
|
8136 |
|
8137 |
|
8138 |
|
8139 |
|
8140 |
|
8141 |
|
8142 |
|
8143 |
|
8144 |
|
8145 |
|
8146 |
|
8147 |
|
8148 |
|
8149 | function fix_cursor (diffs, cursor_pos) {
|
8150 | var norm = cursor_normalize_diff(diffs, cursor_pos);
|
8151 | var ndiffs = norm[1];
|
8152 | var cursor_pointer = norm[0];
|
8153 | var d = ndiffs[cursor_pointer];
|
8154 | var d_next = ndiffs[cursor_pointer + 1];
|
8155 |
|
8156 | if (d == null) {
|
8157 |
|
8158 |
|
8159 | return diffs;
|
8160 | } else if (d[0] !== DIFF_EQUAL) {
|
8161 |
|
8162 |
|
8163 | return diffs;
|
8164 | } else {
|
8165 | if (d_next != null && d[1] + d_next[1] === d_next[1] + d[1]) {
|
8166 |
|
8167 |
|
8168 | ndiffs.splice(cursor_pointer, 2, d_next, d)
|
8169 | return merge_tuples(ndiffs, cursor_pointer, 2)
|
8170 | } else if (d_next != null && d_next[1].indexOf(d[1]) === 0) {
|
8171 |
|
8172 |
|
8173 |
|
8174 |
|
8175 | ndiffs.splice(cursor_pointer, 2, [d_next[0], d[1]], [0, d[1]]);
|
8176 | var suffix = d_next[1].slice(d[1].length);
|
8177 | if (suffix.length > 0) {
|
8178 | ndiffs.splice(cursor_pointer + 2, 0, [d_next[0], suffix]);
|
8179 | }
|
8180 | return merge_tuples(ndiffs, cursor_pointer, 3)
|
8181 | } else {
|
8182 |
|
8183 | return diffs;
|
8184 | }
|
8185 | }
|
8186 |
|
8187 | }
|
8188 |
|
8189 |
|
8190 |
|
8191 |
|
8192 |
|
8193 |
|
8194 |
|
8195 |
|
8196 |
|
8197 |
|
8198 | function merge_tuples (diffs, start, length) {
|
8199 |
|
8200 | for (var i = start + length - 1; i >= 0 && i >= start - 1; i--) {
|
8201 | if (i + 1 < diffs.length) {
|
8202 | var left_d = diffs[i];
|
8203 | var right_d = diffs[i+1];
|
8204 | if (left_d[0] === right_d[1]) {
|
8205 | diffs.splice(i, 2, [left_d[0], left_d[1] + right_d[1]]);
|
8206 | }
|
8207 | }
|
8208 | }
|
8209 | return diffs;
|
8210 | }
|
8211 |
|
8212 |
|
8213 | }),
|
8214 |
|
8215 | (function(module, exports) {
|
8216 |
|
8217 | exports = module.exports = typeof Object.keys === 'function'
|
8218 | ? Object.keys : shim;
|
8219 |
|
8220 | exports.shim = shim;
|
8221 | function shim (obj) {
|
8222 | var keys = [];
|
8223 | for (var key in obj) keys.push(key);
|
8224 | return keys;
|
8225 | }
|
8226 |
|
8227 |
|
8228 | }),
|
8229 |
|
8230 | (function(module, exports) {
|
8231 |
|
8232 | var supportsArgumentsClass = (function(){
|
8233 | return Object.prototype.toString.call(arguments)
|
8234 | })() == '[object Arguments]';
|
8235 |
|
8236 | exports = module.exports = supportsArgumentsClass ? supported : unsupported;
|
8237 |
|
8238 | exports.supported = supported;
|
8239 | function supported(object) {
|
8240 | return Object.prototype.toString.call(object) == '[object Arguments]';
|
8241 | };
|
8242 |
|
8243 | exports.unsupported = unsupported;
|
8244 | function unsupported(object){
|
8245 | return object &&
|
8246 | typeof object == 'object' &&
|
8247 | typeof object.length == 'number' &&
|
8248 | Object.prototype.hasOwnProperty.call(object, 'callee') &&
|
8249 | !Object.prototype.propertyIsEnumerable.call(object, 'callee') ||
|
8250 | false;
|
8251 | };
|
8252 |
|
8253 |
|
8254 | }),
|
8255 |
|
8256 | (function(module, exports) {
|
8257 |
|
8258 | 'use strict';
|
8259 |
|
8260 | var has = Object.prototype.hasOwnProperty
|
8261 | , prefix = '~';
|
8262 |
|
8263 |
|
8264 |
|
8265 |
|
8266 |
|
8267 |
|
8268 |
|
8269 |
|
8270 | function Events() {}
|
8271 |
|
8272 |
|
8273 |
|
8274 |
|
8275 |
|
8276 |
|
8277 |
|
8278 |
|
8279 | if (Object.create) {
|
8280 | Events.prototype = Object.create(null);
|
8281 |
|
8282 |
|
8283 |
|
8284 |
|
8285 |
|
8286 | if (!new Events().__proto__) prefix = false;
|
8287 | }
|
8288 |
|
8289 |
|
8290 |
|
8291 |
|
8292 |
|
8293 |
|
8294 |
|
8295 |
|
8296 |
|
8297 |
|
8298 | function EE(fn, context, once) {
|
8299 | this.fn = fn;
|
8300 | this.context = context;
|
8301 | this.once = once || false;
|
8302 | }
|
8303 |
|
8304 |
|
8305 |
|
8306 |
|
8307 |
|
8308 |
|
8309 |
|
8310 |
|
8311 | function EventEmitter() {
|
8312 | this._events = new Events();
|
8313 | this._eventsCount = 0;
|
8314 | }
|
8315 |
|
8316 |
|
8317 |
|
8318 |
|
8319 |
|
8320 |
|
8321 |
|
8322 |
|
8323 | EventEmitter.prototype.eventNames = function eventNames() {
|
8324 | var names = []
|
8325 | , events
|
8326 | , name;
|
8327 |
|
8328 | if (this._eventsCount === 0) return names;
|
8329 |
|
8330 | for (name in (events = this._events)) {
|
8331 | if (has.call(events, name)) names.push(prefix ? name.slice(1) : name);
|
8332 | }
|
8333 |
|
8334 | if (Object.getOwnPropertySymbols) {
|
8335 | return names.concat(Object.getOwnPropertySymbols(events));
|
8336 | }
|
8337 |
|
8338 | return names;
|
8339 | };
|
8340 |
|
8341 |
|
8342 |
|
8343 |
|
8344 |
|
8345 |
|
8346 |
|
8347 |
|
8348 |
|
8349 | EventEmitter.prototype.listeners = function listeners(event, exists) {
|
8350 | var evt = prefix ? prefix + event : event
|
8351 | , available = this._events[evt];
|
8352 |
|
8353 | if (exists) return !!available;
|
8354 | if (!available) return [];
|
8355 | if (available.fn) return [available.fn];
|
8356 |
|
8357 | for (var i = 0, l = available.length, ee = new Array(l); i < l; i++) {
|
8358 | ee[i] = available[i].fn;
|
8359 | }
|
8360 |
|
8361 | return ee;
|
8362 | };
|
8363 |
|
8364 |
|
8365 |
|
8366 |
|
8367 |
|
8368 |
|
8369 |
|
8370 |
|
8371 | EventEmitter.prototype.emit = function emit(event, a1, a2, a3, a4, a5) {
|
8372 | var evt = prefix ? prefix + event : event;
|
8373 |
|
8374 | if (!this._events[evt]) return false;
|
8375 |
|
8376 | var listeners = this._events[evt]
|
8377 | , len = arguments.length
|
8378 | , args
|
8379 | , i;
|
8380 |
|
8381 | if (listeners.fn) {
|
8382 | if (listeners.once) this.removeListener(event, listeners.fn, undefined, true);
|
8383 |
|
8384 | switch (len) {
|
8385 | case 1: return listeners.fn.call(listeners.context), true;
|
8386 | case 2: return listeners.fn.call(listeners.context, a1), true;
|
8387 | case 3: return listeners.fn.call(listeners.context, a1, a2), true;
|
8388 | case 4: return listeners.fn.call(listeners.context, a1, a2, a3), true;
|
8389 | case 5: return listeners.fn.call(listeners.context, a1, a2, a3, a4), true;
|
8390 | case 6: return listeners.fn.call(listeners.context, a1, a2, a3, a4, a5), true;
|
8391 | }
|
8392 |
|
8393 | for (i = 1, args = new Array(len -1); i < len; i++) {
|
8394 | args[i - 1] = arguments[i];
|
8395 | }
|
8396 |
|
8397 | listeners.fn.apply(listeners.context, args);
|
8398 | } else {
|
8399 | var length = listeners.length
|
8400 | , j;
|
8401 |
|
8402 | for (i = 0; i < length; i++) {
|
8403 | if (listeners[i].once) this.removeListener(event, listeners[i].fn, undefined, true);
|
8404 |
|
8405 | switch (len) {
|
8406 | case 1: listeners[i].fn.call(listeners[i].context); break;
|
8407 | case 2: listeners[i].fn.call(listeners[i].context, a1); break;
|
8408 | case 3: listeners[i].fn.call(listeners[i].context, a1, a2); break;
|
8409 | case 4: listeners[i].fn.call(listeners[i].context, a1, a2, a3); break;
|
8410 | default:
|
8411 | if (!args) for (j = 1, args = new Array(len -1); j < len; j++) {
|
8412 | args[j - 1] = arguments[j];
|
8413 | }
|
8414 |
|
8415 | listeners[i].fn.apply(listeners[i].context, args);
|
8416 | }
|
8417 | }
|
8418 | }
|
8419 |
|
8420 | return true;
|
8421 | };
|
8422 |
|
8423 |
|
8424 |
|
8425 |
|
8426 |
|
8427 |
|
8428 |
|
8429 |
|
8430 |
|
8431 |
|
8432 | EventEmitter.prototype.on = function on(event, fn, context) {
|
8433 | var listener = new EE(fn, context || this)
|
8434 | , evt = prefix ? prefix + event : event;
|
8435 |
|
8436 | if (!this._events[evt]) this._events[evt] = listener, this._eventsCount++;
|
8437 | else if (!this._events[evt].fn) this._events[evt].push(listener);
|
8438 | else this._events[evt] = [this._events[evt], listener];
|
8439 |
|
8440 | return this;
|
8441 | };
|
8442 |
|
8443 |
|
8444 |
|
8445 |
|
8446 |
|
8447 |
|
8448 |
|
8449 |
|
8450 |
|
8451 |
|
8452 | EventEmitter.prototype.once = function once(event, fn, context) {
|
8453 | var listener = new EE(fn, context || this, true)
|
8454 | , evt = prefix ? prefix + event : event;
|
8455 |
|
8456 | if (!this._events[evt]) this._events[evt] = listener, this._eventsCount++;
|
8457 | else if (!this._events[evt].fn) this._events[evt].push(listener);
|
8458 | else this._events[evt] = [this._events[evt], listener];
|
8459 |
|
8460 | return this;
|
8461 | };
|
8462 |
|
8463 |
|
8464 |
|
8465 |
|
8466 |
|
8467 |
|
8468 |
|
8469 |
|
8470 |
|
8471 |
|
8472 |
|
8473 | EventEmitter.prototype.removeListener = function removeListener(event, fn, context, once) {
|
8474 | var evt = prefix ? prefix + event : event;
|
8475 |
|
8476 | if (!this._events[evt]) return this;
|
8477 | if (!fn) {
|
8478 | if (--this._eventsCount === 0) this._events = new Events();
|
8479 | else delete this._events[evt];
|
8480 | return this;
|
8481 | }
|
8482 |
|
8483 | var listeners = this._events[evt];
|
8484 |
|
8485 | if (listeners.fn) {
|
8486 | if (
|
8487 | listeners.fn === fn
|
8488 | && (!once || listeners.once)
|
8489 | && (!context || listeners.context === context)
|
8490 | ) {
|
8491 | if (--this._eventsCount === 0) this._events = new Events();
|
8492 | else delete this._events[evt];
|
8493 | }
|
8494 | } else {
|
8495 | for (var i = 0, events = [], length = listeners.length; i < length; i++) {
|
8496 | if (
|
8497 | listeners[i].fn !== fn
|
8498 | || (once && !listeners[i].once)
|
8499 | || (context && listeners[i].context !== context)
|
8500 | ) {
|
8501 | events.push(listeners[i]);
|
8502 | }
|
8503 | }
|
8504 |
|
8505 |
|
8506 |
|
8507 |
|
8508 | if (events.length) this._events[evt] = events.length === 1 ? events[0] : events;
|
8509 | else if (--this._eventsCount === 0) this._events = new Events();
|
8510 | else delete this._events[evt];
|
8511 | }
|
8512 |
|
8513 | return this;
|
8514 | };
|
8515 |
|
8516 |
|
8517 |
|
8518 |
|
8519 |
|
8520 |
|
8521 |
|
8522 |
|
8523 | EventEmitter.prototype.removeAllListeners = function removeAllListeners(event) {
|
8524 | var evt;
|
8525 |
|
8526 | if (event) {
|
8527 | evt = prefix ? prefix + event : event;
|
8528 | if (this._events[evt]) {
|
8529 | if (--this._eventsCount === 0) this._events = new Events();
|
8530 | else delete this._events[evt];
|
8531 | }
|
8532 | } else {
|
8533 | this._events = new Events();
|
8534 | this._eventsCount = 0;
|
8535 | }
|
8536 |
|
8537 | return this;
|
8538 | };
|
8539 |
|
8540 |
|
8541 |
|
8542 |
|
8543 | EventEmitter.prototype.off = EventEmitter.prototype.removeListener;
|
8544 | EventEmitter.prototype.addListener = EventEmitter.prototype.on;
|
8545 |
|
8546 |
|
8547 |
|
8548 |
|
8549 | EventEmitter.prototype.setMaxListeners = function setMaxListeners() {
|
8550 | return this;
|
8551 | };
|
8552 |
|
8553 |
|
8554 |
|
8555 |
|
8556 | EventEmitter.prefixed = prefix;
|
8557 |
|
8558 |
|
8559 |
|
8560 |
|
8561 | EventEmitter.EventEmitter = EventEmitter;
|
8562 |
|
8563 |
|
8564 |
|
8565 |
|
8566 | if ('undefined' !== typeof module) {
|
8567 | module.exports = EventEmitter;
|
8568 | }
|
8569 |
|
8570 |
|
8571 | }),
|
8572 |
|
8573 | (function(module, exports, __webpack_require__) {
|
8574 |
|
8575 | "use strict";
|
8576 |
|
8577 |
|
8578 | Object.defineProperty(exports, "__esModule", {
|
8579 | value: true
|
8580 | });
|
8581 | exports.matchText = exports.matchSpacing = exports.matchNewline = exports.matchBlot = exports.matchAttributor = exports.default = undefined;
|
8582 |
|
8583 | 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; };
|
8584 |
|
8585 | 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"); } }; }();
|
8586 |
|
8587 | 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; }; }();
|
8588 |
|
8589 | var _extend2 = __webpack_require__(3);
|
8590 |
|
8591 | var _extend3 = _interopRequireDefault(_extend2);
|
8592 |
|
8593 | var _quillDelta = __webpack_require__(2);
|
8594 |
|
8595 | var _quillDelta2 = _interopRequireDefault(_quillDelta);
|
8596 |
|
8597 | var _parchment = __webpack_require__(0);
|
8598 |
|
8599 | var _parchment2 = _interopRequireDefault(_parchment);
|
8600 |
|
8601 | var _quill = __webpack_require__(5);
|
8602 |
|
8603 | var _quill2 = _interopRequireDefault(_quill);
|
8604 |
|
8605 | var _logger = __webpack_require__(10);
|
8606 |
|
8607 | var _logger2 = _interopRequireDefault(_logger);
|
8608 |
|
8609 | var _module = __webpack_require__(9);
|
8610 |
|
8611 | var _module2 = _interopRequireDefault(_module);
|
8612 |
|
8613 | var _align = __webpack_require__(36);
|
8614 |
|
8615 | var _background = __webpack_require__(37);
|
8616 |
|
8617 | var _code = __webpack_require__(13);
|
8618 |
|
8619 | var _code2 = _interopRequireDefault(_code);
|
8620 |
|
8621 | var _color = __webpack_require__(26);
|
8622 |
|
8623 | var _direction = __webpack_require__(38);
|
8624 |
|
8625 | var _font = __webpack_require__(39);
|
8626 |
|
8627 | var _size = __webpack_require__(40);
|
8628 |
|
8629 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
8630 |
|
8631 | 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; }
|
8632 |
|
8633 | function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
8634 |
|
8635 | 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; }
|
8636 |
|
8637 | 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; }
|
8638 |
|
8639 | var debug = (0, _logger2.default)('quill:clipboard');
|
8640 |
|
8641 | var DOM_KEY = '__ql-matcher';
|
8642 |
|
8643 | 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]];
|
8644 |
|
8645 | var ATTRIBUTE_ATTRIBUTORS = [_align.AlignAttribute, _direction.DirectionAttribute].reduce(function (memo, attr) {
|
8646 | memo[attr.keyName] = attr;
|
8647 | return memo;
|
8648 | }, {});
|
8649 |
|
8650 | var STYLE_ATTRIBUTORS = [_align.AlignStyle, _background.BackgroundStyle, _color.ColorStyle, _direction.DirectionStyle, _font.FontStyle, _size.SizeStyle].reduce(function (memo, attr) {
|
8651 | memo[attr.keyName] = attr;
|
8652 | return memo;
|
8653 | }, {});
|
8654 |
|
8655 | var Clipboard = function (_Module) {
|
8656 | _inherits(Clipboard, _Module);
|
8657 |
|
8658 | function Clipboard(quill, options) {
|
8659 | _classCallCheck(this, Clipboard);
|
8660 |
|
8661 | var _this = _possibleConstructorReturn(this, (Clipboard.__proto__ || Object.getPrototypeOf(Clipboard)).call(this, quill, options));
|
8662 |
|
8663 | _this.quill.root.addEventListener('paste', _this.onPaste.bind(_this));
|
8664 | _this.container = _this.quill.addContainer('ql-clipboard');
|
8665 | _this.container.setAttribute('contenteditable', true);
|
8666 | _this.container.setAttribute('tabindex', -1);
|
8667 | _this.matchers = [];
|
8668 | CLIPBOARD_CONFIG.concat(_this.options.matchers).forEach(function (_ref) {
|
8669 | var _ref2 = _slicedToArray(_ref, 2),
|
8670 | selector = _ref2[0],
|
8671 | matcher = _ref2[1];
|
8672 |
|
8673 | if (!options.matchVisual && matcher === matchSpacing) return;
|
8674 | _this.addMatcher(selector, matcher);
|
8675 | });
|
8676 | return _this;
|
8677 | }
|
8678 |
|
8679 | _createClass(Clipboard, [{
|
8680 | key: 'addMatcher',
|
8681 | value: function addMatcher(selector, matcher) {
|
8682 | this.matchers.push([selector, matcher]);
|
8683 | }
|
8684 | }, {
|
8685 | key: 'convert',
|
8686 | value: function convert(html) {
|
8687 | if (typeof html === 'string') {
|
8688 | this.container.innerHTML = html.replace(/\>\r?\n +\</g, '><');
|
8689 | return this.convert();
|
8690 | }
|
8691 | var formats = this.quill.getFormat(this.quill.selection.savedRange.index);
|
8692 | if (formats[_code2.default.blotName]) {
|
8693 | var text = this.container.innerText;
|
8694 | this.container.innerHTML = '';
|
8695 | return new _quillDelta2.default().insert(text, _defineProperty({}, _code2.default.blotName, formats[_code2.default.blotName]));
|
8696 | }
|
8697 |
|
8698 | var _prepareMatching = this.prepareMatching(),
|
8699 | _prepareMatching2 = _slicedToArray(_prepareMatching, 2),
|
8700 | elementMatchers = _prepareMatching2[0],
|
8701 | textMatchers = _prepareMatching2[1];
|
8702 |
|
8703 | var delta = traverse(this.container, elementMatchers, textMatchers);
|
8704 |
|
8705 | if (deltaEndsWith(delta, '\n') && delta.ops[delta.ops.length - 1].attributes == null) {
|
8706 | delta = delta.compose(new _quillDelta2.default().retain(delta.length() - 1).delete(1));
|
8707 | }
|
8708 | debug.log('convert', this.container.innerHTML, delta);
|
8709 | this.container.innerHTML = '';
|
8710 | return delta;
|
8711 | }
|
8712 | }, {
|
8713 | key: 'dangerouslyPasteHTML',
|
8714 | value: function dangerouslyPasteHTML(index, html) {
|
8715 | var source = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : _quill2.default.sources.API;
|
8716 |
|
8717 | if (typeof index === 'string') {
|
8718 | return this.quill.setContents(this.convert(index), html);
|
8719 | } else {
|
8720 | var paste = this.convert(html);
|
8721 | return this.quill.updateContents(new _quillDelta2.default().retain(index).concat(paste), source);
|
8722 | }
|
8723 | }
|
8724 | }, {
|
8725 | key: 'onPaste',
|
8726 | value: function onPaste(e) {
|
8727 | var _this2 = this;
|
8728 |
|
8729 | if (e.defaultPrevented || !this.quill.isEnabled()) return;
|
8730 | var range = this.quill.getSelection();
|
8731 | var delta = new _quillDelta2.default().retain(range.index);
|
8732 | var scrollTop = this.quill.scrollingContainer.scrollTop;
|
8733 | this.container.focus();
|
8734 | this.quill.selection.update(_quill2.default.sources.SILENT);
|
8735 | setTimeout(function () {
|
8736 | delta = delta.concat(_this2.convert()).delete(range.length);
|
8737 | _this2.quill.updateContents(delta, _quill2.default.sources.USER);
|
8738 |
|
8739 | _this2.quill.setSelection(delta.length() - range.length, _quill2.default.sources.SILENT);
|
8740 | _this2.quill.scrollingContainer.scrollTop = scrollTop;
|
8741 | _this2.quill.focus();
|
8742 | }, 1);
|
8743 | }
|
8744 | }, {
|
8745 | key: 'prepareMatching',
|
8746 | value: function prepareMatching() {
|
8747 | var _this3 = this;
|
8748 |
|
8749 | var elementMatchers = [],
|
8750 | textMatchers = [];
|
8751 | this.matchers.forEach(function (pair) {
|
8752 | var _pair = _slicedToArray(pair, 2),
|
8753 | selector = _pair[0],
|
8754 | matcher = _pair[1];
|
8755 |
|
8756 | switch (selector) {
|
8757 | case Node.TEXT_NODE:
|
8758 | textMatchers.push(matcher);
|
8759 | break;
|
8760 | case Node.ELEMENT_NODE:
|
8761 | elementMatchers.push(matcher);
|
8762 | break;
|
8763 | default:
|
8764 | [].forEach.call(_this3.container.querySelectorAll(selector), function (node) {
|
8765 |
|
8766 | node[DOM_KEY] = node[DOM_KEY] || [];
|
8767 | node[DOM_KEY].push(matcher);
|
8768 | });
|
8769 | break;
|
8770 | }
|
8771 | });
|
8772 | return [elementMatchers, textMatchers];
|
8773 | }
|
8774 | }]);
|
8775 |
|
8776 | return Clipboard;
|
8777 | }(_module2.default);
|
8778 |
|
8779 | Clipboard.DEFAULTS = {
|
8780 | matchers: [],
|
8781 | matchVisual: true
|
8782 | };
|
8783 |
|
8784 | function applyFormat(delta, format, value) {
|
8785 | if ((typeof format === 'undefined' ? 'undefined' : _typeof(format)) === 'object') {
|
8786 | return Object.keys(format).reduce(function (delta, key) {
|
8787 | return applyFormat(delta, key, format[key]);
|
8788 | }, delta);
|
8789 | } else {
|
8790 | return delta.reduce(function (delta, op) {
|
8791 | if (op.attributes && op.attributes[format]) {
|
8792 | return delta.push(op);
|
8793 | } else {
|
8794 | return delta.insert(op.insert, (0, _extend3.default)({}, _defineProperty({}, format, value), op.attributes));
|
8795 | }
|
8796 | }, new _quillDelta2.default());
|
8797 | }
|
8798 | }
|
8799 |
|
8800 | function computeStyle(node) {
|
8801 | if (node.nodeType !== Node.ELEMENT_NODE) return {};
|
8802 | var DOM_KEY = '__ql-computed-style';
|
8803 | return node[DOM_KEY] || (node[DOM_KEY] = window.getComputedStyle(node));
|
8804 | }
|
8805 |
|
8806 | function deltaEndsWith(delta, text) {
|
8807 | var endText = "";
|
8808 | for (var i = delta.ops.length - 1; i >= 0 && endText.length < text.length; --i) {
|
8809 | var op = delta.ops[i];
|
8810 | if (typeof op.insert !== 'string') break;
|
8811 | endText = op.insert + endText;
|
8812 | }
|
8813 | return endText.slice(-1 * text.length) === text;
|
8814 | }
|
8815 |
|
8816 | function isLine(node) {
|
8817 | if (node.childNodes.length === 0) return false;
|
8818 | var style = computeStyle(node);
|
8819 | return ['block', 'list-item'].indexOf(style.display) > -1;
|
8820 | }
|
8821 |
|
8822 | function traverse(node, elementMatchers, textMatchers) {
|
8823 |
|
8824 | if (node.nodeType === node.TEXT_NODE) {
|
8825 | return textMatchers.reduce(function (delta, matcher) {
|
8826 | return matcher(node, delta);
|
8827 | }, new _quillDelta2.default());
|
8828 | } else if (node.nodeType === node.ELEMENT_NODE) {
|
8829 | return [].reduce.call(node.childNodes || [], function (delta, childNode) {
|
8830 | var childrenDelta = traverse(childNode, elementMatchers, textMatchers);
|
8831 | if (childNode.nodeType === node.ELEMENT_NODE) {
|
8832 | childrenDelta = elementMatchers.reduce(function (childrenDelta, matcher) {
|
8833 | return matcher(childNode, childrenDelta);
|
8834 | }, childrenDelta);
|
8835 | childrenDelta = (childNode[DOM_KEY] || []).reduce(function (childrenDelta, matcher) {
|
8836 | return matcher(childNode, childrenDelta);
|
8837 | }, childrenDelta);
|
8838 | }
|
8839 | return delta.concat(childrenDelta);
|
8840 | }, new _quillDelta2.default());
|
8841 | } else {
|
8842 | return new _quillDelta2.default();
|
8843 | }
|
8844 | }
|
8845 |
|
8846 | function matchAlias(format, node, delta) {
|
8847 | return applyFormat(delta, format, true);
|
8848 | }
|
8849 |
|
8850 | function matchAttributor(node, delta) {
|
8851 | var attributes = _parchment2.default.Attributor.Attribute.keys(node);
|
8852 | var classes = _parchment2.default.Attributor.Class.keys(node);
|
8853 | var styles = _parchment2.default.Attributor.Style.keys(node);
|
8854 | var formats = {};
|
8855 | attributes.concat(classes).concat(styles).forEach(function (name) {
|
8856 | var attr = _parchment2.default.query(name, _parchment2.default.Scope.ATTRIBUTE);
|
8857 | if (attr != null) {
|
8858 | formats[attr.attrName] = attr.value(node);
|
8859 | if (formats[attr.attrName]) return;
|
8860 | }
|
8861 | attr = ATTRIBUTE_ATTRIBUTORS[name];
|
8862 | if (attr != null && attr.attrName === name) {
|
8863 | formats[attr.attrName] = attr.value(node) || undefined;
|
8864 | }
|
8865 | attr = STYLE_ATTRIBUTORS[name];
|
8866 | if (attr != null && attr.attrName === name) {
|
8867 | attr = STYLE_ATTRIBUTORS[name];
|
8868 | formats[attr.attrName] = attr.value(node) || undefined;
|
8869 | }
|
8870 | });
|
8871 | if (Object.keys(formats).length > 0) {
|
8872 | delta = applyFormat(delta, formats);
|
8873 | }
|
8874 | return delta;
|
8875 | }
|
8876 |
|
8877 | function matchBlot(node, delta) {
|
8878 | var match = _parchment2.default.query(node);
|
8879 | if (match == null) return delta;
|
8880 | if (match.prototype instanceof _parchment2.default.Embed) {
|
8881 | var embed = {};
|
8882 | var value = match.value(node);
|
8883 | if (value != null) {
|
8884 | embed[match.blotName] = value;
|
8885 | delta = new _quillDelta2.default().insert(embed, match.formats(node));
|
8886 | }
|
8887 | } else if (typeof match.formats === 'function') {
|
8888 | delta = applyFormat(delta, match.blotName, match.formats(node));
|
8889 | }
|
8890 | return delta;
|
8891 | }
|
8892 |
|
8893 | function matchBreak(node, delta) {
|
8894 | if (!deltaEndsWith(delta, '\n')) {
|
8895 | delta.insert('\n');
|
8896 | }
|
8897 | return delta;
|
8898 | }
|
8899 |
|
8900 | function matchIgnore() {
|
8901 | return new _quillDelta2.default();
|
8902 | }
|
8903 |
|
8904 | function matchIndent(node, delta) {
|
8905 | var match = _parchment2.default.query(node);
|
8906 | if (match == null || match.blotName !== 'list-item' || !deltaEndsWith(delta, '\n')) {
|
8907 | return delta;
|
8908 | }
|
8909 | var indent = -1,
|
8910 | parent = node.parentNode;
|
8911 | while (!parent.classList.contains('ql-clipboard')) {
|
8912 | if ((_parchment2.default.query(parent) || {}).blotName === 'list') {
|
8913 | indent += 1;
|
8914 | }
|
8915 | parent = parent.parentNode;
|
8916 | }
|
8917 | if (indent <= 0) return delta;
|
8918 | return delta.compose(new _quillDelta2.default().retain(delta.length() - 1).retain(1, { indent: indent }));
|
8919 | }
|
8920 |
|
8921 | function matchNewline(node, delta) {
|
8922 | if (!deltaEndsWith(delta, '\n')) {
|
8923 | if (isLine(node) || delta.length() > 0 && node.nextSibling && isLine(node.nextSibling)) {
|
8924 | delta.insert('\n');
|
8925 | }
|
8926 | }
|
8927 | return delta;
|
8928 | }
|
8929 |
|
8930 | function matchSpacing(node, delta) {
|
8931 | if (isLine(node) && node.nextElementSibling != null && !deltaEndsWith(delta, '\n\n')) {
|
8932 | var nodeHeight = node.offsetHeight + parseFloat(computeStyle(node).marginTop) + parseFloat(computeStyle(node).marginBottom);
|
8933 | if (node.nextElementSibling.offsetTop > node.offsetTop + nodeHeight * 1.5) {
|
8934 | delta.insert('\n');
|
8935 | }
|
8936 | }
|
8937 | return delta;
|
8938 | }
|
8939 |
|
8940 | function matchStyles(node, delta) {
|
8941 | var formats = {};
|
8942 | var style = node.style || {};
|
8943 | if (style.fontStyle && computeStyle(node).fontStyle === 'italic') {
|
8944 | formats.italic = true;
|
8945 | }
|
8946 | if (style.fontWeight && (computeStyle(node).fontWeight.startsWith('bold') || parseInt(computeStyle(node).fontWeight) >= 700)) {
|
8947 | formats.bold = true;
|
8948 | }
|
8949 | if (Object.keys(formats).length > 0) {
|
8950 | delta = applyFormat(delta, formats);
|
8951 | }
|
8952 | if (parseFloat(style.textIndent || 0) > 0) {
|
8953 |
|
8954 | delta = new _quillDelta2.default().insert('\t').concat(delta);
|
8955 | }
|
8956 | return delta;
|
8957 | }
|
8958 |
|
8959 | function matchText(node, delta) {
|
8960 | var text = node.data;
|
8961 |
|
8962 | if (node.parentNode.tagName === 'O:P') {
|
8963 | return delta.insert(text.trim());
|
8964 | }
|
8965 | if (text.trim().length === 0 && node.parentNode.classList.contains('ql-clipboard')) {
|
8966 | return delta;
|
8967 | }
|
8968 | if (!computeStyle(node.parentNode).whiteSpace.startsWith('pre')) {
|
8969 |
|
8970 | var replacer = function replacer(collapse, match) {
|
8971 | match = match.replace(/[^\u00a0]/g, '');
|
8972 | return match.length < 1 && collapse ? ' ' : match;
|
8973 | };
|
8974 | text = text.replace(/\r\n/g, ' ').replace(/\n/g, ' ');
|
8975 | text = text.replace(/\s\s+/g, replacer.bind(replacer, true));
|
8976 | if (node.previousSibling == null && isLine(node.parentNode) || node.previousSibling != null && isLine(node.previousSibling)) {
|
8977 | text = text.replace(/^\s+/, replacer.bind(replacer, false));
|
8978 | }
|
8979 | if (node.nextSibling == null && isLine(node.parentNode) || node.nextSibling != null && isLine(node.nextSibling)) {
|
8980 | text = text.replace(/\s+$/, replacer.bind(replacer, false));
|
8981 | }
|
8982 | }
|
8983 | return delta.insert(text);
|
8984 | }
|
8985 |
|
8986 | exports.default = Clipboard;
|
8987 | exports.matchAttributor = matchAttributor;
|
8988 | exports.matchBlot = matchBlot;
|
8989 | exports.matchNewline = matchNewline;
|
8990 | exports.matchSpacing = matchSpacing;
|
8991 | exports.matchText = matchText;
|
8992 |
|
8993 | }),
|
8994 |
|
8995 | (function(module, exports, __webpack_require__) {
|
8996 |
|
8997 | "use strict";
|
8998 |
|
8999 |
|
9000 | Object.defineProperty(exports, "__esModule", {
|
9001 | value: true
|
9002 | });
|
9003 |
|
9004 | 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; }; }();
|
9005 |
|
9006 | 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); } };
|
9007 |
|
9008 | var _inline = __webpack_require__(6);
|
9009 |
|
9010 | var _inline2 = _interopRequireDefault(_inline);
|
9011 |
|
9012 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
9013 |
|
9014 | function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
9015 |
|
9016 | 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; }
|
9017 |
|
9018 | 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; }
|
9019 |
|
9020 | var Bold = function (_Inline) {
|
9021 | _inherits(Bold, _Inline);
|
9022 |
|
9023 | function Bold() {
|
9024 | _classCallCheck(this, Bold);
|
9025 |
|
9026 | return _possibleConstructorReturn(this, (Bold.__proto__ || Object.getPrototypeOf(Bold)).apply(this, arguments));
|
9027 | }
|
9028 |
|
9029 | _createClass(Bold, [{
|
9030 | key: 'optimize',
|
9031 | value: function optimize(context) {
|
9032 | _get(Bold.prototype.__proto__ || Object.getPrototypeOf(Bold.prototype), 'optimize', this).call(this, context);
|
9033 | if (this.domNode.tagName !== this.statics.tagName[0]) {
|
9034 | this.replaceWith(this.statics.blotName);
|
9035 | }
|
9036 | }
|
9037 | }], [{
|
9038 | key: 'create',
|
9039 | value: function create() {
|
9040 | return _get(Bold.__proto__ || Object.getPrototypeOf(Bold), 'create', this).call(this);
|
9041 | }
|
9042 | }, {
|
9043 | key: 'formats',
|
9044 | value: function formats() {
|
9045 | return true;
|
9046 | }
|
9047 | }]);
|
9048 |
|
9049 | return Bold;
|
9050 | }(_inline2.default);
|
9051 |
|
9052 | Bold.blotName = 'bold';
|
9053 | Bold.tagName = ['STRONG', 'B'];
|
9054 |
|
9055 | exports.default = Bold;
|
9056 |
|
9057 | }),
|
9058 |
|
9059 | (function(module, exports, __webpack_require__) {
|
9060 |
|
9061 | "use strict";
|
9062 |
|
9063 |
|
9064 | Object.defineProperty(exports, "__esModule", {
|
9065 | value: true
|
9066 | });
|
9067 | exports.addControls = exports.default = undefined;
|
9068 |
|
9069 | 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"); } }; }();
|
9070 |
|
9071 | 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; }; }();
|
9072 |
|
9073 | var _quillDelta = __webpack_require__(2);
|
9074 |
|
9075 | var _quillDelta2 = _interopRequireDefault(_quillDelta);
|
9076 |
|
9077 | var _parchment = __webpack_require__(0);
|
9078 |
|
9079 | var _parchment2 = _interopRequireDefault(_parchment);
|
9080 |
|
9081 | var _quill = __webpack_require__(5);
|
9082 |
|
9083 | var _quill2 = _interopRequireDefault(_quill);
|
9084 |
|
9085 | var _logger = __webpack_require__(10);
|
9086 |
|
9087 | var _logger2 = _interopRequireDefault(_logger);
|
9088 |
|
9089 | var _module = __webpack_require__(9);
|
9090 |
|
9091 | var _module2 = _interopRequireDefault(_module);
|
9092 |
|
9093 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
9094 |
|
9095 | 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; }
|
9096 |
|
9097 | function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
9098 |
|
9099 | 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; }
|
9100 |
|
9101 | 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; }
|
9102 |
|
9103 | var debug = (0, _logger2.default)('quill:toolbar');
|
9104 |
|
9105 | var Toolbar = function (_Module) {
|
9106 | _inherits(Toolbar, _Module);
|
9107 |
|
9108 | function Toolbar(quill, options) {
|
9109 | _classCallCheck(this, Toolbar);
|
9110 |
|
9111 | var _this = _possibleConstructorReturn(this, (Toolbar.__proto__ || Object.getPrototypeOf(Toolbar)).call(this, quill, options));
|
9112 |
|
9113 | if (Array.isArray(_this.options.container)) {
|
9114 | var container = document.createElement('div');
|
9115 | addControls(container, _this.options.container);
|
9116 | quill.container.parentNode.insertBefore(container, quill.container);
|
9117 | _this.container = container;
|
9118 | } else if (typeof _this.options.container === 'string') {
|
9119 | _this.container = document.querySelector(_this.options.container);
|
9120 | } else {
|
9121 | _this.container = _this.options.container;
|
9122 | }
|
9123 | if (!(_this.container instanceof HTMLElement)) {
|
9124 | var _ret;
|
9125 |
|
9126 | return _ret = debug.error('Container required for toolbar', _this.options), _possibleConstructorReturn(_this, _ret);
|
9127 | }
|
9128 | _this.container.classList.add('ql-toolbar');
|
9129 | _this.controls = [];
|
9130 | _this.handlers = {};
|
9131 | Object.keys(_this.options.handlers).forEach(function (format) {
|
9132 | _this.addHandler(format, _this.options.handlers[format]);
|
9133 | });
|
9134 | [].forEach.call(_this.container.querySelectorAll('button, select'), function (input) {
|
9135 | _this.attach(input);
|
9136 | });
|
9137 | _this.quill.on(_quill2.default.events.EDITOR_CHANGE, function (type, range) {
|
9138 | if (type === _quill2.default.events.SELECTION_CHANGE) {
|
9139 | _this.update(range);
|
9140 | }
|
9141 | });
|
9142 | _this.quill.on(_quill2.default.events.SCROLL_OPTIMIZE, function () {
|
9143 | var _this$quill$selection = _this.quill.selection.getRange(),
|
9144 | _this$quill$selection2 = _slicedToArray(_this$quill$selection, 1),
|
9145 | range = _this$quill$selection2[0];
|
9146 |
|
9147 |
|
9148 | _this.update(range);
|
9149 | });
|
9150 | return _this;
|
9151 | }
|
9152 |
|
9153 | _createClass(Toolbar, [{
|
9154 | key: 'addHandler',
|
9155 | value: function addHandler(format, handler) {
|
9156 | this.handlers[format] = handler;
|
9157 | }
|
9158 | }, {
|
9159 | key: 'attach',
|
9160 | value: function attach(input) {
|
9161 | var _this2 = this;
|
9162 |
|
9163 | var format = [].find.call(input.classList, function (className) {
|
9164 | return className.indexOf('ql-') === 0;
|
9165 | });
|
9166 | if (!format) return;
|
9167 | format = format.slice('ql-'.length);
|
9168 | if (input.tagName === 'BUTTON') {
|
9169 | input.setAttribute('type', 'button');
|
9170 | }
|
9171 | if (this.handlers[format] == null) {
|
9172 | if (this.quill.scroll.whitelist != null && this.quill.scroll.whitelist[format] == null) {
|
9173 | debug.warn('ignoring attaching to disabled format', format, input);
|
9174 | return;
|
9175 | }
|
9176 | if (_parchment2.default.query(format) == null) {
|
9177 | debug.warn('ignoring attaching to nonexistent format', format, input);
|
9178 | return;
|
9179 | }
|
9180 | }
|
9181 | var eventName = input.tagName === 'SELECT' ? 'change' : 'click';
|
9182 | input.addEventListener(eventName, function (e) {
|
9183 | var value = void 0;
|
9184 | if (input.tagName === 'SELECT') {
|
9185 | if (input.selectedIndex < 0) return;
|
9186 | var selected = input.options[input.selectedIndex];
|
9187 | if (selected.hasAttribute('selected')) {
|
9188 | value = false;
|
9189 | } else {
|
9190 | value = selected.value || false;
|
9191 | }
|
9192 | } else {
|
9193 | if (input.classList.contains('ql-active')) {
|
9194 | value = false;
|
9195 | } else {
|
9196 | value = input.value || !input.hasAttribute('value');
|
9197 | }
|
9198 | e.preventDefault();
|
9199 | }
|
9200 | _this2.quill.focus();
|
9201 |
|
9202 | var _quill$selection$getR = _this2.quill.selection.getRange(),
|
9203 | _quill$selection$getR2 = _slicedToArray(_quill$selection$getR, 1),
|
9204 | range = _quill$selection$getR2[0];
|
9205 |
|
9206 | if (_this2.handlers[format] != null) {
|
9207 | _this2.handlers[format].call(_this2, value);
|
9208 | } else if (_parchment2.default.query(format).prototype instanceof _parchment2.default.Embed) {
|
9209 | value = prompt('Enter ' + format);
|
9210 | if (!value) return;
|
9211 | _this2.quill.updateContents(new _quillDelta2.default().retain(range.index).delete(range.length).insert(_defineProperty({}, format, value)), _quill2.default.sources.USER);
|
9212 | } else {
|
9213 | _this2.quill.format(format, value, _quill2.default.sources.USER);
|
9214 | }
|
9215 | _this2.update(range);
|
9216 | });
|
9217 |
|
9218 | this.controls.push([format, input]);
|
9219 | }
|
9220 | }, {
|
9221 | key: 'update',
|
9222 | value: function update(range) {
|
9223 | var formats = range == null ? {} : this.quill.getFormat(range);
|
9224 | this.controls.forEach(function (pair) {
|
9225 | var _pair = _slicedToArray(pair, 2),
|
9226 | format = _pair[0],
|
9227 | input = _pair[1];
|
9228 |
|
9229 | if (input.tagName === 'SELECT') {
|
9230 | var option = void 0;
|
9231 | if (range == null) {
|
9232 | option = null;
|
9233 | } else if (formats[format] == null) {
|
9234 | option = input.querySelector('option[selected]');
|
9235 | } else if (!Array.isArray(formats[format])) {
|
9236 | var value = formats[format];
|
9237 | if (typeof value === 'string') {
|
9238 | value = value.replace(/\"/g, '\\"');
|
9239 | }
|
9240 | option = input.querySelector('option[value="' + value + '"]');
|
9241 | }
|
9242 | if (option == null) {
|
9243 | input.value = '';
|
9244 | input.selectedIndex = -1;
|
9245 | } else {
|
9246 | option.selected = true;
|
9247 | }
|
9248 | } else {
|
9249 | if (range == null) {
|
9250 | input.classList.remove('ql-active');
|
9251 | } else if (input.hasAttribute('value')) {
|
9252 |
|
9253 |
|
9254 | var isActive = formats[format] === input.getAttribute('value') || formats[format] != null && formats[format].toString() === input.getAttribute('value') || formats[format] == null && !input.getAttribute('value');
|
9255 | input.classList.toggle('ql-active', isActive);
|
9256 | } else {
|
9257 | input.classList.toggle('ql-active', formats[format] != null);
|
9258 | }
|
9259 | }
|
9260 | });
|
9261 | }
|
9262 | }]);
|
9263 |
|
9264 | return Toolbar;
|
9265 | }(_module2.default);
|
9266 |
|
9267 | Toolbar.DEFAULTS = {};
|
9268 |
|
9269 | function addButton(container, format, value) {
|
9270 | var input = document.createElement('button');
|
9271 | input.setAttribute('type', 'button');
|
9272 | input.classList.add('ql-' + format);
|
9273 | if (value != null) {
|
9274 | input.value = value;
|
9275 | }
|
9276 | container.appendChild(input);
|
9277 | }
|
9278 |
|
9279 | function addControls(container, groups) {
|
9280 | if (!Array.isArray(groups[0])) {
|
9281 | groups = [groups];
|
9282 | }
|
9283 | groups.forEach(function (controls) {
|
9284 | var group = document.createElement('span');
|
9285 | group.classList.add('ql-formats');
|
9286 | controls.forEach(function (control) {
|
9287 | if (typeof control === 'string') {
|
9288 | addButton(group, control);
|
9289 | } else {
|
9290 | var format = Object.keys(control)[0];
|
9291 | var value = control[format];
|
9292 | if (Array.isArray(value)) {
|
9293 | addSelect(group, format, value);
|
9294 | } else {
|
9295 | addButton(group, format, value);
|
9296 | }
|
9297 | }
|
9298 | });
|
9299 | container.appendChild(group);
|
9300 | });
|
9301 | }
|
9302 |
|
9303 | function addSelect(container, format, values) {
|
9304 | var input = document.createElement('select');
|
9305 | input.classList.add('ql-' + format);
|
9306 | values.forEach(function (value) {
|
9307 | var option = document.createElement('option');
|
9308 | if (value !== false) {
|
9309 | option.setAttribute('value', value);
|
9310 | } else {
|
9311 | option.setAttribute('selected', 'selected');
|
9312 | }
|
9313 | input.appendChild(option);
|
9314 | });
|
9315 | container.appendChild(input);
|
9316 | }
|
9317 |
|
9318 | Toolbar.DEFAULTS = {
|
9319 | container: null,
|
9320 | handlers: {
|
9321 | clean: function clean() {
|
9322 | var _this3 = this;
|
9323 |
|
9324 | var range = this.quill.getSelection();
|
9325 | if (range == null) return;
|
9326 | if (range.length == 0) {
|
9327 | var formats = this.quill.getFormat();
|
9328 | Object.keys(formats).forEach(function (name) {
|
9329 |
|
9330 | if (_parchment2.default.query(name, _parchment2.default.Scope.INLINE) != null) {
|
9331 | _this3.quill.format(name, false);
|
9332 | }
|
9333 | });
|
9334 | } else {
|
9335 | this.quill.removeFormat(range, _quill2.default.sources.USER);
|
9336 | }
|
9337 | },
|
9338 | direction: function direction(value) {
|
9339 | var align = this.quill.getFormat()['align'];
|
9340 | if (value === 'rtl' && align == null) {
|
9341 | this.quill.format('align', 'right', _quill2.default.sources.USER);
|
9342 | } else if (!value && align === 'right') {
|
9343 | this.quill.format('align', false, _quill2.default.sources.USER);
|
9344 | }
|
9345 | this.quill.format('direction', value, _quill2.default.sources.USER);
|
9346 | },
|
9347 | indent: function indent(value) {
|
9348 | var range = this.quill.getSelection();
|
9349 | var formats = this.quill.getFormat(range);
|
9350 | var indent = parseInt(formats.indent || 0);
|
9351 | if (value === '+1' || value === '-1') {
|
9352 | var modifier = value === '+1' ? 1 : -1;
|
9353 | if (formats.direction === 'rtl') modifier *= -1;
|
9354 | this.quill.format('indent', indent + modifier, _quill2.default.sources.USER);
|
9355 | }
|
9356 | },
|
9357 | link: function link(value) {
|
9358 | if (value === true) {
|
9359 | value = prompt('Enter link URL:');
|
9360 | }
|
9361 | this.quill.format('link', value, _quill2.default.sources.USER);
|
9362 | },
|
9363 | list: function list(value) {
|
9364 | var range = this.quill.getSelection();
|
9365 | var formats = this.quill.getFormat(range);
|
9366 | if (value === 'check') {
|
9367 | if (formats['list'] === 'checked' || formats['list'] === 'unchecked') {
|
9368 | this.quill.format('list', false, _quill2.default.sources.USER);
|
9369 | } else {
|
9370 | this.quill.format('list', 'unchecked', _quill2.default.sources.USER);
|
9371 | }
|
9372 | } else {
|
9373 | this.quill.format('list', value, _quill2.default.sources.USER);
|
9374 | }
|
9375 | }
|
9376 | }
|
9377 | };
|
9378 |
|
9379 | exports.default = Toolbar;
|
9380 | exports.addControls = addControls;
|
9381 |
|
9382 | }),
|
9383 |
|
9384 | (function(module, exports) {
|
9385 |
|
9386 | module.exports = "<svg viewbox=\"0 0 18 18\"> <polyline class=\"ql-even ql-stroke\" points=\"5 7 3 9 5 11\"></polyline> <polyline class=\"ql-even ql-stroke\" points=\"13 7 15 9 13 11\"></polyline> <line class=ql-stroke x1=10 x2=8 y1=5 y2=13></line> </svg>";
|
9387 |
|
9388 | }),
|
9389 |
|
9390 | (function(module, exports, __webpack_require__) {
|
9391 |
|
9392 | "use strict";
|
9393 |
|
9394 |
|
9395 | Object.defineProperty(exports, "__esModule", {
|
9396 | value: true
|
9397 | });
|
9398 |
|
9399 | 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; }; }();
|
9400 |
|
9401 | 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); } };
|
9402 |
|
9403 | var _picker = __webpack_require__(28);
|
9404 |
|
9405 | var _picker2 = _interopRequireDefault(_picker);
|
9406 |
|
9407 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
9408 |
|
9409 | function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
9410 |
|
9411 | 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; }
|
9412 |
|
9413 | 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; }
|
9414 |
|
9415 | var ColorPicker = function (_Picker) {
|
9416 | _inherits(ColorPicker, _Picker);
|
9417 |
|
9418 | function ColorPicker(select, label) {
|
9419 | _classCallCheck(this, ColorPicker);
|
9420 |
|
9421 | var _this = _possibleConstructorReturn(this, (ColorPicker.__proto__ || Object.getPrototypeOf(ColorPicker)).call(this, select));
|
9422 |
|
9423 | _this.label.innerHTML = label;
|
9424 | _this.container.classList.add('ql-color-picker');
|
9425 | [].slice.call(_this.container.querySelectorAll('.ql-picker-item'), 0, 7).forEach(function (item) {
|
9426 | item.classList.add('ql-primary');
|
9427 | });
|
9428 | return _this;
|
9429 | }
|
9430 |
|
9431 | _createClass(ColorPicker, [{
|
9432 | key: 'buildItem',
|
9433 | value: function buildItem(option) {
|
9434 | var item = _get(ColorPicker.prototype.__proto__ || Object.getPrototypeOf(ColorPicker.prototype), 'buildItem', this).call(this, option);
|
9435 | item.style.backgroundColor = option.getAttribute('value') || '';
|
9436 | return item;
|
9437 | }
|
9438 | }, {
|
9439 | key: 'selectItem',
|
9440 | value: function selectItem(item, trigger) {
|
9441 | _get(ColorPicker.prototype.__proto__ || Object.getPrototypeOf(ColorPicker.prototype), 'selectItem', this).call(this, item, trigger);
|
9442 | var colorLabel = this.label.querySelector('.ql-color-label');
|
9443 | var value = item ? item.getAttribute('data-value') || '' : '';
|
9444 | if (colorLabel) {
|
9445 | if (colorLabel.tagName === 'line') {
|
9446 | colorLabel.style.stroke = value;
|
9447 | } else {
|
9448 | colorLabel.style.fill = value;
|
9449 | }
|
9450 | }
|
9451 | }
|
9452 | }]);
|
9453 |
|
9454 | return ColorPicker;
|
9455 | }(_picker2.default);
|
9456 |
|
9457 | exports.default = ColorPicker;
|
9458 |
|
9459 | }),
|
9460 |
|
9461 | (function(module, exports, __webpack_require__) {
|
9462 |
|
9463 | "use strict";
|
9464 |
|
9465 |
|
9466 | Object.defineProperty(exports, "__esModule", {
|
9467 | value: true
|
9468 | });
|
9469 |
|
9470 | 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; }; }();
|
9471 |
|
9472 | 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); } };
|
9473 |
|
9474 | var _picker = __webpack_require__(28);
|
9475 |
|
9476 | var _picker2 = _interopRequireDefault(_picker);
|
9477 |
|
9478 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
9479 |
|
9480 | function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
9481 |
|
9482 | 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; }
|
9483 |
|
9484 | 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; }
|
9485 |
|
9486 | var IconPicker = function (_Picker) {
|
9487 | _inherits(IconPicker, _Picker);
|
9488 |
|
9489 | function IconPicker(select, icons) {
|
9490 | _classCallCheck(this, IconPicker);
|
9491 |
|
9492 | var _this = _possibleConstructorReturn(this, (IconPicker.__proto__ || Object.getPrototypeOf(IconPicker)).call(this, select));
|
9493 |
|
9494 | _this.container.classList.add('ql-icon-picker');
|
9495 | [].forEach.call(_this.container.querySelectorAll('.ql-picker-item'), function (item) {
|
9496 | item.innerHTML = icons[item.getAttribute('data-value') || ''];
|
9497 | });
|
9498 | _this.defaultItem = _this.container.querySelector('.ql-selected');
|
9499 | _this.selectItem(_this.defaultItem);
|
9500 | return _this;
|
9501 | }
|
9502 |
|
9503 | _createClass(IconPicker, [{
|
9504 | key: 'selectItem',
|
9505 | value: function selectItem(item, trigger) {
|
9506 | _get(IconPicker.prototype.__proto__ || Object.getPrototypeOf(IconPicker.prototype), 'selectItem', this).call(this, item, trigger);
|
9507 | item = item || this.defaultItem;
|
9508 | this.label.innerHTML = item.innerHTML;
|
9509 | }
|
9510 | }]);
|
9511 |
|
9512 | return IconPicker;
|
9513 | }(_picker2.default);
|
9514 |
|
9515 | exports.default = IconPicker;
|
9516 |
|
9517 | }),
|
9518 |
|
9519 | (function(module, exports, __webpack_require__) {
|
9520 |
|
9521 | "use strict";
|
9522 |
|
9523 |
|
9524 | Object.defineProperty(exports, "__esModule", {
|
9525 | value: true
|
9526 | });
|
9527 |
|
9528 | 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; }; }();
|
9529 |
|
9530 | function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
9531 |
|
9532 | var Tooltip = function () {
|
9533 | function Tooltip(quill, boundsContainer) {
|
9534 | var _this = this;
|
9535 |
|
9536 | _classCallCheck(this, Tooltip);
|
9537 |
|
9538 | this.quill = quill;
|
9539 | this.boundsContainer = boundsContainer || document.body;
|
9540 | this.root = quill.addContainer('ql-tooltip');
|
9541 | this.root.innerHTML = this.constructor.TEMPLATE;
|
9542 | if (this.quill.root === this.quill.scrollingContainer) {
|
9543 | this.quill.root.addEventListener('scroll', function () {
|
9544 | _this.root.style.marginTop = -1 * _this.quill.root.scrollTop + 'px';
|
9545 | });
|
9546 | }
|
9547 | this.hide();
|
9548 | }
|
9549 |
|
9550 | _createClass(Tooltip, [{
|
9551 | key: 'hide',
|
9552 | value: function hide() {
|
9553 | this.root.classList.add('ql-hidden');
|
9554 | }
|
9555 | }, {
|
9556 | key: 'position',
|
9557 | value: function position(reference) {
|
9558 | var left = reference.left + reference.width / 2 - this.root.offsetWidth / 2;
|
9559 |
|
9560 | var top = reference.bottom + this.quill.root.scrollTop;
|
9561 | this.root.style.left = left + 'px';
|
9562 | this.root.style.top = top + 'px';
|
9563 | this.root.classList.remove('ql-flip');
|
9564 | var containerBounds = this.boundsContainer.getBoundingClientRect();
|
9565 | var rootBounds = this.root.getBoundingClientRect();
|
9566 | var shift = 0;
|
9567 | if (rootBounds.right > containerBounds.right) {
|
9568 | shift = containerBounds.right - rootBounds.right;
|
9569 | this.root.style.left = left + shift + 'px';
|
9570 | }
|
9571 | if (rootBounds.left < containerBounds.left) {
|
9572 | shift = containerBounds.left - rootBounds.left;
|
9573 | this.root.style.left = left + shift + 'px';
|
9574 | }
|
9575 | if (rootBounds.bottom > containerBounds.bottom) {
|
9576 | var height = rootBounds.bottom - rootBounds.top;
|
9577 | var verticalShift = reference.bottom - reference.top + height;
|
9578 | this.root.style.top = top - verticalShift + 'px';
|
9579 | this.root.classList.add('ql-flip');
|
9580 | }
|
9581 | return shift;
|
9582 | }
|
9583 | }, {
|
9584 | key: 'show',
|
9585 | value: function show() {
|
9586 | this.root.classList.remove('ql-editing');
|
9587 | this.root.classList.remove('ql-hidden');
|
9588 | }
|
9589 | }]);
|
9590 |
|
9591 | return Tooltip;
|
9592 | }();
|
9593 |
|
9594 | exports.default = Tooltip;
|
9595 |
|
9596 | }),
|
9597 |
|
9598 | (function(module, exports, __webpack_require__) {
|
9599 |
|
9600 | "use strict";
|
9601 |
|
9602 |
|
9603 | Object.defineProperty(exports, "__esModule", {
|
9604 | value: true
|
9605 | });
|
9606 |
|
9607 | 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"); } }; }();
|
9608 |
|
9609 | 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); } };
|
9610 |
|
9611 | 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; }; }();
|
9612 |
|
9613 | var _extend = __webpack_require__(3);
|
9614 |
|
9615 | var _extend2 = _interopRequireDefault(_extend);
|
9616 |
|
9617 | var _emitter = __webpack_require__(8);
|
9618 |
|
9619 | var _emitter2 = _interopRequireDefault(_emitter);
|
9620 |
|
9621 | var _base = __webpack_require__(43);
|
9622 |
|
9623 | var _base2 = _interopRequireDefault(_base);
|
9624 |
|
9625 | var _link = __webpack_require__(27);
|
9626 |
|
9627 | var _link2 = _interopRequireDefault(_link);
|
9628 |
|
9629 | var _selection = __webpack_require__(15);
|
9630 |
|
9631 | var _icons = __webpack_require__(41);
|
9632 |
|
9633 | var _icons2 = _interopRequireDefault(_icons);
|
9634 |
|
9635 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
9636 |
|
9637 | function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
9638 |
|
9639 | 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; }
|
9640 |
|
9641 | 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; }
|
9642 |
|
9643 | var TOOLBAR_CONFIG = [[{ header: ['1', '2', '3', false] }], ['bold', 'italic', 'underline', 'link'], [{ list: 'ordered' }, { list: 'bullet' }], ['clean']];
|
9644 |
|
9645 | var SnowTheme = function (_BaseTheme) {
|
9646 | _inherits(SnowTheme, _BaseTheme);
|
9647 |
|
9648 | function SnowTheme(quill, options) {
|
9649 | _classCallCheck(this, SnowTheme);
|
9650 |
|
9651 | if (options.modules.toolbar != null && options.modules.toolbar.container == null) {
|
9652 | options.modules.toolbar.container = TOOLBAR_CONFIG;
|
9653 | }
|
9654 |
|
9655 | var _this = _possibleConstructorReturn(this, (SnowTheme.__proto__ || Object.getPrototypeOf(SnowTheme)).call(this, quill, options));
|
9656 |
|
9657 | _this.quill.container.classList.add('ql-snow');
|
9658 | return _this;
|
9659 | }
|
9660 |
|
9661 | _createClass(SnowTheme, [{
|
9662 | key: 'extendToolbar',
|
9663 | value: function extendToolbar(toolbar) {
|
9664 | toolbar.container.classList.add('ql-snow');
|
9665 | this.buildButtons([].slice.call(toolbar.container.querySelectorAll('button')), _icons2.default);
|
9666 | this.buildPickers([].slice.call(toolbar.container.querySelectorAll('select')), _icons2.default);
|
9667 | this.tooltip = new SnowTooltip(this.quill, this.options.bounds);
|
9668 | if (toolbar.container.querySelector('.ql-link')) {
|
9669 | this.quill.keyboard.addBinding({ key: 'K', shortKey: true }, function (range, context) {
|
9670 | toolbar.handlers['link'].call(toolbar, !context.format.link);
|
9671 | });
|
9672 | }
|
9673 | }
|
9674 | }]);
|
9675 |
|
9676 | return SnowTheme;
|
9677 | }(_base2.default);
|
9678 |
|
9679 | SnowTheme.DEFAULTS = (0, _extend2.default)(true, {}, _base2.default.DEFAULTS, {
|
9680 | modules: {
|
9681 | toolbar: {
|
9682 | handlers: {
|
9683 | link: function link(value) {
|
9684 | if (value) {
|
9685 | var range = this.quill.getSelection();
|
9686 | if (range == null || range.length == 0) return;
|
9687 | var preview = this.quill.getText(range);
|
9688 | if (/^\S+@\S+\.\S+$/.test(preview) && preview.indexOf('mailto:') !== 0) {
|
9689 | preview = 'mailto:' + preview;
|
9690 | }
|
9691 | var tooltip = this.quill.theme.tooltip;
|
9692 | tooltip.edit('link', preview);
|
9693 | } else {
|
9694 | this.quill.format('link', false);
|
9695 | }
|
9696 | }
|
9697 | }
|
9698 | }
|
9699 | }
|
9700 | });
|
9701 |
|
9702 | var SnowTooltip = function (_BaseTooltip) {
|
9703 | _inherits(SnowTooltip, _BaseTooltip);
|
9704 |
|
9705 | function SnowTooltip(quill, bounds) {
|
9706 | _classCallCheck(this, SnowTooltip);
|
9707 |
|
9708 | var _this2 = _possibleConstructorReturn(this, (SnowTooltip.__proto__ || Object.getPrototypeOf(SnowTooltip)).call(this, quill, bounds));
|
9709 |
|
9710 | _this2.preview = _this2.root.querySelector('a.ql-preview');
|
9711 | return _this2;
|
9712 | }
|
9713 |
|
9714 | _createClass(SnowTooltip, [{
|
9715 | key: 'listen',
|
9716 | value: function listen() {
|
9717 | var _this3 = this;
|
9718 |
|
9719 | _get(SnowTooltip.prototype.__proto__ || Object.getPrototypeOf(SnowTooltip.prototype), 'listen', this).call(this);
|
9720 | this.root.querySelector('a.ql-action').addEventListener('click', function (event) {
|
9721 | if (_this3.root.classList.contains('ql-editing')) {
|
9722 | _this3.save();
|
9723 | } else {
|
9724 | _this3.edit('link', _this3.preview.textContent);
|
9725 | }
|
9726 | event.preventDefault();
|
9727 | });
|
9728 | this.root.querySelector('a.ql-remove').addEventListener('click', function (event) {
|
9729 | if (_this3.linkRange != null) {
|
9730 | var range = _this3.linkRange;
|
9731 | _this3.restoreFocus();
|
9732 | _this3.quill.formatText(range, 'link', false, _emitter2.default.sources.USER);
|
9733 | delete _this3.linkRange;
|
9734 | }
|
9735 | event.preventDefault();
|
9736 | _this3.hide();
|
9737 | });
|
9738 | this.quill.on(_emitter2.default.events.SELECTION_CHANGE, function (range, oldRange, source) {
|
9739 | if (range == null) return;
|
9740 | if (range.length === 0 && source === _emitter2.default.sources.USER) {
|
9741 | var _quill$scroll$descend = _this3.quill.scroll.descendant(_link2.default, range.index),
|
9742 | _quill$scroll$descend2 = _slicedToArray(_quill$scroll$descend, 2),
|
9743 | link = _quill$scroll$descend2[0],
|
9744 | offset = _quill$scroll$descend2[1];
|
9745 |
|
9746 | if (link != null) {
|
9747 | _this3.linkRange = new _selection.Range(range.index - offset, link.length());
|
9748 | var preview = _link2.default.formats(link.domNode);
|
9749 | _this3.preview.textContent = preview;
|
9750 | _this3.preview.setAttribute('href', preview);
|
9751 | _this3.show();
|
9752 | _this3.position(_this3.quill.getBounds(_this3.linkRange));
|
9753 | return;
|
9754 | }
|
9755 | } else {
|
9756 | delete _this3.linkRange;
|
9757 | }
|
9758 | _this3.hide();
|
9759 | });
|
9760 | }
|
9761 | }, {
|
9762 | key: 'show',
|
9763 | value: function show() {
|
9764 | _get(SnowTooltip.prototype.__proto__ || Object.getPrototypeOf(SnowTooltip.prototype), 'show', this).call(this);
|
9765 | this.root.removeAttribute('data-mode');
|
9766 | }
|
9767 | }]);
|
9768 |
|
9769 | return SnowTooltip;
|
9770 | }(_base.BaseTooltip);
|
9771 |
|
9772 | SnowTooltip.TEMPLATE = ['<a class="ql-preview" target="_blank" href="about:blank"></a>', '<input type="text" data-formula="e=mc^2" data-link="https://quilljs.com" data-video="Embed URL">', '<a class="ql-action"></a>', '<a class="ql-remove"></a>'].join('');
|
9773 |
|
9774 | exports.default = SnowTheme;
|
9775 |
|
9776 | }),
|
9777 |
|
9778 | (function(module, exports, __webpack_require__) {
|
9779 |
|
9780 | "use strict";
|
9781 |
|
9782 |
|
9783 | var _core = __webpack_require__(29);
|
9784 |
|
9785 | var _core2 = _interopRequireDefault(_core);
|
9786 |
|
9787 | var _align = __webpack_require__(36);
|
9788 |
|
9789 | var _direction = __webpack_require__(38);
|
9790 |
|
9791 | var _indent = __webpack_require__(64);
|
9792 |
|
9793 | var _blockquote = __webpack_require__(65);
|
9794 |
|
9795 | var _blockquote2 = _interopRequireDefault(_blockquote);
|
9796 |
|
9797 | var _header = __webpack_require__(66);
|
9798 |
|
9799 | var _header2 = _interopRequireDefault(_header);
|
9800 |
|
9801 | var _list = __webpack_require__(67);
|
9802 |
|
9803 | var _list2 = _interopRequireDefault(_list);
|
9804 |
|
9805 | var _background = __webpack_require__(37);
|
9806 |
|
9807 | var _color = __webpack_require__(26);
|
9808 |
|
9809 | var _font = __webpack_require__(39);
|
9810 |
|
9811 | var _size = __webpack_require__(40);
|
9812 |
|
9813 | var _bold = __webpack_require__(56);
|
9814 |
|
9815 | var _bold2 = _interopRequireDefault(_bold);
|
9816 |
|
9817 | var _italic = __webpack_require__(68);
|
9818 |
|
9819 | var _italic2 = _interopRequireDefault(_italic);
|
9820 |
|
9821 | var _link = __webpack_require__(27);
|
9822 |
|
9823 | var _link2 = _interopRequireDefault(_link);
|
9824 |
|
9825 | var _script = __webpack_require__(69);
|
9826 |
|
9827 | var _script2 = _interopRequireDefault(_script);
|
9828 |
|
9829 | var _strike = __webpack_require__(70);
|
9830 |
|
9831 | var _strike2 = _interopRequireDefault(_strike);
|
9832 |
|
9833 | var _underline = __webpack_require__(71);
|
9834 |
|
9835 | var _underline2 = _interopRequireDefault(_underline);
|
9836 |
|
9837 | var _image = __webpack_require__(72);
|
9838 |
|
9839 | var _image2 = _interopRequireDefault(_image);
|
9840 |
|
9841 | var _video = __webpack_require__(73);
|
9842 |
|
9843 | var _video2 = _interopRequireDefault(_video);
|
9844 |
|
9845 | var _code = __webpack_require__(13);
|
9846 |
|
9847 | var _code2 = _interopRequireDefault(_code);
|
9848 |
|
9849 | var _formula = __webpack_require__(74);
|
9850 |
|
9851 | var _formula2 = _interopRequireDefault(_formula);
|
9852 |
|
9853 | var _syntax = __webpack_require__(75);
|
9854 |
|
9855 | var _syntax2 = _interopRequireDefault(_syntax);
|
9856 |
|
9857 | var _toolbar = __webpack_require__(57);
|
9858 |
|
9859 | var _toolbar2 = _interopRequireDefault(_toolbar);
|
9860 |
|
9861 | var _icons = __webpack_require__(41);
|
9862 |
|
9863 | var _icons2 = _interopRequireDefault(_icons);
|
9864 |
|
9865 | var _picker = __webpack_require__(28);
|
9866 |
|
9867 | var _picker2 = _interopRequireDefault(_picker);
|
9868 |
|
9869 | var _colorPicker = __webpack_require__(59);
|
9870 |
|
9871 | var _colorPicker2 = _interopRequireDefault(_colorPicker);
|
9872 |
|
9873 | var _iconPicker = __webpack_require__(60);
|
9874 |
|
9875 | var _iconPicker2 = _interopRequireDefault(_iconPicker);
|
9876 |
|
9877 | var _tooltip = __webpack_require__(61);
|
9878 |
|
9879 | var _tooltip2 = _interopRequireDefault(_tooltip);
|
9880 |
|
9881 | var _bubble = __webpack_require__(108);
|
9882 |
|
9883 | var _bubble2 = _interopRequireDefault(_bubble);
|
9884 |
|
9885 | var _snow = __webpack_require__(62);
|
9886 |
|
9887 | var _snow2 = _interopRequireDefault(_snow);
|
9888 |
|
9889 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
9890 |
|
9891 | _core2.default.register({
|
9892 | 'attributors/attribute/direction': _direction.DirectionAttribute,
|
9893 |
|
9894 | 'attributors/class/align': _align.AlignClass,
|
9895 | 'attributors/class/background': _background.BackgroundClass,
|
9896 | 'attributors/class/color': _color.ColorClass,
|
9897 | 'attributors/class/direction': _direction.DirectionClass,
|
9898 | 'attributors/class/font': _font.FontClass,
|
9899 | 'attributors/class/size': _size.SizeClass,
|
9900 |
|
9901 | 'attributors/style/align': _align.AlignStyle,
|
9902 | 'attributors/style/background': _background.BackgroundStyle,
|
9903 | 'attributors/style/color': _color.ColorStyle,
|
9904 | 'attributors/style/direction': _direction.DirectionStyle,
|
9905 | 'attributors/style/font': _font.FontStyle,
|
9906 | 'attributors/style/size': _size.SizeStyle
|
9907 | }, true);
|
9908 |
|
9909 | _core2.default.register({
|
9910 | 'formats/align': _align.AlignClass,
|
9911 | 'formats/direction': _direction.DirectionClass,
|
9912 | 'formats/indent': _indent.IndentClass,
|
9913 |
|
9914 | 'formats/background': _background.BackgroundStyle,
|
9915 | 'formats/color': _color.ColorStyle,
|
9916 | 'formats/font': _font.FontClass,
|
9917 | 'formats/size': _size.SizeClass,
|
9918 |
|
9919 | 'formats/blockquote': _blockquote2.default,
|
9920 | 'formats/code-block': _code2.default,
|
9921 | 'formats/header': _header2.default,
|
9922 | 'formats/list': _list2.default,
|
9923 |
|
9924 | 'formats/bold': _bold2.default,
|
9925 | 'formats/code': _code.Code,
|
9926 | 'formats/italic': _italic2.default,
|
9927 | 'formats/link': _link2.default,
|
9928 | 'formats/script': _script2.default,
|
9929 | 'formats/strike': _strike2.default,
|
9930 | 'formats/underline': _underline2.default,
|
9931 |
|
9932 | 'formats/image': _image2.default,
|
9933 | 'formats/video': _video2.default,
|
9934 |
|
9935 | 'formats/list/item': _list.ListItem,
|
9936 |
|
9937 | 'modules/formula': _formula2.default,
|
9938 | 'modules/syntax': _syntax2.default,
|
9939 | 'modules/toolbar': _toolbar2.default,
|
9940 |
|
9941 | 'themes/bubble': _bubble2.default,
|
9942 | 'themes/snow': _snow2.default,
|
9943 |
|
9944 | 'ui/icons': _icons2.default,
|
9945 | 'ui/picker': _picker2.default,
|
9946 | 'ui/icon-picker': _iconPicker2.default,
|
9947 | 'ui/color-picker': _colorPicker2.default,
|
9948 | 'ui/tooltip': _tooltip2.default
|
9949 | }, true);
|
9950 |
|
9951 | module.exports = _core2.default;
|
9952 |
|
9953 | }),
|
9954 |
|
9955 | (function(module, exports, __webpack_require__) {
|
9956 |
|
9957 | "use strict";
|
9958 |
|
9959 |
|
9960 | Object.defineProperty(exports, "__esModule", {
|
9961 | value: true
|
9962 | });
|
9963 | exports.IndentClass = undefined;
|
9964 |
|
9965 | 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; }; }();
|
9966 |
|
9967 | 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); } };
|
9968 |
|
9969 | var _parchment = __webpack_require__(0);
|
9970 |
|
9971 | var _parchment2 = _interopRequireDefault(_parchment);
|
9972 |
|
9973 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
9974 |
|
9975 | function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
9976 |
|
9977 | 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; }
|
9978 |
|
9979 | 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; }
|
9980 |
|
9981 | var IdentAttributor = function (_Parchment$Attributor) {
|
9982 | _inherits(IdentAttributor, _Parchment$Attributor);
|
9983 |
|
9984 | function IdentAttributor() {
|
9985 | _classCallCheck(this, IdentAttributor);
|
9986 |
|
9987 | return _possibleConstructorReturn(this, (IdentAttributor.__proto__ || Object.getPrototypeOf(IdentAttributor)).apply(this, arguments));
|
9988 | }
|
9989 |
|
9990 | _createClass(IdentAttributor, [{
|
9991 | key: 'add',
|
9992 | value: function add(node, value) {
|
9993 | if (value === '+1' || value === '-1') {
|
9994 | var indent = this.value(node) || 0;
|
9995 | value = value === '+1' ? indent + 1 : indent - 1;
|
9996 | }
|
9997 | if (value === 0) {
|
9998 | this.remove(node);
|
9999 | return true;
|
10000 | } else {
|
10001 | return _get(IdentAttributor.prototype.__proto__ || Object.getPrototypeOf(IdentAttributor.prototype), 'add', this).call(this, node, value);
|
10002 | }
|
10003 | }
|
10004 | }, {
|
10005 | key: 'canAdd',
|
10006 | value: function canAdd(node, value) {
|
10007 | return _get(IdentAttributor.prototype.__proto__ || Object.getPrototypeOf(IdentAttributor.prototype), 'canAdd', this).call(this, node, value) || _get(IdentAttributor.prototype.__proto__ || Object.getPrototypeOf(IdentAttributor.prototype), 'canAdd', this).call(this, node, parseInt(value));
|
10008 | }
|
10009 | }, {
|
10010 | key: 'value',
|
10011 | value: function value(node) {
|
10012 | return parseInt(_get(IdentAttributor.prototype.__proto__ || Object.getPrototypeOf(IdentAttributor.prototype), 'value', this).call(this, node)) || undefined;
|
10013 | }
|
10014 | }]);
|
10015 |
|
10016 | return IdentAttributor;
|
10017 | }(_parchment2.default.Attributor.Class);
|
10018 |
|
10019 | var IndentClass = new IdentAttributor('indent', 'ql-indent', {
|
10020 | scope: _parchment2.default.Scope.BLOCK,
|
10021 | whitelist: [1, 2, 3, 4, 5, 6, 7, 8]
|
10022 | });
|
10023 |
|
10024 | exports.IndentClass = IndentClass;
|
10025 |
|
10026 | }),
|
10027 |
|
10028 | (function(module, exports, __webpack_require__) {
|
10029 |
|
10030 | "use strict";
|
10031 |
|
10032 |
|
10033 | Object.defineProperty(exports, "__esModule", {
|
10034 | value: true
|
10035 | });
|
10036 |
|
10037 | var _block = __webpack_require__(4);
|
10038 |
|
10039 | var _block2 = _interopRequireDefault(_block);
|
10040 |
|
10041 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
10042 |
|
10043 | function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
10044 |
|
10045 | 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; }
|
10046 |
|
10047 | 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; }
|
10048 |
|
10049 | var Blockquote = function (_Block) {
|
10050 | _inherits(Blockquote, _Block);
|
10051 |
|
10052 | function Blockquote() {
|
10053 | _classCallCheck(this, Blockquote);
|
10054 |
|
10055 | return _possibleConstructorReturn(this, (Blockquote.__proto__ || Object.getPrototypeOf(Blockquote)).apply(this, arguments));
|
10056 | }
|
10057 |
|
10058 | return Blockquote;
|
10059 | }(_block2.default);
|
10060 |
|
10061 | Blockquote.blotName = 'blockquote';
|
10062 | Blockquote.tagName = 'blockquote';
|
10063 |
|
10064 | exports.default = Blockquote;
|
10065 |
|
10066 | }),
|
10067 |
|
10068 | (function(module, exports, __webpack_require__) {
|
10069 |
|
10070 | "use strict";
|
10071 |
|
10072 |
|
10073 | Object.defineProperty(exports, "__esModule", {
|
10074 | value: true
|
10075 | });
|
10076 |
|
10077 | 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; }; }();
|
10078 |
|
10079 | var _block = __webpack_require__(4);
|
10080 |
|
10081 | var _block2 = _interopRequireDefault(_block);
|
10082 |
|
10083 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
10084 |
|
10085 | function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
10086 |
|
10087 | 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; }
|
10088 |
|
10089 | 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; }
|
10090 |
|
10091 | var Header = function (_Block) {
|
10092 | _inherits(Header, _Block);
|
10093 |
|
10094 | function Header() {
|
10095 | _classCallCheck(this, Header);
|
10096 |
|
10097 | return _possibleConstructorReturn(this, (Header.__proto__ || Object.getPrototypeOf(Header)).apply(this, arguments));
|
10098 | }
|
10099 |
|
10100 | _createClass(Header, null, [{
|
10101 | key: 'formats',
|
10102 | value: function formats(domNode) {
|
10103 | return this.tagName.indexOf(domNode.tagName) + 1;
|
10104 | }
|
10105 | }]);
|
10106 |
|
10107 | return Header;
|
10108 | }(_block2.default);
|
10109 |
|
10110 | Header.blotName = 'header';
|
10111 | Header.tagName = ['H1', 'H2', 'H3', 'H4', 'H5', 'H6'];
|
10112 |
|
10113 | exports.default = Header;
|
10114 |
|
10115 | }),
|
10116 |
|
10117 | (function(module, exports, __webpack_require__) {
|
10118 |
|
10119 | "use strict";
|
10120 |
|
10121 |
|
10122 | Object.defineProperty(exports, "__esModule", {
|
10123 | value: true
|
10124 | });
|
10125 | exports.default = exports.ListItem = undefined;
|
10126 |
|
10127 | 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; }; }();
|
10128 |
|
10129 | 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); } };
|
10130 |
|
10131 | var _parchment = __webpack_require__(0);
|
10132 |
|
10133 | var _parchment2 = _interopRequireDefault(_parchment);
|
10134 |
|
10135 | var _block = __webpack_require__(4);
|
10136 |
|
10137 | var _block2 = _interopRequireDefault(_block);
|
10138 |
|
10139 | var _container = __webpack_require__(24);
|
10140 |
|
10141 | var _container2 = _interopRequireDefault(_container);
|
10142 |
|
10143 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
10144 |
|
10145 | 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; }
|
10146 |
|
10147 | function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
10148 |
|
10149 | 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; }
|
10150 |
|
10151 | 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; }
|
10152 |
|
10153 | var ListItem = function (_Block) {
|
10154 | _inherits(ListItem, _Block);
|
10155 |
|
10156 | function ListItem() {
|
10157 | _classCallCheck(this, ListItem);
|
10158 |
|
10159 | return _possibleConstructorReturn(this, (ListItem.__proto__ || Object.getPrototypeOf(ListItem)).apply(this, arguments));
|
10160 | }
|
10161 |
|
10162 | _createClass(ListItem, [{
|
10163 | key: 'format',
|
10164 | value: function format(name, value) {
|
10165 | if (name === List.blotName && !value) {
|
10166 | this.replaceWith(_parchment2.default.create(this.statics.scope));
|
10167 | } else {
|
10168 | _get(ListItem.prototype.__proto__ || Object.getPrototypeOf(ListItem.prototype), 'format', this).call(this, name, value);
|
10169 | }
|
10170 | }
|
10171 | }, {
|
10172 | key: 'remove',
|
10173 | value: function remove() {
|
10174 | if (this.prev == null && this.next == null) {
|
10175 | this.parent.remove();
|
10176 | } else {
|
10177 | _get(ListItem.prototype.__proto__ || Object.getPrototypeOf(ListItem.prototype), 'remove', this).call(this);
|
10178 | }
|
10179 | }
|
10180 | }, {
|
10181 | key: 'replaceWith',
|
10182 | value: function replaceWith(name, value) {
|
10183 | this.parent.isolate(this.offset(this.parent), this.length());
|
10184 | if (name === this.parent.statics.blotName) {
|
10185 | this.parent.replaceWith(name, value);
|
10186 | return this;
|
10187 | } else {
|
10188 | this.parent.unwrap();
|
10189 | return _get(ListItem.prototype.__proto__ || Object.getPrototypeOf(ListItem.prototype), 'replaceWith', this).call(this, name, value);
|
10190 | }
|
10191 | }
|
10192 | }], [{
|
10193 | key: 'formats',
|
10194 | value: function formats(domNode) {
|
10195 | return domNode.tagName === this.tagName ? undefined : _get(ListItem.__proto__ || Object.getPrototypeOf(ListItem), 'formats', this).call(this, domNode);
|
10196 | }
|
10197 | }]);
|
10198 |
|
10199 | return ListItem;
|
10200 | }(_block2.default);
|
10201 |
|
10202 | ListItem.blotName = 'list-item';
|
10203 | ListItem.tagName = 'LI';
|
10204 |
|
10205 | var List = function (_Container) {
|
10206 | _inherits(List, _Container);
|
10207 |
|
10208 | _createClass(List, null, [{
|
10209 | key: 'create',
|
10210 | value: function create(value) {
|
10211 | var tagName = value === 'ordered' ? 'OL' : 'UL';
|
10212 | var node = _get(List.__proto__ || Object.getPrototypeOf(List), 'create', this).call(this, tagName);
|
10213 | if (value === 'checked' || value === 'unchecked') {
|
10214 | node.setAttribute('data-checked', value === 'checked');
|
10215 | }
|
10216 | return node;
|
10217 | }
|
10218 | }, {
|
10219 | key: 'formats',
|
10220 | value: function formats(domNode) {
|
10221 | if (domNode.tagName === 'OL') return 'ordered';
|
10222 | if (domNode.tagName === 'UL') {
|
10223 | if (domNode.hasAttribute('data-checked')) {
|
10224 | return domNode.getAttribute('data-checked') === 'true' ? 'checked' : 'unchecked';
|
10225 | } else {
|
10226 | return 'bullet';
|
10227 | }
|
10228 | }
|
10229 | return undefined;
|
10230 | }
|
10231 | }]);
|
10232 |
|
10233 | function List(domNode) {
|
10234 | _classCallCheck(this, List);
|
10235 |
|
10236 | var _this2 = _possibleConstructorReturn(this, (List.__proto__ || Object.getPrototypeOf(List)).call(this, domNode));
|
10237 |
|
10238 | domNode.addEventListener('click', function (e) {
|
10239 | if (e.target.parentNode !== domNode) return;
|
10240 | var format = _this2.statics.formats(domNode);
|
10241 | var blot = _parchment2.default.find(e.target);
|
10242 | if (format === 'checked') {
|
10243 | blot.format('list', 'unchecked');
|
10244 | } else if (format === 'unchecked') {
|
10245 | blot.format('list', 'checked');
|
10246 | }
|
10247 | });
|
10248 | return _this2;
|
10249 | }
|
10250 |
|
10251 | _createClass(List, [{
|
10252 | key: 'format',
|
10253 | value: function format(name, value) {
|
10254 | if (this.children.length > 0) {
|
10255 | this.children.tail.format(name, value);
|
10256 | }
|
10257 | }
|
10258 | }, {
|
10259 | key: 'formats',
|
10260 | value: function formats() {
|
10261 |
|
10262 | return _defineProperty({}, this.statics.blotName, this.statics.formats(this.domNode));
|
10263 | }
|
10264 | }, {
|
10265 | key: 'insertBefore',
|
10266 | value: function insertBefore(blot, ref) {
|
10267 | if (blot instanceof ListItem) {
|
10268 | _get(List.prototype.__proto__ || Object.getPrototypeOf(List.prototype), 'insertBefore', this).call(this, blot, ref);
|
10269 | } else {
|
10270 | var index = ref == null ? this.length() : ref.offset(this);
|
10271 | var after = this.split(index);
|
10272 | after.parent.insertBefore(blot, after);
|
10273 | }
|
10274 | }
|
10275 | }, {
|
10276 | key: 'optimize',
|
10277 | value: function optimize(context) {
|
10278 | _get(List.prototype.__proto__ || Object.getPrototypeOf(List.prototype), 'optimize', this).call(this, context);
|
10279 | var next = this.next;
|
10280 | if (next != null && next.prev === this && next.statics.blotName === this.statics.blotName && next.domNode.tagName === this.domNode.tagName && next.domNode.getAttribute('data-checked') === this.domNode.getAttribute('data-checked')) {
|
10281 | next.moveChildren(this);
|
10282 | next.remove();
|
10283 | }
|
10284 | }
|
10285 | }, {
|
10286 | key: 'replace',
|
10287 | value: function replace(target) {
|
10288 | if (target.statics.blotName !== this.statics.blotName) {
|
10289 | var item = _parchment2.default.create(this.statics.defaultChild);
|
10290 | target.moveChildren(item);
|
10291 | this.appendChild(item);
|
10292 | }
|
10293 | _get(List.prototype.__proto__ || Object.getPrototypeOf(List.prototype), 'replace', this).call(this, target);
|
10294 | }
|
10295 | }]);
|
10296 |
|
10297 | return List;
|
10298 | }(_container2.default);
|
10299 |
|
10300 | List.blotName = 'list';
|
10301 | List.scope = _parchment2.default.Scope.BLOCK_BLOT;
|
10302 | List.tagName = ['OL', 'UL'];
|
10303 | List.defaultChild = 'list-item';
|
10304 | List.allowedChildren = [ListItem];
|
10305 |
|
10306 | exports.ListItem = ListItem;
|
10307 | exports.default = List;
|
10308 |
|
10309 | }),
|
10310 |
|
10311 | (function(module, exports, __webpack_require__) {
|
10312 |
|
10313 | "use strict";
|
10314 |
|
10315 |
|
10316 | Object.defineProperty(exports, "__esModule", {
|
10317 | value: true
|
10318 | });
|
10319 |
|
10320 | var _bold = __webpack_require__(56);
|
10321 |
|
10322 | var _bold2 = _interopRequireDefault(_bold);
|
10323 |
|
10324 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
10325 |
|
10326 | function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
10327 |
|
10328 | 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; }
|
10329 |
|
10330 | 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; }
|
10331 |
|
10332 | var Italic = function (_Bold) {
|
10333 | _inherits(Italic, _Bold);
|
10334 |
|
10335 | function Italic() {
|
10336 | _classCallCheck(this, Italic);
|
10337 |
|
10338 | return _possibleConstructorReturn(this, (Italic.__proto__ || Object.getPrototypeOf(Italic)).apply(this, arguments));
|
10339 | }
|
10340 |
|
10341 | return Italic;
|
10342 | }(_bold2.default);
|
10343 |
|
10344 | Italic.blotName = 'italic';
|
10345 | Italic.tagName = ['EM', 'I'];
|
10346 |
|
10347 | exports.default = Italic;
|
10348 |
|
10349 | }),
|
10350 |
|
10351 | (function(module, exports, __webpack_require__) {
|
10352 |
|
10353 | "use strict";
|
10354 |
|
10355 |
|
10356 | Object.defineProperty(exports, "__esModule", {
|
10357 | value: true
|
10358 | });
|
10359 |
|
10360 | 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; }; }();
|
10361 |
|
10362 | 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); } };
|
10363 |
|
10364 | var _inline = __webpack_require__(6);
|
10365 |
|
10366 | var _inline2 = _interopRequireDefault(_inline);
|
10367 |
|
10368 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
10369 |
|
10370 | function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
10371 |
|
10372 | 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; }
|
10373 |
|
10374 | 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; }
|
10375 |
|
10376 | var Script = function (_Inline) {
|
10377 | _inherits(Script, _Inline);
|
10378 |
|
10379 | function Script() {
|
10380 | _classCallCheck(this, Script);
|
10381 |
|
10382 | return _possibleConstructorReturn(this, (Script.__proto__ || Object.getPrototypeOf(Script)).apply(this, arguments));
|
10383 | }
|
10384 |
|
10385 | _createClass(Script, null, [{
|
10386 | key: 'create',
|
10387 | value: function create(value) {
|
10388 | if (value === 'super') {
|
10389 | return document.createElement('sup');
|
10390 | } else if (value === 'sub') {
|
10391 | return document.createElement('sub');
|
10392 | } else {
|
10393 | return _get(Script.__proto__ || Object.getPrototypeOf(Script), 'create', this).call(this, value);
|
10394 | }
|
10395 | }
|
10396 | }, {
|
10397 | key: 'formats',
|
10398 | value: function formats(domNode) {
|
10399 | if (domNode.tagName === 'SUB') return 'sub';
|
10400 | if (domNode.tagName === 'SUP') return 'super';
|
10401 | return undefined;
|
10402 | }
|
10403 | }]);
|
10404 |
|
10405 | return Script;
|
10406 | }(_inline2.default);
|
10407 |
|
10408 | Script.blotName = 'script';
|
10409 | Script.tagName = ['SUB', 'SUP'];
|
10410 |
|
10411 | exports.default = Script;
|
10412 |
|
10413 | }),
|
10414 |
|
10415 | (function(module, exports, __webpack_require__) {
|
10416 |
|
10417 | "use strict";
|
10418 |
|
10419 |
|
10420 | Object.defineProperty(exports, "__esModule", {
|
10421 | value: true
|
10422 | });
|
10423 |
|
10424 | var _inline = __webpack_require__(6);
|
10425 |
|
10426 | var _inline2 = _interopRequireDefault(_inline);
|
10427 |
|
10428 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
10429 |
|
10430 | function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
10431 |
|
10432 | 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; }
|
10433 |
|
10434 | 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; }
|
10435 |
|
10436 | var Strike = function (_Inline) {
|
10437 | _inherits(Strike, _Inline);
|
10438 |
|
10439 | function Strike() {
|
10440 | _classCallCheck(this, Strike);
|
10441 |
|
10442 | return _possibleConstructorReturn(this, (Strike.__proto__ || Object.getPrototypeOf(Strike)).apply(this, arguments));
|
10443 | }
|
10444 |
|
10445 | return Strike;
|
10446 | }(_inline2.default);
|
10447 |
|
10448 | Strike.blotName = 'strike';
|
10449 | Strike.tagName = 'S';
|
10450 |
|
10451 | exports.default = Strike;
|
10452 |
|
10453 | }),
|
10454 |
|
10455 | (function(module, exports, __webpack_require__) {
|
10456 |
|
10457 | "use strict";
|
10458 |
|
10459 |
|
10460 | Object.defineProperty(exports, "__esModule", {
|
10461 | value: true
|
10462 | });
|
10463 |
|
10464 | var _inline = __webpack_require__(6);
|
10465 |
|
10466 | var _inline2 = _interopRequireDefault(_inline);
|
10467 |
|
10468 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
10469 |
|
10470 | function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
10471 |
|
10472 | 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; }
|
10473 |
|
10474 | 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; }
|
10475 |
|
10476 | var Underline = function (_Inline) {
|
10477 | _inherits(Underline, _Inline);
|
10478 |
|
10479 | function Underline() {
|
10480 | _classCallCheck(this, Underline);
|
10481 |
|
10482 | return _possibleConstructorReturn(this, (Underline.__proto__ || Object.getPrototypeOf(Underline)).apply(this, arguments));
|
10483 | }
|
10484 |
|
10485 | return Underline;
|
10486 | }(_inline2.default);
|
10487 |
|
10488 | Underline.blotName = 'underline';
|
10489 | Underline.tagName = 'U';
|
10490 |
|
10491 | exports.default = Underline;
|
10492 |
|
10493 | }),
|
10494 |
|
10495 | (function(module, exports, __webpack_require__) {
|
10496 |
|
10497 | "use strict";
|
10498 |
|
10499 |
|
10500 | Object.defineProperty(exports, "__esModule", {
|
10501 | value: true
|
10502 | });
|
10503 |
|
10504 | 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; }; }();
|
10505 |
|
10506 | 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); } };
|
10507 |
|
10508 | var _parchment = __webpack_require__(0);
|
10509 |
|
10510 | var _parchment2 = _interopRequireDefault(_parchment);
|
10511 |
|
10512 | var _link = __webpack_require__(27);
|
10513 |
|
10514 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
10515 |
|
10516 | function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
10517 |
|
10518 | 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; }
|
10519 |
|
10520 | 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; }
|
10521 |
|
10522 | var ATTRIBUTES = ['alt', 'height', 'width'];
|
10523 |
|
10524 | var Image = function (_Parchment$Embed) {
|
10525 | _inherits(Image, _Parchment$Embed);
|
10526 |
|
10527 | function Image() {
|
10528 | _classCallCheck(this, Image);
|
10529 |
|
10530 | return _possibleConstructorReturn(this, (Image.__proto__ || Object.getPrototypeOf(Image)).apply(this, arguments));
|
10531 | }
|
10532 |
|
10533 | _createClass(Image, [{
|
10534 | key: 'format',
|
10535 | value: function format(name, value) {
|
10536 | if (ATTRIBUTES.indexOf(name) > -1) {
|
10537 | if (value) {
|
10538 | this.domNode.setAttribute(name, value);
|
10539 | } else {
|
10540 | this.domNode.removeAttribute(name);
|
10541 | }
|
10542 | } else {
|
10543 | _get(Image.prototype.__proto__ || Object.getPrototypeOf(Image.prototype), 'format', this).call(this, name, value);
|
10544 | }
|
10545 | }
|
10546 | }], [{
|
10547 | key: 'create',
|
10548 | value: function create(value) {
|
10549 | var node = _get(Image.__proto__ || Object.getPrototypeOf(Image), 'create', this).call(this, value);
|
10550 | if (typeof value === 'string') {
|
10551 | node.setAttribute('src', this.sanitize(value));
|
10552 | }
|
10553 | return node;
|
10554 | }
|
10555 | }, {
|
10556 | key: 'formats',
|
10557 | value: function formats(domNode) {
|
10558 | return ATTRIBUTES.reduce(function (formats, attribute) {
|
10559 | if (domNode.hasAttribute(attribute)) {
|
10560 | formats[attribute] = domNode.getAttribute(attribute);
|
10561 | }
|
10562 | return formats;
|
10563 | }, {});
|
10564 | }
|
10565 | }, {
|
10566 | key: 'match',
|
10567 | value: function match(url) {
|
10568 | return (/\.(jpe?g|gif|png)$/.test(url) || /^data:image\/.+;base64/.test(url)
|
10569 | );
|
10570 | }
|
10571 | }, {
|
10572 | key: 'sanitize',
|
10573 | value: function sanitize(url) {
|
10574 | return (0, _link.sanitize)(url, ['http', 'https', 'data']) ? url : '//:0';
|
10575 | }
|
10576 | }, {
|
10577 | key: 'value',
|
10578 | value: function value(domNode) {
|
10579 | return domNode.getAttribute('src');
|
10580 | }
|
10581 | }]);
|
10582 |
|
10583 | return Image;
|
10584 | }(_parchment2.default.Embed);
|
10585 |
|
10586 | Image.blotName = 'image';
|
10587 | Image.tagName = 'IMG';
|
10588 |
|
10589 | exports.default = Image;
|
10590 |
|
10591 | }),
|
10592 |
|
10593 | (function(module, exports, __webpack_require__) {
|
10594 |
|
10595 | "use strict";
|
10596 |
|
10597 |
|
10598 | Object.defineProperty(exports, "__esModule", {
|
10599 | value: true
|
10600 | });
|
10601 |
|
10602 | 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; }; }();
|
10603 |
|
10604 | 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); } };
|
10605 |
|
10606 | var _block = __webpack_require__(4);
|
10607 |
|
10608 | var _link = __webpack_require__(27);
|
10609 |
|
10610 | var _link2 = _interopRequireDefault(_link);
|
10611 |
|
10612 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
10613 |
|
10614 | function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
10615 |
|
10616 | 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; }
|
10617 |
|
10618 | 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; }
|
10619 |
|
10620 | var ATTRIBUTES = ['height', 'width'];
|
10621 |
|
10622 | var Video = function (_BlockEmbed) {
|
10623 | _inherits(Video, _BlockEmbed);
|
10624 |
|
10625 | function Video() {
|
10626 | _classCallCheck(this, Video);
|
10627 |
|
10628 | return _possibleConstructorReturn(this, (Video.__proto__ || Object.getPrototypeOf(Video)).apply(this, arguments));
|
10629 | }
|
10630 |
|
10631 | _createClass(Video, [{
|
10632 | key: 'format',
|
10633 | value: function format(name, value) {
|
10634 | if (ATTRIBUTES.indexOf(name) > -1) {
|
10635 | if (value) {
|
10636 | this.domNode.setAttribute(name, value);
|
10637 | } else {
|
10638 | this.domNode.removeAttribute(name);
|
10639 | }
|
10640 | } else {
|
10641 | _get(Video.prototype.__proto__ || Object.getPrototypeOf(Video.prototype), 'format', this).call(this, name, value);
|
10642 | }
|
10643 | }
|
10644 | }], [{
|
10645 | key: 'create',
|
10646 | value: function create(value) {
|
10647 | var node = _get(Video.__proto__ || Object.getPrototypeOf(Video), 'create', this).call(this, value);
|
10648 | node.setAttribute('frameborder', '0');
|
10649 | node.setAttribute('allowfullscreen', true);
|
10650 | node.setAttribute('src', this.sanitize(value));
|
10651 | return node;
|
10652 | }
|
10653 | }, {
|
10654 | key: 'formats',
|
10655 | value: function formats(domNode) {
|
10656 | return ATTRIBUTES.reduce(function (formats, attribute) {
|
10657 | if (domNode.hasAttribute(attribute)) {
|
10658 | formats[attribute] = domNode.getAttribute(attribute);
|
10659 | }
|
10660 | return formats;
|
10661 | }, {});
|
10662 | }
|
10663 | }, {
|
10664 | key: 'sanitize',
|
10665 | value: function sanitize(url) {
|
10666 | return _link2.default.sanitize(url);
|
10667 | }
|
10668 | }, {
|
10669 | key: 'value',
|
10670 | value: function value(domNode) {
|
10671 | return domNode.getAttribute('src');
|
10672 | }
|
10673 | }]);
|
10674 |
|
10675 | return Video;
|
10676 | }(_block.BlockEmbed);
|
10677 |
|
10678 | Video.blotName = 'video';
|
10679 | Video.className = 'ql-video';
|
10680 | Video.tagName = 'IFRAME';
|
10681 |
|
10682 | exports.default = Video;
|
10683 |
|
10684 | }),
|
10685 |
|
10686 | (function(module, exports, __webpack_require__) {
|
10687 |
|
10688 | "use strict";
|
10689 |
|
10690 |
|
10691 | Object.defineProperty(exports, "__esModule", {
|
10692 | value: true
|
10693 | });
|
10694 | exports.default = exports.FormulaBlot = undefined;
|
10695 |
|
10696 | 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; }; }();
|
10697 |
|
10698 | 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); } };
|
10699 |
|
10700 | var _embed = __webpack_require__(25);
|
10701 |
|
10702 | var _embed2 = _interopRequireDefault(_embed);
|
10703 |
|
10704 | var _quill = __webpack_require__(5);
|
10705 |
|
10706 | var _quill2 = _interopRequireDefault(_quill);
|
10707 |
|
10708 | var _module = __webpack_require__(9);
|
10709 |
|
10710 | var _module2 = _interopRequireDefault(_module);
|
10711 |
|
10712 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
10713 |
|
10714 | function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
10715 |
|
10716 | 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; }
|
10717 |
|
10718 | 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; }
|
10719 |
|
10720 | var FormulaBlot = function (_Embed) {
|
10721 | _inherits(FormulaBlot, _Embed);
|
10722 |
|
10723 | function FormulaBlot() {
|
10724 | _classCallCheck(this, FormulaBlot);
|
10725 |
|
10726 | return _possibleConstructorReturn(this, (FormulaBlot.__proto__ || Object.getPrototypeOf(FormulaBlot)).apply(this, arguments));
|
10727 | }
|
10728 |
|
10729 | _createClass(FormulaBlot, null, [{
|
10730 | key: 'create',
|
10731 | value: function create(value) {
|
10732 | var node = _get(FormulaBlot.__proto__ || Object.getPrototypeOf(FormulaBlot), 'create', this).call(this, value);
|
10733 | if (typeof value === 'string') {
|
10734 | window.katex.render(value, node);
|
10735 | node.setAttribute('data-value', value);
|
10736 | }
|
10737 | return node;
|
10738 | }
|
10739 | }, {
|
10740 | key: 'value',
|
10741 | value: function value(domNode) {
|
10742 | return domNode.getAttribute('data-value');
|
10743 | }
|
10744 | }]);
|
10745 |
|
10746 | return FormulaBlot;
|
10747 | }(_embed2.default);
|
10748 |
|
10749 | FormulaBlot.blotName = 'formula';
|
10750 | FormulaBlot.className = 'ql-formula';
|
10751 | FormulaBlot.tagName = 'SPAN';
|
10752 |
|
10753 | var Formula = function (_Module) {
|
10754 | _inherits(Formula, _Module);
|
10755 |
|
10756 | _createClass(Formula, null, [{
|
10757 | key: 'register',
|
10758 | value: function register() {
|
10759 | _quill2.default.register(FormulaBlot, true);
|
10760 | }
|
10761 | }]);
|
10762 |
|
10763 | function Formula() {
|
10764 | _classCallCheck(this, Formula);
|
10765 |
|
10766 | var _this2 = _possibleConstructorReturn(this, (Formula.__proto__ || Object.getPrototypeOf(Formula)).call(this));
|
10767 |
|
10768 | if (window.katex == null) {
|
10769 | throw new Error('Formula module requires KaTeX.');
|
10770 | }
|
10771 | return _this2;
|
10772 | }
|
10773 |
|
10774 | return Formula;
|
10775 | }(_module2.default);
|
10776 |
|
10777 | exports.FormulaBlot = FormulaBlot;
|
10778 | exports.default = Formula;
|
10779 |
|
10780 | }),
|
10781 |
|
10782 | (function(module, exports, __webpack_require__) {
|
10783 |
|
10784 | "use strict";
|
10785 |
|
10786 |
|
10787 | Object.defineProperty(exports, "__esModule", {
|
10788 | value: true
|
10789 | });
|
10790 | exports.default = exports.CodeToken = exports.CodeBlock = undefined;
|
10791 |
|
10792 | 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; }; }();
|
10793 |
|
10794 | 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); } };
|
10795 |
|
10796 | var _parchment = __webpack_require__(0);
|
10797 |
|
10798 | var _parchment2 = _interopRequireDefault(_parchment);
|
10799 |
|
10800 | var _quill = __webpack_require__(5);
|
10801 |
|
10802 | var _quill2 = _interopRequireDefault(_quill);
|
10803 |
|
10804 | var _module = __webpack_require__(9);
|
10805 |
|
10806 | var _module2 = _interopRequireDefault(_module);
|
10807 |
|
10808 | var _code = __webpack_require__(13);
|
10809 |
|
10810 | var _code2 = _interopRequireDefault(_code);
|
10811 |
|
10812 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
10813 |
|
10814 | function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
10815 |
|
10816 | 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; }
|
10817 |
|
10818 | 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; }
|
10819 |
|
10820 | var SyntaxCodeBlock = function (_CodeBlock) {
|
10821 | _inherits(SyntaxCodeBlock, _CodeBlock);
|
10822 |
|
10823 | function SyntaxCodeBlock() {
|
10824 | _classCallCheck(this, SyntaxCodeBlock);
|
10825 |
|
10826 | return _possibleConstructorReturn(this, (SyntaxCodeBlock.__proto__ || Object.getPrototypeOf(SyntaxCodeBlock)).apply(this, arguments));
|
10827 | }
|
10828 |
|
10829 | _createClass(SyntaxCodeBlock, [{
|
10830 | key: 'replaceWith',
|
10831 | value: function replaceWith(block) {
|
10832 | this.domNode.textContent = this.domNode.textContent;
|
10833 | this.attach();
|
10834 | _get(SyntaxCodeBlock.prototype.__proto__ || Object.getPrototypeOf(SyntaxCodeBlock.prototype), 'replaceWith', this).call(this, block);
|
10835 | }
|
10836 | }, {
|
10837 | key: 'highlight',
|
10838 | value: function highlight(_highlight) {
|
10839 | var text = this.domNode.textContent;
|
10840 | if (this.cachedText !== text) {
|
10841 | if (text.trim().length > 0 || this.cachedText == null) {
|
10842 | this.domNode.innerHTML = _highlight(text);
|
10843 | this.domNode.normalize();
|
10844 | this.attach();
|
10845 | }
|
10846 | this.cachedText = text;
|
10847 | }
|
10848 | }
|
10849 | }]);
|
10850 |
|
10851 | return SyntaxCodeBlock;
|
10852 | }(_code2.default);
|
10853 |
|
10854 | SyntaxCodeBlock.className = 'ql-syntax';
|
10855 |
|
10856 | var CodeToken = new _parchment2.default.Attributor.Class('token', 'hljs', {
|
10857 | scope: _parchment2.default.Scope.INLINE
|
10858 | });
|
10859 |
|
10860 | var Syntax = function (_Module) {
|
10861 | _inherits(Syntax, _Module);
|
10862 |
|
10863 | _createClass(Syntax, null, [{
|
10864 | key: 'register',
|
10865 | value: function register() {
|
10866 | _quill2.default.register(CodeToken, true);
|
10867 | _quill2.default.register(SyntaxCodeBlock, true);
|
10868 | }
|
10869 | }]);
|
10870 |
|
10871 | function Syntax(quill, options) {
|
10872 | _classCallCheck(this, Syntax);
|
10873 |
|
10874 | var _this2 = _possibleConstructorReturn(this, (Syntax.__proto__ || Object.getPrototypeOf(Syntax)).call(this, quill, options));
|
10875 |
|
10876 | if (typeof _this2.options.highlight !== 'function') {
|
10877 | throw new Error('Syntax module requires highlight.js. Please include the library on the page before Quill.');
|
10878 | }
|
10879 | var timer = null;
|
10880 | _this2.quill.on(_quill2.default.events.SCROLL_OPTIMIZE, function () {
|
10881 | clearTimeout(timer);
|
10882 | timer = setTimeout(function () {
|
10883 | _this2.highlight();
|
10884 | timer = null;
|
10885 | }, _this2.options.interval);
|
10886 | });
|
10887 | _this2.highlight();
|
10888 | return _this2;
|
10889 | }
|
10890 |
|
10891 | _createClass(Syntax, [{
|
10892 | key: 'highlight',
|
10893 | value: function highlight() {
|
10894 | var _this3 = this;
|
10895 |
|
10896 | if (this.quill.selection.composing) return;
|
10897 | this.quill.update(_quill2.default.sources.USER);
|
10898 | var range = this.quill.getSelection();
|
10899 | this.quill.scroll.descendants(SyntaxCodeBlock).forEach(function (code) {
|
10900 | code.highlight(_this3.options.highlight);
|
10901 | });
|
10902 | this.quill.update(_quill2.default.sources.SILENT);
|
10903 | if (range != null) {
|
10904 | this.quill.setSelection(range, _quill2.default.sources.SILENT);
|
10905 | }
|
10906 | }
|
10907 | }]);
|
10908 |
|
10909 | return Syntax;
|
10910 | }(_module2.default);
|
10911 |
|
10912 | Syntax.DEFAULTS = {
|
10913 | highlight: function () {
|
10914 | if (window.hljs == null) return null;
|
10915 | return function (text) {
|
10916 | var result = window.hljs.highlightAuto(text);
|
10917 | return result.value;
|
10918 | };
|
10919 | }(),
|
10920 | interval: 1000
|
10921 | };
|
10922 |
|
10923 | exports.CodeBlock = SyntaxCodeBlock;
|
10924 | exports.CodeToken = CodeToken;
|
10925 | exports.default = Syntax;
|
10926 |
|
10927 | }),
|
10928 |
|
10929 | (function(module, exports) {
|
10930 |
|
10931 | module.exports = "<svg viewbox=\"0 0 18 18\"> <line class=ql-stroke x1=3 x2=15 y1=9 y2=9></line> <line class=ql-stroke x1=3 x2=13 y1=14 y2=14></line> <line class=ql-stroke x1=3 x2=9 y1=4 y2=4></line> </svg>";
|
10932 |
|
10933 | }),
|
10934 |
|
10935 | (function(module, exports) {
|
10936 |
|
10937 | module.exports = "<svg viewbox=\"0 0 18 18\"> <line class=ql-stroke x1=15 x2=3 y1=9 y2=9></line> <line class=ql-stroke x1=14 x2=4 y1=14 y2=14></line> <line class=ql-stroke x1=12 x2=6 y1=4 y2=4></line> </svg>";
|
10938 |
|
10939 | }),
|
10940 |
|
10941 | (function(module, exports) {
|
10942 |
|
10943 | module.exports = "<svg viewbox=\"0 0 18 18\"> <line class=ql-stroke x1=15 x2=3 y1=9 y2=9></line> <line class=ql-stroke x1=15 x2=5 y1=14 y2=14></line> <line class=ql-stroke x1=15 x2=9 y1=4 y2=4></line> </svg>";
|
10944 |
|
10945 | }),
|
10946 |
|
10947 | (function(module, exports) {
|
10948 |
|
10949 | module.exports = "<svg viewbox=\"0 0 18 18\"> <line class=ql-stroke x1=15 x2=3 y1=9 y2=9></line> <line class=ql-stroke x1=15 x2=3 y1=14 y2=14></line> <line class=ql-stroke x1=15 x2=3 y1=4 y2=4></line> </svg>";
|
10950 |
|
10951 | }),
|
10952 |
|
10953 | (function(module, exports) {
|
10954 |
|
10955 | module.exports = "<svg viewbox=\"0 0 18 18\"> <g class=\"ql-fill ql-color-label\"> <polygon points=\"6 6.868 6 6 5 6 5 7 5.942 7 6 6.868\"></polygon> <rect height=1 width=1 x=4 y=4></rect> <polygon points=\"6.817 5 6 5 6 6 6.38 6 6.817 5\"></polygon> <rect height=1 width=1 x=2 y=6></rect> <rect height=1 width=1 x=3 y=5></rect> <rect height=1 width=1 x=4 y=7></rect> <polygon points=\"4 11.439 4 11 3 11 3 12 3.755 12 4 11.439\"></polygon> <rect height=1 width=1 x=2 y=12></rect> <rect height=1 width=1 x=2 y=9></rect> <rect height=1 width=1 x=2 y=15></rect> <polygon points=\"4.63 10 4 10 4 11 4.192 11 4.63 10\"></polygon> <rect height=1 width=1 x=3 y=8></rect> <path d=M10.832,4.2L11,4.582V4H10.708A1.948,1.948,0,0,1,10.832,4.2Z></path> <path d=M7,4.582L7.168,4.2A1.929,1.929,0,0,1,7.292,4H7V4.582Z></path> <path d=M8,13H7.683l-0.351.8a1.933,1.933,0,0,1-.124.2H8V13Z></path> <rect height=1 width=1 x=12 y=2></rect> <rect height=1 width=1 x=11 y=3></rect> <path d=M9,3H8V3.282A1.985,1.985,0,0,1,9,3Z></path> <rect height=1 width=1 x=2 y=3></rect> <rect height=1 width=1 x=6 y=2></rect> <rect height=1 width=1 x=3 y=2></rect> <rect height=1 width=1 x=5 y=3></rect> <rect height=1 width=1 x=9 y=2></rect> <rect height=1 width=1 x=15 y=14></rect> <polygon points=\"13.447 10.174 13.469 10.225 13.472 10.232 13.808 11 14 11 14 10 13.37 10 13.447 10.174\"></polygon> <rect height=1 width=1 x=13 y=7></rect> <rect height=1 width=1 x=15 y=5></rect> <rect height=1 width=1 x=14 y=6></rect> <rect height=1 width=1 x=15 y=8></rect> <rect height=1 width=1 x=14 y=9></rect> <path d=M3.775,14H3v1H4V14.314A1.97,1.97,0,0,1,3.775,14Z></path> <rect height=1 width=1 x=14 y=3></rect> <polygon points=\"12 6.868 12 6 11.62 6 12 6.868\"></polygon> <rect height=1 width=1 x=15 y=2></rect> <rect height=1 width=1 x=12 y=5></rect> <rect height=1 width=1 x=13 y=4></rect> <polygon points=\"12.933 9 13 9 13 8 12.495 8 12.933 9\"></polygon> <rect height=1 width=1 x=9 y=14></rect> <rect height=1 width=1 x=8 y=15></rect> <path d=M6,14.926V15H7V14.316A1.993,1.993,0,0,1,6,14.926Z></path> <rect height=1 width=1 x=5 y=15></rect> <path d=M10.668,13.8L10.317,13H10v1h0.792A1.947,1.947,0,0,1,10.668,13.8Z></path> <rect height=1 width=1 x=11 y=15></rect> <path d=M14.332,12.2a1.99,1.99,0,0,1,.166.8H15V12H14.245Z></path> <rect height=1 width=1 x=14 y=15></rect> <rect height=1 width=1 x=15 y=11></rect> </g> <polyline class=ql-stroke points=\"5.5 13 9 5 12.5 13\"></polyline> <line class=ql-stroke x1=11.63 x2=6.38 y1=11 y2=11></line> </svg>";
|
10956 |
|
10957 | }),
|
10958 |
|
10959 | (function(module, exports) {
|
10960 |
|
10961 | module.exports = "<svg viewbox=\"0 0 18 18\"> <rect class=\"ql-fill ql-stroke\" height=3 width=3 x=4 y=5></rect> <rect class=\"ql-fill ql-stroke\" height=3 width=3 x=11 y=5></rect> <path class=\"ql-even ql-fill ql-stroke\" d=M7,8c0,4.031-3,5-3,5></path> <path class=\"ql-even ql-fill ql-stroke\" d=M14,8c0,4.031-3,5-3,5></path> </svg>";
|
10962 |
|
10963 | }),
|
10964 |
|
10965 | (function(module, exports) {
|
10966 |
|
10967 | module.exports = "<svg viewbox=\"0 0 18 18\"> <path class=ql-stroke d=M5,4H9.5A2.5,2.5,0,0,1,12,6.5v0A2.5,2.5,0,0,1,9.5,9H5A0,0,0,0,1,5,9V4A0,0,0,0,1,5,4Z></path> <path class=ql-stroke d=M5,9h5.5A2.5,2.5,0,0,1,13,11.5v0A2.5,2.5,0,0,1,10.5,14H5a0,0,0,0,1,0,0V9A0,0,0,0,1,5,9Z></path> </svg>";
|
10968 |
|
10969 | }),
|
10970 |
|
10971 | (function(module, exports) {
|
10972 |
|
10973 | module.exports = "<svg class=\"\" viewbox=\"0 0 18 18\"> <line class=ql-stroke x1=5 x2=13 y1=3 y2=3></line> <line class=ql-stroke x1=6 x2=9.35 y1=12 y2=3></line> <line class=ql-stroke x1=11 x2=15 y1=11 y2=15></line> <line class=ql-stroke x1=15 x2=11 y1=11 y2=15></line> <rect class=ql-fill height=1 rx=0.5 ry=0.5 width=7 x=2 y=14></rect> </svg>";
|
10974 |
|
10975 | }),
|
10976 |
|
10977 | (function(module, exports) {
|
10978 |
|
10979 | module.exports = "<svg viewbox=\"0 0 18 18\"> <line class=\"ql-color-label ql-stroke ql-transparent\" x1=3 x2=15 y1=15 y2=15></line> <polyline class=ql-stroke points=\"5.5 11 9 3 12.5 11\"></polyline> <line class=ql-stroke x1=11.63 x2=6.38 y1=9 y2=9></line> </svg>";
|
10980 |
|
10981 | }),
|
10982 |
|
10983 | (function(module, exports) {
|
10984 |
|
10985 | module.exports = "<svg viewbox=\"0 0 18 18\"> <polygon class=\"ql-stroke ql-fill\" points=\"3 11 5 9 3 7 3 11\"></polygon> <line class=\"ql-stroke ql-fill\" x1=15 x2=11 y1=4 y2=4></line> <path class=ql-fill d=M11,3a3,3,0,0,0,0,6h1V3H11Z></path> <rect class=ql-fill height=11 width=1 x=11 y=4></rect> <rect class=ql-fill height=11 width=1 x=13 y=4></rect> </svg>";
|
10986 |
|
10987 | }),
|
10988 |
|
10989 | (function(module, exports) {
|
10990 |
|
10991 | module.exports = "<svg viewbox=\"0 0 18 18\"> <polygon class=\"ql-stroke ql-fill\" points=\"15 12 13 10 15 8 15 12\"></polygon> <line class=\"ql-stroke ql-fill\" x1=9 x2=5 y1=4 y2=4></line> <path class=ql-fill d=M5,3A3,3,0,0,0,5,9H6V3H5Z></path> <rect class=ql-fill height=11 width=1 x=5 y=4></rect> <rect class=ql-fill height=11 width=1 x=7 y=4></rect> </svg>";
|
10992 |
|
10993 | }),
|
10994 |
|
10995 | (function(module, exports) {
|
10996 |
|
10997 | module.exports = "<svg viewbox=\"0 0 18 18\"> <path class=ql-fill d=M14,16H4a1,1,0,0,1,0-2H14A1,1,0,0,1,14,16Z /> <path class=ql-fill d=M14,4H4A1,1,0,0,1,4,2H14A1,1,0,0,1,14,4Z /> <rect class=ql-fill x=3 y=6 width=12 height=6 rx=1 ry=1 /> </svg>";
|
10998 |
|
10999 | }),
|
11000 |
|
11001 | (function(module, exports) {
|
11002 |
|
11003 | module.exports = "<svg viewbox=\"0 0 18 18\"> <path class=ql-fill d=M13,16H5a1,1,0,0,1,0-2h8A1,1,0,0,1,13,16Z /> <path class=ql-fill d=M13,4H5A1,1,0,0,1,5,2h8A1,1,0,0,1,13,4Z /> <rect class=ql-fill x=2 y=6 width=14 height=6 rx=1 ry=1 /> </svg>";
|
11004 |
|
11005 | }),
|
11006 |
|
11007 | (function(module, exports) {
|
11008 |
|
11009 | module.exports = "<svg viewbox=\"0 0 18 18\"> <path class=ql-fill d=M15,8H13a1,1,0,0,1,0-2h2A1,1,0,0,1,15,8Z /> <path class=ql-fill d=M15,12H13a1,1,0,0,1,0-2h2A1,1,0,0,1,15,12Z /> <path class=ql-fill d=M15,16H5a1,1,0,0,1,0-2H15A1,1,0,0,1,15,16Z /> <path class=ql-fill d=M15,4H5A1,1,0,0,1,5,2H15A1,1,0,0,1,15,4Z /> <rect class=ql-fill x=2 y=6 width=8 height=6 rx=1 ry=1 /> </svg>";
|
11010 |
|
11011 | }),
|
11012 |
|
11013 | (function(module, exports) {
|
11014 |
|
11015 | module.exports = "<svg viewbox=\"0 0 18 18\"> <path class=ql-fill d=M5,8H3A1,1,0,0,1,3,6H5A1,1,0,0,1,5,8Z /> <path class=ql-fill d=M5,12H3a1,1,0,0,1,0-2H5A1,1,0,0,1,5,12Z /> <path class=ql-fill d=M13,16H3a1,1,0,0,1,0-2H13A1,1,0,0,1,13,16Z /> <path class=ql-fill d=M13,4H3A1,1,0,0,1,3,2H13A1,1,0,0,1,13,4Z /> <rect class=ql-fill x=8 y=6 width=8 height=6 rx=1 ry=1 transform=\"translate(24 18) rotate(-180)\"/> </svg>";
|
11016 |
|
11017 | }),
|
11018 |
|
11019 | (function(module, exports) {
|
11020 |
|
11021 | module.exports = "<svg viewbox=\"0 0 18 18\"> <path class=ql-fill d=M11.759,2.482a2.561,2.561,0,0,0-3.53.607A7.656,7.656,0,0,0,6.8,6.2C6.109,9.188,5.275,14.677,4.15,14.927a1.545,1.545,0,0,0-1.3-.933A0.922,0.922,0,0,0,2,15.036S1.954,16,4.119,16s3.091-2.691,3.7-5.553c0.177-.826.36-1.726,0.554-2.6L8.775,6.2c0.381-1.421.807-2.521,1.306-2.676a1.014,1.014,0,0,0,1.02.56A0.966,0.966,0,0,0,11.759,2.482Z></path> <rect class=ql-fill height=1.6 rx=0.8 ry=0.8 width=5 x=5.15 y=6.2></rect> <path class=ql-fill d=M13.663,12.027a1.662,1.662,0,0,1,.266-0.276q0.193,0.069.456,0.138a2.1,2.1,0,0,0,.535.069,1.075,1.075,0,0,0,.767-0.3,1.044,1.044,0,0,0,.314-0.8,0.84,0.84,0,0,0-.238-0.619,0.8,0.8,0,0,0-.594-0.239,1.154,1.154,0,0,0-.781.3,4.607,4.607,0,0,0-.781,1q-0.091.15-.218,0.346l-0.246.38c-0.068-.288-0.137-0.582-0.212-0.885-0.459-1.847-2.494-.984-2.941-0.8-0.482.2-.353,0.647-0.094,0.529a0.869,0.869,0,0,1,1.281.585c0.217,0.751.377,1.436,0.527,2.038a5.688,5.688,0,0,1-.362.467,2.69,2.69,0,0,1-.264.271q-0.221-.08-0.471-0.147a2.029,2.029,0,0,0-.522-0.066,1.079,1.079,0,0,0-.768.3A1.058,1.058,0,0,0,9,15.131a0.82,0.82,0,0,0,.832.852,1.134,1.134,0,0,0,.787-0.3,5.11,5.11,0,0,0,.776-0.993q0.141-.219.215-0.34c0.046-.076.122-0.194,0.223-0.346a2.786,2.786,0,0,0,.918,1.726,2.582,2.582,0,0,0,2.376-.185c0.317-.181.212-0.565,0-0.494A0.807,0.807,0,0,1,14.176,15a5.159,5.159,0,0,1-.913-2.446l0,0Q13.487,12.24,13.663,12.027Z></path> </svg>";
|
11022 |
|
11023 | }),
|
11024 |
|
11025 | (function(module, exports) {
|
11026 |
|
11027 | module.exports = "<svg viewbox=\"0 0 18 18\"> <line class=ql-stroke x1=3 x2=3 y1=4 y2=14></line> <line class=ql-stroke x1=11 x2=11 y1=4 y2=14></line> <line class=ql-stroke x1=11 x2=3 y1=9 y2=9></line> <line class=\"ql-stroke ql-thin\" x1=13.5 x2=15.5 y1=14.5 y2=14.5></line> <path class=ql-fill d=M14.5,15a0.5,0.5,0,0,1-.5-0.5V12.085l-0.276.138A0.5,0.5,0,0,1,13.053,12c-0.124-.247-0.023-0.324.224-0.447l1-.5A0.5,0.5,0,0,1,15,11.5v3A0.5,0.5,0,0,1,14.5,15Z></path> </svg>";
|
11028 |
|
11029 | }),
|
11030 |
|
11031 | (function(module, exports) {
|
11032 |
|
11033 | module.exports = "<svg viewbox=\"0 0 18 18\"> <line class=ql-stroke x1=3 x2=3 y1=4 y2=14></line> <line class=ql-stroke x1=11 x2=11 y1=4 y2=14></line> <line class=ql-stroke x1=11 x2=3 y1=9 y2=9></line> <path class=\"ql-stroke ql-thin\" d=M15.5,14.5h-2c0-.234,1.85-1.076,1.85-2.234a0.959,0.959,0,0,0-1.85-.109></path> </svg>";
|
11034 |
|
11035 | }),
|
11036 |
|
11037 | (function(module, exports) {
|
11038 |
|
11039 | module.exports = "<svg viewbox=\"0 0 18 18\"> <line class=ql-stroke x1=7 x2=13 y1=4 y2=4></line> <line class=ql-stroke x1=5 x2=11 y1=14 y2=14></line> <line class=ql-stroke x1=8 x2=10 y1=14 y2=4></line> </svg>";
|
11040 |
|
11041 | }),
|
11042 |
|
11043 | (function(module, exports) {
|
11044 |
|
11045 | module.exports = "<svg viewbox=\"0 0 18 18\"> <rect class=ql-stroke height=10 width=12 x=3 y=4></rect> <circle class=ql-fill cx=6 cy=7 r=1></circle> <polyline class=\"ql-even ql-fill\" points=\"5 12 5 11 7 9 8 10 11 7 13 9 13 12 5 12\"></polyline> </svg>";
|
11046 |
|
11047 | }),
|
11048 |
|
11049 | (function(module, exports) {
|
11050 |
|
11051 | module.exports = "<svg viewbox=\"0 0 18 18\"> <line class=ql-stroke x1=3 x2=15 y1=14 y2=14></line> <line class=ql-stroke x1=3 x2=15 y1=4 y2=4></line> <line class=ql-stroke x1=9 x2=15 y1=9 y2=9></line> <polyline class=\"ql-fill ql-stroke\" points=\"3 7 3 11 5 9 3 7\"></polyline> </svg>";
|
11052 |
|
11053 | }),
|
11054 |
|
11055 | (function(module, exports) {
|
11056 |
|
11057 | module.exports = "<svg viewbox=\"0 0 18 18\"> <line class=ql-stroke x1=3 x2=15 y1=14 y2=14></line> <line class=ql-stroke x1=3 x2=15 y1=4 y2=4></line> <line class=ql-stroke x1=9 x2=15 y1=9 y2=9></line> <polyline class=ql-stroke points=\"5 7 5 11 3 9 5 7\"></polyline> </svg>";
|
11058 |
|
11059 | }),
|
11060 |
|
11061 | (function(module, exports) {
|
11062 |
|
11063 | module.exports = "<svg viewbox=\"0 0 18 18\"> <line class=ql-stroke x1=7 x2=11 y1=7 y2=11></line> <path class=\"ql-even ql-stroke\" d=M8.9,4.577a3.476,3.476,0,0,1,.36,4.679A3.476,3.476,0,0,1,4.577,8.9C3.185,7.5,2.035,6.4,4.217,4.217S7.5,3.185,8.9,4.577Z></path> <path class=\"ql-even ql-stroke\" d=M13.423,9.1a3.476,3.476,0,0,0-4.679-.36,3.476,3.476,0,0,0,.36,4.679c1.392,1.392,2.5,2.542,4.679.36S14.815,10.5,13.423,9.1Z></path> </svg>";
|
11064 |
|
11065 | }),
|
11066 |
|
11067 | (function(module, exports) {
|
11068 |
|
11069 | module.exports = "<svg viewbox=\"0 0 18 18\"> <line class=ql-stroke x1=7 x2=15 y1=4 y2=4></line> <line class=ql-stroke x1=7 x2=15 y1=9 y2=9></line> <line class=ql-stroke x1=7 x2=15 y1=14 y2=14></line> <line class=\"ql-stroke ql-thin\" x1=2.5 x2=4.5 y1=5.5 y2=5.5></line> <path class=ql-fill d=M3.5,6A0.5,0.5,0,0,1,3,5.5V3.085l-0.276.138A0.5,0.5,0,0,1,2.053,3c-0.124-.247-0.023-0.324.224-0.447l1-.5A0.5,0.5,0,0,1,4,2.5v3A0.5,0.5,0,0,1,3.5,6Z></path> <path class=\"ql-stroke ql-thin\" d=M4.5,10.5h-2c0-.234,1.85-1.076,1.85-2.234A0.959,0.959,0,0,0,2.5,8.156></path> <path class=\"ql-stroke ql-thin\" d=M2.5,14.846a0.959,0.959,0,0,0,1.85-.109A0.7,0.7,0,0,0,3.75,14a0.688,0.688,0,0,0,.6-0.736,0.959,0.959,0,0,0-1.85-.109></path> </svg>";
|
11070 |
|
11071 | }),
|
11072 |
|
11073 | (function(module, exports) {
|
11074 |
|
11075 | module.exports = "<svg viewbox=\"0 0 18 18\"> <line class=ql-stroke x1=6 x2=15 y1=4 y2=4></line> <line class=ql-stroke x1=6 x2=15 y1=9 y2=9></line> <line class=ql-stroke x1=6 x2=15 y1=14 y2=14></line> <line class=ql-stroke x1=3 x2=3 y1=4 y2=4></line> <line class=ql-stroke x1=3 x2=3 y1=9 y2=9></line> <line class=ql-stroke x1=3 x2=3 y1=14 y2=14></line> </svg>";
|
11076 |
|
11077 | }),
|
11078 |
|
11079 | (function(module, exports) {
|
11080 |
|
11081 | module.exports = "<svg class=\"\" viewbox=\"0 0 18 18\"> <line class=ql-stroke x1=9 x2=15 y1=4 y2=4></line> <polyline class=ql-stroke points=\"3 4 4 5 6 3\"></polyline> <line class=ql-stroke x1=9 x2=15 y1=14 y2=14></line> <polyline class=ql-stroke points=\"3 14 4 15 6 13\"></polyline> <line class=ql-stroke x1=9 x2=15 y1=9 y2=9></line> <polyline class=ql-stroke points=\"3 9 4 10 6 8\"></polyline> </svg>";
|
11082 |
|
11083 | }),
|
11084 |
|
11085 | (function(module, exports) {
|
11086 |
|
11087 | module.exports = "<svg viewbox=\"0 0 18 18\"> <path class=ql-fill d=M15.5,15H13.861a3.858,3.858,0,0,0,1.914-2.975,1.8,1.8,0,0,0-1.6-1.751A1.921,1.921,0,0,0,12.021,11.7a0.50013,0.50013,0,1,0,.957.291h0a0.914,0.914,0,0,1,1.053-.725,0.81,0.81,0,0,1,.744.762c0,1.076-1.16971,1.86982-1.93971,2.43082A1.45639,1.45639,0,0,0,12,15.5a0.5,0.5,0,0,0,.5.5h3A0.5,0.5,0,0,0,15.5,15Z /> <path class=ql-fill d=M9.65,5.241a1,1,0,0,0-1.409.108L6,7.964,3.759,5.349A1,1,0,0,0,2.192,6.59178Q2.21541,6.6213,2.241,6.649L4.684,9.5,2.241,12.35A1,1,0,0,0,3.71,13.70722q0.02557-.02768.049-0.05722L6,11.036,8.241,13.65a1,1,0,1,0,1.567-1.24277Q9.78459,12.3777,9.759,12.35L7.316,9.5,9.759,6.651A1,1,0,0,0,9.65,5.241Z /> </svg>";
|
11088 |
|
11089 | }),
|
11090 |
|
11091 | (function(module, exports) {
|
11092 |
|
11093 | module.exports = "<svg viewbox=\"0 0 18 18\"> <path class=ql-fill d=M15.5,7H13.861a4.015,4.015,0,0,0,1.914-2.975,1.8,1.8,0,0,0-1.6-1.751A1.922,1.922,0,0,0,12.021,3.7a0.5,0.5,0,1,0,.957.291,0.917,0.917,0,0,1,1.053-.725,0.81,0.81,0,0,1,.744.762c0,1.077-1.164,1.925-1.934,2.486A1.423,1.423,0,0,0,12,7.5a0.5,0.5,0,0,0,.5.5h3A0.5,0.5,0,0,0,15.5,7Z /> <path class=ql-fill d=M9.651,5.241a1,1,0,0,0-1.41.108L6,7.964,3.759,5.349a1,1,0,1,0-1.519,1.3L4.683,9.5,2.241,12.35a1,1,0,1,0,1.519,1.3L6,11.036,8.241,13.65a1,1,0,0,0,1.519-1.3L7.317,9.5,9.759,6.651A1,1,0,0,0,9.651,5.241Z /> </svg>";
|
11094 |
|
11095 | }),
|
11096 |
|
11097 | (function(module, exports) {
|
11098 |
|
11099 | module.exports = "<svg viewbox=\"0 0 18 18\"> <line class=\"ql-stroke ql-thin\" x1=15.5 x2=2.5 y1=8.5 y2=9.5></line> <path class=ql-fill d=M9.007,8C6.542,7.791,6,7.519,6,6.5,6,5.792,7.283,5,9,5c1.571,0,2.765.679,2.969,1.309a1,1,0,0,0,1.9-.617C13.356,4.106,11.354,3,9,3,6.2,3,4,4.538,4,6.5a3.2,3.2,0,0,0,.5,1.843Z></path> <path class=ql-fill d=M8.984,10C11.457,10.208,12,10.479,12,11.5c0,0.708-1.283,1.5-3,1.5-1.571,0-2.765-.679-2.969-1.309a1,1,0,1,0-1.9.617C4.644,13.894,6.646,15,9,15c2.8,0,5-1.538,5-3.5a3.2,3.2,0,0,0-.5-1.843Z></path> </svg>";
|
11100 |
|
11101 | }),
|
11102 |
|
11103 | (function(module, exports) {
|
11104 |
|
11105 | module.exports = "<svg viewbox=\"0 0 18 18\"> <path class=ql-stroke d=M5,3V9a4.012,4.012,0,0,0,4,4H9a4.012,4.012,0,0,0,4-4V3></path> <rect class=ql-fill height=1 rx=0.5 ry=0.5 width=12 x=3 y=15></rect> </svg>";
|
11106 |
|
11107 | }),
|
11108 |
|
11109 | (function(module, exports) {
|
11110 |
|
11111 | module.exports = "<svg viewbox=\"0 0 18 18\"> <rect class=ql-stroke height=12 width=12 x=3 y=3></rect> <rect class=ql-fill height=12 width=1 x=5 y=3></rect> <rect class=ql-fill height=12 width=1 x=12 y=3></rect> <rect class=ql-fill height=2 width=8 x=5 y=8></rect> <rect class=ql-fill height=1 width=3 x=3 y=5></rect> <rect class=ql-fill height=1 width=3 x=3 y=7></rect> <rect class=ql-fill height=1 width=3 x=3 y=10></rect> <rect class=ql-fill height=1 width=3 x=3 y=12></rect> <rect class=ql-fill height=1 width=3 x=12 y=5></rect> <rect class=ql-fill height=1 width=3 x=12 y=7></rect> <rect class=ql-fill height=1 width=3 x=12 y=10></rect> <rect class=ql-fill height=1 width=3 x=12 y=12></rect> </svg>";
|
11112 |
|
11113 | }),
|
11114 |
|
11115 | (function(module, exports) {
|
11116 |
|
11117 | module.exports = "<svg viewbox=\"0 0 18 18\"> <polygon class=ql-stroke points=\"7 11 9 13 11 11 7 11\"></polygon> <polygon class=ql-stroke points=\"7 7 9 5 11 7 7 7\"></polygon> </svg>";
|
11118 |
|
11119 | }),
|
11120 |
|
11121 | (function(module, exports, __webpack_require__) {
|
11122 |
|
11123 | "use strict";
|
11124 |
|
11125 |
|
11126 | Object.defineProperty(exports, "__esModule", {
|
11127 | value: true
|
11128 | });
|
11129 | exports.default = exports.BubbleTooltip = undefined;
|
11130 |
|
11131 | 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); } };
|
11132 |
|
11133 | 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; }; }();
|
11134 |
|
11135 | var _extend = __webpack_require__(3);
|
11136 |
|
11137 | var _extend2 = _interopRequireDefault(_extend);
|
11138 |
|
11139 | var _emitter = __webpack_require__(8);
|
11140 |
|
11141 | var _emitter2 = _interopRequireDefault(_emitter);
|
11142 |
|
11143 | var _base = __webpack_require__(43);
|
11144 |
|
11145 | var _base2 = _interopRequireDefault(_base);
|
11146 |
|
11147 | var _selection = __webpack_require__(15);
|
11148 |
|
11149 | var _icons = __webpack_require__(41);
|
11150 |
|
11151 | var _icons2 = _interopRequireDefault(_icons);
|
11152 |
|
11153 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
11154 |
|
11155 | function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
11156 |
|
11157 | 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; }
|
11158 |
|
11159 | 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; }
|
11160 |
|
11161 | var TOOLBAR_CONFIG = [['bold', 'italic', 'link'], [{ header: 1 }, { header: 2 }, 'blockquote']];
|
11162 |
|
11163 | var BubbleTheme = function (_BaseTheme) {
|
11164 | _inherits(BubbleTheme, _BaseTheme);
|
11165 |
|
11166 | function BubbleTheme(quill, options) {
|
11167 | _classCallCheck(this, BubbleTheme);
|
11168 |
|
11169 | if (options.modules.toolbar != null && options.modules.toolbar.container == null) {
|
11170 | options.modules.toolbar.container = TOOLBAR_CONFIG;
|
11171 | }
|
11172 |
|
11173 | var _this = _possibleConstructorReturn(this, (BubbleTheme.__proto__ || Object.getPrototypeOf(BubbleTheme)).call(this, quill, options));
|
11174 |
|
11175 | _this.quill.container.classList.add('ql-bubble');
|
11176 | return _this;
|
11177 | }
|
11178 |
|
11179 | _createClass(BubbleTheme, [{
|
11180 | key: 'extendToolbar',
|
11181 | value: function extendToolbar(toolbar) {
|
11182 | this.tooltip = new BubbleTooltip(this.quill, this.options.bounds);
|
11183 | this.tooltip.root.appendChild(toolbar.container);
|
11184 | this.buildButtons([].slice.call(toolbar.container.querySelectorAll('button')), _icons2.default);
|
11185 | this.buildPickers([].slice.call(toolbar.container.querySelectorAll('select')), _icons2.default);
|
11186 | }
|
11187 | }]);
|
11188 |
|
11189 | return BubbleTheme;
|
11190 | }(_base2.default);
|
11191 |
|
11192 | BubbleTheme.DEFAULTS = (0, _extend2.default)(true, {}, _base2.default.DEFAULTS, {
|
11193 | modules: {
|
11194 | toolbar: {
|
11195 | handlers: {
|
11196 | link: function link(value) {
|
11197 | if (!value) {
|
11198 | this.quill.format('link', false);
|
11199 | } else {
|
11200 | this.quill.theme.tooltip.edit();
|
11201 | }
|
11202 | }
|
11203 | }
|
11204 | }
|
11205 | }
|
11206 | });
|
11207 |
|
11208 | var BubbleTooltip = function (_BaseTooltip) {
|
11209 | _inherits(BubbleTooltip, _BaseTooltip);
|
11210 |
|
11211 | function BubbleTooltip(quill, bounds) {
|
11212 | _classCallCheck(this, BubbleTooltip);
|
11213 |
|
11214 | var _this2 = _possibleConstructorReturn(this, (BubbleTooltip.__proto__ || Object.getPrototypeOf(BubbleTooltip)).call(this, quill, bounds));
|
11215 |
|
11216 | _this2.quill.on(_emitter2.default.events.EDITOR_CHANGE, function (type, range, oldRange, source) {
|
11217 | if (type !== _emitter2.default.events.SELECTION_CHANGE) return;
|
11218 | if (range != null && range.length > 0 && source === _emitter2.default.sources.USER) {
|
11219 | _this2.show();
|
11220 |
|
11221 | _this2.root.style.left = '0px';
|
11222 | _this2.root.style.width = '';
|
11223 | _this2.root.style.width = _this2.root.offsetWidth + 'px';
|
11224 | var lines = _this2.quill.getLines(range.index, range.length);
|
11225 | if (lines.length === 1) {
|
11226 | _this2.position(_this2.quill.getBounds(range));
|
11227 | } else {
|
11228 | var lastLine = lines[lines.length - 1];
|
11229 | var index = _this2.quill.getIndex(lastLine);
|
11230 | var length = Math.min(lastLine.length() - 1, range.index + range.length - index);
|
11231 | var _bounds = _this2.quill.getBounds(new _selection.Range(index, length));
|
11232 | _this2.position(_bounds);
|
11233 | }
|
11234 | } else if (document.activeElement !== _this2.textbox && _this2.quill.hasFocus()) {
|
11235 | _this2.hide();
|
11236 | }
|
11237 | });
|
11238 | return _this2;
|
11239 | }
|
11240 |
|
11241 | _createClass(BubbleTooltip, [{
|
11242 | key: 'listen',
|
11243 | value: function listen() {
|
11244 | var _this3 = this;
|
11245 |
|
11246 | _get(BubbleTooltip.prototype.__proto__ || Object.getPrototypeOf(BubbleTooltip.prototype), 'listen', this).call(this);
|
11247 | this.root.querySelector('.ql-close').addEventListener('click', function () {
|
11248 | _this3.root.classList.remove('ql-editing');
|
11249 | });
|
11250 | this.quill.on(_emitter2.default.events.SCROLL_OPTIMIZE, function () {
|
11251 |
|
11252 | setTimeout(function () {
|
11253 | if (_this3.root.classList.contains('ql-hidden')) return;
|
11254 | var range = _this3.quill.getSelection();
|
11255 | if (range != null) {
|
11256 | _this3.position(_this3.quill.getBounds(range));
|
11257 | }
|
11258 | }, 1);
|
11259 | });
|
11260 | }
|
11261 | }, {
|
11262 | key: 'cancel',
|
11263 | value: function cancel() {
|
11264 | this.show();
|
11265 | }
|
11266 | }, {
|
11267 | key: 'position',
|
11268 | value: function position(reference) {
|
11269 | var shift = _get(BubbleTooltip.prototype.__proto__ || Object.getPrototypeOf(BubbleTooltip.prototype), 'position', this).call(this, reference);
|
11270 | var arrow = this.root.querySelector('.ql-tooltip-arrow');
|
11271 | arrow.style.marginLeft = '';
|
11272 | if (shift === 0) return shift;
|
11273 | arrow.style.marginLeft = -1 * shift - arrow.offsetWidth / 2 + 'px';
|
11274 | }
|
11275 | }]);
|
11276 |
|
11277 | return BubbleTooltip;
|
11278 | }(_base.BaseTooltip);
|
11279 |
|
11280 | BubbleTooltip.TEMPLATE = ['<span class="ql-tooltip-arrow"></span>', '<div class="ql-tooltip-editor">', '<input type="text" data-formula="e=mc^2" data-link="https://quilljs.com" data-video="Embed URL">', '<a class="ql-close"></a>', '</div>'].join('');
|
11281 |
|
11282 | exports.BubbleTooltip = BubbleTooltip;
|
11283 | exports.default = BubbleTheme;
|
11284 |
|
11285 | }),
|
11286 |
|
11287 | (function(module, exports, __webpack_require__) {
|
11288 |
|
11289 | module.exports = __webpack_require__(63);
|
11290 |
|
11291 |
|
11292 | })
|
11293 | ]);
|
11294 | }); |
\ | No newline at end of file |