UNPKG

@atlaskit/editor-plugin-selection-extension

Version:

editor-plugin-selection-extension plugin for @atlaskit/editor-core

21 lines 497 B
import { Node } from '@atlaskit/editor-prosemirror/model'; export const insertAdfAtEndOfDoc = nodeAdf => (state, dispatch) => { const { tr, schema } = state; try { const docEnd = state.doc.content.size; const modifiedNode = Node.fromJSON(schema, nodeAdf); modifiedNode.check(); tr.insert(tr.mapping.map(docEnd), modifiedNode).scrollIntoView(); dispatch(tr); return { status: 'success' }; } catch { return { status: 'failed' }; } };