Make WordPress Core

Opened 9 years ago

Closed 7 years ago

#33712 closed defect (bug) (wontfix)

Press This: Multiple paragraphs in source text are quoted as a single paragraph

Reported by: rachelmcr's profile rachelmcr Owned by:
Milestone: Priority: normal
Severity: normal Version: 4.2
Component: Press This Keywords: needs-patch
Focuses: javascript Cc:


When using Press This to quote multiple paragraphs from a source article, the text is reduced to a single paragraph (no line or paragraph breaks) in the editor. Other formatting such as links are also removed — I can understand removing some of the source formatting, but I'd expect Press This to at least maintain paragraph breaks from the source text.

Attachments (2)

Press-This-Source.png (121.7 KB) - added by rachelmcr 9 years ago.
Press-This-Editor.png (120.8 KB) - added by rachelmcr 9 years ago.

Download all attachments as: .zip

Change History (9)

#1 @rachelmcr
9 years ago

The attached screenshots show how the three paragraphs at the end of the WordPress 4.3 announcement become a single paragraph with Press This.

#2 @kraftbj
9 years ago

  • Focuses javascript added
  • Keywords needs-patch added
  • Version changed from 4.3 to 4.2

For a JS wizard, this is coming from the bookmarklet

We're using window.getSelection right now. I think we could use Range.toString() to preserve line breaks?

#3 @azaozz
9 years ago

There are two ways this can be done:

  • We can make "pseudo" paragraphs. window.getSelection().toString() returns the text with line breaks which follow the visible layout. We can replace \n\n with <p> and \n with <br>, or just run it through wpautop(). This will approximate the original layout but will not use any of the HTML, so if there is a link in the selection, only the linked text will be shown. The advantage is that this will produce very clean, minimal, safe HTML from the selection.
  • We can get the selected range and "extract" the HTML. This will bring all sorts of tags and attributes, so will have to run it through pretty restrictive kses filter. In many cases this will also contain divs which don't work well in the editor. At first look this seems better, but the selection will have to be filtered/cleaned quite a lot to make it suitable for the editor.

#4 @kraftbj
9 years ago

#26681 was marked as a duplicate.

#5 @agnes.lesage@…
8 years ago

Could be rgeat to have basic formatting, at least line breaks

#6 @cbmwm
7 years ago

Any news regarding the development of importing line/paragraph breaks with "Press This"? It seems anyone including the lead dev classified this a useful request.

#7 @kraftbj
7 years ago

  • Milestone Awaiting Review deleted
  • Resolution set to wontfix
  • Status changed from new to closed

With the bookmarklet being deprecated, I'm closing this as wontfix.

Note: See TracTickets for help on using tickets.