@atlaskit/editor-plugin-undo-redo
Version:
Undo redo plugin for @atlaskit/editor-core
33 lines (32 loc) • 1.34 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.forceFocus = exports.closeTypeAheadAndRunCommand = void 0;
var closeTypeAheadAndRunCommand = exports.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;
};
};
var forceFocus = exports.forceFocus = function forceFocus(editorView, api) {
return function (command) {
var result = closeTypeAheadAndRunCommand(editorView, api)(command);
if (result && !editorView.hasFocus()) {
editorView.focus();
}
return result;
};
};