mirror of
https://github.com/zadam/trilium.git
synced 2025-12-05 23:14:24 +01:00
Merge 4d1a91baa6d9d7d903ee7c3e2c8f78d45c53612a into 3cc64b576429b050ea356c3c76b8bf72f4a5b9b7
This commit is contained in:
commit
bdd8e3db06
@ -487,7 +487,7 @@ type EventMappings = {
|
|||||||
relationMapResetPanZoom: { ntxId: string | null | undefined };
|
relationMapResetPanZoom: { ntxId: string | null | undefined };
|
||||||
relationMapResetZoomIn: { ntxId: string | null | undefined };
|
relationMapResetZoomIn: { ntxId: string | null | undefined };
|
||||||
relationMapResetZoomOut: { ntxId: string | null | undefined };
|
relationMapResetZoomOut: { ntxId: string | null | undefined };
|
||||||
activeNoteChanged: {};
|
activeNoteChanged: {ntxId: string | null | undefined};
|
||||||
showAddLinkDialog: AddLinkOpts;
|
showAddLinkDialog: AddLinkOpts;
|
||||||
showIncludeDialog: IncludeNoteOpts;
|
showIncludeDialog: IncludeNoteOpts;
|
||||||
openBulkActionsDialog: {
|
openBulkActionsDialog: {
|
||||||
|
|||||||
@ -165,7 +165,7 @@ export default class TabManager extends Component {
|
|||||||
const activeNoteContext = this.getActiveContext();
|
const activeNoteContext = this.getActiveContext();
|
||||||
this.updateDocumentTitle(activeNoteContext);
|
this.updateDocumentTitle(activeNoteContext);
|
||||||
|
|
||||||
this.triggerEvent("activeNoteChanged", {}); // trigger this even in on popstate event
|
this.triggerEvent("activeNoteChanged", {ntxId:activeNoteContext?.ntxId}); // trigger this even in on popstate event
|
||||||
}
|
}
|
||||||
|
|
||||||
calculateHash(): string {
|
calculateHash(): string {
|
||||||
|
|||||||
@ -95,9 +95,11 @@ export default function NoteDetail() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
// Automatically focus the editor.
|
// Automatically focus the editor.
|
||||||
useTriliumEvent("activeNoteChanged", () => {
|
useTriliumEvent("activeNoteChanged", ({ ntxId: eventNtxId }) => {
|
||||||
// Restore focus to the editor when switching tabs, but only if the note tree is not already focused.
|
if (eventNtxId != ntxId) return;
|
||||||
if (!document.activeElement?.classList.contains("fancytree-title")) {
|
// Restore focus to the editor when switching tabs,
|
||||||
|
// but only if the note tree and the note panel (e.g., note title or note detail) are not focused.
|
||||||
|
if (!document.activeElement?.classList.contains("fancytree-title") && !parentComponent.$widget[0].closest(".note-split")?.contains(document.activeElement)) {
|
||||||
parentComponent.triggerCommand("focusOnDetail", { ntxId });
|
parentComponent.triggerCommand("focusOnDetail", { ntxId });
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@ -29,7 +29,11 @@ export default class LeftPaneContainer extends FlexContainer<Component> {
|
|||||||
if (visible) {
|
if (visible) {
|
||||||
this.triggerEvent("focusTree", {});
|
this.triggerEvent("focusTree", {});
|
||||||
} else {
|
} else {
|
||||||
this.triggerEvent("focusOnDetail", { ntxId: appContext.tabManager.getActiveContext()?.ntxId });
|
const ntxId = appContext.tabManager.getActiveContext()?.ntxId;
|
||||||
|
const noteContainer = document.querySelector(`.note-split[data-ntx-id="${ntxId}"]`);
|
||||||
|
if (!noteContainer?.contains(document.activeElement)) {
|
||||||
|
this.triggerEvent("focusOnDetail", { ntxId });
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
options.save("leftPaneVisible", this.currentLeftPaneVisible.toString());
|
options.save("leftPaneVisible", this.currentLeftPaneVisible.toString());
|
||||||
|
|||||||
@ -45,10 +45,10 @@ function NoteSearch() {
|
|||||||
if (!suggestion?.notePath) {
|
if (!suggestion?.notePath) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
const ntxId = autocompleteRef.current?.closest(".note-split")?.getAttribute("data-ntx-id") ?? null;
|
||||||
const activeContext = appContext.tabManager.getActiveContext();
|
const activeNoteContext = appContext.tabManager.getNoteContextById(ntxId) ?? appContext.tabManager.getActiveContext();
|
||||||
if (activeContext) {
|
if (activeNoteContext) {
|
||||||
activeContext.setNote(suggestion.notePath);
|
activeNoteContext.setNote(suggestion.notePath);
|
||||||
}
|
}
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
|
|||||||
72
apps/server-e2e/src/layout/split_pane.spec.ts
Normal file
72
apps/server-e2e/src/layout/split_pane.spec.ts
Normal file
@ -0,0 +1,72 @@
|
|||||||
|
import { test, expect } from "@playwright/test";
|
||||||
|
import App from "../support/app";
|
||||||
|
|
||||||
|
const TEXT_NOTE_TITLE = "Text notes";
|
||||||
|
const CODE_NOTE_TITLE = "Code notes";
|
||||||
|
|
||||||
|
test("Open the note in the correct split pane", async ({ page, context }) => {
|
||||||
|
const app = new App(page, context);
|
||||||
|
await app.goto();
|
||||||
|
await app.closeAllTabs();
|
||||||
|
|
||||||
|
// Open the first split.
|
||||||
|
await app.goToNoteInNewTab(TEXT_NOTE_TITLE);
|
||||||
|
const split1 = app.currentNoteSplit;
|
||||||
|
|
||||||
|
// Create a new split.
|
||||||
|
const splitButton = split1.locator("button.bx-dock-right");
|
||||||
|
await expect(splitButton).toBeVisible();
|
||||||
|
await splitButton.click();
|
||||||
|
|
||||||
|
// Search for "Code notes" in the empty area of the second split.
|
||||||
|
const split2 = app.currentNoteSplit.nth(1);;
|
||||||
|
await expect(split2).toBeVisible();
|
||||||
|
const autocomplete = split2.locator(".note-autocomplete");
|
||||||
|
await autocomplete.fill(CODE_NOTE_TITLE);
|
||||||
|
const resultsSelector = split2.locator(".note-detail-empty-results");
|
||||||
|
await expect(resultsSelector).toContainText(CODE_NOTE_TITLE);
|
||||||
|
|
||||||
|
//Focus on the first split.
|
||||||
|
const noteContent = split1.locator(".note-detail-editable-text-editor");
|
||||||
|
await expect(noteContent.locator("p")).toBeVisible();
|
||||||
|
await noteContent.focus();
|
||||||
|
|
||||||
|
// Click the search result in the second split.
|
||||||
|
await resultsSelector.locator(".aa-suggestion", { hasText: CODE_NOTE_TITLE })
|
||||||
|
.nth(1).click();
|
||||||
|
|
||||||
|
await expect(split2).toContainText(CODE_NOTE_TITLE);
|
||||||
|
});
|
||||||
|
|
||||||
|
test("Can directly focus the autocomplete input within the split", async ({ page, context }) => {
|
||||||
|
const app = new App(page, context);
|
||||||
|
await app.goto();
|
||||||
|
await app.closeAllTabs();
|
||||||
|
|
||||||
|
// Open the first split.
|
||||||
|
await app.goToNoteInNewTab(TEXT_NOTE_TITLE);
|
||||||
|
const split1 = app.currentNoteSplit;
|
||||||
|
|
||||||
|
// Create a new split.
|
||||||
|
const splitButton = split1.locator("button.bx-dock-right");
|
||||||
|
await expect(splitButton).toBeVisible();
|
||||||
|
await splitButton.click();
|
||||||
|
|
||||||
|
// Search for "Code notes" in the empty area of the second split.
|
||||||
|
const split2 = app.currentNoteSplit.nth(1);;
|
||||||
|
await expect(split2).toBeVisible();
|
||||||
|
|
||||||
|
// Focus the first split.
|
||||||
|
const noteContent = split1.locator(".note-detail-editable-text-editor");
|
||||||
|
await expect(noteContent.locator("p")).toBeVisible();
|
||||||
|
await noteContent.focus();
|
||||||
|
await noteContent.click();
|
||||||
|
|
||||||
|
// click the autocomplete input box of the second split
|
||||||
|
const autocomplete = split2.locator(".note-autocomplete");
|
||||||
|
await autocomplete.focus();
|
||||||
|
await autocomplete.click();
|
||||||
|
|
||||||
|
await page.waitForTimeout(100);
|
||||||
|
await expect(autocomplete).toBeFocused();
|
||||||
|
});
|
||||||
Loading…
x
Reference in New Issue
Block a user