@eclipse-glsp/client 2.7.0-next.9 → 2.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/base/action-dispatcher.d.ts +2 -1
- package/lib/base/action-dispatcher.d.ts.map +1 -1
- package/lib/base/action-dispatcher.js +48 -24
- package/lib/base/action-dispatcher.js.map +1 -1
- package/lib/base/default.module.d.ts.map +1 -1
- package/lib/base/default.module.js +2 -0
- package/lib/base/default.module.js.map +1 -1
- package/lib/base/editor-context-service.d.ts +4 -3
- package/lib/base/editor-context-service.d.ts.map +1 -1
- package/lib/base/editor-context-service.js +11 -1
- package/lib/base/editor-context-service.js.map +1 -1
- package/lib/base/model/diagram-loader.d.ts +8 -6
- package/lib/base/model/diagram-loader.d.ts.map +1 -1
- package/lib/base/model/diagram-loader.js +1 -1
- package/lib/base/model/diagram-loader.js.map +1 -1
- package/lib/base/model/glsp-model-source.d.ts +5 -2
- package/lib/base/model/glsp-model-source.d.ts.map +1 -1
- package/lib/base/model/glsp-model-source.js +28 -1
- package/lib/base/model/glsp-model-source.js.map +1 -1
- package/lib/base/selection-service.d.ts +4 -3
- package/lib/base/selection-service.d.ts.map +1 -1
- package/lib/base/selection-service.js +6 -1
- package/lib/base/selection-service.js.map +1 -1
- package/lib/base/shortcuts/available-shortcuts-extension.d.ts +1 -1
- package/lib/base/shortcuts/available-shortcuts-extension.d.ts.map +1 -1
- package/lib/base/shortcuts/available-shortcuts-extension.js +3 -4
- package/lib/base/shortcuts/available-shortcuts-extension.js.map +1 -1
- package/lib/base/view/mouse-tool.d.ts +1 -1
- package/lib/base/view/mouse-tool.d.ts.map +1 -1
- package/lib/base/view/mouse-tool.js +3 -19
- package/lib/base/view/mouse-tool.js.map +1 -1
- package/lib/features/change-bounds/move-element-handler.d.ts +2 -3
- package/lib/features/change-bounds/move-element-handler.d.ts.map +1 -1
- package/lib/features/change-bounds/move-element-handler.js +2 -3
- package/lib/features/change-bounds/move-element-handler.js.map +1 -1
- package/lib/features/change-bounds/resize/resize-handler.d.ts +2 -3
- package/lib/features/change-bounds/resize/resize-handler.d.ts.map +1 -1
- package/lib/features/change-bounds/resize/resize-handler.js +2 -3
- package/lib/features/change-bounds/resize/resize-handler.js.map +1 -1
- package/lib/features/export/default-png-diagram-exporter.d.ts +52 -0
- package/lib/features/export/default-png-diagram-exporter.d.ts.map +1 -0
- package/lib/features/export/default-png-diagram-exporter.js +157 -0
- package/lib/features/export/default-png-diagram-exporter.js.map +1 -0
- package/lib/features/export/default-svg-diagram-exporter.d.ts +32 -0
- package/lib/features/export/default-svg-diagram-exporter.d.ts.map +1 -0
- package/lib/features/export/default-svg-diagram-exporter.js +54 -0
- package/lib/features/export/default-svg-diagram-exporter.js.map +1 -0
- package/lib/features/export/diagram-export-postprocessor.d.ts +33 -0
- package/lib/features/export/diagram-export-postprocessor.d.ts.map +1 -0
- package/lib/features/export/diagram-export-postprocessor.js +84 -0
- package/lib/features/export/diagram-export-postprocessor.js.map +1 -0
- package/lib/features/export/diagram-exporter.d.ts +44 -0
- package/lib/features/export/diagram-exporter.d.ts.map +1 -0
- package/lib/features/export/diagram-exporter.js +18 -0
- package/lib/features/export/diagram-exporter.js.map +1 -0
- package/lib/features/export/export-modules.d.ts +1 -1
- package/lib/features/export/export-modules.d.ts.map +1 -1
- package/lib/features/export/export-modules.js +20 -3
- package/lib/features/export/export-modules.js.map +1 -1
- package/lib/features/export/export-result-action-handler.d.ts +28 -0
- package/lib/features/export/export-result-action-handler.d.ts.map +1 -0
- package/lib/features/export/export-result-action-handler.js +72 -0
- package/lib/features/export/export-result-action-handler.js.map +1 -0
- package/lib/features/export/export-svg-action-handler.d.ts +19 -0
- package/lib/features/export/export-svg-action-handler.d.ts.map +1 -1
- package/lib/features/export/export-svg-action-handler.js +4 -15
- package/lib/features/export/export-svg-action-handler.js.map +1 -1
- package/lib/features/export/glsp-svg-exporter.d.ts +18 -1
- package/lib/features/export/glsp-svg-exporter.d.ts.map +1 -1
- package/lib/features/export/glsp-svg-exporter.js +44 -11
- package/lib/features/export/glsp-svg-exporter.js.map +1 -1
- package/lib/features/export/request-export-command.d.ts +29 -0
- package/lib/features/export/request-export-command.d.ts.map +1 -0
- package/lib/features/export/request-export-command.js +73 -0
- package/lib/features/export/request-export-command.js.map +1 -0
- package/lib/features/export/request-export-key-listener.d.ts +21 -0
- package/lib/features/export/request-export-key-listener.d.ts.map +1 -0
- package/lib/features/export/request-export-key-listener.js +40 -0
- package/lib/features/export/request-export-key-listener.js.map +1 -0
- package/lib/features/helper-lines/helper-line-feedback.d.ts +1 -1
- package/lib/features/helper-lines/helper-line-feedback.d.ts.map +1 -1
- package/lib/features/helper-lines/helper-line-feedback.js +2 -3
- package/lib/features/helper-lines/helper-line-feedback.js.map +1 -1
- package/lib/features/routing/edge-router.d.ts +2 -1
- package/lib/features/routing/edge-router.d.ts.map +1 -1
- package/lib/features/routing/edge-router.js +2 -1
- package/lib/features/routing/edge-router.js.map +1 -1
- package/lib/features/routing/routing-module.d.ts +1 -1
- package/lib/features/routing/routing-module.d.ts.map +1 -1
- package/lib/features/routing/routing-module.js +7 -1
- package/lib/features/routing/routing-module.js.map +1 -1
- package/lib/features/routing/sticky-manhattan-anchors.d.ts +29 -0
- package/lib/features/routing/sticky-manhattan-anchors.d.ts.map +1 -0
- package/lib/features/routing/sticky-manhattan-anchors.js +62 -0
- package/lib/features/routing/sticky-manhattan-anchors.js.map +1 -0
- package/lib/features/routing/sticky-manhattan-edge-router.d.ts +107 -0
- package/lib/features/routing/sticky-manhattan-edge-router.d.ts.map +1 -0
- package/lib/features/routing/sticky-manhattan-edge-router.js +626 -0
- package/lib/features/routing/sticky-manhattan-edge-router.js.map +1 -0
- package/lib/features/search-palette/search-palette.d.ts +2 -2
- package/lib/features/search-palette/search-palette.d.ts.map +1 -1
- package/lib/features/search-palette/search-palette.js +3 -4
- package/lib/features/search-palette/search-palette.js.map +1 -1
- package/lib/features/select/select-module.d.ts +1 -1
- package/lib/features/select/select-module.js +1 -1
- package/lib/features/tool-palette/tool-palette.d.ts.map +1 -1
- package/lib/features/tool-palette/tool-palette.js +1 -2
- package/lib/features/tool-palette/tool-palette.js.map +1 -1
- package/lib/features/tools/change-bounds/change-bounds-tool-move-feedback.d.ts +2 -3
- package/lib/features/tools/change-bounds/change-bounds-tool-move-feedback.d.ts.map +1 -1
- package/lib/features/tools/change-bounds/change-bounds-tool-move-feedback.js +2 -3
- package/lib/features/tools/change-bounds/change-bounds-tool-move-feedback.js.map +1 -1
- package/lib/features/viewport/origin-viewport.d.ts +2 -13
- package/lib/features/viewport/origin-viewport.d.ts.map +1 -1
- package/lib/features/viewport/origin-viewport.js +3 -19
- package/lib/features/viewport/origin-viewport.js.map +1 -1
- package/lib/index.d.ts +11 -1
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +11 -1
- package/lib/index.js.map +1 -1
- package/lib/views/gedge-view-with-gaps-on-intersections.d.ts +39 -0
- package/lib/views/gedge-view-with-gaps-on-intersections.d.ts.map +1 -0
- package/lib/views/gedge-view-with-gaps-on-intersections.js +85 -0
- package/lib/views/gedge-view-with-gaps-on-intersections.js.map +1 -0
- package/lib/views/rounded-corner-manhattan-edge-view.d.ts +58 -0
- package/lib/views/rounded-corner-manhattan-edge-view.d.ts.map +1 -0
- package/lib/views/rounded-corner-manhattan-edge-view.js +170 -0
- package/lib/views/rounded-corner-manhattan-edge-view.js.map +1 -0
- package/package.json +4 -6
- package/src/base/action-dispatcher.spec.ts +103 -3
- package/src/base/action-dispatcher.ts +50 -25
- package/src/base/default.module.ts +4 -0
- package/src/base/editor-context-service.ts +17 -5
- package/src/base/model/diagram-loader.ts +8 -6
- package/src/base/model/glsp-model-source.ts +35 -1
- package/src/base/selection-service.ts +11 -2
- package/src/base/shortcuts/available-shortcuts-extension.ts +3 -4
- package/src/base/view/mouse-tool.ts +4 -19
- package/src/features/change-bounds/move-element-handler.ts +3 -2
- package/src/features/change-bounds/resize/resize-handler.ts +4 -3
- package/src/features/export/default-png-diagram-exporter.ts +145 -0
- package/src/features/export/default-svg-diagram-exporter.ts +39 -0
- package/src/features/export/diagram-export-postprocessor.ts +82 -0
- package/src/features/export/diagram-exporter.ts +45 -0
- package/src/features/export/export-modules.ts +24 -4
- package/src/features/export/export-result-action-handler.ts +66 -0
- package/src/features/export/export-svg-action-handler.ts +7 -2
- package/src/features/export/glsp-svg-exporter.ts +48 -12
- package/src/features/export/request-export-command.ts +65 -0
- package/src/features/export/request-export-key-listener.ts +29 -0
- package/src/features/helper-lines/helper-line-feedback.ts +6 -4
- package/src/features/routing/edge-router.ts +2 -2
- package/src/features/routing/routing-module.ts +8 -1
- package/src/features/routing/sticky-manhattan-anchors.ts +53 -0
- package/src/features/routing/sticky-manhattan-edge-router.spec.ts +212 -0
- package/src/features/routing/sticky-manhattan-edge-router.ts +713 -0
- package/src/features/search-palette/search-palette.ts +3 -4
- package/src/features/select/select-module.ts +1 -1
- package/src/features/tool-palette/tool-palette.ts +1 -1
- package/src/features/tools/change-bounds/change-bounds-tool-move-feedback.ts +13 -3
- package/src/features/viewport/origin-viewport.ts +10 -23
- package/src/index.ts +11 -1
- package/src/views/gedge-view-with-gaps-on-intersections.tsx +99 -0
- package/src/views/rounded-corner-manhattan-edge-view.ts +171 -0
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/********************************************************************************
|
|
2
|
+
* Copyright (c) 2026 EclipseSource and others.
|
|
3
|
+
*
|
|
4
|
+
* This program and the accompanying materials are made available under the
|
|
5
|
+
* terms of the Eclipse Public License v. 2.0 which is available at
|
|
6
|
+
* http://www.eclipse.org/legal/epl-2.0.
|
|
7
|
+
*
|
|
8
|
+
* This Source Code may also be made available under the following Secondary
|
|
9
|
+
* Licenses when the conditions for such availability set forth in the Eclipse
|
|
10
|
+
* Public License v. 2.0 are satisfied: GNU General Public License, version 2
|
|
11
|
+
* with the GNU Classpath Exception which is available at
|
|
12
|
+
* https://www.gnu.org/software/classpath/license.html.
|
|
13
|
+
*
|
|
14
|
+
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
|
|
15
|
+
********************************************************************************/
|
|
16
|
+
|
|
17
|
+
import { Action, ExportFormat, ExportMimeType, GModelRoot, SvgExportOptions } from '@eclipse-glsp/sprotty';
|
|
18
|
+
import { inject, injectable } from 'inversify';
|
|
19
|
+
import { DiagramExporter } from './diagram-exporter';
|
|
20
|
+
import { GLSPSvgExporter } from './glsp-svg-exporter';
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Default SVG strategy for the unified export registry. Wraps {@link GLSPSvgExporter} —
|
|
24
|
+
* the same exporter that powers the legacy `RequestExportSvgAction` path — so adopter
|
|
25
|
+
* overrides on the SVG renderer (extending {@link GLSPSvgExporter}) participate in unified
|
|
26
|
+
* exports for free.
|
|
27
|
+
*/
|
|
28
|
+
@injectable()
|
|
29
|
+
export class DefaultSvgDiagramExporter implements DiagramExporter<SvgExportOptions> {
|
|
30
|
+
readonly format: ExportFormat = 'svg';
|
|
31
|
+
readonly mimeType: ExportMimeType = 'image/svg+xml';
|
|
32
|
+
readonly encoding = 'text' as const;
|
|
33
|
+
|
|
34
|
+
@inject(GLSPSvgExporter) protected svgExporter: GLSPSvgExporter;
|
|
35
|
+
|
|
36
|
+
async export(root: GModelRoot, options: SvgExportOptions = {}, cause?: Action): Promise<string> {
|
|
37
|
+
return this.svgExporter.exportToString(root, options, cause);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
/********************************************************************************
|
|
2
|
+
* Copyright (c) 2026 EclipseSource and others.
|
|
3
|
+
*
|
|
4
|
+
* This program and the accompanying materials are made available under the
|
|
5
|
+
* terms of the Eclipse Public License v. 2.0 which is available at
|
|
6
|
+
* http://www.eclipse.org/legal/epl-2.0.
|
|
7
|
+
*
|
|
8
|
+
* This Source Code may also be made available under the following Secondary
|
|
9
|
+
* Licenses when the conditions for such availability set forth in the Eclipse
|
|
10
|
+
* Public License v. 2.0 are satisfied: GNU General Public License, version 2
|
|
11
|
+
* with the GNU Classpath Exception which is available at
|
|
12
|
+
* https://www.gnu.org/software/classpath/license.html.
|
|
13
|
+
*
|
|
14
|
+
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
|
|
15
|
+
********************************************************************************/
|
|
16
|
+
|
|
17
|
+
import {
|
|
18
|
+
Action,
|
|
19
|
+
ExportResultAction,
|
|
20
|
+
GModelElement,
|
|
21
|
+
GModelRoot,
|
|
22
|
+
IActionDispatcher,
|
|
23
|
+
IVNodePostprocessor,
|
|
24
|
+
RejectAction,
|
|
25
|
+
RequestExportAction,
|
|
26
|
+
TYPES
|
|
27
|
+
} from '@eclipse-glsp/sprotty';
|
|
28
|
+
import { inject, injectable, multiInject } from 'inversify';
|
|
29
|
+
import { VNode } from 'snabbdom';
|
|
30
|
+
import { DiagramExporter } from './diagram-exporter';
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Postprocessor for the unified {@link RequestExportAction} flow. Captures the rendered model
|
|
34
|
+
* root from the `decorate` pass, then on `postUpdate` looks up the matching
|
|
35
|
+
* {@link DiagramExporter} by `format` and dispatches an {@link ExportResultAction} with the
|
|
36
|
+
* produced bytes.
|
|
37
|
+
*/
|
|
38
|
+
@injectable()
|
|
39
|
+
export class DiagramExportPostprocessor implements IVNodePostprocessor {
|
|
40
|
+
@multiInject(TYPES.IDiagramExporter) protected exporters: DiagramExporter[];
|
|
41
|
+
@inject(TYPES.IActionDispatcher) protected actionDispatcher: IActionDispatcher;
|
|
42
|
+
|
|
43
|
+
protected root: GModelRoot;
|
|
44
|
+
|
|
45
|
+
decorate(vnode: VNode, element: GModelElement): VNode {
|
|
46
|
+
if (element instanceof GModelRoot) {
|
|
47
|
+
this.root = element;
|
|
48
|
+
}
|
|
49
|
+
return vnode;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
postUpdate(cause?: Action): void {
|
|
53
|
+
if (!this.root || !RequestExportAction.is(cause)) {
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
56
|
+
const request = cause;
|
|
57
|
+
this.runExport(request).catch(err => {
|
|
58
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
59
|
+
this.actionDispatcher.dispatch(RejectAction.create(message, { responseId: request.requestId }));
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
protected async runExport(request: RequestExportAction): Promise<void> {
|
|
64
|
+
// First-bound-wins on duplicate formats: an adopter who registers a custom
|
|
65
|
+
// PNG exporter without `unbind`-ing the default will pick up the default. To
|
|
66
|
+
// override, rebind via `binding.rebind(DefaultPngDiagramExporter, MyPngExporter)`
|
|
67
|
+
// in your `DiagramExportModule` extension.
|
|
68
|
+
const exporter = this.exporters.find(candidate => candidate.format === request.format);
|
|
69
|
+
if (!exporter) {
|
|
70
|
+
throw new Error(`No DiagramExporter registered for format '${request.format}'`);
|
|
71
|
+
}
|
|
72
|
+
const data = await exporter.export(this.root, request.formatOptions ?? {}, request);
|
|
73
|
+
this.actionDispatcher.dispatch(
|
|
74
|
+
ExportResultAction.create(exporter.format, data, {
|
|
75
|
+
mimeType: exporter.mimeType,
|
|
76
|
+
encoding: exporter.encoding,
|
|
77
|
+
responseId: request.requestId,
|
|
78
|
+
formatOptions: request.formatOptions
|
|
79
|
+
})
|
|
80
|
+
);
|
|
81
|
+
}
|
|
82
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/********************************************************************************
|
|
2
|
+
* Copyright (c) 2026 EclipseSource and others.
|
|
3
|
+
*
|
|
4
|
+
* This program and the accompanying materials are made available under the
|
|
5
|
+
* terms of the Eclipse Public License v. 2.0 which is available at
|
|
6
|
+
* http://www.eclipse.org/legal/epl-2.0.
|
|
7
|
+
*
|
|
8
|
+
* This Source Code may also be made available under the following Secondary
|
|
9
|
+
* Licenses when the conditions for such availability set forth in the Eclipse
|
|
10
|
+
* Public License v. 2.0 are satisfied: GNU General Public License, version 2
|
|
11
|
+
* with the GNU Classpath Exception which is available at
|
|
12
|
+
* https://www.gnu.org/software/classpath/license.html.
|
|
13
|
+
*
|
|
14
|
+
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
|
|
15
|
+
********************************************************************************/
|
|
16
|
+
|
|
17
|
+
import { Action, ExportEncoding, ExportFormat, ExportMimeType, GModelRoot } from '@eclipse-glsp/sprotty';
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* A pluggable strategy that turns the rendered diagram into the bytes of a specific export
|
|
21
|
+
* format. GLSP ships strategies for `'svg'` and `'png'` (both rendered client-side via the
|
|
22
|
+
* existing SVG export pipeline + `OffscreenCanvas` for PNG). Adopters add formats — PPTX,
|
|
23
|
+
* PDF, server-rendered PNG, … — by registering additional contributions.
|
|
24
|
+
*
|
|
25
|
+
* Implementations choose how the bytes are produced (DOM serialisation, canvas
|
|
26
|
+
* rasterisation, delegation to a backend service via Theia/Electron RPC, …) — the registry
|
|
27
|
+
* is runtime-agnostic. The generic `O` is the strategy-specific options shape (e.g.
|
|
28
|
+
* `PngExportOptions`) carried inside `RequestExportAction.formatOptions`; the postprocessor
|
|
29
|
+
* forwards the bag to the strategy, so each implementation reads its typed options directly
|
|
30
|
+
* without an in-method cast.
|
|
31
|
+
*/
|
|
32
|
+
export interface DiagramExporter<O = unknown> {
|
|
33
|
+
/** Format identifier matched against `RequestExportAction.format` (lower-case). */
|
|
34
|
+
readonly format: ExportFormat;
|
|
35
|
+
/** MIME type written into the resulting `ExportResultAction.mimeType`. */
|
|
36
|
+
readonly mimeType: ExportMimeType;
|
|
37
|
+
/** Encoding of the produced `data` field — `'text'` for SVG markup, `'base64'` for binary formats, or any adopter-defined tag. */
|
|
38
|
+
readonly encoding: ExportEncoding;
|
|
39
|
+
/**
|
|
40
|
+
* Produce the export payload. `formatOptions` is the strategy-typed slice of
|
|
41
|
+
* `RequestExportAction.formatOptions`; `cause` carries the originating action so
|
|
42
|
+
* adopters can inspect request metadata beyond the per-format options.
|
|
43
|
+
*/
|
|
44
|
+
export(root: GModelRoot, formatOptions: O, cause?: Action): Promise<string>;
|
|
45
|
+
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/********************************************************************************
|
|
2
|
-
* Copyright (c) 2019-
|
|
2
|
+
* Copyright (c) 2019-2026 EclipseSource and others.
|
|
3
3
|
*
|
|
4
4
|
* This program and the accompanying materials are made available under the
|
|
5
5
|
* terms of the Eclipse Public License v. 2.0 which is available at
|
|
@@ -13,26 +13,42 @@
|
|
|
13
13
|
*
|
|
14
14
|
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
|
|
15
15
|
********************************************************************************/
|
|
16
|
+
/* eslint-disable @typescript-eslint/no-deprecated */
|
|
16
17
|
import {
|
|
17
18
|
bindAsService,
|
|
18
19
|
configureActionHandler,
|
|
19
20
|
configureCommand,
|
|
21
|
+
ExportResultAction,
|
|
20
22
|
ExportSvgAction,
|
|
21
23
|
ExportSvgCommand,
|
|
22
|
-
ExportSvgKeyListener,
|
|
23
24
|
ExportSvgPostprocessor,
|
|
24
25
|
FeatureModule,
|
|
25
26
|
TYPES
|
|
26
27
|
} from '@eclipse-glsp/sprotty';
|
|
28
|
+
import { DefaultPngDiagramExporter } from './default-png-diagram-exporter';
|
|
29
|
+
import { DefaultSvgDiagramExporter } from './default-svg-diagram-exporter';
|
|
30
|
+
import { DiagramExportPostprocessor } from './diagram-export-postprocessor';
|
|
31
|
+
import { ExportResultActionHandler } from './export-result-action-handler';
|
|
27
32
|
import { ExportSvgActionHandler } from './export-svg-action-handler';
|
|
28
33
|
import { GLSPSvgExporter } from './glsp-svg-exporter';
|
|
34
|
+
import { RequestExportCommand } from './request-export-command';
|
|
35
|
+
import { RequestExportKeyListener } from './request-export-key-listener';
|
|
29
36
|
|
|
30
37
|
export const exportModule = new FeatureModule(
|
|
31
38
|
(bind, _unbind, isBound) => {
|
|
32
39
|
const context = { bind, isBound };
|
|
40
|
+
bindAsService(context, TYPES.SvgExporter, GLSPSvgExporter);
|
|
41
|
+
|
|
42
|
+
// Unified export pipeline.
|
|
43
|
+
bindAsService(context, TYPES.HiddenVNodePostprocessor, DiagramExportPostprocessor);
|
|
44
|
+
configureCommand(context, RequestExportCommand);
|
|
45
|
+
bindAsService(context, TYPES.IDiagramExporter, DefaultSvgDiagramExporter);
|
|
46
|
+
bindAsService(context, TYPES.IDiagramExporter, DefaultPngDiagramExporter);
|
|
47
|
+
|
|
48
|
+
// Legacy SVG-only pipeline kept functional for adopters still dispatching the
|
|
49
|
+
// deprecated `RequestExportSvgAction` / `ExportSvgAction`.
|
|
33
50
|
bindAsService(context, TYPES.HiddenVNodePostprocessor, ExportSvgPostprocessor);
|
|
34
51
|
configureCommand(context, ExportSvgCommand);
|
|
35
|
-
bind(TYPES.SvgExporter).to(GLSPSvgExporter).inSingletonScope();
|
|
36
52
|
},
|
|
37
53
|
{ featureId: Symbol('export') }
|
|
38
54
|
);
|
|
@@ -45,7 +61,11 @@ export const exportModule = new FeatureModule(
|
|
|
45
61
|
export const standaloneExportModule = new FeatureModule(
|
|
46
62
|
(bind, _unbind, isBound) => {
|
|
47
63
|
const context = { bind, isBound };
|
|
48
|
-
bindAsService(context, TYPES.KeyListener,
|
|
64
|
+
bindAsService(context, TYPES.KeyListener, RequestExportKeyListener);
|
|
65
|
+
bind(ExportResultActionHandler).toSelf().inSingletonScope();
|
|
66
|
+
configureActionHandler(context, ExportResultAction.KIND, ExportResultActionHandler);
|
|
67
|
+
|
|
68
|
+
// Legacy download path: bound so adopters dispatching `ExportSvgAction` still get a download.
|
|
49
69
|
bind(ExportSvgActionHandler).toSelf().inSingletonScope();
|
|
50
70
|
configureActionHandler(context, ExportSvgAction.KIND, ExportSvgActionHandler);
|
|
51
71
|
},
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
/********************************************************************************
|
|
2
|
+
* Copyright (c) 2026 EclipseSource and others.
|
|
3
|
+
*
|
|
4
|
+
* This program and the accompanying materials are made available under the
|
|
5
|
+
* terms of the Eclipse Public License v. 2.0 which is available at
|
|
6
|
+
* http://www.eclipse.org/legal/epl-2.0.
|
|
7
|
+
*
|
|
8
|
+
* This Source Code may also be made available under the following Secondary
|
|
9
|
+
* Licenses when the conditions for such availability set forth in the Eclipse
|
|
10
|
+
* Public License v. 2.0 are satisfied: GNU General Public License, version 2
|
|
11
|
+
* with the GNU Classpath Exception which is available at
|
|
12
|
+
* https://www.gnu.org/software/classpath/license.html.
|
|
13
|
+
*
|
|
14
|
+
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
|
|
15
|
+
********************************************************************************/
|
|
16
|
+
|
|
17
|
+
import { ExportResultAction, IActionHandler } from '@eclipse-glsp/sprotty';
|
|
18
|
+
import { saveAs } from 'file-saver';
|
|
19
|
+
import { injectable } from 'inversify';
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Default handler for the unified {@link ExportResultAction} — triggers a browser file
|
|
23
|
+
* download for UI-driven flows. Bound by `standaloneExportModule`; integrations that
|
|
24
|
+
* provide their own download UX omit it.
|
|
25
|
+
*/
|
|
26
|
+
@injectable()
|
|
27
|
+
export class ExportResultActionHandler implements IActionHandler {
|
|
28
|
+
handle(action: ExportResultAction): void {
|
|
29
|
+
if (!ExportResultAction.is(action)) {
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
const blob = this.toBlob(action);
|
|
33
|
+
saveAs(blob, `diagram.${this.extensionFor(action.format)}`);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
protected toBlob(action: ExportResultAction): Blob {
|
|
37
|
+
// `encoding` is `ProposalString<'text' | 'base64'>` — an open union. Reject unknown
|
|
38
|
+
// tags explicitly: silently treating an arbitrary value as text would mojibake binary
|
|
39
|
+
// payloads, while treating it as base64 would corrupt text payloads.
|
|
40
|
+
switch (action.encoding) {
|
|
41
|
+
case 'text':
|
|
42
|
+
return new Blob([action.data], { type: `${action.mimeType};charset=utf-8` });
|
|
43
|
+
case 'base64':
|
|
44
|
+
return new Blob([this.decodeBase64(action.data)], { type: action.mimeType });
|
|
45
|
+
default:
|
|
46
|
+
throw new Error(
|
|
47
|
+
`ExportResultActionHandler: unsupported encoding '${action.encoding}' for format '${action.format}'. ` +
|
|
48
|
+
'Adopters that ship a custom encoding must also subclass this handler to decode it.'
|
|
49
|
+
);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
protected extensionFor(format: string): string {
|
|
54
|
+
return format.toLowerCase();
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
protected decodeBase64(data: string): ArrayBuffer {
|
|
58
|
+
const binary = atob(data);
|
|
59
|
+
const buffer = new ArrayBuffer(binary.length);
|
|
60
|
+
const view = new Uint8Array(buffer);
|
|
61
|
+
for (let i = 0; i < binary.length; ++i) {
|
|
62
|
+
view[i] = binary.charCodeAt(i);
|
|
63
|
+
}
|
|
64
|
+
return buffer;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/********************************************************************************
|
|
2
|
-
* Copyright (c) 2023 EclipseSource and others.
|
|
2
|
+
* Copyright (c) 2023-2026 EclipseSource and others.
|
|
3
3
|
*
|
|
4
4
|
* This program and the accompanying materials are made available under the
|
|
5
5
|
* terms of the Eclipse Public License v. 2.0 which is available at
|
|
@@ -13,15 +13,20 @@
|
|
|
13
13
|
*
|
|
14
14
|
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
|
|
15
15
|
********************************************************************************/
|
|
16
|
+
/* eslint-disable @typescript-eslint/no-deprecated */
|
|
17
|
+
import { ExportSvgAction, IActionHandler } from '@eclipse-glsp/sprotty';
|
|
16
18
|
import { saveAs } from 'file-saver';
|
|
17
19
|
import { injectable } from 'inversify';
|
|
18
|
-
import { ExportSvgAction, IActionHandler } from '@eclipse-glsp/sprotty';
|
|
19
20
|
|
|
20
21
|
/**
|
|
21
22
|
* The default handler for {@link ExportSvgAction}s. This generic handler can be used in
|
|
22
23
|
* any GLSP project independent of the target platform. However, platform integration modules typically
|
|
23
24
|
* * this handler is rebound to an application specific handler in platform integration modules
|
|
24
25
|
* (e.g. the Theia integration)
|
|
26
|
+
*
|
|
27
|
+
* @deprecated Use the unified export pipeline ({@link RequestExportAction} +
|
|
28
|
+
* {@link DiagramExporter}) and bind your own {@link IActionHandler} for
|
|
29
|
+
* {@link ExportResultAction} instead.
|
|
25
30
|
*/
|
|
26
31
|
@injectable()
|
|
27
32
|
export class ExportSvgActionHandler implements IActionHandler {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/********************************************************************************
|
|
2
|
-
* Copyright (c) 2022-
|
|
2
|
+
* Copyright (c) 2022-2026 EclipseSource and others.
|
|
3
3
|
*
|
|
4
4
|
* This program and the accompanying materials are made available under the
|
|
5
5
|
* terms of the Eclipse Public License v. 2.0 which is available at
|
|
@@ -13,11 +13,13 @@
|
|
|
13
13
|
*
|
|
14
14
|
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
|
|
15
15
|
********************************************************************************/
|
|
16
|
+
/* eslint-disable @typescript-eslint/no-deprecated */
|
|
16
17
|
import {
|
|
17
18
|
Action,
|
|
18
19
|
ExportSvgAction,
|
|
19
20
|
ExportSvgOptions,
|
|
20
21
|
GModelRoot,
|
|
22
|
+
RejectAction,
|
|
21
23
|
RequestAction,
|
|
22
24
|
RequestExportSvgAction,
|
|
23
25
|
SvgExporter
|
|
@@ -27,18 +29,52 @@ import { v4 as uuid } from 'uuid';
|
|
|
27
29
|
|
|
28
30
|
@injectable()
|
|
29
31
|
export class GLSPSvgExporter extends SvgExporter {
|
|
32
|
+
/**
|
|
33
|
+
* Legacy entry point for the SVG-only export flow. New code should use the unified
|
|
34
|
+
* `RequestExportAction` flow (registered via the `DiagramExporter` registry);
|
|
35
|
+
* adopters that previously bound {@link RequestExportSvgAction} should migrate to
|
|
36
|
+
* `RequestExportAction` with `format: 'svg'`.
|
|
37
|
+
*
|
|
38
|
+
* @deprecated Use the unified export pipeline. Retained for backward compatibility
|
|
39
|
+
* with the legacy {@link RequestExportSvgAction} / {@link ExportSvgAction} flow.
|
|
40
|
+
*/
|
|
30
41
|
override export(root: GModelRoot, request?: RequestExportSvgAction): void {
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
+
try {
|
|
43
|
+
const svgExport = this.exportToString(root, request?.options, request);
|
|
44
|
+
this.actionDispatcher.dispatch(
|
|
45
|
+
ExportSvgAction.create(svgExport, { responseId: request?.requestId, options: request?.options })
|
|
46
|
+
);
|
|
47
|
+
} catch (err: unknown) {
|
|
48
|
+
this.dispatchRejectionIfRequested(request, err instanceof Error ? err.message : String(err));
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* Produce the serialised SVG string without dispatching any action. Throws on
|
|
54
|
+
* failure (no document, no SVG element). Used by the legacy `export()` path and
|
|
55
|
+
* by unified-export strategies (`DefaultSvgDiagramExporter`, `DefaultPngDiagramExporter`)
|
|
56
|
+
* that need the SVG bytes without the action-dispatch side effect.
|
|
57
|
+
*/
|
|
58
|
+
exportToString(root: GModelRoot, options?: ExportSvgOptions, cause?: Action): string {
|
|
59
|
+
if (typeof document === 'undefined') {
|
|
60
|
+
throw new Error('SVG export failed: document is not available');
|
|
61
|
+
}
|
|
62
|
+
let svgElement = this.findSvgElement();
|
|
63
|
+
if (!svgElement) {
|
|
64
|
+
throw new Error('SVG export failed: SVG element not found');
|
|
65
|
+
}
|
|
66
|
+
// Only the legacy SVG-only flow carries a `RequestExportSvgAction`; under the unified
|
|
67
|
+
// export flow `cause` is a `RequestExportAction` and the legacy override hooks are
|
|
68
|
+
// intentionally invoked with `undefined`.
|
|
69
|
+
const request = RequestExportSvgAction.is(cause) ? cause : undefined;
|
|
70
|
+
svgElement = this.prepareSvgElement(svgElement, root, request);
|
|
71
|
+
const serializedSvg = this.createSvg(svgElement, root, options ?? {}, cause);
|
|
72
|
+
return this.getSvgExport(serializedSvg, svgElement, root, request);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
protected dispatchRejectionIfRequested(request: RequestExportSvgAction | undefined, message: string): void {
|
|
76
|
+
if (request?.requestId) {
|
|
77
|
+
this.actionDispatcher.dispatch(RejectAction.create(message, { responseId: request.requestId }));
|
|
42
78
|
}
|
|
43
79
|
}
|
|
44
80
|
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
/********************************************************************************
|
|
2
|
+
* Copyright (c) 2026 EclipseSource and others.
|
|
3
|
+
*
|
|
4
|
+
* This program and the accompanying materials are made available under the
|
|
5
|
+
* terms of the Eclipse Public License v. 2.0 which is available at
|
|
6
|
+
* http://www.eclipse.org/legal/epl-2.0.
|
|
7
|
+
*
|
|
8
|
+
* This Source Code may also be made available under the following Secondary
|
|
9
|
+
* Licenses when the conditions for such availability set forth in the Eclipse
|
|
10
|
+
* Public License v. 2.0 are satisfied: GNU General Public License, version 2
|
|
11
|
+
* with the GNU Classpath Exception which is available at
|
|
12
|
+
* https://www.gnu.org/software/classpath/license.html.
|
|
13
|
+
*
|
|
14
|
+
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
|
|
15
|
+
********************************************************************************/
|
|
16
|
+
|
|
17
|
+
import {
|
|
18
|
+
CommandExecutionContext,
|
|
19
|
+
CommandResult,
|
|
20
|
+
HiddenCommand,
|
|
21
|
+
isExportable,
|
|
22
|
+
isHoverable,
|
|
23
|
+
isSelectable,
|
|
24
|
+
isViewport,
|
|
25
|
+
RequestExportAction,
|
|
26
|
+
TYPES
|
|
27
|
+
} from '@eclipse-glsp/sprotty';
|
|
28
|
+
import { inject } from 'inversify';
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* {@link HiddenCommand} for the unified {@link RequestExportAction} kind. Performs the same
|
|
32
|
+
* pre-render preparation as sprotty's `ExportSvgCommand` (clone the root, reset
|
|
33
|
+
* viewport, drop selection/hover) so the rendered SVG used by every
|
|
34
|
+
* `DiagramExporter` strategy is independent of UI state.
|
|
35
|
+
*/
|
|
36
|
+
export class RequestExportCommand extends HiddenCommand {
|
|
37
|
+
static readonly KIND = RequestExportAction.KIND;
|
|
38
|
+
|
|
39
|
+
constructor(@inject(TYPES.Action) protected action: RequestExportAction) {
|
|
40
|
+
super();
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
execute(context: CommandExecutionContext): CommandResult {
|
|
44
|
+
if (!isExportable(context.root)) {
|
|
45
|
+
return { model: context.root, modelChanged: false };
|
|
46
|
+
}
|
|
47
|
+
const root = context.modelFactory.createRoot(context.root);
|
|
48
|
+
if (!isExportable(root)) {
|
|
49
|
+
return { model: context.root, modelChanged: false };
|
|
50
|
+
}
|
|
51
|
+
if (isViewport(root)) {
|
|
52
|
+
root.zoom = 1;
|
|
53
|
+
root.scroll = { x: 0, y: 0 };
|
|
54
|
+
}
|
|
55
|
+
root.index.all().forEach(element => {
|
|
56
|
+
if (isSelectable(element) && element.selected) {
|
|
57
|
+
element.selected = false;
|
|
58
|
+
}
|
|
59
|
+
if (isHoverable(element) && element.hoverFeedback) {
|
|
60
|
+
element.hoverFeedback = false;
|
|
61
|
+
}
|
|
62
|
+
});
|
|
63
|
+
return { model: root, modelChanged: true, cause: this.action };
|
|
64
|
+
}
|
|
65
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/********************************************************************************
|
|
2
|
+
* Copyright (c) 2026 EclipseSource and others.
|
|
3
|
+
*
|
|
4
|
+
* This program and the accompanying materials are made available under the
|
|
5
|
+
* terms of the Eclipse Public License v. 2.0 which is available at
|
|
6
|
+
* http://www.eclipse.org/legal/epl-2.0.
|
|
7
|
+
*
|
|
8
|
+
* This Source Code may also be made available under the following Secondary
|
|
9
|
+
* Licenses when the conditions for such availability set forth in the Eclipse
|
|
10
|
+
* Public License v. 2.0 are satisfied: GNU General Public License, version 2
|
|
11
|
+
* with the GNU Classpath Exception which is available at
|
|
12
|
+
* https://www.gnu.org/software/classpath/license.html.
|
|
13
|
+
*
|
|
14
|
+
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
|
|
15
|
+
********************************************************************************/
|
|
16
|
+
|
|
17
|
+
import { Action, GModelElement, KeyListener, RequestExportAction, matchesKeystroke } from '@eclipse-glsp/sprotty';
|
|
18
|
+
import { injectable } from 'inversify';
|
|
19
|
+
|
|
20
|
+
/** Dispatches a {@link RequestExportAction} (format `'svg'`) on `Ctrl+Shift+E`. */
|
|
21
|
+
@injectable()
|
|
22
|
+
export class RequestExportKeyListener extends KeyListener {
|
|
23
|
+
override keyDown(_element: GModelElement, event: KeyboardEvent): Action[] {
|
|
24
|
+
if (matchesKeystroke(event, 'KeyE', 'ctrlCmd', 'shift')) {
|
|
25
|
+
return [RequestExportAction.create('svg')];
|
|
26
|
+
}
|
|
27
|
+
return [];
|
|
28
|
+
}
|
|
29
|
+
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/********************************************************************************
|
|
2
|
-
* Copyright (c) 2023-
|
|
2
|
+
* Copyright (c) 2023-2026 EclipseSource and others.
|
|
3
3
|
*
|
|
4
4
|
* This program and the accompanying materials are made available under the
|
|
5
5
|
* terms of the Eclipse Public License v. 2.0 which is available at
|
|
@@ -30,10 +30,10 @@ import {
|
|
|
30
30
|
equalUpTo,
|
|
31
31
|
isBoundsAware,
|
|
32
32
|
isDecoration,
|
|
33
|
-
isViewport
|
|
33
|
+
isViewport,
|
|
34
|
+
partition
|
|
34
35
|
} from '@eclipse-glsp/sprotty';
|
|
35
36
|
import { inject, injectable } from 'inversify';
|
|
36
|
-
import { partition } from 'lodash';
|
|
37
37
|
import '../../../css/helper-lines.css';
|
|
38
38
|
import { EditorContextService } from '../../base/editor-context-service';
|
|
39
39
|
import { FeedbackCommand } from '../../base/feedback/feedback-command';
|
|
@@ -125,7 +125,9 @@ export class DrawHelperLinesFeedbackCommand extends FeedbackCommand {
|
|
|
125
125
|
removeSelectionBounds(context.root);
|
|
126
126
|
const alignableElements = getMatchingElements(context.root.index, this.isAlignableElementPredicate);
|
|
127
127
|
this.log('All alignable elements: ', alignableElements);
|
|
128
|
-
const
|
|
128
|
+
const { match: referenceElements, rest: elements } = partition(alignableElements, (element): element is BoundsAwareModelElement =>
|
|
129
|
+
this.elementIds.includes(element.id)
|
|
130
|
+
);
|
|
129
131
|
this.log('Split alignable elements into reference elements and other elements: ', referenceElements, elements);
|
|
130
132
|
if (referenceElements.length === 0) {
|
|
131
133
|
this.log('--> No helper lines as we do not have any reference elements.');
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/********************************************************************************
|
|
2
|
-
* Copyright (c) 2024 EclipseSource and others.
|
|
2
|
+
* Copyright (c) 2024-2026 EclipseSource and others.
|
|
3
3
|
*
|
|
4
4
|
* This program and the accompanying materials are made available under the
|
|
5
5
|
* terms of the Eclipse Public License v. 2.0 which is available at
|
|
@@ -114,7 +114,7 @@ export class GLSPBezierEdgeRouter extends BezierEdgeRouter {
|
|
|
114
114
|
}
|
|
115
115
|
}
|
|
116
116
|
|
|
117
|
-
function ensureBounds(element?: GConnectableElement): boolean {
|
|
117
|
+
export function ensureBounds(element?: GConnectableElement): boolean {
|
|
118
118
|
if (!element) {
|
|
119
119
|
return false;
|
|
120
120
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/********************************************************************************
|
|
2
|
-
* Copyright (c) 2019-
|
|
2
|
+
* Copyright (c) 2019-2026 EclipseSource and others.
|
|
3
3
|
*
|
|
4
4
|
* This program and the accompanying materials are made available under the
|
|
5
5
|
* terms of the Eclipse Public License v. 2.0 which is available at
|
|
@@ -32,6 +32,8 @@ import {
|
|
|
32
32
|
configureCommand
|
|
33
33
|
} from '@eclipse-glsp/sprotty';
|
|
34
34
|
import { GLSPBezierEdgeRouter, GLSPManhattanEdgeRouter, GLSPPolylineEdgeRouter } from './edge-router';
|
|
35
|
+
import { StickyManhattanDiamondAnchor, StickyManhattanEllipticAnchor, StickyManhattanRectangularAnchor } from './sticky-manhattan-anchors';
|
|
36
|
+
import { GLSPStickyManhattanEdgeRouter } from './sticky-manhattan-edge-router';
|
|
35
37
|
|
|
36
38
|
export const routingModule = new FeatureModule(
|
|
37
39
|
(bind, unbind, isBound, rebind) => {
|
|
@@ -54,6 +56,11 @@ export const routingModule = new FeatureModule(
|
|
|
54
56
|
bindAsService(context, TYPES.IAnchorComputer, BezierRectangleAnchor);
|
|
55
57
|
bindAsService(context, TYPES.IAnchorComputer, BezierDiamondAnchor);
|
|
56
58
|
|
|
59
|
+
bindAsService(context, TYPES.IEdgeRouter, GLSPStickyManhattanEdgeRouter);
|
|
60
|
+
bindAsService(context, TYPES.IAnchorComputer, StickyManhattanEllipticAnchor);
|
|
61
|
+
bindAsService(context, TYPES.IAnchorComputer, StickyManhattanRectangularAnchor);
|
|
62
|
+
bindAsService(context, TYPES.IAnchorComputer, StickyManhattanDiamondAnchor);
|
|
63
|
+
|
|
57
64
|
configureCommand({ bind, isBound }, AddRemoveBezierSegmentCommand);
|
|
58
65
|
},
|
|
59
66
|
{ featureId: Symbol('routing') }
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/********************************************************************************
|
|
2
|
+
* Copyright (c) 2026 EclipseSource and others.
|
|
3
|
+
*
|
|
4
|
+
* This program and the accompanying materials are made available under the
|
|
5
|
+
* terms of the Eclipse Public License v. 2.0 which is available at
|
|
6
|
+
* http://www.eclipse.org/legal/epl-2.0.
|
|
7
|
+
*
|
|
8
|
+
* This Source Code may also be made available under the following Secondary
|
|
9
|
+
* Licenses when the conditions for such availability set forth in the Eclipse
|
|
10
|
+
* Public License v. 2.0 are satisfied: GNU General Public License, version 2
|
|
11
|
+
* with the GNU Classpath Exception which is available at
|
|
12
|
+
* https://www.gnu.org/software/classpath/license.html.
|
|
13
|
+
*
|
|
14
|
+
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
|
|
15
|
+
********************************************************************************/
|
|
16
|
+
import {
|
|
17
|
+
DIAMOND_ANCHOR_KIND,
|
|
18
|
+
ELLIPTIC_ANCHOR_KIND,
|
|
19
|
+
ManhattanDiamondAnchor,
|
|
20
|
+
ManhattanEllipticAnchor,
|
|
21
|
+
ManhattanRectangularAnchor,
|
|
22
|
+
RECTANGULAR_ANCHOR_KIND
|
|
23
|
+
} from '@eclipse-glsp/sprotty';
|
|
24
|
+
import { injectable } from 'inversify';
|
|
25
|
+
import { GLSPStickyManhattanEdgeRouter } from './sticky-manhattan-edge-router';
|
|
26
|
+
|
|
27
|
+
// Anchor computers are keyed by `<routerKind>:<anchorKind>` in the AnchorComputerRegistry.
|
|
28
|
+
// The sticky router has its own routerKind, so dedicated subclasses must be registered even
|
|
29
|
+
// though their geometry behavior is identical to the standard Manhattan anchors.
|
|
30
|
+
|
|
31
|
+
@injectable()
|
|
32
|
+
export class StickyManhattanRectangularAnchor extends ManhattanRectangularAnchor {
|
|
33
|
+
static override readonly KIND = GLSPStickyManhattanEdgeRouter.KIND + ':' + RECTANGULAR_ANCHOR_KIND;
|
|
34
|
+
override get kind(): string {
|
|
35
|
+
return StickyManhattanRectangularAnchor.KIND;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
@injectable()
|
|
40
|
+
export class StickyManhattanDiamondAnchor extends ManhattanDiamondAnchor {
|
|
41
|
+
static override readonly KIND = GLSPStickyManhattanEdgeRouter.KIND + ':' + DIAMOND_ANCHOR_KIND;
|
|
42
|
+
override get kind(): string {
|
|
43
|
+
return StickyManhattanDiamondAnchor.KIND;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
@injectable()
|
|
48
|
+
export class StickyManhattanEllipticAnchor extends ManhattanEllipticAnchor {
|
|
49
|
+
static override readonly KIND = GLSPStickyManhattanEdgeRouter.KIND + ':' + ELLIPTIC_ANCHOR_KIND;
|
|
50
|
+
override get kind(): string {
|
|
51
|
+
return StickyManhattanEllipticAnchor.KIND;
|
|
52
|
+
}
|
|
53
|
+
}
|