Skip to content

Fix final cursor positions on hotkeys#4809

Draft
Gazook89 wants to merge 3 commits into
naturalcrit:masterfrom
Gazook89:Fix-final-cursor-positions-on-hotkeys
Draft

Fix final cursor positions on hotkeys#4809
Gazook89 wants to merge 3 commits into
naturalcrit:masterfrom
Gazook89:Fix-final-cursor-positions-on-hotkeys

Conversation

@Gazook89

Copy link
Copy Markdown
Collaborator

Description

Revisits the keymaps/hotkeys/shortcuts to adjust the final cursor position/selection after snippets are added. Since the editor update, snippets like new page are leaving their cursors at the start of the snippet string, which is annoying because then you need to move your cursor via keyboard or mouse to where you likely want it (in the case of new page, you want the cursor on that new page).

This PR doesn't yet hit every existing keymap. Either it can sit and wallow until I do all of them, or just take this small chunk and throw it live. Here is what it has:

  • New Column and New Page keymaps: final cursor position is at end of snippet
  • Make Space / Remove Space: final cursor is the entire snippet as a range, so the hotkey can be pressed repeatedly to increase the space, or be decreased by using the remove hotkey.
  • Make Span / Make Div: final cursor is place after the new opening brackets to be ready to type attributes/class name/id etc. Removing the span/div leaves the cursor at the end of the selected text.

I do also have my own version of the wrapSelection function in the keymaps that apparently is a hot topic right now. I'm spinning that into it's own PR.

To-Do

  • Headings (H1, H2, etc)
  • Make Link
    • I'd be interested to get opinions on what final cursor position should be here...the whole snippet [alt](url)? Or just the url part? Is it more important to allow quickly toggling the link syntax entirely, off and on? Or to create the link syntax and then be ready to type the URL, or the alt text?
  • Lists seem to be entirely broken on live site, particularly if trying to convert a series of lines into a list.
  • Add tests

Related Issues or Discussions

QA Instructions, Screenshots, Recordings

Will update out of draft status.

### Reviewer Checklist

Replace the list below with specific features you want reviewers to look at.

*Reviewers, refer to this list when testing features, or suggest new items *

  • Verify new features are functional
    • Feature A does X
    • Feature B does Y
  • Verify old features have not broken
    • Feature Z can still be used
  • Test for edge cases / try to break things
    • Feature A handles negative numbers
  • Identify opportunities for simplification and refactoring
  • Check for code legibility and appropriate comments

Gazook89 added 3 commits May 6, 2026 22:28
Final selection is the whole new text, which allows pressing the hotkey multiple times on the same bit of text to increase the amount of space (rather than just adding more snippets of text).

Works on the reverse "remove space" hotkey as well.
Using hotkeys on selected text wraps text in braces, and leaves cursor position ready to add attributes (class, styles, etc) to newly created element.

Unwrapping removes the braces and cursor is ready to continue typing at end of string.

Specifically does *not* ever leave string fully selected to prevent accidentally overwriting/deleting that content.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Backlog

Development

Successfully merging this pull request may close these issues.

Editor Update Issue: \page & \column hotkeys final cursor position

1 participant