-
-
Notifications
You must be signed in to change notification settings - Fork 163
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
Tinymce customization #1807
Merged
Merged
Tinymce customization #1807
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
ee15ad1
Create template for TinyMCE docs
stevepiercy d0c9346
Migrate content from #1806
stevepiercy 1a3aec7
Fix redirecting link to TinyMCE latest
stevepiercy 4dea7a8
Update docs/classic-ui/tinymce-customization.md
stevepiercy cf8c000
Enhance tinymce customization documentation
petschki 0ed08b5
Explain each of the three options to better inform the reader's decision
stevepiercy File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
--- | ||
myst: | ||
html_meta: | ||
"description": "TinyMCE customization in Plone 6" | ||
"property=og:description": "TinyMCE customization in Plone 6" | ||
"property=og:title": "TinyMCE customization in Plone 6" | ||
"keywords": "Plone 6, Classic UI, Bootstrap 5, TinyMCE, customization" | ||
--- | ||
|
||
(classic-ui-tinymce-customization-label)= | ||
|
||
# TinyMCE customization | ||
|
||
This chapter is a developer reference manual for customizing {term}`TinyMCE`. | ||
|
||
|
||
## Customize {menuselection}`Format` menu | ||
|
||
There are several options to customize TinyMCE's {menuselection}`Format --> Formats` menu. | ||
|
||
The first two options use TinyMCE's [`formats` JSON configuration](https://www.tiny.cloud/docs/tinymce/latest/content-formatting/). | ||
They are less complicated to implement than the third option. | ||
|
||
|
||
### Add-on GenericSetup configuration file | ||
|
||
This option is best for system administrators and developers who write their own add-ons to ease reproducibility. | ||
|
||
You can add a GenericSetup configuration file to your add-on, such as {file}`profiles/default/registry/tinymce.xml`, with the following content. | ||
|
||
```xml | ||
<registry> | ||
<records interface="plone.base.interfaces.controlpanel.ITinyMCESchema" | ||
prefix="plone"> | ||
<value key="formats" | ||
purge="true" | ||
>{ | ||
"myformat": { | ||
"block": "div", | ||
"classes": "my-css-classes" | ||
} | ||
}</value> | ||
</records> | ||
</registry> | ||
``` | ||
|
||
|
||
### Edit the `Formats` option in the TinyMCE control panel | ||
|
||
This option is good for quick edits, but is not as reproducible as the GenericSetup option. | ||
|
||
You can manually customize the `Formats` value through-the-web in the TinyMCE control panel. | ||
|
||
1. Navigate to {menuselection}`Site Setup --> TinyMCE --> Default`, or append `@@tinymce-controlpanel` to the root of your website in your browser's location bar. | ||
1. Scroll down to {guilabel}`Formats`, and edit the JSON configuration. | ||
1. Click the {guilabel}`Save` button. | ||
|
||
|
||
|
||
### Inject formats with files named {file}`tinymce-formats.css` | ||
|
||
This option is more complex to implement than the previous options. | ||
|
||
In Plone 6, TinyMCE has a special logic that automatically reads registered files named {file}`tinymce-formats.css` and adds the CSS classes defined in those files to TinyMCE's {menuselection}`Format --> Formats` menu by using the [`importcss_file_filter` option](https://www.tiny.cloud/docs/tinymce/latest/importcss/#importcss_file_filter). | ||
|
||
To add custom formats, you can provide your own files. | ||
|
||
1. Name the file {file}`tinymce-formats.css`. | ||
1. Register the file as a resource in your Plone site. | ||
1. Include the file in the TinyMCE control panel in the textarea input {guilabel}`Choose the CSS used in WYSIWYG Editor Area`. | ||
1. Navigate to {menuselection}`Site Setup --> TinyMCE --> Default`, or append `@@tinymce-controlpanel` to the root of your website in your browser's location bar. | ||
1. Scroll down to {guilabel}`Choose the CSS used in WYSIWYG Editor Area`. | ||
|
||
CSS styles defined in this file will automatically be added to the top level of TinyMCE's {menuselection}`Format --> Formats` menu. | ||
|
||
|
||
## Remove imported formats | ||
stevepiercy marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
Plone 6 Classic UI ships with the Barceloneta theme which includes two custom formats, `highlight-inline` and `p.highlight-paragraph`, in the TinyMCE {menuselection}`Format --> Formats` menu. | ||
You can remove these formats through the TinyMCE control panel. | ||
|
||
1. Navigate to {menuselection}`Site Setup --> TinyMCE --> Default`, or append `@@tinymce-controlpanel` to the root of your website in your browser's location bar. | ||
1. Scroll down to {guilabel}`Choose the CSS used in WYSIWYG Editor Area`. | ||
1. Remove the entry `++theme++barceloneta/tinymce/tinymce-formats.css`. | ||
1. Click the {guilabel}`Save` button. | ||
|
||
Once removed, the custom formats will no longer appear in the menu. |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What about
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Beware:
other_settings
will override all previously made settings. This is meant to inject settings which are not populated in other config fields.And the
style_formats_merge
options provides the default "tinymce styles" but that's not exactly the same as the plone default tinymce styles ...