diff --git a/client/compatibilities/select2/_select2.css b/client/compatibilities/select2/_select2.css deleted file mode 100644 index a45dfb22..00000000 --- a/client/compatibilities/select2/_select2.css +++ /dev/null @@ -1,486 +0,0 @@ -.select2-container { - box-sizing: border-box; - display: inline-block; - margin: 0; - position: relative; - vertical-align: middle; } - .select2-container .select2-selection--single { - box-sizing: border-box; - cursor: pointer; - display: block; - height: 28px; - user-select: none; - -webkit-user-select: none; } - .select2-container .select2-selection--single .select2-selection__rendered { - display: block; - padding-left: 8px; - padding-right: 20px; - overflow: hidden; - text-overflow: ellipsis; - white-space: nowrap; } - .select2-container .select2-selection--single .select2-selection__clear { - position: relative; } - .select2-container[dir="rtl"] .select2-selection--single .select2-selection__rendered { - padding-right: 8px; - padding-left: 20px; } - .select2-container .select2-selection--multiple { - box-sizing: border-box; - cursor: pointer; - display: block; - min-height: 32px; - user-select: none; - -webkit-user-select: none; } - .select2-container .select2-selection--multiple .select2-selection__rendered { - display: inline-block; - overflow: hidden; - padding-left: 8px; - text-overflow: ellipsis; - white-space: nowrap; } - .select2-container .select2-search--inline { - float: left; - width: 250px; } - .select2-container .select2-search--inline .select2-search__field { - box-sizing: border-box; - width: 100% !important; - border: none; - font-size: 100%; - margin-top: 5px; - padding: 0; } - .select2-container .select2-search--inline .select2-search__field::-webkit-search-cancel-button { - -webkit-appearance: none; } - -.select2-dropdown { - background-color: white; - border: 1px solid #aaa; - border-radius: 4px; - box-sizing: border-box; - display: block; - position: absolute; - left: -100000px; - width: 100%; - z-index: 1051; } - -.select2-results { - display: block; } - -.select2-results__options { - list-style: none; - margin: 0; - padding: 0; } - -.select2-results__option { - padding: 6px; - user-select: none; - -webkit-user-select: none; } - .select2-results__option[aria-selected] { - cursor: pointer; } - -.select2-container--open .select2-dropdown { - left: 0; } - -.select2-container--open .select2-dropdown--above { - border-bottom: none; - border-bottom-left-radius: 0; - border-bottom-right-radius: 0; } - -.select2-container--open .select2-dropdown--below { - border-top: none; - border-top-left-radius: 0; - border-top-right-radius: 0; } - -.select2-search--dropdown { - display: block; - padding: 4px; } - .select2-search--dropdown .select2-search__field { - padding: 4px; - width: 100%; - box-sizing: border-box; } - .select2-search--dropdown .select2-search__field::-webkit-search-cancel-button { - -webkit-appearance: none; } - .select2-search--dropdown.select2-search--hide { - display: none; } - -.select2-close-mask { - border: 0; - margin: 0; - padding: 0; - display: block; - position: fixed; - left: 0; - top: 0; - min-height: 100%; - min-width: 100%; - height: auto; - width: auto; - opacity: 0; - z-index: 99; - background-color: #fff; - filter: alpha(opacity=0); } - -.select2-hidden-accessible { - border: 0 !important; - clip: rect(0 0 0 0) !important; - height: 1px !important; - margin: -1px !important; - overflow: hidden !important; - padding: 0 !important; - position: absolute !important; - width: 1px !important; } - -.select2-container--default .select2-selection--single { - background-color: #fff; - border: 1px solid #aaa; - border-radius: 4px; } - .select2-container--default .select2-selection--single .select2-selection__rendered { - color: #444; - line-height: 28px; } - .select2-container--default .select2-selection--single .select2-selection__clear { - cursor: pointer; - float: right; - font-weight: bold; } - .select2-container--default .select2-selection--single .select2-selection__placeholder { - color: #999; } - .select2-container--default .select2-selection--single .select2-selection__arrow { - height: 26px; - position: absolute; - top: 1px; - right: 1px; - width: 20px; } - .select2-container--default .select2-selection--single .select2-selection__arrow b { - border-color: #888 transparent transparent transparent; - border-style: solid; - border-width: 5px 4px 0 4px; - height: 0; - left: 50%; - margin-left: -4px; - margin-top: -2px; - position: absolute; - top: 50%; - width: 0; } - -.select2-container--default[dir="rtl"] .select2-selection--single .select2-selection__clear { - float: left; } - -.select2-container--default[dir="rtl"] .select2-selection--single .select2-selection__arrow { - left: 1px; - right: auto; } - -.select2-container--default.select2-container--disabled .select2-selection--single { - background-color: #eee; - cursor: default; } - .select2-container--default.select2-container--disabled .select2-selection--single .select2-selection__clear { - display: none; } - -.select2-container--default.select2-container--open .select2-selection--single .select2-selection__arrow b { - border-color: transparent transparent #888 transparent; - border-width: 0 4px 5px 4px; } - -.select2-container--default .select2-selection--multiple { - background-color: white; - border: 1px solid #aaa; - border-radius: 4px; - cursor: text; } - .select2-container--default .select2-selection--multiple .select2-selection__rendered { - box-sizing: border-box; - list-style: none; - margin: 0; - padding: 0 5px; - width: 100%; } - .select2-container--default .select2-selection--multiple .select2-selection__rendered li { - list-style: none; } - .select2-container--default .select2-selection--multiple .select2-selection__placeholder { - color: #999; - margin-top: 5px; - float: left; } - .select2-container--default .select2-selection--multiple .select2-selection__clear { - cursor: pointer; - float: right; - font-weight: bold; - margin-top: 5px; - margin-right: 10px; } - .select2-container--default .select2-selection--multiple .select2-selection__choice { - background-color: #e4e4e4; - border: 1px solid #aaa; - border-radius: 4px; - cursor: default; - float: left; - margin-right: 5px; - margin-top: 5px; - padding: 0 5px; } - .select2-container--default .select2-selection--multiple .select2-selection__choice__remove { - color: #999; - cursor: pointer; - display: inline-block; - font-weight: bold; - margin-right: 2px; } - .select2-container--default .select2-selection--multiple .select2-selection__choice__remove:hover { - color: #333; } - -.select2-container--default[dir="rtl"] .select2-selection--multiple .select2-selection__choice, .select2-container--default[dir="rtl"] .select2-selection--multiple .select2-selection__placeholder, .select2-container--default[dir="rtl"] .select2-selection--multiple .select2-search--inline { - float: right; } - -.select2-container--default[dir="rtl"] .select2-selection--multiple .select2-selection__choice { - margin-left: 5px; - margin-right: auto; } - -.select2-container--default[dir="rtl"] .select2-selection--multiple .select2-selection__choice__remove { - margin-left: 2px; - margin-right: auto; } - -.select2-container--default.select2-container--focus .select2-selection--multiple { - border: solid black 1px; - outline: 0; } - -.select2-container--default.select2-container--disabled .select2-selection--multiple { - background-color: #eee; - cursor: default; } - -.select2-container--default.select2-container--disabled .select2-selection__choice__remove { - display: none; } - -.select2-container--default.select2-container--open.select2-container--above .select2-selection--single, .select2-container--default.select2-container--open.select2-container--above .select2-selection--multiple { - border-top-left-radius: 0; - border-top-right-radius: 0; } - -.select2-container--default.select2-container--open.select2-container--below .select2-selection--single, .select2-container--default.select2-container--open.select2-container--below .select2-selection--multiple { - border-bottom-left-radius: 0; - border-bottom-right-radius: 0; } - -.select2-container--default .select2-search--dropdown .select2-search__field { - border: 1px solid #aaa; } - -.select2-container--default .select2-search--inline .select2-search__field { - background: transparent; - border: none; - outline: 0; - box-shadow: none; - -webkit-appearance: textfield; } - -.select2-container--default .select2-results > .select2-results__options { - max-height: 200px; - overflow-y: auto; } - -.select2-container--default .select2-results__option[role=group] { - padding: 0; } - -.select2-container--default .select2-results__option[aria-disabled=true] { - color: #999; } - -.select2-container--default .select2-results__option[aria-selected=true] { - background-color: #ddd; } - -.select2-container--default .select2-results__option .select2-results__option { - padding-left: 1em; } - .select2-container--default .select2-results__option .select2-results__option .select2-results__group { - padding-left: 0; } - .select2-container--default .select2-results__option .select2-results__option .select2-results__option { - margin-left: -1em; - padding-left: 2em; } - .select2-container--default .select2-results__option .select2-results__option .select2-results__option .select2-results__option { - margin-left: -2em; - padding-left: 3em; } - .select2-container--default .select2-results__option .select2-results__option .select2-results__option .select2-results__option .select2-results__option { - margin-left: -3em; - padding-left: 4em; } - .select2-container--default .select2-results__option .select2-results__option .select2-results__option .select2-results__option .select2-results__option .select2-results__option { - margin-left: -4em; - padding-left: 5em; } - .select2-container--default .select2-results__option .select2-results__option .select2-results__option .select2-results__option .select2-results__option .select2-results__option .select2-results__option { - margin-left: -5em; - padding-left: 6em; } - -.select2-container--default .select2-results__option--highlighted[aria-selected] { - background-color: #5897fb; - color: white; } - -.select2-container--default .select2-results__group { - cursor: default; - display: block; - padding: 6px; } - -.select2-container--classic .select2-selection--single { - background-color: #f7f7f7; - border: 1px solid #aaa; - border-radius: 4px; - outline: 0; - background-image: -webkit-linear-gradient(top, white 50%, #eeeeee 100%); - background-image: -o-linear-gradient(top, white 50%, #eeeeee 100%); - background-image: linear-gradient(to bottom, white 50%, #eeeeee 100%); - background-repeat: repeat-x; - filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#FFFFFFFF', endColorstr='#FFEEEEEE', GradientType=0); } - .select2-container--classic .select2-selection--single:focus { - border: 1px solid #5897fb; } - .select2-container--classic .select2-selection--single .select2-selection__rendered { - color: #444; - line-height: 28px; } - .select2-container--classic .select2-selection--single .select2-selection__clear { - cursor: pointer; - float: right; - font-weight: bold; - margin-right: 10px; } - .select2-container--classic .select2-selection--single .select2-selection__placeholder { - color: #999; } - .select2-container--classic .select2-selection--single .select2-selection__arrow { - background-color: #ddd; - border: none; - border-left: 1px solid #aaa; - border-top-right-radius: 4px; - border-bottom-right-radius: 4px; - height: 26px; - position: absolute; - top: 1px; - right: 1px; - width: 20px; - background-image: -webkit-linear-gradient(top, #eeeeee 50%, #cccccc 100%); - background-image: -o-linear-gradient(top, #eeeeee 50%, #cccccc 100%); - background-image: linear-gradient(to bottom, #eeeeee 50%, #cccccc 100%); - background-repeat: repeat-x; - filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#FFEEEEEE', endColorstr='#FFCCCCCC', GradientType=0); } - .select2-container--classic .select2-selection--single .select2-selection__arrow b { - border-color: #888 transparent transparent transparent; - border-style: solid; - border-width: 5px 4px 0 4px; - height: 0; - left: 50%; - margin-left: -4px; - margin-top: -2px; - position: absolute; - top: 50%; - width: 0; } - -.select2-container--classic[dir="rtl"] .select2-selection--single .select2-selection__clear { - float: left; } - -.select2-container--classic[dir="rtl"] .select2-selection--single .select2-selection__arrow { - border: none; - border-right: 1px solid #aaa; - border-radius: 0; - border-top-left-radius: 4px; - border-bottom-left-radius: 4px; - left: 1px; - right: auto; } - -.select2-container--classic.select2-container--open .select2-selection--single { - border: 1px solid #5897fb; } - .select2-container--classic.select2-container--open .select2-selection--single .select2-selection__arrow { - background: transparent; - border: none; } - .select2-container--classic.select2-container--open .select2-selection--single .select2-selection__arrow b { - border-color: transparent transparent #888 transparent; - border-width: 0 4px 5px 4px; } - -.select2-container--classic.select2-container--open.select2-container--above .select2-selection--single { - border-top: none; - border-top-left-radius: 0; - border-top-right-radius: 0; - background-image: -webkit-linear-gradient(top, white 0%, #eeeeee 50%); - background-image: -o-linear-gradient(top, white 0%, #eeeeee 50%); - background-image: linear-gradient(to bottom, white 0%, #eeeeee 50%); - background-repeat: repeat-x; - filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#FFFFFFFF', endColorstr='#FFEEEEEE', GradientType=0); } - -.select2-container--classic.select2-container--open.select2-container--below .select2-selection--single { - border-bottom: none; - border-bottom-left-radius: 0; - border-bottom-right-radius: 0; - background-image: -webkit-linear-gradient(top, #eeeeee 50%, white 100%); - background-image: -o-linear-gradient(top, #eeeeee 50%, white 100%); - background-image: linear-gradient(to bottom, #eeeeee 50%, white 100%); - background-repeat: repeat-x; - filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#FFEEEEEE', endColorstr='#FFFFFFFF', GradientType=0); } - -.select2-container--classic .select2-selection--multiple { - background-color: white; - border: 1px solid #aaa; - border-radius: 4px; - cursor: text; - outline: 0; } - .select2-container--classic .select2-selection--multiple:focus { - border: 1px solid #5897fb; } - .select2-container--classic .select2-selection--multiple .select2-selection__rendered { - list-style: none; - margin: 0; - padding: 0 5px; } - .select2-container--classic .select2-selection--multiple .select2-selection__clear { - display: none; } - .select2-container--classic .select2-selection--multiple .select2-selection__choice { - background-color: #e4e4e4; - border: 1px solid #aaa; - border-radius: 4px; - cursor: default; - float: left; - margin-right: 5px; - margin-top: 5px; - padding: 0 5px; } - .select2-container--classic .select2-selection--multiple .select2-selection__choice__remove { - color: #888; - cursor: pointer; - display: inline-block; - font-weight: bold; - margin-right: 2px; } - .select2-container--classic .select2-selection--multiple .select2-selection__choice__remove:hover { - color: #555; } - -.select2-container--classic[dir="rtl"] .select2-selection--multiple .select2-selection__choice { - float: right; } - -.select2-container--classic[dir="rtl"] .select2-selection--multiple .select2-selection__choice { - margin-left: 5px; - margin-right: auto; } - -.select2-container--classic[dir="rtl"] .select2-selection--multiple .select2-selection__choice__remove { - margin-left: 2px; - margin-right: auto; } - -.select2-container--classic.select2-container--open .select2-selection--multiple { - border: 1px solid #5897fb; } - -.select2-container--classic.select2-container--open.select2-container--above .select2-selection--multiple { - border-top: none; - border-top-left-radius: 0; - border-top-right-radius: 0; } - -.select2-container--classic.select2-container--open.select2-container--below .select2-selection--multiple { - border-bottom: none; - border-bottom-left-radius: 0; - border-bottom-right-radius: 0; } - -.select2-container--classic .select2-search--dropdown .select2-search__field { - border: 1px solid #aaa; - outline: 0; } - -.select2-container--classic .select2-search--inline .select2-search__field { - outline: 0; - box-shadow: none; } - -.select2-container--classic .select2-dropdown { - background-color: white; - border: 1px solid transparent; } - -.select2-container--classic .select2-dropdown--above { - border-bottom: none; } - -.select2-container--classic .select2-dropdown--below { - border-top: none; } - -.select2-container--classic .select2-results > .select2-results__options { - max-height: 200px; - overflow-y: auto; } - -.select2-container--classic .select2-results__option[role=group] { - padding: 0; } - -.select2-container--classic .select2-results__option[aria-disabled=true] { - color: grey; } - -.select2-container--classic .select2-results__option--highlighted[aria-selected] { - background-color: #3875d7; - color: white; } - -.select2-container--classic .select2-results__group { - cursor: default; - display: block; - padding: 6px; } - -.select2-container--classic.select2-container--open .select2-dropdown { - border-color: #5897fb; } diff --git a/client/compatibilities/select2/select2.min.js b/client/compatibilities/select2/select2.min.js deleted file mode 100644 index 5a12c63f..00000000 --- a/client/compatibilities/select2/select2.min.js +++ /dev/null @@ -1,3 +0,0 @@ -/*! Select2 4.0.3 | https://github.com/select2/select2/blob/master/LICENSE.md */!function(a){"function"==typeof define&&define.amd?define(["jquery"],a):a("object"==typeof exports?require("jquery"):jQuery)}(function(a){var b=function(){if(a&&a.fn&&a.fn.select2&&a.fn.select2.amd)var b=a.fn.select2.amd;var b;return function(){if(!b||!b.requirejs){b?c=b:b={};var a,c,d;!function(b){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(a=a.split("/"),g=a.length-1,s.nodeIdCompat&&w.test(a[g])&&(a[g]=a[g].replace(w,"")),a=n.slice(0,n.length-1).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,c){return function(){var d=v.call(arguments,0);return"string"!=typeof d[0]&&1===d.length&&d.push(null),n.apply(b,d.concat([a,c]))}}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 c=r[a];delete r[a],t[a]=!0,m.apply(b,c)}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,c,d,f){var h,k,l,m,n,s,u=[],v=typeof d;if(f=f||a,"undefined"===v||"function"===v){for(c=!c.length&&d.length?["require","exports","module"]:c,n=0;n0&&(b.call(arguments,a.prototype.constructor),e=c.prototype.constructor),e.apply(this,arguments)}function e(){this.constructor=d}var f=b(c),g=b(a);c.displayName=a.displayName,d.prototype=new e;for(var h=0;hc;c++)a[c].apply(this,b)},c.Observable=d,c.generateChars=function(a){for(var b="",c=0;a>c;c++){var d=Math.floor(36*Math.random());b+=d.toString(36)}return b},c.bind=function(a,b){return function(){a.apply(b,arguments)}},c._convertData=function(a){for(var b in a){var c=b.split("-"),d=a;if(1!==c.length){for(var e=0;e":">",'"':""","'":"'","/":"/"};return"string"!=typeof a?a:String(a).replace(/[&<>"'\/\\]/g,function(a){return b[a]})},c.appendMany=function(b,c){if("1.7"===a.fn.jquery.substr(0,3)){var d=a();a.map(c,function(a){d=d.add(a)}),c=d}b.append(c)},c}),b.define("select2/results",["jquery","./utils"],function(a,b){function c(a,b,d){this.$element=a,this.data=d,this.options=b,c.__super__.constructor.call(this)}return b.Extend(c,b.Observable),c.prototype.render=function(){var b=a('
    ');return this.options.get("multiple")&&b.attr("aria-multiselectable","true"),this.$results=b,b},c.prototype.clear=function(){this.$results.empty()},c.prototype.displayMessage=function(b){var c=this.options.get("escapeMarkup");this.clear(),this.hideLoading();var d=a('
  • '),e=this.options.get("translations").get(b.message);d.append(c(e(b.args))),d[0].className+=" select2-results__message",this.$results.append(d)},c.prototype.hideMessages=function(){this.$results.find(".select2-results__message").remove()},c.prototype.append=function(a){this.hideLoading();var b=[];if(null==a.results||0===a.results.length)return void(0===this.$results.children().length&&this.trigger("results:message",{message:"noResults"}));a.results=this.sort(a.results);for(var c=0;c0?b.first().trigger("mouseenter"):a.first().trigger("mouseenter"),this.ensureHighlightVisible()},c.prototype.setClasses=function(){var b=this;this.data.current(function(c){var d=a.map(c,function(a){return a.id.toString()}),e=b.$results.find(".select2-results__option[aria-selected]");e.each(function(){var b=a(this),c=a.data(this,"data"),e=""+c.id;null!=c.element&&c.element.selected||null==c.element&&a.inArray(e,d)>-1?b.attr("aria-selected","true"):b.attr("aria-selected","false")})})},c.prototype.showLoading=function(a){this.hideLoading();var b=this.options.get("translations").get("searching"),c={disabled:!0,loading:!0,text:b(a)},d=this.option(c);d.className+=" loading-results",this.$results.prepend(d)},c.prototype.hideLoading=function(){this.$results.find(".loading-results").remove()},c.prototype.option=function(b){var c=document.createElement("li");c.className="select2-results__option";var d={role:"treeitem","aria-selected":"false"};b.disabled&&(delete d["aria-selected"],d["aria-disabled"]="true"),null==b.id&&delete d["aria-selected"],null!=b._resultId&&(c.id=b._resultId),b.title&&(c.title=b.title),b.children&&(d.role="group",d["aria-label"]=b.text,delete d["aria-selected"]);for(var e in d){var f=d[e];c.setAttribute(e,f)}if(b.children){var g=a(c),h=document.createElement("strong");h.className="select2-results__group";a(h);this.template(b,h);for(var i=[],j=0;j",{"class":"select2-results__options select2-results__options--nested"});m.append(i),g.append(h),g.append(m)}else this.template(b,c);return a.data(c,"data",b),c},c.prototype.bind=function(b,c){var d=this,e=b.id+"-results";this.$results.attr("id",e),b.on("results:all",function(a){d.clear(),d.append(a.data),b.isOpen()&&(d.setClasses(),d.highlightFirstItem())}),b.on("results:append",function(a){d.append(a.data),b.isOpen()&&d.setClasses()}),b.on("query",function(a){d.hideMessages(),d.showLoading(a)}),b.on("select",function(){b.isOpen()&&(d.setClasses(),d.highlightFirstItem())}),b.on("unselect",function(){b.isOpen()&&(d.setClasses(),d.highlightFirstItem())}),b.on("open",function(){d.$results.attr("aria-expanded","true"),d.$results.attr("aria-hidden","false"),d.setClasses(),d.ensureHighlightVisible()}),b.on("close",function(){d.$results.attr("aria-expanded","false"),d.$results.attr("aria-hidden","true"),d.$results.removeAttr("aria-activedescendant")}),b.on("results:toggle",function(){var a=d.getHighlightedResults();0!==a.length&&a.trigger("mouseup")}),b.on("results:select",function(){var a=d.getHighlightedResults();if(0!==a.length){var b=a.data("data");"true"==a.attr("aria-selected")?d.trigger("close",{}):d.trigger("select",{data:b})}}),b.on("results:previous",function(){var a=d.getHighlightedResults(),b=d.$results.find("[aria-selected]"),c=b.index(a);if(0!==c){var e=c-1;0===a.length&&(e=0);var f=b.eq(e);f.trigger("mouseenter");var g=d.$results.offset().top,h=f.offset().top,i=d.$results.scrollTop()+(h-g);0===e?d.$results.scrollTop(0):0>h-g&&d.$results.scrollTop(i)}}),b.on("results:next",function(){var a=d.getHighlightedResults(),b=d.$results.find("[aria-selected]"),c=b.index(a),e=c+1;if(!(e>=b.length)){var f=b.eq(e);f.trigger("mouseenter");var g=d.$results.offset().top+d.$results.outerHeight(!1),h=f.offset().top+f.outerHeight(!1),i=d.$results.scrollTop()+h-g;0===e?d.$results.scrollTop(0):h>g&&d.$results.scrollTop(i)}}),b.on("results:focus",function(a){a.element.addClass("select2-results__option--highlighted")}),b.on("results:message",function(a){d.displayMessage(a)}),a.fn.mousewheel&&this.$results.on("mousewheel",function(a){var b=d.$results.scrollTop(),c=d.$results.get(0).scrollHeight-b+a.deltaY,e=a.deltaY>0&&b-a.deltaY<=0,f=a.deltaY<0&&c<=d.$results.height();e?(d.$results.scrollTop(0),a.preventDefault(),a.stopPropagation()):f&&(d.$results.scrollTop(d.$results.get(0).scrollHeight-d.$results.height()),a.preventDefault(),a.stopPropagation())}),this.$results.on("mouseup",".select2-results__option[aria-selected]",function(b){var c=a(this),e=c.data("data");return"true"===c.attr("aria-selected")?void(d.options.get("multiple")?d.trigger("unselect",{originalEvent:b,data:e}):d.trigger("close",{})):void d.trigger("select",{originalEvent:b,data:e})}),this.$results.on("mouseenter",".select2-results__option[aria-selected]",function(b){var c=a(this).data("data");d.getHighlightedResults().removeClass("select2-results__option--highlighted"),d.trigger("results:focus",{data:c,element:a(this)})})},c.prototype.getHighlightedResults=function(){var a=this.$results.find(".select2-results__option--highlighted");return a},c.prototype.destroy=function(){this.$results.remove()},c.prototype.ensureHighlightVisible=function(){var a=this.getHighlightedResults();if(0!==a.length){var b=this.$results.find("[aria-selected]"),c=b.index(a),d=this.$results.offset().top,e=a.offset().top,f=this.$results.scrollTop()+(e-d),g=e-d;f-=2*a.outerHeight(!1),2>=c?this.$results.scrollTop(0):(g>this.$results.outerHeight()||0>g)&&this.$results.scrollTop(f)}},c.prototype.template=function(b,c){var d=this.options.get("templateResult"),e=this.options.get("escapeMarkup"),f=d(b,c);null==f?c.style.display="none":"string"==typeof f?c.innerHTML=e(f):a(c).append(f)},c}),b.define("select2/keys",[],function(){var a={BACKSPACE:8,TAB:9,ENTER:13,SHIFT:16,CTRL:17,ALT:18,ESC:27,SPACE:32,PAGE_UP:33,PAGE_DOWN:34,END:35,HOME:36,LEFT:37,UP:38,RIGHT:39,DOWN:40,DELETE:46};return a}),b.define("select2/selection/base",["jquery","../utils","../keys"],function(a,b,c){function d(a,b){this.$element=a,this.options=b,d.__super__.constructor.call(this)}return b.Extend(d,b.Observable),d.prototype.render=function(){var b=a('');return this._tabindex=0,null!=this.$element.data("old-tabindex")?this._tabindex=this.$element.data("old-tabindex"):null!=this.$element.attr("tabindex")&&(this._tabindex=this.$element.attr("tabindex")),b.attr("title",this.$element.attr("title")),b.attr("tabindex",this._tabindex),this.$selection=b,b},d.prototype.bind=function(a,b){var d=this,e=(a.id+"-container",a.id+"-results");this.container=a,this.$selection.on("focus",function(a){d.trigger("focus",a)}),this.$selection.on("blur",function(a){d._handleBlur(a)}),this.$selection.on("keydown",function(a){d.trigger("keypress",a),a.which===c.SPACE&&a.preventDefault()}),a.on("results:focus",function(a){d.$selection.attr("aria-activedescendant",a.data._resultId)}),a.on("selection:update",function(a){d.update(a.data)}),a.on("open",function(){d.$selection.attr("aria-expanded","true"),d.$selection.attr("aria-owns",e),d._attachCloseHandler(a)}),a.on("close",function(){d.$selection.attr("aria-expanded","false"),d.$selection.removeAttr("aria-activedescendant"),d.$selection.removeAttr("aria-owns"),d.$selection.focus(),d._detachCloseHandler(a)}),a.on("enable",function(){d.$selection.attr("tabindex",d._tabindex)}),a.on("disable",function(){d.$selection.attr("tabindex","-1")})},d.prototype._handleBlur=function(b){var c=this;window.setTimeout(function(){document.activeElement==c.$selection[0]||a.contains(c.$selection[0],document.activeElement)||c.trigger("blur",b)},1)},d.prototype._attachCloseHandler=function(b){a(document.body).on("mousedown.select2."+b.id,function(b){var c=a(b.target),d=c.closest(".select2"),e=a(".select2.select2-container--open");e.each(function(){var b=a(this);if(this!=d[0]){var c=b.data("element");c.select2("close")}})})},d.prototype._detachCloseHandler=function(b){a(document.body).off("mousedown.select2."+b.id)},d.prototype.position=function(a,b){var c=b.find(".selection");c.append(a)},d.prototype.destroy=function(){this._detachCloseHandler(this.container)},d.prototype.update=function(a){throw new Error("The `update` method must be defined in child classes.")},d}),b.define("select2/selection/single",["jquery","./base","../utils","../keys"],function(a,b,c,d){function e(){e.__super__.constructor.apply(this,arguments)}return c.Extend(e,b),e.prototype.render=function(){var a=e.__super__.render.call(this);return a.addClass("select2-selection--single"),a.html(''),a},e.prototype.bind=function(a,b){var c=this;e.__super__.bind.apply(this,arguments);var d=a.id+"-container";this.$selection.find(".select2-selection__rendered").attr("id",d),this.$selection.attr("aria-labelledby",d),this.$selection.on("mousedown",function(a){1===a.which&&c.trigger("toggle",{originalEvent:a})}),this.$selection.on("focus",function(a){}),this.$selection.on("blur",function(a){}),a.on("focus",function(b){a.isOpen()||c.$selection.focus()}),a.on("selection:update",function(a){c.update(a.data)})},e.prototype.clear=function(){this.$selection.find(".select2-selection__rendered").empty()},e.prototype.display=function(a,b){var c=this.options.get("templateSelection"),d=this.options.get("escapeMarkup");return d(c(a,b))},e.prototype.selectionContainer=function(){return a("")},e.prototype.update=function(a){if(0===a.length)return void this.clear();var b=a[0],c=this.$selection.find(".select2-selection__rendered"),d=this.display(b,c);c.empty().append(d),c.prop("title",b.title||b.text)},e}),b.define("select2/selection/multiple",["jquery","./base","../utils"],function(a,b,c){function d(a,b){d.__super__.constructor.apply(this,arguments)}return c.Extend(d,b),d.prototype.render=function(){var a=d.__super__.render.call(this);return a.addClass("select2-selection--multiple"),a.html('
      '),a},d.prototype.bind=function(b,c){var e=this;d.__super__.bind.apply(this,arguments),this.$selection.on("click",function(a){e.trigger("toggle",{originalEvent:a})}),this.$selection.on("click",".select2-selection__choice__remove",function(b){if(!e.options.get("disabled")){var c=a(this),d=c.parent(),f=d.data("data");e.trigger("unselect",{originalEvent:b,data:f})}})},d.prototype.clear=function(){this.$selection.find(".select2-selection__rendered").empty()},d.prototype.display=function(a,b){var c=this.options.get("templateSelection"),d=this.options.get("escapeMarkup");return d(c(a,b))},d.prototype.selectionContainer=function(){var b=a('
    • ×
    • ');return b},d.prototype.update=function(a){if(this.clear(),0!==a.length){for(var b=[],d=0;d1;if(d||c)return a.call(this,b);this.clear();var e=this.createPlaceholder(this.placeholder);this.$selection.find(".select2-selection__rendered").append(e)},b}),b.define("select2/selection/allowClear",["jquery","../keys"],function(a,b){function c(){}return c.prototype.bind=function(a,b,c){var d=this;a.call(this,b,c),null==this.placeholder&&this.options.get("debug")&&window.console&&console.error&&console.error("Select2: The `allowClear` option should be used in combination with the `placeholder` option."),this.$selection.on("mousedown",".select2-selection__clear",function(a){d._handleClear(a)}),b.on("keypress",function(a){d._handleKeyboardClear(a,b)})},c.prototype._handleClear=function(a,b){if(!this.options.get("disabled")){var c=this.$selection.find(".select2-selection__clear");if(0!==c.length){b.stopPropagation();for(var d=c.data("data"),e=0;e0||0===c.length)){var d=a('×');d.data("data",c),this.$selection.find(".select2-selection__rendered").prepend(d)}},c}),b.define("select2/selection/search",["jquery","../utils","../keys"],function(a,b,c){function d(a,b,c){a.call(this,b,c)}return d.prototype.render=function(b){var c=a('');this.$searchContainer=c,this.$search=c.find("input");var d=b.call(this);return this._transferTabIndex(),d},d.prototype.bind=function(a,b,d){var e=this;a.call(this,b,d),b.on("open",function(){e.$search.trigger("focus")}),b.on("close",function(){e.$search.val(""),e.$search.removeAttr("aria-activedescendant"),e.$search.trigger("focus")}),b.on("enable",function(){e.$search.prop("disabled",!1),e._transferTabIndex()}),b.on("disable",function(){e.$search.prop("disabled",!0)}),b.on("focus",function(a){e.$search.trigger("focus")}),b.on("results:focus",function(a){e.$search.attr("aria-activedescendant",a.id)}),this.$selection.on("focusin",".select2-search--inline",function(a){e.trigger("focus",a)}),this.$selection.on("focusout",".select2-search--inline",function(a){e._handleBlur(a)}),this.$selection.on("keydown",".select2-search--inline",function(a){a.stopPropagation(),e.trigger("keypress",a),e._keyUpPrevented=a.isDefaultPrevented();var b=a.which;if(b===c.BACKSPACE&&""===e.$search.val()){var d=e.$searchContainer.prev(".select2-selection__choice");if(d.length>0){var f=d.data("data");e.searchRemoveChoice(f),a.preventDefault()}}});var f=document.documentMode,g=f&&11>=f;this.$selection.on("input.searchcheck",".select2-search--inline",function(a){return g?void e.$selection.off("input.search input.searchcheck"):void e.$selection.off("keyup.search")}),this.$selection.on("keyup.search input.search",".select2-search--inline",function(a){if(g&&"input"===a.type)return void e.$selection.off("input.search input.searchcheck");var b=a.which;b!=c.SHIFT&&b!=c.CTRL&&b!=c.ALT&&b!=c.TAB&&e.handleSearch(a)})},d.prototype._transferTabIndex=function(a){this.$search.attr("tabindex",this.$selection.attr("tabindex")),this.$selection.attr("tabindex","-1")},d.prototype.createPlaceholder=function(a,b){this.$search.attr("placeholder",b.text)},d.prototype.update=function(a,b){var c=this.$search[0]==document.activeElement;this.$search.attr("placeholder",""),a.call(this,b),this.$selection.find(".select2-selection__rendered").append(this.$searchContainer),this.resizeSearch(),c&&this.$search.focus()},d.prototype.handleSearch=function(){if(this.resizeSearch(),!this._keyUpPrevented){var a=this.$search.val();this.trigger("query",{term:a})}this._keyUpPrevented=!1},d.prototype.searchRemoveChoice=function(a,b){this.trigger("unselect",{data:b}),this.$search.val(b.text),this.handleSearch()},d.prototype.resizeSearch=function(){this.$search.css("width","25px");var a="";if(""!==this.$search.attr("placeholder"))a=this.$selection.find(".select2-selection__rendered").innerWidth();else{var b=this.$search.val().length+1;a=.75*b+"em"}this.$search.css("width",a)},d}),b.define("select2/selection/eventRelay",["jquery"],function(a){function b(){}return b.prototype.bind=function(b,c,d){var e=this,f=["open","opening","close","closing","select","selecting","unselect","unselecting"],g=["opening","closing","selecting","unselecting"];b.call(this,c,d),c.on("*",function(b,c){if(-1!==a.inArray(b,f)){c=c||{};var d=a.Event("select2:"+b,{params:c});e.$element.trigger(d),-1!==a.inArray(b,g)&&(c.prevented=d.isDefaultPrevented())}})},b}),b.define("select2/translation",["jquery","require"],function(a,b){function c(a){this.dict=a||{}}return c.prototype.all=function(){return this.dict},c.prototype.get=function(a){return this.dict[a]},c.prototype.extend=function(b){this.dict=a.extend({},b.all(),this.dict)},c._cache={},c.loadPath=function(a){if(!(a in c._cache)){var d=b(a);c._cache[a]=d}return new c(c._cache[a])},c}),b.define("select2/diacritics",[],function(){var a={"Ⓐ":"A","A":"A","À":"A","Á":"A","Â":"A","Ầ":"A","Ấ":"A","Ẫ":"A","Ẩ":"A","Ã":"A","Ā":"A","Ă":"A","Ằ":"A","Ắ":"A","Ẵ":"A","Ẳ":"A","Ȧ":"A","Ǡ":"A","Ä":"A","Ǟ":"A","Ả":"A","Å":"A","Ǻ":"A","Ǎ":"A","Ȁ":"A","Ȃ":"A","Ạ":"A","Ậ":"A","Ặ":"A","Ḁ":"A","Ą":"A","Ⱥ":"A","Ɐ":"A","Ꜳ":"AA","Æ":"AE","Ǽ":"AE","Ǣ":"AE","Ꜵ":"AO","Ꜷ":"AU","Ꜹ":"AV","Ꜻ":"AV","Ꜽ":"AY","Ⓑ":"B","B":"B","Ḃ":"B","Ḅ":"B","Ḇ":"B","Ƀ":"B","Ƃ":"B","Ɓ":"B","Ⓒ":"C","C":"C","Ć":"C","Ĉ":"C","Ċ":"C","Č":"C","Ç":"C","Ḉ":"C","Ƈ":"C","Ȼ":"C","Ꜿ":"C","Ⓓ":"D","D":"D","Ḋ":"D","Ď":"D","Ḍ":"D","Ḑ":"D","Ḓ":"D","Ḏ":"D","Đ":"D","Ƌ":"D","Ɗ":"D","Ɖ":"D","Ꝺ":"D","DZ":"DZ","DŽ":"DZ","Dz":"Dz","Dž":"Dz","Ⓔ":"E","E":"E","È":"E","É":"E","Ê":"E","Ề":"E","Ế":"E","Ễ":"E","Ể":"E","Ẽ":"E","Ē":"E","Ḕ":"E","Ḗ":"E","Ĕ":"E","Ė":"E","Ë":"E","Ẻ":"E","Ě":"E","Ȅ":"E","Ȇ":"E","Ẹ":"E","Ệ":"E","Ȩ":"E","Ḝ":"E","Ę":"E","Ḙ":"E","Ḛ":"E","Ɛ":"E","Ǝ":"E","Ⓕ":"F","F":"F","Ḟ":"F","Ƒ":"F","Ꝼ":"F","Ⓖ":"G","G":"G","Ǵ":"G","Ĝ":"G","Ḡ":"G","Ğ":"G","Ġ":"G","Ǧ":"G","Ģ":"G","Ǥ":"G","Ɠ":"G","Ꞡ":"G","Ᵹ":"G","Ꝿ":"G","Ⓗ":"H","H":"H","Ĥ":"H","Ḣ":"H","Ḧ":"H","Ȟ":"H","Ḥ":"H","Ḩ":"H","Ḫ":"H","Ħ":"H","Ⱨ":"H","Ⱶ":"H","Ɥ":"H","Ⓘ":"I","I":"I","Ì":"I","Í":"I","Î":"I","Ĩ":"I","Ī":"I","Ĭ":"I","İ":"I","Ï":"I","Ḯ":"I","Ỉ":"I","Ǐ":"I","Ȉ":"I","Ȋ":"I","Ị":"I","Į":"I","Ḭ":"I","Ɨ":"I","Ⓙ":"J","J":"J","Ĵ":"J","Ɉ":"J","Ⓚ":"K","K":"K","Ḱ":"K","Ǩ":"K","Ḳ":"K","Ķ":"K","Ḵ":"K","Ƙ":"K","Ⱪ":"K","Ꝁ":"K","Ꝃ":"K","Ꝅ":"K","Ꞣ":"K","Ⓛ":"L","L":"L","Ŀ":"L","Ĺ":"L","Ľ":"L","Ḷ":"L","Ḹ":"L","Ļ":"L","Ḽ":"L","Ḻ":"L","Ł":"L","Ƚ":"L","Ɫ":"L","Ⱡ":"L","Ꝉ":"L","Ꝇ":"L","Ꞁ":"L","LJ":"LJ","Lj":"Lj","Ⓜ":"M","M":"M","Ḿ":"M","Ṁ":"M","Ṃ":"M","Ɱ":"M","Ɯ":"M","Ⓝ":"N","N":"N","Ǹ":"N","Ń":"N","Ñ":"N","Ṅ":"N","Ň":"N","Ṇ":"N","Ņ":"N","Ṋ":"N","Ṉ":"N","Ƞ":"N","Ɲ":"N","Ꞑ":"N","Ꞥ":"N","NJ":"NJ","Nj":"Nj","Ⓞ":"O","O":"O","Ò":"O","Ó":"O","Ô":"O","Ồ":"O","Ố":"O","Ỗ":"O","Ổ":"O","Õ":"O","Ṍ":"O","Ȭ":"O","Ṏ":"O","Ō":"O","Ṑ":"O","Ṓ":"O","Ŏ":"O","Ȯ":"O","Ȱ":"O","Ö":"O","Ȫ":"O","Ỏ":"O","Ő":"O","Ǒ":"O","Ȍ":"O","Ȏ":"O","Ơ":"O","Ờ":"O","Ớ":"O","Ỡ":"O","Ở":"O","Ợ":"O","Ọ":"O","Ộ":"O","Ǫ":"O","Ǭ":"O","Ø":"O","Ǿ":"O","Ɔ":"O","Ɵ":"O","Ꝋ":"O","Ꝍ":"O","Ƣ":"OI","Ꝏ":"OO","Ȣ":"OU","Ⓟ":"P","P":"P","Ṕ":"P","Ṗ":"P","Ƥ":"P","Ᵽ":"P","Ꝑ":"P","Ꝓ":"P","Ꝕ":"P","Ⓠ":"Q","Q":"Q","Ꝗ":"Q","Ꝙ":"Q","Ɋ":"Q","Ⓡ":"R","R":"R","Ŕ":"R","Ṙ":"R","Ř":"R","Ȑ":"R","Ȓ":"R","Ṛ":"R","Ṝ":"R","Ŗ":"R","Ṟ":"R","Ɍ":"R","Ɽ":"R","Ꝛ":"R","Ꞧ":"R","Ꞃ":"R","Ⓢ":"S","S":"S","ẞ":"S","Ś":"S","Ṥ":"S","Ŝ":"S","Ṡ":"S","Š":"S","Ṧ":"S","Ṣ":"S","Ṩ":"S","Ș":"S","Ş":"S","Ȿ":"S","Ꞩ":"S","Ꞅ":"S","Ⓣ":"T","T":"T","Ṫ":"T","Ť":"T","Ṭ":"T","Ț":"T","Ţ":"T","Ṱ":"T","Ṯ":"T","Ŧ":"T","Ƭ":"T","Ʈ":"T","Ⱦ":"T","Ꞇ":"T","Ꜩ":"TZ","Ⓤ":"U","U":"U","Ù":"U","Ú":"U","Û":"U","Ũ":"U","Ṹ":"U","Ū":"U","Ṻ":"U","Ŭ":"U","Ü":"U","Ǜ":"U","Ǘ":"U","Ǖ":"U","Ǚ":"U","Ủ":"U","Ů":"U","Ű":"U","Ǔ":"U","Ȕ":"U","Ȗ":"U","Ư":"U","Ừ":"U","Ứ":"U","Ữ":"U","Ử":"U","Ự":"U","Ụ":"U","Ṳ":"U","Ų":"U","Ṷ":"U","Ṵ":"U","Ʉ":"U","Ⓥ":"V","V":"V","Ṽ":"V","Ṿ":"V","Ʋ":"V","Ꝟ":"V","Ʌ":"V","Ꝡ":"VY","Ⓦ":"W","W":"W","Ẁ":"W","Ẃ":"W","Ŵ":"W","Ẇ":"W","Ẅ":"W","Ẉ":"W","Ⱳ":"W","Ⓧ":"X","X":"X","Ẋ":"X","Ẍ":"X","Ⓨ":"Y","Y":"Y","Ỳ":"Y","Ý":"Y","Ŷ":"Y","Ỹ":"Y","Ȳ":"Y","Ẏ":"Y","Ÿ":"Y","Ỷ":"Y","Ỵ":"Y","Ƴ":"Y","Ɏ":"Y","Ỿ":"Y","Ⓩ":"Z","Z":"Z","Ź":"Z","Ẑ":"Z","Ż":"Z","Ž":"Z","Ẓ":"Z","Ẕ":"Z","Ƶ":"Z","Ȥ":"Z","Ɀ":"Z","Ⱬ":"Z","Ꝣ":"Z","ⓐ":"a","a":"a","ẚ":"a","à":"a","á":"a","â":"a","ầ":"a","ấ":"a","ẫ":"a","ẩ":"a","ã":"a","ā":"a","ă":"a","ằ":"a","ắ":"a","ẵ":"a","ẳ":"a","ȧ":"a","ǡ":"a","ä":"a","ǟ":"a","ả":"a","å":"a","ǻ":"a","ǎ":"a","ȁ":"a","ȃ":"a","ạ":"a","ậ":"a","ặ":"a","ḁ":"a","ą":"a","ⱥ":"a","ɐ":"a","ꜳ":"aa","æ":"ae","ǽ":"ae","ǣ":"ae","ꜵ":"ao","ꜷ":"au","ꜹ":"av","ꜻ":"av","ꜽ":"ay","ⓑ":"b","b":"b","ḃ":"b","ḅ":"b","ḇ":"b","ƀ":"b","ƃ":"b","ɓ":"b","ⓒ":"c","c":"c","ć":"c","ĉ":"c","ċ":"c","č":"c","ç":"c","ḉ":"c","ƈ":"c","ȼ":"c","ꜿ":"c","ↄ":"c","ⓓ":"d","d":"d","ḋ":"d","ď":"d","ḍ":"d","ḑ":"d","ḓ":"d","ḏ":"d","đ":"d","ƌ":"d","ɖ":"d","ɗ":"d","ꝺ":"d","dz":"dz","dž":"dz","ⓔ":"e","e":"e","è":"e","é":"e","ê":"e","ề":"e","ế":"e","ễ":"e","ể":"e","ẽ":"e","ē":"e","ḕ":"e","ḗ":"e","ĕ":"e","ė":"e","ë":"e","ẻ":"e","ě":"e","ȅ":"e","ȇ":"e","ẹ":"e","ệ":"e","ȩ":"e","ḝ":"e","ę":"e","ḙ":"e","ḛ":"e","ɇ":"e","ɛ":"e","ǝ":"e","ⓕ":"f","f":"f","ḟ":"f","ƒ":"f","ꝼ":"f","ⓖ":"g","g":"g","ǵ":"g","ĝ":"g","ḡ":"g","ğ":"g","ġ":"g","ǧ":"g","ģ":"g","ǥ":"g","ɠ":"g","ꞡ":"g","ᵹ":"g","ꝿ":"g","ⓗ":"h","h":"h","ĥ":"h","ḣ":"h","ḧ":"h","ȟ":"h","ḥ":"h","ḩ":"h","ḫ":"h","ẖ":"h","ħ":"h","ⱨ":"h","ⱶ":"h","ɥ":"h","ƕ":"hv","ⓘ":"i","i":"i","ì":"i","í":"i","î":"i","ĩ":"i","ī":"i","ĭ":"i","ï":"i","ḯ":"i","ỉ":"i","ǐ":"i","ȉ":"i","ȋ":"i","ị":"i","į":"i","ḭ":"i","ɨ":"i","ı":"i","ⓙ":"j","j":"j","ĵ":"j","ǰ":"j","ɉ":"j","ⓚ":"k","k":"k","ḱ":"k","ǩ":"k","ḳ":"k","ķ":"k","ḵ":"k","ƙ":"k","ⱪ":"k","ꝁ":"k","ꝃ":"k","ꝅ":"k","ꞣ":"k","ⓛ":"l","l":"l","ŀ":"l","ĺ":"l","ľ":"l","ḷ":"l","ḹ":"l","ļ":"l","ḽ":"l","ḻ":"l","ſ":"l","ł":"l","ƚ":"l","ɫ":"l","ⱡ":"l","ꝉ":"l","ꞁ":"l","ꝇ":"l","lj":"lj","ⓜ":"m","m":"m","ḿ":"m","ṁ":"m","ṃ":"m","ɱ":"m","ɯ":"m","ⓝ":"n","n":"n","ǹ":"n","ń":"n","ñ":"n","ṅ":"n","ň":"n","ṇ":"n","ņ":"n","ṋ":"n","ṉ":"n","ƞ":"n","ɲ":"n","ʼn":"n","ꞑ":"n","ꞥ":"n","nj":"nj","ⓞ":"o","o":"o","ò":"o","ó":"o","ô":"o","ồ":"o","ố":"o","ỗ":"o","ổ":"o","õ":"o","ṍ":"o","ȭ":"o","ṏ":"o","ō":"o","ṑ":"o","ṓ":"o","ŏ":"o","ȯ":"o","ȱ":"o","ö":"o","ȫ":"o","ỏ":"o","ő":"o","ǒ":"o","ȍ":"o","ȏ":"o","ơ":"o","ờ":"o","ớ":"o","ỡ":"o","ở":"o","ợ":"o","ọ":"o","ộ":"o","ǫ":"o","ǭ":"o","ø":"o","ǿ":"o","ɔ":"o","ꝋ":"o","ꝍ":"o","ɵ":"o","ƣ":"oi","ȣ":"ou","ꝏ":"oo","ⓟ":"p","p":"p","ṕ":"p","ṗ":"p","ƥ":"p","ᵽ":"p","ꝑ":"p","ꝓ":"p","ꝕ":"p","ⓠ":"q","q":"q","ɋ":"q","ꝗ":"q","ꝙ":"q","ⓡ":"r","r":"r","ŕ":"r","ṙ":"r","ř":"r","ȑ":"r","ȓ":"r","ṛ":"r","ṝ":"r","ŗ":"r","ṟ":"r","ɍ":"r","ɽ":"r","ꝛ":"r","ꞧ":"r","ꞃ":"r","ⓢ":"s","s":"s","ß":"s","ś":"s","ṥ":"s","ŝ":"s","ṡ":"s","š":"s","ṧ":"s","ṣ":"s","ṩ":"s","ș":"s","ş":"s","ȿ":"s","ꞩ":"s","ꞅ":"s","ẛ":"s","ⓣ":"t","t":"t","ṫ":"t","ẗ":"t","ť":"t","ṭ":"t","ț":"t","ţ":"t","ṱ":"t","ṯ":"t","ŧ":"t","ƭ":"t","ʈ":"t","ⱦ":"t","ꞇ":"t","ꜩ":"tz","ⓤ":"u","u":"u","ù":"u","ú":"u","û":"u","ũ":"u","ṹ":"u","ū":"u","ṻ":"u","ŭ":"u","ü":"u","ǜ":"u","ǘ":"u","ǖ":"u","ǚ":"u","ủ":"u","ů":"u","ű":"u","ǔ":"u","ȕ":"u","ȗ":"u","ư":"u","ừ":"u","ứ":"u","ữ":"u","ử":"u","ự":"u","ụ":"u","ṳ":"u","ų":"u","ṷ":"u","ṵ":"u","ʉ":"u","ⓥ":"v","v":"v","ṽ":"v","ṿ":"v","ʋ":"v","ꝟ":"v","ʌ":"v","ꝡ":"vy","ⓦ":"w","w":"w","ẁ":"w","ẃ":"w","ŵ":"w","ẇ":"w","ẅ":"w","ẘ":"w","ẉ":"w","ⱳ":"w","ⓧ":"x","x":"x","ẋ":"x","ẍ":"x","ⓨ":"y","y":"y","ỳ":"y","ý":"y","ŷ":"y","ỹ":"y","ȳ":"y","ẏ":"y","ÿ":"y","ỷ":"y","ẙ":"y","ỵ":"y","ƴ":"y","ɏ":"y","ỿ":"y","ⓩ":"z","z":"z","ź":"z","ẑ":"z","ż":"z","ž":"z","ẓ":"z","ẕ":"z","ƶ":"z","ȥ":"z","ɀ":"z","ⱬ":"z","ꝣ":"z","Ά":"Α","Έ":"Ε","Ή":"Η","Ί":"Ι","Ϊ":"Ι","Ό":"Ο","Ύ":"Υ","Ϋ":"Υ","Ώ":"Ω","ά":"α","έ":"ε","ή":"η","ί":"ι","ϊ":"ι","ΐ":"ι","ό":"ο","ύ":"υ","ϋ":"υ","ΰ":"υ","ω":"ω","ς":"σ"};return a}),b.define("select2/data/base",["../utils"],function(a){function b(a,c){b.__super__.constructor.call(this)}return a.Extend(b,a.Observable),b.prototype.current=function(a){throw new Error("The `current` method must be defined in child classes.")},b.prototype.query=function(a,b){throw new Error("The `query` method must be defined in child classes.")},b.prototype.bind=function(a,b){},b.prototype.destroy=function(){},b.prototype.generateResultId=function(b,c){var d=b.id+"-result-";return d+=a.generateChars(4),d+=null!=c.id?"-"+c.id.toString():"-"+a.generateChars(4)},b}),b.define("select2/data/select",["./base","../utils","jquery"],function(a,b,c){function d(a,b){this.$element=a,this.options=b,d.__super__.constructor.call(this)}return b.Extend(d,a),d.prototype.current=function(a){var b=[],d=this;this.$element.find(":selected").each(function(){var a=c(this),e=d.item(a);b.push(e)}),a(b)},d.prototype.select=function(a){var b=this;if(a.selected=!0,c(a.element).is("option"))return a.element.selected=!0,void this.$element.trigger("change"); -if(this.$element.prop("multiple"))this.current(function(d){var e=[];a=[a],a.push.apply(a,d);for(var f=0;f=0){var k=f.filter(d(j)),l=this.item(k),m=c.extend(!0,{},j,l),n=this.option(m);k.replaceWith(n)}else{var o=this.option(j);if(j.children){var p=this.convertToOptions(j.children);b.appendMany(o,p)}h.push(o)}}return h},d}),b.define("select2/data/ajax",["./array","../utils","jquery"],function(a,b,c){function d(a,b){this.ajaxOptions=this._applyDefaults(b.get("ajax")),null!=this.ajaxOptions.processResults&&(this.processResults=this.ajaxOptions.processResults),d.__super__.constructor.call(this,a,b)}return b.Extend(d,a),d.prototype._applyDefaults=function(a){var b={data:function(a){return c.extend({},a,{q:a.term})},transport:function(a,b,d){var e=c.ajax(a);return e.then(b),e.fail(d),e}};return c.extend({},b,a,!0)},d.prototype.processResults=function(a){return a},d.prototype.query=function(a,b){function d(){var d=f.transport(f,function(d){var f=e.processResults(d,a);e.options.get("debug")&&window.console&&console.error&&(f&&f.results&&c.isArray(f.results)||console.error("Select2: The AJAX results did not return an array in the `results` key of the response.")),b(f)},function(){d.status&&"0"===d.status||e.trigger("results:message",{message:"errorLoading"})});e._request=d}var e=this;null!=this._request&&(c.isFunction(this._request.abort)&&this._request.abort(),this._request=null);var f=c.extend({type:"GET"},this.ajaxOptions);"function"==typeof f.url&&(f.url=f.url.call(this.$element,a)),"function"==typeof f.data&&(f.data=f.data.call(this.$element,a)),this.ajaxOptions.delay&&null!=a.term?(this._queryTimeout&&window.clearTimeout(this._queryTimeout),this._queryTimeout=window.setTimeout(d,this.ajaxOptions.delay)):d()},d}),b.define("select2/data/tags",["jquery"],function(a){function b(b,c,d){var e=d.get("tags"),f=d.get("createTag");void 0!==f&&(this.createTag=f);var g=d.get("insertTag");if(void 0!==g&&(this.insertTag=g),b.call(this,c,d),a.isArray(e))for(var h=0;h0&&b.term.length>this.maximumInputLength?void this.trigger("results:message",{message:"inputTooLong",args:{maximum:this.maximumInputLength,input:b.term,params:b}}):void a.call(this,b,c)},a}),b.define("select2/data/maximumSelectionLength",[],function(){function a(a,b,c){this.maximumSelectionLength=c.get("maximumSelectionLength"),a.call(this,b,c)}return a.prototype.query=function(a,b,c){var d=this;this.current(function(e){var f=null!=e?e.length:0;return d.maximumSelectionLength>0&&f>=d.maximumSelectionLength?void d.trigger("results:message",{message:"maximumSelected",args:{maximum:d.maximumSelectionLength}}):void a.call(d,b,c)})},a}),b.define("select2/dropdown",["jquery","./utils"],function(a,b){function c(a,b){this.$element=a,this.options=b,c.__super__.constructor.call(this)}return b.Extend(c,b.Observable),c.prototype.render=function(){var b=a('');return b.attr("dir",this.options.get("dir")),this.$dropdown=b,b},c.prototype.bind=function(){},c.prototype.position=function(a,b){},c.prototype.destroy=function(){this.$dropdown.remove()},c}),b.define("select2/dropdown/search",["jquery","../utils"],function(a,b){function c(){}return c.prototype.render=function(b){var c=b.call(this),d=a('');return this.$searchContainer=d,this.$search=d.find("input"),c.prepend(d),c},c.prototype.bind=function(b,c,d){var e=this;b.call(this,c,d),this.$search.on("keydown",function(a){e.trigger("keypress",a),e._keyUpPrevented=a.isDefaultPrevented()}),this.$search.on("input",function(b){a(this).off("keyup")}),this.$search.on("keyup input",function(a){e.handleSearch(a)}),c.on("open",function(){e.$search.attr("tabindex",0),e.$search.focus(),window.setTimeout(function(){e.$search.focus()},0)}),c.on("close",function(){e.$search.attr("tabindex",-1),e.$search.val("")}),c.on("focus",function(){c.isOpen()&&e.$search.focus()}),c.on("results:all",function(a){if(null==a.query.term||""===a.query.term){var b=e.showSearch(a);b?e.$searchContainer.removeClass("select2-search--hide"):e.$searchContainer.addClass("select2-search--hide")}})},c.prototype.handleSearch=function(a){if(!this._keyUpPrevented){var b=this.$search.val();this.trigger("query",{term:b})}this._keyUpPrevented=!1},c.prototype.showSearch=function(a,b){return!0},c}),b.define("select2/dropdown/hidePlaceholder",[],function(){function a(a,b,c,d){this.placeholder=this.normalizePlaceholder(c.get("placeholder")),a.call(this,b,c,d)}return a.prototype.append=function(a,b){b.results=this.removePlaceholder(b.results),a.call(this,b)},a.prototype.normalizePlaceholder=function(a,b){return"string"==typeof b&&(b={id:"",text:b}),b},a.prototype.removePlaceholder=function(a,b){for(var c=b.slice(0),d=b.length-1;d>=0;d--){var e=b[d];this.placeholder.id===e.id&&c.splice(d,1)}return c},a}),b.define("select2/dropdown/infiniteScroll",["jquery"],function(a){function b(a,b,c,d){this.lastParams={},a.call(this,b,c,d),this.$loadingMore=this.createLoadingMore(),this.loading=!1}return b.prototype.append=function(a,b){this.$loadingMore.remove(),this.loading=!1,a.call(this,b),this.showLoadingMore(b)&&this.$results.append(this.$loadingMore)},b.prototype.bind=function(b,c,d){var e=this;b.call(this,c,d),c.on("query",function(a){e.lastParams=a,e.loading=!0}),c.on("query:append",function(a){e.lastParams=a,e.loading=!0}),this.$results.on("scroll",function(){var b=a.contains(document.documentElement,e.$loadingMore[0]);if(!e.loading&&b){var c=e.$results.offset().top+e.$results.outerHeight(!1),d=e.$loadingMore.offset().top+e.$loadingMore.outerHeight(!1);c+50>=d&&e.loadMore()}})},b.prototype.loadMore=function(){this.loading=!0;var b=a.extend({},{page:1},this.lastParams);b.page++,this.trigger("query:append",b)},b.prototype.showLoadingMore=function(a,b){return b.pagination&&b.pagination.more},b.prototype.createLoadingMore=function(){var b=a('
    • '),c=this.options.get("translations").get("loadingMore");return b.html(c(this.lastParams)),b},b}),b.define("select2/dropdown/attachBody",["jquery","../utils"],function(a,b){function c(b,c,d){this.$dropdownParent=d.get("dropdownParent")||a(document.body),b.call(this,c,d)}return c.prototype.bind=function(a,b,c){var d=this,e=!1;a.call(this,b,c),b.on("open",function(){d._showDropdown(),d._attachPositioningHandler(b),e||(e=!0,b.on("results:all",function(){d._positionDropdown(),d._resizeDropdown()}),b.on("results:append",function(){d._positionDropdown(),d._resizeDropdown()}))}),b.on("close",function(){d._hideDropdown(),d._detachPositioningHandler(b)}),this.$dropdownContainer.on("mousedown",function(a){a.stopPropagation()})},c.prototype.destroy=function(a){a.call(this),this.$dropdownContainer.remove()},c.prototype.position=function(a,b,c){b.attr("class",c.attr("class")),b.removeClass("select2"),b.addClass("select2-container--open"),b.css({position:"absolute",top:-999999}),this.$container=c},c.prototype.render=function(b){var c=a(""),d=b.call(this);return c.append(d),this.$dropdownContainer=c,c},c.prototype._hideDropdown=function(a){this.$dropdownContainer.detach()},c.prototype._attachPositioningHandler=function(c,d){var e=this,f="scroll.select2."+d.id,g="resize.select2."+d.id,h="orientationchange.select2."+d.id,i=this.$container.parents().filter(b.hasScroll);i.each(function(){a(this).data("select2-scroll-position",{x:a(this).scrollLeft(),y:a(this).scrollTop()})}),i.on(f,function(b){var c=a(this).data("select2-scroll-position");a(this).scrollTop(c.y)}),a(window).on(f+" "+g+" "+h,function(a){e._positionDropdown(),e._resizeDropdown()})},c.prototype._detachPositioningHandler=function(c,d){var e="scroll.select2."+d.id,f="resize.select2."+d.id,g="orientationchange.select2."+d.id,h=this.$container.parents().filter(b.hasScroll);h.off(e),a(window).off(e+" "+f+" "+g)},c.prototype._positionDropdown=function(){var b=a(window),c=this.$dropdown.hasClass("select2-dropdown--above"),d=this.$dropdown.hasClass("select2-dropdown--below"),e=null,f=this.$container.offset();f.bottom=f.top+this.$container.outerHeight(!1);var g={height:this.$container.outerHeight(!1)};g.top=f.top,g.bottom=f.top+g.height;var h={height:this.$dropdown.outerHeight(!1)},i={top:b.scrollTop(),bottom:b.scrollTop()+b.height()},j=i.topf.bottom+h.height,l={left:f.left,top:g.bottom},m=this.$dropdownParent;"static"===m.css("position")&&(m=m.offsetParent());var n=m.offset();l.top-=n.top,l.left-=n.left,c||d||(e="below"),k||!j||c?!j&&k&&c&&(e="below"):e="above",("above"==e||c&&"below"!==e)&&(l.top=g.top-n.top-h.height),null!=e&&(this.$dropdown.removeClass("select2-dropdown--below select2-dropdown--above").addClass("select2-dropdown--"+e),this.$container.removeClass("select2-container--below select2-container--above").addClass("select2-container--"+e)),this.$dropdownContainer.css(l)},c.prototype._resizeDropdown=function(){var a={width:this.$container.outerWidth(!1)+"px"};this.options.get("dropdownAutoWidth")&&(a.minWidth=a.width,a.position="relative",a.width="auto"),this.$dropdown.css(a)},c.prototype._showDropdown=function(a){this.$dropdownContainer.appendTo(this.$dropdownParent),this._positionDropdown(),this._resizeDropdown()},c}),b.define("select2/dropdown/minimumResultsForSearch",[],function(){function a(b){for(var c=0,d=0;d0&&(l.dataAdapter=j.Decorate(l.dataAdapter,r)),l.maximumInputLength>0&&(l.dataAdapter=j.Decorate(l.dataAdapter,s)),l.maximumSelectionLength>0&&(l.dataAdapter=j.Decorate(l.dataAdapter,t)),l.tags&&(l.dataAdapter=j.Decorate(l.dataAdapter,p)),(null!=l.tokenSeparators||null!=l.tokenizer)&&(l.dataAdapter=j.Decorate(l.dataAdapter,q)),null!=l.query){var C=b(l.amdBase+"compat/query");l.dataAdapter=j.Decorate(l.dataAdapter,C)}if(null!=l.initSelection){var D=b(l.amdBase+"compat/initSelection");l.dataAdapter=j.Decorate(l.dataAdapter,D)}}if(null==l.resultsAdapter&&(l.resultsAdapter=c,null!=l.ajax&&(l.resultsAdapter=j.Decorate(l.resultsAdapter,x)),null!=l.placeholder&&(l.resultsAdapter=j.Decorate(l.resultsAdapter,w)),l.selectOnClose&&(l.resultsAdapter=j.Decorate(l.resultsAdapter,A))),null==l.dropdownAdapter){if(l.multiple)l.dropdownAdapter=u;else{var E=j.Decorate(u,v);l.dropdownAdapter=E}if(0!==l.minimumResultsForSearch&&(l.dropdownAdapter=j.Decorate(l.dropdownAdapter,z)),l.closeOnSelect&&(l.dropdownAdapter=j.Decorate(l.dropdownAdapter,B)),null!=l.dropdownCssClass||null!=l.dropdownCss||null!=l.adaptDropdownCssClass){var F=b(l.amdBase+"compat/dropdownCss");l.dropdownAdapter=j.Decorate(l.dropdownAdapter,F)}l.dropdownAdapter=j.Decorate(l.dropdownAdapter,y)}if(null==l.selectionAdapter){if(l.multiple?l.selectionAdapter=e:l.selectionAdapter=d,null!=l.placeholder&&(l.selectionAdapter=j.Decorate(l.selectionAdapter,f)),l.allowClear&&(l.selectionAdapter=j.Decorate(l.selectionAdapter,g)),l.multiple&&(l.selectionAdapter=j.Decorate(l.selectionAdapter,h)),null!=l.containerCssClass||null!=l.containerCss||null!=l.adaptContainerCssClass){var G=b(l.amdBase+"compat/containerCss");l.selectionAdapter=j.Decorate(l.selectionAdapter,G)}l.selectionAdapter=j.Decorate(l.selectionAdapter,i)}if("string"==typeof l.language)if(l.language.indexOf("-")>0){var H=l.language.split("-"),I=H[0];l.language=[l.language,I]}else l.language=[l.language];if(a.isArray(l.language)){var J=new k;l.language.push("en");for(var K=l.language,L=0;L0){for(var f=a.extend(!0,{},e),g=e.children.length-1;g>=0;g--){var h=e.children[g],i=c(d,h);null==i&&f.children.splice(g,1)}return f.children.length>0?f:c(d,f)}var j=b(e.text).toUpperCase(),k=b(d.term).toUpperCase();return j.indexOf(k)>-1?e:null}this.defaults={amdBase:"./",amdLanguageBase:"./i18n/",closeOnSelect:!0,debug:!1,dropdownAutoWidth:!1,escapeMarkup:j.escapeMarkup,language:C,matcher:c,minimumInputLength:0,maximumInputLength:0,maximumSelectionLength:0,minimumResultsForSearch:0,selectOnClose:!1,sorter:function(a){return a},templateResult:function(a){return a.text},templateSelection:function(a){return a.text},theme:"default",width:"resolve"}},D.prototype.set=function(b,c){var d=a.camelCase(b),e={};e[d]=c;var f=j._convertData(e);a.extend(this.defaults,f)};var E=new D;return E}),b.define("select2/options",["require","jquery","./defaults","./utils"],function(a,b,c,d){function e(b,e){if(this.options=b,null!=e&&this.fromElement(e),this.options=c.apply(this.options),e&&e.is("input")){var f=a(this.get("amdBase")+"compat/inputData");this.options.dataAdapter=d.Decorate(this.options.dataAdapter,f)}}return e.prototype.fromElement=function(a){var c=["select2"];null==this.options.multiple&&(this.options.multiple=a.prop("multiple")),null==this.options.disabled&&(this.options.disabled=a.prop("disabled")),null==this.options.language&&(a.prop("lang")?this.options.language=a.prop("lang").toLowerCase():a.closest("[lang]").prop("lang")&&(this.options.language=a.closest("[lang]").prop("lang"))),null==this.options.dir&&(a.prop("dir")?this.options.dir=a.prop("dir"):a.closest("[dir]").prop("dir")?this.options.dir=a.closest("[dir]").prop("dir"):this.options.dir="ltr"),a.prop("disabled",this.options.disabled),a.prop("multiple",this.options.multiple),a.data("select2Tags")&&(this.options.debug&&window.console&&console.warn&&console.warn('Select2: The `data-select2-tags` attribute has been changed to use the `data-data` and `data-tags="true"` attributes and will be removed in future versions of Select2.'),a.data("data",a.data("select2Tags")),a.data("tags",!0)),a.data("ajaxUrl")&&(this.options.debug&&window.console&&console.warn&&console.warn("Select2: The `data-ajax-url` attribute has been changed to `data-ajax--url` and support for the old attribute will be removed in future versions of Select2."),a.attr("ajax--url",a.data("ajaxUrl")),a.data("ajax--url",a.data("ajaxUrl")));var e={};e=b.fn.jquery&&"1."==b.fn.jquery.substr(0,2)&&a[0].dataset?b.extend(!0,{},a[0].dataset,a.data()):a.data();var f=b.extend(!0,{},e);f=d._convertData(f);for(var g in f)b.inArray(g,c)>-1||(b.isPlainObject(this.options[g])?b.extend(this.options[g],f[g]):this.options[g]=f[g]);return this},e.prototype.get=function(a){return this.options[a]},e.prototype.set=function(a,b){this.options[a]=b},e}),b.define("select2/core",["jquery","./options","./utils","./keys"],function(a,b,c,d){var e=function(a,c){null!=a.data("select2")&&a.data("select2").destroy(),this.$element=a,this.id=this._generateId(a),c=c||{},this.options=new b(c,a),e.__super__.constructor.call(this);var d=a.attr("tabindex")||0;a.data("old-tabindex",d),a.attr("tabindex","-1");var f=this.options.get("dataAdapter");this.dataAdapter=new f(a,this.options);var g=this.render();this._placeContainer(g);var h=this.options.get("selectionAdapter");this.selection=new h(a,this.options),this.$selection=this.selection.render(),this.selection.position(this.$selection,g);var i=this.options.get("dropdownAdapter");this.dropdown=new i(a,this.options),this.$dropdown=this.dropdown.render(),this.dropdown.position(this.$dropdown,g);var j=this.options.get("resultsAdapter");this.results=new j(a,this.options,this.dataAdapter),this.$results=this.results.render(),this.results.position(this.$results,this.$dropdown);var k=this;this._bindAdapters(),this._registerDomEvents(),this._registerDataEvents(),this._registerSelectionEvents(),this._registerDropdownEvents(),this._registerResultsEvents(),this._registerEvents(),this.dataAdapter.current(function(a){k.trigger("selection:update",{data:a})}),a.addClass("select2-hidden-accessible"),a.attr("aria-hidden","true"),this._syncAttributes(),a.data("select2",this)};return c.Extend(e,c.Observable),e.prototype._generateId=function(a){var b="";return b=null!=a.attr("id")?a.attr("id"):null!=a.attr("name")?a.attr("name")+"-"+c.generateChars(2):c.generateChars(4),b=b.replace(/(:|\.|\[|\]|,)/g,""),b="select2-"+b},e.prototype._placeContainer=function(a){a.insertAfter(this.$element);var b=this._resolveWidth(this.$element,this.options.get("width"));null!=b&&a.css("width",b)},e.prototype._resolveWidth=function(a,b){var c=/^width:(([-+]?([0-9]*\.)?[0-9]+)(px|em|ex|%|in|cm|mm|pt|pc))/i;if("resolve"==b){var d=this._resolveWidth(a,"style");return null!=d?d:this._resolveWidth(a,"element")}if("element"==b){var e=a.outerWidth(!1);return 0>=e?"auto":e+"px"}if("style"==b){var f=a.attr("style");if("string"!=typeof f)return null;for(var g=f.split(";"),h=0,i=g.length;i>h;h+=1){var j=g[h].replace(/\s/g,""),k=j.match(c);if(null!==k&&k.length>=1)return k[1]}return null}return b},e.prototype._bindAdapters=function(){this.dataAdapter.bind(this,this.$container),this.selection.bind(this,this.$container),this.dropdown.bind(this,this.$container),this.results.bind(this,this.$container)},e.prototype._registerDomEvents=function(){var b=this;this.$element.on("change.select2",function(){b.dataAdapter.current(function(a){b.trigger("selection:update",{data:a})})}),this.$element.on("focus.select2",function(a){b.trigger("focus",a)}),this._syncA=c.bind(this._syncAttributes,this),this._syncS=c.bind(this._syncSubtree,this),this.$element[0].attachEvent&&this.$element[0].attachEvent("onpropertychange",this._syncA);var d=window.MutationObserver||window.WebKitMutationObserver||window.MozMutationObserver;null!=d?(this._observer=new d(function(c){a.each(c,b._syncA),a.each(c,b._syncS)}),this._observer.observe(this.$element[0],{attributes:!0,childList:!0,subtree:!1})):this.$element[0].addEventListener&&(this.$element[0].addEventListener("DOMAttrModified",b._syncA,!1),this.$element[0].addEventListener("DOMNodeInserted",b._syncS,!1),this.$element[0].addEventListener("DOMNodeRemoved",b._syncS,!1))},e.prototype._registerDataEvents=function(){var a=this;this.dataAdapter.on("*",function(b,c){a.trigger(b,c)})},e.prototype._registerSelectionEvents=function(){var b=this,c=["toggle","focus"];this.selection.on("toggle",function(){b.toggleDropdown()}),this.selection.on("focus",function(a){b.focus(a)}),this.selection.on("*",function(d,e){-1===a.inArray(d,c)&&b.trigger(d,e)})},e.prototype._registerDropdownEvents=function(){var a=this;this.dropdown.on("*",function(b,c){a.trigger(b,c)})},e.prototype._registerResultsEvents=function(){var a=this;this.results.on("*",function(b,c){a.trigger(b,c)})},e.prototype._registerEvents=function(){var a=this;this.on("open",function(){a.$container.addClass("select2-container--open")}),this.on("close",function(){a.$container.removeClass("select2-container--open")}),this.on("enable",function(){a.$container.removeClass("select2-container--disabled")}),this.on("disable",function(){a.$container.addClass("select2-container--disabled")}),this.on("blur",function(){a.$container.removeClass("select2-container--focus")}),this.on("query",function(b){a.isOpen()||a.trigger("open",{}),this.dataAdapter.query(b,function(c){a.trigger("results:all",{data:c,query:b})})}),this.on("query:append",function(b){this.dataAdapter.query(b,function(c){a.trigger("results:append",{data:c,query:b})})}),this.on("keypress",function(b){var c=b.which;a.isOpen()?c===d.ESC||c===d.TAB||c===d.UP&&b.altKey?(a.close(),b.preventDefault()):c===d.ENTER?(a.trigger("results:select",{}),b.preventDefault()):c===d.SPACE&&b.ctrlKey?(a.trigger("results:toggle",{}),b.preventDefault()):c===d.UP?(a.trigger("results:previous",{}),b.preventDefault()):c===d.DOWN&&(a.trigger("results:next",{}),b.preventDefault()):(c===d.ENTER||c===d.SPACE||c===d.DOWN&&b.altKey)&&(a.open(),b.preventDefault())})},e.prototype._syncAttributes=function(){this.options.set("disabled",this.$element.prop("disabled")),this.options.get("disabled")?(this.isOpen()&&this.close(),this.trigger("disable",{})):this.trigger("enable",{})},e.prototype._syncSubtree=function(a,b){var c=!1,d=this;if(!a||!a.target||"OPTION"===a.target.nodeName||"OPTGROUP"===a.target.nodeName){if(b)if(b.addedNodes&&b.addedNodes.length>0)for(var e=0;e0&&(c=!0);else c=!0;c&&this.dataAdapter.current(function(a){d.trigger("selection:update",{data:a})})}},e.prototype.trigger=function(a,b){var c=e.__super__.trigger,d={open:"opening",close:"closing",select:"selecting",unselect:"unselecting"};if(void 0===b&&(b={}),a in d){var f=d[a],g={prevented:!1,name:a,args:b};if(c.call(this,f,g),g.prevented)return void(b.prevented=!0)}c.call(this,a,b)},e.prototype.toggleDropdown=function(){this.options.get("disabled")||(this.isOpen()?this.close():this.open())},e.prototype.open=function(){this.isOpen()||this.trigger("query",{})},e.prototype.close=function(){this.isOpen()&&this.trigger("close",{})},e.prototype.isOpen=function(){return this.$container.hasClass("select2-container--open")},e.prototype.hasFocus=function(){return this.$container.hasClass("select2-container--focus")},e.prototype.focus=function(a){this.hasFocus()||(this.$container.addClass("select2-container--focus"),this.trigger("focus",{}))},e.prototype.enable=function(a){this.options.get("debug")&&window.console&&console.warn&&console.warn('Select2: The `select2("enable")` method has been deprecated and will be removed in later Select2 versions. Use $element.prop("disabled") instead.'),(null==a||0===a.length)&&(a=[!0]);var b=!a[0];this.$element.prop("disabled",b)},e.prototype.data=function(){this.options.get("debug")&&arguments.length>0&&window.console&&console.warn&&console.warn('Select2: Data can no longer be set using `select2("data")`. You should consider setting the value instead using `$element.val()`.');var a=[];return this.dataAdapter.current(function(b){a=b}),a},e.prototype.val=function(b){if(this.options.get("debug")&&window.console&&console.warn&&console.warn('Select2: The `select2("val")` method has been deprecated and will be removed in later Select2 versions. Use $element.val() instead.'),null==b||0===b.length)return this.$element.val();var c=b[0];a.isArray(c)&&(c=a.map(c,function(a){return a.toString()})),this.$element.val(c).trigger("change")},e.prototype.destroy=function(){this.$container.remove(),this.$element[0].detachEvent&&this.$element[0].detachEvent("onpropertychange",this._syncA),null!=this._observer?(this._observer.disconnect(),this._observer=null):this.$element[0].removeEventListener&&(this.$element[0].removeEventListener("DOMAttrModified",this._syncA,!1),this.$element[0].removeEventListener("DOMNodeInserted",this._syncS,!1),this.$element[0].removeEventListener("DOMNodeRemoved",this._syncS,!1)),this._syncA=null,this._syncS=null,this.$element.off(".select2"),this.$element.attr("tabindex",this.$element.data("old-tabindex")),this.$element.removeClass("select2-hidden-accessible"),this.$element.attr("aria-hidden","false"),this.$element.removeData("select2"),this.dataAdapter.destroy(),this.selection.destroy(),this.dropdown.destroy(),this.results.destroy(),this.dataAdapter=null,this.selection=null,this.dropdown=null,this.results=null; -},e.prototype.render=function(){var b=a('');return b.attr("dir",this.options.get("dir")),this.$container=b,this.$container.addClass("select2-container--"+this.options.get("theme")),b.data("element",this.$element),b},e}),b.define("jquery-mousewheel",["jquery"],function(a){return a}),b.define("jquery.select2",["jquery","jquery-mousewheel","./select2/core","./select2/defaults"],function(a,b,c,d){if(null==a.fn.select2){var e=["open","close","destroy"];a.fn.select2=function(b){if(b=b||{},"object"==typeof b)return this.each(function(){var d=a.extend(!0,{},b);new c(a(this),d)}),this;if("string"==typeof b){var d,f=Array.prototype.slice.call(arguments,1);return this.each(function(){var c=a(this).data("select2");null==c&&window.console&&console.error&&console.error("The select2('"+b+"') method was called on an element that is not using Select2."),d=c[b].apply(c,f)}),a.inArray(b,e)>-1?this:d}throw new Error("Invalid arguments for Select2: "+b)}}return null==a.fn.select2.defaults&&(a.fn.select2.defaults=d),c}),{define:b.define,require:b.require}}(),c=b.require("jquery.select2");return a.fn.select2.amd=b,c}); diff --git a/client/compatibilities/timepicker/timepicker.min.css b/client/compatibilities/timepicker/timepicker.min.css deleted file mode 100644 index 6dc1066a..00000000 --- a/client/compatibilities/timepicker/timepicker.min.css +++ /dev/null @@ -1,84 +0,0 @@ -/** - * jQuery Timepicker - * http://timepicker.co - * - * Enhances standard form input fields helping users to select (or type) times. - * - * Copyright (c) 2016 Willington Vega; Licensed MIT, GPL - */ - - .ui-timepicker-container { - position: absolute; - overflow: hidden; - box-sizing: border-box; -} - -.ui-timepicker { - box-sizing: content-box; - display: block; - height: 205px; - list-style: none outside none; - margin: 0; - padding: 0 1px; - text-align: center; -} - -.ui-timepicker-viewport { - box-sizing: content-box; - display: block; - height: 205px; - margin: 0; - padding: 0; - overflow: auto; - overflow-x: hidden; /* IE */ -} - -.ui-timepicker-standard { - /* overwrites .ui-widget */ - font-family: Verdana,Arial,sans-serif; - font-size: 1.1em; - /* overwrites .ui-widget-content */ - background-color: #FFF; - border: 1px solid #AAA; - color: #222; - /* overwrites .ui-menu */ - margin: 0; - padding: 2px; -} -.ui-timepicker-standard a { - border: 1px solid transparent; - color: #222; - display: block; - padding: 0.2em 0.4em; - text-decoration: none; -} -.ui-timepicker-standard .ui-state-hover { - /* overwrites .ui-state-hover */ - background-color: #DADADA; - border: 1px solid #999; - font-weight: normal; - color: #212121; -} -.ui-timepicker-standard .ui-menu-item { - /* overwrites .ui-menu and .ui-menu-item */ - /*clear: left; - float: left;*/ - margin: 0; - padding: 0; -} - -.ui-timepicker-corners, -.ui-timepicker-corners .ui-corner-all { - -moz-border-radius: 4px; - -webkit-border-radius: 4px; - border-radius: 4px; -} - -.ui-timepicker-hidden { - /* overwrites .ui-helper-hidden */ - display: none; -} - -.ui-timepicker-no-scrollbar .ui-timepicker { - border: none; -} diff --git a/client/compatibilities/timepicker/timepicker.min.js b/client/compatibilities/timepicker/timepicker.min.js deleted file mode 100644 index 62b3d4c1..00000000 --- a/client/compatibilities/timepicker/timepicker.min.js +++ /dev/null @@ -1,2 +0,0 @@ -!function(e){"object"==typeof module&&"object"==typeof module.exports?e(require("jquery"),window,document):"undefined"!=typeof jQuery&&e(jQuery,window,document)}(function(e,t,i,n){!function(){function t(e,t,i){return new Array(i+1-e.length).join(t)+e}function n(){if(1===arguments.length){var t=arguments[0];return"string"==typeof t&&(t=e.fn.timepicker.parseTime(t)),new Date(0,0,0,t.getHours(),t.getMinutes(),t.getSeconds())}return 3===arguments.length?new Date(0,0,0,arguments[0],arguments[1],arguments[2]):2===arguments.length?new Date(0,0,0,arguments[0],arguments[1],0):new Date(0,0,0)}e.TimePicker=function(){var t=this;t.container=e(".ui-timepicker-container"),t.ui=t.container.find(".ui-timepicker"),0===t.container.length&&(t.container=e("
      ").addClass("ui-timepicker-container").addClass("ui-timepicker-hidden ui-helper-hidden").appendTo("body").hide(),t.ui=e("
      ").addClass("ui-timepicker").addClass("ui-widget ui-widget-content ui-menu").addClass("ui-corner-all").appendTo(t.container),t.viewport=e("
        ").addClass("ui-timepicker-viewport").appendTo(t.ui),e.fn.jquery>="1.4.2"&&t.ui.delegate("a","mouseenter.timepicker",function(){t.activate(!1,e(this).parent())}).delegate("a","mouseleave.timepicker",function(){t.deactivate(!1)}).delegate("a","click.timepicker",function(i){i.preventDefault(),t.select(!1,e(this).parent())}))},e.TimePicker.count=0,e.TimePicker.instance=function(){return e.TimePicker._instance||(e.TimePicker._instance=new e.TimePicker),e.TimePicker._instance},e.TimePicker.prototype={keyCode:{ALT:18,BLOQ_MAYUS:20,CTRL:17,DOWN:40,END:35,ENTER:13,HOME:36,LEFT:37,NUMPAD_ENTER:108,PAGE_DOWN:34,PAGE_UP:33,RIGHT:39,SHIFT:16,TAB:9,UP:38},_items:function(t,i){var r,a,o=this,s=e("
          "),c=null;for(-1===t.options.timeFormat.indexOf("m")&&t.options.interval%60!==0&&(t.options.interval=60*Math.max(Math.round(t.options.interval/60),1)),r=i?n(i):t.options.startTime?n(t.options.startTime):n(t.options.startHour,t.options.startMinutes),a=new Date(r.getTime()+864e5);a>r;)o._isValidTime(t,r)&&(c=e("
        • ").addClass("ui-menu-item").appendTo(s),e("").addClass("ui-corner-all").text(e.fn.timepicker.formatTime(t.options.timeFormat,r)).appendTo(c),c.data("time-value",r)),r=new Date(r.getTime()+60*t.options.interval*1e3);return s.children()},_isValidTime:function(e,t){var i=null,r=null;return t=n(t),null!==e.options.minTime?i=n(e.options.minTime):null===e.options.minHour&&null===e.options.minMinutes||(i=n(e.options.minHour,e.options.minMinutes)),null!==e.options.maxTime?r=n(e.options.maxTime):null===e.options.maxHour&&null===e.options.maxMinutes||(r=n(e.options.maxHour,e.options.maxMinutes)),null!==i&&null!==r?t>=i&&r>=t:null!==i?t>=i:null!==r?r>=t:!0},_hasScroll:function(){var e="undefined"!=typeof this.ui.prop?"prop":"attr";return this.ui.height()r?i.ui.scrollTop(a+r):r>=o&&i.ui.scrollTop(a+r-o+t.height())}i.active=t.eq(0).children("a").addClass("ui-state-hover").attr("id","ui-active-item").end()}},deactivate:function(){var e=this;e.active&&(e.active.children("a").removeClass("ui-state-hover").removeAttr("id"),e.active=null)},next:function(e){return(this.closed()||this.instance===e)&&this._move(e,"next",".ui-menu-item:first"),e.element},previous:function(e){return(this.closed()||this.instance===e)&&this._move(e,"prev",".ui-menu-item:last"),e.element},first:function(e){return this.instance===e?this.active&&0===this.active.prevAll(".ui-menu-item").length:!1},last:function(e){return this.instance===e?this.active&&0===this.active.nextAll(".ui-menu-item").length:!1},selected:function(e){return this.instance===e&&this.active?this.active:null},open:function(t){var n=this,r=t.getTime(),a=t.options.dynamic&&r;if(!t.options.dropdown)return t.element;switch(t.element.data("timepicker-event-namespace",Math.random()),e(i).bind("click.timepicker-"+t.element.data("timepicker-event-namespace"),function(e){t.element.get(0)===e.target?t.element.data("timepicker-user-clicked-outside",!1):t.element.data("timepicker-user-clicked-outside",!0).blur()}),(t.rebuild||!t.items||a)&&(t.items=n._items(t,a?r:null)),(t.rebuild||n.instance!==t||a)&&(e.fn.jquery<"1.4.2"?(n.viewport.children().remove(),n.viewport.append(t.items),n.viewport.find("a").bind("mouseover.timepicker",function(){n.activate(t,e(this).parent())}).bind("mouseout.timepicker",function(){n.deactivate(t)}).bind("click.timepicker",function(i){i.preventDefault(),n.select(t,e(this).parent())})):(n.viewport.children().detach(),n.viewport.append(t.items))),t.rebuild=!1,n.container.removeClass("ui-helper-hidden ui-timepicker-hidden ui-timepicker-standard ui-timepicker-corners").show(),t.options.theme){case"standard":n.container.addClass("ui-timepicker-standard");break;case"standard-rounded-corners":n.container.addClass("ui-timepicker-standard ui-timepicker-corners")}n.container.hasClass("ui-timepicker-no-scrollbar")||t.options.scrollbar||(n.container.addClass("ui-timepicker-no-scrollbar"),n.viewport.css({paddingRight:40}));var o=n.container.outerHeight()-n.container.height(),s=t.options.zindex?t.options.zindex:t.element.offsetParent().css("z-index"),c=t.element.offset();n.container.css({top:c.top+t.element.outerHeight(),left:c.left}),n.container.show(),n.container.css({left:t.element.offset().left,height:n.ui.outerHeight()+o,width:t.element.outerWidth(),zIndex:s,cursor:"default"});var u=n.container.width()-(n.ui.outerWidth()-n.ui.width());return n.ui.css({width:u}),n.viewport.css({width:u}),t.items.css({width:u}),n.instance=t,r?t.items.each(function(){var i,a=e(this);return i=e.fn.jquery<"1.4.2"?e.fn.timepicker.parseTime(a.find("a").text()):a.data("time-value"),i.getTime()===r.getTime()?(n.activate(t,a),!1):!0}):n.deactivate(t),t.element},close:function(t){var n=this;return n.instance===t&&(n.container.addClass("ui-helper-hidden ui-timepicker-hidden").hide(),n.ui.scrollTop(0),n.ui.children().removeClass("ui-state-hover")),e(i).unbind("click.timepicker-"+t.element.data("timepicker-event-namespace")),t.element},closed:function(){return this.ui.is(":hidden")},destroy:function(e){var t=this;return t.close(e,!0),e.element.unbind(".timepicker").data("TimePicker",null)},parse:function(t,i){return e.fn.timepicker.parseTime(i)},format:function(t,i,n){return n=n||t.options.timeFormat,e.fn.timepicker.formatTime(n,i)},getTime:function(t){var i=this,n=e.fn.timepicker.parseTime(t.element.val());return n instanceof Date&&!i._isValidTime(t,n)?null:n instanceof Date&&t.selectedTime?t.format(n)===t.format(t.selectedTime)?t.selectedTime:n:n instanceof Date?n:null},setTime:function(t,i,r){var a=this,o=t.selectedTime;if("string"==typeof i&&(i=t.parse(i)),i&&i.getMinutes&&a._isValidTime(t,i)){if(i=n(i),t.selectedTime=i,t.element.val(t.format(i,t.options.timeFormat)),r)return t}else t.selectedTime=null;return null===o&&null===t.selectedTime||(t.element.trigger("time-change",[i]),e.isFunction(t.options.change)&&t.options.change.apply(t.element,[i])),t.element},option:function(t,i,n){if("undefined"==typeof n)return t.options[i];var r,a,o=t.getTime();"string"==typeof i?(r={},r[i]=n):r=i,a=["minHour","minMinutes","minTime","maxHour","maxMinutes","maxTime","startHour","startMinutes","startTime","timeFormat","interval","dropdown"],e.each(r,function(i){t.options[i]=r[i],t.rebuild=t.rebuild||e.inArray(i,a)>-1}),t.rebuild&&t.setTime(o)}},e.TimePicker.defaults={timeFormat:"hh:mm p",minHour:null,minMinutes:null,minTime:null,maxHour:null,maxMinutes:null,maxTime:null,startHour:null,startMinutes:null,startTime:null,interval:30,dynamic:!0,theme:"standard",zindex:null,dropdown:!0,scrollbar:!1,change:function(){}},e.TimePicker.methods={chainable:["next","previous","open","close","destroy","setTime"]},e.fn.timepicker=function(t){if("string"==typeof t){var i,n,r=Array.prototype.slice.call(arguments,1);return i="option"===t&&arguments.length>2?"each":-1!==e.inArray(t,e.TimePicker.methods.chainable)?"each":"map",n=this[i](function(){var i=e(this),n=i.data("TimePicker");return"object"==typeof n?n[t].apply(n,r):void 0}),"map"===i&&1===this.length?e.makeArray(n).shift():"map"===i?e.makeArray(n):n}if(1===this.length&&this.data("TimePicker"))return this.data("TimePicker");var a=e.extend({},e.TimePicker.defaults,t);return this.each(function(){e.TimePicker.instance().register(this,a)})},e.fn.timepicker.formatTime=function(e,i){var n=i.getHours(),r=n%12,a=i.getMinutes(),o=i.getSeconds(),s={hh:t((0===r?12:r).toString(),"0",2),HH:t(n.toString(),"0",2),mm:t(a.toString(),"0",2),ss:t(o.toString(),"0",2),h:0===r?12:r,H:n,m:a,s:o,p:n>11?"PM":"AM"},c=e,u="";for(u in s)s.hasOwnProperty(u)&&(c=c.replace(new RegExp(u,"g"),s[u]));return c=c.replace(new RegExp("a","g"),n>11?"pm":"am")},e.fn.timepicker.parseTime=function(){var t=[[/^(\d+)$/,"$1"],[/^:(\d)$/,"$10"],[/^:(\d+)/,"$1"],[/^(\d):([7-9])$/,"0$10$2"],[/^(\d):(\d\d)$/,"$1$2"],[/^(\d):(\d{1,})$/,"0$1$20"],[/^(\d\d):([7-9])$/,"$10$2"],[/^(\d\d):(\d)$/,"$1$20"],[/^(\d\d):(\d*)$/,"$1$2"],[/^(\d{3,}):(\d)$/,"$10$2"],[/^(\d{3,}):(\d{2,})/,"$1$2"],[/^(\d):(\d):(\d)$/,"0$10$20$3"],[/^(\d{1,2}):(\d):(\d\d)/,"$10$2$3"]],i=t.length;return function(r){var a=n(new Date),o=!1,s=!1,c=!1,u=!1,l=!1;if("undefined"==typeof r||!r.toLowerCase)return null;r=r.toLowerCase(),o=/a/.test(r),s=o?!1:/p/.test(r),r=r.replace(/[^0-9:]/g,"").replace(/:+/g,":");for(var m=0;i>m;m+=1)if(t[m][0].test(r)){r=r.replace(t[m][0],t[m][1]);break}return r=r.replace(/:/g,""),1===r.length?c=r:2===r.length?c=r:3===r.length||5===r.length?(c=r.substr(0,1),u=r.substr(1,2),l=r.substr(3,2)):(4===r.length||r.length>5)&&(c=r.substr(0,2),u=r.substr(2,2),l=r.substr(4,2)),r.length>0&&r.length<5&&(r.length<3&&(u=0),l=0),c===!1||u===!1||l===!1?!1:(c=parseInt(c,10),u=parseInt(u,10),l=parseInt(l,10),o&&12===c?c=0:s&&12>c&&(c+=12),c>24?r.length>=6?e.fn.timepicker.parseTime(r.substr(0,5)):e.fn.timepicker.parseTime(r+"0"+(o?"a":"")+(s?"p":"")):(a.setHours(c,u,l),a))}}()}()}); -//# sourceMappingURL=jquery.timepicker.min.js.map diff --git a/client/libs/QuillEditor.test.js b/client/libs/QuillEditor.test.js deleted file mode 100644 index 53ba398c..00000000 --- a/client/libs/QuillEditor.test.js +++ /dev/null @@ -1,151 +0,0 @@ -import { $ } from 'meteor/jquery'; -import { chai } from 'meteor/practicalmeteor:chai'; -import QuillEditor from './QuillEditor'; - -chai.should(); - -describe('QuillEditor', () => { - - it('should expose createEditor()', () => { - QuillEditor.createEditor.should.not.be.undefined; - }); - - it('should expose generateHTMLForDeltas()', () => { - QuillEditor.generateHTMLForDeltas.should.not.be.undefined; - }); - - it('should expose generatePlainTextFromDeltas()', () => { - QuillEditor.generatePlainTextFromDeltas.should.not.be.undefined; - }); - - describe('createEditor', () => { - var hostElement, - editor, - container; - - beforeEach(() => { - hostElement = $('
          '); - $(document.body).append(hostElement); - - container = $('
          ').get(0); - hostElement.append(container); - editor = QuillEditor.createEditor({container}); - }); - - afterEach(() => { - hostElement.remove(); - editor = null; - container = null; - }); - - it('should throw an Error if container is not specified', () => { - chai.expect(() => { - QuillEditor.createEditor(); - }).to.throw(Error); - }); - - it('should not return an undefined', () => { - editor = QuillEditor.createEditor({container}); - editor.should.not.be.undefined; - }); - - it('should expose getContents()', () => { - editor.getContents.should.not.be.undefined; - }); - - describe('getContents()', () => { - it('should not return null', function() { - editor.getContents().should.not.be.undefined; - }); - - it('should contain a key ops', function() { - editor.getContents().ops.should.not.be.undefined; - }); - }); - - it('should expose setContents()', () => { - editor.setContents.should.not.be.undefined; - }); - - describe('setContents()', () => { - it('should reflect the contents when setting with string', function() { - editor.setContents('hello 123'); - QuillEditor.generateHTMLForDeltas(editor.getContents()).should.be.equal('

          hello 123

          ') - }); - - it('should reflect the contents when setting with deltas', function() { - editor.setContents({ - ops: [{ - insert: 'hello 123' - }] - }); - QuillEditor.generateHTMLForDeltas(editor.getContents()).should.be.equal('

          hello 123

          ') - }); - }); - - }); - - describe('generateHTMLForDeltas', () => { - var delta = { - "ops" : [ - { - "insert" : "this is some text " - }, - { - "attributes" : - { - "link" : "https://codebuddies.org/" - }, - "insert" : "https://codebuddies.org/" - }, - { - "insert" : "\n" - } - ] - }, - expectedHTML = '

          this is some text https://codebuddies.org/

          '; - - it('should return html for a sequence of delta', () => { - var html = QuillEditor.generateHTMLForDeltas(delta); - html.should.be.equal(expectedHTML); - }); - - it('should fallback if delta is a plain string', function() { - var html = QuillEditor.generateHTMLForDeltas('this is a string'); - html.should.be.equal('

          this is a string

          '); - }); - }); - - describe('generatePlainTextFromDeltas', () => { - var delta = { - "ops" : [ - { - "insert" : "this is some text " - }, - { - "attributes" : - { - "link" : "https://codebuddies.org/" - }, - "insert" : "https://codebuddies.org/" - }, - { - "insert" : "\n" - } - ] - }, - expectedText = 'this is some text https://codebuddies.org/'; - - it('should throw an error if argument is not a Delta object', function() { - chai.expect(() => { - QuillEditor.generatePlainTextFromDeltas('someString'); - }).to.throw(Error); - }); - - it('should return a plain string', function() { - var result = QuillEditor.generatePlainTextFromDeltas(delta); - result.should.be.equal(expectedText); - }); - }); - -}); \ No newline at end of file diff --git a/client/libs/QuillEditorDefaultOptions.js b/client/libs/QuillEditorDefaultOptions.js deleted file mode 100644 index e5fb27e0..00000000 --- a/client/libs/QuillEditorDefaultOptions.js +++ /dev/null @@ -1,10 +0,0 @@ -export default { - modules: { - toolbar: [ - ['bold', 'italic', 'underline'], - ['link'] - ] - }, - placeholder: 'What do you hope to cover or master during this hangout?', - theme: 'snow' -}; \ No newline at end of file diff --git a/client/libs/quill.js b/client/libs/quill.js deleted file mode 100644 index 39c87379..00000000 --- a/client/libs/quill.js +++ /dev/null @@ -1,10296 +0,0 @@ -/*! - * Quill Editor v1.0.6 - * https://quilljs.com/ - * Copyright (c) 2014, Jason Chen - * Copyright (c) 2013, salesforce.com - */ -(function webpackUniversalModuleDefinition(root, factory) { - if(typeof exports === 'object' && typeof module === 'object') - module.exports = factory(); - else if(typeof define === 'function' && define.amd) - define([], factory); - else if(typeof exports === 'object') - exports["Quill"] = factory(); - else - root["Quill"] = factory(); -})(this, function() { -return /******/ (function(modules) { // webpackBootstrap -/******/ // The module cache -/******/ var installedModules = {}; - -/******/ // The require function -/******/ function __webpack_require__(moduleId) { - -/******/ // Check if module is in cache -/******/ if(installedModules[moduleId]) -/******/ return installedModules[moduleId].exports; - -/******/ // Create a new module (and put it into the cache) -/******/ var module = installedModules[moduleId] = { -/******/ exports: {}, -/******/ id: moduleId, -/******/ loaded: false -/******/ }; - -/******/ // Execute the module function -/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__); - -/******/ // Flag the module as loaded -/******/ module.loaded = true; - -/******/ // Return the exports of the module -/******/ return module.exports; -/******/ } - - -/******/ // expose the modules object (__webpack_modules__) -/******/ __webpack_require__.m = modules; - -/******/ // expose the module cache -/******/ __webpack_require__.c = installedModules; - -/******/ // __webpack_public_path__ -/******/ __webpack_require__.p = ""; - -/******/ // Load entry module and return exports -/******/ return __webpack_require__(0); -/******/ }) -/************************************************************************/ -/******/ ([ -/* 0 */ -/***/ function(module, exports, __webpack_require__) { - - module.exports = __webpack_require__(53); - - -/***/ }, -/* 1 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - var _parchment = __webpack_require__(2); - - var _parchment2 = _interopRequireDefault(_parchment); - - var _quill = __webpack_require__(18); - - var _quill2 = _interopRequireDefault(_quill); - - var _block = __webpack_require__(32); - - var _block2 = _interopRequireDefault(_block); - - var _break = __webpack_require__(33); - - var _break2 = _interopRequireDefault(_break); - - var _container = __webpack_require__(42); - - var _container2 = _interopRequireDefault(_container); - - var _cursor = __webpack_require__(37); - - var _cursor2 = _interopRequireDefault(_cursor); - - var _embed = __webpack_require__(34); - - var _embed2 = _interopRequireDefault(_embed); - - var _inline = __webpack_require__(35); - - var _inline2 = _interopRequireDefault(_inline); - - var _scroll = __webpack_require__(43); - - var _scroll2 = _interopRequireDefault(_scroll); - - var _text = __webpack_require__(36); - - var _text2 = _interopRequireDefault(_text); - - var _clipboard = __webpack_require__(44); - - var _clipboard2 = _interopRequireDefault(_clipboard); - - var _history = __webpack_require__(51); - - var _history2 = _interopRequireDefault(_history); - - var _keyboard = __webpack_require__(52); - - var _keyboard2 = _interopRequireDefault(_keyboard); - - function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - - _quill2.default.register({ - 'blots/block': _block2.default, - 'blots/block/embed': _block.BlockEmbed, - 'blots/break': _break2.default, - 'blots/container': _container2.default, - 'blots/cursor': _cursor2.default, - 'blots/embed': _embed2.default, - 'blots/inline': _inline2.default, - 'blots/scroll': _scroll2.default, - 'blots/text': _text2.default, - - 'modules/clipboard': _clipboard2.default, - 'modules/history': _history2.default, - 'modules/keyboard': _keyboard2.default - }); - - _parchment2.default.register(_block2.default, _break2.default, _cursor2.default, _inline2.default, _scroll2.default, _text2.default); - - module.exports = _quill2.default; - -/***/ }, -/* 2 */ -/***/ function(module, exports, __webpack_require__) { - - "use strict"; - var container_1 = __webpack_require__(3); - var format_1 = __webpack_require__(7); - var leaf_1 = __webpack_require__(12); - var scroll_1 = __webpack_require__(13); - var inline_1 = __webpack_require__(14); - var block_1 = __webpack_require__(15); - var embed_1 = __webpack_require__(16); - var text_1 = __webpack_require__(17); - var attributor_1 = __webpack_require__(8); - var class_1 = __webpack_require__(10); - var style_1 = __webpack_require__(11); - var store_1 = __webpack_require__(9); - var Registry = __webpack_require__(6); - var Parchment = { - Scope: Registry.Scope, - create: Registry.create, - find: Registry.find, - query: Registry.query, - register: Registry.register, - Container: container_1.default, - Format: format_1.default, - Leaf: leaf_1.default, - Embed: embed_1.default, - Scroll: scroll_1.default, - Block: block_1.default, - Inline: inline_1.default, - Text: text_1.default, - Attributor: { - Attribute: attributor_1.default, - Class: class_1.default, - Style: style_1.default, - Store: store_1.default - } - }; - Object.defineProperty(exports, "__esModule", { value: true }); - exports.default = Parchment; - - -/***/ }, -/* 3 */ -/***/ function(module, exports, __webpack_require__) { - - "use strict"; - var __extends = (this && this.__extends) || function (d, b) { - for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; - function __() { this.constructor = d; } - d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); - }; - var linked_list_1 = __webpack_require__(4); - var shadow_1 = __webpack_require__(5); - var Registry = __webpack_require__(6); - var ContainerBlot = (function (_super) { - __extends(ContainerBlot, _super); - function ContainerBlot() { - _super.apply(this, arguments); - } - ContainerBlot.prototype.appendChild = function (other) { - this.insertBefore(other); - }; - ContainerBlot.prototype.attach = function () { - var _this = this; - _super.prototype.attach.call(this); - this.children = new linked_list_1.default(); - // Need to be reversed for if DOM nodes already in order - [].slice.call(this.domNode.childNodes).reverse().forEach(function (node) { - try { - var child = makeBlot(node); - _this.insertBefore(child, _this.children.head); - } - catch (err) { - if (err instanceof Registry.ParchmentError) - return; - else - throw err; - } - }); - }; - ContainerBlot.prototype.deleteAt = function (index, length) { - if (index === 0 && length === this.length()) { - return this.remove(); - } - this.children.forEachAt(index, length, function (child, offset, length) { - child.deleteAt(offset, length); - }); - }; - ContainerBlot.prototype.descendant = function (criteria, index) { - var _a = this.children.find(index), child = _a[0], offset = _a[1]; - if ((criteria.blotName == null && criteria(child)) || - (criteria.blotName != null && child instanceof criteria)) { - return [child, offset]; - } - else if (child instanceof ContainerBlot) { - return child.descendant(criteria, offset); - } - else { - return [null, -1]; - } - }; - ContainerBlot.prototype.descendants = function (criteria, index, length) { - if (index === void 0) { index = 0; } - if (length === void 0) { length = Number.MAX_VALUE; } - var descendants = [], lengthLeft = length; - this.children.forEachAt(index, length, function (child, index, length) { - if ((criteria.blotName == null && criteria(child)) || - (criteria.blotName != null && child instanceof criteria)) { - descendants.push(child); - } - if (child instanceof ContainerBlot) { - descendants = descendants.concat(child.descendants(criteria, index, lengthLeft)); - } - lengthLeft -= length; - }); - return descendants; - }; - ContainerBlot.prototype.detach = function () { - this.children.forEach(function (child) { - child.detach(); - }); - _super.prototype.detach.call(this); - }; - ContainerBlot.prototype.formatAt = function (index, length, name, value) { - this.children.forEachAt(index, length, function (child, offset, length) { - child.formatAt(offset, length, name, value); - }); - }; - ContainerBlot.prototype.insertAt = function (index, value, def) { - var _a = this.children.find(index), child = _a[0], offset = _a[1]; - if (child) { - child.insertAt(offset, value, def); - } - else { - var blot = (def == null) ? Registry.create('text', value) : Registry.create(value, def); - this.appendChild(blot); - } - }; - ContainerBlot.prototype.insertBefore = function (childBlot, refBlot) { - if (this.statics.allowedChildren != null && !this.statics.allowedChildren.some(function (child) { - return childBlot instanceof child; - })) { - throw new Registry.ParchmentError("Cannot insert " + childBlot.statics.blotName + " into " + this.statics.blotName); - } - childBlot.insertInto(this, refBlot); - }; - ContainerBlot.prototype.length = function () { - return this.children.reduce(function (memo, child) { - return memo + child.length(); - }, 0); - }; - ContainerBlot.prototype.moveChildren = function (targetParent, refNode) { - this.children.forEach(function (child) { - targetParent.insertBefore(child, refNode); - }); - }; - ContainerBlot.prototype.optimize = function () { - _super.prototype.optimize.call(this); - if (this.children.length === 0) { - if (this.statics.defaultChild != null) { - var child = Registry.create(this.statics.defaultChild); - this.appendChild(child); - child.optimize(); - } - else { - this.remove(); - } - } - }; - ContainerBlot.prototype.path = function (index, inclusive) { - if (inclusive === void 0) { inclusive = false; } - var _a = this.children.find(index, inclusive), child = _a[0], offset = _a[1]; - var position = [[this, index]]; - if (child instanceof ContainerBlot) { - return position.concat(child.path(offset, inclusive)); - } - else if (child != null) { - position.push([child, offset]); - } - return position; - }; - ContainerBlot.prototype.removeChild = function (child) { - this.children.remove(child); - }; - ContainerBlot.prototype.replace = function (target) { - if (target instanceof ContainerBlot) { - target.moveChildren(this); - } - _super.prototype.replace.call(this, target); - }; - ContainerBlot.prototype.split = function (index, force) { - if (force === void 0) { force = false; } - if (!force) { - if (index === 0) - return this; - if (index === this.length()) - return this.next; - } - var after = this.clone(); - this.parent.insertBefore(after, this.next); - this.children.forEachAt(index, this.length(), function (child, offset, length) { - child = child.split(offset, force); - after.appendChild(child); - }); - return after; - }; - ContainerBlot.prototype.unwrap = function () { - this.moveChildren(this.parent, this.next); - this.remove(); - }; - ContainerBlot.prototype.update = function (mutations) { - var _this = this; - var addedNodes = [], removedNodes = []; - mutations.forEach(function (mutation) { - if (mutation.target === _this.domNode && mutation.type === 'childList') { - addedNodes.push.apply(addedNodes, mutation.addedNodes); - removedNodes.push.apply(removedNodes, mutation.removedNodes); - } - }); - removedNodes.forEach(function (node) { - var blot = Registry.find(node); - if (blot == null) - return; - if (blot.domNode.parentNode == null || blot.domNode.parentNode === _this.domNode) { - blot.detach(); - } - }); - addedNodes.filter(function (node) { - return node.parentNode == _this.domNode; - }).sort(function (a, b) { - if (a === b) - return 0; - if (a.compareDocumentPosition(b) & Node.DOCUMENT_POSITION_FOLLOWING) { - return 1; - } - return -1; - }).forEach(function (node) { - var refBlot = null; - if (node.nextSibling != null) { - refBlot = Registry.find(node.nextSibling); - } - var blot = makeBlot(node); - if (blot.next != refBlot || blot.next == null) { - if (blot.parent != null) { - blot.parent.removeChild(_this); - } - _this.insertBefore(blot, refBlot); - } - }); - }; - return ContainerBlot; - }(shadow_1.default)); - function makeBlot(node) { - var blot = Registry.find(node); - if (blot == null) { - try { - blot = Registry.create(node); - } - catch (e) { - blot = Registry.create(Registry.Scope.INLINE); - [].slice.call(node.childNodes).forEach(function (child) { - blot.domNode.appendChild(child); - }); - node.parentNode.replaceChild(blot.domNode, node); - blot.attach(); - } - } - return blot; - } - Object.defineProperty(exports, "__esModule", { value: true }); - exports.default = ContainerBlot; - - -/***/ }, -/* 4 */ -/***/ function(module, exports) { - - "use strict"; - var LinkedList = (function () { - function LinkedList() { - this.head = this.tail = undefined; - this.length = 0; - } - LinkedList.prototype.append = function () { - var nodes = []; - for (var _i = 0; _i < arguments.length; _i++) { - nodes[_i - 0] = arguments[_i]; - } - this.insertBefore(nodes[0], undefined); - if (nodes.length > 1) { - this.append.apply(this, nodes.slice(1)); - } - }; - LinkedList.prototype.contains = function (node) { - var cur, next = this.iterator(); - while (cur = next()) { - if (cur === node) - return true; - } - return false; - }; - LinkedList.prototype.insertBefore = function (node, refNode) { - node.next = refNode; - if (refNode != null) { - node.prev = refNode.prev; - if (refNode.prev != null) { - refNode.prev.next = node; - } - refNode.prev = node; - if (refNode === this.head) { - this.head = node; - } - } - else if (this.tail != null) { - this.tail.next = node; - node.prev = this.tail; - this.tail = node; - } - else { - node.prev = undefined; - this.head = this.tail = node; - } - this.length += 1; - }; - LinkedList.prototype.offset = function (target) { - var index = 0, cur = this.head; - while (cur != null) { - if (cur === target) - return index; - index += cur.length(); - cur = cur.next; - } - return -1; - }; - LinkedList.prototype.remove = function (node) { - if (!this.contains(node)) - return; - if (node.prev != null) - node.prev.next = node.next; - if (node.next != null) - node.next.prev = node.prev; - if (node === this.head) - this.head = node.next; - if (node === this.tail) - this.tail = node.prev; - this.length -= 1; - }; - LinkedList.prototype.iterator = function (curNode) { - if (curNode === void 0) { curNode = this.head; } - // TODO use yield when we can - return function () { - var ret = curNode; - if (curNode != null) - curNode = curNode.next; - return ret; - }; - }; - LinkedList.prototype.find = function (index, inclusive) { - if (inclusive === void 0) { inclusive = false; } - var cur, next = this.iterator(); - while (cur = next()) { - var length_1 = cur.length(); - if (index < length_1 || (inclusive && index === length_1 && (cur.next == null || cur.next.length() !== 0))) { - return [cur, index]; - } - index -= length_1; - } - return [null, 0]; - }; - LinkedList.prototype.forEach = function (callback) { - var cur, next = this.iterator(); - while (cur = next()) { - callback(cur); - } - }; - LinkedList.prototype.forEachAt = function (index, length, callback) { - if (length <= 0) - return; - var _a = this.find(index), startNode = _a[0], offset = _a[1]; - var cur, curIndex = index - offset, next = this.iterator(startNode); - while ((cur = next()) && curIndex < index + length) { - var curLength = cur.length(); - if (index > curIndex) { - callback(cur, index - curIndex, Math.min(length, curIndex + curLength - index)); - } - else { - callback(cur, 0, Math.min(curLength, index + length - curIndex)); - } - curIndex += curLength; - } - }; - LinkedList.prototype.map = function (callback) { - return this.reduce(function (memo, cur) { - memo.push(callback(cur)); - return memo; - }, []); - }; - LinkedList.prototype.reduce = function (callback, memo) { - var cur, next = this.iterator(); - while (cur = next()) { - memo = callback(memo, cur); - } - return memo; - }; - return LinkedList; - }()); - Object.defineProperty(exports, "__esModule", { value: true }); - exports.default = LinkedList; - - -/***/ }, -/* 5 */ -/***/ function(module, exports, __webpack_require__) { - - "use strict"; - var Registry = __webpack_require__(6); - var ShadowBlot = (function () { - function ShadowBlot(domNode) { - this.domNode = domNode; - this.attach(); - } - Object.defineProperty(ShadowBlot.prototype, "statics", { - // Hack for accessing inherited static methods - get: function () { - return this.constructor; - }, - enumerable: true, - configurable: true - }); - ShadowBlot.create = function (value) { - if (this.tagName == null) { - throw new Registry.ParchmentError('Blot definition missing tagName'); - } - var node; - if (Array.isArray(this.tagName)) { - if (typeof value === 'string') { - value = value.toUpperCase(); - if (parseInt(value).toString() === value) { - value = parseInt(value); - } - } - if (typeof value === 'number') { - node = document.createElement(this.tagName[value - 1]); - } - else if (this.tagName.indexOf(value) > -1) { - node = document.createElement(value); - } - else { - node = document.createElement(this.tagName[0]); - } - } - else { - node = document.createElement(this.tagName); - } - if (this.className) { - node.classList.add(this.className); - } - return node; - }; - ShadowBlot.prototype.attach = function () { - this.domNode[Registry.DATA_KEY] = { blot: this }; - }; - ShadowBlot.prototype.clone = function () { - var domNode = this.domNode.cloneNode(); - return Registry.create(domNode); - }; - ShadowBlot.prototype.detach = function () { - if (this.parent != null) - this.parent.removeChild(this); - delete this.domNode[Registry.DATA_KEY]; - }; - ShadowBlot.prototype.deleteAt = function (index, length) { - var blot = this.isolate(index, length); - blot.remove(); - }; - ShadowBlot.prototype.formatAt = function (index, length, name, value) { - var blot = this.isolate(index, length); - if (Registry.query(name, Registry.Scope.BLOT) != null && value) { - blot.wrap(name, value); - } - else if (Registry.query(name, Registry.Scope.ATTRIBUTE) != null) { - var parent_1 = Registry.create(this.statics.scope); - blot.wrap(parent_1); - parent_1.format(name, value); - } - }; - ShadowBlot.prototype.insertAt = function (index, value, def) { - var blot = (def == null) ? Registry.create('text', value) : Registry.create(value, def); - var ref = this.split(index); - this.parent.insertBefore(blot, ref); - }; - ShadowBlot.prototype.insertInto = function (parentBlot, refBlot) { - if (this.parent != null) { - this.parent.children.remove(this); - } - parentBlot.children.insertBefore(this, refBlot); - if (refBlot != null) { - var refDomNode = refBlot.domNode; - } - if (this.next == null || this.domNode.nextSibling != refDomNode) { - parentBlot.domNode.insertBefore(this.domNode, refDomNode); - } - this.parent = parentBlot; - }; - ShadowBlot.prototype.isolate = function (index, length) { - var target = this.split(index); - target.split(length); - return target; - }; - ShadowBlot.prototype.length = function () { - return 1; - }; - ; - ShadowBlot.prototype.offset = function (root) { - if (root === void 0) { root = this.parent; } - if (this.parent == null || this == root) - return 0; - return this.parent.children.offset(this) + this.parent.offset(root); - }; - ShadowBlot.prototype.optimize = function () { - // TODO clean up once we use WeakMap - if (this.domNode[Registry.DATA_KEY] != null) { - delete this.domNode[Registry.DATA_KEY].mutations; - } - }; - ShadowBlot.prototype.remove = function () { - if (this.domNode.parentNode != null) { - this.domNode.parentNode.removeChild(this.domNode); - } - this.detach(); - }; - ShadowBlot.prototype.replace = function (target) { - if (target.parent == null) - return; - target.parent.insertBefore(this, target.next); - target.remove(); - }; - ShadowBlot.prototype.replaceWith = function (name, value) { - var replacement = typeof name === 'string' ? Registry.create(name, value) : name; - replacement.replace(this); - return replacement; - }; - ShadowBlot.prototype.split = function (index, force) { - return index === 0 ? this : this.next; - }; - ShadowBlot.prototype.update = function (mutations) { - if (mutations === void 0) { mutations = []; } - // Nothing to do by default - }; - ShadowBlot.prototype.wrap = function (name, value) { - var wrapper = typeof name === 'string' ? Registry.create(name, value) : name; - if (this.parent != null) { - this.parent.insertBefore(wrapper, this.next); - } - wrapper.appendChild(this); - return wrapper; - }; - ShadowBlot.blotName = 'abstract'; - return ShadowBlot; - }()); - Object.defineProperty(exports, "__esModule", { value: true }); - exports.default = ShadowBlot; - - -/***/ }, -/* 6 */ -/***/ function(module, exports) { - - "use strict"; - var __extends = (this && this.__extends) || function (d, b) { - for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; - function __() { this.constructor = d; } - d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); - }; - var ParchmentError = (function (_super) { - __extends(ParchmentError, _super); - function ParchmentError(message) { - message = '[Parchment] ' + message; - _super.call(this, message); - this.message = message; - this.name = this.constructor.name; - } - return ParchmentError; - }(Error)); - exports.ParchmentError = ParchmentError; - var attributes = {}; - var classes = {}; - var tags = {}; - var types = {}; - exports.DATA_KEY = '__blot'; - (function (Scope) { - Scope[Scope["TYPE"] = 3] = "TYPE"; - Scope[Scope["LEVEL"] = 12] = "LEVEL"; - Scope[Scope["ATTRIBUTE"] = 13] = "ATTRIBUTE"; - Scope[Scope["BLOT"] = 14] = "BLOT"; - Scope[Scope["INLINE"] = 7] = "INLINE"; - Scope[Scope["BLOCK"] = 11] = "BLOCK"; - Scope[Scope["BLOCK_BLOT"] = 10] = "BLOCK_BLOT"; - Scope[Scope["INLINE_BLOT"] = 6] = "INLINE_BLOT"; - Scope[Scope["BLOCK_ATTRIBUTE"] = 9] = "BLOCK_ATTRIBUTE"; - Scope[Scope["INLINE_ATTRIBUTE"] = 5] = "INLINE_ATTRIBUTE"; - Scope[Scope["ANY"] = 15] = "ANY"; - })(exports.Scope || (exports.Scope = {})); - var Scope = exports.Scope; - ; - function create(input, value) { - var match = query(input); - if (match == null) { - throw new ParchmentError("Unable to create " + input + " blot"); - } - var BlotClass = match; - var node = input instanceof Node ? input : BlotClass.create(value); - return new BlotClass(node, value); - } - exports.create = create; - function find(node, bubble) { - if (bubble === void 0) { bubble = false; } - if (node == null) - return null; - if (node[exports.DATA_KEY] != null) - return node[exports.DATA_KEY].blot; - if (bubble) - return find(node.parentNode, bubble); - return null; - } - exports.find = find; - function query(query, scope) { - if (scope === void 0) { scope = Scope.ANY; } - var match; - if (typeof query === 'string') { - match = types[query] || attributes[query]; - } - else if (query instanceof Text) { - match = types['text']; - } - else if (typeof query === 'number') { - if (query & Scope.LEVEL & Scope.BLOCK) { - match = types['block']; - } - else if (query & Scope.LEVEL & Scope.INLINE) { - match = types['inline']; - } - } - else if (query instanceof HTMLElement) { - var names = (query.getAttribute('class') || '').split(/\s+/); - for (var i in names) { - match = classes[names[i]]; - if (match) - break; - } - match = match || tags[query.tagName]; - } - if (match == null) - return null; - if ((scope & Scope.LEVEL & match.scope) && (scope & Scope.TYPE & match.scope)) - return match; - return null; - } - exports.query = query; - function register() { - var Definitions = []; - for (var _i = 0; _i < arguments.length; _i++) { - Definitions[_i - 0] = arguments[_i]; - } - if (Definitions.length > 1) { - return Definitions.map(function (d) { - return register(d); - }); - } - var Definition = Definitions[0]; - if (typeof Definition.blotName !== 'string' && typeof Definition.attrName !== 'string') { - throw new ParchmentError('Invalid definition'); - } - else if (Definition.blotName === 'abstract') { - throw new ParchmentError('Cannot register abstract class'); - } - types[Definition.blotName || Definition.attrName] = Definition; - if (typeof Definition.keyName === 'string') { - attributes[Definition.keyName] = Definition; - } - else { - if (Definition.className != null) { - classes[Definition.className] = Definition; - } - if (Definition.tagName != null) { - if (Array.isArray(Definition.tagName)) { - Definition.tagName = Definition.tagName.map(function (tagName) { - return tagName.toUpperCase(); - }); - } - else { - Definition.tagName = Definition.tagName.toUpperCase(); - } - var tagNames = Array.isArray(Definition.tagName) ? Definition.tagName : [Definition.tagName]; - tagNames.forEach(function (tag) { - if (tags[tag] == null || Definition.className == null) { - tags[tag] = Definition; - } - }); - } - } - return Definition; - } - exports.register = register; - - -/***/ }, -/* 7 */ -/***/ function(module, exports, __webpack_require__) { - - "use strict"; - var __extends = (this && this.__extends) || function (d, b) { - for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; - function __() { this.constructor = d; } - d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); - }; - var attributor_1 = __webpack_require__(8); - var store_1 = __webpack_require__(9); - var container_1 = __webpack_require__(3); - var Registry = __webpack_require__(6); - var FormatBlot = (function (_super) { - __extends(FormatBlot, _super); - function FormatBlot() { - _super.apply(this, arguments); - } - FormatBlot.formats = function (domNode) { - if (typeof this.tagName === 'string') { - return true; - } - else if (Array.isArray(this.tagName)) { - return domNode.tagName.toLowerCase(); - } - return undefined; - }; - FormatBlot.prototype.attach = function () { - _super.prototype.attach.call(this); - this.attributes = new store_1.default(this.domNode); - }; - FormatBlot.prototype.format = function (name, value) { - var format = Registry.query(name); - if (format instanceof attributor_1.default) { - this.attributes.attribute(format, value); - } - else if (value) { - if (format != null && (name !== this.statics.blotName || this.formats()[name] !== value)) { - this.replaceWith(name, value); - } - } - }; - FormatBlot.prototype.formats = function () { - var formats = this.attributes.values(); - var format = this.statics.formats(this.domNode); - if (format != null) { - formats[this.statics.blotName] = format; - } - return formats; - }; - FormatBlot.prototype.replaceWith = function (name, value) { - var replacement = _super.prototype.replaceWith.call(this, name, value); - this.attributes.copy(replacement); - return replacement; - }; - FormatBlot.prototype.update = function (mutations) { - var _this = this; - _super.prototype.update.call(this, mutations); - if (mutations.some(function (mutation) { - return mutation.target === _this.domNode && mutation.type === 'attributes'; - })) { - this.attributes.build(); - } - }; - FormatBlot.prototype.wrap = function (name, value) { - var wrapper = _super.prototype.wrap.call(this, name, value); - if (wrapper instanceof FormatBlot && wrapper.statics.scope === this.statics.scope) { - this.attributes.move(wrapper); - } - return wrapper; - }; - return FormatBlot; - }(container_1.default)); - Object.defineProperty(exports, "__esModule", { value: true }); - exports.default = FormatBlot; - - -/***/ }, -/* 8 */ -/***/ function(module, exports, __webpack_require__) { - - "use strict"; - var Registry = __webpack_require__(6); - var Attributor = (function () { - function Attributor(attrName, keyName, options) { - if (options === void 0) { options = {}; } - this.attrName = attrName; - this.keyName = keyName; - var attributeBit = Registry.Scope.TYPE & Registry.Scope.ATTRIBUTE; - if (options.scope != null) { - // Ignore type bits, force attribute bit - this.scope = (options.scope & Registry.Scope.LEVEL) | attributeBit; - } - else { - this.scope = Registry.Scope.ATTRIBUTE; - } - if (options.whitelist != null) - this.whitelist = options.whitelist; - } - Attributor.keys = function (node) { - return [].map.call(node.attributes, function (item) { - return item.name; - }); - }; - Attributor.prototype.add = function (node, value) { - if (!this.canAdd(node, value)) - return false; - node.setAttribute(this.keyName, value); - return true; - }; - Attributor.prototype.canAdd = function (node, value) { - var match = Registry.query(node, Registry.Scope.BLOT & (this.scope | Registry.Scope.TYPE)); - if (match != null && (this.whitelist == null || this.whitelist.indexOf(value) > -1)) { - return true; - } - return false; - }; - Attributor.prototype.remove = function (node) { - node.removeAttribute(this.keyName); - }; - Attributor.prototype.value = function (node) { - return node.getAttribute(this.keyName); - }; - return Attributor; - }()); - Object.defineProperty(exports, "__esModule", { value: true }); - exports.default = Attributor; - - -/***/ }, -/* 9 */ -/***/ function(module, exports, __webpack_require__) { - - "use strict"; - var attributor_1 = __webpack_require__(8); - var class_1 = __webpack_require__(10); - var style_1 = __webpack_require__(11); - var Registry = __webpack_require__(6); - var AttributorStore = (function () { - function AttributorStore(domNode) { - this.attributes = {}; - this.domNode = domNode; - this.build(); - } - AttributorStore.prototype.attribute = function (attribute, value) { - if (value) { - if (attribute.add(this.domNode, value)) { - if (attribute.value(this.domNode) != null) { - this.attributes[attribute.attrName] = attribute; - } - else { - delete this.attributes[attribute.attrName]; - } - } - } - else { - attribute.remove(this.domNode); - delete this.attributes[attribute.attrName]; - } - }; - AttributorStore.prototype.build = function () { - var _this = this; - this.attributes = {}; - var attributes = attributor_1.default.keys(this.domNode); - var classes = class_1.default.keys(this.domNode); - var styles = style_1.default.keys(this.domNode); - attributes.concat(classes).concat(styles).forEach(function (name) { - var attr = Registry.query(name, Registry.Scope.ATTRIBUTE); - if (attr instanceof attributor_1.default) { - _this.attributes[attr.attrName] = attr; - } - }); - }; - AttributorStore.prototype.copy = function (target) { - var _this = this; - Object.keys(this.attributes).forEach(function (key) { - var value = _this.attributes[key].value(_this.domNode); - target.format(key, value); - }); - }; - AttributorStore.prototype.move = function (target) { - var _this = this; - this.copy(target); - Object.keys(this.attributes).forEach(function (key) { - _this.attributes[key].remove(_this.domNode); - }); - this.attributes = {}; - }; - AttributorStore.prototype.values = function () { - var _this = this; - return Object.keys(this.attributes).reduce(function (attributes, name) { - attributes[name] = _this.attributes[name].value(_this.domNode); - return attributes; - }, {}); - }; - return AttributorStore; - }()); - Object.defineProperty(exports, "__esModule", { value: true }); - exports.default = AttributorStore; - - -/***/ }, -/* 10 */ -/***/ function(module, exports, __webpack_require__) { - - "use strict"; - var __extends = (this && this.__extends) || function (d, b) { - for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; - function __() { this.constructor = d; } - d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); - }; - var attributor_1 = __webpack_require__(8); - function match(node, prefix) { - var className = node.getAttribute('class') || ''; - return className.split(/\s+/).filter(function (name) { - return name.indexOf(prefix + "-") === 0; - }); - } - var ClassAttributor = (function (_super) { - __extends(ClassAttributor, _super); - function ClassAttributor() { - _super.apply(this, arguments); - } - ClassAttributor.keys = function (node) { - return (node.getAttribute('class') || '').split(/\s+/).map(function (name) { - return name.split('-').slice(0, -1).join('-'); - }); - }; - ClassAttributor.prototype.add = function (node, value) { - if (!this.canAdd(node, value)) - return false; - this.remove(node); - node.classList.add(this.keyName + "-" + value); - return true; - }; - ClassAttributor.prototype.remove = function (node) { - var matches = match(node, this.keyName); - matches.forEach(function (name) { - node.classList.remove(name); - }); - if (node.classList.length === 0) { - node.removeAttribute('class'); - } - }; - ClassAttributor.prototype.value = function (node) { - var result = match(node, this.keyName)[0] || ''; - return result.slice(this.keyName.length + 1); // +1 for hyphen - }; - return ClassAttributor; - }(attributor_1.default)); - Object.defineProperty(exports, "__esModule", { value: true }); - exports.default = ClassAttributor; - - -/***/ }, -/* 11 */ -/***/ function(module, exports, __webpack_require__) { - - "use strict"; - var __extends = (this && this.__extends) || function (d, b) { - for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; - function __() { this.constructor = d; } - d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); - }; - var attributor_1 = __webpack_require__(8); - function camelize(name) { - var parts = name.split('-'); - var rest = parts.slice(1).map(function (part) { - return part[0].toUpperCase() + part.slice(1); - }).join(''); - return parts[0] + rest; - } - var StyleAttributor = (function (_super) { - __extends(StyleAttributor, _super); - function StyleAttributor() { - _super.apply(this, arguments); - } - StyleAttributor.keys = function (node) { - return (node.getAttribute('style') || '').split(';').map(function (value) { - var arr = value.split(':'); - return arr[0].trim(); - }); - }; - StyleAttributor.prototype.add = function (node, value) { - if (!this.canAdd(node, value)) - return false; - node.style[camelize(this.keyName)] = value; - return true; - }; - StyleAttributor.prototype.remove = function (node) { - node.style[camelize(this.keyName)] = ''; - if (!node.getAttribute('style')) { - node.removeAttribute('style'); - } - }; - StyleAttributor.prototype.value = function (node) { - return node.style[camelize(this.keyName)]; - }; - return StyleAttributor; - }(attributor_1.default)); - Object.defineProperty(exports, "__esModule", { value: true }); - exports.default = StyleAttributor; - - -/***/ }, -/* 12 */ -/***/ function(module, exports, __webpack_require__) { - - "use strict"; - var __extends = (this && this.__extends) || function (d, b) { - for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; - function __() { this.constructor = d; } - d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); - }; - var shadow_1 = __webpack_require__(5); - var Registry = __webpack_require__(6); - var LeafBlot = (function (_super) { - __extends(LeafBlot, _super); - function LeafBlot() { - _super.apply(this, arguments); - } - LeafBlot.value = function (domNode) { - return true; - }; - LeafBlot.prototype.index = function (node, offset) { - if (node !== this.domNode) - return -1; - return Math.min(offset, 1); - }; - LeafBlot.prototype.position = function (index, inclusive) { - var offset = [].indexOf.call(this.parent.domNode.childNodes, this.domNode); - if (index > 0) - offset += 1; - return [this.parent.domNode, offset]; - }; - LeafBlot.prototype.value = function () { - return (_a = {}, _a[this.statics.blotName] = this.statics.value(this.domNode) || true, _a); - var _a; - }; - LeafBlot.scope = Registry.Scope.INLINE_BLOT; - return LeafBlot; - }(shadow_1.default)); - Object.defineProperty(exports, "__esModule", { value: true }); - exports.default = LeafBlot; - - -/***/ }, -/* 13 */ -/***/ function(module, exports, __webpack_require__) { - - "use strict"; - var __extends = (this && this.__extends) || function (d, b) { - for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; - function __() { this.constructor = d; } - d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); - }; - var container_1 = __webpack_require__(3); - var Registry = __webpack_require__(6); - var OBSERVER_CONFIG = { - attributes: true, - characterData: true, - characterDataOldValue: true, - childList: true, - subtree: true - }; - var MAX_OPTIMIZE_ITERATIONS = 100; - var ScrollBlot = (function (_super) { - __extends(ScrollBlot, _super); - function ScrollBlot(node) { - var _this = this; - _super.call(this, node); - this.parent = null; - this.observer = new MutationObserver(function (mutations) { - _this.update(mutations); - }); - this.observer.observe(this.domNode, OBSERVER_CONFIG); - } - ScrollBlot.prototype.detach = function () { - _super.prototype.detach.call(this); - this.observer.disconnect(); - }; - ScrollBlot.prototype.deleteAt = function (index, length) { - this.update(); - if (index === 0 && length === this.length()) { - this.children.forEach(function (child) { - child.remove(); - }); - } - else { - _super.prototype.deleteAt.call(this, index, length); - } - }; - ScrollBlot.prototype.formatAt = function (index, length, name, value) { - this.update(); - _super.prototype.formatAt.call(this, index, length, name, value); - }; - ScrollBlot.prototype.insertAt = function (index, value, def) { - this.update(); - _super.prototype.insertAt.call(this, index, value, def); - }; - ScrollBlot.prototype.optimize = function (mutations) { - var _this = this; - if (mutations === void 0) { mutations = []; } - _super.prototype.optimize.call(this); - mutations.push.apply(mutations, this.observer.takeRecords()); - // TODO use WeakMap - var mark = function (blot, markParent) { - if (markParent === void 0) { markParent = true; } - if (blot == null || blot === _this) - return; - if (blot.domNode.parentNode == null) - return; - if (blot.domNode[Registry.DATA_KEY].mutations == null) { - blot.domNode[Registry.DATA_KEY].mutations = []; - } - if (markParent) - mark(blot.parent); - }; - var optimize = function (blot) { - if (blot.domNode[Registry.DATA_KEY] == null || blot.domNode[Registry.DATA_KEY].mutations == null) { - return; - } - if (blot instanceof container_1.default) { - blot.children.forEach(optimize); - } - blot.optimize(); - }; - var remaining = mutations; - for (var i = 0; remaining.length > 0; i += 1) { - if (i >= MAX_OPTIMIZE_ITERATIONS) { - throw new Error('[Parchment] Maximum optimize iterations reached'); - } - remaining.forEach(function (mutation) { - var blot = Registry.find(mutation.target, true); - if (blot == null) - return; - if (blot.domNode === mutation.target) { - if (mutation.type === 'childList') { - mark(Registry.find(mutation.previousSibling, false)); - [].forEach.call(mutation.addedNodes, function (node) { - var child = Registry.find(node, false); - mark(child, false); - if (child instanceof container_1.default) { - child.children.forEach(function (grandChild) { - mark(grandChild, false); - }); - } - }); - } - else if (mutation.type === 'attributes') { - mark(blot.prev); - } - } - mark(blot); - }); - this.children.forEach(optimize); - remaining = this.observer.takeRecords(); - mutations.push.apply(mutations, remaining); - } - }; - ScrollBlot.prototype.update = function (mutations) { - var _this = this; - mutations = mutations || this.observer.takeRecords(); - // TODO use WeakMap - mutations.map(function (mutation) { - var blot = Registry.find(mutation.target, true); - if (blot == null) - return; - if (blot.domNode[Registry.DATA_KEY].mutations == null) { - blot.domNode[Registry.DATA_KEY].mutations = [mutation]; - return blot; - } - else { - blot.domNode[Registry.DATA_KEY].mutations.push(mutation); - return null; - } - }).forEach(function (blot) { - if (blot == null || blot === _this) - return; - blot.update(blot.domNode[Registry.DATA_KEY].mutations || []); - }); - if (this.domNode[Registry.DATA_KEY].mutations != null) { - _super.prototype.update.call(this, this.domNode[Registry.DATA_KEY].mutations); - } - this.optimize(mutations); - }; - ScrollBlot.blotName = 'scroll'; - ScrollBlot.defaultChild = 'block'; - ScrollBlot.scope = Registry.Scope.BLOCK_BLOT; - ScrollBlot.tagName = 'DIV'; - return ScrollBlot; - }(container_1.default)); - Object.defineProperty(exports, "__esModule", { value: true }); - exports.default = ScrollBlot; - - -/***/ }, -/* 14 */ -/***/ function(module, exports, __webpack_require__) { - - "use strict"; - var __extends = (this && this.__extends) || function (d, b) { - for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; - function __() { this.constructor = d; } - d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); - }; - var format_1 = __webpack_require__(7); - var Registry = __webpack_require__(6); - // Shallow object comparison - function isEqual(obj1, obj2) { - if (Object.keys(obj1).length !== Object.keys(obj2).length) - return false; - for (var prop in obj1) { - if (obj1[prop] !== obj2[prop]) - return false; - } - return true; - } - var InlineBlot = (function (_super) { - __extends(InlineBlot, _super); - function InlineBlot() { - _super.apply(this, arguments); - } - InlineBlot.formats = function (domNode) { - if (domNode.tagName === InlineBlot.tagName) - return undefined; - return _super.formats.call(this, domNode); - }; - InlineBlot.prototype.format = function (name, value) { - var _this = this; - if (name === this.statics.blotName && !value) { - this.children.forEach(function (child) { - if (!(child instanceof format_1.default)) { - child = child.wrap(InlineBlot.blotName, true); - } - _this.attributes.copy(child); - }); - this.unwrap(); - } - else { - _super.prototype.format.call(this, name, value); - } - }; - InlineBlot.prototype.formatAt = function (index, length, name, value) { - if (this.formats()[name] != null || Registry.query(name, Registry.Scope.ATTRIBUTE)) { - var blot = this.isolate(index, length); - blot.format(name, value); - } - else { - _super.prototype.formatAt.call(this, index, length, name, value); - } - }; - InlineBlot.prototype.optimize = function () { - _super.prototype.optimize.call(this); - var formats = this.formats(); - if (Object.keys(formats).length === 0) { - return this.unwrap(); // unformatted span - } - var next = this.next; - if (next instanceof InlineBlot && next.prev === this && isEqual(formats, next.formats())) { - next.moveChildren(this); - next.remove(); - } - }; - InlineBlot.blotName = 'inline'; - InlineBlot.scope = Registry.Scope.INLINE_BLOT; - InlineBlot.tagName = 'SPAN'; - return InlineBlot; - }(format_1.default)); - Object.defineProperty(exports, "__esModule", { value: true }); - exports.default = InlineBlot; - - -/***/ }, -/* 15 */ -/***/ function(module, exports, __webpack_require__) { - - "use strict"; - var __extends = (this && this.__extends) || function (d, b) { - for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; - function __() { this.constructor = d; } - d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); - }; - var format_1 = __webpack_require__(7); - var Registry = __webpack_require__(6); - var BlockBlot = (function (_super) { - __extends(BlockBlot, _super); - function BlockBlot() { - _super.apply(this, arguments); - } - BlockBlot.formats = function (domNode) { - var tagName = Registry.query(BlockBlot.blotName).tagName; - if (domNode.tagName === tagName) - return undefined; - return _super.formats.call(this, domNode); - }; - BlockBlot.prototype.format = function (name, value) { - if (Registry.query(name, Registry.Scope.BLOCK) == null) { - return; - } - else if (name === this.statics.blotName && !value) { - this.replaceWith(BlockBlot.blotName); - } - else { - _super.prototype.format.call(this, name, value); - } - }; - BlockBlot.prototype.formatAt = function (index, length, name, value) { - if (Registry.query(name, Registry.Scope.BLOCK) != null) { - this.format(name, value); - } - else { - _super.prototype.formatAt.call(this, index, length, name, value); - } - }; - BlockBlot.prototype.insertAt = function (index, value, def) { - if (def == null || Registry.query(value, Registry.Scope.INLINE) != null) { - // Insert text or inline - _super.prototype.insertAt.call(this, index, value, def); - } - else { - var after = this.split(index); - var blot = Registry.create(value, def); - after.parent.insertBefore(blot, after); - } - }; - BlockBlot.blotName = 'block'; - BlockBlot.scope = Registry.Scope.BLOCK_BLOT; - BlockBlot.tagName = 'P'; - return BlockBlot; - }(format_1.default)); - Object.defineProperty(exports, "__esModule", { value: true }); - exports.default = BlockBlot; - - -/***/ }, -/* 16 */ -/***/ function(module, exports, __webpack_require__) { - - "use strict"; - var __extends = (this && this.__extends) || function (d, b) { - for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; - function __() { this.constructor = d; } - d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); - }; - var leaf_1 = __webpack_require__(12); - var EmbedBlot = (function (_super) { - __extends(EmbedBlot, _super); - function EmbedBlot() { - _super.apply(this, arguments); - } - EmbedBlot.formats = function (domNode) { - return undefined; - }; - EmbedBlot.prototype.format = function (name, value) { - // super.formatAt wraps, which is what we want in general, - // but this allows subclasses to overwrite for formats - // that just apply to particular embeds - _super.prototype.formatAt.call(this, 0, this.length(), name, value); - }; - EmbedBlot.prototype.formatAt = function (index, length, name, value) { - if (index === 0 && length === this.length()) { - this.format(name, value); - } - else { - _super.prototype.formatAt.call(this, index, length, name, value); - } - }; - EmbedBlot.prototype.formats = function () { - return this.statics.formats(this.domNode); - }; - return EmbedBlot; - }(leaf_1.default)); - Object.defineProperty(exports, "__esModule", { value: true }); - exports.default = EmbedBlot; - - -/***/ }, -/* 17 */ -/***/ function(module, exports, __webpack_require__) { - - "use strict"; - var __extends = (this && this.__extends) || function (d, b) { - for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; - function __() { this.constructor = d; } - d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); - }; - var leaf_1 = __webpack_require__(12); - var Registry = __webpack_require__(6); - var TextBlot = (function (_super) { - __extends(TextBlot, _super); - function TextBlot(node) { - _super.call(this, node); - this.text = this.statics.value(this.domNode); - } - TextBlot.create = function (value) { - return document.createTextNode(value); - }; - TextBlot.value = function (domNode) { - return domNode.data; - }; - TextBlot.prototype.deleteAt = function (index, length) { - this.domNode.data = this.text = this.text.slice(0, index) + this.text.slice(index + length); - }; - TextBlot.prototype.index = function (node, offset) { - if (this.domNode === node) { - return offset; - } - return -1; - }; - TextBlot.prototype.insertAt = function (index, value, def) { - if (def == null) { - this.text = this.text.slice(0, index) + value + this.text.slice(index); - this.domNode.data = this.text; - } - else { - _super.prototype.insertAt.call(this, index, value, def); - } - }; - TextBlot.prototype.length = function () { - return this.text.length; - }; - TextBlot.prototype.optimize = function () { - _super.prototype.optimize.call(this); - this.text = this.statics.value(this.domNode); - if (this.text.length === 0) { - this.remove(); - } - else if (this.next instanceof TextBlot && this.next.prev === this) { - this.insertAt(this.length(), this.next.value()); - this.next.remove(); - } - }; - TextBlot.prototype.position = function (index, inclusive) { - if (inclusive === void 0) { inclusive = false; } - return [this.domNode, index]; - }; - TextBlot.prototype.split = function (index, force) { - if (force === void 0) { force = false; } - if (!force) { - if (index === 0) - return this; - if (index === this.length()) - return this.next; - } - var after = Registry.create(this.domNode.splitText(index)); - this.parent.insertBefore(after, this.next); - this.text = this.statics.value(this.domNode); - return after; - }; - TextBlot.prototype.update = function (mutations) { - var _this = this; - if (mutations.some(function (mutation) { - return mutation.type === 'characterData' && mutation.target === _this.domNode; - })) { - this.text = this.statics.value(this.domNode); - } - }; - TextBlot.prototype.value = function () { - return this.text; - }; - TextBlot.blotName = 'text'; - TextBlot.scope = Registry.Scope.INLINE_BLOT; - return TextBlot; - }(leaf_1.default)); - Object.defineProperty(exports, "__esModule", { value: true }); - exports.default = TextBlot; - - -/***/ }, -/* 18 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - Object.defineProperty(exports, "__esModule", { - value: true - }); - exports.default = exports.overload = exports.expandConfig = undefined; - - var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; - - var _slicedToArray = function () { function sliceIterator(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"]) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } return function (arr, i) { if (Array.isArray(arr)) { return arr; } else if (Symbol.iterator in Object(arr)) { return sliceIterator(arr, i); } else { throw new TypeError("Invalid attempt to destructure non-iterable instance"); } }; }(); - - var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); - - __webpack_require__(19); - - var _delta = __webpack_require__(20); - - var _delta2 = _interopRequireDefault(_delta); - - var _editor = __webpack_require__(27); - - var _editor2 = _interopRequireDefault(_editor); - - var _emitter = __webpack_require__(28); - - var _emitter2 = _interopRequireDefault(_emitter); - - var _module = __webpack_require__(39); - - var _module2 = _interopRequireDefault(_module); - - var _parchment = __webpack_require__(2); - - var _parchment2 = _interopRequireDefault(_parchment); - - var _selection = __webpack_require__(40); - - var _selection2 = _interopRequireDefault(_selection); - - var _extend = __webpack_require__(25); - - var _extend2 = _interopRequireDefault(_extend); - - var _logger = __webpack_require__(30); - - var _logger2 = _interopRequireDefault(_logger); - - var _theme = __webpack_require__(41); - - var _theme2 = _interopRequireDefault(_theme); - - function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - - function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } - - var debug = (0, _logger2.default)('quill'); - - var Quill = function () { - _createClass(Quill, null, [{ - key: 'debug', - value: function debug(limit) { - _logger2.default.level(limit); - } - }, { - key: 'import', - value: function _import(name) { - if (this.imports[name] == null) { - debug.error('Cannot import ' + name + '. Are you sure it was registered?'); - } - return this.imports[name]; - } - }, { - key: 'register', - value: function register(path, target) { - var _this = this; - - var overwrite = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false; - - if (typeof path !== 'string') { - var name = path.attrName || path.blotName; - if (typeof name === 'string') { - // register(Blot | Attributor, overwrite) - this.register('formats/' + name, path, target); - } else { - Object.keys(path).forEach(function (key) { - _this.register(key, path[key], target); - }); - } - } else { - if (this.imports[path] != null && !overwrite) { - debug.warn('Overwriting ' + path + ' with', target); - } - this.imports[path] = target; - if ((path.startsWith('blots/') || path.startsWith('formats/')) && target.blotName !== 'abstract') { - _parchment2.default.register(target); - } - } - } - }]); - - function Quill(container) { - var _this2 = this; - - var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; - - _classCallCheck(this, Quill); - - options = expandConfig(container, options); - this.container = options.container; - if (this.container == null) { - return debug.error('Invalid Quill container', container); - } - if (options.debug) { - Quill.debug(options.debug); - } - var html = this.container.innerHTML.trim(); - this.container.classList.add('ql-container'); - this.container.innerHTML = ''; - this.root = this.addContainer('ql-editor'); - this.emitter = new _emitter2.default(); - this.scroll = _parchment2.default.create(this.root, { - emitter: this.emitter, - whitelist: options.formats - }); - this.editor = new _editor2.default(this.scroll, this.emitter); - this.selection = new _selection2.default(this.scroll, this.emitter); - this.theme = new options.theme(this, options); - this.keyboard = this.theme.addModule('keyboard'); - this.clipboard = this.theme.addModule('clipboard'); - this.history = this.theme.addModule('history'); - this.theme.init(); - var contents = this.clipboard.convert('
          ' + html + '


          '); - this.setContents(contents); - this.history.clear(); - if (options.readOnly) { - this.disable(); - } - if (options.placeholder) { - this.root.setAttribute('data-placeholder', options.placeholder); - } - this.root.classList.toggle('ql-blank', this.editor.isBlank()); - this.emitter.on(_emitter2.default.events.TEXT_CHANGE, function (delta) { - _this2.root.classList.toggle('ql-blank', _this2.editor.isBlank()); - }); - } - - _createClass(Quill, [{ - key: 'addContainer', - value: function addContainer(container) { - var refNode = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null; - - if (typeof container === 'string') { - var className = container; - container = document.createElement('div'); - container.classList.add(className); - } - this.container.insertBefore(container, refNode); - return container; - } - }, { - key: 'blur', - value: function blur() { - this.selection.setRange(null); - } - }, { - key: 'deleteText', - value: function deleteText(index, length, source) { - var _overload = overload(index, length, source); - - var _overload2 = _slicedToArray(_overload, 4); - - index = _overload2[0]; - length = _overload2[1]; - source = _overload2[3]; - - var range = this.getSelection(); - var change = this.editor.deleteText(index, length, source); - range = shiftRange(range, index, -1 * length, source); - this.setSelection(range, _emitter2.default.sources.SILENT); - return change; - } - }, { - key: 'disable', - value: function disable() { - this.enable(false); - } - }, { - key: 'enable', - value: function enable() { - var enabled = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true; - - this.editor.enable(enabled); - if (!enabled) { - this.blur(); - } - } - }, { - key: 'focus', - value: function focus() { - this.selection.focus(); - this.selection.scrollIntoView(); - } - }, { - key: 'format', - value: function format(name, value) { - var source = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : _emitter2.default.sources.API; - - var range = this.getSelection(true); - var change = new _delta2.default(); - if (range == null) return change; - if (_parchment2.default.query(name, _parchment2.default.Scope.BLOCK)) { - change = this.formatLine(range, name, value, source); - } else if (range.length === 0) { - this.selection.format(name, value); - return change; - } else { - change = this.formatText(range, name, value, source); - } - this.setSelection(range, _emitter2.default.sources.SILENT); - return change; - } - }, { - key: 'formatLine', - value: function formatLine(index, length, name, value, source) { - var formats = void 0; - - var _overload3 = overload(index, length, name, value, source); - - var _overload4 = _slicedToArray(_overload3, 4); - - index = _overload4[0]; - length = _overload4[1]; - formats = _overload4[2]; - source = _overload4[3]; - - var range = this.getSelection(); - var change = this.editor.formatLine(index, length, formats, source); - this.selection.setRange(range, true, _emitter2.default.sources.SILENT); - this.selection.scrollIntoView(); - return change; - } - }, { - key: 'formatText', - value: function formatText(index, length, name, value, source) { - var formats = void 0; - - var _overload5 = overload(index, length, name, value, source); - - var _overload6 = _slicedToArray(_overload5, 4); - - index = _overload6[0]; - length = _overload6[1]; - formats = _overload6[2]; - source = _overload6[3]; - - var range = this.getSelection(); - var change = this.editor.formatText(index, length, formats, source); - this.selection.setRange(range, true, _emitter2.default.sources.SILENT); - this.selection.scrollIntoView(); - return change; - } - }, { - key: 'getBounds', - value: function getBounds(index) { - var length = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0; - - if (typeof index === 'number') { - return this.selection.getBounds(index, length); - } else { - return this.selection.getBounds(index.index, index.length); - } - } - }, { - key: 'getContents', - value: function getContents() { - var index = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0; - var length = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : this.getLength() - index; - - var _overload7 = overload(index, length); - - var _overload8 = _slicedToArray(_overload7, 2); - - index = _overload8[0]; - length = _overload8[1]; - - return this.editor.getContents(index, length); - } - }, { - key: 'getFormat', - value: function getFormat() { - var index = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : this.getSelection(); - var length = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0; - - if (typeof index === 'number') { - return this.editor.getFormat(index, length); - } else { - return this.editor.getFormat(index.index, index.length); - } - } - }, { - key: 'getLength', - value: function getLength() { - return this.scroll.length(); - } - }, { - key: 'getModule', - value: function getModule(name) { - return this.theme.modules[name]; - } - }, { - key: 'getSelection', - value: function getSelection() { - var focus = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false; - - if (focus) this.focus(); - this.update(); // Make sure we access getRange with editor in consistent state - return this.selection.getRange()[0]; - } - }, { - key: 'getText', - value: function getText() { - var index = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0; - var length = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : this.getLength() - index; - - var _overload9 = overload(index, length); - - var _overload10 = _slicedToArray(_overload9, 2); - - index = _overload10[0]; - length = _overload10[1]; - - return this.editor.getText(index, length); - } - }, { - key: 'hasFocus', - value: function hasFocus() { - return this.selection.hasFocus(); - } - }, { - key: 'insertEmbed', - value: function insertEmbed(index, embed, value) { - var source = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : Quill.sources.API; - - var range = this.getSelection(); - var change = this.editor.insertEmbed(index, embed, value, source); - range = shiftRange(range, change, source); - this.setSelection(range, _emitter2.default.sources.SILENT); - return change; - } - }, { - key: 'insertText', - value: function insertText(index, text, name, value, source) { - var formats = void 0, - range = this.getSelection(); - - var _overload11 = overload(index, 0, name, value, source); - - var _overload12 = _slicedToArray(_overload11, 4); - - index = _overload12[0]; - formats = _overload12[2]; - source = _overload12[3]; - - var change = this.editor.insertText(index, text, formats, source); - range = shiftRange(range, index, text.length, source); - this.setSelection(range, _emitter2.default.sources.SILENT); - return change; - } - }, { - key: 'off', - value: function off() { - return this.emitter.off.apply(this.emitter, arguments); - } - }, { - key: 'on', - value: function on() { - return this.emitter.on.apply(this.emitter, arguments); - } - }, { - key: 'once', - value: function once() { - return this.emitter.once.apply(this.emitter, arguments); - } - }, { - key: 'pasteHTML', - value: function pasteHTML(index, html, source) { - this.clipboard.dangerouslyPasteHTML(index, html, source); - } - }, { - key: 'removeFormat', - value: function removeFormat(index, length, source) { - var range = this.getSelection(); - - var _overload13 = overload(index, length, source); - - var _overload14 = _slicedToArray(_overload13, 4); - - index = _overload14[0]; - length = _overload14[1]; - source = _overload14[3]; - - var change = this.editor.removeFormat(index, length, source); - range = shiftRange(range, change, source); - this.setSelection(range, _emitter2.default.sources.SILENT); - return change; - } - }, { - key: 'setContents', - value: function setContents(delta) { - var source = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : _emitter2.default.sources.API; - - delta = new _delta2.default(delta).slice(); - var lastOp = delta.ops[delta.ops.length - 1]; - // Quill contents must always end with newline - if (lastOp == null || lastOp.insert[lastOp.insert.length - 1] !== '\n') { - delta.insert('\n'); - } - delta.delete(this.getLength()); - return this.editor.applyDelta(delta, source); - } - }, { - key: 'setSelection', - value: function setSelection(index, length, source) { - if (index == null) { - this.selection.setRange(null, length || Quill.sources.API); - } else { - var _overload15 = overload(index, length, source); - - var _overload16 = _slicedToArray(_overload15, 4); - - index = _overload16[0]; - length = _overload16[1]; - source = _overload16[3]; - - this.selection.setRange(new _selection.Range(index, length), source); - } - this.selection.scrollIntoView(); - } - }, { - key: 'setText', - value: function setText(text) { - var source = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : _emitter2.default.sources.API; - - var delta = new _delta2.default().insert(text); - return this.setContents(delta, source); - } - }, { - key: 'update', - value: function update() { - var source = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : _emitter2.default.sources.USER; - - var change = this.scroll.update(source); // Will update selection before selection.update() does if text changes - this.selection.update(source); - return change; - } - }, { - key: 'updateContents', - value: function updateContents(delta) { - var source = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : _emitter2.default.sources.API; - - var range = this.getSelection(); - if (Array.isArray(delta)) { - delta = new _delta2.default(delta.slice()); - } - var change = this.editor.applyDelta(delta, source); - if (range != null) { - range = shiftRange(range, change, source); - this.setSelection(range, _emitter2.default.sources.SILENT); - } - return change; - } - }]); - - return Quill; - }(); - - Quill.DEFAULTS = { - bounds: null, - formats: null, - modules: {}, - placeholder: '', - readOnly: false, - theme: 'default' - }; - Quill.events = _emitter2.default.events; - Quill.sources = _emitter2.default.sources; - Quill.version = false ? 'dev' : ("1.0.6"); - - Quill.imports = { - 'delta': _delta2.default, - 'parchment': _parchment2.default, - 'core/module': _module2.default, - 'core/theme': _theme2.default - }; - - function expandConfig(container, userConfig) { - userConfig = (0, _extend2.default)(true, { - container: container, - modules: { - clipboard: true, - keyboard: true, - history: true - } - }, userConfig); - if (!userConfig.theme || userConfig.theme === Quill.DEFAULTS.theme) { - userConfig.theme = _theme2.default; - } else { - userConfig.theme = Quill.import('themes/' + userConfig.theme); - if (userConfig.theme == null) { - throw new Error('Invalid theme ' + userConfig.theme + '. Did you register it?'); - } - } - var themeConfig = (0, _extend2.default)(true, {}, userConfig.theme.DEFAULTS); - [themeConfig, userConfig].forEach(function (config) { - config.modules = config.modules || {}; - Object.keys(config.modules).forEach(function (module) { - if (config.modules[module] === true) { - config.modules[module] = {}; - } - }); - }); - var moduleNames = Object.keys(themeConfig.modules).concat(Object.keys(userConfig.modules)); - var moduleConfig = moduleNames.reduce(function (config, name) { - var moduleClass = Quill.import('modules/' + name); - if (moduleClass == null) { - debug.error('Cannot load ' + name + ' module. Are you sure you registered it?'); - } else { - config[name] = moduleClass.DEFAULTS || {}; - } - return config; - }, {}); - // Special case toolbar shorthand - if (userConfig.modules != null && userConfig.modules.toolbar && userConfig.modules.toolbar.constructor !== Object) { - userConfig.modules.toolbar = { - container: userConfig.modules.toolbar - }; - } - userConfig = (0, _extend2.default)(true, {}, Quill.DEFAULTS, { modules: moduleConfig }, themeConfig, userConfig); - ['bounds', 'container'].forEach(function (key) { - if (typeof userConfig[key] === 'string') { - userConfig[key] = document.querySelector(userConfig[key]); - } - }); - userConfig.modules = Object.keys(userConfig.modules).reduce(function (config, name) { - if (userConfig.modules[name]) { - config[name] = userConfig.modules[name]; - } - return config; - }, {}); - return userConfig; - } - - function overload(index, length, name, value, source) { - var formats = {}; - if (typeof index.index === 'number' && typeof index.length === 'number') { - // Allow for throwaway end (used by insertText/insertEmbed) - if (typeof length !== 'number') { - source = value, value = name, name = length, length = index.length, index = index.index; - } else { - length = index.length, index = index.index; - } - } else if (typeof length !== 'number') { - source = value, value = name, name = length, length = 0; - } - // Handle format being object, two format name/value strings or excluded - if ((typeof name === 'undefined' ? 'undefined' : _typeof(name)) === 'object') { - formats = name; - source = value; - } else if (typeof name === 'string') { - if (value != null) { - formats[name] = value; - } else { - source = name; - } - } - // Handle optional source - source = source || _emitter2.default.sources.API; - return [index, length, formats, source]; - } - - function shiftRange(range, index, length, source) { - if (range == null) return null; - var start = void 0, - end = void 0; - if (index instanceof _delta2.default) { - var _map = [range.index, range.index + range.length].map(function (pos) { - return index.transformPosition(pos, source === _emitter2.default.sources.USER); - }); - - var _map2 = _slicedToArray(_map, 2); - - start = _map2[0]; - end = _map2[1]; - } else { - var _map3 = [range.index, range.index + range.length].map(function (pos) { - if (pos < index || pos === index && source !== _emitter2.default.sources.USER) return pos; - if (length >= 0) { - return pos + length; - } else { - return Math.max(index, pos + length); - } - }); - - var _map4 = _slicedToArray(_map3, 2); - - start = _map4[0]; - end = _map4[1]; - } - return new _selection.Range(start, end - start); - } - - exports.expandConfig = expandConfig; - exports.overload = overload; - exports.default = Quill; - -/***/ }, -/* 19 */ -/***/ function(module, exports) { - - 'use strict'; - - var elem = document.createElement('div'); - elem.classList.toggle('test-class', false); - if (elem.classList.contains('test-class')) { - (function () { - var _toggle = DOMTokenList.prototype.toggle; - DOMTokenList.prototype.toggle = function (token, force) { - if (arguments.length > 1 && !this.contains(token) === !force) { - return force; - } else { - return _toggle.call(this, token); - } - }; - })(); - } - - if (!String.prototype.startsWith) { - String.prototype.startsWith = function (searchString, position) { - position = position || 0; - return this.substr(position, searchString.length) === searchString; - }; - } - - if (!String.prototype.endsWith) { - String.prototype.endsWith = function (searchString, position) { - var subjectString = this.toString(); - if (typeof position !== 'number' || !isFinite(position) || Math.floor(position) !== position || position > subjectString.length) { - position = subjectString.length; - } - position -= searchString.length; - var lastIndex = subjectString.indexOf(searchString, position); - return lastIndex !== -1 && lastIndex === position; - }; - } - - if (!Array.prototype.find) { - Object.defineProperty(Array.prototype, "find", { - value: function value(predicate) { - if (this === null) { - throw new TypeError('Array.prototype.find called on null or undefined'); - } - if (typeof predicate !== 'function') { - throw new TypeError('predicate must be a function'); - } - var list = Object(this); - var length = list.length >>> 0; - var thisArg = arguments[1]; - var value; - - for (var i = 0; i < length; i++) { - value = list[i]; - if (predicate.call(thisArg, value, i, list)) { - return value; - } - } - return undefined; - } - }); - } - - // Disable resizing in Firefox - document.addEventListener("DOMContentLoaded", function () { - document.execCommand("enableObjectResizing", false, false); - }); - -/***/ }, -/* 20 */ -/***/ function(module, exports, __webpack_require__) { - - var diff = __webpack_require__(21); - var equal = __webpack_require__(22); - var extend = __webpack_require__(25); - var op = __webpack_require__(26); - - - var NULL_CHARACTER = String.fromCharCode(0); // Placeholder char for embed in diff() - - - var Delta = function (ops) { - // Assume we are given a well formed ops - if (Array.isArray(ops)) { - this.ops = ops; - } else if (ops != null && Array.isArray(ops.ops)) { - this.ops = ops.ops; - } else { - this.ops = []; - } - }; - - - Delta.prototype.insert = function (text, attributes) { - var newOp = {}; - if (text.length === 0) return this; - newOp.insert = text; - if (typeof attributes === 'object' && Object.keys(attributes).length > 0) newOp.attributes = attributes; - return this.push(newOp); - }; - - Delta.prototype['delete'] = function (length) { - if (length <= 0) return this; - return this.push({ 'delete': length }); - }; - - Delta.prototype.retain = function (length, attributes) { - if (length <= 0) return this; - var newOp = { retain: length }; - if (typeof attributes === 'object' && Object.keys(attributes).length > 0) newOp.attributes = attributes; - return this.push(newOp); - }; - - Delta.prototype.push = function (newOp) { - var index = this.ops.length; - var lastOp = this.ops[index - 1]; - newOp = extend(true, {}, newOp); - if (typeof lastOp === 'object') { - if (typeof newOp['delete'] === 'number' && typeof lastOp['delete'] === 'number') { - this.ops[index - 1] = { 'delete': lastOp['delete'] + newOp['delete'] }; - return this; - } - // Since it does not matter if we insert before or after deleting at the same index, - // always prefer to insert first - if (typeof lastOp['delete'] === 'number' && newOp.insert != null) { - index -= 1; - lastOp = this.ops[index - 1]; - if (typeof lastOp !== 'object') { - this.ops.unshift(newOp); - return this; - } - } - if (equal(newOp.attributes, lastOp.attributes)) { - if (typeof newOp.insert === 'string' && typeof lastOp.insert === 'string') { - this.ops[index - 1] = { insert: lastOp.insert + newOp.insert }; - if (typeof newOp.attributes === 'object') this.ops[index - 1].attributes = newOp.attributes - return this; - } else if (typeof newOp.retain === 'number' && typeof lastOp.retain === 'number') { - this.ops[index - 1] = { retain: lastOp.retain + newOp.retain }; - if (typeof newOp.attributes === 'object') this.ops[index - 1].attributes = newOp.attributes - return this; - } - } - } - if (index === this.ops.length) { - this.ops.push(newOp); - } else { - this.ops.splice(index, 0, newOp); - } - return this; - }; - - Delta.prototype.chop = function () { - var lastOp = this.ops[this.ops.length - 1]; - if (lastOp && lastOp.retain && !lastOp.attributes) { - this.ops.pop(); - } - return this; - }; - - Delta.prototype.length = function () { - return this.ops.reduce(function (length, elem) { - return length + op.length(elem); - }, 0); - }; - - Delta.prototype.slice = function (start, end) { - start = start || 0; - if (typeof end !== 'number') end = Infinity; - var ops = []; - var iter = op.iterator(this.ops); - var index = 0; - while (index < end && iter.hasNext()) { - var nextOp; - if (index < start) { - nextOp = iter.next(start - index); - } else { - nextOp = iter.next(end - index); - ops.push(nextOp); - } - index += op.length(nextOp); - } - return new Delta(ops); - }; - - - Delta.prototype.compose = function (other) { - var thisIter = op.iterator(this.ops); - var otherIter = op.iterator(other.ops); - var delta = new Delta(); - while (thisIter.hasNext() || otherIter.hasNext()) { - if (otherIter.peekType() === 'insert') { - delta.push(otherIter.next()); - } else if (thisIter.peekType() === 'delete') { - delta.push(thisIter.next()); - } else { - var length = Math.min(thisIter.peekLength(), otherIter.peekLength()); - var thisOp = thisIter.next(length); - var otherOp = otherIter.next(length); - if (typeof otherOp.retain === 'number') { - var newOp = {}; - if (typeof thisOp.retain === 'number') { - newOp.retain = length; - } else { - newOp.insert = thisOp.insert; - } - // Preserve null when composing with a retain, otherwise remove it for inserts - var attributes = op.attributes.compose(thisOp.attributes, otherOp.attributes, typeof thisOp.retain === 'number'); - if (attributes) newOp.attributes = attributes; - delta.push(newOp); - // Other op should be delete, we could be an insert or retain - // Insert + delete cancels out - } else if (typeof otherOp['delete'] === 'number' && typeof thisOp.retain === 'number') { - delta.push(otherOp); - } - } - } - return delta.chop(); - }; - - Delta.prototype.concat = function (other) { - var delta = new Delta(this.ops.slice()); - if (other.ops.length > 0) { - delta.push(other.ops[0]); - delta.ops = delta.ops.concat(other.ops.slice(1)); - } - return delta; - }; - - Delta.prototype.diff = function (other) { - var delta = new Delta(); - if (this.ops === other.ops) { - return delta; - } - var strings = [this.ops, other.ops].map(function (ops) { - return ops.map(function (op) { - if (op.insert != null) { - return typeof op.insert === 'string' ? op.insert : NULL_CHARACTER; - } - var prep = (ops === other.ops) ? 'on' : 'with'; - throw new Error('diff() called ' + prep + ' non-document'); - }).join(''); - }); - var diffResult = diff(strings[0], strings[1]); - var thisIter = op.iterator(this.ops); - var otherIter = op.iterator(other.ops); - diffResult.forEach(function (component) { - var length = component[1].length; - while (length > 0) { - var opLength = 0; - switch (component[0]) { - case diff.INSERT: - opLength = Math.min(otherIter.peekLength(), length); - delta.push(otherIter.next(opLength)); - break; - case diff.DELETE: - opLength = Math.min(length, thisIter.peekLength()); - thisIter.next(opLength); - delta['delete'](opLength); - break; - case diff.EQUAL: - opLength = Math.min(thisIter.peekLength(), otherIter.peekLength(), length); - var thisOp = thisIter.next(opLength); - var otherOp = otherIter.next(opLength); - if (equal(thisOp.insert, otherOp.insert)) { - delta.retain(opLength, op.attributes.diff(thisOp.attributes, otherOp.attributes)); - } else { - delta.push(otherOp)['delete'](opLength); - } - break; - } - length -= opLength; - } - }); - return delta.chop(); - }; - - Delta.prototype.transform = function (other, priority) { - priority = !!priority; - if (typeof other === 'number') { - return this.transformPosition(other, priority); - } - var thisIter = op.iterator(this.ops); - var otherIter = op.iterator(other.ops); - var delta = new Delta(); - while (thisIter.hasNext() || otherIter.hasNext()) { - if (thisIter.peekType() === 'insert' && (priority || otherIter.peekType() !== 'insert')) { - delta.retain(op.length(thisIter.next())); - } else if (otherIter.peekType() === 'insert') { - delta.push(otherIter.next()); - } else { - var length = Math.min(thisIter.peekLength(), otherIter.peekLength()); - var thisOp = thisIter.next(length); - var otherOp = otherIter.next(length); - if (thisOp['delete']) { - // Our delete either makes their delete redundant or removes their retain - continue; - } else if (otherOp['delete']) { - delta.push(otherOp); - } else { - // We retain either their retain or insert - delta.retain(length, op.attributes.transform(thisOp.attributes, otherOp.attributes, priority)); - } - } - } - return delta.chop(); - }; - - Delta.prototype.transformPosition = function (index, priority) { - priority = !!priority; - var thisIter = op.iterator(this.ops); - var offset = 0; - while (thisIter.hasNext() && offset <= index) { - var length = thisIter.peekLength(); - var nextType = thisIter.peekType(); - thisIter.next(); - if (nextType === 'delete') { - index -= Math.min(length, index - offset); - continue; - } else if (nextType === 'insert' && (offset < index || !priority)) { - index += length; - } - offset += length; - } - return index; - }; - - - module.exports = Delta; - - -/***/ }, -/* 21 */ -/***/ function(module, exports) { - - /** - * This library modifies the diff-patch-match library by Neil Fraser - * by removing the patch and match functionality and certain advanced - * options in the diff function. The original license is as follows: - * - * === - * - * Diff Match and Patch - * - * Copyright 2006 Google Inc. - * http://code.google.com/p/google-diff-match-patch/ - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - - - /** - * The data structure representing a diff is an array of tuples: - * [[DIFF_DELETE, 'Hello'], [DIFF_INSERT, 'Goodbye'], [DIFF_EQUAL, ' world.']] - * which means: delete 'Hello', add 'Goodbye' and keep ' world.' - */ - var DIFF_DELETE = -1; - var DIFF_INSERT = 1; - var DIFF_EQUAL = 0; - - - /** - * Find the differences between two texts. Simplifies the problem by stripping - * any common prefix or suffix off the texts before diffing. - * @param {string} text1 Old string to be diffed. - * @param {string} text2 New string to be diffed. - * @return {Array} Array of diff tuples. - */ - function diff_main(text1, text2) { - // Check for equality (speedup). - if (text1 == text2) { - if (text1) { - return [[DIFF_EQUAL, text1]]; - } - return []; - } - - // Trim off common prefix (speedup). - var commonlength = diff_commonPrefix(text1, text2); - var commonprefix = text1.substring(0, commonlength); - text1 = text1.substring(commonlength); - text2 = text2.substring(commonlength); - - // Trim off common suffix (speedup). - commonlength = diff_commonSuffix(text1, text2); - var commonsuffix = text1.substring(text1.length - commonlength); - text1 = text1.substring(0, text1.length - commonlength); - text2 = text2.substring(0, text2.length - commonlength); - - // Compute the diff on the middle block. - var diffs = diff_compute_(text1, text2); - - // Restore the prefix and suffix. - if (commonprefix) { - diffs.unshift([DIFF_EQUAL, commonprefix]); - } - if (commonsuffix) { - diffs.push([DIFF_EQUAL, commonsuffix]); - } - diff_cleanupMerge(diffs); - return diffs; - }; - - - /** - * Find the differences between two texts. Assumes that the texts do not - * have any common prefix or suffix. - * @param {string} text1 Old string to be diffed. - * @param {string} text2 New string to be diffed. - * @return {Array} Array of diff tuples. - */ - function diff_compute_(text1, text2) { - var diffs; - - if (!text1) { - // Just add some text (speedup). - return [[DIFF_INSERT, text2]]; - } - - if (!text2) { - // Just delete some text (speedup). - return [[DIFF_DELETE, text1]]; - } - - var longtext = text1.length > text2.length ? text1 : text2; - var shorttext = text1.length > text2.length ? text2 : text1; - var i = longtext.indexOf(shorttext); - if (i != -1) { - // Shorter text is inside the longer text (speedup). - diffs = [[DIFF_INSERT, longtext.substring(0, i)], - [DIFF_EQUAL, shorttext], - [DIFF_INSERT, longtext.substring(i + shorttext.length)]]; - // Swap insertions for deletions if diff is reversed. - if (text1.length > text2.length) { - diffs[0][0] = diffs[2][0] = DIFF_DELETE; - } - return diffs; - } - - if (shorttext.length == 1) { - // Single character string. - // After the previous speedup, the character can't be an equality. - return [[DIFF_DELETE, text1], [DIFF_INSERT, text2]]; - } - - // Check to see if the problem can be split in two. - var hm = diff_halfMatch_(text1, text2); - if (hm) { - // A half-match was found, sort out the return data. - var text1_a = hm[0]; - var text1_b = hm[1]; - var text2_a = hm[2]; - var text2_b = hm[3]; - var mid_common = hm[4]; - // Send both pairs off for separate processing. - var diffs_a = diff_main(text1_a, text2_a); - var diffs_b = diff_main(text1_b, text2_b); - // Merge the results. - return diffs_a.concat([[DIFF_EQUAL, mid_common]], diffs_b); - } - - return diff_bisect_(text1, text2); - }; - - - /** - * Find the 'middle snake' of a diff, split the problem in two - * and return the recursively constructed diff. - * See Myers 1986 paper: An O(ND) Difference Algorithm and Its Variations. - * @param {string} text1 Old string to be diffed. - * @param {string} text2 New string to be diffed. - * @return {Array} Array of diff tuples. - * @private - */ - function diff_bisect_(text1, text2) { - // Cache the text lengths to prevent multiple calls. - var text1_length = text1.length; - var text2_length = text2.length; - var max_d = Math.ceil((text1_length + text2_length) / 2); - var v_offset = max_d; - var v_length = 2 * max_d; - var v1 = new Array(v_length); - var v2 = new Array(v_length); - // Setting all elements to -1 is faster in Chrome & Firefox than mixing - // integers and undefined. - for (var x = 0; x < v_length; x++) { - v1[x] = -1; - v2[x] = -1; - } - v1[v_offset + 1] = 0; - v2[v_offset + 1] = 0; - var delta = text1_length - text2_length; - // If the total number of characters is odd, then the front path will collide - // with the reverse path. - var front = (delta % 2 != 0); - // Offsets for start and end of k loop. - // Prevents mapping of space beyond the grid. - var k1start = 0; - var k1end = 0; - var k2start = 0; - var k2end = 0; - for (var d = 0; d < max_d; d++) { - // Walk the front path one step. - for (var k1 = -d + k1start; k1 <= d - k1end; k1 += 2) { - var k1_offset = v_offset + k1; - var x1; - if (k1 == -d || (k1 != d && v1[k1_offset - 1] < v1[k1_offset + 1])) { - x1 = v1[k1_offset + 1]; - } else { - x1 = v1[k1_offset - 1] + 1; - } - var y1 = x1 - k1; - while (x1 < text1_length && y1 < text2_length && - text1.charAt(x1) == text2.charAt(y1)) { - x1++; - y1++; - } - v1[k1_offset] = x1; - if (x1 > text1_length) { - // Ran off the right of the graph. - k1end += 2; - } else if (y1 > text2_length) { - // Ran off the bottom of the graph. - k1start += 2; - } else if (front) { - var k2_offset = v_offset + delta - k1; - if (k2_offset >= 0 && k2_offset < v_length && v2[k2_offset] != -1) { - // Mirror x2 onto top-left coordinate system. - var x2 = text1_length - v2[k2_offset]; - if (x1 >= x2) { - // Overlap detected. - return diff_bisectSplit_(text1, text2, x1, y1); - } - } - } - } - - // Walk the reverse path one step. - for (var k2 = -d + k2start; k2 <= d - k2end; k2 += 2) { - var k2_offset = v_offset + k2; - var x2; - if (k2 == -d || (k2 != d && v2[k2_offset - 1] < v2[k2_offset + 1])) { - x2 = v2[k2_offset + 1]; - } else { - x2 = v2[k2_offset - 1] + 1; - } - var y2 = x2 - k2; - while (x2 < text1_length && y2 < text2_length && - text1.charAt(text1_length - x2 - 1) == - text2.charAt(text2_length - y2 - 1)) { - x2++; - y2++; - } - v2[k2_offset] = x2; - if (x2 > text1_length) { - // Ran off the left of the graph. - k2end += 2; - } else if (y2 > text2_length) { - // Ran off the top of the graph. - k2start += 2; - } else if (!front) { - var k1_offset = v_offset + delta - k2; - if (k1_offset >= 0 && k1_offset < v_length && v1[k1_offset] != -1) { - var x1 = v1[k1_offset]; - var y1 = v_offset + x1 - k1_offset; - // Mirror x2 onto top-left coordinate system. - x2 = text1_length - x2; - if (x1 >= x2) { - // Overlap detected. - return diff_bisectSplit_(text1, text2, x1, y1); - } - } - } - } - } - // Diff took too long and hit the deadline or - // number of diffs equals number of characters, no commonality at all. - return [[DIFF_DELETE, text1], [DIFF_INSERT, text2]]; - }; - - - /** - * Given the location of the 'middle snake', split the diff in two parts - * and recurse. - * @param {string} text1 Old string to be diffed. - * @param {string} text2 New string to be diffed. - * @param {number} x Index of split point in text1. - * @param {number} y Index of split point in text2. - * @return {Array} Array of diff tuples. - */ - function diff_bisectSplit_(text1, text2, x, y) { - var text1a = text1.substring(0, x); - var text2a = text2.substring(0, y); - var text1b = text1.substring(x); - var text2b = text2.substring(y); - - // Compute both diffs serially. - var diffs = diff_main(text1a, text2a); - var diffsb = diff_main(text1b, text2b); - - return diffs.concat(diffsb); - }; - - - /** - * Determine the common prefix of two strings. - * @param {string} text1 First string. - * @param {string} text2 Second string. - * @return {number} The number of characters common to the start of each - * string. - */ - function diff_commonPrefix(text1, text2) { - // Quick check for common null cases. - if (!text1 || !text2 || text1.charAt(0) != text2.charAt(0)) { - return 0; - } - // Binary search. - // Performance analysis: http://neil.fraser.name/news/2007/10/09/ - var pointermin = 0; - var pointermax = Math.min(text1.length, text2.length); - var pointermid = pointermax; - var pointerstart = 0; - while (pointermin < pointermid) { - if (text1.substring(pointerstart, pointermid) == - text2.substring(pointerstart, pointermid)) { - pointermin = pointermid; - pointerstart = pointermin; - } else { - pointermax = pointermid; - } - pointermid = Math.floor((pointermax - pointermin) / 2 + pointermin); - } - return pointermid; - }; - - - /** - * Determine the common suffix of two strings. - * @param {string} text1 First string. - * @param {string} text2 Second string. - * @return {number} The number of characters common to the end of each string. - */ - function diff_commonSuffix(text1, text2) { - // Quick check for common null cases. - if (!text1 || !text2 || - text1.charAt(text1.length - 1) != text2.charAt(text2.length - 1)) { - return 0; - } - // Binary search. - // Performance analysis: http://neil.fraser.name/news/2007/10/09/ - var pointermin = 0; - var pointermax = Math.min(text1.length, text2.length); - var pointermid = pointermax; - var pointerend = 0; - while (pointermin < pointermid) { - if (text1.substring(text1.length - pointermid, text1.length - pointerend) == - text2.substring(text2.length - pointermid, text2.length - pointerend)) { - pointermin = pointermid; - pointerend = pointermin; - } else { - pointermax = pointermid; - } - pointermid = Math.floor((pointermax - pointermin) / 2 + pointermin); - } - return pointermid; - }; - - - /** - * Do the two texts share a substring which is at least half the length of the - * longer text? - * This speedup can produce non-minimal diffs. - * @param {string} text1 First string. - * @param {string} text2 Second string. - * @return {Array.} Five element Array, containing the prefix of - * text1, the suffix of text1, the prefix of text2, the suffix of - * text2 and the common middle. Or null if there was no match. - */ - function diff_halfMatch_(text1, text2) { - var longtext = text1.length > text2.length ? text1 : text2; - var shorttext = text1.length > text2.length ? text2 : text1; - if (longtext.length < 4 || shorttext.length * 2 < longtext.length) { - return null; // Pointless. - } - - /** - * Does a substring of shorttext exist within longtext such that the substring - * is at least half the length of longtext? - * Closure, but does not reference any external variables. - * @param {string} longtext Longer string. - * @param {string} shorttext Shorter string. - * @param {number} i Start index of quarter length substring within longtext. - * @return {Array.} Five element Array, containing the prefix of - * longtext, the suffix of longtext, the prefix of shorttext, the suffix - * of shorttext and the common middle. Or null if there was no match. - * @private - */ - function diff_halfMatchI_(longtext, shorttext, i) { - // Start with a 1/4 length substring at position i as a seed. - var seed = longtext.substring(i, i + Math.floor(longtext.length / 4)); - var j = -1; - var best_common = ''; - var best_longtext_a, best_longtext_b, best_shorttext_a, best_shorttext_b; - while ((j = shorttext.indexOf(seed, j + 1)) != -1) { - var prefixLength = diff_commonPrefix(longtext.substring(i), - shorttext.substring(j)); - var suffixLength = diff_commonSuffix(longtext.substring(0, i), - shorttext.substring(0, j)); - if (best_common.length < suffixLength + prefixLength) { - best_common = shorttext.substring(j - suffixLength, j) + - shorttext.substring(j, j + prefixLength); - best_longtext_a = longtext.substring(0, i - suffixLength); - best_longtext_b = longtext.substring(i + prefixLength); - best_shorttext_a = shorttext.substring(0, j - suffixLength); - best_shorttext_b = shorttext.substring(j + prefixLength); - } - } - if (best_common.length * 2 >= longtext.length) { - return [best_longtext_a, best_longtext_b, - best_shorttext_a, best_shorttext_b, best_common]; - } else { - return null; - } - } - - // First check if the second quarter is the seed for a half-match. - var hm1 = diff_halfMatchI_(longtext, shorttext, - Math.ceil(longtext.length / 4)); - // Check again based on the third quarter. - var hm2 = diff_halfMatchI_(longtext, shorttext, - Math.ceil(longtext.length / 2)); - var hm; - if (!hm1 && !hm2) { - return null; - } else if (!hm2) { - hm = hm1; - } else if (!hm1) { - hm = hm2; - } else { - // Both matched. Select the longest. - hm = hm1[4].length > hm2[4].length ? hm1 : hm2; - } - - // A half-match was found, sort out the return data. - var text1_a, text1_b, text2_a, text2_b; - if (text1.length > text2.length) { - text1_a = hm[0]; - text1_b = hm[1]; - text2_a = hm[2]; - text2_b = hm[3]; - } else { - text2_a = hm[0]; - text2_b = hm[1]; - text1_a = hm[2]; - text1_b = hm[3]; - } - var mid_common = hm[4]; - return [text1_a, text1_b, text2_a, text2_b, mid_common]; - }; - - - /** - * Reorder and merge like edit sections. Merge equalities. - * Any edit section can move as long as it doesn't cross an equality. - * @param {Array} diffs Array of diff tuples. - */ - function diff_cleanupMerge(diffs) { - diffs.push([DIFF_EQUAL, '']); // Add a dummy entry at the end. - var pointer = 0; - var count_delete = 0; - var count_insert = 0; - var text_delete = ''; - var text_insert = ''; - var commonlength; - while (pointer < diffs.length) { - switch (diffs[pointer][0]) { - case DIFF_INSERT: - count_insert++; - text_insert += diffs[pointer][1]; - pointer++; - break; - case DIFF_DELETE: - count_delete++; - text_delete += diffs[pointer][1]; - pointer++; - break; - case DIFF_EQUAL: - // Upon reaching an equality, check for prior redundancies. - if (count_delete + count_insert > 1) { - if (count_delete !== 0 && count_insert !== 0) { - // Factor out any common prefixies. - commonlength = diff_commonPrefix(text_insert, text_delete); - if (commonlength !== 0) { - if ((pointer - count_delete - count_insert) > 0 && - diffs[pointer - count_delete - count_insert - 1][0] == - DIFF_EQUAL) { - diffs[pointer - count_delete - count_insert - 1][1] += - text_insert.substring(0, commonlength); - } else { - diffs.splice(0, 0, [DIFF_EQUAL, - text_insert.substring(0, commonlength)]); - pointer++; - } - text_insert = text_insert.substring(commonlength); - text_delete = text_delete.substring(commonlength); - } - // Factor out any common suffixies. - commonlength = diff_commonSuffix(text_insert, text_delete); - if (commonlength !== 0) { - diffs[pointer][1] = text_insert.substring(text_insert.length - - commonlength) + diffs[pointer][1]; - text_insert = text_insert.substring(0, text_insert.length - - commonlength); - text_delete = text_delete.substring(0, text_delete.length - - commonlength); - } - } - // Delete the offending records and add the merged ones. - if (count_delete === 0) { - diffs.splice(pointer - count_insert, - count_delete + count_insert, [DIFF_INSERT, text_insert]); - } else if (count_insert === 0) { - diffs.splice(pointer - count_delete, - count_delete + count_insert, [DIFF_DELETE, text_delete]); - } else { - diffs.splice(pointer - count_delete - count_insert, - count_delete + count_insert, [DIFF_DELETE, text_delete], - [DIFF_INSERT, text_insert]); - } - pointer = pointer - count_delete - count_insert + - (count_delete ? 1 : 0) + (count_insert ? 1 : 0) + 1; - } else if (pointer !== 0 && diffs[pointer - 1][0] == DIFF_EQUAL) { - // Merge this equality with the previous one. - diffs[pointer - 1][1] += diffs[pointer][1]; - diffs.splice(pointer, 1); - } else { - pointer++; - } - count_insert = 0; - count_delete = 0; - text_delete = ''; - text_insert = ''; - break; - } - } - if (diffs[diffs.length - 1][1] === '') { - diffs.pop(); // Remove the dummy entry at the end. - } - - // Second pass: look for single edits surrounded on both sides by equalities - // which can be shifted sideways to eliminate an equality. - // e.g: ABAC -> ABAC - var changes = false; - pointer = 1; - // Intentionally ignore the first and last element (don't need checking). - while (pointer < diffs.length - 1) { - if (diffs[pointer - 1][0] == DIFF_EQUAL && - diffs[pointer + 1][0] == DIFF_EQUAL) { - // This is a single edit surrounded by equalities. - if (diffs[pointer][1].substring(diffs[pointer][1].length - - diffs[pointer - 1][1].length) == diffs[pointer - 1][1]) { - // Shift the edit over the previous equality. - diffs[pointer][1] = diffs[pointer - 1][1] + - diffs[pointer][1].substring(0, diffs[pointer][1].length - - diffs[pointer - 1][1].length); - diffs[pointer + 1][1] = diffs[pointer - 1][1] + diffs[pointer + 1][1]; - diffs.splice(pointer - 1, 1); - changes = true; - } else if (diffs[pointer][1].substring(0, diffs[pointer + 1][1].length) == - diffs[pointer + 1][1]) { - // Shift the edit over the next equality. - diffs[pointer - 1][1] += diffs[pointer + 1][1]; - diffs[pointer][1] = - diffs[pointer][1].substring(diffs[pointer + 1][1].length) + - diffs[pointer + 1][1]; - diffs.splice(pointer + 1, 1); - changes = true; - } - } - pointer++; - } - // If shifts were made, the diff needs reordering and another shift sweep. - if (changes) { - diff_cleanupMerge(diffs); - } - }; - - - var diff = diff_main; - diff.INSERT = DIFF_INSERT; - diff.DELETE = DIFF_DELETE; - diff.EQUAL = DIFF_EQUAL; - - - module.exports = diff; - - -/***/ }, -/* 22 */ -/***/ function(module, exports, __webpack_require__) { - - var pSlice = Array.prototype.slice; - var objectKeys = __webpack_require__(23); - var isArguments = __webpack_require__(24); - - var deepEqual = module.exports = function (actual, expected, opts) { - if (!opts) opts = {}; - // 7.1. All identical values are equivalent, as determined by ===. - if (actual === expected) { - return true; - - } else if (actual instanceof Date && expected instanceof Date) { - return actual.getTime() === expected.getTime(); - - // 7.3. Other pairs that do not both pass typeof value == 'object', - // equivalence is determined by ==. - } else if (!actual || !expected || typeof actual != 'object' && typeof expected != 'object') { - return opts.strict ? actual === expected : actual == expected; - - // 7.4. For all other Object pairs, including Array objects, equivalence is - // determined by having the same number of owned properties (as verified - // with Object.prototype.hasOwnProperty.call), the same set of keys - // (although not necessarily the same order), equivalent values for every - // corresponding key, and an identical 'prototype' property. Note: this - // accounts for both named and indexed properties on Arrays. - } else { - return objEquiv(actual, expected, opts); - } - } - - function isUndefinedOrNull(value) { - return value === null || value === undefined; - } - - function isBuffer (x) { - if (!x || typeof x !== 'object' || typeof x.length !== 'number') return false; - if (typeof x.copy !== 'function' || typeof x.slice !== 'function') { - return false; - } - if (x.length > 0 && typeof x[0] !== 'number') return false; - return true; - } - - function objEquiv(a, b, opts) { - var i, key; - if (isUndefinedOrNull(a) || isUndefinedOrNull(b)) - return false; - // an identical 'prototype' property. - if (a.prototype !== b.prototype) return false; - //~~~I've managed to break Object.keys through screwy arguments passing. - // Converting to array solves the problem. - if (isArguments(a)) { - if (!isArguments(b)) { - return false; - } - a = pSlice.call(a); - b = pSlice.call(b); - return deepEqual(a, b, opts); - } - if (isBuffer(a)) { - if (!isBuffer(b)) { - return false; - } - if (a.length !== b.length) return false; - for (i = 0; i < a.length; i++) { - if (a[i] !== b[i]) return false; - } - return true; - } - try { - var ka = objectKeys(a), - kb = objectKeys(b); - } catch (e) {//happens when one is a string literal and the other isn't - return false; - } - // having the same number of owned properties (keys incorporates - // hasOwnProperty) - if (ka.length != kb.length) - return false; - //the same set of keys (although not necessarily the same order), - ka.sort(); - kb.sort(); - //~~~cheap key test - for (i = ka.length - 1; i >= 0; i--) { - if (ka[i] != kb[i]) - return false; - } - //equivalent values for every corresponding key, and - //~~~possibly expensive deep test - for (i = ka.length - 1; i >= 0; i--) { - key = ka[i]; - if (!deepEqual(a[key], b[key], opts)) return false; - } - return typeof a === typeof b; - } - - -/***/ }, -/* 23 */ -/***/ function(module, exports) { - - exports = module.exports = typeof Object.keys === 'function' - ? Object.keys : shim; - - exports.shim = shim; - function shim (obj) { - var keys = []; - for (var key in obj) keys.push(key); - return keys; - } - - -/***/ }, -/* 24 */ -/***/ function(module, exports) { - - var supportsArgumentsClass = (function(){ - return Object.prototype.toString.call(arguments) - })() == '[object Arguments]'; - - exports = module.exports = supportsArgumentsClass ? supported : unsupported; - - exports.supported = supported; - function supported(object) { - return Object.prototype.toString.call(object) == '[object Arguments]'; - }; - - exports.unsupported = unsupported; - function unsupported(object){ - return object && - typeof object == 'object' && - typeof object.length == 'number' && - Object.prototype.hasOwnProperty.call(object, 'callee') && - !Object.prototype.propertyIsEnumerable.call(object, 'callee') || - false; - }; - - -/***/ }, -/* 25 */ -/***/ function(module, exports) { - - 'use strict'; - - var hasOwn = Object.prototype.hasOwnProperty; - var toStr = Object.prototype.toString; - - var isArray = function isArray(arr) { - if (typeof Array.isArray === 'function') { - return Array.isArray(arr); - } - - return toStr.call(arr) === '[object Array]'; - }; - - var isPlainObject = function isPlainObject(obj) { - if (!obj || toStr.call(obj) !== '[object Object]') { - return false; - } - - var hasOwnConstructor = hasOwn.call(obj, 'constructor'); - var hasIsPrototypeOf = obj.constructor && obj.constructor.prototype && hasOwn.call(obj.constructor.prototype, 'isPrototypeOf'); - // Not own constructor property must be Object - if (obj.constructor && !hasOwnConstructor && !hasIsPrototypeOf) { - return false; - } - - // Own properties are enumerated firstly, so to speed up, - // if last one is own, then all properties are own. - var key; - for (key in obj) {/**/} - - return typeof key === 'undefined' || hasOwn.call(obj, key); - }; - - module.exports = function extend() { - var options, name, src, copy, copyIsArray, clone, - target = arguments[0], - i = 1, - length = arguments.length, - deep = false; - - // Handle a deep copy situation - if (typeof target === 'boolean') { - deep = target; - target = arguments[1] || {}; - // skip the boolean and the target - i = 2; - } else if ((typeof target !== 'object' && typeof target !== 'function') || target == null) { - target = {}; - } - - for (; i < length; ++i) { - options = arguments[i]; - // Only deal with non-null/undefined values - if (options != null) { - // Extend the base object - for (name in options) { - src = target[name]; - copy = options[name]; - - // Prevent never-ending loop - if (target !== copy) { - // Recurse if we're merging plain objects or arrays - if (deep && copy && (isPlainObject(copy) || (copyIsArray = isArray(copy)))) { - if (copyIsArray) { - copyIsArray = false; - clone = src && isArray(src) ? src : []; - } else { - clone = src && isPlainObject(src) ? src : {}; - } - - // Never move original objects, clone them - target[name] = extend(deep, clone, copy); - - // Don't bring in undefined values - } else if (typeof copy !== 'undefined') { - target[name] = copy; - } - } - } - } - } - - // Return the modified object - return target; - }; - - - -/***/ }, -/* 26 */ -/***/ function(module, exports, __webpack_require__) { - - var equal = __webpack_require__(22); - var extend = __webpack_require__(25); - - - var lib = { - attributes: { - compose: function (a, b, keepNull) { - if (typeof a !== 'object') a = {}; - if (typeof b !== 'object') b = {}; - var attributes = extend(true, {}, b); - if (!keepNull) { - attributes = Object.keys(attributes).reduce(function (copy, key) { - if (attributes[key] != null) { - copy[key] = attributes[key]; - } - return copy; - }, {}); - } - for (var key in a) { - if (a[key] !== undefined && b[key] === undefined) { - attributes[key] = a[key]; - } - } - return Object.keys(attributes).length > 0 ? attributes : undefined; - }, - - diff: function(a, b) { - if (typeof a !== 'object') a = {}; - if (typeof b !== 'object') b = {}; - var attributes = Object.keys(a).concat(Object.keys(b)).reduce(function (attributes, key) { - if (!equal(a[key], b[key])) { - attributes[key] = b[key] === undefined ? null : b[key]; - } - return attributes; - }, {}); - return Object.keys(attributes).length > 0 ? attributes : undefined; - }, - - transform: function (a, b, priority) { - if (typeof a !== 'object') return b; - if (typeof b !== 'object') return undefined; - if (!priority) return b; // b simply overwrites us without priority - var attributes = Object.keys(b).reduce(function (attributes, key) { - if (a[key] === undefined) attributes[key] = b[key]; // null is a valid value - return attributes; - }, {}); - return Object.keys(attributes).length > 0 ? attributes : undefined; - } - }, - - iterator: function (ops) { - return new Iterator(ops); - }, - - length: function (op) { - if (typeof op['delete'] === 'number') { - return op['delete']; - } else if (typeof op.retain === 'number') { - return op.retain; - } else { - return typeof op.insert === 'string' ? op.insert.length : 1; - } - } - }; - - - function Iterator(ops) { - this.ops = ops; - this.index = 0; - this.offset = 0; - }; - - Iterator.prototype.hasNext = function () { - return this.peekLength() < Infinity; - }; - - Iterator.prototype.next = function (length) { - if (!length) length = Infinity; - var nextOp = this.ops[this.index]; - if (nextOp) { - var offset = this.offset; - var opLength = lib.length(nextOp) - if (length >= opLength - offset) { - length = opLength - offset; - this.index += 1; - this.offset = 0; - } else { - this.offset += length; - } - if (typeof nextOp['delete'] === 'number') { - return { 'delete': length }; - } else { - var retOp = {}; - if (nextOp.attributes) { - retOp.attributes = nextOp.attributes; - } - if (typeof nextOp.retain === 'number') { - retOp.retain = length; - } else if (typeof nextOp.insert === 'string') { - retOp.insert = nextOp.insert.substr(offset, length); - } else { - // offset should === 0, length should === 1 - retOp.insert = nextOp.insert; - } - return retOp; - } - } else { - return { retain: Infinity }; - } - }; - - Iterator.prototype.peekLength = function () { - if (this.ops[this.index]) { - // Should never return 0 if our index is being managed correctly - return lib.length(this.ops[this.index]) - this.offset; - } else { - return Infinity; - } - }; - - Iterator.prototype.peekType = function () { - if (this.ops[this.index]) { - if (typeof this.ops[this.index]['delete'] === 'number') { - return 'delete'; - } else if (typeof this.ops[this.index].retain === 'number') { - return 'retain'; - } else { - return 'insert'; - } - } - return 'retain'; - }; - - - module.exports = lib; - - -/***/ }, -/* 27 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - Object.defineProperty(exports, "__esModule", { - value: true - }); - - var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; - - var _slicedToArray = function () { function sliceIterator(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"]) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } return function (arr, i) { if (Array.isArray(arr)) { return arr; } else if (Symbol.iterator in Object(arr)) { return sliceIterator(arr, i); } else { throw new TypeError("Invalid attempt to destructure non-iterable instance"); } }; }(); - - var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); - - var _delta = __webpack_require__(20); - - var _delta2 = _interopRequireDefault(_delta); - - var _op = __webpack_require__(26); - - var _op2 = _interopRequireDefault(_op); - - var _emitter3 = __webpack_require__(28); - - var _emitter4 = _interopRequireDefault(_emitter3); - - var _parchment = __webpack_require__(2); - - var _parchment2 = _interopRequireDefault(_parchment); - - var _code = __webpack_require__(31); - - var _code2 = _interopRequireDefault(_code); - - var _cursor = __webpack_require__(37); - - var _cursor2 = _interopRequireDefault(_cursor); - - var _block = __webpack_require__(32); - - var _block2 = _interopRequireDefault(_block); - - var _clone = __webpack_require__(38); - - var _clone2 = _interopRequireDefault(_clone); - - var _deepEqual = __webpack_require__(22); - - var _deepEqual2 = _interopRequireDefault(_deepEqual); - - var _extend = __webpack_require__(25); - - var _extend2 = _interopRequireDefault(_extend); - - function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - - function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } - - function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } - - var Editor = function () { - function Editor(scroll, emitter) { - _classCallCheck(this, Editor); - - this.scroll = scroll; - this.emitter = emitter; - this.emitter.on(_emitter4.default.events.SCROLL_UPDATE, this.update.bind(this, null)); - this.delta = this.getDelta(); - this.enable(); - } - - _createClass(Editor, [{ - key: 'applyDelta', - value: function applyDelta(delta) { - var _this = this; - - var source = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : _emitter4.default.sources.API; - - var consumeNextNewline = false; - this.scroll.update(); - var scrollLength = this.scroll.length(); - this.scroll.batch = true; - delta = normalizeDelta(delta); - delta.ops.reduce(function (index, op) { - var length = op.retain || op.delete || op.insert.length || 1; - var attributes = op.attributes || {}; - if (op.insert != null) { - if (typeof op.insert === 'string') { - var text = op.insert; - if (text.endsWith('\n') && consumeNextNewline) { - consumeNextNewline = false; - text = text.slice(0, -1); - } - if (index >= scrollLength && !text.endsWith('\n')) { - consumeNextNewline = true; - } - _this.scroll.insertAt(index, text); - - var _scroll$line = _this.scroll.line(index); - - var _scroll$line2 = _slicedToArray(_scroll$line, 2); - - var line = _scroll$line2[0]; - var offset = _scroll$line2[1]; - - var formats = (0, _extend2.default)({}, (0, _block.bubbleFormats)(line)); - if (line instanceof _block2.default) { - var _line$descendant = line.descendant(_parchment2.default.Leaf, offset); - - var _line$descendant2 = _slicedToArray(_line$descendant, 1); - - var leaf = _line$descendant2[0]; - - formats = (0, _extend2.default)(formats, (0, _block.bubbleFormats)(leaf)); - } - attributes = _op2.default.attributes.diff(formats, attributes) || {}; - } else if (_typeof(op.insert) === 'object') { - var key = Object.keys(op.insert)[0]; // There should only be one key - if (key == null) return index; - _this.scroll.insertAt(index, key, op.insert[key]); - } - scrollLength += length; - } - Object.keys(attributes).forEach(function (name) { - _this.scroll.formatAt(index, length, name, attributes[name]); - }); - return index + length; - }, 0); - delta.ops.reduce(function (index, op) { - if (typeof op.delete === 'number') { - _this.scroll.deleteAt(index, op.delete); - return index; - } - return index + (op.retain || op.insert.length || 1); - }, 0); - this.scroll.batch = false; - this.scroll.optimize(); - return this.update(delta, source); - } - }, { - key: 'deleteText', - value: function deleteText(index, length) { - var source = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : _emitter4.default.sources.API; - - this.scroll.deleteAt(index, length); - return this.update(new _delta2.default().retain(index).delete(length), source); - } - }, { - key: 'enable', - value: function enable() { - var enabled = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true; - - this.scroll.domNode.setAttribute('contenteditable', enabled); - } - }, { - key: 'formatLine', - value: function formatLine(index, length) { - var _this2 = this; - - var formats = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {}; - var source = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : _emitter4.default.sources.API; - - this.scroll.update(); - Object.keys(formats).forEach(function (format) { - var lines = _this2.scroll.lines(index, Math.max(length, 1)); - var lengthRemaining = length; - lines.forEach(function (line, i) { - var lineLength = line.length(); - if (!(line instanceof _code2.default)) { - line.format(format, formats[format]); - } else { - var codeIndex = index - line.offset(_this2.scroll); - var codeLength = line.newlineIndex(codeIndex + lengthRemaining) - codeIndex + 1; - line.formatAt(codeIndex, codeLength, format, formats[format]); - } - lengthRemaining -= lineLength; - }); - }); - this.scroll.optimize(); - return this.update(new _delta2.default().retain(index).retain(length, (0, _clone2.default)(formats)), source); - } - }, { - key: 'formatText', - value: function formatText(index, length) { - var _this3 = this; - - var formats = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {}; - var source = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : _emitter4.default.sources.API; - - Object.keys(formats).forEach(function (format) { - _this3.scroll.formatAt(index, length, format, formats[format]); - }); - return this.update(new _delta2.default().retain(index).retain(length, (0, _clone2.default)(formats)), source); - } - }, { - key: 'getContents', - value: function getContents(index, length) { - return this.delta.slice(index, index + length); - } - }, { - key: 'getDelta', - value: function getDelta() { - return this.scroll.lines().reduce(function (delta, line) { - return delta.concat(line.delta()); - }, new _delta2.default()); - } - }, { - key: 'getFormat', - value: function getFormat(index) { - var length = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0; - - var lines = [], - leaves = []; - if (length === 0) { - this.scroll.path(index).forEach(function (path) { - var _path = _slicedToArray(path, 1); - - var blot = _path[0]; - - if (blot instanceof _block2.default) { - lines.push(blot); - } else if (blot instanceof _parchment2.default.Leaf) { - leaves.push(blot); - } - }); - } else { - lines = this.scroll.lines(index, length); - leaves = this.scroll.descendants(_parchment2.default.Leaf, index, length); - } - var formatsArr = [lines, leaves].map(function (blots) { - if (blots.length === 0) return {}; - var formats = (0, _block.bubbleFormats)(blots.shift()); - while (Object.keys(formats).length > 0) { - var blot = blots.shift(); - if (blot == null) return formats; - formats = combineFormats((0, _block.bubbleFormats)(blot), formats); - } - return formats; - }); - return _extend2.default.apply(_extend2.default, formatsArr); - } - }, { - key: 'getText', - value: function getText(index, length) { - return this.getContents(index, length).ops.map(function (op) { - return typeof op.insert === 'string' ? op.insert : ''; - }).join(''); - } - }, { - key: 'insertEmbed', - value: function insertEmbed(index, embed, value) { - var source = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : _emitter4.default.sources.API; - - this.scroll.insertAt(index, embed, value); - return this.update(new _delta2.default().retain(index).insert(_defineProperty({}, embed, value)), source); - } - }, { - key: 'insertText', - value: function insertText(index, text) { - var _this4 = this; - - var formats = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {}; - var source = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : _emitter4.default.sources.API; - - text = text.replace(/\r\n/g, '\n').replace(/\r/g, '\n'); - this.scroll.insertAt(index, text); - Object.keys(formats).forEach(function (format) { - _this4.scroll.formatAt(index, text.length, format, formats[format]); - }); - return this.update(new _delta2.default().retain(index).insert(text, (0, _clone2.default)(formats)), source); - } - }, { - key: 'isBlank', - value: function isBlank() { - if (this.scroll.children.length == 0) return true; - if (this.scroll.children.length > 1) return false; - var child = this.scroll.children.head; - return child.length() <= 1 && Object.keys(child.formats()).length == 0; - } - }, { - key: 'removeFormat', - value: function removeFormat(index, length, source) { - var text = this.getText(index, length); - - var _scroll$line3 = this.scroll.line(index + length); - - var _scroll$line4 = _slicedToArray(_scroll$line3, 2); - - var line = _scroll$line4[0]; - var offset = _scroll$line4[1]; - - var suffixLength = 0, - suffix = new _delta2.default(); - if (line != null) { - if (!(line instanceof _code2.default)) { - suffixLength = line.length() - offset; - } else { - suffixLength = line.newlineIndex(offset) - offset + 1; - } - suffix = line.delta().slice(offset, offset + suffixLength - 1).insert('\n'); - } - var contents = this.getContents(index, length + suffixLength); - var diff = contents.diff(new _delta2.default().insert(text).concat(suffix)); - var delta = new _delta2.default().retain(index).concat(diff); - return this.applyDelta(delta, source); - } - }, { - key: 'update', - value: function update(change) { - var _this5 = this; - - var source = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : _emitter4.default.sources.USER; - var mutations = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : []; - - var oldDelta = this.delta; - if (mutations.length === 1 && mutations[0].type === 'characterData' && _parchment2.default.find(mutations[0].target)) { - (function () { - // Optimization for character changes - var textBlot = _parchment2.default.find(mutations[0].target); - var formats = (0, _block.bubbleFormats)(textBlot); - var index = textBlot.offset(_this5.scroll); - var oldValue = mutations[0].oldValue.replace(_cursor2.default.CONTENTS, ''); - var oldText = new _delta2.default().insert(oldValue); - var newText = new _delta2.default().insert(textBlot.value()); - var diffDelta = new _delta2.default().retain(index).concat(oldText.diff(newText)); - change = diffDelta.ops.reduce(function (delta, op) { - if (op.insert) { - return delta.insert(op.insert, formats); - } else { - return delta.push(op); - } - }, new _delta2.default()); - _this5.delta = oldDelta.compose(change); - })(); - } else { - this.delta = this.getDelta(); - if (!change || !(0, _deepEqual2.default)(oldDelta.compose(change), this.delta)) { - change = oldDelta.diff(this.delta); - } - } - if (change.length() > 0) { - var _emitter; - - var args = [_emitter4.default.events.TEXT_CHANGE, change, oldDelta, source]; - (_emitter = this.emitter).emit.apply(_emitter, [_emitter4.default.events.EDITOR_CHANGE].concat(args)); - if (source !== _emitter4.default.sources.SILENT) { - var _emitter2; - - (_emitter2 = this.emitter).emit.apply(_emitter2, args); - } - } - return change; - } - }]); - - return Editor; - }(); - - function combineFormats(formats, combined) { - return Object.keys(combined).reduce(function (merged, name) { - if (formats[name] == null) return merged; - if (combined[name] === formats[name]) { - merged[name] = combined[name]; - } else if (Array.isArray(combined[name])) { - if (combined[name].indexOf(formats[name]) < 0) { - merged[name] = combined[name].concat([formats[name]]); - } - } else { - merged[name] = [combined[name], formats[name]]; - } - return merged; - }, {}); - } - - function normalizeDelta(delta) { - return delta.ops.reduce(function (delta, op) { - if (op.insert === 1) { - var attributes = (0, _clone2.default)(op.attributes); - delete attributes['image']; - return delta.insert({ image: op.attributes.image }, attributes); - } - if (op.attributes != null && (op.attributes.list === true || op.attributes.bullet === true)) { - op = (0, _clone2.default)(op); - if (op.attributes.list) { - op.attributes.list = 'ordered'; - } else { - op.attributes.list = 'bullet'; - delete op.attributes.bullet; - } - } - if (typeof op.insert === 'string') { - var text = op.insert.replace(/\r\n/g, '\n').replace(/\r/g, '\n'); - return delta.insert(text, op.attributes); - } - return delta.push(op); - }, new _delta2.default()); - } - - exports.default = Editor; - -/***/ }, -/* 28 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - Object.defineProperty(exports, "__esModule", { - value: true - }); - - var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); - - var _get = function get(object, property, receiver) { if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { return get(parent, property, receiver); } } else if ("value" in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } }; - - var _eventemitter = __webpack_require__(29); - - var _eventemitter2 = _interopRequireDefault(_eventemitter); - - var _logger = __webpack_require__(30); - - var _logger2 = _interopRequireDefault(_logger); - - function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - - function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } - - function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } - - function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } - - var debug = (0, _logger2.default)('quill:events'); - - var Emitter = function (_EventEmitter) { - _inherits(Emitter, _EventEmitter); - - function Emitter() { - _classCallCheck(this, Emitter); - - var _this = _possibleConstructorReturn(this, (Emitter.__proto__ || Object.getPrototypeOf(Emitter)).call(this)); - - _this.on('error', debug.error); - return _this; - } - - _createClass(Emitter, [{ - key: 'emit', - value: function emit() { - debug.log.apply(debug, arguments); - _get(Emitter.prototype.__proto__ || Object.getPrototypeOf(Emitter.prototype), 'emit', this).apply(this, arguments); - } - }]); - - return Emitter; - }(_eventemitter2.default); - - Emitter.events = { - EDITOR_CHANGE: 'editor-change', - SCROLL_BEFORE_UPDATE: 'scroll-before-update', - SCROLL_OPTIMIZE: 'scroll-optimize', - SCROLL_UPDATE: 'scroll-update', - SELECTION_CHANGE: 'selection-change', - TEXT_CHANGE: 'text-change' - }; - Emitter.sources = { - API: 'api', - SILENT: 'silent', - USER: 'user' - }; - - exports.default = Emitter; - -/***/ }, -/* 29 */ -/***/ function(module, exports) { - - 'use strict'; - - var has = Object.prototype.hasOwnProperty - , prefix = '~'; - - /** - * Constructor to create a storage for our `EE` objects. - * An `Events` instance is a plain object whose properties are event names. - * - * @constructor - * @api private - */ - function Events() {} - - // - // We try to not inherit from `Object.prototype`. In some engines creating an - // instance in this way is faster than calling `Object.create(null)` directly. - // If `Object.create(null)` is not supported we prefix the event names with a - // character to make sure that the built-in object properties are not - // overridden or used as an attack vector. - // - if (Object.create) { - Events.prototype = Object.create(null); - - // - // This hack is needed because the `__proto__` property is still inherited in - // some old browsers like Android 4, iPhone 5.1, Opera 11 and Safari 5. - // - if (!new Events().__proto__) prefix = false; - } - - /** - * Representation of a single event listener. - * - * @param {Function} fn The listener function. - * @param {Mixed} context The context to invoke the listener with. - * @param {Boolean} [once=false] Specify if the listener is a one-time listener. - * @constructor - * @api private - */ - function EE(fn, context, once) { - this.fn = fn; - this.context = context; - this.once = once || false; - } - - /** - * Minimal `EventEmitter` interface that is molded against the Node.js - * `EventEmitter` interface. - * - * @constructor - * @api public - */ - function EventEmitter() { - this._events = new Events(); - this._eventsCount = 0; - } - - /** - * Return an array listing the events for which the emitter has registered - * listeners. - * - * @returns {Array} - * @api public - */ - EventEmitter.prototype.eventNames = function eventNames() { - var names = [] - , events - , name; - - if (this._eventsCount === 0) return names; - - for (name in (events = this._events)) { - if (has.call(events, name)) names.push(prefix ? name.slice(1) : name); - } - - if (Object.getOwnPropertySymbols) { - return names.concat(Object.getOwnPropertySymbols(events)); - } - - return names; - }; - - /** - * Return the listeners registered for a given event. - * - * @param {String|Symbol} event The event name. - * @param {Boolean} exists Only check if there are listeners. - * @returns {Array|Boolean} - * @api public - */ - EventEmitter.prototype.listeners = function listeners(event, exists) { - var evt = prefix ? prefix + event : event - , available = this._events[evt]; - - if (exists) return !!available; - if (!available) return []; - if (available.fn) return [available.fn]; - - for (var i = 0, l = available.length, ee = new Array(l); i < l; i++) { - ee[i] = available[i].fn; - } - - return ee; - }; - - /** - * Calls each of the listeners registered for a given event. - * - * @param {String|Symbol} event The event name. - * @returns {Boolean} `true` if the event had listeners, else `false`. - * @api public - */ - EventEmitter.prototype.emit = function emit(event, a1, a2, a3, a4, a5) { - var evt = prefix ? prefix + event : event; - - if (!this._events[evt]) return false; - - var listeners = this._events[evt] - , len = arguments.length - , args - , i; - - if (listeners.fn) { - if (listeners.once) this.removeListener(event, listeners.fn, undefined, true); - - switch (len) { - case 1: return listeners.fn.call(listeners.context), true; - case 2: return listeners.fn.call(listeners.context, a1), true; - case 3: return listeners.fn.call(listeners.context, a1, a2), true; - case 4: return listeners.fn.call(listeners.context, a1, a2, a3), true; - case 5: return listeners.fn.call(listeners.context, a1, a2, a3, a4), true; - case 6: return listeners.fn.call(listeners.context, a1, a2, a3, a4, a5), true; - } - - for (i = 1, args = new Array(len -1); i < len; i++) { - args[i - 1] = arguments[i]; - } - - listeners.fn.apply(listeners.context, args); - } else { - var length = listeners.length - , j; - - for (i = 0; i < length; i++) { - if (listeners[i].once) this.removeListener(event, listeners[i].fn, undefined, true); - - switch (len) { - case 1: listeners[i].fn.call(listeners[i].context); break; - case 2: listeners[i].fn.call(listeners[i].context, a1); break; - case 3: listeners[i].fn.call(listeners[i].context, a1, a2); break; - case 4: listeners[i].fn.call(listeners[i].context, a1, a2, a3); break; - default: - if (!args) for (j = 1, args = new Array(len -1); j < len; j++) { - args[j - 1] = arguments[j]; - } - - listeners[i].fn.apply(listeners[i].context, args); - } - } - } - - return true; - }; - - /** - * Add a listener for a given event. - * - * @param {String|Symbol} event The event name. - * @param {Function} fn The listener function. - * @param {Mixed} [context=this] The context to invoke the listener with. - * @returns {EventEmitter} `this`. - * @api public - */ - EventEmitter.prototype.on = function on(event, fn, context) { - var listener = new EE(fn, context || this) - , evt = prefix ? prefix + event : event; - - if (!this._events[evt]) this._events[evt] = listener, this._eventsCount++; - else if (!this._events[evt].fn) this._events[evt].push(listener); - else this._events[evt] = [this._events[evt], listener]; - - return this; - }; - - /** - * Add a one-time listener for a given event. - * - * @param {String|Symbol} event The event name. - * @param {Function} fn The listener function. - * @param {Mixed} [context=this] The context to invoke the listener with. - * @returns {EventEmitter} `this`. - * @api public - */ - EventEmitter.prototype.once = function once(event, fn, context) { - var listener = new EE(fn, context || this, true) - , evt = prefix ? prefix + event : event; - - if (!this._events[evt]) this._events[evt] = listener, this._eventsCount++; - else if (!this._events[evt].fn) this._events[evt].push(listener); - else this._events[evt] = [this._events[evt], listener]; - - return this; - }; - - /** - * Remove the listeners of a given event. - * - * @param {String|Symbol} event The event name. - * @param {Function} fn Only remove the listeners that match this function. - * @param {Mixed} context Only remove the listeners that have this context. - * @param {Boolean} once Only remove one-time listeners. - * @returns {EventEmitter} `this`. - * @api public - */ - EventEmitter.prototype.removeListener = function removeListener(event, fn, context, once) { - var evt = prefix ? prefix + event : event; - - if (!this._events[evt]) return this; - if (!fn) { - if (--this._eventsCount === 0) this._events = new Events(); - else delete this._events[evt]; - return this; - } - - var listeners = this._events[evt]; - - if (listeners.fn) { - if ( - listeners.fn === fn - && (!once || listeners.once) - && (!context || listeners.context === context) - ) { - if (--this._eventsCount === 0) this._events = new Events(); - else delete this._events[evt]; - } - } else { - for (var i = 0, events = [], length = listeners.length; i < length; i++) { - if ( - listeners[i].fn !== fn - || (once && !listeners[i].once) - || (context && listeners[i].context !== context) - ) { - events.push(listeners[i]); - } - } - - // - // Reset the array, or remove it completely if we have no more listeners. - // - if (events.length) this._events[evt] = events.length === 1 ? events[0] : events; - else if (--this._eventsCount === 0) this._events = new Events(); - else delete this._events[evt]; - } - - return this; - }; - - /** - * Remove all listeners, or those of the specified event. - * - * @param {String|Symbol} [event] The event name. - * @returns {EventEmitter} `this`. - * @api public - */ - EventEmitter.prototype.removeAllListeners = function removeAllListeners(event) { - var evt; - - if (event) { - evt = prefix ? prefix + event : event; - if (this._events[evt]) { - if (--this._eventsCount === 0) this._events = new Events(); - else delete this._events[evt]; - } - } else { - this._events = new Events(); - this._eventsCount = 0; - } - - return this; - }; - - // - // Alias methods names because people roll like that. - // - EventEmitter.prototype.off = EventEmitter.prototype.removeListener; - EventEmitter.prototype.addListener = EventEmitter.prototype.on; - - // - // This function doesn't apply anymore. - // - EventEmitter.prototype.setMaxListeners = function setMaxListeners() { - return this; - }; - - // - // Expose the prefix. - // - EventEmitter.prefixed = prefix; - - // - // Allow `EventEmitter` to be imported as module namespace. - // - EventEmitter.EventEmitter = EventEmitter; - - // - // Expose the module. - // - if ('undefined' !== typeof module) { - module.exports = EventEmitter; - } - - -/***/ }, -/* 30 */ -/***/ function(module, exports) { - - 'use strict'; - - Object.defineProperty(exports, "__esModule", { - value: true - }); - var levels = ['error', 'warn', 'log', 'info']; - var level = 'warn'; - - function debug(method) { - if (levels.indexOf(method) <= levels.indexOf(level)) { - for (var _len = arguments.length, args = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) { - args[_key - 1] = arguments[_key]; - } - - console[method].apply(console, args); - } - } - - function namespace(ns) { - return levels.reduce(function (logger, method) { - logger[method] = debug.bind(console, method, ns); - return logger; - }, {}); - } - - debug.level = namespace.level = function (newLevel) { - level = newLevel; - }; - - exports.default = namespace; - -/***/ }, -/* 31 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - Object.defineProperty(exports, "__esModule", { - value: true - }); - exports.default = exports.Code = undefined; - - var _slicedToArray = function () { function sliceIterator(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"]) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } return function (arr, i) { if (Array.isArray(arr)) { return arr; } else if (Symbol.iterator in Object(arr)) { return sliceIterator(arr, i); } else { throw new TypeError("Invalid attempt to destructure non-iterable instance"); } }; }(); - - var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); - - var _get = function get(object, property, receiver) { if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { return get(parent, property, receiver); } } else if ("value" in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } }; - - var _delta = __webpack_require__(20); - - var _delta2 = _interopRequireDefault(_delta); - - var _parchment = __webpack_require__(2); - - var _parchment2 = _interopRequireDefault(_parchment); - - var _block = __webpack_require__(32); - - var _block2 = _interopRequireDefault(_block); - - var _inline = __webpack_require__(35); - - var _inline2 = _interopRequireDefault(_inline); - - var _text = __webpack_require__(36); - - var _text2 = _interopRequireDefault(_text); - - function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - - function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } - - function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } - - function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } - - var Code = function (_Inline) { - _inherits(Code, _Inline); - - function Code() { - _classCallCheck(this, Code); - - return _possibleConstructorReturn(this, (Code.__proto__ || Object.getPrototypeOf(Code)).apply(this, arguments)); - } - - return Code; - }(_inline2.default); - - Code.blotName = 'code'; - Code.tagName = 'CODE'; - - var CodeBlock = function (_Block) { - _inherits(CodeBlock, _Block); - - function CodeBlock() { - _classCallCheck(this, CodeBlock); - - return _possibleConstructorReturn(this, (CodeBlock.__proto__ || Object.getPrototypeOf(CodeBlock)).apply(this, arguments)); - } - - _createClass(CodeBlock, [{ - key: 'delta', - value: function delta() { - var _this3 = this; - - var text = this.domNode.textContent; - if (text.endsWith('\n')) { - // Should always be true - text = text.slice(0, -1); - } - return text.split('\n').reduce(function (delta, frag) { - return delta.insert(frag).insert('\n', _this3.formats()); - }, new _delta2.default()); - } - }, { - key: 'format', - value: function format(name, value) { - if (name === this.statics.blotName && value) return; - - var _descendant = this.descendant(_text2.default, this.length() - 1); - - var _descendant2 = _slicedToArray(_descendant, 1); - - var text = _descendant2[0]; - - if (text != null) { - text.deleteAt(text.length() - 1, 1); - } - _get(CodeBlock.prototype.__proto__ || Object.getPrototypeOf(CodeBlock.prototype), 'format', this).call(this, name, value); - } - }, { - key: 'formatAt', - value: function formatAt(index, length, name, value) { - if (length === 0) return; - if (_parchment2.default.query(name, _parchment2.default.Scope.BLOCK) == null || name === this.statics.blotName && value === this.statics.formats(this.domNode)) { - return; - } - var nextNewline = this.newlineIndex(index); - if (nextNewline < 0 || nextNewline >= index + length) return; - var prevNewline = this.newlineIndex(index, true) + 1; - var isolateLength = nextNewline - prevNewline + 1; - var blot = this.isolate(prevNewline, isolateLength); - var next = blot.next; - blot.format(name, value); - if (next instanceof CodeBlock) { - next.formatAt(0, index - prevNewline + length - isolateLength, name, value); - } - } - }, { - key: 'insertAt', - value: function insertAt(index, value, def) { - if (def != null) return; - - var _descendant3 = this.descendant(_text2.default, index); - - var _descendant4 = _slicedToArray(_descendant3, 2); - - var text = _descendant4[0]; - var offset = _descendant4[1]; - - text.insertAt(offset, value); - } - }, { - key: 'length', - value: function length() { - var length = this.domNode.textContent.length; - if (!this.domNode.textContent.endsWith('\n')) { - return length + 1; - } - return length; - } - }, { - key: 'newlineIndex', - value: function newlineIndex(searchIndex) { - var reverse = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false; - - if (!reverse) { - var offset = this.domNode.textContent.slice(searchIndex).indexOf('\n'); - return offset > -1 ? searchIndex + offset : -1; - } else { - return this.domNode.textContent.slice(0, searchIndex).lastIndexOf('\n'); - } - } - }, { - key: 'optimize', - value: function optimize() { - if (!this.domNode.textContent.endsWith('\n')) { - this.appendChild(_parchment2.default.create('text', '\n')); - } - _get(CodeBlock.prototype.__proto__ || Object.getPrototypeOf(CodeBlock.prototype), 'optimize', this).call(this); - var next = this.next; - if (next != null && next.prev === this && next.statics.blotName === this.statics.blotName && this.statics.formats(this.domNode) === next.statics.formats(next.domNode)) { - next.optimize(); - next.moveChildren(this); - next.remove(); - } - } - }, { - key: 'replace', - value: function replace(target) { - _get(CodeBlock.prototype.__proto__ || Object.getPrototypeOf(CodeBlock.prototype), 'replace', this).call(this, target); - [].slice.call(this.domNode.querySelectorAll('*')).forEach(function (node) { - var blot = _parchment2.default.find(node); - if (blot == null) { - node.parentNode.removeChild(node); - } else if (blot instanceof _parchment2.default.Embed) { - blot.remove(); - } else { - blot.unwrap(); - } - }); - } - }], [{ - key: 'create', - value: function create(value) { - var domNode = _get(CodeBlock.__proto__ || Object.getPrototypeOf(CodeBlock), 'create', this).call(this, value); - domNode.setAttribute('spellcheck', false); - return domNode; - } - }, { - key: 'formats', - value: function formats(domNode) { - return true; - } - }]); - - return CodeBlock; - }(_block2.default); - - CodeBlock.blotName = 'code-block'; - CodeBlock.tagName = 'PRE'; - CodeBlock.TAB = ' '; - - exports.Code = Code; - exports.default = CodeBlock; - -/***/ }, -/* 32 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - Object.defineProperty(exports, "__esModule", { - value: true - }); - exports.default = exports.BlockEmbed = exports.bubbleFormats = undefined; - - var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); - - var _get = function get(object, property, receiver) { if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { return get(parent, property, receiver); } } else if ("value" in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } }; - - var _extend = __webpack_require__(25); - - var _extend2 = _interopRequireDefault(_extend); - - var _delta = __webpack_require__(20); - - var _delta2 = _interopRequireDefault(_delta); - - var _parchment = __webpack_require__(2); - - var _parchment2 = _interopRequireDefault(_parchment); - - var _break = __webpack_require__(33); - - var _break2 = _interopRequireDefault(_break); - - var _embed = __webpack_require__(34); - - var _embed2 = _interopRequireDefault(_embed); - - var _inline = __webpack_require__(35); - - var _inline2 = _interopRequireDefault(_inline); - - var _text = __webpack_require__(36); - - var _text2 = _interopRequireDefault(_text); - - function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - - function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } - - function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } - - function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } - - var NEWLINE_LENGTH = 1; - - var BlockEmbed = function (_Embed) { - _inherits(BlockEmbed, _Embed); - - function BlockEmbed() { - _classCallCheck(this, BlockEmbed); - - return _possibleConstructorReturn(this, (BlockEmbed.__proto__ || Object.getPrototypeOf(BlockEmbed)).apply(this, arguments)); - } - - _createClass(BlockEmbed, [{ - key: 'attach', - value: function attach() { - _get(BlockEmbed.prototype.__proto__ || Object.getPrototypeOf(BlockEmbed.prototype), 'attach', this).call(this); - this.attributes = new _parchment2.default.Attributor.Store(this.domNode); - } - }, { - key: 'delta', - value: function delta() { - return new _delta2.default().insert(this.value(), (0, _extend2.default)(this.formats(), this.attributes.values())); - } - }, { - key: 'format', - value: function format(name, value) { - var attribute = _parchment2.default.query(name, _parchment2.default.Scope.BLOCK_ATTRIBUTE); - if (attribute != null) { - this.attributes.attribute(attribute, value); - } - } - }, { - key: 'formatAt', - value: function formatAt(index, length, name, value) { - this.format(name, value); - } - }, { - key: 'insertAt', - value: function insertAt(index, value, def) { - if (typeof value === 'string' && value.endsWith('\n')) { - var block = _parchment2.default.create(Block.blotName); - this.parent.insertBefore(block, index === 0 ? this : this.next); - block.insertAt(0, value.slice(0, -1)); - } else { - _get(BlockEmbed.prototype.__proto__ || Object.getPrototypeOf(BlockEmbed.prototype), 'insertAt', this).call(this, index, value, def); - } - } - }]); - - return BlockEmbed; - }(_embed2.default); - - BlockEmbed.scope = _parchment2.default.Scope.BLOCK_BLOT; - // It is important for cursor behavior BlockEmbeds use tags that are block level elements - - - var Block = function (_Parchment$Block) { - _inherits(Block, _Parchment$Block); - - function Block(domNode) { - _classCallCheck(this, Block); - - var _this2 = _possibleConstructorReturn(this, (Block.__proto__ || Object.getPrototypeOf(Block)).call(this, domNode)); - - _this2.cache = {}; - return _this2; - } - - _createClass(Block, [{ - key: 'delta', - value: function delta() { - if (this.cache.delta == null) { - this.cache.delta = this.descendants(_parchment2.default.Leaf).reduce(function (delta, leaf) { - if (leaf.length() === 0) { - return delta; - } else { - return delta.insert(leaf.value(), bubbleFormats(leaf)); - } - }, new _delta2.default()).insert('\n', bubbleFormats(this)); - } - return this.cache.delta; - } - }, { - key: 'deleteAt', - value: function deleteAt(index, length) { - _get(Block.prototype.__proto__ || Object.getPrototypeOf(Block.prototype), 'deleteAt', this).call(this, index, length); - this.cache = {}; - } - }, { - key: 'formatAt', - value: function formatAt(index, length, name, value) { - if (length <= 0) return; - if (_parchment2.default.query(name, _parchment2.default.Scope.BLOCK)) { - if (index + length === this.length()) { - this.format(name, value); - } - } else { - _get(Block.prototype.__proto__ || Object.getPrototypeOf(Block.prototype), 'formatAt', this).call(this, index, Math.min(length, this.length() - index - 1), name, value); - } - this.cache = {}; - } - }, { - key: 'insertAt', - value: function insertAt(index, value, def) { - if (def != null) return _get(Block.prototype.__proto__ || Object.getPrototypeOf(Block.prototype), 'insertAt', this).call(this, index, value, def); - if (value.length === 0) return; - var lines = value.split('\n'); - var text = lines.shift(); - if (text.length > 0) { - if (index < this.length() - 1 || this.children.tail == null) { - _get(Block.prototype.__proto__ || Object.getPrototypeOf(Block.prototype), 'insertAt', this).call(this, Math.min(index, this.length() - 1), text); - } else { - this.children.tail.insertAt(this.children.tail.length(), text); - } - this.cache = {}; - } - var block = this; - lines.reduce(function (index, line) { - block = block.split(index, true); - block.insertAt(0, line); - return line.length; - }, index + text.length); - } - }, { - key: 'insertBefore', - value: function insertBefore(blot, ref) { - var head = this.children.head; - _get(Block.prototype.__proto__ || Object.getPrototypeOf(Block.prototype), 'insertBefore', this).call(this, blot, ref); - if (head instanceof _break2.default) { - head.remove(); - } - this.cache = {}; - } - }, { - key: 'length', - value: function length() { - if (this.cache.length == null) { - this.cache.length = _get(Block.prototype.__proto__ || Object.getPrototypeOf(Block.prototype), 'length', this).call(this) + NEWLINE_LENGTH; - } - return this.cache.length; - } - }, { - key: 'moveChildren', - value: function moveChildren(target, ref) { - _get(Block.prototype.__proto__ || Object.getPrototypeOf(Block.prototype), 'moveChildren', this).call(this, target, ref); - this.cache = {}; - } - }, { - key: 'optimize', - value: function optimize() { - _get(Block.prototype.__proto__ || Object.getPrototypeOf(Block.prototype), 'optimize', this).call(this); - this.cache = {}; - } - }, { - key: 'path', - value: function path(index) { - return _get(Block.prototype.__proto__ || Object.getPrototypeOf(Block.prototype), 'path', this).call(this, index, true); - } - }, { - key: 'removeChild', - value: function removeChild(child) { - _get(Block.prototype.__proto__ || Object.getPrototypeOf(Block.prototype), 'removeChild', this).call(this, child); - this.cache = {}; - } - }, { - key: 'split', - value: function split(index) { - var force = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false; - - if (force && (index === 0 || index >= this.length() - NEWLINE_LENGTH)) { - var clone = this.clone(); - if (index === 0) { - this.parent.insertBefore(clone, this); - return this; - } else { - this.parent.insertBefore(clone, this.next); - return clone; - } - } else { - var next = _get(Block.prototype.__proto__ || Object.getPrototypeOf(Block.prototype), 'split', this).call(this, index, force); - this.cache = {}; - return next; - } - } - }]); - - return Block; - }(_parchment2.default.Block); - - Block.blotName = 'block'; - Block.tagName = 'P'; - Block.defaultChild = 'break'; - Block.allowedChildren = [_inline2.default, _embed2.default, _text2.default]; - - function bubbleFormats(blot) { - var formats = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; - - if (blot == null) return formats; - if (typeof blot.formats === 'function') { - formats = (0, _extend2.default)(formats, blot.formats()); - } - if (blot.parent == null || blot.parent.blotName == 'scroll' || blot.parent.statics.scope !== blot.statics.scope) { - return formats; - } - return bubbleFormats(blot.parent, formats); - } - - exports.bubbleFormats = bubbleFormats; - exports.BlockEmbed = BlockEmbed; - exports.default = Block; - -/***/ }, -/* 33 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - Object.defineProperty(exports, "__esModule", { - value: true - }); - - var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); - - var _get = function get(object, property, receiver) { if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { return get(parent, property, receiver); } } else if ("value" in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } }; - - var _embed = __webpack_require__(34); - - var _embed2 = _interopRequireDefault(_embed); - - function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - - function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } - - function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } - - function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } - - var Break = function (_Embed) { - _inherits(Break, _Embed); - - function Break() { - _classCallCheck(this, Break); - - return _possibleConstructorReturn(this, (Break.__proto__ || Object.getPrototypeOf(Break)).apply(this, arguments)); - } - - _createClass(Break, [{ - key: 'insertInto', - value: function insertInto(parent, ref) { - if (parent.children.length === 0) { - _get(Break.prototype.__proto__ || Object.getPrototypeOf(Break.prototype), 'insertInto', this).call(this, parent, ref); - } - } - }, { - key: 'length', - value: function length() { - return 0; - } - }, { - key: 'value', - value: function value() { - return ''; - } - }], [{ - key: 'value', - value: function value(domNode) { - return undefined; - } - }]); - - return Break; - }(_embed2.default); - - Break.blotName = 'break'; - Break.tagName = 'BR'; - - exports.default = Break; - -/***/ }, -/* 34 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - Object.defineProperty(exports, "__esModule", { - value: true - }); - - var _parchment = __webpack_require__(2); - - var _parchment2 = _interopRequireDefault(_parchment); - - function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - - function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } - - function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } - - function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } - - var Embed = function (_Parchment$Embed) { - _inherits(Embed, _Parchment$Embed); - - function Embed() { - _classCallCheck(this, Embed); - - return _possibleConstructorReturn(this, (Embed.__proto__ || Object.getPrototypeOf(Embed)).apply(this, arguments)); - } - - return Embed; - }(_parchment2.default.Embed); - - exports.default = Embed; - -/***/ }, -/* 35 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - Object.defineProperty(exports, "__esModule", { - value: true - }); - - var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); - - var _get = function get(object, property, receiver) { if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { return get(parent, property, receiver); } } else if ("value" in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } }; - - var _extend = __webpack_require__(25); - - var _extend2 = _interopRequireDefault(_extend); - - var _embed = __webpack_require__(34); - - var _embed2 = _interopRequireDefault(_embed); - - var _text = __webpack_require__(36); - - var _text2 = _interopRequireDefault(_text); - - var _parchment = __webpack_require__(2); - - var _parchment2 = _interopRequireDefault(_parchment); - - function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - - function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } - - function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } - - function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } - - var Inline = function (_Parchment$Inline) { - _inherits(Inline, _Parchment$Inline); - - function Inline() { - _classCallCheck(this, Inline); - - return _possibleConstructorReturn(this, (Inline.__proto__ || Object.getPrototypeOf(Inline)).apply(this, arguments)); - } - - _createClass(Inline, [{ - key: 'formatAt', - value: function formatAt(index, length, name, value) { - if (Inline.compare(this.statics.blotName, name) < 0 && _parchment2.default.query(name, _parchment2.default.Scope.BLOT)) { - var blot = this.isolate(index, length); - if (value) { - blot.wrap(name, value); - } - } else { - _get(Inline.prototype.__proto__ || Object.getPrototypeOf(Inline.prototype), 'formatAt', this).call(this, index, length, name, value); - } - } - }, { - key: 'optimize', - value: function optimize() { - _get(Inline.prototype.__proto__ || Object.getPrototypeOf(Inline.prototype), 'optimize', this).call(this); - var ref = this.parent.parent; - if (this.parent instanceof Inline && Inline.compare(this.statics.blotName, this.parent.statics.blotName) > 0) { - var parent = this.parent.isolate(this.offset(), this.length()); - this.moveChildren(parent); - parent.wrap(this); - } - } - }], [{ - key: 'compare', - value: function compare(self, other) { - var selfIndex = Inline.order.indexOf(self); - var otherIndex = Inline.order.indexOf(other); - if (selfIndex >= 0 || otherIndex >= 0) { - return selfIndex - otherIndex; - } else if (self === other) { - return 0; - } else if (self < other) { - return -1; - } else { - return 1; - } - } - }]); - - return Inline; - }(_parchment2.default.Inline); - - Inline.allowedChildren = [Inline, _embed2.default, _text2.default]; - // Lower index means deeper in the DOM tree, since not found (-1) is for embeds - Inline.order = ['cursor', 'inline', // Must be lower - 'code', 'underline', 'strike', 'italic', 'bold', 'script', 'link' // Must be higher - ]; - - exports.default = Inline; - -/***/ }, -/* 36 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - Object.defineProperty(exports, "__esModule", { - value: true - }); - - var _parchment = __webpack_require__(2); - - var _parchment2 = _interopRequireDefault(_parchment); - - function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - - function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } - - function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } - - function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } - - var TextBlot = function (_Parchment$Text) { - _inherits(TextBlot, _Parchment$Text); - - function TextBlot() { - _classCallCheck(this, TextBlot); - - return _possibleConstructorReturn(this, (TextBlot.__proto__ || Object.getPrototypeOf(TextBlot)).apply(this, arguments)); - } - - return TextBlot; - }(_parchment2.default.Text); - - exports.default = TextBlot; - -/***/ }, -/* 37 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - Object.defineProperty(exports, "__esModule", { - value: true - }); - - var _slicedToArray = function () { function sliceIterator(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"]) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } return function (arr, i) { if (Array.isArray(arr)) { return arr; } else if (Symbol.iterator in Object(arr)) { return sliceIterator(arr, i); } else { throw new TypeError("Invalid attempt to destructure non-iterable instance"); } }; }(); - - var _get = function get(object, property, receiver) { if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { return get(parent, property, receiver); } } else if ("value" in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } }; - - var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); - - var _parchment = __webpack_require__(2); - - var _parchment2 = _interopRequireDefault(_parchment); - - var _embed = __webpack_require__(34); - - var _embed2 = _interopRequireDefault(_embed); - - var _emitter = __webpack_require__(28); - - var _emitter2 = _interopRequireDefault(_emitter); - - function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - - function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } - - function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } - - function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } - - var Cursor = function (_Embed) { - _inherits(Cursor, _Embed); - - _createClass(Cursor, null, [{ - key: 'value', - value: function value(domNode) { - return undefined; - } - }]); - - function Cursor(domNode, selection) { - _classCallCheck(this, Cursor); - - var _this = _possibleConstructorReturn(this, (Cursor.__proto__ || Object.getPrototypeOf(Cursor)).call(this, domNode)); - - _this.selection = selection; - _this.textNode = document.createTextNode(Cursor.CONTENTS); - _this.domNode.appendChild(_this.textNode); - _this._length = 0; - return _this; - } - - _createClass(Cursor, [{ - key: 'detach', - value: function detach() { - // super.detach() will also clear domNode.__blot - if (this.parent != null) this.parent.removeChild(this); - } - }, { - key: 'format', - value: function format(name, value) { - if (this._length !== 0) { - return _get(Cursor.prototype.__proto__ || Object.getPrototypeOf(Cursor.prototype), 'format', this).call(this, name, value); - } - var target = this, - index = 0; - while (target != null && target.statics.scope !== _parchment2.default.Scope.BLOCK_BLOT) { - index += target.offset(target.parent); - target = target.parent; - } - if (target != null) { - this._length = Cursor.CONTENTS.length; - target.optimize(); - target.formatAt(index, Cursor.CONTENTS.length, name, value); - this._length = 0; - } - } - }, { - key: 'index', - value: function index(node, offset) { - if (node === this.textNode) return 0; - return _get(Cursor.prototype.__proto__ || Object.getPrototypeOf(Cursor.prototype), 'index', this).call(this, node, offset); - } - }, { - key: 'length', - value: function length() { - return this._length; - } - }, { - key: 'position', - value: function position(index) { - return [this.textNode, this.textNode.data.length]; - } - }, { - key: 'remove', - value: function remove() { - _get(Cursor.prototype.__proto__ || Object.getPrototypeOf(Cursor.prototype), 'remove', this).call(this); - this.parent = null; - } - }, { - key: 'restore', - value: function restore() { - var _this2 = this; - - if (this.selection.composing) return; - if (this.parent == null) return; - var textNode = this.textNode; - var range = this.selection.getNativeRange(); - // Link format will insert text outside of anchor tag - while (this.domNode.lastChild != null && this.domNode.lastChild !== this.textNode) { - this.domNode.parentNode.insertBefore(this.domNode.lastChild, this.domNode); - } - if (this.textNode.data !== Cursor.CONTENTS) { - this.textNode.data = this.textNode.data.split(Cursor.CONTENTS).join(''); - this.parent.insertBefore(_parchment2.default.create(this.textNode), this); - this.textNode = document.createTextNode(Cursor.CONTENTS); - this.domNode.appendChild(this.textNode); - } - this.remove(); - if (range != null && range.start.node === textNode && range.end.node === textNode) { - this.selection.emitter.once(_emitter2.default.events.SCROLL_OPTIMIZE, function () { - var _map = [range.start.offset, range.end.offset].map(function (offset) { - return Math.max(0, Math.min(textNode.data.length, offset - 1)); - }); - - var _map2 = _slicedToArray(_map, 2); - - var start = _map2[0]; - var end = _map2[1]; - - _this2.selection.setNativeRange(textNode, start, textNode, end); - }); - } - } - }, { - key: 'update', - value: function update(mutations) { - var _this3 = this; - - mutations.forEach(function (mutation) { - if (mutation.type === 'characterData' && mutation.target === _this3.textNode) { - _this3.restore(); - } - }); - } - }, { - key: 'value', - value: function value() { - return ''; - } - }]); - - return Cursor; - }(_embed2.default); - - Cursor.blotName = 'cursor'; - Cursor.className = 'ql-cursor'; - Cursor.tagName = 'span'; - Cursor.CONTENTS = '\uFEFF'; // Zero width no break space - - - exports.default = Cursor; - -/***/ }, -/* 38 */ -/***/ function(module, exports) { - - var clone = (function() { - 'use strict'; - - var nativeMap; - try { - nativeMap = Map; - } catch(_) { - // maybe a reference error because no `Map`. Give it a dummy value that no - // value will ever be an instanceof. - nativeMap = function() {}; - } - - var nativeSet; - try { - nativeSet = Set; - } catch(_) { - nativeSet = function() {}; - } - - var nativePromise; - try { - nativePromise = Promise; - } catch(_) { - nativePromise = function() {}; - } - - /** - * Clones (copies) an Object using deep copying. - * - * This function supports circular references by default, but if you are certain - * there are no circular references in your object, you can save some CPU time - * by calling clone(obj, false). - * - * Caution: if `circular` is false and `parent` contains circular references, - * your program may enter an infinite loop and crash. - * - * @param `parent` - the object to be cloned - * @param `circular` - set to true if the object to be cloned may contain - * circular references. (optional - true by default) - * @param `depth` - set to a number if the object is only to be cloned to - * a particular depth. (optional - defaults to Infinity) - * @param `prototype` - sets the prototype to be used when cloning an object. - * (optional - defaults to parent prototype). - */ - function clone(parent, circular, depth, prototype) { - var filter; - if (typeof circular === 'object') { - depth = circular.depth; - prototype = circular.prototype; - filter = circular.filter; - circular = circular.circular; - } - // maintain two arrays for circular references, where corresponding parents - // and children have the same index - var allParents = []; - var allChildren = []; - - var useBuffer = typeof Buffer != 'undefined'; - - if (typeof circular == 'undefined') - circular = true; - - if (typeof depth == 'undefined') - depth = Infinity; - - // recurse this function so we don't reset allParents and allChildren - function _clone(parent, depth) { - // cloning null always returns null - if (parent === null) - return null; - - if (depth === 0) - return parent; - - var child; - var proto; - if (typeof parent != 'object') { - return parent; - } - - if (parent instanceof nativeMap) { - child = new nativeMap(); - } else if (parent instanceof nativeSet) { - child = new nativeSet(); - } else if (parent instanceof nativePromise) { - child = new nativePromise(function (resolve, reject) { - parent.then(function(value) { - resolve(_clone(value, depth - 1)); - }, function(err) { - reject(_clone(err, depth - 1)); - }); - }); - } else if (clone.__isArray(parent)) { - child = []; - } else if (clone.__isRegExp(parent)) { - child = new RegExp(parent.source, __getRegExpFlags(parent)); - if (parent.lastIndex) child.lastIndex = parent.lastIndex; - } else if (clone.__isDate(parent)) { - child = new Date(parent.getTime()); - } else if (useBuffer && Buffer.isBuffer(parent)) { - child = new Buffer(parent.length); - parent.copy(child); - return child; - } else { - if (typeof prototype == 'undefined') { - proto = Object.getPrototypeOf(parent); - child = Object.create(proto); - } - else { - child = Object.create(prototype); - proto = prototype; - } - } - - if (circular) { - var index = allParents.indexOf(parent); - - if (index != -1) { - return allChildren[index]; - } - allParents.push(parent); - allChildren.push(child); - } - - if (parent instanceof nativeMap) { - var keyIterator = parent.keys(); - while(true) { - var next = keyIterator.next(); - if (next.done) { - break; - } - var keyChild = _clone(next.value, depth - 1); - var valueChild = _clone(parent.get(next.value), depth - 1); - child.set(keyChild, valueChild); - } - } - if (parent instanceof nativeSet) { - var iterator = parent.keys(); - while(true) { - var next = iterator.next(); - if (next.done) { - break; - } - var entryChild = _clone(next.value, depth - 1); - child.add(entryChild); - } - } - - for (var i in parent) { - var attrs; - if (proto) { - attrs = Object.getOwnPropertyDescriptor(proto, i); - } - - if (attrs && attrs.set == null) { - continue; - } - child[i] = _clone(parent[i], depth - 1); - } - - if (Object.getOwnPropertySymbols) { - var symbols = Object.getOwnPropertySymbols(parent); - for (var i = 0; i < symbols.length; i++) { - // Don't need to worry about cloning a symbol because it is a primitive, - // like a number or string. - var symbol = symbols[i]; - child[symbol] = _clone(parent[symbol], depth - 1); - } - } - - return child; - } - - return _clone(parent, depth); - } - - /** - * Simple flat clone using prototype, accepts only objects, usefull for property - * override on FLAT configuration object (no nested props). - * - * USE WITH CAUTION! This may not behave as you wish if you do not know how this - * works. - */ - clone.clonePrototype = function clonePrototype(parent) { - if (parent === null) - return null; - - var c = function () {}; - c.prototype = parent; - return new c(); - }; - - // private utility functions - - function __objToStr(o) { - return Object.prototype.toString.call(o); - } - clone.__objToStr = __objToStr; - - function __isDate(o) { - return typeof o === 'object' && __objToStr(o) === '[object Date]'; - } - clone.__isDate = __isDate; - - function __isArray(o) { - return typeof o === 'object' && __objToStr(o) === '[object Array]'; - } - clone.__isArray = __isArray; - - function __isRegExp(o) { - return typeof o === 'object' && __objToStr(o) === '[object RegExp]'; - } - clone.__isRegExp = __isRegExp; - - function __getRegExpFlags(re) { - var flags = ''; - if (re.global) flags += 'g'; - if (re.ignoreCase) flags += 'i'; - if (re.multiline) flags += 'm'; - return flags; - } - clone.__getRegExpFlags = __getRegExpFlags; - - return clone; - })(); - - if (typeof module === 'object' && module.exports) { - module.exports = clone; - } - - -/***/ }, -/* 39 */ -/***/ function(module, exports) { - - "use strict"; - - Object.defineProperty(exports, "__esModule", { - value: true - }); - - function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } - - var Module = function Module(quill) { - var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; - - _classCallCheck(this, Module); - - this.quill = quill; - this.options = options; - }; - - Module.DEFAULTS = {}; - - exports.default = Module; - -/***/ }, -/* 40 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - Object.defineProperty(exports, "__esModule", { - value: true - }); - exports.default = exports.Range = undefined; - - var _slicedToArray = function () { function sliceIterator(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"]) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } return function (arr, i) { if (Array.isArray(arr)) { return arr; } else if (Symbol.iterator in Object(arr)) { return sliceIterator(arr, i); } else { throw new TypeError("Invalid attempt to destructure non-iterable instance"); } }; }(); - - var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); - - var _parchment = __webpack_require__(2); - - var _parchment2 = _interopRequireDefault(_parchment); - - var _clone = __webpack_require__(38); - - var _clone2 = _interopRequireDefault(_clone); - - var _deepEqual = __webpack_require__(22); - - var _deepEqual2 = _interopRequireDefault(_deepEqual); - - var _break = __webpack_require__(33); - - var _break2 = _interopRequireDefault(_break); - - var _emitter3 = __webpack_require__(28); - - var _emitter4 = _interopRequireDefault(_emitter3); - - var _logger = __webpack_require__(30); - - var _logger2 = _interopRequireDefault(_logger); - - function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - - function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } } - - function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } - - var debug = (0, _logger2.default)('quill:selection'); - - var Range = function Range(index) { - var length = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0; - - _classCallCheck(this, Range); - - this.index = index; - this.length = length; - }; - - var Selection = function () { - function Selection(scroll, emitter) { - var _this = this; - - _classCallCheck(this, Selection); - - this.emitter = emitter; - this.scroll = scroll; - this.composing = false; - this.root = this.scroll.domNode; - this.root.addEventListener('compositionstart', function () { - _this.composing = true; - }); - this.root.addEventListener('compositionend', function () { - _this.composing = false; - }); - this.cursor = _parchment2.default.create('cursor', this); - // savedRange is last non-null range - this.lastRange = this.savedRange = new Range(0, 0); - ['keyup', 'mouseup', 'mouseleave', 'touchend', 'touchleave', 'focus', 'blur'].forEach(function (eventName) { - _this.root.addEventListener(eventName, function () { - // When range used to be a selection and user click within the selection, - // the range now being a cursor has not updated yet without setTimeout - setTimeout(_this.update.bind(_this, _emitter4.default.sources.USER), 100); - }); - }); - this.emitter.on(_emitter4.default.events.EDITOR_CHANGE, function (type, delta) { - if (type === _emitter4.default.events.TEXT_CHANGE && delta.length() > 0) { - _this.update(_emitter4.default.sources.SILENT); - } - }); - this.emitter.on(_emitter4.default.events.SCROLL_BEFORE_UPDATE, function () { - var native = _this.getNativeRange(); - if (native == null) return; - if (native.start.node === _this.cursor.textNode) return; // cursor.restore() will handle - // TODO unclear if this has negative side effects - _this.emitter.once(_emitter4.default.events.SCROLL_UPDATE, function () { - try { - _this.setNativeRange(native.start.node, native.start.offset, native.end.node, native.end.offset); - } catch (ignored) {} - }); - }); - this.update(_emitter4.default.sources.SILENT); - } - - _createClass(Selection, [{ - key: 'focus', - value: function focus() { - if (this.hasFocus()) return; - var bodyTop = document.body.scrollTop; - this.root.focus(); - document.body.scrollTop = bodyTop; - this.setRange(this.savedRange); - } - }, { - key: 'format', - value: function format(_format, value) { - this.scroll.update(); - var nativeRange = this.getNativeRange(); - if (nativeRange == null || !nativeRange.native.collapsed || _parchment2.default.query(_format, _parchment2.default.Scope.BLOCK)) return; - if (nativeRange.start.node !== this.cursor.textNode) { - var blot = _parchment2.default.find(nativeRange.start.node, false); - if (blot == null) return; - // TODO Give blot ability to not split - if (blot instanceof _parchment2.default.Leaf) { - var after = blot.split(nativeRange.start.offset); - blot.parent.insertBefore(this.cursor, after); - } else { - blot.insertBefore(this.cursor, nativeRange.start.node); // Should never happen - } - this.cursor.attach(); - } - this.cursor.format(_format, value); - this.scroll.optimize(); - this.setNativeRange(this.cursor.textNode, this.cursor.textNode.data.length); - this.update(); - } - }, { - key: 'getBounds', - value: function getBounds(index) { - var length = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0; - - var scrollLength = this.scroll.length(); - index = Math.min(index, scrollLength - 1); - length = Math.min(index + length, scrollLength - 1) - index; - var bounds = void 0;var node = void 0; - var _scroll$leaf = this.scroll.leaf(index); - - var _scroll$leaf2 = _slicedToArray(_scroll$leaf, 2); - - var leaf = _scroll$leaf2[0]; - var offset = _scroll$leaf2[1]; - - if (leaf == null) return null; - - var _leaf$position = leaf.position(offset, true); - - var _leaf$position2 = _slicedToArray(_leaf$position, 2); - - node = _leaf$position2[0]; - offset = _leaf$position2[1]; - - var range = document.createRange(); - if (length > 0) { - range.setStart(node, offset); - - var _scroll$leaf3 = this.scroll.leaf(index + length); - - var _scroll$leaf4 = _slicedToArray(_scroll$leaf3, 2); - - leaf = _scroll$leaf4[0]; - offset = _scroll$leaf4[1]; - - if (leaf == null) return null; - - var _leaf$position3 = leaf.position(offset, true); - - var _leaf$position4 = _slicedToArray(_leaf$position3, 2); - - node = _leaf$position4[0]; - offset = _leaf$position4[1]; - - range.setEnd(node, offset); - bounds = range.getBoundingClientRect(); - } else { - var side = 'left'; - if (node instanceof Text) { - if (offset < node.data.length) { - range.setStart(node, offset); - range.setEnd(node, offset + 1); - } else { - range.setStart(node, offset - 1); - range.setEnd(node, offset); - side = 'right'; - } - var rect = range.getBoundingClientRect(); - } else { - var rect = leaf.domNode.getBoundingClientRect(); - if (offset > 0) side = 'right'; - } - bounds = { - height: rect.height, - left: rect[side], - width: 0, - top: rect.top - }; - } - var containerBounds = this.root.parentNode.getBoundingClientRect(); - return { - left: bounds.left - containerBounds.left, - right: bounds.left + bounds.width - containerBounds.left, - top: bounds.top - containerBounds.top, - bottom: bounds.top + bounds.height - containerBounds.top, - height: bounds.height, - width: bounds.width - }; - } - }, { - key: 'getNativeRange', - value: function getNativeRange() { - var selection = document.getSelection(); - if (selection == null || selection.rangeCount <= 0) return null; - var nativeRange = selection.getRangeAt(0); - if (nativeRange == null) return null; - if (!contains(this.root, nativeRange.startContainer) || !nativeRange.collapsed && !contains(this.root, nativeRange.endContainer)) { - return null; - } - var range = { - start: { node: nativeRange.startContainer, offset: nativeRange.startOffset }, - end: { node: nativeRange.endContainer, offset: nativeRange.endOffset }, - native: nativeRange - }; - [range.start, range.end].forEach(function (position) { - var node = position.node, - offset = position.offset; - while (!(node instanceof Text) && node.childNodes.length > 0) { - if (node.childNodes.length > offset) { - node = node.childNodes[offset]; - offset = 0; - } else if (node.childNodes.length === offset) { - node = node.lastChild; - offset = node instanceof Text ? node.data.length : node.childNodes.length + 1; - } else { - break; - } - } - position.node = node, position.offset = offset; - }); - debug.info('getNativeRange', range); - return range; - } - }, { - key: 'getRange', - value: function getRange() { - var _this2 = this; - - var range = this.getNativeRange(); - if (range == null) return [null, null]; - var positions = [[range.start.node, range.start.offset]]; - if (!range.native.collapsed) { - positions.push([range.end.node, range.end.offset]); - } - var indexes = positions.map(function (position) { - var _position = _slicedToArray(position, 2); - - var node = _position[0]; - var offset = _position[1]; - - var blot = _parchment2.default.find(node, true); - var index = blot.offset(_this2.scroll); - if (offset === 0) { - return index; - } else if (blot instanceof _parchment2.default.Container) { - return index + blot.length(); - } else { - return index + blot.index(node, offset); - } - }); - var start = Math.min.apply(Math, _toConsumableArray(indexes)), - end = Math.max.apply(Math, _toConsumableArray(indexes)); - return [new Range(start, end - start), range]; - } - }, { - key: 'hasFocus', - value: function hasFocus() { - return document.activeElement === this.root; - } - }, { - key: 'scrollIntoView', - value: function scrollIntoView() { - var range = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : this.lastRange; - - if (range == null) return; - var bounds = this.getBounds(range.index, range.length); - if (bounds == null) return; - if (this.root.offsetHeight < bounds.bottom) { - var _scroll$line = this.scroll.line(Math.min(range.index + range.length, this.scroll.length() - 1)); - - var _scroll$line2 = _slicedToArray(_scroll$line, 1); - - var line = _scroll$line2[0]; - - this.root.scrollTop = line.domNode.offsetTop + line.domNode.offsetHeight - this.root.offsetHeight; - } else if (bounds.top < 0) { - var _scroll$line3 = this.scroll.line(Math.min(range.index, this.scroll.length() - 1)); - - var _scroll$line4 = _slicedToArray(_scroll$line3, 1); - - var _line = _scroll$line4[0]; - - this.root.scrollTop = _line.domNode.offsetTop; - } - } - }, { - key: 'setNativeRange', - value: function setNativeRange(startNode, startOffset) { - var endNode = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : startNode; - var endOffset = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : startOffset; - var force = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : false; - - debug.info('setNativeRange', startNode, startOffset, endNode, endOffset); - if (startNode != null && (this.root.parentNode == null || startNode.parentNode == null || endNode.parentNode == null)) { - return; - } - var selection = document.getSelection(); - if (selection == null) return; - if (startNode != null) { - if (!this.hasFocus()) this.root.focus(); - var nativeRange = this.getNativeRange(); - if (nativeRange == null || force || startNode !== nativeRange.start.node || startOffset !== nativeRange.start.offset || endNode !== nativeRange.end.node || endOffset !== nativeRange.end.offset) { - var range = document.createRange(); - range.setStart(startNode, startOffset); - range.setEnd(endNode, endOffset); - selection.removeAllRanges(); - selection.addRange(range); - } - } else { - selection.removeAllRanges(); - this.root.blur(); - document.body.focus(); // root.blur() not enough on IE11+Travis+SauceLabs (but not local VMs) - } - } - }, { - key: 'setRange', - value: function setRange(range) { - var _this3 = this; - - var force = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false; - var source = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : _emitter4.default.sources.API; - - if (typeof force === 'string') { - source = force; - force = false; - } - debug.info('setRange', range); - if (range != null) { - (function () { - var indexes = range.collapsed ? [range.index] : [range.index, range.index + range.length]; - var args = []; - var scrollLength = _this3.scroll.length(); - indexes.forEach(function (index, i) { - index = Math.min(scrollLength - 1, index); - var node = void 0; - var _scroll$leaf5 = _this3.scroll.leaf(index); - - var _scroll$leaf6 = _slicedToArray(_scroll$leaf5, 2); - - var leaf = _scroll$leaf6[0]; - var offset = _scroll$leaf6[1]; - - var _leaf$position5 = leaf.position(offset, i !== 0); - - var _leaf$position6 = _slicedToArray(_leaf$position5, 2); - - node = _leaf$position6[0]; - offset = _leaf$position6[1]; - - args.push(node, offset); - }); - if (args.length < 2) { - args = args.concat(args); - } - _this3.setNativeRange.apply(_this3, _toConsumableArray(args).concat([force])); - })(); - } else { - this.setNativeRange(null); - } - this.update(source); - } - }, { - key: 'update', - value: function update() { - var source = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : _emitter4.default.sources.USER; - - var nativeRange = void 0, - oldRange = this.lastRange; - - var _getRange = this.getRange(); - - var _getRange2 = _slicedToArray(_getRange, 2); - - this.lastRange = _getRange2[0]; - nativeRange = _getRange2[1]; - - if (this.lastRange != null) { - this.savedRange = this.lastRange; - } - if (!(0, _deepEqual2.default)(oldRange, this.lastRange)) { - var _emitter; - - if (!this.composing && nativeRange != null && nativeRange.native.collapsed && nativeRange.start.node !== this.cursor.textNode) { - this.cursor.restore(); - } - var args = [_emitter4.default.events.SELECTION_CHANGE, (0, _clone2.default)(this.lastRange), (0, _clone2.default)(oldRange), source]; - (_emitter = this.emitter).emit.apply(_emitter, [_emitter4.default.events.EDITOR_CHANGE].concat(args)); - if (source !== _emitter4.default.sources.SILENT) { - var _emitter2; - - (_emitter2 = this.emitter).emit.apply(_emitter2, args); - } - } - } - }]); - - return Selection; - }(); - - function contains(parent, descendant) { - try { - // Firefox inserts inaccessible nodes around video elements - descendant.parentNode; - } catch (e) { - return false; - } - // IE11 has bug with Text nodes - // https://connect.microsoft.com/IE/feedback/details/780874/node-contains-is-incorrect - if (descendant instanceof Text) { - descendant = descendant.parentNode; - } - return parent.contains(descendant); - } - - exports.Range = Range; - exports.default = Selection; - -/***/ }, -/* 41 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - Object.defineProperty(exports, "__esModule", { - value: true - }); - - var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); - - var _extend = __webpack_require__(25); - - var _extend2 = _interopRequireDefault(_extend); - - var _emitter = __webpack_require__(28); - - var _emitter2 = _interopRequireDefault(_emitter); - - function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - - function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } - - var Theme = function () { - function Theme(quill, options) { - _classCallCheck(this, Theme); - - this.quill = quill; - this.options = options; - this.modules = {}; - } - - _createClass(Theme, [{ - key: 'init', - value: function init() { - var _this = this; - - Object.keys(this.options.modules).forEach(function (name) { - if (_this.modules[name] == null) { - _this.addModule(name); - } - }); - } - }, { - key: 'addModule', - value: function addModule(name) { - var moduleClass = this.quill.constructor.import('modules/' + name); - this.modules[name] = new moduleClass(this.quill, this.options.modules[name] || {}); - return this.modules[name]; - } - }]); - - return Theme; - }(); - - Theme.DEFAULTS = { - modules: {} - }; - Theme.themes = { - 'default': Theme - }; - - exports.default = Theme; - -/***/ }, -/* 42 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - Object.defineProperty(exports, "__esModule", { - value: true - }); - - var _parchment = __webpack_require__(2); - - var _parchment2 = _interopRequireDefault(_parchment); - - var _block = __webpack_require__(32); - - var _block2 = _interopRequireDefault(_block); - - function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - - function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } - - function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } - - function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } - - var Container = function (_Parchment$Container) { - _inherits(Container, _Parchment$Container); - - function Container() { - _classCallCheck(this, Container); - - return _possibleConstructorReturn(this, (Container.__proto__ || Object.getPrototypeOf(Container)).apply(this, arguments)); - } - - return Container; - }(_parchment2.default.Container); - - Container.allowedChildren = [_block2.default, _block.BlockEmbed, Container]; - - exports.default = Container; - -/***/ }, -/* 43 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - Object.defineProperty(exports, "__esModule", { - value: true - }); - - var _slicedToArray = function () { function sliceIterator(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"]) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } return function (arr, i) { if (Array.isArray(arr)) { return arr; } else if (Symbol.iterator in Object(arr)) { return sliceIterator(arr, i); } else { throw new TypeError("Invalid attempt to destructure non-iterable instance"); } }; }(); - - var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); - - var _get = function get(object, property, receiver) { if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { return get(parent, property, receiver); } } else if ("value" in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } }; - - var _parchment = __webpack_require__(2); - - var _parchment2 = _interopRequireDefault(_parchment); - - var _emitter = __webpack_require__(28); - - var _emitter2 = _interopRequireDefault(_emitter); - - var _block = __webpack_require__(32); - - var _block2 = _interopRequireDefault(_block); - - var _break = __webpack_require__(33); - - var _break2 = _interopRequireDefault(_break); - - var _container = __webpack_require__(42); - - var _container2 = _interopRequireDefault(_container); - - var _code = __webpack_require__(31); - - var _code2 = _interopRequireDefault(_code); - - function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - - function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } - - function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } - - function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } - - function isLine(blot) { - return blot instanceof _block2.default || blot instanceof _block.BlockEmbed; - } - - var Scroll = function (_Parchment$Scroll) { - _inherits(Scroll, _Parchment$Scroll); - - function Scroll(domNode, config) { - _classCallCheck(this, Scroll); - - var _this = _possibleConstructorReturn(this, (Scroll.__proto__ || Object.getPrototypeOf(Scroll)).call(this, domNode)); - - _this.emitter = config.emitter; - if (Array.isArray(config.whitelist)) { - _this.whitelist = config.whitelist.reduce(function (whitelist, format) { - whitelist[format] = true; - return whitelist; - }, {}); - } - _this.optimize(); - return _this; - } - - _createClass(Scroll, [{ - key: 'deleteAt', - value: function deleteAt(index, length) { - var _line = this.line(index); - - var _line2 = _slicedToArray(_line, 2); - - var first = _line2[0]; - var offset = _line2[1]; - - var _line3 = this.line(index + length); - - var _line4 = _slicedToArray(_line3, 1); - - var last = _line4[0]; - - _get(Scroll.prototype.__proto__ || Object.getPrototypeOf(Scroll.prototype), 'deleteAt', this).call(this, index, length); - if (last != null && first !== last && offset > 0 && !(first instanceof _block.BlockEmbed) && !(last instanceof _block.BlockEmbed)) { - if (last instanceof _code2.default) { - last.deleteAt(last.length() - 1, 1); - } - var ref = last.children.head instanceof _break2.default ? null : last.children.head; - first.moveChildren(last, ref); - first.remove(); - } - this.optimize(); - } - }, { - key: 'formatAt', - value: function formatAt(index, length, format, value) { - if (this.whitelist != null && !this.whitelist[format]) return; - _get(Scroll.prototype.__proto__ || Object.getPrototypeOf(Scroll.prototype), 'formatAt', this).call(this, index, length, format, value); - this.optimize(); - } - }, { - key: 'insertAt', - value: function insertAt(index, value, def) { - if (def != null && this.whitelist != null && !this.whitelist[value]) return; - if (index >= this.length()) { - if (def == null || _parchment2.default.query(value, _parchment2.default.Scope.BLOCK) == null) { - var blot = _parchment2.default.create(this.statics.defaultChild); - this.appendChild(blot); - if (def == null && value.endsWith('\n')) { - value = value.slice(0, -1); - } - blot.insertAt(0, value, def); - } else { - var embed = _parchment2.default.create(value, def); - this.appendChild(embed); - } - } else { - _get(Scroll.prototype.__proto__ || Object.getPrototypeOf(Scroll.prototype), 'insertAt', this).call(this, index, value, def); - } - this.optimize(); - } - }, { - key: 'insertBefore', - value: function insertBefore(blot, ref) { - if (blot.statics.scope === _parchment2.default.Scope.INLINE_BLOT) { - var wrapper = _parchment2.default.create(this.statics.defaultChild); - wrapper.appendChild(blot); - blot = wrapper; - } - _get(Scroll.prototype.__proto__ || Object.getPrototypeOf(Scroll.prototype), 'insertBefore', this).call(this, blot, ref); - } - }, { - key: 'leaf', - value: function leaf(index) { - return this.path(index).pop() || [null, -1]; - } - }, { - key: 'line', - value: function line(index) { - return this.descendant(isLine, index); - } - }, { - key: 'lines', - value: function lines() { - var index = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0; - var length = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : Number.MAX_VALUE; - - var getLines = function getLines(blot, index, length) { - var lines = [], - lengthLeft = length; - blot.children.forEachAt(index, length, function (child, index, length) { - if (isLine(child)) { - lines.push(child); - } else if (child instanceof _parchment2.default.Container) { - lines = lines.concat(getLines(child, index, lengthLeft)); - } - lengthLeft -= length; - }); - return lines; - }; - return getLines(this, index, length); - } - }, { - key: 'optimize', - value: function optimize() { - var mutations = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : []; - - if (this.batch === true) return; - _get(Scroll.prototype.__proto__ || Object.getPrototypeOf(Scroll.prototype), 'optimize', this).call(this, mutations); - if (mutations.length > 0) { - this.emitter.emit(_emitter2.default.events.SCROLL_OPTIMIZE, mutations); - } - } - }, { - key: 'path', - value: function path(index) { - return _get(Scroll.prototype.__proto__ || Object.getPrototypeOf(Scroll.prototype), 'path', this).call(this, index).slice(1); // Exclude self - } - }, { - key: 'update', - value: function update(mutations) { - if (this.batch === true) return; - var source = _emitter2.default.sources.USER; - if (typeof mutations === 'string') { - source = mutations; - } - if (!Array.isArray(mutations)) { - mutations = this.observer.takeRecords(); - } - if (mutations.length > 0) { - this.emitter.emit(_emitter2.default.events.SCROLL_BEFORE_UPDATE, source, mutations); - } - _get(Scroll.prototype.__proto__ || Object.getPrototypeOf(Scroll.prototype), 'update', this).call(this, mutations.concat([])); // pass copy - if (mutations.length > 0) { - this.emitter.emit(_emitter2.default.events.SCROLL_UPDATE, source, mutations); - } - } - }]); - - return Scroll; - }(_parchment2.default.Scroll); - - Scroll.blotName = 'scroll'; - Scroll.className = 'ql-editor'; - Scroll.tagName = 'DIV'; - Scroll.defaultChild = 'block'; - Scroll.allowedChildren = [_block2.default, _block.BlockEmbed, _container2.default]; - - exports.default = Scroll; - -/***/ }, -/* 44 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - Object.defineProperty(exports, "__esModule", { - value: true - }); - exports.matchText = exports.matchSpacing = exports.matchNewline = exports.matchBlot = exports.matchAttributor = exports.default = undefined; - - var _slicedToArray = function () { function sliceIterator(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"]) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } return function (arr, i) { if (Array.isArray(arr)) { return arr; } else if (Symbol.iterator in Object(arr)) { return sliceIterator(arr, i); } else { throw new TypeError("Invalid attempt to destructure non-iterable instance"); } }; }(); - - var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); - - var _delta = __webpack_require__(20); - - var _delta2 = _interopRequireDefault(_delta); - - var _parchment = __webpack_require__(2); - - var _parchment2 = _interopRequireDefault(_parchment); - - var _quill = __webpack_require__(18); - - var _quill2 = _interopRequireDefault(_quill); - - var _logger = __webpack_require__(30); - - var _logger2 = _interopRequireDefault(_logger); - - var _module = __webpack_require__(39); - - var _module2 = _interopRequireDefault(_module); - - var _align = __webpack_require__(45); - - var _background = __webpack_require__(46); - - var _color = __webpack_require__(47); - - var _direction = __webpack_require__(48); - - var _font = __webpack_require__(49); - - var _size = __webpack_require__(50); - - function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - - function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } - - function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } } - - function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } - - function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } - - function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } - - var debug = (0, _logger2.default)('quill:clipboard'); - - var CLIPBOARD_CONFIG = [[Node.TEXT_NODE, matchText], ['br', matchBreak], [Node.ELEMENT_NODE, matchNewline], [Node.ELEMENT_NODE, matchBlot], [Node.ELEMENT_NODE, matchSpacing], [Node.ELEMENT_NODE, matchAttributor], [Node.ELEMENT_NODE, matchStyles], ['b', matchAlias.bind(matchAlias, 'bold')], ['i', matchAlias.bind(matchAlias, 'italic')], ['style', matchIgnore]]; - - var ATTRIBUTE_ATTRIBUTORS = [_align.AlignAttribute, _direction.DirectionAttribute].reduce(function (memo, attr) { - memo[attr.keyName] = attr; - return memo; - }, {}); - - var STYLE_ATTRIBUTORS = [_align.AlignStyle, _background.BackgroundStyle, _color.ColorStyle, _direction.DirectionStyle, _font.FontStyle, _size.SizeStyle].reduce(function (memo, attr) { - memo[attr.keyName] = attr; - return memo; - }, {}); - - var Clipboard = function (_Module) { - _inherits(Clipboard, _Module); - - function Clipboard(quill, options) { - _classCallCheck(this, Clipboard); - - var _this = _possibleConstructorReturn(this, (Clipboard.__proto__ || Object.getPrototypeOf(Clipboard)).call(this, quill, options)); - - _this.quill.root.addEventListener('paste', _this.onPaste.bind(_this)); - _this.container = _this.quill.addContainer('ql-clipboard'); - _this.container.setAttribute('contenteditable', true); - _this.container.setAttribute('tabindex', -1); - _this.matchers = []; - CLIPBOARD_CONFIG.concat(_this.options.matchers).forEach(function (pair) { - _this.addMatcher.apply(_this, _toConsumableArray(pair)); - }); - return _this; - } - - _createClass(Clipboard, [{ - key: 'addMatcher', - value: function addMatcher(selector, matcher) { - this.matchers.push([selector, matcher]); - } - }, { - key: 'convert', - value: function convert(html) { - var _this2 = this; - - var DOM_KEY = '__ql-matcher'; - if (typeof html === 'string') { - this.container.innerHTML = html; - } - var textMatchers = [], - elementMatchers = []; - this.matchers.forEach(function (pair) { - var _pair = _slicedToArray(pair, 2); - - var selector = _pair[0]; - var matcher = _pair[1]; - - switch (selector) { - case Node.TEXT_NODE: - textMatchers.push(matcher); - break; - case Node.ELEMENT_NODE: - elementMatchers.push(matcher); - break; - default: - [].forEach.call(_this2.container.querySelectorAll(selector), function (node) { - // TODO use weakmap - node[DOM_KEY] = node[DOM_KEY] || []; - node[DOM_KEY].push(matcher); - }); - break; - } - }); - var traverse = function traverse(node) { - // Post-order - if (node.nodeType === node.TEXT_NODE) { - return textMatchers.reduce(function (delta, matcher) { - return matcher(node, delta); - }, new _delta2.default()); - } else if (node.nodeType === node.ELEMENT_NODE) { - return [].reduce.call(node.childNodes || [], function (delta, childNode) { - var childrenDelta = traverse(childNode); - if (childNode.nodeType === node.ELEMENT_NODE) { - childrenDelta = elementMatchers.reduce(function (childrenDelta, matcher) { - return matcher(childNode, childrenDelta); - }, childrenDelta); - childrenDelta = (childNode[DOM_KEY] || []).reduce(function (childrenDelta, matcher) { - return matcher(childNode, childrenDelta); - }, childrenDelta); - } - return delta.concat(childrenDelta); - }, new _delta2.default()); - } else { - return new _delta2.default(); - } - }; - var delta = traverse(this.container); - // Remove trailing newline - if (deltaEndsWith(delta, '\n') && delta.ops[delta.ops.length - 1].attributes == null) { - delta = delta.compose(new _delta2.default().retain(delta.length() - 1).delete(1)); - } - debug.log('convert', this.container.innerHTML, delta); - this.container.innerHTML = ''; - return delta; - } - }, { - key: 'dangerouslyPasteHTML', - value: function dangerouslyPasteHTML(index, html) { - var source = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : _quill2.default.sources.API; - - if (typeof index === 'string') { - return this.quill.setContents(this.convert(index), html); - } else { - var paste = this.convert(html); - return this.quill.updateContents(new _delta2.default().retain(index).concat(paste), source); - } - } - }, { - key: 'onPaste', - value: function onPaste(e) { - var _this3 = this; - - if (e.defaultPrevented) return; - var range = this.quill.getSelection(); - var delta = new _delta2.default().retain(range.index).delete(range.length); - var bodyTop = document.body.scrollTop; - this.container.focus(); - setTimeout(function () { - _this3.quill.selection.update(_quill2.default.sources.SILENT); - delta = delta.concat(_this3.convert()); - _this3.quill.updateContents(delta, _quill2.default.sources.USER); - // range.length contributes to delta.length() - _this3.quill.setSelection(delta.length() - range.length, _quill2.default.sources.SILENT); - document.body.scrollTop = bodyTop; - _this3.quill.selection.scrollIntoView(); - }, 1); - } - }]); - - return Clipboard; - }(_module2.default); - - Clipboard.DEFAULTS = { - matchers: [] - }; - - function computeStyle(node) { - if (node.nodeType !== Node.ELEMENT_NODE) return {}; - var DOM_KEY = '__ql-computed-style'; - return node[DOM_KEY] || (node[DOM_KEY] = window.getComputedStyle(node)); - } - - function deltaEndsWith(delta, text) { - var endText = ""; - for (var i = delta.ops.length - 1; i >= 0 && endText.length < text.length; --i) { - var op = delta.ops[i]; - if (typeof op.insert !== 'string') break; - endText = op.insert + endText; - } - return endText.slice(-1 * text.length) === text; - } - - function isLine(node) { - if (node.childNodes.length === 0) return false; // Exclude embed blocks - var style = computeStyle(node); - return ['block', 'list-item'].indexOf(style.display) > -1; - } - - function matchAlias(format, node, delta) { - return delta.compose(new _delta2.default().retain(delta.length(), _defineProperty({}, format, true))); - } - - function matchAttributor(node, delta) { - var attributes = _parchment2.default.Attributor.Attribute.keys(node); - var classes = _parchment2.default.Attributor.Class.keys(node); - var styles = _parchment2.default.Attributor.Style.keys(node); - var formats = {}; - attributes.concat(classes).concat(styles).forEach(function (name) { - var attr = _parchment2.default.query(name, _parchment2.default.Scope.ATTRIBUTE); - if (attr != null) { - formats[attr.attrName] = attr.value(node); - if (formats[attr.attrName]) return; - } - if (ATTRIBUTE_ATTRIBUTORS[name] != null) { - attr = ATTRIBUTE_ATTRIBUTORS[name]; - formats[attr.attrName] = attr.value(node); - } - if (STYLE_ATTRIBUTORS[name] != null) { - attr = STYLE_ATTRIBUTORS[name]; - formats[attr.attrName] = attr.value(node); - } - }); - if (Object.keys(formats).length > 0) { - delta = delta.compose(new _delta2.default().retain(delta.length(), formats)); - } - return delta; - } - - function matchBlot(node, delta) { - var match = _parchment2.default.query(node); - if (match == null) return delta; - if (match.prototype instanceof _parchment2.default.Embed) { - var embed = {}; - var value = match.value(node); - if (value != null) { - embed[match.blotName] = value; - delta = new _delta2.default().insert(embed, match.formats(node)); - } - } else if (typeof match.formats === 'function') { - var formats = _defineProperty({}, match.blotName, match.formats(node)); - delta = delta.compose(new _delta2.default().retain(delta.length(), formats)); - } - return delta; - } - - function matchBreak(node, delta) { - if (!deltaEndsWith(delta, '\n')) { - delta.insert('\n'); - } - return delta; - } - - function matchIgnore(node, delta) { - return new _delta2.default(); - } - - function matchNewline(node, delta) { - if (isLine(node) && !deltaEndsWith(delta, '\n')) { - delta.insert('\n'); - } - return delta; - } - - function matchSpacing(node, delta) { - if (isLine(node) && node.nextElementSibling != null && !deltaEndsWith(delta, '\n\n')) { - var nodeHeight = node.offsetHeight + parseFloat(computeStyle(node).marginTop) + parseFloat(computeStyle(node).marginBottom); - if (node.nextElementSibling.offsetTop > node.offsetTop + nodeHeight * 1.5) { - delta.insert('\n'); - } - } - return delta; - } - - function matchStyles(node, delta) { - var formats = {}; - var style = node.style || {}; - if (style.fontWeight && computeStyle(node).fontWeight === 'bold') { - formats.bold = true; - } - if (Object.keys(formats).length > 0) { - delta = delta.compose(new _delta2.default().retain(delta.length(), formats)); - } - if (parseFloat(style.textIndent || 0) > 0) { - // Could be 0.5in - delta = new _delta2.default().insert('\t').concat(delta); - } - return delta; - } - - function matchText(node, delta) { - var text = node.data; - // Word represents empty line with   - if (node.parentNode.tagName === 'O:P') { - return delta.insert(text.trim()); - } - if (!computeStyle(node.parentNode).whiteSpace.startsWith('pre')) { - var replacer = function replacer(collapse, match) { - match = match.replace(/[^\u00a0]/g, ''); // \u00a0 is nbsp; - return match.length < 1 && collapse ? ' ' : match; - }; - - text = text.replace(/\r\n/g, ' ').replace(/\n/g, ' '); - text = text.replace(/\s\s+/g, replacer.bind(replacer, true)); // collapse whitespace - if (node.previousSibling == null && isLine(node.parentNode) || node.previousSibling != null && isLine(node.previousSibling)) { - text = text.replace(/^\s+/, replacer.bind(replacer, false)); - } - if (node.nextSibling == null && isLine(node.parentNode) || node.nextSibling != null && isLine(node.nextSibling)) { - text = text.replace(/\s+$/, replacer.bind(replacer, false)); - } - } - return delta.insert(text); - } - - exports.default = Clipboard; - exports.matchAttributor = matchAttributor; - exports.matchBlot = matchBlot; - exports.matchNewline = matchNewline; - exports.matchSpacing = matchSpacing; - exports.matchText = matchText; - -/***/ }, -/* 45 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - Object.defineProperty(exports, "__esModule", { - value: true - }); - exports.AlignStyle = exports.AlignClass = exports.AlignAttribute = undefined; - - var _parchment = __webpack_require__(2); - - var _parchment2 = _interopRequireDefault(_parchment); - - function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - - var config = { - scope: _parchment2.default.Scope.BLOCK, - whitelist: ['right', 'center', 'justify'] - }; - - var AlignAttribute = new _parchment2.default.Attributor.Attribute('align', 'align', config); - var AlignClass = new _parchment2.default.Attributor.Class('align', 'ql-align', config); - var AlignStyle = new _parchment2.default.Attributor.Style('align', 'text-align', config); - - exports.AlignAttribute = AlignAttribute; - exports.AlignClass = AlignClass; - exports.AlignStyle = AlignStyle; - -/***/ }, -/* 46 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - Object.defineProperty(exports, "__esModule", { - value: true - }); - exports.BackgroundStyle = exports.BackgroundClass = undefined; - - var _parchment = __webpack_require__(2); - - var _parchment2 = _interopRequireDefault(_parchment); - - var _color = __webpack_require__(47); - - function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - - var BackgroundClass = new _parchment2.default.Attributor.Class('background', 'ql-bg', { - scope: _parchment2.default.Scope.INLINE - }); - var BackgroundStyle = new _color.ColorAttributor('background', 'background-color', { - scope: _parchment2.default.Scope.INLINE - }); - - exports.BackgroundClass = BackgroundClass; - exports.BackgroundStyle = BackgroundStyle; - -/***/ }, -/* 47 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - Object.defineProperty(exports, "__esModule", { - value: true - }); - exports.ColorStyle = exports.ColorClass = exports.ColorAttributor = undefined; - - var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); - - var _get = function get(object, property, receiver) { if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { return get(parent, property, receiver); } } else if ("value" in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } }; - - var _parchment = __webpack_require__(2); - - var _parchment2 = _interopRequireDefault(_parchment); - - function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - - function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } - - function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } - - function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } - - var ColorAttributor = function (_Parchment$Attributor) { - _inherits(ColorAttributor, _Parchment$Attributor); - - function ColorAttributor() { - _classCallCheck(this, ColorAttributor); - - return _possibleConstructorReturn(this, (ColorAttributor.__proto__ || Object.getPrototypeOf(ColorAttributor)).apply(this, arguments)); - } - - _createClass(ColorAttributor, [{ - key: 'value', - value: function value(domNode) { - var value = _get(ColorAttributor.prototype.__proto__ || Object.getPrototypeOf(ColorAttributor.prototype), 'value', this).call(this, domNode); - if (!value.startsWith('rgb(')) return value; - value = value.replace(/^[^\d]+/, '').replace(/[^\d]+$/, ''); - return '#' + value.split(',').map(function (component) { - return ('00' + parseInt(component).toString(16)).slice(-2); - }).join(''); - } - }]); - - return ColorAttributor; - }(_parchment2.default.Attributor.Style); - - var ColorClass = new _parchment2.default.Attributor.Class('color', 'ql-color', { - scope: _parchment2.default.Scope.INLINE - }); - var ColorStyle = new ColorAttributor('color', 'color', { - scope: _parchment2.default.Scope.INLINE - }); - - exports.ColorAttributor = ColorAttributor; - exports.ColorClass = ColorClass; - exports.ColorStyle = ColorStyle; - -/***/ }, -/* 48 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - Object.defineProperty(exports, "__esModule", { - value: true - }); - exports.DirectionStyle = exports.DirectionClass = exports.DirectionAttribute = undefined; - - var _parchment = __webpack_require__(2); - - var _parchment2 = _interopRequireDefault(_parchment); - - function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - - var config = { - scope: _parchment2.default.Scope.BLOCK, - whitelist: ['rtl'] - }; - - var DirectionAttribute = new _parchment2.default.Attributor.Attribute('direction', 'dir', config); - var DirectionClass = new _parchment2.default.Attributor.Class('direction', 'ql-direction', config); - var DirectionStyle = new _parchment2.default.Attributor.Style('direction', 'direction', config); - - exports.DirectionAttribute = DirectionAttribute; - exports.DirectionClass = DirectionClass; - exports.DirectionStyle = DirectionStyle; - -/***/ }, -/* 49 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - Object.defineProperty(exports, "__esModule", { - value: true - }); - exports.FontClass = exports.FontStyle = undefined; - - var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); - - var _get = function get(object, property, receiver) { if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { return get(parent, property, receiver); } } else if ("value" in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } }; - - var _parchment = __webpack_require__(2); - - var _parchment2 = _interopRequireDefault(_parchment); - - function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - - function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } - - function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } - - function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } - - var config = { - scope: _parchment2.default.Scope.INLINE, - whitelist: ['serif', 'monospace'] - }; - - var FontClass = new _parchment2.default.Attributor.Class('font', 'ql-font', config); - - var FontStyleAttributor = function (_Parchment$Attributor) { - _inherits(FontStyleAttributor, _Parchment$Attributor); - - function FontStyleAttributor() { - _classCallCheck(this, FontStyleAttributor); - - return _possibleConstructorReturn(this, (FontStyleAttributor.__proto__ || Object.getPrototypeOf(FontStyleAttributor)).apply(this, arguments)); - } - - _createClass(FontStyleAttributor, [{ - key: 'value', - value: function value(node) { - return _get(FontStyleAttributor.prototype.__proto__ || Object.getPrototypeOf(FontStyleAttributor.prototype), 'value', this).call(this, node).replace(/["']/g, ''); - } - }]); - - return FontStyleAttributor; - }(_parchment2.default.Attributor.Style); - - var FontStyle = new FontStyleAttributor('font', 'font-family', config); - - exports.FontStyle = FontStyle; - exports.FontClass = FontClass; - -/***/ }, -/* 50 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - Object.defineProperty(exports, "__esModule", { - value: true - }); - exports.SizeStyle = exports.SizeClass = undefined; - - var _parchment = __webpack_require__(2); - - var _parchment2 = _interopRequireDefault(_parchment); - - function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - - var SizeClass = new _parchment2.default.Attributor.Class('size', 'ql-size', { - scope: _parchment2.default.Scope.INLINE, - whitelist: ['small', 'large', 'huge'] - }); - var SizeStyle = new _parchment2.default.Attributor.Style('size', 'font-size', { - scope: _parchment2.default.Scope.INLINE, - whitelist: ['10px', '18px', '32px'] - }); - - exports.SizeClass = SizeClass; - exports.SizeStyle = SizeStyle; - -/***/ }, -/* 51 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - Object.defineProperty(exports, "__esModule", { - value: true - }); - exports.getLastChangeIndex = exports.default = undefined; - - var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); - - var _parchment = __webpack_require__(2); - - var _parchment2 = _interopRequireDefault(_parchment); - - var _quill = __webpack_require__(18); - - var _quill2 = _interopRequireDefault(_quill); - - var _module = __webpack_require__(39); - - var _module2 = _interopRequireDefault(_module); - - function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - - function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } - - function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } - - function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } - - var History = function (_Module) { - _inherits(History, _Module); - - function History(quill, options) { - _classCallCheck(this, History); - - var _this = _possibleConstructorReturn(this, (History.__proto__ || Object.getPrototypeOf(History)).call(this, quill, options)); - - _this.lastRecorded = 0; - _this.ignoreChange = false; - _this.clear(); - _this.quill.on(_quill2.default.events.EDITOR_CHANGE, function (eventName, delta, oldDelta, source) { - if (eventName !== _quill2.default.events.TEXT_CHANGE || _this.ignoreChange) return; - if (!_this.options.userOnly || source === _quill2.default.sources.USER) { - _this.record(delta, oldDelta); - } else { - _this.transform(delta); - } - }); - _this.quill.keyboard.addBinding({ key: 'Z', shortKey: true }, _this.undo.bind(_this)); - _this.quill.keyboard.addBinding({ key: 'Z', shortKey: true, shiftKey: true }, _this.redo.bind(_this)); - if (/Win/i.test(navigator.platform)) { - _this.quill.keyboard.addBinding({ key: 'Y', shortKey: true }, _this.redo.bind(_this)); - } - return _this; - } - - _createClass(History, [{ - key: 'change', - value: function change(source, dest) { - if (this.stack[source].length === 0) return; - var delta = this.stack[source].pop(); - this.lastRecorded = 0; - this.ignoreChange = true; - this.quill.updateContents(delta[source], _quill2.default.sources.USER); - this.ignoreChange = false; - var index = getLastChangeIndex(delta[source]); - this.quill.setSelection(index); - this.quill.selection.scrollIntoView(); - this.stack[dest].push(delta); - } - }, { - key: 'clear', - value: function clear() { - this.stack = { undo: [], redo: [] }; - } - }, { - key: 'record', - value: function record(changeDelta, oldDelta) { - if (changeDelta.ops.length === 0) return; - this.stack.redo = []; - var undoDelta = this.quill.getContents().diff(oldDelta); - var timestamp = Date.now(); - if (this.lastRecorded + this.options.delay > timestamp && this.stack.undo.length > 0) { - var delta = this.stack.undo.pop(); - undoDelta = undoDelta.compose(delta.undo); - changeDelta = delta.redo.compose(changeDelta); - } else { - this.lastRecorded = timestamp; - } - this.stack.undo.push({ - redo: changeDelta, - undo: undoDelta - }); - if (this.stack.undo.length > this.options.maxStack) { - this.stack.undo.shift(); - } - } - }, { - key: 'redo', - value: function redo() { - this.change('redo', 'undo'); - } - }, { - key: 'transform', - value: function transform(delta) { - this.stack.undo.forEach(function (change) { - change.undo = delta.transform(change.undo, true); - change.redo = delta.transform(change.redo, true); - }); - this.stack.redo.forEach(function (change) { - change.undo = delta.transform(change.undo, true); - change.redo = delta.transform(change.redo, true); - }); - } - }, { - key: 'undo', - value: function undo() { - this.change('undo', 'redo'); - } - }]); - - return History; - }(_module2.default); - - History.DEFAULTS = { - delay: 1000, - maxStack: 100, - userOnly: false - }; - - function endsWithNewlineChange(delta) { - var lastOp = delta.ops[delta.ops.length - 1]; - if (lastOp == null) return false; - if (lastOp.insert != null) { - return typeof lastOp.insert === 'string' && lastOp.insert.endsWith('\n'); - } - if (lastOp.attributes != null) { - return Object.keys(lastOp.attributes).some(function (attr) { - return _parchment2.default.query(attr, _parchment2.default.Scope.BLOCK) != null; - }); - } - return false; - } - - function getLastChangeIndex(delta) { - var deleteLength = delta.ops.reduce(function (length, op) { - length += op.delete || 0; - return length; - }, 0); - var changeIndex = delta.length() - deleteLength; - if (endsWithNewlineChange(delta)) { - changeIndex -= 1; - } - return changeIndex; - } - - exports.default = History; - exports.getLastChangeIndex = getLastChangeIndex; - -/***/ }, -/* 52 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - Object.defineProperty(exports, "__esModule", { - value: true - }); - - var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; - - var _slicedToArray = function () { function sliceIterator(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"]) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } return function (arr, i) { if (Array.isArray(arr)) { return arr; } else if (Symbol.iterator in Object(arr)) { return sliceIterator(arr, i); } else { throw new TypeError("Invalid attempt to destructure non-iterable instance"); } }; }(); - - var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); - - var _clone = __webpack_require__(38); - - var _clone2 = _interopRequireDefault(_clone); - - var _deepEqual = __webpack_require__(22); - - var _deepEqual2 = _interopRequireDefault(_deepEqual); - - var _extend = __webpack_require__(25); - - var _extend2 = _interopRequireDefault(_extend); - - var _delta = __webpack_require__(20); - - var _delta2 = _interopRequireDefault(_delta); - - var _op = __webpack_require__(26); - - var _op2 = _interopRequireDefault(_op); - - var _parchment = __webpack_require__(2); - - var _parchment2 = _interopRequireDefault(_parchment); - - var _quill = __webpack_require__(18); - - var _quill2 = _interopRequireDefault(_quill); - - var _logger = __webpack_require__(30); - - var _logger2 = _interopRequireDefault(_logger); - - var _module = __webpack_require__(39); - - var _module2 = _interopRequireDefault(_module); - - var _block = __webpack_require__(32); - - var _block2 = _interopRequireDefault(_block); - - function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - - function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } - - function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } - - function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } - - var debug = (0, _logger2.default)('quill:keyboard'); - - var SHORTKEY = /Mac/i.test(navigator.platform) ? 'metaKey' : 'ctrlKey'; - - var Keyboard = function (_Module) { - _inherits(Keyboard, _Module); - - _createClass(Keyboard, null, [{ - key: 'match', - value: function match(evt, binding) { - binding = normalize(binding); - if (!!binding.shortKey !== evt[SHORTKEY] && binding.shortKey !== null) return false; - if (['altKey', 'ctrlKey', 'metaKey', 'shiftKey'].some(function (key) { - return key != SHORTKEY && !!binding[key] !== evt[key] && binding[key] !== null; - })) { - return false; - } - return binding.key === (evt.which || evt.keyCode); - } - }]); - - function Keyboard(quill, options) { - _classCallCheck(this, Keyboard); - - var _this = _possibleConstructorReturn(this, (Keyboard.__proto__ || Object.getPrototypeOf(Keyboard)).call(this, quill, options)); - - _this.bindings = {}; - Object.keys(_this.options.bindings).forEach(function (name) { - if (_this.options.bindings[name]) { - _this.addBinding(_this.options.bindings[name]); - } - }); - _this.addBinding({ key: Keyboard.keys.ENTER, shiftKey: null }, handleEnter); - _this.addBinding({ key: Keyboard.keys.ENTER, metaKey: null, ctrlKey: null, altKey: null }, function () {}); - _this.addBinding({ key: Keyboard.keys.BACKSPACE }, { collapsed: true, prefix: /^.?$/ }, function (range, context) { - if (range.index === 0) return; - - var _quill$scroll$line = this.quill.scroll.line(range.index); - - var _quill$scroll$line2 = _slicedToArray(_quill$scroll$line, 1); - - var line = _quill$scroll$line2[0]; - - var formats = {}; - if (context.offset === 0) { - var curFormats = line.formats(); - var prevFormats = this.quill.getFormat(range.index - 1, 1); - formats = _op2.default.attributes.diff(curFormats, prevFormats) || {}; - } - this.quill.deleteText(range.index - 1, 1, _quill2.default.sources.USER); - if (Object.keys(formats).length > 0) { - this.quill.formatLine(range.index - 1, 1, formats, _quill2.default.sources.USER); - } - this.quill.selection.scrollIntoView(); - }); - _this.addBinding({ key: Keyboard.keys.DELETE }, { collapsed: true, suffix: /^$/ }, function (range) { - if (range.index >= this.quill.getLength() - 1) return; - this.quill.deleteText(range.index, 1, _quill2.default.sources.USER); - }); - _this.addBinding({ key: Keyboard.keys.BACKSPACE }, { collapsed: false }, handleDelete); - _this.addBinding({ key: Keyboard.keys.DELETE }, { collapsed: false }, handleDelete); - _this.listen(); - return _this; - } - - _createClass(Keyboard, [{ - key: 'addBinding', - value: function addBinding(key) { - var context = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; - var handler = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {}; - - var binding = normalize(key); - if (binding == null || binding.key == null) { - return debug.warn('Attempted to add invalid keyboard binding', binding); - } - if (typeof context === 'function') { - context = { handler: context }; - } - if (typeof handler === 'function') { - handler = { handler: handler }; - } - binding = (0, _extend2.default)(binding, context, handler); - this.bindings[binding.key] = this.bindings[binding.key] || []; - this.bindings[binding.key].push(binding); - } - }, { - key: 'listen', - value: function listen() { - var _this2 = this; - - this.quill.root.addEventListener('keydown', function (evt) { - if (evt.defaultPrevented) return; - var which = evt.which || evt.keyCode; - var bindings = (_this2.bindings[which] || []).filter(function (binding) { - return Keyboard.match(evt, binding); - }); - if (bindings.length === 0) return; - var range = _this2.quill.getSelection(); - if (range == null) return; // implies we do not have focus - - var _quill$scroll$line3 = _this2.quill.scroll.line(range.index); - - var _quill$scroll$line4 = _slicedToArray(_quill$scroll$line3, 2); - - var line = _quill$scroll$line4[0]; - var offset = _quill$scroll$line4[1]; - - var _quill$scroll$leaf = _this2.quill.scroll.leaf(range.index); - - var _quill$scroll$leaf2 = _slicedToArray(_quill$scroll$leaf, 2); - - var leafStart = _quill$scroll$leaf2[0]; - var offsetStart = _quill$scroll$leaf2[1]; - - var _ref = range.length === 0 ? [leafStart, offsetStart] : _this2.quill.scroll.leaf(range.index + range.length); - - var _ref2 = _slicedToArray(_ref, 2); - - var leafEnd = _ref2[0]; - var offsetEnd = _ref2[1]; - - var prefixText = leafStart instanceof _parchment2.default.Text ? leafStart.value().slice(0, offsetStart) : ''; - var suffixText = leafEnd instanceof _parchment2.default.Text ? leafEnd.value().slice(offsetEnd) : ''; - var curContext = { - collapsed: range.length === 0, - empty: range.length === 0 && line.length() <= 1, - format: _this2.quill.getFormat(range), - offset: offset, - prefix: prefixText, - suffix: suffixText - }; - var prevented = bindings.some(function (binding) { - if (binding.collapsed != null && binding.collapsed !== curContext.collapsed) return false; - if (binding.empty != null && binding.empty !== curContext.empty) return false; - if (binding.offset != null && binding.offset !== curContext.offset) return false; - if (Array.isArray(binding.format)) { - // any format is present - if (binding.format.every(function (name) { - return curContext.format[name] == null; - })) { - return false; - } - } else if (_typeof(binding.format) === 'object') { - // all formats must match - if (!Object.keys(binding.format).every(function (name) { - if (binding.format[name] === true) return curContext.format[name] != null; - if (binding.format[name] === false) return curContext.format[name] == null; - return (0, _deepEqual2.default)(binding.format[name], curContext.format[name]); - })) { - return false; - } - } - if (binding.prefix != null && !binding.prefix.test(curContext.prefix)) return false; - if (binding.suffix != null && !binding.suffix.test(curContext.suffix)) return false; - return binding.handler.call(_this2, range, curContext) !== true; - }); - if (prevented) { - evt.preventDefault(); - } - }); - } - }]); - - return Keyboard; - }(_module2.default); - - Keyboard.keys = { - BACKSPACE: 8, - TAB: 9, - ENTER: 13, - ESCAPE: 27, - LEFT: 37, - UP: 38, - RIGHT: 39, - DOWN: 40, - DELETE: 46 - }; - - Keyboard.DEFAULTS = { - bindings: { - 'bold': makeFormatHandler('bold'), - 'italic': makeFormatHandler('italic'), - 'underline': makeFormatHandler('underline'), - 'indent': { - // highlight tab or tab at beginning of list, indent or blockquote - key: Keyboard.keys.TAB, - format: ['blockquote', 'indent', 'list'], - handler: function handler(range, context) { - if (context.collapsed && context.offset !== 0) return true; - this.quill.format('indent', '+1', _quill2.default.sources.USER); - } - }, - 'outdent': { - key: Keyboard.keys.TAB, - shiftKey: true, - format: ['blockquote', 'indent', 'list'], - // highlight tab or tab at beginning of list, indent or blockquote - handler: function handler(range, context) { - if (context.collapsed && context.offset !== 0) return true; - this.quill.format('indent', '-1', _quill2.default.sources.USER); - } - }, - 'outdent backspace': { - key: Keyboard.keys.BACKSPACE, - collapsed: true, - format: ['blockquote', 'indent', 'list'], - offset: 0, - handler: function handler(range, context) { - if (context.format.indent != null) { - this.quill.format('indent', '-1', _quill2.default.sources.USER); - } else if (context.format.blockquote != null) { - this.quill.format('blockquote', false, _quill2.default.sources.USER); - } else if (context.format.list != null) { - this.quill.format('list', false, _quill2.default.sources.USER); - } - } - }, - 'indent code-block': makeCodeBlockHandler(true), - 'outdent code-block': makeCodeBlockHandler(false), - 'remove tab': { - key: Keyboard.keys.TAB, - shiftKey: true, - collapsed: true, - prefix: /\t$/, - handler: function handler(range, context) { - this.quill.deleteText(range.index - 1, 1, _quill2.default.sources.USER); - } - }, - 'tab': { - key: Keyboard.keys.TAB, - handler: function handler(range, context) { - if (!context.collapsed) { - this.quill.scroll.deleteAt(range.index, range.length); - } - this.quill.insertText(range.index, '\t', _quill2.default.sources.USER); - this.quill.setSelection(range.index + 1, _quill2.default.sources.SILENT); - } - }, - 'list empty enter': { - key: Keyboard.keys.ENTER, - collapsed: true, - format: ['list'], - empty: true, - handler: function handler(range, context) { - this.quill.format('list', false, _quill2.default.sources.USER); - if (context.format.indent) { - this.quill.format('indent', false, _quill2.default.sources.USER); - } - } - }, - 'header enter': { - key: Keyboard.keys.ENTER, - collapsed: true, - format: ['header'], - suffix: /^$/, - handler: function handler(range) { - this.quill.scroll.insertAt(range.index, '\n'); - this.quill.formatText(range.index + 1, 1, 'header', false, _quill2.default.sources.USER); - this.quill.setSelection(range.index + 1, _quill2.default.sources.SILENT); - this.quill.selection.scrollIntoView(); - } - }, - 'list autofill': { - key: ' ', - collapsed: true, - format: { list: false }, - prefix: /^(1\.|-)$/, - handler: function handler(range, context) { - var length = context.prefix.length; - this.quill.scroll.deleteAt(range.index - length, length); - this.quill.formatLine(range.index - length, 1, 'list', length === 1 ? 'bullet' : 'ordered', _quill2.default.sources.USER); - this.quill.setSelection(range.index - length, _quill2.default.sources.SILENT); - } - } - } - }; - - function handleDelete(range) { - this.quill.deleteText(range, _quill2.default.sources.USER); - this.quill.setSelection(range.index, _quill2.default.sources.SILENT); - this.quill.selection.scrollIntoView(); - } - - function handleEnter(range, context) { - var _this3 = this; - - if (range.length > 0) { - this.quill.scroll.deleteAt(range.index, range.length); // So we do not trigger text-change - } - var lineFormats = Object.keys(context.format).reduce(function (lineFormats, format) { - if (_parchment2.default.query(format, _parchment2.default.Scope.BLOCK) && !Array.isArray(context.format[format])) { - lineFormats[format] = context.format[format]; - } - return lineFormats; - }, {}); - this.quill.insertText(range.index, '\n', lineFormats, _quill2.default.sources.USER); - this.quill.selection.scrollIntoView(); - Object.keys(context.format).forEach(function (name) { - if (lineFormats[name] != null) return; - if (Array.isArray(context.format[name])) return; - if (name === 'link') return; - _this3.quill.format(name, context.format[name], _quill2.default.sources.USER); - }); - } - - function makeCodeBlockHandler(indent) { - return { - key: Keyboard.keys.TAB, - shiftKey: !indent, - format: { 'code-block': true }, - handler: function handler(range) { - var CodeBlock = _parchment2.default.query('code-block'); - var index = range.index, - length = range.length; - - var _quill$scroll$descend = this.quill.scroll.descendant(CodeBlock, index); - - var _quill$scroll$descend2 = _slicedToArray(_quill$scroll$descend, 2); - - var block = _quill$scroll$descend2[0]; - var offset = _quill$scroll$descend2[1]; - - if (block == null) return; - var scrollOffset = this.quill.scroll.offset(block); - var start = block.newlineIndex(offset, true) + 1; - var end = block.newlineIndex(scrollOffset + offset + length); - var lines = block.domNode.textContent.slice(start, end).split('\n'); - offset = 0; - lines.forEach(function (line, i) { - if (indent) { - block.insertAt(start + offset, CodeBlock.TAB); - offset += CodeBlock.TAB.length; - if (i === 0) { - index += CodeBlock.TAB.length; - } else { - length += CodeBlock.TAB.length; - } - } else if (line.startsWith(CodeBlock.TAB)) { - block.deleteAt(start + offset, CodeBlock.TAB.length); - offset -= CodeBlock.TAB.length; - if (i === 0) { - index -= CodeBlock.TAB.length; - } else { - length -= CodeBlock.TAB.length; - } - } - offset += line.length + 1; - }); - this.quill.update(_quill2.default.sources.USER); - this.quill.setSelection(index, length, _quill2.default.sources.SILENT); - } - }; - } - - function makeFormatHandler(format) { - return { - key: format[0].toUpperCase(), - shortKey: true, - handler: function handler(range, context) { - this.quill.format(format, !context.format[format], _quill2.default.sources.USER); - } - }; - } - - function normalize(binding) { - if (typeof binding === 'string' || typeof binding === 'number') { - return normalize({ key: binding }); - } - if ((typeof binding === 'undefined' ? 'undefined' : _typeof(binding)) === 'object') { - binding = (0, _clone2.default)(binding, false); - } - if (typeof binding.key === 'string') { - if (Keyboard.keys[binding.key.toUpperCase()] != null) { - binding.key = Keyboard.keys[binding.key.toUpperCase()]; - } else if (binding.key.length === 1) { - binding.key = binding.key.toUpperCase().charCodeAt(0); - } else { - return null; - } - } - return binding; - } - - exports.default = Keyboard; - -/***/ }, -/* 53 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - var _core = __webpack_require__(1); - - var _core2 = _interopRequireDefault(_core); - - var _align = __webpack_require__(45); - - var _direction = __webpack_require__(48); - - var _indent = __webpack_require__(54); - - var _blockquote = __webpack_require__(55); - - var _blockquote2 = _interopRequireDefault(_blockquote); - - var _header = __webpack_require__(56); - - var _header2 = _interopRequireDefault(_header); - - var _list = __webpack_require__(57); - - var _list2 = _interopRequireDefault(_list); - - var _background = __webpack_require__(46); - - var _color = __webpack_require__(47); - - var _font = __webpack_require__(49); - - var _size = __webpack_require__(50); - - var _bold = __webpack_require__(58); - - var _bold2 = _interopRequireDefault(_bold); - - var _italic = __webpack_require__(59); - - var _italic2 = _interopRequireDefault(_italic); - - var _link = __webpack_require__(60); - - var _link2 = _interopRequireDefault(_link); - - var _script = __webpack_require__(61); - - var _script2 = _interopRequireDefault(_script); - - var _strike = __webpack_require__(62); - - var _strike2 = _interopRequireDefault(_strike); - - var _underline = __webpack_require__(63); - - var _underline2 = _interopRequireDefault(_underline); - - var _image = __webpack_require__(64); - - var _image2 = _interopRequireDefault(_image); - - var _video = __webpack_require__(65); - - var _video2 = _interopRequireDefault(_video); - - var _code = __webpack_require__(31); - - var _code2 = _interopRequireDefault(_code); - - var _formula = __webpack_require__(66); - - var _formula2 = _interopRequireDefault(_formula); - - var _syntax = __webpack_require__(67); - - var _syntax2 = _interopRequireDefault(_syntax); - - var _toolbar = __webpack_require__(68); - - var _toolbar2 = _interopRequireDefault(_toolbar); - - var _icons = __webpack_require__(69); - - var _icons2 = _interopRequireDefault(_icons); - - var _picker = __webpack_require__(101); - - var _picker2 = _interopRequireDefault(_picker); - - var _colorPicker = __webpack_require__(103); - - var _colorPicker2 = _interopRequireDefault(_colorPicker); - - var _iconPicker = __webpack_require__(104); - - var _iconPicker2 = _interopRequireDefault(_iconPicker); - - var _tooltip = __webpack_require__(105); - - var _tooltip2 = _interopRequireDefault(_tooltip); - - var _bubble = __webpack_require__(106); - - var _bubble2 = _interopRequireDefault(_bubble); - - var _snow = __webpack_require__(108); - - var _snow2 = _interopRequireDefault(_snow); - - function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - - _core2.default.register({ - 'attributors/attribute/direction': _direction.DirectionAttribute, - - 'attributors/class/align': _align.AlignClass, - 'attributors/class/background': _background.BackgroundClass, - 'attributors/class/color': _color.ColorClass, - 'attributors/class/direction': _direction.DirectionClass, - 'attributors/class/font': _font.FontClass, - 'attributors/class/size': _size.SizeClass, - - 'attributors/style/align': _align.AlignStyle, - 'attributors/style/background': _background.BackgroundStyle, - 'attributors/style/color': _color.ColorStyle, - 'attributors/style/direction': _direction.DirectionStyle, - 'attributors/style/font': _font.FontStyle, - 'attributors/style/size': _size.SizeStyle - }, true); - - _core2.default.register({ - 'formats/align': _align.AlignClass, - 'formats/direction': _direction.DirectionClass, - 'formats/indent': _indent.IndentClass, - - 'formats/background': _background.BackgroundStyle, - 'formats/color': _color.ColorStyle, - 'formats/font': _font.FontClass, - 'formats/size': _size.SizeClass, - - 'formats/blockquote': _blockquote2.default, - 'formats/code-block': _code2.default, - 'formats/header': _header2.default, - 'formats/list': _list2.default, - - 'formats/bold': _bold2.default, - 'formats/code': _code.Code, - 'formats/italic': _italic2.default, - 'formats/link': _link2.default, - 'formats/script': _script2.default, - 'formats/strike': _strike2.default, - 'formats/underline': _underline2.default, - - 'formats/image': _image2.default, - 'formats/video': _video2.default, - - 'formats/list/item': _list.ListItem, - - 'modules/formula': _formula2.default, - 'modules/syntax': _syntax2.default, - 'modules/toolbar': _toolbar2.default, - - 'themes/bubble': _bubble2.default, - 'themes/snow': _snow2.default, - - 'ui/icons': _icons2.default, - 'ui/picker': _picker2.default, - 'ui/icon-picker': _iconPicker2.default, - 'ui/color-picker': _colorPicker2.default, - 'ui/tooltip': _tooltip2.default - }, true); - - module.exports = _core2.default; - -/***/ }, -/* 54 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - Object.defineProperty(exports, "__esModule", { - value: true - }); - exports.IndentClass = undefined; - - var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); - - var _get = function get(object, property, receiver) { if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { return get(parent, property, receiver); } } else if ("value" in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } }; - - var _parchment = __webpack_require__(2); - - var _parchment2 = _interopRequireDefault(_parchment); - - function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - - function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } - - function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } - - function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } - - var IdentAttributor = function (_Parchment$Attributor) { - _inherits(IdentAttributor, _Parchment$Attributor); - - function IdentAttributor() { - _classCallCheck(this, IdentAttributor); - - return _possibleConstructorReturn(this, (IdentAttributor.__proto__ || Object.getPrototypeOf(IdentAttributor)).apply(this, arguments)); - } - - _createClass(IdentAttributor, [{ - key: 'add', - value: function add(node, value) { - if (value === '+1' || value === '-1') { - var indent = this.value(node) || 0; - value = value === '+1' ? indent + 1 : indent - 1; - } - if (value === 0) { - this.remove(node); - return true; - } else { - return _get(IdentAttributor.prototype.__proto__ || Object.getPrototypeOf(IdentAttributor.prototype), 'add', this).call(this, node, value); - } - } - }, { - key: 'value', - value: function value(node) { - return parseInt(_get(IdentAttributor.prototype.__proto__ || Object.getPrototypeOf(IdentAttributor.prototype), 'value', this).call(this, node)) || undefined; // Don't return NaN - } - }]); - - return IdentAttributor; - }(_parchment2.default.Attributor.Class); - - var IndentClass = new IdentAttributor('indent', 'ql-indent', { - scope: _parchment2.default.Scope.BLOCK, - whitelist: [1, 2, 3, 4, 5, 6, 7, 8] - }); - - exports.IndentClass = IndentClass; - -/***/ }, -/* 55 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - Object.defineProperty(exports, "__esModule", { - value: true - }); - - var _block = __webpack_require__(32); - - var _block2 = _interopRequireDefault(_block); - - function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - - function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } - - function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } - - function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } - - var Blockquote = function (_Block) { - _inherits(Blockquote, _Block); - - function Blockquote() { - _classCallCheck(this, Blockquote); - - return _possibleConstructorReturn(this, (Blockquote.__proto__ || Object.getPrototypeOf(Blockquote)).apply(this, arguments)); - } - - return Blockquote; - }(_block2.default); - - Blockquote.blotName = 'blockquote'; - Blockquote.tagName = 'blockquote'; - - exports.default = Blockquote; - -/***/ }, -/* 56 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - Object.defineProperty(exports, "__esModule", { - value: true - }); - - var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); - - var _block = __webpack_require__(32); - - var _block2 = _interopRequireDefault(_block); - - function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - - function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } - - function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } - - function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } - - var Header = function (_Block) { - _inherits(Header, _Block); - - function Header() { - _classCallCheck(this, Header); - - return _possibleConstructorReturn(this, (Header.__proto__ || Object.getPrototypeOf(Header)).apply(this, arguments)); - } - - _createClass(Header, null, [{ - key: 'formats', - value: function formats(domNode) { - return this.tagName.indexOf(domNode.tagName) + 1; - } - }]); - - return Header; - }(_block2.default); - - Header.blotName = 'header'; - Header.tagName = ['H1', 'H2', 'H3', 'H4', 'H5', 'H6']; - - exports.default = Header; - -/***/ }, -/* 57 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - Object.defineProperty(exports, "__esModule", { - value: true - }); - exports.default = exports.ListItem = undefined; - - var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); - - var _get = function get(object, property, receiver) { if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { return get(parent, property, receiver); } } else if ("value" in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } }; - - var _extend = __webpack_require__(25); - - var _extend2 = _interopRequireDefault(_extend); - - var _delta = __webpack_require__(20); - - var _delta2 = _interopRequireDefault(_delta); - - var _parchment = __webpack_require__(2); - - var _parchment2 = _interopRequireDefault(_parchment); - - var _block = __webpack_require__(32); - - var _block2 = _interopRequireDefault(_block); - - var _container = __webpack_require__(42); - - var _container2 = _interopRequireDefault(_container); - - function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - - function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } - - function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } - - function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } - - function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } - - var ListItem = function (_Block) { - _inherits(ListItem, _Block); - - function ListItem() { - _classCallCheck(this, ListItem); - - return _possibleConstructorReturn(this, (ListItem.__proto__ || Object.getPrototypeOf(ListItem)).apply(this, arguments)); - } - - _createClass(ListItem, [{ - key: 'format', - value: function format(name, value) { - if (name === List.blotName && !value) { - this.replaceWith(_parchment2.default.create(this.statics.scope)); - } else { - _get(ListItem.prototype.__proto__ || Object.getPrototypeOf(ListItem.prototype), 'format', this).call(this, name, value); - } - } - }, { - key: 'remove', - value: function remove() { - if (this.prev == null && this.next == null) { - this.parent.remove(); - } else { - _get(ListItem.prototype.__proto__ || Object.getPrototypeOf(ListItem.prototype), 'remove', this).call(this); - } - } - }, { - key: 'replaceWith', - value: function replaceWith(name, value) { - this.parent.isolate(this.offset(this.parent), this.length()); - if (name === this.parent.statics.blotName) { - this.parent.replaceWith(name, value); - return this; - } else { - this.parent.unwrap(); - return _get(ListItem.prototype.__proto__ || Object.getPrototypeOf(ListItem.prototype), 'replaceWith', this).call(this, name, value); - } - } - }], [{ - key: 'formats', - value: function formats(domNode) { - return domNode.tagName === this.tagName ? undefined : _get(ListItem.__proto__ || Object.getPrototypeOf(ListItem), 'formats', this).call(this, domNode); - } - }]); - - return ListItem; - }(_block2.default); - - ListItem.blotName = 'list-item'; - ListItem.tagName = 'LI'; - - var List = function (_Container) { - _inherits(List, _Container); - - function List() { - _classCallCheck(this, List); - - return _possibleConstructorReturn(this, (List.__proto__ || Object.getPrototypeOf(List)).apply(this, arguments)); - } - - _createClass(List, [{ - key: 'format', - value: function format(name, value) { - if (this.children.length > 0) { - this.children.tail.format(name, value); - } - } - }, { - key: 'formats', - value: function formats() { - // We don't inherit from FormatBlot - return _defineProperty({}, this.statics.blotName, this.statics.formats(this.domNode)); - } - }, { - key: 'insertBefore', - value: function insertBefore(blot, ref) { - if (blot instanceof ListItem) { - _get(List.prototype.__proto__ || Object.getPrototypeOf(List.prototype), 'insertBefore', this).call(this, blot, ref); - } else { - var index = ref == null ? this.length() : ref.offset(this); - var after = this.split(index); - after.parent.insertBefore(blot, after); - } - } - }, { - key: 'optimize', - value: function optimize() { - _get(List.prototype.__proto__ || Object.getPrototypeOf(List.prototype), 'optimize', this).call(this); - var next = this.next; - if (next != null && next.prev === this && next.statics.blotName === this.statics.blotName && next.domNode.tagName === this.domNode.tagName) { - next.moveChildren(this); - next.remove(); - } - } - }, { - key: 'replace', - value: function replace(target) { - if (target.statics.blotName !== this.statics.blotName) { - var item = _parchment2.default.create(this.statics.defaultChild); - target.moveChildren(item); - this.appendChild(item); - } - _get(List.prototype.__proto__ || Object.getPrototypeOf(List.prototype), 'replace', this).call(this, target); - } - }], [{ - key: 'create', - value: function create(value) { - if (value === 'ordered') { - value = 'OL'; - } else if (value === 'bullet') { - value = 'UL'; - } - return _get(List.__proto__ || Object.getPrototypeOf(List), 'create', this).call(this, value); - } - }, { - key: 'formats', - value: function formats(domNode) { - if (domNode.tagName === 'OL') return 'ordered'; - if (domNode.tagName === 'UL') return 'bullet'; - return undefined; - } - }]); - - return List; - }(_container2.default); - - List.blotName = 'list'; - List.scope = _parchment2.default.Scope.BLOCK_BLOT; - List.tagName = ['OL', 'UL']; - List.defaultChild = 'list-item'; - List.allowedChildren = [ListItem]; - - exports.ListItem = ListItem; - exports.default = List; - -/***/ }, -/* 58 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - Object.defineProperty(exports, "__esModule", { - value: true - }); - - var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); - - var _get = function get(object, property, receiver) { if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { return get(parent, property, receiver); } } else if ("value" in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } }; - - var _inline = __webpack_require__(35); - - var _inline2 = _interopRequireDefault(_inline); - - function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - - function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } - - function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } - - function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } - - var Bold = function (_Inline) { - _inherits(Bold, _Inline); - - function Bold() { - _classCallCheck(this, Bold); - - return _possibleConstructorReturn(this, (Bold.__proto__ || Object.getPrototypeOf(Bold)).apply(this, arguments)); - } - - _createClass(Bold, [{ - key: 'optimize', - value: function optimize() { - _get(Bold.prototype.__proto__ || Object.getPrototypeOf(Bold.prototype), 'optimize', this).call(this); - if (this.domNode.tagName !== this.statics.tagName[0]) { - this.replaceWith(this.statics.blotName); - } - } - }], [{ - key: 'create', - value: function create(value) { - return _get(Bold.__proto__ || Object.getPrototypeOf(Bold), 'create', this).call(this); - } - }, { - key: 'formats', - value: function formats(domNode) { - return true; - } - }]); - - return Bold; - }(_inline2.default); - - Bold.blotName = 'bold'; - Bold.tagName = ['STRONG', 'B']; - - exports.default = Bold; - -/***/ }, -/* 59 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - Object.defineProperty(exports, "__esModule", { - value: true - }); - - var _bold = __webpack_require__(58); - - var _bold2 = _interopRequireDefault(_bold); - - function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - - function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } - - function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } - - function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } - - var Italic = function (_Bold) { - _inherits(Italic, _Bold); - - function Italic() { - _classCallCheck(this, Italic); - - return _possibleConstructorReturn(this, (Italic.__proto__ || Object.getPrototypeOf(Italic)).apply(this, arguments)); - } - - return Italic; - }(_bold2.default); - - Italic.blotName = 'italic'; - Italic.tagName = ['EM', 'I']; - - exports.default = Italic; - -/***/ }, -/* 60 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - Object.defineProperty(exports, "__esModule", { - value: true - }); - exports.sanitize = exports.default = undefined; - - var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); - - var _get = function get(object, property, receiver) { if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { return get(parent, property, receiver); } } else if ("value" in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } }; - - var _inline = __webpack_require__(35); - - var _inline2 = _interopRequireDefault(_inline); - - function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - - function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } - - function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } - - function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } - - var Link = function (_Inline) { - _inherits(Link, _Inline); - - function Link() { - _classCallCheck(this, Link); - - return _possibleConstructorReturn(this, (Link.__proto__ || Object.getPrototypeOf(Link)).apply(this, arguments)); - } - - _createClass(Link, [{ - key: 'format', - value: function format(name, value) { - if (name !== this.statics.blotName || !value) return _get(Link.prototype.__proto__ || Object.getPrototypeOf(Link.prototype), 'format', this).call(this, name, value); - value = this.constructor.sanitize(value); - this.domNode.setAttribute('href', value); - } - }], [{ - key: 'create', - value: function create(value) { - var node = _get(Link.__proto__ || Object.getPrototypeOf(Link), 'create', this).call(this, value); - value = this.sanitize(value); - node.setAttribute('href', value); - node.setAttribute('target', '_blank'); - return node; - } - }, { - key: 'formats', - value: function formats(domNode) { - return domNode.getAttribute('href'); - } - }, { - key: 'sanitize', - value: function sanitize(url) { - return _sanitize(url, ['http', 'https', 'mailto']) ? url : this.SANITIZED_URL; - } - }]); - - return Link; - }(_inline2.default); - - Link.blotName = 'link'; - Link.tagName = 'A'; - Link.SANITIZED_URL = 'about:blank'; - - function _sanitize(url, protocols) { - var anchor = document.createElement('a'); - anchor.href = url; - var protocol = anchor.href.slice(0, anchor.href.indexOf(':')); - return protocols.indexOf(protocol) > -1; - } - - exports.default = Link; - exports.sanitize = _sanitize; - -/***/ }, -/* 61 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - Object.defineProperty(exports, "__esModule", { - value: true - }); - - var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); - - var _get = function get(object, property, receiver) { if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { return get(parent, property, receiver); } } else if ("value" in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } }; - - var _inline = __webpack_require__(35); - - var _inline2 = _interopRequireDefault(_inline); - - function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - - function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } - - function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } - - function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } - - var Script = function (_Inline) { - _inherits(Script, _Inline); - - function Script() { - _classCallCheck(this, Script); - - return _possibleConstructorReturn(this, (Script.__proto__ || Object.getPrototypeOf(Script)).apply(this, arguments)); - } - - _createClass(Script, null, [{ - key: 'create', - value: function create(value) { - if (value === 'super') { - return document.createElement('sup'); - } else if (value === 'sub') { - return document.createElement('sub'); - } else { - return _get(Script.__proto__ || Object.getPrototypeOf(Script), 'create', this).call(this, value); - } - } - }, { - key: 'formats', - value: function formats(domNode) { - if (domNode.tagName === 'SUB') return 'sub'; - if (domNode.tagName === 'SUP') return 'super'; - return undefined; - } - }]); - - return Script; - }(_inline2.default); - - Script.blotName = 'script'; - Script.tagName = ['SUB', 'SUP']; - - exports.default = Script; - -/***/ }, -/* 62 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - Object.defineProperty(exports, "__esModule", { - value: true - }); - - var _inline = __webpack_require__(35); - - var _inline2 = _interopRequireDefault(_inline); - - function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - - function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } - - function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } - - function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } - - var Strike = function (_Inline) { - _inherits(Strike, _Inline); - - function Strike() { - _classCallCheck(this, Strike); - - return _possibleConstructorReturn(this, (Strike.__proto__ || Object.getPrototypeOf(Strike)).apply(this, arguments)); - } - - return Strike; - }(_inline2.default); - - Strike.blotName = 'strike'; - Strike.tagName = 'S'; - - exports.default = Strike; - -/***/ }, -/* 63 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - Object.defineProperty(exports, "__esModule", { - value: true - }); - - var _inline = __webpack_require__(35); - - var _inline2 = _interopRequireDefault(_inline); - - function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - - function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } - - function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } - - function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } - - var Underline = function (_Inline) { - _inherits(Underline, _Inline); - - function Underline() { - _classCallCheck(this, Underline); - - return _possibleConstructorReturn(this, (Underline.__proto__ || Object.getPrototypeOf(Underline)).apply(this, arguments)); - } - - return Underline; - }(_inline2.default); - - Underline.blotName = 'underline'; - Underline.tagName = 'U'; - - exports.default = Underline; - -/***/ }, -/* 64 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - Object.defineProperty(exports, "__esModule", { - value: true - }); - - var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); - - var _get = function get(object, property, receiver) { if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { return get(parent, property, receiver); } } else if ("value" in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } }; - - var _embed = __webpack_require__(34); - - var _embed2 = _interopRequireDefault(_embed); - - var _link = __webpack_require__(60); - - var _link2 = _interopRequireDefault(_link); - - function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - - function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } - - function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } - - function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } - - var ATTRIBUTES = ['alt', 'height', 'width']; - - var Image = function (_Embed) { - _inherits(Image, _Embed); - - function Image() { - _classCallCheck(this, Image); - - return _possibleConstructorReturn(this, (Image.__proto__ || Object.getPrototypeOf(Image)).apply(this, arguments)); - } - - _createClass(Image, [{ - key: 'format', - value: function format(name, value) { - if (ATTRIBUTES.indexOf(name) > -1) { - if (value) { - this.domNode.setAttribute(name, value); - } else { - this.domNode.removeAttribute(name); - } - } else { - _get(Image.prototype.__proto__ || Object.getPrototypeOf(Image.prototype), 'format', this).call(this, name, value); - } - } - }], [{ - key: 'create', - value: function create(value) { - var node = _get(Image.__proto__ || Object.getPrototypeOf(Image), 'create', this).call(this, value); - if (typeof value === 'string') { - node.setAttribute('src', this.sanitize(value)); - } - return node; - } - }, { - key: 'formats', - value: function formats(domNode) { - return ATTRIBUTES.reduce(function (formats, attribute) { - if (domNode.hasAttribute(attribute)) { - formats[attribute] = domNode.getAttribute(attribute); - } - return formats; - }, {}); - } - }, { - key: 'match', - value: function match(url) { - return (/\.(jpe?g|gif|png)$/.test(url) || /^data:image\/.+;base64/.test(url) - ); - } - }, { - key: 'sanitize', - value: function sanitize(url) { - return (0, _link.sanitize)(url, ['http', 'https', 'data']) ? url : '//:0'; - } - }, { - key: 'value', - value: function value(domNode) { - return domNode.getAttribute('src'); - } - }]); - - return Image; - }(_embed2.default); - - Image.blotName = 'image'; - Image.tagName = 'IMG'; - - exports.default = Image; - -/***/ }, -/* 65 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - Object.defineProperty(exports, "__esModule", { - value: true - }); - - var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); - - var _get = function get(object, property, receiver) { if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { return get(parent, property, receiver); } } else if ("value" in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } }; - - var _block = __webpack_require__(32); - - var _link = __webpack_require__(60); - - var _link2 = _interopRequireDefault(_link); - - function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - - function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } - - function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } - - function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } - - var ATTRIBUTES = ['height', 'width']; - - var Video = function (_BlockEmbed) { - _inherits(Video, _BlockEmbed); - - function Video() { - _classCallCheck(this, Video); - - return _possibleConstructorReturn(this, (Video.__proto__ || Object.getPrototypeOf(Video)).apply(this, arguments)); - } - - _createClass(Video, [{ - key: 'format', - value: function format(name, value) { - if (ATTRIBUTES.indexOf(name) > -1) { - if (value) { - this.domNode.setAttribute(name, value); - } else { - this.domNode.removeAttribute(name); - } - } else { - _get(Video.prototype.__proto__ || Object.getPrototypeOf(Video.prototype), 'format', this).call(this, name, value); - } - } - }], [{ - key: 'create', - value: function create(value) { - var node = _get(Video.__proto__ || Object.getPrototypeOf(Video), 'create', this).call(this, value); - node.setAttribute('frameborder', '0'); - node.setAttribute('allowfullscreen', true); - node.setAttribute('src', this.sanitize(value)); - return node; - } - }, { - key: 'formats', - value: function formats(domNode) { - return ATTRIBUTES.reduce(function (formats, attribute) { - if (domNode.hasAttribute(attribute)) { - formats[attribute] = domNode.getAttribute(attribute); - } - return formats; - }, {}); - } - }, { - key: 'sanitize', - value: function sanitize(url) { - return _link2.default.sanitize(url); - } - }, { - key: 'value', - value: function value(domNode) { - return domNode.getAttribute('src'); - } - }]); - - return Video; - }(_block.BlockEmbed); - - Video.blotName = 'video'; - Video.className = 'ql-video'; - Video.tagName = 'IFRAME'; - - exports.default = Video; - -/***/ }, -/* 66 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - Object.defineProperty(exports, "__esModule", { - value: true - }); - exports.default = exports.FormulaBlot = undefined; - - var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); - - var _get = function get(object, property, receiver) { if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { return get(parent, property, receiver); } } else if ("value" in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } }; - - var _embed = __webpack_require__(34); - - var _embed2 = _interopRequireDefault(_embed); - - var _quill = __webpack_require__(18); - - var _quill2 = _interopRequireDefault(_quill); - - function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - - function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } - - function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } - - function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } - - var FormulaBlot = function (_Embed) { - _inherits(FormulaBlot, _Embed); - - function FormulaBlot() { - _classCallCheck(this, FormulaBlot); - - return _possibleConstructorReturn(this, (FormulaBlot.__proto__ || Object.getPrototypeOf(FormulaBlot)).apply(this, arguments)); - } - - _createClass(FormulaBlot, [{ - key: 'index', - value: function index(node, offset) { - return 1; - } - }], [{ - key: 'create', - value: function create(value) { - var node = _get(FormulaBlot.__proto__ || Object.getPrototypeOf(FormulaBlot), 'create', this).call(this, value); - if (typeof value === 'string') { - katex.render(value, node); - node.setAttribute('data-value', value); - } - node.setAttribute('contenteditable', false); - return node; - } - }, { - key: 'value', - value: function value(domNode) { - return domNode.getAttribute('data-value'); - } - }]); - - return FormulaBlot; - }(_embed2.default); - - FormulaBlot.blotName = 'formula'; - FormulaBlot.className = 'ql-formula'; - FormulaBlot.tagName = 'SPAN'; - - function Formula() { - if (window.katex == null) { - throw new Error('Formula module requires KaTeX.'); - } - _quill2.default.register(FormulaBlot, true); - } - - exports.FormulaBlot = FormulaBlot; - exports.default = Formula; - -/***/ }, -/* 67 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - Object.defineProperty(exports, "__esModule", { - value: true - }); - exports.default = exports.CodeToken = exports.CodeBlock = undefined; - - var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); - - var _get = function get(object, property, receiver) { if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { return get(parent, property, receiver); } } else if ("value" in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } }; - - var _parchment = __webpack_require__(2); - - var _parchment2 = _interopRequireDefault(_parchment); - - var _quill = __webpack_require__(18); - - var _quill2 = _interopRequireDefault(_quill); - - var _module = __webpack_require__(39); - - var _module2 = _interopRequireDefault(_module); - - var _code = __webpack_require__(31); - - var _code2 = _interopRequireDefault(_code); - - function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - - function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } - - function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } - - function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } - - var SyntaxCodeBlock = function (_CodeBlock) { - _inherits(SyntaxCodeBlock, _CodeBlock); - - function SyntaxCodeBlock() { - _classCallCheck(this, SyntaxCodeBlock); - - return _possibleConstructorReturn(this, (SyntaxCodeBlock.__proto__ || Object.getPrototypeOf(SyntaxCodeBlock)).apply(this, arguments)); - } - - _createClass(SyntaxCodeBlock, [{ - key: 'replaceWith', - value: function replaceWith(block) { - this.domNode.textContent = this.domNode.textContent; - this.attach(); - _get(SyntaxCodeBlock.prototype.__proto__ || Object.getPrototypeOf(SyntaxCodeBlock.prototype), 'replaceWith', this).call(this, block); - } - }, { - key: 'highlight', - value: function highlight(_highlight) { - if (this.cachedHTML !== this.domNode.innerHTML) { - var text = this.domNode.textContent; - if (text.trim().length > 0 || this.cachedHTML == null) { - this.domNode.innerHTML = _highlight(text); - this.attach(); - } - this.cachedHTML = this.domNode.innerHTML; - } - } - }]); - - return SyntaxCodeBlock; - }(_code2.default); - - SyntaxCodeBlock.className = 'ql-syntax'; - - var CodeToken = new _parchment2.default.Attributor.Class('token', 'hljs', { - scope: _parchment2.default.Scope.INLINE - }); - - var Syntax = function (_Module) { - _inherits(Syntax, _Module); - - function Syntax(quill, options) { - _classCallCheck(this, Syntax); - - var _this2 = _possibleConstructorReturn(this, (Syntax.__proto__ || Object.getPrototypeOf(Syntax)).call(this, quill, options)); - - if (typeof _this2.options.highlight !== 'function') { - throw new Error('Syntax module requires highlight.js. Please include the library on the page before Quill.'); - } - _quill2.default.register(CodeToken, true); - _quill2.default.register(SyntaxCodeBlock, true); - var timer = null; - _this2.quill.on(_quill2.default.events.SCROLL_OPTIMIZE, function () { - if (timer != null) return; - timer = setTimeout(function () { - _this2.highlight(); - timer = null; - }, 100); - }); - _this2.highlight(); - return _this2; - } - - _createClass(Syntax, [{ - key: 'highlight', - value: function highlight() { - var _this3 = this; - - if (this.quill.selection.composing) return; - var range = this.quill.getSelection(); - this.quill.scroll.descendants(SyntaxCodeBlock).forEach(function (code) { - code.highlight(_this3.options.highlight); - }); - this.quill.update(_quill2.default.sources.SILENT); - if (range != null) { - this.quill.setSelection(range, _quill2.default.sources.SILENT); - } - } - }]); - - return Syntax; - }(_module2.default); - - Syntax.DEFAULTS = { - highlight: function () { - if (window.hljs == null) return null; - return function (text) { - var result = window.hljs.highlightAuto(text); - return result.value; - }; - }() - }; - - exports.CodeBlock = SyntaxCodeBlock; - exports.CodeToken = CodeToken; - exports.default = Syntax; - -/***/ }, -/* 68 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - Object.defineProperty(exports, "__esModule", { - value: true - }); - exports.addControls = exports.default = undefined; - - var _slicedToArray = function () { function sliceIterator(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"]) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } return function (arr, i) { if (Array.isArray(arr)) { return arr; } else if (Symbol.iterator in Object(arr)) { return sliceIterator(arr, i); } else { throw new TypeError("Invalid attempt to destructure non-iterable instance"); } }; }(); - - var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); - - var _extend = __webpack_require__(25); - - var _extend2 = _interopRequireDefault(_extend); - - var _delta = __webpack_require__(20); - - var _delta2 = _interopRequireDefault(_delta); - - var _parchment = __webpack_require__(2); - - var _parchment2 = _interopRequireDefault(_parchment); - - var _quill = __webpack_require__(18); - - var _quill2 = _interopRequireDefault(_quill); - - var _logger = __webpack_require__(30); - - var _logger2 = _interopRequireDefault(_logger); - - var _module = __webpack_require__(39); - - var _module2 = _interopRequireDefault(_module); - - function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - - function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } - - function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } - - function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } - - function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } - - var debug = (0, _logger2.default)('quill:toolbar'); - - var Toolbar = function (_Module) { - _inherits(Toolbar, _Module); - - function Toolbar(quill, options) { - _classCallCheck(this, Toolbar); - - var _this = _possibleConstructorReturn(this, (Toolbar.__proto__ || Object.getPrototypeOf(Toolbar)).call(this, quill, options)); - - if (Array.isArray(_this.options.container)) { - var container = document.createElement('div'); - addControls(container, _this.options.container); - quill.container.parentNode.insertBefore(container, quill.container); - _this.container = container; - } else if (typeof _this.options.container === 'string') { - _this.container = document.querySelector(_this.options.container); - } else { - _this.container = _this.options.container; - } - if (!(_this.container instanceof HTMLElement)) { - var _ret; - - return _ret = debug.error('Container required for toolbar', _this.options), _possibleConstructorReturn(_this, _ret); - } - _this.container.classList.add('ql-toolbar'); - _this.controls = []; - _this.handlers = {}; - Object.keys(_this.options.handlers).forEach(function (format) { - _this.addHandler(format, _this.options.handlers[format]); - }); - [].forEach.call(_this.container.querySelectorAll('button, select'), function (input) { - _this.attach(input); - }); - _this.quill.on(_quill2.default.events.EDITOR_CHANGE, function (type, range) { - if (type === _quill2.default.events.SELECTION_CHANGE) { - _this.update(range); - } - }); - _this.quill.on(_quill2.default.events.SCROLL_OPTIMIZE, function () { - var _this$quill$selection = _this.quill.selection.getRange(); - - var _this$quill$selection2 = _slicedToArray(_this$quill$selection, 1); - - var range = _this$quill$selection2[0]; // quill.getSelection triggers update - - _this.update(range); - }); - return _this; - } - - _createClass(Toolbar, [{ - key: 'addHandler', - value: function addHandler(format, handler) { - this.handlers[format] = handler; - } - }, { - key: 'attach', - value: function attach(input) { - var _this2 = this; - - var format = [].find.call(input.classList, function (className) { - return className.indexOf('ql-') === 0; - }); - if (!format) return; - format = format.slice('ql-'.length); - if (input.tagName === 'BUTTON') { - input.setAttribute('type', 'button'); - } - if (this.handlers[format] == null) { - if (this.quill.scroll.whitelist != null && this.quill.scroll.whitelist[format] == null) { - debug.warn('ignoring attaching to disabled format', format, input); - return; - } - if (_parchment2.default.query(format) == null) { - debug.warn('ignoring attaching to nonexistent format', format, input); - return; - } - } - var eventName = input.tagName === 'SELECT' ? 'change' : 'click'; - input.addEventListener(eventName, function (e) { - var value = void 0; - if (input.tagName === 'SELECT') { - if (input.selectedIndex < 0) return; - var selected = input.options[input.selectedIndex]; - if (selected.hasAttribute('selected')) { - value = false; - } else { - value = selected.value || false; - } - } else { - if (input.classList.contains('ql-active')) { - value = false; - } else { - value = input.value || !input.hasAttribute('value'); - } - e.preventDefault(); - } - _this2.quill.focus(); - - var _quill$selection$getR = _this2.quill.selection.getRange(); - - var _quill$selection$getR2 = _slicedToArray(_quill$selection$getR, 1); - - var range = _quill$selection$getR2[0]; - - if (_this2.handlers[format] != null) { - _this2.handlers[format].call(_this2, value); - } else if (_parchment2.default.query(format).prototype instanceof _parchment2.default.Embed) { - value = prompt('Enter ' + format); - if (!value) return; - _this2.quill.updateContents(new _delta2.default().retain(range.index).delete(range.length).insert(_defineProperty({}, format, value)), _quill2.default.sources.USER); - } else { - _this2.quill.format(format, value, _quill2.default.sources.USER); - } - _this2.update(range); - }); - // TODO use weakmap - this.controls.push([format, input]); - } - }, { - key: 'update', - value: function update(range) { - var formats = range == null ? {} : this.quill.getFormat(range); - this.controls.forEach(function (pair) { - var _pair = _slicedToArray(pair, 2); - - var format = _pair[0]; - var input = _pair[1]; - - if (input.tagName === 'SELECT') { - var option = void 0; - if (range == null) { - option = null; - } else if (formats[format] == null) { - option = input.querySelector('option[selected]'); - } else if (!Array.isArray(formats[format])) { - var value = formats[format]; - if (typeof value === 'string') { - value = value.replace(/\"/g, '\\"'); - } - option = input.querySelector('option[value="' + value + '"]'); - } - if (option == null) { - input.value = ''; // TODO make configurable? - input.selectedIndex = -1; - } else { - option.selected = true; - } - } else { - if (range == null) { - input.classList.remove('ql-active'); - } else if (input.hasAttribute('value')) { - // both being null should match (default values) - // '1' should match with 1 (headers) - var isActive = formats[format] === input.getAttribute('value') || formats[format] != null && formats[format].toString() === input.getAttribute('value') || formats[format] == null && !input.getAttribute('value'); - input.classList.toggle('ql-active', isActive); - } else { - input.classList.toggle('ql-active', formats[format] != null); - } - } - }); - } - }]); - - return Toolbar; - }(_module2.default); - - Toolbar.DEFAULTS = {}; - - function addButton(container, format, value) { - var input = document.createElement('button'); - input.setAttribute('type', 'button'); - input.classList.add('ql-' + format); - if (value != null) { - input.value = value; - } - container.appendChild(input); - } - - function addControls(container, groups) { - if (!Array.isArray(groups[0])) { - groups = [groups]; - } - groups.forEach(function (controls) { - var group = document.createElement('span'); - group.classList.add('ql-formats'); - controls.forEach(function (control) { - if (typeof control === 'string') { - addButton(group, control); - } else { - var format = Object.keys(control)[0]; - var value = control[format]; - if (Array.isArray(value)) { - addSelect(group, format, value); - } else { - addButton(group, format, value); - } - } - }); - container.appendChild(group); - }); - } - - function addSelect(container, format, values) { - var input = document.createElement('select'); - input.classList.add('ql-' + format); - values.forEach(function (value) { - var option = document.createElement('option'); - if (value !== false) { - option.setAttribute('value', value); - } else { - option.setAttribute('selected', 'selected'); - } - input.appendChild(option); - }); - container.appendChild(input); - } - - Toolbar.DEFAULTS = { - container: null, - handlers: { - clean: function clean(value) { - var _this3 = this; - - var range = this.quill.getSelection(); - if (range == null) return; - if (range.length == 0) { - var formats = this.quill.getFormat(); - Object.keys(formats).forEach(function (name) { - // Clean functionality in existing apps only clean inline formats - if (_parchment2.default.query(name, _parchment2.default.Scope.INLINE) != null) { - _this3.quill.format(name, false); - } - }); - } else { - this.quill.removeFormat(range, _quill2.default.sources.USER); - } - }, - direction: function direction(value) { - var align = this.quill.getFormat()['align']; - if (value === 'rtl' && align == null) { - this.quill.format('align', 'right', _quill2.default.sources.USER); - } else if (!value && align === 'right') { - this.quill.format('align', false, _quill2.default.sources.USER); - } - this.quill.format('direction', value, _quill2.default.sources.USER); - }, - link: function link(value) { - if (value === true) { - value = prompt('Enter link URL:'); - } - this.quill.format('link', value, _quill2.default.sources.USER); - }, - indent: function indent(value) { - var range = this.quill.getSelection(); - var formats = this.quill.getFormat(range); - var indent = parseInt(formats.indent || 0); - if (value === '+1' || value === '-1') { - var modifier = value === '+1' ? 1 : -1; - if (formats.direction === 'rtl') modifier *= -1; - this.quill.format('indent', indent + modifier, _quill2.default.sources.USER); - } - } - } - }; - - exports.default = Toolbar; - exports.addControls = addControls; - -/***/ }, -/* 69 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - module.exports = { - 'align': { - '': __webpack_require__(70), - 'center': __webpack_require__(71), - 'right': __webpack_require__(72), - 'justify': __webpack_require__(73) - }, - 'background': __webpack_require__(74), - 'blockquote': __webpack_require__(75), - 'bold': __webpack_require__(76), - 'clean': __webpack_require__(77), - 'code': __webpack_require__(78), - 'code-block': __webpack_require__(78), - 'color': __webpack_require__(79), - 'direction': { - '': __webpack_require__(80), - 'rtl': __webpack_require__(81) - }, - 'float': { - 'center': __webpack_require__(82), - 'full': __webpack_require__(83), - 'left': __webpack_require__(84), - 'right': __webpack_require__(85) - }, - 'formula': __webpack_require__(86), - 'header': { - '1': __webpack_require__(87), - '2': __webpack_require__(88) - }, - 'italic': __webpack_require__(89), - 'image': __webpack_require__(90), - 'indent': { - '+1': __webpack_require__(91), - '-1': __webpack_require__(92) - }, - 'link': __webpack_require__(93), - 'list': { - 'ordered': __webpack_require__(94), - 'bullet': __webpack_require__(95) - }, - 'script': { - 'sub': __webpack_require__(96), - 'super': __webpack_require__(97) - }, - 'strike': __webpack_require__(98), - 'underline': __webpack_require__(99), - 'video': __webpack_require__(100) - }; - -/***/ }, -/* 70 */ -/***/ function(module, exports) { - - module.exports = " "; - -/***/ }, -/* 71 */ -/***/ function(module, exports) { - - module.exports = " "; - -/***/ }, -/* 72 */ -/***/ function(module, exports) { - - module.exports = " "; - -/***/ }, -/* 73 */ -/***/ function(module, exports) { - - module.exports = " "; - -/***/ }, -/* 74 */ -/***/ function(module, exports) { - - module.exports = " "; - -/***/ }, -/* 75 */ -/***/ function(module, exports) { - - module.exports = " "; - -/***/ }, -/* 76 */ -/***/ function(module, exports) { - - module.exports = " "; - -/***/ }, -/* 77 */ -/***/ function(module, exports) { - - module.exports = " "; - -/***/ }, -/* 78 */ -/***/ function(module, exports) { - - module.exports = " "; - -/***/ }, -/* 79 */ -/***/ function(module, exports) { - - module.exports = " "; - -/***/ }, -/* 80 */ -/***/ function(module, exports) { - - module.exports = " "; - -/***/ }, -/* 81 */ -/***/ function(module, exports) { - - module.exports = " "; - -/***/ }, -/* 82 */ -/***/ function(module, exports) { - - module.exports = " "; - -/***/ }, -/* 83 */ -/***/ function(module, exports) { - - module.exports = " "; - -/***/ }, -/* 84 */ -/***/ function(module, exports) { - - module.exports = " "; - -/***/ }, -/* 85 */ -/***/ function(module, exports) { - - module.exports = " "; - -/***/ }, -/* 86 */ -/***/ function(module, exports) { - - module.exports = " "; - -/***/ }, -/* 87 */ -/***/ function(module, exports) { - - module.exports = " "; - -/***/ }, -/* 88 */ -/***/ function(module, exports) { - - module.exports = " "; - -/***/ }, -/* 89 */ -/***/ function(module, exports) { - - module.exports = " "; - -/***/ }, -/* 90 */ -/***/ function(module, exports) { - - module.exports = " "; - -/***/ }, -/* 91 */ -/***/ function(module, exports) { - - module.exports = " "; - -/***/ }, -/* 92 */ -/***/ function(module, exports) { - - module.exports = " "; - -/***/ }, -/* 93 */ -/***/ function(module, exports) { - - module.exports = " "; - -/***/ }, -/* 94 */ -/***/ function(module, exports) { - - module.exports = " "; - -/***/ }, -/* 95 */ -/***/ function(module, exports) { - - module.exports = " "; - -/***/ }, -/* 96 */ -/***/ function(module, exports) { - - module.exports = " "; - -/***/ }, -/* 97 */ -/***/ function(module, exports) { - - module.exports = " "; - -/***/ }, -/* 98 */ -/***/ function(module, exports) { - - module.exports = " "; - -/***/ }, -/* 99 */ -/***/ function(module, exports) { - - module.exports = " "; - -/***/ }, -/* 100 */ -/***/ function(module, exports) { - - module.exports = " "; - -/***/ }, -/* 101 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - Object.defineProperty(exports, "__esModule", { - value: true - }); - - var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; - - var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); - - var _dropdown = __webpack_require__(102); - - var _dropdown2 = _interopRequireDefault(_dropdown); - - function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - - function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } - - var Picker = function () { - function Picker(select) { - var _this = this; - - _classCallCheck(this, Picker); - - this.select = select; - this.container = document.createElement('span'); - this.buildPicker(); - this.select.style.display = 'none'; - this.select.parentNode.insertBefore(this.container, this.select); - this.label.addEventListener('click', function (event) { - _this.container.classList.toggle('ql-expanded'); - }); - this.select.addEventListener('change', this.update.bind(this)); - } - - _createClass(Picker, [{ - key: 'buildItem', - value: function buildItem(option) { - var _this2 = this; - - var item = document.createElement('span'); - item.classList.add('ql-picker-item'); - if (option.hasAttribute('value')) { - item.setAttribute('data-value', option.getAttribute('value')); - } - if (option.textContent) { - item.setAttribute('data-label', option.textContent); - } - item.addEventListener('click', function (event) { - _this2.selectItem(item, true); - }); - return item; - } - }, { - key: 'buildLabel', - value: function buildLabel() { - var label = document.createElement('span'); - label.classList.add('ql-picker-label'); - label.innerHTML = _dropdown2.default; - this.container.appendChild(label); - return label; - } - }, { - key: 'buildOptions', - value: function buildOptions() { - var _this3 = this; - - var options = document.createElement('span'); - options.classList.add('ql-picker-options'); - [].slice.call(this.select.options).forEach(function (option) { - var item = _this3.buildItem(option); - options.appendChild(item); - if (option.hasAttribute('selected')) { - _this3.selectItem(item); - } - }); - this.container.appendChild(options); - } - }, { - key: 'buildPicker', - value: function buildPicker() { - var _this4 = this; - - [].slice.call(this.select.attributes).forEach(function (item) { - _this4.container.setAttribute(item.name, item.value); - }); - this.container.classList.add('ql-picker'); - this.label = this.buildLabel(); - this.buildOptions(); - } - }, { - key: 'close', - value: function close() { - this.container.classList.remove('ql-expanded'); - } - }, { - key: 'selectItem', - value: function selectItem(item) { - var trigger = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false; - - var selected = this.container.querySelector('.ql-selected'); - if (item === selected) return; - if (selected != null) { - selected.classList.remove('ql-selected'); - } - if (item != null) { - item.classList.add('ql-selected'); - this.select.selectedIndex = [].indexOf.call(item.parentNode.children, item); - if (item.hasAttribute('data-value')) { - this.label.setAttribute('data-value', item.getAttribute('data-value')); - } else { - this.label.removeAttribute('data-value'); - } - if (item.hasAttribute('data-label')) { - this.label.setAttribute('data-label', item.getAttribute('data-label')); - } else { - this.label.removeAttribute('data-label'); - } - if (trigger) { - if (typeof Event === 'function') { - this.select.dispatchEvent(new Event('change')); - } else if ((typeof Event === 'undefined' ? 'undefined' : _typeof(Event)) === 'object') { - // IE11 - var event = document.createEvent('Event'); - event.initEvent('change', true, true); - this.select.dispatchEvent(event); - } - this.close(); - } - } else { - this.label.removeAttribute('data-value'); - this.label.removeAttribute('data-label'); - } - } - }, { - key: 'update', - value: function update() { - var option = void 0; - if (this.select.selectedIndex > -1) { - var item = this.container.querySelector('.ql-picker-options').children[this.select.selectedIndex]; - option = this.select.options[this.select.selectedIndex]; - this.selectItem(item); - } else { - this.selectItem(null); - } - var isActive = option != null && option !== this.select.querySelector('option[selected]'); - this.label.classList.toggle('ql-active', isActive); - } - }]); - - return Picker; - }(); - - exports.default = Picker; - -/***/ }, -/* 102 */ -/***/ function(module, exports) { - - module.exports = " "; - -/***/ }, -/* 103 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - Object.defineProperty(exports, "__esModule", { - value: true - }); - - var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); - - var _get = function get(object, property, receiver) { if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { return get(parent, property, receiver); } } else if ("value" in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } }; - - var _picker = __webpack_require__(101); - - var _picker2 = _interopRequireDefault(_picker); - - function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - - function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } - - function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } - - function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } - - var ColorPicker = function (_Picker) { - _inherits(ColorPicker, _Picker); - - function ColorPicker(select, label) { - _classCallCheck(this, ColorPicker); - - var _this = _possibleConstructorReturn(this, (ColorPicker.__proto__ || Object.getPrototypeOf(ColorPicker)).call(this, select)); - - _this.label.innerHTML = label; - _this.container.classList.add('ql-color-picker'); - [].slice.call(_this.container.querySelectorAll('.ql-picker-item'), 0, 7).forEach(function (item) { - item.classList.add('ql-primary'); - }); - return _this; - } - - _createClass(ColorPicker, [{ - key: 'buildItem', - value: function buildItem(option) { - var item = _get(ColorPicker.prototype.__proto__ || Object.getPrototypeOf(ColorPicker.prototype), 'buildItem', this).call(this, option); - item.style.backgroundColor = option.getAttribute('value') || ''; - return item; - } - }, { - key: 'selectItem', - value: function selectItem(item, trigger) { - _get(ColorPicker.prototype.__proto__ || Object.getPrototypeOf(ColorPicker.prototype), 'selectItem', this).call(this, item, trigger); - var colorLabel = this.label.querySelector('.ql-color-label'); - var value = item ? item.getAttribute('data-value') || '' : ''; - if (colorLabel) { - if (colorLabel.tagName === 'line') { - colorLabel.style.stroke = value; - } else { - colorLabel.style.fill = value; - } - } - } - }]); - - return ColorPicker; - }(_picker2.default); - - exports.default = ColorPicker; - -/***/ }, -/* 104 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - Object.defineProperty(exports, "__esModule", { - value: true - }); - - var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); - - var _get = function get(object, property, receiver) { if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { return get(parent, property, receiver); } } else if ("value" in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } }; - - var _picker = __webpack_require__(101); - - var _picker2 = _interopRequireDefault(_picker); - - function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - - function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } - - function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } - - function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } - - var IconPicker = function (_Picker) { - _inherits(IconPicker, _Picker); - - function IconPicker(select, icons) { - _classCallCheck(this, IconPicker); - - var _this = _possibleConstructorReturn(this, (IconPicker.__proto__ || Object.getPrototypeOf(IconPicker)).call(this, select)); - - _this.container.classList.add('ql-icon-picker'); - [].forEach.call(_this.container.querySelectorAll('.ql-picker-item'), function (item) { - item.innerHTML = icons[item.getAttribute('data-value') || '']; - }); - _this.defaultItem = _this.container.querySelector('.ql-selected'); - _this.selectItem(_this.defaultItem); - return _this; - } - - _createClass(IconPicker, [{ - key: 'selectItem', - value: function selectItem(item, trigger) { - _get(IconPicker.prototype.__proto__ || Object.getPrototypeOf(IconPicker.prototype), 'selectItem', this).call(this, item, trigger); - item = item || this.defaultItem; - this.label.innerHTML = item.innerHTML; - } - }]); - - return IconPicker; - }(_picker2.default); - - exports.default = IconPicker; - -/***/ }, -/* 105 */ -/***/ function(module, exports) { - - 'use strict'; - - Object.defineProperty(exports, "__esModule", { - value: true - }); - - var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); - - function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } - - var Tooltip = function () { - function Tooltip(quill, boundsContainer) { - var _this = this; - - _classCallCheck(this, Tooltip); - - this.quill = quill; - this.boundsContainer = boundsContainer || document.body; - this.root = quill.addContainer('ql-tooltip'); - this.root.innerHTML = this.constructor.TEMPLATE; - var offset = parseInt(window.getComputedStyle(this.root).marginTop); - this.quill.root.addEventListener('scroll', function () { - _this.root.style.marginTop = -1 * _this.quill.root.scrollTop + offset + 'px'; - _this.checkBounds(); - }); - this.hide(); - } - - _createClass(Tooltip, [{ - key: 'checkBounds', - value: function checkBounds() { - this.root.classList.toggle('ql-out-top', this.root.offsetTop <= 0); - this.root.classList.remove('ql-out-bottom'); - this.root.classList.toggle('ql-out-bottom', this.root.offsetTop + this.root.offsetHeight >= this.quill.root.offsetHeight); - } - }, { - key: 'hide', - value: function hide() { - this.root.classList.add('ql-hidden'); - } - }, { - key: 'position', - value: function position(reference) { - var left = reference.left + reference.width / 2 - this.root.offsetWidth / 2; - var top = reference.bottom + this.quill.root.scrollTop; - this.root.style.left = left + 'px'; - this.root.style.top = top + 'px'; - var containerBounds = this.boundsContainer.getBoundingClientRect(); - var rootBounds = this.root.getBoundingClientRect(); - var shift = 0; - if (rootBounds.right > containerBounds.right) { - shift = containerBounds.right - rootBounds.right; - this.root.style.left = left + shift + 'px'; - } - if (rootBounds.left < containerBounds.left) { - shift = containerBounds.left - rootBounds.left; - this.root.style.left = left + shift + 'px'; - } - this.checkBounds(); - return shift; - } - }, { - key: 'show', - value: function show() { - this.root.classList.remove('ql-editing'); - this.root.classList.remove('ql-hidden'); - } - }]); - - return Tooltip; - }(); - - exports.default = Tooltip; - -/***/ }, -/* 106 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - Object.defineProperty(exports, "__esModule", { - value: true - }); - - var _get = function get(object, property, receiver) { if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { return get(parent, property, receiver); } } else if ("value" in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } }; - - var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); - - var _extend = __webpack_require__(25); - - var _extend2 = _interopRequireDefault(_extend); - - var _emitter = __webpack_require__(28); - - var _emitter2 = _interopRequireDefault(_emitter); - - var _keyboard = __webpack_require__(52); - - var _keyboard2 = _interopRequireDefault(_keyboard); - - var _base = __webpack_require__(107); - - var _base2 = _interopRequireDefault(_base); - - var _icons = __webpack_require__(69); - - var _icons2 = _interopRequireDefault(_icons); - - var _selection = __webpack_require__(40); - - function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - - function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } - - function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } - - function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } - - var TOOLBAR_CONFIG = [['bold', 'italic', 'link'], [{ header: 1 }, { header: 2 }, 'blockquote']]; - - var BubbleTheme = function (_BaseTheme) { - _inherits(BubbleTheme, _BaseTheme); - - function BubbleTheme(quill, options) { - _classCallCheck(this, BubbleTheme); - - if (options.modules.toolbar != null && options.modules.toolbar.container == null) { - options.modules.toolbar.container = TOOLBAR_CONFIG; - } - - var _this = _possibleConstructorReturn(this, (BubbleTheme.__proto__ || Object.getPrototypeOf(BubbleTheme)).call(this, quill, options)); - - _this.quill.container.classList.add('ql-bubble'); - return _this; - } - - _createClass(BubbleTheme, [{ - key: 'extendToolbar', - value: function extendToolbar(toolbar) { - this.tooltip = new BubbleTooltip(this.quill, this.options.bounds); - this.tooltip.root.appendChild(toolbar.container); - this.buildButtons([].slice.call(toolbar.container.querySelectorAll('button'))); - this.buildPickers([].slice.call(toolbar.container.querySelectorAll('select'))); - } - }]); - - return BubbleTheme; - }(_base2.default); - - BubbleTheme.DEFAULTS = (0, _extend2.default)(true, {}, _base2.default.DEFAULTS, { - modules: { - toolbar: { - handlers: { - link: function link(value) { - if (!value) { - this.quill.format('link', false); - } else { - this.quill.theme.tooltip.edit(); - } - } - } - } - } - }); - - var BubbleTooltip = function (_BaseTooltip) { - _inherits(BubbleTooltip, _BaseTooltip); - - function BubbleTooltip(quill, bounds) { - _classCallCheck(this, BubbleTooltip); - - var _this2 = _possibleConstructorReturn(this, (BubbleTooltip.__proto__ || Object.getPrototypeOf(BubbleTooltip)).call(this, quill, bounds)); - - _this2.quill.on(_emitter2.default.events.EDITOR_CHANGE, function (type, range) { - if (type !== _emitter2.default.events.SELECTION_CHANGE) return; - if (range != null && range.length > 0) { - _this2.show(); - // Lock our width so we will expand beyond our offsetParent boundaries - _this2.root.style.left = '0px'; - _this2.root.style.width = ''; - _this2.root.style.width = _this2.root.offsetWidth + 'px'; - var lines = _this2.quill.scroll.lines(range.index, range.length); - if (lines.length === 1) { - _this2.position(_this2.quill.getBounds(range)); - } else { - var lastLine = lines[lines.length - 1]; - var index = lastLine.offset(_this2.quill.scroll); - var length = Math.min(lastLine.length() - 1, range.index + range.length - index); - var _bounds = _this2.quill.getBounds(new _selection.Range(index, length)); - _this2.position(_bounds); - } - } else if (document.activeElement !== _this2.textbox && _this2.quill.hasFocus()) { - _this2.hide(); - } - }); - return _this2; - } - - _createClass(BubbleTooltip, [{ - key: 'listen', - value: function listen() { - var _this3 = this; - - _get(BubbleTooltip.prototype.__proto__ || Object.getPrototypeOf(BubbleTooltip.prototype), 'listen', this).call(this); - this.root.querySelector('.ql-close').addEventListener('click', function (event) { - _this3.root.classList.remove('ql-editing'); - }); - this.quill.on(_emitter2.default.events.SCROLL_OPTIMIZE, function () { - // Let selection be restored by toolbar handlers before repositioning - setTimeout(function () { - if (_this3.root.classList.contains('ql-hidden')) return; - var range = _this3.quill.getSelection(); - if (range != null) { - _this3.position(_this3.quill.getBounds(range)); - } - }, 1); - }); - } - }, { - key: 'cancel', - value: function cancel() { - this.show(); - } - }, { - key: 'position', - value: function position(reference) { - var shift = _get(BubbleTooltip.prototype.__proto__ || Object.getPrototypeOf(BubbleTooltip.prototype), 'position', this).call(this, reference); - if (shift === 0) return shift; - var arrow = this.root.querySelector('.ql-tooltip-arrow'); - arrow.style.marginLeft = ''; - arrow.style.marginLeft = -1 * shift - arrow.offsetWidth / 2 + 'px'; - } - }]); - - return BubbleTooltip; - }(_base.BaseTooltip); - - BubbleTooltip.TEMPLATE = ['', '
          ', '', '', '
          '].join(''); - - exports.default = BubbleTheme; - -/***/ }, -/* 107 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - Object.defineProperty(exports, "__esModule", { - value: true - }); - exports.default = exports.BaseTooltip = undefined; - - var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); - - var _get = function get(object, property, receiver) { if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { return get(parent, property, receiver); } } else if ("value" in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } }; - - var _extend = __webpack_require__(25); - - var _extend2 = _interopRequireDefault(_extend); - - var _delta = __webpack_require__(20); - - var _delta2 = _interopRequireDefault(_delta); - - var _emitter = __webpack_require__(28); - - var _emitter2 = _interopRequireDefault(_emitter); - - var _keyboard = __webpack_require__(52); - - var _keyboard2 = _interopRequireDefault(_keyboard); - - var _theme = __webpack_require__(41); - - var _theme2 = _interopRequireDefault(_theme); - - var _colorPicker = __webpack_require__(103); - - var _colorPicker2 = _interopRequireDefault(_colorPicker); - - var _iconPicker = __webpack_require__(104); - - var _iconPicker2 = _interopRequireDefault(_iconPicker); - - var _picker = __webpack_require__(101); - - var _picker2 = _interopRequireDefault(_picker); - - var _tooltip = __webpack_require__(105); - - var _tooltip2 = _interopRequireDefault(_tooltip); - - var _icons = __webpack_require__(69); - - var _icons2 = _interopRequireDefault(_icons); - - function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - - function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } - - function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } - - function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } - - var ALIGNS = [false, 'center', 'right', 'justify']; - - var COLORS = ["#000000", "#e60000", "#ff9900", "#ffff00", "#008a00", "#0066cc", "#9933ff", "#ffffff", "#facccc", "#ffebcc", "#ffffcc", "#cce8cc", "#cce0f5", "#ebd6ff", "#bbbbbb", "#f06666", "#ffc266", "#ffff66", "#66b966", "#66a3e0", "#c285ff", "#888888", "#a10000", "#b26b00", "#b2b200", "#006100", "#0047b2", "#6b24b2", "#444444", "#5c0000", "#663d00", "#666600", "#003700", "#002966", "#3d1466"]; - - var FONTS = [false, 'serif', 'monospace']; - - var HEADERS = ['1', '2', '3', false]; - - var SIZES = ['small', false, 'large', 'huge']; - - var BaseTheme = function (_Theme) { - _inherits(BaseTheme, _Theme); - - function BaseTheme(quill, options) { - _classCallCheck(this, BaseTheme); - - var _this = _possibleConstructorReturn(this, (BaseTheme.__proto__ || Object.getPrototypeOf(BaseTheme)).call(this, quill, options)); - - var listener = function listener(e) { - if (!document.body.contains(quill.root)) { - return document.body.removeEventListener('click', listener); - } - if (_this.tooltip != null && !_this.tooltip.root.contains(e.target) && document.activeElement !== _this.tooltip.textbox && !_this.quill.hasFocus()) { - _this.tooltip.hide(); - } - if (_this.pickers != null) { - _this.pickers.forEach(function (picker) { - if (!picker.container.contains(e.target)) { - picker.close(); - } - }); - } - }; - document.body.addEventListener('click', listener); - return _this; - } - - _createClass(BaseTheme, [{ - key: 'addModule', - value: function addModule(name) { - var module = _get(BaseTheme.prototype.__proto__ || Object.getPrototypeOf(BaseTheme.prototype), 'addModule', this).call(this, name); - if (name === 'toolbar') { - this.extendToolbar(module); - } - return module; - } - }, { - key: 'buildButtons', - value: function buildButtons(buttons) { - buttons.forEach(function (button) { - var className = button.getAttribute('class') || ''; - className.split(/\s+/).forEach(function (name) { - if (!name.startsWith('ql-')) return; - name = name.slice('ql-'.length); - if (_icons2.default[name] == null) return; - if (name === 'direction') { - button.innerHTML = _icons2.default[name][''] + _icons2.default[name]['rtl']; - } else if (typeof _icons2.default[name] === 'string') { - button.innerHTML = _icons2.default[name]; - } else { - var value = button.value || ''; - if (value != null && _icons2.default[name][value]) { - button.innerHTML = _icons2.default[name][value]; - } - } - }); - }); - } - }, { - key: 'buildPickers', - value: function buildPickers(selects) { - var _this2 = this; - - this.pickers = selects.map(function (select) { - if (select.classList.contains('ql-align')) { - if (select.querySelector('option') == null) { - fillSelect(select, ALIGNS); - } - return new _iconPicker2.default(select, _icons2.default.align); - } else if (select.classList.contains('ql-background') || select.classList.contains('ql-color')) { - var format = select.classList.contains('ql-background') ? 'background' : 'color'; - if (select.querySelector('option') == null) { - fillSelect(select, COLORS, format === 'background' ? '#ffffff' : '#000000'); - } - return new _colorPicker2.default(select, _icons2.default[format]); - } else { - if (select.querySelector('option') == null) { - if (select.classList.contains('ql-font')) { - fillSelect(select, FONTS); - } else if (select.classList.contains('ql-header')) { - fillSelect(select, HEADERS); - } else if (select.classList.contains('ql-size')) { - fillSelect(select, SIZES); - } - } - return new _picker2.default(select); - } - }); - var update = function update() { - _this2.pickers.forEach(function (picker) { - picker.update(); - }); - }; - this.quill.on(_emitter2.default.events.SELECTION_CHANGE, update).on(_emitter2.default.events.SCROLL_OPTIMIZE, update); - } - }]); - - return BaseTheme; - }(_theme2.default); - - BaseTheme.DEFAULTS = (0, _extend2.default)(true, {}, _theme2.default.DEFAULTS, { - modules: { - toolbar: { - handlers: { - formula: function formula(value) { - this.quill.theme.tooltip.edit('formula'); - }, - image: function image(value) { - var _this3 = this; - - var fileInput = this.container.querySelector('input.ql-image[type=file]'); - if (fileInput == null) { - fileInput = document.createElement('input'); - fileInput.setAttribute('type', 'file'); - fileInput.setAttribute('accept', 'image/*'); - fileInput.classList.add('ql-image'); - fileInput.addEventListener('change', function () { - if (fileInput.files != null && fileInput.files[0] != null) { - var reader = new FileReader(); - reader.onload = function (e) { - var range = _this3.quill.getSelection(true); - _this3.quill.updateContents(new _delta2.default().retain(range.index).delete(range.length).insert({ image: e.target.result }), _emitter2.default.sources.USER); - fileInput.value = ""; - }; - reader.readAsDataURL(fileInput.files[0]); - } - }); - this.container.appendChild(fileInput); - } - fileInput.click(); - }, - video: function video(value) { - this.quill.theme.tooltip.edit('video'); - } - } - } - } - }); - - var BaseTooltip = function (_Tooltip) { - _inherits(BaseTooltip, _Tooltip); - - function BaseTooltip(quill, boundsContainer) { - _classCallCheck(this, BaseTooltip); - - var _this4 = _possibleConstructorReturn(this, (BaseTooltip.__proto__ || Object.getPrototypeOf(BaseTooltip)).call(this, quill, boundsContainer)); - - _this4.textbox = _this4.root.querySelector('input[type="text"]'); - _this4.listen(); - return _this4; - } - - _createClass(BaseTooltip, [{ - key: 'listen', - value: function listen() { - var _this5 = this; - - this.textbox.addEventListener('keydown', function (event) { - if (_keyboard2.default.match(event, 'enter')) { - _this5.save(); - event.preventDefault(); - } else if (_keyboard2.default.match(event, 'escape')) { - _this5.cancel(); - event.preventDefault(); - } - }); - } - }, { - key: 'cancel', - value: function cancel() { - this.hide(); - } - }, { - key: 'edit', - value: function edit() { - var mode = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'link'; - var preview = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null; - - this.root.classList.remove('ql-hidden'); - this.root.classList.add('ql-editing'); - if (preview != null) { - this.textbox.value = preview; - } else if (mode !== this.root.getAttribute('data-mode')) { - this.textbox.value = ''; - } - this.position(this.quill.getBounds(this.quill.selection.savedRange)); - this.textbox.select(); - this.textbox.setAttribute('placeholder', this.textbox.getAttribute('data-' + mode) || ''); - this.root.setAttribute('data-mode', mode); - } - }, { - key: 'restoreFocus', - value: function restoreFocus() { - var scrollTop = this.quill.root.scrollTop; - this.quill.focus(); - this.quill.root.scrollTop = scrollTop; - } - }, { - key: 'save', - value: function save() { - var value = this.textbox.value; - switch (this.root.getAttribute('data-mode')) { - case 'link': - var scrollTop = this.quill.root.scrollTop; - if (this.linkRange) { - this.quill.formatText(this.linkRange, 'link', value, _emitter2.default.sources.USER); - delete this.linkRange; - } else { - this.restoreFocus(); - this.quill.format('link', value, _emitter2.default.sources.USER); - } - this.quill.root.scrollTop = scrollTop; - break; - case 'video': - var match = value.match(/^(https?):\/\/(www\.)?youtube\.com\/watch.*v=([a-zA-Z0-9_-]+)/) || value.match(/^(https?):\/\/(www\.)?youtu\.be\/([a-zA-Z0-9_-]+)/); - if (match) { - value = match[1] + '://www.youtube.com/embed/' + match[3] + '?showinfo=0'; - } else if (match = value.match(/^(https?):\/\/(www\.)?vimeo\.com\/(\d+)/)) { - value = match[1] + '://player.vimeo.com/video/' + match[3] + '/'; - } - // fallthrough - case 'formula': - var range = this.quill.getSelection(true); - var index = range.index + range.length; - if (range != null) { - this.quill.insertEmbed(index, this.root.getAttribute('data-mode'), value, _emitter2.default.sources.USER); - if (this.root.getAttribute('data-mode') === 'formula') { - this.quill.insertText(index + 1, ' ', _emitter2.default.sources.USER); - } - this.quill.setSelection(index + 2, _emitter2.default.sources.USER); - } - break; - default: - } - this.textbox.value = ''; - this.hide(); - } - }]); - - return BaseTooltip; - }(_tooltip2.default); - - function fillSelect(select, values) { - var defaultValue = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false; - - values.forEach(function (value) { - var option = document.createElement('option'); - if (value === defaultValue) { - option.setAttribute('selected', 'selected'); - } else { - option.setAttribute('value', value); - } - select.appendChild(option); - }); - } - - exports.BaseTooltip = BaseTooltip; - exports.default = BaseTheme; - -/***/ }, -/* 108 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - Object.defineProperty(exports, "__esModule", { - value: true - }); - - var _slicedToArray = function () { function sliceIterator(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"]) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } return function (arr, i) { if (Array.isArray(arr)) { return arr; } else if (Symbol.iterator in Object(arr)) { return sliceIterator(arr, i); } else { throw new TypeError("Invalid attempt to destructure non-iterable instance"); } }; }(); - - var _get = function get(object, property, receiver) { if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { return get(parent, property, receiver); } } else if ("value" in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } }; - - var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); - - var _extend = __webpack_require__(25); - - var _extend2 = _interopRequireDefault(_extend); - - var _emitter = __webpack_require__(28); - - var _emitter2 = _interopRequireDefault(_emitter); - - var _base = __webpack_require__(107); - - var _base2 = _interopRequireDefault(_base); - - var _link = __webpack_require__(60); - - var _link2 = _interopRequireDefault(_link); - - var _picker = __webpack_require__(101); - - var _picker2 = _interopRequireDefault(_picker); - - var _selection = __webpack_require__(40); - - function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - - function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } - - function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } - - function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } - - var TOOLBAR_CONFIG = [[{ header: ['1', '2', '3', false] }], ['bold', 'italic', 'underline', 'link'], [{ list: 'ordered' }, { list: 'bullet' }], ['clean']]; - - var SnowTheme = function (_BaseTheme) { - _inherits(SnowTheme, _BaseTheme); - - function SnowTheme(quill, options) { - _classCallCheck(this, SnowTheme); - - if (options.modules.toolbar != null && options.modules.toolbar.container == null) { - options.modules.toolbar.container = TOOLBAR_CONFIG; - } - - var _this = _possibleConstructorReturn(this, (SnowTheme.__proto__ || Object.getPrototypeOf(SnowTheme)).call(this, quill, options)); - - _this.quill.container.classList.add('ql-snow'); - return _this; - } - - _createClass(SnowTheme, [{ - key: 'extendToolbar', - value: function extendToolbar(toolbar) { - toolbar.container.classList.add('ql-snow'); - this.buildButtons([].slice.call(toolbar.container.querySelectorAll('button'))); - this.buildPickers([].slice.call(toolbar.container.querySelectorAll('select'))); - this.tooltip = new SnowTooltip(this.quill, this.options.bounds); - if (toolbar.container.querySelector('.ql-link')) { - this.quill.keyboard.addBinding({ key: 'K', shortKey: true }, function (range, context) { - toolbar.handlers['link'].call(toolbar, !context.format.link); - }); - } - } - }]); - - return SnowTheme; - }(_base2.default); - - SnowTheme.DEFAULTS = (0, _extend2.default)(true, {}, _base2.default.DEFAULTS, { - modules: { - toolbar: { - handlers: { - link: function link(value) { - if (value) { - var range = this.quill.getSelection(); - if (range == null || range.length == 0) return; - var preview = this.quill.getText(range); - if (/^\S+@\S+\.\S+$/.test(preview) && preview.indexOf('mailto:') !== 0) { - preview = 'mailto:' + preview; - } - var tooltip = this.quill.theme.tooltip; - tooltip.edit('link', preview); - } else { - this.quill.format('link', false); - } - } - } - } - } - }); - - var SnowTooltip = function (_BaseTooltip) { - _inherits(SnowTooltip, _BaseTooltip); - - function SnowTooltip(quill, bounds) { - _classCallCheck(this, SnowTooltip); - - var _this2 = _possibleConstructorReturn(this, (SnowTooltip.__proto__ || Object.getPrototypeOf(SnowTooltip)).call(this, quill, bounds)); - - _this2.preview = _this2.root.querySelector('a.ql-preview'); - return _this2; - } - - _createClass(SnowTooltip, [{ - key: 'listen', - value: function listen() { - var _this3 = this; - - _get(SnowTooltip.prototype.__proto__ || Object.getPrototypeOf(SnowTooltip.prototype), 'listen', this).call(this); - this.root.querySelector('a.ql-action').addEventListener('click', function (event) { - if (_this3.root.classList.contains('ql-editing')) { - _this3.save(); - } else { - _this3.edit('link', _this3.preview.textContent); - } - event.preventDefault(); - }); - this.root.querySelector('a.ql-remove').addEventListener('click', function (event) { - if (_this3.linkRange != null) { - _this3.restoreFocus(); - _this3.quill.formatText(_this3.linkRange, 'link', false, _emitter2.default.sources.USER); - delete _this3.linkRange; - } - event.preventDefault(); - _this3.hide(); - }); - this.quill.on(_emitter2.default.events.SELECTION_CHANGE, function (range) { - if (range == null) return; - if (range.length === 0) { - var _quill$scroll$descend = _this3.quill.scroll.descendant(_link2.default, range.index); - - var _quill$scroll$descend2 = _slicedToArray(_quill$scroll$descend, 2); - - var link = _quill$scroll$descend2[0]; - var offset = _quill$scroll$descend2[1]; - - if (link != null) { - _this3.linkRange = new _selection.Range(range.index - offset, link.length()); - var preview = _link2.default.formats(link.domNode); - _this3.preview.textContent = preview; - _this3.preview.setAttribute('href', preview); - _this3.show(); - _this3.position(_this3.quill.getBounds(_this3.linkRange)); - return; - } - } - _this3.hide(); - }); - } - }, { - key: 'show', - value: function show() { - _get(SnowTooltip.prototype.__proto__ || Object.getPrototypeOf(SnowTooltip.prototype), 'show', this).call(this); - this.root.removeAttribute('data-mode'); - } - }]); - - return SnowTooltip; - }(_base.BaseTooltip); - - SnowTooltip.TEMPLATE = ['', '', '', ''].join(''); - - exports.default = SnowTheme; - -/***/ } -/******/ ]) -}); -; diff --git a/client/main.js b/client/main.js new file mode 100644 index 00000000..b9f455bb --- /dev/null +++ b/client/main.js @@ -0,0 +1 @@ +import "../imports/ui/main"; diff --git a/client/templates/admin/dashboard/archived_users.js b/client/templates/admin/dashboard/archived_users.js deleted file mode 100644 index 397b85b3..00000000 --- a/client/templates/admin/dashboard/archived_users.js +++ /dev/null @@ -1,6 +0,0 @@ - -Template.archivedUsers.helpers({ - users:function(){ - return ArchivedUsers.find({},{sort: {archived_at : -1}}); - } -}); diff --git a/client/templates/admin/dashboard/daily_new_user.js b/client/templates/admin/dashboard/daily_new_user.js deleted file mode 100644 index e01581dc..00000000 --- a/client/templates/admin/dashboard/daily_new_user.js +++ /dev/null @@ -1,12 +0,0 @@ - -Template.dailyNewUser.helpers({ - users:function(){ - return Meteor.users.find({createdAt:{$gt: new Date(Date.now() - 1* 24 * 60 * 60 * 1000)}}); - } -}); - -Template.dailyNewUser.events({ - "click #foo": function(event, template){ - - } -}); diff --git a/client/templates/admin/dashboard/dashboard.js b/client/templates/admin/dashboard/dashboard.js deleted file mode 100644 index 93907a38..00000000 --- a/client/templates/admin/dashboard/dashboard.js +++ /dev/null @@ -1,24 +0,0 @@ - -Template.dashboard.helpers({ - dailyNewUsersCount:function(){ - return ReactiveMethod.call('dailyNewUsersCount'); - }, - monthlyActiveUsersCount:function(){ - return ReactiveMethod.call('monthlyActiveUsersCount'); - }, - onlineUserCount:function(){ - return ReactiveMethod.call('onlineUserCount'); - }, - blockedUserCount:function(){ - return ReactiveMethod.call('blockedUserCount'); - }, - archivedUserCount:function(){ - return ReactiveMethod.call('archivedUserCount'); - } -}); - -Template.dashboard.events({ - "click #foo": function(event, template){ - - } -}); diff --git a/client/templates/admin/dashboard/monthly_active_users.js b/client/templates/admin/dashboard/monthly_active_users.js deleted file mode 100644 index 1207f907..00000000 --- a/client/templates/admin/dashboard/monthly_active_users.js +++ /dev/null @@ -1,12 +0,0 @@ - -Template.monthlyActiveUsers.helpers({ - users:function(){ - return Meteor.users.find({'status.lastLogin.date':{$gt: new Date(Date.now() - 30 * 24 * 60 * 60 * 1000)}}); - } -}); - -Template.monthlyActiveUsers.events({ - "click #foo": function(event, template){ - - } -}); diff --git a/client/templates/admin/inc/has_permission.js b/client/templates/admin/inc/has_permission.js deleted file mode 100644 index 6d77cf17..00000000 --- a/client/templates/admin/inc/has_permission.js +++ /dev/null @@ -1,13 +0,0 @@ -"use strict" - -Template.hasPermission.helpers({ - target: function () { - var loggedInUserId = Meteor.userId() - - if (!Roles.userIsInRole(loggedInUserId, ['admin','moderator'], 'CB')) { - return 'unauthorised' - } else { - return this.targetTemplate - } - } -}) diff --git a/client/templates/admin/notification/all_notifications.js b/client/templates/admin/notification/all_notifications.js deleted file mode 100644 index 7b5a3748..00000000 --- a/client/templates/admin/notification/all_notifications.js +++ /dev/null @@ -1,65 +0,0 @@ -Template.registerHelper('dispDate', function(date) { - return moment(date).format('h:mm a \ Do MMM \'YY'); -}); - -Template.registerHelper("isActorAdmin", function(actorId){ - return Roles.userIsInRole( actorId, ['admin'], 'CB') ; -}); - -Template.registerHelper('dispCustomDate', function(date, format) { - return moment(date).format(format); -}); - -Template.allNotification.onCreated(function() { - var instance = this; - instance.flag = new ReactiveVar(false); - instance.limit = new ReactiveVar(10); - instance.autorun(function () { - var limit = instance.limit.get(); - var subscription = instance.subscribe('allNotifications', limit); - }); - - instance.dispNotifications = function() { - return Notifications.find({},{sort: {createdAt: -1}}); - } - }); - - Template.allNotification.onRendered(function(){ - var instance = this; - - $('#flux').bind('scroll', function(){ - if($('#flux').scrollTop() + $('#flux').innerHeight()>=$('#flux')[0].scrollHeight){ - - if(Notifications.find().count() === instance.limit.get()){ - instance.limit.set(instance.limit.get() + 5); - $('body').addClass('stop-scrolling') - }else { - if(Notifications.find().count() < instance.limit.get()){ - instance.flag.set(true); - } - } - - } - }); - }); - - -Template.allNotification.helpers({ - notifications:function(){ - return Template.instance().dispNotifications(); - }, - hasBeenSeen:function(){ - var userId = Meteor.userId(); - if (userId && !_.include(this.read, userId)) { - return false; - } else { - return true; - } - } -}); - -Template.allNotification.events({ - "click .markAsRead": function(event, template){ - Meteor.call('markAsRead', this._id, function(error, result) { }); - } -}); diff --git a/client/templates/admin/user/manage_user.js b/client/templates/admin/user/manage_user.js deleted file mode 100644 index f0ecdc76..00000000 --- a/client/templates/admin/user/manage_user.js +++ /dev/null @@ -1,28 +0,0 @@ -Template.registerHelper('userSearchQuery',function(){ - return Session.get("userSearchQuery"); -}); - - -Template.manageUser.helpers({ - searchResults: function() { - return Meteor.users.search(Session.get('userSearchQuery')); - }, - searchMode: function() { - return Session.get("searchMode"); - } -}); - -Template.manageUser.events({ - "keyup #searchBox": function(event, template){ - event.preventDefault(); - //console.log(template.find(".searchTerm").value); - var term = template.find(".searchTerm").value; - if (_.isEmpty(term)){ - Session.set('userSearchQuery', ' '); - Session.set('searchMode',false); - }else{ - Session.set('searchMode',true); - Session.set('userSearchQuery', term); - } - }, -}); diff --git a/client/templates/admin/user/user_by_id.js b/client/templates/admin/user/user_by_id.js deleted file mode 100644 index 4fff0b4e..00000000 --- a/client/templates/admin/user/user_by_id.js +++ /dev/null @@ -1,45 +0,0 @@ -Template.registerHelper('selected', function(key, value) { - return key == value ? 'selected' : ''; -}); - -Template.registerHelper('isUpdateable', function(userId, role) { - var loggedInUserId = Meteor.userId(); - - return ((userId == loggedInUserId || (role === 'moderator' && (!Roles.userIsInRole( loggedInUserId, ['admin'], 'CB')))) ? true : false); -}); - -Template.userById.helpers({ - getUser:function(){ - var userId = FlowRouter.getParam('userId'); - - if (Roles.userIsInRole(userId, ['admin'], 'CB')) { - return ; - } else { - return Meteor.users.find({_id:userId}); - } - - }, - userRoles: function(){ - const roles = Meteor.users.findOne({_id: FlowRouter.getParam('userId') }).roles; - const roleGroup = 'CB'; - return roles[roleGroup] ; - }, -}); - -Template.userById.events({ - "change #authorization": function(event, template){ - var currentAuthorization = template.find('#authorization').value; - const roleGroup = 'CB'; - var pastAuthorization = this.roles[roleGroup].pop(); - var userId = this._id; - var username = this.username; - Meteor.call("updateRoles",this._id,this.username,currentAuthorization,pastAuthorization, roleGroup, function(error, result) { - if (result) { - swal("Done!", "Updated "+ username +"'s access right ", "success") - }else{ - swal("Oops something went wrong!", error + "\n Try again", "error"); - } - - }); - }, -}); diff --git a/client/templates/admin/user/users_by_role.js b/client/templates/admin/user/users_by_role.js deleted file mode 100644 index 711ca550..00000000 --- a/client/templates/admin/user/users_by_role.js +++ /dev/null @@ -1,14 +0,0 @@ -Template.registerHelper("currentRole", function(){ - return FlowRouter.getParam('role'); -}); -Template.usersByRole.helpers({ - users:function(){ - return Meteor.users.find({'roles.CB': FlowRouter.getParam('role') }); - } -}); - -Template.usersByRole.events({ - "click #foo": function(event, template){ - - } -}); diff --git a/client/templates/availability/availability_slot_local.js b/client/templates/availability/availability_slot_local.js deleted file mode 100644 index 59ea95c0..00000000 --- a/client/templates/availability/availability_slot_local.js +++ /dev/null @@ -1,12 +0,0 @@ -import UHR from 'uhr'; - -Template.availabilitySlotLocal.helpers({ - localSlotTime: function(){ - const utcSlot = Template.instance().data; - - let localSlot = UHR(utcSlot.d, utcSlot.h, utcSlot.m, -1) - localSlot.hour = localSlot.hour < 10 ? `0${localSlot.hour}` : localSlot.hour; - localSlot.minute = localSlot.minute < 10 ? `0${localSlot.minute}` : localSlot.minute; - return localSlot; - } -}); diff --git a/client/templates/discussion/add_discussion_modal.js b/client/templates/discussion/add_discussion_modal.js deleted file mode 100644 index 525ee751..00000000 --- a/client/templates/discussion/add_discussion_modal.js +++ /dev/null @@ -1,91 +0,0 @@ -import discussion_tags from '/imports/data/discussion_tags.js'; -import slack_channels from '/imports/data/slack_channels.js'; - -Template.addDiscussionModal.onCreated(function(){ - const instance = this; - instance.processing = new ReactiveVar(false); - instance.discussionDescriptionPreview = new ReactiveVar(''); - console.log(discussion_tags.length); - Meteor.setTimeout(function () { - const tags = discussion_tags; - instance.$(".discussion-tags-multiple", tags).select2({ - placeholder: "Tags (required)", - data: tags, - tags: false, - tokenSeparators: [','], - allowClear: true - }); - - const channels = slack_channels; - instance.$(".slack-channel", channels).select2({ - placeholder: "Channel (optional)", - data: channels, - tags: false, - allowClear: true - }); - },500) - -}); - -Template.addDiscussionModal.helpers({ - processing: function(){ - return Template.instance().processing.get(); - }, - discussionDescriptionPreview: function(){ - return Template.instance().discussionDescriptionPreview.get(); - } -}); - -Template.addDiscussionModal.events({ - "change #discussionDescription": function(event, template){ - event.preventDefault(); - template.discussionDescriptionPreview.set(($.trim(template.find("#discussionDescription").value))) - }, - "submit .addDiscussion": function(event, template){ - event.preventDefault(); - - $('.form-control').css({ "border": '1px solid #cccccc'}); - - if ($.trim(template.find("#discussionTopic").value) == '') { - $('#discussionTopic').css({ 'border': '#FF0000 1px solid'}); - return Bert.alert( 'Topic', 'warning', 'growl-top-right' ); - } - - if (!$(".discussion-tags-multiple").val() ||$(".discussion-tags-multiple").val().length < 1) { - return Bert.alert( 'Please save at least 1 tag. ', 'warning', 'growl-top-right' ); - } - - - if ( $.trim(template.find("#discussionDescription").value) == '') { - $('#discussionDescription').css({ 'border': '#FF0000 1px solid'}); - return Bert.alert( 'Description', 'warning', 'growl-top-right' ); - } - - // console.log(this); - const data = { - topic: $.trim(template.find("#discussionTopic").value), - description: $.trim(template.find("#discussionDescription").value), - groupId: this._id, - groupTitle: this.title, - groupSlug: this.slug, - tags: $(".discussion-tags-multiple").val(), - channel: $(".slack-channel").val() || '#announcements' - } - - // console.log(data); - template.processing.set( true ); - - Meteor.call("discussions.insert", data, function(error, result){ - if(error){ - template.processing.set( false ); - Bert.alert( error.reason , 'danger', 'growl-top-right' ); - } - if(result){ - template.processing.set( false ); - Bert.alert( 'Discussion Created!' , 'success', 'growl-top-right' ); - Modal.hide() - } - }); - - } -}); diff --git a/client/templates/discussion/all_discussions.js b/client/templates/discussion/all_discussions.js deleted file mode 100644 index 5dc44296..00000000 --- a/client/templates/discussion/all_discussions.js +++ /dev/null @@ -1,137 +0,0 @@ -import _ from 'lodash'; - -Template.allDiscussions.onCreated(function() { - const title = "CodeBuddies | Discussions"; - const metaInfo = { - name: "description", - content: "CodeBuddies is a community of independent code learners who enjoy sharing knowledge and helping each other learn faster. We come from all over the world; there are members living in the United States, Japan, Sweden, the United Kingdom, Russia, Australia, Canada, India, and more. Everyone is welcome, independent of previous knowledge." - }; - - DocHead.setTitle(title); - DocHead.addMeta(metaInfo); - - let instance = this; - instance.limit = new ReactiveVar(10); - instance.flag = new ReactiveVar(false); - instance.tags = new ReactiveVar([]); - instance.discussionFilter = new ReactiveVar('newest'); - - let projection = new Object(); - instance.autorun(function () { - let limit = instance.limit.get(); - - FlowRouter.watchPathChange(); - let queryParams = FlowRouter.current().queryParams; - let tags = []; - instance.tags.set(tags) - if (! _.isEmpty(queryParams)) { - tags = queryParams.tags - instance.tags.set(tags) - } - - let discussionFilter = instance.discussionFilter.get() || 'newest'; - switch (discussionFilter) { - case 'newest': - projection.sort = {'created_at' : -1}; - break; - case 'oldest': - projection.sort = {'created_at' : 1}; - break; - case 'most-commented': - projection.sort = {'response_count' : -1}; - break; - case 'least-commented': - projection.sort = {'response_count' : 1}; - break; - default: - projection.sort = {'created_at' : -1}; - } - - instance.subscribe('allDiscussions', limit, discussionFilter, tags); - }); - - - - instance.loadDiscussions = function() { - return Discussions.find({},projection); - } - -}); - -Template.allDiscussions.onRendered(function() { - let instance = this; - - instance.scrollHandler = function(){ - - if ($(window).scrollTop() > ($(document).height() - $(window).height()) -20 && !instance.flag.get()){ - - if(Discussions.find().count() === instance.limit.get()){ - instance.limit.set(instance.limit.get() + 10); - $('body').addClass('stop-scrolling'); - }else{ - if(Discussions.find().count() < instance.limit.get()){ - instance.flag.set(true); - }else { - - } - } - - } - - }.bind(instance); - $(window).on("scroll" ,instance.scrollHandler); - -}); - -Template.allDiscussions.helpers({ - discussions: function(){ - return Template.instance().loadDiscussions(); - }, - status:function(){ - return Template.instance().flag.get(); - }, - discussionFilter: function() { - return Template.instance().discussionFilter.get(); - }, - discussionSearchMode: function(){ - return Session.get('discussionSearchMode'); - }, - tags: function(){ - return Template.instance().tags.get(); - } -}); - -Template.allDiscussions.events({ - "click #addDiscussion" (event, template){ - const data = { - _id: "CB", - title: "CB", - slug: "CB" - } - Modal.show("addDiscussionModal", data); - }, - "click .newest": function(event, template) { - event.preventDefault(); - template.discussionFilter.set('newest'); - }, - "click .oldest": function(event, template) { - event.preventDefault(); - template.discussionFilter.set('oldest'); - }, - "click .most-commented": function(event, template) { - event.preventDefault(); - template.discussionFilter.set('most-commented'); - }, - "click .least-commented": function(event, template) { - event.preventDefault(); - template.discussionFilter.set('least-commented'); - }, - "click .clear-tags": function(event, template) { - event.preventDefault(); - FlowRouter.go('/discussions'); - }, -}); - -Template.allDiscussions.onDestroyed(function(){ - $(window).off("scroll", this.scrollHandler); -}); diff --git a/client/templates/discussion/discussion.js b/client/templates/discussion/discussion.js deleted file mode 100644 index 8b10e516..00000000 --- a/client/templates/discussion/discussion.js +++ /dev/null @@ -1,13 +0,0 @@ -Template.discussion.onCreated(function () { - - const instance = this; - instance.subscribe('discussionById', FlowRouter.getParam('discussionId')); - -}); - - -Template.discussion.helpers({ - discussion() { - return Discussions.findOne({"_id": FlowRouter.getParam('discussionId')}); - } -}); diff --git a/client/templates/discussion/discussion_new_response.js b/client/templates/discussion/discussion_new_response.js deleted file mode 100644 index d298129e..00000000 --- a/client/templates/discussion/discussion_new_response.js +++ /dev/null @@ -1,48 +0,0 @@ -Template.discussionNewResponse.onCreated(function () { - - const instance = this; - instance.discussionResponsePreview = new ReactiveVar(''); - -}); - -Template.discussionNewResponse.helpers({ - discussionResponsePreview() { - return Template.instance().discussionResponsePreview.get(); - } -}); -Template.discussionNewResponse.events({ - "change #discussionResponse": function(event, template){ - event.preventDefault(); - template.discussionResponsePreview.set(($.trim(template.find("#discussionResponse").value))) - }, - "submit .response-form": function(event, template){ - event.preventDefault(); - $('.form-control').css({ "border": '1px solid #cccccc'}); - - if ( $.trim(template.find("#discussionResponse").value) == '') { - $('#discussionResponse').css({ 'border': '#FF0000 1px solid'}); - return Bert.alert( 'Response Can\'t be empty', 'warning', 'growl-top-right' ); - } - - const data = { - discussion_id: this._id, - parent_id: "empty", - text: $.trim(template.find("#discussionResponse").value), - } - - - - Meteor.call("discussionResponses.insert", data, function(error, result){ - if(error){ - console.log("error", error); - - } - if(result){ - // clear response box - template.find("#discussionResponse").value = '' ; - template.discussionResponsePreview.set(''); - } - }); - - }, -}); diff --git a/client/templates/discussion/discussion_responses_list.js b/client/templates/discussion/discussion_responses_list.js deleted file mode 100644 index fcc03394..00000000 --- a/client/templates/discussion/discussion_responses_list.js +++ /dev/null @@ -1,13 +0,0 @@ -Template.discussionResponsesList.onCreated(function () { - - const instance = this; - instance.subscribe('responsesByDiscussionId', FlowRouter.getParam('discussionId')); - -}); - - -Template.discussionResponsesList.helpers({ - responses() { - return DiscussionResponses.find({},{sort: { created_at: 1}}) - }, -}); diff --git a/client/templates/discussion/discussion_search_box.js b/client/templates/discussion/discussion_search_box.js deleted file mode 100644 index 6c8dd1ed..00000000 --- a/client/templates/discussion/discussion_search_box.js +++ /dev/null @@ -1,34 +0,0 @@ -Template.discussionSearchBox.onRendered(function(){ - if(Session.get("discussionSearchTerm") !== ''){ - $("#discussionSearchBox").val(Session.get("discussionSearchTerm")); - } -}); - -Template.discussionSearchBox.helpers({ - discussionSearchMode:function(){ - return Session.get("discussionSearchMode"); - }, - discussionSearchTerm:function(){ - return Session.get("discussionSearchTerm"); - }, -}); - - -Template.discussionSearchBox.events({ - "keyup #discussionSearchBox": function(event, template){ - event.preventDefault(); - const discussionSearchTerm = template.find("#discussionSearchBox").value; - - if (_.isEmpty(discussionSearchTerm)){ - Session.set('discussionSearchTerm', ''); - Session.set('discussionSearchMode',false); - }else{ - Session.set('discussionSearchMode',true); - Session.set('discussionSearchTerm', discussionSearchTerm); - } - }, - "click #clearSearch": function(event, template){ - Session.set('discussionSearchTerm', ''); - Session.set('discussionSearchMode',false); - } -}); diff --git a/client/templates/discussion/discussion_search_result.js b/client/templates/discussion/discussion_search_result.js deleted file mode 100644 index 583b9a0a..00000000 --- a/client/templates/discussion/discussion_search_result.js +++ /dev/null @@ -1,17 +0,0 @@ -Template.discussionSearchResult.onCreated(function() { - this.autorun(() => { - if (!_.isEmpty(Session.get('discussionSearchTerm'))){ - this.subscribe('discussionsSearch', Session.get('discussionSearchTerm')); - } - - }); -}); - -Template.discussionSearchResult.helpers({ - discussionSearchTerm() { - return Session.get('discussionSearchTerm'); - }, - searchResults() { - return Discussions.search(Session.get('discussionSearchTerm')); - } -}); diff --git a/client/templates/discussion/discussion_sidebar_notification.js b/client/templates/discussion/discussion_sidebar_notification.js deleted file mode 100644 index cb110d8c..00000000 --- a/client/templates/discussion/discussion_sidebar_notification.js +++ /dev/null @@ -1,34 +0,0 @@ -Template.discussionSidebarNotification.events({ - "click #subscribe": function(event, template){ - event.preventDefault(); - const data = { - id: this._id - } - - Meteor.call("discussions.subscribe", data, function(error, result){ - if(error){ - Bert.alert( error.reason , 'danger', 'growl-top-right' ); - } - if(result){ - Bert.alert( 'Subscribed!' , 'success', 'growl-top-right' ); - } - }); - - }, - "click #unsubscribe": function(event, template){ - event.preventDefault(); - const data = { - id: this._id - } - - Meteor.call("discussions.unsubscribe", data, function(error, result){ - if(error){ - Bert.alert( error.reason , 'danger', 'growl-top-right' ); - } - if(result){ - Bert.alert( 'Unsubscribed!' , 'success', 'growl-top-right' ); - } - }); - - }, -}); diff --git a/client/templates/discussion/discussion_sidebar_topics.js b/client/templates/discussion/discussion_sidebar_topics.js deleted file mode 100644 index 4f239808..00000000 --- a/client/templates/discussion/discussion_sidebar_topics.js +++ /dev/null @@ -1,38 +0,0 @@ -Template.discussionSidebarTopic.onCreated(function () { - let instance = this ; - instance.activeTopics = new ReactiveVar(0); - instance.recentTopics = new ReactiveVar(0); - - let data = { - type: 'active', - id: FlowRouter.getParam('discussionId') - } - - Meteor.call('discussions.getTopics', data ,function(error, result) { - if(error){ - console.log("error", error); - } - if(result){ - instance.activeTopics.set(result); - } - }); - - data.type = 'recent' - Meteor.call('discussions.getTopics', data ,function(error, result) { - if(error){ - console.log("error", error); - } - if(result){ - instance.recentTopics.set(result); - } - }); - -}); -Template.discussionSidebarTopic.helpers({ - activeTopics: function(){ - return Template.instance().activeTopics.get(); - }, - recentTopics: function(){ - return Template.instance().recentTopics.get(); - }, -}); diff --git a/client/templates/discussion/edit_discussion_modal.js b/client/templates/discussion/edit_discussion_modal.js deleted file mode 100644 index 2f6312db..00000000 --- a/client/templates/discussion/edit_discussion_modal.js +++ /dev/null @@ -1,104 +0,0 @@ -import discussion_tags from '/imports/data/discussion_tags.js'; - - -Template.editDiscussionModal.onCreated(function(){ - const instance = this; - instance.processing = new ReactiveVar(false); - instance.discussionDescriptionPreview = new ReactiveVar(''); -}); - -Template.editDiscussionModal.onRendered(function(){ - const instance = this; - instance.discussionDescriptionPreview.set(instance.data.description) - - - let tags = discussion_tags; - - - instance.data.tags.forEach((tag)=> { - if (tags.indexOf(tag) < 0) { - tags.push(tag); - } - }) - - tags = tags.map((tag) => { - if (instance.data.tags.indexOf(tag) > -1) { - return {id: tag, text: tag, selected: true} - } - return {id: tag, text: tag} - }) - - - Meteor.setTimeout(function () { - - instance.$(".discussion-tags-multiple", tags).select2({ - placeholder: "Tags (required)", - data: tags, - tags: false, - tokenSeparators: [','], - allowClear: true - }); - - },500) - -}); - -Template.editDiscussionModal.helpers({ - processing: function(){ - return Template.instance().processing.get(); - }, - discussionDescriptionPreview: function(){ - // console.log(Template.instance().discussionDescriptionPreview.get()); - - return Template.instance().discussionDescriptionPreview.get(); - } -}); - -Template.editDiscussionModal.events({ - "change #discussionDescription": function(event, template){ - event.preventDefault(); - template.discussionDescriptionPreview.set(($.trim(template.find("#discussionDescription").value))) - }, - "submit .editDiscussion": function(event, template){ - event.preventDefault(); - - $('.form-control').css({ "border": '1px solid #cccccc'}); - - if ($.trim(template.find("#discussionTopic").value) == '') { - $('#discussionTopic').css({ 'border': '#FF0000 1px solid'}); - return Bert.alert( 'Topic', 'warning', 'growl-top-right' ); - } - - if (!$(".discussion-tags-multiple").val() ||$(".discussion-tags-multiple").val().length < 1) { - $('.discussion-tags-multiple').css({ 'border': '#FF0000 1px solid'}); - return Bert.alert( 'Please save at least 1 tag. ', 'warning', 'growl-top-right' ); - } - - if ( $.trim(template.find("#discussionDescription").value) == '') { - $('#discussionDescription').css({ 'border': '#FF0000 1px solid'}); - return Bert.alert( 'Description', 'warning', 'growl-top-right' ); - } - - const data = { - id: this._id, - topic: $.trim(template.find("#discussionTopic").value), - description: $.trim(template.find("#discussionDescription").value), - tags: $(".discussion-tags-multiple").val() - } - - template.processing.set( true ); - - Meteor.call("discussions.update", data, function(error, result){ - if(error){ - template.processing.set( false ); - Bert.alert( error.reason , 'danger', 'growl-top-right' ); - } - if(result){ - template.processing.set( false ); - Bert.alert( 'Discussion Updated!' , 'success', 'growl-top-right' ); - Modal.hide() - } - }); - - } -}); diff --git a/client/templates/discussion/edit_response_modal.js b/client/templates/discussion/edit_response_modal.js deleted file mode 100644 index bca42cee..00000000 --- a/client/templates/discussion/edit_response_modal.js +++ /dev/null @@ -1,60 +0,0 @@ -Template.editResponseModal.onCreated(function(){ - const instance = this; - instance.processing = new ReactiveVar(false); - instance.discussionResponsePreview = new ReactiveVar(''); -}); - -Template.editResponseModal.onRendered(function(){ - const instance = this; - instance.discussionResponsePreview.set(instance.data.text) -}); - -Template.editResponseModal.helpers({ - processing: function(){ - return Template.instance().processing.get(); - }, - discussionResponsePreview: function(){ - console.log(Template.instance().discussionResponsePreview.get()); - - return Template.instance().discussionResponsePreview.get(); - } -}); - -Template.editResponseModal.events({ - "change #editDiscussionResponse": function(event, template){ - event.preventDefault(); - template.discussionResponsePreview.set(($.trim(template.find("#editDiscussionResponse").value))) - }, - "submit .editDiscussion": function(event, template){ - event.preventDefault(); - - $('.form-control').css({ "border": '1px solid #cccccc'}); - - if ( $.trim(template.find("#editDiscussionResponse").value) == '') { - $('#editDiscussionResponse').css({ 'border': '#FF0000 1px solid'}); - return Bert.alert( 'Description', 'warning', 'growl-top-right' ); - } - - // console.log(this); - const data = { - id: this._id, - text: $.trim(template.find("#editDiscussionResponse").value), - } - - // console.log(data); - template.processing.set( true ); - - Meteor.call("discussionResponses.update", data, function(error, result){ - if(error){ - template.processing.set( false ); - Bert.alert( error.reason , 'danger', 'growl-top-right' ); - } - if(result){ - template.processing.set( false ); - Bert.alert( 'Responses Updated!' , 'success', 'growl-top-right' ); - Modal.hide() - } - }); - - } -}); diff --git a/client/templates/hangout/hangout_cards.js b/client/templates/hangout/hangout_cards.js deleted file mode 100644 index e8b0dea7..00000000 --- a/client/templates/hangout/hangout_cards.js +++ /dev/null @@ -1,59 +0,0 @@ -Template.hangoutCards.onCreated(function() { - var instance = this; - instance.limit = new ReactiveVar(12); - instance.flag = new ReactiveVar(false); - - instance.autorun(function () { - var limit = instance.limit.get(); - instance.subscribe('hangouts', limit); - }); - - var instance = this; - - instance.loadHangouts = function(flag = 1) { - return Hangouts.find({}, {sort: {start: flag}}); - } - - const now = new Date(); - instance.liveHangoutsCount = function() { - return Hangouts.find({'end': { $gte : now }}).count() || 0; - } - - instance.pastHangoutsCount = function() { - return Hangouts.find({'end': { $lt : now }}).count() || 0; - } - - instance.addMoreHangouts = function(){ - - if(Hangouts.find().count() === instance.limit.get()){ - instance.limit.set(instance.limit.get() + 9); - - }else{ - if(Hangouts.find().count() < instance.limit.get()){ - instance.flag.set(true); - } - } - } - -}); - -Template.hangoutCards.helpers({ - hangouts:function(flag){ - return Template.instance().loadHangouts(flag); - }, - status:function(){ - return Template.instance().flag.get(); - }, - liveHangoutsCount: function() { - return Template.instance().liveHangoutsCount(); - }, - pastHangoutsCount: function() { - return Template.instance().pastHangoutsCount(); - } -}); - -Template.hangoutCards.events({ - "click #loadMore": function(event, template){ - template.addMoreHangouts(); - } -}); diff --git a/client/templates/home/footer.js b/client/templates/home/footer.js deleted file mode 100644 index 7d389100..00000000 --- a/client/templates/home/footer.js +++ /dev/null @@ -1,37 +0,0 @@ -Template.footer.helpers({ - languageSwitchers: function() { - const supportedLanguages = TAPi18n.getLanguages(); - const currentLanguageCode = TAPi18n.getLanguage(); - return Object.keys(supportedLanguages).map(function(languageCode){ return { - name: supportedLanguages[languageCode].name, - attributes: { - 'data-lang':'', - 'data-lang-code': languageCode, - 'data-lang-name': supportedLanguages[languageCode].name, - 'class': (languageCode === currentLanguageCode ? 'selected_language' : '') - }}; - }); - } -}); - -Template.footer.events({ - "click [data-lang]": function(event, template){ - event.preventDefault(); - const languageCode = event.target.dataset.langCode - const languageName = event.target.dataset.langName - if (languageCode === TAPi18n.getLanguage()) - return; - - TAPi18n.setLanguage(languageCode) - .done(() => { - Bert.alert(TAPi18n.__("alert_language_change", `${languageName} (${languageCode})`), 'success', 'growl-top-right' ); - }) - .fail((error) => { - Bert.alert(TAPi18n.__("alert_language_change_fail", `${languageName} (${languageCode})`), 'danger', 'growl-top-right' ); - console.log(error); - }) - .always(() => { - localStorage.setItem('languageCode', TAPi18n.getLanguage()); - }) - } -}); diff --git a/client/templates/home/home.js b/client/templates/home/home.js deleted file mode 100644 index f9c18abe..00000000 --- a/client/templates/home/home.js +++ /dev/null @@ -1,11 +0,0 @@ -// Meteor.startup(function() { -// $('head').append(''); -// $('head').append(''); -// }); - -Template.home.onCreated(function(){ - var title = "CodeBuddies | Home"; - var metaInfo = {name: "description", content: "We're a community learning code via a Slack chatroom, a Facebook Group, and peer-to-peer organized screensharing/pair-programming hangouts. Learning with others helps us learn faster. The project is free, open-sourced, and 100% community-built."}; - DocHead.setTitle(title); - DocHead.addMeta(metaInfo); -}); diff --git a/client/templates/home/home_logged_in.js b/client/templates/home/home_logged_in.js deleted file mode 100644 index bae200c5..00000000 --- a/client/templates/home/home_logged_in.js +++ /dev/null @@ -1,59 +0,0 @@ -Template.homeLoggedIn.onCreated(function(){ - var title = "CodeBuddies | Home"; - var metaInfo = {name: "description", content: "We're a community learning code via a Slack chatroom, a Facebook Group, and peer-to-peer organized screensharing/pair-programming hangouts. Learning with others helps us learn faster. The project is free, open-sourced, and 100% community-built."}; - DocHead.setTitle(title); - DocHead.addMeta(metaInfo); - - this.autorun(() => { - this.subscribe("userStatus"); - if (!_.isEmpty(Session.get('hangoutSearchTerm'))){ - this.subscribe('hangoutSearch',Session.get('hangoutSearchTerm')); - } - }); - -}); - -Template.homeLoggedIn.helpers({ - userCount: function() { - var totalUsers = Session.get('userCount'); - //console.log(totalUsers); - return totalUsers; - }, - searchResults: function() { - return Hangouts.search(Session.get('hangoutSearchTerm')); - }, - hangoutSearchTerm () { - return Session.get("hangoutSearchTerm"); - }, - hangoutSearchMode () { - // console.log(Session.get('hangoutSearchMode')); - return Session.get("hangoutSearchMode"); - } -}); - - -Template.homeLoggedIn.events({ - "keyup #searchBox": function(event, template){ - event.preventDefault(); - // console.log(template.find(".searchTerm").value); - var term = template.find(".searchTerm").value; - if (_.isEmpty(term)){ - Session.set('hangoutSearchTerm', ''); - Session.set('hangoutSearchMode',false); - }else{ - Session.set('hangoutSearchMode',true); - Session.set('hangoutSearchTerm', term); - } - }, - "click .create-hangout-popup": function() { - Modal.show('createHangoutModal'); - }, - "click #hangout-faq-popup": function() { - Modal.show('hangoutFAQModal'); - }, - "click #clearSearch": function(event, template){ - Session.set('hangoutSearchTerm', ""); - Session.set('hangoutSearchMode', false); - } - -}); diff --git a/client/templates/nav/header.js b/client/templates/nav/header.js deleted file mode 100644 index 4450422f..00000000 --- a/client/templates/nav/header.js +++ /dev/null @@ -1,57 +0,0 @@ -Template.header.onRendered(function(){ - this.subscribe('attendees', 10); -}) -Template.header.helpers({ - user: function() { - return Meteor.user(); - }, - notificationCount:function(){ - return ReactiveMethod.call('notificationCount'); - }, - userNotificationCount:function(){ - return RSVPnotifications.find({createorId:Meteor.userId(),'seen':false}).count(); - } -}); - -Template.header.events({ - 'click .signInSlack': function(event) { - var options = { - requestPermissions: ['identity.basic', 'identity.email'] - }; - Meteor.loginWithSlack(options, function() { - FlowRouter.go("hangouts"); - }); - - }, - 'click #signOut': function(event) { - Meteor.logout(function(err) { - FlowRouter.go("home"); - }); - }, - 'click #newHangout': function(event) { - Modal.show('createHangoutModal'); - }, - 'click #newStudyGroup': function(event) { - Modal.show('newStudyGroupModal'); - }, - "click #newDiscussion" (event, template){ - const data = { - _id: "CB", - title: "CB", - slug: "CB" - } - - Modal.show("addDiscussionModal", data); - }, - 'click .signInGithub': function(event) { - var options = { - requestPermissions: ['read:user', 'user:email'] - }; - Meteor.loginWithGithub(options, function(err) { - if (!err) { - FlowRouter.go("hangouts"); - } - }); - - }, -}); diff --git a/client/templates/other/about.js b/client/templates/other/about.js deleted file mode 100644 index 0f418814..00000000 --- a/client/templates/other/about.js +++ /dev/null @@ -1,48 +0,0 @@ -import flags from '/imports/data/flags.json'; -import c from '/imports/data/contributors.json'; - -Template.about.onCreated(function(){ - var title = "CodeBuddies | About"; - var metaInfo = {name: "description", content: "Our community spends a lot of time helping each other on Slack, but it's hard to schedule study times in advance in a chatroom, and it's also hard to know who else is online possibly working on the same thing at the same time. This website solves those issues."}; - DocHead.setTitle(title); - DocHead.addMeta(metaInfo); -}); - -Template.about.onRendered(function(){ - $(function() { - - // Move to the top of the page on render - var $window = $(window); - if ($window.scrollTop() > 0) { - $window.scrollTop(0); - } - - //$('a.user-popover').popover({ trigger: "hover", html: "true" }); - $('a.user-popover').each(function () { - var $elem = $(this); - $elem.popover({ - placement: 'top', - trigger: 'hover', - html: true, - container: $elem, - animation: false, - title: 'Name goes here', - content: 'This is the popover content. You should be able to mouse over HERE.' - }); - }); - - // display fallback image if image url of contributor is broken - $('img.img-circle').on('error', function() { - $(this).prop('src', '/images/unknown.png'); - }); - }); -}); - -Template.about.helpers({ - countries: function() { - return flags.countries; - }, - contributors: function() { - return c.contributors; - } -}); diff --git a/client/templates/other/faq.js b/client/templates/other/faq.js deleted file mode 100644 index 2d9889c3..00000000 --- a/client/templates/other/faq.js +++ /dev/null @@ -1,17 +0,0 @@ -Template.faq.onCreated(function(){ - var title = "CodeBuddies | Home"; - var metaInfo = {name: "description", content: "CodeBuddies is a community of independent code learners who enjoy sharing knowledge and helping each other learn faster. We come from all over the world; there are members living in the United States, Japan, Sweden, the United Kingdom, Russia, Australia, Canada, India, and more. Everyone is welcome, independent of previous knowledge."}; - DocHead.setTitle(title); - DocHead.addMeta(metaInfo); DocHead.setTitle('CodeBuddies | FAQ'); -}); - -Template.faq.onRendered(function() { - $(function() { - - // Move to the top of the page on render - var $window = $(window); - if ($window.scrollTop() > 0) { - $window.scrollTop(0); - } - }); -}); diff --git a/client/templates/other/hangout-faq.js b/client/templates/other/hangout-faq.js deleted file mode 100644 index 5977d3c3..00000000 --- a/client/templates/other/hangout-faq.js +++ /dev/null @@ -1,16 +0,0 @@ -Template.hangoutFAQModal.onCreated(function(){ - var title = "CodeBuddies | Home"; - var metaInfo = {name: "description", content: "CodeBuddies is a community of independent code learners who enjoy sharing knowledge and helping each other learn faster. We come from all over the world; there are members living in the United States, Japan, Sweden, the United Kingdom, Russia, Australia, Canada, India, and more. Everyone is welcome, independent of previous knowledge."}; - DocHead.setTitle(title); - DocHead.addMeta(metaInfo); DocHead.setTitle('CodeBuddies | Hangout FAQ'); -}); - -Template.hangoutFAQModal.onRendered(function() { - $(function() { - let currentUrl = window.location.href; - if (currentUrl.indexOf("hangout-faq") > -1) { - $("#hangout-faq-modal").removeClass('modal fade'); - $('.modal-header button').hide(); - } - }); -}); diff --git a/client/templates/other/has_blocked.js b/client/templates/other/has_blocked.js deleted file mode 100644 index 9de3a149..00000000 --- a/client/templates/other/has_blocked.js +++ /dev/null @@ -1,20 +0,0 @@ -"use strict" - -import '../../../imports/ui/pages/users/basic_user_information'; - -Template.hasBlocked.helpers({ - target: function () { - let loggedInUser = Meteor.user() - if (Roles.userIsInRole(loggedInUser, 'inactive', 'CB')) { - return 'suspended' - } else { - if (loggedInUser - && loggedInUser.profile.hasOwnProperty('complete') - && ! loggedInUser.profile.complete){ - - return 'basicUserInformation' - } - return this.targetTemplate - } - } -}) diff --git a/client/templates/other/sponsor-us.js b/client/templates/other/sponsor-us.js deleted file mode 100644 index 89099a77..00000000 --- a/client/templates/other/sponsor-us.js +++ /dev/null @@ -1,3 +0,0 @@ -Template.sponsorUs.onCreated(function(){ - -}); \ No newline at end of file diff --git a/client/templates/other/termsOfService.js b/client/templates/other/termsOfService.js deleted file mode 100644 index f6c6e4a2..00000000 --- a/client/templates/other/termsOfService.js +++ /dev/null @@ -1,10 +0,0 @@ -Template.termsOfService.onCreated(function(){ - var title = "CodeBuddies | Terms of Service"; - var metaInfo = { - name: "description", - content: "CodeBuddies is a community of independent code learners who enjoy sharing knowledge and helping each other learn faster. We come from all over the world; there are members living in the United States, Japan, Sweden, the United Kingdom, Russia, Australia, Canada, India, and more. Everyone is welcome, independent of previous knowledge." - }; - - DocHead.setTitle(title); - DocHead.addMeta(metaInfo); -}); diff --git a/client/templates/profile/profile-hangouts-joined/profile-hangouts-joined.js b/client/templates/profile/profile-hangouts-joined/profile-hangouts-joined.js deleted file mode 100644 index 447d589f..00000000 --- a/client/templates/profile/profile-hangouts-joined/profile-hangouts-joined.js +++ /dev/null @@ -1,54 +0,0 @@ -import _ from 'lodash'; - -Template.hangoutsJoined.onCreated(function() { - var instance = this; - instance.limit = new ReactiveVar(5); - instance.flag = new ReactiveVar(false); - - instance.autorun(function () { - var limit = instance.limit.get(); - var userId = FlowRouter.getParam('userId'); - instance.subscribe('hangoutsJoined', limit, userId); - }); - -}); - - -Template.hangoutsJoined.onRendered(function() { - var instance = this; - - instance.loadHangouts = function() { - var userId = FlowRouter.getParam('userId'); - var arr = Hangouts.find().fetch().reverse(); - var userHangouts = _.filter(arr, function(elem) { return elem.users.includes(userId)}); - return userHangouts; - } - - instance.addMoreHangouts = function(){ - - if(Hangouts.find().count() === instance.limit.get()){ - instance.limit.set(instance.limit.get() + 8); - - }else{ - if(Hangouts.find().count() < instance.limit.get()){ - instance.flag.set(true); - } - } - } - -}); - -Template.hangoutsJoined.helpers({ - hangouts:function(){ - return Template.instance().loadHangouts(); - }, - status:function(){ - return Template.instance().flag.get(); - } -}); - -Template.hangoutsJoined.events({ - "click #loadMore": function(event, template){ - template.addMoreHangouts(); - } -}); diff --git a/client/templates/settings/user_account_settings.js b/client/templates/settings/user_account_settings.js deleted file mode 100644 index 2ffac9eb..00000000 --- a/client/templates/settings/user_account_settings.js +++ /dev/null @@ -1,70 +0,0 @@ -Template.userAccountSettings.onCreated(function() { - let instance = this; - const title = "CodeBuddies | User Account Settings"; - DocHead.setTitle(title); - - // instance.flag = new ReactiveVar(false); - instance.emails_preference = new ReactiveVar([]); - instance.selected_emails_preference = new ReactiveVar([]); -}); - -Template.userAccountSettings.onRendered(function () { - let instance = this; - - - instance.autorun(function(){ - const emails_preference = Meteor.user() && Meteor.user().emails_preference; - if (emails_preference) { - instance.emails_preference.set(emails_preference); - } - }); - - -}); - -Template.userAccountSettings.helpers({ - emails_preference () { - return Template.instance().emails_preference.get(); - }, - preferences_modified () { - const emails_preference = Template.instance().emails_preference.get(); - const selected_emails_preference = Template.instance().selected_emails_preference.get(); - return JSON.stringify(emails_preference.sort()) === JSON.stringify(selected_emails_preference.sort()); - } -}); - -Template.userAccountSettings.events({ - "click #deleteMyAccount": function(event, template){ - Modal.show('deleteMyAccountModal'); - - }, - 'change [name="email_preference"]': function ( event, template ) { - - const selected_emails_preference = template.findAll( "input[name=email_preference]:checked"); - let results = selected_emails_preference.map((item)=>{ - return item.defaultValue; - }) - - template.selected_emails_preference.set(results) - }, - "click #updateEmailsPreference": function(event, template){ - - const selected_emails_preference = template.findAll( "input[name=email_preference]:checked"); - let results = selected_emails_preference.map((item)=>{ - return item.defaultValue; - }) - - const data = { - emails_preference: results - } - - Meteor.call("updateEmailsPreference", data, function(error, result){ - if(error){ - return Bert.alert(error.reason, 'danger', 'growl-top-right'); - } - if(result){ - return Bert.alert( 'Your preferences is updated!', 'success', 'growl-top-right' ); - } - }); - }, -}); diff --git a/client/templates/status/status-item.js b/client/templates/status/status-item.js deleted file mode 100644 index 4726fe5b..00000000 --- a/client/templates/status/status-item.js +++ /dev/null @@ -1,17 +0,0 @@ -Template.statusItem.helpers({ - hangoutStatus: function() { - if (this.statusHangout == 'silent') - return "fa-microphone-slash"; - else if (this.statusHangout == 'teaching') - return "fa-user"; - else if (this.statusHangout == "collaboration") - return "fa-users"; - else - return "fa-microphone-slash"; - }, - logged_in_using_codebuddies_team: function() { - if (!(Meteor.loggingIn() || Meteor.userId())) { - return Meteor.user().profile.team_id === Meteor.settings.team_id; - } - } -}); diff --git a/client/templates/study_groups/edit_study_group_info_modal.js b/client/templates/study_groups/edit_study_group_info_modal.js deleted file mode 100644 index c61bd290..00000000 --- a/client/templates/study_groups/edit_study_group_info_modal.js +++ /dev/null @@ -1,65 +0,0 @@ -Template.editStudyGroupInfoModal.onCreated(function () { - let instance = this; - instance.processing = new ReactiveVar(false); - instance.introCharCount = new ReactiveVar(140); -}); - -Template.editStudyGroupInfoModal.onRendered(function () { - let instance = this; - let introCharCount = $("#sgIntro").val().length || 0; - instance.introCharCount.set(140 - introCharCount) -}); - -Template.editStudyGroupInfoModal.helpers({ - processing() { - return Template.instance().processing.get(); - }, - introCharCount() { - return Template.instance().introCharCount.get(); - } -}); - -Template.editStudyGroupInfoModal.events({ - "keyup #sgIntro": function(event, template){ - let introCharCount = $("#sgIntro").val().length || 0; - template.introCharCount.set(140 - introCharCount) - }, - "submit .updateStudyGroupInfo": function(event, template){ - event.preventDefault(); - - $('.form-control').css({ "border": '1px solid #cccccc'}); - - if ($.trim(template.find("#sgIntro").value) == '') { - $('#sgIntro').css({ 'border': '#FF0000 1px solid'}); - return Bert.alert( 'Study Group Introduction', 'warning', 'growl-top-right' ); - } - if ( $("#sgIntro").val().length > 140) { - $('#sgIntro').css({ 'border': '#FF0000 1px solid'}); - return Bert.alert( 'Study Group Introduction', 'warning', 'growl-top-right' ); - } - - - const data = { - id: this._id, - introduction: $.trim(template.find("#sgIntro").value), - description: $.trim(template.find("#sgDesc").value) - } - - - // console.log(data); - template.processing.set( true ); - - Meteor.call("updateStudyGroupInfo", data, function(error, result){ - if(error){ - template.processing.set( false ); - Bert.alert( error.reason , 'danger', 'growl-top-right' ); - } - if(result){ - template.processing.set( false ); - Bert.alert( 'Description updated!' , 'success', 'growl-top-right' ); - Modal.hide() - } - }); - - } -}); diff --git a/client/templates/study_groups/edit_study_group_resources_modal.js b/client/templates/study_groups/edit_study_group_resources_modal.js deleted file mode 100644 index ea634cbd..00000000 --- a/client/templates/study_groups/edit_study_group_resources_modal.js +++ /dev/null @@ -1,59 +0,0 @@ -Template.editStudyGroupResourcesModal.onCreated(function () { - let instance = this; - instance.processing = new ReactiveVar(false); - instance.alert = new ReactiveVar(false); -}); - -Template.editStudyGroupResourcesModal.helpers({ - processing() { - return Template.instance().processing.get(); - }, - alert() { - return Template.instance().alert.get(); - }, - isError(elementId) { - return Template.instance().alert.get().elementId === elementId; - } -}); - -Template.editStudyGroupResourcesModal.events({ - "submit .updateStudyGroupResources": function(event, template){ - event.preventDefault(); - - $('.form-control').css({ "border": '1px solid #cccccc'}); - - if ($.trim(template.find("#sgResourceTitle").value) == '') { - $('#sgResourceTitle').css({ 'border': '#FF0000 1px solid'}); - return template.alert.set({ type: "alert-warning", elementId:"sgResourceTitle", message: "Please include a link title." }); - } - if ($.trim(template.find("#sgResourceURL").value) == '') { - $('#sgResourceURL').css({ 'border': '#FF0000 1px solid'}); - return template.alert.set({ type: "alert-warning", elementId:"sgResourceURL", message: "Please include a link URL." }); - } - - let data = { - studyGroupId: this._id, - studyGroupTitle: this.title, - studyGroupSlug: this.slug, - resourceTitle: template.find("#sgResourceTitle").value, - resourceURL : template.find("#sgResourceURL").value - } - - // console.log(data); - template.processing.set( true ); - template.alert.set( false ); - - Meteor.call("addResource", data, function(error, result){ - if(error){ - template.processing.set( false ); - template.alert.set( { type: "alert-danger", message: error.reason } ); - } - if(result){ - template.processing.set( false ); - Bert.alert( 'Link has been added', 'success', 'growl-top-right' ); - Modal.hide() - } - }); - - } -}); diff --git a/client/templates/study_groups/edit_study_group_title_modal.js b/client/templates/study_groups/edit_study_group_title_modal.js deleted file mode 100644 index f5ec1c18..00000000 --- a/client/templates/study_groups/edit_study_group_title_modal.js +++ /dev/null @@ -1,117 +0,0 @@ -Template.editStudyGroupTitleModal.onCreated(function () { - let instance = this; - instance.processing = new ReactiveVar(false); - instance.titleCharCount = new ReactiveVar(70); - instance.taglineCharCount = new ReactiveVar(60); -}); - -Template.editStudyGroupTitleModal.onRendered(function () { - let instance = this; - let titleCharCount = $("#sgTitle").val().length || 0; - instance.titleCharCount.set(70 - titleCharCount) - - let taglineCharCount = $("#sgTagline").val().length || 0; - instance.taglineCharCount.set(60 - taglineCharCount) - - let tags = [ 'Below are some popular tags. Feel free to type your own! White spaces are supported.', 'JavaScript', 'Python', 'Go', 'CSS', 'PHP', 'R', 'NodeJS', 'D3', 'MongoDB', 'Meteor', 'Java']; - - instance.data.tags.forEach((tag)=> { - if (tags.indexOf(tag) < 0) { - tags.push(tag); - } - }) - - tags = tags.map((tag) => { - if (instance.data.tags.indexOf(tag) > -1) { - return {id: tag, text: tag, selected: true} - } - return {id: tag, text: tag} - }) - - Meteor.setTimeout(function () { - - instance.$(".study-group-tags-multiple", tags).select2({ - placeholder: "Tags (required)", - data: tags, - tags: true, - tokenSeparators: [','], - allowClear: true - }); - - },500) - -}); - -Template.editStudyGroupTitleModal.helpers({ - processing() { - return Template.instance().processing.get(); - }, - titleCharCount() { - return Template.instance().titleCharCount.get(); - }, - taglineCharCount() { - return Template.instance().taglineCharCount.get(); - } -}); - -Template.editStudyGroupTitleModal.events({ - "keyup #sgTitle": function(event, template){ - let titleCharCount = $("#sgTitle").val().length || 0; - template.titleCharCount.set(70 - titleCharCount) - }, - "keyup #sgTagline": function(event, template){ - let taglineCharCount = $("#sgTagline").val().length || 0; - template.taglineCharCount.set(60 - taglineCharCount) - }, - "submit .updateStudyGroupTitle": function(event, template){ - event.preventDefault(); - - $('.form-control').css({ "border": '1px solid #cccccc'}); - - if ($.trim(template.find("#sgTitle").value) == '') { - $('#sgTitle').css({ 'border': '#FF0000 1px solid'}); - return Bert.alert( 'Your title cannot be empty.', 'warning', 'growl-top-right' ); - } - if ($.trim(template.find("#sgTagline").value) == '') { - $('#sgTitle').css({ 'border': '#FF0000 1px solid'}); - return Bert.alert( 'Your tagline cannot be empty.', 'warning', 'growl-top-right' ); - } - if ( $("#sgTitle").val().length > 70) { - $('#sgTitle').css({ 'border': '#FF0000 1px solid'}); - return Bert.alert( 'Please shorten your title.', 'warning', 'growl-top-right' ); - } - if ( $("#sgTagline").val().length > 60) { - $('#sgTagline').css({ 'border': '#FF0000 1px solid'}); - return Bert.alert( 'Please shorten your tagline.', 'warning', 'growl-top-right' ); - } - - if (!$(".study-group-tags-multiple").val() ||$(".study-group-tags-multiple").val().length <= 2) { - $('study-group-tags-multiple').css({ 'border': '#FF0000 1px solid'}); - return Bert.alert( 'Please save at least 3 tags. ', 'warning', 'growl-top-right' ); - } - - const data = { - id: this._id, - title: $.trim(template.find("#sgTitle").value), - tagline: $.trim(template.find("#sgTagline").value), - tags: $(".study-group-tags-multiple").val() - } - - - // console.log(data); - template.processing.set( true ); - - Meteor.call("updateStudyGroupTitle", data, function(error, result){ - if(error){ - template.processing.set( false ); - Bert.alert( error.reason , 'danger', 'growl-top-right' ); - } - if(result){ - template.processing.set( false ); - Bert.alert( 'The information about your study group has been updated!' , 'success', 'growl-top-right' ); - Modal.hide() - } - }); - - } -}); diff --git a/client/templates/study_groups/my_study_groups.js b/client/templates/study_groups/my_study_groups.js deleted file mode 100644 index de081bd5..00000000 --- a/client/templates/study_groups/my_study_groups.js +++ /dev/null @@ -1,104 +0,0 @@ -Template.myStudyGroups.onCreated(function() { - const title = "CodeBuddies | My Study Groups"; - const metaInfo = { - name: "description", - content: "CodeBuddies is a community of independent code learners who enjoy sharing knowledge and helping each other learn faster. We come from all over the world; there are members living in the United States, Japan, Sweden, the United Kingdom, Russia, Australia, Canada, India, and more. Everyone is welcome, independent of previous knowledge." - }; - - DocHead.setTitle(title); - DocHead.addMeta(metaInfo); - - let instance = this; - instance.limit = new ReactiveVar(30); - instance.flag = new ReactiveVar(false); - instance.leftStudyGroup = new ReactiveVar(false); - - - instance.autorun(function () { - let limit = instance.limit.get(); - instance.subscribe('myStudyGroups', limit); - - if (instance.leftStudyGroup.get() === true) { - instance.subscribe('myStudyGroups', limit); - instance.leftStudyGroup.set(false); - } - - const hangoutIds = StudyGroups.find({}, { fields: { _id: 1 } }).map(x => `cb${x._id}`); - instance.subscribe('allHangoutParticipants', hangoutIds); - }); - - instance.loadStudyGroups = function() { - /* filter out study group where logged in user is not a member */ - return StudyGroups.find({'members.id': {$eq: Meteor.userId()}}, {sort: {createdAt: 1}}); - } - - -}); - - -Template.myStudyGroups.onRendered(function() { - let instance = this; - - instance.scrollHandler = function(){ - - if ($(window).scrollTop() > ($(document).height() - $(window).height()) -20 && !instance.flag.get()){ - - if(StudyGroups.find().count() === instance.limit.get()){ - instance.limit.set(instance.limit.get() + 9); - $('body').addClass('stop-scrolling'); - }else{ - if(StudyGroups.find().count() < instance.limit.get()){ - instance.flag.set(true); - }else { - - } - } - - } - - - }.bind(instance); - $(window).on("scroll" ,instance.scrollHandler); -}); - -Template.myStudyGroups.helpers({ - studyGroups: function(){ - return Template.instance().loadStudyGroups(); - }, - status:function(){ - return Template.instance().flag.get(); - }, - numParticipants: function(studyGroupId) { - const hangoutId = `cb${studyGroupId}`; - const appState = AppStats.findOne({ _id: hangoutId }); - if (appState && appState.participants ) { - return appState.participants.length - } - return 0; - } -}); - -Template.myStudyGroups.events({ - 'click #newStudyGroup': function(event, template){ - event.preventDefault(); - Modal.show('newStudyGroupModal'); - }, - 'click .btn-leave-study-group': function(event, template) { - event.preventDefault(); - let data = { - studyGroupId: this._id, - studyGroupTitle: this.title, - studyGroupSlug: this.slug - } - - Meteor.call("leaveStudyGroup", data, function(error, result) { - if(error) { - return Bert.alert( error.reason, 'danger', 'growl-top-right' ); - } - if(result){ - template.leftStudyGroup.set(true); - return Bert.alert( 'You have left the study group!', 'success', 'growl-top-right' ); - } - }); - } -}); diff --git a/client/templates/study_groups/new_study_group_modal.js b/client/templates/study_groups/new_study_group_modal.js deleted file mode 100644 index 24d86655..00000000 --- a/client/templates/study_groups/new_study_group_modal.js +++ /dev/null @@ -1,107 +0,0 @@ - -Template.newStudyGroupModal.onCreated(function() { - let instance = this; - instance.processing = new ReactiveVar(false); - instance.titleCharCount = new ReactiveVar(70); - instance.taglineCharCount = new ReactiveVar(60); -}); - -Template.newStudyGroupModal.onRendered(function() { - let instance = this; - let titleCharCount = $("#title").val().length || 0; - instance.titleCharCount.set(70 - titleCharCount) - - let taglineCharCount = $("#tagline").val().length || 0; - instance.taglineCharCount.set(60 - taglineCharCount) - - Meteor.setTimeout(function () { - const tags = [ 'Below are some popular tags. Feel free to type your own! White spaces are supported.', 'JavaScript', 'Python', 'Go', 'CSS', 'PHP', 'R', 'NodeJS', 'D3', 'MongoDB', 'Meteor', 'Java']; - instance.$(".study-group-tags-multiple", tags).select2({ - placeholder: "Tags (required)", - data: tags, - tags: true, - tokenSeparators: [','], - allowClear: true - }); - },500) - -}); - -Template.newStudyGroupModal.helpers({ - processing() { - return Template.instance().processing.get(); - }, - titleCharCount() { - return Template.instance().titleCharCount.get(); - }, - taglineCharCount() { - return Template.instance().taglineCharCount.get(); - } -}); - -Template.newStudyGroupModal.events({ - "keyup #title": function(event, template){ - let titleCharCount = $("#title").val().length || 0; - template.titleCharCount.set(70 - titleCharCount) - }, - "keyup #tagline": function(event, template){ - let taglineCharCount = $("#tagline").val().length || 0; - template.taglineCharCount.set(60 - taglineCharCount) - }, - "submit .newStudyGroup": function(event, template){ - - event.preventDefault(); - - if ($.trim(template.find("#title").value) == '') { - return Bert.alert( 'Please input a name for your study group.', 'warning', 'growl-top-right' ); - } - if ($.trim(template.find("#tagline").value) == '') { - return Bert.alert( 'Please input a tagline for your study group.', 'warning', 'growl-top-right' ); - } - if ( $("#title").val().length > 70) { - $('#title').css({ 'border': '#FF0000 1px solid'}); - return Bert.alert( 'Please shorten your title.', 'warning', 'growl-top-right' ); - } - if ( $("#tagline").val().length > 60) { - $('#tagline').css({ 'border': '#FF0000 1px solid'}); - return Bert.alert( 'Please shorten your tagline.', 'warning', 'growl-top-right' ); - } - - if (!$(".study-group-tags-multiple").val() ||$(".study-group-tags-multiple").val().length <= 2) { - return Bert.alert( 'Please save at least 3 tags. ', 'warning', 'growl-top-right' ); - } - - - const data = { - title:template.find('#title').value, - slug:template.find('#title').value.replace(/\s+/g, '-').toLowerCase(), - tagline:template.find('#tagline').value, - tags: $(".study-group-tags-multiple").val() - } - // console.log(data); - - template.processing.set( true ); - - Meteor.call("createNewStudyGroup", data, function(error, result){ - if(error){ - template.processing.set( false ); - Bert.alert( error.reason, 'danger', 'growl-top-right' ); - } - if(result){ - template.processing.set( false ); - template.find('#title').value=""; - template.find('#tagline').value=""; - - Modal.hide(); - FlowRouter.go('my study groups'); - Bert.alert({ - type: 'success', - message: 'Congratulations! Your study group "' + data.title + '" has been created.', - icon: 'fa-check-circle', - hideDelay: 6500 - }); - } - }); - - } -}); diff --git a/client/templates/study_groups/single_study_group.js b/client/templates/study_groups/single_study_group.js deleted file mode 100644 index cc4fff3e..00000000 --- a/client/templates/study_groups/single_study_group.js +++ /dev/null @@ -1,108 +0,0 @@ -Template.singleStudyGroup.onCreated(function() { - let instance = this; - instance.studyGroupId = FlowRouter.getParam('studyGroupId'); - instance.hangoutId = `cb${instance.studyGroupId}`; - instance.autorun(() => { - instance.subscribe('studyGroupById', instance.studyGroupId); - instance.subscribe('hangoutParticipants', instance.hangoutId); - }); - -}); - -Template.singleStudyGroup.onRendered(function(){ - const title = "CodeBuddies | Study Groups"; - const metaInfo = { - name: "description", - content: "CodeBuddies is a community of independent code learners who enjoy sharing knowledge and helping each other learn faster. We come from all over the world; there are members living in the United States, Japan, Sweden, the United Kingdom, Russia, Australia, Canada, India, and more. Everyone is welcome, independent of previous knowledge." - }; - - DocHead.setTitle(title); - DocHead.addMeta(metaInfo); - -}); - -Template.singleStudyGroup.helpers({ - studyGroup: function(){ - return StudyGroups.findOne({_id:FlowRouter.getParam('studyGroupId')}); - }, - usersOnlineCount:function(){ - return Meteor.users.find({ "status.online": true }).count(); - }, - resourcesCount: function(){ - return Resources.find().count(); - }, - learningsCount: function() { - return Learnings.find().count(); - }, - numParticipants: function() { - const appState = AppStats.findOne({ _id: Template.instance().hangoutId }); - if (appState && appState.participants ) { - return appState.participants.length - } - return 0; - } -}); - -Template.singleStudyGroup.events({ - 'click #hide-sidebar': function() { - $('.study-group-sidebar').hide(); - $('.study-group-body').removeClass('col-md-9').addClass('col-md-10 col-md-offset-1'); - $('#show-sidebar').fadeIn(); - }, - 'click #show-sidebar': function() { - $('.study-group-sidebar').show(); - $('.study-group-body').removeClass('col-md-10 col-md-offset-1').addClass('col-md-9'); - $('#show-sidebar').hide(); - }, - 'click #newHangout': function(event) { - Modal.show('createHangoutModal'); - }, - 'click .joinStudyGroup': function(event, template){ - event.preventDefault(); - - let data = { - studyGroupId: this._id, - studyGroupTitle: this.title, - studyGroupSlug: this.slug - } - - Meteor.call("joinStudyGroup", data, function(error, result){ - if(error){ - return Bert.alert( error.reason, 'danger', 'growl-top-right' ); - } - if(result){ - return Bert.alert( 'You have joined the study group!', 'success', 'growl-top-right' ); - - } - }); - - }, - 'click .leaveStudyGroup': function(event, template){ - event.preventDefault(); - - let data = { - studyGroupId: this._id, - studyGroupTitle: this.title, - studyGroupSlug: this.slug - } - - Meteor.call("leaveStudyGroup", data, function(error, result){ - if(error){ - return Bert.alert( error.reason, 'danger', 'growl-top-right' ); - } - if(result){ - return Bert.alert( 'You have left the study group!', 'success', 'growl-top-right' ); - - } - }); - - }, - 'click .memberDetail': function(event, template){ - event.preventDefault(); - return Modal.show('studyGroupMemberDetail', this); - }, - "click #editTitle": function(event, template){ - event.preventDefault(); - Modal.show('editStudyGroupTitleModal', this); - }, -}); diff --git a/client/templates/study_groups/study_group_availability.js b/client/templates/study_groups/study_group_availability.js deleted file mode 100644 index e372b35b..00000000 --- a/client/templates/study_groups/study_group_availability.js +++ /dev/null @@ -1,36 +0,0 @@ -Template.studyGroupAvailability.onCreated(function() { - let instance = this; - let studyGroupId = FlowRouter.getParam('studyGroupId'); - instance.subscribe('allStudyGroupAvailability', studyGroupId); - -}); - -Template.studyGroupAvailability.helpers({ - groupMembersAvailabilities (){ - return Availabilities.find({'study_group.id': FlowRouter.getParam('studyGroupId'), 'author.id': {$ne: Meteor.userId() } }, {sort: {start_day: 1, start_hour: 1, start_minute: 1 } }); - }, - currentUsersAvailabilities (){ - return Availabilities.find({'study_group.id': FlowRouter.getParam('studyGroupId'), 'author.id': Meteor.userId() }, {sort: {start_day: 1, start_hour: 1, start_minute: 1 } }); - } -}); - -Template.studyGroupAvailability.events({ - "click #addSlot" (event, template){ - Modal.show("editStudyGroupAvailabilitySlotModal", this); - }, - "click #removeSlot" (event, template){ - event.preventDefault(); - const data = { - availabilityId: this._id, - studyGroupId: this.study_group.id - } - Meteor.call("removeAvailabilitySlot", data, function(error, result){ - if(error){ - Bert.alert( error.reason, 'danger', 'growl-top-right' ); - } - if(result){ - Bert.alert( 'Slot has been removed', 'success', 'growl-top-right' ); - } - }); - }, -}); diff --git a/client/templates/study_groups/study_group_description.js b/client/templates/study_groups/study_group_description.js deleted file mode 100644 index 416e22e1..00000000 --- a/client/templates/study_groups/study_group_description.js +++ /dev/null @@ -1,6 +0,0 @@ -Template.studyGroupDescription.events({ - "click #editDescription": function(event, template){ - event.preventDefault(); - Modal.show('editStudyGroupInfoModal', this); - }, -}) diff --git a/client/templates/study_groups/study_group_hangouts.js b/client/templates/study_groups/study_group_hangouts.js deleted file mode 100644 index 5758d52d..00000000 --- a/client/templates/study_groups/study_group_hangouts.js +++ /dev/null @@ -1,81 +0,0 @@ -Template.studyGroupHangouts.onCreated(function() { - let instance = this; - instance.limit = new ReactiveVar(20); - instance.flag = new ReactiveVar(false); - - instance.autorun(function () { - let limit = instance.limit.get(); - let studyGroupId = FlowRouter.getParam('studyGroupId'); - instance.subscribe('studyGroupHangouts', studyGroupId, limit); - }); - - instance.loadHangouts = function() { - return Hangouts.find({}, {sort: {start: -1}}); - } - - const now = new Date(); - - instance.pastHangoutCount = function() { - return Hangouts.find({'end': {$lt : now}}).count() || 0; - } - - instance.liveHangoutCount = function() { - return Hangouts.find({'end': {$gte : now}}).count() || 0; - } -}); - -Template.studyGroupHangouts.onRendered(function() { - let instance = this; - - instance.scrollHandler = function(){ - - if ($(window).scrollTop() > ($(document).height() - $(window).height()) -20 && !instance.flag.get()){ - - if(Hangouts.find().count() === instance.limit.get()){ - instance.limit.set(instance.limit.get() + 9); - $('body').addClass('stop-scrolling'); - }else{ - if(Hangouts.find().count() < instance.limit.get()){ - instance.flag.set(true); - }else { - - } - } - - } - - }.bind(instance); - $(window).on("scroll" ,instance.scrollHandler); - -}); - - - -Template.studyGroupHangouts.helpers({ - hangouts:function(){ - return Template.instance().loadHangouts(); - }, - status:function(){ - return Template.instance().flag.get(); - }, - hangoutCount: function() { - return Template.instance().loadHangouts().count(); - }, - liveHangoutCount:function(){ - return Template.instance().liveHangoutCount(); - }, - pastHangoutCount:function(){ - return Template.instance().pastHangoutCount(); - } -}); - -Template.studyGroupHangouts.events({ - "click #newHangout": function(event) { - Modal.show('createHangoutModal'); - }, -}); - - -Template.studyGroupHangouts.onDestroyed(function(){ - $(window).off("scroll", this.scrollHandler); -}); diff --git a/client/templates/study_groups/study_group_member_detail.js b/client/templates/study_groups/study_group_member_detail.js deleted file mode 100644 index 446bade2..00000000 --- a/client/templates/study_groups/study_group_member_detail.js +++ /dev/null @@ -1,57 +0,0 @@ -Template.studyGroupMemberDetail.onRendered(function(){ - const user = this.data; - const studyGroupId = FlowRouter.getParam('studyGroupId'); - const instance = this; - this.autorun(function(){ - instance.subscribe("studyGroupMemberDetail", studyGroupId, user.id); - }); - -}); - - -Template.studyGroupMemberDetail.helpers({ - user: function(){ - - return Meteor.users.findOne({_id: Template.instance().data.id }); - - }, - groupId: function(){ - return FlowRouter.getParam('studyGroupId'); - }, - userRoles: function(){ - const roles = Meteor.users.findOne({_id: Template.instance().data.id }).roles; - const studyGroupId = FlowRouter.getParam('studyGroupId'); - return roles[studyGroupId].pop() ; - }, -}); - -Template.studyGroupMemberDetail.events({ - "change #authorization": function(event, template){ - - const user = this; - - const data = { - user: { - id: user._id, - username: user.username, - avatar: user.profile.avatar.default - }, - role: template.find("#authorization").value, - studyGroupId: FlowRouter.getParam('studyGroupId') - } - - //console.log(data); - - Meteor.call('updateUserRoleForStudyGroup', data ,function(error, result){ - if(error){ - Bert.alert( error.reason, 'danger', 'growl-top-right' ); - } - if(result){ - Modal.hide(); - Bert.alert( 'Role updated', 'success', 'growl-top-right' ); - } - }); - - - } -}); diff --git a/client/templates/study_groups/study_group_online_members.js b/client/templates/study_groups/study_group_online_members.js deleted file mode 100644 index 17263e4f..00000000 --- a/client/templates/study_groups/study_group_online_members.js +++ /dev/null @@ -1,14 +0,0 @@ -Template.studyGroupOnlineMembers.helpers({ - onlineUsers: function(){ - const onlineUsernames = Meteor.users.find({ "status.online": true }, { fields: { id: 1 }}) - .fetch() - .map(m => m._id); - const studyGroup = StudyGroups.findOne({_id:FlowRouter.getParam('studyGroupId')}); - if (studyGroup) { - const onlineMembers = studyGroup.members - .filter(m => onlineUsernames.indexOf(m.id) >= 0); - return onlineMembers; - } - return []; - } -}); diff --git a/client/templates/study_groups/study_group_resources.js b/client/templates/study_groups/study_group_resources.js deleted file mode 100644 index 0b50d837..00000000 --- a/client/templates/study_groups/study_group_resources.js +++ /dev/null @@ -1,5 +0,0 @@ -Template.studyGroupResources.events({ - "click #addResource": function(event, template){ - Modal.show("editStudyGroupResourcesModal", this); - }, -}); diff --git a/client/templates/study_groups/study_group_search_result.js b/client/templates/study_groups/study_group_search_result.js deleted file mode 100644 index 59f9b101..00000000 --- a/client/templates/study_groups/study_group_search_result.js +++ /dev/null @@ -1,56 +0,0 @@ -Template.studyGroupsSearchResult.onCreated(function() { - this.autorun(() => { - if (!_.isEmpty(Session.get('sgSearchTerm'))){ - this.subscribe('studyGroupSearch', Session.get('sgSearchTerm')); - } - - }); -}); - -Template.studyGroupsSearchResult.helpers({ - sgSearchTerm() { - return Session.get('sgSearchTerm'); - }, - searchResults() { - return StudyGroups.search(Session.get('sgSearchTerm')); - } -}); - - -Template.allStudyGroups.events({ - 'click .btn-leave-study-group-1': function(event, template) { - event.preventDefault(); - let data = { - studyGroupId: this._id, - studyGroupTitle: this.title, - studyGroupSlug: this.slug - } - - Meteor.call("leaveStudyGroup", data, function(error, result) { - if(error) { - return Bert.alert( error.reason, 'danger', 'growl-top-right' ); - } - if(result){ - return Bert.alert( 'You have left the study group!', 'success', 'growl-top-right' ); - } - }); - }, - 'click .btn-join-study-group-1': function(event, template) { - event.preventDefault(); - let data = { - studyGroupId: this._id, - studyGroupTitle: this.title, - studyGroupSlug: this.slug - } - - Meteor.call("joinStudyGroup", data, function(error, result){ - if(error){ - return Bert.alert( error.reason, 'danger', 'growl-top-right' ); - } - if(result){ - return Bert.alert( 'You have joined the study group!', 'success', 'growl-top-right' ); - - } - }); - } -}); diff --git a/client/templates/study_groups/study_groups_search_box.js b/client/templates/study_groups/study_groups_search_box.js deleted file mode 100644 index 3288ce84..00000000 --- a/client/templates/study_groups/study_groups_search_box.js +++ /dev/null @@ -1,34 +0,0 @@ -Template.studyGroupsSearchBox.onRendered(function(){ - if(Session.get("sgSearchTerm") !== ''){ - $("#sgSearchBox").val(Session.get("sgSearchTerm")); - } -}); - -Template.studyGroupsSearchBox.helpers({ - sgSearchMode:function(){ - //console.log(Session.get("landingPageSearchMode")); - return Session.get("sgSearchMode"); - }, - sgSearchTerm:function(){ - return Session.get("sgSearchTerm"); - }, -}); - - -Template.studyGroupsSearchBox.events({ - "keyup #sgSearchBox": function(event, template){ - event.preventDefault(); - const sgSearchTerm = template.find("#sgSearchBox").value; - if (_.isEmpty(sgSearchTerm)){ - Session.set('sgSearchTerm', ''); - Session.set('sgSearchMode',false); - }else{ - Session.set('sgSearchMode',true); - Session.set('sgSearchTerm', sgSearchTerm); - } - }, - "click #clearSearch": function(event, template){ - Session.set('sgSearchTerm', ''); - Session.set('sgSearchMode',false); - } -}); diff --git a/client/templates/usr-notification/rsvp.js b/client/templates/usr-notification/rsvp.js deleted file mode 100644 index 25a6c9a7..00000000 --- a/client/templates/usr-notification/rsvp.js +++ /dev/null @@ -1,52 +0,0 @@ -Template.registerHelper("isSingular", function(count){ - return count === 1 ? true : false; -}); - -Template.registerHelper("anyAttendees", function(count){ - return count > 0 ? true : false; -}); - -Template.rsvp.onCreated(function() { - var instance = this; - instance.flag = new ReactiveVar(false); - instance.limit = new ReactiveVar(10); - instance.autorun(function () { - var limit = instance.limit.get(); - var subscription = instance.subscribe('attendees', limit); - }); - - instance.dispNotifications = function() { - return RSVPnotifications.find({},{sort: {date: -1}}); - } - }); - - Template.rsvp.onRendered(function(){ - var instance = this; - - $('#flux').bind('scroll', function(){ - if($('#flux').scrollTop() + $('#flux').innerHeight()>=$('#flux')[0].scrollHeight){ - - if(RSVPnotifications.find().count() === instance.limit.get()){ - instance.limit.set(instance.limit.get() + 5); - $('body').addClass('stop-scrolling') - }else { - if(RSVPnotifications.find({},{sort: {date: -1}}).count() < instance.limit.get()){ - instance.flag.set(true); - } - } - - } - }); - }); - -Template.rsvp.helpers({ - notifications:function(){ - return Template.instance().dispNotifications(); - }, -}); - -Template.rsvp.events({ - "click .markAsRead": function(event, template){ - Meteor.call('markItRead', this._id, function(error, result) { }); - } -}); diff --git a/imports/ui/compatibilities/select2/_select2.css b/imports/ui/compatibilities/select2/_select2.css new file mode 100644 index 00000000..44a8472b --- /dev/null +++ b/imports/ui/compatibilities/select2/_select2.css @@ -0,0 +1,644 @@ +.select2-container { + box-sizing: border-box; + display: inline-block; + margin: 0; + position: relative; + vertical-align: middle; +} +.select2-container .select2-selection--single { + box-sizing: border-box; + cursor: pointer; + display: block; + height: 28px; + user-select: none; + -webkit-user-select: none; +} +.select2-container .select2-selection--single .select2-selection__rendered { + display: block; + padding-left: 8px; + padding-right: 20px; + overflow: hidden; + text-overflow: ellipsis; + white-space: nowrap; +} +.select2-container .select2-selection--single .select2-selection__clear { + position: relative; +} +.select2-container[dir="rtl"] .select2-selection--single .select2-selection__rendered { + padding-right: 8px; + padding-left: 20px; +} +.select2-container .select2-selection--multiple { + box-sizing: border-box; + cursor: pointer; + display: block; + min-height: 32px; + user-select: none; + -webkit-user-select: none; +} +.select2-container .select2-selection--multiple .select2-selection__rendered { + display: inline-block; + overflow: hidden; + padding-left: 8px; + text-overflow: ellipsis; + white-space: nowrap; +} +.select2-container .select2-search--inline { + float: left; + width: 250px; +} +.select2-container .select2-search--inline .select2-search__field { + box-sizing: border-box; + width: 100% !important; + border: none; + font-size: 100%; + margin-top: 5px; + padding: 0; +} +.select2-container .select2-search--inline .select2-search__field::-webkit-search-cancel-button { + -webkit-appearance: none; +} + +.select2-dropdown { + background-color: white; + border: 1px solid #aaa; + border-radius: 4px; + box-sizing: border-box; + display: block; + position: absolute; + left: -100000px; + width: 100%; + z-index: 1051; +} + +.select2-results { + display: block; +} + +.select2-results__options { + list-style: none; + margin: 0; + padding: 0; +} + +.select2-results__option { + padding: 6px; + user-select: none; + -webkit-user-select: none; +} +.select2-results__option[aria-selected] { + cursor: pointer; +} + +.select2-container--open .select2-dropdown { + left: 0; +} + +.select2-container--open .select2-dropdown--above { + border-bottom: none; + border-bottom-left-radius: 0; + border-bottom-right-radius: 0; +} + +.select2-container--open .select2-dropdown--below { + border-top: none; + border-top-left-radius: 0; + border-top-right-radius: 0; +} + +.select2-search--dropdown { + display: block; + padding: 4px; +} +.select2-search--dropdown .select2-search__field { + padding: 4px; + width: 100%; + box-sizing: border-box; +} +.select2-search--dropdown .select2-search__field::-webkit-search-cancel-button { + -webkit-appearance: none; +} +.select2-search--dropdown.select2-search--hide { + display: none; +} + +.select2-close-mask { + border: 0; + margin: 0; + padding: 0; + display: block; + position: fixed; + left: 0; + top: 0; + min-height: 100%; + min-width: 100%; + height: auto; + width: auto; + opacity: 0; + z-index: 99; + background-color: #fff; + filter: alpha(opacity=0); +} + +.select2-hidden-accessible { + border: 0 !important; + clip: rect(0 0 0 0) !important; + height: 1px !important; + margin: -1px !important; + overflow: hidden !important; + padding: 0 !important; + position: absolute !important; + width: 1px !important; +} + +.select2-container--default .select2-selection--single { + background-color: #fff; + border: 1px solid #aaa; + border-radius: 4px; +} +.select2-container--default .select2-selection--single .select2-selection__rendered { + color: #444; + line-height: 28px; +} +.select2-container--default .select2-selection--single .select2-selection__clear { + cursor: pointer; + float: right; + font-weight: bold; +} +.select2-container--default .select2-selection--single .select2-selection__placeholder { + color: #999; +} +.select2-container--default .select2-selection--single .select2-selection__arrow { + height: 26px; + position: absolute; + top: 1px; + right: 1px; + width: 20px; +} +.select2-container--default .select2-selection--single .select2-selection__arrow b { + border-color: #888 transparent transparent transparent; + border-style: solid; + border-width: 5px 4px 0 4px; + height: 0; + left: 50%; + margin-left: -4px; + margin-top: -2px; + position: absolute; + top: 50%; + width: 0; +} + +.select2-container--default[dir="rtl"] .select2-selection--single .select2-selection__clear { + float: left; +} + +.select2-container--default[dir="rtl"] .select2-selection--single .select2-selection__arrow { + left: 1px; + right: auto; +} + +.select2-container--default.select2-container--disabled .select2-selection--single { + background-color: #eee; + cursor: default; +} +.select2-container--default.select2-container--disabled + .select2-selection--single + .select2-selection__clear { + display: none; +} + +.select2-container--default.select2-container--open + .select2-selection--single + .select2-selection__arrow + b { + border-color: transparent transparent #888 transparent; + border-width: 0 4px 5px 4px; +} + +.select2-container--default .select2-selection--multiple { + background-color: white; + border: 1px solid #aaa; + border-radius: 4px; + cursor: text; +} +.select2-container--default .select2-selection--multiple .select2-selection__rendered { + box-sizing: border-box; + list-style: none; + margin: 0; + padding: 0 5px; + width: 100%; +} +.select2-container--default .select2-selection--multiple .select2-selection__rendered li { + list-style: none; +} +.select2-container--default .select2-selection--multiple .select2-selection__placeholder { + color: #999; + margin-top: 5px; + float: left; +} +.select2-container--default .select2-selection--multiple .select2-selection__clear { + cursor: pointer; + float: right; + font-weight: bold; + margin-top: 5px; + margin-right: 10px; +} +.select2-container--default .select2-selection--multiple .select2-selection__choice { + background-color: #e4e4e4; + border: 1px solid #aaa; + border-radius: 4px; + cursor: default; + float: left; + margin-right: 5px; + margin-top: 5px; + padding: 0 5px; +} +.select2-container--default .select2-selection--multiple .select2-selection__choice__remove { + color: #999; + cursor: pointer; + display: inline-block; + font-weight: bold; + margin-right: 2px; +} +.select2-container--default .select2-selection--multiple .select2-selection__choice__remove:hover { + color: #333; +} + +.select2-container--default[dir="rtl"] .select2-selection--multiple .select2-selection__choice, +.select2-container--default[dir="rtl"] .select2-selection--multiple .select2-selection__placeholder, +.select2-container--default[dir="rtl"] .select2-selection--multiple .select2-search--inline { + float: right; +} + +.select2-container--default[dir="rtl"] .select2-selection--multiple .select2-selection__choice { + margin-left: 5px; + margin-right: auto; +} + +.select2-container--default[dir="rtl"] + .select2-selection--multiple + .select2-selection__choice__remove { + margin-left: 2px; + margin-right: auto; +} + +.select2-container--default.select2-container--focus .select2-selection--multiple { + border: solid black 1px; + outline: 0; +} + +.select2-container--default.select2-container--disabled .select2-selection--multiple { + background-color: #eee; + cursor: default; +} + +.select2-container--default.select2-container--disabled .select2-selection__choice__remove { + display: none; +} + +.select2-container--default.select2-container--open.select2-container--above + .select2-selection--single, +.select2-container--default.select2-container--open.select2-container--above + .select2-selection--multiple { + border-top-left-radius: 0; + border-top-right-radius: 0; +} + +.select2-container--default.select2-container--open.select2-container--below + .select2-selection--single, +.select2-container--default.select2-container--open.select2-container--below + .select2-selection--multiple { + border-bottom-left-radius: 0; + border-bottom-right-radius: 0; +} + +.select2-container--default .select2-search--dropdown .select2-search__field { + border: 1px solid #aaa; +} + +.select2-container--default .select2-search--inline .select2-search__field { + background: transparent; + border: none; + outline: 0; + box-shadow: none; + -webkit-appearance: textfield; +} + +.select2-container--default .select2-results > .select2-results__options { + max-height: 200px; + overflow-y: auto; +} + +.select2-container--default .select2-results__option[role="group"] { + padding: 0; +} + +.select2-container--default .select2-results__option[aria-disabled="true"] { + color: #999; +} + +.select2-container--default .select2-results__option[aria-selected="true"] { + background-color: #ddd; +} + +.select2-container--default .select2-results__option .select2-results__option { + padding-left: 1em; +} +.select2-container--default + .select2-results__option + .select2-results__option + .select2-results__group { + padding-left: 0; +} +.select2-container--default + .select2-results__option + .select2-results__option + .select2-results__option { + margin-left: -1em; + padding-left: 2em; +} +.select2-container--default + .select2-results__option + .select2-results__option + .select2-results__option + .select2-results__option { + margin-left: -2em; + padding-left: 3em; +} +.select2-container--default + .select2-results__option + .select2-results__option + .select2-results__option + .select2-results__option + .select2-results__option { + margin-left: -3em; + padding-left: 4em; +} +.select2-container--default + .select2-results__option + .select2-results__option + .select2-results__option + .select2-results__option + .select2-results__option + .select2-results__option { + margin-left: -4em; + padding-left: 5em; +} +.select2-container--default + .select2-results__option + .select2-results__option + .select2-results__option + .select2-results__option + .select2-results__option + .select2-results__option + .select2-results__option { + margin-left: -5em; + padding-left: 6em; +} + +.select2-container--default .select2-results__option--highlighted[aria-selected] { + background-color: #5897fb; + color: white; +} + +.select2-container--default .select2-results__group { + cursor: default; + display: block; + padding: 6px; +} + +.select2-container--classic .select2-selection--single { + background-color: #f7f7f7; + border: 1px solid #aaa; + border-radius: 4px; + outline: 0; + background-image: -webkit-linear-gradient(top, white 50%, #eeeeee 100%); + background-image: -o-linear-gradient(top, white 50%, #eeeeee 100%); + background-image: linear-gradient(to bottom, white 50%, #eeeeee 100%); + background-repeat: repeat-x; + filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#FFFFFFFF', endColorstr='#FFEEEEEE', GradientType=0); +} +.select2-container--classic .select2-selection--single:focus { + border: 1px solid #5897fb; +} +.select2-container--classic .select2-selection--single .select2-selection__rendered { + color: #444; + line-height: 28px; +} +.select2-container--classic .select2-selection--single .select2-selection__clear { + cursor: pointer; + float: right; + font-weight: bold; + margin-right: 10px; +} +.select2-container--classic .select2-selection--single .select2-selection__placeholder { + color: #999; +} +.select2-container--classic .select2-selection--single .select2-selection__arrow { + background-color: #ddd; + border: none; + border-left: 1px solid #aaa; + border-top-right-radius: 4px; + border-bottom-right-radius: 4px; + height: 26px; + position: absolute; + top: 1px; + right: 1px; + width: 20px; + background-image: -webkit-linear-gradient(top, #eeeeee 50%, #cccccc 100%); + background-image: -o-linear-gradient(top, #eeeeee 50%, #cccccc 100%); + background-image: linear-gradient(to bottom, #eeeeee 50%, #cccccc 100%); + background-repeat: repeat-x; + filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#FFEEEEEE', endColorstr='#FFCCCCCC', GradientType=0); +} +.select2-container--classic .select2-selection--single .select2-selection__arrow b { + border-color: #888 transparent transparent transparent; + border-style: solid; + border-width: 5px 4px 0 4px; + height: 0; + left: 50%; + margin-left: -4px; + margin-top: -2px; + position: absolute; + top: 50%; + width: 0; +} + +.select2-container--classic[dir="rtl"] .select2-selection--single .select2-selection__clear { + float: left; +} + +.select2-container--classic[dir="rtl"] .select2-selection--single .select2-selection__arrow { + border: none; + border-right: 1px solid #aaa; + border-radius: 0; + border-top-left-radius: 4px; + border-bottom-left-radius: 4px; + left: 1px; + right: auto; +} + +.select2-container--classic.select2-container--open .select2-selection--single { + border: 1px solid #5897fb; +} +.select2-container--classic.select2-container--open + .select2-selection--single + .select2-selection__arrow { + background: transparent; + border: none; +} +.select2-container--classic.select2-container--open + .select2-selection--single + .select2-selection__arrow + b { + border-color: transparent transparent #888 transparent; + border-width: 0 4px 5px 4px; +} + +.select2-container--classic.select2-container--open.select2-container--above + .select2-selection--single { + border-top: none; + border-top-left-radius: 0; + border-top-right-radius: 0; + background-image: -webkit-linear-gradient(top, white 0%, #eeeeee 50%); + background-image: -o-linear-gradient(top, white 0%, #eeeeee 50%); + background-image: linear-gradient(to bottom, white 0%, #eeeeee 50%); + background-repeat: repeat-x; + filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#FFFFFFFF', endColorstr='#FFEEEEEE', GradientType=0); +} + +.select2-container--classic.select2-container--open.select2-container--below + .select2-selection--single { + border-bottom: none; + border-bottom-left-radius: 0; + border-bottom-right-radius: 0; + background-image: -webkit-linear-gradient(top, #eeeeee 50%, white 100%); + background-image: -o-linear-gradient(top, #eeeeee 50%, white 100%); + background-image: linear-gradient(to bottom, #eeeeee 50%, white 100%); + background-repeat: repeat-x; + filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#FFEEEEEE', endColorstr='#FFFFFFFF', GradientType=0); +} + +.select2-container--classic .select2-selection--multiple { + background-color: white; + border: 1px solid #aaa; + border-radius: 4px; + cursor: text; + outline: 0; +} +.select2-container--classic .select2-selection--multiple:focus { + border: 1px solid #5897fb; +} +.select2-container--classic .select2-selection--multiple .select2-selection__rendered { + list-style: none; + margin: 0; + padding: 0 5px; +} +.select2-container--classic .select2-selection--multiple .select2-selection__clear { + display: none; +} +.select2-container--classic .select2-selection--multiple .select2-selection__choice { + background-color: #e4e4e4; + border: 1px solid #aaa; + border-radius: 4px; + cursor: default; + float: left; + margin-right: 5px; + margin-top: 5px; + padding: 0 5px; +} +.select2-container--classic .select2-selection--multiple .select2-selection__choice__remove { + color: #888; + cursor: pointer; + display: inline-block; + font-weight: bold; + margin-right: 2px; +} +.select2-container--classic .select2-selection--multiple .select2-selection__choice__remove:hover { + color: #555; +} + +.select2-container--classic[dir="rtl"] .select2-selection--multiple .select2-selection__choice { + float: right; +} + +.select2-container--classic[dir="rtl"] .select2-selection--multiple .select2-selection__choice { + margin-left: 5px; + margin-right: auto; +} + +.select2-container--classic[dir="rtl"] + .select2-selection--multiple + .select2-selection__choice__remove { + margin-left: 2px; + margin-right: auto; +} + +.select2-container--classic.select2-container--open .select2-selection--multiple { + border: 1px solid #5897fb; +} + +.select2-container--classic.select2-container--open.select2-container--above + .select2-selection--multiple { + border-top: none; + border-top-left-radius: 0; + border-top-right-radius: 0; +} + +.select2-container--classic.select2-container--open.select2-container--below + .select2-selection--multiple { + border-bottom: none; + border-bottom-left-radius: 0; + border-bottom-right-radius: 0; +} + +.select2-container--classic .select2-search--dropdown .select2-search__field { + border: 1px solid #aaa; + outline: 0; +} + +.select2-container--classic .select2-search--inline .select2-search__field { + outline: 0; + box-shadow: none; +} + +.select2-container--classic .select2-dropdown { + background-color: white; + border: 1px solid transparent; +} + +.select2-container--classic .select2-dropdown--above { + border-bottom: none; +} + +.select2-container--classic .select2-dropdown--below { + border-top: none; +} + +.select2-container--classic .select2-results > .select2-results__options { + max-height: 200px; + overflow-y: auto; +} + +.select2-container--classic .select2-results__option[role="group"] { + padding: 0; +} + +.select2-container--classic .select2-results__option[aria-disabled="true"] { + color: grey; +} + +.select2-container--classic .select2-results__option--highlighted[aria-selected] { + background-color: #3875d7; + color: white; +} + +.select2-container--classic .select2-results__group { + cursor: default; + display: block; + padding: 6px; +} + +.select2-container--classic.select2-container--open .select2-dropdown { + border-color: #5897fb; +} diff --git a/client/compatibilities/select2/select2-bootstrap.css b/imports/ui/compatibilities/select2/select2-bootstrap.css similarity index 76% rename from client/compatibilities/select2/select2-bootstrap.css rename to imports/ui/compatibilities/select2/select2-bootstrap.css index c67641aa..9e5a3e5e 100644 --- a/client/compatibilities/select2/select2-bootstrap.css +++ b/imports/ui/compatibilities/select2/select2-bootstrap.css @@ -122,16 +122,16 @@ */ } -.select2-container--bootstrap .select2-results__option[role=group] { +.select2-container--bootstrap .select2-results__option[role="group"] { padding: 0; } -.select2-container--bootstrap .select2-results__option[aria-disabled=true] { +.select2-container--bootstrap .select2-results__option[aria-disabled="true"] { color: #777777; cursor: not-allowed; } -.select2-container--bootstrap .select2-results__option[aria-selected=true] { +.select2-container--bootstrap .select2-results__option[aria-selected="true"] { background-color: #f5f5f5; color: #262626; } @@ -145,31 +145,59 @@ padding: 6px 12px; } -.select2-container--bootstrap .select2-results__option .select2-results__option .select2-results__group { +.select2-container--bootstrap + .select2-results__option + .select2-results__option + .select2-results__group { padding-left: 0; } -.select2-container--bootstrap .select2-results__option .select2-results__option .select2-results__option { +.select2-container--bootstrap + .select2-results__option + .select2-results__option + .select2-results__option { margin-left: -12px; padding-left: 24px; } -.select2-container--bootstrap .select2-results__option .select2-results__option .select2-results__option .select2-results__option { +.select2-container--bootstrap + .select2-results__option + .select2-results__option + .select2-results__option + .select2-results__option { margin-left: -24px; padding-left: 36px; } -.select2-container--bootstrap .select2-results__option .select2-results__option .select2-results__option .select2-results__option .select2-results__option { +.select2-container--bootstrap + .select2-results__option + .select2-results__option + .select2-results__option + .select2-results__option + .select2-results__option { margin-left: -36px; padding-left: 48px; } -.select2-container--bootstrap .select2-results__option .select2-results__option .select2-results__option .select2-results__option .select2-results__option .select2-results__option { +.select2-container--bootstrap + .select2-results__option + .select2-results__option + .select2-results__option + .select2-results__option + .select2-results__option + .select2-results__option { margin-left: -48px; padding-left: 60px; } -.select2-container--bootstrap .select2-results__option .select2-results__option .select2-results__option .select2-results__option .select2-results__option .select2-results__option .select2-results__option { +.select2-container--bootstrap + .select2-results__option + .select2-results__option + .select2-results__option + .select2-results__option + .select2-results__option + .select2-results__option + .select2-results__option { margin-left: -60px; padding-left: 72px; } @@ -183,7 +211,8 @@ white-space: nowrap; } -.select2-container--bootstrap.select2-container--focus .select2-selection, .select2-container--bootstrap.select2-container--open .select2-selection { +.select2-container--bootstrap.select2-container--focus .select2-selection, +.select2-container--bootstrap.select2-container--open .select2-selection { -webkit-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075), 0 0 8px rgba(102, 175, 233, 0.6); box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075), 0 0 8px rgba(102, 175, 233, 0.6); -webkit-transition: border-color ease-in-out 0.15s, box-shadow ease-in-out 0.15s; @@ -191,7 +220,8 @@ -webkit-transition: border-color ease-in-out 0.15s, -webkit-box-shadow ease-in-out 0.15s; transition: border-color ease-in-out 0.15s, -webkit-box-shadow ease-in-out 0.15s; transition: border-color ease-in-out 0.15s, box-shadow ease-in-out 0.15s; - transition: border-color ease-in-out 0.15s, box-shadow ease-in-out 0.15s, -webkit-box-shadow ease-in-out 0.15s; + transition: border-color ease-in-out 0.15s, box-shadow ease-in-out 0.15s, + -webkit-box-shadow ease-in-out 0.15s; border-color: #66afe9; } @@ -204,7 +234,10 @@ */ } -.select2-container--bootstrap.select2-container--open .select2-selection .select2-selection__arrow b { +.select2-container--bootstrap.select2-container--open + .select2-selection + .select2-selection__arrow + b { border-color: transparent transparent #999 transparent; border-width: 0 4px 4px 4px; } @@ -245,12 +278,16 @@ } .select2-container--bootstrap.select2-container--disabled .select2-selection, -.select2-container--bootstrap.select2-container--disabled .select2-selection--multiple .select2-selection__choice { +.select2-container--bootstrap.select2-container--disabled + .select2-selection--multiple + .select2-selection__choice { background-color: #eeeeee; } .select2-container--bootstrap.select2-container--disabled .select2-selection__clear, -.select2-container--bootstrap.select2-container--disabled .select2-selection--multiple .select2-selection__choice__remove { +.select2-container--bootstrap.select2-container--disabled + .select2-selection--multiple + .select2-selection__choice__remove { display: none; } @@ -329,8 +366,8 @@ .select2-container--bootstrap .select2-selection--multiple .select2-selection__rendered { -webkit-box-sizing: border-box; - -moz-box-sizing: border-box; - box-sizing: border-box; + -moz-box-sizing: border-box; + box-sizing: border-box; display: block; line-height: 1.42857143; list-style: none; @@ -359,7 +396,10 @@ padding: 0 6px; } -.select2-container--bootstrap .select2-selection--multiple .select2-search--inline .select2-search__field { +.select2-container--bootstrap + .select2-selection--multiple + .select2-search--inline + .select2-search__field { background: transparent; padding: 0 12px; height: 32px; @@ -376,7 +416,9 @@ margin-right: 3px; } -.select2-container--bootstrap .select2-selection--multiple .select2-selection__choice__remove:hover { +.select2-container--bootstrap + .select2-selection--multiple + .select2-selection__choice__remove:hover { color: #333; } @@ -396,8 +438,16 @@ } .select2-container--bootstrap .select2-selection--single.input-sm .select2-selection__arrow b, -.input-group-sm .select2-container--bootstrap .select2-selection--single .select2-selection__arrow b, -.form-group-sm .select2-container--bootstrap .select2-selection--single .select2-selection__arrow b { +.input-group-sm + .select2-container--bootstrap + .select2-selection--single + .select2-selection__arrow + b, +.form-group-sm + .select2-container--bootstrap + .select2-selection--single + .select2-selection__arrow + b { margin-left: -5px; } @@ -409,17 +459,34 @@ } .select2-container--bootstrap .select2-selection--multiple.input-sm .select2-selection__choice, -.input-group-sm .select2-container--bootstrap .select2-selection--multiple .select2-selection__choice, -.form-group-sm .select2-container--bootstrap .select2-selection--multiple .select2-selection__choice { +.input-group-sm + .select2-container--bootstrap + .select2-selection--multiple + .select2-selection__choice, +.form-group-sm + .select2-container--bootstrap + .select2-selection--multiple + .select2-selection__choice { font-size: 12px; line-height: 1.5; margin: 4px 0 0 5px; padding: 0 5px; } -.select2-container--bootstrap .select2-selection--multiple.input-sm .select2-search--inline .select2-search__field, -.input-group-sm .select2-container--bootstrap .select2-selection--multiple .select2-search--inline .select2-search__field, -.form-group-sm .select2-container--bootstrap .select2-selection--multiple .select2-search--inline .select2-search__field { +.select2-container--bootstrap + .select2-selection--multiple.input-sm + .select2-search--inline + .select2-search__field, +.input-group-sm + .select2-container--bootstrap + .select2-selection--multiple + .select2-search--inline + .select2-search__field, +.form-group-sm + .select2-container--bootstrap + .select2-selection--multiple + .select2-search--inline + .select2-search__field { padding: 0 10px; font-size: 12px; height: 28px; @@ -427,8 +494,14 @@ } .select2-container--bootstrap .select2-selection--multiple.input-sm .select2-selection__clear, -.input-group-sm .select2-container--bootstrap .select2-selection--multiple .select2-selection__clear, -.form-group-sm .select2-container--bootstrap .select2-selection--multiple .select2-selection__clear { +.input-group-sm + .select2-container--bootstrap + .select2-selection--multiple + .select2-selection__clear, +.form-group-sm + .select2-container--bootstrap + .select2-selection--multiple + .select2-selection__clear { margin-top: 5px; } @@ -450,8 +523,16 @@ } .select2-container--bootstrap .select2-selection--single.input-lg .select2-selection__arrow b, -.input-group-lg .select2-container--bootstrap .select2-selection--single .select2-selection__arrow b, -.form-group-lg .select2-container--bootstrap .select2-selection--single .select2-selection__arrow b { +.input-group-lg + .select2-container--bootstrap + .select2-selection--single + .select2-selection__arrow + b, +.form-group-lg + .select2-container--bootstrap + .select2-selection--single + .select2-selection__arrow + b { border-width: 5px 5px 0 5px; margin-left: -5px; margin-left: -10px; @@ -466,8 +547,14 @@ } .select2-container--bootstrap .select2-selection--multiple.input-lg .select2-selection__choice, -.input-group-lg .select2-container--bootstrap .select2-selection--multiple .select2-selection__choice, -.form-group-lg .select2-container--bootstrap .select2-selection--multiple .select2-selection__choice { +.input-group-lg + .select2-container--bootstrap + .select2-selection--multiple + .select2-selection__choice, +.form-group-lg + .select2-container--bootstrap + .select2-selection--multiple + .select2-selection__choice { font-size: 18px; line-height: 1.3333333; border-radius: 4px; @@ -475,9 +562,20 @@ padding: 0 10px; } -.select2-container--bootstrap .select2-selection--multiple.input-lg .select2-search--inline .select2-search__field, -.input-group-lg .select2-container--bootstrap .select2-selection--multiple .select2-search--inline .select2-search__field, -.form-group-lg .select2-container--bootstrap .select2-selection--multiple .select2-search--inline .select2-search__field { +.select2-container--bootstrap + .select2-selection--multiple.input-lg + .select2-search--inline + .select2-search__field, +.input-group-lg + .select2-container--bootstrap + .select2-selection--multiple + .select2-search--inline + .select2-search__field, +.form-group-lg + .select2-container--bootstrap + .select2-selection--multiple + .select2-search--inline + .select2-search__field { padding: 0 16px; font-size: 18px; height: 44px; @@ -485,29 +583,49 @@ } .select2-container--bootstrap .select2-selection--multiple.input-lg .select2-selection__clear, -.input-group-lg .select2-container--bootstrap .select2-selection--multiple .select2-selection__clear, -.form-group-lg .select2-container--bootstrap .select2-selection--multiple .select2-selection__clear { +.input-group-lg + .select2-container--bootstrap + .select2-selection--multiple + .select2-selection__clear, +.form-group-lg + .select2-container--bootstrap + .select2-selection--multiple + .select2-selection__clear { margin-top: 10px; } -.select2-container--bootstrap .select2-selection.input-lg.select2-container--open .select2-selection--single { +.select2-container--bootstrap + .select2-selection.input-lg.select2-container--open + .select2-selection--single { /** * Make the dropdown arrow point up while the dropdown is visible. */ } -.select2-container--bootstrap .select2-selection.input-lg.select2-container--open .select2-selection--single .select2-selection__arrow b { +.select2-container--bootstrap + .select2-selection.input-lg.select2-container--open + .select2-selection--single + .select2-selection__arrow + b { border-color: transparent transparent #999 transparent; border-width: 0 5px 5px 5px; } -.input-group-lg .select2-container--bootstrap .select2-selection.select2-container--open .select2-selection--single { +.input-group-lg + .select2-container--bootstrap + .select2-selection.select2-container--open + .select2-selection--single { /** * Make the dropdown arrow point up while the dropdown is visible. */ } -.input-group-lg .select2-container--bootstrap .select2-selection.select2-container--open .select2-selection--single .select2-selection__arrow b { +.input-group-lg + .select2-container--bootstrap + .select2-selection.select2-container--open + .select2-selection--single + .select2-selection__arrow + b { border-color: transparent transparent #999 transparent; border-width: 0 5px 5px 5px; } @@ -550,7 +668,9 @@ } .select2-container--bootstrap[dir="rtl"] .select2-selection--multiple .select2-selection__choice, -.select2-container--bootstrap[dir="rtl"] .select2-selection--multiple .select2-selection__placeholder, +.select2-container--bootstrap[dir="rtl"] + .select2-selection--multiple + .select2-selection__placeholder, .select2-container--bootstrap[dir="rtl"] .select2-selection--multiple .select2-search--inline { float: right; } @@ -560,7 +680,9 @@ margin-right: 6px; } -.select2-container--bootstrap[dir="rtl"] .select2-selection--multiple .select2-selection__choice__remove { +.select2-container--bootstrap[dir="rtl"] + .select2-selection--multiple + .select2-selection__choice__remove { margin-left: 2px; margin-right: auto; } @@ -646,19 +768,43 @@ /** * Reset rounded corners */ -.input-group > .select2-hidden-accessible:first-child + .select2-container--bootstrap > .selection > .select2-selection, -.input-group > .select2-hidden-accessible:first-child + .select2-container--bootstrap > .selection > .select2-selection.form-control { +.input-group + > .select2-hidden-accessible:first-child + + .select2-container--bootstrap + > .selection + > .select2-selection, +.input-group + > .select2-hidden-accessible:first-child + + .select2-container--bootstrap + > .selection + > .select2-selection.form-control { border-bottom-right-radius: 0; border-top-right-radius: 0; } -.input-group > .select2-hidden-accessible:not(:first-child) + .select2-container--bootstrap:not(:last-child) > .selection > .select2-selection, -.input-group > .select2-hidden-accessible:not(:first-child) + .select2-container--bootstrap:not(:last-child) > .selection > .select2-selection.form-control { +.input-group + > .select2-hidden-accessible:not(:first-child) + + .select2-container--bootstrap:not(:last-child) + > .selection + > .select2-selection, +.input-group + > .select2-hidden-accessible:not(:first-child) + + .select2-container--bootstrap:not(:last-child) + > .selection + > .select2-selection.form-control { border-radius: 0; } -.input-group > .select2-hidden-accessible:not(:first-child):not(:last-child) + .select2-container--bootstrap:last-child > .selection > .select2-selection, -.input-group > .select2-hidden-accessible:not(:first-child):not(:last-child) + .select2-container--bootstrap:last-child > .selection > .select2-selection.form-control { +.input-group + > .select2-hidden-accessible:not(:first-child):not(:last-child) + + .select2-container--bootstrap:last-child + > .selection + > .select2-selection, +.input-group + > .select2-hidden-accessible:not(:first-child):not(:last-child) + + .select2-container--bootstrap:last-child + > .selection + > .select2-selection.form-control { border-bottom-left-radius: 0; border-top-left-radius: 0; } @@ -687,7 +833,8 @@ float: none; } -.input-group > .select2-container--bootstrap.select2-container--open, .input-group > .select2-container--bootstrap.select2-container--focus { +.input-group > .select2-container--bootstrap.select2-container--open, +.input-group > .select2-container--bootstrap.select2-container--focus { z-index: 3; } diff --git a/imports/ui/compatibilities/select2/select2.min.js b/imports/ui/compatibilities/select2/select2.min.js new file mode 100644 index 00000000..21cb9dc4 --- /dev/null +++ b/imports/ui/compatibilities/select2/select2.min.js @@ -0,0 +1,3483 @@ +/*! Select2 4.0.3 | https://github.com/select2/select2/blob/master/LICENSE.md */ !(function(a) { + "function" == typeof define && define.amd + ? define(["jquery"], a) + : a("object" == typeof exports ? require("jquery") : jQuery); +})(function(a) { + var b = (function() { + if (a && a.fn && a.fn.select2 && a.fn.select2.amd) var b = a.fn.select2.amd; + var b; + return ( + (function() { + if (!b || !b.requirejs) { + b ? (c = b) : (b = {}); + var a, c, d; + !(function(b) { + 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 ( + a = a.split("/"), + g = a.length - 1, + s.nodeIdCompat && w.test(a[g]) && (a[g] = a[g].replace(w, "")), + a = n.slice(0, n.length - 1).concat(a), + k = 0; + k < a.length; + k += 1 + ) + if (((m = a[k]), "." === m)) a.splice(k, 1), (k -= 1); + else if (".." === m) { + if (1 === k && (".." === a[2] || ".." === a[0])) break; + k > 0 && (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, c) { + return function() { + var d = v.call(arguments, 0); + return ( + "string" != typeof d[0] && 1 === d.length && d.push(null), + n.apply(b, d.concat([a, c])) + ); + }; + } + 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 c = r[a]; + delete r[a], (t[a] = !0), m.apply(b, c); + } + 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, c, d, f) { + var h, + k, + l, + m, + n, + s, + u = [], + v = typeof d; + if (((f = f || a), "undefined" === v || "function" === v)) { + for ( + c = !c.length && d.length ? ["require", "exports", "module"] : c, n = 0; + n < c.length; + n += 1 + ) + if (((m = o(c[n], f)), (k = m.f), "require" === k)) u[n] = p.require(a); + else if ("exports" === k) (u[n] = p.exports(a)), (s = !0); + else if ("module" === k) h = u[n] = p.module(a); + else if (e(q, k) || e(r, k) || e(t, k)) u[n] = j(k); + else { + if (!m.p) throw new Error(a + " missing " + k); + m.p.load(m.n, g(f, !0), i(k), {}), (u[n] = q[k]); + } + (l = d ? d.apply(q[a], u) : void 0), + a && + (h && h.exports !== b && h.exports !== q[a] + ? (q[a] = h.exports) + : (l === b && s) || (q[a] = l)); + } else a && (q[a] = d); + }), + (a = c = n = function(a, c, d, e, f) { + if ("string" == typeof a) return p[a] ? p[a](c) : j(o(a, c).f); + if (!a.splice) { + if (((s = a), s.deps && n(s.deps, s.callback), !c)) return; + c.splice ? ((a = c), (c = d), (d = null)) : (a = b); + } + return ( + (c = c || function() {}), + "function" == typeof d && ((d = e), (e = f)), + e + ? m(b, a, c, d) + : setTimeout(function() { + m(b, a, c, d); + }, 4), + n + ); + }), + (n.config = function(a) { + return n(a); + }), + (a._defined = q), + (d = function(a, b, c) { + if ("string" != typeof a) + throw new Error("See almond README: incorrect module build, no module name"); + b.splice || ((c = b), (b = [])), e(q, a) || e(r, a) || (r[a] = [a, b, c]); + }), + (d.amd = { jQuery: !0 }); + })(), + (b.requirejs = a), + (b.require = c), + (b.define = d); + } + })(), + b.define("almond", function() {}), + b.define("jquery", [], function() { + var b = a || $; + return ( + null == b && + console && + console.error && + console.error( + "Select2: An instance of jQuery or a jQuery-compatible library was not found. Make sure that you are including jQuery before Select2 on your web page." + ), + b + ); + }), + b.define("select2/utils", ["jquery"], function(a) { + function b(a) { + var b = a.prototype, + c = []; + for (var d in b) { + var e = b[d]; + "function" == typeof e && "constructor" !== d && c.push(d); + } + return c; + } + var c = {}; + (c.Extend = function(a, b) { + function c() { + this.constructor = a; + } + var d = {}.hasOwnProperty; + for (var e in b) d.call(b, e) && (a[e] = b[e]); + return ( + (c.prototype = b.prototype), (a.prototype = new c()), (a.__super__ = b.prototype), a + ); + }), + (c.Decorate = function(a, c) { + function d() { + var b = Array.prototype.unshift, + d = c.prototype.constructor.length, + e = a.prototype.constructor; + d > 0 && + (b.call(arguments, a.prototype.constructor), (e = c.prototype.constructor)), + e.apply(this, arguments); + } + function e() { + this.constructor = d; + } + var f = b(c), + g = b(a); + (c.displayName = a.displayName), (d.prototype = new e()); + for (var h = 0; h < g.length; h++) { + var i = g[h]; + d.prototype[i] = a.prototype[i]; + } + for ( + var j = function(a) { + var b = function() {}; + (a in d.prototype) && (b = d.prototype[a]); + var e = c.prototype[a]; + return function() { + var a = Array.prototype.unshift; + return a.call(arguments, b), e.apply(this, arguments); + }; + }, + k = 0; + k < f.length; + k++ + ) { + var l = f[k]; + d.prototype[l] = j(l); + } + return d; + }); + var d = function() { + this.listeners = {}; + }; + return ( + (d.prototype.on = function(a, b) { + (this.listeners = this.listeners || {}), + a in this.listeners ? this.listeners[a].push(b) : (this.listeners[a] = [b]); + }), + (d.prototype.trigger = function(a) { + var b = Array.prototype.slice, + c = b.call(arguments, 1); + (this.listeners = this.listeners || {}), + null == c && (c = []), + 0 === c.length && c.push({}), + (c[0]._type = a), + a in this.listeners && this.invoke(this.listeners[a], b.call(arguments, 1)), + "*" in this.listeners && this.invoke(this.listeners["*"], arguments); + }), + (d.prototype.invoke = function(a, b) { + for (var c = 0, d = a.length; d > c; c++) a[c].apply(this, b); + }), + (c.Observable = d), + (c.generateChars = function(a) { + for (var b = "", c = 0; a > c; c++) { + var d = Math.floor(36 * Math.random()); + b += d.toString(36); + } + return b; + }), + (c.bind = function(a, b) { + return function() { + a.apply(b, arguments); + }; + }), + (c._convertData = function(a) { + for (var b in a) { + var c = b.split("-"), + d = a; + if (1 !== c.length) { + for (var e = 0; e < c.length; e++) { + var f = c[e]; + (f = f.substring(0, 1).toLowerCase() + f.substring(1)), + f in d || (d[f] = {}), + e == c.length - 1 && (d[f] = a[b]), + (d = d[f]); + } + delete a[b]; + } + } + return a; + }), + (c.hasScroll = function(b, c) { + var d = a(c), + e = c.style.overflowX, + f = c.style.overflowY; + return e !== f || ("hidden" !== f && "visible" !== f) + ? "scroll" === e || "scroll" === f + ? !0 + : d.innerHeight() < c.scrollHeight || d.innerWidth() < c.scrollWidth + : !1; + }), + (c.escapeMarkup = function(a) { + var b = { + "\\": "\", + "&": "&", + "<": "<", + ">": ">", + '"': """, + "'": "'", + "/": "/" + }; + return "string" != typeof a + ? a + : String(a).replace(/[&<>"'\/\\]/g, function(a) { + return b[a]; + }); + }), + (c.appendMany = function(b, c) { + if ("1.7" === a.fn.jquery.substr(0, 3)) { + var d = a(); + a.map(c, function(a) { + d = d.add(a); + }), + (c = d); + } + b.append(c); + }), + c + ); + }), + b.define("select2/results", ["jquery", "./utils"], function(a, b) { + function c(a, b, d) { + (this.$element = a), + (this.data = d), + (this.options = b), + c.__super__.constructor.call(this); + } + return ( + b.Extend(c, b.Observable), + (c.prototype.render = function() { + var b = a('
            '); + return ( + this.options.get("multiple") && b.attr("aria-multiselectable", "true"), + (this.$results = b), + b + ); + }), + (c.prototype.clear = function() { + this.$results.empty(); + }), + (c.prototype.displayMessage = function(b) { + var c = this.options.get("escapeMarkup"); + this.clear(), this.hideLoading(); + var d = a( + '
          • ' + ), + e = this.options.get("translations").get(b.message); + d.append(c(e(b.args))), + (d[0].className += " select2-results__message"), + this.$results.append(d); + }), + (c.prototype.hideMessages = function() { + this.$results.find(".select2-results__message").remove(); + }), + (c.prototype.append = function(a) { + this.hideLoading(); + var b = []; + if (null == a.results || 0 === a.results.length) + return void ( + 0 === this.$results.children().length && + this.trigger("results:message", { message: "noResults" }) + ); + a.results = this.sort(a.results); + for (var c = 0; c < a.results.length; c++) { + var d = a.results[c], + e = this.option(d); + b.push(e); + } + this.$results.append(b); + }), + (c.prototype.position = function(a, b) { + var c = b.find(".select2-results"); + c.append(a); + }), + (c.prototype.sort = function(a) { + var b = this.options.get("sorter"); + return b(a); + }), + (c.prototype.highlightFirstItem = function() { + var a = this.$results.find(".select2-results__option[aria-selected]"), + b = a.filter("[aria-selected=true]"); + b.length > 0 ? b.first().trigger("mouseenter") : a.first().trigger("mouseenter"), + this.ensureHighlightVisible(); + }), + (c.prototype.setClasses = function() { + var b = this; + this.data.current(function(c) { + var d = a.map(c, function(a) { + return a.id.toString(); + }), + e = b.$results.find(".select2-results__option[aria-selected]"); + e.each(function() { + var b = a(this), + c = a.data(this, "data"), + e = "" + c.id; + (null != c.element && c.element.selected) || + (null == c.element && a.inArray(e, d) > -1) + ? b.attr("aria-selected", "true") + : b.attr("aria-selected", "false"); + }); + }); + }), + (c.prototype.showLoading = function(a) { + this.hideLoading(); + var b = this.options.get("translations").get("searching"), + c = { disabled: !0, loading: !0, text: b(a) }, + d = this.option(c); + (d.className += " loading-results"), this.$results.prepend(d); + }), + (c.prototype.hideLoading = function() { + this.$results.find(".loading-results").remove(); + }), + (c.prototype.option = function(b) { + var c = document.createElement("li"); + c.className = "select2-results__option"; + var d = { role: "treeitem", "aria-selected": "false" }; + b.disabled && (delete d["aria-selected"], (d["aria-disabled"] = "true")), + null == b.id && delete d["aria-selected"], + null != b._resultId && (c.id = b._resultId), + b.title && (c.title = b.title), + b.children && + ((d.role = "group"), (d["aria-label"] = b.text), delete d["aria-selected"]); + for (var e in d) { + var f = d[e]; + c.setAttribute(e, f); + } + if (b.children) { + var g = a(c), + h = document.createElement("strong"); + h.className = "select2-results__group"; + a(h); + this.template(b, h); + for (var i = [], j = 0; j < b.children.length; j++) { + var k = b.children[j], + l = this.option(k); + i.push(l); + } + var m = a("
              ", { + class: "select2-results__options select2-results__options--nested" + }); + m.append(i), g.append(h), g.append(m); + } else this.template(b, c); + return a.data(c, "data", b), c; + }), + (c.prototype.bind = function(b, c) { + var d = this, + e = b.id + "-results"; + this.$results.attr("id", e), + b.on("results:all", function(a) { + d.clear(), + d.append(a.data), + b.isOpen() && (d.setClasses(), d.highlightFirstItem()); + }), + b.on("results:append", function(a) { + d.append(a.data), b.isOpen() && d.setClasses(); + }), + b.on("query", function(a) { + d.hideMessages(), d.showLoading(a); + }), + b.on("select", function() { + b.isOpen() && (d.setClasses(), d.highlightFirstItem()); + }), + b.on("unselect", function() { + b.isOpen() && (d.setClasses(), d.highlightFirstItem()); + }), + b.on("open", function() { + d.$results.attr("aria-expanded", "true"), + d.$results.attr("aria-hidden", "false"), + d.setClasses(), + d.ensureHighlightVisible(); + }), + b.on("close", function() { + d.$results.attr("aria-expanded", "false"), + d.$results.attr("aria-hidden", "true"), + d.$results.removeAttr("aria-activedescendant"); + }), + b.on("results:toggle", function() { + var a = d.getHighlightedResults(); + 0 !== a.length && a.trigger("mouseup"); + }), + b.on("results:select", function() { + var a = d.getHighlightedResults(); + if (0 !== a.length) { + var b = a.data("data"); + "true" == a.attr("aria-selected") + ? d.trigger("close", {}) + : d.trigger("select", { data: b }); + } + }), + b.on("results:previous", function() { + var a = d.getHighlightedResults(), + b = d.$results.find("[aria-selected]"), + c = b.index(a); + if (0 !== c) { + var e = c - 1; + 0 === a.length && (e = 0); + var f = b.eq(e); + f.trigger("mouseenter"); + var g = d.$results.offset().top, + h = f.offset().top, + i = d.$results.scrollTop() + (h - g); + 0 === e ? d.$results.scrollTop(0) : 0 > h - g && d.$results.scrollTop(i); + } + }), + b.on("results:next", function() { + var a = d.getHighlightedResults(), + b = d.$results.find("[aria-selected]"), + c = b.index(a), + e = c + 1; + if (!(e >= b.length)) { + var f = b.eq(e); + f.trigger("mouseenter"); + var g = d.$results.offset().top + d.$results.outerHeight(!1), + h = f.offset().top + f.outerHeight(!1), + i = d.$results.scrollTop() + h - g; + 0 === e ? d.$results.scrollTop(0) : h > g && d.$results.scrollTop(i); + } + }), + b.on("results:focus", function(a) { + a.element.addClass("select2-results__option--highlighted"); + }), + b.on("results:message", function(a) { + d.displayMessage(a); + }), + a.fn.mousewheel && + this.$results.on("mousewheel", function(a) { + var b = d.$results.scrollTop(), + c = d.$results.get(0).scrollHeight - b + a.deltaY, + e = a.deltaY > 0 && b - a.deltaY <= 0, + f = a.deltaY < 0 && c <= d.$results.height(); + e + ? (d.$results.scrollTop(0), a.preventDefault(), a.stopPropagation()) + : f && + (d.$results.scrollTop(d.$results.get(0).scrollHeight - d.$results.height()), + a.preventDefault(), + a.stopPropagation()); + }), + this.$results.on("mouseup", ".select2-results__option[aria-selected]", function(b) { + var c = a(this), + e = c.data("data"); + return "true" === c.attr("aria-selected") + ? void (d.options.get("multiple") + ? d.trigger("unselect", { originalEvent: b, data: e }) + : d.trigger("close", {})) + : void d.trigger("select", { originalEvent: b, data: e }); + }), + this.$results.on("mouseenter", ".select2-results__option[aria-selected]", function( + b + ) { + var c = a(this).data("data"); + d.getHighlightedResults().removeClass("select2-results__option--highlighted"), + d.trigger("results:focus", { data: c, element: a(this) }); + }); + }), + (c.prototype.getHighlightedResults = function() { + var a = this.$results.find(".select2-results__option--highlighted"); + return a; + }), + (c.prototype.destroy = function() { + this.$results.remove(); + }), + (c.prototype.ensureHighlightVisible = function() { + var a = this.getHighlightedResults(); + if (0 !== a.length) { + var b = this.$results.find("[aria-selected]"), + c = b.index(a), + d = this.$results.offset().top, + e = a.offset().top, + f = this.$results.scrollTop() + (e - d), + g = e - d; + (f -= 2 * a.outerHeight(!1)), + 2 >= c + ? this.$results.scrollTop(0) + : (g > this.$results.outerHeight() || 0 > g) && this.$results.scrollTop(f); + } + }), + (c.prototype.template = function(b, c) { + var d = this.options.get("templateResult"), + e = this.options.get("escapeMarkup"), + f = d(b, c); + null == f + ? (c.style.display = "none") + : "string" == typeof f + ? (c.innerHTML = e(f)) + : a(c).append(f); + }), + c + ); + }), + b.define("select2/keys", [], function() { + var a = { + BACKSPACE: 8, + TAB: 9, + ENTER: 13, + SHIFT: 16, + CTRL: 17, + ALT: 18, + ESC: 27, + SPACE: 32, + PAGE_UP: 33, + PAGE_DOWN: 34, + END: 35, + HOME: 36, + LEFT: 37, + UP: 38, + RIGHT: 39, + DOWN: 40, + DELETE: 46 + }; + return a; + }), + b.define("select2/selection/base", ["jquery", "../utils", "../keys"], function(a, b, c) { + function d(a, b) { + (this.$element = a), (this.options = b), d.__super__.constructor.call(this); + } + return ( + b.Extend(d, b.Observable), + (d.prototype.render = function() { + var b = a( + '' + ); + return ( + (this._tabindex = 0), + null != this.$element.data("old-tabindex") + ? (this._tabindex = this.$element.data("old-tabindex")) + : null != this.$element.attr("tabindex") && + (this._tabindex = this.$element.attr("tabindex")), + b.attr("title", this.$element.attr("title")), + b.attr("tabindex", this._tabindex), + (this.$selection = b), + b + ); + }), + (d.prototype.bind = function(a, b) { + var d = this, + e = (a.id + "-container", a.id + "-results"); + (this.container = a), + this.$selection.on("focus", function(a) { + d.trigger("focus", a); + }), + this.$selection.on("blur", function(a) { + d._handleBlur(a); + }), + this.$selection.on("keydown", function(a) { + d.trigger("keypress", a), a.which === c.SPACE && a.preventDefault(); + }), + a.on("results:focus", function(a) { + d.$selection.attr("aria-activedescendant", a.data._resultId); + }), + a.on("selection:update", function(a) { + d.update(a.data); + }), + a.on("open", function() { + d.$selection.attr("aria-expanded", "true"), + d.$selection.attr("aria-owns", e), + d._attachCloseHandler(a); + }), + a.on("close", function() { + d.$selection.attr("aria-expanded", "false"), + d.$selection.removeAttr("aria-activedescendant"), + d.$selection.removeAttr("aria-owns"), + d.$selection.focus(), + d._detachCloseHandler(a); + }), + a.on("enable", function() { + d.$selection.attr("tabindex", d._tabindex); + }), + a.on("disable", function() { + d.$selection.attr("tabindex", "-1"); + }); + }), + (d.prototype._handleBlur = function(b) { + var c = this; + window.setTimeout(function() { + document.activeElement == c.$selection[0] || + a.contains(c.$selection[0], document.activeElement) || + c.trigger("blur", b); + }, 1); + }), + (d.prototype._attachCloseHandler = function(b) { + a(document.body).on("mousedown.select2." + b.id, function(b) { + var c = a(b.target), + d = c.closest(".select2"), + e = a(".select2.select2-container--open"); + e.each(function() { + var b = a(this); + if (this != d[0]) { + var c = b.data("element"); + c.select2("close"); + } + }); + }); + }), + (d.prototype._detachCloseHandler = function(b) { + a(document.body).off("mousedown.select2." + b.id); + }), + (d.prototype.position = function(a, b) { + var c = b.find(".selection"); + c.append(a); + }), + (d.prototype.destroy = function() { + this._detachCloseHandler(this.container); + }), + (d.prototype.update = function(a) { + throw new Error("The `update` method must be defined in child classes."); + }), + d + ); + }), + b.define("select2/selection/single", ["jquery", "./base", "../utils", "../keys"], function( + a, + b, + c, + d + ) { + function e() { + e.__super__.constructor.apply(this, arguments); + } + return ( + c.Extend(e, b), + (e.prototype.render = function() { + var a = e.__super__.render.call(this); + return ( + a.addClass("select2-selection--single"), + a.html( + '' + ), + a + ); + }), + (e.prototype.bind = function(a, b) { + var c = this; + e.__super__.bind.apply(this, arguments); + var d = a.id + "-container"; + this.$selection.find(".select2-selection__rendered").attr("id", d), + this.$selection.attr("aria-labelledby", d), + this.$selection.on("mousedown", function(a) { + 1 === a.which && c.trigger("toggle", { originalEvent: a }); + }), + this.$selection.on("focus", function(a) {}), + this.$selection.on("blur", function(a) {}), + a.on("focus", function(b) { + a.isOpen() || c.$selection.focus(); + }), + a.on("selection:update", function(a) { + c.update(a.data); + }); + }), + (e.prototype.clear = function() { + this.$selection.find(".select2-selection__rendered").empty(); + }), + (e.prototype.display = function(a, b) { + var c = this.options.get("templateSelection"), + d = this.options.get("escapeMarkup"); + return d(c(a, b)); + }), + (e.prototype.selectionContainer = function() { + return a(""); + }), + (e.prototype.update = function(a) { + if (0 === a.length) return void this.clear(); + var b = a[0], + c = this.$selection.find(".select2-selection__rendered"), + d = this.display(b, c); + c.empty().append(d), c.prop("title", b.title || b.text); + }), + e + ); + }), + b.define("select2/selection/multiple", ["jquery", "./base", "../utils"], function(a, b, c) { + function d(a, b) { + d.__super__.constructor.apply(this, arguments); + } + return ( + c.Extend(d, b), + (d.prototype.render = function() { + var a = d.__super__.render.call(this); + return ( + a.addClass("select2-selection--multiple"), + a.html('
                '), + a + ); + }), + (d.prototype.bind = function(b, c) { + var e = this; + d.__super__.bind.apply(this, arguments), + this.$selection.on("click", function(a) { + e.trigger("toggle", { originalEvent: a }); + }), + this.$selection.on("click", ".select2-selection__choice__remove", function(b) { + if (!e.options.get("disabled")) { + var c = a(this), + d = c.parent(), + f = d.data("data"); + e.trigger("unselect", { originalEvent: b, data: f }); + } + }); + }), + (d.prototype.clear = function() { + this.$selection.find(".select2-selection__rendered").empty(); + }), + (d.prototype.display = function(a, b) { + var c = this.options.get("templateSelection"), + d = this.options.get("escapeMarkup"); + return d(c(a, b)); + }), + (d.prototype.selectionContainer = function() { + var b = a( + '
              • ×
              • ' + ); + return b; + }), + (d.prototype.update = function(a) { + if ((this.clear(), 0 !== a.length)) { + for (var b = [], d = 0; d < a.length; d++) { + var e = a[d], + f = this.selectionContainer(), + g = this.display(e, f); + f.append(g), f.prop("title", e.title || e.text), f.data("data", e), b.push(f); + } + var h = this.$selection.find(".select2-selection__rendered"); + c.appendMany(h, b); + } + }), + d + ); + }), + b.define("select2/selection/placeholder", ["../utils"], function(a) { + function b(a, b, c) { + (this.placeholder = this.normalizePlaceholder(c.get("placeholder"))), + a.call(this, b, c); + } + return ( + (b.prototype.normalizePlaceholder = function(a, b) { + return "string" == typeof b && (b = { id: "", text: b }), b; + }), + (b.prototype.createPlaceholder = function(a, b) { + var c = this.selectionContainer(); + return ( + c.html(this.display(b)), + c + .addClass("select2-selection__placeholder") + .removeClass("select2-selection__choice"), + c + ); + }), + (b.prototype.update = function(a, b) { + var c = 1 == b.length && b[0].id != this.placeholder.id, + d = b.length > 1; + if (d || c) return a.call(this, b); + this.clear(); + var e = this.createPlaceholder(this.placeholder); + this.$selection.find(".select2-selection__rendered").append(e); + }), + b + ); + }), + b.define("select2/selection/allowClear", ["jquery", "../keys"], function(a, b) { + function c() {} + return ( + (c.prototype.bind = function(a, b, c) { + var d = this; + a.call(this, b, c), + null == this.placeholder && + this.options.get("debug") && + window.console && + console.error && + console.error( + "Select2: The `allowClear` option should be used in combination with the `placeholder` option." + ), + this.$selection.on("mousedown", ".select2-selection__clear", function(a) { + d._handleClear(a); + }), + b.on("keypress", function(a) { + d._handleKeyboardClear(a, b); + }); + }), + (c.prototype._handleClear = function(a, b) { + if (!this.options.get("disabled")) { + var c = this.$selection.find(".select2-selection__clear"); + if (0 !== c.length) { + b.stopPropagation(); + for (var d = c.data("data"), e = 0; e < d.length; e++) { + var f = { data: d[e] }; + if ((this.trigger("unselect", f), f.prevented)) return; + } + this.$element.val(this.placeholder.id).trigger("change"), + this.trigger("toggle", {}); + } + } + }), + (c.prototype._handleKeyboardClear = function(a, c, d) { + d.isOpen() || + ((c.which == b.DELETE || c.which == b.BACKSPACE) && this._handleClear(c)); + }), + (c.prototype.update = function(b, c) { + if ( + (b.call(this, c), + !( + this.$selection.find(".select2-selection__placeholder").length > 0 || + 0 === c.length + )) + ) { + var d = a('×'); + d.data("data", c), this.$selection.find(".select2-selection__rendered").prepend(d); + } + }), + c + ); + }), + b.define("select2/selection/search", ["jquery", "../utils", "../keys"], function(a, b, c) { + function d(a, b, c) { + a.call(this, b, c); + } + return ( + (d.prototype.render = function(b) { + var c = a( + '' + ); + (this.$searchContainer = c), (this.$search = c.find("input")); + var d = b.call(this); + return this._transferTabIndex(), d; + }), + (d.prototype.bind = function(a, b, d) { + var e = this; + a.call(this, b, d), + b.on("open", function() { + e.$search.trigger("focus"); + }), + b.on("close", function() { + e.$search.val(""), + e.$search.removeAttr("aria-activedescendant"), + e.$search.trigger("focus"); + }), + b.on("enable", function() { + e.$search.prop("disabled", !1), e._transferTabIndex(); + }), + b.on("disable", function() { + e.$search.prop("disabled", !0); + }), + b.on("focus", function(a) { + e.$search.trigger("focus"); + }), + b.on("results:focus", function(a) { + e.$search.attr("aria-activedescendant", a.id); + }), + this.$selection.on("focusin", ".select2-search--inline", function(a) { + e.trigger("focus", a); + }), + this.$selection.on("focusout", ".select2-search--inline", function(a) { + e._handleBlur(a); + }), + this.$selection.on("keydown", ".select2-search--inline", function(a) { + a.stopPropagation(), + e.trigger("keypress", a), + (e._keyUpPrevented = a.isDefaultPrevented()); + var b = a.which; + if (b === c.BACKSPACE && "" === e.$search.val()) { + var d = e.$searchContainer.prev(".select2-selection__choice"); + if (d.length > 0) { + var f = d.data("data"); + e.searchRemoveChoice(f), a.preventDefault(); + } + } + }); + var f = document.documentMode, + g = f && 11 >= f; + this.$selection.on("input.searchcheck", ".select2-search--inline", function(a) { + return g + ? void e.$selection.off("input.search input.searchcheck") + : void e.$selection.off("keyup.search"); + }), + this.$selection.on("keyup.search input.search", ".select2-search--inline", function( + a + ) { + if (g && "input" === a.type) + return void e.$selection.off("input.search input.searchcheck"); + var b = a.which; + b != c.SHIFT && b != c.CTRL && b != c.ALT && b != c.TAB && e.handleSearch(a); + }); + }), + (d.prototype._transferTabIndex = function(a) { + this.$search.attr("tabindex", this.$selection.attr("tabindex")), + this.$selection.attr("tabindex", "-1"); + }), + (d.prototype.createPlaceholder = function(a, b) { + this.$search.attr("placeholder", b.text); + }), + (d.prototype.update = function(a, b) { + var c = this.$search[0] == document.activeElement; + this.$search.attr("placeholder", ""), + a.call(this, b), + this.$selection.find(".select2-selection__rendered").append(this.$searchContainer), + this.resizeSearch(), + c && this.$search.focus(); + }), + (d.prototype.handleSearch = function() { + if ((this.resizeSearch(), !this._keyUpPrevented)) { + var a = this.$search.val(); + this.trigger("query", { term: a }); + } + this._keyUpPrevented = !1; + }), + (d.prototype.searchRemoveChoice = function(a, b) { + this.trigger("unselect", { data: b }), this.$search.val(b.text), this.handleSearch(); + }), + (d.prototype.resizeSearch = function() { + this.$search.css("width", "25px"); + var a = ""; + if ("" !== this.$search.attr("placeholder")) + a = this.$selection.find(".select2-selection__rendered").innerWidth(); + else { + var b = this.$search.val().length + 1; + a = 0.75 * b + "em"; + } + this.$search.css("width", a); + }), + d + ); + }), + b.define("select2/selection/eventRelay", ["jquery"], function(a) { + function b() {} + return ( + (b.prototype.bind = function(b, c, d) { + var e = this, + f = [ + "open", + "opening", + "close", + "closing", + "select", + "selecting", + "unselect", + "unselecting" + ], + g = ["opening", "closing", "selecting", "unselecting"]; + b.call(this, c, d), + c.on("*", function(b, c) { + if (-1 !== a.inArray(b, f)) { + c = c || {}; + var d = a.Event("select2:" + b, { params: c }); + e.$element.trigger(d), + -1 !== a.inArray(b, g) && (c.prevented = d.isDefaultPrevented()); + } + }); + }), + b + ); + }), + b.define("select2/translation", ["jquery", "require"], function(a, b) { + function c(a) { + this.dict = a || {}; + } + return ( + (c.prototype.all = function() { + return this.dict; + }), + (c.prototype.get = function(a) { + return this.dict[a]; + }), + (c.prototype.extend = function(b) { + this.dict = a.extend({}, b.all(), this.dict); + }), + (c._cache = {}), + (c.loadPath = function(a) { + if (!(a in c._cache)) { + var d = b(a); + c._cache[a] = d; + } + return new c(c._cache[a]); + }), + c + ); + }), + b.define("select2/diacritics", [], function() { + var a = { + "Ⓐ": "A", + A: "A", + À: "A", + Á: "A", + Â: "A", + Ầ: "A", + Ấ: "A", + Ẫ: "A", + Ẩ: "A", + Ã: "A", + Ā: "A", + Ă: "A", + Ằ: "A", + Ắ: "A", + Ẵ: "A", + Ẳ: "A", + Ȧ: "A", + Ǡ: "A", + Ä: "A", + Ǟ: "A", + Ả: "A", + Å: "A", + Ǻ: "A", + Ǎ: "A", + Ȁ: "A", + Ȃ: "A", + Ạ: "A", + Ậ: "A", + Ặ: "A", + Ḁ: "A", + Ą: "A", + Ⱥ: "A", + Ɐ: "A", + Ꜳ: "AA", + Æ: "AE", + Ǽ: "AE", + Ǣ: "AE", + Ꜵ: "AO", + Ꜷ: "AU", + Ꜹ: "AV", + Ꜻ: "AV", + Ꜽ: "AY", + "Ⓑ": "B", + B: "B", + Ḃ: "B", + Ḅ: "B", + Ḇ: "B", + Ƀ: "B", + Ƃ: "B", + Ɓ: "B", + "Ⓒ": "C", + C: "C", + Ć: "C", + Ĉ: "C", + Ċ: "C", + Č: "C", + Ç: "C", + Ḉ: "C", + Ƈ: "C", + Ȼ: "C", + Ꜿ: "C", + "Ⓓ": "D", + D: "D", + Ḋ: "D", + Ď: "D", + Ḍ: "D", + Ḑ: "D", + Ḓ: "D", + Ḏ: "D", + Đ: "D", + Ƌ: "D", + Ɗ: "D", + Ɖ: "D", + Ꝺ: "D", + DZ: "DZ", + DŽ: "DZ", + Dz: "Dz", + Dž: "Dz", + "Ⓔ": "E", + E: "E", + È: "E", + É: "E", + Ê: "E", + Ề: "E", + Ế: "E", + Ễ: "E", + Ể: "E", + Ẽ: "E", + Ē: "E", + Ḕ: "E", + Ḗ: "E", + Ĕ: "E", + Ė: "E", + Ë: "E", + Ẻ: "E", + Ě: "E", + Ȅ: "E", + Ȇ: "E", + Ẹ: "E", + Ệ: "E", + Ȩ: "E", + Ḝ: "E", + Ę: "E", + Ḙ: "E", + Ḛ: "E", + Ɛ: "E", + Ǝ: "E", + "Ⓕ": "F", + F: "F", + Ḟ: "F", + Ƒ: "F", + Ꝼ: "F", + "Ⓖ": "G", + G: "G", + Ǵ: "G", + Ĝ: "G", + Ḡ: "G", + Ğ: "G", + Ġ: "G", + Ǧ: "G", + Ģ: "G", + Ǥ: "G", + Ɠ: "G", + Ꞡ: "G", + Ᵹ: "G", + Ꝿ: "G", + "Ⓗ": "H", + H: "H", + Ĥ: "H", + Ḣ: "H", + Ḧ: "H", + Ȟ: "H", + Ḥ: "H", + Ḩ: "H", + Ḫ: "H", + Ħ: "H", + Ⱨ: "H", + Ⱶ: "H", + Ɥ: "H", + "Ⓘ": "I", + I: "I", + Ì: "I", + Í: "I", + Î: "I", + Ĩ: "I", + Ī: "I", + Ĭ: "I", + İ: "I", + Ï: "I", + Ḯ: "I", + Ỉ: "I", + Ǐ: "I", + Ȉ: "I", + Ȋ: "I", + Ị: "I", + Į: "I", + Ḭ: "I", + Ɨ: "I", + "Ⓙ": "J", + J: "J", + Ĵ: "J", + Ɉ: "J", + "Ⓚ": "K", + K: "K", + Ḱ: "K", + Ǩ: "K", + Ḳ: "K", + Ķ: "K", + Ḵ: "K", + Ƙ: "K", + Ⱪ: "K", + Ꝁ: "K", + Ꝃ: "K", + Ꝅ: "K", + Ꞣ: "K", + "Ⓛ": "L", + L: "L", + Ŀ: "L", + Ĺ: "L", + Ľ: "L", + Ḷ: "L", + Ḹ: "L", + Ļ: "L", + Ḽ: "L", + Ḻ: "L", + Ł: "L", + Ƚ: "L", + Ɫ: "L", + Ⱡ: "L", + Ꝉ: "L", + Ꝇ: "L", + Ꞁ: "L", + LJ: "LJ", + Lj: "Lj", + "Ⓜ": "M", + M: "M", + Ḿ: "M", + Ṁ: "M", + Ṃ: "M", + Ɱ: "M", + Ɯ: "M", + "Ⓝ": "N", + N: "N", + Ǹ: "N", + Ń: "N", + Ñ: "N", + Ṅ: "N", + Ň: "N", + Ṇ: "N", + Ņ: "N", + Ṋ: "N", + Ṉ: "N", + Ƞ: "N", + Ɲ: "N", + Ꞑ: "N", + Ꞥ: "N", + NJ: "NJ", + Nj: "Nj", + "Ⓞ": "O", + O: "O", + Ò: "O", + Ó: "O", + Ô: "O", + Ồ: "O", + Ố: "O", + Ỗ: "O", + Ổ: "O", + Õ: "O", + Ṍ: "O", + Ȭ: "O", + Ṏ: "O", + Ō: "O", + Ṑ: "O", + Ṓ: "O", + Ŏ: "O", + Ȯ: "O", + Ȱ: "O", + Ö: "O", + Ȫ: "O", + Ỏ: "O", + Ő: "O", + Ǒ: "O", + Ȍ: "O", + Ȏ: "O", + Ơ: "O", + Ờ: "O", + Ớ: "O", + Ỡ: "O", + Ở: "O", + Ợ: "O", + Ọ: "O", + Ộ: "O", + Ǫ: "O", + Ǭ: "O", + Ø: "O", + Ǿ: "O", + Ɔ: "O", + Ɵ: "O", + Ꝋ: "O", + Ꝍ: "O", + Ƣ: "OI", + Ꝏ: "OO", + Ȣ: "OU", + "Ⓟ": "P", + P: "P", + Ṕ: "P", + Ṗ: "P", + Ƥ: "P", + Ᵽ: "P", + Ꝑ: "P", + Ꝓ: "P", + Ꝕ: "P", + "Ⓠ": "Q", + Q: "Q", + Ꝗ: "Q", + Ꝙ: "Q", + Ɋ: "Q", + "Ⓡ": "R", + R: "R", + Ŕ: "R", + Ṙ: "R", + Ř: "R", + Ȑ: "R", + Ȓ: "R", + Ṛ: "R", + Ṝ: "R", + Ŗ: "R", + Ṟ: "R", + Ɍ: "R", + Ɽ: "R", + Ꝛ: "R", + Ꞧ: "R", + Ꞃ: "R", + "Ⓢ": "S", + S: "S", + ẞ: "S", + Ś: "S", + Ṥ: "S", + Ŝ: "S", + Ṡ: "S", + Š: "S", + Ṧ: "S", + Ṣ: "S", + Ṩ: "S", + Ș: "S", + Ş: "S", + Ȿ: "S", + Ꞩ: "S", + Ꞅ: "S", + "Ⓣ": "T", + T: "T", + Ṫ: "T", + Ť: "T", + Ṭ: "T", + Ț: "T", + Ţ: "T", + Ṱ: "T", + Ṯ: "T", + Ŧ: "T", + Ƭ: "T", + Ʈ: "T", + Ⱦ: "T", + Ꞇ: "T", + Ꜩ: "TZ", + "Ⓤ": "U", + U: "U", + Ù: "U", + Ú: "U", + Û: "U", + Ũ: "U", + Ṹ: "U", + Ū: "U", + Ṻ: "U", + Ŭ: "U", + Ü: "U", + Ǜ: "U", + Ǘ: "U", + Ǖ: "U", + Ǚ: "U", + Ủ: "U", + Ů: "U", + Ű: "U", + Ǔ: "U", + Ȕ: "U", + Ȗ: "U", + Ư: "U", + Ừ: "U", + Ứ: "U", + Ữ: "U", + Ử: "U", + Ự: "U", + Ụ: "U", + Ṳ: "U", + Ų: "U", + Ṷ: "U", + Ṵ: "U", + Ʉ: "U", + "Ⓥ": "V", + V: "V", + Ṽ: "V", + Ṿ: "V", + Ʋ: "V", + Ꝟ: "V", + Ʌ: "V", + Ꝡ: "VY", + "Ⓦ": "W", + W: "W", + Ẁ: "W", + Ẃ: "W", + Ŵ: "W", + Ẇ: "W", + Ẅ: "W", + Ẉ: "W", + Ⱳ: "W", + "Ⓧ": "X", + X: "X", + Ẋ: "X", + Ẍ: "X", + "Ⓨ": "Y", + Y: "Y", + Ỳ: "Y", + Ý: "Y", + Ŷ: "Y", + Ỹ: "Y", + Ȳ: "Y", + Ẏ: "Y", + Ÿ: "Y", + Ỷ: "Y", + Ỵ: "Y", + Ƴ: "Y", + Ɏ: "Y", + Ỿ: "Y", + "Ⓩ": "Z", + Z: "Z", + Ź: "Z", + Ẑ: "Z", + Ż: "Z", + Ž: "Z", + Ẓ: "Z", + Ẕ: "Z", + Ƶ: "Z", + Ȥ: "Z", + Ɀ: "Z", + Ⱬ: "Z", + Ꝣ: "Z", + "ⓐ": "a", + a: "a", + ẚ: "a", + à: "a", + á: "a", + â: "a", + ầ: "a", + ấ: "a", + ẫ: "a", + ẩ: "a", + ã: "a", + ā: "a", + ă: "a", + ằ: "a", + ắ: "a", + ẵ: "a", + ẳ: "a", + ȧ: "a", + ǡ: "a", + ä: "a", + ǟ: "a", + ả: "a", + å: "a", + ǻ: "a", + ǎ: "a", + ȁ: "a", + ȃ: "a", + ạ: "a", + ậ: "a", + ặ: "a", + ḁ: "a", + ą: "a", + ⱥ: "a", + ɐ: "a", + ꜳ: "aa", + æ: "ae", + ǽ: "ae", + ǣ: "ae", + ꜵ: "ao", + ꜷ: "au", + ꜹ: "av", + ꜻ: "av", + ꜽ: "ay", + "ⓑ": "b", + b: "b", + ḃ: "b", + ḅ: "b", + ḇ: "b", + ƀ: "b", + ƃ: "b", + ɓ: "b", + "ⓒ": "c", + c: "c", + ć: "c", + ĉ: "c", + ċ: "c", + č: "c", + ç: "c", + ḉ: "c", + ƈ: "c", + ȼ: "c", + ꜿ: "c", + ↄ: "c", + "ⓓ": "d", + d: "d", + ḋ: "d", + ď: "d", + ḍ: "d", + ḑ: "d", + ḓ: "d", + ḏ: "d", + đ: "d", + ƌ: "d", + ɖ: "d", + ɗ: "d", + ꝺ: "d", + dz: "dz", + dž: "dz", + "ⓔ": "e", + e: "e", + è: "e", + é: "e", + ê: "e", + ề: "e", + ế: "e", + ễ: "e", + ể: "e", + ẽ: "e", + ē: "e", + ḕ: "e", + ḗ: "e", + ĕ: "e", + ė: "e", + ë: "e", + ẻ: "e", + ě: "e", + ȅ: "e", + ȇ: "e", + ẹ: "e", + ệ: "e", + ȩ: "e", + ḝ: "e", + ę: "e", + ḙ: "e", + ḛ: "e", + ɇ: "e", + ɛ: "e", + ǝ: "e", + "ⓕ": "f", + f: "f", + ḟ: "f", + ƒ: "f", + ꝼ: "f", + "ⓖ": "g", + g: "g", + ǵ: "g", + ĝ: "g", + ḡ: "g", + ğ: "g", + ġ: "g", + ǧ: "g", + ģ: "g", + ǥ: "g", + ɠ: "g", + ꞡ: "g", + ᵹ: "g", + ꝿ: "g", + "ⓗ": "h", + h: "h", + ĥ: "h", + ḣ: "h", + ḧ: "h", + ȟ: "h", + ḥ: "h", + ḩ: "h", + ḫ: "h", + ẖ: "h", + ħ: "h", + ⱨ: "h", + ⱶ: "h", + ɥ: "h", + ƕ: "hv", + "ⓘ": "i", + i: "i", + ì: "i", + í: "i", + î: "i", + ĩ: "i", + ī: "i", + ĭ: "i", + ï: "i", + ḯ: "i", + ỉ: "i", + ǐ: "i", + ȉ: "i", + ȋ: "i", + ị: "i", + į: "i", + ḭ: "i", + ɨ: "i", + ı: "i", + "ⓙ": "j", + j: "j", + ĵ: "j", + ǰ: "j", + ɉ: "j", + "ⓚ": "k", + k: "k", + ḱ: "k", + ǩ: "k", + ḳ: "k", + ķ: "k", + ḵ: "k", + ƙ: "k", + ⱪ: "k", + ꝁ: "k", + ꝃ: "k", + ꝅ: "k", + ꞣ: "k", + "ⓛ": "l", + l: "l", + ŀ: "l", + ĺ: "l", + ľ: "l", + ḷ: "l", + ḹ: "l", + ļ: "l", + ḽ: "l", + ḻ: "l", + ſ: "l", + ł: "l", + ƚ: "l", + ɫ: "l", + ⱡ: "l", + ꝉ: "l", + ꞁ: "l", + ꝇ: "l", + lj: "lj", + "ⓜ": "m", + m: "m", + ḿ: "m", + ṁ: "m", + ṃ: "m", + ɱ: "m", + ɯ: "m", + "ⓝ": "n", + n: "n", + ǹ: "n", + ń: "n", + ñ: "n", + ṅ: "n", + ň: "n", + ṇ: "n", + ņ: "n", + ṋ: "n", + ṉ: "n", + ƞ: "n", + ɲ: "n", + ʼn: "n", + ꞑ: "n", + ꞥ: "n", + nj: "nj", + "ⓞ": "o", + o: "o", + ò: "o", + ó: "o", + ô: "o", + ồ: "o", + ố: "o", + ỗ: "o", + ổ: "o", + õ: "o", + ṍ: "o", + ȭ: "o", + ṏ: "o", + ō: "o", + ṑ: "o", + ṓ: "o", + ŏ: "o", + ȯ: "o", + ȱ: "o", + ö: "o", + ȫ: "o", + ỏ: "o", + ő: "o", + ǒ: "o", + ȍ: "o", + ȏ: "o", + ơ: "o", + ờ: "o", + ớ: "o", + ỡ: "o", + ở: "o", + ợ: "o", + ọ: "o", + ộ: "o", + ǫ: "o", + ǭ: "o", + ø: "o", + ǿ: "o", + ɔ: "o", + ꝋ: "o", + ꝍ: "o", + ɵ: "o", + ƣ: "oi", + ȣ: "ou", + ꝏ: "oo", + "ⓟ": "p", + p: "p", + ṕ: "p", + ṗ: "p", + ƥ: "p", + ᵽ: "p", + ꝑ: "p", + ꝓ: "p", + ꝕ: "p", + "ⓠ": "q", + q: "q", + ɋ: "q", + ꝗ: "q", + ꝙ: "q", + "ⓡ": "r", + r: "r", + ŕ: "r", + ṙ: "r", + ř: "r", + ȑ: "r", + ȓ: "r", + ṛ: "r", + ṝ: "r", + ŗ: "r", + ṟ: "r", + ɍ: "r", + ɽ: "r", + ꝛ: "r", + ꞧ: "r", + ꞃ: "r", + "ⓢ": "s", + s: "s", + ß: "s", + ś: "s", + ṥ: "s", + ŝ: "s", + ṡ: "s", + š: "s", + ṧ: "s", + ṣ: "s", + ṩ: "s", + ș: "s", + ş: "s", + ȿ: "s", + ꞩ: "s", + ꞅ: "s", + ẛ: "s", + "ⓣ": "t", + t: "t", + ṫ: "t", + ẗ: "t", + ť: "t", + ṭ: "t", + ț: "t", + ţ: "t", + ṱ: "t", + ṯ: "t", + ŧ: "t", + ƭ: "t", + ʈ: "t", + ⱦ: "t", + ꞇ: "t", + ꜩ: "tz", + "ⓤ": "u", + u: "u", + ù: "u", + ú: "u", + û: "u", + ũ: "u", + ṹ: "u", + ū: "u", + ṻ: "u", + ŭ: "u", + ü: "u", + ǜ: "u", + ǘ: "u", + ǖ: "u", + ǚ: "u", + ủ: "u", + ů: "u", + ű: "u", + ǔ: "u", + ȕ: "u", + ȗ: "u", + ư: "u", + ừ: "u", + ứ: "u", + ữ: "u", + ử: "u", + ự: "u", + ụ: "u", + ṳ: "u", + ų: "u", + ṷ: "u", + ṵ: "u", + ʉ: "u", + "ⓥ": "v", + v: "v", + ṽ: "v", + ṿ: "v", + ʋ: "v", + ꝟ: "v", + ʌ: "v", + ꝡ: "vy", + "ⓦ": "w", + w: "w", + ẁ: "w", + ẃ: "w", + ŵ: "w", + ẇ: "w", + ẅ: "w", + ẘ: "w", + ẉ: "w", + ⱳ: "w", + "ⓧ": "x", + x: "x", + ẋ: "x", + ẍ: "x", + "ⓨ": "y", + y: "y", + ỳ: "y", + ý: "y", + ŷ: "y", + ỹ: "y", + ȳ: "y", + ẏ: "y", + ÿ: "y", + ỷ: "y", + ẙ: "y", + ỵ: "y", + ƴ: "y", + ɏ: "y", + ỿ: "y", + "ⓩ": "z", + z: "z", + ź: "z", + ẑ: "z", + ż: "z", + ž: "z", + ẓ: "z", + ẕ: "z", + ƶ: "z", + ȥ: "z", + ɀ: "z", + ⱬ: "z", + ꝣ: "z", + Ά: "Α", + Έ: "Ε", + Ή: "Η", + Ί: "Ι", + Ϊ: "Ι", + Ό: "Ο", + Ύ: "Υ", + Ϋ: "Υ", + Ώ: "Ω", + ά: "α", + έ: "ε", + ή: "η", + ί: "ι", + ϊ: "ι", + ΐ: "ι", + ό: "ο", + ύ: "υ", + ϋ: "υ", + ΰ: "υ", + ω: "ω", + ς: "σ" + }; + return a; + }), + b.define("select2/data/base", ["../utils"], function(a) { + function b(a, c) { + b.__super__.constructor.call(this); + } + return ( + a.Extend(b, a.Observable), + (b.prototype.current = function(a) { + throw new Error("The `current` method must be defined in child classes."); + }), + (b.prototype.query = function(a, b) { + throw new Error("The `query` method must be defined in child classes."); + }), + (b.prototype.bind = function(a, b) {}), + (b.prototype.destroy = function() {}), + (b.prototype.generateResultId = function(b, c) { + var d = b.id + "-result-"; + return ( + (d += a.generateChars(4)), + (d += null != c.id ? "-" + c.id.toString() : "-" + a.generateChars(4)) + ); + }), + b + ); + }), + b.define("select2/data/select", ["./base", "../utils", "jquery"], function(a, b, c) { + function d(a, b) { + (this.$element = a), (this.options = b), d.__super__.constructor.call(this); + } + return ( + b.Extend(d, a), + (d.prototype.current = function(a) { + var b = [], + d = this; + this.$element.find(":selected").each(function() { + var a = c(this), + e = d.item(a); + b.push(e); + }), + a(b); + }), + (d.prototype.select = function(a) { + var b = this; + if (((a.selected = !0), c(a.element).is("option"))) + return (a.element.selected = !0), void this.$element.trigger("change"); + if (this.$element.prop("multiple")) + this.current(function(d) { + var e = []; + (a = [a]), a.push.apply(a, d); + for (var f = 0; f < a.length; f++) { + var g = a[f].id; + -1 === c.inArray(g, e) && e.push(g); + } + b.$element.val(e), b.$element.trigger("change"); + }); + else { + var d = a.id; + this.$element.val(d), this.$element.trigger("change"); + } + }), + (d.prototype.unselect = function(a) { + var b = this; + if (this.$element.prop("multiple")) + return ( + (a.selected = !1), + c(a.element).is("option") + ? ((a.element.selected = !1), void this.$element.trigger("change")) + : void this.current(function(d) { + for (var e = [], f = 0; f < d.length; f++) { + var g = d[f].id; + g !== a.id && -1 === c.inArray(g, e) && e.push(g); + } + b.$element.val(e), b.$element.trigger("change"); + }) + ); + }), + (d.prototype.bind = function(a, b) { + var c = this; + (this.container = a), + a.on("select", function(a) { + c.select(a.data); + }), + a.on("unselect", function(a) { + c.unselect(a.data); + }); + }), + (d.prototype.destroy = function() { + this.$element.find("*").each(function() { + c.removeData(this, "data"); + }); + }), + (d.prototype.query = function(a, b) { + var d = [], + e = this, + f = this.$element.children(); + f.each(function() { + var b = c(this); + if (b.is("option") || b.is("optgroup")) { + var f = e.item(b), + g = e.matches(a, f); + null !== g && d.push(g); + } + }), + b({ results: d }); + }), + (d.prototype.addOptions = function(a) { + b.appendMany(this.$element, a); + }), + (d.prototype.option = function(a) { + var b; + a.children + ? ((b = document.createElement("optgroup")), (b.label = a.text)) + : ((b = document.createElement("option")), + void 0 !== b.textContent ? (b.textContent = a.text) : (b.innerText = a.text)), + a.id && (b.value = a.id), + a.disabled && (b.disabled = !0), + a.selected && (b.selected = !0), + a.title && (b.title = a.title); + var d = c(b), + e = this._normalizeItem(a); + return (e.element = b), c.data(b, "data", e), d; + }), + (d.prototype.item = function(a) { + var b = {}; + if (((b = c.data(a[0], "data")), null != b)) return b; + if (a.is("option")) + b = { + id: a.val(), + text: a.text(), + disabled: a.prop("disabled"), + selected: a.prop("selected"), + title: a.prop("title") + }; + else if (a.is("optgroup")) { + b = { text: a.prop("label"), children: [], title: a.prop("title") }; + for (var d = a.children("option"), e = [], f = 0; f < d.length; f++) { + var g = c(d[f]), + h = this.item(g); + e.push(h); + } + b.children = e; + } + return (b = this._normalizeItem(b)), (b.element = a[0]), c.data(a[0], "data", b), b; + }), + (d.prototype._normalizeItem = function(a) { + c.isPlainObject(a) || (a = { id: a, text: a }), (a = c.extend({}, { text: "" }, a)); + var b = { selected: !1, disabled: !1 }; + return ( + null != a.id && (a.id = a.id.toString()), + null != a.text && (a.text = a.text.toString()), + null == a._resultId && + a.id && + null != this.container && + (a._resultId = this.generateResultId(this.container, a)), + c.extend({}, b, a) + ); + }), + (d.prototype.matches = function(a, b) { + var c = this.options.get("matcher"); + return c(a, b); + }), + d + ); + }), + b.define("select2/data/array", ["./select", "../utils", "jquery"], function(a, b, c) { + function d(a, b) { + var c = b.get("data") || []; + d.__super__.constructor.call(this, a, b), this.addOptions(this.convertToOptions(c)); + } + return ( + b.Extend(d, a), + (d.prototype.select = function(a) { + var b = this.$element.find("option").filter(function(b, c) { + return c.value == a.id.toString(); + }); + 0 === b.length && ((b = this.option(a)), this.addOptions(b)), + d.__super__.select.call(this, a); + }), + (d.prototype.convertToOptions = function(a) { + function d(a) { + return function() { + return c(this).val() == a.id; + }; + } + for ( + var e = this, + f = this.$element.find("option"), + g = f + .map(function() { + return e.item(c(this)).id; + }) + .get(), + h = [], + i = 0; + i < a.length; + i++ + ) { + var j = this._normalizeItem(a[i]); + if (c.inArray(j.id, g) >= 0) { + var k = f.filter(d(j)), + l = this.item(k), + m = c.extend(!0, {}, j, l), + n = this.option(m); + k.replaceWith(n); + } else { + var o = this.option(j); + if (j.children) { + var p = this.convertToOptions(j.children); + b.appendMany(o, p); + } + h.push(o); + } + } + return h; + }), + d + ); + }), + b.define("select2/data/ajax", ["./array", "../utils", "jquery"], function(a, b, c) { + function d(a, b) { + (this.ajaxOptions = this._applyDefaults(b.get("ajax"))), + null != this.ajaxOptions.processResults && + (this.processResults = this.ajaxOptions.processResults), + d.__super__.constructor.call(this, a, b); + } + return ( + b.Extend(d, a), + (d.prototype._applyDefaults = function(a) { + var b = { + data: function(a) { + return c.extend({}, a, { q: a.term }); + }, + transport: function(a, b, d) { + var e = c.ajax(a); + return e.then(b), e.fail(d), e; + } + }; + return c.extend({}, b, a, !0); + }), + (d.prototype.processResults = function(a) { + return a; + }), + (d.prototype.query = function(a, b) { + function d() { + var d = f.transport( + f, + function(d) { + var f = e.processResults(d, a); + e.options.get("debug") && + window.console && + console.error && + ((f && f.results && c.isArray(f.results)) || + console.error( + "Select2: The AJAX results did not return an array in the `results` key of the response." + )), + b(f); + }, + function() { + (d.status && "0" === d.status) || + e.trigger("results:message", { message: "errorLoading" }); + } + ); + e._request = d; + } + var e = this; + null != this._request && + (c.isFunction(this._request.abort) && this._request.abort(), + (this._request = null)); + var f = c.extend({ type: "GET" }, this.ajaxOptions); + "function" == typeof f.url && (f.url = f.url.call(this.$element, a)), + "function" == typeof f.data && (f.data = f.data.call(this.$element, a)), + this.ajaxOptions.delay && null != a.term + ? (this._queryTimeout && window.clearTimeout(this._queryTimeout), + (this._queryTimeout = window.setTimeout(d, this.ajaxOptions.delay))) + : d(); + }), + d + ); + }), + b.define("select2/data/tags", ["jquery"], function(a) { + function b(b, c, d) { + var e = d.get("tags"), + f = d.get("createTag"); + void 0 !== f && (this.createTag = f); + var g = d.get("insertTag"); + if ((void 0 !== g && (this.insertTag = g), b.call(this, c, d), a.isArray(e))) + for (var h = 0; h < e.length; h++) { + var i = e[h], + j = this._normalizeItem(i), + k = this.option(j); + this.$element.append(k); + } + } + return ( + (b.prototype.query = function(a, b, c) { + function d(a, f) { + for (var g = a.results, h = 0; h < g.length; h++) { + var i = g[h], + j = null != i.children && !d({ results: i.children }, !0), + k = i.text === b.term; + if (k || j) return f ? !1 : ((a.data = g), void c(a)); + } + if (f) return !0; + var l = e.createTag(b); + if (null != l) { + var m = e.option(l); + m.attr("data-select2-tag", !0), e.addOptions([m]), e.insertTag(g, l); + } + (a.results = g), c(a); + } + var e = this; + return ( + this._removeOldTags(), + null == b.term || null != b.page ? void a.call(this, b, c) : void a.call(this, b, d) + ); + }), + (b.prototype.createTag = function(b, c) { + var d = a.trim(c.term); + return "" === d ? null : { id: d, text: d }; + }), + (b.prototype.insertTag = function(a, b, c) { + b.unshift(c); + }), + (b.prototype._removeOldTags = function(b) { + var c = (this._lastTag, this.$element.find("option[data-select2-tag]")); + c.each(function() { + this.selected || a(this).remove(); + }); + }), + b + ); + }), + b.define("select2/data/tokenizer", ["jquery"], function(a) { + function b(a, b, c) { + var d = c.get("tokenizer"); + void 0 !== d && (this.tokenizer = d), a.call(this, b, c); + } + return ( + (b.prototype.bind = function(a, b, c) { + a.call(this, b, c), + (this.$search = + b.dropdown.$search || b.selection.$search || c.find(".select2-search__field")); + }), + (b.prototype.query = function(b, c, d) { + function e(b) { + var c = g._normalizeItem(b), + d = g.$element.find("option").filter(function() { + return a(this).val() === c.id; + }); + if (!d.length) { + var e = g.option(c); + e.attr("data-select2-tag", !0), g._removeOldTags(), g.addOptions([e]); + } + f(c); + } + function f(a) { + g.trigger("select", { data: a }); + } + var g = this; + c.term = c.term || ""; + var h = this.tokenizer(c, this.options, e); + h.term !== c.term && + (this.$search.length && (this.$search.val(h.term), this.$search.focus()), + (c.term = h.term)), + b.call(this, c, d); + }), + (b.prototype.tokenizer = function(b, c, d, e) { + for ( + var f = d.get("tokenSeparators") || [], + g = c.term, + h = 0, + i = + this.createTag || + function(a) { + return { id: a.term, text: a.term }; + }; + h < g.length; + + ) { + var j = g[h]; + if (-1 !== a.inArray(j, f)) { + var k = g.substr(0, h), + l = a.extend({}, c, { term: k }), + m = i(l); + null != m ? (e(m), (g = g.substr(h + 1) || ""), (h = 0)) : h++; + } else h++; + } + return { term: g }; + }), + b + ); + }), + b.define("select2/data/minimumInputLength", [], function() { + function a(a, b, c) { + (this.minimumInputLength = c.get("minimumInputLength")), a.call(this, b, c); + } + return ( + (a.prototype.query = function(a, b, c) { + return ( + (b.term = b.term || ""), + b.term.length < this.minimumInputLength + ? void this.trigger("results:message", { + message: "inputTooShort", + args: { minimum: this.minimumInputLength, input: b.term, params: b } + }) + : void a.call(this, b, c) + ); + }), + a + ); + }), + b.define("select2/data/maximumInputLength", [], function() { + function a(a, b, c) { + (this.maximumInputLength = c.get("maximumInputLength")), a.call(this, b, c); + } + return ( + (a.prototype.query = function(a, b, c) { + return ( + (b.term = b.term || ""), + this.maximumInputLength > 0 && b.term.length > this.maximumInputLength + ? void this.trigger("results:message", { + message: "inputTooLong", + args: { maximum: this.maximumInputLength, input: b.term, params: b } + }) + : void a.call(this, b, c) + ); + }), + a + ); + }), + b.define("select2/data/maximumSelectionLength", [], function() { + function a(a, b, c) { + (this.maximumSelectionLength = c.get("maximumSelectionLength")), a.call(this, b, c); + } + return ( + (a.prototype.query = function(a, b, c) { + var d = this; + this.current(function(e) { + var f = null != e ? e.length : 0; + return d.maximumSelectionLength > 0 && f >= d.maximumSelectionLength + ? void d.trigger("results:message", { + message: "maximumSelected", + args: { maximum: d.maximumSelectionLength } + }) + : void a.call(d, b, c); + }); + }), + a + ); + }), + b.define("select2/dropdown", ["jquery", "./utils"], function(a, b) { + function c(a, b) { + (this.$element = a), (this.options = b), c.__super__.constructor.call(this); + } + return ( + b.Extend(c, b.Observable), + (c.prototype.render = function() { + var b = a( + '' + ); + return b.attr("dir", this.options.get("dir")), (this.$dropdown = b), b; + }), + (c.prototype.bind = function() {}), + (c.prototype.position = function(a, b) {}), + (c.prototype.destroy = function() { + this.$dropdown.remove(); + }), + c + ); + }), + b.define("select2/dropdown/search", ["jquery", "../utils"], function(a, b) { + function c() {} + return ( + (c.prototype.render = function(b) { + var c = b.call(this), + d = a( + '' + ); + return (this.$searchContainer = d), (this.$search = d.find("input")), c.prepend(d), c; + }), + (c.prototype.bind = function(b, c, d) { + var e = this; + b.call(this, c, d), + this.$search.on("keydown", function(a) { + e.trigger("keypress", a), (e._keyUpPrevented = a.isDefaultPrevented()); + }), + this.$search.on("input", function(b) { + a(this).off("keyup"); + }), + this.$search.on("keyup input", function(a) { + e.handleSearch(a); + }), + c.on("open", function() { + e.$search.attr("tabindex", 0), + e.$search.focus(), + window.setTimeout(function() { + e.$search.focus(); + }, 0); + }), + c.on("close", function() { + e.$search.attr("tabindex", -1), e.$search.val(""); + }), + c.on("focus", function() { + c.isOpen() && e.$search.focus(); + }), + c.on("results:all", function(a) { + if (null == a.query.term || "" === a.query.term) { + var b = e.showSearch(a); + b + ? e.$searchContainer.removeClass("select2-search--hide") + : e.$searchContainer.addClass("select2-search--hide"); + } + }); + }), + (c.prototype.handleSearch = function(a) { + if (!this._keyUpPrevented) { + var b = this.$search.val(); + this.trigger("query", { term: b }); + } + this._keyUpPrevented = !1; + }), + (c.prototype.showSearch = function(a, b) { + return !0; + }), + c + ); + }), + b.define("select2/dropdown/hidePlaceholder", [], function() { + function a(a, b, c, d) { + (this.placeholder = this.normalizePlaceholder(c.get("placeholder"))), + a.call(this, b, c, d); + } + return ( + (a.prototype.append = function(a, b) { + (b.results = this.removePlaceholder(b.results)), a.call(this, b); + }), + (a.prototype.normalizePlaceholder = function(a, b) { + return "string" == typeof b && (b = { id: "", text: b }), b; + }), + (a.prototype.removePlaceholder = function(a, b) { + for (var c = b.slice(0), d = b.length - 1; d >= 0; d--) { + var e = b[d]; + this.placeholder.id === e.id && c.splice(d, 1); + } + return c; + }), + a + ); + }), + b.define("select2/dropdown/infiniteScroll", ["jquery"], function(a) { + function b(a, b, c, d) { + (this.lastParams = {}), + a.call(this, b, c, d), + (this.$loadingMore = this.createLoadingMore()), + (this.loading = !1); + } + return ( + (b.prototype.append = function(a, b) { + this.$loadingMore.remove(), + (this.loading = !1), + a.call(this, b), + this.showLoadingMore(b) && this.$results.append(this.$loadingMore); + }), + (b.prototype.bind = function(b, c, d) { + var e = this; + b.call(this, c, d), + c.on("query", function(a) { + (e.lastParams = a), (e.loading = !0); + }), + c.on("query:append", function(a) { + (e.lastParams = a), (e.loading = !0); + }), + this.$results.on("scroll", function() { + var b = a.contains(document.documentElement, e.$loadingMore[0]); + if (!e.loading && b) { + var c = e.$results.offset().top + e.$results.outerHeight(!1), + d = e.$loadingMore.offset().top + e.$loadingMore.outerHeight(!1); + c + 50 >= d && e.loadMore(); + } + }); + }), + (b.prototype.loadMore = function() { + this.loading = !0; + var b = a.extend({}, { page: 1 }, this.lastParams); + b.page++, this.trigger("query:append", b); + }), + (b.prototype.showLoadingMore = function(a, b) { + return b.pagination && b.pagination.more; + }), + (b.prototype.createLoadingMore = function() { + var b = a( + '
              • ' + ), + c = this.options.get("translations").get("loadingMore"); + return b.html(c(this.lastParams)), b; + }), + b + ); + }), + b.define("select2/dropdown/attachBody", ["jquery", "../utils"], function(a, b) { + function c(b, c, d) { + (this.$dropdownParent = d.get("dropdownParent") || a(document.body)), + b.call(this, c, d); + } + return ( + (c.prototype.bind = function(a, b, c) { + var d = this, + e = !1; + a.call(this, b, c), + b.on("open", function() { + d._showDropdown(), + d._attachPositioningHandler(b), + e || + ((e = !0), + b.on("results:all", function() { + d._positionDropdown(), d._resizeDropdown(); + }), + b.on("results:append", function() { + d._positionDropdown(), d._resizeDropdown(); + })); + }), + b.on("close", function() { + d._hideDropdown(), d._detachPositioningHandler(b); + }), + this.$dropdownContainer.on("mousedown", function(a) { + a.stopPropagation(); + }); + }), + (c.prototype.destroy = function(a) { + a.call(this), this.$dropdownContainer.remove(); + }), + (c.prototype.position = function(a, b, c) { + b.attr("class", c.attr("class")), + b.removeClass("select2"), + b.addClass("select2-container--open"), + b.css({ position: "absolute", top: -999999 }), + (this.$container = c); + }), + (c.prototype.render = function(b) { + var c = a(""), + d = b.call(this); + return c.append(d), (this.$dropdownContainer = c), c; + }), + (c.prototype._hideDropdown = function(a) { + this.$dropdownContainer.detach(); + }), + (c.prototype._attachPositioningHandler = function(c, d) { + var e = this, + f = "scroll.select2." + d.id, + g = "resize.select2." + d.id, + h = "orientationchange.select2." + d.id, + i = this.$container.parents().filter(b.hasScroll); + i.each(function() { + a(this).data("select2-scroll-position", { + x: a(this).scrollLeft(), + y: a(this).scrollTop() + }); + }), + i.on(f, function(b) { + var c = a(this).data("select2-scroll-position"); + a(this).scrollTop(c.y); + }), + a(window).on(f + " " + g + " " + h, function(a) { + e._positionDropdown(), e._resizeDropdown(); + }); + }), + (c.prototype._detachPositioningHandler = function(c, d) { + var e = "scroll.select2." + d.id, + f = "resize.select2." + d.id, + g = "orientationchange.select2." + d.id, + h = this.$container.parents().filter(b.hasScroll); + h.off(e), a(window).off(e + " " + f + " " + g); + }), + (c.prototype._positionDropdown = function() { + var b = a(window), + c = this.$dropdown.hasClass("select2-dropdown--above"), + d = this.$dropdown.hasClass("select2-dropdown--below"), + e = null, + f = this.$container.offset(); + f.bottom = f.top + this.$container.outerHeight(!1); + var g = { height: this.$container.outerHeight(!1) }; + (g.top = f.top), (g.bottom = f.top + g.height); + var h = { height: this.$dropdown.outerHeight(!1) }, + i = { top: b.scrollTop(), bottom: b.scrollTop() + b.height() }, + j = i.top < f.top - h.height, + k = i.bottom > f.bottom + h.height, + l = { left: f.left, top: g.bottom }, + m = this.$dropdownParent; + "static" === m.css("position") && (m = m.offsetParent()); + var n = m.offset(); + (l.top -= n.top), + (l.left -= n.left), + c || d || (e = "below"), + k || !j || c ? !j && k && c && (e = "below") : (e = "above"), + ("above" == e || (c && "below" !== e)) && (l.top = g.top - n.top - h.height), + null != e && + (this.$dropdown + .removeClass("select2-dropdown--below select2-dropdown--above") + .addClass("select2-dropdown--" + e), + this.$container + .removeClass("select2-container--below select2-container--above") + .addClass("select2-container--" + e)), + this.$dropdownContainer.css(l); + }), + (c.prototype._resizeDropdown = function() { + var a = { width: this.$container.outerWidth(!1) + "px" }; + this.options.get("dropdownAutoWidth") && + ((a.minWidth = a.width), (a.position = "relative"), (a.width = "auto")), + this.$dropdown.css(a); + }), + (c.prototype._showDropdown = function(a) { + this.$dropdownContainer.appendTo(this.$dropdownParent), + this._positionDropdown(), + this._resizeDropdown(); + }), + c + ); + }), + b.define("select2/dropdown/minimumResultsForSearch", [], function() { + function a(b) { + for (var c = 0, d = 0; d < b.length; d++) { + var e = b[d]; + e.children ? (c += a(e.children)) : c++; + } + return c; + } + function b(a, b, c, d) { + (this.minimumResultsForSearch = c.get("minimumResultsForSearch")), + this.minimumResultsForSearch < 0 && (this.minimumResultsForSearch = 1 / 0), + a.call(this, b, c, d); + } + return ( + (b.prototype.showSearch = function(b, c) { + return a(c.data.results) < this.minimumResultsForSearch ? !1 : b.call(this, c); + }), + b + ); + }), + b.define("select2/dropdown/selectOnClose", [], function() { + function a() {} + return ( + (a.prototype.bind = function(a, b, c) { + var d = this; + a.call(this, b, c), + b.on("close", function(a) { + d._handleSelectOnClose(a); + }); + }), + (a.prototype._handleSelectOnClose = function(a, b) { + if (b && null != b.originalSelect2Event) { + var c = b.originalSelect2Event; + if ("select" === c._type || "unselect" === c._type) return; + } + var d = this.getHighlightedResults(); + if (!(d.length < 1)) { + var e = d.data("data"); + (null != e.element && e.element.selected) || + (null == e.element && e.selected) || + this.trigger("select", { data: e }); + } + }), + a + ); + }), + b.define("select2/dropdown/closeOnSelect", [], function() { + function a() {} + return ( + (a.prototype.bind = function(a, b, c) { + var d = this; + a.call(this, b, c), + b.on("select", function(a) { + d._selectTriggered(a); + }), + b.on("unselect", function(a) { + d._selectTriggered(a); + }); + }), + (a.prototype._selectTriggered = function(a, b) { + var c = b.originalEvent; + (c && c.ctrlKey) || + this.trigger("close", { originalEvent: c, originalSelect2Event: b }); + }), + a + ); + }), + b.define("select2/i18n/en", [], function() { + return { + errorLoading: function() { + return "The results could not be loaded."; + }, + inputTooLong: function(a) { + var b = a.input.length - a.maximum, + c = "Please delete " + b + " character"; + return 1 != b && (c += "s"), c; + }, + inputTooShort: function(a) { + var b = a.minimum - a.input.length, + c = "Please enter " + b + " or more characters"; + return c; + }, + loadingMore: function() { + return "Loading more results…"; + }, + maximumSelected: function(a) { + var b = "You can only select " + a.maximum + " item"; + return 1 != a.maximum && (b += "s"), b; + }, + noResults: function() { + return "No results found"; + }, + searching: function() { + return "Searching…"; + } + }; + }), + b.define( + "select2/defaults", + [ + "jquery", + "require", + "./results", + "./selection/single", + "./selection/multiple", + "./selection/placeholder", + "./selection/allowClear", + "./selection/search", + "./selection/eventRelay", + "./utils", + "./translation", + "./diacritics", + "./data/select", + "./data/array", + "./data/ajax", + "./data/tags", + "./data/tokenizer", + "./data/minimumInputLength", + "./data/maximumInputLength", + "./data/maximumSelectionLength", + "./dropdown", + "./dropdown/search", + "./dropdown/hidePlaceholder", + "./dropdown/infiniteScroll", + "./dropdown/attachBody", + "./dropdown/minimumResultsForSearch", + "./dropdown/selectOnClose", + "./dropdown/closeOnSelect", + "./i18n/en" + ], + 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 + ) { + function D() { + this.reset(); + } + (D.prototype.apply = function(l) { + if (((l = a.extend(!0, {}, this.defaults, l)), null == l.dataAdapter)) { + if ( + (null != l.ajax + ? (l.dataAdapter = o) + : null != l.data + ? (l.dataAdapter = n) + : (l.dataAdapter = m), + l.minimumInputLength > 0 && (l.dataAdapter = j.Decorate(l.dataAdapter, r)), + l.maximumInputLength > 0 && (l.dataAdapter = j.Decorate(l.dataAdapter, s)), + l.maximumSelectionLength > 0 && (l.dataAdapter = j.Decorate(l.dataAdapter, t)), + l.tags && (l.dataAdapter = j.Decorate(l.dataAdapter, p)), + (null != l.tokenSeparators || null != l.tokenizer) && + (l.dataAdapter = j.Decorate(l.dataAdapter, q)), + null != l.query) + ) { + var C = b(l.amdBase + "compat/query"); + l.dataAdapter = j.Decorate(l.dataAdapter, C); + } + if (null != l.initSelection) { + var D = b(l.amdBase + "compat/initSelection"); + l.dataAdapter = j.Decorate(l.dataAdapter, D); + } + } + if ( + (null == l.resultsAdapter && + ((l.resultsAdapter = c), + null != l.ajax && (l.resultsAdapter = j.Decorate(l.resultsAdapter, x)), + null != l.placeholder && (l.resultsAdapter = j.Decorate(l.resultsAdapter, w)), + l.selectOnClose && (l.resultsAdapter = j.Decorate(l.resultsAdapter, A))), + null == l.dropdownAdapter) + ) { + if (l.multiple) l.dropdownAdapter = u; + else { + var E = j.Decorate(u, v); + l.dropdownAdapter = E; + } + if ( + (0 !== l.minimumResultsForSearch && + (l.dropdownAdapter = j.Decorate(l.dropdownAdapter, z)), + l.closeOnSelect && (l.dropdownAdapter = j.Decorate(l.dropdownAdapter, B)), + null != l.dropdownCssClass || + null != l.dropdownCss || + null != l.adaptDropdownCssClass) + ) { + var F = b(l.amdBase + "compat/dropdownCss"); + l.dropdownAdapter = j.Decorate(l.dropdownAdapter, F); + } + l.dropdownAdapter = j.Decorate(l.dropdownAdapter, y); + } + if (null == l.selectionAdapter) { + if ( + (l.multiple ? (l.selectionAdapter = e) : (l.selectionAdapter = d), + null != l.placeholder && (l.selectionAdapter = j.Decorate(l.selectionAdapter, f)), + l.allowClear && (l.selectionAdapter = j.Decorate(l.selectionAdapter, g)), + l.multiple && (l.selectionAdapter = j.Decorate(l.selectionAdapter, h)), + null != l.containerCssClass || + null != l.containerCss || + null != l.adaptContainerCssClass) + ) { + var G = b(l.amdBase + "compat/containerCss"); + l.selectionAdapter = j.Decorate(l.selectionAdapter, G); + } + l.selectionAdapter = j.Decorate(l.selectionAdapter, i); + } + if ("string" == typeof l.language) + if (l.language.indexOf("-") > 0) { + var H = l.language.split("-"), + I = H[0]; + l.language = [l.language, I]; + } else l.language = [l.language]; + if (a.isArray(l.language)) { + var J = new k(); + l.language.push("en"); + for (var K = l.language, L = 0; L < K.length; L++) { + var M = K[L], + N = {}; + try { + N = k.loadPath(M); + } catch (O) { + try { + (M = this.defaults.amdLanguageBase + M), (N = k.loadPath(M)); + } catch (P) { + l.debug && + window.console && + console.warn && + console.warn( + 'Select2: The language file for "' + + M + + '" could not be automatically loaded. A fallback will be used instead.' + ); + continue; + } + } + J.extend(N); + } + l.translations = J; + } else { + var Q = k.loadPath(this.defaults.amdLanguageBase + "en"), + R = new k(l.language); + R.extend(Q), (l.translations = R); + } + return l; + }), + (D.prototype.reset = function() { + function b(a) { + function b(a) { + return l[a] || a; + } + return a.replace(/[^\u0000-\u007E]/g, b); + } + function c(d, e) { + if ("" === a.trim(d.term)) return e; + if (e.children && e.children.length > 0) { + for (var f = a.extend(!0, {}, e), g = e.children.length - 1; g >= 0; g--) { + var h = e.children[g], + i = c(d, h); + null == i && f.children.splice(g, 1); + } + return f.children.length > 0 ? f : c(d, f); + } + var j = b(e.text).toUpperCase(), + k = b(d.term).toUpperCase(); + return j.indexOf(k) > -1 ? e : null; + } + this.defaults = { + amdBase: "./", + amdLanguageBase: "./i18n/", + closeOnSelect: !0, + debug: !1, + dropdownAutoWidth: !1, + escapeMarkup: j.escapeMarkup, + language: C, + matcher: c, + minimumInputLength: 0, + maximumInputLength: 0, + maximumSelectionLength: 0, + minimumResultsForSearch: 0, + selectOnClose: !1, + sorter: function(a) { + return a; + }, + templateResult: function(a) { + return a.text; + }, + templateSelection: function(a) { + return a.text; + }, + theme: "default", + width: "resolve" + }; + }), + (D.prototype.set = function(b, c) { + var d = a.camelCase(b), + e = {}; + e[d] = c; + var f = j._convertData(e); + a.extend(this.defaults, f); + }); + var E = new D(); + return E; + } + ), + b.define("select2/options", ["require", "jquery", "./defaults", "./utils"], function( + a, + b, + c, + d + ) { + function e(b, e) { + if ( + ((this.options = b), + null != e && this.fromElement(e), + (this.options = c.apply(this.options)), + e && e.is("input")) + ) { + var f = a(this.get("amdBase") + "compat/inputData"); + this.options.dataAdapter = d.Decorate(this.options.dataAdapter, f); + } + } + return ( + (e.prototype.fromElement = function(a) { + var c = ["select2"]; + null == this.options.multiple && (this.options.multiple = a.prop("multiple")), + null == this.options.disabled && (this.options.disabled = a.prop("disabled")), + null == this.options.language && + (a.prop("lang") + ? (this.options.language = a.prop("lang").toLowerCase()) + : a.closest("[lang]").prop("lang") && + (this.options.language = a.closest("[lang]").prop("lang"))), + null == this.options.dir && + (a.prop("dir") + ? (this.options.dir = a.prop("dir")) + : a.closest("[dir]").prop("dir") + ? (this.options.dir = a.closest("[dir]").prop("dir")) + : (this.options.dir = "ltr")), + a.prop("disabled", this.options.disabled), + a.prop("multiple", this.options.multiple), + a.data("select2Tags") && + (this.options.debug && + window.console && + console.warn && + console.warn( + 'Select2: The `data-select2-tags` attribute has been changed to use the `data-data` and `data-tags="true"` attributes and will be removed in future versions of Select2.' + ), + a.data("data", a.data("select2Tags")), + a.data("tags", !0)), + a.data("ajaxUrl") && + (this.options.debug && + window.console && + console.warn && + console.warn( + "Select2: The `data-ajax-url` attribute has been changed to `data-ajax--url` and support for the old attribute will be removed in future versions of Select2." + ), + a.attr("ajax--url", a.data("ajaxUrl")), + a.data("ajax--url", a.data("ajaxUrl"))); + var e = {}; + e = + b.fn.jquery && "1." == b.fn.jquery.substr(0, 2) && a[0].dataset + ? b.extend(!0, {}, a[0].dataset, a.data()) + : a.data(); + var f = b.extend(!0, {}, e); + f = d._convertData(f); + for (var g in f) + b.inArray(g, c) > -1 || + (b.isPlainObject(this.options[g]) + ? b.extend(this.options[g], f[g]) + : (this.options[g] = f[g])); + return this; + }), + (e.prototype.get = function(a) { + return this.options[a]; + }), + (e.prototype.set = function(a, b) { + this.options[a] = b; + }), + e + ); + }), + b.define("select2/core", ["jquery", "./options", "./utils", "./keys"], function( + a, + b, + c, + d + ) { + var e = function(a, c) { + null != a.data("select2") && a.data("select2").destroy(), + (this.$element = a), + (this.id = this._generateId(a)), + (c = c || {}), + (this.options = new b(c, a)), + e.__super__.constructor.call(this); + var d = a.attr("tabindex") || 0; + a.data("old-tabindex", d), a.attr("tabindex", "-1"); + var f = this.options.get("dataAdapter"); + this.dataAdapter = new f(a, this.options); + var g = this.render(); + this._placeContainer(g); + var h = this.options.get("selectionAdapter"); + (this.selection = new h(a, this.options)), + (this.$selection = this.selection.render()), + this.selection.position(this.$selection, g); + var i = this.options.get("dropdownAdapter"); + (this.dropdown = new i(a, this.options)), + (this.$dropdown = this.dropdown.render()), + this.dropdown.position(this.$dropdown, g); + var j = this.options.get("resultsAdapter"); + (this.results = new j(a, this.options, this.dataAdapter)), + (this.$results = this.results.render()), + this.results.position(this.$results, this.$dropdown); + var k = this; + this._bindAdapters(), + this._registerDomEvents(), + this._registerDataEvents(), + this._registerSelectionEvents(), + this._registerDropdownEvents(), + this._registerResultsEvents(), + this._registerEvents(), + this.dataAdapter.current(function(a) { + k.trigger("selection:update", { data: a }); + }), + a.addClass("select2-hidden-accessible"), + a.attr("aria-hidden", "true"), + this._syncAttributes(), + a.data("select2", this); + }; + return ( + c.Extend(e, c.Observable), + (e.prototype._generateId = function(a) { + var b = ""; + return ( + (b = + null != a.attr("id") + ? a.attr("id") + : null != a.attr("name") + ? a.attr("name") + "-" + c.generateChars(2) + : c.generateChars(4)), + (b = b.replace(/(:|\.|\[|\]|,)/g, "")), + (b = "select2-" + b) + ); + }), + (e.prototype._placeContainer = function(a) { + a.insertAfter(this.$element); + var b = this._resolveWidth(this.$element, this.options.get("width")); + null != b && a.css("width", b); + }), + (e.prototype._resolveWidth = function(a, b) { + var c = /^width:(([-+]?([0-9]*\.)?[0-9]+)(px|em|ex|%|in|cm|mm|pt|pc))/i; + if ("resolve" == b) { + var d = this._resolveWidth(a, "style"); + return null != d ? d : this._resolveWidth(a, "element"); + } + if ("element" == b) { + var e = a.outerWidth(!1); + return 0 >= e ? "auto" : e + "px"; + } + if ("style" == b) { + var f = a.attr("style"); + if ("string" != typeof f) return null; + for (var g = f.split(";"), h = 0, i = g.length; i > h; h += 1) { + var j = g[h].replace(/\s/g, ""), + k = j.match(c); + if (null !== k && k.length >= 1) return k[1]; + } + return null; + } + return b; + }), + (e.prototype._bindAdapters = function() { + this.dataAdapter.bind(this, this.$container), + this.selection.bind(this, this.$container), + this.dropdown.bind(this, this.$container), + this.results.bind(this, this.$container); + }), + (e.prototype._registerDomEvents = function() { + var b = this; + this.$element.on("change.select2", function() { + b.dataAdapter.current(function(a) { + b.trigger("selection:update", { data: a }); + }); + }), + this.$element.on("focus.select2", function(a) { + b.trigger("focus", a); + }), + (this._syncA = c.bind(this._syncAttributes, this)), + (this._syncS = c.bind(this._syncSubtree, this)), + this.$element[0].attachEvent && + this.$element[0].attachEvent("onpropertychange", this._syncA); + var d = + window.MutationObserver || + window.WebKitMutationObserver || + window.MozMutationObserver; + null != d + ? ((this._observer = new d(function(c) { + a.each(c, b._syncA), a.each(c, b._syncS); + })), + this._observer.observe(this.$element[0], { + attributes: !0, + childList: !0, + subtree: !1 + })) + : this.$element[0].addEventListener && + (this.$element[0].addEventListener("DOMAttrModified", b._syncA, !1), + this.$element[0].addEventListener("DOMNodeInserted", b._syncS, !1), + this.$element[0].addEventListener("DOMNodeRemoved", b._syncS, !1)); + }), + (e.prototype._registerDataEvents = function() { + var a = this; + this.dataAdapter.on("*", function(b, c) { + a.trigger(b, c); + }); + }), + (e.prototype._registerSelectionEvents = function() { + var b = this, + c = ["toggle", "focus"]; + this.selection.on("toggle", function() { + b.toggleDropdown(); + }), + this.selection.on("focus", function(a) { + b.focus(a); + }), + this.selection.on("*", function(d, e) { + -1 === a.inArray(d, c) && b.trigger(d, e); + }); + }), + (e.prototype._registerDropdownEvents = function() { + var a = this; + this.dropdown.on("*", function(b, c) { + a.trigger(b, c); + }); + }), + (e.prototype._registerResultsEvents = function() { + var a = this; + this.results.on("*", function(b, c) { + a.trigger(b, c); + }); + }), + (e.prototype._registerEvents = function() { + var a = this; + this.on("open", function() { + a.$container.addClass("select2-container--open"); + }), + this.on("close", function() { + a.$container.removeClass("select2-container--open"); + }), + this.on("enable", function() { + a.$container.removeClass("select2-container--disabled"); + }), + this.on("disable", function() { + a.$container.addClass("select2-container--disabled"); + }), + this.on("blur", function() { + a.$container.removeClass("select2-container--focus"); + }), + this.on("query", function(b) { + a.isOpen() || a.trigger("open", {}), + this.dataAdapter.query(b, function(c) { + a.trigger("results:all", { data: c, query: b }); + }); + }), + this.on("query:append", function(b) { + this.dataAdapter.query(b, function(c) { + a.trigger("results:append", { data: c, query: b }); + }); + }), + this.on("keypress", function(b) { + var c = b.which; + a.isOpen() + ? c === d.ESC || c === d.TAB || (c === d.UP && b.altKey) + ? (a.close(), b.preventDefault()) + : c === d.ENTER + ? (a.trigger("results:select", {}), b.preventDefault()) + : c === d.SPACE && b.ctrlKey + ? (a.trigger("results:toggle", {}), b.preventDefault()) + : c === d.UP + ? (a.trigger("results:previous", {}), b.preventDefault()) + : c === d.DOWN && (a.trigger("results:next", {}), b.preventDefault()) + : (c === d.ENTER || c === d.SPACE || (c === d.DOWN && b.altKey)) && + (a.open(), b.preventDefault()); + }); + }), + (e.prototype._syncAttributes = function() { + this.options.set("disabled", this.$element.prop("disabled")), + this.options.get("disabled") + ? (this.isOpen() && this.close(), this.trigger("disable", {})) + : this.trigger("enable", {}); + }), + (e.prototype._syncSubtree = function(a, b) { + var c = !1, + d = this; + if ( + !a || + !a.target || + "OPTION" === a.target.nodeName || + "OPTGROUP" === a.target.nodeName + ) { + if (b) + if (b.addedNodes && b.addedNodes.length > 0) + for (var e = 0; e < b.addedNodes.length; e++) { + var f = b.addedNodes[e]; + f.selected && (c = !0); + } + else b.removedNodes && b.removedNodes.length > 0 && (c = !0); + else c = !0; + c && + this.dataAdapter.current(function(a) { + d.trigger("selection:update", { data: a }); + }); + } + }), + (e.prototype.trigger = function(a, b) { + var c = e.__super__.trigger, + d = { + open: "opening", + close: "closing", + select: "selecting", + unselect: "unselecting" + }; + if ((void 0 === b && (b = {}), a in d)) { + var f = d[a], + g = { prevented: !1, name: a, args: b }; + if ((c.call(this, f, g), g.prevented)) return void (b.prevented = !0); + } + c.call(this, a, b); + }), + (e.prototype.toggleDropdown = function() { + this.options.get("disabled") || (this.isOpen() ? this.close() : this.open()); + }), + (e.prototype.open = function() { + this.isOpen() || this.trigger("query", {}); + }), + (e.prototype.close = function() { + this.isOpen() && this.trigger("close", {}); + }), + (e.prototype.isOpen = function() { + return this.$container.hasClass("select2-container--open"); + }), + (e.prototype.hasFocus = function() { + return this.$container.hasClass("select2-container--focus"); + }), + (e.prototype.focus = function(a) { + this.hasFocus() || + (this.$container.addClass("select2-container--focus"), this.trigger("focus", {})); + }), + (e.prototype.enable = function(a) { + this.options.get("debug") && + window.console && + console.warn && + console.warn( + 'Select2: The `select2("enable")` method has been deprecated and will be removed in later Select2 versions. Use $element.prop("disabled") instead.' + ), + (null == a || 0 === a.length) && (a = [!0]); + var b = !a[0]; + this.$element.prop("disabled", b); + }), + (e.prototype.data = function() { + this.options.get("debug") && + arguments.length > 0 && + window.console && + console.warn && + console.warn( + 'Select2: Data can no longer be set using `select2("data")`. You should consider setting the value instead using `$element.val()`.' + ); + var a = []; + return ( + this.dataAdapter.current(function(b) { + a = b; + }), + a + ); + }), + (e.prototype.val = function(b) { + if ( + (this.options.get("debug") && + window.console && + console.warn && + console.warn( + 'Select2: The `select2("val")` method has been deprecated and will be removed in later Select2 versions. Use $element.val() instead.' + ), + null == b || 0 === b.length) + ) + return this.$element.val(); + var c = b[0]; + a.isArray(c) && + (c = a.map(c, function(a) { + return a.toString(); + })), + this.$element.val(c).trigger("change"); + }), + (e.prototype.destroy = function() { + this.$container.remove(), + this.$element[0].detachEvent && + this.$element[0].detachEvent("onpropertychange", this._syncA), + null != this._observer + ? (this._observer.disconnect(), (this._observer = null)) + : this.$element[0].removeEventListener && + (this.$element[0].removeEventListener("DOMAttrModified", this._syncA, !1), + this.$element[0].removeEventListener("DOMNodeInserted", this._syncS, !1), + this.$element[0].removeEventListener("DOMNodeRemoved", this._syncS, !1)), + (this._syncA = null), + (this._syncS = null), + this.$element.off(".select2"), + this.$element.attr("tabindex", this.$element.data("old-tabindex")), + this.$element.removeClass("select2-hidden-accessible"), + this.$element.attr("aria-hidden", "false"), + this.$element.removeData("select2"), + this.dataAdapter.destroy(), + this.selection.destroy(), + this.dropdown.destroy(), + this.results.destroy(), + (this.dataAdapter = null), + (this.selection = null), + (this.dropdown = null), + (this.results = null); + }), + (e.prototype.render = function() { + var b = a( + '' + ); + return ( + b.attr("dir", this.options.get("dir")), + (this.$container = b), + this.$container.addClass("select2-container--" + this.options.get("theme")), + b.data("element", this.$element), + b + ); + }), + e + ); + }), + b.define("jquery-mousewheel", ["jquery"], function(a) { + return a; + }), + b.define( + "jquery.select2", + ["jquery", "jquery-mousewheel", "./select2/core", "./select2/defaults"], + function(a, b, c, d) { + if (null == a.fn.select2) { + var e = ["open", "close", "destroy"]; + a.fn.select2 = function(b) { + if (((b = b || {}), "object" == typeof b)) + return ( + this.each(function() { + var d = a.extend(!0, {}, b); + new c(a(this), d); + }), + this + ); + if ("string" == typeof b) { + var d, + f = Array.prototype.slice.call(arguments, 1); + return ( + this.each(function() { + var c = a(this).data("select2"); + null == c && + window.console && + console.error && + console.error( + "The select2('" + + b + + "') method was called on an element that is not using Select2." + ), + (d = c[b].apply(c, f)); + }), + a.inArray(b, e) > -1 ? this : d + ); + } + throw new Error("Invalid arguments for Select2: " + b); + }; + } + return null == a.fn.select2.defaults && (a.fn.select2.defaults = d), c; + } + ), + { define: b.define, require: b.require } + ); + })(), + c = b.require("jquery.select2"); + return (a.fn.select2.amd = b), c; +}); diff --git a/imports/ui/compatibilities/timepicker/timepicker.min.css b/imports/ui/compatibilities/timepicker/timepicker.min.css new file mode 100644 index 00000000..1b0ee18b --- /dev/null +++ b/imports/ui/compatibilities/timepicker/timepicker.min.css @@ -0,0 +1,84 @@ +/** + * jQuery Timepicker + * http://timepicker.co + * + * Enhances standard form input fields helping users to select (or type) times. + * + * Copyright (c) 2016 Willington Vega; Licensed MIT, GPL + */ + +.ui-timepicker-container { + position: absolute; + overflow: hidden; + box-sizing: border-box; +} + +.ui-timepicker { + box-sizing: content-box; + display: block; + height: 205px; + list-style: none outside none; + margin: 0; + padding: 0 1px; + text-align: center; +} + +.ui-timepicker-viewport { + box-sizing: content-box; + display: block; + height: 205px; + margin: 0; + padding: 0; + overflow: auto; + overflow-x: hidden; /* IE */ +} + +.ui-timepicker-standard { + /* overwrites .ui-widget */ + font-family: Verdana, Arial, sans-serif; + font-size: 1.1em; + /* overwrites .ui-widget-content */ + background-color: #fff; + border: 1px solid #aaa; + color: #222; + /* overwrites .ui-menu */ + margin: 0; + padding: 2px; +} +.ui-timepicker-standard a { + border: 1px solid transparent; + color: #222; + display: block; + padding: 0.2em 0.4em; + text-decoration: none; +} +.ui-timepicker-standard .ui-state-hover { + /* overwrites .ui-state-hover */ + background-color: #dadada; + border: 1px solid #999; + font-weight: normal; + color: #212121; +} +.ui-timepicker-standard .ui-menu-item { + /* overwrites .ui-menu and .ui-menu-item */ + /*clear: left; + float: left;*/ + margin: 0; + padding: 0; +} + +.ui-timepicker-corners, +.ui-timepicker-corners .ui-corner-all { + -moz-border-radius: 4px; + -webkit-border-radius: 4px; + border-radius: 4px; +} + +.ui-timepicker-hidden { + /* overwrites .ui-helper-hidden */ + display: none; +} + +.ui-timepicker-no-scrollbar .ui-timepicker { + border: none; +} diff --git a/imports/ui/compatibilities/timepicker/timepicker.min.js b/imports/ui/compatibilities/timepicker/timepicker.min.js new file mode 100644 index 00000000..72f44c3d --- /dev/null +++ b/imports/ui/compatibilities/timepicker/timepicker.min.js @@ -0,0 +1,596 @@ +!(function(e) { + "object" == typeof module && "object" == typeof module.exports + ? e(require("jquery"), window, document) + : "undefined" != typeof jQuery && e(jQuery, window, document); +})(function(e, t, i, n) { + !(function() { + function t(e, t, i) { + return new Array(i + 1 - e.length).join(t) + e; + } + function n() { + if (1 === arguments.length) { + var t = arguments[0]; + return ( + "string" == typeof t && (t = e.fn.timepicker.parseTime(t)), + new Date(0, 0, 0, t.getHours(), t.getMinutes(), t.getSeconds()) + ); + } + return 3 === arguments.length + ? new Date(0, 0, 0, arguments[0], arguments[1], arguments[2]) + : 2 === arguments.length + ? new Date(0, 0, 0, arguments[0], arguments[1], 0) + : new Date(0, 0, 0); + } + (e.TimePicker = function() { + var t = this; + (t.container = e(".ui-timepicker-container")), + (t.ui = t.container.find(".ui-timepicker")), + 0 === t.container.length && + ((t.container = e("
                ") + .addClass("ui-timepicker-container") + .addClass("ui-timepicker-hidden ui-helper-hidden") + .appendTo("body") + .hide()), + (t.ui = e("
                ") + .addClass("ui-timepicker") + .addClass("ui-widget ui-widget-content ui-menu") + .addClass("ui-corner-all") + .appendTo(t.container)), + (t.viewport = e("
                  ") + .addClass("ui-timepicker-viewport") + .appendTo(t.ui)), + e.fn.jquery >= "1.4.2" && + t.ui + .delegate("a", "mouseenter.timepicker", function() { + t.activate(!1, e(this).parent()); + }) + .delegate("a", "mouseleave.timepicker", function() { + t.deactivate(!1); + }) + .delegate("a", "click.timepicker", function(i) { + i.preventDefault(), t.select(!1, e(this).parent()); + })); + }), + (e.TimePicker.count = 0), + (e.TimePicker.instance = function() { + return ( + e.TimePicker._instance || (e.TimePicker._instance = new e.TimePicker()), + e.TimePicker._instance + ); + }), + (e.TimePicker.prototype = { + keyCode: { + ALT: 18, + BLOQ_MAYUS: 20, + CTRL: 17, + DOWN: 40, + END: 35, + ENTER: 13, + HOME: 36, + LEFT: 37, + NUMPAD_ENTER: 108, + PAGE_DOWN: 34, + PAGE_UP: 33, + RIGHT: 39, + SHIFT: 16, + TAB: 9, + UP: 38 + }, + _items: function(t, i) { + var r, + a, + o = this, + s = e("
                    "), + c = null; + for ( + -1 === t.options.timeFormat.indexOf("m") && + t.options.interval % 60 !== 0 && + (t.options.interval = 60 * Math.max(Math.round(t.options.interval / 60), 1)), + r = i + ? n(i) + : t.options.startTime + ? n(t.options.startTime) + : n(t.options.startHour, t.options.startMinutes), + a = new Date(r.getTime() + 864e5); + a > r; + + ) + o._isValidTime(t, r) && + ((c = e("
                  • ") + .addClass("ui-menu-item") + .appendTo(s)), + e("") + .addClass("ui-corner-all") + .text(e.fn.timepicker.formatTime(t.options.timeFormat, r)) + .appendTo(c), + c.data("time-value", r)), + (r = new Date(r.getTime() + 60 * t.options.interval * 1e3)); + return s.children(); + }, + _isValidTime: function(e, t) { + var i = null, + r = null; + return ( + (t = n(t)), + null !== e.options.minTime + ? (i = n(e.options.minTime)) + : (null === e.options.minHour && null === e.options.minMinutes) || + (i = n(e.options.minHour, e.options.minMinutes)), + null !== e.options.maxTime + ? (r = n(e.options.maxTime)) + : (null === e.options.maxHour && null === e.options.maxMinutes) || + (r = n(e.options.maxHour, e.options.maxMinutes)), + null !== i && null !== r + ? t >= i && r >= t + : null !== i + ? t >= i + : null !== r + ? r >= t + : !0 + ); + }, + _hasScroll: function() { + var e = "undefined" != typeof this.ui.prop ? "prop" : "attr"; + return this.ui.height() < this.ui[e]("scrollHeight"); + }, + _move: function(e, t, i) { + var n = this; + if ((n.closed() && n.open(e), !n.active)) + return void n.activate(e, n.viewport.children(i)); + var r = n.active[t + "All"](".ui-menu-item").eq(0); + r.length ? n.activate(e, r) : n.activate(e, n.viewport.children(i)); + }, + register: function(t, i) { + var n = this, + r = {}; + (r.element = e(t)), + r.element.data("TimePicker") || + ((r.options = e.metadata ? e.extend({}, i, r.element.metadata()) : e.extend({}, i)), + (r.widget = n), + e.extend(r, { + next: function() { + return n.next(r); + }, + previous: function() { + return n.previous(r); + }, + first: function() { + return n.first(r); + }, + last: function() { + return n.last(r); + }, + selected: function() { + return n.selected(r); + }, + open: function() { + return n.open(r); + }, + close: function() { + return n.close(r); + }, + closed: function() { + return n.closed(r); + }, + destroy: function() { + return n.destroy(r); + }, + parse: function(e) { + return n.parse(r, e); + }, + format: function(e, t) { + return n.format(r, e, t); + }, + getTime: function() { + return n.getTime(r); + }, + setTime: function(e, t) { + return n.setTime(r, e, t); + }, + option: function(e, t) { + return n.option(r, e, t); + } + }), + n._setDefaultTime(r), + n._addInputEventsHandlers(r), + r.element.data("TimePicker", r)); + }, + _setDefaultTime: function(t) { + "now" === t.options.defaultTime + ? t.setTime(n(new Date())) + : t.options.defaultTime && t.options.defaultTime.getFullYear + ? t.setTime(n(t.options.defaultTime)) + : t.options.defaultTime && + t.setTime(e.fn.timepicker.parseTime(t.options.defaultTime)); + }, + _addInputEventsHandlers: function(t) { + var i = this; + t.element + .bind("keydown.timepicker", function(e) { + switch (e.which || e.keyCode) { + case i.keyCode.ENTER: + case i.keyCode.NUMPAD_ENTER: + e.preventDefault(), + i.closed() ? t.element.trigger("change.timepicker") : i.select(t, i.active); + break; + case i.keyCode.UP: + t.previous(); + break; + case i.keyCode.DOWN: + t.next(); + break; + default: + i.closed() || t.close(!0); + } + }) + .bind("focus.timepicker", function() { + t.open(); + }) + .bind("blur.timepicker", function() { + setTimeout(function() { + t.element.data("timepicker-user-clicked-outside") && t.close(); + }); + }) + .bind("change.timepicker", function() { + t.closed() && t.setTime(e.fn.timepicker.parseTime(t.element.val())); + }); + }, + select: function(t, i) { + var n = this, + r = t === !1 ? n.instance : t; + n.setTime(r, e.fn.timepicker.parseTime(i.children("a").text())), n.close(r, !0); + }, + activate: function(e, t) { + var i = this, + n = e === !1 ? i.instance : e; + if (n === i.instance) { + if ((i.deactivate(), i._hasScroll())) { + var r = t.offset().top - i.ui.offset().top, + a = i.ui.scrollTop(), + o = i.ui.height(); + 0 > r ? i.ui.scrollTop(a + r) : r >= o && i.ui.scrollTop(a + r - o + t.height()); + } + i.active = t + .eq(0) + .children("a") + .addClass("ui-state-hover") + .attr("id", "ui-active-item") + .end(); + } + }, + deactivate: function() { + var e = this; + e.active && + (e.active + .children("a") + .removeClass("ui-state-hover") + .removeAttr("id"), + (e.active = null)); + }, + next: function(e) { + return ( + (this.closed() || this.instance === e) && this._move(e, "next", ".ui-menu-item:first"), + e.element + ); + }, + previous: function(e) { + return ( + (this.closed() || this.instance === e) && this._move(e, "prev", ".ui-menu-item:last"), + e.element + ); + }, + first: function(e) { + return this.instance === e + ? this.active && 0 === this.active.prevAll(".ui-menu-item").length + : !1; + }, + last: function(e) { + return this.instance === e + ? this.active && 0 === this.active.nextAll(".ui-menu-item").length + : !1; + }, + selected: function(e) { + return this.instance === e && this.active ? this.active : null; + }, + open: function(t) { + var n = this, + r = t.getTime(), + a = t.options.dynamic && r; + if (!t.options.dropdown) return t.element; + switch ( + (t.element.data("timepicker-event-namespace", Math.random()), + e(i).bind("click.timepicker-" + t.element.data("timepicker-event-namespace"), function( + e + ) { + t.element.get(0) === e.target + ? t.element.data("timepicker-user-clicked-outside", !1) + : t.element.data("timepicker-user-clicked-outside", !0).blur(); + }), + (t.rebuild || !t.items || a) && (t.items = n._items(t, a ? r : null)), + (t.rebuild || n.instance !== t || a) && + (e.fn.jquery < "1.4.2" + ? (n.viewport.children().remove(), + n.viewport.append(t.items), + n.viewport + .find("a") + .bind("mouseover.timepicker", function() { + n.activate(t, e(this).parent()); + }) + .bind("mouseout.timepicker", function() { + n.deactivate(t); + }) + .bind("click.timepicker", function(i) { + i.preventDefault(), n.select(t, e(this).parent()); + })) + : (n.viewport.children().detach(), n.viewport.append(t.items))), + (t.rebuild = !1), + n.container + .removeClass( + "ui-helper-hidden ui-timepicker-hidden ui-timepicker-standard ui-timepicker-corners" + ) + .show(), + t.options.theme) + ) { + case "standard": + n.container.addClass("ui-timepicker-standard"); + break; + case "standard-rounded-corners": + n.container.addClass("ui-timepicker-standard ui-timepicker-corners"); + } + n.container.hasClass("ui-timepicker-no-scrollbar") || + t.options.scrollbar || + (n.container.addClass("ui-timepicker-no-scrollbar"), + n.viewport.css({ paddingRight: 40 })); + var o = n.container.outerHeight() - n.container.height(), + s = t.options.zindex ? t.options.zindex : t.element.offsetParent().css("z-index"), + c = t.element.offset(); + n.container.css({ top: c.top + t.element.outerHeight(), left: c.left }), + n.container.show(), + n.container.css({ + left: t.element.offset().left, + height: n.ui.outerHeight() + o, + width: t.element.outerWidth(), + zIndex: s, + cursor: "default" + }); + var u = n.container.width() - (n.ui.outerWidth() - n.ui.width()); + return ( + n.ui.css({ width: u }), + n.viewport.css({ width: u }), + t.items.css({ width: u }), + (n.instance = t), + r + ? t.items.each(function() { + var i, + a = e(this); + return ( + (i = + e.fn.jquery < "1.4.2" + ? e.fn.timepicker.parseTime(a.find("a").text()) + : a.data("time-value")), + i.getTime() === r.getTime() ? (n.activate(t, a), !1) : !0 + ); + }) + : n.deactivate(t), + t.element + ); + }, + close: function(t) { + var n = this; + return ( + n.instance === t && + (n.container.addClass("ui-helper-hidden ui-timepicker-hidden").hide(), + n.ui.scrollTop(0), + n.ui.children().removeClass("ui-state-hover")), + e(i).unbind("click.timepicker-" + t.element.data("timepicker-event-namespace")), + t.element + ); + }, + closed: function() { + return this.ui.is(":hidden"); + }, + destroy: function(e) { + var t = this; + return t.close(e, !0), e.element.unbind(".timepicker").data("TimePicker", null); + }, + parse: function(t, i) { + return e.fn.timepicker.parseTime(i); + }, + format: function(t, i, n) { + return (n = n || t.options.timeFormat), e.fn.timepicker.formatTime(n, i); + }, + getTime: function(t) { + var i = this, + n = e.fn.timepicker.parseTime(t.element.val()); + return n instanceof Date && !i._isValidTime(t, n) + ? null + : n instanceof Date && t.selectedTime + ? t.format(n) === t.format(t.selectedTime) + ? t.selectedTime + : n + : n instanceof Date + ? n + : null; + }, + setTime: function(t, i, r) { + var a = this, + o = t.selectedTime; + if ( + ("string" == typeof i && (i = t.parse(i)), i && i.getMinutes && a._isValidTime(t, i)) + ) { + if ( + ((i = n(i)), + (t.selectedTime = i), + t.element.val(t.format(i, t.options.timeFormat)), + r) + ) + return t; + } else t.selectedTime = null; + return ( + (null === o && null === t.selectedTime) || + (t.element.trigger("time-change", [i]), + e.isFunction(t.options.change) && t.options.change.apply(t.element, [i])), + t.element + ); + }, + option: function(t, i, n) { + if ("undefined" == typeof n) return t.options[i]; + var r, + a, + o = t.getTime(); + "string" == typeof i ? ((r = {}), (r[i] = n)) : (r = i), + (a = [ + "minHour", + "minMinutes", + "minTime", + "maxHour", + "maxMinutes", + "maxTime", + "startHour", + "startMinutes", + "startTime", + "timeFormat", + "interval", + "dropdown" + ]), + e.each(r, function(i) { + (t.options[i] = r[i]), (t.rebuild = t.rebuild || e.inArray(i, a) > -1); + }), + t.rebuild && t.setTime(o); + } + }), + (e.TimePicker.defaults = { + timeFormat: "hh:mm p", + minHour: null, + minMinutes: null, + minTime: null, + maxHour: null, + maxMinutes: null, + maxTime: null, + startHour: null, + startMinutes: null, + startTime: null, + interval: 30, + dynamic: !0, + theme: "standard", + zindex: null, + dropdown: !0, + scrollbar: !1, + change: function() {} + }), + (e.TimePicker.methods = { + chainable: ["next", "previous", "open", "close", "destroy", "setTime"] + }), + (e.fn.timepicker = function(t) { + if ("string" == typeof t) { + var i, + n, + r = Array.prototype.slice.call(arguments, 1); + return ( + (i = + "option" === t && arguments.length > 2 + ? "each" + : -1 !== e.inArray(t, e.TimePicker.methods.chainable) + ? "each" + : "map"), + (n = this[i](function() { + var i = e(this), + n = i.data("TimePicker"); + return "object" == typeof n ? n[t].apply(n, r) : void 0; + })), + "map" === i && 1 === this.length + ? e.makeArray(n).shift() + : "map" === i + ? e.makeArray(n) + : n + ); + } + if (1 === this.length && this.data("TimePicker")) return this.data("TimePicker"); + var a = e.extend({}, e.TimePicker.defaults, t); + return this.each(function() { + e.TimePicker.instance().register(this, a); + }); + }), + (e.fn.timepicker.formatTime = function(e, i) { + var n = i.getHours(), + r = n % 12, + a = i.getMinutes(), + o = i.getSeconds(), + s = { + hh: t((0 === r ? 12 : r).toString(), "0", 2), + HH: t(n.toString(), "0", 2), + mm: t(a.toString(), "0", 2), + ss: t(o.toString(), "0", 2), + h: 0 === r ? 12 : r, + H: n, + m: a, + s: o, + p: n > 11 ? "PM" : "AM" + }, + c = e, + u = ""; + for (u in s) s.hasOwnProperty(u) && (c = c.replace(new RegExp(u, "g"), s[u])); + return (c = c.replace(new RegExp("a", "g"), n > 11 ? "pm" : "am")); + }), + (e.fn.timepicker.parseTime = (function() { + var t = [ + [/^(\d+)$/, "$1"], + [/^:(\d)$/, "$10"], + [/^:(\d+)/, "$1"], + [/^(\d):([7-9])$/, "0$10$2"], + [/^(\d):(\d\d)$/, "$1$2"], + [/^(\d):(\d{1,})$/, "0$1$20"], + [/^(\d\d):([7-9])$/, "$10$2"], + [/^(\d\d):(\d)$/, "$1$20"], + [/^(\d\d):(\d*)$/, "$1$2"], + [/^(\d{3,}):(\d)$/, "$10$2"], + [/^(\d{3,}):(\d{2,})/, "$1$2"], + [/^(\d):(\d):(\d)$/, "0$10$20$3"], + [/^(\d{1,2}):(\d):(\d\d)/, "$10$2$3"] + ], + i = t.length; + return function(r) { + var a = n(new Date()), + o = !1, + s = !1, + c = !1, + u = !1, + l = !1; + if ("undefined" == typeof r || !r.toLowerCase) return null; + (r = r.toLowerCase()), + (o = /a/.test(r)), + (s = o ? !1 : /p/.test(r)), + (r = r.replace(/[^0-9:]/g, "").replace(/:+/g, ":")); + for (var m = 0; i > m; m += 1) + if (t[m][0].test(r)) { + r = r.replace(t[m][0], t[m][1]); + break; + } + return ( + (r = r.replace(/:/g, "")), + 1 === r.length + ? (c = r) + : 2 === r.length + ? (c = r) + : 3 === r.length || 5 === r.length + ? ((c = r.substr(0, 1)), (u = r.substr(1, 2)), (l = r.substr(3, 2))) + : (4 === r.length || r.length > 5) && + ((c = r.substr(0, 2)), (u = r.substr(2, 2)), (l = r.substr(4, 2))), + r.length > 0 && r.length < 5 && (r.length < 3 && (u = 0), (l = 0)), + c === !1 || u === !1 || l === !1 + ? !1 + : ((c = parseInt(c, 10)), + (u = parseInt(u, 10)), + (l = parseInt(l, 10)), + o && 12 === c ? (c = 0) : s && 12 > c && (c += 12), + c > 24 + ? r.length >= 6 + ? e.fn.timepicker.parseTime(r.substr(0, 5)) + : e.fn.timepicker.parseTime(r + "0" + (o ? "a" : "") + (s ? "p" : "")) + : (a.setHours(c, u, l), a)) + ); + }; + })()); + })(); +}); +//# sourceMappingURL=jquery.timepicker.min.js.map diff --git a/client/templates/admin/dashboard/archived_user.html b/imports/ui/components/admin/dashboard/archived_user.html similarity index 100% rename from client/templates/admin/dashboard/archived_user.html rename to imports/ui/components/admin/dashboard/archived_user.html diff --git a/imports/ui/components/admin/dashboard/archived_users.js b/imports/ui/components/admin/dashboard/archived_users.js new file mode 100644 index 00000000..b8a06bab --- /dev/null +++ b/imports/ui/components/admin/dashboard/archived_users.js @@ -0,0 +1,5 @@ +Template.archivedUsers.helpers({ + users: function() { + return ArchivedUsers.find({}, { sort: { archived_at: -1 } }); + } +}); diff --git a/client/templates/admin/dashboard/daily_new_user.html b/imports/ui/components/admin/dashboard/daily_new_user.html similarity index 100% rename from client/templates/admin/dashboard/daily_new_user.html rename to imports/ui/components/admin/dashboard/daily_new_user.html diff --git a/imports/ui/components/admin/dashboard/daily_new_user.js b/imports/ui/components/admin/dashboard/daily_new_user.js new file mode 100644 index 00000000..abb5590e --- /dev/null +++ b/imports/ui/components/admin/dashboard/daily_new_user.js @@ -0,0 +1,11 @@ +Template.dailyNewUser.helpers({ + users: function() { + return Meteor.users.find({ + createdAt: { $gt: new Date(Date.now() - 1 * 24 * 60 * 60 * 1000) } + }); + } +}); + +Template.dailyNewUser.events({ + "click #foo": function(event, template) {} +}); diff --git a/client/templates/admin/dashboard/dashboard.html b/imports/ui/components/admin/dashboard/dashboard.html similarity index 100% rename from client/templates/admin/dashboard/dashboard.html rename to imports/ui/components/admin/dashboard/dashboard.html diff --git a/imports/ui/components/admin/dashboard/dashboard.js b/imports/ui/components/admin/dashboard/dashboard.js new file mode 100644 index 00000000..aa5e1621 --- /dev/null +++ b/imports/ui/components/admin/dashboard/dashboard.js @@ -0,0 +1,21 @@ +Template.dashboard.helpers({ + dailyNewUsersCount: function() { + return ReactiveMethod.call("dailyNewUsersCount"); + }, + monthlyActiveUsersCount: function() { + return ReactiveMethod.call("monthlyActiveUsersCount"); + }, + onlineUserCount: function() { + return ReactiveMethod.call("onlineUserCount"); + }, + blockedUserCount: function() { + return ReactiveMethod.call("blockedUserCount"); + }, + archivedUserCount: function() { + return ReactiveMethod.call("archivedUserCount"); + } +}); + +Template.dashboard.events({ + "click #foo": function(event, template) {} +}); diff --git a/client/templates/admin/dashboard/monthly_active_users.html b/imports/ui/components/admin/dashboard/monthly_active_users.html similarity index 100% rename from client/templates/admin/dashboard/monthly_active_users.html rename to imports/ui/components/admin/dashboard/monthly_active_users.html diff --git a/imports/ui/components/admin/dashboard/monthly_active_users.js b/imports/ui/components/admin/dashboard/monthly_active_users.js new file mode 100644 index 00000000..d01086cb --- /dev/null +++ b/imports/ui/components/admin/dashboard/monthly_active_users.js @@ -0,0 +1,11 @@ +Template.monthlyActiveUsers.helpers({ + users: function() { + return Meteor.users.find({ + "status.lastLogin.date": { $gt: new Date(Date.now() - 30 * 24 * 60 * 60 * 1000) } + }); + } +}); + +Template.monthlyActiveUsers.events({ + "click #foo": function(event, template) {} +}); diff --git a/client/templates/admin/dashboard/online_user.html b/imports/ui/components/admin/dashboard/online_user.html similarity index 100% rename from client/templates/admin/dashboard/online_user.html rename to imports/ui/components/admin/dashboard/online_user.html diff --git a/client/templates/admin/dashboard/online_user.js b/imports/ui/components/admin/dashboard/online_user.js similarity index 65% rename from client/templates/admin/dashboard/online_user.js rename to imports/ui/components/admin/dashboard/online_user.js index ed67e698..259f5377 100644 --- a/client/templates/admin/dashboard/online_user.js +++ b/imports/ui/components/admin/dashboard/online_user.js @@ -1,12 +1,9 @@ - Template.onlineUser.helpers({ - users:function(){ + users: function() { return Meteor.users.find({ "status.online": true }); } }); Template.onlineUser.events({ - "click #foo": function(event, template){ - - } + "click #foo": function(event, template) {} }); diff --git a/client/templates/admin/dashboard/sort_user_as.html b/imports/ui/components/admin/dashboard/sort_user_as.html similarity index 100% rename from client/templates/admin/dashboard/sort_user_as.html rename to imports/ui/components/admin/dashboard/sort_user_as.html diff --git a/client/templates/admin/dashboard/sort_user_as.js b/imports/ui/components/admin/dashboard/sort_user_as.js similarity index 66% rename from client/templates/admin/dashboard/sort_user_as.js rename to imports/ui/components/admin/dashboard/sort_user_as.js index cdf724b3..0a076e37 100644 --- a/client/templates/admin/dashboard/sort_user_as.js +++ b/imports/ui/components/admin/dashboard/sort_user_as.js @@ -1,5 +1,5 @@ -Template.registerHelper("userList", function(argument){ - switch (FlowRouter.getParam('sortUserAs')) { +Template.registerHelper("userList", function(argument) { + switch (FlowRouter.getParam("sortUserAs")) { case "online": return "onlineUser"; break; @@ -13,14 +13,9 @@ Template.registerHelper("userList", function(argument){ return "archivedUsers"; break; default: - } - - }); Template.sortUserAs.events({ - "click #foo": function(event, template){ - - } + "click #foo": function(event, template) {} }); diff --git a/client/templates/admin/inc/has_permission.html b/imports/ui/components/admin/inc/has_permission.html similarity index 100% rename from client/templates/admin/inc/has_permission.html rename to imports/ui/components/admin/inc/has_permission.html diff --git a/imports/ui/components/admin/inc/has_permission.js b/imports/ui/components/admin/inc/has_permission.js new file mode 100644 index 00000000..3fc64bcd --- /dev/null +++ b/imports/ui/components/admin/inc/has_permission.js @@ -0,0 +1,13 @@ +"use strict"; + +Template.hasPermission.helpers({ + target: function() { + var loggedInUserId = Meteor.userId(); + + if (!Roles.userIsInRole(loggedInUserId, ["admin", "moderator"], "CB")) { + return "unauthorised"; + } else { + return this.targetTemplate; + } + } +}); diff --git a/client/templates/admin/inc/loading.html b/imports/ui/components/admin/inc/loading.html similarity index 100% rename from client/templates/admin/inc/loading.html rename to imports/ui/components/admin/inc/loading.html diff --git a/client/templates/admin/inc/single_archived_user.html b/imports/ui/components/admin/inc/single_archived_user.html similarity index 100% rename from client/templates/admin/inc/single_archived_user.html rename to imports/ui/components/admin/inc/single_archived_user.html diff --git a/client/templates/admin/inc/single_user.html b/imports/ui/components/admin/inc/single_user.html similarity index 100% rename from client/templates/admin/inc/single_user.html rename to imports/ui/components/admin/inc/single_user.html diff --git a/client/templates/admin/inc/sys_header.html b/imports/ui/components/admin/inc/sys_header.html similarity index 100% rename from client/templates/admin/inc/sys_header.html rename to imports/ui/components/admin/inc/sys_header.html diff --git a/client/templates/admin/inc/sys_layout.html b/imports/ui/components/admin/inc/sys_layout.html similarity index 100% rename from client/templates/admin/inc/sys_layout.html rename to imports/ui/components/admin/inc/sys_layout.html diff --git a/client/templates/admin/inc/sys_layout.js b/imports/ui/components/admin/inc/sys_layout.js similarity index 80% rename from client/templates/admin/inc/sys_layout.js rename to imports/ui/components/admin/inc/sys_layout.js index 6c909d61..0636b963 100644 --- a/client/templates/admin/inc/sys_layout.js +++ b/imports/ui/components/admin/inc/sys_layout.js @@ -1,8 +1,7 @@ -Template.sysLayout.onCreated(function(){ +Template.sysLayout.onCreated(function() { var title = "administrative area | CodeBuddies "; DocHead.setTitle(title); var user = Meteor.userId(); this.subscribe("allUsers"); this.subscribe("archivedUsers"); - }); diff --git a/client/templates/admin/inc/unauthorised.html b/imports/ui/components/admin/inc/unauthorised.html similarity index 100% rename from client/templates/admin/inc/unauthorised.html rename to imports/ui/components/admin/inc/unauthorised.html diff --git a/client/templates/admin/landing/admin_landing.html b/imports/ui/components/admin/landing/admin_landing.html similarity index 100% rename from client/templates/admin/landing/admin_landing.html rename to imports/ui/components/admin/landing/admin_landing.html diff --git a/client/templates/admin/notification/all_notifications.html b/imports/ui/components/admin/notification/all_notifications.html similarity index 100% rename from client/templates/admin/notification/all_notifications.html rename to imports/ui/components/admin/notification/all_notifications.html diff --git a/imports/ui/components/admin/notification/all_notifications.js b/imports/ui/components/admin/notification/all_notifications.js new file mode 100644 index 00000000..6dd4da88 --- /dev/null +++ b/imports/ui/components/admin/notification/all_notifications.js @@ -0,0 +1,62 @@ +Template.registerHelper("dispDate", function(date) { + return moment(date).format("h:mm a Do MMM 'YY"); +}); + +Template.registerHelper("isActorAdmin", function(actorId) { + return Roles.userIsInRole(actorId, ["admin"], "CB"); +}); + +Template.registerHelper("dispCustomDate", function(date, format) { + return moment(date).format(format); +}); + +Template.allNotification.onCreated(function() { + var instance = this; + instance.flag = new ReactiveVar(false); + instance.limit = new ReactiveVar(10); + instance.autorun(function() { + var limit = instance.limit.get(); + var subscription = instance.subscribe("allNotifications", limit); + }); + + instance.dispNotifications = function() { + return Notifications.find({}, { sort: { createdAt: -1 } }); + }; +}); + +Template.allNotification.onRendered(function() { + var instance = this; + + $("#flux").bind("scroll", function() { + if ($("#flux").scrollTop() + $("#flux").innerHeight() >= $("#flux")[0].scrollHeight) { + if (Notifications.find().count() === instance.limit.get()) { + instance.limit.set(instance.limit.get() + 5); + $("body").addClass("stop-scrolling"); + } else { + if (Notifications.find().count() < instance.limit.get()) { + instance.flag.set(true); + } + } + } + }); +}); + +Template.allNotification.helpers({ + notifications: function() { + return Template.instance().dispNotifications(); + }, + hasBeenSeen: function() { + var userId = Meteor.userId(); + if (userId && !_.include(this.read, userId)) { + return false; + } else { + return true; + } + } +}); + +Template.allNotification.events({ + "click .markAsRead": function(event, template) { + Meteor.call("markAsRead", this._id, function(error, result) {}); + } +}); diff --git a/client/templates/admin/notification/inc/notificationTemplate8.html b/imports/ui/components/admin/notification/inc/notificationTemplate8.html similarity index 100% rename from client/templates/admin/notification/inc/notificationTemplate8.html rename to imports/ui/components/admin/notification/inc/notificationTemplate8.html diff --git a/client/templates/admin/report/report_discussion_modal.html b/imports/ui/components/admin/report/report_discussion_modal.html similarity index 100% rename from client/templates/admin/report/report_discussion_modal.html rename to imports/ui/components/admin/report/report_discussion_modal.html diff --git a/client/templates/admin/report/report_discussion_modal.js b/imports/ui/components/admin/report/report_discussion_modal.js similarity index 100% rename from client/templates/admin/report/report_discussion_modal.js rename to imports/ui/components/admin/report/report_discussion_modal.js diff --git a/client/templates/admin/report/report_hangout_modal.html b/imports/ui/components/admin/report/report_hangout_modal.html similarity index 100% rename from client/templates/admin/report/report_hangout_modal.html rename to imports/ui/components/admin/report/report_hangout_modal.html diff --git a/client/templates/admin/report/report_hangout_modal.js b/imports/ui/components/admin/report/report_hangout_modal.js similarity index 100% rename from client/templates/admin/report/report_hangout_modal.js rename to imports/ui/components/admin/report/report_hangout_modal.js diff --git a/client/templates/admin/user/manage_user.html b/imports/ui/components/admin/user/manage_user.html similarity index 100% rename from client/templates/admin/user/manage_user.html rename to imports/ui/components/admin/user/manage_user.html diff --git a/imports/ui/components/admin/user/manage_user.js b/imports/ui/components/admin/user/manage_user.js new file mode 100644 index 00000000..f69a81bc --- /dev/null +++ b/imports/ui/components/admin/user/manage_user.js @@ -0,0 +1,27 @@ +Template.registerHelper("userSearchQuery", function() { + return Session.get("userSearchQuery"); +}); + +Template.manageUser.helpers({ + searchResults: function() { + return Meteor.users.search(Session.get("userSearchQuery")); + }, + searchMode: function() { + return Session.get("searchMode"); + } +}); + +Template.manageUser.events({ + "keyup #searchBox": function(event, template) { + event.preventDefault(); + //console.log(template.find(".searchTerm").value); + var term = template.find(".searchTerm").value; + if (_.isEmpty(term)) { + Session.set("userSearchQuery", " "); + Session.set("searchMode", false); + } else { + Session.set("searchMode", true); + Session.set("userSearchQuery", term); + } + } +}); diff --git a/client/templates/admin/user/user_by_id.html b/imports/ui/components/admin/user/user_by_id.html similarity index 100% rename from client/templates/admin/user/user_by_id.html rename to imports/ui/components/admin/user/user_by_id.html diff --git a/imports/ui/components/admin/user/user_by_id.js b/imports/ui/components/admin/user/user_by_id.js new file mode 100644 index 00000000..0b890220 --- /dev/null +++ b/imports/ui/components/admin/user/user_by_id.js @@ -0,0 +1,54 @@ +Template.registerHelper("selected", function(key, value) { + return key == value ? "selected" : ""; +}); + +Template.registerHelper("isUpdateable", function(userId, role) { + var loggedInUserId = Meteor.userId(); + + return userId == loggedInUserId || + (role === "moderator" && !Roles.userIsInRole(loggedInUserId, ["admin"], "CB")) + ? true + : false; +}); + +Template.userById.helpers({ + getUser: function() { + var userId = FlowRouter.getParam("userId"); + + if (Roles.userIsInRole(userId, ["admin"], "CB")) { + return; + } else { + return Meteor.users.find({ _id: userId }); + } + }, + userRoles: function() { + const roles = Meteor.users.findOne({ _id: FlowRouter.getParam("userId") }).roles; + const roleGroup = "CB"; + return roles[roleGroup]; + } +}); + +Template.userById.events({ + "change #authorization": function(event, template) { + var currentAuthorization = template.find("#authorization").value; + const roleGroup = "CB"; + var pastAuthorization = this.roles[roleGroup].pop(); + var userId = this._id; + var username = this.username; + Meteor.call( + "updateRoles", + this._id, + this.username, + currentAuthorization, + pastAuthorization, + roleGroup, + function(error, result) { + if (result) { + swal("Done!", "Updated " + username + "'s access right ", "success"); + } else { + swal("Oops something went wrong!", error + "\n Try again", "error"); + } + } + ); + } +}); diff --git a/client/templates/admin/user/users_by_role.html b/imports/ui/components/admin/user/users_by_role.html similarity index 100% rename from client/templates/admin/user/users_by_role.html rename to imports/ui/components/admin/user/users_by_role.html diff --git a/imports/ui/components/admin/user/users_by_role.js b/imports/ui/components/admin/user/users_by_role.js new file mode 100644 index 00000000..6c85cac3 --- /dev/null +++ b/imports/ui/components/admin/user/users_by_role.js @@ -0,0 +1,12 @@ +Template.registerHelper("currentRole", function() { + return FlowRouter.getParam("role"); +}); +Template.usersByRole.helpers({ + users: function() { + return Meteor.users.find({ "roles.CB": FlowRouter.getParam("role") }); + } +}); + +Template.usersByRole.events({ + "click #foo": function(event, template) {} +}); diff --git a/client/templates/availability/availability_slot_local.html b/imports/ui/components/availability/availability_slot_local.html similarity index 100% rename from client/templates/availability/availability_slot_local.html rename to imports/ui/components/availability/availability_slot_local.html diff --git a/imports/ui/components/availability/availability_slot_local.js b/imports/ui/components/availability/availability_slot_local.js new file mode 100644 index 00000000..5478664e --- /dev/null +++ b/imports/ui/components/availability/availability_slot_local.js @@ -0,0 +1,12 @@ +import UHR from "uhr"; + +Template.availabilitySlotLocal.helpers({ + localSlotTime: function() { + const utcSlot = Template.instance().data; + + let localSlot = UHR(utcSlot.d, utcSlot.h, utcSlot.m, -1); + localSlot.hour = localSlot.hour < 10 ? `0${localSlot.hour}` : localSlot.hour; + localSlot.minute = localSlot.minute < 10 ? `0${localSlot.minute}` : localSlot.minute; + return localSlot; + } +}); diff --git a/client/templates/comments/comment_box.html b/imports/ui/components/comments/comment_box.html similarity index 100% rename from client/templates/comments/comment_box.html rename to imports/ui/components/comments/comment_box.html diff --git a/client/templates/comments/comment_box.js b/imports/ui/components/comments/comment_box.js similarity index 98% rename from client/templates/comments/comment_box.js rename to imports/ui/components/comments/comment_box.js index e63cfad3..418942e5 100644 --- a/client/templates/comments/comment_box.js +++ b/imports/ui/components/comments/comment_box.js @@ -115,10 +115,7 @@ Template.commentBox.events({ if (userId && !_.includes(this.upvotes, userId)) { //checking if user has already voted for other category if true then switching if (userId && _.includes(this.downvotes, userId)) { - Meteor.call("voteSwitching", commentId, "downvote-to-upvote", function( - error, - result - ) { + Meteor.call("voteSwitching", commentId, "downvote-to-upvote", function(error, result) { if (error) { console.log("error", error); } @@ -147,10 +144,7 @@ Template.commentBox.events({ if (userId && !_.includes(this.downvotes, userId)) { //checking if user has already voted for other category if true then switching if (userId && _.includes(this.upvotes, userId)) { - Meteor.call("voteSwitching", commentId, "upvote-to-downvote", function( - error, - result - ) { + Meteor.call("voteSwitching", commentId, "upvote-to-downvote", function(error, result) { if (error) { console.log("error", error); } diff --git a/client/templates/comments/comment_item.html b/imports/ui/components/comments/comment_item.html similarity index 100% rename from client/templates/comments/comment_item.html rename to imports/ui/components/comments/comment_item.html diff --git a/client/templates/discussion/add_discussion_modal.html b/imports/ui/components/discussion/add_discussion_modal.html similarity index 100% rename from client/templates/discussion/add_discussion_modal.html rename to imports/ui/components/discussion/add_discussion_modal.html diff --git a/imports/ui/components/discussion/add_discussion_modal.js b/imports/ui/components/discussion/add_discussion_modal.js new file mode 100644 index 00000000..83424752 --- /dev/null +++ b/imports/ui/components/discussion/add_discussion_modal.js @@ -0,0 +1,90 @@ +import discussion_tags from "/imports/data/discussion_tags.js"; +import slack_channels from "/imports/data/slack_channels.js"; + +Template.addDiscussionModal.onCreated(function() { + const instance = this; + instance.processing = new ReactiveVar(false); + instance.discussionDescriptionPreview = new ReactiveVar(""); + console.log(discussion_tags.length); + Meteor.setTimeout(function() { + const tags = discussion_tags; + instance.$(".discussion-tags-multiple", tags).select2({ + placeholder: "Tags (required)", + data: tags, + tags: false, + tokenSeparators: [","], + allowClear: true + }); + + const channels = slack_channels; + instance.$(".slack-channel", channels).select2({ + placeholder: "Channel (optional)", + data: channels, + tags: false, + allowClear: true + }); + }, 500); +}); + +Template.addDiscussionModal.helpers({ + processing: function() { + return Template.instance().processing.get(); + }, + discussionDescriptionPreview: function() { + return Template.instance().discussionDescriptionPreview.get(); + } +}); + +Template.addDiscussionModal.events({ + "change #discussionDescription": function(event, template) { + event.preventDefault(); + template.discussionDescriptionPreview.set( + $.trim(template.find("#discussionDescription").value) + ); + }, + "submit .addDiscussion": function(event, template) { + event.preventDefault(); + + $(".form-control").css({ border: "1px solid #cccccc" }); + + if ($.trim(template.find("#discussionTopic").value) == "") { + $("#discussionTopic").css({ border: "#FF0000 1px solid" }); + return Bert.alert("Topic", "warning", "growl-top-right"); + } + + if (!$(".discussion-tags-multiple").val() || $(".discussion-tags-multiple").val().length < 1) { + return Bert.alert("Please save at least 1 tag. ", "warning", "growl-top-right"); + } + + if ($.trim(template.find("#discussionDescription").value) == "") { + $("#discussionDescription").css({ border: "#FF0000 1px solid" }); + return Bert.alert("Description", "warning", "growl-top-right"); + } + + // console.log(this); + const data = { + topic: $.trim(template.find("#discussionTopic").value), + description: $.trim(template.find("#discussionDescription").value), + groupId: this._id, + groupTitle: this.title, + groupSlug: this.slug, + tags: $(".discussion-tags-multiple").val(), + channel: $(".slack-channel").val() || "#announcements" + }; + + // console.log(data); + template.processing.set(true); + + Meteor.call("discussions.insert", data, function(error, result) { + if (error) { + template.processing.set(false); + Bert.alert(error.reason, "danger", "growl-top-right"); + } + if (result) { + template.processing.set(false); + Bert.alert("Discussion Created!", "success", "growl-top-right"); + Modal.hide(); + } + }); + } +}); diff --git a/client/templates/discussion/all_discussions.html b/imports/ui/components/discussion/all_discussions.html similarity index 100% rename from client/templates/discussion/all_discussions.html rename to imports/ui/components/discussion/all_discussions.html diff --git a/imports/ui/components/discussion/all_discussions.js b/imports/ui/components/discussion/all_discussions.js new file mode 100644 index 00000000..b8dc8fec --- /dev/null +++ b/imports/ui/components/discussion/all_discussions.js @@ -0,0 +1,132 @@ +import _ from "lodash"; + +Template.allDiscussions.onCreated(function() { + const title = "CodeBuddies | Discussions"; + const metaInfo = { + name: "description", + content: + "CodeBuddies is a community of independent code learners who enjoy sharing knowledge and helping each other learn faster. We come from all over the world; there are members living in the United States, Japan, Sweden, the United Kingdom, Russia, Australia, Canada, India, and more. Everyone is welcome, independent of previous knowledge." + }; + + DocHead.setTitle(title); + DocHead.addMeta(metaInfo); + + let instance = this; + instance.limit = new ReactiveVar(10); + instance.flag = new ReactiveVar(false); + instance.tags = new ReactiveVar([]); + instance.discussionFilter = new ReactiveVar("newest"); + + let projection = new Object(); + instance.autorun(function() { + let limit = instance.limit.get(); + + FlowRouter.watchPathChange(); + let queryParams = FlowRouter.current().queryParams; + let tags = []; + instance.tags.set(tags); + if (!_.isEmpty(queryParams)) { + tags = queryParams.tags; + instance.tags.set(tags); + } + + let discussionFilter = instance.discussionFilter.get() || "newest"; + switch (discussionFilter) { + case "newest": + projection.sort = { created_at: -1 }; + break; + case "oldest": + projection.sort = { created_at: 1 }; + break; + case "most-commented": + projection.sort = { response_count: -1 }; + break; + case "least-commented": + projection.sort = { response_count: 1 }; + break; + default: + projection.sort = { created_at: -1 }; + } + + instance.subscribe("allDiscussions", limit, discussionFilter, tags); + }); + + instance.loadDiscussions = function() { + return Discussions.find({}, projection); + }; +}); + +Template.allDiscussions.onRendered(function() { + let instance = this; + + instance.scrollHandler = function() { + if ( + $(window).scrollTop() > $(document).height() - $(window).height() - 20 && + !instance.flag.get() + ) { + if (Discussions.find().count() === instance.limit.get()) { + instance.limit.set(instance.limit.get() + 10); + $("body").addClass("stop-scrolling"); + } else { + if (Discussions.find().count() < instance.limit.get()) { + instance.flag.set(true); + } else { + } + } + } + }.bind(instance); + $(window).on("scroll", instance.scrollHandler); +}); + +Template.allDiscussions.helpers({ + discussions: function() { + return Template.instance().loadDiscussions(); + }, + status: function() { + return Template.instance().flag.get(); + }, + discussionFilter: function() { + return Template.instance().discussionFilter.get(); + }, + discussionSearchMode: function() { + return Session.get("discussionSearchMode"); + }, + tags: function() { + return Template.instance().tags.get(); + } +}); + +Template.allDiscussions.events({ + "click #addDiscussion"(event, template) { + const data = { + _id: "CB", + title: "CB", + slug: "CB" + }; + Modal.show("addDiscussionModal", data); + }, + "click .newest": function(event, template) { + event.preventDefault(); + template.discussionFilter.set("newest"); + }, + "click .oldest": function(event, template) { + event.preventDefault(); + template.discussionFilter.set("oldest"); + }, + "click .most-commented": function(event, template) { + event.preventDefault(); + template.discussionFilter.set("most-commented"); + }, + "click .least-commented": function(event, template) { + event.preventDefault(); + template.discussionFilter.set("least-commented"); + }, + "click .clear-tags": function(event, template) { + event.preventDefault(); + FlowRouter.go("/discussions"); + } +}); + +Template.allDiscussions.onDestroyed(function() { + $(window).off("scroll", this.scrollHandler); +}); diff --git a/client/templates/discussion/discussion.html b/imports/ui/components/discussion/discussion.html similarity index 100% rename from client/templates/discussion/discussion.html rename to imports/ui/components/discussion/discussion.html diff --git a/imports/ui/components/discussion/discussion.js b/imports/ui/components/discussion/discussion.js new file mode 100644 index 00000000..4632e9df --- /dev/null +++ b/imports/ui/components/discussion/discussion.js @@ -0,0 +1,10 @@ +Template.discussion.onCreated(function() { + const instance = this; + instance.subscribe("discussionById", FlowRouter.getParam("discussionId")); +}); + +Template.discussion.helpers({ + discussion() { + return Discussions.findOne({ _id: FlowRouter.getParam("discussionId") }); + } +}); diff --git a/client/templates/discussion/discussion_breadcrumb.html b/imports/ui/components/discussion/discussion_breadcrumb.html similarity index 100% rename from client/templates/discussion/discussion_breadcrumb.html rename to imports/ui/components/discussion/discussion_breadcrumb.html diff --git a/client/templates/discussion/discussion_card.html b/imports/ui/components/discussion/discussion_card.html similarity index 100% rename from client/templates/discussion/discussion_card.html rename to imports/ui/components/discussion/discussion_card.html diff --git a/client/templates/discussion/discussion_card.js b/imports/ui/components/discussion/discussion_card.js similarity index 88% rename from client/templates/discussion/discussion_card.js rename to imports/ui/components/discussion/discussion_card.js index 28dbe88b..0247d786 100644 --- a/client/templates/discussion/discussion_card.js +++ b/imports/ui/components/discussion/discussion_card.js @@ -19,11 +19,7 @@ Template.discussionCard.events({ swal.disableButtons(); if (result.value) { Meteor.call("discussions.remove", data, function(error) { - swal( - "Poof!", - "Your Discussion has been successfully deleted!", - "success" - ); + swal("Poof!", "Your Discussion has been successfully deleted!", "success"); }); } else if ( result.dismiss === "cancel" || @@ -32,12 +28,7 @@ Template.discussionCard.events({ ) { swal("Phew!", "No changes made", "info"); } else { - swal( - "Oops! Something went wrong", - error.error, - +"\n Try again", - "error" - ); + swal("Oops! Something went wrong", error.error, +"\n Try again", "error"); } }); }, diff --git a/client/templates/discussion/discussion_item.html b/imports/ui/components/discussion/discussion_item.html similarity index 100% rename from client/templates/discussion/discussion_item.html rename to imports/ui/components/discussion/discussion_item.html diff --git a/client/templates/discussion/discussion_item.js b/imports/ui/components/discussion/discussion_item.js similarity index 88% rename from client/templates/discussion/discussion_item.js rename to imports/ui/components/discussion/discussion_item.js index a9f518be..59a66b33 100644 --- a/client/templates/discussion/discussion_item.js +++ b/imports/ui/components/discussion/discussion_item.js @@ -19,11 +19,7 @@ Template.discussionItem.events({ swal.disableButtons(); if (result.value) { Meteor.call("discussions.remove", data, function(error) { - swal( - "Poof!", - "Your Discussion has been successfully deleted!", - "success" - ); + swal("Poof!", "Your Discussion has been successfully deleted!", "success"); }); } else if ( result.dismiss === "cancel" || @@ -32,12 +28,7 @@ Template.discussionItem.events({ ) { swal("Phew!", "No changes made", "info"); } else { - swal( - "Oops! Something went wrong", - error.error, - +"\n Try again", - "error" - ); + swal("Oops! Something went wrong", error.error, +"\n Try again", "error"); } }); // sweetAlert2 }, diff --git a/client/templates/discussion/discussion_list.html b/imports/ui/components/discussion/discussion_list.html similarity index 100% rename from client/templates/discussion/discussion_list.html rename to imports/ui/components/discussion/discussion_list.html diff --git a/client/templates/discussion/discussion_list.js b/imports/ui/components/discussion/discussion_list.js similarity index 100% rename from client/templates/discussion/discussion_list.js rename to imports/ui/components/discussion/discussion_list.js diff --git a/client/templates/discussion/discussion_new_response.html b/imports/ui/components/discussion/discussion_new_response.html similarity index 100% rename from client/templates/discussion/discussion_new_response.html rename to imports/ui/components/discussion/discussion_new_response.html diff --git a/imports/ui/components/discussion/discussion_new_response.js b/imports/ui/components/discussion/discussion_new_response.js new file mode 100644 index 00000000..35a9dc5b --- /dev/null +++ b/imports/ui/components/discussion/discussion_new_response.js @@ -0,0 +1,42 @@ +Template.discussionNewResponse.onCreated(function() { + const instance = this; + instance.discussionResponsePreview = new ReactiveVar(""); +}); + +Template.discussionNewResponse.helpers({ + discussionResponsePreview() { + return Template.instance().discussionResponsePreview.get(); + } +}); +Template.discussionNewResponse.events({ + "change #discussionResponse": function(event, template) { + event.preventDefault(); + template.discussionResponsePreview.set($.trim(template.find("#discussionResponse").value)); + }, + "submit .response-form": function(event, template) { + event.preventDefault(); + $(".form-control").css({ border: "1px solid #cccccc" }); + + if ($.trim(template.find("#discussionResponse").value) == "") { + $("#discussionResponse").css({ border: "#FF0000 1px solid" }); + return Bert.alert("Response Can't be empty", "warning", "growl-top-right"); + } + + const data = { + discussion_id: this._id, + parent_id: "empty", + text: $.trim(template.find("#discussionResponse").value) + }; + + Meteor.call("discussionResponses.insert", data, function(error, result) { + if (error) { + console.log("error", error); + } + if (result) { + // clear response box + template.find("#discussionResponse").value = ""; + template.discussionResponsePreview.set(""); + } + }); + } +}); diff --git a/client/templates/discussion/discussion_removed.html b/imports/ui/components/discussion/discussion_removed.html similarity index 100% rename from client/templates/discussion/discussion_removed.html rename to imports/ui/components/discussion/discussion_removed.html diff --git a/client/templates/discussion/discussion_response_card.html b/imports/ui/components/discussion/discussion_response_card.html similarity index 100% rename from client/templates/discussion/discussion_response_card.html rename to imports/ui/components/discussion/discussion_response_card.html diff --git a/client/templates/discussion/discussion_response_card.js b/imports/ui/components/discussion/discussion_response_card.js similarity index 86% rename from client/templates/discussion/discussion_response_card.js rename to imports/ui/components/discussion/discussion_response_card.js index f0c1a1fb..e1cc4a8e 100644 --- a/client/templates/discussion/discussion_response_card.js +++ b/imports/ui/components/discussion/discussion_response_card.js @@ -20,11 +20,7 @@ Template.discussionResponseCard.events({ swal.disableButtons(); if (result.value) { Meteor.call("discussionResponses.remove", data, function(error) { - swal( - "Poof!", - "Your Discussion has been successfully deleted!", - "success" - ); + swal("Poof!", "Your Discussion has been successfully deleted!", "success"); }); } else if ( result.dismiss === "cancel" || @@ -33,12 +29,7 @@ Template.discussionResponseCard.events({ ) { swal("Phew!", "No changes made", "info"); } else { - swal( - "Oops! Something went wrong", - error.error, - +"\n Try again", - "error" - ); + swal("Oops! Something went wrong", error.error, +"\n Try again", "error"); } }); }, diff --git a/client/templates/discussion/discussion_responses_list.html b/imports/ui/components/discussion/discussion_responses_list.html similarity index 100% rename from client/templates/discussion/discussion_responses_list.html rename to imports/ui/components/discussion/discussion_responses_list.html diff --git a/imports/ui/components/discussion/discussion_responses_list.js b/imports/ui/components/discussion/discussion_responses_list.js new file mode 100644 index 00000000..775f9cf0 --- /dev/null +++ b/imports/ui/components/discussion/discussion_responses_list.js @@ -0,0 +1,10 @@ +Template.discussionResponsesList.onCreated(function() { + const instance = this; + instance.subscribe("responsesByDiscussionId", FlowRouter.getParam("discussionId")); +}); + +Template.discussionResponsesList.helpers({ + responses() { + return DiscussionResponses.find({}, { sort: { created_at: 1 } }); + } +}); diff --git a/client/templates/discussion/discussion_search_box.html b/imports/ui/components/discussion/discussion_search_box.html similarity index 100% rename from client/templates/discussion/discussion_search_box.html rename to imports/ui/components/discussion/discussion_search_box.html diff --git a/imports/ui/components/discussion/discussion_search_box.js b/imports/ui/components/discussion/discussion_search_box.js new file mode 100644 index 00000000..cf2b9e29 --- /dev/null +++ b/imports/ui/components/discussion/discussion_search_box.js @@ -0,0 +1,33 @@ +Template.discussionSearchBox.onRendered(function() { + if (Session.get("discussionSearchTerm") !== "") { + $("#discussionSearchBox").val(Session.get("discussionSearchTerm")); + } +}); + +Template.discussionSearchBox.helpers({ + discussionSearchMode: function() { + return Session.get("discussionSearchMode"); + }, + discussionSearchTerm: function() { + return Session.get("discussionSearchTerm"); + } +}); + +Template.discussionSearchBox.events({ + "keyup #discussionSearchBox": function(event, template) { + event.preventDefault(); + const discussionSearchTerm = template.find("#discussionSearchBox").value; + + if (_.isEmpty(discussionSearchTerm)) { + Session.set("discussionSearchTerm", ""); + Session.set("discussionSearchMode", false); + } else { + Session.set("discussionSearchMode", true); + Session.set("discussionSearchTerm", discussionSearchTerm); + } + }, + "click #clearSearch": function(event, template) { + Session.set("discussionSearchTerm", ""); + Session.set("discussionSearchMode", false); + } +}); diff --git a/client/templates/discussion/discussion_search_result.html b/imports/ui/components/discussion/discussion_search_result.html similarity index 100% rename from client/templates/discussion/discussion_search_result.html rename to imports/ui/components/discussion/discussion_search_result.html diff --git a/imports/ui/components/discussion/discussion_search_result.js b/imports/ui/components/discussion/discussion_search_result.js new file mode 100644 index 00000000..8d8d1044 --- /dev/null +++ b/imports/ui/components/discussion/discussion_search_result.js @@ -0,0 +1,16 @@ +Template.discussionSearchResult.onCreated(function() { + this.autorun(() => { + if (!_.isEmpty(Session.get("discussionSearchTerm"))) { + this.subscribe("discussionsSearch", Session.get("discussionSearchTerm")); + } + }); +}); + +Template.discussionSearchResult.helpers({ + discussionSearchTerm() { + return Session.get("discussionSearchTerm"); + }, + searchResults() { + return Discussions.search(Session.get("discussionSearchTerm")); + } +}); diff --git a/client/templates/discussion/discussion_sidebar_notification.html b/imports/ui/components/discussion/discussion_sidebar_notification.html similarity index 100% rename from client/templates/discussion/discussion_sidebar_notification.html rename to imports/ui/components/discussion/discussion_sidebar_notification.html diff --git a/imports/ui/components/discussion/discussion_sidebar_notification.js b/imports/ui/components/discussion/discussion_sidebar_notification.js new file mode 100644 index 00000000..b51b6a9f --- /dev/null +++ b/imports/ui/components/discussion/discussion_sidebar_notification.js @@ -0,0 +1,32 @@ +Template.discussionSidebarNotification.events({ + "click #subscribe": function(event, template) { + event.preventDefault(); + const data = { + id: this._id + }; + + Meteor.call("discussions.subscribe", data, function(error, result) { + if (error) { + Bert.alert(error.reason, "danger", "growl-top-right"); + } + if (result) { + Bert.alert("Subscribed!", "success", "growl-top-right"); + } + }); + }, + "click #unsubscribe": function(event, template) { + event.preventDefault(); + const data = { + id: this._id + }; + + Meteor.call("discussions.unsubscribe", data, function(error, result) { + if (error) { + Bert.alert(error.reason, "danger", "growl-top-right"); + } + if (result) { + Bert.alert("Unsubscribed!", "success", "growl-top-right"); + } + }); + } +}); diff --git a/client/templates/discussion/discussion_sidebar_participant_list.html b/imports/ui/components/discussion/discussion_sidebar_participant_list.html similarity index 100% rename from client/templates/discussion/discussion_sidebar_participant_list.html rename to imports/ui/components/discussion/discussion_sidebar_participant_list.html diff --git a/client/templates/discussion/discussion_sidebar_topics.html b/imports/ui/components/discussion/discussion_sidebar_topics.html similarity index 100% rename from client/templates/discussion/discussion_sidebar_topics.html rename to imports/ui/components/discussion/discussion_sidebar_topics.html diff --git a/imports/ui/components/discussion/discussion_sidebar_topics.js b/imports/ui/components/discussion/discussion_sidebar_topics.js new file mode 100644 index 00000000..9dbb509d --- /dev/null +++ b/imports/ui/components/discussion/discussion_sidebar_topics.js @@ -0,0 +1,37 @@ +Template.discussionSidebarTopic.onCreated(function() { + let instance = this; + instance.activeTopics = new ReactiveVar(0); + instance.recentTopics = new ReactiveVar(0); + + let data = { + type: "active", + id: FlowRouter.getParam("discussionId") + }; + + Meteor.call("discussions.getTopics", data, function(error, result) { + if (error) { + console.log("error", error); + } + if (result) { + instance.activeTopics.set(result); + } + }); + + data.type = "recent"; + Meteor.call("discussions.getTopics", data, function(error, result) { + if (error) { + console.log("error", error); + } + if (result) { + instance.recentTopics.set(result); + } + }); +}); +Template.discussionSidebarTopic.helpers({ + activeTopics: function() { + return Template.instance().activeTopics.get(); + }, + recentTopics: function() { + return Template.instance().recentTopics.get(); + } +}); diff --git a/client/templates/discussion/edit_discussion_modal.html b/imports/ui/components/discussion/edit_discussion_modal.html similarity index 100% rename from client/templates/discussion/edit_discussion_modal.html rename to imports/ui/components/discussion/edit_discussion_modal.html diff --git a/imports/ui/components/discussion/edit_discussion_modal.js b/imports/ui/components/discussion/edit_discussion_modal.js new file mode 100644 index 00000000..93dbee07 --- /dev/null +++ b/imports/ui/components/discussion/edit_discussion_modal.js @@ -0,0 +1,98 @@ +import discussion_tags from "/imports/data/discussion_tags.js"; + +Template.editDiscussionModal.onCreated(function() { + const instance = this; + instance.processing = new ReactiveVar(false); + instance.discussionDescriptionPreview = new ReactiveVar(""); +}); + +Template.editDiscussionModal.onRendered(function() { + const instance = this; + instance.discussionDescriptionPreview.set(instance.data.description); + + let tags = discussion_tags; + + instance.data.tags.forEach(tag => { + if (tags.indexOf(tag) < 0) { + tags.push(tag); + } + }); + + tags = tags.map(tag => { + if (instance.data.tags.indexOf(tag) > -1) { + return { id: tag, text: tag, selected: true }; + } + return { id: tag, text: tag }; + }); + + Meteor.setTimeout(function() { + instance.$(".discussion-tags-multiple", tags).select2({ + placeholder: "Tags (required)", + data: tags, + tags: false, + tokenSeparators: [","], + allowClear: true + }); + }, 500); +}); + +Template.editDiscussionModal.helpers({ + processing: function() { + return Template.instance().processing.get(); + }, + discussionDescriptionPreview: function() { + // console.log(Template.instance().discussionDescriptionPreview.get()); + + return Template.instance().discussionDescriptionPreview.get(); + } +}); + +Template.editDiscussionModal.events({ + "change #discussionDescription": function(event, template) { + event.preventDefault(); + template.discussionDescriptionPreview.set( + $.trim(template.find("#discussionDescription").value) + ); + }, + "submit .editDiscussion": function(event, template) { + event.preventDefault(); + + $(".form-control").css({ border: "1px solid #cccccc" }); + + if ($.trim(template.find("#discussionTopic").value) == "") { + $("#discussionTopic").css({ border: "#FF0000 1px solid" }); + return Bert.alert("Topic", "warning", "growl-top-right"); + } + + if (!$(".discussion-tags-multiple").val() || $(".discussion-tags-multiple").val().length < 1) { + $(".discussion-tags-multiple").css({ border: "#FF0000 1px solid" }); + return Bert.alert("Please save at least 1 tag. ", "warning", "growl-top-right"); + } + + if ($.trim(template.find("#discussionDescription").value) == "") { + $("#discussionDescription").css({ border: "#FF0000 1px solid" }); + return Bert.alert("Description", "warning", "growl-top-right"); + } + + const data = { + id: this._id, + topic: $.trim(template.find("#discussionTopic").value), + description: $.trim(template.find("#discussionDescription").value), + tags: $(".discussion-tags-multiple").val() + }; + + template.processing.set(true); + + Meteor.call("discussions.update", data, function(error, result) { + if (error) { + template.processing.set(false); + Bert.alert(error.reason, "danger", "growl-top-right"); + } + if (result) { + template.processing.set(false); + Bert.alert("Discussion Updated!", "success", "growl-top-right"); + Modal.hide(); + } + }); + } +}); diff --git a/client/templates/discussion/edit_response_modal.html b/imports/ui/components/discussion/edit_response_modal.html similarity index 100% rename from client/templates/discussion/edit_response_modal.html rename to imports/ui/components/discussion/edit_response_modal.html diff --git a/imports/ui/components/discussion/edit_response_modal.js b/imports/ui/components/discussion/edit_response_modal.js new file mode 100644 index 00000000..acec9b01 --- /dev/null +++ b/imports/ui/components/discussion/edit_response_modal.js @@ -0,0 +1,59 @@ +Template.editResponseModal.onCreated(function() { + const instance = this; + instance.processing = new ReactiveVar(false); + instance.discussionResponsePreview = new ReactiveVar(""); +}); + +Template.editResponseModal.onRendered(function() { + const instance = this; + instance.discussionResponsePreview.set(instance.data.text); +}); + +Template.editResponseModal.helpers({ + processing: function() { + return Template.instance().processing.get(); + }, + discussionResponsePreview: function() { + console.log(Template.instance().discussionResponsePreview.get()); + + return Template.instance().discussionResponsePreview.get(); + } +}); + +Template.editResponseModal.events({ + "change #editDiscussionResponse": function(event, template) { + event.preventDefault(); + template.discussionResponsePreview.set($.trim(template.find("#editDiscussionResponse").value)); + }, + "submit .editDiscussion": function(event, template) { + event.preventDefault(); + + $(".form-control").css({ border: "1px solid #cccccc" }); + + if ($.trim(template.find("#editDiscussionResponse").value) == "") { + $("#editDiscussionResponse").css({ border: "#FF0000 1px solid" }); + return Bert.alert("Description", "warning", "growl-top-right"); + } + + // console.log(this); + const data = { + id: this._id, + text: $.trim(template.find("#editDiscussionResponse").value) + }; + + // console.log(data); + template.processing.set(true); + + Meteor.call("discussionResponses.update", data, function(error, result) { + if (error) { + template.processing.set(false); + Bert.alert(error.reason, "danger", "growl-top-right"); + } + if (result) { + template.processing.set(false); + Bert.alert("Responses Updated!", "success", "growl-top-right"); + Modal.hide(); + } + }); + } +}); diff --git a/client/templates/hangout/hangout-clone.html b/imports/ui/components/hangout/hangout-clone.html similarity index 100% rename from client/templates/hangout/hangout-clone.html rename to imports/ui/components/hangout/hangout-clone.html diff --git a/client/templates/hangout/hangout-clone.js b/imports/ui/components/hangout/hangout-clone.js similarity index 99% rename from client/templates/hangout/hangout-clone.js rename to imports/ui/components/hangout/hangout-clone.js index dc3c58d5..9015715b 100644 --- a/client/templates/hangout/hangout-clone.js +++ b/imports/ui/components/hangout/hangout-clone.js @@ -97,9 +97,7 @@ Template.cloneHangoutModal.events({ const end = new Date(startDate.getTime() + 1000 * 60 * duration); const type = $('input[name="hangout-type"]:checked').val(); const groupId = $(".study-group-single").val(); - const externalCheckbox = $('input[name="externalCheckbox"]').prop( - "checked" - ); + const externalCheckbox = $('input[name="externalCheckbox"]').prop("checked"); const externalButtonText = $('input[name="externalButtonText"]').val(); const externalURL = $('input[name="externalURL"]').val(); diff --git a/client/templates/hangout/hangout-edit.html b/imports/ui/components/hangout/hangout-edit.html similarity index 100% rename from client/templates/hangout/hangout-edit.html rename to imports/ui/components/hangout/hangout-edit.html diff --git a/client/templates/hangout/hangout-edit.js b/imports/ui/components/hangout/hangout-edit.js similarity index 98% rename from client/templates/hangout/hangout-edit.js rename to imports/ui/components/hangout/hangout-edit.js index be84104a..1f80fa46 100644 --- a/client/templates/hangout/hangout-edit.js +++ b/imports/ui/components/hangout/hangout-edit.js @@ -46,9 +46,7 @@ Template.editHangoutModal.events({ const duration = Number($("#end-date-time").val()) || 1440; const end = new Date(startDate.getTime() + 1000 * 60 * duration); const type = $('input[name="hangout-type"]:checked').val(); - const externalCheckbox = $('input[name="externalCheckbox"]').prop( - "checked" - ); + const externalCheckbox = $('input[name="externalCheckbox"]').prop("checked"); const externalButtonText = $('input[name="externalButtonText"]').val(); const externalURL = $('input[name="externalURL"]').val(); diff --git a/client/templates/hangout/hangout-frame.html b/imports/ui/components/hangout/hangout-frame.html similarity index 100% rename from client/templates/hangout/hangout-frame.html rename to imports/ui/components/hangout/hangout-frame.html diff --git a/client/templates/hangout/hangout-frame.js b/imports/ui/components/hangout/hangout-frame.js similarity index 90% rename from client/templates/hangout/hangout-frame.js rename to imports/ui/components/hangout/hangout-frame.js index 38b92c44..f17555cb 100644 --- a/client/templates/hangout/hangout-frame.js +++ b/imports/ui/components/hangout/hangout-frame.js @@ -1,8 +1,6 @@ Template.hangoutFrame.onCreated(function() { let instance = this; - instance.room = new ReactiveVar( - `cb${instance.data._id || instance.data.hroom}` - ); + instance.room = new ReactiveVar(`cb${instance.data._id || instance.data.hroom}`); instance.autorun(() => { instance.subscribe("hangoutParticipants", instance.room.get()); @@ -80,10 +78,7 @@ Template.hangoutFrame.onRendered(function() { * Chrome or Firefox */ - if ( - (!!window.chrome && !!window.chrome.webstore) || - typeof InstallTrigger !== "undefined" - ) { + if ((!!window.chrome && !!window.chrome.webstore) || typeof InstallTrigger !== "undefined") { //console.log('using firefox or chrome') $("p.chrome-firefox-warning").hide(); } else { @@ -92,17 +87,14 @@ Template.hangoutFrame.onRendered(function() { } //Google Hangout support - $("head").append( - '' - ); + $("head").append(''); }); Template.hangoutFrame.events({ "click .load-hangout": function(event, template) { const data = { room: this._id || template.data.hroom, - username: - (Meteor.user() && Meteor.user().username) || template.data.huser, + username: (Meteor.user() && Meteor.user().username) || template.data.huser, type: template.data.htype || this.type, avatar: template.data.havatar || Meteor.user().profile.avatar.default }; diff --git a/client/templates/hangout/hangout-item.html b/imports/ui/components/hangout/hangout-item.html similarity index 100% rename from client/templates/hangout/hangout-item.html rename to imports/ui/components/hangout/hangout-item.html diff --git a/client/templates/hangout/hangout-item.js b/imports/ui/components/hangout/hangout-item.js similarity index 100% rename from client/templates/hangout/hangout-item.js rename to imports/ui/components/hangout/hangout-item.js diff --git a/client/templates/hangout/hangout-learned.html b/imports/ui/components/hangout/hangout-learned.html similarity index 100% rename from client/templates/hangout/hangout-learned.html rename to imports/ui/components/hangout/hangout-learned.html diff --git a/client/templates/hangout/hangout-learned.js b/imports/ui/components/hangout/hangout-learned.js similarity index 100% rename from client/templates/hangout/hangout-learned.js rename to imports/ui/components/hangout/hangout-learned.js diff --git a/client/templates/hangout/hangout-learnings.html b/imports/ui/components/hangout/hangout-learnings.html similarity index 100% rename from client/templates/hangout/hangout-learnings.html rename to imports/ui/components/hangout/hangout-learnings.html diff --git a/client/templates/hangout/hangout-learnings.js b/imports/ui/components/hangout/hangout-learnings.js similarity index 55% rename from client/templates/hangout/hangout-learnings.js rename to imports/ui/components/hangout/hangout-learnings.js index 39ddca1c..02ad3d7d 100644 --- a/client/templates/hangout/hangout-learnings.js +++ b/imports/ui/components/hangout/hangout-learnings.js @@ -1,5 +1,4 @@ -Template.hangoutLearnings.onCreated(function () { - +Template.hangoutLearnings.onCreated(function() { // 1. Initialization var instance = this; @@ -9,44 +8,46 @@ Template.hangoutLearnings.onCreated(function () { instance.limit = new ReactiveVar(5); // ... - instance.autorun(function () { - + instance.autorun(function() { // get the limit var limit = instance.limit.get(); - console.log("Asking for "+limit+" learnings...") - var hangoutId = FlowRouter.getParam('hangoutId'); - console.log(hangoutId) + console.log("Asking for " + limit + " learnings..."); + var hangoutId = FlowRouter.getParam("hangoutId"); + console.log(hangoutId); // subscribe to the learningsByHangoutId publication - var subscription = instance.subscribe('learningsByHangoutId', limit, hangoutId); + var subscription = instance.subscribe("learningsByHangoutId", limit, hangoutId); // if subscription is ready, set limit to newLimit if (subscription.ready()) { - console.log("> Received "+limit+" learnings. \n\n") + console.log("> Received " + limit + " learnings. \n\n"); instance.loaded.set(limit); } else { console.log("> Subscription is not ready yet. \n\n"); } }); - instance.learningsForHangout = function() { - return Learnings.find({}, {limit: instance.loaded.get(), sort: {created_at: -1}}); - } - + instance.learningsForHangout = function() { + return Learnings.find({}, { limit: instance.loaded.get(), sort: { created_at: -1 } }); + }; }); Template.hangoutLearnings.helpers({ - // the posts cursor - learnings: function () { + // the posts cursor + learnings: function() { return Template.instance().learningsForHangout(); }, // are there more posts to show? - hasMoreLearnings: function () { - return Template.instance().learningsForHangout().count() >= Template.instance().limit.get(); + hasMoreLearnings: function() { + return ( + Template.instance() + .learningsForHangout() + .count() >= Template.instance().limit.get() + ); } }); Template.hangoutLearnings.events({ - 'click #load-more-learnings': function (event, instance) { + "click #load-more-learnings": function(event, instance) { event.preventDefault(); // get current value for limit, i.e. how many learnings are currently displayed diff --git a/client/templates/hangout/hangout-modal.html b/imports/ui/components/hangout/hangout-modal.html similarity index 100% rename from client/templates/hangout/hangout-modal.html rename to imports/ui/components/hangout/hangout-modal.html diff --git a/client/templates/hangout/hangout-modal.js b/imports/ui/components/hangout/hangout-modal.js similarity index 97% rename from client/templates/hangout/hangout-modal.js rename to imports/ui/components/hangout/hangout-modal.js index f4b2a2cf..c117c541 100644 --- a/client/templates/hangout/hangout-modal.js +++ b/imports/ui/components/hangout/hangout-modal.js @@ -83,10 +83,7 @@ Template.createHangoutModal.onRendered(function() { data: studyGroups }); - if ( - typeof instance.studyGroupId !== "undefined" && - instance.studyGroupId !== "" - ) { + if (typeof instance.studyGroupId !== "undefined" && instance.studyGroupId !== "") { instance .$(".study-group-single") .val(instance.studyGroupId) @@ -113,9 +110,7 @@ Template.createHangoutModal.events({ const duration = Number($("#end-date-time").val()) || 1440; const end = new Date(startDate.getTime() + 1000 * 60 * duration); const groupId = $(".study-group-single").val(); - const externalCheckbox = $('input[name="externalCheckbox"]').prop( - "checked" - ); + const externalCheckbox = $('input[name="externalCheckbox"]').prop("checked"); const externalButtonText = $('input[name="externalButtonText"]').val(); const externalURL = $('input[name="externalURL"]').val(); diff --git a/client/templates/hangout/hangout.html b/imports/ui/components/hangout/hangout.html similarity index 100% rename from client/templates/hangout/hangout.html rename to imports/ui/components/hangout/hangout.html diff --git a/client/templates/hangout/hangout.js b/imports/ui/components/hangout/hangout.js similarity index 95% rename from client/templates/hangout/hangout.js rename to imports/ui/components/hangout/hangout.js index 69c7d2ad..f055ea39 100644 --- a/client/templates/hangout/hangout.js +++ b/imports/ui/components/hangout/hangout.js @@ -1,9 +1,7 @@ import QuillEditor from "../../libs/QuillEditor"; Meteor.startup(function() { - $("head").append( - '' - ); + $("head").append(''); //$('head').append(''); }); diff --git a/client/templates/hangout/hangout_action_bar.html b/imports/ui/components/hangout/hangout_action_bar.html similarity index 100% rename from client/templates/hangout/hangout_action_bar.html rename to imports/ui/components/hangout/hangout_action_bar.html diff --git a/client/templates/hangout/hangout_action_bar.js b/imports/ui/components/hangout/hangout_action_bar.js similarity index 82% rename from client/templates/hangout/hangout_action_bar.js rename to imports/ui/components/hangout/hangout_action_bar.js index 01a295b8..1e8060d6 100644 --- a/client/templates/hangout/hangout_action_bar.js +++ b/imports/ui/components/hangout/hangout_action_bar.js @@ -18,23 +18,16 @@ Template.hangoutActionBar.events({ "checked", hangout.data.externalCheckbox ); - $("#clone-hangout-modal #externalButtonText").val( - hangout.data.externalButtonText - ); + $("#clone-hangout-modal #externalButtonText").val(hangout.data.externalButtonText); $("#clone-hangout-modal #externalURL").val(hangout.data.externalURL); $("#clone-hangout-modal #topic").val(hangout.data.topic); - $("#clone-hangout-modal input[value=" + hangout.data.type + "]").prop( - "checked", - true - ); + $("#clone-hangout-modal input[value=" + hangout.data.type + "]").prop("checked", true); } }, "click .edit-hangout": function(e, hangout) { //console.log(hangout.data.topic); //pass in the right times like 03/09/2016 2:03 AM - var start_time_reverted = moment(hangout.data.start).format( - "MM/DD/YYYY h:mm A" - ); + var start_time_reverted = moment(hangout.data.start).format("MM/DD/YYYY h:mm A"); var hangoutDuration = hangout.data.duration; //var end_time_reverted = moment(hangout.data.end).format('MM/DD/YYYY h:mm A'); @@ -54,21 +47,13 @@ Template.hangoutActionBar.events({ //console.log(editor_content.html()); Modal.show("editHangoutModal", { hangout }); - $("#edit-hangout-modal input#external-checkbox").prop( - "checked", - hangout.data.externalCheckbox - ); - $("#edit-hangout-modal #externalButtonText").val( - hangout.data.externalButtonText - ); + $("#edit-hangout-modal input#external-checkbox").prop("checked", hangout.data.externalCheckbox); + $("#edit-hangout-modal #externalButtonText").val(hangout.data.externalButtonText); $("#edit-hangout-modal #externalURL").val(hangout.data.externalURL); $("#edit-hangout-modal #topic").val(hangout.data.topic); // $('#edit-hangout-modal #description').val(hangout.data.description); // templateInstance.editor.setContents(hangout.data.description); - $("#edit-hangout-modal input[value=" + hangout.data.type + "]").prop( - "checked", - true - ); + $("#edit-hangout-modal input[value=" + hangout.data.type + "]").prop("checked", true); $("#edit-hangout-modal #start-date-time").val(start_time_reverted); $("#edit-hangout-modal #end-date-time").val(hangoutDuration); $("#edit-hangout-modal #group").val(hangout.data.group.title); @@ -95,11 +80,7 @@ Template.hangoutActionBar.events({ swal.disableButtons(); if (result.value) { Meteor.call("deleteHangout", data, function(error) { - swal( - "Poof!", - "Your hangout has been successfully deleted!", - "success" - ); + swal("Poof!", "Your hangout has been successfully deleted!", "success"); }); } else if ( result.dismiss === "cancel" || @@ -108,12 +89,7 @@ Template.hangoutActionBar.events({ ) { swal("Phew!", "No changes made", "info"); } else { - swal( - "Oops! Something went wrong", - error.error, - +"\n Try again", - "error" - ); + swal("Oops! Something went wrong", error.error, +"\n Try again", "error"); } }); //sweetAlert 2 } diff --git a/client/templates/hangout/hangout_action_buttons.html b/imports/ui/components/hangout/hangout_action_buttons.html similarity index 100% rename from client/templates/hangout/hangout_action_buttons.html rename to imports/ui/components/hangout/hangout_action_buttons.html diff --git a/client/templates/hangout/hangout_action_buttons.js b/imports/ui/components/hangout/hangout_action_buttons.js similarity index 83% rename from client/templates/hangout/hangout_action_buttons.js rename to imports/ui/components/hangout/hangout_action_buttons.js index c587f8bd..2b23a85f 100644 --- a/client/templates/hangout/hangout_action_buttons.js +++ b/imports/ui/components/hangout/hangout_action_buttons.js @@ -3,29 +3,16 @@ import QuillEditor from "../../libs/QuillEditor"; Template.hangoutActionButtons.helpers({ icsDownloadLink: function(hangout) { const nowDate = new Date(); - const startDate = Blaze._globalHelpers.getHangoutGoogleCalendarDate( - hangout.start - ); - const startTime = Blaze._globalHelpers.getHangoutGoogleCalendarTime( - hangout.start - ); - const endDate = Blaze._globalHelpers.getHangoutGoogleCalendarDate( - hangout.end - ); - const endTime = Blaze._globalHelpers.getHangoutGoogleCalendarTime( - hangout.end - ); - const currentDate = Blaze._globalHelpers.getHangoutGoogleCalendarDate( - nowDate - ); - const currentTime = Blaze._globalHelpers.getHangoutGoogleCalendarTime( - nowDate - ); + const startDate = Blaze._globalHelpers.getHangoutGoogleCalendarDate(hangout.start); + const startTime = Blaze._globalHelpers.getHangoutGoogleCalendarTime(hangout.start); + const endDate = Blaze._globalHelpers.getHangoutGoogleCalendarDate(hangout.end); + const endTime = Blaze._globalHelpers.getHangoutGoogleCalendarTime(hangout.end); + const currentDate = Blaze._globalHelpers.getHangoutGoogleCalendarDate(nowDate); + const currentTime = Blaze._globalHelpers.getHangoutGoogleCalendarTime(nowDate); const start = `${startDate}T${startTime}`; const end = `${endDate}T${endTime}`; const current = `${currentDate}T${currentTime}`; - const SEPARATOR = - navigator.appVersion.indexOf("Win") !== -1 ? "\r\n" : "\n"; + const SEPARATOR = navigator.appVersion.indexOf("Win") !== -1 ? "\r\n" : "\n"; let topic = hangout.topic; const group = (hangout && hangout.group) || null; @@ -49,9 +36,7 @@ Template.hangoutActionButtons.helpers({ "END:VEVENT" ].join(SEPARATOR); const calendarEvent = `BEGIN:VCALENDAR${SEPARATOR}PRODID:Calendar${SEPARATOR}VERSION:2.0${SEPARATOR}${calendarDetails}${SEPARATOR}END:VCALENDAR`; - return `data:text/calendar;charset=utf8,${encodeURIComponent( - calendarEvent - )}`; + return `data:text/calendar;charset=utf8,${encodeURIComponent(calendarEvent)}`; }, googleCalendarUrl: function(hangout) { const { _id: id, topic, description, group, start, end } = hangout; @@ -79,23 +64,16 @@ Template.hangoutActionButtons.events({ "checked", hangout.data.externalCheckbox ); - $("#clone-hangout-modal #externalButtonText").val( - hangout.data.externalButtonText - ); + $("#clone-hangout-modal #externalButtonText").val(hangout.data.externalButtonText); $("#clone-hangout-modal #externalURL").val(hangout.data.externalURL); $("#clone-hangout-modal #topic").val(hangout.data.topic); - $("#clone-hangout-modal input[value=" + hangout.data.type + "]").prop( - "checked", - true - ); + $("#clone-hangout-modal input[value=" + hangout.data.type + "]").prop("checked", true); } }, "click .edit-hangout": function(e, hangout) { //console.log(hangout.data.topic); //pass in the right times like 03/09/2016 2:03 AM - var start_time_reverted = moment(hangout.data.start).format( - "MM/DD/YYYY h:mm A" - ); + var start_time_reverted = moment(hangout.data.start).format("MM/DD/YYYY h:mm A"); var hangoutDuration = hangout.data.duration; //var end_time_reverted = moment(hangout.data.end).format('MM/DD/YYYY h:mm A'); @@ -118,17 +96,9 @@ Template.hangoutActionButtons.events({ $("#edit-hangout-modal #topic").val(hangout.data.topic); // $('#edit-hangout-modal #description').val(hangout.data.description); // templateInstance.editor.setContents(hangout.data.description); - $("#edit-hangout-modal input[value=" + hangout.data.type + "]").prop( - "checked", - true - ); - $("#edit-hangout-modal input#external-checkbox").prop( - "checked", - hangout.data.externalCheckbox - ); - $("#edit-hangout-modal #externalButtonText").val( - hangout.data.externalButtonText - ); + $("#edit-hangout-modal input[value=" + hangout.data.type + "]").prop("checked", true); + $("#edit-hangout-modal input#external-checkbox").prop("checked", hangout.data.externalCheckbox); + $("#edit-hangout-modal #externalButtonText").val(hangout.data.externalButtonText); $("#edit-hangout-modal #externalURL").val(hangout.data.externalURL); $("#edit-hangout-modal #start-date-time").val(start_time_reverted); $("#edit-hangout-modal #end-date-time").val(hangoutDuration); @@ -157,11 +127,7 @@ Template.hangoutActionButtons.events({ if (result.value) { Meteor.call("deleteHangout", data, function(error) { - swal( - "Poof!", - "Your hangout has been successfully deleted!", - "success" - ); + swal("Poof!", "Your hangout has been successfully deleted!", "success"); }); } else if ( result.dismiss === "cancel" || @@ -170,12 +136,7 @@ Template.hangoutActionButtons.events({ ) { swal("Phew!", "No changes made", "info"); } else { - swal( - "Oops! Something went wrong", - error.error, - +"\n Try again", - "error" - ); + swal("Oops! Something went wrong", error.error, +"\n Try again", "error"); } }); //sweetAlert }, @@ -199,11 +160,7 @@ Template.hangoutActionButtons.events({ swal.disableButtons(); if (result.value) { Meteor.call("endHangout", data, function(error) { - swal( - "Poof!", - "Your hangout has been successfully deleted!", - "success" - ); + swal("Poof!", "Your hangout has been successfully deleted!", "success"); }); } else if ( result.dismiss === "cancel" || @@ -212,12 +169,7 @@ Template.hangoutActionButtons.events({ ) { swal("Phew!", "No changes made", "info"); } else { - swal( - "Oops! Something went wrong", - error.error, - +"\n Try again", - "error" - ); + swal("Oops! Something went wrong", error.error, +"\n Try again", "error"); } }); //sweetAlert 2 } diff --git a/client/templates/hangout/hangout_card.html b/imports/ui/components/hangout/hangout_card.html similarity index 100% rename from client/templates/hangout/hangout_card.html rename to imports/ui/components/hangout/hangout_card.html diff --git a/client/templates/hangout/hangout_card.js b/imports/ui/components/hangout/hangout_card.js similarity index 100% rename from client/templates/hangout/hangout_card.js rename to imports/ui/components/hangout/hangout_card.js diff --git a/client/templates/hangout/hangout_cards.html b/imports/ui/components/hangout/hangout_cards.html similarity index 100% rename from client/templates/hangout/hangout_cards.html rename to imports/ui/components/hangout/hangout_cards.html diff --git a/imports/ui/components/hangout/hangout_cards.js b/imports/ui/components/hangout/hangout_cards.js new file mode 100644 index 00000000..694bb509 --- /dev/null +++ b/imports/ui/components/hangout/hangout_cards.js @@ -0,0 +1,56 @@ +Template.hangoutCards.onCreated(function() { + var instance = this; + instance.limit = new ReactiveVar(12); + instance.flag = new ReactiveVar(false); + + instance.autorun(function() { + var limit = instance.limit.get(); + instance.subscribe("hangouts", limit); + }); + + var instance = this; + + instance.loadHangouts = function(flag = 1) { + return Hangouts.find({}, { sort: { start: flag } }); + }; + + const now = new Date(); + instance.liveHangoutsCount = function() { + return Hangouts.find({ end: { $gte: now } }).count() || 0; + }; + + instance.pastHangoutsCount = function() { + return Hangouts.find({ end: { $lt: now } }).count() || 0; + }; + + instance.addMoreHangouts = function() { + if (Hangouts.find().count() === instance.limit.get()) { + instance.limit.set(instance.limit.get() + 9); + } else { + if (Hangouts.find().count() < instance.limit.get()) { + instance.flag.set(true); + } + } + }; +}); + +Template.hangoutCards.helpers({ + hangouts: function(flag) { + return Template.instance().loadHangouts(flag); + }, + status: function() { + return Template.instance().flag.get(); + }, + liveHangoutsCount: function() { + return Template.instance().liveHangoutsCount(); + }, + pastHangoutsCount: function() { + return Template.instance().pastHangoutsCount(); + } +}); + +Template.hangoutCards.events({ + "click #loadMore": function(event, template) { + template.addMoreHangouts(); + } +}); diff --git a/client/templates/hangout/hangout_sidebar_alternatives.html b/imports/ui/components/hangout/hangout_sidebar_alternatives.html similarity index 100% rename from client/templates/hangout/hangout_sidebar_alternatives.html rename to imports/ui/components/hangout/hangout_sidebar_alternatives.html diff --git a/client/templates/hangout/hangout_sidebar_tips.html b/imports/ui/components/hangout/hangout_sidebar_tips.html similarity index 100% rename from client/templates/hangout/hangout_sidebar_tips.html rename to imports/ui/components/hangout/hangout_sidebar_tips.html diff --git a/client/templates/hangout/support_hangout_organizer.html b/imports/ui/components/hangout/support_hangout_organizer.html similarity index 100% rename from client/templates/hangout/support_hangout_organizer.html rename to imports/ui/components/hangout/support_hangout_organizer.html diff --git a/client/templates/hangout/support_hangout_organizer.js b/imports/ui/components/hangout/support_hangout_organizer.js similarity index 100% rename from client/templates/hangout/support_hangout_organizer.js rename to imports/ui/components/hangout/support_hangout_organizer.js diff --git a/client/templates/home/footer.html b/imports/ui/components/home/footer.html similarity index 100% rename from client/templates/home/footer.html rename to imports/ui/components/home/footer.html diff --git a/imports/ui/components/home/footer.js b/imports/ui/components/home/footer.js new file mode 100644 index 00000000..0dcee39b --- /dev/null +++ b/imports/ui/components/home/footer.js @@ -0,0 +1,46 @@ +Template.footer.helpers({ + languageSwitchers: function() { + const supportedLanguages = TAPi18n.getLanguages(); + const currentLanguageCode = TAPi18n.getLanguage(); + return Object.keys(supportedLanguages).map(function(languageCode) { + return { + name: supportedLanguages[languageCode].name, + attributes: { + "data-lang": "", + "data-lang-code": languageCode, + "data-lang-name": supportedLanguages[languageCode].name, + class: languageCode === currentLanguageCode ? "selected_language" : "" + } + }; + }); + } +}); + +Template.footer.events({ + "click [data-lang]": function(event, template) { + event.preventDefault(); + const languageCode = event.target.dataset.langCode; + const languageName = event.target.dataset.langName; + if (languageCode === TAPi18n.getLanguage()) return; + + TAPi18n.setLanguage(languageCode) + .done(() => { + Bert.alert( + TAPi18n.__("alert_language_change", `${languageName} (${languageCode})`), + "success", + "growl-top-right" + ); + }) + .fail(error => { + Bert.alert( + TAPi18n.__("alert_language_change_fail", `${languageName} (${languageCode})`), + "danger", + "growl-top-right" + ); + console.log(error); + }) + .always(() => { + localStorage.setItem("languageCode", TAPi18n.getLanguage()); + }); + } +}); diff --git a/client/templates/home/hangout-tips.html b/imports/ui/components/home/hangout-tips.html similarity index 100% rename from client/templates/home/hangout-tips.html rename to imports/ui/components/home/hangout-tips.html diff --git a/client/templates/home/home.html b/imports/ui/components/home/home.html similarity index 100% rename from client/templates/home/home.html rename to imports/ui/components/home/home.html diff --git a/imports/ui/components/home/home.js b/imports/ui/components/home/home.js new file mode 100644 index 00000000..f10199a3 --- /dev/null +++ b/imports/ui/components/home/home.js @@ -0,0 +1,11 @@ +import "./home.html"; +Template.home.onCreated(function() { + var title = "CodeBuddies | Home"; + var metaInfo = { + name: "description", + content: + "We're a community learning code via a Slack chatroom, a Facebook Group, and peer-to-peer organized screensharing/pair-programming hangouts. Learning with others helps us learn faster. The project is free, open-sourced, and 100% community-built." + }; + DocHead.setTitle(title); + DocHead.addMeta(metaInfo); +}); diff --git a/client/templates/home/home_logged_in.html b/imports/ui/components/home/home_logged_in.html similarity index 100% rename from client/templates/home/home_logged_in.html rename to imports/ui/components/home/home_logged_in.html diff --git a/imports/ui/components/home/home_logged_in.js b/imports/ui/components/home/home_logged_in.js new file mode 100644 index 00000000..bdc6eb9f --- /dev/null +++ b/imports/ui/components/home/home_logged_in.js @@ -0,0 +1,60 @@ +Template.homeLoggedIn.onCreated(function() { + var title = "CodeBuddies | Home"; + var metaInfo = { + name: "description", + content: + "We're a community learning code via a Slack chatroom, a Facebook Group, and peer-to-peer organized screensharing/pair-programming hangouts. Learning with others helps us learn faster. The project is free, open-sourced, and 100% community-built." + }; + DocHead.setTitle(title); + DocHead.addMeta(metaInfo); + + this.autorun(() => { + this.subscribe("userStatus"); + if (!_.isEmpty(Session.get("hangoutSearchTerm"))) { + this.subscribe("hangoutSearch", Session.get("hangoutSearchTerm")); + } + }); +}); + +Template.homeLoggedIn.helpers({ + userCount: function() { + var totalUsers = Session.get("userCount"); + //console.log(totalUsers); + return totalUsers; + }, + searchResults: function() { + return Hangouts.search(Session.get("hangoutSearchTerm")); + }, + hangoutSearchTerm() { + return Session.get("hangoutSearchTerm"); + }, + hangoutSearchMode() { + // console.log(Session.get('hangoutSearchMode')); + return Session.get("hangoutSearchMode"); + } +}); + +Template.homeLoggedIn.events({ + "keyup #searchBox": function(event, template) { + event.preventDefault(); + // console.log(template.find(".searchTerm").value); + var term = template.find(".searchTerm").value; + if (_.isEmpty(term)) { + Session.set("hangoutSearchTerm", ""); + Session.set("hangoutSearchMode", false); + } else { + Session.set("hangoutSearchMode", true); + Session.set("hangoutSearchTerm", term); + } + }, + "click .create-hangout-popup": function() { + Modal.show("createHangoutModal"); + }, + "click #hangout-faq-popup": function() { + Modal.show("hangoutFAQModal"); + }, + "click #clearSearch": function(event, template) { + Session.set("hangoutSearchTerm", ""); + Session.set("hangoutSearchMode", false); + } +}); diff --git a/client/templates/home/home_logged_out.html b/imports/ui/components/home/home_logged_out.html similarity index 100% rename from client/templates/home/home_logged_out.html rename to imports/ui/components/home/home_logged_out.html diff --git a/client/templates/home/home_logged_out.js b/imports/ui/components/home/home_logged_out.js similarity index 91% rename from client/templates/home/home_logged_out.js rename to imports/ui/components/home/home_logged_out.js index 51d57953..c9919e05 100644 --- a/client/templates/home/home_logged_out.js +++ b/imports/ui/components/home/home_logged_out.js @@ -1,3 +1,5 @@ +import "./home_logged_out.html"; + Template.homeLoggedOut.onCreated(function() { var title = "CodeBuddies | Home"; var metaInfo = { @@ -17,12 +19,7 @@ Template.homeLoggedOut.onCreated(function() { if (error) { console.log(error); } else { - const { - studyGroupCount = 0, - discussionCount = 0, - learningsCount = 0, - hangoutsCount = 0 - } = + const { studyGroupCount = 0, discussionCount = 0, learningsCount = 0, hangoutsCount = 0 } = result || {}; console.log(studyGroupCount); diff --git a/client/templates/members/member-status.html b/imports/ui/components/members/member-status.html similarity index 100% rename from client/templates/members/member-status.html rename to imports/ui/components/members/member-status.html diff --git a/client/templates/members/member-status.js b/imports/ui/components/members/member-status.js similarity index 97% rename from client/templates/members/member-status.js rename to imports/ui/components/members/member-status.js index 939dd670..913fab10 100644 --- a/client/templates/members/member-status.js +++ b/imports/ui/components/members/member-status.js @@ -38,10 +38,7 @@ Template.memberStatus.events({ study_group_id: FlowRouter.getParam("studyGroupId") }; - Meteor.call("updateUserStatusForStudyGroup", data, function( - error, - result - ) { + Meteor.call("updateUserStatusForStudyGroup", data, function(error, result) { if (error) { console.log(error); return Bert.alert(error.reason, "danger", "growl-top-right"); diff --git a/client/templates/nav/header.html b/imports/ui/components/nav/header.html similarity index 100% rename from client/templates/nav/header.html rename to imports/ui/components/nav/header.html diff --git a/imports/ui/components/nav/header.js b/imports/ui/components/nav/header.js new file mode 100644 index 00000000..990b4e02 --- /dev/null +++ b/imports/ui/components/nav/header.js @@ -0,0 +1,56 @@ +import "./header.html"; +Template.header.onRendered(function() { + this.subscribe("attendees", 10); +}); +Template.header.helpers({ + user: function() { + return Meteor.user(); + }, + notificationCount: function() { + return ReactiveMethod.call("notificationCount"); + }, + userNotificationCount: function() { + return RSVPnotifications.find({ createorId: Meteor.userId(), seen: false }).count(); + } +}); + +Template.header.events({ + "click .signInSlack": function(event) { + var options = { + requestPermissions: ["identity.basic", "identity.email"] + }; + Meteor.loginWithSlack(options, function() { + FlowRouter.go("hangouts"); + }); + }, + "click #signOut": function(event) { + Meteor.logout(function(err) { + FlowRouter.go("home"); + }); + }, + "click #newHangout": function(event) { + Modal.show("createHangoutModal"); + }, + "click #newStudyGroup": function(event) { + Modal.show("newStudyGroupModal"); + }, + "click #newDiscussion"(event, template) { + const data = { + _id: "CB", + title: "CB", + slug: "CB" + }; + + Modal.show("addDiscussionModal", data); + }, + "click .signInGithub": function(event) { + var options = { + requestPermissions: ["read:user", "user:email"] + }; + Meteor.loginWithGithub(options, function(err) { + if (!err) { + FlowRouter.go("hangouts"); + } + }); + } +}); diff --git a/client/templates/other/about.html b/imports/ui/components/other/about.html similarity index 100% rename from client/templates/other/about.html rename to imports/ui/components/other/about.html diff --git a/imports/ui/components/other/about.js b/imports/ui/components/other/about.js new file mode 100644 index 00000000..8735e635 --- /dev/null +++ b/imports/ui/components/other/about.js @@ -0,0 +1,51 @@ +import flags from "/imports/data/flags.json"; +import c from "/imports/data/contributors.json"; + +Template.about.onCreated(function() { + var title = "CodeBuddies | About"; + var metaInfo = { + name: "description", + content: + "Our community spends a lot of time helping each other on Slack, but it's hard to schedule study times in advance in a chatroom, and it's also hard to know who else is online possibly working on the same thing at the same time. This website solves those issues." + }; + DocHead.setTitle(title); + DocHead.addMeta(metaInfo); +}); + +Template.about.onRendered(function() { + $(function() { + // Move to the top of the page on render + var $window = $(window); + if ($window.scrollTop() > 0) { + $window.scrollTop(0); + } + + //$('a.user-popover').popover({ trigger: "hover", html: "true" }); + $("a.user-popover").each(function() { + var $elem = $(this); + $elem.popover({ + placement: "top", + trigger: "hover", + html: true, + container: $elem, + animation: false, + title: "Name goes here", + content: "This is the popover content. You should be able to mouse over HERE." + }); + }); + + // display fallback image if image url of contributor is broken + $("img.img-circle").on("error", function() { + $(this).prop("src", "/images/unknown.png"); + }); + }); +}); + +Template.about.helpers({ + countries: function() { + return flags.countries; + }, + contributors: function() { + return c.contributors; + } +}); diff --git a/client/templates/other/content-not-found.html b/imports/ui/components/other/content-not-found.html similarity index 100% rename from client/templates/other/content-not-found.html rename to imports/ui/components/other/content-not-found.html diff --git a/client/templates/other/coworking.html b/imports/ui/components/other/coworking.html similarity index 100% rename from client/templates/other/coworking.html rename to imports/ui/components/other/coworking.html diff --git a/client/templates/other/coworking.js b/imports/ui/components/other/coworking.js similarity index 100% rename from client/templates/other/coworking.js rename to imports/ui/components/other/coworking.js diff --git a/client/templates/other/faq.html b/imports/ui/components/other/faq.html similarity index 100% rename from client/templates/other/faq.html rename to imports/ui/components/other/faq.html diff --git a/imports/ui/components/other/faq.js b/imports/ui/components/other/faq.js new file mode 100644 index 00000000..e7f29805 --- /dev/null +++ b/imports/ui/components/other/faq.js @@ -0,0 +1,21 @@ +Template.faq.onCreated(function() { + var title = "CodeBuddies | Home"; + var metaInfo = { + name: "description", + content: + "CodeBuddies is a community of independent code learners who enjoy sharing knowledge and helping each other learn faster. We come from all over the world; there are members living in the United States, Japan, Sweden, the United Kingdom, Russia, Australia, Canada, India, and more. Everyone is welcome, independent of previous knowledge." + }; + DocHead.setTitle(title); + DocHead.addMeta(metaInfo); + DocHead.setTitle("CodeBuddies | FAQ"); +}); + +Template.faq.onRendered(function() { + $(function() { + // Move to the top of the page on render + var $window = $(window); + if ($window.scrollTop() > 0) { + $window.scrollTop(0); + } + }); +}); diff --git a/client/templates/other/goodbye.html b/imports/ui/components/other/goodbye.html similarity index 100% rename from client/templates/other/goodbye.html rename to imports/ui/components/other/goodbye.html diff --git a/client/templates/other/goodbye.js b/imports/ui/components/other/goodbye.js similarity index 63% rename from client/templates/other/goodbye.js rename to imports/ui/components/other/goodbye.js index d665ffff..bec90e56 100644 --- a/client/templates/other/goodbye.js +++ b/imports/ui/components/other/goodbye.js @@ -1,4 +1,4 @@ -Template.goodbye.onCreated(function(){ +Template.goodbye.onCreated(function() { var title = "CodeBuddies | Goodbye"; DocHead.setTitle(title); }); diff --git a/client/templates/other/hangout-faq.html b/imports/ui/components/other/hangout-faq.html similarity index 100% rename from client/templates/other/hangout-faq.html rename to imports/ui/components/other/hangout-faq.html diff --git a/imports/ui/components/other/hangout-faq.js b/imports/ui/components/other/hangout-faq.js new file mode 100644 index 00000000..194bf3a1 --- /dev/null +++ b/imports/ui/components/other/hangout-faq.js @@ -0,0 +1,21 @@ +Template.hangoutFAQModal.onCreated(function() { + var title = "CodeBuddies | Home"; + var metaInfo = { + name: "description", + content: + "CodeBuddies is a community of independent code learners who enjoy sharing knowledge and helping each other learn faster. We come from all over the world; there are members living in the United States, Japan, Sweden, the United Kingdom, Russia, Australia, Canada, India, and more. Everyone is welcome, independent of previous knowledge." + }; + DocHead.setTitle(title); + DocHead.addMeta(metaInfo); + DocHead.setTitle("CodeBuddies | Hangout FAQ"); +}); + +Template.hangoutFAQModal.onRendered(function() { + $(function() { + let currentUrl = window.location.href; + if (currentUrl.indexOf("hangout-faq") > -1) { + $("#hangout-faq-modal").removeClass("modal fade"); + $(".modal-header button").hide(); + } + }); +}); diff --git a/client/templates/other/has_blocked.html b/imports/ui/components/other/has_blocked.html similarity index 100% rename from client/templates/other/has_blocked.html rename to imports/ui/components/other/has_blocked.html diff --git a/imports/ui/components/other/has_blocked.js b/imports/ui/components/other/has_blocked.js new file mode 100644 index 00000000..9c309a46 --- /dev/null +++ b/imports/ui/components/other/has_blocked.js @@ -0,0 +1,22 @@ +import "./has_blocked.html"; +("use strict"); + +import "../../pages/users/basic_user_information"; + +Template.hasBlocked.helpers({ + target: function() { + let loggedInUser = Meteor.user(); + if (Roles.userIsInRole(loggedInUser, "inactive", "CB")) { + return "suspended"; + } else { + if ( + loggedInUser && + loggedInUser.profile.hasOwnProperty("complete") && + !loggedInUser.profile.complete + ) { + return "basicUserInformation"; + } + return this.targetTemplate; + } + } +}); diff --git a/client/templates/other/learning.html b/imports/ui/components/other/learning.html similarity index 100% rename from client/templates/other/learning.html rename to imports/ui/components/other/learning.html diff --git a/client/templates/other/page-not-found.html b/imports/ui/components/other/page-not-found.html similarity index 100% rename from client/templates/other/page-not-found.html rename to imports/ui/components/other/page-not-found.html diff --git a/client/templates/other/page-not-found.js b/imports/ui/components/other/page-not-found.js similarity index 59% rename from client/templates/other/page-not-found.js rename to imports/ui/components/other/page-not-found.js index 6e3088c4..40cf9067 100644 --- a/client/templates/other/page-not-found.js +++ b/imports/ui/components/other/page-not-found.js @@ -1,4 +1,4 @@ -Template.pageNotFound.onCreated(function(){ +Template.pageNotFound.onCreated(function() { var title = "CodeBuddies | 404"; DocHead.setTitle(title); }); diff --git a/client/templates/other/privacy-agreement.html b/imports/ui/components/other/privacy-agreement.html similarity index 100% rename from client/templates/other/privacy-agreement.html rename to imports/ui/components/other/privacy-agreement.html diff --git a/client/templates/other/privacy-agreement.js b/imports/ui/components/other/privacy-agreement.js similarity index 100% rename from client/templates/other/privacy-agreement.js rename to imports/ui/components/other/privacy-agreement.js diff --git a/client/templates/other/privacy.html b/imports/ui/components/other/privacy.html similarity index 100% rename from client/templates/other/privacy.html rename to imports/ui/components/other/privacy.html diff --git a/client/templates/other/privacy.js b/imports/ui/components/other/privacy.js similarity index 99% rename from client/templates/other/privacy.js rename to imports/ui/components/other/privacy.js index d5154cea..1346250c 100644 --- a/client/templates/other/privacy.js +++ b/imports/ui/components/other/privacy.js @@ -1,6 +1,5 @@ Template.privacyPolicy.onRendered(function() { $(function() { - // Move to the top of the page on render var $window = $(window); if ($window.scrollTop() > 0) { diff --git a/client/templates/other/slack.html b/imports/ui/components/other/slack.html similarity index 100% rename from client/templates/other/slack.html rename to imports/ui/components/other/slack.html diff --git a/client/templates/other/slack.js b/imports/ui/components/other/slack.js similarity index 76% rename from client/templates/other/slack.js rename to imports/ui/components/other/slack.js index 484e8601..8e3a85f2 100644 --- a/client/templates/other/slack.js +++ b/imports/ui/components/other/slack.js @@ -1,13 +1,12 @@ -Template.slack.onCreated(function(){ +Template.slack.onCreated(function() { var title = "CodeBuddies | Slack"; - var metaInfo = {name: "description", content: ""}; + var metaInfo = { name: "description", content: "" }; DocHead.setTitle(title); DocHead.addMeta(metaInfo); }); Template.slack.onRendered(function() { $(function() { - // Move to the top of the page on render var $window = $(window); if ($window.scrollTop() > 0) { diff --git a/client/templates/other/sponsor-us.html b/imports/ui/components/other/sponsor-us.html similarity index 100% rename from client/templates/other/sponsor-us.html rename to imports/ui/components/other/sponsor-us.html diff --git a/imports/ui/components/other/sponsor-us.js b/imports/ui/components/other/sponsor-us.js new file mode 100644 index 00000000..ec55d5cf --- /dev/null +++ b/imports/ui/components/other/sponsor-us.js @@ -0,0 +1 @@ +Template.sponsorUs.onCreated(function() {}); diff --git a/client/templates/other/suspended.html b/imports/ui/components/other/suspended.html similarity index 100% rename from client/templates/other/suspended.html rename to imports/ui/components/other/suspended.html diff --git a/client/templates/other/terms-of-service.html b/imports/ui/components/other/terms-of-service.html similarity index 100% rename from client/templates/other/terms-of-service.html rename to imports/ui/components/other/terms-of-service.html diff --git a/imports/ui/components/other/termsOfService.js b/imports/ui/components/other/termsOfService.js new file mode 100644 index 00000000..4e97ff62 --- /dev/null +++ b/imports/ui/components/other/termsOfService.js @@ -0,0 +1,11 @@ +Template.termsOfService.onCreated(function() { + var title = "CodeBuddies | Terms of Service"; + var metaInfo = { + name: "description", + content: + "CodeBuddies is a community of independent code learners who enjoy sharing knowledge and helping each other learn faster. We come from all over the world; there are members living in the United States, Japan, Sweden, the United Kingdom, Russia, Australia, Canada, India, and more. Everyone is welcome, independent of previous knowledge." + }; + + DocHead.setTitle(title); + DocHead.addMeta(metaInfo); +}); diff --git a/client/templates/other/welcome.html b/imports/ui/components/other/welcome.html similarity index 100% rename from client/templates/other/welcome.html rename to imports/ui/components/other/welcome.html diff --git a/client/templates/profile/profile-edit/profile-edit.html b/imports/ui/components/profile/profile-edit/profile-edit.html similarity index 100% rename from client/templates/profile/profile-edit/profile-edit.html rename to imports/ui/components/profile/profile-edit/profile-edit.html diff --git a/client/templates/profile/profile-edit/profile-edit.js b/imports/ui/components/profile/profile-edit/profile-edit.js similarity index 100% rename from client/templates/profile/profile-edit/profile-edit.js rename to imports/ui/components/profile/profile-edit/profile-edit.js diff --git a/client/templates/profile/profile-hangouts-joined/profile-hangouts-joined.html b/imports/ui/components/profile/profile-hangouts-joined/profile-hangouts-joined.html similarity index 100% rename from client/templates/profile/profile-hangouts-joined/profile-hangouts-joined.html rename to imports/ui/components/profile/profile-hangouts-joined/profile-hangouts-joined.html diff --git a/imports/ui/components/profile/profile-hangouts-joined/profile-hangouts-joined.js b/imports/ui/components/profile/profile-hangouts-joined/profile-hangouts-joined.js new file mode 100644 index 00000000..389bd50f --- /dev/null +++ b/imports/ui/components/profile/profile-hangouts-joined/profile-hangouts-joined.js @@ -0,0 +1,53 @@ +import _ from "lodash"; + +Template.hangoutsJoined.onCreated(function() { + var instance = this; + instance.limit = new ReactiveVar(5); + instance.flag = new ReactiveVar(false); + + instance.autorun(function() { + var limit = instance.limit.get(); + var userId = FlowRouter.getParam("userId"); + instance.subscribe("hangoutsJoined", limit, userId); + }); +}); + +Template.hangoutsJoined.onRendered(function() { + var instance = this; + + instance.loadHangouts = function() { + var userId = FlowRouter.getParam("userId"); + var arr = Hangouts.find() + .fetch() + .reverse(); + var userHangouts = _.filter(arr, function(elem) { + return elem.users.includes(userId); + }); + return userHangouts; + }; + + instance.addMoreHangouts = function() { + if (Hangouts.find().count() === instance.limit.get()) { + instance.limit.set(instance.limit.get() + 8); + } else { + if (Hangouts.find().count() < instance.limit.get()) { + instance.flag.set(true); + } + } + }; +}); + +Template.hangoutsJoined.helpers({ + hangouts: function() { + return Template.instance().loadHangouts(); + }, + status: function() { + return Template.instance().flag.get(); + } +}); + +Template.hangoutsJoined.events({ + "click #loadMore": function(event, template) { + template.addMoreHangouts(); + } +}); diff --git a/client/templates/profile/profile-learnings/profile-learnings.html b/imports/ui/components/profile/profile-learnings/profile-learnings.html similarity index 100% rename from client/templates/profile/profile-learnings/profile-learnings.html rename to imports/ui/components/profile/profile-learnings/profile-learnings.html diff --git a/client/templates/profile/profile-learnings/profile-learnings.js b/imports/ui/components/profile/profile-learnings/profile-learnings.js similarity index 56% rename from client/templates/profile/profile-learnings/profile-learnings.js rename to imports/ui/components/profile/profile-learnings/profile-learnings.js index de46904d..71403536 100644 --- a/client/templates/profile/profile-learnings/profile-learnings.js +++ b/imports/ui/components/profile/profile-learnings/profile-learnings.js @@ -1,5 +1,4 @@ -Template.profileLearnings.onCreated(function () { - +Template.profileLearnings.onCreated(function() { // 1. Initialization var instance = this; @@ -9,46 +8,48 @@ Template.profileLearnings.onCreated(function () { instance.limit = new ReactiveVar(5); // ... - instance.autorun(function () { - + instance.autorun(function() { // get the limit var limit = instance.limit.get(); - console.log("Asking for "+limit+" learnings...") - var userId = FlowRouter.getParam('userId'); - console.log(userId) + console.log("Asking for " + limit + " learnings..."); + var userId = FlowRouter.getParam("userId"); + console.log(userId); // subscribe to the learningsByUserId publication - var subscription = instance.subscribe('learningsByUserId', limit, userId); + var subscription = instance.subscribe("learningsByUserId", limit, userId); console.log(subscription); // if subscription is ready, set limit to newLimit if (subscription.ready()) { - console.log("> Received "+limit+" learnings. \n\n") + console.log("> Received " + limit + " learnings. \n\n"); instance.loaded.set(limit); } else { console.log("> Subscription is not ready yet. \n\n"); } }); - instance.learningsForUser = function() { - return Learnings.find({}, {limit: instance.loaded.get(), sort: {created_at: -1}}); - } - + instance.learningsForUser = function() { + return Learnings.find({}, { limit: instance.loaded.get(), sort: { created_at: -1 } }); + }; }); Template.profileLearnings.helpers({ - // the posts cursor - learnings: function () { + // the posts cursor + learnings: function() { return Template.instance().learningsForUser(); }, // are there more posts to show? - hasMoreLearnings: function () { - return Template.instance().learningsForUser().count() >= Template.instance().limit.get(); + hasMoreLearnings: function() { + return ( + Template.instance() + .learningsForUser() + .count() >= Template.instance().limit.get() + ); } }); Template.profileLearnings.events({ - 'click #load-more-learnings': function (event, instance) { + "click #load-more-learnings": function(event, instance) { event.preventDefault(); // get current value for limit, i.e. how many learnings are currently displayed diff --git a/client/templates/profile/profile.html b/imports/ui/components/profile/profile.html similarity index 100% rename from client/templates/profile/profile.html rename to imports/ui/components/profile/profile.html diff --git a/client/templates/profile/profile.js b/imports/ui/components/profile/profile.js similarity index 100% rename from client/templates/profile/profile.js rename to imports/ui/components/profile/profile.js diff --git a/client/templates/resources/resources_list.html b/imports/ui/components/resources/resources_list.html similarity index 100% rename from client/templates/resources/resources_list.html rename to imports/ui/components/resources/resources_list.html diff --git a/client/templates/resources/resources_list.js b/imports/ui/components/resources/resources_list.js similarity index 55% rename from client/templates/resources/resources_list.js rename to imports/ui/components/resources/resources_list.js index 3bb51835..f4ea0ab8 100644 --- a/client/templates/resources/resources_list.js +++ b/imports/ui/components/resources/resources_list.js @@ -1,11 +1,10 @@ Template.resourcesList.onCreated(function() { - this.subscribe('resourcesByStudyGroup', FlowRouter.getParam('studyGroupId')); + this.subscribe("resourcesByStudyGroup", FlowRouter.getParam("studyGroupId")); }); Template.resourcesList.helpers({ - resources: function(){ + resources: function() { return Resources.find(); - } }); @@ -13,11 +12,11 @@ Template.resourcesList.events({ "click .delete-resource": function(event, template) { Meteor.call("deleteResource", this._id, function(error, result) { if (error) { - Bert.alert( error.reason, 'danger', 'growl-top-right' ); + Bert.alert(error.reason, "danger", "growl-top-right"); } - if(result){ - Bert.alert( 'Link removed', 'success', 'growl-top-right' ); + if (result) { + Bert.alert("Link removed", "success", "growl-top-right"); } }); - }, + } }); diff --git a/client/templates/settings/delete_my_account_modal.html b/imports/ui/components/settings/delete_my_account_modal.html similarity index 100% rename from client/templates/settings/delete_my_account_modal.html rename to imports/ui/components/settings/delete_my_account_modal.html diff --git a/client/templates/settings/delete_my_account_modal.js b/imports/ui/components/settings/delete_my_account_modal.js similarity index 82% rename from client/templates/settings/delete_my_account_modal.js rename to imports/ui/components/settings/delete_my_account_modal.js index bd8407e4..acd4d8dd 100644 --- a/client/templates/settings/delete_my_account_modal.js +++ b/imports/ui/components/settings/delete_my_account_modal.js @@ -2,10 +2,7 @@ Template.deleteMyAccountModal.events({ "click #delete": function(event, template) { event.preventDefault(); //console.log(template.find('input:radio[name="reasonForDeletingAccount"]:checked').value); - if ( - template.find('input:radio[name="reasonForDeletingAccount"]:checked') === - null - ) { + if (template.find('input:radio[name="reasonForDeletingAccount"]:checked') === null) { swal({ title: TAPi18n.__("Please select your reason for leaving"), confirmButtonText: TAPi18n.__("ok"), @@ -13,9 +10,7 @@ Template.deleteMyAccountModal.events({ }); return; } - const reason = template.find( - 'input:radio[name="reasonForDeletingAccount"]:checked' - ).value; + const reason = template.find('input:radio[name="reasonForDeletingAccount"]:checked').value; const detail = template.find("#detail").value; if ($.trim(reason) == "other" && $.trim(detail) == "") { diff --git a/client/templates/settings/unsubscribe_from_mailing_list.html b/imports/ui/components/settings/unsubscribe_from_mailing_list.html similarity index 100% rename from client/templates/settings/unsubscribe_from_mailing_list.html rename to imports/ui/components/settings/unsubscribe_from_mailing_list.html diff --git a/client/templates/settings/unsubscribe_from_mailing_list.js b/imports/ui/components/settings/unsubscribe_from_mailing_list.js similarity index 89% rename from client/templates/settings/unsubscribe_from_mailing_list.js rename to imports/ui/components/settings/unsubscribe_from_mailing_list.js index 82c046f6..5a0c98a5 100644 --- a/client/templates/settings/unsubscribe_from_mailing_list.js +++ b/imports/ui/components/settings/unsubscribe_from_mailing_list.js @@ -1,13 +1,10 @@ // import { ReactiveVar } from 'meteor/reactive-var'; -import { UnsubscribeLinks } from "../../../imports/api/unsubscribe_links/unsubscribe_links"; +import { UnsubscribeLinks } from "../../../api/unsubscribe_links/unsubscribe_links"; Template.unsubscribeFromMailingList.onCreated(function() { const instance = this; instance.processing = new ReactiveVar(false); instance.list = new ReactiveVar([]); - instance.subscribe( - "unsubscribe.link", - FlowRouter.getParam("unsubscribeLinkId") - ); + instance.subscribe("unsubscribe.link", FlowRouter.getParam("unsubscribeLinkId")); Meteor.call( "users.getEmailPreferences", diff --git a/client/templates/settings/user_account_settings.html b/imports/ui/components/settings/user_account_settings.html similarity index 100% rename from client/templates/settings/user_account_settings.html rename to imports/ui/components/settings/user_account_settings.html diff --git a/imports/ui/components/settings/user_account_settings.js b/imports/ui/components/settings/user_account_settings.js new file mode 100644 index 00000000..c8213044 --- /dev/null +++ b/imports/ui/components/settings/user_account_settings.js @@ -0,0 +1,66 @@ +Template.userAccountSettings.onCreated(function() { + let instance = this; + const title = "CodeBuddies | User Account Settings"; + DocHead.setTitle(title); + + // instance.flag = new ReactiveVar(false); + instance.emails_preference = new ReactiveVar([]); + instance.selected_emails_preference = new ReactiveVar([]); +}); + +Template.userAccountSettings.onRendered(function() { + let instance = this; + + instance.autorun(function() { + const emails_preference = Meteor.user() && Meteor.user().emails_preference; + if (emails_preference) { + instance.emails_preference.set(emails_preference); + } + }); +}); + +Template.userAccountSettings.helpers({ + emails_preference() { + return Template.instance().emails_preference.get(); + }, + preferences_modified() { + const emails_preference = Template.instance().emails_preference.get(); + const selected_emails_preference = Template.instance().selected_emails_preference.get(); + return ( + JSON.stringify(emails_preference.sort()) === JSON.stringify(selected_emails_preference.sort()) + ); + } +}); + +Template.userAccountSettings.events({ + "click #deleteMyAccount": function(event, template) { + Modal.show("deleteMyAccountModal"); + }, + 'change [name="email_preference"]': function(event, template) { + const selected_emails_preference = template.findAll("input[name=email_preference]:checked"); + let results = selected_emails_preference.map(item => { + return item.defaultValue; + }); + + template.selected_emails_preference.set(results); + }, + "click #updateEmailsPreference": function(event, template) { + const selected_emails_preference = template.findAll("input[name=email_preference]:checked"); + let results = selected_emails_preference.map(item => { + return item.defaultValue; + }); + + const data = { + emails_preference: results + }; + + Meteor.call("updateEmailsPreference", data, function(error, result) { + if (error) { + return Bert.alert(error.reason, "danger", "growl-top-right"); + } + if (result) { + return Bert.alert("Your preferences is updated!", "success", "growl-top-right"); + } + }); + } +}); diff --git a/client/templates/status/learning-edit.html b/imports/ui/components/status/learning-edit.html similarity index 100% rename from client/templates/status/learning-edit.html rename to imports/ui/components/status/learning-edit.html diff --git a/client/templates/status/learning-edit.js b/imports/ui/components/status/learning-edit.js similarity index 100% rename from client/templates/status/learning-edit.js rename to imports/ui/components/status/learning-edit.js diff --git a/client/templates/status/learning-item.html b/imports/ui/components/status/learning-item.html similarity index 100% rename from client/templates/status/learning-item.html rename to imports/ui/components/status/learning-item.html diff --git a/client/templates/status/learning-item.js b/imports/ui/components/status/learning-item.js similarity index 92% rename from client/templates/status/learning-item.js rename to imports/ui/components/status/learning-item.js index cc09b4ee..332dcc3b 100644 --- a/client/templates/status/learning-item.js +++ b/imports/ui/components/status/learning-item.js @@ -54,9 +54,7 @@ Template.learningItem.events({ }).then(result => { console.log(result); if (result.value) { - Meteor.call("deleteLearning", learningId, Meteor.userId(), function( - error - ) { + Meteor.call("deleteLearning", learningId, Meteor.userId(), function(error) { swal("Poof!", "Your learning was deleted!", "success"); }); } else if ( @@ -66,12 +64,7 @@ Template.learningItem.events({ ) { swal("Phew!", "No changes made", "info"); } else { - swal( - "Oops! Something went wrong", - error.error, - +"\n Try again", - "error" - ); + swal("Oops! Something went wrong", error.error, +"\n Try again", "error"); } }); } diff --git a/client/templates/status/status-item.html b/imports/ui/components/status/status-item.html similarity index 100% rename from client/templates/status/status-item.html rename to imports/ui/components/status/status-item.html diff --git a/imports/ui/components/status/status-item.js b/imports/ui/components/status/status-item.js new file mode 100644 index 00000000..c1dce9ad --- /dev/null +++ b/imports/ui/components/status/status-item.js @@ -0,0 +1,13 @@ +Template.statusItem.helpers({ + hangoutStatus: function() { + if (this.statusHangout == "silent") return "fa-microphone-slash"; + else if (this.statusHangout == "teaching") return "fa-user"; + else if (this.statusHangout == "collaboration") return "fa-users"; + else return "fa-microphone-slash"; + }, + logged_in_using_codebuddies_team: function() { + if (!(Meteor.loggingIn() || Meteor.userId())) { + return Meteor.user().profile.team_id === Meteor.settings.team_id; + } + } +}); diff --git a/client/templates/status/status-list.html b/imports/ui/components/status/status-list.html similarity index 100% rename from client/templates/status/status-list.html rename to imports/ui/components/status/status-list.html diff --git a/client/templates/status/status-list.js b/imports/ui/components/status/status-list.js similarity index 72% rename from client/templates/status/status-list.js rename to imports/ui/components/status/status-list.js index 0f7ca8e4..7f781d9c 100644 --- a/client/templates/status/status-list.js +++ b/imports/ui/components/status/status-list.js @@ -12,7 +12,7 @@ Template.statusList.onCreated(function() { //console.log("Asking for "+limit+" learnings…") // subscribe to the posts publication - var subscription = instance.subscribe('learnings', limit); + var subscription = instance.subscribe("learnings", limit); // if subscription is ready, set limit to newLimit if (subscription.ready()) { @@ -23,9 +23,9 @@ Template.statusList.onCreated(function() { } // get total number of learnings - Meteor.call('getTotalNumberOfLearnings', function(error, result) { + Meteor.call("getTotalNumberOfLearnings", function(error, result) { if (error) { - console.log('error', error); + console.log("error", error); } if (result) { instance.totalNumberOfLearnings.set(result); @@ -33,21 +33,18 @@ Template.statusList.onCreated(function() { }); }); instance.learnings = function() { - return Learnings.find( - {}, - { limit: instance.loaded.get(), sort: { created_at: -1 } }, - ); + return Learnings.find({}, { limit: instance.loaded.get(), sort: { created_at: -1 } }); }; }); Template.statusList.helpers({ usersOnlineCount: function() { - return Meteor.users.find({ 'status.online': true }).count(); + return Meteor.users.find({ "status.online": true }).count(); }, usersOnline: function() { - return Meteor.users.find({ 'status.online': true }); + return Meteor.users.find({ "status.online": true }); }, isWorking: function(type) { - return type == 'working'; + return type == "working"; }, learnedUsersCount: function() { return Template.instance().totalNumberOfLearnings.get(); @@ -62,11 +59,11 @@ Template.statusList.helpers({ .learnings() .count() >= Template.instance().limit.get() ); - }, + } }); Template.statusList.events({ - 'click #load-more-learnings': function(event, instance) { + "click #load-more-learnings": function(event, instance) { event.preventDefault(); // get current value for limit, i.e. how many posts are currently displayed @@ -76,16 +73,16 @@ Template.statusList.events({ limit += 5; instance.limit.set(limit); }, - 'click .signIn': function(event) { + "click .signIn": function(event) { var options = { - requestPermissions: ['identity.basic', 'identity.email'], + requestPermissions: ["identity.basic", "identity.email"] }; Meteor.loginWithSlack(options); }, - 'click .signInGithub': function(event) { + "click .signInGithub": function(event) { var options = { - requestPermissions: ['read:user', 'user:email'], + requestPermissions: ["read:user", "user:email"] }; Meteor.loginWithGithub(options); - }, + } }); diff --git a/client/templates/status/update-status.html b/imports/ui/components/status/update-status.html similarity index 100% rename from client/templates/status/update-status.html rename to imports/ui/components/status/update-status.html diff --git a/client/templates/status/update-status.js b/imports/ui/components/status/update-status.js similarity index 100% rename from client/templates/status/update-status.js rename to imports/ui/components/status/update-status.js diff --git a/client/templates/study_groups/all_study_groups.html b/imports/ui/components/study_groups/all_study_groups.html similarity index 100% rename from client/templates/study_groups/all_study_groups.html rename to imports/ui/components/study_groups/all_study_groups.html diff --git a/client/templates/study_groups/all_study_groups.js b/imports/ui/components/study_groups/all_study_groups.js similarity index 91% rename from client/templates/study_groups/all_study_groups.js rename to imports/ui/components/study_groups/all_study_groups.js index 84145753..9d3095b1 100644 --- a/client/templates/study_groups/all_study_groups.js +++ b/imports/ui/components/study_groups/all_study_groups.js @@ -19,9 +19,7 @@ Template.allStudyGroups.onCreated(function() { let studyGroupsFilter = instance.studyGroupsFilter.get(); instance.subscribe("allStudyGroups", limit, studyGroupsFilter); - const hangoutIds = StudyGroups.find({}, { fields: { _id: 1 } }).map( - x => `cb${x._id}` - ); + const hangoutIds = StudyGroups.find({}, { fields: { _id: 1 } }).map(x => `cb${x._id}`); instance.subscribe("allHangoutParticipants", hangoutIds); }); @@ -86,11 +84,7 @@ Template.allStudyGroups.events({ return Bert.alert(error.reason, "danger", "growl-top-right"); } if (result) { - return Bert.alert( - "You have left the study group!", - "success", - "growl-top-right" - ); + return Bert.alert("You have left the study group!", "success", "growl-top-right"); } }); }, @@ -108,11 +102,7 @@ Template.allStudyGroups.events({ return Bert.alert(error.reason, "danger", "growl-top-right"); } if (result) { - return Bert.alert( - "You have joined the study group!", - "success", - "growl-top-right" - ); + return Bert.alert("You have joined the study group!", "success", "growl-top-right"); } }); } diff --git a/client/templates/study_groups/all_study_groups_homepage.html b/imports/ui/components/study_groups/all_study_groups_homepage.html similarity index 100% rename from client/templates/study_groups/all_study_groups_homepage.html rename to imports/ui/components/study_groups/all_study_groups_homepage.html diff --git a/client/templates/study_groups/edit_study_group_availability_slot_modal.html b/imports/ui/components/study_groups/edit_study_group_availability_slot_modal.html similarity index 100% rename from client/templates/study_groups/edit_study_group_availability_slot_modal.html rename to imports/ui/components/study_groups/edit_study_group_availability_slot_modal.html diff --git a/client/templates/study_groups/edit_study_group_availability_slot_modal.js b/imports/ui/components/study_groups/edit_study_group_availability_slot_modal.js similarity index 55% rename from client/templates/study_groups/edit_study_group_availability_slot_modal.js rename to imports/ui/components/study_groups/edit_study_group_availability_slot_modal.js index 6e36cd75..a93161ef 100644 --- a/client/templates/study_groups/edit_study_group_availability_slot_modal.js +++ b/imports/ui/components/study_groups/edit_study_group_availability_slot_modal.js @@ -1,46 +1,45 @@ -import UHR from 'uhr'; +import UHR from "uhr"; -Template.editStudyGroupAvailabilitySlotModal.onCreated(function () { +Template.editStudyGroupAvailabilitySlotModal.onCreated(function() { let instance = this; instance.processing = new ReactiveVar(false); - }); -getHour = (slot) =>{ +getHour = slot => { return Number(slot.slice(0, -3)); -} +}; -getMinute = (slot, hour) =>{ - return Number(slot.slice(`${hour}`.length + 1, slot.length )); -} +getMinute = (slot, hour) => { + return Number(slot.slice(`${hour}`.length + 1, slot.length)); +}; -Template.editStudyGroupAvailabilitySlotModal.onRendered(function(){ +Template.editStudyGroupAvailabilitySlotModal.onRendered(function() { let instance = this; - instance.$('.timepicker').timepicker({ - timeFormat: 'H:mm', - interval: 60, - minTime: '00:00', - maxTime: '23:59', - defaultTime: '0', - startTime: '00:00', - dynamic: false, - dropdown: true, - scrollbar: true, - zindex: 99999999 + instance.$(".timepicker").timepicker({ + timeFormat: "H:mm", + interval: 60, + minTime: "00:00", + maxTime: "23:59", + defaultTime: "0", + startTime: "00:00", + dynamic: false, + dropdown: true, + scrollbar: true, + zindex: 99999999 }); }); Template.editStudyGroupAvailabilitySlotModal.helpers({ processing() { - return Template.instance().processing.get(); + return Template.instance().processing.get(); } }); Template.editStudyGroupAvailabilitySlotModal.events({ - "submit .updateStudyAvailabilityGroupSlot": function(event, template){ + "submit .updateStudyAvailabilityGroupSlot": function(event, template) { event.preventDefault(); - $('.timepicker').css({ "border": '1px solid #cccccc'}); + $(".timepicker").css({ border: "1px solid #cccccc" }); const day = Number(template.find("#availabilityDay").value); @@ -50,18 +49,17 @@ Template.editStudyGroupAvailabilitySlotModal.events({ const startHour = getHour(slotStartTime); const endHour = getHour(slotEndTime); - const startMinute = getMinute(slotStartTime, startHour) - const endMinute = getMinute(slotEndTime, endHour) + const startMinute = getMinute(slotStartTime, startHour); + const endMinute = getMinute(slotEndTime, endHour); if (startHour == endHour && startMinute >= endMinute) { - return $('.end-time').css({ 'border': '#FF0000 1px solid'}); + return $(".end-time").css({ border: "#FF0000 1px solid" }); } if (startHour > endHour) { - return $('.end-time').css({ 'border': '#FF0000 1px solid'}); + return $(".end-time").css({ border: "#FF0000 1px solid" }); } - const utcStartSlot = UHR(day, startHour, startMinute, 1); const utcEndSlot = UHR(day, endHour, endMinute, 1); @@ -76,22 +74,21 @@ Template.editStudyGroupAvailabilitySlotModal.events({ endHour: utcEndSlot.hour, endMinute: utcEndSlot.minute, userTimeZoneOffsetInHours: new Date().getTimezoneOffset() / 60 - } + }; // console.log(data); - template.processing.set( true ); + template.processing.set(true); - Meteor.call("addAvailabilitySlot", data, function(error, result){ - if(error){ - template.processing.set( false ); - Bert.alert( error.reason, 'danger', 'growl-top-right' ); + Meteor.call("addAvailabilitySlot", data, function(error, result) { + if (error) { + template.processing.set(false); + Bert.alert(error.reason, "danger", "growl-top-right"); } - if(result){ - template.processing.set( false ); - Bert.alert( 'Slot has been added', 'success', 'growl-top-right' ); - Modal.hide() + if (result) { + template.processing.set(false); + Bert.alert("Slot has been added", "success", "growl-top-right"); + Modal.hide(); } }); - } }); diff --git a/client/templates/study_groups/edit_study_group_info_modal.html b/imports/ui/components/study_groups/edit_study_group_info_modal.html similarity index 100% rename from client/templates/study_groups/edit_study_group_info_modal.html rename to imports/ui/components/study_groups/edit_study_group_info_modal.html diff --git a/imports/ui/components/study_groups/edit_study_group_info_modal.js b/imports/ui/components/study_groups/edit_study_group_info_modal.js new file mode 100644 index 00000000..82397572 --- /dev/null +++ b/imports/ui/components/study_groups/edit_study_group_info_modal.js @@ -0,0 +1,62 @@ +Template.editStudyGroupInfoModal.onCreated(function() { + let instance = this; + instance.processing = new ReactiveVar(false); + instance.introCharCount = new ReactiveVar(140); +}); + +Template.editStudyGroupInfoModal.onRendered(function() { + let instance = this; + let introCharCount = $("#sgIntro").val().length || 0; + instance.introCharCount.set(140 - introCharCount); +}); + +Template.editStudyGroupInfoModal.helpers({ + processing() { + return Template.instance().processing.get(); + }, + introCharCount() { + return Template.instance().introCharCount.get(); + } +}); + +Template.editStudyGroupInfoModal.events({ + "keyup #sgIntro": function(event, template) { + let introCharCount = $("#sgIntro").val().length || 0; + template.introCharCount.set(140 - introCharCount); + }, + "submit .updateStudyGroupInfo": function(event, template) { + event.preventDefault(); + + $(".form-control").css({ border: "1px solid #cccccc" }); + + if ($.trim(template.find("#sgIntro").value) == "") { + $("#sgIntro").css({ border: "#FF0000 1px solid" }); + return Bert.alert("Study Group Introduction", "warning", "growl-top-right"); + } + if ($("#sgIntro").val().length > 140) { + $("#sgIntro").css({ border: "#FF0000 1px solid" }); + return Bert.alert("Study Group Introduction", "warning", "growl-top-right"); + } + + const data = { + id: this._id, + introduction: $.trim(template.find("#sgIntro").value), + description: $.trim(template.find("#sgDesc").value) + }; + + // console.log(data); + template.processing.set(true); + + Meteor.call("updateStudyGroupInfo", data, function(error, result) { + if (error) { + template.processing.set(false); + Bert.alert(error.reason, "danger", "growl-top-right"); + } + if (result) { + template.processing.set(false); + Bert.alert("Description updated!", "success", "growl-top-right"); + Modal.hide(); + } + }); + } +}); diff --git a/client/templates/study_groups/edit_study_group_resources_modal.html b/imports/ui/components/study_groups/edit_study_group_resources_modal.html similarity index 100% rename from client/templates/study_groups/edit_study_group_resources_modal.html rename to imports/ui/components/study_groups/edit_study_group_resources_modal.html diff --git a/imports/ui/components/study_groups/edit_study_group_resources_modal.js b/imports/ui/components/study_groups/edit_study_group_resources_modal.js new file mode 100644 index 00000000..1924d02e --- /dev/null +++ b/imports/ui/components/study_groups/edit_study_group_resources_modal.js @@ -0,0 +1,66 @@ +Template.editStudyGroupResourcesModal.onCreated(function() { + let instance = this; + instance.processing = new ReactiveVar(false); + instance.alert = new ReactiveVar(false); +}); + +Template.editStudyGroupResourcesModal.helpers({ + processing() { + return Template.instance().processing.get(); + }, + alert() { + return Template.instance().alert.get(); + }, + isError(elementId) { + return Template.instance().alert.get().elementId === elementId; + } +}); + +Template.editStudyGroupResourcesModal.events({ + "submit .updateStudyGroupResources": function(event, template) { + event.preventDefault(); + + $(".form-control").css({ border: "1px solid #cccccc" }); + + if ($.trim(template.find("#sgResourceTitle").value) == "") { + $("#sgResourceTitle").css({ border: "#FF0000 1px solid" }); + return template.alert.set({ + type: "alert-warning", + elementId: "sgResourceTitle", + message: "Please include a link title." + }); + } + if ($.trim(template.find("#sgResourceURL").value) == "") { + $("#sgResourceURL").css({ border: "#FF0000 1px solid" }); + return template.alert.set({ + type: "alert-warning", + elementId: "sgResourceURL", + message: "Please include a link URL." + }); + } + + let data = { + studyGroupId: this._id, + studyGroupTitle: this.title, + studyGroupSlug: this.slug, + resourceTitle: template.find("#sgResourceTitle").value, + resourceURL: template.find("#sgResourceURL").value + }; + + // console.log(data); + template.processing.set(true); + template.alert.set(false); + + Meteor.call("addResource", data, function(error, result) { + if (error) { + template.processing.set(false); + template.alert.set({ type: "alert-danger", message: error.reason }); + } + if (result) { + template.processing.set(false); + Bert.alert("Link has been added", "success", "growl-top-right"); + Modal.hide(); + } + }); + } +}); diff --git a/client/templates/study_groups/edit_study_group_title_modal.html b/imports/ui/components/study_groups/edit_study_group_title_modal.html similarity index 100% rename from client/templates/study_groups/edit_study_group_title_modal.html rename to imports/ui/components/study_groups/edit_study_group_title_modal.html diff --git a/imports/ui/components/study_groups/edit_study_group_title_modal.js b/imports/ui/components/study_groups/edit_study_group_title_modal.js new file mode 100644 index 00000000..ff9ec64a --- /dev/null +++ b/imports/ui/components/study_groups/edit_study_group_title_modal.js @@ -0,0 +1,132 @@ +Template.editStudyGroupTitleModal.onCreated(function() { + let instance = this; + instance.processing = new ReactiveVar(false); + instance.titleCharCount = new ReactiveVar(70); + instance.taglineCharCount = new ReactiveVar(60); +}); + +Template.editStudyGroupTitleModal.onRendered(function() { + let instance = this; + let titleCharCount = $("#sgTitle").val().length || 0; + instance.titleCharCount.set(70 - titleCharCount); + + let taglineCharCount = $("#sgTagline").val().length || 0; + instance.taglineCharCount.set(60 - taglineCharCount); + + let tags = [ + "Below are some popular tags. Feel free to type your own! White spaces are supported.", + "JavaScript", + "Python", + "Go", + "CSS", + "PHP", + "R", + "NodeJS", + "D3", + "MongoDB", + "Meteor", + "Java" + ]; + + instance.data.tags.forEach(tag => { + if (tags.indexOf(tag) < 0) { + tags.push(tag); + } + }); + + tags = tags.map(tag => { + if (instance.data.tags.indexOf(tag) > -1) { + return { id: tag, text: tag, selected: true }; + } + return { id: tag, text: tag }; + }); + + Meteor.setTimeout(function() { + instance.$(".study-group-tags-multiple", tags).select2({ + placeholder: "Tags (required)", + data: tags, + tags: true, + tokenSeparators: [","], + allowClear: true + }); + }, 500); +}); + +Template.editStudyGroupTitleModal.helpers({ + processing() { + return Template.instance().processing.get(); + }, + titleCharCount() { + return Template.instance().titleCharCount.get(); + }, + taglineCharCount() { + return Template.instance().taglineCharCount.get(); + } +}); + +Template.editStudyGroupTitleModal.events({ + "keyup #sgTitle": function(event, template) { + let titleCharCount = $("#sgTitle").val().length || 0; + template.titleCharCount.set(70 - titleCharCount); + }, + "keyup #sgTagline": function(event, template) { + let taglineCharCount = $("#sgTagline").val().length || 0; + template.taglineCharCount.set(60 - taglineCharCount); + }, + "submit .updateStudyGroupTitle": function(event, template) { + event.preventDefault(); + + $(".form-control").css({ border: "1px solid #cccccc" }); + + if ($.trim(template.find("#sgTitle").value) == "") { + $("#sgTitle").css({ border: "#FF0000 1px solid" }); + return Bert.alert("Your title cannot be empty.", "warning", "growl-top-right"); + } + if ($.trim(template.find("#sgTagline").value) == "") { + $("#sgTitle").css({ border: "#FF0000 1px solid" }); + return Bert.alert("Your tagline cannot be empty.", "warning", "growl-top-right"); + } + if ($("#sgTitle").val().length > 70) { + $("#sgTitle").css({ border: "#FF0000 1px solid" }); + return Bert.alert("Please shorten your title.", "warning", "growl-top-right"); + } + if ($("#sgTagline").val().length > 60) { + $("#sgTagline").css({ border: "#FF0000 1px solid" }); + return Bert.alert("Please shorten your tagline.", "warning", "growl-top-right"); + } + + if ( + !$(".study-group-tags-multiple").val() || + $(".study-group-tags-multiple").val().length <= 2 + ) { + $("study-group-tags-multiple").css({ border: "#FF0000 1px solid" }); + return Bert.alert("Please save at least 3 tags. ", "warning", "growl-top-right"); + } + + const data = { + id: this._id, + title: $.trim(template.find("#sgTitle").value), + tagline: $.trim(template.find("#sgTagline").value), + tags: $(".study-group-tags-multiple").val() + }; + + // console.log(data); + template.processing.set(true); + + Meteor.call("updateStudyGroupTitle", data, function(error, result) { + if (error) { + template.processing.set(false); + Bert.alert(error.reason, "danger", "growl-top-right"); + } + if (result) { + template.processing.set(false); + Bert.alert( + "The information about your study group has been updated!", + "success", + "growl-top-right" + ); + Modal.hide(); + } + }); + } +}); diff --git a/client/templates/study_groups/my_study_groups.html b/imports/ui/components/study_groups/my_study_groups.html similarity index 100% rename from client/templates/study_groups/my_study_groups.html rename to imports/ui/components/study_groups/my_study_groups.html diff --git a/imports/ui/components/study_groups/my_study_groups.js b/imports/ui/components/study_groups/my_study_groups.js new file mode 100644 index 00000000..d7218ae4 --- /dev/null +++ b/imports/ui/components/study_groups/my_study_groups.js @@ -0,0 +1,98 @@ +Template.myStudyGroups.onCreated(function() { + const title = "CodeBuddies | My Study Groups"; + const metaInfo = { + name: "description", + content: + "CodeBuddies is a community of independent code learners who enjoy sharing knowledge and helping each other learn faster. We come from all over the world; there are members living in the United States, Japan, Sweden, the United Kingdom, Russia, Australia, Canada, India, and more. Everyone is welcome, independent of previous knowledge." + }; + + DocHead.setTitle(title); + DocHead.addMeta(metaInfo); + + let instance = this; + instance.limit = new ReactiveVar(30); + instance.flag = new ReactiveVar(false); + instance.leftStudyGroup = new ReactiveVar(false); + + instance.autorun(function() { + let limit = instance.limit.get(); + instance.subscribe("myStudyGroups", limit); + + if (instance.leftStudyGroup.get() === true) { + instance.subscribe("myStudyGroups", limit); + instance.leftStudyGroup.set(false); + } + + const hangoutIds = StudyGroups.find({}, { fields: { _id: 1 } }).map(x => `cb${x._id}`); + instance.subscribe("allHangoutParticipants", hangoutIds); + }); + + instance.loadStudyGroups = function() { + /* filter out study group where logged in user is not a member */ + return StudyGroups.find({ "members.id": { $eq: Meteor.userId() } }, { sort: { createdAt: 1 } }); + }; +}); + +Template.myStudyGroups.onRendered(function() { + let instance = this; + + instance.scrollHandler = function() { + if ( + $(window).scrollTop() > $(document).height() - $(window).height() - 20 && + !instance.flag.get() + ) { + if (StudyGroups.find().count() === instance.limit.get()) { + instance.limit.set(instance.limit.get() + 9); + $("body").addClass("stop-scrolling"); + } else { + if (StudyGroups.find().count() < instance.limit.get()) { + instance.flag.set(true); + } else { + } + } + } + }.bind(instance); + $(window).on("scroll", instance.scrollHandler); +}); + +Template.myStudyGroups.helpers({ + studyGroups: function() { + return Template.instance().loadStudyGroups(); + }, + status: function() { + return Template.instance().flag.get(); + }, + numParticipants: function(studyGroupId) { + const hangoutId = `cb${studyGroupId}`; + const appState = AppStats.findOne({ _id: hangoutId }); + if (appState && appState.participants) { + return appState.participants.length; + } + return 0; + } +}); + +Template.myStudyGroups.events({ + "click #newStudyGroup": function(event, template) { + event.preventDefault(); + Modal.show("newStudyGroupModal"); + }, + "click .btn-leave-study-group": function(event, template) { + event.preventDefault(); + let data = { + studyGroupId: this._id, + studyGroupTitle: this.title, + studyGroupSlug: this.slug + }; + + Meteor.call("leaveStudyGroup", data, function(error, result) { + if (error) { + return Bert.alert(error.reason, "danger", "growl-top-right"); + } + if (result) { + template.leftStudyGroup.set(true); + return Bert.alert("You have left the study group!", "success", "growl-top-right"); + } + }); + } +}); diff --git a/client/templates/study_groups/new_study_group_modal.html b/imports/ui/components/study_groups/new_study_group_modal.html similarity index 100% rename from client/templates/study_groups/new_study_group_modal.html rename to imports/ui/components/study_groups/new_study_group_modal.html diff --git a/imports/ui/components/study_groups/new_study_group_modal.js b/imports/ui/components/study_groups/new_study_group_modal.js new file mode 100644 index 00000000..3c09e3bb --- /dev/null +++ b/imports/ui/components/study_groups/new_study_group_modal.js @@ -0,0 +1,125 @@ +Template.newStudyGroupModal.onCreated(function() { + let instance = this; + instance.processing = new ReactiveVar(false); + instance.titleCharCount = new ReactiveVar(70); + instance.taglineCharCount = new ReactiveVar(60); +}); + +Template.newStudyGroupModal.onRendered(function() { + let instance = this; + let titleCharCount = $("#title").val().length || 0; + instance.titleCharCount.set(70 - titleCharCount); + + let taglineCharCount = $("#tagline").val().length || 0; + instance.taglineCharCount.set(60 - taglineCharCount); + + Meteor.setTimeout(function() { + const tags = [ + "Below are some popular tags. Feel free to type your own! White spaces are supported.", + "JavaScript", + "Python", + "Go", + "CSS", + "PHP", + "R", + "NodeJS", + "D3", + "MongoDB", + "Meteor", + "Java" + ]; + instance.$(".study-group-tags-multiple", tags).select2({ + placeholder: "Tags (required)", + data: tags, + tags: true, + tokenSeparators: [","], + allowClear: true + }); + }, 500); +}); + +Template.newStudyGroupModal.helpers({ + processing() { + return Template.instance().processing.get(); + }, + titleCharCount() { + return Template.instance().titleCharCount.get(); + }, + taglineCharCount() { + return Template.instance().taglineCharCount.get(); + } +}); + +Template.newStudyGroupModal.events({ + "keyup #title": function(event, template) { + let titleCharCount = $("#title").val().length || 0; + template.titleCharCount.set(70 - titleCharCount); + }, + "keyup #tagline": function(event, template) { + let taglineCharCount = $("#tagline").val().length || 0; + template.taglineCharCount.set(60 - taglineCharCount); + }, + "submit .newStudyGroup": function(event, template) { + event.preventDefault(); + + if ($.trim(template.find("#title").value) == "") { + return Bert.alert("Please input a name for your study group.", "warning", "growl-top-right"); + } + if ($.trim(template.find("#tagline").value) == "") { + return Bert.alert( + "Please input a tagline for your study group.", + "warning", + "growl-top-right" + ); + } + if ($("#title").val().length > 70) { + $("#title").css({ border: "#FF0000 1px solid" }); + return Bert.alert("Please shorten your title.", "warning", "growl-top-right"); + } + if ($("#tagline").val().length > 60) { + $("#tagline").css({ border: "#FF0000 1px solid" }); + return Bert.alert("Please shorten your tagline.", "warning", "growl-top-right"); + } + + if ( + !$(".study-group-tags-multiple").val() || + $(".study-group-tags-multiple").val().length <= 2 + ) { + return Bert.alert("Please save at least 3 tags. ", "warning", "growl-top-right"); + } + + const data = { + title: template.find("#title").value, + slug: template + .find("#title") + .value.replace(/\s+/g, "-") + .toLowerCase(), + tagline: template.find("#tagline").value, + tags: $(".study-group-tags-multiple").val() + }; + // console.log(data); + + template.processing.set(true); + + Meteor.call("createNewStudyGroup", data, function(error, result) { + if (error) { + template.processing.set(false); + Bert.alert(error.reason, "danger", "growl-top-right"); + } + if (result) { + template.processing.set(false); + template.find("#title").value = ""; + template.find("#tagline").value = ""; + + Modal.hide(); + FlowRouter.go("my study groups"); + Bert.alert({ + type: "success", + message: 'Congratulations! Your study group "' + data.title + '" has been created.', + icon: "fa-check-circle", + hideDelay: 6500 + }); + } + }); + } +}); diff --git a/client/templates/study_groups/single_study_group.html b/imports/ui/components/study_groups/single_study_group.html similarity index 100% rename from client/templates/study_groups/single_study_group.html rename to imports/ui/components/study_groups/single_study_group.html diff --git a/imports/ui/components/study_groups/single_study_group.js b/imports/ui/components/study_groups/single_study_group.js new file mode 100644 index 00000000..fe1426ac --- /dev/null +++ b/imports/ui/components/study_groups/single_study_group.js @@ -0,0 +1,107 @@ +Template.singleStudyGroup.onCreated(function() { + let instance = this; + instance.studyGroupId = FlowRouter.getParam("studyGroupId"); + instance.hangoutId = `cb${instance.studyGroupId}`; + instance.autorun(() => { + instance.subscribe("studyGroupById", instance.studyGroupId); + instance.subscribe("hangoutParticipants", instance.hangoutId); + }); +}); + +Template.singleStudyGroup.onRendered(function() { + const title = "CodeBuddies | Study Groups"; + const metaInfo = { + name: "description", + content: + "CodeBuddies is a community of independent code learners who enjoy sharing knowledge and helping each other learn faster. We come from all over the world; there are members living in the United States, Japan, Sweden, the United Kingdom, Russia, Australia, Canada, India, and more. Everyone is welcome, independent of previous knowledge." + }; + + DocHead.setTitle(title); + DocHead.addMeta(metaInfo); +}); + +Template.singleStudyGroup.helpers({ + studyGroup: function() { + return StudyGroups.findOne({ _id: FlowRouter.getParam("studyGroupId") }); + }, + usersOnlineCount: function() { + return Meteor.users.find({ "status.online": true }).count(); + }, + resourcesCount: function() { + return Resources.find().count(); + }, + learningsCount: function() { + return Learnings.find().count(); + }, + numParticipants: function() { + const appState = AppStats.findOne({ _id: Template.instance().hangoutId }); + if (appState && appState.participants) { + return appState.participants.length; + } + return 0; + } +}); + +Template.singleStudyGroup.events({ + "click #hide-sidebar": function() { + $(".study-group-sidebar").hide(); + $(".study-group-body") + .removeClass("col-md-9") + .addClass("col-md-10 col-md-offset-1"); + $("#show-sidebar").fadeIn(); + }, + "click #show-sidebar": function() { + $(".study-group-sidebar").show(); + $(".study-group-body") + .removeClass("col-md-10 col-md-offset-1") + .addClass("col-md-9"); + $("#show-sidebar").hide(); + }, + "click #newHangout": function(event) { + Modal.show("createHangoutModal"); + }, + "click .joinStudyGroup": function(event, template) { + event.preventDefault(); + + let data = { + studyGroupId: this._id, + studyGroupTitle: this.title, + studyGroupSlug: this.slug + }; + + Meteor.call("joinStudyGroup", data, function(error, result) { + if (error) { + return Bert.alert(error.reason, "danger", "growl-top-right"); + } + if (result) { + return Bert.alert("You have joined the study group!", "success", "growl-top-right"); + } + }); + }, + "click .leaveStudyGroup": function(event, template) { + event.preventDefault(); + + let data = { + studyGroupId: this._id, + studyGroupTitle: this.title, + studyGroupSlug: this.slug + }; + + Meteor.call("leaveStudyGroup", data, function(error, result) { + if (error) { + return Bert.alert(error.reason, "danger", "growl-top-right"); + } + if (result) { + return Bert.alert("You have left the study group!", "success", "growl-top-right"); + } + }); + }, + "click .memberDetail": function(event, template) { + event.preventDefault(); + return Modal.show("studyGroupMemberDetail", this); + }, + "click #editTitle": function(event, template) { + event.preventDefault(); + Modal.show("editStudyGroupTitleModal", this); + } +}); diff --git a/client/templates/study_groups/study_group_activities.html b/imports/ui/components/study_groups/study_group_activities.html similarity index 100% rename from client/templates/study_groups/study_group_activities.html rename to imports/ui/components/study_groups/study_group_activities.html diff --git a/client/templates/study_groups/study_group_activities.js b/imports/ui/components/study_groups/study_group_activities.js similarity index 54% rename from client/templates/study_groups/study_group_activities.js rename to imports/ui/components/study_groups/study_group_activities.js index c5a077dc..6874308a 100644 --- a/client/templates/study_groups/study_group_activities.js +++ b/imports/ui/components/study_groups/study_group_activities.js @@ -1,39 +1,41 @@ Template.studyGroupActivities.onCreated(function() { let instance = this; - // initialize the reactive variables + // initialize the reactive variables instance.loaded = new ReactiveVar(0); instance.limit = new ReactiveVar(12); this.autorun(() => { - //Pagination - let limit = this.limit.get(); - let studyGroupId = FlowRouter.getParam('studyGroupId'); - let subscription = instance.subscribe('allStudyGroupActivities', limit, studyGroupId); - if (subscription.ready()) { - instance.loaded.set(limit); - } + //Pagination + let limit = this.limit.get(); + let studyGroupId = FlowRouter.getParam("studyGroupId"); + let subscription = instance.subscribe("allStudyGroupActivities", limit, studyGroupId); + if (subscription.ready()) { + instance.loaded.set(limit); + } }); instance.activitiesForStudyGroup = function() { - return Activities.find({}, {limit: instance.loaded.get(), sort: {created_at: -1}}); - } - + return Activities.find({}, { limit: instance.loaded.get(), sort: { created_at: -1 } }); + }; }); - Template.studyGroupActivities.helpers({ activities: function() { //return Activities.find({'study_group.id': FlowRouter.getParam('studyGroupId') }); return Template.instance().activitiesForStudyGroup(); }, - hasMoreActivities: function () { - return Template.instance().activitiesForStudyGroup().count() >= Template.instance().limit.get(); + hasMoreActivities: function() { + return ( + Template.instance() + .activitiesForStudyGroup() + .count() >= Template.instance().limit.get() + ); } }); Template.studyGroupActivities.events({ - 'click #load-more-activities': function (event, instance) { + "click #load-more-activities": function(event, instance) { event.preventDefault(); // get current value for limit, i.e. how many activities are currently displayed diff --git a/client/templates/study_groups/study_group_availability.html b/imports/ui/components/study_groups/study_group_availability.html similarity index 100% rename from client/templates/study_groups/study_group_availability.html rename to imports/ui/components/study_groups/study_group_availability.html diff --git a/imports/ui/components/study_groups/study_group_availability.js b/imports/ui/components/study_groups/study_group_availability.js new file mode 100644 index 00000000..c13db17e --- /dev/null +++ b/imports/ui/components/study_groups/study_group_availability.js @@ -0,0 +1,44 @@ +Template.studyGroupAvailability.onCreated(function() { + let instance = this; + let studyGroupId = FlowRouter.getParam("studyGroupId"); + instance.subscribe("allStudyGroupAvailability", studyGroupId); +}); + +Template.studyGroupAvailability.helpers({ + groupMembersAvailabilities() { + return Availabilities.find( + { + "study_group.id": FlowRouter.getParam("studyGroupId"), + "author.id": { $ne: Meteor.userId() } + }, + { sort: { start_day: 1, start_hour: 1, start_minute: 1 } } + ); + }, + currentUsersAvailabilities() { + return Availabilities.find( + { "study_group.id": FlowRouter.getParam("studyGroupId"), "author.id": Meteor.userId() }, + { sort: { start_day: 1, start_hour: 1, start_minute: 1 } } + ); + } +}); + +Template.studyGroupAvailability.events({ + "click #addSlot"(event, template) { + Modal.show("editStudyGroupAvailabilitySlotModal", this); + }, + "click #removeSlot"(event, template) { + event.preventDefault(); + const data = { + availabilityId: this._id, + studyGroupId: this.study_group.id + }; + Meteor.call("removeAvailabilitySlot", data, function(error, result) { + if (error) { + Bert.alert(error.reason, "danger", "growl-top-right"); + } + if (result) { + Bert.alert("Slot has been removed", "success", "growl-top-right"); + } + }); + } +}); diff --git a/client/templates/study_groups/study_group_description.html b/imports/ui/components/study_groups/study_group_description.html similarity index 100% rename from client/templates/study_groups/study_group_description.html rename to imports/ui/components/study_groups/study_group_description.html diff --git a/imports/ui/components/study_groups/study_group_description.js b/imports/ui/components/study_groups/study_group_description.js new file mode 100644 index 00000000..d425ccbb --- /dev/null +++ b/imports/ui/components/study_groups/study_group_description.js @@ -0,0 +1,6 @@ +Template.studyGroupDescription.events({ + "click #editDescription": function(event, template) { + event.preventDefault(); + Modal.show("editStudyGroupInfoModal", this); + } +}); diff --git a/client/templates/study_groups/study_group_discussion.html b/imports/ui/components/study_groups/study_group_discussion.html similarity index 100% rename from client/templates/study_groups/study_group_discussion.html rename to imports/ui/components/study_groups/study_group_discussion.html diff --git a/client/templates/study_groups/study_group_discussion.js b/imports/ui/components/study_groups/study_group_discussion.js similarity index 92% rename from client/templates/study_groups/study_group_discussion.js rename to imports/ui/components/study_groups/study_group_discussion.js index f139a717..80519298 100644 --- a/client/templates/study_groups/study_group_discussion.js +++ b/imports/ui/components/study_groups/study_group_discussion.js @@ -26,12 +26,7 @@ Template.studyGroupDiscussion.onCreated(function() { projection.sort = { created_at: -1 }; } - instance.subscribe( - "studyGroupDiscussions", - studyGroupId, - limit, - discussionFilter - ); + instance.subscribe("studyGroupDiscussions", studyGroupId, limit, discussionFilter); }); console.log(projection); @@ -100,11 +95,7 @@ Template.studyGroupDiscussion.events({ if (result.value) { Meteor.call("discussions.remove", data, function(error) { - swal( - "Poof!", - "Your Discussion has been successfully deleted!", - "success" - ); + swal("Poof!", "Your Discussion has been successfully deleted!", "success"); }); } else if ( result.dismiss === "cancel" || @@ -113,12 +104,7 @@ Template.studyGroupDiscussion.events({ ) { swal("Phew!", "No changes made", "info"); } else { - swal( - "Oops! Something went wrong", - error.error, - +"\n Try again", - "error" - ); + swal("Oops! Something went wrong", error.error, +"\n Try again", "error"); } }); //sweetAlert 2 }, diff --git a/client/templates/study_groups/study_group_hangouts.html b/imports/ui/components/study_groups/study_group_hangouts.html similarity index 100% rename from client/templates/study_groups/study_group_hangouts.html rename to imports/ui/components/study_groups/study_group_hangouts.html diff --git a/imports/ui/components/study_groups/study_group_hangouts.js b/imports/ui/components/study_groups/study_group_hangouts.js new file mode 100644 index 00000000..44a14e9e --- /dev/null +++ b/imports/ui/components/study_groups/study_group_hangouts.js @@ -0,0 +1,77 @@ +Template.studyGroupHangouts.onCreated(function() { + let instance = this; + instance.limit = new ReactiveVar(20); + instance.flag = new ReactiveVar(false); + + instance.autorun(function() { + let limit = instance.limit.get(); + let studyGroupId = FlowRouter.getParam("studyGroupId"); + instance.subscribe("studyGroupHangouts", studyGroupId, limit); + }); + + instance.loadHangouts = function() { + return Hangouts.find({}, { sort: { start: -1 } }); + }; + + const now = new Date(); + + instance.pastHangoutCount = function() { + return Hangouts.find({ end: { $lt: now } }).count() || 0; + }; + + instance.liveHangoutCount = function() { + return Hangouts.find({ end: { $gte: now } }).count() || 0; + }; +}); + +Template.studyGroupHangouts.onRendered(function() { + let instance = this; + + instance.scrollHandler = function() { + if ( + $(window).scrollTop() > $(document).height() - $(window).height() - 20 && + !instance.flag.get() + ) { + if (Hangouts.find().count() === instance.limit.get()) { + instance.limit.set(instance.limit.get() + 9); + $("body").addClass("stop-scrolling"); + } else { + if (Hangouts.find().count() < instance.limit.get()) { + instance.flag.set(true); + } else { + } + } + } + }.bind(instance); + $(window).on("scroll", instance.scrollHandler); +}); + +Template.studyGroupHangouts.helpers({ + hangouts: function() { + return Template.instance().loadHangouts(); + }, + status: function() { + return Template.instance().flag.get(); + }, + hangoutCount: function() { + return Template.instance() + .loadHangouts() + .count(); + }, + liveHangoutCount: function() { + return Template.instance().liveHangoutCount(); + }, + pastHangoutCount: function() { + return Template.instance().pastHangoutCount(); + } +}); + +Template.studyGroupHangouts.events({ + "click #newHangout": function(event) { + Modal.show("createHangoutModal"); + } +}); + +Template.studyGroupHangouts.onDestroyed(function() { + $(window).off("scroll", this.scrollHandler); +}); diff --git a/client/templates/study_groups/study_group_info.html b/imports/ui/components/study_groups/study_group_info.html similarity index 100% rename from client/templates/study_groups/study_group_info.html rename to imports/ui/components/study_groups/study_group_info.html diff --git a/client/templates/study_groups/study_group_info.js b/imports/ui/components/study_groups/study_group_info.js similarity index 100% rename from client/templates/study_groups/study_group_info.js rename to imports/ui/components/study_groups/study_group_info.js diff --git a/client/templates/study_groups/study_group_learnings.html b/imports/ui/components/study_groups/study_group_learnings.html similarity index 100% rename from client/templates/study_groups/study_group_learnings.html rename to imports/ui/components/study_groups/study_group_learnings.html diff --git a/client/templates/study_groups/study_group_learnings.js b/imports/ui/components/study_groups/study_group_learnings.js similarity index 62% rename from client/templates/study_groups/study_group_learnings.js rename to imports/ui/components/study_groups/study_group_learnings.js index 89a0250c..cf21147a 100644 --- a/client/templates/study_groups/study_group_learnings.js +++ b/imports/ui/components/study_groups/study_group_learnings.js @@ -1,5 +1,4 @@ -Template.studyGroupLearnings.onCreated(function () { - +Template.studyGroupLearnings.onCreated(function() { // 1. Initialization var instance = this; @@ -8,16 +7,15 @@ Template.studyGroupLearnings.onCreated(function () { instance.loaded = new ReactiveVar(0); instance.limit = new ReactiveVar(5); - instance.autorun(function () { - + instance.autorun(function() { // get the limit var limit = instance.limit.get(); //console.log("Asking for "+limit+" learnings...") - var studyGroupId = FlowRouter.getParam('studyGroupId'); + var studyGroupId = FlowRouter.getParam("studyGroupId"); //console.log(studyGroupId) // subscribe to the learningsByHangoutId publication - var subscription = instance.subscribe('learningsByStudyGroupId', limit, studyGroupId); + var subscription = instance.subscribe("learningsByStudyGroupId", limit, studyGroupId); // if subscription is ready, set limit to newLimit if (subscription.ready()) { //console.log("> Received "+limit+" learnings. \n\n") @@ -27,25 +25,28 @@ Template.studyGroupLearnings.onCreated(function () { } }); - instance.learningsForStudyGroup = function() { - return Learnings.find({}, {limit: instance.loaded.get(), sort: {created_at: -1}}); - } - + instance.learningsForStudyGroup = function() { + return Learnings.find({}, { limit: instance.loaded.get(), sort: { created_at: -1 } }); + }; }); Template.studyGroupLearnings.helpers({ - // the posts cursor - learnings: function () { + // the posts cursor + learnings: function() { return Template.instance().learningsForStudyGroup(); }, // are there more posts to show? - hasMoreLearnings: function () { - return Template.instance().learningsForStudyGroup().count() >= Template.instance().limit.get(); + hasMoreLearnings: function() { + return ( + Template.instance() + .learningsForStudyGroup() + .count() >= Template.instance().limit.get() + ); } }); Template.studyGroupLearnings.events({ - 'click #load-more-learnings': function (event, instance) { + "click #load-more-learnings": function(event, instance) { event.preventDefault(); // get current value for limit, i.e. how many learnings are currently displayed diff --git a/client/templates/study_groups/study_group_member_detail.html b/imports/ui/components/study_groups/study_group_member_detail.html similarity index 100% rename from client/templates/study_groups/study_group_member_detail.html rename to imports/ui/components/study_groups/study_group_member_detail.html diff --git a/imports/ui/components/study_groups/study_group_member_detail.js b/imports/ui/components/study_groups/study_group_member_detail.js new file mode 100644 index 00000000..5f0c3f61 --- /dev/null +++ b/imports/ui/components/study_groups/study_group_member_detail.js @@ -0,0 +1,50 @@ +Template.studyGroupMemberDetail.onRendered(function() { + const user = this.data; + const studyGroupId = FlowRouter.getParam("studyGroupId"); + const instance = this; + this.autorun(function() { + instance.subscribe("studyGroupMemberDetail", studyGroupId, user.id); + }); +}); + +Template.studyGroupMemberDetail.helpers({ + user: function() { + return Meteor.users.findOne({ _id: Template.instance().data.id }); + }, + groupId: function() { + return FlowRouter.getParam("studyGroupId"); + }, + userRoles: function() { + const roles = Meteor.users.findOne({ _id: Template.instance().data.id }).roles; + const studyGroupId = FlowRouter.getParam("studyGroupId"); + return roles[studyGroupId].pop(); + } +}); + +Template.studyGroupMemberDetail.events({ + "change #authorization": function(event, template) { + const user = this; + + const data = { + user: { + id: user._id, + username: user.username, + avatar: user.profile.avatar.default + }, + role: template.find("#authorization").value, + studyGroupId: FlowRouter.getParam("studyGroupId") + }; + + //console.log(data); + + Meteor.call("updateUserRoleForStudyGroup", data, function(error, result) { + if (error) { + Bert.alert(error.reason, "danger", "growl-top-right"); + } + if (result) { + Modal.hide(); + Bert.alert("Role updated", "success", "growl-top-right"); + } + }); + } +}); diff --git a/client/templates/study_groups/study_group_members.html b/imports/ui/components/study_groups/study_group_members.html similarity index 100% rename from client/templates/study_groups/study_group_members.html rename to imports/ui/components/study_groups/study_group_members.html diff --git a/client/templates/study_groups/study_group_online_members.html b/imports/ui/components/study_groups/study_group_online_members.html similarity index 100% rename from client/templates/study_groups/study_group_online_members.html rename to imports/ui/components/study_groups/study_group_online_members.html diff --git a/imports/ui/components/study_groups/study_group_online_members.js b/imports/ui/components/study_groups/study_group_online_members.js new file mode 100644 index 00000000..3b600037 --- /dev/null +++ b/imports/ui/components/study_groups/study_group_online_members.js @@ -0,0 +1,14 @@ +Template.studyGroupOnlineMembers.helpers({ + onlineUsers: function() { + const onlineUsernames = Meteor.users + .find({ "status.online": true }, { fields: { id: 1 } }) + .fetch() + .map(m => m._id); + const studyGroup = StudyGroups.findOne({ _id: FlowRouter.getParam("studyGroupId") }); + if (studyGroup) { + const onlineMembers = studyGroup.members.filter(m => onlineUsernames.indexOf(m.id) >= 0); + return onlineMembers; + } + return []; + } +}); diff --git a/client/templates/study_groups/study_group_owners_guide.html b/imports/ui/components/study_groups/study_group_owners_guide.html similarity index 100% rename from client/templates/study_groups/study_group_owners_guide.html rename to imports/ui/components/study_groups/study_group_owners_guide.html diff --git a/client/templates/study_groups/study_group_resources.html b/imports/ui/components/study_groups/study_group_resources.html similarity index 100% rename from client/templates/study_groups/study_group_resources.html rename to imports/ui/components/study_groups/study_group_resources.html diff --git a/imports/ui/components/study_groups/study_group_resources.js b/imports/ui/components/study_groups/study_group_resources.js new file mode 100644 index 00000000..58ded32f --- /dev/null +++ b/imports/ui/components/study_groups/study_group_resources.js @@ -0,0 +1,5 @@ +Template.studyGroupResources.events({ + "click #addResource": function(event, template) { + Modal.show("editStudyGroupResourcesModal", this); + } +}); diff --git a/client/templates/study_groups/study_group_search_result.html b/imports/ui/components/study_groups/study_group_search_result.html similarity index 100% rename from client/templates/study_groups/study_group_search_result.html rename to imports/ui/components/study_groups/study_group_search_result.html diff --git a/imports/ui/components/study_groups/study_group_search_result.js b/imports/ui/components/study_groups/study_group_search_result.js new file mode 100644 index 00000000..4c74431c --- /dev/null +++ b/imports/ui/components/study_groups/study_group_search_result.js @@ -0,0 +1,53 @@ +Template.studyGroupsSearchResult.onCreated(function() { + this.autorun(() => { + if (!_.isEmpty(Session.get("sgSearchTerm"))) { + this.subscribe("studyGroupSearch", Session.get("sgSearchTerm")); + } + }); +}); + +Template.studyGroupsSearchResult.helpers({ + sgSearchTerm() { + return Session.get("sgSearchTerm"); + }, + searchResults() { + return StudyGroups.search(Session.get("sgSearchTerm")); + } +}); + +Template.allStudyGroups.events({ + "click .btn-leave-study-group-1": function(event, template) { + event.preventDefault(); + let data = { + studyGroupId: this._id, + studyGroupTitle: this.title, + studyGroupSlug: this.slug + }; + + Meteor.call("leaveStudyGroup", data, function(error, result) { + if (error) { + return Bert.alert(error.reason, "danger", "growl-top-right"); + } + if (result) { + return Bert.alert("You have left the study group!", "success", "growl-top-right"); + } + }); + }, + "click .btn-join-study-group-1": function(event, template) { + event.preventDefault(); + let data = { + studyGroupId: this._id, + studyGroupTitle: this.title, + studyGroupSlug: this.slug + }; + + Meteor.call("joinStudyGroup", data, function(error, result) { + if (error) { + return Bert.alert(error.reason, "danger", "growl-top-right"); + } + if (result) { + return Bert.alert("You have joined the study group!", "success", "growl-top-right"); + } + }); + } +}); diff --git a/client/templates/study_groups/study_group_settings.html b/imports/ui/components/study_groups/study_group_settings.html similarity index 100% rename from client/templates/study_groups/study_group_settings.html rename to imports/ui/components/study_groups/study_group_settings.html diff --git a/client/templates/study_groups/study_group_settings.js b/imports/ui/components/study_groups/study_group_settings.js similarity index 89% rename from client/templates/study_groups/study_group_settings.js rename to imports/ui/components/study_groups/study_group_settings.js index d74b6ce9..7e9e874e 100644 --- a/client/templates/study_groups/study_group_settings.js +++ b/imports/ui/components/study_groups/study_group_settings.js @@ -6,11 +6,9 @@ Template.studyGroupSettings.onRendered(function() { instance.$("#transferOwnership").prop("disabled", true); const members = instance.data.members; if (members.length > 1) { - const eligibleMembers = members - .filter(member => member.role !== `owner`) - .map(member => { - return { id: member.id, text: member.name }; - }); + const eligibleMembers = members.filter(member => member.role !== `owner`).map(member => { + return { id: member.id, text: member.name }; + }); instance.$("#studyGroupMemberList").prop("disabled", false); instance.$("#transferOwnership").prop("disabled", false); @@ -55,11 +53,7 @@ Template.studyGroupSettings.events({ Meteor.call("archiveStudyGroup", studyGroupId, function(error) { FlowRouter.go("all study groups"); swal("Poof!", "Your study group has been archived", "success"); - return Bert.alert( - "Study Group Archived", - "success", - "growl-top-right" - ); + return Bert.alert("Study Group Archived", "success", "growl-top-right"); }); } else if ( result.dismiss === "cancel" || @@ -75,8 +69,7 @@ Template.studyGroupSettings.events({ "change #hangoutPermission": function(event, template) { const data = { id: this._id, - permission: - template.find("#hangoutPermission").value == "true" ? true : false + permission: template.find("#hangoutPermission").value == "true" ? true : false }; swal({ @@ -110,9 +103,7 @@ Template.studyGroupSettings.events({ studyGroupId: this._id, newOwnerId: template.find("#studyGroupMemberList").value }; - const newOwnerUsername = template.find( - "#studyGroupMemberList option:selected" - ).text; + const newOwnerUsername = template.find("#studyGroupMemberList option:selected").text; swal({ type: "warning", @@ -162,11 +153,7 @@ Template.studyGroupSettings.events({ if (result.value) { Meteor.call("saveHangoutChannel", data, function(error) { - return Bert.alert( - `Hangout channels saved`, - "success", - "growl-top-right" - ); + return Bert.alert(`Hangout channels saved`, "success", "growl-top-right"); }); } else if ( result.dismiss === "cancel" || diff --git a/client/templates/study_groups/study_groups_search_box.html b/imports/ui/components/study_groups/study_groups_search_box.html similarity index 100% rename from client/templates/study_groups/study_groups_search_box.html rename to imports/ui/components/study_groups/study_groups_search_box.html diff --git a/imports/ui/components/study_groups/study_groups_search_box.js b/imports/ui/components/study_groups/study_groups_search_box.js new file mode 100644 index 00000000..a489edb0 --- /dev/null +++ b/imports/ui/components/study_groups/study_groups_search_box.js @@ -0,0 +1,33 @@ +Template.studyGroupsSearchBox.onRendered(function() { + if (Session.get("sgSearchTerm") !== "") { + $("#sgSearchBox").val(Session.get("sgSearchTerm")); + } +}); + +Template.studyGroupsSearchBox.helpers({ + sgSearchMode: function() { + //console.log(Session.get("landingPageSearchMode")); + return Session.get("sgSearchMode"); + }, + sgSearchTerm: function() { + return Session.get("sgSearchTerm"); + } +}); + +Template.studyGroupsSearchBox.events({ + "keyup #sgSearchBox": function(event, template) { + event.preventDefault(); + const sgSearchTerm = template.find("#sgSearchBox").value; + if (_.isEmpty(sgSearchTerm)) { + Session.set("sgSearchTerm", ""); + Session.set("sgSearchMode", false); + } else { + Session.set("sgSearchMode", true); + Session.set("sgSearchTerm", sgSearchTerm); + } + }, + "click #clearSearch": function(event, template) { + Session.set("sgSearchTerm", ""); + Session.set("sgSearchMode", false); + } +}); diff --git a/client/templates/usr-notification/rsvp.html b/imports/ui/components/usr-notification/rsvp.html similarity index 100% rename from client/templates/usr-notification/rsvp.html rename to imports/ui/components/usr-notification/rsvp.html diff --git a/imports/ui/components/usr-notification/rsvp.js b/imports/ui/components/usr-notification/rsvp.js new file mode 100644 index 00000000..f6a03f64 --- /dev/null +++ b/imports/ui/components/usr-notification/rsvp.js @@ -0,0 +1,50 @@ +Template.registerHelper("isSingular", function(count) { + return count === 1 ? true : false; +}); + +Template.registerHelper("anyAttendees", function(count) { + return count > 0 ? true : false; +}); + +Template.rsvp.onCreated(function() { + var instance = this; + instance.flag = new ReactiveVar(false); + instance.limit = new ReactiveVar(10); + instance.autorun(function() { + var limit = instance.limit.get(); + var subscription = instance.subscribe("attendees", limit); + }); + + instance.dispNotifications = function() { + return RSVPnotifications.find({}, { sort: { date: -1 } }); + }; +}); + +Template.rsvp.onRendered(function() { + var instance = this; + + $("#flux").bind("scroll", function() { + if ($("#flux").scrollTop() + $("#flux").innerHeight() >= $("#flux")[0].scrollHeight) { + if (RSVPnotifications.find().count() === instance.limit.get()) { + instance.limit.set(instance.limit.get() + 5); + $("body").addClass("stop-scrolling"); + } else { + if (RSVPnotifications.find({}, { sort: { date: -1 } }).count() < instance.limit.get()) { + instance.flag.set(true); + } + } + } + }); +}); + +Template.rsvp.helpers({ + notifications: function() { + return Template.instance().dispNotifications(); + } +}); + +Template.rsvp.events({ + "click .markAsRead": function(event, template) { + Meteor.call("markItRead", this._id, function(error, result) {}); + } +}); diff --git a/client/css/_about.scss b/imports/ui/css/_about.scss similarity index 100% rename from client/css/_about.scss rename to imports/ui/css/_about.scss diff --git a/client/css/_animations.scss b/imports/ui/css/_animations.scss similarity index 100% rename from client/css/_animations.scss rename to imports/ui/css/_animations.scss diff --git a/client/css/_base.scss b/imports/ui/css/_base.scss similarity index 100% rename from client/css/_base.scss rename to imports/ui/css/_base.scss diff --git a/client/css/_breakpoints.scss b/imports/ui/css/_breakpoints.scss similarity index 100% rename from client/css/_breakpoints.scss rename to imports/ui/css/_breakpoints.scss diff --git a/client/css/_buttons.scss b/imports/ui/css/_buttons.scss similarity index 100% rename from client/css/_buttons.scss rename to imports/ui/css/_buttons.scss diff --git a/client/css/_colors.scss b/imports/ui/css/_colors.scss similarity index 100% rename from client/css/_colors.scss rename to imports/ui/css/_colors.scss diff --git a/client/css/_coworking.scss b/imports/ui/css/_coworking.scss similarity index 100% rename from client/css/_coworking.scss rename to imports/ui/css/_coworking.scss diff --git a/client/css/_discussion.scss b/imports/ui/css/_discussion.scss similarity index 100% rename from client/css/_discussion.scss rename to imports/ui/css/_discussion.scss diff --git a/client/css/_edit_learning.scss b/imports/ui/css/_edit_learning.scss similarity index 100% rename from client/css/_edit_learning.scss rename to imports/ui/css/_edit_learning.scss diff --git a/client/css/_faq.scss b/imports/ui/css/_faq.scss similarity index 100% rename from client/css/_faq.scss rename to imports/ui/css/_faq.scss diff --git a/client/css/_fonts.scss b/imports/ui/css/_fonts.scss similarity index 100% rename from client/css/_fonts.scss rename to imports/ui/css/_fonts.scss diff --git a/client/css/_footer.scss b/imports/ui/css/_footer.scss similarity index 100% rename from client/css/_footer.scss rename to imports/ui/css/_footer.scss diff --git a/client/css/_hangout_board.scss b/imports/ui/css/_hangout_board.scss similarity index 100% rename from client/css/_hangout_board.scss rename to imports/ui/css/_hangout_board.scss diff --git a/client/css/_hangout_card.scss b/imports/ui/css/_hangout_card.scss similarity index 100% rename from client/css/_hangout_card.scss rename to imports/ui/css/_hangout_card.scss diff --git a/client/css/_hangout_list.scss b/imports/ui/css/_hangout_list.scss similarity index 100% rename from client/css/_hangout_list.scss rename to imports/ui/css/_hangout_list.scss diff --git a/client/css/_hangout_modal.scss b/imports/ui/css/_hangout_modal.scss similarity index 100% rename from client/css/_hangout_modal.scss rename to imports/ui/css/_hangout_modal.scss diff --git a/client/css/_home.scss b/imports/ui/css/_home.scss similarity index 100% rename from client/css/_home.scss rename to imports/ui/css/_home.scss diff --git a/client/css/_mixins.scss b/imports/ui/css/_mixins.scss similarity index 100% rename from client/css/_mixins.scss rename to imports/ui/css/_mixins.scss diff --git a/client/css/_navbar.scss b/imports/ui/css/_navbar.scss similarity index 100% rename from client/css/_navbar.scss rename to imports/ui/css/_navbar.scss diff --git a/client/css/_notification.scss b/imports/ui/css/_notification.scss similarity index 100% rename from client/css/_notification.scss rename to imports/ui/css/_notification.scss diff --git a/client/css/_post.scss b/imports/ui/css/_post.scss similarity index 100% rename from client/css/_post.scss rename to imports/ui/css/_post.scss diff --git a/client/css/_profile.scss b/imports/ui/css/_profile.scss similarity index 100% rename from client/css/_profile.scss rename to imports/ui/css/_profile.scss diff --git a/client/css/_quill_editor.scss b/imports/ui/css/_quill_editor.scss similarity index 100% rename from client/css/_quill_editor.scss rename to imports/ui/css/_quill_editor.scss diff --git a/client/css/_sections.scss b/imports/ui/css/_sections.scss similarity index 100% rename from client/css/_sections.scss rename to imports/ui/css/_sections.scss diff --git a/client/css/_slack.scss b/imports/ui/css/_slack.scss similarity index 100% rename from client/css/_slack.scss rename to imports/ui/css/_slack.scss diff --git a/client/css/_sponsor.scss b/imports/ui/css/_sponsor.scss similarity index 100% rename from client/css/_sponsor.scss rename to imports/ui/css/_sponsor.scss diff --git a/client/css/_status_input.scss b/imports/ui/css/_status_input.scss similarity index 100% rename from client/css/_status_input.scss rename to imports/ui/css/_status_input.scss diff --git a/client/css/_status_list.scss b/imports/ui/css/_status_list.scss similarity index 100% rename from client/css/_status_list.scss rename to imports/ui/css/_status_list.scss diff --git a/client/css/_study_groups.scss b/imports/ui/css/_study_groups.scss similarity index 100% rename from client/css/_study_groups.scss rename to imports/ui/css/_study_groups.scss diff --git a/client/css/_tabs.scss b/imports/ui/css/_tabs.scss similarity index 100% rename from client/css/_tabs.scss rename to imports/ui/css/_tabs.scss diff --git a/client/css/_tips_lists.scss b/imports/ui/css/_tips_lists.scss similarity index 100% rename from client/css/_tips_lists.scss rename to imports/ui/css/_tips_lists.scss diff --git a/client/css/_update_status.scss b/imports/ui/css/_update_status.scss similarity index 100% rename from client/css/_update_status.scss rename to imports/ui/css/_update_status.scss diff --git a/client/css/_variables.scss b/imports/ui/css/_variables.scss similarity index 100% rename from client/css/_variables.scss rename to imports/ui/css/_variables.scss diff --git a/client/css/style.scss b/imports/ui/css/style.scss similarity index 100% rename from client/css/style.scss rename to imports/ui/css/style.scss diff --git a/client/head.html b/imports/ui/head.html similarity index 100% rename from client/head.html rename to imports/ui/head.html diff --git a/client/layouts/layout.html b/imports/ui/layouts/layout.html similarity index 100% rename from client/layouts/layout.html rename to imports/ui/layouts/layout.html diff --git a/client/layouts/layout.js b/imports/ui/layouts/layout.js similarity index 80% rename from client/layouts/layout.js rename to imports/ui/layouts/layout.js index 4752c421..2551c8e8 100644 --- a/client/layouts/layout.js +++ b/imports/ui/layouts/layout.js @@ -1,3 +1,5 @@ +import "./layout.html"; + Template.layout.events({ "click .continue-popup": function(event, template) { event.preventDefault(); @@ -28,18 +30,9 @@ Template.layout.events({ } }); } else if (result.dismiss === "esc" || result.dismiss === "overlay") { - swal( - "No worries!", - "Sign up or sign in with Slack or Github at any time.", - "info" - ); + swal("No worries!", "Sign up or sign in with Slack or Github at any time.", "info"); } else { - swal( - "Oops! Something went wrong", - error.error, - +"\n Try again", - "error" - ); + swal("Oops! Something went wrong", error.error, +"\n Try again", "error"); } }); } diff --git a/client/libs/QuillEditor.js b/imports/ui/libs/QuillEditor.js similarity index 70% rename from client/libs/QuillEditor.js rename to imports/ui/libs/QuillEditor.js index c95d30a3..7e750f3e 100644 --- a/client/libs/QuillEditor.js +++ b/imports/ui/libs/QuillEditor.js @@ -1,19 +1,20 @@ -import { _ } from 'meteor/erasaur:meteor-lodash'; -import Quill from './quill.js'; -import quillRender from 'quill-render'; -import QuillEditorDefaultOptions from './QuillEditorDefaultOptions'; -import { fromString } from 'html-to-text'; +import { _ } from "meteor/erasaur:meteor-lodash"; +import Quill from "./quill.js"; +import quillRender from "quill-render"; +import QuillEditorDefaultOptions from "./QuillEditorDefaultOptions"; +import { fromString } from "html-to-text"; -const isQuillDataFormat = (possibleQuillFormat) => { - return (!_.isUndefined(possibleQuillFormat.ops) && - _.isArray(possibleQuillFormat.ops)); -} +const isQuillDataFormat = possibleQuillFormat => { + return !_.isUndefined(possibleQuillFormat.ops) && _.isArray(possibleQuillFormat.ops); +}; -const normaliseToQuillFormat = (data) => { - return [{ - insert: data - }]; -} +const normaliseToQuillFormat = data => { + return [ + { + insert: data + } + ]; +}; /** * Create an editor which attaches to a DOM container. @@ -24,10 +25,9 @@ const normaliseToQuillFormat = (data) => { * Configuration options for Quill. If not specified default configuration * will be used. */ -const createEditor = ({container, options}) => { - +const createEditor = ({ container, options }) => { if (_.isUndefined(container)) { - throw new Error('container property missing'); + throw new Error("container property missing"); } const editor = new Quill(container, _.defaults(options, QuillEditorDefaultOptions)); @@ -46,20 +46,20 @@ const createEditor = ({container, options}) => { * will be converted to Quill format and assumes it is one continuous * string. */ - const setContents = (data) => { + const setContents = data => { if (isQuillDataFormat(data)) { editor.setContents(data); } else { editor.setContents({ ops: normaliseToQuillFormat(data) - }) + }); } - } + }; return { getContents, setContents - } + }; }; /** @@ -68,7 +68,7 @@ const createEditor = ({container, options}) => { * will be used as is, otherwise the data will be converted to Quill * format and assumes it is one continuous string. */ -const generateHTMLForDeltas = (data) => { +const generateHTMLForDeltas = data => { if (isQuillDataFormat(data)) { return quillRender(data.ops); } @@ -76,17 +76,17 @@ const generateHTMLForDeltas = (data) => { return quillRender(normaliseToQuillFormat(data)); }; -const generatePlainTextFromDeltas = (deltas) => { +const generatePlainTextFromDeltas = deltas => { if (!isQuillDataFormat(deltas)) { - throw new Error('expecting deltas as an argument'); + throw new Error("expecting deltas as an argument"); } return fromString(generateHTMLForDeltas(deltas), { hideLinkHrefIfSameAsText: true }); -} +}; export default { createEditor, generateHTMLForDeltas, generatePlainTextFromDeltas -} +}; diff --git a/imports/ui/libs/QuillEditor.test.js b/imports/ui/libs/QuillEditor.test.js new file mode 100644 index 00000000..fceb4b07 --- /dev/null +++ b/imports/ui/libs/QuillEditor.test.js @@ -0,0 +1,155 @@ +import { $ } from "meteor/jquery"; +import { chai } from "meteor/practicalmeteor:chai"; +import QuillEditor from "./QuillEditor"; + +chai.should(); + +describe("QuillEditor", () => { + it("should expose createEditor()", () => { + QuillEditor.createEditor.should.not.be.undefined; + }); + + it("should expose generateHTMLForDeltas()", () => { + QuillEditor.generateHTMLForDeltas.should.not.be.undefined; + }); + + it("should expose generatePlainTextFromDeltas()", () => { + QuillEditor.generatePlainTextFromDeltas.should.not.be.undefined; + }); + + describe("createEditor", () => { + var hostElement, editor, container; + + beforeEach(() => { + hostElement = $("
                    "); + $(document.body).append(hostElement); + + container = $("
                    ").get(0); + hostElement.append(container); + editor = QuillEditor.createEditor({ container }); + }); + + afterEach(() => { + hostElement.remove(); + editor = null; + container = null; + }); + + it("should throw an Error if container is not specified", () => { + chai + .expect(() => { + QuillEditor.createEditor(); + }) + .to.throw(Error); + }); + + it("should not return an undefined", () => { + editor = QuillEditor.createEditor({ container }); + editor.should.not.be.undefined; + }); + + it("should expose getContents()", () => { + editor.getContents.should.not.be.undefined; + }); + + describe("getContents()", () => { + it("should not return null", function() { + editor.getContents().should.not.be.undefined; + }); + + it("should contain a key ops", function() { + editor.getContents().ops.should.not.be.undefined; + }); + }); + + it("should expose setContents()", () => { + editor.setContents.should.not.be.undefined; + }); + + describe("setContents()", () => { + it("should reflect the contents when setting with string", function() { + editor.setContents("hello 123"); + QuillEditor.generateHTMLForDeltas(editor.getContents()).should.be.equal( + "

                    hello 123

                    " + ); + }); + + it("should reflect the contents when setting with deltas", function() { + editor.setContents({ + ops: [ + { + insert: "hello 123" + } + ] + }); + QuillEditor.generateHTMLForDeltas(editor.getContents()).should.be.equal( + "

                    hello 123

                    " + ); + }); + }); + }); + + describe("generateHTMLForDeltas", () => { + var delta = { + ops: [ + { + insert: "this is some text " + }, + { + attributes: { + link: "https://codebuddies.org/" + }, + insert: "https://codebuddies.org/" + }, + { + insert: "\n" + } + ] + }, + expectedHTML = + '

                    this is some text https://codebuddies.org/

                    '; + + it("should return html for a sequence of delta", () => { + var html = QuillEditor.generateHTMLForDeltas(delta); + html.should.be.equal(expectedHTML); + }); + + it("should fallback if delta is a plain string", function() { + var html = QuillEditor.generateHTMLForDeltas("this is a string"); + html.should.be.equal("

                    this is a string

                    "); + }); + }); + + describe("generatePlainTextFromDeltas", () => { + var delta = { + ops: [ + { + insert: "this is some text " + }, + { + attributes: { + link: "https://codebuddies.org/" + }, + insert: "https://codebuddies.org/" + }, + { + insert: "\n" + } + ] + }, + expectedText = "this is some text https://codebuddies.org/"; + + it("should throw an error if argument is not a Delta object", function() { + chai + .expect(() => { + QuillEditor.generatePlainTextFromDeltas("someString"); + }) + .to.throw(Error); + }); + + it("should return a plain string", function() { + var result = QuillEditor.generatePlainTextFromDeltas(delta); + result.should.be.equal(expectedText); + }); + }); +}); diff --git a/imports/ui/libs/QuillEditorDefaultOptions.js b/imports/ui/libs/QuillEditorDefaultOptions.js new file mode 100644 index 00000000..abd7eb2f --- /dev/null +++ b/imports/ui/libs/QuillEditorDefaultOptions.js @@ -0,0 +1,7 @@ +export default { + modules: { + toolbar: [["bold", "italic", "underline"], ["link"]] + }, + placeholder: "What do you hope to cover or master during this hangout?", + theme: "snow" +}; diff --git a/imports/ui/libs/quill.js b/imports/ui/libs/quill.js new file mode 100644 index 00000000..7290e953 --- /dev/null +++ b/imports/ui/libs/quill.js @@ -0,0 +1,13933 @@ +/*! + * Quill Editor v1.0.6 + * https://quilljs.com/ + * Copyright (c) 2014, Jason Chen + * Copyright (c) 2013, salesforce.com + */ +(function webpackUniversalModuleDefinition(root, factory) { + if (typeof exports === "object" && typeof module === "object") module.exports = factory(); + else if (typeof define === "function" && define.amd) define([], factory); + else if (typeof exports === "object") exports["Quill"] = factory(); + else root["Quill"] = factory(); +})(this, function() { + return /******/ (function(modules) { + // webpackBootstrap + /******/ // The module cache + /******/ var installedModules = {}; // The require function + + /******/ /******/ function __webpack_require__(moduleId) { + /******/ // Check if module is in cache + /******/ if (installedModules[moduleId]) /******/ return installedModules[moduleId].exports; // Create a new module (and put it into the cache) + + /******/ /******/ var module = (installedModules[moduleId] = { + /******/ exports: {}, + /******/ id: moduleId, + /******/ loaded: false + /******/ + }); // Execute the module function + + /******/ /******/ modules[moduleId].call( + module.exports, + module, + module.exports, + __webpack_require__ + ); // Flag the module as loaded + + /******/ /******/ module.loaded = true; // Return the exports of the module + + /******/ /******/ return module.exports; + /******/ + } // expose the modules object (__webpack_modules__) + + /******/ /******/ __webpack_require__.m = modules; // expose the module cache + + /******/ /******/ __webpack_require__.c = installedModules; // __webpack_public_path__ + + /******/ /******/ __webpack_require__.p = ""; // Load entry module and return exports + + /******/ /******/ return __webpack_require__(0); + /******/ + })( + /************************************************************************/ + /******/ [ + /* 0 */ + /***/ function(module, exports, __webpack_require__) { + module.exports = __webpack_require__(53); + + /***/ + }, + /* 1 */ + /***/ function(module, exports, __webpack_require__) { + "use strict"; + + var _parchment = __webpack_require__(2); + + var _parchment2 = _interopRequireDefault(_parchment); + + var _quill = __webpack_require__(18); + + var _quill2 = _interopRequireDefault(_quill); + + var _block = __webpack_require__(32); + + var _block2 = _interopRequireDefault(_block); + + var _break = __webpack_require__(33); + + var _break2 = _interopRequireDefault(_break); + + var _container = __webpack_require__(42); + + var _container2 = _interopRequireDefault(_container); + + var _cursor = __webpack_require__(37); + + var _cursor2 = _interopRequireDefault(_cursor); + + var _embed = __webpack_require__(34); + + var _embed2 = _interopRequireDefault(_embed); + + var _inline = __webpack_require__(35); + + var _inline2 = _interopRequireDefault(_inline); + + var _scroll = __webpack_require__(43); + + var _scroll2 = _interopRequireDefault(_scroll); + + var _text = __webpack_require__(36); + + var _text2 = _interopRequireDefault(_text); + + var _clipboard = __webpack_require__(44); + + var _clipboard2 = _interopRequireDefault(_clipboard); + + var _history = __webpack_require__(51); + + var _history2 = _interopRequireDefault(_history); + + var _keyboard = __webpack_require__(52); + + var _keyboard2 = _interopRequireDefault(_keyboard); + + function _interopRequireDefault(obj) { + return obj && obj.__esModule ? obj : { default: obj }; + } + + _quill2.default.register({ + "blots/block": _block2.default, + "blots/block/embed": _block.BlockEmbed, + "blots/break": _break2.default, + "blots/container": _container2.default, + "blots/cursor": _cursor2.default, + "blots/embed": _embed2.default, + "blots/inline": _inline2.default, + "blots/scroll": _scroll2.default, + "blots/text": _text2.default, + + "modules/clipboard": _clipboard2.default, + "modules/history": _history2.default, + "modules/keyboard": _keyboard2.default + }); + + _parchment2.default.register( + _block2.default, + _break2.default, + _cursor2.default, + _inline2.default, + _scroll2.default, + _text2.default + ); + + module.exports = _quill2.default; + + /***/ + }, + /* 2 */ + /***/ function(module, exports, __webpack_require__) { + "use strict"; + var container_1 = __webpack_require__(3); + var format_1 = __webpack_require__(7); + var leaf_1 = __webpack_require__(12); + var scroll_1 = __webpack_require__(13); + var inline_1 = __webpack_require__(14); + var block_1 = __webpack_require__(15); + var embed_1 = __webpack_require__(16); + var text_1 = __webpack_require__(17); + var attributor_1 = __webpack_require__(8); + var class_1 = __webpack_require__(10); + var style_1 = __webpack_require__(11); + var store_1 = __webpack_require__(9); + var Registry = __webpack_require__(6); + var Parchment = { + Scope: Registry.Scope, + create: Registry.create, + find: Registry.find, + query: Registry.query, + register: Registry.register, + Container: container_1.default, + Format: format_1.default, + Leaf: leaf_1.default, + Embed: embed_1.default, + Scroll: scroll_1.default, + Block: block_1.default, + Inline: inline_1.default, + Text: text_1.default, + Attributor: { + Attribute: attributor_1.default, + Class: class_1.default, + Style: style_1.default, + Store: store_1.default + } + }; + Object.defineProperty(exports, "__esModule", { value: true }); + exports.default = Parchment; + + /***/ + }, + /* 3 */ + /***/ function(module, exports, __webpack_require__) { + "use strict"; + var __extends = + (this && this.__extends) || + function(d, b) { + for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; + function __() { + this.constructor = d; + } + d.prototype = b === null ? Object.create(b) : ((__.prototype = b.prototype), new __()); + }; + var linked_list_1 = __webpack_require__(4); + var shadow_1 = __webpack_require__(5); + var Registry = __webpack_require__(6); + var ContainerBlot = (function(_super) { + __extends(ContainerBlot, _super); + function ContainerBlot() { + _super.apply(this, arguments); + } + ContainerBlot.prototype.appendChild = function(other) { + this.insertBefore(other); + }; + ContainerBlot.prototype.attach = function() { + var _this = this; + _super.prototype.attach.call(this); + this.children = new linked_list_1.default(); + // Need to be reversed for if DOM nodes already in order + [].slice + .call(this.domNode.childNodes) + .reverse() + .forEach(function(node) { + try { + var child = makeBlot(node); + _this.insertBefore(child, _this.children.head); + } catch (err) { + if (err instanceof Registry.ParchmentError) return; + else throw err; + } + }); + }; + ContainerBlot.prototype.deleteAt = function(index, length) { + if (index === 0 && length === this.length()) { + return this.remove(); + } + this.children.forEachAt(index, length, function(child, offset, length) { + child.deleteAt(offset, length); + }); + }; + ContainerBlot.prototype.descendant = function(criteria, index) { + var _a = this.children.find(index), + child = _a[0], + offset = _a[1]; + if ( + (criteria.blotName == null && criteria(child)) || + (criteria.blotName != null && child instanceof criteria) + ) { + return [child, offset]; + } else if (child instanceof ContainerBlot) { + return child.descendant(criteria, offset); + } else { + return [null, -1]; + } + }; + ContainerBlot.prototype.descendants = function(criteria, index, length) { + if (index === void 0) { + index = 0; + } + if (length === void 0) { + length = Number.MAX_VALUE; + } + var descendants = [], + lengthLeft = length; + this.children.forEachAt(index, length, function(child, index, length) { + if ( + (criteria.blotName == null && criteria(child)) || + (criteria.blotName != null && child instanceof criteria) + ) { + descendants.push(child); + } + if (child instanceof ContainerBlot) { + descendants = descendants.concat(child.descendants(criteria, index, lengthLeft)); + } + lengthLeft -= length; + }); + return descendants; + }; + ContainerBlot.prototype.detach = function() { + this.children.forEach(function(child) { + child.detach(); + }); + _super.prototype.detach.call(this); + }; + ContainerBlot.prototype.formatAt = function(index, length, name, value) { + this.children.forEachAt(index, length, function(child, offset, length) { + child.formatAt(offset, length, name, value); + }); + }; + ContainerBlot.prototype.insertAt = function(index, value, def) { + var _a = this.children.find(index), + child = _a[0], + offset = _a[1]; + if (child) { + child.insertAt(offset, value, def); + } else { + var blot = def == null ? Registry.create("text", value) : Registry.create(value, def); + this.appendChild(blot); + } + }; + ContainerBlot.prototype.insertBefore = function(childBlot, refBlot) { + if ( + this.statics.allowedChildren != null && + !this.statics.allowedChildren.some(function(child) { + return childBlot instanceof child; + }) + ) { + throw new Registry.ParchmentError( + "Cannot insert " + childBlot.statics.blotName + " into " + this.statics.blotName + ); + } + childBlot.insertInto(this, refBlot); + }; + ContainerBlot.prototype.length = function() { + return this.children.reduce(function(memo, child) { + return memo + child.length(); + }, 0); + }; + ContainerBlot.prototype.moveChildren = function(targetParent, refNode) { + this.children.forEach(function(child) { + targetParent.insertBefore(child, refNode); + }); + }; + ContainerBlot.prototype.optimize = function() { + _super.prototype.optimize.call(this); + if (this.children.length === 0) { + if (this.statics.defaultChild != null) { + var child = Registry.create(this.statics.defaultChild); + this.appendChild(child); + child.optimize(); + } else { + this.remove(); + } + } + }; + ContainerBlot.prototype.path = function(index, inclusive) { + if (inclusive === void 0) { + inclusive = false; + } + var _a = this.children.find(index, inclusive), + child = _a[0], + offset = _a[1]; + var position = [[this, index]]; + if (child instanceof ContainerBlot) { + return position.concat(child.path(offset, inclusive)); + } else if (child != null) { + position.push([child, offset]); + } + return position; + }; + ContainerBlot.prototype.removeChild = function(child) { + this.children.remove(child); + }; + ContainerBlot.prototype.replace = function(target) { + if (target instanceof ContainerBlot) { + target.moveChildren(this); + } + _super.prototype.replace.call(this, target); + }; + ContainerBlot.prototype.split = function(index, force) { + if (force === void 0) { + force = false; + } + if (!force) { + if (index === 0) return this; + if (index === this.length()) return this.next; + } + var after = this.clone(); + this.parent.insertBefore(after, this.next); + this.children.forEachAt(index, this.length(), function(child, offset, length) { + child = child.split(offset, force); + after.appendChild(child); + }); + return after; + }; + ContainerBlot.prototype.unwrap = function() { + this.moveChildren(this.parent, this.next); + this.remove(); + }; + ContainerBlot.prototype.update = function(mutations) { + var _this = this; + var addedNodes = [], + removedNodes = []; + mutations.forEach(function(mutation) { + if (mutation.target === _this.domNode && mutation.type === "childList") { + addedNodes.push.apply(addedNodes, mutation.addedNodes); + removedNodes.push.apply(removedNodes, mutation.removedNodes); + } + }); + removedNodes.forEach(function(node) { + var blot = Registry.find(node); + if (blot == null) return; + if (blot.domNode.parentNode == null || blot.domNode.parentNode === _this.domNode) { + blot.detach(); + } + }); + addedNodes + .filter(function(node) { + return node.parentNode == _this.domNode; + }) + .sort(function(a, b) { + if (a === b) return 0; + if (a.compareDocumentPosition(b) & Node.DOCUMENT_POSITION_FOLLOWING) { + return 1; + } + return -1; + }) + .forEach(function(node) { + var refBlot = null; + if (node.nextSibling != null) { + refBlot = Registry.find(node.nextSibling); + } + var blot = makeBlot(node); + if (blot.next != refBlot || blot.next == null) { + if (blot.parent != null) { + blot.parent.removeChild(_this); + } + _this.insertBefore(blot, refBlot); + } + }); + }; + return ContainerBlot; + })(shadow_1.default); + function makeBlot(node) { + var blot = Registry.find(node); + if (blot == null) { + try { + blot = Registry.create(node); + } catch (e) { + blot = Registry.create(Registry.Scope.INLINE); + [].slice.call(node.childNodes).forEach(function(child) { + blot.domNode.appendChild(child); + }); + node.parentNode.replaceChild(blot.domNode, node); + blot.attach(); + } + } + return blot; + } + Object.defineProperty(exports, "__esModule", { value: true }); + exports.default = ContainerBlot; + + /***/ + }, + /* 4 */ + /***/ function(module, exports) { + "use strict"; + var LinkedList = (function() { + function LinkedList() { + this.head = this.tail = undefined; + this.length = 0; + } + LinkedList.prototype.append = function() { + var nodes = []; + for (var _i = 0; _i < arguments.length; _i++) { + nodes[_i - 0] = arguments[_i]; + } + this.insertBefore(nodes[0], undefined); + if (nodes.length > 1) { + this.append.apply(this, nodes.slice(1)); + } + }; + LinkedList.prototype.contains = function(node) { + var cur, + next = this.iterator(); + while ((cur = next())) { + if (cur === node) return true; + } + return false; + }; + LinkedList.prototype.insertBefore = function(node, refNode) { + node.next = refNode; + if (refNode != null) { + node.prev = refNode.prev; + if (refNode.prev != null) { + refNode.prev.next = node; + } + refNode.prev = node; + if (refNode === this.head) { + this.head = node; + } + } else if (this.tail != null) { + this.tail.next = node; + node.prev = this.tail; + this.tail = node; + } else { + node.prev = undefined; + this.head = this.tail = node; + } + this.length += 1; + }; + LinkedList.prototype.offset = function(target) { + var index = 0, + cur = this.head; + while (cur != null) { + if (cur === target) return index; + index += cur.length(); + cur = cur.next; + } + return -1; + }; + LinkedList.prototype.remove = function(node) { + if (!this.contains(node)) return; + if (node.prev != null) node.prev.next = node.next; + if (node.next != null) node.next.prev = node.prev; + if (node === this.head) this.head = node.next; + if (node === this.tail) this.tail = node.prev; + this.length -= 1; + }; + LinkedList.prototype.iterator = function(curNode) { + if (curNode === void 0) { + curNode = this.head; + } + // TODO use yield when we can + return function() { + var ret = curNode; + if (curNode != null) curNode = curNode.next; + return ret; + }; + }; + LinkedList.prototype.find = function(index, inclusive) { + if (inclusive === void 0) { + inclusive = false; + } + var cur, + next = this.iterator(); + while ((cur = next())) { + var length_1 = cur.length(); + if ( + index < length_1 || + (inclusive && index === length_1 && (cur.next == null || cur.next.length() !== 0)) + ) { + return [cur, index]; + } + index -= length_1; + } + return [null, 0]; + }; + LinkedList.prototype.forEach = function(callback) { + var cur, + next = this.iterator(); + while ((cur = next())) { + callback(cur); + } + }; + LinkedList.prototype.forEachAt = function(index, length, callback) { + if (length <= 0) return; + var _a = this.find(index), + startNode = _a[0], + offset = _a[1]; + var cur, + curIndex = index - offset, + next = this.iterator(startNode); + while ((cur = next()) && curIndex < index + length) { + var curLength = cur.length(); + if (index > curIndex) { + callback(cur, index - curIndex, Math.min(length, curIndex + curLength - index)); + } else { + callback(cur, 0, Math.min(curLength, index + length - curIndex)); + } + curIndex += curLength; + } + }; + LinkedList.prototype.map = function(callback) { + return this.reduce(function(memo, cur) { + memo.push(callback(cur)); + return memo; + }, []); + }; + LinkedList.prototype.reduce = function(callback, memo) { + var cur, + next = this.iterator(); + while ((cur = next())) { + memo = callback(memo, cur); + } + return memo; + }; + return LinkedList; + })(); + Object.defineProperty(exports, "__esModule", { value: true }); + exports.default = LinkedList; + + /***/ + }, + /* 5 */ + /***/ function(module, exports, __webpack_require__) { + "use strict"; + var Registry = __webpack_require__(6); + var ShadowBlot = (function() { + function ShadowBlot(domNode) { + this.domNode = domNode; + this.attach(); + } + Object.defineProperty(ShadowBlot.prototype, "statics", { + // Hack for accessing inherited static methods + get: function() { + return this.constructor; + }, + enumerable: true, + configurable: true + }); + ShadowBlot.create = function(value) { + if (this.tagName == null) { + throw new Registry.ParchmentError("Blot definition missing tagName"); + } + var node; + if (Array.isArray(this.tagName)) { + if (typeof value === "string") { + value = value.toUpperCase(); + if (parseInt(value).toString() === value) { + value = parseInt(value); + } + } + if (typeof value === "number") { + node = document.createElement(this.tagName[value - 1]); + } else if (this.tagName.indexOf(value) > -1) { + node = document.createElement(value); + } else { + node = document.createElement(this.tagName[0]); + } + } else { + node = document.createElement(this.tagName); + } + if (this.className) { + node.classList.add(this.className); + } + return node; + }; + ShadowBlot.prototype.attach = function() { + this.domNode[Registry.DATA_KEY] = { blot: this }; + }; + ShadowBlot.prototype.clone = function() { + var domNode = this.domNode.cloneNode(); + return Registry.create(domNode); + }; + ShadowBlot.prototype.detach = function() { + if (this.parent != null) this.parent.removeChild(this); + delete this.domNode[Registry.DATA_KEY]; + }; + ShadowBlot.prototype.deleteAt = function(index, length) { + var blot = this.isolate(index, length); + blot.remove(); + }; + ShadowBlot.prototype.formatAt = function(index, length, name, value) { + var blot = this.isolate(index, length); + if (Registry.query(name, Registry.Scope.BLOT) != null && value) { + blot.wrap(name, value); + } else if (Registry.query(name, Registry.Scope.ATTRIBUTE) != null) { + var parent_1 = Registry.create(this.statics.scope); + blot.wrap(parent_1); + parent_1.format(name, value); + } + }; + ShadowBlot.prototype.insertAt = function(index, value, def) { + var blot = def == null ? Registry.create("text", value) : Registry.create(value, def); + var ref = this.split(index); + this.parent.insertBefore(blot, ref); + }; + ShadowBlot.prototype.insertInto = function(parentBlot, refBlot) { + if (this.parent != null) { + this.parent.children.remove(this); + } + parentBlot.children.insertBefore(this, refBlot); + if (refBlot != null) { + var refDomNode = refBlot.domNode; + } + if (this.next == null || this.domNode.nextSibling != refDomNode) { + parentBlot.domNode.insertBefore(this.domNode, refDomNode); + } + this.parent = parentBlot; + }; + ShadowBlot.prototype.isolate = function(index, length) { + var target = this.split(index); + target.split(length); + return target; + }; + ShadowBlot.prototype.length = function() { + return 1; + }; + ShadowBlot.prototype.offset = function(root) { + if (root === void 0) { + root = this.parent; + } + if (this.parent == null || this == root) return 0; + return this.parent.children.offset(this) + this.parent.offset(root); + }; + ShadowBlot.prototype.optimize = function() { + // TODO clean up once we use WeakMap + if (this.domNode[Registry.DATA_KEY] != null) { + delete this.domNode[Registry.DATA_KEY].mutations; + } + }; + ShadowBlot.prototype.remove = function() { + if (this.domNode.parentNode != null) { + this.domNode.parentNode.removeChild(this.domNode); + } + this.detach(); + }; + ShadowBlot.prototype.replace = function(target) { + if (target.parent == null) return; + target.parent.insertBefore(this, target.next); + target.remove(); + }; + ShadowBlot.prototype.replaceWith = function(name, value) { + var replacement = typeof name === "string" ? Registry.create(name, value) : name; + replacement.replace(this); + return replacement; + }; + ShadowBlot.prototype.split = function(index, force) { + return index === 0 ? this : this.next; + }; + ShadowBlot.prototype.update = function(mutations) { + if (mutations === void 0) { + mutations = []; + } + // Nothing to do by default + }; + ShadowBlot.prototype.wrap = function(name, value) { + var wrapper = typeof name === "string" ? Registry.create(name, value) : name; + if (this.parent != null) { + this.parent.insertBefore(wrapper, this.next); + } + wrapper.appendChild(this); + return wrapper; + }; + ShadowBlot.blotName = "abstract"; + return ShadowBlot; + })(); + Object.defineProperty(exports, "__esModule", { value: true }); + exports.default = ShadowBlot; + + /***/ + }, + /* 6 */ + /***/ function(module, exports) { + "use strict"; + var __extends = + (this && this.__extends) || + function(d, b) { + for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; + function __() { + this.constructor = d; + } + d.prototype = b === null ? Object.create(b) : ((__.prototype = b.prototype), new __()); + }; + var ParchmentError = (function(_super) { + __extends(ParchmentError, _super); + function ParchmentError(message) { + message = "[Parchment] " + message; + _super.call(this, message); + this.message = message; + this.name = this.constructor.name; + } + return ParchmentError; + })(Error); + exports.ParchmentError = ParchmentError; + var attributes = {}; + var classes = {}; + var tags = {}; + var types = {}; + exports.DATA_KEY = "__blot"; + (function(Scope) { + Scope[(Scope["TYPE"] = 3)] = "TYPE"; + Scope[(Scope["LEVEL"] = 12)] = "LEVEL"; + Scope[(Scope["ATTRIBUTE"] = 13)] = "ATTRIBUTE"; + Scope[(Scope["BLOT"] = 14)] = "BLOT"; + Scope[(Scope["INLINE"] = 7)] = "INLINE"; + Scope[(Scope["BLOCK"] = 11)] = "BLOCK"; + Scope[(Scope["BLOCK_BLOT"] = 10)] = "BLOCK_BLOT"; + Scope[(Scope["INLINE_BLOT"] = 6)] = "INLINE_BLOT"; + Scope[(Scope["BLOCK_ATTRIBUTE"] = 9)] = "BLOCK_ATTRIBUTE"; + Scope[(Scope["INLINE_ATTRIBUTE"] = 5)] = "INLINE_ATTRIBUTE"; + Scope[(Scope["ANY"] = 15)] = "ANY"; + })(exports.Scope || (exports.Scope = {})); + var Scope = exports.Scope; + function create(input, value) { + var match = query(input); + if (match == null) { + throw new ParchmentError("Unable to create " + input + " blot"); + } + var BlotClass = match; + var node = input instanceof Node ? input : BlotClass.create(value); + return new BlotClass(node, value); + } + exports.create = create; + function find(node, bubble) { + if (bubble === void 0) { + bubble = false; + } + if (node == null) return null; + if (node[exports.DATA_KEY] != null) return node[exports.DATA_KEY].blot; + if (bubble) return find(node.parentNode, bubble); + return null; + } + exports.find = find; + function query(query, scope) { + if (scope === void 0) { + scope = Scope.ANY; + } + var match; + if (typeof query === "string") { + match = types[query] || attributes[query]; + } else if (query instanceof Text) { + match = types["text"]; + } else if (typeof query === "number") { + if (query & Scope.LEVEL & Scope.BLOCK) { + match = types["block"]; + } else if (query & Scope.LEVEL & Scope.INLINE) { + match = types["inline"]; + } + } else if (query instanceof HTMLElement) { + var names = (query.getAttribute("class") || "").split(/\s+/); + for (var i in names) { + match = classes[names[i]]; + if (match) break; + } + match = match || tags[query.tagName]; + } + if (match == null) return null; + if (scope & Scope.LEVEL & match.scope && scope & Scope.TYPE & match.scope) return match; + return null; + } + exports.query = query; + function register() { + var Definitions = []; + for (var _i = 0; _i < arguments.length; _i++) { + Definitions[_i - 0] = arguments[_i]; + } + if (Definitions.length > 1) { + return Definitions.map(function(d) { + return register(d); + }); + } + var Definition = Definitions[0]; + if (typeof Definition.blotName !== "string" && typeof Definition.attrName !== "string") { + throw new ParchmentError("Invalid definition"); + } else if (Definition.blotName === "abstract") { + throw new ParchmentError("Cannot register abstract class"); + } + types[Definition.blotName || Definition.attrName] = Definition; + if (typeof Definition.keyName === "string") { + attributes[Definition.keyName] = Definition; + } else { + if (Definition.className != null) { + classes[Definition.className] = Definition; + } + if (Definition.tagName != null) { + if (Array.isArray(Definition.tagName)) { + Definition.tagName = Definition.tagName.map(function(tagName) { + return tagName.toUpperCase(); + }); + } else { + Definition.tagName = Definition.tagName.toUpperCase(); + } + var tagNames = Array.isArray(Definition.tagName) + ? Definition.tagName + : [Definition.tagName]; + tagNames.forEach(function(tag) { + if (tags[tag] == null || Definition.className == null) { + tags[tag] = Definition; + } + }); + } + } + return Definition; + } + exports.register = register; + + /***/ + }, + /* 7 */ + /***/ function(module, exports, __webpack_require__) { + "use strict"; + var __extends = + (this && this.__extends) || + function(d, b) { + for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; + function __() { + this.constructor = d; + } + d.prototype = b === null ? Object.create(b) : ((__.prototype = b.prototype), new __()); + }; + var attributor_1 = __webpack_require__(8); + var store_1 = __webpack_require__(9); + var container_1 = __webpack_require__(3); + var Registry = __webpack_require__(6); + var FormatBlot = (function(_super) { + __extends(FormatBlot, _super); + function FormatBlot() { + _super.apply(this, arguments); + } + FormatBlot.formats = function(domNode) { + if (typeof this.tagName === "string") { + return true; + } else if (Array.isArray(this.tagName)) { + return domNode.tagName.toLowerCase(); + } + return undefined; + }; + FormatBlot.prototype.attach = function() { + _super.prototype.attach.call(this); + this.attributes = new store_1.default(this.domNode); + }; + FormatBlot.prototype.format = function(name, value) { + var format = Registry.query(name); + if (format instanceof attributor_1.default) { + this.attributes.attribute(format, value); + } else if (value) { + if ( + format != null && + (name !== this.statics.blotName || this.formats()[name] !== value) + ) { + this.replaceWith(name, value); + } + } + }; + FormatBlot.prototype.formats = function() { + var formats = this.attributes.values(); + var format = this.statics.formats(this.domNode); + if (format != null) { + formats[this.statics.blotName] = format; + } + return formats; + }; + FormatBlot.prototype.replaceWith = function(name, value) { + var replacement = _super.prototype.replaceWith.call(this, name, value); + this.attributes.copy(replacement); + return replacement; + }; + FormatBlot.prototype.update = function(mutations) { + var _this = this; + _super.prototype.update.call(this, mutations); + if ( + mutations.some(function(mutation) { + return mutation.target === _this.domNode && mutation.type === "attributes"; + }) + ) { + this.attributes.build(); + } + }; + FormatBlot.prototype.wrap = function(name, value) { + var wrapper = _super.prototype.wrap.call(this, name, value); + if (wrapper instanceof FormatBlot && wrapper.statics.scope === this.statics.scope) { + this.attributes.move(wrapper); + } + return wrapper; + }; + return FormatBlot; + })(container_1.default); + Object.defineProperty(exports, "__esModule", { value: true }); + exports.default = FormatBlot; + + /***/ + }, + /* 8 */ + /***/ function(module, exports, __webpack_require__) { + "use strict"; + var Registry = __webpack_require__(6); + var Attributor = (function() { + function Attributor(attrName, keyName, options) { + if (options === void 0) { + options = {}; + } + this.attrName = attrName; + this.keyName = keyName; + var attributeBit = Registry.Scope.TYPE & Registry.Scope.ATTRIBUTE; + if (options.scope != null) { + // Ignore type bits, force attribute bit + this.scope = (options.scope & Registry.Scope.LEVEL) | attributeBit; + } else { + this.scope = Registry.Scope.ATTRIBUTE; + } + if (options.whitelist != null) this.whitelist = options.whitelist; + } + Attributor.keys = function(node) { + return [].map.call(node.attributes, function(item) { + return item.name; + }); + }; + Attributor.prototype.add = function(node, value) { + if (!this.canAdd(node, value)) return false; + node.setAttribute(this.keyName, value); + return true; + }; + Attributor.prototype.canAdd = function(node, value) { + var match = Registry.query( + node, + Registry.Scope.BLOT & (this.scope | Registry.Scope.TYPE) + ); + if (match != null && (this.whitelist == null || this.whitelist.indexOf(value) > -1)) { + return true; + } + return false; + }; + Attributor.prototype.remove = function(node) { + node.removeAttribute(this.keyName); + }; + Attributor.prototype.value = function(node) { + return node.getAttribute(this.keyName); + }; + return Attributor; + })(); + Object.defineProperty(exports, "__esModule", { value: true }); + exports.default = Attributor; + + /***/ + }, + /* 9 */ + /***/ function(module, exports, __webpack_require__) { + "use strict"; + var attributor_1 = __webpack_require__(8); + var class_1 = __webpack_require__(10); + var style_1 = __webpack_require__(11); + var Registry = __webpack_require__(6); + var AttributorStore = (function() { + function AttributorStore(domNode) { + this.attributes = {}; + this.domNode = domNode; + this.build(); + } + AttributorStore.prototype.attribute = function(attribute, value) { + if (value) { + if (attribute.add(this.domNode, value)) { + if (attribute.value(this.domNode) != null) { + this.attributes[attribute.attrName] = attribute; + } else { + delete this.attributes[attribute.attrName]; + } + } + } else { + attribute.remove(this.domNode); + delete this.attributes[attribute.attrName]; + } + }; + AttributorStore.prototype.build = function() { + var _this = this; + this.attributes = {}; + var attributes = attributor_1.default.keys(this.domNode); + var classes = class_1.default.keys(this.domNode); + var styles = style_1.default.keys(this.domNode); + attributes + .concat(classes) + .concat(styles) + .forEach(function(name) { + var attr = Registry.query(name, Registry.Scope.ATTRIBUTE); + if (attr instanceof attributor_1.default) { + _this.attributes[attr.attrName] = attr; + } + }); + }; + AttributorStore.prototype.copy = function(target) { + var _this = this; + Object.keys(this.attributes).forEach(function(key) { + var value = _this.attributes[key].value(_this.domNode); + target.format(key, value); + }); + }; + AttributorStore.prototype.move = function(target) { + var _this = this; + this.copy(target); + Object.keys(this.attributes).forEach(function(key) { + _this.attributes[key].remove(_this.domNode); + }); + this.attributes = {}; + }; + AttributorStore.prototype.values = function() { + var _this = this; + return Object.keys(this.attributes).reduce(function(attributes, name) { + attributes[name] = _this.attributes[name].value(_this.domNode); + return attributes; + }, {}); + }; + return AttributorStore; + })(); + Object.defineProperty(exports, "__esModule", { value: true }); + exports.default = AttributorStore; + + /***/ + }, + /* 10 */ + /***/ function(module, exports, __webpack_require__) { + "use strict"; + var __extends = + (this && this.__extends) || + function(d, b) { + for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; + function __() { + this.constructor = d; + } + d.prototype = b === null ? Object.create(b) : ((__.prototype = b.prototype), new __()); + }; + var attributor_1 = __webpack_require__(8); + function match(node, prefix) { + var className = node.getAttribute("class") || ""; + return className.split(/\s+/).filter(function(name) { + return name.indexOf(prefix + "-") === 0; + }); + } + var ClassAttributor = (function(_super) { + __extends(ClassAttributor, _super); + function ClassAttributor() { + _super.apply(this, arguments); + } + ClassAttributor.keys = function(node) { + return (node.getAttribute("class") || "").split(/\s+/).map(function(name) { + return name + .split("-") + .slice(0, -1) + .join("-"); + }); + }; + ClassAttributor.prototype.add = function(node, value) { + if (!this.canAdd(node, value)) return false; + this.remove(node); + node.classList.add(this.keyName + "-" + value); + return true; + }; + ClassAttributor.prototype.remove = function(node) { + var matches = match(node, this.keyName); + matches.forEach(function(name) { + node.classList.remove(name); + }); + if (node.classList.length === 0) { + node.removeAttribute("class"); + } + }; + ClassAttributor.prototype.value = function(node) { + var result = match(node, this.keyName)[0] || ""; + return result.slice(this.keyName.length + 1); // +1 for hyphen + }; + return ClassAttributor; + })(attributor_1.default); + Object.defineProperty(exports, "__esModule", { value: true }); + exports.default = ClassAttributor; + + /***/ + }, + /* 11 */ + /***/ function(module, exports, __webpack_require__) { + "use strict"; + var __extends = + (this && this.__extends) || + function(d, b) { + for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; + function __() { + this.constructor = d; + } + d.prototype = b === null ? Object.create(b) : ((__.prototype = b.prototype), new __()); + }; + var attributor_1 = __webpack_require__(8); + function camelize(name) { + var parts = name.split("-"); + var rest = parts + .slice(1) + .map(function(part) { + return part[0].toUpperCase() + part.slice(1); + }) + .join(""); + return parts[0] + rest; + } + var StyleAttributor = (function(_super) { + __extends(StyleAttributor, _super); + function StyleAttributor() { + _super.apply(this, arguments); + } + StyleAttributor.keys = function(node) { + return (node.getAttribute("style") || "").split(";").map(function(value) { + var arr = value.split(":"); + return arr[0].trim(); + }); + }; + StyleAttributor.prototype.add = function(node, value) { + if (!this.canAdd(node, value)) return false; + node.style[camelize(this.keyName)] = value; + return true; + }; + StyleAttributor.prototype.remove = function(node) { + node.style[camelize(this.keyName)] = ""; + if (!node.getAttribute("style")) { + node.removeAttribute("style"); + } + }; + StyleAttributor.prototype.value = function(node) { + return node.style[camelize(this.keyName)]; + }; + return StyleAttributor; + })(attributor_1.default); + Object.defineProperty(exports, "__esModule", { value: true }); + exports.default = StyleAttributor; + + /***/ + }, + /* 12 */ + /***/ function(module, exports, __webpack_require__) { + "use strict"; + var __extends = + (this && this.__extends) || + function(d, b) { + for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; + function __() { + this.constructor = d; + } + d.prototype = b === null ? Object.create(b) : ((__.prototype = b.prototype), new __()); + }; + var shadow_1 = __webpack_require__(5); + var Registry = __webpack_require__(6); + var LeafBlot = (function(_super) { + __extends(LeafBlot, _super); + function LeafBlot() { + _super.apply(this, arguments); + } + LeafBlot.value = function(domNode) { + return true; + }; + LeafBlot.prototype.index = function(node, offset) { + if (node !== this.domNode) return -1; + return Math.min(offset, 1); + }; + LeafBlot.prototype.position = function(index, inclusive) { + var offset = [].indexOf.call(this.parent.domNode.childNodes, this.domNode); + if (index > 0) offset += 1; + return [this.parent.domNode, offset]; + }; + LeafBlot.prototype.value = function() { + return ( + (_a = {}), (_a[this.statics.blotName] = this.statics.value(this.domNode) || true), _a + ); + var _a; + }; + LeafBlot.scope = Registry.Scope.INLINE_BLOT; + return LeafBlot; + })(shadow_1.default); + Object.defineProperty(exports, "__esModule", { value: true }); + exports.default = LeafBlot; + + /***/ + }, + /* 13 */ + /***/ function(module, exports, __webpack_require__) { + "use strict"; + var __extends = + (this && this.__extends) || + function(d, b) { + for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; + function __() { + this.constructor = d; + } + d.prototype = b === null ? Object.create(b) : ((__.prototype = b.prototype), new __()); + }; + var container_1 = __webpack_require__(3); + var Registry = __webpack_require__(6); + var OBSERVER_CONFIG = { + attributes: true, + characterData: true, + characterDataOldValue: true, + childList: true, + subtree: true + }; + var MAX_OPTIMIZE_ITERATIONS = 100; + var ScrollBlot = (function(_super) { + __extends(ScrollBlot, _super); + function ScrollBlot(node) { + var _this = this; + _super.call(this, node); + this.parent = null; + this.observer = new MutationObserver(function(mutations) { + _this.update(mutations); + }); + this.observer.observe(this.domNode, OBSERVER_CONFIG); + } + ScrollBlot.prototype.detach = function() { + _super.prototype.detach.call(this); + this.observer.disconnect(); + }; + ScrollBlot.prototype.deleteAt = function(index, length) { + this.update(); + if (index === 0 && length === this.length()) { + this.children.forEach(function(child) { + child.remove(); + }); + } else { + _super.prototype.deleteAt.call(this, index, length); + } + }; + ScrollBlot.prototype.formatAt = function(index, length, name, value) { + this.update(); + _super.prototype.formatAt.call(this, index, length, name, value); + }; + ScrollBlot.prototype.insertAt = function(index, value, def) { + this.update(); + _super.prototype.insertAt.call(this, index, value, def); + }; + ScrollBlot.prototype.optimize = function(mutations) { + var _this = this; + if (mutations === void 0) { + mutations = []; + } + _super.prototype.optimize.call(this); + mutations.push.apply(mutations, this.observer.takeRecords()); + // TODO use WeakMap + var mark = function(blot, markParent) { + if (markParent === void 0) { + markParent = true; + } + if (blot == null || blot === _this) return; + if (blot.domNode.parentNode == null) return; + if (blot.domNode[Registry.DATA_KEY].mutations == null) { + blot.domNode[Registry.DATA_KEY].mutations = []; + } + if (markParent) mark(blot.parent); + }; + var optimize = function(blot) { + if ( + blot.domNode[Registry.DATA_KEY] == null || + blot.domNode[Registry.DATA_KEY].mutations == null + ) { + return; + } + if (blot instanceof container_1.default) { + blot.children.forEach(optimize); + } + blot.optimize(); + }; + var remaining = mutations; + for (var i = 0; remaining.length > 0; i += 1) { + if (i >= MAX_OPTIMIZE_ITERATIONS) { + throw new Error("[Parchment] Maximum optimize iterations reached"); + } + remaining.forEach(function(mutation) { + var blot = Registry.find(mutation.target, true); + if (blot == null) return; + if (blot.domNode === mutation.target) { + if (mutation.type === "childList") { + mark(Registry.find(mutation.previousSibling, false)); + [].forEach.call(mutation.addedNodes, function(node) { + var child = Registry.find(node, false); + mark(child, false); + if (child instanceof container_1.default) { + child.children.forEach(function(grandChild) { + mark(grandChild, false); + }); + } + }); + } else if (mutation.type === "attributes") { + mark(blot.prev); + } + } + mark(blot); + }); + this.children.forEach(optimize); + remaining = this.observer.takeRecords(); + mutations.push.apply(mutations, remaining); + } + }; + ScrollBlot.prototype.update = function(mutations) { + var _this = this; + mutations = mutations || this.observer.takeRecords(); + // TODO use WeakMap + mutations + .map(function(mutation) { + var blot = Registry.find(mutation.target, true); + if (blot == null) return; + if (blot.domNode[Registry.DATA_KEY].mutations == null) { + blot.domNode[Registry.DATA_KEY].mutations = [mutation]; + return blot; + } else { + blot.domNode[Registry.DATA_KEY].mutations.push(mutation); + return null; + } + }) + .forEach(function(blot) { + if (blot == null || blot === _this) return; + blot.update(blot.domNode[Registry.DATA_KEY].mutations || []); + }); + if (this.domNode[Registry.DATA_KEY].mutations != null) { + _super.prototype.update.call(this, this.domNode[Registry.DATA_KEY].mutations); + } + this.optimize(mutations); + }; + ScrollBlot.blotName = "scroll"; + ScrollBlot.defaultChild = "block"; + ScrollBlot.scope = Registry.Scope.BLOCK_BLOT; + ScrollBlot.tagName = "DIV"; + return ScrollBlot; + })(container_1.default); + Object.defineProperty(exports, "__esModule", { value: true }); + exports.default = ScrollBlot; + + /***/ + }, + /* 14 */ + /***/ function(module, exports, __webpack_require__) { + "use strict"; + var __extends = + (this && this.__extends) || + function(d, b) { + for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; + function __() { + this.constructor = d; + } + d.prototype = b === null ? Object.create(b) : ((__.prototype = b.prototype), new __()); + }; + var format_1 = __webpack_require__(7); + var Registry = __webpack_require__(6); + // Shallow object comparison + function isEqual(obj1, obj2) { + if (Object.keys(obj1).length !== Object.keys(obj2).length) return false; + for (var prop in obj1) { + if (obj1[prop] !== obj2[prop]) return false; + } + return true; + } + var InlineBlot = (function(_super) { + __extends(InlineBlot, _super); + function InlineBlot() { + _super.apply(this, arguments); + } + InlineBlot.formats = function(domNode) { + if (domNode.tagName === InlineBlot.tagName) return undefined; + return _super.formats.call(this, domNode); + }; + InlineBlot.prototype.format = function(name, value) { + var _this = this; + if (name === this.statics.blotName && !value) { + this.children.forEach(function(child) { + if (!(child instanceof format_1.default)) { + child = child.wrap(InlineBlot.blotName, true); + } + _this.attributes.copy(child); + }); + this.unwrap(); + } else { + _super.prototype.format.call(this, name, value); + } + }; + InlineBlot.prototype.formatAt = function(index, length, name, value) { + if (this.formats()[name] != null || Registry.query(name, Registry.Scope.ATTRIBUTE)) { + var blot = this.isolate(index, length); + blot.format(name, value); + } else { + _super.prototype.formatAt.call(this, index, length, name, value); + } + }; + InlineBlot.prototype.optimize = function() { + _super.prototype.optimize.call(this); + var formats = this.formats(); + if (Object.keys(formats).length === 0) { + return this.unwrap(); // unformatted span + } + var next = this.next; + if ( + next instanceof InlineBlot && + next.prev === this && + isEqual(formats, next.formats()) + ) { + next.moveChildren(this); + next.remove(); + } + }; + InlineBlot.blotName = "inline"; + InlineBlot.scope = Registry.Scope.INLINE_BLOT; + InlineBlot.tagName = "SPAN"; + return InlineBlot; + })(format_1.default); + Object.defineProperty(exports, "__esModule", { value: true }); + exports.default = InlineBlot; + + /***/ + }, + /* 15 */ + /***/ function(module, exports, __webpack_require__) { + "use strict"; + var __extends = + (this && this.__extends) || + function(d, b) { + for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; + function __() { + this.constructor = d; + } + d.prototype = b === null ? Object.create(b) : ((__.prototype = b.prototype), new __()); + }; + var format_1 = __webpack_require__(7); + var Registry = __webpack_require__(6); + var BlockBlot = (function(_super) { + __extends(BlockBlot, _super); + function BlockBlot() { + _super.apply(this, arguments); + } + BlockBlot.formats = function(domNode) { + var tagName = Registry.query(BlockBlot.blotName).tagName; + if (domNode.tagName === tagName) return undefined; + return _super.formats.call(this, domNode); + }; + BlockBlot.prototype.format = function(name, value) { + if (Registry.query(name, Registry.Scope.BLOCK) == null) { + return; + } else if (name === this.statics.blotName && !value) { + this.replaceWith(BlockBlot.blotName); + } else { + _super.prototype.format.call(this, name, value); + } + }; + BlockBlot.prototype.formatAt = function(index, length, name, value) { + if (Registry.query(name, Registry.Scope.BLOCK) != null) { + this.format(name, value); + } else { + _super.prototype.formatAt.call(this, index, length, name, value); + } + }; + BlockBlot.prototype.insertAt = function(index, value, def) { + if (def == null || Registry.query(value, Registry.Scope.INLINE) != null) { + // Insert text or inline + _super.prototype.insertAt.call(this, index, value, def); + } else { + var after = this.split(index); + var blot = Registry.create(value, def); + after.parent.insertBefore(blot, after); + } + }; + BlockBlot.blotName = "block"; + BlockBlot.scope = Registry.Scope.BLOCK_BLOT; + BlockBlot.tagName = "P"; + return BlockBlot; + })(format_1.default); + Object.defineProperty(exports, "__esModule", { value: true }); + exports.default = BlockBlot; + + /***/ + }, + /* 16 */ + /***/ function(module, exports, __webpack_require__) { + "use strict"; + var __extends = + (this && this.__extends) || + function(d, b) { + for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; + function __() { + this.constructor = d; + } + d.prototype = b === null ? Object.create(b) : ((__.prototype = b.prototype), new __()); + }; + var leaf_1 = __webpack_require__(12); + var EmbedBlot = (function(_super) { + __extends(EmbedBlot, _super); + function EmbedBlot() { + _super.apply(this, arguments); + } + EmbedBlot.formats = function(domNode) { + return undefined; + }; + EmbedBlot.prototype.format = function(name, value) { + // super.formatAt wraps, which is what we want in general, + // but this allows subclasses to overwrite for formats + // that just apply to particular embeds + _super.prototype.formatAt.call(this, 0, this.length(), name, value); + }; + EmbedBlot.prototype.formatAt = function(index, length, name, value) { + if (index === 0 && length === this.length()) { + this.format(name, value); + } else { + _super.prototype.formatAt.call(this, index, length, name, value); + } + }; + EmbedBlot.prototype.formats = function() { + return this.statics.formats(this.domNode); + }; + return EmbedBlot; + })(leaf_1.default); + Object.defineProperty(exports, "__esModule", { value: true }); + exports.default = EmbedBlot; + + /***/ + }, + /* 17 */ + /***/ function(module, exports, __webpack_require__) { + "use strict"; + var __extends = + (this && this.__extends) || + function(d, b) { + for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; + function __() { + this.constructor = d; + } + d.prototype = b === null ? Object.create(b) : ((__.prototype = b.prototype), new __()); + }; + var leaf_1 = __webpack_require__(12); + var Registry = __webpack_require__(6); + var TextBlot = (function(_super) { + __extends(TextBlot, _super); + function TextBlot(node) { + _super.call(this, node); + this.text = this.statics.value(this.domNode); + } + TextBlot.create = function(value) { + return document.createTextNode(value); + }; + TextBlot.value = function(domNode) { + return domNode.data; + }; + TextBlot.prototype.deleteAt = function(index, length) { + this.domNode.data = this.text = + this.text.slice(0, index) + this.text.slice(index + length); + }; + TextBlot.prototype.index = function(node, offset) { + if (this.domNode === node) { + return offset; + } + return -1; + }; + TextBlot.prototype.insertAt = function(index, value, def) { + if (def == null) { + this.text = this.text.slice(0, index) + value + this.text.slice(index); + this.domNode.data = this.text; + } else { + _super.prototype.insertAt.call(this, index, value, def); + } + }; + TextBlot.prototype.length = function() { + return this.text.length; + }; + TextBlot.prototype.optimize = function() { + _super.prototype.optimize.call(this); + this.text = this.statics.value(this.domNode); + if (this.text.length === 0) { + this.remove(); + } else if (this.next instanceof TextBlot && this.next.prev === this) { + this.insertAt(this.length(), this.next.value()); + this.next.remove(); + } + }; + TextBlot.prototype.position = function(index, inclusive) { + if (inclusive === void 0) { + inclusive = false; + } + return [this.domNode, index]; + }; + TextBlot.prototype.split = function(index, force) { + if (force === void 0) { + force = false; + } + if (!force) { + if (index === 0) return this; + if (index === this.length()) return this.next; + } + var after = Registry.create(this.domNode.splitText(index)); + this.parent.insertBefore(after, this.next); + this.text = this.statics.value(this.domNode); + return after; + }; + TextBlot.prototype.update = function(mutations) { + var _this = this; + if ( + mutations.some(function(mutation) { + return mutation.type === "characterData" && mutation.target === _this.domNode; + }) + ) { + this.text = this.statics.value(this.domNode); + } + }; + TextBlot.prototype.value = function() { + return this.text; + }; + TextBlot.blotName = "text"; + TextBlot.scope = Registry.Scope.INLINE_BLOT; + return TextBlot; + })(leaf_1.default); + Object.defineProperty(exports, "__esModule", { value: true }); + exports.default = TextBlot; + + /***/ + }, + /* 18 */ + /***/ function(module, exports, __webpack_require__) { + "use strict"; + + Object.defineProperty(exports, "__esModule", { + value: true + }); + exports.default = exports.overload = exports.expandConfig = undefined; + + var _typeof = + typeof Symbol === "function" && typeof Symbol.iterator === "symbol" + ? function(obj) { + return typeof obj; + } + : function(obj) { + return obj && + typeof Symbol === "function" && + obj.constructor === Symbol && + obj !== Symbol.prototype + ? "symbol" + : typeof obj; + }; + + var _slicedToArray = (function() { + function sliceIterator(arr, i) { + var _arr = []; + var _n = true; + var _d = false; + var _e = undefined; + try { + for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { + _arr.push(_s.value); + if (i && _arr.length === i) break; + } + } catch (err) { + _d = true; + _e = err; + } finally { + try { + if (!_n && _i["return"]) _i["return"](); + } finally { + if (_d) throw _e; + } + } + return _arr; + } + return function(arr, i) { + if (Array.isArray(arr)) { + return arr; + } else if (Symbol.iterator in Object(arr)) { + return sliceIterator(arr, i); + } else { + throw new TypeError("Invalid attempt to destructure non-iterable instance"); + } + }; + })(); + + var _createClass = (function() { + function defineProperties(target, props) { + for (var i = 0; i < props.length; i++) { + var descriptor = props[i]; + descriptor.enumerable = descriptor.enumerable || false; + descriptor.configurable = true; + if ("value" in descriptor) descriptor.writable = true; + Object.defineProperty(target, descriptor.key, descriptor); + } + } + return function(Constructor, protoProps, staticProps) { + if (protoProps) defineProperties(Constructor.prototype, protoProps); + if (staticProps) defineProperties(Constructor, staticProps); + return Constructor; + }; + })(); + + __webpack_require__(19); + + var _delta = __webpack_require__(20); + + var _delta2 = _interopRequireDefault(_delta); + + var _editor = __webpack_require__(27); + + var _editor2 = _interopRequireDefault(_editor); + + var _emitter = __webpack_require__(28); + + var _emitter2 = _interopRequireDefault(_emitter); + + var _module = __webpack_require__(39); + + var _module2 = _interopRequireDefault(_module); + + var _parchment = __webpack_require__(2); + + var _parchment2 = _interopRequireDefault(_parchment); + + var _selection = __webpack_require__(40); + + var _selection2 = _interopRequireDefault(_selection); + + var _extend = __webpack_require__(25); + + var _extend2 = _interopRequireDefault(_extend); + + var _logger = __webpack_require__(30); + + var _logger2 = _interopRequireDefault(_logger); + + var _theme = __webpack_require__(41); + + var _theme2 = _interopRequireDefault(_theme); + + function _interopRequireDefault(obj) { + return obj && obj.__esModule ? obj : { default: obj }; + } + + function _classCallCheck(instance, Constructor) { + if (!(instance instanceof Constructor)) { + throw new TypeError("Cannot call a class as a function"); + } + } + + var debug = (0, _logger2.default)("quill"); + + var Quill = (function() { + _createClass(Quill, null, [ + { + key: "debug", + value: function debug(limit) { + _logger2.default.level(limit); + } + }, + { + key: "import", + value: function _import(name) { + if (this.imports[name] == null) { + debug.error("Cannot import " + name + ". Are you sure it was registered?"); + } + return this.imports[name]; + } + }, + { + key: "register", + value: function register(path, target) { + var _this = this; + + var overwrite = + arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false; + + if (typeof path !== "string") { + var name = path.attrName || path.blotName; + if (typeof name === "string") { + // register(Blot | Attributor, overwrite) + this.register("formats/" + name, path, target); + } else { + Object.keys(path).forEach(function(key) { + _this.register(key, path[key], target); + }); + } + } else { + if (this.imports[path] != null && !overwrite) { + debug.warn("Overwriting " + path + " with", target); + } + this.imports[path] = target; + if ( + (path.startsWith("blots/") || path.startsWith("formats/")) && + target.blotName !== "abstract" + ) { + _parchment2.default.register(target); + } + } + } + } + ]); + + function Quill(container) { + var _this2 = this; + + var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; + + _classCallCheck(this, Quill); + + options = expandConfig(container, options); + this.container = options.container; + if (this.container == null) { + return debug.error("Invalid Quill container", container); + } + if (options.debug) { + Quill.debug(options.debug); + } + var html = this.container.innerHTML.trim(); + this.container.classList.add("ql-container"); + this.container.innerHTML = ""; + this.root = this.addContainer("ql-editor"); + this.emitter = new _emitter2.default(); + this.scroll = _parchment2.default.create(this.root, { + emitter: this.emitter, + whitelist: options.formats + }); + this.editor = new _editor2.default(this.scroll, this.emitter); + this.selection = new _selection2.default(this.scroll, this.emitter); + this.theme = new options.theme(this, options); + this.keyboard = this.theme.addModule("keyboard"); + this.clipboard = this.theme.addModule("clipboard"); + this.history = this.theme.addModule("history"); + this.theme.init(); + var contents = this.clipboard.convert( + "
                    " + html + "


                    " + ); + this.setContents(contents); + this.history.clear(); + if (options.readOnly) { + this.disable(); + } + if (options.placeholder) { + this.root.setAttribute("data-placeholder", options.placeholder); + } + this.root.classList.toggle("ql-blank", this.editor.isBlank()); + this.emitter.on(_emitter2.default.events.TEXT_CHANGE, function(delta) { + _this2.root.classList.toggle("ql-blank", _this2.editor.isBlank()); + }); + } + + _createClass(Quill, [ + { + key: "addContainer", + value: function addContainer(container) { + var refNode = + arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null; + + if (typeof container === "string") { + var className = container; + container = document.createElement("div"); + container.classList.add(className); + } + this.container.insertBefore(container, refNode); + return container; + } + }, + { + key: "blur", + value: function blur() { + this.selection.setRange(null); + } + }, + { + key: "deleteText", + value: function deleteText(index, length, source) { + var _overload = overload(index, length, source); + + var _overload2 = _slicedToArray(_overload, 4); + + index = _overload2[0]; + length = _overload2[1]; + source = _overload2[3]; + + var range = this.getSelection(); + var change = this.editor.deleteText(index, length, source); + range = shiftRange(range, index, -1 * length, source); + this.setSelection(range, _emitter2.default.sources.SILENT); + return change; + } + }, + { + key: "disable", + value: function disable() { + this.enable(false); + } + }, + { + key: "enable", + value: function enable() { + var enabled = + arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true; + + this.editor.enable(enabled); + if (!enabled) { + this.blur(); + } + } + }, + { + key: "focus", + value: function focus() { + this.selection.focus(); + this.selection.scrollIntoView(); + } + }, + { + key: "format", + value: function format(name, value) { + var source = + arguments.length > 2 && arguments[2] !== undefined + ? arguments[2] + : _emitter2.default.sources.API; + + var range = this.getSelection(true); + var change = new _delta2.default(); + if (range == null) return change; + if (_parchment2.default.query(name, _parchment2.default.Scope.BLOCK)) { + change = this.formatLine(range, name, value, source); + } else if (range.length === 0) { + this.selection.format(name, value); + return change; + } else { + change = this.formatText(range, name, value, source); + } + this.setSelection(range, _emitter2.default.sources.SILENT); + return change; + } + }, + { + key: "formatLine", + value: function formatLine(index, length, name, value, source) { + var formats = void 0; + + var _overload3 = overload(index, length, name, value, source); + + var _overload4 = _slicedToArray(_overload3, 4); + + index = _overload4[0]; + length = _overload4[1]; + formats = _overload4[2]; + source = _overload4[3]; + + var range = this.getSelection(); + var change = this.editor.formatLine(index, length, formats, source); + this.selection.setRange(range, true, _emitter2.default.sources.SILENT); + this.selection.scrollIntoView(); + return change; + } + }, + { + key: "formatText", + value: function formatText(index, length, name, value, source) { + var formats = void 0; + + var _overload5 = overload(index, length, name, value, source); + + var _overload6 = _slicedToArray(_overload5, 4); + + index = _overload6[0]; + length = _overload6[1]; + formats = _overload6[2]; + source = _overload6[3]; + + var range = this.getSelection(); + var change = this.editor.formatText(index, length, formats, source); + this.selection.setRange(range, true, _emitter2.default.sources.SILENT); + this.selection.scrollIntoView(); + return change; + } + }, + { + key: "getBounds", + value: function getBounds(index) { + var length = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0; + + if (typeof index === "number") { + return this.selection.getBounds(index, length); + } else { + return this.selection.getBounds(index.index, index.length); + } + } + }, + { + key: "getContents", + value: function getContents() { + var index = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0; + var length = + arguments.length > 1 && arguments[1] !== undefined + ? arguments[1] + : this.getLength() - index; + + var _overload7 = overload(index, length); + + var _overload8 = _slicedToArray(_overload7, 2); + + index = _overload8[0]; + length = _overload8[1]; + + return this.editor.getContents(index, length); + } + }, + { + key: "getFormat", + value: function getFormat() { + var index = + arguments.length > 0 && arguments[0] !== undefined + ? arguments[0] + : this.getSelection(); + var length = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0; + + if (typeof index === "number") { + return this.editor.getFormat(index, length); + } else { + return this.editor.getFormat(index.index, index.length); + } + } + }, + { + key: "getLength", + value: function getLength() { + return this.scroll.length(); + } + }, + { + key: "getModule", + value: function getModule(name) { + return this.theme.modules[name]; + } + }, + { + key: "getSelection", + value: function getSelection() { + var focus = + arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false; + + if (focus) this.focus(); + this.update(); // Make sure we access getRange with editor in consistent state + return this.selection.getRange()[0]; + } + }, + { + key: "getText", + value: function getText() { + var index = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0; + var length = + arguments.length > 1 && arguments[1] !== undefined + ? arguments[1] + : this.getLength() - index; + + var _overload9 = overload(index, length); + + var _overload10 = _slicedToArray(_overload9, 2); + + index = _overload10[0]; + length = _overload10[1]; + + return this.editor.getText(index, length); + } + }, + { + key: "hasFocus", + value: function hasFocus() { + return this.selection.hasFocus(); + } + }, + { + key: "insertEmbed", + value: function insertEmbed(index, embed, value) { + var source = + arguments.length > 3 && arguments[3] !== undefined + ? arguments[3] + : Quill.sources.API; + + var range = this.getSelection(); + var change = this.editor.insertEmbed(index, embed, value, source); + range = shiftRange(range, change, source); + this.setSelection(range, _emitter2.default.sources.SILENT); + return change; + } + }, + { + key: "insertText", + value: function insertText(index, text, name, value, source) { + var formats = void 0, + range = this.getSelection(); + + var _overload11 = overload(index, 0, name, value, source); + + var _overload12 = _slicedToArray(_overload11, 4); + + index = _overload12[0]; + formats = _overload12[2]; + source = _overload12[3]; + + var change = this.editor.insertText(index, text, formats, source); + range = shiftRange(range, index, text.length, source); + this.setSelection(range, _emitter2.default.sources.SILENT); + return change; + } + }, + { + key: "off", + value: function off() { + return this.emitter.off.apply(this.emitter, arguments); + } + }, + { + key: "on", + value: function on() { + return this.emitter.on.apply(this.emitter, arguments); + } + }, + { + key: "once", + value: function once() { + return this.emitter.once.apply(this.emitter, arguments); + } + }, + { + key: "pasteHTML", + value: function pasteHTML(index, html, source) { + this.clipboard.dangerouslyPasteHTML(index, html, source); + } + }, + { + key: "removeFormat", + value: function removeFormat(index, length, source) { + var range = this.getSelection(); + + var _overload13 = overload(index, length, source); + + var _overload14 = _slicedToArray(_overload13, 4); + + index = _overload14[0]; + length = _overload14[1]; + source = _overload14[3]; + + var change = this.editor.removeFormat(index, length, source); + range = shiftRange(range, change, source); + this.setSelection(range, _emitter2.default.sources.SILENT); + return change; + } + }, + { + key: "setContents", + value: function setContents(delta) { + var source = + arguments.length > 1 && arguments[1] !== undefined + ? arguments[1] + : _emitter2.default.sources.API; + + delta = new _delta2.default(delta).slice(); + var lastOp = delta.ops[delta.ops.length - 1]; + // Quill contents must always end with newline + if (lastOp == null || lastOp.insert[lastOp.insert.length - 1] !== "\n") { + delta.insert("\n"); + } + delta.delete(this.getLength()); + return this.editor.applyDelta(delta, source); + } + }, + { + key: "setSelection", + value: function setSelection(index, length, source) { + if (index == null) { + this.selection.setRange(null, length || Quill.sources.API); + } else { + var _overload15 = overload(index, length, source); + + var _overload16 = _slicedToArray(_overload15, 4); + + index = _overload16[0]; + length = _overload16[1]; + source = _overload16[3]; + + this.selection.setRange(new _selection.Range(index, length), source); + } + this.selection.scrollIntoView(); + } + }, + { + key: "setText", + value: function setText(text) { + var source = + arguments.length > 1 && arguments[1] !== undefined + ? arguments[1] + : _emitter2.default.sources.API; + + var delta = new _delta2.default().insert(text); + return this.setContents(delta, source); + } + }, + { + key: "update", + value: function update() { + var source = + arguments.length > 0 && arguments[0] !== undefined + ? arguments[0] + : _emitter2.default.sources.USER; + + var change = this.scroll.update(source); // Will update selection before selection.update() does if text changes + this.selection.update(source); + return change; + } + }, + { + key: "updateContents", + value: function updateContents(delta) { + var source = + arguments.length > 1 && arguments[1] !== undefined + ? arguments[1] + : _emitter2.default.sources.API; + + var range = this.getSelection(); + if (Array.isArray(delta)) { + delta = new _delta2.default(delta.slice()); + } + var change = this.editor.applyDelta(delta, source); + if (range != null) { + range = shiftRange(range, change, source); + this.setSelection(range, _emitter2.default.sources.SILENT); + } + return change; + } + } + ]); + + return Quill; + })(); + + Quill.DEFAULTS = { + bounds: null, + formats: null, + modules: {}, + placeholder: "", + readOnly: false, + theme: "default" + }; + Quill.events = _emitter2.default.events; + Quill.sources = _emitter2.default.sources; + Quill.version = false ? "dev" : "1.0.6"; + + Quill.imports = { + delta: _delta2.default, + parchment: _parchment2.default, + "core/module": _module2.default, + "core/theme": _theme2.default + }; + + function expandConfig(container, userConfig) { + userConfig = (0, _extend2.default)( + true, + { + container: container, + modules: { + clipboard: true, + keyboard: true, + history: true + } + }, + userConfig + ); + if (!userConfig.theme || userConfig.theme === Quill.DEFAULTS.theme) { + userConfig.theme = _theme2.default; + } else { + userConfig.theme = Quill.import("themes/" + userConfig.theme); + if (userConfig.theme == null) { + throw new Error("Invalid theme " + userConfig.theme + ". Did you register it?"); + } + } + var themeConfig = (0, _extend2.default)(true, {}, userConfig.theme.DEFAULTS); + [themeConfig, userConfig].forEach(function(config) { + config.modules = config.modules || {}; + Object.keys(config.modules).forEach(function(module) { + if (config.modules[module] === true) { + config.modules[module] = {}; + } + }); + }); + var moduleNames = Object.keys(themeConfig.modules).concat( + Object.keys(userConfig.modules) + ); + var moduleConfig = moduleNames.reduce(function(config, name) { + var moduleClass = Quill.import("modules/" + name); + if (moduleClass == null) { + debug.error("Cannot load " + name + " module. Are you sure you registered it?"); + } else { + config[name] = moduleClass.DEFAULTS || {}; + } + return config; + }, {}); + // Special case toolbar shorthand + if ( + userConfig.modules != null && + userConfig.modules.toolbar && + userConfig.modules.toolbar.constructor !== Object + ) { + userConfig.modules.toolbar = { + container: userConfig.modules.toolbar + }; + } + userConfig = (0, _extend2.default)( + true, + {}, + Quill.DEFAULTS, + { modules: moduleConfig }, + themeConfig, + userConfig + ); + ["bounds", "container"].forEach(function(key) { + if (typeof userConfig[key] === "string") { + userConfig[key] = document.querySelector(userConfig[key]); + } + }); + userConfig.modules = Object.keys(userConfig.modules).reduce(function(config, name) { + if (userConfig.modules[name]) { + config[name] = userConfig.modules[name]; + } + return config; + }, {}); + return userConfig; + } + + function overload(index, length, name, value, source) { + var formats = {}; + if (typeof index.index === "number" && typeof index.length === "number") { + // Allow for throwaway end (used by insertText/insertEmbed) + if (typeof length !== "number") { + (source = value), + (value = name), + (name = length), + (length = index.length), + (index = index.index); + } else { + (length = index.length), (index = index.index); + } + } else if (typeof length !== "number") { + (source = value), (value = name), (name = length), (length = 0); + } + // Handle format being object, two format name/value strings or excluded + if ((typeof name === "undefined" ? "undefined" : _typeof(name)) === "object") { + formats = name; + source = value; + } else if (typeof name === "string") { + if (value != null) { + formats[name] = value; + } else { + source = name; + } + } + // Handle optional source + source = source || _emitter2.default.sources.API; + return [index, length, formats, source]; + } + + function shiftRange(range, index, length, source) { + if (range == null) return null; + var start = void 0, + end = void 0; + if (index instanceof _delta2.default) { + var _map = [range.index, range.index + range.length].map(function(pos) { + return index.transformPosition(pos, source === _emitter2.default.sources.USER); + }); + + var _map2 = _slicedToArray(_map, 2); + + start = _map2[0]; + end = _map2[1]; + } else { + var _map3 = [range.index, range.index + range.length].map(function(pos) { + if (pos < index || (pos === index && source !== _emitter2.default.sources.USER)) + return pos; + if (length >= 0) { + return pos + length; + } else { + return Math.max(index, pos + length); + } + }); + + var _map4 = _slicedToArray(_map3, 2); + + start = _map4[0]; + end = _map4[1]; + } + return new _selection.Range(start, end - start); + } + + exports.expandConfig = expandConfig; + exports.overload = overload; + exports.default = Quill; + + /***/ + }, + /* 19 */ + /***/ function(module, exports) { + "use strict"; + + var elem = document.createElement("div"); + elem.classList.toggle("test-class", false); + if (elem.classList.contains("test-class")) { + (function() { + var _toggle = DOMTokenList.prototype.toggle; + DOMTokenList.prototype.toggle = function(token, force) { + if (arguments.length > 1 && !this.contains(token) === !force) { + return force; + } else { + return _toggle.call(this, token); + } + }; + })(); + } + + if (!String.prototype.startsWith) { + String.prototype.startsWith = function(searchString, position) { + position = position || 0; + return this.substr(position, searchString.length) === searchString; + }; + } + + if (!String.prototype.endsWith) { + String.prototype.endsWith = function(searchString, position) { + var subjectString = this.toString(); + if ( + typeof position !== "number" || + !isFinite(position) || + Math.floor(position) !== position || + position > subjectString.length + ) { + position = subjectString.length; + } + position -= searchString.length; + var lastIndex = subjectString.indexOf(searchString, position); + return lastIndex !== -1 && lastIndex === position; + }; + } + + if (!Array.prototype.find) { + Object.defineProperty(Array.prototype, "find", { + value: function value(predicate) { + if (this === null) { + throw new TypeError("Array.prototype.find called on null or undefined"); + } + if (typeof predicate !== "function") { + throw new TypeError("predicate must be a function"); + } + var list = Object(this); + var length = list.length >>> 0; + var thisArg = arguments[1]; + var value; + + for (var i = 0; i < length; i++) { + value = list[i]; + if (predicate.call(thisArg, value, i, list)) { + return value; + } + } + return undefined; + } + }); + } + + // Disable resizing in Firefox + document.addEventListener("DOMContentLoaded", function() { + document.execCommand("enableObjectResizing", false, false); + }); + + /***/ + }, + /* 20 */ + /***/ function(module, exports, __webpack_require__) { + var diff = __webpack_require__(21); + var equal = __webpack_require__(22); + var extend = __webpack_require__(25); + var op = __webpack_require__(26); + + var NULL_CHARACTER = String.fromCharCode(0); // Placeholder char for embed in diff() + + var Delta = function(ops) { + // Assume we are given a well formed ops + if (Array.isArray(ops)) { + this.ops = ops; + } else if (ops != null && Array.isArray(ops.ops)) { + this.ops = ops.ops; + } else { + this.ops = []; + } + }; + + Delta.prototype.insert = function(text, attributes) { + var newOp = {}; + if (text.length === 0) return this; + newOp.insert = text; + if (typeof attributes === "object" && Object.keys(attributes).length > 0) + newOp.attributes = attributes; + return this.push(newOp); + }; + + Delta.prototype["delete"] = function(length) { + if (length <= 0) return this; + return this.push({ delete: length }); + }; + + Delta.prototype.retain = function(length, attributes) { + if (length <= 0) return this; + var newOp = { retain: length }; + if (typeof attributes === "object" && Object.keys(attributes).length > 0) + newOp.attributes = attributes; + return this.push(newOp); + }; + + Delta.prototype.push = function(newOp) { + var index = this.ops.length; + var lastOp = this.ops[index - 1]; + newOp = extend(true, {}, newOp); + if (typeof lastOp === "object") { + if (typeof newOp["delete"] === "number" && typeof lastOp["delete"] === "number") { + this.ops[index - 1] = { delete: lastOp["delete"] + newOp["delete"] }; + return this; + } + // Since it does not matter if we insert before or after deleting at the same index, + // always prefer to insert first + if (typeof lastOp["delete"] === "number" && newOp.insert != null) { + index -= 1; + lastOp = this.ops[index - 1]; + if (typeof lastOp !== "object") { + this.ops.unshift(newOp); + return this; + } + } + if (equal(newOp.attributes, lastOp.attributes)) { + if (typeof newOp.insert === "string" && typeof lastOp.insert === "string") { + this.ops[index - 1] = { insert: lastOp.insert + newOp.insert }; + if (typeof newOp.attributes === "object") + this.ops[index - 1].attributes = newOp.attributes; + return this; + } else if (typeof newOp.retain === "number" && typeof lastOp.retain === "number") { + this.ops[index - 1] = { retain: lastOp.retain + newOp.retain }; + if (typeof newOp.attributes === "object") + this.ops[index - 1].attributes = newOp.attributes; + return this; + } + } + } + if (index === this.ops.length) { + this.ops.push(newOp); + } else { + this.ops.splice(index, 0, newOp); + } + return this; + }; + + Delta.prototype.chop = function() { + var lastOp = this.ops[this.ops.length - 1]; + if (lastOp && lastOp.retain && !lastOp.attributes) { + this.ops.pop(); + } + return this; + }; + + Delta.prototype.length = function() { + return this.ops.reduce(function(length, elem) { + return length + op.length(elem); + }, 0); + }; + + Delta.prototype.slice = function(start, end) { + start = start || 0; + if (typeof end !== "number") end = Infinity; + var ops = []; + var iter = op.iterator(this.ops); + var index = 0; + while (index < end && iter.hasNext()) { + var nextOp; + if (index < start) { + nextOp = iter.next(start - index); + } else { + nextOp = iter.next(end - index); + ops.push(nextOp); + } + index += op.length(nextOp); + } + return new Delta(ops); + }; + + Delta.prototype.compose = function(other) { + var thisIter = op.iterator(this.ops); + var otherIter = op.iterator(other.ops); + var delta = new Delta(); + while (thisIter.hasNext() || otherIter.hasNext()) { + if (otherIter.peekType() === "insert") { + delta.push(otherIter.next()); + } else if (thisIter.peekType() === "delete") { + delta.push(thisIter.next()); + } else { + var length = Math.min(thisIter.peekLength(), otherIter.peekLength()); + var thisOp = thisIter.next(length); + var otherOp = otherIter.next(length); + if (typeof otherOp.retain === "number") { + var newOp = {}; + if (typeof thisOp.retain === "number") { + newOp.retain = length; + } else { + newOp.insert = thisOp.insert; + } + // Preserve null when composing with a retain, otherwise remove it for inserts + var attributes = op.attributes.compose( + thisOp.attributes, + otherOp.attributes, + typeof thisOp.retain === "number" + ); + if (attributes) newOp.attributes = attributes; + delta.push(newOp); + // Other op should be delete, we could be an insert or retain + // Insert + delete cancels out + } else if ( + typeof otherOp["delete"] === "number" && + typeof thisOp.retain === "number" + ) { + delta.push(otherOp); + } + } + } + return delta.chop(); + }; + + Delta.prototype.concat = function(other) { + var delta = new Delta(this.ops.slice()); + if (other.ops.length > 0) { + delta.push(other.ops[0]); + delta.ops = delta.ops.concat(other.ops.slice(1)); + } + return delta; + }; + + Delta.prototype.diff = function(other) { + var delta = new Delta(); + if (this.ops === other.ops) { + return delta; + } + var strings = [this.ops, other.ops].map(function(ops) { + return ops + .map(function(op) { + if (op.insert != null) { + return typeof op.insert === "string" ? op.insert : NULL_CHARACTER; + } + var prep = ops === other.ops ? "on" : "with"; + throw new Error("diff() called " + prep + " non-document"); + }) + .join(""); + }); + var diffResult = diff(strings[0], strings[1]); + var thisIter = op.iterator(this.ops); + var otherIter = op.iterator(other.ops); + diffResult.forEach(function(component) { + var length = component[1].length; + while (length > 0) { + var opLength = 0; + switch (component[0]) { + case diff.INSERT: + opLength = Math.min(otherIter.peekLength(), length); + delta.push(otherIter.next(opLength)); + break; + case diff.DELETE: + opLength = Math.min(length, thisIter.peekLength()); + thisIter.next(opLength); + delta["delete"](opLength); + break; + case diff.EQUAL: + opLength = Math.min(thisIter.peekLength(), otherIter.peekLength(), length); + var thisOp = thisIter.next(opLength); + var otherOp = otherIter.next(opLength); + if (equal(thisOp.insert, otherOp.insert)) { + delta.retain( + opLength, + op.attributes.diff(thisOp.attributes, otherOp.attributes) + ); + } else { + delta.push(otherOp)["delete"](opLength); + } + break; + } + length -= opLength; + } + }); + return delta.chop(); + }; + + Delta.prototype.transform = function(other, priority) { + priority = !!priority; + if (typeof other === "number") { + return this.transformPosition(other, priority); + } + var thisIter = op.iterator(this.ops); + var otherIter = op.iterator(other.ops); + var delta = new Delta(); + while (thisIter.hasNext() || otherIter.hasNext()) { + if ( + thisIter.peekType() === "insert" && + (priority || otherIter.peekType() !== "insert") + ) { + delta.retain(op.length(thisIter.next())); + } else if (otherIter.peekType() === "insert") { + delta.push(otherIter.next()); + } else { + var length = Math.min(thisIter.peekLength(), otherIter.peekLength()); + var thisOp = thisIter.next(length); + var otherOp = otherIter.next(length); + if (thisOp["delete"]) { + // Our delete either makes their delete redundant or removes their retain + continue; + } else if (otherOp["delete"]) { + delta.push(otherOp); + } else { + // We retain either their retain or insert + delta.retain( + length, + op.attributes.transform(thisOp.attributes, otherOp.attributes, priority) + ); + } + } + } + return delta.chop(); + }; + + Delta.prototype.transformPosition = function(index, priority) { + priority = !!priority; + var thisIter = op.iterator(this.ops); + var offset = 0; + while (thisIter.hasNext() && offset <= index) { + var length = thisIter.peekLength(); + var nextType = thisIter.peekType(); + thisIter.next(); + if (nextType === "delete") { + index -= Math.min(length, index - offset); + continue; + } else if (nextType === "insert" && (offset < index || !priority)) { + index += length; + } + offset += length; + } + return index; + }; + + module.exports = Delta; + + /***/ + }, + /* 21 */ + /***/ function(module, exports) { + /** + * This library modifies the diff-patch-match library by Neil Fraser + * by removing the patch and match functionality and certain advanced + * options in the diff function. The original license is as follows: + * + * === + * + * Diff Match and Patch + * + * Copyright 2006 Google Inc. + * http://code.google.com/p/google-diff-match-patch/ + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + /** + * The data structure representing a diff is an array of tuples: + * [[DIFF_DELETE, 'Hello'], [DIFF_INSERT, 'Goodbye'], [DIFF_EQUAL, ' world.']] + * which means: delete 'Hello', add 'Goodbye' and keep ' world.' + */ + var DIFF_DELETE = -1; + var DIFF_INSERT = 1; + var DIFF_EQUAL = 0; + + /** + * Find the differences between two texts. Simplifies the problem by stripping + * any common prefix or suffix off the texts before diffing. + * @param {string} text1 Old string to be diffed. + * @param {string} text2 New string to be diffed. + * @return {Array} Array of diff tuples. + */ + function diff_main(text1, text2) { + // Check for equality (speedup). + if (text1 == text2) { + if (text1) { + return [[DIFF_EQUAL, text1]]; + } + return []; + } + + // Trim off common prefix (speedup). + var commonlength = diff_commonPrefix(text1, text2); + var commonprefix = text1.substring(0, commonlength); + text1 = text1.substring(commonlength); + text2 = text2.substring(commonlength); + + // Trim off common suffix (speedup). + commonlength = diff_commonSuffix(text1, text2); + var commonsuffix = text1.substring(text1.length - commonlength); + text1 = text1.substring(0, text1.length - commonlength); + text2 = text2.substring(0, text2.length - commonlength); + + // Compute the diff on the middle block. + var diffs = diff_compute_(text1, text2); + + // Restore the prefix and suffix. + if (commonprefix) { + diffs.unshift([DIFF_EQUAL, commonprefix]); + } + if (commonsuffix) { + diffs.push([DIFF_EQUAL, commonsuffix]); + } + diff_cleanupMerge(diffs); + return diffs; + } + + /** + * Find the differences between two texts. Assumes that the texts do not + * have any common prefix or suffix. + * @param {string} text1 Old string to be diffed. + * @param {string} text2 New string to be diffed. + * @return {Array} Array of diff tuples. + */ + function diff_compute_(text1, text2) { + var diffs; + + if (!text1) { + // Just add some text (speedup). + return [[DIFF_INSERT, text2]]; + } + + if (!text2) { + // Just delete some text (speedup). + return [[DIFF_DELETE, text1]]; + } + + var longtext = text1.length > text2.length ? text1 : text2; + var shorttext = text1.length > text2.length ? text2 : text1; + var i = longtext.indexOf(shorttext); + if (i != -1) { + // Shorter text is inside the longer text (speedup). + diffs = [ + [DIFF_INSERT, longtext.substring(0, i)], + [DIFF_EQUAL, shorttext], + [DIFF_INSERT, longtext.substring(i + shorttext.length)] + ]; + // Swap insertions for deletions if diff is reversed. + if (text1.length > text2.length) { + diffs[0][0] = diffs[2][0] = DIFF_DELETE; + } + return diffs; + } + + if (shorttext.length == 1) { + // Single character string. + // After the previous speedup, the character can't be an equality. + return [[DIFF_DELETE, text1], [DIFF_INSERT, text2]]; + } + + // Check to see if the problem can be split in two. + var hm = diff_halfMatch_(text1, text2); + if (hm) { + // A half-match was found, sort out the return data. + var text1_a = hm[0]; + var text1_b = hm[1]; + var text2_a = hm[2]; + var text2_b = hm[3]; + var mid_common = hm[4]; + // Send both pairs off for separate processing. + var diffs_a = diff_main(text1_a, text2_a); + var diffs_b = diff_main(text1_b, text2_b); + // Merge the results. + return diffs_a.concat([[DIFF_EQUAL, mid_common]], diffs_b); + } + + return diff_bisect_(text1, text2); + } + + /** + * Find the 'middle snake' of a diff, split the problem in two + * and return the recursively constructed diff. + * See Myers 1986 paper: An O(ND) Difference Algorithm and Its Variations. + * @param {string} text1 Old string to be diffed. + * @param {string} text2 New string to be diffed. + * @return {Array} Array of diff tuples. + * @private + */ + function diff_bisect_(text1, text2) { + // Cache the text lengths to prevent multiple calls. + var text1_length = text1.length; + var text2_length = text2.length; + var max_d = Math.ceil((text1_length + text2_length) / 2); + var v_offset = max_d; + var v_length = 2 * max_d; + var v1 = new Array(v_length); + var v2 = new Array(v_length); + // Setting all elements to -1 is faster in Chrome & Firefox than mixing + // integers and undefined. + for (var x = 0; x < v_length; x++) { + v1[x] = -1; + v2[x] = -1; + } + v1[v_offset + 1] = 0; + v2[v_offset + 1] = 0; + var delta = text1_length - text2_length; + // If the total number of characters is odd, then the front path will collide + // with the reverse path. + var front = delta % 2 != 0; + // Offsets for start and end of k loop. + // Prevents mapping of space beyond the grid. + var k1start = 0; + var k1end = 0; + var k2start = 0; + var k2end = 0; + for (var d = 0; d < max_d; d++) { + // Walk the front path one step. + for (var k1 = -d + k1start; k1 <= d - k1end; k1 += 2) { + var k1_offset = v_offset + k1; + var x1; + if (k1 == -d || (k1 != d && v1[k1_offset - 1] < v1[k1_offset + 1])) { + x1 = v1[k1_offset + 1]; + } else { + x1 = v1[k1_offset - 1] + 1; + } + var y1 = x1 - k1; + while ( + x1 < text1_length && + y1 < text2_length && + text1.charAt(x1) == text2.charAt(y1) + ) { + x1++; + y1++; + } + v1[k1_offset] = x1; + if (x1 > text1_length) { + // Ran off the right of the graph. + k1end += 2; + } else if (y1 > text2_length) { + // Ran off the bottom of the graph. + k1start += 2; + } else if (front) { + var k2_offset = v_offset + delta - k1; + if (k2_offset >= 0 && k2_offset < v_length && v2[k2_offset] != -1) { + // Mirror x2 onto top-left coordinate system. + var x2 = text1_length - v2[k2_offset]; + if (x1 >= x2) { + // Overlap detected. + return diff_bisectSplit_(text1, text2, x1, y1); + } + } + } + } + + // Walk the reverse path one step. + for (var k2 = -d + k2start; k2 <= d - k2end; k2 += 2) { + var k2_offset = v_offset + k2; + var x2; + if (k2 == -d || (k2 != d && v2[k2_offset - 1] < v2[k2_offset + 1])) { + x2 = v2[k2_offset + 1]; + } else { + x2 = v2[k2_offset - 1] + 1; + } + var y2 = x2 - k2; + while ( + x2 < text1_length && + y2 < text2_length && + text1.charAt(text1_length - x2 - 1) == text2.charAt(text2_length - y2 - 1) + ) { + x2++; + y2++; + } + v2[k2_offset] = x2; + if (x2 > text1_length) { + // Ran off the left of the graph. + k2end += 2; + } else if (y2 > text2_length) { + // Ran off the top of the graph. + k2start += 2; + } else if (!front) { + var k1_offset = v_offset + delta - k2; + if (k1_offset >= 0 && k1_offset < v_length && v1[k1_offset] != -1) { + var x1 = v1[k1_offset]; + var y1 = v_offset + x1 - k1_offset; + // Mirror x2 onto top-left coordinate system. + x2 = text1_length - x2; + if (x1 >= x2) { + // Overlap detected. + return diff_bisectSplit_(text1, text2, x1, y1); + } + } + } + } + } + // Diff took too long and hit the deadline or + // number of diffs equals number of characters, no commonality at all. + return [[DIFF_DELETE, text1], [DIFF_INSERT, text2]]; + } + + /** + * Given the location of the 'middle snake', split the diff in two parts + * and recurse. + * @param {string} text1 Old string to be diffed. + * @param {string} text2 New string to be diffed. + * @param {number} x Index of split point in text1. + * @param {number} y Index of split point in text2. + * @return {Array} Array of diff tuples. + */ + function diff_bisectSplit_(text1, text2, x, y) { + var text1a = text1.substring(0, x); + var text2a = text2.substring(0, y); + var text1b = text1.substring(x); + var text2b = text2.substring(y); + + // Compute both diffs serially. + var diffs = diff_main(text1a, text2a); + var diffsb = diff_main(text1b, text2b); + + return diffs.concat(diffsb); + } + + /** + * Determine the common prefix of two strings. + * @param {string} text1 First string. + * @param {string} text2 Second string. + * @return {number} The number of characters common to the start of each + * string. + */ + function diff_commonPrefix(text1, text2) { + // Quick check for common null cases. + if (!text1 || !text2 || text1.charAt(0) != text2.charAt(0)) { + return 0; + } + // Binary search. + // Performance analysis: http://neil.fraser.name/news/2007/10/09/ + var pointermin = 0; + var pointermax = Math.min(text1.length, text2.length); + var pointermid = pointermax; + var pointerstart = 0; + while (pointermin < pointermid) { + if ( + text1.substring(pointerstart, pointermid) == text2.substring(pointerstart, pointermid) + ) { + pointermin = pointermid; + pointerstart = pointermin; + } else { + pointermax = pointermid; + } + pointermid = Math.floor((pointermax - pointermin) / 2 + pointermin); + } + return pointermid; + } + + /** + * Determine the common suffix of two strings. + * @param {string} text1 First string. + * @param {string} text2 Second string. + * @return {number} The number of characters common to the end of each string. + */ + function diff_commonSuffix(text1, text2) { + // Quick check for common null cases. + if ( + !text1 || + !text2 || + text1.charAt(text1.length - 1) != text2.charAt(text2.length - 1) + ) { + return 0; + } + // Binary search. + // Performance analysis: http://neil.fraser.name/news/2007/10/09/ + var pointermin = 0; + var pointermax = Math.min(text1.length, text2.length); + var pointermid = pointermax; + var pointerend = 0; + while (pointermin < pointermid) { + if ( + text1.substring(text1.length - pointermid, text1.length - pointerend) == + text2.substring(text2.length - pointermid, text2.length - pointerend) + ) { + pointermin = pointermid; + pointerend = pointermin; + } else { + pointermax = pointermid; + } + pointermid = Math.floor((pointermax - pointermin) / 2 + pointermin); + } + return pointermid; + } + + /** + * Do the two texts share a substring which is at least half the length of the + * longer text? + * This speedup can produce non-minimal diffs. + * @param {string} text1 First string. + * @param {string} text2 Second string. + * @return {Array.} Five element Array, containing the prefix of + * text1, the suffix of text1, the prefix of text2, the suffix of + * text2 and the common middle. Or null if there was no match. + */ + function diff_halfMatch_(text1, text2) { + var longtext = text1.length > text2.length ? text1 : text2; + var shorttext = text1.length > text2.length ? text2 : text1; + if (longtext.length < 4 || shorttext.length * 2 < longtext.length) { + return null; // Pointless. + } + + /** + * Does a substring of shorttext exist within longtext such that the substring + * is at least half the length of longtext? + * Closure, but does not reference any external variables. + * @param {string} longtext Longer string. + * @param {string} shorttext Shorter string. + * @param {number} i Start index of quarter length substring within longtext. + * @return {Array.} Five element Array, containing the prefix of + * longtext, the suffix of longtext, the prefix of shorttext, the suffix + * of shorttext and the common middle. Or null if there was no match. + * @private + */ + function diff_halfMatchI_(longtext, shorttext, i) { + // Start with a 1/4 length substring at position i as a seed. + var seed = longtext.substring(i, i + Math.floor(longtext.length / 4)); + var j = -1; + var best_common = ""; + var best_longtext_a, best_longtext_b, best_shorttext_a, best_shorttext_b; + while ((j = shorttext.indexOf(seed, j + 1)) != -1) { + var prefixLength = diff_commonPrefix(longtext.substring(i), shorttext.substring(j)); + var suffixLength = diff_commonSuffix( + longtext.substring(0, i), + shorttext.substring(0, j) + ); + if (best_common.length < suffixLength + prefixLength) { + best_common = + shorttext.substring(j - suffixLength, j) + + shorttext.substring(j, j + prefixLength); + best_longtext_a = longtext.substring(0, i - suffixLength); + best_longtext_b = longtext.substring(i + prefixLength); + best_shorttext_a = shorttext.substring(0, j - suffixLength); + best_shorttext_b = shorttext.substring(j + prefixLength); + } + } + if (best_common.length * 2 >= longtext.length) { + return [ + best_longtext_a, + best_longtext_b, + best_shorttext_a, + best_shorttext_b, + best_common + ]; + } else { + return null; + } + } + + // First check if the second quarter is the seed for a half-match. + var hm1 = diff_halfMatchI_(longtext, shorttext, Math.ceil(longtext.length / 4)); + // Check again based on the third quarter. + var hm2 = diff_halfMatchI_(longtext, shorttext, Math.ceil(longtext.length / 2)); + var hm; + if (!hm1 && !hm2) { + return null; + } else if (!hm2) { + hm = hm1; + } else if (!hm1) { + hm = hm2; + } else { + // Both matched. Select the longest. + hm = hm1[4].length > hm2[4].length ? hm1 : hm2; + } + + // A half-match was found, sort out the return data. + var text1_a, text1_b, text2_a, text2_b; + if (text1.length > text2.length) { + text1_a = hm[0]; + text1_b = hm[1]; + text2_a = hm[2]; + text2_b = hm[3]; + } else { + text2_a = hm[0]; + text2_b = hm[1]; + text1_a = hm[2]; + text1_b = hm[3]; + } + var mid_common = hm[4]; + return [text1_a, text1_b, text2_a, text2_b, mid_common]; + } + + /** + * Reorder and merge like edit sections. Merge equalities. + * Any edit section can move as long as it doesn't cross an equality. + * @param {Array} diffs Array of diff tuples. + */ + function diff_cleanupMerge(diffs) { + diffs.push([DIFF_EQUAL, ""]); // Add a dummy entry at the end. + var pointer = 0; + var count_delete = 0; + var count_insert = 0; + var text_delete = ""; + var text_insert = ""; + var commonlength; + while (pointer < diffs.length) { + switch (diffs[pointer][0]) { + case DIFF_INSERT: + count_insert++; + text_insert += diffs[pointer][1]; + pointer++; + break; + case DIFF_DELETE: + count_delete++; + text_delete += diffs[pointer][1]; + pointer++; + break; + case DIFF_EQUAL: + // Upon reaching an equality, check for prior redundancies. + if (count_delete + count_insert > 1) { + if (count_delete !== 0 && count_insert !== 0) { + // Factor out any common prefixies. + commonlength = diff_commonPrefix(text_insert, text_delete); + if (commonlength !== 0) { + if ( + pointer - count_delete - count_insert > 0 && + diffs[pointer - count_delete - count_insert - 1][0] == DIFF_EQUAL + ) { + diffs[ + pointer - count_delete - count_insert - 1 + ][1] += text_insert.substring(0, commonlength); + } else { + diffs.splice(0, 0, [DIFF_EQUAL, text_insert.substring(0, commonlength)]); + pointer++; + } + text_insert = text_insert.substring(commonlength); + text_delete = text_delete.substring(commonlength); + } + // Factor out any common suffixies. + commonlength = diff_commonSuffix(text_insert, text_delete); + if (commonlength !== 0) { + diffs[pointer][1] = + text_insert.substring(text_insert.length - commonlength) + + diffs[pointer][1]; + text_insert = text_insert.substring(0, text_insert.length - commonlength); + text_delete = text_delete.substring(0, text_delete.length - commonlength); + } + } + // Delete the offending records and add the merged ones. + if (count_delete === 0) { + diffs.splice(pointer - count_insert, count_delete + count_insert, [ + DIFF_INSERT, + text_insert + ]); + } else if (count_insert === 0) { + diffs.splice(pointer - count_delete, count_delete + count_insert, [ + DIFF_DELETE, + text_delete + ]); + } else { + diffs.splice( + pointer - count_delete - count_insert, + count_delete + count_insert, + [DIFF_DELETE, text_delete], + [DIFF_INSERT, text_insert] + ); + } + pointer = + pointer - + count_delete - + count_insert + + (count_delete ? 1 : 0) + + (count_insert ? 1 : 0) + + 1; + } else if (pointer !== 0 && diffs[pointer - 1][0] == DIFF_EQUAL) { + // Merge this equality with the previous one. + diffs[pointer - 1][1] += diffs[pointer][1]; + diffs.splice(pointer, 1); + } else { + pointer++; + } + count_insert = 0; + count_delete = 0; + text_delete = ""; + text_insert = ""; + break; + } + } + if (diffs[diffs.length - 1][1] === "") { + diffs.pop(); // Remove the dummy entry at the end. + } + + // Second pass: look for single edits surrounded on both sides by equalities + // which can be shifted sideways to eliminate an equality. + // e.g: ABAC -> ABAC + var changes = false; + pointer = 1; + // Intentionally ignore the first and last element (don't need checking). + while (pointer < diffs.length - 1) { + if (diffs[pointer - 1][0] == DIFF_EQUAL && diffs[pointer + 1][0] == DIFF_EQUAL) { + // This is a single edit surrounded by equalities. + if ( + diffs[pointer][1].substring( + diffs[pointer][1].length - diffs[pointer - 1][1].length + ) == diffs[pointer - 1][1] + ) { + // Shift the edit over the previous equality. + diffs[pointer][1] = + diffs[pointer - 1][1] + + diffs[pointer][1].substring( + 0, + diffs[pointer][1].length - diffs[pointer - 1][1].length + ); + diffs[pointer + 1][1] = diffs[pointer - 1][1] + diffs[pointer + 1][1]; + diffs.splice(pointer - 1, 1); + changes = true; + } else if ( + diffs[pointer][1].substring(0, diffs[pointer + 1][1].length) == + diffs[pointer + 1][1] + ) { + // Shift the edit over the next equality. + diffs[pointer - 1][1] += diffs[pointer + 1][1]; + diffs[pointer][1] = + diffs[pointer][1].substring(diffs[pointer + 1][1].length) + diffs[pointer + 1][1]; + diffs.splice(pointer + 1, 1); + changes = true; + } + } + pointer++; + } + // If shifts were made, the diff needs reordering and another shift sweep. + if (changes) { + diff_cleanupMerge(diffs); + } + } + + var diff = diff_main; + diff.INSERT = DIFF_INSERT; + diff.DELETE = DIFF_DELETE; + diff.EQUAL = DIFF_EQUAL; + + module.exports = diff; + + /***/ + }, + /* 22 */ + /***/ function(module, exports, __webpack_require__) { + var pSlice = Array.prototype.slice; + var objectKeys = __webpack_require__(23); + var isArguments = __webpack_require__(24); + + var deepEqual = (module.exports = function(actual, expected, opts) { + if (!opts) opts = {}; + // 7.1. All identical values are equivalent, as determined by ===. + if (actual === expected) { + return true; + } else if (actual instanceof Date && expected instanceof Date) { + return actual.getTime() === expected.getTime(); + + // 7.3. Other pairs that do not both pass typeof value == 'object', + // equivalence is determined by ==. + } else if ( + !actual || + !expected || + (typeof actual != "object" && typeof expected != "object") + ) { + return opts.strict ? actual === expected : actual == expected; + + // 7.4. For all other Object pairs, including Array objects, equivalence is + // determined by having the same number of owned properties (as verified + // with Object.prototype.hasOwnProperty.call), the same set of keys + // (although not necessarily the same order), equivalent values for every + // corresponding key, and an identical 'prototype' property. Note: this + // accounts for both named and indexed properties on Arrays. + } else { + return objEquiv(actual, expected, opts); + } + }); + + function isUndefinedOrNull(value) { + return value === null || value === undefined; + } + + function isBuffer(x) { + if (!x || typeof x !== "object" || typeof x.length !== "number") return false; + if (typeof x.copy !== "function" || typeof x.slice !== "function") { + return false; + } + if (x.length > 0 && typeof x[0] !== "number") return false; + return true; + } + + function objEquiv(a, b, opts) { + var i, key; + if (isUndefinedOrNull(a) || isUndefinedOrNull(b)) return false; + // an identical 'prototype' property. + if (a.prototype !== b.prototype) return false; + //~~~I've managed to break Object.keys through screwy arguments passing. + // Converting to array solves the problem. + if (isArguments(a)) { + if (!isArguments(b)) { + return false; + } + a = pSlice.call(a); + b = pSlice.call(b); + return deepEqual(a, b, opts); + } + if (isBuffer(a)) { + if (!isBuffer(b)) { + return false; + } + if (a.length !== b.length) return false; + for (i = 0; i < a.length; i++) { + if (a[i] !== b[i]) return false; + } + return true; + } + try { + var ka = objectKeys(a), + kb = objectKeys(b); + } catch (e) { + //happens when one is a string literal and the other isn't + return false; + } + // having the same number of owned properties (keys incorporates + // hasOwnProperty) + if (ka.length != kb.length) return false; + //the same set of keys (although not necessarily the same order), + ka.sort(); + kb.sort(); + //~~~cheap key test + for (i = ka.length - 1; i >= 0; i--) { + if (ka[i] != kb[i]) return false; + } + //equivalent values for every corresponding key, and + //~~~possibly expensive deep test + for (i = ka.length - 1; i >= 0; i--) { + key = ka[i]; + if (!deepEqual(a[key], b[key], opts)) return false; + } + return typeof a === typeof b; + } + + /***/ + }, + /* 23 */ + /***/ function(module, exports) { + exports = module.exports = typeof Object.keys === "function" ? Object.keys : shim; + + exports.shim = shim; + function shim(obj) { + var keys = []; + for (var key in obj) keys.push(key); + return keys; + } + + /***/ + }, + /* 24 */ + /***/ function(module, exports) { + var supportsArgumentsClass = + (function() { + return Object.prototype.toString.call(arguments); + })() == "[object Arguments]"; + + exports = module.exports = supportsArgumentsClass ? supported : unsupported; + + exports.supported = supported; + function supported(object) { + return Object.prototype.toString.call(object) == "[object Arguments]"; + } + + exports.unsupported = unsupported; + function unsupported(object) { + return ( + (object && + typeof object == "object" && + typeof object.length == "number" && + Object.prototype.hasOwnProperty.call(object, "callee") && + !Object.prototype.propertyIsEnumerable.call(object, "callee")) || + false + ); + } + + /***/ + }, + /* 25 */ + /***/ function(module, exports) { + "use strict"; + + var hasOwn = Object.prototype.hasOwnProperty; + var toStr = Object.prototype.toString; + + var isArray = function isArray(arr) { + if (typeof Array.isArray === "function") { + return Array.isArray(arr); + } + + return toStr.call(arr) === "[object Array]"; + }; + + var isPlainObject = function isPlainObject(obj) { + if (!obj || toStr.call(obj) !== "[object Object]") { + return false; + } + + var hasOwnConstructor = hasOwn.call(obj, "constructor"); + var hasIsPrototypeOf = + obj.constructor && + obj.constructor.prototype && + hasOwn.call(obj.constructor.prototype, "isPrototypeOf"); + // Not own constructor property must be Object + if (obj.constructor && !hasOwnConstructor && !hasIsPrototypeOf) { + return false; + } + + // Own properties are enumerated firstly, so to speed up, + // if last one is own, then all properties are own. + var key; + for (key in obj) { + /**/ + } + + return typeof key === "undefined" || hasOwn.call(obj, key); + }; + + module.exports = function extend() { + var options, + name, + src, + copy, + copyIsArray, + clone, + target = arguments[0], + i = 1, + length = arguments.length, + deep = false; + + // Handle a deep copy situation + if (typeof target === "boolean") { + deep = target; + target = arguments[1] || {}; + // skip the boolean and the target + i = 2; + } else if ( + (typeof target !== "object" && typeof target !== "function") || + target == null + ) { + target = {}; + } + + for (; i < length; ++i) { + options = arguments[i]; + // Only deal with non-null/undefined values + if (options != null) { + // Extend the base object + for (name in options) { + src = target[name]; + copy = options[name]; + + // Prevent never-ending loop + if (target !== copy) { + // Recurse if we're merging plain objects or arrays + if (deep && copy && (isPlainObject(copy) || (copyIsArray = isArray(copy)))) { + if (copyIsArray) { + copyIsArray = false; + clone = src && isArray(src) ? src : []; + } else { + clone = src && isPlainObject(src) ? src : {}; + } + + // Never move original objects, clone them + target[name] = extend(deep, clone, copy); + + // Don't bring in undefined values + } else if (typeof copy !== "undefined") { + target[name] = copy; + } + } + } + } + } + + // Return the modified object + return target; + }; + + /***/ + }, + /* 26 */ + /***/ function(module, exports, __webpack_require__) { + var equal = __webpack_require__(22); + var extend = __webpack_require__(25); + + var lib = { + attributes: { + compose: function(a, b, keepNull) { + if (typeof a !== "object") a = {}; + if (typeof b !== "object") b = {}; + var attributes = extend(true, {}, b); + if (!keepNull) { + attributes = Object.keys(attributes).reduce(function(copy, key) { + if (attributes[key] != null) { + copy[key] = attributes[key]; + } + return copy; + }, {}); + } + for (var key in a) { + if (a[key] !== undefined && b[key] === undefined) { + attributes[key] = a[key]; + } + } + return Object.keys(attributes).length > 0 ? attributes : undefined; + }, + + diff: function(a, b) { + if (typeof a !== "object") a = {}; + if (typeof b !== "object") b = {}; + var attributes = Object.keys(a) + .concat(Object.keys(b)) + .reduce(function(attributes, key) { + if (!equal(a[key], b[key])) { + attributes[key] = b[key] === undefined ? null : b[key]; + } + return attributes; + }, {}); + return Object.keys(attributes).length > 0 ? attributes : undefined; + }, + + transform: function(a, b, priority) { + if (typeof a !== "object") return b; + if (typeof b !== "object") return undefined; + if (!priority) return b; // b simply overwrites us without priority + var attributes = Object.keys(b).reduce(function(attributes, key) { + if (a[key] === undefined) attributes[key] = b[key]; // null is a valid value + return attributes; + }, {}); + return Object.keys(attributes).length > 0 ? attributes : undefined; + } + }, + + iterator: function(ops) { + return new Iterator(ops); + }, + + length: function(op) { + if (typeof op["delete"] === "number") { + return op["delete"]; + } else if (typeof op.retain === "number") { + return op.retain; + } else { + return typeof op.insert === "string" ? op.insert.length : 1; + } + } + }; + + function Iterator(ops) { + this.ops = ops; + this.index = 0; + this.offset = 0; + } + + Iterator.prototype.hasNext = function() { + return this.peekLength() < Infinity; + }; + + Iterator.prototype.next = function(length) { + if (!length) length = Infinity; + var nextOp = this.ops[this.index]; + if (nextOp) { + var offset = this.offset; + var opLength = lib.length(nextOp); + if (length >= opLength - offset) { + length = opLength - offset; + this.index += 1; + this.offset = 0; + } else { + this.offset += length; + } + if (typeof nextOp["delete"] === "number") { + return { delete: length }; + } else { + var retOp = {}; + if (nextOp.attributes) { + retOp.attributes = nextOp.attributes; + } + if (typeof nextOp.retain === "number") { + retOp.retain = length; + } else if (typeof nextOp.insert === "string") { + retOp.insert = nextOp.insert.substr(offset, length); + } else { + // offset should === 0, length should === 1 + retOp.insert = nextOp.insert; + } + return retOp; + } + } else { + return { retain: Infinity }; + } + }; + + Iterator.prototype.peekLength = function() { + if (this.ops[this.index]) { + // Should never return 0 if our index is being managed correctly + return lib.length(this.ops[this.index]) - this.offset; + } else { + return Infinity; + } + }; + + Iterator.prototype.peekType = function() { + if (this.ops[this.index]) { + if (typeof this.ops[this.index]["delete"] === "number") { + return "delete"; + } else if (typeof this.ops[this.index].retain === "number") { + return "retain"; + } else { + return "insert"; + } + } + return "retain"; + }; + + module.exports = lib; + + /***/ + }, + /* 27 */ + /***/ function(module, exports, __webpack_require__) { + "use strict"; + + Object.defineProperty(exports, "__esModule", { + value: true + }); + + var _typeof = + typeof Symbol === "function" && typeof Symbol.iterator === "symbol" + ? function(obj) { + return typeof obj; + } + : function(obj) { + return obj && + typeof Symbol === "function" && + obj.constructor === Symbol && + obj !== Symbol.prototype + ? "symbol" + : typeof obj; + }; + + var _slicedToArray = (function() { + function sliceIterator(arr, i) { + var _arr = []; + var _n = true; + var _d = false; + var _e = undefined; + try { + for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { + _arr.push(_s.value); + if (i && _arr.length === i) break; + } + } catch (err) { + _d = true; + _e = err; + } finally { + try { + if (!_n && _i["return"]) _i["return"](); + } finally { + if (_d) throw _e; + } + } + return _arr; + } + return function(arr, i) { + if (Array.isArray(arr)) { + return arr; + } else if (Symbol.iterator in Object(arr)) { + return sliceIterator(arr, i); + } else { + throw new TypeError("Invalid attempt to destructure non-iterable instance"); + } + }; + })(); + + var _createClass = (function() { + function defineProperties(target, props) { + for (var i = 0; i < props.length; i++) { + var descriptor = props[i]; + descriptor.enumerable = descriptor.enumerable || false; + descriptor.configurable = true; + if ("value" in descriptor) descriptor.writable = true; + Object.defineProperty(target, descriptor.key, descriptor); + } + } + return function(Constructor, protoProps, staticProps) { + if (protoProps) defineProperties(Constructor.prototype, protoProps); + if (staticProps) defineProperties(Constructor, staticProps); + return Constructor; + }; + })(); + + var _delta = __webpack_require__(20); + + var _delta2 = _interopRequireDefault(_delta); + + var _op = __webpack_require__(26); + + var _op2 = _interopRequireDefault(_op); + + var _emitter3 = __webpack_require__(28); + + var _emitter4 = _interopRequireDefault(_emitter3); + + var _parchment = __webpack_require__(2); + + var _parchment2 = _interopRequireDefault(_parchment); + + var _code = __webpack_require__(31); + + var _code2 = _interopRequireDefault(_code); + + var _cursor = __webpack_require__(37); + + var _cursor2 = _interopRequireDefault(_cursor); + + var _block = __webpack_require__(32); + + var _block2 = _interopRequireDefault(_block); + + var _clone = __webpack_require__(38); + + var _clone2 = _interopRequireDefault(_clone); + + var _deepEqual = __webpack_require__(22); + + var _deepEqual2 = _interopRequireDefault(_deepEqual); + + var _extend = __webpack_require__(25); + + var _extend2 = _interopRequireDefault(_extend); + + function _interopRequireDefault(obj) { + return obj && obj.__esModule ? obj : { default: obj }; + } + + function _defineProperty(obj, key, value) { + if (key in obj) { + Object.defineProperty(obj, key, { + value: value, + enumerable: true, + configurable: true, + writable: true + }); + } else { + obj[key] = value; + } + return obj; + } + + function _classCallCheck(instance, Constructor) { + if (!(instance instanceof Constructor)) { + throw new TypeError("Cannot call a class as a function"); + } + } + + var Editor = (function() { + function Editor(scroll, emitter) { + _classCallCheck(this, Editor); + + this.scroll = scroll; + this.emitter = emitter; + this.emitter.on(_emitter4.default.events.SCROLL_UPDATE, this.update.bind(this, null)); + this.delta = this.getDelta(); + this.enable(); + } + + _createClass(Editor, [ + { + key: "applyDelta", + value: function applyDelta(delta) { + var _this = this; + + var source = + arguments.length > 1 && arguments[1] !== undefined + ? arguments[1] + : _emitter4.default.sources.API; + + var consumeNextNewline = false; + this.scroll.update(); + var scrollLength = this.scroll.length(); + this.scroll.batch = true; + delta = normalizeDelta(delta); + delta.ops.reduce(function(index, op) { + var length = op.retain || op.delete || op.insert.length || 1; + var attributes = op.attributes || {}; + if (op.insert != null) { + if (typeof op.insert === "string") { + var text = op.insert; + if (text.endsWith("\n") && consumeNextNewline) { + consumeNextNewline = false; + text = text.slice(0, -1); + } + if (index >= scrollLength && !text.endsWith("\n")) { + consumeNextNewline = true; + } + _this.scroll.insertAt(index, text); + + var _scroll$line = _this.scroll.line(index); + + var _scroll$line2 = _slicedToArray(_scroll$line, 2); + + var line = _scroll$line2[0]; + var offset = _scroll$line2[1]; + + var formats = (0, _extend2.default)({}, (0, _block.bubbleFormats)(line)); + if (line instanceof _block2.default) { + var _line$descendant = line.descendant(_parchment2.default.Leaf, offset); + + var _line$descendant2 = _slicedToArray(_line$descendant, 1); + + var leaf = _line$descendant2[0]; + + formats = (0, _extend2.default)(formats, (0, _block.bubbleFormats)(leaf)); + } + attributes = _op2.default.attributes.diff(formats, attributes) || {}; + } else if (_typeof(op.insert) === "object") { + var key = Object.keys(op.insert)[0]; // There should only be one key + if (key == null) return index; + _this.scroll.insertAt(index, key, op.insert[key]); + } + scrollLength += length; + } + Object.keys(attributes).forEach(function(name) { + _this.scroll.formatAt(index, length, name, attributes[name]); + }); + return index + length; + }, 0); + delta.ops.reduce(function(index, op) { + if (typeof op.delete === "number") { + _this.scroll.deleteAt(index, op.delete); + return index; + } + return index + (op.retain || op.insert.length || 1); + }, 0); + this.scroll.batch = false; + this.scroll.optimize(); + return this.update(delta, source); + } + }, + { + key: "deleteText", + value: function deleteText(index, length) { + var source = + arguments.length > 2 && arguments[2] !== undefined + ? arguments[2] + : _emitter4.default.sources.API; + + this.scroll.deleteAt(index, length); + return this.update(new _delta2.default().retain(index).delete(length), source); + } + }, + { + key: "enable", + value: function enable() { + var enabled = + arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true; + + this.scroll.domNode.setAttribute("contenteditable", enabled); + } + }, + { + key: "formatLine", + value: function formatLine(index, length) { + var _this2 = this; + + var formats = + arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {}; + var source = + arguments.length > 3 && arguments[3] !== undefined + ? arguments[3] + : _emitter4.default.sources.API; + + this.scroll.update(); + Object.keys(formats).forEach(function(format) { + var lines = _this2.scroll.lines(index, Math.max(length, 1)); + var lengthRemaining = length; + lines.forEach(function(line, i) { + var lineLength = line.length(); + if (!(line instanceof _code2.default)) { + line.format(format, formats[format]); + } else { + var codeIndex = index - line.offset(_this2.scroll); + var codeLength = + line.newlineIndex(codeIndex + lengthRemaining) - codeIndex + 1; + line.formatAt(codeIndex, codeLength, format, formats[format]); + } + lengthRemaining -= lineLength; + }); + }); + this.scroll.optimize(); + return this.update( + new _delta2.default().retain(index).retain(length, (0, _clone2.default)(formats)), + source + ); + } + }, + { + key: "formatText", + value: function formatText(index, length) { + var _this3 = this; + + var formats = + arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {}; + var source = + arguments.length > 3 && arguments[3] !== undefined + ? arguments[3] + : _emitter4.default.sources.API; + + Object.keys(formats).forEach(function(format) { + _this3.scroll.formatAt(index, length, format, formats[format]); + }); + return this.update( + new _delta2.default().retain(index).retain(length, (0, _clone2.default)(formats)), + source + ); + } + }, + { + key: "getContents", + value: function getContents(index, length) { + return this.delta.slice(index, index + length); + } + }, + { + key: "getDelta", + value: function getDelta() { + return this.scroll.lines().reduce(function(delta, line) { + return delta.concat(line.delta()); + }, new _delta2.default()); + } + }, + { + key: "getFormat", + value: function getFormat(index) { + var length = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0; + + var lines = [], + leaves = []; + if (length === 0) { + this.scroll.path(index).forEach(function(path) { + var _path = _slicedToArray(path, 1); + + var blot = _path[0]; + + if (blot instanceof _block2.default) { + lines.push(blot); + } else if (blot instanceof _parchment2.default.Leaf) { + leaves.push(blot); + } + }); + } else { + lines = this.scroll.lines(index, length); + leaves = this.scroll.descendants(_parchment2.default.Leaf, index, length); + } + var formatsArr = [lines, leaves].map(function(blots) { + if (blots.length === 0) return {}; + var formats = (0, _block.bubbleFormats)(blots.shift()); + while (Object.keys(formats).length > 0) { + var blot = blots.shift(); + if (blot == null) return formats; + formats = combineFormats((0, _block.bubbleFormats)(blot), formats); + } + return formats; + }); + return _extend2.default.apply(_extend2.default, formatsArr); + } + }, + { + key: "getText", + value: function getText(index, length) { + return this.getContents(index, length) + .ops.map(function(op) { + return typeof op.insert === "string" ? op.insert : ""; + }) + .join(""); + } + }, + { + key: "insertEmbed", + value: function insertEmbed(index, embed, value) { + var source = + arguments.length > 3 && arguments[3] !== undefined + ? arguments[3] + : _emitter4.default.sources.API; + + this.scroll.insertAt(index, embed, value); + return this.update( + new _delta2.default().retain(index).insert(_defineProperty({}, embed, value)), + source + ); + } + }, + { + key: "insertText", + value: function insertText(index, text) { + var _this4 = this; + + var formats = + arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {}; + var source = + arguments.length > 3 && arguments[3] !== undefined + ? arguments[3] + : _emitter4.default.sources.API; + + text = text.replace(/\r\n/g, "\n").replace(/\r/g, "\n"); + this.scroll.insertAt(index, text); + Object.keys(formats).forEach(function(format) { + _this4.scroll.formatAt(index, text.length, format, formats[format]); + }); + return this.update( + new _delta2.default().retain(index).insert(text, (0, _clone2.default)(formats)), + source + ); + } + }, + { + key: "isBlank", + value: function isBlank() { + if (this.scroll.children.length == 0) return true; + if (this.scroll.children.length > 1) return false; + var child = this.scroll.children.head; + return child.length() <= 1 && Object.keys(child.formats()).length == 0; + } + }, + { + key: "removeFormat", + value: function removeFormat(index, length, source) { + var text = this.getText(index, length); + + var _scroll$line3 = this.scroll.line(index + length); + + var _scroll$line4 = _slicedToArray(_scroll$line3, 2); + + var line = _scroll$line4[0]; + var offset = _scroll$line4[1]; + + var suffixLength = 0, + suffix = new _delta2.default(); + if (line != null) { + if (!(line instanceof _code2.default)) { + suffixLength = line.length() - offset; + } else { + suffixLength = line.newlineIndex(offset) - offset + 1; + } + suffix = line + .delta() + .slice(offset, offset + suffixLength - 1) + .insert("\n"); + } + var contents = this.getContents(index, length + suffixLength); + var diff = contents.diff(new _delta2.default().insert(text).concat(suffix)); + var delta = new _delta2.default().retain(index).concat(diff); + return this.applyDelta(delta, source); + } + }, + { + key: "update", + value: function update(change) { + var _this5 = this; + + var source = + arguments.length > 1 && arguments[1] !== undefined + ? arguments[1] + : _emitter4.default.sources.USER; + var mutations = + arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : []; + + var oldDelta = this.delta; + if ( + mutations.length === 1 && + mutations[0].type === "characterData" && + _parchment2.default.find(mutations[0].target) + ) { + (function() { + // Optimization for character changes + var textBlot = _parchment2.default.find(mutations[0].target); + var formats = (0, _block.bubbleFormats)(textBlot); + var index = textBlot.offset(_this5.scroll); + var oldValue = mutations[0].oldValue.replace(_cursor2.default.CONTENTS, ""); + var oldText = new _delta2.default().insert(oldValue); + var newText = new _delta2.default().insert(textBlot.value()); + var diffDelta = new _delta2.default() + .retain(index) + .concat(oldText.diff(newText)); + change = diffDelta.ops.reduce(function(delta, op) { + if (op.insert) { + return delta.insert(op.insert, formats); + } else { + return delta.push(op); + } + }, new _delta2.default()); + _this5.delta = oldDelta.compose(change); + })(); + } else { + this.delta = this.getDelta(); + if (!change || !(0, _deepEqual2.default)(oldDelta.compose(change), this.delta)) { + change = oldDelta.diff(this.delta); + } + } + if (change.length() > 0) { + var _emitter; + + var args = [_emitter4.default.events.TEXT_CHANGE, change, oldDelta, source]; + (_emitter = this.emitter).emit.apply( + _emitter, + [_emitter4.default.events.EDITOR_CHANGE].concat(args) + ); + if (source !== _emitter4.default.sources.SILENT) { + var _emitter2; + + (_emitter2 = this.emitter).emit.apply(_emitter2, args); + } + } + return change; + } + } + ]); + + return Editor; + })(); + + function combineFormats(formats, combined) { + return Object.keys(combined).reduce(function(merged, name) { + if (formats[name] == null) return merged; + if (combined[name] === formats[name]) { + merged[name] = combined[name]; + } else if (Array.isArray(combined[name])) { + if (combined[name].indexOf(formats[name]) < 0) { + merged[name] = combined[name].concat([formats[name]]); + } + } else { + merged[name] = [combined[name], formats[name]]; + } + return merged; + }, {}); + } + + function normalizeDelta(delta) { + return delta.ops.reduce(function(delta, op) { + if (op.insert === 1) { + var attributes = (0, _clone2.default)(op.attributes); + delete attributes["image"]; + return delta.insert({ image: op.attributes.image }, attributes); + } + if ( + op.attributes != null && + (op.attributes.list === true || op.attributes.bullet === true) + ) { + op = (0, _clone2.default)(op); + if (op.attributes.list) { + op.attributes.list = "ordered"; + } else { + op.attributes.list = "bullet"; + delete op.attributes.bullet; + } + } + if (typeof op.insert === "string") { + var text = op.insert.replace(/\r\n/g, "\n").replace(/\r/g, "\n"); + return delta.insert(text, op.attributes); + } + return delta.push(op); + }, new _delta2.default()); + } + + exports.default = Editor; + + /***/ + }, + /* 28 */ + /***/ function(module, exports, __webpack_require__) { + "use strict"; + + Object.defineProperty(exports, "__esModule", { + value: true + }); + + var _createClass = (function() { + function defineProperties(target, props) { + for (var i = 0; i < props.length; i++) { + var descriptor = props[i]; + descriptor.enumerable = descriptor.enumerable || false; + descriptor.configurable = true; + if ("value" in descriptor) descriptor.writable = true; + Object.defineProperty(target, descriptor.key, descriptor); + } + } + return function(Constructor, protoProps, staticProps) { + if (protoProps) defineProperties(Constructor.prototype, protoProps); + if (staticProps) defineProperties(Constructor, staticProps); + return Constructor; + }; + })(); + + var _get = function get(object, property, receiver) { + if (object === null) object = Function.prototype; + var desc = Object.getOwnPropertyDescriptor(object, property); + if (desc === undefined) { + var parent = Object.getPrototypeOf(object); + if (parent === null) { + return undefined; + } else { + return get(parent, property, receiver); + } + } else if ("value" in desc) { + return desc.value; + } else { + var getter = desc.get; + if (getter === undefined) { + return undefined; + } + return getter.call(receiver); + } + }; + + var _eventemitter = __webpack_require__(29); + + var _eventemitter2 = _interopRequireDefault(_eventemitter); + + var _logger = __webpack_require__(30); + + var _logger2 = _interopRequireDefault(_logger); + + function _interopRequireDefault(obj) { + return obj && obj.__esModule ? obj : { default: obj }; + } + + function _classCallCheck(instance, Constructor) { + if (!(instance instanceof Constructor)) { + throw new TypeError("Cannot call a class as a function"); + } + } + + function _possibleConstructorReturn(self, call) { + if (!self) { + throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); + } + return call && (typeof call === "object" || typeof call === "function") ? call : self; + } + + function _inherits(subClass, superClass) { + if (typeof superClass !== "function" && superClass !== null) { + throw new TypeError( + "Super expression must either be null or a function, not " + typeof superClass + ); + } + subClass.prototype = Object.create(superClass && superClass.prototype, { + constructor: { value: subClass, enumerable: false, writable: true, configurable: true } + }); + if (superClass) + Object.setPrototypeOf + ? Object.setPrototypeOf(subClass, superClass) + : (subClass.__proto__ = superClass); + } + + var debug = (0, _logger2.default)("quill:events"); + + var Emitter = (function(_EventEmitter) { + _inherits(Emitter, _EventEmitter); + + function Emitter() { + _classCallCheck(this, Emitter); + + var _this = _possibleConstructorReturn( + this, + (Emitter.__proto__ || Object.getPrototypeOf(Emitter)).call(this) + ); + + _this.on("error", debug.error); + return _this; + } + + _createClass(Emitter, [ + { + key: "emit", + value: function emit() { + debug.log.apply(debug, arguments); + _get( + Emitter.prototype.__proto__ || Object.getPrototypeOf(Emitter.prototype), + "emit", + this + ).apply(this, arguments); + } + } + ]); + + return Emitter; + })(_eventemitter2.default); + + Emitter.events = { + EDITOR_CHANGE: "editor-change", + SCROLL_BEFORE_UPDATE: "scroll-before-update", + SCROLL_OPTIMIZE: "scroll-optimize", + SCROLL_UPDATE: "scroll-update", + SELECTION_CHANGE: "selection-change", + TEXT_CHANGE: "text-change" + }; + Emitter.sources = { + API: "api", + SILENT: "silent", + USER: "user" + }; + + exports.default = Emitter; + + /***/ + }, + /* 29 */ + /***/ function(module, exports) { + "use strict"; + + var has = Object.prototype.hasOwnProperty, + prefix = "~"; + + /** + * Constructor to create a storage for our `EE` objects. + * An `Events` instance is a plain object whose properties are event names. + * + * @constructor + * @api private + */ + function Events() {} + + // + // We try to not inherit from `Object.prototype`. In some engines creating an + // instance in this way is faster than calling `Object.create(null)` directly. + // If `Object.create(null)` is not supported we prefix the event names with a + // character to make sure that the built-in object properties are not + // overridden or used as an attack vector. + // + if (Object.create) { + Events.prototype = Object.create(null); + + // + // This hack is needed because the `__proto__` property is still inherited in + // some old browsers like Android 4, iPhone 5.1, Opera 11 and Safari 5. + // + if (!new Events().__proto__) prefix = false; + } + + /** + * Representation of a single event listener. + * + * @param {Function} fn The listener function. + * @param {Mixed} context The context to invoke the listener with. + * @param {Boolean} [once=false] Specify if the listener is a one-time listener. + * @constructor + * @api private + */ + function EE(fn, context, once) { + this.fn = fn; + this.context = context; + this.once = once || false; + } + + /** + * Minimal `EventEmitter` interface that is molded against the Node.js + * `EventEmitter` interface. + * + * @constructor + * @api public + */ + function EventEmitter() { + this._events = new Events(); + this._eventsCount = 0; + } + + /** + * Return an array listing the events for which the emitter has registered + * listeners. + * + * @returns {Array} + * @api public + */ + EventEmitter.prototype.eventNames = function eventNames() { + var names = [], + events, + name; + + if (this._eventsCount === 0) return names; + + for (name in (events = this._events)) { + if (has.call(events, name)) names.push(prefix ? name.slice(1) : name); + } + + if (Object.getOwnPropertySymbols) { + return names.concat(Object.getOwnPropertySymbols(events)); + } + + return names; + }; + + /** + * Return the listeners registered for a given event. + * + * @param {String|Symbol} event The event name. + * @param {Boolean} exists Only check if there are listeners. + * @returns {Array|Boolean} + * @api public + */ + EventEmitter.prototype.listeners = function listeners(event, exists) { + var evt = prefix ? prefix + event : event, + available = this._events[evt]; + + if (exists) return !!available; + if (!available) return []; + if (available.fn) return [available.fn]; + + for (var i = 0, l = available.length, ee = new Array(l); i < l; i++) { + ee[i] = available[i].fn; + } + + return ee; + }; + + /** + * Calls each of the listeners registered for a given event. + * + * @param {String|Symbol} event The event name. + * @returns {Boolean} `true` if the event had listeners, else `false`. + * @api public + */ + EventEmitter.prototype.emit = function emit(event, a1, a2, a3, a4, a5) { + var evt = prefix ? prefix + event : event; + + if (!this._events[evt]) return false; + + var listeners = this._events[evt], + len = arguments.length, + args, + i; + + if (listeners.fn) { + if (listeners.once) this.removeListener(event, listeners.fn, undefined, true); + + switch (len) { + case 1: + return listeners.fn.call(listeners.context), true; + case 2: + return listeners.fn.call(listeners.context, a1), true; + case 3: + return listeners.fn.call(listeners.context, a1, a2), true; + case 4: + return listeners.fn.call(listeners.context, a1, a2, a3), true; + case 5: + return listeners.fn.call(listeners.context, a1, a2, a3, a4), true; + case 6: + return listeners.fn.call(listeners.context, a1, a2, a3, a4, a5), true; + } + + for (i = 1, args = new Array(len - 1); i < len; i++) { + args[i - 1] = arguments[i]; + } + + listeners.fn.apply(listeners.context, args); + } else { + var length = listeners.length, + j; + + for (i = 0; i < length; i++) { + if (listeners[i].once) this.removeListener(event, listeners[i].fn, undefined, true); + + switch (len) { + case 1: + listeners[i].fn.call(listeners[i].context); + break; + case 2: + listeners[i].fn.call(listeners[i].context, a1); + break; + case 3: + listeners[i].fn.call(listeners[i].context, a1, a2); + break; + case 4: + listeners[i].fn.call(listeners[i].context, a1, a2, a3); + break; + default: + if (!args) + for (j = 1, args = new Array(len - 1); j < len; j++) { + args[j - 1] = arguments[j]; + } + + listeners[i].fn.apply(listeners[i].context, args); + } + } + } + + return true; + }; + + /** + * Add a listener for a given event. + * + * @param {String|Symbol} event The event name. + * @param {Function} fn The listener function. + * @param {Mixed} [context=this] The context to invoke the listener with. + * @returns {EventEmitter} `this`. + * @api public + */ + EventEmitter.prototype.on = function on(event, fn, context) { + var listener = new EE(fn, context || this), + evt = prefix ? prefix + event : event; + + if (!this._events[evt]) (this._events[evt] = listener), this._eventsCount++; + else if (!this._events[evt].fn) this._events[evt].push(listener); + else this._events[evt] = [this._events[evt], listener]; + + return this; + }; + + /** + * Add a one-time listener for a given event. + * + * @param {String|Symbol} event The event name. + * @param {Function} fn The listener function. + * @param {Mixed} [context=this] The context to invoke the listener with. + * @returns {EventEmitter} `this`. + * @api public + */ + EventEmitter.prototype.once = function once(event, fn, context) { + var listener = new EE(fn, context || this, true), + evt = prefix ? prefix + event : event; + + if (!this._events[evt]) (this._events[evt] = listener), this._eventsCount++; + else if (!this._events[evt].fn) this._events[evt].push(listener); + else this._events[evt] = [this._events[evt], listener]; + + return this; + }; + + /** + * Remove the listeners of a given event. + * + * @param {String|Symbol} event The event name. + * @param {Function} fn Only remove the listeners that match this function. + * @param {Mixed} context Only remove the listeners that have this context. + * @param {Boolean} once Only remove one-time listeners. + * @returns {EventEmitter} `this`. + * @api public + */ + EventEmitter.prototype.removeListener = function removeListener(event, fn, context, once) { + var evt = prefix ? prefix + event : event; + + if (!this._events[evt]) return this; + if (!fn) { + if (--this._eventsCount === 0) this._events = new Events(); + else delete this._events[evt]; + return this; + } + + var listeners = this._events[evt]; + + if (listeners.fn) { + if ( + listeners.fn === fn && + (!once || listeners.once) && + (!context || listeners.context === context) + ) { + if (--this._eventsCount === 0) this._events = new Events(); + else delete this._events[evt]; + } + } else { + for (var i = 0, events = [], length = listeners.length; i < length; i++) { + if ( + listeners[i].fn !== fn || + (once && !listeners[i].once) || + (context && listeners[i].context !== context) + ) { + events.push(listeners[i]); + } + } + + // + // Reset the array, or remove it completely if we have no more listeners. + // + if (events.length) this._events[evt] = events.length === 1 ? events[0] : events; + else if (--this._eventsCount === 0) this._events = new Events(); + else delete this._events[evt]; + } + + return this; + }; + + /** + * Remove all listeners, or those of the specified event. + * + * @param {String|Symbol} [event] The event name. + * @returns {EventEmitter} `this`. + * @api public + */ + EventEmitter.prototype.removeAllListeners = function removeAllListeners(event) { + var evt; + + if (event) { + evt = prefix ? prefix + event : event; + if (this._events[evt]) { + if (--this._eventsCount === 0) this._events = new Events(); + else delete this._events[evt]; + } + } else { + this._events = new Events(); + this._eventsCount = 0; + } + + return this; + }; + + // + // Alias methods names because people roll like that. + // + EventEmitter.prototype.off = EventEmitter.prototype.removeListener; + EventEmitter.prototype.addListener = EventEmitter.prototype.on; + + // + // This function doesn't apply anymore. + // + EventEmitter.prototype.setMaxListeners = function setMaxListeners() { + return this; + }; + + // + // Expose the prefix. + // + EventEmitter.prefixed = prefix; + + // + // Allow `EventEmitter` to be imported as module namespace. + // + EventEmitter.EventEmitter = EventEmitter; + + // + // Expose the module. + // + if ("undefined" !== typeof module) { + module.exports = EventEmitter; + } + + /***/ + }, + /* 30 */ + /***/ function(module, exports) { + "use strict"; + + Object.defineProperty(exports, "__esModule", { + value: true + }); + var levels = ["error", "warn", "log", "info"]; + var level = "warn"; + + function debug(method) { + if (levels.indexOf(method) <= levels.indexOf(level)) { + for ( + var _len = arguments.length, args = Array(_len > 1 ? _len - 1 : 0), _key = 1; + _key < _len; + _key++ + ) { + args[_key - 1] = arguments[_key]; + } + + console[method].apply(console, args); + } + } + + function namespace(ns) { + return levels.reduce(function(logger, method) { + logger[method] = debug.bind(console, method, ns); + return logger; + }, {}); + } + + debug.level = namespace.level = function(newLevel) { + level = newLevel; + }; + + exports.default = namespace; + + /***/ + }, + /* 31 */ + /***/ function(module, exports, __webpack_require__) { + "use strict"; + + Object.defineProperty(exports, "__esModule", { + value: true + }); + exports.default = exports.Code = undefined; + + var _slicedToArray = (function() { + function sliceIterator(arr, i) { + var _arr = []; + var _n = true; + var _d = false; + var _e = undefined; + try { + for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { + _arr.push(_s.value); + if (i && _arr.length === i) break; + } + } catch (err) { + _d = true; + _e = err; + } finally { + try { + if (!_n && _i["return"]) _i["return"](); + } finally { + if (_d) throw _e; + } + } + return _arr; + } + return function(arr, i) { + if (Array.isArray(arr)) { + return arr; + } else if (Symbol.iterator in Object(arr)) { + return sliceIterator(arr, i); + } else { + throw new TypeError("Invalid attempt to destructure non-iterable instance"); + } + }; + })(); + + var _createClass = (function() { + function defineProperties(target, props) { + for (var i = 0; i < props.length; i++) { + var descriptor = props[i]; + descriptor.enumerable = descriptor.enumerable || false; + descriptor.configurable = true; + if ("value" in descriptor) descriptor.writable = true; + Object.defineProperty(target, descriptor.key, descriptor); + } + } + return function(Constructor, protoProps, staticProps) { + if (protoProps) defineProperties(Constructor.prototype, protoProps); + if (staticProps) defineProperties(Constructor, staticProps); + return Constructor; + }; + })(); + + var _get = function get(object, property, receiver) { + if (object === null) object = Function.prototype; + var desc = Object.getOwnPropertyDescriptor(object, property); + if (desc === undefined) { + var parent = Object.getPrototypeOf(object); + if (parent === null) { + return undefined; + } else { + return get(parent, property, receiver); + } + } else if ("value" in desc) { + return desc.value; + } else { + var getter = desc.get; + if (getter === undefined) { + return undefined; + } + return getter.call(receiver); + } + }; + + var _delta = __webpack_require__(20); + + var _delta2 = _interopRequireDefault(_delta); + + var _parchment = __webpack_require__(2); + + var _parchment2 = _interopRequireDefault(_parchment); + + var _block = __webpack_require__(32); + + var _block2 = _interopRequireDefault(_block); + + var _inline = __webpack_require__(35); + + var _inline2 = _interopRequireDefault(_inline); + + var _text = __webpack_require__(36); + + var _text2 = _interopRequireDefault(_text); + + function _interopRequireDefault(obj) { + return obj && obj.__esModule ? obj : { default: obj }; + } + + function _classCallCheck(instance, Constructor) { + if (!(instance instanceof Constructor)) { + throw new TypeError("Cannot call a class as a function"); + } + } + + function _possibleConstructorReturn(self, call) { + if (!self) { + throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); + } + return call && (typeof call === "object" || typeof call === "function") ? call : self; + } + + function _inherits(subClass, superClass) { + if (typeof superClass !== "function" && superClass !== null) { + throw new TypeError( + "Super expression must either be null or a function, not " + typeof superClass + ); + } + subClass.prototype = Object.create(superClass && superClass.prototype, { + constructor: { value: subClass, enumerable: false, writable: true, configurable: true } + }); + if (superClass) + Object.setPrototypeOf + ? Object.setPrototypeOf(subClass, superClass) + : (subClass.__proto__ = superClass); + } + + var Code = (function(_Inline) { + _inherits(Code, _Inline); + + function Code() { + _classCallCheck(this, Code); + + return _possibleConstructorReturn( + this, + (Code.__proto__ || Object.getPrototypeOf(Code)).apply(this, arguments) + ); + } + + return Code; + })(_inline2.default); + + Code.blotName = "code"; + Code.tagName = "CODE"; + + var CodeBlock = (function(_Block) { + _inherits(CodeBlock, _Block); + + function CodeBlock() { + _classCallCheck(this, CodeBlock); + + return _possibleConstructorReturn( + this, + (CodeBlock.__proto__ || Object.getPrototypeOf(CodeBlock)).apply(this, arguments) + ); + } + + _createClass( + CodeBlock, + [ + { + key: "delta", + value: function delta() { + var _this3 = this; + + var text = this.domNode.textContent; + if (text.endsWith("\n")) { + // Should always be true + text = text.slice(0, -1); + } + return text.split("\n").reduce(function(delta, frag) { + return delta.insert(frag).insert("\n", _this3.formats()); + }, new _delta2.default()); + } + }, + { + key: "format", + value: function format(name, value) { + if (name === this.statics.blotName && value) return; + + var _descendant = this.descendant(_text2.default, this.length() - 1); + + var _descendant2 = _slicedToArray(_descendant, 1); + + var text = _descendant2[0]; + + if (text != null) { + text.deleteAt(text.length() - 1, 1); + } + _get( + CodeBlock.prototype.__proto__ || Object.getPrototypeOf(CodeBlock.prototype), + "format", + this + ).call(this, name, value); + } + }, + { + key: "formatAt", + value: function formatAt(index, length, name, value) { + if (length === 0) return; + if ( + _parchment2.default.query(name, _parchment2.default.Scope.BLOCK) == null || + (name === this.statics.blotName && value === this.statics.formats(this.domNode)) + ) { + return; + } + var nextNewline = this.newlineIndex(index); + if (nextNewline < 0 || nextNewline >= index + length) return; + var prevNewline = this.newlineIndex(index, true) + 1; + var isolateLength = nextNewline - prevNewline + 1; + var blot = this.isolate(prevNewline, isolateLength); + var next = blot.next; + blot.format(name, value); + if (next instanceof CodeBlock) { + next.formatAt(0, index - prevNewline + length - isolateLength, name, value); + } + } + }, + { + key: "insertAt", + value: function insertAt(index, value, def) { + if (def != null) return; + + var _descendant3 = this.descendant(_text2.default, index); + + var _descendant4 = _slicedToArray(_descendant3, 2); + + var text = _descendant4[0]; + var offset = _descendant4[1]; + + text.insertAt(offset, value); + } + }, + { + key: "length", + value: function length() { + var length = this.domNode.textContent.length; + if (!this.domNode.textContent.endsWith("\n")) { + return length + 1; + } + return length; + } + }, + { + key: "newlineIndex", + value: function newlineIndex(searchIndex) { + var reverse = + arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false; + + if (!reverse) { + var offset = this.domNode.textContent.slice(searchIndex).indexOf("\n"); + return offset > -1 ? searchIndex + offset : -1; + } else { + return this.domNode.textContent.slice(0, searchIndex).lastIndexOf("\n"); + } + } + }, + { + key: "optimize", + value: function optimize() { + if (!this.domNode.textContent.endsWith("\n")) { + this.appendChild(_parchment2.default.create("text", "\n")); + } + _get( + CodeBlock.prototype.__proto__ || Object.getPrototypeOf(CodeBlock.prototype), + "optimize", + this + ).call(this); + var next = this.next; + if ( + next != null && + next.prev === this && + next.statics.blotName === this.statics.blotName && + this.statics.formats(this.domNode) === next.statics.formats(next.domNode) + ) { + next.optimize(); + next.moveChildren(this); + next.remove(); + } + } + }, + { + key: "replace", + value: function replace(target) { + _get( + CodeBlock.prototype.__proto__ || Object.getPrototypeOf(CodeBlock.prototype), + "replace", + this + ).call(this, target); + [].slice.call(this.domNode.querySelectorAll("*")).forEach(function(node) { + var blot = _parchment2.default.find(node); + if (blot == null) { + node.parentNode.removeChild(node); + } else if (blot instanceof _parchment2.default.Embed) { + blot.remove(); + } else { + blot.unwrap(); + } + }); + } + } + ], + [ + { + key: "create", + value: function create(value) { + var domNode = _get( + CodeBlock.__proto__ || Object.getPrototypeOf(CodeBlock), + "create", + this + ).call(this, value); + domNode.setAttribute("spellcheck", false); + return domNode; + } + }, + { + key: "formats", + value: function formats(domNode) { + return true; + } + } + ] + ); + + return CodeBlock; + })(_block2.default); + + CodeBlock.blotName = "code-block"; + CodeBlock.tagName = "PRE"; + CodeBlock.TAB = " "; + + exports.Code = Code; + exports.default = CodeBlock; + + /***/ + }, + /* 32 */ + /***/ function(module, exports, __webpack_require__) { + "use strict"; + + Object.defineProperty(exports, "__esModule", { + value: true + }); + exports.default = exports.BlockEmbed = exports.bubbleFormats = undefined; + + var _createClass = (function() { + function defineProperties(target, props) { + for (var i = 0; i < props.length; i++) { + var descriptor = props[i]; + descriptor.enumerable = descriptor.enumerable || false; + descriptor.configurable = true; + if ("value" in descriptor) descriptor.writable = true; + Object.defineProperty(target, descriptor.key, descriptor); + } + } + return function(Constructor, protoProps, staticProps) { + if (protoProps) defineProperties(Constructor.prototype, protoProps); + if (staticProps) defineProperties(Constructor, staticProps); + return Constructor; + }; + })(); + + var _get = function get(object, property, receiver) { + if (object === null) object = Function.prototype; + var desc = Object.getOwnPropertyDescriptor(object, property); + if (desc === undefined) { + var parent = Object.getPrototypeOf(object); + if (parent === null) { + return undefined; + } else { + return get(parent, property, receiver); + } + } else if ("value" in desc) { + return desc.value; + } else { + var getter = desc.get; + if (getter === undefined) { + return undefined; + } + return getter.call(receiver); + } + }; + + var _extend = __webpack_require__(25); + + var _extend2 = _interopRequireDefault(_extend); + + var _delta = __webpack_require__(20); + + var _delta2 = _interopRequireDefault(_delta); + + var _parchment = __webpack_require__(2); + + var _parchment2 = _interopRequireDefault(_parchment); + + var _break = __webpack_require__(33); + + var _break2 = _interopRequireDefault(_break); + + var _embed = __webpack_require__(34); + + var _embed2 = _interopRequireDefault(_embed); + + var _inline = __webpack_require__(35); + + var _inline2 = _interopRequireDefault(_inline); + + var _text = __webpack_require__(36); + + var _text2 = _interopRequireDefault(_text); + + function _interopRequireDefault(obj) { + return obj && obj.__esModule ? obj : { default: obj }; + } + + function _classCallCheck(instance, Constructor) { + if (!(instance instanceof Constructor)) { + throw new TypeError("Cannot call a class as a function"); + } + } + + function _possibleConstructorReturn(self, call) { + if (!self) { + throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); + } + return call && (typeof call === "object" || typeof call === "function") ? call : self; + } + + function _inherits(subClass, superClass) { + if (typeof superClass !== "function" && superClass !== null) { + throw new TypeError( + "Super expression must either be null or a function, not " + typeof superClass + ); + } + subClass.prototype = Object.create(superClass && superClass.prototype, { + constructor: { value: subClass, enumerable: false, writable: true, configurable: true } + }); + if (superClass) + Object.setPrototypeOf + ? Object.setPrototypeOf(subClass, superClass) + : (subClass.__proto__ = superClass); + } + + var NEWLINE_LENGTH = 1; + + var BlockEmbed = (function(_Embed) { + _inherits(BlockEmbed, _Embed); + + function BlockEmbed() { + _classCallCheck(this, BlockEmbed); + + return _possibleConstructorReturn( + this, + (BlockEmbed.__proto__ || Object.getPrototypeOf(BlockEmbed)).apply(this, arguments) + ); + } + + _createClass(BlockEmbed, [ + { + key: "attach", + value: function attach() { + _get( + BlockEmbed.prototype.__proto__ || Object.getPrototypeOf(BlockEmbed.prototype), + "attach", + this + ).call(this); + this.attributes = new _parchment2.default.Attributor.Store(this.domNode); + } + }, + { + key: "delta", + value: function delta() { + return new _delta2.default().insert( + this.value(), + (0, _extend2.default)(this.formats(), this.attributes.values()) + ); + } + }, + { + key: "format", + value: function format(name, value) { + var attribute = _parchment2.default.query( + name, + _parchment2.default.Scope.BLOCK_ATTRIBUTE + ); + if (attribute != null) { + this.attributes.attribute(attribute, value); + } + } + }, + { + key: "formatAt", + value: function formatAt(index, length, name, value) { + this.format(name, value); + } + }, + { + key: "insertAt", + value: function insertAt(index, value, def) { + if (typeof value === "string" && value.endsWith("\n")) { + var block = _parchment2.default.create(Block.blotName); + this.parent.insertBefore(block, index === 0 ? this : this.next); + block.insertAt(0, value.slice(0, -1)); + } else { + _get( + BlockEmbed.prototype.__proto__ || Object.getPrototypeOf(BlockEmbed.prototype), + "insertAt", + this + ).call(this, index, value, def); + } + } + } + ]); + + return BlockEmbed; + })(_embed2.default); + + BlockEmbed.scope = _parchment2.default.Scope.BLOCK_BLOT; + // It is important for cursor behavior BlockEmbeds use tags that are block level elements + + var Block = (function(_Parchment$Block) { + _inherits(Block, _Parchment$Block); + + function Block(domNode) { + _classCallCheck(this, Block); + + var _this2 = _possibleConstructorReturn( + this, + (Block.__proto__ || Object.getPrototypeOf(Block)).call(this, domNode) + ); + + _this2.cache = {}; + return _this2; + } + + _createClass(Block, [ + { + key: "delta", + value: function delta() { + if (this.cache.delta == null) { + this.cache.delta = this.descendants(_parchment2.default.Leaf) + .reduce(function(delta, leaf) { + if (leaf.length() === 0) { + return delta; + } else { + return delta.insert(leaf.value(), bubbleFormats(leaf)); + } + }, new _delta2.default()) + .insert("\n", bubbleFormats(this)); + } + return this.cache.delta; + } + }, + { + key: "deleteAt", + value: function deleteAt(index, length) { + _get( + Block.prototype.__proto__ || Object.getPrototypeOf(Block.prototype), + "deleteAt", + this + ).call(this, index, length); + this.cache = {}; + } + }, + { + key: "formatAt", + value: function formatAt(index, length, name, value) { + if (length <= 0) return; + if (_parchment2.default.query(name, _parchment2.default.Scope.BLOCK)) { + if (index + length === this.length()) { + this.format(name, value); + } + } else { + _get( + Block.prototype.__proto__ || Object.getPrototypeOf(Block.prototype), + "formatAt", + this + ).call(this, index, Math.min(length, this.length() - index - 1), name, value); + } + this.cache = {}; + } + }, + { + key: "insertAt", + value: function insertAt(index, value, def) { + if (def != null) + return _get( + Block.prototype.__proto__ || Object.getPrototypeOf(Block.prototype), + "insertAt", + this + ).call(this, index, value, def); + if (value.length === 0) return; + var lines = value.split("\n"); + var text = lines.shift(); + if (text.length > 0) { + if (index < this.length() - 1 || this.children.tail == null) { + _get( + Block.prototype.__proto__ || Object.getPrototypeOf(Block.prototype), + "insertAt", + this + ).call(this, Math.min(index, this.length() - 1), text); + } else { + this.children.tail.insertAt(this.children.tail.length(), text); + } + this.cache = {}; + } + var block = this; + lines.reduce(function(index, line) { + block = block.split(index, true); + block.insertAt(0, line); + return line.length; + }, index + text.length); + } + }, + { + key: "insertBefore", + value: function insertBefore(blot, ref) { + var head = this.children.head; + _get( + Block.prototype.__proto__ || Object.getPrototypeOf(Block.prototype), + "insertBefore", + this + ).call(this, blot, ref); + if (head instanceof _break2.default) { + head.remove(); + } + this.cache = {}; + } + }, + { + key: "length", + value: function length() { + if (this.cache.length == null) { + this.cache.length = + _get( + Block.prototype.__proto__ || Object.getPrototypeOf(Block.prototype), + "length", + this + ).call(this) + NEWLINE_LENGTH; + } + return this.cache.length; + } + }, + { + key: "moveChildren", + value: function moveChildren(target, ref) { + _get( + Block.prototype.__proto__ || Object.getPrototypeOf(Block.prototype), + "moveChildren", + this + ).call(this, target, ref); + this.cache = {}; + } + }, + { + key: "optimize", + value: function optimize() { + _get( + Block.prototype.__proto__ || Object.getPrototypeOf(Block.prototype), + "optimize", + this + ).call(this); + this.cache = {}; + } + }, + { + key: "path", + value: function path(index) { + return _get( + Block.prototype.__proto__ || Object.getPrototypeOf(Block.prototype), + "path", + this + ).call(this, index, true); + } + }, + { + key: "removeChild", + value: function removeChild(child) { + _get( + Block.prototype.__proto__ || Object.getPrototypeOf(Block.prototype), + "removeChild", + this + ).call(this, child); + this.cache = {}; + } + }, + { + key: "split", + value: function split(index) { + var force = + arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false; + + if (force && (index === 0 || index >= this.length() - NEWLINE_LENGTH)) { + var clone = this.clone(); + if (index === 0) { + this.parent.insertBefore(clone, this); + return this; + } else { + this.parent.insertBefore(clone, this.next); + return clone; + } + } else { + var next = _get( + Block.prototype.__proto__ || Object.getPrototypeOf(Block.prototype), + "split", + this + ).call(this, index, force); + this.cache = {}; + return next; + } + } + } + ]); + + return Block; + })(_parchment2.default.Block); + + Block.blotName = "block"; + Block.tagName = "P"; + Block.defaultChild = "break"; + Block.allowedChildren = [_inline2.default, _embed2.default, _text2.default]; + + function bubbleFormats(blot) { + var formats = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; + + if (blot == null) return formats; + if (typeof blot.formats === "function") { + formats = (0, _extend2.default)(formats, blot.formats()); + } + if ( + blot.parent == null || + blot.parent.blotName == "scroll" || + blot.parent.statics.scope !== blot.statics.scope + ) { + return formats; + } + return bubbleFormats(blot.parent, formats); + } + + exports.bubbleFormats = bubbleFormats; + exports.BlockEmbed = BlockEmbed; + exports.default = Block; + + /***/ + }, + /* 33 */ + /***/ function(module, exports, __webpack_require__) { + "use strict"; + + Object.defineProperty(exports, "__esModule", { + value: true + }); + + var _createClass = (function() { + function defineProperties(target, props) { + for (var i = 0; i < props.length; i++) { + var descriptor = props[i]; + descriptor.enumerable = descriptor.enumerable || false; + descriptor.configurable = true; + if ("value" in descriptor) descriptor.writable = true; + Object.defineProperty(target, descriptor.key, descriptor); + } + } + return function(Constructor, protoProps, staticProps) { + if (protoProps) defineProperties(Constructor.prototype, protoProps); + if (staticProps) defineProperties(Constructor, staticProps); + return Constructor; + }; + })(); + + var _get = function get(object, property, receiver) { + if (object === null) object = Function.prototype; + var desc = Object.getOwnPropertyDescriptor(object, property); + if (desc === undefined) { + var parent = Object.getPrototypeOf(object); + if (parent === null) { + return undefined; + } else { + return get(parent, property, receiver); + } + } else if ("value" in desc) { + return desc.value; + } else { + var getter = desc.get; + if (getter === undefined) { + return undefined; + } + return getter.call(receiver); + } + }; + + var _embed = __webpack_require__(34); + + var _embed2 = _interopRequireDefault(_embed); + + function _interopRequireDefault(obj) { + return obj && obj.__esModule ? obj : { default: obj }; + } + + function _classCallCheck(instance, Constructor) { + if (!(instance instanceof Constructor)) { + throw new TypeError("Cannot call a class as a function"); + } + } + + function _possibleConstructorReturn(self, call) { + if (!self) { + throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); + } + return call && (typeof call === "object" || typeof call === "function") ? call : self; + } + + function _inherits(subClass, superClass) { + if (typeof superClass !== "function" && superClass !== null) { + throw new TypeError( + "Super expression must either be null or a function, not " + typeof superClass + ); + } + subClass.prototype = Object.create(superClass && superClass.prototype, { + constructor: { value: subClass, enumerable: false, writable: true, configurable: true } + }); + if (superClass) + Object.setPrototypeOf + ? Object.setPrototypeOf(subClass, superClass) + : (subClass.__proto__ = superClass); + } + + var Break = (function(_Embed) { + _inherits(Break, _Embed); + + function Break() { + _classCallCheck(this, Break); + + return _possibleConstructorReturn( + this, + (Break.__proto__ || Object.getPrototypeOf(Break)).apply(this, arguments) + ); + } + + _createClass( + Break, + [ + { + key: "insertInto", + value: function insertInto(parent, ref) { + if (parent.children.length === 0) { + _get( + Break.prototype.__proto__ || Object.getPrototypeOf(Break.prototype), + "insertInto", + this + ).call(this, parent, ref); + } + } + }, + { + key: "length", + value: function length() { + return 0; + } + }, + { + key: "value", + value: function value() { + return ""; + } + } + ], + [ + { + key: "value", + value: function value(domNode) { + return undefined; + } + } + ] + ); + + return Break; + })(_embed2.default); + + Break.blotName = "break"; + Break.tagName = "BR"; + + exports.default = Break; + + /***/ + }, + /* 34 */ + /***/ function(module, exports, __webpack_require__) { + "use strict"; + + Object.defineProperty(exports, "__esModule", { + value: true + }); + + var _parchment = __webpack_require__(2); + + var _parchment2 = _interopRequireDefault(_parchment); + + function _interopRequireDefault(obj) { + return obj && obj.__esModule ? obj : { default: obj }; + } + + function _classCallCheck(instance, Constructor) { + if (!(instance instanceof Constructor)) { + throw new TypeError("Cannot call a class as a function"); + } + } + + function _possibleConstructorReturn(self, call) { + if (!self) { + throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); + } + return call && (typeof call === "object" || typeof call === "function") ? call : self; + } + + function _inherits(subClass, superClass) { + if (typeof superClass !== "function" && superClass !== null) { + throw new TypeError( + "Super expression must either be null or a function, not " + typeof superClass + ); + } + subClass.prototype = Object.create(superClass && superClass.prototype, { + constructor: { value: subClass, enumerable: false, writable: true, configurable: true } + }); + if (superClass) + Object.setPrototypeOf + ? Object.setPrototypeOf(subClass, superClass) + : (subClass.__proto__ = superClass); + } + + var Embed = (function(_Parchment$Embed) { + _inherits(Embed, _Parchment$Embed); + + function Embed() { + _classCallCheck(this, Embed); + + return _possibleConstructorReturn( + this, + (Embed.__proto__ || Object.getPrototypeOf(Embed)).apply(this, arguments) + ); + } + + return Embed; + })(_parchment2.default.Embed); + + exports.default = Embed; + + /***/ + }, + /* 35 */ + /***/ function(module, exports, __webpack_require__) { + "use strict"; + + Object.defineProperty(exports, "__esModule", { + value: true + }); + + var _createClass = (function() { + function defineProperties(target, props) { + for (var i = 0; i < props.length; i++) { + var descriptor = props[i]; + descriptor.enumerable = descriptor.enumerable || false; + descriptor.configurable = true; + if ("value" in descriptor) descriptor.writable = true; + Object.defineProperty(target, descriptor.key, descriptor); + } + } + return function(Constructor, protoProps, staticProps) { + if (protoProps) defineProperties(Constructor.prototype, protoProps); + if (staticProps) defineProperties(Constructor, staticProps); + return Constructor; + }; + })(); + + var _get = function get(object, property, receiver) { + if (object === null) object = Function.prototype; + var desc = Object.getOwnPropertyDescriptor(object, property); + if (desc === undefined) { + var parent = Object.getPrototypeOf(object); + if (parent === null) { + return undefined; + } else { + return get(parent, property, receiver); + } + } else if ("value" in desc) { + return desc.value; + } else { + var getter = desc.get; + if (getter === undefined) { + return undefined; + } + return getter.call(receiver); + } + }; + + var _extend = __webpack_require__(25); + + var _extend2 = _interopRequireDefault(_extend); + + var _embed = __webpack_require__(34); + + var _embed2 = _interopRequireDefault(_embed); + + var _text = __webpack_require__(36); + + var _text2 = _interopRequireDefault(_text); + + var _parchment = __webpack_require__(2); + + var _parchment2 = _interopRequireDefault(_parchment); + + function _interopRequireDefault(obj) { + return obj && obj.__esModule ? obj : { default: obj }; + } + + function _classCallCheck(instance, Constructor) { + if (!(instance instanceof Constructor)) { + throw new TypeError("Cannot call a class as a function"); + } + } + + function _possibleConstructorReturn(self, call) { + if (!self) { + throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); + } + return call && (typeof call === "object" || typeof call === "function") ? call : self; + } + + function _inherits(subClass, superClass) { + if (typeof superClass !== "function" && superClass !== null) { + throw new TypeError( + "Super expression must either be null or a function, not " + typeof superClass + ); + } + subClass.prototype = Object.create(superClass && superClass.prototype, { + constructor: { value: subClass, enumerable: false, writable: true, configurable: true } + }); + if (superClass) + Object.setPrototypeOf + ? Object.setPrototypeOf(subClass, superClass) + : (subClass.__proto__ = superClass); + } + + var Inline = (function(_Parchment$Inline) { + _inherits(Inline, _Parchment$Inline); + + function Inline() { + _classCallCheck(this, Inline); + + return _possibleConstructorReturn( + this, + (Inline.__proto__ || Object.getPrototypeOf(Inline)).apply(this, arguments) + ); + } + + _createClass( + Inline, + [ + { + key: "formatAt", + value: function formatAt(index, length, name, value) { + if ( + Inline.compare(this.statics.blotName, name) < 0 && + _parchment2.default.query(name, _parchment2.default.Scope.BLOT) + ) { + var blot = this.isolate(index, length); + if (value) { + blot.wrap(name, value); + } + } else { + _get( + Inline.prototype.__proto__ || Object.getPrototypeOf(Inline.prototype), + "formatAt", + this + ).call(this, index, length, name, value); + } + } + }, + { + key: "optimize", + value: function optimize() { + _get( + Inline.prototype.__proto__ || Object.getPrototypeOf(Inline.prototype), + "optimize", + this + ).call(this); + var ref = this.parent.parent; + if ( + this.parent instanceof Inline && + Inline.compare(this.statics.blotName, this.parent.statics.blotName) > 0 + ) { + var parent = this.parent.isolate(this.offset(), this.length()); + this.moveChildren(parent); + parent.wrap(this); + } + } + } + ], + [ + { + key: "compare", + value: function compare(self, other) { + var selfIndex = Inline.order.indexOf(self); + var otherIndex = Inline.order.indexOf(other); + if (selfIndex >= 0 || otherIndex >= 0) { + return selfIndex - otherIndex; + } else if (self === other) { + return 0; + } else if (self < other) { + return -1; + } else { + return 1; + } + } + } + ] + ); + + return Inline; + })(_parchment2.default.Inline); + + Inline.allowedChildren = [Inline, _embed2.default, _text2.default]; + // Lower index means deeper in the DOM tree, since not found (-1) is for embeds + Inline.order = [ + "cursor", + "inline", // Must be lower + "code", + "underline", + "strike", + "italic", + "bold", + "script", + "link" // Must be higher + ]; + + exports.default = Inline; + + /***/ + }, + /* 36 */ + /***/ function(module, exports, __webpack_require__) { + "use strict"; + + Object.defineProperty(exports, "__esModule", { + value: true + }); + + var _parchment = __webpack_require__(2); + + var _parchment2 = _interopRequireDefault(_parchment); + + function _interopRequireDefault(obj) { + return obj && obj.__esModule ? obj : { default: obj }; + } + + function _classCallCheck(instance, Constructor) { + if (!(instance instanceof Constructor)) { + throw new TypeError("Cannot call a class as a function"); + } + } + + function _possibleConstructorReturn(self, call) { + if (!self) { + throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); + } + return call && (typeof call === "object" || typeof call === "function") ? call : self; + } + + function _inherits(subClass, superClass) { + if (typeof superClass !== "function" && superClass !== null) { + throw new TypeError( + "Super expression must either be null or a function, not " + typeof superClass + ); + } + subClass.prototype = Object.create(superClass && superClass.prototype, { + constructor: { value: subClass, enumerable: false, writable: true, configurable: true } + }); + if (superClass) + Object.setPrototypeOf + ? Object.setPrototypeOf(subClass, superClass) + : (subClass.__proto__ = superClass); + } + + var TextBlot = (function(_Parchment$Text) { + _inherits(TextBlot, _Parchment$Text); + + function TextBlot() { + _classCallCheck(this, TextBlot); + + return _possibleConstructorReturn( + this, + (TextBlot.__proto__ || Object.getPrototypeOf(TextBlot)).apply(this, arguments) + ); + } + + return TextBlot; + })(_parchment2.default.Text); + + exports.default = TextBlot; + + /***/ + }, + /* 37 */ + /***/ function(module, exports, __webpack_require__) { + "use strict"; + + Object.defineProperty(exports, "__esModule", { + value: true + }); + + var _slicedToArray = (function() { + function sliceIterator(arr, i) { + var _arr = []; + var _n = true; + var _d = false; + var _e = undefined; + try { + for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { + _arr.push(_s.value); + if (i && _arr.length === i) break; + } + } catch (err) { + _d = true; + _e = err; + } finally { + try { + if (!_n && _i["return"]) _i["return"](); + } finally { + if (_d) throw _e; + } + } + return _arr; + } + return function(arr, i) { + if (Array.isArray(arr)) { + return arr; + } else if (Symbol.iterator in Object(arr)) { + return sliceIterator(arr, i); + } else { + throw new TypeError("Invalid attempt to destructure non-iterable instance"); + } + }; + })(); + + var _get = function get(object, property, receiver) { + if (object === null) object = Function.prototype; + var desc = Object.getOwnPropertyDescriptor(object, property); + if (desc === undefined) { + var parent = Object.getPrototypeOf(object); + if (parent === null) { + return undefined; + } else { + return get(parent, property, receiver); + } + } else if ("value" in desc) { + return desc.value; + } else { + var getter = desc.get; + if (getter === undefined) { + return undefined; + } + return getter.call(receiver); + } + }; + + var _createClass = (function() { + function defineProperties(target, props) { + for (var i = 0; i < props.length; i++) { + var descriptor = props[i]; + descriptor.enumerable = descriptor.enumerable || false; + descriptor.configurable = true; + if ("value" in descriptor) descriptor.writable = true; + Object.defineProperty(target, descriptor.key, descriptor); + } + } + return function(Constructor, protoProps, staticProps) { + if (protoProps) defineProperties(Constructor.prototype, protoProps); + if (staticProps) defineProperties(Constructor, staticProps); + return Constructor; + }; + })(); + + var _parchment = __webpack_require__(2); + + var _parchment2 = _interopRequireDefault(_parchment); + + var _embed = __webpack_require__(34); + + var _embed2 = _interopRequireDefault(_embed); + + var _emitter = __webpack_require__(28); + + var _emitter2 = _interopRequireDefault(_emitter); + + function _interopRequireDefault(obj) { + return obj && obj.__esModule ? obj : { default: obj }; + } + + function _classCallCheck(instance, Constructor) { + if (!(instance instanceof Constructor)) { + throw new TypeError("Cannot call a class as a function"); + } + } + + function _possibleConstructorReturn(self, call) { + if (!self) { + throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); + } + return call && (typeof call === "object" || typeof call === "function") ? call : self; + } + + function _inherits(subClass, superClass) { + if (typeof superClass !== "function" && superClass !== null) { + throw new TypeError( + "Super expression must either be null or a function, not " + typeof superClass + ); + } + subClass.prototype = Object.create(superClass && superClass.prototype, { + constructor: { value: subClass, enumerable: false, writable: true, configurable: true } + }); + if (superClass) + Object.setPrototypeOf + ? Object.setPrototypeOf(subClass, superClass) + : (subClass.__proto__ = superClass); + } + + var Cursor = (function(_Embed) { + _inherits(Cursor, _Embed); + + _createClass(Cursor, null, [ + { + key: "value", + value: function value(domNode) { + return undefined; + } + } + ]); + + function Cursor(domNode, selection) { + _classCallCheck(this, Cursor); + + var _this = _possibleConstructorReturn( + this, + (Cursor.__proto__ || Object.getPrototypeOf(Cursor)).call(this, domNode) + ); + + _this.selection = selection; + _this.textNode = document.createTextNode(Cursor.CONTENTS); + _this.domNode.appendChild(_this.textNode); + _this._length = 0; + return _this; + } + + _createClass(Cursor, [ + { + key: "detach", + value: function detach() { + // super.detach() will also clear domNode.__blot + if (this.parent != null) this.parent.removeChild(this); + } + }, + { + key: "format", + value: function format(name, value) { + if (this._length !== 0) { + return _get( + Cursor.prototype.__proto__ || Object.getPrototypeOf(Cursor.prototype), + "format", + this + ).call(this, name, value); + } + var target = this, + index = 0; + while ( + target != null && + target.statics.scope !== _parchment2.default.Scope.BLOCK_BLOT + ) { + index += target.offset(target.parent); + target = target.parent; + } + if (target != null) { + this._length = Cursor.CONTENTS.length; + target.optimize(); + target.formatAt(index, Cursor.CONTENTS.length, name, value); + this._length = 0; + } + } + }, + { + key: "index", + value: function index(node, offset) { + if (node === this.textNode) return 0; + return _get( + Cursor.prototype.__proto__ || Object.getPrototypeOf(Cursor.prototype), + "index", + this + ).call(this, node, offset); + } + }, + { + key: "length", + value: function length() { + return this._length; + } + }, + { + key: "position", + value: function position(index) { + return [this.textNode, this.textNode.data.length]; + } + }, + { + key: "remove", + value: function remove() { + _get( + Cursor.prototype.__proto__ || Object.getPrototypeOf(Cursor.prototype), + "remove", + this + ).call(this); + this.parent = null; + } + }, + { + key: "restore", + value: function restore() { + var _this2 = this; + + if (this.selection.composing) return; + if (this.parent == null) return; + var textNode = this.textNode; + var range = this.selection.getNativeRange(); + // Link format will insert text outside of anchor tag + while (this.domNode.lastChild != null && this.domNode.lastChild !== this.textNode) { + this.domNode.parentNode.insertBefore(this.domNode.lastChild, this.domNode); + } + if (this.textNode.data !== Cursor.CONTENTS) { + this.textNode.data = this.textNode.data.split(Cursor.CONTENTS).join(""); + this.parent.insertBefore(_parchment2.default.create(this.textNode), this); + this.textNode = document.createTextNode(Cursor.CONTENTS); + this.domNode.appendChild(this.textNode); + } + this.remove(); + if (range != null && range.start.node === textNode && range.end.node === textNode) { + this.selection.emitter.once(_emitter2.default.events.SCROLL_OPTIMIZE, function() { + var _map = [range.start.offset, range.end.offset].map(function(offset) { + return Math.max(0, Math.min(textNode.data.length, offset - 1)); + }); + + var _map2 = _slicedToArray(_map, 2); + + var start = _map2[0]; + var end = _map2[1]; + + _this2.selection.setNativeRange(textNode, start, textNode, end); + }); + } + } + }, + { + key: "update", + value: function update(mutations) { + var _this3 = this; + + mutations.forEach(function(mutation) { + if (mutation.type === "characterData" && mutation.target === _this3.textNode) { + _this3.restore(); + } + }); + } + }, + { + key: "value", + value: function value() { + return ""; + } + } + ]); + + return Cursor; + })(_embed2.default); + + Cursor.blotName = "cursor"; + Cursor.className = "ql-cursor"; + Cursor.tagName = "span"; + Cursor.CONTENTS = "\uFEFF"; // Zero width no break space + + exports.default = Cursor; + + /***/ + }, + /* 38 */ + /***/ function(module, exports) { + var clone = (function() { + "use strict"; + + var nativeMap; + try { + nativeMap = Map; + } catch (_) { + // maybe a reference error because no `Map`. Give it a dummy value that no + // value will ever be an instanceof. + nativeMap = function() {}; + } + + var nativeSet; + try { + nativeSet = Set; + } catch (_) { + nativeSet = function() {}; + } + + var nativePromise; + try { + nativePromise = Promise; + } catch (_) { + nativePromise = function() {}; + } + + /** + * Clones (copies) an Object using deep copying. + * + * This function supports circular references by default, but if you are certain + * there are no circular references in your object, you can save some CPU time + * by calling clone(obj, false). + * + * Caution: if `circular` is false and `parent` contains circular references, + * your program may enter an infinite loop and crash. + * + * @param `parent` - the object to be cloned + * @param `circular` - set to true if the object to be cloned may contain + * circular references. (optional - true by default) + * @param `depth` - set to a number if the object is only to be cloned to + * a particular depth. (optional - defaults to Infinity) + * @param `prototype` - sets the prototype to be used when cloning an object. + * (optional - defaults to parent prototype). + */ + function clone(parent, circular, depth, prototype) { + var filter; + if (typeof circular === "object") { + depth = circular.depth; + prototype = circular.prototype; + filter = circular.filter; + circular = circular.circular; + } + // maintain two arrays for circular references, where corresponding parents + // and children have the same index + var allParents = []; + var allChildren = []; + + var useBuffer = typeof Buffer != "undefined"; + + if (typeof circular == "undefined") circular = true; + + if (typeof depth == "undefined") depth = Infinity; + + // recurse this function so we don't reset allParents and allChildren + function _clone(parent, depth) { + // cloning null always returns null + if (parent === null) return null; + + if (depth === 0) return parent; + + var child; + var proto; + if (typeof parent != "object") { + return parent; + } + + if (parent instanceof nativeMap) { + child = new nativeMap(); + } else if (parent instanceof nativeSet) { + child = new nativeSet(); + } else if (parent instanceof nativePromise) { + child = new nativePromise(function(resolve, reject) { + parent.then( + function(value) { + resolve(_clone(value, depth - 1)); + }, + function(err) { + reject(_clone(err, depth - 1)); + } + ); + }); + } else if (clone.__isArray(parent)) { + child = []; + } else if (clone.__isRegExp(parent)) { + child = new RegExp(parent.source, __getRegExpFlags(parent)); + if (parent.lastIndex) child.lastIndex = parent.lastIndex; + } else if (clone.__isDate(parent)) { + child = new Date(parent.getTime()); + } else if (useBuffer && Buffer.isBuffer(parent)) { + child = new Buffer(parent.length); + parent.copy(child); + return child; + } else { + if (typeof prototype == "undefined") { + proto = Object.getPrototypeOf(parent); + child = Object.create(proto); + } else { + child = Object.create(prototype); + proto = prototype; + } + } + + if (circular) { + var index = allParents.indexOf(parent); + + if (index != -1) { + return allChildren[index]; + } + allParents.push(parent); + allChildren.push(child); + } + + if (parent instanceof nativeMap) { + var keyIterator = parent.keys(); + while (true) { + var next = keyIterator.next(); + if (next.done) { + break; + } + var keyChild = _clone(next.value, depth - 1); + var valueChild = _clone(parent.get(next.value), depth - 1); + child.set(keyChild, valueChild); + } + } + if (parent instanceof nativeSet) { + var iterator = parent.keys(); + while (true) { + var next = iterator.next(); + if (next.done) { + break; + } + var entryChild = _clone(next.value, depth - 1); + child.add(entryChild); + } + } + + for (var i in parent) { + var attrs; + if (proto) { + attrs = Object.getOwnPropertyDescriptor(proto, i); + } + + if (attrs && attrs.set == null) { + continue; + } + child[i] = _clone(parent[i], depth - 1); + } + + if (Object.getOwnPropertySymbols) { + var symbols = Object.getOwnPropertySymbols(parent); + for (var i = 0; i < symbols.length; i++) { + // Don't need to worry about cloning a symbol because it is a primitive, + // like a number or string. + var symbol = symbols[i]; + child[symbol] = _clone(parent[symbol], depth - 1); + } + } + + return child; + } + + return _clone(parent, depth); + } + + /** + * Simple flat clone using prototype, accepts only objects, usefull for property + * override on FLAT configuration object (no nested props). + * + * USE WITH CAUTION! This may not behave as you wish if you do not know how this + * works. + */ + clone.clonePrototype = function clonePrototype(parent) { + if (parent === null) return null; + + var c = function() {}; + c.prototype = parent; + return new c(); + }; + + // private utility functions + + function __objToStr(o) { + return Object.prototype.toString.call(o); + } + clone.__objToStr = __objToStr; + + function __isDate(o) { + return typeof o === "object" && __objToStr(o) === "[object Date]"; + } + clone.__isDate = __isDate; + + function __isArray(o) { + return typeof o === "object" && __objToStr(o) === "[object Array]"; + } + clone.__isArray = __isArray; + + function __isRegExp(o) { + return typeof o === "object" && __objToStr(o) === "[object RegExp]"; + } + clone.__isRegExp = __isRegExp; + + function __getRegExpFlags(re) { + var flags = ""; + if (re.global) flags += "g"; + if (re.ignoreCase) flags += "i"; + if (re.multiline) flags += "m"; + return flags; + } + clone.__getRegExpFlags = __getRegExpFlags; + + return clone; + })(); + + if (typeof module === "object" && module.exports) { + module.exports = clone; + } + + /***/ + }, + /* 39 */ + /***/ function(module, exports) { + "use strict"; + + Object.defineProperty(exports, "__esModule", { + value: true + }); + + function _classCallCheck(instance, Constructor) { + if (!(instance instanceof Constructor)) { + throw new TypeError("Cannot call a class as a function"); + } + } + + var Module = function Module(quill) { + var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; + + _classCallCheck(this, Module); + + this.quill = quill; + this.options = options; + }; + + Module.DEFAULTS = {}; + + exports.default = Module; + + /***/ + }, + /* 40 */ + /***/ function(module, exports, __webpack_require__) { + "use strict"; + + Object.defineProperty(exports, "__esModule", { + value: true + }); + exports.default = exports.Range = undefined; + + var _slicedToArray = (function() { + function sliceIterator(arr, i) { + var _arr = []; + var _n = true; + var _d = false; + var _e = undefined; + try { + for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { + _arr.push(_s.value); + if (i && _arr.length === i) break; + } + } catch (err) { + _d = true; + _e = err; + } finally { + try { + if (!_n && _i["return"]) _i["return"](); + } finally { + if (_d) throw _e; + } + } + return _arr; + } + return function(arr, i) { + if (Array.isArray(arr)) { + return arr; + } else if (Symbol.iterator in Object(arr)) { + return sliceIterator(arr, i); + } else { + throw new TypeError("Invalid attempt to destructure non-iterable instance"); + } + }; + })(); + + var _createClass = (function() { + function defineProperties(target, props) { + for (var i = 0; i < props.length; i++) { + var descriptor = props[i]; + descriptor.enumerable = descriptor.enumerable || false; + descriptor.configurable = true; + if ("value" in descriptor) descriptor.writable = true; + Object.defineProperty(target, descriptor.key, descriptor); + } + } + return function(Constructor, protoProps, staticProps) { + if (protoProps) defineProperties(Constructor.prototype, protoProps); + if (staticProps) defineProperties(Constructor, staticProps); + return Constructor; + }; + })(); + + var _parchment = __webpack_require__(2); + + var _parchment2 = _interopRequireDefault(_parchment); + + var _clone = __webpack_require__(38); + + var _clone2 = _interopRequireDefault(_clone); + + var _deepEqual = __webpack_require__(22); + + var _deepEqual2 = _interopRequireDefault(_deepEqual); + + var _break = __webpack_require__(33); + + var _break2 = _interopRequireDefault(_break); + + var _emitter3 = __webpack_require__(28); + + var _emitter4 = _interopRequireDefault(_emitter3); + + var _logger = __webpack_require__(30); + + var _logger2 = _interopRequireDefault(_logger); + + function _interopRequireDefault(obj) { + return obj && obj.__esModule ? obj : { default: obj }; + } + + function _toConsumableArray(arr) { + if (Array.isArray(arr)) { + for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { + arr2[i] = arr[i]; + } + return arr2; + } else { + return Array.from(arr); + } + } + + function _classCallCheck(instance, Constructor) { + if (!(instance instanceof Constructor)) { + throw new TypeError("Cannot call a class as a function"); + } + } + + var debug = (0, _logger2.default)("quill:selection"); + + var Range = function Range(index) { + var length = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0; + + _classCallCheck(this, Range); + + this.index = index; + this.length = length; + }; + + var Selection = (function() { + function Selection(scroll, emitter) { + var _this = this; + + _classCallCheck(this, Selection); + + this.emitter = emitter; + this.scroll = scroll; + this.composing = false; + this.root = this.scroll.domNode; + this.root.addEventListener("compositionstart", function() { + _this.composing = true; + }); + this.root.addEventListener("compositionend", function() { + _this.composing = false; + }); + this.cursor = _parchment2.default.create("cursor", this); + // savedRange is last non-null range + this.lastRange = this.savedRange = new Range(0, 0); + ["keyup", "mouseup", "mouseleave", "touchend", "touchleave", "focus", "blur"].forEach( + function(eventName) { + _this.root.addEventListener(eventName, function() { + // When range used to be a selection and user click within the selection, + // the range now being a cursor has not updated yet without setTimeout + setTimeout(_this.update.bind(_this, _emitter4.default.sources.USER), 100); + }); + } + ); + this.emitter.on(_emitter4.default.events.EDITOR_CHANGE, function(type, delta) { + if (type === _emitter4.default.events.TEXT_CHANGE && delta.length() > 0) { + _this.update(_emitter4.default.sources.SILENT); + } + }); + this.emitter.on(_emitter4.default.events.SCROLL_BEFORE_UPDATE, function() { + var native = _this.getNativeRange(); + if (native == null) return; + if (native.start.node === _this.cursor.textNode) return; // cursor.restore() will handle + // TODO unclear if this has negative side effects + _this.emitter.once(_emitter4.default.events.SCROLL_UPDATE, function() { + try { + _this.setNativeRange( + native.start.node, + native.start.offset, + native.end.node, + native.end.offset + ); + } catch (ignored) {} + }); + }); + this.update(_emitter4.default.sources.SILENT); + } + + _createClass(Selection, [ + { + key: "focus", + value: function focus() { + if (this.hasFocus()) return; + var bodyTop = document.body.scrollTop; + this.root.focus(); + document.body.scrollTop = bodyTop; + this.setRange(this.savedRange); + } + }, + { + key: "format", + value: function format(_format, value) { + this.scroll.update(); + var nativeRange = this.getNativeRange(); + if ( + nativeRange == null || + !nativeRange.native.collapsed || + _parchment2.default.query(_format, _parchment2.default.Scope.BLOCK) + ) + return; + if (nativeRange.start.node !== this.cursor.textNode) { + var blot = _parchment2.default.find(nativeRange.start.node, false); + if (blot == null) return; + // TODO Give blot ability to not split + if (blot instanceof _parchment2.default.Leaf) { + var after = blot.split(nativeRange.start.offset); + blot.parent.insertBefore(this.cursor, after); + } else { + blot.insertBefore(this.cursor, nativeRange.start.node); // Should never happen + } + this.cursor.attach(); + } + this.cursor.format(_format, value); + this.scroll.optimize(); + this.setNativeRange(this.cursor.textNode, this.cursor.textNode.data.length); + this.update(); + } + }, + { + key: "getBounds", + value: function getBounds(index) { + var length = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0; + + var scrollLength = this.scroll.length(); + index = Math.min(index, scrollLength - 1); + length = Math.min(index + length, scrollLength - 1) - index; + var bounds = void 0; + var node = void 0; + var _scroll$leaf = this.scroll.leaf(index); + + var _scroll$leaf2 = _slicedToArray(_scroll$leaf, 2); + + var leaf = _scroll$leaf2[0]; + var offset = _scroll$leaf2[1]; + + if (leaf == null) return null; + + var _leaf$position = leaf.position(offset, true); + + var _leaf$position2 = _slicedToArray(_leaf$position, 2); + + node = _leaf$position2[0]; + offset = _leaf$position2[1]; + + var range = document.createRange(); + if (length > 0) { + range.setStart(node, offset); + + var _scroll$leaf3 = this.scroll.leaf(index + length); + + var _scroll$leaf4 = _slicedToArray(_scroll$leaf3, 2); + + leaf = _scroll$leaf4[0]; + offset = _scroll$leaf4[1]; + + if (leaf == null) return null; + + var _leaf$position3 = leaf.position(offset, true); + + var _leaf$position4 = _slicedToArray(_leaf$position3, 2); + + node = _leaf$position4[0]; + offset = _leaf$position4[1]; + + range.setEnd(node, offset); + bounds = range.getBoundingClientRect(); + } else { + var side = "left"; + if (node instanceof Text) { + if (offset < node.data.length) { + range.setStart(node, offset); + range.setEnd(node, offset + 1); + } else { + range.setStart(node, offset - 1); + range.setEnd(node, offset); + side = "right"; + } + var rect = range.getBoundingClientRect(); + } else { + var rect = leaf.domNode.getBoundingClientRect(); + if (offset > 0) side = "right"; + } + bounds = { + height: rect.height, + left: rect[side], + width: 0, + top: rect.top + }; + } + var containerBounds = this.root.parentNode.getBoundingClientRect(); + return { + left: bounds.left - containerBounds.left, + right: bounds.left + bounds.width - containerBounds.left, + top: bounds.top - containerBounds.top, + bottom: bounds.top + bounds.height - containerBounds.top, + height: bounds.height, + width: bounds.width + }; + } + }, + { + key: "getNativeRange", + value: function getNativeRange() { + var selection = document.getSelection(); + if (selection == null || selection.rangeCount <= 0) return null; + var nativeRange = selection.getRangeAt(0); + if (nativeRange == null) return null; + if ( + !contains(this.root, nativeRange.startContainer) || + (!nativeRange.collapsed && !contains(this.root, nativeRange.endContainer)) + ) { + return null; + } + var range = { + start: { node: nativeRange.startContainer, offset: nativeRange.startOffset }, + end: { node: nativeRange.endContainer, offset: nativeRange.endOffset }, + native: nativeRange + }; + [range.start, range.end].forEach(function(position) { + var node = position.node, + offset = position.offset; + while (!(node instanceof Text) && node.childNodes.length > 0) { + if (node.childNodes.length > offset) { + node = node.childNodes[offset]; + offset = 0; + } else if (node.childNodes.length === offset) { + node = node.lastChild; + offset = node instanceof Text ? node.data.length : node.childNodes.length + 1; + } else { + break; + } + } + (position.node = node), (position.offset = offset); + }); + debug.info("getNativeRange", range); + return range; + } + }, + { + key: "getRange", + value: function getRange() { + var _this2 = this; + + var range = this.getNativeRange(); + if (range == null) return [null, null]; + var positions = [[range.start.node, range.start.offset]]; + if (!range.native.collapsed) { + positions.push([range.end.node, range.end.offset]); + } + var indexes = positions.map(function(position) { + var _position = _slicedToArray(position, 2); + + var node = _position[0]; + var offset = _position[1]; + + var blot = _parchment2.default.find(node, true); + var index = blot.offset(_this2.scroll); + if (offset === 0) { + return index; + } else if (blot instanceof _parchment2.default.Container) { + return index + blot.length(); + } else { + return index + blot.index(node, offset); + } + }); + var start = Math.min.apply(Math, _toConsumableArray(indexes)), + end = Math.max.apply(Math, _toConsumableArray(indexes)); + return [new Range(start, end - start), range]; + } + }, + { + key: "hasFocus", + value: function hasFocus() { + return document.activeElement === this.root; + } + }, + { + key: "scrollIntoView", + value: function scrollIntoView() { + var range = + arguments.length > 0 && arguments[0] !== undefined + ? arguments[0] + : this.lastRange; + + if (range == null) return; + var bounds = this.getBounds(range.index, range.length); + if (bounds == null) return; + if (this.root.offsetHeight < bounds.bottom) { + var _scroll$line = this.scroll.line( + Math.min(range.index + range.length, this.scroll.length() - 1) + ); + + var _scroll$line2 = _slicedToArray(_scroll$line, 1); + + var line = _scroll$line2[0]; + + this.root.scrollTop = + line.domNode.offsetTop + line.domNode.offsetHeight - this.root.offsetHeight; + } else if (bounds.top < 0) { + var _scroll$line3 = this.scroll.line( + Math.min(range.index, this.scroll.length() - 1) + ); + + var _scroll$line4 = _slicedToArray(_scroll$line3, 1); + + var _line = _scroll$line4[0]; + + this.root.scrollTop = _line.domNode.offsetTop; + } + } + }, + { + key: "setNativeRange", + value: function setNativeRange(startNode, startOffset) { + var endNode = + arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : startNode; + var endOffset = + arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : startOffset; + var force = + arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : false; + + debug.info("setNativeRange", startNode, startOffset, endNode, endOffset); + if ( + startNode != null && + (this.root.parentNode == null || + startNode.parentNode == null || + endNode.parentNode == null) + ) { + return; + } + var selection = document.getSelection(); + if (selection == null) return; + if (startNode != null) { + if (!this.hasFocus()) this.root.focus(); + var nativeRange = this.getNativeRange(); + if ( + nativeRange == null || + force || + startNode !== nativeRange.start.node || + startOffset !== nativeRange.start.offset || + endNode !== nativeRange.end.node || + endOffset !== nativeRange.end.offset + ) { + var range = document.createRange(); + range.setStart(startNode, startOffset); + range.setEnd(endNode, endOffset); + selection.removeAllRanges(); + selection.addRange(range); + } + } else { + selection.removeAllRanges(); + this.root.blur(); + document.body.focus(); // root.blur() not enough on IE11+Travis+SauceLabs (but not local VMs) + } + } + }, + { + key: "setRange", + value: function setRange(range) { + var _this3 = this; + + var force = + arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false; + var source = + arguments.length > 2 && arguments[2] !== undefined + ? arguments[2] + : _emitter4.default.sources.API; + + if (typeof force === "string") { + source = force; + force = false; + } + debug.info("setRange", range); + if (range != null) { + (function() { + var indexes = range.collapsed + ? [range.index] + : [range.index, range.index + range.length]; + var args = []; + var scrollLength = _this3.scroll.length(); + indexes.forEach(function(index, i) { + index = Math.min(scrollLength - 1, index); + var node = void 0; + var _scroll$leaf5 = _this3.scroll.leaf(index); + + var _scroll$leaf6 = _slicedToArray(_scroll$leaf5, 2); + + var leaf = _scroll$leaf6[0]; + var offset = _scroll$leaf6[1]; + + var _leaf$position5 = leaf.position(offset, i !== 0); + + var _leaf$position6 = _slicedToArray(_leaf$position5, 2); + + node = _leaf$position6[0]; + offset = _leaf$position6[1]; + + args.push(node, offset); + }); + if (args.length < 2) { + args = args.concat(args); + } + _this3.setNativeRange.apply(_this3, _toConsumableArray(args).concat([force])); + })(); + } else { + this.setNativeRange(null); + } + this.update(source); + } + }, + { + key: "update", + value: function update() { + var source = + arguments.length > 0 && arguments[0] !== undefined + ? arguments[0] + : _emitter4.default.sources.USER; + + var nativeRange = void 0, + oldRange = this.lastRange; + + var _getRange = this.getRange(); + + var _getRange2 = _slicedToArray(_getRange, 2); + + this.lastRange = _getRange2[0]; + nativeRange = _getRange2[1]; + + if (this.lastRange != null) { + this.savedRange = this.lastRange; + } + if (!(0, _deepEqual2.default)(oldRange, this.lastRange)) { + var _emitter; + + if ( + !this.composing && + nativeRange != null && + nativeRange.native.collapsed && + nativeRange.start.node !== this.cursor.textNode + ) { + this.cursor.restore(); + } + var args = [ + _emitter4.default.events.SELECTION_CHANGE, + (0, _clone2.default)(this.lastRange), + (0, _clone2.default)(oldRange), + source + ]; + (_emitter = this.emitter).emit.apply( + _emitter, + [_emitter4.default.events.EDITOR_CHANGE].concat(args) + ); + if (source !== _emitter4.default.sources.SILENT) { + var _emitter2; + + (_emitter2 = this.emitter).emit.apply(_emitter2, args); + } + } + } + } + ]); + + return Selection; + })(); + + function contains(parent, descendant) { + try { + // Firefox inserts inaccessible nodes around video elements + descendant.parentNode; + } catch (e) { + return false; + } + // IE11 has bug with Text nodes + // https://connect.microsoft.com/IE/feedback/details/780874/node-contains-is-incorrect + if (descendant instanceof Text) { + descendant = descendant.parentNode; + } + return parent.contains(descendant); + } + + exports.Range = Range; + exports.default = Selection; + + /***/ + }, + /* 41 */ + /***/ function(module, exports, __webpack_require__) { + "use strict"; + + Object.defineProperty(exports, "__esModule", { + value: true + }); + + var _createClass = (function() { + function defineProperties(target, props) { + for (var i = 0; i < props.length; i++) { + var descriptor = props[i]; + descriptor.enumerable = descriptor.enumerable || false; + descriptor.configurable = true; + if ("value" in descriptor) descriptor.writable = true; + Object.defineProperty(target, descriptor.key, descriptor); + } + } + return function(Constructor, protoProps, staticProps) { + if (protoProps) defineProperties(Constructor.prototype, protoProps); + if (staticProps) defineProperties(Constructor, staticProps); + return Constructor; + }; + })(); + + var _extend = __webpack_require__(25); + + var _extend2 = _interopRequireDefault(_extend); + + var _emitter = __webpack_require__(28); + + var _emitter2 = _interopRequireDefault(_emitter); + + function _interopRequireDefault(obj) { + return obj && obj.__esModule ? obj : { default: obj }; + } + + function _classCallCheck(instance, Constructor) { + if (!(instance instanceof Constructor)) { + throw new TypeError("Cannot call a class as a function"); + } + } + + var Theme = (function() { + function Theme(quill, options) { + _classCallCheck(this, Theme); + + this.quill = quill; + this.options = options; + this.modules = {}; + } + + _createClass(Theme, [ + { + key: "init", + value: function init() { + var _this = this; + + Object.keys(this.options.modules).forEach(function(name) { + if (_this.modules[name] == null) { + _this.addModule(name); + } + }); + } + }, + { + key: "addModule", + value: function addModule(name) { + var moduleClass = this.quill.constructor.import("modules/" + name); + this.modules[name] = new moduleClass(this.quill, this.options.modules[name] || {}); + return this.modules[name]; + } + } + ]); + + return Theme; + })(); + + Theme.DEFAULTS = { + modules: {} + }; + Theme.themes = { + default: Theme + }; + + exports.default = Theme; + + /***/ + }, + /* 42 */ + /***/ function(module, exports, __webpack_require__) { + "use strict"; + + Object.defineProperty(exports, "__esModule", { + value: true + }); + + var _parchment = __webpack_require__(2); + + var _parchment2 = _interopRequireDefault(_parchment); + + var _block = __webpack_require__(32); + + var _block2 = _interopRequireDefault(_block); + + function _interopRequireDefault(obj) { + return obj && obj.__esModule ? obj : { default: obj }; + } + + function _classCallCheck(instance, Constructor) { + if (!(instance instanceof Constructor)) { + throw new TypeError("Cannot call a class as a function"); + } + } + + function _possibleConstructorReturn(self, call) { + if (!self) { + throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); + } + return call && (typeof call === "object" || typeof call === "function") ? call : self; + } + + function _inherits(subClass, superClass) { + if (typeof superClass !== "function" && superClass !== null) { + throw new TypeError( + "Super expression must either be null or a function, not " + typeof superClass + ); + } + subClass.prototype = Object.create(superClass && superClass.prototype, { + constructor: { value: subClass, enumerable: false, writable: true, configurable: true } + }); + if (superClass) + Object.setPrototypeOf + ? Object.setPrototypeOf(subClass, superClass) + : (subClass.__proto__ = superClass); + } + + var Container = (function(_Parchment$Container) { + _inherits(Container, _Parchment$Container); + + function Container() { + _classCallCheck(this, Container); + + return _possibleConstructorReturn( + this, + (Container.__proto__ || Object.getPrototypeOf(Container)).apply(this, arguments) + ); + } + + return Container; + })(_parchment2.default.Container); + + Container.allowedChildren = [_block2.default, _block.BlockEmbed, Container]; + + exports.default = Container; + + /***/ + }, + /* 43 */ + /***/ function(module, exports, __webpack_require__) { + "use strict"; + + Object.defineProperty(exports, "__esModule", { + value: true + }); + + var _slicedToArray = (function() { + function sliceIterator(arr, i) { + var _arr = []; + var _n = true; + var _d = false; + var _e = undefined; + try { + for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { + _arr.push(_s.value); + if (i && _arr.length === i) break; + } + } catch (err) { + _d = true; + _e = err; + } finally { + try { + if (!_n && _i["return"]) _i["return"](); + } finally { + if (_d) throw _e; + } + } + return _arr; + } + return function(arr, i) { + if (Array.isArray(arr)) { + return arr; + } else if (Symbol.iterator in Object(arr)) { + return sliceIterator(arr, i); + } else { + throw new TypeError("Invalid attempt to destructure non-iterable instance"); + } + }; + })(); + + var _createClass = (function() { + function defineProperties(target, props) { + for (var i = 0; i < props.length; i++) { + var descriptor = props[i]; + descriptor.enumerable = descriptor.enumerable || false; + descriptor.configurable = true; + if ("value" in descriptor) descriptor.writable = true; + Object.defineProperty(target, descriptor.key, descriptor); + } + } + return function(Constructor, protoProps, staticProps) { + if (protoProps) defineProperties(Constructor.prototype, protoProps); + if (staticProps) defineProperties(Constructor, staticProps); + return Constructor; + }; + })(); + + var _get = function get(object, property, receiver) { + if (object === null) object = Function.prototype; + var desc = Object.getOwnPropertyDescriptor(object, property); + if (desc === undefined) { + var parent = Object.getPrototypeOf(object); + if (parent === null) { + return undefined; + } else { + return get(parent, property, receiver); + } + } else if ("value" in desc) { + return desc.value; + } else { + var getter = desc.get; + if (getter === undefined) { + return undefined; + } + return getter.call(receiver); + } + }; + + var _parchment = __webpack_require__(2); + + var _parchment2 = _interopRequireDefault(_parchment); + + var _emitter = __webpack_require__(28); + + var _emitter2 = _interopRequireDefault(_emitter); + + var _block = __webpack_require__(32); + + var _block2 = _interopRequireDefault(_block); + + var _break = __webpack_require__(33); + + var _break2 = _interopRequireDefault(_break); + + var _container = __webpack_require__(42); + + var _container2 = _interopRequireDefault(_container); + + var _code = __webpack_require__(31); + + var _code2 = _interopRequireDefault(_code); + + function _interopRequireDefault(obj) { + return obj && obj.__esModule ? obj : { default: obj }; + } + + function _classCallCheck(instance, Constructor) { + if (!(instance instanceof Constructor)) { + throw new TypeError("Cannot call a class as a function"); + } + } + + function _possibleConstructorReturn(self, call) { + if (!self) { + throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); + } + return call && (typeof call === "object" || typeof call === "function") ? call : self; + } + + function _inherits(subClass, superClass) { + if (typeof superClass !== "function" && superClass !== null) { + throw new TypeError( + "Super expression must either be null or a function, not " + typeof superClass + ); + } + subClass.prototype = Object.create(superClass && superClass.prototype, { + constructor: { value: subClass, enumerable: false, writable: true, configurable: true } + }); + if (superClass) + Object.setPrototypeOf + ? Object.setPrototypeOf(subClass, superClass) + : (subClass.__proto__ = superClass); + } + + function isLine(blot) { + return blot instanceof _block2.default || blot instanceof _block.BlockEmbed; + } + + var Scroll = (function(_Parchment$Scroll) { + _inherits(Scroll, _Parchment$Scroll); + + function Scroll(domNode, config) { + _classCallCheck(this, Scroll); + + var _this = _possibleConstructorReturn( + this, + (Scroll.__proto__ || Object.getPrototypeOf(Scroll)).call(this, domNode) + ); + + _this.emitter = config.emitter; + if (Array.isArray(config.whitelist)) { + _this.whitelist = config.whitelist.reduce(function(whitelist, format) { + whitelist[format] = true; + return whitelist; + }, {}); + } + _this.optimize(); + return _this; + } + + _createClass(Scroll, [ + { + key: "deleteAt", + value: function deleteAt(index, length) { + var _line = this.line(index); + + var _line2 = _slicedToArray(_line, 2); + + var first = _line2[0]; + var offset = _line2[1]; + + var _line3 = this.line(index + length); + + var _line4 = _slicedToArray(_line3, 1); + + var last = _line4[0]; + + _get( + Scroll.prototype.__proto__ || Object.getPrototypeOf(Scroll.prototype), + "deleteAt", + this + ).call(this, index, length); + if ( + last != null && + first !== last && + offset > 0 && + !(first instanceof _block.BlockEmbed) && + !(last instanceof _block.BlockEmbed) + ) { + if (last instanceof _code2.default) { + last.deleteAt(last.length() - 1, 1); + } + var ref = + last.children.head instanceof _break2.default ? null : last.children.head; + first.moveChildren(last, ref); + first.remove(); + } + this.optimize(); + } + }, + { + key: "formatAt", + value: function formatAt(index, length, format, value) { + if (this.whitelist != null && !this.whitelist[format]) return; + _get( + Scroll.prototype.__proto__ || Object.getPrototypeOf(Scroll.prototype), + "formatAt", + this + ).call(this, index, length, format, value); + this.optimize(); + } + }, + { + key: "insertAt", + value: function insertAt(index, value, def) { + if (def != null && this.whitelist != null && !this.whitelist[value]) return; + if (index >= this.length()) { + if ( + def == null || + _parchment2.default.query(value, _parchment2.default.Scope.BLOCK) == null + ) { + var blot = _parchment2.default.create(this.statics.defaultChild); + this.appendChild(blot); + if (def == null && value.endsWith("\n")) { + value = value.slice(0, -1); + } + blot.insertAt(0, value, def); + } else { + var embed = _parchment2.default.create(value, def); + this.appendChild(embed); + } + } else { + _get( + Scroll.prototype.__proto__ || Object.getPrototypeOf(Scroll.prototype), + "insertAt", + this + ).call(this, index, value, def); + } + this.optimize(); + } + }, + { + key: "insertBefore", + value: function insertBefore(blot, ref) { + if (blot.statics.scope === _parchment2.default.Scope.INLINE_BLOT) { + var wrapper = _parchment2.default.create(this.statics.defaultChild); + wrapper.appendChild(blot); + blot = wrapper; + } + _get( + Scroll.prototype.__proto__ || Object.getPrototypeOf(Scroll.prototype), + "insertBefore", + this + ).call(this, blot, ref); + } + }, + { + key: "leaf", + value: function leaf(index) { + return this.path(index).pop() || [null, -1]; + } + }, + { + key: "line", + value: function line(index) { + return this.descendant(isLine, index); + } + }, + { + key: "lines", + value: function lines() { + var index = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0; + var length = + arguments.length > 1 && arguments[1] !== undefined + ? arguments[1] + : Number.MAX_VALUE; + + var getLines = function getLines(blot, index, length) { + var lines = [], + lengthLeft = length; + blot.children.forEachAt(index, length, function(child, index, length) { + if (isLine(child)) { + lines.push(child); + } else if (child instanceof _parchment2.default.Container) { + lines = lines.concat(getLines(child, index, lengthLeft)); + } + lengthLeft -= length; + }); + return lines; + }; + return getLines(this, index, length); + } + }, + { + key: "optimize", + value: function optimize() { + var mutations = + arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : []; + + if (this.batch === true) return; + _get( + Scroll.prototype.__proto__ || Object.getPrototypeOf(Scroll.prototype), + "optimize", + this + ).call(this, mutations); + if (mutations.length > 0) { + this.emitter.emit(_emitter2.default.events.SCROLL_OPTIMIZE, mutations); + } + } + }, + { + key: "path", + value: function path(index) { + return _get( + Scroll.prototype.__proto__ || Object.getPrototypeOf(Scroll.prototype), + "path", + this + ) + .call(this, index) + .slice(1); // Exclude self + } + }, + { + key: "update", + value: function update(mutations) { + if (this.batch === true) return; + var source = _emitter2.default.sources.USER; + if (typeof mutations === "string") { + source = mutations; + } + if (!Array.isArray(mutations)) { + mutations = this.observer.takeRecords(); + } + if (mutations.length > 0) { + this.emitter.emit( + _emitter2.default.events.SCROLL_BEFORE_UPDATE, + source, + mutations + ); + } + _get( + Scroll.prototype.__proto__ || Object.getPrototypeOf(Scroll.prototype), + "update", + this + ).call(this, mutations.concat([])); // pass copy + if (mutations.length > 0) { + this.emitter.emit(_emitter2.default.events.SCROLL_UPDATE, source, mutations); + } + } + } + ]); + + return Scroll; + })(_parchment2.default.Scroll); + + Scroll.blotName = "scroll"; + Scroll.className = "ql-editor"; + Scroll.tagName = "DIV"; + Scroll.defaultChild = "block"; + Scroll.allowedChildren = [_block2.default, _block.BlockEmbed, _container2.default]; + + exports.default = Scroll; + + /***/ + }, + /* 44 */ + /***/ function(module, exports, __webpack_require__) { + "use strict"; + + Object.defineProperty(exports, "__esModule", { + value: true + }); + exports.matchText = exports.matchSpacing = exports.matchNewline = exports.matchBlot = exports.matchAttributor = exports.default = undefined; + + var _slicedToArray = (function() { + function sliceIterator(arr, i) { + var _arr = []; + var _n = true; + var _d = false; + var _e = undefined; + try { + for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { + _arr.push(_s.value); + if (i && _arr.length === i) break; + } + } catch (err) { + _d = true; + _e = err; + } finally { + try { + if (!_n && _i["return"]) _i["return"](); + } finally { + if (_d) throw _e; + } + } + return _arr; + } + return function(arr, i) { + if (Array.isArray(arr)) { + return arr; + } else if (Symbol.iterator in Object(arr)) { + return sliceIterator(arr, i); + } else { + throw new TypeError("Invalid attempt to destructure non-iterable instance"); + } + }; + })(); + + var _createClass = (function() { + function defineProperties(target, props) { + for (var i = 0; i < props.length; i++) { + var descriptor = props[i]; + descriptor.enumerable = descriptor.enumerable || false; + descriptor.configurable = true; + if ("value" in descriptor) descriptor.writable = true; + Object.defineProperty(target, descriptor.key, descriptor); + } + } + return function(Constructor, protoProps, staticProps) { + if (protoProps) defineProperties(Constructor.prototype, protoProps); + if (staticProps) defineProperties(Constructor, staticProps); + return Constructor; + }; + })(); + + var _delta = __webpack_require__(20); + + var _delta2 = _interopRequireDefault(_delta); + + var _parchment = __webpack_require__(2); + + var _parchment2 = _interopRequireDefault(_parchment); + + var _quill = __webpack_require__(18); + + var _quill2 = _interopRequireDefault(_quill); + + var _logger = __webpack_require__(30); + + var _logger2 = _interopRequireDefault(_logger); + + var _module = __webpack_require__(39); + + var _module2 = _interopRequireDefault(_module); + + var _align = __webpack_require__(45); + + var _background = __webpack_require__(46); + + var _color = __webpack_require__(47); + + var _direction = __webpack_require__(48); + + var _font = __webpack_require__(49); + + var _size = __webpack_require__(50); + + function _interopRequireDefault(obj) { + return obj && obj.__esModule ? obj : { default: obj }; + } + + function _defineProperty(obj, key, value) { + if (key in obj) { + Object.defineProperty(obj, key, { + value: value, + enumerable: true, + configurable: true, + writable: true + }); + } else { + obj[key] = value; + } + return obj; + } + + function _toConsumableArray(arr) { + if (Array.isArray(arr)) { + for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { + arr2[i] = arr[i]; + } + return arr2; + } else { + return Array.from(arr); + } + } + + function _classCallCheck(instance, Constructor) { + if (!(instance instanceof Constructor)) { + throw new TypeError("Cannot call a class as a function"); + } + } + + function _possibleConstructorReturn(self, call) { + if (!self) { + throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); + } + return call && (typeof call === "object" || typeof call === "function") ? call : self; + } + + function _inherits(subClass, superClass) { + if (typeof superClass !== "function" && superClass !== null) { + throw new TypeError( + "Super expression must either be null or a function, not " + typeof superClass + ); + } + subClass.prototype = Object.create(superClass && superClass.prototype, { + constructor: { value: subClass, enumerable: false, writable: true, configurable: true } + }); + if (superClass) + Object.setPrototypeOf + ? Object.setPrototypeOf(subClass, superClass) + : (subClass.__proto__ = superClass); + } + + var debug = (0, _logger2.default)("quill:clipboard"); + + var CLIPBOARD_CONFIG = [ + [Node.TEXT_NODE, matchText], + ["br", matchBreak], + [Node.ELEMENT_NODE, matchNewline], + [Node.ELEMENT_NODE, matchBlot], + [Node.ELEMENT_NODE, matchSpacing], + [Node.ELEMENT_NODE, matchAttributor], + [Node.ELEMENT_NODE, matchStyles], + ["b", matchAlias.bind(matchAlias, "bold")], + ["i", matchAlias.bind(matchAlias, "italic")], + ["style", matchIgnore] + ]; + + var ATTRIBUTE_ATTRIBUTORS = [_align.AlignAttribute, _direction.DirectionAttribute].reduce( + function(memo, attr) { + memo[attr.keyName] = attr; + return memo; + }, + {} + ); + + var STYLE_ATTRIBUTORS = [ + _align.AlignStyle, + _background.BackgroundStyle, + _color.ColorStyle, + _direction.DirectionStyle, + _font.FontStyle, + _size.SizeStyle + ].reduce(function(memo, attr) { + memo[attr.keyName] = attr; + return memo; + }, {}); + + var Clipboard = (function(_Module) { + _inherits(Clipboard, _Module); + + function Clipboard(quill, options) { + _classCallCheck(this, Clipboard); + + var _this = _possibleConstructorReturn( + this, + (Clipboard.__proto__ || Object.getPrototypeOf(Clipboard)).call(this, quill, options) + ); + + _this.quill.root.addEventListener("paste", _this.onPaste.bind(_this)); + _this.container = _this.quill.addContainer("ql-clipboard"); + _this.container.setAttribute("contenteditable", true); + _this.container.setAttribute("tabindex", -1); + _this.matchers = []; + CLIPBOARD_CONFIG.concat(_this.options.matchers).forEach(function(pair) { + _this.addMatcher.apply(_this, _toConsumableArray(pair)); + }); + return _this; + } + + _createClass(Clipboard, [ + { + key: "addMatcher", + value: function addMatcher(selector, matcher) { + this.matchers.push([selector, matcher]); + } + }, + { + key: "convert", + value: function convert(html) { + var _this2 = this; + + var DOM_KEY = "__ql-matcher"; + if (typeof html === "string") { + this.container.innerHTML = html; + } + var textMatchers = [], + elementMatchers = []; + this.matchers.forEach(function(pair) { + var _pair = _slicedToArray(pair, 2); + + var selector = _pair[0]; + var matcher = _pair[1]; + + switch (selector) { + case Node.TEXT_NODE: + textMatchers.push(matcher); + break; + case Node.ELEMENT_NODE: + elementMatchers.push(matcher); + break; + default: + [].forEach.call(_this2.container.querySelectorAll(selector), function(node) { + // TODO use weakmap + node[DOM_KEY] = node[DOM_KEY] || []; + node[DOM_KEY].push(matcher); + }); + break; + } + }); + var traverse = function traverse(node) { + // Post-order + if (node.nodeType === node.TEXT_NODE) { + return textMatchers.reduce(function(delta, matcher) { + return matcher(node, delta); + }, new _delta2.default()); + } else if (node.nodeType === node.ELEMENT_NODE) { + return [].reduce.call( + node.childNodes || [], + function(delta, childNode) { + var childrenDelta = traverse(childNode); + if (childNode.nodeType === node.ELEMENT_NODE) { + childrenDelta = elementMatchers.reduce(function(childrenDelta, matcher) { + return matcher(childNode, childrenDelta); + }, childrenDelta); + childrenDelta = (childNode[DOM_KEY] || []).reduce(function( + childrenDelta, + matcher + ) { + return matcher(childNode, childrenDelta); + }, + childrenDelta); + } + return delta.concat(childrenDelta); + }, + new _delta2.default() + ); + } else { + return new _delta2.default(); + } + }; + var delta = traverse(this.container); + // Remove trailing newline + if ( + deltaEndsWith(delta, "\n") && + delta.ops[delta.ops.length - 1].attributes == null + ) { + delta = delta.compose(new _delta2.default().retain(delta.length() - 1).delete(1)); + } + debug.log("convert", this.container.innerHTML, delta); + this.container.innerHTML = ""; + return delta; + } + }, + { + key: "dangerouslyPasteHTML", + value: function dangerouslyPasteHTML(index, html) { + var source = + arguments.length > 2 && arguments[2] !== undefined + ? arguments[2] + : _quill2.default.sources.API; + + if (typeof index === "string") { + return this.quill.setContents(this.convert(index), html); + } else { + var paste = this.convert(html); + return this.quill.updateContents( + new _delta2.default().retain(index).concat(paste), + source + ); + } + } + }, + { + key: "onPaste", + value: function onPaste(e) { + var _this3 = this; + + if (e.defaultPrevented) return; + var range = this.quill.getSelection(); + var delta = new _delta2.default().retain(range.index).delete(range.length); + var bodyTop = document.body.scrollTop; + this.container.focus(); + setTimeout(function() { + _this3.quill.selection.update(_quill2.default.sources.SILENT); + delta = delta.concat(_this3.convert()); + _this3.quill.updateContents(delta, _quill2.default.sources.USER); + // range.length contributes to delta.length() + _this3.quill.setSelection( + delta.length() - range.length, + _quill2.default.sources.SILENT + ); + document.body.scrollTop = bodyTop; + _this3.quill.selection.scrollIntoView(); + }, 1); + } + } + ]); + + return Clipboard; + })(_module2.default); + + Clipboard.DEFAULTS = { + matchers: [] + }; + + function computeStyle(node) { + if (node.nodeType !== Node.ELEMENT_NODE) return {}; + var DOM_KEY = "__ql-computed-style"; + return node[DOM_KEY] || (node[DOM_KEY] = window.getComputedStyle(node)); + } + + function deltaEndsWith(delta, text) { + var endText = ""; + for (var i = delta.ops.length - 1; i >= 0 && endText.length < text.length; --i) { + var op = delta.ops[i]; + if (typeof op.insert !== "string") break; + endText = op.insert + endText; + } + return endText.slice(-1 * text.length) === text; + } + + function isLine(node) { + if (node.childNodes.length === 0) return false; // Exclude embed blocks + var style = computeStyle(node); + return ["block", "list-item"].indexOf(style.display) > -1; + } + + function matchAlias(format, node, delta) { + return delta.compose( + new _delta2.default().retain(delta.length(), _defineProperty({}, format, true)) + ); + } + + function matchAttributor(node, delta) { + var attributes = _parchment2.default.Attributor.Attribute.keys(node); + var classes = _parchment2.default.Attributor.Class.keys(node); + var styles = _parchment2.default.Attributor.Style.keys(node); + var formats = {}; + attributes + .concat(classes) + .concat(styles) + .forEach(function(name) { + var attr = _parchment2.default.query(name, _parchment2.default.Scope.ATTRIBUTE); + if (attr != null) { + formats[attr.attrName] = attr.value(node); + if (formats[attr.attrName]) return; + } + if (ATTRIBUTE_ATTRIBUTORS[name] != null) { + attr = ATTRIBUTE_ATTRIBUTORS[name]; + formats[attr.attrName] = attr.value(node); + } + if (STYLE_ATTRIBUTORS[name] != null) { + attr = STYLE_ATTRIBUTORS[name]; + formats[attr.attrName] = attr.value(node); + } + }); + if (Object.keys(formats).length > 0) { + delta = delta.compose(new _delta2.default().retain(delta.length(), formats)); + } + return delta; + } + + function matchBlot(node, delta) { + var match = _parchment2.default.query(node); + if (match == null) return delta; + if (match.prototype instanceof _parchment2.default.Embed) { + var embed = {}; + var value = match.value(node); + if (value != null) { + embed[match.blotName] = value; + delta = new _delta2.default().insert(embed, match.formats(node)); + } + } else if (typeof match.formats === "function") { + var formats = _defineProperty({}, match.blotName, match.formats(node)); + delta = delta.compose(new _delta2.default().retain(delta.length(), formats)); + } + return delta; + } + + function matchBreak(node, delta) { + if (!deltaEndsWith(delta, "\n")) { + delta.insert("\n"); + } + return delta; + } + + function matchIgnore(node, delta) { + return new _delta2.default(); + } + + function matchNewline(node, delta) { + if (isLine(node) && !deltaEndsWith(delta, "\n")) { + delta.insert("\n"); + } + return delta; + } + + function matchSpacing(node, delta) { + if (isLine(node) && node.nextElementSibling != null && !deltaEndsWith(delta, "\n\n")) { + var nodeHeight = + node.offsetHeight + + parseFloat(computeStyle(node).marginTop) + + parseFloat(computeStyle(node).marginBottom); + if (node.nextElementSibling.offsetTop > node.offsetTop + nodeHeight * 1.5) { + delta.insert("\n"); + } + } + return delta; + } + + function matchStyles(node, delta) { + var formats = {}; + var style = node.style || {}; + if (style.fontWeight && computeStyle(node).fontWeight === "bold") { + formats.bold = true; + } + if (Object.keys(formats).length > 0) { + delta = delta.compose(new _delta2.default().retain(delta.length(), formats)); + } + if (parseFloat(style.textIndent || 0) > 0) { + // Could be 0.5in + delta = new _delta2.default().insert("\t").concat(delta); + } + return delta; + } + + function matchText(node, delta) { + var text = node.data; + // Word represents empty line with   + if (node.parentNode.tagName === "O:P") { + return delta.insert(text.trim()); + } + if (!computeStyle(node.parentNode).whiteSpace.startsWith("pre")) { + var replacer = function replacer(collapse, match) { + match = match.replace(/[^\u00a0]/g, ""); // \u00a0 is nbsp; + return match.length < 1 && collapse ? " " : match; + }; + + text = text.replace(/\r\n/g, " ").replace(/\n/g, " "); + text = text.replace(/\s\s+/g, replacer.bind(replacer, true)); // collapse whitespace + if ( + (node.previousSibling == null && isLine(node.parentNode)) || + (node.previousSibling != null && isLine(node.previousSibling)) + ) { + text = text.replace(/^\s+/, replacer.bind(replacer, false)); + } + if ( + (node.nextSibling == null && isLine(node.parentNode)) || + (node.nextSibling != null && isLine(node.nextSibling)) + ) { + text = text.replace(/\s+$/, replacer.bind(replacer, false)); + } + } + return delta.insert(text); + } + + exports.default = Clipboard; + exports.matchAttributor = matchAttributor; + exports.matchBlot = matchBlot; + exports.matchNewline = matchNewline; + exports.matchSpacing = matchSpacing; + exports.matchText = matchText; + + /***/ + }, + /* 45 */ + /***/ function(module, exports, __webpack_require__) { + "use strict"; + + Object.defineProperty(exports, "__esModule", { + value: true + }); + exports.AlignStyle = exports.AlignClass = exports.AlignAttribute = undefined; + + var _parchment = __webpack_require__(2); + + var _parchment2 = _interopRequireDefault(_parchment); + + function _interopRequireDefault(obj) { + return obj && obj.__esModule ? obj : { default: obj }; + } + + var config = { + scope: _parchment2.default.Scope.BLOCK, + whitelist: ["right", "center", "justify"] + }; + + var AlignAttribute = new _parchment2.default.Attributor.Attribute("align", "align", config); + var AlignClass = new _parchment2.default.Attributor.Class("align", "ql-align", config); + var AlignStyle = new _parchment2.default.Attributor.Style("align", "text-align", config); + + exports.AlignAttribute = AlignAttribute; + exports.AlignClass = AlignClass; + exports.AlignStyle = AlignStyle; + + /***/ + }, + /* 46 */ + /***/ function(module, exports, __webpack_require__) { + "use strict"; + + Object.defineProperty(exports, "__esModule", { + value: true + }); + exports.BackgroundStyle = exports.BackgroundClass = undefined; + + var _parchment = __webpack_require__(2); + + var _parchment2 = _interopRequireDefault(_parchment); + + var _color = __webpack_require__(47); + + function _interopRequireDefault(obj) { + return obj && obj.__esModule ? obj : { default: obj }; + } + + var BackgroundClass = new _parchment2.default.Attributor.Class("background", "ql-bg", { + scope: _parchment2.default.Scope.INLINE + }); + var BackgroundStyle = new _color.ColorAttributor("background", "background-color", { + scope: _parchment2.default.Scope.INLINE + }); + + exports.BackgroundClass = BackgroundClass; + exports.BackgroundStyle = BackgroundStyle; + + /***/ + }, + /* 47 */ + /***/ function(module, exports, __webpack_require__) { + "use strict"; + + Object.defineProperty(exports, "__esModule", { + value: true + }); + exports.ColorStyle = exports.ColorClass = exports.ColorAttributor = undefined; + + var _createClass = (function() { + function defineProperties(target, props) { + for (var i = 0; i < props.length; i++) { + var descriptor = props[i]; + descriptor.enumerable = descriptor.enumerable || false; + descriptor.configurable = true; + if ("value" in descriptor) descriptor.writable = true; + Object.defineProperty(target, descriptor.key, descriptor); + } + } + return function(Constructor, protoProps, staticProps) { + if (protoProps) defineProperties(Constructor.prototype, protoProps); + if (staticProps) defineProperties(Constructor, staticProps); + return Constructor; + }; + })(); + + var _get = function get(object, property, receiver) { + if (object === null) object = Function.prototype; + var desc = Object.getOwnPropertyDescriptor(object, property); + if (desc === undefined) { + var parent = Object.getPrototypeOf(object); + if (parent === null) { + return undefined; + } else { + return get(parent, property, receiver); + } + } else if ("value" in desc) { + return desc.value; + } else { + var getter = desc.get; + if (getter === undefined) { + return undefined; + } + return getter.call(receiver); + } + }; + + var _parchment = __webpack_require__(2); + + var _parchment2 = _interopRequireDefault(_parchment); + + function _interopRequireDefault(obj) { + return obj && obj.__esModule ? obj : { default: obj }; + } + + function _classCallCheck(instance, Constructor) { + if (!(instance instanceof Constructor)) { + throw new TypeError("Cannot call a class as a function"); + } + } + + function _possibleConstructorReturn(self, call) { + if (!self) { + throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); + } + return call && (typeof call === "object" || typeof call === "function") ? call : self; + } + + function _inherits(subClass, superClass) { + if (typeof superClass !== "function" && superClass !== null) { + throw new TypeError( + "Super expression must either be null or a function, not " + typeof superClass + ); + } + subClass.prototype = Object.create(superClass && superClass.prototype, { + constructor: { value: subClass, enumerable: false, writable: true, configurable: true } + }); + if (superClass) + Object.setPrototypeOf + ? Object.setPrototypeOf(subClass, superClass) + : (subClass.__proto__ = superClass); + } + + var ColorAttributor = (function(_Parchment$Attributor) { + _inherits(ColorAttributor, _Parchment$Attributor); + + function ColorAttributor() { + _classCallCheck(this, ColorAttributor); + + return _possibleConstructorReturn( + this, + (ColorAttributor.__proto__ || Object.getPrototypeOf(ColorAttributor)).apply( + this, + arguments + ) + ); + } + + _createClass(ColorAttributor, [ + { + key: "value", + value: function value(domNode) { + var value = _get( + ColorAttributor.prototype.__proto__ || + Object.getPrototypeOf(ColorAttributor.prototype), + "value", + this + ).call(this, domNode); + if (!value.startsWith("rgb(")) return value; + value = value.replace(/^[^\d]+/, "").replace(/[^\d]+$/, ""); + return ( + "#" + + value + .split(",") + .map(function(component) { + return ("00" + parseInt(component).toString(16)).slice(-2); + }) + .join("") + ); + } + } + ]); + + return ColorAttributor; + })(_parchment2.default.Attributor.Style); + + var ColorClass = new _parchment2.default.Attributor.Class("color", "ql-color", { + scope: _parchment2.default.Scope.INLINE + }); + var ColorStyle = new ColorAttributor("color", "color", { + scope: _parchment2.default.Scope.INLINE + }); + + exports.ColorAttributor = ColorAttributor; + exports.ColorClass = ColorClass; + exports.ColorStyle = ColorStyle; + + /***/ + }, + /* 48 */ + /***/ function(module, exports, __webpack_require__) { + "use strict"; + + Object.defineProperty(exports, "__esModule", { + value: true + }); + exports.DirectionStyle = exports.DirectionClass = exports.DirectionAttribute = undefined; + + var _parchment = __webpack_require__(2); + + var _parchment2 = _interopRequireDefault(_parchment); + + function _interopRequireDefault(obj) { + return obj && obj.__esModule ? obj : { default: obj }; + } + + var config = { + scope: _parchment2.default.Scope.BLOCK, + whitelist: ["rtl"] + }; + + var DirectionAttribute = new _parchment2.default.Attributor.Attribute( + "direction", + "dir", + config + ); + var DirectionClass = new _parchment2.default.Attributor.Class( + "direction", + "ql-direction", + config + ); + var DirectionStyle = new _parchment2.default.Attributor.Style( + "direction", + "direction", + config + ); + + exports.DirectionAttribute = DirectionAttribute; + exports.DirectionClass = DirectionClass; + exports.DirectionStyle = DirectionStyle; + + /***/ + }, + /* 49 */ + /***/ function(module, exports, __webpack_require__) { + "use strict"; + + Object.defineProperty(exports, "__esModule", { + value: true + }); + exports.FontClass = exports.FontStyle = undefined; + + var _createClass = (function() { + function defineProperties(target, props) { + for (var i = 0; i < props.length; i++) { + var descriptor = props[i]; + descriptor.enumerable = descriptor.enumerable || false; + descriptor.configurable = true; + if ("value" in descriptor) descriptor.writable = true; + Object.defineProperty(target, descriptor.key, descriptor); + } + } + return function(Constructor, protoProps, staticProps) { + if (protoProps) defineProperties(Constructor.prototype, protoProps); + if (staticProps) defineProperties(Constructor, staticProps); + return Constructor; + }; + })(); + + var _get = function get(object, property, receiver) { + if (object === null) object = Function.prototype; + var desc = Object.getOwnPropertyDescriptor(object, property); + if (desc === undefined) { + var parent = Object.getPrototypeOf(object); + if (parent === null) { + return undefined; + } else { + return get(parent, property, receiver); + } + } else if ("value" in desc) { + return desc.value; + } else { + var getter = desc.get; + if (getter === undefined) { + return undefined; + } + return getter.call(receiver); + } + }; + + var _parchment = __webpack_require__(2); + + var _parchment2 = _interopRequireDefault(_parchment); + + function _interopRequireDefault(obj) { + return obj && obj.__esModule ? obj : { default: obj }; + } + + function _classCallCheck(instance, Constructor) { + if (!(instance instanceof Constructor)) { + throw new TypeError("Cannot call a class as a function"); + } + } + + function _possibleConstructorReturn(self, call) { + if (!self) { + throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); + } + return call && (typeof call === "object" || typeof call === "function") ? call : self; + } + + function _inherits(subClass, superClass) { + if (typeof superClass !== "function" && superClass !== null) { + throw new TypeError( + "Super expression must either be null or a function, not " + typeof superClass + ); + } + subClass.prototype = Object.create(superClass && superClass.prototype, { + constructor: { value: subClass, enumerable: false, writable: true, configurable: true } + }); + if (superClass) + Object.setPrototypeOf + ? Object.setPrototypeOf(subClass, superClass) + : (subClass.__proto__ = superClass); + } + + var config = { + scope: _parchment2.default.Scope.INLINE, + whitelist: ["serif", "monospace"] + }; + + var FontClass = new _parchment2.default.Attributor.Class("font", "ql-font", config); + + var FontStyleAttributor = (function(_Parchment$Attributor) { + _inherits(FontStyleAttributor, _Parchment$Attributor); + + function FontStyleAttributor() { + _classCallCheck(this, FontStyleAttributor); + + return _possibleConstructorReturn( + this, + (FontStyleAttributor.__proto__ || Object.getPrototypeOf(FontStyleAttributor)).apply( + this, + arguments + ) + ); + } + + _createClass(FontStyleAttributor, [ + { + key: "value", + value: function value(node) { + return _get( + FontStyleAttributor.prototype.__proto__ || + Object.getPrototypeOf(FontStyleAttributor.prototype), + "value", + this + ) + .call(this, node) + .replace(/["']/g, ""); + } + } + ]); + + return FontStyleAttributor; + })(_parchment2.default.Attributor.Style); + + var FontStyle = new FontStyleAttributor("font", "font-family", config); + + exports.FontStyle = FontStyle; + exports.FontClass = FontClass; + + /***/ + }, + /* 50 */ + /***/ function(module, exports, __webpack_require__) { + "use strict"; + + Object.defineProperty(exports, "__esModule", { + value: true + }); + exports.SizeStyle = exports.SizeClass = undefined; + + var _parchment = __webpack_require__(2); + + var _parchment2 = _interopRequireDefault(_parchment); + + function _interopRequireDefault(obj) { + return obj && obj.__esModule ? obj : { default: obj }; + } + + var SizeClass = new _parchment2.default.Attributor.Class("size", "ql-size", { + scope: _parchment2.default.Scope.INLINE, + whitelist: ["small", "large", "huge"] + }); + var SizeStyle = new _parchment2.default.Attributor.Style("size", "font-size", { + scope: _parchment2.default.Scope.INLINE, + whitelist: ["10px", "18px", "32px"] + }); + + exports.SizeClass = SizeClass; + exports.SizeStyle = SizeStyle; + + /***/ + }, + /* 51 */ + /***/ function(module, exports, __webpack_require__) { + "use strict"; + + Object.defineProperty(exports, "__esModule", { + value: true + }); + exports.getLastChangeIndex = exports.default = undefined; + + var _createClass = (function() { + function defineProperties(target, props) { + for (var i = 0; i < props.length; i++) { + var descriptor = props[i]; + descriptor.enumerable = descriptor.enumerable || false; + descriptor.configurable = true; + if ("value" in descriptor) descriptor.writable = true; + Object.defineProperty(target, descriptor.key, descriptor); + } + } + return function(Constructor, protoProps, staticProps) { + if (protoProps) defineProperties(Constructor.prototype, protoProps); + if (staticProps) defineProperties(Constructor, staticProps); + return Constructor; + }; + })(); + + var _parchment = __webpack_require__(2); + + var _parchment2 = _interopRequireDefault(_parchment); + + var _quill = __webpack_require__(18); + + var _quill2 = _interopRequireDefault(_quill); + + var _module = __webpack_require__(39); + + var _module2 = _interopRequireDefault(_module); + + function _interopRequireDefault(obj) { + return obj && obj.__esModule ? obj : { default: obj }; + } + + function _classCallCheck(instance, Constructor) { + if (!(instance instanceof Constructor)) { + throw new TypeError("Cannot call a class as a function"); + } + } + + function _possibleConstructorReturn(self, call) { + if (!self) { + throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); + } + return call && (typeof call === "object" || typeof call === "function") ? call : self; + } + + function _inherits(subClass, superClass) { + if (typeof superClass !== "function" && superClass !== null) { + throw new TypeError( + "Super expression must either be null or a function, not " + typeof superClass + ); + } + subClass.prototype = Object.create(superClass && superClass.prototype, { + constructor: { value: subClass, enumerable: false, writable: true, configurable: true } + }); + if (superClass) + Object.setPrototypeOf + ? Object.setPrototypeOf(subClass, superClass) + : (subClass.__proto__ = superClass); + } + + var History = (function(_Module) { + _inherits(History, _Module); + + function History(quill, options) { + _classCallCheck(this, History); + + var _this = _possibleConstructorReturn( + this, + (History.__proto__ || Object.getPrototypeOf(History)).call(this, quill, options) + ); + + _this.lastRecorded = 0; + _this.ignoreChange = false; + _this.clear(); + _this.quill.on(_quill2.default.events.EDITOR_CHANGE, function( + eventName, + delta, + oldDelta, + source + ) { + if (eventName !== _quill2.default.events.TEXT_CHANGE || _this.ignoreChange) return; + if (!_this.options.userOnly || source === _quill2.default.sources.USER) { + _this.record(delta, oldDelta); + } else { + _this.transform(delta); + } + }); + _this.quill.keyboard.addBinding({ key: "Z", shortKey: true }, _this.undo.bind(_this)); + _this.quill.keyboard.addBinding( + { key: "Z", shortKey: true, shiftKey: true }, + _this.redo.bind(_this) + ); + if (/Win/i.test(navigator.platform)) { + _this.quill.keyboard.addBinding({ key: "Y", shortKey: true }, _this.redo.bind(_this)); + } + return _this; + } + + _createClass(History, [ + { + key: "change", + value: function change(source, dest) { + if (this.stack[source].length === 0) return; + var delta = this.stack[source].pop(); + this.lastRecorded = 0; + this.ignoreChange = true; + this.quill.updateContents(delta[source], _quill2.default.sources.USER); + this.ignoreChange = false; + var index = getLastChangeIndex(delta[source]); + this.quill.setSelection(index); + this.quill.selection.scrollIntoView(); + this.stack[dest].push(delta); + } + }, + { + key: "clear", + value: function clear() { + this.stack = { undo: [], redo: [] }; + } + }, + { + key: "record", + value: function record(changeDelta, oldDelta) { + if (changeDelta.ops.length === 0) return; + this.stack.redo = []; + var undoDelta = this.quill.getContents().diff(oldDelta); + var timestamp = Date.now(); + if ( + this.lastRecorded + this.options.delay > timestamp && + this.stack.undo.length > 0 + ) { + var delta = this.stack.undo.pop(); + undoDelta = undoDelta.compose(delta.undo); + changeDelta = delta.redo.compose(changeDelta); + } else { + this.lastRecorded = timestamp; + } + this.stack.undo.push({ + redo: changeDelta, + undo: undoDelta + }); + if (this.stack.undo.length > this.options.maxStack) { + this.stack.undo.shift(); + } + } + }, + { + key: "redo", + value: function redo() { + this.change("redo", "undo"); + } + }, + { + key: "transform", + value: function transform(delta) { + this.stack.undo.forEach(function(change) { + change.undo = delta.transform(change.undo, true); + change.redo = delta.transform(change.redo, true); + }); + this.stack.redo.forEach(function(change) { + change.undo = delta.transform(change.undo, true); + change.redo = delta.transform(change.redo, true); + }); + } + }, + { + key: "undo", + value: function undo() { + this.change("undo", "redo"); + } + } + ]); + + return History; + })(_module2.default); + + History.DEFAULTS = { + delay: 1000, + maxStack: 100, + userOnly: false + }; + + function endsWithNewlineChange(delta) { + var lastOp = delta.ops[delta.ops.length - 1]; + if (lastOp == null) return false; + if (lastOp.insert != null) { + return typeof lastOp.insert === "string" && lastOp.insert.endsWith("\n"); + } + if (lastOp.attributes != null) { + return Object.keys(lastOp.attributes).some(function(attr) { + return _parchment2.default.query(attr, _parchment2.default.Scope.BLOCK) != null; + }); + } + return false; + } + + function getLastChangeIndex(delta) { + var deleteLength = delta.ops.reduce(function(length, op) { + length += op.delete || 0; + return length; + }, 0); + var changeIndex = delta.length() - deleteLength; + if (endsWithNewlineChange(delta)) { + changeIndex -= 1; + } + return changeIndex; + } + + exports.default = History; + exports.getLastChangeIndex = getLastChangeIndex; + + /***/ + }, + /* 52 */ + /***/ function(module, exports, __webpack_require__) { + "use strict"; + + Object.defineProperty(exports, "__esModule", { + value: true + }); + + var _typeof = + typeof Symbol === "function" && typeof Symbol.iterator === "symbol" + ? function(obj) { + return typeof obj; + } + : function(obj) { + return obj && + typeof Symbol === "function" && + obj.constructor === Symbol && + obj !== Symbol.prototype + ? "symbol" + : typeof obj; + }; + + var _slicedToArray = (function() { + function sliceIterator(arr, i) { + var _arr = []; + var _n = true; + var _d = false; + var _e = undefined; + try { + for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { + _arr.push(_s.value); + if (i && _arr.length === i) break; + } + } catch (err) { + _d = true; + _e = err; + } finally { + try { + if (!_n && _i["return"]) _i["return"](); + } finally { + if (_d) throw _e; + } + } + return _arr; + } + return function(arr, i) { + if (Array.isArray(arr)) { + return arr; + } else if (Symbol.iterator in Object(arr)) { + return sliceIterator(arr, i); + } else { + throw new TypeError("Invalid attempt to destructure non-iterable instance"); + } + }; + })(); + + var _createClass = (function() { + function defineProperties(target, props) { + for (var i = 0; i < props.length; i++) { + var descriptor = props[i]; + descriptor.enumerable = descriptor.enumerable || false; + descriptor.configurable = true; + if ("value" in descriptor) descriptor.writable = true; + Object.defineProperty(target, descriptor.key, descriptor); + } + } + return function(Constructor, protoProps, staticProps) { + if (protoProps) defineProperties(Constructor.prototype, protoProps); + if (staticProps) defineProperties(Constructor, staticProps); + return Constructor; + }; + })(); + + var _clone = __webpack_require__(38); + + var _clone2 = _interopRequireDefault(_clone); + + var _deepEqual = __webpack_require__(22); + + var _deepEqual2 = _interopRequireDefault(_deepEqual); + + var _extend = __webpack_require__(25); + + var _extend2 = _interopRequireDefault(_extend); + + var _delta = __webpack_require__(20); + + var _delta2 = _interopRequireDefault(_delta); + + var _op = __webpack_require__(26); + + var _op2 = _interopRequireDefault(_op); + + var _parchment = __webpack_require__(2); + + var _parchment2 = _interopRequireDefault(_parchment); + + var _quill = __webpack_require__(18); + + var _quill2 = _interopRequireDefault(_quill); + + var _logger = __webpack_require__(30); + + var _logger2 = _interopRequireDefault(_logger); + + var _module = __webpack_require__(39); + + var _module2 = _interopRequireDefault(_module); + + var _block = __webpack_require__(32); + + var _block2 = _interopRequireDefault(_block); + + function _interopRequireDefault(obj) { + return obj && obj.__esModule ? obj : { default: obj }; + } + + function _classCallCheck(instance, Constructor) { + if (!(instance instanceof Constructor)) { + throw new TypeError("Cannot call a class as a function"); + } + } + + function _possibleConstructorReturn(self, call) { + if (!self) { + throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); + } + return call && (typeof call === "object" || typeof call === "function") ? call : self; + } + + function _inherits(subClass, superClass) { + if (typeof superClass !== "function" && superClass !== null) { + throw new TypeError( + "Super expression must either be null or a function, not " + typeof superClass + ); + } + subClass.prototype = Object.create(superClass && superClass.prototype, { + constructor: { value: subClass, enumerable: false, writable: true, configurable: true } + }); + if (superClass) + Object.setPrototypeOf + ? Object.setPrototypeOf(subClass, superClass) + : (subClass.__proto__ = superClass); + } + + var debug = (0, _logger2.default)("quill:keyboard"); + + var SHORTKEY = /Mac/i.test(navigator.platform) ? "metaKey" : "ctrlKey"; + + var Keyboard = (function(_Module) { + _inherits(Keyboard, _Module); + + _createClass(Keyboard, null, [ + { + key: "match", + value: function match(evt, binding) { + binding = normalize(binding); + if (!!binding.shortKey !== evt[SHORTKEY] && binding.shortKey !== null) return false; + if ( + ["altKey", "ctrlKey", "metaKey", "shiftKey"].some(function(key) { + return key != SHORTKEY && !!binding[key] !== evt[key] && binding[key] !== null; + }) + ) { + return false; + } + return binding.key === (evt.which || evt.keyCode); + } + } + ]); + + function Keyboard(quill, options) { + _classCallCheck(this, Keyboard); + + var _this = _possibleConstructorReturn( + this, + (Keyboard.__proto__ || Object.getPrototypeOf(Keyboard)).call(this, quill, options) + ); + + _this.bindings = {}; + Object.keys(_this.options.bindings).forEach(function(name) { + if (_this.options.bindings[name]) { + _this.addBinding(_this.options.bindings[name]); + } + }); + _this.addBinding({ key: Keyboard.keys.ENTER, shiftKey: null }, handleEnter); + _this.addBinding( + { key: Keyboard.keys.ENTER, metaKey: null, ctrlKey: null, altKey: null }, + function() {} + ); + _this.addBinding( + { key: Keyboard.keys.BACKSPACE }, + { collapsed: true, prefix: /^.?$/ }, + function(range, context) { + if (range.index === 0) return; + + var _quill$scroll$line = this.quill.scroll.line(range.index); + + var _quill$scroll$line2 = _slicedToArray(_quill$scroll$line, 1); + + var line = _quill$scroll$line2[0]; + + var formats = {}; + if (context.offset === 0) { + var curFormats = line.formats(); + var prevFormats = this.quill.getFormat(range.index - 1, 1); + formats = _op2.default.attributes.diff(curFormats, prevFormats) || {}; + } + this.quill.deleteText(range.index - 1, 1, _quill2.default.sources.USER); + if (Object.keys(formats).length > 0) { + this.quill.formatLine(range.index - 1, 1, formats, _quill2.default.sources.USER); + } + this.quill.selection.scrollIntoView(); + } + ); + _this.addBinding( + { key: Keyboard.keys.DELETE }, + { collapsed: true, suffix: /^$/ }, + function(range) { + if (range.index >= this.quill.getLength() - 1) return; + this.quill.deleteText(range.index, 1, _quill2.default.sources.USER); + } + ); + _this.addBinding({ key: Keyboard.keys.BACKSPACE }, { collapsed: false }, handleDelete); + _this.addBinding({ key: Keyboard.keys.DELETE }, { collapsed: false }, handleDelete); + _this.listen(); + return _this; + } + + _createClass(Keyboard, [ + { + key: "addBinding", + value: function addBinding(key) { + var context = + arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; + var handler = + arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {}; + + var binding = normalize(key); + if (binding == null || binding.key == null) { + return debug.warn("Attempted to add invalid keyboard binding", binding); + } + if (typeof context === "function") { + context = { handler: context }; + } + if (typeof handler === "function") { + handler = { handler: handler }; + } + binding = (0, _extend2.default)(binding, context, handler); + this.bindings[binding.key] = this.bindings[binding.key] || []; + this.bindings[binding.key].push(binding); + } + }, + { + key: "listen", + value: function listen() { + var _this2 = this; + + this.quill.root.addEventListener("keydown", function(evt) { + if (evt.defaultPrevented) return; + var which = evt.which || evt.keyCode; + var bindings = (_this2.bindings[which] || []).filter(function(binding) { + return Keyboard.match(evt, binding); + }); + if (bindings.length === 0) return; + var range = _this2.quill.getSelection(); + if (range == null) return; // implies we do not have focus + + var _quill$scroll$line3 = _this2.quill.scroll.line(range.index); + + var _quill$scroll$line4 = _slicedToArray(_quill$scroll$line3, 2); + + var line = _quill$scroll$line4[0]; + var offset = _quill$scroll$line4[1]; + + var _quill$scroll$leaf = _this2.quill.scroll.leaf(range.index); + + var _quill$scroll$leaf2 = _slicedToArray(_quill$scroll$leaf, 2); + + var leafStart = _quill$scroll$leaf2[0]; + var offsetStart = _quill$scroll$leaf2[1]; + + var _ref = + range.length === 0 + ? [leafStart, offsetStart] + : _this2.quill.scroll.leaf(range.index + range.length); + + var _ref2 = _slicedToArray(_ref, 2); + + var leafEnd = _ref2[0]; + var offsetEnd = _ref2[1]; + + var prefixText = + leafStart instanceof _parchment2.default.Text + ? leafStart.value().slice(0, offsetStart) + : ""; + var suffixText = + leafEnd instanceof _parchment2.default.Text + ? leafEnd.value().slice(offsetEnd) + : ""; + var curContext = { + collapsed: range.length === 0, + empty: range.length === 0 && line.length() <= 1, + format: _this2.quill.getFormat(range), + offset: offset, + prefix: prefixText, + suffix: suffixText + }; + var prevented = bindings.some(function(binding) { + if (binding.collapsed != null && binding.collapsed !== curContext.collapsed) + return false; + if (binding.empty != null && binding.empty !== curContext.empty) return false; + if (binding.offset != null && binding.offset !== curContext.offset) + return false; + if (Array.isArray(binding.format)) { + // any format is present + if ( + binding.format.every(function(name) { + return curContext.format[name] == null; + }) + ) { + return false; + } + } else if (_typeof(binding.format) === "object") { + // all formats must match + if ( + !Object.keys(binding.format).every(function(name) { + if (binding.format[name] === true) return curContext.format[name] != null; + if (binding.format[name] === false) + return curContext.format[name] == null; + return (0, + _deepEqual2.default)(binding.format[name], curContext.format[name]); + }) + ) { + return false; + } + } + if (binding.prefix != null && !binding.prefix.test(curContext.prefix)) + return false; + if (binding.suffix != null && !binding.suffix.test(curContext.suffix)) + return false; + return binding.handler.call(_this2, range, curContext) !== true; + }); + if (prevented) { + evt.preventDefault(); + } + }); + } + } + ]); + + return Keyboard; + })(_module2.default); + + Keyboard.keys = { + BACKSPACE: 8, + TAB: 9, + ENTER: 13, + ESCAPE: 27, + LEFT: 37, + UP: 38, + RIGHT: 39, + DOWN: 40, + DELETE: 46 + }; + + Keyboard.DEFAULTS = { + bindings: { + bold: makeFormatHandler("bold"), + italic: makeFormatHandler("italic"), + underline: makeFormatHandler("underline"), + indent: { + // highlight tab or tab at beginning of list, indent or blockquote + key: Keyboard.keys.TAB, + format: ["blockquote", "indent", "list"], + handler: function handler(range, context) { + if (context.collapsed && context.offset !== 0) return true; + this.quill.format("indent", "+1", _quill2.default.sources.USER); + } + }, + outdent: { + key: Keyboard.keys.TAB, + shiftKey: true, + format: ["blockquote", "indent", "list"], + // highlight tab or tab at beginning of list, indent or blockquote + handler: function handler(range, context) { + if (context.collapsed && context.offset !== 0) return true; + this.quill.format("indent", "-1", _quill2.default.sources.USER); + } + }, + "outdent backspace": { + key: Keyboard.keys.BACKSPACE, + collapsed: true, + format: ["blockquote", "indent", "list"], + offset: 0, + handler: function handler(range, context) { + if (context.format.indent != null) { + this.quill.format("indent", "-1", _quill2.default.sources.USER); + } else if (context.format.blockquote != null) { + this.quill.format("blockquote", false, _quill2.default.sources.USER); + } else if (context.format.list != null) { + this.quill.format("list", false, _quill2.default.sources.USER); + } + } + }, + "indent code-block": makeCodeBlockHandler(true), + "outdent code-block": makeCodeBlockHandler(false), + "remove tab": { + key: Keyboard.keys.TAB, + shiftKey: true, + collapsed: true, + prefix: /\t$/, + handler: function handler(range, context) { + this.quill.deleteText(range.index - 1, 1, _quill2.default.sources.USER); + } + }, + tab: { + key: Keyboard.keys.TAB, + handler: function handler(range, context) { + if (!context.collapsed) { + this.quill.scroll.deleteAt(range.index, range.length); + } + this.quill.insertText(range.index, "\t", _quill2.default.sources.USER); + this.quill.setSelection(range.index + 1, _quill2.default.sources.SILENT); + } + }, + "list empty enter": { + key: Keyboard.keys.ENTER, + collapsed: true, + format: ["list"], + empty: true, + handler: function handler(range, context) { + this.quill.format("list", false, _quill2.default.sources.USER); + if (context.format.indent) { + this.quill.format("indent", false, _quill2.default.sources.USER); + } + } + }, + "header enter": { + key: Keyboard.keys.ENTER, + collapsed: true, + format: ["header"], + suffix: /^$/, + handler: function handler(range) { + this.quill.scroll.insertAt(range.index, "\n"); + this.quill.formatText( + range.index + 1, + 1, + "header", + false, + _quill2.default.sources.USER + ); + this.quill.setSelection(range.index + 1, _quill2.default.sources.SILENT); + this.quill.selection.scrollIntoView(); + } + }, + "list autofill": { + key: " ", + collapsed: true, + format: { list: false }, + prefix: /^(1\.|-)$/, + handler: function handler(range, context) { + var length = context.prefix.length; + this.quill.scroll.deleteAt(range.index - length, length); + this.quill.formatLine( + range.index - length, + 1, + "list", + length === 1 ? "bullet" : "ordered", + _quill2.default.sources.USER + ); + this.quill.setSelection(range.index - length, _quill2.default.sources.SILENT); + } + } + } + }; + + function handleDelete(range) { + this.quill.deleteText(range, _quill2.default.sources.USER); + this.quill.setSelection(range.index, _quill2.default.sources.SILENT); + this.quill.selection.scrollIntoView(); + } + + function handleEnter(range, context) { + var _this3 = this; + + if (range.length > 0) { + this.quill.scroll.deleteAt(range.index, range.length); // So we do not trigger text-change + } + var lineFormats = Object.keys(context.format).reduce(function(lineFormats, format) { + if ( + _parchment2.default.query(format, _parchment2.default.Scope.BLOCK) && + !Array.isArray(context.format[format]) + ) { + lineFormats[format] = context.format[format]; + } + return lineFormats; + }, {}); + this.quill.insertText(range.index, "\n", lineFormats, _quill2.default.sources.USER); + this.quill.selection.scrollIntoView(); + Object.keys(context.format).forEach(function(name) { + if (lineFormats[name] != null) return; + if (Array.isArray(context.format[name])) return; + if (name === "link") return; + _this3.quill.format(name, context.format[name], _quill2.default.sources.USER); + }); + } + + function makeCodeBlockHandler(indent) { + return { + key: Keyboard.keys.TAB, + shiftKey: !indent, + format: { "code-block": true }, + handler: function handler(range) { + var CodeBlock = _parchment2.default.query("code-block"); + var index = range.index, + length = range.length; + + var _quill$scroll$descend = this.quill.scroll.descendant(CodeBlock, index); + + var _quill$scroll$descend2 = _slicedToArray(_quill$scroll$descend, 2); + + var block = _quill$scroll$descend2[0]; + var offset = _quill$scroll$descend2[1]; + + if (block == null) return; + var scrollOffset = this.quill.scroll.offset(block); + var start = block.newlineIndex(offset, true) + 1; + var end = block.newlineIndex(scrollOffset + offset + length); + var lines = block.domNode.textContent.slice(start, end).split("\n"); + offset = 0; + lines.forEach(function(line, i) { + if (indent) { + block.insertAt(start + offset, CodeBlock.TAB); + offset += CodeBlock.TAB.length; + if (i === 0) { + index += CodeBlock.TAB.length; + } else { + length += CodeBlock.TAB.length; + } + } else if (line.startsWith(CodeBlock.TAB)) { + block.deleteAt(start + offset, CodeBlock.TAB.length); + offset -= CodeBlock.TAB.length; + if (i === 0) { + index -= CodeBlock.TAB.length; + } else { + length -= CodeBlock.TAB.length; + } + } + offset += line.length + 1; + }); + this.quill.update(_quill2.default.sources.USER); + this.quill.setSelection(index, length, _quill2.default.sources.SILENT); + } + }; + } + + function makeFormatHandler(format) { + return { + key: format[0].toUpperCase(), + shortKey: true, + handler: function handler(range, context) { + this.quill.format(format, !context.format[format], _quill2.default.sources.USER); + } + }; + } + + function normalize(binding) { + if (typeof binding === "string" || typeof binding === "number") { + return normalize({ key: binding }); + } + if ((typeof binding === "undefined" ? "undefined" : _typeof(binding)) === "object") { + binding = (0, _clone2.default)(binding, false); + } + if (typeof binding.key === "string") { + if (Keyboard.keys[binding.key.toUpperCase()] != null) { + binding.key = Keyboard.keys[binding.key.toUpperCase()]; + } else if (binding.key.length === 1) { + binding.key = binding.key.toUpperCase().charCodeAt(0); + } else { + return null; + } + } + return binding; + } + + exports.default = Keyboard; + + /***/ + }, + /* 53 */ + /***/ function(module, exports, __webpack_require__) { + "use strict"; + + var _core = __webpack_require__(1); + + var _core2 = _interopRequireDefault(_core); + + var _align = __webpack_require__(45); + + var _direction = __webpack_require__(48); + + var _indent = __webpack_require__(54); + + var _blockquote = __webpack_require__(55); + + var _blockquote2 = _interopRequireDefault(_blockquote); + + var _header = __webpack_require__(56); + + var _header2 = _interopRequireDefault(_header); + + var _list = __webpack_require__(57); + + var _list2 = _interopRequireDefault(_list); + + var _background = __webpack_require__(46); + + var _color = __webpack_require__(47); + + var _font = __webpack_require__(49); + + var _size = __webpack_require__(50); + + var _bold = __webpack_require__(58); + + var _bold2 = _interopRequireDefault(_bold); + + var _italic = __webpack_require__(59); + + var _italic2 = _interopRequireDefault(_italic); + + var _link = __webpack_require__(60); + + var _link2 = _interopRequireDefault(_link); + + var _script = __webpack_require__(61); + + var _script2 = _interopRequireDefault(_script); + + var _strike = __webpack_require__(62); + + var _strike2 = _interopRequireDefault(_strike); + + var _underline = __webpack_require__(63); + + var _underline2 = _interopRequireDefault(_underline); + + var _image = __webpack_require__(64); + + var _image2 = _interopRequireDefault(_image); + + var _video = __webpack_require__(65); + + var _video2 = _interopRequireDefault(_video); + + var _code = __webpack_require__(31); + + var _code2 = _interopRequireDefault(_code); + + var _formula = __webpack_require__(66); + + var _formula2 = _interopRequireDefault(_formula); + + var _syntax = __webpack_require__(67); + + var _syntax2 = _interopRequireDefault(_syntax); + + var _toolbar = __webpack_require__(68); + + var _toolbar2 = _interopRequireDefault(_toolbar); + + var _icons = __webpack_require__(69); + + var _icons2 = _interopRequireDefault(_icons); + + var _picker = __webpack_require__(101); + + var _picker2 = _interopRequireDefault(_picker); + + var _colorPicker = __webpack_require__(103); + + var _colorPicker2 = _interopRequireDefault(_colorPicker); + + var _iconPicker = __webpack_require__(104); + + var _iconPicker2 = _interopRequireDefault(_iconPicker); + + var _tooltip = __webpack_require__(105); + + var _tooltip2 = _interopRequireDefault(_tooltip); + + var _bubble = __webpack_require__(106); + + var _bubble2 = _interopRequireDefault(_bubble); + + var _snow = __webpack_require__(108); + + var _snow2 = _interopRequireDefault(_snow); + + function _interopRequireDefault(obj) { + return obj && obj.__esModule ? obj : { default: obj }; + } + + _core2.default.register( + { + "attributors/attribute/direction": _direction.DirectionAttribute, + + "attributors/class/align": _align.AlignClass, + "attributors/class/background": _background.BackgroundClass, + "attributors/class/color": _color.ColorClass, + "attributors/class/direction": _direction.DirectionClass, + "attributors/class/font": _font.FontClass, + "attributors/class/size": _size.SizeClass, + + "attributors/style/align": _align.AlignStyle, + "attributors/style/background": _background.BackgroundStyle, + "attributors/style/color": _color.ColorStyle, + "attributors/style/direction": _direction.DirectionStyle, + "attributors/style/font": _font.FontStyle, + "attributors/style/size": _size.SizeStyle + }, + true + ); + + _core2.default.register( + { + "formats/align": _align.AlignClass, + "formats/direction": _direction.DirectionClass, + "formats/indent": _indent.IndentClass, + + "formats/background": _background.BackgroundStyle, + "formats/color": _color.ColorStyle, + "formats/font": _font.FontClass, + "formats/size": _size.SizeClass, + + "formats/blockquote": _blockquote2.default, + "formats/code-block": _code2.default, + "formats/header": _header2.default, + "formats/list": _list2.default, + + "formats/bold": _bold2.default, + "formats/code": _code.Code, + "formats/italic": _italic2.default, + "formats/link": _link2.default, + "formats/script": _script2.default, + "formats/strike": _strike2.default, + "formats/underline": _underline2.default, + + "formats/image": _image2.default, + "formats/video": _video2.default, + + "formats/list/item": _list.ListItem, + + "modules/formula": _formula2.default, + "modules/syntax": _syntax2.default, + "modules/toolbar": _toolbar2.default, + + "themes/bubble": _bubble2.default, + "themes/snow": _snow2.default, + + "ui/icons": _icons2.default, + "ui/picker": _picker2.default, + "ui/icon-picker": _iconPicker2.default, + "ui/color-picker": _colorPicker2.default, + "ui/tooltip": _tooltip2.default + }, + true + ); + + module.exports = _core2.default; + + /***/ + }, + /* 54 */ + /***/ function(module, exports, __webpack_require__) { + "use strict"; + + Object.defineProperty(exports, "__esModule", { + value: true + }); + exports.IndentClass = undefined; + + var _createClass = (function() { + function defineProperties(target, props) { + for (var i = 0; i < props.length; i++) { + var descriptor = props[i]; + descriptor.enumerable = descriptor.enumerable || false; + descriptor.configurable = true; + if ("value" in descriptor) descriptor.writable = true; + Object.defineProperty(target, descriptor.key, descriptor); + } + } + return function(Constructor, protoProps, staticProps) { + if (protoProps) defineProperties(Constructor.prototype, protoProps); + if (staticProps) defineProperties(Constructor, staticProps); + return Constructor; + }; + })(); + + var _get = function get(object, property, receiver) { + if (object === null) object = Function.prototype; + var desc = Object.getOwnPropertyDescriptor(object, property); + if (desc === undefined) { + var parent = Object.getPrototypeOf(object); + if (parent === null) { + return undefined; + } else { + return get(parent, property, receiver); + } + } else if ("value" in desc) { + return desc.value; + } else { + var getter = desc.get; + if (getter === undefined) { + return undefined; + } + return getter.call(receiver); + } + }; + + var _parchment = __webpack_require__(2); + + var _parchment2 = _interopRequireDefault(_parchment); + + function _interopRequireDefault(obj) { + return obj && obj.__esModule ? obj : { default: obj }; + } + + function _classCallCheck(instance, Constructor) { + if (!(instance instanceof Constructor)) { + throw new TypeError("Cannot call a class as a function"); + } + } + + function _possibleConstructorReturn(self, call) { + if (!self) { + throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); + } + return call && (typeof call === "object" || typeof call === "function") ? call : self; + } + + function _inherits(subClass, superClass) { + if (typeof superClass !== "function" && superClass !== null) { + throw new TypeError( + "Super expression must either be null or a function, not " + typeof superClass + ); + } + subClass.prototype = Object.create(superClass && superClass.prototype, { + constructor: { value: subClass, enumerable: false, writable: true, configurable: true } + }); + if (superClass) + Object.setPrototypeOf + ? Object.setPrototypeOf(subClass, superClass) + : (subClass.__proto__ = superClass); + } + + var IdentAttributor = (function(_Parchment$Attributor) { + _inherits(IdentAttributor, _Parchment$Attributor); + + function IdentAttributor() { + _classCallCheck(this, IdentAttributor); + + return _possibleConstructorReturn( + this, + (IdentAttributor.__proto__ || Object.getPrototypeOf(IdentAttributor)).apply( + this, + arguments + ) + ); + } + + _createClass(IdentAttributor, [ + { + key: "add", + value: function add(node, value) { + if (value === "+1" || value === "-1") { + var indent = this.value(node) || 0; + value = value === "+1" ? indent + 1 : indent - 1; + } + if (value === 0) { + this.remove(node); + return true; + } else { + return _get( + IdentAttributor.prototype.__proto__ || + Object.getPrototypeOf(IdentAttributor.prototype), + "add", + this + ).call(this, node, value); + } + } + }, + { + key: "value", + value: function value(node) { + return ( + parseInt( + _get( + IdentAttributor.prototype.__proto__ || + Object.getPrototypeOf(IdentAttributor.prototype), + "value", + this + ).call(this, node) + ) || undefined + ); // Don't return NaN + } + } + ]); + + return IdentAttributor; + })(_parchment2.default.Attributor.Class); + + var IndentClass = new IdentAttributor("indent", "ql-indent", { + scope: _parchment2.default.Scope.BLOCK, + whitelist: [1, 2, 3, 4, 5, 6, 7, 8] + }); + + exports.IndentClass = IndentClass; + + /***/ + }, + /* 55 */ + /***/ function(module, exports, __webpack_require__) { + "use strict"; + + Object.defineProperty(exports, "__esModule", { + value: true + }); + + var _block = __webpack_require__(32); + + var _block2 = _interopRequireDefault(_block); + + function _interopRequireDefault(obj) { + return obj && obj.__esModule ? obj : { default: obj }; + } + + function _classCallCheck(instance, Constructor) { + if (!(instance instanceof Constructor)) { + throw new TypeError("Cannot call a class as a function"); + } + } + + function _possibleConstructorReturn(self, call) { + if (!self) { + throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); + } + return call && (typeof call === "object" || typeof call === "function") ? call : self; + } + + function _inherits(subClass, superClass) { + if (typeof superClass !== "function" && superClass !== null) { + throw new TypeError( + "Super expression must either be null or a function, not " + typeof superClass + ); + } + subClass.prototype = Object.create(superClass && superClass.prototype, { + constructor: { value: subClass, enumerable: false, writable: true, configurable: true } + }); + if (superClass) + Object.setPrototypeOf + ? Object.setPrototypeOf(subClass, superClass) + : (subClass.__proto__ = superClass); + } + + var Blockquote = (function(_Block) { + _inherits(Blockquote, _Block); + + function Blockquote() { + _classCallCheck(this, Blockquote); + + return _possibleConstructorReturn( + this, + (Blockquote.__proto__ || Object.getPrototypeOf(Blockquote)).apply(this, arguments) + ); + } + + return Blockquote; + })(_block2.default); + + Blockquote.blotName = "blockquote"; + Blockquote.tagName = "blockquote"; + + exports.default = Blockquote; + + /***/ + }, + /* 56 */ + /***/ function(module, exports, __webpack_require__) { + "use strict"; + + Object.defineProperty(exports, "__esModule", { + value: true + }); + + var _createClass = (function() { + function defineProperties(target, props) { + for (var i = 0; i < props.length; i++) { + var descriptor = props[i]; + descriptor.enumerable = descriptor.enumerable || false; + descriptor.configurable = true; + if ("value" in descriptor) descriptor.writable = true; + Object.defineProperty(target, descriptor.key, descriptor); + } + } + return function(Constructor, protoProps, staticProps) { + if (protoProps) defineProperties(Constructor.prototype, protoProps); + if (staticProps) defineProperties(Constructor, staticProps); + return Constructor; + }; + })(); + + var _block = __webpack_require__(32); + + var _block2 = _interopRequireDefault(_block); + + function _interopRequireDefault(obj) { + return obj && obj.__esModule ? obj : { default: obj }; + } + + function _classCallCheck(instance, Constructor) { + if (!(instance instanceof Constructor)) { + throw new TypeError("Cannot call a class as a function"); + } + } + + function _possibleConstructorReturn(self, call) { + if (!self) { + throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); + } + return call && (typeof call === "object" || typeof call === "function") ? call : self; + } + + function _inherits(subClass, superClass) { + if (typeof superClass !== "function" && superClass !== null) { + throw new TypeError( + "Super expression must either be null or a function, not " + typeof superClass + ); + } + subClass.prototype = Object.create(superClass && superClass.prototype, { + constructor: { value: subClass, enumerable: false, writable: true, configurable: true } + }); + if (superClass) + Object.setPrototypeOf + ? Object.setPrototypeOf(subClass, superClass) + : (subClass.__proto__ = superClass); + } + + var Header = (function(_Block) { + _inherits(Header, _Block); + + function Header() { + _classCallCheck(this, Header); + + return _possibleConstructorReturn( + this, + (Header.__proto__ || Object.getPrototypeOf(Header)).apply(this, arguments) + ); + } + + _createClass(Header, null, [ + { + key: "formats", + value: function formats(domNode) { + return this.tagName.indexOf(domNode.tagName) + 1; + } + } + ]); + + return Header; + })(_block2.default); + + Header.blotName = "header"; + Header.tagName = ["H1", "H2", "H3", "H4", "H5", "H6"]; + + exports.default = Header; + + /***/ + }, + /* 57 */ + /***/ function(module, exports, __webpack_require__) { + "use strict"; + + Object.defineProperty(exports, "__esModule", { + value: true + }); + exports.default = exports.ListItem = undefined; + + var _createClass = (function() { + function defineProperties(target, props) { + for (var i = 0; i < props.length; i++) { + var descriptor = props[i]; + descriptor.enumerable = descriptor.enumerable || false; + descriptor.configurable = true; + if ("value" in descriptor) descriptor.writable = true; + Object.defineProperty(target, descriptor.key, descriptor); + } + } + return function(Constructor, protoProps, staticProps) { + if (protoProps) defineProperties(Constructor.prototype, protoProps); + if (staticProps) defineProperties(Constructor, staticProps); + return Constructor; + }; + })(); + + var _get = function get(object, property, receiver) { + if (object === null) object = Function.prototype; + var desc = Object.getOwnPropertyDescriptor(object, property); + if (desc === undefined) { + var parent = Object.getPrototypeOf(object); + if (parent === null) { + return undefined; + } else { + return get(parent, property, receiver); + } + } else if ("value" in desc) { + return desc.value; + } else { + var getter = desc.get; + if (getter === undefined) { + return undefined; + } + return getter.call(receiver); + } + }; + + var _extend = __webpack_require__(25); + + var _extend2 = _interopRequireDefault(_extend); + + var _delta = __webpack_require__(20); + + var _delta2 = _interopRequireDefault(_delta); + + var _parchment = __webpack_require__(2); + + var _parchment2 = _interopRequireDefault(_parchment); + + var _block = __webpack_require__(32); + + var _block2 = _interopRequireDefault(_block); + + var _container = __webpack_require__(42); + + var _container2 = _interopRequireDefault(_container); + + function _interopRequireDefault(obj) { + return obj && obj.__esModule ? obj : { default: obj }; + } + + function _defineProperty(obj, key, value) { + if (key in obj) { + Object.defineProperty(obj, key, { + value: value, + enumerable: true, + configurable: true, + writable: true + }); + } else { + obj[key] = value; + } + return obj; + } + + function _classCallCheck(instance, Constructor) { + if (!(instance instanceof Constructor)) { + throw new TypeError("Cannot call a class as a function"); + } + } + + function _possibleConstructorReturn(self, call) { + if (!self) { + throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); + } + return call && (typeof call === "object" || typeof call === "function") ? call : self; + } + + function _inherits(subClass, superClass) { + if (typeof superClass !== "function" && superClass !== null) { + throw new TypeError( + "Super expression must either be null or a function, not " + typeof superClass + ); + } + subClass.prototype = Object.create(superClass && superClass.prototype, { + constructor: { value: subClass, enumerable: false, writable: true, configurable: true } + }); + if (superClass) + Object.setPrototypeOf + ? Object.setPrototypeOf(subClass, superClass) + : (subClass.__proto__ = superClass); + } + + var ListItem = (function(_Block) { + _inherits(ListItem, _Block); + + function ListItem() { + _classCallCheck(this, ListItem); + + return _possibleConstructorReturn( + this, + (ListItem.__proto__ || Object.getPrototypeOf(ListItem)).apply(this, arguments) + ); + } + + _createClass( + ListItem, + [ + { + key: "format", + value: function format(name, value) { + if (name === List.blotName && !value) { + this.replaceWith(_parchment2.default.create(this.statics.scope)); + } else { + _get( + ListItem.prototype.__proto__ || Object.getPrototypeOf(ListItem.prototype), + "format", + this + ).call(this, name, value); + } + } + }, + { + key: "remove", + value: function remove() { + if (this.prev == null && this.next == null) { + this.parent.remove(); + } else { + _get( + ListItem.prototype.__proto__ || Object.getPrototypeOf(ListItem.prototype), + "remove", + this + ).call(this); + } + } + }, + { + key: "replaceWith", + value: function replaceWith(name, value) { + this.parent.isolate(this.offset(this.parent), this.length()); + if (name === this.parent.statics.blotName) { + this.parent.replaceWith(name, value); + return this; + } else { + this.parent.unwrap(); + return _get( + ListItem.prototype.__proto__ || Object.getPrototypeOf(ListItem.prototype), + "replaceWith", + this + ).call(this, name, value); + } + } + } + ], + [ + { + key: "formats", + value: function formats(domNode) { + return domNode.tagName === this.tagName + ? undefined + : _get( + ListItem.__proto__ || Object.getPrototypeOf(ListItem), + "formats", + this + ).call(this, domNode); + } + } + ] + ); + + return ListItem; + })(_block2.default); + + ListItem.blotName = "list-item"; + ListItem.tagName = "LI"; + + var List = (function(_Container) { + _inherits(List, _Container); + + function List() { + _classCallCheck(this, List); + + return _possibleConstructorReturn( + this, + (List.__proto__ || Object.getPrototypeOf(List)).apply(this, arguments) + ); + } + + _createClass( + List, + [ + { + key: "format", + value: function format(name, value) { + if (this.children.length > 0) { + this.children.tail.format(name, value); + } + } + }, + { + key: "formats", + value: function formats() { + // We don't inherit from FormatBlot + return _defineProperty( + {}, + this.statics.blotName, + this.statics.formats(this.domNode) + ); + } + }, + { + key: "insertBefore", + value: function insertBefore(blot, ref) { + if (blot instanceof ListItem) { + _get( + List.prototype.__proto__ || Object.getPrototypeOf(List.prototype), + "insertBefore", + this + ).call(this, blot, ref); + } else { + var index = ref == null ? this.length() : ref.offset(this); + var after = this.split(index); + after.parent.insertBefore(blot, after); + } + } + }, + { + key: "optimize", + value: function optimize() { + _get( + List.prototype.__proto__ || Object.getPrototypeOf(List.prototype), + "optimize", + this + ).call(this); + var next = this.next; + if ( + next != null && + next.prev === this && + next.statics.blotName === this.statics.blotName && + next.domNode.tagName === this.domNode.tagName + ) { + next.moveChildren(this); + next.remove(); + } + } + }, + { + key: "replace", + value: function replace(target) { + if (target.statics.blotName !== this.statics.blotName) { + var item = _parchment2.default.create(this.statics.defaultChild); + target.moveChildren(item); + this.appendChild(item); + } + _get( + List.prototype.__proto__ || Object.getPrototypeOf(List.prototype), + "replace", + this + ).call(this, target); + } + } + ], + [ + { + key: "create", + value: function create(value) { + if (value === "ordered") { + value = "OL"; + } else if (value === "bullet") { + value = "UL"; + } + return _get(List.__proto__ || Object.getPrototypeOf(List), "create", this).call( + this, + value + ); + } + }, + { + key: "formats", + value: function formats(domNode) { + if (domNode.tagName === "OL") return "ordered"; + if (domNode.tagName === "UL") return "bullet"; + return undefined; + } + } + ] + ); + + return List; + })(_container2.default); + + List.blotName = "list"; + List.scope = _parchment2.default.Scope.BLOCK_BLOT; + List.tagName = ["OL", "UL"]; + List.defaultChild = "list-item"; + List.allowedChildren = [ListItem]; + + exports.ListItem = ListItem; + exports.default = List; + + /***/ + }, + /* 58 */ + /***/ function(module, exports, __webpack_require__) { + "use strict"; + + Object.defineProperty(exports, "__esModule", { + value: true + }); + + var _createClass = (function() { + function defineProperties(target, props) { + for (var i = 0; i < props.length; i++) { + var descriptor = props[i]; + descriptor.enumerable = descriptor.enumerable || false; + descriptor.configurable = true; + if ("value" in descriptor) descriptor.writable = true; + Object.defineProperty(target, descriptor.key, descriptor); + } + } + return function(Constructor, protoProps, staticProps) { + if (protoProps) defineProperties(Constructor.prototype, protoProps); + if (staticProps) defineProperties(Constructor, staticProps); + return Constructor; + }; + })(); + + var _get = function get(object, property, receiver) { + if (object === null) object = Function.prototype; + var desc = Object.getOwnPropertyDescriptor(object, property); + if (desc === undefined) { + var parent = Object.getPrototypeOf(object); + if (parent === null) { + return undefined; + } else { + return get(parent, property, receiver); + } + } else if ("value" in desc) { + return desc.value; + } else { + var getter = desc.get; + if (getter === undefined) { + return undefined; + } + return getter.call(receiver); + } + }; + + var _inline = __webpack_require__(35); + + var _inline2 = _interopRequireDefault(_inline); + + function _interopRequireDefault(obj) { + return obj && obj.__esModule ? obj : { default: obj }; + } + + function _classCallCheck(instance, Constructor) { + if (!(instance instanceof Constructor)) { + throw new TypeError("Cannot call a class as a function"); + } + } + + function _possibleConstructorReturn(self, call) { + if (!self) { + throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); + } + return call && (typeof call === "object" || typeof call === "function") ? call : self; + } + + function _inherits(subClass, superClass) { + if (typeof superClass !== "function" && superClass !== null) { + throw new TypeError( + "Super expression must either be null or a function, not " + typeof superClass + ); + } + subClass.prototype = Object.create(superClass && superClass.prototype, { + constructor: { value: subClass, enumerable: false, writable: true, configurable: true } + }); + if (superClass) + Object.setPrototypeOf + ? Object.setPrototypeOf(subClass, superClass) + : (subClass.__proto__ = superClass); + } + + var Bold = (function(_Inline) { + _inherits(Bold, _Inline); + + function Bold() { + _classCallCheck(this, Bold); + + return _possibleConstructorReturn( + this, + (Bold.__proto__ || Object.getPrototypeOf(Bold)).apply(this, arguments) + ); + } + + _createClass( + Bold, + [ + { + key: "optimize", + value: function optimize() { + _get( + Bold.prototype.__proto__ || Object.getPrototypeOf(Bold.prototype), + "optimize", + this + ).call(this); + if (this.domNode.tagName !== this.statics.tagName[0]) { + this.replaceWith(this.statics.blotName); + } + } + } + ], + [ + { + key: "create", + value: function create(value) { + return _get(Bold.__proto__ || Object.getPrototypeOf(Bold), "create", this).call( + this + ); + } + }, + { + key: "formats", + value: function formats(domNode) { + return true; + } + } + ] + ); + + return Bold; + })(_inline2.default); + + Bold.blotName = "bold"; + Bold.tagName = ["STRONG", "B"]; + + exports.default = Bold; + + /***/ + }, + /* 59 */ + /***/ function(module, exports, __webpack_require__) { + "use strict"; + + Object.defineProperty(exports, "__esModule", { + value: true + }); + + var _bold = __webpack_require__(58); + + var _bold2 = _interopRequireDefault(_bold); + + function _interopRequireDefault(obj) { + return obj && obj.__esModule ? obj : { default: obj }; + } + + function _classCallCheck(instance, Constructor) { + if (!(instance instanceof Constructor)) { + throw new TypeError("Cannot call a class as a function"); + } + } + + function _possibleConstructorReturn(self, call) { + if (!self) { + throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); + } + return call && (typeof call === "object" || typeof call === "function") ? call : self; + } + + function _inherits(subClass, superClass) { + if (typeof superClass !== "function" && superClass !== null) { + throw new TypeError( + "Super expression must either be null or a function, not " + typeof superClass + ); + } + subClass.prototype = Object.create(superClass && superClass.prototype, { + constructor: { value: subClass, enumerable: false, writable: true, configurable: true } + }); + if (superClass) + Object.setPrototypeOf + ? Object.setPrototypeOf(subClass, superClass) + : (subClass.__proto__ = superClass); + } + + var Italic = (function(_Bold) { + _inherits(Italic, _Bold); + + function Italic() { + _classCallCheck(this, Italic); + + return _possibleConstructorReturn( + this, + (Italic.__proto__ || Object.getPrototypeOf(Italic)).apply(this, arguments) + ); + } + + return Italic; + })(_bold2.default); + + Italic.blotName = "italic"; + Italic.tagName = ["EM", "I"]; + + exports.default = Italic; + + /***/ + }, + /* 60 */ + /***/ function(module, exports, __webpack_require__) { + "use strict"; + + Object.defineProperty(exports, "__esModule", { + value: true + }); + exports.sanitize = exports.default = undefined; + + var _createClass = (function() { + function defineProperties(target, props) { + for (var i = 0; i < props.length; i++) { + var descriptor = props[i]; + descriptor.enumerable = descriptor.enumerable || false; + descriptor.configurable = true; + if ("value" in descriptor) descriptor.writable = true; + Object.defineProperty(target, descriptor.key, descriptor); + } + } + return function(Constructor, protoProps, staticProps) { + if (protoProps) defineProperties(Constructor.prototype, protoProps); + if (staticProps) defineProperties(Constructor, staticProps); + return Constructor; + }; + })(); + + var _get = function get(object, property, receiver) { + if (object === null) object = Function.prototype; + var desc = Object.getOwnPropertyDescriptor(object, property); + if (desc === undefined) { + var parent = Object.getPrototypeOf(object); + if (parent === null) { + return undefined; + } else { + return get(parent, property, receiver); + } + } else if ("value" in desc) { + return desc.value; + } else { + var getter = desc.get; + if (getter === undefined) { + return undefined; + } + return getter.call(receiver); + } + }; + + var _inline = __webpack_require__(35); + + var _inline2 = _interopRequireDefault(_inline); + + function _interopRequireDefault(obj) { + return obj && obj.__esModule ? obj : { default: obj }; + } + + function _classCallCheck(instance, Constructor) { + if (!(instance instanceof Constructor)) { + throw new TypeError("Cannot call a class as a function"); + } + } + + function _possibleConstructorReturn(self, call) { + if (!self) { + throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); + } + return call && (typeof call === "object" || typeof call === "function") ? call : self; + } + + function _inherits(subClass, superClass) { + if (typeof superClass !== "function" && superClass !== null) { + throw new TypeError( + "Super expression must either be null or a function, not " + typeof superClass + ); + } + subClass.prototype = Object.create(superClass && superClass.prototype, { + constructor: { value: subClass, enumerable: false, writable: true, configurable: true } + }); + if (superClass) + Object.setPrototypeOf + ? Object.setPrototypeOf(subClass, superClass) + : (subClass.__proto__ = superClass); + } + + var Link = (function(_Inline) { + _inherits(Link, _Inline); + + function Link() { + _classCallCheck(this, Link); + + return _possibleConstructorReturn( + this, + (Link.__proto__ || Object.getPrototypeOf(Link)).apply(this, arguments) + ); + } + + _createClass( + Link, + [ + { + key: "format", + value: function format(name, value) { + if (name !== this.statics.blotName || !value) + return _get( + Link.prototype.__proto__ || Object.getPrototypeOf(Link.prototype), + "format", + this + ).call(this, name, value); + value = this.constructor.sanitize(value); + this.domNode.setAttribute("href", value); + } + } + ], + [ + { + key: "create", + value: function create(value) { + var node = _get( + Link.__proto__ || Object.getPrototypeOf(Link), + "create", + this + ).call(this, value); + value = this.sanitize(value); + node.setAttribute("href", value); + node.setAttribute("target", "_blank"); + return node; + } + }, + { + key: "formats", + value: function formats(domNode) { + return domNode.getAttribute("href"); + } + }, + { + key: "sanitize", + value: function sanitize(url) { + return _sanitize(url, ["http", "https", "mailto"]) ? url : this.SANITIZED_URL; + } + } + ] + ); + + return Link; + })(_inline2.default); + + Link.blotName = "link"; + Link.tagName = "A"; + Link.SANITIZED_URL = "about:blank"; + + function _sanitize(url, protocols) { + var anchor = document.createElement("a"); + anchor.href = url; + var protocol = anchor.href.slice(0, anchor.href.indexOf(":")); + return protocols.indexOf(protocol) > -1; + } + + exports.default = Link; + exports.sanitize = _sanitize; + + /***/ + }, + /* 61 */ + /***/ function(module, exports, __webpack_require__) { + "use strict"; + + Object.defineProperty(exports, "__esModule", { + value: true + }); + + var _createClass = (function() { + function defineProperties(target, props) { + for (var i = 0; i < props.length; i++) { + var descriptor = props[i]; + descriptor.enumerable = descriptor.enumerable || false; + descriptor.configurable = true; + if ("value" in descriptor) descriptor.writable = true; + Object.defineProperty(target, descriptor.key, descriptor); + } + } + return function(Constructor, protoProps, staticProps) { + if (protoProps) defineProperties(Constructor.prototype, protoProps); + if (staticProps) defineProperties(Constructor, staticProps); + return Constructor; + }; + })(); + + var _get = function get(object, property, receiver) { + if (object === null) object = Function.prototype; + var desc = Object.getOwnPropertyDescriptor(object, property); + if (desc === undefined) { + var parent = Object.getPrototypeOf(object); + if (parent === null) { + return undefined; + } else { + return get(parent, property, receiver); + } + } else if ("value" in desc) { + return desc.value; + } else { + var getter = desc.get; + if (getter === undefined) { + return undefined; + } + return getter.call(receiver); + } + }; + + var _inline = __webpack_require__(35); + + var _inline2 = _interopRequireDefault(_inline); + + function _interopRequireDefault(obj) { + return obj && obj.__esModule ? obj : { default: obj }; + } + + function _classCallCheck(instance, Constructor) { + if (!(instance instanceof Constructor)) { + throw new TypeError("Cannot call a class as a function"); + } + } + + function _possibleConstructorReturn(self, call) { + if (!self) { + throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); + } + return call && (typeof call === "object" || typeof call === "function") ? call : self; + } + + function _inherits(subClass, superClass) { + if (typeof superClass !== "function" && superClass !== null) { + throw new TypeError( + "Super expression must either be null or a function, not " + typeof superClass + ); + } + subClass.prototype = Object.create(superClass && superClass.prototype, { + constructor: { value: subClass, enumerable: false, writable: true, configurable: true } + }); + if (superClass) + Object.setPrototypeOf + ? Object.setPrototypeOf(subClass, superClass) + : (subClass.__proto__ = superClass); + } + + var Script = (function(_Inline) { + _inherits(Script, _Inline); + + function Script() { + _classCallCheck(this, Script); + + return _possibleConstructorReturn( + this, + (Script.__proto__ || Object.getPrototypeOf(Script)).apply(this, arguments) + ); + } + + _createClass(Script, null, [ + { + key: "create", + value: function create(value) { + if (value === "super") { + return document.createElement("sup"); + } else if (value === "sub") { + return document.createElement("sub"); + } else { + return _get( + Script.__proto__ || Object.getPrototypeOf(Script), + "create", + this + ).call(this, value); + } + } + }, + { + key: "formats", + value: function formats(domNode) { + if (domNode.tagName === "SUB") return "sub"; + if (domNode.tagName === "SUP") return "super"; + return undefined; + } + } + ]); + + return Script; + })(_inline2.default); + + Script.blotName = "script"; + Script.tagName = ["SUB", "SUP"]; + + exports.default = Script; + + /***/ + }, + /* 62 */ + /***/ function(module, exports, __webpack_require__) { + "use strict"; + + Object.defineProperty(exports, "__esModule", { + value: true + }); + + var _inline = __webpack_require__(35); + + var _inline2 = _interopRequireDefault(_inline); + + function _interopRequireDefault(obj) { + return obj && obj.__esModule ? obj : { default: obj }; + } + + function _classCallCheck(instance, Constructor) { + if (!(instance instanceof Constructor)) { + throw new TypeError("Cannot call a class as a function"); + } + } + + function _possibleConstructorReturn(self, call) { + if (!self) { + throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); + } + return call && (typeof call === "object" || typeof call === "function") ? call : self; + } + + function _inherits(subClass, superClass) { + if (typeof superClass !== "function" && superClass !== null) { + throw new TypeError( + "Super expression must either be null or a function, not " + typeof superClass + ); + } + subClass.prototype = Object.create(superClass && superClass.prototype, { + constructor: { value: subClass, enumerable: false, writable: true, configurable: true } + }); + if (superClass) + Object.setPrototypeOf + ? Object.setPrototypeOf(subClass, superClass) + : (subClass.__proto__ = superClass); + } + + var Strike = (function(_Inline) { + _inherits(Strike, _Inline); + + function Strike() { + _classCallCheck(this, Strike); + + return _possibleConstructorReturn( + this, + (Strike.__proto__ || Object.getPrototypeOf(Strike)).apply(this, arguments) + ); + } + + return Strike; + })(_inline2.default); + + Strike.blotName = "strike"; + Strike.tagName = "S"; + + exports.default = Strike; + + /***/ + }, + /* 63 */ + /***/ function(module, exports, __webpack_require__) { + "use strict"; + + Object.defineProperty(exports, "__esModule", { + value: true + }); + + var _inline = __webpack_require__(35); + + var _inline2 = _interopRequireDefault(_inline); + + function _interopRequireDefault(obj) { + return obj && obj.__esModule ? obj : { default: obj }; + } + + function _classCallCheck(instance, Constructor) { + if (!(instance instanceof Constructor)) { + throw new TypeError("Cannot call a class as a function"); + } + } + + function _possibleConstructorReturn(self, call) { + if (!self) { + throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); + } + return call && (typeof call === "object" || typeof call === "function") ? call : self; + } + + function _inherits(subClass, superClass) { + if (typeof superClass !== "function" && superClass !== null) { + throw new TypeError( + "Super expression must either be null or a function, not " + typeof superClass + ); + } + subClass.prototype = Object.create(superClass && superClass.prototype, { + constructor: { value: subClass, enumerable: false, writable: true, configurable: true } + }); + if (superClass) + Object.setPrototypeOf + ? Object.setPrototypeOf(subClass, superClass) + : (subClass.__proto__ = superClass); + } + + var Underline = (function(_Inline) { + _inherits(Underline, _Inline); + + function Underline() { + _classCallCheck(this, Underline); + + return _possibleConstructorReturn( + this, + (Underline.__proto__ || Object.getPrototypeOf(Underline)).apply(this, arguments) + ); + } + + return Underline; + })(_inline2.default); + + Underline.blotName = "underline"; + Underline.tagName = "U"; + + exports.default = Underline; + + /***/ + }, + /* 64 */ + /***/ function(module, exports, __webpack_require__) { + "use strict"; + + Object.defineProperty(exports, "__esModule", { + value: true + }); + + var _createClass = (function() { + function defineProperties(target, props) { + for (var i = 0; i < props.length; i++) { + var descriptor = props[i]; + descriptor.enumerable = descriptor.enumerable || false; + descriptor.configurable = true; + if ("value" in descriptor) descriptor.writable = true; + Object.defineProperty(target, descriptor.key, descriptor); + } + } + return function(Constructor, protoProps, staticProps) { + if (protoProps) defineProperties(Constructor.prototype, protoProps); + if (staticProps) defineProperties(Constructor, staticProps); + return Constructor; + }; + })(); + + var _get = function get(object, property, receiver) { + if (object === null) object = Function.prototype; + var desc = Object.getOwnPropertyDescriptor(object, property); + if (desc === undefined) { + var parent = Object.getPrototypeOf(object); + if (parent === null) { + return undefined; + } else { + return get(parent, property, receiver); + } + } else if ("value" in desc) { + return desc.value; + } else { + var getter = desc.get; + if (getter === undefined) { + return undefined; + } + return getter.call(receiver); + } + }; + + var _embed = __webpack_require__(34); + + var _embed2 = _interopRequireDefault(_embed); + + var _link = __webpack_require__(60); + + var _link2 = _interopRequireDefault(_link); + + function _interopRequireDefault(obj) { + return obj && obj.__esModule ? obj : { default: obj }; + } + + function _classCallCheck(instance, Constructor) { + if (!(instance instanceof Constructor)) { + throw new TypeError("Cannot call a class as a function"); + } + } + + function _possibleConstructorReturn(self, call) { + if (!self) { + throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); + } + return call && (typeof call === "object" || typeof call === "function") ? call : self; + } + + function _inherits(subClass, superClass) { + if (typeof superClass !== "function" && superClass !== null) { + throw new TypeError( + "Super expression must either be null or a function, not " + typeof superClass + ); + } + subClass.prototype = Object.create(superClass && superClass.prototype, { + constructor: { value: subClass, enumerable: false, writable: true, configurable: true } + }); + if (superClass) + Object.setPrototypeOf + ? Object.setPrototypeOf(subClass, superClass) + : (subClass.__proto__ = superClass); + } + + var ATTRIBUTES = ["alt", "height", "width"]; + + var Image = (function(_Embed) { + _inherits(Image, _Embed); + + function Image() { + _classCallCheck(this, Image); + + return _possibleConstructorReturn( + this, + (Image.__proto__ || Object.getPrototypeOf(Image)).apply(this, arguments) + ); + } + + _createClass( + Image, + [ + { + key: "format", + value: function format(name, value) { + if (ATTRIBUTES.indexOf(name) > -1) { + if (value) { + this.domNode.setAttribute(name, value); + } else { + this.domNode.removeAttribute(name); + } + } else { + _get( + Image.prototype.__proto__ || Object.getPrototypeOf(Image.prototype), + "format", + this + ).call(this, name, value); + } + } + } + ], + [ + { + key: "create", + value: function create(value) { + var node = _get( + Image.__proto__ || Object.getPrototypeOf(Image), + "create", + this + ).call(this, value); + if (typeof value === "string") { + node.setAttribute("src", this.sanitize(value)); + } + return node; + } + }, + { + key: "formats", + value: function formats(domNode) { + return ATTRIBUTES.reduce(function(formats, attribute) { + if (domNode.hasAttribute(attribute)) { + formats[attribute] = domNode.getAttribute(attribute); + } + return formats; + }, {}); + } + }, + { + key: "match", + value: function match(url) { + return /\.(jpe?g|gif|png)$/.test(url) || /^data:image\/.+;base64/.test(url); + } + }, + { + key: "sanitize", + value: function sanitize(url) { + return (0, _link.sanitize)(url, ["http", "https", "data"]) ? url : "//:0"; + } + }, + { + key: "value", + value: function value(domNode) { + return domNode.getAttribute("src"); + } + } + ] + ); + + return Image; + })(_embed2.default); + + Image.blotName = "image"; + Image.tagName = "IMG"; + + exports.default = Image; + + /***/ + }, + /* 65 */ + /***/ function(module, exports, __webpack_require__) { + "use strict"; + + Object.defineProperty(exports, "__esModule", { + value: true + }); + + var _createClass = (function() { + function defineProperties(target, props) { + for (var i = 0; i < props.length; i++) { + var descriptor = props[i]; + descriptor.enumerable = descriptor.enumerable || false; + descriptor.configurable = true; + if ("value" in descriptor) descriptor.writable = true; + Object.defineProperty(target, descriptor.key, descriptor); + } + } + return function(Constructor, protoProps, staticProps) { + if (protoProps) defineProperties(Constructor.prototype, protoProps); + if (staticProps) defineProperties(Constructor, staticProps); + return Constructor; + }; + })(); + + var _get = function get(object, property, receiver) { + if (object === null) object = Function.prototype; + var desc = Object.getOwnPropertyDescriptor(object, property); + if (desc === undefined) { + var parent = Object.getPrototypeOf(object); + if (parent === null) { + return undefined; + } else { + return get(parent, property, receiver); + } + } else if ("value" in desc) { + return desc.value; + } else { + var getter = desc.get; + if (getter === undefined) { + return undefined; + } + return getter.call(receiver); + } + }; + + var _block = __webpack_require__(32); + + var _link = __webpack_require__(60); + + var _link2 = _interopRequireDefault(_link); + + function _interopRequireDefault(obj) { + return obj && obj.__esModule ? obj : { default: obj }; + } + + function _classCallCheck(instance, Constructor) { + if (!(instance instanceof Constructor)) { + throw new TypeError("Cannot call a class as a function"); + } + } + + function _possibleConstructorReturn(self, call) { + if (!self) { + throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); + } + return call && (typeof call === "object" || typeof call === "function") ? call : self; + } + + function _inherits(subClass, superClass) { + if (typeof superClass !== "function" && superClass !== null) { + throw new TypeError( + "Super expression must either be null or a function, not " + typeof superClass + ); + } + subClass.prototype = Object.create(superClass && superClass.prototype, { + constructor: { value: subClass, enumerable: false, writable: true, configurable: true } + }); + if (superClass) + Object.setPrototypeOf + ? Object.setPrototypeOf(subClass, superClass) + : (subClass.__proto__ = superClass); + } + + var ATTRIBUTES = ["height", "width"]; + + var Video = (function(_BlockEmbed) { + _inherits(Video, _BlockEmbed); + + function Video() { + _classCallCheck(this, Video); + + return _possibleConstructorReturn( + this, + (Video.__proto__ || Object.getPrototypeOf(Video)).apply(this, arguments) + ); + } + + _createClass( + Video, + [ + { + key: "format", + value: function format(name, value) { + if (ATTRIBUTES.indexOf(name) > -1) { + if (value) { + this.domNode.setAttribute(name, value); + } else { + this.domNode.removeAttribute(name); + } + } else { + _get( + Video.prototype.__proto__ || Object.getPrototypeOf(Video.prototype), + "format", + this + ).call(this, name, value); + } + } + } + ], + [ + { + key: "create", + value: function create(value) { + var node = _get( + Video.__proto__ || Object.getPrototypeOf(Video), + "create", + this + ).call(this, value); + node.setAttribute("frameborder", "0"); + node.setAttribute("allowfullscreen", true); + node.setAttribute("src", this.sanitize(value)); + return node; + } + }, + { + key: "formats", + value: function formats(domNode) { + return ATTRIBUTES.reduce(function(formats, attribute) { + if (domNode.hasAttribute(attribute)) { + formats[attribute] = domNode.getAttribute(attribute); + } + return formats; + }, {}); + } + }, + { + key: "sanitize", + value: function sanitize(url) { + return _link2.default.sanitize(url); + } + }, + { + key: "value", + value: function value(domNode) { + return domNode.getAttribute("src"); + } + } + ] + ); + + return Video; + })(_block.BlockEmbed); + + Video.blotName = "video"; + Video.className = "ql-video"; + Video.tagName = "IFRAME"; + + exports.default = Video; + + /***/ + }, + /* 66 */ + /***/ function(module, exports, __webpack_require__) { + "use strict"; + + Object.defineProperty(exports, "__esModule", { + value: true + }); + exports.default = exports.FormulaBlot = undefined; + + var _createClass = (function() { + function defineProperties(target, props) { + for (var i = 0; i < props.length; i++) { + var descriptor = props[i]; + descriptor.enumerable = descriptor.enumerable || false; + descriptor.configurable = true; + if ("value" in descriptor) descriptor.writable = true; + Object.defineProperty(target, descriptor.key, descriptor); + } + } + return function(Constructor, protoProps, staticProps) { + if (protoProps) defineProperties(Constructor.prototype, protoProps); + if (staticProps) defineProperties(Constructor, staticProps); + return Constructor; + }; + })(); + + var _get = function get(object, property, receiver) { + if (object === null) object = Function.prototype; + var desc = Object.getOwnPropertyDescriptor(object, property); + if (desc === undefined) { + var parent = Object.getPrototypeOf(object); + if (parent === null) { + return undefined; + } else { + return get(parent, property, receiver); + } + } else if ("value" in desc) { + return desc.value; + } else { + var getter = desc.get; + if (getter === undefined) { + return undefined; + } + return getter.call(receiver); + } + }; + + var _embed = __webpack_require__(34); + + var _embed2 = _interopRequireDefault(_embed); + + var _quill = __webpack_require__(18); + + var _quill2 = _interopRequireDefault(_quill); + + function _interopRequireDefault(obj) { + return obj && obj.__esModule ? obj : { default: obj }; + } + + function _classCallCheck(instance, Constructor) { + if (!(instance instanceof Constructor)) { + throw new TypeError("Cannot call a class as a function"); + } + } + + function _possibleConstructorReturn(self, call) { + if (!self) { + throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); + } + return call && (typeof call === "object" || typeof call === "function") ? call : self; + } + + function _inherits(subClass, superClass) { + if (typeof superClass !== "function" && superClass !== null) { + throw new TypeError( + "Super expression must either be null or a function, not " + typeof superClass + ); + } + subClass.prototype = Object.create(superClass && superClass.prototype, { + constructor: { value: subClass, enumerable: false, writable: true, configurable: true } + }); + if (superClass) + Object.setPrototypeOf + ? Object.setPrototypeOf(subClass, superClass) + : (subClass.__proto__ = superClass); + } + + var FormulaBlot = (function(_Embed) { + _inherits(FormulaBlot, _Embed); + + function FormulaBlot() { + _classCallCheck(this, FormulaBlot); + + return _possibleConstructorReturn( + this, + (FormulaBlot.__proto__ || Object.getPrototypeOf(FormulaBlot)).apply(this, arguments) + ); + } + + _createClass( + FormulaBlot, + [ + { + key: "index", + value: function index(node, offset) { + return 1; + } + } + ], + [ + { + key: "create", + value: function create(value) { + var node = _get( + FormulaBlot.__proto__ || Object.getPrototypeOf(FormulaBlot), + "create", + this + ).call(this, value); + if (typeof value === "string") { + katex.render(value, node); + node.setAttribute("data-value", value); + } + node.setAttribute("contenteditable", false); + return node; + } + }, + { + key: "value", + value: function value(domNode) { + return domNode.getAttribute("data-value"); + } + } + ] + ); + + return FormulaBlot; + })(_embed2.default); + + FormulaBlot.blotName = "formula"; + FormulaBlot.className = "ql-formula"; + FormulaBlot.tagName = "SPAN"; + + function Formula() { + if (window.katex == null) { + throw new Error("Formula module requires KaTeX."); + } + _quill2.default.register(FormulaBlot, true); + } + + exports.FormulaBlot = FormulaBlot; + exports.default = Formula; + + /***/ + }, + /* 67 */ + /***/ function(module, exports, __webpack_require__) { + "use strict"; + + Object.defineProperty(exports, "__esModule", { + value: true + }); + exports.default = exports.CodeToken = exports.CodeBlock = undefined; + + var _createClass = (function() { + function defineProperties(target, props) { + for (var i = 0; i < props.length; i++) { + var descriptor = props[i]; + descriptor.enumerable = descriptor.enumerable || false; + descriptor.configurable = true; + if ("value" in descriptor) descriptor.writable = true; + Object.defineProperty(target, descriptor.key, descriptor); + } + } + return function(Constructor, protoProps, staticProps) { + if (protoProps) defineProperties(Constructor.prototype, protoProps); + if (staticProps) defineProperties(Constructor, staticProps); + return Constructor; + }; + })(); + + var _get = function get(object, property, receiver) { + if (object === null) object = Function.prototype; + var desc = Object.getOwnPropertyDescriptor(object, property); + if (desc === undefined) { + var parent = Object.getPrototypeOf(object); + if (parent === null) { + return undefined; + } else { + return get(parent, property, receiver); + } + } else if ("value" in desc) { + return desc.value; + } else { + var getter = desc.get; + if (getter === undefined) { + return undefined; + } + return getter.call(receiver); + } + }; + + var _parchment = __webpack_require__(2); + + var _parchment2 = _interopRequireDefault(_parchment); + + var _quill = __webpack_require__(18); + + var _quill2 = _interopRequireDefault(_quill); + + var _module = __webpack_require__(39); + + var _module2 = _interopRequireDefault(_module); + + var _code = __webpack_require__(31); + + var _code2 = _interopRequireDefault(_code); + + function _interopRequireDefault(obj) { + return obj && obj.__esModule ? obj : { default: obj }; + } + + function _classCallCheck(instance, Constructor) { + if (!(instance instanceof Constructor)) { + throw new TypeError("Cannot call a class as a function"); + } + } + + function _possibleConstructorReturn(self, call) { + if (!self) { + throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); + } + return call && (typeof call === "object" || typeof call === "function") ? call : self; + } + + function _inherits(subClass, superClass) { + if (typeof superClass !== "function" && superClass !== null) { + throw new TypeError( + "Super expression must either be null or a function, not " + typeof superClass + ); + } + subClass.prototype = Object.create(superClass && superClass.prototype, { + constructor: { value: subClass, enumerable: false, writable: true, configurable: true } + }); + if (superClass) + Object.setPrototypeOf + ? Object.setPrototypeOf(subClass, superClass) + : (subClass.__proto__ = superClass); + } + + var SyntaxCodeBlock = (function(_CodeBlock) { + _inherits(SyntaxCodeBlock, _CodeBlock); + + function SyntaxCodeBlock() { + _classCallCheck(this, SyntaxCodeBlock); + + return _possibleConstructorReturn( + this, + (SyntaxCodeBlock.__proto__ || Object.getPrototypeOf(SyntaxCodeBlock)).apply( + this, + arguments + ) + ); + } + + _createClass(SyntaxCodeBlock, [ + { + key: "replaceWith", + value: function replaceWith(block) { + this.domNode.textContent = this.domNode.textContent; + this.attach(); + _get( + SyntaxCodeBlock.prototype.__proto__ || + Object.getPrototypeOf(SyntaxCodeBlock.prototype), + "replaceWith", + this + ).call(this, block); + } + }, + { + key: "highlight", + value: function highlight(_highlight) { + if (this.cachedHTML !== this.domNode.innerHTML) { + var text = this.domNode.textContent; + if (text.trim().length > 0 || this.cachedHTML == null) { + this.domNode.innerHTML = _highlight(text); + this.attach(); + } + this.cachedHTML = this.domNode.innerHTML; + } + } + } + ]); + + return SyntaxCodeBlock; + })(_code2.default); + + SyntaxCodeBlock.className = "ql-syntax"; + + var CodeToken = new _parchment2.default.Attributor.Class("token", "hljs", { + scope: _parchment2.default.Scope.INLINE + }); + + var Syntax = (function(_Module) { + _inherits(Syntax, _Module); + + function Syntax(quill, options) { + _classCallCheck(this, Syntax); + + var _this2 = _possibleConstructorReturn( + this, + (Syntax.__proto__ || Object.getPrototypeOf(Syntax)).call(this, quill, options) + ); + + if (typeof _this2.options.highlight !== "function") { + throw new Error( + "Syntax module requires highlight.js. Please include the library on the page before Quill." + ); + } + _quill2.default.register(CodeToken, true); + _quill2.default.register(SyntaxCodeBlock, true); + var timer = null; + _this2.quill.on(_quill2.default.events.SCROLL_OPTIMIZE, function() { + if (timer != null) return; + timer = setTimeout(function() { + _this2.highlight(); + timer = null; + }, 100); + }); + _this2.highlight(); + return _this2; + } + + _createClass(Syntax, [ + { + key: "highlight", + value: function highlight() { + var _this3 = this; + + if (this.quill.selection.composing) return; + var range = this.quill.getSelection(); + this.quill.scroll.descendants(SyntaxCodeBlock).forEach(function(code) { + code.highlight(_this3.options.highlight); + }); + this.quill.update(_quill2.default.sources.SILENT); + if (range != null) { + this.quill.setSelection(range, _quill2.default.sources.SILENT); + } + } + } + ]); + + return Syntax; + })(_module2.default); + + Syntax.DEFAULTS = { + highlight: (function() { + if (window.hljs == null) return null; + return function(text) { + var result = window.hljs.highlightAuto(text); + return result.value; + }; + })() + }; + + exports.CodeBlock = SyntaxCodeBlock; + exports.CodeToken = CodeToken; + exports.default = Syntax; + + /***/ + }, + /* 68 */ + /***/ function(module, exports, __webpack_require__) { + "use strict"; + + Object.defineProperty(exports, "__esModule", { + value: true + }); + exports.addControls = exports.default = undefined; + + var _slicedToArray = (function() { + function sliceIterator(arr, i) { + var _arr = []; + var _n = true; + var _d = false; + var _e = undefined; + try { + for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { + _arr.push(_s.value); + if (i && _arr.length === i) break; + } + } catch (err) { + _d = true; + _e = err; + } finally { + try { + if (!_n && _i["return"]) _i["return"](); + } finally { + if (_d) throw _e; + } + } + return _arr; + } + return function(arr, i) { + if (Array.isArray(arr)) { + return arr; + } else if (Symbol.iterator in Object(arr)) { + return sliceIterator(arr, i); + } else { + throw new TypeError("Invalid attempt to destructure non-iterable instance"); + } + }; + })(); + + var _createClass = (function() { + function defineProperties(target, props) { + for (var i = 0; i < props.length; i++) { + var descriptor = props[i]; + descriptor.enumerable = descriptor.enumerable || false; + descriptor.configurable = true; + if ("value" in descriptor) descriptor.writable = true; + Object.defineProperty(target, descriptor.key, descriptor); + } + } + return function(Constructor, protoProps, staticProps) { + if (protoProps) defineProperties(Constructor.prototype, protoProps); + if (staticProps) defineProperties(Constructor, staticProps); + return Constructor; + }; + })(); + + var _extend = __webpack_require__(25); + + var _extend2 = _interopRequireDefault(_extend); + + var _delta = __webpack_require__(20); + + var _delta2 = _interopRequireDefault(_delta); + + var _parchment = __webpack_require__(2); + + var _parchment2 = _interopRequireDefault(_parchment); + + var _quill = __webpack_require__(18); + + var _quill2 = _interopRequireDefault(_quill); + + var _logger = __webpack_require__(30); + + var _logger2 = _interopRequireDefault(_logger); + + var _module = __webpack_require__(39); + + var _module2 = _interopRequireDefault(_module); + + function _interopRequireDefault(obj) { + return obj && obj.__esModule ? obj : { default: obj }; + } + + function _defineProperty(obj, key, value) { + if (key in obj) { + Object.defineProperty(obj, key, { + value: value, + enumerable: true, + configurable: true, + writable: true + }); + } else { + obj[key] = value; + } + return obj; + } + + function _classCallCheck(instance, Constructor) { + if (!(instance instanceof Constructor)) { + throw new TypeError("Cannot call a class as a function"); + } + } + + function _possibleConstructorReturn(self, call) { + if (!self) { + throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); + } + return call && (typeof call === "object" || typeof call === "function") ? call : self; + } + + function _inherits(subClass, superClass) { + if (typeof superClass !== "function" && superClass !== null) { + throw new TypeError( + "Super expression must either be null or a function, not " + typeof superClass + ); + } + subClass.prototype = Object.create(superClass && superClass.prototype, { + constructor: { value: subClass, enumerable: false, writable: true, configurable: true } + }); + if (superClass) + Object.setPrototypeOf + ? Object.setPrototypeOf(subClass, superClass) + : (subClass.__proto__ = superClass); + } + + var debug = (0, _logger2.default)("quill:toolbar"); + + var Toolbar = (function(_Module) { + _inherits(Toolbar, _Module); + + function Toolbar(quill, options) { + _classCallCheck(this, Toolbar); + + var _this = _possibleConstructorReturn( + this, + (Toolbar.__proto__ || Object.getPrototypeOf(Toolbar)).call(this, quill, options) + ); + + if (Array.isArray(_this.options.container)) { + var container = document.createElement("div"); + addControls(container, _this.options.container); + quill.container.parentNode.insertBefore(container, quill.container); + _this.container = container; + } else if (typeof _this.options.container === "string") { + _this.container = document.querySelector(_this.options.container); + } else { + _this.container = _this.options.container; + } + if (!(_this.container instanceof HTMLElement)) { + var _ret; + + return ( + (_ret = debug.error("Container required for toolbar", _this.options)), + _possibleConstructorReturn(_this, _ret) + ); + } + _this.container.classList.add("ql-toolbar"); + _this.controls = []; + _this.handlers = {}; + Object.keys(_this.options.handlers).forEach(function(format) { + _this.addHandler(format, _this.options.handlers[format]); + }); + [].forEach.call(_this.container.querySelectorAll("button, select"), function(input) { + _this.attach(input); + }); + _this.quill.on(_quill2.default.events.EDITOR_CHANGE, function(type, range) { + if (type === _quill2.default.events.SELECTION_CHANGE) { + _this.update(range); + } + }); + _this.quill.on(_quill2.default.events.SCROLL_OPTIMIZE, function() { + var _this$quill$selection = _this.quill.selection.getRange(); + + var _this$quill$selection2 = _slicedToArray(_this$quill$selection, 1); + + var range = _this$quill$selection2[0]; // quill.getSelection triggers update + + _this.update(range); + }); + return _this; + } + + _createClass(Toolbar, [ + { + key: "addHandler", + value: function addHandler(format, handler) { + this.handlers[format] = handler; + } + }, + { + key: "attach", + value: function attach(input) { + var _this2 = this; + + var format = [].find.call(input.classList, function(className) { + return className.indexOf("ql-") === 0; + }); + if (!format) return; + format = format.slice("ql-".length); + if (input.tagName === "BUTTON") { + input.setAttribute("type", "button"); + } + if (this.handlers[format] == null) { + if ( + this.quill.scroll.whitelist != null && + this.quill.scroll.whitelist[format] == null + ) { + debug.warn("ignoring attaching to disabled format", format, input); + return; + } + if (_parchment2.default.query(format) == null) { + debug.warn("ignoring attaching to nonexistent format", format, input); + return; + } + } + var eventName = input.tagName === "SELECT" ? "change" : "click"; + input.addEventListener(eventName, function(e) { + var value = void 0; + if (input.tagName === "SELECT") { + if (input.selectedIndex < 0) return; + var selected = input.options[input.selectedIndex]; + if (selected.hasAttribute("selected")) { + value = false; + } else { + value = selected.value || false; + } + } else { + if (input.classList.contains("ql-active")) { + value = false; + } else { + value = input.value || !input.hasAttribute("value"); + } + e.preventDefault(); + } + _this2.quill.focus(); + + var _quill$selection$getR = _this2.quill.selection.getRange(); + + var _quill$selection$getR2 = _slicedToArray(_quill$selection$getR, 1); + + var range = _quill$selection$getR2[0]; + + if (_this2.handlers[format] != null) { + _this2.handlers[format].call(_this2, value); + } else if ( + _parchment2.default.query(format).prototype instanceof _parchment2.default.Embed + ) { + value = prompt("Enter " + format); + if (!value) return; + _this2.quill.updateContents( + new _delta2.default() + .retain(range.index) + .delete(range.length) + .insert(_defineProperty({}, format, value)), + _quill2.default.sources.USER + ); + } else { + _this2.quill.format(format, value, _quill2.default.sources.USER); + } + _this2.update(range); + }); + // TODO use weakmap + this.controls.push([format, input]); + } + }, + { + key: "update", + value: function update(range) { + var formats = range == null ? {} : this.quill.getFormat(range); + this.controls.forEach(function(pair) { + var _pair = _slicedToArray(pair, 2); + + var format = _pair[0]; + var input = _pair[1]; + + if (input.tagName === "SELECT") { + var option = void 0; + if (range == null) { + option = null; + } else if (formats[format] == null) { + option = input.querySelector("option[selected]"); + } else if (!Array.isArray(formats[format])) { + var value = formats[format]; + if (typeof value === "string") { + value = value.replace(/\"/g, '\\"'); + } + option = input.querySelector('option[value="' + value + '"]'); + } + if (option == null) { + input.value = ""; // TODO make configurable? + input.selectedIndex = -1; + } else { + option.selected = true; + } + } else { + if (range == null) { + input.classList.remove("ql-active"); + } else if (input.hasAttribute("value")) { + // both being null should match (default values) + // '1' should match with 1 (headers) + var isActive = + formats[format] === input.getAttribute("value") || + (formats[format] != null && + formats[format].toString() === input.getAttribute("value")) || + (formats[format] == null && !input.getAttribute("value")); + input.classList.toggle("ql-active", isActive); + } else { + input.classList.toggle("ql-active", formats[format] != null); + } + } + }); + } + } + ]); + + return Toolbar; + })(_module2.default); + + Toolbar.DEFAULTS = {}; + + function addButton(container, format, value) { + var input = document.createElement("button"); + input.setAttribute("type", "button"); + input.classList.add("ql-" + format); + if (value != null) { + input.value = value; + } + container.appendChild(input); + } + + function addControls(container, groups) { + if (!Array.isArray(groups[0])) { + groups = [groups]; + } + groups.forEach(function(controls) { + var group = document.createElement("span"); + group.classList.add("ql-formats"); + controls.forEach(function(control) { + if (typeof control === "string") { + addButton(group, control); + } else { + var format = Object.keys(control)[0]; + var value = control[format]; + if (Array.isArray(value)) { + addSelect(group, format, value); + } else { + addButton(group, format, value); + } + } + }); + container.appendChild(group); + }); + } + + function addSelect(container, format, values) { + var input = document.createElement("select"); + input.classList.add("ql-" + format); + values.forEach(function(value) { + var option = document.createElement("option"); + if (value !== false) { + option.setAttribute("value", value); + } else { + option.setAttribute("selected", "selected"); + } + input.appendChild(option); + }); + container.appendChild(input); + } + + Toolbar.DEFAULTS = { + container: null, + handlers: { + clean: function clean(value) { + var _this3 = this; + + var range = this.quill.getSelection(); + if (range == null) return; + if (range.length == 0) { + var formats = this.quill.getFormat(); + Object.keys(formats).forEach(function(name) { + // Clean functionality in existing apps only clean inline formats + if (_parchment2.default.query(name, _parchment2.default.Scope.INLINE) != null) { + _this3.quill.format(name, false); + } + }); + } else { + this.quill.removeFormat(range, _quill2.default.sources.USER); + } + }, + direction: function direction(value) { + var align = this.quill.getFormat()["align"]; + if (value === "rtl" && align == null) { + this.quill.format("align", "right", _quill2.default.sources.USER); + } else if (!value && align === "right") { + this.quill.format("align", false, _quill2.default.sources.USER); + } + this.quill.format("direction", value, _quill2.default.sources.USER); + }, + link: function link(value) { + if (value === true) { + value = prompt("Enter link URL:"); + } + this.quill.format("link", value, _quill2.default.sources.USER); + }, + indent: function indent(value) { + var range = this.quill.getSelection(); + var formats = this.quill.getFormat(range); + var indent = parseInt(formats.indent || 0); + if (value === "+1" || value === "-1") { + var modifier = value === "+1" ? 1 : -1; + if (formats.direction === "rtl") modifier *= -1; + this.quill.format("indent", indent + modifier, _quill2.default.sources.USER); + } + } + } + }; + + exports.default = Toolbar; + exports.addControls = addControls; + + /***/ + }, + /* 69 */ + /***/ function(module, exports, __webpack_require__) { + "use strict"; + + module.exports = { + align: { + "": __webpack_require__(70), + center: __webpack_require__(71), + right: __webpack_require__(72), + justify: __webpack_require__(73) + }, + background: __webpack_require__(74), + blockquote: __webpack_require__(75), + bold: __webpack_require__(76), + clean: __webpack_require__(77), + code: __webpack_require__(78), + "code-block": __webpack_require__(78), + color: __webpack_require__(79), + direction: { + "": __webpack_require__(80), + rtl: __webpack_require__(81) + }, + float: { + center: __webpack_require__(82), + full: __webpack_require__(83), + left: __webpack_require__(84), + right: __webpack_require__(85) + }, + formula: __webpack_require__(86), + header: { + "1": __webpack_require__(87), + "2": __webpack_require__(88) + }, + italic: __webpack_require__(89), + image: __webpack_require__(90), + indent: { + "+1": __webpack_require__(91), + "-1": __webpack_require__(92) + }, + link: __webpack_require__(93), + list: { + ordered: __webpack_require__(94), + bullet: __webpack_require__(95) + }, + script: { + sub: __webpack_require__(96), + super: __webpack_require__(97) + }, + strike: __webpack_require__(98), + underline: __webpack_require__(99), + video: __webpack_require__(100) + }; + + /***/ + }, + /* 70 */ + /***/ function(module, exports) { + module.exports = + ' '; + + /***/ + }, + /* 71 */ + /***/ function(module, exports) { + module.exports = + ' '; + + /***/ + }, + /* 72 */ + /***/ function(module, exports) { + module.exports = + ' '; + + /***/ + }, + /* 73 */ + /***/ function(module, exports) { + module.exports = + ' '; + + /***/ + }, + /* 74 */ + /***/ function(module, exports) { + module.exports = + ' '; + + /***/ + }, + /* 75 */ + /***/ function(module, exports) { + module.exports = + ' '; + + /***/ + }, + /* 76 */ + /***/ function(module, exports) { + module.exports = + ' '; + + /***/ + }, + /* 77 */ + /***/ function(module, exports) { + module.exports = + ' '; + + /***/ + }, + /* 78 */ + /***/ function(module, exports) { + module.exports = + ' '; + + /***/ + }, + /* 79 */ + /***/ function(module, exports) { + module.exports = + ' '; + + /***/ + }, + /* 80 */ + /***/ function(module, exports) { + module.exports = + ' '; + + /***/ + }, + /* 81 */ + /***/ function(module, exports) { + module.exports = + ' '; + + /***/ + }, + /* 82 */ + /***/ function(module, exports) { + module.exports = + ' '; + + /***/ + }, + /* 83 */ + /***/ function(module, exports) { + module.exports = + ' '; + + /***/ + }, + /* 84 */ + /***/ function(module, exports) { + module.exports = + ' '; + + /***/ + }, + /* 85 */ + /***/ function(module, exports) { + module.exports = + ' '; + + /***/ + }, + /* 86 */ + /***/ function(module, exports) { + module.exports = + ' '; + + /***/ + }, + /* 87 */ + /***/ function(module, exports) { + module.exports = + ' '; + + /***/ + }, + /* 88 */ + /***/ function(module, exports) { + module.exports = + ' '; + + /***/ + }, + /* 89 */ + /***/ function(module, exports) { + module.exports = + ' '; + + /***/ + }, + /* 90 */ + /***/ function(module, exports) { + module.exports = + ' '; + + /***/ + }, + /* 91 */ + /***/ function(module, exports) { + module.exports = + ' '; + + /***/ + }, + /* 92 */ + /***/ function(module, exports) { + module.exports = + ' '; + + /***/ + }, + /* 93 */ + /***/ function(module, exports) { + module.exports = + ' '; + + /***/ + }, + /* 94 */ + /***/ function(module, exports) { + module.exports = + ' '; + + /***/ + }, + /* 95 */ + /***/ function(module, exports) { + module.exports = + ' '; + + /***/ + }, + /* 96 */ + /***/ function(module, exports) { + module.exports = + ' '; + + /***/ + }, + /* 97 */ + /***/ function(module, exports) { + module.exports = + ' '; + + /***/ + }, + /* 98 */ + /***/ function(module, exports) { + module.exports = + ' '; + + /***/ + }, + /* 99 */ + /***/ function(module, exports) { + module.exports = + ' '; + + /***/ + }, + /* 100 */ + /***/ function(module, exports) { + module.exports = + ' '; + + /***/ + }, + /* 101 */ + /***/ function(module, exports, __webpack_require__) { + "use strict"; + + Object.defineProperty(exports, "__esModule", { + value: true + }); + + var _typeof = + typeof Symbol === "function" && typeof Symbol.iterator === "symbol" + ? function(obj) { + return typeof obj; + } + : function(obj) { + return obj && + typeof Symbol === "function" && + obj.constructor === Symbol && + obj !== Symbol.prototype + ? "symbol" + : typeof obj; + }; + + var _createClass = (function() { + function defineProperties(target, props) { + for (var i = 0; i < props.length; i++) { + var descriptor = props[i]; + descriptor.enumerable = descriptor.enumerable || false; + descriptor.configurable = true; + if ("value" in descriptor) descriptor.writable = true; + Object.defineProperty(target, descriptor.key, descriptor); + } + } + return function(Constructor, protoProps, staticProps) { + if (protoProps) defineProperties(Constructor.prototype, protoProps); + if (staticProps) defineProperties(Constructor, staticProps); + return Constructor; + }; + })(); + + var _dropdown = __webpack_require__(102); + + var _dropdown2 = _interopRequireDefault(_dropdown); + + function _interopRequireDefault(obj) { + return obj && obj.__esModule ? obj : { default: obj }; + } + + function _classCallCheck(instance, Constructor) { + if (!(instance instanceof Constructor)) { + throw new TypeError("Cannot call a class as a function"); + } + } + + var Picker = (function() { + function Picker(select) { + var _this = this; + + _classCallCheck(this, Picker); + + this.select = select; + this.container = document.createElement("span"); + this.buildPicker(); + this.select.style.display = "none"; + this.select.parentNode.insertBefore(this.container, this.select); + this.label.addEventListener("click", function(event) { + _this.container.classList.toggle("ql-expanded"); + }); + this.select.addEventListener("change", this.update.bind(this)); + } + + _createClass(Picker, [ + { + key: "buildItem", + value: function buildItem(option) { + var _this2 = this; + + var item = document.createElement("span"); + item.classList.add("ql-picker-item"); + if (option.hasAttribute("value")) { + item.setAttribute("data-value", option.getAttribute("value")); + } + if (option.textContent) { + item.setAttribute("data-label", option.textContent); + } + item.addEventListener("click", function(event) { + _this2.selectItem(item, true); + }); + return item; + } + }, + { + key: "buildLabel", + value: function buildLabel() { + var label = document.createElement("span"); + label.classList.add("ql-picker-label"); + label.innerHTML = _dropdown2.default; + this.container.appendChild(label); + return label; + } + }, + { + key: "buildOptions", + value: function buildOptions() { + var _this3 = this; + + var options = document.createElement("span"); + options.classList.add("ql-picker-options"); + [].slice.call(this.select.options).forEach(function(option) { + var item = _this3.buildItem(option); + options.appendChild(item); + if (option.hasAttribute("selected")) { + _this3.selectItem(item); + } + }); + this.container.appendChild(options); + } + }, + { + key: "buildPicker", + value: function buildPicker() { + var _this4 = this; + + [].slice.call(this.select.attributes).forEach(function(item) { + _this4.container.setAttribute(item.name, item.value); + }); + this.container.classList.add("ql-picker"); + this.label = this.buildLabel(); + this.buildOptions(); + } + }, + { + key: "close", + value: function close() { + this.container.classList.remove("ql-expanded"); + } + }, + { + key: "selectItem", + value: function selectItem(item) { + var trigger = + arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false; + + var selected = this.container.querySelector(".ql-selected"); + if (item === selected) return; + if (selected != null) { + selected.classList.remove("ql-selected"); + } + if (item != null) { + item.classList.add("ql-selected"); + this.select.selectedIndex = [].indexOf.call(item.parentNode.children, item); + if (item.hasAttribute("data-value")) { + this.label.setAttribute("data-value", item.getAttribute("data-value")); + } else { + this.label.removeAttribute("data-value"); + } + if (item.hasAttribute("data-label")) { + this.label.setAttribute("data-label", item.getAttribute("data-label")); + } else { + this.label.removeAttribute("data-label"); + } + if (trigger) { + if (typeof Event === "function") { + this.select.dispatchEvent(new Event("change")); + } else if ( + (typeof Event === "undefined" ? "undefined" : _typeof(Event)) === "object" + ) { + // IE11 + var event = document.createEvent("Event"); + event.initEvent("change", true, true); + this.select.dispatchEvent(event); + } + this.close(); + } + } else { + this.label.removeAttribute("data-value"); + this.label.removeAttribute("data-label"); + } + } + }, + { + key: "update", + value: function update() { + var option = void 0; + if (this.select.selectedIndex > -1) { + var item = this.container.querySelector(".ql-picker-options").children[ + this.select.selectedIndex + ]; + option = this.select.options[this.select.selectedIndex]; + this.selectItem(item); + } else { + this.selectItem(null); + } + var isActive = + option != null && option !== this.select.querySelector("option[selected]"); + this.label.classList.toggle("ql-active", isActive); + } + } + ]); + + return Picker; + })(); + + exports.default = Picker; + + /***/ + }, + /* 102 */ + /***/ function(module, exports) { + module.exports = + ' '; + + /***/ + }, + /* 103 */ + /***/ function(module, exports, __webpack_require__) { + "use strict"; + + Object.defineProperty(exports, "__esModule", { + value: true + }); + + var _createClass = (function() { + function defineProperties(target, props) { + for (var i = 0; i < props.length; i++) { + var descriptor = props[i]; + descriptor.enumerable = descriptor.enumerable || false; + descriptor.configurable = true; + if ("value" in descriptor) descriptor.writable = true; + Object.defineProperty(target, descriptor.key, descriptor); + } + } + return function(Constructor, protoProps, staticProps) { + if (protoProps) defineProperties(Constructor.prototype, protoProps); + if (staticProps) defineProperties(Constructor, staticProps); + return Constructor; + }; + })(); + + var _get = function get(object, property, receiver) { + if (object === null) object = Function.prototype; + var desc = Object.getOwnPropertyDescriptor(object, property); + if (desc === undefined) { + var parent = Object.getPrototypeOf(object); + if (parent === null) { + return undefined; + } else { + return get(parent, property, receiver); + } + } else if ("value" in desc) { + return desc.value; + } else { + var getter = desc.get; + if (getter === undefined) { + return undefined; + } + return getter.call(receiver); + } + }; + + var _picker = __webpack_require__(101); + + var _picker2 = _interopRequireDefault(_picker); + + function _interopRequireDefault(obj) { + return obj && obj.__esModule ? obj : { default: obj }; + } + + function _classCallCheck(instance, Constructor) { + if (!(instance instanceof Constructor)) { + throw new TypeError("Cannot call a class as a function"); + } + } + + function _possibleConstructorReturn(self, call) { + if (!self) { + throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); + } + return call && (typeof call === "object" || typeof call === "function") ? call : self; + } + + function _inherits(subClass, superClass) { + if (typeof superClass !== "function" && superClass !== null) { + throw new TypeError( + "Super expression must either be null or a function, not " + typeof superClass + ); + } + subClass.prototype = Object.create(superClass && superClass.prototype, { + constructor: { value: subClass, enumerable: false, writable: true, configurable: true } + }); + if (superClass) + Object.setPrototypeOf + ? Object.setPrototypeOf(subClass, superClass) + : (subClass.__proto__ = superClass); + } + + var ColorPicker = (function(_Picker) { + _inherits(ColorPicker, _Picker); + + function ColorPicker(select, label) { + _classCallCheck(this, ColorPicker); + + var _this = _possibleConstructorReturn( + this, + (ColorPicker.__proto__ || Object.getPrototypeOf(ColorPicker)).call(this, select) + ); + + _this.label.innerHTML = label; + _this.container.classList.add("ql-color-picker"); + [].slice + .call(_this.container.querySelectorAll(".ql-picker-item"), 0, 7) + .forEach(function(item) { + item.classList.add("ql-primary"); + }); + return _this; + } + + _createClass(ColorPicker, [ + { + key: "buildItem", + value: function buildItem(option) { + var item = _get( + ColorPicker.prototype.__proto__ || Object.getPrototypeOf(ColorPicker.prototype), + "buildItem", + this + ).call(this, option); + item.style.backgroundColor = option.getAttribute("value") || ""; + return item; + } + }, + { + key: "selectItem", + value: function selectItem(item, trigger) { + _get( + ColorPicker.prototype.__proto__ || Object.getPrototypeOf(ColorPicker.prototype), + "selectItem", + this + ).call(this, item, trigger); + var colorLabel = this.label.querySelector(".ql-color-label"); + var value = item ? item.getAttribute("data-value") || "" : ""; + if (colorLabel) { + if (colorLabel.tagName === "line") { + colorLabel.style.stroke = value; + } else { + colorLabel.style.fill = value; + } + } + } + } + ]); + + return ColorPicker; + })(_picker2.default); + + exports.default = ColorPicker; + + /***/ + }, + /* 104 */ + /***/ function(module, exports, __webpack_require__) { + "use strict"; + + Object.defineProperty(exports, "__esModule", { + value: true + }); + + var _createClass = (function() { + function defineProperties(target, props) { + for (var i = 0; i < props.length; i++) { + var descriptor = props[i]; + descriptor.enumerable = descriptor.enumerable || false; + descriptor.configurable = true; + if ("value" in descriptor) descriptor.writable = true; + Object.defineProperty(target, descriptor.key, descriptor); + } + } + return function(Constructor, protoProps, staticProps) { + if (protoProps) defineProperties(Constructor.prototype, protoProps); + if (staticProps) defineProperties(Constructor, staticProps); + return Constructor; + }; + })(); + + var _get = function get(object, property, receiver) { + if (object === null) object = Function.prototype; + var desc = Object.getOwnPropertyDescriptor(object, property); + if (desc === undefined) { + var parent = Object.getPrototypeOf(object); + if (parent === null) { + return undefined; + } else { + return get(parent, property, receiver); + } + } else if ("value" in desc) { + return desc.value; + } else { + var getter = desc.get; + if (getter === undefined) { + return undefined; + } + return getter.call(receiver); + } + }; + + var _picker = __webpack_require__(101); + + var _picker2 = _interopRequireDefault(_picker); + + function _interopRequireDefault(obj) { + return obj && obj.__esModule ? obj : { default: obj }; + } + + function _classCallCheck(instance, Constructor) { + if (!(instance instanceof Constructor)) { + throw new TypeError("Cannot call a class as a function"); + } + } + + function _possibleConstructorReturn(self, call) { + if (!self) { + throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); + } + return call && (typeof call === "object" || typeof call === "function") ? call : self; + } + + function _inherits(subClass, superClass) { + if (typeof superClass !== "function" && superClass !== null) { + throw new TypeError( + "Super expression must either be null or a function, not " + typeof superClass + ); + } + subClass.prototype = Object.create(superClass && superClass.prototype, { + constructor: { value: subClass, enumerable: false, writable: true, configurable: true } + }); + if (superClass) + Object.setPrototypeOf + ? Object.setPrototypeOf(subClass, superClass) + : (subClass.__proto__ = superClass); + } + + var IconPicker = (function(_Picker) { + _inherits(IconPicker, _Picker); + + function IconPicker(select, icons) { + _classCallCheck(this, IconPicker); + + var _this = _possibleConstructorReturn( + this, + (IconPicker.__proto__ || Object.getPrototypeOf(IconPicker)).call(this, select) + ); + + _this.container.classList.add("ql-icon-picker"); + [].forEach.call(_this.container.querySelectorAll(".ql-picker-item"), function(item) { + item.innerHTML = icons[item.getAttribute("data-value") || ""]; + }); + _this.defaultItem = _this.container.querySelector(".ql-selected"); + _this.selectItem(_this.defaultItem); + return _this; + } + + _createClass(IconPicker, [ + { + key: "selectItem", + value: function selectItem(item, trigger) { + _get( + IconPicker.prototype.__proto__ || Object.getPrototypeOf(IconPicker.prototype), + "selectItem", + this + ).call(this, item, trigger); + item = item || this.defaultItem; + this.label.innerHTML = item.innerHTML; + } + } + ]); + + return IconPicker; + })(_picker2.default); + + exports.default = IconPicker; + + /***/ + }, + /* 105 */ + /***/ function(module, exports) { + "use strict"; + + Object.defineProperty(exports, "__esModule", { + value: true + }); + + var _createClass = (function() { + function defineProperties(target, props) { + for (var i = 0; i < props.length; i++) { + var descriptor = props[i]; + descriptor.enumerable = descriptor.enumerable || false; + descriptor.configurable = true; + if ("value" in descriptor) descriptor.writable = true; + Object.defineProperty(target, descriptor.key, descriptor); + } + } + return function(Constructor, protoProps, staticProps) { + if (protoProps) defineProperties(Constructor.prototype, protoProps); + if (staticProps) defineProperties(Constructor, staticProps); + return Constructor; + }; + })(); + + function _classCallCheck(instance, Constructor) { + if (!(instance instanceof Constructor)) { + throw new TypeError("Cannot call a class as a function"); + } + } + + var Tooltip = (function() { + function Tooltip(quill, boundsContainer) { + var _this = this; + + _classCallCheck(this, Tooltip); + + this.quill = quill; + this.boundsContainer = boundsContainer || document.body; + this.root = quill.addContainer("ql-tooltip"); + this.root.innerHTML = this.constructor.TEMPLATE; + var offset = parseInt(window.getComputedStyle(this.root).marginTop); + this.quill.root.addEventListener("scroll", function() { + _this.root.style.marginTop = -1 * _this.quill.root.scrollTop + offset + "px"; + _this.checkBounds(); + }); + this.hide(); + } + + _createClass(Tooltip, [ + { + key: "checkBounds", + value: function checkBounds() { + this.root.classList.toggle("ql-out-top", this.root.offsetTop <= 0); + this.root.classList.remove("ql-out-bottom"); + this.root.classList.toggle( + "ql-out-bottom", + this.root.offsetTop + this.root.offsetHeight >= this.quill.root.offsetHeight + ); + } + }, + { + key: "hide", + value: function hide() { + this.root.classList.add("ql-hidden"); + } + }, + { + key: "position", + value: function position(reference) { + var left = reference.left + reference.width / 2 - this.root.offsetWidth / 2; + var top = reference.bottom + this.quill.root.scrollTop; + this.root.style.left = left + "px"; + this.root.style.top = top + "px"; + var containerBounds = this.boundsContainer.getBoundingClientRect(); + var rootBounds = this.root.getBoundingClientRect(); + var shift = 0; + if (rootBounds.right > containerBounds.right) { + shift = containerBounds.right - rootBounds.right; + this.root.style.left = left + shift + "px"; + } + if (rootBounds.left < containerBounds.left) { + shift = containerBounds.left - rootBounds.left; + this.root.style.left = left + shift + "px"; + } + this.checkBounds(); + return shift; + } + }, + { + key: "show", + value: function show() { + this.root.classList.remove("ql-editing"); + this.root.classList.remove("ql-hidden"); + } + } + ]); + + return Tooltip; + })(); + + exports.default = Tooltip; + + /***/ + }, + /* 106 */ + /***/ function(module, exports, __webpack_require__) { + "use strict"; + + Object.defineProperty(exports, "__esModule", { + value: true + }); + + var _get = function get(object, property, receiver) { + if (object === null) object = Function.prototype; + var desc = Object.getOwnPropertyDescriptor(object, property); + if (desc === undefined) { + var parent = Object.getPrototypeOf(object); + if (parent === null) { + return undefined; + } else { + return get(parent, property, receiver); + } + } else if ("value" in desc) { + return desc.value; + } else { + var getter = desc.get; + if (getter === undefined) { + return undefined; + } + return getter.call(receiver); + } + }; + + var _createClass = (function() { + function defineProperties(target, props) { + for (var i = 0; i < props.length; i++) { + var descriptor = props[i]; + descriptor.enumerable = descriptor.enumerable || false; + descriptor.configurable = true; + if ("value" in descriptor) descriptor.writable = true; + Object.defineProperty(target, descriptor.key, descriptor); + } + } + return function(Constructor, protoProps, staticProps) { + if (protoProps) defineProperties(Constructor.prototype, protoProps); + if (staticProps) defineProperties(Constructor, staticProps); + return Constructor; + }; + })(); + + var _extend = __webpack_require__(25); + + var _extend2 = _interopRequireDefault(_extend); + + var _emitter = __webpack_require__(28); + + var _emitter2 = _interopRequireDefault(_emitter); + + var _keyboard = __webpack_require__(52); + + var _keyboard2 = _interopRequireDefault(_keyboard); + + var _base = __webpack_require__(107); + + var _base2 = _interopRequireDefault(_base); + + var _icons = __webpack_require__(69); + + var _icons2 = _interopRequireDefault(_icons); + + var _selection = __webpack_require__(40); + + function _interopRequireDefault(obj) { + return obj && obj.__esModule ? obj : { default: obj }; + } + + function _classCallCheck(instance, Constructor) { + if (!(instance instanceof Constructor)) { + throw new TypeError("Cannot call a class as a function"); + } + } + + function _possibleConstructorReturn(self, call) { + if (!self) { + throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); + } + return call && (typeof call === "object" || typeof call === "function") ? call : self; + } + + function _inherits(subClass, superClass) { + if (typeof superClass !== "function" && superClass !== null) { + throw new TypeError( + "Super expression must either be null or a function, not " + typeof superClass + ); + } + subClass.prototype = Object.create(superClass && superClass.prototype, { + constructor: { value: subClass, enumerable: false, writable: true, configurable: true } + }); + if (superClass) + Object.setPrototypeOf + ? Object.setPrototypeOf(subClass, superClass) + : (subClass.__proto__ = superClass); + } + + var TOOLBAR_CONFIG = [ + ["bold", "italic", "link"], + [{ header: 1 }, { header: 2 }, "blockquote"] + ]; + + var BubbleTheme = (function(_BaseTheme) { + _inherits(BubbleTheme, _BaseTheme); + + function BubbleTheme(quill, options) { + _classCallCheck(this, BubbleTheme); + + if (options.modules.toolbar != null && options.modules.toolbar.container == null) { + options.modules.toolbar.container = TOOLBAR_CONFIG; + } + + var _this = _possibleConstructorReturn( + this, + (BubbleTheme.__proto__ || Object.getPrototypeOf(BubbleTheme)).call( + this, + quill, + options + ) + ); + + _this.quill.container.classList.add("ql-bubble"); + return _this; + } + + _createClass(BubbleTheme, [ + { + key: "extendToolbar", + value: function extendToolbar(toolbar) { + this.tooltip = new BubbleTooltip(this.quill, this.options.bounds); + this.tooltip.root.appendChild(toolbar.container); + this.buildButtons([].slice.call(toolbar.container.querySelectorAll("button"))); + this.buildPickers([].slice.call(toolbar.container.querySelectorAll("select"))); + } + } + ]); + + return BubbleTheme; + })(_base2.default); + + BubbleTheme.DEFAULTS = (0, _extend2.default)(true, {}, _base2.default.DEFAULTS, { + modules: { + toolbar: { + handlers: { + link: function link(value) { + if (!value) { + this.quill.format("link", false); + } else { + this.quill.theme.tooltip.edit(); + } + } + } + } + } + }); + + var BubbleTooltip = (function(_BaseTooltip) { + _inherits(BubbleTooltip, _BaseTooltip); + + function BubbleTooltip(quill, bounds) { + _classCallCheck(this, BubbleTooltip); + + var _this2 = _possibleConstructorReturn( + this, + (BubbleTooltip.__proto__ || Object.getPrototypeOf(BubbleTooltip)).call( + this, + quill, + bounds + ) + ); + + _this2.quill.on(_emitter2.default.events.EDITOR_CHANGE, function(type, range) { + if (type !== _emitter2.default.events.SELECTION_CHANGE) return; + if (range != null && range.length > 0) { + _this2.show(); + // Lock our width so we will expand beyond our offsetParent boundaries + _this2.root.style.left = "0px"; + _this2.root.style.width = ""; + _this2.root.style.width = _this2.root.offsetWidth + "px"; + var lines = _this2.quill.scroll.lines(range.index, range.length); + if (lines.length === 1) { + _this2.position(_this2.quill.getBounds(range)); + } else { + var lastLine = lines[lines.length - 1]; + var index = lastLine.offset(_this2.quill.scroll); + var length = Math.min(lastLine.length() - 1, range.index + range.length - index); + var _bounds = _this2.quill.getBounds(new _selection.Range(index, length)); + _this2.position(_bounds); + } + } else if (document.activeElement !== _this2.textbox && _this2.quill.hasFocus()) { + _this2.hide(); + } + }); + return _this2; + } + + _createClass(BubbleTooltip, [ + { + key: "listen", + value: function listen() { + var _this3 = this; + + _get( + BubbleTooltip.prototype.__proto__ || + Object.getPrototypeOf(BubbleTooltip.prototype), + "listen", + this + ).call(this); + this.root.querySelector(".ql-close").addEventListener("click", function(event) { + _this3.root.classList.remove("ql-editing"); + }); + this.quill.on(_emitter2.default.events.SCROLL_OPTIMIZE, function() { + // Let selection be restored by toolbar handlers before repositioning + setTimeout(function() { + if (_this3.root.classList.contains("ql-hidden")) return; + var range = _this3.quill.getSelection(); + if (range != null) { + _this3.position(_this3.quill.getBounds(range)); + } + }, 1); + }); + } + }, + { + key: "cancel", + value: function cancel() { + this.show(); + } + }, + { + key: "position", + value: function position(reference) { + var shift = _get( + BubbleTooltip.prototype.__proto__ || + Object.getPrototypeOf(BubbleTooltip.prototype), + "position", + this + ).call(this, reference); + if (shift === 0) return shift; + var arrow = this.root.querySelector(".ql-tooltip-arrow"); + arrow.style.marginLeft = ""; + arrow.style.marginLeft = -1 * shift - arrow.offsetWidth / 2 + "px"; + } + } + ]); + + return BubbleTooltip; + })(_base.BaseTooltip); + + BubbleTooltip.TEMPLATE = [ + '', + '
                    ', + '', + '', + "
                    " + ].join(""); + + exports.default = BubbleTheme; + + /***/ + }, + /* 107 */ + /***/ function(module, exports, __webpack_require__) { + "use strict"; + + Object.defineProperty(exports, "__esModule", { + value: true + }); + exports.default = exports.BaseTooltip = undefined; + + var _createClass = (function() { + function defineProperties(target, props) { + for (var i = 0; i < props.length; i++) { + var descriptor = props[i]; + descriptor.enumerable = descriptor.enumerable || false; + descriptor.configurable = true; + if ("value" in descriptor) descriptor.writable = true; + Object.defineProperty(target, descriptor.key, descriptor); + } + } + return function(Constructor, protoProps, staticProps) { + if (protoProps) defineProperties(Constructor.prototype, protoProps); + if (staticProps) defineProperties(Constructor, staticProps); + return Constructor; + }; + })(); + + var _get = function get(object, property, receiver) { + if (object === null) object = Function.prototype; + var desc = Object.getOwnPropertyDescriptor(object, property); + if (desc === undefined) { + var parent = Object.getPrototypeOf(object); + if (parent === null) { + return undefined; + } else { + return get(parent, property, receiver); + } + } else if ("value" in desc) { + return desc.value; + } else { + var getter = desc.get; + if (getter === undefined) { + return undefined; + } + return getter.call(receiver); + } + }; + + var _extend = __webpack_require__(25); + + var _extend2 = _interopRequireDefault(_extend); + + var _delta = __webpack_require__(20); + + var _delta2 = _interopRequireDefault(_delta); + + var _emitter = __webpack_require__(28); + + var _emitter2 = _interopRequireDefault(_emitter); + + var _keyboard = __webpack_require__(52); + + var _keyboard2 = _interopRequireDefault(_keyboard); + + var _theme = __webpack_require__(41); + + var _theme2 = _interopRequireDefault(_theme); + + var _colorPicker = __webpack_require__(103); + + var _colorPicker2 = _interopRequireDefault(_colorPicker); + + var _iconPicker = __webpack_require__(104); + + var _iconPicker2 = _interopRequireDefault(_iconPicker); + + var _picker = __webpack_require__(101); + + var _picker2 = _interopRequireDefault(_picker); + + var _tooltip = __webpack_require__(105); + + var _tooltip2 = _interopRequireDefault(_tooltip); + + var _icons = __webpack_require__(69); + + var _icons2 = _interopRequireDefault(_icons); + + function _interopRequireDefault(obj) { + return obj && obj.__esModule ? obj : { default: obj }; + } + + function _classCallCheck(instance, Constructor) { + if (!(instance instanceof Constructor)) { + throw new TypeError("Cannot call a class as a function"); + } + } + + function _possibleConstructorReturn(self, call) { + if (!self) { + throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); + } + return call && (typeof call === "object" || typeof call === "function") ? call : self; + } + + function _inherits(subClass, superClass) { + if (typeof superClass !== "function" && superClass !== null) { + throw new TypeError( + "Super expression must either be null or a function, not " + typeof superClass + ); + } + subClass.prototype = Object.create(superClass && superClass.prototype, { + constructor: { value: subClass, enumerable: false, writable: true, configurable: true } + }); + if (superClass) + Object.setPrototypeOf + ? Object.setPrototypeOf(subClass, superClass) + : (subClass.__proto__ = superClass); + } + + var ALIGNS = [false, "center", "right", "justify"]; + + var COLORS = [ + "#000000", + "#e60000", + "#ff9900", + "#ffff00", + "#008a00", + "#0066cc", + "#9933ff", + "#ffffff", + "#facccc", + "#ffebcc", + "#ffffcc", + "#cce8cc", + "#cce0f5", + "#ebd6ff", + "#bbbbbb", + "#f06666", + "#ffc266", + "#ffff66", + "#66b966", + "#66a3e0", + "#c285ff", + "#888888", + "#a10000", + "#b26b00", + "#b2b200", + "#006100", + "#0047b2", + "#6b24b2", + "#444444", + "#5c0000", + "#663d00", + "#666600", + "#003700", + "#002966", + "#3d1466" + ]; + + var FONTS = [false, "serif", "monospace"]; + + var HEADERS = ["1", "2", "3", false]; + + var SIZES = ["small", false, "large", "huge"]; + + var BaseTheme = (function(_Theme) { + _inherits(BaseTheme, _Theme); + + function BaseTheme(quill, options) { + _classCallCheck(this, BaseTheme); + + var _this = _possibleConstructorReturn( + this, + (BaseTheme.__proto__ || Object.getPrototypeOf(BaseTheme)).call(this, quill, options) + ); + + var listener = function listener(e) { + if (!document.body.contains(quill.root)) { + return document.body.removeEventListener("click", listener); + } + if ( + _this.tooltip != null && + !_this.tooltip.root.contains(e.target) && + document.activeElement !== _this.tooltip.textbox && + !_this.quill.hasFocus() + ) { + _this.tooltip.hide(); + } + if (_this.pickers != null) { + _this.pickers.forEach(function(picker) { + if (!picker.container.contains(e.target)) { + picker.close(); + } + }); + } + }; + document.body.addEventListener("click", listener); + return _this; + } + + _createClass(BaseTheme, [ + { + key: "addModule", + value: function addModule(name) { + var module = _get( + BaseTheme.prototype.__proto__ || Object.getPrototypeOf(BaseTheme.prototype), + "addModule", + this + ).call(this, name); + if (name === "toolbar") { + this.extendToolbar(module); + } + return module; + } + }, + { + key: "buildButtons", + value: function buildButtons(buttons) { + buttons.forEach(function(button) { + var className = button.getAttribute("class") || ""; + className.split(/\s+/).forEach(function(name) { + if (!name.startsWith("ql-")) return; + name = name.slice("ql-".length); + if (_icons2.default[name] == null) return; + if (name === "direction") { + button.innerHTML = _icons2.default[name][""] + _icons2.default[name]["rtl"]; + } else if (typeof _icons2.default[name] === "string") { + button.innerHTML = _icons2.default[name]; + } else { + var value = button.value || ""; + if (value != null && _icons2.default[name][value]) { + button.innerHTML = _icons2.default[name][value]; + } + } + }); + }); + } + }, + { + key: "buildPickers", + value: function buildPickers(selects) { + var _this2 = this; + + this.pickers = selects.map(function(select) { + if (select.classList.contains("ql-align")) { + if (select.querySelector("option") == null) { + fillSelect(select, ALIGNS); + } + return new _iconPicker2.default(select, _icons2.default.align); + } else if ( + select.classList.contains("ql-background") || + select.classList.contains("ql-color") + ) { + var format = select.classList.contains("ql-background") + ? "background" + : "color"; + if (select.querySelector("option") == null) { + fillSelect(select, COLORS, format === "background" ? "#ffffff" : "#000000"); + } + return new _colorPicker2.default(select, _icons2.default[format]); + } else { + if (select.querySelector("option") == null) { + if (select.classList.contains("ql-font")) { + fillSelect(select, FONTS); + } else if (select.classList.contains("ql-header")) { + fillSelect(select, HEADERS); + } else if (select.classList.contains("ql-size")) { + fillSelect(select, SIZES); + } + } + return new _picker2.default(select); + } + }); + var update = function update() { + _this2.pickers.forEach(function(picker) { + picker.update(); + }); + }; + this.quill + .on(_emitter2.default.events.SELECTION_CHANGE, update) + .on(_emitter2.default.events.SCROLL_OPTIMIZE, update); + } + } + ]); + + return BaseTheme; + })(_theme2.default); + + BaseTheme.DEFAULTS = (0, _extend2.default)(true, {}, _theme2.default.DEFAULTS, { + modules: { + toolbar: { + handlers: { + formula: function formula(value) { + this.quill.theme.tooltip.edit("formula"); + }, + image: function image(value) { + var _this3 = this; + + var fileInput = this.container.querySelector("input.ql-image[type=file]"); + if (fileInput == null) { + fileInput = document.createElement("input"); + fileInput.setAttribute("type", "file"); + fileInput.setAttribute("accept", "image/*"); + fileInput.classList.add("ql-image"); + fileInput.addEventListener("change", function() { + if (fileInput.files != null && fileInput.files[0] != null) { + var reader = new FileReader(); + reader.onload = function(e) { + var range = _this3.quill.getSelection(true); + _this3.quill.updateContents( + new _delta2.default() + .retain(range.index) + .delete(range.length) + .insert({ image: e.target.result }), + _emitter2.default.sources.USER + ); + fileInput.value = ""; + }; + reader.readAsDataURL(fileInput.files[0]); + } + }); + this.container.appendChild(fileInput); + } + fileInput.click(); + }, + video: function video(value) { + this.quill.theme.tooltip.edit("video"); + } + } + } + } + }); + + var BaseTooltip = (function(_Tooltip) { + _inherits(BaseTooltip, _Tooltip); + + function BaseTooltip(quill, boundsContainer) { + _classCallCheck(this, BaseTooltip); + + var _this4 = _possibleConstructorReturn( + this, + (BaseTooltip.__proto__ || Object.getPrototypeOf(BaseTooltip)).call( + this, + quill, + boundsContainer + ) + ); + + _this4.textbox = _this4.root.querySelector('input[type="text"]'); + _this4.listen(); + return _this4; + } + + _createClass(BaseTooltip, [ + { + key: "listen", + value: function listen() { + var _this5 = this; + + this.textbox.addEventListener("keydown", function(event) { + if (_keyboard2.default.match(event, "enter")) { + _this5.save(); + event.preventDefault(); + } else if (_keyboard2.default.match(event, "escape")) { + _this5.cancel(); + event.preventDefault(); + } + }); + } + }, + { + key: "cancel", + value: function cancel() { + this.hide(); + } + }, + { + key: "edit", + value: function edit() { + var mode = + arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : "link"; + var preview = + arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null; + + this.root.classList.remove("ql-hidden"); + this.root.classList.add("ql-editing"); + if (preview != null) { + this.textbox.value = preview; + } else if (mode !== this.root.getAttribute("data-mode")) { + this.textbox.value = ""; + } + this.position(this.quill.getBounds(this.quill.selection.savedRange)); + this.textbox.select(); + this.textbox.setAttribute( + "placeholder", + this.textbox.getAttribute("data-" + mode) || "" + ); + this.root.setAttribute("data-mode", mode); + } + }, + { + key: "restoreFocus", + value: function restoreFocus() { + var scrollTop = this.quill.root.scrollTop; + this.quill.focus(); + this.quill.root.scrollTop = scrollTop; + } + }, + { + key: "save", + value: function save() { + var value = this.textbox.value; + switch (this.root.getAttribute("data-mode")) { + case "link": + var scrollTop = this.quill.root.scrollTop; + if (this.linkRange) { + this.quill.formatText( + this.linkRange, + "link", + value, + _emitter2.default.sources.USER + ); + delete this.linkRange; + } else { + this.restoreFocus(); + this.quill.format("link", value, _emitter2.default.sources.USER); + } + this.quill.root.scrollTop = scrollTop; + break; + case "video": + var match = + value.match( + /^(https?):\/\/(www\.)?youtube\.com\/watch.*v=([a-zA-Z0-9_-]+)/ + ) || value.match(/^(https?):\/\/(www\.)?youtu\.be\/([a-zA-Z0-9_-]+)/); + if (match) { + value = match[1] + "://www.youtube.com/embed/" + match[3] + "?showinfo=0"; + } else if ((match = value.match(/^(https?):\/\/(www\.)?vimeo\.com\/(\d+)/))) { + value = match[1] + "://player.vimeo.com/video/" + match[3] + "/"; + } + // fallthrough + case "formula": + var range = this.quill.getSelection(true); + var index = range.index + range.length; + if (range != null) { + this.quill.insertEmbed( + index, + this.root.getAttribute("data-mode"), + value, + _emitter2.default.sources.USER + ); + if (this.root.getAttribute("data-mode") === "formula") { + this.quill.insertText(index + 1, " ", _emitter2.default.sources.USER); + } + this.quill.setSelection(index + 2, _emitter2.default.sources.USER); + } + break; + default: + } + this.textbox.value = ""; + this.hide(); + } + } + ]); + + return BaseTooltip; + })(_tooltip2.default); + + function fillSelect(select, values) { + var defaultValue = + arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false; + + values.forEach(function(value) { + var option = document.createElement("option"); + if (value === defaultValue) { + option.setAttribute("selected", "selected"); + } else { + option.setAttribute("value", value); + } + select.appendChild(option); + }); + } + + exports.BaseTooltip = BaseTooltip; + exports.default = BaseTheme; + + /***/ + }, + /* 108 */ + /***/ function(module, exports, __webpack_require__) { + "use strict"; + + Object.defineProperty(exports, "__esModule", { + value: true + }); + + var _slicedToArray = (function() { + function sliceIterator(arr, i) { + var _arr = []; + var _n = true; + var _d = false; + var _e = undefined; + try { + for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { + _arr.push(_s.value); + if (i && _arr.length === i) break; + } + } catch (err) { + _d = true; + _e = err; + } finally { + try { + if (!_n && _i["return"]) _i["return"](); + } finally { + if (_d) throw _e; + } + } + return _arr; + } + return function(arr, i) { + if (Array.isArray(arr)) { + return arr; + } else if (Symbol.iterator in Object(arr)) { + return sliceIterator(arr, i); + } else { + throw new TypeError("Invalid attempt to destructure non-iterable instance"); + } + }; + })(); + + var _get = function get(object, property, receiver) { + if (object === null) object = Function.prototype; + var desc = Object.getOwnPropertyDescriptor(object, property); + if (desc === undefined) { + var parent = Object.getPrototypeOf(object); + if (parent === null) { + return undefined; + } else { + return get(parent, property, receiver); + } + } else if ("value" in desc) { + return desc.value; + } else { + var getter = desc.get; + if (getter === undefined) { + return undefined; + } + return getter.call(receiver); + } + }; + + var _createClass = (function() { + function defineProperties(target, props) { + for (var i = 0; i < props.length; i++) { + var descriptor = props[i]; + descriptor.enumerable = descriptor.enumerable || false; + descriptor.configurable = true; + if ("value" in descriptor) descriptor.writable = true; + Object.defineProperty(target, descriptor.key, descriptor); + } + } + return function(Constructor, protoProps, staticProps) { + if (protoProps) defineProperties(Constructor.prototype, protoProps); + if (staticProps) defineProperties(Constructor, staticProps); + return Constructor; + }; + })(); + + var _extend = __webpack_require__(25); + + var _extend2 = _interopRequireDefault(_extend); + + var _emitter = __webpack_require__(28); + + var _emitter2 = _interopRequireDefault(_emitter); + + var _base = __webpack_require__(107); + + var _base2 = _interopRequireDefault(_base); + + var _link = __webpack_require__(60); + + var _link2 = _interopRequireDefault(_link); + + var _picker = __webpack_require__(101); + + var _picker2 = _interopRequireDefault(_picker); + + var _selection = __webpack_require__(40); + + function _interopRequireDefault(obj) { + return obj && obj.__esModule ? obj : { default: obj }; + } + + function _classCallCheck(instance, Constructor) { + if (!(instance instanceof Constructor)) { + throw new TypeError("Cannot call a class as a function"); + } + } + + function _possibleConstructorReturn(self, call) { + if (!self) { + throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); + } + return call && (typeof call === "object" || typeof call === "function") ? call : self; + } + + function _inherits(subClass, superClass) { + if (typeof superClass !== "function" && superClass !== null) { + throw new TypeError( + "Super expression must either be null or a function, not " + typeof superClass + ); + } + subClass.prototype = Object.create(superClass && superClass.prototype, { + constructor: { value: subClass, enumerable: false, writable: true, configurable: true } + }); + if (superClass) + Object.setPrototypeOf + ? Object.setPrototypeOf(subClass, superClass) + : (subClass.__proto__ = superClass); + } + + var TOOLBAR_CONFIG = [ + [{ header: ["1", "2", "3", false] }], + ["bold", "italic", "underline", "link"], + [{ list: "ordered" }, { list: "bullet" }], + ["clean"] + ]; + + var SnowTheme = (function(_BaseTheme) { + _inherits(SnowTheme, _BaseTheme); + + function SnowTheme(quill, options) { + _classCallCheck(this, SnowTheme); + + if (options.modules.toolbar != null && options.modules.toolbar.container == null) { + options.modules.toolbar.container = TOOLBAR_CONFIG; + } + + var _this = _possibleConstructorReturn( + this, + (SnowTheme.__proto__ || Object.getPrototypeOf(SnowTheme)).call(this, quill, options) + ); + + _this.quill.container.classList.add("ql-snow"); + return _this; + } + + _createClass(SnowTheme, [ + { + key: "extendToolbar", + value: function extendToolbar(toolbar) { + toolbar.container.classList.add("ql-snow"); + this.buildButtons([].slice.call(toolbar.container.querySelectorAll("button"))); + this.buildPickers([].slice.call(toolbar.container.querySelectorAll("select"))); + this.tooltip = new SnowTooltip(this.quill, this.options.bounds); + if (toolbar.container.querySelector(".ql-link")) { + this.quill.keyboard.addBinding({ key: "K", shortKey: true }, function( + range, + context + ) { + toolbar.handlers["link"].call(toolbar, !context.format.link); + }); + } + } + } + ]); + + return SnowTheme; + })(_base2.default); + + SnowTheme.DEFAULTS = (0, _extend2.default)(true, {}, _base2.default.DEFAULTS, { + modules: { + toolbar: { + handlers: { + link: function link(value) { + if (value) { + var range = this.quill.getSelection(); + if (range == null || range.length == 0) return; + var preview = this.quill.getText(range); + if (/^\S+@\S+\.\S+$/.test(preview) && preview.indexOf("mailto:") !== 0) { + preview = "mailto:" + preview; + } + var tooltip = this.quill.theme.tooltip; + tooltip.edit("link", preview); + } else { + this.quill.format("link", false); + } + } + } + } + } + }); + + var SnowTooltip = (function(_BaseTooltip) { + _inherits(SnowTooltip, _BaseTooltip); + + function SnowTooltip(quill, bounds) { + _classCallCheck(this, SnowTooltip); + + var _this2 = _possibleConstructorReturn( + this, + (SnowTooltip.__proto__ || Object.getPrototypeOf(SnowTooltip)).call( + this, + quill, + bounds + ) + ); + + _this2.preview = _this2.root.querySelector("a.ql-preview"); + return _this2; + } + + _createClass(SnowTooltip, [ + { + key: "listen", + value: function listen() { + var _this3 = this; + + _get( + SnowTooltip.prototype.__proto__ || Object.getPrototypeOf(SnowTooltip.prototype), + "listen", + this + ).call(this); + this.root.querySelector("a.ql-action").addEventListener("click", function(event) { + if (_this3.root.classList.contains("ql-editing")) { + _this3.save(); + } else { + _this3.edit("link", _this3.preview.textContent); + } + event.preventDefault(); + }); + this.root.querySelector("a.ql-remove").addEventListener("click", function(event) { + if (_this3.linkRange != null) { + _this3.restoreFocus(); + _this3.quill.formatText( + _this3.linkRange, + "link", + false, + _emitter2.default.sources.USER + ); + delete _this3.linkRange; + } + event.preventDefault(); + _this3.hide(); + }); + this.quill.on(_emitter2.default.events.SELECTION_CHANGE, function(range) { + if (range == null) return; + if (range.length === 0) { + var _quill$scroll$descend = _this3.quill.scroll.descendant( + _link2.default, + range.index + ); + + var _quill$scroll$descend2 = _slicedToArray(_quill$scroll$descend, 2); + + var link = _quill$scroll$descend2[0]; + var offset = _quill$scroll$descend2[1]; + + if (link != null) { + _this3.linkRange = new _selection.Range(range.index - offset, link.length()); + var preview = _link2.default.formats(link.domNode); + _this3.preview.textContent = preview; + _this3.preview.setAttribute("href", preview); + _this3.show(); + _this3.position(_this3.quill.getBounds(_this3.linkRange)); + return; + } + } + _this3.hide(); + }); + } + }, + { + key: "show", + value: function show() { + _get( + SnowTooltip.prototype.__proto__ || Object.getPrototypeOf(SnowTooltip.prototype), + "show", + this + ).call(this); + this.root.removeAttribute("data-mode"); + } + } + ]); + + return SnowTooltip; + })(_base.BaseTooltip); + + SnowTooltip.TEMPLATE = [ + '', + '', + '', + '' + ].join(""); + + exports.default = SnowTheme; + + /***/ + } + /******/ + ] + ); +}); diff --git a/client/templates/main.js b/imports/ui/main.js similarity index 87% rename from client/templates/main.js rename to imports/ui/main.js index ec4b330c..f2ac6ff5 100644 --- a/client/templates/main.js +++ b/imports/ui/main.js @@ -1,8 +1,12 @@ +import "./components/home/home"; +import "./components/nav/header"; +import "./components/other/has_blocked"; +import "./components/home/home_logged_out"; +import "./layouts/layout"; +import "./css/style.scss"; if (Meteor.isClient) { Meteor.startup(function() { - $("head").append( - '' - ); + $("head").append(''); if (!Meteor.settings.public.isModeDebug) { console = console || {}; @@ -11,16 +15,13 @@ if (Meteor.isClient) { const defaultLang = "en"; const localStorageLang = localStorage.getItem("languageCode"); - const browserLang = ( - window.navigator.userLanguage || - window.navigator.language || - "" - ).slice(0, 2); + const browserLang = (window.navigator.userLanguage || window.navigator.language || "").slice( + 0, + 2 + ); TAPi18n.setLanguage(localStorageLang || browserLang || defaultLang) .fail(console.log) - .always(() => - localStorage.setItem("languageCode", TAPi18n.getLanguage()) - ); + .always(() => localStorage.setItem("languageCode", TAPi18n.getLanguage())); }); } @@ -135,17 +136,12 @@ Template.registerHelper("isHangoutEndTimeTBA", function(start, end) { Template.registerHelper("isOwnerOfTheGroup", function(userId, groupId) { const loggedInUserId = Meteor.userId(); - return loggedInUserId !== userId && - Roles.userIsInRole(loggedInUserId, ["owner"], groupId) + return loggedInUserId !== userId && Roles.userIsInRole(loggedInUserId, ["owner"], groupId) ? true : false; }); -Template.registerHelper("canUpdateUserRoleForGroup", function( - subjectId, - groupId, - subjectRole -) { +Template.registerHelper("canUpdateUserRoleForGroup", function(subjectId, groupId, subjectRole) { const loggedInUserId = Meteor.userId(); return loggedInUserId !== subjectId &&