Copying content from RTE to another removes attributes
Hi,
I'm having trouble with copying content from one RTE property to another, in Umbraco 10.7.0.
I have two RTE properties on the same document type. One of the RTE's is used for the text visible on the published page and the other for pre-created snippets of text from which the user copies some to the first one.
If the user copies a single paragraph ie:
<p class="bluetext">this is blue text</p>
from one RTE to another, the class-attribute is removed.
<p>this is blue text</p>
If multiple paragraphs is copied the class-attributes are preserved:
<p class="bluetext">this is blue text</p>
<p class="bluetext">this is blue text</p>
So I continued on, looking into this. And two things occurred to me.
We rarely put classes on the p-tags, often we want to color parts of the text, not that often paragraphs. So the classes will usually be on spans and not paragraphs
When copying text with parts of the text colored using spans, this coloring will be removed as well.
After diving into the source code, I found a setting on the TinyMCE RTE called "paste_process", which was calling a function called cleanupPasteData. This can be overwritten in appsettings.json under the RichTextEditor-property.
function cleanupPasteData(plugin, args) {
// Remove spans
args.content = args.content.replace(/<\s*span[^>]*>(.*?)<\s*\/\s*span>/g, "$1");
// Convert b to strong.
args.content = args.content.replace(/<\s*b([^>]*)>(.*?)<\s*\/\s*b([^>]*)>/g, "<strong$1>$2</strong$3>");
// convert i to em
args.content = args.content.replace(/<\s*i([^>]*)>(.*?)<\s*\/\s*i([^>]*)>/g, "<em$1>$2</em$3>");
}
Copying content from RTE to another removes attributes
Hi,
I'm having trouble with copying content from one RTE property to another, in Umbraco 10.7.0.
I have two RTE properties on the same document type. One of the RTE's is used for the text visible on the published page and the other for pre-created snippets of text from which the user copies some to the first one.
If the user copies a single paragraph ie:
from one RTE to another, the class-attribute is removed.
If multiple paragraphs is copied the class-attributes are preserved:
Is this something that can be configured?
Can't say I have ever come across this behaviour, and it seems to work as expected for me.
What version of Umbraco are you using?
Umbraco 10.7.0 - I haven't come across this either - it is very strange indeed.
We've migrated from 7 to 10 and it wasn't a problem before but is now.
So I continued on, looking into this. And two things occurred to me.
After diving into the source code, I found a setting on the TinyMCE RTE called "paste_process", which was calling a function called cleanupPasteData. This can be overwritten in appsettings.json under the RichTextEditor-property.
appsettings.json - configuration:
is working on a reply...