slate 0.67.1 → 0.70.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/CHANGELOG.md +10 -0
- package/dist/index.es.js +71 -130
- package/dist/index.es.js.map +1 -1
- package/dist/index.js +78 -136
- package/dist/index.js.map +1 -1
- package/dist/slate.js +78 -136
- package/dist/slate.min.js +2 -2
- package/dist/transforms/node.d.ts +1 -1
- package/dist/transforms/node.d.ts.map +1 -1
- package/dist/utils/string.d.ts +0 -3
- package/dist/utils/string.d.ts.map +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,15 @@
|
|
|
1
1
|
# slate
|
|
2
2
|
|
|
3
|
+
## 0.70.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [#4565](https://github.com/ianstormtaylor/slate/pull/4565) [`5818aca5`](https://github.com/ianstormtaylor/slate/commit/5818aca5038f38465a5769fe944f184be0255341) Thanks [@oliger](https://github.com/oliger)! - Fix issue with unicode 1.1 smileys followed by a variation selector.
|
|
8
|
+
|
|
9
|
+
### Patch Changes
|
|
10
|
+
|
|
11
|
+
- [#4638](https://github.com/ianstormtaylor/slate/pull/4638) [`e0f41514`](https://github.com/ianstormtaylor/slate/commit/e0f41514a1e0e866297904be16eff82702e8afd8) Thanks [@e1himself](https://github.com/e1himself)! - Improve typescript type of `props` argument of `Transforms.setNodes()`
|
|
12
|
+
|
|
3
13
|
## 0.67.1
|
|
4
14
|
|
|
5
15
|
### Patch Changes
|
package/dist/index.es.js
CHANGED
|
@@ -462,135 +462,121 @@ var CHAMELEON = /['\u2018\u2019]/;
|
|
|
462
462
|
* Get the distance to the end of the first character in a string of text.
|
|
463
463
|
*/
|
|
464
464
|
|
|
465
|
+
var CodepointType;
|
|
466
|
+
|
|
467
|
+
(function (CodepointType) {
|
|
468
|
+
// ZWJ sequences consist of multiple emojis separated by ZWJ character. They
|
|
469
|
+
// are used to combine multiple emojis into one emoji.
|
|
470
|
+
// https://en.wikipedia.org/wiki/Zero-width_joiner
|
|
471
|
+
CodepointType[CodepointType["ZeroWidthJoiner"] = 0] = "ZeroWidthJoiner"; // Kecap sequences consit of a digit, an asterisk or a number sign followed by
|
|
472
|
+
// the Combining Enclosing Keycap character. They are used to create emoji
|
|
473
|
+
// with a keycap appearance. https://emojipedia.org/emoji-keycap-sequence
|
|
474
|
+
|
|
475
|
+
CodepointType[CodepointType["Keycap"] = 1] = "Keycap"; // Modifiers are used in ZWJ sequences to apply a skin tone to an emoji.
|
|
476
|
+
// https://en.wikipedia.org/wiki/Emoticons_(Unicode_block)#Emoji_modifiers
|
|
477
|
+
|
|
478
|
+
CodepointType[CodepointType["Modifier"] = 2] = "Modifier"; // Variation selectors are used to specify if a character should be displayed
|
|
479
|
+
// as text or as an emoji.
|
|
480
|
+
|
|
481
|
+
CodepointType[CodepointType["VariationSelector"] = 3] = "VariationSelector"; // Flag sequences consist of a pair of regional indicators.
|
|
482
|
+
// https://en.wikipedia.org/wiki/Regional_indicator_symbol
|
|
483
|
+
|
|
484
|
+
CodepointType[CodepointType["RegionalIndicator"] = 4] = "RegionalIndicator"; // Tag sequences consist of a Black Flag emoji followed by a series of Tag
|
|
485
|
+
// codepoints, then the Cancel Tag codepoint.
|
|
486
|
+
// https://en.wikipedia.org/wiki/Tags_(Unicode_block)
|
|
487
|
+
|
|
488
|
+
CodepointType[CodepointType["Tag"] = 5] = "Tag";
|
|
489
|
+
CodepointType[CodepointType["Character"] = 6] = "Character";
|
|
490
|
+
})(CodepointType || (CodepointType = {}));
|
|
491
|
+
|
|
465
492
|
var getCharacterDistance = function getCharacterDistance(str) {
|
|
466
493
|
var isRTL = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
494
|
+
var codepoints = isRTL ? codepointsIteratorRTL(str) : str;
|
|
467
495
|
var isLTR = !isRTL;
|
|
468
|
-
var
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
// ZWJ: zero width joiner
|
|
472
|
-
// VAR: variation selector
|
|
473
|
-
// BMP: sequenceable codepoint from basic multilingual plane
|
|
474
|
-
// RI: regional indicator
|
|
475
|
-
// KC: keycap
|
|
476
|
-
// TAG: tag
|
|
477
|
-
|
|
478
|
-
var prev = null;
|
|
479
|
-
var codepoints = isLTR ? str : codepointsIteratorRTL(str);
|
|
496
|
+
var [isKeycapStart, isKeycapEnd, isTagStart, isTagEnd] = isLTR ? [isKeycap, isCombiningEnclosingKeycap, isBlackFlag, isCancelTag] : [isCombiningEnclosingKeycap, isKeycap, isCancelTag, isBlackFlag];
|
|
497
|
+
var distance = 0;
|
|
498
|
+
var previousType = null;
|
|
480
499
|
|
|
481
500
|
for (var codepoint of codepoints) {
|
|
482
501
|
var code = codepoint.codePointAt(0);
|
|
483
|
-
if (!code) break;
|
|
502
|
+
if (!code) break;
|
|
503
|
+
|
|
504
|
+
if (isLTR && previousType === CodepointType.VariationSelector && !isZWJ(code) && !isKeycapEnd(code)) {
|
|
505
|
+
break;
|
|
506
|
+
}
|
|
484
507
|
|
|
485
508
|
if (isZWJ(code)) {
|
|
486
|
-
|
|
487
|
-
|
|
509
|
+
distance += codepoint.length;
|
|
510
|
+
previousType = CodepointType.ZeroWidthJoiner;
|
|
488
511
|
continue;
|
|
489
512
|
}
|
|
490
513
|
|
|
491
|
-
var [isKeycapStart, isKeycapEnd] = isLTR ? [isKeycap, isCombiningEnclosingKeycap] : [isCombiningEnclosingKeycap, isKeycap];
|
|
492
|
-
|
|
493
514
|
if (isKeycapStart(code)) {
|
|
494
|
-
if (
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
dist += codepoint.length;
|
|
499
|
-
prev = 'KC';
|
|
515
|
+
if (previousType === CodepointType.Keycap) break;
|
|
516
|
+
distance += codepoint.length;
|
|
517
|
+
previousType = CodepointType.Keycap;
|
|
500
518
|
continue;
|
|
501
519
|
}
|
|
502
520
|
|
|
503
521
|
if (isKeycapEnd(code)) {
|
|
504
|
-
|
|
522
|
+
distance += codepoint.length;
|
|
505
523
|
break;
|
|
506
524
|
}
|
|
507
525
|
|
|
508
526
|
if (isVariationSelector(code)) {
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
break;
|
|
513
|
-
}
|
|
514
|
-
|
|
515
|
-
prev = 'VAR';
|
|
516
|
-
continue;
|
|
517
|
-
}
|
|
518
|
-
|
|
519
|
-
if (isBMPEmoji(code)) {
|
|
520
|
-
if (isLTR && prev && prev !== 'ZWJ' && prev !== 'VAR') {
|
|
521
|
-
break;
|
|
522
|
-
}
|
|
523
|
-
|
|
524
|
-
dist += codepoint.length;
|
|
525
|
-
|
|
526
|
-
if (isRTL && prev === 'VAR') {
|
|
527
|
-
break;
|
|
528
|
-
}
|
|
529
|
-
|
|
530
|
-
prev = 'BMP';
|
|
527
|
+
if (isRTL && previousType === CodepointType.Character) break;
|
|
528
|
+
distance += codepoint.length;
|
|
529
|
+
previousType = CodepointType.VariationSelector;
|
|
531
530
|
continue;
|
|
532
531
|
}
|
|
533
532
|
|
|
534
533
|
if (isModifier(code)) {
|
|
535
|
-
|
|
536
|
-
|
|
534
|
+
distance += codepoint.length;
|
|
535
|
+
previousType = CodepointType.Modifier;
|
|
537
536
|
continue;
|
|
538
537
|
}
|
|
539
538
|
|
|
540
|
-
var [isTagStart, isTagEnd] = isLTR ? [isBlackFlag, isCancelTag] : [isCancelTag, isBlackFlag];
|
|
541
|
-
|
|
542
539
|
if (isTagStart(code)) {
|
|
543
|
-
if (
|
|
544
|
-
|
|
545
|
-
|
|
540
|
+
if (previousType === CodepointType.Tag) break;
|
|
541
|
+
distance += codepoint.length;
|
|
542
|
+
previousType = CodepointType.Tag;
|
|
546
543
|
continue;
|
|
547
544
|
}
|
|
548
545
|
|
|
549
|
-
if (
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
}
|
|
553
|
-
|
|
554
|
-
if (prev === 'TAG' && isTag(code)) {
|
|
555
|
-
dist += codepoint.length;
|
|
556
|
-
continue;
|
|
557
|
-
}
|
|
558
|
-
|
|
559
|
-
if (isRegionalIndicator(code)) {
|
|
560
|
-
dist += codepoint.length;
|
|
561
|
-
|
|
562
|
-
if (prev === 'RI') {
|
|
546
|
+
if (previousType === CodepointType.Tag) {
|
|
547
|
+
if (isTagEnd(code)) {
|
|
548
|
+
distance += codepoint.length;
|
|
563
549
|
break;
|
|
564
550
|
}
|
|
565
551
|
|
|
566
|
-
|
|
567
|
-
|
|
552
|
+
if (isTag(code)) {
|
|
553
|
+
distance += codepoint.length;
|
|
554
|
+
continue;
|
|
555
|
+
}
|
|
556
|
+
|
|
557
|
+
break;
|
|
568
558
|
}
|
|
569
559
|
|
|
570
|
-
if (
|
|
571
|
-
|
|
572
|
-
// sequence.
|
|
573
|
-
if (prev === 'NSEQ') {
|
|
560
|
+
if (isRegionalIndicator(code)) {
|
|
561
|
+
if (previousType && previousType !== CodepointType.RegionalIndicator) {
|
|
574
562
|
break;
|
|
575
563
|
}
|
|
576
564
|
|
|
577
|
-
|
|
578
|
-
|
|
565
|
+
distance += codepoint.length;
|
|
566
|
+
if (previousType === CodepointType.RegionalIndicator) break;
|
|
567
|
+
previousType = CodepointType.RegionalIndicator;
|
|
579
568
|
continue;
|
|
580
|
-
} //
|
|
581
|
-
//
|
|
569
|
+
} // If previous and curent codepoints are regular characters. it means we are
|
|
570
|
+
// not in a sequence.
|
|
582
571
|
|
|
583
572
|
|
|
584
|
-
if (
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
break;
|
|
573
|
+
if (previousType === CodepointType.Character) break;
|
|
574
|
+
distance += codepoint.length;
|
|
575
|
+
previousType = CodepointType.Character;
|
|
576
|
+
continue;
|
|
591
577
|
}
|
|
592
578
|
|
|
593
|
-
return
|
|
579
|
+
return distance || 1;
|
|
594
580
|
};
|
|
595
581
|
/**
|
|
596
582
|
* Get the distance to the end of the first word in a string of text.
|
|
@@ -703,41 +689,6 @@ var isKeycap = code => {
|
|
|
703
689
|
var isCombiningEnclosingKeycap = code => {
|
|
704
690
|
return code === 0x20e3;
|
|
705
691
|
};
|
|
706
|
-
/**
|
|
707
|
-
* Is `code` one of the BMP codes used in emoji sequences.
|
|
708
|
-
*
|
|
709
|
-
* https://emojipedia.org/emoji-zwj-sequences/
|
|
710
|
-
*/
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
var isBMPEmoji = code => {
|
|
714
|
-
// This requires tiny bit of maintanance, better ideas?
|
|
715
|
-
// Fortunately it only happens if new Unicode Standard
|
|
716
|
-
// is released. Fails gracefully if upkeep lags behind,
|
|
717
|
-
// same way Slate previously behaved with all emojis.
|
|
718
|
-
return code === 0x2764 || // heart (❤)
|
|
719
|
-
code === 0x2642 || // male (♂)
|
|
720
|
-
code === 0x2640 || // female (♀)
|
|
721
|
-
code === 0x2620 || // scull (☠)
|
|
722
|
-
code === 0x2695 || // medical (⚕)
|
|
723
|
-
code === 0x2708 || // plane (✈️)
|
|
724
|
-
code === 0x25ef || // large circle (◯)
|
|
725
|
-
code === 0x2b06 || // up arrow (⬆)
|
|
726
|
-
code === 0x2197 || // up-right arrow (↗)
|
|
727
|
-
code === 0x27a1 || // right arrow (➡)
|
|
728
|
-
code === 0x2198 || // down-right arrow (↘)
|
|
729
|
-
code === 0x2b07 || // down arrow (⬇)
|
|
730
|
-
code === 0x2199 || // down-left arrow (↙)
|
|
731
|
-
code === 0x2b05 || // left arrow (⬅)
|
|
732
|
-
code === 0x2196 || // up-left arrow (↖)
|
|
733
|
-
code === 0x2195 || // up-down arrow (↕)
|
|
734
|
-
code === 0x2194 || // left-right arrow (↔)
|
|
735
|
-
code === 0x21a9 || // right arrow curving left (↩)
|
|
736
|
-
code === 0x21aa || // left arrow curving right (↪)
|
|
737
|
-
code === 0x2934 || // right arrow curving up (⤴)
|
|
738
|
-
code === 0x2935 // right arrow curving down (⤵)
|
|
739
|
-
;
|
|
740
|
-
};
|
|
741
692
|
/**
|
|
742
693
|
* Is `code` a Regional Indicator.
|
|
743
694
|
*
|
|
@@ -748,16 +699,6 @@ var isBMPEmoji = code => {
|
|
|
748
699
|
var isRegionalIndicator = code => {
|
|
749
700
|
return code >= 0x1f1e6 && code <= 0x1f1ff;
|
|
750
701
|
};
|
|
751
|
-
/**
|
|
752
|
-
* Is `code` from basic multilingual plane.
|
|
753
|
-
*
|
|
754
|
-
* https://codepoints.net/basic_multilingual_plane
|
|
755
|
-
*/
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
var isBMP = code => {
|
|
759
|
-
return code <= 0xffff;
|
|
760
|
-
};
|
|
761
702
|
/**
|
|
762
703
|
* Is `code` a Zero Width Joiner.
|
|
763
704
|
*
|