You can make a difference in the Apple Support Community!

When you sign up with your Apple Account, you can provide valuable feedback to other community members by upvoting helpful replies and User Tips.

Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

Cutting and pasting from Mail (in dark mode) into Pages produces an invisible result

Cutting and pasting from Mail (in dark mode) into Pages (and anything else with white background)

produces an invisible result, i.e. white text on a white background.


And that is a pain :-)


[Re-Titled by Moderator]

MacBook Pro 15", macOS 10.15

Posted on Nov 7, 2019 5:16 PM

Reply
Question marked as Top-ranking reply

Posted on Dec 3, 2019 10:23 AM

The heart of the problem is when you copy that white text from Mail to the clipboard, it is rich text (RTF), and apple assigns the color white to that text string. If Pages had the means to paste that text as UTF-8 text, instead of RTF, then the color information would be stripped and you would receive ordinary black text on paste.


To fix this in the specific case where you are copying white text from a black background, you can run the following AppleScript immediately afterward, and it will change the RTF content on the clipboard to just UTF-8 text. A subsequent paste into Pages will deposit black, not white text.


-- replace RTF text with white color on the clipboard with UTF-8 text
-- run immediately after copying white text from a black background
-use scripting additions

do shell script "pbpaste -Prefer txt | pbcopy"
return


  1. From Dock : Launchpad : Other, click on Script Editor.
  2. copy and paste the code from above into the Script Editor
    1. Click the Compile button
    2. File menu : Save…
      1. File Format: Text
      2. Save As: wb.applescript
      3. [Desktop]
      4. Save
    3. option key + File menu : Save As…
      1. File format: application
      2. Save As: wb.app
      3. [Desktop]
      4. Save
  3. Quit Script Editor


Now, all you have to do is double-click wb.app on your Desktop after you copy white text from a black background, and then a normal paste (of black text) into Pages.



8 replies
Question marked as Top-ranking reply

Dec 3, 2019 10:23 AM in response to Michael Tippett

The heart of the problem is when you copy that white text from Mail to the clipboard, it is rich text (RTF), and apple assigns the color white to that text string. If Pages had the means to paste that text as UTF-8 text, instead of RTF, then the color information would be stripped and you would receive ordinary black text on paste.


To fix this in the specific case where you are copying white text from a black background, you can run the following AppleScript immediately afterward, and it will change the RTF content on the clipboard to just UTF-8 text. A subsequent paste into Pages will deposit black, not white text.


-- replace RTF text with white color on the clipboard with UTF-8 text
-- run immediately after copying white text from a black background
-use scripting additions

do shell script "pbpaste -Prefer txt | pbcopy"
return


  1. From Dock : Launchpad : Other, click on Script Editor.
  2. copy and paste the code from above into the Script Editor
    1. Click the Compile button
    2. File menu : Save…
      1. File Format: Text
      2. Save As: wb.applescript
      3. [Desktop]
      4. Save
    3. option key + File menu : Save As…
      1. File format: application
      2. Save As: wb.app
      3. [Desktop]
      4. Save
  3. Quit Script Editor


Now, all you have to do is double-click wb.app on your Desktop after you copy white text from a black background, and then a normal paste (of black text) into Pages.



Dec 3, 2019 10:52 AM in response to t quinn

Paste and Match Style will not work because the RTF code on the clipboard has assigned a white color of the original text to the pasted text, and Pages is honoring that white color regardless of the paste method.


The solution that I provided gets rid of the RTF color attribute, but also any other text attributes. To preserve those, one would have to write some Objective-C NSPasteboard folly that only changes the white color to black color in the RTF code, and puts that RTF code back on the clipboard.

Dec 3, 2019 1:27 PM in response to Michael Tippett

You are welcome.


This solution will not preserve other copied text atrributes though as UTF-8 plain text does not support them. There would be considerable Objective-C code involved to get the copied RTF data from the clipboard, change the text color, and preserve all other RTF text attributes, before pushing back onto the clipboard — prior to the paste into Pages.

Dec 5, 2019 7:30 AM in response to Michael Tippett

On revisiting this problem, and if you do not mind a white email background in your message content, Apple Mail has a checkbox in its Preferences : Viewing panel to toggle Use dark backgrounds for messages. In doing so, you will always copy and paste black text into Pages, and can ignore the external AppleScript solution altogether.


The first paragraph, by switching from the dark message background, preserves all other text attributes including highlighting (if present) which are stripped as a side-effect of the AppleScript solution.

Cutting and pasting from Mail (in dark mode) into Pages produces an invisible result

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.