Add fullscreen feature to Markdown editor #967
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Since I started to use HTMLy, the Markdown editor has always felt kind of strange to me for long posts. After a bit of reflecting, I noticed that this is because any other normal text or blog editor (Notepad, Word, WordPress, even specialized Markdown editors) don't often have the quirks of a form-based webpage, where you have the textarea that holds the main content that is just a little element on a scrolling page with many other elements, which instead HTMLy does.
This is uncomfortable in general, because the scrolling of the page in general tends to hide formatting buttons from view when writing, or even cause double scrolling when the textarea is shorter than the text contained (and the textarea in HTMLy does not resize to grow or shrink based on the content, so double scrolling always happens). On mobile, where screen space is little and browsers cause even more layout shifts when the virtual keyboard is opened or closed, this is an even bigger issue.
This commit, then, adds a small improvement to the existing Markdown editor, which otherwise continues working as usual, in the form of a toggleable fullscreen view, which can be activated or deactivated by pressing CTRL+P or the dedicated button in the editor toolbar. When deactivated (default), as said, the editor continues working as usual. When activated, using some CSS transformations, the editor area is placed in a way to cover the entire page viewport, showing the editor toolbar at the top, and the textarea below, set to take all remaining available space. Screenshots attached for demonstration; tested on both Firefox and Chromium on desktop, and Chromium on Android.
Additionally, with some extra JavaScript that dynamically inserts a special meta viewport value, as illustrated in https://developer.chrome.com/blog/viewport-resize-behavior, when using the editor in this new fullscreen mode on mobile the viewport is resized automatically to account for the virtual keyboard, keeping the textarea always fully visible and preventing the double scrolling discussed above. In short, I think this addition can improve the editing experience for anyone.