Skip to content

Commit a7390fb

Browse files
Release v0.0.134
1 parent 0e1e375 commit a7390fb

7 files changed

Lines changed: 66 additions & 8 deletions

File tree

dist/index.js

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48179,6 +48179,7 @@ var SchemaDesigner = class {
4817948179
this.applyColors(this.config.colors);
4818048180
this.configureMxOutline();
4818148181
this.initializeToolbar();
48182+
this.setupKeyboardShortcuts();
4818248183
}
4818348184
/**
4818448185
* Applies the colors from the config to the schema designer
@@ -48670,6 +48671,22 @@ var SchemaDesigner = class {
4867048671
this.container.parentElement.appendChild(toolbarBelt);
4867148672
}
4867248673
}
48674+
setupKeyboardShortcuts() {
48675+
const keyHandler = new mxGraphFactory.mxDefaultKeyHandler(this.mxEditor);
48676+
keyHandler.bindAction(8, "delete");
48677+
keyHandler.bindAction(46, "delete");
48678+
const graphKeyhandler = new mxGraphFactory.mxKeyHandler(this.mxGraph);
48679+
graphKeyhandler.bindKey(90, (evt) => {
48680+
if (evt.ctrlKey || evt.metaKey) {
48681+
this.mxEditor.execute("undo");
48682+
}
48683+
});
48684+
graphKeyhandler.bindShiftKey(90, (evt) => {
48685+
if (evt.ctrlKey || evt.metaKey) {
48686+
this.mxEditor.execute("redo");
48687+
}
48688+
});
48689+
}
4867348690
/**
4867448691
* Zoom in the schema designer
4867548692
*/
@@ -48748,7 +48765,7 @@ var SchemaDesigner = class {
4874848765
* @param schema The schema to render
4874948766
* @param cleanUndoManager Whether to clean the undo manager so that the user can't undo the rendering
4875048767
*/
48751-
renderSchema(schema, cleanUndoManager = false) {
48768+
renderSchema(schema, cleanUndoManager = true) {
4875248769
const parent = this.mxGraph.getDefaultParent();
4875348770
this.mxModel.beginUpdate();
4875448771
try {

dist/index.js.map

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/src/ts/schemaDesigner/schemaDesigner.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ export declare class SchemaDesigner {
7474
* Initializes the toolbar for the schema designer
7575
*/
7676
private initializeToolbar;
77+
private setupKeyboardShortcuts;
7778
/**
7879
* Zoom in the schema designer
7980
*/

dist/src/ts/schemaDesigner/schemaDesigner.js

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ class SchemaDesigner {
8080
this.applyColors(this.config.colors);
8181
this.configureMxOutline();
8282
this.initializeToolbar();
83+
this.setupKeyboardShortcuts();
8384
}
8485
/**
8586
* Applies the colors from the config to the schema designer
@@ -549,6 +550,23 @@ class SchemaDesigner {
549550
this.container.parentElement.appendChild(toolbarBelt);
550551
}
551552
}
553+
setupKeyboardShortcuts() {
554+
const keyHandler = new mx_1.mxGraphFactory.mxDefaultKeyHandler(this.mxEditor);
555+
keyHandler.bindAction(8, 'delete');
556+
keyHandler.bindAction(46, 'delete');
557+
// CTRL + Z or CMD + Z
558+
const graphKeyhandler = new mx_1.mxGraphFactory.mxKeyHandler(this.mxGraph);
559+
graphKeyhandler.bindKey(90, (evt) => {
560+
if (evt.ctrlKey || evt.metaKey) {
561+
this.mxEditor.execute("undo");
562+
}
563+
});
564+
graphKeyhandler.bindShiftKey(90, (evt) => {
565+
if (evt.ctrlKey || evt.metaKey) {
566+
this.mxEditor.execute("redo");
567+
}
568+
});
569+
}
552570
/**
553571
* Zoom in the schema designer
554572
*/
@@ -628,7 +646,7 @@ class SchemaDesigner {
628646
* @param schema The schema to render
629647
* @param cleanUndoManager Whether to clean the undo manager so that the user can't undo the rendering
630648
*/
631-
renderSchema(schema, cleanUndoManager = false) {
649+
renderSchema(schema, cleanUndoManager = true) {
632650
const parent = this.mxGraph.getDefaultParent();
633651
this.mxModel.beginUpdate();
634652
try {

dist/tsconfig.tsbuildinfo

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "azdataGraph",
33
"description": "azdataGraph is a derivative of mxGraph, which is a fully client side JavaScript diagramming library that uses SVG and HTML for rendering.",
4-
"version": "0.0.133",
4+
"version": "0.0.134",
55
"homepage": "https://github.com/microsoft/azdataGraph",
66
"author": "Microsoft",
77
"license": "Apache-2.0",

src/ts/schemaDesigner/schemaDesigner.ts

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ export class SchemaDesigner {
7575
this.applyColors(this.config.colors);
7676
this.configureMxOutline();
7777
this.initializeToolbar();
78+
this.setupKeyboardShortcuts();
7879
}
7980

8081
/**
@@ -399,7 +400,7 @@ export class SchemaDesigner {
399400

400401
const self = this;
401402
(this.mxGraph.connectionHandler as extendedConnectionHandler).validateConnection = function (source, target) {
402-
403+
403404

404405
if (this.edgeState === null) {
405406
return null!;
@@ -646,6 +647,27 @@ export class SchemaDesigner {
646647
}
647648
}
648649

650+
private setupKeyboardShortcuts() {
651+
const keyHandler = new mx.mxDefaultKeyHandler(this.mxEditor);
652+
keyHandler.bindAction(8, 'delete');
653+
keyHandler.bindAction(46, 'delete');
654+
655+
// CTRL + Z or CMD + Z
656+
const graphKeyhandler = new mx.mxKeyHandler(this.mxGraph);
657+
658+
graphKeyhandler.bindKey(90, (evt: KeyboardEvent) => {
659+
if (evt.ctrlKey || evt.metaKey) {
660+
this.mxEditor.execute("undo");
661+
}
662+
});
663+
664+
graphKeyhandler.bindShiftKey(90, (evt: KeyboardEvent) => {
665+
if (evt.ctrlKey || evt.metaKey) {
666+
this.mxEditor.execute("redo");
667+
}
668+
});
669+
}
670+
649671
/**
650672
* Zoom in the schema designer
651673
*/
@@ -733,7 +755,7 @@ export class SchemaDesigner {
733755
* @param schema The schema to render
734756
* @param cleanUndoManager Whether to clean the undo manager so that the user can't undo the rendering
735757
*/
736-
public renderSchema(schema: Schema, cleanUndoManager: boolean = false) {
758+
public renderSchema(schema: Schema, cleanUndoManager: boolean = true) {
737759
const parent = this.mxGraph.getDefaultParent();
738760
this.mxModel.beginUpdate();
739761
try {

0 commit comments

Comments
 (0)