UNPKG

@progress/kendo-ui

Version:

This package is part of the [Kendo UI for jQuery](http://www.telerik.com/kendo-ui) suite.

1 lines 4.22 kB
module.exports=function(e){function t(i){if(n[i])return n[i].exports;var r=n[i]={exports:{},id:i,loaded:!1};return e[i].call(r.exports,r,r.exports,t),r.loaded=!0,r.exports}var n={};return t.m=e,t.c=n,t.p="",t(0)}({0:function(e,t,n){e.exports=n(992)},3:function(e,t){e.exports=function(){throw Error("define cannot be used indirect")}},988:function(e,t){e.exports=require("./formatblock")},992:function(e,t,n){var i,r,o;!function(s,define){r=[n(988)],i=s,o="function"==typeof i?i.apply(t,r):i,!(void 0!==o&&(e.exports=o))}(function(){!function(e){var t=window.kendo,n=e.extend,i=t.ui.editor,r=i.Dom,o=i.Command,s=i.Tool,a=i.BlockFormatter,l=r.normalize,d=i.RangeUtils,p=i.EditorUtils.registerTool,f=o.extend({init:function(e){this.options=e,o.fn.init.call(this,e)},_insertMarker:function(e,t){var n,i=r.create(e,"a");return i.className="k-marker",t.insertNode(i),i.parentNode||(n=t.commonAncestorContainer,n.innerHTML="",n.appendChild(i)),l(i.parentNode),i},_moveFocus:function(e,t){var n,i;if(r.isEmpty(t))e.setStartBefore(t);else{if(e.selectNodeContents(t),n=d.textNodes(e)[0],!n){for(;t.childNodes.length&&!r.is(t.firstChild,"br");)t=t.firstChild;n=t}r.isEmpty(n)?e.setStartBefore(n):(r.emptyNode(n)&&(n.innerHTML="\ufeff"),i=n.firstChild||n,r.isDataNode(i)?e.setStart(i,0):e.setStartBefore(i))}},shouldTrim:function(e){var t="p,h1,h2,h3,h4,h5,h6".split(","),n=r.parentOfType(e.startContainer,t),i=r.parentOfType(e.endContainer,t);return n&&!i||!n&&i},_blankAfter:function(e){for(;e&&(r.isMarker(e)||""===r.stripBom(e.nodeValue));)e=e.nextSibling;return!e},exec:function(){var t,n,o,s,p,f,c,h,m,u,g,N,C,b,x=this.getRange(),v=d.documentFromRange(x),y=i.emptyElementContent;this.expandImmutablesIn(x),u=this.shouldTrim(x),x.deleteContents(),p=this._insertMarker(v,x),r.stripBomNode(p.previousSibling),r.stripBomNode(p.nextSibling),f=r.closestEditableOfType(p,["li"]),c=r.closestEditableOfType(p,"h1,h2,h3,h4,h5,h6".split(",")),h=r.is(p.parentNode,"table")&&p.parentNode,f?r.emptyNode(f)&&(s=r.create(v,"p"),r.next(f)&&(m=x.cloneRange(),m.selectNode(f),d.split(m,f.parentNode)),g=e("br",f),1==g.length&&g.remove(),N=f.parentNode,C=f.parentNode.children.length,b=C>1&&1==f.childNodes.length&&f.children[0],r.insertAfter(s,N),r.remove(1==C?f.parentNode:f),b&&b!==p?(s.appendChild(b),s.appendChild(p)):s.innerHTML=y,o=s):c&&this._blankAfter(p)?(s=this._insertParagraphAfter(c),r.remove(p),o=s):h&&(s=this._insertParagraphAfter(h),r.remove(p),o=s),o||(f||c||new a([{tags:["p"]}]).apply([p]),x.selectNode(p),t=r.parentOfType(p,[f?"li":c?r.name(c):"p"]),d.split(x,t,u),n=t.previousSibling,r.is(n,"li")&&n.firstChild&&!r.is(n.firstChild,"br")&&(n=n.firstChild),o=t.nextSibling,this.clean(n,{links:!0}),this.clean(o,{links:!0}),r.is(o,"li")&&o.firstChild&&!r.is(o.firstChild,"br")&&(o=o.firstChild),r.remove(t),l(n)),l(o),this._moveFocus(x,o),x.collapse(!0),r.scrollTo(o,!0),d.selectRange(x)},_insertParagraphAfter:function(e){var t=this.getRange(),n=d.documentFromRange(t),o=i.emptyElementContent,s=r.create(n,"p");return r.insertAfter(s,e),s.innerHTML=o,s},clean:function(t,n){var o,s=t;if(t.firstChild&&r.is(t.firstChild,"br")&&r.remove(t.firstChild),r.isDataNode(t)&&!t.nodeValue&&(t=t.parentNode),t){for(o=!1;t.firstChild&&1==t.firstChild.nodeType;)o=o||r.significantNodes(t.childNodes).length>1,t=t.firstChild;if(r.isEmpty(t)||!/^\s*$/.test(t.innerHTML)||o||(e(s).find(".k-br").remove(),t.innerHTML=i.emptyElementContent),n&&n.links)for(;t!=s;){if(r.is(t,"a")&&r.emptyNode(t)){r.unwrap(t);break}t=t.parentNode}}}}),c=o.extend({init:function(e){this.options=e,o.fn.init.call(this,e)},exec:function(){var e,n,i,o,s,a,p=this.getRange();this.expandImmutablesIn(p),e=r.create(d.documentFromRange(p),"br"),n=p.startContainer,o=t.support.browser,s=o.msie&&o.version<11,a=r.is(n,"table")&&n,p.deleteContents(),a?r.insertAfter(e,a):p.insertNode(e),l(e.parentNode),s||e.nextSibling&&!r.isWhitespace(e.nextSibling)||(i=e.cloneNode(!0),i.className="k-br",r.insertAfter(i,e)),p.setStartAfter(e),p.collapse(!0),r.scrollTo(e.nextSibling||e,!0),d.selectRange(p)}});n(i,{ParagraphCommand:f,NewLineCommand:c}),p("insertLineBreak",new s({key:13,shift:!0,command:c})),p("insertParagraph",new s({key:13,command:f}))}(window.kendo.jQuery)},n(3))}});