X-Git-Url: https://jasonwoof.com/gitweb/?p=ckeditor.git;a=blobdiff_plain;f=plugins%2Fwysiwygarea%2Fplugin.js;h=8d8359280f1b38e3a56cc2e7c6bc5d6f4ec9d6b2;hp=55eca4f97135a2d64f00a841ff9981147ccff35b;hb=8761695d9b70afe75905deaac88f78c1f8aeb32d;hpb=ea7e3453c7b0f023b050aca6d9f83ab372860d91 diff --git a/plugins/wysiwygarea/plugin.js b/plugins/wysiwygarea/plugin.js index 55eca4f..8d83592 100644 --- a/plugins/wysiwygarea/plugin.js +++ b/plugins/wysiwygarea/plugin.js @@ -3,6 +3,7 @@ Copyright (c) 2003-2009, CKSource - Frederico Knabben. All rights reserved. For licensing, see LICENSE.html or http://ckeditor.com/license */ -(function(){var a={table:1,pre:1},b=/\s*<(p|div|address|h\d|center)[^>]*>\s*(?:]*>| | )\s*(:?<\/\1>)?\s*$/gi;function c(f){var k=this;if(k.mode=='wysiwyg'){k.focus();var g=k.getSelection(),h=f.data;if(k.dataProcessor)h=k.dataProcessor.toHtml(h);if(CKEDITOR.env.ie){var i=g.isLocked;if(i)g.unlock();var j=g.getNative();if(j.type=='Control')j.clear();j.createRange().pasteHTML(h);if(i)k.getSelection().lock();}else k.document.$.execCommand('inserthtml',false,h);}};function d(f){if(this.mode=='wysiwyg'){this.focus();this.fire('saveSnapshot');var g=f.data,h=g.getName(),i=CKEDITOR.dtd.$block[h],j=this.getSelection(),k=j.getRanges(),l=j.isLocked;if(l)j.unlock();var m,n,o,p;for(var q=k.length-1;q>=0;q--){m=k[q];m.deleteContents();n=!q&&g||g.clone(true);var r,s;if(this.config.enterMode!=CKEDITOR.ENTER_BR&&i)while((r=m.getCommonAncestor(false,true))&&((s=CKEDITOR.dtd[r.getName()])&&(!(s&&s[h]))))m.splitBlock();m.insertNode(n);if(!o)o=n;}m.moveToPosition(o,CKEDITOR.POSITION_AFTER_END);var t=o.getNextSourceNode(true);if(t&&t.type==CKEDITOR.NODE_ELEMENT)m.moveToElementEditStart(t);j.selectRanges([m]);if(l)this.getSelection().lock();CKEDITOR.tools.setTimeout(function(){this.fire('saveSnapshot');},0,this);}};function e(f){var g=f.editor,h=f.data.path,i=h.blockLimit,j=f.data.selection,k=j.getRanges()[0],l=g.document.getBody(),m=g.config.enterMode;if(m!=CKEDITOR.ENTER_BR&&k.collapsed&&i.getName()=='body'&&!h.block){var n=j.createBookmarks(),o=k.fixBlock(true,g.config.enterMode==CKEDITOR.ENTER_DIV?'div':'p');if(CKEDITOR.env.ie){var p=o.getElementsByTag('br'),q;for(var r=0;r':'br');l.append(A);}};CKEDITOR.plugins.add('wysiwygarea',{requires:['editingblock'],init:function(f){var g=f.config.enterMode!=CKEDITOR.ENTER_BR?f.config.enterMode==CKEDITOR.ENTER_DIV?'div':'p':false;f.on('editingBlockReady',function(){var h,i,j,k,l,m,n,o=CKEDITOR.env.isCustomDomain(),p=function(){if(j)j.remove();if(i)i.remove(); -m=0;var s='void( '+(CKEDITOR.env.gecko?'setTimeout':'')+'( function(){'+'document.open();'+(CKEDITOR.env.ie&&o?'document.domain="'+document.domain+'";':'')+'document.write( window.parent[ "_cke_htmlToLoad_'+f.name+'" ] );'+'document.close();'+'window.parent[ "_cke_htmlToLoad_'+f.name+'" ] = null;'+'}'+(CKEDITOR.env.gecko?', 0 )':')()')+' )';if(CKEDITOR.env.opera)s='void(0);';j=CKEDITOR.dom.element.createFromHtml('');var t=f.lang.editorTitle.replace('%1',f.name);if(CKEDITOR.env.gecko){j.on('load',function(u){u.removeListener();r(j.$.contentWindow);});h.setAttributes({role:'region',title:t});j.setAttributes({role:'region',title:' '});}else if(CKEDITOR.env.webkit){j.setAttribute('title',t);j.setAttribute('name',t);}else if(CKEDITOR.env.ie){i=CKEDITOR.dom.element.createFromHtml('
'+''+CKEDITOR.tools.htmlEncode(t)+''+'
',CKEDITOR.document);j.appendTo(i);i.appendTo(h);}if(!CKEDITOR.env.ie)h.append(j);},q='',r=function(s){if(m)return;m=1;var t=s.document,u=t.body,v=t.getElementById('cke_actscrpt');v.parentNode.removeChild(v);delete CKEDITOR._['contentDomReady'+f.name];u.spellcheck=!f.config.disableNativeSpellChecker;if(CKEDITOR.env.ie){u.hideFocus=true;u.disabled=true;u.contentEditable=true;u.removeAttribute('disabled');}else t.designMode='on';try{t.execCommand('enableObjectResizing',false,!f.config.disableObjectResizing);}catch(B){}try{t.execCommand('enableInlineTableEditing',false,!f.config.disableNativeTableHandles);}catch(C){}s=f.window=new CKEDITOR.dom.window(s);t=f.document=new CKEDITOR.dom.document(t);var w=t.getBody().getFirst();if(CKEDITOR.env.gecko&&w&&w.is&&w.is('br')&&w.hasAttribute('_moz_editor_bogus_node')){var x=t.$.createEvent('KeyEvents');x.initKeyEvent('keypress',true,true,s.$,false,false,false,false,0,32);t.$.dispatchEvent(x);var y=t.getBody().getFirst();if(f.config.enterMode==CKEDITOR.ENTER_BR)t.createElement('br',{attributes:{_moz_dirty:''}}).replace(y);else y.remove();}if(!(CKEDITOR.env.ie||CKEDITOR.env.opera))t.on('mousedown',function(D){var E=D.data.getTarget(); -if(E.is('img','hr','input','textarea','select'))f.getSelection().selectElement(E);});if(CKEDITOR.env.webkit){t.on('click',function(D){if(D.data.getTarget().is('input','select'))D.data.preventDefault();});t.on('mouseup',function(D){if(D.data.getTarget().is('input','textarea'))D.data.preventDefault();});}var z=CKEDITOR.env.ie||CKEDITOR.env.safari?s:t;z.on('blur',function(){f.focusManager.blur();});z.on('focus',function(){f.focusManager.focus();});var A=f.keystrokeHandler;if(A)A.attach(t);if(f.contextMenu)f.contextMenu.addTarget(t);setTimeout(function(){f.fire('contentDom');if(n){f.mode='wysiwyg';f.fire('mode');n=false;}k=false;if(l){f.focus();l=false;}if(CKEDITOR.env.ie)setTimeout(function(){if(f.document){var D=f.document.$.body;D.runtimeStyle.marginBottom='0px';D.runtimeStyle.marginBottom='';}},1000);},0);};f.addMode('wysiwyg',{load:function(s,t,u){h=s;if(CKEDITOR.env.ie&&CKEDITOR.env.quirks)s.setStyle('position','relative');f.mayBeDirty=true;n=true;if(u)this.loadSnapshotData(t);else this.loadData(t);},loadData:function(s){k=true;if(f.dataProcessor)s=f.dataProcessor.toHtml(s,g);s=f.config.docType+''+''+''+''+''+''+s+''+''+q;window['_cke_htmlToLoad_'+f.name]=s;CKEDITOR._['contentDomReady'+f.name]=r;p();if(CKEDITOR.env.opera){var t=j.$.contentWindow.document;t.open();t.write(s);t.close();}},getData:function(){var s=j.getFrameDocument().getBody().getHtml();if(f.dataProcessor)s=f.dataProcessor.toDataFormat(s,g);if(f.config.ignoreEmptyParagraph)s=s.replace(b,'');return s;},getSnapshotData:function(){return j.getFrameDocument().getBody().getHtml();},loadSnapshotData:function(s){j.getFrameDocument().getBody().setHtml(s);},unload:function(s){f.window=f.document=j=h=l=null;f.fire('contentDomUnload');},focus:function(){if(k)l=true;else if(f.window){f.window.focus();f.selectionChange();}}});f.on('insertHtml',c,null,null,20);f.on('insertElement',d,null,null,20);f.on('selectionChange',e,null,null,1);});}});})();CKEDITOR.config.disableObjectResizing=false;CKEDITOR.config.disableNativeTableHandles=true;CKEDITOR.config.disableNativeSpellChecker=true;CKEDITOR.config.ignoreEmptyParagraph=true; +(function(){var a={table:1,pre:1},b=/\s*<(p|div|address|h\d|center)[^>]*>\s*(?:]*>| | )\s*(:?<\/\1>)?\s*$/gi;function c(g){var l=this;if(l.mode=='wysiwyg'){l.focus();var h=l.getSelection(),i=g.data;if(l.dataProcessor)i=l.dataProcessor.toHtml(i);if(CKEDITOR.env.ie){var j=h.isLocked;if(j)h.unlock();var k=h.getNative();if(k.type=='Control')k.clear();k.createRange().pasteHTML(i);if(j)l.getSelection().lock();}else l.document.$.execCommand('inserthtml',false,i);}};function d(g){if(this.mode=='wysiwyg'){this.focus();this.fire('saveSnapshot');var h=g.data,i=h.getName(),j=CKEDITOR.dtd.$block[i],k=this.getSelection(),l=k.getRanges(),m=k.isLocked;if(m)k.unlock();var n,o,p,q;for(var r=l.length-1;r>=0;r--){n=l[r];n.deleteContents();o=!r&&h||h.clone(true);var s,t;if(j)while((s=n.getCommonAncestor(false,true))&&((t=CKEDITOR.dtd[s.getName()])&&(!(t&&t[i]))))if(n.checkStartOfBlock()&&n.checkEndOfBlock()){n.setStartBefore(s);n.collapse(true);s.remove();}else n.splitBlock();n.insertNode(o);if(!p)p=o;}n.moveToPosition(p,CKEDITOR.POSITION_AFTER_END);var u=p.getNextSourceNode(true);if(u&&u.type==CKEDITOR.NODE_ELEMENT)n.moveToElementEditStart(u);k.selectRanges([n]);if(m)this.getSelection().lock();CKEDITOR.tools.setTimeout(function(){this.fire('saveSnapshot');},0,this);}};function e(g){if(!g.checkDirty())setTimeout(function(){g.resetDirty();});};function f(g){var h=g.editor,i=g.data.path,j=i.blockLimit,k=g.data.selection,l=k.getRanges()[0],m=h.document.getBody(),n=h.config.enterMode;if(n!=CKEDITOR.ENTER_BR&&l.collapsed&&j.getName()=='body'&&!i.block){e(h);var o=k.createBookmarks(),p=l.fixBlock(true,h.config.enterMode==CKEDITOR.ENTER_DIV?'div':'p');if(CKEDITOR.env.ie){var q=p.getElementsByTag('br'),r;for(var s=0;s':'br');m.append(B);}};CKEDITOR.plugins.add('wysiwygarea',{requires:['editingblock'],init:function(g){var h=g.config.enterMode!=CKEDITOR.ENTER_BR?g.config.enterMode==CKEDITOR.ENTER_DIV?'div':'p':false; +g.on('editingBlockReady',function(){var i,j,k,l,m,n,o,p=CKEDITOR.env.isCustomDomain(),q=function(){if(k)k.remove();if(j)j.remove();n=0;var t='void( '+(CKEDITOR.env.gecko?'setTimeout':'')+'( function(){'+'document.open();'+(CKEDITOR.env.ie&&p?'document.domain="'+document.domain+'";':'')+'document.write( window.parent[ "_cke_htmlToLoad_'+g.name+'" ] );'+'document.close();'+'window.parent[ "_cke_htmlToLoad_'+g.name+'" ] = null;'+'}'+(CKEDITOR.env.gecko?', 0 )':')()')+' )';if(CKEDITOR.env.opera)t='void(0);';k=CKEDITOR.dom.element.createFromHtml('');var u=g.lang.editorTitle.replace('%1',g.name);if(CKEDITOR.env.gecko){k.on('load',function(v){v.removeListener();s(k.$.contentWindow);});i.setAttributes({role:'region',title:u});k.setAttributes({role:'region',title:' '});}else if(CKEDITOR.env.webkit){k.setAttribute('title',u);k.setAttribute('name',u);}else if(CKEDITOR.env.ie){j=CKEDITOR.dom.element.createFromHtml('
'+''+CKEDITOR.tools.htmlEncode(u)+''+'
',CKEDITOR.document);k.appendTo(j);j.appendTo(i);}if(!CKEDITOR.env.ie)i.append(k);},r='',s=function(t){if(n)return;n=1;var u=t.document,v=u.body,w=u.getElementById('cke_actscrpt');w.parentNode.removeChild(w);delete CKEDITOR._['contentDomReady'+g.name];v.spellcheck=!g.config.disableNativeSpellChecker;if(CKEDITOR.env.ie){v.hideFocus=true;v.disabled=true;v.contentEditable=true;v.removeAttribute('disabled');}else u.designMode='on';try{u.execCommand('enableObjectResizing',false,!g.config.disableObjectResizing);}catch(z){}try{u.execCommand('enableInlineTableEditing',false,!g.config.disableNativeTableHandles);}catch(A){}t=g.window=new CKEDITOR.dom.window(t);u=g.document=new CKEDITOR.dom.document(u);if(!(CKEDITOR.env.ie||CKEDITOR.env.opera))u.on('mousedown',function(B){var C=B.data.getTarget();if(C.is('img','hr','input','textarea','select'))g.getSelection().selectElement(C);});if(CKEDITOR.env.webkit){u.on('click',function(B){if(B.data.getTarget().is('input','select'))B.data.preventDefault(); +});u.on('mouseup',function(B){if(B.data.getTarget().is('input','textarea'))B.data.preventDefault();});}var x=CKEDITOR.env.ie||CKEDITOR.env.webkit?t:u;x.on('blur',function(){g.focusManager.blur();});x.on('focus',function(){if(CKEDITOR.env.gecko){var B=v;while(B.firstChild)B=B.firstChild;if(!B.nextSibling&&'BR'==B.tagName&&B.hasAttribute('_moz_editor_bogus_node')){var C=u.$.createEvent('KeyEvents');C.initKeyEvent('keypress',true,true,t.$,false,false,false,false,0,32);u.$.dispatchEvent(C);var D=u.getBody().getFirst();if(g.config.enterMode==CKEDITOR.ENTER_BR)u.createElement('br',{attributes:{_moz_dirty:''}}).replace(D);else D.remove();}}g.focusManager.focus();});var y=g.keystrokeHandler;if(y)y.attach(u);if(CKEDITOR.env.ie)g.on('key',function(B){var C=B.data.keyCode==8&&g.getSelection().getSelectedElement();if(C){g.fire('saveSnapshot');C.remove();g.fire('saveSnapshot');B.cancel();}});if(g.contextMenu)g.contextMenu.addTarget(u);setTimeout(function(){g.fire('contentDom');if(o){g.mode='wysiwyg';g.fire('mode');o=false;}l=false;if(m){g.focus();m=false;}setTimeout(function(){g.fire('dataReady');},0);if(CKEDITOR.env.ie)setTimeout(function(){if(g.document){var B=g.document.$.body;B.runtimeStyle.marginBottom='0px';B.runtimeStyle.marginBottom='';}},1000);},0);};g.addMode('wysiwyg',{load:function(t,u,v){i=t;if(CKEDITOR.env.ie&&CKEDITOR.env.quirks)t.setStyle('position','relative');g.mayBeDirty=true;o=true;if(v)this.loadSnapshotData(u);else this.loadData(u);},loadData:function(t){l=true;if(g.dataProcessor)t=g.dataProcessor.toHtml(t,h);t=g.config.docType+''+''+''+''+''+''+t+''+''+r;window['_cke_htmlToLoad_'+g.name]=t;CKEDITOR._['contentDomReady'+g.name]=s;q();if(CKEDITOR.env.opera){var u=k.$.contentWindow.document;u.open();u.write(t);u.close();}},getData:function(){var t=k.getFrameDocument().getBody().getHtml();if(g.dataProcessor)t=g.dataProcessor.toDataFormat(t,h);if(g.config.ignoreEmptyParagraph)t=t.replace(b,'');return t;},getSnapshotData:function(){return k.getFrameDocument().getBody().getHtml();},loadSnapshotData:function(t){k.getFrameDocument().getBody().setHtml(t);},unload:function(t){g.window=g.document=k=i=m=null;g.fire('contentDomUnload');},focus:function(){if(l)m=true;else if(g.window){g.window.focus(); +g.selectionChange();}}});g.on('insertHtml',c,null,null,20);g.on('insertElement',d,null,null,20);g.on('selectionChange',f,null,null,1);});}});})();CKEDITOR.config.disableObjectResizing=false;CKEDITOR.config.disableNativeTableHandles=true;CKEDITOR.config.disableNativeSpellChecker=true;CKEDITOR.config.ignoreEmptyParagraph=true;