@atlaskit/editor-plugin-status
Version:
Status plugin for @atlaskit/editor-core
16 lines • 671 B
JavaScript
import { NodeSelection } from '@atlaskit/editor-prosemirror/state';
export var mayGetStatusAtSelection = function mayGetStatusAtSelection(selection) {
if (selection && selection instanceof NodeSelection) {
var nodeSelection = selection;
if (nodeSelection.node.type.name === 'status') {
return selection.node.attrs || null;
}
}
return null;
};
export var isEmptyStatus = function isEmptyStatus(node) {
return node && (node.text && node.text.trim().length === 0 || node.text === '');
};
export var setNodeSelectionNearPos = function setNodeSelectionNearPos(tr, pos) {
return tr.setSelection(NodeSelection.create(tr.doc, tr.mapping.map(pos)));
};