Skip to content

[mac] fix: double-click in Preview no longer switches to Edit mode#369

Merged
Shpigford merged 1 commit into
mainfrom
claude/beautiful-morse-d14c30
May 15, 2026
Merged

[mac] fix: double-click in Preview no longer switches to Edit mode#369
Shpigford merged 1 commit into
mainfrom
claude/beautiful-morse-d14c30

Conversation

@Shpigford

Copy link
Copy Markdown
Owner

Summary

Fixes #366. Double-clicking any rendered text in Preview mode was kicking the user back into the editor — including when they were just trying to select a word.

Root cause: a JS dblclick listener on the WKWebView posted a jumpToSource message to a Swift handler that both scrolled the editor and set viewMode = .edit. Since virtually every rendered element carries a data-sourcepos, every word-select triggered it.

This PR removes the entire jump-to-source thread end-to-end — no producer, no consumer, no notification. Double-click in Preview now does what WKWebView does natively (select the word) and stays in Preview.

Changes

  • Drop the JS dblclick listener from the preview HTML
  • Remove jumpToSource WKScriptMessageHandler registration, dispatch, and cleanup
  • Remove onJumpToSource from PreviewView and its Coordinator
  • Remove the onJumpToSource: closure passed by ContentView
  • Remove the now-orphaned scrollEditorToLine notification declaration, the EditorView observer, and handleScrollToLine (their only producer was the closure above)

Net: -67 lines, no new code.

iOS is unaffected — it never had this listener.

Test plan

  • Open a markdown file (or Help → Sample Document)
  • Switch to Preview mode
  • Double-click on a paragraph, heading, list item, table cell, blockquote — each should select the word and remain in Preview
  • Confirm task-checkbox toggle in preview still works (separate handler)
  • Confirm outline → preview scroll still works
  • Confirm find/replace in preview still works

The `jumpToSource` thread (JS dblclick listener → WKScriptMessageHandler →
`onJumpToSource` closure) was set up so any double-click on rendered
markdown both scrolled the editor and flipped `viewMode = .edit`. This
hijacked every double-click word selection in Preview. Removing the whole
thread (listener, message handler, callback, and the now-unused
`scrollEditorToLine` notification + EditorView observer) restores normal
selection and keeps Preview mode sticky.

Fixes #366
@cloudflare-workers-and-pages

Copy link
Copy Markdown

Deploying clearly with  Cloudflare Pages  Cloudflare Pages

Latest commit: e73329c
Status: ✅  Deploy successful!
Preview URL: https://caef1a42.clearly-cjz.pages.dev
Branch Preview URL: https://claude-beautiful-morse-d14c3.clearly-cjz.pages.dev

View logs

@Shpigford Shpigford merged commit b4db951 into main May 15, 2026
3 checks passed
@Shpigford Shpigford deleted the claude/beautiful-morse-d14c30 branch May 15, 2026 13:47
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.

Fix double-click Preview mode switch

1 participant