1- import React , { useCallback , useMemo , useRef , useState } from 'react' ;
1+ import React , { useCallback , useState } from 'react' ;
22import {
33 Button ,
44 css ,
@@ -23,7 +23,7 @@ import { connect } from 'react-redux';
2323import type { DataModelingState } from '../store/reducer' ;
2424import type { StaticModel } from '../services/data-model-storage' ;
2525import { exportToJson , exportToPng } from '../services/export-diagram' ;
26- import { getNodesBounds , useDiagram } from '@mongodb-js/diagramming' ;
26+ import { useDiagram } from '@mongodb-js/diagramming' ;
2727
2828const nbsp = '\u00a0' ;
2929
@@ -64,8 +64,6 @@ const ExportDiagramModal = ({
6464 const [ exportFormat , setExportFormat ] = useState < 'png' | 'json' | null > ( null ) ;
6565 const diagram = useDiagram ( ) ;
6666 const [ isExporting , setIsExporting ] = useState ( false ) ;
67- const exportDiagramContainerRef = useRef < HTMLDivElement > ( null ) ;
68- const bounds = useMemo ( ( ) => getNodesBounds ( diagram . getNodes ( ) ) , [ diagram ] ) ;
6967
7068 const onExport = useCallback ( async ( ) => {
7169 if ( ! exportFormat || ! model ) {
@@ -75,7 +73,7 @@ const ExportDiagramModal = ({
7573 if ( exportFormat === 'json' ) {
7674 exportToJson ( diagramLabel , model ) ;
7775 } else if ( exportFormat === 'png' ) {
78- await exportToPng ( diagramLabel , exportDiagramContainerRef , diagram ) ;
76+ await exportToPng ( diagramLabel , diagram ) ;
7977 }
8078 onCloseClick ( ) ;
8179 setIsExporting ( false ) ;
@@ -131,18 +129,6 @@ const ExportDiagramModal = ({
131129 </ div >
132130 </ RadioGroup >
133131 </ div >
134- { /* Container where we render export diagram when exporting png */ }
135- < div
136- style = { {
137- width : bounds . width ,
138- height : bounds . height ,
139- // Fixed at bottom right corner
140- position : 'fixed' ,
141- top : '100vh' ,
142- left : '100vw' ,
143- } }
144- ref = { exportDiagramContainerRef }
145- />
146132 </ ModalBody >
147133 < ModalFooter className = { footerStyles } >
148134 < Button
0 commit comments