Skip to content

Decouple isSelectable from isEditable in NativeTextViewWrapper#32

Merged
luca-chen198 merged 2 commits into
nodes-app:mainfrom
axelandersson:31-readonly-link-clicks
May 21, 2026
Merged

Decouple isSelectable from isEditable in NativeTextViewWrapper#32
luca-chen198 merged 2 commits into
nodes-app:mainfrom
axelandersson:31-readonly-link-clicks

Conversation

@axelandersson
Copy link
Copy Markdown
Contributor

Summary

  • Always set textView.isSelectable = true regardless of isEditable, so isEditable: false no longer silently disables link hit-testing and text selection.
  • isEditable now controls only the caret and editing, matching the DocC contract ("renders read-only with no caret").

Fixes #31.

Test plan

  • swift build green
  • swift test green
  • Manual: NativeTextViewWrapper(text:, isEditable: false) with a [text](url) link opens the URL in the default browser on click
  • Manual: [[Name]] wiki link in read-only mode fires onLinkClick
  • Manual: text can be selected (drag) and copied in read-only mode
  • Manual: editable mode behavior unchanged

🤖 Generated with Claude Code

Setting `isEditable: false` previously also forced `isSelectable =
false` on the underlying NSTextView, which makes NSTextView skip
link hit-testing and disables text selection. Read-only markdown
views could not open URLs in the browser, fire `onLinkClick` for
wiki links, or copy text. `isSelectable` is now always true;
`isEditable` controls only the caret and editing, as documented.

Fixes nodes-app#31.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@luca-chen198
Copy link
Copy Markdown
Collaborator

luca-chen198 commented May 19, 2026

I will review it today. Thx

Read-only mode (isEditable: false) hides the caret but NSTextView still
updates selectedRange on click. The engine's active-token logic was
caret-driven, so clicking a heading / code / task / HR line still
revealed its raw markdown syntax — half-read-only.

- `computeActiveTokenIndices` gains a `suppressed: Bool = false` flag;
  when true it returns an empty set
- The 5 coordinator call sites pass `suppressed: !textView.isEditable`
- Styling calls forward `caretLocation: -1` when read-only so the
  two paths that bypass activeTokenIndices (task-checkbox reveal,
  HR-line-caret reveal) also stay silent

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Copy link
Copy Markdown
Collaborator

@luca-chen198 luca-chen198 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

gj

@luca-chen198 luca-chen198 merged commit bde74ba into nodes-app:main May 21, 2026
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.

Read-only mode (isEditable: false) silently disables link clicks

2 participants