Fixes #35876.

git-svn-id: https://develop.svn.wordpress.org/trunk@36589 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Andrew Ozz 2016-02-19 19:18:59 +00:00
parent ca008e9f51
commit 218c1240b8
33 changed files with 3103 additions and 2218 deletions

File diff suppressed because one or more lines are too long

View File

@ -1 +1 @@
tinymce.PluginManager.add("colorpicker",function(e){function t(t,n){function r(e){var t=new tinymce.util.Color(e),n=t.toRgb();o.fromJSON({r:n.r,g:n.g,b:n.b,hex:t.toHex().substr(1)}),i(t.toHex())}function i(e){o.find("#preview")[0].getEl().style.background=e}var o=e.windowManager.open({title:"Color",items:{type:"container",layout:"flex",direction:"row",align:"stretch",padding:5,spacing:10,items:[{type:"colorpicker",value:n,onchange:function(){var e=this.rgb();o&&(o.find("#r").value(e.r),o.find("#g").value(e.g),o.find("#b").value(e.b),o.find("#hex").value(this.value().substr(1)),i(this.value()))}},{type:"form",padding:0,labelGap:5,defaults:{type:"textbox",size:7,value:"0",flex:1,spellcheck:!1,onchange:function(){var e,t,n=o.find("colorpicker")[0];return e=this.name(),t=this.value(),"hex"==e?(t="#"+t,r(t),void n.value(t)):(t={r:o.find("#r").value(),g:o.find("#g").value(),b:o.find("#b").value()},n.value(t),void r(t))}},items:[{name:"r",label:"R",autofocus:1},{name:"g",label:"G"},{name:"b",label:"B"},{name:"hex",label:"#",value:"000000"},{name:"preview",type:"container",border:1}]}]},onSubmit:function(){t("#"+this.toJSON().hex)}});r(n)}e.settings.color_picker_callback||(e.settings.color_picker_callback=t)});
tinymce.PluginManager.add("colorpicker",function(a){function b(b,c){function d(a){var b=new tinymce.util.Color(a),c=b.toRgb();f.fromJSON({r:c.r,g:c.g,b:c.b,hex:b.toHex().substr(1)}),e(b.toHex())}function e(a){f.find("#preview")[0].getEl().style.background=a}var f=a.windowManager.open({title:"Color",items:{type:"container",layout:"flex",direction:"row",align:"stretch",padding:5,spacing:10,items:[{type:"colorpicker",value:c,onchange:function(){var a=this.rgb();f&&(f.find("#r").value(a.r),f.find("#g").value(a.g),f.find("#b").value(a.b),f.find("#hex").value(this.value().substr(1)),e(this.value()))}},{type:"form",padding:0,labelGap:5,defaults:{type:"textbox",size:7,value:"0",flex:1,spellcheck:!1,onchange:function(){var a,b,c=f.find("colorpicker")[0];return a=this.name(),b=this.value(),"hex"==a?(b="#"+b,d(b),void c.value(b)):(b={r:f.find("#r").value(),g:f.find("#g").value(),b:f.find("#b").value()},c.value(b),void d(b))}},items:[{name:"r",label:"R",autofocus:1},{name:"g",label:"G"},{name:"b",label:"B"},{name:"hex",label:"#",value:"000000"},{name:"preview",type:"container",border:1}]}]},onSubmit:function(){b("#"+this.toJSON().hex)}});d(c)}a.settings.color_picker_callback||(a.settings.color_picker_callback=b)});

View File

@ -1 +1 @@
tinymce.PluginManager.add("directionality",function(e){function t(t){var n,r=e.dom,i=e.selection.getSelectedBlocks();i.length&&(n=r.getAttrib(i[0],"dir"),tinymce.each(i,function(e){r.getParent(e.parentNode,"*[dir='"+t+"']",r.getRoot())||(n!=t?r.setAttrib(e,"dir",t):r.setAttrib(e,"dir",null))}),e.nodeChanged())}function n(e){var t=[];return tinymce.each("h1 h2 h3 h4 h5 h6 div p".split(" "),function(n){t.push(n+"[dir="+e+"]")}),t.join(",")}e.addCommand("mceDirectionLTR",function(){t("ltr")}),e.addCommand("mceDirectionRTL",function(){t("rtl")}),e.addButton("ltr",{title:"Left to right",cmd:"mceDirectionLTR",stateSelector:n("ltr")}),e.addButton("rtl",{title:"Right to left",cmd:"mceDirectionRTL",stateSelector:n("rtl")})});
tinymce.PluginManager.add("directionality",function(a){function b(b){var c,d=a.dom,e=a.selection.getSelectedBlocks();e.length&&(c=d.getAttrib(e[0],"dir"),tinymce.each(e,function(a){d.getParent(a.parentNode,"*[dir='"+b+"']",d.getRoot())||(c!=b?d.setAttrib(a,"dir",b):d.setAttrib(a,"dir",null))}),a.nodeChanged())}function c(a){var b=[];return tinymce.each("h1 h2 h3 h4 h5 h6 div p".split(" "),function(c){b.push(c+"[dir="+a+"]")}),b.join(",")}a.addCommand("mceDirectionLTR",function(){b("ltr")}),a.addCommand("mceDirectionRTL",function(){b("rtl")}),a.addButton("ltr",{title:"Left to right",cmd:"mceDirectionLTR",stateSelector:c("ltr")}),a.addButton("rtl",{title:"Right to left",cmd:"mceDirectionRTL",stateSelector:c("rtl")})});

View File

