toeverything / blocksuite

🧩 Content editing tech stack for the web - BlockSuite is a toolkit for building editors and collaborative applications.
https://blocksuite.io
Mozilla Public License 2.0
4.37k stars 398 forks source link

fix(blocks): rich-text can't redo since pressing shift causes e.key to be uppercase #7450

Closed valonsodev closed 3 months ago

valonsodev commented 3 months ago

As described here https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/key#value.

If the pressed key is the B key, the returned value is the string "b". However, if the Shift key is pressed at the same time (so shiftKey is true), the returned value is the string "B"

This means that when using the rich-text component you are unable to redo since pressing ctrl + shift + z makes e.key == 'Z'. It also means that after pressing CapsLock pressing ctrl + z to undo doesn't work since CapsLock makes e.key be uppercase 'Z'.

Simple fix by accepting either lowercase or uppercase Z.

vercel[bot] commented 3 months ago

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
blocksuite ❌ Failed (Inspect) Jul 3, 2024 11:41am
1 Skipped Deployment | Name | Status | Preview | Comments | Updated (UTC) | | :--- | :----- | :------ | :------- | :------ | | **blocksuite-docs** | ⬜️ Ignored ([Inspect](https://vercel.com/toeverything/blocksuite-docs/EkZNfY25Yh7TVjFHuY4RRefV88op)) | [Visit Preview](https://blocksuite-docs-git-fork-valonsogit-master-toeverything.vercel.app) | | Jul 3, 2024 11:41am |
graphite-app[bot] commented 3 months ago

Your org has enabled the Graphite merge queue for merging into master

Add the label “merge” to the PR and Graphite will automatically add it to the merge queue when it’s ready to merge.

You must have a Graphite account and log in to Graphite in order to use the merge queue. Sign up using this link.

L-Sun commented 3 months ago

Hotkey case sensitivity is by design. You can press Ctrl + y to redo.

valonsodev commented 3 months ago

Ctrl + y doesnt work when using the rich-text component alone, as in: document.createElement("rich-text")

And if this is by design, what is the point of having the component checking shiftKey when e.key == z?


if (e.key === 'z') {
    if (e.shiftKey) {
        //This will never run since if e.shiftKey == true then e.key would be uppercase Z
    }
}           
graphite-app[bot] commented 3 months ago

Merge activity