landmark-serve
Version:
Web Application Framework and Admin GUI / Content Management System built on Express.js and Mongoose
1 lines • 9.71 kB
JavaScript
!function(e,t){"use strict";function n(e,t){for(var n,i=[],o=0;o<e.length;++o){if(n=s[e[o]]||a(e[o]),!n)throw"module definition dependecy not found: "+e[o];i.push(n)}t.apply(null,i)}function i(e,i,o){if("string"!=typeof e)throw"invalid module definition, module id must be defined and be a string";if(i===t)throw"invalid module definition, dependencies must be specified";if(o===t)throw"invalid module definition, definition function must be specified";n(i,function(){s[e]=o.apply(null,arguments)})}function o(e){return!!s[e]}function a(t){for(var n=e,i=t.split(/[.\/]/),o=0;o<i.length;++o){if(!n[i[o]])return;n=n[i[o]]}return n}function r(n){for(var i=0;i<n.length;i++){for(var o=e,a=n[i],r=a.split(/[.\/]/),l=0;l<r.length-1;++l)o[r[l]]===t&&(o[r[l]]={}),o=o[r[l]];o[r[r.length-1]]=s[a]}}var s={},l="tinymce/pasteplugin/Clipboard",c="tinymce/Env",d="tinymce/util/Tools",u="tinymce/util/VK",p="tinymce/html/DomParser",f="tinymce/html/Serializer",g="tinymce/html/Schema",m="tinymce/pasteplugin/WordFilter",v="tinymce/html/Node",h="tinymce/pasteplugin/Quirks",b="tinymce/pasteplugin/Plugin",y="tinymce/PluginManager";i(l,[c,d,u,p,f,g],function(e,t,n,i,o,a){function r(){return!e.gecko&&("ClipboardEvent"in window||e.webkit&&"FocusEvent"in window)}return function(o){function s(){return(new Date).getTime()}function l(e){return n.metaKeyPressed(e)&&86==e.keyCode||e.shiftKey&&45==e.keyCode}function c(e){function n(e){var t=e.name,i=e;if("br"===t)return l+="\n",void 0;if(c[t]&&(l+=" "),d[t])return l+=" ",void 0;if(3==e.type&&(l+=e.value),!e.shortEnded&&(e=e.firstChild))do n(e);while(e=e.next);u[t]&&i.next&&(l+="\n","p"==t&&(l+="\n"))}var r=new a,s=new i({},r),l="",c=r.getShortEndedElements(),d=t.makeMap("script noscript style textarea video audio iframe object"," "),u=o.schema.getBlockElements();return n(s.parse(e.innerHTML)),l}function d(){return s()-h<100||"text"==v.pasteFormat}function u(e,n){return t.each(n,function(t){e=t.constructor==RegExp?e.replace(t,""):e.replace(t[0],t[1])}),e}function p(t){var n=o.fire("PastePreProcess",{content:t}),i=o.dom;if(t=n.content,o.settings.paste_data_images||(t=t.replace(/<img src=\"data:image[^>]+>/g,"")),(o.settings.paste_remove_styles||o.settings.paste_remove_styles_if_webkit!==!1&&e.webkit)&&(t=t.replace(/ style=\"[^\"]+\"/g,"")),!n.isDefaultPrevented()){if(o.hasEventListeners("PastePostProcess")&&!n.isDefaultPrevented()){var a=i.add(o.getBody(),"div",{style:"display:none"},t);n=o.fire("PastePostProcess",{node:a}),i.remove(a),t=n.node.innerHTML}n.isDefaultPrevented()||o.insertContent(t)}}function f(e){e=o.dom.encode(e).replace(/\r\n/g,"\n");var t=o.dom.getParent(o.selection.getStart(),o.dom.isBlock);e=t&&/^(PRE|DIV)$/.test(t.nodeName)||!o.settings.forced_root_block?u(e,[[/\n/g,"<br>"]]):u(e,[[/\n\n/g,"</p><p>"],[/^(.*<\/p>)(<p>)$/,"<p>$1"],[/\n/g,"<br />"]]),p(e)}function g(){var e=o.dom.getViewPort().y,t=o.dom.add(o.getBody(),"div",{contentEditable:!1,"data-mce-bogus":"1",style:"position: absolute; top: "+e+"px; left: 0; width: 1px; height: 1px; overflow: hidden"},'<div contentEditable="true" data-mce-bogus="1">X</div>');return o.dom.bind(t,"beforedeactivate focusin focusout",function(e){e.stopPropagation()}),t}function m(e){o.dom.unbind(e),o.dom.remove(e)}var v=this,h;if(o.on("keydown",function(e){n.metaKeyPressed(e)&&e.shiftKey&&86==e.keyCode&&(h=s())}),r())o.on("paste",function(e){function t(e,t){for(var i=0;i<n.types.length;i++)if(n.types[i]==e)return t(n.getData(e)),!0}var n=e.clipboardData;n&&(e.preventDefault(),d()?t("text/plain",f)||t("text/html",p):t("text/html",p)||t("text/plain",f))});else{if(e.ie){var b=0;o.on("keydown",function(e){if(l(e)&&!e.isDefaultPrevented()){e.stopImmediatePropagation();var t=g();b=s(),o.dom.bind(t,"paste",function(){setTimeout(function(){o.selection.setRng(n),m(t),d()?f(c(t.firstChild)):p(t.firstChild.innerHTML)},0)});var n=o.selection.getRng();t.firstChild.focus(),t.firstChild.innerText=""}}),o.on("init",function(){var e=o.dom;o.dom.bind(o.getBody(),"paste",function(t){if(s()-b>100){var n,i=g();t.preventDefault(),e.bind(i,"paste",function(e){e.stopPropagation(),n=!0});var a=o.selection.getRng(),r=e.doc.body.createTextRange();if(r.moveToElementText(i.firstChild),r.execCommand("Paste"),m(i),!n)return o.windowManager.alert("Please use Ctrl+V/Cmd+V keyboard shortcuts to paste contents."),void 0;o.selection.setRng(a),d()?f(c(i.firstChild)):p(i.firstChild.innerHTML)}})})}else o.on("init",function(){o.dom.bind(o.getBody(),"paste",function(e){var t=o.getDoc();return e.preventDefault(),e.clipboardData||t.dataTransfer?(f((e.clipboardData||t.dataTransfer).getData("Text")),void 0):(e.preventDefault(),o.windowManager.alert("Please use Ctrl+V/Cmd+V keyboard shortcuts to paste contents."),void 0)})}),o.on("keydown",function(t){if(l(t)&&!t.isDefaultPrevented()){t.stopImmediatePropagation();var n=g(),i=o.selection.getRng();e.webkit&&(n.contentEditable=!0),o.selection.select(n,!0),o.dom.bind(n,"paste",function(e){e.stopPropagation(),setTimeout(function(){m(n),o.lastRng=i,o.selection.setRng(i);var e=n.firstChild;e.lastChild&&"BR"==e.lastChild.nodeName&&e.removeChild(e.lastChild),d()?f(c(e)):p(e.innerHTML)},0)})}});o.settings.paste_data_images||o.on("drop",function(e){var t=e.dataTransfer;t&&t.files&&t.files.length>0&&e.preventDefault()})}o.paste_block_drop&&o.on("dragend dragover draggesture dragdrop drop drag",function(e){e.preventDefault(),e.stopPropagation()}),this.paste=p,this.pasteText=f,this.innerText=c}}),i(m,[d,p,g,f,v],function(e,t,n,i,o){function a(e){return/class="?Mso|style="[^"]*\bmso-|style='[^'']*\bmso-|w:WordDocument/i.test(e)}function r(r){var s=e.each,l=r.settings;r.on("PastePreProcess",function(c){function d(e){s(e,function(e){f=e.constructor==RegExp?f.replace(e,""):f.replace(e[0],e[1])})}function u(e){function t(e,t,r,s){var l=e._listLevel||a;l!=a&&(a>l?n&&(n=n.parent.parent):(i=n,n=null)),n&&n.name==r?n.append(e):(i=i||n,n=new o(r,1),s>1&&n.attr("start",""+s),e.wrap(n)),e.name="li",t.value="";var c=t.next;c&&3==c.type&&(c.value=c.value.replace(/^\u00a0+/,"")),l>a&&i&&i.lastChild.append(n),a=l}for(var n,i,a=1,r=e.getAll("p"),s=0;s<r.length;s++)if(e=r[s],"p"==e.name&&e.firstChild){for(var l="",c=e.firstChild;c&&!(l=c.value);)c=c.firstChild;if(/^\s*[\u2022\u00b7\u00a7\u00d8\u25CF]\s*$/.test(l)){t(e,c,"ul");continue}if(/^\s*\w+\.$/.test(l)){var d=/([0-9])\./.exec(l),u=1;d&&(u=parseInt(d[1],10)),t(e,c,"ol",u);continue}n=null}}function p(t,n){if("p"===t.name){var i=/mso-list:\w+ \w+([0-9]+)/.exec(n);i&&(t._listLevel=parseInt(i[1],10))}if(r.getParam("paste_retain_style_properties","none")){var o="";if(e.each(r.dom.parseStyle(n),function(e,t){switch(t){case"horiz-align":return t="text-align",void 0;case"vert-align":return t="vertical-align",void 0;case"font-color":case"mso-foreground":return t="color",void 0;case"mso-background":case"mso-highlight":t="background"}("all"==g||m&&m[t])&&(o+=t+":"+e+";")}),o)return o}return null}var f=c.content,g,m;if(g=l.paste_retain_style_properties,g&&(m=e.makeMap(g)),l.paste_enable_default_filters!==!1&&a(c.content)){c.wordContent=!0,d([/<!--[\s\S]+?-->/gi,/<(!|script[^>]*>.*?<\/script(?=[>\s])|\/?(\?xml(:\w+)?|img|meta|link|style|\w:\w+)(?=[\s\/>]))[^>]*>/gi,[/<(\/?)s>/gi,"<$1strike>"],[/ /gi,"\xa0"],[/<span\s+style\s*=\s*"\s*mso-spacerun\s*:\s*yes\s*;?\s*"\s*>([\s\u00a0]*)<\/span>/gi,function(e,t){return t.length>0?t.replace(/./," ").slice(Math.floor(t.length/2)).split("").join("\xa0"):""}]]);var v=l.paste_word_valid_elements;v||(v="@[style],-strong/b,-em/i,-span,-p,-ol,-ul,-li,-h1,-h2,-h3,-h4,-h5,-h6,-table,-tr,-td[colspan|rowspan],-th,-thead,-tfoot,-tbody,-a[!href],sub,sup,strike,br");var h=new n({valid_elements:v}),b=new t({},h);b.addAttributeFilter("style",function(e){for(var t=e.length,n;t--;)n=e[t],n.attr("style",p(n,n.attr("style"))),"span"!=n.name||n.attributes.length||n.unwrap()});var y=b.parse(f);u(y),c.content=new i({},h).serialize(y)}})}return r.isWordContent=a,r}),i(h,[c,d,m],function(e,t,n){return function(i){function o(e){i.on("PastePreProcess",function(t){t.content=e(t.content)})}function a(e,n){return t.each(n,function(t){e=t.constructor==RegExp?e.replace(t,""):e.replace(t[0],t[1])}),e}function r(e){return e=a(e,[/^[\s\S]*<!--StartFragment-->|<!--EndFragment-->[\s\S]*$/g,[/<span class="Apple-converted-space">\u00a0<\/span>/g,"\xa0"],/<br>$/])}function s(e){if(!n.isWordContent(e))return e;if(!l){var o=[];t.each(i.schema.getBlockElements(),function(e,t){o.push(t)}),l=new RegExp("(?:<br> [\\s\\r\\n]+|<br>)*(<\\/?("+o.join("|")+")[^>]*>)(?:<br> [\\s\\r\\n]+|<br>)*","g")}return e=a(e,[[l,"$1"]]),e=a(e,[[/<br><br>/g,"<BR><BR>"],[/<br>/g," "],[/<BR><BR>/g,"<br>"]])}var l;e.webkit&&o(r),e.ie&&o(s)}}),i(b,[y,l,m,h],function(e,t,n,i){var o;e.add("paste",function(e){function a(){"text"==s.pasteFormat?(this.active(!1),s.pasteFormat="html"):(s.pasteFormat="text",this.active(!0),o||(e.windowManager.alert("Paste is now in plain text mode. Contents will now be pasted as plain text until you toggle this option off."),o=!0))}var r=this,s,l=e.settings;r.clipboard=s=new t(e),r.quirks=new i(e),r.wordFilter=new n(e),r.innerText=s.innerText,e.settings.paste_as_text&&(r.clipboard.pasteFormat="text"),l.paste_preprocess&&e.on("PastePreProcess",function(e){l.paste_preprocess.call(r,r,e)}),l.paste_postprocess&&e.on("PastePostProcess",function(e){l.paste_postprocess.call(r,r,e)}),e.addCommand("mceInsertClipboardContent",function(e,t){t.content&&r.clipboard.paste(t.content),t.text&&r.clipboard.pasteText(t.text)}),e.addButton("pastetext",{icon:"pastetext",tooltip:"Paste as text",onclick:a,active:"text"==r.clipboard.pasteFormat}),e.addMenuItem("pastetext",{text:"Paste as text",selectable:!0,active:s.pasteFormat,onclick:a})})}),r([l,m,h,b])}(this);