From 21d0f4a233012857d22dd95a8238bee89f25093a Mon Sep 17 00:00:00 2001 From: Akumatus Date: Sun, 22 Sep 2019 01:48:25 +0800 Subject: [PATCH] Replace deprecated findDOMNode with editor.findDOMNode in cloneFragment (#3018) --- packages/slate-react/src/utils/clone-fragment.js | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/packages/slate-react/src/utils/clone-fragment.js b/packages/slate-react/src/utils/clone-fragment.js index 4a9759ef5..ddf9ccb7b 100644 --- a/packages/slate-react/src/utils/clone-fragment.js +++ b/packages/slate-react/src/utils/clone-fragment.js @@ -7,7 +7,6 @@ import { Value } from 'slate' import TRANSFER_TYPES from '../constants/transfer-types' import removeAllRanges from './remove-all-ranges' -import findDOMNode from './find-dom-node' import DATA_ATTRS from '../constants/data-attributes' import SELECTORS from '../constants/selectors' @@ -56,9 +55,13 @@ function cloneFragment(event, editor, callback = () => undefined) { // content, since the spacer is before void's content in the DOM. if (endVoid) { const r = range.cloneRange() - const node = findDOMNode(endVoid, window) - r.setEndAfter(node) - contents = r.cloneContents() + const path = document.getPath(endVoid.key) + + if (path) { + const node = editor.findDOMNode(path) + r.setEndAfter(node) + contents = r.cloneContents() + } } // COMPAT: If the start node is a void node, we need to attach the encoded