feat(text): add an option to auto-capitalize first letter of sentence#10196
feat(text): add an option to auto-capitalize first letter of sentence#10196MShahnoor wants to merge 3 commits into
Conversation
There was a problem hiding this comment.
Code Review
This pull request introduces an opt-in "AutoCapitalize" plugin for CKEditor 5, which automatically capitalizes the first letter of a sentence as the user types. It includes the corresponding configuration options, UI toggle, translations, and unit tests. The review feedback focuses on improving the plugin's performance and correctness: specifically, optimizing getTextBefore to only inspect the last 50 characters instead of traversing the entire paragraph on every keystroke, updating isSentenceStart to handle this optimization via an isAtBlockStart flag, and ensuring the code attribute check uses the target selection rather than the global document selection.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
Greptile SummaryThis PR adds an opt-in "Automatic capitalization" feature to Trilium's text editor, capitalizing the first letter of a sentence as the user types — matching Word/OneNote behaviour. The feature is off by default and toggled under Options > Text Notes > Features.
Confidence Score: 5/5Safe to merge — the feature is opt-in and disabled by default, so existing users are unaffected until they enable it. The change is well-scoped: a single new CKEditor plugin that only activates when explicitly enabled, wired through the same option pipeline as sibling features. The capitalization logic, undo semantics, and code-context guards have been verified against the tests and the model traversal code. No existing behaviour is altered. No files require special attention — all changes follow established patterns and the core plugin logic is thoroughly tested. Important Files Changed
|
Adds an optional setting that capitalizes the first letter of a sentence as you type in text notes, like Word and OneNote. A new CKEditor plugin hooks the insertText command and uppercases the first lowercase letter typed at the start of a block or after sentence-ending punctuation (. ! ?). The change goes through the editor model, so undo/redo and inline formatting are preserved; code blocks and inline code are left untouched. Disabled by default. Controlled by a new "Automatic capitalization" toggle under Text Notes > Features (option textNoteAutoCapitalizeEnabled), gated via getDisabledPlugins() the same way as the existing emoji and slash-command features.
89da1ed to
3b09693
Compare
Capitalize the first letter of a sentence when the word is finished (space, tab, Enter or Shift+Enter) rather than on the first keystroke, matching Word and OneNote. Apply the capital in its own undo step so pressing Ctrl+Z once reverts only the capitalization (for example "Is " back to "is ", keeping the trailing space) and a second Ctrl+Z removes the text. Code blocks and inline code are left untouched, and inline formatting on the letter is preserved.
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
Address review feedback and the coverage gate on the previous commit: remove the non-null assertion from the test helper, split the insertText and line-break handlers into dedicated methods, and mark the unreachable defensive guards with v8 ignore. Add tests for a soft break acting as a word boundary and for Enter on an empty line, restoring 100% coverage. Wrap lines to the 100-column limit. No behaviour change.
Bundle ReportChanges will increase total bundle size by 2.25MB (2.33%) ⬆️. This is within the configured threshold ✅ Detailed changes
ℹ️ *Bundle size includes cached data from a previous commit Affected Assets, Files, and Routes:view changes for bundle: client-esmAssets Changed:
Files in
Files in
view changes for bundle: standalone-esmAssets Changed:
|
I recently moved my notes from Microsoft OneNote to Trilium, and the one habit my fingers can't shake is automatic capitalization. OneNote has option to capitalize the first letter of a sentence as you type, and this is a feature that I'm used to so I would love to see it in Trillium too.
This adds that as an optional setting for text notes. When it's on, Trilium capitalizes the first letter of a sentence as you type: at the start of a line, and after a period, exclamation mark, or question mark. It's off by default, so nothing changes for anyone unless they turn it on, under Options > Text Notes > Features, next to the emoji, note, and slash-command toggles.
Under the hood it's a small CKEditor plugin that hooks the insertText command and capitalizes the letter right before it's inserted, so it stays a normal edit (undo works, and existing formatting is kept). The new option and the way it's switched off (removing the plugin in getDisabledPlugins) follow the same pattern as the existing emoji and slash-command toggles.
I added tests for the plugin covering the sentence-start cases, mid-sentence typing, code blocks, inline code, and pasting, and pnpm typecheck is clean.
Here's what it looks like
auto-capitalization.mov
I kept the change small and tried to match how the existing editor toggles are built. Happy to adjust anything.