Tiny MCE popups blank in Django admin

前端 未结 10 997
再見小時候
再見小時候 2020-12-06 00:45

I have got tinyMCE working in the django admin, but all the popups are blank (eg. edit HTML, add image)

The paths to the popup html pages all exist in the right plac

10条回答
  •  天涯浪人
    2020-12-06 01:34

    If this is the JQuery version of TinyMCE, and you're serving media (including the TinyMCE .js files) from another server to that on which Django is running, this might apply: your browser will prevent the TinyMCE script from accessing the Django admin URL from the domain from which TinyMCE is served. Safari's error console is the most explicit e.g.:

    Unsafe JavaScript attempt to access frame with URL http://127.0.0.1/~whatever/django-templates/javascript/tiny_mce/jscripts/more stuffhere/anchor.htm
    from frame with URL http://127.0.0.1:8000/admin/flatpages/flatpage/1/.
    Domains, protocols and ports must match.
    

    There is a setting in tiny_mce_popup.js file that states:

    // Uncomment and change this document.domain value if you are loading the script cross subdomains
    // document.domain = 'moxiecode.com';
    

    but it didn't work for me. You could try breaking the rules and serve the TinyMCE scripts from the Django server, or add the scripts to your modified admin templates' HTML... but I'm sure there's a better solution. I ran out of patience trying, and although I'm sure it's been done, I can't find a solution for getting TinyMCE to work across domains.

    However, because of the hideous HTML/inline CSS mangling users can produce with visual editors, other solutions might be better: Textile (Ruby's Redcloth gives visual feedback - perhaps there's a similar Python implementation based on PyTextile or Python-Textile??), or markItUp! (JQuery, so might present the same problem) which has a nice visual editing toolbar.

    If you're doubting this move away from 'Word-like' editors, <- that link is a good article on the issue.

    Postscript: there's a nice Javascript implementation of Markdown in WMD, that offers a TinyMCE-like toolbar, semantic-markup-style (wysiwym - 'what you see is what you mean') editor shortcuts. GitHub uses a related solution.

提交回复
热议问题