Hello!
I am about to start a website with grav for a friend. As they are not very tech savvy, I installed the tinymce plugin.
However, I experience a strange behavior: the tinymce editor is only reliably active in “Expert” mode but not in “Normal” mode.
E.g. I cannot make tinymce work in modular pages (in the modules) in normal mode
I already tried to play with some blueprints but I cannot seem to figure out what I am doing wrong.
Can you help me?
Thank you in advance!
@speendo, I cannot reproduce the issue…
- Downloaded the One-Page Site skeleton
- Installed TinyMCE Editor plugin using:
$ bin/gpm install tinymce-editor
- No further changes.
- Opened Admin / Pages / Home / _callout module in normal mode and edited the content:
Now its your turn to show us a reproducible case in which a module cannot be edited using TinyMCE in normal mode.
Thank you @pamtbaau for helping me!
Actually, I wanted to add some images in my first post, but I don’t have the permissions yet.
So instead, I link the images: Imgur: The magic of the Internet
I should also mention that I use the theme “Akazie Wood” (GitHub - AkazieIT/grav-theme-akazie-wood: This is a theme of Akazie IT GmbH and is intended for simple websites without great features) - maybe the reason is to be found in the theme’s blueprints?
I searched and found the key
type: editor
a couple of times in the blueprints but I wasn’t able to change that key to make tinymce work.
Thank you once more for your help.
It seems like I found the reason:
There are a couple of blueprints in the theme folder specifying the editor with
content:
type: section
title: THEME_AKAZIEWOOD.ADMIN.SECTION.CONTENT
underline: true
fields:
content:
type: markdown
validate:
type: textarea
Is there a way to override those blueprints without changing the actual theme?
@speendo, Blueprints can indeed be extended to add/replace/remove fields. See Advanced Blueprint Features
Try the following to override blueprint /themes/akazie-wood/blueprints/modular/text.yaml:
Admin should now show TinyMCE as editor for modules using file text.md
1 Like
Thank you @pamtbaau!
Your solution works perfectly.
Just out of curiosity: How would it be possible to remove the field type: markdown
in the override without replacing it with type: tinymce
.
I ask because my inherited theme is now dependent on the tinymce plugin. I would prefer that it uses the default editor (tinymce when it is installed, otherwise fall back to markdown).
@speendo, Try the following to conditionally set the type of editor to be used:
Update blueprint /user/themes/myakazie/blueprints/modular/text.yaml:
extends@:
type: text
context: blueprints://pages/modular
form:
fields:
tabs:
fields:
inhalt:
fields:
content:
fields:
content:
data-type@: '\Grav\Theme\Myakazie::getEditorType'
Add the following to the class in /user/themes/myakazie/myakazie.php:
public static function getEditorType(): string {
/** @var Config */
$config = Grav::instance()['config'];
$useMceEditor = $config->get('plugins.tinymce-editor.enabled', false);
return $useMceEditor ? 'tinymce' : 'markdown';
}
See Using Function Calls (data-*@)
1 Like
That’s awesome! Thank you!