@ -1 +1 @@
tinymce.PluginManager.add("fullscreen",function(e){function t(){var e,t,n=window,r=document,i=r.body;return i.offsetWidth&&(e=i.offsetWidth,t=i.offsetHeight),n.innerWidth&&n.innerHeight&&(e=n.innerWidth,t=n.innerHeight),{w:e,h:t}}function n(){var e=tinymce.DOM.getViewPort();return{x:e.x,y:e.y}}function r(e){scrollTo(e.x,e.y)}function i(){function i(){f.setStyle(p,"height",t().h-(m.clientHeight-p.clientHeight))}var h,m,p,g,v=document.body,y=document.documentElement;d=!d,m=e.getContainer(),h=m.style,p=e.getContentAreaContainer().firstChild,g=p.style,d?(u=n(),o=g.width,a=g.height,g.width=g.height="100%",l=h.width,c=h.height,h.width=h.height="",f.addClass(v,"mce-fullscreen"),f.addClass(y,"mce-fullscreen"),f.addClass(m,"mce-fullscreen"),f.bind(window,"resize",i),i(),s=i):(g.width=o,g.height=a,l&&(h.width=l),c&&(h.height=c),f.removeClass(v,"mce-fullscreen"),f.removeClass(y,"mce-fullscreen"),f.removeClass(m,"mce-fullscreen"),f.unbind(window,"resize",s),r(u)),e.fire("FullscreenStateChanged",{state:d})}var o,a,s,l,c,u,d=!1,f=tinymce.DOM;return e.settings.inline?void 0:(e.on("init",function(){e.addShortcut("Meta+Alt+F","",i)}),e.on("remove",function(){s&&f.unbind(window,"resize",s)}),e.addCommand("mceFullScreen",i),e.addMenuItem("fullscreen",{text:"Fullscreen",shortcut:"Meta+Alt+F",selectable:!0,onClick:i,onPostRender:function(){var t=this;e.on("FullscreenStateChanged",function(e){t.active(e.state)})},context:"view"}),e.addButton("fullscreen",{tooltip:"Fullscreen",shortcut:"Meta+Alt+F",onClick:i,onPostRender:function(){var t=this;e.on("FullscreenStateChanged",function(e){t.active(e.state)})}}),{isFullscreen:function(){return d}})});
tinymce.PluginManager.add("fullscreen",function(a){function b(){var a,b,c=window,d=document,e=d.body;return e.offsetWidth&&(a=e.offsetWidth,b=e.offsetHeight),c.innerWidth&&c.innerHeight&&(a=c.innerWidth,b=c.innerHeight),{w:a,h:b}}function c(){var a=tinymce.DOM.getViewPort();return{x:a.x,y:a.y}}function d(a){scrollTo(a.x,a.y)}function e(){function e(){m.setStyle(p,"height",b().h-(o.clientHeight-p.clientHeight))}var n,o,p,q,r=document.body,s=document.documentElement;l=!l,o=a.getContainer(),n=o.style,p=a.getContentAreaContainer().firstChild,q=p.style,l?(k=c(),f=q.width,g=q.height,q.width=q.height="100%",i=n.width,j=n.height,n.width=n.height="",m.addClass(r,"mce-fullscreen"),m.addClass(s,"mce-fullscreen"),m.addClass(o,"mce-fullscreen"),m.bind(window,"resize",e),e(),h=e):(q.width=f,q.height=g,i&&(n.width=i),j&&(n.height=j),m.removeClass(r,"mce-fullscreen"),m.removeClass(s,"mce-fullscreen"),m.removeClass(o,"mce-fullscreen"),m.unbind(window,"resize",h),d(k)),a.fire("FullscreenStateChanged",{state:l})}var f,g,h,i,j,k,l=!1,m=tinymce.DOM;return a.settings.inline?void 0:(a.on("init",function(){a.addShortcut("Meta+Alt+F","",e)}),a.on("remove",function(){h&&m.unbind(window,"resize",h)}),a.addCommand("mceFullScreen",e),a.addMenuItem("fullscreen",{text:"Fullscreen",shortcut:"Meta+Alt+F",selectable:!0,onClick:e,onPostRender:function(){var b=this;a.on("FullscreenStateChanged",function(a){b.active(a.state)})},context:"view"}),a.addButton("fullscreen",{tooltip:"Fullscreen",shortcut:"Meta+Alt+F",onClick:e,onPostRender:function(){var b=this;a.on("FullscreenStateChanged",function(a){b.active(a.state)})}}),{isFullscreen:function(){return l}})});

View File

@ -1 +1 @@
tinymce.PluginManager.add("hr",function(e){e.addCommand("InsertHorizontalRule",function(){e.execCommand("mceInsertContent",!1,"<hr />")}),e.addButton("hr",{icon:"hr",tooltip:"Horizontal line",cmd:"InsertHorizontalRule"}),e.addMenuItem("hr",{icon:"hr",text:"Horizontal line",cmd:"InsertHorizontalRule",context:"insert"})});
tinymce.PluginManager.add("hr",function(a){a.addCommand("InsertHorizontalRule",function(){a.execCommand("mceInsertContent",!1,"<hr />")}),a.addButton("hr",{icon:"hr",tooltip:"Horizontal line",cmd:"InsertHorizontalRule"}),a.addMenuItem("hr",{icon:"hr",text:"Horizontal line",cmd:"InsertHorizontalRule",context:"insert"})});

View File

