Merge branch 'develop' into feature/MFA

This commit is contained in:
Jin
2025-03-28 22:04:23 +01:00
9 changed files with 428 additions and 49 deletions

View File

@@ -6,4 +6,14 @@ describe("Link", () => {
const output = parseNavigationStateFromUrl("http://localhost:8080/#?searchString=hello");
expect(output).toMatchObject({ searchString: "hello" });
});
it("parses searchString with hash", () => {
const output = parseNavigationStateFromUrl("https://github.com/orgs/TriliumNext/discussions/1526#discussioncomment-12656660");
expect(output).toStrictEqual({});
});
it("parses notePath", () => {
const output = parseNavigationStateFromUrl(`#root/WWaBNf3SSA1b/mQ2tIzLVFKHL`);
expect(output).toMatchObject({ notePath: "root/WWaBNf3SSA1b/mQ2tIzLVFKHL", noteId: "mQ2tIzLVFKHL" });
});
});

View File

@@ -238,10 +238,14 @@ export function parseNavigationStateFromUrl(url: string | undefined) {
}
}
if (!notePath.match(/^[_a-z0-9]{4,}(\/[_a-z0-9]{4,})*$/i)) {
if (searchString) {
return { searchString }
}
if (!notePath.match(/^[_a-z0-9]{4,}(\/[_a-z0-9]{4,})*$/i)) {
return {};
}
return {
notePath,
noteId: treeService.getNoteIdFromUrl(notePath),

View File

@@ -2,6 +2,7 @@ import TypeWidget from "./type_widget.js";
import utils from "../../services/utils.js";
import linkService from "../../services/link.js";
import server from "../../services/server.js";
import asset_path from "../../../../services/asset_path.js";
import type FNote from "../../entities/fnote.js";
import type { ExcalidrawElement, Theme } from "@excalidraw/excalidraw/element/types";
import type { AppState, BinaryFileData, ExcalidrawImperativeAPI, ExcalidrawProps, LibraryItem, SceneData } from "@excalidraw/excalidraw/types";
@@ -129,9 +130,9 @@ export default class ExcalidrawTypeWidget extends TypeWidget {
this.SCENE_VERSION_INITIAL = -1; // -1 indicates that it is fresh. excalidraw scene version is always >0
this.SCENE_VERSION_ERROR = -2; // -2 indicates error
// ensure that assets are loaded from trilium
// TODO:
(window as any).EXCALIDRAW_ASSET_PATH = `${window.location.origin}/node_modules/@excalidraw/excalidraw/dist/`;
// currently required by excalidraw, in order to allows self-hosting fonts locally.
// this avoids making excalidraw load the fonts from an external CDN.
(window as any).EXCALIDRAW_ASSET_PATH = `${window.location.origin}/${asset_path}/app-dist/excalidraw/`;
// temporary vars
this.currentNoteId = "";

View File

@@ -47,6 +47,11 @@ const TPL = `
height: 100%;
}
/* Workaround for #1327 */
body.desktop.electron .note-detail-editable-text {
letter-spacing: -0.01px;
}
body.mobile .note-detail-editable-text {
padding-left: 4px;
}