Simple Machines Community Forum

SMF Support => SMF 2.1.x Support => Topic started by: kruimeltje on April 12, 2019, 01:15:31 PM

Title: SMF 2.1 WYSIWYG
Post by: kruimeltje on April 12, 2019, 01:15:31 PM
Hi,

I made a copy of the default theme and changed the colors, just to get more into CSS.
When I was testing (to check for possible forgotten color changes) I tried the wysiwyg-editor.
when I used that editor I saw, through inspection (F12), that the jquery of the default theme was loaded 'html, p, code::before, table' of jquery.sceditor.default.css via ajax.googleapis.com.
I found out when typing in the quick_reply box, because I made the theme gray with white font and the standard fontcolor is black.
After turning the wysiwyg off the fontcolor is white again and the body of minified.css is loaded.

wysiwyg on: jquery.sceditor.default
wysiwyg off: minified.css

Now I wonder why/how that happened, purely to understand how it works.
I tried to find out more about jquery, but I still don't get it to be honest.

SMF version: 2.1 RC1

Thanks in advance! :)
Title: Re: SMF 2.1 WYSIWYG
Post by: Kindred on April 12, 2019, 02:12:01 PM
I'm not sure I understand your question...

when the wysiwyg is not used, there is no need to load the resources -- so we don't.
Title: Re: SMF 2.1 WYSIWYG
Post by: Sesquipedalian on April 12, 2019, 04:56:51 PM
Quote from: Kindred on April 12, 2019, 02:12:01 PM
when the wysiwyg is not used, there is no need to load the resources -- so we don't.

Strictly speaking, in SMF 2.1 the "Disable WYSIWYG editor" setting merely tells SCEditor to only show its plain text mode. SCEditor itself is loaded in either case.

Quote from: kruimeltje on April 12, 2019, 01:15:31 PM
Now I wonder why/how that happened, purely to understand how it works.

SCEditor uses an iframe containing an editable HTML document to present its WYSIWYG view, and a normal textarea element to show the plain text view. The file jquery.sceditor.default.css styles the document inside the iframe, while jquery.sceditor.css styles the textarea.

Note that being inside an iframe means that the editable document does not inherit any CSS rules from the containing page, whereas the textarea does inherit them. That's why changes to index.css can affect the plain text view (i.e. the textarea) but not the WYSIWYG view (i.e. content of the iframe).
Title: Re: SMF 2.1 WYSIWYG
Post by: kruimeltje on April 14, 2019, 03:56:06 PM
Thanks for your reply @Sesquipedalin!

would it be possible to use two different jquery.sceditor.default.css files? One for the default theme and one for the grey one.
If yes, where should I allocate which file is loaded to style the iframe associated with the correct theme?

Title: Re: SMF 2.1 WYSIWYG
Post by: SychO on April 14, 2019, 04:11:23 PM
try to copy jquery.sceditor.default.css from the default theme to your custom theme and then edit it, it should do the trick
Title: Re: SMF 2.1 WYSIWYG
Post by: kruimeltje on April 15, 2019, 10:01:42 AM
Quote from: SychO on April 14, 2019, 04:11:23 PM
try to copy jquery.sceditor.default.css from the default theme to your custom theme and then edit it, it should do the trick
Thanks for the tip.

I've tried it. Unfortunately, it doesn't work.
It still loads the stylesheet of default theme : Themes/default/css/jquery.sceditor.default.css

Also have tried to rename the file to theme name (default to curve grey): jquery.sceditor.curve grey.css, but that does not work either.
Title: Re: SMF 2.1 WYSIWYG
Post by: Sesquipedalian on April 15, 2019, 11:55:50 AM
That's odd. SychO's advice should have worked. To help rule out the possibility of a caching issue, toggle the "Minimize CSS and JavaScript files" setting and check if that makes any difference. If not, please open a new bug report on GitHub so that I don't forget to look into this.
Title: Re: SMF 2.1 WYSIWYG
Post by: SychO on April 15, 2019, 12:12:00 PM
@Sesquipedalian it seems that file only ever loads from the default theme, this is where it's "used" in the code


// Set up the SCEditor options
$sce_options = array(
'style' => $settings['default_theme_url'] . '/css/jquery.sceditor.default.css',
'emoticonsCompat' => true,
'colors' => 'black,maroon,brown,green,navy,grey,red,orange,teal,blue,white,hotpink,yellow,limegreen,purple',
'format' => 'bbcode',
'plugins' => '',
'bbcodeTrim' => true,
);
Title: Re: SMF 2.1 WYSIWYG
Post by: Sesquipedalian on April 15, 2019, 01:34:37 PM
That's what I suspected, but I was on my phone at the time and couldn't quickly check.
Title: Re: SMF 2.1 WYSIWYG
Post by: Sesquipedalian on April 15, 2019, 01:49:40 PM
Tracked in https://github.com/SimpleMachines/SMF2.1/issues/5601
Title: Re: SMF 2.1 WYSIWYG
Post by: maximus23 on April 15, 2019, 02:00:16 PM
Hi,

Just modify by :

'style' => $settings['theme_url'] . '/css/jquery.sceditor.default.css',

?

:)
Title: Re: SMF 2.1 WYSIWYG
Post by: Sesquipedalian on April 15, 2019, 02:03:51 PM
Quote from: maximus23 on April 15, 2019, 02:00:16 PM
Hi,

Just modify by :

'style' => $settings['theme_url'] . '/css/jquery.sceditor.default.css',

?

:)

That wouldn't be good enough, I'm afraid. If the CSS file wasn't present in the user's selected theme, that code would fail. But you are on the right track. The fix that will be included in RC3 can be seen here: https://github.com/SimpleMachines/SMF2.1/pull/5602/files
Title: Re: SMF 2.1 WYSIWYG
Post by: maximus23 on April 15, 2019, 02:11:11 PM
QuoteThat wouldn't be good enough, I'm afraid. If the CSS file wasn't present in the user's selected theme, that code would fail. But you are on the right track. The fix that will be included in RC3 can be seen here: https://github.com/SimpleMachines/SMF2.1/pull/5602/files

Ok thanks for the fix. :)
Title: Re: SMF 2.1 WYSIWYG
Post by: kruimeltje on April 15, 2019, 03:25:12 PM
Quote from: Sesquipedalian on April 15, 2019, 02:03:51 PM

That wouldn't be good enough, I'm afraid. If the CSS file wasn't present in the user's selected theme, that code would fail. But you are on the right track. The fix that will be included in RC3 can be seen here: https://github.com/SimpleMachines/SMF2.1/pull/5602/files

I have adjusted the code, in sources/subs-editor.php, as in the pull on Github and can confirm that it works.

Thanks for the fast fix!  :D
Title: Re: SMF 2.1 WYSIWYG
Post by: Sesquipedalian on April 15, 2019, 05:01:17 PM
No problem.