!function(){var a={},b=function(b){for(var c=a[b],e=c.deps,f=c.defn,g=e.length,h=new Array(g),i=0;ib.start.length?-1:a.start.length0},e=function(b,e,f,g){var h,i,j=a(b);for(i=0;i0?a.splitText(d):a,a.splitText(c-d-e),a.deleteData(0,b.start.length),a.deleteData(a.data.length-b.end.length,b.end.length),a},e=function(a,b,e){var f,g,h,i,j,k,l,m,n,o,p;if(f=a.selection,g=a.dom,f.isCollapsed()&&(h=f.getRng(!0),i=h.startContainer,j=h.startOffset,l=i.data,o=e===!0?1:0,3==i.nodeType&&(n=c.findEndPattern(b,l,j,o),void 0!==n&&(k=Math.max(0,j-o),k=l.lastIndexOf(n.start,k-n.end.length-1),k!==-1&&(m=g.createRng(),m.setStart(i,k),m.setEnd(i,j-o),n=c.findPattern(b,m.toString()),n&&n.end&&!(i.data.length<=n.start.length+n.end.length))))))return p=a.formatter.get(n.format),p&&p[0].inline?(a.undoManager.transact(function(){i=d(i,n,j,k,o),a.formatter.apply(n.format,{},i)}),i):void 0},f=function(d,e){var f,g,h,i,j,k,l,m,n,o,p;if(f=d.selection,g=d.dom,f.isCollapsed()&&(l=g.getParent(f.getStart(),"p"))){for(n=new a(l,l);j=n.next();)if(3==j.nodeType){i=j;break}if(i){if(m=c.findPattern(e,i.data),!m)return;if(o=f.getRng(!0),h=o.startContainer,p=o.startOffset,i==h&&(p=Math.max(0,p-m.start.length)),b.trim(i.data).length==m.start.length)return;m.format&&(k=d.formatter.get(m.format),k&&k[0].block&&(i.deleteData(0,m.start.length),d.formatter.apply(m.format,{},i),o.setStart(h,p),o.collapse(!0),f.setRng(o))),m.cmd&&d.undoManager.transact(function(){i.deleteData(0,m.start.length),d.execCommand(m.cmd)})}}};return{applyInlineFormat:e,applyBlockFormat:f}}),g("5",["3","4"],function(a,b){function c(a,c){var d,e;e=b.applyInlineFormat(a,c,!1),e&&(d=a.dom.createRng(),d.setStart(e,e.data.length),d.setEnd(e,e.data.length),a.selection.setRng(d)),b.applyBlockFormat(a,c)}function d(a,c){var d,e,f,g,h;d=b.applyInlineFormat(a,c,!0),d&&(h=a.dom,e=d.data.slice(-1),/[\u00a0 ]/.test(e)&&(d.deleteData(d.data.length-1,1),f=h.doc.createTextNode(e),d.nextSibling?h.insertAfter(f,d.nextSibling):d.parentNode.appendChild(f),g=h.createRng(),g.setStart(f,1),g.setEnd(f,1),a.selection.setRng(g)))}var e=function(a,b,c){for(var d=0;d