@progress/kendo-ui
Version:
This package is part of the [Kendo UI for jQuery](http://www.telerik.com/kendo-ui) suite.
1 lines • 18.3 kB
JavaScript
module.exports=function(e){function t(i){if(n[i])return n[i].exports;var s=n[i]={exports:{},id:i,loaded:!1};return e[i].call(s.exports,s,s.exports,t),s.loaded=!0,s.exports}var n={};return t.m=e,t.c=n,t.p="",t(0)}({0:function(e,t,n){e.exports=n(976)},3:function(e,t){e.exports=function(){throw Error("define cannot be used indirect")}},976:function(e,t,n){var i,s,o;!function(r,define){s=[n(977)],i=r,o="function"==typeof i?i.apply(t,s):i,!(void 0!==o&&(e.exports=o))}(function(){!function(e){var t=window.kendo,n=t.Class,i=t.ui.editor,s=i.RangeUtils,o=i.Dom,r=i.RestorePoint,a=i.Marker,l=t.support.browser,c=e.extend,d=n.extend({init:function(e){this.editor=e;var t=e.options.pasteCleanup;this.cleaners=[new u(t),new h(t),new f(t),new m(t),new b(t),new v(t),new C(t),new w(t)]},htmlToFragment:function(e){var t=this.editor,n=t.document,i=o.create(n,"div"),s=n.createDocumentFragment();for(i.innerHTML=e;i.firstChild;)s.appendChild(i.firstChild);return s},isBlock:function(e){return/<(div|p|ul|ol|table|h[1-6])/i.test(e)},_startModification:function(){var e,t,n=this.editor;if(!this._inProgress)return this._inProgress=!0,e=n.getRange(),t=new r(e,n.body),o.persistScrollTop(n.document),{range:e,restorePoint:t}},_endModification:function(e){i._finishUpdate(this.editor,e.restorePoint),this.editor._selectionChange(),this._inProgress=!1},_contentModification:function(e,t){var n=this,i=n.editor,s=n._startModification();s&&(e.call(n,i,s.range),setTimeout(function(){t.call(n,i,s.range),n._endModification(s)}))},_removeBomNodes:function(e){var t,n=s.textNodes(e);for(t=0;t<n.length;t++)n[t].nodeValue=o.stripBom(n[t].nodeValue)||n[t].nodeValue},_onBeforeCopy:function(e){var t=new a;t.add(e),this._removeBomNodes(e),t.remove(e),this.editor.selectRange(e)},oncopy:function(){this._onBeforeCopy(this.editor.getRange())},oncut:function(){this._onBeforeCopy(this.editor.getRange()),this._contentModification(e.noop,e.noop)},_fileToDataURL:function(t){var n=e.Deferred(),i=new FileReader;return t instanceof window.File||!t.getAsFile||(t=t.getAsFile()),i.onload=e.proxy(n.resolve,n),i.readAsDataURL(t),n.promise()},_triggerPaste:function(e,t){var n={html:e||""};n.html=n.html.replace(/\ufeff/g,""),this.editor.trigger("paste",n),this.paste(n.html,t||{})},_handleImagePaste:function(e){var t,n;if("FileReader"in window&&!(l.msie&&l.version>10))return t=e.clipboardData||e.originalEvent.clipboardData||window.clipboardData||{},n=t.items||t.files,this._insertImages(n)},_insertImages:function(t){var n,i,s;if(t&&(n=e.grep(t,function(e){return/^image\//i.test(e.type)}),i=e.grep(t,function(e){return/^text\/html/i.test(e.type)}),!i.length&&n.length&&(s=this._startModification())))return e.when.apply(e,e.map(n,this._fileToDataURL)).done(e.proxy(function(){var t=Array.prototype.slice.call(arguments),n=e.map(t,function(e){return'<img src="'+e.target.result+'" />'}).join("");this._triggerPaste(n),this._endModification(s)},this)),!0},onpaste:function(n){if("false"!==this.editor.body.contentEditable){if(this._handleImagePaste(n))return void n.preventDefault();this.expandImmutablesIn(),this._contentModification(function(i,s){var r,a,l,c=o.create(i.document,"div",{className:"k-paste-container",innerHTML:"\ufeff"}),d=t.support.browser,p=i.body;this._decoreateClipboardNode(c,p),p.appendChild(c),d.webkit&&this._moveToCaretPosition(c,s),d.msie&&d.version<11?(n.preventDefault(),r=i.createRange(),r.selectNodeContents(c),i.selectRange(r),a=i.document.body.createTextRange(),a.moveToElementText(c),e(p).off("paste"),a.execCommand("Paste"),e(p).on("paste",e.proxy(this.onpaste,this))):(l=i.createRange(),l.selectNodeContents(c),i.selectRange(l)),s.deleteContents()},function(t,n){var i,s="";t.selectRange(n),i=e(t.body).children(".k-paste-container"),i.each(function(){var e=this.lastChild;e&&o.is(e,"br")&&o.remove(e),s+=this.innerHTML}),i.remove(),this._triggerPaste(s,{clean:!0})})}},ondragover:function(e){(l.msie||l.edge)&&(e.stopPropagation(),e.preventDefault())},ondrop:function(e){var t,n;"FileReader"in window&&(t=(e.originalEvent||e).dataTransfer||{},n=t.items||t.files,this._insertImages(n)&&e.preventDefault())},_decoreateClipboardNode:function(t,n){var i,s,o,r;(l.msie||l.webkit)&&(t=e(t),t.css({borderWidth:"0px",width:"0px",height:"0px",overflow:"hidden",margin:"0",padding:"0"}),l.msie&&(i=e(n.ownerDocument.documentElement),t.css({fontVariant:"normal",fontWeight:"normal",lineSpacing:"normal",lineHeight:"normal",textDecoration:"none"}),s=i.css("color"),s&&t.css("color",s),o=i.css("fontFamily"),o&&t.css("fontFamily",o),r=i.css("fontSize"),r&&t.css("fontSize",r)))},_moveToCaretPosition:function(t,n){var i=this,s=i.editor.body,r=o.offset(t,s),a=i._caretOffset(n,s),l=a.left-r.left,c=a.top-r.top,d="translate("+l+"px,"+c+"px)";e(t).css({"-webkit-transform":d,transform:d})},_caretOffset:function(e,t){var n,i,s,r,a,l,c=this.editor,d=o.create(c.document,"span",{innerHTML:"\ufeff"}),p=e.startContainer;return e.collapsed?(i=o.isDataNode(p),i&&(o.isBom(p)||0===e.startOffset)?o.insertBefore(d,p):i&&e.startOffset===p.length?o.insertAfter(d,p):(e.insertNode(d),n=!0)):(p=p===t?p.childNodes[e.startOffset]:p,o.insertBefore(d,p)),s=o.offset(d,t),r=d.previousSibling,a=d.nextSibling,o.remove(d),n&&o.isDataNode(r)&&o.isDataNode(a)&&!o.isBom(r)&&!o.isBom(a)&&(l=r.length,a.data=r.data+a.data,e.setStart(a,l),o.remove(r),e.collapse(!0),c.selectRange(e)),s},expandImmutablesIn:function(e){var n,i,s,o=this.editor;o&&o.options.immutables&&(n=o.body,e=e||o.getRange(),t.ui.editor.Immutables.expandImmutablesIn(e),e.startContainer===n&&0===e.startOffset&&(i=n.ownerDocument,s=i.createTextNode("\ufeff"),n.insertBefore(s,n.childNodes[0]),e.setStartBefore(s)),o.selectRange(e))},splittableParent:function(e,t){var n,i;if(e)return o.closestEditableOfType(t,["p","ul","ol"])||t.parentNode;if(n=t.parentNode,i=t.ownerDocument.body,o.isInline(n))for(;n.parentNode!=i&&!o.isBlock(n.parentNode);)n=n.parentNode;return n},paste:function(t,n){var i,r,l,d,p,u,h,f,m,g,b,v,x,T,y,C,w,L=this.editor;if(this.expandImmutablesIn(),n=c({clean:!1,split:!0},n),!n.skipCleaners)for(i=0,r=this.cleaners.length;i<r;i++)this.cleaners[i].applicable(t)&&(t=this.cleaners[i].clean(t));if(n.clean&&(t=t.replace(/(<br>(\s| )*)+(<\/?(div|p|li|col|t))/gi,"$3"),t=t.replace(/<(a|span)[^>]*><\/\1>/gi,"")),t=t.replace(/<(a|span|font)([^>]*)> <\/\1>/gi,"<$1$2> </$1>"),t=t.replace(/^<li/i,"<ul><li").replace(/li>$/g,"li></ul>"),d=this.isBlock(t),L.focus(),p=L.getRange(),p.deleteContents(),p.startContainer==L.document&&p.selectNodeContents(L.body),u=new a,h=u.addCaret(p),f=this.splittableParent(d,h),m=!1,g=f!=L.body&&!o.is(f,"td"),n.split&&g&&(d||o.isInline(f))&&(p.selectNode(h),s.split(p,f,!0),m=!0),b=this.htmlToFragment(t),b.firstChild&&"k-paste-container"===b.firstChild.className){for(v=[],i=0,r=b.childNodes.length;i<r;i++)v.push(b.childNodes[i].innerHTML);b=this.htmlToFragment(v.join("<br />"))}if(l=b.childNodes,e(l).filter("table").addClass("k-table").end().find("table").addClass("k-table"),e(l).each(function(e,t){o.isBlock(t)&&!o.isSelfClosing(t)&&""===t.innerHTML&&t.appendChild(L.document.createTextNode("\ufeff"))}),p.insertNode(b),f=this.splittableParent(d,h),m){for(;h.parentNode!=f;)o.unwrap(h.parentNode);o.unwrap(h.parentNode)}if(o.normalize(p.commonAncestorContainer),h.style.display="inline",o.restoreScrollTop(L.document),o.scrollTo(h),u.removeCaret(p),x=p.commonAncestorContainer.parentNode,(p.collapsed&&"tbody"==o.name(x)||p.collapsed&&"thead"==o.name(x))&&(p.setStartAfter(e(x).closest("table")[0]),p.collapse(!0)),T=e(p.commonAncestorContainer.parentNode).closest("table"),T.get(0)){for(y=T.parent().contents(),C=y.length-1,w=y.get(C);null!==w.nodeValue&&(" "===w.nodeValue||""===w.nodeValue);)C-=1,w=y.get(C);w!==T.get(0)||T.parents("table").length||o.insertAfter(o.createEmptyNode(L.document,"p"),T[0])}L.selectRange(p)}}),p=n.extend({init:function(e){this.options=e||{},this.replacements=[]},clean:function(e,t){var n,i,s=this,o=t||s.replacements;for(n=0,i=o.length;n<i;n+=2)e=e.replace(o[n],o[n+1]);return e}}),u=p.extend({init:function(e){p.fn.init.call(this,e),this.replacements=[/<(\/?)script([^>]*)>/i,"<$1telerik:script$2>"]},applicable:function(e){return!this.options.none&&/<script[^>]*>/i.test(e)}}),h=p.extend({init:function(e){p.fn.init.call(this,e);var t=" ";this.replacements=[/<span\s+class="Apple-tab-span"[^>]*>\s*<\/span>/gi,t,/\t/gi,t,/ /gi,t]},applicable:function(e){return/ |class="?Apple-tab-span/i.test(e)}}),f=p.extend({init:function(e){p.fn.init.call(this,e),this.junkReplacements=[/<\?xml[^>]*>/gi,"",/<!--(.|\n)*?-->/g,"",/"/g,"'",/<o:p> <\/o:p>/gi," ",/<\/?(meta|link|style|o:|v:|x:)[^>]*>((?:.|\n)*?<\/(meta|link|style|o:|v:|x:)[^>]*>)?/gi,"",/<\/o>/g,""],this.replacements=this.junkReplacements.concat([/(?:<br> [\s\r\n]+|<br>)*(<\/?(h[1-6]|hr|p|div|table|tbody|thead|tfoot|th|tr|td|li|ol|ul|caption|address|pre|form|blockquote|dl|dt|dd|dir|fieldset)[^>]*>)(?:<br> [\s\r\n]+|<br>)*/g,"$1",/<br><br>/g,"<BR><BR>",/<br>(?!\n)/g," ",/<table([^>]*)>(\s| )+<t/gi,"<table$1><t",/<tr[^>]*>(\s| )*<\/tr>/gi,"",/<tbody[^>]*>(\s| )*<\/tbody>/gi,"",/<table[^>]*>(\s| )*<\/table>/gi,"",/<BR><BR>/g,"<br>",/^\s*( )+/gi,"",/( |<br[^>]*>)+\s*$/gi,"",/mso-[^;"]*;?/gi,"",/<(\/?)b(\s[^>]*)?>/gi,"<$1strong$2>",/<(\/?)font(\s[^>]*)?>/gi,this.convertFontMatch,/<(\/?)i(\s[^>]*)?>/gi,"<$1em$2>",/style=(["|'])\s*\1/g,"",/(<br[^>]*>)?\n/g,function(e,t){return t?e:" "}])},convertFontMatch:function(e,t,n){var i=/face=['"]([^'"]+)['"]/i,s=i.exec(n),o=n&&s&&s[1];return t?"</span>":o?'<span style="font-family:'+o+'">':"<span>"},applicable:function(e){return/class="?Mso/i.test(e)||/style="[^"]*mso-/i.test(e)||/urn:schemas-microsoft-com:office/.test(e)},stripEmptyAnchors:function(e){return e.replace(/<a([^>]*)>\s*<\/a>/gi,function(e,t){return!t||t.indexOf("href")<0?"":e})},listType:function(e,t){var n,i=e.innerHTML,s=o.innerText(e),r=i.match(/^(?:<span [^>]*texhtml[^>]*>)?<span [^>]*(?:Symbol|Wingdings)[^>]*>([^<]+)/i),a=r&&r[1],l=/^[a-z\d]/i.test(a),c=function(e){return e.replace(/^(?: |[\u00a0\n\r\s])+/,"")};return r&&(n=!0),i=i.replace(/<\/?\w+[^>]*>/g,"").replace(/ /g," "),!n&&/^[\u2022\u00b7\u00a7\u00d8o]\u00a0+/.test(i)||n&&/^.\u00a0+/.test(i)||a&&!l&&t?{tag:"ul",style:this._guessUnorderedListStyle(c(s))}:/^\s*\w+[\.\)][\u00a0 ]{2,}/.test(i)?{tag:"ol",style:this._guessOrderedListStyle(c(s))}:void 0},_convertToLi:function(e){var t;return 1==e.childNodes.length?(t=e.firstChild.nodeType===o.nodeTypes.TEXT_NODE?o.innerText(e):e.firstChild.innerHTML.replace(/^\w+[\.\)]( )+ /,""),t=this._checkForBullet(t)):t=this._getHtmlNoBullet(e),o.remove(e),o.create(document,"li",{innerHTML:t})},_checkForBullet:function(e){var t=o.create(document,"p",{innerHTML:e}),n=/^\s*\w+[\.\)]\s+/;return n.test(t.innerText)?this._getHtmlNoBullet(t):e},_getHtmlNoBullet:function(e){var t,n=o.name(e);return o.remove(e.firstChild),3==e.firstChild.nodeType&&/^[ivxlcdm]+\.$/i.test(e.firstChild.nodeValue)&&o.remove(e.firstChild),/^( |\s)+$/i.test(e.firstChild.innerHTML)&&o.remove(e.firstChild),t="p"!=n?"<"+n+">"+e.innerHTML+"</"+n+">":e.innerHTML},_guessUnorderedListStyle:function(e){return/^[\u2022\u00b7\u00FC\u00D8\u002dv-]/.test(e)?null:/^o/.test(e)?"circle":"square"},_guessOrderedListStyle:function(e){var t=null;return/^\d/.test(e)||(t=(/^[a-z]/.test(e)?"lower-":"upper-")+(/^[ivxlcdm]/i.test(e)?"roman":"alpha")),t},extractListLevels:function(e){var n=/style=['"]?[^'"]*?mso-list:\s?[a-zA-Z]+(\d+)\s[a-zA-Z]+(\d+)\s(\w+)/gi;return e=e.replace(n,function(e,n,i){return t.format('data-list="{0}" data-level="{1}" {2}',n,i,e)})},_createList:function(e,t){return o.create(document,e,{style:{listStyleType:t}})},lists:function(t){var n,i,s,r,a,c,d,p,u,h,f,m,g,b,v,x,T=e(t).find(o.blockElements.join(",")),y=-1,C={},w=["p","h1","h2","h3","h4","h5","h6"],L=!1;for(p=0;p<T.length;p++)u=T[p],g=e(u).data(),b=g.list,n=o.name(u),L=!!e(u).parents("table").length,L||(v=this.listType(u,g),h=v&&v.tag,!h||w.indexOf(n)<0?u.innerHTML?i&&!c&&i.appendChild(u):o.remove(u):l.msie||(f=g.level||parseFloat(u.style.marginLeft||0),x=h+b,C[f]||(C[f]={}),(!s||s<0)&&(s=f,r=b,a=e(t).find("[data-list='"+r+"']").last()[0],d=this._createList(h,v.style),o.insertBefore(d,u),y=f,C[f][x]=d),c=a===u,m=C[f][x],(f>y||!m)&&(m=this._createList(h,v.style),C[f][x]=m,i.appendChild(m)),i=this._convertToLi(u),m.appendChild(i),c?s=y=-1:y=f))},removeAttributes:function(e){for(var t=e.attributes,n=t.length;n--;)"colspan"!=o.name(t[n])&&e.removeAttributeNode(t[n])},createColGroup:function(n){var i=n.cells,s=e(n).closest("table"),o=s.children("colgroup");i.length<2||(o.length&&(i=o.children(),o[0].parentNode.removeChild(o[0])),o=e(e.map(i,function(e){var n=e.width;return n&&0!==parseInt(n,10)?t.format('<col style="width:{0}px;"/>',n):"<col />"}).join("")),o.is("colgroup")||(o=e("<colgroup/>").append(o)),o.prependTo(s))},convertHeaders:function(t){var n,i=t.cells,s=e.map(i,function(t){var n=e(t).children("p").children("strong")[0];if(n&&"strong"==o.name(n))return n});if(s.length==i.length){for(n=0;n<s.length;n++)o.unwrap(s[n]);for(e(t).closest("table").find("colgroup").after("<thead></thead>").end().find("thead").append(t),n=0;n<i.length;n++)o.changeTag(i[n],"th")}},removeParagraphs:function(t){var n,i,s,r,a;for(n=0;n<t.length;n++)for(this.removeAttributes(t[n]),r=e(t[n]),a=r.children("p"),i=0,s=a.length;i<s;i++)i<s-1&&o.insertAfter(o.create(document,"br"),a[i]),o.unwrap(a[i])},removeDefaultColors:function(e){for(var t=0;t<e.length;t++)/^\s*color:\s*[^;]*;?$/i.test(e[t].style.cssText)&&o.unwrap(e[t])},removeTextNodes:function(e){var t,n,i,s,r;for(t=0;t<e.length;t++)for(r=e[t],i=r.childNodes,n=0;n<i.length;n++)s=i[n],s.nodeType===o.nodeTypes.TEXT_NODE&&r.removeChild(s)},tables:function(t){var n,i,s,o,r,a=e(t).find("table"),l=this;for(o=0;o<a.length;o++){for(n=a[o].rows,s=i=n[0],r=1;r<n.length;r++)n[r].cells.length>s.cells.length&&(s=n[r]);l.createColGroup(s),l.convertHeaders(i),l.removeAttributes(a[o]),l.removeParagraphs(a.eq(o).find("td,th")),l.removeDefaultColors(a.eq(o).find("span")),l.removeTextNodes(a.eq(o).find("tr"))}},headers:function(t){var n,i=e(t).find("p.MsoTitle");for(n=0;n<i.length;n++)o.changeTag(i[n],"h1")},removeFormatting:function(t){e(t).find("*").each(function(){e(this).css({fontSize:"",fontFamily:""}),this.getAttribute("style")||this.style.cssText||this.removeAttribute("style")})},clean:function(e){var t,n=this,i=this.options;return i.none?(e=p.fn.clean.call(n,e,this.junkReplacements),e=n.stripEmptyAnchors(e)):(e=i.msConvertLists?this.extractListLevels(e):e,e=p.fn.clean.call(n,e),e=n.stripEmptyAnchors(e),t=o.create(document,"div",{innerHTML:e}),n.headers(t),i.msConvertLists&&n.lists(t),n.tables(t),i.msAllFormatting&&n.removeFormatting(t),e=t.innerHTML.replace(/(<[^>]*)\s+class="?[^"\s>]*"?/gi,"$1")),e}}),m=p.extend({init:function(e){p.fn.init.call(this,e),this.replacements=[/\s+class="Apple-style-span[^"]*"/gi,"",/<(div|p|h[1-6])\s+style="[^"]*"/gi,"<$1",/^<div>(.*)<\/div>$/,"$1"]},applicable:function(e){return/class="?Apple-style-span|style="[^"]*-webkit-nbsp-mode/i.test(e)}}),g=p.extend({clean:function(e){var t=o.create(document,"div",{innerHTML:e});return t=this.cleanDom(t),t.innerHTML},cleanDom:function(e){return e}}),b=g.extend({cleanDom:function(t){var n=this.collectTags();return e(t).find(n).each(function(){o.unwrap(this)}),t},collectTags:function(){if(this.options.span)return"span"},applicable:function(){return this.options.span}}),v=g.extend({cleanDom:function(t){var n=this.collectAttr(),i=e(t).find("["+n.join("],[")+"]");return i.removeAttr(n.join(" ")),t},collectAttr:function(){return this.options.css?["class","style"]:[]},applicable:function(){return this.options.css}}),x=function(){this.text="",this.add=function(e){this.text+=e}},T=n.extend({init:function(e){this.separators=e||{text:" ",line:"<br/>"},this.lines=[],this.inlineBlockText=[],this.resetLine()},appendText:function(e){3===e.nodeType&&(e=e.nodeValue),this.textContainer.add(e)},appendInlineBlockText:function(e){this.inlineBlockText.push(e)},flashInlineBlockText:function(){this.inlineBlockText.length&&(this.appendText(this.inlineBlockText.join(" ")),this.inlineBlockText=[])},endLine:function(){this.flashInlineBlockText(),this.resetLine()},html:function(){var e,t,n,i,s,o,r,a,l=this.separators,c="",d=this.lines;for(this.flashInlineBlockText(),e=0,t=d.length,n=t-1;e<t;e++){for(i=d[e],s=0,o=i.length,r=o-1;s<o;s++)a=i[s].text,c+=a,s!==r&&(c+=l.text);e!==n&&(c+=l.line)}return c},resetLine:function(){this.textContainer=new x,this.line=[],this.line.push(this.textContainer),this.lines.push(this.line)}}),y=n.extend({init:function(e){this.callback=e},enumerate:function(e){var t,n;e&&(t=this.callback(e),n=e.firstChild,!t&&n&&this.enumerate(n),this.enumerate(e.nextSibling))}}),C=p.extend({init:function(t){p.fn.init.call(this,t),this.hasText=!1,this.enumerator=new y(e.proxy(this.buildText,this))},clean:function(e){var t=o.create(document,"div",{innerHTML:e});return this.cleanDom(t)},cleanDom:function(e){return this.separators=this.getDefaultSeparators(),this.htmlLines=new T(this.separators),this.enumerator.enumerate(e.firstChild),this.hasText=!1,this.htmlLines.html()},buildText:function(e){if(o.isDataNode(e)){if(o.isEmptyspace(e))return;this.htmlLines.appendText(e.nodeValue.replace("\n",this.separators.line)),this.hasText=!0}else{if(o.isBlock(e)&&this.hasText){var t=this.actions[o.name(e)]||this.actions.block;return t(this,e)}o.isBr(e)&&this.htmlLines.appendText(this.separators.line)}},applicable:function(){var e=this.options;return e.all||e.keepNewLines},getDefaultSeparators:function(){return this.options.all?{text:" ",line:" "}:{text:" ",line:"<br/>"}},actions:{ul:e.noop,ol:e.noop,table:e.noop,thead:e.noop,tbody:e.noop,td:function(e,t){var n=new C({all:!0}),i=n.cleanDom(t);return e.htmlLines.appendInlineBlockText(i),!0},block:function(e){e.htmlLines.endLine()}}}),w=p.extend({clean:function(e){return this.options.custom(e)},applicable:function(){return"function"==typeof this.options.custom}});c(i,{Clipboard:d,Cleaner:p,ScriptCleaner:u,TabCleaner:h,MSWordFormatCleaner:f,WebkitFormatCleaner:m,HtmlTagsCleaner:b,HtmlAttrCleaner:v,HtmlContentCleaner:C,HtmlTextLines:T,CustomCleaner:w})}(window.kendo.jQuery)},n(3))},977:function(e,t){e.exports=require("../command")}});