diff --git a/packages/core/src/editor/plugins/with-event-data.ts b/packages/core/src/editor/plugins/with-event-data.ts index c6576909c..3412a1ba4 100644 --- a/packages/core/src/editor/plugins/with-event-data.ts +++ b/packages/core/src/editor/plugins/with-event-data.ts @@ -11,7 +11,6 @@ import { isDOMText, getPlainText } from '../../utils/dom' export const withEventData = (editor: T) => { const e = editor as T & IDomEditor - const { insertText, insertFragment } = e e.setFragmentData = (data: Pick) => { const { selection } = e @@ -102,6 +101,7 @@ export const withEventData = (editor: T) => { e.insertData = (data: DataTransfer) => { const fragment = data.getData('application/x-slate-fragment') + // 只有从编辑器中内复制的内容,才会获取 fragment,从其他地方粘贴到编辑器中,不会获取 fragment if (fragment) { const decoded = decodeURIComponent(window.atob(fragment)) const parsed = JSON.parse(decoded) as Node[] @@ -127,7 +127,7 @@ export const withEventData = (editor: T) => { Transforms.splitNodes(e, { always: true }) } - insertText(line) + e.insertText(line) split = true } return