Skip to content

Address issue #196: Add markdown UTType when copying from editor#208

Merged
schuyler merged 2 commits intomainfrom
claude/resolve-issue-196-01CwBM6PgD5QurjfGpUPUfc8
Dec 9, 2025
Merged

Address issue #196: Add markdown UTType when copying from editor#208
schuyler merged 2 commits intomainfrom
claude/resolve-issue-196-01CwBM6PgD5QurjfGpUPUfc8

Conversation

@schuyler
Copy link
Copy Markdown
Owner

@schuyler schuyler commented Dec 8, 2025

Summary

When copying content from the editor, MacDown now places net.daringfireball.markdown on the pasteboard alongside public.utf8-plain-text. This improves interoperability with Markdown-aware applications that can identify and handle markdown content specially.

Changes:

  • Override writablePasteboardTypes to advertise markdown UTType support
  • Override writeSelectionToPasteboard:types: to write both plain text and markdown types when requested
  • Both copy (⌘C) and cut (⌘X) operations benefit from this change

Related Issue

Related to #196

Manual Testing Plan

Key Test Scenarios

  1. Plain Text Fallback - Copy text, paste in TextEdit → plain text works normally
  2. Markdown-Aware Apps - Copy text, paste in Ulysses/iA Writer → markdown recognized
  3. Cut Operation - Cut text, verify removal and correct paste
  4. Special Characters - Copy emoji, unicode, symbols → no corruption
  5. Code Blocks - Copy fenced code blocks → syntax preserved
  6. Large Selections - Select all in large document → no lag or crashes
  7. Cross-Document - Copy between MacDown documents → works correctly

Success Criteria

  • Plain text copying/pasting works with all existing applications (backward compatible)
  • net.daringfireball.markdown UTType is available for Markdown-aware applications
  • Copy and cut operations both write both pasteboard types
  • No errors or crashes occur

Review Notes

  • Architecture (Groucho): Recommended overriding writablePasteboardTypes and writeSelectionToPasteboard:types: in MPEditorView
  • Code Review (Chico): Fixed initial implementation to respect the types: parameter per NSTextView API contract
  • Documentation (Harpo): No documentation updates needed
  • Testing (Zeppo): Provided comprehensive 15-scenario manual testing plan

Override writeSelectionToPasteboard:types: in MPEditorView to include
net.daringfireball.markdown UTType alongside plain text when copying
or cutting content. This improves interoperability with Markdown-aware
applications that can detect and handle markdown content specially.

Related to #196
Address code review feedback:
- Add writablePasteboardTypes override to advertise markdown UTType
- Respect the types: parameter in writeSelectionToPasteboard:types:
- Only write types that are actually requested
- Fix documentation typo (Overriden -> Overridden)

Related to #196
@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Dec 8, 2025

Code Coverage Report

Current Coverage: 42.55%

