MyBB Community Forums

Full Version: The 'reduced size on paste of unformatted text' browser-dependent SCEditor bug
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
This SCEditor bug and the previous 'redundant tags on paste of unformatted text' browser-dependent SCEditor bug I've just reported reference Hovatek's thread MyCode parse error ( [font="droid sans", sans-serif] ) and nixer55's post #29 in the SCEditor Issues and Resolutions [1.8.21 upgrade] thread. I plan to report a third bug which references only Hovatek's thread.

All three bug reports are heavily based on my post #9 in Hovatek's thread, from the first horizontal line onwards.

Specific to this bug report:

The 'reduced size on paste of unformatted text' browser-dependent SCEditor bug.

Description: As in the previous 'redundant tags on paste of unformatted text' browser-dependent SCEditor bug I've just reported, in WYSIWYG mode, on pasting unformatted text into the editor which was cut/copied from elsewhere within the editor, some browsers (e.g., Chrome and Microsoft Edge) generate redundant font+size+color attributes in the paste data whose values reflect the editor's default style (based on the default stylesheet jscripts/sceditor/styles/jquery.sceditor.mybb.css). Other browsers (e.g., Firefox) don't, and are not subject to this bug. Under those prone browsers (e.g., Chrome and Microsoft Edge), when the unformatted text cut/copied from elsewhere in the editor in WYSIWYG mode is pasted back into it, its default font size of 14px (redundantly generated in the pasted data by these browsers) as styled by the default stylesheet (jscripts/sceditor/styles/jquery.sceditor.mybb.css) does not match any of the sizes supported by MyBB's customisation of SCEditor, such that the editor picks the "best fit" out of those sizes, which is in fact smaller than 14px.

How to reproduce: As in the previous 'redundant tags on paste of unformatted text' browser-dependent SCEditor bug, in Chrome or Microsoft Edge, bring up a new editor window through a page such as a New Reply page. Deselect Source mode if it is selected, such that the editor is in WYSIWYG mode. Now, type some text into it, such as "Blah". Do not style or format that text in any way. Next, select it all, cut or copy it, then paste it. You should be able to observe that the pasted text "Blah" is smaller than the cut/copied original. Now switch to Source mode and note that the default attribute of the "size" tag is "small", rather than the size specified by the default stylesheet, "14px" (and thus infer that "small" and "14px" are different font sizes).

Impact: Mild-moderate. It is annoying in WYSIWYG mode to have to re-select such pasted text and click the "Remove Formatting" button to get it back to its original (unformatted) size.

Potential but flawed solution: As for the previous 'redundant tags on paste of unformatted text' browser-dependent SCEditor bug, because this bug stems from browsers redundantly setting values for style attributes in pasted text that are already at their default values, the "obvious" fix is to edit the appropriate section of jscript/bbcodes_sceditor.js which deals with the "size" tag, and simply have it ignore the default value of "14px", such that it does not generate a MyCode size tag in that case. I have tested this approach and it does work on a default MyBB installation, however, the problem is that it involves hard-coding that default "14px" size into this Javascript file based on that in the default stylesheet, jscripts/sceditor/styles/jquery.sceditor.mybb.css, whereas that default stylesheet font-size value might be changed (customised) by themes. This, then, is not a generally-reliable solution.

The working solution I've come up with for the previous bug also fixes this one. Again, I'm happy to supply a PR.
I think it is fixed now, right?
Yep, fixed by PR #4186, merged 11 days ago.
Thanks guys, sorry this wasn’t dealt with sooner. Feel free to ping me on discord if there’s any requiring to be pushed.