@@ -7,7 +7,7 @@ import './schemaDesigner.css';
77import '../../css/common.css' ;
88
99import { IColumn , IEntity , IRelationship , ISchema , OnAction , SchemaDesignerConfig } from './schemaDesignerInterfaces' ;
10- import { mxEditor , mxGraph , mxGraphModel , mxHierarchicalLayout } from 'mxgraph' ;
10+ import { mxCell , mxEditor , mxGraph , mxGraphModel , mxHierarchicalLayout } from 'mxgraph' ;
1111
1212import { mxGraphFactory as mx } from '../mx' ;
1313import { SchemaDesignerToolbar } from './schemaDesignerToolbar' ;
@@ -24,6 +24,8 @@ export class SchemaDesigner {
2424 private _toolbar ! : SchemaDesignerToolbar ;
2525 private _layout ! : mxHierarchicalLayout ;
2626
27+ private cellClickListeners : ( ( cell : mxCell ) => void ) [ ] = [ ] ;
28+
2729 constructor (
2830 private _container : HTMLElement ,
2931 private _config : SchemaDesignerConfig
@@ -402,6 +404,19 @@ export class SchemaDesigner {
402404 this . _graph . view . validate ( source ) ;
403405 } ) ;
404406
407+ // this._graph.dblClick = (_evt, cell) => {
408+ // if (cell !== undefined) {
409+ // this.cellClickListeners.forEach((listener) => listener(cell));
410+ // }
411+ // };
412+
413+ this . _graph . addListener ( mx . mxEvent . DOUBLE_CLICK , ( _sender , evt ) => {
414+ const cell = this . _graph . getSelectionCell ( ) ;
415+ if ( cell !== undefined ) {
416+ this . cellClickListeners . forEach ( ( listener ) => listener ( cell ) ) ;
417+ }
418+ } ) ;
419+
405420 this . _graph . getStylesheet ( ) . getDefaultVertexStyle ( ) [ 'cellHighlightColor' ] = "red" ;
406421 this . _graph . getStylesheet ( ) . getDefaultEdgeStyle ( ) [ 'edgeStyle' ] = mx . mxEdgeStyle . ElbowConnector ;
407422 this . _graph . stylesheet . getDefaultEdgeStyle ( ) [ mx . mxConstants . STYLE_EDGE ] = mx . mxConstants . EDGESTYLE_ENTITY_RELATION ;
@@ -415,6 +430,7 @@ export class SchemaDesigner {
415430 outline . createSizer ( ) ;
416431 outline . labelsVisible = true ;
417432 outline . sizerSize = 5 ;
433+ outline . minScale = 0.0002 ;
418434 }
419435
420436 private setupToolbar ( ) {
@@ -684,6 +700,10 @@ export class SchemaDesigner {
684700 }
685701 return mostNegativeY ;
686702 }
703+
704+ public addCellClickListener ( listener : ( cell : mxCell ) => void ) {
705+ this . cellClickListeners . push ( listener ) ;
706+ }
687707}
688708
689709
0 commit comments