activeadmin_quill_editor 0.1.2 → 0.2.9
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/LICENSE.txt +1 -1
- data/README.md +22 -22
- data/Rakefile +12 -2
- data/app/assets/javascripts/activeadmin/quill_editor/quill.core.js +1117 -924
- data/app/assets/javascripts/activeadmin/quill_editor/quill.js +1296 -1014
- data/app/assets/javascripts/activeadmin/quill_editor/quill.min.js +2 -2
- data/app/assets/javascripts/activeadmin/quill_editor_input.js +27 -17
- data/app/assets/stylesheets/activeadmin/_quill_editor_input.scss +55 -0
- data/app/assets/stylesheets/activeadmin/quill_editor/quill.bubble.css +1 -1
- data/app/assets/stylesheets/activeadmin/quill_editor/quill.core.css +1 -1
- data/app/assets/stylesheets/activeadmin/quill_editor/quill.snow.css +1 -1
- data/lib/activeadmin/quill_editor.rb +2 -0
- data/lib/activeadmin/quill_editor/engine.rb +2 -0
- data/lib/activeadmin/quill_editor/version.rb +3 -1
- data/lib/activeadmin_quill_editor.rb +2 -0
- data/lib/formtastic/inputs/quill_editor_input.rb +7 -5
- metadata +135 -14
- data/.gitignore +0 -3
- data/Gemfile +0 -4
- data/activeadmin_quill_editor.gemspec +0 -19
- data/app/assets/stylesheets/activeadmin/_quill_editor_input.sass +0 -24
- data/screenshot.jpg +0 -0
@@ -1,5 +1,5 @@
|
|
1
1
|
/*!
|
2
|
-
* Quill Editor v1.3.
|
2
|
+
* Quill Editor v1.3.7
|
3
3
|
* https://quilljs.com/
|
4
4
|
* Copyright (c) 2014, Jason Chen
|
5
5
|
* Copyright (c) 2013, salesforce.com
|
@@ -13,7 +13,7 @@
|
|
13
13
|
exports["Quill"] = factory();
|
14
14
|
else
|
15
15
|
root["Quill"] = factory();
|
16
|
-
})(this, function() {
|
16
|
+
})(typeof self !== 'undefined' ? self : this, function() {
|
17
17
|
return /******/ (function(modules) { // webpackBootstrap
|
18
18
|
/******/ // The module cache
|
19
19
|
/******/ var installedModules = {};
|
@@ -117,8 +117,8 @@ var Parchment = {
|
|
117
117
|
Attribute: attributor_1.default,
|
118
118
|
Class: class_1.default,
|
119
119
|
Style: style_1.default,
|
120
|
-
Store: store_1.default
|
121
|
-
}
|
120
|
+
Store: store_1.default,
|
121
|
+
},
|
122
122
|
};
|
123
123
|
exports.default = Parchment;
|
124
124
|
|
@@ -172,16 +172,15 @@ var Scope;
|
|
172
172
|
Scope[Scope["INLINE_ATTRIBUTE"] = 5] = "INLINE_ATTRIBUTE";
|
173
173
|
Scope[Scope["ANY"] = 15] = "ANY";
|
174
174
|
})(Scope = exports.Scope || (exports.Scope = {}));
|
175
|
-
;
|
176
175
|
function create(input, value) {
|
177
176
|
var match = query(input);
|
178
177
|
if (match == null) {
|
179
178
|
throw new ParchmentError("Unable to create " + input + " blot");
|
180
179
|
}
|
181
180
|
var BlotClass = match;
|
182
|
-
var node =
|
183
|
-
|
184
|
-
|
181
|
+
var node =
|
182
|
+
// @ts-ignore
|
183
|
+
input instanceof Node || input['nodeType'] === Node.TEXT_NODE ? input : BlotClass.create(value);
|
185
184
|
return new BlotClass(node, value);
|
186
185
|
}
|
187
186
|
exports.create = create;
|
@@ -189,6 +188,7 @@ function find(node, bubble) {
|
|
189
188
|
if (bubble === void 0) { bubble = false; }
|
190
189
|
if (node == null)
|
191
190
|
return null;
|
191
|
+
// @ts-ignore
|
192
192
|
if (node[exports.DATA_KEY] != null)
|
193
193
|
return node[exports.DATA_KEY].blot;
|
194
194
|
if (bubble)
|
@@ -201,6 +201,7 @@ function query(query, scope) {
|
|
201
201
|
var match;
|
202
202
|
if (typeof query === 'string') {
|
203
203
|
match = types[query] || attributes[query];
|
204
|
+
// @ts-ignore
|
204
205
|
}
|
205
206
|
else if (query instanceof Text || query['nodeType'] === Node.TEXT_NODE) {
|
206
207
|
match = types['text'];
|
@@ -224,7 +225,8 @@ function query(query, scope) {
|
|
224
225
|
}
|
225
226
|
if (match == null)
|
226
227
|
return null;
|
227
|
-
|
228
|
+
// @ts-ignore
|
229
|
+
if (scope & Scope.LEVEL & match.scope && scope & Scope.TYPE & match.scope)
|
228
230
|
return match;
|
229
231
|
return null;
|
230
232
|
}
|
@@ -437,7 +439,19 @@ Delta.prototype.slice = function (start, end) {
|
|
437
439
|
Delta.prototype.compose = function (other) {
|
438
440
|
var thisIter = op.iterator(this.ops);
|
439
441
|
var otherIter = op.iterator(other.ops);
|
440
|
-
var
|
442
|
+
var ops = [];
|
443
|
+
var firstOther = otherIter.peek();
|
444
|
+
if (firstOther != null && typeof firstOther.retain === 'number' && firstOther.attributes == null) {
|
445
|
+
var firstLeft = firstOther.retain;
|
446
|
+
while (thisIter.peekType() === 'insert' && thisIter.peekLength() <= firstLeft) {
|
447
|
+
firstLeft -= thisIter.peekLength();
|
448
|
+
ops.push(thisIter.next());
|
449
|
+
}
|
450
|
+
if (firstOther.retain - firstLeft > 0) {
|
451
|
+
otherIter.next(firstOther.retain - firstLeft);
|
452
|
+
}
|
453
|
+
}
|
454
|
+
var delta = new Delta(ops);
|
441
455
|
while (thisIter.hasNext() || otherIter.hasNext()) {
|
442
456
|
if (otherIter.peekType() === 'insert') {
|
443
457
|
delta.push(otherIter.next());
|
@@ -458,6 +472,13 @@ Delta.prototype.compose = function (other) {
|
|
458
472
|
var attributes = op.attributes.compose(thisOp.attributes, otherOp.attributes, typeof thisOp.retain === 'number');
|
459
473
|
if (attributes) newOp.attributes = attributes;
|
460
474
|
delta.push(newOp);
|
475
|
+
|
476
|
+
// Optimization if rest of other is just retain
|
477
|
+
if (!otherIter.hasNext() && equal(delta.ops[delta.ops.length - 1], newOp)) {
|
478
|
+
var rest = new Delta(thisIter.rest());
|
479
|
+
return delta.concat(rest).chop();
|
480
|
+
}
|
481
|
+
|
461
482
|
// Other op should be delete, we could be an insert or retain
|
462
483
|
// Insert + delete cancels out
|
463
484
|
} else if (typeof otherOp['delete'] === 'number' && typeof thisOp.retain === 'number') {
|
@@ -615,6 +636,8 @@ module.exports = Delta;
|
|
615
636
|
|
616
637
|
var hasOwn = Object.prototype.hasOwnProperty;
|
617
638
|
var toStr = Object.prototype.toString;
|
639
|
+
var defineProperty = Object.defineProperty;
|
640
|
+
var gOPD = Object.getOwnPropertyDescriptor;
|
618
641
|
|
619
642
|
var isArray = function isArray(arr) {
|
620
643
|
if (typeof Array.isArray === 'function') {
|
@@ -644,6 +667,35 @@ var isPlainObject = function isPlainObject(obj) {
|
|
644
667
|
return typeof key === 'undefined' || hasOwn.call(obj, key);
|
645
668
|
};
|
646
669
|
|
670
|
+
// If name is '__proto__', and Object.defineProperty is available, define __proto__ as an own property on target
|
671
|
+
var setProperty = function setProperty(target, options) {
|
672
|
+
if (defineProperty && options.name === '__proto__') {
|
673
|
+
defineProperty(target, options.name, {
|
674
|
+
enumerable: true,
|
675
|
+
configurable: true,
|
676
|
+
value: options.newValue,
|
677
|
+
writable: true
|
678
|
+
});
|
679
|
+
} else {
|
680
|
+
target[options.name] = options.newValue;
|
681
|
+
}
|
682
|
+
};
|
683
|
+
|
684
|
+
// Return undefined instead of __proto__ if '__proto__' is not an own property
|
685
|
+
var getProperty = function getProperty(obj, name) {
|
686
|
+
if (name === '__proto__') {
|
687
|
+
if (!hasOwn.call(obj, name)) {
|
688
|
+
return void 0;
|
689
|
+
} else if (gOPD) {
|
690
|
+
// In early versions of node, obj['__proto__'] is buggy when obj has
|
691
|
+
// __proto__ as an own property. Object.getOwnPropertyDescriptor() works.
|
692
|
+
return gOPD(obj, name).value;
|
693
|
+
}
|
694
|
+
}
|
695
|
+
|
696
|
+
return obj[name];
|
697
|
+
};
|
698
|
+
|
647
699
|
module.exports = function extend() {
|
648
700
|
var options, name, src, copy, copyIsArray, clone;
|
649
701
|
var target = arguments[0];
|
@@ -668,8 +720,8 @@ module.exports = function extend() {
|
|
668
720
|
if (options != null) {
|
669
721
|
// Extend the base object
|
670
722
|
for (name in options) {
|
671
|
-
src = target
|
672
|
-
copy = options
|
723
|
+
src = getProperty(target, name);
|
724
|
+
copy = getProperty(options, name);
|
673
725
|
|
674
726
|
// Prevent never-ending loop
|
675
727
|
if (target !== copy) {
|
@@ -683,11 +735,11 @@ module.exports = function extend() {
|
|
683
735
|
}
|
684
736
|
|
685
737
|
// Never move original objects, clone them
|
686
|
-
target
|
738
|
+
setProperty(target, { name: name, newValue: extend(deep, clone, copy) });
|
687
739
|
|
688
740
|
// Don't bring in undefined values
|
689
741
|
} else if (typeof copy !== 'undefined') {
|
690
|
-
target
|
742
|
+
setProperty(target, { name: name, newValue: copy });
|
691
743
|
}
|
692
744
|
}
|
693
745
|
}
|
@@ -1531,7 +1583,7 @@ Quill.DEFAULTS = {
|
|
1531
1583
|
Quill.events = _emitter4.default.events;
|
1532
1584
|
Quill.sources = _emitter4.default.sources;
|
1533
1585
|
// eslint-disable-next-line no-undef
|
1534
|
-
Quill.version = false ? 'dev' : "1.3.
|
1586
|
+
Quill.version = false ? 'dev' : "1.3.7";
|
1535
1587
|
|
1536
1588
|
Quill.imports = {
|
1537
1589
|
'delta': _quillDelta2.default,
|
@@ -1852,7 +1904,7 @@ function _inherits(subClass, superClass) { if (typeof superClass !== "function"
|
|
1852
1904
|
|
1853
1905
|
var debug = (0, _logger2.default)('quill:events');
|
1854
1906
|
|
1855
|
-
var EVENTS = ['selectionchange', 'mousedown', 'mouseup'];
|
1907
|
+
var EVENTS = ['selectionchange', 'mousedown', 'mouseup', 'click'];
|
1856
1908
|
|
1857
1909
|
EVENTS.forEach(function (eventName) {
|
1858
1910
|
document.addEventListener(eventName, function () {
|
@@ -2136,17 +2188,26 @@ var Attributor = /** @class */ (function () {
|
|
2136
2188
|
};
|
2137
2189
|
Attributor.prototype.canAdd = function (node, value) {
|
2138
2190
|
var match = Registry.query(node, Registry.Scope.BLOT & (this.scope | Registry.Scope.TYPE));
|
2139
|
-
if (match
|
2191
|
+
if (match == null)
|
2192
|
+
return false;
|
2193
|
+
if (this.whitelist == null)
|
2140
2194
|
return true;
|
2195
|
+
if (typeof value === 'string') {
|
2196
|
+
return this.whitelist.indexOf(value.replace(/["']/g, '')) > -1;
|
2197
|
+
}
|
2198
|
+
else {
|
2199
|
+
return this.whitelist.indexOf(value) > -1;
|
2141
2200
|
}
|
2142
|
-
return false;
|
2143
2201
|
};
|
2144
2202
|
Attributor.prototype.remove = function (node) {
|
2145
2203
|
node.removeAttribute(this.keyName);
|
2146
2204
|
};
|
2147
2205
|
Attributor.prototype.value = function (node) {
|
2148
2206
|
var value = node.getAttribute(this.keyName);
|
2149
|
-
|
2207
|
+
if (this.canAdd(node, value) && value) {
|
2208
|
+
return value;
|
2209
|
+
}
|
2210
|
+
return '';
|
2150
2211
|
};
|
2151
2212
|
return Attributor;
|
2152
2213
|
}());
|
@@ -2388,7 +2449,7 @@ var _code = __webpack_require__(13);
|
|
2388
2449
|
|
2389
2450
|
var _code2 = _interopRequireDefault(_code);
|
2390
2451
|
|
2391
|
-
var _cursor = __webpack_require__(
|
2452
|
+
var _cursor = __webpack_require__(24);
|
2392
2453
|
|
2393
2454
|
var _cursor2 = _interopRequireDefault(_cursor);
|
2394
2455
|
|
@@ -3304,21 +3365,31 @@ var shadow_1 = __webpack_require__(30);
|
|
3304
3365
|
var Registry = __webpack_require__(1);
|
3305
3366
|
var ContainerBlot = /** @class */ (function (_super) {
|
3306
3367
|
__extends(ContainerBlot, _super);
|
3307
|
-
function ContainerBlot() {
|
3308
|
-
|
3368
|
+
function ContainerBlot(domNode) {
|
3369
|
+
var _this = _super.call(this, domNode) || this;
|
3370
|
+
_this.build();
|
3371
|
+
return _this;
|
3309
3372
|
}
|
3310
3373
|
ContainerBlot.prototype.appendChild = function (other) {
|
3311
3374
|
this.insertBefore(other);
|
3312
3375
|
};
|
3313
3376
|
ContainerBlot.prototype.attach = function () {
|
3314
|
-
var _this = this;
|
3315
3377
|
_super.prototype.attach.call(this);
|
3378
|
+
this.children.forEach(function (child) {
|
3379
|
+
child.attach();
|
3380
|
+
});
|
3381
|
+
};
|
3382
|
+
ContainerBlot.prototype.build = function () {
|
3383
|
+
var _this = this;
|
3316
3384
|
this.children = new linked_list_1.default();
|
3317
3385
|
// Need to be reversed for if DOM nodes already in order
|
3318
|
-
[].slice
|
3386
|
+
[].slice
|
3387
|
+
.call(this.domNode.childNodes)
|
3388
|
+
.reverse()
|
3389
|
+
.forEach(function (node) {
|
3319
3390
|
try {
|
3320
3391
|
var child = makeBlot(node);
|
3321
|
-
_this.insertBefore(child, _this.children.head);
|
3392
|
+
_this.insertBefore(child, _this.children.head || undefined);
|
3322
3393
|
}
|
3323
3394
|
catch (err) {
|
3324
3395
|
if (err instanceof Registry.ParchmentError)
|
@@ -3352,7 +3423,8 @@ var ContainerBlot = /** @class */ (function (_super) {
|
|
3352
3423
|
ContainerBlot.prototype.descendants = function (criteria, index, length) {
|
3353
3424
|
if (index === void 0) { index = 0; }
|
3354
3425
|
if (length === void 0) { length = Number.MAX_VALUE; }
|
3355
|
-
var descendants = []
|
3426
|
+
var descendants = [];
|
3427
|
+
var lengthLeft = length;
|
3356
3428
|
this.children.forEachAt(index, length, function (child, index, length) {
|
3357
3429
|
if ((criteria.blotName == null && criteria(child)) ||
|
3358
3430
|
(criteria.blotName != null && child instanceof criteria)) {
|
@@ -3382,14 +3454,15 @@ var ContainerBlot = /** @class */ (function (_super) {
|
|
3382
3454
|
child.insertAt(offset, value, def);
|
3383
3455
|
}
|
3384
3456
|
else {
|
3385
|
-
var blot =
|
3457
|
+
var blot = def == null ? Registry.create('text', value) : Registry.create(value, def);
|
3386
3458
|
this.appendChild(blot);
|
3387
3459
|
}
|
3388
3460
|
};
|
3389
3461
|
ContainerBlot.prototype.insertBefore = function (childBlot, refBlot) {
|
3390
|
-
if (this.statics.allowedChildren != null &&
|
3391
|
-
|
3392
|
-
|
3462
|
+
if (this.statics.allowedChildren != null &&
|
3463
|
+
!this.statics.allowedChildren.some(function (child) {
|
3464
|
+
return childBlot instanceof child;
|
3465
|
+
})) {
|
3393
3466
|
throw new Registry.ParchmentError("Cannot insert " + childBlot.statics.blotName + " into " + this.statics.blotName);
|
3394
3467
|
}
|
3395
3468
|
childBlot.insertInto(this, refBlot);
|
@@ -3460,7 +3533,8 @@ var ContainerBlot = /** @class */ (function (_super) {
|
|
3460
3533
|
};
|
3461
3534
|
ContainerBlot.prototype.update = function (mutations, context) {
|
3462
3535
|
var _this = this;
|
3463
|
-
var addedNodes = []
|
3536
|
+
var addedNodes = [];
|
3537
|
+
var removedNodes = [];
|
3464
3538
|
mutations.forEach(function (mutation) {
|
3465
3539
|
if (mutation.target === _this.domNode && mutation.type === 'childList') {
|
3466
3540
|
addedNodes.push.apply(addedNodes, mutation.addedNodes);
|
@@ -3471,8 +3545,10 @@ var ContainerBlot = /** @class */ (function (_super) {
|
|
3471
3545
|
// Check node has actually been removed
|
3472
3546
|
// One exception is Chrome does not immediately remove IFRAMEs
|
3473
3547
|
// from DOM but MutationRecord is correct in its reported removal
|
3474
|
-
if (node.parentNode != null &&
|
3475
|
-
|
3548
|
+
if (node.parentNode != null &&
|
3549
|
+
// @ts-ignore
|
3550
|
+
node.tagName !== 'IFRAME' &&
|
3551
|
+
document.body.compareDocumentPosition(node) & Node.DOCUMENT_POSITION_CONTAINED_BY) {
|
3476
3552
|
return;
|
3477
3553
|
}
|
3478
3554
|
var blot = Registry.find(node);
|
@@ -3482,16 +3558,19 @@ var ContainerBlot = /** @class */ (function (_super) {
|
|
3482
3558
|
blot.detach();
|
3483
3559
|
}
|
3484
3560
|
});
|
3485
|
-
addedNodes
|
3561
|
+
addedNodes
|
3562
|
+
.filter(function (node) {
|
3486
3563
|
return node.parentNode == _this.domNode;
|
3487
|
-
})
|
3564
|
+
})
|
3565
|
+
.sort(function (a, b) {
|
3488
3566
|
if (a === b)
|
3489
3567
|
return 0;
|
3490
3568
|
if (a.compareDocumentPosition(b) & Node.DOCUMENT_POSITION_FOLLOWING) {
|
3491
3569
|
return 1;
|
3492
3570
|
}
|
3493
3571
|
return -1;
|
3494
|
-
})
|
3572
|
+
})
|
3573
|
+
.forEach(function (node) {
|
3495
3574
|
var refBlot = null;
|
3496
3575
|
if (node.nextSibling != null) {
|
3497
3576
|
refBlot = Registry.find(node.nextSibling);
|
@@ -3501,7 +3580,7 @@ var ContainerBlot = /** @class */ (function (_super) {
|
|
3501
3580
|
if (blot.parent != null) {
|
3502
3581
|
blot.parent.removeChild(_this);
|
3503
3582
|
}
|
3504
|
-
_this.insertBefore(blot, refBlot);
|
3583
|
+
_this.insertBefore(blot, refBlot || undefined);
|
3505
3584
|
}
|
3506
3585
|
});
|
3507
3586
|
};
|
@@ -3516,9 +3595,12 @@ function makeBlot(node) {
|
|
3516
3595
|
catch (e) {
|
3517
3596
|
blot = Registry.create(Registry.Scope.INLINE);
|
3518
3597
|
[].slice.call(node.childNodes).forEach(function (child) {
|
3598
|
+
// @ts-ignore
|
3519
3599
|
blot.domNode.appendChild(child);
|
3520
3600
|
});
|
3521
|
-
node.parentNode
|
3601
|
+
if (node.parentNode) {
|
3602
|
+
node.parentNode.replaceChild(blot.domNode, node);
|
3603
|
+
}
|
3522
3604
|
blot.attach();
|
3523
3605
|
}
|
3524
3606
|
}
|
@@ -3550,8 +3632,10 @@ var container_1 = __webpack_require__(17);
|
|
3550
3632
|
var Registry = __webpack_require__(1);
|
3551
3633
|
var FormatBlot = /** @class */ (function (_super) {
|
3552
3634
|
__extends(FormatBlot, _super);
|
3553
|
-
function FormatBlot() {
|
3554
|
-
|
3635
|
+
function FormatBlot(domNode) {
|
3636
|
+
var _this = _super.call(this, domNode) || this;
|
3637
|
+
_this.attributes = new store_1.default(_this.domNode);
|
3638
|
+
return _this;
|
3555
3639
|
}
|
3556
3640
|
FormatBlot.formats = function (domNode) {
|
3557
3641
|
if (typeof this.tagName === 'string') {
|
@@ -3562,10 +3646,6 @@ var FormatBlot = /** @class */ (function (_super) {
|
|
3562
3646
|
}
|
3563
3647
|
return undefined;
|
3564
3648
|
};
|
3565
|
-
FormatBlot.prototype.attach = function () {
|
3566
|
-
_super.prototype.attach.call(this);
|
3567
|
-
this.attributes = new store_1.default(this.domNode);
|
3568
|
-
};
|
3569
3649
|
FormatBlot.prototype.format = function (name, value) {
|
3570
3650
|
var format = Registry.query(name);
|
3571
3651
|
if (format instanceof attributor_1.default) {
|
@@ -3652,8 +3732,8 @@ var LeafBlot = /** @class */ (function (_super) {
|
|
3652
3732
|
return [this.parent.domNode, offset];
|
3653
3733
|
};
|
3654
3734
|
LeafBlot.prototype.value = function () {
|
3655
|
-
return _a = {}, _a[this.statics.blotName] = this.statics.value(this.domNode) || true, _a;
|
3656
3735
|
var _a;
|
3736
|
+
return _a = {}, _a[this.statics.blotName] = this.statics.value(this.domNode) || true, _a;
|
3657
3737
|
};
|
3658
3738
|
LeafBlot.scope = Registry.Scope.INLINE_BLOT;
|
3659
3739
|
return LeafBlot;
|
@@ -3802,6 +3882,22 @@ Iterator.prototype.peekType = function () {
|
|
3802
3882
|
return 'retain';
|
3803
3883
|
};
|
3804
3884
|
|
3885
|
+
Iterator.prototype.rest = function () {
|
3886
|
+
if (!this.hasNext()) {
|
3887
|
+
return [];
|
3888
|
+
} else if (this.offset === 0) {
|
3889
|
+
return this.ops.slice(this.index);
|
3890
|
+
} else {
|
3891
|
+
var offset = this.offset;
|
3892
|
+
var index = this.index;
|
3893
|
+
var next = this.next();
|
3894
|
+
var rest = this.ops.slice(this.index);
|
3895
|
+
this.offset = offset;
|
3896
|
+
this.index = index;
|
3897
|
+
return [next].concat(rest);
|
3898
|
+
}
|
3899
|
+
};
|
3900
|
+
|
3805
3901
|
|
3806
3902
|
module.exports = lib;
|
3807
3903
|
|
@@ -3916,7 +4012,13 @@ function clone(parent, circular, depth, prototype, includeNonEnumerable) {
|
|
3916
4012
|
} else if (clone.__isDate(parent)) {
|
3917
4013
|
child = new Date(parent.getTime());
|
3918
4014
|
} else if (useBuffer && Buffer.isBuffer(parent)) {
|
3919
|
-
|
4015
|
+
if (Buffer.allocUnsafe) {
|
4016
|
+
// Node.js >= 4.5.0
|
4017
|
+
child = Buffer.allocUnsafe(parent.length);
|
4018
|
+
} else {
|
4019
|
+
// Older Node.js versions
|
4020
|
+
child = new Buffer(parent.length);
|
4021
|
+
}
|
3920
4022
|
parent.copy(child);
|
3921
4023
|
return child;
|
3922
4024
|
} else if (_instanceof(parent, Error)) {
|
@@ -4100,7 +4202,7 @@ var _code = __webpack_require__(13);
|
|
4100
4202
|
|
4101
4203
|
var _code2 = _interopRequireDefault(_code);
|
4102
4204
|
|
4103
|
-
var _container = __webpack_require__(
|
4205
|
+
var _container = __webpack_require__(25);
|
4104
4206
|
|
4105
4207
|
var _container2 = _interopRequireDefault(_container);
|
4106
4208
|
|
@@ -4326,224 +4428,604 @@ exports.default = Scroll;
|
|
4326
4428
|
Object.defineProperty(exports, "__esModule", {
|
4327
4429
|
value: true
|
4328
4430
|
});
|
4431
|
+
exports.SHORTKEY = exports.default = undefined;
|
4329
4432
|
|
4330
|
-
var
|
4433
|
+
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; };
|
4331
4434
|
|
4332
|
-
var
|
4435
|
+
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"); } }; }();
|
4333
4436
|
|
4334
4437
|
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; }; }();
|
4335
4438
|
|
4439
|
+
var _clone = __webpack_require__(21);
|
4440
|
+
|
4441
|
+
var _clone2 = _interopRequireDefault(_clone);
|
4442
|
+
|
4443
|
+
var _deepEqual = __webpack_require__(11);
|
4444
|
+
|
4445
|
+
var _deepEqual2 = _interopRequireDefault(_deepEqual);
|
4446
|
+
|
4447
|
+
var _extend = __webpack_require__(3);
|
4448
|
+
|
4449
|
+
var _extend2 = _interopRequireDefault(_extend);
|
4450
|
+
|
4451
|
+
var _quillDelta = __webpack_require__(2);
|
4452
|
+
|
4453
|
+
var _quillDelta2 = _interopRequireDefault(_quillDelta);
|
4454
|
+
|
4455
|
+
var _op = __webpack_require__(20);
|
4456
|
+
|
4457
|
+
var _op2 = _interopRequireDefault(_op);
|
4458
|
+
|
4336
4459
|
var _parchment = __webpack_require__(0);
|
4337
4460
|
|
4338
4461
|
var _parchment2 = _interopRequireDefault(_parchment);
|
4339
4462
|
|
4340
|
-
var
|
4463
|
+
var _quill = __webpack_require__(5);
|
4341
4464
|
|
4342
|
-
var
|
4465
|
+
var _quill2 = _interopRequireDefault(_quill);
|
4466
|
+
|
4467
|
+
var _logger = __webpack_require__(10);
|
4468
|
+
|
4469
|
+
var _logger2 = _interopRequireDefault(_logger);
|
4470
|
+
|
4471
|
+
var _module = __webpack_require__(9);
|
4472
|
+
|
4473
|
+
var _module2 = _interopRequireDefault(_module);
|
4343
4474
|
|
4344
4475
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
4345
4476
|
|
4477
|
+
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; }
|
4478
|
+
|
4346
4479
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
4347
4480
|
|
4348
4481
|
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; }
|
4349
4482
|
|
4350
4483
|
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; }
|
4351
4484
|
|
4352
|
-
var
|
4353
|
-
_inherits(Cursor, _Parchment$Embed);
|
4485
|
+
var debug = (0, _logger2.default)('quill:keyboard');
|
4354
4486
|
|
4355
|
-
|
4356
|
-
|
4357
|
-
|
4358
|
-
|
4487
|
+
var SHORTKEY = /Mac/i.test(navigator.platform) ? 'metaKey' : 'ctrlKey';
|
4488
|
+
|
4489
|
+
var Keyboard = function (_Module) {
|
4490
|
+
_inherits(Keyboard, _Module);
|
4491
|
+
|
4492
|
+
_createClass(Keyboard, null, [{
|
4493
|
+
key: 'match',
|
4494
|
+
value: function match(evt, binding) {
|
4495
|
+
binding = normalize(binding);
|
4496
|
+
if (['altKey', 'ctrlKey', 'metaKey', 'shiftKey'].some(function (key) {
|
4497
|
+
return !!binding[key] !== evt[key] && binding[key] !== null;
|
4498
|
+
})) {
|
4499
|
+
return false;
|
4500
|
+
}
|
4501
|
+
return binding.key === (evt.which || evt.keyCode);
|
4359
4502
|
}
|
4360
4503
|
}]);
|
4361
4504
|
|
4362
|
-
function
|
4363
|
-
_classCallCheck(this,
|
4505
|
+
function Keyboard(quill, options) {
|
4506
|
+
_classCallCheck(this, Keyboard);
|
4364
4507
|
|
4365
|
-
var _this = _possibleConstructorReturn(this, (
|
4508
|
+
var _this = _possibleConstructorReturn(this, (Keyboard.__proto__ || Object.getPrototypeOf(Keyboard)).call(this, quill, options));
|
4366
4509
|
|
4367
|
-
_this.
|
4368
|
-
_this.
|
4369
|
-
|
4370
|
-
|
4510
|
+
_this.bindings = {};
|
4511
|
+
Object.keys(_this.options.bindings).forEach(function (name) {
|
4512
|
+
if (name === 'list autofill' && quill.scroll.whitelist != null && !quill.scroll.whitelist['list']) {
|
4513
|
+
return;
|
4514
|
+
}
|
4515
|
+
if (_this.options.bindings[name]) {
|
4516
|
+
_this.addBinding(_this.options.bindings[name]);
|
4517
|
+
}
|
4518
|
+
});
|
4519
|
+
_this.addBinding({ key: Keyboard.keys.ENTER, shiftKey: null }, handleEnter);
|
4520
|
+
_this.addBinding({ key: Keyboard.keys.ENTER, metaKey: null, ctrlKey: null, altKey: null }, function () {});
|
4521
|
+
if (/Firefox/i.test(navigator.userAgent)) {
|
4522
|
+
// Need to handle delete and backspace for Firefox in the general case #1171
|
4523
|
+
_this.addBinding({ key: Keyboard.keys.BACKSPACE }, { collapsed: true }, handleBackspace);
|
4524
|
+
_this.addBinding({ key: Keyboard.keys.DELETE }, { collapsed: true }, handleDelete);
|
4525
|
+
} else {
|
4526
|
+
_this.addBinding({ key: Keyboard.keys.BACKSPACE }, { collapsed: true, prefix: /^.?$/ }, handleBackspace);
|
4527
|
+
_this.addBinding({ key: Keyboard.keys.DELETE }, { collapsed: true, suffix: /^.?$/ }, handleDelete);
|
4528
|
+
}
|
4529
|
+
_this.addBinding({ key: Keyboard.keys.BACKSPACE }, { collapsed: false }, handleDeleteRange);
|
4530
|
+
_this.addBinding({ key: Keyboard.keys.DELETE }, { collapsed: false }, handleDeleteRange);
|
4531
|
+
_this.addBinding({ key: Keyboard.keys.BACKSPACE, altKey: null, ctrlKey: null, metaKey: null, shiftKey: null }, { collapsed: true, offset: 0 }, handleBackspace);
|
4532
|
+
_this.listen();
|
4371
4533
|
return _this;
|
4372
4534
|
}
|
4373
4535
|
|
4374
|
-
_createClass(
|
4375
|
-
key: '
|
4376
|
-
value: function
|
4377
|
-
|
4378
|
-
|
4379
|
-
|
4380
|
-
|
4381
|
-
|
4382
|
-
|
4383
|
-
if (this._length !== 0) {
|
4384
|
-
return _get(Cursor.prototype.__proto__ || Object.getPrototypeOf(Cursor.prototype), 'format', this).call(this, name, value);
|
4536
|
+
_createClass(Keyboard, [{
|
4537
|
+
key: 'addBinding',
|
4538
|
+
value: function addBinding(key) {
|
4539
|
+
var context = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
4540
|
+
var handler = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
4541
|
+
|
4542
|
+
var binding = normalize(key);
|
4543
|
+
if (binding == null || binding.key == null) {
|
4544
|
+
return debug.warn('Attempted to add invalid keyboard binding', binding);
|
4385
4545
|
}
|
4386
|
-
|
4387
|
-
|
4388
|
-
while (target != null && target.statics.scope !== _parchment2.default.Scope.BLOCK_BLOT) {
|
4389
|
-
index += target.offset(target.parent);
|
4390
|
-
target = target.parent;
|
4546
|
+
if (typeof context === 'function') {
|
4547
|
+
context = { handler: context };
|
4391
4548
|
}
|
4392
|
-
if (
|
4393
|
-
|
4394
|
-
target.optimize();
|
4395
|
-
target.formatAt(index, Cursor.CONTENTS.length, name, value);
|
4396
|
-
this._length = 0;
|
4549
|
+
if (typeof handler === 'function') {
|
4550
|
+
handler = { handler: handler };
|
4397
4551
|
}
|
4552
|
+
binding = (0, _extend2.default)(binding, context, handler);
|
4553
|
+
this.bindings[binding.key] = this.bindings[binding.key] || [];
|
4554
|
+
this.bindings[binding.key].push(binding);
|
4398
4555
|
}
|
4399
4556
|
}, {
|
4400
|
-
key: '
|
4401
|
-
value: function
|
4402
|
-
|
4403
|
-
return _get(Cursor.prototype.__proto__ || Object.getPrototypeOf(Cursor.prototype), 'index', this).call(this, node, offset);
|
4404
|
-
}
|
4405
|
-
}, {
|
4406
|
-
key: 'length',
|
4407
|
-
value: function length() {
|
4408
|
-
return this._length;
|
4409
|
-
}
|
4410
|
-
}, {
|
4411
|
-
key: 'position',
|
4412
|
-
value: function position() {
|
4413
|
-
return [this.textNode, this.textNode.data.length];
|
4414
|
-
}
|
4415
|
-
}, {
|
4416
|
-
key: 'remove',
|
4417
|
-
value: function remove() {
|
4418
|
-
_get(Cursor.prototype.__proto__ || Object.getPrototypeOf(Cursor.prototype), 'remove', this).call(this);
|
4419
|
-
this.parent = null;
|
4420
|
-
}
|
4421
|
-
}, {
|
4422
|
-
key: 'restore',
|
4423
|
-
value: function restore() {
|
4424
|
-
if (this.selection.composing || this.parent == null) return;
|
4425
|
-
var textNode = this.textNode;
|
4426
|
-
var range = this.selection.getNativeRange();
|
4427
|
-
var restoreText = void 0,
|
4428
|
-
start = void 0,
|
4429
|
-
end = void 0;
|
4430
|
-
if (range != null && range.start.node === textNode && range.end.node === textNode) {
|
4431
|
-
var _ref = [textNode, range.start.offset, range.end.offset];
|
4432
|
-
restoreText = _ref[0];
|
4433
|
-
start = _ref[1];
|
4434
|
-
end = _ref[2];
|
4435
|
-
}
|
4436
|
-
// Link format will insert text outside of anchor tag
|
4437
|
-
while (this.domNode.lastChild != null && this.domNode.lastChild !== this.textNode) {
|
4438
|
-
this.domNode.parentNode.insertBefore(this.domNode.lastChild, this.domNode);
|
4439
|
-
}
|
4440
|
-
if (this.textNode.data !== Cursor.CONTENTS) {
|
4441
|
-
var text = this.textNode.data.split(Cursor.CONTENTS).join('');
|
4442
|
-
if (this.next instanceof _text2.default) {
|
4443
|
-
restoreText = this.next.domNode;
|
4444
|
-
this.next.insertAt(0, text);
|
4445
|
-
this.textNode.data = Cursor.CONTENTS;
|
4446
|
-
} else {
|
4447
|
-
this.textNode.data = text;
|
4448
|
-
this.parent.insertBefore(_parchment2.default.create(this.textNode), this);
|
4449
|
-
this.textNode = document.createTextNode(Cursor.CONTENTS);
|
4450
|
-
this.domNode.appendChild(this.textNode);
|
4451
|
-
}
|
4452
|
-
}
|
4453
|
-
this.remove();
|
4454
|
-
if (start != null) {
|
4455
|
-
var _map = [start, end].map(function (offset) {
|
4456
|
-
return Math.max(0, Math.min(restoreText.data.length, offset - 1));
|
4457
|
-
});
|
4557
|
+
key: 'listen',
|
4558
|
+
value: function listen() {
|
4559
|
+
var _this2 = this;
|
4458
4560
|
|
4459
|
-
|
4561
|
+
this.quill.root.addEventListener('keydown', function (evt) {
|
4562
|
+
if (evt.defaultPrevented) return;
|
4563
|
+
var which = evt.which || evt.keyCode;
|
4564
|
+
var bindings = (_this2.bindings[which] || []).filter(function (binding) {
|
4565
|
+
return Keyboard.match(evt, binding);
|
4566
|
+
});
|
4567
|
+
if (bindings.length === 0) return;
|
4568
|
+
var range = _this2.quill.getSelection();
|
4569
|
+
if (range == null || !_this2.quill.hasFocus()) return;
|
4460
4570
|
|
4461
|
-
|
4462
|
-
|
4571
|
+
var _quill$getLine = _this2.quill.getLine(range.index),
|
4572
|
+
_quill$getLine2 = _slicedToArray(_quill$getLine, 2),
|
4573
|
+
line = _quill$getLine2[0],
|
4574
|
+
offset = _quill$getLine2[1];
|
4463
4575
|
|
4464
|
-
|
4465
|
-
|
4466
|
-
|
4467
|
-
|
4468
|
-
endOffset: end
|
4469
|
-
};
|
4470
|
-
}
|
4471
|
-
}
|
4472
|
-
}, {
|
4473
|
-
key: 'update',
|
4474
|
-
value: function update(mutations, context) {
|
4475
|
-
var _this2 = this;
|
4576
|
+
var _quill$getLeaf = _this2.quill.getLeaf(range.index),
|
4577
|
+
_quill$getLeaf2 = _slicedToArray(_quill$getLeaf, 2),
|
4578
|
+
leafStart = _quill$getLeaf2[0],
|
4579
|
+
offsetStart = _quill$getLeaf2[1];
|
4476
4580
|
|
4477
|
-
|
4478
|
-
|
4479
|
-
|
4480
|
-
|
4481
|
-
|
4482
|
-
|
4483
|
-
|
4484
|
-
|
4485
|
-
|
4486
|
-
|
4487
|
-
|
4581
|
+
var _ref = range.length === 0 ? [leafStart, offsetStart] : _this2.quill.getLeaf(range.index + range.length),
|
4582
|
+
_ref2 = _slicedToArray(_ref, 2),
|
4583
|
+
leafEnd = _ref2[0],
|
4584
|
+
offsetEnd = _ref2[1];
|
4585
|
+
|
4586
|
+
var prefixText = leafStart instanceof _parchment2.default.Text ? leafStart.value().slice(0, offsetStart) : '';
|
4587
|
+
var suffixText = leafEnd instanceof _parchment2.default.Text ? leafEnd.value().slice(offsetEnd) : '';
|
4588
|
+
var curContext = {
|
4589
|
+
collapsed: range.length === 0,
|
4590
|
+
empty: range.length === 0 && line.length() <= 1,
|
4591
|
+
format: _this2.quill.getFormat(range),
|
4592
|
+
offset: offset,
|
4593
|
+
prefix: prefixText,
|
4594
|
+
suffix: suffixText
|
4595
|
+
};
|
4596
|
+
var prevented = bindings.some(function (binding) {
|
4597
|
+
if (binding.collapsed != null && binding.collapsed !== curContext.collapsed) return false;
|
4598
|
+
if (binding.empty != null && binding.empty !== curContext.empty) return false;
|
4599
|
+
if (binding.offset != null && binding.offset !== curContext.offset) return false;
|
4600
|
+
if (Array.isArray(binding.format)) {
|
4601
|
+
// any format is present
|
4602
|
+
if (binding.format.every(function (name) {
|
4603
|
+
return curContext.format[name] == null;
|
4604
|
+
})) {
|
4605
|
+
return false;
|
4606
|
+
}
|
4607
|
+
} else if (_typeof(binding.format) === 'object') {
|
4608
|
+
// all formats must match
|
4609
|
+
if (!Object.keys(binding.format).every(function (name) {
|
4610
|
+
if (binding.format[name] === true) return curContext.format[name] != null;
|
4611
|
+
if (binding.format[name] === false) return curContext.format[name] == null;
|
4612
|
+
return (0, _deepEqual2.default)(binding.format[name], curContext.format[name]);
|
4613
|
+
})) {
|
4614
|
+
return false;
|
4615
|
+
}
|
4616
|
+
}
|
4617
|
+
if (binding.prefix != null && !binding.prefix.test(curContext.prefix)) return false;
|
4618
|
+
if (binding.suffix != null && !binding.suffix.test(curContext.suffix)) return false;
|
4619
|
+
return binding.handler.call(_this2, range, curContext) !== true;
|
4620
|
+
});
|
4621
|
+
if (prevented) {
|
4622
|
+
evt.preventDefault();
|
4623
|
+
}
|
4624
|
+
});
|
4488
4625
|
}
|
4489
4626
|
}]);
|
4490
4627
|
|
4491
|
-
return
|
4492
|
-
}(
|
4628
|
+
return Keyboard;
|
4629
|
+
}(_module2.default);
|
4493
4630
|
|
4494
|
-
|
4495
|
-
|
4496
|
-
|
4497
|
-
|
4631
|
+
Keyboard.keys = {
|
4632
|
+
BACKSPACE: 8,
|
4633
|
+
TAB: 9,
|
4634
|
+
ENTER: 13,
|
4635
|
+
ESCAPE: 27,
|
4636
|
+
LEFT: 37,
|
4637
|
+
UP: 38,
|
4638
|
+
RIGHT: 39,
|
4639
|
+
DOWN: 40,
|
4640
|
+
DELETE: 46
|
4641
|
+
};
|
4498
4642
|
|
4643
|
+
Keyboard.DEFAULTS = {
|
4644
|
+
bindings: {
|
4645
|
+
'bold': makeFormatHandler('bold'),
|
4646
|
+
'italic': makeFormatHandler('italic'),
|
4647
|
+
'underline': makeFormatHandler('underline'),
|
4648
|
+
'indent': {
|
4649
|
+
// highlight tab or tab at beginning of list, indent or blockquote
|
4650
|
+
key: Keyboard.keys.TAB,
|
4651
|
+
format: ['blockquote', 'indent', 'list'],
|
4652
|
+
handler: function handler(range, context) {
|
4653
|
+
if (context.collapsed && context.offset !== 0) return true;
|
4654
|
+
this.quill.format('indent', '+1', _quill2.default.sources.USER);
|
4655
|
+
}
|
4656
|
+
},
|
4657
|
+
'outdent': {
|
4658
|
+
key: Keyboard.keys.TAB,
|
4659
|
+
shiftKey: true,
|
4660
|
+
format: ['blockquote', 'indent', 'list'],
|
4661
|
+
// highlight tab or tab at beginning of list, indent or blockquote
|
4662
|
+
handler: function handler(range, context) {
|
4663
|
+
if (context.collapsed && context.offset !== 0) return true;
|
4664
|
+
this.quill.format('indent', '-1', _quill2.default.sources.USER);
|
4665
|
+
}
|
4666
|
+
},
|
4667
|
+
'outdent backspace': {
|
4668
|
+
key: Keyboard.keys.BACKSPACE,
|
4669
|
+
collapsed: true,
|
4670
|
+
shiftKey: null,
|
4671
|
+
metaKey: null,
|
4672
|
+
ctrlKey: null,
|
4673
|
+
altKey: null,
|
4674
|
+
format: ['indent', 'list'],
|
4675
|
+
offset: 0,
|
4676
|
+
handler: function handler(range, context) {
|
4677
|
+
if (context.format.indent != null) {
|
4678
|
+
this.quill.format('indent', '-1', _quill2.default.sources.USER);
|
4679
|
+
} else if (context.format.list != null) {
|
4680
|
+
this.quill.format('list', false, _quill2.default.sources.USER);
|
4681
|
+
}
|
4682
|
+
}
|
4683
|
+
},
|
4684
|
+
'indent code-block': makeCodeBlockHandler(true),
|
4685
|
+
'outdent code-block': makeCodeBlockHandler(false),
|
4686
|
+
'remove tab': {
|
4687
|
+
key: Keyboard.keys.TAB,
|
4688
|
+
shiftKey: true,
|
4689
|
+
collapsed: true,
|
4690
|
+
prefix: /\t$/,
|
4691
|
+
handler: function handler(range) {
|
4692
|
+
this.quill.deleteText(range.index - 1, 1, _quill2.default.sources.USER);
|
4693
|
+
}
|
4694
|
+
},
|
4695
|
+
'tab': {
|
4696
|
+
key: Keyboard.keys.TAB,
|
4697
|
+
handler: function handler(range) {
|
4698
|
+
this.quill.history.cutoff();
|
4699
|
+
var delta = new _quillDelta2.default().retain(range.index).delete(range.length).insert('\t');
|
4700
|
+
this.quill.updateContents(delta, _quill2.default.sources.USER);
|
4701
|
+
this.quill.history.cutoff();
|
4702
|
+
this.quill.setSelection(range.index + 1, _quill2.default.sources.SILENT);
|
4703
|
+
}
|
4704
|
+
},
|
4705
|
+
'list empty enter': {
|
4706
|
+
key: Keyboard.keys.ENTER,
|
4707
|
+
collapsed: true,
|
4708
|
+
format: ['list'],
|
4709
|
+
empty: true,
|
4710
|
+
handler: function handler(range, context) {
|
4711
|
+
this.quill.format('list', false, _quill2.default.sources.USER);
|
4712
|
+
if (context.format.indent) {
|
4713
|
+
this.quill.format('indent', false, _quill2.default.sources.USER);
|
4714
|
+
}
|
4715
|
+
}
|
4716
|
+
},
|
4717
|
+
'checklist enter': {
|
4718
|
+
key: Keyboard.keys.ENTER,
|
4719
|
+
collapsed: true,
|
4720
|
+
format: { list: 'checked' },
|
4721
|
+
handler: function handler(range) {
|
4722
|
+
var _quill$getLine3 = this.quill.getLine(range.index),
|
4723
|
+
_quill$getLine4 = _slicedToArray(_quill$getLine3, 2),
|
4724
|
+
line = _quill$getLine4[0],
|
4725
|
+
offset = _quill$getLine4[1];
|
4499
4726
|
|
4500
|
-
|
4727
|
+
var formats = (0, _extend2.default)({}, line.formats(), { list: 'checked' });
|
4728
|
+
var delta = new _quillDelta2.default().retain(range.index).insert('\n', formats).retain(line.length() - offset - 1).retain(1, { list: 'unchecked' });
|
4729
|
+
this.quill.updateContents(delta, _quill2.default.sources.USER);
|
4730
|
+
this.quill.setSelection(range.index + 1, _quill2.default.sources.SILENT);
|
4731
|
+
this.quill.scrollIntoView();
|
4732
|
+
}
|
4733
|
+
},
|
4734
|
+
'header enter': {
|
4735
|
+
key: Keyboard.keys.ENTER,
|
4736
|
+
collapsed: true,
|
4737
|
+
format: ['header'],
|
4738
|
+
suffix: /^$/,
|
4739
|
+
handler: function handler(range, context) {
|
4740
|
+
var _quill$getLine5 = this.quill.getLine(range.index),
|
4741
|
+
_quill$getLine6 = _slicedToArray(_quill$getLine5, 2),
|
4742
|
+
line = _quill$getLine6[0],
|
4743
|
+
offset = _quill$getLine6[1];
|
4501
4744
|
|
4502
|
-
|
4503
|
-
|
4504
|
-
|
4745
|
+
var delta = new _quillDelta2.default().retain(range.index).insert('\n', context.format).retain(line.length() - offset - 1).retain(1, { header: null });
|
4746
|
+
this.quill.updateContents(delta, _quill2.default.sources.USER);
|
4747
|
+
this.quill.setSelection(range.index + 1, _quill2.default.sources.SILENT);
|
4748
|
+
this.quill.scrollIntoView();
|
4749
|
+
}
|
4750
|
+
},
|
4751
|
+
'list autofill': {
|
4752
|
+
key: ' ',
|
4753
|
+
collapsed: true,
|
4754
|
+
format: { list: false },
|
4755
|
+
prefix: /^\s*?(\d+\.|-|\*|\[ ?\]|\[x\])$/,
|
4756
|
+
handler: function handler(range, context) {
|
4757
|
+
var length = context.prefix.length;
|
4505
4758
|
|
4506
|
-
|
4759
|
+
var _quill$getLine7 = this.quill.getLine(range.index),
|
4760
|
+
_quill$getLine8 = _slicedToArray(_quill$getLine7, 2),
|
4761
|
+
line = _quill$getLine8[0],
|
4762
|
+
offset = _quill$getLine8[1];
|
4507
4763
|
|
4764
|
+
if (offset > length) return true;
|
4765
|
+
var value = void 0;
|
4766
|
+
switch (context.prefix.trim()) {
|
4767
|
+
case '[]':case '[ ]':
|
4768
|
+
value = 'unchecked';
|
4769
|
+
break;
|
4770
|
+
case '[x]':
|
4771
|
+
value = 'checked';
|
4772
|
+
break;
|
4773
|
+
case '-':case '*':
|
4774
|
+
value = 'bullet';
|
4775
|
+
break;
|
4776
|
+
default:
|
4777
|
+
value = 'ordered';
|
4778
|
+
}
|
4779
|
+
this.quill.insertText(range.index, ' ', _quill2.default.sources.USER);
|
4780
|
+
this.quill.history.cutoff();
|
4781
|
+
var delta = new _quillDelta2.default().retain(range.index - offset).delete(length + 1).retain(line.length() - 2 - offset).retain(1, { list: value });
|
4782
|
+
this.quill.updateContents(delta, _quill2.default.sources.USER);
|
4783
|
+
this.quill.history.cutoff();
|
4784
|
+
this.quill.setSelection(range.index - length, _quill2.default.sources.SILENT);
|
4785
|
+
}
|
4786
|
+
},
|
4787
|
+
'code exit': {
|
4788
|
+
key: Keyboard.keys.ENTER,
|
4789
|
+
collapsed: true,
|
4790
|
+
format: ['code-block'],
|
4791
|
+
prefix: /\n\n$/,
|
4792
|
+
suffix: /^\s+$/,
|
4793
|
+
handler: function handler(range) {
|
4794
|
+
var _quill$getLine9 = this.quill.getLine(range.index),
|
4795
|
+
_quill$getLine10 = _slicedToArray(_quill$getLine9, 2),
|
4796
|
+
line = _quill$getLine10[0],
|
4797
|
+
offset = _quill$getLine10[1];
|
4508
4798
|
|
4509
|
-
|
4510
|
-
|
4511
|
-
}
|
4799
|
+
var delta = new _quillDelta2.default().retain(range.index + line.length() - offset - 2).retain(1, { 'code-block': null }).delete(1);
|
4800
|
+
this.quill.updateContents(delta, _quill2.default.sources.USER);
|
4801
|
+
}
|
4802
|
+
},
|
4803
|
+
'embed left': makeEmbedArrowHandler(Keyboard.keys.LEFT, false),
|
4804
|
+
'embed left shift': makeEmbedArrowHandler(Keyboard.keys.LEFT, true),
|
4805
|
+
'embed right': makeEmbedArrowHandler(Keyboard.keys.RIGHT, false),
|
4806
|
+
'embed right shift': makeEmbedArrowHandler(Keyboard.keys.RIGHT, true)
|
4807
|
+
}
|
4808
|
+
};
|
4512
4809
|
|
4513
|
-
|
4810
|
+
function makeEmbedArrowHandler(key, shiftKey) {
|
4811
|
+
var _ref3;
|
4514
4812
|
|
4515
|
-
var
|
4813
|
+
var where = key === Keyboard.keys.LEFT ? 'prefix' : 'suffix';
|
4814
|
+
return _ref3 = {
|
4815
|
+
key: key,
|
4816
|
+
shiftKey: shiftKey,
|
4817
|
+
altKey: null
|
4818
|
+
}, _defineProperty(_ref3, where, /^$/), _defineProperty(_ref3, 'handler', function handler(range) {
|
4819
|
+
var index = range.index;
|
4820
|
+
if (key === Keyboard.keys.RIGHT) {
|
4821
|
+
index += range.length + 1;
|
4822
|
+
}
|
4516
4823
|
|
4517
|
-
var
|
4824
|
+
var _quill$getLeaf3 = this.quill.getLeaf(index),
|
4825
|
+
_quill$getLeaf4 = _slicedToArray(_quill$getLeaf3, 1),
|
4826
|
+
leaf = _quill$getLeaf4[0];
|
4518
4827
|
|
4519
|
-
|
4828
|
+
if (!(leaf instanceof _parchment2.default.Embed)) return true;
|
4829
|
+
if (key === Keyboard.keys.LEFT) {
|
4830
|
+
if (shiftKey) {
|
4831
|
+
this.quill.setSelection(range.index - 1, range.length + 1, _quill2.default.sources.USER);
|
4832
|
+
} else {
|
4833
|
+
this.quill.setSelection(range.index - 1, _quill2.default.sources.USER);
|
4834
|
+
}
|
4835
|
+
} else {
|
4836
|
+
if (shiftKey) {
|
4837
|
+
this.quill.setSelection(range.index, range.length + 1, _quill2.default.sources.USER);
|
4838
|
+
} else {
|
4839
|
+
this.quill.setSelection(range.index + range.length + 1, _quill2.default.sources.USER);
|
4840
|
+
}
|
4841
|
+
}
|
4842
|
+
return false;
|
4843
|
+
}), _ref3;
|
4844
|
+
}
|
4520
4845
|
|
4521
|
-
function
|
4846
|
+
function handleBackspace(range, context) {
|
4847
|
+
if (range.index === 0 || this.quill.getLength() <= 1) return;
|
4522
4848
|
|
4523
|
-
|
4849
|
+
var _quill$getLine11 = this.quill.getLine(range.index),
|
4850
|
+
_quill$getLine12 = _slicedToArray(_quill$getLine11, 1),
|
4851
|
+
line = _quill$getLine12[0];
|
4524
4852
|
|
4525
|
-
|
4853
|
+
var formats = {};
|
4854
|
+
if (context.offset === 0) {
|
4855
|
+
var _quill$getLine13 = this.quill.getLine(range.index - 1),
|
4856
|
+
_quill$getLine14 = _slicedToArray(_quill$getLine13, 1),
|
4857
|
+
prev = _quill$getLine14[0];
|
4526
4858
|
|
4527
|
-
|
4859
|
+
if (prev != null && prev.length() > 1) {
|
4860
|
+
var curFormats = line.formats();
|
4861
|
+
var prevFormats = this.quill.getFormat(range.index - 1, 1);
|
4862
|
+
formats = _op2.default.attributes.diff(curFormats, prevFormats) || {};
|
4863
|
+
}
|
4864
|
+
}
|
4865
|
+
// Check for astral symbols
|
4866
|
+
var length = /[\uD800-\uDBFF][\uDC00-\uDFFF]$/.test(context.prefix) ? 2 : 1;
|
4867
|
+
this.quill.deleteText(range.index - length, length, _quill2.default.sources.USER);
|
4868
|
+
if (Object.keys(formats).length > 0) {
|
4869
|
+
this.quill.formatLine(range.index - length, length, formats, _quill2.default.sources.USER);
|
4870
|
+
}
|
4871
|
+
this.quill.focus();
|
4872
|
+
}
|
4528
4873
|
|
4529
|
-
|
4530
|
-
|
4874
|
+
function handleDelete(range, context) {
|
4875
|
+
// Check for astral symbols
|
4876
|
+
var length = /^[\uD800-\uDBFF][\uDC00-\uDFFF]/.test(context.suffix) ? 2 : 1;
|
4877
|
+
if (range.index >= this.quill.getLength() - length) return;
|
4878
|
+
var formats = {},
|
4879
|
+
nextLength = 0;
|
4531
4880
|
|
4532
|
-
|
4533
|
-
|
4881
|
+
var _quill$getLine15 = this.quill.getLine(range.index),
|
4882
|
+
_quill$getLine16 = _slicedToArray(_quill$getLine15, 1),
|
4883
|
+
line = _quill$getLine16[0];
|
4534
4884
|
|
4535
|
-
|
4885
|
+
if (context.offset >= line.length() - 1) {
|
4886
|
+
var _quill$getLine17 = this.quill.getLine(range.index + 1),
|
4887
|
+
_quill$getLine18 = _slicedToArray(_quill$getLine17, 1),
|
4888
|
+
next = _quill$getLine18[0];
|
4889
|
+
|
4890
|
+
if (next) {
|
4891
|
+
var curFormats = line.formats();
|
4892
|
+
var nextFormats = this.quill.getFormat(range.index, 1);
|
4893
|
+
formats = _op2.default.attributes.diff(curFormats, nextFormats) || {};
|
4894
|
+
nextLength = next.length();
|
4895
|
+
}
|
4896
|
+
}
|
4897
|
+
this.quill.deleteText(range.index, length, _quill2.default.sources.USER);
|
4898
|
+
if (Object.keys(formats).length > 0) {
|
4899
|
+
this.quill.formatLine(range.index + nextLength - 1, length, formats, _quill2.default.sources.USER);
|
4536
4900
|
}
|
4901
|
+
}
|
4537
4902
|
|
4538
|
-
|
4539
|
-
|
4903
|
+
function handleDeleteRange(range) {
|
4904
|
+
var lines = this.quill.getLines(range);
|
4905
|
+
var formats = {};
|
4906
|
+
if (lines.length > 1) {
|
4907
|
+
var firstFormats = lines[0].formats();
|
4908
|
+
var lastFormats = lines[lines.length - 1].formats();
|
4909
|
+
formats = _op2.default.attributes.diff(lastFormats, firstFormats) || {};
|
4910
|
+
}
|
4911
|
+
this.quill.deleteText(range, _quill2.default.sources.USER);
|
4912
|
+
if (Object.keys(formats).length > 0) {
|
4913
|
+
this.quill.formatLine(range.index, 1, formats, _quill2.default.sources.USER);
|
4914
|
+
}
|
4915
|
+
this.quill.setSelection(range.index, _quill2.default.sources.SILENT);
|
4916
|
+
this.quill.focus();
|
4917
|
+
}
|
4540
4918
|
|
4541
|
-
|
4919
|
+
function handleEnter(range, context) {
|
4920
|
+
var _this3 = this;
|
4542
4921
|
|
4543
|
-
|
4922
|
+
if (range.length > 0) {
|
4923
|
+
this.quill.scroll.deleteAt(range.index, range.length); // So we do not trigger text-change
|
4924
|
+
}
|
4925
|
+
var lineFormats = Object.keys(context.format).reduce(function (lineFormats, format) {
|
4926
|
+
if (_parchment2.default.query(format, _parchment2.default.Scope.BLOCK) && !Array.isArray(context.format[format])) {
|
4927
|
+
lineFormats[format] = context.format[format];
|
4928
|
+
}
|
4929
|
+
return lineFormats;
|
4930
|
+
}, {});
|
4931
|
+
this.quill.insertText(range.index, '\n', lineFormats, _quill2.default.sources.USER);
|
4932
|
+
// Earlier scroll.deleteAt might have messed up our selection,
|
4933
|
+
// so insertText's built in selection preservation is not reliable
|
4934
|
+
this.quill.setSelection(range.index + 1, _quill2.default.sources.SILENT);
|
4935
|
+
this.quill.focus();
|
4936
|
+
Object.keys(context.format).forEach(function (name) {
|
4937
|
+
if (lineFormats[name] != null) return;
|
4938
|
+
if (Array.isArray(context.format[name])) return;
|
4939
|
+
if (name === 'link') return;
|
4940
|
+
_this3.quill.format(name, context.format[name], _quill2.default.sources.USER);
|
4941
|
+
});
|
4942
|
+
}
|
4943
|
+
|
4944
|
+
function makeCodeBlockHandler(indent) {
|
4945
|
+
return {
|
4946
|
+
key: Keyboard.keys.TAB,
|
4947
|
+
shiftKey: !indent,
|
4948
|
+
format: { 'code-block': true },
|
4949
|
+
handler: function handler(range) {
|
4950
|
+
var CodeBlock = _parchment2.default.query('code-block');
|
4951
|
+
var index = range.index,
|
4952
|
+
length = range.length;
|
4953
|
+
|
4954
|
+
var _quill$scroll$descend = this.quill.scroll.descendant(CodeBlock, index),
|
4955
|
+
_quill$scroll$descend2 = _slicedToArray(_quill$scroll$descend, 2),
|
4956
|
+
block = _quill$scroll$descend2[0],
|
4957
|
+
offset = _quill$scroll$descend2[1];
|
4958
|
+
|
4959
|
+
if (block == null) return;
|
4960
|
+
var scrollIndex = this.quill.getIndex(block);
|
4961
|
+
var start = block.newlineIndex(offset, true) + 1;
|
4962
|
+
var end = block.newlineIndex(scrollIndex + offset + length);
|
4963
|
+
var lines = block.domNode.textContent.slice(start, end).split('\n');
|
4964
|
+
offset = 0;
|
4965
|
+
lines.forEach(function (line, i) {
|
4966
|
+
if (indent) {
|
4967
|
+
block.insertAt(start + offset, CodeBlock.TAB);
|
4968
|
+
offset += CodeBlock.TAB.length;
|
4969
|
+
if (i === 0) {
|
4970
|
+
index += CodeBlock.TAB.length;
|
4971
|
+
} else {
|
4972
|
+
length += CodeBlock.TAB.length;
|
4973
|
+
}
|
4974
|
+
} else if (line.startsWith(CodeBlock.TAB)) {
|
4975
|
+
block.deleteAt(start + offset, CodeBlock.TAB.length);
|
4976
|
+
offset -= CodeBlock.TAB.length;
|
4977
|
+
if (i === 0) {
|
4978
|
+
index -= CodeBlock.TAB.length;
|
4979
|
+
} else {
|
4980
|
+
length -= CodeBlock.TAB.length;
|
4981
|
+
}
|
4982
|
+
}
|
4983
|
+
offset += line.length + 1;
|
4984
|
+
});
|
4985
|
+
this.quill.update(_quill2.default.sources.USER);
|
4986
|
+
this.quill.setSelection(index, length, _quill2.default.sources.SILENT);
|
4987
|
+
}
|
4988
|
+
};
|
4989
|
+
}
|
4990
|
+
|
4991
|
+
function makeFormatHandler(format) {
|
4992
|
+
return {
|
4993
|
+
key: format[0].toUpperCase(),
|
4994
|
+
shortKey: true,
|
4995
|
+
handler: function handler(range, context) {
|
4996
|
+
this.quill.format(format, !context.format[format], _quill2.default.sources.USER);
|
4997
|
+
}
|
4998
|
+
};
|
4999
|
+
}
|
5000
|
+
|
5001
|
+
function normalize(binding) {
|
5002
|
+
if (typeof binding === 'string' || typeof binding === 'number') {
|
5003
|
+
return normalize({ key: binding });
|
5004
|
+
}
|
5005
|
+
if ((typeof binding === 'undefined' ? 'undefined' : _typeof(binding)) === 'object') {
|
5006
|
+
binding = (0, _clone2.default)(binding, false);
|
5007
|
+
}
|
5008
|
+
if (typeof binding.key === 'string') {
|
5009
|
+
if (Keyboard.keys[binding.key.toUpperCase()] != null) {
|
5010
|
+
binding.key = Keyboard.keys[binding.key.toUpperCase()];
|
5011
|
+
} else if (binding.key.length === 1) {
|
5012
|
+
binding.key = binding.key.toUpperCase().charCodeAt(0);
|
5013
|
+
} else {
|
5014
|
+
return null;
|
5015
|
+
}
|
5016
|
+
}
|
5017
|
+
if (binding.shortKey) {
|
5018
|
+
binding[SHORTKEY] = binding.shortKey;
|
5019
|
+
delete binding.shortKey;
|
5020
|
+
}
|
5021
|
+
return binding;
|
5022
|
+
}
|
5023
|
+
|
5024
|
+
exports.default = Keyboard;
|
5025
|
+
exports.SHORTKEY = SHORTKEY;
|
4544
5026
|
|
4545
5027
|
/***/ }),
|
4546
|
-
/*
|
5028
|
+
/* 24 */
|
4547
5029
|
/***/ (function(module, exports, __webpack_require__) {
|
4548
5030
|
|
4549
5031
|
"use strict";
|
@@ -4553,10 +5035,12 @@ Object.defineProperty(exports, "__esModule", {
|
|
4553
5035
|
value: true
|
4554
5036
|
});
|
4555
5037
|
|
4556
|
-
var
|
5038
|
+
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"); } }; }();
|
4557
5039
|
|
4558
5040
|
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); } };
|
4559
5041
|
|
5042
|
+
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; }; }();
|
5043
|
+
|
4560
5044
|
var _parchment = __webpack_require__(0);
|
4561
5045
|
|
4562
5046
|
var _parchment2 = _interopRequireDefault(_parchment);
|
@@ -4573,95 +5057,198 @@ function _possibleConstructorReturn(self, call) { if (!self) { throw new Referen
|
|
4573
5057
|
|
4574
5058
|
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; }
|
4575
5059
|
|
4576
|
-
var
|
5060
|
+
var Cursor = function (_Parchment$Embed) {
|
5061
|
+
_inherits(Cursor, _Parchment$Embed);
|
4577
5062
|
|
4578
|
-
|
4579
|
-
|
5063
|
+
_createClass(Cursor, null, [{
|
5064
|
+
key: 'value',
|
5065
|
+
value: function value() {
|
5066
|
+
return undefined;
|
5067
|
+
}
|
5068
|
+
}]);
|
4580
5069
|
|
4581
|
-
function
|
4582
|
-
_classCallCheck(this,
|
5070
|
+
function Cursor(domNode, selection) {
|
5071
|
+
_classCallCheck(this, Cursor);
|
4583
5072
|
|
4584
|
-
var _this = _possibleConstructorReturn(this, (
|
5073
|
+
var _this = _possibleConstructorReturn(this, (Cursor.__proto__ || Object.getPrototypeOf(Cursor)).call(this, domNode));
|
4585
5074
|
|
4586
|
-
_this.
|
4587
|
-
_this.
|
4588
|
-
|
4589
|
-
|
4590
|
-
});
|
4591
|
-
_this.leftGuard = document.createTextNode(GUARD_TEXT);
|
4592
|
-
_this.rightGuard = document.createTextNode(GUARD_TEXT);
|
4593
|
-
_this.domNode.appendChild(_this.leftGuard);
|
4594
|
-
_this.domNode.appendChild(_this.contentNode);
|
4595
|
-
_this.domNode.appendChild(_this.rightGuard);
|
5075
|
+
_this.selection = selection;
|
5076
|
+
_this.textNode = document.createTextNode(Cursor.CONTENTS);
|
5077
|
+
_this.domNode.appendChild(_this.textNode);
|
5078
|
+
_this._length = 0;
|
4596
5079
|
return _this;
|
4597
5080
|
}
|
4598
5081
|
|
4599
|
-
_createClass(
|
4600
|
-
key: '
|
4601
|
-
value: function
|
4602
|
-
|
4603
|
-
if (
|
4604
|
-
|
5082
|
+
_createClass(Cursor, [{
|
5083
|
+
key: 'detach',
|
5084
|
+
value: function detach() {
|
5085
|
+
// super.detach() will also clear domNode.__blot
|
5086
|
+
if (this.parent != null) this.parent.removeChild(this);
|
5087
|
+
}
|
5088
|
+
}, {
|
5089
|
+
key: 'format',
|
5090
|
+
value: function format(name, value) {
|
5091
|
+
if (this._length !== 0) {
|
5092
|
+
return _get(Cursor.prototype.__proto__ || Object.getPrototypeOf(Cursor.prototype), 'format', this).call(this, name, value);
|
5093
|
+
}
|
5094
|
+
var target = this,
|
5095
|
+
index = 0;
|
5096
|
+
while (target != null && target.statics.scope !== _parchment2.default.Scope.BLOCK_BLOT) {
|
5097
|
+
index += target.offset(target.parent);
|
5098
|
+
target = target.parent;
|
5099
|
+
}
|
5100
|
+
if (target != null) {
|
5101
|
+
this._length = Cursor.CONTENTS.length;
|
5102
|
+
target.optimize();
|
5103
|
+
target.formatAt(index, Cursor.CONTENTS.length, name, value);
|
5104
|
+
this._length = 0;
|
5105
|
+
}
|
5106
|
+
}
|
5107
|
+
}, {
|
5108
|
+
key: 'index',
|
5109
|
+
value: function index(node, offset) {
|
5110
|
+
if (node === this.textNode) return 0;
|
5111
|
+
return _get(Cursor.prototype.__proto__ || Object.getPrototypeOf(Cursor.prototype), 'index', this).call(this, node, offset);
|
5112
|
+
}
|
5113
|
+
}, {
|
5114
|
+
key: 'length',
|
5115
|
+
value: function length() {
|
5116
|
+
return this._length;
|
5117
|
+
}
|
5118
|
+
}, {
|
5119
|
+
key: 'position',
|
5120
|
+
value: function position() {
|
5121
|
+
return [this.textNode, this.textNode.data.length];
|
5122
|
+
}
|
5123
|
+
}, {
|
5124
|
+
key: 'remove',
|
5125
|
+
value: function remove() {
|
5126
|
+
_get(Cursor.prototype.__proto__ || Object.getPrototypeOf(Cursor.prototype), 'remove', this).call(this);
|
5127
|
+
this.parent = null;
|
4605
5128
|
}
|
4606
5129
|
}, {
|
4607
5130
|
key: 'restore',
|
4608
|
-
value: function restore(
|
4609
|
-
|
4610
|
-
|
4611
|
-
var
|
4612
|
-
|
4613
|
-
|
4614
|
-
|
4615
|
-
|
4616
|
-
|
4617
|
-
|
4618
|
-
|
4619
|
-
|
4620
|
-
|
4621
|
-
|
4622
|
-
|
4623
|
-
|
4624
|
-
|
4625
|
-
|
4626
|
-
|
4627
|
-
}
|
4628
|
-
} else if (node === this.rightGuard) {
|
5131
|
+
value: function restore() {
|
5132
|
+
if (this.selection.composing || this.parent == null) return;
|
5133
|
+
var textNode = this.textNode;
|
5134
|
+
var range = this.selection.getNativeRange();
|
5135
|
+
var restoreText = void 0,
|
5136
|
+
start = void 0,
|
5137
|
+
end = void 0;
|
5138
|
+
if (range != null && range.start.node === textNode && range.end.node === textNode) {
|
5139
|
+
var _ref = [textNode, range.start.offset, range.end.offset];
|
5140
|
+
restoreText = _ref[0];
|
5141
|
+
start = _ref[1];
|
5142
|
+
end = _ref[2];
|
5143
|
+
}
|
5144
|
+
// Link format will insert text outside of anchor tag
|
5145
|
+
while (this.domNode.lastChild != null && this.domNode.lastChild !== this.textNode) {
|
5146
|
+
this.domNode.parentNode.insertBefore(this.domNode.lastChild, this.domNode);
|
5147
|
+
}
|
5148
|
+
if (this.textNode.data !== Cursor.CONTENTS) {
|
5149
|
+
var text = this.textNode.data.split(Cursor.CONTENTS).join('');
|
4629
5150
|
if (this.next instanceof _text2.default) {
|
5151
|
+
restoreText = this.next.domNode;
|
4630
5152
|
this.next.insertAt(0, text);
|
4631
|
-
|
4632
|
-
startNode: this.next.domNode,
|
4633
|
-
startOffset: text.length
|
4634
|
-
};
|
5153
|
+
this.textNode.data = Cursor.CONTENTS;
|
4635
5154
|
} else {
|
4636
|
-
textNode =
|
4637
|
-
this.parent.insertBefore(_parchment2.default.create(textNode), this
|
4638
|
-
|
4639
|
-
|
4640
|
-
startOffset: text.length
|
4641
|
-
};
|
5155
|
+
this.textNode.data = text;
|
5156
|
+
this.parent.insertBefore(_parchment2.default.create(this.textNode), this);
|
5157
|
+
this.textNode = document.createTextNode(Cursor.CONTENTS);
|
5158
|
+
this.domNode.appendChild(this.textNode);
|
4642
5159
|
}
|
4643
5160
|
}
|
4644
|
-
|
4645
|
-
|
5161
|
+
this.remove();
|
5162
|
+
if (start != null) {
|
5163
|
+
var _map = [start, end].map(function (offset) {
|
5164
|
+
return Math.max(0, Math.min(restoreText.data.length, offset - 1));
|
5165
|
+
});
|
5166
|
+
|
5167
|
+
var _map2 = _slicedToArray(_map, 2);
|
5168
|
+
|
5169
|
+
start = _map2[0];
|
5170
|
+
end = _map2[1];
|
5171
|
+
|
5172
|
+
return {
|
5173
|
+
startNode: restoreText,
|
5174
|
+
startOffset: start,
|
5175
|
+
endNode: restoreText,
|
5176
|
+
endOffset: end
|
5177
|
+
};
|
5178
|
+
}
|
4646
5179
|
}
|
4647
5180
|
}, {
|
4648
5181
|
key: 'update',
|
4649
5182
|
value: function update(mutations, context) {
|
4650
5183
|
var _this2 = this;
|
4651
5184
|
|
4652
|
-
mutations.
|
4653
|
-
|
4654
|
-
|
4655
|
-
|
4656
|
-
|
4657
|
-
}
|
5185
|
+
if (mutations.some(function (mutation) {
|
5186
|
+
return mutation.type === 'characterData' && mutation.target === _this2.textNode;
|
5187
|
+
})) {
|
5188
|
+
var range = this.restore();
|
5189
|
+
if (range) context.range = range;
|
5190
|
+
}
|
5191
|
+
}
|
5192
|
+
}, {
|
5193
|
+
key: 'value',
|
5194
|
+
value: function value() {
|
5195
|
+
return '';
|
4658
5196
|
}
|
4659
5197
|
}]);
|
4660
5198
|
|
4661
|
-
return
|
5199
|
+
return Cursor;
|
4662
5200
|
}(_parchment2.default.Embed);
|
4663
5201
|
|
4664
|
-
|
5202
|
+
Cursor.blotName = 'cursor';
|
5203
|
+
Cursor.className = 'ql-cursor';
|
5204
|
+
Cursor.tagName = 'span';
|
5205
|
+
Cursor.CONTENTS = '\uFEFF'; // Zero width no break space
|
5206
|
+
|
5207
|
+
|
5208
|
+
exports.default = Cursor;
|
5209
|
+
|
5210
|
+
/***/ }),
|
5211
|
+
/* 25 */
|
5212
|
+
/***/ (function(module, exports, __webpack_require__) {
|
5213
|
+
|
5214
|
+
"use strict";
|
5215
|
+
|
5216
|
+
|
5217
|
+
Object.defineProperty(exports, "__esModule", {
|
5218
|
+
value: true
|
5219
|
+
});
|
5220
|
+
|
5221
|
+
var _parchment = __webpack_require__(0);
|
5222
|
+
|
5223
|
+
var _parchment2 = _interopRequireDefault(_parchment);
|
5224
|
+
|
5225
|
+
var _block = __webpack_require__(4);
|
5226
|
+
|
5227
|
+
var _block2 = _interopRequireDefault(_block);
|
5228
|
+
|
5229
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
5230
|
+
|
5231
|
+
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
5232
|
+
|
5233
|
+
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; }
|
5234
|
+
|
5235
|
+
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; }
|
5236
|
+
|
5237
|
+
var Container = function (_Parchment$Container) {
|
5238
|
+
_inherits(Container, _Parchment$Container);
|
5239
|
+
|
5240
|
+
function Container() {
|
5241
|
+
_classCallCheck(this, Container);
|
5242
|
+
|
5243
|
+
return _possibleConstructorReturn(this, (Container.__proto__ || Object.getPrototypeOf(Container)).apply(this, arguments));
|
5244
|
+
}
|
5245
|
+
|
5246
|
+
return Container;
|
5247
|
+
}(_parchment2.default.Container);
|
5248
|
+
|
5249
|
+
Container.allowedChildren = [_block2.default, _block.BlockEmbed, Container];
|
5250
|
+
|
5251
|
+
exports.default = Container;
|
4665
5252
|
|
4666
5253
|
/***/ }),
|
4667
5254
|
/* 26 */
|
@@ -4776,6 +5363,7 @@ var Link = function (_Inline) {
|
|
4776
5363
|
var node = _get(Link.__proto__ || Object.getPrototypeOf(Link), 'create', this).call(this, value);
|
4777
5364
|
value = this.sanitize(value);
|
4778
5365
|
node.setAttribute('href', value);
|
5366
|
+
node.setAttribute('rel', 'noopener noreferrer');
|
4779
5367
|
node.setAttribute('target', '_blank');
|
4780
5368
|
return node;
|
4781
5369
|
}
|
@@ -4824,6 +5412,10 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol
|
|
4824
5412
|
|
4825
5413
|
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; }; }();
|
4826
5414
|
|
5415
|
+
var _keyboard = __webpack_require__(23);
|
5416
|
+
|
5417
|
+
var _keyboard2 = _interopRequireDefault(_keyboard);
|
5418
|
+
|
4827
5419
|
var _dropdown = __webpack_require__(107);
|
4828
5420
|
|
4829
5421
|
var _dropdown2 = _interopRequireDefault(_dropdown);
|
@@ -4832,6 +5424,12 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
|
|
4832
5424
|
|
4833
5425
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
4834
5426
|
|
5427
|
+
var optionsCounter = 0;
|
5428
|
+
|
5429
|
+
function toggleAriaAttribute(element, attribute) {
|
5430
|
+
element.setAttribute(attribute, !(element.getAttribute(attribute) === 'true'));
|
5431
|
+
}
|
5432
|
+
|
4835
5433
|
var Picker = function () {
|
4836
5434
|
function Picker(select) {
|
4837
5435
|
var _this = this;
|
@@ -4843,18 +5441,45 @@ var Picker = function () {
|
|
4843
5441
|
this.buildPicker();
|
4844
5442
|
this.select.style.display = 'none';
|
4845
5443
|
this.select.parentNode.insertBefore(this.container, this.select);
|
5444
|
+
|
4846
5445
|
this.label.addEventListener('mousedown', function () {
|
4847
|
-
_this.
|
5446
|
+
_this.togglePicker();
|
5447
|
+
});
|
5448
|
+
this.label.addEventListener('keydown', function (event) {
|
5449
|
+
switch (event.keyCode) {
|
5450
|
+
// Allows the "Enter" key to open the picker
|
5451
|
+
case _keyboard2.default.keys.ENTER:
|
5452
|
+
_this.togglePicker();
|
5453
|
+
break;
|
5454
|
+
|
5455
|
+
// Allows the "Escape" key to close the picker
|
5456
|
+
case _keyboard2.default.keys.ESCAPE:
|
5457
|
+
_this.escape();
|
5458
|
+
event.preventDefault();
|
5459
|
+
break;
|
5460
|
+
default:
|
5461
|
+
}
|
4848
5462
|
});
|
4849
5463
|
this.select.addEventListener('change', this.update.bind(this));
|
4850
5464
|
}
|
4851
5465
|
|
4852
5466
|
_createClass(Picker, [{
|
5467
|
+
key: 'togglePicker',
|
5468
|
+
value: function togglePicker() {
|
5469
|
+
this.container.classList.toggle('ql-expanded');
|
5470
|
+
// Toggle aria-expanded and aria-hidden to make the picker accessible
|
5471
|
+
toggleAriaAttribute(this.label, 'aria-expanded');
|
5472
|
+
toggleAriaAttribute(this.options, 'aria-hidden');
|
5473
|
+
}
|
5474
|
+
}, {
|
4853
5475
|
key: 'buildItem',
|
4854
5476
|
value: function buildItem(option) {
|
4855
5477
|
var _this2 = this;
|
4856
5478
|
|
4857
5479
|
var item = document.createElement('span');
|
5480
|
+
item.tabIndex = '0';
|
5481
|
+
item.setAttribute('role', 'button');
|
5482
|
+
|
4858
5483
|
item.classList.add('ql-picker-item');
|
4859
5484
|
if (option.hasAttribute('value')) {
|
4860
5485
|
item.setAttribute('data-value', option.getAttribute('value'));
|
@@ -4865,6 +5490,23 @@ var Picker = function () {
|
|
4865
5490
|
item.addEventListener('click', function () {
|
4866
5491
|
_this2.selectItem(item, true);
|
4867
5492
|
});
|
5493
|
+
item.addEventListener('keydown', function (event) {
|
5494
|
+
switch (event.keyCode) {
|
5495
|
+
// Allows the "Enter" key to select an item
|
5496
|
+
case _keyboard2.default.keys.ENTER:
|
5497
|
+
_this2.selectItem(item, true);
|
5498
|
+
event.preventDefault();
|
5499
|
+
break;
|
5500
|
+
|
5501
|
+
// Allows the "Escape" key to close the picker
|
5502
|
+
case _keyboard2.default.keys.ESCAPE:
|
5503
|
+
_this2.escape();
|
5504
|
+
event.preventDefault();
|
5505
|
+
break;
|
5506
|
+
default:
|
5507
|
+
}
|
5508
|
+
});
|
5509
|
+
|
4868
5510
|
return item;
|
4869
5511
|
}
|
4870
5512
|
}, {
|
@@ -4873,6 +5515,9 @@ var Picker = function () {
|
|
4873
5515
|
var label = document.createElement('span');
|
4874
5516
|
label.classList.add('ql-picker-label');
|
4875
5517
|
label.innerHTML = _dropdown2.default;
|
5518
|
+
label.tabIndex = '0';
|
5519
|
+
label.setAttribute('role', 'button');
|
5520
|
+
label.setAttribute('aria-expanded', 'false');
|
4876
5521
|
this.container.appendChild(label);
|
4877
5522
|
return label;
|
4878
5523
|
}
|
@@ -4883,6 +5528,18 @@ var Picker = function () {
|
|
4883
5528
|
|
4884
5529
|
var options = document.createElement('span');
|
4885
5530
|
options.classList.add('ql-picker-options');
|
5531
|
+
|
5532
|
+
// Don't want screen readers to read this until options are visible
|
5533
|
+
options.setAttribute('aria-hidden', 'true');
|
5534
|
+
options.tabIndex = '-1';
|
5535
|
+
|
5536
|
+
// Need a unique id for aria-controls
|
5537
|
+
options.id = 'ql-picker-options-' + optionsCounter;
|
5538
|
+
optionsCounter += 1;
|
5539
|
+
this.label.setAttribute('aria-controls', options.id);
|
5540
|
+
|
5541
|
+
this.options = options;
|
5542
|
+
|
4886
5543
|
[].slice.call(this.select.options).forEach(function (option) {
|
4887
5544
|
var item = _this3.buildItem(option);
|
4888
5545
|
options.appendChild(item);
|
@@ -4904,10 +5561,25 @@ var Picker = function () {
|
|
4904
5561
|
this.label = this.buildLabel();
|
4905
5562
|
this.buildOptions();
|
4906
5563
|
}
|
5564
|
+
}, {
|
5565
|
+
key: 'escape',
|
5566
|
+
value: function escape() {
|
5567
|
+
var _this5 = this;
|
5568
|
+
|
5569
|
+
// Close menu and return focus to trigger label
|
5570
|
+
this.close();
|
5571
|
+
// Need setTimeout for accessibility to ensure that the browser executes
|
5572
|
+
// focus on the next process thread and after any DOM content changes
|
5573
|
+
setTimeout(function () {
|
5574
|
+
return _this5.label.focus();
|
5575
|
+
}, 1);
|
5576
|
+
}
|
4907
5577
|
}, {
|
4908
5578
|
key: 'close',
|
4909
5579
|
value: function close() {
|
4910
5580
|
this.container.classList.remove('ql-expanded');
|
5581
|
+
this.label.setAttribute('aria-expanded', 'false');
|
5582
|
+
this.options.setAttribute('aria-hidden', 'true');
|
4911
5583
|
}
|
4912
5584
|
}, {
|
4913
5585
|
key: 'selectItem',
|
@@ -4972,6 +5644,10 @@ exports.default = Picker;
|
|
4972
5644
|
"use strict";
|
4973
5645
|
|
4974
5646
|
|
5647
|
+
Object.defineProperty(exports, "__esModule", {
|
5648
|
+
value: true
|
5649
|
+
});
|
5650
|
+
|
4975
5651
|
var _parchment = __webpack_require__(0);
|
4976
5652
|
|
4977
5653
|
var _parchment2 = _interopRequireDefault(_parchment);
|
@@ -4988,15 +5664,15 @@ var _break = __webpack_require__(16);
|
|
4988
5664
|
|
4989
5665
|
var _break2 = _interopRequireDefault(_break);
|
4990
5666
|
|
4991
|
-
var _container = __webpack_require__(
|
5667
|
+
var _container = __webpack_require__(25);
|
4992
5668
|
|
4993
5669
|
var _container2 = _interopRequireDefault(_container);
|
4994
5670
|
|
4995
|
-
var _cursor = __webpack_require__(
|
5671
|
+
var _cursor = __webpack_require__(24);
|
4996
5672
|
|
4997
5673
|
var _cursor2 = _interopRequireDefault(_cursor);
|
4998
5674
|
|
4999
|
-
var _embed = __webpack_require__(
|
5675
|
+
var _embed = __webpack_require__(35);
|
5000
5676
|
|
5001
5677
|
var _embed2 = _interopRequireDefault(_embed);
|
5002
5678
|
|
@@ -5020,7 +5696,7 @@ var _history = __webpack_require__(42);
|
|
5020
5696
|
|
5021
5697
|
var _history2 = _interopRequireDefault(_history);
|
5022
5698
|
|
5023
|
-
var _keyboard = __webpack_require__(
|
5699
|
+
var _keyboard = __webpack_require__(23);
|
5024
5700
|
|
5025
5701
|
var _keyboard2 = _interopRequireDefault(_keyboard);
|
5026
5702
|
|
@@ -5044,7 +5720,7 @@ _quill2.default.register({
|
|
5044
5720
|
|
5045
5721
|
_parchment2.default.register(_block2.default, _break2.default, _cursor2.default, _inline2.default, _scroll2.default, _text2.default);
|
5046
5722
|
|
5047
|
-
|
5723
|
+
exports.default = _quill2.default;
|
5048
5724
|
|
5049
5725
|
/***/ }),
|
5050
5726
|
/* 30 */
|
@@ -5057,7 +5733,8 @@ var Registry = __webpack_require__(1);
|
|
5057
5733
|
var ShadowBlot = /** @class */ (function () {
|
5058
5734
|
function ShadowBlot(domNode) {
|
5059
5735
|
this.domNode = domNode;
|
5060
|
-
|
5736
|
+
// @ts-ignore
|
5737
|
+
this.domNode[Registry.DATA_KEY] = { blot: this };
|
5061
5738
|
}
|
5062
5739
|
Object.defineProperty(ShadowBlot.prototype, "statics", {
|
5063
5740
|
// Hack for accessing inherited static methods
|
@@ -5098,7 +5775,9 @@ var ShadowBlot = /** @class */ (function () {
|
|
5098
5775
|
return node;
|
5099
5776
|
};
|
5100
5777
|
ShadowBlot.prototype.attach = function () {
|
5101
|
-
this.
|
5778
|
+
if (this.parent != null) {
|
5779
|
+
this.scroll = this.parent.scroll;
|
5780
|
+
}
|
5102
5781
|
};
|
5103
5782
|
ShadowBlot.prototype.clone = function () {
|
5104
5783
|
var domNode = this.domNode.cloneNode(false);
|
@@ -5107,6 +5786,7 @@ var ShadowBlot = /** @class */ (function () {
|
|
5107
5786
|
ShadowBlot.prototype.detach = function () {
|
5108
5787
|
if (this.parent != null)
|
5109
5788
|
this.parent.removeChild(this);
|
5789
|
+
// @ts-ignore
|
5110
5790
|
delete this.domNode[Registry.DATA_KEY];
|
5111
5791
|
};
|
5112
5792
|
ShadowBlot.prototype.deleteAt = function (index, length) {
|
@@ -5125,22 +5805,26 @@ var ShadowBlot = /** @class */ (function () {
|
|
5125
5805
|
}
|
5126
5806
|
};
|
5127
5807
|
ShadowBlot.prototype.insertAt = function (index, value, def) {
|
5128
|
-
var blot =
|
5808
|
+
var blot = def == null ? Registry.create('text', value) : Registry.create(value, def);
|
5129
5809
|
var ref = this.split(index);
|
5130
5810
|
this.parent.insertBefore(blot, ref);
|
5131
5811
|
};
|
5132
5812
|
ShadowBlot.prototype.insertInto = function (parentBlot, refBlot) {
|
5813
|
+
if (refBlot === void 0) { refBlot = null; }
|
5133
5814
|
if (this.parent != null) {
|
5134
5815
|
this.parent.children.remove(this);
|
5135
5816
|
}
|
5817
|
+
var refDomNode = null;
|
5136
5818
|
parentBlot.children.insertBefore(this, refBlot);
|
5137
5819
|
if (refBlot != null) {
|
5138
|
-
|
5820
|
+
refDomNode = refBlot.domNode;
|
5139
5821
|
}
|
5140
|
-
if (this.
|
5141
|
-
|
5822
|
+
if (this.domNode.parentNode != parentBlot.domNode ||
|
5823
|
+
this.domNode.nextSibling != refDomNode) {
|
5824
|
+
parentBlot.domNode.insertBefore(this.domNode, refDomNode);
|
5142
5825
|
}
|
5143
5826
|
this.parent = parentBlot;
|
5827
|
+
this.attach();
|
5144
5828
|
};
|
5145
5829
|
ShadowBlot.prototype.isolate = function (index, length) {
|
5146
5830
|
var target = this.split(index);
|
@@ -5150,7 +5834,6 @@ var ShadowBlot = /** @class */ (function () {
|
|
5150
5834
|
ShadowBlot.prototype.length = function () {
|
5151
5835
|
return 1;
|
5152
5836
|
};
|
5153
|
-
;
|
5154
5837
|
ShadowBlot.prototype.offset = function (root) {
|
5155
5838
|
if (root === void 0) { root = this.parent; }
|
5156
5839
|
if (this.parent == null || this == root)
|
@@ -5159,7 +5842,9 @@ var ShadowBlot = /** @class */ (function () {
|
|
5159
5842
|
};
|
5160
5843
|
ShadowBlot.prototype.optimize = function (context) {
|
5161
5844
|
// TODO clean up once we use WeakMap
|
5845
|
+
// @ts-ignore
|
5162
5846
|
if (this.domNode[Registry.DATA_KEY] != null) {
|
5847
|
+
// @ts-ignore
|
5163
5848
|
delete this.domNode[Registry.DATA_KEY].mutations;
|
5164
5849
|
}
|
5165
5850
|
};
|
@@ -5218,6 +5903,7 @@ var AttributorStore = /** @class */ (function () {
|
|
5218
5903
|
this.build();
|
5219
5904
|
}
|
5220
5905
|
AttributorStore.prototype.attribute = function (attribute, value) {
|
5906
|
+
// verb
|
5221
5907
|
if (value) {
|
5222
5908
|
if (attribute.add(this.domNode, value)) {
|
5223
5909
|
if (attribute.value(this.domNode) != null) {
|
@@ -5239,7 +5925,10 @@ var AttributorStore = /** @class */ (function () {
|
|
5239
5925
|
var attributes = attributor_1.default.keys(this.domNode);
|
5240
5926
|
var classes = class_1.default.keys(this.domNode);
|
5241
5927
|
var styles = style_1.default.keys(this.domNode);
|
5242
|
-
attributes
|
5928
|
+
attributes
|
5929
|
+
.concat(classes)
|
5930
|
+
.concat(styles)
|
5931
|
+
.forEach(function (name) {
|
5243
5932
|
var attr = Registry.query(name, Registry.Scope.ATTRIBUTE);
|
5244
5933
|
if (attr instanceof attributor_1.default) {
|
5245
5934
|
_this.attributes[attr.attrName] = attr;
|
@@ -5304,7 +5993,10 @@ var ClassAttributor = /** @class */ (function (_super) {
|
|
5304
5993
|
}
|
5305
5994
|
ClassAttributor.keys = function (node) {
|
5306
5995
|
return (node.getAttribute('class') || '').split(/\s+/).map(function (name) {
|
5307
|
-
return name
|
5996
|
+
return name
|
5997
|
+
.split('-')
|
5998
|
+
.slice(0, -1)
|
5999
|
+
.join('-');
|
5308
6000
|
});
|
5309
6001
|
};
|
5310
6002
|
ClassAttributor.prototype.add = function (node, value) {
|
@@ -5316,743 +6008,262 @@ var ClassAttributor = /** @class */ (function (_super) {
|
|
5316
6008
|
};
|
5317
6009
|
ClassAttributor.prototype.remove = function (node) {
|
5318
6010
|
var matches = match(node, this.keyName);
|
5319
|
-
matches.forEach(function (name) {
|
5320
|
-
node.classList.remove(name);
|
5321
|
-
});
|
5322
|
-
if (node.classList.length === 0) {
|
5323
|
-
node.removeAttribute('class');
|
5324
|
-
}
|
5325
|
-
};
|
5326
|
-
ClassAttributor.prototype.value = function (node) {
|
5327
|
-
var result = match(node, this.keyName)[0] || '';
|
5328
|
-
var value = result.slice(this.keyName.length + 1); // +1 for hyphen
|
5329
|
-
return this.canAdd(node, value) ? value : '';
|
5330
|
-
};
|
5331
|
-
return ClassAttributor;
|
5332
|
-
}(attributor_1.default));
|
5333
|
-
exports.default = ClassAttributor;
|
5334
|
-
|
5335
|
-
|
5336
|
-
/***/ }),
|
5337
|
-
/* 33 */
|
5338
|
-
/***/ (function(module, exports, __webpack_require__) {
|
5339
|
-
|
5340
|
-
"use strict";
|
5341
|
-
|
5342
|
-
var __extends = (this && this.__extends) || (function () {
|
5343
|
-
var extendStatics = Object.setPrototypeOf ||
|
5344
|
-
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
5345
|
-
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
|
5346
|
-
return function (d, b) {
|
5347
|
-
extendStatics(d, b);
|
5348
|
-
function __() { this.constructor = d; }
|
5349
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
5350
|
-
};
|
5351
|
-
})();
|
5352
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
5353
|
-
var attributor_1 = __webpack_require__(12);
|
5354
|
-
function camelize(name) {
|
5355
|
-
var parts = name.split('-');
|
5356
|
-
var rest = parts.slice(1).map(function (part) {
|
5357
|
-
return part[0].toUpperCase() + part.slice(1);
|
5358
|
-
}).join('');
|
5359
|
-
return parts[0] + rest;
|
5360
|
-
}
|
5361
|
-
var StyleAttributor = /** @class */ (function (_super) {
|
5362
|
-
__extends(StyleAttributor, _super);
|
5363
|
-
function StyleAttributor() {
|
5364
|
-
return _super !== null && _super.apply(this, arguments) || this;
|
5365
|
-
}
|
5366
|
-
StyleAttributor.keys = function (node) {
|
5367
|
-
return (node.getAttribute('style') || '').split(';').map(function (value) {
|
5368
|
-
var arr = value.split(':');
|
5369
|
-
return arr[0].trim();
|
5370
|
-
});
|
5371
|
-
};
|
5372
|
-
StyleAttributor.prototype.add = function (node, value) {
|
5373
|
-
if (!this.canAdd(node, value))
|
5374
|
-
return false;
|
5375
|
-
node.style[camelize(this.keyName)] = value;
|
5376
|
-
return true;
|
5377
|
-
};
|
5378
|
-
StyleAttributor.prototype.remove = function (node) {
|
5379
|
-
node.style[camelize(this.keyName)] = '';
|
5380
|
-
if (!node.getAttribute('style')) {
|
5381
|
-
node.removeAttribute('style');
|
5382
|
-
}
|
5383
|
-
};
|
5384
|
-
StyleAttributor.prototype.value = function (node) {
|
5385
|
-
var value = node.style[camelize(this.keyName)];
|
5386
|
-
return this.canAdd(node, value) ? value : '';
|
5387
|
-
};
|
5388
|
-
return StyleAttributor;
|
5389
|
-
}(attributor_1.default));
|
5390
|
-
exports.default = StyleAttributor;
|
5391
|
-
|
5392
|
-
|
5393
|
-
/***/ }),
|
5394
|
-
/* 34 */
|
5395
|
-
/***/ (function(module, exports, __webpack_require__) {
|
5396
|
-
|
5397
|
-
"use strict";
|
5398
|
-
|
5399
|
-
|
5400
|
-
Object.defineProperty(exports, "__esModule", {
|
5401
|
-
value: true
|
5402
|
-
});
|
5403
|
-
|
5404
|
-
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; }; }();
|
5405
|
-
|
5406
|
-
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
5407
|
-
|
5408
|
-
var Theme = function () {
|
5409
|
-
function Theme(quill, options) {
|
5410
|
-
_classCallCheck(this, Theme);
|
5411
|
-
|
5412
|
-
this.quill = quill;
|
5413
|
-
this.options = options;
|
5414
|
-
this.modules = {};
|
5415
|
-
}
|
5416
|
-
|
5417
|
-
_createClass(Theme, [{
|
5418
|
-
key: 'init',
|
5419
|
-
value: function init() {
|
5420
|
-
var _this = this;
|
5421
|
-
|
5422
|
-
Object.keys(this.options.modules).forEach(function (name) {
|
5423
|
-
if (_this.modules[name] == null) {
|
5424
|
-
_this.addModule(name);
|
5425
|
-
}
|
5426
|
-
});
|
5427
|
-
}
|
5428
|
-
}, {
|
5429
|
-
key: 'addModule',
|
5430
|
-
value: function addModule(name) {
|
5431
|
-
var moduleClass = this.quill.constructor.import('modules/' + name);
|
5432
|
-
this.modules[name] = new moduleClass(this.quill, this.options.modules[name] || {});
|
5433
|
-
return this.modules[name];
|
5434
|
-
}
|
5435
|
-
}]);
|
5436
|
-
|
5437
|
-
return Theme;
|
5438
|
-
}();
|
5439
|
-
|
5440
|
-
Theme.DEFAULTS = {
|
5441
|
-
modules: {}
|
5442
|
-
};
|
5443
|
-
Theme.themes = {
|
5444
|
-
'default': Theme
|
5445
|
-
};
|
5446
|
-
|
5447
|
-
exports.default = Theme;
|
5448
|
-
|
5449
|
-
/***/ }),
|
5450
|
-
/* 35 */
|
5451
|
-
/***/ (function(module, exports, __webpack_require__) {
|
5452
|
-
|
5453
|
-
"use strict";
|
5454
|
-
|
5455
|
-
|
5456
|
-
Object.defineProperty(exports, "__esModule", {
|
5457
|
-
value: true
|
5458
|
-
});
|
5459
|
-
exports.SHORTKEY = exports.default = undefined;
|
5460
|
-
|
5461
|
-
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; };
|
5462
|
-
|
5463
|
-
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"); } }; }();
|
5464
|
-
|
5465
|
-
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; }; }();
|
5466
|
-
|
5467
|
-
var _clone = __webpack_require__(21);
|
5468
|
-
|
5469
|
-
var _clone2 = _interopRequireDefault(_clone);
|
5470
|
-
|
5471
|
-
var _deepEqual = __webpack_require__(11);
|
5472
|
-
|
5473
|
-
var _deepEqual2 = _interopRequireDefault(_deepEqual);
|
5474
|
-
|
5475
|
-
var _extend = __webpack_require__(3);
|
5476
|
-
|
5477
|
-
var _extend2 = _interopRequireDefault(_extend);
|
5478
|
-
|
5479
|
-
var _quillDelta = __webpack_require__(2);
|
5480
|
-
|
5481
|
-
var _quillDelta2 = _interopRequireDefault(_quillDelta);
|
5482
|
-
|
5483
|
-
var _op = __webpack_require__(20);
|
5484
|
-
|
5485
|
-
var _op2 = _interopRequireDefault(_op);
|
5486
|
-
|
5487
|
-
var _parchment = __webpack_require__(0);
|
5488
|
-
|
5489
|
-
var _parchment2 = _interopRequireDefault(_parchment);
|
5490
|
-
|
5491
|
-
var _embed = __webpack_require__(25);
|
5492
|
-
|
5493
|
-
var _embed2 = _interopRequireDefault(_embed);
|
5494
|
-
|
5495
|
-
var _quill = __webpack_require__(5);
|
5496
|
-
|
5497
|
-
var _quill2 = _interopRequireDefault(_quill);
|
5498
|
-
|
5499
|
-
var _logger = __webpack_require__(10);
|
5500
|
-
|
5501
|
-
var _logger2 = _interopRequireDefault(_logger);
|
5502
|
-
|
5503
|
-
var _module = __webpack_require__(9);
|
5504
|
-
|
5505
|
-
var _module2 = _interopRequireDefault(_module);
|
5506
|
-
|
5507
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
5508
|
-
|
5509
|
-
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; }
|
5510
|
-
|
5511
|
-
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
5512
|
-
|
5513
|
-
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; }
|
5514
|
-
|
5515
|
-
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; }
|
5516
|
-
|
5517
|
-
var debug = (0, _logger2.default)('quill:keyboard');
|
5518
|
-
|
5519
|
-
var SHORTKEY = /Mac/i.test(navigator.platform) ? 'metaKey' : 'ctrlKey';
|
5520
|
-
|
5521
|
-
var Keyboard = function (_Module) {
|
5522
|
-
_inherits(Keyboard, _Module);
|
5523
|
-
|
5524
|
-
_createClass(Keyboard, null, [{
|
5525
|
-
key: 'match',
|
5526
|
-
value: function match(evt, binding) {
|
5527
|
-
binding = normalize(binding);
|
5528
|
-
if (['altKey', 'ctrlKey', 'metaKey', 'shiftKey'].some(function (key) {
|
5529
|
-
return !!binding[key] !== evt[key] && binding[key] !== null;
|
5530
|
-
})) {
|
5531
|
-
return false;
|
5532
|
-
}
|
5533
|
-
return binding.key === (evt.which || evt.keyCode);
|
5534
|
-
}
|
5535
|
-
}]);
|
5536
|
-
|
5537
|
-
function Keyboard(quill, options) {
|
5538
|
-
_classCallCheck(this, Keyboard);
|
5539
|
-
|
5540
|
-
var _this = _possibleConstructorReturn(this, (Keyboard.__proto__ || Object.getPrototypeOf(Keyboard)).call(this, quill, options));
|
5541
|
-
|
5542
|
-
_this.bindings = {};
|
5543
|
-
Object.keys(_this.options.bindings).forEach(function (name) {
|
5544
|
-
if (name === 'list autofill' && quill.scroll.whitelist != null && !quill.scroll.whitelist['list']) {
|
5545
|
-
return;
|
5546
|
-
}
|
5547
|
-
if (_this.options.bindings[name]) {
|
5548
|
-
_this.addBinding(_this.options.bindings[name]);
|
5549
|
-
}
|
5550
|
-
});
|
5551
|
-
_this.addBinding({ key: Keyboard.keys.ENTER, shiftKey: null }, handleEnter);
|
5552
|
-
_this.addBinding({ key: Keyboard.keys.ENTER, metaKey: null, ctrlKey: null, altKey: null }, function () {});
|
5553
|
-
if (/Firefox/i.test(navigator.userAgent)) {
|
5554
|
-
// Need to handle delete and backspace for Firefox in the general case #1171
|
5555
|
-
_this.addBinding({ key: Keyboard.keys.BACKSPACE }, { collapsed: true }, handleBackspace);
|
5556
|
-
_this.addBinding({ key: Keyboard.keys.DELETE }, { collapsed: true }, handleDelete);
|
5557
|
-
} else {
|
5558
|
-
_this.addBinding({ key: Keyboard.keys.BACKSPACE }, { collapsed: true, prefix: /^.?$/ }, handleBackspace);
|
5559
|
-
_this.addBinding({ key: Keyboard.keys.DELETE }, { collapsed: true, suffix: /^.?$/ }, handleDelete);
|
5560
|
-
}
|
5561
|
-
_this.addBinding({ key: Keyboard.keys.BACKSPACE }, { collapsed: false }, handleDeleteRange);
|
5562
|
-
_this.addBinding({ key: Keyboard.keys.DELETE }, { collapsed: false }, handleDeleteRange);
|
5563
|
-
_this.addBinding({ key: Keyboard.keys.BACKSPACE, altKey: null, ctrlKey: null, metaKey: null, shiftKey: null }, { collapsed: true, offset: 0 }, handleBackspace);
|
5564
|
-
_this.listen();
|
5565
|
-
return _this;
|
5566
|
-
}
|
5567
|
-
|
5568
|
-
_createClass(Keyboard, [{
|
5569
|
-
key: 'addBinding',
|
5570
|
-
value: function addBinding(key) {
|
5571
|
-
var context = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
5572
|
-
var handler = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
5573
|
-
|
5574
|
-
var binding = normalize(key);
|
5575
|
-
if (binding == null || binding.key == null) {
|
5576
|
-
return debug.warn('Attempted to add invalid keyboard binding', binding);
|
5577
|
-
}
|
5578
|
-
if (typeof context === 'function') {
|
5579
|
-
context = { handler: context };
|
5580
|
-
}
|
5581
|
-
if (typeof handler === 'function') {
|
5582
|
-
handler = { handler: handler };
|
5583
|
-
}
|
5584
|
-
binding = (0, _extend2.default)(binding, context, handler);
|
5585
|
-
this.bindings[binding.key] = this.bindings[binding.key] || [];
|
5586
|
-
this.bindings[binding.key].push(binding);
|
5587
|
-
}
|
5588
|
-
}, {
|
5589
|
-
key: 'listen',
|
5590
|
-
value: function listen() {
|
5591
|
-
var _this2 = this;
|
5592
|
-
|
5593
|
-
this.quill.root.addEventListener('keydown', function (evt) {
|
5594
|
-
if (evt.defaultPrevented) return;
|
5595
|
-
var which = evt.which || evt.keyCode;
|
5596
|
-
var bindings = (_this2.bindings[which] || []).filter(function (binding) {
|
5597
|
-
return Keyboard.match(evt, binding);
|
5598
|
-
});
|
5599
|
-
if (bindings.length === 0) return;
|
5600
|
-
var range = _this2.quill.getSelection();
|
5601
|
-
if (range == null || !_this2.quill.hasFocus()) return;
|
5602
|
-
|
5603
|
-
var _quill$getLine = _this2.quill.getLine(range.index),
|
5604
|
-
_quill$getLine2 = _slicedToArray(_quill$getLine, 2),
|
5605
|
-
line = _quill$getLine2[0],
|
5606
|
-
offset = _quill$getLine2[1];
|
5607
|
-
|
5608
|
-
var _quill$getLeaf = _this2.quill.getLeaf(range.index),
|
5609
|
-
_quill$getLeaf2 = _slicedToArray(_quill$getLeaf, 2),
|
5610
|
-
leafStart = _quill$getLeaf2[0],
|
5611
|
-
offsetStart = _quill$getLeaf2[1];
|
5612
|
-
|
5613
|
-
var _ref = range.length === 0 ? [leafStart, offsetStart] : _this2.quill.getLeaf(range.index + range.length),
|
5614
|
-
_ref2 = _slicedToArray(_ref, 2),
|
5615
|
-
leafEnd = _ref2[0],
|
5616
|
-
offsetEnd = _ref2[1];
|
5617
|
-
|
5618
|
-
var prefixText = leafStart instanceof _parchment2.default.Text ? leafStart.value().slice(0, offsetStart) : '';
|
5619
|
-
var suffixText = leafEnd instanceof _parchment2.default.Text ? leafEnd.value().slice(offsetEnd) : '';
|
5620
|
-
var curContext = {
|
5621
|
-
collapsed: range.length === 0,
|
5622
|
-
empty: range.length === 0 && line.length() <= 1,
|
5623
|
-
format: _this2.quill.getFormat(range),
|
5624
|
-
offset: offset,
|
5625
|
-
prefix: prefixText,
|
5626
|
-
suffix: suffixText
|
5627
|
-
};
|
5628
|
-
var prevented = bindings.some(function (binding) {
|
5629
|
-
if (binding.collapsed != null && binding.collapsed !== curContext.collapsed) return false;
|
5630
|
-
if (binding.empty != null && binding.empty !== curContext.empty) return false;
|
5631
|
-
if (binding.offset != null && binding.offset !== curContext.offset) return false;
|
5632
|
-
if (Array.isArray(binding.format)) {
|
5633
|
-
// any format is present
|
5634
|
-
if (binding.format.every(function (name) {
|
5635
|
-
return curContext.format[name] == null;
|
5636
|
-
})) {
|
5637
|
-
return false;
|
5638
|
-
}
|
5639
|
-
} else if (_typeof(binding.format) === 'object') {
|
5640
|
-
// all formats must match
|
5641
|
-
if (!Object.keys(binding.format).every(function (name) {
|
5642
|
-
if (binding.format[name] === true) return curContext.format[name] != null;
|
5643
|
-
if (binding.format[name] === false) return curContext.format[name] == null;
|
5644
|
-
return (0, _deepEqual2.default)(binding.format[name], curContext.format[name]);
|
5645
|
-
})) {
|
5646
|
-
return false;
|
5647
|
-
}
|
5648
|
-
}
|
5649
|
-
if (binding.prefix != null && !binding.prefix.test(curContext.prefix)) return false;
|
5650
|
-
if (binding.suffix != null && !binding.suffix.test(curContext.suffix)) return false;
|
5651
|
-
return binding.handler.call(_this2, range, curContext) !== true;
|
5652
|
-
});
|
5653
|
-
if (prevented) {
|
5654
|
-
evt.preventDefault();
|
5655
|
-
}
|
5656
|
-
});
|
5657
|
-
}
|
5658
|
-
}]);
|
5659
|
-
|
5660
|
-
return Keyboard;
|
5661
|
-
}(_module2.default);
|
5662
|
-
|
5663
|
-
Keyboard.keys = {
|
5664
|
-
BACKSPACE: 8,
|
5665
|
-
TAB: 9,
|
5666
|
-
ENTER: 13,
|
5667
|
-
ESCAPE: 27,
|
5668
|
-
LEFT: 37,
|
5669
|
-
UP: 38,
|
5670
|
-
RIGHT: 39,
|
5671
|
-
DOWN: 40,
|
5672
|
-
DELETE: 46
|
5673
|
-
};
|
5674
|
-
|
5675
|
-
Keyboard.DEFAULTS = {
|
5676
|
-
bindings: {
|
5677
|
-
'bold': makeFormatHandler('bold'),
|
5678
|
-
'italic': makeFormatHandler('italic'),
|
5679
|
-
'underline': makeFormatHandler('underline'),
|
5680
|
-
'indent': {
|
5681
|
-
// highlight tab or tab at beginning of list, indent or blockquote
|
5682
|
-
key: Keyboard.keys.TAB,
|
5683
|
-
format: ['blockquote', 'indent', 'list'],
|
5684
|
-
handler: function handler(range, context) {
|
5685
|
-
if (context.collapsed && context.offset !== 0) return true;
|
5686
|
-
this.quill.format('indent', '+1', _quill2.default.sources.USER);
|
5687
|
-
}
|
5688
|
-
},
|
5689
|
-
'outdent': {
|
5690
|
-
key: Keyboard.keys.TAB,
|
5691
|
-
shiftKey: true,
|
5692
|
-
format: ['blockquote', 'indent', 'list'],
|
5693
|
-
// highlight tab or tab at beginning of list, indent or blockquote
|
5694
|
-
handler: function handler(range, context) {
|
5695
|
-
if (context.collapsed && context.offset !== 0) return true;
|
5696
|
-
this.quill.format('indent', '-1', _quill2.default.sources.USER);
|
5697
|
-
}
|
5698
|
-
},
|
5699
|
-
'outdent backspace': {
|
5700
|
-
key: Keyboard.keys.BACKSPACE,
|
5701
|
-
collapsed: true,
|
5702
|
-
shiftKey: null,
|
5703
|
-
metaKey: null,
|
5704
|
-
ctrlKey: null,
|
5705
|
-
altKey: null,
|
5706
|
-
format: ['indent', 'list'],
|
5707
|
-
offset: 0,
|
5708
|
-
handler: function handler(range, context) {
|
5709
|
-
if (context.format.indent != null) {
|
5710
|
-
this.quill.format('indent', '-1', _quill2.default.sources.USER);
|
5711
|
-
} else if (context.format.list != null) {
|
5712
|
-
this.quill.format('list', false, _quill2.default.sources.USER);
|
5713
|
-
}
|
5714
|
-
}
|
5715
|
-
},
|
5716
|
-
'indent code-block': makeCodeBlockHandler(true),
|
5717
|
-
'outdent code-block': makeCodeBlockHandler(false),
|
5718
|
-
'remove tab': {
|
5719
|
-
key: Keyboard.keys.TAB,
|
5720
|
-
shiftKey: true,
|
5721
|
-
collapsed: true,
|
5722
|
-
prefix: /\t$/,
|
5723
|
-
handler: function handler(range) {
|
5724
|
-
this.quill.deleteText(range.index - 1, 1, _quill2.default.sources.USER);
|
5725
|
-
}
|
5726
|
-
},
|
5727
|
-
'tab': {
|
5728
|
-
key: Keyboard.keys.TAB,
|
5729
|
-
handler: function handler(range) {
|
5730
|
-
this.quill.history.cutoff();
|
5731
|
-
var delta = new _quillDelta2.default().retain(range.index).delete(range.length).insert('\t');
|
5732
|
-
this.quill.updateContents(delta, _quill2.default.sources.USER);
|
5733
|
-
this.quill.history.cutoff();
|
5734
|
-
this.quill.setSelection(range.index + 1, _quill2.default.sources.SILENT);
|
5735
|
-
}
|
5736
|
-
},
|
5737
|
-
'list empty enter': {
|
5738
|
-
key: Keyboard.keys.ENTER,
|
5739
|
-
collapsed: true,
|
5740
|
-
format: ['list'],
|
5741
|
-
empty: true,
|
5742
|
-
handler: function handler(range, context) {
|
5743
|
-
this.quill.format('list', false, _quill2.default.sources.USER);
|
5744
|
-
if (context.format.indent) {
|
5745
|
-
this.quill.format('indent', false, _quill2.default.sources.USER);
|
6011
|
+
matches.forEach(function (name) {
|
6012
|
+
node.classList.remove(name);
|
6013
|
+
});
|
6014
|
+
if (node.classList.length === 0) {
|
6015
|
+
node.removeAttribute('class');
|
5746
6016
|
}
|
5747
|
-
|
5748
|
-
|
5749
|
-
|
5750
|
-
|
5751
|
-
|
5752
|
-
|
5753
|
-
|
5754
|
-
|
5755
|
-
|
5756
|
-
line = _quill$getLine4[0],
|
5757
|
-
offset = _quill$getLine4[1];
|
6017
|
+
};
|
6018
|
+
ClassAttributor.prototype.value = function (node) {
|
6019
|
+
var result = match(node, this.keyName)[0] || '';
|
6020
|
+
var value = result.slice(this.keyName.length + 1); // +1 for hyphen
|
6021
|
+
return this.canAdd(node, value) ? value : '';
|
6022
|
+
};
|
6023
|
+
return ClassAttributor;
|
6024
|
+
}(attributor_1.default));
|
6025
|
+
exports.default = ClassAttributor;
|
5758
6026
|
|
5759
|
-
var delta = new _quillDelta2.default().retain(range.index).insert('\n', { list: 'checked' }).retain(line.length() - offset - 1).retain(1, { list: 'unchecked' });
|
5760
|
-
this.quill.updateContents(delta, _quill2.default.sources.USER);
|
5761
|
-
this.quill.setSelection(range.index + 1, _quill2.default.sources.SILENT);
|
5762
|
-
this.quill.scrollIntoView();
|
5763
|
-
}
|
5764
|
-
},
|
5765
|
-
'header enter': {
|
5766
|
-
key: Keyboard.keys.ENTER,
|
5767
|
-
collapsed: true,
|
5768
|
-
format: ['header'],
|
5769
|
-
suffix: /^$/,
|
5770
|
-
handler: function handler(range, context) {
|
5771
|
-
var _quill$getLine5 = this.quill.getLine(range.index),
|
5772
|
-
_quill$getLine6 = _slicedToArray(_quill$getLine5, 2),
|
5773
|
-
line = _quill$getLine6[0],
|
5774
|
-
offset = _quill$getLine6[1];
|
5775
6027
|
|
5776
|
-
|
5777
|
-
|
5778
|
-
|
5779
|
-
this.quill.scrollIntoView();
|
5780
|
-
}
|
5781
|
-
},
|
5782
|
-
'list autofill': {
|
5783
|
-
key: ' ',
|
5784
|
-
collapsed: true,
|
5785
|
-
format: { list: false },
|
5786
|
-
prefix: /^\s*?(1\.|-|\[ ?\]|\[x\])$/,
|
5787
|
-
handler: function handler(range, context) {
|
5788
|
-
var length = context.prefix.length;
|
6028
|
+
/***/ }),
|
6029
|
+
/* 33 */
|
6030
|
+
/***/ (function(module, exports, __webpack_require__) {
|
5789
6031
|
|
5790
|
-
|
5791
|
-
_quill$getLine8 = _slicedToArray(_quill$getLine7, 2),
|
5792
|
-
line = _quill$getLine8[0],
|
5793
|
-
offset = _quill$getLine8[1];
|
6032
|
+
"use strict";
|
5794
6033
|
|
5795
|
-
|
5796
|
-
|
5797
|
-
|
5798
|
-
|
5799
|
-
|
5800
|
-
|
5801
|
-
|
5802
|
-
|
5803
|
-
|
5804
|
-
|
5805
|
-
|
5806
|
-
|
5807
|
-
|
5808
|
-
|
6034
|
+
var __extends = (this && this.__extends) || (function () {
|
6035
|
+
var extendStatics = Object.setPrototypeOf ||
|
6036
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
6037
|
+
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
|
6038
|
+
return function (d, b) {
|
6039
|
+
extendStatics(d, b);
|
6040
|
+
function __() { this.constructor = d; }
|
6041
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
6042
|
+
};
|
6043
|
+
})();
|
6044
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
6045
|
+
var attributor_1 = __webpack_require__(12);
|
6046
|
+
function camelize(name) {
|
6047
|
+
var parts = name.split('-');
|
6048
|
+
var rest = parts
|
6049
|
+
.slice(1)
|
6050
|
+
.map(function (part) {
|
6051
|
+
return part[0].toUpperCase() + part.slice(1);
|
6052
|
+
})
|
6053
|
+
.join('');
|
6054
|
+
return parts[0] + rest;
|
6055
|
+
}
|
6056
|
+
var StyleAttributor = /** @class */ (function (_super) {
|
6057
|
+
__extends(StyleAttributor, _super);
|
6058
|
+
function StyleAttributor() {
|
6059
|
+
return _super !== null && _super.apply(this, arguments) || this;
|
6060
|
+
}
|
6061
|
+
StyleAttributor.keys = function (node) {
|
6062
|
+
return (node.getAttribute('style') || '').split(';').map(function (value) {
|
6063
|
+
var arr = value.split(':');
|
6064
|
+
return arr[0].trim();
|
6065
|
+
});
|
6066
|
+
};
|
6067
|
+
StyleAttributor.prototype.add = function (node, value) {
|
6068
|
+
if (!this.canAdd(node, value))
|
6069
|
+
return false;
|
6070
|
+
// @ts-ignore
|
6071
|
+
node.style[camelize(this.keyName)] = value;
|
6072
|
+
return true;
|
6073
|
+
};
|
6074
|
+
StyleAttributor.prototype.remove = function (node) {
|
6075
|
+
// @ts-ignore
|
6076
|
+
node.style[camelize(this.keyName)] = '';
|
6077
|
+
if (!node.getAttribute('style')) {
|
6078
|
+
node.removeAttribute('style');
|
5809
6079
|
}
|
5810
|
-
|
5811
|
-
|
5812
|
-
|
5813
|
-
|
5814
|
-
this.
|
5815
|
-
|
5816
|
-
|
5817
|
-
|
5818
|
-
|
5819
|
-
key: Keyboard.keys.ENTER,
|
5820
|
-
collapsed: true,
|
5821
|
-
format: ['code-block'],
|
5822
|
-
prefix: /\n\n$/,
|
5823
|
-
suffix: /^\s+$/,
|
5824
|
-
handler: function handler(range) {
|
5825
|
-
var _quill$getLine9 = this.quill.getLine(range.index),
|
5826
|
-
_quill$getLine10 = _slicedToArray(_quill$getLine9, 2),
|
5827
|
-
line = _quill$getLine10[0],
|
5828
|
-
offset = _quill$getLine10[1];
|
6080
|
+
};
|
6081
|
+
StyleAttributor.prototype.value = function (node) {
|
6082
|
+
// @ts-ignore
|
6083
|
+
var value = node.style[camelize(this.keyName)];
|
6084
|
+
return this.canAdd(node, value) ? value : '';
|
6085
|
+
};
|
6086
|
+
return StyleAttributor;
|
6087
|
+
}(attributor_1.default));
|
6088
|
+
exports.default = StyleAttributor;
|
5829
6089
|
|
5830
|
-
|
5831
|
-
|
5832
|
-
|
5833
|
-
|
5834
|
-
|
5835
|
-
|
5836
|
-
|
5837
|
-
|
6090
|
+
|
6091
|
+
/***/ }),
|
6092
|
+
/* 34 */
|
6093
|
+
/***/ (function(module, exports, __webpack_require__) {
|
6094
|
+
|
6095
|
+
"use strict";
|
6096
|
+
|
6097
|
+
|
6098
|
+
Object.defineProperty(exports, "__esModule", {
|
6099
|
+
value: true
|
6100
|
+
});
|
6101
|
+
|
6102
|
+
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; }; }();
|
6103
|
+
|
6104
|
+
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
6105
|
+
|
6106
|
+
var Theme = function () {
|
6107
|
+
function Theme(quill, options) {
|
6108
|
+
_classCallCheck(this, Theme);
|
6109
|
+
|
6110
|
+
this.quill = quill;
|
6111
|
+
this.options = options;
|
6112
|
+
this.modules = {};
|
5838
6113
|
}
|
5839
|
-
};
|
5840
6114
|
|
5841
|
-
|
5842
|
-
|
6115
|
+
_createClass(Theme, [{
|
6116
|
+
key: 'init',
|
6117
|
+
value: function init() {
|
6118
|
+
var _this = this;
|
5843
6119
|
|
5844
|
-
|
5845
|
-
|
5846
|
-
|
5847
|
-
|
5848
|
-
|
5849
|
-
|
5850
|
-
|
5851
|
-
|
6120
|
+
Object.keys(this.options.modules).forEach(function (name) {
|
6121
|
+
if (_this.modules[name] == null) {
|
6122
|
+
_this.addModule(name);
|
6123
|
+
}
|
6124
|
+
});
|
6125
|
+
}
|
6126
|
+
}, {
|
6127
|
+
key: 'addModule',
|
6128
|
+
value: function addModule(name) {
|
6129
|
+
var moduleClass = this.quill.constructor.import('modules/' + name);
|
6130
|
+
this.modules[name] = new moduleClass(this.quill, this.options.modules[name] || {});
|
6131
|
+
return this.modules[name];
|
5852
6132
|
}
|
6133
|
+
}]);
|
5853
6134
|
|
5854
|
-
|
5855
|
-
|
5856
|
-
leaf = _quill$getLeaf4[0];
|
6135
|
+
return Theme;
|
6136
|
+
}();
|
5857
6137
|
|
5858
|
-
|
5859
|
-
|
5860
|
-
|
5861
|
-
|
5862
|
-
|
5863
|
-
|
5864
|
-
}
|
5865
|
-
} else {
|
5866
|
-
if (shiftKey) {
|
5867
|
-
this.quill.setSelection(range.index, range.length + 1, _quill2.default.sources.USER);
|
5868
|
-
} else {
|
5869
|
-
this.quill.setSelection(range.index + range.length + 1, _quill2.default.sources.USER);
|
5870
|
-
}
|
5871
|
-
}
|
5872
|
-
return false;
|
5873
|
-
}), _ref3;
|
5874
|
-
}
|
6138
|
+
Theme.DEFAULTS = {
|
6139
|
+
modules: {}
|
6140
|
+
};
|
6141
|
+
Theme.themes = {
|
6142
|
+
'default': Theme
|
6143
|
+
};
|
5875
6144
|
|
5876
|
-
|
5877
|
-
if (range.index === 0 || this.quill.getLength() <= 1) return;
|
6145
|
+
exports.default = Theme;
|
5878
6146
|
|
5879
|
-
|
5880
|
-
|
5881
|
-
|
6147
|
+
/***/ }),
|
6148
|
+
/* 35 */
|
6149
|
+
/***/ (function(module, exports, __webpack_require__) {
|
5882
6150
|
|
5883
|
-
|
5884
|
-
if (context.offset === 0) {
|
5885
|
-
var _quill$getLine13 = this.quill.getLine(range.index - 1),
|
5886
|
-
_quill$getLine14 = _slicedToArray(_quill$getLine13, 1),
|
5887
|
-
prev = _quill$getLine14[0];
|
6151
|
+
"use strict";
|
5888
6152
|
|
5889
|
-
if (prev != null && prev.length() > 1) {
|
5890
|
-
var curFormats = line.formats();
|
5891
|
-
var prevFormats = this.quill.getFormat(range.index - 1, 1);
|
5892
|
-
formats = _op2.default.attributes.diff(curFormats, prevFormats) || {};
|
5893
|
-
}
|
5894
|
-
}
|
5895
|
-
// Check for astral symbols
|
5896
|
-
var length = /[\uD800-\uDBFF][\uDC00-\uDFFF]$/.test(context.prefix) ? 2 : 1;
|
5897
|
-
this.quill.deleteText(range.index - length, length, _quill2.default.sources.USER);
|
5898
|
-
if (Object.keys(formats).length > 0) {
|
5899
|
-
this.quill.formatLine(range.index - length, length, formats, _quill2.default.sources.USER);
|
5900
|
-
}
|
5901
|
-
this.quill.focus();
|
5902
|
-
}
|
5903
6153
|
|
5904
|
-
|
5905
|
-
|
5906
|
-
|
5907
|
-
|
5908
|
-
|
5909
|
-
nextLength = 0;
|
6154
|
+
Object.defineProperty(exports, "__esModule", {
|
6155
|
+
value: true
|
6156
|
+
});
|
6157
|
+
|
6158
|
+
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; }; }();
|
5910
6159
|
|
5911
|
-
|
5912
|
-
_quill$getLine16 = _slicedToArray(_quill$getLine15, 1),
|
5913
|
-
line = _quill$getLine16[0];
|
6160
|
+
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); } };
|
5914
6161
|
|
5915
|
-
|
5916
|
-
var _quill$getLine17 = this.quill.getLine(range.index + 1),
|
5917
|
-
_quill$getLine18 = _slicedToArray(_quill$getLine17, 1),
|
5918
|
-
next = _quill$getLine18[0];
|
6162
|
+
var _parchment = __webpack_require__(0);
|
5919
6163
|
|
5920
|
-
|
5921
|
-
var curFormats = line.formats();
|
5922
|
-
var nextFormats = this.quill.getFormat(range.index, 1);
|
5923
|
-
formats = _op2.default.attributes.diff(curFormats, nextFormats) || {};
|
5924
|
-
nextLength = next.length();
|
5925
|
-
}
|
5926
|
-
}
|
5927
|
-
this.quill.deleteText(range.index, length, _quill2.default.sources.USER);
|
5928
|
-
if (Object.keys(formats).length > 0) {
|
5929
|
-
this.quill.formatLine(range.index + nextLength - 1, length, formats, _quill2.default.sources.USER);
|
5930
|
-
}
|
5931
|
-
}
|
6164
|
+
var _parchment2 = _interopRequireDefault(_parchment);
|
5932
6165
|
|
5933
|
-
|
5934
|
-
var lines = this.quill.getLines(range);
|
5935
|
-
var formats = {};
|
5936
|
-
if (lines.length > 1) {
|
5937
|
-
var firstFormats = lines[0].formats();
|
5938
|
-
var lastFormats = lines[lines.length - 1].formats();
|
5939
|
-
formats = _op2.default.attributes.diff(lastFormats, firstFormats) || {};
|
5940
|
-
}
|
5941
|
-
this.quill.deleteText(range, _quill2.default.sources.USER);
|
5942
|
-
if (Object.keys(formats).length > 0) {
|
5943
|
-
this.quill.formatLine(range.index, 1, formats, _quill2.default.sources.USER);
|
5944
|
-
}
|
5945
|
-
this.quill.setSelection(range.index, _quill2.default.sources.SILENT);
|
5946
|
-
this.quill.focus();
|
5947
|
-
}
|
6166
|
+
var _text = __webpack_require__(7);
|
5948
6167
|
|
5949
|
-
|
5950
|
-
var _this3 = this;
|
6168
|
+
var _text2 = _interopRequireDefault(_text);
|
5951
6169
|
|
5952
|
-
|
5953
|
-
this.quill.scroll.deleteAt(range.index, range.length); // So we do not trigger text-change
|
5954
|
-
}
|
5955
|
-
var lineFormats = Object.keys(context.format).reduce(function (lineFormats, format) {
|
5956
|
-
if (_parchment2.default.query(format, _parchment2.default.Scope.BLOCK) && !Array.isArray(context.format[format])) {
|
5957
|
-
lineFormats[format] = context.format[format];
|
5958
|
-
}
|
5959
|
-
return lineFormats;
|
5960
|
-
}, {});
|
5961
|
-
this.quill.insertText(range.index, '\n', lineFormats, _quill2.default.sources.USER);
|
5962
|
-
// Earlier scroll.deleteAt might have messed up our selection,
|
5963
|
-
// so insertText's built in selection preservation is not reliable
|
5964
|
-
this.quill.setSelection(range.index + 1, _quill2.default.sources.SILENT);
|
5965
|
-
this.quill.focus();
|
5966
|
-
Object.keys(context.format).forEach(function (name) {
|
5967
|
-
if (lineFormats[name] != null) return;
|
5968
|
-
if (Array.isArray(context.format[name])) return;
|
5969
|
-
if (name === 'link') return;
|
5970
|
-
_this3.quill.format(name, context.format[name], _quill2.default.sources.USER);
|
5971
|
-
});
|
5972
|
-
}
|
6170
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
5973
6171
|
|
5974
|
-
function
|
5975
|
-
return {
|
5976
|
-
key: Keyboard.keys.TAB,
|
5977
|
-
shiftKey: !indent,
|
5978
|
-
format: { 'code-block': true },
|
5979
|
-
handler: function handler(range) {
|
5980
|
-
var CodeBlock = _parchment2.default.query('code-block');
|
5981
|
-
var index = range.index,
|
5982
|
-
length = range.length;
|
6172
|
+
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
5983
6173
|
|
5984
|
-
|
5985
|
-
_quill$scroll$descend2 = _slicedToArray(_quill$scroll$descend, 2),
|
5986
|
-
block = _quill$scroll$descend2[0],
|
5987
|
-
offset = _quill$scroll$descend2[1];
|
6174
|
+
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; }
|
5988
6175
|
|
5989
|
-
|
5990
|
-
|
5991
|
-
|
5992
|
-
|
5993
|
-
|
5994
|
-
|
5995
|
-
|
5996
|
-
|
5997
|
-
|
5998
|
-
|
5999
|
-
|
6000
|
-
|
6001
|
-
|
6002
|
-
|
6003
|
-
|
6004
|
-
|
6005
|
-
|
6006
|
-
|
6007
|
-
|
6008
|
-
|
6009
|
-
|
6010
|
-
|
6011
|
-
|
6176
|
+
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; }
|
6177
|
+
|
6178
|
+
var GUARD_TEXT = '\uFEFF';
|
6179
|
+
|
6180
|
+
var Embed = function (_Parchment$Embed) {
|
6181
|
+
_inherits(Embed, _Parchment$Embed);
|
6182
|
+
|
6183
|
+
function Embed(node) {
|
6184
|
+
_classCallCheck(this, Embed);
|
6185
|
+
|
6186
|
+
var _this = _possibleConstructorReturn(this, (Embed.__proto__ || Object.getPrototypeOf(Embed)).call(this, node));
|
6187
|
+
|
6188
|
+
_this.contentNode = document.createElement('span');
|
6189
|
+
_this.contentNode.setAttribute('contenteditable', false);
|
6190
|
+
[].slice.call(_this.domNode.childNodes).forEach(function (childNode) {
|
6191
|
+
_this.contentNode.appendChild(childNode);
|
6192
|
+
});
|
6193
|
+
_this.leftGuard = document.createTextNode(GUARD_TEXT);
|
6194
|
+
_this.rightGuard = document.createTextNode(GUARD_TEXT);
|
6195
|
+
_this.domNode.appendChild(_this.leftGuard);
|
6196
|
+
_this.domNode.appendChild(_this.contentNode);
|
6197
|
+
_this.domNode.appendChild(_this.rightGuard);
|
6198
|
+
return _this;
|
6199
|
+
}
|
6200
|
+
|
6201
|
+
_createClass(Embed, [{
|
6202
|
+
key: 'index',
|
6203
|
+
value: function index(node, offset) {
|
6204
|
+
if (node === this.leftGuard) return 0;
|
6205
|
+
if (node === this.rightGuard) return 1;
|
6206
|
+
return _get(Embed.prototype.__proto__ || Object.getPrototypeOf(Embed.prototype), 'index', this).call(this, node, offset);
|
6207
|
+
}
|
6208
|
+
}, {
|
6209
|
+
key: 'restore',
|
6210
|
+
value: function restore(node) {
|
6211
|
+
var range = void 0,
|
6212
|
+
textNode = void 0;
|
6213
|
+
var text = node.data.split(GUARD_TEXT).join('');
|
6214
|
+
if (node === this.leftGuard) {
|
6215
|
+
if (this.prev instanceof _text2.default) {
|
6216
|
+
var prevLength = this.prev.length();
|
6217
|
+
this.prev.insertAt(prevLength, text);
|
6218
|
+
range = {
|
6219
|
+
startNode: this.prev.domNode,
|
6220
|
+
startOffset: prevLength + text.length
|
6221
|
+
};
|
6222
|
+
} else {
|
6223
|
+
textNode = document.createTextNode(text);
|
6224
|
+
this.parent.insertBefore(_parchment2.default.create(textNode), this);
|
6225
|
+
range = {
|
6226
|
+
startNode: textNode,
|
6227
|
+
startOffset: text.length
|
6228
|
+
};
|
6012
6229
|
}
|
6013
|
-
|
6014
|
-
|
6015
|
-
|
6016
|
-
|
6230
|
+
} else if (node === this.rightGuard) {
|
6231
|
+
if (this.next instanceof _text2.default) {
|
6232
|
+
this.next.insertAt(0, text);
|
6233
|
+
range = {
|
6234
|
+
startNode: this.next.domNode,
|
6235
|
+
startOffset: text.length
|
6236
|
+
};
|
6237
|
+
} else {
|
6238
|
+
textNode = document.createTextNode(text);
|
6239
|
+
this.parent.insertBefore(_parchment2.default.create(textNode), this.next);
|
6240
|
+
range = {
|
6241
|
+
startNode: textNode,
|
6242
|
+
startOffset: text.length
|
6243
|
+
};
|
6244
|
+
}
|
6245
|
+
}
|
6246
|
+
node.data = GUARD_TEXT;
|
6247
|
+
return range;
|
6017
6248
|
}
|
6018
|
-
}
|
6019
|
-
|
6249
|
+
}, {
|
6250
|
+
key: 'update',
|
6251
|
+
value: function update(mutations, context) {
|
6252
|
+
var _this2 = this;
|
6020
6253
|
|
6021
|
-
function
|
6022
|
-
|
6023
|
-
|
6024
|
-
|
6025
|
-
|
6026
|
-
|
6254
|
+
mutations.forEach(function (mutation) {
|
6255
|
+
if (mutation.type === 'characterData' && (mutation.target === _this2.leftGuard || mutation.target === _this2.rightGuard)) {
|
6256
|
+
var range = _this2.restore(mutation.target);
|
6257
|
+
if (range) context.range = range;
|
6258
|
+
}
|
6259
|
+
});
|
6027
6260
|
}
|
6028
|
-
};
|
6029
|
-
}
|
6261
|
+
}]);
|
6030
6262
|
|
6031
|
-
|
6032
|
-
|
6033
|
-
return normalize({ key: binding });
|
6034
|
-
}
|
6035
|
-
if ((typeof binding === 'undefined' ? 'undefined' : _typeof(binding)) === 'object') {
|
6036
|
-
binding = (0, _clone2.default)(binding, false);
|
6037
|
-
}
|
6038
|
-
if (typeof binding.key === 'string') {
|
6039
|
-
if (Keyboard.keys[binding.key.toUpperCase()] != null) {
|
6040
|
-
binding.key = Keyboard.keys[binding.key.toUpperCase()];
|
6041
|
-
} else if (binding.key.length === 1) {
|
6042
|
-
binding.key = binding.key.toUpperCase().charCodeAt(0);
|
6043
|
-
} else {
|
6044
|
-
return null;
|
6045
|
-
}
|
6046
|
-
}
|
6047
|
-
if (binding.shortKey) {
|
6048
|
-
binding[SHORTKEY] = binding.shortKey;
|
6049
|
-
delete binding.shortKey;
|
6050
|
-
}
|
6051
|
-
return binding;
|
6052
|
-
}
|
6263
|
+
return Embed;
|
6264
|
+
}(_parchment2.default.Embed);
|
6053
6265
|
|
6054
|
-
exports.default =
|
6055
|
-
exports.SHORTKEY = SHORTKEY;
|
6266
|
+
exports.default = Embed;
|
6056
6267
|
|
6057
6268
|
/***/ }),
|
6058
6269
|
/* 36 */
|
@@ -6358,13 +6569,13 @@ var History = function (_Module) {
|
|
6358
6569
|
value: function change(source, dest) {
|
6359
6570
|
if (this.stack[source].length === 0) return;
|
6360
6571
|
var delta = this.stack[source].pop();
|
6572
|
+
this.stack[dest].push(delta);
|
6361
6573
|
this.lastRecorded = 0;
|
6362
6574
|
this.ignoreChange = true;
|
6363
6575
|
this.quill.updateContents(delta[source], _quill2.default.sources.USER);
|
6364
6576
|
this.ignoreChange = false;
|
6365
6577
|
var index = getLastChangeIndex(delta[source]);
|
6366
6578
|
this.quill.setSelection(index);
|
6367
|
-
this.stack[dest].push(delta);
|
6368
6579
|
}
|
6369
6580
|
}, {
|
6370
6581
|
key: 'clear',
|
@@ -6488,7 +6699,7 @@ var _emitter = __webpack_require__(8);
|
|
6488
6699
|
|
6489
6700
|
var _emitter2 = _interopRequireDefault(_emitter);
|
6490
6701
|
|
6491
|
-
var _keyboard = __webpack_require__(
|
6702
|
+
var _keyboard = __webpack_require__(23);
|
6492
6703
|
|
6493
6704
|
var _keyboard2 = _interopRequireDefault(_keyboard);
|
6494
6705
|
|
@@ -6553,7 +6764,7 @@ var BaseTheme = function (_Theme) {
|
|
6553
6764
|
});
|
6554
6765
|
}
|
6555
6766
|
};
|
6556
|
-
|
6767
|
+
quill.emitter.listenDOM('click', document.body, listener);
|
6557
6768
|
return _this;
|
6558
6769
|
}
|
6559
6770
|
|
@@ -6812,7 +7023,7 @@ exports.default = BaseTheme;
|
|
6812
7023
|
Object.defineProperty(exports, "__esModule", { value: true });
|
6813
7024
|
var LinkedList = /** @class */ (function () {
|
6814
7025
|
function LinkedList() {
|
6815
|
-
this.head = this.tail =
|
7026
|
+
this.head = this.tail = null;
|
6816
7027
|
this.length = 0;
|
6817
7028
|
}
|
6818
7029
|
LinkedList.prototype.append = function () {
|
@@ -6820,20 +7031,22 @@ var LinkedList = /** @class */ (function () {
|
|
6820
7031
|
for (var _i = 0; _i < arguments.length; _i++) {
|
6821
7032
|
nodes[_i] = arguments[_i];
|
6822
7033
|
}
|
6823
|
-
this.insertBefore(nodes[0],
|
7034
|
+
this.insertBefore(nodes[0], null);
|
6824
7035
|
if (nodes.length > 1) {
|
6825
7036
|
this.append.apply(this, nodes.slice(1));
|
6826
7037
|
}
|
6827
7038
|
};
|
6828
7039
|
LinkedList.prototype.contains = function (node) {
|
6829
7040
|
var cur, next = this.iterator();
|
6830
|
-
while (cur = next()) {
|
7041
|
+
while ((cur = next())) {
|
6831
7042
|
if (cur === node)
|
6832
7043
|
return true;
|
6833
7044
|
}
|
6834
7045
|
return false;
|
6835
7046
|
};
|
6836
7047
|
LinkedList.prototype.insertBefore = function (node, refNode) {
|
7048
|
+
if (!node)
|
7049
|
+
return;
|
6837
7050
|
node.next = refNode;
|
6838
7051
|
if (refNode != null) {
|
6839
7052
|
node.prev = refNode.prev;
|
@@ -6851,7 +7064,7 @@ var LinkedList = /** @class */ (function () {
|
|
6851
7064
|
this.tail = node;
|
6852
7065
|
}
|
6853
7066
|
else {
|
6854
|
-
node.prev =
|
7067
|
+
node.prev = null;
|
6855
7068
|
this.head = this.tail = node;
|
6856
7069
|
}
|
6857
7070
|
this.length += 1;
|
@@ -6892,9 +7105,10 @@ var LinkedList = /** @class */ (function () {
|
|
6892
7105
|
LinkedList.prototype.find = function (index, inclusive) {
|
6893
7106
|
if (inclusive === void 0) { inclusive = false; }
|
6894
7107
|
var cur, next = this.iterator();
|
6895
|
-
while (cur = next()) {
|
7108
|
+
while ((cur = next())) {
|
6896
7109
|
var length = cur.length();
|
6897
|
-
if (index < length ||
|
7110
|
+
if (index < length ||
|
7111
|
+
(inclusive && index === length && (cur.next == null || cur.next.length() !== 0))) {
|
6898
7112
|
return [cur, index];
|
6899
7113
|
}
|
6900
7114
|
index -= length;
|
@@ -6903,7 +7117,7 @@ var LinkedList = /** @class */ (function () {
|
|
6903
7117
|
};
|
6904
7118
|
LinkedList.prototype.forEach = function (callback) {
|
6905
7119
|
var cur, next = this.iterator();
|
6906
|
-
while (cur = next()) {
|
7120
|
+
while ((cur = next())) {
|
6907
7121
|
callback(cur);
|
6908
7122
|
}
|
6909
7123
|
};
|
@@ -6931,7 +7145,7 @@ var LinkedList = /** @class */ (function () {
|
|
6931
7145
|
};
|
6932
7146
|
LinkedList.prototype.reduce = function (callback, memo) {
|
6933
7147
|
var cur, next = this.iterator();
|
6934
|
-
while (cur = next()) {
|
7148
|
+
while ((cur = next())) {
|
6935
7149
|
memo = callback(memo, cur);
|
6936
7150
|
}
|
6937
7151
|
return memo;
|
@@ -6965,18 +7179,19 @@ var OBSERVER_CONFIG = {
|
|
6965
7179
|
characterData: true,
|
6966
7180
|
characterDataOldValue: true,
|
6967
7181
|
childList: true,
|
6968
|
-
subtree: true
|
7182
|
+
subtree: true,
|
6969
7183
|
};
|
6970
7184
|
var MAX_OPTIMIZE_ITERATIONS = 100;
|
6971
7185
|
var ScrollBlot = /** @class */ (function (_super) {
|
6972
7186
|
__extends(ScrollBlot, _super);
|
6973
7187
|
function ScrollBlot(node) {
|
6974
7188
|
var _this = _super.call(this, node) || this;
|
6975
|
-
_this.
|
7189
|
+
_this.scroll = _this;
|
6976
7190
|
_this.observer = new MutationObserver(function (mutations) {
|
6977
7191
|
_this.update(mutations);
|
6978
7192
|
});
|
6979
7193
|
_this.observer.observe(_this.domNode, OBSERVER_CONFIG);
|
7194
|
+
_this.attach();
|
6980
7195
|
return _this;
|
6981
7196
|
}
|
6982
7197
|
ScrollBlot.prototype.detach = function () {
|
@@ -7020,14 +7235,21 @@ var ScrollBlot = /** @class */ (function (_super) {
|
|
7020
7235
|
return;
|
7021
7236
|
if (blot.domNode.parentNode == null)
|
7022
7237
|
return;
|
7238
|
+
// @ts-ignore
|
7023
7239
|
if (blot.domNode[Registry.DATA_KEY].mutations == null) {
|
7240
|
+
// @ts-ignore
|
7024
7241
|
blot.domNode[Registry.DATA_KEY].mutations = [];
|
7025
7242
|
}
|
7026
7243
|
if (markParent)
|
7027
7244
|
mark(blot.parent);
|
7028
7245
|
};
|
7029
7246
|
var optimize = function (blot) {
|
7030
|
-
|
7247
|
+
// Post-order traversal
|
7248
|
+
if (
|
7249
|
+
// @ts-ignore
|
7250
|
+
blot.domNode[Registry.DATA_KEY] == null ||
|
7251
|
+
// @ts-ignore
|
7252
|
+
blot.domNode[Registry.DATA_KEY].mutations == null) {
|
7031
7253
|
return;
|
7032
7254
|
}
|
7033
7255
|
if (blot instanceof container_1.default) {
|
@@ -7075,24 +7297,35 @@ var ScrollBlot = /** @class */ (function (_super) {
|
|
7075
7297
|
if (context === void 0) { context = {}; }
|
7076
7298
|
mutations = mutations || this.observer.takeRecords();
|
7077
7299
|
// TODO use WeakMap
|
7078
|
-
mutations
|
7300
|
+
mutations
|
7301
|
+
.map(function (mutation) {
|
7079
7302
|
var blot = Registry.find(mutation.target, true);
|
7080
7303
|
if (blot == null)
|
7081
|
-
return;
|
7304
|
+
return null;
|
7305
|
+
// @ts-ignore
|
7082
7306
|
if (blot.domNode[Registry.DATA_KEY].mutations == null) {
|
7307
|
+
// @ts-ignore
|
7083
7308
|
blot.domNode[Registry.DATA_KEY].mutations = [mutation];
|
7084
7309
|
return blot;
|
7085
7310
|
}
|
7086
7311
|
else {
|
7312
|
+
// @ts-ignore
|
7087
7313
|
blot.domNode[Registry.DATA_KEY].mutations.push(mutation);
|
7088
7314
|
return null;
|
7089
7315
|
}
|
7090
|
-
})
|
7091
|
-
|
7316
|
+
})
|
7317
|
+
.forEach(function (blot) {
|
7318
|
+
if (blot == null ||
|
7319
|
+
blot === _this ||
|
7320
|
+
//@ts-ignore
|
7321
|
+
blot.domNode[Registry.DATA_KEY] == null)
|
7092
7322
|
return;
|
7323
|
+
// @ts-ignore
|
7093
7324
|
blot.update(blot.domNode[Registry.DATA_KEY].mutations || [], context);
|
7094
7325
|
});
|
7326
|
+
// @ts-ignore
|
7095
7327
|
if (this.domNode[Registry.DATA_KEY].mutations != null) {
|
7328
|
+
// @ts-ignore
|
7096
7329
|
_super.prototype.update.call(this, this.domNode[Registry.DATA_KEY].mutations, context);
|
7097
7330
|
}
|
7098
7331
|
this.optimize(mutations, context);
|
@@ -7129,7 +7362,9 @@ var Registry = __webpack_require__(1);
|
|
7129
7362
|
function isEqual(obj1, obj2) {
|
7130
7363
|
if (Object.keys(obj1).length !== Object.keys(obj2).length)
|
7131
7364
|
return false;
|
7365
|
+
// @ts-ignore
|
7132
7366
|
for (var prop in obj1) {
|
7367
|
+
// @ts-ignore
|
7133
7368
|
if (obj1[prop] !== obj2[prop])
|
7134
7369
|
return false;
|
7135
7370
|
}
|
@@ -7251,7 +7486,7 @@ var BlockBlot = /** @class */ (function (_super) {
|
|
7251
7486
|
};
|
7252
7487
|
BlockBlot.prototype.update = function (mutations, context) {
|
7253
7488
|
if (navigator.userAgent.match(/Trident/)) {
|
7254
|
-
this.
|
7489
|
+
this.build();
|
7255
7490
|
}
|
7256
7491
|
else {
|
7257
7492
|
_super.prototype.update.call(this, mutations, context);
|
@@ -7344,8 +7579,9 @@ var TextBlot = /** @class */ (function (_super) {
|
|
7344
7579
|
};
|
7345
7580
|
TextBlot.value = function (domNode) {
|
7346
7581
|
var text = domNode.data;
|
7347
|
-
|
7348
|
-
|
7582
|
+
// @ts-ignore
|
7583
|
+
if (text['normalize'])
|
7584
|
+
text = text['normalize']();
|
7349
7585
|
return text;
|
7350
7586
|
};
|
7351
7587
|
TextBlot.prototype.deleteAt = function (index, length) {
|
@@ -7574,6 +7810,7 @@ function diff_main(text1, text2, cursor_pos) {
|
|
7574
7810
|
if (cursor_pos != null) {
|
7575
7811
|
diffs = fix_cursor(diffs, cursor_pos);
|
7576
7812
|
}
|
7813
|
+
diffs = fix_emoji(diffs);
|
7577
7814
|
return diffs;
|
7578
7815
|
};
|
7579
7816
|
|
@@ -8163,7 +8400,46 @@ function fix_cursor (diffs, cursor_pos) {
|
|
8163
8400
|
return diffs;
|
8164
8401
|
}
|
8165
8402
|
}
|
8403
|
+
}
|
8404
|
+
|
8405
|
+
/*
|
8406
|
+
* Check diff did not split surrogate pairs.
|
8407
|
+
* Ex. [0, '\uD83D'], [-1, '\uDC36'], [1, '\uDC2F'] -> [-1, '\uD83D\uDC36'], [1, '\uD83D\uDC2F']
|
8408
|
+
* '\uD83D\uDC36' === '🐶', '\uD83D\uDC2F' === '🐯'
|
8409
|
+
*
|
8410
|
+
* @param {Array} diffs Array of diff tuples
|
8411
|
+
* @return {Array} Array of diff tuples
|
8412
|
+
*/
|
8413
|
+
function fix_emoji (diffs) {
|
8414
|
+
var compact = false;
|
8415
|
+
var starts_with_pair_end = function(str) {
|
8416
|
+
return str.charCodeAt(0) >= 0xDC00 && str.charCodeAt(0) <= 0xDFFF;
|
8417
|
+
}
|
8418
|
+
var ends_with_pair_start = function(str) {
|
8419
|
+
return str.charCodeAt(str.length-1) >= 0xD800 && str.charCodeAt(str.length-1) <= 0xDBFF;
|
8420
|
+
}
|
8421
|
+
for (var i = 2; i < diffs.length; i += 1) {
|
8422
|
+
if (diffs[i-2][0] === DIFF_EQUAL && ends_with_pair_start(diffs[i-2][1]) &&
|
8423
|
+
diffs[i-1][0] === DIFF_DELETE && starts_with_pair_end(diffs[i-1][1]) &&
|
8424
|
+
diffs[i][0] === DIFF_INSERT && starts_with_pair_end(diffs[i][1])) {
|
8425
|
+
compact = true;
|
8426
|
+
|
8427
|
+
diffs[i-1][1] = diffs[i-2][1].slice(-1) + diffs[i-1][1];
|
8428
|
+
diffs[i][1] = diffs[i-2][1].slice(-1) + diffs[i][1];
|
8166
8429
|
|
8430
|
+
diffs[i-2][1] = diffs[i-2][1].slice(0, -1);
|
8431
|
+
}
|
8432
|
+
}
|
8433
|
+
if (!compact) {
|
8434
|
+
return diffs;
|
8435
|
+
}
|
8436
|
+
var fixed_diffs = [];
|
8437
|
+
for (var i = 0; i < diffs.length; i += 1) {
|
8438
|
+
if (diffs[i][1].length > 0) {
|
8439
|
+
fixed_diffs.push(diffs[i]);
|
8440
|
+
}
|
8441
|
+
}
|
8442
|
+
return fixed_diffs;
|
8167
8443
|
}
|
8168
8444
|
|
8169
8445
|
/*
|
@@ -8695,10 +8971,12 @@ var Clipboard = function (_Module) {
|
|
8695
8971
|
var source = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : _quill2.default.sources.API;
|
8696
8972
|
|
8697
8973
|
if (typeof index === 'string') {
|
8698
|
-
|
8974
|
+
this.quill.setContents(this.convert(index), html);
|
8975
|
+
this.quill.setSelection(0, _quill2.default.sources.SILENT);
|
8699
8976
|
} else {
|
8700
8977
|
var paste = this.convert(html);
|
8701
|
-
|
8978
|
+
this.quill.updateContents(new _quillDelta2.default().retain(index).concat(paste), source);
|
8979
|
+
this.quill.setSelection(index + paste.length(), _quill2.default.sources.SILENT);
|
8702
8980
|
}
|
8703
8981
|
}
|
8704
8982
|
}, {
|
@@ -8839,11 +9117,11 @@ function matchAttributor(node, delta) {
|
|
8839
9117
|
if (formats[attr.attrName]) return;
|
8840
9118
|
}
|
8841
9119
|
attr = ATTRIBUTE_ATTRIBUTORS[name];
|
8842
|
-
if (attr != null && attr.attrName === name) {
|
9120
|
+
if (attr != null && (attr.attrName === name || attr.keyName === name)) {
|
8843
9121
|
formats[attr.attrName] = attr.value(node) || undefined;
|
8844
9122
|
}
|
8845
9123
|
attr = STYLE_ATTRIBUTORS[name];
|
8846
|
-
if (attr != null && attr.attrName === name) {
|
9124
|
+
if (attr != null && (attr.attrName === name || attr.keyName === name)) {
|
8847
9125
|
attr = STYLE_ATTRIBUTORS[name];
|
8848
9126
|
formats[attr.attrName] = attr.value(node) || undefined;
|
8849
9127
|
}
|
@@ -9749,7 +10027,7 @@ var SnowTooltip = function (_BaseTooltip) {
|
|
9749
10027
|
return SnowTooltip;
|
9750
10028
|
}(_base.BaseTooltip);
|
9751
10029
|
|
9752
|
-
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('');
|
10030
|
+
SnowTooltip.TEMPLATE = ['<a class="ql-preview" rel="noopener noreferrer" 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('');
|
9753
10031
|
|
9754
10032
|
exports.default = SnowTheme;
|
9755
10033
|
|
@@ -9760,6 +10038,10 @@ exports.default = SnowTheme;
|
|
9760
10038
|
"use strict";
|
9761
10039
|
|
9762
10040
|
|
10041
|
+
Object.defineProperty(exports, "__esModule", {
|
10042
|
+
value: true
|
10043
|
+
});
|
10044
|
+
|
9763
10045
|
var _core = __webpack_require__(29);
|
9764
10046
|
|
9765
10047
|
var _core2 = _interopRequireDefault(_core);
|
@@ -9928,7 +10210,7 @@ _core2.default.register({
|
|
9928
10210
|
'ui/tooltip': _tooltip2.default
|
9929
10211
|
}, true);
|
9930
10212
|
|
9931
|
-
|
10213
|
+
exports.default = _core2.default;
|
9932
10214
|
|
9933
10215
|
/***/ }),
|
9934
10216
|
/* 64 */
|
@@ -10116,7 +10398,7 @@ var _block = __webpack_require__(4);
|
|
10116
10398
|
|
10117
10399
|
var _block2 = _interopRequireDefault(_block);
|
10118
10400
|
|
10119
|
-
var _container = __webpack_require__(
|
10401
|
+
var _container = __webpack_require__(25);
|
10120
10402
|
|
10121
10403
|
var _container2 = _interopRequireDefault(_container);
|
10122
10404
|
|
@@ -10680,7 +10962,7 @@ var _createClass = function () { function defineProperties(target, props) { for
|
|
10680
10962
|
|
10681
10963
|
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); } };
|
10682
10964
|
|
10683
|
-
var _embed = __webpack_require__(
|
10965
|
+
var _embed = __webpack_require__(35);
|
10684
10966
|
|
10685
10967
|
var _embed2 = _interopRequireDefault(_embed);
|
10686
10968
|
|
@@ -11276,5 +11558,5 @@ module.exports = __webpack_require__(63);
|
|
11276
11558
|
|
11277
11559
|
|
11278
11560
|
/***/ })
|
11279
|
-
/******/ ]);
|
11561
|
+
/******/ ])["default"];
|
11280
11562
|
});
|