/** * 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.3.1 (2020-05-27) */ !function(p){"use strict";var S=function(e){var n=e;return{get:function(){return n},set:function(e){n=e}}},x=function(){},b=function(e){return function(){return e}},o=function(e){return e};function y(r){for(var o=[],e=1;e=n.length&&e.substr(t,t+n.length)===n},le=function(e,n){return-1!==e.indexOf(n)},fe=function(e,n){return ae(e,n,0)},se=(r=/^\s+|\s+$/g,function(e){return e.replace(r,"")}),de=function(e){return e.style!==undefined&&w(e.style.getPropertyValue)},me=function(e){if(null===e||e===undefined)throw new Error("Node cannot be null or undefined");return{dom:b(e)}},ge={fromHtml:function(e,n){var t=(n||p.document).createElement("div");if(t.innerHTML=e,!t.hasChildNodes()||1t.maxRow||st.maxCol))Qn.getAt(n,l,s).filter(r).isNone()?(o=f,0,i=e[l].element(),u=ge.fromTag("td"),pn(u,ge.fromTag("br")),(o?pn:gn)(i,u)):f=!0}}(m,g,p,d),f=p,s=N(qn(o=e,"tr"),function(e){return 0===e.dom().childElementCount}),B(s,yn),f.minCol!==f.maxCol&&f.minRow!==f.maxRow||B(qn(o,"th,td"),function(e){ue(e,"rowspan"),ue(e,"colspan")}),ue(o,"width"),ue(o,"height"),Ce(o,"width"),Ce(o,"height"),e};var et=function bf(t,r){var n=function(e){return t(e)?C.from(e.dom().nodeValue):C.none()};return{get:function(e){if(!t(e))throw new Error("Can only get "+r+" value of a "+r+" node");return n(e).getOr("")},getOption:n,set:function(e,n){if(!t(e))throw new Error("Can only set raw "+r+" value of a "+r+" node");e.dom().nodeValue=n}}}(Z,"text"),nt=function(e){return et.get(e)},tt=function(e){return et.getOption(e)},rt=function(e,n){return et.set(e,n)},ot=function(e){return"img"===$(e)?1:tt(e).fold(function(){return fn(e).length},function(e){return e.length})},it=["img","br"],ut=function(e){return tt(e).filter(function(e){return 0!==e.trim().length||-1=e.startCol()&&o<=e.finishRow()&&i>=e.startRow()},St=function(e,n){return n.column()>=e.startCol()&&n.column()+n.colspan()-1<=e.finishCol()&&n.row()>=e.startRow()&&n.row()+n.rowspan()-1<=e.finishRow()},xt=function(e,n){return t=Math.min(e.row(),n.row()),r=Math.min(e.column(),n.column()),o=Math.max(e.row()+e.rowspan()-1,n.row()+n.rowspan()-1),i=Math.max(e.column()+e.colspan()-1,n.column()+n.colspan()-1),{startRow:b(t),startCol:b(r),finishRow:b(o),finishCol:b(i)};var t,r,o,i},Ct=function(e,n,t){var r=Qn.findItem(e,n,en),o=Qn.findItem(e,t,en);return r.bind(function(n){return o.map(function(e){return xt(n,e)})})},Rt=function(n,e,t){return Ct(n,e,t).bind(function(e){return function(e,n){for(var t=!0,r=y(St,n),o=n.startRow();o<=n.finishRow();o++)for(var i=n.startCol();i<=n.finishCol();i++)t=t&&Qn.getAt(e,o,i).exists(r);return t?C.some(n):C.none()}(n,e)})},Tt=function(t,e,n){return Ct(t,e,n).map(function(e){var n=Qn.filterItems(t,y(yt,e));return k(n,function(e){return e.element()})})},Ot=function(e,n){return Qn.findItem(e,n,function(e,n){return tn(n,e)}).map(function(e){return e.element()})},Dt=function(u,c,a){return $n(u).bind(function(e){var r,n,o,i,t=Et(e);return r=t,n=u,o=c,i=a,Qn.findItem(r,n,en).bind(function(e){var n=0=r.length-1)return C.none();var e=r[o].fold(function(){var e,n,t=(e=r.slice(0,o),(n=T.call(e,0)).reverse(),n);return L(t,function(e,n){return e.map(function(e){return{value:e,delta:n+1}})})},function(e){return C.some({value:e,delta:0})}),n=r[o+1].fold(function(){var e=r.slice(o+1);return L(e,function(e,n){return e.map(function(e){return{value:e,delta:n+1}})})},function(e){return C.some({value:e,delta:1})});return e.bind(function(t){return n.map(function(e){var n=e.delta+t.delta;return Math.abs(e.value-t.value)/n})})},mo=function(t){var e=t.grid,n=fo(0,e.columns()),r=fo(0,e.rows());return k(n,function(n){return go(function(){return j(r,function(e){return Qn.getAt(t,e,n).filter(function(e){return e.column()===n}).fold(b([]),function(e){return[e]})})},function(e){return 1===e.colspan()},function(){return Qn.getAt(t,0,n)})})},go=function(e,n,t){var r=e();return M(r,n).orThunk(function(){return C.from(r[0]).orThunk(t)}).map(function(e){return e.element()})},po=function(t){var e=t.grid,n=fo(0,e.rows()),r=fo(0,e.columns());return k(n,function(n){return go(function(){return j(r,function(e){return Qn.getAt(t,n,e).filter(function(e){return e.row()===n}).fold(b([]),function(e){return[e]})})},function(e){return 1===e.rowspan()},function(){return Qn.getAt(t,n,0)})})},ho=function(e){var n=e.replace(/\./g,"-");return{resolve:function(e){return n+"-"+e}}},vo=ho("ephox-snooker").resolve,bo=vo("resizer-bar"),wo=vo("resizer-rows"),yo=vo("resizer-cols"),So=function(e){var n=En(e.parent(),"."+bo);B(n,yn)},xo=function(t,e,r){var o=t.origin();B(e,function(e){e.each(function(e){var n=r(o,e);co(n,bo),pn(t.parent(),n)})})},Co=function(e,n,l,f){xo(e,n,function(e,n){var t,r,o,i,u,c,a=(t=n.col,r=n.x-e.left(),o=l.top()-e.top(),i=7,u=f,c=ge.fromTag("div"),we(c,{position:"absolute",left:r-i/2+"px",top:o+"px",height:u+"px",width:i+"px"}),te(c,{"data-column":t,role:"presentation"}),c);return co(a,yo),a})},Ro=function(e,n,l,f){xo(e,n,function(e,n){var t,r,o,i,u,c,a=(t=n.row,r=l.left()-e.left(),o=n.y-e.top(),i=f,u=7,c=ge.fromTag("div"),we(c,{position:"absolute",left:r+"px",top:o-u/2+"px",height:u+"px",width:i+"px"}),te(c,{"data-row":t,role:"presentation"}),c);return co(a,wo),a})},To=function(e,n,t,r){So(e);var o=Gn(n),i=Qn.generate(o);!function(e,n,t,r,o,i){var u=jr(n),c=0=n.length||e.column()>Po(n[0]))return $o.error("invalid start address out of table bounds, row: "+e.row()+", column: "+e.column());var r=n.slice(e.row()),o=r[0].cells().slice(e.column()),i=Po(t[0]),u=t.length;return $o.value({rowDelta:r.length-u,colDelta:o.length-i})}(t,r,o).map(function(e){var n=Zo(r,e,i);return function(e,n,t,r,o){for(var i,u,c,a,l,f=e.row(),s=e.column(),d=f+t.length,m=s+Po(t[0]),g=f;g',r.insertBefore(o,r.firstChild)),""===u.align?Xu(t,r):Vu(t,r,u.align),t.focus(),t.addVisual()})},xc=function(e,n){var t,r,o,i,u,c,a,l,f=e.dom,s=nc(e,Cu(e));!1===n?(t=f.getParent(e.selection.getStart(),"table"))?(o=t,i=Cu(r=e),l=r.dom,s=Re(Re({width:l.getStyle(o,"width")||l.getAttrib(o,"width"),height:l.getStyle(o,"height")||l.getAttrib(o,"height"),cellspacing:l.getStyle(o,"border-spacing")||l.getAttrib(o,"cellspacing"),cellpadding:l.getAttrib(o,"cellpadding")||Uu(r.dom,o,"padding"),border:(u=l,c=o,a=xe(ge.fromDom(c),"border-width"),Ru(r)&&a.isSome()?a.getOr(""):u.getAttrib(c,"border")||Uu(r.dom,c,"border-width")||Uu(r.dom,c,"border")),caption:!!l.select("caption",o)[0],"class":l.getAttrib(o,"class","")},Zu("align","align",r,o)),i?Gu(l,o):{})):Cu(e)&&(s.borderstyle="",s.bordercolor="",s.backgroundcolor=""):(s.cols="1",s.rows="1",Cu(e)&&(s.borderstyle="",s.bordercolor="",s.backgroundcolor=""));var d=0=e.left&&n<=e.right&&t>=e.top&&t<=e.bottom}),ga=function(t,r,e,n,o){var i=function(e){var n=t.dom().createRange();return n.setStart(r.dom(),e),n.collapse(!0),n},u=nt(r).length,c=function(e,n,t,r,o){if(0===o)return 0;if(n===r)return o-1;for(var i=r,u=1;ur.left&&o.leftt.right;var n,t})});var t},El={point:function(e){return e.bottom},adjuster:function(e,n,t,r,o){var i=yl(o,5);return Math.abs(t.bottom-r.bottom)<1||t.top>o.bottom?Dl.retry(i):t.top===o.bottom?Dl.retry(yl(o,1)):Al(e,n,o)?Dl.retry(xl(i,5,0)):Dl.none()},move:yl,gather:fl},kl=function(t,r,o,i,u){return 0===u?C.some(i):(a=t,l=i.left,f=r.point(i),a.elementFromPoint(l,f).filter(function(e){return"table"===$(e)}).isSome()?(n=i,c=u-1,kl(t,e=r,o,e.move(n,5),c)):t.situsFromPoint(i.left,r.point(i)).bind(function(e){return e.start().fold(C.none,function(n){return Ol(t,n).bind(function(e){return r.adjuster(t,n,e,o,i).fold(C.none,function(e){return kl(t,r,o,e,u-1)})}).orThunk(function(){return C.some(i)})},C.none)}));var e,n,c,a,l,f},Bl=function(n,t,e){var r,o,i,u=n.move(e,5),c=kl(t,n,e,u,100).getOr(u);return o=c,i=t,((r=n).point(o)>i.getInnerHeight()?C.some(r.point(o)-i.getInnerHeight()):r.point(o)<0?C.some(-r.point(o)):C.none()).fold(function(){return t.situsFromPoint(c.left,n.point(c))},function(e){return t.scrollBy(0,e),t.situsFromPoint(c.left,n.point(c)-e)})},Nl={tryUp:y(Bl,{point:function(e){return e.top},adjuster:function(e,n,t,r,o){var i=Sl(o,5);return Math.abs(t.top-r.top)<1||t.bottom