@eclipse-glsp/client 2.7.0-next.24 → 2.7.0-next.25
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/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/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 +19 -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 +4 -0
- package/lib/features/export/export-svg-action-handler.d.ts.map +1 -1
- package/lib/features/export/export-svg-action-handler.js +5 -1
- 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 +43 -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/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/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 +6 -0
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +6 -0
- package/lib/index.js.map +1 -1
- package/package.json +3 -3
- package/src/base/model/diagram-loader.ts +8 -6
- 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 +23 -4
- package/src/features/export/export-result-action-handler.ts +66 -0
- package/src/features/export/export-svg-action-handler.ts +5 -1
- package/src/features/export/glsp-svg-exporter.ts +47 -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/tool-palette/tool-palette.ts +1 -1
- package/src/features/viewport/origin-viewport.ts +10 -23
- package/src/index.ts +6 -0
|
@@ -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
|
|
@@ -17,22 +17,37 @@ import {
|
|
|
17
17
|
bindAsService,
|
|
18
18
|
configureActionHandler,
|
|
19
19
|
configureCommand,
|
|
20
|
+
ExportResultAction,
|
|
20
21
|
ExportSvgAction,
|
|
21
22
|
ExportSvgCommand,
|
|
22
|
-
ExportSvgKeyListener,
|
|
23
23
|
ExportSvgPostprocessor,
|
|
24
24
|
FeatureModule,
|
|
25
25
|
TYPES
|
|
26
26
|
} from '@eclipse-glsp/sprotty';
|
|
27
|
+
import { DefaultPngDiagramExporter } from './default-png-diagram-exporter';
|
|
28
|
+
import { DefaultSvgDiagramExporter } from './default-svg-diagram-exporter';
|
|
29
|
+
import { DiagramExportPostprocessor } from './diagram-export-postprocessor';
|
|
30
|
+
import { ExportResultActionHandler } from './export-result-action-handler';
|
|
27
31
|
import { ExportSvgActionHandler } from './export-svg-action-handler';
|
|
28
32
|
import { GLSPSvgExporter } from './glsp-svg-exporter';
|
|
33
|
+
import { RequestExportCommand } from './request-export-command';
|
|
34
|
+
import { RequestExportKeyListener } from './request-export-key-listener';
|
|
29
35
|
|
|
30
36
|
export const exportModule = new FeatureModule(
|
|
31
37
|
(bind, _unbind, isBound) => {
|
|
32
38
|
const context = { bind, isBound };
|
|
39
|
+
bindAsService(context, TYPES.SvgExporter, GLSPSvgExporter);
|
|
40
|
+
|
|
41
|
+
// Unified export pipeline.
|
|
42
|
+
bindAsService(context, TYPES.HiddenVNodePostprocessor, DiagramExportPostprocessor);
|
|
43
|
+
configureCommand(context, RequestExportCommand);
|
|
44
|
+
bindAsService(context, TYPES.IDiagramExporter, DefaultSvgDiagramExporter);
|
|
45
|
+
bindAsService(context, TYPES.IDiagramExporter, DefaultPngDiagramExporter);
|
|
46
|
+
|
|
47
|
+
// Legacy SVG-only pipeline kept functional for adopters still dispatching the
|
|
48
|
+
// deprecated `RequestExportSvgAction` / `ExportSvgAction`.
|
|
33
49
|
bindAsService(context, TYPES.HiddenVNodePostprocessor, ExportSvgPostprocessor);
|
|
34
50
|
configureCommand(context, ExportSvgCommand);
|
|
35
|
-
bind(TYPES.SvgExporter).to(GLSPSvgExporter).inSingletonScope();
|
|
36
51
|
},
|
|
37
52
|
{ featureId: Symbol('export') }
|
|
38
53
|
);
|
|
@@ -45,7 +60,11 @@ export const exportModule = new FeatureModule(
|
|
|
45
60
|
export const standaloneExportModule = new FeatureModule(
|
|
46
61
|
(bind, _unbind, isBound) => {
|
|
47
62
|
const context = { bind, isBound };
|
|
48
|
-
bindAsService(context, TYPES.KeyListener,
|
|
63
|
+
bindAsService(context, TYPES.KeyListener, RequestExportKeyListener);
|
|
64
|
+
bind(ExportResultActionHandler).toSelf().inSingletonScope();
|
|
65
|
+
configureActionHandler(context, ExportResultAction.KIND, ExportResultActionHandler);
|
|
66
|
+
|
|
67
|
+
// Legacy download path: bound so adopters dispatching `ExportSvgAction` still get a download.
|
|
49
68
|
bind(ExportSvgActionHandler).toSelf().inSingletonScope();
|
|
50
69
|
configureActionHandler(context, ExportSvgAction.KIND, ExportSvgActionHandler);
|
|
51
70
|
},
|
|
@@ -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
|
|
@@ -22,6 +22,10 @@ import { ExportSvgAction, IActionHandler } from '@eclipse-glsp/sprotty';
|
|
|
22
22
|
* any GLSP project independent of the target platform. However, platform integration modules typically
|
|
23
23
|
* * this handler is rebound to an application specific handler in platform integration modules
|
|
24
24
|
* (e.g. the Theia integration)
|
|
25
|
+
*
|
|
26
|
+
* @deprecated Use the unified export pipeline ({@link RequestExportAction} +
|
|
27
|
+
* {@link DiagramExporter}) and bind your own {@link IActionHandler} for
|
|
28
|
+
* {@link ExportResultAction} instead.
|
|
25
29
|
*/
|
|
26
30
|
@injectable()
|
|
27
31
|
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
|
|
@@ -18,6 +18,7 @@ import {
|
|
|
18
18
|
ExportSvgAction,
|
|
19
19
|
ExportSvgOptions,
|
|
20
20
|
GModelRoot,
|
|
21
|
+
RejectAction,
|
|
21
22
|
RequestAction,
|
|
22
23
|
RequestExportSvgAction,
|
|
23
24
|
SvgExporter
|
|
@@ -27,18 +28,52 @@ import { v4 as uuid } from 'uuid';
|
|
|
27
28
|
|
|
28
29
|
@injectable()
|
|
29
30
|
export class GLSPSvgExporter extends SvgExporter {
|
|
31
|
+
/**
|
|
32
|
+
* Legacy entry point for the SVG-only export flow. New code should use the unified
|
|
33
|
+
* `RequestExportAction` flow (registered via the `DiagramExporter` registry);
|
|
34
|
+
* adopters that previously bound {@link RequestExportSvgAction} should migrate to
|
|
35
|
+
* `RequestExportAction` with `format: 'svg'`.
|
|
36
|
+
*
|
|
37
|
+
* @deprecated Use the unified export pipeline. Retained for backward compatibility
|
|
38
|
+
* with the legacy {@link RequestExportSvgAction} / {@link ExportSvgAction} flow.
|
|
39
|
+
*/
|
|
30
40
|
override export(root: GModelRoot, request?: RequestExportSvgAction): void {
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
41
|
+
try {
|
|
42
|
+
const svgExport = this.exportToString(root, request?.options, request);
|
|
43
|
+
this.actionDispatcher.dispatch(
|
|
44
|
+
ExportSvgAction.create(svgExport, { responseId: request?.requestId, options: request?.options })
|
|
45
|
+
);
|
|
46
|
+
} catch (err: unknown) {
|
|
47
|
+
this.dispatchRejectionIfRequested(request, err instanceof Error ? err.message : String(err));
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Produce the serialised SVG string without dispatching any action. Throws on
|
|
53
|
+
* failure (no document, no SVG element). Used by the legacy `export()` path and
|
|
54
|
+
* by unified-export strategies (`DefaultSvgDiagramExporter`, `DefaultPngDiagramExporter`)
|
|
55
|
+
* that need the SVG bytes without the action-dispatch side effect.
|
|
56
|
+
*/
|
|
57
|
+
exportToString(root: GModelRoot, options?: ExportSvgOptions, cause?: Action): string {
|
|
58
|
+
if (typeof document === 'undefined') {
|
|
59
|
+
throw new Error('SVG export failed: document is not available');
|
|
60
|
+
}
|
|
61
|
+
let svgElement = this.findSvgElement();
|
|
62
|
+
if (!svgElement) {
|
|
63
|
+
throw new Error('SVG export failed: SVG element not found');
|
|
64
|
+
}
|
|
65
|
+
// Only the legacy SVG-only flow carries a `RequestExportSvgAction`; under the unified
|
|
66
|
+
// export flow `cause` is a `RequestExportAction` and the legacy override hooks are
|
|
67
|
+
// intentionally invoked with `undefined`.
|
|
68
|
+
const request = RequestExportSvgAction.is(cause) ? cause : undefined;
|
|
69
|
+
svgElement = this.prepareSvgElement(svgElement, root, request);
|
|
70
|
+
const serializedSvg = this.createSvg(svgElement, root, options ?? {}, cause);
|
|
71
|
+
return this.getSvgExport(serializedSvg, svgElement, root, request);
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
protected dispatchRejectionIfRequested(request: RequestExportSvgAction | undefined, message: string): void {
|
|
75
|
+
if (request?.requestId) {
|
|
76
|
+
this.actionDispatcher.dispatch(RejectAction.create(message, { responseId: request.requestId }));
|
|
42
77
|
}
|
|
43
78
|
}
|
|
44
79
|
|
|
@@ -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
|
+
}
|
|
@@ -20,6 +20,7 @@ import {
|
|
|
20
20
|
IActionHandler,
|
|
21
21
|
ICommand,
|
|
22
22
|
MarkersReason,
|
|
23
|
+
OriginViewportAction,
|
|
23
24
|
PaletteItem,
|
|
24
25
|
RequestContextActions,
|
|
25
26
|
RequestMarkersAction,
|
|
@@ -43,7 +44,6 @@ import { IDebugManager } from '../debug/debug-manager';
|
|
|
43
44
|
import { IGridManager } from '../grid/grid-manager';
|
|
44
45
|
import { MouseDeleteTool } from '../tools/deletion/delete-tool';
|
|
45
46
|
import { MarqueeMouseTool } from '../tools/marquee-selection/marquee-mouse-tool';
|
|
46
|
-
import { OriginViewportAction } from '../viewport/origin-viewport';
|
|
47
47
|
|
|
48
48
|
const CLICKED_CSS_CLASS = 'clicked';
|
|
49
49
|
const SEARCH_ICON_ID = 'search';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/********************************************************************************
|
|
2
|
-
* Copyright (c) 2024-
|
|
2
|
+
* Copyright (c) 2024-2026 Axon Ivy AG 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
|
|
@@ -14,31 +14,18 @@
|
|
|
14
14
|
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
|
|
15
15
|
********************************************************************************/
|
|
16
16
|
|
|
17
|
-
import {
|
|
17
|
+
import {
|
|
18
|
+
Bounds,
|
|
19
|
+
BoundsAwareViewportCommand,
|
|
20
|
+
GModelRoot,
|
|
21
|
+
OriginViewportAction,
|
|
22
|
+
TYPES,
|
|
23
|
+
Viewport,
|
|
24
|
+
limitViewport
|
|
25
|
+
} from '@eclipse-glsp/sprotty';
|
|
18
26
|
import { inject, injectable } from 'inversify';
|
|
19
27
|
import { EditorContextService } from '../../base/editor-context-service';
|
|
20
28
|
|
|
21
|
-
export interface OriginViewportAction extends Action {
|
|
22
|
-
kind: typeof OriginViewportAction.KIND;
|
|
23
|
-
animate: boolean;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
export namespace OriginViewportAction {
|
|
27
|
-
export const KIND = 'originViewport';
|
|
28
|
-
|
|
29
|
-
export function is(object: any): object is OriginViewportAction {
|
|
30
|
-
return Action.hasKind(object, KIND);
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
export function create(options: { animate?: boolean } = {}): OriginViewportAction {
|
|
34
|
-
return {
|
|
35
|
-
kind: KIND,
|
|
36
|
-
animate: true,
|
|
37
|
-
...options
|
|
38
|
-
};
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
|
|
42
29
|
@injectable()
|
|
43
30
|
export class OriginViewportCommand extends BoundsAwareViewportCommand {
|
|
44
31
|
static readonly KIND = OriginViewportAction.KIND;
|
package/src/index.ts
CHANGED
|
@@ -132,9 +132,15 @@ export * from './features/element-template/add-template-element';
|
|
|
132
132
|
export * from './features/element-template/element-template-module';
|
|
133
133
|
export * from './features/element-template/mouse-tracking-element-position-listener';
|
|
134
134
|
export * from './features/element-template/remove-template-element';
|
|
135
|
+
export * from './features/export/default-png-diagram-exporter';
|
|
136
|
+
export * from './features/export/default-svg-diagram-exporter';
|
|
137
|
+
export * from './features/export/diagram-export-postprocessor';
|
|
138
|
+
export * from './features/export/diagram-exporter';
|
|
135
139
|
export * from './features/export/export-modules';
|
|
140
|
+
export * from './features/export/export-result-action-handler';
|
|
136
141
|
export * from './features/export/export-svg-action-handler';
|
|
137
142
|
export * from './features/export/glsp-svg-exporter';
|
|
143
|
+
export * from './features/export/request-export-command';
|
|
138
144
|
export * from './features/grid/grid';
|
|
139
145
|
export * from './features/grid/grid-manager';
|
|
140
146
|
export * from './features/grid/grid-model';
|