@@ -4,7 +4,7 @@ import { Editor, EditorUi, Graph } from "../editor";
44import { mxEvent , mxResources } from "./mxgraph" ;
55import type { Language } from "../editor/i18n" ;
66import { getLanguage } from "../editor/i18n" ;
7- import type { Func } from "laser-utils" ;
7+ import type { A , O , F } from "laser-utils/dist/es/types " ;
88
99const themes : Record < string , Node > = { } ;
1010themes [ Graph . prototype . defaultThemeName ] = (
@@ -26,7 +26,7 @@ export class DiagramEditor {
2626 public start = (
2727 lang : Language ,
2828 init ?: XMLDocument | null ,
29- onXMLChange ?: ( xml : Element ) => void
29+ onXMLChange ?: ( xml : Element , changes : A . Any ) => void
3030 ) : void => {
3131 this . container . appendChild ( this . diagramContainer ) ;
3232 this . container . style . overflow = "hidden" ;
@@ -36,8 +36,14 @@ export class DiagramEditor {
3636 if ( init ) {
3737 this . editorUi . editor . setGraphXml ( init . documentElement ) ;
3838 }
39- this . editor . graph . getModel ( ) . addListener ( mxEvent . CHANGE , ( ) => {
40- onXMLChange && onXMLChange ( this . editorUi && this . editorUi . editor . getGraphXml ( ) ) ;
39+ this . editor . graph . getModel ( ) . addListener ( mxEvent . CHANGE , ( _ : O . Any , event : O . Any ) => {
40+ if ( onXMLChange ) {
41+ let changes : A . Any = [ ] ;
42+ if ( event && event . properties && event . properties . changes ) {
43+ changes = event . properties . changes ;
44+ }
45+ onXMLChange ( this . editorUi && this . editorUi . editor . getGraphXml ( ) , changes ) ;
46+ }
4147 } ) ;
4248 } ;
4349
@@ -54,7 +60,7 @@ export class DiagramEditor {
5460 this . container . removeChild ( this . diagramContainer ) ;
5561 } ;
5662
57- public static getLang = ( lang : Func . Args < typeof getLanguage > [ "0" ] ) => {
63+ public static getLang = ( lang : F . Args < typeof getLanguage > [ "0" ] ) => {
5864 return getLanguage ( lang ) ;
5965 } ;
6066}
0 commit comments