UNPKG

@atlaskit/editor-plugin-selection

Version:

Selection plugin for @atlaskit/editor-core

24 lines 1.54 kB
import { getFragmentsFromSelection, getLocalIdsFromSelection } from '@atlaskit/editor-common/selection'; export var getSelectionFragment = function getSelectionFragment(api) { return function () { var _api$selection$shared; var selection = api === null || api === void 0 || (_api$selection$shared = api.selection.sharedState) === null || _api$selection$shared === void 0 || (_api$selection$shared = _api$selection$shared.currentState()) === null || _api$selection$shared === void 0 ? void 0 : _api$selection$shared.selection; return getFragmentsFromSelection(selection); }; }; export var getSelectionLocalIds = function getSelectionLocalIds(api) { return function () { var _api$selection$shared2, _selection; var selection = api === null || api === void 0 || (_api$selection$shared2 = api.selection.sharedState) === null || _api$selection$shared2 === void 0 || (_api$selection$shared2 = _api$selection$shared2.currentState()) === null || _api$selection$shared2 === void 0 ? void 0 : _api$selection$shared2.selection; if ((_selection = selection) !== null && _selection !== void 0 && _selection.empty) { // If we have an empty selection the current state might not be correct // We have a hack here to retrieve the current selection - but not dispatch a transaction api === null || api === void 0 || api.core.actions.execute(function (_ref) { var tr = _ref.tr; selection = tr.selection; return null; }); } return getLocalIdsFromSelection(selection); }; };