File tree Expand file tree Collapse file tree 1 file changed +28
-1
lines changed
NetworkDynamicsInspector/src Expand file tree Collapse file tree 1 file changed +28
-1
lines changed Original file line number Diff line number Diff line change @@ -132,7 +132,9 @@ function has_electron_window end
132
132
function get_electron_app end
133
133
function get_electron_window end
134
134
135
- function save_electron_screenshot (path= joinpath (@__DIR__ , " screenshot.png" ))
135
+ function save_electron_screenshot (path= joinpath (@__DIR__ , " screenshot.png" ), resize= true )
136
+ resize && _resize_electron_to_content ()
137
+
136
138
path = isabspath (path) ? path : joinpath (pwd (), path)
137
139
has_electron_window ()|| error (" No Electron window exists!" )
138
140
winid = get_electron_window (). id
@@ -152,3 +154,28 @@ function save_electron_screenshot(path=joinpath(@__DIR__, "screenshot.png"))
152
154
end
153
155
nothing
154
156
end
157
+
158
+ function _resize_electron_to_content ()
159
+ window = get_electron_window ()
160
+ js_max_h = """
161
+ {
162
+ let maxHeight = 0;
163
+ Array.from(document.querySelectorAll('.graphplot-col, .timeseries-col')).forEach(el => {
164
+ const height = el.offsetHeight;
165
+ console.log(height)
166
+ if (height > maxHeight) {
167
+ maxHeight = height;
168
+ }
169
+ })
170
+ maxHeight
171
+ }
172
+ """
173
+ y = run (window, js_max_h)
174
+
175
+ run (get_electron_app (), """
176
+ {
177
+ let win = BrowserWindow.fromId($(window. id) )
178
+ win.setSize(win.getSize()[0], $y )
179
+ }
180
+ """ )
181
+ end
You can’t perform that action at this time.
0 commit comments