slate-react 0.66.6 → 0.67.0-202191204438
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 +17 -0
- package/dist/index.es.js +23 -60
- package/dist/index.es.js.map +1 -1
- package/dist/index.js +29 -64
- package/dist/index.js.map +1 -1
- package/dist/plugin/react-editor.d.ts.map +1 -1
- package/dist/slate-react.js +29 -64
- package/dist/slate-react.min.js +1 -1
- package/package.json +4 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,22 @@
|
|
|
1
1
|
# slate-react
|
|
2
2
|
|
|
3
|
+
## 0.67.0-202191204438
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [#4540](https://github.com/ianstormtaylor/slate/pull/4540) [`11ef83b4`](https://github.com/ianstormtaylor/slate/commit/11ef83b47fca84d1f908b5c9eeefada516fe9fed) Thanks [@bryanph](https://github.com/bryanph)! - The Slate Provider's "value" prop is now only used as initial state for editor.children as was intended before. If your code relies on replacing editor.children you should do so by replacing it directly instead of relying on the "value" prop to do this for you.
|
|
8
|
+
|
|
9
|
+
### Patch Changes
|
|
10
|
+
|
|
11
|
+
- Updated dependencies []:
|
|
12
|
+
- slate@0.66.5-202191204438
|
|
13
|
+
|
|
14
|
+
## 0.66.7
|
|
15
|
+
|
|
16
|
+
### Patch Changes
|
|
17
|
+
|
|
18
|
+
- [#4588](https://github.com/ianstormtaylor/slate/pull/4588) [`ae65ae5f`](https://github.com/ianstormtaylor/slate/commit/ae65ae5f717c877eee0e3f839b76fc18d8b44999) Thanks [@jaked](https://github.com/jaked)! - revert #4455 / #4512; fix triple-click by unhanging range with void
|
|
19
|
+
|
|
3
20
|
## 0.66.6
|
|
4
21
|
|
|
5
22
|
### Patch Changes
|
package/dist/index.es.js
CHANGED
|
@@ -2594,61 +2594,11 @@ var ReactEditor = {
|
|
|
2594
2594
|
anchorNode = domRange.anchorNode;
|
|
2595
2595
|
anchorOffset = domRange.anchorOffset;
|
|
2596
2596
|
focusNode = domRange.focusNode;
|
|
2597
|
-
focusOffset = domRange.focusOffset; //
|
|
2598
|
-
// focus node is the next element sibling and focusOffset is 0.
|
|
2599
|
-
// This will highlight the corresponding toolbar button for the sibling
|
|
2600
|
-
// block even though users just want to target the previous block.
|
|
2601
|
-
// (2021/08/24)
|
|
2602
|
-
// Signs of a triple click in Chrome
|
|
2603
|
-
// - anchor node will be a text node but focus node won't
|
|
2604
|
-
// - both anchorOffset and focusOffset are 0
|
|
2605
|
-
// - focusNode value will be null since Chrome tries to extend to just the
|
|
2606
|
-
// beginning of the next block
|
|
2607
|
-
|
|
2608
|
-
if (IS_CHROME && anchorNode && focusNode && anchorNode.nodeType !== focusNode.nodeType && domRange.anchorOffset === 0 && domRange.focusOffset === 0 && focusNode.nodeValue == null) {
|
|
2609
|
-
// If an anchorNode is an element node when triple clicked, then the focusNode
|
|
2610
|
-
// should also be the same as anchorNode when triple clicked.
|
|
2611
|
-
// Otherwise, anchorNode is a text node and we need to
|
|
2612
|
-
// - climb up the DOM tree to get the farthest element node that receives
|
|
2613
|
-
// triple click. It should have atribute 'data-slate-node' = "element"
|
|
2614
|
-
// - get the last child of that element node
|
|
2615
|
-
// - climb down the DOM tree to get the text node of the last child
|
|
2616
|
-
// - this is also the end of the selection aka the focusNode
|
|
2617
|
-
var anchorElement = anchorNode.parentNode;
|
|
2618
|
-
var selectedBlock = anchorElement.closest('[data-slate-node="element"]');
|
|
2619
|
-
|
|
2620
|
-
if (selectedBlock) {
|
|
2621
|
-
// The Slate Text nodes are leaf-level and contains document's text.
|
|
2622
|
-
// However, when represented in the DOM, they are actually Element nodes
|
|
2623
|
-
// and different from the DOM's Text nodes
|
|
2624
|
-
var {
|
|
2625
|
-
childElementCount: slateTextNodeCount
|
|
2626
|
-
} = selectedBlock;
|
|
2627
|
-
|
|
2628
|
-
if (slateTextNodeCount === 1) {
|
|
2629
|
-
focusNode = anchorNode;
|
|
2630
|
-
focusOffset = focusNode.length;
|
|
2631
|
-
} else if (slateTextNodeCount > 1) {
|
|
2632
|
-
// A element with attribute data-slate-node="element" can have multiple
|
|
2633
|
-
// children with attribute data-slate-node="text". But these children only have
|
|
2634
|
-
// one child at each level.
|
|
2635
|
-
// <span data-slate-node="text">
|
|
2636
|
-
// <span data-slate-leaf="">
|
|
2637
|
-
// <span data-slate-string=""></span>
|
|
2638
|
-
// </span>
|
|
2639
|
-
// </span>
|
|
2640
|
-
var focusElement = selectedBlock.lastElementChild;
|
|
2641
|
-
var nodeIterator = document.createNodeIterator(focusElement, NodeFilter.SHOW_TEXT);
|
|
2642
|
-
focusNode = nodeIterator.nextNode();
|
|
2643
|
-
focusOffset = focusNode.length;
|
|
2644
|
-
}
|
|
2645
|
-
}
|
|
2646
|
-
} // COMPAT: There's a bug in chrome that always returns `true` for
|
|
2597
|
+
focusOffset = domRange.focusOffset; // COMPAT: There's a bug in chrome that always returns `true` for
|
|
2647
2598
|
// `isCollapsed` for a Selection that comes from a ShadowRoot.
|
|
2648
2599
|
// (2020/08/08)
|
|
2649
2600
|
// https://bugs.chromium.org/p/chromium/issues/detail?id=447523
|
|
2650
2601
|
|
|
2651
|
-
|
|
2652
2602
|
if (IS_CHROME && hasShadowRoot()) {
|
|
2653
2603
|
isCollapsed = domRange.anchorNode === domRange.focusNode && domRange.anchorOffset === domRange.focusOffset;
|
|
2654
2604
|
} else {
|
|
@@ -2679,10 +2629,24 @@ var ReactEditor = {
|
|
|
2679
2629
|
return null;
|
|
2680
2630
|
}
|
|
2681
2631
|
|
|
2682
|
-
|
|
2683
|
-
anchor,
|
|
2684
|
-
focus
|
|
2685
|
-
};
|
|
2632
|
+
var range = {
|
|
2633
|
+
anchor: anchor,
|
|
2634
|
+
focus: focus
|
|
2635
|
+
}; // if the selection is a hanging range that ends in a void
|
|
2636
|
+
// and the DOM focus is an Element
|
|
2637
|
+
// (meaning that the selection ends before the element)
|
|
2638
|
+
// unhang the range to avoid mistakenly including the void
|
|
2639
|
+
|
|
2640
|
+
if (Range.isExpanded(range) && Range.isForward(range) && isDOMElement(focusNode) && Editor.void(editor, {
|
|
2641
|
+
at: range.focus,
|
|
2642
|
+
mode: 'highest'
|
|
2643
|
+
})) {
|
|
2644
|
+
range = Editor.unhangRange(editor, range, {
|
|
2645
|
+
voids: true
|
|
2646
|
+
});
|
|
2647
|
+
}
|
|
2648
|
+
|
|
2649
|
+
return range;
|
|
2686
2650
|
},
|
|
2687
2651
|
|
|
2688
2652
|
hasRange(editor, range) {
|
|
@@ -3720,8 +3684,7 @@ var Slate = props => {
|
|
|
3720
3684
|
} = props,
|
|
3721
3685
|
rest = _objectWithoutProperties(props, _excluded);
|
|
3722
3686
|
|
|
3723
|
-
var [
|
|
3724
|
-
var context = useMemo(() => {
|
|
3687
|
+
var [context, setContext] = React.useState(() => {
|
|
3725
3688
|
if (!Node.isNodeList(value)) {
|
|
3726
3689
|
throw new Error("[Slate] value is invalid! Expected a list of elements" + "but got: ".concat(JSON.stringify(value)));
|
|
3727
3690
|
}
|
|
@@ -3733,11 +3696,11 @@ var Slate = props => {
|
|
|
3733
3696
|
editor.children = value;
|
|
3734
3697
|
Object.assign(editor, rest);
|
|
3735
3698
|
return [editor];
|
|
3736
|
-
}
|
|
3699
|
+
});
|
|
3737
3700
|
var onContextChange = useCallback(() => {
|
|
3738
3701
|
onChange(editor.children);
|
|
3739
|
-
|
|
3740
|
-
}, [
|
|
3702
|
+
setContext([editor]);
|
|
3703
|
+
}, [onChange]);
|
|
3741
3704
|
EDITOR_TO_ON_CHANGE.set(editor, onContextChange);
|
|
3742
3705
|
useEffect(() => {
|
|
3743
3706
|
return () => {
|