Language Change NPM Resource Changed PR-5.0-dev Pending

User tests: Successful: Unsuccessful:

avatar brianteeman
brianteeman
11 Jun 2023

Tinymce in its current implementation is not a true wysiwyg editor for the cassiopeia template as it is not aware of the cassiopeia css. This can severely restrict what people think is possible with tinmyce and creates confusion that what they edit doesn't match what is displayed.

By default tinymce will look for the presence of an editor.css file in the site template and load the classes from that. Prior to this PR the only thing in that file was some internal classes. This PR creates a true editor.css file for the cassiopeia template. It is generated by the editor.scss file which is a subset of the template.scss which keeps the size down.

One downside of adding this editor.css is that tinymce in its current configuration will display all the classes in one long list on the formats menu/button. Therefore I have changed the default behaviour to NOT display the list (the css is still loaded) and added a new configuration option (default is off) that will let you turn it on if you want. This means that there is a small b/c break so documentation will be created.

Testing

As this is an scss change you will need to either run npm build:css or use one of the pre built packages.
The eaisest thing to check would be to edit the typography article of the sample data.

Before PR

image

also check the Display-1 text at the bottom of the file

After PR

image

Frontend

This pr works just the same on the frontend where perhaps it is a more obvious improvement.

Before PR

chrome_2023-06-12_08-23-17.mp4

After PR

chrome_2023-06-12_08-22-02.mp4

Please select:

42b0045 11 Jun 2023 avatar brianteeman scss
184a54e 11 Jun 2023 avatar brianteeman lint
avatar joomla-cms-bot joomla-cms-bot - change - 11 Jun 2023
Category Repository NPM Change
avatar brianteeman brianteeman - open - 11 Jun 2023
avatar brianteeman brianteeman - change - 11 Jun 2023
Status New Pending
avatar brianteeman brianteeman - change - 11 Jun 2023
Labels Added: NPM Resource Changed PR-5.0-dev
avatar brianteeman brianteeman - change - 11 Jun 2023
Status Pending Closed
Closed_Date 0000-00-00 00:00:00 2023-06-11 17:17:53
Closed_By brianteeman
avatar brianteeman brianteeman - close - 11 Jun 2023
avatar brianteeman brianteeman - change - 12 Jun 2023
Title
editor.scss
[5.x] Cassiopeia editor.scss
avatar brianteeman brianteeman - edited - 12 Jun 2023
avatar brianteeman brianteeman - edited - 12 Jun 2023
avatar joomla-cms-bot joomla-cms-bot - change - 12 Jun 2023
Category Repository NPM Change Administration Language & Strings Repository NPM Change Front End Plugins
avatar brianteeman brianteeman - change - 12 Jun 2023
The description was changed
avatar brianteeman brianteeman - change - 12 Jun 2023
Status Closed New
Closed_Date 2023-06-11 17:17:53
Closed_By brianteeman
avatar brianteeman brianteeman - change - 12 Jun 2023
Status New Pending
avatar brianteeman brianteeman - reopen - 12 Jun 2023
avatar brianteeman brianteeman - change - 12 Jun 2023
The description was changed
avatar brianteeman brianteeman - edited - 12 Jun 2023
avatar brianteeman brianteeman - change - 12 Jun 2023
The description was changed
avatar brianteeman brianteeman - edited - 12 Jun 2023
avatar brianteeman brianteeman - change - 12 Jun 2023
Labels Added: Language Change
avatar brianteeman brianteeman - change - 12 Jun 2023
The description was changed
avatar brianteeman brianteeman - edited - 12 Jun 2023
avatar richard67
richard67 - comment - 12 Jun 2023

@brianteeman Can it be that the before and after PR videos for the frontend are mixed up?

avatar brianteeman brianteeman - change - 12 Jun 2023
The description was changed
avatar brianteeman brianteeman - edited - 12 Jun 2023
avatar brianteeman
brianteeman - comment - 12 Jun 2023

@brianteeman Can it be that the before and after PR videos for the frontend are mixed up?

they were indeed. I have corrected the posrt - thanks

avatar HLeithner
HLeithner - comment - 21 Jun 2023

Why is now ok to load 1000 lines of code into the editor.css?

avatar brianteeman
brianteeman - comment - 21 Jun 2023

because if you dont then you dont have a wyiwyg editor

avatar HLeithner
HLeithner - comment - 21 Jun 2023

Yes but what has changed between #31828 (comment) and now?

Your quote:

There is absolutely no way that an editor.css should be over 1000 lines!!

avatar brianteeman
brianteeman - comment - 21 Jun 2023

Because

  1. I was wrong as I was saying it should be in a system editor.css and a small cassiopeia edirtor.css override. But now that we are being stricter about system/core markup not being bootstrap it is not possible.
  2. That PR didnt implement the correct classes for the cassiopeia template - it was just native bootstrap
  3. That PR had the problem of the dropdowns which I resolved here
avatar dgrammatiko
dgrammatiko - comment - 25 Jun 2023

