Skip to content

Commit 6f0a264

Browse files
authored
Merge branch 'main' into electron_newwindow
2 parents f3f07cd + 23f2e1e commit 6f0a264

File tree

51 files changed

+2084
-792
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

51 files changed

+2084
-792
lines changed

.nvmrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
22.21.0
1+
24.11.0

_regroup/package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,16 +38,16 @@
3838
"@playwright/test": "1.56.1",
3939
"@stylistic/eslint-plugin": "5.5.0",
4040
"@types/express": "5.0.5",
41-
"@types/node": "24.9.1",
41+
"@types/node": "24.9.2",
4242
"@types/yargs": "17.0.34",
4343
"@vitest/coverage-v8": "3.2.4",
44-
"eslint": "9.38.0",
44+
"eslint": "9.39.0",
4545
"eslint-plugin-simple-import-sort": "12.1.1",
4646
"esm": "3.2.25",
4747
"jsdoc": "4.0.5",
4848
"lorem-ipsum": "2.0.8",
4949
"rcedit": "4.0.1",
50-
"rimraf": "6.0.1",
50+
"rimraf": "6.1.0",
5151
"tslib": "2.8.1",
5252
"typedoc": "0.28.14",
5353
"typedoc-plugin-missing-exports": "4.1.2"

apps/client/package.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
"circular-deps": "dpdm -T src/**/*.ts --tree=false --warning=false --skip-dynamic-imports=circular"
1616
},
1717
"dependencies": {
18-
"@eslint/js": "9.38.0",
18+
"@eslint/js": "9.39.0",
1919
"@excalidraw/excalidraw": "0.18.0",
2020
"@fullcalendar/core": "6.1.19",
2121
"@fullcalendar/daygrid": "6.1.19",
@@ -37,12 +37,12 @@
3737
"bootstrap": "5.3.8",
3838
"boxicons": "2.1.4",
3939
"color": "5.0.2",
40-
"dayjs": "1.11.18",
40+
"dayjs": "1.11.19",
4141
"dayjs-plugin-utc": "0.1.2",
4242
"debounce": "2.2.0",
4343
"draggabilly": "3.0.0",
4444
"force-graph": "1.51.0",
45-
"globals": "16.4.0",
45+
"globals": "16.5.0",
4646
"i18next": "25.6.0",
4747
"i18next-http-backend": "3.0.2",
4848
"jquery": "3.7.1",
@@ -59,7 +59,7 @@
5959
"normalize.css": "8.0.1",
6060
"panzoom": "9.4.3",
6161
"preact": "10.27.2",
62-
"react-i18next": "16.2.1",
62+
"react-i18next": "16.2.3",
6363
"reveal.js": "5.2.1",
6464
"svg-pan-zoom": "3.6.2",
6565
"tabulator-tables": "6.3.1",
@@ -76,7 +76,7 @@
7676
"@types/reveal.js": "5.2.1",
7777
"@types/tabulator-tables": "6.3.0",
7878
"copy-webpack-plugin": "13.0.1",
79-
"happy-dom": "20.0.8",
79+
"happy-dom": "20.0.10",
8080
"script-loader": "0.7.2",
8181
"vite-plugin-static-copy": "3.1.4"
8282
}

