File tree Expand file tree Collapse file tree 1 file changed +16
-13
lines changed Expand file tree Collapse file tree 1 file changed +16
-13
lines changed Original file line number Diff line number Diff line change @@ -17,20 +17,23 @@ export default class CanvasPatcher {
1717 const that = this
1818
1919 // Get the current canvas view or wait for it to be created
20- const canvasView = this . plugin . getCurrentCanvasView ( ) ?? await new Promise < CanvasView > ( ( resolve ) => {
21- // @ts -ignore
22- const uninstall = around ( this . plugin . app . internalPlugins . plugins . canvas . views , {
23- canvas : ( next : any ) => function ( ...args : any ) {
24- const result = next . call ( this , ...args )
25-
26- resolve ( result )
27- uninstall ( ) // Uninstall the patch
28-
29- return result
30- }
20+ const canvasView = (
21+ this . plugin . app . workspace . getLeavesOfType ( 'canvas' ) ?. first ( ) ?. view ??
22+ await new Promise < CanvasView > ( ( resolve ) => {
23+ // @ts -ignore
24+ const uninstall = around ( this . plugin . app . internalPlugins . plugins . canvas . views , {
25+ canvas : ( next : any ) => function ( ...args : any ) {
26+ const result = next . call ( this , ...args )
27+
28+ resolve ( result )
29+ uninstall ( ) // Uninstall the patch
30+
31+ return result
32+ }
33+ } )
34+ this . plugin . register ( uninstall )
3135 } )
32- this . plugin . register ( uninstall )
33- } )
36+ ) as CanvasView
3437
3538 // Patch canvas view
3639 patchObjectPrototype ( this . plugin , canvasView , {
You can’t perform that action at this time.
0 commit comments