From af8cc35b17aa33809c453b7f59d3635f871bbcf0 Mon Sep 17 00:00:00 2001 From: Anthony Blackshaw Date: Thu, 2 Aug 2018 23:26:02 +0100 Subject: [PATCH] - Removed legacy coffee. - Added data-mh-transform-proxied restricted attributes. --- coffee/.gitignore | 8 - coffee/.sass-lint.yml | 146 ------------- coffee/LICENSE | 21 -- coffee/README.md | 3 - coffee/coffeelint.json | 54 ----- coffee/dist/index.js | 1 - coffee/dist/sass/_content.scss | 4 - coffee/package.json | 35 --- coffee/src/scripts/api.coffee | 12 -- coffee/src/scripts/content.coffee | 156 -------------- coffee/src/scripts/image-uploader.coffee | 264 ----------------------- coffee/webpack.config.js | 85 -------- module/index.js | 1 + 13 files changed, 1 insertion(+), 789 deletions(-) delete mode 100644 coffee/.gitignore delete mode 100644 coffee/.sass-lint.yml delete mode 100644 coffee/LICENSE delete mode 100644 coffee/README.md delete mode 100644 coffee/coffeelint.json delete mode 100644 coffee/dist/index.js delete mode 100644 coffee/dist/sass/_content.scss delete mode 100644 coffee/package.json delete mode 100644 coffee/src/scripts/api.coffee delete mode 100644 coffee/src/scripts/content.coffee delete mode 100644 coffee/src/scripts/image-uploader.coffee delete mode 100644 coffee/webpack.config.js diff --git a/coffee/.gitignore b/coffee/.gitignore deleted file mode 100644 index a30fff1..0000000 --- a/coffee/.gitignore +++ /dev/null @@ -1,8 +0,0 @@ -# Directories -.cache -.sass-cache -node_modules - -# Files -npm-debug.log -*~ \ No newline at end of file diff --git a/coffee/.sass-lint.yml b/coffee/.sass-lint.yml deleted file mode 100644 index 0f9263a..0000000 --- a/coffee/.sass-lint.yml +++ /dev/null @@ -1,146 +0,0 @@ -# Rule Configuration -rules: - attribute-quotes: - - 2 - border-zero: - - convention: 'none' - brace-style: - - - style: '1tbs' - allow-single-line: false - class-name-format: - - 2 - - - allow-leading-underscore: true - convention: hyphenatedbem - empty-args: - - 2 - - include: true - empty-line-between-blocks: - - 2 - - - include: true - allow-single-line-rulesets: false - extends-before-declarations: - - 2 - extends-before-mixins: - - 2 - final-newline: - - 2 - - include: false - force-attribute-nesting: - - 0 - force-element-nesting: - - 0 - force-pseudo-nesting: - - 0 - function-name-format: - - 2 - - - allow-leading-underscore: true - convention: hyphenatedbem - hex-length: - - 2 - - style: short - hex-notation: - - 2 - - style: lowercase - id-name-format: - - 2 - - - allow-leading-underscore: true - convention: hyphenatedlowercase - indentation: - - 1 - - size: 4 - leading-zero: - - 2 - - include: true - mixin-name-format: - - 0 - mixins-before-declarations: - - 0 - nesting-depth: - - 2 - - max-depth: 4 - no-attribute-selectors: - - 2 - no-color-hex: - - 0 - no-color-keywords: - - 2 - no-color-literals: - - 0 - no-combinator: - - 0 - no-css-comments: - - 0 - no-duplicate-properties: - - 2 - no-empty-rulesets: - - 2 - no-important: - - 0 - no-invalid-hex: - - 2 - no-mergeable-selectors: - - 2 - no-misspelled-properties: - - 2 - no-trailing-whitespace: - - 2 - no-transition-all: - - 2 - no-vendor-prefixes: - - 0 - no-universal-selectors: - - 0 - one-declaration-per-line: - - 2 - property-sort-order: - - 2 - - order: 'alphabetical' - quotes: - - 2 - - style: 'single' - shorthand-values: - - 2 - - allowed-shorthands: [1, 2, 3] - single-line-per-selector: - - 2 - space-after-bang: - - 2 - - include: 'false' - space-after-colon: - - 2 - - include: true - space-after-comma: - - 2 - - include: true - space-around-operator: - - 2 - - include: true - space-before-bang: - - 2 - - include: true - space-before-brace: - - 2 - - include: true - space-before-colon: - - 2 - - include: false - space-between-parens: - - 2 - - include: false - trailing-semicolon: - - 2 - - include: true - url-quotes: - - 2 - variable-name-format: - - 2 - - - allow-leading-underscore: true - convention: hyphenatedbem - zero-unit: - - 0 \ No newline at end of file diff --git a/coffee/LICENSE b/coffee/LICENSE deleted file mode 100644 index 17f54a4..0000000 --- a/coffee/LICENSE +++ /dev/null @@ -1,21 +0,0 @@ -The MIT License (MIT) - -Copyright (c) 2016 Getme Limited (http://getme.co.uk) - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. \ No newline at end of file diff --git a/coffee/README.md b/coffee/README.md deleted file mode 100644 index 16a4877..0000000 --- a/coffee/README.md +++ /dev/null @@ -1,3 +0,0 @@ -# manhattan-contents - -Core content management for manhattan applications. \ No newline at end of file diff --git a/coffee/coffeelint.json b/coffee/coffeelint.json deleted file mode 100644 index 7a409c1..0000000 --- a/coffee/coffeelint.json +++ /dev/null @@ -1,54 +0,0 @@ -{ - "arrow_spacing": { - "level": "error" - }, - "braces_spacing": { - "level": "error", - "empty_object_spaces": 0, - "spaces": 0 - }, - "camel_case_classes": { - "level": "error" - }, - "colon_assignment_spacing": { - "level": "error", - "spacing": { - "left": 0, - "right": 1 - } - }, - "empty_constructor_needs_parens": { - "level": "error" - }, - "ensure_comprehensions": { - "level": "error" - }, - "indentation": { - "level": "error", - "value": 4 - }, - "newlines_after_classes": { - "level": "ignore" - }, - "no_implicit_braces": { - "level": "ignore" - }, - "no_stand_alone_at": { - "level": "error" - }, - "no_this": { - "level": "error" - }, - "no_unnecessary_double_quotes": { - "level": "error" - }, - "non_empty_constructor_needs_parens": { - "level": "error" - }, - "space_operators": { - "level": "ignore" - }, - "spacing_after_comma": { - "level": "error" - } -} \ No newline at end of file diff --git a/coffee/dist/index.js b/coffee/dist/index.js deleted file mode 100644 index 8172405..0000000 --- a/coffee/dist/index.js +++ /dev/null @@ -1 +0,0 @@ -!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.ManhattanContent=e():t.ManhattanContent=e()}(this,function(){return function(t){function __webpack_require__(n){if(e[n])return e[n].exports;var i=e[n]={i:n,l:!1,exports:{}};return t[n].call(i.exports,i,i.exports,__webpack_require__),i.l=!0,i.exports}var e={};return __webpack_require__.m=t,__webpack_require__.c=e,__webpack_require__.i=function(t){return t},__webpack_require__.d=function(t,e,n){__webpack_require__.o(t,e)||Object.defineProperty(t,e,{configurable:!1,enumerable:!0,get:n})},__webpack_require__.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return __webpack_require__.d(e,"a",e),e},__webpack_require__.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},__webpack_require__.p="",__webpack_require__(__webpack_require__.s=6)}([function(t,e){(function(){var e;e={},e.Machine=function(){function Machine(t){this.context=t,this._stateTransitions={},this._stateTransitionsAny={},this._defaultTransition=null,this._initialState=null,this._currentState=null}return Machine.prototype.addTransition=function(t,e,n,i){return n||(n=e),this._stateTransitions[[t,e]]=[n,i]},Machine.prototype.addTransitions=function(t,e,n,i){var o,r,s,a;for(n||(n=e),a=[],r=0,s=t.length;r-1;for(i=0;i<=this.length()-t.length();){for(n=!0,a=t.characters,o=r=0,s=a.length;rr;n=e<=r?++s:--s)t=i.characters[n],t.addTags.apply(t,o);return i},String.prototype.hasTags=function(){var t,e,n,i,o,r,s,a;for(i=2<=arguments.length?L.call(arguments,0,o=arguments.length-1):(o=0,[]),n=arguments[o++],void 0!==n&&"boolean"!=typeof n&&(i.push(n),n=!1),e=!1,a=this.characters,r=0,s=a.length;r0&&t._tags[0].selfClosing()&&(o+=t._tags[0].head()),o+=t.c()}for(T=a.reverse(),v=0,f=T.length;v0)for(r=this.charAt(t-1),s=r.tags(),r.isTag()&&s.shift(),"string"!=typeof e&&(a=a.copy()),g=a.characters,h=0,p=g.length;h0&&t._tags[0].selfClosing()&&o<3||o<2)){h=[],A=t._runLengthMap;for(p in A)l=A[p],h.push(l);for(h.sort(u),R=t._tags.slice(),L=0,b=R.length;L0&&n>e)break;if(-1===(r=this.indexOf(t,a)))break;s.push(r),a=r+1}for(s.push(this.length()),u=[],o=h=0,c=s.length-2;0<=c?h<=c:h>=c;o=0<=c?++h:--h)l=s[o],o>0&&(l+=1),i=s[o+1],u.push(this.slice(l,i));return u},String.prototype.startsWith=function(t){var e,n,i,o,r;if("string"==typeof t)return this.text().slice(0,t.length)===t;for(r=t.characters,n=i=0,o=r.length;ir;n=e<=r?++s:--s)t=i.characters[n],t.removeTags.apply(t,o);return i},String.prototype.copy=function(){var t,e;return e=new v.String("",this._preserveWhitespace),e.characters=function(){var e,n,i,o;for(i=this.characters,o=[],e=0,n=i.length;e",b,_,function(){return this._pushTag()}),this.fsm.addTransitions([" ","\n"],S),this.fsm.addTransition(">",S,_,function(){return this._pushTag()}),this.fsm.addTransitions([" ","\n"],h),this.fsm.addTransition("/",h,S,function(){return this.selfClosing=!0}),this.fsm.addTransition(">",h,_,function(){return this._pushTag()}),this.fsm.addTransitions(e,h,a,function(){return this._back()}),this.fsm.addTransitions(C,T,null,function(t){return this.tagName+=t}),this.fsm.addTransitions([" ","\n"],T,I),this.fsm.addTransition(">",T,_,function(){return this._popTag()}),this.fsm.addTransitions([" ","\n"],I),this.fsm.addTransition(">",I,_,function(){return this._popTag()}),this.fsm.addTransitions(l,a,null,function(t){return this.attributeName+=t}),this.fsm.addTransitions([" ","\n"],a,u),this.fsm.addTransition("=",a,i),this.fsm.addTransitions([" ","\n"],u),this.fsm.addTransition("=",u,i),this.fsm.addTransitions(">",a,h,function(){return this._pushAttribute(),this._back()}),this.fsm.addTransitionAny(u,h,function(){return this._pushAttribute(),this._back()}),this.fsm.addTransitions([" ","\n"],i),this.fsm.addTransition("'",i,p),this.fsm.addTransition('"',i,c),this.fsm.addTransitions(n.concat(["&"],i,d,function(){return this._back()})),this.fsm.addTransition(" ",d,h,function(){return this._pushAttribute()}),this.fsm.addTransitions(["/",">"],d,h,function(){return this._back(),this._pushAttribute()}),this.fsm.addTransition("&",d,r),this.fsm.addTransitionAny(d,null,function(t){return this.attributeValue+=t}),this.fsm.addTransition("'",p,h,function(){return this._pushAttribute()}),this.fsm.addTransition("&",p,s),this.fsm.addTransitionAny(p,null,function(t){return this.attributeValue+=t}),this.fsm.addTransition('"',c,h,function(){return this._pushAttribute()}),this.fsm.addTransition("&",c,o),this.fsm.addTransitionAny(c,null,function(t){return this.attributeValue+=t}),this.fsm.addTransitions(f,r,null,function(t){return this.entity+=t}),this.fsm.addTransitions(f,s,function(t){return this.entity+=t}),this.fsm.addTransitions(f,o,null,function(t){return this.entity+=t}),this.fsm.addTransition(";",r,d,function(){return this.attributeValue+="&"+this.entity+";",this.entity=""}),this.fsm.addTransition(";",s,p,function(){return this.attributeValue+="&"+this.entity+";",this.entity=""}),this.fsm.addTransition(";",o,c,function(){return this.attributeValue+="&"+this.entity+";",this.entity=""})}return _Parser.prototype._back=function(){return this.head--},_Parser.prototype._pushAttribute=function(){return this.attributes[this.attributeName]=this.attributeValue,this.attributeName="",this.attributeValue=""},_Parser.prototype._pushChar=function(t){var e,n;return e=new v.Character(t,this.tags),this._preserveWhitespace?void this.string.characters.push(e):!this.string.length()||e.isTag()||e.isEntity()||!e.isWhitespace()||(n=this.string.characters[this.string.length()-1],!n.isWhitespace()||n.isTag()||n.isEntity())?this.string.characters.push(e):void 0},_Parser.prototype._pushTag=function(){var t,e;return t=new v.Tag(this.tagName,this.attributes),this.tags.push(t),t.selfClosing()&&(this._pushChar(""),this.tags.pop(),!this.selfClosed&&(e=this.tagName,M.call(v.Tag.SELF_CLOSING,e)>=0)&&this.fsm.reset()),this.tagName="",this.selfClosed=!1,this.attributes={}},_Parser.prototype._popTag=function(){for(var t,e;;)if(e=this.tags.pop(),this.string.length()&&(t=this.string.characters[this.string.length()-1],t.isTag()||t.isEntity()||!t.isWhitespace()||t.removeTags(e)),e.name()===this.tagName.toLowerCase())break;return this.tagName=""},_Parser.prototype.parse=function(t,e){var n,i;for(this._preserveWhitespace=e,this.reset(),t=this.preprocess(t),this.fsm.parser=this;this.head> "+i)}this.head++}return this.string},_Parser.prototype.preprocess=function(t){return t=t.replace(/\r\n/g,"\n").replace(/\r/g,"\n"),t=t.replace(//g,""),this._preserveWhitespace||(t=t.replace(/\s+/g," ")),t},_Parser.prototype.reset=function(){return this.fsm.reset(),this.head=0,this.string=new v.String,this.entity="",this.tags=[],this.tagName="",this.selfClosing=!1,this.attributes={},this.attributeName="",this.attributeValue=""},_Parser}(),v.Tag=function(){function Tag(t,e){var n,i;this._name=t.toLowerCase(),this._selfClosing=!0===v.Tag.SELF_CLOSING[this._name],this._head=null,this._attributes={};for(n in e)i=e[n],this._attributes[n]=i}return Tag.SELF_CLOSING={area:!0,base:!0,br:!0,hr:!0,img:!0,input:!0,"link meta":!0,wbr:!0},Tag.prototype.head=function(){var t,e,n,i;if(!this._head){t=[],i=this._attributes;for(e in i)n=i[e],n?t.push(e+'="'+n+'"'):t.push(""+e);t.sort(),t.unshift(this._name),this._head="<"+t.join(" ")+">"}return this._head},Tag.prototype.name=function(){return this._name},Tag.prototype.selfClosing=function(){return this._selfClosing},Tag.prototype.tail=function(){return this._selfClosing?"":""},Tag.prototype.attr=function(t,e){return void 0===e?this._attributes[t]:(this._attributes[t]=e,this._head=null)},Tag.prototype.removeAttr=function(t){if(void 0!==this._attributes[t])return delete this._attributes[t],this._head=null},Tag.prototype.copy=function(){return new v.Tag(this._name,this._attributes)},Tag}(),v.Character=function(){function Character(t,e){this._c=t,t.length>1&&(this._c=t.toLowerCase()),this._tags=[],this.addTags.apply(this,e)}return Character.prototype.c=function(){return this._c},Character.prototype.isEntity=function(){return this._c.length>1},Character.prototype.isTag=function(t){return!(0===this._tags.length||!this._tags[0].selfClosing())&&(!t||this._tags[0].name()===t)},Character.prototype.isWhitespace=function(){var t;return" "===(t=this._c)||"\n"===t||" "===t||this.isTag("br")},Character.prototype.tags=function(){var t;return function(){var e,n,i,o;for(i=this._tags,o=[],e=0,n=i.length;e0;)switch(i=r.shift(),i.nodeType){case Node.TEXT_NODE:if(i.textContent.length>=o)return[i,o];o-=i.textContent.length;break;case Node.ELEMENT_NODE:if(l=i.nodeName.toLowerCase(),a.call(n,l)>=0){if(0===o)return[i,0];o=Math.max(0,o-1)}else i.childNodes&&Array.prototype.unshift.apply(r,function(){var t,e,n,o;for(n=i.childNodes,o=[],t=0,e=n.length;t0;){if((s=i.shift())===e)return l=s.nodeName.toLowerCase(),a.call(n,l)>=0?r+1:r;switch(s.nodeType){case Node.TEXT_NODE:r+=s.textContent.length;break;case Node.ELEMENT_NODE:u=s.nodeName.toLowerCase(),a.call(n,u)>=0?r+=1:s.childNodes&&Array.prototype.unshift.apply(i,function(){var t,e,n,i;for(n=s.childNodes,i=[],t=0,e=n.length;t=0&&(c=1);break}if(e.collapsed)return[h,c,h,c];if(r===t)for(r=o[o.length-1],s=r.textContent.length,u=_=0,g=o.length;_-1)?(r.splice(o,1),r.length?t.setAttribute("class",r.join(" ")):t.removeAttribute("class")):void 0)}},"undefined"!=typeof window&&(window.ContentEdit=e),void 0!==t&&t.exports&&(t.exports=e),i=function(){function _TagNames(){this._tagNames={}}return _TagNames.prototype.register=function(){var t,e,n,i,o,s;for(t=arguments[0],n=2<=arguments.length?r.call(arguments,1):[],s=[],i=0,o=n.length;i0)return this.children[0];for(r=[this].concat(this.parents()),i=0,o=r.length;i=0||(this.prototype[e]=n);return this},Node.fromDOMElement=function(t){throw new Error("`fromDOMElement` not implemented")},Node}(),e.NodeCollection=function(t){function NodeCollection(){NodeCollection.__super__.constructor.call(this),this.children=[]}return l(NodeCollection,t),NodeCollection.prototype.descendants=function(){var t,e,n;for(t=[],n=this.children.slice();n.length>0;)e=n.shift(),t.push(e),e.children&&e.children.length>0&&(n=e.children.slice().concat(n));return t},NodeCollection.prototype.isMounted=function(){return!1},NodeCollection.prototype.type=function(){return"NodeCollection"},NodeCollection.prototype.attach=function(t,n){return t.parent()&&t.parent().detach(t),t._parent=this,void 0!==n?this.children.splice(n,0,t):this.children.push(t),t.mount&&this.isMounted()&&t.mount(),this.taint(),e.Root.get().trigger("attach",this,t)},NodeCollection.prototype.commit=function(){var t,n,i,o;for(o=this.descendants(),n=0,i=o.length;n-1))},Element.prototype.merge=function(t){return!(!this.can("merge")||!this.can("remove"))&&(this.constructor.mergers[t.type()]?this.constructor.mergers[t.type()](t,this):t.constructor.mergers[this.type()]?t.constructor.mergers[this.type()](t,this):void 0)},Element.prototype.mount=function(){var t;return this._domElement||(this._domElement=document.createElement(this.tagName())),t=this.nextSibling(),t?this.parent().domElement().insertBefore(this._domElement,t.domElement()):this.isFixed()?(this.parent().domElement().parentNode.replaceChild(this._domElement,this.parent().domElement()),this.parent()._domElement=this._domElement):this.parent().domElement().appendChild(this._domElement),this._addDOMEventListeners(),this._addCSSClass("ce-element"),this._addCSSClass("ce-element--type-"+this.cssTypeName()),this.isFocused()&&this._addCSSClass("ce-element--focused"),e.Root.get().trigger("mount",this)},Element.prototype.removeAttr=function(t){if(t=t.toLowerCase(),this._attributes[t])return delete this._attributes[t],this.isMounted()&&"class"!==t.toLowerCase()&&this._domElement.removeAttribute(t),this.taint()},Element.prototype.removeCSSClass=function(t){var e,n,i;if(this.hasCSSClass(t))return i=function(){var t,n,i,o;for(i=this.attr("class").split(" "),o=[],t=0,n=i.length;t-1&&i.splice(n,1),i.length?this.attr("class",i.join(" ")):this.removeAttr("class"),this._removeCSSClass(t),this.taint()},Element.prototype.tagName=function(t){return void 0===t?this._tagName:(this._tagName=t.toLowerCase(),this.isMounted()&&(this.unmount(),this.mount()),this.taint())},Element.prototype.unmount=function(){return this._removeDOMEventListeners(),this.isFixed()?(this._removeCSSClass("ce-element"),this._removeCSSClass("ce-element--type-"+this.cssTypeName()),void this._removeCSSClass("ce-element--focused")):(this._domElement.parentNode&&this._domElement.parentNode.removeChild(this._domElement),this._domElement=null,e.Root.get().trigger("unmount",this))},Element.prototype._addDOMEventListeners=function(){var t,e,n,i;this._domEventHandlers={dragstart:function(t){return function(t){return t.preventDefault()}}(),focus:function(t){return function(t){return t.preventDefault()}}(),keydown:function(t){return function(e){return t._onKeyDown(e)}}(this),keyup:function(t){return function(e){return t._onKeyUp(e)}}(this),mousedown:function(t){return function(e){if(0===e.button)return t._onMouseDown(e)}}(this),mousemove:function(t){return function(e){return t._onMouseMove(e)}}(this),mouseover:function(t){return function(e){return t._onMouseOver(e)}}(this),mouseout:function(t){return function(e){return t._onMouseOut(e)}}(this),mouseup:function(t){return function(e){if(0===e.button)return t._onMouseUp(e)}}(this),dragover:function(t){return function(t){return t.preventDefault()}}(),drop:function(t){return function(e){return t._onNativeDrop(e)}}(this),paste:function(t){return function(e){return t._onPaste(e)}}(this)},n=this._domEventHandlers,i=[];for(e in n)t=n[e],i.push(this._domElement.addEventListener(e,t));return i},Element.prototype._onKeyDown=function(t){},Element.prototype._onKeyUp=function(t){},Element.prototype._onMouseDown=function(t){if(this.focus)return this.focus(!0)},Element.prototype._onMouseMove=function(t){return this._onOver(t)},Element.prototype._onMouseOver=function(t){return this._onOver(t)},Element.prototype._onMouseOut=function(t){var n;if(this._removeCSSClass("ce-element--over"),n=e.Root.get(),n.dragging())return this._removeCSSClass("ce-element--drop"),this._removeCSSClass("ce-element--drop-above"),this._removeCSSClass("ce-element--drop-below"),this._removeCSSClass("ce-element--drop-center"),this._removeCSSClass("ce-element--drop-left"),this._removeCSSClass("ce-element--drop-right"),n._dropTarget=null},Element.prototype._onMouseUp=function(t){return this._ieMouseDownEchoed=!1},Element.prototype._onNativeDrop=function(t){return t.preventDefault(),t.stopPropagation(),e.Root.get().trigger("native-drop",this,t)},Element.prototype._onPaste=function(t){return t.preventDefault(),t.stopPropagation(),e.Root.get().trigger("paste",this,t)},Element.prototype._onOver=function(t){var n,i;if(this._addCSSClass("ce-element--over"),i=e.Root.get(),(n=i.dragging())&&n!==this&&!i._dropTarget&&this.can("drop")&&(this.constructor.droppers[n.type()]||n.constructor.droppers[this.type()]))return this._addCSSClass("ce-element--drop"),i._dropTarget=this},Element.prototype._removeDOMEventListeners=function(){var t,e,n,i;n=this._domEventHandlers,i=[];for(e in n)t=n[e],i.push(this._domElement.removeEventListener(e,t));return i},Element.prototype._addCSSClass=function(t){if(this.isMounted())return e.addCSSClass(this._domElement,t)},Element.prototype._attributesToString=function(){return Object.getOwnPropertyNames(this._attributes).length>0?" "+e.attributesToString(this._attributes):""},Element.prototype._removeCSSClass=function(t){if(this.isMounted())return e.removeCSSClass(this._domElement,t)},Element.droppers={},Element.mergers={},Element.placements=["above","below"],Element.getDOMElementAttributes=function(t){var e,n,i,o,r;if(!t.hasAttributes())return{};for(n={},r=t.attributes,i=0,o=r.length;ie.HELPER_CHAR_LIMIT&&(n=n.substr(0,e.HELPER_CHAR_LIMIT)),t.innerHTML=n,t},ElementCollection.prototype.detach=function(t){if(e.NodeCollection.prototype.detach.call(this,t),0===this.children.length&&this.parent())return this.parent().detach(this)},ElementCollection.prototype.html=function(t){var n,i,o,r;return null==t&&(t=""),o=function(){var n,o,r,s;for(r=this.children,s=[],n=0,o=r.length;n"+r+o.join(r)+r+t+"")},ElementCollection.prototype.mount=function(){var t,e,n,i,o,r,s,a;this._domElement=document.createElement(this._tagName),r=this._attributes;for(e in r)n=r[e],this._domElement.setAttribute(e,n);for(ElementCollection.__super__.mount.call(this),s=this.children,a=[],i=0,o=s.length;ir.height-o&&(i=["bottom","left"]):t>r.width-o&&(nr.height-o&&(i=["bottom","right"])),i},ResizableElement.prototype._getSizeInfo=function(){var t;return t=this.size(),"w "+t[0]+" × h "+t[1]},ResizableElement}(e.Element),e.Region=function(t){function Region(t){Region.__super__.constructor.call(this),this._domElement=t,this.setContent(t)}return l(Region,t),Region.prototype.domElement=function(){return this._domElement},Region.prototype.isMounted=function(){return!0},Region.prototype.type=function(){return"Region"},Region.prototype.html=function(t){var n,i;return null==t&&(t=""),i=e.LINE_ENDINGS,function(){var e,i,o,r;for(o=this.children,r=[],e=0,i=o.length;eo.width-e.DROP_EDGE_SIZE&&(i="right"),r="above",n>o.height/2&&(r="below"),[r,i]):null},_Root.prototype._onDrag=function(t){var e,n,i;if(ContentSelect.Range.unselectAll(),this._draggingDOMElement.style.left=t.pageX+"px",this._draggingDOMElement.style.top=t.pageY+"px",this._dropTarget&&(e=this._getDropPlacement(t.clientX,t.clientY),this._dropTarget._removeCSSClass("ce-element--drop-above"),this._dropTarget._removeCSSClass("ce-element--drop-below"),this._dropTarget._removeCSSClass("ce-element--drop-center"),this._dropTarget._removeCSSClass("ce-element--drop-left"),this._dropTarget._removeCSSClass("ce-element--drop-right"),n=e[0],s.call(this._dragging.constructor.placements,n)>=0&&this._dropTarget._addCSSClass("ce-element--drop-"+e[0]),i=e[1],s.call(this._dragging.constructor.placements,i)>=0))return this._dropTarget._addCSSClass("ce-element--drop-"+e[1])},_Root.prototype._onStopDragging=function(t){var e;return e=this._getDropPlacement(t.clientX,t.clientY),this._dragging.drop(this._dropTarget,e),this.cancelDragging()},_Root.prototype.startResizing=function(t,n,i,o,r){var s,a;if(!this._resizing)return this._resizing=t,this._resizingInit={corner:n,fixed:r,origin:[i,o],size:t.size()},this._resizing._addCSSClass("ce-element--resizing"),a=this._resizing.parent().domElement(),s=document.createElement("div"),s.setAttribute("class","ce-measure"),a.appendChild(s),this._resizingParentWidth=s.getBoundingClientRect().width,a.removeChild(s),document.addEventListener("mousemove",this._onResize),document.addEventListener("mouseup",this._onStopResizing),e.addCSSClass(document.body,"ce--resizing")},_Root.prototype._onResize=function(t){var e,n,i,o;return ContentSelect.Range.unselectAll(),i=this._resizingInit.origin[0]-t.clientX,"right"===this._resizingInit.corner[1]&&(i=-i),n=this._resizingInit.size[0]+i,n=Math.min(n,this._resizingParentWidth),this._resizingInit.fixed?e=n*this._resizing.aspectRatio():(o=this._resizingInit.origin[1]-t.clientY,"bottom"===this._resizingInit.corner[0]&&(o=-o),e=this._resizingInit.size[1]+o),this._resizing.size([n,e])},_Root.prototype._onStopResizing=function(t){return document.removeEventListener("mousemove",this._onResize),document.removeEventListener("mouseup",this._onStopResizing),this._resizing._removeCSSClass("ce-element--resizing"),this._resizing=null,this._resizingInit=null,this._resizingParentWidth=null,e.removeCSSClass(document.body,"ce--resizing")},_Root}(e.Node),e.Root=function(){function Root(){}var t;return t=null,Root.get=function(){return null!=t?t:t=new n},Root}(),e.Static=function(t){function Static(t,e,n){Static.__super__.constructor.call(this,t,e),this._content=n}return l(Static,t),Static.prototype.cssTypeName=function(){return"static"},Static.prototype.type=function(){return"Static"},Static.prototype.typeName=function(){return"Static"},Static.prototype.createDraggingDOMElement=function(){var t,n;if(this.isMounted())return t=Static.__super__.createDraggingDOMElement.call(this),n=this._domElement.textContent,n.length>e.HELPER_CHAR_LIMIT&&(n=n.substr(0,e.HELPER_CHAR_LIMIT)),t.innerHTML=n,t},Static.prototype.html=function(t){return null==t&&(t=""),HTMLString.Tag.SELF_CLOSING[this._tagName]?t+"<"+this._tagName+this._attributesToString()+">":t+"<"+this._tagName+this._attributesToString()+">"+this._content+t+""},Static.prototype.mount=function(){var t,e,n;this._domElement=document.createElement(this._tagName),n=this._attributes;for(t in n)e=n[t],this._domElement.setAttribute(t,e);return this._domElement.innerHTML=this._content,Static.__super__.mount.call(this)},Static.prototype.blur=void 0,Static.prototype.focus=void 0,Static.prototype._onMouseDown=function(t){if(Static.__super__._onMouseDown.call(this,t),void 0!==this.attr("data-ce-moveable"))return clearTimeout(this._dragTimeout),this._dragTimeout=setTimeout(function(e){return function(){return e.drag(t.pageX,t.pageY)}}(this),150)},Static.prototype._onMouseOver=function(t){return Static.__super__._onMouseOver.call(this,t),this._removeCSSClass("ce-element--over")},Static.prototype._onMouseUp=function(t){if(Static.__super__._onMouseUp.call(this,t),this._dragTimeout)return clearTimeout(this._dragTimeout)},Static.droppers={Static:e.Element._dropVert},Static.fromDOMElement=function(t){return new this(t.tagName,this.getDOMElementAttributes(t),t.innerHTML)},Static}(e.Element),e.TagNames.get().register(e.Static,"static"),e.Text=function(t){function Text(t,n,i){Text.__super__.constructor.call(this,t,n),i instanceof HTMLString.String?this.content=i:e.TRIM_WHITESPACE?this.content=new HTMLString.String(i).trim():this.content=new HTMLString.String(i,!0)}return l(Text,t),Text.prototype.cssTypeName=function(){return"text"},Text.prototype.type=function(){return"Text"},Text.prototype.typeName=function(){return"Text"},Text.prototype.blur=function(){return this.isMounted()&&this._syncContent(),this.content.isWhitespace()&&this.can("remove")?this.parent()&&this.parent().detach(this):this.isMounted()&&(document.documentMode||/Edge/.test(navigator.userAgent)||this._domElement.blur(),this._domElement.removeAttribute("contenteditable")),Text.__super__.blur.call(this)},Text.prototype.createDraggingDOMElement=function(){var t,n;if(this.isMounted())return t=Text.__super__.createDraggingDOMElement.call(this),n=HTMLString.String.encode(this._domElement.textContent),n.length>e.HELPER_CHAR_LIMIT&&(n=n.substr(0,e.HELPER_CHAR_LIMIT)),t.innerHTML=n,t},Text.prototype.drag=function(t,e){return this.storeState(),this._domElement.removeAttribute("contenteditable"),Text.__super__.drag.call(this,t,e)},Text.prototype.drop=function(t,e){return Text.__super__.drop.call(this,t,e),this.restoreState()},Text.prototype.focus=function(t){return this.isMounted()&&this._domElement.setAttribute("contenteditable",""),Text.__super__.focus.call(this,t)},Text.prototype.html=function(t){var n,i,o;return null==t&&(t=""),(!this._lastCached||this._lastCached"+o+t+e.INDENT+this._cached+o+t+""},Text.prototype.mount=function(){var t,e,n;this._domElement=document.createElement(this._tagName),n=this._attributes;for(t in n)e=n[t],this._domElement.setAttribute(t,e);return this.updateInnerHTML(),Text.__super__.mount.call(this)},Text.prototype.restoreState=function(){if(this._savedSelection)return this.isMounted()&&this.isFocused()?(this._domElement.setAttribute("contenteditable",""),this._addCSSClass("ce-element--focused"),document.activeElement!==this.domElement()&&this.domElement().focus(),this._savedSelection.select(this._domElement),this._savedSelection=void 0):void(this._savedSelection=void 0)},Text.prototype.selection=function(t){return void 0===t?this.isMounted()?ContentSelect.Range.query(this._domElement):new ContentSelect.Range(0,0):t.select(this._domElement)},Text.prototype.storeState=function(){if(this.isMounted()&&this.isFocused())return this._savedSelection=ContentSelect.Range.query(this._domElement)},Text.prototype.unmount=function(){return this._domElement.removeAttribute("contenteditable"),Text.__super__.unmount.call(this)},Text.prototype.updateInnerHTML=function(){return this._domElement.innerHTML=this.content.html(),ContentSelect.Range.prepareElement(this._domElement),this._flagIfEmpty()},Text.prototype._onKeyDown=function(t){switch(t.keyCode){case 40:return this._keyDown(t);case 37:return this._keyLeft(t);case 39:return this._keyRight(t);case 38:return this._keyUp(t);case 9:return this._keyTab(t);case 8:return this._keyBack(t);case 46:return this._keyDelete(t);case 13:return this._keyReturn(t)}},Text.prototype._onKeyUp=function(t){return Text.__super__._onKeyUp.call(this,t),this._syncContent()},Text.prototype._onMouseDown=function(t){if(Text.__super__._onMouseDown.call(this,t),clearTimeout(this._dragTimeout),this._dragTimeout=setTimeout(function(e){return function(){return e.drag(t.pageX,t.pageY)}}(this),e.DRAG_HOLD_DURATION),0===this.content.length()&&e.Root.get().focused()===this)return t.preventDefault(),document.activeElement!==this._domElement&&this._domElement.focus(),new ContentSelect.Range(0,0).select(this._domElement)},Text.prototype._onMouseMove=function(t){return this._dragTimeout&&clearTimeout(this._dragTimeout),Text.__super__._onMouseMove.call(this,t)},Text.prototype._onMouseOut=function(t){return this._dragTimeout&&clearTimeout(this._dragTimeout),Text.__super__._onMouseOut.call(this,t)},Text.prototype._onMouseUp=function(t){return this._dragTimeout&&clearTimeout(this._dragTimeout),Text.__super__._onMouseUp.call(this,t)},Text.prototype._keyBack=function(t){var e,n;if(n=ContentSelect.Range.query(this._domElement),0===n.get()[0]&&n.isCollapsed())return t.preventDefault(),e=this.previousContent(),this._syncContent(),e?e.merge(this):void 0},Text.prototype._keyDelete=function(t){var e,n;if(n=ContentSelect.Range.query(this._domElement),this._atEnd(n)&&n.isCollapsed())return t.preventDefault(),e=this.nextContent(),e?this.merge(e):void 0},Text.prototype._keyDown=function(t){return this._keyRight(t)},Text.prototype._keyLeft=function(t){var n,i;if(i=ContentSelect.Range.query(this._domElement),0===i.get()[0]&&i.isCollapsed())return t.preventDefault(),n=this.previousContent(),n?(n.focus(),i=new ContentSelect.Range(n.content.length(),n.content.length()),i.select(n.domElement())):e.Root.get().trigger("previous-region",this.closest(function(t){return"Fixture"===t.type()||"Region"===t.type()}))},Text.prototype._keyReturn=function(t){var n,i,o,r,s,a;if(t.preventDefault(),!(this.content.isWhitespace()&&!t.shiftKey^e.PREFER_LINE_BREAKS)){if(r=ContentSelect.Range.query(this._domElement),a=this.content.substring(0,r.get()[0]),s=this.content.substring(r.get()[1]),t.shiftKey^e.PREFER_LINE_BREAKS)return i=r.get()[0],o="
",this.content.length()===i&&(0!==this.content.length()&&this.content.characters[i-1].isTag("br")||(o="

