MyBB Community Forums

Full Version: SCEditor - Duplicate tags after re-election.
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2
Hi, 

For some time now users reporting to me bug in editor.  For example: if first select (ex. font-size), then again change this font - it not change BBCode, but adding next.

GIF presents: 
[Image: c6a70585d61c4f41d089bbf1844eb37d.gif]

It's hard to do with so many modify tags on tapatalk for example...
This specific case looks like a bug on our end indeed, since it seems to works fine on http://www.sceditor.com/

It applies only to the [/size] tag, so I guess it's connected with our custom BBCode: https://github.com/mybb/mybb/blob/featur...s#L77-L165
Hi,

Thank you for your report. We have pushed this issue to our Github repository for further analysis where you can track our commits and progress with fixing this bug. Discussions regarding this bug may also take place there too.

Follow this link to visit the issue on Github: https://github.com/mybb/mybb/issues/2228

Thanks for contributing to MyBB!

Regards,
The MyBB Group
Hi,

This happens because at https://github.com/mybb/mybb/blob/featur...ceditor.js, line 146, you have:
editor.wysiwygEditorInsertHtml('<span data-scefontsize=' + sizes[fontSize-1] + ' style="font-size:' + sizes[fontSize-1] + '">', '</span>');

Instead of the above, you should use :
editor.execCommand('fontsize', desired-value-here);
Using this way, it would not add extra unnecessary spans.

Of course it would create <font .. instead, but using jquery you can change it to span.
(2016-03-06, 10:47 AM)mkm87 Wrote: [ -> ]Hi,

This happens because at https://github.com/mybb/mybb/blob/featur...ceditor.js, line 146, you have:
editor.wysiwygEditorInsertHtml('<span data-scefontsize=' + sizes[fontSize-1] + ' style="font-size:' + sizes[fontSize-1] + '">', '</span>');

Instead of the above, you should use :
editor.execCommand('fontsize', desired-value-here);
Using this way, it would not add extra unnecessary spans.

Of course it would create <font .. instead, but using jquery you can change it to span.

i tried made something like in 13/10/2015 https://github.com/mybb/mybb/pull/2229/files

but cause others bugs. And i tried understand core file of sceditor, but i not find anything. I not know what code in core that result in font tag.
(2016-03-06, 03:27 PM)martec Wrote: [ -> ]i tried made something like in 13/10/2015 https://github.com/mybb/mybb/pull/2229/files

but cause others bugs. And i tried understand core file of sceditor, but i not find anything. I not know what code in core that result in font tag.


The code that result in font tag is:
editor.execCommand('fontsize' ...

https://developer.mozilla.org/en-US/docs...xecCommand -> fontSize
I've spent/wasted a whole afternoon to try to understand how it works too, and it was this method.
If you don't use execCommand, but <span.. instead, it will add additional <span.. tags if you re-apply, which is something unwanted.

I do not use neither Mybb nor the sceditor's font-size default command so i can't help you right now with the bugs. Instead i use pixels as font-size, which i've posted here:
http://community.mybb.com/thread-189611.html
Maybe that code can help you fix it.
(2016-03-06, 04:42 PM)mkm87 Wrote: [ -> ]The code that result in font tag is:
editor.execCommand('fontsize' ...

https://developer.mozilla.org/en-US/docs...xecCommand -> fontSize
I've spent/wasted a whole afternoon to try to understand how it works too, and it was this method.
If you don't use execCommand, but <span.. instead, it will add additional <span.. tags if you re-apply, which is something unwanted.

I do not use neither Mybb nor the sceditor's font-size default command so i can't help you right now with the bugs. Instead i use pixels as font-size, which i've posted here:
http://community.mybb.com/thread-189611.html
Maybe that code can help you fix it.

i thought that execCommand it was internal command, but appear that not. thanks for unravel the mystery.

and i not know if this bug persist https://bugzilla.mozilla.org/show_bug.cgi?id=763859 , if not document.execCommand('styleWithCSS',false,true); is fix for this.

EDIT: i tested here. Yes editor.execCommand('styleWithCSS', true); is solution for this. But only work in webkit/Blink. Not work in  Gecko (FF).

EDIT2: This really not fault or bug of SCEditor. I check here Redactor, and Redactor too add font tag, this happen why browser (FF, Edge etc...) not respect styleWithCSS. So what solution that xenforo used for this?

Xenforo use css to "fix" this.

Some like this:


font[size="6"] {
    font-size: 22px;
}

So solution is use font tag in SCEditor and make correction using css like xenforo.
Feel free to edit your PR with that solution
(2016-03-07, 05:22 PM)Destroy666 Wrote: [ -> ]Feel free to edit your PR with that solution

yes... i willl.
now only in 1.8.8 correct?
so not need rush.
Yes
Pages: 1 2