开发者

How can I move TinyMCE's toolbar into a modal popup?

I'm using TinyMCE & jQuery and am having a problem moving TinyMCE's external toolbar to another location in the DOM.

To further complicate things, there are multiple TinyMCE instances on the page. I only want the toolbar for the one that's currently being edited.

Here's some sample code:

$(textarea).tinymce({
  setup: function(ed) {setupMCEToolbar(ed, compone开发者_如何学GontID, displaySettingsPane)}
  ,script_url: '/clubs/data/shared/scripts/tiny_mce/tiny_mce.js'
  ,theme : "advanced"
  ,plugins : "safari,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"
   ,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,|,cite,abbr,acronym,del,ins,attribs,|,visualchars,nonbreaking,template,pagebreak"
  ,theme_advanced_toolbar_location : "external"
  ,theme_advanced_toolbar_align : "left"
  ,theme_advanced_statusbar_location : "bottom"
  ,theme_advanced_resizing : true
 });

var setupMCEToolbar = function (mce, componentID, displaySettingsPane)
{
 mce.onClick.add(function(ed,e){
  displaySettingsPane($('#' + componentID));
  $('#' + componentID).fetch('.mceExternalToolbar').eq(0).appendTo('#settingsPaneContent');
 });
}

Basically, it seems as though the setupMCEToolbar function cannot track down the mceExternalToolbar to move it.

Has anyone ever had success trying to do something like this?

EDIT It's a Monday alright... it couldn't find the external toolbar because I was using children() instead of fetch().

There's still an issue in that: 1) Moving it is incredibly slow and 2) Once it moves, TinyMCE breaks.

EDIT 2 A bit more clarification: The modal is draggable, thus making any purely-CSS workarounds a bit awkward...


I have not had much success moving the element, however it should be fairly simple to remove and recreate the TinyMCE box in your toolbar.

I would do something like the following:

var content = tinyMCE.get('id_of_text_area').getContent();
tinyMCE.execCommand('mceFocus', false, 'id_of_text_area');
tinyMCE.execCommand('mceRemoveControl', false, 'id_of_text_area');

// pop up your new area
popup('new_area');

// Add a new textarea with the content
$('<textarea id="id_of_text_area" />')
  .val(content)
  .appendTo('#new_area')
  // initialize a new editor on this textarea
  .tinymce({..});


when you have textarea id="opis" use that:

    #opis_external {
        top:200px !important;
        left:0px !important;
        position:fixed !important;

    }
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