django在tinymce中更改字体大小和字体系列

时间:2015-02-08 04:44:49

标签: django tinymce

我的基本文件中有这个脚本......

<script src="//tinymce.cachefly.net/4.1/tinymce.min.js"></script>
<script>
tinymce.init({selector:'textarea',
plugins: [
    "advlist autolink lists link image charmap print preview hr anchor pagebreak",
    "searchreplace wordcount visualblocks visualchars code fullscreen",
    "insertdatetime media nonbreaking save table contextmenu directionality",
    "emoticons template paste textcolor colorpicker textpattern"
    ],
});
</script>

在我的tinymce文本编辑器中,我看到的字体大小我猜是10像素,但我想将其更改为16像素,并且还想更改字体系列..

任何帮助??

3 个答案:

答案 0 :(得分:2)

要设置默认字体大小,只需添加该行即可 在settings.py的TINYMCE_DEFAULT_CONFIG变量中'content_style':'。mcecontentbody {font-size:13px;}',

TINYMCE_DEFAULT_CONFIG = {
    'theme': 'advanced',
    'relative_urls': False,
    'plugins': 'media,spellchecker',
    'content_style': '.mcecontentbody{font-size:13px;}',
    'theme_advanced_buttons1': 'bold,italic,underline,bullist,numlist,|,link,unlink,image',
    'theme_advanced_resizing': True,
    'theme_advanced_path': False,
}

答案 1 :(得分:1)

请参阅适用于我的settings.py配置:

TINYMCE_DEFAULT_CONFIG = {
'theme': "advanced", # default value
'relative_urls': False, # default value
'plugins': 'table,spellchecker,paste,searchreplace',
'theme_advanced_buttons1': 'bold,italic,underline,bullist,numlist,link,unlink,styleselect,fontselect,fontsizeselect',
'width': '100%',
'height': 300,
'paste_text_sticky': True,
'paste_text_sticky_default': True,
'valid_styles': 'font-weight,font-style,text-decoration',
'fontsize_formats': "8pt 10pt 11pt 12pt 13pt 14pt 16pt 18pt 20pt 24pt 36pt",
'font_formats': "Andale Mono=andale mono,times;" +
    "Arial=arial,helvetica,sans-serif;" +
    "Arial Black=arial black,avant garde;" +
    "Book Antiqua=book antiqua,palatino;" +
    "Comic Sans MS=comic sans ms,sans-serif;" +
    "Courier New=courier new,courier;" +
    "Georgia=georgia,palatino;" +
    "Helvetica=helvetica;" +
    "Impact=impact,chicago;" +
    "Symbol=symbol;" +
    "Tahoma=tahoma,arial,helvetica,sans-serif;" +
    "Terminal=terminal,monaco;" +
    "Times New Roman=times new roman,times;" +
    "Trebuchet MS=trebuchet ms,geneva;" +
    "Verdana=verdana,geneva;" +
    "Webdings=webdings;" +
    "Wingdings=wingdings,zapf dingbats",}
TINYMCE_SPELLCHECKER = True
TINYMCE_COMPRESSOR = True

以下是截图:

TinyMCE

答案 2 :(得分:-1)

查看tinyMCE配置文档。有两种合适的设置可满足您的需求:font_formats和fontsize_formats,使用方式如下:

tinymce.init({
    fontsize_formats: "8pt 10pt 12pt 14pt 18pt 24pt 36pt",
    font_formats: "Arial=arial,helvetica,sans-serif;"
});