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

Javascript Tinymce:编辑器底部的工具栏位置,javascript,tinymce,tinymce-4,Javascript,Tinymce,Tinymce 4,我用的是带有现代主题的TinyMCE 4。我想在编辑器底部设置工具栏的位置(就像状态栏的位置一样) 下面是代码,但它不起作用: tinymce.init({ selector: 'textarea#editor', menubar: false, statusbar: false, resize: false, height: textE

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

下面是代码,但它不起作用:

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

根据tinyMCE文档,您只能使用 主题\现代\工具栏\位置:“底部”

当您使用高级主题时

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>

//O2k7皮肤
tinyMCE.init({
//一般选择
模式:“精确”,
元素:“elm1”,
主题:“高级”,
皮肤:“o2k7”,
插件:“拼写检查器、分页符、样式、图层、表格、保存、advhr、advimage、advlink、情绪、iespell、inlinepopups、insertdatetime、预览、媒体、搜索替换、打印、上下文菜单、粘贴、方向性、全屏、不可编辑、visualchars、不可中断、xhtmlxtras、模板、图像管理器、文件管理器”,
//主题选项
主题_高级_按钮1:“保存、新建文档、|、粗体、斜体、下划线、删除线、|、左对齐、居中对齐、右对齐、满对齐、|、样式选择、格式选择、字体选择、字体大小选择”,
主题高级按钮2:“剪切、复制、粘贴、粘贴文本、粘贴文字、搜索、替换、布利斯特、numlist、outdent、indent、blockquote、|、撤消、重做、链接、取消链接、锚定、图像、清理、帮助、代码、插入日期、插入时间、预览、前景色、后景色”,
主题|高级|按钮3:“表格控件,|,hr,removeformat,visualaid,|,sub,sup,|,charmap,情感,易趣,媒体,advhr,|,打印,|,ltr,rtl,|,全屏”,
theme_advanced_按钮4:“插入层、向前移动、向后移动、绝对、|、styleprops、拼写检查器、|、引用、缩写、首字母缩略词、del、ins、attribs、|、visualchars、非中断、模板、块引号、页面中断、|、插入文件、插入图像”,
主题\高级\工具栏\位置:“顶部”,
主题\高级\工具栏\对齐:“左”,
主题\高级\状态栏\位置:“底部”,
主题\u高级\u大小调整:正确,
主题\高级\工具栏\位置:“底部”
});

在他们的一篇博文中,他们说他们已经删除了advanced_主题。所以,如果我们想使用TinyMCE底部的工具栏,我们必须创建一个新的皮肤。

我知道这是一篇老文章,但我想我会分享我的解决方案

我为“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属性,因此在旧浏览器中不受支持

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

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

但是TinyMCE 4中删除了高级主题。因此,这意味着,我不能使用theme_modern_toolbar_location:“bottom”,因为在文档中,此属性只能用于旧版3.x。在新的4.xSorry中,我看不到任何对工具栏位置的控制来恢复一篇非常旧的文章,但是自2013年以来,这个问题有什么变化吗?我真的希望我的TinyMCE工具栏位于文本框的底部。我必须使用
.tox div.tox-editor-container
作为选择器,因为我使用的是一个角度包装器,但这很有效。谢谢