[SM-329] Merge libs/electron into desktop (#3989)

This commit is contained in:
Oscar Hinton 2022-12-02 12:45:09 +01:00 committed by GitHub
parent 8e4e770ca3
commit 0a73290714
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
47 changed files with 146 additions and 385 deletions

View File

@ -86,7 +86,7 @@
"error",
{
"zones": [
// Do not allow angular/node/electron code to be imported into common
// Do not allow angular/node code to be imported into common
{
"target": "./libs/common/**/*",
"from": "./libs/angular/**/*"
@ -94,10 +94,6 @@
{
"target": "./libs/common/**/*",
"from": "./libs/node/**/*"
},
{
"target": "./libs/common/**/*",
"from": "./libs/electron/**/*"
}
]
}
@ -131,12 +127,6 @@
"rules": {
"no-restricted-imports": ["error", { "patterns": ["@bitwarden/node/*", "src/**/*"] }]
}
},
{
"files": ["libs/electron/src/**/*.ts"],
"rules": {
"no-restricted-imports": ["error", { "patterns": ["@bitwarden/electron/*", "src/**/*"] }]
}
}
]
}

View File

@ -152,16 +152,6 @@
./libs/common/src/services/bitwardenFileUpload.service.ts
./libs/common/src/services/webCryptoFunction.service.ts
./libs/common/src/interfaces/IEncrypted.ts
./libs/electron/spec/services/electronLog.service.spec.ts
./libs/electron/src/baseMenu.ts
./libs/electron/src/services/electronLog.service.ts
./libs/electron/src/services/electronStorage.service.ts
./libs/electron/src/services/electronRendererMessaging.service.ts
./libs/electron/src/services/electronMainMessaging.service.ts
./libs/electron/src/services/electronPlatformUtils.service.ts
./libs/electron/src/services/electronRendererStorage.service.ts
./libs/electron/src/services/electronCrypto.service.ts
./libs/electron/src/services/electronRendererSecureStorage.service.ts
./README.md
./LICENSE_BITWARDEN.txt
./CONTRIBUTING.md

View File

@ -7,7 +7,8 @@ import { EnvironmentService } from "@bitwarden/common/abstractions/environment.s
import { I18nService } from "@bitwarden/common/abstractions/i18n.service";
import { PlatformUtilsService } from "@bitwarden/common/abstractions/platformUtils.service";
import { Utils } from "@bitwarden/common/misc/utils";
import { getCookie } from "@bitwarden/electron/utils";
import { getCookie } from "../../utils";
const BroadcasterSubscriptionId = "AccessibilityCookieComponent";

View File

