Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Custom style dropdown (without auto-generated list) #8758

Open
JorisDebonnet opened this issue Jan 26, 2019 · 7 comments
Open

Custom style dropdown (without auto-generated list) #8758

JorisDebonnet opened this issue Jan 26, 2019 · 7 comments

Comments

@JorisDebonnet
Copy link
Contributor

I am using SilverStripe 4.2 at the moment.

I seems to be impossible to create a custom style dropdown without also automatically putting all classes from content_css into that dropdown. The documentation even explicitly says that:

style_formats won't be applied if you do not enable importcss_append.

What? Why?

I want my website's CSS to be applied to the content in the editor, but I do not want all useless classes to be imported into that style dropdown. Most of those classes are for layout, header, menu, footer, ... there's no reason for those in the styles dropdown. I still want the full stylesheet to be applied though because some of those classes can actually be used in the content on some special pages, but I don't want them in the dropdown because they're too complicated (e.g. they need to be edited via html source).

In 3.x it used to be possible to use the theme_advanced_styles option to just have a simple custom list, but it seems to be ignored. I also tried with style_formats but that only works if the auto-generated list also appears. I'll just expose those classes for now, but it doesn't look very professional...

@kinglozzer
Copy link
Member

Does this option help?

$config->setOptions([
    'style_formats' => [
        [
            'title' => 'Button',
            'selector' => 'a',
            'classes' => 'button'
        ]
    ],
    'style_formats_autohide' => true
]);

@maxime-rainville
Copy link
Contributor

Following the example as in the tutorial this is what I get.

image

If I add @kinglozzer's suggestion this is what I get.

image

@JorisDebonnet Are you importing your entire frontend CSS file into the editor_css? My assumption reading the tutorial is that you should have a dedicated editor.css file that's only use for styling the WYSIWYG.

@JorisDebonnet
Copy link
Contributor Author

I haven't found a solution yet. I feel like I tried all suggestions... suppose I'll have to retry with a fresh installation and debug from there. Going on a vacation in 5 hours though, so I'll get some sleep and retry this when I get back.

@tobedamobe
Copy link

Are there any solutions yet? Hope your vacation was fine @JorisDebonnet and i hope you found a Solution ;)

@JorisDebonnet
Copy link
Contributor Author

Are there any solutions yet? Hope your vacation was fine @JorisDebonnet and i hope you found a Solution ;)

Hi @tobedamobe, I'm afraid I did not really find a solution. My _config.php still includes the following comment line:

// 'theme_advanced_styles' => $css_classes // doesn't work anymore... :(

I ended up creating a separate editor.css, which luckily was doable because I work with scss, so it just compiles "most but not all" css classes. Not as good as manually being able to state the list of css classes that should be available to the user, but better than nothing. (I did not yet try finding a solution from a fresh install)

@prij
Copy link

prij commented Jan 8, 2021

I was able to achieve this by adding an arbitrary non-matched value for the following property:
'importcss_selector_filter' => 'hideEditorStyles',

As per @derralf's config:
https://gist.github.com/derralf/1b1c0318695320748b8db41802211103

@lerni
Copy link
Contributor

lerni commented Jan 9, 2021

Or just disable the import plugin $config->disablePlugins(['importcss']);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

7 participants