Welcome | Get started | Dive | Contribute | Topics | Reference | Changes | More
tinymce
: Add the TinyMCE editor¶
The lino.modlib.tinymce
plugin activates usage of the TinyMCE editor for
HTML text fields (lino.core.fields.RichTextField
) instead of the
built-in Ext.form.HtmlEditor editor that comes with ExtJS.
Side note: Code snippets (lines starting with >>>
) in this document get
tested as part of our development workflow. The following
initialization snippet tells you which demo project is being used in
this document.
>>> from lino import startup
>>> startup('lino_book.projects.min9.settings')
>>> from lino.api.doctest import *
Dependencies¶
It requires the lino.modlib.office
plugin because it adds entries to the
menu.
>>> dd.plugins.tinymce.needs_plugins
['lino.modlib.office']
This plugin makes sense only if lino.modlib.extjs
is also installed. But
this is not a requirement, it rather means that other frond ends should disable
it by listing it in to their disables_plugins
.
Configuration¶
When serving static files from a different subdomain, TinyMCE needs to know about this.
Typical usage is to specify this in your lino_local.py
file:
def setup_site(self):
...
from lino.api.ad import configure_plugin
configure_plugin('tinymce', document_domain="mydomain.com")
Currently when using this, you must also manually change your
static tiny_mce_popup.js
file after each collectstatic.
- tiny_mce_popup.js¶
The factory version of that file contains:
// Uncomment and change this document.domain value if you are loading the script cross subdomains
// document.domain = 'moxiecode.com';
Uncomment and set the document.domain
to the same value as
your document_domain
.
The Templates
table¶
- class lino.modlib.tinymce.TextFieldTemplate¶
A reusable block of text that can be selected from a text editor to be inserted into the text being edited.
- class lino.modlib.tinymce.TextFieldTemplates¶
- class lino.modlib.tinymce.MyTextFieldTemplates¶
- class lino.modlib.tinymce.Templates¶
The Templates
is designed to make usage of TinyMCE’s
external_template_list_url
setting.
It is called by TinyMCE (template_external_list_url) to fill the list of available templates.
>>> url = "/tinymce/templates/notes/MyNotes/69/body"
>>> test_client.force_login(rt.login('robin').user)
>>> response = test_client.get(url, REMOTE_USER='robin')
>>> response.status_code
200
>>> print(response.content.decode())
...
var tinyMCETemplateList = [
[ "hello", "/tinymce/templates/notes/MyNotes/69/body/1", "Inserts 'Hello, world!'" ],
[ "mfg", "/tinymce/templates/notes/MyNotes/69/body/2", "None" ]
];
>>> url = "/tinymce/templates/notes/MyNotes/69/body/1"
>>> response = test_client.get(url, REMOTE_USER='robin')
>>> response.status_code
200
>>> print(response.content.decode())
...
Hello, world!