@@ -91,8 +91,8 @@ const methods = {
9191 }
9292 if ( isMobile ( ) && this . mobileMenu ) {
9393 mobileMenu ( this )
94- } else {
95- this . contextMenu && contextMenu ( this , this . contextMenuOption )
94+ } else if ( this . contextMenu ) {
95+ this . disposable . push ( contextMenu ( this , this . contextMenuOption ) )
9696 }
9797 this . draggable && nodeDraggable ( this )
9898 this . allowUndo && operationHistory ( this )
@@ -101,6 +101,34 @@ const methods = {
101101 this . layout ( )
102102 this . linkDiv ( )
103103 } ,
104+ destroy ( this : Partial < MindElixirInstance > ) {
105+ this . disposable ! . forEach ( fn => fn ( ) )
106+ this . mindElixirBox ?. remove ( )
107+ this . mindElixirBox = undefined
108+ this . nodeData = undefined
109+ this . arrows = undefined
110+ this . summaries = undefined
111+ this . currentArrow = undefined
112+ this . currentNode = undefined
113+ this . currentNodes = undefined
114+ this . currentSummary = undefined
115+ this . waitCopy = undefined
116+ this . theme = undefined
117+ this . direction = undefined
118+ this . bus = undefined
119+ this . container = undefined
120+ this . map = undefined
121+ this . lines = undefined
122+ this . linkController = undefined
123+ this . linkSvgGroup = undefined
124+ this . P2 = undefined
125+ this . P3 = undefined
126+ this . line1 = undefined
127+ this . line2 = undefined
128+ this . nodes = undefined
129+ this . selection ?. destroy ( )
130+ this . selection = undefined
131+ } ,
104132}
105133
106134export default methods
0 commit comments