You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* Return string version of Rect's x/y/width/height attributes
@@ -301,19 +307,23 @@ export function noteOpenInEditor(openNoteFilename: string): boolean {
301
307
}
302
308
303
309
/**
304
-
* Returns the Editor object that matches a given filename (if available)
310
+
* Returns the TEditor that matches a given filename (if available).
311
+
* If getLastOpenEditor is true, then return the last open Editor window (which is the most recently opened one), otherwise the first one that matches the filename.
305
312
* @author@jgclark
306
313
* @param {string} openNoteFilename to find in list of open Editor windows
314
+
* @param {boolean} getLastOpenEditor - whether to return the last open Editor window
307
315
* @returns {TEditor} the matching open Editor window
logDebug('positionEditorWindowWithSmartPlacement',`Calculated smart location for new window -> ${rectToString(newWindowRect)}`)
366
+
367
+
// Set the window rect for the new window
368
+
editor.windowRect=newWindowRect
369
+
returntrue
370
+
}
371
+
372
+
/**
373
+
* Opens note in new floating window, optionally only if it's not already open in one, and optionally move window to a smart location on the screen, rather than the default position, which is often unhelpful.
339
374
* @param {string} filename to open in window
375
+
* @param {number} width - requested width of the new window (if set at zero, treat as if not set)
376
+
* @param {boolean} onlyIfNotAlreadyOpen - whether to only open the window if it's not already open in one
377
+
* @param {boolean} smartLocation - whether to move window to a smart location on the screen, based on the current NP window size(s), position(s) and the screen area
logWarn('openWindowSet',`Failed to open floating window '${filename}'`)
414
+
}
415
+
416
+
/**
417
+
* Calculate the smart placement for the new window:
418
+
* - Calculate all the areas of the screen from the existing open Editor and HTML windows.
419
+
* - Then find the next available area that is big enough for the same height and requested width, that is next to an existing Editor window, but within the screen boundaries.
420
+
* @param {Rect} currenthisWindowRect - the Rect of the current window
421
+
* @param {number} requestedWidth - the requested width of the new window (if set at zero, treat as if not set)
422
+
* @returns {Rect} the smart location for the new window
Copy file name to clipboardExpand all lines: jgclark.WindowTools/CHANGELOG.md
+4Lines changed: 4 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,6 +4,10 @@ _Please see the [Plugin documentation](https://noteplan.co/plugins/jgclark.Windo
4
4
<!-- - TODO: Extend to deal with closed main sidebars.
5
5
- TODO: Can now save a folder as part of a window set. (Note: not yet a particular 'folder view'.) -->
6
6
7
+
## [1.5.0] - 2025-11-30
8
+
-**open note in new window** and **open current note in new window** now don't just open the new 'floating' window wherever NP decides, which is often unhelpful. Instead it tries to place it next to, _but not on top of_, existing NP windows. You can turn off this behaviour using the new '
9
+
- prevent the **open ... note in new window/split** commands from running on iOS and iPadOS, as they don't have any effect.
10
+
7
11
## [1.4.0] - 2025-11-07
8
12
### New
9
13
- New **reset main window** command. This resets the main NP window to default widths, including the main (left) sidebar (requires NP v3.19.2 or later). Alias: /rmw.
"plugin.lastUpdateInfo": "v1.4.0: New '/reset windows' command.\nNow can save folders andsidebar width in Window Sets, and open to that width (requires NP v3.19.2).\nOther improvements to Window Sets.\nv1.3.0: Improve note and heading pickers. Support for Teamspace notes in /open note... commands. Fix to Window Set selection.\nv1.2.1: update list of plugin windows it knows about\nv1.2.0: new command 'swap splits', plus positioning bug fix\nv1.1.2: Bug fixes.\nv1.1.1: improve migration from previous plugin ('WindowSets')\nv1.1.0: added x-callbacks for /open Window Set, /open note in new split and /open note in new window commands.\nv1.0.0: 3 new commands, and renamed plugin from 'Window Sets'. Also moved 3 window-related commands from 'Note Helpers' plugin.\nv0.4.0: First public release, and requires NP v3.9.8.",
13
+
"plugin.lastUpdateInfo": "v1.5.0: Use 'smart placement' when opening new Editor windows in the commands. New setting 'Use Smart Placement?' allows you to turn off this behaviour.\nv1.4.0: New '/reset windows' command.\nNow can save folders andsidebar width in Window Sets, and open to that width (requires NP v3.19.2).\nOther improvements to Window Sets.\nv1.3.0: Improve note and heading pickers. Support for Teamspace notes in /open note... commands. Fix to Window Set selection.\nv1.2.1: update list of plugin windows it knows about\nv1.2.0: new command 'swap splits', plus positioning bug fix\nv1.1.2: Bug fixes.\nv1.1.1: improve migration from previous plugin ('WindowSets')\nv1.1.0: added x-callbacks for /open Window Set, /open note in new split and /open note in new window commands.\nv1.0.0: 3 new commands, and renamed plugin from 'Window Sets'. Also moved 3 window-related commands from 'Note Helpers' plugin.\nv0.4.0: First public release, and requires NP v3.9.8.",
14
14
"plugin.dependencies": [],
15
15
"plugin.script": "script.js",
16
16
"plugin.isRemote": "false",
@@ -284,6 +284,14 @@
284
284
"default": 300,
285
285
"required": false
286
286
},
287
+
{
288
+
"key": "useSmartPlacement",
289
+
"title": "Use smart placement when opening new windows?",
290
+
"description": "It set, this will place the window on the screen next to, but not on top of, current open NP windows. It will also use the default editor width (if set above).",
0 commit comments