2?r(t,17,o(arguments,2),null,e):r(t,1,null,null,e)}var r=t("../internals/createWrapper"),o=t("../internals/slice");e.exports=i},{"../internals/createWrapper":71,"../internals/slice":82}],62:[function(t,e,n){function i(t,e,n){var i=typeof t;if(null==t||"function"==i)return r(t,e,n);if("object"!=i)return l(t);var u=s(t),c=u[0],h=t[c];return 1!=u.length||h!==h||a(h)?function(e){for(var n=u.length,i=!1;n--&&(i=o(e[u[n]],t[u[n]],null,!0)););return i}:function(t){var e=t[c];return h===e&&(0!==h||1/h==1/e)}}var r=t("../internals/baseCreateCallback"),o=t("../internals/baseIsEqual"),a=t("../objects/isObject"),s=t("../objects/keys"),l=t("../utilities/property");e.exports=i},{"../internals/baseCreateCallback":66,"../internals/baseIsEqual":70,"../objects/isObject":90,"../objects/keys":92,"../utilities/property":98}],63:[function(t,e,n){var i=[];e.exports=i},{}],64:[function(t,e,n){function i(t){function e(){if(i){var t=s(i);u.apply(t,arguments)}if(this instanceof e){var a=r(n.prototype),c=n.apply(a,t||arguments);return o(c)?c:a}return n.apply(l,t||arguments)}var n=t[0],i=t[2],l=t[4];return a(e,t),e}var r=t("./baseCreate"),o=t("../objects/isObject"),a=t("./setBindData"),s=t("./slice"),l=[],u=l.push;e.exports=i},{"../objects/isObject":90,"./baseCreate":65,"./setBindData":80,"./slice":82}],65:[function(t,e,n){function i(t,e){return o(t)?a(t):{}}var r=t("./isNative"),o=t("../objects/isObject"),a=(t("../utilities/noop"),r(a=Object.create)&&a);a||(i=function(){function t(){}return function(e){if(o(e)){t.prototype=e;var n=new t;t.prototype=null}return n||window.Object()}}()),e.exports=i},{"../objects/isObject":90,"../utilities/noop":97,"./isNative":75}],66:[function(t,e,n){function i(t,e,n){if("function"!=typeof t)return o;if("undefined"==typeof e||!("prototype"in t))return t;var i=t.__bindData__;if("undefined"==typeof i&&(s.funcNames&&(i=!t.name),i=i||!s.funcDecomp,!i)){var h=c.call(t);s.funcNames||(i=!l.test(h)),i||(i=u.test(h),a(t,i))}if(i===!1||i!==!0&&1&i[1])return t;switch(n){case 1:return function(n){return t.call(e,n)};case 2:return function(n,i){return t.call(e,n,i)};case 3:return function(n,i,r){return t.call(e,n,i,r)};case 4:return function(n,i,r,o){return t.call(e,n,i,r,o)}}return r(t,e)}var r=t("../functions/bind"),o=t("../utilities/identity"),a=t("./setBindData"),s=t("../support"),l=/^\s*function[ \n\r\t]+\w/,u=/\bthis\b/,c=Function.prototype.toString;e.exports=i},{"../functions/bind":61,"../support":94,"../utilities/identity":96,"./setBindData":80}],67:[function(t,e,n){function i(t){function e(){var t=f?d:this;if(c){var a=s(c);u.apply(a,arguments)}if((h||g)&&(a||(a=s(arguments)),h&&u.apply(a,h),g&&a.length-1:void 0});return w.pop(),x.pop(),N&&(l(w),l(x)),_}var r=t("../objects/forIn"),o=t("./getArray"),a=t("../objects/isFunction"),s=t("./objectTypes"),l=t("./releaseArray"),u="[object Arguments]",c="[object Array]",h="[object Boolean]",d="[object Date]",p="[object Number]",f="[object Object]",m="[object RegExp]",g="[object String]",v=Object.prototype,y=v.toString,b=v.hasOwnProperty;e.exports=i},{"../objects/forIn":85,"../objects/isFunction":89,"./getArray":73,"./objectTypes":77,"./releaseArray":79}],71:[function(t,e,n){function i(t,e,n,l,h,d){var p=1&e,f=2&e,m=4&e,g=16&e,v=32&e;if(!f&&!a(t))throw new TypeError;g&&!n.length&&(e&=-17,g=n=!1),v&&!l.length&&(e&=-33,v=l=!1);var y=t&&t.__bindData__;if(y&&y!==!0)return y=s(y),y[2]&&(y[2]=s(y[2])),y[3]&&(y[3]=s(y[3])),!p||1&y[1]||(y[4]=h),!p&&1&y[1]&&(e|=8),!m||4&y[1]||(y[5]=d),g&&u.apply(y[2]||(y[2]=[]),n),v&&c.apply(y[3]||(y[3]=[]),l),y[1]|=e,i.apply(null,y);var b=1==e||17===e?r:o;return b([t,e,n,l,h,d])}var r=t("./baseBind"),o=t("./baseCreateWrapper"),a=t("../objects/isFunction"),s=t("./slice"),l=[],u=l.push,c=l.unshift;e.exports=i},{"../objects/isFunction":89,"./baseBind":64,"./baseCreateWrapper":67,"./slice":82}],72:[function(t,e,n){function i(t){return r[t]}var r=t("./htmlEscapes");e.exports=i},{"./htmlEscapes":74}],73:[function(t,e,n){function i(){return r.pop()||[]}var r=t("./arrayPool");e.exports=i},{"./arrayPool":63}],74:[function(t,e,n){var i={"&":"&","<":"<",">":">",'"':""","'":"'"};e.exports=i},{}],75:[function(t,e,n){function i(t){return"function"==typeof t&&a.test(t)}var r=Object.prototype,o=r.toString,a=RegExp("^"+String(o).replace(/[.*+?^${}()|[\]\\]/g,"\\$&").replace(/toString| for [^\]]+/g,".*?")+"$");e.exports=i},{}],76:[function(t,e,n){var i=40;e.exports=i},{}],77:[function(t,e,n){var i={"boolean":!1,"function":!0,object:!0,number:!1,string:!1,undefined:!1};e.exports=i},{}],78:[function(t,e,n){var i=t("./htmlEscapes"),r=t("../objects/keys"),o=RegExp("["+r(i).join("")+"]","g");e.exports=o},{"../objects/keys":92,"./htmlEscapes":74}],79:[function(t,e,n){function i(t){t.length=0,r.lengthr?0:r);++i3&&"function"==typeof u[h-2])var d=i(u[--h-1],u[h--],2);else h>2&&"function"==typeof u[h-1]&&(d=u[--h]);for(;++c=0,r=this.range.compareBoundaryPoints(Range.END_TO_END,n)<=0;if(i&&r){var o=document.createElement("em");o.classList.add("scribe-marker");var a=document.createElement("em");a.classList.add("scribe-marker");var s=this.range.cloneRange();if(s.collapse(!1),s.insertNode(a),a.nextSibling&&a.nextSibling.nodeType===Node.TEXT_NODE&&""===a.nextSibling.data&&a.parentNode.removeChild(a.nextSibling),a.previousSibling&&a.previousSibling.nodeType===Node.TEXT_NODE&&""===a.previousSibling.data&&a.parentNode.removeChild(a.previousSibling),!this.range.collapsed){var l=this.range.cloneRange();l.collapse(!0),l.insertNode(o),o.nextSibling&&o.nextSibling.nodeType===Node.TEXT_NODE&&""===o.nextSibling.data&&o.parentNode.removeChild(o.nextSibling),o.previousSibling&&o.previousSibling.nodeType===Node.TEXT_NODE&&""===o.previousSibling.data&&o.parentNode.removeChild(o.previousSibling)}this.selection.removeAllRanges(),this.selection.addRange(this.range)}}},e.prototype.getMarkers=function(){return t.el.querySelectorAll("em.scribe-marker")},e.prototype.removeMarkers=function(){var t=this.getMarkers();Array.prototype.forEach.call(t,function(t){t.parentNode.removeChild(t)})},e.prototype.selectMarkers=function(t){var e=this.getMarkers();if(e.length){var n=document.createRange();n.setStartBefore(e[0]),e.length>=2?n.setEndAfter(e[1]):n.setEndAfter(e[0]),t||this.removeMarkers(),this.selection.removeAllRanges(),this.selection.addRange(n)}},e.prototype.isCaretOnNewLine=function(){function t(t){for(var e=document.createTreeWalker(t,NodeFilter.SHOW_ELEMENT,null,!1),n=e.root;n;){var i=n.childNodes.length;if(i>1||1===i&&""!==n.textContent.trim())return!1;if(0===i)return""===n.textContent.trim();n=e.nextNode()}}var e=this.getContaining(function(t){return"P"===t.nodeName});return e?t(e):!1},e}},{"../element":106}],104:[function(t,e,n){"use strict";e.exports=function(t,e){function n(t,n){e.api.Command.call(this,t),this._nodeName=n}return n.prototype=Object.create(t.Command.prototype),n.prototype.constructor=n,n.prototype.queryState=function(){var t=new e.api.Selection;return e.api.Command.prototype.queryState.call(this)&&!!t.getContaining(function(t){return t.nodeName===this._nodeName}.bind(this))},n}},{}],105:[function(t,e,n){function i(t,e){function n(t){var e=r(t.map(function(t){var e=o(t.addedNodes),n=o(t.removedNodes);return e.concat(n)})),n=e.filter(function(t){return!s.isEmptyTextNode(t)}).filter(function(t){return!a.isSelectionMarkerNode(t)});return n.length>0}var i=window.MutationObserver||window.WebKitMutationObserver||window.MozMutationObserver,l=!1,u=new i(function(t){if(!l&&n(t)){l=!0;try{e()}catch(i){throw i}finally{setTimeout(function(){l=!1},0)}}});return u.observe(t,{attributes:!0,childList:!0,subtree:!0}),u}var r=t("lodash-amd/modern/arrays/flatten"),o=t("lodash-amd/modern/collections/toArray"),a=t("./element"),s=t("./node");e.exports=i},{"./element":106,"./node":108,"lodash-amd/modern/arrays/flatten":55,"lodash-amd/modern/collections/toArray":60}],106:[function(t,e,n){function i(t){return s(l,t.nodeName)}function r(t){return t.nodeType===Node.ELEMENT_NODE&&"scribe-marker"===t.className}function o(t){return t.nodeType===Node.ELEMENT_NODE&&"caret-position"===t.className}function a(t,e){for(;e.childNodes.length>0;)t.insertBefore(e.childNodes[0],e);t.removeChild(e)}var s=t("lodash-amd/modern/collections/contains"),l=["ADDRESS","ARTICLE","ASIDE","AUDIO","BLOCKQUOTE","CANVAS","DD","DIV","FIELDSET","FIGCAPTION","FIGURE","FOOTER","FORM","H1","H2","H3","H4","H5","H6","HEADER","HGROUP","HR","LI","NOSCRIPT","OL","OUTPUT","P","PRE","SECTION","TABLE","TD","TH","TFOOT","UL","VIDEO"];e.exports={isBlockElement:i,isSelectionMarkerNode:r,isCaretPositionNode:o,unwrap:a}},{"lodash-amd/modern/collections/contains":58}],107:[function(t,e,n){function i(){this._listeners={}}var r=(t("lodash-amd/modern/arrays/pull"),t("immutable/dist/immutable"));i.prototype.on=function(t,e){var n=this._listeners[t]||r.Set();this._listeners[t]=n.add(e)},i.prototype.off=function(t,e){var n=this._listeners[t]||r.Set();n=e?n["delete"](e):n.clear()},i.prototype.trigger=function(t,e){for(var n=t.split(":");n.length;){var i=n.join(":"),o=this._listeners[i]||r.Set();o.forEach(function(t){t.apply(null,e)}),n.splice(n.length-1,1)}},e.exports=i},{"immutable/dist/immutable":54,"lodash-amd/modern/arrays/pull":57}],108:[function(t,e,n){"use strict";function i(t){return t.nodeType===Node.TEXT_NODE&&""===t.textContent}function r(t,e){return e.parentNode.insertBefore(t,e.nextSibling)}function o(t){return t.parentNode.removeChild(t)}e.exports={isEmptyTextNode:i,insertAfter:r,removeNode:o}},{}],109:[function(t,e,n){var i=t("./commands/indent"),r=t("./commands/insert-list"),o=t("./commands/outdent"),a=t("./commands/redo"),s=t("./commands/subscript"),l=t("./commands/superscript"),u=t("./commands/undo");e.exports={indent:i,insertList:r,outdent:o,redo:a,subscript:s,superscript:l,undo:u}},{"./commands/indent":110,"./commands/insert-list":111,"./commands/outdent":112,"./commands/redo":113,"./commands/subscript":114,"./commands/superscript":115,"./commands/undo":116}],110:[function(t,e,n){"use strict";e.exports=function(){return function(t){var e=new t.api.Command("indent");e.queryEnabled=function(){var e=new t.api.Selection,n=e.getContaining(function(t){return"UL"===t.nodeName||"OL"===t.nodeName});return t.api.Command.prototype.queryEnabled.call(this)&&t.allowsBlockElements()&&!n},t.commands.indent=e}}},{}],111:[function(t,e,n){"use strict";e.exports=function(){return function(t){var e=function(e){t.api.Command.call(this,e)};e.prototype=Object.create(t.api.Command.prototype),e.prototype.constructor=e,e.prototype.execute=function(e){function n(t){if(t.length>0){var e=document.createElement(o.nodeName);t.forEach(function(t){e.appendChild(t)}),o.parentNode.insertBefore(e,o.nextElementSibling)}}if(this.queryState()){var i=new t.api.Selection,r=i.range,o=i.getContaining(function(t){return"OL"===t.nodeName||"UL"===t.nodeName}),a=i.getContaining(function(t){return"LI"===t.nodeName});t.transactionManager.run(function(){if(a){var e=new t.api.Node(a).nextAll();n(e),i.placeMarkers();var s=document.createElement("p");s.innerHTML=a.innerHTML,o.parentNode.insertBefore(s,o.nextElementSibling),a.parentNode.removeChild(a)}else{var l=Array.prototype.map.call(o.querySelectorAll("li"),function(t){return r.intersectsNode(t)&&t}).filter(function(t){return t}),u=l.slice(-1)[0],c=new t.api.Node(u).nextAll();n(c),i.placeMarkers();var h=document.createDocumentFragment();l.forEach(function(t){var e=document.createElement("p");e.innerHTML=t.innerHTML,h.appendChild(e)}),o.parentNode.insertBefore(h,o.nextElementSibling),l.forEach(function(t){t.parentNode.removeChild(t)})}0===o.childNodes.length&&o.parentNode.removeChild(o),i.selectMarkers()}.bind(this))}else t.api.Command.prototype.execute.call(this,e)},e.prototype.queryEnabled=function(){return t.api.Command.prototype.queryEnabled.call(this)&&t.allowsBlockElements()},t.commands.insertOrderedList=new e("insertOrderedList"),t.commands.insertUnorderedList=new e("insertUnorderedList")}}},{}],112:[function(t,e,n){"use strict";e.exports=function(){return function(t){var e=new t.api.Command("outdent");e.queryEnabled=function(){var e=new t.api.Selection,n=e.getContaining(function(t){return"UL"===t.nodeName||"OL"===t.nodeName});return t.api.Command.prototype.queryEnabled.call(this)&&t.allowsBlockElements()&&!n},t.commands.outdent=e}}},{}],113:[function(t,e,n){"use strict";e.exports=function(){return function(t){var e=new t.api.Command("redo");e.execute=function(){var e=t.undoManager.redo();"undefined"!=typeof e&&t.restoreFromHistory(e)},e.queryEnabled=function(){return t.undoManager.position1},t.commands.undo=e,t.options.undo.enabled&&t.el.addEventListener("keydown",function(t){t.shiftKey||!t.metaKey&&!t.ctrlKey||90!==t.keyCode||(t.preventDefault(),e.execute())})}}},{}],117:[function(t,e,n){var i=t("lodash-amd/modern/collections/contains"),r=t("../../dom-observer");e.exports=function(){return function(t){var e=function(){setTimeout(function(){t.pushHistory()}.bind(t),0),t.el.removeEventListener("focus",e)}.bind(t);t.el.addEventListener("focus",e),t.el.addEventListener("focus",function(){function e(t){var n=document.createTreeWalker(t,NodeFilter.SHOW_ALL,null,!1),i=n.currentNode;return n.firstChild()?"BR"===n.currentNode.nodeName?i:e(n.currentNode):n.currentNode}var n=new t.api.Selection;if(n.range){var i=t.allowsBlockElements()&&n.range.startContainer===t.el;if(i){var r=e(t.el.firstChild),o=n.range;o.setStart(r,0),o.setEnd(r,0),n.selection.removeAllRanges(),n.selection.addRange(o)}}}.bind(t));var n=function(){if(!t._skipFormatters){var e=new t.api.Selection,n=e.range,i=function(){n&&e.placeMarkers(),t.setHTML(t._htmlFormatterFactory.format(t.getHTML())),e.selectMarkers()}.bind(t);n?(t.undoManager&&t.undoManager.undo(),t.transactionManager.run(i)):i()}delete t._skipFormatters}.bind(t);r(t.el,n),t.allowsBlockElements()&&t.el.addEventListener("keydown",function(e){if(13===e.keyCode){var n=new t.api.Selection,i=n.range,r=n.getContaining(function(t){return/^(H[1-6])$/.test(t.nodeName)});if(r&&i.collapsed){var o=i.cloneRange();o.setEndAfter(r,0);var a=o.cloneContents();""===a.firstChild.textContent&&(e.preventDefault(),t.transactionManager.run(function(){var t=document.createElement("p"),e=document.createElement("br");t.appendChild(e),r.parentNode.insertBefore(t,r.nextElementSibling),i.setStart(t,0),i.setEnd(t,0),n.selection.removeAllRanges(),n.selection.addRange(i)}))}}}),t.allowsBlockElements()&&t.el.addEventListener("keydown",function(e){if(13===e.keyCode||8===e.keyCode){var n=new t.api.Selection,i=n.range;if(i.collapsed){var r=n.getContaining(function(t){return"LI"===t.nodeName});if(r&&""===r.textContent.trim()){e.preventDefault();var o=n.getContaining(function(t){return"UL"===t.nodeName||"OL"===t.nodeName}),a=t.getCommand("OL"===o.nodeName?"insertOrderedList":"insertUnorderedList");a.execute()}}}}),t.el.addEventListener("paste",function(e){if(e.clipboardData)e.preventDefault(),i(e.clipboardData.types,"text/html")?t.insertHTML(e.clipboardData.getData("text/html")):t.insertPlainText(e.clipboardData.getData("text/plain"));else{var n=new t.api.Selection;n.placeMarkers();var r=document.createElement("div");document.body.appendChild(r),r.setAttribute("contenteditable",!0),r.focus(),setTimeout(function(){var e=r.innerHTML;r.parentNode.removeChild(r),n.selectMarkers(),t.el.focus(),t.insertHTML(e)},1)}})}}},{"../../dom-observer":105,"lodash-amd/modern/collections/contains":58}],118:[function(t,e,n){function i(t,e){var n=Array.prototype.reduce.call(e.childNodes,function(e,n){function i(){var t=[n];e.push(t)}var r=o(e);if(r){var a=t.element.isBlockElement(r[0]);a===t.element.isBlockElement(n)?r.push(n):i()}else i();return e},[]),i=n.filter(function(e){var n=t.element.isBlockElement(e[0]);return!n});i.forEach(function(t){var e=document.createElement("p");t[0].parentNode.insertBefore(e,t[0]),t.forEach(function(t){e.appendChild(t)})}),e._isWrapped=!0}function r(t,e){for(var n=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,null,!1),o=n.firstChild();o;){if("BLOCKQUOTE"===o.nodeName&&!o._isWrapped){i(t,o),r(t,e);break}o=n.nextSibling()}}var o=t("lodash-amd/modern/arrays/last");e.exports=function(){return function(t){t.registerHTMLFormatter("normalize",function(e){var n=document.createElement("div");return n.innerHTML=e,i(t,n),r(t,n),n.innerHTML})}}},{"lodash-amd/modern/arrays/last":56}],119:[function(t,e,n){function i(t,e){return t.isCaretPositionNode(e)?!0:""===e.parentNode.textContent.trim()}function r(t,e){function n(e){return 0===e.children.length&&t.isBlockElement(e)||1===e.children.length&&t.isSelectionMarkerNode(e.children[0])?!0:t.isBlockElement(e)||0!==e.children.length?!1:i(t,e)}for(var s=e.firstElementChild;s;)t.isSelectionMarkerNode(s)||(n(s)&&""===s.textContent.trim()&&!o(a,s.nodeName)?s.appendChild(document.createElement("br")):s.children.length>0&&r(t,s)),s=s.nextElementSibling}var o=(t("../../../../element"),t("lodash-amd/modern/collections/contains")),a=["AREA","BASE","BR","COL","COMMAND","EMBED","HR","IMG","INPUT","KEYGEN","LINK","META","PARAM","SOURCE","TRACK","WBR"];e.exports=function(){return function(t){t.registerHTMLFormatter("normalize",function(e){var n=document.createElement("div");return n.innerHTML=e,r(t.element,n),n.innerHTML})}}},{"../../../../element":106,"lodash-amd/modern/collections/contains":58}],120:[function(t,e,n){"use strict";e.exports=function(){return function(t){var e=/(\s| )+/g;t.registerHTMLFormatter("export",function(t){return t.replace(e," ")})}}},{}],121:[function(t,e,n){var i=t("lodash-amd/modern/utilities/escape");e.exports=function(){return function(t){t.registerPlainTextFormatter(i)}}},{"lodash-amd/modern/utilities/escape":95}],122:[function(t,e,n){"use strict";function i(t){for(var e=document.createTreeWalker(t,NodeFilter.SHOW_ALL,null,!1);e.nextNode();)if(e.currentNode&&(~["br"].indexOf(e.currentNode.nodeName.toLowerCase())||e.currentNode.length>0))return!0;return!1}e.exports=function(){return function(t){t.el.addEventListener("keydown",function(e){if(13===e.keyCode){var n=new t.api.Selection,r=n.range,o=n.getContaining(function(t){return"LI"===t.nodeName||/^(H[1-6])$/.test(t.nodeName)});o||(e.preventDefault(),t.transactionManager.run(function(){"BR"===t.el.lastChild.nodeName&&t.el.removeChild(t.el.lastChild);var e=document.createElement("br");r.insertNode(e),r.collapse(!1);var o=r.cloneRange();o.setEndAfter(t.el.lastChild,0);var a=o.cloneContents();if(!i(a)){var s=document.createElement("br");r.insertNode(s)}var l=r.cloneRange();l.setStartAfter(e,0),l.setEndAfter(e,0),n.selection.removeAllRanges(),n.selection.addRange(l)}))}}.bind(this)),""===t.getHTML().trim()&&t.setContent("")}}},{}],123:[function(t,e,n){var i=t("./patches/commands/bold"),r=t("./patches/commands/indent"),o=t("./patches/commands/insert-html"),a=t("./patches/commands/insert-list"),s=t("./patches/commands/outdent"),l=t("./patches/commands/create-link"),u=t("./patches/events");e.exports={commands:{bold:i,indent:r,insertHTML:o,insertList:a,outdent:s,createLink:l},events:u}},{"./patches/commands/bold":124,"./patches/commands/create-link":125,"./patches/commands/indent":126,"./patches/commands/insert-html":127,"./patches/commands/insert-list":128,"./patches/commands/outdent":129,"./patches/events":130}],124:[function(t,e,n){"use strict";e.exports=function(){return function(t){var e=new t.api.CommandPatch("bold");e.queryEnabled=function(){var e=new t.api.Selection,n=e.getContaining(function(t){return/^(H[1-6])$/.test(t.nodeName)});return t.api.CommandPatch.prototype.queryEnabled.apply(this,arguments)&&!n},t.commandPatches.bold=e}}},{}],125:[function(t,e,n){"use strict";e.exports=function(){return function(t){var e=new t.api.CommandPatch("createLink");t.commandPatches.createLink=e,e.execute=function(e){var n=new t.api.Selection;if(n.range.collapsed){var i=document.createElement("a");i.setAttribute("href",e),i.textContent=e,n.range.insertNode(i);var r=document.createRange();r.setStartBefore(i),r.setEndAfter(i),n.selection.removeAllRanges(),n.selection.addRange(r)}else t.api.CommandPatch.prototype.execute.call(this,e)}}}},{}],126:[function(t,e,n){"use strict";var i="\ufeff";e.exports=function(){return function(t){var e=new t.api.CommandPatch("indent");e.execute=function(e){t.transactionManager.run(function(){var n=new t.api.Selection,r=n.range,o="P"===r.commonAncestorContainer.nodeName&&" "===r.commonAncestorContainer.innerHTML;if(o){var a=document.createTextNode(i);r.insertNode(a),r.setStart(a,0),r.setEnd(a,0),n.selection.removeAllRanges(),n.selection.addRange(r)}t.api.CommandPatch.prototype.execute.call(this,e),n=new t.api.Selection;var s=n.getContaining(function(t){return"BLOCKQUOTE"===t.nodeName});s&&s.removeAttribute("style")}.bind(this))},t.commandPatches.indent=e}}},{}],127:[function(t,e,n){"use strict";e.exports=function(){return function(t){var e=new t.api.CommandPatch("insertHTML"),n=t.element;e.execute=function(e){t.transactionManager.run(function(){function i(t){var e=document.createTreeWalker(t,NodeFilter.SHOW_ELEMENT,null,!1),r=e.firstChild();if(r)do"SPAN"===r.nodeName?n.unwrap(t,r):(r.style.lineHeight=null,""===r.getAttribute("style")&&r.removeAttribute("style")),i(r);while(r=e.nextSibling())}t.api.CommandPatch.prototype.execute.call(this,e),i(t.el)}.bind(this))},t.commandPatches.insertHTML=e}}},{}],128:[function(t,e,n){"use strict";e.exports=function(){return function(t){var e=t.element,n=t.node,i=function(e){t.api.CommandPatch.call(this,e)};i.prototype=Object.create(t.api.CommandPatch.prototype),i.prototype.constructor=i,i.prototype.execute=function(i){t.transactionManager.run(function(){if(t.api.CommandPatch.prototype.execute.call(this,i),this.queryState()){var r=new t.api.Selection,o=r.getContaining(function(t){return"OL"===t.nodeName||"UL"===t.nodeName});if(o.nextElementSibling&&0===o.nextElementSibling.childNodes.length&&n.removeNode(o.nextElementSibling),o){var a=o.parentNode;a&&/^(H[1-6]|P)$/.test(a.nodeName)&&(r.placeMarkers(),n.insertAfter(o,a),r.selectMarkers(),2===a.childNodes.length&&n.isEmptyTextNode(a.firstChild)&&n.removeNode(a),0===a.childNodes.length&&n.removeNode(a))}var s=Array.prototype.slice.call(o.childNodes);s.forEach(function(t){var n=Array.prototype.slice.call(t.childNodes);n.forEach(function(n){if("SPAN"===n.nodeName){var i=n;e.unwrap(t,i)}else n.nodeType===Node.ELEMENT_NODE&&(n.style.lineHeight=null,""===n.getAttribute("style")&&n.removeAttribute("style"))})})}}.bind(this))},t.commandPatches.insertOrderedList=new i("insertOrderedList"),t.commandPatches.insertUnorderedList=new i("insertUnorderedList")}}},{}],129:[function(t,e,n){"use strict";e.exports=function(){return function(t){var e=new t.api.CommandPatch("outdent");e.execute=function(){t.transactionManager.run(function(){var e=new t.api.Selection,n=e.range,i=e.getContaining(function(t){return"BLOCKQUOTE"===t.nodeName});if("BLOCKQUOTE"===n.commonAncestorContainer.nodeName){e.placeMarkers(),e.selectMarkers(!0);var r=n.cloneContents();i.parentNode.insertBefore(r,i),n.deleteContents(),e.selectMarkers(),""===i.textContent&&i.parentNode.removeChild(i)}else{var o=e.getContaining(function(t){return"P"===t.nodeName});if(o){var a=new t.api.Node(o).nextAll();if(a.length){var s=document.createElement(i.nodeName);a.forEach(function(t){s.appendChild(t)}),i.parentNode.insertBefore(s,i.nextElementSibling)}e.placeMarkers(),i.parentNode.insertBefore(o,i.nextElementSibling),e.selectMarkers(),""===i.innerHTML&&i.parentNode.removeChild(i)}else t.api.CommandPatch.prototype.execute.call(this)}}.bind(this))},t.commandPatches.outdent=e}}},{}],130:[function(t,e,n){"use strict";e.exports=function(){return function(t){var e=t.element;t.allowsBlockElements()&&t.el.addEventListener("keyup",function(n){if(8===n.keyCode||46===n.keyCode){var i=new t.api.Selection,r=i.getContaining(function(t){return"P"===t.nodeName});r&&(t.undoManager&&t.undoManager.undo(),t.transactionManager.run(function(){i.placeMarkers();var t=Array.prototype.slice.call(r.childNodes);t.forEach(function(t){if("SPAN"===t.nodeName){var n=t;e.unwrap(r,n)}else t.nodeType===Node.ELEMENT_NODE&&(t.style.lineHeight=null,""===t.getAttribute("style")&&t.removeAttribute("style"))}),i.selectMarkers()}))}})}}},{}],131:[function(t,e,n){"use strict";e.exports=function(){return function(t){""===t.getHTML().trim()&&t.setContent("
")}}},{}],132:[function(t,e,n){function i(t,e){b.call(this),this.el=t,this.commands={},this.options=a(e||{},{allowBlockElements:!0,debug:!1,undo:{enabled:!0},defaultCommandPatches:["bold","indent","insertHTML","insertList","outdent","createLink"]}),this.commandPatches={},this._plainTextFormatterFactory=new r,this._htmlFormatterFactory=new o,this.api=new g(this),this.node=x,this.element=w,this.Immutable=_;var n=v(this);if(this.transactionManager=new n,this.undoManager=!1,this.options.undo.enabled){var i=y(this);this.undoManager=new i}this.el.setAttribute("contenteditable",!0),this.el.addEventListener("input",function(){this.transactionManager.run()}.bind(this),!1),this.allowsBlockElements()?(this.use(m()),this.use(c()),this.use(h())):this.use(p());var k=_.List.of(d,u),$=_.List.of(f.events),S=_.List(this.options.defaultCommandPatches).map(function(t){return f.commands[t]}),T=_.List.of("indent","insertList","outdent","redo","subscript","superscript","undo").map(function(t){return s[t]}),E=_.List().concat(k,$,S,T);E.forEach(function(t){this.use(t())}.bind(this)),this.use(l())}function r(){this.formatters=_.List()}function o(){this.formatters={sanitize:_.List(),normalize:_.List(),"export":_.List()}}var a=t("lodash-amd/modern/objects/defaults"),s=t("./plugins/core/commands"),l=t("./plugins/core/events"),u=t("./plugins/core/formatters/html/replace-nbsp-chars"),c=t("./plugins/core/formatters/html/enforce-p-elements"),h=t("./plugins/core/formatters/html/ensure-selectable-containers"),d=t("./plugins/core/formatters/plain-text/escape-html-characters"),p=t("./plugins/core/inline-elements-mode"),f=t("./plugins/core/patches"),m=t("./plugins/core/set-root-p-element"),g=t("./api"),v=t("./transaction-manager"),y=t("./undo-manager"),b=t("./event-emitter"),w=t("./element"),x=t("./node"),_=t("immutable/dist/immutable");i.prototype=Object.create(b.prototype),i.prototype.use=function(t){return t(this),this},i.prototype.setHTML=function(t,e){e&&(this._skipFormatters=!0),this.el.innerHTML!==t&&(this.el.innerHTML=t)},i.prototype.getHTML=function(){return this.el.innerHTML},i.prototype.getContent=function(){return this._htmlFormatterFactory.formatForExport(this.getHTML().replace(/ $/,""))},i.prototype.getTextContent=function(){return this.el.textContent},i.prototype.pushHistory=function(){if(this.options.undo.enabled){var t=this.undoManager.stack[this.undoManager.position],e=t&&t.replace(//g,"").replace(/<\/em>/g,"");if(!t||t&&this.getHTML()!==e){var n=new this.api.Selection;n.placeMarkers();var i=this.getHTML();return n.removeMarkers(),this.undoManager.push(i),!0}return!1}return!1},i.prototype.getCommand=function(t){return this.commands[t]||this.commandPatches[t]||new this.api.Command(t)},i.prototype.restoreFromHistory=function(t){this.setHTML(t,!0);var e=new this.api.Selection;e.selectMarkers(),this.trigger("content-changed")},i.prototype.allowsBlockElements=function(){return this.options.allowBlockElements},i.prototype.setContent=function(t){this.allowsBlockElements()||(t+=" "),this.setHTML(t),this.trigger("content-changed")},i.prototype.insertPlainText=function(t){this.insertHTML(""+this._plainTextFormatterFactory.format(t)+"
")},i.prototype.insertHTML=function(t){this.getCommand("insertHTML").execute(this._htmlFormatterFactory.format(t))},i.prototype.isDebugModeEnabled=function(){return this.options.debug},i.prototype.registerHTMLFormatter=function(t,e){this._htmlFormatterFactory.formatters[t]=this._htmlFormatterFactory.formatters[t].push(e)},i.prototype.registerPlainTextFormatter=function(t){this._plainTextFormatterFactory.formatters=this._plainTextFormatterFactory.formatters.push(t)},r.prototype.format=function(t){var e=this.formatters.reduce(function(t,e){return e(t)},t);return e},o.prototype=Object.create(r.prototype),o.prototype.constructor=o,o.prototype.format=function(t){var e=this.formatters.sanitize.concat(this.formatters.normalize),n=e.reduce(function(t,e){return e(t)},t);return n},o.prototype.formatForExport=function(t){return this.formatters["export"].reduce(function(t,e){return e(t)},t)},e.exports=i},{"./api":99,"./element":106,"./event-emitter":107,"./node":108,"./plugins/core/commands":109,"./plugins/core/events":117,"./plugins/core/formatters/html/enforce-p-elements":118,"./plugins/core/formatters/html/ensure-selectable-containers":119,"./plugins/core/formatters/html/replace-nbsp-chars":120,"./plugins/core/formatters/plain-text/escape-html-characters":121,"./plugins/core/inline-elements-mode":122,"./plugins/core/patches":123,"./plugins/core/set-root-p-element":131,"./transaction-manager":133,"./undo-manager":134,"immutable/dist/immutable":54,"lodash-amd/modern/objects/defaults":84}],133:[function(t,e,n){var i=t("lodash-amd/modern/objects/assign");e.exports=function(t){function e(){this.history=[]}return i(e.prototype,{start:function(){this.history.push(1)},end:function(){this.history.pop(),0===this.history.length&&(t.pushHistory(),t.trigger("content-changed"))},run:function(t){this.start();try{t&&t()}finally{this.end()}}}),e}},{"lodash-amd/modern/objects/assign":83}],134:[function(t,e,n){"use strict";e.exports=function(t){function e(){this.position=-1,this.stack=[],this.debug=t.isDebugModeEnabled()}return e.prototype.maxStackSize=100,e.prototype.push=function(t){for(this.debug&&console.log("UndoManager.push: %s",t),this.stack.length=++this.position,this.stack.push(t);this.stack.length>this.maxStackSize;)this.stack.shift(),--this.position},e.prototype.undo=function(){return this.position>0?this.stack[--this.position]:void 0},e.prototype.redo=function(){return this.position").replace(/\n/g," ")})}}},{}],136:[function(t,e,n){"use strict";e.exports=function(){return function(t){var e=new t.api.Command("createLink");e.nodeName="A",e.execute=function(){var e=new t.api.Selection,n=e.range,i=e.getContaining(function(t){return t.nodeName===this.nodeName}.bind(this)),r=i?i.href:"http://",o=window.prompt("Enter a link.",r);if(i&&(n.selectNode(i),e.selection.removeAllRanges(),e.selection.addRange(n)),o){var a=/^https?\:\/\//;if(!a.test(o))if(!/^mailto\:/.test(o)&&/@/.test(o)){
+var s=window.confirm("The URL you entered appears to be an email address. Do you want to add the required \u201cmailto:\u201d prefix?");s&&(o="mailto:"+o)}else{var l=window.confirm("The URL you entered appears to be a link. Do you want to add the required \u201chttp://\u201d prefix?");l&&(o="http://"+o)}t.api.SimpleCommand.prototype.execute.call(this,o)}},e.queryState=function(){var e=new t.api.Selection;return!!e.getContaining(function(t){return t.nodeName===this.nodeName}.bind(this))},t.commands.linkPrompt=e}}},{}],137:[function(e,n,i){/**
+ * Copyright (c) 2011-2014 Felix Gnass
+ * Licensed under the MIT license
+ */
+!function(e,r){"object"==typeof i?n.exports=r():"function"==typeof t&&t.amd?t(r):e.Spinner=r()}(this,function(){"use strict";function t(t,e){var n,i=document.createElement(t||"div");for(n in e)i[n]=e[n];return i}function e(t){for(var e=1,n=arguments.length;n>e;e++)t.appendChild(arguments[e]);return t}function n(t,e,n,i){var r=["opacity",e,~~(100*t),n,i].join("-"),o=.01+n/i*100,a=Math.max(1-(1-t)/e*(100-o),t),s=u.substring(0,u.indexOf("Animation")).toLowerCase(),l=s&&"-"+s+"-"||"";return h[r]||(d.insertRule("@"+l+"keyframes "+r+"{0%{opacity:"+a+"}"+o+"%{opacity:"+t+"}"+(o+.01)+"%{opacity:1}"+(o+e)%100+"%{opacity:"+t+"}100%{opacity:"+a+"}}",d.cssRules.length),h[r]=1),r}function i(t,e){var n,i,r=t.style;for(e=e.charAt(0).toUpperCase()+e.slice(1),i=0;i',n)}d.addRule(".spin-vml","behavior:url(#default#VML)"),s.prototype.lines=function(t,i){function o(){return r(n("group",{coordsize:c+" "+c,coordorigin:-u+" "+-u}),{width:c,height:c})}function s(t,s,l){e(d,e(r(o(),{rotation:360/i.lines*t+"deg",left:~~s}),e(r(n("roundrect",{arcsize:i.corners}),{width:u,height:i.width,left:i.radius,top:-i.width>>1,filter:l}),n("fill",{color:a(i.color,t),opacity:i.opacity}),n("stroke",{opacity:0}))))}var l,u=i.length+i.width,c=2*u,h=2*-(i.width+i.length)+"px",d=r(o(),{position:"absolute",top:h,left:h});if(i.shadow)for(l=1;l<=i.lines;l++)s(l,-2,"progid:DXImageTransform.Microsoft.Blur(pixelradius=2,makeshadow=1,shadowopacity=.3)");for(l=1;l<=i.lines;l++)s(l);return e(t,d)},s.prototype.opacity=function(t,e,n,i){var r=t.firstChild;i=i.shadow&&i.lines||0,r&&e+i>1)+"px"})}for(var l,c=0,h=(o.lines-1)*(1-o.direction)/2;c'+i.result(this.block_type,"icon_name")+""+i.result(this.block_type,"title")),this}}),e.exports=o},{"./blocks":156,"./events":166,"./function-bind":173,"./lodash":178,"./renderable":180}],139:[function(t,e,n){(function(n){"use strict";var i=t("./lodash"),r="undefined"!=typeof window?window.$:"undefined"!=typeof n?n.$:null,o=t("./blocks"),a=t("./block-control"),s=t("./event-bus"),l=function(t,e){this.available_types=t||[],this.mediator=e,this._ensureElement(),this._bindFunctions(),this._bindMediatedEvents(),this.initialize()};Object.assign(l.prototype,t("./function-bind"),t("./mediated-events"),t("./renderable"),t("./events"),{bound:["handleControlButtonClick"],block_controls:null,className:"st-block-controls",eventNamespace:"block-controls",mediatedEvents:{render:"renderInContainer",show:"show",hide:"hide"},initialize:function(){for(var t in this.available_types)if(o.hasOwnProperty(t)){var e=new a(t);e.can_be_rendered&&this.$el.append(e.render().$el)}this.$el.delegate(".st-block-control","click",this.handleControlButtonClick),this.mediator.on("block-controls:show",this.renderInContainer)},show:function(){this.$el.addClass("st-block-controls--active"),s.trigger("block:controls:shown")},hide:function(){this.removeCurrentContainer(),this.$el.removeClass("st-block-controls--active"),s.trigger("block:controls:hidden")},handleControlButtonClick:function(t){t.stopPropagation(),this.mediator.trigger("block:create",r(t.currentTarget).attr("data-type"))},renderInContainer:function(t){this.removeCurrentContainer(),t.append(this.$el.detach()),t.addClass("with-st-controls"),this.currentContainer=t,this.show()},removeCurrentContainer:function(){i.isUndefined(this.currentContainer)||(this.currentContainer.removeClass("with-st-controls"),this.currentContainer=void 0)}}),e.exports=l}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"./block-control":138,"./blocks":156,"./event-bus":165,"./events":166,"./function-bind":173,"./lodash":178,"./mediated-events":179,"./renderable":180}],140:[function(t,e,n){"use strict";var i=function(){this._ensureElement(),this._bindFunctions()};Object.assign(i.prototype,t("./function-bind"),t("./renderable"),{tagName:"a",className:"st-block-ui-btn st-block-ui-btn--delete st-icon",attributes:{html:"delete","data-icon":"bin"}}),e.exports=i},{"./function-bind":173,"./renderable":180}],141:[function(t,e,n){"use strict";var i=t("./lodash"),r=t("./utils"),o=t("./config"),a=t("./event-bus"),s=t("./blocks"),l=["convertToMarkdown","convertFromMarkdown","formatBar"],u=function(t,e,n){this.options=t,this.blockOptions=l.reduce(function(e,n){return e[n]=t[n],e},{}),this.instance_scope=e,this.mediator=n,this.blocks=[],this.blockCounts={},this.blockTypes={},this._setBlocksTypes(),this._setRequired(),this._bindMediatedEvents(),this.initialize()};Object.assign(u.prototype,t("./function-bind"),t("./mediated-events"),t("./events"),{eventNamespace:"block",mediatedEvents:{create:"createBlock",remove:"removeBlock",rerender:"rerenderBlock"},initialize:function(){},createBlock:function(t,e){if(t=r.classify(t),this.canCreateBlock(t)){var n=new s[t](e,this.instance_scope,this.mediator,this.blockOptions);this.blocks.push(n),this._incrementBlockTypeCount(t),this.mediator.trigger("block:render",n),this.triggerBlockCountUpdate(),this.mediator.trigger("block:limitReached",this.blockLimitReached()),a.trigger(e?"block:create:existing":"block:create:new",n),r.log("Block created of type "+t)}},removeBlock:function(t){var e=this.findBlockById(t),n=r.classify(e.type);this.mediator.trigger("block-controls:reset"),this.blocks=this.blocks.filter(function(t){return t.blockID!==e.blockID}),this._decrementBlockTypeCount(n),this.triggerBlockCountUpdate(),this.mediator.trigger("block:limitReached",this.blockLimitReached()),a.trigger("block:remove")},rerenderBlock:function(t){var e=this.findBlockById(t);i.isUndefined(e)||e.isEmpty()||!e.drop_options.re_render_on_reorder||e.beforeLoadingData()},triggerBlockCountUpdate:function(){this.mediator.trigger("block:countUpdate",this.blocks.length)},canCreateBlock:function(t){return this.blockLimitReached()?(r.log("Cannot add any more blocks. Limit reached."),!1):this.isBlockTypeAvailable(t)?this.canAddBlockType(t)?!0:(r.log("Block Limit reached for type "+t),!1):(r.log("Block type not available "+t),!1)},validateBlockTypesExist:function(t){return o.skipValidation||!t?!1:void(this.required||[]).forEach(function(t,e){if(this.isBlockTypeAvailable(t))if(0===this._getBlockTypeCount(t))r.log("Failed validation on required block type "+t),this.mediator.trigger("errors:add",{text:i18n.t("errors:type_missing",{type:t})});else{var n=this.getBlocksByType(t).filter(function(t){return!t.isEmpty()});if(n.length>0)return!1;this.mediator.trigger("errors:add",{text:i18n.t("errors:required_type_empty",{type:t})}),r.log("A required block type "+t+" is empty")}},this)},findBlockById:function(t){return this.blocks.find(function(e){return e.blockID===t})},getBlocksByType:function(t){return this.blocks.filter(function(e){return r.classify(e.type)===t})},getBlocksByIDs:function(t){return this.blocks.filter(function(e){return t.includes(e.blockID)})},blockLimitReached:function(){return 0!==this.options.blockLimit&&this.blocks.length>=this.options.blockLimit},isBlockTypeAvailable:function(t){return!i.isUndefined(this.blockTypes[t])},canAddBlockType:function(t){var e=this._getBlockTypeLimit(t);return!(0!==e&&this._getBlockTypeCount(t)>=e)},_setBlocksTypes:function(){this.blockTypes=r.flatten(i.isUndefined(this.options.blockTypes)?s:this.options.blockTypes)},_setRequired:function(){this.required=!1,Array.isArray(this.options.required)&&!i.isEmpty(this.options.required)&&(this.required=this.options.required)},_incrementBlockTypeCount:function(t){this.blockCounts[t]=i.isUndefined(this.blockCounts[t])?1:this.blockCounts[t]+1},_decrementBlockTypeCount:function(t){this.blockCounts[t]=i.isUndefined(this.blockCounts[t])?1:this.blockCounts[t]-1},_getBlockTypeCount:function(t){return i.isUndefined(this.blockCounts[t])?0:this.blockCounts[t]},_blockLimitReached:function(){return 0!==this.options.blockLimit&&this.blocks.length>=this.options.blockLimit},_getBlockTypeLimit:function(t){return this.isBlockTypeAvailable(t)?parseInt(i.isUndefined(this.options.blockTypeLimits[t])?0:this.options.blockTypeLimits[t],10):0}}),e.exports=u},{"./blocks":156,"./config":162,"./event-bus":165,"./events":166,"./function-bind":173,"./lodash":178,"./mediated-events":179,"./utils":184}],142:[function(t,e,n){"use strict";var i=[""," "," ","
"].join("\n"),r=function(t,e){this.mediator=e,this.$block=t,this._ensureElement(),this._bindFunctions(),this.initialize()};Object.assign(r.prototype,t("./function-bind"),t("./renderable"),{total_blocks:0,bound:["onBlockCountChange","onSelectChange","toggle","show","hide"],className:"st-block-positioner",visibleClass:"st-block-positioner--is-visible",initialize:function(){this.$el.append(i),this.$select=this.$(".st-block-positioner__select"),this.$select.on("change",this.onSelectChange),this.mediator.on("block:countUpdate",this.onBlockCountChange)},onBlockCountChange:function(t){t!==this.total_blocks&&(this.total_blocks=t,this.renderPositionList())},onSelectChange:function(){var t=this.$select.val();0!==t&&(this.mediator.trigger("block:changePosition",this.$block,t,1===t?"before":"after"),this.toggle())},renderPositionList:function(){for(var t=""+i18n.t("general:position")+" ",e=1;e<=this.total_blocks;e++)t+=""+e+" ";this.$select.html(t)},toggle:function(){this.$select.val(0),this.$el.toggleClass(this.visibleClass)},show:function(){this.$el.addClass(this.visibleClass)},hide:function(){this.$el.removeClass(this.visibleClass)}}),e.exports=r},{"./function-bind":173,"./renderable":180}],143:[function(t,e,n){(function(n){"use strict";var i=t("./lodash"),r="undefined"!=typeof window?window.$:"undefined"!=typeof n?n.$:null,o=t("./event-bus"),a=function(t,e){this.$block=t,this.blockID=this.$block.attr("id"),this.mediator=e,this._ensureElement(),this._bindFunctions(),this.initialize()};Object.assign(a.prototype,t("./function-bind"),t("./renderable"),{bound:["onMouseDown","onDragStart","onDragEnd","onDrop"],className:"st-block-ui-btn st-block-ui-btn--reorder st-icon",tagName:"a",attributes:function(){return{html:"reorder",draggable:"true","data-icon":"move"}},initialize:function(){this.$el.bind("mousedown touchstart",this.onMouseDown).bind("dragstart",this.onDragStart).bind("dragend touchend",this.onDragEnd),this.$block.dropArea().bind("drop",this.onDrop)},blockId:function(){return this.$block.attr("id")},onMouseDown:function(){this.mediator.trigger("block-controls:hide"),o.trigger("block:reorder:down")},onDrop:function(t){t.preventDefault();var e=this.$block,n=t.originalEvent.dataTransfer.getData("text/plain"),a=r("#"+n);i.isUndefined(n)||i.isEmpty(a)||e.attr("id")===n||e.attr("data-instance")!==a.attr("data-instance")||e.after(a),this.mediator.trigger("block:rerender",n),o.trigger("block:reorder:dropped",n)},onDragStart:function(t){var e=r(t.currentTarget).parent();t.originalEvent.dataTransfer.setDragImage(this.$block[0],e.position().left,e.position().top),t.originalEvent.dataTransfer.setData("Text",this.blockId()),o.trigger("block:reorder:dragstart"),this.$block.addClass("st-block--dragging")},onDragEnd:function(t){o.trigger("block:reorder:dragend"),this.$block.removeClass("st-block--dragging")},render:function(){return this}}),e.exports=a}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"./event-bus":165,"./function-bind":173,"./lodash":178,"./renderable":180}],144:[function(t,e,n){"use strict";var i=t("./lodash"),r=t("./utils"),o=t("./event-bus");e.exports={blockStorage:{},createStore:function(t){this.blockStorage={type:r.underscored(this.type),data:t||{}}},save:function(){var t=this._serializeData();i.isEmpty(t)||this.setData(t)},getData:function(){return this.save(),this.blockStorage},getBlockData:function(){return this.save(),this.blockStorage.data},_getData:function(){return this.blockStorage.data},setData:function(t){r.log("Setting data for block "+this.blockID),Object.assign(this.blockStorage.data,t||{})},setAndLoadData:function(t){this.setData(t),this.beforeLoadingData()},_serializeData:function(){},loadData:function(){},beforeLoadingData:function(){r.log("loadData for "+this.blockID),o.trigger("editor/block/loadData"),this.loadData(this._getData())},_loadData:function(){r.log("_loadData is deprecated and will be removed in the future. Please use beforeLoadingData instead."),this.beforeLoadingData()},checkAndLoadData:function(){i.isEmpty(this._getData())||this.beforeLoadingData()}}},{"./event-bus":165,"./lodash":178,"./utils":184}],145:[function(t,e,n){(function(n){"use strict";var i=t("./lodash"),r="undefined"!=typeof window?window.$:"undefined"!=typeof n?n.$:null,o=t("./utils"),a=function(t){var e=t.attr("data-st-name")||t.attr("name");return e||(e="Field"),o.capitalize(e)};e.exports={errors:[],valid:function(){return this.performValidations(),0===this.errors.length},performValidations:function(){this.resetErrors();var t=this.$(".st-required");t.each(function(t,e){this.validateField(e)}.bind(this)),this.validations.forEach(this.runValidator,this),this.$el.toggleClass("st-block--with-errors",this.errors.length>0)},validations:[],validateField:function(t){t=r(t);var e=t.attr("contenteditable")?t.text():t.val();0===e.length&&this.setError(t,i18n.t("errors:block_empty",{name:a(t)}))},runValidator:function(t){i.isUndefined(this[t])||this[t].call(this)},setError:function(t,e){var n=this.addMessage(e,"st-msg--error");t.addClass("st-error"),this.errors.push({field:t,reason:e,msg:n})},resetErrors:function(){this.errors.forEach(function(t){t.field.removeClass("st-error"),t.msg.remove()}),this.$messages.removeClass("st-block__messages--is-visible"),this.errors=[]}}}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"./lodash":178,"./utils":184}],146:[function(t,e,n){(function(n){"use strict";var i=t("./lodash"),r="undefined"!=typeof window?window.$:"undefined"!=typeof n?n.$:null,o=t("scribe-editor"),a=t("scribe-plugin-formatter-plain-text-convert-new-lines-to-html"),s=t("scribe-plugin-link-prompt-command"),l=t("./config"),u=t("./utils"),c=t("./to-markdown"),h=t("./block_mixins"),d=t("./simple-block"),p=t("./block-reorder"),f=t("./block-deletion"),m=t("./block-positioner"),g=t("./event-bus"),v=t("spin.js"),y=function(t,e,n,i){d.apply(this,arguments)};y.prototype=Object.create(d.prototype),y.prototype.constructor=y;var b=["","
","<%= i18n.t('general:delete') %>"," ","
","
","
"].join("\n");Object.assign(y.prototype,d.fn,t("./block-validations"),{bound:["_handleContentPaste","_onFocus","_onBlur","onDrop","onDeleteClick","clearInsertedStyles","getSelectionForFormatter","onBlockRender"],className:"st-block st-icon--add",attributes:function(){return Object.assign(d.fn.attributes.call(this),{"data-icon-after":"add"})},icon_name:"default",validationFailMsg:function(){return i18n.t("errors:validation_fail",{type:this.title()})},editorHTML:'
',toolbarEnabled:!0,availableMixins:["droppable","pastable","uploadable","fetchable","ajaxable","controllable"],droppable:!1,pastable:!1,uploadable:!1,fetchable:!1,ajaxable:!1,drop_options:{},paste_options:{},upload_options:{},formattable:!0,_previousSelection:"",initialize:function(){},toMarkdown:function(t){return t},toHTML:function(t){return t},withMixin:function(t){if(i.isObject(t)){var e="initialize"+t.mixinName;i.isUndefined(this[e])&&(Object.assign(this,t),this[e]())}},render:function(){if(this.beforeBlockRender(),this._setBlockInner(),this.$editor=this.$inner.children().first(),this.droppable||this.pastable||this.uploadable){var t=r("",{"class":"st-block__inputs"});this.$inner.append(t),this.$inputs=t}return this.hasTextBlock()&&this._initTextBlocks(),this.availableMixins.forEach(function(t){this[t]&&this.withMixin(h[u.classify(t)])},this),this.formattable&&this._initFormatting(),this._blockPrepare(),this},remove:function(){this.ajaxable&&this.resolveAllInQueue(),this.$el.remove()},loading:function(){i.isUndefined(this.spinner)||this.ready(),this.spinner=new v(l.defaults.spinner),this.spinner.spin(this.$el[0]),this.$el.addClass("st--is-loading")},ready:function(){this.$el.removeClass("st--is-loading"),i.isUndefined(this.spinner)||(this.spinner.stop(),delete this.spinner)},_serializeData:function(){u.log("toData for "+this.blockID);var t={};return this.hasTextBlock()&&(t.text=this.getTextBlockHTML(),t.text.length>0&&this.options.convertToMarkdown&&(t.text=c(t.text,this.type))),this.$(":input").not(".st-paste-block").length>0&&this.$(":input").each(function(e,n){n.getAttribute("name")&&(t[n.getAttribute("name")]=n.value)}),t},focus:function(){this.getTextBlock().focus()},blur:function(){this.getTextBlock().blur()},onFocus:function(){this.getTextBlock().bind("focus",this._onFocus)},onBlur:function(){this.getTextBlock().bind("blur",this._onBlur)},_onFocus:function(){this.trigger("blockFocus",this.$el)},_onBlur:function(){},onBlockRender:function(){this.focus()},onDrop:function(t){},onDeleteClick:function(t){t.preventDefault();var e=function(t){t.preventDefault(),this.mediator.trigger("block:remove",this.blockID),this.remove()},n=function(t){t.preventDefault(),this.$el.removeClass("st-block--delete-active"),r.remove()};if(this.isEmpty())return void e.call(this,new Event("click"));this.$inner.append(i.template(b)),this.$el.addClass("st-block--delete-active");var r=this.$inner.find(".st-block__ui-delete-controls");this.$inner.on("click",".st-block-ui-btn--confirm-delete",e.bind(this)).on("click",".st-block-ui-btn--deny-delete",n.bind(this))},beforeLoadingData:function(){this.loading(),(this.droppable||this.uploadable||this.pastable)&&(this.$editor.show(),this.$inputs.hide()),d.fn.beforeLoadingData.call(this),this.ready()},execTextBlockCommand:function(t){if(i.isUndefined(this._scribe))throw"No Scribe instance found to send a command to";var e=this._scribe.getCommand(t);this._scribe.el.focus(),e.execute()},queryTextBlockCommandState:function(t){if(i.isUndefined(this._scribe))throw"No Scribe instance found to query command";var e=this._scribe.getCommand(t),n=new this._scribe.api.Selection;return n.range&&e.queryState()},_handleContentPaste:function(t){setTimeout(this.onContentPasted.bind(this,t,r(t.currentTarget)),0)},_getBlockClass:function(){return"st-block--"+this.className},_initUIComponents:function(){var t=new m(this.$el,this.mediator);this._withUIComponent(t,".st-block-ui-btn--reorder",t.toggle),this._withUIComponent(new p(this.$el,this.mediator)),this._withUIComponent(new f,".st-block-ui-btn--delete",this.onDeleteClick),this.onFocus(),this.onBlur()},_initFormatting:function(){var t=this;this.options.formatBar&&this.options.formatBar.commands.forEach(function(e){if(!i.isUndefined(e.keyCode)){var n=!1;t.$el.on("keyup",".st-text-block",function(t){(17===t.which||224===t.which||91===t.which)&&(n=!1)}).on("keydown",".st-text-block",{formatter:e},function(e){(17===e.which||224===e.which||91===e.which)&&(n=!0),e.which===e.data.formatter.keyCode&&n&&(e.preventDefault(),t.execTextBlockCommand(e.data.formatter.cmd))})}})},_initTextBlocks:function(){this.getTextBlock().bind("keyup",this.getSelectionForFormatter).bind("mouseup",this.getSelectionForFormatter).bind("DOMNodeInserted",this.clearInsertedStyles);var t=this.getTextBlock().get(0);!i.isUndefined(t)&&i.isUndefined(this._scribe)&&(this._scribe=new o(t,{debug:l.scribeDebug}),this._scribe.use(a()),this._scribe.use(s()),i.isFunction(this.options.configureScribe)&&this.options.configureScribe.call(this,this._scribe))},getSelectionForFormatter:function(){var t=this;setTimeout(function(){var e=window.getSelection(),n=e.toString().trim(),i="formatter:"+(""===n?"hide":"position");t.mediator.trigger(i,t),g.trigger(i,t)},1)},clearInsertedStyles:function(t){var e=t.target;e.removeAttribute("style")},hasTextBlock:function(){return this.getTextBlock().length>0},getTextBlock:function(){return i.isUndefined(this.text_block)&&(this.text_block=this.$(".st-text-block")),this.text_block},getTextBlockHTML:function(){return this._scribe.getHTML()},setTextBlockHTML:function(t){return this._scribe.setContent(t)},isEmpty:function(){return i.isEmpty(this.getBlockData())}}),y.extend=t("./helpers/extend"),e.exports=y}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"./block-deletion":140,"./block-positioner":142,"./block-reorder":143,"./block-validations":145,"./block_mixins":151,"./config":162,"./event-bus":165,"./helpers/extend":175,"./lodash":178,"./simple-block":181,"./to-markdown":183,"./utils":184,"scribe-editor":132,"scribe-plugin-formatter-plain-text-convert-new-lines-to-html":135,"scribe-plugin-link-prompt-command":136,"spin.js":137}],147:[function(t,e,n){"use strict";var i=t("../utils");e.exports={mixinName:"Ajaxable",ajaxable:!0,initializeAjaxable:function(){this._queued=[]},addQueuedItem:function(t,e){i.log("Adding queued item for "+this.blockID+" called "+t),this._queued.push({name:t,deferred:e})},removeQueuedItem:function(t){i.log("Removing queued item for "+this.blockID+" called "+t),this._queued=this._queued.filter(function(e){return e.name!==t})},hasItemsInQueue:function(){return this._queued.length>0},resolveAllInQueue:function(){this._queued.forEach(function(t){i.log("Aborting queued request: "+t.name),t.deferred.abort()},this)}}},{"../utils":184}],148:[function(t,e,n){(function(n){"use strict";var i="undefined"!=typeof window?window.$:"undefined"!=typeof n?n.$:null,r=t("../utils");e.exports={mixinName:"Controllable",initializeControllable:function(){r.log("Adding controllable to block "+this.blockID),this.$control_ui=i("
",{"class":"st-block__control-ui"}),Object.keys(this.controls).forEach(function(t){this.addUiControl(t,this.controls[t].bind(this))},this),this.$inner.append(this.$control_ui)},getControlTemplate:function(t){return i("
",{"data-icon":t,"class":"st-icon st-block-control-ui-btn st-block-control-ui-btn--"+t})},addUiControl:function(t,e){this.$control_ui.append(this.getControlTemplate(t)),this.$control_ui.on("click",".st-block-control-ui-btn--"+t,e)}}}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"../utils":184}],149:[function(t,e,n){(function(n){"use strict";var i=t("../lodash"),r="undefined"!=typeof window?window.$:"undefined"!=typeof n?n.$:null,o=t("../config"),a=t("../utils"),s=t("../event-bus");e.exports={mixinName:"Droppable",valid_drop_file_types:["File","Files","text/plain","text/uri-list"],initializeDroppable:function(){a.log("Adding droppable to block "+this.blockID),this.drop_options=Object.assign({},o.defaults.Block.drop_options,this.drop_options);var t=r(i.template(this.drop_options.html,{block:this,_:i}));this.$editor.hide(),this.$inputs.append(t),this.$dropzone=t,this.$dropzone.dropArea().bind("drop",this._handleDrop.bind(this)),this.$inner.addClass("st-block__inner--droppable")},_handleDrop:function(t){t.preventDefault(),t=t.originalEvent;var e=r(t.target),n=t.dataTransfer.types;e.removeClass("st-dropzone--dragover"),n&&n.some(function(t){return this.valid_drop_file_types.includes(t)},this)&&this.onDrop(t.dataTransfer),s.trigger("block:content:dropped",this.blockID)}}}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"../config":162,"../event-bus":165,"../lodash":178,"../utils":184}],150:[function(t,e,n){(function(n){"use strict";var i=t("../lodash"),r="undefined"!=typeof window?window.$:"undefined"!=typeof n?n.$:null;e.exports={mixinName:"Fetchable",initializeFetchable:function(){this.withMixin(t("./ajaxable"))},fetch:function(t,e,n){var o=i.uniqueId(this.blockID+"_fetch"),a=r.ajax(t);return this.resetMessages(),this.addQueuedItem(o,a),i.isUndefined(e)||a.done(e.bind(this)),i.isUndefined(n)||a.fail(n.bind(this)),a.always(this.removeQueuedItem.bind(this,o)),a}}}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"../lodash":178,"./ajaxable":147}],151:[function(t,e,n){"use strict";e.exports={Ajaxable:t("./ajaxable.js"),Controllable:t("./controllable.js"),Droppable:t("./droppable.js"),Fetchable:t("./fetchable.js"),Pastable:t("./pastable.js"),Uploadable:t("./uploadable.js")}},{"./ajaxable.js":147,"./controllable.js":148,"./droppable.js":149,"./fetchable.js":150,"./pastable.js":152,"./uploadable.js":153}],152:[function(t,e,n){(function(n){"use strict";var i=t("../lodash"),r="undefined"!=typeof window?window.$:"undefined"!=typeof n?n.$:null,o=t("../config"),a=t("../utils");e.exports={mixinName:"Pastable",initializePastable:function(){a.log("Adding pastable to block "+this.blockID),this.paste_options=Object.assign({},o.defaults.Block.paste_options,this.paste_options),this.$inputs.append(i.template(this.paste_options.html,this)),this.$(".st-paste-block").bind("click",function(){r(this).select()}).bind("paste",this._handleContentPaste).bind("submit",this._handleContentPaste)}}}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"../config":162,"../lodash":178,"../utils":184}],153:[function(t,e,n){"use strict";var i=t("../lodash"),r=t("../config"),o=t("../utils"),a=t("../extensions/file-uploader");e.exports={mixinName:"Uploadable",uploadsCount:0,initializeUploadable:function(){o.log("Adding uploadable to block "+this.blockID),this.withMixin(t("./ajaxable")),this.upload_options=Object.assign({},r.defaults.Block.upload_options,this.upload_options),this.$inputs.append(i.template(this.upload_options.html,this))},uploader:function(t,e,n){return a(this,t,e,n)}}},{"../config":162,"../extensions/file-uploader":168,"../lodash":178,"../utils":184,"./ajaxable":147}],154:[function(t,e,n){"use strict";var i=t("../block"),r=t("../to-html");e.exports=i.extend({type:"Heading",title:function(){return i18n.t("blocks:heading:title")},editorHTML:'
',icon_name:"heading",loadData:function(t){this.getTextBlock().html(r(t.text,this.type))}})},{"../block":146,"../to-html":182}],155:[function(t,e,n){(function(n){"use strict";var i="undefined"!=typeof window?window.$:"undefined"!=typeof n?n.$:null,r=t("../block");e.exports=r.extend({type:"image",title:function(){return i18n.t("blocks:image:title")},droppable:!0,uploadable:!0,icon_name:"image",loadData:function(t){this.$editor.html(i(" ",{src:t.file.url}))},onBlockRender:function(){this.$inputs.find("button").bind("click",function(t){t.preventDefault()}),this.$inputs.find("input").on("change",function(t){this.onDrop(t.currentTarget)}.bind(this))},onDrop:function(t){var e=t.files[0],n="undefined"!=typeof URL?URL:"undefined"!=typeof webkitURL?webkitURL:null;/image/.test(e.type)&&(this.loading(),this.$inputs.hide(),this.$editor.html(i(" ",{src:n.createObjectURL(e)})).show(),this.uploader(e,function(t){this.setData(t),this.ready()},function(t){this.addMessage(i18n.t("blocks:image:upload_error")),this.ready()}))}})}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"../block":146}],156:[function(t,e,n){"use strict";e.exports={Text:t("./text"),Quote:t("./quote"),Image:t("./image"),Heading:t("./heading"),List:t("./list"),Tweet:t("./tweet"),Video:t("./video")}},{"./heading":154,"./image":155,"./list":157,"./quote":158,"./text":159,"./tweet":160,"./video":161}],157:[function(t,e,n){"use strict";var i=t("../lodash"),r=t("../block"),o=t("../to-html"),a='';e.exports=r.extend({type:"list",title:function(){return i18n.t("blocks:list:title")},icon_name:"list",editorHTML:function(){return i.template(a,this)},loadData:function(t){this.setTextBlockHTML("")},onBlockRender:function(){this.checkForList=this.checkForList.bind(this),this.getTextBlock().on("click keyup",this.checkForList),this.focus()},checkForList:function(){0===this.$("ul").length&&document.execCommand("insertUnorderedList",!1,!1)},toMarkdown:function(t){return t.replace(/<\/li>/gm,"\n").replace(/<\/?[^>]+(>|$)/g,"").replace(/^(.+)$/gm," - $1")},toHTML:function(t){return t=t.replace(/^ - (.+)$/gm,"$1 ").replace(/\n/gm,"")},onContentPasted:function(t,e){this.$("ul").html(this.pastedMarkdownToHTML(e[0].innerHTML)),this.getTextBlock().caretToEnd()},isEmpty:function(){return i.isEmpty(this.getBlockData().text)}})},{"../block":146,"../lodash":178,"../to-html":182}],158:[function(t,e,n){"use strict";var i=t("../lodash"),r=t("../block"),o=t("../to-html"),a=i.template([' ',' <%= i18n.t("blocks:quote:credit_field") %> ',' "',' class="st-input-string st-required js-cite-input" type="text" />'].join("\n"));e.exports=r.extend({type:"quote",title:function(){return i18n.t("blocks:quote:title")},icon_name:"quote",editorHTML:function(){return a(this)},loadData:function(t){this.getTextBlock().html(o(t.text,this.type)),this.$(".js-cite-input").val(t.cite)},toMarkdown:function(t){return t.replace(/^(.+)$/gm,"> $1")}})},{"../block":146,"../lodash":178,"../to-html":182}],159:[function(t,e,n){"use strict";var i=t("../block"),r=t("../to-html");e.exports=i.extend({type:"text",title:function(){return i18n.t("blocks:text:title")},editorHTML:'
',
+icon_name:"text",markdownSupport:!0,_serializeData:function(){var t=i.prototype._serializeData.apply(this);return Object.keys(t).length&&this.markdownSupport&&(t.isHtml=!0),t},loadData:function(t){this.markdownSupport&&!t.isHtml?this.getTextBlock().html(r(t.text,this.type)):this.getTextBlock().html(t.text)}})},{"../block":146,"../to-html":182}],160:[function(t,e,n){(function(n){"use strict";var i=t("../lodash"),r="undefined"!=typeof window?window.$:"undefined"!=typeof n?n.$:null,o=t("../utils"),a=t("../block"),s=i.template(["",''].join("\n"));e.exports=a.extend({type:"tweet",droppable:!0,pastable:!0,fetchable:!0,drop_options:{re_render_on_reorder:!0},title:function(){return i18n.t("blocks:tweet:title")},fetchUrl:function(t){return"/tweets/?tweet_id="+t},icon_name:"twitter",loadData:function(t){i.isUndefined(t.status_url)&&(t.status_url=""),this.$inner.find("iframe").remove(),this.$inner.prepend(s(t))},onContentPasted:function(t){var e=r(t.target),n=e.val();this.handleTwitterDropPaste(n)},handleTwitterDropPaste:function(t){if(!this.validTweetUrl(t))return void o.log("Invalid Tweet URL");var e=t.match(/[^\/]+$/);if(!i.isEmpty(e)){this.loading(),e=e[0];var n={url:this.fetchUrl(e),dataType:"json"};this.fetch(n,this.onTweetSuccess,this.onTweetFail)}},validTweetUrl:function(t){return o.isURI(t)&&-1!==t.indexOf("twitter")&&-1!==t.indexOf("status")},onTweetSuccess:function(t){var e={user:{profile_image_url:t.user.profile_image_url,profile_image_url_https:t.user.profile_image_url_https,screen_name:t.user.screen_name,name:t.user.name},id:t.id_str,text:t.text,created_at:t.created_at,entities:t.entities,status_url:"https://twitter.com/"+t.user.screen_name+"/status/"+t.id_str};this.setAndLoadData(e),this.ready()},onTweetFail:function(){this.addMessage(i18n.t("blocks:tweet:fetch_error")),this.ready()},onDrop:function(t){var e=t.getData("text/plain");this.handleTwitterDropPaste(e)}})}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"../block":146,"../lodash":178,"../utils":184}],161:[function(t,e,n){"use strict";var i=t("../lodash"),r=t("../utils"),o=t("../block");e.exports=o.extend({providers:{vimeo:{regex:/(?:http[s]?:\/\/)?(?:www.)?vimeo.com\/(.+)/,html:''},youtube:{regex:/(?:http[s]?:\/\/)?(?:www.)?(?:(?:youtube.com\/watch\?(?:.*)(?:v=))|(?:youtu.be\/))([^&].+)/,html:''}},type:"video",title:function(){return i18n.t("blocks:video:title")},droppable:!0,pastable:!0,icon_name:"video",loadData:function(t){if(this.providers.hasOwnProperty(t.source)){var e=this.providers[t.source],n="file:"===window.location.protocol?"http:":window.location.protocol,r=e.square?"with-square-media":"with-sixteen-by-nine-media";this.$editor.addClass("st-block__editor--"+r).html(i.template(e.html,{protocol:n,remote_id:t.remote_id,width:this.$editor.width()}))}},onContentPasted:function(t){this.handleDropPaste(t.target.value)},matchVideoProvider:function(t,e,n){var r=t.regex.exec(n);return null==r||i.isUndefined(r[1])?{}:{source:e,remote_id:r[1]}},handleDropPaste:function(t){if(r.isURI(t))for(var e in this.providers)this.providers.hasOwnProperty(e)&&this.setAndLoadData(this.matchVideoProvider(this.providers[e],e,t))},onDrop:function(t){var e=t.getData("text/plain");this.handleDropPaste(e)}})},{"../block":146,"../lodash":178,"../utils":184}],162:[function(t,e,n){"use strict";var i={html:['','
<%= _.result(block, "icon_name") %> ','
<%= i18n.t("general:drop", { block: "" + _.result(block, "title") + " " }) %>',"
"].join("\n"),re_render_on_reorder:!1},r={html:[' "',' class="st-block__paste-input st-paste-block">'].join("")},o={html:['',' ','<%= i18n.t("general:upload") %> ',"
"].join("\n")};e.exports={debug:!1,scribeDebug:!1,skipValidation:!1,version:"0.4.0",language:"en",instances:[],defaults:{defaultType:!1,spinner:{className:"st-spinner",lines:9,length:8,width:3,radius:6,color:"#000",speed:1.4,trail:57,shadow:!1,left:"50%",top:"50%"},Block:{drop_options:i,paste_options:r,upload_options:o},blockLimit:0,blockTypeLimits:{},required:[],uploadUrl:"/attachments",baseImageUrl:"/sir-trevor-uploads/",errorsContainer:void 0,convertToMarkdown:!1,convertFromMarkdown:!0,formatBar:{commands:[{name:"Bold",title:"bold",cmd:"bold",keyCode:66,text:"B"},{name:"Italic",title:"italic",cmd:"italic",keyCode:73,text:"i"},{name:"Link",title:"link",iconName:"link",cmd:"linkPrompt",text:"link"},{name:"Unlink",title:"unlink",iconName:"link",cmd:"unlink",text:"link"}]}}}},{}],163:[function(t,e,n){(function(n){"use strict";var i=t("./lodash"),r="undefined"!=typeof window?window.$:"undefined"!=typeof n?n.$:null,o=t("./config"),a=t("./utils"),s=t("./events"),l=t("./event-bus"),u=t("./form-events"),c=t("./block-controls"),h=t("./block-manager"),d=t("./floating-block-controls"),p=t("./format-bar"),f=t("./extensions/editor-store"),m=t("./error-handler"),g=function(t){this.initialize(t)};Object.assign(g.prototype,t("./function-bind"),t("./events"),{bound:["onFormSubmit","hideAllTheThings","changeBlockPosition","removeBlockDragOver","renderBlock","resetBlockControls","blockLimitReached"],events:{"block:reorder:dragend":"removeBlockDragOver","block:content:dropped":"removeBlockDragOver"},initialize:function(t){return a.log("Init SirTrevor.Editor"),this.options=Object.assign({},o.defaults,t||{}),this.ID=i.uniqueId("st-editor-"),this._ensureAndSetElements()?(!i.isUndefined(this.options.onEditorRender)&&i.isFunction(this.options.onEditorRender)&&(this.onEditorRender=this.options.onEditorRender),this.mediator=Object.assign({},s),this._bindFunctions(),o.instances.push(this),this.build(),void u.bindFormSubmit(this.$form)):!1},build:function(){this.$el.hide(),this.errorHandler=new m(this.$outer,this.mediator,this.options.errorsContainer),this.store=new f(this.$el.val(),this.mediator),this.block_manager=new h(this.options,this.ID,this.mediator),this.block_controls=new c(this.block_manager.blockTypes,this.mediator),this.fl_block_controls=new d(this.$wrapper,this.ID,this.mediator),this.formatBar=new p(this.options.formatBar,this.mediator),this.mediator.on("block:changePosition",this.changeBlockPosition),this.mediator.on("block-controls:reset",this.resetBlockControls),this.mediator.on("block:limitReached",this.blockLimitReached),this.mediator.on("block:render",this.renderBlock),this.dataStore="Please use store.retrieve();",this._setEvents(),this.$wrapper.prepend(this.fl_block_controls.render().$el),r(document.body).append(this.formatBar.render().$el),this.$outer.append(this.block_controls.render().$el),r(window).bind("click",this.hideAllTheThings),this.createBlocks(),this.$wrapper.addClass("st-ready"),i.isUndefined(this.onEditorRender)||this.onEditorRender()},createBlocks:function(){var t=this.store.retrieve();t.data.length>0?t.data.forEach(function(t){this.mediator.trigger("block:create",t.type,t.data)},this):this.options.defaultType!==!1&&this.mediator.trigger("block:create",this.options.defaultType,{})},destroy:function(){this.formatBar.destroy(),this.fl_block_controls.destroy(),this.block_controls.destroy(),this.blocks.forEach(function(t){this.mediator.trigger("block:remove",this.block.blockID)},this),this.mediator.stopListening(),this.stopListening(),o.instances=o.instances.filter(function(t){return t.ID!==this.ID},this),this.store.reset(),this.$outer.replaceWith(this.$el.detach())},reinitialize:function(t){this.destroy(),this.initialize(t||this.options)},resetBlockControls:function(){this.block_controls.renderInContainer(this.$wrapper),this.block_controls.hide()},blockLimitReached:function(t){this.$wrapper.toggleClass("st--block-limit-reached",t)},_setEvents:function(){Object.keys(this.events).forEach(function(t){l.on(t,this[this.events[t]],this)},this)},hideAllTheThings:function(t){this.block_controls.hide(),this.formatBar.hide()},store:function(t,e){return a.log("The store method has been removed, please call store[methodName]"),this.store[t].call(this,e||{})},renderBlock:function(t){this._renderInPosition(t.render().$el),this.hideAllTheThings(),this.scrollTo(t.$el),t.trigger("onRender")},scrollTo:function(t){r("html, body").animate({scrollTop:t.position().top},300,"linear")},removeBlockDragOver:function(){this.$outer.find(".st-drag-over").removeClass("st-drag-over")},changeBlockPosition:function(t,e){e-=1;var n=this.getBlockPosition(t),i=this.$wrapper.find(".st-block").eq(e),r=n>e?"Before":"After";i&&i.attr("id")!==t.attr("id")&&(this.hideAllTheThings(),t["insert"+r](i),this.scrollTo(t))},_renderInPosition:function(t){this.block_controls.currentContainer?this.block_controls.currentContainer.after(t):this.$wrapper.append(t)},validateAndSaveBlock:function(t,e){if((!o.skipValidation||e)&&!t.valid())return this.mediator.trigger("errors:add",{text:i.result(t,"validationFailMsg")}),void a.log("Block "+t.blockID+" failed validation");var n=t.getData();a.log("Adding data for block "+t.blockID+" to block store:",n),this.store.addData(n)},onFormSubmit:function(t){return t=t===!1?!1:!0,a.log("Handling form submission for Editor "+this.ID),this.mediator.trigger("errors:reset"),this.store.reset(),this.validateBlocks(t),this.block_manager.validateBlockTypesExist(t),this.mediator.trigger("errors:render"),this.$el.val(this.store.toString()),this.errorHandler.errors.length},validateBlocks:function(t){var e=this;this.$wrapper.find(".st-block").each(function(n,o){var a=e.block_manager.findBlockById(r(o).attr("id"));i.isUndefined(a)||e.validateAndSaveBlock(a,t)})},findBlockById:function(t){return this.block_manager.findBlockById(t)},getBlocksByType:function(t){return this.block_manager.getBlocksByType(t)},getBlocksByIDs:function(t){return this.block_manager.getBlocksByIDs(t)},getBlockPosition:function(t){return this.$wrapper.find(".st-block").index(t)},_ensureAndSetElements:function(){if(i.isUndefined(this.options.el)||i.isEmpty(this.options.el))return a.log("You must provide an el"),!1;this.$el=this.options.el,this.el=this.options.el[0],this.$form=this.$el.parents("form");var t=r("").attr({id:this.ID,"class":"st-outer",dropzone:"copy link move"}),e=r("
").attr({"class":"st-blocks"});return this.$el.wrap(t).wrap(e),this.$outer=this.$form.find("#"+this.ID),this.$wrapper=this.$outer.find(".st-blocks"),!0}}),e.exports=g}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"./block-controls":139,"./block-manager":141,"./config":162,"./error-handler":164,"./event-bus":165,"./events":166,"./extensions/editor-store":167,"./floating-block-controls":170,"./form-events":171,"./format-bar":172,"./function-bind":173,"./lodash":178,"./utils":184}],164:[function(t,e,n){(function(n){"use strict";var i=t("./lodash"),r="undefined"!=typeof window?window.$:"undefined"!=typeof n?n.$:null,o=function(t,e,n){this.$wrapper=t,this.mediator=e,this.$el=n,i.isUndefined(this.$el)&&(this._ensureElement(),this.$wrapper.prepend(this.$el)),this.$el.hide(),this._bindFunctions(),this._bindMediatedEvents(),this.initialize()};Object.assign(o.prototype,t("./function-bind"),t("./mediated-events"),t("./renderable"),{errors:[],className:"st-errors",eventNamespace:"errors",mediatedEvents:{reset:"reset",add:"addMessage",render:"render"},initialize:function(){var t=r("