@atlaskit/editor-plugin-mentions
Version:
Mentions plugin for @atlaskit/editor-core
16 lines • 572 B
JavaScript
import { canInsert } from '@atlaskit/editor-prosemirror/utils';
import { mentionPluginKey } from './key';
export function getMentionPluginState(state) {
return mentionPluginKey.getState(state);
}
export var canMentionBeCreatedInRange = function canMentionBeCreatedInRange(from, to) {
return function (state) {
var $from = state.doc.resolve(from);
var $to = state.doc.resolve(to);
var mention = state.schema.nodes.mention.createChecked();
if ($from.parent === $to.parent && canInsert($from, mention)) {
return true;
}
return false;
};
};