@finos/legend-extension-dsl-diagram 7.0.3 → 7.0.4
Sign up to get free protection for your applications and to get access to all the features.
- package/lib/{DSL_Diagram_DiagramRenderer.d.ts → DiagramRenderer.d.ts} +10 -2
- package/lib/DiagramRenderer.d.ts.map +1 -0
- package/lib/{DSL_Diagram_DiagramRenderer.js → DiagramRenderer.js} +64 -66
- package/lib/DiagramRenderer.js.map +1 -0
- package/lib/components/studio/DSL_Diagram_LegendStudioApplicationPlugin.d.ts +2 -0
- package/lib/components/studio/DSL_Diagram_LegendStudioApplicationPlugin.d.ts.map +1 -1
- package/lib/components/studio/DSL_Diagram_LegendStudioApplicationPlugin.js +5 -0
- package/lib/components/studio/DSL_Diagram_LegendStudioApplicationPlugin.js.map +1 -1
- package/lib/components/studio/DSL_Diagram_LegendStudioCommand.d.ts +28 -0
- package/lib/components/studio/DSL_Diagram_LegendStudioCommand.d.ts.map +1 -0
- package/lib/components/studio/DSL_Diagram_LegendStudioCommand.js +62 -0
- package/lib/components/studio/DSL_Diagram_LegendStudioCommand.js.map +1 -0
- package/lib/components/studio/DiagramEditor.d.ts.map +1 -1
- package/lib/components/studio/DiagramEditor.js +13 -11
- package/lib/components/studio/DiagramEditor.js.map +1 -1
- package/lib/components/studio/InheritanceDiagramRenderer.d.ts +1 -1
- package/lib/components/studio/InheritanceDiagramRenderer.d.ts.map +1 -1
- package/lib/components/studio/InheritanceDiagramRenderer.js +1 -1
- package/lib/components/studio/InheritanceDiagramRenderer.js.map +1 -1
- package/lib/index.css +1 -1
- package/lib/index.d.ts +1 -1
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +1 -1
- package/lib/index.js.map +1 -1
- package/lib/package.json +4 -4
- package/lib/stores/studio/DiagramEditorState.d.ts +5 -4
- package/lib/stores/studio/DiagramEditorState.d.ts.map +1 -1
- package/lib/stores/studio/DiagramEditorState.js +59 -62
- package/lib/stores/studio/DiagramEditorState.js.map +1 -1
- package/package.json +11 -11
- package/src/{DSL_Diagram_DiagramRenderer.ts → DiagramRenderer.ts} +108 -101
- package/src/components/studio/DSL_Diagram_LegendStudioApplicationPlugin.tsx +12 -1
- package/src/components/studio/DSL_Diagram_LegendStudioCommand.ts +64 -0
- package/src/components/studio/DiagramEditor.tsx +23 -18
- package/src/components/studio/InheritanceDiagramRenderer.ts +1 -1
- package/src/index.ts +1 -1
- package/src/stores/studio/DiagramEditorState.ts +76 -83
- package/tsconfig.json +2 -1
- package/lib/DSL_Diagram_DiagramRenderer.d.ts.map +0 -1
- package/lib/DSL_Diagram_DiagramRenderer.js.map +0 -1
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@finos/legend-extension-dsl-diagram",
|
3
|
-
"version": "7.0.
|
3
|
+
"version": "7.0.4",
|
4
4
|
"description": "Legend extension for Diagram DSL",
|
5
5
|
"keywords": [
|
6
6
|
"legend",
|
@@ -43,27 +43,27 @@
|
|
43
43
|
"test:watch": "jest --watch"
|
44
44
|
},
|
45
45
|
"dependencies": {
|
46
|
-
"@finos/legend-application": "
|
47
|
-
"@finos/legend-application-studio": "
|
48
|
-
"@finos/legend-art": "4.0
|
49
|
-
"@finos/legend-graph": "
|
50
|
-
"@finos/legend-shared": "6.1.
|
51
|
-
"@finos/legend-storage": "3.0.
|
46
|
+
"@finos/legend-application": "10.0.0",
|
47
|
+
"@finos/legend-application-studio": "19.0.0",
|
48
|
+
"@finos/legend-art": "4.1.0",
|
49
|
+
"@finos/legend-graph": "19.0.0",
|
50
|
+
"@finos/legend-shared": "6.1.5",
|
51
|
+
"@finos/legend-storage": "3.0.14",
|
52
52
|
"@types/react": "18.0.21",
|
53
53
|
"mobx": "6.6.2",
|
54
54
|
"mobx-react-lite": "3.4.0",
|
55
55
|
"react": "18.2.0",
|
56
56
|
"react-dnd": "16.0.1",
|
57
57
|
"react-dom": "18.2.0",
|
58
|
-
"serializr": "
|
58
|
+
"serializr": "3.0.1"
|
59
59
|
},
|
60
60
|
"devDependencies": {
|
61
|
-
"@finos/legend-dev-utils": "2.0.
|
62
|
-
"@jest/globals": "29.1
|
61
|
+
"@finos/legend-dev-utils": "2.0.21",
|
62
|
+
"@jest/globals": "29.2.1",
|
63
63
|
"@testing-library/react": "13.4.0",
|
64
64
|
"cross-env": "7.0.3",
|
65
65
|
"eslint": "8.25.0",
|
66
|
-
"jest": "29.1
|
66
|
+
"jest": "29.2.1",
|
67
67
|
"jest-canvas-mock": "2.4.0",
|
68
68
|
"npm-run-all": "4.1.5",
|
69
69
|
"rimraf": "3.0.2",
|
@@ -89,6 +89,7 @@ import {
|
|
89
89
|
relationshipView_simplifyPath,
|
90
90
|
relationshipView_setPath,
|
91
91
|
} from './stores/studio/DSL_Diagram_GraphModifierHelper.js';
|
92
|
+
import { forceDispatchKeyboardEvent } from '@finos/legend-application';
|
92
93
|
|
93
94
|
export enum DIAGRAM_INTERACTION_MODE {
|
94
95
|
LAYOUT,
|
@@ -559,7 +560,7 @@ export class DiagramRenderer {
|
|
559
560
|
}
|
560
561
|
|
561
562
|
autoRecenter(): void {
|
562
|
-
this.
|
563
|
+
this.center(
|
563
564
|
this.virtualScreen.position.x + this.virtualScreen.rectangle.width / 2,
|
564
565
|
this.virtualScreen.position.y + this.virtualScreen.rectangle.height / 2,
|
565
566
|
);
|
@@ -568,7 +569,7 @@ export class DiagramRenderer {
|
|
568
569
|
/**
|
569
570
|
* Reset the screen offset
|
570
571
|
*/
|
571
|
-
private
|
572
|
+
private center(x: number, y: number): void {
|
572
573
|
this.screenOffset = new Point(
|
573
574
|
-x + this.canvasCenter.x,
|
574
575
|
-y + this.canvasCenter.y,
|
@@ -2292,7 +2293,109 @@ export class DiagramRenderer {
|
|
2292
2293
|
});
|
2293
2294
|
}
|
2294
2295
|
|
2296
|
+
// -------------------------------- Actions ------------------------------
|
2297
|
+
|
2298
|
+
recenter(): void {
|
2299
|
+
if (this.selectedClasses.length !== 0) {
|
2300
|
+
const firstClass = getNullableFirstElement(this.selectedClasses);
|
2301
|
+
if (firstClass) {
|
2302
|
+
this.center(
|
2303
|
+
firstClass.position.x + firstClass.rectangle.width / 2,
|
2304
|
+
firstClass.position.y + firstClass.rectangle.height / 2,
|
2305
|
+
);
|
2306
|
+
}
|
2307
|
+
} else {
|
2308
|
+
this.autoRecenter();
|
2309
|
+
}
|
2310
|
+
}
|
2311
|
+
|
2312
|
+
switchToZoomMode(): void {
|
2313
|
+
this.changeMode(
|
2314
|
+
this.interactionMode !== DIAGRAM_INTERACTION_MODE.ZOOM_IN
|
2315
|
+
? DIAGRAM_INTERACTION_MODE.ZOOM_IN
|
2316
|
+
: DIAGRAM_INTERACTION_MODE.ZOOM_OUT,
|
2317
|
+
DIAGRAM_RELATIONSHIP_EDIT_MODE.NONE,
|
2318
|
+
);
|
2319
|
+
}
|
2320
|
+
|
2321
|
+
switchToViewMode(): void {
|
2322
|
+
this.changeMode(
|
2323
|
+
DIAGRAM_INTERACTION_MODE.LAYOUT,
|
2324
|
+
DIAGRAM_RELATIONSHIP_EDIT_MODE.NONE,
|
2325
|
+
);
|
2326
|
+
}
|
2327
|
+
|
2328
|
+
switchToPanMode(): void {
|
2329
|
+
this.changeMode(
|
2330
|
+
DIAGRAM_INTERACTION_MODE.PAN,
|
2331
|
+
DIAGRAM_RELATIONSHIP_EDIT_MODE.NONE,
|
2332
|
+
);
|
2333
|
+
}
|
2334
|
+
|
2335
|
+
switchToAddPropertyMode(): void {
|
2336
|
+
if (!this.isReadOnly) {
|
2337
|
+
this.changeMode(
|
2338
|
+
DIAGRAM_INTERACTION_MODE.ADD_RELATIONSHIP,
|
2339
|
+
DIAGRAM_RELATIONSHIP_EDIT_MODE.PROPERTY,
|
2340
|
+
);
|
2341
|
+
}
|
2342
|
+
}
|
2343
|
+
|
2344
|
+
switchToAddInheritanceMode(): void {
|
2345
|
+
if (!this.isReadOnly) {
|
2346
|
+
this.changeMode(
|
2347
|
+
DIAGRAM_INTERACTION_MODE.ADD_RELATIONSHIP,
|
2348
|
+
DIAGRAM_RELATIONSHIP_EDIT_MODE.INHERITANCE,
|
2349
|
+
);
|
2350
|
+
}
|
2351
|
+
}
|
2352
|
+
|
2353
|
+
switchToAddClassMode(): void {
|
2354
|
+
if (!this.isReadOnly) {
|
2355
|
+
this.changeMode(
|
2356
|
+
DIAGRAM_INTERACTION_MODE.ADD_CLASS,
|
2357
|
+
DIAGRAM_RELATIONSHIP_EDIT_MODE.NONE,
|
2358
|
+
);
|
2359
|
+
}
|
2360
|
+
}
|
2361
|
+
|
2362
|
+
ejectProperty(): void {
|
2363
|
+
if (!this.isReadOnly) {
|
2364
|
+
if (this.mouseOverClassProperty) {
|
2365
|
+
if (
|
2366
|
+
this.mouseOverClassProperty.genericType.value.rawType instanceof Class
|
2367
|
+
) {
|
2368
|
+
this.addClassView(
|
2369
|
+
this.mouseOverClassProperty.genericType.value.rawType,
|
2370
|
+
this.canvasCoordinateToModelCoordinate(
|
2371
|
+
this.eventCoordinateToCanvasCoordinate(
|
2372
|
+
new Point(this.cursorPosition.x, this.cursorPosition.y),
|
2373
|
+
),
|
2374
|
+
),
|
2375
|
+
);
|
2376
|
+
}
|
2377
|
+
} else if (this.selectedClassProperty) {
|
2378
|
+
if (
|
2379
|
+
this.selectedClassProperty.property.genericType.value
|
2380
|
+
.rawType instanceof Class
|
2381
|
+
) {
|
2382
|
+
this.addClassView(
|
2383
|
+
this.selectedClassProperty.property.genericType.value.rawType,
|
2384
|
+
this.selectedClassProperty.selectionPoint,
|
2385
|
+
);
|
2386
|
+
}
|
2387
|
+
this.selectedClassProperty = undefined;
|
2388
|
+
}
|
2389
|
+
}
|
2390
|
+
}
|
2391
|
+
|
2392
|
+
// --------------------------------- Event handler --------------------------
|
2393
|
+
|
2295
2394
|
keydown(e: KeyboardEvent): void {
|
2395
|
+
// NOTE: Since <canvas> element does not bubble `keydown` event naturally, we will
|
2396
|
+
// manually do this in order to take advantage of application keyboard shortcuts service
|
2397
|
+
forceDispatchKeyboardEvent(e);
|
2398
|
+
|
2296
2399
|
// Remove selected view(s)
|
2297
2400
|
if ('Delete' === e.key) {
|
2298
2401
|
if (!this.isReadOnly) {
|
@@ -2357,7 +2460,7 @@ export class DiagramRenderer {
|
|
2357
2460
|
);
|
2358
2461
|
}
|
2359
2462
|
}
|
2360
|
-
this.
|
2463
|
+
this.setSelectedClasses([]);
|
2361
2464
|
this.drawScreen();
|
2362
2465
|
}
|
2363
2466
|
}
|
@@ -2390,72 +2493,6 @@ export class DiagramRenderer {
|
|
2390
2493
|
}
|
2391
2494
|
}
|
2392
2495
|
|
2393
|
-
// Recenter
|
2394
|
-
else if ('r' === e.key) {
|
2395
|
-
if (this.selectedClasses.length !== 0) {
|
2396
|
-
const firstClass = getNullableFirstElement(this.selectedClasses);
|
2397
|
-
if (firstClass) {
|
2398
|
-
this.recenter(
|
2399
|
-
firstClass.position.x + firstClass.rectangle.width / 2,
|
2400
|
-
firstClass.position.y + firstClass.rectangle.height / 2,
|
2401
|
-
);
|
2402
|
-
}
|
2403
|
-
} else {
|
2404
|
-
this.autoRecenter();
|
2405
|
-
}
|
2406
|
-
}
|
2407
|
-
// Zoom
|
2408
|
-
else if ('z' === e.key) {
|
2409
|
-
this.changeMode(
|
2410
|
-
this.interactionMode !== DIAGRAM_INTERACTION_MODE.ZOOM_IN
|
2411
|
-
? DIAGRAM_INTERACTION_MODE.ZOOM_IN
|
2412
|
-
: DIAGRAM_INTERACTION_MODE.ZOOM_OUT,
|
2413
|
-
DIAGRAM_RELATIONSHIP_EDIT_MODE.NONE,
|
2414
|
-
);
|
2415
|
-
}
|
2416
|
-
|
2417
|
-
// Use View Tool
|
2418
|
-
else if ('v' === e.key) {
|
2419
|
-
this.changeMode(
|
2420
|
-
DIAGRAM_INTERACTION_MODE.LAYOUT,
|
2421
|
-
DIAGRAM_RELATIONSHIP_EDIT_MODE.NONE,
|
2422
|
-
);
|
2423
|
-
}
|
2424
|
-
// Use Pan Tool
|
2425
|
-
else if ('m' === e.key) {
|
2426
|
-
this.changeMode(
|
2427
|
-
DIAGRAM_INTERACTION_MODE.PAN,
|
2428
|
-
DIAGRAM_RELATIONSHIP_EDIT_MODE.NONE,
|
2429
|
-
);
|
2430
|
-
}
|
2431
|
-
// Use Property Tool
|
2432
|
-
else if ('p' === e.key) {
|
2433
|
-
if (!this.isReadOnly) {
|
2434
|
-
this.changeMode(
|
2435
|
-
DIAGRAM_INTERACTION_MODE.ADD_RELATIONSHIP,
|
2436
|
-
DIAGRAM_RELATIONSHIP_EDIT_MODE.PROPERTY,
|
2437
|
-
);
|
2438
|
-
}
|
2439
|
-
}
|
2440
|
-
// Use Inheritance Tool
|
2441
|
-
else if ('i' === e.key) {
|
2442
|
-
if (!this.isReadOnly) {
|
2443
|
-
this.changeMode(
|
2444
|
-
DIAGRAM_INTERACTION_MODE.ADD_RELATIONSHIP,
|
2445
|
-
DIAGRAM_RELATIONSHIP_EDIT_MODE.INHERITANCE,
|
2446
|
-
);
|
2447
|
-
}
|
2448
|
-
}
|
2449
|
-
// Add Class
|
2450
|
-
else if ('c' === e.key) {
|
2451
|
-
if (!this.isReadOnly) {
|
2452
|
-
this.changeMode(
|
2453
|
-
DIAGRAM_INTERACTION_MODE.ADD_CLASS,
|
2454
|
-
DIAGRAM_RELATIONSHIP_EDIT_MODE.NONE,
|
2455
|
-
);
|
2456
|
-
}
|
2457
|
-
}
|
2458
|
-
|
2459
2496
|
// Hide/show properties for selected element(s)
|
2460
2497
|
else if (e.altKey && 'KeyP' === e.code) {
|
2461
2498
|
if (!this.isReadOnly) {
|
@@ -2500,38 +2537,6 @@ export class DiagramRenderer {
|
|
2500
2537
|
}
|
2501
2538
|
}
|
2502
2539
|
|
2503
|
-
// Eject the property
|
2504
|
-
else if ('ArrowRight' === e.key) {
|
2505
|
-
if (!this.isReadOnly) {
|
2506
|
-
if (this.mouseOverClassProperty) {
|
2507
|
-
if (
|
2508
|
-
this.mouseOverClassProperty.genericType.value.rawType instanceof
|
2509
|
-
Class
|
2510
|
-
) {
|
2511
|
-
this.addClassView(
|
2512
|
-
this.mouseOverClassProperty.genericType.value.rawType,
|
2513
|
-
this.canvasCoordinateToModelCoordinate(
|
2514
|
-
this.eventCoordinateToCanvasCoordinate(
|
2515
|
-
new Point(this.cursorPosition.x, this.cursorPosition.y),
|
2516
|
-
),
|
2517
|
-
),
|
2518
|
-
);
|
2519
|
-
}
|
2520
|
-
} else if (this.selectedClassProperty) {
|
2521
|
-
if (
|
2522
|
-
this.selectedClassProperty.property.genericType.value
|
2523
|
-
.rawType instanceof Class
|
2524
|
-
) {
|
2525
|
-
this.addClassView(
|
2526
|
-
this.selectedClassProperty.property.genericType.value.rawType,
|
2527
|
-
this.selectedClassProperty.selectionPoint,
|
2528
|
-
);
|
2529
|
-
}
|
2530
|
-
this.selectedClassProperty = undefined;
|
2531
|
-
}
|
2532
|
-
}
|
2533
|
-
}
|
2534
|
-
|
2535
2540
|
// Add supertypes of selected classes to the diagram
|
2536
2541
|
else if ('ArrowUp' === e.key) {
|
2537
2542
|
const views = this.getSuperTypeLevels(
|
@@ -3436,6 +3441,8 @@ export class DiagramRenderer {
|
|
3436
3441
|
return [];
|
3437
3442
|
}
|
3438
3443
|
|
3444
|
+
// --------------------------------------- Extension -----------------------------------
|
3445
|
+
|
3439
3446
|
layoutTaxonomy(
|
3440
3447
|
classViewLevels: ClassView[][],
|
3441
3448
|
diagram: Diagram,
|
@@ -53,8 +53,13 @@ import {
|
|
53
53
|
getDiagramSnippetWithOneClassView,
|
54
54
|
getDiagramSnippetWithPropertyView,
|
55
55
|
} from './DSL_Diagram_CodeSnippets.js';
|
56
|
-
import
|
56
|
+
import {
|
57
|
+
collectKeyedCommandConfigEntriesFromConfig,
|
58
|
+
type DocumentationEntry,
|
59
|
+
type KeyedCommandConfigEntry,
|
60
|
+
} from '@finos/legend-application';
|
57
61
|
import { DSL_DIAGRAM_LEGEND_STUDIO_APPLICATION_NAVIGATION_CONTEXT_KEY } from '../../stores/studio/DSL_Diagram_LegendStudioApplicationNavigationContext.js';
|
62
|
+
import { DSL_DIAGRAM_LEGEND_STUDIO_COMMAND_CONFIG } from './DSL_Diagram_LegendStudioCommand.js';
|
58
63
|
|
59
64
|
const DIAGRAM_ELEMENT_TYPE = 'DIAGRAM';
|
60
65
|
const DIAGRAM_ELEMENT_PROJECT_EXPLORER_DND_TYPE = 'PROJECT_EXPLORER_DIAGRAM';
|
@@ -67,6 +72,12 @@ export class DSL_Diagram_LegendStudioApplicationPlugin
|
|
67
72
|
super(packageJson.extensions.applicationStudioPlugin, packageJson.version);
|
68
73
|
}
|
69
74
|
|
75
|
+
override getExtraKeyedCommandConfigEntries(): KeyedCommandConfigEntry[] {
|
76
|
+
return collectKeyedCommandConfigEntriesFromConfig(
|
77
|
+
DSL_DIAGRAM_LEGEND_STUDIO_COMMAND_CONFIG,
|
78
|
+
);
|
79
|
+
}
|
80
|
+
|
70
81
|
override getExtraRequiredDocumentationKeys(): string[] {
|
71
82
|
return [
|
72
83
|
DSL_DIAGRAM_LEGEND_STUDIO_DOCUMENTATION_KEY.GRAMMAR_ELEMENT_DIAGRAM,
|
@@ -0,0 +1,64 @@
|
|
1
|
+
/**
|
2
|
+
* Copyright (c) 2020-present, Goldman Sachs
|
3
|
+
*
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
5
|
+
* you may not use this file except in compliance with the License.
|
6
|
+
* You may obtain a copy of the License at
|
7
|
+
*
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
9
|
+
*
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
13
|
+
* See the License for the specific language governing permissions and
|
14
|
+
* limitations under the License.
|
15
|
+
*/
|
16
|
+
|
17
|
+
import type { CommandConfigData } from '@finos/legend-application';
|
18
|
+
|
19
|
+
export enum DSL_DIAGRAM_LEGEND_STUDIO_COMMAND_KEY {
|
20
|
+
RECENTER = 'dsl-diagram.diagram-editor.recenter',
|
21
|
+
USE_ZOOM_TOOL = 'dsl-diagram.diagram-editor.use-zoom-tool',
|
22
|
+
USE_VIEW_TOOL = 'dsl-diagram.diagram-editor.use-view-tool',
|
23
|
+
USE_PAN_TOOL = 'dsl-diagram.diagram-editor.use-pan-tool',
|
24
|
+
USE_PROPERTY_TOOL = 'dsl-diagram.diagram-editor.use-property-tool',
|
25
|
+
USE_INHERITANCE_TOOL = 'dsl-diagram.diagram-editor.use-inheritance-tool',
|
26
|
+
ADD_CLASS = 'dsl-diagram.diagram-editor.add-class',
|
27
|
+
EJECT_PROPERTY = 'dsl-diagram.diagram-editor.eject-property',
|
28
|
+
}
|
29
|
+
|
30
|
+
export const DSL_DIAGRAM_LEGEND_STUDIO_COMMAND_CONFIG: CommandConfigData = {
|
31
|
+
[DSL_DIAGRAM_LEGEND_STUDIO_COMMAND_KEY.RECENTER]: {
|
32
|
+
title: 'Diagram Editor: Recenter',
|
33
|
+
defaultKeyboardShortcut: 'r',
|
34
|
+
},
|
35
|
+
[DSL_DIAGRAM_LEGEND_STUDIO_COMMAND_KEY.USE_ZOOM_TOOL]: {
|
36
|
+
title: 'Diagram Editor: Use zoom tool',
|
37
|
+
defaultKeyboardShortcut: 'z',
|
38
|
+
},
|
39
|
+
[DSL_DIAGRAM_LEGEND_STUDIO_COMMAND_KEY.USE_VIEW_TOOL]: {
|
40
|
+
title: 'Diagram Editor: Use view tool',
|
41
|
+
defaultKeyboardShortcut: 'v',
|
42
|
+
},
|
43
|
+
[DSL_DIAGRAM_LEGEND_STUDIO_COMMAND_KEY.USE_PAN_TOOL]: {
|
44
|
+
title: 'Diagram Editor: Use pan tool',
|
45
|
+
defaultKeyboardShortcut: 'm',
|
46
|
+
},
|
47
|
+
[DSL_DIAGRAM_LEGEND_STUDIO_COMMAND_KEY.USE_PROPERTY_TOOL]: {
|
48
|
+
title: 'Diagram Editor: Use property tool',
|
49
|
+
defaultKeyboardShortcut: 'p',
|
50
|
+
},
|
51
|
+
[DSL_DIAGRAM_LEGEND_STUDIO_COMMAND_KEY.USE_INHERITANCE_TOOL]: {
|
52
|
+
title: 'Diagram Editor: Use inheritance tool',
|
53
|
+
defaultKeyboardShortcut: 'i',
|
54
|
+
},
|
55
|
+
[DSL_DIAGRAM_LEGEND_STUDIO_COMMAND_KEY.ADD_CLASS]: {
|
56
|
+
title: 'Diagram Editor: Add class',
|
57
|
+
defaultKeyboardShortcut: 'c',
|
58
|
+
},
|
59
|
+
[DSL_DIAGRAM_LEGEND_STUDIO_COMMAND_KEY.EJECT_PROPERTY]: {
|
60
|
+
title: 'Diagram Editor: Eject Property',
|
61
|
+
defaultKeyboardShortcut: 'ArrowRight',
|
62
|
+
when: 'When hovering on a class property',
|
63
|
+
},
|
64
|
+
};
|
@@ -23,7 +23,7 @@ import {
|
|
23
23
|
DIAGRAM_INTERACTION_MODE,
|
24
24
|
DIAGRAM_RELATIONSHIP_EDIT_MODE,
|
25
25
|
DIAGRAM_ZOOM_LEVELS,
|
26
|
-
} from '../../
|
26
|
+
} from '../../DiagramRenderer.js';
|
27
27
|
import {
|
28
28
|
type DiagramEditorInlineClassCreatorState,
|
29
29
|
type DiagramEditorInlineClassRenamerState,
|
@@ -35,7 +35,7 @@ import {
|
|
35
35
|
import {
|
36
36
|
type ResizablePanelHandlerProps,
|
37
37
|
ContextMenu,
|
38
|
-
|
38
|
+
getCollapsiblePanelGroupProps,
|
39
39
|
BasePopover,
|
40
40
|
BlankPanelContent,
|
41
41
|
CaretDownIcon,
|
@@ -94,6 +94,7 @@ import {
|
|
94
94
|
useApplicationStore,
|
95
95
|
useApplicationNavigationContext,
|
96
96
|
buildElementOption,
|
97
|
+
useCommands,
|
97
98
|
} from '@finos/legend-application';
|
98
99
|
import {
|
99
100
|
ClassFormEditor,
|
@@ -663,24 +664,30 @@ const DiagramEditorOverlay = observer(
|
|
663
664
|
.width,
|
664
665
|
);
|
665
666
|
|
667
|
+
// layout
|
668
|
+
const sidePanelCollapsiblePanelGroupProps = getCollapsiblePanelGroupProps(
|
669
|
+
diagramEditorState.sidePanelDisplayState.size === 0,
|
670
|
+
{
|
671
|
+
classes: ['diagram-editor__overlay__panel'],
|
672
|
+
onStopResize: resizeSidePanel,
|
673
|
+
size: diagramEditorState.sidePanelDisplayState.size,
|
674
|
+
},
|
675
|
+
);
|
676
|
+
|
666
677
|
return (
|
667
678
|
<ResizablePanelGroup
|
668
679
|
className="diagram-editor__overlay"
|
669
680
|
orientation="vertical"
|
670
681
|
>
|
671
|
-
<ResizablePanel
|
682
|
+
<ResizablePanel
|
683
|
+
{...sidePanelCollapsiblePanelGroupProps.remainingPanel}
|
684
|
+
minSize={300}
|
685
|
+
>
|
672
686
|
<div className="diagram-editor__view-finder" />
|
673
687
|
</ResizablePanel>
|
674
688
|
<ResizablePanelSplitter className="diagram-editor__overlay__panel-resizer" />
|
675
689
|
<ResizablePanel
|
676
|
-
{...
|
677
|
-
diagramEditorState.sidePanelDisplayState.size === 0,
|
678
|
-
{
|
679
|
-
classes: ['diagram-editor__overlay__panel'],
|
680
|
-
onStopResize: resizeSidePanel,
|
681
|
-
size: diagramEditorState.sidePanelDisplayState.size,
|
682
|
-
},
|
683
|
-
)}
|
690
|
+
{...sidePanelCollapsiblePanelGroupProps.collapsiblePanel}
|
684
691
|
direction={-1}
|
685
692
|
>
|
686
693
|
<div className="panel diagram-editor__side-panel">
|
@@ -1186,7 +1193,6 @@ const DiagramEditorDiagramCanvas = observer(
|
|
1186
1193
|
renderer.render();
|
1187
1194
|
renderer.autoRecenter();
|
1188
1195
|
}
|
1189
|
-
return diagramEditorState.cleanUp();
|
1190
1196
|
}, [diagramCanvasRef, diagramEditorState]);
|
1191
1197
|
|
1192
1198
|
useEffect(() => {
|
@@ -1364,6 +1370,7 @@ const DiagramEditorHeader = observer(
|
|
1364
1370
|
</div>
|
1365
1371
|
<DropdownMenu
|
1366
1372
|
className="diagram-editor__header__dropdown"
|
1373
|
+
title="Zoom..."
|
1367
1374
|
content={
|
1368
1375
|
<MenuContent>
|
1369
1376
|
<MenuContentItem
|
@@ -1390,13 +1397,9 @@ const DiagramEditorHeader = observer(
|
|
1390
1397
|
elevation: 7,
|
1391
1398
|
}}
|
1392
1399
|
>
|
1393
|
-
<
|
1394
|
-
className="diagram-editor__header__dropdown__label diagram-editor__header__zoomer__dropdown__label"
|
1395
|
-
tabIndex={-1}
|
1396
|
-
title="Zoom..."
|
1397
|
-
>
|
1400
|
+
<div className="diagram-editor__header__dropdown__label diagram-editor__header__zoomer__dropdown__label">
|
1398
1401
|
{Math.round(diagramEditorState.renderer.zoom * 100)}%
|
1399
|
-
</
|
1402
|
+
</div>
|
1400
1403
|
<div className="diagram-editor__header__dropdown__trigger diagram-editor__header__zoomer__dropdown__trigger">
|
1401
1404
|
<CaretDownIcon />
|
1402
1405
|
</div>
|
@@ -1429,6 +1432,8 @@ export const DiagramEditor = observer(() => {
|
|
1429
1432
|
DSL_DIAGRAM_LEGEND_STUDIO_APPLICATION_NAVIGATION_CONTEXT_KEY.DIAGRAM_EDITOR,
|
1430
1433
|
);
|
1431
1434
|
|
1435
|
+
useCommands(diagramEditorState);
|
1436
|
+
|
1432
1437
|
return (
|
1433
1438
|
<div className="diagram-editor">
|
1434
1439
|
<div className="diagram-editor__header">
|
package/src/index.ts
CHANGED
@@ -22,7 +22,7 @@ export { DiagramEditorState } from './stores/studio/DiagramEditorState.js';
|
|
22
22
|
export {
|
23
23
|
DiagramRenderer,
|
24
24
|
DIAGRAM_INTERACTION_MODE,
|
25
|
-
} from './
|
25
|
+
} from './DiagramRenderer.js';
|
26
26
|
|
27
27
|
export { Diagram } from './graph/metamodel/pure/packageableElements/diagram/DSL_Diagram_Diagram.js';
|
28
28
|
export { ClassView } from './graph/metamodel/pure/packageableElements/diagram/DSL_Diagram_ClassView.js';
|