slate-react 0.91.0-202319185818 → 0.91.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 +35 -6
- package/dist/index.es.js.map +1 -1
- package/dist/index.js +39 -10
- package/dist/index.js.map +1 -1
- package/dist/slate-react.js +39 -10
- package/dist/slate-react.min.js +1 -1
- package/dist/utils/range-list.d.ts +9 -1
- package/dist/utils/range-list.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/index.es.js
CHANGED
|
@@ -1120,6 +1120,14 @@ var useIsomorphicLayoutEffect = CAN_USE_DOM ? useLayoutEffect : useEffect;
|
|
|
1120
1120
|
var _excluded$3 = ["anchor", "focus"],
|
|
1121
1121
|
_excluded2$1 = ["anchor", "focus"];
|
|
1122
1122
|
var shallowCompare = (obj1, obj2) => Object.keys(obj1).length === Object.keys(obj2).length && Object.keys(obj1).every(key => obj2.hasOwnProperty(key) && obj1[key] === obj2[key]);
|
|
1123
|
+
|
|
1124
|
+
var isDecorationFlagsEqual = (range, other) => {
|
|
1125
|
+
var rangeOwnProps = _objectWithoutProperties(range, _excluded$3);
|
|
1126
|
+
|
|
1127
|
+
var otherOwnProps = _objectWithoutProperties(other, _excluded2$1);
|
|
1128
|
+
|
|
1129
|
+
return range[PLACEHOLDER_SYMBOL] === other[PLACEHOLDER_SYMBOL] && shallowCompare(rangeOwnProps, otherOwnProps);
|
|
1130
|
+
};
|
|
1123
1131
|
/**
|
|
1124
1132
|
* Check if a list of decorator ranges are equal to another.
|
|
1125
1133
|
*
|
|
@@ -1128,7 +1136,8 @@ var shallowCompare = (obj1, obj2) => Object.keys(obj1).length === Object.keys(ob
|
|
|
1128
1136
|
* kept in order, and the odd case where they aren't is okay to re-render for.
|
|
1129
1137
|
*/
|
|
1130
1138
|
|
|
1131
|
-
|
|
1139
|
+
|
|
1140
|
+
var isElementDecorationsEqual = (list, another) => {
|
|
1132
1141
|
if (list.length !== another.length) {
|
|
1133
1142
|
return false;
|
|
1134
1143
|
}
|
|
@@ -1137,11 +1146,31 @@ var isDecoratorRangeListEqual = (list, another) => {
|
|
|
1137
1146
|
var range = list[i];
|
|
1138
1147
|
var other = another[i];
|
|
1139
1148
|
|
|
1140
|
-
|
|
1149
|
+
if (!Range.equals(range, other) || !isDecorationFlagsEqual(range, other)) {
|
|
1150
|
+
return false;
|
|
1151
|
+
}
|
|
1152
|
+
}
|
|
1153
|
+
|
|
1154
|
+
return true;
|
|
1155
|
+
};
|
|
1156
|
+
/**
|
|
1157
|
+
* Check if a list of decorator ranges are equal to another.
|
|
1158
|
+
*
|
|
1159
|
+
* PERF: this requires the two lists to also have the ranges inside them in the
|
|
1160
|
+
* same order, but this is an okay constraint for us since decorations are
|
|
1161
|
+
* kept in order, and the odd case where they aren't is okay to re-render for.
|
|
1162
|
+
*/
|
|
1163
|
+
|
|
1164
|
+
var isTextDecorationsEqual = (list, another) => {
|
|
1165
|
+
if (list.length !== another.length) {
|
|
1166
|
+
return false;
|
|
1167
|
+
}
|
|
1141
1168
|
|
|
1142
|
-
|
|
1169
|
+
for (var i = 0; i < list.length; i++) {
|
|
1170
|
+
var range = list[i];
|
|
1171
|
+
var other = another[i]; // compare only offsets because paths doesn't matter for text
|
|
1143
1172
|
|
|
1144
|
-
if (
|
|
1173
|
+
if (range.anchor.offset !== other.anchor.offset || range.focus.offset !== other.focus.offset || !isDecorationFlagsEqual(range, other)) {
|
|
1145
1174
|
return false;
|
|
1146
1175
|
}
|
|
1147
1176
|
}
|
|
@@ -1462,7 +1491,7 @@ var Text = props => {
|
|
|
1462
1491
|
};
|
|
1463
1492
|
|
|
1464
1493
|
var MemoizedText = /*#__PURE__*/React.memo(Text, (prev, next) => {
|
|
1465
|
-
return next.parent === prev.parent && next.isLast === prev.isLast && next.renderLeaf === prev.renderLeaf && next.text === prev.text &&
|
|
1494
|
+
return next.parent === prev.parent && next.isLast === prev.isLast && next.renderLeaf === prev.renderLeaf && next.text === prev.text && isTextDecorationsEqual(next.decorations, prev.decorations);
|
|
1466
1495
|
});
|
|
1467
1496
|
|
|
1468
1497
|
/**
|
|
@@ -1562,7 +1591,7 @@ var Element = props => {
|
|
|
1562
1591
|
};
|
|
1563
1592
|
|
|
1564
1593
|
var MemoizedElement = /*#__PURE__*/React.memo(Element, (prev, next) => {
|
|
1565
|
-
return prev.element === next.element && prev.renderElement === next.renderElement && prev.renderLeaf === next.renderLeaf &&
|
|
1594
|
+
return prev.element === next.element && prev.renderElement === next.renderElement && prev.renderLeaf === next.renderLeaf && isElementDecorationsEqual(prev.decorations, next.decorations) && (prev.selection === next.selection || !!prev.selection && !!next.selection && Range.equals(prev.selection, next.selection));
|
|
1566
1595
|
});
|
|
1567
1596
|
/**
|
|
1568
1597
|
* The default element renderer.
|