Skip to content

Add a .tag inline-selection kind for #tag autocomplete#94

Open
ChristineTham wants to merge 1 commit into
nodes-app:mainfrom
ChristineTham:pr/tag-token
Open

Add a .tag inline-selection kind for #tag autocomplete#94
ChristineTham wants to merge 1 commit into
nodes-app:mainfrom
ChristineTham:pr/tag-token

Conversation

@ChristineTham

Copy link
Copy Markdown

What

Adds a .tag InlineSelectionKind and caret-scan detection: when the caret is inside a #tag (≥1 body char, # at a whitespace/line boundary so headings and mid-word # don't match, not inside code), the engine fires onInlineSelectionChange(.tag) with the tag text + a caret rect — mirroring how it drives wiki-link autocomplete.

Also adds an isLiteralMode flag to InlineReplacementRequest so a host can commit a plain #tag verbatim (caret at end) without wiki-link [[Name|id]] parsing.

This lets embedders reuse their existing wiki-link completion UI to offer tag suggestions — the engine previously emitted inline-token callbacks and a caret rect only for [[wiki-links]] / ![[embeds]].

Context: extracted from the ChristineTham/swift-markdown-engine fork used by HelloNotes. Rebased onto current main (the inline-replacement path was unified upstream since the fork's base; the literal branch is layered on top).

Adds a `.tag` InlineSelectionKind and caret-scan detection: when the caret is
inside a `#tag` (≥1 body char, `#` at a whitespace/line boundary so headings
and mid-word `#` don't match, not in code), the engine fires
onInlineSelectionChange(.tag) with the tag text + a caret rect, mirroring how
it drives wiki-link autocomplete. Also adds an `isLiteralMode` to
InlineReplacementRequest so a host can commit a plain `#tag ` verbatim (caret
at end) without wiki-link `[[Name|id]]` parsing.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings July 11, 2026 09:03

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Adds #tag-aware inline selection handling so embedders can drive tag autocomplete using the same inline-selection callback mechanism as wiki-link completion, and extends inline replacement to support verbatim (non–wiki-link-parsed) insertions.

Changes:

  • Introduces InlineSelectionKind.tag and a caret-scan (tagContext) to detect #tag contexts outside code.
  • Emits onInlineSelectionChange(.tag) + caret rect when typing inside a tag.
  • Adds isLiteralMode to InlineReplacementRequest to support inserting plain literal fragments and placing the caret at the end.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

File Description
Sources/MarkdownEngine/TextView/NativeTextViewSelectionTypes.swift Adds .tag inline selection kind and isLiteralMode on inline replacement requests.
Sources/MarkdownEngine/TextView/Coordinator/NativeTextViewCoordinator+TextDelegate.swift Triggers .tag inline selection + caret rect when typing inside a detected tag.
Sources/MarkdownEngine/TextView/Coordinator/NativeTextViewCoordinator+Restyling.swift Supports literal-mode replacement insertion and caret placement.
Sources/MarkdownEngine/TextView/Coordinator/NativeTextViewCoordinator+InlineSelection.swift Implements #tag detection logic (tagContext) with code-block exclusion.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

}

let undoActionName = request.isImageEmbedMode ? "Insert Image Embed" : "Insert Link"
let undoActionName = request.isLiteralMode ? "Insert Tag" : "Insert Link"
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.

2 participants