@kieler/klighd-core
Version:
Core KLighD diagram visualization with Sprotty
43 lines • 1.91 kB
JavaScript
;
/*
* KIELER - Kiel Integrated Environment for Layout Eclipse RichClient
*
* http://rtsys.informatik.uni-kiel.de/kieler
*
* Copyright 2021 by
* + Kiel University
* + Department of Computer Science
* + Real-Time and Embedded Systems Group
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0.
*
* SPDX-License-Identifier: EPL-2.0
*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.getBookmarkViewport = exports.requestModel = exports.getActionDispatcher = exports.diagramType = void 0;
const sprotty_1 = require("sprotty");
const sprotty_protocol_1 = require("sprotty-protocol");
// This module contains helper methods that can simplify the interaction with the Sprotty container from outside this package.
// The main goal of each helper is to abstract Sprotty internal implementations.
/** Diagram type that is communicated with the diagram server. */
exports.diagramType = 'keith-diagram';
/** Queries and returns an ActionDispatcher from the given DI Container. */
function getActionDispatcher(container) {
return container.get(sprotty_1.TYPES.IActionDispatcher);
}
exports.getActionDispatcher = getActionDispatcher;
/** Starts a model communication with the diagram server by dispatching a model request. */
async function requestModel(actionDispatcher, sourceUri) {
await actionDispatcher.dispatch(sprotty_protocol_1.RequestModelAction.create({ sourceUri, diagramType: exports.diagramType }));
}
exports.requestModel = requestModel;
function getBookmarkViewport(x, y, zoom) {
if (Number.isFinite(x) && Number.isFinite(y) && Number.isFinite(zoom)) {
return { scroll: { x, y }, zoom };
}
return null;
}
exports.getBookmarkViewport = getBookmarkViewport;
//# sourceMappingURL=external-helpers.js.map