Disable TinyMCE absolute to relative URL Conversions

后端 未结 4 763
挽巷
挽巷 2020-12-29 19:48

Can anyone tell me how to get TinyMCE to stop converting my URLs to relative links in Plone?

For example, if I enter this in the HTML source:

<         


        
相关标签:
4条回答
  • 2020-12-29 20:13

    Set convert_urls: false in tiny_mce_init.js, not tiny_mce.js. Early in tiny_mce_init.js you'll see a call to window.tinyMCE.init passing a bunch of initialisation options. In the Products.TinyMCE I'm looking at, the last option is fix_list_elements: false. Add your option there.

    Edit: tiny_mce_init.js is no longer used in Products.TinyMCE 1.3.x (Plone 4.3). Instead, override the tinymce-jsonconfiguration browser view, e.g.:

    Assuming you have a package with a browser layer, add in browser/configure.zcml:

    <browser:page
        for="*"
        name="tinymce-jsonconfiguration"
        class=".tinymce.TinyMCEBrowserView"
        permission="zope2.View"
        attribute="jsonConfiguration"
        layer="..interfaces.IMyBrowserLayer"
        />
    

    Then add browser/tinymce.py:

    try:
        import simplejson as json
    except ImportError:
        import json
    
    from Acquisition import aq_inner
    from Products.CMFCore.utils import getToolByName
    from Products.TinyMCE.browser.browser import TinyMCEBrowserView as View
    from Products.TinyMCE.browser.interfaces.browser import ITinyMCEBrowserView
    from zope.interface import implements
    
    
    class TinyMCEBrowserView(View):
        implements(ITinyMCEBrowserView)
    
        def jsonConfiguration(self, field):
            """Return the configuration in JSON"""
    
            utility = getToolByName(aq_inner(self.context), 'portal_tinymce')
            config = utility.getConfiguration(context=self.context,
                                              field=field,
                                              request=self.request)
            config['convert_urls'] = False
            return json.dumps(config)
    
    0 讨论(0)
  • 2020-12-29 20:15

    An other solution is to configure TinyMCE with the control panel to use UID for every links and images, instead of path, so you don't modify any existing javascripts and don't have any relative url displayed.

    0 讨论(0)
  • 2020-12-29 20:27

    You should add these configs into tinymce.int:

    relative_urls: false,

    convert_urls: false,

    remove_script_host : false,

    0 讨论(0)
  • 2020-12-29 20:33

    In Plone 5 is possible disable TinyMCE absolute to relative URL adding variables in Advanced tab of TinyMCE Settings

    Site setup > TinyMCE > Advaced

    {"relative_urls": false, "convert_urls": false, "remove_script_host": false}
    

    Further variables are available in Products/CMFPlone/static/components/tinymce-builded/js/tinymce/tinymce.js

    ...
    popup_css: '',
    plugins: '',
    document_base_url: documentBaseUrl,
    add_form_submit_trigger: true,
    submit_patch: true,
    add_unload_trigger: true,
    convert_urls: true,
    relative_urls: true,
    remove_script_host: true,
    object_resizing: true,
    ...
    
    0 讨论(0)
提交回复
热议问题