Coverage Details (Summary)
Name                                                                                                                                   Coverage            
-------------------------------------------------------------------------------------------------------------------------------------- ------------------- 
MASPreferences.bundle                                                                                                                  0.00% (0/0)         
MacDown 3000.app                                                                                                                       54.71% (6800/12429) 
    /Users/runner/work/macdown3000/macdown3000/MacDown/Code/Preferences/MPHtmlPreferencesViewController.m                              0.00% (0/87)        
        MPPrismDefaultThemeName                                                                                                        0.00% (0/2)         
        -[MPHtmlPreferencesViewController viewIdentifier]                                                                              0.00% (0/3)         
        -[MPHtmlPreferencesViewController toolbarItemImage]                                                                            0.00% (0/3)         
        -[MPHtmlPreferencesViewController toolbarItemLabel]                                                                            0.00% (0/2)         
        -[MPHtmlPreferencesViewController viewWillAppear]                                                                              0.00% (0/4)         
        -[MPHtmlPreferencesViewController changeStylesheet:]                                                                           0.00% (0/7)         
        -[MPHtmlPreferencesViewController changeHighlightingTheme:]                                                                    0.00% (0/7)         
        -[MPHtmlPreferencesViewController invokeStylesheetFunction:]                                                                   0.00% (0/23)        
        -[MPHtmlPreferencesViewController loadStylesheets]                                                                             0.00% (0/13)        
        -[MPHtmlPreferencesViewController loadHighlightingThemes]                                                                      0.00% (0/23)        
    /Users/runner/work/macdown3000/macdown3000/MacDown/Code/Extension/NSColor+HTML.m                                                   94.05% (332/353)    
        +[NSColor(HTML) colorWithHexString:]                                                                                           94.12% (16/17)      
        +[NSColor(HTML) colorWithHTMLName:]                                                                                            89.13% (164/184)    
        __35+[NSColor(HTML) colorWithHTMLName:]_block_invoke                                                                           100.00% (152/152)   
    /Users/runner/work/macdown3000/macdown3000/Dependency/peg-markdown-highlight/HGMarkdownHighlightingStyle.m                         87.69% (57/65)      
        +[HGMarkdownHighlightingStyle colorFromARGBColor:]                                                                             100.00% (6/6)       
        -[HGMarkdownHighlightingStyle initWithType:attributesToAdd:toRemove:fontTraitsToAdd:]                                          88.89% (8/9)        
        -[HGMarkdownHighlightingStyle initWithStyleAttributes:baseFont:]                                                               86.00% (43/50)      
    /Users/runner/work/macdown3000/macdown3000/MacDown/Code/Extension/hoedown_html_patch.c                                             73.64% (95/129)     
        hoedown_patch_render_blockcode                                                                                                 89.09% (49/55)      
        hoedown_patch_render_listitem                                                                                                  100.00% (46/46)     
        hoedown_patch_render_toc_header                                                                                                0.00% (0/28)        
    /Users/runner/work/macdown3000/macdown3000/MacDown/Code/Application/MPMainController.m                                             40.76% (97/238)     
        MPOpenBundledFile                                                                                                              95.24% (20/21)      
        __MPOpenBundledFile_block_invoke                                                                                               85.71% (6/7)        
        treat                                                                                                                          20.00% (6/30)       
        __treat_block_invoke                                                                                                           0.00% (0/3)         
        -[MPMainController applicationDidFinishLaunching:]                                                                             100.00% (6/6)       
        -[MPMainController openUrlSchemeAppleEvent:withReplyEvent:]                                                                    0.00% (0/45)        
        __59-[MPMainController openUrlSchemeAppleEvent:withReplyEvent:]_block_invoke                                                   0.00% (0/7)         
        -[MPMainController valueForKey:fromQueryItems:]                                                                                0.00% (0/5)         
        -[MPMainController preferences]                                                                                                100.00% (3/3)       
        -[MPMainController preferencesWindowController]                                                                                0.00% (0/18)        
        -[MPMainController showPreferencesWindow:]                                                                                     0.00% (0/2)         
        -[MPMainController showHelp:]                                                                                                  100.00% (3/3)       
        -[MPMainController showContributing:]                                                                                          100.00% (3/3)       
        -[MPMainController init]                                                                                                       90.91% (10/11)      
        -[MPMainController applicationShouldOpenUntitledFile:]                                                                         80.00% (4/5)        
        -[MPMainController applicationDidBecomeActive:]                                                                                100.00% (5/5)       
        -[MPMainController copyFiles]                                                                                                  63.33% (19/30)      
        -[MPMainController openPendingFiles]                                                                                           29.41% (5/17)       
        -[MPMainController openPendingPipedContent]                                                                                    28.57% (4/14)       
        -[MPMainController showFirstLaunchTips]                                                                                        100.00% (3/3)       
    /Users/runner/work/macdown3000/macdown3000/MacDown/Code/Utility/MPUtilities.m                                                      63.12% (101/160)    
        MPDataRootDirectory                                                                                                            100.00% (14/14)     

... (2113 more lines truncated)

📊 **Full coverage report available in workflow artifacts**

@schuyler schuyler merged commit bd2e293 into main Dec 9, 2025
4 checks passed
@schuyler schuyler deleted the claude/resolve-issue-196-01CwBM6PgD5QurjfGpUPUfc8 branch December 9, 2025 02:04
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