update tinymce to 3.5.0.1
This commit is contained in:
parent
205c09e4f0
commit
e39014a3a7
26 changed files with 5794 additions and 4903 deletions
|
|
@ -1 +1 @@
|
|||
(function(){tinymce.create("tinymce.plugins.AutolinkPlugin",{init:function(a,b){var c=this;if(tinyMCE.isIE){return}a.onKeyDown.add(function(d,f){if(f.keyCode==13){return c.handleEnter(d)}});a.onKeyPress.add(function(d,f){if(f.which==41){return c.handleEclipse(d)}});a.onKeyUp.add(function(d,f){if(f.keyCode==32){return c.handleSpacebar(d)}})},handleEclipse:function(a){this.parseCurrentLine(a,-1,"(",true)},handleSpacebar:function(a){this.parseCurrentLine(a,0,"",true)},handleEnter:function(a){this.parseCurrentLine(a,-1,"",false)},parseCurrentLine:function(i,d,b,g){var a,f,c,n,k,m,h,e,j;a=i.selection.getRng().cloneRange();if(a.startOffset<5){e=a.endContainer.previousSibling;if(e==null){if(a.endContainer.firstChild==null||a.endContainer.firstChild.nextSibling==null){return}e=a.endContainer.firstChild.nextSibling}j=e.length;a.setStart(e,j);a.setEnd(e,j);if(a.endOffset<5){return}f=a.endOffset;n=e}else{n=a.endContainer;if(n.nodeType!=3&&n.firstChild){while(n.nodeType!=3&&n.firstChild){n=n.firstChild}a.setStart(n,0);a.setEnd(n,n.nodeValue.length)}if(a.endOffset==1){f=2}else{f=a.endOffset-1-d}}c=f;do{a.setStart(n,f-2);a.setEnd(n,f-1);f-=1}while(a.toString()!=" "&&a.toString()!=""&&a.toString().charCodeAt(0)!=160&&(f-2)>=0&&a.toString()!=b);if(a.toString()==b||a.toString().charCodeAt(0)==160){a.setStart(n,f);a.setEnd(n,c);f+=1}else{if(a.startOffset==0){a.setStart(n,0);a.setEnd(n,c)}else{a.setStart(n,f);a.setEnd(n,c)}}m=a.toString();h=m.match(/^(https?:\/\/|ssh:\/\/|ftp:\/\/|file:\/|www\.|[A-Z0-9._%+-]+@)(.+)$/i);if(h){if(h[1]=="www."){h[1]="http://www."}else{if(/@$/.test(h[1])){h[1]="mailto:"+h[1]}}k=i.selection.getBookmark();i.selection.setRng(a);tinyMCE.execCommand("createlink",false,h[1]+h[2]);i.selection.moveToBookmark(k);if(tinyMCE.isWebKit){i.selection.collapse(false);var l=Math.min(n.length,c+1);a.setStart(n,l);a.setEnd(n,l);i.selection.setRng(a)}}},getInfo:function(){return{longname:"Autolink",author:"Moxiecode Systems AB",authorurl:"http://tinymce.moxiecode.com",infourl:"http://wiki.moxiecode.com/index.php/TinyMCE:Plugins/autolink",version:tinymce.majorVersion+"."+tinymce.minorVersion}}});tinymce.PluginManager.add("autolink",tinymce.plugins.AutolinkPlugin)})();
|
||||
(function(){tinymce.create("tinymce.plugins.AutolinkPlugin",{init:function(a,b){var c=this;a.onKeyDown.addToTop(function(d,f){if(f.keyCode==13){return c.handleEnter(d)}});if(tinyMCE.isIE){return}a.onKeyPress.add(function(d,f){if(f.which==41){return c.handleEclipse(d)}});a.onKeyUp.add(function(d,f){if(f.keyCode==32){return c.handleSpacebar(d)}})},handleEclipse:function(a){this.parseCurrentLine(a,-1,"(",true)},handleSpacebar:function(a){this.parseCurrentLine(a,0,"",true)},handleEnter:function(a){this.parseCurrentLine(a,-1,"",false)},parseCurrentLine:function(i,d,b,g){var a,f,c,n,k,m,h,e,j;a=i.selection.getRng(true).cloneRange();if(a.startOffset<5){e=a.endContainer.previousSibling;if(e==null){if(a.endContainer.firstChild==null||a.endContainer.firstChild.nextSibling==null){return}e=a.endContainer.firstChild.nextSibling}j=e.length;a.setStart(e,j);a.setEnd(e,j);if(a.endOffset<5){return}f=a.endOffset;n=e}else{n=a.endContainer;if(n.nodeType!=3&&n.firstChild){while(n.nodeType!=3&&n.firstChild){n=n.firstChild}a.setStart(n,0);a.setEnd(n,n.nodeValue.length)}if(a.endOffset==1){f=2}else{f=a.endOffset-1-d}}c=f;do{a.setStart(n,f-2);a.setEnd(n,f-1);f-=1}while(a.toString()!=" "&&a.toString()!=""&&a.toString().charCodeAt(0)!=160&&(f-2)>=0&&a.toString()!=b);if(a.toString()==b||a.toString().charCodeAt(0)==160){a.setStart(n,f);a.setEnd(n,c);f+=1}else{if(a.startOffset==0){a.setStart(n,0);a.setEnd(n,c)}else{a.setStart(n,f);a.setEnd(n,c)}}var m=a.toString();if(m.charAt(m.length-1)=="."){a.setEnd(n,c-1)}m=a.toString();h=m.match(/^(https?:\/\/|ssh:\/\/|ftp:\/\/|file:\/|www\.|[A-Z0-9._%+-]+@)(.+)$/i);if(h){if(h[1]=="www."){h[1]="http://www."}else{if(/@$/.test(h[1])){h[1]="mailto:"+h[1]}}k=i.selection.getBookmark();i.selection.setRng(a);tinyMCE.execCommand("createlink",false,h[1]+h[2]);i.selection.moveToBookmark(k);if(tinyMCE.isWebKit){i.selection.collapse(false);var l=Math.min(n.length,c+1);a.setStart(n,l);a.setEnd(n,l);i.selection.setRng(a)}}},getInfo:function(){return{longname:"Autolink",author:"Moxiecode Systems AB",authorurl:"http://tinymce.moxiecode.com",infourl:"http://wiki.moxiecode.com/index.php/TinyMCE:Plugins/autolink",version:tinymce.majorVersion+"."+tinymce.minorVersion}}});tinymce.PluginManager.add("autolink",tinymce.plugins.AutolinkPlugin)})();
|
||||
|
|
@ -1,174 +1,180 @@
|
|||
/**
|
||||
* editor_plugin_src.js
|
||||
*
|
||||
* Copyright 2011, Moxiecode Systems AB
|
||||
* Released under LGPL License.
|
||||
*
|
||||
* License: http://tinymce.moxiecode.com/license
|
||||
* Contributing: http://tinymce.moxiecode.com/contributing
|
||||
*/
|
||||
|
||||
(function() {
|
||||
tinymce.create('tinymce.plugins.AutolinkPlugin', {
|
||||
/**
|
||||
* Initializes the plugin, this will be executed after the plugin has been created.
|
||||
* This call is done before the editor instance has finished it's initialization so use the onInit event
|
||||
* of the editor instance to intercept that event.
|
||||
*
|
||||
* @param {tinymce.Editor} ed Editor instance that the plugin is initialized in.
|
||||
* @param {string} url Absolute URL to where the plugin is located.
|
||||
*/
|
||||
|
||||
init : function(ed, url) {
|
||||
var t = this;
|
||||
|
||||
// Internet Explorer has built-in automatic linking
|
||||
if (tinyMCE.isIE)
|
||||
return;
|
||||
|
||||
// Add a key down handler
|
||||
ed.onKeyDown.add(function(ed, e) {
|
||||
if (e.keyCode == 13)
|
||||
return t.handleEnter(ed);
|
||||
});
|
||||
|
||||
ed.onKeyPress.add(function(ed, e) {
|
||||
if (e.which == 41)
|
||||
return t.handleEclipse(ed);
|
||||
});
|
||||
|
||||
// Add a key up handler
|
||||
ed.onKeyUp.add(function(ed, e) {
|
||||
if (e.keyCode == 32)
|
||||
return t.handleSpacebar(ed);
|
||||
});
|
||||
},
|
||||
|
||||
handleEclipse : function(ed) {
|
||||
this.parseCurrentLine(ed, -1, '(', true);
|
||||
},
|
||||
|
||||
handleSpacebar : function(ed) {
|
||||
this.parseCurrentLine(ed, 0, '', true);
|
||||
},
|
||||
|
||||
handleEnter : function(ed) {
|
||||
this.parseCurrentLine(ed, -1, '', false);
|
||||
},
|
||||
|
||||
parseCurrentLine : function(ed, end_offset, delimiter, goback) {
|
||||
var r, end, start, endContainer, bookmark, text, matches, prev, len;
|
||||
|
||||
// We need at least five characters to form a URL,
|
||||
// hence, at minimum, five characters from the beginning of the line.
|
||||
r = ed.selection.getRng().cloneRange();
|
||||
if (r.startOffset < 5) {
|
||||
// During testing, the caret is placed inbetween two text nodes.
|
||||
// The previous text node contains the URL.
|
||||
prev = r.endContainer.previousSibling;
|
||||
if (prev == null) {
|
||||
if (r.endContainer.firstChild == null || r.endContainer.firstChild.nextSibling == null)
|
||||
return;
|
||||
|
||||
prev = r.endContainer.firstChild.nextSibling;
|
||||
}
|
||||
len = prev.length;
|
||||
r.setStart(prev, len);
|
||||
r.setEnd(prev, len);
|
||||
|
||||
if (r.endOffset < 5)
|
||||
return;
|
||||
|
||||
end = r.endOffset;
|
||||
endContainer = prev;
|
||||
} else {
|
||||
endContainer = r.endContainer;
|
||||
|
||||
// Get a text node
|
||||
if (endContainer.nodeType != 3 && endContainer.firstChild) {
|
||||
while (endContainer.nodeType != 3 && endContainer.firstChild)
|
||||
endContainer = endContainer.firstChild;
|
||||
|
||||
r.setStart(endContainer, 0);
|
||||
r.setEnd(endContainer, endContainer.nodeValue.length);
|
||||
}
|
||||
|
||||
if (r.endOffset == 1)
|
||||
end = 2;
|
||||
else
|
||||
end = r.endOffset - 1 - end_offset;
|
||||
}
|
||||
|
||||
start = end;
|
||||
|
||||
do
|
||||
{
|
||||
// Move the selection one character backwards.
|
||||
r.setStart(endContainer, end - 2);
|
||||
r.setEnd(endContainer, end - 1);
|
||||
end -= 1;
|
||||
|
||||
// Loop until one of the following is found: a blank space, , delimeter, (end-2) >= 0
|
||||
} while (r.toString() != ' ' && r.toString() != '' && r.toString().charCodeAt(0) != 160 && (end -2) >= 0 && r.toString() != delimiter);
|
||||
|
||||
if (r.toString() == delimiter || r.toString().charCodeAt(0) == 160) {
|
||||
r.setStart(endContainer, end);
|
||||
r.setEnd(endContainer, start);
|
||||
end += 1;
|
||||
} else if (r.startOffset == 0) {
|
||||
r.setStart(endContainer, 0);
|
||||
r.setEnd(endContainer, start);
|
||||
}
|
||||
else {
|
||||
r.setStart(endContainer, end);
|
||||
r.setEnd(endContainer, start);
|
||||
}
|
||||
|
||||
text = r.toString();
|
||||
matches = text.match(/^(https?:\/\/|ssh:\/\/|ftp:\/\/|file:\/|www\.|[A-Z0-9._%+-]+@)(.+)$/i);
|
||||
|
||||
if (matches) {
|
||||
if (matches[1] == 'www.') {
|
||||
matches[1] = 'http://www.';
|
||||
} else if (/@$/.test(matches[1])) {
|
||||
matches[1] = 'mailto:' + matches[1];
|
||||
}
|
||||
|
||||
bookmark = ed.selection.getBookmark();
|
||||
|
||||
ed.selection.setRng(r);
|
||||
tinyMCE.execCommand('createlink',false, matches[1] + matches[2]);
|
||||
ed.selection.moveToBookmark(bookmark);
|
||||
|
||||
// TODO: Determine if this is still needed.
|
||||
if (tinyMCE.isWebKit) {
|
||||
// move the caret to its original position
|
||||
ed.selection.collapse(false);
|
||||
var max = Math.min(endContainer.length, start + 1);
|
||||
r.setStart(endContainer, max);
|
||||
r.setEnd(endContainer, max);
|
||||
ed.selection.setRng(r);
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Returns information about the plugin as a name/value array.
|
||||
* The current keys are longname, author, authorurl, infourl and version.
|
||||
*
|
||||
* @return {Object} Name/value array containing information about the plugin.
|
||||
*/
|
||||
getInfo : function() {
|
||||
return {
|
||||
longname : 'Autolink',
|
||||
author : 'Moxiecode Systems AB',
|
||||
authorurl : 'http://tinymce.moxiecode.com',
|
||||
infourl : 'http://wiki.moxiecode.com/index.php/TinyMCE:Plugins/autolink',
|
||||
version : tinymce.majorVersion + "." + tinymce.minorVersion
|
||||
};
|
||||
}
|
||||
});
|
||||
|
||||
// Register plugin
|
||||
tinymce.PluginManager.add('autolink', tinymce.plugins.AutolinkPlugin);
|
||||
})();
|
||||
/**
|
||||
* editor_plugin_src.js
|
||||
*
|
||||
* Copyright 2011, Moxiecode Systems AB
|
||||
* Released under LGPL License.
|
||||
*
|
||||
* License: http://tinymce.moxiecode.com/license
|
||||
* Contributing: http://tinymce.moxiecode.com/contributing
|
||||
*/
|
||||
|
||||
(function() {
|
||||
tinymce.create('tinymce.plugins.AutolinkPlugin', {
|
||||
/**
|
||||
* Initializes the plugin, this will be executed after the plugin has been created.
|
||||
* This call is done before the editor instance has finished it's initialization so use the onInit event
|
||||
* of the editor instance to intercept that event.
|
||||
*
|
||||
* @param {tinymce.Editor} ed Editor instance that the plugin is initialized in.
|
||||
* @param {string} url Absolute URL to where the plugin is located.
|
||||
*/
|
||||
|
||||
init : function(ed, url) {
|
||||
var t = this;
|
||||
|
||||
// Add a key down handler
|
||||
ed.onKeyDown.addToTop(function(ed, e) {
|
||||
if (e.keyCode == 13)
|
||||
return t.handleEnter(ed);
|
||||
});
|
||||
|
||||
// Internet Explorer has built-in automatic linking for most cases
|
||||
if (tinyMCE.isIE)
|
||||
return;
|
||||
|
||||
ed.onKeyPress.add(function(ed, e) {
|
||||
if (e.which == 41)
|
||||
return t.handleEclipse(ed);
|
||||
});
|
||||
|
||||
// Add a key up handler
|
||||
ed.onKeyUp.add(function(ed, e) {
|
||||
if (e.keyCode == 32)
|
||||
return t.handleSpacebar(ed);
|
||||
});
|
||||
},
|
||||
|
||||
handleEclipse : function(ed) {
|
||||
this.parseCurrentLine(ed, -1, '(', true);
|
||||
},
|
||||
|
||||
handleSpacebar : function(ed) {
|
||||
this.parseCurrentLine(ed, 0, '', true);
|
||||
},
|
||||
|
||||
handleEnter : function(ed) {
|
||||
this.parseCurrentLine(ed, -1, '', false);
|
||||
},
|
||||
|
||||
parseCurrentLine : function(ed, end_offset, delimiter, goback) {
|
||||
var r, end, start, endContainer, bookmark, text, matches, prev, len;
|
||||
|
||||
// We need at least five characters to form a URL,
|
||||
// hence, at minimum, five characters from the beginning of the line.
|
||||
r = ed.selection.getRng(true).cloneRange();
|
||||
if (r.startOffset < 5) {
|
||||
// During testing, the caret is placed inbetween two text nodes.
|
||||
// The previous text node contains the URL.
|
||||
prev = r.endContainer.previousSibling;
|
||||
if (prev == null) {
|
||||
if (r.endContainer.firstChild == null || r.endContainer.firstChild.nextSibling == null)
|
||||
return;
|
||||
|
||||
prev = r.endContainer.firstChild.nextSibling;
|
||||
}
|
||||
len = prev.length;
|
||||
r.setStart(prev, len);
|
||||
r.setEnd(prev, len);
|
||||
|
||||
if (r.endOffset < 5)
|
||||
return;
|
||||
|
||||
end = r.endOffset;
|
||||
endContainer = prev;
|
||||
} else {
|
||||
endContainer = r.endContainer;
|
||||
|
||||
// Get a text node
|
||||
if (endContainer.nodeType != 3 && endContainer.firstChild) {
|
||||
while (endContainer.nodeType != 3 && endContainer.firstChild)
|
||||
endContainer = endContainer.firstChild;
|
||||
|
||||
r.setStart(endContainer, 0);
|
||||
r.setEnd(endContainer, endContainer.nodeValue.length);
|
||||
}
|
||||
|
||||
if (r.endOffset == 1)
|
||||
end = 2;
|
||||
else
|
||||
end = r.endOffset - 1 - end_offset;
|
||||
}
|
||||
|
||||
start = end;
|
||||
|
||||
do
|
||||
{
|
||||
// Move the selection one character backwards.
|
||||
r.setStart(endContainer, end - 2);
|
||||
r.setEnd(endContainer, end - 1);
|
||||
end -= 1;
|
||||
|
||||
// Loop until one of the following is found: a blank space, , delimeter, (end-2) >= 0
|
||||
} while (r.toString() != ' ' && r.toString() != '' && r.toString().charCodeAt(0) != 160 && (end -2) >= 0 && r.toString() != delimiter);
|
||||
|
||||
if (r.toString() == delimiter || r.toString().charCodeAt(0) == 160) {
|
||||
r.setStart(endContainer, end);
|
||||
r.setEnd(endContainer, start);
|
||||
end += 1;
|
||||
} else if (r.startOffset == 0) {
|
||||
r.setStart(endContainer, 0);
|
||||
r.setEnd(endContainer, start);
|
||||
}
|
||||
else {
|
||||
r.setStart(endContainer, end);
|
||||
r.setEnd(endContainer, start);
|
||||
}
|
||||
|
||||
// Exclude last . from word like "www.site.com."
|
||||
var text = r.toString();
|
||||
if (text.charAt(text.length - 1) == '.') {
|
||||
r.setEnd(endContainer, start - 1);
|
||||
}
|
||||
|
||||
text = r.toString();
|
||||
matches = text.match(/^(https?:\/\/|ssh:\/\/|ftp:\/\/|file:\/|www\.|[A-Z0-9._%+-]+@)(.+)$/i);
|
||||
|
||||
if (matches) {
|
||||
if (matches[1] == 'www.') {
|
||||
matches[1] = 'http://www.';
|
||||
} else if (/@$/.test(matches[1])) {
|
||||
matches[1] = 'mailto:' + matches[1];
|
||||
}
|
||||
|
||||
bookmark = ed.selection.getBookmark();
|
||||
|
||||
ed.selection.setRng(r);
|
||||
tinyMCE.execCommand('createlink',false, matches[1] + matches[2]);
|
||||
ed.selection.moveToBookmark(bookmark);
|
||||
|
||||
// TODO: Determine if this is still needed.
|
||||
if (tinyMCE.isWebKit) {
|
||||
// move the caret to its original position
|
||||
ed.selection.collapse(false);
|
||||
var max = Math.min(endContainer.length, start + 1);
|
||||
r.setStart(endContainer, max);
|
||||
r.setEnd(endContainer, max);
|
||||
ed.selection.setRng(r);
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Returns information about the plugin as a name/value array.
|
||||
* The current keys are longname, author, authorurl, infourl and version.
|
||||
*
|
||||
* @return {Object} Name/value array containing information about the plugin.
|
||||
*/
|
||||
getInfo : function() {
|
||||
return {
|
||||
longname : 'Autolink',
|
||||
author : 'Moxiecode Systems AB',
|
||||
authorurl : 'http://tinymce.moxiecode.com',
|
||||
infourl : 'http://wiki.moxiecode.com/index.php/TinyMCE:Plugins/autolink',
|
||||
version : tinymce.majorVersion + "." + tinymce.minorVersion
|
||||
};
|
||||
}
|
||||
});
|
||||
|
||||
// Register plugin
|
||||
tinymce.PluginManager.add('autolink', tinymce.plugins.AutolinkPlugin);
|
||||
})();
|
||||
|
|
|
|||
|
|
@ -1 +1 @@
|
|||
(function(){var a=tinymce.DOM;tinymce.create("tinymce.plugins.FullScreenPlugin",{init:function(d,e){var f=this,g={},c,b;f.editor=d;d.addCommand("mceFullScreen",function(){var i,j=a.doc.documentElement;if(d.getParam("fullscreen_is_enabled")){if(d.getParam("fullscreen_new_window")){closeFullscreen()}else{a.win.setTimeout(function(){tinymce.dom.Event.remove(a.win,"resize",f.resizeFunc);tinyMCE.get(d.getParam("fullscreen_editor_id")).setContent(d.getContent());tinyMCE.remove(d);a.remove("mce_fullscreen_container");j.style.overflow=d.getParam("fullscreen_html_overflow");a.setStyle(a.doc.body,"overflow",d.getParam("fullscreen_overflow"));a.win.scrollTo(d.getParam("fullscreen_scrollx"),d.getParam("fullscreen_scrolly"));tinyMCE.settings=tinyMCE.oldSettings},10)}return}if(d.getParam("fullscreen_new_window")){i=a.win.open(e+"/fullscreen.htm","mceFullScreenPopup","fullscreen=yes,menubar=no,toolbar=no,scrollbars=no,resizable=yes,left=0,top=0,width="+screen.availWidth+",height="+screen.availHeight);try{i.resizeTo(screen.availWidth,screen.availHeight)}catch(h){}}else{tinyMCE.oldSettings=tinyMCE.settings;g.fullscreen_overflow=a.getStyle(a.doc.body,"overflow",1)||"auto";g.fullscreen_html_overflow=a.getStyle(j,"overflow",1);c=a.getViewPort();g.fullscreen_scrollx=c.x;g.fullscreen_scrolly=c.y;if(tinymce.isOpera&&g.fullscreen_overflow=="visible"){g.fullscreen_overflow="auto"}if(tinymce.isIE&&g.fullscreen_overflow=="scroll"){g.fullscreen_overflow="auto"}if(tinymce.isIE&&(g.fullscreen_html_overflow=="visible"||g.fullscreen_html_overflow=="scroll")){g.fullscreen_html_overflow="auto"}if(g.fullscreen_overflow=="0px"){g.fullscreen_overflow=""}a.setStyle(a.doc.body,"overflow","hidden");j.style.overflow="hidden";c=a.getViewPort();a.win.scrollTo(0,0);if(tinymce.isIE){c.h-=1}if(tinymce.isIE6){b="absolute;top:"+c.y}else{b="fixed;top:0"}n=a.add(a.doc.body,"div",{id:"mce_fullscreen_container",style:"position:"+b+";left:0;width:"+c.w+"px;height:"+c.h+"px;z-index:200000;"});a.add(n,"div",{id:"mce_fullscreen"});tinymce.each(d.settings,function(k,l){g[l]=k});g.id="mce_fullscreen";g.width=n.clientWidth;g.height=n.clientHeight-15;g.fullscreen_is_enabled=true;g.fullscreen_editor_id=d.id;g.theme_advanced_resizing=false;g.save_onsavecallback=function(){d.setContent(tinyMCE.get(g.id).getContent());d.execCommand("mceSave")};tinymce.each(d.getParam("fullscreen_settings"),function(m,l){g[l]=m});if(g.theme_advanced_toolbar_location==="external"){g.theme_advanced_toolbar_location="top"}f.fullscreenEditor=new tinymce.Editor("mce_fullscreen",g);f.fullscreenEditor.onInit.add(function(){f.fullscreenEditor.setContent(d.getContent());f.fullscreenEditor.focus()});f.fullscreenEditor.render();f.fullscreenElement=new tinymce.dom.Element("mce_fullscreen_container");f.fullscreenElement.update();f.resizeFunc=tinymce.dom.Event.add(a.win,"resize",function(){var o=tinymce.DOM.getViewPort(),l=f.fullscreenEditor,k,m;k=l.dom.getSize(l.getContainer().firstChild);m=l.dom.getSize(l.getContainer().getElementsByTagName("iframe")[0]);l.theme.resizeTo(o.w-k.w+m.w,o.h-k.h+m.h)})}});d.addButton("fullscreen",{title:"fullscreen.desc",cmd:"mceFullScreen"});d.onNodeChange.add(function(i,h){h.setActive("fullscreen",i.getParam("fullscreen_is_enabled"))})},getInfo:function(){return{longname:"Fullscreen",author:"Moxiecode Systems AB",authorurl:"http://tinymce.moxiecode.com",infourl:"http://wiki.moxiecode.com/index.php/TinyMCE:Plugins/fullscreen",version:tinymce.majorVersion+"."+tinymce.minorVersion}}});tinymce.PluginManager.add("fullscreen",tinymce.plugins.FullScreenPlugin)})();
|
||||
(function(){var a=tinymce.DOM;tinymce.create("tinymce.plugins.FullScreenPlugin",{init:function(d,e){var f=this,g={},c,b;f.editor=d;d.addCommand("mceFullScreen",function(){var i,j=a.doc.documentElement;if(d.getParam("fullscreen_is_enabled")){if(d.getParam("fullscreen_new_window")){closeFullscreen()}else{a.win.setTimeout(function(){tinymce.dom.Event.remove(a.win,"resize",f.resizeFunc);tinyMCE.get(d.getParam("fullscreen_editor_id")).setContent(d.getContent());tinyMCE.remove(d);a.remove("mce_fullscreen_container");j.style.overflow=d.getParam("fullscreen_html_overflow");a.setStyle(a.doc.body,"overflow",d.getParam("fullscreen_overflow"));a.win.scrollTo(d.getParam("fullscreen_scrollx"),d.getParam("fullscreen_scrolly"));tinyMCE.settings=tinyMCE.oldSettings},10)}return}if(d.getParam("fullscreen_new_window")){i=a.win.open(e+"/fullscreen.htm","mceFullScreenPopup","fullscreen=yes,menubar=no,toolbar=no,scrollbars=no,resizable=yes,left=0,top=0,width="+screen.availWidth+",height="+screen.availHeight);try{i.resizeTo(screen.availWidth,screen.availHeight)}catch(h){}}else{tinyMCE.oldSettings=tinyMCE.settings;g.fullscreen_overflow=a.getStyle(a.doc.body,"overflow",1)||"auto";g.fullscreen_html_overflow=a.getStyle(j,"overflow",1);c=a.getViewPort();g.fullscreen_scrollx=c.x;g.fullscreen_scrolly=c.y;if(tinymce.isOpera&&g.fullscreen_overflow=="visible"){g.fullscreen_overflow="auto"}if(tinymce.isIE&&g.fullscreen_overflow=="scroll"){g.fullscreen_overflow="auto"}if(tinymce.isIE&&(g.fullscreen_html_overflow=="visible"||g.fullscreen_html_overflow=="scroll")){g.fullscreen_html_overflow="auto"}if(g.fullscreen_overflow=="0px"){g.fullscreen_overflow=""}a.setStyle(a.doc.body,"overflow","hidden");j.style.overflow="hidden";c=a.getViewPort();a.win.scrollTo(0,0);if(tinymce.isIE){c.h-=1}if(tinymce.isIE6||document.compatMode=="BackCompat"){b="absolute;top:"+c.y}else{b="fixed;top:0"}n=a.add(a.doc.body,"div",{id:"mce_fullscreen_container",style:"position:"+b+";left:0;width:"+c.w+"px;height:"+c.h+"px;z-index:200000;"});a.add(n,"div",{id:"mce_fullscreen"});tinymce.each(d.settings,function(k,l){g[l]=k});g.id="mce_fullscreen";g.width=n.clientWidth;g.height=n.clientHeight-15;g.fullscreen_is_enabled=true;g.fullscreen_editor_id=d.id;g.theme_advanced_resizing=false;g.save_onsavecallback=function(){d.setContent(tinyMCE.get(g.id).getContent());d.execCommand("mceSave")};tinymce.each(d.getParam("fullscreen_settings"),function(m,l){g[l]=m});if(g.theme_advanced_toolbar_location==="external"){g.theme_advanced_toolbar_location="top"}f.fullscreenEditor=new tinymce.Editor("mce_fullscreen",g);f.fullscreenEditor.onInit.add(function(){f.fullscreenEditor.setContent(d.getContent());f.fullscreenEditor.focus()});f.fullscreenEditor.render();f.fullscreenElement=new tinymce.dom.Element("mce_fullscreen_container");f.fullscreenElement.update();f.resizeFunc=tinymce.dom.Event.add(a.win,"resize",function(){var o=tinymce.DOM.getViewPort(),l=f.fullscreenEditor,k,m;k=l.dom.getSize(l.getContainer().firstChild);m=l.dom.getSize(l.getContainer().getElementsByTagName("iframe")[0]);l.theme.resizeTo(o.w-k.w+m.w,o.h-k.h+m.h)})}});d.addButton("fullscreen",{title:"fullscreen.desc",cmd:"mceFullScreen"});d.onNodeChange.add(function(i,h){h.setActive("fullscreen",i.getParam("fullscreen_is_enabled"))})},getInfo:function(){return{longname:"Fullscreen",author:"Moxiecode Systems AB",authorurl:"http://tinymce.moxiecode.com",infourl:"http://wiki.moxiecode.com/index.php/TinyMCE:Plugins/fullscreen",version:tinymce.majorVersion+"."+tinymce.minorVersion}}});tinymce.PluginManager.add("fullscreen",tinymce.plugins.FullScreenPlugin)})();
|
||||
|
|
@ -79,7 +79,7 @@
|
|||
vp.h -= 1;
|
||||
|
||||
// Use fixed position if it exists
|
||||
if (tinymce.isIE6)
|
||||
if (tinymce.isIE6 || document.compatMode == 'BackCompat')
|
||||
posCss = 'absolute;top:' + vp.y;
|
||||
else
|
||||
posCss = 'fixed;top:0';
|
||||
|
|
|
|||
|
|
@ -1,951 +1,951 @@
|
|||
/**
|
||||
* editor_plugin_src.js
|
||||
*
|
||||
* Copyright 2011, Moxiecode Systems AB
|
||||
* Released under LGPL License.
|
||||
*
|
||||
* License: http://tinymce.moxiecode.com/license
|
||||
* Contributing: http://tinymce.moxiecode.com/contributing
|
||||
*/
|
||||
|
||||
(function() {
|
||||
var each = tinymce.each, Event = tinymce.dom.Event, bookmark;
|
||||
|
||||
// Skips text nodes that only contain whitespace since they aren't semantically important.
|
||||
function skipWhitespaceNodes(e, next) {
|
||||
while (e && (e.nodeType === 8 || (e.nodeType === 3 && /^[ \t\n\r]*$/.test(e.nodeValue)))) {
|
||||
e = next(e);
|
||||
}
|
||||
return e;
|
||||
}
|
||||
|
||||
function skipWhitespaceNodesBackwards(e) {
|
||||
return skipWhitespaceNodes(e, function(e) {
|
||||
return e.previousSibling;
|
||||
});
|
||||
}
|
||||
|
||||
function skipWhitespaceNodesForwards(e) {
|
||||
return skipWhitespaceNodes(e, function(e) {
|
||||
return e.nextSibling;
|
||||
});
|
||||
}
|
||||
|
||||
function hasParentInList(ed, e, list) {
|
||||
return ed.dom.getParent(e, function(p) {
|
||||
return tinymce.inArray(list, p) !== -1;
|
||||
});
|
||||
}
|
||||
|
||||
function isList(e) {
|
||||
return e && (e.tagName === 'OL' || e.tagName === 'UL');
|
||||
}
|
||||
|
||||
function splitNestedLists(element, dom) {
|
||||
var tmp, nested, wrapItem;
|
||||
tmp = skipWhitespaceNodesBackwards(element.lastChild);
|
||||
while (isList(tmp)) {
|
||||
nested = tmp;
|
||||
tmp = skipWhitespaceNodesBackwards(nested.previousSibling);
|
||||
}
|
||||
if (nested) {
|
||||
wrapItem = dom.create('li', { style: 'list-style-type: none;'});
|
||||
dom.split(element, nested);
|
||||
dom.insertAfter(wrapItem, nested);
|
||||
wrapItem.appendChild(nested);
|
||||
wrapItem.appendChild(nested);
|
||||
element = wrapItem.previousSibling;
|
||||
}
|
||||
return element;
|
||||
}
|
||||
|
||||
function attemptMergeWithAdjacent(e, allowDifferentListStyles, mergeParagraphs) {
|
||||
e = attemptMergeWithPrevious(e, allowDifferentListStyles, mergeParagraphs);
|
||||
return attemptMergeWithNext(e, allowDifferentListStyles, mergeParagraphs);
|
||||
}
|
||||
|
||||
function attemptMergeWithPrevious(e, allowDifferentListStyles, mergeParagraphs) {
|
||||
var prev = skipWhitespaceNodesBackwards(e.previousSibling);
|
||||
if (prev) {
|
||||
return attemptMerge(prev, e, allowDifferentListStyles ? prev : false, mergeParagraphs);
|
||||
} else {
|
||||
return e;
|
||||
}
|
||||
}
|
||||
|
||||
function attemptMergeWithNext(e, allowDifferentListStyles, mergeParagraphs) {
|
||||
var next = skipWhitespaceNodesForwards(e.nextSibling);
|
||||
if (next) {
|
||||
return attemptMerge(e, next, allowDifferentListStyles ? next : false, mergeParagraphs);
|
||||
} else {
|
||||
return e;
|
||||
}
|
||||
}
|
||||
|
||||
function attemptMerge(e1, e2, differentStylesMasterElement, mergeParagraphs) {
|
||||
if (canMerge(e1, e2, !!differentStylesMasterElement, mergeParagraphs)) {
|
||||
return merge(e1, e2, differentStylesMasterElement);
|
||||
} else if (e1 && e1.tagName === 'LI' && isList(e2)) {
|
||||
// Fix invalidly nested lists.
|
||||
e1.appendChild(e2);
|
||||
}
|
||||
return e2;
|
||||
}
|
||||
|
||||
function canMerge(e1, e2, allowDifferentListStyles, mergeParagraphs) {
|
||||
if (!e1 || !e2) {
|
||||
return false;
|
||||
} else if (e1.tagName === 'LI' && e2.tagName === 'LI') {
|
||||
return e2.style.listStyleType === 'none' || containsOnlyAList(e2);
|
||||
} else if (isList(e1)) {
|
||||
return (e1.tagName === e2.tagName && (allowDifferentListStyles || e1.style.listStyleType === e2.style.listStyleType)) || isListForIndent(e2);
|
||||
} else return mergeParagraphs && e1.tagName === 'P' && e2.tagName === 'P';
|
||||
}
|
||||
|
||||
function isListForIndent(e) {
|
||||
var firstLI = skipWhitespaceNodesForwards(e.firstChild), lastLI = skipWhitespaceNodesBackwards(e.lastChild);
|
||||
return firstLI && lastLI && isList(e) && firstLI === lastLI && (isList(firstLI) || firstLI.style.listStyleType === 'none' || containsOnlyAList(firstLI));
|
||||
}
|
||||
|
||||
function containsOnlyAList(e) {
|
||||
var firstChild = skipWhitespaceNodesForwards(e.firstChild), lastChild = skipWhitespaceNodesBackwards(e.lastChild);
|
||||
return firstChild && lastChild && firstChild === lastChild && isList(firstChild);
|
||||
}
|
||||
|
||||
function merge(e1, e2, masterElement) {
|
||||
var lastOriginal = skipWhitespaceNodesBackwards(e1.lastChild), firstNew = skipWhitespaceNodesForwards(e2.firstChild);
|
||||
if (e1.tagName === 'P') {
|
||||
e1.appendChild(e1.ownerDocument.createElement('br'));
|
||||
}
|
||||
while (e2.firstChild) {
|
||||
e1.appendChild(e2.firstChild);
|
||||
}
|
||||
if (masterElement) {
|
||||
e1.style.listStyleType = masterElement.style.listStyleType;
|
||||
}
|
||||
e2.parentNode.removeChild(e2);
|
||||
attemptMerge(lastOriginal, firstNew, false);
|
||||
return e1;
|
||||
}
|
||||
|
||||
function findItemToOperateOn(e, dom) {
|
||||
var item;
|
||||
if (!dom.is(e, 'li,ol,ul')) {
|
||||
item = dom.getParent(e, 'li');
|
||||
if (item) {
|
||||
e = item;
|
||||
}
|
||||
}
|
||||
return e;
|
||||
}
|
||||
|
||||
tinymce.create('tinymce.plugins.Lists', {
|
||||
init: function(ed) {
|
||||
var LIST_TABBING = 'TABBING';
|
||||
var LIST_EMPTY_ITEM = 'EMPTY';
|
||||
var LIST_ESCAPE = 'ESCAPE';
|
||||
var LIST_PARAGRAPH = 'PARAGRAPH';
|
||||
var LIST_UNKNOWN = 'UNKNOWN';
|
||||
var state = LIST_UNKNOWN;
|
||||
|
||||
function isTabInList(e) {
|
||||
// Don't indent on Ctrl+Tab or Alt+Tab
|
||||
return e.keyCode === tinymce.VK.TAB && !(e.altKey || e.ctrlKey) &&
|
||||
(ed.queryCommandState('InsertUnorderedList') || ed.queryCommandState('InsertOrderedList'));
|
||||
}
|
||||
|
||||
function isOnLastListItem() {
|
||||
var li = getLi();
|
||||
var grandParent = li.parentNode.parentNode;
|
||||
var isLastItem = li.parentNode.lastChild === li;
|
||||
return isLastItem && !isNestedList(grandParent) && isEmptyListItem(li);
|
||||
}
|
||||
|
||||
function isNestedList(grandParent) {
|
||||
if (isList(grandParent)) {
|
||||
return grandParent.parentNode && grandParent.parentNode.tagName === 'LI';
|
||||
} else {
|
||||
return grandParent.tagName === 'LI';
|
||||
}
|
||||
}
|
||||
|
||||
function isInEmptyListItem() {
|
||||
return ed.selection.isCollapsed() && isEmptyListItem(getLi());
|
||||
}
|
||||
|
||||
function getLi() {
|
||||
var n = ed.selection.getStart();
|
||||
// Get start will return BR if the LI only contains a BR or an empty element as we use these to fix caret position
|
||||
return ((n.tagName == 'BR' || n.tagName == '') && n.parentNode.tagName == 'LI') ? n.parentNode : n;
|
||||
}
|
||||
|
||||
function isEmptyListItem(li) {
|
||||
var numChildren = li.childNodes.length;
|
||||
if (li.tagName === 'LI') {
|
||||
return numChildren == 0 ? true : numChildren == 1 && (li.firstChild.tagName == '' || li.firstChild.tagName == 'BR' || isEmptyIE9Li(li));
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
function isEmptyIE9Li(li) {
|
||||
// only consider this to be last item if there is no list item content or that content is nbsp or space since IE9 creates these
|
||||
var lis = tinymce.grep(li.parentNode.childNodes, function(n) {return n.tagName == 'LI'});
|
||||
var isLastLi = li == lis[lis.length - 1];
|
||||
var child = li.firstChild;
|
||||
return tinymce.isIE9 && isLastLi && (child.nodeValue == String.fromCharCode(160) || child.nodeValue == String.fromCharCode(32));
|
||||
}
|
||||
|
||||
function isEnter(e) {
|
||||
return e.keyCode === tinymce.VK.ENTER;
|
||||
}
|
||||
|
||||
function isEnterWithoutShift(e) {
|
||||
return isEnter(e) && !e.shiftKey;
|
||||
}
|
||||
|
||||
function getListKeyState(e) {
|
||||
if (isTabInList(e)) {
|
||||
return LIST_TABBING;
|
||||
} else if (isEnterWithoutShift(e) && isOnLastListItem()) {
|
||||
// Returns LIST_UNKNOWN since breaking out of lists is handled by the EnterKey.js logic now
|
||||
//return LIST_ESCAPE;
|
||||
return LIST_UNKNOWN;
|
||||
} else if (isEnterWithoutShift(e) && isInEmptyListItem()) {
|
||||
return LIST_EMPTY_ITEM;
|
||||
} else {
|
||||
return LIST_UNKNOWN;
|
||||
}
|
||||
}
|
||||
|
||||
function cancelDefaultEvents(ed, e) {
|
||||
// list escape is done manually using outdent as it does not create paragraphs correctly in td's
|
||||
if (state == LIST_TABBING || state == LIST_EMPTY_ITEM || tinymce.isGecko && state == LIST_ESCAPE) {
|
||||
Event.cancel(e);
|
||||
}
|
||||
}
|
||||
|
||||
function isCursorAtEndOfContainer() {
|
||||
var range = ed.selection.getRng(true);
|
||||
var startContainer = range.startContainer;
|
||||
if (startContainer.nodeType == 3) {
|
||||
var value = startContainer.nodeValue;
|
||||
if (tinymce.isIE9 && value.length > 1 && value.charCodeAt(value.length-1) == 32) {
|
||||
// IE9 places a space on the end of the text in some cases so ignore last char
|
||||
return (range.endOffset == value.length-1);
|
||||
} else {
|
||||
return (range.endOffset == value.length);
|
||||
}
|
||||
} else if (startContainer.nodeType == 1) {
|
||||
return range.endOffset == startContainer.childNodes.length;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/*
|
||||
If we are at the end of a list item surrounded with an element, pressing enter should create a
|
||||
new list item instead without splitting the element e.g. don't want to create new P or H1 tag
|
||||
*/
|
||||
function isEndOfListItem() {
|
||||
var node = ed.selection.getNode();
|
||||
var validElements = 'h1,h2,h3,h4,h5,h6,p,div';
|
||||
var isLastParagraphOfLi = ed.dom.is(node, validElements) && node.parentNode.tagName === 'LI' && node.parentNode.lastChild === node;
|
||||
return ed.selection.isCollapsed() && isLastParagraphOfLi && isCursorAtEndOfContainer();
|
||||
}
|
||||
|
||||
// Creates a new list item after the current selection's list item parent
|
||||
function createNewLi(ed, e) {
|
||||
if (isEnterWithoutShift(e) && isEndOfListItem()) {
|
||||
var node = ed.selection.getNode();
|
||||
var li = ed.dom.create("li");
|
||||
var parentLi = ed.dom.getParent(node, 'li');
|
||||
ed.dom.insertAfter(li, parentLi);
|
||||
|
||||
// Move caret to new list element.
|
||||
if (tinymce.isIE6 || tinymce.isIE7 || tinyMCE.isIE8) {
|
||||
// Removed this line since it would create an odd < > tag and placing the caret inside an empty LI is handled and should be handled by the selection logic
|
||||
//li.appendChild(ed.dom.create(" ")); // IE needs an element within the bullet point
|
||||
ed.selection.setCursorLocation(li, 1);
|
||||
} else {
|
||||
ed.selection.setCursorLocation(li, 0);
|
||||
}
|
||||
e.preventDefault();
|
||||
}
|
||||
}
|
||||
|
||||
function imageJoiningListItem(ed, e) {
|
||||
var prevSibling;
|
||||
|
||||
if (!tinymce.isGecko)
|
||||
return;
|
||||
|
||||
var n = ed.selection.getStart();
|
||||
if (e.keyCode != tinymce.VK.BACKSPACE || n.tagName !== 'IMG')
|
||||
return;
|
||||
|
||||
function lastLI(node) {
|
||||
var child = node.firstChild;
|
||||
var li = null;
|
||||
do {
|
||||
if (!child)
|
||||
break;
|
||||
|
||||
if (child.tagName === 'LI')
|
||||
li = child;
|
||||
} while (child = child.nextSibling);
|
||||
|
||||
return li;
|
||||
}
|
||||
|
||||
function addChildren(parentNode, destination) {
|
||||
while (parentNode.childNodes.length > 0)
|
||||
destination.appendChild(parentNode.childNodes[0]);
|
||||
}
|
||||
|
||||
// Check if there is a previous sibling
|
||||
prevSibling = n.parentNode.previousSibling;
|
||||
if (!prevSibling)
|
||||
return;
|
||||
|
||||
var ul;
|
||||
if (prevSibling.tagName === 'UL' || prevSibling.tagName === 'OL')
|
||||
ul = prevSibling;
|
||||
else if (prevSibling.previousSibling && (prevSibling.previousSibling.tagName === 'UL' || prevSibling.previousSibling.tagName === 'OL'))
|
||||
ul = prevSibling.previousSibling;
|
||||
else
|
||||
return;
|
||||
|
||||
var li = lastLI(ul);
|
||||
|
||||
// move the caret to the end of the list item
|
||||
var rng = ed.dom.createRng();
|
||||
rng.setStart(li, 1);
|
||||
rng.setEnd(li, 1);
|
||||
ed.selection.setRng(rng);
|
||||
ed.selection.collapse(true);
|
||||
|
||||
// save a bookmark at the end of the list item
|
||||
var bookmark = ed.selection.getBookmark();
|
||||
|
||||
// copy the image an its text to the list item
|
||||
var clone = n.parentNode.cloneNode(true);
|
||||
if (clone.tagName === 'P' || clone.tagName === 'DIV')
|
||||
addChildren(clone, li);
|
||||
else
|
||||
li.appendChild(clone);
|
||||
|
||||
// remove the old copy of the image
|
||||
n.parentNode.parentNode.removeChild(n.parentNode);
|
||||
|
||||
// move the caret where we saved the bookmark
|
||||
ed.selection.moveToBookmark(bookmark);
|
||||
}
|
||||
|
||||
// fix the cursor position to ensure it is correct in IE
|
||||
function setCursorPositionToOriginalLi(li) {
|
||||
var list = ed.dom.getParent(li, 'ol,ul');
|
||||
if (list != null) {
|
||||
var lastLi = list.lastChild;
|
||||
// Removed this line since IE9 would report an DOM character error and placing the caret inside an empty LI is handled and should be handled by the selection logic
|
||||
//lastLi.appendChild(ed.getDoc().createElement(''));
|
||||
ed.selection.setCursorLocation(lastLi, 0);
|
||||
}
|
||||
}
|
||||
|
||||
this.ed = ed;
|
||||
ed.addCommand('Indent', this.indent, this);
|
||||
ed.addCommand('Outdent', this.outdent, this);
|
||||
ed.addCommand('InsertUnorderedList', function() {
|
||||
this.applyList('UL', 'OL');
|
||||
}, this);
|
||||
ed.addCommand('InsertOrderedList', function() {
|
||||
this.applyList('OL', 'UL');
|
||||
}, this);
|
||||
|
||||
ed.onInit.add(function() {
|
||||
ed.editorCommands.addCommands({
|
||||
'outdent': function() {
|
||||
var sel = ed.selection, dom = ed.dom;
|
||||
|
||||
function hasStyleIndent(n) {
|
||||
n = dom.getParent(n, dom.isBlock);
|
||||
return n && (parseInt(ed.dom.getStyle(n, 'margin-left') || 0, 10) + parseInt(ed.dom.getStyle(n, 'padding-left') || 0, 10)) > 0;
|
||||
}
|
||||
|
||||
return hasStyleIndent(sel.getStart()) || hasStyleIndent(sel.getEnd()) || ed.queryCommandState('InsertOrderedList') || ed.queryCommandState('InsertUnorderedList');
|
||||
}
|
||||
}, 'state');
|
||||
});
|
||||
|
||||
ed.onKeyUp.add(function(ed, e) {
|
||||
if (state == LIST_TABBING) {
|
||||
ed.execCommand(e.shiftKey ? 'Outdent' : 'Indent', true, null);
|
||||
state = LIST_UNKNOWN;
|
||||
return Event.cancel(e);
|
||||
} else if (state == LIST_EMPTY_ITEM) {
|
||||
var li = getLi();
|
||||
var shouldOutdent = ed.settings.list_outdent_on_enter === true || e.shiftKey;
|
||||
ed.execCommand(shouldOutdent ? 'Outdent' : 'Indent', true, null);
|
||||
if (tinymce.isIE) {
|
||||
setCursorPositionToOriginalLi(li);
|
||||
}
|
||||
|
||||
return Event.cancel(e);
|
||||
} else if (state == LIST_ESCAPE) {
|
||||
if (tinymce.isIE6 || tinymce.isIE7 || tinymce.isIE8) {
|
||||
// append a zero sized nbsp so that caret is positioned correctly in IE after escaping and applying formatting.
|
||||
// if there is no text then applying formatting for e.g a H1 to the P tag immediately following list after
|
||||
// escaping from it will cause the caret to be positioned on the last li instead of staying the in P tag.
|
||||
var n = ed.getDoc().createTextNode('\uFEFF');
|
||||
ed.selection.getNode().appendChild(n);
|
||||
} else if (tinymce.isIE9 || tinymce.isGecko) {
|
||||
// IE9 does not escape the list so we use outdent to do this and cancel the default behaviour
|
||||
// Gecko does not create a paragraph outdenting inside a TD so default behaviour is cancelled and we outdent ourselves
|
||||
ed.execCommand('Outdent');
|
||||
return Event.cancel(e);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
function fixListItem(parent, reference) {
|
||||
// a zero-sized non-breaking space is placed in the empty list item so that the nested list is
|
||||
// displayed on the below line instead of next to it
|
||||
var n = ed.getDoc().createTextNode('\uFEFF');
|
||||
parent.insertBefore(n, reference);
|
||||
ed.selection.setCursorLocation(n, 0);
|
||||
// repaint to remove rendering artifact. only visible when creating new list
|
||||
ed.execCommand('mceRepaint');
|
||||
}
|
||||
|
||||
function fixIndentedListItemForGecko(ed, e) {
|
||||
if (isEnter(e)) {
|
||||
var li = getLi();
|
||||
if (li) {
|
||||
var parent = li.parentNode;
|
||||
var grandParent = parent && parent.parentNode;
|
||||
if (grandParent && grandParent.nodeName == 'LI' && grandParent.firstChild == parent && li == parent.firstChild) {
|
||||
fixListItem(grandParent, parent);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function fixIndentedListItemForIE8(ed, e) {
|
||||
if (isEnter(e)) {
|
||||
var li = getLi();
|
||||
if (ed.dom.select('ul li', li).length === 1) {
|
||||
var list = li.firstChild;
|
||||
fixListItem(li, list);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function fixDeletingFirstCharOfList(ed, e) {
|
||||
function listElements(list, li) {
|
||||
var elements = [];
|
||||
var walker = new tinymce.dom.TreeWalker(li, list);
|
||||
for (var node = walker.current(); node; node = walker.next()) {
|
||||
if (ed.dom.is(node, 'ol,ul,li')) {
|
||||
elements.push(node);
|
||||
}
|
||||
}
|
||||
return elements;
|
||||
}
|
||||
|
||||
if (e.keyCode == tinymce.VK.BACKSPACE) {
|
||||
var li = getLi();
|
||||
if (li) {
|
||||
var list = ed.dom.getParent(li, 'ol,ul');
|
||||
if (list && list.firstChild === li) {
|
||||
var elements = listElements(list, li);
|
||||
ed.execCommand("Outdent", false, elements);
|
||||
ed.undoManager.add();
|
||||
return Event.cancel(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function fixDeletingEmptyLiInWebkit(ed, e) {
|
||||
var li = getLi();
|
||||
if (e.keyCode === tinymce.VK.BACKSPACE && ed.dom.is(li, 'li') && li.parentNode.firstChild!==li) {
|
||||
if (ed.dom.select('ul,ol', li).length === 1) {
|
||||
var prevLi = li.previousSibling;
|
||||
ed.dom.remove(ed.dom.select('br', li));
|
||||
ed.dom.remove(li, true);
|
||||
var textNodes = tinymce.grep(prevLi.childNodes, function(n){ return n.nodeType === 3 });
|
||||
if (textNodes.length === 1) {
|
||||
var textNode = textNodes[0]
|
||||
ed.selection.setCursorLocation(textNode, textNode.length);
|
||||
}
|
||||
ed.undoManager.add();
|
||||
return Event.cancel(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ed.onKeyDown.add(function(_, e) { state = getListKeyState(e); });
|
||||
ed.onKeyDown.add(cancelDefaultEvents);
|
||||
ed.onKeyDown.add(imageJoiningListItem);
|
||||
ed.onKeyDown.add(createNewLi);
|
||||
|
||||
if (tinymce.isGecko) {
|
||||
ed.onKeyUp.add(fixIndentedListItemForGecko);
|
||||
}
|
||||
if (tinymce.isIE8) {
|
||||
ed.onKeyUp.add(fixIndentedListItemForIE8);
|
||||
}
|
||||
if (tinymce.isGecko || tinymce.isWebKit) {
|
||||
ed.onKeyDown.add(fixDeletingFirstCharOfList);
|
||||
}
|
||||
if (tinymce.isWebKit) {
|
||||
ed.onKeyDown.add(fixDeletingEmptyLiInWebkit);
|
||||
}
|
||||
},
|
||||
|
||||
applyList: function(targetListType, oppositeListType) {
|
||||
var t = this, ed = t.ed, dom = ed.dom, applied = [], hasSameType = false, hasOppositeType = false, hasNonList = false, actions,
|
||||
selectedBlocks = ed.selection.getSelectedBlocks();
|
||||
|
||||
function cleanupBr(e) {
|
||||
if (e && e.tagName === 'BR') {
|
||||
dom.remove(e);
|
||||
}
|
||||
}
|
||||
|
||||
function makeList(element) {
|
||||
var list = dom.create(targetListType), li;
|
||||
|
||||
function adjustIndentForNewList(element) {
|
||||
// If there's a margin-left, outdent one level to account for the extra list margin.
|
||||
if (element.style.marginLeft || element.style.paddingLeft) {
|
||||
t.adjustPaddingFunction(false)(element);
|
||||
}
|
||||
}
|
||||
|
||||
if (element.tagName === 'LI') {
|
||||
// No change required.
|
||||
} else if (element.tagName === 'P' || element.tagName === 'DIV' || element.tagName === 'BODY') {
|
||||
processBrs(element, function(startSection, br) {
|
||||
doWrapList(startSection, br, element.tagName === 'BODY' ? null : startSection.parentNode);
|
||||
li = startSection.parentNode;
|
||||
adjustIndentForNewList(li);
|
||||
cleanupBr(br);
|
||||
});
|
||||
if (li) {
|
||||
if (li.tagName === 'LI' && (element.tagName === 'P' || selectedBlocks.length > 1)) {
|
||||
dom.split(li.parentNode.parentNode, li.parentNode);
|
||||
}
|
||||
attemptMergeWithAdjacent(li.parentNode, true);
|
||||
}
|
||||
return;
|
||||
} else {
|
||||
// Put the list around the element.
|
||||
li = dom.create('li');
|
||||
dom.insertAfter(li, element);
|
||||
li.appendChild(element);
|
||||
adjustIndentForNewList(element);
|
||||
element = li;
|
||||
}
|
||||
dom.insertAfter(list, element);
|
||||
list.appendChild(element);
|
||||
attemptMergeWithAdjacent(list, true);
|
||||
applied.push(element);
|
||||
}
|
||||
|
||||
function doWrapList(start, end, template) {
|
||||
var li, n = start, tmp;
|
||||
while (!dom.isBlock(start.parentNode) && start.parentNode !== dom.getRoot()) {
|
||||
start = dom.split(start.parentNode, start.previousSibling);
|
||||
start = start.nextSibling;
|
||||
n = start;
|
||||
}
|
||||
if (template) {
|
||||
li = template.cloneNode(true);
|
||||
start.parentNode.insertBefore(li, start);
|
||||
while (li.firstChild) dom.remove(li.firstChild);
|
||||
li = dom.rename(li, 'li');
|
||||
} else {
|
||||
li = dom.create('li');
|
||||
start.parentNode.insertBefore(li, start);
|
||||
}
|
||||
while (n && n != end) {
|
||||
tmp = n.nextSibling;
|
||||
li.appendChild(n);
|
||||
n = tmp;
|
||||
}
|
||||
if (li.childNodes.length === 0) {
|
||||
li.innerHTML = '<br _mce_bogus="1" />';
|
||||
}
|
||||
makeList(li);
|
||||
}
|
||||
|
||||
function processBrs(element, callback) {
|
||||
var startSection, previousBR, END_TO_START = 3, START_TO_END = 1,
|
||||
breakElements = 'br,ul,ol,p,div,h1,h2,h3,h4,h5,h6,table,blockquote,address,pre,form,center,dl';
|
||||
|
||||
function isAnyPartSelected(start, end) {
|
||||
var r = dom.createRng(), sel;
|
||||
bookmark.keep = true;
|
||||
ed.selection.moveToBookmark(bookmark);
|
||||
bookmark.keep = false;
|
||||
sel = ed.selection.getRng(true);
|
||||
if (!end) {
|
||||
end = start.parentNode.lastChild;
|
||||
}
|
||||
r.setStartBefore(start);
|
||||
r.setEndAfter(end);
|
||||
return !(r.compareBoundaryPoints(END_TO_START, sel) > 0 || r.compareBoundaryPoints(START_TO_END, sel) <= 0);
|
||||
}
|
||||
|
||||
function nextLeaf(br) {
|
||||
if (br.nextSibling)
|
||||
return br.nextSibling;
|
||||
if (!dom.isBlock(br.parentNode) && br.parentNode !== dom.getRoot())
|
||||
return nextLeaf(br.parentNode);
|
||||
}
|
||||
|
||||
// Split on BRs within the range and process those.
|
||||
startSection = element.firstChild;
|
||||
// First mark the BRs that have any part of the previous section selected.
|
||||
var trailingContentSelected = false;
|
||||
each(dom.select(breakElements, element), function(br) {
|
||||
if (br.hasAttribute && br.hasAttribute('_mce_bogus')) {
|
||||
return true; // Skip the bogus Brs that are put in to appease Firefox and Safari.
|
||||
}
|
||||
if (isAnyPartSelected(startSection, br)) {
|
||||
dom.addClass(br, '_mce_tagged_br');
|
||||
startSection = nextLeaf(br);
|
||||
}
|
||||
});
|
||||
trailingContentSelected = (startSection && isAnyPartSelected(startSection, undefined));
|
||||
startSection = element.firstChild;
|
||||
each(dom.select(breakElements, element), function(br) {
|
||||
// Got a section from start to br.
|
||||
var tmp = nextLeaf(br);
|
||||
if (br.hasAttribute && br.hasAttribute('_mce_bogus')) {
|
||||
return true; // Skip the bogus Brs that are put in to appease Firefox and Safari.
|
||||
}
|
||||
if (dom.hasClass(br, '_mce_tagged_br')) {
|
||||
callback(startSection, br, previousBR);
|
||||
previousBR = null;
|
||||
} else {
|
||||
previousBR = br;
|
||||
}
|
||||
startSection = tmp;
|
||||
});
|
||||
if (trailingContentSelected) {
|
||||
callback(startSection, undefined, previousBR);
|
||||
}
|
||||
}
|
||||
|
||||
function wrapList(element) {
|
||||
processBrs(element, function(startSection, br, previousBR) {
|
||||
// Need to indent this part
|
||||
doWrapList(startSection, br);
|
||||
cleanupBr(br);
|
||||
cleanupBr(previousBR);
|
||||
});
|
||||
}
|
||||
|
||||
function changeList(element) {
|
||||
if (tinymce.inArray(applied, element) !== -1) {
|
||||
return;
|
||||
}
|
||||
if (element.parentNode.tagName === oppositeListType) {
|
||||
dom.split(element.parentNode, element);
|
||||
makeList(element);
|
||||
attemptMergeWithNext(element.parentNode, false);
|
||||
}
|
||||
applied.push(element);
|
||||
}
|
||||
|
||||
function convertListItemToParagraph(element) {
|
||||
var child, nextChild, mergedElement, splitLast;
|
||||
if (tinymce.inArray(applied, element) !== -1) {
|
||||
return;
|
||||
}
|
||||
element = splitNestedLists(element, dom);
|
||||
while (dom.is(element.parentNode, 'ol,ul,li')) {
|
||||
dom.split(element.parentNode, element);
|
||||
}
|
||||
// Push the original element we have from the selection, not the renamed one.
|
||||
applied.push(element);
|
||||
element = dom.rename(element, 'p');
|
||||
mergedElement = attemptMergeWithAdjacent(element, false, ed.settings.force_br_newlines);
|
||||
if (mergedElement === element) {
|
||||
// Now split out any block elements that can't be contained within a P.
|
||||
// Manually iterate to ensure we handle modifications correctly (doesn't work with tinymce.each)
|
||||
child = element.firstChild;
|
||||
while (child) {
|
||||
if (dom.isBlock(child)) {
|
||||
child = dom.split(child.parentNode, child);
|
||||
splitLast = true;
|
||||
nextChild = child.nextSibling && child.nextSibling.firstChild;
|
||||
} else {
|
||||
nextChild = child.nextSibling;
|
||||
if (splitLast && child.tagName === 'BR') {
|
||||
dom.remove(child);
|
||||
}
|
||||
splitLast = false;
|
||||
}
|
||||
child = nextChild;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
each(selectedBlocks, function(e) {
|
||||
e = findItemToOperateOn(e, dom);
|
||||
if (e.tagName === oppositeListType || (e.tagName === 'LI' && e.parentNode.tagName === oppositeListType)) {
|
||||
hasOppositeType = true;
|
||||
} else if (e.tagName === targetListType || (e.tagName === 'LI' && e.parentNode.tagName === targetListType)) {
|
||||
hasSameType = true;
|
||||
} else {
|
||||
hasNonList = true;
|
||||
}
|
||||
});
|
||||
|
||||
if (hasNonList &&!hasSameType || hasOppositeType || selectedBlocks.length === 0) {
|
||||
actions = {
|
||||
'LI': changeList,
|
||||
'H1': makeList,
|
||||
'H2': makeList,
|
||||
'H3': makeList,
|
||||
'H4': makeList,
|
||||
'H5': makeList,
|
||||
'H6': makeList,
|
||||
'P': makeList,
|
||||
'BODY': makeList,
|
||||
'DIV': selectedBlocks.length > 1 ? makeList : wrapList,
|
||||
defaultAction: wrapList,
|
||||
elements: this.selectedBlocks()
|
||||
};
|
||||
} else {
|
||||
actions = {
|
||||
defaultAction: convertListItemToParagraph,
|
||||
elements: this.selectedBlocks()
|
||||
};
|
||||
}
|
||||
this.process(actions);
|
||||
},
|
||||
|
||||
indent: function() {
|
||||
var ed = this.ed, dom = ed.dom, indented = [];
|
||||
|
||||
function createWrapItem(element) {
|
||||
var wrapItem = dom.create('li', { style: 'list-style-type: none;'});
|
||||
dom.insertAfter(wrapItem, element);
|
||||
return wrapItem;
|
||||
}
|
||||
|
||||
function createWrapList(element) {
|
||||
var wrapItem = createWrapItem(element),
|
||||
list = dom.getParent(element, 'ol,ul'),
|
||||
listType = list.tagName,
|
||||
listStyle = dom.getStyle(list, 'list-style-type'),
|
||||
attrs = {},
|
||||
wrapList;
|
||||
if (listStyle !== '') {
|
||||
attrs.style = 'list-style-type: ' + listStyle + ';';
|
||||
}
|
||||
wrapList = dom.create(listType, attrs);
|
||||
wrapItem.appendChild(wrapList);
|
||||
return wrapList;
|
||||
}
|
||||
|
||||
function indentLI(element) {
|
||||
if (!hasParentInList(ed, element, indented)) {
|
||||
element = splitNestedLists(element, dom);
|
||||
var wrapList = createWrapList(element);
|
||||
wrapList.appendChild(element);
|
||||
attemptMergeWithAdjacent(wrapList.parentNode, false);
|
||||
attemptMergeWithAdjacent(wrapList, false);
|
||||
indented.push(element);
|
||||
}
|
||||
}
|
||||
|
||||
this.process({
|
||||
'LI': indentLI,
|
||||
defaultAction: this.adjustPaddingFunction(true),
|
||||
elements: this.selectedBlocks()
|
||||
});
|
||||
|
||||
},
|
||||
|
||||
outdent: function(ui, elements) {
|
||||
var t = this, ed = t.ed, dom = ed.dom, outdented = [];
|
||||
|
||||
function outdentLI(element) {
|
||||
var listElement, targetParent, align;
|
||||
if (!hasParentInList(ed, element, outdented)) {
|
||||
if (dom.getStyle(element, 'margin-left') !== '' || dom.getStyle(element, 'padding-left') !== '') {
|
||||
return t.adjustPaddingFunction(false)(element);
|
||||
}
|
||||
align = dom.getStyle(element, 'text-align', true);
|
||||
if (align === 'center' || align === 'right') {
|
||||
dom.setStyle(element, 'text-align', 'left');
|
||||
return;
|
||||
}
|
||||
element = splitNestedLists(element, dom);
|
||||
listElement = element.parentNode;
|
||||
targetParent = element.parentNode.parentNode;
|
||||
if (targetParent.tagName === 'P') {
|
||||
dom.split(targetParent, element.parentNode);
|
||||
} else {
|
||||
dom.split(listElement, element);
|
||||
if (targetParent.tagName === 'LI') {
|
||||
// Nested list, need to split the LI and go back out to the OL/UL element.
|
||||
dom.split(targetParent, element);
|
||||
} else if (!dom.is(targetParent, 'ol,ul')) {
|
||||
dom.rename(element, 'p');
|
||||
}
|
||||
}
|
||||
outdented.push(element);
|
||||
}
|
||||
}
|
||||
|
||||
var listElements = elements && tinymce.is(elements, 'array') ? elements : this.selectedBlocks();
|
||||
this.process({
|
||||
'LI': outdentLI,
|
||||
defaultAction: this.adjustPaddingFunction(false),
|
||||
elements: listElements
|
||||
});
|
||||
|
||||
each(outdented, attemptMergeWithAdjacent);
|
||||
},
|
||||
|
||||
process: function(actions) {
|
||||
var t = this, sel = t.ed.selection, dom = t.ed.dom, selectedBlocks, r;
|
||||
|
||||
function isEmptyElement(element) {
|
||||
var excludeBrsAndBookmarks = tinymce.grep(element.childNodes, function(n) {
|
||||
return !(n.nodeName === 'BR' || n.nodeName === 'SPAN' && dom.getAttrib(n, 'data-mce-type') == 'bookmark'
|
||||
|| n.nodeType == 3 && (n.nodeValue == String.fromCharCode(160) || n.nodeValue == ''));
|
||||
});
|
||||
return excludeBrsAndBookmarks.length === 0;
|
||||
}
|
||||
|
||||
function processElement(element) {
|
||||
dom.removeClass(element, '_mce_act_on');
|
||||
if (!element || element.nodeType !== 1 || selectedBlocks.length > 1 && isEmptyElement(element)) {
|
||||
return;
|
||||
}
|
||||
element = findItemToOperateOn(element, dom);
|
||||
var action = actions[element.tagName];
|
||||
if (!action) {
|
||||
action = actions.defaultAction;
|
||||
}
|
||||
action(element);
|
||||
}
|
||||
|
||||
function recurse(element) {
|
||||
t.splitSafeEach(element.childNodes, processElement);
|
||||
}
|
||||
|
||||
function brAtEdgeOfSelection(container, offset) {
|
||||
return offset >= 0 && container.hasChildNodes() && offset < container.childNodes.length &&
|
||||
container.childNodes[offset].tagName === 'BR';
|
||||
}
|
||||
|
||||
function isInTable() {
|
||||
var n = sel.getNode();
|
||||
var p = dom.getParent(n, 'td');
|
||||
return p !== null;
|
||||
}
|
||||
|
||||
selectedBlocks = actions.elements;
|
||||
|
||||
r = sel.getRng(true);
|
||||
if (!r.collapsed) {
|
||||
if (brAtEdgeOfSelection(r.endContainer, r.endOffset - 1)) {
|
||||
r.setEnd(r.endContainer, r.endOffset - 1);
|
||||
sel.setRng(r);
|
||||
}
|
||||
if (brAtEdgeOfSelection(r.startContainer, r.startOffset)) {
|
||||
r.setStart(r.startContainer, r.startOffset + 1);
|
||||
sel.setRng(r);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (tinymce.isIE8) {
|
||||
// append a zero sized nbsp so that caret is restored correctly using bookmark
|
||||
var s = t.ed.selection.getNode();
|
||||
if (s.tagName === 'LI' && !(s.parentNode.lastChild === s)) {
|
||||
var i = t.ed.getDoc().createTextNode('\uFEFF');
|
||||
s.appendChild(i);
|
||||
}
|
||||
}
|
||||
|
||||
bookmark = sel.getBookmark();
|
||||
actions.OL = actions.UL = recurse;
|
||||
t.splitSafeEach(selectedBlocks, processElement);
|
||||
sel.moveToBookmark(bookmark);
|
||||
bookmark = null;
|
||||
|
||||
// we avoid doing repaint in a table as this will move the caret out of the table in Firefox 3.6
|
||||
if (!isInTable()) {
|
||||
// Avoids table or image handles being left behind in Firefox.
|
||||
t.ed.execCommand('mceRepaint');
|
||||
}
|
||||
},
|
||||
|
||||
splitSafeEach: function(elements, f) {
|
||||
if (tinymce.isGecko && (/Firefox\/[12]\.[0-9]/.test(navigator.userAgent) ||
|
||||
/Firefox\/3\.[0-4]/.test(navigator.userAgent))) {
|
||||
this.classBasedEach(elements, f);
|
||||
} else {
|
||||
each(elements, f);
|
||||
}
|
||||
},
|
||||
|
||||
classBasedEach: function(elements, f) {
|
||||
var dom = this.ed.dom, nodes, element;
|
||||
// Mark nodes
|
||||
each(elements, function(element) {
|
||||
dom.addClass(element, '_mce_act_on');
|
||||
});
|
||||
nodes = dom.select('._mce_act_on');
|
||||
while (nodes.length > 0) {
|
||||
element = nodes.shift();
|
||||
dom.removeClass(element, '_mce_act_on');
|
||||
f(element);
|
||||
nodes = dom.select('._mce_act_on');
|
||||
}
|
||||
},
|
||||
|
||||
adjustPaddingFunction: function(isIndent) {
|
||||
var indentAmount, indentUnits, ed = this.ed;
|
||||
indentAmount = ed.settings.indentation;
|
||||
indentUnits = /[a-z%]+/i.exec(indentAmount);
|
||||
indentAmount = parseInt(indentAmount, 10);
|
||||
return function(element) {
|
||||
var currentIndent, newIndentAmount;
|
||||
currentIndent = parseInt(ed.dom.getStyle(element, 'margin-left') || 0, 10) + parseInt(ed.dom.getStyle(element, 'padding-left') || 0, 10);
|
||||
if (isIndent) {
|
||||
newIndentAmount = currentIndent + indentAmount;
|
||||
} else {
|
||||
newIndentAmount = currentIndent - indentAmount;
|
||||
}
|
||||
ed.dom.setStyle(element, 'padding-left', '');
|
||||
ed.dom.setStyle(element, 'margin-left', newIndentAmount > 0 ? newIndentAmount + indentUnits : '');
|
||||
};
|
||||
},
|
||||
|
||||
selectedBlocks: function() {
|
||||
var ed = this.ed
|
||||
var selectedBlocks = ed.selection.getSelectedBlocks();
|
||||
return selectedBlocks.length == 0 ? [ ed.dom.getRoot() ] : selectedBlocks;
|
||||
},
|
||||
|
||||
getInfo: function() {
|
||||
return {
|
||||
longname : 'Lists',
|
||||
author : 'Moxiecode Systems AB',
|
||||
authorurl : 'http://tinymce.moxiecode.com',
|
||||
infourl : 'http://wiki.moxiecode.com/index.php/TinyMCE:Plugins/lists',
|
||||
version : tinymce.majorVersion + "." + tinymce.minorVersion
|
||||
};
|
||||
}
|
||||
});
|
||||
tinymce.PluginManager.add("lists", tinymce.plugins.Lists);
|
||||
}());
|
||||
/**
|
||||
* editor_plugin_src.js
|
||||
*
|
||||
* Copyright 2011, Moxiecode Systems AB
|
||||
* Released under LGPL License.
|
||||
*
|
||||
* License: http://tinymce.moxiecode.com/license
|
||||
* Contributing: http://tinymce.moxiecode.com/contributing
|
||||
*/
|
||||
|
||||
(function() {
|
||||
var each = tinymce.each, Event = tinymce.dom.Event, bookmark;
|
||||
|
||||
// Skips text nodes that only contain whitespace since they aren't semantically important.
|
||||
function skipWhitespaceNodes(e, next) {
|
||||
while (e && (e.nodeType === 8 || (e.nodeType === 3 && /^[ \t\n\r]*$/.test(e.nodeValue)))) {
|
||||
e = next(e);
|
||||
}
|
||||
return e;
|
||||
}
|
||||
|
||||
function skipWhitespaceNodesBackwards(e) {
|
||||
return skipWhitespaceNodes(e, function(e) {
|
||||
return e.previousSibling;
|
||||
});
|
||||
}
|
||||
|
||||
function skipWhitespaceNodesForwards(e) {
|
||||
return skipWhitespaceNodes(e, function(e) {
|
||||
return e.nextSibling;
|
||||
});
|
||||
}
|
||||
|
||||
function hasParentInList(ed, e, list) {
|
||||
return ed.dom.getParent(e, function(p) {
|
||||
return tinymce.inArray(list, p) !== -1;
|
||||
});
|
||||
}
|
||||
|
||||
function isList(e) {
|
||||
return e && (e.tagName === 'OL' || e.tagName === 'UL');
|
||||
}
|
||||
|
||||
function splitNestedLists(element, dom) {
|
||||
var tmp, nested, wrapItem;
|
||||
tmp = skipWhitespaceNodesBackwards(element.lastChild);
|
||||
while (isList(tmp)) {
|
||||
nested = tmp;
|
||||
tmp = skipWhitespaceNodesBackwards(nested.previousSibling);
|
||||
}
|
||||
if (nested) {
|
||||
wrapItem = dom.create('li', { style: 'list-style-type: none;'});
|
||||
dom.split(element, nested);
|
||||
dom.insertAfter(wrapItem, nested);
|
||||
wrapItem.appendChild(nested);
|
||||
wrapItem.appendChild(nested);
|
||||
element = wrapItem.previousSibling;
|
||||
}
|
||||
return element;
|
||||
}
|
||||
|
||||
function attemptMergeWithAdjacent(e, allowDifferentListStyles, mergeParagraphs) {
|
||||
e = attemptMergeWithPrevious(e, allowDifferentListStyles, mergeParagraphs);
|
||||
return attemptMergeWithNext(e, allowDifferentListStyles, mergeParagraphs);
|
||||
}
|
||||
|
||||
function attemptMergeWithPrevious(e, allowDifferentListStyles, mergeParagraphs) {
|
||||
var prev = skipWhitespaceNodesBackwards(e.previousSibling);
|
||||
if (prev) {
|
||||
return attemptMerge(prev, e, allowDifferentListStyles ? prev : false, mergeParagraphs);
|
||||
} else {
|
||||
return e;
|
||||
}
|
||||
}
|
||||
|
||||
function attemptMergeWithNext(e, allowDifferentListStyles, mergeParagraphs) {
|
||||
var next = skipWhitespaceNodesForwards(e.nextSibling);
|
||||
if (next) {
|
||||
return attemptMerge(e, next, allowDifferentListStyles ? next : false, mergeParagraphs);
|
||||
} else {
|
||||
return e;
|
||||
}
|
||||
}
|
||||
|
||||
function attemptMerge(e1, e2, differentStylesMasterElement, mergeParagraphs) {
|
||||
if (canMerge(e1, e2, !!differentStylesMasterElement, mergeParagraphs)) {
|
||||
return merge(e1, e2, differentStylesMasterElement);
|
||||
} else if (e1 && e1.tagName === 'LI' && isList(e2)) {
|
||||
// Fix invalidly nested lists.
|
||||
e1.appendChild(e2);
|
||||
}
|
||||
return e2;
|
||||
}
|
||||
|
||||
function canMerge(e1, e2, allowDifferentListStyles, mergeParagraphs) {
|
||||
if (!e1 || !e2) {
|
||||
return false;
|
||||
} else if (e1.tagName === 'LI' && e2.tagName === 'LI') {
|
||||
return e2.style.listStyleType === 'none' || containsOnlyAList(e2);
|
||||
} else if (isList(e1)) {
|
||||
return (e1.tagName === e2.tagName && (allowDifferentListStyles || e1.style.listStyleType === e2.style.listStyleType)) || isListForIndent(e2);
|
||||
} else return mergeParagraphs && e1.tagName === 'P' && e2.tagName === 'P';
|
||||
}
|
||||
|
||||
function isListForIndent(e) {
|
||||
var firstLI = skipWhitespaceNodesForwards(e.firstChild), lastLI = skipWhitespaceNodesBackwards(e.lastChild);
|
||||
return firstLI && lastLI && isList(e) && firstLI === lastLI && (isList(firstLI) || firstLI.style.listStyleType === 'none' || containsOnlyAList(firstLI));
|
||||
}
|
||||
|
||||
function containsOnlyAList(e) {
|
||||
var firstChild = skipWhitespaceNodesForwards(e.firstChild), lastChild = skipWhitespaceNodesBackwards(e.lastChild);
|
||||
return firstChild && lastChild && firstChild === lastChild && isList(firstChild);
|
||||
}
|
||||
|
||||
function merge(e1, e2, masterElement) {
|
||||
var lastOriginal = skipWhitespaceNodesBackwards(e1.lastChild), firstNew = skipWhitespaceNodesForwards(e2.firstChild);
|
||||
if (e1.tagName === 'P') {
|
||||
e1.appendChild(e1.ownerDocument.createElement('br'));
|
||||
}
|
||||
while (e2.firstChild) {
|
||||
e1.appendChild(e2.firstChild);
|
||||
}
|
||||
if (masterElement) {
|
||||
e1.style.listStyleType = masterElement.style.listStyleType;
|
||||
}
|
||||
e2.parentNode.removeChild(e2);
|
||||
attemptMerge(lastOriginal, firstNew, false);
|
||||
return e1;
|
||||
}
|
||||
|
||||
function findItemToOperateOn(e, dom) {
|
||||
var item;
|
||||
if (!dom.is(e, 'li,ol,ul')) {
|
||||
item = dom.getParent(e, 'li');
|
||||
if (item) {
|
||||
e = item;
|
||||
}
|
||||
}
|
||||
return e;
|
||||
}
|
||||
|
||||
tinymce.create('tinymce.plugins.Lists', {
|
||||
init: function(ed) {
|
||||
var LIST_TABBING = 'TABBING';
|
||||
var LIST_EMPTY_ITEM = 'EMPTY';
|
||||
var LIST_ESCAPE = 'ESCAPE';
|
||||
var LIST_PARAGRAPH = 'PARAGRAPH';
|
||||
var LIST_UNKNOWN = 'UNKNOWN';
|
||||
var state = LIST_UNKNOWN;
|
||||
|
||||
function isTabInList(e) {
|
||||
// Don't indent on Ctrl+Tab or Alt+Tab
|
||||
return e.keyCode === tinymce.VK.TAB && !(e.altKey || e.ctrlKey) &&
|
||||
(ed.queryCommandState('InsertUnorderedList') || ed.queryCommandState('InsertOrderedList'));
|
||||
}
|
||||
|
||||
function isOnLastListItem() {
|
||||
var li = getLi();
|
||||
var grandParent = li.parentNode.parentNode;
|
||||
var isLastItem = li.parentNode.lastChild === li;
|
||||
return isLastItem && !isNestedList(grandParent) && isEmptyListItem(li);
|
||||
}
|
||||
|
||||
function isNestedList(grandParent) {
|
||||
if (isList(grandParent)) {
|
||||
return grandParent.parentNode && grandParent.parentNode.tagName === 'LI';
|
||||
} else {
|
||||
return grandParent.tagName === 'LI';
|
||||
}
|
||||
}
|
||||
|
||||
function isInEmptyListItem() {
|
||||
return ed.selection.isCollapsed() && isEmptyListItem(getLi());
|
||||
}
|
||||
|
||||
function getLi() {
|
||||
var n = ed.selection.getStart();
|
||||
// Get start will return BR if the LI only contains a BR or an empty element as we use these to fix caret position
|
||||
return ((n.tagName == 'BR' || n.tagName == '') && n.parentNode.tagName == 'LI') ? n.parentNode : n;
|
||||
}
|
||||
|
||||
function isEmptyListItem(li) {
|
||||
var numChildren = li.childNodes.length;
|
||||
if (li.tagName === 'LI') {
|
||||
return numChildren == 0 ? true : numChildren == 1 && (li.firstChild.tagName == '' || li.firstChild.tagName == 'BR' || isEmptyIE9Li(li));
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
function isEmptyIE9Li(li) {
|
||||
// only consider this to be last item if there is no list item content or that content is nbsp or space since IE9 creates these
|
||||
var lis = tinymce.grep(li.parentNode.childNodes, function(n) {return n.tagName == 'LI'});
|
||||
var isLastLi = li == lis[lis.length - 1];
|
||||
var child = li.firstChild;
|
||||
return tinymce.isIE9 && isLastLi && (child.nodeValue == String.fromCharCode(160) || child.nodeValue == String.fromCharCode(32));
|
||||
}
|
||||
|
||||
function isEnter(e) {
|
||||
return e.keyCode === tinymce.VK.ENTER;
|
||||
}
|
||||
|
||||
function isEnterWithoutShift(e) {
|
||||
return isEnter(e) && !e.shiftKey;
|
||||
}
|
||||
|
||||
function getListKeyState(e) {
|
||||
if (isTabInList(e)) {
|
||||
return LIST_TABBING;
|
||||
} else if (isEnterWithoutShift(e) && isOnLastListItem()) {
|
||||
// Returns LIST_UNKNOWN since breaking out of lists is handled by the EnterKey.js logic now
|
||||
//return LIST_ESCAPE;
|
||||
return LIST_UNKNOWN;
|
||||
} else if (isEnterWithoutShift(e) && isInEmptyListItem()) {
|
||||
return LIST_EMPTY_ITEM;
|
||||
} else {
|
||||
return LIST_UNKNOWN;
|
||||
}
|
||||
}
|
||||
|
||||
function cancelDefaultEvents(ed, e) {
|
||||
// list escape is done manually using outdent as it does not create paragraphs correctly in td's
|
||||
if (state == LIST_TABBING || state == LIST_EMPTY_ITEM || tinymce.isGecko && state == LIST_ESCAPE) {
|
||||
Event.cancel(e);
|
||||
}
|
||||
}
|
||||
|
||||
function isCursorAtEndOfContainer() {
|
||||
var range = ed.selection.getRng(true);
|
||||
var startContainer = range.startContainer;
|
||||
if (startContainer.nodeType == 3) {
|
||||
var value = startContainer.nodeValue;
|
||||
if (tinymce.isIE9 && value.length > 1 && value.charCodeAt(value.length-1) == 32) {
|
||||
// IE9 places a space on the end of the text in some cases so ignore last char
|
||||
return (range.endOffset == value.length-1);
|
||||
} else {
|
||||
return (range.endOffset == value.length);
|
||||
}
|
||||
} else if (startContainer.nodeType == 1) {
|
||||
return range.endOffset == startContainer.childNodes.length;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/*
|
||||
If we are at the end of a list item surrounded with an element, pressing enter should create a
|
||||
new list item instead without splitting the element e.g. don't want to create new P or H1 tag
|
||||
*/
|
||||
function isEndOfListItem() {
|
||||
var node = ed.selection.getNode();
|
||||
var validElements = 'h1,h2,h3,h4,h5,h6,p,div';
|
||||
var isLastParagraphOfLi = ed.dom.is(node, validElements) && node.parentNode.tagName === 'LI' && node.parentNode.lastChild === node;
|
||||
return ed.selection.isCollapsed() && isLastParagraphOfLi && isCursorAtEndOfContainer();
|
||||
}
|
||||
|
||||
// Creates a new list item after the current selection's list item parent
|
||||
function createNewLi(ed, e) {
|
||||
if (isEnterWithoutShift(e) && isEndOfListItem()) {
|
||||
var node = ed.selection.getNode();
|
||||
var li = ed.dom.create("li");
|
||||
var parentLi = ed.dom.getParent(node, 'li');
|
||||
ed.dom.insertAfter(li, parentLi);
|
||||
|
||||
// Move caret to new list element.
|
||||
if (tinymce.isIE6 || tinymce.isIE7 || tinyMCE.isIE8) {
|
||||
// Removed this line since it would create an odd < > tag and placing the caret inside an empty LI is handled and should be handled by the selection logic
|
||||
//li.appendChild(ed.dom.create(" ")); // IE needs an element within the bullet point
|
||||
ed.selection.setCursorLocation(li, 1);
|
||||
} else {
|
||||
ed.selection.setCursorLocation(li, 0);
|
||||
}
|
||||
e.preventDefault();
|
||||
}
|
||||
}
|
||||
|
||||
function imageJoiningListItem(ed, e) {
|
||||
var prevSibling;
|
||||
|
||||
if (!tinymce.isGecko)
|
||||
return;
|
||||
|
||||
var n = ed.selection.getStart();
|
||||
if (e.keyCode != tinymce.VK.BACKSPACE || n.tagName !== 'IMG')
|
||||
return;
|
||||
|
||||
function lastLI(node) {
|
||||
var child = node.firstChild;
|
||||
var li = null;
|
||||
do {
|
||||
if (!child)
|
||||
break;
|
||||
|
||||
if (child.tagName === 'LI')
|
||||
li = child;
|
||||
} while (child = child.nextSibling);
|
||||
|
||||
return li;
|
||||
}
|
||||
|
||||
function addChildren(parentNode, destination) {
|
||||
while (parentNode.childNodes.length > 0)
|
||||
destination.appendChild(parentNode.childNodes[0]);
|
||||
}
|
||||
|
||||
// Check if there is a previous sibling
|
||||
prevSibling = n.parentNode.previousSibling;
|
||||
if (!prevSibling)
|
||||
return;
|
||||
|
||||
var ul;
|
||||
if (prevSibling.tagName === 'UL' || prevSibling.tagName === 'OL')
|
||||
ul = prevSibling;
|
||||
else if (prevSibling.previousSibling && (prevSibling.previousSibling.tagName === 'UL' || prevSibling.previousSibling.tagName === 'OL'))
|
||||
ul = prevSibling.previousSibling;
|
||||
else
|
||||
return;
|
||||
|
||||
var li = lastLI(ul);
|
||||
|
||||
// move the caret to the end of the list item
|
||||
var rng = ed.dom.createRng();
|
||||
rng.setStart(li, 1);
|
||||
rng.setEnd(li, 1);
|
||||
ed.selection.setRng(rng);
|
||||
ed.selection.collapse(true);
|
||||
|
||||
// save a bookmark at the end of the list item
|
||||
var bookmark = ed.selection.getBookmark();
|
||||
|
||||
// copy the image an its text to the list item
|
||||
var clone = n.parentNode.cloneNode(true);
|
||||
if (clone.tagName === 'P' || clone.tagName === 'DIV')
|
||||
addChildren(clone, li);
|
||||
else
|
||||
li.appendChild(clone);
|
||||
|
||||
// remove the old copy of the image
|
||||
n.parentNode.parentNode.removeChild(n.parentNode);
|
||||
|
||||
// move the caret where we saved the bookmark
|
||||
ed.selection.moveToBookmark(bookmark);
|
||||
}
|
||||
|
||||
// fix the cursor position to ensure it is correct in IE
|
||||
function setCursorPositionToOriginalLi(li) {
|
||||
var list = ed.dom.getParent(li, 'ol,ul');
|
||||
if (list != null) {
|
||||
var lastLi = list.lastChild;
|
||||
// Removed this line since IE9 would report an DOM character error and placing the caret inside an empty LI is handled and should be handled by the selection logic
|
||||
//lastLi.appendChild(ed.getDoc().createElement(''));
|
||||
ed.selection.setCursorLocation(lastLi, 0);
|
||||
}
|
||||
}
|
||||
|
||||
this.ed = ed;
|
||||
ed.addCommand('Indent', this.indent, this);
|
||||
ed.addCommand('Outdent', this.outdent, this);
|
||||
ed.addCommand('InsertUnorderedList', function() {
|
||||
this.applyList('UL', 'OL');
|
||||
}, this);
|
||||
ed.addCommand('InsertOrderedList', function() {
|
||||
this.applyList('OL', 'UL');
|
||||
}, this);
|
||||
|
||||
ed.onInit.add(function() {
|
||||
ed.editorCommands.addCommands({
|
||||
'outdent': function() {
|
||||
var sel = ed.selection, dom = ed.dom;
|
||||
|
||||
function hasStyleIndent(n) {
|
||||
n = dom.getParent(n, dom.isBlock);
|
||||
return n && (parseInt(ed.dom.getStyle(n, 'margin-left') || 0, 10) + parseInt(ed.dom.getStyle(n, 'padding-left') || 0, 10)) > 0;
|
||||
}
|
||||
|
||||
return hasStyleIndent(sel.getStart()) || hasStyleIndent(sel.getEnd()) || ed.queryCommandState('InsertOrderedList') || ed.queryCommandState('InsertUnorderedList');
|
||||
}
|
||||
}, 'state');
|
||||
});
|
||||
|
||||
ed.onKeyUp.add(function(ed, e) {
|
||||
if (state == LIST_TABBING) {
|
||||
ed.execCommand(e.shiftKey ? 'Outdent' : 'Indent', true, null);
|
||||
state = LIST_UNKNOWN;
|
||||
return Event.cancel(e);
|
||||
} else if (state == LIST_EMPTY_ITEM) {
|
||||
var li = getLi();
|
||||
var shouldOutdent = ed.settings.list_outdent_on_enter === true || e.shiftKey;
|
||||
ed.execCommand(shouldOutdent ? 'Outdent' : 'Indent', true, null);
|
||||
if (tinymce.isIE) {
|
||||
setCursorPositionToOriginalLi(li);
|
||||
}
|
||||
|
||||
return Event.cancel(e);
|
||||
} else if (state == LIST_ESCAPE) {
|
||||
if (tinymce.isIE6 || tinymce.isIE7 || tinymce.isIE8) {
|
||||
// append a zero sized nbsp so that caret is positioned correctly in IE after escaping and applying formatting.
|
||||
// if there is no text then applying formatting for e.g a H1 to the P tag immediately following list after
|
||||
// escaping from it will cause the caret to be positioned on the last li instead of staying the in P tag.
|
||||
var n = ed.getDoc().createTextNode('\uFEFF');
|
||||
ed.selection.getNode().appendChild(n);
|
||||
} else if (tinymce.isIE9 || tinymce.isGecko) {
|
||||
// IE9 does not escape the list so we use outdent to do this and cancel the default behaviour
|
||||
// Gecko does not create a paragraph outdenting inside a TD so default behaviour is cancelled and we outdent ourselves
|
||||
ed.execCommand('Outdent');
|
||||
return Event.cancel(e);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
function fixListItem(parent, reference) {
|
||||
// a zero-sized non-breaking space is placed in the empty list item so that the nested list is
|
||||
// displayed on the below line instead of next to it
|
||||
var n = ed.getDoc().createTextNode('\uFEFF');
|
||||
parent.insertBefore(n, reference);
|
||||
ed.selection.setCursorLocation(n, 0);
|
||||
// repaint to remove rendering artifact. only visible when creating new list
|
||||
ed.execCommand('mceRepaint');
|
||||
}
|
||||
|
||||
function fixIndentedListItemForGecko(ed, e) {
|
||||
if (isEnter(e)) {
|
||||
var li = getLi();
|
||||
if (li) {
|
||||
var parent = li.parentNode;
|
||||
var grandParent = parent && parent.parentNode;
|
||||
if (grandParent && grandParent.nodeName == 'LI' && grandParent.firstChild == parent && li == parent.firstChild) {
|
||||
fixListItem(grandParent, parent);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function fixIndentedListItemForIE8(ed, e) {
|
||||
if (isEnter(e)) {
|
||||
var li = getLi();
|
||||
if (ed.dom.select('ul li', li).length === 1) {
|
||||
var list = li.firstChild;
|
||||
fixListItem(li, list);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function fixDeletingFirstCharOfList(ed, e) {
|
||||
function listElements(list, li) {
|
||||
var elements = [];
|
||||
var walker = new tinymce.dom.TreeWalker(li, list);
|
||||
for (var node = walker.current(); node; node = walker.next()) {
|
||||
if (ed.dom.is(node, 'ol,ul,li')) {
|
||||
elements.push(node);
|
||||
}
|
||||
}
|
||||
return elements;
|
||||
}
|
||||
|
||||
if (e.keyCode == tinymce.VK.BACKSPACE) {
|
||||
var li = getLi();
|
||||
if (li) {
|
||||
var list = ed.dom.getParent(li, 'ol,ul');
|
||||
if (list && list.firstChild === li) {
|
||||
var elements = listElements(list, li);
|
||||
ed.execCommand("Outdent", false, elements);
|
||||
ed.undoManager.add();
|
||||
return Event.cancel(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function fixDeletingEmptyLiInWebkit(ed, e) {
|
||||
var li = getLi();
|
||||
if (e.keyCode === tinymce.VK.BACKSPACE && ed.dom.is(li, 'li') && li.parentNode.firstChild!==li) {
|
||||
if (ed.dom.select('ul,ol', li).length === 1) {
|
||||
var prevLi = li.previousSibling;
|
||||
ed.dom.remove(ed.dom.select('br', li));
|
||||
ed.dom.remove(li, true);
|
||||
var textNodes = tinymce.grep(prevLi.childNodes, function(n){ return n.nodeType === 3 });
|
||||
if (textNodes.length === 1) {
|
||||
var textNode = textNodes[0]
|
||||
ed.selection.setCursorLocation(textNode, textNode.length);
|
||||
}
|
||||
ed.undoManager.add();
|
||||
return Event.cancel(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ed.onKeyDown.add(function(_, e) { state = getListKeyState(e); });
|
||||
ed.onKeyDown.add(cancelDefaultEvents);
|
||||
ed.onKeyDown.add(imageJoiningListItem);
|
||||
ed.onKeyDown.add(createNewLi);
|
||||
|
||||
if (tinymce.isGecko) {
|
||||
ed.onKeyUp.add(fixIndentedListItemForGecko);
|
||||
}
|
||||
if (tinymce.isIE8) {
|
||||
ed.onKeyUp.add(fixIndentedListItemForIE8);
|
||||
}
|
||||
if (tinymce.isGecko || tinymce.isWebKit) {
|
||||
ed.onKeyDown.add(fixDeletingFirstCharOfList);
|
||||
}
|
||||
if (tinymce.isWebKit) {
|
||||
ed.onKeyDown.add(fixDeletingEmptyLiInWebkit);
|
||||
}
|
||||
},
|
||||
|
||||
applyList: function(targetListType, oppositeListType) {
|
||||
var t = this, ed = t.ed, dom = ed.dom, applied = [], hasSameType = false, hasOppositeType = false, hasNonList = false, actions,
|
||||
selectedBlocks = ed.selection.getSelectedBlocks();
|
||||
|
||||
function cleanupBr(e) {
|
||||
if (e && e.tagName === 'BR') {
|
||||
dom.remove(e);
|
||||
}
|
||||
}
|
||||
|
||||
function makeList(element) {
|
||||
var list = dom.create(targetListType), li;
|
||||
|
||||
function adjustIndentForNewList(element) {
|
||||
// If there's a margin-left, outdent one level to account for the extra list margin.
|
||||
if (element.style.marginLeft || element.style.paddingLeft) {
|
||||
t.adjustPaddingFunction(false)(element);
|
||||
}
|
||||
}
|
||||
|
||||
if (element.tagName === 'LI') {
|
||||
// No change required.
|
||||
} else if (element.tagName === 'P' || element.tagName === 'DIV' || element.tagName === 'BODY') {
|
||||
processBrs(element, function(startSection, br) {
|
||||
doWrapList(startSection, br, element.tagName === 'BODY' ? null : startSection.parentNode);
|
||||
li = startSection.parentNode;
|
||||
adjustIndentForNewList(li);
|
||||
cleanupBr(br);
|
||||
});
|
||||
if (li) {
|
||||
if (li.tagName === 'LI' && (element.tagName === 'P' || selectedBlocks.length > 1)) {
|
||||
dom.split(li.parentNode.parentNode, li.parentNode);
|
||||
}
|
||||
attemptMergeWithAdjacent(li.parentNode, true);
|
||||
}
|
||||
return;
|
||||
} else {
|
||||
// Put the list around the element.
|
||||
li = dom.create('li');
|
||||
dom.insertAfter(li, element);
|
||||
li.appendChild(element);
|
||||
adjustIndentForNewList(element);
|
||||
element = li;
|
||||
}
|
||||
dom.insertAfter(list, element);
|
||||
list.appendChild(element);
|
||||
attemptMergeWithAdjacent(list, true);
|
||||
applied.push(element);
|
||||
}
|
||||
|
||||
function doWrapList(start, end, template) {
|
||||
var li, n = start, tmp;
|
||||
while (!dom.isBlock(start.parentNode) && start.parentNode !== dom.getRoot()) {
|
||||
start = dom.split(start.parentNode, start.previousSibling);
|
||||
start = start.nextSibling;
|
||||
n = start;
|
||||
}
|
||||
if (template) {
|
||||
li = template.cloneNode(true);
|
||||
start.parentNode.insertBefore(li, start);
|
||||
while (li.firstChild) dom.remove(li.firstChild);
|
||||
li = dom.rename(li, 'li');
|
||||
} else {
|
||||
li = dom.create('li');
|
||||
start.parentNode.insertBefore(li, start);
|
||||
}
|
||||
while (n && n != end) {
|
||||
tmp = n.nextSibling;
|
||||
li.appendChild(n);
|
||||
n = tmp;
|
||||
}
|
||||
if (li.childNodes.length === 0) {
|
||||
li.innerHTML = '<br _mce_bogus="1" />';
|
||||
}
|
||||
makeList(li);
|
||||
}
|
||||
|
||||
function processBrs(element, callback) {
|
||||
var startSection, previousBR, END_TO_START = 3, START_TO_END = 1,
|
||||
breakElements = 'br,ul,ol,p,div,h1,h2,h3,h4,h5,h6,table,blockquote,address,pre,form,center,dl';
|
||||
|
||||
function isAnyPartSelected(start, end) {
|
||||
var r = dom.createRng(), sel;
|
||||
bookmark.keep = true;
|
||||
ed.selection.moveToBookmark(bookmark);
|
||||
bookmark.keep = false;
|
||||
sel = ed.selection.getRng(true);
|
||||
if (!end) {
|
||||
end = start.parentNode.lastChild;
|
||||
}
|
||||
r.setStartBefore(start);
|
||||
r.setEndAfter(end);
|
||||
return !(r.compareBoundaryPoints(END_TO_START, sel) > 0 || r.compareBoundaryPoints(START_TO_END, sel) <= 0);
|
||||
}
|
||||
|
||||
function nextLeaf(br) {
|
||||
if (br.nextSibling)
|
||||
return br.nextSibling;
|
||||
if (!dom.isBlock(br.parentNode) && br.parentNode !== dom.getRoot())
|
||||
return nextLeaf(br.parentNode);
|
||||
}
|
||||
|
||||
// Split on BRs within the range and process those.
|
||||
startSection = element.firstChild;
|
||||
// First mark the BRs that have any part of the previous section selected.
|
||||
var trailingContentSelected = false;
|
||||
each(dom.select(breakElements, element), function(br) {
|
||||
if (br.hasAttribute && br.hasAttribute('_mce_bogus')) {
|
||||
return true; // Skip the bogus Brs that are put in to appease Firefox and Safari.
|
||||
}
|
||||
if (isAnyPartSelected(startSection, br)) {
|
||||
dom.addClass(br, '_mce_tagged_br');
|
||||
startSection = nextLeaf(br);
|
||||
}
|
||||
});
|
||||
trailingContentSelected = (startSection && isAnyPartSelected(startSection, undefined));
|
||||
startSection = element.firstChild;
|
||||
each(dom.select(breakElements, element), function(br) {
|
||||
// Got a section from start to br.
|
||||
var tmp = nextLeaf(br);
|
||||
if (br.hasAttribute && br.hasAttribute('_mce_bogus')) {
|
||||
return true; // Skip the bogus Brs that are put in to appease Firefox and Safari.
|
||||
}
|
||||
if (dom.hasClass(br, '_mce_tagged_br')) {
|
||||
callback(startSection, br, previousBR);
|
||||
previousBR = null;
|
||||
} else {
|
||||
previousBR = br;
|
||||
}
|
||||
startSection = tmp;
|
||||
});
|
||||
if (trailingContentSelected) {
|
||||
callback(startSection, undefined, previousBR);
|
||||
}
|
||||
}
|
||||
|
||||
function wrapList(element) {
|
||||
processBrs(element, function(startSection, br, previousBR) {
|
||||
// Need to indent this part
|
||||
doWrapList(startSection, br);
|
||||
cleanupBr(br);
|
||||
cleanupBr(previousBR);
|
||||
});
|
||||
}
|
||||
|
||||
function changeList(element) {
|
||||
if (tinymce.inArray(applied, element) !== -1) {
|
||||
return;
|
||||
}
|
||||
if (element.parentNode.tagName === oppositeListType) {
|
||||
dom.split(element.parentNode, element);
|
||||
makeList(element);
|
||||
attemptMergeWithNext(element.parentNode, false);
|
||||
}
|
||||
applied.push(element);
|
||||
}
|
||||
|
||||
function convertListItemToParagraph(element) {
|
||||
var child, nextChild, mergedElement, splitLast;
|
||||
if (tinymce.inArray(applied, element) !== -1) {
|
||||
return;
|
||||
}
|
||||
element = splitNestedLists(element, dom);
|
||||
while (dom.is(element.parentNode, 'ol,ul,li')) {
|
||||
dom.split(element.parentNode, element);
|
||||
}
|
||||
// Push the original element we have from the selection, not the renamed one.
|
||||
applied.push(element);
|
||||
element = dom.rename(element, 'p');
|
||||
mergedElement = attemptMergeWithAdjacent(element, false, ed.settings.force_br_newlines);
|
||||
if (mergedElement === element) {
|
||||
// Now split out any block elements that can't be contained within a P.
|
||||
// Manually iterate to ensure we handle modifications correctly (doesn't work with tinymce.each)
|
||||
child = element.firstChild;
|
||||
while (child) {
|
||||
if (dom.isBlock(child)) {
|
||||
child = dom.split(child.parentNode, child);
|
||||
splitLast = true;
|
||||
nextChild = child.nextSibling && child.nextSibling.firstChild;
|
||||
} else {
|
||||
nextChild = child.nextSibling;
|
||||
if (splitLast && child.tagName === 'BR') {
|
||||
dom.remove(child);
|
||||
}
|
||||
splitLast = false;
|
||||
}
|
||||
child = nextChild;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
each(selectedBlocks, function(e) {
|
||||
e = findItemToOperateOn(e, dom);
|
||||
if (e.tagName === oppositeListType || (e.tagName === 'LI' && e.parentNode.tagName === oppositeListType)) {
|
||||
hasOppositeType = true;
|
||||
} else if (e.tagName === targetListType || (e.tagName === 'LI' && e.parentNode.tagName === targetListType)) {
|
||||
hasSameType = true;
|
||||
} else {
|
||||
hasNonList = true;
|
||||
}
|
||||
});
|
||||
|
||||
if (hasNonList &&!hasSameType || hasOppositeType || selectedBlocks.length === 0) {
|
||||
actions = {
|
||||
'LI': changeList,
|
||||
'H1': makeList,
|
||||
'H2': makeList,
|
||||
'H3': makeList,
|
||||
'H4': makeList,
|
||||
'H5': makeList,
|
||||
'H6': makeList,
|
||||
'P': makeList,
|
||||
'BODY': makeList,
|
||||
'DIV': selectedBlocks.length > 1 ? makeList : wrapList,
|
||||
defaultAction: wrapList,
|
||||
elements: this.selectedBlocks()
|
||||
};
|
||||
} else {
|
||||
actions = {
|
||||
defaultAction: convertListItemToParagraph,
|
||||
elements: this.selectedBlocks()
|
||||
};
|
||||
}
|
||||
this.process(actions);
|
||||
},
|
||||
|
||||
indent: function() {
|
||||
var ed = this.ed, dom = ed.dom, indented = [];
|
||||
|
||||
function createWrapItem(element) {
|
||||
var wrapItem = dom.create('li', { style: 'list-style-type: none;'});
|
||||
dom.insertAfter(wrapItem, element);
|
||||
return wrapItem;
|
||||
}
|
||||
|
||||
function createWrapList(element) {
|
||||
var wrapItem = createWrapItem(element),
|
||||
list = dom.getParent(element, 'ol,ul'),
|
||||
listType = list.tagName,
|
||||
listStyle = dom.getStyle(list, 'list-style-type'),
|
||||
attrs = {},
|
||||
wrapList;
|
||||
if (listStyle !== '') {
|
||||
attrs.style = 'list-style-type: ' + listStyle + ';';
|
||||
}
|
||||
wrapList = dom.create(listType, attrs);
|
||||
wrapItem.appendChild(wrapList);
|
||||
return wrapList;
|
||||
}
|
||||
|
||||
function indentLI(element) {
|
||||
if (!hasParentInList(ed, element, indented)) {
|
||||
element = splitNestedLists(element, dom);
|
||||
var wrapList = createWrapList(element);
|
||||
wrapList.appendChild(element);
|
||||
attemptMergeWithAdjacent(wrapList.parentNode, false);
|
||||
attemptMergeWithAdjacent(wrapList, false);
|
||||
indented.push(element);
|
||||
}
|
||||
}
|
||||
|
||||
this.process({
|
||||
'LI': indentLI,
|
||||
defaultAction: this.adjustPaddingFunction(true),
|
||||
elements: this.selectedBlocks()
|
||||
});
|
||||
|
||||
},
|
||||
|
||||
outdent: function(ui, elements) {
|
||||
var t = this, ed = t.ed, dom = ed.dom, outdented = [];
|
||||
|
||||
function outdentLI(element) {
|
||||
var listElement, targetParent, align;
|
||||
if (!hasParentInList(ed, element, outdented)) {
|
||||
if (dom.getStyle(element, 'margin-left') !== '' || dom.getStyle(element, 'padding-left') !== '') {
|
||||
return t.adjustPaddingFunction(false)(element);
|
||||
}
|
||||
align = dom.getStyle(element, 'text-align', true);
|
||||
if (align === 'center' || align === 'right') {
|
||||
dom.setStyle(element, 'text-align', 'left');
|
||||
return;
|
||||
}
|
||||
element = splitNestedLists(element, dom);
|
||||
listElement = element.parentNode;
|
||||
targetParent = element.parentNode.parentNode;
|
||||
if (targetParent.tagName === 'P') {
|
||||
dom.split(targetParent, element.parentNode);
|
||||
} else {
|
||||
dom.split(listElement, element);
|
||||
if (targetParent.tagName === 'LI') {
|
||||
// Nested list, need to split the LI and go back out to the OL/UL element.
|
||||
dom.split(targetParent, element);
|
||||
} else if (!dom.is(targetParent, 'ol,ul')) {
|
||||
dom.rename(element, 'p');
|
||||
}
|
||||
}
|
||||
outdented.push(element);
|
||||
}
|
||||
}
|
||||
|
||||
var listElements = elements && tinymce.is(elements, 'array') ? elements : this.selectedBlocks();
|
||||
this.process({
|
||||
'LI': outdentLI,
|
||||
defaultAction: this.adjustPaddingFunction(false),
|
||||
elements: listElements
|
||||
});
|
||||
|
||||
each(outdented, attemptMergeWithAdjacent);
|
||||
},
|
||||
|
||||
process: function(actions) {
|
||||
var t = this, sel = t.ed.selection, dom = t.ed.dom, selectedBlocks, r;
|
||||
|
||||
function isEmptyElement(element) {
|
||||
var excludeBrsAndBookmarks = tinymce.grep(element.childNodes, function(n) {
|
||||
return !(n.nodeName === 'BR' || n.nodeName === 'SPAN' && dom.getAttrib(n, 'data-mce-type') == 'bookmark'
|
||||
|| n.nodeType == 3 && (n.nodeValue == String.fromCharCode(160) || n.nodeValue == ''));
|
||||
});
|
||||
return excludeBrsAndBookmarks.length === 0;
|
||||
}
|
||||
|
||||
function processElement(element) {
|
||||
dom.removeClass(element, '_mce_act_on');
|
||||
if (!element || element.nodeType !== 1 || selectedBlocks.length > 1 && isEmptyElement(element)) {
|
||||
return;
|
||||
}
|
||||
element = findItemToOperateOn(element, dom);
|
||||
var action = actions[element.tagName];
|
||||
if (!action) {
|
||||
action = actions.defaultAction;
|
||||
}
|
||||
action(element);
|
||||
}
|
||||
|
||||
function recurse(element) {
|
||||
t.splitSafeEach(element.childNodes, processElement);
|
||||
}
|
||||
|
||||
function brAtEdgeOfSelection(container, offset) {
|
||||
return offset >= 0 && container.hasChildNodes() && offset < container.childNodes.length &&
|
||||
container.childNodes[offset].tagName === 'BR';
|
||||
}
|
||||
|
||||
function isInTable() {
|
||||
var n = sel.getNode();
|
||||
var p = dom.getParent(n, 'td');
|
||||
return p !== null;
|
||||
}
|
||||
|
||||
selectedBlocks = actions.elements;
|
||||
|
||||
r = sel.getRng(true);
|
||||
if (!r.collapsed) {
|
||||
if (brAtEdgeOfSelection(r.endContainer, r.endOffset - 1)) {
|
||||
r.setEnd(r.endContainer, r.endOffset - 1);
|
||||
sel.setRng(r);
|
||||
}
|
||||
if (brAtEdgeOfSelection(r.startContainer, r.startOffset)) {
|
||||
r.setStart(r.startContainer, r.startOffset + 1);
|
||||
sel.setRng(r);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (tinymce.isIE8) {
|
||||
// append a zero sized nbsp so that caret is restored correctly using bookmark
|
||||
var s = t.ed.selection.getNode();
|
||||
if (s.tagName === 'LI' && !(s.parentNode.lastChild === s)) {
|
||||
var i = t.ed.getDoc().createTextNode('\uFEFF');
|
||||
s.appendChild(i);
|
||||
}
|
||||
}
|
||||
|
||||
bookmark = sel.getBookmark();
|
||||
actions.OL = actions.UL = recurse;
|
||||
t.splitSafeEach(selectedBlocks, processElement);
|
||||
sel.moveToBookmark(bookmark);
|
||||
bookmark = null;
|
||||
|
||||
// we avoid doing repaint in a table as this will move the caret out of the table in Firefox 3.6
|
||||
if (!isInTable()) {
|
||||
// Avoids table or image handles being left behind in Firefox.
|
||||
t.ed.execCommand('mceRepaint');
|
||||
}
|
||||
},
|
||||
|
||||
splitSafeEach: function(elements, f) {
|
||||
if (tinymce.isGecko && (/Firefox\/[12]\.[0-9]/.test(navigator.userAgent) ||
|
||||
/Firefox\/3\.[0-4]/.test(navigator.userAgent))) {
|
||||
this.classBasedEach(elements, f);
|
||||
} else {
|
||||
each(elements, f);
|
||||
}
|
||||
},
|
||||
|
||||
classBasedEach: function(elements, f) {
|
||||
var dom = this.ed.dom, nodes, element;
|
||||
// Mark nodes
|
||||
each(elements, function(element) {
|
||||
dom.addClass(element, '_mce_act_on');
|
||||
});
|
||||
nodes = dom.select('._mce_act_on');
|
||||
while (nodes.length > 0) {
|
||||
element = nodes.shift();
|
||||
dom.removeClass(element, '_mce_act_on');
|
||||
f(element);
|
||||
nodes = dom.select('._mce_act_on');
|
||||
}
|
||||
},
|
||||
|
||||
adjustPaddingFunction: function(isIndent) {
|
||||
var indentAmount, indentUnits, ed = this.ed;
|
||||
indentAmount = ed.settings.indentation;
|
||||
indentUnits = /[a-z%]+/i.exec(indentAmount);
|
||||
indentAmount = parseInt(indentAmount, 10);
|
||||
return function(element) {
|
||||
var currentIndent, newIndentAmount;
|
||||
currentIndent = parseInt(ed.dom.getStyle(element, 'margin-left') || 0, 10) + parseInt(ed.dom.getStyle(element, 'padding-left') || 0, 10);
|
||||
if (isIndent) {
|
||||
newIndentAmount = currentIndent + indentAmount;
|
||||
} else {
|
||||
newIndentAmount = currentIndent - indentAmount;
|
||||
}
|
||||
ed.dom.setStyle(element, 'padding-left', '');
|
||||
ed.dom.setStyle(element, 'margin-left', newIndentAmount > 0 ? newIndentAmount + indentUnits : '');
|
||||
};
|
||||
},
|
||||
|
||||
selectedBlocks: function() {
|
||||
var ed = this.ed
|
||||
var selectedBlocks = ed.selection.getSelectedBlocks();
|
||||
return selectedBlocks.length == 0 ? [ ed.dom.getRoot() ] : selectedBlocks;
|
||||
},
|
||||
|
||||
getInfo: function() {
|
||||
return {
|
||||
longname : 'Lists',
|
||||
author : 'Moxiecode Systems AB',
|
||||
authorurl : 'http://tinymce.moxiecode.com',
|
||||
infourl : 'http://wiki.moxiecode.com/index.php/TinyMCE:Plugins/lists',
|
||||
version : tinymce.majorVersion + "." + tinymce.minorVersion
|
||||
};
|
||||
}
|
||||
});
|
||||
tinymce.PluginManager.add("lists", tinymce.plugins.Lists);
|
||||
}());
|
||||
|
|
|
|||
File diff suppressed because one or more lines are too long
|
|
@ -261,12 +261,96 @@
|
|||
selection.collapse(start);
|
||||
}
|
||||
|
||||
function canDelete(backspace) {
|
||||
var rng, container, offset, nonEditableParent;
|
||||
|
||||
function removeNodeIfNotParent(node) {
|
||||
var parent = container;
|
||||
|
||||
while (parent) {
|
||||
if (parent === node) {
|
||||
return;
|
||||
}
|
||||
|
||||
parent = parent.parentNode;
|
||||
}
|
||||
|
||||
dom.remove(node);
|
||||
moveSelection();
|
||||
}
|
||||
|
||||
function isNextPrevTreeNodeNonEditable() {
|
||||
var node, walker, nonEmptyElements = ed.schema.getNonEmptyElements();
|
||||
|
||||
walker = new tinymce.dom.TreeWalker(container, ed.getBody());
|
||||
while (node = (backspace ? walker.prev() : walker.next())) {
|
||||
// Found IMG/INPUT etc
|
||||
if (nonEmptyElements[node.nodeName.toLowerCase()]) {
|
||||
break;
|
||||
}
|
||||
|
||||
// Found text node with contents
|
||||
if (node.nodeType === 3 && tinymce.trim(node.nodeValue).length > 0) {
|
||||
break;
|
||||
}
|
||||
|
||||
// Found non editable node
|
||||
if (getContentEditable(node) === "false") {
|
||||
removeNodeIfNotParent(node);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
// Check if the content node is within a non editable parent
|
||||
if (getNonEditableParent(node)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
if (selection.isCollapsed()) {
|
||||
rng = selection.getRng(true);
|
||||
container = rng.startContainer;
|
||||
offset = rng.startOffset;
|
||||
container = getParentCaretContainer(container) || container;
|
||||
|
||||
// Is in noneditable parent
|
||||
if (nonEditableParent = getNonEditableParent(container)) {
|
||||
removeNodeIfNotParent(nonEditableParent);
|
||||
return false;
|
||||
}
|
||||
|
||||
// Check if the caret is in the middle of a text node
|
||||
if (container.nodeType == 3 && (backspace ? offset > 0 : offset < container.nodeValue.length)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// Resolve container index
|
||||
if (container.nodeType == 1) {
|
||||
container = container.childNodes[offset] || container;
|
||||
}
|
||||
|
||||
// Check if previous or next tree node is non editable then block the event
|
||||
if (isNextPrevTreeNodeNonEditable()) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
startElement = selection.getStart()
|
||||
endElement = selection.getEnd();
|
||||
|
||||
// Disable all key presses in contentEditable=false except delete or backspace
|
||||
nonEditableParent = getNonEditableParent(startElement) || getNonEditableParent(endElement);
|
||||
if (nonEditableParent && (keyCode < 112 || keyCode > 124) && keyCode != VK.DELETE && keyCode != VK.BACKSPACE) {
|
||||
// Is Ctrl+c, Ctrl+v or Ctrl+x then use default browser behavior
|
||||
if ((tinymce.isMac ? e.metaKey : e.ctrlKey) && (keyCode == 67 || keyCode == 88 || keyCode == 86)) {
|
||||
return;
|
||||
}
|
||||
|
||||
e.preventDefault();
|
||||
|
||||
// Arrow left/right select the element and collapse left/right
|
||||
|
|
@ -298,6 +382,7 @@
|
|||
positionCaretOnElement(nonEditableParent, true);
|
||||
} else {
|
||||
dom.remove(nonEditableParent);
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
removeCaretContainer(caretContainer);
|
||||
|
|
@ -315,23 +400,31 @@
|
|||
positionCaretOnElement(nonEditableParent, false);
|
||||
} else {
|
||||
dom.remove(nonEditableParent);
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
removeCaretContainer(caretContainer);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ((keyCode == VK.BACKSPACE || keyCode == VK.DELETE) && !canDelete(keyCode == VK.BACKSPACE)) {
|
||||
e.preventDefault();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
ed.onMouseDown.addToTop(function(ed, e){
|
||||
// prevent collapsing selection to caret when clicking in a non-editable section
|
||||
ed.onMouseDown.addToTop(function(ed, e) {
|
||||
var node = ed.selection.getNode();
|
||||
|
||||
if (getContentEditable(node) === "false" && node == e.target) {
|
||||
e.preventDefault();
|
||||
// Expand selection on mouse down we can't block the default event since it's used for drag/drop
|
||||
moveSelection();
|
||||
}
|
||||
});
|
||||
|
||||
ed.onMouseUp.addToTop(moveSelection);
|
||||
ed.onKeyDown.addToTop(handleKey);
|
||||
ed.onKeyUp.addToTop(moveSelection);
|
||||
|
|
@ -341,6 +434,31 @@
|
|||
init : function(ed, url) {
|
||||
var editClass, nonEditClass, nonEditableRegExps;
|
||||
|
||||
// Converts configured regexps to noneditable span items
|
||||
function convertRegExpsToNonEditable(ed, args) {
|
||||
var i = nonEditableRegExps.length, content = args.content, cls = tinymce.trim(nonEditClass);
|
||||
|
||||
// Don't replace the variables when raw is used for example on undo/redo
|
||||
if (args.format == "raw") {
|
||||
return;
|
||||
}
|
||||
|
||||
while (i--) {
|
||||
content = content.replace(nonEditableRegExps[i], function(match) {
|
||||
var args = arguments, index = args[args.length - 2];
|
||||
|
||||
// Is value inside an attribute then don't replace
|
||||
if (index > 0 && content.charAt(index - 1) == '"') {
|
||||
return match;
|
||||
}
|
||||
|
||||
return '<span class="' + cls + '" data-mce-content="' + ed.dom.encode(args[0]) + '">' + ed.dom.encode(typeof(args[1]) === "string" ? args[1] : args[0]) + '</span>';
|
||||
});
|
||||
}
|
||||
|
||||
args.content = content;
|
||||
};
|
||||
|
||||
editClass = " " + tinymce.trim(ed.getParam("noneditable_editable_class", "mceEditable")) + " ";
|
||||
nonEditClass = " " + tinymce.trim(ed.getParam("noneditable_noneditable_class", "mceNonEditable")) + " ";
|
||||
|
||||
|
|
@ -354,26 +472,10 @@
|
|||
handleContentEditableSelection(ed);
|
||||
|
||||
if (nonEditableRegExps) {
|
||||
ed.onBeforeSetContent.add(function(ed, args) {
|
||||
var i = nonEditableRegExps.length, content = args.content, cls = tinymce.trim(nonEditClass);
|
||||
|
||||
// Don't replace the variables when raw is used for example on undo/redo
|
||||
if (args.format == "raw") {
|
||||
return;
|
||||
}
|
||||
|
||||
while (i--) {
|
||||
content = content.replace(nonEditableRegExps[i], function() {
|
||||
var args = arguments;
|
||||
|
||||
return '<span class="' + cls + '" data-mce-content="' + ed.dom.encode(args[0]) + '">' + ed.dom.encode(typeof(args[1]) === "string" ? args[1] : args[0]) + '</span>';
|
||||
});
|
||||
}
|
||||
|
||||
args.content = content;
|
||||
});
|
||||
ed.selection.onBeforeSetContent.add(convertRegExpsToNonEditable);
|
||||
ed.onBeforeSetContent.add(convertRegExpsToNonEditable);
|
||||
}
|
||||
|
||||
|
||||
// Apply contentEditable true/false on elements with the noneditable/editable classes
|
||||
ed.parser.addAttributeFilter('class', function(nodes) {
|
||||
var i = nodes.length, className, node;
|
||||
|
|
|
|||
File diff suppressed because one or more lines are too long
|
|
@ -359,7 +359,7 @@
|
|||
}
|
||||
|
||||
// IE9 adds BRs before/after block elements when contents is pasted from word or for example another browser
|
||||
if (tinymce.isIE && document.documentMode >= 9) {
|
||||
if (tinymce.isIE && document.documentMode >= 9 && /<(h[1-6r]|p|div|address|pre|form|table|tbody|thead|tfoot|th|tr|td|li|ol|ul|caption|blockquote|center|dl|dt|dd|dir|fieldset)/.test(o.content)) {
|
||||
// IE9 adds BRs before/after block elements when contents is pasted from word or for example another browser
|
||||
process([[/(?:<br> [\s\r\n]+|<br>)*(<\/?(h[1-6r]|p|div|address|pre|form|table|tbody|thead|tfoot|th|tr|td|li|ol|ul|caption|blockquote|center|dl|dt|dd|dir|fieldset)[^>]*>)(?:<br> [\s\r\n]+|<br>)*/g, '$1']]);
|
||||
|
||||
|
|
|
|||
|
|
@ -1 +1 @@
|
|||
(function(){var c=tinymce.DOM,a=tinymce.dom.Event,d=tinymce.each,b=tinymce.explode;tinymce.create("tinymce.plugins.TabFocusPlugin",{init:function(f,g){function e(i,j){if(j.keyCode===9){return a.cancel(j)}}function h(l,p){var j,m,o,n,k;function q(t){n=c.select(":input:enabled,*[tabindex]");function s(v){return v.nodeName==="BODY"||(v.type!="hidden"&&!(v.style.display=="none")&&!(v.style.visibility=="hidden")&&s(v.parentNode))}function i(v){return v.attributes.tabIndex.specified||v.nodeName=="INPUT"||v.nodeName=="TEXTAREA"}function u(){return tinymce.isIE6||tinymce.isIE7}function r(v){return((!u()||i(v)))&&v.getAttribute("tabindex")!="-1"&&s(v)}d(n,function(w,v){if(w.id==l.id){j=v;return false}});if(t>0){for(m=j+1;m<n.length;m++){if(r(n[m])){return n[m]}}}else{for(m=j-1;m>=0;m--){if(r(n[m])){return n[m]}}}return null}if(p.keyCode===9){k=b(l.getParam("tab_focus",l.getParam("tabfocus_elements",":prev,:next")));if(k.length==1){k[1]=k[0];k[0]=":prev"}if(p.shiftKey){if(k[0]==":prev"){n=q(-1)}else{n=c.get(k[0])}}else{if(k[1]==":next"){n=q(1)}else{n=c.get(k[1])}}if(n){if(n.id&&(l=tinymce.get(n.id||n.name))){l.focus()}else{window.setTimeout(function(){if(!tinymce.isWebKit){window.focus()}n.focus()},10)}return a.cancel(p)}}}f.onKeyUp.add(e);if(tinymce.isGecko){f.onKeyPress.add(h);f.onKeyDown.add(e)}else{f.onKeyDown.add(h)}},getInfo:function(){return{longname:"Tabfocus",author:"Moxiecode Systems AB",authorurl:"http://tinymce.moxiecode.com",infourl:"http://wiki.moxiecode.com/index.php/TinyMCE:Plugins/tabfocus",version:tinymce.majorVersion+"."+tinymce.minorVersion}}});tinymce.PluginManager.add("tabfocus",tinymce.plugins.TabFocusPlugin)})();
|
||||
(function(){var c=tinymce.DOM,a=tinymce.dom.Event,d=tinymce.each,b=tinymce.explode;tinymce.create("tinymce.plugins.TabFocusPlugin",{init:function(f,g){function e(i,j){if(j.keyCode===9){return a.cancel(j)}}function h(l,p){var j,m,o,n,k;function q(t){n=c.select(":input:enabled,*[tabindex]:not(iframe)");function s(v){return v.nodeName==="BODY"||(v.type!="hidden"&&!(v.style.display=="none")&&!(v.style.visibility=="hidden")&&s(v.parentNode))}function i(v){return v.attributes.tabIndex.specified||v.nodeName=="INPUT"||v.nodeName=="TEXTAREA"}function u(){return tinymce.isIE6||tinymce.isIE7}function r(v){return((!u()||i(v)))&&v.getAttribute("tabindex")!="-1"&&s(v)}d(n,function(w,v){if(w.id==l.id){j=v;return false}});if(t>0){for(m=j+1;m<n.length;m++){if(r(n[m])){return n[m]}}}else{for(m=j-1;m>=0;m--){if(r(n[m])){return n[m]}}}return null}if(p.keyCode===9){k=b(l.getParam("tab_focus",l.getParam("tabfocus_elements",":prev,:next")));if(k.length==1){k[1]=k[0];k[0]=":prev"}if(p.shiftKey){if(k[0]==":prev"){n=q(-1)}else{n=c.get(k[0])}}else{if(k[1]==":next"){n=q(1)}else{n=c.get(k[1])}}if(n){if(n.id&&(l=tinymce.get(n.id||n.name))){l.focus()}else{window.setTimeout(function(){if(!tinymce.isWebKit){window.focus()}n.focus()},10)}return a.cancel(p)}}}f.onKeyUp.add(e);if(tinymce.isGecko){f.onKeyPress.add(h);f.onKeyDown.add(e)}else{f.onKeyDown.add(h)}},getInfo:function(){return{longname:"Tabfocus",author:"Moxiecode Systems AB",authorurl:"http://tinymce.moxiecode.com",infourl:"http://wiki.moxiecode.com/index.php/TinyMCE:Plugins/tabfocus",version:tinymce.majorVersion+"."+tinymce.minorVersion}}});tinymce.PluginManager.add("tabfocus",tinymce.plugins.TabFocusPlugin)})();
|
||||
|
|
@ -22,7 +22,7 @@
|
|||
var x, i, f, el, v;
|
||||
|
||||
function find(d) {
|
||||
el = DOM.select(':input:enabled,*[tabindex]');
|
||||
el = DOM.select(':input:enabled,*[tabindex]:not(iframe)');
|
||||
|
||||
function canSelectRecursive(e) {
|
||||
return e.nodeName==="BODY" || (e.type != 'hidden' &&
|
||||
|
|
|
|||
|
|
@ -137,7 +137,7 @@ function updateAction() {
|
|||
do {
|
||||
if (cell == tdElm)
|
||||
break;
|
||||
col += cell.getAttribute("colspan");
|
||||
col += cell.getAttribute("colspan")?cell.getAttribute("colspan"):1;
|
||||
} while ((cell = nextCell(cell)) != null);
|
||||
|
||||
for (var i=0; i<rows.length; i++) {
|
||||
|
|
@ -152,7 +152,7 @@ function updateAction() {
|
|||
cell = updateCell(cell, true);
|
||||
break;
|
||||
}
|
||||
curr += cell.getAttribute("colspan");
|
||||
curr += cell.getAttribute("colspan")?cell.getAttribute("colspan"):1;
|
||||
} while ((cell = nextCell(cell)) != null);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
p, h1, h2, h3, h4, h5, h6, hgroup, aside, div, section, article, blockquote, address, pre {display: block; padding-top: 10px; border: 1px dashed #BBB; background: transparent no-repeat}
|
||||
p, h1, h2, h3, h4, h5, h6, hgroup, aside, div, section, article, address, pre {margin-left: 3px}
|
||||
section, article, address, hgroup, aside {margin: 1em 0 0 3px}
|
||||
p, h1, h2, h3, h4, h5, h6, hgroup, aside, div, section, article, blockquote, address, pre, figure {display: block; padding-top: 10px; border: 1px dashed #BBB; background: transparent no-repeat}
|
||||
p, h1, h2, h3, h4, h5, h6, hgroup, aside, div, section, article, address, pre, figure {margin-left: 3px}
|
||||
section, article, address, hgroup, aside, figure {margin: 0 0 1em 3px}
|
||||
|
||||
p {background-image: url(data:image/gif;base64,R0lGODlhCQAJAJEAAAAAAP///7u7u////yH5BAEAAAMALAAAAAAJAAkAAAIQnG+CqCN/mlyvsRUpThG6AgA7)}
|
||||
h1 {background-image: url(data:image/gif;base64,R0lGODlhDQAKAIABALu7u////yH5BAEAAAEALAAAAAANAAoAAAIXjI8GybGu1JuxHoAfRNRW3TWXyF2YiRUAOw==)}
|
||||
|
|
@ -17,3 +17,5 @@ address {background-image: url(data:image/gif;base64,R0lGODlhLQAKAIABALu7u////yH
|
|||
pre {background-image: url(data:image/gif;base64,R0lGODlhFQAKAIABALu7uwAAACH5BAEAAAEALAAAAAAVAAoAAAIjjI+ZoN0cgDwSmnpz1NCueYERhnibZVKLNnbOq8IvKpJtVQAAOw==)}
|
||||
hgroup {background-image: url(data:image/gif;base64,R0lGODlhJwAKAIABALu7uwAAACH5BAEAAAEALAAAAAAnAAoAAAI3jI+pywYNI3uB0gpsRtt5fFnfNZaVSYJil4Wo03Hv6Z62uOCgiXH1kZIIJ8NiIxRrAZNMZAtQAAA7)}
|
||||
aside {background-image: url(data:image/gif;base64,R0lGODlhHgAKAIABAKqqqv///yH5BAEAAAEALAAAAAAeAAoAAAItjI+pG8APjZOTzgtqy7I3f1yehmQcFY4WKZbqByutmW4aHUd6vfcVbgudgpYCADs=)}
|
||||
figure {background-image: url(data:image/gif;base64,R0lGODlhJAAKAIAAALu7u////yH5BAEAAAEALAAAAAAkAAoAAAI0jI+py+2fwAHUSFvD3RlvG4HIp4nX5JFSpnZUJ6LlrM52OE7uSWosBHScgkSZj7dDKnWAAgA7)}
|
||||
figcaption {border: 1px dashed #BBB}
|
||||
|
|
|
|||
|
|
@ -1 +1 @@
|
|||
(function(){tinymce.create("tinymce.plugins.VisualBlocks",{init:function(a,b){var c;if(!window.NodeList){return}a.addCommand("mceVisualBlocks",function(){var e=a.dom,d;if(!c){c=e.uniqueId();d=e.create("link",{id:c,rel:"stylesheet",href:b+"/css/visualblocks.css"});a.getDoc().getElementsByTagName("head")[0].appendChild(d)}else{d=e.get(c);d.disabled=!d.disabled}a.controlManager.setActive("visualblocks",!d.disabled)});a.addButton("visualblocks",{title:"visualblocks.desc",cmd:"mceVisualBlocks"});a.onInit.add(function(){if(a.settings.visualblocks_default_state){a.execCommand("mceVisualBlocks")}})},getInfo:function(){return{longname:"Visual blocks",author:"Moxiecode Systems AB",authorurl:"http://tinymce.moxiecode.com",infourl:"http://wiki.moxiecode.com/index.php/TinyMCE:Plugins/visualblocks",version:tinymce.majorVersion+"."+tinymce.minorVersion}}});tinymce.PluginManager.add("visualblocks",tinymce.plugins.VisualBlocks)})();
|
||||
(function(){tinymce.create("tinymce.plugins.VisualBlocks",{init:function(a,b){var c;if(!window.NodeList){return}a.addCommand("mceVisualBlocks",function(){var e=a.dom,d;if(!c){c=e.uniqueId();d=e.create("link",{id:c,rel:"stylesheet",href:b+"/css/visualblocks.css"});a.getDoc().getElementsByTagName("head")[0].appendChild(d)}else{d=e.get(c);d.disabled=!d.disabled}a.controlManager.setActive("visualblocks",!d.disabled)});a.addButton("visualblocks",{title:"visualblocks.desc",cmd:"mceVisualBlocks"});a.onInit.add(function(){if(a.settings.visualblocks_default_state){a.execCommand("mceVisualBlocks",false,null,{skip_focus:true})}})},getInfo:function(){return{longname:"Visual blocks",author:"Moxiecode Systems AB",authorurl:"http://tinymce.moxiecode.com",infourl:"http://wiki.moxiecode.com/index.php/TinyMCE:Plugins/visualblocks",version:tinymce.majorVersion+"."+tinymce.minorVersion}}});tinymce.PluginManager.add("visualblocks",tinymce.plugins.VisualBlocks)})();
|
||||
|
|
@ -42,7 +42,7 @@
|
|||
|
||||
ed.onInit.add(function() {
|
||||
if (ed.settings.visualblocks_default_state) {
|
||||
ed.execCommand('mceVisualBlocks');
|
||||
ed.execCommand('mceVisualBlocks', false, null, {skip_focus : true});
|
||||
}
|
||||
});
|
||||
},
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue