/** * Copyright (c) Tiny Technologies, Inc. All rights reserved. * Licensed under the LGPL or a commercial license. * For LGPL see License.txt in the project root for license information. * For commercial licenses see https://www.tiny.cloud/ * * Version: 5.7.0 (2021-02-10) */ !function(){"use strict";var C=function(){},b=function(n){return function(){return n}},d=function(n){return n};function S(r){for(var o=[],n=1;n=e.length&&n.substr(t,t+e.length)===e},un=function(n,e){return-1!==n.indexOf(e)},cn=function(n,e){return on(n,e,0)},an=function(n,e){return on(n,e,n.length-e.length)},ln=(X=/^\s+|\s+$/g,function(n){return n.replace(X,"")}),fn=function(n){return 0=n.startCol&&o<=n.finishRow&&u>=n.startRow},Mt=function(n,e){return e.column>=n.startCol&&e.column+e.colspan-1<=n.finishCol&&e.row>=n.startRow&&e.row+e.rowspan-1<=n.finishRow},Nt=function(n,e,t){var r=Et.findItem(n,e,Mn),o=Et.findItem(n,t,Mn);return r.bind(function(r){return o.map(function(n){return e=r,t=n,{startRow:Math.min(e.row,t.row),startCol:Math.min(e.column,t.column),finishRow:Math.max(e.row+e.rowspan-1,t.row+t.rowspan-1),finishCol:Math.max(e.column+e.colspan-1,t.column+t.colspan-1)};var e,t})})},jt=function(e,n,t){return Nt(e,n,t).bind(function(n){return function(n,e){for(var t=!0,r=S(Mt,e),o=e.startRow;o<=e.finishRow;o++)for(var u=e.startCol;u<=e.finishCol;u++)t=t&&Et.getAt(n,o,u).exists(r);return t?O.some(e):O.none()}(e,n)})},Wt=function(t,n,e){return Nt(t,n,e).map(function(n){var e=Et.filterItems(t,S(Pt,n));return B(e,function(n){return n.element})})},Lt=function(n,e){return Et.findItem(n,e,function(n,e){return jn(e,n)}).map(function(n){return n.element})},zt=function(i,c,a){return st(i).bind(function(n){var r,e,o,u,t=Ft(n);return r=t,e=i,o=c,u=a,Et.findItem(r,e,Mn).bind(function(n){var e=0=r.length-1)return O.none();var n=r[o].fold(function(){var n,e,t=(n=r.slice(0,o),(e=x.call(n,0)).reverse(),e);return $(t,function(n,e){return n.map(function(n){return{value:n,delta:e+1}})})},function(n){return O.some({value:n,delta:0})}),e=r[o+1].fold(function(){var n=r.slice(o+1);return $(n,function(n,e){return n.map(function(n){return{value:n,delta:e+1}})})},function(n){return O.some({value:n,delta:1})});return n.bind(function(t){return e.map(function(n){var e=n.delta+t.delta;return Math.abs(n.value-t.value)/e})})},Hr=function(e,t){return function(n){return"rtl"===qr(n)?t:e}},qr=function(n){return"rtl"===Xe(n,"direction")?"rtl":"ltr"},Vr=Mr("height",function(n){var e=n.dom;return Se(n)?e.getBoundingClientRect().height:e.offsetHeight}),Ur=function(n){return Vr.get(n)},$r=function(n){return Vr.getOuter(n)},Gr=function(t,r){return{left:t,top:r,translate:function(n,e){return Gr(t+n,r+e)}}},Kr=Gr,Xr=function(n,e){return n!==undefined?n:e!==undefined?e:0},Yr=function(n){var e=n.dom.ownerDocument,t=e.body,r=e.defaultView,o=e.documentElement;if(t===n.dom)return Kr(t.offsetLeft,t.offsetTop);var u=Xr(null==r?void 0:r.pageYOffset,o.scrollTop),i=Xr(null==r?void 0:r.pageXOffset,o.scrollLeft),c=Xr(o.clientTop,t.clientTop),a=Xr(o.clientLeft,t.clientLeft);return Jr(n).translate(i-a,u-c)},Jr=function(n){var e,t=n.dom,r=t.ownerDocument.body;return r===t?Kr(r.offsetLeft,r.offsetTop):Se(n)?(e=t.getBoundingClientRect(),Kr(e.left,e.top)):Kr(0,0)},Qr=function(n,e){return{row:n,y:e}},Zr=function(n,e){return{col:n,x:e}},no=function(n){return Yr(n).left+Wr(n)},eo=function(n){return Yr(n).left},to=function(n,e){return Zr(n,eo(e))},ro=function(n,e){return Zr(n,no(e))},oo=function(n){return Yr(n).top},uo=function(n,e){return Qr(n,oo(e))},io=function(n,e){return Qr(n,oo(e)+$r(e))},co=function(t,e,r){if(0===r.length)return[];var n=B(r.slice(1),function(n,e){return n.map(function(n){return t(e,n)})}),o=r[r.length-1].map(function(n){return e(r.length-1,n)});return n.concat([o])},ao={delta:d,positions:function(n){return co(uo,io,n)},edge:oo},lo=Hr({delta:d,edge:eo,positions:function(n){return co(to,ro,n)}},{delta:function(n){return-n},edge:no,positions:function(n){return co(ro,to,n)}}),fo={delta:function(n,e){return lo(e).delta(n,e)},positions:function(n,e){return lo(e).positions(n,e)},edge:function(n){return lo(n).edge(n)}},so={unsupportedLength:["em","ex","cap","ch","ic","rem","lh","rlh","vw","vh","vi","vb","vmin","vmax","cm","mm","Q","in","pc","pt","px"],fixed:["px","pt"],relative:["%"],empty:[""]},mo=(ur="[eE][+-]?[0-9]+",cr=["Infinity",(or="[0-9]+")+"\\."+(ir=function(n){return"(?:"+n+")?"})(or)+ir(ur),"\\."+or+ir(ur),or+ir(ur)].join("|"),new RegExp("^([+-]?(?:"+cr+"))(.*)$")),go=function(n,o){return O.from(mo.exec(n)).bind(function(n){var e,t=Number(n[1]),r=n[2];return e=r,k(o,function(n){return k(so[n],function(n){return e===n})})?O.some({value:t,unit:r}):O.none()})},po=function(){var n=kn().browser;return n.isIE()||n.isEdge()},ho=function(n,e,t){return r=Xe(n,e),o=t,u=parseFloat(r),isNaN(u)?o:u;var r,o,u},vo=function(n){return po()?(t=(e=n).dom.getBoundingClientRect().height,"border-box"===Xe(e,"box-sizing")?t:t-ho(e,"padding-top",0)-ho(e,"padding-bottom",0)-(ho(e,"border-top-width",0)+ho(e,"border-bottom-width",0))):ho(n,"height",Ur(n));var e,t},bo=function(n){return po()?(t=(e=n).dom.getBoundingClientRect().width,"border-box"===Xe(e,"box-sizing")?t:t-ho(e,"padding-left",0)-ho(e,"padding-right",0)-(ho(e,"border-left-width",0)+ho(e,"border-right-width",0))):ho(n,"width",jr(n));var e,t},wo=/(\d+(\.\d+)?)%/,yo=/(\d+(\.\d+)?)px|em/,Co=function(n,e){var t,r=(t=n,O.from(t.dom.offsetParent).map(Bn.fromDom).getOr(Te(le(n))));return e(n)/e(r)*100},xo=function(n,e){Ge(n,"width",e+"px")},So=function(n,e){Ge(n,"width",e+"%")},To=function(n,e){Ge(n,"height",e+"px")},Ro=function(n,e,t,r){var o,u,i,c,a,l=parseInt(n,10);return an(n,"%")&&"table"!==ne(e)?(u=l,i=t,c=r,a=st(o=e).map(function(n){var e=i(n);return Math.floor(u/100*e)}).getOr(u),c(o,a),a):l},Do=function(n){var e,t=Je(e=n,"height").getOrThunk(function(){return vo(e)+"px"});return t?Ro(t,n,Ur,To):Ur(n)},Oo=function(n){return Je(n,"width").fold(function(){return O.from(Fe(n,"width"))},function(n){return O.some(n)})},Ao=function(n,e){return n/e.pixelWidth()*100},ko=function(e,t){return Oo(e).fold(function(){var n=jr(e);return Ao(n,t)},function(n){return function(n,e,t){var r=wo.exec(e);if(null!==r)return parseFloat(r[1]);var o=bo(n);return Ao(o,t)}(e,n,t)})},Io=function(e,t){return Oo(e).fold(function(){return bo(e)},function(n){return function(n,e,t){var r=yo.exec(e);if(null!==r)return parseInt(r[1],10);var o=wo.exec(e);if(null===o)return bo(n);var u=parseFloat(o[1]);return u/100*t.pixelWidth()}(e,n,t)})},Bo=function(n){return t="rowspan",Do(e=n)/nt(e,t);var e,t},Eo=function(n,e,t){Ge(n,"width",e+t)},Po=function(n){return Co(n,jr)+"%"},Mo=b(wo),No=b(yo),jo=ae("col"),Wo=function(n,e,t){return Je(n,e).fold(function(){return t(n)+"px"},function(n){return n})},Lo=function(n,e){return Wo(n,"width",function(n){return jo(n)?jr(n):Io(n,e)})},zo=function(n){return Wo(n,"height",Bo)},_o=function(n,e){return Je(n,e).isSome()},Fo=function(n,e,t,r,o,u){return n.filter(r).fold(function(){return u(Fr(t,e))},function(n){return o(n)})},Ho=function(n,e,i,c,a){var t,l=Lr(n,function(n){return _o(n,"width")}),r=Et.hasColumns(n)?(t=n,B(Et.justColumns(t),function(n){return O.from(n.element)})):l,f=[O.some(fo.edge(e))].concat(B(fo.positions(l,e),function(n){return n.map(function(n){return n.x})})),s=g(et);return B(r,function(n,u){return Fo(n,u,f,s,function(n){if(!jo(r=n)||_o(r,"width"))return i(n,a);var e,t,r,o=(e=l[u],t=d,e!==undefined&&null!==e?t(e):O.none());return Fo(o,u,f,s,function(n){return c(O.some(jr(n)))},c)},c)})},qo=function(n){return n.map(function(n){return n+"px"}).getOr("")},Vo=function(n,e,t){return Ho(n,e,Io,function(n){return n.getOrThunk(t.minCellWidth)},t)},Uo=function(n,e,t,r,o){var u=_r(n),i=[O.some(t.edge(e))].concat(B(t.positions(u,e),function(n){return n.map(function(n){return n.y})}));return B(u,function(n,e){return Fo(n,e,i,g(tt),r,o)})},$o=function(n){var e=n;return{get:function(){return e},set:function(n){e=n}}},Go=function(t){var n=function(){return jr(t)},e=b(0);return{width:n,pixelWidth:n,getWidths:function(n,e){return Vo(n,t,e)},getCellDelta:e,singleColumnWidth:b([0]),minCellWidth:e,setElementWidth:C,adjustTableWidth:C,isRelative:!0,label:"none"}},Ko=function(n,r){var o=$o(parseFloat(n)),u=$o(jr(r));return{width:o.get,pixelWidth:u.get,getWidths:function(n,e){return Ho(n,r,ko,function(n){return n.fold(function(){return t.minCellWidth()},function(n){return n/t.pixelWidth()*100})},t=e);var t},getCellDelta:function(n){return n/u.get()*100},singleColumnWidth:function(n,e){return[100-n]},minCellWidth:function(){return ot()/u.get()*100},setElementWidth:So,adjustTableWidth:function(n){var e=o.get(),t=e+n/100*e;So(r,t),o.set(t),u.set(jr(r))},isRelative:!0,label:"percent"}},Xo=function(n,t){var r=$o(n),o=r.get;return{width:o,pixelWidth:o,getWidths:function(n,e){return Vo(n,t,e)},getCellDelta:d,singleColumnWidth:function(n,e){return[Math.max(ot(),n+e)-n]},minCellWidth:ot,setElementWidth:xo,adjustTableWidth:function(n){var e=o()+n;xo(t,e),r.set(e)},isRelative:!1,label:"pixel"}},Yo=function(e){return Oo(e).fold(function(){return Go(e)},function(n){return function(n,e){var t=Mo().exec(e);if(null!==t)return Ko(t[1],n);var r=No().exec(e);if(null!==r){var o=parseInt(r[1],10);return Xo(o,n)}var u=jr(n);return Xo(u,n)}(e,n)})},Jo=Xo,Qo=Ko,Zo=function(n,e,t,r){for(var o,u,i,c=e.grid.columns,a=e.grid.rows,l=0;lt.maxRow||st.maxCol||(Et.getAt(e,l,s).filter(r).isNone()?(o=f,0,u=n[l].element,i=Bn.fromTag("td"),Ut(i,Bn.fromTag("br")),(o?Ut:Vt)(u,i)):f=!0)}},nu=function(n,e){var t,u,r,i,c,a,l,f,s,o=function(n){return En(n.element,e)},d=Ir(n),m=ht(d),g=Yo(n),p=Et.generate(m),h=(u=o,r=(t=p).grid.columns,i=t.grid.rows,c=r,l=a=0,f=[],s=[],_n(t.access,function(n){var e,t,r,o;f.push(n),u(n)&&(s.push(n),t=(e=n.row)+n.rowspan-1,o=(r=n.column)+n.colspan-1,ee.maxCol)&&Yt(n.element)});var o=P(it(n,"tr"),function(n){return 0===n.dom.childElementCount});E(o,Yt),e.minCol!==e.maxCol&&e.minRow!==e.maxRow||E(it(n,"th,td"),function(n){qe(n,"rowspan"),qe(n,"colspan")}),qe(n,Dt),qe(n,"data-snooker-col-series"),Yo(n).adjustTableWidth(r)}(d,h,p,function(n,e,t,r){if(0===r.minCol&&e.grid.columns===r.maxCol+1)return 0;var o=Vo(e,n,t),u=N(o,function(n,e){return n+e},0),i=N(o.slice(r.minCol,r.maxCol+1),function(n,e){return n+e},0)/u*t.pixelWidth()-t.pixelWidth();return t.getCellDelta(i)}(n,Et.fromTable(n),g,h)),d},eu=function(n){return"img"===ne(n)?1:nr(n).fold(function(){return pe(n).length},function(n){return n.length})},tu=["img","br"],ru=function(n){return nr(n).filter(function(n){return 0!==n.trim().length||-1=e.column&&n<=Tt(t[0])+e.column})},Sa=function(n,u,i,c,a){var e,t,r,o,l,f=At(u),s=(e=n,t=f,r=Tt(u[0]),o=I(r-e.column,function(n){return n+e.column}),l=j(o,function(e){return _(t,function(n){return n!==e})}).getOr(r-1),G(G({},e),{column:l})),d=xa(s,i,f);return function(n,e,t){if(n.row>=e.length||n.column>Tt(e[0]))return ga.error("invalid start address out of table bounds, row: "+n.row+", column: "+n.column);var r=e.slice(n.row),o=r[0].cells.slice(n.column),u=Tt(t[0]),i=t.length;return ga.value({rowDelta:r.length-i,colDelta:o.length-u})}(s,u,i).map(function(n){var e=G(G({},n),{colDelta:n.colDelta-d.length}),t=ya(u,e,c),r=At(t),o=xa(s,i,r);return Ca(s,t,i,c,a,o)})},Ta=function(t,n,e,r,o){var u,i,c,a;u=n,i=t,c=o,a=r.cell,0=e.grid.columns&&n.isLocked})},rl=function(n,e){var t=Lr(n),r=Pa(e);return N(r,function(n,e){return n+t[e.column].map(Wr).getOr(0)},0)},ol=function(t){return function(e,n){return oa(e,n).filter(function(n){return!(t?el:tl)(e,n)}).map(function(n){return{details:n,pixelDelta:rl(e,n)}})}},ul=function(t){return function(e,n){return ra(e,n).filter(function(n){return!(t?el:tl)(e,n.cells)})}},il=ea(function(n,e,t,r){var o=e[0].row,u=Ya(e),i=M(u,function(n,e){return{grid:Da(n.grid,o,e.row+n.delta,t,r.getOrInit),delta:n.delta+1}},{grid:n,delta:0}).grid;return Xa(i,o,e[0].column)},oa,C,C,ja),cl=ea(function(n,e,t,r){var o=Ya(e),u=o[o.length-1],i=u.row+u.rowspan,c=M(o,function(n,e){return Da(n,i,e.row,t,r.getOrInit)},n);return Xa(c,i,e[0].column)},oa,C,C,ja),al=ea(function(n,e,t,r){var o=e.details,u=Pa(o),i=u[0].column,c=M(u,function(n,e){return{grid:Oa(n.grid,i,e.column+n.delta,t,r.getOrInit),delta:n.delta+1}},{grid:n,delta:0}).grid;return Xa(c,o[0].row,i)},ol(!0),nl,C,ja),ll=ea(function(n,e,t,r){var o=e.details,u=o[o.length-1],i=u.column+u.colspan,c=Pa(o),a=M(c,function(n,e){return Oa(n,i,e.column,t,r.getOrInit)},n);return Xa(a,o[0].row,i)},ol(!1),nl,C,ja),fl=ea(function(n,e,t,r){var o,u,i=Pa(e.details),c=(o=n,u=B(i,function(n){return n.column}),z(o,function(n){var e=n.cells,t=M(u,function(n,e){return 0<=e&&e=t&&n.column=t&&n.column=o&&n.column',u.insertBefore(i,u.firstChild)),""===a.align?Jl(o,u):Yl(o,u,a.align)),o.focus(),o.addVisual(),0=n.left&&e<=n.right&&t>=n.top&&t<=n.bottom}),Kf=function(t,r,n,e,o){var u=function(n){var e=t.dom.createRange();return e.setStart(r.dom,n),e.collapse(!0),e},i=Zt(r).length,c=function(n,e,t,r,o){if(0===o)return 0;if(e===r)return o-1;for(var u=r,i=1;ir.left&&o.leftt.right;var e,t})});var t},sd={point:function(n){return n.bottom},adjuster:function(n,e,t,r,o){var u=td(o,5);return Math.abs(t.bottom-r.bottom)<1||t.top>o.bottom?ld.retry(u):t.top===o.bottom?ld.retry(td(o,1)):fd(n,e,o)?ld.retry(od(u,5,0)):ld.none()},move:td,gather:Gs},dd=function(t,r,o,u,i){return 0===i?O.some(u):(a=t,l=u.left,f=r.point(u),a.elementFromPoint(l,f).filter(function(n){return"table"===ne(n)}).isSome()?(e=u,c=i-1,dd(t,n=r,o,n.move(e,5),c)):t.situsFromPoint(u.left,r.point(u)).bind(function(n){return n.start.fold(O.none,function(e){return ad(t,e).bind(function(n){return r.adjuster(t,e,n,o,u).fold(O.none,function(n){return dd(t,r,o,n,i-1)})}).orThunk(function(){return O.some(u)})},O.none)}));var n,e,c,a,l,f},md=function(e,t,n){var r,o,u,i=e.move(n,5),c=dd(t,e,n,i,100).getOr(i);return o=c,u=t,((r=e).point(o)>u.getInnerHeight()?O.some(r.point(o)-u.getInnerHeight()):r.point(o)<0?O.some(-r.point(o)):O.none()).fold(function(){return t.situsFromPoint(c.left,e.point(c))},function(n){return t.scrollBy(0,n),t.situsFromPoint(c.left,e.point(c)-n)})},gd={tryUp:S(md,{point:function(n){return n.top},adjuster:function(n,e,t,r,o){var u=rd(o,5);return Math.abs(t.top-r.top)<1||t.bottom=t.grid.columns&&(n.onLast=!0)),n},{onAny:!1,onFirst:!1,onLast:!1});return{mergeable:aa(t,o).isSome(),unmergeable:la(t,o).isSome(),locked:r}})},m=function(){u.set(Y(s)()),c=u.get().bind(d),E(i.get(),function(n){return n()})},g=function(e,t){var r=function(){return u.get().fold(function(){e.setDisabled(!0)},function(n){e.setDisabled(t(n))})};return r(),i.set(i.get().concat([r])),function(){i.set(P(i.get(),function(n){return n!==r}))}},p=function(e){return c.exists(function(n){return n.locked[e]})},r.on("NodeChange ExecCommand TableSelectorChange",m),{onSetupTable:function(n){return g(n,function(n){return!1})},onSetupCellOrRow:function(n){return g(n,function(n){return l(n.element)})},onSetupColumn:function(e){return function(n){return g(n,function(n){return l(n.element)||p(e)})}},onSetupPasteable:function(e){return function(n){return g(n,function(n){return l(n.element)||e().isNone()})}},onSetupPasteableColumn:function(e,t){return function(n){return g(n,function(n){return l(n.element)||e().isNone()||p(t)})}},onSetupMergeable:function(n){return g(n,function(n){return f("mergeable")})},onSetupUnmergeable:function(n){return g(n,function(n){return f("unmergeable")})},resetTargets:m,targets:function(){return u.get()}}),S=jc(a),T=Hd(a,S.lazyResize,x),R=Ml(a,S.lazyWire,C),D=(h=$o(O.none()),v=$o(O.none()),b=function(n){n.set(O.none())},{getRows:h.get,setRows:function(n){h.set(n),b(v)},clearRows:function(){return b(h)},getColumns:v.get,setColumns:function(n){v.set(n),b(h)},clearColumns:function(){return b(v)}});return Af(a,R,T,C,D),kf(a,R,C),Mu(a,C,R,T),function(e,n,t){var r=function(n){return function(){return e.execCommand(n)}},o=function(n){e.execCommand("mceInsertTable",!1,{rows:n.numRows,columns:n.numColumns})},u={text:"Table properties",onSetup:n.onSetupTable,onAction:r("mceTableProps")},i={text:"Delete table",icon:"table-delete-table",onSetup:n.onSetupTable,onAction:r("mceTableDelete")};e.ui.registry.addMenuItem("tableinsertrowbefore",{text:"Insert row before",icon:"table-insert-row-above",onAction:r("mceTableInsertRowBefore"),onSetup:n.onSetupCellOrRow}),e.ui.registry.addMenuItem("tableinsertrowafter",{text:"Insert row after",icon:"table-insert-row-after",onAction:r("mceTableInsertRowAfter"),onSetup:n.onSetupCellOrRow}),e.ui.registry.addMenuItem("tabledeleterow",{text:"Delete row",icon:"table-delete-row",onAction:r("mceTableDeleteRow"),onSetup:n.onSetupCellOrRow}),e.ui.registry.addMenuItem("tablerowprops",{text:"Row properties",icon:"table-row-properties",onAction:r("mceTableRowProps"),onSetup:n.onSetupCellOrRow}),e.ui.registry.addMenuItem("tablecutrow",{text:"Cut row",icon:"cut-row",onAction:r("mceTableCutRow"),onSetup:n.onSetupCellOrRow}),e.ui.registry.addMenuItem("tablecopyrow",{text:"Copy row",icon:"duplicate-row",onAction:r("mceTableCopyRow"),onSetup:n.onSetupCellOrRow}),e.ui.registry.addMenuItem("tablepasterowbefore",{text:"Paste row before",icon:"paste-row-before",onAction:r("mceTablePasteRowBefore"),onSetup:n.onSetupPasteable(t.getRows)}),e.ui.registry.addMenuItem("tablepasterowafter",{text:"Paste row after",icon:"paste-row-after",onAction:r("mceTablePasteRowAfter"),onSetup:n.onSetupPasteable(t.getRows)});e.ui.registry.addMenuItem("tableinsertcolumnbefore",{text:"Insert column before",icon:"table-insert-column-before",onAction:r("mceTableInsertColBefore"),onSetup:n.onSetupColumn("onFirst")}),e.ui.registry.addMenuItem("tableinsertcolumnafter",{text:"Insert column after",icon:"table-insert-column-after",onAction:r("mceTableInsertColAfter"),onSetup:n.onSetupColumn("onLast")}),e.ui.registry.addMenuItem("tabledeletecolumn",{text:"Delete column",icon:"table-delete-column",onAction:r("mceTableDeleteCol"),onSetup:n.onSetupColumn("onAny")}),e.ui.registry.addMenuItem("tablecutcolumn",{text:"Cut column",icon:"cut-column",onAction:r("mceTableCutCol"),onSetup:n.onSetupColumn("onAny")}),e.ui.registry.addMenuItem("tablecopycolumn",{text:"Copy column",icon:"duplicate-column",onAction:r("mceTableCopyCol"),onSetup:n.onSetupColumn("onAny")}),e.ui.registry.addMenuItem("tablepastecolumnbefore",{text:"Paste column before",icon:"paste-column-before",onAction:r("mceTablePasteColBefore"),onSetup:n.onSetupPasteableColumn(t.getColumns,"onFirst")}),e.ui.registry.addMenuItem("tablepastecolumnafter",{text:"Paste column after",icon:"paste-column-after",onAction:r("mceTablePasteColAfter"),onSetup:n.onSetupPasteableColumn(t.getColumns,"onLast")});e.ui.registry.addMenuItem("tablecellprops",{text:"Cell properties",icon:"table-cell-properties",onAction:r("mceTableCellProps"),onSetup:n.onSetupCellOrRow}),e.ui.registry.addMenuItem("tablemergecells",{text:"Merge cells",icon:"table-merge-cells",onAction:r("mceTableMergeCells"),onSetup:n.onSetupMergeable}),e.ui.registry.addMenuItem("tablesplitcells",{text:"Split cell",icon:"table-split-cells",onAction:r("mceTableSplitCells"),onSetup:n.onSetupUnmergeable});!1===e.getParam("table_grid",!0,"boolean")?e.ui.registry.addMenuItem("inserttable",{text:"Table",icon:"table",onAction:r("mceInsertTable")}):e.ui.registry.addNestedMenuItem("inserttable",{text:"Table",icon:"table",getSubmenuItems:function(){return[{type:"fancymenuitem",fancytype:"inserttable",onAction:o}]}}),e.ui.registry.addMenuItem("inserttabledialog",{text:"Insert table",icon:"table",onAction:r("mceInsertTable")}),e.ui.registry.addMenuItem("tableprops",u),e.ui.registry.addMenuItem("deletetable",i),e.ui.registry.addNestedMenuItem("row",{type:"nestedmenuitem",text:"Row",getSubmenuItems:function(){return"tableinsertrowbefore tableinsertrowafter tabledeleterow tablerowprops | tablecutrow tablecopyrow tablepasterowbefore tablepasterowafter"}}),e.ui.registry.addNestedMenuItem("column",{type:"nestedmenuitem",text:"Column",getSubmenuItems:function(){return"tableinsertcolumnbefore tableinsertcolumnafter tabledeletecolumn | tablecutcolumn tablecopycolumn tablepastecolumnbefore tablepastecolumnafter"}}),e.ui.registry.addNestedMenuItem("cell",{type:"nestedmenuitem",text:"Cell",getSubmenuItems:function(){return"tablecellprops tablemergecells tablesplitcells"}}),e.ui.registry.addContextMenu("table",{update:function(){return n.resetTargets(),n.targets().fold(function(){return""},function(n){return"caption"===ne(n.element)?"tableprops deletetable":"cell row column | advtablesort | tableprops deletetable"})}})}(a,x,D),function(e,n,t){e.ui.registry.addMenuButton("table",{tooltip:"Table",icon:"table",fetch:function(n){return n("inserttable | cell row column | advtablesort | tableprops deletetable")}});var r=function(n){return function(){return e.execCommand(n)}};e.ui.registry.addButton("tableprops",{tooltip:"Table properties",onAction:r("mceTableProps"),icon:"table",onSetup:n.onSetupTable}),e.ui.registry.addButton("tabledelete",{tooltip:"Delete table",onAction:r("mceTableDelete"),icon:"table-delete-table",onSetup:n.onSetupTable}),e.ui.registry.addButton("tablecellprops",{tooltip:"Cell properties",onAction:r("mceTableCellProps"),icon:"table-cell-properties",onSetup:n.onSetupCellOrRow}),e.ui.registry.addButton("tablemergecells",{tooltip:"Merge cells",onAction:r("mceTableMergeCells"),icon:"table-merge-cells",onSetup:n.onSetupMergeable}),e.ui.registry.addButton("tablesplitcells",{tooltip:"Split cell",onAction:r("mceTableSplitCells"),icon:"table-split-cells",onSetup:n.onSetupUnmergeable}),e.ui.registry.addButton("tableinsertrowbefore",{tooltip:"Insert row before",onAction:r("mceTableInsertRowBefore"),icon:"table-insert-row-above",onSetup:n.onSetupCellOrRow}),e.ui.registry.addButton("tableinsertrowafter",{tooltip:"Insert row after",onAction:r("mceTableInsertRowAfter"),icon:"table-insert-row-after",onSetup:n.onSetupCellOrRow}),e.ui.registry.addButton("tabledeleterow",{tooltip:"Delete row",onAction:r("mceTableDeleteRow"),icon:"table-delete-row",onSetup:n.onSetupCellOrRow}),e.ui.registry.addButton("tablerowprops",{tooltip:"Row properties",onAction:r("mceTableRowProps"),icon:"table-row-properties",onSetup:n.onSetupCellOrRow}),e.ui.registry.addButton("tableinsertcolbefore",{tooltip:"Insert column before",onAction:r("mceTableInsertColBefore"),icon:"table-insert-column-before",onSetup:n.onSetupColumn("onFirst")}),e.ui.registry.addButton("tableinsertcolafter",{tooltip:"Insert column after",onAction:r("mceTableInsertColAfter"),icon:"table-insert-column-after",onSetup:n.onSetupColumn("onLast")}),e.ui.registry.addButton("tabledeletecol",{tooltip:"Delete column",onAction:r("mceTableDeleteCol"),icon:"table-delete-column",onSetup:n.onSetupColumn("onAny")}),e.ui.registry.addButton("tablecutrow",{tooltip:"Cut row",icon:"cut-row",onAction:r("mceTableCutRow"),onSetup:n.onSetupCellOrRow}),e.ui.registry.addButton("tablecopyrow",{tooltip:"Copy row",icon:"duplicate-row",onAction:r("mceTableCopyRow"),onSetup:n.onSetupCellOrRow}),e.ui.registry.addButton("tablepasterowbefore",{tooltip:"Paste row before",icon:"paste-row-before",onAction:r("mceTablePasteRowBefore"),onSetup:n.onSetupPasteable(t.getRows)}),e.ui.registry.addButton("tablepasterowafter",{tooltip:"Paste row after",icon:"paste-row-after",onAction:r("mceTablePasteRowAfter"),onSetup:n.onSetupPasteable(t.getRows)}),e.ui.registry.addButton("tablecutcol",{tooltip:"Cut column",icon:"cut-column",onAction:r("mceTableCutCol"),onSetup:n.onSetupColumn("onAny")}),e.ui.registry.addButton("tablecopycol",{tooltip:"Copy column",icon:"duplicate-column",onAction:r("mceTableCopyCol"),onSetup:n.onSetupColumn("onAny")}),e.ui.registry.addButton("tablepastecolbefore",{tooltip:"Paste column before",icon:"paste-column-before",onAction:r("mceTablePasteColBefore"),onSetup:n.onSetupPasteableColumn(t.getColumns,"onFirst")}),e.ui.registry.addButton("tablepastecolafter",{tooltip:"Paste column after",icon:"paste-column-after",onAction:r("mceTablePasteColAfter"),onSetup:n.onSetupPasteableColumn(t.getColumns,"onLast")}),e.ui.registry.addButton("tableinsertdialog",{tooltip:"Insert table",onAction:r("mceInsertTable"),icon:"table"})}(a,x,D),0<(y=(w=a).getParam("table_toolbar","tableprops tabledelete | tableinsertrowbefore tableinsertrowafter tabledeleterow | tableinsertcolbefore tableinsertcolafter tabledeletecol")).length&&w.ui.registry.addContextToolbar("table",{predicate:function(n){return w.dom.is(n,"table")&&w.getBody().contains(n)},items:y,scope:"node",position:"node"}),a.on("PreInit",function(){a.serializer.addTempAttr(Bu.firstSelected),a.serializer.addTempAttr(Bu.lastSelected),a.formatter.register(If)}),a.getParam("table_tab_navigation",!0,"boolean")&&a.on("keydown",function(n){var e,t,r,o,u,i,c;t=a,r=R,(e=n).keyCode===xs.TAB&&(o=bu(t),u=function(n){var e=ne(n);return Mn(n,o)||A(Os,e)},(i=t.selection.getRng()).collapsed&&(c=Bn.fromDom(i.startContainer),at(c,u).each(function(n){e.preventDefault(),(e.shiftKey?Ts:Ss)(t,u,n,r).each(function(n){t.selection.setRng(n)})})))}),a.on("remove",function(){S.destroy()}),Vl(a,D,S,x)};Or.add("table",qd)}();