tinymce / tinymce-angular

Official TinyMCE Angular Component
MIT License
324 stars 93 forks source link

Selector & body_class #171

Closed leomayer closed 3 years ago

leomayer commented 4 years ago

What is the current behavior?

I want to set for all the content within tinyMCE a class. According to the documentation this works in the Settings by

selector: 'textarea',
body_class: 'content-angular-tinymce',

In general this works great. The issue appears now with #82 when I have more than one textarea.

I didn't find a way to specifiy the selector for the editor.

So either there is a way to work with #82 or how to specify an additional class which wraps the body?

Testing with tinymce 5.3.2

jscasca commented 4 years ago

Hi @leomayer

The idea of the Angular wrapper is to avoid having textareas converted via selectors in the page but to have an independent component such as <editor ...></editor>. What is it you are trying to achieve? Perhaps you can share with us a codesandbox of your situation?

leomayer commented 4 years ago

Our use case:

The content of tinyMCE uses a different font than for the whole application, e.g. nav-bar. I'm aware that I can configure in in a specific css file which encapsulate the whole setttings for tinyMCE.

We display the content in another context - outside tinyMCE, e.g. in a div. Within that we have the need to reuse these CSS styles in the same way as in tinyMCE. Naturally it shouldn't apply to nav-bar.

Currently we add a body_class which applies automagically font style properly. Additonally we set a class on the requested div. In short - anytime we have some kind of displaying and editing text we want to use the same settings. Since we do not set on the nav-bar this class the font of the app remains unchanged.

I don't see any other possibilities than wrapping the content with a body_class! Well, except you define the CSS more than once. I have no clue why no attribute extists which would set within editor the body_class. Using the selector is a workaround but fails as soon one has more than one textarea.

jscasca commented 3 years ago

Hi @leomayer

You can set the body_class in TinyMCE and can have multiple editors with different body classes wrapping the content. I made a small codesandbox replicating my understanding of what you are trying to do: https://codesandbox.io/s/tinymceangular-forked-w7xyd?file=/src/app/app.component.html

Let me know your thoughts and thank you for your patience