Skip to content

feat(callout): callout block pipeline with config-driven endering#88

Open
sospartan wants to merge 2 commits into
nodes-app:mainfrom
sospartan:feature/callout-standalone-pipeline
Open

feat(callout): callout block pipeline with config-driven endering#88
sospartan wants to merge 2 commits into
nodes-app:mainfrom
sospartan:feature/callout-standalone-pipeline

Conversation

@sospartan

Copy link
Copy Markdown
Contributor

Summary

Adds config-driven callout block support as a standalone pipeline, entirely
separate from blockquotes. Embedders supply type-to-color+icon mappings via
CalloutConfiguration, and the engine renders GFM-style callouts with
background fill, colored accent bar, and SF Symbol icons.

Problem

The previous callout implementation on local was tied to blockquote styling
— detection happened inside styleBlockquote() via regex, making the feature
hard to isolate, test, and review independently.

Solution

A dedicated BlockKind.callout in BlockParser, activated by a single static
injection point (BlockParser.calloutTypes). No method signatures change
anywhere in the parser/styler/tokenizer pipeline.

  • Parser: calloutInfo() hand-scanner classifies > [!TYPE] lines before
    isBlockquote() in computeBlocks
  • Token: single token per block (like codeBlock), so incremental editing
    naturally expands to the full callout range via tokenRestyleParagraphs
  • Styler: styleCallout() independent of styleBlockquote(); title always
    visible, [!TYPE] marker hidden in render mode
  • Renderer: plain rectangle background + left accent bar + SF Symbol icon
    (no rounded corners, no overlay title)
  • Config: CalloutConfiguration with CalloutStyle(color:icon:) per type;
    .none default preserves backward compatibility

…endering

- New BlockKind.callout in BlockParser, detected before blockquote via
  static var calloutTypes injection point (no method signature changes)
- Config-driven colors and icons via CalloutConfiguration + CalloutStyle
- Single token per block (like codeBlock) for consistent paragraph expansion
- Title always visible text; [!TYPE] marker hidden in render mode, revealed
  while editing
- Icon vertically centered on text baseline; edit mode omits icon indent
- Empty-title line height maintained via base font on hidden marker area
- Callout background: plain rectangle fill + left color accent bar
- Activation: BlockParser.calloutTypes set once in NativeTextViewWrapper
@sospartan sospartan marked this pull request as ready for review July 8, 2026 02:21
@sospartan

Copy link
Copy Markdown
Contributor Author

@luca-chen198
Taking the previous feedback, I've completely refactored this PR with the following approach:

  • Reference implementation: Studied CodeBlock and LaTex for the architecture.
  • Minimal core impact: The changes no longer interfere with the blockquote implementation.
  • Opt-in feature: Callouts are now optional and can be configured by developers.

I'm relieved the #87 wasn't merged, as it felt rough and poorly structured. This version is much cleaner, I think. I hope this is a step forward, and I'm definitely open to further feedback!

- Inject BlockParser.calloutTypes before each callout test
- Title is always visible (bold + bodyText), not hidden
- [!TYPE] marker still hidden (clear) when inactive, muted when editing
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.

1 participant