@ -14,8 +14,16 @@
tinymce.PluginManager.add('lists', function(editor) {
var self = this;
function isChildOfBody(elm) {
return editor.$.contains(editor.getBody(), elm);
}
function isBr(node) {
return node && node.nodeName == 'BR';
}
function isListNode(node) {
return node && (/^(OL|UL|DL)$/).test(node.nodeName);
return node && (/^(OL|UL|DL)$/).test(node.nodeName) && isChildOfBody(node);
}
function isFirstChild(node) {
@ -558,8 +566,8 @@ tinymce.PluginManager.add('lists', function(editor) {
return;
}
if (dom.isBlock(node) || node.nodeName == 'BR') {
if (node.nodeName == 'BR') {
if (dom.isBlock(node) || isBr(node)) {
if (isBr(node)) {
dom.remove(node);
}
@ -665,6 +673,18 @@ tinymce.PluginManager.add('lists', function(editor) {
};
}
function isBogusBr(node) {
if (!isBr(node)) {
return false;
}
if (dom.isBlock(node.nextSibling) && !isBr(node.previousSibling)) {
return true;
}
return false;
}
self.backspaceDelete = function(isForward) {
function findNextCaretContainer(rng, isForward) {
var node = rng.startContainer, offset = rng.startOffset;
@ -675,9 +695,16 @@ tinymce.PluginManager.add('lists', function(editor) {
}
nonEmptyBlocks = editor.schema.getNonEmptyElements();
walker = new tinymce.dom.TreeWalker(rng.startContainer);
walker = new tinymce.dom.TreeWalker(rng.startContainer, editor.getBody());
while ((node = walker[isForward ? 'next' : 'prev']())) {
// Delete at <li>|<br></li> then jump over the bogus br
if (isForward) {
if (isBogusBr(tinymce.dom.RangeUtils.getNode(rng.startContainer, rng.startOffset))) {
walker.next();
}
}
while ((node = walker[isForward ? 'next' : 'prev2']())) {
if (node.nodeName == 'LI' && !node.hasChildNodes()) {
return node;
}
@ -695,12 +722,22 @@ tinymce.PluginManager.add('lists', function(editor) {
function mergeLiElements(fromElm, toElm) {
var node, listNode, ul = fromElm.parentNode;
if (!isChildOfBody(fromElm) || !isChildOfBody(toElm)) {
return;
}
if (isListNode(toElm.lastChild)) {
listNode = toElm.lastChild;
}
if (ul == toElm.lastChild) {
if (isBr(ul.previousSibling)) {
dom.remove(ul.previousSibling);
}
}
node = toElm.lastChild;
if (node && node.nodeName == 'BR' && fromElm.hasChildNodes()) {
if (node && isBr(node) && fromElm.hasChildNodes()) {
dom.remove(node);
}

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -1 +1 @@
tinymce.PluginManager.add("tabfocus",function(e){function t(e){9!==e.keyCode||e.ctrlKey||e.altKey||e.metaKey||e.preventDefault()}function n(t){function n(n){function o(e){return"BODY"===e.nodeName||"hidden"!=e.type&&"none"!=e.style.display&&"hidden"!=e.style.visibility&&o(e.parentNode)}function l(e){return/INPUT|TEXTAREA|BUTTON/.test(e.tagName)&&tinymce.get(t.id)&&-1!=e.tabIndex&&o(e)}if(s=r.select(":input:enabled,*[tabindex]:not(iframe)"),i(s,function(t,n){return t.id==e.id?(a=n,!1):void 0}),n>0){for(c=a+1;c<s.length;c++)if(l(s[c]))return s[c]}else for(c=a-1;c>=0;c--)if(l(s[c]))return s[c];return null}var a,s,l,c;if(!(9!==t.keyCode||t.ctrlKey||t.altKey||t.metaKey||t.isDefaultPrevented())&&(l=o(e.getParam("tab_focus",e.getParam("tabfocus_elements",":prev,:next"))),1==l.length&&(l[1]=l[0],l[0]=":prev"),s=t.shiftKey?":prev"==l[0]?n(-1):r.get(l[0]):":next"==l[1]?n(1):r.get(l[1]))){var u=tinymce.get(s.id||s.name);s.id&&u?u.focus():tinymce.util.Delay.setTimeout(function(){tinymce.Env.webkit||window.focus(),s.focus()},10),t.preventDefault()}}var r=tinymce.DOM,i=tinymce.each,o=tinymce.explode;e.on("init",function(){e.inline&&tinymce.DOM.setAttrib(e.getBody(),"tabIndex",null),e.on("keyup",t),tinymce.Env.gecko?e.on("keypress keydown",n):e.on("keydown",n)})});
tinymce.PluginManager.add("tabfocus",function(a){function b(a){9!==a.keyCode||a.ctrlKey||a.altKey||a.metaKey||a.preventDefault()}function c(b){function c(c){function f(a){return"BODY"===a.nodeName||"hidden"!=a.type&&"none"!=a.style.display&&"hidden"!=a.style.visibility&&f(a.parentNode)}function i(a){return/INPUT|TEXTAREA|BUTTON/.test(a.tagName)&&tinymce.get(b.id)&&-1!=a.tabIndex&&f(a)}if(h=d.select(":input:enabled,*[tabindex]:not(iframe)"),e(h,function(b,c){return b.id==a.id?(g=c,!1):void 0}),c>0){for(j=g+1;j<h.length;j++)if(i(h[j]))return h[j]}else for(j=g-1;j>=0;j--)if(i(h[j]))return h[j];return null}var g,h,i,j;if(!(9!==b.keyCode||b.ctrlKey||b.altKey||b.metaKey||b.isDefaultPrevented())&&(i=f(a.getParam("tab_focus",a.getParam("tabfocus_elements",":prev,:next"))),1==i.length&&(i[1]=i[0],i[0]=":prev"),h=b.shiftKey?":prev"==i[0]?c(-1):d.get(i[0]):":next"==i[1]?c(1):d.get(i[1]))){var k=tinymce.get(h.id||h.name);h.id&&k?k.focus():tinymce.util.Delay.setTimeout(function(){tinymce.Env.webkit||window.focus(),h.focus()},10),b.preventDefault()}}var d=tinymce.DOM,e=tinymce.each,f=tinymce.explode;a.on("init",function(){a.inline&&tinymce.DOM.setAttrib(a.getBody(),"tabIndex",null),a.on("keyup",b),tinymce.Env.gecko?a.on("keypress keydown",c):a.on("keydown",c)})});

View File

@ -1 +1 @@
tinymce.PluginManager.add("textcolor",function(e){function t(t){var n;return e.dom.getParents(e.selection.getStart(),function(e){var r;(r=e.style["forecolor"==t?"color":"background-color"])&&(n=r)}),n}function n(){var t,n,r=[];for(n=e.settings.textcolor_map||["000000","Black","993300","Burnt orange","333300","Dark olive","003300","Dark green","003366","Dark azure","000080","Navy Blue","333399","Indigo","333333","Very dark gray","800000","Maroon","FF6600","Orange","808000","Olive","008000","Green","008080","Teal","0000FF","Blue","666699","Grayish blue","808080","Gray","FF0000","Red","FF9900","Amber","99CC00","Yellow green","339966","Sea green","33CCCC","Turquoise","3366FF","Royal blue","800080","Purple","999999","Medium gray","FF00FF","Magenta","FFCC00","Gold","FFFF00","Yellow","00FF00","Lime","00FFFF","Aqua","00CCFF","Sky blue","993366","Red violet","FFFFFF","White","FF99CC","Pink","FFCC99","Peach","FFFF99","Light yellow","CCFFCC","Pale green","CCFFFF","Pale cyan","99CCFF","Light sky blue","CC99FF","Plum"],t=0;t<n.length;t+=2)r.push({text:n[t+1],color:"#"+n[t]});return r}function r(){function t(e,t){var n="transparent"==e;return'<td class="mce-grid-cell'+(n?" mce-colorbtn-trans":"")+'"><div id="'+h+"-"+m++ +'" data-mce-color="'+(e?e:"")+'" role="option" tabIndex="-1" style="'+(e?"background-color: "+e:"")+'" title="'+tinymce.translate(t)+'">'+(n?"&#215;":"")+"</div></td>"}var r,i,o,a,s,u,d,f=this,h=f._id,m=0;for(r=n(),r.push({text:tinymce.translate("No color"),color:"transparent"}),o='<table class="mce-grid mce-grid-border mce-colorbutton-grid" role="list" cellspacing="0"><tbody>',a=r.length-1,u=0;c>u;u++){for(o+="<tr>",s=0;l>s;s++)d=u*l+s,d>a?o+="<td></td>":(i=r[d],o+=t(i.color,i.text));o+="</tr>"}if(e.settings.color_picker_callback){for(o+='<tr><td colspan="'+l+'" class="mce-custom-color-btn"><div id="'+h+'-c" class="mce-widget mce-btn mce-btn-small mce-btn-flat" role="button" tabindex="-1" aria-labelledby="'+h+'-c" style="width: 100%"><button type="button" role="presentation" tabindex="-1">'+tinymce.translate("Custom...")+"</button></div></td></tr>",o+="<tr>",s=0;l>s;s++)o+=t("","Custom color");o+="</tr>"}return o+="</tbody></table>"}function i(t,n){e.undoManager.transact(function(){e.focus(),e.formatter.apply(t,{value:n}),e.nodeChanged()})}function o(t){e.undoManager.transact(function(){e.focus(),e.formatter.remove(t,{value:null},null,!0),e.nodeChanged()})}function a(n){function r(e){u.hidePanel(),u.color(e),i(u.settings.format,e)}function a(){u.hidePanel(),u.resetColor(),o(u.settings.format)}function s(e,t){e.style.background=t,e.setAttribute("data-mce-color",t)}var c,u=this.parent();tinymce.DOM.getParent(n.target,".mce-custom-color-btn")&&(u.hidePanel(),e.settings.color_picker_callback.call(e,function(e){var t,n,i,o=u.panel.getEl().getElementsByTagName("table")[0];for(t=tinymce.map(o.rows[o.rows.length-1].childNodes,function(e){return e.firstChild}),i=0;i<t.length&&(n=t[i],n.getAttribute("data-mce-color"));i++);if(i==l)for(i=0;l-1>i;i++)s(t[i],t[i+1].getAttribute("data-mce-color"));s(n,e),r(e)},t(u.settings.format))),c=n.target.getAttribute("data-mce-color"),c?(this.lastId&&document.getElementById(this.lastId).setAttribute("aria-selected",!1),n.target.setAttribute("aria-selected",!0),this.lastId=n.target.id,"transparent"==c?a():r(c)):null!==c&&u.hidePanel()}function s(){var e=this;e._color?i(e.settings.format,e._color):o(e.settings.format)}var l,c;c=e.settings.textcolor_rows||5,l=e.settings.textcolor_cols||8,e.addButton("forecolor",{type:"colorbutton",tooltip:"Text color",format:"forecolor",panel:{role:"application",ariaRemember:!0,html:r,onclick:a},onclick:s}),e.addButton("backcolor",{type:"colorbutton",tooltip:"Background color",format:"hilitecolor",panel:{role:"application",ariaRemember:!0,html:r,onclick:a},onclick:s})});
tinymce.PluginManager.add("textcolor",function(a){function b(b){var c;return a.dom.getParents(a.selection.getStart(),function(a){var d;(d=a.style["forecolor"==b?"color":"background-color"])&&(c=d)}),c}function c(){var b,c,d=[];for(c=a.settings.textcolor_map||["000000","Black","993300","Burnt orange","333300","Dark olive","003300","Dark green","003366","Dark azure","000080","Navy Blue","333399","Indigo","333333","Very dark gray","800000","Maroon","FF6600","Orange","808000","Olive","008000","Green","008080","Teal","0000FF","Blue","666699","Grayish blue","808080","Gray","FF0000","Red","FF9900","Amber","99CC00","Yellow green","339966","Sea green","33CCCC","Turquoise","3366FF","Royal blue","800080","Purple","999999","Medium gray","FF00FF","Magenta","FFCC00","Gold","FFFF00","Yellow","00FF00","Lime","00FFFF","Aqua","00CCFF","Sky blue","993366","Red violet","FFFFFF","White","FF99CC","Pink","FFCC99","Peach","FFFF99","Light yellow","CCFFCC","Pale green","CCFFFF","Pale cyan","99CCFF","Light sky blue","CC99FF","Plum"],b=0;b<c.length;b+=2)d.push({text:c[b+1],color:"#"+c[b]});return d}function d(){function b(a,b){var c="transparent"==a;return'<td class="mce-grid-cell'+(c?" mce-colorbtn-trans":"")+'"><div id="'+n+"-"+o++ +'" data-mce-color="'+(a?a:"")+'" role="option" tabIndex="-1" style="'+(a?"background-color: "+a:"")+'" title="'+tinymce.translate(b)+'">'+(c?"&#215;":"")+"</div></td>"}var d,e,f,g,h,k,l,m=this,n=m._id,o=0;for(d=c(),d.push({text:tinymce.translate("No color"),color:"transparent"}),f='<table class="mce-grid mce-grid-border mce-colorbutton-grid" role="list" cellspacing="0"><tbody>',g=d.length-1,k=0;j>k;k++){for(f+="<tr>",h=0;i>h;h++)l=k*i+h,l>g?f+="<td></td>":(e=d[l],f+=b(e.color,e.text));f+="</tr>"}if(a.settings.color_picker_callback){for(f+='<tr><td colspan="'+i+'" class="mce-custom-color-btn"><div id="'+n+'-c" class="mce-widget mce-btn mce-btn-small mce-btn-flat" role="button" tabindex="-1" aria-labelledby="'+n+'-c" style="width: 100%"><button type="button" role="presentation" tabindex="-1">'+tinymce.translate("Custom...")+"</button></div></td></tr>",f+="<tr>",h=0;i>h;h++)f+=b("","Custom color");f+="</tr>"}return f+="</tbody></table>"}function e(b,c){a.undoManager.transact(function(){a.focus(),a.formatter.apply(b,{value:c}),a.nodeChanged()})}function f(b){a.undoManager.transact(function(){a.focus(),a.formatter.remove(b,{value:null},null,!0),a.nodeChanged()})}function g(c){function d(a){k.hidePanel(),k.color(a),e(k.settings.format,a)}function g(){k.hidePanel(),k.resetColor(),f(k.settings.format)}function h(a,b){a.style.background=b,a.setAttribute("data-mce-color",b)}var j,k=this.parent();tinymce.DOM.getParent(c.target,".mce-custom-color-btn")&&(k.hidePanel(),a.settings.color_picker_callback.call(a,function(a){var b,c,e,f=k.panel.getEl().getElementsByTagName("table")[0];for(b=tinymce.map(f.rows[f.rows.length-1].childNodes,function(a){return a.firstChild}),e=0;e<b.length&&(c=b[e],c.getAttribute("data-mce-color"));e++);if(e==i)for(e=0;i-1>e;e++)h(b[e],b[e+1].getAttribute("data-mce-color"));h(c,a),d(a)},b(k.settings.format))),j=c.target.getAttribute("data-mce-color"),j?(this.lastId&&document.getElementById(this.lastId).setAttribute("aria-selected",!1),c.target.setAttribute("aria-selected",!0),this.lastId=c.target.id,"transparent"==j?g():d(j)):null!==j&&k.hidePanel()}function h(){var a=this;a._color?e(a.settings.format,a._color):f(a.settings.format)}var i,j;j=a.settings.textcolor_rows||5,i=a.settings.textcolor_cols||8,a.addButton("forecolor",{type:"colorbutton",tooltip:"Text color",format:"forecolor",panel:{role:"application",ariaRemember:!0,html:d,onclick:g},onclick:h}),a.addButton("backcolor",{type:"colorbutton",tooltip:"Background color",format:"hilitecolor",panel:{role:"application",ariaRemember:!0,html:d,onclick:g},onclick:h})});

View File

@ -1 +1 @@
.mce-content-body .mce-reset{margin:0;padding:0;border:0;outline:0;vertical-align:top;background:transparent;text-decoration:none;color:black;font-family:Arial;font-size:11px;text-shadow:none;float:none;position:static;width:auto;height:auto;white-space:nowrap;cursor:inherit;line-height:normal;font-weight:normal;text-align:left;-webkit-tap-highlight-color:transparent;-moz-box-sizing:content-box;-webkit-box-sizing:content-box;box-sizing:content-box;direction:ltr;max-width:none}.mce-object{border:1px dotted #3a3a3a;background:#d5d5d5 url(img/object.gif) no-repeat center}.mce-preview-object{display:inline-block;position:relative;margin:0 2px 0 2px;line-height:0;border:1px solid gray}.mce-preview-object .mce-shim{position:absolute;top:0;left:0;width:100%;height:100%;background:url(data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7)}figure.align-left{float:left}figure.align-right{float:right}figure.image.align-center{display:table;margin-left:auto;margin-right:auto}figure.image{display:inline-block;border:1px solid gray;margin:0 2px 0 1px;background:#f5f2f0}figure.image img{margin:8px 8px 0 8px}figure.image figcaption{margin:6px 8px 6px 8px;text-align:center}.mce-preview-object[data-mce-selected] .mce-shim{display:none}.mce-pagebreak{cursor:default;display:block;border:0;width:100%;height:5px;border:1px dashed #666;margin-top:15px;page-break-before:always}@media print{.mce-pagebreak{border:0}}.mce-item-anchor{cursor:default;display:inline-block;-webkit-user-select:all;-webkit-user-modify:read-only;-moz-user-select:all;-moz-user-modify:read-only;user-select:all;user-modify:read-only;width:9px !important;height:9px !important;border:1px dotted #3a3a3a;background:#d5d5d5 url(img/anchor.gif) no-repeat center}.mce-nbsp,.mce-shy{background:#aaa}.mce-shy::after{content:'-'}hr{cursor:default}.mce-match-marker{background:#aaa;color:#fff}.mce-match-marker-selected{background:#39f;color:#fff}.mce-spellchecker-word{border-bottom:2px solid #f00;cursor:default}.mce-spellchecker-grammar{border-bottom:2px solid #008000;cursor:default}.mce-item-table,.mce-item-table td,.mce-item-table th,.mce-item-table caption{border:1px dashed #bbb}td.mce-item-selected,th.mce-item-selected{background-color:#39f !important}.mce-edit-focus{outline:1px dotted #333}.mce-content-body *[contentEditable=false] *[contentEditable=true]:focus{outline:2px solid #2d8ac7}.mce-content-body *[contentEditable=false] *[contentEditable=true]:hover{outline:2px solid #7acaff}.mce-content-body *[contentEditable=false][data-mce-selected]{outline:2px solid #2d8ac7}.mce-resize-bar-dragging{background-color:blue;opacity:.25;filter:alpha(opacity=25);zoom:1}
.mce-content-body .mce-reset{margin:0;padding:0;border:0;outline:0;vertical-align:top;background:transparent;text-decoration:none;color:black;font-family:Arial;font-size:11px;text-shadow:none;float:none;position:static;width:auto;height:auto;white-space:nowrap;cursor:inherit;line-height:normal;font-weight:normal;text-align:left;-webkit-tap-highlight-color:transparent;-moz-box-sizing:content-box;-webkit-box-sizing:content-box;box-sizing:content-box;direction:ltr;max-width:none}.mce-object{border:1px dotted #3a3a3a;background:#d5d5d5 url(img/object.gif) no-repeat center}.mce-preview-object{display:inline-block;position:relative;margin:0 2px 0 2px;line-height:0;border:1px solid gray}.mce-preview-object .mce-shim{position:absolute;top:0;left:0;width:100%;height:100%;background:url(data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7)}figure.align-left{float:left}figure.align-right{float:right}figure.image.align-center{display:table;margin-left:auto;margin-right:auto}figure.image{display:inline-block;border:1px solid gray;margin:0 2px 0 1px;background:#f5f2f0}figure.image img{margin:8px 8px 0 8px}figure.image figcaption{margin:6px 8px 6px 8px;text-align:center}.mce-preview-object[data-mce-selected] .mce-shim{display:none}.mce-pagebreak{cursor:default;display:block;border:0;width:100%;height:5px;border:1px dashed #666;margin-top:15px;page-break-before:always}@media print{.mce-pagebreak{border:0}}.mce-item-anchor{cursor:default;display:inline-block;-webkit-user-select:all;-webkit-user-modify:read-only;-moz-user-select:all;-moz-user-modify:read-only;user-select:all;user-modify:read-only;width:9px !important;height:9px !important;border:1px dotted #3a3a3a;background:#d5d5d5 url(img/anchor.gif) no-repeat center}.mce-nbsp,.mce-shy{background:#aaa}.mce-shy::after{content:'-'}hr{cursor:default}.mce-match-marker{background:#aaa;color:#fff}.mce-match-marker-selected{background:#39f;color:#fff}.mce-spellchecker-word{border-bottom:2px solid #f00;cursor:default}.mce-spellchecker-grammar{border-bottom:2px solid #008000;cursor:default}.mce-item-table,.mce-item-table td,.mce-item-table th,.mce-item-table caption{border:1px dashed #bbb}td[data-mce-selected],th[data-mce-selected]{background-color:#39f !important}.mce-edit-focus{outline:1px dotted #333}.mce-content-body *[contentEditable=false] *[contentEditable=true]:focus{outline:2px solid #2d8ac7}.mce-content-body *[contentEditable=false] *[contentEditable=true]:hover{outline:2px solid #7acaff}.mce-content-body *[contentEditable=false][data-mce-selected]{outline:2px solid #2d8ac7}.mce-resize-bar-dragging{background-color:blue;opacity:.25;filter:alpha(opacity=25);zoom:1}

View File

@ -1 +1 @@
body{background-color:#fff;color:#000;font-family:Verdana,Arial,Helvetica,sans-serif;font-size:11px;scrollbar-3dlight-color:#f0f0ee;scrollbar-arrow-color:#676662;scrollbar-base-color:#f0f0ee;scrollbar-darkshadow-color:#ddd;scrollbar-face-color:#e0e0dd;scrollbar-highlight-color:#f0f0ee;scrollbar-shadow-color:#f0f0ee;scrollbar-track-color:#f5f5f5}td,th{font-family:Verdana,Arial,Helvetica,sans-serif;font-size:11px}.mce-content-body .mce-reset{margin:0;padding:0;border:0;outline:0;vertical-align:top;background:transparent;text-decoration:none;color:black;font-family:Arial;font-size:11px;text-shadow:none;float:none;position:static;width:auto;height:auto;white-space:nowrap;cursor:inherit;line-height:normal;font-weight:normal;text-align:left;-webkit-tap-highlight-color:transparent;-moz-box-sizing:content-box;-webkit-box-sizing:content-box;box-sizing:content-box;direction:ltr;max-width:none}.mce-object{border:1px dotted #3a3a3a;background:#d5d5d5 url(img/object.gif) no-repeat center}.mce-preview-object{display:inline-block;position:relative;margin:0 2px 0 2px;line-height:0;border:1px solid gray}.mce-preview-object .mce-shim{position:absolute;top:0;left:0;width:100%;height:100%;background:url(data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7)}figure.align-left{float:left}figure.align-right{float:right}figure.image.align-center{display:table;margin-left:auto;margin-right:auto}figure.image{display:inline-block;border:1px solid gray;margin:0 2px 0 1px;background:#f5f2f0}figure.image img{margin:8px 8px 0 8px}figure.image figcaption{margin:6px 8px 6px 8px;text-align:center}.mce-preview-object[data-mce-selected] .mce-shim{display:none}.mce-pagebreak{cursor:default;display:block;border:0;width:100%;height:5px;border:1px dashed #666;margin-top:15px;page-break-before:always}@media print{.mce-pagebreak{border:0}}.mce-item-anchor{cursor:default;display:inline-block;-webkit-user-select:all;-webkit-user-modify:read-only;-moz-user-select:all;-moz-user-modify:read-only;user-select:all;user-modify:read-only;width:9px !important;height:9px !important;border:1px dotted #3a3a3a;background:#d5d5d5 url(img/anchor.gif) no-repeat center}.mce-nbsp,.mce-shy{background:#aaa}.mce-shy::after{content:'-'}hr{cursor:default}.mce-match-marker{background:#aaa;color:#fff}.mce-match-marker-selected{background:#39f;color:#fff}.mce-spellchecker-word{border-bottom:2px solid #f00;cursor:default}.mce-spellchecker-grammar{border-bottom:2px solid #008000;cursor:default}.mce-item-table,.mce-item-table td,.mce-item-table th,.mce-item-table caption{border:1px dashed #bbb}td.mce-item-selected,th.mce-item-selected{background-color:#39f !important}.mce-edit-focus{outline:1px dotted #333}.mce-content-body *[contentEditable=false] *[contentEditable=true]:focus{outline:2px solid #2d8ac7}.mce-content-body *[contentEditable=false] *[contentEditable=true]:hover{outline:2px solid #7acaff}.mce-content-body *[contentEditable=false][data-mce-selected]{outline:2px solid #2d8ac7}.mce-resize-bar-dragging{background-color:blue;opacity:.25;filter:alpha(opacity=25);zoom:1}
body{background-color:#fff;color:#000;font-family:Verdana,Arial,Helvetica,sans-serif;font-size:11px;scrollbar-3dlight-color:#f0f0ee;scrollbar-arrow-color:#676662;scrollbar-base-color:#f0f0ee;scrollbar-darkshadow-color:#ddd;scrollbar-face-color:#e0e0dd;scrollbar-highlight-color:#f0f0ee;scrollbar-shadow-color:#f0f0ee;scrollbar-track-color:#f5f5f5}td,th{font-family:Verdana,Arial,Helvetica,sans-serif;font-size:11px}.mce-content-body .mce-reset{margin:0;padding:0;border:0;outline:0;vertical-align:top;background:transparent;text-decoration:none;color:black;font-family:Arial;font-size:11px;text-shadow:none;float:none;position:static;width:auto;height:auto;white-space:nowrap;cursor:inherit;line-height:normal;font-weight:normal;text-align:left;-webkit-tap-highlight-color:transparent;-moz-box-sizing:content-box;-webkit-box-sizing:content-box;box-sizing:content-box;direction:ltr;max-width:none}.mce-object{border:1px dotted #3a3a3a;background:#d5d5d5 url(img/object.gif) no-repeat center}.mce-preview-object{display:inline-block;position:relative;margin:0 2px 0 2px;line-height:0;border:1px solid gray}.mce-preview-object .mce-shim{position:absolute;top:0;left:0;width:100%;height:100%;background:url(data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7)}figure.align-left{float:left}figure.align-right{float:right}figure.image.align-center{display:table;margin-left:auto;margin-right:auto}figure.image{display:inline-block;border:1px solid gray;margin:0 2px 0 1px;background:#f5f2f0}figure.image img{margin:8px 8px 0 8px}figure.image figcaption{margin:6px 8px 6px 8px;text-align:center}.mce-preview-object[data-mce-selected] .mce-shim{display:none}.mce-pagebreak{cursor:default;display:block;border:0;width:100%;height:5px;border:1px dashed #666;margin-top:15px;page-break-before:always}@media print{.mce-pagebreak{border:0}}.mce-item-anchor{cursor:default;display:inline-block;-webkit-user-select:all;-webkit-user-modify:read-only;-moz-user-select:all;-moz-user-modify:read-only;user-select:all;user-modify:read-only;width:9px !important;height:9px !important;border:1px dotted #3a3a3a;background:#d5d5d5 url(img/anchor.gif) no-repeat center}.mce-nbsp,.mce-shy{background:#aaa}.mce-shy::after{content:'-'}hr{cursor:default}.mce-match-marker{background:#aaa;color:#fff}.mce-match-marker-selected{background:#39f;color:#fff}.mce-spellchecker-word{border-bottom:2px solid #f00;cursor:default}.mce-spellchecker-grammar{border-bottom:2px solid #008000;cursor:default}.mce-item-table,.mce-item-table td,.mce-item-table th,.mce-item-table caption{border:1px dashed #bbb}td[data-mce-selected],th[data-mce-selected]{background-color:#39f !important}.mce-edit-focus{outline:1px dotted #333}.mce-content-body *[contentEditable=false] *[contentEditable=true]:focus{outline:2px solid #2d8ac7}.mce-content-body *[contentEditable=false] *[contentEditable=true]:hover{outline:2px solid #7acaff}.mce-content-body *[contentEditable=false][data-mce-selected]{outline:2px solid #2d8ac7}.mce-resize-bar-dragging{background-color:blue;opacity:.25;filter:alpha(opacity=25);zoom:1}

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -709,7 +709,9 @@ tinymce.ThemeManager.add('modern', function(editor) {
// Preload skin css
if (args.skinUiCss) {
tinymce.DOM.styleSheetLoader.load(args.skinUiCss);
tinymce.DOM.styleSheetLoader.load(args.skinUiCss, function() {
editor.fire('SkinLoaded');
});
}
return {};
@ -735,7 +737,9 @@ tinymce.ThemeManager.add('modern', function(editor) {
}
if (args.skinUiCss) {
tinymce.DOM.loadCSS(args.skinUiCss);
tinymce.DOM.styleSheetLoader.load(args.skinUiCss, function() {
editor.fire('SkinLoaded');
});
}
// Basic UI layout

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

View File

@ -18,7 +18,7 @@ $wp_db_version = 36180;
*
* @global string $tinymce_version
*/
$tinymce_version = '4303-20160205';
$tinymce_version = '4304-20160219';
/**
* Holds the required PHP version

View File

@ -47,6 +47,9 @@
<script src="tinymce/file/Conversions.js"></script>
<script src="tinymce/file/ImageScanner.js"></script>
<!-- tinymce.fmt.* -->
<script src="tinymce/fmt/Hooks.js"></script>
<!-- tinymce.text.* -->
<script src="tinymce/text/ExtendingChar.js"></script>
<script src="tinymce/text/Zwsp.js"></script>
@ -62,6 +65,7 @@
<script src="tinymce/dom/Serializer.js"></script>
<script src="tinymce/dom/TridentSelection.js"></script>
<script src="tinymce/dom/NodePath.js"></script>
<script src="tinymce/dom/TreeWalker.js"></script>
<!-- tinymce.html.* -->
<script src="tinymce/html/DomParser.js"></script>
@ -104,6 +108,8 @@
<script src="tinymce/util/I18n.js"></script>
<script src="tinymce/util/Fun.js"></script>
<script src="tinymce/util/Delay.js"></script>
<script src="tinymce/util/Promise.js"></script>
<script src="tinymce/util/Tools.js"></script>
<!-- tinymce.* -->
<script src="tinymce/AddOnManager.js"></script>
@ -119,6 +125,7 @@
<script src="tinymce/Shortcuts.js"></script>
<script src="tinymce/UndoManager.js"></script>
<script src="tinymce/SelectionOverrides.js"></script>
<script src="tinymce/WindowManager.js"></script>
<!-- tinymce.plugins.* -->
<!--<script src="plugins/autolink.js"></script>-->

View File

@ -116,7 +116,7 @@
{href: 'test1.css', cssRules: [
{selectorText: '.a'},
{selectorText: '.b'}
]},
]}
]);
equal(evt.control.items().length, 1);
@ -133,7 +133,7 @@
{href: 'test1.css', cssRules: [
{selectorText: '.a'},
{selectorText: '.b'}
]},
]}
]);
equal(evt.control.items().length, 1);
@ -148,7 +148,7 @@
{href: 'test1.css', cssRules: [
{selectorText: '.a'},
{selectorText: '.b'}
]},
]}
]);
equal(evt.control.items().length, 1);
@ -168,7 +168,7 @@
{selectorText: '.a'},
{selectorText: '.b'},
{selectorText: '.c'}
]},
]}
]);
equal(evt.control.items().length, 3);

File diff suppressed because it is too large Load Diff

View File

@ -31,6 +31,8 @@
delete editor.settings.table_cell_class_list;
delete editor.settings.table_row_class_list;
delete editor.settings.table_style_by_css;
editor.off('newcell newrow');
}
});
@ -511,7 +513,7 @@
});
test("mceTableMergeCells command with cell selection", function() {
editor.getBody().innerHTML = '<table><tr><td class="mce-item-selected">1</td><td class="mce-item-selected">2</td></tr></table>';
editor.getBody().innerHTML = '<table><tr><td data-mce-selected="1">1</td><td data-mce-selected="1">2</td></tr></table>';
Utils.setSelection('td', 0);
editor.execCommand('mceTableMergeCells');
equal(cleanTableHtml(editor.getContent()), '<table><tbody><tr><td colspan="2">12</td></tr></tbody></table>');
@ -554,8 +556,8 @@
test("Delete selected cells", function() {
editor.getBody().innerHTML = (
'<table><tbody>' +
'<tr><td class="mce-item-selected">A1</td><td>A2</td></tr>' +
'<tr><td class="mce-item-selected">B1</td><td>B2</td></tr>' +
'<tr><td data-mce-selected="1">A1</td><td>A2</td></tr>' +
'<tr><td data-mce-selected="1">B1</td><td>B2</td></tr>' +
'</tbody></table>' +
'<p>x</p>'
);
@ -572,8 +574,8 @@
test("Delete all cells", function() {
editor.getBody().innerHTML = (
'<table><tbody>' +
'<tr><td class="mce-item-selected">A1</td><td class="mce-item-selected">A2</td></tr>' +
'<tr><td class="mce-item-selected">B1</td><td class="mce-item-selected">B2</td></tr>' +
'<tr><td data-mce-selected="1">A1</td><td data-mce-selected="1">A2</td></tr>' +
'<tr><td data-mce-selected="1">B1</td><td data-mce-selected="1">B2</td></tr>' +
'</tbody></table>' +
'<p>x</p>'
);
@ -998,4 +1000,26 @@
'</table>');
});
test("Table newcell/newrow events", function() {
var cells = [], rows = [], counter = 0;
editor.on('newcell', function(e) {
cells.push(e.node);
e.node.setAttribute('data-counter', counter++);
});
editor.on('newrow', function(e) {
rows.push(e.node);
e.node.setAttribute('data-counter', counter++);
});
editor.plugins.table.insertTable(2, 3);
equal(cells.length, 6);
equal(rows.length, 3);
equal(cells[cells.length - 1].getAttribute('data-counter'), "8");
equal(rows[rows.length - 1].getAttribute('data-counter'), "6");
});
})();

View File

@ -6,11 +6,10 @@ module("tinymce.EditorManager", {
selector: "textarea",
add_unload_trigger: false,
disable_nodechange: true,
skin: false,
init_instance_callback: function(ed) {
window.editor = ed;
QUnit.start();
}
skin: false
}).then(function(editors) {
window.editor = editors[0];
QUnit.start();
});
}
});
@ -96,3 +95,26 @@ asyncTest('Init/remove on same id', function() {
strictEqual(tinymce.get().length, 2);
});
test('overrideDefaults', function() {
var oldBaseURI, oldBaseUrl, oldSuffix;
oldBaseURI = tinymce.baseURI;
oldBaseUrl = tinymce.baseURL;
oldSuffix = tinymce.suffix;
tinymce.overrideDefaults({
test: 42,
base_url: "http://www.tinymce.com/base/",
suffix: "x"
});
strictEqual(tinymce.baseURI.path, "/base");
strictEqual(tinymce.baseURL, "http://www.tinymce.com/base");
strictEqual(tinymce.suffix, "x");
strictEqual(new tinymce.Editor('ed', {}, tinymce).settings.test, 42);
tinymce.baseURI = oldBaseURI;
tinymce.baseURL = oldBaseUrl;
tinymce.suffix = oldSuffix;
});

View File

@ -0,0 +1,41 @@
ModuleLoader.require([
], function() {
module("tinymce.WindowManager", {
setupModule: function() {
QUnit.stop();
tinymce.init({
selector: "textarea",
add_unload_trigger: false,
disable_nodechange: true,
init_instance_callback: function(ed) {
window.editor = ed;
QUnit.start();
}
});
},
teardown: function() {
editor.off('CloseWindow OpenWindow');
}
});
test('OpenWindow/CloseWindow events', function() {
var openWindowArgs, closeWindowArgs;
editor.on('CloseWindow', function(e) {
closeWindowArgs = e;
});
editor.on('OpenWindow', function(e) {
openWindowArgs = e;
e.win.close();
});
editor.windowManager.alert('test');
equal(openWindowArgs.type, 'openwindow');
equal(closeWindowArgs.type, 'closewindow');
equal(editor.windowManager.getWindows().length, 0);
});
});

View File

@ -513,3 +513,14 @@ test('Trailing BR (IE11)', function() {
DOM.setHTML('test', 'a<br><br>');
equal(ser.serialize(DOM.get('test')), 'a');
});
test('addTempAttr', function() {
var ser = new tinymce.dom.Serializer({});
ser.addTempAttr('data-x');
ser.addTempAttr('data-y');
DOM.setHTML('test', '<p data-x="1" data-y="2" data-z="3">a</p>');
equal(ser.serialize(DOM.get('test'), {getInner: 1}), '<p data-z="3">a</p>');
equal(ser.trimHtml('<p data-x="1" data-y="2" data-z="3">a</p>'), '<p data-z="3">a</p>');
});

View File

@ -0,0 +1,109 @@
ModuleLoader.require([
"tinymce/dom/TreeWalker"
], function(TreeWalker) {
var viewElm, nodes;
module("tinymce.dom.TreeWalker", {
setupModule: function() {
function setupHtml(html) {
var viewElm;
viewElm = document.getElementById('view');
viewElm.innerHTML = html;
return viewElm;
}
function all(node) {
var list = [node];
if (node.hasChildNodes()) {
for (var i = 0; i < node.childNodes.length; i++) {
list = list.concat(all(node.childNodes[i]));
}
}
return list;
}
viewElm = setupHtml(
'1' +
'<ul>' +
'<li>' +
'2' +
'<ul>' +
'<li>3</li>' +
'<li>4</li>' +
'</ul>' +
'</li>' +
'<li>' +
'5' +
'<ul>' +
'<li>6</li>' +
'<li>7</li>' +
'</ul>' +
'</li>' +
'</ul>' +
'8'
);
nodes = all(viewElm).slice(1);
},
teardownModule: function() {
viewElm = nodes = null;
}
});
function compareNodeLists(expectedNodes, actutalNodes) {
if (expectedNodes.length !== actutalNodes.length) {
return false;
}
for (var i = 0; i < expectedNodes.length; i++) {
if (expectedNodes[i] !== actutalNodes[i]) {
return false;
}
}
return true;
}
test('next', function() {
var walker = new TreeWalker(nodes[0], viewElm);
var actualNodes;
actualNodes = [walker.current()];
while ((walker.next())) {
actualNodes.push(walker.current());
}
ok(compareNodeLists(nodes, actualNodes), 'Should be the same');
});
test('prev2', function() {
var walker = new TreeWalker(nodes[nodes.length - 1], viewElm);
var actualNodes;
actualNodes = [walker.current()];
while ((walker.prev2())) {
actualNodes.push(walker.current());
}
actualNodes = actualNodes.reverse();
ok(compareNodeLists(nodes, actualNodes), 'Should be the same');
});
test('prev2(shallow:true)', function() {
var walker = new TreeWalker(nodes[nodes.length - 1], viewElm);
var actualNodes;
actualNodes = [walker.current()];
while ((walker.prev2(true))) {
actualNodes.push(walker.current());
}
actualNodes = actualNodes.reverse();
ok(compareNodeLists(viewElm.childNodes, actualNodes), 'Should be the same');
});
});

View File

@ -0,0 +1,71 @@
ModuleLoader.require(["tinymce/fmt/Hooks"], function(Hooks) {
module("tinymce.fmt.Hooks", {
setupModule: function() {
QUnit.stop();
tinymce.init({
selector: "textarea",
add_unload_trigger: false,
disable_nodechange: true,
skin: false,
entities: 'raw',
indent: false,
init_instance_callback: function(ed) {
editor = ed;
QUnit.start();
}
});
}
});
test('pre - postProcessHook', function() {
function assertPreHook(setupHtml, setupSelection, expected) {
editor.getBody().innerHTML = setupHtml;
Utils.setSelection.apply(Utils, setupSelection);
Hooks.postProcess('pre', editor);
equal(editor.getContent(), expected);
}
assertPreHook(
'<pre>a</pre><pre>b</pre>',
['pre:nth-child(1)', 0, 'pre:nth-child(2)', 1],
'<pre>a<br /><br />b</pre>'
);
assertPreHook(
'<pre>a</pre><pre>b</pre>',
['pre:nth-child(2)', 0, 'pre:nth-child(2)', 1],
'<pre>a</pre><pre>b</pre>'
);
assertPreHook(
'<pre>a</pre><pre>b</pre>',
['pre:nth-child(2)', 1, 'pre:nth-child(2)', 1],
'<pre>a</pre><pre>b</pre>'
);
assertPreHook(
'<pre>a</pre><pre>b</pre><pre>c</pre>',
['pre:nth-child(1)', 0, 'pre:nth-child(3)', 1],
'<pre>a<br /><br />b<br /><br />c</pre>'
);
assertPreHook(
'<pre>a</pre><pre>b</pre>',
['pre:nth-child(1)', 0, 'pre:nth-child(1)', 1],
'<pre>a</pre><pre>b</pre>'
);
assertPreHook(
'<pre>a</pre><p>b</p><pre>c</pre>',
['pre:nth-child(1)', 0, 'pre:nth-child(3)', 1],
'<pre>a</pre><p>b</p><pre>c</pre>'
);
assertPreHook(
'<pre>a</pre><pre>b</pre><p>c</p><pre>d</pre><pre>e</pre>',
['pre:nth-child(1)', 0, 'pre:nth-child(5)', 1],
'<pre>a<br /><br />b</pre><p>c</p><pre>d<br /><br />e</pre>'
);
});
});

View File

@ -67,4 +67,13 @@ ModuleLoader.require([
equal(ClientRect.compare(rect(5, 10, 10, 10), rect(10, 10, 10, 10)), -1);
equal(ClientRect.compare(rect(15, 10, 10, 10), rect(10, 10, 10, 10)), 1);
});
});
test('containsXY', function() {
equal(ClientRect.containsXY(rect(10, 70, 10, 40), 1, 2), false);
equal(ClientRect.containsXY(rect(10, 70, 10, 40), 15, 2), false);
equal(ClientRect.containsXY(rect(10, 70, 10, 40), 25, 2), false);
equal(ClientRect.containsXY(rect(10, 70, 10, 40), 10, 70), true);
equal(ClientRect.containsXY(rect(10, 70, 10, 40), 20, 110), true);
equal(ClientRect.containsXY(rect(10, 70, 10, 40), 15, 75), true);
});
});

View File

@ -90,6 +90,22 @@ ModuleLoader.require([
}, 10);
});
asyncTest('throttle stop', function() {
var fn, args = [];
fn = Delay.throttle(function(a) {
args.push(a);
}, 0);
fn(1);
fn.stop();
Delay.setTimeout(function() {
deepEqual(args, []);
QUnit.start();
}, 10);
});
test('clearTimeout', function() {
var id;

View File

@ -0,0 +1,40 @@
ModuleLoader.require(["tinymce/util/Promise"], function(Promise) {
module("tinymce.util.Promise");
asyncTest('Promise resolve', function() {
new Promise(function(resolve) {
resolve("123");
}).then(function(result) {
equal("123", result);
QUnit.start();
});
});
asyncTest('Promise reject', function() {
new Promise(function(resolve, reject) {
reject("123");
}).then(function() {
}, function(result) {
equal("123", result);
QUnit.start();
});
});
asyncTest('Promise reject', function() {
var promises = [
new Promise(function(resolve) {
resolve("123");
}),
new Promise(function(resolve) {
resolve("456");
})
];
Promise.all(promises).then(function(results) {
equal("123", results[0]);
equal("456", results[1]);
QUnit.start();
});
});
});

View File

@ -0,0 +1,8 @@
ModuleLoader.require(["tinymce/util/Tools"], function(Tools) {
module("tinymce.util.Tools");
test('extend', function() {
deepEqual({a: 1, b: 2, c: 3}, Tools.extend({a: 1}, {b: 2}, {c: 3}));
deepEqual({a: 1, c: 3}, Tools.extend({a: 1}, null, {c: 3}));
});
});