A fully open source & end-to-end encrypted note taking alternative to Evernote.
TypeScript asp-net-coredotnet-coreelectronfosshacktoberfestnote-managmentnote-takingnote-taking-appnotebooknotesnotes-appopen-sourceopensourceprivacyproductivityreactreact-nativereactjsself-hosted
desktop: remove icon from native menu
Abdullah Atta513c9ee8a79d
diff --git a/apps/desktop/package-lock.json b/apps/desktop/package-lock.jsonindex aa3921ebc..35ac2a864 100644--- a/apps/desktop/package-lock.json+++ b/apps/desktop/package-lock.json@@ -13,7 +13,6 @@"@lingui/core": "5.1.2","@notesnook/intl": "file:../../packages/intl","@notesnook/ui": "file:../../packages/ui",- "@resvg/resvg-js": "^2.6.2","@trpc/client": "10.45.2","@trpc/server": "10.45.2","better-sqlite3-multiple-ciphers": "11.9.1",@@ -7752,221 +7751,6 @@"node": ">=14"}},- "node_modules/@resvg/resvg-js": {- "version": "2.6.2",- "resolved": "https://registry.npmjs.org/@resvg/resvg-js/-/resvg-js-2.6.2.tgz",- "integrity": "sha512-xBaJish5OeGmniDj9cW5PRa/PtmuVU3ziqrbr5xJj901ZDN4TosrVaNZpEiLZAxdfnhAe7uQ7QFWfjPe9d9K2Q==",- "license": "MPL-2.0",- "engines": {- "node": ">= 10"- },- "optionalDependencies": {- "@resvg/resvg-js-android-arm-eabi": "2.6.2",- "@resvg/resvg-js-android-arm64": "2.6.2",- "@resvg/resvg-js-darwin-arm64": "2.6.2",- "@resvg/resvg-js-darwin-x64": "2.6.2",- "@resvg/resvg-js-linux-arm-gnueabihf": "2.6.2",- "@resvg/resvg-js-linux-arm64-gnu": "2.6.2",- "@resvg/resvg-js-linux-arm64-musl": "2.6.2",- "@resvg/resvg-js-linux-x64-gnu": "2.6.2",- "@resvg/resvg-js-linux-x64-musl": "2.6.2",- "@resvg/resvg-js-win32-arm64-msvc": "2.6.2",- "@resvg/resvg-js-win32-ia32-msvc": "2.6.2",- "@resvg/resvg-js-win32-x64-msvc": "2.6.2"- }- },- "node_modules/@resvg/resvg-js-android-arm-eabi": {- "version": "2.6.2",- "resolved": "https://registry.npmjs.org/@resvg/resvg-js-android-arm-eabi/-/resvg-js-android-arm-eabi-2.6.2.tgz",- "integrity": "sha512-FrJibrAk6v29eabIPgcTUMPXiEz8ssrAk7TXxsiZzww9UTQ1Z5KAbFJs+Z0Ez+VZTYgnE5IQJqBcoSiMebtPHA==",- "cpu": [- "arm"- ],- "license": "MPL-2.0",- "optional": true,- "os": [- "android"- ],- "engines": {- "node": ">= 10"- }- },- "node_modules/@resvg/resvg-js-android-arm64": {- "version": "2.6.2",- "resolved": "https://registry.npmjs.org/@resvg/resvg-js-android-arm64/-/resvg-js-android-arm64-2.6.2.tgz",- "integrity": "sha512-VcOKezEhm2VqzXpcIJoITuvUS/fcjIw5NA/w3tjzWyzmvoCdd+QXIqy3FBGulWdClvp4g+IfUemigrkLThSjAQ==",- "cpu": [- "arm64"- ],- "license": "MPL-2.0",- "optional": true,- "os": [- "android"- ],- "engines": {- "node": ">= 10"- }- },- "node_modules/@resvg/resvg-js-darwin-arm64": {- "version": "2.6.2",- "resolved": "https://registry.npmjs.org/@resvg/resvg-js-darwin-arm64/-/resvg-js-darwin-arm64-2.6.2.tgz",- "integrity": "sha512-nmok2LnAd6nLUKI16aEB9ydMC6Lidiiq2m1nEBDR1LaaP7FGs4AJ90qDraxX+CWlVuRlvNjyYJTNv8qFjtL9+A==",- "cpu": [- "arm64"- ],- "license": "MPL-2.0",- "optional": true,- "os": [- "darwin"- ],- "engines": {- "node": ">= 10"- }- },- "node_modules/@resvg/resvg-js-darwin-x64": {- "version": "2.6.2",- "resolved": "https://registry.npmjs.org/@resvg/resvg-js-darwin-x64/-/resvg-js-darwin-x64-2.6.2.tgz",- "integrity": "sha512-GInyZLjgWDfsVT6+SHxQVRwNzV0AuA1uqGsOAW+0th56J7Nh6bHHKXHBWzUrihxMetcFDmQMAX1tZ1fZDYSRsw==",- "cpu": [- "x64"- ],- "license": "MPL-2.0",- "optional": true,- "os": [- "darwin"- ],- "engines": {- "node": ">= 10"- }- },- "node_modules/@resvg/resvg-js-linux-arm-gnueabihf": {- "version": "2.6.2",- "resolved": "https://registry.npmjs.org/@resvg/resvg-js-linux-arm-gnueabihf/-/resvg-js-linux-arm-gnueabihf-2.6.2.tgz",- "integrity": "sha512-YIV3u/R9zJbpqTTNwTZM5/ocWetDKGsro0SWp70eGEM9eV2MerWyBRZnQIgzU3YBnSBQ1RcxRZvY/UxwESfZIw==",- "cpu": [- "arm"- ],- "license": "MPL-2.0",- "optional": true,- "os": [- "linux"- ],- "engines": {- "node": ">= 10"- }- },- "node_modules/@resvg/resvg-js-linux-arm64-gnu": {- "version": "2.6.2",- "resolved": "https://registry.npmjs.org/@resvg/resvg-js-linux-arm64-gnu/-/resvg-js-linux-arm64-gnu-2.6.2.tgz",- "integrity": "sha512-zc2BlJSim7YR4FZDQ8OUoJg5holYzdiYMeobb9pJuGDidGL9KZUv7SbiD4E8oZogtYY42UZEap7dqkkYuA91pg==",- "cpu": [- "arm64"- ],- "license": "MPL-2.0",- "optional": true,- "os": [- "linux"- ],- "engines": {- "node": ">= 10"- }- },- "node_modules/@resvg/resvg-js-linux-arm64-musl": {- "version": "2.6.2",- "resolved": "https://registry.npmjs.org/@resvg/resvg-js-linux-arm64-musl/-/resvg-js-linux-arm64-musl-2.6.2.tgz",- "integrity": "sha512-3h3dLPWNgSsD4lQBJPb4f+kvdOSJHa5PjTYVsWHxLUzH4IFTJUAnmuWpw4KqyQ3NA5QCyhw4TWgxk3jRkQxEKg==",- "cpu": [- "arm64"- ],- "license": "MPL-2.0",- "optional": true,- "os": [- "linux"- ],- "engines": {- "node": ">= 10"- }- },- "node_modules/@resvg/resvg-js-linux-x64-gnu": {- "version": "2.6.2",- "resolved": "https://registry.npmjs.org/@resvg/resvg-js-linux-x64-gnu/-/resvg-js-linux-x64-gnu-2.6.2.tgz",- "integrity": "sha512-IVUe+ckIerA7xMZ50duAZzwf1U7khQe2E0QpUxu5MBJNao5RqC0zwV/Zm965vw6D3gGFUl7j4m+oJjubBVoftw==",- "cpu": [- "x64"- ],- "license": "MPL-2.0",- "optional": true,- "os": [- "linux"- ],- "engines": {- "node": ">= 10"- }- },- "node_modules/@resvg/resvg-js-linux-x64-musl": {- "version": "2.6.2",- "resolved": "https://registry.npmjs.org/@resvg/resvg-js-linux-x64-musl/-/resvg-js-linux-x64-musl-2.6.2.tgz",- "integrity": "sha512-UOf83vqTzoYQO9SZ0fPl2ZIFtNIz/Rr/y+7X8XRX1ZnBYsQ/tTb+cj9TE+KHOdmlTFBxhYzVkP2lRByCzqi4jQ==",- "cpu": [- "x64"- ],- "license": "MPL-2.0",- "optional": true,- "os": [- "linux"- ],- "engines": {- "node": ">= 10"- }- },- "node_modules/@resvg/resvg-js-win32-arm64-msvc": {- "version": "2.6.2",- "resolved": "https://registry.npmjs.org/@resvg/resvg-js-win32-arm64-msvc/-/resvg-js-win32-arm64-msvc-2.6.2.tgz",- "integrity": "sha512-7C/RSgCa+7vqZ7qAbItfiaAWhyRSoD4l4BQAbVDqRRsRgY+S+hgS3in0Rxr7IorKUpGE69X48q6/nOAuTJQxeQ==",- "cpu": [- "arm64"- ],- "license": "MPL-2.0",- "optional": true,- "os": [- "win32"- ],- "engines": {- "node": ">= 10"- }- },- "node_modules/@resvg/resvg-js-win32-ia32-msvc": {- "version": "2.6.2",- "resolved": "https://registry.npmjs.org/@resvg/resvg-js-win32-ia32-msvc/-/resvg-js-win32-ia32-msvc-2.6.2.tgz",- "integrity": "sha512-har4aPAlvjnLcil40AC77YDIk6loMawuJwFINEM7n0pZviwMkMvjb2W5ZirsNOZY4aDbo5tLx0wNMREp5Brk+w==",- "cpu": [- "ia32"- ],- "license": "MPL-2.0",- "optional": true,- "os": [- "win32"- ],- "engines": {- "node": ">= 10"- }- },- "node_modules/@resvg/resvg-js-win32-x64-msvc": {- "version": "2.6.2",- "resolved": "https://registry.npmjs.org/@resvg/resvg-js-win32-x64-msvc/-/resvg-js-win32-x64-msvc-2.6.2.tgz",- "integrity": "sha512-ZXtYhtUr5SSaBrUDq7DiyjOFJqBVL/dOBN7N/qmi/pO0IgiWW/f/ue3nbvu9joWE5aAKDoIzy/CxsY0suwGosQ==",- "cpu": [- "x64"- ],- "license": "MPL-2.0",- "optional": true,- "os": [- "win32"- ],- "engines": {- "node": ">= 10"- }- },"node_modules/@rollup/rollup-android-arm-eabi": {"version": "4.40.1","resolved": "https://registry.npmjs.org/@rollup/rollup-android-arm-eabi/-/rollup-android-arm-eabi-4.40.1.tgz",diff --git a/apps/desktop/package.json b/apps/desktop/package.jsonindex ff93508be..d9c756139 100644--- a/apps/desktop/package.json+++ b/apps/desktop/package.json@@ -28,7 +28,6 @@"@lingui/core": "5.1.2","@notesnook/intl": "file:../../packages/intl","@notesnook/ui": "file:../../packages/ui",- "@resvg/resvg-js": "^2.6.2","@trpc/client": "10.45.2","@trpc/server": "10.45.2","better-sqlite3-multiple-ciphers": "11.9.1",diff --git a/apps/desktop/src/api/os-integration.ts b/apps/desktop/src/api/os-integration.tsindex dbbd7848a..6742d09af 100644--- a/apps/desktop/src/api/os-integration.ts+++ b/apps/desktop/src/api/os-integration.ts@@ -43,7 +43,6 @@ import { setupDesktopIntegration } from "../utils/desktop-integration";import { rm } from "fs/promises";import { disableCustomDns, enableCustomDns } from "../utils/custom-dns";import type { MenuItem as NNMenuItem } from "@notesnook/ui";-import { Resvg } from "@resvg/resvg-js";const t = initTRPC.create();@@ -241,20 +240,15 @@ export const osIntegrationRouter = t.router({showMenu: t.procedure.input(z.object({- menuItems: z.array(z.any()),- menuIconColor: z.string()+ menuItems: z.array(z.any())}))- .subscription(({ input: { menuItems, menuIconColor } }) =>+ .subscription(({ input: { menuItems } }) =>observable<string[]>((emit) => {const items = menuItems as NNMenuItem[];const menu = new Menu();for (const item of items) {- const menuItem = toMenuItem(- item,- (id) => emit.next(id),- menuIconColor- );+ const menuItem = toMenuItem(item, (id) => emit.next(id));if (menuItem) menu.append(menuItem);}if (menu.items.length > 0) menu.popup();@@ -269,7 +263,6 @@ export const osIntegrationRouter = t.router({function toMenuItem(item: NNMenuItem,onClick: (id: string[]) => void,- menuIconColor: string,parentKey?: string): MenuItem | undefined {switch (item.type) {@@ -281,12 +274,7 @@ function toMenuItem(const submenu = item.menu ? new Menu() : undefined;if (submenu && item.menu) {for (const subitem of item.menu.items) {- const subMenuItem = toMenuItem(- subitem,- onClick,- menuIconColor,- item.key- );+ const subMenuItem = toMenuItem(subitem, onClick, item.key);if (subMenuItem) submenu.append(subMenuItem);}}@@ -300,12 +288,6 @@ function toMenuItem(checked: item.isChecked,type: submenu ? "submenu" : item.isChecked ? "checkbox" : "normal",id: item.key,- icon: item.icon- ? svgPathToPng(- item.icon,- (item.styles?.icon?.color as string | undefined) || menuIconColor- )- : undefined,submenu,click: () => onClick(parentKey ? [parentKey, item.key] : [item.key]),accelerator: item.modifier?.replace("Mod", "CommandOrControl")@@ -313,22 +295,3 @@ function toMenuItem(}}}--function svgPathToPng(path: string, color?: string) {- const svg = Buffer.from(- `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" role="presentation" class="icon" style="stroke-width: 0px; stroke: ${- color || config.windowControlsIconColor- }; width: 14px; height: 14px;"><path d="${path}" style="fill: ${- color || config.windowControlsIconColor- };"></path></svg>`- );- const resvg = new Resvg(svg, {- fitTo: { mode: "width", value: 14 },- logLevel: "error",- font: {- loadSystemFonts: false- }- });- const pngData = resvg.render();- return nativeImage.createFromBuffer(pngData.asPng());-}diff --git a/apps/web/package-lock.json b/apps/web/package-lock.jsonindex a0d1ee26c..6e7c241dd 100644--- a/apps/web/package-lock.json+++ b/apps/web/package-lock.json@@ -43185,6 +43185,8 @@"dependencies": {"@lingui/core": "5.1.2","@notesnook/intl": "file:../../packages/intl",+ "@notesnook/ui": "file:../../packages/ui",+ "@resvg/resvg-js": "^2.6.2","@trpc/client": "10.45.2","@trpc/server": "10.45.2","better-sqlite3-multiple-ciphers": "11.9.1",diff --git a/apps/web/src/hooks/use-menu.ts b/apps/web/src/hooks/use-menu.tsindex 0d9d7b3c3..e48f56041 100644--- a/apps/web/src/hooks/use-menu.ts+++ b/apps/web/src/hooks/use-menu.ts@@ -21,7 +21,6 @@ import { create } from "zustand";import { shallow } from "zustand/shallow";import { MenuItem, PositionOptions } from "@notesnook/ui";import { desktop } from "../common/desktop-bridge";-import { useThemeEngineStore } from "@notesnook/theme";import { isMac } from "../utils/platform";type MenuOptions = {@@ -47,18 +46,14 @@ const useMenuStore = create<MenuStore>((set) => ({},open: async (items, options) => {if (IS_DESKTOP_APP && canShowNativeMenu(items) && isMac()) {- const serializedItems = await resolveMenuItems(items);- const scopes = useThemeEngineStore.getState().theme.scopes;- const menuIconColor =- scopes.contextMenu?.primary?.icon || scopes.base?.primary?.icon;+ const resolvedItems = await resolveMenuItems(items);desktop?.integration.showMenu.subscribe({- menuItems: JSON.parse(JSON.stringify(serializedItems)),- menuIconColor+ menuItems: JSON.parse(JSON.stringify(resolvedItems))},{onData(ids) {- findAndCallAction(serializedItems, ids);+ findAndCallAction(resolvedItems, ids);}});