slate-react 0.82.1 → 0.82.2-2022864247
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/components/element.d.ts.map +1 -1
- package/dist/index.es.js +15 -16
- package/dist/index.es.js.map +1 -1
- package/dist/index.js +14 -15
- package/dist/index.js.map +1 -1
- package/dist/slate-react.js +14 -15
- package/dist/slate-react.min.js +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1600,11 +1600,23 @@ var Element = function Element(props) {
|
|
|
1600
1600
|
renderPlaceholder = props.renderPlaceholder,
|
|
1601
1601
|
renderLeaf = props.renderLeaf,
|
|
1602
1602
|
selection = props.selection;
|
|
1603
|
-
var ref = React.useRef(null);
|
|
1604
1603
|
var editor = useSlateStatic();
|
|
1605
1604
|
var readOnly = useReadOnly();
|
|
1606
1605
|
var isInline = editor.isInline(element);
|
|
1607
1606
|
var key = ReactEditor.findKey(editor, element);
|
|
1607
|
+
var ref = React.useCallback(function (ref) {
|
|
1608
|
+
// Update element-related weak maps with the DOM element ref.
|
|
1609
|
+
var KEY_TO_ELEMENT = EDITOR_TO_KEY_TO_ELEMENT.get(editor);
|
|
1610
|
+
|
|
1611
|
+
if (ref) {
|
|
1612
|
+
KEY_TO_ELEMENT === null || KEY_TO_ELEMENT === void 0 ? void 0 : KEY_TO_ELEMENT.set(key, ref);
|
|
1613
|
+
NODE_TO_ELEMENT.set(element, ref);
|
|
1614
|
+
ELEMENT_TO_NODE.set(ref, element);
|
|
1615
|
+
} else {
|
|
1616
|
+
KEY_TO_ELEMENT === null || KEY_TO_ELEMENT === void 0 ? void 0 : KEY_TO_ELEMENT["delete"](key);
|
|
1617
|
+
NODE_TO_ELEMENT["delete"](element);
|
|
1618
|
+
}
|
|
1619
|
+
}, [editor, key, element]);
|
|
1608
1620
|
var children = useChildren({
|
|
1609
1621
|
decorations: decorations,
|
|
1610
1622
|
node: element,
|
|
@@ -1667,21 +1679,8 @@ var Element = function Element(props) {
|
|
|
1667
1679
|
}));
|
|
1668
1680
|
NODE_TO_INDEX.set(_text, 0);
|
|
1669
1681
|
NODE_TO_PARENT.set(_text, element);
|
|
1670
|
-
}
|
|
1671
|
-
|
|
1672
|
-
|
|
1673
|
-
useIsomorphicLayoutEffect(function () {
|
|
1674
|
-
var KEY_TO_ELEMENT = EDITOR_TO_KEY_TO_ELEMENT.get(editor);
|
|
1682
|
+
}
|
|
1675
1683
|
|
|
1676
|
-
if (ref.current) {
|
|
1677
|
-
KEY_TO_ELEMENT === null || KEY_TO_ELEMENT === void 0 ? void 0 : KEY_TO_ELEMENT.set(key, ref.current);
|
|
1678
|
-
NODE_TO_ELEMENT.set(element, ref.current);
|
|
1679
|
-
ELEMENT_TO_NODE.set(ref.current, element);
|
|
1680
|
-
} else {
|
|
1681
|
-
KEY_TO_ELEMENT === null || KEY_TO_ELEMENT === void 0 ? void 0 : KEY_TO_ELEMENT["delete"](key);
|
|
1682
|
-
NODE_TO_ELEMENT["delete"](element);
|
|
1683
|
-
}
|
|
1684
|
-
});
|
|
1685
1684
|
return renderElement({
|
|
1686
1685
|
attributes: attributes,
|
|
1687
1686
|
children: children,
|