Obtaining the “default” mockup TinyMCE configuration on Plone 5

谁说我不能喝 提交于 2019-12-11 03:33:17

问题


I'm trying to configure TinyMCE inside Plone 5 template (so: not the z3c.form widget type).

Using the TinyMCE Mockup patter you quickly learn how to display a rudimentary TinyMCE configuration (without any i18n support). But how I can get the "default" configuration applied to TinyMCE when it's loaded for default content types like a Plone page?

What I'm looking for a way to get the right value for the data-pat-tinymce HTML attribute.


回答1:


I think what you're asking for is to do something like this...

First, get the default tinymce pattern configuration:

from zope.component import getMultiAdapter
import json
pattern_options = getMultiAdapter(
  (context, request, None),
  name="plone_settings").tinymce()['data-pat-tinymce']
tiny_options = json.loads(pattern_options)

Then, manipulate the tiny_options dictionary and customize to your needs and provide it to your data-pat-tinymce attribute with json.dumps.




回答2:


Starting from @vangheem answer I found also an alternative way using mimetype select pattern.

You must configure the pattern with a JSON like this:

conf = {"textareaName": "text",
        "widget": {"text/html": {"pattern": "tinymce",
                                 "patternOptions": tiny_options}}}

...where tiny_options is the one taken from the accepted answer above and textareaName is the HTML textarea name where you want to activate TinyMCE.



来源:https://stackoverflow.com/questions/30606898/obtaining-the-default-mockup-tinymce-configuration-on-plone-5

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!