slate 0.118.1 → 0.120.0

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.
package/dist/index.es.js CHANGED
@@ -1,5 +1,3 @@
1
- import { produce } from 'immer';
2
-
3
1
  // eslint-disable-next-line no-redeclare
4
2
  var PathRef = {
5
3
  transform(ref, op) {
@@ -370,676 +368,239 @@ function _defineProperty(obj, key, value) {
370
368
  return obj;
371
369
  }
372
370
 
373
- function ownKeys$e(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
374
- function _objectSpread$e(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$e(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$e(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
375
- var insertChildren = function insertChildren(xs, index) {
376
- for (var _len = arguments.length, newValues = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) {
377
- newValues[_key - 2] = arguments[_key];
378
- }
379
- return [...xs.slice(0, index), ...newValues, ...xs.slice(index)];
380
- };
381
- var replaceChildren = function replaceChildren(xs, index, removeCount) {
382
- for (var _len2 = arguments.length, newValues = new Array(_len2 > 3 ? _len2 - 3 : 0), _key2 = 3; _key2 < _len2; _key2++) {
383
- newValues[_key2 - 3] = arguments[_key2];
371
+ function _objectWithoutPropertiesLoose(source, excluded) {
372
+ if (source == null) return {};
373
+ var target = {};
374
+ var sourceKeys = Object.keys(source);
375
+ var key, i;
376
+ for (i = 0; i < sourceKeys.length; i++) {
377
+ key = sourceKeys[i];
378
+ if (excluded.indexOf(key) >= 0) continue;
379
+ target[key] = source[key];
384
380
  }
385
- return [...xs.slice(0, index), ...newValues, ...xs.slice(index + removeCount)];
386
- };
387
- var removeChildren = replaceChildren;
388
- /**
389
- * Replace a descendant with a new node, replacing all ancestors
390
- */
391
- var modifyDescendant = (editor, path, f) => {
392
- if (path.length === 0) {
393
- throw new Error('Cannot modify the editor');
381
+ return target;
382
+ }
383
+
384
+ function _objectWithoutProperties(source, excluded) {
385
+ if (source == null) return {};
386
+ var target = _objectWithoutPropertiesLoose(source, excluded);
387
+ var key, i;
388
+ if (Object.getOwnPropertySymbols) {
389
+ var sourceSymbolKeys = Object.getOwnPropertySymbols(source);
390
+ for (i = 0; i < sourceSymbolKeys.length; i++) {
391
+ key = sourceSymbolKeys[i];
392
+ if (excluded.indexOf(key) >= 0) continue;
393
+ if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue;
394
+ target[key] = source[key];
395
+ }
394
396
  }
395
- var node = Node.get(editor, path);
396
- var slicedPath = path.slice();
397
- var modifiedNode = f(node);
398
- while (slicedPath.length > 1) {
399
- var _index = slicedPath.pop();
400
- var ancestorNode = Node.get(editor, slicedPath);
401
- modifiedNode = _objectSpread$e(_objectSpread$e({}, ancestorNode), {}, {
402
- children: replaceChildren(ancestorNode.children, _index, 1, modifiedNode)
397
+ return target;
398
+ }
399
+
400
+ var _excluded$4 = ["anchor", "focus"];
401
+ function ownKeys$g(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
402
+ function _objectSpread$g(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$g(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$g(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
403
+ // eslint-disable-next-line no-redeclare
404
+ var Range = {
405
+ edges(range) {
406
+ var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
407
+ var {
408
+ reverse = false
409
+ } = options;
410
+ var {
411
+ anchor,
412
+ focus
413
+ } = range;
414
+ return Range.isBackward(range) === reverse ? [anchor, focus] : [focus, anchor];
415
+ },
416
+ end(range) {
417
+ var [, end] = Range.edges(range);
418
+ return end;
419
+ },
420
+ equals(range, another) {
421
+ return Point.equals(range.anchor, another.anchor) && Point.equals(range.focus, another.focus);
422
+ },
423
+ surrounds(range, target) {
424
+ var intersectionRange = Range.intersection(range, target);
425
+ if (!intersectionRange) {
426
+ return false;
427
+ }
428
+ return Range.equals(intersectionRange, target);
429
+ },
430
+ includes(range, target) {
431
+ if (Range.isRange(target)) {
432
+ if (Range.includes(range, target.anchor) || Range.includes(range, target.focus)) {
433
+ return true;
434
+ }
435
+ var [rs, re] = Range.edges(range);
436
+ var [ts, te] = Range.edges(target);
437
+ return Point.isBefore(rs, ts) && Point.isAfter(re, te);
438
+ }
439
+ var [start, end] = Range.edges(range);
440
+ var isAfterStart = false;
441
+ var isBeforeEnd = false;
442
+ if (Point.isPoint(target)) {
443
+ isAfterStart = Point.compare(target, start) >= 0;
444
+ isBeforeEnd = Point.compare(target, end) <= 0;
445
+ } else {
446
+ isAfterStart = Path.compare(target, start.path) >= 0;
447
+ isBeforeEnd = Path.compare(target, end.path) <= 0;
448
+ }
449
+ return isAfterStart && isBeforeEnd;
450
+ },
451
+ intersection(range, another) {
452
+ var rest = _objectWithoutProperties(range, _excluded$4);
453
+ var [s1, e1] = Range.edges(range);
454
+ var [s2, e2] = Range.edges(another);
455
+ var start = Point.isBefore(s1, s2) ? s2 : s1;
456
+ var end = Point.isBefore(e1, e2) ? e1 : e2;
457
+ if (Point.isBefore(end, start)) {
458
+ return null;
459
+ } else {
460
+ return _objectSpread$g({
461
+ anchor: start,
462
+ focus: end
463
+ }, rest);
464
+ }
465
+ },
466
+ isBackward(range) {
467
+ var {
468
+ anchor,
469
+ focus
470
+ } = range;
471
+ return Point.isAfter(anchor, focus);
472
+ },
473
+ isCollapsed(range) {
474
+ var {
475
+ anchor,
476
+ focus
477
+ } = range;
478
+ return Point.equals(anchor, focus);
479
+ },
480
+ isExpanded(range) {
481
+ return !Range.isCollapsed(range);
482
+ },
483
+ isForward(range) {
484
+ return !Range.isBackward(range);
485
+ },
486
+ isRange(value) {
487
+ return isObject(value) && Point.isPoint(value.anchor) && Point.isPoint(value.focus);
488
+ },
489
+ *points(range) {
490
+ yield [range.anchor, 'anchor'];
491
+ yield [range.focus, 'focus'];
492
+ },
493
+ start(range) {
494
+ var [start] = Range.edges(range);
495
+ return start;
496
+ },
497
+ transform(range, op) {
498
+ var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
499
+ if (range === null) {
500
+ return null;
501
+ }
502
+ var {
503
+ affinity = 'inward'
504
+ } = options;
505
+ var affinityAnchor;
506
+ var affinityFocus;
507
+ if (affinity === 'inward') {
508
+ // If the range is collapsed, make sure to use the same affinity to
509
+ // avoid the two points passing each other and expanding in the opposite
510
+ // direction
511
+ var isCollapsed = Range.isCollapsed(range);
512
+ if (Range.isForward(range)) {
513
+ affinityAnchor = 'forward';
514
+ affinityFocus = isCollapsed ? affinityAnchor : 'backward';
515
+ } else {
516
+ affinityAnchor = 'backward';
517
+ affinityFocus = isCollapsed ? affinityAnchor : 'forward';
518
+ }
519
+ } else if (affinity === 'outward') {
520
+ if (Range.isForward(range)) {
521
+ affinityAnchor = 'backward';
522
+ affinityFocus = 'forward';
523
+ } else {
524
+ affinityAnchor = 'forward';
525
+ affinityFocus = 'backward';
526
+ }
527
+ } else {
528
+ affinityAnchor = affinity;
529
+ affinityFocus = affinity;
530
+ }
531
+ var anchor = Point.transform(range.anchor, op, {
532
+ affinity: affinityAnchor
533
+ });
534
+ var focus = Point.transform(range.focus, op, {
535
+ affinity: affinityFocus
403
536
  });
537
+ if (!anchor || !focus) {
538
+ return null;
539
+ }
540
+ return {
541
+ anchor,
542
+ focus
543
+ };
404
544
  }
405
- var index = slicedPath.pop();
406
- editor.children = replaceChildren(editor.children, index, 1, modifiedNode);
407
545
  };
546
+
408
547
  /**
409
- * Replace the children of a node, replacing all ancestors
548
+ * Shared the function with isElementType utility
410
549
  */
411
- var modifyChildren = (editor, path, f) => {
412
- if (path.length === 0) {
413
- editor.children = f(editor.children);
414
- } else {
415
- modifyDescendant(editor, path, node => {
416
- if (Text.isText(node)) {
417
- throw new Error("Cannot get the element at path [".concat(path, "] because it refers to a leaf node: ").concat(Scrubber.stringify(node)));
418
- }
419
- return _objectSpread$e(_objectSpread$e({}, node), {}, {
420
- children: f(node.children)
421
- });
550
+ var isElement = function isElement(value) {
551
+ var {
552
+ deep = false
553
+ } = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
554
+ if (!isObject(value)) return false;
555
+ // PERF: No need to use the full Editor.isEditor here
556
+ var isEditor = typeof value.apply === 'function';
557
+ if (isEditor) return false;
558
+ var isChildrenValid = deep ? Node.isNodeList(value.children) : Array.isArray(value.children);
559
+ return isChildrenValid;
560
+ };
561
+ // eslint-disable-next-line no-redeclare
562
+ var Element = {
563
+ isAncestor(value) {
564
+ var {
565
+ deep = false
566
+ } = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
567
+ return isObject(value) && Node.isNodeList(value.children, {
568
+ deep
422
569
  });
423
- }
424
- };
425
- /**
426
- * Replace a leaf, replacing all ancestors
427
- */
428
- var modifyLeaf = (editor, path, f) => modifyDescendant(editor, path, node => {
429
- if (!Text.isText(node)) {
430
- throw new Error("Cannot get the leaf node at path [".concat(path, "] because it refers to a non-leaf node: ").concat(Scrubber.stringify(node)));
431
- }
432
- return f(node);
433
- });
434
- // eslint-disable-next-line no-redeclare
435
- var GeneralTransforms = {
436
- transform(editor, op) {
437
- var transformSelection = false;
438
- switch (op.type) {
439
- case 'insert_node':
440
- {
441
- var {
442
- path,
443
- node
444
- } = op;
445
- modifyChildren(editor, Path.parent(path), children => {
446
- var index = path[path.length - 1];
447
- if (index > children.length) {
448
- throw new Error("Cannot apply an \"insert_node\" operation at path [".concat(path, "] because the destination is past the end of the node."));
449
- }
450
- return insertChildren(children, index, node);
451
- });
452
- transformSelection = true;
453
- break;
454
- }
455
- case 'insert_text':
456
- {
457
- var {
458
- path: _path,
459
- offset,
460
- text
461
- } = op;
462
- if (text.length === 0) break;
463
- modifyLeaf(editor, _path, node => {
464
- var before = node.text.slice(0, offset);
465
- var after = node.text.slice(offset);
466
- return _objectSpread$e(_objectSpread$e({}, node), {}, {
467
- text: before + text + after
468
- });
469
- });
470
- transformSelection = true;
471
- break;
472
- }
473
- case 'merge_node':
474
- {
475
- var {
476
- path: _path2
477
- } = op;
478
- var index = _path2[_path2.length - 1];
479
- var prevPath = Path.previous(_path2);
480
- var prevIndex = prevPath[prevPath.length - 1];
481
- modifyChildren(editor, Path.parent(_path2), children => {
482
- var node = children[index];
483
- var prev = children[prevIndex];
484
- var newNode;
485
- if (Text.isText(node) && Text.isText(prev)) {
486
- newNode = _objectSpread$e(_objectSpread$e({}, prev), {}, {
487
- text: prev.text + node.text
488
- });
489
- } else if (!Text.isText(node) && !Text.isText(prev)) {
490
- newNode = _objectSpread$e(_objectSpread$e({}, prev), {}, {
491
- children: prev.children.concat(node.children)
492
- });
493
- } else {
494
- throw new Error("Cannot apply a \"merge_node\" operation at path [".concat(_path2, "] to nodes of different interfaces: ").concat(Scrubber.stringify(node), " ").concat(Scrubber.stringify(prev)));
495
- }
496
- return replaceChildren(children, prevIndex, 2, newNode);
497
- });
498
- transformSelection = true;
499
- break;
500
- }
501
- case 'move_node':
502
- {
503
- var {
504
- path: _path3,
505
- newPath
506
- } = op;
507
- var _index2 = _path3[_path3.length - 1];
508
- if (Path.isAncestor(_path3, newPath)) {
509
- throw new Error("Cannot move a path [".concat(_path3, "] to new path [").concat(newPath, "] because the destination is inside itself."));
510
- }
511
- var _node = Node.get(editor, _path3);
512
- modifyChildren(editor, Path.parent(_path3), children => removeChildren(children, _index2, 1));
513
- // This is tricky, but since the `path` and `newPath` both refer to
514
- // the same snapshot in time, there's a mismatch. After either
515
- // removing the original position, the second step's path can be out
516
- // of date. So instead of using the `op.newPath` directly, we
517
- // transform `op.path` to ascertain what the `newPath` would be after
518
- // the operation was applied.
519
- var truePath = Path.transform(_path3, op);
520
- var newIndex = truePath[truePath.length - 1];
521
- modifyChildren(editor, Path.parent(truePath), children => insertChildren(children, newIndex, _node));
522
- transformSelection = true;
523
- break;
524
- }
525
- case 'remove_node':
526
- {
527
- var {
528
- path: _path4
529
- } = op;
530
- var _index3 = _path4[_path4.length - 1];
531
- modifyChildren(editor, Path.parent(_path4), children => removeChildren(children, _index3, 1));
532
- // Transform all the points in the value, but if the point was in the
533
- // node that was removed we need to update the range or remove it.
534
- if (editor.selection) {
535
- var selection = _objectSpread$e({}, editor.selection);
536
- for (var [point, key] of Range.points(selection)) {
537
- var result = Point.transform(point, op);
538
- if (selection != null && result != null) {
539
- selection[key] = result;
540
- } else {
541
- var prev = void 0;
542
- var next = void 0;
543
- for (var [n, p] of Node.texts(editor)) {
544
- if (Path.compare(p, _path4) === -1) {
545
- prev = [n, p];
546
- } else {
547
- next = [n, p];
548
- break;
549
- }
550
- }
551
- var preferNext = false;
552
- if (prev && next) {
553
- if (Path.isSibling(prev[1], _path4)) {
554
- preferNext = false;
555
- } else if (Path.equals(next[1], _path4)) {
556
- preferNext = true;
557
- } else {
558
- preferNext = Path.common(prev[1], _path4).length < Path.common(next[1], _path4).length;
559
- }
560
- }
561
- if (prev && !preferNext) {
562
- selection[key] = {
563
- path: prev[1],
564
- offset: prev[0].text.length
565
- };
566
- } else if (next) {
567
- selection[key] = {
568
- path: next[1],
569
- offset: 0
570
- };
571
- } else {
572
- selection = null;
573
- }
574
- }
575
- }
576
- if (!selection || !Range.equals(selection, editor.selection)) {
577
- editor.selection = selection;
578
- }
579
- }
580
- break;
581
- }
582
- case 'remove_text':
583
- {
584
- var {
585
- path: _path5,
586
- offset: _offset,
587
- text: _text
588
- } = op;
589
- if (_text.length === 0) break;
590
- modifyLeaf(editor, _path5, node => {
591
- var before = node.text.slice(0, _offset);
592
- var after = node.text.slice(_offset + _text.length);
593
- return _objectSpread$e(_objectSpread$e({}, node), {}, {
594
- text: before + after
595
- });
596
- });
597
- transformSelection = true;
598
- break;
599
- }
600
- case 'set_node':
601
- {
602
- var {
603
- path: _path6,
604
- properties,
605
- newProperties
606
- } = op;
607
- if (_path6.length === 0) {
608
- throw new Error("Cannot set properties on the root node!");
609
- }
610
- modifyDescendant(editor, _path6, node => {
611
- var newNode = _objectSpread$e({}, node);
612
- for (var _key3 in newProperties) {
613
- if (_key3 === 'children' || _key3 === 'text') {
614
- throw new Error("Cannot set the \"".concat(_key3, "\" property of nodes!"));
615
- }
616
- var value = newProperties[_key3];
617
- if (value == null) {
618
- delete newNode[_key3];
619
- } else {
620
- newNode[_key3] = value;
621
- }
622
- }
623
- // properties that were previously defined, but are now missing, must be deleted
624
- for (var _key4 in properties) {
625
- if (!newProperties.hasOwnProperty(_key4)) {
626
- delete newNode[_key4];
627
- }
628
- }
629
- return newNode;
630
- });
631
- break;
632
- }
633
- case 'set_selection':
634
- {
635
- var {
636
- newProperties: _newProperties
637
- } = op;
638
- if (_newProperties == null) {
639
- editor.selection = null;
640
- break;
641
- }
642
- if (editor.selection == null) {
643
- if (!Range.isRange(_newProperties)) {
644
- throw new Error("Cannot apply an incomplete \"set_selection\" operation properties ".concat(Scrubber.stringify(_newProperties), " when there is no current selection."));
645
- }
646
- editor.selection = _objectSpread$e({}, _newProperties);
647
- break;
648
- }
649
- var _selection = _objectSpread$e({}, editor.selection);
650
- for (var _key5 in _newProperties) {
651
- var value = _newProperties[_key5];
652
- if (value == null) {
653
- if (_key5 === 'anchor' || _key5 === 'focus') {
654
- throw new Error("Cannot remove the \"".concat(_key5, "\" selection property"));
655
- }
656
- delete _selection[_key5];
657
- } else {
658
- _selection[_key5] = value;
659
- }
660
- }
661
- editor.selection = _selection;
662
- break;
663
- }
664
- case 'split_node':
665
- {
666
- var {
667
- path: _path7,
668
- position,
669
- properties: _properties
670
- } = op;
671
- var _index4 = _path7[_path7.length - 1];
672
- if (_path7.length === 0) {
673
- throw new Error("Cannot apply a \"split_node\" operation at path [".concat(_path7, "] because the root node cannot be split."));
674
- }
675
- modifyChildren(editor, Path.parent(_path7), children => {
676
- var node = children[_index4];
677
- var newNode;
678
- var nextNode;
679
- if (Text.isText(node)) {
680
- var before = node.text.slice(0, position);
681
- var after = node.text.slice(position);
682
- newNode = _objectSpread$e(_objectSpread$e({}, node), {}, {
683
- text: before
684
- });
685
- nextNode = _objectSpread$e(_objectSpread$e({}, _properties), {}, {
686
- text: after
687
- });
688
- } else {
689
- var _before = node.children.slice(0, position);
690
- var _after = node.children.slice(position);
691
- newNode = _objectSpread$e(_objectSpread$e({}, node), {}, {
692
- children: _before
693
- });
694
- nextNode = _objectSpread$e(_objectSpread$e({}, _properties), {}, {
695
- children: _after
696
- });
697
- }
698
- return replaceChildren(children, _index4, 1, newNode, nextNode);
699
- });
700
- transformSelection = true;
701
- break;
702
- }
703
- }
704
- if (transformSelection && editor.selection) {
705
- var _selection2 = _objectSpread$e({}, editor.selection);
706
- for (var [_point, _key6] of Range.points(_selection2)) {
707
- _selection2[_key6] = Point.transform(_point, op);
708
- }
709
- if (!Range.equals(_selection2, editor.selection)) {
710
- editor.selection = _selection2;
711
- }
712
- }
713
- }
714
- };
715
-
716
- // eslint-disable-next-line no-redeclare
717
- var NodeTransforms = {
718
- insertNodes(editor, nodes, options) {
719
- editor.insertNodes(nodes, options);
720
- },
721
- liftNodes(editor, options) {
722
- editor.liftNodes(options);
723
- },
724
- mergeNodes(editor, options) {
725
- editor.mergeNodes(options);
726
- },
727
- moveNodes(editor, options) {
728
- editor.moveNodes(options);
729
- },
730
- removeNodes(editor, options) {
731
- editor.removeNodes(options);
732
- },
733
- setNodes(editor, props, options) {
734
- editor.setNodes(props, options);
735
- },
736
- splitNodes(editor, options) {
737
- editor.splitNodes(options);
738
- },
739
- unsetNodes(editor, props, options) {
740
- editor.unsetNodes(props, options);
741
- },
742
- unwrapNodes(editor, options) {
743
- editor.unwrapNodes(options);
744
- },
745
- wrapNodes(editor, element, options) {
746
- editor.wrapNodes(element, options);
747
- }
748
- };
749
-
750
- // eslint-disable-next-line no-redeclare
751
- var SelectionTransforms = {
752
- collapse(editor, options) {
753
- editor.collapse(options);
754
- },
755
- deselect(editor) {
756
- editor.deselect();
757
- },
758
- move(editor, options) {
759
- editor.move(options);
760
- },
761
- select(editor, target) {
762
- editor.select(target);
763
- },
764
- setPoint(editor, props, options) {
765
- editor.setPoint(props, options);
766
- },
767
- setSelection(editor, props) {
768
- editor.setSelection(props);
769
- }
770
- };
771
-
772
- var isObject = value => typeof value === 'object' && value !== null;
773
-
774
- /*
775
- Custom deep equal comparison for Slate nodes.
776
-
777
- We don't need general purpose deep equality;
778
- Slate only supports plain values, Arrays, and nested objects.
779
- Complex values nested inside Arrays are not supported.
780
-
781
- Slate objects are designed to be serialised, so
782
- missing keys are deliberately normalised to undefined.
783
- */
784
- var isDeepEqual = (node, another) => {
785
- for (var key in node) {
786
- var a = node[key];
787
- var b = another[key];
788
- if (Array.isArray(a) && Array.isArray(b)) {
789
- if (a.length !== b.length) return false;
790
- for (var i = 0; i < a.length; i++) {
791
- if (a[i] !== b[i]) return false;
792
- }
793
- } else if (isObject(a) && isObject(b)) {
794
- if (!isDeepEqual(a, b)) return false;
795
- } else if (a !== b) {
796
- return false;
797
- }
798
- }
799
- /*
800
- Deep object equality is only necessary in one direction; in the reverse direction
801
- we are only looking for keys that are missing.
802
- As above, undefined keys are normalised to missing.
803
- */
804
- for (var _key in another) {
805
- if (node[_key] === undefined && another[_key] !== undefined) {
806
- return false;
807
- }
808
- }
809
- return true;
810
- };
811
-
812
- function _objectWithoutPropertiesLoose(source, excluded) {
813
- if (source == null) return {};
814
- var target = {};
815
- var sourceKeys = Object.keys(source);
816
- var key, i;
817
- for (i = 0; i < sourceKeys.length; i++) {
818
- key = sourceKeys[i];
819
- if (excluded.indexOf(key) >= 0) continue;
820
- target[key] = source[key];
821
- }
822
- return target;
823
- }
824
-
825
- function _objectWithoutProperties(source, excluded) {
826
- if (source == null) return {};
827
- var target = _objectWithoutPropertiesLoose(source, excluded);
828
- var key, i;
829
- if (Object.getOwnPropertySymbols) {
830
- var sourceSymbolKeys = Object.getOwnPropertySymbols(source);
831
- for (i = 0; i < sourceSymbolKeys.length; i++) {
832
- key = sourceSymbolKeys[i];
833
- if (excluded.indexOf(key) >= 0) continue;
834
- if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue;
835
- target[key] = source[key];
836
- }
837
- }
838
- return target;
839
- }
840
-
841
- var _excluded$4 = ["anchor", "focus"];
842
- function ownKeys$d(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
843
- function _objectSpread$d(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$d(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$d(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
844
- // eslint-disable-next-line no-redeclare
845
- var Range = {
846
- edges(range) {
847
- var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
848
- var {
849
- reverse = false
850
- } = options;
851
- var {
852
- anchor,
853
- focus
854
- } = range;
855
- return Range.isBackward(range) === reverse ? [anchor, focus] : [focus, anchor];
856
- },
857
- end(range) {
858
- var [, end] = Range.edges(range);
859
- return end;
860
- },
861
- equals(range, another) {
862
- return Point.equals(range.anchor, another.anchor) && Point.equals(range.focus, another.focus);
863
- },
864
- surrounds(range, target) {
865
- var intersectionRange = Range.intersection(range, target);
866
- if (!intersectionRange) {
867
- return false;
868
- }
869
- return Range.equals(intersectionRange, target);
870
- },
871
- includes(range, target) {
872
- if (Range.isRange(target)) {
873
- if (Range.includes(range, target.anchor) || Range.includes(range, target.focus)) {
874
- return true;
875
- }
876
- var [rs, re] = Range.edges(range);
877
- var [ts, te] = Range.edges(target);
878
- return Point.isBefore(rs, ts) && Point.isAfter(re, te);
879
- }
880
- var [start, end] = Range.edges(range);
881
- var isAfterStart = false;
882
- var isBeforeEnd = false;
883
- if (Point.isPoint(target)) {
884
- isAfterStart = Point.compare(target, start) >= 0;
885
- isBeforeEnd = Point.compare(target, end) <= 0;
886
- } else {
887
- isAfterStart = Path.compare(target, start.path) >= 0;
888
- isBeforeEnd = Path.compare(target, end.path) <= 0;
889
- }
890
- return isAfterStart && isBeforeEnd;
891
- },
892
- intersection(range, another) {
893
- var rest = _objectWithoutProperties(range, _excluded$4);
894
- var [s1, e1] = Range.edges(range);
895
- var [s2, e2] = Range.edges(another);
896
- var start = Point.isBefore(s1, s2) ? s2 : s1;
897
- var end = Point.isBefore(e1, e2) ? e1 : e2;
898
- if (Point.isBefore(end, start)) {
899
- return null;
900
- } else {
901
- return _objectSpread$d({
902
- anchor: start,
903
- focus: end
904
- }, rest);
905
- }
906
- },
907
- isBackward(range) {
908
- var {
909
- anchor,
910
- focus
911
- } = range;
912
- return Point.isAfter(anchor, focus);
913
- },
914
- isCollapsed(range) {
915
- var {
916
- anchor,
917
- focus
918
- } = range;
919
- return Point.equals(anchor, focus);
920
- },
921
- isExpanded(range) {
922
- return !Range.isCollapsed(range);
923
- },
924
- isForward(range) {
925
- return !Range.isBackward(range);
926
- },
927
- isRange(value) {
928
- return isObject(value) && Point.isPoint(value.anchor) && Point.isPoint(value.focus);
929
- },
930
- *points(range) {
931
- yield [range.anchor, 'anchor'];
932
- yield [range.focus, 'focus'];
933
- },
934
- start(range) {
935
- var [start] = Range.edges(range);
936
- return start;
937
- },
938
- transform(range, op) {
939
- var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
940
- if (range === null) {
941
- return null;
942
- }
943
- var {
944
- affinity = 'inward'
945
- } = options;
946
- var affinityAnchor;
947
- var affinityFocus;
948
- if (affinity === 'inward') {
949
- // If the range is collapsed, make sure to use the same affinity to
950
- // avoid the two points passing each other and expanding in the opposite
951
- // direction
952
- var isCollapsed = Range.isCollapsed(range);
953
- if (Range.isForward(range)) {
954
- affinityAnchor = 'forward';
955
- affinityFocus = isCollapsed ? affinityAnchor : 'backward';
956
- } else {
957
- affinityAnchor = 'backward';
958
- affinityFocus = isCollapsed ? affinityAnchor : 'forward';
959
- }
960
- } else if (affinity === 'outward') {
961
- if (Range.isForward(range)) {
962
- affinityAnchor = 'backward';
963
- affinityFocus = 'forward';
964
- } else {
965
- affinityAnchor = 'forward';
966
- affinityFocus = 'backward';
967
- }
968
- } else {
969
- affinityAnchor = affinity;
970
- affinityFocus = affinity;
971
- }
972
- var anchor = Point.transform(range.anchor, op, {
973
- affinity: affinityAnchor
974
- });
975
- var focus = Point.transform(range.focus, op, {
976
- affinity: affinityFocus
977
- });
978
- if (!anchor || !focus) {
979
- return null;
980
- }
981
- return {
982
- anchor,
983
- focus
984
- };
985
- }
986
- };
987
-
988
- /**
989
- * Shared the function with isElementType utility
990
- */
991
- var isElement = function isElement(value) {
992
- var {
993
- deep = false
994
- } = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
995
- if (!isObject(value)) return false;
996
- // PERF: No need to use the full Editor.isEditor here
997
- var isEditor = typeof value.apply === 'function';
998
- if (isEditor) return false;
999
- var isChildrenValid = deep ? Node.isNodeList(value.children) : Array.isArray(value.children);
1000
- return isChildrenValid;
1001
- };
1002
- // eslint-disable-next-line no-redeclare
1003
- var Element = {
1004
- isAncestor(value) {
1005
- var {
1006
- deep = false
1007
- } = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
1008
- return isObject(value) && Node.isNodeList(value.children, {
1009
- deep
1010
- });
1011
- },
1012
- isElement,
1013
- isElementList(value) {
1014
- var {
1015
- deep = false
1016
- } = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
1017
- return Array.isArray(value) && value.every(val => Element.isElement(val, {
1018
- deep
1019
- }));
1020
- },
1021
- isElementProps(props) {
1022
- return props.children !== undefined;
1023
- },
1024
- isElementType: function isElementType(value, elementVal) {
1025
- var elementKey = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'type';
1026
- return isElement(value) && value[elementKey] === elementVal;
1027
- },
1028
- matches(element, props) {
1029
- for (var key in props) {
1030
- if (key === 'children') {
1031
- continue;
1032
- }
1033
- if (element[key] !== props[key]) {
1034
- return false;
1035
- }
1036
- }
1037
- return true;
570
+ },
571
+ isElement,
572
+ isElementList(value) {
573
+ var {
574
+ deep = false
575
+ } = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
576
+ return Array.isArray(value) && value.every(val => Element.isElement(val, {
577
+ deep
578
+ }));
579
+ },
580
+ isElementProps(props) {
581
+ return props.children !== undefined;
582
+ },
583
+ isElementType: function isElementType(value, elementVal) {
584
+ var elementKey = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'type';
585
+ return isElement(value) && value[elementKey] === elementVal;
586
+ },
587
+ matches(element, props) {
588
+ for (var key in props) {
589
+ if (key === 'children') {
590
+ continue;
591
+ }
592
+ if (element[key] !== props[key]) {
593
+ return false;
594
+ }
595
+ }
596
+ return true;
1038
597
  }
1039
598
  };
1040
599
 
1041
600
  var _excluded$3 = ["children"],
1042
601
  _excluded2$3 = ["text"];
602
+ function ownKeys$f(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
603
+ function _objectSpread$f(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$f(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$f(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
1043
604
  // eslint-disable-next-line no-redeclare
1044
605
  var Node = {
1045
606
  ancestor(root, path) {
@@ -1145,36 +706,42 @@ var Node = {
1145
706
  return [n, p];
1146
707
  },
1147
708
  fragment(root, range) {
1148
- var newRoot = produce({
709
+ var newRoot = {
1149
710
  children: root.children
1150
- }, r => {
1151
- var [start, end] = Range.edges(range);
1152
- var nodeEntries = Node.nodes(r, {
1153
- reverse: true,
1154
- pass: _ref => {
1155
- var [, path] = _ref;
1156
- return !Range.includes(range, path);
1157
- }
1158
- });
1159
- for (var [, path] of nodeEntries) {
1160
- if (!Range.includes(range, path)) {
1161
- var parent = Node.parent(r, path);
1162
- var index = path[path.length - 1];
1163
- parent.children.splice(index, 1);
1164
- }
1165
- if (Path.equals(path, end.path)) {
1166
- var leaf = Node.leaf(r, path);
1167
- leaf.text = leaf.text.slice(0, end.offset);
1168
- }
1169
- if (Path.equals(path, start.path)) {
1170
- var _leaf = Node.leaf(r, path);
1171
- _leaf.text = _leaf.text.slice(start.offset);
1172
- }
1173
- }
1174
- if (Editor.isEditor(r)) {
1175
- r.selection = null;
711
+ };
712
+ var [start, end] = Range.edges(range);
713
+ var nodeEntries = Node.nodes(newRoot, {
714
+ reverse: true,
715
+ pass: _ref => {
716
+ var [, path] = _ref;
717
+ return !Range.includes(range, path);
1176
718
  }
1177
719
  });
720
+ var _loop = function _loop() {
721
+ if (!Range.includes(range, path)) {
722
+ var index = path[path.length - 1];
723
+ modifyChildren(newRoot, Path.parent(path), children => removeChildren(children, index, 1));
724
+ }
725
+ if (Path.equals(path, end.path)) {
726
+ modifyLeaf(newRoot, path, node => {
727
+ var before = node.text.slice(0, end.offset);
728
+ return _objectSpread$f(_objectSpread$f({}, node), {}, {
729
+ text: before
730
+ });
731
+ });
732
+ }
733
+ if (Path.equals(path, start.path)) {
734
+ modifyLeaf(newRoot, path, node => {
735
+ var before = node.text.slice(start.offset);
736
+ return _objectSpread$f(_objectSpread$f({}, node), {}, {
737
+ text: before
738
+ });
739
+ });
740
+ }
741
+ };
742
+ for (var [, path] of nodeEntries) {
743
+ _loop();
744
+ }
1178
745
  return newRoot.children;
1179
746
  },
1180
747
  get(root, path) {
@@ -1342,9 +909,9 @@ var Node = {
1342
909
  }();
1343
910
  }
1344
911
  };
1345
-
1346
- function ownKeys$c(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
1347
- function _objectSpread$c(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$c(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$c(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
912
+
913
+ function ownKeys$e(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
914
+ function _objectSpread$e(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$e(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$e(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
1348
915
  // eslint-disable-next-line no-redeclare
1349
916
  var Operation = {
1350
917
  isNodeOperation(value) {
@@ -1390,19 +957,19 @@ var Operation = {
1390
957
  switch (op.type) {
1391
958
  case 'insert_node':
1392
959
  {
1393
- return _objectSpread$c(_objectSpread$c({}, op), {}, {
960
+ return _objectSpread$e(_objectSpread$e({}, op), {}, {
1394
961
  type: 'remove_node'
1395
962
  });
1396
963
  }
1397
964
  case 'insert_text':
1398
965
  {
1399
- return _objectSpread$c(_objectSpread$c({}, op), {}, {
966
+ return _objectSpread$e(_objectSpread$e({}, op), {}, {
1400
967
  type: 'remove_text'
1401
968
  });
1402
969
  }
1403
970
  case 'merge_node':
1404
971
  {
1405
- return _objectSpread$c(_objectSpread$c({}, op), {}, {
972
+ return _objectSpread$e(_objectSpread$e({}, op), {}, {
1406
973
  type: 'split_node',
1407
974
  path: Path.previous(op.path)
1408
975
  });
@@ -1420,7 +987,7 @@ var Operation = {
1420
987
  // If the move happens completely within a single parent the path and
1421
988
  // newPath are stable with respect to each other.
1422
989
  if (Path.isSibling(path, newPath)) {
1423
- return _objectSpread$c(_objectSpread$c({}, op), {}, {
990
+ return _objectSpread$e(_objectSpread$e({}, op), {}, {
1424
991
  path: newPath,
1425
992
  newPath: path
1426
993
  });
@@ -1433,20 +1000,20 @@ var Operation = {
1433
1000
  // after the original move path.
1434
1001
  var inversePath = Path.transform(path, op);
1435
1002
  var inverseNewPath = Path.transform(Path.next(path), op);
1436
- return _objectSpread$c(_objectSpread$c({}, op), {}, {
1003
+ return _objectSpread$e(_objectSpread$e({}, op), {}, {
1437
1004
  path: inversePath,
1438
1005
  newPath: inverseNewPath
1439
1006
  });
1440
1007
  }
1441
1008
  case 'remove_node':
1442
1009
  {
1443
- return _objectSpread$c(_objectSpread$c({}, op), {}, {
1010
+ return _objectSpread$e(_objectSpread$e({}, op), {}, {
1444
1011
  type: 'insert_node'
1445
1012
  });
1446
1013
  }
1447
1014
  case 'remove_text':
1448
1015
  {
1449
- return _objectSpread$c(_objectSpread$c({}, op), {}, {
1016
+ return _objectSpread$e(_objectSpread$e({}, op), {}, {
1450
1017
  type: 'insert_text'
1451
1018
  });
1452
1019
  }
@@ -1456,7 +1023,7 @@ var Operation = {
1456
1023
  properties,
1457
1024
  newProperties
1458
1025
  } = op;
1459
- return _objectSpread$c(_objectSpread$c({}, op), {}, {
1026
+ return _objectSpread$e(_objectSpread$e({}, op), {}, {
1460
1027
  properties: newProperties,
1461
1028
  newProperties: properties
1462
1029
  });
@@ -1468,17 +1035,17 @@ var Operation = {
1468
1035
  newProperties: _newProperties
1469
1036
  } = op;
1470
1037
  if (_properties == null) {
1471
- return _objectSpread$c(_objectSpread$c({}, op), {}, {
1038
+ return _objectSpread$e(_objectSpread$e({}, op), {}, {
1472
1039
  properties: _newProperties,
1473
1040
  newProperties: null
1474
1041
  });
1475
1042
  } else if (_newProperties == null) {
1476
- return _objectSpread$c(_objectSpread$c({}, op), {}, {
1043
+ return _objectSpread$e(_objectSpread$e({}, op), {}, {
1477
1044
  properties: null,
1478
1045
  newProperties: _properties
1479
1046
  });
1480
1047
  } else {
1481
- return _objectSpread$c(_objectSpread$c({}, op), {}, {
1048
+ return _objectSpread$e(_objectSpread$e({}, op), {}, {
1482
1049
  properties: _newProperties,
1483
1050
  newProperties: _properties
1484
1051
  });
@@ -1486,7 +1053,7 @@ var Operation = {
1486
1053
  }
1487
1054
  case 'split_node':
1488
1055
  {
1489
- return _objectSpread$c(_objectSpread$c({}, op), {}, {
1056
+ return _objectSpread$e(_objectSpread$e({}, op), {}, {
1490
1057
  type: 'merge_node',
1491
1058
  path: Path.next(op.path)
1492
1059
  });
@@ -1495,6 +1062,315 @@ var Operation = {
1495
1062
  }
1496
1063
  };
1497
1064
 
1065
+ var isObject = value => typeof value === 'object' && value !== null;
1066
+
1067
+ /*
1068
+ Custom deep equal comparison for Slate nodes.
1069
+
1070
+ We don't need general purpose deep equality;
1071
+ Slate only supports plain values, Arrays, and nested objects.
1072
+ Complex values nested inside Arrays are not supported.
1073
+
1074
+ Slate objects are designed to be serialised, so
1075
+ missing keys are deliberately normalised to undefined.
1076
+ */
1077
+ var isDeepEqual = (node, another) => {
1078
+ for (var key in node) {
1079
+ var a = node[key];
1080
+ var b = another[key];
1081
+ if (Array.isArray(a) && Array.isArray(b)) {
1082
+ if (a.length !== b.length) return false;
1083
+ for (var i = 0; i < a.length; i++) {
1084
+ if (a[i] !== b[i]) return false;
1085
+ }
1086
+ } else if (isObject(a) && isObject(b)) {
1087
+ if (!isDeepEqual(a, b)) return false;
1088
+ } else if (a !== b) {
1089
+ return false;
1090
+ }
1091
+ }
1092
+ /*
1093
+ Deep object equality is only necessary in one direction; in the reverse direction
1094
+ we are only looking for keys that are missing.
1095
+ As above, undefined keys are normalised to missing.
1096
+ */
1097
+ for (var _key in another) {
1098
+ if (node[_key] === undefined && another[_key] !== undefined) {
1099
+ return false;
1100
+ }
1101
+ }
1102
+ return true;
1103
+ };
1104
+
1105
+ /**
1106
+ * Get the default location to insert content into the editor.
1107
+ * By default, use the selection as the target location. But if there is
1108
+ * no selection, insert at the end of the document since that is such a
1109
+ * common use case when inserting from a non-selected state.
1110
+ */
1111
+ var getDefaultInsertLocation = editor => {
1112
+ if (editor.selection) {
1113
+ return editor.selection;
1114
+ } else if (editor.children.length > 0) {
1115
+ return Editor.end(editor, []);
1116
+ } else {
1117
+ return [0];
1118
+ }
1119
+ };
1120
+
1121
+ var matchPath = (editor, path) => {
1122
+ var [node] = Editor.node(editor, path);
1123
+ return n => n === node;
1124
+ };
1125
+
1126
+ // Character (grapheme cluster) boundaries are determined according to
1127
+ // the default grapheme cluster boundary specification, extended grapheme clusters variant[1].
1128
+ //
1129
+ // References:
1130
+ //
1131
+ // [1] https://www.unicode.org/reports/tr29/#Default_Grapheme_Cluster_Table
1132
+ // [2] https://www.unicode.org/Public/UCD/latest/ucd/auxiliary/GraphemeBreakProperty.txt
1133
+ // [3] https://www.unicode.org/Public/UCD/latest/ucd/auxiliary/GraphemeBreakTest.html
1134
+ // [4] https://www.unicode.org/Public/UCD/latest/ucd/auxiliary/GraphemeBreakTest.txt
1135
+ /**
1136
+ * Get the distance to the end of the first character in a string of text.
1137
+ */
1138
+ var getCharacterDistance = function getCharacterDistance(str) {
1139
+ var isRTL = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
1140
+ var isLTR = !isRTL;
1141
+ var codepoints = isRTL ? codepointsIteratorRTL(str) : str;
1142
+ var left = CodepointType.None;
1143
+ var right = CodepointType.None;
1144
+ var distance = 0;
1145
+ // Evaluation of these conditions are deferred.
1146
+ var gb11 = null; // Is GB11 applicable?
1147
+ var gb12Or13 = null; // Is GB12 or GB13 applicable?
1148
+ for (var char of codepoints) {
1149
+ var code = char.codePointAt(0);
1150
+ if (!code) break;
1151
+ var type = getCodepointType(char, code);
1152
+ [left, right] = isLTR ? [right, type] : [type, left];
1153
+ if (intersects(left, CodepointType.ZWJ) && intersects(right, CodepointType.ExtPict)) {
1154
+ if (isLTR) {
1155
+ gb11 = endsWithEmojiZWJ(str.substring(0, distance));
1156
+ } else {
1157
+ gb11 = endsWithEmojiZWJ(str.substring(0, str.length - distance));
1158
+ }
1159
+ if (!gb11) break;
1160
+ }
1161
+ if (intersects(left, CodepointType.RI) && intersects(right, CodepointType.RI)) {
1162
+ if (gb12Or13 !== null) {
1163
+ gb12Or13 = !gb12Or13;
1164
+ } else {
1165
+ if (isLTR) {
1166
+ gb12Or13 = true;
1167
+ } else {
1168
+ gb12Or13 = endsWithOddNumberOfRIs(str.substring(0, str.length - distance));
1169
+ }
1170
+ }
1171
+ if (!gb12Or13) break;
1172
+ }
1173
+ if (left !== CodepointType.None && right !== CodepointType.None && isBoundaryPair(left, right)) {
1174
+ break;
1175
+ }
1176
+ distance += char.length;
1177
+ }
1178
+ return distance || 1;
1179
+ };
1180
+ var SPACE = /\s/;
1181
+ var PUNCTUATION = /[\u002B\u0021-\u0023\u0025-\u002A\u002C-\u002F\u003A\u003B\u003F\u0040\u005B-\u005D\u005F\u007B\u007D\u00A1\u00A7\u00AB\u00B6\u00B7\u00BB\u00BF\u037E\u0387\u055A-\u055F\u0589\u058A\u05BE\u05C0\u05C3\u05C6\u05F3\u05F4\u0609\u060A\u060C\u060D\u061B\u061E\u061F\u066A-\u066D\u06D4\u0700-\u070D\u07F7-\u07F9\u0830-\u083E\u085E\u0964\u0965\u0970\u0AF0\u0DF4\u0E4F\u0E5A\u0E5B\u0F04-\u0F12\u0F14\u0F3A-\u0F3D\u0F85\u0FD0-\u0FD4\u0FD9\u0FDA\u104A-\u104F\u10FB\u1360-\u1368\u1400\u166D\u166E\u169B\u169C\u16EB-\u16ED\u1735\u1736\u17D4-\u17D6\u17D8-\u17DA\u1800-\u180A\u1944\u1945\u1A1E\u1A1F\u1AA0-\u1AA6\u1AA8-\u1AAD\u1B5A-\u1B60\u1BFC-\u1BFF\u1C3B-\u1C3F\u1C7E\u1C7F\u1CC0-\u1CC7\u1CD3\u2010-\u2027\u2030-\u2043\u2045-\u2051\u2053-\u205E\u207D\u207E\u208D\u208E\u2329\u232A\u2768-\u2775\u27C5\u27C6\u27E6-\u27EF\u2983-\u2998\u29D8-\u29DB\u29FC\u29FD\u2CF9-\u2CFC\u2CFE\u2CFF\u2D70\u2E00-\u2E2E\u2E30-\u2E3B\u3001-\u3003\u3008-\u3011\u3014-\u301F\u3030\u303D\u30A0\u30FB\uA4FE\uA4FF\uA60D-\uA60F\uA673\uA67E\uA6F2-\uA6F7\uA874-\uA877\uA8CE\uA8CF\uA8F8-\uA8FA\uA92E\uA92F\uA95F\uA9C1-\uA9CD\uA9DE\uA9DF\uAA5C-\uAA5F\uAADE\uAADF\uAAF0\uAAF1\uABEB\uFD3E\uFD3F\uFE10-\uFE19\uFE30-\uFE52\uFE54-\uFE61\uFE63\uFE68\uFE6A\uFE6B\uFF01-\uFF03\uFF05-\uFF0A\uFF0C-\uFF0F\uFF1A\uFF1B\uFF1F\uFF20\uFF3B-\uFF3D\uFF3F\uFF5B\uFF5D\uFF5F-\uFF65]/;
1182
+ var CHAMELEON = /['\u2018\u2019]/;
1183
+ /**
1184
+ * Get the distance to the end of the first word in a string of text.
1185
+ */
1186
+ var getWordDistance = function getWordDistance(text) {
1187
+ var isRTL = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
1188
+ var dist = 0;
1189
+ var started = false;
1190
+ while (text.length > 0) {
1191
+ var charDist = getCharacterDistance(text, isRTL);
1192
+ var [char, remaining] = splitByCharacterDistance(text, charDist, isRTL);
1193
+ if (isWordCharacter(char, remaining, isRTL)) {
1194
+ started = true;
1195
+ dist += charDist;
1196
+ } else if (!started) {
1197
+ dist += charDist;
1198
+ } else {
1199
+ break;
1200
+ }
1201
+ text = remaining;
1202
+ }
1203
+ return dist;
1204
+ };
1205
+ /**
1206
+ * Split a string in two parts at a given distance starting from the end when
1207
+ * `isRTL` is set to `true`.
1208
+ */
1209
+ var splitByCharacterDistance = (str, dist, isRTL) => {
1210
+ if (isRTL) {
1211
+ var at = str.length - dist;
1212
+ return [str.slice(at, str.length), str.slice(0, at)];
1213
+ }
1214
+ return [str.slice(0, dist), str.slice(dist)];
1215
+ };
1216
+ /**
1217
+ * Check if a character is a word character. The `remaining` argument is used
1218
+ * because sometimes you must read subsequent characters to truly determine it.
1219
+ */
1220
+ var isWordCharacter = function isWordCharacter(char, remaining) {
1221
+ var isRTL = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
1222
+ if (SPACE.test(char)) {
1223
+ return false;
1224
+ }
1225
+ // Chameleons count as word characters as long as they're in a word, so
1226
+ // recurse to see if the next one is a word character or not.
1227
+ if (CHAMELEON.test(char)) {
1228
+ var charDist = getCharacterDistance(remaining, isRTL);
1229
+ var [nextChar, nextRemaining] = splitByCharacterDistance(remaining, charDist, isRTL);
1230
+ if (isWordCharacter(nextChar, nextRemaining, isRTL)) {
1231
+ return true;
1232
+ }
1233
+ }
1234
+ if (PUNCTUATION.test(char)) {
1235
+ return false;
1236
+ }
1237
+ return true;
1238
+ };
1239
+ /**
1240
+ * Iterate on codepoints from right to left.
1241
+ */
1242
+ var codepointsIteratorRTL = function* codepointsIteratorRTL(str) {
1243
+ var end = str.length - 1;
1244
+ for (var i = 0; i < str.length; i++) {
1245
+ var char1 = str.charAt(end - i);
1246
+ if (isLowSurrogate(char1.charCodeAt(0))) {
1247
+ var char2 = str.charAt(end - i - 1);
1248
+ if (isHighSurrogate(char2.charCodeAt(0))) {
1249
+ yield char2 + char1;
1250
+ i++;
1251
+ continue;
1252
+ }
1253
+ }
1254
+ yield char1;
1255
+ }
1256
+ };
1257
+ /**
1258
+ * Is `charCode` a high surrogate.
1259
+ *
1260
+ * https://en.wikipedia.org/wiki/Universal_Character_Set_characters#Surrogates
1261
+ */
1262
+ var isHighSurrogate = charCode => {
1263
+ return charCode >= 0xd800 && charCode <= 0xdbff;
1264
+ };
1265
+ /**
1266
+ * Is `charCode` a low surrogate.
1267
+ *
1268
+ * https://en.wikipedia.org/wiki/Universal_Character_Set_characters#Surrogates
1269
+ */
1270
+ var isLowSurrogate = charCode => {
1271
+ return charCode >= 0xdc00 && charCode <= 0xdfff;
1272
+ };
1273
+ var CodepointType;
1274
+ (function (CodepointType) {
1275
+ CodepointType[CodepointType["None"] = 0] = "None";
1276
+ CodepointType[CodepointType["Extend"] = 1] = "Extend";
1277
+ CodepointType[CodepointType["ZWJ"] = 2] = "ZWJ";
1278
+ CodepointType[CodepointType["RI"] = 4] = "RI";
1279
+ CodepointType[CodepointType["Prepend"] = 8] = "Prepend";
1280
+ CodepointType[CodepointType["SpacingMark"] = 16] = "SpacingMark";
1281
+ CodepointType[CodepointType["L"] = 32] = "L";
1282
+ CodepointType[CodepointType["V"] = 64] = "V";
1283
+ CodepointType[CodepointType["T"] = 128] = "T";
1284
+ CodepointType[CodepointType["LV"] = 256] = "LV";
1285
+ CodepointType[CodepointType["LVT"] = 512] = "LVT";
1286
+ CodepointType[CodepointType["ExtPict"] = 1024] = "ExtPict";
1287
+ CodepointType[CodepointType["Any"] = 2048] = "Any";
1288
+ })(CodepointType || (CodepointType = {}));
1289
+ var reExtend = /^(?:[\u0300-\u036F\u0483-\u0489\u0591-\u05BD\u05BF\u05C1\u05C2\u05C4\u05C5\u05C7\u0610-\u061A\u064B-\u065F\u0670\u06D6-\u06DC\u06DF-\u06E4\u06E7\u06E8\u06EA-\u06ED\u0711\u0730-\u074A\u07A6-\u07B0\u07EB-\u07F3\u07FD\u0816-\u0819\u081B-\u0823\u0825-\u0827\u0829-\u082D\u0859-\u085B\u0898-\u089F\u08CA-\u08E1\u08E3-\u0902\u093A\u093C\u0941-\u0948\u094D\u0951-\u0957\u0962\u0963\u0981\u09BC\u09BE\u09C1-\u09C4\u09CD\u09D7\u09E2\u09E3\u09FE\u0A01\u0A02\u0A3C\u0A41\u0A42\u0A47\u0A48\u0A4B-\u0A4D\u0A51\u0A70\u0A71\u0A75\u0A81\u0A82\u0ABC\u0AC1-\u0AC5\u0AC7\u0AC8\u0ACD\u0AE2\u0AE3\u0AFA-\u0AFF\u0B01\u0B3C\u0B3E\u0B3F\u0B41-\u0B44\u0B4D\u0B55-\u0B57\u0B62\u0B63\u0B82\u0BBE\u0BC0\u0BCD\u0BD7\u0C00\u0C04\u0C3C\u0C3E-\u0C40\u0C46-\u0C48\u0C4A-\u0C4D\u0C55\u0C56\u0C62\u0C63\u0C81\u0CBC\u0CBF\u0CC2\u0CC6\u0CCC\u0CCD\u0CD5\u0CD6\u0CE2\u0CE3\u0D00\u0D01\u0D3B\u0D3C\u0D3E\u0D41-\u0D44\u0D4D\u0D57\u0D62\u0D63\u0D81\u0DCA\u0DCF\u0DD2-\u0DD4\u0DD6\u0DDF\u0E31\u0E34-\u0E3A\u0E47-\u0E4E\u0EB1\u0EB4-\u0EBC\u0EC8-\u0ECE\u0F18\u0F19\u0F35\u0F37\u0F39\u0F71-\u0F7E\u0F80-\u0F84\u0F86\u0F87\u0F8D-\u0F97\u0F99-\u0FBC\u0FC6\u102D-\u1030\u1032-\u1037\u1039\u103A\u103D\u103E\u1058\u1059\u105E-\u1060\u1071-\u1074\u1082\u1085\u1086\u108D\u109D\u135D-\u135F\u1712-\u1714\u1732\u1733\u1752\u1753\u1772\u1773\u17B4\u17B5\u17B7-\u17BD\u17C6\u17C9-\u17D3\u17DD\u180B-\u180D\u180F\u1885\u1886\u18A9\u1920-\u1922\u1927\u1928\u1932\u1939-\u193B\u1A17\u1A18\u1A1B\u1A56\u1A58-\u1A5E\u1A60\u1A62\u1A65-\u1A6C\u1A73-\u1A7C\u1A7F\u1AB0-\u1ACE\u1B00-\u1B03\u1B34-\u1B3A\u1B3C\u1B42\u1B6B-\u1B73\u1B80\u1B81\u1BA2-\u1BA5\u1BA8\u1BA9\u1BAB-\u1BAD\u1BE6\u1BE8\u1BE9\u1BED\u1BEF-\u1BF1\u1C2C-\u1C33\u1C36\u1C37\u1CD0-\u1CD2\u1CD4-\u1CE0\u1CE2-\u1CE8\u1CED\u1CF4\u1CF8\u1CF9\u1DC0-\u1DFF\u200C\u20D0-\u20F0\u2CEF-\u2CF1\u2D7F\u2DE0-\u2DFF\u302A-\u302F\u3099\u309A\uA66F-\uA672\uA674-\uA67D\uA69E\uA69F\uA6F0\uA6F1\uA802\uA806\uA80B\uA825\uA826\uA82C\uA8C4\uA8C5\uA8E0-\uA8F1\uA8FF\uA926-\uA92D\uA947-\uA951\uA980-\uA982\uA9B3\uA9B6-\uA9B9\uA9BC\uA9BD\uA9E5\uAA29-\uAA2E\uAA31\uAA32\uAA35\uAA36\uAA43\uAA4C\uAA7C\uAAB0\uAAB2-\uAAB4\uAAB7\uAAB8\uAABE\uAABF\uAAC1\uAAEC\uAAED\uAAF6\uABE5\uABE8\uABED\uFB1E\uFE00-\uFE0F\uFE20-\uFE2F\uFF9E\uFF9F]|\uD800[\uDDFD\uDEE0\uDF76-\uDF7A]|\uD802[\uDE01-\uDE03\uDE05\uDE06\uDE0C-\uDE0F\uDE38-\uDE3A\uDE3F\uDEE5\uDEE6]|\uD803[\uDD24-\uDD27\uDEAB\uDEAC\uDEFD-\uDEFF\uDF46-\uDF50\uDF82-\uDF85]|\uD804[\uDC01\uDC38-\uDC46\uDC70\uDC73\uDC74\uDC7F-\uDC81\uDCB3-\uDCB6\uDCB9\uDCBA\uDCC2\uDD00-\uDD02\uDD27-\uDD2B\uDD2D-\uDD34\uDD73\uDD80\uDD81\uDDB6-\uDDBE\uDDC9-\uDDCC\uDDCF\uDE2F-\uDE31\uDE34\uDE36\uDE37\uDE3E\uDE41\uDEDF\uDEE3-\uDEEA\uDF00\uDF01\uDF3B\uDF3C\uDF3E\uDF40\uDF57\uDF66-\uDF6C\uDF70-\uDF74]|\uD805[\uDC38-\uDC3F\uDC42-\uDC44\uDC46\uDC5E\uDCB0\uDCB3-\uDCB8\uDCBA\uDCBD\uDCBF\uDCC0\uDCC2\uDCC3\uDDAF\uDDB2-\uDDB5\uDDBC\uDDBD\uDDBF\uDDC0\uDDDC\uDDDD\uDE33-\uDE3A\uDE3D\uDE3F\uDE40\uDEAB\uDEAD\uDEB0-\uDEB5\uDEB7\uDF1D-\uDF1F\uDF22-\uDF25\uDF27-\uDF2B]|\uD806[\uDC2F-\uDC37\uDC39\uDC3A\uDD30\uDD3B\uDD3C\uDD3E\uDD43\uDDD4-\uDDD7\uDDDA\uDDDB\uDDE0\uDE01-\uDE0A\uDE33-\uDE38\uDE3B-\uDE3E\uDE47\uDE51-\uDE56\uDE59-\uDE5B\uDE8A-\uDE96\uDE98\uDE99]|\uD807[\uDC30-\uDC36\uDC38-\uDC3D\uDC3F\uDC92-\uDCA7\uDCAA-\uDCB0\uDCB2\uDCB3\uDCB5\uDCB6\uDD31-\uDD36\uDD3A\uDD3C\uDD3D\uDD3F-\uDD45\uDD47\uDD90\uDD91\uDD95\uDD97\uDEF3\uDEF4\uDF00\uDF01\uDF36-\uDF3A\uDF40\uDF42]|\uD80D[\uDC40\uDC47-\uDC55]|\uD81A[\uDEF0-\uDEF4\uDF30-\uDF36]|\uD81B[\uDF4F\uDF8F-\uDF92\uDFE4]|\uD82F[\uDC9D\uDC9E]|\uD833[\uDF00-\uDF2D\uDF30-\uDF46]|\uD834[\uDD65\uDD67-\uDD69\uDD6E-\uDD72\uDD7B-\uDD82\uDD85-\uDD8B\uDDAA-\uDDAD\uDE42-\uDE44]|\uD836[\uDE00-\uDE36\uDE3B-\uDE6C\uDE75\uDE84\uDE9B-\uDE9F\uDEA1-\uDEAF]|\uD838[\uDC00-\uDC06\uDC08-\uDC18\uDC1B-\uDC21\uDC23\uDC24\uDC26-\uDC2A\uDC8F\uDD30-\uDD36\uDEAE\uDEEC-\uDEEF]|\uD839[\uDCEC-\uDCEF]|\uD83A[\uDCD0-\uDCD6\uDD44-\uDD4A]|\uD83C[\uDFFB-\uDFFF]|\uDB40[\uDC20-\uDC7F\uDD00-\uDDEF])$/;
1290
+ var rePrepend = /^(?:[\u0600-\u0605\u06DD\u070F\u0890\u0891\u08E2\u0D4E]|\uD804[\uDCBD\uDCCD\uDDC2\uDDC3]|\uD806[\uDD3F\uDD41\uDE3A\uDE84-\uDE89]|\uD807\uDD46)$/;
1291
+ var reSpacingMark = /^(?:[\u0903\u093B\u093E-\u0940\u0949-\u094C\u094E\u094F\u0982\u0983\u09BF\u09C0\u09C7\u09C8\u09CB\u09CC\u0A03\u0A3E-\u0A40\u0A83\u0ABE-\u0AC0\u0AC9\u0ACB\u0ACC\u0B02\u0B03\u0B40\u0B47\u0B48\u0B4B\u0B4C\u0BBF\u0BC1\u0BC2\u0BC6-\u0BC8\u0BCA-\u0BCC\u0C01-\u0C03\u0C41-\u0C44\u0C82\u0C83\u0CBE\u0CC0\u0CC1\u0CC3\u0CC4\u0CC7\u0CC8\u0CCA\u0CCB\u0D02\u0D03\u0D3F\u0D40\u0D46-\u0D48\u0D4A-\u0D4C\u0D82\u0D83\u0DD0\u0DD1\u0DD8-\u0DDE\u0DF2\u0DF3\u0E33\u0EB3\u0F3E\u0F3F\u0F7F\u1031\u103B\u103C\u1056\u1057\u1084\u1715\u1734\u17B6\u17BE-\u17C5\u17C7\u17C8\u1923-\u1926\u1929-\u192B\u1930\u1931\u1933-\u1938\u1A19\u1A1A\u1A55\u1A57\u1A6D-\u1A72\u1B04\u1B3B\u1B3D-\u1B41\u1B43\u1B44\u1B82\u1BA1\u1BA6\u1BA7\u1BAA\u1BE7\u1BEA-\u1BEC\u1BEE\u1BF2\u1BF3\u1C24-\u1C2B\u1C34\u1C35\u1CE1\u1CF7\uA823\uA824\uA827\uA880\uA881\uA8B4-\uA8C3\uA952\uA953\uA983\uA9B4\uA9B5\uA9BA\uA9BB\uA9BE-\uA9C0\uAA2F\uAA30\uAA33\uAA34\uAA4D\uAAEB\uAAEE\uAAEF\uAAF5\uABE3\uABE4\uABE6\uABE7\uABE9\uABEA\uABEC]|\uD804[\uDC00\uDC02\uDC82\uDCB0-\uDCB2\uDCB7\uDCB8\uDD2C\uDD45\uDD46\uDD82\uDDB3-\uDDB5\uDDBF\uDDC0\uDDCE\uDE2C-\uDE2E\uDE32\uDE33\uDE35\uDEE0-\uDEE2\uDF02\uDF03\uDF3F\uDF41-\uDF44\uDF47\uDF48\uDF4B-\uDF4D\uDF62\uDF63]|\uD805[\uDC35-\uDC37\uDC40\uDC41\uDC45\uDCB1\uDCB2\uDCB9\uDCBB\uDCBC\uDCBE\uDCC1\uDDB0\uDDB1\uDDB8-\uDDBB\uDDBE\uDE30-\uDE32\uDE3B\uDE3C\uDE3E\uDEAC\uDEAE\uDEAF\uDEB6\uDF26]|\uD806[\uDC2C-\uDC2E\uDC38\uDD31-\uDD35\uDD37\uDD38\uDD3D\uDD40\uDD42\uDDD1-\uDDD3\uDDDC-\uDDDF\uDDE4\uDE39\uDE57\uDE58\uDE97]|\uD807[\uDC2F\uDC3E\uDCA9\uDCB1\uDCB4\uDD8A-\uDD8E\uDD93\uDD94\uDD96\uDEF5\uDEF6]|\uD81B[\uDF51-\uDF87\uDFF0\uDFF1]|\uD834[\uDD66\uDD6D])$/;
1292
+ var reL = /^[\u1100-\u115F\uA960-\uA97C]$/;
1293
+ var reV = /^[\u1160-\u11A7\uD7B0-\uD7C6]$/;
1294
+ var reT = /^[\u11A8-\u11FF\uD7CB-\uD7FB]$/;
1295
+ var reLV = /^[\uAC00\uAC1C\uAC38\uAC54\uAC70\uAC8C\uACA8\uACC4\uACE0\uACFC\uAD18\uAD34\uAD50\uAD6C\uAD88\uADA4\uADC0\uADDC\uADF8\uAE14\uAE30\uAE4C\uAE68\uAE84\uAEA0\uAEBC\uAED8\uAEF4\uAF10\uAF2C\uAF48\uAF64\uAF80\uAF9C\uAFB8\uAFD4\uAFF0\uB00C\uB028\uB044\uB060\uB07C\uB098\uB0B4\uB0D0\uB0EC\uB108\uB124\uB140\uB15C\uB178\uB194\uB1B0\uB1CC\uB1E8\uB204\uB220\uB23C\uB258\uB274\uB290\uB2AC\uB2C8\uB2E4\uB300\uB31C\uB338\uB354\uB370\uB38C\uB3A8\uB3C4\uB3E0\uB3FC\uB418\uB434\uB450\uB46C\uB488\uB4A4\uB4C0\uB4DC\uB4F8\uB514\uB530\uB54C\uB568\uB584\uB5A0\uB5BC\uB5D8\uB5F4\uB610\uB62C\uB648\uB664\uB680\uB69C\uB6B8\uB6D4\uB6F0\uB70C\uB728\uB744\uB760\uB77C\uB798\uB7B4\uB7D0\uB7EC\uB808\uB824\uB840\uB85C\uB878\uB894\uB8B0\uB8CC\uB8E8\uB904\uB920\uB93C\uB958\uB974\uB990\uB9AC\uB9C8\uB9E4\uBA00\uBA1C\uBA38\uBA54\uBA70\uBA8C\uBAA8\uBAC4\uBAE0\uBAFC\uBB18\uBB34\uBB50\uBB6C\uBB88\uBBA4\uBBC0\uBBDC\uBBF8\uBC14\uBC30\uBC4C\uBC68\uBC84\uBCA0\uBCBC\uBCD8\uBCF4\uBD10\uBD2C\uBD48\uBD64\uBD80\uBD9C\uBDB8\uBDD4\uBDF0\uBE0C\uBE28\uBE44\uBE60\uBE7C\uBE98\uBEB4\uBED0\uBEEC\uBF08\uBF24\uBF40\uBF5C\uBF78\uBF94\uBFB0\uBFCC\uBFE8\uC004\uC020\uC03C\uC058\uC074\uC090\uC0AC\uC0C8\uC0E4\uC100\uC11C\uC138\uC154\uC170\uC18C\uC1A8\uC1C4\uC1E0\uC1FC\uC218\uC234\uC250\uC26C\uC288\uC2A4\uC2C0\uC2DC\uC2F8\uC314\uC330\uC34C\uC368\uC384\uC3A0\uC3BC\uC3D8\uC3F4\uC410\uC42C\uC448\uC464\uC480\uC49C\uC4B8\uC4D4\uC4F0\uC50C\uC528\uC544\uC560\uC57C\uC598\uC5B4\uC5D0\uC5EC\uC608\uC624\uC640\uC65C\uC678\uC694\uC6B0\uC6CC\uC6E8\uC704\uC720\uC73C\uC758\uC774\uC790\uC7AC\uC7C8\uC7E4\uC800\uC81C\uC838\uC854\uC870\uC88C\uC8A8\uC8C4\uC8E0\uC8FC\uC918\uC934\uC950\uC96C\uC988\uC9A4\uC9C0\uC9DC\uC9F8\uCA14\uCA30\uCA4C\uCA68\uCA84\uCAA0\uCABC\uCAD8\uCAF4\uCB10\uCB2C\uCB48\uCB64\uCB80\uCB9C\uCBB8\uCBD4\uCBF0\uCC0C\uCC28\uCC44\uCC60\uCC7C\uCC98\uCCB4\uCCD0\uCCEC\uCD08\uCD24\uCD40\uCD5C\uCD78\uCD94\uCDB0\uCDCC\uCDE8\uCE04\uCE20\uCE3C\uCE58\uCE74\uCE90\uCEAC\uCEC8\uCEE4\uCF00\uCF1C\uCF38\uCF54\uCF70\uCF8C\uCFA8\uCFC4\uCFE0\uCFFC\uD018\uD034\uD050\uD06C\uD088\uD0A4\uD0C0\uD0DC\uD0F8\uD114\uD130\uD14C\uD168\uD184\uD1A0\uD1BC\uD1D8\uD1F4\uD210\uD22C\uD248\uD264\uD280\uD29C\uD2B8\uD2D4\uD2F0\uD30C\uD328\uD344\uD360\uD37C\uD398\uD3B4\uD3D0\uD3EC\uD408\uD424\uD440\uD45C\uD478\uD494\uD4B0\uD4CC\uD4E8\uD504\uD520\uD53C\uD558\uD574\uD590\uD5AC\uD5C8\uD5E4\uD600\uD61C\uD638\uD654\uD670\uD68C\uD6A8\uD6C4\uD6E0\uD6FC\uD718\uD734\uD750\uD76C\uD788]$/;
1296
+ var reLVT = /^[\uAC01-\uAC1B\uAC1D-\uAC37\uAC39-\uAC53\uAC55-\uAC6F\uAC71-\uAC8B\uAC8D-\uACA7\uACA9-\uACC3\uACC5-\uACDF\uACE1-\uACFB\uACFD-\uAD17\uAD19-\uAD33\uAD35-\uAD4F\uAD51-\uAD6B\uAD6D-\uAD87\uAD89-\uADA3\uADA5-\uADBF\uADC1-\uADDB\uADDD-\uADF7\uADF9-\uAE13\uAE15-\uAE2F\uAE31-\uAE4B\uAE4D-\uAE67\uAE69-\uAE83\uAE85-\uAE9F\uAEA1-\uAEBB\uAEBD-\uAED7\uAED9-\uAEF3\uAEF5-\uAF0F\uAF11-\uAF2B\uAF2D-\uAF47\uAF49-\uAF63\uAF65-\uAF7F\uAF81-\uAF9B\uAF9D-\uAFB7\uAFB9-\uAFD3\uAFD5-\uAFEF\uAFF1-\uB00B\uB00D-\uB027\uB029-\uB043\uB045-\uB05F\uB061-\uB07B\uB07D-\uB097\uB099-\uB0B3\uB0B5-\uB0CF\uB0D1-\uB0EB\uB0ED-\uB107\uB109-\uB123\uB125-\uB13F\uB141-\uB15B\uB15D-\uB177\uB179-\uB193\uB195-\uB1AF\uB1B1-\uB1CB\uB1CD-\uB1E7\uB1E9-\uB203\uB205-\uB21F\uB221-\uB23B\uB23D-\uB257\uB259-\uB273\uB275-\uB28F\uB291-\uB2AB\uB2AD-\uB2C7\uB2C9-\uB2E3\uB2E5-\uB2FF\uB301-\uB31B\uB31D-\uB337\uB339-\uB353\uB355-\uB36F\uB371-\uB38B\uB38D-\uB3A7\uB3A9-\uB3C3\uB3C5-\uB3DF\uB3E1-\uB3FB\uB3FD-\uB417\uB419-\uB433\uB435-\uB44F\uB451-\uB46B\uB46D-\uB487\uB489-\uB4A3\uB4A5-\uB4BF\uB4C1-\uB4DB\uB4DD-\uB4F7\uB4F9-\uB513\uB515-\uB52F\uB531-\uB54B\uB54D-\uB567\uB569-\uB583\uB585-\uB59F\uB5A1-\uB5BB\uB5BD-\uB5D7\uB5D9-\uB5F3\uB5F5-\uB60F\uB611-\uB62B\uB62D-\uB647\uB649-\uB663\uB665-\uB67F\uB681-\uB69B\uB69D-\uB6B7\uB6B9-\uB6D3\uB6D5-\uB6EF\uB6F1-\uB70B\uB70D-\uB727\uB729-\uB743\uB745-\uB75F\uB761-\uB77B\uB77D-\uB797\uB799-\uB7B3\uB7B5-\uB7CF\uB7D1-\uB7EB\uB7ED-\uB807\uB809-\uB823\uB825-\uB83F\uB841-\uB85B\uB85D-\uB877\uB879-\uB893\uB895-\uB8AF\uB8B1-\uB8CB\uB8CD-\uB8E7\uB8E9-\uB903\uB905-\uB91F\uB921-\uB93B\uB93D-\uB957\uB959-\uB973\uB975-\uB98F\uB991-\uB9AB\uB9AD-\uB9C7\uB9C9-\uB9E3\uB9E5-\uB9FF\uBA01-\uBA1B\uBA1D-\uBA37\uBA39-\uBA53\uBA55-\uBA6F\uBA71-\uBA8B\uBA8D-\uBAA7\uBAA9-\uBAC3\uBAC5-\uBADF\uBAE1-\uBAFB\uBAFD-\uBB17\uBB19-\uBB33\uBB35-\uBB4F\uBB51-\uBB6B\uBB6D-\uBB87\uBB89-\uBBA3\uBBA5-\uBBBF\uBBC1-\uBBDB\uBBDD-\uBBF7\uBBF9-\uBC13\uBC15-\uBC2F\uBC31-\uBC4B\uBC4D-\uBC67\uBC69-\uBC83\uBC85-\uBC9F\uBCA1-\uBCBB\uBCBD-\uBCD7\uBCD9-\uBCF3\uBCF5-\uBD0F\uBD11-\uBD2B\uBD2D-\uBD47\uBD49-\uBD63\uBD65-\uBD7F\uBD81-\uBD9B\uBD9D-\uBDB7\uBDB9-\uBDD3\uBDD5-\uBDEF\uBDF1-\uBE0B\uBE0D-\uBE27\uBE29-\uBE43\uBE45-\uBE5F\uBE61-\uBE7B\uBE7D-\uBE97\uBE99-\uBEB3\uBEB5-\uBECF\uBED1-\uBEEB\uBEED-\uBF07\uBF09-\uBF23\uBF25-\uBF3F\uBF41-\uBF5B\uBF5D-\uBF77\uBF79-\uBF93\uBF95-\uBFAF\uBFB1-\uBFCB\uBFCD-\uBFE7\uBFE9-\uC003\uC005-\uC01F\uC021-\uC03B\uC03D-\uC057\uC059-\uC073\uC075-\uC08F\uC091-\uC0AB\uC0AD-\uC0C7\uC0C9-\uC0E3\uC0E5-\uC0FF\uC101-\uC11B\uC11D-\uC137\uC139-\uC153\uC155-\uC16F\uC171-\uC18B\uC18D-\uC1A7\uC1A9-\uC1C3\uC1C5-\uC1DF\uC1E1-\uC1FB\uC1FD-\uC217\uC219-\uC233\uC235-\uC24F\uC251-\uC26B\uC26D-\uC287\uC289-\uC2A3\uC2A5-\uC2BF\uC2C1-\uC2DB\uC2DD-\uC2F7\uC2F9-\uC313\uC315-\uC32F\uC331-\uC34B\uC34D-\uC367\uC369-\uC383\uC385-\uC39F\uC3A1-\uC3BB\uC3BD-\uC3D7\uC3D9-\uC3F3\uC3F5-\uC40F\uC411-\uC42B\uC42D-\uC447\uC449-\uC463\uC465-\uC47F\uC481-\uC49B\uC49D-\uC4B7\uC4B9-\uC4D3\uC4D5-\uC4EF\uC4F1-\uC50B\uC50D-\uC527\uC529-\uC543\uC545-\uC55F\uC561-\uC57B\uC57D-\uC597\uC599-\uC5B3\uC5B5-\uC5CF\uC5D1-\uC5EB\uC5ED-\uC607\uC609-\uC623\uC625-\uC63F\uC641-\uC65B\uC65D-\uC677\uC679-\uC693\uC695-\uC6AF\uC6B1-\uC6CB\uC6CD-\uC6E7\uC6E9-\uC703\uC705-\uC71F\uC721-\uC73B\uC73D-\uC757\uC759-\uC773\uC775-\uC78F\uC791-\uC7AB\uC7AD-\uC7C7\uC7C9-\uC7E3\uC7E5-\uC7FF\uC801-\uC81B\uC81D-\uC837\uC839-\uC853\uC855-\uC86F\uC871-\uC88B\uC88D-\uC8A7\uC8A9-\uC8C3\uC8C5-\uC8DF\uC8E1-\uC8FB\uC8FD-\uC917\uC919-\uC933\uC935-\uC94F\uC951-\uC96B\uC96D-\uC987\uC989-\uC9A3\uC9A5-\uC9BF\uC9C1-\uC9DB\uC9DD-\uC9F7\uC9F9-\uCA13\uCA15-\uCA2F\uCA31-\uCA4B\uCA4D-\uCA67\uCA69-\uCA83\uCA85-\uCA9F\uCAA1-\uCABB\uCABD-\uCAD7\uCAD9-\uCAF3\uCAF5-\uCB0F\uCB11-\uCB2B\uCB2D-\uCB47\uCB49-\uCB63\uCB65-\uCB7F\uCB81-\uCB9B\uCB9D-\uCBB7\uCBB9-\uCBD3\uCBD5-\uCBEF\uCBF1-\uCC0B\uCC0D-\uCC27\uCC29-\uCC43\uCC45-\uCC5F\uCC61-\uCC7B\uCC7D-\uCC97\uCC99-\uCCB3\uCCB5-\uCCCF\uCCD1-\uCCEB\uCCED-\uCD07\uCD09-\uCD23\uCD25-\uCD3F\uCD41-\uCD5B\uCD5D-\uCD77\uCD79-\uCD93\uCD95-\uCDAF\uCDB1-\uCDCB\uCDCD-\uCDE7\uCDE9-\uCE03\uCE05-\uCE1F\uCE21-\uCE3B\uCE3D-\uCE57\uCE59-\uCE73\uCE75-\uCE8F\uCE91-\uCEAB\uCEAD-\uCEC7\uCEC9-\uCEE3\uCEE5-\uCEFF\uCF01-\uCF1B\uCF1D-\uCF37\uCF39-\uCF53\uCF55-\uCF6F\uCF71-\uCF8B\uCF8D-\uCFA7\uCFA9-\uCFC3\uCFC5-\uCFDF\uCFE1-\uCFFB\uCFFD-\uD017\uD019-\uD033\uD035-\uD04F\uD051-\uD06B\uD06D-\uD087\uD089-\uD0A3\uD0A5-\uD0BF\uD0C1-\uD0DB\uD0DD-\uD0F7\uD0F9-\uD113\uD115-\uD12F\uD131-\uD14B\uD14D-\uD167\uD169-\uD183\uD185-\uD19F\uD1A1-\uD1BB\uD1BD-\uD1D7\uD1D9-\uD1F3\uD1F5-\uD20F\uD211-\uD22B\uD22D-\uD247\uD249-\uD263\uD265-\uD27F\uD281-\uD29B\uD29D-\uD2B7\uD2B9-\uD2D3\uD2D5-\uD2EF\uD2F1-\uD30B\uD30D-\uD327\uD329-\uD343\uD345-\uD35F\uD361-\uD37B\uD37D-\uD397\uD399-\uD3B3\uD3B5-\uD3CF\uD3D1-\uD3EB\uD3ED-\uD407\uD409-\uD423\uD425-\uD43F\uD441-\uD45B\uD45D-\uD477\uD479-\uD493\uD495-\uD4AF\uD4B1-\uD4CB\uD4CD-\uD4E7\uD4E9-\uD503\uD505-\uD51F\uD521-\uD53B\uD53D-\uD557\uD559-\uD573\uD575-\uD58F\uD591-\uD5AB\uD5AD-\uD5C7\uD5C9-\uD5E3\uD5E5-\uD5FF\uD601-\uD61B\uD61D-\uD637\uD639-\uD653\uD655-\uD66F\uD671-\uD68B\uD68D-\uD6A7\uD6A9-\uD6C3\uD6C5-\uD6DF\uD6E1-\uD6FB\uD6FD-\uD717\uD719-\uD733\uD735-\uD74F\uD751-\uD76B\uD76D-\uD787\uD789-\uD7A3]$/;
1297
+ var reExtPict = /^(?:[\xA9\xAE\u203C\u2049\u2122\u2139\u2194-\u2199\u21A9\u21AA\u231A\u231B\u2328\u2388\u23CF\u23E9-\u23F3\u23F8-\u23FA\u24C2\u25AA\u25AB\u25B6\u25C0\u25FB-\u25FE\u2600-\u2605\u2607-\u2612\u2614-\u2685\u2690-\u2705\u2708-\u2712\u2714\u2716\u271D\u2721\u2728\u2733\u2734\u2744\u2747\u274C\u274E\u2753-\u2755\u2757\u2763-\u2767\u2795-\u2797\u27A1\u27B0\u27BF\u2934\u2935\u2B05-\u2B07\u2B1B\u2B1C\u2B50\u2B55\u3030\u303D\u3297\u3299]|\uD83C[\uDC00-\uDCFF\uDD0D-\uDD0F\uDD2F\uDD6C-\uDD71\uDD7E\uDD7F\uDD8E\uDD91-\uDD9A\uDDAD-\uDDE5\uDE01-\uDE0F\uDE1A\uDE2F\uDE32-\uDE3A\uDE3C-\uDE3F\uDE49-\uDFFA]|\uD83D[\uDC00-\uDD3D\uDD46-\uDE4F\uDE80-\uDEFF\uDF74-\uDF7F\uDFD5-\uDFFF]|\uD83E[\uDC0C-\uDC0F\uDC48-\uDC4F\uDC5A-\uDC5F\uDC88-\uDC8F\uDCAE-\uDCFF\uDD0C-\uDD3A\uDD3C-\uDD45\uDD47-\uDEFF]|\uD83F[\uDC00-\uDFFD])$/;
1298
+ var getCodepointType = (char, code) => {
1299
+ var type = CodepointType.Any;
1300
+ if (char.search(reExtend) !== -1) {
1301
+ type |= CodepointType.Extend;
1302
+ }
1303
+ if (code === 0x200d) {
1304
+ type |= CodepointType.ZWJ;
1305
+ }
1306
+ if (code >= 0x1f1e6 && code <= 0x1f1ff) {
1307
+ type |= CodepointType.RI;
1308
+ }
1309
+ if (char.search(rePrepend) !== -1) {
1310
+ type |= CodepointType.Prepend;
1311
+ }
1312
+ if (char.search(reSpacingMark) !== -1) {
1313
+ type |= CodepointType.SpacingMark;
1314
+ }
1315
+ if (char.search(reL) !== -1) {
1316
+ type |= CodepointType.L;
1317
+ }
1318
+ if (char.search(reV) !== -1) {
1319
+ type |= CodepointType.V;
1320
+ }
1321
+ if (char.search(reT) !== -1) {
1322
+ type |= CodepointType.T;
1323
+ }
1324
+ if (char.search(reLV) !== -1) {
1325
+ type |= CodepointType.LV;
1326
+ }
1327
+ if (char.search(reLVT) !== -1) {
1328
+ type |= CodepointType.LVT;
1329
+ }
1330
+ if (char.search(reExtPict) !== -1) {
1331
+ type |= CodepointType.ExtPict;
1332
+ }
1333
+ return type;
1334
+ };
1335
+ function intersects(x, y) {
1336
+ return (x & y) !== 0;
1337
+ }
1338
+ var NonBoundaryPairs = [
1339
+ // GB6
1340
+ [CodepointType.L, CodepointType.L | CodepointType.V | CodepointType.LV | CodepointType.LVT],
1341
+ // GB7
1342
+ [CodepointType.LV | CodepointType.V, CodepointType.V | CodepointType.T],
1343
+ // GB8
1344
+ [CodepointType.LVT | CodepointType.T, CodepointType.T],
1345
+ // GB9
1346
+ [CodepointType.Any, CodepointType.Extend | CodepointType.ZWJ],
1347
+ // GB9a
1348
+ [CodepointType.Any, CodepointType.SpacingMark],
1349
+ // GB9b
1350
+ [CodepointType.Prepend, CodepointType.Any],
1351
+ // GB11
1352
+ [CodepointType.ZWJ, CodepointType.ExtPict],
1353
+ // GB12 and GB13
1354
+ [CodepointType.RI, CodepointType.RI]];
1355
+ function isBoundaryPair(left, right) {
1356
+ return NonBoundaryPairs.findIndex(r => intersects(left, r[0]) && intersects(right, r[1])) === -1;
1357
+ }
1358
+ var endingEmojiZWJ = /(?:[\xA9\xAE\u203C\u2049\u2122\u2139\u2194-\u2199\u21A9\u21AA\u231A\u231B\u2328\u2388\u23CF\u23E9-\u23F3\u23F8-\u23FA\u24C2\u25AA\u25AB\u25B6\u25C0\u25FB-\u25FE\u2600-\u2605\u2607-\u2612\u2614-\u2685\u2690-\u2705\u2708-\u2712\u2714\u2716\u271D\u2721\u2728\u2733\u2734\u2744\u2747\u274C\u274E\u2753-\u2755\u2757\u2763-\u2767\u2795-\u2797\u27A1\u27B0\u27BF\u2934\u2935\u2B05-\u2B07\u2B1B\u2B1C\u2B50\u2B55\u3030\u303D\u3297\u3299]|\uD83C[\uDC00-\uDCFF\uDD0D-\uDD0F\uDD2F\uDD6C-\uDD71\uDD7E\uDD7F\uDD8E\uDD91-\uDD9A\uDDAD-\uDDE5\uDE01-\uDE0F\uDE1A\uDE2F\uDE32-\uDE3A\uDE3C-\uDE3F\uDE49-\uDFFA]|\uD83D[\uDC00-\uDD3D\uDD46-\uDE4F\uDE80-\uDEFF\uDF74-\uDF7F\uDFD5-\uDFFF]|\uD83E[\uDC0C-\uDC0F\uDC48-\uDC4F\uDC5A-\uDC5F\uDC88-\uDC8F\uDCAE-\uDCFF\uDD0C-\uDD3A\uDD3C-\uDD45\uDD47-\uDEFF]|\uD83F[\uDC00-\uDFFD])(?:[\u0300-\u036F\u0483-\u0489\u0591-\u05BD\u05BF\u05C1\u05C2\u05C4\u05C5\u05C7\u0610-\u061A\u064B-\u065F\u0670\u06D6-\u06DC\u06DF-\u06E4\u06E7\u06E8\u06EA-\u06ED\u0711\u0730-\u074A\u07A6-\u07B0\u07EB-\u07F3\u07FD\u0816-\u0819\u081B-\u0823\u0825-\u0827\u0829-\u082D\u0859-\u085B\u0898-\u089F\u08CA-\u08E1\u08E3-\u0902\u093A\u093C\u0941-\u0948\u094D\u0951-\u0957\u0962\u0963\u0981\u09BC\u09BE\u09C1-\u09C4\u09CD\u09D7\u09E2\u09E3\u09FE\u0A01\u0A02\u0A3C\u0A41\u0A42\u0A47\u0A48\u0A4B-\u0A4D\u0A51\u0A70\u0A71\u0A75\u0A81\u0A82\u0ABC\u0AC1-\u0AC5\u0AC7\u0AC8\u0ACD\u0AE2\u0AE3\u0AFA-\u0AFF\u0B01\u0B3C\u0B3E\u0B3F\u0B41-\u0B44\u0B4D\u0B55-\u0B57\u0B62\u0B63\u0B82\u0BBE\u0BC0\u0BCD\u0BD7\u0C00\u0C04\u0C3C\u0C3E-\u0C40\u0C46-\u0C48\u0C4A-\u0C4D\u0C55\u0C56\u0C62\u0C63\u0C81\u0CBC\u0CBF\u0CC2\u0CC6\u0CCC\u0CCD\u0CD5\u0CD6\u0CE2\u0CE3\u0D00\u0D01\u0D3B\u0D3C\u0D3E\u0D41-\u0D44\u0D4D\u0D57\u0D62\u0D63\u0D81\u0DCA\u0DCF\u0DD2-\u0DD4\u0DD6\u0DDF\u0E31\u0E34-\u0E3A\u0E47-\u0E4E\u0EB1\u0EB4-\u0EBC\u0EC8-\u0ECE\u0F18\u0F19\u0F35\u0F37\u0F39\u0F71-\u0F7E\u0F80-\u0F84\u0F86\u0F87\u0F8D-\u0F97\u0F99-\u0FBC\u0FC6\u102D-\u1030\u1032-\u1037\u1039\u103A\u103D\u103E\u1058\u1059\u105E-\u1060\u1071-\u1074\u1082\u1085\u1086\u108D\u109D\u135D-\u135F\u1712-\u1714\u1732\u1733\u1752\u1753\u1772\u1773\u17B4\u17B5\u17B7-\u17BD\u17C6\u17C9-\u17D3\u17DD\u180B-\u180D\u180F\u1885\u1886\u18A9\u1920-\u1922\u1927\u1928\u1932\u1939-\u193B\u1A17\u1A18\u1A1B\u1A56\u1A58-\u1A5E\u1A60\u1A62\u1A65-\u1A6C\u1A73-\u1A7C\u1A7F\u1AB0-\u1ACE\u1B00-\u1B03\u1B34-\u1B3A\u1B3C\u1B42\u1B6B-\u1B73\u1B80\u1B81\u1BA2-\u1BA5\u1BA8\u1BA9\u1BAB-\u1BAD\u1BE6\u1BE8\u1BE9\u1BED\u1BEF-\u1BF1\u1C2C-\u1C33\u1C36\u1C37\u1CD0-\u1CD2\u1CD4-\u1CE0\u1CE2-\u1CE8\u1CED\u1CF4\u1CF8\u1CF9\u1DC0-\u1DFF\u200C\u20D0-\u20F0\u2CEF-\u2CF1\u2D7F\u2DE0-\u2DFF\u302A-\u302F\u3099\u309A\uA66F-\uA672\uA674-\uA67D\uA69E\uA69F\uA6F0\uA6F1\uA802\uA806\uA80B\uA825\uA826\uA82C\uA8C4\uA8C5\uA8E0-\uA8F1\uA8FF\uA926-\uA92D\uA947-\uA951\uA980-\uA982\uA9B3\uA9B6-\uA9B9\uA9BC\uA9BD\uA9E5\uAA29-\uAA2E\uAA31\uAA32\uAA35\uAA36\uAA43\uAA4C\uAA7C\uAAB0\uAAB2-\uAAB4\uAAB7\uAAB8\uAABE\uAABF\uAAC1\uAAEC\uAAED\uAAF6\uABE5\uABE8\uABED\uFB1E\uFE00-\uFE0F\uFE20-\uFE2F\uFF9E\uFF9F]|\uD800[\uDDFD\uDEE0\uDF76-\uDF7A]|\uD802[\uDE01-\uDE03\uDE05\uDE06\uDE0C-\uDE0F\uDE38-\uDE3A\uDE3F\uDEE5\uDEE6]|\uD803[\uDD24-\uDD27\uDEAB\uDEAC\uDEFD-\uDEFF\uDF46-\uDF50\uDF82-\uDF85]|\uD804[\uDC01\uDC38-\uDC46\uDC70\uDC73\uDC74\uDC7F-\uDC81\uDCB3-\uDCB6\uDCB9\uDCBA\uDCC2\uDD00-\uDD02\uDD27-\uDD2B\uDD2D-\uDD34\uDD73\uDD80\uDD81\uDDB6-\uDDBE\uDDC9-\uDDCC\uDDCF\uDE2F-\uDE31\uDE34\uDE36\uDE37\uDE3E\uDE41\uDEDF\uDEE3-\uDEEA\uDF00\uDF01\uDF3B\uDF3C\uDF3E\uDF40\uDF57\uDF66-\uDF6C\uDF70-\uDF74]|\uD805[\uDC38-\uDC3F\uDC42-\uDC44\uDC46\uDC5E\uDCB0\uDCB3-\uDCB8\uDCBA\uDCBD\uDCBF\uDCC0\uDCC2\uDCC3\uDDAF\uDDB2-\uDDB5\uDDBC\uDDBD\uDDBF\uDDC0\uDDDC\uDDDD\uDE33-\uDE3A\uDE3D\uDE3F\uDE40\uDEAB\uDEAD\uDEB0-\uDEB5\uDEB7\uDF1D-\uDF1F\uDF22-\uDF25\uDF27-\uDF2B]|\uD806[\uDC2F-\uDC37\uDC39\uDC3A\uDD30\uDD3B\uDD3C\uDD3E\uDD43\uDDD4-\uDDD7\uDDDA\uDDDB\uDDE0\uDE01-\uDE0A\uDE33-\uDE38\uDE3B-\uDE3E\uDE47\uDE51-\uDE56\uDE59-\uDE5B\uDE8A-\uDE96\uDE98\uDE99]|\uD807[\uDC30-\uDC36\uDC38-\uDC3D\uDC3F\uDC92-\uDCA7\uDCAA-\uDCB0\uDCB2\uDCB3\uDCB5\uDCB6\uDD31-\uDD36\uDD3A\uDD3C\uDD3D\uDD3F-\uDD45\uDD47\uDD90\uDD91\uDD95\uDD97\uDEF3\uDEF4\uDF00\uDF01\uDF36-\uDF3A\uDF40\uDF42]|\uD80D[\uDC40\uDC47-\uDC55]|\uD81A[\uDEF0-\uDEF4\uDF30-\uDF36]|\uD81B[\uDF4F\uDF8F-\uDF92\uDFE4]|\uD82F[\uDC9D\uDC9E]|\uD833[\uDF00-\uDF2D\uDF30-\uDF46]|\uD834[\uDD65\uDD67-\uDD69\uDD6E-\uDD72\uDD7B-\uDD82\uDD85-\uDD8B\uDDAA-\uDDAD\uDE42-\uDE44]|\uD836[\uDE00-\uDE36\uDE3B-\uDE6C\uDE75\uDE84\uDE9B-\uDE9F\uDEA1-\uDEAF]|\uD838[\uDC00-\uDC06\uDC08-\uDC18\uDC1B-\uDC21\uDC23\uDC24\uDC26-\uDC2A\uDC8F\uDD30-\uDD36\uDEAE\uDEEC-\uDEEF]|\uD839[\uDCEC-\uDCEF]|\uD83A[\uDCD0-\uDCD6\uDD44-\uDD4A]|\uD83C[\uDFFB-\uDFFF]|\uDB40[\uDC20-\uDC7F\uDD00-\uDDEF])*\u200D$/;
1359
+ var endsWithEmojiZWJ = str => {
1360
+ return str.search(endingEmojiZWJ) !== -1;
1361
+ };
1362
+ var endingRIs = /(?:\uD83C[\uDDE6-\uDDFF])+$/g;
1363
+ var endsWithOddNumberOfRIs = str => {
1364
+ var match = str.match(endingRIs);
1365
+ if (match === null) {
1366
+ return false;
1367
+ } else {
1368
+ // A RI is represented by a surrogate pair.
1369
+ var numRIs = match[0].length / 2;
1370
+ return numRIs % 2 === 1;
1371
+ }
1372
+ };
1373
+
1498
1374
  var isEditor = function isEditor(value) {
1499
1375
  var {
1500
1376
  deep = false
@@ -1712,8 +1588,8 @@ var Span = {
1712
1588
  }
1713
1589
  };
1714
1590
 
1715
- function ownKeys$b(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
1716
- function _objectSpread$b(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$b(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$b(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
1591
+ function ownKeys$d(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
1592
+ function _objectSpread$d(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$d(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$d(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
1717
1593
  // eslint-disable-next-line no-redeclare
1718
1594
  var Point = {
1719
1595
  compare(point, another) {
@@ -1794,7 +1670,7 @@ var Point = {
1794
1670
  return null;
1795
1671
  } else if (op.position < offset || op.position === offset && affinity === 'forward') {
1796
1672
  offset -= op.position;
1797
- path = Path.transform(path, op, _objectSpread$b(_objectSpread$b({}, options), {}, {
1673
+ path = Path.transform(path, op, _objectSpread$d(_objectSpread$d({}, options), {}, {
1798
1674
  affinity: 'forward'
1799
1675
  }));
1800
1676
  }
@@ -1841,8 +1717,8 @@ var Scrubber = {
1841
1717
 
1842
1718
  var _excluded$2 = ["text"],
1843
1719
  _excluded2$2 = ["anchor", "focus", "merge"];
1844
- function ownKeys$a(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
1845
- function _objectSpread$a(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$a(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$a(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
1720
+ function ownKeys$c(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
1721
+ function _objectSpread$c(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$c(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$c(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
1846
1722
  // eslint-disable-next-line no-redeclare
1847
1723
  var Text = {
1848
1724
  equals(text, another) {
@@ -1878,7 +1754,7 @@ var Text = {
1878
1754
  },
1879
1755
  decorations(node, decorations) {
1880
1756
  var leaves = [{
1881
- leaf: _objectSpread$a({}, node)
1757
+ leaf: _objectSpread$c({}, node)
1882
1758
  }];
1883
1759
  for (var dec of decorations) {
1884
1760
  var {
@@ -1916,332 +1792,465 @@ var Text = {
1916
1792
  });
1917
1793
  continue;
1918
1794
  }
1919
- // Otherwise we need to split the leaf, at the start, end, or both,
1920
- // and add the range to the middle intersecting section. Do the end
1921
- // split first since we don't need to update the offset that way.
1922
- var middle = leaf;
1923
- var before = void 0;
1924
- var after = void 0;
1925
- if (decorationEnd < leafEnd) {
1926
- var off = decorationEnd - leafStart;
1927
- after = {
1928
- leaf: _objectSpread$a(_objectSpread$a({}, middle), {}, {
1929
- text: middle.text.slice(off)
1930
- })
1931
- };
1932
- middle = _objectSpread$a(_objectSpread$a({}, middle), {}, {
1933
- text: middle.text.slice(0, off)
1934
- });
1795
+ // Otherwise we need to split the leaf, at the start, end, or both,
1796
+ // and add the range to the middle intersecting section. Do the end
1797
+ // split first since we don't need to update the offset that way.
1798
+ var middle = leaf;
1799
+ var before = void 0;
1800
+ var after = void 0;
1801
+ if (decorationEnd < leafEnd) {
1802
+ var off = decorationEnd - leafStart;
1803
+ after = {
1804
+ leaf: _objectSpread$c(_objectSpread$c({}, middle), {}, {
1805
+ text: middle.text.slice(off)
1806
+ })
1807
+ };
1808
+ middle = _objectSpread$c(_objectSpread$c({}, middle), {}, {
1809
+ text: middle.text.slice(0, off)
1810
+ });
1811
+ }
1812
+ if (decorationStart > leafStart) {
1813
+ var _off = decorationStart - leafStart;
1814
+ before = {
1815
+ leaf: _objectSpread$c(_objectSpread$c({}, middle), {}, {
1816
+ text: middle.text.slice(0, _off)
1817
+ })
1818
+ };
1819
+ middle = _objectSpread$c(_objectSpread$c({}, middle), {}, {
1820
+ text: middle.text.slice(_off)
1821
+ });
1822
+ }
1823
+ merge(middle, rest);
1824
+ if (before) {
1825
+ next.push(before);
1826
+ }
1827
+ next.push({
1828
+ leaf: middle
1829
+ });
1830
+ if (after) {
1831
+ next.push(after);
1832
+ }
1833
+ }
1834
+ leaves = next;
1835
+ }
1836
+ if (leaves.length > 1) {
1837
+ var currentOffset = 0;
1838
+ for (var [index, item] of leaves.entries()) {
1839
+ var _start = currentOffset;
1840
+ var _end = _start + item.leaf.text.length;
1841
+ var position = {
1842
+ start: _start,
1843
+ end: _end
1844
+ };
1845
+ if (index === 0) position.isFirst = true;
1846
+ if (index === leaves.length - 1) position.isLast = true;
1847
+ item.position = position;
1848
+ currentOffset = _end;
1849
+ }
1850
+ }
1851
+ return leaves;
1852
+ }
1853
+ };
1854
+
1855
+ function ownKeys$b(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
1856
+ function _objectSpread$b(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$b(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$b(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
1857
+ var insertChildren = function insertChildren(xs, index) {
1858
+ for (var _len = arguments.length, newValues = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) {
1859
+ newValues[_key - 2] = arguments[_key];
1860
+ }
1861
+ return [...xs.slice(0, index), ...newValues, ...xs.slice(index)];
1862
+ };
1863
+ var replaceChildren = function replaceChildren(xs, index, removeCount) {
1864
+ for (var _len2 = arguments.length, newValues = new Array(_len2 > 3 ? _len2 - 3 : 0), _key2 = 3; _key2 < _len2; _key2++) {
1865
+ newValues[_key2 - 3] = arguments[_key2];
1866
+ }
1867
+ return [...xs.slice(0, index), ...newValues, ...xs.slice(index + removeCount)];
1868
+ };
1869
+ var removeChildren = replaceChildren;
1870
+ /**
1871
+ * Replace a descendant with a new node, replacing all ancestors
1872
+ */
1873
+ var modifyDescendant = (root, path, f) => {
1874
+ if (path.length === 0) {
1875
+ throw new Error('Cannot modify the editor');
1876
+ }
1877
+ var node = Node.get(root, path);
1878
+ var slicedPath = path.slice();
1879
+ var modifiedNode = f(node);
1880
+ while (slicedPath.length > 1) {
1881
+ var _index = slicedPath.pop();
1882
+ var ancestorNode = Node.get(root, slicedPath);
1883
+ modifiedNode = _objectSpread$b(_objectSpread$b({}, ancestorNode), {}, {
1884
+ children: replaceChildren(ancestorNode.children, _index, 1, modifiedNode)
1885
+ });
1886
+ }
1887
+ var index = slicedPath.pop();
1888
+ root.children = replaceChildren(root.children, index, 1, modifiedNode);
1889
+ };
1890
+ /**
1891
+ * Replace the children of a node, replacing all ancestors
1892
+ */
1893
+ var modifyChildren = (root, path, f) => {
1894
+ if (path.length === 0) {
1895
+ root.children = f(root.children);
1896
+ } else {
1897
+ modifyDescendant(root, path, node => {
1898
+ if (Text.isText(node)) {
1899
+ throw new Error("Cannot get the element at path [".concat(path, "] because it refers to a leaf node: ").concat(Scrubber.stringify(node)));
1900
+ }
1901
+ return _objectSpread$b(_objectSpread$b({}, node), {}, {
1902
+ children: f(node.children)
1903
+ });
1904
+ });
1905
+ }
1906
+ };
1907
+ /**
1908
+ * Replace a leaf, replacing all ancestors
1909
+ */
1910
+ var modifyLeaf = (root, path, f) => modifyDescendant(root, path, node => {
1911
+ if (!Text.isText(node)) {
1912
+ throw new Error("Cannot get the leaf node at path [".concat(path, "] because it refers to a non-leaf node: ").concat(Scrubber.stringify(node)));
1913
+ }
1914
+ return f(node);
1915
+ });
1916
+
1917
+ function ownKeys$a(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
1918
+ function _objectSpread$a(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$a(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$a(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
1919
+ // eslint-disable-next-line no-redeclare
1920
+ var GeneralTransforms = {
1921
+ transform(editor, op) {
1922
+ var transformSelection = false;
1923
+ switch (op.type) {
1924
+ case 'insert_node':
1925
+ {
1926
+ var {
1927
+ path,
1928
+ node
1929
+ } = op;
1930
+ modifyChildren(editor, Path.parent(path), children => {
1931
+ var index = path[path.length - 1];
1932
+ if (index > children.length) {
1933
+ throw new Error("Cannot apply an \"insert_node\" operation at path [".concat(path, "] because the destination is past the end of the node."));
1934
+ }
1935
+ return insertChildren(children, index, node);
1936
+ });
1937
+ transformSelection = true;
1938
+ break;
1939
+ }
1940
+ case 'insert_text':
1941
+ {
1942
+ var {
1943
+ path: _path,
1944
+ offset,
1945
+ text
1946
+ } = op;
1947
+ if (text.length === 0) break;
1948
+ modifyLeaf(editor, _path, node => {
1949
+ var before = node.text.slice(0, offset);
1950
+ var after = node.text.slice(offset);
1951
+ return _objectSpread$a(_objectSpread$a({}, node), {}, {
1952
+ text: before + text + after
1953
+ });
1954
+ });
1955
+ transformSelection = true;
1956
+ break;
1957
+ }
1958
+ case 'merge_node':
1959
+ {
1960
+ var {
1961
+ path: _path2
1962
+ } = op;
1963
+ var index = _path2[_path2.length - 1];
1964
+ var prevPath = Path.previous(_path2);
1965
+ var prevIndex = prevPath[prevPath.length - 1];
1966
+ modifyChildren(editor, Path.parent(_path2), children => {
1967
+ var node = children[index];
1968
+ var prev = children[prevIndex];
1969
+ var newNode;
1970
+ if (Text.isText(node) && Text.isText(prev)) {
1971
+ newNode = _objectSpread$a(_objectSpread$a({}, prev), {}, {
1972
+ text: prev.text + node.text
1973
+ });
1974
+ } else if (!Text.isText(node) && !Text.isText(prev)) {
1975
+ newNode = _objectSpread$a(_objectSpread$a({}, prev), {}, {
1976
+ children: prev.children.concat(node.children)
1977
+ });
1978
+ } else {
1979
+ throw new Error("Cannot apply a \"merge_node\" operation at path [".concat(_path2, "] to nodes of different interfaces: ").concat(Scrubber.stringify(node), " ").concat(Scrubber.stringify(prev)));
1980
+ }
1981
+ return replaceChildren(children, prevIndex, 2, newNode);
1982
+ });
1983
+ transformSelection = true;
1984
+ break;
1985
+ }
1986
+ case 'move_node':
1987
+ {
1988
+ var {
1989
+ path: _path3,
1990
+ newPath
1991
+ } = op;
1992
+ var _index = _path3[_path3.length - 1];
1993
+ if (Path.isAncestor(_path3, newPath)) {
1994
+ throw new Error("Cannot move a path [".concat(_path3, "] to new path [").concat(newPath, "] because the destination is inside itself."));
1995
+ }
1996
+ var _node = Node.get(editor, _path3);
1997
+ modifyChildren(editor, Path.parent(_path3), children => removeChildren(children, _index, 1));
1998
+ // This is tricky, but since the `path` and `newPath` both refer to
1999
+ // the same snapshot in time, there's a mismatch. After either
2000
+ // removing the original position, the second step's path can be out
2001
+ // of date. So instead of using the `op.newPath` directly, we
2002
+ // transform `op.path` to ascertain what the `newPath` would be after
2003
+ // the operation was applied.
2004
+ var truePath = Path.transform(_path3, op);
2005
+ var newIndex = truePath[truePath.length - 1];
2006
+ modifyChildren(editor, Path.parent(truePath), children => insertChildren(children, newIndex, _node));
2007
+ transformSelection = true;
2008
+ break;
2009
+ }
2010
+ case 'remove_node':
2011
+ {
2012
+ var {
2013
+ path: _path4
2014
+ } = op;
2015
+ var _index2 = _path4[_path4.length - 1];
2016
+ modifyChildren(editor, Path.parent(_path4), children => removeChildren(children, _index2, 1));
2017
+ // Transform all the points in the value, but if the point was in the
2018
+ // node that was removed we need to update the range or remove it.
2019
+ if (editor.selection) {
2020
+ var selection = _objectSpread$a({}, editor.selection);
2021
+ for (var [point, key] of Range.points(selection)) {
2022
+ var result = Point.transform(point, op);
2023
+ if (selection != null && result != null) {
2024
+ selection[key] = result;
2025
+ } else {
2026
+ var prev = void 0;
2027
+ var next = void 0;
2028
+ for (var [n, p] of Node.texts(editor)) {
2029
+ if (Path.compare(p, _path4) === -1) {
2030
+ prev = [n, p];
2031
+ } else {
2032
+ next = [n, p];
2033
+ break;
2034
+ }
2035
+ }
2036
+ var preferNext = false;
2037
+ if (prev && next) {
2038
+ if (Path.isSibling(prev[1], _path4)) {
2039
+ preferNext = false;
2040
+ } else if (Path.equals(next[1], _path4)) {
2041
+ preferNext = true;
2042
+ } else {
2043
+ preferNext = Path.common(prev[1], _path4).length < Path.common(next[1], _path4).length;
2044
+ }
2045
+ }
2046
+ if (prev && !preferNext) {
2047
+ selection[key] = {
2048
+ path: prev[1],
2049
+ offset: prev[0].text.length
2050
+ };
2051
+ } else if (next) {
2052
+ selection[key] = {
2053
+ path: next[1],
2054
+ offset: 0
2055
+ };
2056
+ } else {
2057
+ selection = null;
2058
+ }
2059
+ }
2060
+ }
2061
+ if (!selection || !Range.equals(selection, editor.selection)) {
2062
+ editor.selection = selection;
2063
+ }
2064
+ }
2065
+ break;
1935
2066
  }
1936
- if (decorationStart > leafStart) {
1937
- var _off = decorationStart - leafStart;
1938
- before = {
1939
- leaf: _objectSpread$a(_objectSpread$a({}, middle), {}, {
1940
- text: middle.text.slice(0, _off)
1941
- })
1942
- };
1943
- middle = _objectSpread$a(_objectSpread$a({}, middle), {}, {
1944
- text: middle.text.slice(_off)
2067
+ case 'remove_text':
2068
+ {
2069
+ var {
2070
+ path: _path5,
2071
+ offset: _offset,
2072
+ text: _text
2073
+ } = op;
2074
+ if (_text.length === 0) break;
2075
+ modifyLeaf(editor, _path5, node => {
2076
+ var before = node.text.slice(0, _offset);
2077
+ var after = node.text.slice(_offset + _text.length);
2078
+ return _objectSpread$a(_objectSpread$a({}, node), {}, {
2079
+ text: before + after
2080
+ });
1945
2081
  });
2082
+ transformSelection = true;
2083
+ break;
1946
2084
  }
1947
- merge(middle, rest);
1948
- if (before) {
1949
- next.push(before);
2085
+ case 'set_node':
2086
+ {
2087
+ var {
2088
+ path: _path6,
2089
+ properties,
2090
+ newProperties
2091
+ } = op;
2092
+ if (_path6.length === 0) {
2093
+ throw new Error("Cannot set properties on the root node!");
2094
+ }
2095
+ modifyDescendant(editor, _path6, node => {
2096
+ var newNode = _objectSpread$a({}, node);
2097
+ for (var _key in newProperties) {
2098
+ if (_key === 'children' || _key === 'text') {
2099
+ throw new Error("Cannot set the \"".concat(_key, "\" property of nodes!"));
2100
+ }
2101
+ var value = newProperties[_key];
2102
+ if (value == null) {
2103
+ delete newNode[_key];
2104
+ } else {
2105
+ newNode[_key] = value;
2106
+ }
2107
+ }
2108
+ // properties that were previously defined, but are now missing, must be deleted
2109
+ for (var _key2 in properties) {
2110
+ if (!newProperties.hasOwnProperty(_key2)) {
2111
+ delete newNode[_key2];
2112
+ }
2113
+ }
2114
+ return newNode;
2115
+ });
2116
+ break;
1950
2117
  }
1951
- next.push({
1952
- leaf: middle
1953
- });
1954
- if (after) {
1955
- next.push(after);
2118
+ case 'set_selection':
2119
+ {
2120
+ var {
2121
+ newProperties: _newProperties
2122
+ } = op;
2123
+ if (_newProperties == null) {
2124
+ editor.selection = null;
2125
+ break;
2126
+ }
2127
+ if (editor.selection == null) {
2128
+ if (!Range.isRange(_newProperties)) {
2129
+ throw new Error("Cannot apply an incomplete \"set_selection\" operation properties ".concat(Scrubber.stringify(_newProperties), " when there is no current selection."));
2130
+ }
2131
+ editor.selection = _objectSpread$a({}, _newProperties);
2132
+ break;
2133
+ }
2134
+ var _selection = _objectSpread$a({}, editor.selection);
2135
+ for (var _key3 in _newProperties) {
2136
+ var value = _newProperties[_key3];
2137
+ if (value == null) {
2138
+ if (_key3 === 'anchor' || _key3 === 'focus') {
2139
+ throw new Error("Cannot remove the \"".concat(_key3, "\" selection property"));
2140
+ }
2141
+ delete _selection[_key3];
2142
+ } else {
2143
+ _selection[_key3] = value;
2144
+ }
2145
+ }
2146
+ editor.selection = _selection;
2147
+ break;
1956
2148
  }
1957
- }
1958
- leaves = next;
1959
- }
1960
- if (leaves.length > 1) {
1961
- var currentOffset = 0;
1962
- for (var [index, item] of leaves.entries()) {
1963
- var _start = currentOffset;
1964
- var _end = _start + item.leaf.text.length;
1965
- var position = {
1966
- start: _start,
1967
- end: _end
1968
- };
1969
- if (index === 0) position.isFirst = true;
1970
- if (index === leaves.length - 1) position.isLast = true;
1971
- item.position = position;
1972
- currentOffset = _end;
1973
- }
1974
- }
1975
- return leaves;
1976
- }
1977
- };
1978
-
1979
- /**
1980
- * Get the default location to insert content into the editor.
1981
- * By default, use the selection as the target location. But if there is
1982
- * no selection, insert at the end of the document since that is such a
1983
- * common use case when inserting from a non-selected state.
1984
- */
1985
- var getDefaultInsertLocation = editor => {
1986
- if (editor.selection) {
1987
- return editor.selection;
1988
- } else if (editor.children.length > 0) {
1989
- return Editor.end(editor, []);
1990
- } else {
1991
- return [0];
1992
- }
1993
- };
1994
-
1995
- var matchPath = (editor, path) => {
1996
- var [node] = Editor.node(editor, path);
1997
- return n => n === node;
1998
- };
1999
-
2000
- // Character (grapheme cluster) boundaries are determined according to
2001
- // the default grapheme cluster boundary specification, extended grapheme clusters variant[1].
2002
- //
2003
- // References:
2004
- //
2005
- // [1] https://www.unicode.org/reports/tr29/#Default_Grapheme_Cluster_Table
2006
- // [2] https://www.unicode.org/Public/UCD/latest/ucd/auxiliary/GraphemeBreakProperty.txt
2007
- // [3] https://www.unicode.org/Public/UCD/latest/ucd/auxiliary/GraphemeBreakTest.html
2008
- // [4] https://www.unicode.org/Public/UCD/latest/ucd/auxiliary/GraphemeBreakTest.txt
2009
- /**
2010
- * Get the distance to the end of the first character in a string of text.
2011
- */
2012
- var getCharacterDistance = function getCharacterDistance(str) {
2013
- var isRTL = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
2014
- var isLTR = !isRTL;
2015
- var codepoints = isRTL ? codepointsIteratorRTL(str) : str;
2016
- var left = CodepointType.None;
2017
- var right = CodepointType.None;
2018
- var distance = 0;
2019
- // Evaluation of these conditions are deferred.
2020
- var gb11 = null; // Is GB11 applicable?
2021
- var gb12Or13 = null; // Is GB12 or GB13 applicable?
2022
- for (var char of codepoints) {
2023
- var code = char.codePointAt(0);
2024
- if (!code) break;
2025
- var type = getCodepointType(char, code);
2026
- [left, right] = isLTR ? [right, type] : [type, left];
2027
- if (intersects(left, CodepointType.ZWJ) && intersects(right, CodepointType.ExtPict)) {
2028
- if (isLTR) {
2029
- gb11 = endsWithEmojiZWJ(str.substring(0, distance));
2030
- } else {
2031
- gb11 = endsWithEmojiZWJ(str.substring(0, str.length - distance));
2032
- }
2033
- if (!gb11) break;
2034
- }
2035
- if (intersects(left, CodepointType.RI) && intersects(right, CodepointType.RI)) {
2036
- if (gb12Or13 !== null) {
2037
- gb12Or13 = !gb12Or13;
2038
- } else {
2039
- if (isLTR) {
2040
- gb12Or13 = true;
2041
- } else {
2042
- gb12Or13 = endsWithOddNumberOfRIs(str.substring(0, str.length - distance));
2149
+ case 'split_node':
2150
+ {
2151
+ var {
2152
+ path: _path7,
2153
+ position,
2154
+ properties: _properties
2155
+ } = op;
2156
+ var _index3 = _path7[_path7.length - 1];
2157
+ if (_path7.length === 0) {
2158
+ throw new Error("Cannot apply a \"split_node\" operation at path [".concat(_path7, "] because the root node cannot be split."));
2159
+ }
2160
+ modifyChildren(editor, Path.parent(_path7), children => {
2161
+ var node = children[_index3];
2162
+ var newNode;
2163
+ var nextNode;
2164
+ if (Text.isText(node)) {
2165
+ var before = node.text.slice(0, position);
2166
+ var after = node.text.slice(position);
2167
+ newNode = _objectSpread$a(_objectSpread$a({}, node), {}, {
2168
+ text: before
2169
+ });
2170
+ nextNode = _objectSpread$a(_objectSpread$a({}, _properties), {}, {
2171
+ text: after
2172
+ });
2173
+ } else {
2174
+ var _before = node.children.slice(0, position);
2175
+ var _after = node.children.slice(position);
2176
+ newNode = _objectSpread$a(_objectSpread$a({}, node), {}, {
2177
+ children: _before
2178
+ });
2179
+ nextNode = _objectSpread$a(_objectSpread$a({}, _properties), {}, {
2180
+ children: _after
2181
+ });
2182
+ }
2183
+ return replaceChildren(children, _index3, 1, newNode, nextNode);
2184
+ });
2185
+ transformSelection = true;
2186
+ break;
2043
2187
  }
2044
- }
2045
- if (!gb12Or13) break;
2046
- }
2047
- if (left !== CodepointType.None && right !== CodepointType.None && isBoundaryPair(left, right)) {
2048
- break;
2049
- }
2050
- distance += char.length;
2051
- }
2052
- return distance || 1;
2053
- };
2054
- var SPACE = /\s/;
2055
- var PUNCTUATION = /[\u002B\u0021-\u0023\u0025-\u002A\u002C-\u002F\u003A\u003B\u003F\u0040\u005B-\u005D\u005F\u007B\u007D\u00A1\u00A7\u00AB\u00B6\u00B7\u00BB\u00BF\u037E\u0387\u055A-\u055F\u0589\u058A\u05BE\u05C0\u05C3\u05C6\u05F3\u05F4\u0609\u060A\u060C\u060D\u061B\u061E\u061F\u066A-\u066D\u06D4\u0700-\u070D\u07F7-\u07F9\u0830-\u083E\u085E\u0964\u0965\u0970\u0AF0\u0DF4\u0E4F\u0E5A\u0E5B\u0F04-\u0F12\u0F14\u0F3A-\u0F3D\u0F85\u0FD0-\u0FD4\u0FD9\u0FDA\u104A-\u104F\u10FB\u1360-\u1368\u1400\u166D\u166E\u169B\u169C\u16EB-\u16ED\u1735\u1736\u17D4-\u17D6\u17D8-\u17DA\u1800-\u180A\u1944\u1945\u1A1E\u1A1F\u1AA0-\u1AA6\u1AA8-\u1AAD\u1B5A-\u1B60\u1BFC-\u1BFF\u1C3B-\u1C3F\u1C7E\u1C7F\u1CC0-\u1CC7\u1CD3\u2010-\u2027\u2030-\u2043\u2045-\u2051\u2053-\u205E\u207D\u207E\u208D\u208E\u2329\u232A\u2768-\u2775\u27C5\u27C6\u27E6-\u27EF\u2983-\u2998\u29D8-\u29DB\u29FC\u29FD\u2CF9-\u2CFC\u2CFE\u2CFF\u2D70\u2E00-\u2E2E\u2E30-\u2E3B\u3001-\u3003\u3008-\u3011\u3014-\u301F\u3030\u303D\u30A0\u30FB\uA4FE\uA4FF\uA60D-\uA60F\uA673\uA67E\uA6F2-\uA6F7\uA874-\uA877\uA8CE\uA8CF\uA8F8-\uA8FA\uA92E\uA92F\uA95F\uA9C1-\uA9CD\uA9DE\uA9DF\uAA5C-\uAA5F\uAADE\uAADF\uAAF0\uAAF1\uABEB\uFD3E\uFD3F\uFE10-\uFE19\uFE30-\uFE52\uFE54-\uFE61\uFE63\uFE68\uFE6A\uFE6B\uFF01-\uFF03\uFF05-\uFF0A\uFF0C-\uFF0F\uFF1A\uFF1B\uFF1F\uFF20\uFF3B-\uFF3D\uFF3F\uFF5B\uFF5D\uFF5F-\uFF65]/;
2056
- var CHAMELEON = /['\u2018\u2019]/;
2057
- /**
2058
- * Get the distance to the end of the first word in a string of text.
2059
- */
2060
- var getWordDistance = function getWordDistance(text) {
2061
- var isRTL = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
2062
- var dist = 0;
2063
- var started = false;
2064
- while (text.length > 0) {
2065
- var charDist = getCharacterDistance(text, isRTL);
2066
- var [char, remaining] = splitByCharacterDistance(text, charDist, isRTL);
2067
- if (isWordCharacter(char, remaining, isRTL)) {
2068
- started = true;
2069
- dist += charDist;
2070
- } else if (!started) {
2071
- dist += charDist;
2072
- } else {
2073
- break;
2074
- }
2075
- text = remaining;
2076
- }
2077
- return dist;
2078
- };
2079
- /**
2080
- * Split a string in two parts at a given distance starting from the end when
2081
- * `isRTL` is set to `true`.
2082
- */
2083
- var splitByCharacterDistance = (str, dist, isRTL) => {
2084
- if (isRTL) {
2085
- var at = str.length - dist;
2086
- return [str.slice(at, str.length), str.slice(0, at)];
2087
- }
2088
- return [str.slice(0, dist), str.slice(dist)];
2089
- };
2090
- /**
2091
- * Check if a character is a word character. The `remaining` argument is used
2092
- * because sometimes you must read subsequent characters to truly determine it.
2093
- */
2094
- var isWordCharacter = function isWordCharacter(char, remaining) {
2095
- var isRTL = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
2096
- if (SPACE.test(char)) {
2097
- return false;
2098
- }
2099
- // Chameleons count as word characters as long as they're in a word, so
2100
- // recurse to see if the next one is a word character or not.
2101
- if (CHAMELEON.test(char)) {
2102
- var charDist = getCharacterDistance(remaining, isRTL);
2103
- var [nextChar, nextRemaining] = splitByCharacterDistance(remaining, charDist, isRTL);
2104
- if (isWordCharacter(nextChar, nextRemaining, isRTL)) {
2105
- return true;
2106
2188
  }
2107
- }
2108
- if (PUNCTUATION.test(char)) {
2109
- return false;
2110
- }
2111
- return true;
2112
- };
2113
- /**
2114
- * Iterate on codepoints from right to left.
2115
- */
2116
- var codepointsIteratorRTL = function* codepointsIteratorRTL(str) {
2117
- var end = str.length - 1;
2118
- for (var i = 0; i < str.length; i++) {
2119
- var char1 = str.charAt(end - i);
2120
- if (isLowSurrogate(char1.charCodeAt(0))) {
2121
- var char2 = str.charAt(end - i - 1);
2122
- if (isHighSurrogate(char2.charCodeAt(0))) {
2123
- yield char2 + char1;
2124
- i++;
2125
- continue;
2189
+ if (transformSelection && editor.selection) {
2190
+ var _selection2 = _objectSpread$a({}, editor.selection);
2191
+ for (var [_point, _key4] of Range.points(_selection2)) {
2192
+ _selection2[_key4] = Point.transform(_point, op);
2193
+ }
2194
+ if (!Range.equals(_selection2, editor.selection)) {
2195
+ editor.selection = _selection2;
2126
2196
  }
2127
2197
  }
2128
- yield char1;
2129
2198
  }
2130
2199
  };
2131
- /**
2132
- * Is `charCode` a high surrogate.
2133
- *
2134
- * https://en.wikipedia.org/wiki/Universal_Character_Set_characters#Surrogates
2135
- */
2136
- var isHighSurrogate = charCode => {
2137
- return charCode >= 0xd800 && charCode <= 0xdbff;
2138
- };
2139
- /**
2140
- * Is `charCode` a low surrogate.
2141
- *
2142
- * https://en.wikipedia.org/wiki/Universal_Character_Set_characters#Surrogates
2143
- */
2144
- var isLowSurrogate = charCode => {
2145
- return charCode >= 0xdc00 && charCode <= 0xdfff;
2146
- };
2147
- var CodepointType;
2148
- (function (CodepointType) {
2149
- CodepointType[CodepointType["None"] = 0] = "None";
2150
- CodepointType[CodepointType["Extend"] = 1] = "Extend";
2151
- CodepointType[CodepointType["ZWJ"] = 2] = "ZWJ";
2152
- CodepointType[CodepointType["RI"] = 4] = "RI";
2153
- CodepointType[CodepointType["Prepend"] = 8] = "Prepend";
2154
- CodepointType[CodepointType["SpacingMark"] = 16] = "SpacingMark";
2155
- CodepointType[CodepointType["L"] = 32] = "L";
2156
- CodepointType[CodepointType["V"] = 64] = "V";
2157
- CodepointType[CodepointType["T"] = 128] = "T";
2158
- CodepointType[CodepointType["LV"] = 256] = "LV";
2159
- CodepointType[CodepointType["LVT"] = 512] = "LVT";
2160
- CodepointType[CodepointType["ExtPict"] = 1024] = "ExtPict";
2161
- CodepointType[CodepointType["Any"] = 2048] = "Any";
2162
- })(CodepointType || (CodepointType = {}));
2163
- var reExtend = /^(?:[\u0300-\u036F\u0483-\u0489\u0591-\u05BD\u05BF\u05C1\u05C2\u05C4\u05C5\u05C7\u0610-\u061A\u064B-\u065F\u0670\u06D6-\u06DC\u06DF-\u06E4\u06E7\u06E8\u06EA-\u06ED\u0711\u0730-\u074A\u07A6-\u07B0\u07EB-\u07F3\u07FD\u0816-\u0819\u081B-\u0823\u0825-\u0827\u0829-\u082D\u0859-\u085B\u0898-\u089F\u08CA-\u08E1\u08E3-\u0902\u093A\u093C\u0941-\u0948\u094D\u0951-\u0957\u0962\u0963\u0981\u09BC\u09BE\u09C1-\u09C4\u09CD\u09D7\u09E2\u09E3\u09FE\u0A01\u0A02\u0A3C\u0A41\u0A42\u0A47\u0A48\u0A4B-\u0A4D\u0A51\u0A70\u0A71\u0A75\u0A81\u0A82\u0ABC\u0AC1-\u0AC5\u0AC7\u0AC8\u0ACD\u0AE2\u0AE3\u0AFA-\u0AFF\u0B01\u0B3C\u0B3E\u0B3F\u0B41-\u0B44\u0B4D\u0B55-\u0B57\u0B62\u0B63\u0B82\u0BBE\u0BC0\u0BCD\u0BD7\u0C00\u0C04\u0C3C\u0C3E-\u0C40\u0C46-\u0C48\u0C4A-\u0C4D\u0C55\u0C56\u0C62\u0C63\u0C81\u0CBC\u0CBF\u0CC2\u0CC6\u0CCC\u0CCD\u0CD5\u0CD6\u0CE2\u0CE3\u0D00\u0D01\u0D3B\u0D3C\u0D3E\u0D41-\u0D44\u0D4D\u0D57\u0D62\u0D63\u0D81\u0DCA\u0DCF\u0DD2-\u0DD4\u0DD6\u0DDF\u0E31\u0E34-\u0E3A\u0E47-\u0E4E\u0EB1\u0EB4-\u0EBC\u0EC8-\u0ECE\u0F18\u0F19\u0F35\u0F37\u0F39\u0F71-\u0F7E\u0F80-\u0F84\u0F86\u0F87\u0F8D-\u0F97\u0F99-\u0FBC\u0FC6\u102D-\u1030\u1032-\u1037\u1039\u103A\u103D\u103E\u1058\u1059\u105E-\u1060\u1071-\u1074\u1082\u1085\u1086\u108D\u109D\u135D-\u135F\u1712-\u1714\u1732\u1733\u1752\u1753\u1772\u1773\u17B4\u17B5\u17B7-\u17BD\u17C6\u17C9-\u17D3\u17DD\u180B-\u180D\u180F\u1885\u1886\u18A9\u1920-\u1922\u1927\u1928\u1932\u1939-\u193B\u1A17\u1A18\u1A1B\u1A56\u1A58-\u1A5E\u1A60\u1A62\u1A65-\u1A6C\u1A73-\u1A7C\u1A7F\u1AB0-\u1ACE\u1B00-\u1B03\u1B34-\u1B3A\u1B3C\u1B42\u1B6B-\u1B73\u1B80\u1B81\u1BA2-\u1BA5\u1BA8\u1BA9\u1BAB-\u1BAD\u1BE6\u1BE8\u1BE9\u1BED\u1BEF-\u1BF1\u1C2C-\u1C33\u1C36\u1C37\u1CD0-\u1CD2\u1CD4-\u1CE0\u1CE2-\u1CE8\u1CED\u1CF4\u1CF8\u1CF9\u1DC0-\u1DFF\u200C\u20D0-\u20F0\u2CEF-\u2CF1\u2D7F\u2DE0-\u2DFF\u302A-\u302F\u3099\u309A\uA66F-\uA672\uA674-\uA67D\uA69E\uA69F\uA6F0\uA6F1\uA802\uA806\uA80B\uA825\uA826\uA82C\uA8C4\uA8C5\uA8E0-\uA8F1\uA8FF\uA926-\uA92D\uA947-\uA951\uA980-\uA982\uA9B3\uA9B6-\uA9B9\uA9BC\uA9BD\uA9E5\uAA29-\uAA2E\uAA31\uAA32\uAA35\uAA36\uAA43\uAA4C\uAA7C\uAAB0\uAAB2-\uAAB4\uAAB7\uAAB8\uAABE\uAABF\uAAC1\uAAEC\uAAED\uAAF6\uABE5\uABE8\uABED\uFB1E\uFE00-\uFE0F\uFE20-\uFE2F\uFF9E\uFF9F]|\uD800[\uDDFD\uDEE0\uDF76-\uDF7A]|\uD802[\uDE01-\uDE03\uDE05\uDE06\uDE0C-\uDE0F\uDE38-\uDE3A\uDE3F\uDEE5\uDEE6]|\uD803[\uDD24-\uDD27\uDEAB\uDEAC\uDEFD-\uDEFF\uDF46-\uDF50\uDF82-\uDF85]|\uD804[\uDC01\uDC38-\uDC46\uDC70\uDC73\uDC74\uDC7F-\uDC81\uDCB3-\uDCB6\uDCB9\uDCBA\uDCC2\uDD00-\uDD02\uDD27-\uDD2B\uDD2D-\uDD34\uDD73\uDD80\uDD81\uDDB6-\uDDBE\uDDC9-\uDDCC\uDDCF\uDE2F-\uDE31\uDE34\uDE36\uDE37\uDE3E\uDE41\uDEDF\uDEE3-\uDEEA\uDF00\uDF01\uDF3B\uDF3C\uDF3E\uDF40\uDF57\uDF66-\uDF6C\uDF70-\uDF74]|\uD805[\uDC38-\uDC3F\uDC42-\uDC44\uDC46\uDC5E\uDCB0\uDCB3-\uDCB8\uDCBA\uDCBD\uDCBF\uDCC0\uDCC2\uDCC3\uDDAF\uDDB2-\uDDB5\uDDBC\uDDBD\uDDBF\uDDC0\uDDDC\uDDDD\uDE33-\uDE3A\uDE3D\uDE3F\uDE40\uDEAB\uDEAD\uDEB0-\uDEB5\uDEB7\uDF1D-\uDF1F\uDF22-\uDF25\uDF27-\uDF2B]|\uD806[\uDC2F-\uDC37\uDC39\uDC3A\uDD30\uDD3B\uDD3C\uDD3E\uDD43\uDDD4-\uDDD7\uDDDA\uDDDB\uDDE0\uDE01-\uDE0A\uDE33-\uDE38\uDE3B-\uDE3E\uDE47\uDE51-\uDE56\uDE59-\uDE5B\uDE8A-\uDE96\uDE98\uDE99]|\uD807[\uDC30-\uDC36\uDC38-\uDC3D\uDC3F\uDC92-\uDCA7\uDCAA-\uDCB0\uDCB2\uDCB3\uDCB5\uDCB6\uDD31-\uDD36\uDD3A\uDD3C\uDD3D\uDD3F-\uDD45\uDD47\uDD90\uDD91\uDD95\uDD97\uDEF3\uDEF4\uDF00\uDF01\uDF36-\uDF3A\uDF40\uDF42]|\uD80D[\uDC40\uDC47-\uDC55]|\uD81A[\uDEF0-\uDEF4\uDF30-\uDF36]|\uD81B[\uDF4F\uDF8F-\uDF92\uDFE4]|\uD82F[\uDC9D\uDC9E]|\uD833[\uDF00-\uDF2D\uDF30-\uDF46]|\uD834[\uDD65\uDD67-\uDD69\uDD6E-\uDD72\uDD7B-\uDD82\uDD85-\uDD8B\uDDAA-\uDDAD\uDE42-\uDE44]|\uD836[\uDE00-\uDE36\uDE3B-\uDE6C\uDE75\uDE84\uDE9B-\uDE9F\uDEA1-\uDEAF]|\uD838[\uDC00-\uDC06\uDC08-\uDC18\uDC1B-\uDC21\uDC23\uDC24\uDC26-\uDC2A\uDC8F\uDD30-\uDD36\uDEAE\uDEEC-\uDEEF]|\uD839[\uDCEC-\uDCEF]|\uD83A[\uDCD0-\uDCD6\uDD44-\uDD4A]|\uD83C[\uDFFB-\uDFFF]|\uDB40[\uDC20-\uDC7F\uDD00-\uDDEF])$/;
2164
- var rePrepend = /^(?:[\u0600-\u0605\u06DD\u070F\u0890\u0891\u08E2\u0D4E]|\uD804[\uDCBD\uDCCD\uDDC2\uDDC3]|\uD806[\uDD3F\uDD41\uDE3A\uDE84-\uDE89]|\uD807\uDD46)$/;
2165
- var reSpacingMark = /^(?:[\u0903\u093B\u093E-\u0940\u0949-\u094C\u094E\u094F\u0982\u0983\u09BF\u09C0\u09C7\u09C8\u09CB\u09CC\u0A03\u0A3E-\u0A40\u0A83\u0ABE-\u0AC0\u0AC9\u0ACB\u0ACC\u0B02\u0B03\u0B40\u0B47\u0B48\u0B4B\u0B4C\u0BBF\u0BC1\u0BC2\u0BC6-\u0BC8\u0BCA-\u0BCC\u0C01-\u0C03\u0C41-\u0C44\u0C82\u0C83\u0CBE\u0CC0\u0CC1\u0CC3\u0CC4\u0CC7\u0CC8\u0CCA\u0CCB\u0D02\u0D03\u0D3F\u0D40\u0D46-\u0D48\u0D4A-\u0D4C\u0D82\u0D83\u0DD0\u0DD1\u0DD8-\u0DDE\u0DF2\u0DF3\u0E33\u0EB3\u0F3E\u0F3F\u0F7F\u1031\u103B\u103C\u1056\u1057\u1084\u1715\u1734\u17B6\u17BE-\u17C5\u17C7\u17C8\u1923-\u1926\u1929-\u192B\u1930\u1931\u1933-\u1938\u1A19\u1A1A\u1A55\u1A57\u1A6D-\u1A72\u1B04\u1B3B\u1B3D-\u1B41\u1B43\u1B44\u1B82\u1BA1\u1BA6\u1BA7\u1BAA\u1BE7\u1BEA-\u1BEC\u1BEE\u1BF2\u1BF3\u1C24-\u1C2B\u1C34\u1C35\u1CE1\u1CF7\uA823\uA824\uA827\uA880\uA881\uA8B4-\uA8C3\uA952\uA953\uA983\uA9B4\uA9B5\uA9BA\uA9BB\uA9BE-\uA9C0\uAA2F\uAA30\uAA33\uAA34\uAA4D\uAAEB\uAAEE\uAAEF\uAAF5\uABE3\uABE4\uABE6\uABE7\uABE9\uABEA\uABEC]|\uD804[\uDC00\uDC02\uDC82\uDCB0-\uDCB2\uDCB7\uDCB8\uDD2C\uDD45\uDD46\uDD82\uDDB3-\uDDB5\uDDBF\uDDC0\uDDCE\uDE2C-\uDE2E\uDE32\uDE33\uDE35\uDEE0-\uDEE2\uDF02\uDF03\uDF3F\uDF41-\uDF44\uDF47\uDF48\uDF4B-\uDF4D\uDF62\uDF63]|\uD805[\uDC35-\uDC37\uDC40\uDC41\uDC45\uDCB1\uDCB2\uDCB9\uDCBB\uDCBC\uDCBE\uDCC1\uDDB0\uDDB1\uDDB8-\uDDBB\uDDBE\uDE30-\uDE32\uDE3B\uDE3C\uDE3E\uDEAC\uDEAE\uDEAF\uDEB6\uDF26]|\uD806[\uDC2C-\uDC2E\uDC38\uDD31-\uDD35\uDD37\uDD38\uDD3D\uDD40\uDD42\uDDD1-\uDDD3\uDDDC-\uDDDF\uDDE4\uDE39\uDE57\uDE58\uDE97]|\uD807[\uDC2F\uDC3E\uDCA9\uDCB1\uDCB4\uDD8A-\uDD8E\uDD93\uDD94\uDD96\uDEF5\uDEF6]|\uD81B[\uDF51-\uDF87\uDFF0\uDFF1]|\uD834[\uDD66\uDD6D])$/;
2166
- var reL = /^[\u1100-\u115F\uA960-\uA97C]$/;
2167
- var reV = /^[\u1160-\u11A7\uD7B0-\uD7C6]$/;
2168
- var reT = /^[\u11A8-\u11FF\uD7CB-\uD7FB]$/;
2169
- var reLV = /^[\uAC00\uAC1C\uAC38\uAC54\uAC70\uAC8C\uACA8\uACC4\uACE0\uACFC\uAD18\uAD34\uAD50\uAD6C\uAD88\uADA4\uADC0\uADDC\uADF8\uAE14\uAE30\uAE4C\uAE68\uAE84\uAEA0\uAEBC\uAED8\uAEF4\uAF10\uAF2C\uAF48\uAF64\uAF80\uAF9C\uAFB8\uAFD4\uAFF0\uB00C\uB028\uB044\uB060\uB07C\uB098\uB0B4\uB0D0\uB0EC\uB108\uB124\uB140\uB15C\uB178\uB194\uB1B0\uB1CC\uB1E8\uB204\uB220\uB23C\uB258\uB274\uB290\uB2AC\uB2C8\uB2E4\uB300\uB31C\uB338\uB354\uB370\uB38C\uB3A8\uB3C4\uB3E0\uB3FC\uB418\uB434\uB450\uB46C\uB488\uB4A4\uB4C0\uB4DC\uB4F8\uB514\uB530\uB54C\uB568\uB584\uB5A0\uB5BC\uB5D8\uB5F4\uB610\uB62C\uB648\uB664\uB680\uB69C\uB6B8\uB6D4\uB6F0\uB70C\uB728\uB744\uB760\uB77C\uB798\uB7B4\uB7D0\uB7EC\uB808\uB824\uB840\uB85C\uB878\uB894\uB8B0\uB8CC\uB8E8\uB904\uB920\uB93C\uB958\uB974\uB990\uB9AC\uB9C8\uB9E4\uBA00\uBA1C\uBA38\uBA54\uBA70\uBA8C\uBAA8\uBAC4\uBAE0\uBAFC\uBB18\uBB34\uBB50\uBB6C\uBB88\uBBA4\uBBC0\uBBDC\uBBF8\uBC14\uBC30\uBC4C\uBC68\uBC84\uBCA0\uBCBC\uBCD8\uBCF4\uBD10\uBD2C\uBD48\uBD64\uBD80\uBD9C\uBDB8\uBDD4\uBDF0\uBE0C\uBE28\uBE44\uBE60\uBE7C\uBE98\uBEB4\uBED0\uBEEC\uBF08\uBF24\uBF40\uBF5C\uBF78\uBF94\uBFB0\uBFCC\uBFE8\uC004\uC020\uC03C\uC058\uC074\uC090\uC0AC\uC0C8\uC0E4\uC100\uC11C\uC138\uC154\uC170\uC18C\uC1A8\uC1C4\uC1E0\uC1FC\uC218\uC234\uC250\uC26C\uC288\uC2A4\uC2C0\uC2DC\uC2F8\uC314\uC330\uC34C\uC368\uC384\uC3A0\uC3BC\uC3D8\uC3F4\uC410\uC42C\uC448\uC464\uC480\uC49C\uC4B8\uC4D4\uC4F0\uC50C\uC528\uC544\uC560\uC57C\uC598\uC5B4\uC5D0\uC5EC\uC608\uC624\uC640\uC65C\uC678\uC694\uC6B0\uC6CC\uC6E8\uC704\uC720\uC73C\uC758\uC774\uC790\uC7AC\uC7C8\uC7E4\uC800\uC81C\uC838\uC854\uC870\uC88C\uC8A8\uC8C4\uC8E0\uC8FC\uC918\uC934\uC950\uC96C\uC988\uC9A4\uC9C0\uC9DC\uC9F8\uCA14\uCA30\uCA4C\uCA68\uCA84\uCAA0\uCABC\uCAD8\uCAF4\uCB10\uCB2C\uCB48\uCB64\uCB80\uCB9C\uCBB8\uCBD4\uCBF0\uCC0C\uCC28\uCC44\uCC60\uCC7C\uCC98\uCCB4\uCCD0\uCCEC\uCD08\uCD24\uCD40\uCD5C\uCD78\uCD94\uCDB0\uCDCC\uCDE8\uCE04\uCE20\uCE3C\uCE58\uCE74\uCE90\uCEAC\uCEC8\uCEE4\uCF00\uCF1C\uCF38\uCF54\uCF70\uCF8C\uCFA8\uCFC4\uCFE0\uCFFC\uD018\uD034\uD050\uD06C\uD088\uD0A4\uD0C0\uD0DC\uD0F8\uD114\uD130\uD14C\uD168\uD184\uD1A0\uD1BC\uD1D8\uD1F4\uD210\uD22C\uD248\uD264\uD280\uD29C\uD2B8\uD2D4\uD2F0\uD30C\uD328\uD344\uD360\uD37C\uD398\uD3B4\uD3D0\uD3EC\uD408\uD424\uD440\uD45C\uD478\uD494\uD4B0\uD4CC\uD4E8\uD504\uD520\uD53C\uD558\uD574\uD590\uD5AC\uD5C8\uD5E4\uD600\uD61C\uD638\uD654\uD670\uD68C\uD6A8\uD6C4\uD6E0\uD6FC\uD718\uD734\uD750\uD76C\uD788]$/;
2170
- var reLVT = /^[\uAC01-\uAC1B\uAC1D-\uAC37\uAC39-\uAC53\uAC55-\uAC6F\uAC71-\uAC8B\uAC8D-\uACA7\uACA9-\uACC3\uACC5-\uACDF\uACE1-\uACFB\uACFD-\uAD17\uAD19-\uAD33\uAD35-\uAD4F\uAD51-\uAD6B\uAD6D-\uAD87\uAD89-\uADA3\uADA5-\uADBF\uADC1-\uADDB\uADDD-\uADF7\uADF9-\uAE13\uAE15-\uAE2F\uAE31-\uAE4B\uAE4D-\uAE67\uAE69-\uAE83\uAE85-\uAE9F\uAEA1-\uAEBB\uAEBD-\uAED7\uAED9-\uAEF3\uAEF5-\uAF0F\uAF11-\uAF2B\uAF2D-\uAF47\uAF49-\uAF63\uAF65-\uAF7F\uAF81-\uAF9B\uAF9D-\uAFB7\uAFB9-\uAFD3\uAFD5-\uAFEF\uAFF1-\uB00B\uB00D-\uB027\uB029-\uB043\uB045-\uB05F\uB061-\uB07B\uB07D-\uB097\uB099-\uB0B3\uB0B5-\uB0CF\uB0D1-\uB0EB\uB0ED-\uB107\uB109-\uB123\uB125-\uB13F\uB141-\uB15B\uB15D-\uB177\uB179-\uB193\uB195-\uB1AF\uB1B1-\uB1CB\uB1CD-\uB1E7\uB1E9-\uB203\uB205-\uB21F\uB221-\uB23B\uB23D-\uB257\uB259-\uB273\uB275-\uB28F\uB291-\uB2AB\uB2AD-\uB2C7\uB2C9-\uB2E3\uB2E5-\uB2FF\uB301-\uB31B\uB31D-\uB337\uB339-\uB353\uB355-\uB36F\uB371-\uB38B\uB38D-\uB3A7\uB3A9-\uB3C3\uB3C5-\uB3DF\uB3E1-\uB3FB\uB3FD-\uB417\uB419-\uB433\uB435-\uB44F\uB451-\uB46B\uB46D-\uB487\uB489-\uB4A3\uB4A5-\uB4BF\uB4C1-\uB4DB\uB4DD-\uB4F7\uB4F9-\uB513\uB515-\uB52F\uB531-\uB54B\uB54D-\uB567\uB569-\uB583\uB585-\uB59F\uB5A1-\uB5BB\uB5BD-\uB5D7\uB5D9-\uB5F3\uB5F5-\uB60F\uB611-\uB62B\uB62D-\uB647\uB649-\uB663\uB665-\uB67F\uB681-\uB69B\uB69D-\uB6B7\uB6B9-\uB6D3\uB6D5-\uB6EF\uB6F1-\uB70B\uB70D-\uB727\uB729-\uB743\uB745-\uB75F\uB761-\uB77B\uB77D-\uB797\uB799-\uB7B3\uB7B5-\uB7CF\uB7D1-\uB7EB\uB7ED-\uB807\uB809-\uB823\uB825-\uB83F\uB841-\uB85B\uB85D-\uB877\uB879-\uB893\uB895-\uB8AF\uB8B1-\uB8CB\uB8CD-\uB8E7\uB8E9-\uB903\uB905-\uB91F\uB921-\uB93B\uB93D-\uB957\uB959-\uB973\uB975-\uB98F\uB991-\uB9AB\uB9AD-\uB9C7\uB9C9-\uB9E3\uB9E5-\uB9FF\uBA01-\uBA1B\uBA1D-\uBA37\uBA39-\uBA53\uBA55-\uBA6F\uBA71-\uBA8B\uBA8D-\uBAA7\uBAA9-\uBAC3\uBAC5-\uBADF\uBAE1-\uBAFB\uBAFD-\uBB17\uBB19-\uBB33\uBB35-\uBB4F\uBB51-\uBB6B\uBB6D-\uBB87\uBB89-\uBBA3\uBBA5-\uBBBF\uBBC1-\uBBDB\uBBDD-\uBBF7\uBBF9-\uBC13\uBC15-\uBC2F\uBC31-\uBC4B\uBC4D-\uBC67\uBC69-\uBC83\uBC85-\uBC9F\uBCA1-\uBCBB\uBCBD-\uBCD7\uBCD9-\uBCF3\uBCF5-\uBD0F\uBD11-\uBD2B\uBD2D-\uBD47\uBD49-\uBD63\uBD65-\uBD7F\uBD81-\uBD9B\uBD9D-\uBDB7\uBDB9-\uBDD3\uBDD5-\uBDEF\uBDF1-\uBE0B\uBE0D-\uBE27\uBE29-\uBE43\uBE45-\uBE5F\uBE61-\uBE7B\uBE7D-\uBE97\uBE99-\uBEB3\uBEB5-\uBECF\uBED1-\uBEEB\uBEED-\uBF07\uBF09-\uBF23\uBF25-\uBF3F\uBF41-\uBF5B\uBF5D-\uBF77\uBF79-\uBF93\uBF95-\uBFAF\uBFB1-\uBFCB\uBFCD-\uBFE7\uBFE9-\uC003\uC005-\uC01F\uC021-\uC03B\uC03D-\uC057\uC059-\uC073\uC075-\uC08F\uC091-\uC0AB\uC0AD-\uC0C7\uC0C9-\uC0E3\uC0E5-\uC0FF\uC101-\uC11B\uC11D-\uC137\uC139-\uC153\uC155-\uC16F\uC171-\uC18B\uC18D-\uC1A7\uC1A9-\uC1C3\uC1C5-\uC1DF\uC1E1-\uC1FB\uC1FD-\uC217\uC219-\uC233\uC235-\uC24F\uC251-\uC26B\uC26D-\uC287\uC289-\uC2A3\uC2A5-\uC2BF\uC2C1-\uC2DB\uC2DD-\uC2F7\uC2F9-\uC313\uC315-\uC32F\uC331-\uC34B\uC34D-\uC367\uC369-\uC383\uC385-\uC39F\uC3A1-\uC3BB\uC3BD-\uC3D7\uC3D9-\uC3F3\uC3F5-\uC40F\uC411-\uC42B\uC42D-\uC447\uC449-\uC463\uC465-\uC47F\uC481-\uC49B\uC49D-\uC4B7\uC4B9-\uC4D3\uC4D5-\uC4EF\uC4F1-\uC50B\uC50D-\uC527\uC529-\uC543\uC545-\uC55F\uC561-\uC57B\uC57D-\uC597\uC599-\uC5B3\uC5B5-\uC5CF\uC5D1-\uC5EB\uC5ED-\uC607\uC609-\uC623\uC625-\uC63F\uC641-\uC65B\uC65D-\uC677\uC679-\uC693\uC695-\uC6AF\uC6B1-\uC6CB\uC6CD-\uC6E7\uC6E9-\uC703\uC705-\uC71F\uC721-\uC73B\uC73D-\uC757\uC759-\uC773\uC775-\uC78F\uC791-\uC7AB\uC7AD-\uC7C7\uC7C9-\uC7E3\uC7E5-\uC7FF\uC801-\uC81B\uC81D-\uC837\uC839-\uC853\uC855-\uC86F\uC871-\uC88B\uC88D-\uC8A7\uC8A9-\uC8C3\uC8C5-\uC8DF\uC8E1-\uC8FB\uC8FD-\uC917\uC919-\uC933\uC935-\uC94F\uC951-\uC96B\uC96D-\uC987\uC989-\uC9A3\uC9A5-\uC9BF\uC9C1-\uC9DB\uC9DD-\uC9F7\uC9F9-\uCA13\uCA15-\uCA2F\uCA31-\uCA4B\uCA4D-\uCA67\uCA69-\uCA83\uCA85-\uCA9F\uCAA1-\uCABB\uCABD-\uCAD7\uCAD9-\uCAF3\uCAF5-\uCB0F\uCB11-\uCB2B\uCB2D-\uCB47\uCB49-\uCB63\uCB65-\uCB7F\uCB81-\uCB9B\uCB9D-\uCBB7\uCBB9-\uCBD3\uCBD5-\uCBEF\uCBF1-\uCC0B\uCC0D-\uCC27\uCC29-\uCC43\uCC45-\uCC5F\uCC61-\uCC7B\uCC7D-\uCC97\uCC99-\uCCB3\uCCB5-\uCCCF\uCCD1-\uCCEB\uCCED-\uCD07\uCD09-\uCD23\uCD25-\uCD3F\uCD41-\uCD5B\uCD5D-\uCD77\uCD79-\uCD93\uCD95-\uCDAF\uCDB1-\uCDCB\uCDCD-\uCDE7\uCDE9-\uCE03\uCE05-\uCE1F\uCE21-\uCE3B\uCE3D-\uCE57\uCE59-\uCE73\uCE75-\uCE8F\uCE91-\uCEAB\uCEAD-\uCEC7\uCEC9-\uCEE3\uCEE5-\uCEFF\uCF01-\uCF1B\uCF1D-\uCF37\uCF39-\uCF53\uCF55-\uCF6F\uCF71-\uCF8B\uCF8D-\uCFA7\uCFA9-\uCFC3\uCFC5-\uCFDF\uCFE1-\uCFFB\uCFFD-\uD017\uD019-\uD033\uD035-\uD04F\uD051-\uD06B\uD06D-\uD087\uD089-\uD0A3\uD0A5-\uD0BF\uD0C1-\uD0DB\uD0DD-\uD0F7\uD0F9-\uD113\uD115-\uD12F\uD131-\uD14B\uD14D-\uD167\uD169-\uD183\uD185-\uD19F\uD1A1-\uD1BB\uD1BD-\uD1D7\uD1D9-\uD1F3\uD1F5-\uD20F\uD211-\uD22B\uD22D-\uD247\uD249-\uD263\uD265-\uD27F\uD281-\uD29B\uD29D-\uD2B7\uD2B9-\uD2D3\uD2D5-\uD2EF\uD2F1-\uD30B\uD30D-\uD327\uD329-\uD343\uD345-\uD35F\uD361-\uD37B\uD37D-\uD397\uD399-\uD3B3\uD3B5-\uD3CF\uD3D1-\uD3EB\uD3ED-\uD407\uD409-\uD423\uD425-\uD43F\uD441-\uD45B\uD45D-\uD477\uD479-\uD493\uD495-\uD4AF\uD4B1-\uD4CB\uD4CD-\uD4E7\uD4E9-\uD503\uD505-\uD51F\uD521-\uD53B\uD53D-\uD557\uD559-\uD573\uD575-\uD58F\uD591-\uD5AB\uD5AD-\uD5C7\uD5C9-\uD5E3\uD5E5-\uD5FF\uD601-\uD61B\uD61D-\uD637\uD639-\uD653\uD655-\uD66F\uD671-\uD68B\uD68D-\uD6A7\uD6A9-\uD6C3\uD6C5-\uD6DF\uD6E1-\uD6FB\uD6FD-\uD717\uD719-\uD733\uD735-\uD74F\uD751-\uD76B\uD76D-\uD787\uD789-\uD7A3]$/;
2171
- var reExtPict = /^(?:[\xA9\xAE\u203C\u2049\u2122\u2139\u2194-\u2199\u21A9\u21AA\u231A\u231B\u2328\u2388\u23CF\u23E9-\u23F3\u23F8-\u23FA\u24C2\u25AA\u25AB\u25B6\u25C0\u25FB-\u25FE\u2600-\u2605\u2607-\u2612\u2614-\u2685\u2690-\u2705\u2708-\u2712\u2714\u2716\u271D\u2721\u2728\u2733\u2734\u2744\u2747\u274C\u274E\u2753-\u2755\u2757\u2763-\u2767\u2795-\u2797\u27A1\u27B0\u27BF\u2934\u2935\u2B05-\u2B07\u2B1B\u2B1C\u2B50\u2B55\u3030\u303D\u3297\u3299]|\uD83C[\uDC00-\uDCFF\uDD0D-\uDD0F\uDD2F\uDD6C-\uDD71\uDD7E\uDD7F\uDD8E\uDD91-\uDD9A\uDDAD-\uDDE5\uDE01-\uDE0F\uDE1A\uDE2F\uDE32-\uDE3A\uDE3C-\uDE3F\uDE49-\uDFFA]|\uD83D[\uDC00-\uDD3D\uDD46-\uDE4F\uDE80-\uDEFF\uDF74-\uDF7F\uDFD5-\uDFFF]|\uD83E[\uDC0C-\uDC0F\uDC48-\uDC4F\uDC5A-\uDC5F\uDC88-\uDC8F\uDCAE-\uDCFF\uDD0C-\uDD3A\uDD3C-\uDD45\uDD47-\uDEFF]|\uD83F[\uDC00-\uDFFD])$/;
2172
- var getCodepointType = (char, code) => {
2173
- var type = CodepointType.Any;
2174
- if (char.search(reExtend) !== -1) {
2175
- type |= CodepointType.Extend;
2176
- }
2177
- if (code === 0x200d) {
2178
- type |= CodepointType.ZWJ;
2179
- }
2180
- if (code >= 0x1f1e6 && code <= 0x1f1ff) {
2181
- type |= CodepointType.RI;
2182
- }
2183
- if (char.search(rePrepend) !== -1) {
2184
- type |= CodepointType.Prepend;
2185
- }
2186
- if (char.search(reSpacingMark) !== -1) {
2187
- type |= CodepointType.SpacingMark;
2188
- }
2189
- if (char.search(reL) !== -1) {
2190
- type |= CodepointType.L;
2191
- }
2192
- if (char.search(reV) !== -1) {
2193
- type |= CodepointType.V;
2194
- }
2195
- if (char.search(reT) !== -1) {
2196
- type |= CodepointType.T;
2197
- }
2198
- if (char.search(reLV) !== -1) {
2199
- type |= CodepointType.LV;
2200
- }
2201
- if (char.search(reLVT) !== -1) {
2202
- type |= CodepointType.LVT;
2203
- }
2204
- if (char.search(reExtPict) !== -1) {
2205
- type |= CodepointType.ExtPict;
2200
+
2201
+ // eslint-disable-next-line no-redeclare
2202
+ var NodeTransforms = {
2203
+ insertNodes(editor, nodes, options) {
2204
+ editor.insertNodes(nodes, options);
2205
+ },
2206
+ liftNodes(editor, options) {
2207
+ editor.liftNodes(options);
2208
+ },
2209
+ mergeNodes(editor, options) {
2210
+ editor.mergeNodes(options);
2211
+ },
2212
+ moveNodes(editor, options) {
2213
+ editor.moveNodes(options);
2214
+ },
2215
+ removeNodes(editor, options) {
2216
+ editor.removeNodes(options);
2217
+ },
2218
+ setNodes(editor, props, options) {
2219
+ editor.setNodes(props, options);
2220
+ },
2221
+ splitNodes(editor, options) {
2222
+ editor.splitNodes(options);
2223
+ },
2224
+ unsetNodes(editor, props, options) {
2225
+ editor.unsetNodes(props, options);
2226
+ },
2227
+ unwrapNodes(editor, options) {
2228
+ editor.unwrapNodes(options);
2229
+ },
2230
+ wrapNodes(editor, element, options) {
2231
+ editor.wrapNodes(element, options);
2206
2232
  }
2207
- return type;
2208
- };
2209
- function intersects(x, y) {
2210
- return (x & y) !== 0;
2211
- }
2212
- var NonBoundaryPairs = [
2213
- // GB6
2214
- [CodepointType.L, CodepointType.L | CodepointType.V | CodepointType.LV | CodepointType.LVT],
2215
- // GB7
2216
- [CodepointType.LV | CodepointType.V, CodepointType.V | CodepointType.T],
2217
- // GB8
2218
- [CodepointType.LVT | CodepointType.T, CodepointType.T],
2219
- // GB9
2220
- [CodepointType.Any, CodepointType.Extend | CodepointType.ZWJ],
2221
- // GB9a
2222
- [CodepointType.Any, CodepointType.SpacingMark],
2223
- // GB9b
2224
- [CodepointType.Prepend, CodepointType.Any],
2225
- // GB11
2226
- [CodepointType.ZWJ, CodepointType.ExtPict],
2227
- // GB12 and GB13
2228
- [CodepointType.RI, CodepointType.RI]];
2229
- function isBoundaryPair(left, right) {
2230
- return NonBoundaryPairs.findIndex(r => intersects(left, r[0]) && intersects(right, r[1])) === -1;
2231
- }
2232
- var endingEmojiZWJ = /(?:[\xA9\xAE\u203C\u2049\u2122\u2139\u2194-\u2199\u21A9\u21AA\u231A\u231B\u2328\u2388\u23CF\u23E9-\u23F3\u23F8-\u23FA\u24C2\u25AA\u25AB\u25B6\u25C0\u25FB-\u25FE\u2600-\u2605\u2607-\u2612\u2614-\u2685\u2690-\u2705\u2708-\u2712\u2714\u2716\u271D\u2721\u2728\u2733\u2734\u2744\u2747\u274C\u274E\u2753-\u2755\u2757\u2763-\u2767\u2795-\u2797\u27A1\u27B0\u27BF\u2934\u2935\u2B05-\u2B07\u2B1B\u2B1C\u2B50\u2B55\u3030\u303D\u3297\u3299]|\uD83C[\uDC00-\uDCFF\uDD0D-\uDD0F\uDD2F\uDD6C-\uDD71\uDD7E\uDD7F\uDD8E\uDD91-\uDD9A\uDDAD-\uDDE5\uDE01-\uDE0F\uDE1A\uDE2F\uDE32-\uDE3A\uDE3C-\uDE3F\uDE49-\uDFFA]|\uD83D[\uDC00-\uDD3D\uDD46-\uDE4F\uDE80-\uDEFF\uDF74-\uDF7F\uDFD5-\uDFFF]|\uD83E[\uDC0C-\uDC0F\uDC48-\uDC4F\uDC5A-\uDC5F\uDC88-\uDC8F\uDCAE-\uDCFF\uDD0C-\uDD3A\uDD3C-\uDD45\uDD47-\uDEFF]|\uD83F[\uDC00-\uDFFD])(?:[\u0300-\u036F\u0483-\u0489\u0591-\u05BD\u05BF\u05C1\u05C2\u05C4\u05C5\u05C7\u0610-\u061A\u064B-\u065F\u0670\u06D6-\u06DC\u06DF-\u06E4\u06E7\u06E8\u06EA-\u06ED\u0711\u0730-\u074A\u07A6-\u07B0\u07EB-\u07F3\u07FD\u0816-\u0819\u081B-\u0823\u0825-\u0827\u0829-\u082D\u0859-\u085B\u0898-\u089F\u08CA-\u08E1\u08E3-\u0902\u093A\u093C\u0941-\u0948\u094D\u0951-\u0957\u0962\u0963\u0981\u09BC\u09BE\u09C1-\u09C4\u09CD\u09D7\u09E2\u09E3\u09FE\u0A01\u0A02\u0A3C\u0A41\u0A42\u0A47\u0A48\u0A4B-\u0A4D\u0A51\u0A70\u0A71\u0A75\u0A81\u0A82\u0ABC\u0AC1-\u0AC5\u0AC7\u0AC8\u0ACD\u0AE2\u0AE3\u0AFA-\u0AFF\u0B01\u0B3C\u0B3E\u0B3F\u0B41-\u0B44\u0B4D\u0B55-\u0B57\u0B62\u0B63\u0B82\u0BBE\u0BC0\u0BCD\u0BD7\u0C00\u0C04\u0C3C\u0C3E-\u0C40\u0C46-\u0C48\u0C4A-\u0C4D\u0C55\u0C56\u0C62\u0C63\u0C81\u0CBC\u0CBF\u0CC2\u0CC6\u0CCC\u0CCD\u0CD5\u0CD6\u0CE2\u0CE3\u0D00\u0D01\u0D3B\u0D3C\u0D3E\u0D41-\u0D44\u0D4D\u0D57\u0D62\u0D63\u0D81\u0DCA\u0DCF\u0DD2-\u0DD4\u0DD6\u0DDF\u0E31\u0E34-\u0E3A\u0E47-\u0E4E\u0EB1\u0EB4-\u0EBC\u0EC8-\u0ECE\u0F18\u0F19\u0F35\u0F37\u0F39\u0F71-\u0F7E\u0F80-\u0F84\u0F86\u0F87\u0F8D-\u0F97\u0F99-\u0FBC\u0FC6\u102D-\u1030\u1032-\u1037\u1039\u103A\u103D\u103E\u1058\u1059\u105E-\u1060\u1071-\u1074\u1082\u1085\u1086\u108D\u109D\u135D-\u135F\u1712-\u1714\u1732\u1733\u1752\u1753\u1772\u1773\u17B4\u17B5\u17B7-\u17BD\u17C6\u17C9-\u17D3\u17DD\u180B-\u180D\u180F\u1885\u1886\u18A9\u1920-\u1922\u1927\u1928\u1932\u1939-\u193B\u1A17\u1A18\u1A1B\u1A56\u1A58-\u1A5E\u1A60\u1A62\u1A65-\u1A6C\u1A73-\u1A7C\u1A7F\u1AB0-\u1ACE\u1B00-\u1B03\u1B34-\u1B3A\u1B3C\u1B42\u1B6B-\u1B73\u1B80\u1B81\u1BA2-\u1BA5\u1BA8\u1BA9\u1BAB-\u1BAD\u1BE6\u1BE8\u1BE9\u1BED\u1BEF-\u1BF1\u1C2C-\u1C33\u1C36\u1C37\u1CD0-\u1CD2\u1CD4-\u1CE0\u1CE2-\u1CE8\u1CED\u1CF4\u1CF8\u1CF9\u1DC0-\u1DFF\u200C\u20D0-\u20F0\u2CEF-\u2CF1\u2D7F\u2DE0-\u2DFF\u302A-\u302F\u3099\u309A\uA66F-\uA672\uA674-\uA67D\uA69E\uA69F\uA6F0\uA6F1\uA802\uA806\uA80B\uA825\uA826\uA82C\uA8C4\uA8C5\uA8E0-\uA8F1\uA8FF\uA926-\uA92D\uA947-\uA951\uA980-\uA982\uA9B3\uA9B6-\uA9B9\uA9BC\uA9BD\uA9E5\uAA29-\uAA2E\uAA31\uAA32\uAA35\uAA36\uAA43\uAA4C\uAA7C\uAAB0\uAAB2-\uAAB4\uAAB7\uAAB8\uAABE\uAABF\uAAC1\uAAEC\uAAED\uAAF6\uABE5\uABE8\uABED\uFB1E\uFE00-\uFE0F\uFE20-\uFE2F\uFF9E\uFF9F]|\uD800[\uDDFD\uDEE0\uDF76-\uDF7A]|\uD802[\uDE01-\uDE03\uDE05\uDE06\uDE0C-\uDE0F\uDE38-\uDE3A\uDE3F\uDEE5\uDEE6]|\uD803[\uDD24-\uDD27\uDEAB\uDEAC\uDEFD-\uDEFF\uDF46-\uDF50\uDF82-\uDF85]|\uD804[\uDC01\uDC38-\uDC46\uDC70\uDC73\uDC74\uDC7F-\uDC81\uDCB3-\uDCB6\uDCB9\uDCBA\uDCC2\uDD00-\uDD02\uDD27-\uDD2B\uDD2D-\uDD34\uDD73\uDD80\uDD81\uDDB6-\uDDBE\uDDC9-\uDDCC\uDDCF\uDE2F-\uDE31\uDE34\uDE36\uDE37\uDE3E\uDE41\uDEDF\uDEE3-\uDEEA\uDF00\uDF01\uDF3B\uDF3C\uDF3E\uDF40\uDF57\uDF66-\uDF6C\uDF70-\uDF74]|\uD805[\uDC38-\uDC3F\uDC42-\uDC44\uDC46\uDC5E\uDCB0\uDCB3-\uDCB8\uDCBA\uDCBD\uDCBF\uDCC0\uDCC2\uDCC3\uDDAF\uDDB2-\uDDB5\uDDBC\uDDBD\uDDBF\uDDC0\uDDDC\uDDDD\uDE33-\uDE3A\uDE3D\uDE3F\uDE40\uDEAB\uDEAD\uDEB0-\uDEB5\uDEB7\uDF1D-\uDF1F\uDF22-\uDF25\uDF27-\uDF2B]|\uD806[\uDC2F-\uDC37\uDC39\uDC3A\uDD30\uDD3B\uDD3C\uDD3E\uDD43\uDDD4-\uDDD7\uDDDA\uDDDB\uDDE0\uDE01-\uDE0A\uDE33-\uDE38\uDE3B-\uDE3E\uDE47\uDE51-\uDE56\uDE59-\uDE5B\uDE8A-\uDE96\uDE98\uDE99]|\uD807[\uDC30-\uDC36\uDC38-\uDC3D\uDC3F\uDC92-\uDCA7\uDCAA-\uDCB0\uDCB2\uDCB3\uDCB5\uDCB6\uDD31-\uDD36\uDD3A\uDD3C\uDD3D\uDD3F-\uDD45\uDD47\uDD90\uDD91\uDD95\uDD97\uDEF3\uDEF4\uDF00\uDF01\uDF36-\uDF3A\uDF40\uDF42]|\uD80D[\uDC40\uDC47-\uDC55]|\uD81A[\uDEF0-\uDEF4\uDF30-\uDF36]|\uD81B[\uDF4F\uDF8F-\uDF92\uDFE4]|\uD82F[\uDC9D\uDC9E]|\uD833[\uDF00-\uDF2D\uDF30-\uDF46]|\uD834[\uDD65\uDD67-\uDD69\uDD6E-\uDD72\uDD7B-\uDD82\uDD85-\uDD8B\uDDAA-\uDDAD\uDE42-\uDE44]|\uD836[\uDE00-\uDE36\uDE3B-\uDE6C\uDE75\uDE84\uDE9B-\uDE9F\uDEA1-\uDEAF]|\uD838[\uDC00-\uDC06\uDC08-\uDC18\uDC1B-\uDC21\uDC23\uDC24\uDC26-\uDC2A\uDC8F\uDD30-\uDD36\uDEAE\uDEEC-\uDEEF]|\uD839[\uDCEC-\uDCEF]|\uD83A[\uDCD0-\uDCD6\uDD44-\uDD4A]|\uD83C[\uDFFB-\uDFFF]|\uDB40[\uDC20-\uDC7F\uDD00-\uDDEF])*\u200D$/;
2233
- var endsWithEmojiZWJ = str => {
2234
- return str.search(endingEmojiZWJ) !== -1;
2235
2233
  };
2236
- var endingRIs = /(?:\uD83C[\uDDE6-\uDDFF])+$/g;
2237
- var endsWithOddNumberOfRIs = str => {
2238
- var match = str.match(endingRIs);
2239
- if (match === null) {
2240
- return false;
2241
- } else {
2242
- // A RI is represented by a surrogate pair.
2243
- var numRIs = match[0].length / 2;
2244
- return numRIs % 2 === 1;
2234
+
2235
+ // eslint-disable-next-line no-redeclare
2236
+ var SelectionTransforms = {
2237
+ collapse(editor, options) {
2238
+ editor.collapse(options);
2239
+ },
2240
+ deselect(editor) {
2241
+ editor.deselect();
2242
+ },
2243
+ move(editor, options) {
2244
+ editor.move(options);
2245
+ },
2246
+ select(editor, target) {
2247
+ editor.select(target);
2248
+ },
2249
+ setPoint(editor, props, options) {
2250
+ editor.setPoint(props, options);
2251
+ },
2252
+ setSelection(editor, props) {
2253
+ editor.setSelection(props);
2245
2254
  }
2246
2255
  };
2247
2256