2010-06-03 48 views
1

我已成功設置tinymce以在iframe中的頁面上工作。一切都很完美。TinyMce imagemanager與iframe一起使用時不會生成圖像路徑

但是,當您使用imagemanager在編輯器中選取要插入或替換的圖像時,它將不會將圖像的路徑(和文件名)複製到「插入/編輯圖像」中的「圖像URL」框。該框將保持空白或保留前一圖像的地址。

行爲與filemanager插件相同。

tinyMCE.init( 
{  
    mode : "none",  
    editor_selector : "mceEditor",  
    theme : "advanced",  
    plugins : "filemanager,imagemanager,autoresize,safari,pagebreak,style,layer,table,save,advhr,advimage,advlink,emotions,iespell,insertdatetime,preview,media,searchreplace,print,contextmenu,paste,directionality,fullscreen,noneditable,visualchars,nonbreaking,xhtmlxtras,template,inlinepopups,spellchecker",  
    theme_advanced_buttons1 : "insertfile,insertimage,advimage,imagemanager,bold,italic,underline,|,justifyleft,justifycenter,justifyright,justifyfull,nonbreaking,cut,copy,paste,pastetext,pasteword,|,search,replace,|,bullist,numlist",  
    theme_advanced_buttons2 : "blockquote,|,link,unlink,anchor,image,cleanup,help,code,|,insertdate,inserttime,|,forecolor,backcolor,|,charmap,iespell,media,advhr",  
    theme_advanced_layout_manager : "SimpleLayout",  
    theme_advanced_buttons3 : "tablecontrols,|,hr,removeformat,visualaid,|,sub,sup,strikethrough",  
    theme_advanced_buttons4 : "styleselect,formatselect,fontselect,fontsizeselect,|,undo,redo,|,spellchecker",  
    theme_advanced_toolbar_location : "external",  
    theme_advanced_toolbar_align : "left",  
    theme_advanced_statusbar_location : "bottom",  
    relative_urls : true,  
    document_base_url : "http://xxxxxxxxxxx.com/",  
    auto_resize : true,  
    content_css : "/custom/css/style.css",  
    extended_valid_elements : "iframe[height|width|src|frameborder|scrolling]",  
});  

/*  
    The following code comes from- http://tinymce.moxiecode.com/punbb/viewtopic.php?id=12966  
    Without it the editor only loads 10% of the time. With it, it's pretty much 100% consistent.  
    The other changes mentioned in the post have also been implemented.  
*/  
var setupTiny = function()  
{  
    var ifrObj = document.getElementById('pageEditIFrame');  
    var win = ifrObj;  
    if (win.contentWindow)  
    {  
     win = win.contentWindow;  
    }  

    var d;  
    if(ifrObj.contentDocument)  
    {  
     d = ifrObj.contentDocument;  
    }  
    else if (ifrObj.contentWindow)  
    {  
     d = ifrObj.contentWindow.document;  
    }  
    else if (ifrObj.document)  
    {  
     d = ifrObj.document;  
    }  

    textAreas.each(function(txtEl)  
    {  
     tinyMCE.execCommand('mceAddFrameControl', false,  
     {  
      element_id : txtEl,  
      window : win,  
      doc : d  
     });  
    });  
};  

//Waiting 1 second seems to make the editor load more reliably.  
setTimeout("setupTiny();",1000); 

回答

1

我遇到了一個類似的問題,只出現在更新版本的Firefox中 - Chrome和IE對我來說工作正常。不知道它是否是完全相同的問題(我沒有使用iframe),但它以相同的方式呈現。

此處,我發現我的解決方案: http://tinymce.moxiecode.com/punbb/viewtopic.php?id=23302

正如你可以看到那裏,編碼器用於TinyMCE的的人認爲它在FF的一個bug,雖然修復看起來更像是tiny_mce假設的錯誤仍然存​​在在3.5的某個點固定的Firefox。下面是對我工作的解決方案(從郵報):

1) 轉到tiny_mce.js

2) 找到這行:this.isGecko = ua.indexOf('Gecko') != -1;

下將其添加:

this.isGecko369 = (this.isGecko && ua.indexOf('irefox/3.6.')!= -1 && parseInt(ua.substr(ua.indexOf('irefox/3.6.')+11,2)) >= 9); 
this.isGecko369 = (this.isGecko369 || (this.isGecko && ua.indexOf('irefox/3.5.')!= -1 && parseInt(ua.substr(ua.indexOf('irefox/3.5.')+11,2)) >= 9)); 

3) 找到這行:fixGeckoBaseHREFBug : function(m, e, h) {

下面THA t有這一行:if (tinyMCE.isGecko) { 改變它:if (tinyMCE.isGecko && !tinyMCE.isGecko369) {