activeadmin_quill_editor 0.1.0 → 0.2.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +5 -5
- data/README.md +4 -3
- data/Rakefile +2 -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 +22 -16
- data/app/assets/stylesheets/activeadmin/_quill_editor_input.scss +40 -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
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 6f989d7ad5b9adc4bfdfeabc7b750379cac05dab61394d778d147acce31c681a
|
4
|
+
data.tar.gz: 2e3b77ebbcc3cce7338c3a65d751074d1517a7320acc4f6ef3c7b80bfe464f53
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2dc76a0740fa5f5664309795c9ee87d029fce479e61dd8093c91d3510de1d0fc5f737d36efe56b32920eb4931b44fef63ed3d92bcb04bf32de494f903fae71cc
|
7
|
+
data.tar.gz: 394ae3ac8ec352ef335ae051dde2e50c6d40f0aaef0331bf9cb6dc00d6e11878950c632e6ef1dab16f03e030090fce9c869e5d9af25987319e9e0f491014a5e1
|
data/README.md
CHANGED
@@ -8,7 +8,8 @@ An Active Admin plugin to use [Quill Rich Text Editor](https://github.com/quillj
|
|
8
8
|
|
9
9
|
- Update your Gemfile: `gem 'activeadmin_quill_editor'` (and execute *bundle*)
|
10
10
|
- Add at the end of your ActiveAdmin styles (_app/assets/stylesheets/active_admin.scss_):
|
11
|
-
```
|
11
|
+
```scss
|
12
|
+
@import 'activeadmin/quill_editor/quill.snow';
|
12
13
|
@import 'activeadmin/quill_editor_input';
|
13
14
|
```
|
14
15
|
- Add at the end of your ActiveAdmin javascripts (_app/assets/javascripts/active_admin.js_):
|
@@ -22,7 +23,7 @@ Why 2 separated scripts? In this way you can include a different version of *qui
|
|
22
23
|
|
23
24
|
## Options
|
24
25
|
|
25
|
-
**data-options**: permits to set *quill editor* options directly - see [options list](https://quilljs.com/docs/
|
26
|
+
**data-options**: permits to set *quill editor* options directly - see [options list](https://quilljs.com/docs/configuration/)
|
26
27
|
|
27
28
|
## Examples
|
28
29
|
|
@@ -56,7 +57,7 @@ Take a look at [other ActiveAdmin components](https://github.com/blocknotes?utf8
|
|
56
57
|
|
57
58
|
## Contributors
|
58
59
|
|
59
|
-
- [Mattia Roccoberton](http://blocknot.es)
|
60
|
+
- [Mattia Roccoberton](http://blocknot.es): author
|
60
61
|
|
61
62
|
## License
|
62
63
|
|
data/Rakefile
CHANGED
@@ -1,3 +1,3 @@
|
|
1
|
-
#
|
1
|
+
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require
|
3
|
+
require 'bundler/gem_tasks'
|
@@ -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,140 +4428,746 @@ 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];
|
4575
|
+
|
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];
|
4580
|
+
|
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
|
+
});
|
4625
|
+
}
|
4626
|
+
}]);
|
4627
|
+
|
4628
|
+
return Keyboard;
|
4629
|
+
}(_module2.default);
|
4630
|
+
|
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
|
+
};
|
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];
|
4726
|
+
|
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];
|
4744
|
+
|
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;
|
4758
|
+
|
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];
|
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];
|
4798
|
+
|
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
|
+
};
|
4809
|
+
|
4810
|
+
function makeEmbedArrowHandler(key, shiftKey) {
|
4811
|
+
var _ref3;
|
4812
|
+
|
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
|
+
}
|
4823
|
+
|
4824
|
+
var _quill$getLeaf3 = this.quill.getLeaf(index),
|
4825
|
+
_quill$getLeaf4 = _slicedToArray(_quill$getLeaf3, 1),
|
4826
|
+
leaf = _quill$getLeaf4[0];
|
4827
|
+
|
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
|
+
}
|
4845
|
+
|
4846
|
+
function handleBackspace(range, context) {
|
4847
|
+
if (range.index === 0 || this.quill.getLength() <= 1) return;
|
4848
|
+
|
4849
|
+
var _quill$getLine11 = this.quill.getLine(range.index),
|
4850
|
+
_quill$getLine12 = _slicedToArray(_quill$getLine11, 1),
|
4851
|
+
line = _quill$getLine12[0];
|
4852
|
+
|
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];
|
4858
|
+
|
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
|
+
}
|
4873
|
+
|
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;
|
4880
|
+
|
4881
|
+
var _quill$getLine15 = this.quill.getLine(range.index),
|
4882
|
+
_quill$getLine16 = _slicedToArray(_quill$getLine15, 1),
|
4883
|
+
line = _quill$getLine16[0];
|
4884
|
+
|
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);
|
4900
|
+
}
|
4901
|
+
}
|
4902
|
+
|
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
|
+
}
|
4918
|
+
|
4919
|
+
function handleEnter(range, context) {
|
4920
|
+
var _this3 = this;
|
4921
|
+
|
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;
|
5026
|
+
|
5027
|
+
/***/ }),
|
5028
|
+
/* 24 */
|
5029
|
+
/***/ (function(module, exports, __webpack_require__) {
|
5030
|
+
|
5031
|
+
"use strict";
|
5032
|
+
|
5033
|
+
|
5034
|
+
Object.defineProperty(exports, "__esModule", {
|
5035
|
+
value: true
|
5036
|
+
});
|
5037
|
+
|
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"); } }; }();
|
5039
|
+
|
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); } };
|
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
|
+
|
5044
|
+
var _parchment = __webpack_require__(0);
|
5045
|
+
|
5046
|
+
var _parchment2 = _interopRequireDefault(_parchment);
|
5047
|
+
|
5048
|
+
var _text = __webpack_require__(7);
|
5049
|
+
|
5050
|
+
var _text2 = _interopRequireDefault(_text);
|
5051
|
+
|
5052
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
5053
|
+
|
5054
|
+
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
5055
|
+
|
5056
|
+
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; }
|
5057
|
+
|
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; }
|
5059
|
+
|
5060
|
+
var Cursor = function (_Parchment$Embed) {
|
5061
|
+
_inherits(Cursor, _Parchment$Embed);
|
5062
|
+
|
5063
|
+
_createClass(Cursor, null, [{
|
5064
|
+
key: 'value',
|
5065
|
+
value: function value() {
|
5066
|
+
return undefined;
|
5067
|
+
}
|
5068
|
+
}]);
|
5069
|
+
|
5070
|
+
function Cursor(domNode, selection) {
|
5071
|
+
_classCallCheck(this, Cursor);
|
5072
|
+
|
5073
|
+
var _this = _possibleConstructorReturn(this, (Cursor.__proto__ || Object.getPrototypeOf(Cursor)).call(this, domNode));
|
5074
|
+
|
5075
|
+
_this.selection = selection;
|
5076
|
+
_this.textNode = document.createTextNode(Cursor.CONTENTS);
|
5077
|
+
_this.domNode.appendChild(_this.textNode);
|
5078
|
+
_this._length = 0;
|
5079
|
+
return _this;
|
5080
|
+
}
|
5081
|
+
|
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;
|
5128
|
+
}
|
5129
|
+
}, {
|
5130
|
+
key: 'restore',
|
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('');
|
5150
|
+
if (this.next instanceof _text2.default) {
|
5151
|
+
restoreText = this.next.domNode;
|
5152
|
+
this.next.insertAt(0, text);
|
5153
|
+
this.textNode.data = Cursor.CONTENTS;
|
5154
|
+
} else {
|
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);
|
5159
|
+
}
|
5160
|
+
}
|
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];
|
4463
5171
|
|
4464
5172
|
return {
|
4465
5173
|
startNode: restoreText,
|
@@ -4500,7 +5208,7 @@ Cursor.CONTENTS = '\uFEFF'; // Zero width no break space
|
|
4500
5208
|
exports.default = Cursor;
|
4501
5209
|
|
4502
5210
|
/***/ }),
|
4503
|
-
/*
|
5211
|
+
/* 25 */
|
4504
5212
|
/***/ (function(module, exports, __webpack_require__) {
|
4505
5213
|
|
4506
5214
|
"use strict";
|
@@ -4542,127 +5250,6 @@ Container.allowedChildren = [_block2.default, _block.BlockEmbed, Container];
|
|
4542
5250
|
|
4543
5251
|
exports.default = Container;
|
4544
5252
|
|
4545
|
-
/***/ }),
|
4546
|
-
/* 25 */
|
4547
|
-
/***/ (function(module, exports, __webpack_require__) {
|
4548
|
-
|
4549
|
-
"use strict";
|
4550
|
-
|
4551
|
-
|
4552
|
-
Object.defineProperty(exports, "__esModule", {
|
4553
|
-
value: true
|
4554
|
-
});
|
4555
|
-
|
4556
|
-
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; }; }();
|
4557
|
-
|
4558
|
-
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
|
-
|
4560
|
-
var _parchment = __webpack_require__(0);
|
4561
|
-
|
4562
|
-
var _parchment2 = _interopRequireDefault(_parchment);
|
4563
|
-
|
4564
|
-
var _text = __webpack_require__(7);
|
4565
|
-
|
4566
|
-
var _text2 = _interopRequireDefault(_text);
|
4567
|
-
|
4568
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
4569
|
-
|
4570
|
-
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
4571
|
-
|
4572
|
-
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; }
|
4573
|
-
|
4574
|
-
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
|
-
|
4576
|
-
var GUARD_TEXT = '\uFEFF';
|
4577
|
-
|
4578
|
-
var Embed = function (_Parchment$Embed) {
|
4579
|
-
_inherits(Embed, _Parchment$Embed);
|
4580
|
-
|
4581
|
-
function Embed(node) {
|
4582
|
-
_classCallCheck(this, Embed);
|
4583
|
-
|
4584
|
-
var _this = _possibleConstructorReturn(this, (Embed.__proto__ || Object.getPrototypeOf(Embed)).call(this, node));
|
4585
|
-
|
4586
|
-
_this.contentNode = document.createElement('span');
|
4587
|
-
_this.contentNode.setAttribute('contenteditable', false);
|
4588
|
-
[].slice.call(_this.domNode.childNodes).forEach(function (childNode) {
|
4589
|
-
_this.contentNode.appendChild(childNode);
|
4590
|
-
});
|
4591
|
-
_this.leftGuard = document.createTextNode(GUARD_TEXT);
|
4592
|
-
_this.rightGuard = document.createTextNode(GUARD_TEXT);
|
4593
|
-
_this.domNode.appendChild(_this.leftGuard);
|
4594
|
-
_this.domNode.appendChild(_this.contentNode);
|
4595
|
-
_this.domNode.appendChild(_this.rightGuard);
|
4596
|
-
return _this;
|
4597
|
-
}
|
4598
|
-
|
4599
|
-
_createClass(Embed, [{
|
4600
|
-
key: 'index',
|
4601
|
-
value: function index(node, offset) {
|
4602
|
-
if (node === this.leftGuard) return 0;
|
4603
|
-
if (node === this.rightGuard) return 1;
|
4604
|
-
return _get(Embed.prototype.__proto__ || Object.getPrototypeOf(Embed.prototype), 'index', this).call(this, node, offset);
|
4605
|
-
}
|
4606
|
-
}, {
|
4607
|
-
key: 'restore',
|
4608
|
-
value: function restore(node) {
|
4609
|
-
var range = void 0,
|
4610
|
-
textNode = void 0;
|
4611
|
-
var text = node.data.split(GUARD_TEXT).join('');
|
4612
|
-
if (node === this.leftGuard) {
|
4613
|
-
if (this.prev instanceof _text2.default) {
|
4614
|
-
var prevLength = this.prev.length();
|
4615
|
-
this.prev.insertAt(prevLength, text);
|
4616
|
-
range = {
|
4617
|
-
startNode: this.prev.domNode,
|
4618
|
-
startOffset: prevLength + text.length
|
4619
|
-
};
|
4620
|
-
} else {
|
4621
|
-
textNode = document.createTextNode(text);
|
4622
|
-
this.parent.insertBefore(_parchment2.default.create(textNode), this);
|
4623
|
-
range = {
|
4624
|
-
startNode: textNode,
|
4625
|
-
startOffset: text.length
|
4626
|
-
};
|
4627
|
-
}
|
4628
|
-
} else if (node === this.rightGuard) {
|
4629
|
-
if (this.next instanceof _text2.default) {
|
4630
|
-
this.next.insertAt(0, text);
|
4631
|
-
range = {
|
4632
|
-
startNode: this.next.domNode,
|
4633
|
-
startOffset: text.length
|
4634
|
-
};
|
4635
|
-
} else {
|
4636
|
-
textNode = document.createTextNode(text);
|
4637
|
-
this.parent.insertBefore(_parchment2.default.create(textNode), this.next);
|
4638
|
-
range = {
|
4639
|
-
startNode: textNode,
|
4640
|
-
startOffset: text.length
|
4641
|
-
};
|
4642
|
-
}
|
4643
|
-
}
|
4644
|
-
node.data = GUARD_TEXT;
|
4645
|
-
return range;
|
4646
|
-
}
|
4647
|
-
}, {
|
4648
|
-
key: 'update',
|
4649
|
-
value: function update(mutations, context) {
|
4650
|
-
var _this2 = this;
|
4651
|
-
|
4652
|
-
mutations.forEach(function (mutation) {
|
4653
|
-
if (mutation.type === 'characterData' && (mutation.target === _this2.leftGuard || mutation.target === _this2.rightGuard)) {
|
4654
|
-
var range = _this2.restore(mutation.target);
|
4655
|
-
if (range) context.range = range;
|
4656
|
-
}
|
4657
|
-
});
|
4658
|
-
}
|
4659
|
-
}]);
|
4660
|
-
|
4661
|
-
return Embed;
|
4662
|
-
}(_parchment2.default.Embed);
|
4663
|
-
|
4664
|
-
exports.default = Embed;
|
4665
|
-
|
4666
5253
|
/***/ }),
|
4667
5254
|
/* 26 */
|
4668
5255
|
/***/ (function(module, exports, __webpack_require__) {
|
@@ -4735,6 +5322,10 @@ exports.ColorStyle = ColorStyle;
|
|
4735
5322
|
"use strict";
|
4736
5323
|
|
4737
5324
|
|
5325
|
+
Object.defineProperty(exports, "__esModule", {
|
5326
|
+
value: true
|
5327
|
+
});
|
5328
|
+
|
4738
5329
|
var _parchment = __webpack_require__(0);
|
4739
5330
|
|
4740
5331
|
var _parchment2 = _interopRequireDefault(_parchment);
|
@@ -4751,15 +5342,15 @@ var _break = __webpack_require__(16);
|
|
4751
5342
|
|
4752
5343
|
var _break2 = _interopRequireDefault(_break);
|
4753
5344
|
|
4754
|
-
var _container = __webpack_require__(
|
5345
|
+
var _container = __webpack_require__(25);
|
4755
5346
|
|
4756
5347
|
var _container2 = _interopRequireDefault(_container);
|
4757
5348
|
|
4758
|
-
var _cursor = __webpack_require__(
|
5349
|
+
var _cursor = __webpack_require__(24);
|
4759
5350
|
|
4760
5351
|
var _cursor2 = _interopRequireDefault(_cursor);
|
4761
5352
|
|
4762
|
-
var _embed = __webpack_require__(
|
5353
|
+
var _embed = __webpack_require__(35);
|
4763
5354
|
|
4764
5355
|
var _embed2 = _interopRequireDefault(_embed);
|
4765
5356
|
|
@@ -4783,7 +5374,7 @@ var _history = __webpack_require__(42);
|
|
4783
5374
|
|
4784
5375
|
var _history2 = _interopRequireDefault(_history);
|
4785
5376
|
|
4786
|
-
var _keyboard = __webpack_require__(
|
5377
|
+
var _keyboard = __webpack_require__(23);
|
4787
5378
|
|
4788
5379
|
var _keyboard2 = _interopRequireDefault(_keyboard);
|
4789
5380
|
|
@@ -4807,7 +5398,7 @@ _quill2.default.register({
|
|
4807
5398
|
|
4808
5399
|
_parchment2.default.register(_block2.default, _break2.default, _cursor2.default, _inline2.default, _scroll2.default, _text2.default);
|
4809
5400
|
|
4810
|
-
|
5401
|
+
exports.default = _quill2.default;
|
4811
5402
|
|
4812
5403
|
/***/ }),
|
4813
5404
|
/* 30 */
|
@@ -4820,7 +5411,8 @@ var Registry = __webpack_require__(1);
|
|
4820
5411
|
var ShadowBlot = /** @class */ (function () {
|
4821
5412
|
function ShadowBlot(domNode) {
|
4822
5413
|
this.domNode = domNode;
|
4823
|
-
|
5414
|
+
// @ts-ignore
|
5415
|
+
this.domNode[Registry.DATA_KEY] = { blot: this };
|
4824
5416
|
}
|
4825
5417
|
Object.defineProperty(ShadowBlot.prototype, "statics", {
|
4826
5418
|
// Hack for accessing inherited static methods
|
@@ -4861,7 +5453,9 @@ var ShadowBlot = /** @class */ (function () {
|
|
4861
5453
|
return node;
|
4862
5454
|
};
|
4863
5455
|
ShadowBlot.prototype.attach = function () {
|
4864
|
-
this.
|
5456
|
+
if (this.parent != null) {
|
5457
|
+
this.scroll = this.parent.scroll;
|
5458
|
+
}
|
4865
5459
|
};
|
4866
5460
|
ShadowBlot.prototype.clone = function () {
|
4867
5461
|
var domNode = this.domNode.cloneNode(false);
|
@@ -4870,6 +5464,7 @@ var ShadowBlot = /** @class */ (function () {
|
|
4870
5464
|
ShadowBlot.prototype.detach = function () {
|
4871
5465
|
if (this.parent != null)
|
4872
5466
|
this.parent.removeChild(this);
|
5467
|
+
// @ts-ignore
|
4873
5468
|
delete this.domNode[Registry.DATA_KEY];
|
4874
5469
|
};
|
4875
5470
|
ShadowBlot.prototype.deleteAt = function (index, length) {
|
@@ -4888,22 +5483,26 @@ var ShadowBlot = /** @class */ (function () {
|
|
4888
5483
|
}
|
4889
5484
|
};
|
4890
5485
|
ShadowBlot.prototype.insertAt = function (index, value, def) {
|
4891
|
-
var blot =
|
5486
|
+
var blot = def == null ? Registry.create('text', value) : Registry.create(value, def);
|
4892
5487
|
var ref = this.split(index);
|
4893
5488
|
this.parent.insertBefore(blot, ref);
|
4894
5489
|
};
|
4895
5490
|
ShadowBlot.prototype.insertInto = function (parentBlot, refBlot) {
|
5491
|
+
if (refBlot === void 0) { refBlot = null; }
|
4896
5492
|
if (this.parent != null) {
|
4897
5493
|
this.parent.children.remove(this);
|
4898
5494
|
}
|
5495
|
+
var refDomNode = null;
|
4899
5496
|
parentBlot.children.insertBefore(this, refBlot);
|
4900
5497
|
if (refBlot != null) {
|
4901
|
-
|
5498
|
+
refDomNode = refBlot.domNode;
|
4902
5499
|
}
|
4903
|
-
if (this.
|
4904
|
-
|
5500
|
+
if (this.domNode.parentNode != parentBlot.domNode ||
|
5501
|
+
this.domNode.nextSibling != refDomNode) {
|
5502
|
+
parentBlot.domNode.insertBefore(this.domNode, refDomNode);
|
4905
5503
|
}
|
4906
5504
|
this.parent = parentBlot;
|
5505
|
+
this.attach();
|
4907
5506
|
};
|
4908
5507
|
ShadowBlot.prototype.isolate = function (index, length) {
|
4909
5508
|
var target = this.split(index);
|
@@ -4913,7 +5512,6 @@ var ShadowBlot = /** @class */ (function () {
|
|
4913
5512
|
ShadowBlot.prototype.length = function () {
|
4914
5513
|
return 1;
|
4915
5514
|
};
|
4916
|
-
;
|
4917
5515
|
ShadowBlot.prototype.offset = function (root) {
|
4918
5516
|
if (root === void 0) { root = this.parent; }
|
4919
5517
|
if (this.parent == null || this == root)
|
@@ -4922,7 +5520,9 @@ var ShadowBlot = /** @class */ (function () {
|
|
4922
5520
|
};
|
4923
5521
|
ShadowBlot.prototype.optimize = function (context) {
|
4924
5522
|
// TODO clean up once we use WeakMap
|
5523
|
+
// @ts-ignore
|
4925
5524
|
if (this.domNode[Registry.DATA_KEY] != null) {
|
5525
|
+
// @ts-ignore
|
4926
5526
|
delete this.domNode[Registry.DATA_KEY].mutations;
|
4927
5527
|
}
|
4928
5528
|
};
|
@@ -4981,6 +5581,7 @@ var AttributorStore = /** @class */ (function () {
|
|
4981
5581
|
this.build();
|
4982
5582
|
}
|
4983
5583
|
AttributorStore.prototype.attribute = function (attribute, value) {
|
5584
|
+
// verb
|
4984
5585
|
if (value) {
|
4985
5586
|
if (attribute.add(this.domNode, value)) {
|
4986
5587
|
if (attribute.value(this.domNode) != null) {
|
@@ -5002,7 +5603,10 @@ var AttributorStore = /** @class */ (function () {
|
|
5002
5603
|
var attributes = attributor_1.default.keys(this.domNode);
|
5003
5604
|
var classes = class_1.default.keys(this.domNode);
|
5004
5605
|
var styles = style_1.default.keys(this.domNode);
|
5005
|
-
attributes
|
5606
|
+
attributes
|
5607
|
+
.concat(classes)
|
5608
|
+
.concat(styles)
|
5609
|
+
.forEach(function (name) {
|
5006
5610
|
var attr = Registry.query(name, Registry.Scope.ATTRIBUTE);
|
5007
5611
|
if (attr instanceof attributor_1.default) {
|
5008
5612
|
_this.attributes[attr.attrName] = attr;
|
@@ -5067,7 +5671,10 @@ var ClassAttributor = /** @class */ (function (_super) {
|
|
5067
5671
|
}
|
5068
5672
|
ClassAttributor.keys = function (node) {
|
5069
5673
|
return (node.getAttribute('class') || '').split(/\s+/).map(function (name) {
|
5070
|
-
return name
|
5674
|
+
return name
|
5675
|
+
.split('-')
|
5676
|
+
.slice(0, -1)
|
5677
|
+
.join('-');
|
5071
5678
|
});
|
5072
5679
|
};
|
5073
5680
|
ClassAttributor.prototype.add = function (node, value) {
|
@@ -5116,9 +5723,12 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
5116
5723
|
var attributor_1 = __webpack_require__(12);
|
5117
5724
|
function camelize(name) {
|
5118
5725
|
var parts = name.split('-');
|
5119
|
-
var rest = parts
|
5726
|
+
var rest = parts
|
5727
|
+
.slice(1)
|
5728
|
+
.map(function (part) {
|
5120
5729
|
return part[0].toUpperCase() + part.slice(1);
|
5121
|
-
})
|
5730
|
+
})
|
5731
|
+
.join('');
|
5122
5732
|
return parts[0] + rest;
|
5123
5733
|
}
|
5124
5734
|
var StyleAttributor = /** @class */ (function (_super) {
|
@@ -5135,16 +5745,19 @@ var StyleAttributor = /** @class */ (function (_super) {
|
|
5135
5745
|
StyleAttributor.prototype.add = function (node, value) {
|
5136
5746
|
if (!this.canAdd(node, value))
|
5137
5747
|
return false;
|
5748
|
+
// @ts-ignore
|
5138
5749
|
node.style[camelize(this.keyName)] = value;
|
5139
5750
|
return true;
|
5140
5751
|
};
|
5141
5752
|
StyleAttributor.prototype.remove = function (node) {
|
5753
|
+
// @ts-ignore
|
5142
5754
|
node.style[camelize(this.keyName)] = '';
|
5143
5755
|
if (!node.getAttribute('style')) {
|
5144
5756
|
node.removeAttribute('style');
|
5145
5757
|
}
|
5146
5758
|
};
|
5147
5759
|
StyleAttributor.prototype.value = function (node) {
|
5760
|
+
// @ts-ignore
|
5148
5761
|
var value = node.style[camelize(this.keyName)];
|
5149
5762
|
return this.canAdd(node, value) ? value : '';
|
5150
5763
|
};
|
@@ -5166,656 +5779,169 @@ Object.defineProperty(exports, "__esModule", {
|
|
5166
5779
|
|
5167
5780
|
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; }; }();
|
5168
5781
|
|
5169
|
-
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
5170
|
-
|
5171
|
-
var Theme = function () {
|
5172
|
-
function Theme(quill, options) {
|
5173
|
-
_classCallCheck(this, Theme);
|
5174
|
-
|
5175
|
-
this.quill = quill;
|
5176
|
-
this.options = options;
|
5177
|
-
this.modules = {};
|
5178
|
-
}
|
5179
|
-
|
5180
|
-
_createClass(Theme, [{
|
5181
|
-
key: 'init',
|
5182
|
-
value: function init() {
|
5183
|
-
var _this = this;
|
5184
|
-
|
5185
|
-
Object.keys(this.options.modules).forEach(function (name) {
|
5186
|
-
if (_this.modules[name] == null) {
|
5187
|
-
_this.addModule(name);
|
5188
|
-
}
|
5189
|
-
});
|
5190
|
-
}
|
5191
|
-
}, {
|
5192
|
-
key: 'addModule',
|
5193
|
-
value: function addModule(name) {
|
5194
|
-
var moduleClass = this.quill.constructor.import('modules/' + name);
|
5195
|
-
this.modules[name] = new moduleClass(this.quill, this.options.modules[name] || {});
|
5196
|
-
return this.modules[name];
|
5197
|
-
}
|
5198
|
-
}]);
|
5199
|
-
|
5200
|
-
return Theme;
|
5201
|
-
}();
|
5202
|
-
|
5203
|
-
Theme.DEFAULTS = {
|
5204
|
-
modules: {}
|
5205
|
-
};
|
5206
|
-
Theme.themes = {
|
5207
|
-
'default': Theme
|
5208
|
-
};
|
5209
|
-
|
5210
|
-
exports.default = Theme;
|
5211
|
-
|
5212
|
-
/***/ }),
|
5213
|
-
/* 35 */
|
5214
|
-
/***/ (function(module, exports, __webpack_require__) {
|
5215
|
-
|
5216
|
-
"use strict";
|
5217
|
-
|
5218
|
-
|
5219
|
-
Object.defineProperty(exports, "__esModule", {
|
5220
|
-
value: true
|
5221
|
-
});
|
5222
|
-
exports.SHORTKEY = exports.default = undefined;
|
5223
|
-
|
5224
|
-
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; };
|
5225
|
-
|
5226
|
-
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"); } }; }();
|
5227
|
-
|
5228
|
-
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; }; }();
|
5229
|
-
|
5230
|
-
var _clone = __webpack_require__(21);
|
5231
|
-
|
5232
|
-
var _clone2 = _interopRequireDefault(_clone);
|
5233
|
-
|
5234
|
-
var _deepEqual = __webpack_require__(11);
|
5235
|
-
|
5236
|
-
var _deepEqual2 = _interopRequireDefault(_deepEqual);
|
5237
|
-
|
5238
|
-
var _extend = __webpack_require__(3);
|
5239
|
-
|
5240
|
-
var _extend2 = _interopRequireDefault(_extend);
|
5241
|
-
|
5242
|
-
var _quillDelta = __webpack_require__(2);
|
5243
|
-
|
5244
|
-
var _quillDelta2 = _interopRequireDefault(_quillDelta);
|
5245
|
-
|
5246
|
-
var _op = __webpack_require__(20);
|
5247
|
-
|
5248
|
-
var _op2 = _interopRequireDefault(_op);
|
5249
|
-
|
5250
|
-
var _parchment = __webpack_require__(0);
|
5251
|
-
|
5252
|
-
var _parchment2 = _interopRequireDefault(_parchment);
|
5253
|
-
|
5254
|
-
var _embed = __webpack_require__(25);
|
5255
|
-
|
5256
|
-
var _embed2 = _interopRequireDefault(_embed);
|
5257
|
-
|
5258
|
-
var _quill = __webpack_require__(5);
|
5259
|
-
|
5260
|
-
var _quill2 = _interopRequireDefault(_quill);
|
5261
|
-
|
5262
|
-
var _logger = __webpack_require__(10);
|
5263
|
-
|
5264
|
-
var _logger2 = _interopRequireDefault(_logger);
|
5265
|
-
|
5266
|
-
var _module = __webpack_require__(9);
|
5267
|
-
|
5268
|
-
var _module2 = _interopRequireDefault(_module);
|
5269
|
-
|
5270
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
5271
|
-
|
5272
|
-
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; }
|
5273
|
-
|
5274
|
-
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
5275
|
-
|
5276
|
-
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; }
|
5277
|
-
|
5278
|
-
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; }
|
5279
|
-
|
5280
|
-
var debug = (0, _logger2.default)('quill:keyboard');
|
5281
|
-
|
5282
|
-
var SHORTKEY = /Mac/i.test(navigator.platform) ? 'metaKey' : 'ctrlKey';
|
5283
|
-
|
5284
|
-
var Keyboard = function (_Module) {
|
5285
|
-
_inherits(Keyboard, _Module);
|
5286
|
-
|
5287
|
-
_createClass(Keyboard, null, [{
|
5288
|
-
key: 'match',
|
5289
|
-
value: function match(evt, binding) {
|
5290
|
-
binding = normalize(binding);
|
5291
|
-
if (['altKey', 'ctrlKey', 'metaKey', 'shiftKey'].some(function (key) {
|
5292
|
-
return !!binding[key] !== evt[key] && binding[key] !== null;
|
5293
|
-
})) {
|
5294
|
-
return false;
|
5295
|
-
}
|
5296
|
-
return binding.key === (evt.which || evt.keyCode);
|
5297
|
-
}
|
5298
|
-
}]);
|
5299
|
-
|
5300
|
-
function Keyboard(quill, options) {
|
5301
|
-
_classCallCheck(this, Keyboard);
|
5302
|
-
|
5303
|
-
var _this = _possibleConstructorReturn(this, (Keyboard.__proto__ || Object.getPrototypeOf(Keyboard)).call(this, quill, options));
|
5304
|
-
|
5305
|
-
_this.bindings = {};
|
5306
|
-
Object.keys(_this.options.bindings).forEach(function (name) {
|
5307
|
-
if (name === 'list autofill' && quill.scroll.whitelist != null && !quill.scroll.whitelist['list']) {
|
5308
|
-
return;
|
5309
|
-
}
|
5310
|
-
if (_this.options.bindings[name]) {
|
5311
|
-
_this.addBinding(_this.options.bindings[name]);
|
5312
|
-
}
|
5313
|
-
});
|
5314
|
-
_this.addBinding({ key: Keyboard.keys.ENTER, shiftKey: null }, handleEnter);
|
5315
|
-
_this.addBinding({ key: Keyboard.keys.ENTER, metaKey: null, ctrlKey: null, altKey: null }, function () {});
|
5316
|
-
if (/Firefox/i.test(navigator.userAgent)) {
|
5317
|
-
// Need to handle delete and backspace for Firefox in the general case #1171
|
5318
|
-
_this.addBinding({ key: Keyboard.keys.BACKSPACE }, { collapsed: true }, handleBackspace);
|
5319
|
-
_this.addBinding({ key: Keyboard.keys.DELETE }, { collapsed: true }, handleDelete);
|
5320
|
-
} else {
|
5321
|
-
_this.addBinding({ key: Keyboard.keys.BACKSPACE }, { collapsed: true, prefix: /^.?$/ }, handleBackspace);
|
5322
|
-
_this.addBinding({ key: Keyboard.keys.DELETE }, { collapsed: true, suffix: /^.?$/ }, handleDelete);
|
5323
|
-
}
|
5324
|
-
_this.addBinding({ key: Keyboard.keys.BACKSPACE }, { collapsed: false }, handleDeleteRange);
|
5325
|
-
_this.addBinding({ key: Keyboard.keys.DELETE }, { collapsed: false }, handleDeleteRange);
|
5326
|
-
_this.addBinding({ key: Keyboard.keys.BACKSPACE, altKey: null, ctrlKey: null, metaKey: null, shiftKey: null }, { collapsed: true, offset: 0 }, handleBackspace);
|
5327
|
-
_this.listen();
|
5328
|
-
return _this;
|
5329
|
-
}
|
5330
|
-
|
5331
|
-
_createClass(Keyboard, [{
|
5332
|
-
key: 'addBinding',
|
5333
|
-
value: function addBinding(key) {
|
5334
|
-
var context = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
5335
|
-
var handler = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
5336
|
-
|
5337
|
-
var binding = normalize(key);
|
5338
|
-
if (binding == null || binding.key == null) {
|
5339
|
-
return debug.warn('Attempted to add invalid keyboard binding', binding);
|
5340
|
-
}
|
5341
|
-
if (typeof context === 'function') {
|
5342
|
-
context = { handler: context };
|
5343
|
-
}
|
5344
|
-
if (typeof handler === 'function') {
|
5345
|
-
handler = { handler: handler };
|
5346
|
-
}
|
5347
|
-
binding = (0, _extend2.default)(binding, context, handler);
|
5348
|
-
this.bindings[binding.key] = this.bindings[binding.key] || [];
|
5349
|
-
this.bindings[binding.key].push(binding);
|
5350
|
-
}
|
5351
|
-
}, {
|
5352
|
-
key: 'listen',
|
5353
|
-
value: function listen() {
|
5354
|
-
var _this2 = this;
|
5355
|
-
|
5356
|
-
this.quill.root.addEventListener('keydown', function (evt) {
|
5357
|
-
if (evt.defaultPrevented) return;
|
5358
|
-
var which = evt.which || evt.keyCode;
|
5359
|
-
var bindings = (_this2.bindings[which] || []).filter(function (binding) {
|
5360
|
-
return Keyboard.match(evt, binding);
|
5361
|
-
});
|
5362
|
-
if (bindings.length === 0) return;
|
5363
|
-
var range = _this2.quill.getSelection();
|
5364
|
-
if (range == null || !_this2.quill.hasFocus()) return;
|
5365
|
-
|
5366
|
-
var _quill$getLine = _this2.quill.getLine(range.index),
|
5367
|
-
_quill$getLine2 = _slicedToArray(_quill$getLine, 2),
|
5368
|
-
line = _quill$getLine2[0],
|
5369
|
-
offset = _quill$getLine2[1];
|
5370
|
-
|
5371
|
-
var _quill$getLeaf = _this2.quill.getLeaf(range.index),
|
5372
|
-
_quill$getLeaf2 = _slicedToArray(_quill$getLeaf, 2),
|
5373
|
-
leafStart = _quill$getLeaf2[0],
|
5374
|
-
offsetStart = _quill$getLeaf2[1];
|
5375
|
-
|
5376
|
-
var _ref = range.length === 0 ? [leafStart, offsetStart] : _this2.quill.getLeaf(range.index + range.length),
|
5377
|
-
_ref2 = _slicedToArray(_ref, 2),
|
5378
|
-
leafEnd = _ref2[0],
|
5379
|
-
offsetEnd = _ref2[1];
|
5380
|
-
|
5381
|
-
var prefixText = leafStart instanceof _parchment2.default.Text ? leafStart.value().slice(0, offsetStart) : '';
|
5382
|
-
var suffixText = leafEnd instanceof _parchment2.default.Text ? leafEnd.value().slice(offsetEnd) : '';
|
5383
|
-
var curContext = {
|
5384
|
-
collapsed: range.length === 0,
|
5385
|
-
empty: range.length === 0 && line.length() <= 1,
|
5386
|
-
format: _this2.quill.getFormat(range),
|
5387
|
-
offset: offset,
|
5388
|
-
prefix: prefixText,
|
5389
|
-
suffix: suffixText
|
5390
|
-
};
|
5391
|
-
var prevented = bindings.some(function (binding) {
|
5392
|
-
if (binding.collapsed != null && binding.collapsed !== curContext.collapsed) return false;
|
5393
|
-
if (binding.empty != null && binding.empty !== curContext.empty) return false;
|
5394
|
-
if (binding.offset != null && binding.offset !== curContext.offset) return false;
|
5395
|
-
if (Array.isArray(binding.format)) {
|
5396
|
-
// any format is present
|
5397
|
-
if (binding.format.every(function (name) {
|
5398
|
-
return curContext.format[name] == null;
|
5399
|
-
})) {
|
5400
|
-
return false;
|
5401
|
-
}
|
5402
|
-
} else if (_typeof(binding.format) === 'object') {
|
5403
|
-
// all formats must match
|
5404
|
-
if (!Object.keys(binding.format).every(function (name) {
|
5405
|
-
if (binding.format[name] === true) return curContext.format[name] != null;
|
5406
|
-
if (binding.format[name] === false) return curContext.format[name] == null;
|
5407
|
-
return (0, _deepEqual2.default)(binding.format[name], curContext.format[name]);
|
5408
|
-
})) {
|
5409
|
-
return false;
|
5410
|
-
}
|
5411
|
-
}
|
5412
|
-
if (binding.prefix != null && !binding.prefix.test(curContext.prefix)) return false;
|
5413
|
-
if (binding.suffix != null && !binding.suffix.test(curContext.suffix)) return false;
|
5414
|
-
return binding.handler.call(_this2, range, curContext) !== true;
|
5415
|
-
});
|
5416
|
-
if (prevented) {
|
5417
|
-
evt.preventDefault();
|
5782
|
+
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
5783
|
+
|
5784
|
+
var Theme = function () {
|
5785
|
+
function Theme(quill, options) {
|
5786
|
+
_classCallCheck(this, Theme);
|
5787
|
+
|
5788
|
+
this.quill = quill;
|
5789
|
+
this.options = options;
|
5790
|
+
this.modules = {};
|
5791
|
+
}
|
5792
|
+
|
5793
|
+
_createClass(Theme, [{
|
5794
|
+
key: 'init',
|
5795
|
+
value: function init() {
|
5796
|
+
var _this = this;
|
5797
|
+
|
5798
|
+
Object.keys(this.options.modules).forEach(function (name) {
|
5799
|
+
if (_this.modules[name] == null) {
|
5800
|
+
_this.addModule(name);
|
5418
5801
|
}
|
5419
5802
|
});
|
5420
5803
|
}
|
5804
|
+
}, {
|
5805
|
+
key: 'addModule',
|
5806
|
+
value: function addModule(name) {
|
5807
|
+
var moduleClass = this.quill.constructor.import('modules/' + name);
|
5808
|
+
this.modules[name] = new moduleClass(this.quill, this.options.modules[name] || {});
|
5809
|
+
return this.modules[name];
|
5810
|
+
}
|
5421
5811
|
}]);
|
5422
5812
|
|
5423
|
-
return
|
5424
|
-
}(
|
5813
|
+
return Theme;
|
5814
|
+
}();
|
5425
5815
|
|
5426
|
-
|
5427
|
-
|
5428
|
-
|
5429
|
-
|
5430
|
-
|
5431
|
-
LEFT: 37,
|
5432
|
-
UP: 38,
|
5433
|
-
RIGHT: 39,
|
5434
|
-
DOWN: 40,
|
5435
|
-
DELETE: 46
|
5816
|
+
Theme.DEFAULTS = {
|
5817
|
+
modules: {}
|
5818
|
+
};
|
5819
|
+
Theme.themes = {
|
5820
|
+
'default': Theme
|
5436
5821
|
};
|
5437
5822
|
|
5438
|
-
|
5439
|
-
bindings: {
|
5440
|
-
'bold': makeFormatHandler('bold'),
|
5441
|
-
'italic': makeFormatHandler('italic'),
|
5442
|
-
'underline': makeFormatHandler('underline'),
|
5443
|
-
'indent': {
|
5444
|
-
// highlight tab or tab at beginning of list, indent or blockquote
|
5445
|
-
key: Keyboard.keys.TAB,
|
5446
|
-
format: ['blockquote', 'indent', 'list'],
|
5447
|
-
handler: function handler(range, context) {
|
5448
|
-
if (context.collapsed && context.offset !== 0) return true;
|
5449
|
-
this.quill.format('indent', '+1', _quill2.default.sources.USER);
|
5450
|
-
}
|
5451
|
-
},
|
5452
|
-
'outdent': {
|
5453
|
-
key: Keyboard.keys.TAB,
|
5454
|
-
shiftKey: true,
|
5455
|
-
format: ['blockquote', 'indent', 'list'],
|
5456
|
-
// highlight tab or tab at beginning of list, indent or blockquote
|
5457
|
-
handler: function handler(range, context) {
|
5458
|
-
if (context.collapsed && context.offset !== 0) return true;
|
5459
|
-
this.quill.format('indent', '-1', _quill2.default.sources.USER);
|
5460
|
-
}
|
5461
|
-
},
|
5462
|
-
'outdent backspace': {
|
5463
|
-
key: Keyboard.keys.BACKSPACE,
|
5464
|
-
collapsed: true,
|
5465
|
-
shiftKey: null,
|
5466
|
-
metaKey: null,
|
5467
|
-
ctrlKey: null,
|
5468
|
-
altKey: null,
|
5469
|
-
format: ['indent', 'list'],
|
5470
|
-
offset: 0,
|
5471
|
-
handler: function handler(range, context) {
|
5472
|
-
if (context.format.indent != null) {
|
5473
|
-
this.quill.format('indent', '-1', _quill2.default.sources.USER);
|
5474
|
-
} else if (context.format.list != null) {
|
5475
|
-
this.quill.format('list', false, _quill2.default.sources.USER);
|
5476
|
-
}
|
5477
|
-
}
|
5478
|
-
},
|
5479
|
-
'indent code-block': makeCodeBlockHandler(true),
|
5480
|
-
'outdent code-block': makeCodeBlockHandler(false),
|
5481
|
-
'remove tab': {
|
5482
|
-
key: Keyboard.keys.TAB,
|
5483
|
-
shiftKey: true,
|
5484
|
-
collapsed: true,
|
5485
|
-
prefix: /\t$/,
|
5486
|
-
handler: function handler(range) {
|
5487
|
-
this.quill.deleteText(range.index - 1, 1, _quill2.default.sources.USER);
|
5488
|
-
}
|
5489
|
-
},
|
5490
|
-
'tab': {
|
5491
|
-
key: Keyboard.keys.TAB,
|
5492
|
-
handler: function handler(range) {
|
5493
|
-
this.quill.history.cutoff();
|
5494
|
-
var delta = new _quillDelta2.default().retain(range.index).delete(range.length).insert('\t');
|
5495
|
-
this.quill.updateContents(delta, _quill2.default.sources.USER);
|
5496
|
-
this.quill.history.cutoff();
|
5497
|
-
this.quill.setSelection(range.index + 1, _quill2.default.sources.SILENT);
|
5498
|
-
}
|
5499
|
-
},
|
5500
|
-
'list empty enter': {
|
5501
|
-
key: Keyboard.keys.ENTER,
|
5502
|
-
collapsed: true,
|
5503
|
-
format: ['list'],
|
5504
|
-
empty: true,
|
5505
|
-
handler: function handler(range, context) {
|
5506
|
-
this.quill.format('list', false, _quill2.default.sources.USER);
|
5507
|
-
if (context.format.indent) {
|
5508
|
-
this.quill.format('indent', false, _quill2.default.sources.USER);
|
5509
|
-
}
|
5510
|
-
}
|
5511
|
-
},
|
5512
|
-
'checklist enter': {
|
5513
|
-
key: Keyboard.keys.ENTER,
|
5514
|
-
collapsed: true,
|
5515
|
-
format: { list: 'checked' },
|
5516
|
-
handler: function handler(range) {
|
5517
|
-
var _quill$getLine3 = this.quill.getLine(range.index),
|
5518
|
-
_quill$getLine4 = _slicedToArray(_quill$getLine3, 2),
|
5519
|
-
line = _quill$getLine4[0],
|
5520
|
-
offset = _quill$getLine4[1];
|
5521
|
-
|
5522
|
-
var delta = new _quillDelta2.default().retain(range.index).insert('\n', { list: 'checked' }).retain(line.length() - offset - 1).retain(1, { list: 'unchecked' });
|
5523
|
-
this.quill.updateContents(delta, _quill2.default.sources.USER);
|
5524
|
-
this.quill.setSelection(range.index + 1, _quill2.default.sources.SILENT);
|
5525
|
-
this.quill.scrollIntoView();
|
5526
|
-
}
|
5527
|
-
},
|
5528
|
-
'header enter': {
|
5529
|
-
key: Keyboard.keys.ENTER,
|
5530
|
-
collapsed: true,
|
5531
|
-
format: ['header'],
|
5532
|
-
suffix: /^$/,
|
5533
|
-
handler: function handler(range, context) {
|
5534
|
-
var _quill$getLine5 = this.quill.getLine(range.index),
|
5535
|
-
_quill$getLine6 = _slicedToArray(_quill$getLine5, 2),
|
5536
|
-
line = _quill$getLine6[0],
|
5537
|
-
offset = _quill$getLine6[1];
|
5538
|
-
|
5539
|
-
var delta = new _quillDelta2.default().retain(range.index).insert('\n', context.format).retain(line.length() - offset - 1).retain(1, { header: null });
|
5540
|
-
this.quill.updateContents(delta, _quill2.default.sources.USER);
|
5541
|
-
this.quill.setSelection(range.index + 1, _quill2.default.sources.SILENT);
|
5542
|
-
this.quill.scrollIntoView();
|
5543
|
-
}
|
5544
|
-
},
|
5545
|
-
'list autofill': {
|
5546
|
-
key: ' ',
|
5547
|
-
collapsed: true,
|
5548
|
-
format: { list: false },
|
5549
|
-
prefix: /^\s*?(1\.|-|\[ ?\]|\[x\])$/,
|
5550
|
-
handler: function handler(range, context) {
|
5551
|
-
var length = context.prefix.length;
|
5552
|
-
|
5553
|
-
var _quill$getLine7 = this.quill.getLine(range.index),
|
5554
|
-
_quill$getLine8 = _slicedToArray(_quill$getLine7, 2),
|
5555
|
-
line = _quill$getLine8[0],
|
5556
|
-
offset = _quill$getLine8[1];
|
5823
|
+
exports.default = Theme;
|
5557
5824
|
|
5558
|
-
|
5559
|
-
|
5560
|
-
|
5561
|
-
case '[]':case '[ ]':
|
5562
|
-
value = 'unchecked';
|
5563
|
-
break;
|
5564
|
-
case '[x]':
|
5565
|
-
value = 'checked';
|
5566
|
-
break;
|
5567
|
-
case '-':
|
5568
|
-
value = 'bullet';
|
5569
|
-
break;
|
5570
|
-
default:
|
5571
|
-
value = 'ordered';
|
5572
|
-
}
|
5573
|
-
this.quill.insertText(range.index, ' ', _quill2.default.sources.USER);
|
5574
|
-
this.quill.history.cutoff();
|
5575
|
-
var delta = new _quillDelta2.default().retain(range.index - offset).delete(length + 1).retain(line.length() - 2 - offset).retain(1, { list: value });
|
5576
|
-
this.quill.updateContents(delta, _quill2.default.sources.USER);
|
5577
|
-
this.quill.history.cutoff();
|
5578
|
-
this.quill.setSelection(range.index - length, _quill2.default.sources.SILENT);
|
5579
|
-
}
|
5580
|
-
},
|
5581
|
-
'code exit': {
|
5582
|
-
key: Keyboard.keys.ENTER,
|
5583
|
-
collapsed: true,
|
5584
|
-
format: ['code-block'],
|
5585
|
-
prefix: /\n\n$/,
|
5586
|
-
suffix: /^\s+$/,
|
5587
|
-
handler: function handler(range) {
|
5588
|
-
var _quill$getLine9 = this.quill.getLine(range.index),
|
5589
|
-
_quill$getLine10 = _slicedToArray(_quill$getLine9, 2),
|
5590
|
-
line = _quill$getLine10[0],
|
5591
|
-
offset = _quill$getLine10[1];
|
5825
|
+
/***/ }),
|
5826
|
+
/* 35 */
|
5827
|
+
/***/ (function(module, exports, __webpack_require__) {
|
5592
5828
|
|
5593
|
-
|
5594
|
-
this.quill.updateContents(delta, _quill2.default.sources.USER);
|
5595
|
-
}
|
5596
|
-
},
|
5597
|
-
'embed left': makeEmbedArrowHandler(Keyboard.keys.LEFT, false),
|
5598
|
-
'embed left shift': makeEmbedArrowHandler(Keyboard.keys.LEFT, true),
|
5599
|
-
'embed right': makeEmbedArrowHandler(Keyboard.keys.RIGHT, false),
|
5600
|
-
'embed right shift': makeEmbedArrowHandler(Keyboard.keys.RIGHT, true)
|
5601
|
-
}
|
5602
|
-
};
|
5829
|
+
"use strict";
|
5603
5830
|
|
5604
|
-
function makeEmbedArrowHandler(key, shiftKey) {
|
5605
|
-
var _ref3;
|
5606
5831
|
|
5607
|
-
|
5608
|
-
|
5609
|
-
|
5610
|
-
shiftKey: shiftKey
|
5611
|
-
}, _defineProperty(_ref3, where, /^$/), _defineProperty(_ref3, 'handler', function handler(range) {
|
5612
|
-
var index = range.index;
|
5613
|
-
if (key === Keyboard.keys.RIGHT) {
|
5614
|
-
index += range.length + 1;
|
5615
|
-
}
|
5832
|
+
Object.defineProperty(exports, "__esModule", {
|
5833
|
+
value: true
|
5834
|
+
});
|
5616
5835
|
|
5617
|
-
|
5618
|
-
_quill$getLeaf4 = _slicedToArray(_quill$getLeaf3, 1),
|
5619
|
-
leaf = _quill$getLeaf4[0];
|
5836
|
+
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; }; }();
|
5620
5837
|
|
5621
|
-
|
5622
|
-
if (key === Keyboard.keys.LEFT) {
|
5623
|
-
if (shiftKey) {
|
5624
|
-
this.quill.setSelection(range.index - 1, range.length + 1, _quill2.default.sources.USER);
|
5625
|
-
} else {
|
5626
|
-
this.quill.setSelection(range.index - 1, _quill2.default.sources.USER);
|
5627
|
-
}
|
5628
|
-
} else {
|
5629
|
-
if (shiftKey) {
|
5630
|
-
this.quill.setSelection(range.index, range.length + 1, _quill2.default.sources.USER);
|
5631
|
-
} else {
|
5632
|
-
this.quill.setSelection(range.index + range.length + 1, _quill2.default.sources.USER);
|
5633
|
-
}
|
5634
|
-
}
|
5635
|
-
return false;
|
5636
|
-
}), _ref3;
|
5637
|
-
}
|
5838
|
+
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); } };
|
5638
5839
|
|
5639
|
-
|
5640
|
-
if (range.index === 0 || this.quill.getLength() <= 1) return;
|
5840
|
+
var _parchment = __webpack_require__(0);
|
5641
5841
|
|
5642
|
-
|
5643
|
-
_quill$getLine12 = _slicedToArray(_quill$getLine11, 1),
|
5644
|
-
line = _quill$getLine12[0];
|
5842
|
+
var _parchment2 = _interopRequireDefault(_parchment);
|
5645
5843
|
|
5646
|
-
|
5647
|
-
if (context.offset === 0) {
|
5648
|
-
var _quill$getLine13 = this.quill.getLine(range.index - 1),
|
5649
|
-
_quill$getLine14 = _slicedToArray(_quill$getLine13, 1),
|
5650
|
-
prev = _quill$getLine14[0];
|
5844
|
+
var _text = __webpack_require__(7);
|
5651
5845
|
|
5652
|
-
|
5653
|
-
var curFormats = line.formats();
|
5654
|
-
var prevFormats = this.quill.getFormat(range.index - 1, 1);
|
5655
|
-
formats = _op2.default.attributes.diff(curFormats, prevFormats) || {};
|
5656
|
-
}
|
5657
|
-
}
|
5658
|
-
// Check for astral symbols
|
5659
|
-
var length = /[\uD800-\uDBFF][\uDC00-\uDFFF]$/.test(context.prefix) ? 2 : 1;
|
5660
|
-
this.quill.deleteText(range.index - length, length, _quill2.default.sources.USER);
|
5661
|
-
if (Object.keys(formats).length > 0) {
|
5662
|
-
this.quill.formatLine(range.index - length, length, formats, _quill2.default.sources.USER);
|
5663
|
-
}
|
5664
|
-
this.quill.focus();
|
5665
|
-
}
|
5846
|
+
var _text2 = _interopRequireDefault(_text);
|
5666
5847
|
|
5667
|
-
function
|
5668
|
-
// Check for astral symbols
|
5669
|
-
var length = /^[\uD800-\uDBFF][\uDC00-\uDFFF]/.test(context.suffix) ? 2 : 1;
|
5670
|
-
if (range.index >= this.quill.getLength() - length) return;
|
5671
|
-
var formats = {},
|
5672
|
-
nextLength = 0;
|
5848
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
5673
5849
|
|
5674
|
-
|
5675
|
-
_quill$getLine16 = _slicedToArray(_quill$getLine15, 1),
|
5676
|
-
line = _quill$getLine16[0];
|
5850
|
+
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
5677
5851
|
|
5678
|
-
|
5679
|
-
var _quill$getLine17 = this.quill.getLine(range.index + 1),
|
5680
|
-
_quill$getLine18 = _slicedToArray(_quill$getLine17, 1),
|
5681
|
-
next = _quill$getLine18[0];
|
5852
|
+
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; }
|
5682
5853
|
|
5683
|
-
|
5684
|
-
var curFormats = line.formats();
|
5685
|
-
var nextFormats = this.quill.getFormat(range.index, 1);
|
5686
|
-
formats = _op2.default.attributes.diff(curFormats, nextFormats) || {};
|
5687
|
-
nextLength = next.length();
|
5688
|
-
}
|
5689
|
-
}
|
5690
|
-
this.quill.deleteText(range.index, length, _quill2.default.sources.USER);
|
5691
|
-
if (Object.keys(formats).length > 0) {
|
5692
|
-
this.quill.formatLine(range.index + nextLength - 1, length, formats, _quill2.default.sources.USER);
|
5693
|
-
}
|
5694
|
-
}
|
5854
|
+
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; }
|
5695
5855
|
|
5696
|
-
|
5697
|
-
var lines = this.quill.getLines(range);
|
5698
|
-
var formats = {};
|
5699
|
-
if (lines.length > 1) {
|
5700
|
-
var firstFormats = lines[0].formats();
|
5701
|
-
var lastFormats = lines[lines.length - 1].formats();
|
5702
|
-
formats = _op2.default.attributes.diff(lastFormats, firstFormats) || {};
|
5703
|
-
}
|
5704
|
-
this.quill.deleteText(range, _quill2.default.sources.USER);
|
5705
|
-
if (Object.keys(formats).length > 0) {
|
5706
|
-
this.quill.formatLine(range.index, 1, formats, _quill2.default.sources.USER);
|
5707
|
-
}
|
5708
|
-
this.quill.setSelection(range.index, _quill2.default.sources.SILENT);
|
5709
|
-
this.quill.focus();
|
5710
|
-
}
|
5856
|
+
var GUARD_TEXT = '\uFEFF';
|
5711
5857
|
|
5712
|
-
function
|
5713
|
-
|
5858
|
+
var Embed = function (_Parchment$Embed) {
|
5859
|
+
_inherits(Embed, _Parchment$Embed);
|
5714
5860
|
|
5715
|
-
|
5716
|
-
this
|
5717
|
-
}
|
5718
|
-
var lineFormats = Object.keys(context.format).reduce(function (lineFormats, format) {
|
5719
|
-
if (_parchment2.default.query(format, _parchment2.default.Scope.BLOCK) && !Array.isArray(context.format[format])) {
|
5720
|
-
lineFormats[format] = context.format[format];
|
5721
|
-
}
|
5722
|
-
return lineFormats;
|
5723
|
-
}, {});
|
5724
|
-
this.quill.insertText(range.index, '\n', lineFormats, _quill2.default.sources.USER);
|
5725
|
-
// Earlier scroll.deleteAt might have messed up our selection,
|
5726
|
-
// so insertText's built in selection preservation is not reliable
|
5727
|
-
this.quill.setSelection(range.index + 1, _quill2.default.sources.SILENT);
|
5728
|
-
this.quill.focus();
|
5729
|
-
Object.keys(context.format).forEach(function (name) {
|
5730
|
-
if (lineFormats[name] != null) return;
|
5731
|
-
if (Array.isArray(context.format[name])) return;
|
5732
|
-
if (name === 'link') return;
|
5733
|
-
_this3.quill.format(name, context.format[name], _quill2.default.sources.USER);
|
5734
|
-
});
|
5735
|
-
}
|
5861
|
+
function Embed(node) {
|
5862
|
+
_classCallCheck(this, Embed);
|
5736
5863
|
|
5737
|
-
|
5738
|
-
return {
|
5739
|
-
key: Keyboard.keys.TAB,
|
5740
|
-
shiftKey: !indent,
|
5741
|
-
format: { 'code-block': true },
|
5742
|
-
handler: function handler(range) {
|
5743
|
-
var CodeBlock = _parchment2.default.query('code-block');
|
5744
|
-
var index = range.index,
|
5745
|
-
length = range.length;
|
5864
|
+
var _this = _possibleConstructorReturn(this, (Embed.__proto__ || Object.getPrototypeOf(Embed)).call(this, node));
|
5746
5865
|
|
5747
|
-
|
5748
|
-
|
5749
|
-
|
5750
|
-
|
5866
|
+
_this.contentNode = document.createElement('span');
|
5867
|
+
_this.contentNode.setAttribute('contenteditable', false);
|
5868
|
+
[].slice.call(_this.domNode.childNodes).forEach(function (childNode) {
|
5869
|
+
_this.contentNode.appendChild(childNode);
|
5870
|
+
});
|
5871
|
+
_this.leftGuard = document.createTextNode(GUARD_TEXT);
|
5872
|
+
_this.rightGuard = document.createTextNode(GUARD_TEXT);
|
5873
|
+
_this.domNode.appendChild(_this.leftGuard);
|
5874
|
+
_this.domNode.appendChild(_this.contentNode);
|
5875
|
+
_this.domNode.appendChild(_this.rightGuard);
|
5876
|
+
return _this;
|
5877
|
+
}
|
5751
5878
|
|
5752
|
-
|
5753
|
-
|
5754
|
-
|
5755
|
-
|
5756
|
-
|
5757
|
-
|
5758
|
-
|
5759
|
-
|
5760
|
-
|
5761
|
-
|
5762
|
-
|
5763
|
-
|
5764
|
-
|
5765
|
-
|
5766
|
-
|
5767
|
-
|
5768
|
-
|
5769
|
-
|
5770
|
-
|
5771
|
-
|
5772
|
-
}
|
5773
|
-
|
5774
|
-
|
5879
|
+
_createClass(Embed, [{
|
5880
|
+
key: 'index',
|
5881
|
+
value: function index(node, offset) {
|
5882
|
+
if (node === this.leftGuard) return 0;
|
5883
|
+
if (node === this.rightGuard) return 1;
|
5884
|
+
return _get(Embed.prototype.__proto__ || Object.getPrototypeOf(Embed.prototype), 'index', this).call(this, node, offset);
|
5885
|
+
}
|
5886
|
+
}, {
|
5887
|
+
key: 'restore',
|
5888
|
+
value: function restore(node) {
|
5889
|
+
var range = void 0,
|
5890
|
+
textNode = void 0;
|
5891
|
+
var text = node.data.split(GUARD_TEXT).join('');
|
5892
|
+
if (node === this.leftGuard) {
|
5893
|
+
if (this.prev instanceof _text2.default) {
|
5894
|
+
var prevLength = this.prev.length();
|
5895
|
+
this.prev.insertAt(prevLength, text);
|
5896
|
+
range = {
|
5897
|
+
startNode: this.prev.domNode,
|
5898
|
+
startOffset: prevLength + text.length
|
5899
|
+
};
|
5900
|
+
} else {
|
5901
|
+
textNode = document.createTextNode(text);
|
5902
|
+
this.parent.insertBefore(_parchment2.default.create(textNode), this);
|
5903
|
+
range = {
|
5904
|
+
startNode: textNode,
|
5905
|
+
startOffset: text.length
|
5906
|
+
};
|
5775
5907
|
}
|
5776
|
-
|
5777
|
-
|
5778
|
-
|
5779
|
-
|
5908
|
+
} else if (node === this.rightGuard) {
|
5909
|
+
if (this.next instanceof _text2.default) {
|
5910
|
+
this.next.insertAt(0, text);
|
5911
|
+
range = {
|
5912
|
+
startNode: this.next.domNode,
|
5913
|
+
startOffset: text.length
|
5914
|
+
};
|
5915
|
+
} else {
|
5916
|
+
textNode = document.createTextNode(text);
|
5917
|
+
this.parent.insertBefore(_parchment2.default.create(textNode), this.next);
|
5918
|
+
range = {
|
5919
|
+
startNode: textNode,
|
5920
|
+
startOffset: text.length
|
5921
|
+
};
|
5922
|
+
}
|
5923
|
+
}
|
5924
|
+
node.data = GUARD_TEXT;
|
5925
|
+
return range;
|
5780
5926
|
}
|
5781
|
-
}
|
5782
|
-
|
5927
|
+
}, {
|
5928
|
+
key: 'update',
|
5929
|
+
value: function update(mutations, context) {
|
5930
|
+
var _this2 = this;
|
5783
5931
|
|
5784
|
-
function
|
5785
|
-
|
5786
|
-
|
5787
|
-
|
5788
|
-
|
5789
|
-
|
5932
|
+
mutations.forEach(function (mutation) {
|
5933
|
+
if (mutation.type === 'characterData' && (mutation.target === _this2.leftGuard || mutation.target === _this2.rightGuard)) {
|
5934
|
+
var range = _this2.restore(mutation.target);
|
5935
|
+
if (range) context.range = range;
|
5936
|
+
}
|
5937
|
+
});
|
5790
5938
|
}
|
5791
|
-
};
|
5792
|
-
}
|
5939
|
+
}]);
|
5793
5940
|
|
5794
|
-
|
5795
|
-
|
5796
|
-
return normalize({ key: binding });
|
5797
|
-
}
|
5798
|
-
if ((typeof binding === 'undefined' ? 'undefined' : _typeof(binding)) === 'object') {
|
5799
|
-
binding = (0, _clone2.default)(binding, false);
|
5800
|
-
}
|
5801
|
-
if (typeof binding.key === 'string') {
|
5802
|
-
if (Keyboard.keys[binding.key.toUpperCase()] != null) {
|
5803
|
-
binding.key = Keyboard.keys[binding.key.toUpperCase()];
|
5804
|
-
} else if (binding.key.length === 1) {
|
5805
|
-
binding.key = binding.key.toUpperCase().charCodeAt(0);
|
5806
|
-
} else {
|
5807
|
-
return null;
|
5808
|
-
}
|
5809
|
-
}
|
5810
|
-
if (binding.shortKey) {
|
5811
|
-
binding[SHORTKEY] = binding.shortKey;
|
5812
|
-
delete binding.shortKey;
|
5813
|
-
}
|
5814
|
-
return binding;
|
5815
|
-
}
|
5941
|
+
return Embed;
|
5942
|
+
}(_parchment2.default.Embed);
|
5816
5943
|
|
5817
|
-
exports.default =
|
5818
|
-
exports.SHORTKEY = SHORTKEY;
|
5944
|
+
exports.default = Embed;
|
5819
5945
|
|
5820
5946
|
/***/ }),
|
5821
5947
|
/* 36 */
|
@@ -6065,13 +6191,13 @@ var History = function (_Module) {
|
|
6065
6191
|
value: function change(source, dest) {
|
6066
6192
|
if (this.stack[source].length === 0) return;
|
6067
6193
|
var delta = this.stack[source].pop();
|
6194
|
+
this.stack[dest].push(delta);
|
6068
6195
|
this.lastRecorded = 0;
|
6069
6196
|
this.ignoreChange = true;
|
6070
6197
|
this.quill.updateContents(delta[source], _quill2.default.sources.USER);
|
6071
6198
|
this.ignoreChange = false;
|
6072
6199
|
var index = getLastChangeIndex(delta[source]);
|
6073
6200
|
this.quill.setSelection(index);
|
6074
|
-
this.stack[dest].push(delta);
|
6075
6201
|
}
|
6076
6202
|
}, {
|
6077
6203
|
key: 'clear',
|
@@ -6177,7 +6303,7 @@ exports.getLastChangeIndex = getLastChangeIndex;
|
|
6177
6303
|
Object.defineProperty(exports, "__esModule", { value: true });
|
6178
6304
|
var LinkedList = /** @class */ (function () {
|
6179
6305
|
function LinkedList() {
|
6180
|
-
this.head = this.tail =
|
6306
|
+
this.head = this.tail = null;
|
6181
6307
|
this.length = 0;
|
6182
6308
|
}
|
6183
6309
|
LinkedList.prototype.append = function () {
|
@@ -6185,20 +6311,22 @@ var LinkedList = /** @class */ (function () {
|
|
6185
6311
|
for (var _i = 0; _i < arguments.length; _i++) {
|
6186
6312
|
nodes[_i] = arguments[_i];
|
6187
6313
|
}
|
6188
|
-
this.insertBefore(nodes[0],
|
6314
|
+
this.insertBefore(nodes[0], null);
|
6189
6315
|
if (nodes.length > 1) {
|
6190
6316
|
this.append.apply(this, nodes.slice(1));
|
6191
6317
|
}
|
6192
6318
|
};
|
6193
6319
|
LinkedList.prototype.contains = function (node) {
|
6194
6320
|
var cur, next = this.iterator();
|
6195
|
-
while (cur = next()) {
|
6321
|
+
while ((cur = next())) {
|
6196
6322
|
if (cur === node)
|
6197
6323
|
return true;
|
6198
6324
|
}
|
6199
6325
|
return false;
|
6200
6326
|
};
|
6201
6327
|
LinkedList.prototype.insertBefore = function (node, refNode) {
|
6328
|
+
if (!node)
|
6329
|
+
return;
|
6202
6330
|
node.next = refNode;
|
6203
6331
|
if (refNode != null) {
|
6204
6332
|
node.prev = refNode.prev;
|
@@ -6216,7 +6344,7 @@ var LinkedList = /** @class */ (function () {
|
|
6216
6344
|
this.tail = node;
|
6217
6345
|
}
|
6218
6346
|
else {
|
6219
|
-
node.prev =
|
6347
|
+
node.prev = null;
|
6220
6348
|
this.head = this.tail = node;
|
6221
6349
|
}
|
6222
6350
|
this.length += 1;
|
@@ -6257,9 +6385,10 @@ var LinkedList = /** @class */ (function () {
|
|
6257
6385
|
LinkedList.prototype.find = function (index, inclusive) {
|
6258
6386
|
if (inclusive === void 0) { inclusive = false; }
|
6259
6387
|
var cur, next = this.iterator();
|
6260
|
-
while (cur = next()) {
|
6388
|
+
while ((cur = next())) {
|
6261
6389
|
var length = cur.length();
|
6262
|
-
if (index < length ||
|
6390
|
+
if (index < length ||
|
6391
|
+
(inclusive && index === length && (cur.next == null || cur.next.length() !== 0))) {
|
6263
6392
|
return [cur, index];
|
6264
6393
|
}
|
6265
6394
|
index -= length;
|
@@ -6268,7 +6397,7 @@ var LinkedList = /** @class */ (function () {
|
|
6268
6397
|
};
|
6269
6398
|
LinkedList.prototype.forEach = function (callback) {
|
6270
6399
|
var cur, next = this.iterator();
|
6271
|
-
while (cur = next()) {
|
6400
|
+
while ((cur = next())) {
|
6272
6401
|
callback(cur);
|
6273
6402
|
}
|
6274
6403
|
};
|
@@ -6296,7 +6425,7 @@ var LinkedList = /** @class */ (function () {
|
|
6296
6425
|
};
|
6297
6426
|
LinkedList.prototype.reduce = function (callback, memo) {
|
6298
6427
|
var cur, next = this.iterator();
|
6299
|
-
while (cur = next()) {
|
6428
|
+
while ((cur = next())) {
|
6300
6429
|
memo = callback(memo, cur);
|
6301
6430
|
}
|
6302
6431
|
return memo;
|
@@ -6330,18 +6459,19 @@ var OBSERVER_CONFIG = {
|
|
6330
6459
|
characterData: true,
|
6331
6460
|
characterDataOldValue: true,
|
6332
6461
|
childList: true,
|
6333
|
-
subtree: true
|
6462
|
+
subtree: true,
|
6334
6463
|
};
|
6335
6464
|
var MAX_OPTIMIZE_ITERATIONS = 100;
|
6336
6465
|
var ScrollBlot = /** @class */ (function (_super) {
|
6337
6466
|
__extends(ScrollBlot, _super);
|
6338
6467
|
function ScrollBlot(node) {
|
6339
6468
|
var _this = _super.call(this, node) || this;
|
6340
|
-
_this.
|
6469
|
+
_this.scroll = _this;
|
6341
6470
|
_this.observer = new MutationObserver(function (mutations) {
|
6342
6471
|
_this.update(mutations);
|
6343
6472
|
});
|
6344
6473
|
_this.observer.observe(_this.domNode, OBSERVER_CONFIG);
|
6474
|
+
_this.attach();
|
6345
6475
|
return _this;
|
6346
6476
|
}
|
6347
6477
|
ScrollBlot.prototype.detach = function () {
|
@@ -6385,14 +6515,21 @@ var ScrollBlot = /** @class */ (function (_super) {
|
|
6385
6515
|
return;
|
6386
6516
|
if (blot.domNode.parentNode == null)
|
6387
6517
|
return;
|
6518
|
+
// @ts-ignore
|
6388
6519
|
if (blot.domNode[Registry.DATA_KEY].mutations == null) {
|
6520
|
+
// @ts-ignore
|
6389
6521
|
blot.domNode[Registry.DATA_KEY].mutations = [];
|
6390
6522
|
}
|
6391
6523
|
if (markParent)
|
6392
6524
|
mark(blot.parent);
|
6393
6525
|
};
|
6394
6526
|
var optimize = function (blot) {
|
6395
|
-
|
6527
|
+
// Post-order traversal
|
6528
|
+
if (
|
6529
|
+
// @ts-ignore
|
6530
|
+
blot.domNode[Registry.DATA_KEY] == null ||
|
6531
|
+
// @ts-ignore
|
6532
|
+
blot.domNode[Registry.DATA_KEY].mutations == null) {
|
6396
6533
|
return;
|
6397
6534
|
}
|
6398
6535
|
if (blot instanceof container_1.default) {
|
@@ -6440,24 +6577,35 @@ var ScrollBlot = /** @class */ (function (_super) {
|
|
6440
6577
|
if (context === void 0) { context = {}; }
|
6441
6578
|
mutations = mutations || this.observer.takeRecords();
|
6442
6579
|
// TODO use WeakMap
|
6443
|
-
mutations
|
6580
|
+
mutations
|
6581
|
+
.map(function (mutation) {
|
6444
6582
|
var blot = Registry.find(mutation.target, true);
|
6445
6583
|
if (blot == null)
|
6446
|
-
return;
|
6584
|
+
return null;
|
6585
|
+
// @ts-ignore
|
6447
6586
|
if (blot.domNode[Registry.DATA_KEY].mutations == null) {
|
6587
|
+
// @ts-ignore
|
6448
6588
|
blot.domNode[Registry.DATA_KEY].mutations = [mutation];
|
6449
6589
|
return blot;
|
6450
6590
|
}
|
6451
6591
|
else {
|
6592
|
+
// @ts-ignore
|
6452
6593
|
blot.domNode[Registry.DATA_KEY].mutations.push(mutation);
|
6453
6594
|
return null;
|
6454
6595
|
}
|
6455
|
-
})
|
6456
|
-
|
6596
|
+
})
|
6597
|
+
.forEach(function (blot) {
|
6598
|
+
if (blot == null ||
|
6599
|
+
blot === _this ||
|
6600
|
+
//@ts-ignore
|
6601
|
+
blot.domNode[Registry.DATA_KEY] == null)
|
6457
6602
|
return;
|
6603
|
+
// @ts-ignore
|
6458
6604
|
blot.update(blot.domNode[Registry.DATA_KEY].mutations || [], context);
|
6459
6605
|
});
|
6606
|
+
// @ts-ignore
|
6460
6607
|
if (this.domNode[Registry.DATA_KEY].mutations != null) {
|
6608
|
+
// @ts-ignore
|
6461
6609
|
_super.prototype.update.call(this, this.domNode[Registry.DATA_KEY].mutations, context);
|
6462
6610
|
}
|
6463
6611
|
this.optimize(mutations, context);
|
@@ -6494,7 +6642,9 @@ var Registry = __webpack_require__(1);
|
|
6494
6642
|
function isEqual(obj1, obj2) {
|
6495
6643
|
if (Object.keys(obj1).length !== Object.keys(obj2).length)
|
6496
6644
|
return false;
|
6645
|
+
// @ts-ignore
|
6497
6646
|
for (var prop in obj1) {
|
6647
|
+
// @ts-ignore
|
6498
6648
|
if (obj1[prop] !== obj2[prop])
|
6499
6649
|
return false;
|
6500
6650
|
}
|
@@ -6616,7 +6766,7 @@ var BlockBlot = /** @class */ (function (_super) {
|
|
6616
6766
|
};
|
6617
6767
|
BlockBlot.prototype.update = function (mutations, context) {
|
6618
6768
|
if (navigator.userAgent.match(/Trident/)) {
|
6619
|
-
this.
|
6769
|
+
this.build();
|
6620
6770
|
}
|
6621
6771
|
else {
|
6622
6772
|
_super.prototype.update.call(this, mutations, context);
|
@@ -6709,8 +6859,9 @@ var TextBlot = /** @class */ (function (_super) {
|
|
6709
6859
|
};
|
6710
6860
|
TextBlot.value = function (domNode) {
|
6711
6861
|
var text = domNode.data;
|
6712
|
-
|
6713
|
-
|
6862
|
+
// @ts-ignore
|
6863
|
+
if (text['normalize'])
|
6864
|
+
text = text['normalize']();
|
6714
6865
|
return text;
|
6715
6866
|
};
|
6716
6867
|
TextBlot.prototype.deleteAt = function (index, length) {
|
@@ -6939,6 +7090,7 @@ function diff_main(text1, text2, cursor_pos) {
|
|
6939
7090
|
if (cursor_pos != null) {
|
6940
7091
|
diffs = fix_cursor(diffs, cursor_pos);
|
6941
7092
|
}
|
7093
|
+
diffs = fix_emoji(diffs);
|
6942
7094
|
return diffs;
|
6943
7095
|
};
|
6944
7096
|
|
@@ -7528,7 +7680,46 @@ function fix_cursor (diffs, cursor_pos) {
|
|
7528
7680
|
return diffs;
|
7529
7681
|
}
|
7530
7682
|
}
|
7683
|
+
}
|
7684
|
+
|
7685
|
+
/*
|
7686
|
+
* Check diff did not split surrogate pairs.
|
7687
|
+
* Ex. [0, '\uD83D'], [-1, '\uDC36'], [1, '\uDC2F'] -> [-1, '\uD83D\uDC36'], [1, '\uD83D\uDC2F']
|
7688
|
+
* '\uD83D\uDC36' === '🐶', '\uD83D\uDC2F' === '🐯'
|
7689
|
+
*
|
7690
|
+
* @param {Array} diffs Array of diff tuples
|
7691
|
+
* @return {Array} Array of diff tuples
|
7692
|
+
*/
|
7693
|
+
function fix_emoji (diffs) {
|
7694
|
+
var compact = false;
|
7695
|
+
var starts_with_pair_end = function(str) {
|
7696
|
+
return str.charCodeAt(0) >= 0xDC00 && str.charCodeAt(0) <= 0xDFFF;
|
7697
|
+
}
|
7698
|
+
var ends_with_pair_start = function(str) {
|
7699
|
+
return str.charCodeAt(str.length-1) >= 0xD800 && str.charCodeAt(str.length-1) <= 0xDBFF;
|
7700
|
+
}
|
7701
|
+
for (var i = 2; i < diffs.length; i += 1) {
|
7702
|
+
if (diffs[i-2][0] === DIFF_EQUAL && ends_with_pair_start(diffs[i-2][1]) &&
|
7703
|
+
diffs[i-1][0] === DIFF_DELETE && starts_with_pair_end(diffs[i-1][1]) &&
|
7704
|
+
diffs[i][0] === DIFF_INSERT && starts_with_pair_end(diffs[i][1])) {
|
7705
|
+
compact = true;
|
7706
|
+
|
7707
|
+
diffs[i-1][1] = diffs[i-2][1].slice(-1) + diffs[i-1][1];
|
7708
|
+
diffs[i][1] = diffs[i-2][1].slice(-1) + diffs[i][1];
|
7531
7709
|
|
7710
|
+
diffs[i-2][1] = diffs[i-2][1].slice(0, -1);
|
7711
|
+
}
|
7712
|
+
}
|
7713
|
+
if (!compact) {
|
7714
|
+
return diffs;
|
7715
|
+
}
|
7716
|
+
var fixed_diffs = [];
|
7717
|
+
for (var i = 0; i < diffs.length; i += 1) {
|
7718
|
+
if (diffs[i][1].length > 0) {
|
7719
|
+
fixed_diffs.push(diffs[i]);
|
7720
|
+
}
|
7721
|
+
}
|
7722
|
+
return fixed_diffs;
|
7532
7723
|
}
|
7533
7724
|
|
7534
7725
|
/*
|
@@ -8060,10 +8251,12 @@ var Clipboard = function (_Module) {
|
|
8060
8251
|
var source = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : _quill2.default.sources.API;
|
8061
8252
|
|
8062
8253
|
if (typeof index === 'string') {
|
8063
|
-
|
8254
|
+
this.quill.setContents(this.convert(index), html);
|
8255
|
+
this.quill.setSelection(0, _quill2.default.sources.SILENT);
|
8064
8256
|
} else {
|
8065
8257
|
var paste = this.convert(html);
|
8066
|
-
|
8258
|
+
this.quill.updateContents(new _quillDelta2.default().retain(index).concat(paste), source);
|
8259
|
+
this.quill.setSelection(index + paste.length(), _quill2.default.sources.SILENT);
|
8067
8260
|
}
|
8068
8261
|
}
|
8069
8262
|
}, {
|
@@ -8204,11 +8397,11 @@ function matchAttributor(node, delta) {
|
|
8204
8397
|
if (formats[attr.attrName]) return;
|
8205
8398
|
}
|
8206
8399
|
attr = ATTRIBUTE_ATTRIBUTORS[name];
|
8207
|
-
if (attr != null && attr.attrName === name) {
|
8400
|
+
if (attr != null && (attr.attrName === name || attr.keyName === name)) {
|
8208
8401
|
formats[attr.attrName] = attr.value(node) || undefined;
|
8209
8402
|
}
|
8210
8403
|
attr = STYLE_ATTRIBUTORS[name];
|
8211
|
-
if (attr != null && attr.attrName === name) {
|
8404
|
+
if (attr != null && (attr.attrName === name || attr.keyName === name)) {
|
8212
8405
|
attr = STYLE_ATTRIBUTORS[name];
|
8213
8406
|
formats[attr.attrName] = attr.value(node) || undefined;
|
8214
8407
|
}
|
@@ -8397,5 +8590,5 @@ module.exports = __webpack_require__(29);
|
|
8397
8590
|
|
8398
8591
|
|
8399
8592
|
/***/ })
|
8400
|
-
/******/ ]);
|
8593
|
+
/******/ ])["default"];
|
8401
8594
|
});
|