mirror of
https://github.com/zadam/trilium.git
synced 2025-11-13 18:08:56 +01:00
add 'Open note on server' menu item to NoteActions drop-down
This commit is contained in:
parent
c781eab061
commit
a1d38b6bb8
@ -329,6 +329,7 @@ export type CommandMappings = {
|
|||||||
exportAsPdf: CommandData;
|
exportAsPdf: CommandData;
|
||||||
openNoteExternally: CommandData;
|
openNoteExternally: CommandData;
|
||||||
openNoteCustom: CommandData;
|
openNoteCustom: CommandData;
|
||||||
|
openNoteOnServer: CommandData;
|
||||||
renderActiveNote: CommandData;
|
renderActiveNote: CommandData;
|
||||||
unhoist: CommandData;
|
unhoist: CommandData;
|
||||||
reloadFrontendApp: CommandData;
|
reloadFrontendApp: CommandData;
|
||||||
|
|||||||
@ -66,6 +66,13 @@ export default class RootCommandExecutor extends Component {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
openNoteOnServerCommand() {
|
||||||
|
const noteId = appContext.tabManager.getActiveContextNoteId();
|
||||||
|
if (noteId) {
|
||||||
|
openService.openNoteOnServer(noteId);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
enterProtectedSessionCommand() {
|
enterProtectedSessionCommand() {
|
||||||
protectedSessionService.enterProtectedSession();
|
protectedSessionService.enterProtectedSession();
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,4 +1,5 @@
|
|||||||
import utils from "./utils.js";
|
import utils from "./utils.js";
|
||||||
|
import options from "./options.js";
|
||||||
import server from "./server.js";
|
import server from "./server.js";
|
||||||
|
|
||||||
type ExecFunction = (command: string, cb: (err: string, stdout: string, stderror: string) => void) => void;
|
type ExecFunction = (command: string, cb: (err: string, stdout: string, stderror: string) => void) => void;
|
||||||
@ -171,6 +172,21 @@ function getHost() {
|
|||||||
return `${url.protocol}//${url.hostname}:${url.port}`;
|
return `${url.protocol}//${url.hostname}:${url.port}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function openNoteOnServer(noteId: string) {
|
||||||
|
// Get the sync server host from options
|
||||||
|
const syncServerHost = options.get("syncServerHost");
|
||||||
|
|
||||||
|
if (!syncServerHost) {
|
||||||
|
console.error("No sync server host configured");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const url = new URL(`#root/${noteId}`, syncServerHost).toString();
|
||||||
|
|
||||||
|
// Use window.open to ensure link opens in external browser in Electron
|
||||||
|
window.open(url, '_blank', 'noopener,noreferrer');
|
||||||
|
}
|
||||||
|
|
||||||
async function openDirectory(directory: string) {
|
async function openDirectory(directory: string) {
|
||||||
try {
|
try {
|
||||||
if (utils.isElectron()) {
|
if (utils.isElectron()) {
|
||||||
@ -198,5 +214,6 @@ export default {
|
|||||||
openAttachmentExternally,
|
openAttachmentExternally,
|
||||||
openNoteCustom,
|
openNoteCustom,
|
||||||
openAttachmentCustom,
|
openAttachmentCustom,
|
||||||
|
openNoteOnServer,
|
||||||
openDirectory
|
openDirectory
|
||||||
};
|
};
|
||||||
|
|||||||
@ -682,6 +682,7 @@
|
|||||||
"open_note_externally": "Open note externally",
|
"open_note_externally": "Open note externally",
|
||||||
"open_note_externally_title": "File will be open in an external application and watched for changes. You'll then be able to upload the modified version back to Trilium.",
|
"open_note_externally_title": "File will be open in an external application and watched for changes. You'll then be able to upload the modified version back to Trilium.",
|
||||||
"open_note_custom": "Open note custom",
|
"open_note_custom": "Open note custom",
|
||||||
|
"open_note_on_server": "Open note on server",
|
||||||
"import_files": "Import files",
|
"import_files": "Import files",
|
||||||
"export_note": "Export note",
|
"export_note": "Export note",
|
||||||
"delete_note": "Delete note",
|
"delete_note": "Delete note",
|
||||||
|
|||||||
@ -5,6 +5,7 @@ import { ParentComponent } from "../react/react_utils";
|
|||||||
import { t } from "../../services/i18n"
|
import { t } from "../../services/i18n"
|
||||||
import { useContext } from "preact/hooks";
|
import { useContext } from "preact/hooks";
|
||||||
import { useIsNoteReadOnly } from "../react/hooks";
|
import { useIsNoteReadOnly } from "../react/hooks";
|
||||||
|
import { useTriliumOption } from "../react/hooks";
|
||||||
import ActionButton from "../react/ActionButton"
|
import ActionButton from "../react/ActionButton"
|
||||||
import appContext, { CommandNames } from "../../components/app_context";
|
import appContext, { CommandNames } from "../../components/app_context";
|
||||||
import branches from "../../services/branches";
|
import branches from "../../services/branches";
|
||||||
@ -53,6 +54,7 @@ function NoteContextMenu({ note, noteContext }: { note: FNote, noteContext?: Not
|
|||||||
const isMac = getIsMac();
|
const isMac = getIsMac();
|
||||||
const hasSource = ["text", "code", "relationMap", "mermaid", "canvas", "mindMap", "aiChat"].includes(note.type);
|
const hasSource = ["text", "code", "relationMap", "mermaid", "canvas", "mindMap", "aiChat"].includes(note.type);
|
||||||
const isSearchOrBook = ["search", "book"].includes(note.type);
|
const isSearchOrBook = ["search", "book"].includes(note.type);
|
||||||
|
const [ syncServerHost ] = useTriliumOption("syncServerHost");
|
||||||
const {isReadOnly, enableEditing} = useIsNoteReadOnly(note, noteContext);
|
const {isReadOnly, enableEditing} = useIsNoteReadOnly(note, noteContext);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@ -90,6 +92,7 @@ function NoteContextMenu({ note, noteContext }: { note: FNote, noteContext?: Not
|
|||||||
<CommandItem command="openNoteExternally" icon="bx bx-file-find" disabled={isSearchOrBook || !isElectron} text={t("note_actions.open_note_externally")} title={t("note_actions.open_note_externally_title")} />
|
<CommandItem command="openNoteExternally" icon="bx bx-file-find" disabled={isSearchOrBook || !isElectron} text={t("note_actions.open_note_externally")} title={t("note_actions.open_note_externally_title")} />
|
||||||
<CommandItem command="openNoteCustom" icon="bx bx-customize" disabled={isSearchOrBook || isMac || !isElectron} text={t("note_actions.open_note_custom")} />
|
<CommandItem command="openNoteCustom" icon="bx bx-customize" disabled={isSearchOrBook || isMac || !isElectron} text={t("note_actions.open_note_custom")} />
|
||||||
<CommandItem command="showNoteSource" icon="bx bx-code" disabled={!hasSource} text={t("note_actions.note_source")} />
|
<CommandItem command="showNoteSource" icon="bx bx-code" disabled={!hasSource} text={t("note_actions.note_source")} />
|
||||||
|
<CommandItem command="openNoteOnServer" icon="bx bx-world" disabled={!syncServerHost} text={t("note_actions.open_note_on_server")} />
|
||||||
<FormDropdownDivider />
|
<FormDropdownDivider />
|
||||||
|
|
||||||
<CommandItem command="forceSaveRevision" icon="bx bx-save" disabled={isInOptionsOrHelp} text={t("note_actions.save_revision")} />
|
<CommandItem command="forceSaveRevision" icon="bx bx-save" disabled={isInOptionsOrHelp} text={t("note_actions.save_revision")} />
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user