apps/client/src/components/app_context.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -270,6 +270,7 @@ export type CommandMappings = {
270270
closeThisNoteSplit: CommandData;
271271
moveThisNoteSplit: CommandData & { isMovingLeft: boolean };
272272
jumpToNote: CommandData;
273+
openTodayNote: CommandData;
273274
commandPalette: CommandData;
274275

275276
// Keyboard shortcuts

apps/client/src/components/entrypoints.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,16 @@ export default class Entrypoints extends Component {
159159
this.openInWindowCommand({ notePath: "", hoistedNoteId: "root" });
160160
}
161161

162+
async openTodayNoteCommand() {
163+
const todayNote = await dateNoteService.getTodayNote();
164+
if (!todayNote) {
165+
console.warn("Missing today note.");
166+
return;
167+
}
168+
169+
await appContext.tabManager.openInSameTab(todayNote.noteId);
170+
}
171+
162172
async runActiveNoteCommand() {
163173
const noteContext = appContext.tabManager.getActiveContext();
164174
if (!noteContext) {

apps/client/src/entities/fnote.ts

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -417,7 +417,7 @@ export default class FNote {
417417
return notePaths;
418418
}
419419

420-
getSortedNotePathRecords(hoistedNoteId = "root"): NotePathRecord[] {
420+
getSortedNotePathRecords(hoistedNoteId = "root", activeNotePath: string | null = null): NotePathRecord[] {
421421
const isHoistedRoot = hoistedNoteId === "root";
422422

423423
const notePaths: NotePathRecord[] = this.getAllNotePaths().map((path) => ({
@@ -428,7 +428,23 @@ export default class FNote {
428428
isHidden: path.includes("_hidden")
429429
}));
430430

431+
// Calculate the length of the prefix match between two arrays
432+
const prefixMatchLength = (path: string[], target: string[]) => {
433+
const diffIndex = path.findIndex((seg, i) => seg !== target[i]);
434+
return diffIndex === -1 ? Math.min(path.length, target.length) : diffIndex;
435+
};
436+
431437
notePaths.sort((a, b) => {
438+
if (activeNotePath) {
439+
const activeSegments = activeNotePath.split('/');
440+
const aOverlap = prefixMatchLength(a.notePath, activeSegments);
441+
const bOverlap = prefixMatchLength(b.notePath, activeSegments);
442+
// Paths with more matching prefix segments are prioritized
443+
// when the match count is equal, other criteria are used for sorting
444+
if (bOverlap !== aOverlap) {
445+
return bOverlap - aOverlap;
446+
}
447+
}
432448
if (a.isInHoistedSubTree !== b.isInHoistedSubTree) {
433449
return a.isInHoistedSubTree ? -1 : 1;
434450
} else if (a.isArchived !== b.isArchived) {
@@ -449,10 +465,11 @@ export default class FNote {
449465
* Returns the note path considered to be the "best"
450466
*
451467
* @param {string} [hoistedNoteId='root']
468+
* @param {string|null} [activeNotePath=null]
452469
* @return {string[]} array of noteIds constituting the particular note path
453470
*/
454-
getBestNotePath(hoistedNoteId = "root") {
455-
return this.getSortedNotePathRecords(hoistedNoteId)[0]?.notePath;
471+
getBestNotePath(hoistedNoteId = "root", activeNotePath: string | null = null) {
472+
return this.getSortedNotePathRecords(hoistedNoteId, activeNotePath)[0]?.notePath;
456473
}
457474

458475
/**

apps/client/src/services/tree.ts

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -26,21 +26,12 @@ async function resolveNotePathToSegments(notePath: string, hoistedNoteId = "root
2626
}
2727

2828
const path = notePath.split("/").reverse();
29-
30-
if (!path.includes("root")) {
31-
path.push("root");
32-
}
33-
3429
const effectivePathSegments: string[] = [];
3530
let childNoteId: string | null = null;
3631
let i = 0;
3732

38-
while (true) {
39-
if (i >= path.length) {
40-
break;
41-
}
42-
43-
const parentNoteId = path[i++];
33+
for (let i = 0; i < path.length; i++) {
34+
const parentNoteId = path[i];
4435

4536
if (childNoteId !== null) {
4637
const child = await froca.getNote(childNoteId, !logErrors);
@@ -65,7 +56,7 @@ async function resolveNotePathToSegments(notePath: string, hoistedNoteId = "root
6556
return null;
6657
}
6758

68-
if (!parents.some((p) => p.noteId === parentNoteId)) {
59+
if (!parents.some(p => p.noteId === parentNoteId) || (i === path.length - 1 && parentNoteId !== 'root')) {
6960
if (logErrors) {
7061
const parent = froca.getNoteFromCache(parentNoteId);
7162

@@ -77,7 +68,8 @@ async function resolveNotePathToSegments(notePath: string, hoistedNoteId = "root
7768
);
7869
}
7970

80-
const bestNotePath = child.getBestNotePath(hoistedNoteId);
71+
const activeNotePath = appContext.tabManager.getActiveContextNotePath();
72+
const bestNotePath = child.getBestNotePath(hoistedNoteId, activeNotePath);
8173

8274
if (bestNotePath) {
8375
const pathToRoot = bestNotePath.reverse().slice(1);
@@ -108,7 +100,9 @@ async function resolveNotePathToSegments(notePath: string, hoistedNoteId = "root
108100
if (!note) {
109101
throw new Error(`Unable to find note: ${notePath}.`);
110102
}
111-
const bestNotePath = note.getBestNotePath(hoistedNoteId);
103+
104+
const activeNotePath = appContext.tabManager.getActiveContextNotePath();
105+
const bestNotePath = note.getBestNotePath(hoistedNoteId, activeNotePath);
112106

113107
if (!bestNotePath) {
114108
throw new Error(`Did not find any path segments for '${note.toString()}', hoisted note '${hoistedNoteId}'`);

apps/client/src/services/utils.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,11 @@ export function reloadFrontendApp(reason?: string) {
1111
logInfo(`Frontend app reload: ${reason}`);
1212
}
1313

14-
window.location.reload();
14+
if (isElectron()) {
15+
dynamicRequire("@electron/remote").BrowserWindow.getFocusedWindow()?.reload();
16+
} else {
17+
window.location.reload();
18+
}
1519
}
1620

1721
export function restartDesktopApp() {

apps/desktop/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
"@triliumnext/commons": "workspace:*",
3636
"@triliumnext/server": "workspace:*",
3737
"copy-webpack-plugin": "13.0.1",
38-
"electron": "38.4.0",
38+
"electron": "38.5.0",
3939
"@electron-forge/cli": "7.10.2",
4040
"@electron-forge/maker-deb": "7.10.2",
4141
"@electron-forge/maker-dmg": "7.10.2",

apps/edit-docs/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
"@triliumnext/desktop": "workspace:*",
1313
"@types/fs-extra": "11.0.4",
1414
"copy-webpack-plugin": "13.0.1",
15-
"electron": "38.4.0",
15+
"electron": "38.5.0",
1616
"fs-extra": "11.3.2"
1717
},
1818
"scripts": {

0 commit comments

Comments
 (0)