froala / wysiwyg-editor

The next generation Javascript WYSIWYG HTML Editor.
https://www.froala.com/wysiwyg-editor
Other
5.3k stars 675 forks source link

Weird inline styles issues when copy and paste within the same editor #4250

Open yellow1912 opened 3 years ago

yellow1912 commented 3 years ago

This is related to this issue https://github.com/froala/wysiwyg-editor/issues/3806

events: {
          'window.copy': function () {
            localStorage.removeItem("fr-copied-html");
            localStorage.removeItem("fr-copied-text");
          }
        }

The above code was added due to issues when copying and pasting across editors on the same page.

That fix creates different issue when copying and pasting within the same editor, however:

Expected behavior.

Copy and pasting in the same editors should keep the same exact HTML code.

Actual behavior.

When copying and pasting the text in the same editor, an additional inline style was added, for example, when copy a plain h2 heading with no style like this:

<h2>1. Clearly define your goals</h2>

I get something like this:

<h2 style="box-sizing: border-box; border: 0px solid rgb(84, 84, 84); margin: 0px; font-size: 30px; font-weight: 300; line-height: 40px; color: rgb(255, 255, 255); font-family: sans-serif; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; letter-spacing: 0.3px; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: rgb(31, 31, 31); text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;">1. Clearly define your goals</h2>

Steps to reproduce the problem.

In the Froala configs put:

events: {
          'window.copy': function () {
            localStorage.removeItem("fr-copied-html");
            localStorage.removeItem("fr-copied-text");
          }
        }
Editor version.

If you don't know it, please see https://wysiwyg-editor.froala.help/hc/en-us/articles/360000717049-How-can-I-find-my-editor-version-.

OS.

Froala 3.2.6

Browser.

Chrome latest

I think the best fix, is to properly fix issue#3806, then we don't have to apply the hack fix which leads to other issues.

AkshayCM commented 2 years ago

Thank you for your feedback. The request has been reported to the product management team for evaluation and consideration for an upcoming release.

zutsori commented 2 years ago

Any update on this issue? We are seeing this issue without custom extension code. (3.1.1, Chrome)

cheseauf commented 2 years ago

Thank you for your feedback. The request has been reported to the product management team for evaluation and consideration for an upcoming release.

Any update on this issue ?

DavidEichmann commented 1 year ago

This issue appears to be solved in Froala 4.0.17

Using the workaround in the issue description and trying to copy:

<h1>Header 1</h1>

I get this when pasting:

<h1 id="isPasted">Header 1</h1>