UNPKG

@atlaskit/editor-plugin-selection-toolbar

Version:

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

20 lines • 738 B
import { isExperimentEnabled } from '@atlaskit/platform-feature-experiments/is-experiment-enabled'; export function getSelectionNodeTypes(state) { var _state$selection = state.selection, from = _state$selection.from, to = _state$selection.to; if (isExperimentEnabled('platform_editor_reduce_memory_leaks')) { var _selectionNodeTypes = new Set(); state.doc.nodesBetween(from, to, function (node) { _selectionNodeTypes.add(node.type); }); return Array.from(_selectionNodeTypes); } var selectionNodeTypes = []; state.doc.nodesBetween(from, to, function (node) { if (selectionNodeTypes.indexOf(node.type) !== 0) { selectionNodeTypes.push(node.type); } }); return selectionNodeTypes; }