@@ -8,19 +8,31 @@ import {Tab} from "../layout/Tab";
8
8
import { fetchPost } from "../util/fetch" ;
9
9
import { showMessage } from "../dialog/message" ;
10
10
11
- export const openNewWindow = ( tab : Tab ) => {
11
+ interface windowOptions {
12
+ position ?: {
13
+ x : number ,
14
+ y : number ,
15
+ } ,
16
+ width ?: number ,
17
+ height ?: number
18
+ }
19
+
20
+ export const openNewWindow = ( tab : Tab , options : windowOptions = { } ) => {
12
21
const json = { } ;
13
22
layoutToJSON ( tab , json ) ;
14
23
/// #if !BROWSER
15
24
ipcRenderer . send ( Constants . SIYUAN_OPENWINDOW , {
25
+ position : options . position ,
26
+ width : options . width ,
27
+ height : options . height ,
16
28
id : getCurrentWindow ( ) . id ,
17
29
url : `${ window . location . protocol } //${ window . location . host } /stage/build/app/window.html?v=${ Constants . SIYUAN_VERSION } &json=${ JSON . stringify ( json ) } `
18
30
} ) ;
19
31
/// #endif
20
32
tab . parent . removeTab ( tab . id ) ;
21
33
} ;
22
34
23
- export const openNewWindowById = ( id : string ) => {
35
+ export const openNewWindowById = ( id : string , options : windowOptions = { } ) => {
24
36
fetchPost ( "/api/block/getBlockInfo" , { id} , ( response ) => {
25
37
if ( response . code === 3 ) {
26
38
showMessage ( response . msg ) ;
@@ -50,6 +62,9 @@ export const openNewWindowById = (id: string) => {
50
62
}
51
63
/// #if !BROWSER
52
64
ipcRenderer . send ( Constants . SIYUAN_OPENWINDOW , {
65
+ position : options . position ,
66
+ width : options . width ,
67
+ height : options . height ,
53
68
id : getCurrentWindow ( ) . id ,
54
69
url : `${ window . location . protocol } //${ window . location . host } /stage/build/app/window.html?v=${ Constants . SIYUAN_VERSION } &json=${ JSON . stringify ( json ) } `
55
70
} ) ;
@@ -62,6 +77,9 @@ export const openNewWindowById = (id: string) => {
62
77
} ;
63
78
/// #if !BROWSER
64
79
ipcRenderer . send ( Constants . SIYUAN_OPENWINDOW , {
80
+ position : options . position ,
81
+ width : options . width ,
82
+ height : options . height ,
65
83
id : getCurrentWindow ( ) . id ,
66
84
url : `${ window . location . protocol } //${ window . location . host } /stage/build/app/window.html?v=${ Constants . SIYUAN_VERSION } &json=${ JSON . stringify ( json ) } `
67
85
} ) ;
0 commit comments