@@ -4,11 +4,18 @@ import { Stage, Layer, Rect, Circle } from 'react-konva';
44import 'dockview/dist/styles/dockview.css' ;
55
66// Canvas component with Konva shapes
7- const CanvasView = ( { panel } ) => {
7+ const CanvasView = ( panel ) => {
88 const containerRef = useRef ( null ) ;
9+ const stageRef = useRef ( null ) ;
910 const [ size , setSize ] = useState ( { width : 400 , height : 400 } ) ;
1011
1112 useEffect ( ( ) => {
13+ panel . api . onDidLocationChange ( ( { location} ) => {
14+ if ( location . type === 'popout' ) {
15+ stageRef . current ?. setWindow ( location ?. getWindow ( ) ) ;
16+ }
17+ } )
18+
1219 if ( containerRef . current ) {
1320 const resize = ( ) => {
1421 const { clientWidth, clientHeight } = containerRef . current ;
@@ -31,6 +38,7 @@ const CanvasView = ({ panel }) => {
3138 draggable
3239 onDragStart = { ( ) => setDragging ( true ) }
3340 onDragEnd = { ( ) => setDragging ( false ) }
41+ ref = { stageRef }
3442 >
3543 < Layer >
3644 < Rect x = { 100 } y = { 100 } width = { 300 } height = { 150 } fill = "blue" cornerRadius = { 10 } />
@@ -61,7 +69,7 @@ export const RightControls = (props) => {
6169 return ( ) => {
6270 disposable . dispose ( ) ;
6371 } ;
64- } , [ props . containerApi ] ) ;
72+ } , [ props . api , props . containerApi ] ) ;
6573
6674 const onClickPopout = ( ) => {
6775 if ( props . api . location . type !== 'popout' ) {
0 commit comments