")),this.content=this.content.insert(i,new HTMLString.String(o,!0),!0),this.updateInnerHTML(),i+=1,r=new ContentSelect.Range(i,i),r.select(this.domElement()),void this.taint();if(this.can("spawn"))return this.content=a.trim(),this.updateInnerHTML(),n=new this.constructor("p",{},s.trim()),this.parent().attach(n,this.parent().children.indexOf(this)+1),a.length()?(n.focus(),r=new ContentSelect.Range(0,0),r.select(n.domElement())):(r=new ContentSelect.Range(0,a.length()),r.select(this._domElement)),this.taint()}},Text.prototype._keyRight=function(t){var n,i;if(i=ContentSelect.Range.query(this._domElement),this._atEnd(i)&&i.isCollapsed())return t.preventDefault(),n=this.nextContent(),n?(n.focus(),i=new ContentSelect.Range(0,0),i.select(n.domElement())):e.Root.get().trigger("next-region",this.closest(function(t){return"Fixture"===t.type()||"Region"===t.type()}))},Text.prototype._keyTab=function(t){if(t.preventDefault(),this.isFixed())return t.shiftKey?e.Root.get().trigger("previous-region",this.closest(function(t){return"Fixture"===t.type()||"Region"===t.type()})):e.Root.get().trigger("next-region",this.closest(function(t){return"Fixture"===t.type()||"Region"===t.type()}))},Text.prototype._keyUp=function(t){return this._keyLeft(t)},Text.prototype._atEnd=function(t){return t.get()[0]>=this.content.length()},Text.prototype._flagIfEmpty=function(){return 0===this.content.length()?this._addCSSClass("ce-element--empty"):this._removeCSSClass("ce-element--empty")},Text.prototype._syncContent=function(t){var e,n;return n=this.content.html(),this.content=new HTMLString.String(this._domElement.innerHTML,this.content.preserveWhitespace()),e=this.content.html(),n!==e&&this.taint(),this._flagIfEmpty()},Text.droppers={Static:e.Element._dropVert,Text:e.Element._dropVert},Text.mergers={Text:function(t,e){var n;return n=e.content.length(),t.content.length()&&(e.content=e.content.concat(t.content)),e.isMounted()&&e.updateInnerHTML(),e.focus(),new ContentSelect.Range(n,n).select(e._domElement),t.parent()&&t.parent().detach(t),e.taint()}},Text.fromDOMElement=function(t){return new this(t.tagName,this.getDOMElementAttributes(t),t.innerHTML.replace(/^\s+|\s+$/g,""))},Text}(e.Element),e.TagNames.get().register(e.Text,"address","blockquote","h1","h2","h3","h4","h5","h6","p"),e.PreText=function(t){function PreText(t,n,i){i instanceof HTMLString.String?this.content=i:this.content=new HTMLString.String(i,!0),e.Element.call(this,t,n)}return l(PreText,t),PreText.TAB_INDENT=" ",PreText.prototype.cssTypeName=function(){return"pre-text"},PreText.prototype.type=function(){return"PreText"},PreText.prototype.typeName=function(){return"Preformatted"},PreText.prototype.blur=function(){return this.isMounted()&&(this._domElement.innerHTML=this.content.html()),PreText.__super__.blur.call(this)},PreText.prototype.html=function(t){var e;return null==t&&(t=""),(!this._lastCached||this._lastCached"+this._cached+""},PreText.prototype.updateInnerHTML=function(){var t;return t=this.content.html(),this._domElement.innerHTML=t,this._ensureEndZWS(),ContentSelect.Range.prepareElement(this._domElement),this._flagIfEmpty()},PreText.prototype._keyBack=function(t){var e;return e=ContentSelect.Range.query(this._domElement),e.get()[0]<=this.content.length()?PreText.__super__._keyBack.call(this,t):(e.set(this.content.length(),this.content.length()),e.select(this._domElement))},PreText.prototype._keyReturn=function(t){var e,n,i,o;return t.preventDefault(),n=ContentSelect.Range.query(this._domElement),e=n.get()[0]+1,0===n.get()[0]&&n.isCollapsed()?this.content=new HTMLString.String("\n",!0).concat(this.content):this._atEnd(n)&&n.isCollapsed()?this.content=this.content.concat(new HTMLString.String("\n",!0)):0===n.get()[0]&&n.get()[1]===this.content.length()?(this.content=new HTMLString.String("\n",!0),e=0):(o=this.content.substring(0,n.get()[0]),i=this.content.substring(n.get()[1]),this.content=o.concat(new HTMLString.String("\n",!0),i)),this.updateInnerHTML(),n.set(e,e),n.select(this._domElement),this.taint()},PreText.prototype._keyTab=function(t){var n,i,o,r,s,a,l,u,h,c,d,p,_,m,g,f,v,y,E,C,T,I,b,S,w,L;for(t.preventDefault(),n=this.content.length(),h=e.PreText.TAB_INDENT,u=h.length,_=this.content.split("\n"),m=this.selection().get(),m[0]=Math.min(m[0],n),m[1]=Math.min(m[1],n),o=0,v=-1,r=-1,a=C=0,S=_.length;C-1&&r>-1));a=++C)o+=p;if(v===r)u-=(m[0]-o)%u,l=new HTMLString.String(Array(u+1).join(" "),!0),E=_[v].substring(0,m[0]-o),y=_[v].substring(m[1]-o),_[v]=E.concat(l,y),f=u;else if(t.shiftKey){for(s=0,a=T=v;v<=r?T<=r:T>=r;a=v<=r?++T:--T){for(L=_[a].characters.slice(),c=I=0,w=L.length;Iu-1))&&i.isWhitespace();c=++I)_[a].characters.shift();a===v&&(s=c)}f=Math.max(-u,-s)}else{for(l=new HTMLString.String(h,!0),a=b=v;v<=r?b<=r:b>=r;a=v<=r?++b:--b)_[a]=l.concat(_[a]);f=u}return this.content=HTMLString.String.join(new HTMLString.String("\n",!0),_),this.updateInnerHTML(),g=this.content.length()-n,new ContentSelect.Range(m[0]+f,m[1]+g).select(this._domElement)},PreText.prototype._syncContent=function(t){var e,n;return this._ensureEndZWS(),n=this.content.html(),this.content=new HTMLString.String(this._domElement.innerHTML.replace(/\u200B$/g,""),this.content.preserveWhitespace()),e=this.content.html(),n!==e&&this.taint(),this._flagIfEmpty()},PreText.prototype._ensureEndZWS=function(){var t,e;if(this._domElement.lastChild&&(t=this._domElement.innerHTML,!("​"===t[t.length-1]&&t.indexOf("​")-1&&(e._domElement.innerHTML=t.replace(/\u200B/g,"")),e._domElement.lastChild.textContent+="​"}}(this),this._savedSelection?e():(this.storeState(),e(),this.restoreState())},PreText.droppers={PreText:e.Element._dropVert,Static:e.Element._dropVert,Text:e.Element._dropVert},PreText.mergers={},PreText.fromDOMElement=function(t){return new this(t.tagName,this.getDOMElementAttributes(t),t.innerHTML)},PreText}(e.Text),e.TagNames.get().register(e.PreText,"pre"),e.Image=function(t){function Image(t,e){var n;Image.__super__.constructor.call(this,"img",t),this.a=e||null,n=this.size(),this._aspectRatio=n[1]/n[0]}return l(Image,t),Image.prototype.cssTypeName=function(){return"image"},Image.prototype.type=function(){return"Image"},Image.prototype.typeName=function(){return"Image"},Image.prototype.createDraggingDOMElement=function(){var t;if(this.isMounted())return t=Image.__super__.createDraggingDOMElement.call(this),t.style.backgroundImage="url('"+this._attributes.src+"')",t},Image.prototype.html=function(t){var n,i,o;return null==t&&(t=""),i=t+"",this.a?(o=e.LINE_ENDINGS,n=e.attributesToString(this.a),n+=' data-ce-tag="img"',t+""+o+e.INDENT+i+o+t+""):i},Image.prototype.mount=function(){var t,e;return this._domElement=document.createElement("div"),t="",this.a&&this.a.class&&(t+=" "+this.a.class),this._attributes.class&&(t+=" "+this._attributes.class),this._domElement.setAttribute("class",t),e=this._attributes.style?this._attributes.style:"",e+="background-image:url('"+this._attributes.src+"');",this._attributes.width&&(e+="width:"+this._attributes.width+"px;"),this._attributes.height&&(e+="height:"+this._attributes.height+"px;"),this._domElement.setAttribute("style",e),Image.__super__.mount.call(this)},Image.prototype.unmount=function(){var t,e;return this.isFixed()&&(e=document.createElement("div"),e.innerHTML=this.html(),t=e.querySelector("a, img"),this._domElement.parentNode.replaceChild(t,this._domElement),this._domElement=t),Image.__super__.unmount.call(this)},Image.droppers={Image:e.Element._dropBoth,PreText:e.Element._dropBoth,Static:e.Element._dropBoth,Text:e.Element._dropBoth},Image.placements=["above","below","left","right","center"],Image.fromDOMElement=function(t){var e,n,i,o,r,s,a,l,u;if(e=null,"a"===t.tagName.toLowerCase()){for(e=this.getDOMElementAttributes(t),r=function(){var e,n,o,r;for(o=t.childNodes,r=[],e=0,n=o.length;e",t+"<"+this.tagName()+" "+i+">"+r+e.INDENT+o+r+t+""},ImageFixture.prototype.mount=function(){var t,e,n,i,o;this._domElement=document.createElement(this.tagName()),o=this._attributes;for(e in o)i=o[e],"alt"!==e&&"style"!==e&&this._domElement.setAttribute(e,i);return t="",this.a&&this.a.class&&(t+=" "+this.a.class),this._attributes.class&&(t+=" "+this._attributes.class),this._domElement.setAttribute("class",t),n=this._attributes.style?this._attributes.style:"",n=n.replace(/background-image:.+?(;|$)/i,""),n=[n.trim(),"background-image:url('"+this.src()+"');"].join(" "),this._domElement.setAttribute("style",n.trim()),ImageFixture.__super__.mount.call(this)},ImageFixture.prototype.src=function(t){return void 0===t?this._src:(this._src=t.toLowerCase(),this.isMounted()&&(this.unmount(),this.mount()),this.taint())},ImageFixture.prototype.unmount=function(){var t,e;return this.isFixed()?(e=document.createElement("div"),e.innerHTML=this.html(),t=e.firstElementChild,this._domElement.parentNode.replaceChild(t,this._domElement),this._domElement=t,this.parent()._domElement=this._domElement):ImageFixture.__super__.unmount.call(this)},ImageFixture.prototype._attributesToString=function(){var t,n,i,o,r;this._attributes.style?(i=this._attributes.style?this._attributes.style:"",i=i.replace(/background-image:.+?(;|$)/i,""),i=[i.trim(),"background-image:url('"+this.src()+"');"].join(" "),this._attributes.style=i.trim()):this._attributes.style="background-image:url('"+this.src()+"');",t={},r=this._attributes;for(n in r)o=r[n],"alt"!==n&&(t[n]=o);return" "+e.attributesToString(t)},ImageFixture.droppers={ImageFixture:e.Element._dropVert,Image:e.Element._dropVert,PreText:e.Element._dropVert,Text:e.Element._dropVert},ImageFixture.fromDOMElement=function(t){var e,n,i,o,r,s,a,l;for(t.tagName,n=this.getDOMElementAttributes(t),s="",e="",r=function(){var e,n,o,r;for(o=t.childNodes,r=[],e=0,n=o.length;e80&&(t=t.substr(0,80)+"..."),t},Video.prototype.createDraggingDOMElement=function(){var t;if(this.isMounted())return t=Video.__super__.createDraggingDOMElement.call(this),t.innerHTML=this._title(),t},Video.prototype.html=function(t){var n,i,o,r,s,a,l;if(null==t&&(t=""),i=e.LINE_ENDINGS,"video"===this.tagName()){for(r=[],l=this.sources,s=0,a=l.length;s");return t+""+i+r.join(i)+i+t+""}return t+"<"+this._tagName+this._attributesToString()+">"},Video.prototype.mount=function(){var t;return this._domElement=document.createElement("div"),this.a&&this.a.class?this._domElement.setAttribute("class",this.a.class):this._attributes.class&&this._domElement.setAttribute("class",this._attributes.class),t=this._attributes.style?this._attributes.style:"",this._attributes.width&&(t+="width:"+this._attributes.width+"px;"),this._attributes.height&&(t+="height:"+this._attributes.height+"px;"),this._domElement.setAttribute("style",t),this._domElement.setAttribute("data-ce-title",this._title()),Video.__super__.mount.call(this)},Video.prototype.unmount=function(){var t,e;return this.isFixed()&&(e=document.createElement("div"),e.innerHTML=this.html(),t=e.querySelector("iframe"),this._domElement.parentNode.replaceChild(t,this._domElement),this._domElement=t),Video.__super__.unmount.call(this)},Video.droppers={Image:e.Element._dropBoth,PreText:e.Element._dropBoth,Static:e.Element._dropBoth,Text:e.Element._dropBoth,Video:e.Element._dropBoth},Video.placements=["above","below","left","right","center"],Video.fromDOMElement=function(t){var e,n,i,o,r,s;for(i=function(){var n,i,o,r;for(o=t.childNodes,r=[],n=0,i=o.length;n0?this.children[0]:null},ListItem.prototype.type=function(){return"ListItem"},ListItem.prototype.html=function(t){var n;return null==t&&(t=""),n=[t+""],this.listItemText()&&n.push(this.listItemText().html(t+e.INDENT)),this.list()&&n.push(this.list().html(t+e.INDENT)),n.push(t+""),n.join(e.LINE_ENDINGS)},ListItem.prototype.indent=function(){var t;if(this.can("indent")&&0!==this.parent().children.indexOf(this))return t=this.previousSibling(),t.list()||t.attach(new e.List(t.parent().tagName())),this.listItemText().storeState(),this.parent().detach(this),t.list().attach(this),this.listItemText().restoreState()},ListItem.prototype.remove=function(){var t,e,n,i,o,r;if(this.parent()){if(n=this.parent().children.indexOf(this),this.list())for(r=this.list().children.slice(),e=i=0,o=r.length;i0)for(l._getChild("tbody")||l.attach(new e.TableSection("tbody")),c=0,p=r.length;c0)return!1;return!0},TableRow.prototype.type=function(){return"TableRow"},TableRow.prototype.typeName=function(){return"Table row"},TableRow.prototype._onMouseOver=function(t){return TableRow.__super__._onMouseOver.call(this,t),this._removeCSSClass("ce-element--over")},TableRow.droppers={TableRow:e.Element._dropVert},TableRow.fromDOMElement=function(t){var n,i,o,r,s,a,l;for(r=new this(this.getDOMElementAttributes(t)),o=function(){var e,i,o,r;for(o=t.childNodes,r=[],e=0,i=o.length;e0?this.children[0]:null},TableCell.prototype.type=function(){return"TableCell"},TableCell.prototype.html=function(t){var n;return null==t&&(t=""),n=[t+"<"+this.tagName()+this._attributesToString()+">"],this.tableCellText()&&n.push(this.tableCellText().html(t+e.INDENT)),n.push(t+""),n.join(e.LINE_ENDINGS)},TableCell.prototype._onMouseOver=function(t){return TableCell.__super__._onMouseOver.call(this,t),this._removeCSSClass("ce-element--over")},TableCell.prototype._addDOMEventListeners=function(){},TableCell.prototype._removeDOMEventListners=function(){},TableCell.fromDOMElement=function(t){var n,i;return n=new this(t.tagName,this.getDOMElementAttributes(t)),i=new e.TableCellText(t.innerHTML.replace(/^\s+|\s+$/g,"")),n.attach(i),n},TableCell}(e.ElementCollection),e.TableCellText=function(t){function TableCellText(t){TableCellText.__super__.constructor.call(this,"div",{},t)}return l(TableCellText,t),TableCellText.prototype.cssTypeName=function(){return"table-cell-text"},TableCellText.prototype.type=function(){return"TableCellText"},TableCellText.prototype._isInFirstRow=function(){var t,e,n,i;return t=this.parent(),e=t.parent(),n=e.parent(),i=n.parent(),n===i.firstSection()&&e===n.children[0]},TableCellText.prototype._isInLastRow=function(){var t,e,n,i;return t=this.parent(),e=t.parent(),n=e.parent(),i=n.parent(),n===i.lastSection()&&e===n.children[n.children.length-1]},TableCellText.prototype._isLastInSection=function(){var t,e,n;return t=this.parent(),e=t.parent(),n=e.parent(),e===n.children[n.children.length-1]&&t===e.children[e.children.length-1]},TableCellText.prototype.blur=function(){return this.isMounted()&&(this._domElement.blur(),this._domElement.removeAttribute("contenteditable")),e.Element.prototype.blur.call(this)},TableCellText.prototype.can=function(t,e){if(e)throw new Error("Cannot set behaviour for ListItemText");return this.parent().can(t)},TableCellText.prototype.html=function(t){var n;return null==t&&(t=""),(!this._lastCached||this._lastCached0&&i.setAttribute("class",t.join(" ")),e)for(o in e)r=e[o],i.setAttribute(o,r);return n&&(i.innerHTML=n),i},ComponentUI}(),n.WidgetUI=function(t){function WidgetUI(){return WidgetUI.__super__.constructor.apply(this,arguments)}return a(WidgetUI,t),WidgetUI.prototype.attach=function(t,e){if(WidgetUI.__super__.attach.call(this,t,e),!this.isMounted())return t.mount()},WidgetUI.prototype.detach=function(t){if(WidgetUI.__super__.detach.call(this,t),this.isMounted())return t.unmount()},WidgetUI.prototype.detatch=function(t){return this.detach(t)},WidgetUI.prototype.show=function(){var t;return this._hideTimeout&&(clearTimeout(this._hideTimeout),this._hideTimeout=null,this.unmount()),this.isMounted()||this.mount(),t=function(t){return function(){return t.addCSSClass("ct-widget--active"),t._showTimeout=null}}(this),this._showTimeout=setTimeout(t,100)},WidgetUI.prototype.hide=function(){var t;if(this._showTimeout&&(clearTimeout(this._showTimeout),this._showTimeout=null),this.removeCSSClass("ct-widget--active"),t=function(e){return function(){return e._hideTimeout=null,window.getComputedStyle?parseFloat(window.getComputedStyle(e._domElement).opacity)<.01?e.unmount():e._hideTimeout=setTimeout(t,250):void e.unmount()}}(this),this.isMounted())return this._hideTimeout=setTimeout(t,250)},WidgetUI}(n.ComponentUI),n.AnchoredComponentUI=function(t){function AnchoredComponentUI(){return AnchoredComponentUI.__super__.constructor.apply(this,arguments)}return a(AnchoredComponentUI,t),AnchoredComponentUI.prototype.mount=function(t,e){return null==e&&(e=null),t.insertBefore(this._domElement,e),this._addDOMEventListeners()},AnchoredComponentUI}(n.ComponentUI),n.Event=function(){function Event(t,e){this._name=t,this._detail=e,this._timeStamp=Date.now(),this._defaultPrevented=!1,this._propagationStopped=!1}return Event.prototype.defaultPrevented=function(){return this._defaultPrevented},Event.prototype.detail=function(){return this._detail},Event.prototype.name=function(){return this._name},Event.prototype.propagationStopped=function(){return this._propagationStopped},Event.prototype.timeStamp=function(){return this._timeStamp},Event.prototype.preventDefault=function(){return this._defaultPrevented=!0},Event.prototype.stopImmediatePropagation=function(){return this._propagationStopped=!0},Event}(),n.FlashUI=function(t){function FlashUI(t){FlashUI.__super__.constructor.call(this),this.mount(t)}return a(FlashUI,t),FlashUI.prototype.mount=function(t){var e;return this._domElement=this.constructor.createDiv(["ct-flash","ct-flash--active","ct-flash--"+t,"ct-widget","ct-widget--active"]),FlashUI.__super__.mount.call(this,n.EditorApp.get().domElement()),e=function(t){return function(){return window.getComputedStyle?parseFloat(window.getComputedStyle(t._domElement).opacity)<.01?t.unmount():setTimeout(e,250):void t.unmount()}}(this),setTimeout(e,250)},FlashUI}(n.AnchoredComponentUI),n.IgnitionUI=function(t){function IgnitionUI(){IgnitionUI.__super__.constructor.call(this),this._revertToState="ready",this._state="ready"}return a(IgnitionUI,t),IgnitionUI.prototype.busy=function(t){if(this.dispatchEvent(this.createEvent("busy",{busy:t}))){if(t===("busy"===this._state))return;return t?(this._revertToState=this._state,this.state("busy")):this.state(this._revertToState)}},IgnitionUI.prototype.cancel=function(){if(this.dispatchEvent(this.createEvent("cancel")))return this.state("ready")},IgnitionUI.prototype.confirm=function(){if(this.dispatchEvent(this.createEvent("confirm")))return this.state("ready")},IgnitionUI.prototype.edit=function(){if(this.dispatchEvent(this.createEvent("edit")))return this.state("editing")},IgnitionUI.prototype.mount=function(){return IgnitionUI.__super__.mount.call(this),this._domElement=this.constructor.createDiv(["ct-widget","ct-ignition","ct-ignition--ready"]),this.parent().domElement().appendChild(this._domElement),this._domEdit=this.constructor.createDiv(["ct-ignition__button","ct-ignition__button--edit"]),this._domElement.appendChild(this._domEdit),this._domConfirm=this.constructor.createDiv(["ct-ignition__button","ct-ignition__button--confirm"]),this._domElement.appendChild(this._domConfirm),this._domCancel=this.constructor.createDiv(["ct-ignition__button","ct-ignition__button--cancel"]),this._domElement.appendChild(this._domCancel),this._domBusy=this.constructor.createDiv(["ct-ignition__button","ct-ignition__button--busy"]),this._domElement.appendChild(this._domBusy),this._addDOMEventListeners()},IgnitionUI.prototype.state=function(t){if(void 0===t)return this._state;if(this._state!==t&&this.dispatchEvent(this.createEvent("statechange",{state:t})))return this._state=t,this.removeCSSClass("ct-ignition--busy"),this.removeCSSClass("ct-ignition--editing"),this.removeCSSClass("ct-ignition--ready"),"busy"===this._state?this.addCSSClass("ct-ignition--busy"):"editing"===this._state?this.addCSSClass("ct-ignition--editing"):"ready"===this._state?this.addCSSClass("ct-ignition--ready"):void 0},IgnitionUI.prototype.unmount=function(){return IgnitionUI.__super__.unmount.call(this),this._domEdit=null,this._domConfirm=null,this._domCancel=null},IgnitionUI.prototype._addDOMEventListeners=function(){return this._domEdit.addEventListener("click",function(t){return function(e){return e.preventDefault(),t.edit()}}(this)),this._domConfirm.addEventListener("click",function(t){return function(e){return e.preventDefault(),t.confirm()}}(this)),this._domCancel.addEventListener("click",function(t){return function(e){return e.preventDefault(),t.cancel()}}(this))},IgnitionUI}(n.WidgetUI),n.InspectorUI=function(t){function InspectorUI(){InspectorUI.__super__.constructor.call(this),this._tagUIs=[]}return a(InspectorUI,t),InspectorUI.prototype.mount=function(){return this._domElement=this.constructor.createDiv(["ct-widget","ct-inspector"]),this.parent().domElement().appendChild(this._domElement),this._domTags=this.constructor.createDiv(["ct-inspector__tags","ct-tags"]),this._domElement.appendChild(this._domTags),this._domCounter=this.constructor.createDiv(["ct-inspector__counter"]),this._domElement.appendChild(this._domCounter),this.updateCounter(),this._addDOMEventListeners(),this._handleFocusChange=function(t){return function(){return t.updateTags()}}(this),ContentEdit.Root.get().bind("blur",this._handleFocusChange),ContentEdit.Root.get().bind("focus",this._handleFocusChange),ContentEdit.Root.get().bind("mount",this._handleFocusChange)},InspectorUI.prototype.unmount=function(){return InspectorUI.__super__.unmount.call(this),this._domTags=null,ContentEdit.Root.get().unbind("blur",this._handleFocusChange),ContentEdit.Root.get().unbind("focus",this._handleFocusChange),ContentEdit.Root.get().unbind("mount",this._handleFocusChange)},InspectorUI.prototype.updateCounter=function(){var t,e,i,o,r,s,a,l,u,h,c;if(this.isMounted()){for(e="",c=n.EditorApp.get().orderedRegions(),u=0,h=c.length;u]*>/gi,""),e=e.replace(/[\u200B]+/,""),e=e.replace(/['";:,.?¿\-!¡]+/g,""),l=(e.match(/\S+/g)||[]).length,l=l.toString().replace(/\B(?=(\d{3})+(?!\d))/g,","),(i=ContentEdit.Root.get().focused())&&"PreText"===i.type()&&i.selection().isCollapsed())?(o=0,t=1,a=i.content.substring(0,i.selection().get()[0]),r=a.text().split("\n"),o=r.length,t=r[r.length-1].length+1,o=o.toString().replace(/\B(?=(\d{3})+(?!\d))/g,","),t=t.toString().replace(/\B(?=(\d{3})+(?!\d))/g,","),this._domCounter.textContent=l+" / "+o+":"+t):void(this._domCounter.textContent=l)}},InspectorUI.prototype.updateTags=function(){var t,e,i,o,r,s,a,l,u;for(t=ContentEdit.Root.get().focused(),l=this._tagUIs,o=0,s=l.length;owindow.innerWidth&&(this._domElement.style.left=window.innerWidth-t.width+"px"),t.top+t.height>window.innerHeight&&(this._domElement.style.top=window.innerHeight-t.height+"px"),t.left<0&&(this._domElement.style.left="0px"),t.top<0&&(this._domElement.style.top="0px"),t=this._domElement.getBoundingClientRect(),window.localStorage.setItem("ct-toolbox-position",t.left+","+t.top)},ToolboxUI.prototype._removeDOMEventListeners=function(){return this.isMounted()&&this._domGrip.removeEventListener("mousedown",this._onStartDragging),window.removeEventListener("keydown",this._handleKeyDown),window.removeEventListener("resize",this._handleResize),clearInterval(this._updateToolsInterval)},ToolboxUI.prototype._onDrag=function(t){return ContentSelect.Range.unselectAll(),this._domElement.style.left=t.clientX-this._draggingOffset.x+"px",this._domElement.style.top=t.clientY-this._draggingOffset.y+"px"},ToolboxUI.prototype._onStartDragging=function(t){var e;if(t.preventDefault(),!this.isDragging())return this._dragging=!0,this.addCSSClass("ct-toolbox--dragging"),e=this._domElement.getBoundingClientRect(),this._draggingOffset={x:t.clientX-e.left,y:t.clientY-e.top},document.addEventListener("mousemove",this._onDrag),document.addEventListener("mouseup",this._onStopDragging),ContentEdit.addCSSClass(document.body,"ce--dragging")},ToolboxUI.prototype._onStopDragging=function(t){if(this.isDragging())return this._contain(),document.removeEventListener("mousemove",this._onDrag),document.removeEventListener("mouseup",this._onStopDragging),this._draggingOffset=null,this._dragging=!1,this.removeCSSClass("ct-toolbox--dragging"),ContentEdit.removeCSSClass(document.body,"ce--dragging")},ToolboxUI}(n.WidgetUI),n.ToolUI=function(t){function ToolUI(t){this._onMouseUp=l(this._onMouseUp,this),this._onMouseLeave=l(this._onMouseLeave,this),this._onMouseDown=l(this._onMouseDown,this),this._addDOMEventListeners=l(this._addDOMEventListeners,this),ToolUI.__super__.constructor.call(this),this.tool=t,this._mouseDown=!1,this._disabled=!1}return a(ToolUI,t),ToolUI.prototype.apply=function(t,e){var n,i;if(this.tool.canApply(t,e))return i={element:t,selection:e},n=function(t){return function(e){if(e)return t.dispatchEvent(t.createEvent("applied",i))}}(this),this.dispatchEvent(this.createEvent("apply",i))?this.tool.apply(t,e,n):void 0},ToolUI.prototype.disabled=function(t){if(void 0===t)return this._disabled;if(this._disabled!==t)return this._disabled=t,t?(this._mouseDown=!1,this.addCSSClass("ct-tool--disabled"),this.removeCSSClass("ct-tool--applied")):this.removeCSSClass("ct-tool--disabled")},ToolUI.prototype.mount=function(t,e){return null==e&&(e=null),this._domElement=this.constructor.createDiv(["ct-tool","ct-tool--"+this.tool.icon]),this._domElement.setAttribute("data-ct-tooltip",ContentEdit._(this.tool.label)),ToolUI.__super__.mount.call(this,t,e)},ToolUI.prototype.update=function(t,e){return(!this.tool.requiresElement||t&&t.isMounted())&&this.tool.canApply(t,e)?(this.disabled(!1),this.tool.isApplied(t,e)?this.addCSSClass("ct-tool--applied"):this.removeCSSClass("ct-tool--applied")):void this.disabled(!0)},ToolUI.prototype._addDOMEventListeners=function(){return this._domElement.addEventListener("mousedown",this._onMouseDown),this._domElement.addEventListener("mouseleave",this._onMouseLeave),this._domElement.addEventListener("mouseup",this._onMouseUp)},ToolUI.prototype._onMouseDown=function(t){if(t.preventDefault(),!this.disabled())return this._mouseDown=!0,this.addCSSClass("ct-tool--down")},ToolUI.prototype._onMouseLeave=function(t){return this._mouseDown=!1,this.removeCSSClass("ct-tool--down")},ToolUI.prototype._onMouseUp=function(t){var e,n;if(this._mouseDown){if(e=ContentEdit.Root.get().focused(),this.tool.requiresElement&&(!e||!e.isMounted()))return;n=null,e&&e.selection&&(n=e.selection()),this.apply(e,n)}return this._mouseDown=!1,this.removeCSSClass("ct-tool--down")},ToolUI}(n.AnchoredComponentUI),n.AnchoredDialogUI=function(t){function AnchoredDialogUI(){AnchoredDialogUI.__super__.constructor.call(this),this._position=[0,0]}return a(AnchoredDialogUI,t),AnchoredDialogUI.prototype.mount=function(){return this._domElement=this.constructor.createDiv(["ct-widget","ct-anchored-dialog"]),this.parent().domElement().appendChild(this._domElement),this._contain(),this._domElement.style.top=this._position[1]+"px",this._domElement.style.left=this._position[0]+"px"},AnchoredDialogUI.prototype.position=function(t){return void 0===t?this._position.slice():(this._position=t.slice(),this.isMounted()?(this._contain(),this._domElement.style.top=this._position[1]+"px",this._domElement.style.left=this._position[0]+"px"):void 0)},AnchoredDialogUI.prototype._contain=function(){var t,e,n;if(this.isMounted())return n=this._domElement.getBoundingClientRect(),t=n.width/2+5,e=document.documentElement.clientWidth||document.body.clientWidth,this._position[0]+t>e&&(this._position[0]=e-t),this._position[0]-1,head:n.indexOf("ct-section--applied")>-1},this.dispatchEvent(this.createEvent("save",t))},TableDialog.prototype.unmount=function(){return TableDialog.__super__.unmount.call(this),this._domBodyInput=null,this._domBodySection=null,this._domApply=null,this._domHeadSection=null,this._domHeadSwitch=null,this._domFootSection=null,this._domFootSwitch=null},TableDialog.prototype._addDOMEventListeners=function(){var t;return TableDialog.__super__._addDOMEventListeners.call(this),t=function(t){return t.preventDefault(),this.getAttribute("class").indexOf("ct-section--applied")>-1?ContentEdit.removeCSSClass(this,"ct-section--applied"):ContentEdit.addCSSClass(this,"ct-section--applied")},this._domHeadSection.addEventListener("click",t),this._domFootSection.addEventListener("click",t),this._domBodySection.addEventListener("click",function(t){return function(e){return t._domBodyInput.focus()}}(this)),this._domBodyInput.addEventListener("input",function(t){return function(e){var n;return n=/^[1-9]\d{0,1}$/.test(e.target.value),n?(ContentEdit.removeCSSClass(t._domBodyInput,"ct-section__input--invalid"),ContentEdit.removeCSSClass(t._domApply,"ct-control--muted")):(ContentEdit.addCSSClass(t._domBodyInput,"ct-section__input--invalid"),ContentEdit.addCSSClass(t._domApply,"ct-control--muted"))}}(this)),this._domApply.addEventListener("click",function(t){return function(e){var n;if(e.preventDefault(),n=t._domApply.getAttribute("class"),-1===n.indexOf("ct-control--muted"))return t.save()}}(this))},TableDialog}(n.DialogUI),n.VideoDialog=function(t){function VideoDialog(){VideoDialog.__super__.constructor.call(this,"Insert video")}return a(VideoDialog,t),VideoDialog.prototype.clearPreview=function(){if(this._domPreview)return this._domPreview.parentNode.removeChild(this._domPreview),this._domPreview=void 0},VideoDialog.prototype.mount=function(){var t;return VideoDialog.__super__.mount.call(this),ContentEdit.addCSSClass(this._domElement,"ct-video-dialog"),ContentEdit.addCSSClass(this._domView,"ct-video-dialog__preview"),t=this.constructor.createDiv(["ct-control-group"]),this._domControls.appendChild(t),this._domInput=document.createElement("input"),this._domInput.setAttribute("class","ct-video-dialog__input"),this._domInput.setAttribute("name","url"),this._domInput.setAttribute("placeholder",ContentEdit._("Paste YouTube or Vimeo URL")+"..."),this._domInput.setAttribute("type","text"),t.appendChild(this._domInput),this._domButton=this.constructor.createDiv(["ct-control","ct-control--text","ct-control--insert","ct-control--muted"]),this._domButton.textContent=ContentEdit._("Insert"),t.appendChild(this._domButton),this._addDOMEventListeners()},VideoDialog.prototype.preview=function(t){return this.clearPreview(),this._domPreview=document.createElement("iframe"),this._domPreview.setAttribute("frameborder","0"),this._domPreview.setAttribute("height","100%"),this._domPreview.setAttribute("src",t),this._domPreview.setAttribute("width","100%"),this._domView.appendChild(this._domPreview)},VideoDialog.prototype.save=function(){var t,e;return e=this._domInput.value.trim(),t=n.getEmbedVideoURL(e),t?this.dispatchEvent(this.createEvent("save",{url:t})):this.dispatchEvent(this.createEvent("save",{url:e}))},VideoDialog.prototype.show=function(){return VideoDialog.__super__.show.call(this),this._domInput.focus()},VideoDialog.prototype.unmount=function(){return this.isMounted()&&this._domInput.blur(),VideoDialog.__super__.unmount.call(this),this._domButton=null,this._domInput=null,this._domPreview=null},VideoDialog.prototype._addDOMEventListeners=function(){return VideoDialog.__super__._addDOMEventListeners.call(this),this._domInput.addEventListener("input",function(t){return function(e){var i;return e.target.value?ContentEdit.removeCSSClass(t._domButton,"ct-control--muted"):ContentEdit.addCSSClass(t._domButton,"ct-control--muted"),t._updatePreviewTimeout&&clearTimeout(t._updatePreviewTimeout),i=function(){var e,i;return i=t._domInput.value.trim(),e=n.getEmbedVideoURL(i),e?t.preview(e):t.clearPreview()},t._updatePreviewTimeout=setTimeout(i,500)}}(this)),this._domInput.addEventListener("keypress",function(t){return function(e){if(13===e.keyCode)return t.save()}}(this)),this._domButton.addEventListener("click",function(t){return function(e){var n;if(e.preventDefault(),n=t._domButton.getAttribute("class"),-1===n.indexOf("ct-control--muted"))return t.save()}}(this))},VideoDialog}(n.DialogUI),n.HTMLCleaner=function(){function HTMLCleaner(t,e){this.tagWhitelist=t||this.constructor.DEFAULT_TAG_WHITELIST,this.attributeWhitelist=e||this.constructor.DEFAULT_ATTRIBUTE_WHITELIST}return HTMLCleaner.DEFAULT_ATTRIBUTE_WHITELIST={a:["href"],td:["colspan"]},HTMLCleaner.DEFAULT_TAG_WHITELIST=["a","address","b","blockquote","code","del","em","h1","h2","h3","h4","h5","h6","i","ins","li","ol","p","pre","strong","sup","table","tbody","td","tfoot","th","thead","tr","u","ul","#text"],HTMLCleaner.NO_CONTENT_TAGS=["head","meta","style","script","title"],HTMLCleaner.prototype.clean=function(t){var e,n,i,o,r,s,a,l,u,h,c,d,p,_,m,g,f;for(u=document.implementation.createHTMLDocument(),d=u.createElement("div"),d.innerHTML=t,h=function(){var t,e,n,o;for(n=d.childNodes,o=[],t=0,e=n.length;t0;)if(r=h.shift(),s=r.nodeName.toLowerCase(),this.tagWhitelist.indexOf(s)<0){if(this.constructor.NO_CONTENT_TAGS.indexOf(s)>-1){r.remove();continue}for(f=r.childNodes,p=0,m=f.length;p=r.length-1)){for(e=r[o+1],i=null,l=e.descendants(),s=0,a=l.length;s-1&&c.indexOf(p)>-1){if(e=c.indexOf(l)>-1&&c.indexOf(p)>-1?new HTMLString.String(w.innerHTML):new HTMLString.String(HTMLString.String.encode(w.textContent)),t.content)return C=t.selection(),s=C.get()[0]+e.length(),S=t.content.substring(0,C.get()[0]),b=t.content.substring(C.get()[1]),y=t.content.substring(C.get()[0],C.get()[1]),y.length()&&(i=y.characters[0],I=i.tags(),i.isTag()&&I.shift(),I.length>=1&&(e=e.format.apply(e,[0,e.length()].concat(u.call(I))))),t.content=S.concat(e),t.content=t.content.concat(b,!1),t.updateInnerHTML(),t.taint(),C.set(s,s),void t.selection(C);w.innerHTML="

"+e.html()+"

"}if(g=t,"Region"!==t.parent().type()&&(t=t.closest(function(t){return"Region"===t.parent().type()})),v=t.parent(),c.indexOf(l)>-1&&c.indexOf(p)>-1){for(d=w.createElement("p");w.childNodes.length>0;)d.appendChild(w.childNodes[0]);w.appendChild(d)}for(h=0,_=g,A=w.childNodes,M=0,U=A.length;M=1&&(e=e.format.apply(e,[0,e.length()].concat(u.call(y))))),t.content=C.concat(e),t.content=t.content.concat(E,!1),t.updateInnerHTML(),t.taint(),f.set(i,i),t.selection(f)}},_EditorApp.prototype.revert=function(){var t;if(this.dispatchEvent(this.createEvent("revert")))return!(n.CANCEL_MESSAGE&&(t=ContentEdit._(n.CANCEL_MESSAGE),ContentEdit.Root.get().lastModified()>this._rootLastModified&&!window.confirm(t)))&&(this.revertToSnapshot(this.history.goTo(0),!1),!0)},_EditorApp.prototype.revertToSnapshot=function(t,e){var n,i,o,r,s,a,l,u,h,c;null==e&&(e=!0),i=[],u=this._regions;for(o in u){for(r=u[o],h=r.children,a=0,l=h.length;a-1?c.push(this._orderedRegions.splice(r,1)):c.push(void 0));return c},_EditorApp}(n.ComponentUI),n.EditorApp=function(){function EditorApp(){}var t;return t=null,EditorApp.get=function(){var e;return e=n.EditorApp.getCls(),null!=t?t:t=new e},EditorApp.getCls=function(){return r},EditorApp}(),n.History=function(){function History(t){this._lastSnapshotTaken=null,this._regions={},this.replaceRegions(t),this._snapshotIndex=-1,this._snapshots=[],this._store()}return History.prototype.canRedo=function(){return this._snapshotIndex0},History.prototype.index=function(){return this._snapshotIndex},History.prototype.length=function(){return this._snapshots.length},History.prototype.snapshot=function(){return this._snapshots[this._snapshotIndex]},History.prototype.goTo=function(t){return this._snapshotIndex=Math.min(this._snapshots.length-1,Math.max(0,t)),this.snapshot()},History.prototype.redo=function(){return this.goTo(this._snapshotIndex+1)},History.prototype.replaceRegions=function(t){var e,n,i;this._regions={},i=[];for(e in t)n=t[e],i.push(this._regions[e]=n);return i},History.prototype.restoreSelection=function(t){var e,n;if(t.selected)return n=this._regions[t.selected.region],e=n.descendants()[t.selected.element],e.focus(),e.selection&&t.selected.selection?e.selection(t.selected.selection):void 0},History.prototype.stopWatching=function(){if(this._watchInterval&&clearInterval(this._watchInterval),this._delayedStoreTimeout)return clearTimeout(this._delayedStoreTimeout)},History.prototype.undo=function(){return this.goTo(this._snapshotIndex-1)},History.prototype.watch=function(){var t;return this._lastSnapshotTaken=Date.now(),t=function(t){return function(){var e,n;if(null!==(n=ContentEdit.Root.get().lastModified())&&n>t._lastSnapshotTaken){if(t._delayedStoreRequested===n)return;return t._delayedStoreTimeout&&clearTimeout(t._delayedStoreTimeout),e=function(){return t._lastSnapshotTaken=n,t._store()},t._delayedStoreRequested=n,t._delayedStoreTimeout=setTimeout(e,500)}}}(this),this._watchInterval=setInterval(t,50)},History.prototype._store=function(){var t,e,n,i,o,r,s;o={regions:{},regionModifieds:{},rootModified:ContentEdit.Root.get().lastModified(),selected:null},r=this._regions;for(e in r)i=r[e],o.regions[e]=i.html(),o.regionModifieds[e]=i.lastModified();if(t=ContentEdit.Root.get().focused()){if(o.selected={},!(i=t.closest(function(t){return"Region"===t.type()||"Fixture"===t.type()})))return;s=this._regions;for(e in s)if(n=s[e],i===n){o.selected.region=e;break}o.selected.element=i.descendants().indexOf(t),t.selection&&(o.selected.selection=t.selection())}return this._snapshotIndex0&&s[f-1].hasTags("a");)f-=1;for(;u-1){t.addCSSClass(o);break}t.a=null}t.unmount(),t.mount()}else t.isFixed()&&"a"===t.tagName()?t.attr("href",s.href):(t.content=t.content.unformat(h,v,"a"),s.href&&(n=new HTMLString.Tag("a",s),t.content=t.content.format(h,v,n),t.content.optimize()),t.updateInnerHTML());return t.taint(),d.dispatchEvent(d.createEvent("click"))}),o.attach(d),o.attach(a),d.show(),a.show()}},Link}(n.Tools.Bold),n.Tools.Heading=function(t){function Heading(){return Heading.__super__.constructor.apply(this,arguments)}return a(Heading,t),n.ToolShelf.stow(Heading,"heading"),Heading.label="Heading",Heading.icon="heading",Heading.tagName="h1",Heading.canApply=function(t,e){return!t.isFixed()&&(void 0!==t.content&&-1!==["Text","PreText"].indexOf(t.type()))},Heading.isApplied=function(t,e){return!!t.content&&(-1!==["Text","PreText"].indexOf(t.type())&&t.tagName()===this.tagName)},Heading.apply=function(t,e,n){var i,o,r,s,a;if(a={tool:this,element:t,selection:e},this.dispatchEditorEvent("tool-apply",a))return t.storeState(),"PreText"===t.type()?(i=t.content.html().replace(/ /g," "),s=new ContentEdit.Text(this.tagName,{},i),r=t.parent(),o=r.children.indexOf(t),r.detach(t),r.attach(s,o),t.blur(),s.focus(),s.selection(e)):(t.removeAttr("class"),t.tagName()===this.tagName?t.tagName("p"):t.tagName(this.tagName),t.restoreState()),this.dispatchEditorEvent("tool-applied",a),n(!0)},Heading}(n.Tool),n.Tools.Subheading=function(t){function Subheading(){return Subheading.__super__.constructor.apply(this,arguments)}return a(Subheading,t),n.ToolShelf.stow(Subheading,"subheading"),Subheading.label="Subheading",Subheading.icon="subheading",Subheading.tagName="h2",Subheading}(n.Tools.Heading),n.Tools.Paragraph=function(t){function Paragraph(){return Paragraph.__super__.constructor.apply(this,arguments)}return a(Paragraph,t),n.ToolShelf.stow(Paragraph,"paragraph"),Paragraph.label="Paragraph",Paragraph.icon="paragraph",Paragraph.tagName="p",Paragraph.canApply=function(t,e){return!t.isFixed()&&void 0!==t},Paragraph.apply=function(t,e,i){var o,r,s,a;return o=this.editor().ctrlDown(),n.Tools.Heading.canApply(t)&&!o?Paragraph.__super__.constructor.apply.call(this,t,e,i):(a={tool:this,element:t,selection:e},this.dispatchEditorEvent("tool-apply",a)?("Region"!==t.parent().type()&&(t=t.closest(function(t){return"Region"===t.parent().type()})),s=t.parent(),r=new ContentEdit.Text("p"),s.attach(r,s.children.indexOf(t)+1),r.focus(),i(!0),this.dispatchEditorEvent("tool-applied",a)):void 0)},Paragraph}(n.Tools.Heading),n.Tools.Preformatted=function(t){function Preformatted(){return Preformatted.__super__.constructor.apply(this,arguments)}return a(Preformatted,t),n.ToolShelf.stow(Preformatted,"preformatted"),Preformatted.label="Preformatted",Preformatted.icon="preformatted",Preformatted.tagName="pre",Preformatted.apply=function(t,e,i){var o,r,s,a,l;if(l={tool:this,element:t,selection:e},this.dispatchEditorEvent("tool-apply",l))return"PreText"===t.type()?void n.Tools.Paragraph.apply(t,e,i):(a=t.content.text(),s=new ContentEdit.PreText("pre",{},HTMLString.String.encode(a)),r=t.parent(),o=r.children.indexOf(t),r.detach(t),r.attach(s,o),t.blur(),s.focus(),s.selection(e),i(!0),this.dispatchEditorEvent("tool-applied",l))},Preformatted}(n.Tools.Heading),n.Tools.AlignLeft=function(t){function AlignLeft(){return AlignLeft.__super__.constructor.apply(this,arguments)}return a(AlignLeft,t),n.ToolShelf.stow(AlignLeft,"align-left"),AlignLeft.label="Align left",AlignLeft.icon="align-left",AlignLeft.className="text-left",AlignLeft.canApply=function(t,e){return void 0!==t.content},AlignLeft.isApplied=function(t,e){var n;return!!this.canApply(t)&&("ListItemText"!==(n=t.type())&&"TableCellText"!==n||(t=t.parent()),t.hasCSSClass(this.className))},AlignLeft.apply=function(t,e,i){var o,r,s,a,l,u;if(s={tool:this,element:t,selection:e},this.dispatchEditorEvent("tool-apply",s)){for("ListItemText"!==(u=t.type())&&"TableCellText"!==u||(t=t.parent()),o=[n.Tools.AlignLeft.className,n.Tools.AlignCenter.className,n.Tools.AlignRight.className],a=0,l=o.length;a0;a=s<=0?++t:--t)n=l.children[l.children.length-1],e.push(l.detach(n));return e}()):s>0?d.push(function(){var t,e;for(e=[],a=t=0;0<=s?ts;a=0<=s?++t:--t)n=new ContentEdit.TableCell(i),l.attach(n),o=new ContentEdit.TableCellText(""),e.push(n.attach(o));return e}()):d.push(void 0);return d},Table._createTable=function(t){var e,n,i,o;return o=new ContentEdit.Table,t.head&&(i=this._createTableSection("thead","th",t.columns),o.attach(i)),e=this._createTableSection("tbody","td",t.columns),o.attach(e),t.foot&&(n=this._createTableSection("tfoot","td",t.columns),o.attach(n)),o},Table._createTableSection=function(t,e,n){var i,o,r,s,a;for(s=new ContentEdit.TableSection(t),r=new ContentEdit.TableRow,s.attach(r),a=0;0<=n?an;0<=n?++a:--a)i=new ContentEdit.TableCell(e),r.attach(i),o=new ContentEdit.TableCellText(""),i.attach(o);return s},Table._updateTable=function(t,e){var n,i,o,r,s,a,l;if(!t.head&&e.thead()&&e.detach(e.thead()),!t.foot&&e.tfoot()&&e.detach(e.tfoot()),n=e.firstSection().children[0].children.length,t.columns!==n)for(l=e.children,s=0,a=l.length;s0},Indent.apply=function(t,e,n){var i;if(i={tool:this,element:t,selection:e},this.dispatchEditorEvent("tool-apply",i))return t.parent().indent(),n(!0),this.dispatchEditorEvent("tool-applied",i)},Indent}(n.Tool),n.Tools.Unindent=function(t){function Unindent(){return Unindent.__super__.constructor.apply(this,arguments)}return a(Unindent,t),n.ToolShelf.stow(Unindent,"unindent"),Unindent.label="Unindent",Unindent.icon="unindent",Unindent.canApply=function(t,e){return"ListItem"===t.parent().type()},Unindent.apply=function(t,e,n){var i;if(i={tool:this,element:t,selection:e},this.dispatchEditorEvent("tool-apply",i))return t.parent().unindent(),n(!0),this.dispatchEditorEvent("tool-applied",i)},Unindent}(n.Tool),n.Tools.LineBreak=function(t){function LineBreak(){return LineBreak.__super__.constructor.apply(this,arguments)}return a(LineBreak,t),n.ToolShelf.stow(LineBreak,"line-break"),LineBreak.label="Line break",LineBreak.icon="line-break",LineBreak.canApply=function(t,e){return t.content},LineBreak.apply=function(t,e,n){var i,o,r,s,a;if(a={tool:this,element:t,selection:e},this.dispatchEditorEvent("tool-apply",a))return o=e.get()[0]+1,s=t.content.substring(0,e.get()[0]),r=t.content.substring(e.get()[1]),i=new HTMLString.String("
",t.content.preserveWhitespace()),t.content=s.concat(i,r),t.updateInnerHTML(),t.taint(),e.set(o,o),t.selection(e),n(!0),this.dispatchEditorEvent("tool-applied",a)},LineBreak}(n.Tool),n.Tools.Image=function(t){function Image(){return Image.__super__.constructor.apply(this,arguments)}return a(Image,t),n.ToolShelf.stow(Image,"image"),Image.label="Image",Image.icon="image",Image.canApply=function(t,e){return!t.isFixed()||"ImageFixture"===t.type()},Image.apply=function(t,e,i){var o,r,s,a;if(a={tool:this,element:t,selection:e},this.dispatchEditorEvent("tool-apply",a))return t.storeState&&t.storeState(),o=n.EditorApp.get(),s=new n.ModalUI,r=new n.ImageDialog,r.addEventListener("cancel",function(e){return function(){return s.hide(),r.hide(),t.restoreState&&t.restoreState(),i(!1)}}()),r.addEventListener("save",function(e){return function(n){var o,l,u,h,c,d,p,_;return o=n.detail(),c=o.imageURL,h=o.imageSize,u=o.imageAttrs,u||(u={}),u.height=h[1],u.src=c,u.width=h[0],"ImageFixture"===t.type()?t.src(c):(l=new ContentEdit.Image(u),_=e._insertAt(t),p=_[0],d=_[1],p.parent().attach(l,d),l.focus()),s.hide(),r.hide(),i(!0),e.dispatchEditorEvent("tool-applied",a)}}(this)),o.attach(s),o.attach(r),s.show(),r.show()},Image}(n.Tool),n.Tools.Video=function(t){function Video(){return Video.__super__.constructor.apply(this,arguments)}return a(Video,t),n.ToolShelf.stow(Video,"video"),Video.label="Video",Video.icon="video",Video.canApply=function(t,e){return!t.isFixed()},Video.apply=function(t,e,i){var o,r,s,a;if(a={tool:this,element:t,selection:e},this.dispatchEditorEvent("tool-apply",a))return t.storeState&&t.storeState(),o=n.EditorApp.get(),s=new n.ModalUI,r=new n.VideoDialog,r.addEventListener("cancel",function(e){return function(){return s.hide(),r.hide(),t.restoreState&&t.restoreState(),i(!1)}}()),r.addEventListener("save",function(e){return function(o){var l,u,h,c,d,p;if(c=o.detail().url,c?(d=new ContentEdit.Video("iframe",{frameborder:0,height:n.DEFAULT_VIDEO_HEIGHT,src:c,width:n.DEFAULT_VIDEO_WIDTH}),p=e._insertAt(t),h=p[0],u=p[1],h.parent().attach(d,u),d.focus()):t.restoreState&&t.restoreState(),s.hide(),r.hide(),l=""!==c,i(l),l)return e.dispatchEditorEvent("tool-applied",a)}}(this)),o.attach(s),o.attach(r),s.show(),r.show()},Video}(n.Tool),n.Tools.Undo=function(t){function Undo(){return Undo.__super__.constructor.apply(this,arguments)}return a(Undo,t),n.ToolShelf.stow(Undo,"undo"),Undo.label="Undo",Undo.icon="undo",Undo.requiresElement=!1,Undo.canApply=function(t,e){var i;return i=n.EditorApp.get(),i.history&&i.history.canUndo()},Undo.apply=function(t,e,n){var i,o,r;if(r={tool:this,element:t,selection:e},this.dispatchEditorEvent("tool-apply",r))return i=this.editor(),i.history.stopWatching(),o=i.history.undo(),i.revertToSnapshot(o),i.history.watch(),this.dispatchEditorEvent("tool-applied",r)},Undo}(n.Tool),n.Tools.Redo=function(t){function Redo(){return Redo.__super__.constructor.apply(this,arguments)}return a(Redo,t),n.ToolShelf.stow(Redo,"redo"),Redo.label="Redo",Redo.icon="redo",Redo.requiresElement=!1,Redo.canApply=function(t,e){var i;return i=n.EditorApp.get(),i.history&&i.history.canRedo()},Redo.apply=function(t,e,i){var o,r,s;if(s={tool:this,element:t,selection:e},this.dispatchEditorEvent("tool-apply",s))return o=n.EditorApp.get(),o.history.stopWatching(),r=o.history.redo(),o.revertToSnapshot(r),o.history.watch(),this.dispatchEditorEvent("tool-applied",s)},Redo}(n.Tool),n.Tools.Remove=function(t){function Remove(){return Remove.__super__.constructor.apply(this,arguments)}return a(Remove,t),n.ToolShelf.stow(Remove,"remove"),Remove.label="Remove",Remove.icon="remove",Remove.canApply=function(t,e){return!t.isFixed()},Remove.apply=function(t,e,n){var i,o,r,s,a;if(a={tool:this,element:t,selection:e},this.dispatchEditorEvent("tool-apply",a)){if(i=this.editor(),t.blur(),t.nextContent()?t.nextContent().focus():t.previousContent()&&t.previousContent().focus(),!t.isMounted())return n(!0),void this.dispatchEditorEvent("tool-applied",a);switch(t.type()){case"ListItemText":i.ctrlDown()?(o=t.closest(function(t){return"Region"===t.parent().type()}),o.parent().detach(o)):t.parent().parent().detach(t.parent());break;case"TableCellText":i.ctrlDown()?(s=t.closest(function(t){return"Table"===t.type()}),s.parent().detach(s)):(r=t.parent().parent(),r.parent().detach(r));break;default:t.parent().detach(t)}return n(!0),this.dispatchEditorEvent("tool-applied",a)}},Remove}(n.Tool)}.call(this)},function(t,e){(function(){var e,n,i={}.hasOwnProperty,o=function(t,e){function ctor(){this.constructor=t}for(var n in e)i.call(e,n)&&(t[n]=e[n]);return ctor.prototype=e.prototype,t.prototype=new ctor,t.__super__=e.prototype,t},r=[].slice,s=function(t,e){return function(){return t.apply(e,arguments)}};e={dimSnippetDOMElement:function(t,n){var i;if(i=e.getSnippetDOMElement(t,n))return i.classList.remove("cf--highlight-snippet")},dimAllSnippetDOMElements:function(){var t,e,n,i,o;for(i=document.querySelectorAll(".cf--highlight-snippet"),o=[],e=0,n=i.length;e0)return this.mount(),this._toggle.show(),this.flow(this._flows.flows()[0])},_FlowMgr.prototype.api=function(){return this._api},_FlowMgr.prototype.isOpen=function(){return this._open},_FlowMgr.prototype.close=function(){var t;if(this.dispatchEvent(this.createEvent("close")))return document.body.classList.remove("cf--flow-mgr-open"),this._draw.close(),t=ContentTools.EditorApp.get(),t.syncRegions(),t.domRegions().length?t.ignition().show():void 0},_FlowMgr.prototype.flow=function(t,n){return null==n&&(n=!1),void 0===t?this._flow:n||this._flow!==t?(this._flow=t,this._flows.select(t),e.FlowMgr.get().loadInterface("list-snippets")):void 0},_FlowMgr.prototype.loadInterface=function(){var t,e,n,i;if(n=arguments[0],t=2<=arguments.length?r.call(arguments,1):[],i=new this.constructor._uiInterfaces[n])return i.safeToClose()?this._toggle.enable():this._toggle.disable(),this._draw.children().length>1&&(e=this._draw.children()[1],e.unmount(),this._draw.detach(e)),this._draw.attach(i),i.mount(),i.init.apply(i,t)},_FlowMgr.prototype.mount=function(){var t,e,n,i,o;for(this._domElement=this.constructor.createDiv(["cf-flow-mgr"]),document.body.insertBefore(this._domElement,null),this._addDOMEventListeners(),i=this.children(),o=[],e=0,n=i.length;e0;)this._domSelect.remove(0);for(s=this._flows,a=[],o=0,r=s.length;o0&&i._body.attach(i._global),i._body.unmount(),i._body.mount()})}}(this))},AddSnippetUI}(e.InterfaceUI),e.FlowMgr.getCls().registerInterface("add-snippet",e.AddSnippetUI),e.ListSnippetsUI=function(t){function ListSnippetsUI(){ListSnippetsUI.__super__.constructor.call(this,"Snippets"),this._tools={order:new e.InlayToolUI("order","Order",!0),add:new e.InlayToolUI("add","Add",!0)},this._header.tools().attach(this._tools.order),this._header.tools().attach(this._tools.add),this._tools.order.addEventListener("click",function(t){return function(t){return e.FlowMgr.get().loadInterface("order-snippets")}}()),this._tools.add.addEventListener("click",function(t){return function(t){return e.FlowMgr.get().loadInterface("add-snippet")}}())}return o(ListSnippetsUI,t),ListSnippetsUI.prototype.init=function(){var t,n;return ListSnippetsUI.__super__.init.call(this),e.dimAllSnippetDOMElements(),t=e.FlowMgr.get(),n=t.api().getSnippets(t.flow()),n.addEventListener("load",function(i){return function(o){var r,s,a,l,u,h,c,d,p,_,m,g,f;for(a=JSON.parse(o.target.responseText).payload,g=i._body.children,d=0,_=g.length;d<_;d++)r=g[d],i._body.detach(r);for(s=e.FlowMgr.get().flow(),u=e.getSnippetCls(s),f=a.snippets,p=0,m=f.length;p=l.height/2&&(i=i.nextElementSibling),this._body.domElement().insertBefore(this._grabbed,i)}},OrderSnippetsUI.prototype._drop=function(t){var e,n,i,o,r;if(this._grabbed){for(this._grabbed.classList.remove("ct-snippet--ghost"),this._grabbed=null,this._grabbedOffset=null,document.body.removeChild(this._grabbedHelper),this._grabbedHelper=null,this._body.domElement().classList.remove("ct-inlay__body--sorting"),this._newSnippetOrder=[],r=this._body.domElement().childNodes,i=0,o=r.length;i0},SaveSemaphore}(),l=function(t,e,n){var i;return i=o.EditorApp.get(),i.addEventListener("saved",function(r){var s,l,u,h,c,d,p;if(c=r.detail().regions,Object.keys(c).length>0&&(s=n(c),Object.keys(s).length>0)){a.inc(),i.busy(!0),p=new XMLHttpRequest,p.open("POST",t),l=new FormData,h=e||{};for(u in h)d=h[u],l.append(u,d);return l.append("contents",JSON.stringify(s)),p.send(l),p.addEventListener("load",function(t){return a.dec(),a.saving()||i.busy(!1),200===parseInt(t.target.status)?new o.FlashUI("ok"):new o.FlashUI("no")})}})},u=function(t,e,n){var a,u,h,c,d;return null==t&&(t="/"),null==e&&(e="/"),null==n&&(n={}),u=o.EditorApp.get(),h=i.FlowMgr.get(),ContentEdit.INDENT="",ContentEdit.LINE_ENDINGS="",o.RESTRICTED_ATTRIBUTES["*"].push("data-ce-tag"),o.RESTRICTED_ATTRIBUTES["*"].push("data-fixture"),o.RESTRICTED_ATTRIBUTES["*"].push("data-transforms"),o.RESTRICTED_ATTRIBUTES["*"].push("data-mh-asset-key"),o.RESTRICTED_ATTRIBUTES["*"].push("data-name"),o.IMAGE_UPLOADER=function(t){return new s(t,n)},u.init("[data-allow-edits] [data-editable], [data-allow-edits] [data-fixture]","data-name"),a=new r(e,n),h.init("[data-cf-flow]",a),c=e+"update-flow-contents",l(c,n,function(t){var e,n,i,o,r,s;e={};for(n in t)s=t[n],n.startsWith("snippet:")&&(i=n.split(":"),i[0],r=i[1],o=i[2],e[r]||(e[r]={}),e[r][o]=s);return e}),d=t+"update-global-contents",l(d,n,function(t){var e,n,i,o,r;e={};for(n in t)r=t[n],n.startsWith("global:")&&(i=n.split(":"),i[0],o=i[1],e[o]=r);return e})},t.exports={init:u,addSaveProcess:l,FlowAPI:r,ImageUploader:s,SaveSemaphore:a}},function(t,e,n){var i,o,r=function(t,e){function ctor(){this.constructor=t}for(var n in e)s.call(e,n)&&(t[n]=e[n]);return ctor.prototype=e.prototype,t.prototype=new ctor,t.__super__=e.prototype,t},s={}.hasOwnProperty;i=n(1),o=function(t){function FlowAPI(t,e){null==t&&(t="/"),null==e&&(e={}),FlowAPI.__super__.constructor.call(this,t,e)}return r(FlowAPI,t),FlowAPI}(i.BaseAPI),t.exports={FlowAPI:o}},function(t,e,n){var i,o;i=n(0),o=function(){function ImageUploader(t,e){null==e&&(e={}),this.dialog=t,this.baseParams=e,this.postTransforms=[],this.element=ContentEdit.Root.get().focused(),"ImageFixture"===this.element.type()&&(this.postTransforms=JSON.parse(this.element.domElement().getAttribute("data-transforms")||"[]")),t.addEventListener("imageuploader.cancelupload",function(t){return function(){return t.onCancelUpload()}}(this)),t.addEventListener("imageuploader.clear",function(t){return function(){return t.onClear()}}(this)),t.addEventListener("imageuploader.clear",function(t){return function(){return t.onClear()}}(this)),t.addEventListener("imageuploader.fileready",function(t){return function(e){if(e.detail().file)return t.onFileReady(e.detail().file)}}(this)),t.addEventListener("imageuploader.rotateccw",function(t){return function(e){return t.onRotate(-90)}}(this)),t.addEventListener("imageuploader.rotatecw",function(t){return function(e){return t.onRotate(90)}}(this)),t.addEventListener("imageuploader.save",function(t){return function(){return t.onSave()}}(this))}return ImageUploader.prototype.getTransformURL=function(){return"/manage/transform-asset"},ImageUploader.prototype.getUploadURL=function(){return"/manage/upload-asset"},ImageUploader.prototype.transform=function(t,e){var n,o,r,s,a;n=new FormData,r=this.baseParams;for(o in r)s=r[o],n.append(o,s);return n.append("key",this.image.key),n.append("transforms",JSON.stringify(t)),a=new XMLHttpRequest,a.open("POST",this.getTransformURL(),!0),a.addEventListener("load",function(t){return function(n){var o;return 200===parseInt(n.target.status)?(o=JSON.parse(n.target.responseText),e(o.payload.asset)):new i.FlashUI("no"),t.xhr=null}}(this)),a.send(n)},ImageUploader.prototype.onCancelUpload=function(){return this.xhr&&(this.xhr.upload.removeEventListener("progress",this.xhrProgress),this.xhr.upload.removeEventListener("load",this.xhrComplete),this.xhr.abort()),this.dialog.state("empty")},ImageUploader.prototype.onClear=function(){return this.dialog.clear(),this.image=null},ImageUploader.prototype.onFileReady=function(t){var e,n,o,r;this.dialog.progress(0),this.dialog.state("uploading"),e=new FormData,o=this.baseParams;for(n in o)r=o[n],e.append(n,r);return e.append("file",t),this.xhr=new XMLHttpRequest,this.xhr.open("POST",this.getUploadURL(),!0),this.xhrProgress=function(t){return function(e){return t.dialog.progress(e.loaded/e.total*100)}}(this),this.xhr.upload.addEventListener("progress",this.xhrProgress),this.xhrComplete=function(t){return function(e){var n,o;return 200===parseInt(e.target.status)?(o=JSON.parse(e.target.responseText),n=o.payload.asset,n.type?(t.image={angle:0,height:n.core_meta.image.size[1],key:n.key,maxWidth:n.core_meta.image.size[0],url:n.variations["--draft--"].url,width:n.core_meta.image.size[0]},t.dialog.populate(t.image.url,[t.image.width,t.image.height])):new i.FlashUI("no")):new i.FlashUI("no"),t.xhr=null}}(this),this.xhr.addEventListener("load",this.xhrComplete),this.xhr.send(e)},ImageUploader.prototype.onRotate=function(t){var e;return this.image.angle+=t,this.image.angle<0?this.image.angle+=360:this.image.angle>270&&(this.image.angle-=360),e=[{id:"image.rotate",settings:{angle:this.image.angle}}],this.transform(e,function(t){return function(e){return t.image.url=e.variations["--draft--"].url,90===t.image.angle||(t.image.angle=270)?(t.image.height=e.core_meta.image.size[0],t.image.maxWidth=e.core_meta.image.size[1],t.image.width=e.core_meta.image.size[1]):(t.image.height=e.core_meta.image.size[1],t.image.maxWidth=e.core_meta.image.size[0],t.image.width=e.core_meta.image.size[0]),t.dialog.populate(t.image.url,[t.image.width,t.image.height])}}(this))},ImageUploader.prototype.onSave=function(){var t,e,n;return n=[],0!==this.image.angle&&n.push({id:"image.rotate",settings:{angle:this.image.angle}}),e=this.dialog.cropRegion(),t=this.image.maxWidth,e.toString()!==[0,0,1,1].toString()&&(n.push({id:"image.crop",settings:{top:Math.max(0,e[0]),left:Math.max(0,e[1]),bottom:Math.min(1,e[2]),right:Math.min(1,e[3])}}),t=parseInt(t*(e[3]-e[1]))),n=n.concat(this.postTransforms),this.transform(n,function(e){return function(n){var i;if(i=n.variations["--draft--"],e.dialog.save(i.url,[i.core_meta.image.size[0],i.core_meta.image.size[1]],{alt:"","data-ce-max-width":t,"data-mh-asset-key":n.key}),"ImageFixture"===e.element.type()&&(e.element.attr("data-mh-asset-key",n.key),!e.element.attr("alt")))return e.element.attr("alt","")}}(this))},ImageUploader}(),t.exports={ImageUploader:o}},function(t,e,n){!function(e,n){t.exports=n()}(0,function(){return function(t){function __webpack_require__(n){if(e[n])return e[n].exports;var i=e[n]={exports:{},id:n,loaded:!1};return t[n].call(i.exports,i,i.exports,__webpack_require__),i.loaded=!0,i.exports}var e={};return __webpack_require__.m=t,__webpack_require__.c=e,__webpack_require__.p="",__webpack_require__(0)}([function(t,e,n){t.exports=n(1)},function(t,e){var n,i,o,r,s,a,l,u,h,c,d=[].indexOf||function(t){for(var e=0,n=this.length;e=0?n[i]=o:n.setAttribute(i,o);return n},h=function(t,e){return null==e&&(e=document),Array.prototype.slice.call(e.querySelectorAll(t))},c=function(t,e){return null==e&&(e=document),e.querySelector(t)},s=function(t,e,n){var i,o,r;null==n&&(n={}),i=document.createEvent("Event"),i.initEvent(e,!0,!0);for(o in n)r=n[o],i[o]=r;return t.dispatchEvent(i)},l=function(t,e){var n,i,o,r;r=[];for(i in e)o=e[i],r.push(function(){var e,r,s,a;for(s=i.split(/\s+/),a=[],e=0,r=s.length;e - super(baseUrl, baseParams) - - -module.exports = {FlowAPI: FlowAPI} \ No newline at end of file diff --git a/coffee/src/scripts/content.coffee b/coffee/src/scripts/content.coffee deleted file mode 100644 index 5be1bf5..0000000 --- a/coffee/src/scripts/content.coffee +++ /dev/null @@ -1,156 +0,0 @@ -$ = require 'manhattan-essentials' -ContentTools = require 'ContentTools' -ContentFlow = require 'content-flow' -FlowAPI = require('./api.coffee').FlowAPI -ImageUploader = require('./image-uploader.coffee').ImageUploader - - -class SaveSemaphore - # Simple semaphore to manage the busy state of the editor when saving - # changes. - - @_saving = 0 - - @dec: () -> - # Decrement the semaphore count - @_saving = Math.max(0, @_saving - 1) - - @inc: () -> - # Increment the semaphore count - @_saving += 1 - - @saving: () -> - # Return true if the editor is still saving - return @_saving > 0 - - -addSaveProcess = (url, params, buildContentsFunc) -> - # Set up a save process based on the content built using the given - # function. - editor = ContentTools.EditorApp.get() - - editor.addEventListener 'saved', (ev) -> - - # If nothing has changed exit early - regions = ev.detail().regions - unless Object.keys(regions).length > 0 - return - - # Build the contents object we'll be saving - contents = buildContentsFunc(regions) - - # If we have no content changes to save exit early - unless Object.keys(contents).length > 0 - return - - # Mark the editor as busy while we save the page - SaveSemaphore.inc() - editor.busy(true) - - # Create a save request - xhr = new XMLHttpRequest() - xhr.open('POST', url) - - # Add the form data for the save request - formData = new FormData() - for k, v of (params or {}) - formData.append(k, v) - formData.append('contents', JSON.stringify(contents)) - xhr.send(formData) - - # Handle the save request response - xhr.addEventListener 'load', (ev) -> - - # Check if were still saving changes and if not mark the editor as - # no longer busy. - SaveSemaphore.dec() - unless SaveSemaphore.saving() - editor.busy(false) - - # Handle the result of the save request - if parseInt(ev.target.status) is 200 - new ContentTools.FlashUI('ok') - else - new ContentTools.FlashUI('no') - - -init = (baseURL='/', baseFlowURL='/', baseParams={}) -> - - # Set-up the editor and flow manager - editor = ContentTools.EditorApp.get() - flowMgr = ContentFlow.FlowMgr.get() - - # Use minimal whitespace in the HTML output as it's easier to deal with - ContentEdit.INDENT = '' - ContentEdit.LINE_ENDINGS = '' - - # Restrict special attributes - ContentTools.RESTRICTED_ATTRIBUTES['*'].push('data-ce-tag') - ContentTools.RESTRICTED_ATTRIBUTES['*'].push('data-fixture') - ContentTools.RESTRICTED_ATTRIBUTES['*'].push('data-transforms') - ContentTools.RESTRICTED_ATTRIBUTES['*'].push('data-mh-asset-key') - ContentTools.RESTRICTED_ATTRIBUTES['*'].push('data-name') - - # Assign an image uploader for the editor - ContentTools.IMAGE_UPLOADER = (dialog) -> - return new ImageUploader(dialog, baseParams) - - # Initialize the editor - editor.init( - '[data-allow-edits] [data-editable], [data-allow-edits] [data-fixture]', - 'data-name' - ) - - # Initialize the content flow manager - api = new FlowAPI(baseFlowURL, baseParams) - flowMgr.init('[data-cf-flow]', api) - - # Setup save processes for flows and global content - - # Flows - updateFlowsURL = baseFlowURL + 'update-flow-contents' - addSaveProcess updateFlowsURL, baseParams, (regions) -> - contents = {} - - for k, v of regions - # Check the region belongs to a snippet - unless k.startsWith('snippet:') - continue - - # Extract the snippet Id and region name - [_, snippetId, region_name] = k.split(':') - - # Add the region's content to the snippet - unless contents[snippetId] - contents[snippetId] = {} - contents[snippetId][region_name] = v - - return contents - - # Global - updateGlobalURL = baseURL + 'update-global-contents' - addSaveProcess updateGlobalURL, baseParams, (regions) -> - contents = {} - - for k, v of regions - # Check the region is global - unless k.startsWith('global:') - continue - - # Extract the region name - [_, region_name] = k.split(':') - contents[region_name] = v - - return contents - - -module.exports = { - # Standard init - init: init, - - # Provide access to other standard set up classes/functions - addSaveProcess: addSaveProcess, - FlowAPI: FlowAPI, - ImageUploader: ImageUploader, - SaveSemaphore: SaveSemaphore - } \ No newline at end of file diff --git a/coffee/src/scripts/image-uploader.coffee b/coffee/src/scripts/image-uploader.coffee deleted file mode 100644 index 0ce276c..0000000 --- a/coffee/src/scripts/image-uploader.coffee +++ /dev/null @@ -1,264 +0,0 @@ -ContentTools = require 'ContentTools' - - -class ImageUploader - # An image uploader class for manhattan - - constructor: (dialog, baseParams={}) -> - # A reference to the UI dialog being used to upload an image - @dialog = dialog - - # A table of params to include when uploading or transforming images - @baseParams = baseParams - - # Check if the image upload is for an image fixture and if so extract - # any transform stack. - @postTransforms = [] - @element = ContentEdit.Root.get().focused() - if @element.type() is 'ImageFixture' - @postTransforms = JSON.parse( - @element.domElement().getAttribute('data-transforms') or '[]' - ) - - # Listen to and map events from the dialog to handlers - dialog.addEventListener 'imageuploader.cancelupload', () => - @onCancelUpload() - - dialog.addEventListener 'imageuploader.clear', () => - @onClear() - - dialog.addEventListener 'imageuploader.clear', () => - @onClear() - - dialog.addEventListener 'imageuploader.fileready', (ev) => - if ev.detail().file - @onFileReady(ev.detail().file) - - dialog.addEventListener 'imageuploader.rotateccw', (ev) => - @onRotate(-90) - - dialog.addEventListener 'imageuploader.rotatecw', (ev) => - @onRotate(90) - - dialog.addEventListener 'imageuploader.save', () => - @onSave() - - # Methods - - getTransformURL: () -> - # Return the transform URL - return '/manage/transform-asset' - - getUploadURL: () -> - # Return the upload URL - return '/manage/upload-asset' - - transform: (transforms, callback) -> - # Transform the image - - # Build the form data to transform the image - formData = new FormData() - for k, v of @baseParams - formData.append(k, v) - formData.append('key', @image.key) - formData.append('transforms', JSON.stringify(transforms)) - - # Build a request to send the file - xhr = new XMLHttpRequest() - xhr.open('POST', @getTransformURL(), true) - - xhr.addEventListener 'load', (ev) => - if parseInt(ev.target.status) is 200 - # Handle successful upload - - # Unpack the repsonse - response = JSON.parse(ev.target.responseText) - - # Trigger the callback - callback(response.payload.asset) - - else - # Handle failed upload - new ContentTools.FlashUI('no') - - # Clear the XHR - @xhr = null - - # Transform the image - xhr.send(formData) - - # Dialog event handlers - - onCancelUpload: () -> - # Handle a request to cancel an upload - - # Stop any current upload - if @xhr - @xhr.upload.removeEventListener('progress', @xhrProgress) - @xhr.upload.removeEventListener('load', @xhrComplete) - @xhr.abort() - - # Set the dialog to empty - @dialog.state('empty') - - onClear: () -> - # Handle a request to clear the image - @dialog.clear() - @image = null - - onFileReady: (file) -> - # Handle a request to upload a file - - # Set the dialog state to uploading - @dialog.progress(0) - @dialog.state('uploading') - - # Build the form data to upload the image - formData = new FormData() - for k, v of @baseParams - formData.append(k, v) - formData.append('file', file) - - # Build a request to send the file - @xhr = new XMLHttpRequest() - @xhr.open('POST', @getUploadURL(), true) - - # Add handlers for progress and load - - @xhrProgress = (ev) => - # Update the progress bar - @dialog.progress((ev.loaded / ev.total) * 100) - - @xhr.upload.addEventListener('progress', @xhrProgress) - - @xhrComplete = (ev) => - if parseInt(ev.target.status) is 200 - # Handle successful upload - - # Unpack the repsonse - response = JSON.parse(ev.target.responseText) - asset = response.payload.asset - - # Make sure an image was uploaded - if asset['type'] - - # Build the image from the resposne - @image = { - angle: 0, - height: asset['core_meta']['image']['size'][1], - key: asset['key'], - maxWidth: asset['core_meta']['image']['size'][0], - url: asset['variations']['--draft--']['url'], - width: asset['core_meta']['image']['size'][0] - } - - # Update the dialog to display the new image - @dialog.populate(@image.url, [@image.width, @image.height]) - - else - # Handle upload of non-image - new ContentTools.FlashUI('no') - - else - # Handle failed upload - new ContentTools.FlashUI('no') - - # Clear the XHR - @xhr = null - - @xhr.addEventListener('load', @xhrComplete) - - # Upload the file - @xhr.send(formData) - - onRotate: (angle) -> - # Handle a request to rotate the image - - # Update the angle of the image - @image.angle += angle - - # Stay within 360 degress - if @image.angle < 0 - @image.angle += 360 - else if @image.angle > 270 - @image.angle -= 360 - - # Build the transform - transforms = [ - {'id': 'image.rotate', 'settings': {'angle': @image.angle}} - ] - - # Perfom the transform - @transform transforms, (asset) => - # Update the image from the resposne - @image.url = asset['variations']['--draft--']['url'] - - # Flip the image width/height based on the angle - if @image.angle is 90 or @image.angle = 270 - @image.height = asset['core_meta']['image']['size'][0] - @image.maxWidth = asset['core_meta']['image']['size'][1] - @image.width = width = asset['core_meta']['image']['size'][1] - else - @image.height = asset['core_meta']['image']['size'][1] - @image.maxWidth = asset['core_meta']['image']['size'][0] - @image.width = width = asset['core_meta']['image']['size'][0] - - # Update the dialog to display the new image - @dialog.populate(@image.url, [@image.width, @image.height]) - - onSave: () -> - # Handle a request to save the image - - # Build the transforms for the final image - transforms = [] - - # Angle - unless @image.angle is 0 - transforms.push({ - 'id': 'image.rotate', - 'settings': {'angle': @image.angle} - }) - - # Crop - region = @dialog.cropRegion() - maxWidth = @image.maxWidth - unless region.toString() is [0, 0, 1, 1].toString() - transforms.push({ - 'id': 'image.crop', - 'settings': { - 'top': Math.max(0, region[0]), - 'left': Math.max(0, region[1]), - 'bottom': Math.min(1, region[2]), - 'right': Math.min(1, region[3]) - } - }) - maxWidth = parseInt(maxWidth * (region[3] - region[1])) - - # Apply any post transforms - transforms = transforms.concat(@postTransforms) - - # Perform the transform - @transform transforms, (asset) => - # Insert the image into the page - draft = asset['variations']['--draft--'] - @dialog.save( - draft['url'], - [ - draft['core_meta']['image']['size'][0], - draft['core_meta']['image']['size'][1] - ], - { - 'alt': '', - 'data-ce-max-width': maxWidth, - 'data-mh-asset-key': asset['key'] - } - ) - - # For image fixtures the attributes must be set independently - if @element.type() is 'ImageFixture' - @element.attr('data-mh-asset-key', asset['key']) - unless @element.attr('alt') - @element.attr('alt', '') - - -module.exports = {ImageUploader: ImageUploader} \ No newline at end of file diff --git a/coffee/webpack.config.js b/coffee/webpack.config.js deleted file mode 100644 index 45994a0..0000000 --- a/coffee/webpack.config.js +++ /dev/null @@ -1,85 +0,0 @@ -// Imports -const path = require('path') -const webpack = require('webpack') - -// Plugin config -const plugins = [ - - new webpack.DefinePlugin({ - 'process.env': { - - // The `NODE_ENV` flag indicates which environment web pack is compiling - // in/for (defaults to the local environment). - 'NODE_ENV': JSON.stringify(process.env.NODE_ENV || 'dev') - - } - }) - -]; - -// Environment specific config -switch (process.env.NODE_ENV) { - - case 'dist': - var uglifyPlugin = new webpack.optimize.UglifyJsPlugin({ - beautify: false, - comments: false, - compress: { - drop_console: true, - warnings: false - }, - mangle: { - except: ['webpackJsonp'], - screw_ie8 : true, - keep_fnames: true - } - }) - - plugins.push(uglifyPlugin); - break; - - default: - break; - -} - -// Project config -module.exports = { - plugins: plugins, - - entry: [ - path.resolve(__dirname, 'src/scripts', 'content.coffee') - ], - - output: { - library: 'ManhattanContent', - libraryTarget: 'umd', - path: path.join(__dirname, 'dist'), - filename: 'index.js' - }, - - module: { - rules: [ - - // CoffeeScript (to JavaScript) - { - test: /\.coffee$/, - loaders: ['coffee-loader'] - }, - - // CoffeeScript (lint) - { - test: /\.coffee$/, - exclude: /node_modules/, - loader: 'coffeelint-loader' - } - ] - }, - - // Dev server - devServer: { - contentBase: path.resolve(__dirname, 'dist'), - inline: true, - port: 5999 - } -}; diff --git a/module/index.js b/module/index.js index 8485546..d335c43 100644 --- a/module/index.js +++ b/module/index.js @@ -103,6 +103,7 @@ export function init(baseURL='/', baseFlowURL='/', baseParams={}) { ContentTools.RESTRICTED_ATTRIBUTES['*'].push('data-mh-local-transforms') ContentTools.RESTRICTED_ATTRIBUTES['*'].push('data-mh-proxy') ContentTools.RESTRICTED_ATTRIBUTES['*'].push('data-transforms') + ContentTools.RESTRICTED_ATTRIBUTES['*'].push('data-mh-transform-proxied') ContentTools.RESTRICTED_ATTRIBUTES['*'].push('data-name') // Apply common modifications