newbthenewbd / grav-plugin-tinymce-editor

TinyMCE Editor Integration Plugin for Grav
Other
60 stars 10 forks source link

Disable for specific pages #25

Closed Tamriel closed 3 years ago

Tamriel commented 5 years ago

This plugin makes the plugin lightslider unusable, because the lightslider needs exactly the written markdown code, without html around it. Suggestion: Disable tinymce-editor for specific pages.

pete-willard commented 5 years ago

Ditto! I would like to retain the default markdown editor but have a few pages with extra rich content that use TinyMCE. I cannot figure out how to disable the integration (without modifying the plugin's files) so that it is only used when type: tinymce is used in the blueprint.

newbthenewbd commented 4 years ago

I have just now pushed a new development version to the develop branch, adding, amongst many things, a blacklist and a whitelist for pages using collections.

Note that this feature will only start working completely correctly with Grav v1.6 when a Grav release with this commit included is made available - with v1.6.15, TinyMCE will behave erratically on unpublished pages when either the whitelist or the blacklist is enabled, due to what is apparently a core bug. Although I haven't tested it yet, a quick glance at the code seems to suggest that Grav v1.7 is unaffected by that issue.

I would love to receive some feedback on the feature before it makes its way into the next release of the plugin, as the viability of seriously overhauling it may later be very limited, and, although I have extensively tested it, it is unfortunately not one of these things that I personally use often enough to spot all the possible (yet hopefully nonexistent) design faults of. The latest development version of the plugin can be installed as explained here.

Thanks!

newbthenewbd commented 3 years ago

Implemented (finally) in v1.3.0 - hopefully it works good. Should any issues arise, please notify. :slightly_smiling_face:

andrea75 commented 3 years ago

Implemented (finally) in v1.3.0 - hopefully it works good. Should any issues arise, please notify. 🙂

I'm sorry, but I really don't understand how to apply the filter... :(

newbthenewbd commented 3 years ago

The blacklist and the whitelist are page collections. You may learn more about them here: https://learn.getgrav.org/16/content/collections#collection-headers

Or here, for the newer, slightly different version: https://learn.getgrav.org/17/content/collections#collection-headers

In short, the @root.descendants in the whitelist items means that all pages are included, while the @none in the blacklist items means that the blacklist contains no pages. To add a specific individual page to the blacklist, you may remove the @none item in the TinyMCE plugin configuration file (user/config/plugins/tinymce-editor.yaml), and add the page like this:

blacklist:
  items:
    - '@page.page': '/my-awesome-page'

In order to add that page's children:

blacklist:
  items:
    - '@page.children': '/my-awesome-page'

And in order to recursively add all the descendants of that page (its children, the children of these children, and so on):

blacklist:
  items:
    - '@page.descendants': '/my-awesome-page'

Finally, if you want to whitelist or blacklist pages based on their frontmatter, you may use a taxonomy. For example, the following:

blacklist:
  items:
    - '@taxonomy.tag': 'notinymce'

...will blacklist all the pages that include this in their frontmatter:

taxonomy:
    tag: [notinymce]

(It might be a better idea to use a custom taxonomy for this, like '@taxonomy.tinymce': 'no'. See https://learn.getgrav.org/17/content/taxonomy for details on how to.)

There are more options for this, but this is a pretty long reply already - check out one of the links I gave at the top of this text to read more about collections.

And now for the worse news - I just noticed that Grav 1.7 broke this mechanism for the plugin somewhere along the way... With 1.6.31 it worked fine. Will investigate.

andrea75 commented 3 years ago

And now for the worse news - I just noticed that Grav 1.7 broke this mechanism for the plugin somewhere along the way... With 1.6.31 it worked fine. Will investigate.

All clear now... thank you so much. It was simpler than I thought. The only problem is that I have the last stable version (1.7.5)... so I think that it's normal, about what you said above, that the filter doesn't work. That's right? Because I tried all combo (whitelist/blacklist - items/tags) but the Tiny editor appear in any case if I enable the plugin, even if I apply the whitelist or the blacklist

newbthenewbd commented 3 years ago

Well, that's about correct, except an enabled whitelist would always disable TinyMCE everywhere as long as the issue is present, right?

Anyways, should this thing right above get merged, the whitelists and blacklists shall work by the next release of Grav. I don't know how I would go about correctly working this around in my plugin before that (by writing my own collection parser? :upside_down_face:), but a band-aid that you can try is to remove the non-published filter. The consequence will be that the whitelist and the blacklist will cease to work correctly for pages that are not published...

mahagr commented 3 years ago

@newbthenewbd The issue has been fixed. Though when the plugin will only support Grav 1.7.6 or later, it might be a good idea to start using three-way options Filter: Only Published (true) | Only Non-Published (false) | Both (null or empty string) instead of using two options for the same thing. :)

Though if you make the change, you'd need to handle the old configuration, too.

andrea75 commented 3 years ago

Well, that's about correct, except an enabled whitelist would always disable TinyMCE everywhere as long as the issue is present, right?

Anyways, should this thing right above get merged, the whitelists and blacklists shall work by the next release of Grav. I don't know how I would go about correctly working this around in my plugin before that (by writing my own collection parser? 🙃), but a band-aid that you can try is to remove the non-published filter. The consequence will be that the whitelist and the blacklist will cease to work correctly for pages that are not published...

Yes, correct. If I enable whitelist, it disable TinyMCE in any page. On the contrary, with the blacklist enable, TinyMCE is present in all pages.
I hope it will be fix soon in the next version. :(