Copying <pre> content removes newlines

UNCONFIRMED
Unassigned

Status

Mozilla Developer Network
General
--
minor
UNCONFIRMED
2 years ago
2 years ago

People

(Reporter: Julien G, Unassigned)

Tracking

({in-triage})

Details

(Whiteboard: [specification][type:bug])

(Reporter)

Description

2 years ago
What did you do?
================
1. Went on https://developer.mozilla.org/en-US/docs/Web/API/Event/eventPhase$edit 
2. Copied and pasted code from a <pre> block (e.g. the "HTML content" code)

What happened?
==============
The pasted content doesn't have any newline. (whenever it is pasted inside the editor or in another editor (for instance, local text editor on my machine). So it seems the buffer doesn't have any newline.

What should have happened?
==========================
The content that is pasted should reflect the content that was copied.

Is there anything else we should know?
======================================
Only happens in Firefox.  Really odd bug.
Does it happen in all OS's?
Severity: normal → minor
Keywords: in-triage
Duplicate of this bug: 1268941
This wasn't happening to me until recently. Now it happens all the time and makes me crazy. Can we figure out how to fix it?
This bug was only in Firefox, but bug 1268941 reproduces at least in Safari.  Also, it doesn't pass Julien's test - pasting in another text editor preserves whitespace, so this new issue appears to be pasting in CKEditor. I'm treating bug 1268941 as a separate issue. I suspect this bug should be closed.
(In reply to John Whitlock [:jwhitlock] from comment #5)
> This bug was only in Firefox, but bug 1268941 reproduces at least in Safari.
> Also, it doesn't pass Julien's test - pasting in another text editor
> preserves whitespace, so this new issue appears to be pasting in CKEditor.
> I'm treating bug 1268941 as a separate issue. I suspect this bug should be
> closed.

I think you're seeing "newlines" and translating it to "whitespace" in your head. This is just about newlines specifically.
True, I looked past the newlines report and investigated general whitespace trimming on paste. It can be done in a single editor window and a plain text editor (or even Bugzilla):

1. Edit https://developer.allizom.org/en-US/docs/user:jwhitlock
2. Copy the pre section:

Fixed width text:
  * Two
    * Four
      * Six
        * Eight

3. Paste in a plain-text editor. Whitespace is preserved.
4. Paste in visual CKEditor. Pastes on one line.
5. Switch to source mode. The text that was pasted in visual mode has no newlines, and whitespace has been combined into single spaces.
6. In source mode, paste. Output has newlines and leading whitespace.
Gah. I'm the doofus here; I zoned out on the fact that newlines are a kind of whitespace. Sorry about that. :/
You need to log in before you can comment on or make changes to this bug.