UNPKG

@atlaskit/editor-plugin-undo-redo

Version:

Undo redo plugin for @atlaskit/editor-core

27 lines 1.15 kB
export var closeTypeAheadAndRunCommand = function closeTypeAheadAndRunCommand(editorView, api) { return function (command) { var _api$typeAhead; if (!editorView) { return false; } if (api !== null && api !== void 0 && (_api$typeAhead = api.typeAhead) !== null && _api$typeAhead !== void 0 && (_api$typeAhead = _api$typeAhead.actions) !== null && _api$typeAhead !== void 0 && _api$typeAhead.isOpen(editorView.state)) { var _api$typeAhead2; api === null || api === void 0 || (_api$typeAhead2 = api.typeAhead) === null || _api$typeAhead2 === void 0 || (_api$typeAhead2 = _api$typeAhead2.actions) === null || _api$typeAhead2 === void 0 || _api$typeAhead2.close({ attachCommand: command, insertCurrentQueryAsRawText: false }); } else { command(editorView.state, editorView.dispatch); } return true; }; }; export var forceFocus = function forceFocus(editorView, api) { return function (command) { var result = closeTypeAheadAndRunCommand(editorView, api)(command); if (result && !editorView.hasFocus()) { editorView.focus(); } return result; }; };