sprotty
Version:
A next-gen framework for graphical views
61 lines • 2.67 kB
JavaScript
;
/********************************************************************************
* Copyright (c) 2017-2023 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.overrideViewerOptions = exports.configureViewerOptions = exports.defaultViewerOptions = void 0;
const object_1 = require("sprotty-protocol/lib/utils/object");
const types_1 = require("../types");
const defaultViewerOptions = () => ({
baseDiv: 'sprotty',
baseClass: 'sprotty',
hiddenDiv: 'sprotty-hidden',
hiddenClass: 'sprotty-hidden',
popupDiv: 'sprotty-popup',
popupClass: 'sprotty-popup',
popupClosedClass: 'sprotty-popup-closed',
needsClientLayout: true,
needsServerLayout: false,
popupOpenDelay: 1000,
popupCloseDelay: 300,
zoomLimits: { min: 0.01, max: 10 },
horizontalScrollLimits: { min: -100000, max: 100000 },
verticalScrollLimits: { min: -100000, max: 100000 }
});
exports.defaultViewerOptions = defaultViewerOptions;
/**
* Utility function to partially set viewer options. Default values (from `defaultViewerOptions`) are used for
* options that are not specified.
*/
function configureViewerOptions(context, options) {
const opt = Object.assign(Object.assign({}, (0, exports.defaultViewerOptions)()), options);
if (context.isBound(types_1.TYPES.ViewerOptions)) {
context.rebind(types_1.TYPES.ViewerOptions).toConstantValue(opt);
}
else {
context.bind(types_1.TYPES.ViewerOptions).toConstantValue(opt);
}
}
exports.configureViewerOptions = configureViewerOptions;
/**
* Utility function to partially override the currently configured viewer options in a DI container.
*/
function overrideViewerOptions(container, options) {
const opt = container.get(types_1.TYPES.ViewerOptions);
(0, object_1.safeAssign)(opt, options);
return opt;
}
exports.overrideViewerOptions = overrideViewerOptions;
//# sourceMappingURL=viewer-options.js.map