Tinymce:编辑器底部的工具栏位置



我正在使用具有现代主题的TinyMCE 4。我想在编辑器底部设置工具栏的位置(就像状态栏的位置一样)

这是代码,但它不起作用:

tinymce.init({
                selector: 'textarea#editor',
                menubar: false,
                statusbar: false,
                resize: false,
                height: textEditHeight,
                theme_modern_toolbar_location : "bottom",
});
我知道

这是一篇旧帖子,但我想我会分享我的解决方案。

我为"init"事件添加一个事件处理程序,然后使用 jQuery 更改工具栏和编辑器div 的顺序。

tinyMCE.init({
...
    setup: function (ed) {
      ed.on('init', function (evt) {
          var toolbar = $(evt.target.editorContainer)
                            .find('>.mce-container-body >.mce-toolbar-grp');
          var editor = $(evt.target.editorContainer)
                            .find('>.mce-container-body >.mce-edit-area');
          // switch the order of the elements
          toolbar.detach().insertAfter(editor);
      });
}

我已经找到了一种方法,用纯CSS。只需将此代码添加到您的自定义 css 文件或 html 中的样式标签中即可。

#mceu_5-body{
   display: flex;
   flex-direction: column-reverse;
}

它所做的是反转div 的排列方向,即从下到上。唯一的缺点是flex是一个现代的CSS属性,因此在旧浏览器中不受支持

基于 tinyMCE 文档,您只能使用theme_modern_toolbar_location:"底部"

当您使用高级主题时。

theme : "advanced",

完整示例:

<script type="text/javascript">
// O2k7 skin
tinyMCE.init({
        // General options
        mode : "exact",
        elements : "elm1",
        theme : "advanced",
        skin : "o2k7",
        plugins : "spellchecker,pagebreak,style,layer,table,save,advhr,advimage,advlink,emotions,iespell,inlinepopups,insertdatetime,preview,media,searchreplace,print,contextmenu,paste,directionality,fullscreen,noneditable,visualchars,nonbreaking,xhtmlxtras,template,imagemanager,filemanager",
        // Theme options
        theme_advanced_buttons1 : "save,newdocument,|,bold,italic,underline,strikethrough,|,justifyleft,justifycenter,justifyright,justifyfull,|,styleselect,formatselect,fontselect,fontsizeselect",
        theme_advanced_buttons2 : "cut,copy,paste,pastetext,pasteword,|,search,replace,|,bullist,numlist,|,outdent,indent,blockquote,|,undo,redo,|,link,unlink,anchor,image,cleanup,help,code,|,insertdate,inserttime,preview,|,forecolor,backcolor",
        theme_advanced_buttons3 : "tablecontrols,|,hr,removeformat,visualaid,|,sub,sup,|,charmap,emotions,iespell,media,advhr,|,print,|,ltr,rtl,|,fullscreen",
        theme_advanced_buttons4 : "insertlayer,moveforward,movebackward,absolute,|,styleprops,spellchecker,|,cite,abbr,acronym,del,ins,attribs,|,visualchars,nonbreaking,template,blockquote,pagebreak,|,insertfile,insertimage",
        theme_advanced_toolbar_location : "top",
        theme_advanced_toolbar_align : "left",
        theme_advanced_statusbar_location : "bottom",
        theme_advanced_resizing : true,
        theme_advanced_toolbar_location : "bottom"
});
</script>
<form method="post" action="dump.php">
        <textarea id="elm1" name="elm1" style="width:100%">
        </textarea>

</form>

在他们的一篇博客文章中,他们说他们已经删除了advanced_theme。因此,如果我们想使用 TinyMCE 底部的工具栏,我们将不得不创建一个新皮肤。

自定义 css 文件的底部插入 css 代码

.mce-top-part{
    position:absolute;
    bottom:0
}

最新更新