Copying from obsidian preview also copies the background color

Steps to reproduce

Copy any text and paste it in a place that recognizes html, like Anki or Microsoft Word. If it is in dark mode it copies the background color as if it were part of the format (the same is true in the light mode, but it is more difficult to realize).

Edit: It works perfectly if between the copied text there is a blank line or a list (ordered, unordered, or task list).

Expected result

Paste just the markdown format (without the symbols), if in bold, paste in bold, but don’t paste any color.

Actual result

This text:
I was going past the house where the cat and the dog lived.

Is pasted like that:
WINWORD_20-06-14-45_479x235
Whit this code copied:

<span style="color: rgb(216, 216, 216); background-color: rgb(41, 44, 46);">I was going&nbsp;</span><strong>past</strong><span style="color: rgb(216, 216, 216); background-color: rgb(41, 44, 46);">&nbsp;the&nbsp;</span><em>house</em><span style="color: rgb(216, 216, 216); background-color: rgb(41, 44, 46);">&nbsp;where the&nbsp;</span>cat<span style="color: rgb(216, 216, 216); background-color: rgb(41, 44, 46);">&nbsp;and the dog lived.</span>

Environment

  • Operating system: Win10 64bits
  • Obsidian version: 0.6.7
  • Using custom CSS: Yes. I tried to remove the CSS and use the default, the result was the same.
3 Likes

Linking to another preview copy bug https://forum.obsidian.md/t/preview-mode-text-copy-does-not-copy-entire-selection/4517

In word you can do paste->merge formatting.