TinyMCE Toolbar location

匿名 (未验证) 提交于 2019-12-03 02:54:01

问题:

How can the Toolbar be displayed on a defined Place (div with specific id)?

I tried theme_advanced_toolbar_location : "external" and setting the position of the "mceExternalToolbar" (like suggested here: TinyMCE - external toolbar position) but don't really like this solution since it uses fixed positioning.... Is there a option how to where to place the div.

The docu says for theme_advanced_toolbar_location:

.. adds the toolbar to a DIV element and sets the class of this DIV to "mceExternalToolbar". ... but not if you can change the div. is there maybe a possibilty to change this code?

BR, Stefan

回答1:

This has been an issue for me a few months ago. All you need to do is to move the external toolbar to the place you want it to be. I wrote a function in one of my plugins. On my page i have created a div with class "externalToolbarWrapper" in which i insert the toolbar. Here is that function. You might need to tweak it a bit, but think it will be of help to you.

    showExternalToolbar: function(){          if (this.editor.getParam('theme_advanced_toolbar_location') != 'external') return;          if (!document.getElementById('externalToolbarWrapper')) $(document.body).prepend('<div id="externalToolbarWrapper"></div>');          var $toolbar = $('#'+this.editor.id + '_external');          // inserts the external toolbar in the external wrapper         $('#externalToolbarWrapper').append('<div id="replacementDiv"></div>');          $('#replacementDiv').replaceWith($toolbar.show());         $toolbar.css('top','0px');         $toolbar.css('display','block');          $('#' + this.editor.id + '_external_close').remove();         $('#' + this.editor.id +'_toolbargroup').css('width', innerWidth || 800); // innerwidth is an integer value     }, 

Update:

You should call it onInit (use the setup configuration parameter here)

   setup : function(ed) {       ed.onInit.add(function(ed) {           // place your code here       });    }, 


标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!