Couple of things here:

  • you could have an @import statement at the beginning of the file pointing to the template.css (so the editor has only the TinyMCE related code, easier to edit)
  • This approach is not realistic EVEN for cassiopeia. Let me explain: Most templates (also Cassiopeia) use some of the params to customise some colours, fonts, etc. By adding a static file these params cannot be emulated correctly. The only way to do this correctly is to have PHP create the editor.css, similar to what I'm doing with https://github.com/dgrammatiko/wysiwyg-tinymce-j4.1
  • Last comment, if the RL of 4.1 and later releases weren't against to my proposal for a similar patch to com_ajax as the one for plugins and modules the url could have been part of the Helper file but right now (unless someone is willing to fix that and PD accept it) only calling a normal route with a different php entry point (ie I 'm using editor.php) is possible.

In short, this is not a complete solution, and once again the claim WYSIWYG is by approximation...

avatar brianteeman
brianteeman - comment - 25 Jun 2023

Could you explain the first point please. My understanding is that if you simply import the entire template css then the editor has all the css. The intention here was to only include the minimum

avatar dgrammatiko
dgrammatiko - comment - 25 Jun 2023

My understanding is that if you simply import the entire template css then the editor has all the css.

Nope, that not what's happening in reality. You hard code:

  • The fonts:
    if ($paramsFontScheme) {
    if (stripos($paramsFontScheme, 'https://') === 0) {
    $this->getPreloadManager()->preconnect('https://fonts.googleapis.com/', ['crossorigin' => 'anonymous']);
    $this->getPreloadManager()->preconnect('https://fonts.gstatic.com/', ['crossorigin' => 'anonymous']);
    $this->getPreloadManager()->preload($paramsFontScheme, ['as' => 'style', 'crossorigin' => 'anonymous']);
    $wa->registerAndUseStyle('fontscheme.current', $paramsFontScheme, [], ['media' => 'print', 'rel' => 'lazy-stylesheet', 'onload' => 'this.media=\'all\'', 'crossorigin' => 'anonymous']);
    if (preg_match_all('/family=([^?:]*):/i', $paramsFontScheme, $matches) > 0) {
    $fontStyles = '--cassiopeia-font-family-body: "' . str_replace('+', ' ', $matches[1][0]) . '", sans-serif;
    --cassiopeia-font-family-headings: "' . str_replace('+', ' ', isset($matches[1][1]) ? $matches[1][1] : $matches[1][0]) . '", sans-serif;
    --cassiopeia-font-weight-normal: 400;
    --cassiopeia-font-weight-headings: 700;';
    }
    } else {
    $wa->registerAndUseStyle('fontscheme.current', $paramsFontScheme, ['version' => 'auto'], ['media' => 'print', 'rel' => 'lazy-stylesheet', 'onload' => 'this.media=\'all\'']);
    $this->getPreloadManager()->preload($wa->getAsset('style', 'fontscheme.current')->getUri() . '?' . $this->getMediaVersion(), ['as' => 'style']);
    }
    }
  • The inline color parts:
    ->addInlineStyle(":root {
    --hue: 214;
    --template-bg-light: #f0f4fb;
    --template-text-dark: #495057;
    --template-text-light: #ffffff;
    --template-link-color: #2a69b8;
    --template-special-color: #001B4C;
    $fontStyles
    }");
  • The extra color CSS:
    $paramsColorName = $this->params->get('colorName', 'colors_standard');
    $assetColorName = 'theme.' . $paramsColorName;
    $wa->registerAndUseStyle($assetColorName, 'media/templates/site/cassiopeia/css/global/' . $paramsColorName . '.css');
avatar brianteeman
brianteeman - comment - 25 Jun 2023

but then you are still importing hundreds of lines of css that are not relevant to the editor. That is what I was aiming to avoid

avatar brianteeman
brianteeman - comment - 25 Jun 2023

Am I being really daft or is the inline style for the color complletely wrong. There is no way in cassiopeia to set those colours. That is a functionality only present in Atum

avatar brianteeman
brianteeman - comment - 26 Jun 2023

Thanks to others for pointing out when those inline color styles are used ie when using the media manager in the frontend. So definitely not needed in the editor.css

avatar dgrammatiko
dgrammatiko - comment - 26 Jun 2023

Thanks to others for pointing out when those inline color styles are used ie when using the media manager in the frontend. So definitely not needed in the editor.css

Still, this approach is completely ignorant of the colours, fonts:

  • The extra color CSS:
    $paramsColorName = $this->params->get('colorName', 'colors_standard');
    $assetColorName = 'theme.' . $paramsColorName;
    $wa->registerAndUseStyle($assetColorName, 'media/templates/site/cassiopeia/css/global/' . $paramsColorName . '.css');

But most importantly, for me, it's a monkey patch if you try to emulate the styles ignoring that almost every template out there has some params that control aspects of the styling and therefore can only be done using PHP.

avatar brianteeman
brianteeman - comment - 26 Jun 2023

This is only for cassiopeia not for any other template!

avatar brianteeman brianteeman - change - 8 Sep 2023
Status Pending Closed
Closed_Date 0000-00-00 00:00:00 2023-09-08 12:05:10
Closed_By brianteeman
avatar brianteeman brianteeman - close - 8 Sep 2023

Add a Comment

Login with GitHub to post a comment