mirror of
https://github.com/zadam/trilium.git
synced 2025-11-26 02:24:23 +01:00
Search selected text in trilium (#7859)
This commit is contained in:
commit
d6de7cca96
@ -4,7 +4,7 @@ import zoomService from "../components/zoom.js";
|
|||||||
import contextMenu, { type MenuItem } from "./context_menu.js";
|
import contextMenu, { type MenuItem } from "./context_menu.js";
|
||||||
import { t } from "../services/i18n.js";
|
import { t } from "../services/i18n.js";
|
||||||
import type { BrowserWindow } from "electron";
|
import type { BrowserWindow } from "electron";
|
||||||
import type { CommandNames } from "../components/app_context.js";
|
import type { CommandNames, AppContext } from "../components/app_context.js";
|
||||||
|
|
||||||
function setupContextMenu() {
|
function setupContextMenu() {
|
||||||
const electron = utils.dynamicRequire("electron");
|
const electron = utils.dynamicRequire("electron");
|
||||||
@ -13,6 +13,8 @@ function setupContextMenu() {
|
|||||||
// FIXME: Remove typecast once Electron is properly integrated.
|
// FIXME: Remove typecast once Electron is properly integrated.
|
||||||
const { webContents } = remote.getCurrentWindow() as BrowserWindow;
|
const { webContents } = remote.getCurrentWindow() as BrowserWindow;
|
||||||
|
|
||||||
|
let appContext: AppContext;
|
||||||
|
|
||||||
webContents.on("context-menu", (event, params) => {
|
webContents.on("context-menu", (event, params) => {
|
||||||
const { editFlags } = params;
|
const { editFlags } = params;
|
||||||
const hasText = params.selectionText.trim().length > 0;
|
const hasText = params.selectionText.trim().length > 0;
|
||||||
@ -119,6 +121,20 @@ function setupContextMenu() {
|
|||||||
uiIcon: "bx bx-search-alt",
|
uiIcon: "bx bx-search-alt",
|
||||||
handler: () => electron.shell.openExternal(searchUrl)
|
handler: () => electron.shell.openExternal(searchUrl)
|
||||||
});
|
});
|
||||||
|
|
||||||
|
items.push({
|
||||||
|
title: t("electron_context_menu.search_in_trilium", { term: shortenedSelection }),
|
||||||
|
uiIcon: "bx bx-search",
|
||||||
|
handler: async () => {
|
||||||
|
if (!appContext) {
|
||||||
|
appContext = (await import("../components/app_context.js")).default;
|
||||||
|
}
|
||||||
|
|
||||||
|
await appContext.triggerCommand("searchNotes", {
|
||||||
|
searchString: params.selectionText
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
if (items.length === 0) {
|
if (items.length === 0) {
|
||||||
|
|||||||
@ -1868,6 +1868,7 @@
|
|||||||
"copy-link": "Copy link",
|
"copy-link": "Copy link",
|
||||||
"paste": "Paste",
|
"paste": "Paste",
|
||||||
"paste-as-plain-text": "Paste as plain text",
|
"paste-as-plain-text": "Paste as plain text",
|
||||||
|
"search_in_trilium": "Search for \"{{term}}\" in Trilium",
|
||||||
"search_online": "Search for \"{{term}}\" with {{searchEngine}}"
|
"search_online": "Search for \"{{term}}\" with {{searchEngine}}"
|
||||||
},
|
},
|
||||||
"image_context_menu": {
|
"image_context_menu": {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user