UNPKG

@atlaskit/editor-plugin-mentions

Version:

Mentions plugin for @atlaskit/editor-core

14 lines 510 B
import { canInsert } from '@atlaskit/editor-prosemirror/utils'; import { mentionPluginKey } from './key'; export function getMentionPluginState(state) { return mentionPluginKey.getState(state); } export const canMentionBeCreatedInRange = (from, to) => state => { const $from = state.doc.resolve(from); const $to = state.doc.resolve(to); const mention = state.schema.nodes.mention.createChecked(); if ($from.parent === $to.parent && canInsert($from, mention)) { return true; } return false; };