diff --git a/build/onion-editor.js b/build/onion-editor.js index 5fec72c..6c85072 100644 --- a/build/onion-editor.js +++ b/build/onion-editor.js @@ -5035,8 +5035,6 @@ define('scribe-plugin-blockquote-command',[],function () { //# sourceMappingURL=scribe-plugin-blockquote-command.js.map; define('scribe-plugin-curly-quotes',[],function () { - - return function () { var keys = { @@ -5182,6 +5180,7 @@ define('scribe-plugin-curly-quotes',[],function () { // Apply a function on all text nodes in a container, mutating in place function mapTextNodes(container, func) { +console.log(container) var walker = document.createTreeWalker(container, NodeFilter.SHOW_TEXT); var node = walker.firstChild(); if (node) { @@ -5198,7 +5197,8 @@ define('scribe-plugin-curly-quotes',[],function () { }); -//# sourceMappingURL=scribe-plugin-curly-quotes.js.map; +//# sourceMappingURL=scribe-plugin-curly-quotes.js.map +; define('scribe-plugin-formatter-plain-text-convert-new-lines-to-html',[],function () { @@ -10681,7 +10681,7 @@ define('link-formatter',[ * http://www.avclub.com/some-article ==> /some-article */ - 'use strict'; + // http://www.w3.org/TR/html-markup/syntax.html#syntax-elements @@ -10758,7 +10758,7 @@ define('link-formatter',[ define('only-trailing-brs',[],function () { - 'use strict'; + // For single-line mode: Firefox needs a BR at the end to work. // However, we don't want multiple BRs since this is a single-line input. @@ -10777,7 +10777,7 @@ define('only-trailing-brs',[],function () { define('paste-strip-newlines',[],function () { - 'use strict'; + return function () { return function (scribe) { @@ -10791,7 +10791,7 @@ define('paste-strip-newlines',[],function () { define('paste-strip-nbsps',[],function () { - 'use strict'; + return function () { return function (scribe) { @@ -10808,7 +10808,7 @@ define('paste-strip-nbsps',[],function () { define('paste-from-word',['scribe-common/src/element'], function (scribeElement) { - 'use strict'; + return function () { return function (scribe) { @@ -10880,7 +10880,7 @@ define('paste-from-word',['scribe-common/src/element'], function (scribeElement) }); define('paste-sanitize',['scribe-common/src/element'], function (scribeElement) { - 'use strict'; + return function () { return function (scribe) { @@ -10936,7 +10936,7 @@ define('paste-sanitize',['scribe-common/src/element'], function (scribeElement) define('remove-a-styles',['scribe-common/src/element'], function (scribeElement) { - 'use strict'; + return function () { return function (scribe) { @@ -10970,7 +10970,7 @@ define('remove-a-styles',['scribe-common/src/element'], function (scribeElement) define('strip-bold-in-headings',['scribe-common/src/element'], function (scribeElement) { - 'use strict'; + return function () { return function (scribe) { @@ -11075,7 +11075,7 @@ define('our-ensure-selectable-containers',[ * the config. */ - 'use strict'; + // http://www.w3.org/TR/html-markup/syntax.html#syntax-elements var html5VoidElements = ['AREA', 'BASE', 'BR', 'COL', 'COMMAND', 'EMBED', 'HR', 'IMG', 'INPUT', 'KEYGEN', 'LINK', 'META', 'PARAM', 'SOURCE', 'TRACK', 'WBR']; @@ -11156,7 +11156,7 @@ define('enforce-p-elements',[ * that we do not end up in a pristine state. */ - 'use strict'; + /** * Wrap consecutive inline elements and text nodes in a P element. @@ -11346,7 +11346,7 @@ define('onion-editor',[ filterForExport ) { - 'use strict'; + var defaults = { multiline: true, @@ -11621,12 +11621,24 @@ define('onion-editor',[ scribe.use(scribePluginCurlyQuotes()); scribe.use(scribePluginKeyboardShortcuts(Object.freeze(keyCommands))); - //TODO: kill this existing toolbar & replace w/ Medium style selection toolbar + // TODO: toolbar setup to allow mutliple toolbars on the page, scribe version + // we're using (theonion/scribe#649a8af55c36ad2536a66a99d4abab57e418ba33, + // scribe-plugin-toolbar#0.2.0) doesn't have support for toolbar sharing or + // mutiple toolbars if (options.multiline) { - scribe.use(scribePluginToolbar($('.document-tools .toolbar-contents', element.parentNode)[0])); - } - else { - $('.document-tools .toolbar-contents', element.parentNode).hide(); + var toolbarSelector = '.document-tools .toolbar-contents'; + var $toolbar = $(scribe.el.parentNode).find(toolbarSelector); + + scribe.use(scribePluginToolbar($toolbar[0], options)); + + $toolbar.hide(); + $(scribe.el) + .on('focus', function () { + $toolbar.show(); + $(toolbarSelector).not($toolbar).hide(); + }); + } else { + $(element.parentNode).find('.document-tools .toolbar-contents').hide(); } // a little hacky to prevent deletion of images and other inline elements via the backspace key. diff --git a/build/onion-editor.min.js b/build/onion-editor.min.js index 2e71f7c..ea933f9 100644 --- a/build/onion-editor.min.js +++ b/build/onion-editor.min.js @@ -1,4 +1,4 @@ -/*! onion-editor 2016-05-18 */ -!function(a,b){"function"==typeof define?define(b):"object"==typeof exports?module.exports=b():a.OnionEditor=b()}(this,function(){var a,b,c;return function(d){function e(a,b){return u.call(a,b)}function f(a,b){var c,d,e,f,g,h,i,j,k,l,m,n=b&&b.split("/"),o=s.map,p=o&&o["*"]||{};if(a&&"."===a.charAt(0))if(b){for(n=n.slice(0,n.length-1),a=a.split("/"),g=a.length-1,s.nodeIdCompat&&w.test(a[g])&&(a[g]=a[g].replace(w,"")),a=n.concat(a),k=0;k0&&(a.splice(k-1,2),k-=2)}a=a.join("/")}else 0===a.indexOf("./")&&(a=a.substring(2));if((n||p)&&o){for(c=a.split("/"),k=c.length;k>0;k-=1){if(d=c.slice(0,k).join("/"),n)for(l=n.length;l>0;l-=1)if(e=o[n.slice(0,l).join("/")],e&&(e=e[d])){f=e,h=k;break}if(f)break;!i&&p&&p[d]&&(i=p[d],j=k)}!f&&i&&(f=i,h=j),f&&(c.splice(0,h,f),a=c.join("/"))}return a}function g(a,b){return function(){return n.apply(d,v.call(arguments,0).concat([a,b]))}}function h(a){return function(b){return f(b,a)}}function i(a){return function(b){q[a]=b}}function j(a){if(e(r,a)){var b=r[a];delete r[a],t[a]=!0,m.apply(d,b)}if(!e(q,a)&&!e(t,a))throw new Error("No "+a);return q[a]}function k(a){var b,c=a?a.indexOf("!"):-1;return c>-1&&(b=a.substring(0,c),a=a.substring(c+1,a.length)),[b,a]}function l(a){return function(){return s&&s.config&&s.config[a]||{}}}var m,n,o,p,q={},r={},s={},t={},u=Object.prototype.hasOwnProperty,v=[].slice,w=/\.js$/;o=function(a,b){var c,d=k(a),e=d[0];return a=d[1],e&&(e=f(e,b),c=j(e)),e?a=c&&c.normalize?c.normalize(a,h(b)):f(a,b):(a=f(a,b),d=k(a),e=d[0],a=d[1],e&&(c=j(e))),{f:e?e+"!"+a:a,n:a,pr:e,p:c}},p={require:function(a){return g(a)},exports:function(a){var b=q[a];return"undefined"!=typeof b?b:q[a]={}},module:function(a){return{id:a,uri:"",exports:q[a],config:l(a)}}},m=function(a,b,c,f){var h,k,l,m,n,s,u=[],v=typeof c;if(f=f||a,"undefined"===v||"function"===v){for(b=!b.length&&c.length?["require","exports","module"]:b,n=0;ne?0:e);++d2?a(c,17,b(arguments,2),null,d):a(c,1,null,null,d)}return c}),c("lodash-amd/modern/utilities/identity",[],function(){function a(a){return a}return a}),c("lodash-amd/modern/support",["./internals/isNative"],function(a){var b=/\bthis\b/,c={};return c.funcDecomp=!a(window.WinRTError)&&b.test(function(){return this}),c.funcNames="string"==typeof Function.name,c}),c("lodash-amd/modern/internals/baseCreateCallback",["../functions/bind","../utilities/identity","./setBindData","../support"],function(a,b,c,d){function e(e,i,j){if("function"!=typeof e)return b;if("undefined"==typeof i||!("prototype"in e))return e;var k=e.__bindData__;if("undefined"==typeof k&&(d.funcNames&&(k=!e.name),k=k||!d.funcDecomp,!k)){var l=h.call(e);d.funcNames||(k=!f.test(l)),k||(k=g.test(l),c(e,k))}if(k===!1||k!==!0&&1&k[1])return e;switch(j){case 1:return function(a){return e.call(i,a)};case 2:return function(a,b){return e.call(i,a,b)};case 3:return function(a,b,c){return e.call(i,a,b,c)};case 4:return function(a,b,c,d){return e.call(i,a,b,c,d)}}return a(e,i)}var f=/^\s*function[ \n\r\t]+\w/,g=/\bthis\b/,h=Function.prototype.toString;return e}),c("lodash-amd/modern/objects/forIn",["../internals/baseCreateCallback","../internals/objectTypes"],function(a,b){var c=function(c,d,e){var f,g=c,h=g;if(!g)return h;if(!b[typeof g])return h;d=d&&"undefined"==typeof e?d:a(d,e,3);for(f in g)if(d(g[f],f,c)===!1)return h;return h};return c}),c("lodash-amd/modern/internals/arrayPool",[],function(){var a=[];return a}),c("lodash-amd/modern/internals/getArray",["./arrayPool"],function(a){function b(){return a.pop()||[]}return b}),c("lodash-amd/modern/internals/maxPoolSize",[],function(){var a=40;return a}),c("lodash-amd/modern/internals/releaseArray",["./arrayPool","./maxPoolSize"],function(a,b){function c(c){c.length=0,a.length-1:void 0});return u.pop(),v.pop(),G&&(e(u),e(v)),w}var g="[object Arguments]",h="[object Array]",i="[object Boolean]",j="[object Date]",k="[object Number]",l="[object Object]",m="[object RegExp]",n="[object String]",o=Object.prototype,p=o.toString,q=o.hasOwnProperty;return f}),c("lodash-amd/modern/utilities/property",[],function(){function a(a){return function(b){return b[a]}}return a}),c("lodash-amd/modern/functions/createCallback",["../internals/baseCreateCallback","../internals/baseIsEqual","../objects/isObject","../objects/keys","../utilities/property"],function(a,b,c,d,e){function f(f,g,h){var i=typeof f;if(null==f||"function"==i)return a(f,g,h);if("object"!=i)return e(f);var j=d(f),k=j[0],l=f[k];return 1!=j.length||l!==l||c(l)?function(a){for(var c=j.length,d=!1;c--&&(d=b(a[j[c]],f[j[c]],null,!0)););return d}:function(a){var b=a[k];return l===b&&(0!==l||1/l==1/b)}}return f}),c("lodash-amd/modern/objects/forOwn",["../internals/baseCreateCallback","./keys","../internals/objectTypes"],function(a,b,c){var d=function(d,e,f){var g,h=d,i=h;if(!h)return i;if(!c[typeof h])return i;e=e&&"undefined"==typeof f?e:a(e,f,3);for(var j=-1,k=c[typeof h]&&b(h),l=k?k.length:0;++j0){var b=document.createElement(f.nodeName);a.forEach(function(a){b.appendChild(a)}),f.parentNode.insertBefore(b,f.nextElementSibling)}}if(this.queryState()){var d=new a.api.Selection,e=d.range,f=d.getContaining(function(a){return"OL"===a.nodeName||"UL"===a.nodeName}),g=d.getContaining(function(a){return"LI"===a.nodeName});a.transactionManager.run(function(){if(g){var b=new a.api.Node(g).nextAll();c(b),d.placeMarkers();var h=document.createElement("p");h.innerHTML=g.innerHTML,f.parentNode.insertBefore(h,f.nextElementSibling),g.parentNode.removeChild(g)}else{var i=Array.prototype.map.call(f.querySelectorAll("li"),function(a){return e.intersectsNode(a)&&a}).filter(function(a){return a}),j=i.slice(-1)[0],k=new a.api.Node(j).nextAll();c(k),d.placeMarkers();var l=document.createDocumentFragment();i.forEach(function(a){var b=document.createElement("p");b.innerHTML=a.innerHTML,l.appendChild(b)}),f.parentNode.insertBefore(l,f.nextElementSibling),i.forEach(function(a){a.parentNode.removeChild(a)})}0===f.childNodes.length&&f.parentNode.removeChild(f),d.selectMarkers()}.bind(this))}else a.api.Command.prototype.execute.call(this,b)},b.prototype.queryEnabled=function(){return a.api.Command.prototype.queryEnabled.call(this)&&a.allowsBlockElements()},a.commands.insertOrderedList=new b("insertOrderedList"),a.commands.insertUnorderedList=new b("insertUnorderedList")}}}),c("plugins/core/commands/outdent",[],function(){return function(){return function(a){var b=new a.api.Command("outdent");b.queryEnabled=function(){var b=new a.api.Selection,c=b.getContaining(function(a){return"UL"===a.nodeName||"OL"===a.nodeName});return a.api.Command.prototype.queryEnabled.call(this)&&a.allowsBlockElements()&&!c},a.commands.outdent=b}}}),c("plugins/core/commands/redo",[],function(){return function(){return function(a){var b=new a.api.Command("redo");b.execute=function(){var b=a.undoManager.redo();"undefined"!=typeof b&&a.restoreFromHistory(b)},b.queryEnabled=function(){return a.undoManager.position1},a.commands.undo=b,a.el.addEventListener("keydown",function(a){a.shiftKey||!a.metaKey&&!a.ctrlKey||90!==a.keyCode||(a.preventDefault(),b.execute())})}}}),c("plugins/core/commands",["./commands/indent","./commands/insert-list","./commands/outdent","./commands/redo","./commands/subscript","./commands/superscript","./commands/undo"],function(a,b,c,d,e,f,g){return{indent:a,insertList:b,outdent:c,redo:d,subscript:e,superscript:f,undo:g}}),c("lodash-amd/modern/internals/baseIndexOf",[],function(){function a(a,b,c){for(var d=(c||0)-1,e=a?a.length:0;++dh?f(0,k+h):h)||0,c(e)?l=j(e,g,h)>-1:"number"==typeof k?l=(d(e)?e.indexOf(g,h):j(e,g,h))>-1:b(e,function(a){return++i>=h?!(l=a===g):void 0}),l}var f=Math.max;return e}),c("lodash-amd/modern/objects/values",["./keys"],function(a){function b(b){for(var c=-1,d=a(b),e=d.length,f=Array(e);++c0;)a.insertBefore(b.childNodes[0],b);a.removeChild(b)}var e=["P","LI","DIV","BLOCKQUOTE","UL","OL","H1","H2","H3","H4","H5","H6"];return{isBlockElement:b,isSelectionMarkerNode:c,unwrap:d}}),c("scribe-common/src/node",[],function(){function a(a){return a.nodeType===Node.TEXT_NODE&&""===a.textContent}function b(a,b){return b.parentNode.insertBefore(a,b.nextSibling)}function c(a){return a.parentNode.removeChild(a)}return{isEmptyTextNode:a,insertAfter:b,removeNode:c}}),c("dom-observer",["lodash-amd/modern/arrays/flatten","lodash-amd/modern/collections/toArray","scribe-common/src/element","scribe-common/src/node"],function(a,b,c,d){function e(e,f){function g(e){var f=a(e.map(function(a){var c=b(a.addedNodes),d=b(a.removedNodes);return c.concat(d)})),g=f.filter(function(a){return!d.isEmptyTextNode(a)}).filter(function(a){return!c.isSelectionMarkerNode(a)});return g.length>0}var h=!1,i=new MutationObserver(function(a){if(!h&&g(a)){h=!0;try{f()}finally{setTimeout(function(){h=!1},0)}}});return i.observe(e,{attributes:!0,childList:!0,subtree:!0}),i}return e}),c("plugins/core/events",["lodash-amd/modern/collections/contains","../../dom-observer"],function(a,b){return function(){return function(c){function d(){var a=navigator.userAgent;return a.search("Safari")>=0&&a.search("Chrome")<0}var e=function(){setTimeout(function(){c.pushHistory()}.bind(c),0),c.el.removeEventListener("focus",e)}.bind(c);c.el.addEventListener("focus",e),c.el.addEventListener("focus",function(){function a(b){var c=document.createTreeWalker(b),d=c.currentNode;return c.firstChild()?"BR"===c.currentNode.nodeName?d:a(c.currentNode):c.currentNode}var b=new c.api.Selection;if(b.range){var d=c.allowsBlockElements()&&b.range.startContainer===c.el;if(d){var e=a(c.el.firstChild),f=b.range;f.setStart(e,0),f.setEnd(e,0),b.selection.removeAllRanges(),b.selection.addRange(f)}}}.bind(c));var f=function(){if(!c._skipFormatters){var a=new c.api.Selection,b=a.range,d=function(){b&&a.placeMarkers(),c.setHTML(c._htmlFormatterFactory.format(c.getHTML())),a.selectMarkers()}.bind(c);b?(c.undoManager.undo(),c.transactionManager.run(d)):d()}delete c._skipFormatters}.bind(c);b(c.el,f),c.allowsBlockElements()&&c.el.addEventListener("keydown",function(a){if(13===a.keyCode){var b=new c.api.Selection,d=b.range,e=b.getContaining(function(a){return/^(H[1-6])$/.test(a.nodeName)});if(e&&d.collapsed){var f=d.cloneRange();f.setEndAfter(e,0);var g=f.cloneContents();""===g.firstChild.textContent&&(a.preventDefault(),c.transactionManager.run(function(){var a=document.createElement("p"),c=document.createElement("br");a.appendChild(c),e.parentNode.insertBefore(a,e.nextElementSibling),d.setStart(a,0),d.setEnd(a,0),b.selection.removeAllRanges(),b.selection.addRange(d)}))}}}),c.allowsBlockElements()&&c.el.addEventListener("keydown",function(a){if(13===a.keyCode||8===a.keyCode){var b=new c.api.Selection,d=b.range;if(d.collapsed){var e=b.getContaining(function(a){return"LI"===a.nodeName});if(e&&""===e.textContent.trim()){a.preventDefault();var f=b.getContaining(function(a){return"UL"===a.nodeName||"OL"===a.nodeName}),g=c.getCommand("OL"===f.nodeName?"insertOrderedList":"insertUnorderedList");g.execute()}}}}),c.el.addEventListener("paste",function(b){if(!b.clipboardData||!a(b.clipboardData.types,"text/html")&&d()){var e=new c.api.Selection;e.placeMarkers();var f=document.createElement("div");document.body.appendChild(f),f.setAttribute("contenteditable",!0),f.focus(),setTimeout(function(){var a=f.innerHTML;f.parentNode.removeChild(f),e.selectMarkers(),c.el.focus(),a=c._htmlFormatterFactory.formatPaste(a),c.insertHTML(a)},1)}else if(b.preventDefault(),a(b.clipboardData.types,"text/html")){var g=b.clipboardData.getData("text/html");g=c._htmlFormatterFactory.formatPaste(g),c.insertHTML(g)}else c.insertPlainText(b.clipboardData.getData("text/plain"))})}}}),c("plugins/core/formatters/html/replace-nbsp-chars",[],function(){return function(){return function(a){var b=/(\s| )+/g;a.registerHTMLFormatter("export",function(a){return a.replace(b," ")})}}}),c("lodash-amd/modern/arrays/last",["../functions/createCallback","../internals/slice"],function(a,b){function c(c,f,g){var h=0,i=c?c.length:0;if("number"!=typeof f&&null!=f){var j=i;for(f=a(f,g,3);j--&&f(c[j],j,c);)h++}else if(h=f,null==h||g)return c?c[i-1]:d;return b(c,e(0,i-h))}var d,e=Math.max;return c}),c("plugins/core/formatters/html/enforce-p-elements",["lodash-amd/modern/arrays/last","scribe-common/src/element"],function(a,b){function c(c){var d=Array.prototype.reduce.call(c.childNodes,function(c,d){function e(){var a=[d];c.push(a)}var f=a(c);if(f){var g=b.isBlockElement(f[0]);g===b.isBlockElement(d)?f.push(d):e()}else e();return c},[]),e=d.filter(function(a){var c=b.isBlockElement(a[0]);return!c});e.forEach(function(a){var b=document.createElement("p");a[0].parentNode.insertBefore(b,a[0]),a.forEach(function(a){b.appendChild(a)})}),c._isWrapped=!0}function d(a){for(var b=document.createTreeWalker(a,NodeFilter.SHOW_ELEMENT),e=b.firstChild();e;){if("BLOCKQUOTE"===e.nodeName&&!e._isWrapped){c(e),d(a);break}e=b.nextSibling()}}return function(){return function(a){a.registerHTMLFormatter("normalize",function(a){var b=document.createElement("div");return b.innerHTML=a,c(b),d(b),b.innerHTML})}}}),c("plugins/core/formatters/html/ensure-selectable-containers",["scribe-common/src/element","lodash-amd/modern/collections/contains"],function(a,b){function c(e){function f(b){return 0===b.children.length||1===b.children.length&&a.isSelectionMarkerNode(b.children[0])}for(var g=e.firstElementChild;g;)a.isSelectionMarkerNode(g)||(f(g)&&""===g.textContent.trim()&&!b(d,g.nodeName)?g.appendChild(document.createElement("br")):g.children.length>0&&c(g)),g=g.nextElementSibling}var d=["AREA","BASE","BR","COL","COMMAND","EMBED","HR","IMG","INPUT","KEYGEN","LINK","META","PARAM","SOURCE","TRACK","WBR"];return function(){return function(a){a.registerHTMLFormatter("normalize",function(a){var b=document.createElement("div");return b.innerHTML=a,c(b),b.innerHTML})}}}),c("lodash-amd/modern/internals/htmlEscapes",[],function(){var a={"&":"&","<":"<",">":">",'"':""","'":"'"};return a}),c("lodash-amd/modern/internals/escapeHtmlChar",["./htmlEscapes"],function(a){function b(b){return a[b]}return b}),c("lodash-amd/modern/internals/reUnescapedHtml",["./htmlEscapes","../objects/keys"],function(a,b){var c=RegExp("["+b(a).join("")+"]","g");return c}),c("lodash-amd/modern/utilities/escape",["../internals/escapeHtmlChar","../objects/keys","../internals/reUnescapedHtml"],function(a,b,c){function d(b){return null==b?"":String(b).replace(c,a)}return d}),c("plugins/core/formatters/plain-text/escape-html-characters",["lodash-amd/modern/utilities/escape"],function(a){return function(){return function(b){b.registerPlainTextFormatter(a)}}}),c("plugins/core/inline-elements-mode",[],function(){function a(a){for(var b=document.createTreeWalker(a);b.nextNode();)if(b.currentNode&&(~["br"].indexOf(b.currentNode.nodeName.toLowerCase())||b.currentNode.length>0))return!0;return!1}return function(){return function(b){b.el.addEventListener("keydown",function(c){if(13===c.keyCode){var d=new b.api.Selection,e=d.range,f=d.getContaining(function(a){return"LI"===a.nodeName||/^(H[1-6])$/.test(a.nodeName)});f||(c.preventDefault(),b.transactionManager.run(function(){"BR"===b.el.lastChild.nodeName&&b.el.removeChild(b.el.lastChild);var c=document.createElement("br");e.insertNode(c),e.collapse(!1);var f=e.cloneRange();f.setEndAfter(b.el.lastChild,0);var g=f.cloneContents();if(!a(g)){var h=document.createElement("br");e.insertNode(h)}var i=e.cloneRange();i.setStartAfter(c,0),i.setEndAfter(c,0),d.selection.removeAllRanges(),d.selection.addRange(i)}))}}.bind(this)),""===b.getHTML().trim()&&b.setContent("")}}}),c("plugins/core/patches/commands/indent",[],function(){var a="\ufeff";return function(){return function(b){var c=new b.api.CommandPatch("indent");c.execute=function(c){b.transactionManager.run(function(){var d=new b.api.Selection,e=d.range,f="P"===e.commonAncestorContainer.nodeName&&"
"===e.commonAncestorContainer.innerHTML;if(f){var g=document.createTextNode(a);e.insertNode(g),e.setStart(g,0),e.setEnd(g,0),d.selection.removeAllRanges(),d.selection.addRange(e)}b.api.CommandPatch.prototype.execute.call(this,c),d=new b.api.Selection;var h=d.getContaining(function(a){return"BLOCKQUOTE"===a.nodeName});h&&h.removeAttribute("style")}.bind(this))},b.commandPatches.indent=c}}}),c("plugins/core/patches/commands/insert-html",["scribe-common/src/element"],function(a){return function(){return function(b){var c=new b.api.CommandPatch("insertHTML");c.execute=function(c){b.transactionManager.run(function(){function d(b){var c=document.createTreeWalker(b,NodeFilter.SHOW_ELEMENT),e=c.firstChild();if(e)do"SPAN"===e.nodeName?a.unwrap(b,e):(e.style.lineHeight=null,""===e.getAttribute("style")&&e.removeAttribute("style")),d(e);while(e=c.nextSibling())}b.api.CommandPatch.prototype.execute.call(this,c),d(b.el)}.bind(this))},b.commandPatches.insertHTML=c}}}),c("plugins/core/patches/commands/insert-list",["scribe-common/src/element","scribe-common/src/node"],function(a,b){return function(){return function(c){var d=function(a){c.api.CommandPatch.call(this,a)};d.prototype=Object.create(c.api.CommandPatch.prototype),d.prototype.constructor=d,d.prototype.execute=function(d){c.transactionManager.run(function(){if(c.api.CommandPatch.prototype.execute.call(this,d),this.queryState()){var e=new c.api.Selection,f=e.getContaining(function(a){return"OL"===a.nodeName||"UL"===a.nodeName});if(f.nextElementSibling&&0===f.nextElementSibling.childNodes.length&&b.removeNode(f.nextElementSibling),f){var g=f.parentNode;g&&/^(H[1-6]|P)$/.test(g.nodeName)&&(e.placeMarkers(),b.insertAfter(f,g),e.selectMarkers(),2===g.childNodes.length&&b.isEmptyTextNode(g.firstChild)&&b.removeNode(g),0===g.childNodes.length&&b.removeNode(g))}var h=Array.prototype.slice.call(f.childNodes);h.forEach(function(b){var c=Array.prototype.slice.call(b.childNodes);c.forEach(function(c){if("SPAN"===c.nodeName){var d=c;a.unwrap(b,d)}else c.nodeType===Node.ELEMENT_NODE&&(c.style.lineHeight=null,""===c.getAttribute("style")&&c.removeAttribute("style"))})})}}.bind(this))},c.commandPatches.insertOrderedList=new d("insertOrderedList"),c.commandPatches.insertUnorderedList=new d("insertUnorderedList")}}}),c("plugins/core/patches/commands/outdent",[],function(){return function(){return function(a){var b=new a.api.CommandPatch("outdent");b.execute=function(){a.transactionManager.run(function(){var b=new a.api.Selection,c=b.range,d=b.getContaining(function(a){return"BLOCKQUOTE"===a.nodeName});if("BLOCKQUOTE"===c.commonAncestorContainer.nodeName){b.placeMarkers(),b.selectMarkers(!0);var e=c.cloneContents();d.parentNode.insertBefore(e,d),c.deleteContents(),b.selectMarkers(),""===d.textContent&&d.parentNode.removeChild(d)}else{var f=b.getContaining(function(a){return"P"===a.nodeName});if(f){var g=new a.api.Node(f).nextAll();if(g.length){var h=document.createElement(d.nodeName);g.forEach(function(a){h.appendChild(a)}),d.parentNode.insertBefore(h,d.nextElementSibling)}b.placeMarkers(),d.parentNode.insertBefore(f,d.nextElementSibling),b.selectMarkers(),""===d.innerHTML&&d.parentNode.removeChild(d)}else a.api.CommandPatch.prototype.execute.call(this)}}.bind(this))},a.commandPatches.outdent=b}}}),c("plugins/core/patches/commands/create-link",[],function(){return function(){return function(a){var b=new a.api.CommandPatch("createLink");a.commandPatches.createLink=b,b.execute=function(b){var c=new a.api.Selection;if(c.selection.isCollapsed){var d=document.createElement("a");d.setAttribute("href",b),d.textContent=b,c.range.insertNode(d);var e=document.createRange();e.setStartBefore(d),e.setEndAfter(d),c.selection.removeAllRanges(),c.selection.addRange(e)}else a.api.CommandPatch.prototype.execute.call(this,b)}}}}),c("plugins/core/patches/events",["scribe-common/src/element"],function(a){return function(){return function(b){b.allowsBlockElements()&&b.el.addEventListener("keyup",function(c){if(8===c.keyCode||46===c.keyCode){var d=new b.api.Selection,e=d.getContaining(function(a){return"P"===a.nodeName});e&&(b.undoManager.undo(),b.transactionManager.run(function(){d.placeMarkers();var b=Array.prototype.slice.call(e.childNodes);b.forEach(function(b){if("SPAN"===b.nodeName){var c=b;a.unwrap(e,c)}else b.nodeType===Node.ELEMENT_NODE&&(b.style.lineHeight=null,""===b.getAttribute("style")&&b.removeAttribute("style"))}),d.selectMarkers()}))}})}}}),c("plugins/core/patches",["./patches/commands/indent","./patches/commands/insert-html","./patches/commands/insert-list","./patches/commands/outdent","./patches/commands/create-link","./patches/events"],function(a,b,c,d,e,f){return{commands:{indent:a,insertHTML:b,insertList:c,outdent:d,createLink:e},events:f}}),c("plugins/core/set-root-p-element",[],function(){return function(){return function(a){""===a.getHTML().trim()&&a.setContent("


")}}}),c("api/command-patch",[],function(){return function(a){function b(a){this.commandName=a}return b.prototype.execute=function(b){a.transactionManager.run(function(){document.execCommand(this.commandName,!1,b||null)}.bind(this))},b.prototype.queryState=function(){return"insertOrderedList"===this.commandName||"insertUnorderedList"==this.commandName?!1:document.queryCommandState(this.commandName)},b.prototype.queryEnabled=function(){return document.queryCommandEnabled(this.commandName)},b}}),c("api/command",[],function(){return function(a){function b(b){this.commandName=b,this.patch=a.commandPatches[this.commandName]}return b.prototype.execute=function(b){this.patch?this.patch.execute(b):a.transactionManager.run(function(){document.execCommand(this.commandName,!1,b||null)}.bind(this))},b.prototype.queryState=function(){return this.patch?this.patch.queryState():document.queryCommandState(this.commandName)},b.prototype.queryEnabled=function(){return this.patch?this.patch.queryEnabled():document.queryCommandEnabled(this.commandName)},b}}),c("api/node",[],function(){function a(a){this.node=a}return a.prototype.getAncestor=function(a){var b=function(a){return a&&a.attributes&&a.attributes.getNamedItem("contenteditable")};if(!b(this.node))for(var c=this.node.parentNode;c&&!b(c);){if(a(c))return c; -c=c.parentNode}},a.prototype.nextAll=function(){for(var a=[],b=this.node.nextSibling;b;)a.push(b),b=b.nextSibling;return a},a}),c("api/selection",[],function(){return function(a){function b(){this.selection=window.getSelection(),this.selection.rangeCount&&(this.range=this.selection.getRangeAt(0))}return b.prototype.getContaining=function(b){if(this.range){var c=new a.api.Node(this.range.commonAncestorContainer),d=c.node&&c.node.attributes&&c.node.attributes.getNamedItem("contenteditable");return!d&&b(c.node)?c.node:c.getAncestor(b)}},b.prototype.placeMarkers=function(){if(this.range){var a=document.createElement("em");a.classList.add("scribe-marker");var b=document.createElement("em");b.classList.add("scribe-marker");var c=this.range.cloneRange();if(c.collapse(!1),c.insertNode(b),b.nextSibling&&b.nextSibling.nodeType===Node.TEXT_NODE&&""===b.nextSibling.data&&b.parentNode.removeChild(b.nextSibling),b.previousSibling&&b.previousSibling.nodeType===Node.TEXT_NODE&&""===b.previousSibling.data&&b.parentNode.removeChild(b.previousSibling),!this.selection.isCollapsed){var d=this.range.cloneRange();d.collapse(!0),d.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.selection.removeAllRanges(),this.selection.addRange(this.range)}},b.prototype.getMarkers=function(){return a.el.querySelectorAll("em.scribe-marker")},b.prototype.removeMarkers=function(){var a=this.getMarkers();Array.prototype.forEach.call(a,function(a){a.parentNode.removeChild(a)})},b.prototype.selectMarkers=function(a){var b=this.getMarkers();if(b.length){var c=document.createRange();c.setStartBefore(b[0]),b.length>=2?c.setEndAfter(b[1]):c.setEndAfter(b[0]),a||this.removeMarkers(),this.selection.removeAllRanges(),this.selection.addRange(c)}},b.prototype.isCaretOnNewLine=function(){var a=this.getContaining(function(a){return"P"===a.nodeName});if(a){var b=a.innerHTML.trim();return"P"===a.nodeName&&("
"===b||""===b)}return!1},b}}),c("api/simple-command",[],function(){return function(a,b){function c(a,c){b.api.Command.call(this,a),this.nodeName=c}return c.prototype=Object.create(a.Command.prototype),c.prototype.constructor=c,c.prototype.queryState=function(){var a=new b.api.Selection;return b.api.Command.prototype.queryState.call(this)&&!!a.getContaining(function(a){return a.nodeName===this.nodeName}.bind(this))},c}}),c("api",["./api/command-patch","./api/command","./api/node","./api/selection","./api/simple-command"],function(a,b,c,d,e){return function(f){this.CommandPatch=a(f),this.Command=b(f),this.Node=c,this.Selection=d(f),this.SimpleCommand=e(this,f)}}),c("lodash-amd/modern/objects/assign",["../internals/baseCreateCallback","./keys","../internals/objectTypes"],function(a,b,c){var d=function(d,e,f){var g,h=d,i=h;if(!h)return i;var j=arguments,k=0,l="number"==typeof f?2:j.length;if(l>3&&"function"==typeof j[l-2])var m=a(j[--l-1],j[l--],2);else l>2&&"function"==typeof j[l-1]&&(m=j[--l]);for(;++kthis.maxStackSize;)this.stack.shift(),--this.position},b.prototype.undo=function(){return this.position>0?this.stack[--this.position]:void 0},b.prototype.redo=function(){return this.position$/,""))},p.prototype.getTextContent=function(){return this.el.textContent},p.prototype.pushHistory=function(){var a=this.undoManager.stack[this.undoManager.position],b=a&&a.replace(//g,"").replace(/<\/em>/g,"");if(!a||a&&this.getContent()!==b){var c=new this.api.Selection;c.placeMarkers();var d=this.getHTML();return c.removeMarkers(),this.undoManager.push(d),!0}return!1},p.prototype.getCommand=function(a){return this.commands[a]||this.commandPatches[a]||new this.api.Command(a)},p.prototype.restoreFromHistory=function(a){this.setHTML(a,!0);var b=new this.api.Selection;b.selectMarkers(),this.trigger("content-changed")},p.prototype.allowsBlockElements=function(){return this.options.allowBlockElements},p.prototype.setContent=function(a){this.allowsBlockElements()||(a+="
"),this.setHTML(a),this.trigger("content-changed")},p.prototype.insertPlainText=function(a){this.insertHTML("

"+this._plainTextFormatterFactory.format(a)+"

")},p.prototype.insertHTML=function(a){this.getCommand("insertHTML").execute(this._htmlFormatterFactory.format(a))},p.prototype.isDebugModeEnabled=function(){return this.options.debug},p.prototype.registerHTMLFormatter=function(a,b){this._htmlFormatterFactory.formatters[a].push(b)},p.prototype.registerPlainTextFormatter=function(a){this._plainTextFormatterFactory.formatters.push(a)},q.prototype.format=function(a){var b=this.formatters.reduce(function(a,b){return b(a)},a);return b},r.prototype=Object.create(q.prototype),r.prototype.constructor=r,r.prototype.format=function(a){var c=b([this.formatters.sanitize,this.formatters.normalize]),d=c.reduce(function(a,b){return b(a)},a);return d},r.prototype.formatPaste=function(a){return this.formatters.paste.reduce(function(a,b){return b(a)},a)},r.prototype.formatForExport=function(a){return this.formatters["export"].reduce(function(a,b){return b(a)},a)},p}),c("scribe-plugin-blockquote-command",[],function(){return function(){return function(a){var b=new a.api.SimpleCommand("blockquote","BLOCKQUOTE");b.execute=function(){var b=a.getCommand(this.queryState()?"outdent":"indent");b.execute()},b.queryEnabled=function(){var b=a.getCommand(this.queryState()?"outdent":"indent");return b.queryEnabled()},b.queryState=function(){var b=new a.api.Selection,c=b.getContaining(function(a){return"BLOCKQUOTE"===a.nodeName});return a.allowsBlockElements()&&!!c},a.commands.blockquote=b,a.allowsBlockElements()&&a.el.addEventListener("keydown",function(b){if(13===b.keyCode){var c=a.getCommand("blockquote");if(c.queryState()){var d=new a.api.Selection;d.isCaretOnNewLine()&&(b.preventDefault(),c.execute())}}})}}}),c("scribe-plugin-curly-quotes",[],function(){return function(){var a={34:'"',39:"'"},b="“",c="”",d="‘",e="’";return function(f){function g(g){var i,j=a[g.charCode];'"'===j?i=h()?c:b:"'"===j&&(i=h()?e:d),i&&(g.preventDefault(),f.transactionManager.run(function(){var a=k(i);l(a)}))}function h(){var a=i()||"";return j(a)}function i(){var a=new f.api.Selection,b=a.range.commonAncestorContainer.textContent;return b[a.range.startOffset-1]}function j(a){return/[^\s()]/.test(a)}function k(a){var b=document.createTextNode(a),c=new f.api.Selection;return c.range.deleteContents(),c.range.insertNode(b),b}function l(a){var b=document.createRange();b.setStartAfter(a),b.setEndAfter(a);var c=new f.api.Selection;c.selection.removeAllRanges(),c.selection.addRange(b)}function m(a){var f=document.createElement("div");return f.innerHTML=a,o(f,function(a){var f=a.split(/(<[^>]+?>)/);return f.map(function(a){return"<"===a[0]?a:a.replace(/([\s\S])?'([\s\S])?/g,n(d,e)).replace(/([\s\S])?"([\s\S])?/g,n(b,c))}).join("")}),f.innerHTML}function n(a,b){return function(c,d,e){d=d||"",e=e||"";var f=!d,g=!e,h=j(d),i=j(e);return h||f&&!i&&!g?d+b+e:d+a+e}}function o(a,b){var c=document.createTreeWalker(a,NodeFilter.SHOW_TEXT),d=c.firstChild();if(d)do d.data=b(d.data);while(d=c.nextSibling());return d}f.el.addEventListener("keypress",g),f.registerHTMLFormatter("normalize",m)}}}),c("scribe-plugin-formatter-plain-text-convert-new-lines-to-html",[],function(){return function(){return function(a){a.registerPlainTextFormatter(function(a){return a.replace(/\n([ \t]*\n)+/g,"

").replace(/\n/g,"
")})}}}),c("scribe-plugin-heading-command",[],function(){return function(a){return function(b){var c="",d="H"+a,e="h"+a,f=new b.api.Command("formatBlock");f.execute=function(){this.queryState()?b.api.Command.prototype.execute.call(this,"

"):b.api.Command.prototype.execute.call(this,c)},f.queryState=function(){var a=new b.api.Selection;return!!a.getContaining(function(a){return a.nodeName===d})},f.queryEnabled=function(){var a=new b.api.Selection,c=a.getContaining(function(a){return"OL"===a.nodeName||"UL"===a.nodeName});return b.api.Command.prototype.queryEnabled.apply(this,arguments)&&b.allowsBlockElements()&&!c},b.commands[e]=f}}}),c("scribe-plugin-intelligent-unlink-command",[],function(){return function(){return function(a){var b=new a.api.Command("unlink");b.execute=function(){var b=new a.api.Selection;b.selection.isCollapsed?a.transactionManager.run(function(){var c=b.getContaining(function(a){return"A"===a.nodeName});c&&new a.api.Element(c.parentNode).unwrap(c)}.bind(this)):a.api.Command.prototype.execute.apply(this,arguments)},b.queryEnabled=function(){var b=new a.api.Selection;return b.selection.isCollapsed?!!b.getContaining(function(a){return"A"===a.nodeName}):a.api.Command.prototype.queryEnabled.apply(this,arguments)},a.commands.unlink=b}}}),c("lodash-amd/modern/internals/isNative",[],function(){function a(a){return"function"==typeof a&&d.test(a)}var b=Object.prototype,c=b.toString,d=RegExp("^"+String(c).replace(/[.*+?^${}()|[\]\\]/g,"\\$&").replace(/toString| for [^\]]+/g,".*?")+"$");return a}),c("lodash-amd/modern/internals/objectTypes",[],function(){var a={"boolean":!1,"function":!0,object:!0,number:!1,string:!1,undefined:!1};return a}),c("lodash-amd/modern/objects/isObject",["../internals/objectTypes"],function(a){function b(b){return!(!b||!a[typeof b])}return b}),c("lodash-amd/modern/utilities/noop",[],function(){function a(){}return a}),c("lodash-amd/modern/internals/baseCreate",["./isNative","../objects/isObject","../utilities/noop"],function(a,b,c){function d(a,c){return b(a)?e(a):{}}var e=a(e=Object.create)&&e;return e||(d=function(){function a(){}return function(c){if(b(c)){a.prototype=c;var d=new a;a.prototype=null}return d||window.Object()}}()),d}),c("lodash-amd/modern/internals/setBindData",["./isNative","../utilities/noop"],function(a,b){var c={configurable:!1,enumerable:!1,value:null,writable:!1},d=function(){try{var b={},c=a(c=Object.defineProperty)&&c,d=c(b,b,b)&&c}catch(e){}return d}(),e=d?function(a,b){c.value=b,d(a,"__bindData__",c)}:b;return e}),c("lodash-amd/modern/internals/slice",[],function(){function a(a,b,c){b||(b=0),"undefined"==typeof c&&(c=a?a.length:0);for(var d=-1,e=c-b||0,f=Array(0>e?0:e);++d2?a(c,17,b(arguments,2),null,d):a(c,1,null,null,d)}return c}),c("lodash-amd/modern/utilities/identity",[],function(){function a(a){return a}return a}),c("lodash-amd/modern/support",["./internals/isNative"],function(a){var b=/\bthis\b/,c={};return c.funcDecomp=!a(window.WinRTError)&&b.test(function(){return this}),c.funcNames="string"==typeof Function.name,c}),c("lodash-amd/modern/internals/baseCreateCallback",["../functions/bind","../utilities/identity","./setBindData","../support"],function(a,b,c,d){function e(e,i,j){if("function"!=typeof e)return b;if("undefined"==typeof i||!("prototype"in e))return e;var k=e.__bindData__;if("undefined"==typeof k&&(d.funcNames&&(k=!e.name),k=k||!d.funcDecomp,!k)){var l=h.call(e);d.funcNames||(k=!f.test(l)),k||(k=g.test(l),c(e,k))}if(k===!1||k!==!0&&1&k[1])return e;switch(j){case 1:return function(a){return e.call(i,a)};case 2:return function(a,b){return e.call(i,a,b)};case 3:return function(a,b,c){return e.call(i,a,b,c)};case 4:return function(a,b,c,d){return e.call(i,a,b,c,d)}}return a(e,i)}var f=/^\s*function[ \n\r\t]+\w/,g=/\bthis\b/,h=Function.prototype.toString;return e}),c("lodash-amd/modern/objects/forIn",["../internals/baseCreateCallback","../internals/objectTypes"],function(a,b){var c=function(c,d,e){var f,g=c,h=g;if(!g)return h;if(!b[typeof g])return h;d=d&&"undefined"==typeof e?d:a(d,e,3);for(f in g)if(d(g[f],f,c)===!1)return h;return h};return c}),c("lodash-amd/modern/internals/arrayPool",[],function(){var a=[];return a}),c("lodash-amd/modern/internals/getArray",["./arrayPool"],function(a){function b(){return a.pop()||[]}return b}),c("lodash-amd/modern/internals/maxPoolSize",[],function(){var a=40;return a}),c("lodash-amd/modern/internals/releaseArray",["./arrayPool","./maxPoolSize"],function(a,b){function c(c){c.length=0,a.length-1:void 0});return u.pop(),v.pop(),G&&(e(u),e(v)),w}var g="[object Arguments]",h="[object Array]",i="[object Boolean]",j="[object Date]",k="[object Number]",l="[object Object]",m="[object RegExp]",n="[object String]",o=Object.prototype,p=o.toString,q=o.hasOwnProperty;return f}),c("lodash-amd/modern/internals/shimKeys",["./objectTypes"],function(a){var b=Object.prototype,c=b.hasOwnProperty,d=function(b){var d,e=b,f=[];if(!e)return f;if(!a[typeof b])return f;for(d in e)c.call(e,d)&&f.push(d);return f};return d}),c("lodash-amd/modern/objects/keys",["../internals/isNative","./isObject","../internals/shimKeys"],function(a,b,c){var d=a(d=Object.keys)&&d,e=d?function(a){return b(a)?d(a):[]}:c;return e}),c("lodash-amd/modern/utilities/property",[],function(){function a(a){return function(b){return b[a]}}return a}),c("lodash-amd/modern/functions/createCallback",["../internals/baseCreateCallback","../internals/baseIsEqual","../objects/isObject","../objects/keys","../utilities/property"],function(a,b,c,d,e){function f(f,g,h){var i=typeof f;if(null==f||"function"==i)return a(f,g,h);if("object"!=i)return e(f);var j=d(f),k=j[0],l=f[k];return 1!=j.length||l!==l||c(l)?function(a){for(var c=j.length,d=!1;c--&&(d=b(a[j[c]],f[j[c]],null,!0)););return d}:function(a){var b=a[k];return l===b&&(0!==l||1/l==1/b)}}return f}),c("lodash-amd/modern/objects/forOwn",["../internals/baseCreateCallback","./keys","../internals/objectTypes"],function(a,b,c){var d=function(d,e,f){var g,h=d,i=h;if(!h)return i;if(!c[typeof h])return i;e=e&&"undefined"==typeof f?e:a(e,f,3);for(var j=-1,k=c[typeof h]&&b(h),l=k?k.length:0;++j-1||a.indexOf("/")>-1||a.indexOf("www")>-1||a.indexOf("http://")>-1||a.indexOf("https://")>-1||""===a?!1:!0}function e(a){c(),k.show(),a.addClass("link-edit"),setTimeout(function(){$("body, .link-tools .close").bind("click",f),l.val(a.attr("href").replace(m,"")),l[0].focus()},10)}function f(a){0===$(a.target).closest(".link-tools").length&&g()}function g(){b.updateContents(function(){var a=l.val();""===a?h():$(".link-edit, [href="+m+"]").attr("href",a).removeClass("link-edit")},!1),$("body, .link-tools .close").unbind("click"),k.hide()}function h(){var a=$(".link-edit, [href*="+m+"]");a[0].outerHTML=a[0].innerHTML}var i=b.el.parentNode,j=new b.api.Command("createLink"),k=$(".link-tools",i),l=$(".link-tools input",i),m="#replaceme",n=$(".search-results",k),o=a.searchHandler||function(a,b){};j.nodeName="A",j.execute=function(){var a=this,c=new b.api.Selection;c.range.collapsed||(b._skipFormatters=!0,b.api.SimpleCommand.prototype.execute.call(a,m),e($("a[href*="+m+"]")))},$(".remove",k).click(function(){l.val(""),g()}),$(".ok",k).click(g),n.click(function(a){var b=$(a.target).closest("a");1===b.length&&(a.preventDefault(),l.val(b.attr("href")),c())}),l.bind("keyup",c).bind("keydown",function(a){(13===a.keyCode||27===a.keyCode)&&g()}),b.el.addEventListener("click",function(a){var c=(new b.api.Selection,$(a.target).closest("a"));1===c.length&&(e(c),a.preventDefault())});var p;j.queryState=function(){var a=new b.api.Selection;return!!a.getContaining(function(a){return a.nodeName===this.nodeName}.bind(this))},b.commands.linkUI=j}}}),function(a,b){"function"==typeof c&&c.amd?c("html-janitor",b):a.amdWeb=b()}(this,function(){function a(a){this.config=a}function b(a){return-1!==e.indexOf(a.nodeName)}function c(a){return-1!==f.indexOf(a.nodeName)}function d(a){return document.createTreeWalker(a,NodeFilter.SHOW_TEXT|NodeFilter.SHOW_ELEMENT|NodeFilter.SHOW_COMMENT)}var e=["P","LI","DIV"],f=["A","B","DEL","I","U"];return a.prototype.clean=function(a){var b=document.createElement("div");return b.innerHTML=a,this._sanitize(b),b.innerHTML},a.prototype._sanitize=function(a){var e=d(a),f=e.firstChild();if(f)do{var g=f.nodeName.toLowerCase(),h=this.config.tags[g];if(!f._sanitized){if(this.config.skipSanitization(f))return;if(f.nodeType!==Node.TEXT_NODE){if(f.nodeType===Node.COMMENT_NODE){a.removeChild(f),this._sanitize(a);break}var i,j=c(f);j&&(i=Array.prototype.some.call(f.childNodes,b));var k=j&&i,l=!!a.parentNode,m=b(a)&&b(f)&&l;if(!this.config.tags[g]||k||m){if("SCRIPT"!==f.nodeName&&"STYLE"!==f.nodeName)for(;f.childNodes.length>0;)a.insertBefore(f.childNodes[0],f);a.removeChild(f),this._sanitize(a);break}for(var n=0;ne?0:e);++d2?a(c,17,b(arguments,2),null,d):a(c,1,null,null,d)}return c}),c("lodash-amd/modern/utilities/identity",[],function(){function a(a){return a}return a}),c("lodash-amd/modern/support",["./internals/isNative"],function(a){var b=/\bthis\b/,c={};return c.funcDecomp=!a(window.WinRTError)&&b.test(function(){return this}),c.funcNames="string"==typeof Function.name,c}),c("lodash-amd/modern/internals/baseCreateCallback",["../functions/bind","../utilities/identity","./setBindData","../support"],function(a,b,c,d){function e(e,i,j){if("function"!=typeof e)return b;if("undefined"==typeof i||!("prototype"in e))return e;var k=e.__bindData__;if("undefined"==typeof k&&(d.funcNames&&(k=!e.name),k=k||!d.funcDecomp,!k)){var l=h.call(e);d.funcNames||(k=!f.test(l)),k||(k=g.test(l),c(e,k))}if(k===!1||k!==!0&&1&k[1])return e;switch(j){case 1:return function(a){return e.call(i,a)};case 2:return function(a,b){return e.call(i,a,b)};case 3:return function(a,b,c){return e.call(i,a,b,c)};case 4:return function(a,b,c,d){return e.call(i,a,b,c,d)}}return a(e,i)}var f=/^\s*function[ \n\r\t]+\w/,g=/\bthis\b/,h=Function.prototype.toString;return e}),c("lodash-amd/modern/internals/shimKeys",["./objectTypes"],function(a){var b=Object.prototype,c=b.hasOwnProperty,d=function(b){var d,e=b,f=[];if(!e)return f;if(!a[typeof b])return f;for(d in e)c.call(e,d)&&f.push(d);return f};return d}),c("lodash-amd/modern/objects/keys",["../internals/isNative","./isObject","../internals/shimKeys"],function(a,b,c){var d=a(d=Object.keys)&&d,e=d?function(a){return b(a)?d(a):[]}:c;return e}),c("lodash-amd/modern/objects/forOwn",["../internals/baseCreateCallback","./keys","../internals/objectTypes"],function(a,b,c){var d=function(d,e,f){var g,h=d,i=h;if(!h)return i;if(!c[typeof h])return i;e=e&&"undefined"==typeof f?e:a(e,f,3);for(var j=-1,k=c[typeof h]&&b(h),l=k?k.length:0;++j3&&"function"==typeof h[i-2])var j=a(h[--i-1],h[i--],2);else i>2&&"function"==typeof h[i-1]&&(j=h[--i]);for(var k=f(arguments,1,i),l=-1,m=c(),n=c();++l3&&"function"==typeof j[l-2])var m=a(j[--l-1],j[l--],2);else l>2&&"function"==typeof j[l-1]&&(m=j[--l]);for(;++ke?0:e);++d2?a(c,17,b(arguments,2),null,d):a(c,1,null,null,d)}return c}),c("lodash-amd/modern/utilities/identity",[],function(){function a(a){return a}return a}),c("lodash-amd/modern/support",["./internals/isNative"],function(a){var b=/\bthis\b/,c={};return c.funcDecomp=!a(window.WinRTError)&&b.test(function(){return this}),c.funcNames="string"==typeof Function.name,c}),c("lodash-amd/modern/internals/baseCreateCallback",["../functions/bind","../utilities/identity","./setBindData","../support"],function(a,b,c,d){function e(e,i,j){if("function"!=typeof e)return b;if("undefined"==typeof i||!("prototype"in e))return e;var k=e.__bindData__;if("undefined"==typeof k&&(d.funcNames&&(k=!e.name),k=k||!d.funcDecomp,!k)){var l=h.call(e);d.funcNames||(k=!f.test(l)),k||(k=g.test(l),c(e,k))}if(k===!1||k!==!0&&1&k[1])return e;switch(j){case 1:return function(a){return e.call(i,a)};case 2:return function(a,b){return e.call(i,a,b)};case 3:return function(a,b,c){return e.call(i,a,b,c)};case 4:return function(a,b,c,d){return e.call(i,a,b,c,d)}}return a(e,i)}var f=/^\s*function[ \n\r\t]+\w/,g=/\bthis\b/,h=Function.prototype.toString;return e}),c("lodash-amd/modern/internals/shimKeys",["./objectTypes"],function(a){var b=Object.prototype,c=b.hasOwnProperty,d=function(b){var d,e=b,f=[];if(!e)return f;if(!a[typeof b])return f;for(d in e)c.call(e,d)&&f.push(d);return f};return d}),c("lodash-amd/modern/objects/keys",["../internals/isNative","./isObject","../internals/shimKeys"],function(a,b,c){var d=a(d=Object.keys)&&d,e=d?function(a){return b(a)?d(a):[]}:c;return e}),c("lodash-amd/modern/objects/forOwn",["../internals/baseCreateCallback","./keys","../internals/objectTypes"],function(a,b,c){var d=function(d,e,f){var g,h=d,i=h;if(!h)return i;if(!c[typeof h])return i;e=e&&"undefined"==typeof f?e:a(e,f,3);for(var j=-1,k=c[typeof h]&&b(h),l=k?k.length:0;++jh?f(0,k+h):h)||0,c(e)?l=j(e,g,h)>-1:"number"==typeof k?l=(d(e)?e.indexOf(g,h):j(e,g,h))>-1:b(e,function(a){return++i>=h?!(l=a===g):void 0}),l}var f=Math.max;return e}),c("scribe-common/src/element",["lodash-amd/modern/collections/contains"],function(a){function b(b){return a(e,b.nodeName)}function c(a){return a.nodeType===Node.ELEMENT_NODE&&"scribe-marker"===a.className}function d(a,b){for(;b.childNodes.length>0;)a.insertBefore(b.childNodes[0],b);a.removeChild(b)}var e=["P","LI","DIV","BLOCKQUOTE","UL","OL","H1","H2","H3","H4","H5","H6"];return{isBlockElement:b,isSelectionMarkerNode:c,unwrap:d}}),c("scribe-plugin-smart-lists",["scribe-common/src/element"],function(a){return function(){function b(a){return"*"===a||"-"===a||"•"===a}function c(b){for(;b&&!a.isBlockElement(b);)b=b.parentNode;return b}var d={32:"Space",42:"*",45:"-",46:".",49:"1",8226:"•"};return function(a){function e(){var b,c=new a.api.Selection,d=c.selection.anchorNode;if(d.nodeType===Node.TEXT_NODE?b=d:d.firstChild.nodeType===Node.TEXT_NODE&&(b=d.firstChild),!b)throw new Error("Cannot empty non-text node!");var e=b.parentNode;b.previousSibling&&e.removeChild(b.previousSibling),e.removeChild(b)}function f(f){var j;g=h,h=i,i=d[f.charCode];var k=new a.api.Selection,l=k.range.commonAncestorContainer,m=c(l);if(m&&"P"===m.tagName){var n=b(l.textContent[0]);b(h)&&"Space"===i&&n&&(j="insertUnorderedList");var o="1."===[l.previousSibling&&l.previousSibling.textContent,l.textContent].join("").slice(0,2);"1"===g&&"."===h&&"Space"===i&&o&&(j="insertOrderedList")}j&&(f.preventDefault(),a.transactionManager.run(function(){a.getCommand(j).execute(),e()}))}var g,h,i;a.el.addEventListener("keypress",f)}}}),c("scribe-plugin-toolbar",[],function(){return function(a){return function(b){var c=a.querySelectorAll("[data-command-name]");Array.prototype.forEach.call(c,function(a){function c(){var c=b.getCommand(a.dataset.commandName),d=new b.api.Selection;d.range&&c.queryState(a.dataset.commandValue)?a.classList.add("active"):a.classList.remove("active"),d.range&&c.queryEnabled()?a.removeAttribute("disabled"):a.setAttribute("disabled","disabled")}a.addEventListener("click",function(){var c=b.getCommand(a.dataset.commandName);b.el.focus(),c.execute(a.dataset.commandValue)}),b.el.addEventListener("keyup",c),b.el.addEventListener("mouseup",c),b.el.addEventListener("focus",c),b.el.addEventListener("blur",c),b.on("content-changed",c)})}}}),c("scribe-plugin-inline-objects",[],function(){return function(a){return function(b){function c(a){n=a,$(".embed-button",q).click(d),$(".inline-tools button",q.parentNode).click(function(a){var b=$(a.target).data("commandName");"function"==typeof r[b]&&r[b]()})}function d(a){var c,d,g=$(".embed-fly-out").height(),h=$(".embed-button").height(),i=$(a.target).closest("button").data("commandName");"embed-before"===i?(c=o.position().top-g/2+h/2,d="before"):(c=o.position().top+o.height()+parseInt(o.css("margin-top"))-g/2+h/2,d="after"),$(".embed-fly-out",q).css({top:c,left:$(b.el).css("padding-left")}).show();var j=o;$(".embed-fly-out button").bind("click.inline",function(a){var b=$(a.target).closest("button").data("commandName");f(b,j,d)}),$("body").bind("click.inline",function(a){0===$(a.target).closest(".embed-tools").length&&e()})}function e(){$("body").unbind("click.inline"),$(".embed-fly-out button").unbind("click.inline"),$(".embed-fly-out").hide()}function f(a,c,d){b.trigger("inline:insert:"+a,[function(e){b.updateContents(function(){var f=$(m(n[a].template,$.extend(n[a].defaults,e)));$(c)[d](f),$(".inline",q).attr("contenteditable",!1),b.trigger("inline:insert:"+a+":done",[f])})}]),$(".embed-tools",q).removeClass("active")}function g(){$(".inline-tools").hide(),$(q).removeClass("inline-active")}function h(){var a=$(p),b=a.position();$(q).addClass("inline-active"),$(".inline-tools").attr("data-type",a.attr("data-type")),$(".inline-tools .size",q).html($(p).attr("data-size")),$(".inline-tools .crop",q).html($(p).attr("data-crop")),$(".inline-tools",q).css({top:b.top+parseInt(a.css("margin-top")),left:b.left+parseInt(a.css("margin-left"))+parseInt($(".editor",q).css("margin-left")),width:a.width(),height:a.height()}).show()}function i(){return n[$(p).attr("data-type")].size}function j(){return n[$(p).attr("data-type")].crop}function k(a,b){var c=$(p).attr("data-"+a),d=b.indexOf(c)+1;d>=b.length&&(d=0),l(a,b[d]),"function"==typeof window.picturefill&&setTimeout(function(){window.picturefill(p)},100)}function l(a,c){var d=$(p).attr("data-"+a);b.updateContents(function(){$(p).removeClass(a+"-"+d).addClass(a+"-"+c).attr("data-"+a,c),h()})}function m(a,b){for(var c in b)c&&(a=a.replace(new RegExp("{{"+c+"}}","g"),b[c]));return a}var n,o,p,q=b.el.parentNode;b.el.addEventListener("mouseover",function(a){var c=$(a.target).closest(".editor>*");1===c.length?($(".embed-tools",q).css({width:$(b.el).css("padding-left"),top:c.position().top+c.css("margin-top").replace(/[^-\d\.]/g,"")/2,height:c.height()}).addClass("active"),o=c):$(".embed-tools",q).removeClass("active")}),b.el.parentNode.addEventListener("mouseleave",function(a){g(),$(".embed-tools",q).removeClass("active")}),$(".embed-tools",q).mouseover(function(){$(".embed-tools",q).addClass("active")}),$(".editor",q).mouseover(function(a){var b=$(a.target).parents(".inline");1===b.length?(p=b[b.length-1],h()):g()});var r={inline_caption:function(){var a=prompt("Caption",$(".caption",p).html());(a||""===a)&&b.updateContents(function(){$(".caption",p).html(a)})},inline_size:function(){var a=i();k("size",a);var b=$(p).attr("data-crop"),c=j();-1===c.indexOf(b)&&l("crop",c[0])},inline_crop:function(){var a=n[$(p).attr("data-type")].crop;k("crop",a)},inline_up:function(){g();var a=$(p).prev()[0];if(a){var c=$(p).offset().top;b.updateContents(function(){$(p).after(a),setTimeout(function(){h();var a=$(p).offset().top;window.scrollBy(0,a-c)},0)})}},inline_down:function(){g();var a=$(p).next()[0];if(a){var c=$(p).offset().top;b.updateContents(function(){$(p).before(a),setTimeout(function(){h();var a=$(p).offset().top;window.scrollBy(0,a-c)},0)})}},inline_remove:function(){b.updateContents(function(){$(p).remove()}),g()},inline_edit:function(){b.trigger("inline:edit:"+$(p).attr("data-type"),[p,function(a,c){var d=$(a).attr("data-type");b.updateContents(function(){a.outerHTML=m(n[d].template,$.extend(n[d].defaults,c)),b.trigger("inline:edit:"+d+":done",[$(p)])})}])}};"string"==typeof a||a instanceof String?$.ajax(a,{success:c,dataType:"json"}):c(a)}}}),c("scribe-plugin-betty-cropper",[],function(){return function(a){return function(b){function c(b){a.insertDialog().then(function(a){var c;c=-1!==a.name.toUpperCase().indexOf("GIF")?"gif":"jpg",b({image_id:a.id,format:c}),window.picturefill&&setTimeout(function(){window.picturefill($("[data-image-id="+a.id+"]")[0])},100)},function(a){console.log(a)},function(a){console.log(a)})}function d(b,c){e=b.getAttribute("data-image-id");var d=$(".caption",b).html(),f=b.getAttribute("data-alt");a.editDialog({id:e,caption:d,alt:f}).then(function(a){null===a.id?$(b).remove():($(b).attr("data-image-id",a.id),$(b).attr("data-alt",a.alt),$(".caption",b).html(a.caption),window.picturefill&&setTimeout(function(){window.picturefill($("[data-image-id="+a.id+"]")[0])},100))})}var e;b.on("inline:edit:image",d),b.on("inline:insert:image",c)}}}),c("scribe-plugin-youtube",[],function(){return function(a){return function(a){function b(a){if(!a)return!1;var b=/^.*((youtu.be\/)|(v\/)|(\/u\/\w\/)|(embed\/)|(watch\?))\??v?=?([^#\&\?]*).*/,c=a.match(b);return c&&11==c[7].length?c[7]:!1}function c(a){var c=prompt("Youtube URL:"),d=b(c);d&&a({youtube_id:d,caption:""})}function d(a,c){var d=prompt("Youtube URL:",$(a).attr("data-youtube-id")||""),e=b(d);e&&c(a,{youtube_id:e,caption:$(".caption",a).html()})}a.on("inline:insert:youtube",c),a.on("inline:edit:youtube",d)}}}),c("scribe-plugin-embed",[],function(){return function(a){return function(a){function b(a,b){h.val(unescape($(a).attr("data-code"))),i.val($(".caption",a).text());var c=$(a).attr("data-size")+"-"+$(a).attr("data-crop");$("[value="+c+"]",g).attr("checked",!0),g.modal("show"),j.click(function(){var c=h.val();""===c.trim()?k.show():(k.hide(),b(a,{code:c,caption:i.val(),escaped_code:escape(c),size:d(),crop:e()}),g.modal("hide"))}),g.modal("show")}function c(a){h.val(""),i.val(""),g.modal("show"),j.click(function(){var b=h.val();""===b.trim()?k.show():(k.hide(),a({code:b,caption:i.val(),escaped_code:escape(b),size:d(),crop:e()}),g.modal("hide"))})}function d(){var a="original";return l.length>0&&l.val().split("-")[0],a}function e(){var a="original";return l.length>0&&l.val().split("-")[1],a}a.on("inline:insert:embed",c),a.on("inline:edit:embed",b);var f=a.el.parentNode,g=$(".embed-modal",f),h=$(".embed-body",g),i=$(".embed-caption",g),j=$(".set-embed-button",g),k=$(".embed-error",g),l=$("[name=size]",g);g.on("hide.bs.modal",function(){j.unbind("click"),k.hide()})}}}),c("scribe-plugin-embed-instagram",[],function(){return function(a){return function(a){var b=$(a.el.parentNode).find(".embed-modal"),c=b.find(".embed-caption"),d=b.find(".embed-error"),e=b.find(".embed-body"),f=b.find(".set-embed-button");b.on("hide.bs.modal",function(){f.off("click"),d.hide()});var g=function(a){e.val(""),c.val(""),f.on("click",function(){var f=e.val();f.trim()?(d.hide(),a({html:escape(f),caption:c.val()}),b.modal("hide")):d.show()}),b.modal("show")},h=function(a,g){var h=$(a),i=h.children(".embed-container"),j=i.instagramEmbedProcessor().data("pluginInstagramEmbedProcessor");e.val(j.html()),c.val(h.children(".caption").text()),f.on("click",function(){var f=e.val();f.trim()?(d.hide(),g(a,{html:escape(f),caption:c.val()}),b.modal("hide")):d.show()}),b.modal("show")},i=function(a){var b=a.find(".embed-container"),c=b.instagramEmbedProcessor().data("pluginInstagramEmbedProcessor");c.prep()};a.on("inline:insert:embed-instagram",g),a.on("inline:insert:embed-instagram:done",i),a.on("inline:edit:embed-instagram",h),a.on("inline:edit:embed-instagram:done",i)}}}),c("scribe-plugin-onion-video",[],function(){return function(a){return function(b){function c(c){function d(){}function e(){}return a.insertDialog().then(function(d){b.updateContents(function(){c({embed_url:a.videoEmbedUrl,video_id:d.attrs.id})})},function(a){e(a)},function(a){d(a)})}function d(b,c){var d=$(b).attr("data-video-id")||$(b).attr("data-videoid");a.editDialog(d)}b.on("inline:edit:onion-video",d),b.on("inline:insert:onion-video",c)}}}),c("scribe-plugin-hr",[],function(){return function(a){return function(a){function b(a){a({})}a.on("inline:insert:hr",b)}}}),c("scribe-plugin-placeholder",[],function(){return function(a){return function(b){function c(){var c=b.getContent();"


"===c||""===c?a.container.style.display="":a.container.style.display="none"}b.on("content-changed",c),a.container.innerHTML=a.text}}}),c("link-formatter",["scribe-common/src/element","lodash-amd/modern/collections/contains"],function(a,b){"use strict";return function(a){return function(b){function c(b){return b=b.trim(),b=e(b),a.domain&&(b=d(b,a.domain)),b}function d(a,b){var c=document.createElement("a");c.href=a;var d=c.hostname;return d.indexOf(b)>-1&&c.pathname.length>1&&(a=c.pathname+c.search+c.hash),a}function e(a){return"http://"!==a.substr(0,7)&&"https://"!==a.substr(0,8)&&"mailto:"!==a.substr(0,7)&&"/"!==a.substr(0,1)?-1!=a.indexOf("@")?"mailto:"+a:"http://"+a:a}function f(a){for(var b=a.firstElementChild;b;)"A"===b.nodeName?b.hasAttribute("href")&&b.setAttribute("href",c(b.getAttribute("href"))):b.children.length>0&&f(b),b=b.nextElementSibling}b.registerHTMLFormatter("sanitize",function(a){var b=document.createElement("div");return b.innerHTML=a,f(b),b.innerHTML})}}}),c("only-trailing-brs",[],function(){"use strict";return function(){return function(a){a.registerHTMLFormatter("normalize",function(a){return a.replace(/
(.)/g," $1")})}}}),c("paste-strip-newlines",[],function(){"use strict";return function(){return function(a){a.registerHTMLFormatter("paste",function(a){return a.replace(/\n/g," ")})}}}),c("paste-strip-nbsps",[],function(){"use strict";return function(){return function(a){a.registerHTMLFormatter("paste",function(a){return a.replace(/ /g," ")}),a.registerHTMLFormatter("normalize",function(a){return a.replace(/ /g," ")})}}}),c("paste-from-word",["scribe-common/src/element"],function(a){"use strict";return function(){return function(b){function c(a){return/0&&d(c),"A"===c.nodeName&&(c.href||a.unwrap(b,c)),c=e}}b.registerHTMLFormatter("paste",function(a){if(!c(a))return a;a=a.replace(//gi,""),a=a.replace(/<(!|script[^>]*>.*?<\/script(?=[>\s])|\/?(\?xml(:\w+)?|img|meta|link|style|\w:\w+)(?=[\s\/>]))[^>]*>/gi,"");var b=document.createElement("div");return b.innerHTML=a,d(b),b.innerHTML})}}}),c("paste-sanitize",["scribe-common/src/element"],function(a){"use strict";return function(){return function(b){function c(b){for(var d=b.firstElementChild;d;){var e=d.nextElementSibling;d.children.length>0&&c(d),d.hasAttribute("style")&&d.removeAttribute("style"),"P"===d.nodeName&&""===d.textContent.trim()&&b.removeChild(d),"SPAN"===d.nodeName&&a.unwrap(b,d),d=e}}b.registerHTMLFormatter("paste",function(a){var b=document.createElement("div");b.innerHTML=a;var d=[].slice.call(b.childNodes);return d.forEach(function(a){3===a.nodeType&&""===a.textContent.trim()&&b.removeChild(a)}),c(b),b.innerHTML})}}}),c("remove-a-styles",["scribe-common/src/element"],function(a){"use strict";return function(){return function(a){function b(a){for(var c=a.firstElementChild;c;)"A"===c.nodeName&&c.hasAttribute("style")?c.removeAttribute("style"):c.children.length>0&&b(c),c=c.nextElementSibling}a.registerHTMLFormatter("sanitize",function(a){var c=document.createElement("div");return c.innerHTML=a,b(c),c.innerHTML})}}}),c("strip-bold-in-headings",["scribe-common/src/element"],function(a){"use strict";return function(){return function(b){function c(b){for(var d=b.firstElementChild;d;)"B"===d.nodeName&&/^(H[1-6])$/.test(b.nodeName)?a.unwrap(b,d):d.children.length>0&&c(d),d=d.nextElementSibling}b.registerHTMLFormatter("sanitize",function(a){var b=document.createElement("div");return b.innerHTML=a,c(b),b.innerHTML})}}}),c("scribe-plugin-anchor",[],function(){return function(a){return function(a){function b(a){return a.toString().toLowerCase().replace(/\s+/g,"-").replace(/[^\w\-]+/g,"").replace(/\-\-+/g,"-").trim()}var c=new a.api.Command("anchor");c.queryEnabled=function(){var b=new a.api.Selection,c=b.getContaining(function(a){return!0});return void 0!==c},c.queryState=function(b){var c=new a.api.Selection,d=c.getContaining(function(a){return 3!==a.nodeType});return void 0===d?!1:!!d.id},c.execute=function(){var c=new a.api.Selection;console.log(c);var d=c.getContaining(function(a){return 3!==a.nodeType});console.log(d),a.transactionManager.run(function(){d.id?d.removeAttribute("id"):d.id=b(d.textContent)}.bind(this))},a.commands.toggleAnchor=c}}}),c("our-ensure-selectable-containers",["scribe-common/src/element","lodash-amd/modern/collections/contains"],function(a,b){"use strict";function c(e,f){function g(b){return 0===b.children.length||1===b.children.length&&a.isSelectionMarkerNode(b.children[0])}for(var h=e.firstElementChild;h;)a.isSelectionMarkerNode(h)||(g(h)&&""===h.textContent.trim()&&!b(d,h.nodeName)&&a.isBlockElement(h)?h.appendChild(document.createElement("br")):h.children.length>0&&(f.skipElement&&f.skipElement&&f.skipElement(h)||c(h,f))),h=h.nextElementSibling}var d=["AREA","BASE","BR","COL","COMMAND","EMBED","HR","IMG","INPUT","KEYGEN","LINK","META","PARAM","SOURCE","TRACK","WBR"];return function(a){return function(b){b.registerHTMLFormatter("normalize",function(b){var d=document.createElement("div");return d.innerHTML=b,c(d,a),d.innerHTML})}}}),c("enforce-p-elements",["lodash-amd/modern/arrays/last","scribe-common/src/element"],function(a,b){"use strict";function c(c){var d=Array.prototype.reduce.call(c.childNodes,function(c,d){function e(){var a=[d];c.push(a)}var f=a(c);if(f){var g=b.isBlockElement(f[0]);g===b.isBlockElement(d)?f.push(d):e()}else e();return c},[]),e=d.filter(function(a){var c=b.isBlockElement(a[0]);return!c});e.forEach(function(a){var b=document.createElement("p");a[0].parentNode.insertBefore(b,a[0]),a.forEach(function(a){b.appendChild(a)})}),c._isWrapped=!0}function d(a){for(var b=document.createTreeWalker(a,NodeFilter.SHOW_ELEMENT),e=b.firstChild();e;){if("BLOCKQUOTE"===e.nodeName&&!e._isWrapped){c(e),d(a);break}e=b.nextSibling()}}return function(){return function(a){a.registerHTMLFormatter("normalize",function(a){var b=document.createElement("div");return b.innerHTML=a,c(b),d(b),b.innerHTML})}}}),c("filter-for-export",["scribe-common/src/element"],function(a){"user strict";return function(){return function(a){function b(a){for(var c=a.firstElementChild;c;)c.filterForExport&&c.filterForExport(),c.children.length>0&&b(c),c=c.nextElementSibling}a.registerHTMLFormatter("export",function(a){var c=document.createElement("div");return c.innerHTML=a,b(c),c.innerHTML})}}}),c("onion-editor",["scribe","scribe-plugin-blockquote-command","scribe-plugin-curly-quotes","scribe-plugin-formatter-plain-text-convert-new-lines-to-html","scribe-plugin-heading-command","scribe-plugin-intelligent-unlink-command","scribe-plugin-keyboard-shortcuts","scribe-plugin-link-ui","scribe-plugin-sanitizer","scribe-plugin-smart-lists","scribe-plugin-toolbar","scribe-plugin-inline-objects","scribe-plugin-betty-cropper","scribe-plugin-youtube","scribe-plugin-embed","scribe-plugin-embed-instagram","scribe-plugin-onion-video","scribe-plugin-hr","scribe-plugin-placeholder","link-formatter","only-trailing-brs","paste-strip-newlines","paste-strip-nbsps","paste-from-word","paste-sanitize","remove-a-styles","strip-bold-in-headings","scribe-plugin-anchor","our-ensure-selectable-containers","enforce-p-elements","filter-for-export"],function(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,A,B,C,D,E){"use strict";function F(u,F){function H(a){return $(a).is("div.inline")}F=$.extend(G,F),$(".inline",u).attr("contenteditable","false");var I=new a(u,{allowBlockElements:F.multiline});I._htmlFormatterFactory.formatters.normalize=[],I.allowsBlockElements()&&(I.use(D()),I.use(C({skipElement:H})));var J=new I.api.CommandPatch("insertHTML");J.execute=function(a){I.transactionManager.run(function(){function b(a){var c=document.createTreeWalker(a,NodeFilter.SHOW_ELEMENT),d=c.firstChild();if(d)do"SPAN"===d.nodeName&&-1===d.className.indexOf("inline")?u.unwrap(a,d):(d.style.lineHeight=null,""===d.getAttribute("style")&&d.removeAttribute("style")),b(d);while(d=c.nextSibling())}I.api.CommandPatch.prototype.execute.call(this,a),b(I.el)}.bind(this))},I.commandPatches.insertHTML=J,F.placeholder&&I.use(s(F.placeholder));var K=new I.api.CommandPatch("bold");K.execute=function(a){void 0===this.selection?document.execCommand(this.commandName,!1,a||null):I.transactionManager.run(function(){document.execCommand(this.commandName,!1,a||null)}.bind(this))},I.commandPatches.bold=K;var L=new I.api.CommandPatch("italic");L.execute=function(a){void 0===this.selection?document.execCommand(this.commandName,!1,a||null):I.transactionManager.run(function(){document.execCommand(this.commandName,!1,a||null)}.bind(this))},I.commandPatches.italic=L;var M=new I.api.CommandPatch("underline");M.execute=function(a){void 0===this.selection?document.execCommand(this.commandName,!1,a||null):I.transactionManager.run(function(){document.execCommand(this.commandName,!1,a||null)}.bind(this))},I.commandPatches.underline=M;var N={},O=function(a){return a.metaKey||a.ctrlKey},P={};return F.multiline&&(P.p={id:!0},P.br={},P.hr={}),-1!==F.formatting.indexOf("bold")&&(N.bold=function(a){return a.metaKey&&66===a.keyCode},P.b={id:!0}),-1!==F.formatting.indexOf("italic")&&(N.italic=function(a){return a.metaKey&&73===a.keyCode},P.i={id:!0},P.em={id:!0}),-1!==F.formatting.indexOf("strike")&&(N.strikeThrough=function(a){return a.altKey&&a.shiftKey&&83===a.keyCode},P.strike={id:!0}),-1!==F.formatting.indexOf("underline")&&(N.underline=function(a){return a.metaKey&&85===a.keyCode},P.u={id:!0}),N.removeFormat=function(a){return a.altKey&&a.shiftKey&&65===a.keyCode},F.multiline&&-1!==F.formatting.indexOf("link")&&(N.linkUI=function(a){return a.metaKey&&!a.shiftKey&&75===a.keyCode},N.unlink=function(a){return a.metaKey&&a.shiftKey&&75===a.keyCode},I.use(f()),I.use(h(F.link)),I.use(t(F.link)),P.a={href:!0,target:!0,id:!0}),F.multiline&&-1!==F.formatting.indexOf("list")&&(N.insertUnorderedList=function(a){return a.altKey&&a.shiftKey&&66===a.keyCode},N.insertOrderedList=function(a){return a.altKey&&a.shiftKey&&78===a.keyCode},I.use(j()),P.ol={id:!0},P.ul={id:!0},P.li={id:!0}),F.multiline&&-1!==F.formatting.indexOf("blockquote")&&(N.blockquote=function(a){return a.altKey&&a.shiftKey&&87===a.keyCode},I.use(b()),P.blockquote={id:!0}),F.multiline&&-1!==F.formatting.indexOf("heading")&&(N.h3=function(a){return O(a)&&50===a.keyCode},N.h4=function(a){return O(a)&&51===a.keyCode},I.use(e(3)),I.use(e(4)),P.h3={id:!0},P.h4={id:!0}),F.multiline&&F.inlineObjects&&(I.use(l(F.inlineObjects)),I.use(m(F.image)),I.use(n()),I.use(o()),I.use(p()),I.use(r()),I.use(B()),I.use(q(F.video)),I.use(z()),I.use(A())),I.use(i({tags:P,skipSanitization:H})),I.use(x()),I.use(y()),I.use(v()),I.use(w()),F.statsContainer&&setInterval(function(){$(F.statsContainer).html($(I.el).text().split(" ").length)},3e3),I.use(E()),I.updateContents=function(a,b){"undefined"==typeof b&&(b=!0),I._skipFormatters=b;var c=window.scrollY;setTimeout(function(){I.el.focus(),setTimeout(function(){I.transactionManager.run(a),window.scrollTo(0,c),I.trigger("content-changed")},20)},20)},I.use(c()),I.use(g(Object.freeze(N))),F.multiline?I.use(k($(".document-tools .toolbar-contents",u.parentNode)[0])):$(".document-tools .toolbar-contents",u.parentNode).hide(),I.el.addEventListener("keydown",function(a){if(8===a.keyCode){var b=new I.api.Selection,c=$(b.selection.anchorNode).closest(".editor>*").prev();c.hasClass("inline")&&0===b.selection.anchorOffset&&b.selection.isCollapsed&&a.preventDefault()}}),I.use(d()),this.setChangeHandler=function(a){I.on("content-changed",a)},this.setContent=function(a){a||(a="


"),I.setContent(a)},this.getContent=function(){var a=I.getContent();return a},this.scribe=I,this}var G={multiline:!0,formatting:["link","bold","italic","blockquote","heading","list","underline"],link:{domain:"avclub.com"},video:{videoEmbedUrl:"http://example.com?videoid=",insertDialog:function(){},editDialog:function(){}},image:{insertDialog:function(){},editDialog:function(){}}};return F}),b("onion-editor")}); \ No newline at end of file +/*! onion-editor 2016-07-12 */ +!function(a,b){"function"==typeof define?define(b):"object"==typeof exports?module.exports=b():a.OnionEditor=b()}(this,function(){var a,b,c;return function(d){function e(a,b){return u.call(a,b)}function f(a,b){var c,d,e,f,g,h,i,j,k,l,m,n=b&&b.split("/"),o=s.map,p=o&&o["*"]||{};if(a&&"."===a.charAt(0))if(b){for(n=n.slice(0,n.length-1),a=a.split("/"),g=a.length-1,s.nodeIdCompat&&w.test(a[g])&&(a[g]=a[g].replace(w,"")),a=n.concat(a),k=0;k0&&(a.splice(k-1,2),k-=2)}a=a.join("/")}else 0===a.indexOf("./")&&(a=a.substring(2));if((n||p)&&o){for(c=a.split("/"),k=c.length;k>0;k-=1){if(d=c.slice(0,k).join("/"),n)for(l=n.length;l>0;l-=1)if(e=o[n.slice(0,l).join("/")],e&&(e=e[d])){f=e,h=k;break}if(f)break;!i&&p&&p[d]&&(i=p[d],j=k)}!f&&i&&(f=i,h=j),f&&(c.splice(0,h,f),a=c.join("/"))}return a}function g(a,b){return function(){return n.apply(d,v.call(arguments,0).concat([a,b]))}}function h(a){return function(b){return f(b,a)}}function i(a){return function(b){q[a]=b}}function j(a){if(e(r,a)){var b=r[a];delete r[a],t[a]=!0,m.apply(d,b)}if(!e(q,a)&&!e(t,a))throw new Error("No "+a);return q[a]}function k(a){var b,c=a?a.indexOf("!"):-1;return c>-1&&(b=a.substring(0,c),a=a.substring(c+1,a.length)),[b,a]}function l(a){return function(){return s&&s.config&&s.config[a]||{}}}var m,n,o,p,q={},r={},s={},t={},u=Object.prototype.hasOwnProperty,v=[].slice,w=/\.js$/;o=function(a,b){var c,d=k(a),e=d[0];return a=d[1],e&&(e=f(e,b),c=j(e)),e?a=c&&c.normalize?c.normalize(a,h(b)):f(a,b):(a=f(a,b),d=k(a),e=d[0],a=d[1],e&&(c=j(e))),{f:e?e+"!"+a:a,n:a,pr:e,p:c}},p={require:function(a){return g(a)},exports:function(a){var b=q[a];return"undefined"!=typeof b?b:q[a]={}},module:function(a){return{id:a,uri:"",exports:q[a],config:l(a)}}},m=function(a,b,c,f){var h,k,l,m,n,s,u=[],v=typeof c;if(f=f||a,"undefined"===v||"function"===v){for(b=!b.length&&c.length?["require","exports","module"]:b,n=0;ne?0:e);++d2?a(c,17,b(arguments,2),null,d):a(c,1,null,null,d)}return c}),c("lodash-amd/modern/utilities/identity",[],function(){function a(a){return a}return a}),c("lodash-amd/modern/support",["./internals/isNative"],function(a){var b=/\bthis\b/,c={};return c.funcDecomp=!a(window.WinRTError)&&b.test(function(){return this}),c.funcNames="string"==typeof Function.name,c}),c("lodash-amd/modern/internals/baseCreateCallback",["../functions/bind","../utilities/identity","./setBindData","../support"],function(a,b,c,d){function e(e,i,j){if("function"!=typeof e)return b;if("undefined"==typeof i||!("prototype"in e))return e;var k=e.__bindData__;if("undefined"==typeof k&&(d.funcNames&&(k=!e.name),k=k||!d.funcDecomp,!k)){var l=h.call(e);d.funcNames||(k=!f.test(l)),k||(k=g.test(l),c(e,k))}if(k===!1||k!==!0&&1&k[1])return e;switch(j){case 1:return function(a){return e.call(i,a)};case 2:return function(a,b){return e.call(i,a,b)};case 3:return function(a,b,c){return e.call(i,a,b,c)};case 4:return function(a,b,c,d){return e.call(i,a,b,c,d)}}return a(e,i)}var f=/^\s*function[ \n\r\t]+\w/,g=/\bthis\b/,h=Function.prototype.toString;return e}),c("lodash-amd/modern/objects/forIn",["../internals/baseCreateCallback","../internals/objectTypes"],function(a,b){var c=function(c,d,e){var f,g=c,h=g;if(!g)return h;if(!b[typeof g])return h;d=d&&"undefined"==typeof e?d:a(d,e,3);for(f in g)if(d(g[f],f,c)===!1)return h;return h};return c}),c("lodash-amd/modern/internals/arrayPool",[],function(){var a=[];return a}),c("lodash-amd/modern/internals/getArray",["./arrayPool"],function(a){function b(){return a.pop()||[]}return b}),c("lodash-amd/modern/internals/maxPoolSize",[],function(){var a=40;return a}),c("lodash-amd/modern/internals/releaseArray",["./arrayPool","./maxPoolSize"],function(a,b){function c(c){c.length=0,a.length-1:void 0});return u.pop(),v.pop(),G&&(e(u),e(v)),w}var g="[object Arguments]",h="[object Array]",i="[object Boolean]",j="[object Date]",k="[object Number]",l="[object Object]",m="[object RegExp]",n="[object String]",o=Object.prototype,p=o.toString,q=o.hasOwnProperty;return f}),c("lodash-amd/modern/utilities/property",[],function(){function a(a){return function(b){return b[a]}}return a}),c("lodash-amd/modern/functions/createCallback",["../internals/baseCreateCallback","../internals/baseIsEqual","../objects/isObject","../objects/keys","../utilities/property"],function(a,b,c,d,e){function f(f,g,h){var i=typeof f;if(null==f||"function"==i)return a(f,g,h);if("object"!=i)return e(f);var j=d(f),k=j[0],l=f[k];return 1!=j.length||l!==l||c(l)?function(a){for(var c=j.length,d=!1;c--&&(d=b(a[j[c]],f[j[c]],null,!0)););return d}:function(a){var b=a[k];return l===b&&(0!==l||1/l==1/b)}}return f}),c("lodash-amd/modern/objects/forOwn",["../internals/baseCreateCallback","./keys","../internals/objectTypes"],function(a,b,c){var d=function(d,e,f){var g,h=d,i=h;if(!h)return i;if(!c[typeof h])return i;e=e&&"undefined"==typeof f?e:a(e,f,3);for(var j=-1,k=c[typeof h]&&b(h),l=k?k.length:0;++j0){var b=document.createElement(f.nodeName);a.forEach(function(a){b.appendChild(a)}),f.parentNode.insertBefore(b,f.nextElementSibling)}}if(this.queryState()){var d=new a.api.Selection,e=d.range,f=d.getContaining(function(a){return"OL"===a.nodeName||"UL"===a.nodeName}),g=d.getContaining(function(a){return"LI"===a.nodeName});a.transactionManager.run(function(){if(g){var b=new a.api.Node(g).nextAll();c(b),d.placeMarkers();var h=document.createElement("p");h.innerHTML=g.innerHTML,f.parentNode.insertBefore(h,f.nextElementSibling),g.parentNode.removeChild(g)}else{var i=Array.prototype.map.call(f.querySelectorAll("li"),function(a){return e.intersectsNode(a)&&a}).filter(function(a){return a}),j=i.slice(-1)[0],k=new a.api.Node(j).nextAll();c(k),d.placeMarkers();var l=document.createDocumentFragment();i.forEach(function(a){var b=document.createElement("p");b.innerHTML=a.innerHTML,l.appendChild(b)}),f.parentNode.insertBefore(l,f.nextElementSibling),i.forEach(function(a){a.parentNode.removeChild(a)})}0===f.childNodes.length&&f.parentNode.removeChild(f),d.selectMarkers()}.bind(this))}else a.api.Command.prototype.execute.call(this,b)},b.prototype.queryEnabled=function(){return a.api.Command.prototype.queryEnabled.call(this)&&a.allowsBlockElements()},a.commands.insertOrderedList=new b("insertOrderedList"),a.commands.insertUnorderedList=new b("insertUnorderedList")}}}),c("plugins/core/commands/outdent",[],function(){return function(){return function(a){var b=new a.api.Command("outdent");b.queryEnabled=function(){var b=new a.api.Selection,c=b.getContaining(function(a){return"UL"===a.nodeName||"OL"===a.nodeName});return a.api.Command.prototype.queryEnabled.call(this)&&a.allowsBlockElements()&&!c},a.commands.outdent=b}}}),c("plugins/core/commands/redo",[],function(){return function(){return function(a){var b=new a.api.Command("redo");b.execute=function(){var b=a.undoManager.redo();"undefined"!=typeof b&&a.restoreFromHistory(b)},b.queryEnabled=function(){return a.undoManager.position1},a.commands.undo=b,a.el.addEventListener("keydown",function(a){a.shiftKey||!a.metaKey&&!a.ctrlKey||90!==a.keyCode||(a.preventDefault(),b.execute())})}}}),c("plugins/core/commands",["./commands/indent","./commands/insert-list","./commands/outdent","./commands/redo","./commands/subscript","./commands/superscript","./commands/undo"],function(a,b,c,d,e,f,g){return{indent:a,insertList:b,outdent:c,redo:d,subscript:e,superscript:f,undo:g}}),c("lodash-amd/modern/internals/baseIndexOf",[],function(){function a(a,b,c){for(var d=(c||0)-1,e=a?a.length:0;++dh?f(0,k+h):h)||0,c(e)?l=j(e,g,h)>-1:"number"==typeof k?l=(d(e)?e.indexOf(g,h):j(e,g,h))>-1:b(e,function(a){return++i>=h?!(l=a===g):void 0}),l}var f=Math.max;return e}),c("lodash-amd/modern/objects/values",["./keys"],function(a){function b(b){for(var c=-1,d=a(b),e=d.length,f=Array(e);++c0;)a.insertBefore(b.childNodes[0],b);a.removeChild(b)}var e=["P","LI","DIV","BLOCKQUOTE","UL","OL","H1","H2","H3","H4","H5","H6"];return{isBlockElement:b,isSelectionMarkerNode:c,unwrap:d}}),c("scribe-common/src/node",[],function(){function a(a){return a.nodeType===Node.TEXT_NODE&&""===a.textContent}function b(a,b){return b.parentNode.insertBefore(a,b.nextSibling)}function c(a){return a.parentNode.removeChild(a)}return{isEmptyTextNode:a,insertAfter:b,removeNode:c}}),c("dom-observer",["lodash-amd/modern/arrays/flatten","lodash-amd/modern/collections/toArray","scribe-common/src/element","scribe-common/src/node"],function(a,b,c,d){function e(e,f){function g(e){var f=a(e.map(function(a){var c=b(a.addedNodes),d=b(a.removedNodes);return c.concat(d)})),g=f.filter(function(a){return!d.isEmptyTextNode(a)}).filter(function(a){return!c.isSelectionMarkerNode(a)});return g.length>0}var h=!1,i=new MutationObserver(function(a){if(!h&&g(a)){h=!0;try{f()}finally{setTimeout(function(){h=!1},0)}}});return i.observe(e,{attributes:!0,childList:!0,subtree:!0}),i}return e}),c("plugins/core/events",["lodash-amd/modern/collections/contains","../../dom-observer"],function(a,b){return function(){return function(c){function d(){var a=navigator.userAgent;return a.search("Safari")>=0&&a.search("Chrome")<0}var e=function(){setTimeout(function(){c.pushHistory()}.bind(c),0),c.el.removeEventListener("focus",e)}.bind(c);c.el.addEventListener("focus",e),c.el.addEventListener("focus",function(){function a(b){var c=document.createTreeWalker(b),d=c.currentNode;return c.firstChild()?"BR"===c.currentNode.nodeName?d:a(c.currentNode):c.currentNode}var b=new c.api.Selection;if(b.range){var d=c.allowsBlockElements()&&b.range.startContainer===c.el;if(d){var e=a(c.el.firstChild),f=b.range;f.setStart(e,0),f.setEnd(e,0),b.selection.removeAllRanges(),b.selection.addRange(f)}}}.bind(c));var f=function(){if(!c._skipFormatters){var a=new c.api.Selection,b=a.range,d=function(){b&&a.placeMarkers(),c.setHTML(c._htmlFormatterFactory.format(c.getHTML())),a.selectMarkers()}.bind(c);b?(c.undoManager.undo(),c.transactionManager.run(d)):d()}delete c._skipFormatters}.bind(c);b(c.el,f),c.allowsBlockElements()&&c.el.addEventListener("keydown",function(a){if(13===a.keyCode){var b=new c.api.Selection,d=b.range,e=b.getContaining(function(a){return/^(H[1-6])$/.test(a.nodeName)});if(e&&d.collapsed){var f=d.cloneRange();f.setEndAfter(e,0);var g=f.cloneContents();""===g.firstChild.textContent&&(a.preventDefault(),c.transactionManager.run(function(){var a=document.createElement("p"),c=document.createElement("br");a.appendChild(c),e.parentNode.insertBefore(a,e.nextElementSibling),d.setStart(a,0),d.setEnd(a,0),b.selection.removeAllRanges(),b.selection.addRange(d)}))}}}),c.allowsBlockElements()&&c.el.addEventListener("keydown",function(a){if(13===a.keyCode||8===a.keyCode){var b=new c.api.Selection,d=b.range;if(d.collapsed){var e=b.getContaining(function(a){return"LI"===a.nodeName});if(e&&""===e.textContent.trim()){a.preventDefault();var f=b.getContaining(function(a){return"UL"===a.nodeName||"OL"===a.nodeName}),g=c.getCommand("OL"===f.nodeName?"insertOrderedList":"insertUnorderedList");g.execute()}}}}),c.el.addEventListener("paste",function(b){if(!b.clipboardData||!a(b.clipboardData.types,"text/html")&&d()){var e=new c.api.Selection;e.placeMarkers();var f=document.createElement("div");document.body.appendChild(f),f.setAttribute("contenteditable",!0),f.focus(),setTimeout(function(){var a=f.innerHTML;f.parentNode.removeChild(f),e.selectMarkers(),c.el.focus(),a=c._htmlFormatterFactory.formatPaste(a),c.insertHTML(a)},1)}else if(b.preventDefault(),a(b.clipboardData.types,"text/html")){var g=b.clipboardData.getData("text/html");g=c._htmlFormatterFactory.formatPaste(g),c.insertHTML(g)}else c.insertPlainText(b.clipboardData.getData("text/plain"))})}}}),c("plugins/core/formatters/html/replace-nbsp-chars",[],function(){return function(){return function(a){var b=/(\s| )+/g;a.registerHTMLFormatter("export",function(a){return a.replace(b," ")})}}}),c("lodash-amd/modern/arrays/last",["../functions/createCallback","../internals/slice"],function(a,b){function c(c,f,g){var h=0,i=c?c.length:0;if("number"!=typeof f&&null!=f){var j=i;for(f=a(f,g,3);j--&&f(c[j],j,c);)h++}else if(h=f,null==h||g)return c?c[i-1]:d;return b(c,e(0,i-h))}var d,e=Math.max;return c}),c("plugins/core/formatters/html/enforce-p-elements",["lodash-amd/modern/arrays/last","scribe-common/src/element"],function(a,b){function c(c){var d=Array.prototype.reduce.call(c.childNodes,function(c,d){function e(){var a=[d];c.push(a)}var f=a(c);if(f){var g=b.isBlockElement(f[0]);g===b.isBlockElement(d)?f.push(d):e()}else e();return c},[]),e=d.filter(function(a){var c=b.isBlockElement(a[0]);return!c});e.forEach(function(a){var b=document.createElement("p");a[0].parentNode.insertBefore(b,a[0]),a.forEach(function(a){b.appendChild(a)})}),c._isWrapped=!0}function d(a){for(var b=document.createTreeWalker(a,NodeFilter.SHOW_ELEMENT),e=b.firstChild();e;){if("BLOCKQUOTE"===e.nodeName&&!e._isWrapped){c(e),d(a);break}e=b.nextSibling()}}return function(){return function(a){a.registerHTMLFormatter("normalize",function(a){var b=document.createElement("div");return b.innerHTML=a,c(b),d(b),b.innerHTML})}}}),c("plugins/core/formatters/html/ensure-selectable-containers",["scribe-common/src/element","lodash-amd/modern/collections/contains"],function(a,b){function c(e){function f(b){return 0===b.children.length||1===b.children.length&&a.isSelectionMarkerNode(b.children[0])}for(var g=e.firstElementChild;g;)a.isSelectionMarkerNode(g)||(f(g)&&""===g.textContent.trim()&&!b(d,g.nodeName)?g.appendChild(document.createElement("br")):g.children.length>0&&c(g)),g=g.nextElementSibling}var d=["AREA","BASE","BR","COL","COMMAND","EMBED","HR","IMG","INPUT","KEYGEN","LINK","META","PARAM","SOURCE","TRACK","WBR"];return function(){return function(a){a.registerHTMLFormatter("normalize",function(a){var b=document.createElement("div");return b.innerHTML=a,c(b),b.innerHTML})}}}),c("lodash-amd/modern/internals/htmlEscapes",[],function(){var a={"&":"&","<":"<",">":">",'"':""","'":"'"};return a}),c("lodash-amd/modern/internals/escapeHtmlChar",["./htmlEscapes"],function(a){function b(b){return a[b]}return b}),c("lodash-amd/modern/internals/reUnescapedHtml",["./htmlEscapes","../objects/keys"],function(a,b){var c=RegExp("["+b(a).join("")+"]","g");return c}),c("lodash-amd/modern/utilities/escape",["../internals/escapeHtmlChar","../objects/keys","../internals/reUnescapedHtml"],function(a,b,c){function d(b){return null==b?"":String(b).replace(c,a)}return d}),c("plugins/core/formatters/plain-text/escape-html-characters",["lodash-amd/modern/utilities/escape"],function(a){return function(){return function(b){b.registerPlainTextFormatter(a)}}}),c("plugins/core/inline-elements-mode",[],function(){function a(a){for(var b=document.createTreeWalker(a);b.nextNode();)if(b.currentNode&&(~["br"].indexOf(b.currentNode.nodeName.toLowerCase())||b.currentNode.length>0))return!0;return!1}return function(){return function(b){b.el.addEventListener("keydown",function(c){if(13===c.keyCode){var d=new b.api.Selection,e=d.range,f=d.getContaining(function(a){return"LI"===a.nodeName||/^(H[1-6])$/.test(a.nodeName)});f||(c.preventDefault(),b.transactionManager.run(function(){"BR"===b.el.lastChild.nodeName&&b.el.removeChild(b.el.lastChild);var c=document.createElement("br");e.insertNode(c),e.collapse(!1);var f=e.cloneRange();f.setEndAfter(b.el.lastChild,0);var g=f.cloneContents();if(!a(g)){var h=document.createElement("br");e.insertNode(h)}var i=e.cloneRange();i.setStartAfter(c,0),i.setEndAfter(c,0),d.selection.removeAllRanges(),d.selection.addRange(i)}))}}.bind(this)),""===b.getHTML().trim()&&b.setContent("")}}}),c("plugins/core/patches/commands/indent",[],function(){var a="";return function(){return function(b){var c=new b.api.CommandPatch("indent");c.execute=function(c){b.transactionManager.run(function(){var d=new b.api.Selection,e=d.range,f="P"===e.commonAncestorContainer.nodeName&&"
"===e.commonAncestorContainer.innerHTML;if(f){var g=document.createTextNode(a);e.insertNode(g),e.setStart(g,0),e.setEnd(g,0),d.selection.removeAllRanges(),d.selection.addRange(e)}b.api.CommandPatch.prototype.execute.call(this,c),d=new b.api.Selection;var h=d.getContaining(function(a){return"BLOCKQUOTE"===a.nodeName});h&&h.removeAttribute("style")}.bind(this))},b.commandPatches.indent=c}}}),c("plugins/core/patches/commands/insert-html",["scribe-common/src/element"],function(a){return function(){return function(b){var c=new b.api.CommandPatch("insertHTML");c.execute=function(c){b.transactionManager.run(function(){function d(b){var c=document.createTreeWalker(b,NodeFilter.SHOW_ELEMENT),e=c.firstChild();if(e)do"SPAN"===e.nodeName?a.unwrap(b,e):(e.style.lineHeight=null,""===e.getAttribute("style")&&e.removeAttribute("style")),d(e);while(e=c.nextSibling())}b.api.CommandPatch.prototype.execute.call(this,c),d(b.el)}.bind(this))},b.commandPatches.insertHTML=c}}}),c("plugins/core/patches/commands/insert-list",["scribe-common/src/element","scribe-common/src/node"],function(a,b){return function(){return function(c){var d=function(a){c.api.CommandPatch.call(this,a)};d.prototype=Object.create(c.api.CommandPatch.prototype),d.prototype.constructor=d,d.prototype.execute=function(d){c.transactionManager.run(function(){if(c.api.CommandPatch.prototype.execute.call(this,d),this.queryState()){var e=new c.api.Selection,f=e.getContaining(function(a){return"OL"===a.nodeName||"UL"===a.nodeName});if(f.nextElementSibling&&0===f.nextElementSibling.childNodes.length&&b.removeNode(f.nextElementSibling),f){var g=f.parentNode;g&&/^(H[1-6]|P)$/.test(g.nodeName)&&(e.placeMarkers(),b.insertAfter(f,g),e.selectMarkers(),2===g.childNodes.length&&b.isEmptyTextNode(g.firstChild)&&b.removeNode(g),0===g.childNodes.length&&b.removeNode(g))}var h=Array.prototype.slice.call(f.childNodes);h.forEach(function(b){var c=Array.prototype.slice.call(b.childNodes);c.forEach(function(c){if("SPAN"===c.nodeName){var d=c;a.unwrap(b,d)}else c.nodeType===Node.ELEMENT_NODE&&(c.style.lineHeight=null,""===c.getAttribute("style")&&c.removeAttribute("style"))})})}}.bind(this))},c.commandPatches.insertOrderedList=new d("insertOrderedList"),c.commandPatches.insertUnorderedList=new d("insertUnorderedList")}}}),c("plugins/core/patches/commands/outdent",[],function(){return function(){return function(a){var b=new a.api.CommandPatch("outdent");b.execute=function(){a.transactionManager.run(function(){var b=new a.api.Selection,c=b.range,d=b.getContaining(function(a){return"BLOCKQUOTE"===a.nodeName});if("BLOCKQUOTE"===c.commonAncestorContainer.nodeName){b.placeMarkers(),b.selectMarkers(!0);var e=c.cloneContents();d.parentNode.insertBefore(e,d),c.deleteContents(),b.selectMarkers(),""===d.textContent&&d.parentNode.removeChild(d)}else{var f=b.getContaining(function(a){return"P"===a.nodeName});if(f){var g=new a.api.Node(f).nextAll();if(g.length){var h=document.createElement(d.nodeName);g.forEach(function(a){h.appendChild(a)}),d.parentNode.insertBefore(h,d.nextElementSibling)}b.placeMarkers(),d.parentNode.insertBefore(f,d.nextElementSibling),b.selectMarkers(),""===d.innerHTML&&d.parentNode.removeChild(d)}else a.api.CommandPatch.prototype.execute.call(this)}}.bind(this))},a.commandPatches.outdent=b}}}),c("plugins/core/patches/commands/create-link",[],function(){return function(){return function(a){var b=new a.api.CommandPatch("createLink");a.commandPatches.createLink=b,b.execute=function(b){var c=new a.api.Selection;if(c.selection.isCollapsed){var d=document.createElement("a");d.setAttribute("href",b),d.textContent=b,c.range.insertNode(d);var e=document.createRange();e.setStartBefore(d),e.setEndAfter(d),c.selection.removeAllRanges(),c.selection.addRange(e)}else a.api.CommandPatch.prototype.execute.call(this,b)}}}}),c("plugins/core/patches/events",["scribe-common/src/element"],function(a){return function(){return function(b){b.allowsBlockElements()&&b.el.addEventListener("keyup",function(c){if(8===c.keyCode||46===c.keyCode){var d=new b.api.Selection,e=d.getContaining(function(a){return"P"===a.nodeName});e&&(b.undoManager.undo(),b.transactionManager.run(function(){d.placeMarkers();var b=Array.prototype.slice.call(e.childNodes);b.forEach(function(b){if("SPAN"===b.nodeName){var c=b;a.unwrap(e,c)}else b.nodeType===Node.ELEMENT_NODE&&(b.style.lineHeight=null,""===b.getAttribute("style")&&b.removeAttribute("style"))}),d.selectMarkers()}))}})}}}),c("plugins/core/patches",["./patches/commands/indent","./patches/commands/insert-html","./patches/commands/insert-list","./patches/commands/outdent","./patches/commands/create-link","./patches/events"],function(a,b,c,d,e,f){return{commands:{indent:a,insertHTML:b,insertList:c,outdent:d,createLink:e},events:f}}),c("plugins/core/set-root-p-element",[],function(){return function(){return function(a){""===a.getHTML().trim()&&a.setContent("


")}}}),c("api/command-patch",[],function(){return function(a){function b(a){this.commandName=a}return b.prototype.execute=function(b){a.transactionManager.run(function(){document.execCommand(this.commandName,!1,b||null)}.bind(this))},b.prototype.queryState=function(){return"insertOrderedList"===this.commandName||"insertUnorderedList"==this.commandName?!1:document.queryCommandState(this.commandName)},b.prototype.queryEnabled=function(){return document.queryCommandEnabled(this.commandName)},b}}),c("api/command",[],function(){return function(a){function b(b){this.commandName=b,this.patch=a.commandPatches[this.commandName]}return b.prototype.execute=function(b){this.patch?this.patch.execute(b):a.transactionManager.run(function(){document.execCommand(this.commandName,!1,b||null)}.bind(this))},b.prototype.queryState=function(){return this.patch?this.patch.queryState():document.queryCommandState(this.commandName)},b.prototype.queryEnabled=function(){return this.patch?this.patch.queryEnabled():document.queryCommandEnabled(this.commandName)},b}}),c("api/node",[],function(){function a(a){this.node=a}return a.prototype.getAncestor=function(a){var b=function(a){return a&&a.attributes&&a.attributes.getNamedItem("contenteditable")};if(!b(this.node))for(var c=this.node.parentNode;c&&!b(c);){if(a(c))return c; +c=c.parentNode}},a.prototype.nextAll=function(){for(var a=[],b=this.node.nextSibling;b;)a.push(b),b=b.nextSibling;return a},a}),c("api/selection",[],function(){return function(a){function b(){this.selection=window.getSelection(),this.selection.rangeCount&&(this.range=this.selection.getRangeAt(0))}return b.prototype.getContaining=function(b){if(this.range){var c=new a.api.Node(this.range.commonAncestorContainer),d=c.node&&c.node.attributes&&c.node.attributes.getNamedItem("contenteditable");return!d&&b(c.node)?c.node:c.getAncestor(b)}},b.prototype.placeMarkers=function(){if(this.range){var a=document.createElement("em");a.classList.add("scribe-marker");var b=document.createElement("em");b.classList.add("scribe-marker");var c=this.range.cloneRange();if(c.collapse(!1),c.insertNode(b),b.nextSibling&&b.nextSibling.nodeType===Node.TEXT_NODE&&""===b.nextSibling.data&&b.parentNode.removeChild(b.nextSibling),b.previousSibling&&b.previousSibling.nodeType===Node.TEXT_NODE&&""===b.previousSibling.data&&b.parentNode.removeChild(b.previousSibling),!this.selection.isCollapsed){var d=this.range.cloneRange();d.collapse(!0),d.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.selection.removeAllRanges(),this.selection.addRange(this.range)}},b.prototype.getMarkers=function(){return a.el.querySelectorAll("em.scribe-marker")},b.prototype.removeMarkers=function(){var a=this.getMarkers();Array.prototype.forEach.call(a,function(a){a.parentNode.removeChild(a)})},b.prototype.selectMarkers=function(a){var b=this.getMarkers();if(b.length){var c=document.createRange();c.setStartBefore(b[0]),c.setEndAfter(b.length>=2?b[1]:b[0]),a||this.removeMarkers(),this.selection.removeAllRanges(),this.selection.addRange(c)}},b.prototype.isCaretOnNewLine=function(){var a=this.getContaining(function(a){return"P"===a.nodeName});if(a){var b=a.innerHTML.trim();return"P"===a.nodeName&&("
"===b||""===b)}return!1},b}}),c("api/simple-command",[],function(){return function(a,b){function c(a,c){b.api.Command.call(this,a),this.nodeName=c}return c.prototype=Object.create(a.Command.prototype),c.prototype.constructor=c,c.prototype.queryState=function(){var a=new b.api.Selection;return b.api.Command.prototype.queryState.call(this)&&!!a.getContaining(function(a){return a.nodeName===this.nodeName}.bind(this))},c}}),c("api",["./api/command-patch","./api/command","./api/node","./api/selection","./api/simple-command"],function(a,b,c,d,e){return function(f){this.CommandPatch=a(f),this.Command=b(f),this.Node=c,this.Selection=d(f),this.SimpleCommand=e(this,f)}}),c("lodash-amd/modern/objects/assign",["../internals/baseCreateCallback","./keys","../internals/objectTypes"],function(a,b,c){var d=function(d,e,f){var g,h=d,i=h;if(!h)return i;var j=arguments,k=0,l="number"==typeof f?2:j.length;if(l>3&&"function"==typeof j[l-2])var m=a(j[--l-1],j[l--],2);else l>2&&"function"==typeof j[l-1]&&(m=j[--l]);for(;++kthis.maxStackSize;)this.stack.shift(),--this.position},b.prototype.undo=function(){return this.position>0?this.stack[--this.position]:void 0},b.prototype.redo=function(){return this.position$/,""))},p.prototype.getTextContent=function(){return this.el.textContent},p.prototype.pushHistory=function(){var a=this.undoManager.stack[this.undoManager.position],b=a&&a.replace(//g,"").replace(/<\/em>/g,"");if(!a||a&&this.getContent()!==b){var c=new this.api.Selection;c.placeMarkers();var d=this.getHTML();return c.removeMarkers(),this.undoManager.push(d),!0}return!1},p.prototype.getCommand=function(a){return this.commands[a]||this.commandPatches[a]||new this.api.Command(a)},p.prototype.restoreFromHistory=function(a){this.setHTML(a,!0);var b=new this.api.Selection;b.selectMarkers(),this.trigger("content-changed")},p.prototype.allowsBlockElements=function(){return this.options.allowBlockElements},p.prototype.setContent=function(a){this.allowsBlockElements()||(a+="
"),this.setHTML(a),this.trigger("content-changed")},p.prototype.insertPlainText=function(a){this.insertHTML("

"+this._plainTextFormatterFactory.format(a)+"

")},p.prototype.insertHTML=function(a){this.getCommand("insertHTML").execute(this._htmlFormatterFactory.format(a))},p.prototype.isDebugModeEnabled=function(){return this.options.debug},p.prototype.registerHTMLFormatter=function(a,b){this._htmlFormatterFactory.formatters[a].push(b)},p.prototype.registerPlainTextFormatter=function(a){this._plainTextFormatterFactory.formatters.push(a)},q.prototype.format=function(a){var b=this.formatters.reduce(function(a,b){return b(a)},a);return b},r.prototype=Object.create(q.prototype),r.prototype.constructor=r,r.prototype.format=function(a){var c=b([this.formatters.sanitize,this.formatters.normalize]),d=c.reduce(function(a,b){return b(a)},a);return d},r.prototype.formatPaste=function(a){return this.formatters.paste.reduce(function(a,b){return b(a)},a)},r.prototype.formatForExport=function(a){return this.formatters.export.reduce(function(a,b){return b(a)},a)},p}),c("scribe-plugin-blockquote-command",[],function(){return function(){return function(a){var b=new a.api.SimpleCommand("blockquote","BLOCKQUOTE");b.execute=function(){var b=a.getCommand(this.queryState()?"outdent":"indent");b.execute()},b.queryEnabled=function(){var b=a.getCommand(this.queryState()?"outdent":"indent");return b.queryEnabled()},b.queryState=function(){var b=new a.api.Selection,c=b.getContaining(function(a){return"BLOCKQUOTE"===a.nodeName});return a.allowsBlockElements()&&!!c},a.commands.blockquote=b,a.allowsBlockElements()&&a.el.addEventListener("keydown",function(b){if(13===b.keyCode){var c=a.getCommand("blockquote");if(c.queryState()){var d=new a.api.Selection;d.isCaretOnNewLine()&&(b.preventDefault(),c.execute())}}})}}}),c("scribe-plugin-curly-quotes",[],function(){return function(){var a={34:'"',39:"'"},b="“",c="”",d="‘",e="’";return function(f){function g(g){var i,j=a[g.charCode];'"'===j?i=h()?c:b:"'"===j&&(i=h()?e:d),i&&(g.preventDefault(),f.transactionManager.run(function(){var a=k(i);l(a)}))}function h(){var a=i()||"";return j(a)}function i(){var a=new f.api.Selection,b=a.range.commonAncestorContainer.textContent;return b[a.range.startOffset-1]}function j(a){return/[^\s()]/.test(a)}function k(a){var b=document.createTextNode(a),c=new f.api.Selection;return c.range.deleteContents(),c.range.insertNode(b),b}function l(a){var b=document.createRange();b.setStartAfter(a),b.setEndAfter(a);var c=new f.api.Selection;c.selection.removeAllRanges(),c.selection.addRange(b)}function m(a){var f=document.createElement("div");return f.innerHTML=a,o(f,function(a){var f=a.split(/(<[^>]+?>)/);return f.map(function(a){return"<"===a[0]?a:a.replace(/([\s\S])?'([\s\S])?/g,n(d,e)).replace(/([\s\S])?"([\s\S])?/g,n(b,c))}).join("")}),f.innerHTML}function n(a,b){return function(c,d,e){d=d||"",e=e||"";var f=!d,g=!e,h=j(d),i=j(e);return h||f&&!i&&!g?d+b+e:d+a+e}}function o(a,b){console.log(a);var c=document.createTreeWalker(a,NodeFilter.SHOW_TEXT),d=c.firstChild();if(d)do d.data=b(d.data);while(d=c.nextSibling());return d}f.el.addEventListener("keypress",g),f.registerHTMLFormatter("normalize",m)}}}),c("scribe-plugin-formatter-plain-text-convert-new-lines-to-html",[],function(){return function(){return function(a){a.registerPlainTextFormatter(function(a){return a.replace(/\n([ \t]*\n)+/g,"

").replace(/\n/g,"
")})}}}),c("scribe-plugin-heading-command",[],function(){return function(a){return function(b){var c="",d="H"+a,e="h"+a,f=new b.api.Command("formatBlock");f.execute=function(){this.queryState()?b.api.Command.prototype.execute.call(this,"

"):b.api.Command.prototype.execute.call(this,c)},f.queryState=function(){var a=new b.api.Selection;return!!a.getContaining(function(a){return a.nodeName===d})},f.queryEnabled=function(){var a=new b.api.Selection,c=a.getContaining(function(a){return"OL"===a.nodeName||"UL"===a.nodeName});return b.api.Command.prototype.queryEnabled.apply(this,arguments)&&b.allowsBlockElements()&&!c},b.commands[e]=f}}}),c("scribe-plugin-intelligent-unlink-command",[],function(){return function(){return function(a){var b=new a.api.Command("unlink");b.execute=function(){var b=new a.api.Selection;b.selection.isCollapsed?a.transactionManager.run(function(){var c=b.getContaining(function(a){return"A"===a.nodeName});c&&new a.api.Element(c.parentNode).unwrap(c)}.bind(this)):a.api.Command.prototype.execute.apply(this,arguments)},b.queryEnabled=function(){var b=new a.api.Selection;return b.selection.isCollapsed?!!b.getContaining(function(a){return"A"===a.nodeName}):a.api.Command.prototype.queryEnabled.apply(this,arguments)},a.commands.unlink=b}}}),c("lodash-amd/modern/internals/isNative",[],function(){function a(a){return"function"==typeof a&&d.test(a)}var b=Object.prototype,c=b.toString,d=RegExp("^"+String(c).replace(/[.*+?^${}()|[\]\\]/g,"\\$&").replace(/toString| for [^\]]+/g,".*?")+"$");return a}),c("lodash-amd/modern/internals/objectTypes",[],function(){var a={"boolean":!1,"function":!0,object:!0,number:!1,string:!1,undefined:!1};return a}),c("lodash-amd/modern/objects/isObject",["../internals/objectTypes"],function(a){function b(b){return!(!b||!a[typeof b])}return b}),c("lodash-amd/modern/utilities/noop",[],function(){function a(){}return a}),c("lodash-amd/modern/internals/baseCreate",["./isNative","../objects/isObject","../utilities/noop"],function(a,b){function c(a){return b(a)?d(a):{}}var d=a(d=Object.create)&&d;return d||(c=function(){function a(){}return function(c){if(b(c)){a.prototype=c;var d=new a;a.prototype=null}return d||window.Object()}}()),c}),c("lodash-amd/modern/internals/setBindData",["./isNative","../utilities/noop"],function(a,b){var c={configurable:!1,enumerable:!1,value:null,writable:!1},d=function(){try{var b={},c=a(c=Object.defineProperty)&&c,d=c(b,b,b)&&c}catch(e){}return d}(),e=d?function(a,b){c.value=b,d(a,"__bindData__",c)}:b;return e}),c("lodash-amd/modern/internals/slice",[],function(){function a(a,b,c){b||(b=0),"undefined"==typeof c&&(c=a?a.length:0);for(var d=-1,e=c-b||0,f=Array(0>e?0:e);++d2?a(c,17,b(arguments,2),null,d):a(c,1,null,null,d)}return c}),c("lodash-amd/modern/utilities/identity",[],function(){function a(a){return a}return a}),c("lodash-amd/modern/support",["./internals/isNative"],function(a){var b=/\bthis\b/,c={};return c.funcDecomp=!a(window.WinRTError)&&b.test(function(){return this}),c.funcNames="string"==typeof Function.name,c}),c("lodash-amd/modern/internals/baseCreateCallback",["../functions/bind","../utilities/identity","./setBindData","../support"],function(a,b,c,d){function e(e,i,j){if("function"!=typeof e)return b;if("undefined"==typeof i||!("prototype"in e))return e;var k=e.__bindData__;if("undefined"==typeof k&&(d.funcNames&&(k=!e.name),k=k||!d.funcDecomp,!k)){var l=h.call(e);d.funcNames||(k=!f.test(l)),k||(k=g.test(l),c(e,k))}if(k===!1||k!==!0&&1&k[1])return e;switch(j){case 1:return function(a){return e.call(i,a)};case 2:return function(a,b){return e.call(i,a,b)};case 3:return function(a,b,c){return e.call(i,a,b,c)};case 4:return function(a,b,c,d){return e.call(i,a,b,c,d)}}return a(e,i)}var f=/^\s*function[ \n\r\t]+\w/,g=/\bthis\b/,h=Function.prototype.toString;return e}),c("lodash-amd/modern/objects/forIn",["../internals/baseCreateCallback","../internals/objectTypes"],function(a,b){var c=function(c,d,e){var f,g=c,h=g;if(!g)return h;if(!b[typeof g])return h;d=d&&"undefined"==typeof e?d:a(d,e,3);for(f in g)if(d(g[f],f,c)===!1)return h;return h};return c}),c("lodash-amd/modern/internals/arrayPool",[],function(){var a=[];return a}),c("lodash-amd/modern/internals/getArray",["./arrayPool"],function(a){function b(){return a.pop()||[]}return b}),c("lodash-amd/modern/internals/maxPoolSize",[],function(){var a=40;return a}),c("lodash-amd/modern/internals/releaseArray",["./arrayPool","./maxPoolSize"],function(a,b){function c(c){c.length=0,a.length-1:void 0});return u.pop(),v.pop(),G&&(e(u),e(v)),w}var g="[object Arguments]",h="[object Array]",i="[object Boolean]",j="[object Date]",k="[object Number]",l="[object Object]",m="[object RegExp]",n="[object String]",o=Object.prototype,p=o.toString,q=o.hasOwnProperty;return f}),c("lodash-amd/modern/internals/shimKeys",["./objectTypes"],function(a){var b=Object.prototype,c=b.hasOwnProperty,d=function(b){var d,e=b,f=[];if(!e)return f;if(!a[typeof b])return f;for(d in e)c.call(e,d)&&f.push(d);return f};return d}),c("lodash-amd/modern/objects/keys",["../internals/isNative","./isObject","../internals/shimKeys"],function(a,b,c){var d=a(d=Object.keys)&&d,e=d?function(a){return b(a)?d(a):[]}:c;return e}),c("lodash-amd/modern/utilities/property",[],function(){function a(a){return function(b){return b[a]}}return a}),c("lodash-amd/modern/functions/createCallback",["../internals/baseCreateCallback","../internals/baseIsEqual","../objects/isObject","../objects/keys","../utilities/property"],function(a,b,c,d,e){function f(f,g,h){var i=typeof f;if(null==f||"function"==i)return a(f,g,h);if("object"!=i)return e(f);var j=d(f),k=j[0],l=f[k];return 1!=j.length||l!==l||c(l)?function(a){for(var c=j.length,d=!1;c--&&(d=b(a[j[c]],f[j[c]],null,!0)););return d}:function(a){var b=a[k];return l===b&&(0!==l||1/l==1/b)}}return f}),c("lodash-amd/modern/objects/forOwn",["../internals/baseCreateCallback","./keys","../internals/objectTypes"],function(a,b,c){var d=function(d,e,f){var g,h=d,i=h;if(!h)return i;if(!c[typeof h])return i;e=e&&"undefined"==typeof f?e:a(e,f,3);for(var j=-1,k=c[typeof h]&&b(h),l=k?k.length:0;++j-1||a.indexOf("/")>-1||a.indexOf("www")>-1||a.indexOf("http://")>-1||a.indexOf("https://")>-1||""===a?!1:!0}function e(a){c(),k.show(),a.addClass("link-edit"),setTimeout(function(){$("body, .link-tools .close").bind("click",f),l.val(a.attr("href").replace(m,"")),l[0].focus()},10)}function f(a){0===$(a.target).closest(".link-tools").length&&g()}function g(){b.updateContents(function(){var a=l.val();""===a?h():$(".link-edit, [href="+m+"]").attr("href",a).removeClass("link-edit")},!1),$("body, .link-tools .close").unbind("click"),k.hide()}function h(){var a=$(".link-edit, [href*="+m+"]");a[0].outerHTML=a[0].innerHTML}var i=b.el.parentNode,j=new b.api.Command("createLink"),k=$(".link-tools",i),l=$(".link-tools input",i),m="#replaceme",n=$(".search-results",k),o=a.searchHandler||function(){};j.nodeName="A",j.execute=function(){var a=this,c=new b.api.Selection;c.range.collapsed||(b._skipFormatters=!0,b.api.SimpleCommand.prototype.execute.call(a,m),e($("a[href*="+m+"]")))},$(".remove",k).click(function(){l.val(""),g()}),$(".ok",k).click(g),n.click(function(a){var b=$(a.target).closest("a");1===b.length&&(a.preventDefault(),l.val(b.attr("href")),c())}),l.bind("keyup",c).bind("keydown",function(a){(13===a.keyCode||27===a.keyCode)&&g()}),b.el.addEventListener("click",function(a){var c=(new b.api.Selection,$(a.target).closest("a"));1===c.length&&(e(c),a.preventDefault())});var p;j.queryState=function(){var a=new b.api.Selection;return!!a.getContaining(function(a){return a.nodeName===this.nodeName}.bind(this))},b.commands.linkUI=j}}}),function(a,b){"function"==typeof c&&c.amd?c("html-janitor",b):a.amdWeb=b()}(this,function(){function a(a){this.config=a}function b(a){return-1!==e.indexOf(a.nodeName)}function c(a){return-1!==f.indexOf(a.nodeName)}function d(a){return document.createTreeWalker(a,NodeFilter.SHOW_TEXT|NodeFilter.SHOW_ELEMENT|NodeFilter.SHOW_COMMENT)}var e=["P","LI","DIV"],f=["A","B","DEL","I","U"];return a.prototype.clean=function(a){var b=document.createElement("div");return b.innerHTML=a,this._sanitize(b),b.innerHTML},a.prototype._sanitize=function(a){var e=d(a),f=e.firstChild();if(f)do{var g=f.nodeName.toLowerCase(),h=this.config.tags[g];if(!f._sanitized){if(this.config.skipSanitization(f))return;if(f.nodeType!==Node.TEXT_NODE){if(f.nodeType===Node.COMMENT_NODE){a.removeChild(f),this._sanitize(a);break}var i,j=c(f);j&&(i=Array.prototype.some.call(f.childNodes,b));var k=j&&i,l=!!a.parentNode,m=b(a)&&b(f)&&l;if(!this.config.tags[g]||k||m){if("SCRIPT"!==f.nodeName&&"STYLE"!==f.nodeName)for(;f.childNodes.length>0;)a.insertBefore(f.childNodes[0],f);a.removeChild(f),this._sanitize(a);break}for(var n=0;ne?0:e);++d2?a(c,17,b(arguments,2),null,d):a(c,1,null,null,d)}return c}),c("lodash-amd/modern/utilities/identity",[],function(){function a(a){return a}return a}),c("lodash-amd/modern/support",["./internals/isNative"],function(a){var b=/\bthis\b/,c={};return c.funcDecomp=!a(window.WinRTError)&&b.test(function(){return this}),c.funcNames="string"==typeof Function.name,c}),c("lodash-amd/modern/internals/baseCreateCallback",["../functions/bind","../utilities/identity","./setBindData","../support"],function(a,b,c,d){function e(e,i,j){if("function"!=typeof e)return b;if("undefined"==typeof i||!("prototype"in e))return e;var k=e.__bindData__;if("undefined"==typeof k&&(d.funcNames&&(k=!e.name),k=k||!d.funcDecomp,!k)){var l=h.call(e);d.funcNames||(k=!f.test(l)),k||(k=g.test(l),c(e,k))}if(k===!1||k!==!0&&1&k[1])return e;switch(j){case 1:return function(a){return e.call(i,a)};case 2:return function(a,b){return e.call(i,a,b)};case 3:return function(a,b,c){return e.call(i,a,b,c)};case 4:return function(a,b,c,d){return e.call(i,a,b,c,d)}}return a(e,i)}var f=/^\s*function[ \n\r\t]+\w/,g=/\bthis\b/,h=Function.prototype.toString;return e}),c("lodash-amd/modern/internals/shimKeys",["./objectTypes"],function(a){var b=Object.prototype,c=b.hasOwnProperty,d=function(b){var d,e=b,f=[];if(!e)return f;if(!a[typeof b])return f;for(d in e)c.call(e,d)&&f.push(d);return f};return d}),c("lodash-amd/modern/objects/keys",["../internals/isNative","./isObject","../internals/shimKeys"],function(a,b,c){var d=a(d=Object.keys)&&d,e=d?function(a){return b(a)?d(a):[]}:c;return e}),c("lodash-amd/modern/objects/forOwn",["../internals/baseCreateCallback","./keys","../internals/objectTypes"],function(a,b,c){var d=function(d,e,f){var g,h=d,i=h;if(!h)return i;if(!c[typeof h])return i;e=e&&"undefined"==typeof f?e:a(e,f,3);for(var j=-1,k=c[typeof h]&&b(h),l=k?k.length:0;++j3&&"function"==typeof h[i-2])var j=a(h[--i-1],h[i--],2);else i>2&&"function"==typeof h[i-1]&&(j=h[--i]);for(var k=f(arguments,1,i),l=-1,m=c(),n=c();++l3&&"function"==typeof j[l-2])var m=a(j[--l-1],j[l--],2);else l>2&&"function"==typeof j[l-1]&&(m=j[--l]);for(;++ke?0:e);++d2?a(c,17,b(arguments,2),null,d):a(c,1,null,null,d)}return c}),c("lodash-amd/modern/utilities/identity",[],function(){function a(a){return a}return a}),c("lodash-amd/modern/support",["./internals/isNative"],function(a){var b=/\bthis\b/,c={};return c.funcDecomp=!a(window.WinRTError)&&b.test(function(){return this}),c.funcNames="string"==typeof Function.name,c}),c("lodash-amd/modern/internals/baseCreateCallback",["../functions/bind","../utilities/identity","./setBindData","../support"],function(a,b,c,d){function e(e,i,j){if("function"!=typeof e)return b;if("undefined"==typeof i||!("prototype"in e))return e;var k=e.__bindData__;if("undefined"==typeof k&&(d.funcNames&&(k=!e.name),k=k||!d.funcDecomp,!k)){var l=h.call(e);d.funcNames||(k=!f.test(l)),k||(k=g.test(l),c(e,k))}if(k===!1||k!==!0&&1&k[1])return e;switch(j){case 1:return function(a){return e.call(i,a)};case 2:return function(a,b){return e.call(i,a,b)};case 3:return function(a,b,c){return e.call(i,a,b,c)};case 4:return function(a,b,c,d){return e.call(i,a,b,c,d)}}return a(e,i)}var f=/^\s*function[ \n\r\t]+\w/,g=/\bthis\b/,h=Function.prototype.toString;return e}),c("lodash-amd/modern/internals/shimKeys",["./objectTypes"],function(a){var b=Object.prototype,c=b.hasOwnProperty,d=function(b){var d,e=b,f=[];if(!e)return f;if(!a[typeof b])return f;for(d in e)c.call(e,d)&&f.push(d);return f};return d}),c("lodash-amd/modern/objects/keys",["../internals/isNative","./isObject","../internals/shimKeys"],function(a,b,c){var d=a(d=Object.keys)&&d,e=d?function(a){return b(a)?d(a):[]}:c;return e}),c("lodash-amd/modern/objects/forOwn",["../internals/baseCreateCallback","./keys","../internals/objectTypes"],function(a,b,c){var d=function(d,e,f){var g,h=d,i=h;if(!h)return i;if(!c[typeof h])return i;e=e&&"undefined"==typeof f?e:a(e,f,3);for(var j=-1,k=c[typeof h]&&b(h),l=k?k.length:0;++jh?f(0,k+h):h)||0,c(e)?l=j(e,g,h)>-1:"number"==typeof k?l=(d(e)?e.indexOf(g,h):j(e,g,h))>-1:b(e,function(a){return++i>=h?!(l=a===g):void 0}),l}var f=Math.max;return e}),c("scribe-common/src/element",["lodash-amd/modern/collections/contains"],function(a){function b(b){return a(e,b.nodeName)}function c(a){return a.nodeType===Node.ELEMENT_NODE&&"scribe-marker"===a.className}function d(a,b){for(;b.childNodes.length>0;)a.insertBefore(b.childNodes[0],b);a.removeChild(b)}var e=["P","LI","DIV","BLOCKQUOTE","UL","OL","H1","H2","H3","H4","H5","H6"];return{isBlockElement:b,isSelectionMarkerNode:c,unwrap:d}}),c("scribe-plugin-smart-lists",["scribe-common/src/element"],function(a){return function(){function b(a){return"*"===a||"-"===a||"•"===a}function c(b){for(;b&&!a.isBlockElement(b);)b=b.parentNode;return b}var d={32:"Space",42:"*",45:"-",46:".",49:"1",8226:"•"};return function(a){function e(){var b,c=new a.api.Selection,d=c.selection.anchorNode;if(d.nodeType===Node.TEXT_NODE?b=d:d.firstChild.nodeType===Node.TEXT_NODE&&(b=d.firstChild),!b)throw new Error("Cannot empty non-text node!");var e=b.parentNode;b.previousSibling&&e.removeChild(b.previousSibling),e.removeChild(b)}function f(f){var j;g=h,h=i,i=d[f.charCode];var k=new a.api.Selection,l=k.range.commonAncestorContainer,m=c(l);if(m&&"P"===m.tagName){var n=b(l.textContent[0]);b(h)&&"Space"===i&&n&&(j="insertUnorderedList");var o="1."===[l.previousSibling&&l.previousSibling.textContent,l.textContent].join("").slice(0,2);"1"===g&&"."===h&&"Space"===i&&o&&(j="insertOrderedList")}j&&(f.preventDefault(),a.transactionManager.run(function(){a.getCommand(j).execute(),e()}))}var g,h,i;a.el.addEventListener("keypress",f)}}}),c("scribe-plugin-toolbar",[],function(){return function(a){return function(b){var c=a.querySelectorAll("[data-command-name]");Array.prototype.forEach.call(c,function(a){function c(){var c=b.getCommand(a.dataset.commandName),d=new b.api.Selection;d.range&&c.queryState(a.dataset.commandValue)?a.classList.add("active"):a.classList.remove("active"),d.range&&c.queryEnabled()?a.removeAttribute("disabled"):a.setAttribute("disabled","disabled")}a.addEventListener("click",function(){var c=b.getCommand(a.dataset.commandName);b.el.focus(),c.execute(a.dataset.commandValue)}),b.el.addEventListener("keyup",c),b.el.addEventListener("mouseup",c),b.el.addEventListener("focus",c),b.el.addEventListener("blur",c),b.on("content-changed",c)})}}}),c("scribe-plugin-inline-objects",[],function(){return function(a){return function(b){function c(a){n=a,$(".embed-button",q).click(d),$(".inline-tools button",q.parentNode).click(function(a){var b=$(a.target).data("commandName");"function"==typeof r[b]&&r[b]()})}function d(a){var c,d,g=$(".embed-fly-out").height(),h=$(".embed-button").height(),i=$(a.target).closest("button").data("commandName");"embed-before"===i?(c=o.position().top-g/2+h/2,d="before"):(c=o.position().top+o.height()+parseInt(o.css("margin-top"))-g/2+h/2,d="after"),$(".embed-fly-out",q).css({top:c,left:$(b.el).css("padding-left")}).show();var j=o;$(".embed-fly-out button").bind("click.inline",function(a){var b=$(a.target).closest("button").data("commandName");f(b,j,d)}),$("body").bind("click.inline",function(a){0===$(a.target).closest(".embed-tools").length&&e()})}function e(){$("body").unbind("click.inline"),$(".embed-fly-out button").unbind("click.inline"),$(".embed-fly-out").hide()}function f(a,c,d){b.trigger("inline:insert:"+a,[function(e){b.updateContents(function(){var f=$(m(n[a].template,$.extend(n[a].defaults,e)));$(c)[d](f),$(".inline",q).attr("contenteditable",!1),b.trigger("inline:insert:"+a+":done",[f])})}]),$(".embed-tools",q).removeClass("active")}function g(){$(".inline-tools").hide(),$(q).removeClass("inline-active")}function h(){var a=$(p),b=a.position();$(q).addClass("inline-active"),$(".inline-tools").attr("data-type",a.attr("data-type")),$(".inline-tools .size",q).html($(p).attr("data-size")),$(".inline-tools .crop",q).html($(p).attr("data-crop")),$(".inline-tools",q).css({top:b.top+parseInt(a.css("margin-top")),left:b.left+parseInt(a.css("margin-left"))+parseInt($(".editor",q).css("margin-left")),width:a.width(),height:a.height()}).show()}function i(){return n[$(p).attr("data-type")].size}function j(){return n[$(p).attr("data-type")].crop}function k(a,b){var c=$(p).attr("data-"+a),d=b.indexOf(c)+1;d>=b.length&&(d=0),l(a,b[d]),"function"==typeof window.picturefill&&setTimeout(function(){window.picturefill(p)},100)}function l(a,c){var d=$(p).attr("data-"+a);b.updateContents(function(){$(p).removeClass(a+"-"+d).addClass(a+"-"+c).attr("data-"+a,c),h()})}function m(a,b){for(var c in b)c&&(a=a.replace(new RegExp("{{"+c+"}}","g"),b[c]));return a}var n,o,p,q=b.el.parentNode;b.el.addEventListener("mouseover",function(a){var c=$(a.target).closest(".editor>*");1===c.length?($(".embed-tools",q).css({width:$(b.el).css("padding-left"),top:c.position().top+c.css("margin-top").replace(/[^-\d\.]/g,"")/2,height:c.height()}).addClass("active"),o=c):$(".embed-tools",q).removeClass("active")}),b.el.parentNode.addEventListener("mouseleave",function(){g(),$(".embed-tools",q).removeClass("active")}),$(".embed-tools",q).mouseover(function(){$(".embed-tools",q).addClass("active")}),$(".editor",q).mouseover(function(a){var b=$(a.target).parents(".inline");1===b.length?(p=b[b.length-1],h()):g()});var r={inline_caption:function(){var a=prompt("Caption",$(".caption",p).html());(a||""===a)&&b.updateContents(function(){$(".caption",p).html(a)})},inline_size:function(){var a=i();k("size",a);var b=$(p).attr("data-crop"),c=j();-1===c.indexOf(b)&&l("crop",c[0])},inline_crop:function(){var a=n[$(p).attr("data-type")].crop;k("crop",a)},inline_up:function(){g();var a=$(p).prev()[0];if(a){var c=$(p).offset().top;b.updateContents(function(){$(p).after(a),setTimeout(function(){h();var a=$(p).offset().top;window.scrollBy(0,a-c)},0)})}},inline_down:function(){g();var a=$(p).next()[0];if(a){var c=$(p).offset().top;b.updateContents(function(){$(p).before(a),setTimeout(function(){h();var a=$(p).offset().top;window.scrollBy(0,a-c)},0)})}},inline_remove:function(){b.updateContents(function(){$(p).remove()}),g()},inline_edit:function(){b.trigger("inline:edit:"+$(p).attr("data-type"),[p,function(a,c){var d=$(a).attr("data-type");b.updateContents(function(){a.outerHTML=m(n[d].template,$.extend(n[d].defaults,c)),b.trigger("inline:edit:"+d+":done",[$(p)])})}])}};"string"==typeof a||a instanceof String?$.ajax(a,{success:c,dataType:"json"}):c(a)}}}),c("scribe-plugin-betty-cropper",[],function(){return function(a){return function(b){function c(b){a.insertDialog().then(function(a){var c;c=-1!==a.name.toUpperCase().indexOf("GIF")?"gif":"jpg",b({image_id:a.id,format:c}),window.picturefill&&setTimeout(function(){window.picturefill($("[data-image-id="+a.id+"]")[0])},100)},function(a){console.log(a)},function(a){console.log(a)})}function d(b){e=b.getAttribute("data-image-id");var c=$(".caption",b).html(),d=b.getAttribute("data-alt");a.editDialog({id:e,caption:c,alt:d}).then(function(a){null===a.id?$(b).remove():($(b).attr("data-image-id",a.id),$(b).attr("data-alt",a.alt),$(".caption",b).html(a.caption),window.picturefill&&setTimeout(function(){window.picturefill($("[data-image-id="+a.id+"]")[0])},100))})}var e;b.on("inline:edit:image",d),b.on("inline:insert:image",c)}}}),c("scribe-plugin-youtube",[],function(){return function(){return function(a){function b(a){if(!a)return!1;var b=/^.*((youtu.be\/)|(v\/)|(\/u\/\w\/)|(embed\/)|(watch\?))\??v?=?([^#\&\?]*).*/,c=a.match(b);return c&&11==c[7].length?c[7]:!1}function c(a){var c=prompt("Youtube URL:"),d=b(c);d&&a({youtube_id:d,caption:""})}function d(a,c){var d=prompt("Youtube URL:",$(a).attr("data-youtube-id")||""),e=b(d);e&&c(a,{youtube_id:e,caption:$(".caption",a).html()})}a.on("inline:insert:youtube",c),a.on("inline:edit:youtube",d)}}}),c("scribe-plugin-embed",[],function(){return function(){return function(a){function b(a,b){h.val(unescape($(a).attr("data-code"))),i.val($(".caption",a).text());var c=$(a).attr("data-size")+"-"+$(a).attr("data-crop");$("[value="+c+"]",g).attr("checked",!0),g.modal("show"),j.click(function(){var c=h.val();""===c.trim()?k.show():(k.hide(),b(a,{code:c,caption:i.val(),escaped_code:escape(c),size:d(),crop:e()}),g.modal("hide"))}),g.modal("show")}function c(a){h.val(""),i.val(""),g.modal("show"),j.click(function(){var b=h.val();""===b.trim()?k.show():(k.hide(),a({code:b,caption:i.val(),escaped_code:escape(b),size:d(),crop:e()}),g.modal("hide"))})}function d(){var a="original";return l.length>0&&l.val().split("-")[0],a}function e(){var a="original";return l.length>0&&l.val().split("-")[1],a}a.on("inline:insert:embed",c),a.on("inline:edit:embed",b);var f=a.el.parentNode,g=$(".embed-modal",f),h=$(".embed-body",g),i=$(".embed-caption",g),j=$(".set-embed-button",g),k=$(".embed-error",g),l=$("[name=size]",g);g.on("hide.bs.modal",function(){j.unbind("click"),k.hide()})}}}),c("scribe-plugin-embed-instagram",[],function(){return function(){return function(a){var b=$(a.el.parentNode).find(".embed-modal"),c=b.find(".embed-caption"),d=b.find(".embed-error"),e=b.find(".embed-body"),f=b.find(".set-embed-button");b.on("hide.bs.modal",function(){f.off("click"),d.hide()});var g=function(a){e.val(""),c.val(""),f.on("click",function(){var f=e.val();f.trim()?(d.hide(),a({html:escape(f),caption:c.val()}),b.modal("hide")):d.show()}),b.modal("show")},h=function(a,g){var h=$(a),i=h.children(".embed-container"),j=i.instagramEmbedProcessor().data("pluginInstagramEmbedProcessor");e.val(j.html()),c.val(h.children(".caption").text()),f.on("click",function(){var f=e.val();f.trim()?(d.hide(),g(a,{html:escape(f),caption:c.val()}),b.modal("hide")):d.show()}),b.modal("show")},i=function(a){var b=a.find(".embed-container"),c=b.instagramEmbedProcessor().data("pluginInstagramEmbedProcessor");c.prep()};a.on("inline:insert:embed-instagram",g),a.on("inline:insert:embed-instagram:done",i),a.on("inline:edit:embed-instagram",h),a.on("inline:edit:embed-instagram:done",i)}}}),c("scribe-plugin-onion-video",[],function(){return function(a){return function(b){function c(c){function d(){}function e(){}return a.insertDialog().then(function(d){b.updateContents(function(){c({embed_url:a.videoEmbedUrl,video_id:d.attrs.id})})},function(a){e(a)},function(a){d(a)})}function d(b){var c=$(b).attr("data-video-id")||$(b).attr("data-videoid");a.editDialog(c)}b.on("inline:edit:onion-video",d),b.on("inline:insert:onion-video",c)}}}),c("scribe-plugin-hr",[],function(){return function(){return function(a){function b(a){a({})}a.on("inline:insert:hr",b)}}}),c("scribe-plugin-placeholder",[],function(){return function(a){return function(b){function c(){var c=b.getContent();a.container.style.display="


"===c||""===c?"":"none"}b.on("content-changed",c),a.container.innerHTML=a.text}}}),c("link-formatter",["scribe-common/src/element","lodash-amd/modern/collections/contains"],function(){return function(a){return function(b){function c(b){return b=b.trim(),b=e(b),a.domain&&(b=d(b,a.domain)),b}function d(a,b){var c=document.createElement("a");c.href=a;var d=c.hostname;return d.indexOf(b)>-1&&c.pathname.length>1&&(a=c.pathname+c.search+c.hash),a}function e(a){return"http://"!==a.substr(0,7)&&"https://"!==a.substr(0,8)&&"mailto:"!==a.substr(0,7)&&"/"!==a.substr(0,1)?-1!=a.indexOf("@")?"mailto:"+a:"http://"+a:a}function f(a){for(var b=a.firstElementChild;b;)"A"===b.nodeName?b.hasAttribute("href")&&b.setAttribute("href",c(b.getAttribute("href"))):b.children.length>0&&f(b),b=b.nextElementSibling}b.registerHTMLFormatter("sanitize",function(a){var b=document.createElement("div");return b.innerHTML=a,f(b),b.innerHTML})}}}),c("only-trailing-brs",[],function(){return function(){return function(a){a.registerHTMLFormatter("normalize",function(a){return a.replace(/
(.)/g," $1")})}}}),c("paste-strip-newlines",[],function(){return function(){return function(a){a.registerHTMLFormatter("paste",function(a){return a.replace(/\n/g," ")})}}}),c("paste-strip-nbsps",[],function(){return function(){return function(a){a.registerHTMLFormatter("paste",function(a){return a.replace(/ /g," ")}),a.registerHTMLFormatter("normalize",function(a){return a.replace(/ /g," ")})}}}),c("paste-from-word",["scribe-common/src/element"],function(a){return function(){return function(b){function c(a){return/0&&d(c),"A"===c.nodeName&&(c.href||a.unwrap(b,c)),c=e}}b.registerHTMLFormatter("paste",function(a){if(!c(a))return a;a=a.replace(//gi,""),a=a.replace(/<(!|script[^>]*>.*?<\/script(?=[>\s])|\/?(\?xml(:\w+)?|img|meta|link|style|\w:\w+)(?=[\s\/>]))[^>]*>/gi,"");var b=document.createElement("div");return b.innerHTML=a,d(b),b.innerHTML})}}}),c("paste-sanitize",["scribe-common/src/element"],function(a){return function(){return function(b){function c(b){for(var d=b.firstElementChild;d;){var e=d.nextElementSibling;d.children.length>0&&c(d),d.hasAttribute("style")&&d.removeAttribute("style"),"P"===d.nodeName&&""===d.textContent.trim()&&b.removeChild(d),"SPAN"===d.nodeName&&a.unwrap(b,d),d=e}}b.registerHTMLFormatter("paste",function(a){var b=document.createElement("div");b.innerHTML=a;var d=[].slice.call(b.childNodes);return d.forEach(function(a){3===a.nodeType&&""===a.textContent.trim()&&b.removeChild(a)}),c(b),b.innerHTML})}}}),c("remove-a-styles",["scribe-common/src/element"],function(){return function(){return function(a){function b(a){for(var c=a.firstElementChild;c;)"A"===c.nodeName&&c.hasAttribute("style")?c.removeAttribute("style"):c.children.length>0&&b(c),c=c.nextElementSibling}a.registerHTMLFormatter("sanitize",function(a){var c=document.createElement("div");return c.innerHTML=a,b(c),c.innerHTML})}}}),c("strip-bold-in-headings",["scribe-common/src/element"],function(a){return function(){return function(b){function c(b){for(var d=b.firstElementChild;d;)"B"===d.nodeName&&/^(H[1-6])$/.test(b.nodeName)?a.unwrap(b,d):d.children.length>0&&c(d),d=d.nextElementSibling}b.registerHTMLFormatter("sanitize",function(a){var b=document.createElement("div");return b.innerHTML=a,c(b),b.innerHTML})}}}),c("scribe-plugin-anchor",[],function(){return function(){return function(a){function b(a){return a.toString().toLowerCase().replace(/\s+/g,"-").replace(/[^\w\-]+/g,"").replace(/\-\-+/g,"-").trim()}var c=new a.api.Command("anchor");c.queryEnabled=function(){var b=new a.api.Selection,c=b.getContaining(function(){return!0});return void 0!==c},c.queryState=function(){var b=new a.api.Selection,c=b.getContaining(function(a){return 3!==a.nodeType});return void 0===c?!1:!!c.id},c.execute=function(){var c=new a.api.Selection;console.log(c);var d=c.getContaining(function(a){return 3!==a.nodeType});console.log(d),a.transactionManager.run(function(){d.id?d.removeAttribute("id"):d.id=b(d.textContent)}.bind(this))},a.commands.toggleAnchor=c}}}),c("our-ensure-selectable-containers",["scribe-common/src/element","lodash-amd/modern/collections/contains"],function(a,b){function c(e,f){function g(b){return 0===b.children.length||1===b.children.length&&a.isSelectionMarkerNode(b.children[0])}for(var h=e.firstElementChild;h;)a.isSelectionMarkerNode(h)||(g(h)&&""===h.textContent.trim()&&!b(d,h.nodeName)&&a.isBlockElement(h)?h.appendChild(document.createElement("br")):h.children.length>0&&(f.skipElement&&f.skipElement&&f.skipElement(h)||c(h,f))),h=h.nextElementSibling}var d=["AREA","BASE","BR","COL","COMMAND","EMBED","HR","IMG","INPUT","KEYGEN","LINK","META","PARAM","SOURCE","TRACK","WBR"];return function(a){return function(b){b.registerHTMLFormatter("normalize",function(b){var d=document.createElement("div");return d.innerHTML=b,c(d,a),d.innerHTML})}}}),c("enforce-p-elements",["lodash-amd/modern/arrays/last","scribe-common/src/element"],function(a,b){function c(c){var d=Array.prototype.reduce.call(c.childNodes,function(c,d){function e(){var a=[d];c.push(a)}var f=a(c);if(f){var g=b.isBlockElement(f[0]);g===b.isBlockElement(d)?f.push(d):e()}else e();return c},[]),e=d.filter(function(a){var c=b.isBlockElement(a[0]);return!c});e.forEach(function(a){var b=document.createElement("p");a[0].parentNode.insertBefore(b,a[0]),a.forEach(function(a){b.appendChild(a)})}),c._isWrapped=!0}function d(a){for(var b=document.createTreeWalker(a,NodeFilter.SHOW_ELEMENT),e=b.firstChild();e;){if("BLOCKQUOTE"===e.nodeName&&!e._isWrapped){c(e),d(a);break}e=b.nextSibling()}}return function(){return function(a){a.registerHTMLFormatter("normalize",function(a){var b=document.createElement("div");return b.innerHTML=a,c(b),d(b),b.innerHTML})}}}),c("filter-for-export",["scribe-common/src/element"],function(){"user strict";return function(){return function(a){function b(a){for(var c=a.firstElementChild;c;)c.filterForExport&&c.filterForExport(),c.children.length>0&&b(c),c=c.nextElementSibling}a.registerHTMLFormatter("export",function(a){var c=document.createElement("div");return c.innerHTML=a,b(c),c.innerHTML})}}}),c("onion-editor",["scribe","scribe-plugin-blockquote-command","scribe-plugin-curly-quotes","scribe-plugin-formatter-plain-text-convert-new-lines-to-html","scribe-plugin-heading-command","scribe-plugin-intelligent-unlink-command","scribe-plugin-keyboard-shortcuts","scribe-plugin-link-ui","scribe-plugin-sanitizer","scribe-plugin-smart-lists","scribe-plugin-toolbar","scribe-plugin-inline-objects","scribe-plugin-betty-cropper","scribe-plugin-youtube","scribe-plugin-embed","scribe-plugin-embed-instagram","scribe-plugin-onion-video","scribe-plugin-hr","scribe-plugin-placeholder","link-formatter","only-trailing-brs","paste-strip-newlines","paste-strip-nbsps","paste-from-word","paste-sanitize","remove-a-styles","strip-bold-in-headings","scribe-plugin-anchor","our-ensure-selectable-containers","enforce-p-elements","filter-for-export"],function(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,A,B,C,D,E){function F(u,F){function H(a){return $(a).is("div.inline")}F=$.extend(G,F),$(".inline",u).attr("contenteditable","false");var I=new a(u,{allowBlockElements:F.multiline});I._htmlFormatterFactory.formatters.normalize=[],I.allowsBlockElements()&&(I.use(D()),I.use(C({skipElement:H})));var J=new I.api.CommandPatch("insertHTML");J.execute=function(a){I.transactionManager.run(function(){function b(a){var c=document.createTreeWalker(a,NodeFilter.SHOW_ELEMENT),d=c.firstChild();if(d)do"SPAN"===d.nodeName&&-1===d.className.indexOf("inline")?u.unwrap(a,d):(d.style.lineHeight=null,""===d.getAttribute("style")&&d.removeAttribute("style")),b(d);while(d=c.nextSibling())}I.api.CommandPatch.prototype.execute.call(this,a),b(I.el)}.bind(this))},I.commandPatches.insertHTML=J,F.placeholder&&I.use(s(F.placeholder));var K=new I.api.CommandPatch("bold");K.execute=function(a){void 0===this.selection?document.execCommand(this.commandName,!1,a||null):I.transactionManager.run(function(){document.execCommand(this.commandName,!1,a||null)}.bind(this))},I.commandPatches.bold=K;var L=new I.api.CommandPatch("italic");L.execute=function(a){void 0===this.selection?document.execCommand(this.commandName,!1,a||null):I.transactionManager.run(function(){document.execCommand(this.commandName,!1,a||null)}.bind(this))},I.commandPatches.italic=L;var M=new I.api.CommandPatch("underline");M.execute=function(a){void 0===this.selection?document.execCommand(this.commandName,!1,a||null):I.transactionManager.run(function(){document.execCommand(this.commandName,!1,a||null)}.bind(this))},I.commandPatches.underline=M;var N={},O=function(a){return a.metaKey||a.ctrlKey},P={};if(F.multiline&&(P.p={id:!0},P.br={},P.hr={}),-1!==F.formatting.indexOf("bold")&&(N.bold=function(a){return a.metaKey&&66===a.keyCode},P.b={id:!0}),-1!==F.formatting.indexOf("italic")&&(N.italic=function(a){return a.metaKey&&73===a.keyCode},P.i={id:!0},P.em={id:!0}),-1!==F.formatting.indexOf("strike")&&(N.strikeThrough=function(a){return a.altKey&&a.shiftKey&&83===a.keyCode},P.strike={id:!0}),-1!==F.formatting.indexOf("underline")&&(N.underline=function(a){return a.metaKey&&85===a.keyCode},P.u={id:!0}),N.removeFormat=function(a){return a.altKey&&a.shiftKey&&65===a.keyCode},F.multiline&&-1!==F.formatting.indexOf("link")&&(N.linkUI=function(a){return a.metaKey&&!a.shiftKey&&75===a.keyCode},N.unlink=function(a){return a.metaKey&&a.shiftKey&&75===a.keyCode},I.use(f()),I.use(h(F.link)),I.use(t(F.link)),P.a={href:!0,target:!0,id:!0}),F.multiline&&-1!==F.formatting.indexOf("list")&&(N.insertUnorderedList=function(a){return a.altKey&&a.shiftKey&&66===a.keyCode},N.insertOrderedList=function(a){return a.altKey&&a.shiftKey&&78===a.keyCode},I.use(j()),P.ol={id:!0},P.ul={id:!0},P.li={id:!0}),F.multiline&&-1!==F.formatting.indexOf("blockquote")&&(N.blockquote=function(a){return a.altKey&&a.shiftKey&&87===a.keyCode},I.use(b()),P.blockquote={id:!0}),F.multiline&&-1!==F.formatting.indexOf("heading")&&(N.h3=function(a){return O(a)&&50===a.keyCode},N.h4=function(a){return O(a)&&51===a.keyCode},I.use(e(3)),I.use(e(4)),P.h3={id:!0},P.h4={id:!0}),F.multiline&&F.inlineObjects&&(I.use(l(F.inlineObjects)),I.use(m(F.image)),I.use(n()),I.use(o()),I.use(p()),I.use(r()),I.use(B()),I.use(q(F.video)),I.use(z()),I.use(A())),I.use(i({tags:P,skipSanitization:H})),I.use(x()),I.use(y()),I.use(v()),I.use(w()),F.statsContainer&&setInterval(function(){$(F.statsContainer).html($(I.el).text().split(" ").length)},3e3),I.use(E()),I.updateContents=function(a,b){"undefined"==typeof b&&(b=!0),I._skipFormatters=b;var c=window.scrollY;setTimeout(function(){I.el.focus(),setTimeout(function(){I.transactionManager.run(a),window.scrollTo(0,c),I.trigger("content-changed")},20)},20)},I.use(c()),I.use(g(Object.freeze(N))),F.multiline){var Q=".document-tools .toolbar-contents",R=$(I.el.parentNode).find(Q);I.use(k(R[0],F)),R.hide(),$(I.el).on("focus",function(){R.show(),$(Q).not(R).hide()})}else $(u.parentNode).find(".document-tools .toolbar-contents").hide();return I.el.addEventListener("keydown",function(a){if(8===a.keyCode){var b=new I.api.Selection,c=$(b.selection.anchorNode).closest(".editor>*").prev();c.hasClass("inline")&&0===b.selection.anchorOffset&&b.selection.isCollapsed&&a.preventDefault()}}),I.use(d()),this.setChangeHandler=function(a){I.on("content-changed",a)},this.setContent=function(a){a||(a="


"),I.setContent(a)},this.getContent=function(){var a=I.getContent();return a},this.scribe=I,this}var G={multiline:!0,formatting:["link","bold","italic","blockquote","heading","list","underline"],link:{domain:"avclub.com"},video:{videoEmbedUrl:"http://example.com?videoid=",insertDialog:function(){},editDialog:function(){}},image:{insertDialog:function(){},editDialog:function(){}}};return F}),b("onion-editor")}); \ No newline at end of file diff --git a/src/js/onion-editor.js b/src/js/onion-editor.js index 346200c..ccd00fc 100644 --- a/src/js/onion-editor.js +++ b/src/js/onion-editor.js @@ -341,12 +341,24 @@ define('onion-editor',[ scribe.use(scribePluginCurlyQuotes()); scribe.use(scribePluginKeyboardShortcuts(Object.freeze(keyCommands))); - //TODO: kill this existing toolbar & replace w/ Medium style selection toolbar + // TODO: toolbar setup to allow mutliple toolbars on the page, scribe version + // we're using (theonion/scribe#649a8af55c36ad2536a66a99d4abab57e418ba33, + // scribe-plugin-toolbar#0.2.0) doesn't have support for toolbar sharing or + // mutiple toolbars if (options.multiline) { - scribe.use(scribePluginToolbar($('.document-tools .toolbar-contents', element.parentNode)[0])); - } - else { - $('.document-tools .toolbar-contents', element.parentNode).hide(); + var toolbarSelector = '.document-tools .toolbar-contents'; + var $toolbar = $(scribe.el.parentNode).find(toolbarSelector); + + scribe.use(scribePluginToolbar($toolbar[0], options)); + + $toolbar.hide(); + $(scribe.el) + .on('focus', function () { + $toolbar.show(); + $(toolbarSelector).not($toolbar).hide(); + }); + } else { + $(element.parentNode).find('.document-tools .toolbar-contents').hide(); } // a little hacky to prevent deletion of images and other inline elements via the backspace key.