Jump to content

Pasted text background color using themes


Recommended Posts

Hello Team,

When rich text is pasted into the editor, the text has style attributes like so (taken this example from this IC site and pasted into editor using color themes):

<p style="background-color:#ffffff; color:#2f3d4b; font-size:14px; text-align:start">

The pasted rich text displays fine on a white theme due to matching colors. However, on a dark theme, the pasted text displays in black on a white background (opaque).

To make this transparent and display pasted content as expected on any color theme using current theme's colors, we just have to get rid of the background, background-color and color attributes from the HTML.

Please eliminate the background, background-color and color attributes from the HTML of the pasted rich text which would resolve the issue and users will be able to paste rich text as-is on any color theme which will be a HUGE breakthrough! Eliminating these color attributes will retain all other formatting and displays text in current theme colors. Forcing to paste as plain text results in a bad UX as the users would be required to reformat the text all over if the formatting like headers, tabular data, bullet lists, font-sizes, bolds, italics, etc. are important.

Even if only the attribute "keys" are removed (background-color: , background: and color:), it results in markup like below and it works fine too.

<p style="#ffffff; #2f3d4b; font-size:14px; text-align:start">

The related topic is here -

Please confirm if this is added to your roadmap..

Link to comment
Share on other sites

When playing around with the Alpha version, I did not have issues copying text from dark mode version and having it show incorrectly in light mode. 😉 

As I noted elsewhere...  the new dark mode is very nice and cleans up some old technical debt.  

Link to comment
Share on other sites

19 hours ago, Marc Stridgen said:

Just to confirm, we dont add public roadmaps. So if this was to be added, you would see this either in a blog or in release notes generally

How would we know if the suggestions made are going to be considered are not?

i have more than 75 suggestions to make.

Link to comment
Share on other sites

22 hours ago, Omri Amos said:

you can fix it yourself. just add this js code to your template:

document.querySelectorAll('div[data-role="commentContent"]').forEach(div => {
    div.querySelectorAll('*').forEach(element => {
        element.style.backgroundColor = '';
        element.style.color = '';
    });
});

 

Which template?

Link to comment
Share on other sites

4 hours ago, WebCMS said:

How would we know if the suggestions made are going to be considered are not?

i have more than 75 suggestions to make.

You wouldn't other than seeing it appear in blogs or release notes. Its important to know that suggestions do not necessarily mean they will be added. In many cases they won't, and in others it may be a considerable amount of time before they are, as they would be things we would put into our over all goals for the product. 

Link to comment
Share on other sites

Posted (edited)
On 5/6/2024 at 12:58 AM, Omri Amos said:

you can fix it yourself. just add this js code to your template:

document.querySelectorAll('div[data-role="commentContent"]').forEach(div => {
    div.querySelectorAll('*').forEach(element => {
        element.style.backgroundColor = '';
        element.style.color = '';
    });
});

 

It would be ideal for the IC Team to add this block to whatever template it is so all clients don't have to add it to their templates redundantly. This is the solution and you just have to add it and test. This small change which belongs in the core would resolve a BIG pain point.

The last thing clients want to do is modify templates and maintain/re-apply the changes across updates.

Edited by WebCMS
Link to comment
Share on other sites

Posted (edited)
6 hours ago, WebCMS said:

It would be ideal for the IC Team to add this block to whatever template it is so all clients don't have to add it to their templates redundantly. This is the solution and you just have to add it and test. This small change which belongs in the core would resolve a BIG pain point.

The last thing clients want to do is modify templates and maintain/re-apply the changes across updates.

It's quite a bad approach and should never be used in any reputable software. Unwanted styles/tags should always be stripped immediately when text is pasted into the editor, long before the message is sent to the database, not on the template side as it happens in this example.

This code is a temporary and ineffective workaround, not a solution.

Edited by 13.
Link to comment
Share on other sites

Posted (edited)
6 hours ago, 13. said:

It's quite a bad approach and should never be used in any reputable software. Unwanted styles/tags should always be stripped immediately when text is pasted into the editor, long before the message is sent to the database, not on the template side as it happens in this example.

This code is a temporary and ineffective workaround, not a solution.

Agree. It would support paste as well as copy functionality to paste into any editor. Apparently, that is what v5 is doing.

For the time being in v4, what is the template name @Randy Calvert @Omri Amos @Sonya* @SeNioR- ?? I see a bunch of comment and post templates and it isn't clear which one it is.

Edited by WebCMS
Link to comment
Share on other sites

  • 2 weeks later...
On 5/9/2024 at 9:47 AM, 13. said:

It's quite a bad approach and should never be used in any reputable software. Unwanted styles/tags should always be stripped immediately when text is pasted into the editor, long before the message is sent to the database, not on the template side as it happens in this example.

This code is a temporary and ineffective workaround, not a solution.

Of course, that was my intention - a workaround to fix an existing issue.

Obviously the real solution is to remove the colors from the original code and never load it to begin with, instead of dynamically removing in on the client side after it has already been added to the page.

But this workaround does work, fortunately, in the meantime. 

On 5/9/2024 at 4:25 PM, WebCMS said:

For the time being in v4, what is the template name @Randy Calvert @Omri Amos @Sonya* @SeNioR- ?? I see a bunch of comment and post templates and it isn't clear which one it is.

just add it to the globalTemplate right before the </body>...

Link to comment
Share on other sites

41 minutes ago, Omri Amos said:

But this workaround does work, fortunately, in the meantime. 

just add it to the globalTemplate right before the </body>...

I added this before the </body> in globalTemplate

<script>
document.querySelectorAll('div[data-role="commentContent"]').forEach(div => {
    div.querySelectorAll('*').forEach(element => {
        element.style.backgroundColor = '';
        element.style.color = '';
    });
});
</script>

But it pastes with background color and text color as-is with no sanitization.

I saved the pasted text in the editor and reloaded the page and it still displays the text with background color and text color as-is.

(I tried copy/pasting text from light theme to dark theme and vice-versa).

Then I tried with the '.cke_wysiwyg_div.cke_reset.cke_enable_context_menu.cke_editable.cke_editable_themed.cke_contents_ltr' and 'div#cke_1_contents' selectors and found no change in behavior.

I checked the page source and the code is there.

I checked the Console tab and there are no errors.

Any ideas how to make this work?

Link to comment
Share on other sites

16 minutes ago, Omri Amos said:

I guess you have a custom theme and you need to find the right selector for your comments.

 

We don't have any 3rd party custom themes.

Just created a few themes provided by the system custom.css template (colors using just CSS).

Edited by WebCMS
Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...