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

Tinymce customization #1807

Merged
merged 6 commits into from
Dec 5, 2024
Merged

Tinymce customization #1807

merged 6 commits into from
Dec 5, 2024

Conversation

stevepiercy
Copy link
Contributor

@stevepiercy stevepiercy commented Dec 5, 2024

Closes #1806.


📚 Documentation preview 📚: https://plone6--1807.org.readthedocs.build/

docs/classic-ui/tinymce-customization.md Outdated Show resolved Hide resolved
@stevepiercy
Copy link
Contributor Author

@stevepiercy stevepiercy requested a review from petschki December 5, 2024 09:47
@petschki
Copy link
Member

petschki commented Dec 5, 2024

@stevepiercy I've changed the order of information and enhanced it:

  1. customize formats (with recommended JSON config option and example how to update)
  2. remove formats

Restructure the .css file option to be more how-to guide-ish
@stevepiercy
Copy link
Contributor Author

@petschki I made a few more revisions to better explain why someone should choose one option over another, and turned the .css file option into more of a how-to-guide.

Copy link
Member

@petschki petschki left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍🏼

@stevepiercy stevepiercy merged commit 3eb6df2 into 6.0 Dec 5, 2024
3 checks passed
@stevepiercy stevepiercy deleted the tinymce-customization branch December 5, 2024 13:14
@szakitibi
Copy link

szakitibi commented Dec 5, 2024

Please note following the instructions of Edit the Formats option in the TinyMCE control panel will not add the new item to the "Format" menu. Editing the "Formats" JSON will only add the format to the configurations, but it will be still invisible in the TinyMCE's menu. E.g. "discreet" for classic demo portal is registered as one of the "Formats" in the JSON, but it is nowhere to be found in the TinyMCE menu.

As a last step "Formats" must be registered under one of styles (in the case of "myformat", under "Block styles" of the controlpanel), only then will it pop up in the TinyMCE's menu.


You can add a GenericSetup configuration file to your add-on, such as {file}`profiles/default/registry/tinymce.xml`, with the following content.

```xml
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about

  <records interface="Products.CMFPlone.interfaces.ITinyMCESchema" prefix="plone">
    <value key="other_settings">
      {
        "extended_valid_elements":"i[class],script[type|src]",
        "style_formats": [
          {
            "title": "Highlight",
            "block": "p",
            "attributes": {
              "class": "featured"
            }
          },
          {
            "title": "Alert",
            "block": "p",
            "attributes": {
              "class": "redalert"
            }
          }
        ],
        "style_formats_merge": true
      }
    </value>
  </records>

Copy link
Member

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 ...

@petschki
Copy link
Member

petschki commented Dec 5, 2024

@szakitibi yes you're right. forgot about that. But depending on the format you can also add it to the "Inline formats"

@szakitibi
Copy link

@szakitibi yes you're right. forgot about that. But depending on the format you can also add it to the "Inline formats"

Exactly. That is why I used "under one of the styles". The official documentation should be clear about this part, that the registered "formats" can be registered under different styles, and that will determine their position in the TinyMCE menu.

@petschki
Copy link
Member

petschki commented Dec 5, 2024

Last but not least there should be a warning, that the provided genericsetup xml will kill the default formats. If those should be preserved, you need to copy them over to your tinymce.xml

@szakitibi
Copy link

Also another comment regarding the use of "formats" JSON. I think it is not possible to add top level items (like the highlight-inline) to "Formats" dropdown menu with the available "* styles" configurations. It seems currently only the tinymce-formats.css is able to do that trick.

@stevepiercy
Copy link
Contributor Author

I would be happy to accept a pull request with revisions to this document. These comments are great, but they won't get into the documentation unless someone who has the technical knowledge writes them up in PR.

I do not have this technical knowledge. I am only a technical writer who translates Plone-ish to English and sprinkles some MyST syntax on top to make it pretty. Thanks for your collaboration.

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

Successfully merging this pull request may close these issues.

4 participants