editor.js icon indicating copy to clipboard operation
editor.js copied to clipboard

Add support for copying and pasting of "strong" and "em" HTML elements

Open arsm100 opened this issue 3 years ago • 6 comments

Fixes #1666

Followed the suggestion of @neSpecc to extend the sanitization config for both italic and bold formatting.

I also added tests to cover the new use cases.

Before:

https://user-images.githubusercontent.com/44353593/199292460-d22fd918-9ef2-45e2-ad97-599eafa3f9d9.mov

After:

https://user-images.githubusercontent.com/44353593/199292392-6d9b7b99-f410-4c02-ae65-18565c5e458b.mov

arsm100 avatar Nov 01 '22 17:11 arsm100

Hi @neSpecc @gohabereg @TatianaFomina @ilyamore88! Do you mind reviewing this to get the linked issue resolved? Thanks!

arsm100 avatar Nov 14 '22 19:11 arsm100

I think the Inline Tool should return only a single tag, not a set of one. It would be more straightforward. Maybe I'm wrong.

Anyway, the problem you're resolving is understandable. Maybe we could somehow support strong tags on paste, but convert them to b? Probably it will require a new API improvement, to make it similar to the handleTags like in Block Tools.

We need to think about it a little bit more.

neSpecc avatar Feb 18 '23 01:02 neSpecc

Well, I think it has to accept both variations. The question is if we should replace one with another. <strong> and <em> are semantic elements that are given more importance on accessibility side (i.e. screen readers). But <b> and <i> elements are simply made for styling purposes and totally ignored.

My personal preference would be to convert any instance of <b> to <strong> and <i> to <em>. Also updating the Inline Tool to use these instead.

varna avatar Aug 23 '23 12:08 varna

Please add strong: {} and em: {} to the respective sanitize rules as a quick fix for when pasting is broken. After that there will be enough time to worry about some details and difficulties that arise (for ex. user pasted <strong> tag, but can't add or remove it because the tool adds and deletes only <b>, not <strong>).

However, for now please add the sanitize rules, to save people efforts if they have to copy and paste large texts.

buranovite avatar Sep 19 '23 15:09 buranovite

can we, please, re-consider this PR?

gorenburg avatar Aug 05 '24 23:08 gorenburg

bump very needed

un000 avatar Aug 08 '25 21:08 un000