ここの情報は古いです。ご理解頂いた上でお取り扱いください。

Changeset 7289


Ignore:
Timestamp:
May 20, 2008, 10:17:06 PM (11 years ago)
Author:
ebihara
Message:

#2352:IEの場合、FONT要素を除き、正規表現によって文字装飾タグへの変換をおこなうよう変更

Location:
OpenPNE/trunk/public_html/js/tiny_mce/plugins/openpne
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • OpenPNE/trunk/public_html/js/tiny_mce/plugins/openpne/editor_plugin.js

    r7279 r7289  
    3131id=t.prefix+id;s=tinymce.extend({title:s.title,'class':'mce_'+id,'menu_class':ed.getParam('skin')+'Skin',scope:s.scope},s);c=new tinymce.ui.OpenPNECmdButton(id,s);ed.onPostRender.add(function(){var parentContainer=document.getElementById(c.id).parentNode;parentContainer.style.width="45px";});ed.onRemove.add(function(){c.destroy();});return t.add(c);},_previewToText:function(s,editor){var editorDoc=editor.getBody();function rep(re,str){s=s.replace(re,str);};if(!tinymce.isWebKit){s=tinymce.trim(s);rep('/<(\/?)strong>/gi','<\1b>');rep('/<(\/?)strike>/gi','<\1s>');rep('/<(\/?)em>/gi','<\1i>');editor.dom.setHTML(editor.getBody(),s);}
    3232function convertHtmlTagToDecoTag(doc,tagname)
    33 {var tagList=doc.getElementsByTagName(tagname);var org_tagname=tagname;var args={};while(tagList.length){targetObj=tagList[0];if(org_tagname=="font"){var size=targetObj.getAttribute("size");var color=targetObj.getAttribute("color");if(size&&color){if(tinymce.isIE){targetObj.removeAttribute("color");targetObj.innerHTML='<font color="'+color+'">'+targetObj.innerHTML+"</font>";}else{var fontSize=document.createElement("font");fontSize.setAttribute("size",size);fontSize.removeAttribute("color");var clone=targetObj.cloneNode(true);clone.removeAttribute("size");fontSize.appendChild(clone);targetObj.parentNode.replaceChild(fontSize,targetObj);}
     33{var tagList=doc.getElementsByTagName(tagname);var org_tagname=tagname;var args={};if(Prototype.Browser.IE&&org_tagname!="font"){var reg=new RegExp("<"+tagname+">","gi");editorDoc.innerHTML=editorDoc.innerHTML.replace(reg,"<op"+tagname+">");var reg=new RegExp("</"+tagname+">","gi");editorDoc.innerHTML=editorDoc.innerHTML.replace(reg,"</op"+tagname+">");s=editorDoc.innerHTML;return;}
     34while(tagList.length){targetObj=tagList[0];if(org_tagname=="font"){var size=targetObj.getAttribute("size");var color=targetObj.getAttribute("color");if(size&&color){if(tinymce.isIE){targetObj.removeAttribute("color");targetObj.innerHTML='<font color="'+color+'">'+targetObj.innerHTML+"</font>";}else{var fontSize=document.createElement("font");fontSize.setAttribute("size",size);fontSize.removeAttribute("color");var clone=targetObj.cloneNode(true);clone.removeAttribute("size");fontSize.appendChild(clone);targetObj.parentNode.replaceChild(fontSize,targetObj);}
    3435tagList=doc.getElementsByTagName(org_tagname);args={};continue;}
    3536if(size=='5'){tagname='op:large';}else if(size=='1'){tagname='op:small';}
     
    3940tagList=doc.getElementsByTagName(org_tagname);}
    4041s=editorDoc.innerHTML;}
    41 var convertList=new Array('span','b','u','s','i','font');for(var i=0;i<convertList.length;i++){convertHtmlTagToDecoTag(editor.getBody(),convertList[i]);}
     42var convertList=new Array('span','font','b','u','s','i');for(var i=0;i<convertList.length;i++){convertHtmlTagToDecoTag(editor.getBody(),convertList[i]);}
    4243rep(/<\/?div>/gi,"");if(tinymce.isIE){rep(/<op/gi,"<op:");rep(/<\/op/gi,"</op:");}
    4344rep(/<br\s?\/?[^>]*>/gi,"\n\n");rep(/&nbsp;/gi," ");rep(/&quot;/gi,"\"");rep(/&lt;/gi,"<");rep(/&gt;/gi,">");rep(/&amp;/gi,"&");return s;},_textToPreview:function(s){s=tinymce.trim(s);var rule=/&lt;op:(b|u|s|i|large|small|color)( code="(#[0-9a-f]{3,6})"|)&gt;(.*?)&lt;\/op:\1&gt;/i;function rep(re,str){s=s.replace(re,str);};function convertDecoTagToHtmlTag(matches)
  • OpenPNE/trunk/public_html/js/tiny_mce/plugins/openpne/editor_plugin.js.src

    r7279 r7289  
    378378                var org_tagname = tagname;
    379379                var args = {};
     380
     381                if (Prototype.Browser.IE && org_tagname != "font") {
     382                    var reg = new RegExp("<" + tagname + ">", "gi");
     383                    editorDoc.innerHTML = editorDoc.innerHTML.replace(reg, "<op" + tagname + ">");
     384
     385                    var reg = new RegExp("</" + tagname + ">", "gi");
     386                    editorDoc.innerHTML = editorDoc.innerHTML.replace(reg, "</op" + tagname + ">");
     387
     388                    s = editorDoc.innerHTML;
     389                    return;
     390                }
    380391
    381392                while (tagList.length) {
     
    466477            }
    467478
    468             var convertList = new Array('span', 'b', 'u', 's', 'i', 'font');
     479            var convertList = new Array('span', 'font', 'b', 'u', 's', 'i');
    469480            for (var i = 0; i < convertList.length; i++) {
    470481                convertHtmlTagToDecoTag(editor.getBody(), convertList[i]);
Note: See TracChangeset for help on using the changeset viewer.