Skip to content

[Feature]: Add Alt/Option-click multi-cursor editing #658

Description

@jian45154

Pre-flight checks

  • I have searched existing issues and discussions for a similar request.
  • This request is about Markra itself, not a provider-specific support question.

Problem

Markra does not currently support creating multiple carets with Ctrl+Click on Windows or with another mouse gesture.

Making the same small edit at several non-contiguous locations therefore requires repeating the edit manually or using find and replace, which may affect unintended matches. Common examples include adding the same prefix or suffix to several lines, updating selected Markdown fragments, or editing multiple list items at once.

Proposed solution

Enable multiple selections in the production editors and support multi-cursor editing in both WYSIWYG and Source modes:

  • Hold Alt on Windows/Linux or Option on macOS and left-click an ordinary editable text position to add another caret without removing existing carets.
  • Alt/Option-click an existing caret to remove it.
  • Typing and standard editing actions—at minimum text input, Backspace, Delete, and Enter—should apply at every caret.
  • Treat a simultaneous multi-caret edit as one undo/redo operation.
  • A normal click should return to a single caret.
  • Pressing Escape should remove secondary carets while keeping the primary caret.
  • All active carets and non-contiguous selections should remain clearly visible.

Existing interactions must continue to work:

  • Ctrl/Cmd+Click must continue to open links.
  • The multi-cursor gesture must not reuse CodeMirror's default Ctrl/Cmd+Click behavior.
  • Single-selection commands such as the slash menu or AI selection actions should either operate only on the primary selection or be unavailable while multiple carets are active.
  • Read-only, IME, Vim mode, and typewriter mode behavior should not regress.

Acceptance criteria

  1. Multiple carets can be created and removed with Alt/Option+Click.
  2. A single edit is applied correctly at every caret.
  3. The feature works at ordinary editable text positions in both WYSIWYG and Source modes.
  4. Undo and redo treat each simultaneous edit as one operation.
  5. Switching back to a single caret is predictable.
  6. Ctrl/Cmd+Click link navigation remains functional.
  7. Focused tests cover caret creation, simultaneous insertion/deletion, undo/redo, and relevant mouse-event conflicts.

Initial scope

The first implementation may exclude interactive rendered widgets that maintain their own pointer or editing behavior, including visual table cells, images, media controls, and table controls.

The following can be handled separately:

  • Column or rectangular selection
  • Add-caret-above/below shortcuts
  • Select next/all occurrences
  • Configurable multi-cursor modifiers
  • Multi-cursor editing across visual table cells

Product area

Editing

Alternatives considered

  • Repeating each edit manually
  • Using find and replace

Find and replace is useful when every occurrence should change, but it is less suitable when only several specific locations need editing.

Additional context

Markra does not currently enable multiple selections in its production editors. Both WYSIWYG and Source modes use CodeMirror's minimalSetup, while EditorState.allowMultipleSelections currently appears only in tests.

The implementation should explicitly:

  • Enable EditorState.allowMultipleSelections.
  • Configure Alt/Option+Click as the gesture that adds a selection range.
  • Avoid CodeMirror's default Ctrl/Cmd+Click modifier because Markra already uses it to open links.
  • Audit rendered Markdown widgets that intercept mouse events and currently replace the selection with a single caret.
  • Define whether external document refreshes preserve mapped secondary carets or intentionally collapse them.

Reference behavior:

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions