UNPKG

sprotty

Version:

A next-gen framework for graphical views

49 lines 2.38 kB
"use strict"; /******************************************************************************** * Copyright (c) 2017-2021 TypeFox and others. * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v. 2.0 which is available at * http://www.eclipse.org/legal/epl-2.0. * * This Source Code may also be made available under the following Secondary * Licenses when the conditions for such availability set forth in the Eclipse * Public License v. 2.0 are satisfied: GNU General Public License, version 2 * with the GNU Classpath Exception which is available at * https://www.gnu.org/software/classpath/license.html. * * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 ********************************************************************************/ Object.defineProperty(exports, "__esModule", { value: true }); exports.overrideCommandStackOptions = exports.configureCommandStackOptions = exports.defaultCommandStackOptions = void 0; const object_1 = require("sprotty-protocol/lib/utils/object"); const types_1 = require("../types"); const defaultCommandStackOptions = () => ({ defaultDuration: 250, undoHistoryLimit: 50 }); exports.defaultCommandStackOptions = defaultCommandStackOptions; /** * Utility function to partially set command stack options. Default values (from `defaultViewerOptions`) are used for * options that are not specified. */ function configureCommandStackOptions(context, options) { const opt = Object.assign(Object.assign({}, (0, exports.defaultCommandStackOptions)()), options); if (context.isBound(types_1.TYPES.CommandStackOptions)) { context.rebind(types_1.TYPES.CommandStackOptions).toConstantValue(opt); } else { context.bind(types_1.TYPES.CommandStackOptions).toConstantValue(opt); } } exports.configureCommandStackOptions = configureCommandStackOptions; /** * Utility function to partially override the currently configured command stack options in a DI container. */ function overrideCommandStackOptions(container, options) { const defaultOptions = container.get(types_1.TYPES.CommandStackOptions); (0, object_1.safeAssign)(defaultOptions, options); return defaultOptions; } exports.overrideCommandStackOptions = overrideCommandStackOptions; //# sourceMappingURL=command-stack-options.js.map