WordPress.org

Make WordPress Core

Opened 2 years ago

Closed 3 months ago

Last modified 2 months ago

#19947 closed defect (bug) (invalid)

Copy paste behavior in Visual mode differs from HTML mode

Reported by: BjornW Owned by:
Milestone: Priority: normal
Severity: normal Version:
Component: Editor Keywords: ux-feedback 2nd-opinion
Focuses: Cc:

Description

Copy a random html page from a random site including links and images and paste it into the WYSIWYG Editor Visual mode and it will include the images and links. Basically it (mostly) looks like the copied page. If you paste the same into the WYSIWYG Editor HTML tab and it will strip out _all_ HTML markup and just leaves the plain text, without the images or links.

Expected:
I would expect the Visual and HTML mode of the WYSIWYG editor to behave the same, either both use the code (displaying the results of the markup code in the Visual tab and the markup code itself in the HTML tab) or both strip out all html.

Change History (3)

comment:1 azaozz3 months ago

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

This is how the browsers work. When copying from a web page, the clipboard contains all HTML tags. If you paste in a rich-text aware application (like a word processor or the Visual editor) the tags are included. If you paste in a text-only editor like Notepad or a textarea, all tags are stripped and only the text is pasted.

comment:2 BjornW2 months ago

Thanks azaozz, I have some knowledge on how browsers work ;)

My ticket should be read as an UX annoyance which we may be able to fix: make the behaviour consistent in WordPress instead of adhering the current status quo of inconsistency. Personally I really loath it when my pasted content contains all sorts of markup only relevant in the context from which it is copied. Usually it is completely irrelevant to the copied context. Anyway, perhaps this is just my personal annoyance and therefor not relevant for the larger community, so I understand it if you'd like to close this ticket without a solution. I just wanted to clarify it for archival purposes.

ps: thanks for cleaning up older tickets like mine, would be great if we'd ever reach zero open tickets :)

Last edited 2 months ago by BjornW (previous) (diff)

comment:3 azaozz2 months ago

Well, I had to include the full explanation in case other people reading this are not aware :)

My ticket should be read as an UX annoyance which we may be able to fix: make the behaviour consistent in WordPress instead of adhering the current status quo of inconsistency.

Agreed. A "quick and dirty" fix would be to redirect the paste to a hidden div with contenteditable="true", then insert the innerHTML into the textarea. However considering how much "garbage" is inserted together with the tags, especially when using Chrome or copying from old MSWord, there should be a lot of cleanup.

If somebody wants to take a crack at that, feel free to reopen this ticket.

Last edited 2 months ago by azaozz (previous) (diff)
Note: See TracTickets for help on using tickets.