Skip to content

Add macOS support with dedicated NSTextView-based paragraph rendering - #92

Closed
Jun Yan (junyan72) wants to merge 1 commit into
mainfrom
macos-support
Closed

Jun Yan (junyan72) wants to merge 1 commit into
mainfrom
macos-support

Conversation

@junyan72

Copy link
Copy Markdown
Contributor

Summary

Add macOS 14+ support to SwiftStreamingMarkdown by creating a dedicated AppKit rendering layer for paragraph content (the only component that required UIKit interop), while adapting all shared source files with platform typealiases and #if os guards.

Key pieces:

  • ParagraphNSView — NSTextView subclass with CADisplayLink-based fade animation, context menu, and citation/latex attachment view providers
  • ParagraphViewMac — NSViewRepresentable wrapper (macOS equivalent of ParagraphView)
  • PlatformTypes.swift — Central typealias file (PlatformFont, PlatformColor, PlatformImage, PlatformEdgeInsets) enabling shared code to compile on both platforms
  • Cross-platform InlineCitationAttachment — Rewritten with InterfaceStyle enum and platform-conditional image rendering
  • Sample app — Updated with supportedDestinations: [iOS, macOS] and platform-conditional UI (NSAlert, NSSharingServicePicker, NSPasteboard)

Known limitations (follow-up work):

  • BlockMathView on macOS is a placeholder Text() (iosMath supports macOS but wiring is deferred)
  • Snapshot tests not yet recorded for macOS
  • NSFont Sendable warnings exist (pre-existing pattern, not a regression)

Refs #85

Validation

  • swift build — macOS library build succeeds
  • xcodebuild build -destination 'platform=macOS' — sample app builds for macOS
  • xcodebuild build -destination 'platform=iOS Simulator,name=iPhone 16' — sample app builds for iOS (no regression)
  • make lint and make test not yet run on this branch (draft PR)

OSS readiness

  • No secrets, internal URLs, private identifiers, or product-only service names were added.
  • Public docs, fixtures, or notices were updated if behavior or dependencies changed.
  • Third-party dependency changes (adds, removes, version bumps) are intentional and reviewed. (no dependency changes)
  • Streaming/incomplete markdown behavior remains covered by fixtures or tests. (macOS snapshot tests pending)

- Add .macOS(.v14) platform to Package.swift
- Create ParagraphNSView (NSTextView subclass) with CADisplayLink fade animation,
  context menu, and citation/latex view providers for macOS
- Create ParagraphViewMac (NSViewRepresentable wrapper) and ParagraphNSViewCache
- Introduce PlatformTypes.swift with cross-platform typealiases
  (PlatformFont, PlatformColor, PlatformImage, PlatformEdgeInsets)
- Extract LatexAttachmentData into shared model file
- Rewrite InlineCitationAttachment for cross-platform rendering
- Adapt Typography, TextFonts, and inline/block views with #if os guards
- Update sample app with supportedDestinations: [iOS, macOS] and
  platform-conditional UI code (NSAlert, NSSharingServicePicker, NSPasteboard)

Refs #85

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@junyan72

Copy link
Copy Markdown
Contributor Author

Closing — all macOS support functionality from this prototype has been incorporated into main via PR #106 and related PRs. The implementation uses a different file organization (separate MDFont/MDColor/MDImage types instead of PlatformTypes, UI/Paragraph/AppKit/ instead of UI/AppKit/) but covers the same functionality.

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