Realce de sintaxe não é copiado ao colar em locais que suportam texto colorido

Sim! Eu tenho o mesmo comportamento.

E, estritamente falando, não é um bug. O Firefox está copiando o HTML exatamente como solicitado:

<meta http-equiv="content-type" content="text/html; charset=utf-8">
<p dir="auto">Quando copiei o mencionado abaixo, do Discourse, para meu cliente de e-mail:</p>
<pre data-code-wrap="diff" dir="auto" class="codeblock-buttons">
		<div class="codeblock-button-wrapper" style="right: 0px;"></div>
		<code class="lang-diff hljs language-diff" data-highlighted="yes">
			<span class="hljs-meta">@@ -1,11 +1,11 @@</span>
			<span class="hljs-deletion">-Young volunteer award – celebrating young volunteers, aged 16-24, who go the extra mile in their local communities, demonstrating our values and the importance of connection and action.</span>
			<span class="hljs-addition">+The Young Volunteer Award celebrates young volunteers, aged 16–24, who go the extra mile in their local communities, demonstrating our values and the importance of connection and action.</span>
		</code>
	</pre>

A diferença resultante após a colagem vem do Chromium aplicando os estilos em linha, enquanto o Firefox não o faz. Reduzir a um único destaque[1] esclarece o que está acontecendo:

<span
  class="hljs-deletion">
-Young volunteer award – celebrating young volunteers, aged 16-24, who go the extra mile in their local communities, demonstrating our values and the importance of connection and action.
</span>
<span
  class="hljs-deletion"
  style="background: none 0% 0% / auto repeat scroll padding-box border-box rgb(255, 224, 224); color: rgb(192, 45, 46);">
-Young volunteer award – celebrating young volunteers, aged 16-24, who go the extra mile in their local communities, demonstrating our values and the importance of connection and action.
</span>

(quebras de linha adicionadas)

O Chromium aplica, a partir de class="hljs-deletion", o CSS em linha style="background: none 0% 0% / auto repeat scroll padding-box border-box rgb(255, 224, 224); color: rgb(192, 45, 46);" ao span, já que o destino da colagem provavelmente não possui esse estilo.


  1. heh ↩︎

1 curtida