From b7615304dad11d1d114c35e4bf75d53ee43ca9aa Mon Sep 17 00:00:00 2001 From: HoaX7 Date: Mon, 16 Sep 2024 17:57:05 +0530 Subject: [PATCH 01/57] fix: build fix --- app/src-tauri/tauri.conf.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src-tauri/tauri.conf.json b/app/src-tauri/tauri.conf.json index c25347e..5d18c63 100644 --- a/app/src-tauri/tauri.conf.json +++ b/app/src-tauri/tauri.conf.json @@ -74,7 +74,7 @@ "updater": { "active": true, "dialog": true, - "endpoints": ["http://localhost:5000/tauri/{{target}}/{{arch}}/{{current_version}}"], + "endpoints": ["https://scribe.izzi-xenex.xyz/tauri/{{target}}/{{arch}}/{{current_version}}"], "pubkey": "dW50cnVzdGVkIGNvbW1lbnQ6IG1pbmlzaWduIHB1YmxpYyBrZXk6IEJDQzY3MjU3MDQ3MDQ1OEYKUldTUFJYQUVWM0xHdktsNDY4RHREYzZnV3BDV3pxS1NVRHNQZGZhSHZqOTlvbXZ1YWdtdkU3b2kK", "windows": { "installMode": "passive" From 1e1f741ecd6ef2881a4e435244749ca709c948d7 Mon Sep 17 00:00:00 2001 From: HoaX7 Date: Mon, 16 Sep 2024 19:15:10 +0530 Subject: [PATCH 02/57] feat: added readme file --- readme.md | 1 + 1 file changed, 1 insertion(+) create mode 100644 readme.md diff --git a/readme.md b/readme.md new file mode 100644 index 0000000..a1daad5 --- /dev/null +++ b/readme.md @@ -0,0 +1 @@ +

Scribe v0.1.0

A Simple opensource note taking app perfect for quick notes or detailed plans, stay on top of your day and never lose track of your ideas again.

This markdown was created using scribe.

Quick notes

Press Ctrl+space from anywhere to jot down notes without having to worry about where to save them. The app will automatically save the contents to a shortnotes.md.

Settings

You can modify the save path by clicking on File > Settings.

Note: You must move the files manually to the new save directory.

Key features

Roadmap

From afd493ec7eac35c17b55e032edb7b59063a91279 Mon Sep 17 00:00:00 2001 From: HoaX7 Date: Thu, 19 Sep 2024 00:08:27 +0530 Subject: [PATCH 03/57] feat: search support and bug fixes --- .github/workflows/build.yml | 10 +- app/docs/readme.md | 1 + app/package-lock.json | 14 + app/package.json | 1 + app/src-tauri/Cargo.lock | 386 +++++++++++++++++- app/src-tauri/Cargo.toml | 2 +- app/src-tauri/src/commands.rs | 7 + app/src-tauri/src/controller.rs | 9 +- app/src-tauri/src/main.rs | 3 +- app/src-tauri/tauri.conf.json | 5 +- app/src/api/index.ts | 5 + app/src/lib/components/common/Modal.svelte | 14 +- .../lib/components/editor/BubbleMenu.svelte | 2 +- app/src/lib/components/editor/Editor.svelte | 7 + .../lib/components/editor/MenuButton.svelte | 2 +- app/src/lib/components/menu/Main.svelte | 44 +- app/src/lib/components/menu/items.ts | 15 +- app/src/lib/components/search/Index.svelte | 37 ++ .../lib/components/settings/tabs/Home.svelte | 3 + .../components/sidebar/FileListItem.svelte | 30 +- app/src/lib/components/sidebar/Index.svelte | 55 ++- .../components/sidebar/SearchContent.svelte | 66 +++ app/src/lib/hooks/TauriEventListener.svelte | 20 + app/src/routes/+page.svelte | 13 +- app/src/routes/shortNotes/+page.svelte | 7 +- app/src/types/index.ts | 1 + app/src/utils/constants.ts | 8 + app/src/utils/errors.ts | 3 + app/static/assets/images/search.svg | 1 + backend/noteapp_lib/Cargo.lock | 125 ++++++ backend/noteapp_lib/Cargo.toml | 1 + backend/noteapp_lib/settings.toml | 3 +- backend/noteapp_lib/src/app_settings/mod.rs | 16 +- backend/noteapp_lib/src/bin/bin.rs | 7 +- backend/noteapp_lib/src/fs/mod.rs | 76 +++- backend/noteapp_lib/src/lib.rs | 2 +- backend/noteapp_lib/src/storage/mod.rs | 10 +- readme.md | 2 +- 38 files changed, 935 insertions(+), 78 deletions(-) create mode 100644 app/docs/readme.md create mode 100644 app/src/lib/components/search/Index.svelte create mode 100644 app/src/lib/components/sidebar/SearchContent.svelte create mode 100644 app/src/lib/hooks/TauriEventListener.svelte create mode 100644 app/src/utils/constants.ts create mode 100644 app/src/utils/errors.ts create mode 100644 app/static/assets/images/search.svg diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 18d7588..66cabca 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -7,6 +7,8 @@ on: jobs: release: + permissions: + contents: write strategy: fail-fast: false matrix: @@ -28,13 +30,6 @@ jobs: - name: Checkout repository uses: actions/checkout@v4 - # for projects that use labels and PRs, - # try https://github.com/mikepenz/release-changelog-builder-action instead - # TODO: use API to collect commit messages - - name: Build Changelog - id: build_changelog - run: echo "changelog=- ADD CHANGELOG" >> $GITHUB_OUTPUT - - name: Node.js setup uses: actions/setup-node@v4 # NOTE: enterprise developers may hard code a version @@ -67,7 +62,6 @@ jobs: tagName: app-v__VERSION__ releaseName: Scribe v__VERSION__ releaseBody: | - ${{steps.build_changelog.outputs.changelog}} See the assets to download this version and install. releaseDraft: true prerelease: false \ No newline at end of file diff --git a/app/docs/readme.md b/app/docs/readme.md new file mode 100644 index 0000000..4100891 --- /dev/null +++ b/app/docs/readme.md @@ -0,0 +1 @@ +

Scribe v0.1.0

A Simple opensource note taking app perfect for quick notes or detailed plans, stay on top of your day and never lose track of your ideas again.

This markdown was created using scribe.

Quick notes

Press Ctrl+space from anywhere to jot down notes without having to worry about where to save them. The app will automatically save the contents in a shortnotes.md in the selected directory.

Settings

All notes by default are saved in the installation path under a docs folder.

You can modify the save path by clicking on File > Settings.

Note: You must move the files manually to the new save directory.

Key features

  • Built for speed with rust.

  • Close the app and take notes from anywhere.

  • Markdown shortcuts make it easy to format the text while typing.

    To test that, start a new line and type # followed by a space to get a heading. Try #, ##, ###, ####, #####, ###### for different levels.

  • You can also try > for blockquotes, *, - or + for bullet lists, or `foobar` to highlight code, ~~tildes~~ to strike text, or ==equal signs== to highlight text, (c) to see how it’s converted to a proper © character. You can also try ->, >>, 1/2, !=, or --** for bold and _Italic_ for italic.

  • An inline toolbar is also available when you select text.

Roadmap

  • Integration with notion.

diff --git a/app/package-lock.json b/app/package-lock.json index ad6c089..1b5e0b0 100644 --- a/app/package-lock.json +++ b/app/package-lock.json @@ -21,6 +21,7 @@ "@tiptap/extension-task-item": "^2.6.6", "@tiptap/extension-task-list": "^2.6.6", "@tiptap/extension-text-style": "^2.6.6", + "@tiptap/extension-typography": "^2.6.6", "@tiptap/extension-underline": "^2.6.6", "@tiptap/pm": "^2.6.6", "@tiptap/starter-kit": "^2.6.6", @@ -1575,6 +1576,19 @@ "@tiptap/core": "^2.6.6" } }, + "node_modules/@tiptap/extension-typography": { + "version": "2.6.6", + "resolved": "https://registry.npmjs.org/@tiptap/extension-typography/-/extension-typography-2.6.6.tgz", + "integrity": "sha512-0niSddtPOY7CjKGmxOBQ34VqLGxTeOfN+zICL5CLmS8B815qb1G1csXhUyHJ1wT7q8xMCAhXnGCt8b8ilmj/sg==", + "license": "MIT", + "funding": { + "type": "github", + "url": "https://github.com/sponsors/ueberdosis" + }, + "peerDependencies": { + "@tiptap/core": "^2.6.6" + } + }, "node_modules/@tiptap/extension-underline": { "version": "2.6.6", "resolved": "https://registry.npmjs.org/@tiptap/extension-underline/-/extension-underline-2.6.6.tgz", diff --git a/app/package.json b/app/package.json index 0de44b5..ff98655 100644 --- a/app/package.json +++ b/app/package.json @@ -55,6 +55,7 @@ "@tiptap/extension-task-item": "^2.6.6", "@tiptap/extension-task-list": "^2.6.6", "@tiptap/extension-text-style": "^2.6.6", + "@tiptap/extension-typography": "^2.6.6", "@tiptap/extension-underline": "^2.6.6", "@tiptap/pm": "^2.6.6", "@tiptap/starter-kit": "^2.6.6", diff --git a/app/src-tauri/Cargo.lock b/app/src-tauri/Cargo.lock index 820da6e..d6a2af0 100644 --- a/app/src-tauri/Cargo.lock +++ b/app/src-tauri/Cargo.lock @@ -212,6 +212,9 @@ name = "bytes" version = "1.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8318a53db07bb3f8dca91a600466bdb3f2eaadeedfdbcf02e1accbad9271ba50" +dependencies = [ + "serde", +] [[package]] name = "cairo-rs" @@ -658,7 +661,7 @@ dependencies = [ "rustc_version", "toml 0.8.19", "vswhom", - "winreg", + "winreg 0.52.0", ] [[package]] @@ -858,6 +861,12 @@ dependencies = [ "syn 2.0.77", ] +[[package]] +name = "futures-sink" +version = "0.3.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9fb8e00e87438d937621c1c6269e53f536c14d3fbd6a042bb24879e57d474fb5" + [[package]] name = "futures-task" version = "0.3.30" @@ -871,8 +880,11 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3d6401deb83407ab3da39eba7e33987a73c3df0c82b4bb5813ee871c19c41d48" dependencies = [ "futures-core", + "futures-io", "futures-macro", + "futures-sink", "futures-task", + "memchr", "pin-project-lite", "pin-utils", "slab", @@ -1184,6 +1196,25 @@ dependencies = [ "syn 1.0.109", ] +[[package]] +name = "h2" +version = "0.3.26" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "81fe527a889e1532da5c525686d96d4c2e74cdd345badf8dfef9f6b39dd5f5e8" +dependencies = [ + "bytes", + "fnv", + "futures-core", + "futures-sink", + "futures-util", + "http", + "indexmap 2.5.0", + "slab", + "tokio", + "tokio-util", + "tracing", +] + [[package]] name = "hashbrown" version = "0.12.3" @@ -1254,12 +1285,72 @@ dependencies = [ "itoa 1.0.11", ] +[[package]] +name = "http-body" +version = "0.4.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7ceab25649e9960c0311ea418d17bee82c0dcec1bd053b5f9a66e265a693bed2" +dependencies = [ + "bytes", + "http", + "pin-project-lite", +] + [[package]] name = "http-range" version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "21dec9db110f5f872ed9699c3ecf50cf16f423502706ba5c72462e28d3157573" +[[package]] +name = "httparse" +version = "1.9.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0fcc0b4a115bf80b728eb8ea024ad5bd707b615bfed49e0665b6e0f86fd082d9" + +[[package]] +name = "httpdate" +version = "1.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "df3b46402a9d5adb4c86a0cf463f42e19994e3ee891101b1841f30a545cb49a9" + +[[package]] +name = "hyper" +version = "0.14.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a152ddd61dfaec7273fe8419ab357f33aee0d914c5f4efbf0d96fa749eea5ec9" +dependencies = [ + "bytes", + "futures-channel", + "futures-core", + "futures-util", + "h2", + "http", + "http-body", + "httparse", + "httpdate", + "itoa 1.0.11", + "pin-project-lite", + "socket2", + "tokio", + "tower-service", + "tracing", + "want", +] + +[[package]] +name = "hyper-tls" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d6183ddfa99b85da61a140bea0efc93fdf56ceaa041b37d553518030827f9905" +dependencies = [ + "bytes", + "hyper", + "native-tls", + "tokio", + "tokio-native-tls", +] + [[package]] name = "iana-time-zone" version = "0.1.60" @@ -1377,6 +1468,12 @@ dependencies = [ "cfg-if", ] +[[package]] +name = "ipnet" +version = "2.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "187674a687eed5fe42285b40c6291f9a01517d415fad1c3cbc6a9f778af7fcd4" + [[package]] name = "itoa" version = "0.4.8" @@ -1630,6 +1727,18 @@ dependencies = [ "autocfg", ] +[[package]] +name = "mime" +version = "0.3.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6877bb514081ee2a7ff5ef9de3281f14a4dd4bceac4c09388074a6b5df8a139a" + +[[package]] +name = "minisign-verify" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a05b5d0594e0cb1ad8cee3373018d2b84e25905dc75b2468114cc9a8e86cfc20" + [[package]] name = "miniz_oxide" version = "0.7.4" @@ -1661,6 +1770,23 @@ dependencies = [ "windows-sys 0.52.0", ] +[[package]] +name = "native-tls" +version = "0.2.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a8614eb2c83d59d1c8cc974dd3f920198647674a0a035e1af1fa58707e317466" +dependencies = [ + "libc", + "log", + "openssl", + "openssl-probe", + "openssl-sys", + "schannel", + "security-framework", + "security-framework-sys", + "tempfile", +] + [[package]] name = "ndk" version = "0.6.0" @@ -1705,6 +1831,7 @@ checksum = "72ef4a56884ca558e5ddb05a1d1e7e1bfd9a68d9ed024c21704cc98872dae1bb" name = "noteapp_lib" version = "0.1.0" dependencies = [ + "ignore", "serde", "thiserror", "tokio", @@ -1811,6 +1938,50 @@ version = "1.19.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" +[[package]] +name = "openssl" +version = "0.10.66" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9529f4786b70a3e8c61e11179af17ab6188ad8d0ded78c5529441ed39d4bd9c1" +dependencies = [ + "bitflags 2.6.0", + "cfg-if", + "foreign-types 0.3.2", + "libc", + "once_cell", + "openssl-macros", + "openssl-sys", +] + +[[package]] +name = "openssl-macros" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a948666b637a0f465e8564c73e89d4dde00d72d4d473cc972f390fc3dcee7d9c" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.77", +] + +[[package]] +name = "openssl-probe" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ff011a302c396a5197692431fc1948019154afc178baf7d8e37367442a4601cf" + +[[package]] +name = "openssl-sys" +version = "0.9.103" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7f9e8deee91df40a943c71b917e5874b951d32a802526c85721ce3b776c929d6" +dependencies = [ + "cc", + "libc", + "pkg-config", + "vcpkg", +] + [[package]] name = "os_info" version = "3.8.2" @@ -2299,6 +2470,48 @@ version = "0.8.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7a66a03ae7c801facd77a29370b4faec201768915ac14a721ba36f20bc9c209b" +[[package]] +name = "reqwest" +version = "0.11.27" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dd67538700a17451e7cba03ac727fb961abb7607553461627b97de0b89cf4a62" +dependencies = [ + "base64 0.21.7", + "bytes", + "encoding_rs", + "futures-core", + "futures-util", + "h2", + "http", + "http-body", + "hyper", + "hyper-tls", + "ipnet", + "js-sys", + "log", + "mime", + "native-tls", + "once_cell", + "percent-encoding", + "pin-project-lite", + "rustls-pemfile", + "serde", + "serde_json", + "serde_urlencoded", + "sync_wrapper", + "system-configuration", + "tokio", + "tokio-native-tls", + "tokio-util", + "tower-service", + "url", + "wasm-bindgen", + "wasm-bindgen-futures", + "wasm-streams", + "web-sys", + "winreg 0.50.0", +] + [[package]] name = "rfd" version = "0.10.0" @@ -2351,6 +2564,15 @@ dependencies = [ "windows-sys 0.52.0", ] +[[package]] +name = "rustls-pemfile" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1c74cae0a4cf6ccbbf5f359f08efdf8ee7e1dc532573bf0db71968cb56b1448c" +dependencies = [ + "base64 0.21.7", +] + [[package]] name = "rustversion" version = "1.0.17" @@ -2372,6 +2594,15 @@ dependencies = [ "winapi-util", ] +[[package]] +name = "schannel" +version = "0.1.24" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e9aaafd5a2b6e3d657ff009d82fbd630b6bd54dd4eb06f21693925cdf80f9b8b" +dependencies = [ + "windows-sys 0.59.0", +] + [[package]] name = "scoped-tls" version = "1.0.1" @@ -2396,6 +2627,29 @@ dependencies = [ "window-shadows", ] +[[package]] +name = "security-framework" +version = "2.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "897b2245f0b511c87893af39b033e5ca9cce68824c4d7e7630b5a1d339658d02" +dependencies = [ + "bitflags 2.6.0", + "core-foundation", + "core-foundation-sys", + "libc", + "security-framework-sys", +] + +[[package]] +name = "security-framework-sys" +version = "2.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "75da29fe9b9b08fe9d6b22b5b4bcbc75d8db3aa31e639aa56bb62e9d46bfceaf" +dependencies = [ + "core-foundation-sys", + "libc", +] + [[package]] name = "selectors" version = "0.22.0" @@ -2478,6 +2732,18 @@ dependencies = [ "serde", ] +[[package]] +name = "serde_urlencoded" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d3491c14715ca2294c4d6a88f15e84739788c1d030eed8c110436aafdaa2f3fd" +dependencies = [ + "form_urlencoded", + "itoa 1.0.11", + "ryu", + "serde", +] + [[package]] name = "serde_with" version = "3.9.0" @@ -2709,6 +2975,12 @@ dependencies = [ "unicode-ident", ] +[[package]] +name = "sync_wrapper" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2047c6ded9c721764247e62cd3b03c09ffc529b2ba5b10ec482ae507a4a70160" + [[package]] name = "sys-locale" version = "0.3.1" @@ -2718,6 +2990,27 @@ dependencies = [ "libc", ] +[[package]] +name = "system-configuration" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ba3a3adc5c275d719af8cb4272ea1c4a6d668a777f37e115f6d11ddbc1c8e0e7" +dependencies = [ + "bitflags 1.3.2", + "core-foundation", + "system-configuration-sys", +] + +[[package]] +name = "system-configuration-sys" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a75fb188eb626b924683e3b95e3a48e63551fcfb51949de2f06a9d91dbee93c9" +dependencies = [ + "core-foundation-sys", + "libc", +] + [[package]] name = "system-deps" version = "5.0.0" @@ -2828,6 +3121,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0e33e3ba00a3b05eb6c57ef135781717d33728b48acf914bb05629e74d897d29" dependencies = [ "anyhow", + "base64 0.22.1", + "bytes", "cocoa 0.24.1", "dirs-next", "dunce", @@ -2842,12 +3137,15 @@ dependencies = [ "heck 0.5.0", "http", "ignore", + "indexmap 1.9.3", + "minisign-verify", "objc", "once_cell", "os_info", "percent-encoding", "rand 0.8.5", "raw-window-handle", + "reqwest", "rfd", "semver", "serde", @@ -2863,12 +3161,14 @@ dependencies = [ "tauri-utils", "tempfile", "thiserror", + "time", "tokio", "url", "uuid", "webkit2gtk", "webview2-com", "windows 0.39.0", + "zip", ] [[package]] @@ -3145,6 +3445,29 @@ dependencies = [ "syn 2.0.77", ] +[[package]] +name = "tokio-native-tls" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bbae76ab933c85776efabc971569dd6119c580d8f5d448769dec1764bf796ef2" +dependencies = [ + "native-tls", + "tokio", +] + +[[package]] +name = "tokio-util" +version = "0.7.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "61e7c3654c13bcd040d4a03abee2c75b1d14a37b423cf5a813ceae1cc903ec6a" +dependencies = [ + "bytes", + "futures-core", + "futures-sink", + "pin-project-lite", + "tokio", +] + [[package]] name = "toml" version = "0.5.11" @@ -3213,6 +3536,12 @@ dependencies = [ "winnow 0.6.18", ] +[[package]] +name = "tower-service" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8df9b6e13f2d32c91b9bd719c00d1958837bc7dec474d94952798cc8e69eeec3" + [[package]] name = "tracing" version = "0.1.40" @@ -3274,6 +3603,12 @@ dependencies = [ "tracing-log", ] +[[package]] +name = "try-lock" +version = "0.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e421abadd41a4225275504ea4d6566923418b7f05506fbc9c0fe86ba7396114b" + [[package]] name = "typenum" version = "1.17.0" @@ -3340,6 +3675,12 @@ version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "830b7e5d4d90034032940e4ace0d9a9a057e7a45cd94e6c007832e39edb82f6d" +[[package]] +name = "vcpkg" +version = "0.2.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "accd4ea62f7bb7a82fe23066fb0957d48ef677f6eeb8215f372f52e48bb32426" + [[package]] name = "version-compare" version = "0.0.11" @@ -3388,6 +3729,15 @@ dependencies = [ "winapi-util", ] +[[package]] +name = "want" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bfa7760aed19e106de2c7c0b581b509f2f25d3dacaf737cb82ac61bc6d760b0e" +dependencies = [ + "try-lock", +] + [[package]] name = "wasi" version = "0.9.0+wasi-snapshot-preview1" @@ -3467,6 +3817,19 @@ version = "0.2.93" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c62a0a307cb4a311d3a07867860911ca130c3494e8c2719593806c08bc5d0484" +[[package]] +name = "wasm-streams" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b65dc4c90b63b118468cf747d8bf3566c1913ef60be765b5730ead9e0a3ba129" +dependencies = [ + "futures-util", + "js-sys", + "wasm-bindgen", + "wasm-bindgen-futures", + "web-sys", +] + [[package]] name = "web-sys" version = "0.3.70" @@ -3917,6 +4280,16 @@ dependencies = [ "memchr", ] +[[package]] +name = "winreg" +version = "0.50.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "524e57b2c537c0f9b1e69f1965311ec12182b4122e45035b1508cd24d2adadb1" +dependencies = [ + "cfg-if", + "windows-sys 0.48.0", +] + [[package]] name = "winreg" version = "0.52.0" @@ -4017,3 +4390,14 @@ dependencies = [ "quote", "syn 2.0.77", ] + +[[package]] +name = "zip" +version = "0.6.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "760394e246e4c28189f19d488c058bf16f564016aefac5d32bb1f3b51d5e9261" +dependencies = [ + "byteorder", + "crc32fast", + "crossbeam-utils", +] diff --git a/app/src-tauri/Cargo.toml b/app/src-tauri/Cargo.toml index 290591a..fbbc59e 100644 --- a/app/src-tauri/Cargo.toml +++ b/app/src-tauri/Cargo.toml @@ -17,7 +17,7 @@ tauri-build = { version = "1.5.4", features = [] } [dependencies] serde_json = "1.0" serde = { version = "1.0", features = ["derive"] } -tauri = { version = "1.7.2", features = [ "dialog-open", "path-all", "window-close", "global-shortcut", "global-shortcut-all", "os-all", "window-unmaximize", "system-tray", "window-maximize", "window-minimize", "window-start-dragging", "window-hide"] } +tauri = { version = "1.7.2", features = [ "dialog-confirm", "updater", "dialog-open", "path-all", "window-close", "global-shortcut", "global-shortcut-all", "os-all", "window-unmaximize", "system-tray", "window-maximize", "window-minimize", "window-start-dragging", "window-hide"] } window-shadows = "0.2.2" noteapp_lib = { path = "../../backend/noteapp_lib" } diff --git a/app/src-tauri/src/commands.rs b/app/src-tauri/src/commands.rs index 84cb49c..709c167 100644 --- a/app/src-tauri/src/commands.rs +++ b/app/src-tauri/src/commands.rs @@ -1,3 +1,5 @@ +use std::path::PathBuf; + use noteapp_lib::{app_settings, storage::StorageType}; use crate::{controller::*, shortcuts}; @@ -56,3 +58,8 @@ pub async fn save_settings(new_settings: app_settings::AppSettings) -> Result<() } Ok(()) } + +#[tauri::command] +pub fn search_contents(query: &str) -> Result, ()> { + StorageType::Disk.search_strategy(query) +} diff --git a/app/src-tauri/src/controller.rs b/app/src-tauri/src/controller.rs index f9ff615..421c256 100644 --- a/app/src-tauri/src/controller.rs +++ b/app/src-tauri/src/controller.rs @@ -1,3 +1,5 @@ +use std::io::ErrorKind; + use noteapp_lib::{app_settings::load_config, errors::AppError, storage::StorageType}; use serde::{Deserialize, Serialize}; @@ -29,6 +31,7 @@ impl ControllerError { impl ControllerError { const INVALID_SETTINGS: &str = "IV_S"; const IO: &str = "IO_E"; + const IO_NOTFOUND: &str = "IO_NF"; } impl From for ControllerError { @@ -41,6 +44,10 @@ impl From for ControllerError { } impl From for ControllerError { fn from(value: std::io::Error) -> Self { - ControllerError::new(value.to_string(), ControllerError::IO, 500) + if value.kind() == ErrorKind::NotFound { + ControllerError::new(value.to_string(), ControllerError::IO_NOTFOUND, 404) + } else { + ControllerError::new(value.to_string(), ControllerError::IO, 500) + } } } diff --git a/app/src-tauri/src/main.rs b/app/src-tauri/src/main.rs index 81daa8d..814616c 100644 --- a/app/src-tauri/src/main.rs +++ b/app/src-tauri/src/main.rs @@ -28,7 +28,8 @@ fn main() { delete_file, open_shortnote_window, get_settings, - save_settings + save_settings, + search_contents ]) .run(tauri::generate_context!()) .expect("error running application"); diff --git a/app/src-tauri/tauri.conf.json b/app/src-tauri/tauri.conf.json index 5d18c63..896fed8 100644 --- a/app/src-tauri/tauri.conf.json +++ b/app/src-tauri/tauri.conf.json @@ -32,7 +32,8 @@ }, "dialog": { "all": false, - "open": true + "open": true, + "confirm": true } }, "bundle": { @@ -59,7 +60,7 @@ "providerShortName": null, "signingIdentity": null }, - "resources": [], + "resources": ["../docs/readme.md"], "shortDescription": "Perfect for quick notes or detailed plans, stay on top of your day and never lose track of your ideas again!", "targets": "all", "windows": { diff --git a/app/src/api/index.ts b/app/src/api/index.ts index a8f1a2a..4835404 100644 --- a/app/src/api/index.ts +++ b/app/src/api/index.ts @@ -49,4 +49,9 @@ export const getSettings = async (): Promise => { export const saveSettings = async (newSettings: Partial) => { if (isEmptyObject(newSettings)) return; return invoke("save_settings", { newSettings }); +}; + +export const searchContent = async (query: string): Promise => { + if (!query) return []; + return invoke("search_contents", { query }); }; \ No newline at end of file diff --git a/app/src/lib/components/common/Modal.svelte b/app/src/lib/components/common/Modal.svelte index 4c7210d..960cbb5 100644 --- a/app/src/lib/components/common/Modal.svelte +++ b/app/src/lib/components/common/Modal.svelte @@ -4,14 +4,19 @@ import { createEventDispatcher } from "svelte"; const dispatch = createEventDispatcher(); + export let empty = false; + export let containerClass = "";
+ class={clsx("fixed inset-0 z-[999] grid h-screen w-screen bg-black bg-opacity-60 backdrop-blur-sm", containerClass ? containerClass : "place-items-center")}> + {#if empty} +
+ +
+ {:else}
+ class="relative bg-white w-3/4 h-3/4 rounded"> @@ -23,4 +28,5 @@
+ {/if} diff --git a/app/src/lib/components/editor/BubbleMenu.svelte b/app/src/lib/components/editor/BubbleMenu.svelte index fc369f0..d4781cf 100644 --- a/app/src/lib/components/editor/BubbleMenu.svelte +++ b/app/src/lib/components/editor/BubbleMenu.svelte @@ -96,7 +96,7 @@ }; -
+
{#if showLinkInput}
{ + const { size } = editor.view.state.doc.content; + editor.commands.insertContentAt(size, text); + } onMount(() => { editor = new Editor({ element: editorContainer, @@ -47,6 +53,7 @@ StarterKit.configure(StarterKitOptions), BubbleMenu.configure({ element: bubbleMenuEl }), SlashCommands, + Typography, ], onTransaction() { editor = editor; diff --git a/app/src/lib/components/editor/MenuButton.svelte b/app/src/lib/components/editor/MenuButton.svelte index 45aa0e2..66d28aa 100644 --- a/app/src/lib/components/editor/MenuButton.svelte +++ b/app/src/lib/components/editor/MenuButton.svelte @@ -6,7 +6,7 @@ diff --git a/app/src/lib/components/menu/Main.svelte b/app/src/lib/components/menu/Main.svelte index 0716e5b..7a83ccb 100644 --- a/app/src/lib/components/menu/Main.svelte +++ b/app/src/lib/components/menu/Main.svelte @@ -6,7 +6,9 @@ import MenuItems from "./MenuItems.svelte"; import { getMenuBar } from "./items"; import Settings from "../settings/Index.svelte"; - import { listen } from "@tauri-apps/api/event"; + import TauriEventListener from "$lib/hooks/TauriEventListener.svelte"; + import { TAURI_EVENTS } from "../../../utils/constants"; + import { emit } from "@tauri-apps/api/event"; const ctx = ContextStore.getContext(); let menubar = []; @@ -15,30 +17,38 @@ const closeMenu = () => { activeMenu = ""; + }; + $: menubar = getMenuBar($ctx.page, () => (showSettings = true)); + + const closeSettings = () => { + showSettings = false; } - $: menubar = getMenuBar($ctx.page, () => showSettings = true); - - listen("show_settings", () => { - showSettings = true; - }) + showSettings = true} /> {#if showSettings} - showSettings = false} /> + {/if}
{#each menubar as menu} -
- - -
+
+ + +
{/each}
diff --git a/app/src/lib/components/menu/items.ts b/app/src/lib/components/menu/items.ts index 0815e17..24f4ded 100644 --- a/app/src/lib/components/menu/items.ts +++ b/app/src/lib/components/menu/items.ts @@ -1,5 +1,6 @@ -import { appWindow } from "@tauri-apps/api/window"; +import { appWindow, WebviewWindow } from "@tauri-apps/api/window"; import { openShortNoteWindow } from "../../../api"; +import { SHORT_NOTE_WINDOW_LABEL } from "../../../utils/constants"; export type MenuItemProps = { name: string; @@ -17,6 +18,11 @@ const emitSave = () => { }); window.dispatchEvent(event); }; +const quitApp = () => { + const shortnotesWindow = WebviewWindow.getByLabel(SHORT_NOTE_WINDOW_LABEL); + shortnotesWindow?.close?.(); + appWindow.close(); +}; export const getMenuBar = (page?: string, cb?: () => void) => [ { name: "File", @@ -32,13 +38,18 @@ export const getMenuBar = (page?: string, cb?: () => void) => [ command: openShortNoteWindow, shortcut: "Ctrl+Space", }, + { + name: "Refresh", + command: () => window.location.reload(), + shortcut: "F5" + }, { name: "Settings", command: () => cb?.(), }, { name: "Quit", - command: appWindow.close, + command: quitApp, classname: "border-t", }, ], diff --git a/app/src/lib/components/search/Index.svelte b/app/src/lib/components/search/Index.svelte new file mode 100644 index 0000000..7f1ba4b --- /dev/null +++ b/app/src/lib/components/search/Index.svelte @@ -0,0 +1,37 @@ + + + + +{#if showModal} + + +
+
+ + +
+
+ +
+
+
+
+{/if} diff --git a/app/src/lib/components/settings/tabs/Home.svelte b/app/src/lib/components/settings/tabs/Home.svelte index c2b67c3..ff8ca18 100644 --- a/app/src/lib/components/settings/tabs/Home.svelte +++ b/app/src/lib/components/settings/tabs/Home.svelte @@ -5,6 +5,8 @@ import { saveSettings } from "../../../../api"; import Spinner from "$lib/components/common/Spinner.svelte"; import Error from "$lib/components/common/ErrorComponent.svelte"; + import { emit } from "@tauri-apps/api/event"; + import { TAURI_EVENTS } from "../../../../utils/constants"; export let settings: SettingProps; let saving = false; @@ -20,6 +22,7 @@ if (typeof dir === "string" && dir !== settings.save_files_to_dir) { await saveSettings({ save_files_to_dir: dir }); settings.save_files_to_dir = dir; + emit(TAURI_EVENTS.RELOAD_FILES); } } catch (err: any) { console.error("Unable to save settings", err); diff --git a/app/src/lib/components/sidebar/FileListItem.svelte b/app/src/lib/components/sidebar/FileListItem.svelte index bbf959b..25066ac 100644 --- a/app/src/lib/components/sidebar/FileListItem.svelte +++ b/app/src/lib/components/sidebar/FileListItem.svelte @@ -5,6 +5,7 @@ import Typography from "../common/Typography.svelte"; import { deleteFile, renameFile } from "../../../api"; import Error from "../common/ErrorComponent.svelte"; + import { IO } from "../../../utils/errors"; export let item: ContextProps; export let ctx: ContextProps; @@ -16,19 +17,26 @@ let fileExists = false; let error = ""; + const updatePages = (obj: ContextProps) => { + const idx = pages.findIndex((p) => p.page === obj.page && p.ext === obj.ext); + if (idx >= 0) { + pages.splice(idx, 1); + setPages(pages); + } + if (ctx.page === obj.page && ctx.ext === obj.ext) { + updateStore(pages[0] || {}); + } + } const deletePage = async (obj: ContextProps) => { const filename = `${obj.page}.${obj.ext}`; try { await deleteFile(filename); - const idx = pages.findIndex((p) => p.page === obj.page && p.ext === obj.ext); - if (idx >= 0) { - pages.splice(idx, 1); - setPages(pages); - } - if (ctx.page === obj.page && ctx.ext === obj.ext) { - updateStore(pages[0] || {}); - } + updatePages(obj); } catch (err: any) { + if (err.code === IO.IO_NF) { + updatePages(obj); + return; + } console.error("unable to delete", err); error = err?.message || "unable to delete page"; } @@ -89,7 +97,11 @@ - {/if} diff --git a/app/src/lib/components/sidebar/Index.svelte b/app/src/lib/components/sidebar/Index.svelte index 86446ab..f39f873 100644 --- a/app/src/lib/components/sidebar/Index.svelte +++ b/app/src/lib/components/sidebar/Index.svelte @@ -7,6 +7,9 @@ import FileListItem from "./FileListItem.svelte"; import { parseFilename } from "../../../utils"; import Error from "../common/ErrorComponent.svelte"; + import TauriEventListener from "$lib/hooks/TauriEventListener.svelte"; + import { TAURI_EVENTS } from "../../../utils/constants"; + import SearchContent from "./SearchContent.svelte"; let pages: ContextProps[] = []; let error = ""; @@ -18,21 +21,9 @@ isShortNote }) - onMount(async () => { - try { - const result = await getFileList(); - pages = await Promise.all(result.map(async (page) => { - const { filename, ext } = await parseFilename(page); - const isShortNote = filename.toLowerCase() === "shortnotes"; - return getPageObject(filename, ext, isShortNote); - })); - const selected = pages[0]; - if (selected?.page !== $ctx.page) updateStore(selected); - } catch (err: any) { - console.error("error", err); - error = err?.message || "unable to load files"; - } - }) + onMount(() => { + loadData(); + }); const updateStore = (selected: ContextProps) => { contextStore.update(selected); @@ -48,12 +39,46 @@ pages.splice(0, 0, newPage); pages = pages; } + + const loadData = async (canUpdate = true, forceUpdate = false) => { + try { + const result = await getFileList(); + pages = await Promise.all(result.map(async (page) => { + const { filename, ext } = await parseFilename(page); + const isShortNote = filename.toLowerCase() === "shortnotes"; + return getPageObject(filename, ext, isShortNote); + })); + if (canUpdate) { + const selected = pages[0]; + if (selected?.page !== $ctx.page || forceUpdate) updateStore(selected); + } + } catch (err: any) { + console.error("error", err); + error = err?.message || "unable to load files"; + } + } + + const handleRefresh = ({ payload }: { payload: { page: string; }; }) => { + const found = pages.find((p) => p.page.toLowerCase() === payload.page.toLowerCase()); + if (found) return; + loadData(pages.length <= 0); + } + + const handlePageSelect = ({ detail }: { detail: string }) => { + const found = pages.find((p) => `${p.page}.${p.ext}` === detail); + if (found && ($ctx.page !== found.page || found.ext !== $ctx.ext)) { + updateStore(found); + } + } + loadData(true, true)} /> + {#if error} {/if}