@ -14,9 +14,9 @@ import { DeviceType } from "@bitwarden/common/enums/deviceType";
import { StorageLocation } from "@bitwarden/common/enums/storageLocation";
import { ThemeType } from "@bitwarden/common/enums/themeType";
import { Utils } from "@bitwarden/common/misc/utils";
import { isWindowsStore } from "@bitwarden/electron/utils";
import { flagEnabled } from "../../flags";
import { isWindowsStore } from "../../utils";
import { SetPinComponent } from "../components/set-pin.component";
@Component({

View File

@ -1,7 +1,7 @@
import { enableProdMode } from "@angular/core";
import { platformBrowserDynamic } from "@angular/platform-browser-dynamic";
import { isDev } from "@bitwarden/electron/utils";
import { isDev } from "../utils";
// tslint:disable-next-line
require("../scss/styles.scss");

View File

@ -10,8 +10,8 @@ import { PolicyService } from "@bitwarden/common/abstractions/policy/policy.serv
import { SearchService } from "@bitwarden/common/abstractions/search.service";
import { SendService } from "@bitwarden/common/abstractions/send.service";
import { SendView } from "@bitwarden/common/models/view/send.view";
import { invokeMenu, RendererMenuItem } from "@bitwarden/electron/utils";
import { invokeMenu, RendererMenuItem } from "../../utils";
import { SearchBarService } from "../layout/search/search-bar.service";
import { AddEditComponent } from "./add-edit.component";

View File

@ -39,14 +39,14 @@ import { GlobalState } from "@bitwarden/common/models/domain/global-state";
import { LoginService } from "@bitwarden/common/services/login.service";
import { MemoryStorageService } from "@bitwarden/common/services/memoryStorage.service";
import { SystemService } from "@bitwarden/common/services/system.service";
import { ElectronCryptoService } from "@bitwarden/electron/services/electronCrypto.service";
import { ElectronLogService } from "@bitwarden/electron/services/electronLog.service";
import { ElectronPlatformUtilsService } from "@bitwarden/electron/services/electronPlatformUtils.service";
import { ElectronRendererMessagingService } from "@bitwarden/electron/services/electronRendererMessaging.service";
import { ElectronRendererSecureStorageService } from "@bitwarden/electron/services/electronRendererSecureStorage.service";
import { ElectronRendererStorageService } from "@bitwarden/electron/services/electronRendererStorage.service";
import { Account } from "../../models/account";
import { ElectronCryptoService } from "../../services/electron-crypto.service";
import { ElectronLogService } from "../../services/electron-log.service";
import { ElectronPlatformUtilsService } from "../../services/electron-platform-utils.service";
import { ElectronRendererMessagingService } from "../../services/electron-renderer-messaging.service";
import { ElectronRendererSecureStorageService } from "../../services/electron-renderer-secure-storage.service";
import { ElectronRendererStorageService } from "../../services/electron-renderer-storage.service";
import { EncryptedMessageHandlerService } from "../../services/encrypted-message-handler.service";
import { I18nService } from "../../services/i18n.service";
import { NativeMessageHandlerService } from "../../services/native-message-handler.service";

View File

@ -27,8 +27,8 @@ import { CipherType } from "@bitwarden/common/enums/cipherType";
import { EventType } from "@bitwarden/common/enums/eventType";
import { CipherView } from "@bitwarden/common/models/view/cipher.view";
import { FolderView } from "@bitwarden/common/models/view/folder.view";
import { invokeMenu, RendererMenuItem } from "@bitwarden/electron/utils";
import { invokeMenu, RendererMenuItem } from "../../utils";
import { SearchBarService } from "../layout/search/search-bar.service";
import { AddEditComponent } from "./add-edit.component";

View File

@ -6,12 +6,6 @@ import { StateFactory } from "@bitwarden/common/factories/stateFactory";
import { GlobalState } from "@bitwarden/common/models/domain/global-state";
import { MemoryStorageService } from "@bitwarden/common/services/memoryStorage.service";
import { StateService } from "@bitwarden/common/services/state.service";
import { ElectronLogService } from "@bitwarden/electron/services/electronLog.service";
import { ElectronMainMessagingService } from "@bitwarden/electron/services/electronMainMessaging.service";
import { ElectronStorageService } from "@bitwarden/electron/services/electronStorage.service";
import { TrayMain } from "@bitwarden/electron/tray.main";
import { UpdaterMain } from "@bitwarden/electron/updater.main";
import { WindowMain } from "@bitwarden/electron/window.main";
import { BiometricMain } from "./main/biometric/biometric.main";
import { DesktopCredentialStorageListener } from "./main/desktop-credential-storage-listener";
@ -19,7 +13,13 @@ import { MenuMain } from "./main/menu/menu.main";
import { MessagingMain } from "./main/messaging.main";
import { NativeMessagingMain } from "./main/native-messaging.main";
import { PowerMonitorMain } from "./main/power-monitor.main";
import { TrayMain } from "./main/tray.main";
import { UpdaterMain } from "./main/updater.main";
import { WindowMain } from "./main/window.main";
import { Account } from "./models/account";
import { ElectronLogService } from "./services/electron-log.service";
import { ElectronMainMessagingService } from "./services/electron-main-messaging.service";
import { ElectronStorageService } from "./services/electron-storage.service";
import { I18nService } from "./services/i18n.service";
export class Main {
@ -105,15 +105,7 @@ export class Main {
(win) => this.trayMain.setupWindowListeners(win)
);
this.messagingMain = new MessagingMain(this, this.stateService);
this.updaterMain = new UpdaterMain(
this.i18nService,
this.windowMain,
"clients",
null,
null,
null,
"bitwarden"
);
this.updaterMain = new UpdaterMain(this.i18nService, this.windowMain, "bitwarden");
this.menuMain = new MenuMain(this);
this.powerMonitorMain = new PowerMonitorMain(this);
this.trayMain = new TrayMain(this.windowMain, this.i18nService, this.stateService);

View File

@ -4,7 +4,8 @@ import { I18nService } from "@bitwarden/common/abstractions/i18n.service";
import { LogService } from "@bitwarden/common/abstractions/log.service";
import { StateService } from "@bitwarden/common/abstractions/state.service";
import { biometrics } from "@bitwarden/desktop-native";
import { WindowMain } from "@bitwarden/electron/window.main";
import { WindowMain } from "../window.main";
import { BiometricMain } from "./biometric.main";

View File

@ -1,8 +1,9 @@
import { BrowserWindow, clipboard, dialog, MenuItemConstructorOptions } from "electron";
import { I18nService } from "@bitwarden/common/abstractions/i18n.service";
import { UpdaterMain } from "@bitwarden/electron/updater.main";
import { isMacAppStore, isSnapStore, isWindowsStore } from "@bitwarden/electron/utils";
import { isMacAppStore, isSnapStore, isWindowsStore } from "../../utils";
import { UpdaterMain } from "../updater.main";
import { IMenubarMenu } from "./menubar";

View File

@ -2,7 +2,8 @@ import { BrowserWindow, dialog, MenuItemConstructorOptions, shell } from "electr
import { I18nService } from "@bitwarden/common/abstractions/i18n.service";
import { MessagingService } from "@bitwarden/common/abstractions/messaging.service";
import { isMacAppStore, isWindowsStore } from "@bitwarden/electron/utils";
import { isMacAppStore, isWindowsStore } from "../../utils";
import { IMenubarMenu } from "./menubar";

View File

@ -2,8 +2,9 @@ import { BrowserWindow, MenuItemConstructorOptions } from "electron";
import { I18nService } from "@bitwarden/common/abstractions/i18n.service";
import { MessagingService } from "@bitwarden/common/abstractions/messaging.service";
import { UpdaterMain } from "@bitwarden/electron/updater.main";
import { isMac } from "@bitwarden/electron/utils";
import { isMac } from "../../utils";
import { UpdaterMain } from "../updater.main";
import { FirstMenu } from "./menu.first";
import { MenuAccount } from "./menu.updater";

View File

@ -2,8 +2,9 @@ import { BrowserWindow, MenuItemConstructorOptions } from "electron";
import { I18nService } from "@bitwarden/common/abstractions/i18n.service";
import { MessagingService } from "@bitwarden/common/abstractions/messaging.service";
import { UpdaterMain } from "@bitwarden/electron/updater.main";
import { isMac, isMacAppStore } from "@bitwarden/electron/utils";
import { isMac, isMacAppStore } from "../../utils";
import { UpdaterMain } from "../updater.main";
import { FirstMenu } from "./menu.first";
import { MenuAccount } from "./menu.updater";

View File

@ -2,8 +2,9 @@ import { BrowserWindow, dialog, MenuItem, MenuItemConstructorOptions } from "ele
import { I18nService } from "@bitwarden/common/abstractions/i18n.service";
import { MessagingService } from "@bitwarden/common/abstractions/messaging.service";
import { UpdaterMain } from "@bitwarden/electron/updater.main";
import { isMacAppStore, isSnapStore, isWindowsStore } from "@bitwarden/electron/utils";
import { isMacAppStore, isSnapStore, isWindowsStore } from "../../utils";
import { UpdaterMain } from "../updater.main";
import { MenuAccount } from "./menu.updater";

View File

@ -1,7 +1,8 @@
import { shell, MenuItemConstructorOptions } from "electron";
import { I18nService } from "@bitwarden/common/abstractions/i18n.service";
import { isMacAppStore, isWindowsStore } from "@bitwarden/electron/utils";
import { isMacAppStore, isWindowsStore } from "../../utils";
import { AboutMenu } from "./menu.about";
import { IMenubarMenu } from "./menubar";

View File

@ -1,17 +1,22 @@
import { app, Menu } from "electron";
import { BaseMenu } from "@bitwarden/electron/baseMenu";
import { I18nService } from "@bitwarden/common/abstractions/i18n.service";
import { Main } from "../../main";
import { WindowMain } from "../window.main";
import { MenuUpdateRequest } from "./menu.updater";
import { Menubar } from "./menubar";
const cloudWebVaultUrl = "https://vault.bitwarden.com";
export class MenuMain extends BaseMenu {
export class MenuMain {
private i18nService: I18nService;
private windowMain: WindowMain;
constructor(private main: Main) {
super(main.i18nService, main.windowMain);
this.i18nService = main.i18nService;
this.windowMain = main.windowMain;
}
async init() {
@ -49,4 +54,84 @@ export class MenuMain extends BaseMenu {
}
return webVaultUrl;
}
private initContextMenu() {
if (this.windowMain.win == null) {
return;
}
const selectionMenu = Menu.buildFromTemplate([
{
label: this.i18nService.t("copy"),
role: "copy",
},
{ type: "separator" },
{
label: this.i18nService.t("selectAll"),
role: "selectAll",
},
]);
const inputMenu = Menu.buildFromTemplate([
{
label: this.i18nService.t("undo"),
role: "undo",
},
{
label: this.i18nService.t("redo"),
role: "redo",
},
{ type: "separator" },
{
label: this.i18nService.t("cut"),
role: "cut",
enabled: false,
},
{
label: this.i18nService.t("copy"),
role: "copy",
enabled: false,
},
{
label: this.i18nService.t("paste"),
role: "paste",
},
{ type: "separator" },
{
label: this.i18nService.t("selectAll"),
role: "selectAll",
},
]);
const inputSelectionMenu = Menu.buildFromTemplate([
{
label: this.i18nService.t("cut"),
role: "cut",
},
{
label: this.i18nService.t("copy"),
role: "copy",
},
{
label: this.i18nService.t("paste"),
role: "paste",
},
{ type: "separator" },
{
label: this.i18nService.t("selectAll"),
role: "selectAll",
},
]);
this.windowMain.win.webContents.on("context-menu", (e, props) => {
const selected = props.selectionText && props.selectionText.trim() !== "";
if (props.isEditable && selected) {
inputSelectionMenu.popup({ window: this.windowMain.win });
} else if (props.isEditable) {
inputMenu.popup({ window: this.windowMain.win });
} else if (selected) {
selectionMenu.popup({ window: this.windowMain.win });
}
});
}
}

View File

@ -2,8 +2,9 @@ import { MenuItemConstructorOptions } from "electron";
import { I18nService } from "@bitwarden/common/abstractions/i18n.service";
import { MessagingService } from "@bitwarden/common/abstractions/messaging.service";
import { isMac } from "@bitwarden/electron/utils";
import { WindowMain } from "@bitwarden/electron/window.main";
import { isMac } from "../../utils";
import { WindowMain } from "../window.main";
import { IMenubarMenu } from "./menubar";

View File

@ -2,9 +2,10 @@ import { Menu, MenuItemConstructorOptions } from "electron";
import { I18nService } from "@bitwarden/common/abstractions/i18n.service";
import { MessagingService } from "@bitwarden/common/abstractions/messaging.service";
import { UpdaterMain } from "@bitwarden/electron/updater.main";
import { isMac } from "@bitwarden/electron/utils";
import { WindowMain } from "@bitwarden/electron/window.main";
import { isMac } from "../../utils";
import { UpdaterMain } from "../updater.main";
import { WindowMain } from "../window.main";
import { AboutMenu } from "./menu.about";
import { AccountMenu } from "./menu.account";

View File

@ -8,7 +8,8 @@ import { ipcMain } from "electron";
import * as ipc from "node-ipc";
import { LogService } from "@bitwarden/common/abstractions/log.service";
import { WindowMain } from "@bitwarden/electron/window.main";
import { WindowMain } from "./window.main";
export class NativeMessagingMain {
private connected: Socket[] = [];

View File

@ -1,8 +1,7 @@
import { powerMonitor } from "electron";
import { isSnapStore } from "@bitwarden/electron/utils";
import { Main } from "../main";
import { isSnapStore } from "../utils";
// tslint:disable-next-line
const IdleLockSeconds = 5 * 60; // 5 minutes

View File

@ -4,10 +4,11 @@ import { autoUpdater } from "electron-updater";
import { I18nService } from "@bitwarden/common/abstractions/i18n.service";
import { isAppImage, isDev, isMacAppStore, isWindowsPortable, isWindowsStore } from "./utils";
import { isAppImage, isDev, isMacAppStore, isWindowsPortable, isWindowsStore } from "../utils";
import { WindowMain } from "./window.main";
const UpdaterCheckInitalDelay = 5 * 1000; // 5 seconds
const UpdaterCheckInitialDelay = 5 * 1000; // 5 seconds
const UpdaterCheckInterval = 12 * 60 * 60 * 1000; // 12 hours
export class UpdaterMain {
@ -18,10 +19,6 @@ export class UpdaterMain {
constructor(
private i18nService: I18nService,
private windowMain: WindowMain,
private gitHubProject: string,
private onCheckingForUpdate: () => void = null,
private onReset: () => void = null,
private onUpdateDownloaded: () => void = null,
private projectName: string
) {
autoUpdater.logger = log;
@ -36,13 +33,10 @@ export class UpdaterMain {
}
async init() {
global.setTimeout(async () => await this.checkForUpdate(), UpdaterCheckInitalDelay);
global.setTimeout(async () => await this.checkForUpdate(), UpdaterCheckInitialDelay);
global.setInterval(async () => await this.checkForUpdate(), UpdaterCheckInterval);
autoUpdater.on("checking-for-update", () => {
if (this.onCheckingForUpdate != null) {
this.onCheckingForUpdate();
}
this.doingUpdateCheck = true;
});
@ -87,10 +81,6 @@ export class UpdaterMain {
});
autoUpdater.on("update-downloaded", async (info) => {
if (this.onUpdateDownloaded != null) {
this.onUpdateDownloaded();
}
if (this.windowMain.win == null) {
return;
}
@ -132,7 +122,7 @@ export class UpdaterMain {
if (!this.canUpdate) {
if (withFeedback) {
shell.openExternal("https://github.com/bitwarden/" + this.gitHubProject + "/releases");
shell.openExternal("https://github.com/bitwarden/clients/releases");
}
return;
@ -147,9 +137,6 @@ export class UpdaterMain {
}
private reset() {
if (this.onReset != null) {
this.onReset();
}
autoUpdater.autoDownload = true;
this.doingUpdateCheck = false;
}

View File

@ -6,7 +6,7 @@ import { app, BrowserWindow, screen } from "electron";
import { LogService } from "@bitwarden/common/abstractions/log.service";
import { StateService } from "@bitwarden/common/abstractions/state.service";
import { cleanUserAgent, isDev, isMacAppStore, isSnapStore } from "./utils";
import { cleanUserAgent, isDev, isMacAppStore, isSnapStore } from "../utils";
const mainWindowSizeKey = "mainWindowSize";
const WindowEventHandlingDelay = 100;

View File

@ -1,4 +1,4 @@
import { ElectronLogService } from "@bitwarden/electron/services/electronLog.service";
import { ElectronLogService } from "./electron-log.service";
describe("ElectronLogService", () => {
it("sets dev based on electron method", () => {

View File

@ -3,8 +3,8 @@ import { app, dialog, ipcMain, Menu, MenuItem, nativeTheme, session } from "elec
import { MessagingService } from "@bitwarden/common/abstractions/messaging.service";
import { ThemeType } from "@bitwarden/common/enums/themeType";
import { WindowMain } from "../main/window.main";
import { RendererMenuItem } from "../utils";
import { WindowMain } from "../window.main";
export class ElectronMainMessagingService implements MessagingService {
constructor(private windowMain: WindowMain, private onMessage: (message: any) => void) {

View File

@ -1,4 +1,4 @@
import { cleanUserAgent } from "@bitwarden/electron/utils";
import { cleanUserAgent } from "./utils";
const expectedUserAgent = `Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/${process.versions.chrome} Safari/537.36`;

View File

@ -11,8 +11,7 @@
"baseUrl": ".",
"paths": {
"@bitwarden/common/*": ["../../libs/common/src/*"],
"@bitwarden/angular/*": ["../../libs/angular/src/*"],
"@bitwarden/electron/*": ["../../libs/electron/src/*"]
"@bitwarden/angular/*": ["../../libs/angular/src/*"]
}
},
"angularCompilerOptions": {

View File

@ -19,7 +19,6 @@ module.exports = {
"<rootDir>/libs/angular/jest.config.js",
"<rootDir>/libs/common/jest.config.js",
"<rootDir>/libs/components/jest.config.js",
"<rootDir>/libs/electron/jest.config.js",
"<rootDir>/libs/node/jest.config.js",
],

View File

@ -1,14 +0,0 @@
const { pathsToModuleNameMapper } = require("ts-jest");
const { compilerOptions } = require("../shared/tsconfig.libs");
const sharedConfig = require("../../libs/shared/jest.config.base");
module.exports = {
...sharedConfig,
preset: "ts-jest",
testEnvironment: "jsdom",
moduleNameMapper: pathsToModuleNameMapper(compilerOptions?.paths || {}, {
prefix: "<rootDir>/",
}),
};

View File

@ -1,23 +0,0 @@
{
"name": "@bitwarden/electron",
"version": "0.0.0",
"description": "Common code used across Bitwarden JavaScript projects.",
"keywords": [
"bitwarden"
],
"author": "Bitwarden Inc.",
"homepage": "https://bitwarden.com",
"repository": {
"type": "git",
"url": "https://github.com/bitwarden/jslib"
},
"license": "GPL-3.0",
"scripts": {
"clean": "rimraf dist/**/*",
"build": "npm run clean && tsc",
"build:watch": "npm run clean && tsc -watch"
},
"dependencies": {
"@bitwarden/common": "file:../common"
}
}

View File

@ -1,225 +0,0 @@
import { Menu, MenuItemConstructorOptions } from "electron";
import { I18nService } from "@bitwarden/common/abstractions/i18n.service";
import { WindowMain } from "./window.main";
export class BaseMenu {
protected editMenuItemOptions: MenuItemConstructorOptions;
protected viewSubMenuItemOptions: MenuItemConstructorOptions[];
protected windowMenuItemOptions: MenuItemConstructorOptions;
protected macAppMenuItemOptions: MenuItemConstructorOptions[];
protected macWindowSubmenuOptions: MenuItemConstructorOptions[];
constructor(protected i18nService: I18nService, protected windowMain: WindowMain) {}
protected initProperties() {
this.editMenuItemOptions = {
label: this.i18nService.t("edit"),
submenu: [
{
label: this.i18nService.t("undo"),
role: "undo",
},
{
label: this.i18nService.t("redo"),
role: "redo",
},
{ type: "separator" },
{
label: this.i18nService.t("cut"),
role: "cut",
},
{
label: this.i18nService.t("copy"),
role: "copy",
},
{
label: this.i18nService.t("paste"),
role: "paste",
},
{ type: "separator" },
{
label: this.i18nService.t("selectAll"),
role: "selectAll",
},
],
};
this.viewSubMenuItemOptions = [
{
label: this.i18nService.t("zoomIn"),
role: "zoomIn",
accelerator: "CmdOrCtrl+=",
},
{
label: this.i18nService.t("zoomOut"),
role: "zoomOut",
accelerator: "CmdOrCtrl+-",
},
{
label: this.i18nService.t("resetZoom"),
role: "resetZoom",
accelerator: "CmdOrCtrl+0",
},
{ type: "separator" },
{
label: this.i18nService.t("toggleFullScreen"),
role: "togglefullscreen",
},
{ type: "separator" },
{
label: this.i18nService.t("reload"),
role: "forceReload",
},
{
label: this.i18nService.t("toggleDevTools"),
role: "toggleDevTools",
accelerator: "F12",
},
];
this.windowMenuItemOptions = {
label: this.i18nService.t("window"),
role: "window",
submenu: [
{
label: this.i18nService.t("minimize"),
role: "minimize",
},
{
label: this.i18nService.t("close"),
role: "close",
},
],
};
if (process.platform === "darwin") {
this.macAppMenuItemOptions = [
{
label: this.i18nService.t("services"),
role: "services",
submenu: [],
},
{ type: "separator" },
{
label: this.i18nService.t("hideBitwarden"),
role: "hide",
},
{
label: this.i18nService.t("hideOthers"),
role: "hideOthers",
},
{
label: this.i18nService.t("showAll"),
role: "unhide",
},
{ type: "separator" },
{
label: this.i18nService.t("quitBitwarden"),
role: "quit",
},
];
this.macWindowSubmenuOptions = [
{
label: this.i18nService.t("minimize"),
role: "minimize",
},
{
label: this.i18nService.t("zoom"),
role: "zoom",
},
{ type: "separator" },
{
label: this.i18nService.t("bringAllToFront"),
role: "front",
},
{
label: this.i18nService.t("close"),
role: "close",
},
];
}
}
protected initContextMenu() {
if (this.windowMain.win == null) {
return;
}
const selectionMenu = Menu.buildFromTemplate([
{
label: this.i18nService.t("copy"),
role: "copy",
},
{ type: "separator" },
{
label: this.i18nService.t("selectAll"),
role: "selectAll",
},
]);
const inputMenu = Menu.buildFromTemplate([
{
label: this.i18nService.t("undo"),
role: "undo",
},
{
label: this.i18nService.t("redo"),
role: "redo",
},
{ type: "separator" },
{
label: this.i18nService.t("cut"),
role: "cut",
enabled: false,
},
{
label: this.i18nService.t("copy"),
role: "copy",
enabled: false,
},
{
label: this.i18nService.t("paste"),
role: "paste",
},
{ type: "separator" },
{
label: this.i18nService.t("selectAll"),
role: "selectAll",
},
]);
const inputSelectionMenu = Menu.buildFromTemplate([
{
label: this.i18nService.t("cut"),
role: "cut",
},
{
label: this.i18nService.t("copy"),
role: "copy",
},
{
label: this.i18nService.t("paste"),
role: "paste",
},
{ type: "separator" },
{
label: this.i18nService.t("selectAll"),
role: "selectAll",
},
]);
this.windowMain.win.webContents.on("context-menu", (e, props) => {
const selected = props.selectionText && props.selectionText.trim() !== "";
if (props.isEditable && selected) {
inputSelectionMenu.popup({ window: this.windowMain.win });
} else if (props.isEditable) {
inputMenu.popup({ window: this.windowMain.win });
} else if (selected) {
selectionMenu.popup({ window: this.windowMain.win });
}
});
}
}

View File

View File

@ -1,5 +0,0 @@
{
"extends": "../shared/tsconfig.libs",
"include": ["src", "spec"],
"exclude": ["node_modules", "dist"]
}

View File

@ -1,3 +0,0 @@
{
"extends": "./tsconfig.json"
}

View File

@ -4,7 +4,6 @@
"paths": {
"@bitwarden/common/*": ["../common/src/*"],
"@bitwarden/angular/*": ["../angular/src/*"],
"@bitwarden/electron/*": ["../electron/src/*"],
"@bitwarden/node/*": ["../node/src/*"]
}
}

18
package-lock.json generated
View File

@ -246,14 +246,6 @@
"name": "@bitwarden/components",
"version": "0.0.0"
},
"libs/electron": {
"name": "@bitwarden/electron",
"version": "0.0.0",
"license": "GPL-3.0",
"dependencies": {
"@bitwarden/common": "file:../common"
}
},
"libs/node": {
"name": "@bitwarden/node",
"version": "0.0.0",
@ -3092,10 +3084,6 @@
"resolved": "apps/desktop/desktop_native",
"link": true
},
"node_modules/@bitwarden/electron": {
"resolved": "libs/electron",
"link": true
},
"node_modules/@bitwarden/node": {
"resolved": "libs/node",
"link": true
@ -45193,12 +45181,6 @@
"@napi-rs/cli": "^2.6.2"
}
},
"@bitwarden/electron": {
"version": "file:libs/electron",
"requires": {
"@bitwarden/common": "file:../common"
}
},
"@bitwarden/node": {
"version": "file:libs/node",
"requires": {

View File

@ -17,7 +17,6 @@
"paths": {
"@bitwarden/common/*": ["./libs/common/src/*"],
"@bitwarden/angular/*": ["./libs/angular/src/*"],
"@bitwarden/electron/*": ["./libs/electron/src/*"],
"@bitwarden/node/*": ["./libs/node/src/*"],
"@bitwarden/components": ["./libs/components/src"]
},

View File

@ -17,7 +17,6 @@
"paths": {
"@bitwarden/common/*": ["./libs/common/src/*"],
"@bitwarden/angular/*": ["./libs/angular/src/*"],
"@bitwarden/electron/*": ["./libs/electron/src/*"],
"@bitwarden/node/*": ["./libs/node/src/*"],
"@bitwarden/components": ["./libs/components/src"]
},