Skip to content

Fix code block cannot be focused#427

Merged
thesophiaxu merged 2 commits intomainfrom
fix-code-block
Mar 31, 2022
Merged

Fix code block cannot be focused#427
thesophiaxu merged 2 commits intomainfrom
fix-code-block

Conversation

@dragonman225
Copy link
Contributor

Disable contenteditable for the <code> element allows the code block (<pre><code></code></pre>, created by ```) to be focused with a single click.

I wonder if we can disable contenteditable for all elements, since we don't need them to be editable in the viewing mode. But also I'd love to know, does it exist for some reasons?

@dragonman225 dragonman225 changed the title Fix code block cannot focus temporarily Fix code block cannot be focused temporarily Mar 28, 2022
@dragonman225 dragonman225 changed the title Fix code block cannot be focused temporarily Fix code block cannot be focused Mar 28, 2022
@thesophiaxu
Copy link
Collaborator

Yeah I think we can remove the content editable on all elements, tested on my machine and it works fine

The reason for that to be there is that the old code needs it to determine caret position when trying to insert the caret at the correct location, but the new code doesn't need it anymore so we can safely remove it.

@dragonman225
Copy link
Contributor Author

Got it! Removed and it doesn't create new bugs on my machine.

@thesophiaxu thesophiaxu merged commit 24498dd into main Mar 31, 2022
@thesophiaxu thesophiaxu deleted the fix-code-block branch March 31, 2022 20:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants