Compare commits

..

275 Commits

Author SHA1 Message Date
perfectra1n
81f02209ea feat(db): update index and fix suggestion from gemini 2026-03-22 09:22:55 -07:00
perfectra1n
124d456c60 feat(db): add missing sqlite indices to help with performance 2026-03-22 09:14:33 -07:00
Elian Doran
76fc9eaeb0 chore(deps): update dependency ws to v8.20.0 (#9136) 2026-03-22 11:40:00 +02:00
Elian Doran
a4b7f54c64 fix(nix): build failing due to rolldown optional deps 2026-03-22 11:37:05 +02:00
Elian Doran
53192d202d chore(nix): add electron & python to shell 2026-03-22 11:37:05 +02:00
Elian Doran
6896ed2c70 chore(nix): update flake lock for new Electron version 2026-03-22 11:37:05 +02:00
Elian Doran
5a96b9c48d fix(deps): update dependency i18next to v25.10.3 (#9135) 2026-03-22 10:56:13 +02:00
renovate[bot]
6113bfc57f fix(deps): update dependency i18next to v25.10.3 2026-03-22 08:49:05 +00:00
Elian Doran
9d7bc20f26 fix(deps): update dependency react-i18next to v16.6.0 (#9137) 2026-03-22 10:47:18 +02:00
renovate[bot]
79788937b9 fix(deps): update dependency react-i18next to v16.6.0 2026-03-22 01:08:10 +00:00
renovate[bot]
66873f16f2 chore(deps): update dependency ws to v8.20.0 2026-03-22 01:07:33 +00:00
Elian Doran
532e001ef0 chore(deps): update dependency stylelint to v17.5.0 (#9115) 2026-03-21 19:29:30 +02:00
Elian Doran
17991bf31f chore(deps): update dependency @preact/preset-vite to v2.10.5 (#9125) 2026-03-21 19:28:47 +02:00
renovate[bot]
2b21b1f75e chore(deps): update dependency @preact/preset-vite to v2.10.5 2026-03-21 17:28:07 +00:00
Elian Doran
dae1f9302c chore(deps): update dependency @redocly/cli to v2.24.1 (#9126) 2026-03-21 19:27:55 +02:00
Elian Doran
33365cdaf1 Translations update from Hosted Weblate (#9124) 2026-03-21 19:25:38 +02:00
green
3ac66ffe72 Translated using Weblate (Japanese)
Currently translated at 100.0% (1719 of 1719 strings)

Translation: Trilium Notes/Client
Translate-URL: https://hosted.weblate.org/projects/trilium/client/ja/
2026-03-21 18:24:53 +01:00
Francis C.
81baf13720 Translated using Weblate (Chinese (Traditional Han script))
Currently translated at 100.0% (1719 of 1719 strings)

Translation: Trilium Notes/Client
Translate-URL: https://hosted.weblate.org/projects/trilium/client/zh_Hant/
2026-03-21 18:24:52 +01:00
AggelosPnS
e0e96350d6 Translated using Weblate (Greek)
Currently translated at 2.8% (49 of 1719 strings)

Translation: Trilium Notes/Client
Translate-URL: https://hosted.weblate.org/projects/trilium/client/el/
2026-03-21 18:24:52 +01:00
Elian Doran
c539c21ced chore(deps): update dependency eslint to v10.1.0 (#9130) 2026-03-21 19:24:44 +02:00
Elian Doran
3f7f6cf982 fix(deps): update dependency i18next to v25.10.2 (#9113) 2026-03-21 19:23:13 +02:00
Elian Doran
271d87ae33 fix(deps): update dependency katex to v0.16.40 (#9127) 2026-03-21 19:22:03 +02:00
Elian Doran
533a77e606 fix(deps): update dependency marked to v17.0.5 (#9128) 2026-03-21 19:21:19 +02:00
Elian Doran
77cf2d4dd9 fix(deps): update dependency sanitize-filename to v1.6.4 (#9129) 2026-03-21 19:20:42 +02:00
Elian Doran
890cb247c1 fix(deps): update dependency eslint-linter-browserify to v10.1.0 (#9131) 2026-03-21 19:19:18 +02:00
renovate[bot]
8d7f4dd0fa fix(deps): update dependency i18next to v25.10.2 2026-03-21 16:55:05 +00:00
Elian Doran
00c4933344 fix(collections/grid): full-width images are too small in preview (closes #9116) 2026-03-21 09:15:13 +02:00
Elian Doran
cd9b46e1c7 fix(attributes): attribute detail not showing up for first item (closes #6948) 2026-03-21 09:06:21 +02:00
Elian Doran
b356b355ca fix(layout): attribute details not visible in new layout (closes #9005) 2026-03-21 08:58:13 +02:00
renovate[bot]
d1aebb7bb0 fix(deps): update dependency eslint-linter-browserify to v10.1.0 2026-03-21 02:04:29 +00:00
renovate[bot]
6cbb595ae8 chore(deps): update dependency eslint to v10.1.0 2026-03-21 02:03:50 +00:00
renovate[bot]
fcf238bc35 fix(deps): update dependency sanitize-filename to v1.6.4 2026-03-21 02:03:10 +00:00
renovate[bot]
8c82468ecc fix(deps): update dependency marked to v17.0.5 2026-03-21 02:02:32 +00:00
renovate[bot]
965905ce00 fix(deps): update dependency katex to v0.16.40 2026-03-21 02:01:52 +00:00
renovate[bot]
ed280775bd chore(deps): update dependency @redocly/cli to v2.24.1 2026-03-21 02:01:10 +00:00
Elian Doran
8834899012 fix(math): limit size of popup and add back overflow (closes #9117) 2026-03-20 20:57:07 +02:00
Elian Doran
55dea474e9 chore(deps): update dependency @ckeditor/ckeditor5-dev-build-tools to v55.2.0 (#9099) 2026-03-20 13:45:51 +02:00
Elian Doran
bc74455a64 chore(deps): update dependency @smithy/middleware-retry to v4.4.44 (#9111) 2026-03-20 13:45:21 +02:00
Elian Doran
2d0b28367f chore(deps): update dependency vite to v8.0.1 (#9112) 2026-03-20 13:45:00 +02:00
Elian Doran
7d8a3e2811 fix(deps): update dependency katex to v0.16.39 (#9114) 2026-03-20 13:44:32 +02:00
renovate[bot]
79e5d9595a chore(deps): update dependency @ckeditor/ckeditor5-dev-build-tools to v55.2.0 2026-03-20 00:11:04 +00:00
renovate[bot]
1f0fa57218 chore(deps): update dependency stylelint to v17.5.0 2026-03-20 00:09:32 +00:00
renovate[bot]
0310626025 fix(deps): update dependency katex to v0.16.39 2026-03-20 00:08:50 +00:00
renovate[bot]
fefbb40c03 chore(deps): update dependency vite to v8.0.1 2026-03-20 00:07:33 +00:00
renovate[bot]
12f89078b8 chore(deps): update dependency @smithy/middleware-retry to v4.4.44 2026-03-20 00:06:57 +00:00
Elian Doran
8d873c5869 fix(share): prevent crash when accessing /share on uninitialized setup (#9088) 2026-03-19 20:13:32 +02:00
Elian Doran
27f4ac1d03 Textarea Label Support (#9077) 2026-03-19 20:02:11 +02:00
Elian Doran
d533360903 chore(attributes): rename textarea to multiline text 2026-03-19 20:01:55 +02:00
Elian Doran
49f5dc1c26 fix(table): text jumping when editing multiline text 2026-03-19 20:00:43 +02:00
Elian Doran
16419ed4ac Merge remote-tracking branch 'origin/main' into textarea-labels 2026-03-19 19:54:16 +02:00
Elian Doran
1595d1b5c9 Fix setup page error (#9102) 2026-03-19 19:50:07 +02:00
Elian Doran
50eb11997c fix(setup): contrast issue in alert (closes #8915) 2026-03-19 19:49:32 +02:00
Elian Doran
d974dfbc31 Translations update from Hosted Weblate (#9109) 2026-03-19 19:26:35 +02:00
Hosted Weblate
e9b63e50d4 Update translation files
Updated by "Cleanup translation files" add-on in Weblate.

Translation: Trilium Notes/Client
Translate-URL: https://hosted.weblate.org/projects/trilium/client/
2026-03-19 18:08:13 +01:00
Elian Doran
b6efb7c9ab feat(relation_map): add common note opening options to context menu 2026-03-19 19:07:54 +02:00
Elian Doran
f84479b1c2 fix(deps): update univer monorepo to v0.18.0 (#9101) 2026-03-19 17:48:23 +02:00
JYC333
8597fa560b Merge branch 'main' into fix/share-uninitialized-crash 2026-03-19 11:49:55 +00:00
JYC333
b29ab93fd5 fix: limit the scope of DB check only for share page 2026-03-19 11:46:35 +00:00
JYC333
225cdaff46 Update apps/client/src/setup.ts
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
2026-03-19 11:34:53 +00:00
JYC333
61dfba8c32 fix: remove knockout dependency 2026-03-19 11:24:45 +00:00
JYC333
4fee91d219 fix: change html to use DOM status 2026-03-19 11:24:09 +00:00
JYC333
12e4f76a8b fix: move setup to DOM implementation to fix knockout issue 2026-03-19 11:23:06 +00:00
JYC333
ec30598397 chore(deps): update dependency eslint-plugin-playwright to v2.10.1 (#9097) 2026-03-19 10:55:01 +00:00
JYC333
fdd2cc77e6 Merge branch 'main' into renovate/eslint-plugin-playwright-2.x 2026-03-19 10:30:16 +00:00
JYC333
6f5c618bcd chore(deps): update dependency @redocly/cli to v2.24.0 (#9100) 2026-03-19 10:29:43 +00:00
JYC333
8041112414 chore(deps): update dependency sanitize-html to v2.17.2 (#9098) 2026-03-19 10:28:18 +00:00
renovate[bot]
40ab2bc798 fix(deps): update univer monorepo to v0.18.0 2026-03-19 00:46:10 +00:00
renovate[bot]
3a3029cf3a chore(deps): update dependency @redocly/cli to v2.24.0 2026-03-19 00:45:28 +00:00
renovate[bot]
e7d1c75cdb chore(deps): update dependency sanitize-html to v2.17.2 2026-03-19 00:44:03 +00:00
renovate[bot]
bc907ee6ad chore(deps): update dependency eslint-plugin-playwright to v2.10.1 2026-03-19 00:43:25 +00:00
Elian Doran
0bff3f1fbc chore(deps): update dependency electron to v41.0.3 (#9090) 2026-03-18 20:18:44 +02:00
Elian Doran
377864b2c6 chore(deps): update dependency wxt to v0.20.20 (#9091) 2026-03-18 19:50:35 +02:00
Elian Doran
3db13df245 fix(deps): update dependency @zumer/snapdom to v2.5.0 (#9093) 2026-03-18 19:48:36 +02:00
Elian Doran
a2e09b40fa chore(deps): update dependency sax to v1.6.0 (#9092) 2026-03-18 19:43:21 +02:00
Elian Doran
aa590753d5 Translations update from Hosted Weblate (#9095) 2026-03-18 13:28:23 +02:00
Hosted Weblate
1c8519d7ec Update translation files
Updated by "Cleanup translation files" add-on in Weblate.

Translation: Trilium Notes/README
Translate-URL: https://hosted.weblate.org/projects/trilium/readme/
2026-03-18 12:26:56 +01:00
Elian Doran
686a614bfa Translations update from Hosted Weblate (#9085) 2026-03-18 13:26:47 +02:00
Elian Doran
01261220e3 Apply suggestion from @gemini-code-assist[bot]
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
2026-03-18 13:26:25 +02:00
허석
1bf92ab19a Translated using Weblate (Korean)
Currently translated at 93.9% (109 of 116 strings)

Translation: Trilium Notes/README
Translate-URL: https://hosted.weblate.org/projects/trilium/readme/ko/
2026-03-18 12:15:30 +01:00
Yunho Park
c0d0d1868d Translated using Weblate (Korean)
Currently translated at 100.0% (158 of 158 strings)

Translation: Trilium Notes/Website
Translate-URL: https://hosted.weblate.org/projects/trilium/website/ko/
2026-03-18 12:15:30 +01:00
허석
da2dec16cc Translated using Weblate (Korean)
Currently translated at 7.3% (126 of 1719 strings)

Translation: Trilium Notes/Client
Translate-URL: https://hosted.weblate.org/projects/trilium/client/ko/
2026-03-18 12:15:29 +01:00
Ulices
787ef7d513 Translated using Weblate (Spanish)
Currently translated at 100.0% (1719 of 1719 strings)

Translation: Trilium Notes/Client
Translate-URL: https://hosted.weblate.org/projects/trilium/client/es/
2026-03-18 12:15:28 +01:00
허석
dcb0ce79e6 Translated using Weblate (Korean)
Currently translated at 51.4% (199 of 387 strings)

Translation: Trilium Notes/Server
Translate-URL: https://hosted.weblate.org/projects/trilium/server/ko/
2026-03-18 12:15:27 +01:00
Elian Doran
9d8202539d chore(deps): update pnpm/action-setup action to v5 (#9094) 2026-03-18 13:15:19 +02:00
renovate[bot]
c46af4bca9 chore(deps): update pnpm/action-setup action to v5 2026-03-18 01:26:54 +00:00
renovate[bot]
610f6652df fix(deps): update dependency @zumer/snapdom to v2.5.0 2026-03-18 01:26:47 +00:00
renovate[bot]
b33635381b chore(deps): update dependency sax to v1.6.0 2026-03-18 01:26:06 +00:00
renovate[bot]
f20af8cac9 chore(deps): update dependency wxt to v0.20.20 2026-03-18 01:25:25 +00:00
renovate[bot]
29f3b987aa chore(deps): update dependency electron to v41.0.3 2026-03-18 01:24:43 +00:00
argusagent
e9987b40e6 fix(share): wire assertShareDbReady into router middleware — address code review 2026-03-17 20:27:04 -04:00
argusagent
1990a990c3 fix(share): return 503 when app is still initializing (#5677) 2026-03-17 20:22:06 -04:00
argusagent
d1159d3af9 fix(share): guard against uninitialized DB connection on /share routes (#5677) 2026-03-17 20:22:05 -04:00
JYC333
723dada78a chore(deps): update typescript-eslint monorepo to v8.57.1 (#9080) 2026-03-17 21:56:25 +00:00
JYC333
0e089af677 chore(deps): update dependency @smithy/middleware-retry to v4.4.43 (#9079) 2026-03-17 20:47:42 +00:00
renovate[bot]
f4aed5d012 chore(deps): update typescript-eslint monorepo to v8.57.1 2026-03-17 20:42:50 +00:00
Elian Doran
860f953962 chore(deps): update dependency @redocly/cli to v2.22.1 (#9081) 2026-03-17 22:37:46 +02:00
Elian Doran
ded692ead7 chore(deps): update ckeditor5 config packages to v14 (major) (#9082) 2026-03-17 22:37:20 +02:00
renovate[bot]
4f5413ebbe chore(deps): update ckeditor5 config packages to v14 2026-03-17 01:14:47 +00:00
renovate[bot]
8f3e210740 chore(deps): update dependency @redocly/cli to v2.22.1 2026-03-17 01:14:03 +00:00
renovate[bot]
783cb8b4e9 chore(deps): update dependency @smithy/middleware-retry to v4.4.43 2026-03-17 01:12:33 +00:00
Mystler
2b94d96930 fix(labels): Code review issue 2026-03-16 18:21:08 +01:00
Elian Doran
ca349e03f2 feat(editor): add catppuccin theme to highlightjs (#9075) 2026-03-16 18:39:40 +02:00
Mystler
5b5222b846 feat(labels): Add textarea label type with Table support 2026-03-16 17:07:37 +01:00
Giulia Ye
850f8ad939 feat(editor): make theme selector scoped to code tag replace regex more robust
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
2026-03-16 11:55:06 +01:00
Giulia Ye
50e5f89e9a feat(editor): make theme selector scoped to code tag regex more robust
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
2026-03-16 11:54:14 +01:00
giuxtaposition
603b47f9b0 feat(editor): add catppuccin theme to highlightjs 2026-03-16 10:35:49 +01:00
Elian Doran
92227c364e chore(deps): update dependency @preact/preset-vite to v2.10.4 (#9070) 2026-03-16 08:05:58 +02:00
Elian Doran
10ac18a7cc chore(deps): update dependency webdriverio to v9.26.1 (#9071) 2026-03-16 08:04:54 +02:00
Elian Doran
e06123e4bd chore(deps): update softprops/action-gh-release action to v2.6.1 (#9072) 2026-03-16 08:04:23 +02:00
Elian Doran
b44bd544cd chore(deps): update dependency node-abi to v4.28.0 (#9073) 2026-03-16 08:01:45 +02:00
renovate[bot]
4c3a448330 chore(deps): update softprops/action-gh-release action to v2.6.1 2026-03-16 01:31:50 +00:00
renovate[bot]
7f07c249af chore(deps): update dependency node-abi to v4.28.0 2026-03-16 01:31:44 +00:00
renovate[bot]
51958d2ac0 chore(deps): update dependency webdriverio to v9.26.1 2026-03-16 00:10:44 +00:00
renovate[bot]
67f474d794 chore(deps): update dependency @preact/preset-vite to v2.10.4 2026-03-16 00:10:12 +00:00
Adorian Doran
e6e8ebd881 pdf.js: add ability to comment selected text (#9068) 2026-03-16 02:08:31 +02:00
Elian Doran
b138fedd35 CSRF fixes (#9067) 2026-03-15 20:13:46 +02:00
contributor
a92d846b57 pdf.js: add ability to comment selected text 2026-03-15 20:05:59 +02:00
Elian Doran
7a544482d1 chore(server): request bootstrap with no cache 2026-03-15 19:39:27 +02:00
Elian Doran
53739ee8d4 e2e(server): address flaky test 2026-03-15 19:33:21 +02:00
Elian Doran
495145e033 chore(server): use random UUID for session ID 2026-03-15 19:33:06 +02:00
Elian Doran
6701d09df5 feat(client): refresh CSRF if request fails 2026-03-15 19:02:28 +02:00
Elian Doran
e36d7121f1 fix(desktop): broken due to CSRF failing 2026-03-15 18:54:37 +02:00
JYC333
9290a60b23 chore(deps): update dependency csrf-csrf to v4.0.3 (#9061) 2026-03-15 15:08:17 +00:00
Elian Doran
761de79a8c chore(deps): update dependency eslint-plugin-playwright to v2.10.0 (#9064) 2026-03-15 16:37:03 +02:00
Elian Doran
b8e9beff1b chore(deps): update dependency lint-staged to v16.4.0 (#9065) 2026-03-15 16:23:52 +02:00
Elian Doran
5b13e0ba4f chore(deps): update softprops/action-gh-release action to v2.5.3 (#9063) 2026-03-15 16:23:07 +02:00
Elian Doran
b0bab18d00 chore(deps): update dependency wxt to v0.20.19 (#9062) 2026-03-15 16:21:31 +02:00
Elian Doran
b4fa1392de Translations update from Hosted Weblate (#9066) 2026-03-15 16:07:45 +02:00
Elian Doran
4e58002e13 Apply suggestions from code review
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
2026-03-15 16:07:18 +02:00
Aindriú Mac Giolla Eoin
adc149aac8 Translated using Weblate (Irish)
Currently translated at 100.0% (1719 of 1719 strings)

Translation: Trilium Notes/Client
Translate-URL: https://hosted.weblate.org/projects/trilium/client/ga/
2026-03-15 11:09:59 +00:00
Marcel
4c02773ddc Translated using Weblate (German)
Currently translated at 100.0% (1719 of 1719 strings)

Translation: Trilium Notes/Client
Translate-URL: https://hosted.weblate.org/projects/trilium/client/de/
2026-03-15 11:09:56 +00:00
green
892abe1d70 Translated using Weblate (Japanese)
Currently translated at 100.0% (158 of 158 strings)

Translation: Trilium Notes/Website
Translate-URL: https://hosted.weblate.org/projects/trilium/website/ja/
2026-03-15 11:09:54 +00:00
green
71c23d33ff Translated using Weblate (Japanese)
Currently translated at 100.0% (1719 of 1719 strings)

Translation: Trilium Notes/Client
Translate-URL: https://hosted.weblate.org/projects/trilium/client/ja/
2026-03-15 11:09:52 +00:00
msnx0
9c110e896e Translated using Weblate (Polish)
Currently translated at 100.0% (1719 of 1719 strings)

Translation: Trilium Notes/Client
Translate-URL: https://hosted.weblate.org/projects/trilium/client/pl/
2026-03-15 11:09:50 +00:00
renovate[bot]
afe7a748e1 chore(deps): update softprops/action-gh-release action to v2.5.3 2026-03-15 05:14:23 +00:00
renovate[bot]
325e582593 chore(deps): update dependency lint-staged to v16.4.0 2026-03-15 00:53:10 +00:00
renovate[bot]
ccebe6a423 chore(deps): update dependency eslint-plugin-playwright to v2.10.0 2026-03-15 00:52:28 +00:00
renovate[bot]
f7c92fa4b2 chore(deps): update dependency wxt to v0.20.19 2026-03-15 00:51:42 +00:00
renovate[bot]
d07c2d118f chore(deps): update dependency csrf-csrf to v4.0.3 2026-03-15 00:51:00 +00:00
Elian Doran
94a09edd1d Renovate/csrf csrf 4.x (#5831) 2026-03-15 00:19:23 +02:00
Elian Doran
f6f939c245 chore(server): address requested changes 2026-03-14 23:49:36 +02:00
Elian Doran
0d889426e8 refactor(server): use different approach to handling the CSRF token 2026-03-14 23:48:06 +02:00
Elian Doran
c8a546ef1e fix(server): uninitialized sessions causing bad CSRF errors 2026-03-14 23:31:17 +02:00
Elian Doran
693919b21a Merge remote-tracking branch 'origin/main' into renovate/csrf-csrf-4.x 2026-03-14 22:48:43 +02:00
Elian Doran
7c1a2039b1 feat(editor): add catppuccin theme to codemirror (#9060) 2026-03-14 22:05:50 +02:00
Elian Doran
c66e4e0475 pdf.js floating highlight button (#9048) 2026-03-14 22:03:55 +02:00
Elian Doran
6bdfbf0d7d chore(deps): fix package lock 2026-03-14 21:52:55 +02:00
Giulia Ye
61393bca90 fix(editor): catppuccin theme declared following alphabetical order based by id
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
2026-03-14 16:03:03 +01:00
giuxtaposition
c41b649bff feat(editor): add catppuccin theme to codemirror 2026-03-14 15:58:37 +01:00
Elian Doran
ba87487714 Space mobile launcher container evenly (#9031) 2026-03-14 13:49:20 +02:00
Elian Doran
3e73f38ae2 chore(deps): update dependency vite to v8 (#9043) 2026-03-14 13:45:25 +02:00
Elian Doran
51dd55c3fd Merge remote-tracking branch 'origin/main' into renovate/vite-8.x
; Conflicts:
;	pnpm-lock.yaml
2026-03-14 12:54:04 +02:00
Elian Doran
de49ca37b9 fix(deps): update ckeditor monorepo (#8884) 2026-03-14 12:51:11 +02:00
Elian Doran
8d8080ee09 Merge remote-tracking branch 'origin/main' into renovate/ckeditor-monorepo
; Conflicts:
;	pnpm-lock.yaml
2026-03-14 12:38:35 +02:00
Elian Doran
f3613ccb25 chore(client): typecheck failing due to changes in JSX handling 2026-03-14 12:35:44 +02:00
Elian Doran
ad7b5700f3 chore(client): tests not running due to change in Vite 2026-03-14 12:29:57 +02:00
Elian Doran
0d17c62d02 chore(client): remove deprecated vite manual chunks 2026-03-14 12:15:43 +02:00
Elian Doran
826690982a chore(deps): update dependency pdfjs-dist to v5.5.207 (#8874) 2026-03-14 12:10:41 +02:00
Elian Doran
b438ff9c62 chore(deps): update dependency electron to v41 (#9025) 2026-03-14 12:08:15 +02:00
Elian Doran
43fb9d1a23 chore(deps): update docker/setup-buildx-action action to v4 (#8931) 2026-03-14 12:07:53 +02:00
Elian Doran
fb17ce8c8a Merge remote-tracking branch 'origin/main' into renovate/ckeditor-monorepo
; Conflicts:
;	pnpm-lock.yaml
2026-03-14 12:06:40 +02:00
Elian Doran
3a8e12535e fix(ckeditor5): version misalignment 2026-03-14 12:04:32 +02:00
Elian Doran
ce0caa3f6d chore(deps): update dependency @smithy/middleware-retry to v4.4.42 (#9035) 2026-03-14 12:00:14 +02:00
Elian Doran
00a0315f12 chore(pdfjs): fix type error after update 2026-03-14 11:59:57 +02:00
renovate[bot]
da38d56dc7 chore(deps): update docker/setup-buildx-action action to v4 2026-03-14 09:55:13 +00:00
renovate[bot]
83e47cba2c chore(deps): update dependency electron to v41 2026-03-14 09:54:14 +00:00
Elian Doran
f4d1eebed4 fix(deps): update dependency knockout to v3.5.2 (#8970) 2026-03-14 11:47:51 +02:00
Elian Doran
f27b394099 Merge remote-tracking branch 'origin/main' into renovate/ckeditor-monorepo
; Conflicts:
;	pnpm-lock.yaml
2026-03-14 11:47:16 +02:00
renovate[bot]
a66c9ccc1f chore(deps): update dependency @smithy/middleware-retry to v4.4.42 2026-03-14 09:45:48 +00:00
Elian Doran
0bc6a830c8 chore(pdfjs): update viewer to latest 2026-03-14 11:42:39 +02:00
Elian Doran
f3008b29af chore(deps): bump yauzl from 2.10.0 to 3.2.1 (#9047) 2026-03-14 11:33:15 +02:00
Elian Doran
5b16ff8be1 chore(client): fix type error after update of knockout 2026-03-14 11:32:44 +02:00
Elian Doran
86621e3388 fix(deps): update dependency reveal.js to v6 (#9028) 2026-03-14 11:30:40 +02:00
Elian Doran
1beb0668c3 fix(deps): update codemirror (#9039) 2026-03-14 11:30:21 +02:00
Elian Doran
34b09f90fb fix(deps): wrong ckeditor version 2026-03-14 11:24:49 +02:00
Elian Doran
a6f964925b chore(presentation): fix paths to themes 2026-03-14 11:17:21 +02:00
Elian Doran
196416bb9f chore(presentation): fix type issues 2026-03-14 11:15:04 +02:00
Elian Doran
1535db9f7d chore(presentation): remove now redundant type definitions 2026-03-14 11:13:50 +02:00
renovate[bot]
ae38ac4de8 fix(deps): update dependency knockout to v3.5.2 2026-03-14 09:11:59 +00:00
Elian Doran
e0aa8d8ecf fix(codemirror): version misalignment causing type errors 2026-03-14 11:09:48 +02:00
renovate[bot]
23c1eacf2b fix(deps): update ckeditor monorepo 2026-03-14 09:03:13 +00:00
contributor
10e28789e2 add optional chaining to access window.parent in callback 2026-03-14 11:03:10 +02:00
contributor
940f7f77f5 add automatic removal of the event 2026-03-14 11:03:10 +02:00
renovate[bot]
83f8b4fcb4 fix(deps): update codemirror 2026-03-14 09:02:35 +00:00
Elian Doran
42dc801ddf fix(deps): update univer monorepo to v0.17.0 (#9057) 2026-03-14 11:01:08 +02:00
renovate[bot]
5e6e5bfbec chore(deps): update dependency vite to v8 2026-03-14 09:00:57 +00:00
Elian Doran
28fc99dd45 fix(deps): update dependency mermaid to v11.13.0 (#8988) 2026-03-14 10:59:16 +02:00
Elian Doran
9ef501c399 Mermaid diagram switcher (#9058) 2026-03-14 10:54:47 +02:00
Elian Doran
6bba908654 feat(mermaid): add new sample diagrams for Ishikawa & Venn 2026-03-14 10:54:33 +02:00
Elian Doran
d423e43312 Merge branch 'feature/mermaid_diagram_switcher' into renovate/mermaid-11.x 2026-03-14 10:50:33 +02:00
Elian Doran
91718f218b Merge remote-tracking branch 'origin/main' into renovate/mermaid-11.x 2026-03-14 10:50:18 +02:00
Elian Doran
e623e91a82 docs(user): mention changes to Mermaid diagrams 2026-03-14 10:44:55 +02:00
Elian Doran
dce9f50911 fix(mermaid): not recentering when using the sample switcher 2026-03-14 10:37:26 +02:00
Elian Doran
5f1486cf6a feat(mermaid): use custom placeholder 2026-03-14 10:31:28 +02:00
Elian Doran
2c6bdc79af chore(mermaid): rounded corners for editor only on desktop 2026-03-14 10:25:59 +02:00
Elian Doran
a6b89cfa30 chore(mermaid): use translations for sample names 2026-03-14 10:22:35 +02:00
Elian Doran
21d1cd395b feat(mermaid): add a text for sample diagram switcher 2026-03-14 10:14:21 +02:00
Elian Doran
981466cbe8 fix(deps): update dependency better-sqlite3 to v12.8.0 (#9056) 2026-03-14 10:08:38 +02:00
Elian Doran
0209573fce chore(mermaid): remove default placeholder content 2026-03-14 10:03:15 +02:00
Elian Doran
92f8459f28 feat(mermaid): show switcher only when note is empty 2026-03-14 10:02:05 +02:00
Elian Doran
da193b456b fix(mermaid): error when diagram is empty 2026-03-14 10:00:18 +02:00
Elian Doran
6c151afca3 fix(mermaid): error text not selectable 2026-03-14 09:58:45 +02:00
Elian Doran
aba6750c18 chore(mermaid): add rounded corners to code editor 2026-03-14 09:44:06 +02:00
Elian Doran
b9a8e4e4ba feat(mermaid): add all official samples 2026-03-14 09:42:35 +02:00
Elian Doran
4134c4ddd0 feat(mermaid): replace note content on switch 2026-03-14 09:29:28 +02:00
Elian Doran
72038fb2ec chore(mermaid): basic logic for content switcher 2026-03-14 09:26:14 +02:00
Elian Doran
069d8b1ae4 refactor(mermaid): move into own directory 2026-03-14 09:20:07 +02:00
Elian Doran
ce71068f6d chore(mermaid): add a bottom section for switching between samples 2026-03-14 09:18:38 +02:00
renovate[bot]
dc298a44e1 fix(deps): update univer monorepo to v0.17.0 2026-03-14 06:54:06 +00:00
renovate[bot]
306bfd7673 fix(deps): update dependency better-sqlite3 to v12.8.0 2026-03-14 06:53:12 +00:00
Elian Doran
25cf23f507 chore(deps): update dependency http-proxy-agent to v8 (#9026) 2026-03-14 08:39:04 +02:00
Elian Doran
096d5f7c65 chore: remove old references to svelte 2026-03-14 08:06:46 +02:00
Elian Doran
0e2dee1609 chore(renovate): group univerjs packages 2026-03-14 08:05:50 +02:00
Elian Doran
ec927d25a9 chore(deps): update dependency @redocly/cli to v2.21.1 (#8905) 2026-03-14 07:44:45 +02:00
renovate[bot]
7c8aefb4ef chore(deps): update dependency http-proxy-agent to v8 2026-03-14 05:44:33 +00:00
Elian Doran
e840769dd6 fix(deps): update dependency react-i18next to v16.5.8 (#9014) 2026-03-14 07:44:00 +02:00
Elian Doran
4a5d3f01b8 chore(deps): update dependency node-abi to v4.27.0 (#9015) 2026-03-14 07:43:26 +02:00
Elian Doran
71d975f339 fix(deps): update dependency force-graph to v1.51.2 (#9050) 2026-03-14 07:42:10 +02:00
Elian Doran
a4051fc372 chore(deps): update pnpm to v10.32.1 (#9012) 2026-03-14 07:41:44 +02:00
Elian Doran
359b2a68b8 chore(deps): update dependency https-proxy-agent to v8 (#9027) 2026-03-14 07:41:11 +02:00
Elian Doran
8124e4e589 chore(deps): update dependency electron to v40.8.2 (#9049) 2026-03-14 07:40:06 +02:00
Elian Doran
5f699996f8 chore(deps): update dependency rollup-plugin-webpack-stats to v3.1.0 (#9051) 2026-03-14 07:35:09 +02:00
Elian Doran
c7c0bc4185 chore(deps): update marocchino/sticky-pull-request-comment action to v3 (#9053) 2026-03-14 07:34:47 +02:00
Elian Doran
d422ac7bc5 chore(deps): update dependency vite-plugin-static-copy to v3.3.0 (#9052) 2026-03-14 07:33:52 +02:00
Elian Doran
0bd912d18a Translations update from Hosted Weblate (#9054) 2026-03-14 07:33:19 +02:00
Ulices
252f2fe72c Translated using Weblate (Spanish)
Currently translated at 100.0% (1693 of 1693 strings)

Translation: Trilium Notes/Client
Translate-URL: https://hosted.weblate.org/projects/trilium/client/es/
2026-03-14 06:09:49 +01:00
renovate[bot]
7f29c347e2 chore(deps): update marocchino/sticky-pull-request-comment action to v3 2026-03-14 00:40:57 +00:00
renovate[bot]
7a3dc824d6 chore(deps): update dependency vite-plugin-static-copy to v3.3.0 2026-03-14 00:40:47 +00:00
renovate[bot]
8550c62771 chore(deps): update dependency rollup-plugin-webpack-stats to v3.1.0 2026-03-14 00:39:43 +00:00
renovate[bot]
66cd657cd8 fix(deps): update dependency force-graph to v1.51.2 2026-03-14 00:38:45 +00:00
renovate[bot]
beac80e175 chore(deps): update dependency electron to v40.8.2 2026-03-14 00:37:41 +00:00
contributor
5ae9952ba1 use pagehide event instead of unload 2026-03-14 01:30:59 +02:00
contributor
d4bc1ec444 add typings 2026-03-14 01:24:50 +02:00
contributor
d52f529b24 extract handler setup into a function 2026-03-14 01:24:50 +02:00
contributor
9a9cfdec2b add unload handler 2026-03-14 01:24:50 +02:00
contributor
6ab421ffa0 check target iframe 2026-03-14 01:24:50 +02:00
contributor
53b0aafb98 disable preferences warning 2026-03-14 01:24:49 +02:00
contributor
6b02ad8421 enable floating highlight button 2026-03-14 01:24:43 +02:00
renovate[bot]
242ebfccc0 chore(deps): update dependency https-proxy-agent to v8 2026-03-13 22:26:27 +00:00
renovate[bot]
545cc0782f fix(deps): update dependency react-i18next to v16.5.8 2026-03-13 22:24:39 +00:00
renovate[bot]
bf6a2917cd fix(deps): update dependency reveal.js to v6 2026-03-13 22:22:26 +00:00
renovate[bot]
eaba2a8395 fix(deps): update dependency mermaid to v11.13.0 2026-03-13 22:19:14 +00:00
Elian Doran
c581fb17bc chore(deps): update dependency @ckeditor/ckeditor5-dev-build-tools to v55 (#9042) 2026-03-14 00:14:41 +02:00
renovate[bot]
9b05b95d77 chore(deps): update dependency pdfjs-dist to v5.5.207 2026-03-13 22:12:07 +00:00
renovate[bot]
b3ba18ddd0 chore(deps): update dependency node-abi to v4.27.0 2026-03-13 22:11:25 +00:00
renovate[bot]
bb2a633ba7 chore(deps): update dependency @redocly/cli to v2.21.1 2026-03-13 22:10:44 +00:00
renovate[bot]
913efdef03 chore(deps): update pnpm to v10.32.1 2026-03-13 22:07:56 +00:00
Elian Doran
bf0bea18b1 fix(deps): update dependency i18next to v25.8.18 (#9013) 2026-03-14 00:06:31 +02:00
Elian Doran
cdebd1f63a chore(deps): update dependency esbuild to v0.27.4 (#9037) 2026-03-14 00:06:07 +02:00
Elian Doran
a6a2635836 chore(deps): update dependency happy-dom to v20.8.4 (#9038) 2026-03-14 00:05:38 +02:00
dependabot[bot]
024b57c2b4 chore(deps): bump yauzl from 2.10.0 to 3.2.1
Bumps [yauzl](https://github.com/thejoshwolfe/yauzl) from 2.10.0 to 3.2.1.
- [Commits](https://github.com/thejoshwolfe/yauzl/compare/2.10.0...3.2.1)

---
updated-dependencies:
- dependency-name: yauzl
  dependency-version: 3.2.1
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
2026-03-13 20:13:10 +00:00
renovate[bot]
6fbc85cbc7 chore(deps): update dependency @ckeditor/ckeditor5-dev-build-tools to v55 2026-03-13 05:51:53 +00:00
renovate[bot]
5f8a0aee13 chore(deps): update dependency happy-dom to v20.8.4 2026-03-13 05:47:50 +00:00
renovate[bot]
0c67b292ef chore(deps): update dependency esbuild to v0.27.4 2026-03-13 05:46:42 +00:00
Elian Doran
ba663e6162 chore(deps): update dependency electron to v40.8.1 (#9036) 2026-03-13 07:42:35 +02:00
Elian Doran
14925266cf fix(deps): update dependency dayjs to v1.11.20 (#9040) 2026-03-13 07:41:36 +02:00
Elian Doran
702e29bd8c chore(deps): update vitest monorepo to v4.1.0 (#9041) 2026-03-13 07:41:10 +02:00
Elian Doran
27ac3e58c5 fix(deps): update dependency sqlite3 to v6 (#9044) 2026-03-13 07:40:07 +02:00
Elian Doran
86e268c06d Translations update from Hosted Weblate (#9046) 2026-03-13 07:39:12 +02:00
Ulices
6e4b231319 Translated using Weblate (Spanish)
Currently translated at 99.2% (1681 of 1693 strings)

Translation: Trilium Notes/Client
Translate-URL: https://hosted.weblate.org/projects/trilium/client/es/
2026-03-13 05:09:49 +01:00
green
041eff6cbd Translated using Weblate (Japanese)
Currently translated at 100.0% (1693 of 1693 strings)

Translation: Trilium Notes/Client
Translate-URL: https://hosted.weblate.org/projects/trilium/client/ja/
2026-03-13 05:09:48 +01:00
renovate[bot]
1a3471a516 fix(deps): update dependency sqlite3 to v6 2026-03-13 01:10:11 +00:00
renovate[bot]
57c8727bb1 chore(deps): update vitest monorepo to v4.1.0 2026-03-13 01:06:52 +00:00
renovate[bot]
bd451d0738 fix(deps): update dependency dayjs to v1.11.20 2026-03-13 01:05:48 +00:00
renovate[bot]
ced062842d chore(deps): update dependency electron to v40.8.1 2026-03-13 01:01:51 +00:00
Mystler
f7067fb968 fix(mobile): Space mobile launcher container evenly 2026-03-12 19:24:27 +01:00
renovate[bot]
309a81a0fe fix(deps): update dependency i18next to v25.8.18 2026-03-12 01:14:10 +00:00
Elian Doran
a3a3b3cb5c Merge remote-tracking branch 'origin/main' into renovate/csrf-csrf-4.x 2025-07-26 15:49:50 +03:00
Jon Fuller
d4aaf4ca9b Merge branch 'develop' into renovate/csrf-csrf-4.x 2025-06-11 12:44:51 -07:00
Elian Doran
e7450b5143 Merge branch 'develop' into renovate/csrf-csrf-4.x 2025-06-08 14:31:55 +03:00
Elian Doran
fd90454eb6 Merge branch 'develop' into renovate/csrf-csrf-4.x 2025-05-17 09:51:02 +03:00
Elian Doran
f327b54c0e feat(csrf): use different token to avoid issues with old token 2025-05-16 19:45:32 +03:00
Elian Doran
f38105ef05 Merge remote-tracking branch 'origin/develop' into renovate/csrf-csrf-4.x 2025-05-16 19:34:19 +03:00
Elian Doran
6f6041ee7b fix(server): migrate csrf to v4 2025-05-15 20:39:31 +03:00
renovate[bot]
2c1517d259 chore(deps): update dependency csrf-csrf to v4 2025-05-15 16:12:11 +00:00
184 changed files with 11923 additions and 9639 deletions

View File

@@ -8,7 +8,7 @@ inputs:
runs:
using: composite
steps:
- uses: pnpm/action-setup@v4
- uses: pnpm/action-setup@v5
- name: Set up node & dependencies
uses: actions/setup-node@v6
with:

View File

@@ -69,7 +69,7 @@ runs:
# Post github action comment
- name: Post comment
uses: marocchino/sticky-pull-request-comment@v2
uses: marocchino/sticky-pull-request-comment@v3
if: ${{ steps.bundleSize.outputs.hasDifferences == 'true' }} # post only in case of changes
with:
number: ${{ github.event.pull_request.number }}

View File

@@ -45,7 +45,7 @@ jobs:
uses: actions/checkout@v6
- name: Setup pnpm
uses: pnpm/action-setup@v4
uses: pnpm/action-setup@v5
- name: Setup Node.js
uses: actions/setup-node@v6

View File

@@ -26,7 +26,7 @@ jobs:
- name: Checkout the repository
uses: actions/checkout@v6
- uses: pnpm/action-setup@v4
- uses: pnpm/action-setup@v5
- name: Set up node & dependencies
uses: actions/setup-node@v6
with:
@@ -74,7 +74,7 @@ jobs:
- test_dev
steps:
- uses: actions/checkout@v6
- uses: pnpm/action-setup@v4
- uses: pnpm/action-setup@v5
- name: Install dependencies
run: pnpm install --frozen-lockfile
- name: Update build info
@@ -89,7 +89,7 @@ jobs:
key: ${{ secrets.RELATIVE_CI_CLIENT_KEY }}
- name: Trigger server build
run: pnpm run server:build
- uses: docker/setup-buildx-action@v3
- uses: docker/setup-buildx-action@v4
- uses: docker/build-push-action@v7
with:
context: apps/server
@@ -109,7 +109,7 @@ jobs:
- name: Checkout the repository
uses: actions/checkout@v6
- uses: pnpm/action-setup@v4
- uses: pnpm/action-setup@v5
- name: Install dependencies
run: pnpm install --frozen-lockfile
@@ -124,7 +124,7 @@ jobs:
run: echo "TEST_TAG=${TEST_TAG,,}" >> $GITHUB_ENV
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
uses: docker/setup-buildx-action@v4
- name: Build and export to Docker
uses: docker/build-push-action@v7

View File

@@ -18,7 +18,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- uses: pnpm/action-setup@v4
- uses: pnpm/action-setup@v5
- name: Set up node & dependencies
uses: actions/setup-node@v6
with:

View File

@@ -40,9 +40,9 @@ jobs:
run: echo "TEST_TAG=${TEST_TAG,,}" >> $GITHUB_ENV
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
uses: docker/setup-buildx-action@v4
- uses: pnpm/action-setup@v4
- uses: pnpm/action-setup@v5
- name: Set up node & dependencies
uses: actions/setup-node@v6
with:
@@ -142,7 +142,7 @@ jobs:
- name: Checkout repository
uses: actions/checkout@v6
- uses: pnpm/action-setup@v4
- uses: pnpm/action-setup@v5
- name: Set up node & dependencies
uses: actions/setup-node@v6
with:
@@ -178,7 +178,7 @@ jobs:
uses: docker/setup-qemu-action@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
uses: docker/setup-buildx-action@v4
- name: Login to GHCR
uses: docker/login-action@v4

View File

@@ -61,7 +61,7 @@ jobs:
runs-on: ${{ matrix.os.image }}
steps:
- uses: actions/checkout@v6
- uses: pnpm/action-setup@v4
- uses: pnpm/action-setup@v5
- name: Set up node & dependencies
uses: actions/setup-node@v6
with:
@@ -91,7 +91,7 @@ jobs:
GPG_SIGNING_KEY: ${{ secrets.GPG_SIGN_KEY }}
- name: Publish release
uses: softprops/action-gh-release@v2.5.0
uses: softprops/action-gh-release@v2.6.1
if: ${{ github.event_name != 'pull_request' }}
with:
make_latest: false
@@ -132,7 +132,7 @@ jobs:
arch: ${{ matrix.arch }}
- name: Publish release
uses: softprops/action-gh-release@v2.5.0
uses: softprops/action-gh-release@v2.6.1
if: ${{ github.event_name != 'pull_request' }}
with:
make_latest: false

View File

@@ -38,7 +38,7 @@ jobs:
filter: tree:0
fetch-depth: 0
- uses: pnpm/action-setup@v4
- uses: pnpm/action-setup@v5
- uses: actions/setup-node@v6
with:
node-version: 24

View File

@@ -17,7 +17,7 @@ jobs:
steps:
- uses: actions/checkout@v6
- uses: pnpm/action-setup@v4
- uses: pnpm/action-setup@v5
- name: Set up node & dependencies
uses: actions/setup-node@v6
with:
@@ -66,7 +66,7 @@ jobs:
runs-on: ${{ matrix.os.image }}
steps:
- uses: actions/checkout@v6
- uses: pnpm/action-setup@v4
- uses: pnpm/action-setup@v5
- name: Set up node & dependencies
uses: actions/setup-node@v6
with:
@@ -150,7 +150,7 @@ jobs:
path: upload
- name: Publish stable release
uses: softprops/action-gh-release@v2.5.0
uses: softprops/action-gh-release@v2.6.1
with:
draft: false
body_path: docs/Release Notes/Release Notes/${{ github.ref_name }}.md

View File

@@ -32,7 +32,7 @@ jobs:
steps:
- uses: actions/checkout@v6
- uses: pnpm/action-setup@v4
- uses: pnpm/action-setup@v5
- name: Set up node & dependencies
uses: actions/setup-node@v6
with:
@@ -58,7 +58,7 @@ jobs:
compression-level: 0
- name: Release web clipper extension
uses: softprops/action-gh-release@v2.5.0
uses: softprops/action-gh-release@v2.6.1
if: ${{ startsWith(github.ref, 'refs/tags/web-clipper-v') }}
with:
draft: false

View File

@@ -26,7 +26,7 @@ jobs:
steps:
- uses: actions/checkout@v6
- uses: pnpm/action-setup@v4
- uses: pnpm/action-setup@v5
- name: Set up node & dependencies
uses: actions/setup-node@v6
with:

1
.gitignore vendored
View File

@@ -46,7 +46,6 @@ upload
/.direnv
/result
.svelte-kit
# docs
site/

View File

@@ -14,9 +14,9 @@
"keywords": [],
"author": "Elian Doran <contact@eliandoran.me>",
"license": "AGPL-3.0-only",
"packageManager": "pnpm@10.32.0",
"packageManager": "pnpm@10.32.1",
"devDependencies": {
"@redocly/cli": "2.20.2",
"@redocly/cli": "2.24.1",
"archiver": "7.0.1",
"fs-extra": "11.3.4",
"js-yaml": "4.1.1",

View File

@@ -35,15 +35,15 @@
"@triliumnext/highlightjs": "workspace:*",
"@triliumnext/share-theme": "workspace:*",
"@triliumnext/split.js": "workspace:*",
"@univerjs/preset-sheets-conditional-formatting": "0.16.1",
"@univerjs/preset-sheets-core": "0.16.1",
"@univerjs/preset-sheets-data-validation": "0.16.1",
"@univerjs/preset-sheets-filter": "0.16.1",
"@univerjs/preset-sheets-find-replace": "0.16.1",
"@univerjs/preset-sheets-note": "0.16.1",
"@univerjs/preset-sheets-sort": "0.16.1",
"@univerjs/presets": "0.16.1",
"@zumer/snapdom": "2.1.0",
"@univerjs/preset-sheets-conditional-formatting": "0.18.0",
"@univerjs/preset-sheets-core": "0.18.0",
"@univerjs/preset-sheets-data-validation": "0.18.0",
"@univerjs/preset-sheets-filter": "0.18.0",
"@univerjs/preset-sheets-find-replace": "0.18.0",
"@univerjs/preset-sheets-note": "0.18.0",
"@univerjs/preset-sheets-sort": "0.18.0",
"@univerjs/presets": "0.18.0",
"@zumer/snapdom": "2.5.0",
"autocomplete.js": "0.38.1",
"bootstrap": "5.3.8",
"boxicons": "2.1.4",
@@ -51,27 +51,26 @@
"color": "5.0.3",
"debounce": "3.0.0",
"draggabilly": "3.0.0",
"force-graph": "1.51.1",
"force-graph": "1.51.2",
"globals": "17.4.0",
"i18next": "25.8.17",
"i18next": "25.10.3",
"i18next-http-backend": "3.0.2",
"jquery": "4.0.0",
"jquery.fancytree": "2.38.5",
"jsplumb": "2.15.6",
"katex": "0.16.38",
"knockout": "3.5.1",
"katex": "0.16.40",
"leaflet": "1.9.4",
"leaflet-gpx": "2.2.0",
"mark.js": "8.11.1",
"marked": "17.0.4",
"mermaid": "11.12.3",
"marked": "17.0.5",
"mermaid": "11.13.0",
"mind-elixir": "5.9.3",
"normalize.css": "8.0.1",
"panzoom": "9.4.3",
"preact": "10.29.0",
"react-i18next": "16.5.6",
"react-i18next": "16.6.0",
"react-window": "2.2.7",
"reveal.js": "5.2.1",
"reveal.js": "6.0.0",
"rrule": "2.8.1",
"svg-pan-zoom": "3.6.2",
"tabulator-tables": "6.4.0",
@@ -85,12 +84,11 @@
"@types/leaflet": "1.9.21",
"@types/leaflet-gpx": "1.3.8",
"@types/mark.js": "8.11.12",
"@types/reveal.js": "5.2.2",
"@types/tabulator-tables": "6.3.1",
"copy-webpack-plugin": "14.0.0",
"happy-dom": "20.8.3",
"happy-dom": "20.8.4",
"lightningcss": "1.32.0",
"script-loader": "0.7.2",
"vite-plugin-static-copy": "3.2.0"
"vite-plugin-static-copy": "3.3.0"
}
}
}

View File

@@ -67,14 +67,6 @@ async function createNote(parentNotePath: string | undefined, options: CreateNot
const parentNoteId = treeService.getNoteIdFromUrl(parentNotePath);
if (options.type === "mermaid" && !options.content && !options.templateNoteId) {
options.content = `graph TD;
A-->B;
A-->C;
B-->D;
C-->D;`;
}
const { note, branch } = await server.post<Response>(`notes/${parentNoteId}/children?target=${options.target}&targetBranchId=${options.targetBranchId || ""}`, {
title: options.title,
content: options.content || "",

View File

@@ -1,4 +1,4 @@
export type LabelType = "text" | "number" | "boolean" | "date" | "datetime" | "time" | "url" | "color";
export type LabelType = "text" | "textarea" | "number" | "boolean" | "date" | "datetime" | "time" | "url" | "color";
type Multiplicity = "single" | "multi";
export interface DefinitionObject {
@@ -17,7 +17,7 @@ function parse(value: string) {
for (const token of tokens) {
if (token === "promoted") {
defObj.isPromoted = true;
} else if (["text", "number", "boolean", "date", "datetime", "time", "url", "color"].includes(token)) {
} else if (["text", "textarea", "number", "boolean", "date", "datetime", "time", "url", "color"].includes(token)) {
defObj.labelType = token as LabelType;
} else if (["single", "multi"].includes(token)) {
defObj.multiplicity = token as Multiplicity;

View File

@@ -93,7 +93,7 @@ async function upload(url: string, fileToUpload: File, componentId?: string, met
const formData = new FormData();
formData.append("upload", fileToUpload);
return await $.ajax({
const doUpload = async () => $.ajax({
url: window.glob.baseApiUrl + url,
headers: await getHeaders(componentId ? {
"trilium-component-id": componentId
@@ -104,6 +104,18 @@ async function upload(url: string, fileToUpload: File, componentId?: string, met
contentType: false, // NEEDED, DON'T REMOVE THIS
processData: false // NEEDED, DON'T REMOVE THIS
});
try {
return await doUpload();
} catch (e: unknown) {
// jQuery rejects with the jqXHR object
const jqXhr = e as JQuery.jqXHR;
if (jqXhr?.status && isCsrfError(jqXhr.status, jqXhr.responseText)) {
await refreshCsrfToken();
return await doUpload();
}
throw e;
}
}
let idCounter = 1;
@@ -112,12 +124,55 @@ const idToRequestMap: Record<string, RequestData> = {};
let maxKnownEntityChangeId = 0;
let csrfRefreshInProgress: Promise<void> | null = null;
/**
* Re-fetches /bootstrap to obtain a fresh CSRF token. This is needed when the
* server session expires (e.g. mobile tab backgrounded for a long time) and the
* existing CSRF token is no longer valid.
*
* Coalesces concurrent calls so only one bootstrap request is in-flight at a time.
*/
async function refreshCsrfToken(): Promise<void> {
if (csrfRefreshInProgress) {
return csrfRefreshInProgress;
}
csrfRefreshInProgress = (async () => {
try {
const response = await fetch(`./bootstrap${window.location.search}`, { cache: "no-store" });
if (response.ok) {
const json = await response.json();
glob.csrfToken = json.csrfToken;
}
} finally {
csrfRefreshInProgress = null;
}
})();
return csrfRefreshInProgress;
}
function isCsrfError(status: number, responseText: string): boolean {
if (status !== 403) {
return false;
}
try {
const body = JSON.parse(responseText);
return body.message === "Invalid CSRF token";
} catch {
return false;
}
}
interface CallOptions {
data?: unknown;
silentNotFound?: boolean;
silentInternalServerError?: boolean;
// If `true`, the value will be returned as a string instead of a JavaScript object if JSON, XMLDocument if XML, etc.
raw?: boolean;
/** Used internally to prevent infinite retry loops on CSRF refresh. */
csrfRetried?: boolean;
}
async function call<T>(method: string, url: string, componentId?: string, options: CallOptions = {}) {
@@ -167,7 +222,7 @@ function ajax(url: string, method: string, data: unknown, headers: Headers, opts
type: method,
headers,
timeout: 60000,
success: (body, textStatus, jqXhr) => {
success: (body, _textStatus, jqXhr) => {
const respHeaders: Headers = {};
jqXhr
@@ -192,7 +247,25 @@ function ajax(url: string, method: string, data: unknown, headers: Headers, opts
// don't report requests that are rejected by the browser, usually when the user is refreshing or going to a different page.
rej("rejected by browser");
return;
} else if (opts.silentNotFound && jqXhr.status === 404) {
}
// If the CSRF token is stale (e.g. session expired while tab was backgrounded),
// refresh it and retry the request once.
if (!opts.csrfRetried && isCsrfError(jqXhr.status, jqXhr.responseText)) {
try {
await refreshCsrfToken();
// Rebuild headers so the fresh glob.csrfToken is picked up
const retryHeaders = await getHeaders({ "trilium-component-id": headers["trilium-component-id"] });
const retryResult = await ajax(url, method, data, retryHeaders, { ...opts, csrfRetried: true });
res(retryResult);
return;
} catch (retryErr) {
rej(retryErr);
return;
}
}
if (opts.silentNotFound && jqXhr.status === 404) {
// report nothing
} else if (opts.silentInternalServerError && jqXhr.status === 500) {
// report nothing

View File

@@ -1,66 +1,107 @@
import "jquery";
import utils from "./services/utils.js";
import ko from "knockout";
// TriliumNextTODO: properly make use of below types
// type SetupModelSetupType = "new-document" | "sync-from-desktop" | "sync-from-server" | "";
// type SetupModelStep = "sync-in-progress" | "setup-type" | "new-document-in-progress" | "sync-from-desktop";
type SetupStep = "sync-in-progress" | "setup-type" | "new-document-in-progress" | "sync-from-desktop" | "sync-from-server";
type SetupType = "new-document" | "sync-from-desktop" | "sync-from-server" | "";
class SetupModel {
syncInProgress: boolean;
step: ko.Observable<string>;
setupType: ko.Observable<string>;
setupNewDocument: ko.Observable<boolean>;
setupSyncFromDesktop: ko.Observable<boolean>;
setupSyncFromServer: ko.Observable<boolean>;
syncServerHost: ko.Observable<string | undefined>;
syncProxy: ko.Observable<string | undefined>;
password: ko.Observable<string | undefined>;
class SetupController {
private step: SetupStep;
private setupType: SetupType = "";
private syncPollIntervalId: number | null = null;
private rootNode: HTMLElement;
private setupTypeForm: HTMLFormElement;
private syncFromServerForm: HTMLFormElement;
private setupTypeNextButton: HTMLButtonElement;
private setupTypeInputs: HTMLInputElement[];
private syncServerHostInput: HTMLInputElement;
private syncProxyInput: HTMLInputElement;
private passwordInput: HTMLInputElement;
private sections: Record<SetupStep, HTMLElement>;
constructor(syncInProgress: boolean) {
this.syncInProgress = syncInProgress;
this.step = ko.observable(syncInProgress ? "sync-in-progress" : "setup-type");
this.setupType = ko.observable("");
this.setupNewDocument = ko.observable(false);
this.setupSyncFromDesktop = ko.observable(false);
this.setupSyncFromServer = ko.observable(false);
this.syncServerHost = ko.observable();
this.syncProxy = ko.observable();
this.password = ko.observable();
constructor(rootNode: HTMLElement, syncInProgress: boolean) {
this.rootNode = rootNode;
this.step = syncInProgress ? "sync-in-progress" : "setup-type";
this.setupTypeForm = mustGetElement("setup-type-form", HTMLFormElement);
this.syncFromServerForm = mustGetElement("sync-from-server-form", HTMLFormElement);
this.setupTypeNextButton = mustGetElement("setup-type-next", HTMLButtonElement);
this.setupTypeInputs = Array.from(document.querySelectorAll<HTMLInputElement>("input[name='setup-type']"));
this.syncServerHostInput = mustGetElement("sync-server-host", HTMLInputElement);
this.syncProxyInput = mustGetElement("sync-proxy", HTMLInputElement);
this.passwordInput = mustGetElement("password", HTMLInputElement);
this.sections = {
"setup-type": mustGetElement("setup-type-section", HTMLElement),
"new-document-in-progress": mustGetElement("new-document-in-progress-section", HTMLElement),
"sync-from-desktop": mustGetElement("sync-from-desktop-section", HTMLElement),
"sync-from-server": mustGetElement("sync-from-server-section", HTMLElement),
"sync-in-progress": mustGetElement("sync-in-progress-section", HTMLElement)
};
}
if (this.syncInProgress) {
setInterval(checkOutstandingSyncs, 1000);
init() {
this.setupTypeForm.addEventListener("submit", (event) => {
event.preventDefault();
void this.selectSetupType();
});
this.syncFromServerForm.addEventListener("submit", (event) => {
event.preventDefault();
void this.finish();
});
for (const input of this.setupTypeInputs) {
input.addEventListener("change", () => {
this.setupType = input.value as SetupType;
this.render();
});
}
for (const backButton of document.querySelectorAll<HTMLElement>("[data-action='back']")) {
backButton.addEventListener("click", () => {
this.back();
});
}
const serverAddress = `${location.protocol}//${location.host}`;
$("#current-host").html(serverAddress);
if (this.step === "sync-in-progress") {
this.startSyncPolling();
}
this.render();
this.rootNode.style.display = "";
}
// this is called in setup.ejs
setupTypeSelected() {
return !!this.setupType();
}
private async selectSetupType() {
if (this.setupType === "new-document") {
this.setStep("new-document-in-progress");
selectSetupType() {
if (this.setupType() === "new-document") {
this.step("new-document-in-progress");
await $.post("api/setup/new-document");
window.location.replace("./setup");
return;
}
$.post("api/setup/new-document").then(() => {
window.location.replace("./setup");
});
} else {
this.step(this.setupType());
if (this.setupType) {
this.setStep(this.setupType);
}
}
back() {
this.step("setup-type");
this.setupType("");
private back() {
this.setStep("setup-type");
this.setupType = "";
for (const input of this.setupTypeInputs) {
input.checked = false;
}
this.render();
}
async finish() {
const syncServerHost = this.syncServerHost();
const syncProxy = this.syncProxy();
const password = this.password();
private async finish() {
const syncServerHost = this.syncServerHostInput.value.trim();
const syncProxy = this.syncProxyInput.value.trim();
const password = this.passwordInput.value;
if (!syncServerHost) {
showAlert("Trilium server address can't be empty");
@@ -74,21 +115,44 @@ class SetupModel {
// not using server.js because it loads too many dependencies
const resp = await $.post("api/setup/sync-from-server", {
syncServerHost: syncServerHost,
syncProxy: syncProxy,
password: password
syncServerHost,
syncProxy,
password
});
if (resp.result === "success") {
this.step("sync-in-progress");
setInterval(checkOutstandingSyncs, 1000);
hideAlert();
this.setStep("sync-in-progress");
this.startSyncPolling();
} else {
showAlert(`Sync setup failed: ${resp.error}`);
}
}
private setStep(step: SetupStep) {
this.step = step;
this.render();
}
private render() {
for (const [step, section] of Object.entries(this.sections) as [SetupStep, HTMLElement][]) {
section.style.display = step === this.step ? "" : "none";
}
this.setupTypeNextButton.disabled = !this.setupType;
}
private getSelectedSetupType(): SetupType {
return (this.setupTypeInputs.find((input) => input.checked)?.value ?? "") as SetupType;
}
private startSyncPolling() {
if (this.syncPollIntervalId !== null) {
return;
}
this.syncPollIntervalId = window.setInterval(checkOutstandingSyncs, 1000);
}
}
async function checkOutstandingSyncs() {
@@ -122,7 +186,19 @@ function getSyncInProgress() {
return !!parseInt(el.content);
}
function mustGetElement<T extends typeof HTMLElement>(id: string, ctor: T): InstanceType<T> {
const element = document.getElementById(id);
if (!element || !(element instanceof ctor)) {
throw new Error(`Expected element #${id}`);
}
return element as InstanceType<T>;
}
addEventListener("DOMContentLoaded", (event) => {
ko.applyBindings(new SetupModel(getSyncInProgress()), document.getElementById("setup-dialog"));
$("#setup-dialog").show();
const rootNode = document.getElementById("setup-dialog");
if (!rootNode || !(rootNode instanceof HTMLElement)) return;
new SetupController(rootNode, getSyncInProgress()).init();
});

View File

@@ -1612,11 +1612,7 @@ body:not(.mobile) #launcher-pane.horizontal .dropdown-submenu > .dropdown-menu {
}
body.mobile #launcher-container {
justify-content: center;
}
body.mobile #launcher-container button {
margin: 0 16px;
justify-content: space-evenly;
}
body.mobile .modal.show {

View File

@@ -675,10 +675,11 @@ li.dropdown-item a.dropdown-item-button:focus-visible {
div.alert {
margin-bottom: 8px;
background: var(--alert-bar-background) !important;
color: var(--main-text-color);
border-radius: 8px;
font-size: .85em;
}
div.alert p + p {
margin-block: 1em 0;
}
}

View File

@@ -1069,7 +1069,6 @@
"rename_note": "اعادة تسمية الملاحظة",
"remove_relation": "حذف العلاقة",
"default_new_note_title": "ملاحظة جديدة",
"open_in_new_tab": "فتح في تبويب جديد",
"enter_new_title": "ادخل عنوان ملاحظة جديدة:",
"note_not_found": "الملاحظة {{noteId}} غير موجودة!",
"cannot_match_transform": "تعذر مطابقة التحويل: {{transform}}"

View File

@@ -1047,7 +1047,6 @@
"unprotecting-title": "解除保护状态"
},
"relation_map": {
"open_in_new_tab": "在新标签页中打开",
"remove_note": "删除笔记",
"edit_title": "编辑标题",
"rename_note": "重命名笔记",

View File

@@ -1046,7 +1046,6 @@
"unprotecting-title": "Ungeschützt-Status"
},
"relation_map": {
"open_in_new_tab": "In neuem Tab öffnen",
"remove_note": "Notiz entfernen",
"edit_title": "Titel bearbeiten",
"rename_note": "Notiz umbenennen",
@@ -2183,5 +2182,52 @@
},
"setup_form": {
"more_info": "Mehr erfahren"
},
"media": {
"play": "Abspielen (Arbeitsbereich)",
"pause": "Pausieren (Arbeitsbereich)",
"back-10s": "10 s zurück (Linke Pfeiltaste)",
"forward-30s": "30 s vorwärts",
"mute": "Stumm (M)",
"unmute": "Stummschaltung aufheben (M)",
"playback-speed": "Wiedergabegeschwindigkeit",
"loop": "Schleife",
"disable-loop": "Schleife deaktivieren",
"rotate": "Rotieren",
"picture-in-picture": "Bild-in-Bild",
"exit-picture-in-picture": "Bild-in-Bild verlassen",
"fullscreen": "Vollbild (F)",
"exit-fullscreen": "Vollbild verlassen",
"unsupported-format": "Medienvorschau ist für dieses Format nicht verfügbar:\n{{mime}}",
"zoom-to-fit": "Zoomen um auszufüllen",
"zoom-reset": "Zoomen um auszufüllen zurücksetzen"
},
"mermaid": {
"placeholder": "Geben den Inhalt des Mermaid-Diagramms ein oder verwenden eine der folgenden Beispieldiagramme.",
"sample_diagrams": "Beispieldiagramme:",
"sample_flowchart": "Flussdiagramm",
"sample_class": "Klasse",
"sample_sequence": "Abfolge",
"sample_entity_relationship": "Entität Beziehung",
"sample_state": "Zustandsübergangsdiagramm",
"sample_mindmap": "Mindmap",
"sample_architecture": "Architektur",
"sample_block": "Block",
"sample_c4": "C4",
"sample_gantt": "Gantt",
"sample_git": "GitGraph",
"sample_kanban": "Kanban",
"sample_packet": "Paket",
"sample_pie": "Kuchen",
"sample_quadrant": "Quadrant",
"sample_radar": "Radar",
"sample_requirement": "Anforderung",
"sample_sankey": "Sankey",
"sample_timeline": "Zeitstrahl",
"sample_treemap": "Kachel",
"sample_user_journey": "Benutzererfahrung",
"sample_xy": "XY",
"sample_venn": "Mengen",
"sample_ishikawa": "Ursache-Wirkung"
}
}

View File

@@ -1,6 +1,6 @@
{
"about": {
"title": "Πληροφορίες για το Trilium Notes",
"title": "Σχετικά με το Trilium Notes",
"homepage": "Αρχική Σελίδα:",
"app_version": "Έκδοση εφαρμογής:",
"db_version": "Έκδοση βάσης δεδομένων:",

View File

@@ -343,6 +343,7 @@
"label_type_title": "Type of the label will help Trilium to choose suitable interface to enter the label value.",
"label_type": "Type",
"text": "Text",
"textarea": "Multi-line Text",
"number": "Number",
"boolean": "Boolean",
"date": "Date",
@@ -1068,7 +1069,6 @@
"unprotecting-title": "Unprotecting status"
},
"relation_map": {
"open_in_new_tab": "Open in new tab",
"remove_note": "Remove note",
"edit_title": "Edit title",
"rename_note": "Rename note",
@@ -1292,10 +1292,6 @@
"erase_excess_revision_snapshots": "Erase excess revision snapshots now",
"erase_excess_revision_snapshots_prompt": "Excess revision snapshots have been erased."
},
"search": {
"title": "Search",
"enable_fuzzy_matching": "Enable fuzzy matching in search (matches similar words when exact matches are insufficient)"
},
"search_engine": {
"title": "Search Engine",
"custom_search_engine_info": "Custom search engine requires both a name and a URL to be set. If either of these is not set, DuckDuckGo will be used as the default search engine.",
@@ -2206,5 +2202,33 @@
},
"setup_form": {
"more_info": "Learn more"
},
"mermaid": {
"placeholder": "Type the content of your Mermaid diagram or use one of the sample diagrams below.",
"sample_diagrams": "Sample diagrams:",
"sample_flowchart": "Flowchart",
"sample_class": "Class",
"sample_sequence": "Sequence",
"sample_entity_relationship": "Entity Relationship",
"sample_state": "State",
"sample_mindmap": "Mindmap",
"sample_architecture": "Architecture",
"sample_block": "Block",
"sample_c4": "C4",
"sample_gantt": "Gantt",
"sample_git": "Git",
"sample_kanban": "Kanban",
"sample_packet": "Packet",
"sample_pie": "Pie",
"sample_quadrant": "Quadrant",
"sample_radar": "Radar",
"sample_requirement": "Requirement",
"sample_sankey": "Sankey",
"sample_timeline": "Timeline",
"sample_treemap": "Treemap",
"sample_user_journey": "User Journey",
"sample_xy": "XY",
"sample_venn": "Venn",
"sample_ishikawa": "Ishikawa"
}
}

View File

@@ -1051,7 +1051,6 @@
"unprotecting-title": "Estado de desprotección"
},
"relation_map": {
"open_in_new_tab": "Abrir en nueva pestaña",
"remove_note": "Quitar nota",
"edit_title": "Editar título",
"rename_note": "Cambiar nombre de nota",
@@ -2198,5 +2197,52 @@
},
"setup_form": {
"more_info": "Para saber más"
},
"media": {
"play": "Reproducir (Espacio)",
"pause": "Pausa (Espacio)",
"back-10s": "Retroceder 10s (tecla de flecha izquierda)",
"forward-30s": "Adelantar 30s",
"mute": "Silenciar (M)",
"unmute": "Activar sonido (M)",
"playback-speed": "Velocidad de reproducción",
"loop": "Bucle",
"disable-loop": "Deshabilitar bucle",
"rotate": "Rotar",
"picture-in-picture": "Imagen en imagen",
"exit-picture-in-picture": "Salir del modo imagen en imagen",
"fullscreen": "Pantalla completa (F)",
"exit-fullscreen": "Salir de la pantalla completa",
"unsupported-format": "La vista previa del medio no está disponible para este formato de archivo:\n{{mime}}",
"zoom-to-fit": "Acercamiento para llenar",
"zoom-reset": "Reiniciar acercamiento para llenar"
},
"mermaid": {
"placeholder": "Ingrese el contenido de su diagrama Mermaid o utilice uno de los diagramas de muestra a continuación.",
"sample_diagrams": "Diagramas de muestra:",
"sample_flowchart": "Diagrama de flujo",
"sample_class": "Clase",
"sample_sequence": "Secuencia",
"sample_entity_relationship": "Relación entre entidades",
"sample_state": "Estado",
"sample_mindmap": "Mapa mental",
"sample_architecture": "Arquitectura",
"sample_block": "Bloque",
"sample_c4": "C4",
"sample_gantt": "Gantt",
"sample_git": "Git",
"sample_kanban": "Kanban",
"sample_packet": "Paquete",
"sample_pie": "Pastel",
"sample_quadrant": "Cuadrante",
"sample_radar": "Radar",
"sample_requirement": "Requerimiento",
"sample_sankey": "Sankey",
"sample_timeline": "Línea de tiempo",
"sample_user_journey": "Jornada de usuario",
"sample_xy": "XY",
"sample_venn": "Venn",
"sample_ishikawa": "Ishikawa",
"sample_treemap": "Mapa de árbol"
}
}

View File

@@ -1036,7 +1036,6 @@
"unprotecting-title": "Statut de la non-protection"
},
"relation_map": {
"open_in_new_tab": "Ouvrir dans un nouvel onglet",
"remove_note": "Supprimer la note",
"edit_title": "Modifier le titre",
"rename_note": "Renommer la note",

View File

@@ -1055,7 +1055,6 @@
"unprotecting-title": "Stádas díchosanta"
},
"relation_map": {
"open_in_new_tab": "Oscail i gcluaisín nua",
"remove_note": "Bain nóta",
"edit_title": "Cuir an teideal in eagar",
"rename_note": "Athainmnigh an nóta",
@@ -2228,5 +2227,52 @@
},
"setup_form": {
"more_info": "Foghlaim níos mó"
},
"media": {
"play": "Seinn (Spás)",
"pause": "Sos (Spás)",
"back-10s": "10 soicind ar ais (eochair saighead chlé)",
"forward-30s": "Ar aghaidh 30s",
"mute": "Balbhaigh (M)",
"unmute": "Díbhalbhaigh (M)",
"playback-speed": "Luas athsheinm",
"loop": "Lúb",
"disable-loop": "Díchumasaigh an lúb",
"rotate": "Rothlaigh",
"picture-in-picture": "Pictiúr i bpictiúr",
"exit-picture-in-picture": "Scoir pictiúr-i-bpictiúr",
"fullscreen": "Lánscáileán (F)",
"exit-fullscreen": "Scoir lánscáileáin",
"unsupported-format": "Níl réamhamharc meán ar fáil don fhormáid comhaid seo:\n{{mime}}",
"zoom-to-fit": "Zúmáil chun líonadh",
"zoom-reset": "Athshocraigh súmáil chun líonadh"
},
"mermaid": {
"placeholder": "Clóscríobh ábhar do léaráid Maighdean Mhara nó bain úsáid as ceann de na léaráidí samplacha thíos.",
"sample_diagrams": "Léaráidí samplacha:",
"sample_flowchart": "Cairt Sreabhadh",
"sample_class": "Rang",
"sample_sequence": "Seicheamh",
"sample_entity_relationship": "Gaol Eintitis",
"sample_state": "Stát",
"sample_mindmap": "Léarscáil intinne",
"sample_architecture": "Ailtireacht",
"sample_block": "Bloc",
"sample_c4": "C4",
"sample_gantt": "Gantt",
"sample_git": "Git",
"sample_kanban": "Kanban",
"sample_packet": "Paicéad",
"sample_pie": "Pióg",
"sample_quadrant": "Ceathrú",
"sample_radar": "Radar",
"sample_requirement": "Riachtanas",
"sample_sankey": "Sankey",
"sample_timeline": "Amlíne",
"sample_treemap": "Léarscáil Crann",
"sample_user_journey": "Turas Úsáideora",
"sample_xy": "XY",
"sample_venn": "Venn",
"sample_ishikawa": "Ishikawa"
}
}

View File

@@ -1049,7 +1049,6 @@
"unprotecting-title": "अन-प्रोटेक्ट स्टेटस"
},
"relation_map": {
"open_in_new_tab": "नए टैब में खोलें",
"remove_note": "नोट हटाएं",
"edit_title": "टाइटल एडिट करें",
"rename_note": "नोट का नाम बदलें",

View File

@@ -1424,7 +1424,6 @@
"unprotecting-title": "Stato non protetto"
},
"relation_map": {
"open_in_new_tab": "Apri in una nuova scheda",
"remove_note": "Rimuovi nota",
"edit_title": "Modifica titolo",
"rename_note": "Rinomina nota",

View File

@@ -588,7 +588,7 @@
"note-map": "ノートマップ",
"render-note": "レンダリングノート",
"book": "コレクション",
"mermaid-diagram": "Mermaidダイアグラム",
"mermaid-diagram": "マーメイド図",
"canvas": "キャンバス",
"web-view": "Web ビュー",
"mind-map": "マインドマップ",
@@ -1180,7 +1180,8 @@
"is_owned_by_note": "ノートによって所有されています",
"and_more": "...その他 {{count}} 件。",
"print_landscape": "PDF にエクスポートするときに、ページの向きを縦向きではなく横向きに変更します。",
"print_page_size": "PDF にエクスポートするときに、ページのサイズを変更します。サポートされる値: <code>A0</code>, <code>A1</code>, <code>A2</code>, <code>A3</code>, <code>A4</code>, <code>A5</code>, <code>A6</code>, <code>Legal</code>, <code>Letter</code>, <code>Tabloid</code>, <code>Ledger</code>。"
"print_page_size": "PDF にエクスポートするときに、ページのサイズを変更します。サポートされる値: <code>A0</code>, <code>A1</code>, <code>A2</code>, <code>A3</code>, <code>A4</code>, <code>A5</code>, <code>A6</code>, <code>Legal</code>, <code>Letter</code>, <code>Tabloid</code>, <code>Ledger</code>。",
"textarea": "複数行テキスト"
},
"link_context_menu": {
"open_note_in_popup": "クイック編集",
@@ -1537,7 +1538,6 @@
"url_placeholder": "http://web サイト..."
},
"relation_map": {
"open_in_new_tab": "新しいタブで開く",
"remove_note": "ノートを削除",
"edit_title": "タイトルを編集",
"rename_note": "ノート名を変更",
@@ -2168,5 +2168,52 @@
},
"setup_form": {
"more_info": "さらに詳しく"
},
"media": {
"play": "再生 (スペース)",
"pause": "一時停止 (スペース)",
"back-10s": "10 秒戻る (左矢印キー)",
"forward-30s": "30 秒進む",
"mute": "ミュート (M)",
"unmute": "ミュート解除 (M)",
"playback-speed": "再生速度",
"loop": "ループ",
"disable-loop": "ループを解除",
"rotate": "回転",
"picture-in-picture": "ピクチャーインピクチャー",
"exit-picture-in-picture": "ピクチャーインピクチャーを終了",
"fullscreen": "全画面表示 (F)",
"exit-fullscreen": "全画面表示を終了",
"unsupported-format": "このファイル形式ではメディアプレビューはご利用いただけません:\n{{mime}}",
"zoom-to-fit": "ズームして全体を表示",
"zoom-reset": "ズーム設定をリセット"
},
"mermaid": {
"placeholder": "マーメイド図の内容を入力するか、以下のサンプル図のいずれかを使用してください。",
"sample_diagrams": "サンプル図:",
"sample_flowchart": "フローチャート",
"sample_class": "クラス図",
"sample_sequence": "シーケンス図",
"sample_entity_relationship": "ER 図",
"sample_state": "状態遷移図",
"sample_mindmap": "マインドマップ",
"sample_architecture": "アーキテクチャ図",
"sample_block": "ブロック図",
"sample_c4": "C4 図",
"sample_gantt": "ガントチャート",
"sample_git": "Git グラフ",
"sample_kanban": "カンバン",
"sample_packet": "パケット図",
"sample_pie": "円グラフ",
"sample_quadrant": "4象限図",
"sample_radar": "レーダーチャート",
"sample_requirement": "要件図",
"sample_sankey": "サンキー図",
"sample_timeline": "タイムライン",
"sample_treemap": "ツリーマップ",
"sample_user_journey": "ユーザージャーニー図",
"sample_xy": "XY チャート",
"sample_venn": "ベン図",
"sample_ishikawa": "石川図"
}
}

View File

@@ -51,7 +51,7 @@
"branch_prefix_saved": "브랜치 접두사가 저장되었습니다.",
"edit_branch_prefix_multiple": "{{count}}개의 지점 접두사 편집",
"branch_prefix_saved_multiple": "{{count}}개의 지점에 대해 지점 접두사가 저장되었습니다.",
"affected_branches": "영향을 받는 브랜치 ({{count}}):"
"affected_branches": "영향을 받은 분기 수({{count}}):"
},
"bulk_actions": {
"bulk_actions": "대량 작업",
@@ -134,6 +134,27 @@
"notSet": "미설정",
"goBackForwards": "히스토리에서 뒤로/앞으로 이동",
"showJumpToNoteDialog": "<a class=\"external\" href=\"https://triliumnext.github.io/Docs/Wiki/note-navigation.html#jump-to-note\">\"노트로 이동\" 대화 상자</a> 표시",
"scrollToActiveNote": "활성화된 노트로 스크롤 이동"
"scrollToActiveNote": "활성화된 노트로 스크롤 이동",
"collapseWholeTree": "모든 노트 트리를 접기",
"collapseSubTree": "하위 트리 접기",
"tabShortcuts": "탭 단축키",
"onlyInDesktop": "데스크톱에서만(일렉트론 빌드)",
"openEmptyTab": "빈 탭 열기",
"closeActiveTab": "활성 탭 닫기",
"jumpToParentNote": "부모 노트로 이동하기",
"activateNextTab": "다음 탭 활성화",
"activatePreviousTab": "이전 탭 활성화",
"creatingNotes": "노트 만들기",
"createNoteInto": "활성 노트에 새로운 하위 노트 추가",
"movingCloningNotes": "노트 이동/복제",
"moveNoteUpDown": "노트 목록에서 노트 위/아래 이동",
"selectAllNotes": "현재 레벨의 모든 노트 선택",
"selectNote": "노트 선택",
"deleteNotes": "노트/하위트리 삭제",
"editingNotes": "노트 편집",
"createEditLink": "외부 링크 생성/편집",
"createInternalLink": "내부 링크 생성",
"followLink": "커서아래 링크 따라가기",
"insertDateTime": "커서위치에 현재 날짜와 시간 삽입"
}
}

View File

@@ -29,7 +29,7 @@
"widget-render-error": {
"title": "Nie udało się wyrenderować niestandardowego widżetu React"
},
"widget-missing-parent": "Niestandardowy widżet nie ma zdefiniowanej obowiązkowej właściwości „{{property}}”.\nJeśli skrypt ma działać bez interfejsu użytkownika (UI) wyłącz go: '#run=frontendStartup'.",
"widget-missing-parent": "Niestandardowy widżet nie ma zdefiniowanej obowiązkowej właściwości „{{property}}”.\n\nJeśli skrypt ma działać bez interfejsu użytkownika (UI) wyłącz go: '#run=frontendStartup'.",
"open-script-note": "Otwórz notatkę ze skryptem",
"scripting-error": "Błąd skryptu użytkownika: {{title}}"
},
@@ -1275,7 +1275,6 @@
"unprotecting-title": "Status zdejmowania ochrony"
},
"relation_map": {
"open_in_new_tab": "Otwórz w nowej karcie",
"remove_note": "Usuń notatkę",
"edit_title": "Edytuj tytuł",
"rename_note": "Zmień nazwę notatki",
@@ -1487,7 +1486,7 @@
"custom_name_label": "Nazwa niestandardowej wyszukiwarki",
"custom_name_placeholder": "Dostosuj nazwę wyszukiwarki",
"custom_url_label": "URL niestandardowej wyszukiwarki powinien zawierać {keyword} jako symbol zastępczy dla wyszukiwanej frazy.",
"custom_url_placeholder": "Dostosuj URL wyszukiwarki",
"custom_url_placeholder": "Dostosuj url wyszukiwarki",
"save_button": "Zapisz"
},
"tray": {
@@ -2198,5 +2197,52 @@
},
"setup_form": {
"more_info": "Dowiedz się więcej"
},
"media": {
"fullscreen": "Pełny ekran (F)",
"mute": "Wycisz (M)",
"unmute": "Wyłącz wyciszenie (M)",
"exit-fullscreen": "Wyłącz pełny ekran",
"loop": "Pętla",
"disable-loop": "Wyłącz pętle",
"rotate": "Obróć",
"picture-in-picture": "Obraz w obrazie",
"pause": "Zatrzymaj (Space)",
"back-10s": "Cofnij 10s (Lewa strzałka)",
"forward-30s": "Do przodu 30s",
"playback-speed": "Szybkość odtwarzania",
"exit-picture-in-picture": "Wyjdź z obrazu w obrazie",
"zoom-to-fit": "Powiększ aby wypełnić",
"unsupported-format": "Podgląd multimediów nie jest dostępny dla tego formatu pliku\n{{mime}}",
"play": "Odtwórz (Space)",
"zoom-reset": "Zresetuj powiększenie"
},
"mermaid": {
"sample_architecture": "Architektura",
"sample_diagrams": "Przykład diagramu:",
"sample_flowchart": "Schemat blokowy",
"sample_class": "Klasa",
"sample_sequence": "Sekwencja",
"sample_timeline": "Oś czasu",
"sample_treemap": "Mapa drzewa",
"sample_xy": "XY",
"sample_venn": "Diagram Venna",
"sample_ishikawa": "Diagram Ishikawa",
"placeholder": "Wpisz treść swojego diagramu lub skorzystaj z jednego z przykładowych diagramów poniżej.",
"sample_entity_relationship": "Diagram związków encji",
"sample_state": "Diagram stanów",
"sample_mindmap": "Mapa myśli",
"sample_block": "Diagram blokowy",
"sample_c4": "C4",
"sample_gantt": "Wykres Gantta",
"sample_git": "Diagram Git",
"sample_kanban": "Kanban",
"sample_packet": "Diagram pakietów",
"sample_pie": "Wykres kołowy",
"sample_quadrant": "Diagram kwadrantowy",
"sample_radar": "Wykres radarowy",
"sample_requirement": "Diagram wymagań",
"sample_sankey": "Wykres Sankeya",
"sample_user_journey": "Mapa Podróży Użytkownika"
}
}

View File

@@ -1047,7 +1047,6 @@
"unprotecting-title": "Estado da remoção de proteção"
},
"relation_map": {
"open_in_new_tab": "Abrir em nova guia",
"remove_note": "Remover nota",
"edit_title": "Editar título",
"rename_note": "Renomear nota",

View File

@@ -1111,7 +1111,6 @@
"start_session_button": "Iniciar sessão protegida"
},
"relation_map": {
"open_in_new_tab": "Abrir em nova aba",
"remove_note": "Remover nota",
"edit_title": "Editar título",
"rename_note": "Renomear nota",

View File

@@ -1054,7 +1054,6 @@
"enter_title_of_new_note": "Introduceți titlul noii notițe",
"note_already_in_diagram": "Notița „{{title}}” deja se află pe diagramă.",
"note_not_found": "Notița „{{noteId}}” nu a putut fi găsită!",
"open_in_new_tab": "Deschide într-un tab nou",
"remove_note": "Șterge notița",
"remove_relation": "Șterge relația",
"rename_note": "Redenumește notița",

View File

@@ -1625,7 +1625,6 @@
"rename_note": "Переименовать заметку",
"remove_relation": "Удалить отношение",
"default_new_note_title": "новая заметка",
"open_in_new_tab": "Открыть в новой вкладке",
"confirm_remove_relation": "Вы уверены, что хотите удалить связь?",
"enter_new_title": "Введите новое название заметки:",
"note_not_found": "Заметка {{noteId}} не найдена!",

View File

@@ -446,7 +446,8 @@
"app_theme_base": "設定為 \"next\"、\"next-light \" 或 \"next-dark\",以使用相應的 TriliumNext 主題(自動、淺色或深色)作為自訂主題的基礎,而非傳統主題。",
"print_landscape": "匯出為 PDF 時,將頁面方向更改為橫向而非縱向。",
"print_page_size": "在匯出 PDF 時更改頁面大小。支援的值:<code>A0</code>、<code>A1</code>、<code>A2</code>、<code>A3</code>、<code>A4</code>、<code>A5</code>、<code>A6</code>、<code>Legal</code>、<code>Letter</code>、<code>Tabloid</code>、<code>Ledger</code>。",
"color_type": "顏色"
"color_type": "顏色",
"textarea": "多行文字"
},
"attribute_editor": {
"help_text_body1": "要新增標籤,只需輸入例如 <code>#rock</code> 或者如果您還想新增值,則例如 <code>#year = 2020</code>",
@@ -1046,7 +1047,6 @@
"unprotecting-title": "解除保護狀態"
},
"relation_map": {
"open_in_new_tab": "在新分頁中打開",
"remove_note": "刪除筆記",
"edit_title": "編輯標題",
"rename_note": "重新命名筆記",
@@ -2183,5 +2183,52 @@
},
"setup_form": {
"more_info": "了解更多"
},
"media": {
"play": "播放 (空白鍵)",
"pause": "暫停 (空白鍵)",
"back-10s": "往前 10 秒 (左方向鍵)",
"forward-30s": "往後 30 秒",
"mute": "靜音 (M)",
"unmute": "解除靜音 (M)",
"playback-speed": "播放速度",
"loop": "循環",
"disable-loop": "解除循環",
"rotate": "旋轉",
"picture-in-picture": "畫中畫",
"exit-picture-in-picture": "退出畫中畫",
"fullscreen": "全螢幕 (F)",
"exit-fullscreen": "退出全螢幕",
"unsupported-format": "此檔案格式不支援媒體預覽:\n{{mime}}",
"zoom-to-fit": "放大至填滿畫面",
"zoom-reset": "重設放大至填滿畫面"
},
"mermaid": {
"placeholder": "請輸入您的美人魚圖表內容,或選用下方其中一個範例圖表。",
"sample_diagrams": "範例圖表:",
"sample_flowchart": "流程圖",
"sample_class": "階層圖",
"sample_sequence": "時序圖",
"sample_entity_relationship": "實體關係圖",
"sample_state": "狀態圖",
"sample_mindmap": "心智圖",
"sample_architecture": "架構圖",
"sample_block": "區塊圖",
"sample_c4": "C4 圖",
"sample_gantt": "甘特圖",
"sample_git": "Git 分支圖",
"sample_kanban": "看板圖",
"sample_packet": "數據包圖",
"sample_pie": "圓餅圖",
"sample_quadrant": "象限圖",
"sample_radar": "雷達圖",
"sample_requirement": "需求圖",
"sample_sankey": "桑基圖",
"sample_timeline": "時間軸",
"sample_treemap": "樹狀圖",
"sample_user_journey": "用戶旅程",
"sample_xy": "XY 圖表",
"sample_venn": "韋恩圖",
"sample_ishikawa": "魚骨圖"
}
}

View File

@@ -1151,7 +1151,6 @@
"unprotecting-title": "Статус зняття захисту"
},
"relation_map": {
"open_in_new_tab": "Відкрити в новій вкладці",
"remove_note": "Видалити нотатку",
"edit_title": "Редагувати заголовок",
"rename_note": "Перейменувати нотатку",

View File

@@ -2,7 +2,7 @@ import "./PromotedAttributes.css";
import { UpdateAttributeResponse } from "@triliumnext/commons";
import clsx from "clsx";
import { ComponentChild, HTMLInputTypeAttribute, InputHTMLAttributes, MouseEventHandler, TargetedEvent, TargetedInputEvent } from "preact";
import { ComponentChild, createElement, HTMLInputTypeAttribute, InputHTMLAttributes, MouseEventHandler, TargetedEvent, TargetedInputEvent } from "preact";
import { Dispatch, StateUpdater, useCallback, useEffect, useRef, useState } from "preact/hooks";
import NoteContext from "../components/note_context";
@@ -36,7 +36,7 @@ interface CellProps {
setCellToFocus(cell: Cell): void;
}
type OnChangeEventData = TargetedEvent<HTMLInputElement, Event> | InputEvent | JQuery.TriggeredEvent<HTMLInputElement, undefined, HTMLInputElement, HTMLInputElement>;
type OnChangeEventData = TargetedEvent<HTMLInputElement | HTMLTextAreaElement, Event> | InputEvent | JQuery.TriggeredEvent<HTMLInputElement, undefined, HTMLInputElement, HTMLInputElement>;
type OnChangeListener = (e: OnChangeEventData) => void | Promise<void>;
export default function PromotedAttributes() {
@@ -171,8 +171,9 @@ function PromotedAttributeCell(props: CellProps) {
);
}
const LABEL_MAPPINGS: Record<LabelType, HTMLInputTypeAttribute> = {
const LABEL_MAPPINGS: Record<LabelType, HTMLInputTypeAttribute | undefined> = {
text: "text",
textarea: undefined,
number: "number",
boolean: "checkbox",
date: "date",
@@ -226,20 +227,21 @@ function LabelInput(props: CellProps & { inputId: string }) {
}
}
const inputNode = <input
className="form-control promoted-attribute-input"
tabIndex={200 + definitionAttr.position}
id={inputId}
type={LABEL_MAPPINGS[definition.labelType ?? "text"]}
value={valueDraft}
checked={definition.labelType === "boolean" ? valueAttr.value === "true" : undefined}
placeholder={t("promoted_attributes.unset-field-placeholder")}
data-attribute-id={valueAttr.attributeId}
data-attribute-type={valueAttr.type}
data-attribute-name={valueAttr.name}
onBlur={onChangeListener}
{...extraInputProps}
/>;
const inputNode = createElement(definition.labelType === "textarea" ? "textarea" : "input", {
className: "form-control promoted-attribute-input",
tabIndex: 200 + definitionAttr.position,
id: inputId,
type: LABEL_MAPPINGS[definition.labelType ?? "text"],
value: valueDraft,
checked: definition.labelType === "boolean" ? valueAttr.value === "true" : undefined,
placeholder: t("promoted_attributes.unset-field-placeholder"),
"data-attribute-id": valueAttr.attributeId,
"data-attribute-type": valueAttr.type,
"data-attribute-name": valueAttr.name,
onBlur: onChangeListener,
...extraInputProps
});
if (definition.labelType === "boolean") {
return <>

View File

@@ -1,18 +1,18 @@
import { t } from "../../services/i18n.js";
import server from "../../services/server.js";
import froca from "../../services/froca.js";
import linkService from "../../services/link.js";
import appContext from "../../components/app_context.js";
import attributeAutocompleteService from "../../services/attribute_autocomplete.js";
import type { Attribute } from "../../services/attribute_parser.js";
import { isExperimentalFeatureEnabled } from "../../services/experimental_features.js";
import { focusSavedElement, saveFocusedElement } from "../../services/focus.js";
import froca from "../../services/froca.js";
import { t } from "../../services/i18n.js";
import linkService from "../../services/link.js";
import noteAutocompleteService from "../../services/note_autocomplete.js";
import promotedAttributeDefinitionParser from "../../services/promoted_attribute_definition_parser.js";
import NoteContextAwareWidget from "../note_context_aware_widget.js";
import server from "../../services/server.js";
import shortcutService from "../../services/shortcuts.js";
import SpacedUpdate from "../../services/spaced_update.js";
import utils from "../../services/utils.js";
import shortcutService from "../../services/shortcuts.js";
import appContext from "../../components/app_context.js";
import type { Attribute } from "../../services/attribute_parser.js";
import { focusSavedElement, saveFocusedElement } from "../../services/focus.js";
import { isExperimentalFeatureEnabled } from "../../services/experimental_features.js";
import NoteContextAwareWidget from "../note_context_aware_widget.js";
const TPL = /*html*/`
<div class="attr-detail tn-tool-dialog">
@@ -29,6 +29,7 @@ const TPL = /*html*/`
max-height: 600px;
overflow: auto;
box-shadow: 10px 10px 93px -25px black;
contain: none;
}
.attr-help td {
@@ -137,6 +138,7 @@ const TPL = /*html*/`
<td>
<select class="attr-input-label-type form-control">
<option value="text">${t("attribute_detail.text")}</option>
<option value="textarea">${t("attribute_detail.textarea")}</option>
<option value="number">${t("attribute_detail.number")}</option>
<option value="boolean">${t("attribute_detail.boolean")}</option>
<option value="date">${t("attribute_detail.date")}</option>
@@ -342,6 +344,7 @@ export default class AttributeDetailWidget extends NoteContextAwareWidget {
private $relatedNotesList!: JQuery<HTMLElement>;
private $relatedNotesMoreNotes!: JQuery<HTMLElement>;
private $attrHelp!: JQuery<HTMLElement>;
private $statusBar?: JQuery<HTMLElement>;
private relatedNotesSpacedUpdate!: SpacedUpdate;
private attribute!: Attribute;
@@ -576,17 +579,24 @@ export default class AttributeDetailWidget extends NoteContextAwareWidget {
return;
}
this.$widget
.css("left", detPosition.left)
.css("right", detPosition.right)
.css("top", y - offset.top + 70)
.css("max-height", outerHeight + y > height - 50 ? height - y - 50 : 10000);
if (isNewLayout) {
if (!this.$statusBar) {
this.$statusBar = $(document.body).find(".component.status-bar");
}
const statusBarHeight = this.$statusBar.outerHeight() ?? 0;
const maxHeight = document.body.clientHeight - statusBarHeight;
this.$widget
.css("left", offset.left + (typeof detPosition.left === "number" ? detPosition.left : 0))
.css("top", "unset")
.css("bottom", 70)
.css("max-height", "80vh");
.css("bottom", statusBarHeight ?? 0)
.css("max-height", maxHeight);
} else {
this.$widget
.css("left", detPosition.left)
.css("right", detPosition.right)
.css("top", y - offset.top + 70)
.css("max-height", outerHeight + y > height - 50 ? height - y - 50 : 10000);
}
if (focus === "name") {
@@ -694,14 +704,14 @@ export default class AttributeDetailWidget extends NoteContextAwareWidget {
return "label-definition";
} else if (attribute.name.startsWith("relation:")) {
return "relation-definition";
} else {
return "label";
}
return "label";
} else if (attribute.type === "relation") {
return "relation";
} else {
this.$title.text("");
}
this.$title.text("");
}
updateAttributeInEditor() {

View File

@@ -364,23 +364,19 @@
mask-repeat: no-repeat;
mask-size: 100% 100%;
}
.ck-content p {
margin-bottom: 0.5em;
line-height: 1.3;
}
.ck-content figure.image {
width: 25%;
}
.ck-content .table {
display: flex;
flex-direction: column-reverse;
overflow-x: scroll;
--scrollbar-thickness: 0;
scrollbar-width: none;
table {
width: max-content;
table-layout: auto;
@@ -435,4 +431,4 @@
}
}
/* #endregion */
/* #endregion */

View File

@@ -2,8 +2,8 @@ import "./index.css";
import { RefObject } from "preact";
import { useEffect, useLayoutEffect, useRef, useState } from "preact/hooks";
import Reveal from "reveal.js";
import slideBaseStylesheet from "reveal.js/dist/reveal.css?raw";
import Reveal, { RevealApi } from "reveal.js";
import slideBaseStylesheet from "reveal.js/reveal.css?raw";
import { openInCurrentNoteContext } from "../../../components/note_context";
import FNote from "../../../entities/fnote";
@@ -20,7 +20,7 @@ import { DEFAULT_THEME, loadPresentationTheme } from "./themes";
export default function PresentationView({ note, noteIds, media, onReady, onProgressChanged }: ViewModeProps<{}>) {
const [ presentation, setPresentation ] = useState<PresentationModel>();
const containerRef = useRef<HTMLDivElement>(null);
const [ api, setApi ] = useState<Reveal.Api>();
const [ api, setApi ] = useState<RevealApi>();
const stylesheets = usePresentationStylesheets(note, media);
function refresh() {
@@ -98,7 +98,7 @@ function usePresentationStylesheets(note: FNote, media: ViewModeMedia) {
return stylesheets;
}
function ButtonOverlay({ containerRef, api }: { containerRef: RefObject<HTMLDivElement>, api: Reveal.Api | undefined }) {
function ButtonOverlay({ containerRef, api }: { containerRef: RefObject<HTMLDivElement>, api: RevealApi | undefined }) {
const [ isOverviewActive, setIsOverviewActive ] = useState(false);
useEffect(() => {
if (!api) return;
@@ -144,9 +144,9 @@ function ButtonOverlay({ containerRef, api }: { containerRef: RefObject<HTMLDivE
);
}
function Presentation({ presentation, setApi } : { presentation: PresentationModel, setApi: (api: Reveal.Api | undefined) => void }) {
function Presentation({ presentation, setApi } : { presentation: PresentationModel, setApi: (api: RevealApi | undefined) => void }) {
const containerRef = useRef<HTMLDivElement>(null);
const [revealApi, setRevealApi] = useState<Reveal.Api>();
const [revealApi, setRevealApi] = useState<RevealApi>();
useEffect(() => {
if (!containerRef.current) return;
@@ -222,7 +222,7 @@ function getNoteIdFromSlide(slide: HTMLElement | undefined) {
return slide.dataset.noteId;
}
function rewireLinks(container: HTMLElement, api: Reveal.Api) {
function rewireLinks(container: HTMLElement, api: RevealApi) {
const links = container.querySelectorAll<HTMLLinkElement>("a.reference-link");
for (const link of links) {
link.addEventListener("click", () => {

View File

@@ -3,49 +3,49 @@ export const DEFAULT_THEME = "white";
const themes = {
black: {
name: "Black",
loadTheme: () => import("reveal.js/dist/theme/black.css?raw")
loadTheme: () => import("reveal.js/theme/black.css?raw")
},
white: {
name: "White",
loadTheme: () => import("reveal.js/dist/theme/white.css?raw")
loadTheme: () => import("reveal.js/theme/white.css?raw")
},
beige: {
name: "Beige",
loadTheme: () => import("reveal.js/dist/theme/beige.css?raw")
loadTheme: () => import("reveal.js/theme/beige.css?raw")
},
serif: {
name: "Serif",
loadTheme: () => import("reveal.js/dist/theme/serif.css?raw")
loadTheme: () => import("reveal.js/theme/serif.css?raw")
},
simple: {
name: "Simple",
loadTheme: () => import("reveal.js/dist/theme/simple.css?raw")
loadTheme: () => import("reveal.js/theme/simple.css?raw")
},
solarized: {
name: "Solarized",
loadTheme: () => import("reveal.js/dist/theme/solarized.css?raw")
loadTheme: () => import("reveal.js/theme/solarized.css?raw")
},
moon: {
name: "Moon",
loadTheme: () => import("reveal.js/dist/theme/moon.css?raw")
loadTheme: () => import("reveal.js/theme/moon.css?raw")
},
dracula: {
name: "Dracula",
loadTheme: () => import("reveal.js/dist/theme/dracula.css?raw")
loadTheme: () => import("reveal.js/theme/dracula.css?raw")
},
sky: {
name: "Sky",
loadTheme: () => import("reveal.js/dist/theme/sky.css?raw")
loadTheme: () => import("reveal.js/theme/sky.css?raw")
},
blood: {
name: "Blood",
loadTheme: () => import("reveal.js/dist/theme/blood.css?raw")
loadTheme: () => import("reveal.js/theme/blood.css?raw")
}
} as const;
export function getPresentationThemes() {
return Object.entries(themes).map(([ id, theme ]) => ({
id: id,
id,
name: theme.name
}));
}

View File

@@ -19,6 +19,13 @@ const labelTypeMappings: Record<ColumnType, Partial<ColumnDefinition>> = {
text: {
editor: "input"
},
textarea: {
editor: "textarea",
formatter: "textarea",
editorParams: {
shiftEnterSubmit: true
}
},
boolean: {
formatter: "tickCross",
editor: "tickCross"

View File

@@ -75,3 +75,9 @@
font-size: 1.5em;
transform: translateY(-50%);
}
.tabulator .tabulator-editable {
textarea {
padding: 7px !important;
}
}

View File

@@ -0,0 +1,19 @@
.note-content-switcher {
--badge-radius: 12px;
position: relative;
display: flex;
min-height: 35px;
gap: 5px;
padding: 5px;
flex-wrap: wrap;
flex-shrink: 0;
font-size: 0.9rem;
align-items: center;
.ext-badge {
--color: var(--input-background-color);
color: var(--main-text-color);
font-size: 1em;
flex-shrink: 0;
}
}

View File

@@ -0,0 +1,39 @@
import "./NoteContentSwitcher.css";
import FNote from "../../entities/fnote";
import server from "../../services/server";
import { Badge } from "../react/Badge";
import { useNoteSavedData } from "../react/hooks";
export interface NoteContentTemplate {
name: string;
content: string;
}
interface NoteContentSwitcherProps {
text: string;
note: FNote;
templates: NoteContentTemplate[];
}
export default function NoteContentSwitcher({ text, note, templates }: NoteContentSwitcherProps) {
const blob = useNoteSavedData(note?.noteId);
return (blob?.trim().length === 0 &&
<div className="note-content-switcher">
{text}{" "}
{templates.map(sample => (
<Badge
key={sample.name}
text={sample.name}
onClick={async () => {
await server.put(`notes/${note.noteId}/data`, {
content: sample.content
});
}}
/>
))}
</div>
);
}

View File

@@ -84,7 +84,7 @@ export const TYPE_MAPPINGS: Record<ExtendedNoteType, NoteTypeMapping> = {
printable: true
},
mermaid: {
view: () => import("./type_widgets/Mermaid"),
view: () => import("./type_widgets/mermaid/Mermaid"),
className: "note-detail-mermaid",
printable: true,
isFullHeight: true

View File

@@ -1,3 +1,4 @@
import { createPortal } from "preact/compat";
import { useEffect, useState } from "preact/hooks";
import FAttribute from "../../entities/fattribute";
@@ -74,7 +75,7 @@ export default function InheritedAttributesTab({ note, componentId, emptyListStr
)}
</div>
{attributeDetailWidgetEl}
{createPortal(attributeDetailWidgetEl, document.body)}
</div>
);
}

View File

@@ -1,5 +1,6 @@
import { AttributeEditor as CKEditorAttributeEditor, MentionFeed, ModelElement, ModelNode, ModelPosition } from "@triliumnext/ckeditor5";
import { AttributeType } from "@triliumnext/commons";
import { createPortal } from "preact/compat";
import { MutableRef, useEffect, useImperativeHandle, useMemo, useRef, useState } from "preact/hooks";
import type { CommandData, FilteredCommandNames } from "../../../components/app_context";
@@ -336,7 +337,8 @@ export default function AttributeEditor({ api, note, componentId, notePath, ntxI
let matchedAttr: Attribute | null = null;
for (const attr of parsedAttrs) {
if (attr.startIndex && clickIndex > attr.startIndex && attr.endIndex && clickIndex <= attr.endIndex) {
if (attr.startIndex !== undefined && clickIndex > attr.startIndex &&
attr.endIndex !== undefined && clickIndex <= attr.endIndex) {
matchedAttr = attr;
break;
}
@@ -407,7 +409,7 @@ export default function AttributeEditor({ api, note, componentId, notePath, ntxI
)}
</div>}
{attributeDetailWidgetEl}
{createPortal(attributeDetailWidgetEl, document.body)}
</>
);
}

View File

@@ -30,6 +30,7 @@ export interface EditableCodeProps extends TypeWidgetProps, Omit<CodeEditorProps
onContentChanged?: (content: string) => void;
/** Invoked after the content of the note has been uploaded to the server, using a spaced update. */
dataSaved?: () => void;
placeholder?: string;
}
export function ReadOnlyCode({ note, viewScope, ntxId, parentComponent }: TypeWidgetProps) {
@@ -74,7 +75,7 @@ function formatViewSource(note: FNote, content: string) {
return content;
}
export function EditableCode({ note, ntxId, noteContext, debounceUpdate, parentComponent, updateInterval, noteType = "code", onContentChanged, dataSaved, ...editorProps }: EditableCodeProps) {
export function EditableCode({ note, ntxId, noteContext, debounceUpdate, parentComponent, updateInterval, noteType = "code", onContentChanged, dataSaved, placeholder, ...editorProps }: EditableCodeProps) {
const editorRef = useRef<VanillaCodeMirror>(null);
const containerRef = useRef<HTMLPreElement>(null);
const [ vimKeymapEnabled ] = useTriliumOptionBool("vimKeymapEnabled");
@@ -115,7 +116,7 @@ export function EditableCode({ note, ntxId, noteContext, debounceUpdate, parentC
editorRef={editorRef} containerRef={containerRef}
mime={mime ?? "text/plain"}
className="note-detail-code-editor"
placeholder={t("editable_code.placeholder")}
placeholder={placeholder ?? t("editable_code.placeholder")}
vimKeybindings={vimKeymapEnabled}
tabIndex={300}
onContentChanged={() => {

View File

@@ -27,12 +27,18 @@
margin: 0 !important;
}
body.desktop .note-detail-split .note-detail-code-editor {
border-radius: 6px;
margin-top: 1px;
}
.note-detail-split .note-detail-error-container {
font-family: var(--monospace-font-family);
margin: 5px;
white-space: pre-wrap;
font-size: 0.85em;
overflow: auto;
user-select: text;
}
.note-detail-split .note-detail-split-preview {

View File

@@ -19,6 +19,7 @@ export interface SplitEditorProps extends EditableCodeProps {
previewButtons?: ComponentChildren;
editorBefore?: ComponentChildren;
forceOrientation?: "horizontal" | "vertical";
extraContent?: ComponentChildren;
}
/**
@@ -41,7 +42,7 @@ export default function SplitEditor(props: SplitEditorProps) {
}
function EditorWithSplit({ note, error, splitOptions, previewContent, previewButtons, className, editorBefore, forceOrientation, ...editorProps }: SplitEditorProps) {
function EditorWithSplit({ note, error, splitOptions, previewContent, previewButtons, className, editorBefore, forceOrientation, extraContent, ...editorProps }: SplitEditorProps) {
const containerRef = useRef<HTMLDivElement>(null);
const splitEditorOrientation = useSplitOrientation(forceOrientation);
@@ -57,9 +58,12 @@ function EditorWithSplit({ note, error, splitOptions, previewContent, previewBut
{...editorProps}
/>
</div>
{error && <Admonition type="caution" className="note-detail-error-container">
{error}
</Admonition>}
{error && (
<Admonition type="caution" className="note-detail-error-container">
{error}
</Admonition>
)}
{extraContent}
</div>
);

View File

@@ -117,6 +117,7 @@ export default function SvgSplitEditor({ ntxId, note, attachmentName, renderSvg,
error={error}
onContentChanged={onContentChanged}
dataSaved={onSave}
placeholder={t("mermaid.placeholder")}
previewContent={(
<RawHtmlBlock
className="render-container"
@@ -151,6 +152,7 @@ export default function SvgSplitEditor({ ntxId, note, attachmentName, renderSvg,
function useResizer(containerRef: RefObject<HTMLDivElement>, noteId: string, svg: string | undefined) {
const lastPanZoom = useRef<{ pan: SvgPanZoom.Point, zoom: number }>();
const lastNoteId = useRef<string>();
const wasEmpty = useRef<boolean>(false);
const zoomRef = useRef<SvgPanZoom.Instance>();
const width = useElementSize(containerRef);
@@ -158,9 +160,14 @@ function useResizer(containerRef: RefObject<HTMLDivElement>, noteId: string, svg
useEffect(() => {
if (zoomRef.current || width?.width === 0) return;
const shouldPreservePanZoom = (lastNoteId.current === noteId);
const shouldPreservePanZoom = (lastNoteId.current === noteId) && !wasEmpty.current;
const svgEl = containerRef.current?.querySelector("svg");
if (!svgEl) return;
if (!svgEl) {
if (svg?.trim().length === 0) {
wasEmpty.current = true;
}
return;
};
const zoomInstance = svgPanZoom(svgEl, {
zoomEnabled: true,
@@ -186,7 +193,7 @@ function useResizer(containerRef: RefObject<HTMLDivElement>, noteId: string, svg
zoomRef.current = undefined;
zoomInstance.destroy();
};
}, [ svg, width ]);
}, [ containerRef, noteId, svg, width ]);
// React to container changes.
useEffect(() => {

View File

@@ -1,7 +1,11 @@
import { useCallback } from "preact/hooks";
import SvgSplitEditor from "./helpers/SvgSplitEditor";
import { TypeWidgetProps } from "./type_widget";
import { getMermaidConfig, loadElkIfNeeded, postprocessMermaidSvg } from "../../services/mermaid";
import { t } from "../../../services/i18n";
import { getMermaidConfig, loadElkIfNeeded, postprocessMermaidSvg } from "../../../services/mermaid";
import NoteContentSwitcher from "../../layout/NoteContentSwitcher";
import SvgSplitEditor from "../helpers/SvgSplitEditor";
import { TypeWidgetProps } from "../type_widget";
import SAMPLE_DIAGRAMS from "./sample_diagrams";
let idCounter = 1;
let registeredErrorReporter = false;
@@ -15,6 +19,10 @@ export default function Mermaid(props: TypeWidgetProps) {
registeredErrorReporter = true;
}
if (!content.trim()) {
return "";
}
mermaid.initialize({
startOnLoad: false,
...(getMermaidConfig() as any),
@@ -30,6 +38,12 @@ export default function Mermaid(props: TypeWidgetProps) {
attachmentName="mermaid-export"
renderSvg={renderSvg}
noteType="mermaid"
extraContent={(
<NoteContentSwitcher
text={t("mermaid.sample_diagrams")}
note={props.note}
templates={SAMPLE_DIAGRAMS} />
)}
{...props}
/>
);

View File

@@ -0,0 +1,512 @@
import { t } from "../../../services/i18n";
import type { NoteContentTemplate } from "../../layout/NoteContentSwitcher";
const SAMPLE_DIAGRAMS: NoteContentTemplate[] = [
{
name: t("mermaid.sample_flowchart"),
content: `\
flowchart TD
A[Christmas] -->|Get money| B(Go shopping)
B --> C{Let me think}
C -->|One| D[Laptop]
C -->|Two| E[iPhone]
C -->|Three| F[fa:fa-car Car]
`
},
{
name: t("mermaid.sample_class"),
content: `\
classDiagram
Animal <|-- Duck
Animal <|-- Fish
Animal <|-- Zebra
Animal : +int age
Animal : +String gender
Animal: +isMammal()
Animal: +mate()
class Duck{
+String beakColor
+swim()
+quack()
}
class Fish{
-int sizeInFeet
-canEat()
}
class Zebra{
+bool is_wild
+run()
}
`
},
{
name: t("mermaid.sample_sequence"),
content: `\
sequenceDiagram
Alice->>+John: Hello John, how are you?
Alice->>+John: John, can you hear me?
John-->>-Alice: Hi Alice, I can hear you!
John-->>-Alice: I feel great!
`
},
{
name: t("mermaid.sample_entity_relationship"),
content: `\
erDiagram
CUSTOMER ||--o{ ORDER : places
ORDER ||--|{ ORDER_ITEM : contains
PRODUCT ||--o{ ORDER_ITEM : includes
CUSTOMER {
string id
string name
string email
}
ORDER {
string id
date orderDate
string status
}
PRODUCT {
string id
string name
float price
}
ORDER_ITEM {
int quantity
float price
}
`
},
{
name: t("mermaid.sample_state"),
content: `\
stateDiagram-v2
[*] --> Still
Still --> [*]
Still --> Moving
Moving --> Still
Moving --> Crash
Crash --> [*]
`
},
{
name: t("mermaid.sample_mindmap"),
content: `\
mindmap
root((mindmap))
Origins
Long history
::icon(fa fa-book)
Popularisation
British popular psychology author Tony Buzan
Research
On effectiveness<br/>and features
On Automatic creation
Uses
Creative techniques
Strategic planning
Argument mapping
Tools
Pen and paper
Mermaid
`
},
{
name: t("mermaid.sample_architecture"),
content: `\
architecture-beta
group api(cloud)[API]
service db(database)[Database] in api
service disk1(disk)[Storage] in api
service disk2(disk)[Storage] in api
service server(server)[Server] in api
db:L -- R:server
disk1:T -- B:server
disk2:T -- B:db
`
},
{
name: t("mermaid.sample_block"),
content: `\
block-beta
columns 1
db(("DB"))
blockArrowId6<["&nbsp;&nbsp;&nbsp;"]>(down)
block:ID
A
B["A wide one in the middle"]
C
end
space
D
ID --> D
C --> D
style B fill:#969,stroke:#333,stroke-width:4px
`
},
{
name: t("mermaid.sample_c4"),
content: `\
C4Context
title System Context diagram for Internet Banking System
Enterprise_Boundary(b0, "BankBoundary0") {
Person(customerA, "Banking Customer A", "A customer of the bank, with personal bank accounts.")
Person(customerB, "Banking Customer B")
Person_Ext(customerC, "Banking Customer C", "desc")
Person(customerD, "Banking Customer D", "A customer of the bank, <br/> with personal bank accounts.")
System(SystemAA, "Internet Banking System", "Allows customers to view information about their bank accounts, and make payments.")
Enterprise_Boundary(b1, "BankBoundary") {
SystemDb_Ext(SystemE, "Mainframe Banking System", "Stores all of the core banking information about customers, accounts, transactions, etc.")
System_Boundary(b2, "BankBoundary2") {
System(SystemA, "Banking System A")
System(SystemB, "Banking System B", "A system of the bank, with personal bank accounts. next line.")
}
System_Ext(SystemC, "E-mail system", "The internal Microsoft Exchange e-mail system.")
SystemDb(SystemD, "Banking System D Database", "A system of the bank, with personal bank accounts.")
Boundary(b3, "BankBoundary3", "boundary") {
SystemQueue(SystemF, "Banking System F Queue", "A system of the bank.")
SystemQueue_Ext(SystemG, "Banking System G Queue", "A system of the bank, with personal bank accounts.")
}
}
}
BiRel(customerA, SystemAA, "Uses")
BiRel(SystemAA, SystemE, "Uses")
Rel(SystemAA, SystemC, "Sends e-mails", "SMTP")
Rel(SystemC, customerA, "Sends e-mails to")
`
},
{
name: t("mermaid.sample_gantt"),
content: `\
gantt
title A Gantt Diagram
dateFormat YYYY-MM-DD
section Section
A task :a1, 2014-01-01, 30d
Another task :after a1 , 20d
section Another
Task in sec :2014-01-12 , 12d
another task : 24d
`
},
{
name: t("mermaid.sample_git"),
content: `\
gitGraph
commit
branch develop
checkout develop
commit
commit
checkout main
merge develop
commit
branch feature
checkout feature
commit
commit
checkout main
merge feature
`
},
{
name: t("mermaid.sample_kanban"),
content: `\
---
config:
kanban:
ticketBaseUrl: 'https://github.com/mermaid-js/mermaid/issues/#TICKET#'
---
kanban
Todo
[Create Documentation]
docs[Create Blog about the new diagram]
[In progress]
id6[Create renderer so that it works in all cases. We also add some extra text here for testing purposes. And some more just for the extra flare.]
id9[Ready for deploy]
id8[Design grammar]@{ assigned: 'knsv' }
id10[Ready for test]
id4[Create parsing tests]@{ ticket: 2038, assigned: 'K.Sveidqvist', priority: 'High' }
id66[last item]@{ priority: 'Very Low', assigned: 'knsv' }
id11[Done]
id5[define getData]
id2[Title of diagram is more than 100 chars when user duplicates diagram with 100 char]@{ ticket: 2036, priority: 'Very High'}
id3[Update DB function]@{ ticket: 2037, assigned: knsv, priority: 'High' }
id12[Can't reproduce]
id3[Weird flickering in Firefox]
`
},
{
name: t("mermaid.sample_packet"),
content: `\
---
title: "TCP Packet"
---
packet
0-15: "Source Port"
16-31: "Destination Port"
32-63: "Sequence Number"
64-95: "Acknowledgment Number"
96-99: "Data Offset"
100-105: "Reserved"
106: "URG"
107: "ACK"
108: "PSH"
109: "RST"
110: "SYN"
111: "FIN"
112-127: "Window"
128-143: "Checksum"
144-159: "Urgent Pointer"
160-191: "(Options and Padding)"
192-255: "Data (variable length)"
`
},
{
name: t("mermaid.sample_pie"),
content: `\
pie title Pets adopted by volunteers
"Dogs" : 386
"Cats" : 85
"Rats" : 15
`
},
{
name: t("mermaid.sample_quadrant"),
content: `\
quadrantChart
title Reach and engagement of campaigns
x-axis Low Reach --> High Reach
y-axis Low Engagement --> High Engagement
quadrant-1 We should expand
quadrant-2 Need to promote
quadrant-3 Re-evaluate
quadrant-4 May be improved
Campaign A: [0.3, 0.6]
Campaign B: [0.45, 0.23]
Campaign C: [0.57, 0.69]
Campaign D: [0.78, 0.34]
Campaign E: [0.40, 0.34]
Campaign F: [0.35, 0.78]
`
},
{
name: t("mermaid.sample_radar"),
content: `\
---
title: "Grades"
---
radar-beta
axis m["Math"], s["Science"], e["English"]
axis h["History"], g["Geography"], a["Art"]
curve a["Alice"]{85, 90, 80, 70, 75, 90}
curve b["Bob"]{70, 75, 85, 80, 90, 85}
max 100
min 0
`
},
{
name: t("mermaid.sample_requirement"),
content: `\
requirementDiagram
requirement test_req {
id: 1
text: the test text.
risk: high
verifymethod: test
}
element test_entity {
type: simulation
}
test_entity - satisfies -> test_req
`
},
{
name: t("mermaid.sample_sankey"),
content: `\
---
config:
sankey:
showValues: false
---
sankey-beta
Agricultural 'waste',Bio-conversion,124.729
Bio-conversion,Liquid,0.597
Bio-conversion,Losses,26.862
Bio-conversion,Solid,280.322
Bio-conversion,Gas,81.144
Biofuel imports,Liquid,35
Biomass imports,Solid,35
Coal imports,Coal,11.606
Coal reserves,Coal,63.965
Coal,Solid,75.571
District heating,Industry,10.639
District heating,Heating and cooling - commercial,22.505
District heating,Heating and cooling - homes,46.184
Electricity grid,Over generation / exports,104.453
Electricity grid,Heating and cooling - homes,113.726
Electricity grid,H2 conversion,27.14
Electricity grid,Industry,342.165
Electricity grid,Road transport,37.797
Electricity grid,Agriculture,4.412
Electricity grid,Heating and cooling - commercial,40.858
Electricity grid,Losses,56.691
Electricity grid,Rail transport,7.863
Electricity grid,Lighting & appliances - commercial,90.008
Electricity grid,Lighting & appliances - homes,93.494
Gas imports,NGas,40.719
Gas reserves,NGas,82.233
Gas,Heating and cooling - commercial,0.129
Gas,Losses,1.401
Gas,Thermal generation,151.891
Gas,Agriculture,2.096
Gas,Industry,48.58
Geothermal,Electricity grid,7.013
H2 conversion,H2,20.897
H2 conversion,Losses,6.242
H2,Road transport,20.897
Hydro,Electricity grid,6.995
Liquid,Industry,121.066
Liquid,International shipping,128.69
Liquid,Road transport,135.835
Liquid,Domestic aviation,14.458
Liquid,International aviation,206.267
Liquid,Agriculture,3.64
Liquid,National navigation,33.218
Liquid,Rail transport,4.413
Marine algae,Bio-conversion,4.375
NGas,Gas,122.952
Nuclear,Thermal generation,839.978
Oil imports,Oil,504.287
Oil reserves,Oil,107.703
Oil,Liquid,611.99
Other waste,Solid,56.587
Other waste,Bio-conversion,77.81
Pumped heat,Heating and cooling - homes,193.026
Pumped heat,Heating and cooling - commercial,70.672
Solar PV,Electricity grid,59.901
Solar Thermal,Heating and cooling - homes,19.263
Solar,Solar Thermal,19.263
Solar,Solar PV,59.901
Solid,Agriculture,0.882
Solid,Thermal generation,400.12
Solid,Industry,46.477
Thermal generation,Electricity grid,525.531
Thermal generation,Losses,787.129
Thermal generation,District heating,79.329
Tidal,Electricity grid,9.452
UK land based bioenergy,Bio-conversion,182.01
Wave,Electricity grid,19.013
Wind,Electricity grid,289.366
`
},
{
name: t("mermaid.sample_timeline"),
content: `\
timeline
title History of Social Media Platform
2002 : LinkedIn
2004 : Facebook
: Google
2005 : YouTube
2006 : Twitter
`
},
{
name: t("mermaid.sample_treemap"),
content: `\
treemap-beta
"Section 1"
"Leaf 1.1": 12
"Section 1.2"
"Leaf 1.2.1": 12
"Section 2"
"Leaf 2.1": 20
"Leaf 2.2": 25
`
},
{
name: t("mermaid.sample_user_journey"),
content: `\
journey
title My working day
section Go to work
Make tea: 5: Me
Go upstairs: 3: Me
Do work: 1: Me, Cat
section Go home
Go downstairs: 5: Me
Sit down: 5: Me
`
},
{
name: t("mermaid.sample_xy"),
content: `\
xychart-beta
title "Sales Revenue"
x-axis [jan, feb, mar, apr, may, jun, jul, aug, sep, oct, nov, dec]
y-axis "Revenue (in $)" 4000 --> 11000
bar [5000, 6000, 7500, 8200, 9500, 10500, 11000, 10200, 9200, 8500, 7000, 6000]
line [5000, 6000, 7500, 8200, 9500, 10500, 11000, 10200, 9200, 8500, 7000, 6000]
`
},
{
name: t("mermaid.sample_venn"),
content: `\
venn-beta
title Web Dev
set Frontend
text React
text shadcn-ui
text Firebase
set Backend
text Hono
text PostgreSQL
text S3
text Lambda
union Frontend,Backend["APIs"]
`
},
{
name: t("mermaid.sample_ishikawa"),
content: `\
ishikawa-beta
Blurry Photo
Process
Out of focus
Shutter speed too slow
Protective film not removed
Beautification filter applied
User
Shaky hands
Equipment
LENS
Inappropriate lens
Damaged lens
Dirty lens
SENSOR
Damaged sensor
Dirty sensor
Environment
Subject moved too quickly
Too dark
`
}
];
export default SAMPLE_DIAGRAMS;

View File

@@ -21,7 +21,6 @@ import TimeSelector from "./components/TimeSelector";
export default function OtherSettings() {
return (
<>
<SearchSettings />
{isElectron() && <>
<SearchEngineSettings />
<TrayOptionsSettings />
@@ -37,21 +36,6 @@ export default function OtherSettings() {
);
}
function SearchSettings() {
const [ fuzzyEnabled, setFuzzyEnabled ] = useTriliumOptionBool("searchEnableFuzzyMatching");
return (
<OptionsSection title={t("search.title")}>
<FormCheckbox
name="search-fuzzy-matching"
label={t("search.enable_fuzzy_matching")}
currentValue={fuzzyEnabled}
onChange={setFuzzyEnabled}
/>
</OptionsSection>
);
}
function SearchEngineSettings() {
const [ customSearchEngineName, setCustomSearchEngineName ] = useTriliumOption("customSearchEngineName");
const [ customSearchEngineUrl, setCustomSearchEngineUrl ] = useTriliumOption("customSearchEngineUrl");

View File

@@ -1,12 +1,14 @@
import { Connection } from "jsplumb";
import { RefObject } from "preact";
import appContext from "../../../components/app_context";
import FNote from "../../../entities/fnote";
import contextMenu from "../../../menus/context_menu";
import link_context_menu from "../../../menus/link_context_menu";
import dialog from "../../../services/dialog";
import { t } from "../../../services/i18n";
import server from "../../../services/server";
import RelationMapApi from "./api";
import { Connection } from "jsplumb";
export function buildNoteContextMenuHandler(note: FNote | null | undefined, mapApiRef: RefObject<RelationMapApi>) {
return (e: MouseEvent) => {
@@ -17,22 +19,8 @@ export function buildNoteContextMenuHandler(note: FNote | null | undefined, mapA
x: e.pageX,
y: e.pageY,
items: [
{
title: t("relation_map.open_in_new_tab"),
uiIcon: "bx bx-empty",
handler: () => appContext.tabManager.openTabWithNoteWithHoisting(note.noteId)
},
{
title: t("relation_map.remove_note"),
uiIcon: "bx bx-trash",
handler: async () => {
if (!note) return;
const result = await dialog.confirmDeleteNoteBoxWithNote(note.title);
if (typeof result !== "object" || !result.confirmed) return;
mapApiRef.current?.removeItem(note.noteId, result.isDeleteNoteChecked);
}
},
...link_context_menu.getItems(e),
{ kind: "separator" },
{
title: t("relation_map.edit_title"),
uiIcon: "bx bx-pencil",
@@ -49,10 +37,26 @@ export function buildNoteContextMenuHandler(note: FNote | null | undefined, mapA
await server.put(`notes/${note.noteId}/title`, { title });
}
}
},
{ kind: "separator" },
{
title: t("relation_map.remove_note"),
uiIcon: "bx bx-trash",
handler: async () => {
if (!note) return;
const result = await dialog.confirmDeleteNoteBoxWithNote(note.title);
if (typeof result !== "object" || !result.confirmed) return;
mapApiRef.current?.removeItem(note.noteId, result.isDeleteNoteChecked);
}
},
],
selectMenuItemHandler() {}
})
selectMenuItemHandler({ command }) {
// Pass the events to the link context menu
link_context_menu.handleLinkContextMenuItem(command, e, note.noteId);
}
});
};
}

View File

@@ -8,8 +8,7 @@
"preact"
],
"rootDir": "src",
"jsx": "preserve",
"jsxFactory": "h",
"jsx": "react-jsx",
"jsxImportSource": "preact",
"module": "esnext",
"moduleResolution": "bundler",

View File

@@ -6,8 +6,7 @@
"node",
"vitest"
],
"jsx": "preserve",
"jsxFactory": "h",
"jsx": "react-jsx",
"jsxImportSource": "preact",
"module": "esnext",
"moduleResolution": "bundler"

View File

@@ -103,10 +103,7 @@ export default defineConfig(() => ({
return "src/[name].js";
},
chunkFileNames: "src/[name]-[hash].js",
assetFileNames: "src/[name]-[hash].[ext]",
manualChunks: {
"ckeditor5": [ "@triliumnext/ckeditor5" ]
},
assetFileNames: "src/[name]-[hash].[ext]"
},
onwarn(warning, rollupWarn) {
if (warning.code === "MODULE_LEVEL_DIRECTIVE") {

View File

@@ -7,7 +7,7 @@
"colors": "1.4.0",
"diff": "8.0.3",
"sqlite": "5.1.1",
"sqlite3": "5.1.7"
"sqlite3": "6.0.1"
},
"scripts": {
"dev": "tsx src/compare.ts",

View File

@@ -23,7 +23,7 @@
},
"dependencies": {
"@electron/remote": "2.1.3",
"better-sqlite3": "12.6.2",
"better-sqlite3": "12.8.0",
"electron-debug": "4.1.0",
"electron-dl": "4.0.0",
"electron-squirrel-startup": "1.0.1",
@@ -35,7 +35,7 @@
"@triliumnext/commons": "workspace:*",
"@triliumnext/server": "workspace:*",
"copy-webpack-plugin": "14.0.0",
"electron": "40.8.0",
"electron": "41.0.3",
"@electron-forge/cli": "7.11.1",
"@electron-forge/maker-deb": "7.11.1",
"@electron-forge/maker-dmg": "7.11.1",

View File

@@ -4,9 +4,9 @@
"description": "Standalone tool to dump contents of Trilium document.db file into a directory tree of notes",
"private": true,
"dependencies": {
"better-sqlite3": "12.6.2",
"better-sqlite3": "12.8.0",
"mime-types": "3.0.2",
"sanitize-filename": "1.6.3",
"sanitize-filename": "1.6.4",
"tsx": "4.21.0",
"yargs": "18.0.0"
},

View File

@@ -5,14 +5,14 @@
"description": "Desktop version of Trilium which imports the demo database (presented to new users at start-up) or the user guide and other documentation and saves the modifications for committing.",
"dependencies": {
"archiver": "7.0.1",
"better-sqlite3": "12.6.2"
"better-sqlite3": "12.8.0"
},
"devDependencies": {
"@triliumnext/client": "workspace:*",
"@triliumnext/desktop": "workspace:*",
"@types/fs-extra": "11.0.4",
"copy-webpack-plugin": "14.0.0",
"electron": "40.8.0",
"electron": "41.0.3",
"fs-extra": "11.3.4"
},
"scripts": {

View File

@@ -75,8 +75,10 @@ test("Tabs are restored in right order", async ({ page, context }) => {
await expect(app.getActiveTab()).toContainText("Mermaid");
// Select the mid one.
const recentNotesSaved = page.waitForResponse((resp) => resp.url().includes("/api/recent-notes") && resp.ok());
await (await app.getTab(1)).click();
await expect(app.noteTreeActiveNote).toContainText("Text notes");
await recentNotesSaved;
// Refresh the page and check the order.
await app.goto( { preserveTabs: true });

View File

@@ -1,5 +1,5 @@
{
"dependencies": {
"better-sqlite3": "12.6.2"
"better-sqlite3": "12.8.0"
}
}

View File

@@ -6,6 +6,7 @@
"main": "./src/main.ts",
"scripts": {
"dev": "cross-env NODE_ENV=development TRILIUM_ENV=dev TRILIUM_DATA_DIR=data TRILIUM_RESOURCE_DIR=src tsx watch --ignore '../client/node_modules/.vite-temp' ./src/main.ts",
"dev-alt": "cross-env NODE_ENV=development TRILIUM_ENV=dev TRILIUM_DATA_DIR=data2 TRILIUM_RESOURCE_DIR=src tsx watch --ignore '../client/node_modules/.vite-temp' ./src/main.ts",
"start-no-dir": "cross-env NODE_ENV=development TRILIUM_ENV=dev TRILIUM_RESOURCE_DIR=src tsx watch --ignore '../client/node_modules/.vite-temp' ./src/main.ts",
"edit-integration-db": "cross-env NODE_ENV=development TRILIUM_PORT=8086 TRILIUM_ENV=dev TRILIUM_DATA_DIR=spec/db TRILIUM_INTEGRATION_TEST=edit TRILIUM_RESOURCE_DIR=src tsx watch --ignore '../client/node_modules/.vite-temp' ./src/main.ts",
"build": "tsx scripts/build.ts",
@@ -29,7 +30,7 @@
"proxy-nginx-subdir": "docker run --name trilium-nginx-subdir --rm --network=host -v ./docker/nginx.conf:/etc/nginx/conf.d/default.conf:ro nginx:latest"
},
"dependencies": {
"better-sqlite3": "12.6.2",
"better-sqlite3": "12.8.0",
"html-to-text": "9.0.5",
"node-html-parser": "7.1.0",
"sucrase": "3.35.1"
@@ -78,11 +79,11 @@
"cls-hooked": "4.2.2",
"compression": "1.8.1",
"cookie-parser": "1.4.7",
"csrf-csrf": "3.2.2",
"csrf-csrf": "4.0.3",
"debounce": "3.0.0",
"debug": "4.4.3",
"ejs": "5.0.1",
"electron": "40.8.0",
"electron": "41.0.3",
"electron-debug": "4.1.0",
"electron-window-state": "5.0.3",
"escape-html": "1.0.3",
@@ -96,9 +97,9 @@
"helmet": "8.1.0",
"html": "1.0.0",
"html2plaintext": "2.1.4",
"http-proxy-agent": "7.0.2",
"https-proxy-agent": "7.0.6",
"i18next": "25.8.17",
"http-proxy-agent": "8.0.0",
"https-proxy-agent": "8.0.0",
"i18next": "25.10.3",
"i18next-fs-backend": "2.6.1",
"image-type": "6.0.0",
"ini": "6.0.0",
@@ -106,15 +107,15 @@
"is-svg": "6.1.0",
"jimp": "1.6.0",
"lorem-ipsum": "2.0.8",
"marked": "17.0.4",
"marked": "17.0.5",
"mime-types": "3.0.2",
"multer": "2.1.1",
"normalize-strings": "1.1.1",
"rand-token": "1.0.1",
"safe-compare": "1.1.4",
"sanitize-filename": "1.6.3",
"sanitize-html": "2.17.1",
"sax": "1.5.0",
"sanitize-filename": "1.6.4",
"sanitize-html": "2.17.2",
"sax": "1.6.0",
"serve-favicon": "2.5.1",
"stream-throttle": "0.1.3",
"strip-bom": "5.0.0",
@@ -125,8 +126,8 @@
"tmp": "0.2.5",
"turnish": "1.8.0",
"unescape": "1.0.1",
"vite": "7.3.1",
"ws": "8.19.0",
"vite": "8.0.1",
"ws": "8.20.0",
"xml2js": "0.6.2",
"yauzl": "3.2.1"
}

View File

@@ -1,306 +0,0 @@
/**
* Integration-level search profiling test.
*
* Uses the real SQLite database (spec/db/document.db loaded in-memory),
* real sql module, real becca cache, and the full app stack.
*
* Profiles search at large scale (50K+ notes) to match real-world
* performance reports from users with 240K+ notes.
*/
import { Application } from "express";
import { beforeAll, describe, expect, it } from "vitest";
import config from "../src/services/config.js";
let app: Application;
function timed<T>(fn: () => T): [T, number] {
const start = performance.now();
const result = fn();
return [result, performance.now() - start];
}
function randomId(len = 12): string {
const chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
let id = "";
for (let i = 0; i < len; i++) id += chars[Math.floor(Math.random() * chars.length)];
return id;
}
function randomWord(len = 8): string {
const chars = "abcdefghijklmnopqrstuvwxyz";
let w = "";
for (let i = 0; i < len; i++) w += chars[Math.floor(Math.random() * chars.length)];
return w;
}
function generateContent(wordCount: number, keyword?: string): string {
const paragraphs: string[] = [];
let remaining = wordCount;
let injected = false;
while (remaining > 0) {
const n = Math.min(remaining, 30 + Math.floor(Math.random() * 30));
const words: string[] = [];
for (let i = 0; i < n; i++) words.push(randomWord(3 + Math.floor(Math.random() * 10)));
if (keyword && !injected && remaining < wordCount / 2) {
words[Math.floor(words.length / 2)] = keyword;
injected = true;
}
paragraphs.push(`<p>${words.join(" ")}</p>`);
remaining -= n;
}
return paragraphs.join("\n");
}
describe("Search profiling (integration)", () => {
beforeAll(async () => {
config.General.noAuthentication = true;
const buildApp = (await import("../src/app.js")).default;
app = await buildApp();
});
it("large-scale profiling (50K notes)", async () => {
const sql = (await import("../src/services/sql.js")).default;
const becca = (await import("../src/becca/becca.js")).default;
const beccaLoader = (await import("../src/becca/becca_loader.js")).default;
const cls = (await import("../src/services/cls.js")).default;
const searchService = (await import("../src/services/search/services/search.js")).default;
const SearchContext = (await import("../src/services/search/search_context.js")).default;
const beccaService = (await import("../src/becca/becca_service.js")).default;
await new Promise<void>((resolve) => {
cls.init(() => {
const initialNoteCount = Object.keys(becca.notes).length;
console.log(`\n Initial becca notes: ${initialNoteCount}`);
// ── Seed 50K notes with hierarchy ──
// Some folders (depth), some with common keyword "test" in title
const TOTAL_NOTES = 50000;
const FOLDER_COUNT = 500; // 500 folders
const NOTES_PER_FOLDER = (TOTAL_NOTES - FOLDER_COUNT) / FOLDER_COUNT; // ~99 notes per folder
const MATCH_FRACTION = 0.10; // 10% match "test" — ~5000 notes
const CONTENT_WORDS = 500;
const now = new Date().toISOString().replace("T", " ").replace("Z", "+0000");
console.log(` Seeding ${TOTAL_NOTES} notes (${FOLDER_COUNT} folders, ~${NOTES_PER_FOLDER.toFixed(0)} per folder)...`);
const [, seedMs] = timed(() => {
sql.transactional(() => {
const folderIds: string[] = [];
// Create folders under root
for (let f = 0; f < FOLDER_COUNT; f++) {
const noteId = `seed${randomId(8)}`;
const branchId = `seed${randomId(8)}`;
const blobId = `seed${randomId(16)}`;
folderIds.push(noteId);
sql.execute(
`INSERT INTO blobs (blobId, content, dateModified, utcDateModified) VALUES (?, ?, ?, ?)`,
[blobId, `<p>Folder ${f}</p>`, now, now]
);
sql.execute(
`INSERT INTO notes (noteId, title, type, mime, blobId, isProtected, isDeleted,
dateCreated, dateModified, utcDateCreated, utcDateModified)
VALUES (?, ?, 'text', 'text/html', ?, 0, 0, ?, ?, ?, ?)`,
[noteId, `Folder ${f} ${randomWord(5)}`, blobId, now, now, now, now]
);
sql.execute(
`INSERT INTO branches (branchId, noteId, parentNoteId, notePosition, isDeleted, isExpanded, utcDateModified)
VALUES (?, ?, 'root', ?, 0, 0, ?)`,
[branchId, noteId, f * 10, now]
);
}
// Create notes under folders
let noteIdx = 0;
for (let f = 0; f < FOLDER_COUNT; f++) {
const parentId = folderIds[f];
for (let n = 0; n < NOTES_PER_FOLDER; n++) {
const isMatch = noteIdx < TOTAL_NOTES * MATCH_FRACTION;
const noteId = `seed${randomId(8)}`;
const branchId = `seed${randomId(8)}`;
const blobId = `seed${randomId(16)}`;
const title = isMatch
? `Test Document ${noteIdx} ${randomWord(6)}`
: `Note ${noteIdx} ${randomWord(6)} ${randomWord(5)}`;
const content = generateContent(CONTENT_WORDS, isMatch ? "test" : undefined);
sql.execute(
`INSERT INTO blobs (blobId, content, dateModified, utcDateModified) VALUES (?, ?, ?, ?)`,
[blobId, content, now, now]
);
sql.execute(
`INSERT INTO notes (noteId, title, type, mime, blobId, isProtected, isDeleted,
dateCreated, dateModified, utcDateCreated, utcDateModified)
VALUES (?, ?, 'text', 'text/html', ?, 0, 0, ?, ?, ?, ?)`,
[noteId, title, blobId, now, now, now, now]
);
sql.execute(
`INSERT INTO branches (branchId, noteId, parentNoteId, notePosition, isDeleted, isExpanded, utcDateModified)
VALUES (?, ?, ?, ?, 0, 0, ?)`,
[branchId, noteId, parentId, n * 10, now]
);
noteIdx++;
}
}
});
});
console.log(` SQL seeding: ${seedMs.toFixed(0)}ms`);
const [, reloadMs] = timed(() => beccaLoader.load());
const totalNotes = Object.keys(becca.notes).length;
console.log(` Becca reload: ${reloadMs.toFixed(0)}ms Total notes: ${totalNotes}`);
// ── Warm caches ──
searchService.searchNotesForAutocomplete("test", true);
// ════════════════════════════════════════════
// PROFILING AT SCALE
// ════════════════════════════════════════════
console.log(`\n ════ PROFILING (${totalNotes} notes) ════\n`);
// 1. getCandidateNotes cost (the full-scan bottleneck)
const allNotes = Object.values(becca.notes);
const [, flatScanMs] = timed(() => {
let count = 0;
for (const note of allNotes) {
const ft = note.getFlatText();
if (ft.includes("test")) count++;
}
return count;
});
console.log(` getFlatText + includes scan (${allNotes.length} notes): ${flatScanMs.toFixed(1)}ms`);
// 2. Full findResultsWithQuery (includes candidate scan + parent walk + scoring)
const findTimes: number[] = [];
let findResultCount = 0;
for (let i = 0; i < 3; i++) {
const [r, ms] = timed(() =>
searchService.findResultsWithQuery("test", new SearchContext({ fastSearch: true }))
);
findTimes.push(ms);
findResultCount = r.length;
}
const findAvg = findTimes.reduce((a, b) => a + b, 0) / findTimes.length;
console.log(` findResultsWithQuery (fast): avg ${findAvg.toFixed(1)}ms (${findResultCount} results)`);
// 3. Exact-only (no fuzzy)
const exactTimes: number[] = [];
for (let i = 0; i < 3; i++) {
const [, ms] = timed(() =>
searchService.findResultsWithQuery("test", new SearchContext({ fastSearch: true, enableFuzzyMatching: false }))
);
exactTimes.push(ms);
}
const exactAvg = exactTimes.reduce((a, b) => a + b, 0) / exactTimes.length;
console.log(` findResultsWithQuery (exact): avg ${exactAvg.toFixed(1)}ms`);
console.log(` Fuzzy overhead: ${(findAvg - exactAvg).toFixed(1)}ms`);
// 4. SearchResult construction + computeScore cost (isolated)
const results = searchService.findResultsWithQuery("test", new SearchContext({ fastSearch: true }));
console.log(` Total results before trim: ${results.length}`);
const [, scoreAllMs] = timed(() => {
for (const r of results) r.computeScore("test", ["test"], true);
});
console.log(` computeScore × ${results.length}: ${scoreAllMs.toFixed(1)}ms (${(scoreAllMs / results.length).toFixed(3)}ms/result)`);
// 5. getNoteTitleForPath for all results
const [, pathTitleMs] = timed(() => {
for (const r of results) beccaService.getNoteTitleForPath(r.notePathArray);
});
console.log(` getNoteTitleForPath × ${results.length}: ${pathTitleMs.toFixed(1)}ms`);
// 6. Content snippet extraction (only 200)
const trimmed = results.slice(0, 200);
const [, snippetMs] = timed(() => {
for (const r of trimmed) {
r.contentSnippet = searchService.extractContentSnippet(r.noteId, ["test"]);
}
});
console.log(` extractContentSnippet × 200: ${snippetMs.toFixed(1)}ms`);
// 7. Highlighting (only 200)
const [, hlMs] = timed(() => {
searchService.highlightSearchResults(trimmed, ["test"]);
});
console.log(` highlightSearchResults × 200: ${hlMs.toFixed(1)}ms`);
// 7b. getBestNotePath cost (used by fast path)
const sampleNotes = Object.values(becca.notes).filter(n => n.title.startsWith("Test Document")).slice(0, 1000);
const [, bestPathMs] = timed(() => {
for (const n of sampleNotes) n.getBestNotePath();
});
console.log(` getBestNotePath × ${sampleNotes.length}: ${bestPathMs.toFixed(1)}ms (${(bestPathMs/sampleNotes.length).toFixed(3)}ms/note)`);
// 8. Full autocomplete end-to-end
const autoTimes: number[] = [];
let autoCount = 0;
for (let i = 0; i < 3; i++) {
const [r, ms] = timed(() =>
searchService.searchNotesForAutocomplete("test", true)
);
autoTimes.push(ms);
autoCount = r.length;
}
const autoAvg = autoTimes.reduce((a, b) => a + b, 0) / autoTimes.length;
const autoMin = Math.min(...autoTimes);
console.log(`\n ★ FULL AUTOCOMPLETE: avg ${autoAvg.toFixed(1)}ms min ${autoMin.toFixed(1)}ms (${autoCount} results)`);
// 9. With a less common search term (fewer matches)
const rareTimes: number[] = [];
let rareCount = 0;
for (let i = 0; i < 3; i++) {
const [r, ms] = timed(() =>
searchService.searchNotesForAutocomplete("leitfaden", true)
);
rareTimes.push(ms);
rareCount = r.length;
}
const rareAvg = rareTimes.reduce((a, b) => a + b, 0) / rareTimes.length;
console.log(` Autocomplete "leitfaden": avg ${rareAvg.toFixed(1)}ms (${rareCount} results)`);
// 10. Full search (fastSearch=false) — the 2.7s bottleneck
console.log(`\n ── Full search (fastSearch=false) ──`);
const fullTimes: number[] = [];
let fullCount = 0;
for (let i = 0; i < 2; i++) {
const [r, ms] = timed(() =>
searchService.findResultsWithQuery("test", new SearchContext({ fastSearch: false }))
);
fullTimes.push(ms);
fullCount = r.length;
}
const fullAvg = fullTimes.reduce((a, b) => a + b, 0) / fullTimes.length;
console.log(` Full search (flat + SQL): avg ${fullAvg.toFixed(1)}ms (${fullCount} results)`);
// 11. SQL content scan alone
const [scanCount, scanMs] = timed(() => {
let count = 0;
for (const row of sql.iterateRows<{ content: Buffer | string }>(`
SELECT noteId, type, mime, content, isProtected
FROM notes JOIN blobs USING (blobId)
WHERE type IN ('text', 'code', 'mermaid', 'canvas', 'mindMap')
AND isDeleted = 0
AND LENGTH(content) < 2097152`)) {
count++;
}
return count;
});
console.log(` Raw SQL scan (${scanCount} rows): ${scanMs.toFixed(1)}ms`);
// ── Summary ──
console.log(`\n ════ SUMMARY ════`);
console.log(` Notes: ${totalNotes} | Matches: ${findResultCount} | Hierarchy depth: 3 (root → folder → note)`);
console.log(` ──────────────────────────────────`);
console.log(` Autocomplete (fast): ${autoAvg.toFixed(1)}ms`);
console.log(` findResults: ${findAvg.toFixed(1)}ms (${((findAvg/autoAvg)*100).toFixed(0)}%)`);
console.log(` snippets+highlight: ${(snippetMs + hlMs).toFixed(1)}ms (${(((snippetMs+hlMs)/autoAvg)*100).toFixed(0)}%)`);
console.log(` Full search: ${fullAvg.toFixed(1)}ms`);
resolve();
});
});
}, 600_000);
});

View File

@@ -79,7 +79,7 @@ CREATE UNIQUE INDEX `IDX_entityChanges_entityName_entityId` ON "entity_changes"
`entityId`
);
CREATE INDEX `IDX_branches_noteId_parentNoteId` ON `branches` (`noteId`,`parentNoteId`);
CREATE INDEX IDX_branches_parentNoteId ON branches (parentNoteId);
CREATE INDEX IDX_branches_parentNoteId_isDeleted_notePosition ON branches (parentNoteId, isDeleted, notePosition);
CREATE INDEX `IDX_notes_title` ON `notes` (`title`);
CREATE INDEX `IDX_notes_type` ON `notes` (`type`);
CREATE INDEX `IDX_notes_dateCreated` ON `notes` (`dateCreated`);
@@ -146,6 +146,13 @@ CREATE INDEX IDX_notes_blobId on notes (blobId);
CREATE INDEX IDX_revisions_blobId on revisions (blobId);
CREATE INDEX IDX_attachments_blobId on attachments (blobId);
CREATE INDEX IDX_entity_changes_isSynced_id ON entity_changes (isSynced, id);
CREATE INDEX IDX_entity_changes_isErased_entityName ON entity_changes (isErased, entityName);
CREATE INDEX IDX_notes_isDeleted_utcDateModified ON notes (isDeleted, utcDateModified);
CREATE INDEX IDX_branches_isDeleted_utcDateModified ON branches (isDeleted, utcDateModified);
CREATE INDEX IDX_attributes_isDeleted_utcDateModified ON attributes (isDeleted, utcDateModified);
CREATE INDEX IDX_attachments_isDeleted_utcDateModified ON attachments (isDeleted, utcDateModified);
CREATE INDEX IDX_attachments_utcDateScheduledForErasureSince ON attachments (utcDateScheduledForErasureSince);
CREATE TABLE IF NOT EXISTS sessions (
id TEXT PRIMARY KEY,

View File

@@ -9,8 +9,7 @@
note where to place the new one and select:</p>
<ul>
<li><em>Insert note after</em>, to put the new note underneath the one selected.</li>
<li
><em>Insert child note</em>, to insert the note as a child of the selected
<li><em>Insert child note</em>, to insert the note as a child of the selected
note.</li>
</ul>
<p>
@@ -21,8 +20,7 @@
<li>When adding a <a href="#root/_help_QEAPj01N5f7w">link</a> in a&nbsp;<a class="reference-link"
href="#root/_help_iPIMuisry3hd">Text</a>&nbsp;note, type the desired title of
the new note and press Enter. Afterwards the type of the note will be asked.</li>
<li
>Similarly, when creating a new tab, type the desired title and press Enter.</li>
<li>Similarly, when creating a new tab, type the desired title and press Enter.</li>
</ul>
<h2>Changing the type of a note</h2>
<p>It is possible to change the type of a note after it has been created
@@ -32,96 +30,94 @@
edit the <a href="#root/_help_4FahAwuGTAwC">source of a note</a>.</p>
<h2>Supported note types</h2>
<p>The following note types are supported by Trilium:</p>
<figure class="table">
<table>
<thead>
<tr>
<th>Note Type</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td><a class="reference-link" href="#root/_help_iPIMuisry3hd">Text</a>
</td>
<td>The default note type, which allows for rich text formatting, images,
admonitions and right-to-left support.</td>
</tr>
<tr>
<td><a class="reference-link" href="#root/_help_6f9hih2hXXZk">Code</a>
</td>
<td>Uses a mono-space font and can be used to store larger chunks of code
or plain text than a text note, and has better syntax highlighting.</td>
</tr>
<tr>
<td><a class="reference-link" href="#root/_help_m523cpzocqaD">Saved Search</a>
</td>
<td>Stores the information about a search (the search text, criteria, etc.)
for later use. Can be used for quick filtering of a large amount of notes,
for example. The search can easily be triggered.</td>
</tr>
<tr>
<td><a class="reference-link" href="#root/_help_iRwzGnHPzonm">Relation Map</a>
</td>
<td>Allows easy creation of notes and relations between them. Can be used
for mainly relational data such as a family tree.</td>
</tr>
<tr>
<td><a class="reference-link" href="#root/_help_bdUJEHsAPYQR">Note Map</a>
</td>
<td>Displays the relationships between the notes, whether via relations or
their hierarchical structure.</td>
</tr>
<tr>
<td><a class="reference-link" href="#root/_help_HcABDtFCkbFN">Render Note</a>
</td>
<td>Used in&nbsp;<a class="reference-link" href="#root/_help_CdNpE2pqjmI6">Scripting</a>,
it displays the HTML content of another note. This allows displaying any
kind of content, provided there is a script behind it to generate it.</td>
</tr>
<tr>
<td><a class="reference-link" href="#root/_help_GTwFsgaA0lCt">Collections</a>
</td>
<td>Displays the children of the note either as a grid, a list, or for a more
specialized case: a calendar.&nbsp;
<br>
<br>Generally useful for easy reading of short notes.</td>
</tr>
<tr>
<td><a class="reference-link" href="#root/_help_s1aBHPd79XYj">Mermaid Diagrams</a>
</td>
<td>Displays diagrams such as bar charts, flow charts, state diagrams, etc.
Requires a bit of technical knowledge since the diagrams are written in
a specialized format.</td>
</tr>
<tr>
<td><a class="reference-link" href="#root/_help_grjYqerjn243">Canvas</a>
</td>
<td>Allows easy drawing of sketches, diagrams, handwritten content. Uses the
same technology behind <a href="https://excalidraw.com">excalidraw.com</a>.</td>
</tr>
<tr>
<td><a class="reference-link" href="#root/_help_1vHRoWCEjj0L">Web View</a>
</td>
<td>Displays the content of an external web page, similar to a browser.</td>
</tr>
<tr>
<td><a class="reference-link" href="#root/_help_gBbsAeiuUxI5">Mind Map</a>
</td>
<td>Easy for brainstorming ideas, by placing them in a hierarchical layout.</td>
</tr>
<tr>
<td><a class="reference-link" href="#root/_help_81SGnPGMk7Xc">Geo Map</a>
</td>
<td>Displays the children of the note as a geographical map, one use-case
would be to plan vacations. It even has basic support for tracks. Notes
can also be created from it.</td>
</tr>
<tr>
<td><a class="reference-link" href="#root/_help_W8vYD3Q1zjCR">File</a>
</td>
<td>Represents an uploaded file such as PDFs, images, video or audio files.</td>
</tr>
</tbody>
</table>
</figure>
<table>
<thead>
<tr>
<th>Note Type</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td><a class="reference-link" href="#root/_help_iPIMuisry3hd">Text</a>
</td>
<td>The default note type, which allows for rich text formatting, images,
admonitions and right-to-left support.</td>
</tr>
<tr>
<td><a class="reference-link" href="#root/_help_6f9hih2hXXZk">Code</a>
</td>
<td>Uses a mono-space font and can be used to store larger chunks of code
or plain text than a text note, and has better syntax highlighting.</td>
</tr>
<tr>
<td><a class="reference-link" href="#root/_help_m523cpzocqaD">Saved Search</a>
</td>
<td>Stores the information about a search (the search text, criteria, etc.)
for later use. Can be used for quick filtering of a large amount of notes,
for example. The search can easily be triggered.</td>
</tr>
<tr>
<td><a class="reference-link" href="#root/_help_iRwzGnHPzonm">Relation Map</a>
</td>
<td>Allows easy creation of notes and relations between them. Can be used
for mainly relational data such as a family tree.</td>
</tr>
<tr>
<td><a class="reference-link" href="#root/_help_bdUJEHsAPYQR">Note Map</a>
</td>
<td>Displays the relationships between the notes, whether via relations or
their hierarchical structure.</td>
</tr>
<tr>
<td><a class="reference-link" href="#root/_help_HcABDtFCkbFN">Render Note</a>
</td>
<td>Used in&nbsp;<a class="reference-link" href="#root/_help_CdNpE2pqjmI6">Scripting</a>,
it displays the HTML content of another note. This allows displaying any
kind of content, provided there is a script behind it to generate it.</td>
</tr>
<tr>
<td><a class="reference-link" href="#root/_help_GTwFsgaA0lCt">Collections</a>
</td>
<td>Displays the children of the note either as a grid, a list, or for a more
specialized case: a calendar.&nbsp;
<br>
<br>Generally useful for easy reading of short notes.</td>
</tr>
<tr>
<td><a class="reference-link" href="#root/_help_s1aBHPd79XYj">Mermaid Diagrams</a>
</td>
<td>Displays diagrams such as bar charts, flow charts, state diagrams, etc.
Requires a bit of technical knowledge since the diagrams are written in
a specialized format.</td>
</tr>
<tr>
<td><a class="reference-link" href="#root/_help_grjYqerjn243">Canvas</a>
</td>
<td>Allows easy drawing of sketches, diagrams, handwritten content. Uses the
same technology behind <a href="https://excalidraw.com">excalidraw.com</a>.</td>
</tr>
<tr>
<td><a class="reference-link" href="#root/_help_1vHRoWCEjj0L">Web View</a>
</td>
<td>Displays the content of an external web page, similar to a browser.</td>
</tr>
<tr>
<td><a class="reference-link" href="#root/_help_gBbsAeiuUxI5">Mind Map</a>
</td>
<td>Easy for brainstorming ideas, by placing them in a hierarchical layout.</td>
</tr>
<tr>
<td><a class="reference-link" href="#root/_help_81SGnPGMk7Xc">Geo Map</a>
</td>
<td>Displays the children of the note as a geographical map, one use-case
would be to plan vacations. It even has basic support for tracks. Notes
can also be created from it.</td>
</tr>
<tr>
<td><a class="reference-link" href="#root/_help_W8vYD3Q1zjCR">File</a>
</td>
<td>Represents an uploaded file such as PDFs, images, video or audio files.</td>
</tr>
</tbody>
</table>

View File

@@ -6,10 +6,20 @@
<img style="aspect-ratio:886/663;" src="2_Mermaid Diagrams_image.png"
width="886" height="663">
</figure>
<h2>Types of diagrams</h2>
<p>Trilium supports Mermaid, which adds support for various diagrams such
as flowchart, sequence diagram, class diagram, state diagram, pie charts,
etc., all using a text description of the chart instead of manually drawing
the diagram.</p>
<p>Starting with v0.103.0, Mermaid diagrams no longer start with a sample
flowchart, but instead a pane at the bottom will show all the supported
diagrams with sample code for each:</p>
<ul>
<li>Simply click on any of the samples to apply it.</li>
<li>The pane will disappear as soon as something is typed in the code editor
or a sample is selected. To make it appear again, simply remove the content
of the note.</li>
</ul>
<h2>Layouts</h2>
<p>Depending on the chart being edited and user preference, there are two
layouts supported by the Mermaid note type:</p>

View File

@@ -11,17 +11,17 @@
Calc, with support for formulas, data validation and text formatting.</p>
<h2>Spreadsheets vs. collections</h2>
<p>There is a slight overlap between spreadsheets and the&nbsp;<a class="reference-link"
href="#root/pOsGYCXsbNQG/GTwFsgaA0lCt/_help_2FvYrpmOXm29">Table</a>&nbsp;collection.
In general the table collection is useful to track meta-information about
notes (for example a collection of people and their birthdays), whereas
spreadsheets are quite useful for calculations since they support formulas.</p>
href="#root/_help_2FvYrpmOXm29">Table</a>&nbsp;collection. In general the table
collection is useful to track meta-information about notes (for example
a collection of people and their birthdays), whereas spreadsheets are quite
useful for calculations since they support formulas.</p>
<p>Spreadsheets also benefit from a wider range of features such as data
validation, formatting and can work on a relatively large dataset.</p>
<h2>Important statement regarding data format</h2>
<p>For Trilium as a knowledge database, it is important that data is stored
in a format that is easy to convert to something else. For example,&nbsp;
<a
class="reference-link" href="#root/pOsGYCXsbNQG/KSZ04uQ2D1St/_help_iPIMuisry3hd">Text</a>&nbsp;notes can be exported to either HTML or Markdown, making
class="reference-link" href="#root/_help_iPIMuisry3hd">Text</a>&nbsp;notes can be exported to either HTML or Markdown, making
it relatively easy to migrate to another software or simply to stand the
test of time.</p>
<p>For spreadsheets, Trilium uses a technology called <a href="https://docs.univer.ai/">Univer Sheets</a>,
@@ -41,28 +41,16 @@
<h2>Supported features</h2>
<p>The spreadsheet has support for the following features:</p>
<ul>
<li>
<p>Filtering</p>
</li>
<li>
<p>Sorting</p>
</li>
<li>
<p>Data validation</p>
</li>
<li>
<p>Conditional formatting</p>
</li>
<li>
<p>Notes / annotations</p>
</li>
<li>
<p>Find / replace</p>
</li>
<li>Filtering</li>
<li>Sorting</li>
<li>Data validation</li>
<li>Conditional formatting</li>
<li>Notes / annotations</li>
<li>Find / replace</li>
</ul>
<p>We might consider adding <a href="https://docs.univer.ai/guides/sheets/features/filter">other features</a> from
Univer at some point. If there is a particular feature that can be added
easily, it can be discussed over <a href="#root/pOsGYCXsbNQG/BgmBlOIl72jZ/_help_wy8So3yZZlH9">GitHub Issues</a>.</p>
easily, it can be discussed over <a href="#root/_help_wy8So3yZZlH9">GitHub Issues</a>.</p>
<h2>Features not supported yet</h2>
<h3>Regarding Pro features</h3>
<p>Univer spreadsheets also feature a <a href="https://univer.ai/pro">Pro plan</a> which
@@ -75,15 +63,9 @@
<p>There are a few features that are already planned but are not supported
yet:</p>
<ul>
<li>
<p>Trilium-specific formulas (e.g. to obtain the title of a note).</p>
</li>
<li>
<p>User-defined formulas</p>
</li>
<li>
<p>Cross-workbook calculation</p>
</li>
<li>Trilium-specific formulas (e.g. to obtain the title of a note).</li>
<li>User-defined formulas</li>
<li>Cross-workbook calculation</li>
</ul>
<p>If you would like us to work on these features, consider <a href="https://triliumnotes.org/en/support-us">supporting us</a>.</p>
<h2>Known limitations</h2>
@@ -92,12 +74,10 @@
<p>It is possible to share a spreadsheet, case in which a best-effort HTML
rendering of the spreadsheet is done.</p>
<ul>
<li>
<p>For more advanced use cases, this will most likely not work as intended.
Feel free to <a href="#root/pOsGYCXsbNQG/BgmBlOIl72jZ/_help_wy8So3yZZlH9">report issues</a>,
but keep in mind that we might not be able to have a complete feature parity
with all the features of Univer.</p>
</li>
<li>For more advanced use cases, this will most likely not work as intended.
Feel free to <a href="#root/_help_wy8So3yZZlH9">report issues</a>, but keep in
mind that we might not be able to have a complete feature parity with all
the features of Univer.</li>
</ul>
</li>
<li>

View File

@@ -101,7 +101,9 @@
"copy-without-formatting": "선택한 텍스트를 서식 없이 복사",
"force-save-revision": "활성 노트의 새 버전을 강제로 생성/저장",
"toggle-book-properties": "컬렉션 속성 토글",
"toggle-classic-editor-toolbar": "고정 도구 모음 에디터의 서식 탭을 전환"
"toggle-classic-editor-toolbar": "고정 도구 모음 에디터의 서식 탭을 전환",
"export-as-pdf": "현재 노트를 PDF로 내보내기",
"toggle-zen-mode": "젠 모드 활성화/비활성화(편집에 집중하기 위한 최소한의 UI)"
},
"hidden-subtree": {
"zen-mode": "젠 모드",
@@ -124,5 +126,90 @@
"sync-title": "동기화",
"other": "기타",
"advanced-title": "고급"
},
"keyboard_action_names": {
"back-in-note-history": "노트 기록으로 돌아가기",
"forward-in-note-history": "노트 기록 앞으로 이동",
"command-palette": "명령 팔레트",
"scroll-to-active-note": "활성 노트로 스크롤",
"quick-search": "빠른 검색",
"search-in-subtree": "하위트리에서 검색",
"expand-subtree": "하위트리 펼치기",
"collapse-tree": "트리 접기",
"collapse-subtree": "하위트리 접기",
"sort-child-notes": "자식 노트 정렬",
"create-note-into-inbox": "인박스에 노트 만들기",
"delete-notes": "노트 삭제",
"edit-note-title": "노트 제목 편집",
"clone-notes-to": "다음으로 복사",
"move-notes-to": "다음으로 노트 이동",
"copy-notes-to-clipboard": "노트를 클립보드로 복사",
"paste-notes-from-clipboard": "클립보드에서 노트 붙이기",
"cut-notes-to-clipboard": "클립보드로 노트 잘라내기",
"add-note-above-to-selection": "선택 위에 새로운 노트 추가",
"add-note-below-to-selection": "선택 아래에 새로운 노트 추가",
"duplicate-subtree": "하위트리 복제",
"open-new-tab": "새로운탭 열기",
"jump-to-note": "이동하기...",
"move-note-down": "노트 아래로 이동",
"move-note-up": "노트 위로 이동",
"close-active-tab": "활성탭 닫기",
"reopen-last-tab": "마지막 탭 다시 열기",
"activate-next-tab": "다음 탭 활성화",
"activate-previous-tab": "이전 탭 활성화",
"open-new-window": "새창 열기",
"toggle-system-tray-icon": "시스템 트레이 아이콘 토글",
"toggle-zen-mode": "젠 모드 토글",
"show-note-source": "노트 소스 보기",
"show-options": "옵션 보기",
"show-revisions": "리비전 보기",
"show-recent-changes": "최근 변경사항 보기",
"show-sql-console": "SQL 콘솔 보기",
"show-backend-log": "백엔드 로그 보기",
"show-help": "도움말 보기",
"follow-link-under-cursor": "커서 아래 링크 따라 가기",
"insert-date-and-time-to-text": "날짜와 시간 텍스트로 추가",
"paste-markdown-into-text": "마크다운을 텍스트로 붙여넣기",
"edit-read-only-note": "읽기 전용 노트 편집",
"add-new-label": "새로운 라벨 추가",
"add-new-relation": "새로운 관계 추가",
"toggle-ribbon-tab-classic-editor": "클래식 에디터 리본 탭 토글",
"toggle-ribbon-tab-basic-properties": "기본 설정 리본탭 토글",
"print-active-note": "활성 노트 프린트",
"export-active-note-as-pdf": "활성 노트를 PDF로 내보내기",
"reload-frontend-app": "프론트엔드 앱 다시 로드",
"open-developer-tools": "개발자 툴 열기",
"find-in-text": "텍스트에서 찾기",
"toggle-full-screen": "전체화면 토글",
"zoom-out": "축소",
"zoom-in": "확대",
"reset-zoom-level": "확대/축소 다시 설정",
"copy-without-formatting": "일반 텍스트로 복사",
"force-save-revision": "리비전 강제 저장"
},
"login": {
"title": "로그인",
"heading": "Trilium 로그인",
"incorrect-password": "암호가 맞지 않습니다. 다시 입력해 주세요.",
"password": "암호",
"button": "로그인",
"sign_in_with_sso": "{{ ssoIssuerName }}로 로그인"
},
"set_password": {
"title": "암호 설정",
"heading": "암호 설정",
"description": "Trilium을 웹에서 사용하기 전에 암호를 먼저 설정해야 합니다. 이 암호로 로그인하세요.",
"password": "암호",
"password-confirmation": "암호 확인",
"button": "암호 설정"
},
"setup": {
"heading": "Trilium 노트 셋업",
"next": "다음",
"init-in-progress": "문서 초기화 진행 중",
"title": "셋업"
},
"setup_sync-from-desktop": {
"step5": "연결 설정이 성공적인지 확인을 위해 \"Test sync\" 버튼을 클릭하세요."
}
}

View File

@@ -58,35 +58,35 @@
<div class="alert alert-warning" id="alert" style="display: none;">
</div>
<div id="setup-type" data-bind="visible: step() == 'setup-type'" style="margin-top: 20px;">
<form data-bind="submit: selectSetupType">
<div id="setup-type-section" style="margin-top: 20px;">
<form id="setup-type-form">
<div class="radio" style="margin-bottom: 15px;">
<label class="tn-radio">
<input type="radio" name="setup-type" value="new-document" data-bind="checked: setupType">
<input type="radio" name="setup-type" value="new-document">
<%= t("setup.new-document") %>
</label>
</div>
<div class="radio" style="margin-bottom: 15px;">
<label class="tn-radio">
<input type="radio" name="setup-type" value="sync-from-desktop" data-bind="checked: setupType">
<input type="radio" name="setup-type" value="sync-from-desktop">
<%= t("setup.sync-from-desktop") %>
</label>
</div>
<div class="radio" style="margin-bottom: 15px;">
<label class="tn-radio">
<input type="radio" name="setup-type" value="sync-from-server" data-bind="checked: setupType">
<input type="radio" name="setup-type" value="sync-from-server">
<%= t("setup.sync-from-server") %>
</label>
</div>
<button type="submit" data-bind="disable: !setupTypeSelected()" class="btn btn-primary"><%= t("setup.next") %></button>
<button type="submit" id="setup-type-next" class="btn btn-primary" disabled><%= t("setup.next") %></button>
</form>
</div>
<div data-bind="visible: step() == 'new-document-in-progress'">
<div id="new-document-in-progress-section">
<h2><%= t("setup.init-in-progress") %></h2>
<div style="display: flex; justify-content: flex-start; margin-top: 20px;">
@@ -103,7 +103,7 @@
</div>
</div>
<div data-bind="visible: step() == 'sync-from-desktop'">
<div id="sync-from-desktop-section">
<h2><%= t("setup_sync-from-desktop.heading") %></h2>
<p><%= t("setup_sync-from-desktop.description") %></p>
@@ -117,11 +117,11 @@
<li><%- t("setup_sync-from-desktop.step6", { link: `<a href="/">${t("setup_sync-from-desktop.step6-here")}</a>` }) %></li>
</ol>
<button type="button" data-bind="click: back" class="btn btn-secondary">Back</button>
<button type="button" data-action="back" class="btn btn-secondary">Back</button>
</div>
<div data-bind="visible: step() == 'sync-from-server'">
<form data-bind="submit: finish">
<div id="sync-from-server-section">
<form id="sync-from-server-form">
<h2><%= t("setup_sync-from-server.heading") %></h2>
@@ -129,27 +129,27 @@
<div class="form-group">
<label for="sync-server-host"><%= t("setup_sync-from-server.server-host") %></label>
<input type="text" id="syncServerHost" class="form-control" data-bind="value: syncServerHost" placeholder="<%= t("setup_sync-from-server.server-host-placeholder") %>">
<input type="text" id="sync-server-host" class="form-control" placeholder="<%= t("setup_sync-from-server.server-host-placeholder") %>">
</div>
<div class="form-group">
<label for="sync-proxy"><%= t("setup_sync-from-server.proxy-server") %></label>
<input type="text" id="sync-proxy" class="form-control" data-bind="value: syncProxy" placeholder="<%= t("setup_sync-from-server.proxy-server-placeholder") %>">
<input type="text" id="sync-proxy" class="form-control" placeholder="<%= t("setup_sync-from-server.proxy-server-placeholder") %>">
<p><strong><%= t("setup_sync-from-server.note") %></strong> <%= t("setup_sync-from-server.proxy-instruction") %></p>
</div>
<div class="form-group" style="margin-bottom: 8px;">
<label for="password"><%= t("setup_sync-from-server.password") %></label>
<input type="password" id="password" class="form-control" data-bind="value: password" placeholder="<%= t("setup_sync-from-server.password-placeholder") %>">
<input type="password" id="password" class="form-control" placeholder="<%= t("setup_sync-from-server.password-placeholder") %>">
</div>
<button type="button" data-bind="click: back" class="btn btn-secondary"><%= t("setup_sync-from-server.back") %></button>
<button type="button" data-action="back" class="btn btn-secondary"><%= t("setup_sync-from-server.back") %></button>
<button type="submit" class="btn btn-primary"><%= t("setup_sync-from-server.finish-setup") %></button>
</form>
</div>
<div data-bind="visible: step() == 'sync-in-progress'">
<div id="sync-in-progress-section">
<h2><%= t("setup_sync-in-progress.heading") %></h2>
<div class="alert alert-success"><%= t("setup_sync-in-progress.successful") %></div>

View File

@@ -31,22 +31,9 @@ export default class Becca {
allNoteSetCache: NoteSet | null;
/**
* Pre-built parallel arrays for fast flat text scanning in search.
* Avoids per-note property access overhead when iterating 50K+ notes.
* Supports incremental updates: when individual notes change, only their
* entries are rebuilt rather than the entire index.
*/
flatTextIndex: { notes: BNote[], flatTexts: string[], noteIdToIdx: Map<string, number> } | null;
/** NoteIds whose flat text needs to be recomputed in the index. */
dirtyFlatTextNoteIds: Set<string>;
constructor() {
this.dirtyFlatTextNoteIds = new Set();
this.allNoteSetCache = null;
this.flatTextIndex = null;
this.reset();
this.allNoteSetCache = null;
}
reset() {
@@ -252,59 +239,6 @@ export default class Becca {
/** Should be called when the set of all non-skeleton notes changes (added/removed) */
dirtyNoteSetCache() {
this.allNoteSetCache = null;
// Full rebuild needed since the note set itself changed
this.flatTextIndex = null;
this.dirtyFlatTextNoteIds.clear();
}
/** Mark a single note's flat text as needing recomputation in the index. */
dirtyNoteFlatText(noteId: string) {
if (this.flatTextIndex) {
// Index exists — schedule an incremental update
this.dirtyFlatTextNoteIds.add(noteId);
}
// If flatTextIndex is null, full rebuild will happen on next access anyway
}
/**
* Returns pre-built parallel arrays of notes and their flat texts for fast scanning.
* The flat texts are already normalized (lowercase, diacritics removed).
* Supports incremental updates: when individual notes are dirtied, only their
* entries are recomputed rather than rebuilding the entire index.
*/
getFlatTextIndex(): { notes: BNote[], flatTexts: string[], noteIdToIdx: Map<string, number> } {
if (!this.flatTextIndex) {
const allNoteSet = this.getAllNoteSet();
const notes: BNote[] = [];
const flatTexts: string[] = [];
const noteIdToIdx = new Map<string, number>();
for (const note of allNoteSet.notes) {
noteIdToIdx.set(note.noteId, notes.length);
notes.push(note);
flatTexts.push(note.getFlatText());
}
this.flatTextIndex = { notes, flatTexts, noteIdToIdx };
this.dirtyFlatTextNoteIds.clear();
} else if (this.dirtyFlatTextNoteIds.size > 0) {
// Incremental update: only recompute flat texts for dirtied notes
const { flatTexts, noteIdToIdx } = this.flatTextIndex;
for (const noteId of this.dirtyFlatTextNoteIds) {
const idx = noteIdToIdx.get(noteId);
if (idx !== undefined) {
const note = this.notes[noteId];
if (note) {
flatTexts[idx] = note.getFlatText();
}
}
}
this.dirtyFlatTextNoteIds.clear();
}
return this.flatTextIndex;
}
getAllNoteSet() {

View File

@@ -6,7 +6,6 @@ import dateUtils from "../../services/date_utils.js";
import promotedAttributeDefinitionParser from "../../services/promoted_attribute_definition_parser.js";
import sanitizeAttributeName from "../../services/sanitize_attribute_name.js";
import type { AttributeRow, AttributeType } from "@triliumnext/commons";
import { normalize } from "../../services/utils.js";
interface SavingOpts {
skipValidation?: boolean;
@@ -35,11 +34,6 @@ class BAttribute extends AbstractBeccaEntity<BAttribute> {
value!: string;
isInheritable!: boolean;
/** Pre-normalized (lowercase, diacritics removed) name for search. */
normalizedName!: string;
/** Pre-normalized (lowercase, diacritics removed) value for search. */
normalizedValue!: string;
constructor(row?: AttributeRow) {
super();
@@ -65,10 +59,6 @@ class BAttribute extends AbstractBeccaEntity<BAttribute> {
this.isInheritable = !!isInheritable;
this.utcDateModified = utcDateModified;
// Pre-compute normalized forms for search (avoids repeated normalize() calls in hot loops)
this.normalizedName = normalize(this.name);
this.normalizedValue = normalize(this.value);
return this;
}

View File

@@ -790,9 +790,6 @@ class BNote extends AbstractBeccaEntity<BNote> {
this.__attributeCache = null;
this.__inheritableAttributeCache = null;
this.__ancestorCache = null;
// Mark only this note's flat text as dirty for incremental index update
this.becca.dirtyNoteFlatText(this.noteId);
}
invalidateSubTree(path: string[] = []) {

View File

@@ -26,5 +26,7 @@ export declare module "express-session" {
totpEnabled: boolean;
ssoEnabled: boolean;
};
/** Set during /bootstrap to mark the session as modified so express-session persists it and sends the cookie. */
csrfInitialized?: true;
}
}

View File

@@ -6,6 +6,27 @@
// Migrations should be kept in descending order, so the latest migration is first.
const MIGRATIONS: (SqlMigration | JsMigration)[] = [
// Add missing database indices for query performance
{
version: 235,
sql: /*sql*/`
CREATE INDEX IF NOT EXISTS IDX_entity_changes_isSynced_id
ON entity_changes (isSynced, id);
CREATE INDEX IF NOT EXISTS IDX_entity_changes_isErased_entityName
ON entity_changes (isErased, entityName);
CREATE INDEX IF NOT EXISTS IDX_notes_isDeleted_utcDateModified
ON notes (isDeleted, utcDateModified);
CREATE INDEX IF NOT EXISTS IDX_branches_isDeleted_utcDateModified
ON branches (isDeleted, utcDateModified);
CREATE INDEX IF NOT EXISTS IDX_attributes_isDeleted_utcDateModified
ON attributes (isDeleted, utcDateModified);
CREATE INDEX IF NOT EXISTS IDX_attachments_isDeleted_utcDateModified
ON attachments (isDeleted, utcDateModified);
DROP INDEX IF EXISTS IDX_branches_parentNoteId;
CREATE INDEX IF NOT EXISTS IDX_branches_parentNoteId_isDeleted_notePosition
ON branches (parentNoteId, isDeleted, notePosition);
`
},
// Migrate aiChat notes to code notes since LLM integration has been removed
{
version: 234,

View File

@@ -97,7 +97,6 @@ const ALLOWED_OPTIONS = new Set<OptionNames>([
"layoutOrientation",
"backgroundEffects",
"allowedHtmlTags",
"searchEnableFuzzyMatching",
"redirectBareDomain",
"showLoginInShareTheme",
"splitEditorOrientation",

View File

@@ -1,7 +1,17 @@
import crypto from "crypto";
import { doubleCsrf } from "csrf-csrf";
import sessionSecret from "../services/session_secret.js";
import { isElectron } from "../services/utils.js";
export const CSRF_COOKIE_NAME = "trilium-csrf";
// In Electron, API calls go through an IPC bypass (routes/electron.ts) that uses a
// FakeRequest with a static session ID, while the bootstrap request goes through real
// Express with a real session. This mismatch causes CSRF validation to always fail.
// We use a per-instance random identifier so each Electron process still gets unique tokens.
const electronSessionId = crypto.randomUUID();
const doubleCsrfUtilities = doubleCsrf({
getSecret: () => sessionSecret,
cookieOptions: {
@@ -10,7 +20,8 @@ const doubleCsrfUtilities = doubleCsrf({
sameSite: "strict",
httpOnly: !isElectron // set to false for Electron, see https://github.com/TriliumNext/Trilium/pull/966
},
cookieName: "_csrf"
cookieName: CSRF_COOKIE_NAME,
getSessionIdentifier: (req) => isElectron ? electronSessionId : req.session.id
});
export const { generateToken, doubleCsrfProtection } = doubleCsrfUtilities;
export const { generateCsrfToken, doubleCsrfProtection } = doubleCsrfUtilities;

View File

@@ -3,6 +3,7 @@ import log from "../services/log.js";
import NotFoundError from "../errors/not_found_error.js";
import ForbiddenError from "../errors/forbidden_error.js";
import HttpError from "../errors/http_error.js";
import { CSRF_COOKIE_NAME } from "./csrf_protection.js";
function register(app: Application) {
@@ -14,7 +15,10 @@ function register(app: Application) {
&& err.code === "EBADCSRFTOKEN";
if (isCsrfTokenError) {
log.error(`Invalid CSRF token: ${req.headers["x-csrf-token"]}, secret: ${req.cookies["_csrf"]}`);
const csrfHeader = req.headers["x-csrf-token"];
const csrfHeaderPrefix = typeof csrfHeader === "string" ? csrfHeader.slice(0, 8) : undefined;
const tokenInfo = csrfHeaderPrefix ? ` (token prefix: ${csrfHeaderPrefix})` : "";
log.error(`Invalid CSRF token on ${req.method} ${req.url}${tokenInfo}`);
return next(new ForbiddenError("Invalid CSRF token"));
}

View File

@@ -11,19 +11,28 @@ import { generateCss, generateIconRegistry, getIconPacks, MIME_TO_EXTENSION_MAPP
import log from "../services/log.js";
import optionService from "../services/options.js";
import protectedSessionService from "../services/protected_session.js";
import { generateCsrfToken } from "./csrf_protection.js";
import sql from "../services/sql.js";
import { isDev, isElectron, isMac, isWindows11 } from "../services/utils.js";
import { generateToken as generateCsrfToken } from "./csrf_protection.js";
type View = "desktop" | "mobile" | "print";
export function bootstrap(req: Request, res: Response) {
const options = optionService.getOptionMap();
//'overwrite' set to false (default) => the existing token will be re-used and validated
//'validateOnReuse' set to false => if validation fails, generate a new token instead of throwing an error
const csrfToken = generateCsrfToken(req, res, false, false);
// csrf-csrf v4 binds CSRF tokens to the session ID via HMAC. With saveUninitialized: false,
// a brand-new session is never persisted unless explicitly modified, so its cookie is never
// sent to the browser — meaning every request gets a different ephemeral session ID, and
// CSRF validation fails. Setting this flag marks the session as modified, which causes
// express-session to persist it and send the session cookie in this response.
if (!req.session.csrfInitialized) {
req.session.csrfInitialized = true;
}
const csrfToken = generateCsrfToken(req, res, {
overwrite: false,
validateOnReuse: false // if validation fails, generate a new token instead of throwing an error
});
log.info(`CSRF token generation: ${csrfToken ? "Successful" : "Failed"}`);
const view = getView(req);

View File

@@ -5,7 +5,7 @@ import packageJson from "../../package.json" with { type: "json" };
import build from "./build.js";
import dataDir from "./data_dir.js";
const APP_DB_VERSION = 234;
const APP_DB_VERSION = 235;
const SYNC_VERSION = 37;
const CLIPPER_PROTOCOL_VERSION = "1.0";

View File

@@ -198,9 +198,6 @@ const defaultOptions: DefaultOption[] = [
isSynced: true
},
// Search settings
{ name: "searchEnableFuzzyMatching", value: "true", isSynced: true },
// Share settings
{ name: "redirectBareDomain", value: "false", isSynced: true },
{ name: "showLoginInShareTheme", value: "false", isSynced: true },

View File

@@ -7,7 +7,7 @@ function parse(value: string): DefinitionObject {
for (const token of tokens) {
if (token === "promoted") {
defObj.isPromoted = true;
} else if (["text", "number", "boolean", "date", "datetime", "time", "url"].includes(token)) {
} else if (["text", "textarea", "number", "boolean", "date", "datetime", "time", "url"].includes(token)) {
defObj.labelType = token;
} else if (["single", "multi"].includes(token)) {
defObj.multiplicity = token;

View File

@@ -7,7 +7,7 @@ import Expression from "./expression.js";
import NoteSet from "../note_set.js";
import becca from "../../../becca/becca.js";
import { normalize } from "../../utils.js";
import { normalizeSearchText, fuzzyMatchWordWithResult } from "../utils/text_utils.js";
import { normalizeSearchText, fuzzyMatchWord, fuzzyMatchWordWithResult } from "../utils/text_utils.js";
import beccaService from "../../../becca/becca_service.js";
class NoteFlatTextExp extends Expression {
@@ -23,18 +23,6 @@ class NoteFlatTextExp extends Expression {
execute(inputNoteSet: NoteSet, executionContext: any, searchContext: SearchContext) {
const resultNoteSet = new NoteSet();
// Cache normalized titles to avoid redundant normalize+getNoteTitle calls
const titleCache = new Map<string, string>();
const getNormalizedTitle = (noteId: string, parentNoteId: string): string => {
const key = `${noteId}-${parentNoteId}`;
let cached = titleCache.get(key);
if (cached === undefined) {
cached = normalizeSearchText(beccaService.getNoteTitle(noteId, parentNoteId));
titleCache.set(key, cached);
}
return cached;
};
/**
* @param note
* @param remainingTokens - tokens still needed to be found in the path towards root
@@ -50,8 +38,10 @@ class NoteFlatTextExp extends Expression {
const noteId = resultPath[resultPath.length - 1];
if (!resultNoteSet.hasNoteId(noteId)) {
// Snapshot takenPath since it's mutable
// we could get here from multiple paths, the first one wins because the paths
// are sorted by importance
executionContext.noteIdToNotePath[noteId] = resultPath;
resultNoteSet.add(becca.notes[noteId]);
}
}
@@ -60,40 +50,45 @@ class NoteFlatTextExp extends Expression {
}
if (note.parents.length === 0 || note.noteId === "root") {
// we've reached root, but there are still remaining tokens -> this candidate note produced no result
return;
}
const foundAttrTokens: string[] = [];
for (const token of remainingTokens) {
if ((note.type && note.type.includes(token)) ||
(note.mime && note.mime.includes(token))) {
// Add defensive checks for undefined properties
const typeMatches = note.type && note.type.includes(token);
const mimeMatches = note.mime && note.mime.includes(token);
if (typeMatches || mimeMatches) {
foundAttrTokens.push(token);
}
}
for (const attribute of note.getOwnedAttributes()) {
const normalizedName = normalizeSearchText(attribute.name);
const normalizedValue = normalizeSearchText(attribute.value);
for (const token of remainingTokens) {
if (attribute.normalizedName.includes(token) || attribute.normalizedValue.includes(token)) {
if (normalizedName.includes(token) || normalizedValue.includes(token)) {
foundAttrTokens.push(token);
}
}
}
for (const parentNote of note.parents) {
const title = getNormalizedTitle(note.noteId, parentNote.noteId);
// Use Set for O(1) lookup instead of Array.includes() which is O(n)
const foundTokenSet = new Set<string>(foundAttrTokens);
const title = normalizeSearchText(beccaService.getNoteTitle(note.noteId, parentNote.noteId));
const foundTokens: string[] = foundAttrTokens.slice();
for (const token of remainingTokens) {
if (this.smartMatch(title, token, searchContext)) {
foundTokenSet.add(token);
foundTokens.push(token);
}
}
if (foundTokenSet.size > 0) {
const newRemainingTokens = remainingTokens.filter((token) => !foundTokenSet.has(token));
if (foundTokens.length > 0) {
const newRemainingTokens = remainingTokens.filter((token) => !foundTokens.includes(token));
searchPathTowardsRoot(parentNote, newRemainingTokens, [note.noteId, ...takenPath]);
} else {
@@ -104,22 +99,6 @@ class NoteFlatTextExp extends Expression {
const candidateNotes = this.getCandidateNotes(inputNoteSet, searchContext);
// Fast path for single-token autocomplete searches:
// Skip the expensive recursive parent walk and just use getBestNotePath().
// The flat text already matched, so we know the token is present.
if (this.tokens.length === 1 && searchContext.autocomplete) {
for (const note of candidateNotes) {
if (!resultNoteSet.hasNoteId(note.noteId)) {
const notePath = note.getBestNotePath();
if (notePath) {
executionContext.noteIdToNotePath[note.noteId] = notePath;
resultNoteSet.add(note);
}
}
}
return resultNoteSet;
}
for (const note of candidateNotes) {
// autocomplete should be able to find notes by their noteIds as well (only leafs)
if (this.tokens.length === 1 && note.noteId.toLowerCase() === this.tokens[0]) {
@@ -133,13 +112,13 @@ class NoteFlatTextExp extends Expression {
// Add defensive checks for undefined properties
const typeMatches = note.type && note.type.includes(token);
const mimeMatches = note.mime && note.mime.includes(token);
if (typeMatches || mimeMatches) {
foundAttrTokens.push(token);
}
for (const attribute of note.ownedAttributes) {
if (attribute.normalizedName.includes(token) || attribute.normalizedValue.includes(token)) {
if (normalizeSearchText(attribute.name).includes(token) || normalizeSearchText(attribute.value).includes(token)) {
foundAttrTokens.push(token);
}
}
@@ -186,25 +165,10 @@ class NoteFlatTextExp extends Expression {
getCandidateNotes(noteSet: NoteSet, searchContext?: SearchContext): BNote[] {
const candidateNotes: BNote[] = [];
// Use the pre-built flat text index for fast scanning.
// This provides pre-computed flat texts in a parallel array, avoiding
// per-note property access overhead at large scale (50K+ notes).
const { notes: indexNotes, flatTexts } = becca.getFlatTextIndex();
// Build a set for quick membership check when noteSet isn't the full set
const isFullSet = noteSet.notes.length === indexNotes.length;
for (let i = 0; i < indexNotes.length; i++) {
const note = indexNotes[i];
// Skip notes not in the input set (only check when not using the full set)
if (!isFullSet && !noteSet.hasNoteId(note.noteId)) {
continue;
}
const flatText = flatTexts[i];
for (const note of noteSet.notes) {
const normalizedFlatText = normalizeSearchText(note.getFlatText());
for (const token of this.tokens) {
if (this.smartMatch(flatText, token, searchContext)) {
if (this.smartMatch(normalizedFlatText, token, searchContext)) {
candidateNotes.push(note);
break;
}

View File

@@ -1,7 +1,6 @@
"use strict";
import hoistedNoteService from "../hoisted_note.js";
import optionService from "../options.js";
import type { SearchParams } from "./services/types.js";
class SearchContext {
@@ -19,8 +18,6 @@ class SearchContext {
debug?: boolean;
debugInfo: {} | null;
fuzzyAttributeSearch: boolean;
/** When true, skip the two-phase fuzzy fallback and use the single-token fast path. */
autocomplete: boolean;
enableFuzzyMatching: boolean; // Controls whether fuzzy matching is enabled for this search phase
highlightedTokens: string[];
originalQuery: string;
@@ -49,12 +46,7 @@ class SearchContext {
this.debug = params.debug;
this.debugInfo = null;
this.fuzzyAttributeSearch = !!params.fuzzyAttributeSearch;
this.autocomplete = !!params.autocomplete;
try {
this.enableFuzzyMatching = optionService.getOptionBool("searchEnableFuzzyMatching");
} catch {
this.enableFuzzyMatching = true; // Default to true if option not yet initialized
}
this.enableFuzzyMatching = true; // Default to true for backward compatibility
this.highlightedTokens = [];
this.originalQuery = "";
this.fulltextQuery = ""; // complete fulltext part

View File

@@ -59,9 +59,8 @@ class SearchResult {
this.fuzzyScore = 0; // Reset fuzzy score tracking
const note = becca.notes[this.noteId];
// normalizeSearchText already lowercases — no need for .toLowerCase() first
const normalizedQuery = normalizeSearchText(fulltextQuery);
const normalizedTitle = normalizeSearchText(note.title);
const normalizedQuery = normalizeSearchText(fulltextQuery.toLowerCase());
const normalizedTitle = normalizeSearchText(note.title.toLowerCase());
// Note ID exact match, much higher score
if (note.noteId.toLowerCase() === fulltextQuery) {
@@ -92,37 +91,35 @@ class SearchResult {
}
addScoreForStrings(tokens: string[], str: string, factor: number, enableFuzzyMatching: boolean = true) {
// normalizeSearchText already lowercases — no need for .toLowerCase() first
const normalizedStr = normalizeSearchText(str);
const normalizedStr = normalizeSearchText(str.toLowerCase());
const chunks = normalizedStr.split(" ");
// Pre-normalize tokens once instead of per-chunk
const normalizedTokens = tokens.map(t => normalizeSearchText(t));
let tokenScore = 0;
for (const chunk of chunks) {
for (let ti = 0; ti < normalizedTokens.length; ti++) {
const normalizedToken = normalizedTokens[ti];
for (const token of tokens) {
const normalizedToken = normalizeSearchText(token.toLowerCase());
if (chunk === normalizedToken) {
tokenScore += SCORE_WEIGHTS.TOKEN_EXACT_MATCH * tokens[ti].length * factor;
tokenScore += SCORE_WEIGHTS.TOKEN_EXACT_MATCH * token.length * factor;
} else if (chunk.startsWith(normalizedToken)) {
tokenScore += SCORE_WEIGHTS.TOKEN_PREFIX_MATCH * tokens[ti].length * factor;
tokenScore += SCORE_WEIGHTS.TOKEN_PREFIX_MATCH * token.length * factor;
} else if (chunk.includes(normalizedToken)) {
tokenScore += SCORE_WEIGHTS.TOKEN_CONTAINS_MATCH * tokens[ti].length * factor;
} else if (enableFuzzyMatching &&
normalizedToken.length >= FUZZY_SEARCH_CONFIG.MIN_FUZZY_TOKEN_LENGTH &&
this.fuzzyScore < SCORE_WEIGHTS.MAX_TOTAL_FUZZY_SCORE) {
// Only compute edit distance when fuzzy matching is enabled
tokenScore += SCORE_WEIGHTS.TOKEN_CONTAINS_MATCH * token.length * factor;
} else {
// Try fuzzy matching for individual tokens with caps applied
const editDistance = calculateOptimizedEditDistance(chunk, normalizedToken, FUZZY_SEARCH_CONFIG.MAX_EDIT_DISTANCE);
if (editDistance <= FUZZY_SEARCH_CONFIG.MAX_EDIT_DISTANCE) {
if (editDistance <= FUZZY_SEARCH_CONFIG.MAX_EDIT_DISTANCE &&
normalizedToken.length >= FUZZY_SEARCH_CONFIG.MIN_FUZZY_TOKEN_LENGTH &&
this.fuzzyScore < SCORE_WEIGHTS.MAX_TOTAL_FUZZY_SCORE) {
const fuzzyWeight = SCORE_WEIGHTS.TOKEN_FUZZY_MATCH * (1 - editDistance / FUZZY_SEARCH_CONFIG.MAX_EDIT_DISTANCE);
const cappedTokenLength = Math.min(tokens[ti].length, SCORE_WEIGHTS.MAX_FUZZY_TOKEN_LENGTH_MULTIPLIER);
// Apply caps: limit token length multiplier and per-token contribution
const cappedTokenLength = Math.min(token.length, SCORE_WEIGHTS.MAX_FUZZY_TOKEN_LENGTH_MULTIPLIER);
const fuzzyTokenScore = Math.min(
fuzzyWeight * cappedTokenLength * factor,
SCORE_WEIGHTS.MAX_FUZZY_SCORE_PER_TOKEN
);
tokenScore += fuzzyTokenScore;
this.fuzzyScore += fuzzyTokenScore;
}

View File

@@ -1,5 +1,6 @@
"use strict";
import normalizeString from "normalize-strings";
import lex from "./lex.js";
import handleParens from "./handle_parens.js";
import parse from "./parse.js";
@@ -7,7 +8,7 @@ import SearchResult from "../search_result.js";
import SearchContext from "../search_context.js";
import becca from "../../../becca/becca.js";
import beccaService from "../../../becca/becca_service.js";
import { normalize, removeDiacritic, escapeHtml, escapeRegExp } from "../../utils.js";
import { normalize, escapeHtml, escapeRegExp } from "../../utils.js";
import log from "../../log.js";
import hoistedNoteService from "../../hoisted_note.js";
import type BNote from "../../../becca/entities/bnote.js";
@@ -16,6 +17,7 @@ import type { SearchParams, TokenStructure } from "./types.js";
import type Expression from "../expressions/expression.js";
import sql from "../../sql.js";
import scriptService from "../../script.js";
import striptags from "striptags";
import protectedSessionService from "../../protected_session.js";
export interface SearchNoteResult {
@@ -248,30 +250,23 @@ function findResultsWithExpression(expression: Expression, searchContext: Search
return performSearch(expression, searchContext, false);
}
// For autocomplete searches, skip the expensive two-phase fuzzy fallback.
// The user is typing and will refine their query — exact matching is
// sufficient and avoids a second full scan of all notes.
if (searchContext.autocomplete) {
return performSearch(expression, searchContext, false);
}
// Phase 1: Try exact matches first (without fuzzy matching)
const exactResults = performSearch(expression, searchContext, false);
// Check if we have sufficient high-quality results
const minResultThreshold = 5;
const minScoreForQuality = 10; // Minimum score to consider a result "high quality"
const highQualityResults = exactResults.filter(result => result.score >= minScoreForQuality);
// If we have enough high-quality exact matches, return them
if (highQualityResults.length >= minResultThreshold) {
return exactResults;
}
// Phase 2: Add fuzzy matching as fallback when exact matches are insufficient
const fuzzyResults = performSearch(expression, searchContext, true);
// Merge results, ensuring exact matches always rank higher than fuzzy matches
return mergeExactAndFuzzyResults(exactResults, fuzzyResults);
}
@@ -453,7 +448,7 @@ function extractContentSnippet(noteId: string, searchTokens: string[], maxLength
try {
let content = note.getContent();
if (!content || typeof content !== "string") {
return "";
}
@@ -469,66 +464,77 @@ function extractContentSnippet(noteId: string, searchTokens: string[], maxLength
return ""; // Protected but no session available
}
// Strip HTML tags for text notes — use fast regex for snippet extraction
// (striptags library is ~18x slower and not needed for search snippets)
// Strip HTML tags for text notes
if (note.type === "text") {
content = content.replace(/<[^>]*>/g, "");
content = striptags(content);
}
// Normalize whitespace while preserving paragraph breaks
// First, normalize multiple newlines to double newlines (paragraph breaks)
content = content.replace(/\n\s*\n/g, "\n\n");
// Then normalize spaces within lines
content = content.split('\n').map(line => line.replace(/\s+/g, " ").trim()).join('\n');
// Finally trim the whole content
content = content.trim();
if (!content) {
return "";
}
// Find match position using normalize on the raw stripped content.
// We use a single normalize() pass — no need for expensive whitespace
// normalization just to find the match index.
const normalizedContent = normalize(content);
const normalizedTokens = searchTokens.map(token => normalize(token));
// Try to find a snippet around the first matching token
const normalizedContent = normalizeString(content.toLowerCase());
let snippetStart = 0;
let matchFound = false;
for (const normalizedToken of normalizedTokens) {
for (const token of searchTokens) {
const normalizedToken = normalizeString(token.toLowerCase());
const matchIndex = normalizedContent.indexOf(normalizedToken);
if (matchIndex !== -1) {
// Center the snippet around the match
snippetStart = Math.max(0, matchIndex - maxLength / 2);
matchFound = true;
break;
}
}
// Extract a snippet region from the raw content, then clean only that
const snippetRegion = content.substring(snippetStart, snippetStart + maxLength + 100);
// Extract snippet
let snippet = content.substring(snippetStart, snippetStart + maxLength);
// Normalize whitespace only on the small snippet region
let snippet = snippetRegion
.replace(/\n\s*\n/g, "\n\n")
.replace(/[ \t]+/g, " ")
.trim()
.substring(0, maxLength);
// If snippet contains linebreaks, limit to max 4 lines
// If snippet contains linebreaks, limit to max 4 lines and override character limit
const lines = snippet.split('\n');
if (lines.length > 4) {
// Find which lines contain the search tokens to ensure they're included
const normalizedLines = lines.map(line => normalizeString(line.toLowerCase()));
const normalizedTokens = searchTokens.map(token => normalizeString(token.toLowerCase()));
// Find the first line that contains a search token
let firstMatchLine = -1;
for (let i = 0; i < lines.length; i++) {
const normalizedLine = normalize(lines[i]);
if (normalizedTokens.some(token => normalizedLine.includes(token))) {
for (let i = 0; i < normalizedLines.length; i++) {
if (normalizedTokens.some(token => normalizedLines[i].includes(token))) {
firstMatchLine = i;
break;
}
}
if (firstMatchLine !== -1) {
// Center the 4-line window around the first match
// Try to show 1 line before and 2 lines after the match
const startLine = Math.max(0, firstMatchLine - 1);
const endLine = Math.min(lines.length, startLine + 4);
snippet = lines.slice(startLine, endLine).join('\n');
} else {
// No match found in lines (shouldn't happen), just take first 4
snippet = lines.slice(0, 4).join('\n');
}
// Add ellipsis if we truncated lines
snippet = snippet + "...";
} else if (lines.length <= 1) {
// Single line content - apply word boundary logic
} else if (lines.length > 1) {
// For multi-line snippets that are 4 or fewer lines, keep them as-is
// No need to truncate
} else {
// Single line content - apply original word boundary logic
// Try to start/end at word boundaries
if (snippetStart > 0) {
const firstSpace = snippet.search(/\s/);
if (firstSpace > 0 && firstSpace < 20) {
@@ -536,7 +542,7 @@ function extractContentSnippet(noteId: string, searchTokens: string[], maxLength
}
snippet = "..." + snippet;
}
if (snippetStart + maxLength < content.length) {
const lastSpace = snippet.search(/\s[^\s]*$/);
if (lastSpace > snippet.length - 20 && lastSpace > 0) {
@@ -576,7 +582,7 @@ function extractAttributeSnippet(noteId: string, searchTokens: string[], maxLeng
// Check if any search token matches the attribute name or value
const hasMatch = searchTokens.some(token => {
const normalizedToken = normalize(token);
const normalizedToken = normalizeString(token.toLowerCase());
return attrName.includes(normalizedToken) || attrValue.includes(normalizedToken);
});
@@ -644,8 +650,7 @@ function searchNotesForAutocomplete(query: string, fastSearch: boolean = true) {
includeHiddenNotes: true,
fuzzyAttributeSearch: true,
ignoreInternalAttributes: true,
ancestorNoteId: hoistedNoteService.isHoistedInHiddenSubtree() ? "root" : hoistedNoteService.getHoistedNoteId(),
autocomplete: true
ancestorNoteId: hoistedNoteService.isHoistedInHiddenSubtree() ? "root" : hoistedNoteService.getHoistedNoteId()
});
const allSearchResults = findResultsWithQuery(query, searchContext);
@@ -722,40 +727,37 @@ function highlightSearchResults(searchResults: SearchResult[], highlightedTokens
}
for (const result of searchResults) {
// Reset token
const tokenRegex = new RegExp(escapeRegExp(token), "gi");
let match;
// Highlight in note path title
if (result.highlightedNotePathTitle) {
const titleRegex = new RegExp(escapeRegExp(token), "gi");
// Compute diacritic-free version ONCE before the loop, not on every iteration
let titleNoDiacritics = removeDiacritic(result.highlightedNotePathTitle);
while ((match = titleRegex.exec(titleNoDiacritics)) !== null) {
while ((match = titleRegex.exec(normalizeString(result.highlightedNotePathTitle))) !== null) {
result.highlightedNotePathTitle = wrapText(result.highlightedNotePathTitle, match.index, token.length, "{", "}");
// 2 characters are added, so we need to adjust the index and re-derive
// 2 characters are added, so we need to adjust the index
titleRegex.lastIndex += 2;
titleNoDiacritics = removeDiacritic(result.highlightedNotePathTitle);
}
}
// Highlight in content snippet
if (result.highlightedContentSnippet) {
const contentRegex = new RegExp(escapeRegExp(token), "gi");
let contentNoDiacritics = removeDiacritic(result.highlightedContentSnippet);
while ((match = contentRegex.exec(contentNoDiacritics)) !== null) {
while ((match = contentRegex.exec(normalizeString(result.highlightedContentSnippet))) !== null) {
result.highlightedContentSnippet = wrapText(result.highlightedContentSnippet, match.index, token.length, "{", "}");
// 2 characters are added, so we need to adjust the index
contentRegex.lastIndex += 2;
contentNoDiacritics = removeDiacritic(result.highlightedContentSnippet);
}
}
// Highlight in attribute snippet
if (result.highlightedAttributeSnippet) {
const attributeRegex = new RegExp(escapeRegExp(token), "gi");
let attrNoDiacritics = removeDiacritic(result.highlightedAttributeSnippet);
while ((match = attributeRegex.exec(attrNoDiacritics)) !== null) {
while ((match = attributeRegex.exec(normalizeString(result.highlightedAttributeSnippet))) !== null) {
result.highlightedAttributeSnippet = wrapText(result.highlightedAttributeSnippet, match.index, token.length, "{", "}");
// 2 characters are added, so we need to adjust the index
attributeRegex.lastIndex += 2;
attrNoDiacritics = removeDiacritic(result.highlightedAttributeSnippet);
}
}
}

View File

@@ -1,675 +0,0 @@
/**
* Comprehensive search benchmark suite.
*
* Covers many scenarios:
* - Single-token, multi-token, phrase-like queries
* - Fuzzy matching enabled vs disabled
* - Autocomplete vs full search
* - Diacritics / unicode queries
* - No-match queries
* - Varying note counts (1K, 5K, 10K, 20K)
* - Warm cache vs cold cache
*
* All times are in-memory (monkeypatched getContent, no real SQL).
*/
import { describe, it, expect, afterEach } from "vitest";
import searchService from "./search.js";
import BNote from "../../../becca/entities/bnote.js";
import BBranch from "../../../becca/entities/bbranch.js";
import SearchContext from "../search_context.js";
import becca from "../../../becca/becca.js";
import { NoteBuilder, note } from "../../../test/becca_mocking.js";
// ── helpers ──────────────────────────────────────────────────────────
function randomWord(len = 6): string {
const chars = "abcdefghijklmnopqrstuvwxyz";
let word = "";
for (let i = 0; i < len; i++) {
word += chars[Math.floor(Math.random() * chars.length)];
}
return word;
}
function generateHtmlContent(wordCount: number, includeKeywords = false, keywords?: string[]): string {
const paragraphs: string[] = [];
let wordsRemaining = wordCount;
const kws = keywords ?? [];
while (wordsRemaining > 0) {
const paraWords = Math.min(wordsRemaining, 20 + Math.floor(Math.random() * 40));
const words: string[] = [];
for (let i = 0; i < paraWords; i++) {
words.push(randomWord(3 + Math.floor(Math.random() * 10)));
}
if (includeKeywords && paragraphs.length === 2) {
for (let k = 0; k < kws.length; k++) {
const pos = Math.min(words.length - 1, Math.floor((words.length / (kws.length + 1)) * (k + 1)));
words[pos] = kws[k];
}
}
paragraphs.push(`<p>${words.join(" ")}</p>`);
wordsRemaining -= paraWords;
}
return `<html><body>${paragraphs.join("\n")}</body></html>`;
}
function timed<T>(fn: () => T): [T, number] {
const start = performance.now();
const result = fn();
return [result, performance.now() - start];
}
function avg(nums: number[]): number {
return nums.reduce((a, b) => a + b, 0) / nums.length;
}
function min(nums: number[]): number {
return Math.min(...nums);
}
// ── dataset builder ──────────────────────────────────────────────────
const syntheticContent: Record<string, string> = {};
function buildDataset(noteCount: number, opts: {
matchFraction?: number;
labelsPerNote?: number;
depth?: number;
contentWordCount?: number;
varyContentSize?: boolean;
titleKeywords?: string[];
contentKeywords?: string[];
/** Include notes with diacritics in titles */
includeDiacritics?: boolean;
} = {}) {
const {
matchFraction = 0.1,
labelsPerNote = 3,
depth = 4,
contentWordCount = 300,
varyContentSize = true,
titleKeywords = ["target"],
contentKeywords = titleKeywords,
includeDiacritics = false,
} = opts;
becca.reset();
for (const key of Object.keys(syntheticContent)) {
delete syntheticContent[key];
}
const rootNote = new NoteBuilder(new BNote({ noteId: "root", title: "root", type: "text" }));
new BBranch({
branchId: "none_root",
noteId: "root",
parentNoteId: "none",
notePosition: 10
});
const containers: NoteBuilder[] = [];
let parent = rootNote;
for (let d = 0; d < depth; d++) {
const container = note(`Container_${d}_${randomWord(4)}`);
parent.child(container);
containers.push(container);
parent = container;
}
const matchCount = Math.floor(noteCount * matchFraction);
const diacriticTitles = [
"résumé", "naïve", "café", "über", "ñoño", "exposé",
"Ångström", "Üntersuchung", "São Paulo", "François"
];
for (let i = 0; i < noteCount; i++) {
const isMatch = i < matchCount;
let title: string;
if (includeDiacritics && i % 20 === 0) {
// Every 20th note gets a diacritics-heavy title
const dTitle = diacriticTitles[i % diacriticTitles.length];
title = isMatch
? `${dTitle} ${titleKeywords.join(" ")} Document ${i}`
: `${dTitle} ${randomWord(5)} Note ${i}`;
} else {
title = isMatch
? `${randomWord(5)} ${titleKeywords.join(" ")} ${randomWord(5)} Document ${i}`
: `${randomWord(5)} ${randomWord(6)} ${randomWord(4)} Note ${i}`;
}
const n = note(title);
for (let l = 0; l < labelsPerNote; l++) {
const labelName = isMatch && l === 0 ? "category" : `label_${randomWord(4)}`;
const labelValue = isMatch && l === 0 ? `important ${titleKeywords[0]}` : randomWord(8);
n.label(labelName, labelValue);
}
let noteWordCount = contentWordCount;
if (varyContentSize) {
const r = Math.random();
if (r < 0.2) noteWordCount = Math.floor(contentWordCount * (0.2 + Math.random() * 0.3));
else if (r < 0.7) noteWordCount = Math.floor(contentWordCount * (0.7 + Math.random() * 0.6));
else if (r < 0.9) noteWordCount = Math.floor(contentWordCount * (1.3 + Math.random() * 0.7));
else noteWordCount = Math.floor(contentWordCount * (2.0 + Math.random() * 1.0));
}
const includeContentKeyword = isMatch && contentKeywords.length > 0;
syntheticContent[n.note.noteId] = generateHtmlContent(
noteWordCount,
includeContentKeyword,
includeContentKeyword ? contentKeywords : undefined
);
const containerIndex = i % containers.length;
containers[containerIndex].child(n);
}
// Monkeypatch getContent()
for (const noteObj of Object.values(becca.notes)) {
const noteId = noteObj.noteId;
if (syntheticContent[noteId]) {
(noteObj as any).getContent = () => syntheticContent[noteId];
} else {
(noteObj as any).getContent = () => "";
}
}
return { rootNote, matchCount };
}
// ── benchmark runner ─────────────────────────────────────────────────
interface BenchmarkResult {
query: string;
mode: string;
noteCount: number;
avgMs: number;
minMs: number;
resultCount: number;
}
function runBenchmark(
query: string,
mode: "autocomplete" | "fullSearch",
fuzzyEnabled: boolean,
iterations = 5
): BenchmarkResult {
const noteCount = Object.keys(becca.notes).length;
// Warm up
if (mode === "autocomplete") {
searchService.searchNotesForAutocomplete(query, true);
} else {
const ctx = new SearchContext({ fastSearch: false });
ctx.enableFuzzyMatching = fuzzyEnabled;
searchService.findResultsWithQuery(query, ctx);
}
const times: number[] = [];
let resultCount = 0;
for (let i = 0; i < iterations; i++) {
if (mode === "autocomplete") {
// For autocomplete, fuzzy is controlled by the global option
// We'll manipulate enableFuzzyMatching after construction
const [results, ms] = timed(() => {
// searchNotesForAutocomplete creates its own SearchContext internally
// so we need to test via findResultsWithQuery for fuzzy control
const ctx = new SearchContext({
fastSearch: true,
includeHiddenNotes: true,
fuzzyAttributeSearch: true,
ignoreInternalAttributes: true,
autocomplete: true
});
ctx.enableFuzzyMatching = fuzzyEnabled;
return searchService.findResultsWithQuery(query, ctx);
});
times.push(ms);
resultCount = results.length;
} else {
const [results, ms] = timed(() => {
const ctx = new SearchContext({ fastSearch: false });
ctx.enableFuzzyMatching = fuzzyEnabled;
return searchService.findResultsWithQuery(query, ctx);
});
times.push(ms);
resultCount = results.length;
}
}
return {
query,
mode: `${mode}${fuzzyEnabled ? "+fuzzy" : ""}`,
noteCount,
avgMs: avg(times),
minMs: min(times),
resultCount
};
}
function printTable(title: string, results: BenchmarkResult[]) {
console.log(`\n${"═".repeat(110)}`);
console.log(` ${title}`);
console.log(`${"═".repeat(110)}`);
console.log(
" " +
"Query".padEnd(35) +
"Mode".padEnd(22) +
"Notes".padStart(7) +
"Avg (ms)".padStart(12) +
"Min (ms)".padStart(12) +
"Results".padStart(10)
);
console.log(` ${"─".repeat(98)}`);
for (const r of results) {
console.log(
" " +
`"${r.query}"`.padEnd(35) +
r.mode.padEnd(22) +
String(r.noteCount).padStart(7) +
r.avgMs.toFixed(1).padStart(12) +
r.minMs.toFixed(1).padStart(12) +
String(r.resultCount).padStart(10)
);
}
console.log(`${"═".repeat(110)}\n`);
}
// ── tests ────────────────────────────────────────────────────────────
describe("Comprehensive Search Benchmark", () => {
afterEach(() => {
becca.reset();
});
describe("Single-token queries", () => {
for (const noteCount of [1000, 5000, 10000, 20000]) {
it(`single token @ ${noteCount} notes — fuzzy on vs off, autocomplete vs full`, () => {
buildDataset(noteCount, {
matchFraction: 0.15,
titleKeywords: ["meeting"],
contentKeywords: ["meeting"],
contentWordCount: 300,
});
const results: BenchmarkResult[] = [
runBenchmark("meeting", "autocomplete", false),
runBenchmark("meeting", "autocomplete", true),
runBenchmark("meeting", "fullSearch", false),
runBenchmark("meeting", "fullSearch", true),
];
printTable(`Single Token "meeting" — ${noteCount} notes`, results);
expect(results[0].resultCount).toBeGreaterThan(0);
});
}
});
describe("Multi-token queries", () => {
for (const noteCount of [1000, 5000, 10000, 20000]) {
it(`multi token @ ${noteCount} notes — fuzzy on vs off`, () => {
buildDataset(noteCount, {
matchFraction: 0.15,
titleKeywords: ["meeting", "notes", "january"],
contentKeywords: ["meeting", "notes", "january"],
contentWordCount: 400,
});
const results: BenchmarkResult[] = [
// 2-token
runBenchmark("meeting notes", "autocomplete", false),
runBenchmark("meeting notes", "autocomplete", true),
runBenchmark("meeting notes", "fullSearch", false),
runBenchmark("meeting notes", "fullSearch", true),
// 3-token
runBenchmark("meeting notes january", "autocomplete", false),
runBenchmark("meeting notes january", "autocomplete", true),
runBenchmark("meeting notes january", "fullSearch", false),
runBenchmark("meeting notes january", "fullSearch", true),
];
printTable(`Multi Token — ${noteCount} notes`, results);
expect(results[0].resultCount).toBeGreaterThan(0);
});
}
});
describe("No-match queries (worst case — full scan, zero results)", () => {
for (const noteCount of [1000, 5000, 10000, 20000]) {
it(`no-match @ ${noteCount} notes`, () => {
buildDataset(noteCount, {
matchFraction: 0.1,
titleKeywords: ["target"],
contentKeywords: ["target"],
contentWordCount: 300,
});
const results: BenchmarkResult[] = [
runBenchmark("xyznonexistent", "autocomplete", false),
runBenchmark("xyznonexistent", "autocomplete", true),
runBenchmark("xyznonexistent", "fullSearch", false),
runBenchmark("xyznonexistent", "fullSearch", true),
runBenchmark("xyzfoo xyzbar", "autocomplete", false),
runBenchmark("xyzfoo xyzbar", "autocomplete", true),
runBenchmark("xyzfoo xyzbar", "fullSearch", false),
runBenchmark("xyzfoo xyzbar", "fullSearch", true),
];
printTable(`No-Match Queries — ${noteCount} notes`, results);
// All should return 0 results
for (const r of results) {
expect(r.resultCount).toBe(0);
}
});
}
});
describe("Diacritics / Unicode queries", () => {
for (const noteCount of [1000, 5000, 10000]) {
it(`diacritics @ ${noteCount} notes`, () => {
buildDataset(noteCount, {
matchFraction: 0.15,
titleKeywords: ["résumé"],
contentKeywords: ["résumé"],
contentWordCount: 300,
includeDiacritics: true,
});
const results: BenchmarkResult[] = [
// Exact diacritics
runBenchmark("résumé", "autocomplete", false),
runBenchmark("résumé", "autocomplete", true),
// ASCII equivalent (should still match via normalize)
runBenchmark("resume", "autocomplete", false),
runBenchmark("resume", "autocomplete", true),
// Full search
runBenchmark("résumé", "fullSearch", false),
runBenchmark("resume", "fullSearch", false),
];
printTable(`Diacritics "résumé" / "resume" — ${noteCount} notes`, results);
});
}
});
describe("Partial / prefix queries (simulating typing)", () => {
for (const noteCount of [5000, 10000, 20000]) {
it(`typing progression @ ${noteCount} notes`, () => {
buildDataset(noteCount, {
matchFraction: 0.15,
titleKeywords: ["documentation"],
contentKeywords: ["documentation"],
contentWordCount: 300,
});
const results: BenchmarkResult[] = [
runBenchmark("d", "autocomplete", false),
runBenchmark("do", "autocomplete", false),
runBenchmark("doc", "autocomplete", false),
runBenchmark("docu", "autocomplete", false),
runBenchmark("docum", "autocomplete", false),
runBenchmark("document", "autocomplete", false),
runBenchmark("documentation", "autocomplete", false),
// Same with fuzzy
runBenchmark("d", "autocomplete", true),
runBenchmark("doc", "autocomplete", true),
runBenchmark("document", "autocomplete", true),
runBenchmark("documentation", "autocomplete", true),
];
printTable(`Typing Progression "documentation" — ${noteCount} notes`, results);
});
}
});
describe("Attribute-matching queries", () => {
for (const noteCount of [5000, 10000]) {
it(`attribute search @ ${noteCount} notes`, () => {
buildDataset(noteCount, {
matchFraction: 0.15,
labelsPerNote: 5,
titleKeywords: ["important"],
contentKeywords: ["important"],
contentWordCount: 200,
});
const results: BenchmarkResult[] = [
// "category" is a label name on matching notes
runBenchmark("category", "autocomplete", false),
runBenchmark("category", "autocomplete", true),
runBenchmark("category", "fullSearch", false),
runBenchmark("category", "fullSearch", true),
// "important" appears in both title and label value
runBenchmark("important", "autocomplete", false),
runBenchmark("important", "autocomplete", true),
];
printTable(`Attribute Matching — ${noteCount} notes`, results);
});
}
});
describe("Long queries (4-5 tokens)", () => {
for (const noteCount of [5000, 10000]) {
it(`long query @ ${noteCount} notes`, () => {
buildDataset(noteCount, {
matchFraction: 0.10,
titleKeywords: ["quarterly", "budget", "review", "report"],
contentKeywords: ["quarterly", "budget", "review", "report"],
contentWordCount: 500,
});
const results: BenchmarkResult[] = [
runBenchmark("quarterly", "autocomplete", false),
runBenchmark("quarterly budget", "autocomplete", false),
runBenchmark("quarterly budget review", "autocomplete", false),
runBenchmark("quarterly budget review report", "autocomplete", false),
// Same with fuzzy
runBenchmark("quarterly budget review report", "autocomplete", true),
// Full search
runBenchmark("quarterly budget review report", "fullSearch", false),
runBenchmark("quarterly budget review report", "fullSearch", true),
];
printTable(`Long Queries (4 tokens) — ${noteCount} notes`, results);
});
}
});
describe("Mixed scenario — realistic user session", () => {
it("simulates a user session with varied queries @ 10K notes", () => {
buildDataset(10000, {
matchFraction: 0.15,
titleKeywords: ["project", "planning"],
contentKeywords: ["project", "planning", "timeline", "budget"],
contentWordCount: 400,
varyContentSize: true,
includeDiacritics: true,
depth: 6,
});
const results: BenchmarkResult[] = [
// Quick autocomplete lookups (user typing in search bar)
runBenchmark("pro", "autocomplete", false),
runBenchmark("project", "autocomplete", false),
runBenchmark("project plan", "autocomplete", false),
// Full search (user hits Enter)
runBenchmark("project", "fullSearch", false),
runBenchmark("project planning", "fullSearch", false),
runBenchmark("project planning", "fullSearch", true),
// Typo / near-miss with fuzzy
runBenchmark("projct", "autocomplete", false),
runBenchmark("projct", "autocomplete", true),
runBenchmark("projct planing", "fullSearch", false),
runBenchmark("projct planing", "fullSearch", true),
// No results
runBenchmark("xyznonexistent", "autocomplete", false),
runBenchmark("xyznonexistent foo", "fullSearch", true),
// Short common substring
runBenchmark("note", "autocomplete", false),
runBenchmark("document", "autocomplete", false),
];
printTable("Realistic User Session — 10K notes", results);
});
});
describe("Cache warmth impact", () => {
it("cold vs warm flat text index @ 10K notes", () => {
buildDataset(10000, {
matchFraction: 0.15,
titleKeywords: ["target"],
contentKeywords: ["target"],
contentWordCount: 300,
});
console.log(`\n${"═".repeat(80)}`);
console.log(" Cold vs Warm Cache — 10K notes");
console.log(`${"═".repeat(80)}`);
// Cold: first search after dataset build (flat text index not yet built)
becca.flatTextIndex = null;
becca.dirtyFlatTextNoteIds.clear();
const [coldResults, coldMs] = timed(() => {
const ctx = new SearchContext({ fastSearch: true, autocomplete: true });
ctx.enableFuzzyMatching = false;
return searchService.findResultsWithQuery("target", ctx);
});
console.log(` Cold (index build + search): ${coldMs.toFixed(1)}ms (${coldResults.length} results)`);
// Warm: subsequent searches reuse the index
const warmTimes: number[] = [];
for (let i = 0; i < 5; i++) {
const [, ms] = timed(() => {
const ctx = new SearchContext({ fastSearch: true, autocomplete: true });
ctx.enableFuzzyMatching = false;
return searchService.findResultsWithQuery("target", ctx);
});
warmTimes.push(ms);
}
console.log(` Warm (reuse index, 5 runs): avg ${avg(warmTimes).toFixed(1)}ms min ${min(warmTimes).toFixed(1)}ms`);
// Incremental: dirty a few notes and search again
const noteIds = Object.keys(becca.notes).slice(0, 50);
for (const nid of noteIds) {
becca.dirtyNoteFlatText(nid);
}
const [, incrMs] = timed(() => {
const ctx = new SearchContext({ fastSearch: true, autocomplete: true });
ctx.enableFuzzyMatching = false;
return searchService.findResultsWithQuery("target", ctx);
});
console.log(` Incremental (50 dirty notes): ${incrMs.toFixed(1)}ms`);
// Full rebuild
becca.flatTextIndex = null;
const [, rebuildMs] = timed(() => {
const ctx = new SearchContext({ fastSearch: true, autocomplete: true });
ctx.enableFuzzyMatching = false;
return searchService.findResultsWithQuery("target", ctx);
});
console.log(` Full rebuild (index = null): ${rebuildMs.toFixed(1)}ms`);
console.log(`${"═".repeat(80)}\n`);
});
});
describe("Fuzzy matching effectiveness comparison", () => {
it("exact vs fuzzy result quality @ 10K notes", () => {
buildDataset(10000, {
matchFraction: 0.10,
titleKeywords: ["performance"],
contentKeywords: ["performance", "optimization"],
contentWordCount: 300,
});
console.log(`\n${"═".repeat(90)}`);
console.log(" Fuzzy Matching Effectiveness — 10K notes");
console.log(`${"═".repeat(90)}`);
console.log(
" " +
"Query".padEnd(30) +
"Fuzzy".padEnd(8) +
"Time (ms)".padStart(12) +
"Results".padStart(10) +
" Notes"
);
console.log(` ${"─".repeat(70)}`);
const queries = [
"performance", // exact match
"performanc", // truncated
"preformance", // typo
"performence", // common misspelling
"optimization", // exact match
"optimzation", // typo
"perf optim", // abbreviated multi
];
for (const query of queries) {
for (const fuzzy of [false, true]) {
const times: number[] = [];
let resultCount = 0;
for (let i = 0; i < 3; i++) {
const [results, ms] = timed(() => {
const ctx = new SearchContext({ fastSearch: true });
ctx.enableFuzzyMatching = fuzzy;
return searchService.findResultsWithQuery(query, ctx);
});
times.push(ms);
resultCount = results.length;
}
console.log(
" " +
`"${query}"`.padEnd(30) +
(fuzzy ? "ON" : "OFF").padEnd(8) +
avg(times).toFixed(1).padStart(12) +
String(resultCount).padStart(10)
);
}
}
console.log(`${"═".repeat(90)}\n`);
});
});
describe("Scale comparison summary", () => {
it("summary table across all note counts", () => {
const summaryResults: BenchmarkResult[] = [];
for (const noteCount of [1000, 5000, 10000, 20000]) {
buildDataset(noteCount, {
matchFraction: 0.15,
titleKeywords: ["meeting", "notes"],
contentKeywords: ["meeting", "notes"],
contentWordCount: 400,
varyContentSize: true,
depth: 5,
});
// Core scenarios
summaryResults.push(runBenchmark("meeting", "autocomplete", false));
summaryResults.push(runBenchmark("meeting", "autocomplete", true));
summaryResults.push(runBenchmark("meeting notes", "autocomplete", false));
summaryResults.push(runBenchmark("meeting notes", "autocomplete", true));
summaryResults.push(runBenchmark("meeting", "fullSearch", false));
summaryResults.push(runBenchmark("meeting", "fullSearch", true));
summaryResults.push(runBenchmark("meeting notes", "fullSearch", false));
summaryResults.push(runBenchmark("meeting notes", "fullSearch", true));
summaryResults.push(runBenchmark("xyznonexistent", "autocomplete", false));
summaryResults.push(runBenchmark("xyznonexistent", "fullSearch", true));
}
printTable("Scale Comparison Summary", summaryResults);
});
});
});

View File

@@ -1,665 +0,0 @@
/**
* Search performance profiling tests.
*
* These tests measure where time is spent in the search pipeline.
* We monkeypatch note.getContent() to return synthetic HTML content
* since unit tests don't have a real SQLite database.
*
* KNOWN GAPS vs production:
* - note.getContent() is instant (monkeypatched) vs ~2ms SQL fetch
* - NoteContentFulltextExp.execute() is skipped (no sql.iterateRows)
* because fastSearch=true uses only NoteFlatTextExp
* - These tests focus on the in-memory/CPU-bound parts of the pipeline
*/
import { describe, it, expect, beforeEach, afterEach } from "vitest";
import searchService from "./search.js";
import BNote from "../../../becca/entities/bnote.js";
import BBranch from "../../../becca/entities/bbranch.js";
import SearchContext from "../search_context.js";
import becca from "../../../becca/becca.js";
import beccaService from "../../../becca/becca_service.js";
import { NoteBuilder, note, id } from "../../../test/becca_mocking.js";
import SearchResult from "../search_result.js";
import { normalizeSearchText } from "../utils/text_utils.js";
// ── helpers ──────────────────────────────────────────────────────────
function randomWord(len = 6): string {
const chars = "abcdefghijklmnopqrstuvwxyz";
let word = "";
for (let i = 0; i < len; i++) {
word += chars[Math.floor(Math.random() * chars.length)];
}
return word;
}
function generateHtmlContent(wordCount: number, includeKeywords = false, keywords?: string[]): string {
const paragraphs: string[] = [];
let wordsRemaining = wordCount;
const kws = keywords ?? ["target"];
while (wordsRemaining > 0) {
const paraWords = Math.min(wordsRemaining, 20 + Math.floor(Math.random() * 40));
const words: string[] = [];
for (let i = 0; i < paraWords; i++) {
words.push(randomWord(3 + Math.floor(Math.random() * 10)));
}
if (includeKeywords && paragraphs.length === 2) {
// Inject all keywords into the paragraph at spaced positions
for (let k = 0; k < kws.length; k++) {
const pos = Math.min(words.length - 1, Math.floor((words.length / (kws.length + 1)) * (k + 1)));
words[pos] = kws[k];
}
}
paragraphs.push(`<p>${words.join(" ")}</p>`);
wordsRemaining -= paraWords;
}
return `<html><body>${paragraphs.join("\n")}</body></html>`;
}
function timed<T>(fn: () => T): [T, number] {
const start = performance.now();
const result = fn();
return [result, performance.now() - start];
}
interface TimingEntry { label: string; ms: number; }
function reportTimings(title: string, timings: TimingEntry[]) {
const total = timings.reduce((s, t) => s + t.ms, 0);
console.log(`\n=== ${title} (total: ${total.toFixed(1)}ms) ===`);
for (const { label, ms } of timings) {
const pct = total > 0 ? ((ms / total) * 100).toFixed(0) : "0";
const bar = "#".repeat(Math.max(1, Math.round(ms / total * 40)));
console.log(` ${label.padEnd(55)} ${ms.toFixed(1).padStart(8)}ms ${pct.padStart(3)}% ${bar}`);
}
}
// ── dataset builder ──────────────────────────────────────────────────
const syntheticContent: Record<string, string> = {};
function buildDataset(noteCount: number, opts: {
matchFraction?: number;
labelsPerNote?: number;
depth?: number;
contentWordCount?: number;
/** When set, contentWordCount is treated as a median and actual sizes vary from 0.2x to 3x */
varyContentSize?: boolean;
/** Keywords to inject into matching notes' titles (default: ["target"]) */
titleKeywords?: string[];
/** Keywords to inject into matching notes' content (default: same as titleKeywords) */
contentKeywords?: string[];
} = {}) {
const {
matchFraction = 0.1,
labelsPerNote = 3,
depth = 3,
contentWordCount = 200,
varyContentSize = false,
titleKeywords = ["target"],
contentKeywords = titleKeywords,
} = opts;
becca.reset();
for (const key of Object.keys(syntheticContent)) {
delete syntheticContent[key];
}
const rootNote = new NoteBuilder(new BNote({ noteId: "root", title: "root", type: "text" }));
new BBranch({
branchId: "none_root",
noteId: "root",
parentNoteId: "none",
notePosition: 10
});
const containers: NoteBuilder[] = [];
let parent = rootNote;
for (let d = 0; d < depth; d++) {
const container = note(`Container_${d}_${randomWord(4)}`);
parent.child(container);
containers.push(container);
parent = container;
}
const matchCount = Math.floor(noteCount * matchFraction);
for (let i = 0; i < noteCount; i++) {
const isMatch = i < matchCount;
const title = isMatch
? `${randomWord(5)} ${titleKeywords.join(" ")} ${randomWord(5)} Document ${i}`
: `${randomWord(5)} ${randomWord(6)} ${randomWord(4)} Note ${i}`;
const n = note(title);
for (let l = 0; l < labelsPerNote; l++) {
const labelName = isMatch && l === 0 ? "category" : `label_${randomWord(4)}`;
const labelValue = isMatch && l === 0 ? `important ${titleKeywords[0]}` : randomWord(8);
n.label(labelName, labelValue);
}
// Vary content size: 0.2x to 3x the median, producing a realistic
// mix of short stubs, medium notes, and long documents.
let noteWordCount = contentWordCount;
if (varyContentSize) {
const r = Math.random();
if (r < 0.2) {
noteWordCount = Math.floor(contentWordCount * (0.2 + Math.random() * 0.3)); // 20-50% (short stubs)
} else if (r < 0.7) {
noteWordCount = Math.floor(contentWordCount * (0.7 + Math.random() * 0.6)); // 70-130% (medium)
} else if (r < 0.9) {
noteWordCount = Math.floor(contentWordCount * (1.3 + Math.random() * 0.7)); // 130-200% (long)
} else {
noteWordCount = Math.floor(contentWordCount * (2.0 + Math.random() * 1.0)); // 200-300% (very long)
}
}
const includeContentKeyword = isMatch && contentKeywords.length > 0;
syntheticContent[n.note.noteId] = generateHtmlContent(
noteWordCount,
includeContentKeyword,
includeContentKeyword ? contentKeywords : undefined
);
const containerIndex = i % containers.length;
containers[containerIndex].child(n);
}
// Monkeypatch getContent()
for (const noteObj of Object.values(becca.notes)) {
const noteId = noteObj.noteId;
if (syntheticContent[noteId]) {
(noteObj as any).getContent = () => syntheticContent[noteId];
} else {
(noteObj as any).getContent = () => "";
}
}
return { rootNote, matchCount };
}
// ── profiling tests ──────────────────────────────────────────────────
describe("Search Profiling", () => {
afterEach(() => {
becca.reset();
});
/**
* Break down the autocomplete pipeline into every individual stage,
* including previously unmeasured operations like getBestNotePath,
* SearchResult construction, and getNoteTitleForPath.
*/
describe("Granular autocomplete pipeline", () => {
for (const noteCount of [500, 2000, 5000, 10000]) {
it(`granular breakdown with ${noteCount} notes`, () => {
const timings: TimingEntry[] = [];
const [, buildMs] = timed(() => buildDataset(noteCount, {
matchFraction: 0.2,
contentWordCount: 300,
depth: 5
}));
timings.push({ label: `Dataset build (${noteCount} notes)`, ms: buildMs });
// === NoteFlatTextExp: getCandidateNotes ===
// This calls getFlatText() + normalizeSearchText() for EVERY note
const allNotes = Object.values(becca.notes);
for (const n of allNotes) n.invalidateThisCache();
const [, candidateMs] = timed(() => {
const token = normalizeSearchText("target");
let count = 0;
for (const n of allNotes) {
const flatText = normalizeSearchText(n.getFlatText());
if (flatText.includes(token)) count++;
}
return count;
});
timings.push({ label: `getCandidateNotes simulation (cold caches)`, ms: candidateMs });
// Warm cache version
const [candidateCount, candidateWarmMs] = timed(() => {
const token = normalizeSearchText("target");
let count = 0;
for (const n of allNotes) {
const flatText = normalizeSearchText(n.getFlatText());
if (flatText.includes(token)) count++;
}
return count;
});
timings.push({ label: `getCandidateNotes simulation (warm caches)`, ms: candidateWarmMs });
// === getBestNotePath for each candidate ===
const candidates = allNotes.filter(n => {
const flatText = normalizeSearchText(n.getFlatText());
return flatText.includes("target");
});
const [, pathMs] = timed(() => {
for (const n of candidates) {
n.getBestNotePath();
}
});
timings.push({ label: `getBestNotePath (${candidates.length} notes)`, ms: pathMs });
// === SearchResult construction (includes getNoteTitleForPath) ===
const paths = candidates.map(n => n.getBestNotePath()).filter(Boolean);
const [searchResults, srMs] = timed(() => {
return paths.map(p => new SearchResult(p));
});
timings.push({ label: `SearchResult construction (${paths.length} results)`, ms: srMs });
// === computeScore ===
const [, scoreMs] = timed(() => {
for (const r of searchResults) {
r.computeScore("target", ["target"], true);
}
});
timings.push({ label: `computeScore with fuzzy (${searchResults.length} results)`, ms: scoreMs });
const [, scoreNoFuzzyMs] = timed(() => {
for (const r of searchResults) {
r.computeScore("target", ["target"], false);
}
});
timings.push({ label: `computeScore no-fuzzy`, ms: scoreNoFuzzyMs });
// === Sorting ===
const [, sortMs] = timed(() => {
searchResults.sort((a, b) => {
if (a.score !== b.score) return b.score - a.score;
if (a.notePathArray.length === b.notePathArray.length) {
return a.notePathTitle < b.notePathTitle ? -1 : 1;
}
return a.notePathArray.length - b.notePathArray.length;
});
});
timings.push({ label: `Sort results`, ms: sortMs });
// === Trim + content snippet extraction ===
const trimmed = searchResults.slice(0, 200);
const [, snippetMs] = timed(() => {
for (const r of trimmed) {
r.contentSnippet = searchService.extractContentSnippet(
r.noteId, ["target"]
);
}
});
timings.push({ label: `Content snippet extraction (${trimmed.length} results)`, ms: snippetMs });
const [, attrMs] = timed(() => {
for (const r of trimmed) {
r.attributeSnippet = searchService.extractAttributeSnippet(
r.noteId, ["target"]
);
}
});
timings.push({ label: `Attribute snippet extraction`, ms: attrMs });
// === Highlighting ===
const [, hlMs] = timed(() => {
searchService.highlightSearchResults(trimmed, ["target"]);
});
timings.push({ label: `Highlighting`, ms: hlMs });
// === Final mapping (getNoteTitleAndIcon) ===
const [, mapMs] = timed(() => {
for (const r of trimmed) {
beccaService.getNoteTitleAndIcon(r.noteId);
}
});
timings.push({ label: `getNoteTitleAndIcon (${trimmed.length} results)`, ms: mapMs });
// === Full autocomplete for comparison ===
const [autoResults, autoMs] = timed(() => {
return searchService.searchNotesForAutocomplete("target", true);
});
timings.push({ label: `Full autocomplete call (end-to-end)`, ms: autoMs });
reportTimings(`Granular Autocomplete — ${noteCount} notes`, timings);
expect(autoResults.length).toBeGreaterThan(0);
});
}
});
/**
* Test the specific cost of normalizeSearchText which is called
* pervasively throughout the pipeline.
*/
describe("normalizeSearchText cost", () => {
it("profile normalizeSearchText at scale", () => {
buildDataset(5000, { matchFraction: 0.2, contentWordCount: 100 });
// Generate various text lengths to profile
const shortTexts = Array.from({ length: 5000 }, () => randomWord(10));
const mediumTexts = Array.from({ length: 5000 }, () =>
Array.from({ length: 20 }, () => randomWord(6)).join(" ")
);
const longTexts = Object.values(becca.notes).map(n => n.getFlatText());
console.log("\n=== normalizeSearchText cost ===");
const [, shortMs] = timed(() => {
for (const t of shortTexts) normalizeSearchText(t);
});
console.log(` 5000 short texts (10 chars): ${shortMs.toFixed(1)}ms (${(shortMs/5000*1000).toFixed(1)}µs/call)`);
const [, medMs] = timed(() => {
for (const t of mediumTexts) normalizeSearchText(t);
});
console.log(` 5000 medium texts (120 chars): ${medMs.toFixed(1)}ms (${(medMs/5000*1000).toFixed(1)}µs/call)`);
const [, longMs] = timed(() => {
for (const t of longTexts) normalizeSearchText(t);
});
console.log(` ${longTexts.length} flat texts (varying): ${longMs.toFixed(1)}ms (${(longMs/longTexts.length*1000).toFixed(1)}µs/call)`);
});
});
/**
* Test the searchPathTowardsRoot recursive walk which runs
* for every candidate note in NoteFlatTextExp.
*/
describe("searchPathTowardsRoot cost", () => {
it("profile recursive walk with varying hierarchy depth", () => {
console.log("\n=== Search path walk vs hierarchy depth ===");
for (const depth of [3, 5, 8, 12]) {
buildDataset(2000, {
matchFraction: 0.15,
depth,
contentWordCount: 50
});
const [results, ms] = timed(() => {
const ctx = new SearchContext({ fastSearch: true });
return searchService.findResultsWithQuery("target", ctx);
});
console.log(` depth=${depth}: ${ms.toFixed(1)}ms (${results.length} results)`);
}
});
});
/**
* Content snippet extraction scaling — the operation that calls
* note.getContent() for each result.
*/
describe("Content snippet extraction", () => {
it("profile snippet extraction with varying content sizes", () => {
console.log("\n=== Content snippet extraction vs content size ===");
for (const wordCount of [50, 200, 500, 1000, 2000, 5000]) {
buildDataset(500, {
matchFraction: 0.5,
contentWordCount: wordCount
});
const ctx = new SearchContext({ fastSearch: true });
const results = searchService.findResultsWithQuery("target", ctx);
const trimmed = results.slice(0, 200);
const [, ms] = timed(() => {
for (const r of trimmed) {
r.contentSnippet = searchService.extractContentSnippet(
r.noteId, ["target"]
);
}
});
const avgContentLen = Object.values(syntheticContent)
.slice(0, 100)
.reduce((s, c) => s + c.length, 0) / 100;
console.log(` ${String(wordCount).padStart(5)} words/note (avg ${Math.round(avgContentLen)} chars) × ${trimmed.length} results: ${ms.toFixed(1)}ms (${(ms / trimmed.length).toFixed(3)}ms/note)`);
}
});
it("profile snippet extraction with varying result counts", () => {
console.log("\n=== Content snippet extraction vs result count ===");
buildDataset(2000, {
matchFraction: 0.5,
contentWordCount: 500
});
const ctx = new SearchContext({ fastSearch: true });
const allResults = searchService.findResultsWithQuery("target", ctx);
for (const count of [5, 10, 20, 50, 100, 200]) {
const subset = allResults.slice(0, count);
const [, ms] = timed(() => {
for (const r of subset) {
r.contentSnippet = searchService.extractContentSnippet(
r.noteId, ["target"]
);
}
});
console.log(` ${String(count).padStart(3)} results: ${ms.toFixed(1)}ms (${(ms / count).toFixed(3)}ms/note)`);
}
});
});
/**
* Two-phase exact/fuzzy search cost.
*/
describe("Two-phase search cost", () => {
for (const noteCount of [1000, 5000, 10000]) {
it(`exact vs progressive with ${noteCount} notes`, () => {
const timings: TimingEntry[] = [];
buildDataset(noteCount, { matchFraction: 0.005, contentWordCount: 50 });
const [exactR, exactMs] = timed(() => {
const ctx = new SearchContext({ fastSearch: true });
ctx.enableFuzzyMatching = false;
return searchService.findResultsWithQuery("target", ctx);
});
timings.push({ label: `Exact-only (${exactR.length} results)`, ms: exactMs });
const [progR, progMs] = timed(() => {
const ctx = new SearchContext({ fastSearch: true });
return searchService.findResultsWithQuery("target", ctx);
});
timings.push({ label: `Progressive exact→fuzzy (${progR.length} results)`, ms: progMs });
const overhead = progMs - exactMs;
timings.push({ label: `Fuzzy phase overhead`, ms: Math.max(0, overhead) });
reportTimings(`Two-phase — ${noteCount} notes`, timings);
});
}
});
/**
* End-to-end scaling to give the full picture.
*/
/**
* Multi-token search with varying content sizes.
* Real users search things like "meeting notes january" — this exercises
* the multi-token path (which doesn't use the single-token fast path)
* with a realistic mix of note sizes.
*/
describe("Multi-token search with varying content sizes", () => {
it("single vs multi-token autocomplete at scale", () => {
console.log("\n=== Single vs multi-token autocomplete (varying content sizes) ===");
for (const noteCount of [1000, 5000, 10000, 20000]) {
buildDataset(noteCount, {
matchFraction: 0.15,
contentWordCount: 400,
varyContentSize: true,
depth: 5,
titleKeywords: ["meeting", "notes", "january"],
contentKeywords: ["meeting", "notes", "january"],
});
// Warm up
searchService.searchNotesForAutocomplete("meeting", true);
// Single token
const singleTimes: number[] = [];
for (let i = 0; i < 3; i++) {
const [, ms] = timed(() => searchService.searchNotesForAutocomplete("meeting", true));
singleTimes.push(ms);
}
const singleAvg = singleTimes.reduce((a, b) => a + b, 0) / singleTimes.length;
// Two tokens
const twoTimes: number[] = [];
for (let i = 0; i < 3; i++) {
const [, ms] = timed(() => searchService.searchNotesForAutocomplete("meeting notes", true));
twoTimes.push(ms);
}
const twoAvg = twoTimes.reduce((a, b) => a + b, 0) / twoTimes.length;
// Three tokens
const threeTimes: number[] = [];
for (let i = 0; i < 3; i++) {
const [, ms] = timed(() => searchService.searchNotesForAutocomplete("meeting notes january", true));
threeTimes.push(ms);
}
const threeAvg = threeTimes.reduce((a, b) => a + b, 0) / threeTimes.length;
console.log(
` ${String(noteCount).padStart(6)} notes: ` +
`1-token ${singleAvg.toFixed(1)}ms ` +
`2-token ${twoAvg.toFixed(1)}ms ` +
`3-token ${threeAvg.toFixed(1)}ms`
);
}
});
it("multi-token with realistic content size distribution", () => {
console.log("\n=== Multi-token search — content size distribution ===");
buildDataset(5000, {
matchFraction: 0.15,
contentWordCount: 400,
varyContentSize: true,
depth: 5,
titleKeywords: ["project", "review"],
contentKeywords: ["project", "review"],
});
// Report the actual content size distribution
const sizes = Object.values(syntheticContent).map(c => c.length);
sizes.sort((a, b) => a - b);
const p10 = sizes[Math.floor(sizes.length * 0.1)];
const p50 = sizes[Math.floor(sizes.length * 0.5)];
const p90 = sizes[Math.floor(sizes.length * 0.9)];
const p99 = sizes[Math.floor(sizes.length * 0.99)];
console.log(` Content sizes: p10=${p10} p50=${p50} p90=${p90} p99=${p99} chars`);
// Warm up
searchService.searchNotesForAutocomplete("project", true);
const queries = [
"project",
"project review",
"project review document",
`${randomWord(7)}`, // no-match single token
`${randomWord(5)} ${randomWord(6)}`, // no-match multi token
];
for (const query of queries) {
const times: number[] = [];
let resultCount = 0;
for (let i = 0; i < 3; i++) {
const [r, ms] = timed(() => searchService.searchNotesForAutocomplete(query, true));
times.push(ms);
resultCount = r.length;
}
const avg = times.reduce((a, b) => a + b, 0) / times.length;
const label = `"${query}"`.padEnd(35);
console.log(` ${label} ${avg.toFixed(1)}ms (${resultCount} results)`);
}
});
});
describe("End-to-end scaling", () => {
it("autocomplete at different scales", () => {
console.log("\n=== End-to-end autocomplete scaling ===");
console.log(" (fastSearch=true, monkeypatched getContent, no real SQL)");
for (const noteCount of [100, 500, 1000, 2000, 5000, 10000, 20000]) {
buildDataset(noteCount, {
matchFraction: 0.2,
contentWordCount: 300,
depth: 4
});
// Warm up
searchService.searchNotesForAutocomplete("target", true);
const times: number[] = [];
for (let i = 0; i < 3; i++) {
const [, ms] = timed(() => searchService.searchNotesForAutocomplete("target", true));
times.push(ms);
}
const avg = times.reduce((a, b) => a + b, 0) / times.length;
const min = Math.min(...times);
console.log(
` ${String(noteCount).padStart(6)} notes: avg ${avg.toFixed(1)}ms ` +
`min ${min.toFixed(1)}ms`
);
}
});
it("compare fast vs non-fast search", () => {
console.log("\n=== Fast vs non-fast search (no real SQL for content) ===");
for (const noteCount of [500, 2000, 5000]) {
buildDataset(noteCount, {
matchFraction: 0.2,
contentWordCount: 200,
depth: 4
});
const [, fastMs] = timed(() => {
const ctx = new SearchContext({ fastSearch: true });
return searchService.findResultsWithQuery("target", ctx);
});
// Non-fast search tries NoteContentFulltextExp which uses sql.iterateRows
// This will likely fail/return empty since there's no real DB, but we
// can still measure the overhead of attempting it
let nonFastMs: number;
let nonFastCount: number;
try {
const [results, ms] = timed(() => {
const ctx = new SearchContext({ fastSearch: false });
return searchService.findResultsWithQuery("target", ctx);
});
nonFastMs = ms;
nonFastCount = results.length;
} catch {
nonFastMs = -1;
nonFastCount = -1;
}
console.log(
` ${String(noteCount).padStart(5)} notes: fast=${fastMs.toFixed(1)}ms ` +
`non-fast=${nonFastMs >= 0 ? nonFastMs.toFixed(1) + 'ms' : 'FAILED (no real DB)'} ` +
`(non-fast results: ${nonFastCount})`
);
}
});
});
});

View File

@@ -21,6 +21,4 @@ export interface SearchParams {
limit?: number | null;
debug?: boolean;
fuzzyAttributeSearch?: boolean;
/** When true, skip the two-phase fuzzy fallback and use the single-token fast path. */
autocomplete?: boolean;
}

View File

@@ -275,17 +275,19 @@ export function fuzzyMatchWordWithResult(token: string, text: string, maxDistanc
}
try {
// Normalize for comparison — some callers pass pre-normalized text,
// others don't, so this function must be self-contained.
// Normalize both strings for comparison
const normalizedToken = token.toLowerCase();
const normalizedText = text.toLowerCase();
// Exact match check first (most common case)
if (normalizedText.includes(normalizedToken)) {
return token;
// Find the exact match in the original text to preserve case
const exactMatch = text.match(new RegExp(escapeRegExp(token), 'i'));
return exactMatch ? exactMatch[0] : token;
}
// For fuzzy matching, split into words and check each against the token
// For fuzzy matching, we need to check individual words in the text
// Split the text into words and check each word against the token
const words = normalizedText.split(/\s+/).filter(word => word.length > 0);
const originalWords = text.split(/\s+/).filter(word => word.length > 0);

View File

@@ -1,6 +1,6 @@
import safeCompare from "safe-compare";
import type { Request, Response, Router } from "express";
import type { NextFunction, Request, Response, Router } from "express";
import shaca from "./shaca/shaca.js";
import shacaLoader from "./shaca/shaca_loader.js";
@@ -10,6 +10,16 @@ import type SNote from "./shaca/entities/snote.js";
import type SAttachment from "./shaca/entities/sattachment.js";
import { getDefaultTemplatePath, renderNoteContent } from "./content_renderer.js";
import utils from "../services/utils.js";
import { isShareDbReady } from "./sql.js";
function assertShareDbReady(_req: Request, res: Response, next: NextFunction) {
if (!isShareDbReady()) {
res.status(503).send("The application is still initializing. Please try again in a moment.");
return;
}
next();
}
function addNoIndexHeader(note: SNote, res: Response) {
if (note.isLabelTruthy("shareDisallowRobotIndexing")) {
@@ -115,6 +125,8 @@ function render404(res: Response) {
}
function register(router: Router) {
// Guard: if the share DB is not yet initialized, return 503 for all /share routes.
router.use("/share", assertShareDbReady);
function renderNote(note: SNote, req: Request, res: Response) {
if (!note) {

View File

@@ -5,12 +5,14 @@ import dataDir from "../services/data_dir.js";
import sql_init from "../services/sql_init.js";
let dbConnection!: Database.Database;
let dbConnectionReady = false;
sql_init.dbReady.then(() => {
dbConnection = new Database(dataDir.DOCUMENT_PATH, {
readonly: true,
nativeBinding: process.env.BETTERSQLITE3_NATIVE_PATH || undefined
});
dbConnectionReady = true;
[`exit`, `SIGINT`, `SIGUSR1`, `SIGUSR2`, `SIGTERM`].forEach((eventType) => {
process.on(eventType, () => {
@@ -23,18 +25,31 @@ sql_init.dbReady.then(() => {
});
});
function assertDbReady(): void {
if (!dbConnectionReady) {
throw new Error("Share database connection is not yet ready. The application may still be initializing.");
}
}
function getRawRows<T>(query: string, params = []): T[] {
assertDbReady();
return dbConnection.prepare(query).raw().all(params) as T[];
}
function getRow<T>(query: string, params: string[] = []): T {
assertDbReady();
return dbConnection.prepare(query).get(params) as T;
}
function getColumn<T>(query: string, params: string[] = []): T[] {
assertDbReady();
return dbConnection.prepare(query).pluck().all(params) as T[];
}
export function isShareDbReady(): boolean {
return dbConnectionReady;
}
export default {
getRawRows,
getRow,

View File

@@ -13,10 +13,10 @@
"postinstall": "wxt prepare"
},
"keywords": [],
"packageManager": "pnpm@10.32.0",
"packageManager": "pnpm@10.32.1",
"devDependencies": {
"@wxt-dev/auto-icons": "1.1.1",
"wxt": "0.20.18"
"wxt": "0.20.20"
},
"dependencies": {
"cash-dom": "8.1.5"

View File

@@ -9,21 +9,21 @@
"preview": "pnpm build && vite preview"
},
"dependencies": {
"i18next": "25.8.17",
"i18next": "25.10.3",
"i18next-http-backend": "3.0.2",
"preact": "10.29.0",
"preact-iso": "2.11.1",
"preact-render-to-string": "6.6.6",
"react-i18next": "16.5.6"
"react-i18next": "16.6.0"
},
"devDependencies": {
"@preact/preset-vite": "2.10.3",
"eslint": "10.0.3",
"@preact/preset-vite": "2.10.5",
"eslint": "10.1.0",
"eslint-config-preact": "2.0.0",
"typescript": "5.9.3",
"user-agent-data-types": "0.4.2",
"vite": "7.3.1",
"vitest": "4.0.18"
"vite": "8.0.1",
"vitest": "4.1.0"
},
"eslintConfig": {
"extends": "preact"

Some files were not shown because too many files have changed in this diff Show More