├── .eslintrc.cjs ├── .github └── FUNDING.yml ├── .gitignore ├── LICENSE ├── README.md ├── assets ├── icon.icns ├── icon.ico └── icon.png ├── biome.json ├── components.json ├── forge.config.ts ├── package-lock.json ├── package.json ├── postcss.config.mjs ├── prettier.config.cjs ├── src ├── backend │ ├── api │ │ ├── index.ts │ │ └── utils │ │ │ └── parseCouchDbUrl.ts │ ├── db │ │ ├── index.ts │ │ └── utils │ │ │ ├── createIndexes.ts │ │ │ ├── syncDb.ts │ │ │ ├── tagsDesignDoc.ts │ │ │ └── trackChanges.ts │ ├── handlers.ts │ ├── menus │ │ ├── index.ts │ │ ├── noteCardContextMenu.ts │ │ ├── notebookContextMenu.ts │ │ ├── notebookSortContextMenu.ts │ │ ├── sortContextMenu.ts │ │ └── trashNoteCardContextMenu.ts │ ├── store │ │ └── index.ts │ └── window │ │ └── index.ts ├── frontend │ ├── App.tsx │ ├── components │ │ └── ui │ │ │ ├── SidebarButton.tsx │ │ │ ├── accordion.tsx │ │ │ ├── badge.tsx │ │ │ ├── button.tsx │ │ │ ├── dialog.tsx │ │ │ ├── form.tsx │ │ │ ├── input.tsx │ │ │ ├── label.tsx │ │ │ ├── radio-group.tsx │ │ │ ├── scroll-area-old.tsx │ │ │ ├── scroll-area.tsx │ │ │ ├── separator.tsx │ │ │ ├── sonner.tsx │ │ │ └── tooltip.tsx │ ├── features │ │ ├── editor │ │ │ ├── components │ │ │ │ ├── DummyEditor.tsx │ │ │ │ ├── Editor.tsx │ │ │ │ ├── EditorClickWrapper.tsx │ │ │ │ └── PublishDialog.tsx │ │ │ ├── hooks │ │ │ │ ├── useNote.ts │ │ │ │ ├── usePublish.ts │ │ │ │ └── useSaveNote.ts │ │ │ ├── index.ts │ │ │ ├── lexical │ │ │ │ ├── autolink │ │ │ │ │ └── AutoLinkPlugin.tsx │ │ │ │ ├── codeblock │ │ │ │ │ ├── CodeBlockPlugin.tsx │ │ │ │ │ └── MarkdownCodeBlockShortcutPlugin.tsx │ │ │ │ ├── customHashtag │ │ │ │ │ └── CustomHashtagPlugin.tsx │ │ │ │ ├── markdownImage │ │ │ │ │ ├── MarkdownImagePlugin.tsx │ │ │ │ │ ├── MarkdownImageShortcut.tsx │ │ │ │ │ ├── components │ │ │ │ │ │ └── MarkdownImageComponent.tsx │ │ │ │ │ ├── hooks │ │ │ │ │ │ ├── useImageInsertCommand.ts │ │ │ │ │ │ └── useMarkdownImagePaste.ts │ │ │ │ │ ├── nodes │ │ │ │ │ │ └── MarkdownImageNode.tsx │ │ │ │ │ └── transformers │ │ │ │ │ │ └── MarkdownImageTransformer.ts │ │ │ │ ├── onBlur │ │ │ │ │ └── OnBlurPlugin.tsx │ │ │ │ ├── onChangeDebounce │ │ │ │ │ └── OnChangeDebouncePlugin.tsx │ │ │ │ ├── onFocus │ │ │ │ │ └── OnFocus.tsx │ │ │ │ ├── scrollCenterCurrentLine │ │ │ │ │ └── ScrollCenterCurrentLinePlugin.tsx │ │ │ │ ├── tabFocus │ │ │ │ │ └── index.tsx │ │ │ │ ├── tabKey │ │ │ │ │ └── TabKeyPlugin.tsx │ │ │ │ ├── toolbar │ │ │ │ │ ├── ToolbarPlugin.tsx │ │ │ │ │ ├── constants.tsx │ │ │ │ │ └── hooks │ │ │ │ │ │ └── useKeybinds.ts │ │ │ │ └── youtube │ │ │ │ │ ├── YouTubeActions.tsx │ │ │ │ │ ├── YouTubeNode.tsx │ │ │ │ │ └── YouTubeTransformer.ts │ │ │ └── themes │ │ │ │ ├── DefaultTheme.css │ │ │ │ └── DefaultTheme.ts │ │ ├── notes │ │ │ ├── components │ │ │ │ ├── NoteCard.tsx │ │ │ │ ├── NoteList.tsx │ │ │ │ ├── NotesHeader.tsx │ │ │ │ └── NotesSearch.tsx │ │ │ ├── hooks │ │ │ │ ├── useCreateNote.ts │ │ │ │ └── useNotes.ts │ │ │ └── index.ts │ │ ├── settings │ │ │ ├── components │ │ │ │ ├── EditorSettings.tsx │ │ │ │ ├── LoginDialog.tsx │ │ │ │ ├── NotebookSettings.tsx │ │ │ │ ├── ProfileSettings.tsx │ │ │ │ ├── RelaySettings.tsx │ │ │ │ ├── Settings.tsx │ │ │ │ └── SyncSettings.tsx │ │ │ └── index.ts │ │ └── sidebar │ │ │ ├── components │ │ │ ├── AllNotesBtn.tsx │ │ │ ├── NewNotebookBtn.tsx │ │ │ ├── NotebookBtn.tsx │ │ │ ├── Notebooks.tsx │ │ │ ├── SidebarHeader.tsx │ │ │ ├── SidebarNav.tsx │ │ │ ├── Tag.tsx │ │ │ ├── Tags.tsx │ │ │ └── TrashNotesBtn.tsx │ │ │ └── index.ts │ ├── hooks │ │ ├── useAppFocus.ts │ │ ├── useEvents.ts │ │ ├── useNotebooks.ts │ │ ├── useSync.ts │ │ ├── useSyncConfig.ts │ │ └── useTags.ts │ ├── index.html │ ├── lib │ │ ├── markdown │ │ │ ├── extractHashtags.ts │ │ │ ├── getHashtagRegexString.ts │ │ │ ├── index.ts │ │ │ ├── parseContent.ts │ │ │ ├── parseTitle.ts │ │ │ ├── removeTitle.ts │ │ │ └── searchContent.ts │ │ ├── nostr │ │ │ ├── index.ts │ │ │ └── shortNpub.ts │ │ └── utils.ts │ ├── main.tsx │ ├── store │ │ └── index.ts │ └── styles │ │ └── globals.css ├── main.ts ├── preload.ts ├── renderer.ts └── types │ ├── Keys.ts │ ├── Note.ts │ ├── Notebook.ts │ └── Relay.ts ├── tsconfig.json ├── types.d.ts ├── webpack.main.config.ts ├── webpack.plugins.ts ├── webpack.renderer.config.ts └── webpack.rules.ts /.eslintrc.cjs: -------------------------------------------------------------------------------- 1 | /** @type {import("eslint").Linter.Config} */ 2 | const config = { 3 | root: true, 4 | parser: "@typescript-eslint/parser", 5 | parserOptions: { 6 | ecmaVersion: "latest", 7 | sourceType: "module", 8 | tsconfigRootDir: __dirname, 9 | projectService: true, 10 | }, 11 | 12 | plugins: ["@typescript-eslint", "react-hooks"], 13 | extends: [ 14 | "plugin:@typescript-eslint/recommended-type-checked", 15 | "plugin:@typescript-eslint/stylistic-type-checked", 16 | "plugin:import/electron", 17 | "plugin:react-hooks/recommended", 18 | ], 19 | rules: { 20 | // These opinionated rules are enabled in stylistic-type-checked above. 21 | // Feel free to reconfigure them to your own preference. 22 | "@typescript-eslint/no-empty-object-type": "off", 23 | "@typescript-eslint/array-type": "off", 24 | "@typescript-eslint/consistent-type-definitions": "off", 25 | "@typescript-eslint/prefer-nullish-coalescing": "warn", 26 | "@typescript-eslint/no-empty-function": "off", 27 | "@typescript-eslint/no-empty-interface": "off", 28 | // "@typescript-eslint/ban-ts-comment": "off", 29 | 30 | "@typescript-eslint/consistent-type-imports": [ 31 | "warn", 32 | { 33 | prefer: "type-imports", 34 | fixStyle: "inline-type-imports", 35 | }, 36 | ], 37 | "@typescript-eslint/no-unused-vars": ["warn", { argsIgnorePattern: "^_" }], 38 | "@typescript-eslint/require-await": "off", 39 | "@typescript-eslint/no-misused-promises": [ 40 | "error", 41 | { 42 | checksVoidReturn: { attributes: false }, 43 | }, 44 | ], 45 | }, 46 | }; 47 | 48 | // eslint-disable-next-line 49 | module.exports = config; 50 | -------------------------------------------------------------------------------- /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | # These are supported funding model platforms 2 | github: [nodetec, christianchiarulli, jchiarulli] 3 | patreon: chrisatmachine 4 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Logs 2 | logs 3 | *.log 4 | npm-debug.log* 5 | yarn-debug.log* 6 | yarn-error.log* 7 | lerna-debug.log* 8 | 9 | # Diagnostic reports (https://nodejs.org/api/report.html) 10 | report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json 11 | 12 | # Runtime data 13 | pids 14 | *.pid 15 | *.seed 16 | *.pid.lock 17 | .DS_Store 18 | 19 | # Directory for instrumented libs generated by jscoverage/JSCover 20 | lib-cov 21 | 22 | # Coverage directory used by tools like istanbul 23 | coverage 24 | *.lcov 25 | 26 | # nyc test coverage 27 | .nyc_output 28 | 29 | # node-waf configuration 30 | .lock-wscript 31 | 32 | # Compiled binary addons (https://nodejs.org/api/addons.html) 33 | build/Release 34 | 35 | # Dependency directories 36 | node_modules/ 37 | jspm_packages/ 38 | 39 | # TypeScript v1 declaration files 40 | typings/ 41 | 42 | # TypeScript cache 43 | *.tsbuildinfo 44 | 45 | # Optional npm cache directory 46 | .npm 47 | 48 | # Optional eslint cache 49 | .eslintcache 50 | 51 | # Optional REPL history 52 | .node_repl_history 53 | 54 | # Output of 'npm pack' 55 | *.tgz 56 | 57 | # Yarn Integrity file 58 | .yarn-integrity 59 | 60 | # dotenv environment variables file 61 | .env 62 | .env.test 63 | 64 | # parcel-bundler cache (https://parceljs.org/) 65 | .cache 66 | 67 | # next.js build output 68 | .next 69 | 70 | # nuxt.js build output 71 | .nuxt 72 | 73 | # vuepress build output 74 | .vuepress/dist 75 | 76 | # Serverless directories 77 | .serverless/ 78 | 79 | # FuseBox cache 80 | .fusebox/ 81 | 82 | # DynamoDB Local files 83 | .dynamodb/ 84 | 85 | # Webpack 86 | .webpack/ 87 | 88 | # Vite 89 | .vite/ 90 | 91 | # Electron-Forge 92 | out/ 93 | 94 | # PouchDB 95 | pouchdb-server -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2025 NODE-TEC 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # ☄️ Comet 2 | 3 | ![comet](https://private-user-images.githubusercontent.com/29136904/423198103-0b77558c-83db-46da-9567-6c4cdbcd0a62.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3NDIxMTQ1MDgsIm5iZiI6MTc0MjExNDIwOCwicGF0aCI6Ii8yOTEzNjkwNC80MjMxOTgxMDMtMGI3NzU1OGMtODNkYi00NmRhLTk1NjctNmM0Y2RiY2QwYTYyLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNTAzMTYlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjUwMzE2VDA4MzY0OFomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPWJjNWE0Mjk5ODIwM2U2MzM0MmM5NGI1MTQ2YjRiYjJkNDgwMjgwYTk1YzY1Y2IzYzU4MDExN2ExZmUxNTg1M2EmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0In0.WQYJ3Ew45E1Vr9AH_PZi-0ukNiDJ7Uc9MzUEc8Q-tpk) 4 | 5 | Comet is a desktop app for taking and publishing notes for nostr. 6 | 7 | ## Development 8 | 9 | ### Install Dependencies 10 | 11 | ```sh 12 | npm i --force 13 | ``` 14 | 15 | ### Run the app 16 | 17 | ```sh 18 | npm run dev 19 | ``` 20 | 21 | ### Package the app 22 | 23 | ```sh 24 | npm run package 25 | ``` 26 | 27 | ## Make the app for your platform 28 | 29 | ### Linux Dependencies 30 | 31 | For RPM 32 | 33 | ```sh 34 | sudo apt install rpm 35 | ``` 36 | 37 | For AppImage 38 | 39 | ```sh 40 | sudo apt install squashfs-tools 41 | ``` 42 | 43 | ```sh 44 | npm run make 45 | ``` 46 | 47 | 48 | 49 | The output for you platform will be in the `out/` directory 50 | 51 | ## Tech Stack 52 | 53 | - electron (desktop app framework) 54 | - nostr (social media protocol) 55 | - shadcn (components) 56 | - nodejs (backend) 57 | - react (frontend) 58 | - pouchdb (database) 59 | - tailwind (styling) 60 | - typescript (language) 61 | - tanstack query (async state) 62 | - zustand (sync state) 63 | - lexical (editor) 64 | -------------------------------------------------------------------------------- /assets/icon.icns: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nodetec/comet/d0867b73ff8f2df69564aef5bdf9b15d80e2451e/assets/icon.icns -------------------------------------------------------------------------------- /assets/icon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nodetec/comet/d0867b73ff8f2df69564aef5bdf9b15d80e2451e/assets/icon.ico -------------------------------------------------------------------------------- /assets/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nodetec/comet/d0867b73ff8f2df69564aef5bdf9b15d80e2451e/assets/icon.png -------------------------------------------------------------------------------- /biome.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://biomejs.dev/schemas/1.9.4/schema.json", 3 | "vcs": { 4 | "enabled": true, 5 | "clientKind": "git", 6 | "useIgnoreFile": true 7 | }, 8 | "files": { "ignoreUnknown": false, "ignore": [] }, 9 | "formatter": { "enabled": true, "indentStyle": "space" }, 10 | "organizeImports": { "enabled": true }, 11 | "linter": { 12 | "enabled": true, 13 | "rules": { 14 | "style": { 15 | "noNonNullAssertion": "off" 16 | }, 17 | "a11y": { 18 | "useKeyWithClickEvents": "off" 19 | }, 20 | "suspicious": { 21 | "noArrayIndexKey": "off" 22 | }, 23 | "complexity": { 24 | "noBannedTypes": "off" 25 | }, 26 | "correctness": { 27 | "noUnusedImports": "warn", 28 | "useHookAtTopLevel": "error" 29 | }, 30 | "nursery": { 31 | "useSortedClasses": { 32 | "level": "warn", 33 | "fix": "safe", 34 | "options": { 35 | "functions": ["clsx", "cva", "cn"] 36 | } 37 | } 38 | }, 39 | "recommended": true 40 | } 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /components.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://ui.shadcn.com/schema.json", 3 | "style": "new-york", 4 | "rsc": false, 5 | "tsx": true, 6 | "tailwind": { 7 | "config": "", 8 | "css": "src/frontend/styles/globals.css", 9 | "baseColor": "neutral", 10 | "cssVariables": true, 11 | "prefix": "" 12 | }, 13 | "aliases": { 14 | "components": "~/components", 15 | "utils": "~/lib/utils", 16 | "ui": "~/components/ui", 17 | "lib": "~/lib", 18 | "hooks": "~/hooks" 19 | }, 20 | "iconLibrary": "lucide" 21 | } 22 | -------------------------------------------------------------------------------- /forge.config.ts: -------------------------------------------------------------------------------- 1 | import { MakerDeb } from "@electron-forge/maker-deb"; 2 | import { MakerRpm } from "@electron-forge/maker-rpm"; 3 | import { MakerSquirrel } from "@electron-forge/maker-squirrel"; 4 | import { AutoUnpackNativesPlugin } from "@electron-forge/plugin-auto-unpack-natives"; 5 | import { FusesPlugin } from "@electron-forge/plugin-fuses"; 6 | import { WebpackPlugin } from "@electron-forge/plugin-webpack"; 7 | import type { ForgeConfig } from "@electron-forge/shared-types"; 8 | import { FuseV1Options, FuseVersion } from "@electron/fuses"; 9 | import dotenv from "dotenv"; 10 | 11 | import { mainConfig } from "./webpack.main.config"; 12 | import { rendererConfig } from "./webpack.renderer.config"; 13 | 14 | // eslint-disable-next-line @typescript-eslint/no-unsafe-call, @typescript-eslint/no-unsafe-member-access 15 | dotenv.config({ path: "./.env" }); 16 | 17 | const config: ForgeConfig = { 18 | packagerConfig: { 19 | name: "Comet", 20 | icon: "./assets/icon", 21 | appBundleId: "org.nodetec.comet", 22 | executableName: "comet", 23 | asar: true, 24 | osxSign: { 25 | identity: process.env.APPLE_IDENTITY!, 26 | }, 27 | osxNotarize: { 28 | appleId: process.env.APPLE_ID!, 29 | appleIdPassword: process.env.APPLE_PASSWORD!, 30 | teamId: process.env.APPLE_TEAM_ID!, 31 | }, 32 | }, 33 | rebuildConfig: {}, 34 | makers: [ 35 | { 36 | name: "@electron-forge/maker-dmg", 37 | config: { 38 | name: "Comet", 39 | icon: "./assets/icon.icns", 40 | overwrite: true, 41 | format: "ULFO", 42 | }, 43 | }, 44 | { 45 | name: "@reforged/maker-appimage", 46 | config: { 47 | options: { 48 | categories: ["Publishing"], 49 | icon: "./assets/icon.png", 50 | bin: "comet", 51 | genericName: "Comet", 52 | name: "Comet", 53 | productName: "Comet", 54 | }, 55 | }, 56 | }, 57 | new MakerSquirrel({}), 58 | new MakerRpm({ 59 | options: { 60 | name: "comet", 61 | productName: "Comet", 62 | icon: "./assets/icon.png", 63 | categories: ["Utility"], 64 | genericName: "Comet", 65 | bin: "comet", 66 | productDescription: "Comet - A note-taking application", 67 | homepage: "https://comet.md", 68 | }, 69 | }), 70 | new MakerDeb({ 71 | options: { 72 | name: "comet", 73 | productName: "Comet", 74 | icon: "./assets/icon.png", 75 | categories: ["Utility"], 76 | genericName: "Comet", 77 | bin: "comet", 78 | productDescription: "Comet - A note-taking application", 79 | homepage: "https://comet.md", 80 | }, 81 | }), 82 | ], 83 | plugins: [ 84 | new AutoUnpackNativesPlugin({}), 85 | new WebpackPlugin({ 86 | mainConfig, 87 | devContentSecurityPolicy: "", 88 | renderer: { 89 | config: rendererConfig, 90 | entryPoints: [ 91 | { 92 | html: "./src/frontend/index.html", 93 | js: "./src/renderer.ts", 94 | name: "main_window", 95 | preload: { 96 | js: "./src/preload.ts", 97 | }, 98 | }, 99 | ], 100 | }, 101 | }), 102 | // Fuses are used to enable/disable various Electron functionality 103 | // at package time, before code signing the application 104 | new FusesPlugin({ 105 | version: FuseVersion.V1, 106 | [FuseV1Options.RunAsNode]: false, 107 | [FuseV1Options.EnableCookieEncryption]: true, 108 | [FuseV1Options.EnableNodeOptionsEnvironmentVariable]: false, 109 | [FuseV1Options.EnableNodeCliInspectArguments]: false, 110 | [FuseV1Options.EnableEmbeddedAsarIntegrityValidation]: true, 111 | [FuseV1Options.OnlyLoadAppFromAsar]: true, 112 | }), 113 | ], 114 | }; 115 | 116 | export default config; 117 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "comet", 3 | "productName": "comet", 4 | "version": "1.0.0", 5 | "description": "Capture locally transmit globally", 6 | "main": ".webpack/main", 7 | "scripts": { 8 | "dev": "electron-forge start", 9 | "package": "electron-forge package", 10 | "make": "electron-forge make", 11 | "publish": "electron-forge publish", 12 | "lint": "eslint --ext .ts,.tsx .", 13 | "server": "pouchdb-server --dir ./pouchdb-server --port 5984" 14 | }, 15 | "keywords": [], 16 | "author": { 17 | "name": "Christian Chiarulli", 18 | "email": "chris.machine@pm.me" 19 | }, 20 | "license": "MIT", 21 | "devDependencies": { 22 | "@electron-forge/cli": "^7.8.0", 23 | "@electron-forge/maker-deb": "^7.8.0", 24 | "@electron-forge/maker-dmg": "^7.8.0", 25 | "@electron-forge/maker-rpm": "^7.8.0", 26 | "@electron-forge/maker-squirrel": "^7.8.0", 27 | "@electron-forge/maker-zip": "^7.8.0", 28 | "@electron-forge/plugin-auto-unpack-natives": "^7.8.0", 29 | "@electron-forge/plugin-fuses": "^7.8.0", 30 | "@electron-forge/plugin-webpack": "^7.8.0", 31 | "@electron/fuses": "^1.8.0", 32 | "@ianvs/prettier-plugin-sort-imports": "^4.4.1", 33 | "@reforged/maker-appimage": "^5.0.0", 34 | "@tanstack/eslint-plugin-query": "^5.71.5", 35 | "@types/crypto-pouch": "^4.0.4", 36 | "@types/pouchdb": "^6.4.2", 37 | "@types/react": "^19.1.0", 38 | "@types/react-copy-to-clipboard": "^5.0.7", 39 | "@types/react-dom": "^19.1.1", 40 | "@types/react-highlight-words": "^0.20.0", 41 | "@typescript-eslint/eslint-plugin": "^8.29.0", 42 | "@typescript-eslint/parser": "^8.29.0", 43 | "@vercel/webpack-asset-relocator-loader": "1.7.3", 44 | "babel-plugin-react-compiler": "^19.0.0-beta-e552027-20250112", 45 | "css-loader": "^7.1.2", 46 | "dotenv": "^16.4.7", 47 | "electron": "35.1.4", 48 | "eslint": "^8.57.1", 49 | "eslint-plugin-import": "^2.31.0", 50 | "eslint-plugin-prettier": "^5.2.6", 51 | "eslint-plugin-react": "^7.37.5", 52 | "eslint-plugin-react-compiler": "^19.0.0-beta-e552027-20250112", 53 | "eslint-plugin-react-hooks": "^5.2.0", 54 | "eslint-plugin-react-refresh": "^0.4.19", 55 | "fork-ts-checker-webpack-plugin": "^9.1.0", 56 | "node-loader": "^2.1.0", 57 | "postcss-loader": "^8.1.1", 58 | "prettier": "^3.5.3", 59 | "prettier-plugin-tailwindcss": "^0.6.11", 60 | "react-compiler-webpack": "^0.2.0", 61 | "style-loader": "^4.0.0", 62 | "ts-loader": "^9.5.2", 63 | "ts-node": "^10.9.2", 64 | "typescript": "~5.8.3", 65 | "typescript-eslint": "^8.29.0" 66 | }, 67 | "dependencies": { 68 | "@column-resizer/react": "^1.3.1", 69 | "@hookform/resolvers": "^4.1.3", 70 | "@lexical/react": "^0.27.2", 71 | "@radix-ui/react-accordion": "^1.2.3", 72 | "@radix-ui/react-dialog": "^1.1.6", 73 | "@radix-ui/react-label": "^2.1.2", 74 | "@radix-ui/react-radio-group": "^1.2.3", 75 | "@radix-ui/react-scroll-area": "^1.2.3", 76 | "@radix-ui/react-separator": "^1.1.2", 77 | "@radix-ui/react-slot": "^1.1.2", 78 | "@radix-ui/react-tooltip": "^1.1.8", 79 | "@radix-ui/react-visually-hidden": "^1.1.2", 80 | "@tailwindcss/postcss": "^4.1.3", 81 | "@tanstack/react-query": "^5.71.10", 82 | "@tanstack/react-query-devtools": "^5.71.10", 83 | "@uidotdev/usehooks": "^2.4.1", 84 | "class-variance-authority": "^0.7.1", 85 | "clsx": "^2.1.1", 86 | "crypto-pouch": "^4.0.2", 87 | "dayjs": "^1.11.13", 88 | "electron-context-menu": "^4.0.5", 89 | "electron-drag-click": "^1.0.6", 90 | "electron-is-dev": "^3.0.1", 91 | "electron-squirrel-startup": "^1.0.1", 92 | "electron-store": "8.2.0", 93 | "lexical": "^0.27.2", 94 | "lucide-react": "^0.487.0", 95 | "next-themes": "^0.4.6", 96 | "nostr-tools": "^2.12.0", 97 | "postcss": "^8.5.3", 98 | "pouchdb": "^9.0.0", 99 | "pouchdb-find": "^9.0.0", 100 | "react": "^19.1.0", 101 | "react-copy-to-clipboard": "^5.1.0", 102 | "react-dom": "^19.1.0", 103 | "react-highlight-words": "^0.21.0", 104 | "react-hook-form": "^7.55.0", 105 | "react-intersection-observer": "^9.16.0", 106 | "sonner": "^2.0.3", 107 | "sqlite3": "^5.1.7", 108 | "tailwind-merge": "^3.1.0", 109 | "tailwindcss": "^4.1.3", 110 | "tailwindcss-animate": "^1.0.7", 111 | "uuid": "^11.1.0", 112 | "zod": "^3.24.2", 113 | "zustand": "^5.0.3" 114 | } 115 | } 116 | -------------------------------------------------------------------------------- /postcss.config.mjs: -------------------------------------------------------------------------------- 1 | export default { 2 | plugins: { 3 | "@tailwindcss/postcss": {}, 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /prettier.config.cjs: -------------------------------------------------------------------------------- 1 | /** @type {import('prettier').Config} */ 2 | module.exports = { 3 | importOrder: [ 4 | "", 5 | "", 6 | "", 7 | "^react$", 8 | "", 9 | "", 10 | "", 11 | "^[.]", 12 | ], 13 | importOrderParserPlugins: ["typescript", "jsx", "decorators-legacy"], 14 | importOrderTypeScriptVersion: "5.0.0", 15 | plugins: [ 16 | "@ianvs/prettier-plugin-sort-imports", 17 | "prettier-plugin-tailwindcss", 18 | ], 19 | }; 20 | -------------------------------------------------------------------------------- /src/backend/api/utils/parseCouchDbUrl.ts: -------------------------------------------------------------------------------- 1 | export function parseCouchDbUrl(urlString: string) { 2 | try { 3 | // Create a URL object from the input string 4 | const url = new URL(urlString); 5 | 6 | // Construct the URL without credentials using protocol, host, and pathname 7 | const urlWithoutCredentials = url.protocol + "//" + url.host + url.pathname; 8 | 9 | // Return an object with the URL, username, and password 10 | return { 11 | url: urlWithoutCredentials, 12 | username: url.username, 13 | password: url.password, 14 | }; 15 | } catch (error) { 16 | if (error instanceof Error) { 17 | throw new Error(`Invalid CouchDB URL: ${error.message}`); 18 | } else { 19 | throw new Error("Invalid CouchDB URL: Unknown error"); 20 | } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /src/backend/db/utils/createIndexes.ts: -------------------------------------------------------------------------------- 1 | // when we need to update indexex, just get thema all delete them if 2 | // they match the old name and create a new with with a new name 3 | // version names like note-index-v1, note-index-v2, etc 4 | export function createIndexes(db: PouchDB.Database) { 5 | return Promise.all([ 6 | db.createIndex({ 7 | index: { 8 | fields: ["editedAt", "type", "trashedAt", "notebookId", "tags"], 9 | name: "note-index-editedAt", 10 | }, 11 | }), 12 | db.createIndex({ 13 | index: { 14 | fields: ["createdAt", "type", "trashedAt", "notebookId", "tags"], 15 | name: "note-index-createdAt", 16 | }, 17 | }), 18 | db.createIndex({ 19 | index: { 20 | fields: ["title", "type", "trashedAt", "notebookId", "tags"], 21 | name: "note-index-title", 22 | }, 23 | }), 24 | db.createIndex({ 25 | index: { 26 | fields: ["editedAt", "type", "trashedAt", "tags"], 27 | name: "note-index-editedAt-all", 28 | }, 29 | }), 30 | db.createIndex({ 31 | index: { 32 | fields: ["createdAt", "type", "trashedAt", "tags"], 33 | name: "note-index-createdAt-all", 34 | }, 35 | }), 36 | db.createIndex({ 37 | index: { 38 | fields: ["title", "type", "trashedAt", "tags"], 39 | name: "note-index-title-all", 40 | }, 41 | }), 42 | db.createIndex({ 43 | index: { 44 | fields: ["tags"], 45 | name: "note-tags-index", 46 | }, 47 | }), 48 | db.createIndex({ 49 | index: { 50 | fields: ["name", "type", "hidden"], 51 | name: "notebook-name-index", 52 | }, 53 | }), 54 | ]); 55 | } 56 | -------------------------------------------------------------------------------- /src/backend/db/utils/syncDb.ts: -------------------------------------------------------------------------------- 1 | import { parseCouchDbUrl } from "&/api/utils/parseCouchDbUrl"; 2 | import { getWindow } from "&/window"; 3 | import PouchDB from "pouchdb"; 4 | 5 | import { getDb, setSync } from ".."; 6 | 7 | export function sync(remoteUrl: string) { 8 | const db = getDb(); 9 | const mainWindow = getWindow(); 10 | let dbUrl = remoteUrl; 11 | let dbUsername = ""; 12 | let dbPassword = ""; 13 | 14 | // If remoteUrl contains authentication info, parse it 15 | if (remoteUrl.includes("@")) { 16 | const parsed = parseCouchDbUrl(remoteUrl); 17 | dbUrl = parsed.url; 18 | dbUsername = parsed.username; 19 | dbPassword = parsed.password; 20 | } 21 | 22 | const remoteDB = new PouchDB(dbUrl, { 23 | auth: { 24 | username: dbUsername, 25 | password: dbPassword, 26 | }, 27 | }); 28 | 29 | // console.log("remoteDB", remoteDB); 30 | // console.log("db", db); 31 | // console.log("mainWindow", mainWindow); 32 | // console.log("dbUrl", dbUrl); 33 | // console.log("dbUsername", dbUsername); 34 | // console.log("dbPassword", dbPassword); 35 | 36 | const sync = db 37 | .sync(remoteDB, { 38 | live: true, 39 | retry: true, 40 | }) 41 | .on("change", function (change) { 42 | console.log("sync change", change); 43 | if (change.direction === "pull") { 44 | console.log("pull change", change); 45 | mainWindow.webContents.send("sync", change); 46 | } 47 | }) 48 | .on("error", function (err) { 49 | console.error("sync error", err); 50 | }); 51 | 52 | console.log("sync", sync); 53 | 54 | setSync(sync); 55 | } 56 | -------------------------------------------------------------------------------- /src/backend/db/utils/tagsDesignDoc.ts: -------------------------------------------------------------------------------- 1 | const designDoc = { 2 | _id: "_design/tags", 3 | views: { 4 | allTags: { 5 | map: `function(doc) { 6 | if (doc.type === "note" && doc.tags && Array.isArray(doc.tags)) { 7 | doc.tags.forEach(function(tag) { 8 | emit(tag, null); 9 | }); 10 | } 11 | }`, 12 | reduce: "_count", 13 | }, 14 | tagsByNotebook: { 15 | map: `function(doc) { 16 | if (doc.type === "note" && doc.notebookId && doc.tags && Array.isArray(doc.tags)) { 17 | doc.tags.forEach(function(tag) { 18 | emit([doc.notebookId, tag], null); 19 | }); 20 | } 21 | }`, 22 | reduce: "_count", 23 | }, 24 | }, 25 | }; 26 | 27 | export async function setupDesignDoc(db: PouchDB.Database) { 28 | try { 29 | await db.put(designDoc); 30 | console.log("Design document created."); 31 | } catch (err) { 32 | // TODO: fix this type 33 | // eslint-disable-next-line @typescript-eslint/ban-ts-comment 34 | // @ts-expect-error 35 | if (err.status !== 409) { 36 | // Ignore if it already exists 37 | console.error("Error creating design document:", err); 38 | throw err; 39 | } 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /src/backend/db/utils/trackChanges.ts: -------------------------------------------------------------------------------- 1 | export function trackChanges(db: PouchDB.Database) { 2 | void db 3 | .changes({ 4 | since: "now", 5 | live: true, 6 | include_docs: true, 7 | }) 8 | .on("change", (change) => { 9 | console.log("change", change); 10 | }); 11 | } 12 | -------------------------------------------------------------------------------- /src/backend/handlers.ts: -------------------------------------------------------------------------------- 1 | import { ipcMain } from "electron"; 2 | 3 | import * as api from "./api"; 4 | 5 | export function setupHandlers(): void { 6 | // notes 7 | ipcMain.handle("createNote", api.createNote); 8 | ipcMain.handle("getNoteFeed", api.getNoteFeed); 9 | ipcMain.handle("getNote", api.getNote); 10 | ipcMain.handle("saveNote", api.saveNote); 11 | ipcMain.handle("addPublishDetailsToNote", api.addPublishDetailsToNote); 12 | ipcMain.handle("searchNotes", api.searchNotes); 13 | 14 | // notebooks 15 | ipcMain.handle("createNotebook", api.createNotebook); 16 | ipcMain.handle("getNotebook", api.getNotebook); 17 | ipcMain.handle("getNotebooks", api.getNotebooks); 18 | ipcMain.handle("hideNotebook", api.hideNotebook); 19 | ipcMain.handle("unhideNotebook", api.unhideNotebook); 20 | ipcMain.handle("deleteNotebook", api.deleteNotebook); 21 | 22 | // tags 23 | ipcMain.handle("getAllTags", api.getAllTags); 24 | ipcMain.handle("getTagsByNotebookId", api.getTagsByNotebookId); 25 | 26 | // sync 27 | ipcMain.handle("syncDb", api.syncDb); 28 | ipcMain.handle("cancelSync", api.cancelSync); 29 | ipcMain.handle("getSyncConfig", api.getSyncConfig); 30 | 31 | // sort settings 32 | ipcMain.handle("getSortSettings", api.getSortSettings); 33 | ipcMain.handle("updateSortSettings", api.updateSortSettings); 34 | 35 | // window 36 | ipcMain.handle("toggleMaximize", api.toggleMaximize); 37 | } 38 | -------------------------------------------------------------------------------- /src/backend/menus/index.ts: -------------------------------------------------------------------------------- 1 | import contextMenu from "electron-context-menu"; 2 | 3 | import { setupNotebookContextMenu } from "./notebookContextMenu"; 4 | import { setupNoteCardContextMenu } from "./noteCardContextMenu"; 5 | import { setupSortContextMenu } from "./sortContextMenu"; 6 | import { setupNotebookSortContextMenu } from "./notebookSortContextMenu"; 7 | import { setupTrashNoteCardContextMenu } from "./trashNoteCardContextMenu"; 8 | 9 | export function setupContextMenus() { 10 | setupNoteCardContextMenu(); 11 | setupNotebookContextMenu(); 12 | setupTrashNoteCardContextMenu(); 13 | setupSortContextMenu(); 14 | setupNotebookSortContextMenu(); 15 | 16 | // Only setup default context menu if not on Linux 17 | if (process.platform !== "linux") { 18 | contextMenu({ 19 | showInspectElement: false, 20 | }); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /src/backend/menus/noteCardContextMenu.ts: -------------------------------------------------------------------------------- 1 | import { moveNoteToNotebook, moveNoteToTrash } from "&/api"; 2 | import { type Note } from "$/types/Note"; 3 | import { type Notebook } from "$/types/Notebook"; 4 | import { ipcMain, Menu } from "electron"; 5 | 6 | export function setupNoteCardContextMenu() { 7 | ipcMain.on( 8 | "noteCardContextMenu", 9 | (event, note: Note, notebooks: Notebook[]) => { 10 | console.log("Note card right clicked", note._id); 11 | 12 | const notebooksNoteDoesNotBelongTo = notebooks.filter( 13 | (notebook) => notebook._id !== note.notebookId, 14 | ); 15 | 16 | const currentNotebook = note.notebookId 17 | ? notebooks.find((n) => n._id === note.notebookId) 18 | : undefined; 19 | 20 | const template = [ 21 | { 22 | label: "Move To", 23 | submenu: notebooksNoteDoesNotBelongTo.map((notebook) => ({ 24 | label: notebook.name, 25 | click: async () => { 26 | await moveNoteToNotebook(event, note._id, notebook._id); 27 | event.sender.send("noteMovedToNotebook", note._id, notebook._id); 28 | }, 29 | })), 30 | }, 31 | { 32 | label: "Trash", 33 | click: async () => { 34 | await moveNoteToTrash(event, note._id); 35 | event.sender.send("noteMovedToTrash", note._id); 36 | }, 37 | }, 38 | ...(currentNotebook 39 | ? [ 40 | { 41 | label: `Remove from ${currentNotebook.name}`, 42 | click: async () => { 43 | await moveNoteToNotebook(event, note._id, undefined); 44 | event.sender.send("noteMovedToNotebook", note._id, ""); 45 | }, 46 | }, 47 | ] 48 | : []), 49 | ]; 50 | 51 | const menu = Menu.buildFromTemplate(template); 52 | 53 | console.log("menu", menu); 54 | 55 | menu.popup(); 56 | // menu.popup({ x: 100, y: 200 }); // use this later 57 | }, 58 | ); 59 | } 60 | -------------------------------------------------------------------------------- /src/backend/menus/notebookContextMenu.ts: -------------------------------------------------------------------------------- 1 | import { deleteNotebook, hideNotebook } from "&/api"; 2 | import { ipcMain, Menu } from "electron"; 3 | 4 | export function setupNotebookContextMenu() { 5 | ipcMain.on("notebookContextMenu", (event, notebookId: string) => { 6 | const template = [ 7 | { 8 | label: "Hide", 9 | click: async () => { 10 | await hideNotebook(event, notebookId); 11 | event.sender.send("notebookHidden", notebookId); 12 | }, 13 | }, 14 | { 15 | label: "Delete", 16 | click: async () => { 17 | await deleteNotebook(event, notebookId); 18 | event.sender.send("notebookDeleted", notebookId); 19 | }, 20 | }, 21 | ]; 22 | 23 | const menu = Menu.buildFromTemplate(template); 24 | 25 | menu.popup(); 26 | }); 27 | } 28 | -------------------------------------------------------------------------------- /src/backend/menus/notebookSortContextMenu.ts: -------------------------------------------------------------------------------- 1 | import { updateNotebook } from "&/api"; 2 | import type { Notebook } from "$/types/Notebook"; 3 | import { ipcMain, Menu, type MenuItemConstructorOptions } from "electron"; 4 | 5 | export function setupNotebookSortContextMenu() { 6 | ipcMain.on( 7 | "notebookSortContextMenu", 8 | (event, notebook: Notebook, x?: number, y?: number) => { 9 | const getCurrentSortOrder = () => { 10 | switch (notebook.sortBy) { 11 | case "createdAt": 12 | return notebook.createdAtSortOrder; 13 | case "editedAt": 14 | return notebook.editedAtSortOrder; 15 | case "title": 16 | return notebook.titleSortOrder; 17 | } 18 | }; 19 | 20 | const template: MenuItemConstructorOptions[] = [ 21 | { 22 | label: "Sort By", 23 | submenu: [ 24 | { 25 | label: "Date Edited", 26 | type: "checkbox", 27 | checked: notebook.sortBy === "editedAt", 28 | click: () => { 29 | void updateNotebook(event, { 30 | _id: notebook._id, 31 | sortBy: "editedAt", 32 | }).then((updatedNotebook) => { 33 | if (updatedNotebook) { 34 | event.sender.send( 35 | "notebookSortSettingsUpdated", 36 | updatedNotebook, 37 | ); 38 | } 39 | }); 40 | }, 41 | }, 42 | { 43 | label: "Date Created", 44 | type: "checkbox", 45 | checked: notebook.sortBy === "createdAt", 46 | click: () => { 47 | void updateNotebook(event, { 48 | _id: notebook._id, 49 | sortBy: "createdAt", 50 | }).then((updatedNotebook) => { 51 | if (updatedNotebook) { 52 | event.sender.send( 53 | "notebookSortSettingsUpdated", 54 | updatedNotebook, 55 | ); 56 | } 57 | }); 58 | }, 59 | }, 60 | { 61 | label: "Title", 62 | type: "checkbox", 63 | checked: notebook.sortBy === "title", 64 | click: () => { 65 | void updateNotebook(event, { 66 | _id: notebook._id, 67 | sortBy: "title", 68 | }).then((updatedNotebook) => { 69 | if (updatedNotebook) { 70 | event.sender.send( 71 | "notebookSortSettingsUpdated", 72 | updatedNotebook, 73 | ); 74 | } 75 | }); 76 | }, 77 | }, 78 | { type: "separator" }, 79 | 80 | { 81 | label: notebook.sortBy === "title" ? "A to Z" : "Newest First", 82 | type: "checkbox", 83 | checked: 84 | getCurrentSortOrder() === 85 | (notebook.sortBy === "title" ? "asc" : "desc"), 86 | click: () => { 87 | const update: Partial = { 88 | _id: notebook._id, 89 | }; 90 | switch (notebook.sortBy) { 91 | case "createdAt": 92 | update.createdAtSortOrder = "desc"; 93 | break; 94 | case "editedAt": 95 | update.editedAtSortOrder = "desc"; 96 | break; 97 | case "title": 98 | update.titleSortOrder = "asc"; 99 | break; 100 | } 101 | void updateNotebook(event, update).then((updatedNotebook) => { 102 | if (updatedNotebook) { 103 | event.sender.send( 104 | "notebookSortSettingsUpdated", 105 | updatedNotebook, 106 | ); 107 | } 108 | }); 109 | }, 110 | }, 111 | 112 | { 113 | label: notebook.sortBy === "title" ? "Z to A" : "Oldest First", 114 | type: "checkbox", 115 | checked: 116 | getCurrentSortOrder() === 117 | (notebook.sortBy === "title" ? "desc" : "asc"), 118 | click: () => { 119 | const update: Partial = { 120 | _id: notebook._id, 121 | }; 122 | switch (notebook.sortBy) { 123 | case "createdAt": 124 | update.createdAtSortOrder = "asc"; 125 | break; 126 | case "editedAt": 127 | update.editedAtSortOrder = "asc"; 128 | break; 129 | case "title": 130 | update.titleSortOrder = "desc"; 131 | break; 132 | } 133 | void updateNotebook(event, update).then((updatedNotebook) => { 134 | if (updatedNotebook) { 135 | event.sender.send( 136 | "notebookSortSettingsUpdated", 137 | updatedNotebook, 138 | ); 139 | } 140 | }); 141 | }, 142 | }, 143 | ], 144 | }, 145 | ]; 146 | 147 | const menu = Menu.buildFromTemplate(template); 148 | menu.popup({ 149 | x, 150 | y, 151 | }); 152 | }, 153 | ); 154 | } 155 | -------------------------------------------------------------------------------- /src/backend/menus/sortContextMenu.ts: -------------------------------------------------------------------------------- 1 | import { getSortSettings, updateSortSettings } from "&/api"; 2 | import { ipcMain, Menu, type MenuItemConstructorOptions } from "electron"; 3 | 4 | export function setupSortContextMenu() { 5 | ipcMain.on("sortContextMenu", (event, x?: number, y?: number) => { 6 | const sortSettings = getSortSettings(); 7 | 8 | const getCurrentSortOrder = () => { 9 | switch (sortSettings.sortBy) { 10 | case "createdAt": 11 | return sortSettings.createdAtSortOrder; 12 | case "editedAt": 13 | return sortSettings.editedAtSortOrder; 14 | case "title": 15 | return sortSettings.titleSortOrder; 16 | } 17 | }; 18 | 19 | const template: MenuItemConstructorOptions[] = [ 20 | { 21 | label: "Sort By", 22 | submenu: [ 23 | { 24 | label: "Date Edited", 25 | type: "checkbox", 26 | checked: sortSettings.sortBy === "editedAt", 27 | click: () => { 28 | void updateSortSettings( 29 | event, 30 | "editedAt", 31 | sortSettings.editedAtSortOrder, 32 | ); 33 | }, 34 | }, 35 | { 36 | label: "Date Created", 37 | type: "checkbox", 38 | checked: sortSettings.sortBy === "createdAt", 39 | click: () => { 40 | void updateSortSettings( 41 | event, 42 | "createdAt", 43 | sortSettings.createdAtSortOrder, 44 | ); 45 | }, 46 | }, 47 | { 48 | label: "Title", 49 | type: "checkbox", 50 | checked: sortSettings.sortBy === "title", 51 | click: () => { 52 | void updateSortSettings( 53 | event, 54 | "title", 55 | sortSettings.titleSortOrder, 56 | ); 57 | }, 58 | }, 59 | { type: "separator" }, 60 | { 61 | label: sortSettings.sortBy === "title" ? "A to Z" : "Newest First", 62 | type: "checkbox", 63 | checked: 64 | getCurrentSortOrder() === 65 | (sortSettings.sortBy === "title" ? "asc" : "desc"), 66 | click: () => { 67 | void updateSortSettings( 68 | event, 69 | sortSettings.sortBy, 70 | sortSettings.sortBy === "title" ? "asc" : "desc", 71 | ); 72 | }, 73 | }, 74 | { 75 | label: sortSettings.sortBy === "title" ? "Z to A" : "Oldest First", 76 | type: "checkbox", 77 | checked: 78 | getCurrentSortOrder() === 79 | (sortSettings.sortBy === "title" ? "desc" : "asc"), 80 | click: () => { 81 | void updateSortSettings( 82 | event, 83 | sortSettings.sortBy, 84 | sortSettings.sortBy === "title" ? "desc" : "asc", 85 | ); 86 | }, 87 | }, 88 | ], 89 | }, 90 | ]; 91 | 92 | const menu = Menu.buildFromTemplate(template); 93 | 94 | try { 95 | menu.popup({ 96 | x, 97 | y, 98 | }); 99 | } catch (error) { 100 | console.error("Error popping up sort context menu", error); 101 | } 102 | }); 103 | } 104 | -------------------------------------------------------------------------------- /src/backend/menus/trashNoteCardContextMenu.ts: -------------------------------------------------------------------------------- 1 | import { deleteNote, restoreNote } from "&/api"; 2 | import { ipcMain, Menu } from "electron"; 3 | 4 | export function setupTrashNoteCardContextMenu() { 5 | ipcMain.on("trashNoteCardContextMenu", (event, noteId: string) => { 6 | const template = [ 7 | { 8 | label: "Restore", 9 | click: async () => { 10 | await restoreNote(event, noteId); 11 | event.sender.send("noteRestored", noteId); 12 | }, 13 | }, 14 | { 15 | label: "Delete", 16 | click: async () => { 17 | await deleteNote(event, noteId); 18 | event.sender.send("noteDeleted", noteId); 19 | }, 20 | }, 21 | ]; 22 | 23 | const menu = Menu.buildFromTemplate(template); 24 | 25 | menu.popup(); 26 | }); 27 | } 28 | -------------------------------------------------------------------------------- /src/backend/store/index.ts: -------------------------------------------------------------------------------- 1 | import Store from "electron-store"; 2 | 3 | interface SyncConfig { 4 | remote: { 5 | url: string | undefined; 6 | }; 7 | method: "custom_sync" | "no_sync"; 8 | } 9 | 10 | interface StoreSchema { 11 | sync: SyncConfig; 12 | sortBy: "createdAt" | "editedAt" | "title"; 13 | createdAtSortOrder: "asc" | "desc"; 14 | editedAtSortOrder: "asc" | "desc"; 15 | titleSortOrder: "asc" | "desc"; 16 | } 17 | 18 | let store: Store; 19 | 20 | export const initStore = () => { 21 | store = new Store({ 22 | encryptionKey: "12345", 23 | clearInvalidConfig: true, 24 | schema: { 25 | sync: { 26 | type: "object", 27 | properties: { 28 | remote: { 29 | type: "object", 30 | properties: { 31 | url: { 32 | type: ["string", "null"], 33 | }, 34 | }, 35 | }, 36 | method: { 37 | type: "string", 38 | enum: ["custom_sync", "no_sync"], 39 | default: "no_sync", 40 | }, 41 | }, 42 | required: ["remote", "method"], 43 | default: { 44 | remote: { 45 | url: undefined, 46 | }, 47 | method: "no_sync", 48 | }, 49 | }, 50 | sortBy: { 51 | type: "string", 52 | enum: ["createdAt", "editedAt", "title"], 53 | default: "editedAt", 54 | }, 55 | createdAtSortOrder: { 56 | type: "string", 57 | enum: ["asc", "desc"], 58 | default: "desc", 59 | }, 60 | editedAtSortOrder: { 61 | type: "string", 62 | enum: ["asc", "desc"], 63 | default: "desc", 64 | }, 65 | titleSortOrder: { 66 | type: "string", 67 | enum: ["asc", "desc"], 68 | default: "asc", 69 | }, 70 | }, 71 | }); 72 | }; 73 | 74 | export const getStore = () => { 75 | return store; 76 | }; 77 | -------------------------------------------------------------------------------- /src/backend/window/index.ts: -------------------------------------------------------------------------------- 1 | import { type BrowserWindow } from "electron"; 2 | 3 | let mainWindow: BrowserWindow; 4 | 5 | export function setWindow(window: BrowserWindow) { 6 | mainWindow = window; 7 | } 8 | 9 | export function getWindow() { 10 | return mainWindow; 11 | } 12 | -------------------------------------------------------------------------------- /src/frontend/App.tsx: -------------------------------------------------------------------------------- 1 | import { Bar, Container, Section } from "@column-resizer/react"; 2 | import { useWindowSize } from "@uidotdev/usehooks"; 3 | 4 | import { Editor } from "./features/editor"; 5 | import { NotesHeader, NotesSearch } from "./features/notes"; 6 | import { NoteList } from "./features/notes/components/NoteList"; 7 | import { NewNotebookBtn, SidebarHeader, SidebarNav } from "./features/sidebar"; 8 | import useAppFocus from "./hooks/useAppFocus"; 9 | import { useEvents } from "./hooks/useEvents"; 10 | import { useSync } from "./hooks/useSync"; 11 | 12 | export default function ResizableLayout() { 13 | useAppFocus(); 14 | useEvents(); 15 | useSync(); 16 | const size = useWindowSize(); 17 | 18 | return ( 19 |
20 | 21 |
800 ? 200 : 180} 25 | minSize={180} 26 | maxSize={size.width! > 800 ? 300 : 180} 27 | > 28 | 29 | 30 | 31 |
32 | 37 |
800 ? 300 : 210} 43 | > 44 | 45 | 46 | 47 |
48 | 53 |
800 ? 300 : 210}> 54 |
55 | 56 |
57 |
58 |
59 |
60 | ); 61 | } 62 | -------------------------------------------------------------------------------- /src/frontend/components/ui/SidebarButton.tsx: -------------------------------------------------------------------------------- 1 | import React from "react"; 2 | 3 | import { cn } from "~/lib/utils"; 4 | 5 | interface SidebarButtonProps { 6 | onClick: () => void; 7 | onContextMenu?: ( 8 | event: React.MouseEvent, 9 | ) => void | Promise; 10 | isFocused: boolean; 11 | isActive: boolean; 12 | icon: React.ReactElement>; 13 | label: string; 14 | } 15 | 16 | export function SidebarButton({ 17 | onClick, 18 | onContextMenu, 19 | isFocused, 20 | isActive, 21 | icon, 22 | label, 23 | }: SidebarButtonProps) { 24 | return ( 25 |
35 | {React.cloneElement(icon, { 36 | className: cn( 37 | "h-4 w-4 text-primary shrink-0", 38 | isActive && "data-[focused=true]:text-secondary-foreground", 39 | ), 40 | })} 41 |
42 | {label} 43 |
44 |
45 | ); 46 | } 47 | -------------------------------------------------------------------------------- /src/frontend/components/ui/accordion.tsx: -------------------------------------------------------------------------------- 1 | import * as React from "react"; 2 | 3 | import * as AccordionPrimitive from "@radix-ui/react-accordion"; 4 | import { cn } from "~/lib/utils"; 5 | import { ChevronDownIcon } from "lucide-react"; 6 | 7 | function Accordion({ 8 | ...props 9 | }: React.ComponentProps) { 10 | return ; 11 | } 12 | 13 | function AccordionItem({ 14 | className, 15 | ...props 16 | }: React.ComponentProps) { 17 | return ( 18 | 23 | ); 24 | } 25 | 26 | function AccordionTrigger({ 27 | className, 28 | children, 29 | ...props 30 | }: React.ComponentProps) { 31 | return ( 32 | 33 | svg]:block [&>svg]:hidden [&[data-state=open]>svg]:rotate-180", 38 | className, 39 | )} 40 | {...props} 41 | > 42 | {children} 43 | 44 | 45 | 46 | ); 47 | } 48 | 49 | function AccordionContent({ 50 | className, 51 | children, 52 | ...props 53 | }: React.ComponentProps) { 54 | return ( 55 | 60 |
{children}
61 |
62 | ); 63 | } 64 | 65 | export { Accordion, AccordionItem, AccordionTrigger, AccordionContent }; 66 | -------------------------------------------------------------------------------- /src/frontend/components/ui/badge.tsx: -------------------------------------------------------------------------------- 1 | import * as React from "react" 2 | import { Slot } from "@radix-ui/react-slot" 3 | import { cva, type VariantProps } from "class-variance-authority" 4 | 5 | import { cn } from "~/lib/utils" 6 | 7 | const badgeVariants = cva( 8 | "inline-flex items-center justify-center rounded-md border px-2 py-0.5 text-xs font-medium w-fit whitespace-nowrap shrink-0 [&>svg]:size-3 gap-1 [&>svg]:pointer-events-none focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive transition-[color,box-shadow] overflow-hidden", 9 | { 10 | variants: { 11 | variant: { 12 | default: 13 | "border-transparent bg-primary text-primary-foreground [a&]:hover:bg-primary/90", 14 | secondary: 15 | "border-transparent bg-secondary text-secondary-foreground [a&]:hover:bg-secondary/90", 16 | accent: 17 | "border-transparent bg-accent text-accent-foreground [a&]:hover:bg-accent/90", 18 | destructive: 19 | "border-transparent bg-destructive text-white [a&]:hover:bg-destructive/90 focus-visible:ring-destructive/20 dark:focus-visible:ring-destructive/40", 20 | outline: 21 | "text-foreground [a&]:hover:bg-accent [a&]:hover:text-accent-foreground", 22 | }, 23 | }, 24 | defaultVariants: { 25 | variant: "default", 26 | }, 27 | } 28 | ) 29 | 30 | function Badge({ 31 | className, 32 | variant, 33 | asChild = false, 34 | ...props 35 | }: React.ComponentProps<"span"> & 36 | VariantProps & { asChild?: boolean }) { 37 | const Comp = asChild ? Slot : "span" 38 | 39 | return ( 40 | 45 | ) 46 | } 47 | 48 | export { Badge, badgeVariants } 49 | -------------------------------------------------------------------------------- /src/frontend/components/ui/button.tsx: -------------------------------------------------------------------------------- 1 | import * as React from "react" 2 | import { Slot } from "@radix-ui/react-slot" 3 | import { cva, type VariantProps } from "class-variance-authority" 4 | 5 | import { cn } from "~/lib/utils" 6 | 7 | const buttonVariants = cva( 8 | "non-draggable inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-0 disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-[1.2rem] [&_svg]:shrink-0 cursor-default", 9 | { 10 | variants: { 11 | variant: { 12 | default: 13 | "bg-primary/60 text-primary-foreground shadow-xs hover:bg-primary/70", 14 | destructive: 15 | "bg-destructive text-white shadow-xs hover:bg-destructive/90 focus-visible:ring-destructive/20 dark:focus-visible:ring-destructive/40", 16 | outline: 17 | "border border-input bg-background shadow-xs hover:bg-accent hover:text-accent-foreground", 18 | secondary: 19 | "bg-secondary text-secondary-foreground shadow-xs hover:bg-secondary/80", 20 | ghost: "text-muted-foreground hover:bg-accent hover:text-accent-foreground data-[active=true]:bg-blue-500/50", 21 | sidebar: "text-secondary-foreground hover:bg-accent hover:text-accent-foreground", 22 | link: "text-primary underline-offset-4 hover:underline", 23 | }, 24 | size: { 25 | default: "h-9 px-4 py-2 has-[>svg]:px-3", 26 | sm: "h-8 rounded-md gap-1.5 px-3 has-[>svg]:px-2.5", 27 | lg: "h-10 rounded-md px-6 has-[>svg]:px-4", 28 | icon: "size-9", 29 | }, 30 | }, 31 | defaultVariants: { 32 | variant: "default", 33 | size: "default", 34 | }, 35 | } 36 | ) 37 | 38 | function Button({ 39 | className, 40 | variant, 41 | size, 42 | asChild = false, 43 | ...props 44 | }: React.ComponentProps<"button"> & 45 | VariantProps & { 46 | asChild?: boolean 47 | }) { 48 | const Comp = asChild ? Slot : "button" 49 | 50 | return ( 51 | 56 | ) 57 | } 58 | 59 | export { Button, buttonVariants } 60 | -------------------------------------------------------------------------------- /src/frontend/components/ui/dialog.tsx: -------------------------------------------------------------------------------- 1 | import * as React from "react"; 2 | 3 | import * as DialogPrimitive from "@radix-ui/react-dialog"; 4 | import { cn } from "~/lib/utils"; 5 | import { XIcon } from "lucide-react"; 6 | 7 | function Dialog({ 8 | ...props 9 | }: React.ComponentProps) { 10 | return ; 11 | } 12 | 13 | function DialogTrigger({ 14 | ...props 15 | }: React.ComponentProps) { 16 | return ; 17 | } 18 | 19 | function DialogPortal({ 20 | ...props 21 | }: React.ComponentProps) { 22 | return ; 23 | } 24 | 25 | function DialogClose({ 26 | ...props 27 | }: React.ComponentProps) { 28 | return ; 29 | } 30 | 31 | function DialogOverlay({ 32 | className, 33 | ...props 34 | }: React.ComponentProps) { 35 | return ( 36 | 44 | ); 45 | } 46 | 47 | function DialogContent({ 48 | className, 49 | children, 50 | ...props 51 | }: React.ComponentProps) { 52 | return ( 53 | 54 | 55 | 64 | {children} 65 | 66 | 67 | Close 68 | 69 | 70 | 71 | ); 72 | } 73 | 74 | function DialogHeader({ className, ...props }: React.ComponentProps<"div">) { 75 | return ( 76 |
81 | ); 82 | } 83 | 84 | function DialogFooter({ className, ...props }: React.ComponentProps<"div">) { 85 | return ( 86 |
94 | ); 95 | } 96 | 97 | function DialogTitle({ 98 | className, 99 | ...props 100 | }: React.ComponentProps) { 101 | return ( 102 | 107 | ); 108 | } 109 | 110 | function DialogDescription({ 111 | className, 112 | ...props 113 | }: React.ComponentProps) { 114 | return ( 115 | 120 | ); 121 | } 122 | 123 | export { 124 | Dialog, 125 | DialogClose, 126 | DialogContent, 127 | DialogDescription, 128 | DialogFooter, 129 | DialogHeader, 130 | DialogOverlay, 131 | DialogPortal, 132 | DialogTitle, 133 | DialogTrigger, 134 | }; 135 | -------------------------------------------------------------------------------- /src/frontend/components/ui/form.tsx: -------------------------------------------------------------------------------- 1 | import * as React from "react" 2 | import * as LabelPrimitive from "@radix-ui/react-label" 3 | import { Slot } from "@radix-ui/react-slot" 4 | import { 5 | Controller, 6 | FormProvider, 7 | useFormContext, 8 | useFormState, 9 | type ControllerProps, 10 | type FieldPath, 11 | type FieldValues, 12 | } from "react-hook-form" 13 | 14 | import { cn } from "~/lib/utils" 15 | import { Label } from "~/components/ui/label" 16 | 17 | const Form = FormProvider 18 | 19 | type FormFieldContextValue< 20 | TFieldValues extends FieldValues = FieldValues, 21 | TName extends FieldPath = FieldPath, 22 | > = { 23 | name: TName 24 | } 25 | 26 | const FormFieldContext = React.createContext( 27 | {} as FormFieldContextValue 28 | ) 29 | 30 | const FormField = < 31 | TFieldValues extends FieldValues = FieldValues, 32 | TName extends FieldPath = FieldPath, 33 | >({ 34 | ...props 35 | }: ControllerProps) => { 36 | return ( 37 | 38 | 39 | 40 | ) 41 | } 42 | 43 | const useFormField = () => { 44 | const fieldContext = React.useContext(FormFieldContext) 45 | const itemContext = React.useContext(FormItemContext) 46 | const { getFieldState } = useFormContext() 47 | const formState = useFormState({ name: fieldContext.name }) 48 | const fieldState = getFieldState(fieldContext.name, formState) 49 | 50 | if (!fieldContext) { 51 | throw new Error("useFormField should be used within ") 52 | } 53 | 54 | const { id } = itemContext 55 | 56 | return { 57 | id, 58 | name: fieldContext.name, 59 | formItemId: `${id}-form-item`, 60 | formDescriptionId: `${id}-form-item-description`, 61 | formMessageId: `${id}-form-item-message`, 62 | ...fieldState, 63 | } 64 | } 65 | 66 | type FormItemContextValue = { 67 | id: string 68 | } 69 | 70 | const FormItemContext = React.createContext( 71 | {} as FormItemContextValue 72 | ) 73 | 74 | function FormItem({ className, ...props }: React.ComponentProps<"div">) { 75 | const id = React.useId() 76 | 77 | return ( 78 | 79 |
84 | 85 | ) 86 | } 87 | 88 | function FormLabel({ 89 | className, 90 | ...props 91 | }: React.ComponentProps) { 92 | const { error, formItemId } = useFormField() 93 | 94 | return ( 95 |