From 5b7ee3f75c01524265f7eefdac90bdb3fa83a67a Mon Sep 17 00:00:00 2001 From: simialbi Date: Fri, 15 May 2020 14:40:30 +0200 Subject: [PATCH 1/3] started to add toolbar button for better table --- .gitignore | 2 + dist/demo/demo1.html | 2 +- dist/demo/demo1.js | 12455 ++++++++++++++++++++++----- dist/quill-better-table.css | 19 +- dist/quill-better-table.js | 11707 +++++++++++++++++++++---- package.json | 7 +- src/assets/quill-better-table.scss | 26 + src/quill-better-table.js | 21 + src/themes/better-table-snow.js | 32 + src/ui/table-picker.js | 51 + 10 files changed, 20450 insertions(+), 3872 deletions(-) create mode 100644 src/themes/better-table-snow.js create mode 100644 src/ui/table-picker.js diff --git a/.gitignore b/.gitignore index a1e6638..d260fdb 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,6 @@ node_modules +.idea +*.iml *.lock *-lock.json .DS_Store diff --git a/dist/demo/demo1.html b/dist/demo/demo1.html index 44a2567..aea00ea 100644 --- a/dist/demo/demo1.html +++ b/dist/demo/demo1.html @@ -1 +1 @@ - Document

quill-better-table demo

\ No newline at end of file + Document

quill-better-table demo

\ No newline at end of file diff --git a/dist/demo/demo1.js b/dist/demo/demo1.js index 6ef2322..f5ec1a2 100644 --- a/dist/demo/demo1.js +++ b/dist/demo/demo1.js @@ -73,7 +73,7 @@ return /******/ (function(modules) { // webpackBootstrap /******/ /******/ var hotApplyOnUpdate = true; /******/ // eslint-disable-next-line no-unused-vars -/******/ var hotCurrentHash = "b2ee69a9ed01aab8434c"; +/******/ var hotCurrentHash = "111370371cf15dc7774e"; /******/ var hotRequestTimeout = 10000; /******/ var hotCurrentModuleData = {}; /******/ var hotCurrentChildModule; @@ -166,6 +166,7 @@ return /******/ (function(modules) { // webpackBootstrap /******/ _declinedDependencies: {}, /******/ _selfAccepted: false, /******/ _selfDeclined: false, +/******/ _selfInvalidated: false, /******/ _disposeHandlers: [], /******/ _main: hotCurrentChildModule !== moduleId, /******/ @@ -196,6 +197,29 @@ return /******/ (function(modules) { // webpackBootstrap /******/ var idx = hot._disposeHandlers.indexOf(callback); /******/ if (idx >= 0) hot._disposeHandlers.splice(idx, 1); /******/ }, +/******/ invalidate: function() { +/******/ this._selfInvalidated = true; +/******/ switch (hotStatus) { +/******/ case "idle": +/******/ hotUpdate = {}; +/******/ hotUpdate[moduleId] = modules[moduleId]; +/******/ hotSetStatus("ready"); +/******/ break; +/******/ case "ready": +/******/ hotApplyInvalidatedModule(moduleId); +/******/ break; +/******/ case "prepare": +/******/ case "check": +/******/ case "dispose": +/******/ case "apply": +/******/ (hotQueuedInvalidatedModules = +/******/ hotQueuedInvalidatedModules || []).push(moduleId); +/******/ break; +/******/ default: +/******/ // ignore requests in error states +/******/ break; +/******/ } +/******/ }, /******/ /******/ // Management API /******/ check: hotCheck, @@ -237,7 +261,7 @@ return /******/ (function(modules) { // webpackBootstrap /******/ var hotDeferred; /******/ /******/ // The update info -/******/ var hotUpdate, hotUpdateNewHash; +/******/ var hotUpdate, hotUpdateNewHash, hotQueuedInvalidatedModules; /******/ /******/ function toModuleId(id) { /******/ var isNumber = +id + "" === id; @@ -252,7 +276,7 @@ return /******/ (function(modules) { // webpackBootstrap /******/ hotSetStatus("check"); /******/ return hotDownloadManifest(hotRequestTimeout).then(function(update) { /******/ if (!update) { -/******/ hotSetStatus("idle"); +/******/ hotSetStatus(hotApplyInvalidatedModules() ? "ready" : "idle"); /******/ return null; /******/ } /******/ hotRequestedFilesMap = {}; @@ -271,7 +295,6 @@ return /******/ (function(modules) { // webpackBootstrap /******/ var chunkId = 0; /******/ // eslint-disable-next-line no-lone-blocks /******/ { -/******/ /*globals chunkId */ /******/ hotEnsureUpdateChunk(chunkId); /******/ } /******/ if ( @@ -346,6 +369,11 @@ return /******/ (function(modules) { // webpackBootstrap /******/ if (hotStatus !== "ready") /******/ throw new Error("apply() is only allowed in ready status"); /******/ options = options || {}; +/******/ return hotApplyInternal(options); +/******/ } +/******/ +/******/ function hotApplyInternal(options) { +/******/ hotApplyInvalidatedModules(); /******/ /******/ var cb; /******/ var i; @@ -368,7 +396,11 @@ return /******/ (function(modules) { // webpackBootstrap /******/ var moduleId = queueItem.id; /******/ var chain = queueItem.chain; /******/ module = installedModules[moduleId]; -/******/ if (!module || module.hot._selfAccepted) continue; +/******/ if ( +/******/ !module || +/******/ (module.hot._selfAccepted && !module.hot._selfInvalidated) +/******/ ) +/******/ continue; /******/ if (module.hot._selfDeclined) { /******/ return { /******/ type: "self-declined", @@ -536,10 +568,13 @@ return /******/ (function(modules) { // webpackBootstrap /******/ installedModules[moduleId] && /******/ installedModules[moduleId].hot._selfAccepted && /******/ // removed self-accepted modules should not be required -/******/ appliedUpdate[moduleId] !== warnUnexpectedRequire +/******/ appliedUpdate[moduleId] !== warnUnexpectedRequire && +/******/ // when called invalidate self-accepting is not possible +/******/ !installedModules[moduleId].hot._selfInvalidated /******/ ) { /******/ outdatedSelfAcceptedModules.push({ /******/ module: moduleId, +/******/ parents: installedModules[moduleId].parents.slice(), /******/ errorHandler: installedModules[moduleId].hot._selfAccepted /******/ }); /******/ } @@ -612,7 +647,11 @@ return /******/ (function(modules) { // webpackBootstrap /******/ // Now in "apply" phase /******/ hotSetStatus("apply"); /******/ -/******/ hotCurrentHash = hotUpdateNewHash; +/******/ if (hotUpdateNewHash !== undefined) { +/******/ hotCurrentHash = hotUpdateNewHash; +/******/ hotUpdateNewHash = undefined; +/******/ } +/******/ hotUpdate = undefined; /******/ /******/ // insert new code /******/ for (moduleId in appliedUpdate) { @@ -665,7 +704,8 @@ return /******/ (function(modules) { // webpackBootstrap /******/ for (i = 0; i < outdatedSelfAcceptedModules.length; i++) { /******/ var item = outdatedSelfAcceptedModules[i]; /******/ moduleId = item.module; -/******/ hotCurrentParents = [moduleId]; +/******/ hotCurrentParents = item.parents; +/******/ hotCurrentChildModule = moduleId; /******/ try { /******/ __webpack_require__(moduleId); /******/ } catch (err) { @@ -707,12 +747,35 @@ return /******/ (function(modules) { // webpackBootstrap /******/ return Promise.reject(error); /******/ } /******/ +/******/ if (hotQueuedInvalidatedModules) { +/******/ return hotApplyInternal(options).then(function(list) { +/******/ outdatedModules.forEach(function(moduleId) { +/******/ if (list.indexOf(moduleId) < 0) list.push(moduleId); +/******/ }); +/******/ return list; +/******/ }); +/******/ } +/******/ /******/ hotSetStatus("idle"); /******/ return new Promise(function(resolve) { /******/ resolve(outdatedModules); /******/ }); /******/ } /******/ +/******/ function hotApplyInvalidatedModules() { +/******/ if (hotQueuedInvalidatedModules) { +/******/ if (!hotUpdate) hotUpdate = {}; +/******/ hotQueuedInvalidatedModules.forEach(hotApplyInvalidatedModule); +/******/ hotQueuedInvalidatedModules = undefined; +/******/ return true; +/******/ } +/******/ } +/******/ +/******/ function hotApplyInvalidatedModule(moduleId) { +/******/ if (!Object.prototype.hasOwnProperty.call(hotUpdate, moduleId)) +/******/ hotUpdate[moduleId] = modules[moduleId]; +/******/ } +/******/ /******/ // The module cache /******/ var installedModules = {}; /******/ @@ -801,7 +864,7 @@ return /******/ (function(modules) { // webpackBootstrap /******/ /******/ /******/ // Load entry module and return exports -/******/ return hotCreateRequire(13)(__webpack_require__.s = 13); +/******/ return hotCreateRequire(108)(__webpack_require__.s = 108); /******/ }) /************************************************************************/ /******/ ([ @@ -812,1127 +875,3388 @@ module.exports = __WEBPACK_EXTERNAL_MODULE__0__; /***/ }), /* 1 */ -/***/ (function(module, exports) { +/***/ (function(module, exports, __webpack_require__) { -module.exports = ""; +!function(t,e){ true?module.exports=e():undefined}(window,(function(){return function(t){var e={};function s(i){if(e[i])return e[i].exports;var r=e[i]={i:i,l:!1,exports:{}};return t[i].call(r.exports,r,r.exports,s),r.l=!0,r.exports}return s.m=t,s.c=e,s.d=function(t,e,i){s.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:i})},s.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},s.t=function(t,e){if(1&e&&(t=s(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var i=Object.create(null);if(s.r(i),Object.defineProperty(i,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var r in t)s.d(i,r,function(e){return t[e]}.bind(null,r));return i},s.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return s.d(e,"a",e),e},s.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},s.p="",s(s.s=0)}([function(t,e,s){t.exports=s(1)},function(t,e,s){"use strict";var i;s.r(e),s.d(e,"ParentBlot",(function(){return u})),s.d(e,"ContainerBlot",(function(){return p})),s.d(e,"LeafBlot",(function(){return N})),s.d(e,"EmbedBlot",(function(){return L})),s.d(e,"ScrollBlot",(function(){return I})),s.d(e,"BlockBlot",(function(){return C})),s.d(e,"InlineBlot",(function(){return T})),s.d(e,"TextBlot",(function(){return _})),s.d(e,"Attributor",(function(){return b})),s.d(e,"ClassAttributor",(function(){return v})),s.d(e,"StyleAttributor",(function(){return A})),s.d(e,"AttributorStore",(function(){return x})),s.d(e,"Registry",(function(){return a})),s.d(e,"Scope",(function(){return r})),function(t){t[t.TYPE=3]="TYPE",t[t.LEVEL=12]="LEVEL",t[t.ATTRIBUTE=13]="ATTRIBUTE",t[t.BLOT=14]="BLOT",t[t.INLINE=7]="INLINE",t[t.BLOCK=11]="BLOCK",t[t.BLOCK_BLOT=10]="BLOCK_BLOT",t[t.INLINE_BLOT=6]="INLINE_BLOT",t[t.BLOCK_ATTRIBUTE=9]="BLOCK_ATTRIBUTE",t[t.INLINE_ATTRIBUTE=5]="INLINE_ATTRIBUTE",t[t.ANY=15]="ANY"}(i||(i={}));var r=i;var n=class{constructor(){this.head=null,this.tail=null,this.length=0}append(...t){if(this.insertBefore(t[0],null),t.length>1){const e=t.slice(1);this.append(...e)}}at(t){const e=this.iterator();let s=e();for(;s&&t>0;)t-=1,s=e();return s}contains(t){const e=this.iterator();let s=e();for(;s;){if(s===t)return!0;s=e()}return!1}indexOf(t){const e=this.iterator();let s=e(),i=0;for(;s;){if(s===t)return i;i+=1,s=e()}return-1}insertBefore(t,e){null!=t&&(this.remove(t),t.next=e,null!=e?(t.prev=e.prev,null!=e.prev&&(e.prev.next=t),e.prev=t,e===this.head&&(this.head=t)):null!=this.tail?(this.tail.next=t,t.prev=this.tail,this.tail=t):(t.prev=null,this.head=this.tail=t),this.length+=1)}offset(t){let e=0,s=this.head;for(;null!=s;){if(s===t)return e;e+=s.length(),s=s.next}return-1}remove(t){this.contains(t)&&(null!=t.prev&&(t.prev.next=t.next),null!=t.next&&(t.next.prev=t.prev),t===this.head&&(this.head=t.next),t===this.tail&&(this.tail=t.prev),this.length-=1)}iterator(t=this.head){return()=>{const e=t;return null!=t&&(t=t.next),e}}find(t,e=!1){const s=this.iterator();let i=s();for(;i;){const r=i.length();if(tn?s(a,t-n,Math.min(e,n+i-t)):s(a,0,Math.min(i,t+e-n)),n+=i,a=o()}}map(t){return this.reduce((e,s)=>(e.push(t(s)),e),[])}reduce(t,e){const s=this.iterator();let i=s();for(;i;)e=t(e,i),i=s();return e}};class o extends Error{constructor(t){super(t="[Parchment] "+t),this.message=t,this.name=this.constructor.name}}class a{constructor(){this.attributes={},this.classes={},this.tags={},this.types={}}static find(t,e=!1){return null==t?null:this.blots.has(t)?this.blots.get(t)||null:e?this.find(t.parentNode,e):null}create(t,e,s){const i=this.query(e);if(null==i)throw new o(`Unable to create ${e} blot`);const r=i,n=e instanceof Node||e.nodeType===Node.TEXT_NODE?e:r.create(s),l=new r(t,n,s);return a.blots.set(l.domNode,l),l}find(t,e=!1){return a.find(t,e)}query(t,e=r.ANY){let s;if("string"==typeof t)s=this.types[t]||this.attributes[t];else if(t instanceof Text||t.nodeType===Node.TEXT_NODE)s=this.types.text;else if("number"==typeof t)t&r.LEVEL&r.BLOCK?s=this.types.block:t&r.LEVEL&r.INLINE&&(s=this.types.inline);else if(t instanceof HTMLElement){(t.getAttribute("class")||"").split(/\s+/).some(t=>(s=this.classes[t],!!s)),s=s||this.tags[t.tagName]}return null==s?null:e&r.LEVEL&s.scope&&e&r.TYPE&s.scope?s:null}register(...t){if(t.length>1)return t.map(t=>this.register(t));const e=t[0];if("string"!=typeof e.blotName&&"string"!=typeof e.attrName)throw new o("Invalid definition");if("abstract"===e.blotName)throw new o("Cannot register abstract class");if(this.types[e.blotName||e.attrName]=e,"string"==typeof e.keyName)this.attributes[e.keyName]=e;else if(null!=e.className&&(this.classes[e.className]=e),null!=e.tagName){Array.isArray(e.tagName)?e.tagName=e.tagName.map(t=>t.toUpperCase()):e.tagName=e.tagName.toUpperCase(),(Array.isArray(e.tagName)?e.tagName:[e.tagName]).forEach(t=>{null!=this.tags[t]&&null!=e.className||(this.tags[t]=e)})}return e}}a.blots=new WeakMap;class l{constructor(t,e){this.scroll=t,this.domNode=e,a.blots.set(e,this),this.prev=null,this.next=null}static create(t){if(null==this.tagName)throw new o("Blot definition missing tagName");let e;return Array.isArray(this.tagName)?("string"==typeof t&&(t=t.toUpperCase(),parseInt(t,10).toString()===t&&(t=parseInt(t,10))),e="number"==typeof t?document.createElement(this.tagName[t-1]):this.tagName.indexOf(t)>-1?document.createElement(t):document.createElement(this.tagName[0])):e=document.createElement(this.tagName),this.className&&e.classList.add(this.className),e}get statics(){return this.constructor}attach(){}clone(){const t=this.domNode.cloneNode(!1);return this.scroll.create(t)}detach(){null!=this.parent&&this.parent.removeChild(this),a.blots.delete(this.domNode)}deleteAt(t,e){this.isolate(t,e).remove()}formatAt(t,e,s,i){const n=this.isolate(t,e);if(null!=this.scroll.query(s,r.BLOT)&&i)n.wrap(s,i);else if(null!=this.scroll.query(s,r.ATTRIBUTE)){const t=this.scroll.create(this.statics.scope);n.wrap(t),t.format(s,i)}}insertAt(t,e,s){const i=null==s?this.scroll.create("text",e):this.scroll.create(e,s),r=this.split(t);this.parent.insertBefore(i,r||void 0)}isolate(t,e){const s=this.split(t);if(null==s)throw new Error("Attempt to isolate at end");return s.split(e),s}length(){return 1}offset(t=this.parent){return null==this.parent||this===t?0:this.parent.children.offset(this)+this.parent.offset(t)}optimize(t){!this.statics.requiredContainer||this.parent instanceof this.statics.requiredContainer||this.wrap(this.statics.requiredContainer.blotName)}remove(){null!=this.domNode.parentNode&&this.domNode.parentNode.removeChild(this.domNode),this.detach()}replaceWith(t,e){const s="string"==typeof t?this.scroll.create(t,e):t;return null!=this.parent&&(this.parent.insertBefore(s,this.next||void 0),this.remove()),s}split(t,e){return 0===t?this:this.next}update(t,e){}wrap(t,e){const s="string"==typeof t?this.scroll.create(t,e):t;if(null!=this.parent&&this.parent.insertBefore(s,this.next||void 0),"function"!=typeof s.appendChild)throw new o(`Cannot wrap ${t}`);return s.appendChild(this),s}}l.blotName="abstract";var h=l;function c(t,e){let s=e.find(t);if(null==s)try{s=e.create(t)}catch(i){s=e.create(r.INLINE),Array.from(t.childNodes).forEach(t=>{s.domNode.appendChild(t)}),t.parentNode&&t.parentNode.replaceChild(s.domNode,t),s.attach()}return s}class d extends h{constructor(t,e){super(t,e),this.uiNode=null,this.build()}appendChild(t){this.insertBefore(t)}attach(){super.attach(),this.children.forEach(t=>{t.attach()})}attachUI(t){null!=this.uiNode&&this.uiNode.remove(),this.uiNode=t,d.uiClass&&this.uiNode.classList.add(d.uiClass),this.uiNode.setAttribute("contenteditable","false"),this.domNode.insertBefore(this.uiNode,this.domNode.firstChild)}build(){this.children=new n,Array.from(this.domNode.childNodes).filter(t=>t!==this.uiNode).reverse().forEach(t=>{try{const e=c(t,this.scroll);this.insertBefore(e,this.children.head||void 0)}catch(t){if(t instanceof o)return;throw t}})}deleteAt(t,e){if(0===t&&e===this.length())return this.remove();this.children.forEachAt(t,e,(t,e,s)=>{t.deleteAt(e,s)})}descendant(t,e=0){const[s,i]=this.children.find(e);return null==t.blotName&&t(s)||null!=t.blotName&&s instanceof t?[s,i]:s instanceof d?s.descendant(t,i):[null,-1]}descendants(t,e=0,s=Number.MAX_VALUE){let i=[],r=s;return this.children.forEachAt(e,s,(e,s,n)=>{(null==t.blotName&&t(e)||null!=t.blotName&&e instanceof t)&&i.push(e),e instanceof d&&(i=i.concat(e.descendants(t,s,r))),r-=n}),i}detach(){this.children.forEach(t=>{t.detach()}),super.detach()}enforceAllowedChildren(){let t=!1;this.children.forEach(e=>{if(t)return;this.statics.allowedChildren.some(t=>e instanceof t)||(e.statics.scope===r.BLOCK_BLOT?(null!=e.next&&this.splitAfter(e),null!=e.prev&&this.splitAfter(e.prev),e.parent.unwrap(),t=!0):e instanceof d?e.unwrap():e.remove())})}formatAt(t,e,s,i){this.children.forEachAt(t,e,(t,e,r)=>{t.formatAt(e,r,s,i)})}insertAt(t,e,s){const[i,r]=this.children.find(t);if(i)i.insertAt(r,e,s);else{const t=null==s?this.scroll.create("text",e):this.scroll.create(e,s);this.appendChild(t)}}insertBefore(t,e){null!=t.parent&&t.parent.children.remove(t);let s=null;this.children.insertBefore(t,e||null),t.parent=this,null!=e&&(s=e.domNode),this.domNode.parentNode===t.domNode&&this.domNode.nextSibling===s||this.domNode.insertBefore(t.domNode,s),t.attach()}length(){return this.children.reduce((t,e)=>t+e.length(),0)}moveChildren(t,e){this.children.forEach(s=>{t.insertBefore(s,e)})}optimize(t){if(super.optimize(t),this.enforceAllowedChildren(),null!=this.uiNode&&this.uiNode!==this.domNode.firstChild&&this.domNode.insertBefore(this.uiNode,this.domNode.firstChild),0===this.children.length)if(null!=this.statics.defaultChild){const t=this.scroll.create(this.statics.defaultChild.blotName);this.appendChild(t)}else this.remove()}path(t,e=!1){const[s,i]=this.children.find(t,e),r=[[this,t]];return s instanceof d?r.concat(s.path(i,e)):(null!=s&&r.push([s,i]),r)}removeChild(t){this.children.remove(t)}replaceWith(t,e){const s="string"==typeof t?this.scroll.create(t,e):t;return s instanceof d&&this.moveChildren(s),super.replaceWith(s)}split(t,e=!1){if(!e){if(0===t)return this;if(t===this.length())return this.next}const s=this.clone();return this.parent&&this.parent.insertBefore(s,this.next||void 0),this.children.forEachAt(t,this.length(),(t,i,r)=>{const n=t.split(i,e);null!=n&&s.appendChild(n)}),s}splitAfter(t){const e=this.clone();for(;null!=t.next;)e.appendChild(t.next);return this.parent&&this.parent.insertBefore(e,this.next||void 0),e}unwrap(){this.parent&&this.moveChildren(this.parent,this.next||void 0),this.remove()}update(t,e){const s=[],i=[];t.forEach(t=>{t.target===this.domNode&&"childList"===t.type&&(s.push(...t.addedNodes),i.push(...t.removedNodes))}),i.forEach(t=>{if(null!=t.parentNode&&"IFRAME"!==t.tagName&&document.body.compareDocumentPosition(t)&Node.DOCUMENT_POSITION_CONTAINED_BY)return;const e=this.scroll.find(t);null!=e&&(null!=e.domNode.parentNode&&e.domNode.parentNode!==this.domNode||e.detach())}),s.filter(t=>t.parentNode===this.domNode||t===this.uiNode).sort((t,e)=>t===e?0:t.compareDocumentPosition(e)&Node.DOCUMENT_POSITION_FOLLOWING?1:-1).forEach(t=>{let e=null;null!=t.nextSibling&&(e=this.scroll.find(t.nextSibling));const s=c(t,this.scroll);s.next===e&&null!=s.next||(null!=s.parent&&s.parent.removeChild(this),this.insertBefore(s,e||void 0))}),this.enforceAllowedChildren()}}d.uiClass="";var u=d;class m extends u{checkMerge(){return null!==this.next&&this.next.statics.blotName===this.statics.blotName}deleteAt(t,e){super.deleteAt(t,e),this.enforceAllowedChildren()}formatAt(t,e,s,i){super.formatAt(t,e,s,i),this.enforceAllowedChildren()}insertAt(t,e,s){super.insertAt(t,e,s),this.enforceAllowedChildren()}optimize(t){super.optimize(t),this.children.length>0&&null!=this.next&&this.checkMerge()&&(this.next.moveChildren(this),this.next.remove())}}m.blotName="container",m.scope=r.BLOCK_BLOT;var p=m;class f extends h{static value(t){return!0}index(t,e){return this.domNode===t||this.domNode.compareDocumentPosition(t)&Node.DOCUMENT_POSITION_CONTAINED_BY?Math.min(e,1):-1}position(t,e){let s=Array.from(this.parent.domNode.childNodes).indexOf(this.domNode);return t>0&&(s+=1),[this.parent.domNode,s]}value(){return{[this.statics.blotName]:this.statics.value(this.domNode)||!0}}}f.scope=r.INLINE_BLOT;var N=f;class b{constructor(t,e,s={}){this.attrName=t,this.keyName=e;const i=r.TYPE&r.ATTRIBUTE;this.scope=null!=s.scope?s.scope&r.LEVEL|i:r.ATTRIBUTE,null!=s.whitelist&&(this.whitelist=s.whitelist)}static keys(t){return Array.from(t.attributes).map(t=>t.name)}add(t,e){return!!this.canAdd(t,e)&&(t.setAttribute(this.keyName,e),!0)}canAdd(t,e){return null==this.whitelist||("string"==typeof e?this.whitelist.indexOf(e.replace(/["']/g,""))>-1:this.whitelist.indexOf(e)>-1)}remove(t){t.removeAttribute(this.keyName)}value(t){const e=t.getAttribute(this.keyName);return this.canAdd(t,e)&&e?e:""}}function g(t,e){return(t.getAttribute("class")||"").split(/\s+/).filter(t=>0===t.indexOf(`${e}-`))}var v=class extends b{static keys(t){return(t.getAttribute("class")||"").split(/\s+/).map(t=>t.split("-").slice(0,-1).join("-"))}add(t,e){return!!this.canAdd(t,e)&&(this.remove(t),t.classList.add(`${this.keyName}-${e}`),!0)}remove(t){g(t,this.keyName).forEach(e=>{t.classList.remove(e)}),0===t.classList.length&&t.removeAttribute("class")}value(t){const e=(g(t,this.keyName)[0]||"").slice(this.keyName.length+1);return this.canAdd(t,e)?e:""}};function y(t){const e=t.split("-"),s=e.slice(1).map(t=>t[0].toUpperCase()+t.slice(1)).join("");return e[0]+s}var A=class extends b{static keys(t){return(t.getAttribute("style")||"").split(";").map(t=>t.split(":")[0].trim())}add(t,e){return!!this.canAdd(t,e)&&(t.style[y(this.keyName)]=e,!0)}remove(t){t.style[y(this.keyName)]="",t.getAttribute("style")||t.removeAttribute("style")}value(t){const e=t.style[y(this.keyName)];return this.canAdd(t,e)?e:""}};var x=class{constructor(t){this.attributes={},this.domNode=t,this.build()}attribute(t,e){e?t.add(this.domNode,e)&&(null!=t.value(this.domNode)?this.attributes[t.attrName]=t:delete this.attributes[t.attrName]):(t.remove(this.domNode),delete this.attributes[t.attrName])}build(){this.attributes={};const t=a.find(this.domNode);if(null==t)return;const e=b.keys(this.domNode),s=v.keys(this.domNode),i=A.keys(this.domNode);e.concat(s).concat(i).forEach(e=>{const s=t.scroll.query(e,r.ATTRIBUTE);s instanceof b&&(this.attributes[s.attrName]=s)})}copy(t){Object.keys(this.attributes).forEach(e=>{const s=this.attributes[e].value(this.domNode);t.format(e,s)})}move(t){this.copy(t),Object.keys(this.attributes).forEach(t=>{this.attributes[t].remove(this.domNode)}),this.attributes={}}values(){return Object.keys(this.attributes).reduce((t,e)=>(t[e]=this.attributes[e].value(this.domNode),t),{})}};class E extends u{constructor(t,e){super(t,e),this.attributes=new x(this.domNode)}static formats(t,e){const s=e.query(E.blotName);if(null==s||t.tagName!==s.tagName)return"string"==typeof this.tagName||(Array.isArray(this.tagName)?t.tagName.toLowerCase():void 0)}format(t,e){if(t!==this.statics.blotName||e){const s=this.scroll.query(t,r.INLINE);if(null==s)return;s instanceof b?this.attributes.attribute(s,e):!e||t===this.statics.blotName&&this.formats()[t]===e||this.replaceWith(t,e)}else this.children.forEach(t=>{t instanceof E||(t=t.wrap(E.blotName,!0)),this.attributes.copy(t)}),this.unwrap()}formats(){const t=this.attributes.values(),e=this.statics.formats(this.domNode,this.scroll);return null!=e&&(t[this.statics.blotName]=e),t}formatAt(t,e,s,i){if(null!=this.formats()[s]||this.scroll.query(s,r.ATTRIBUTE)){this.isolate(t,e).format(s,i)}else super.formatAt(t,e,s,i)}optimize(t){super.optimize(t);const e=this.formats();if(0===Object.keys(e).length)return this.unwrap();const s=this.next;s instanceof E&&s.prev===this&&function(t,e){if(Object.keys(t).length!==Object.keys(e).length)return!1;for(const s in t)if(t[s]!==e[s])return!1;return!0}(e,s.formats())&&(s.moveChildren(this),s.remove())}replaceWith(t,e){const s=super.replaceWith(t,e);return this.attributes.copy(s),s}update(t,e){super.update(t,e),t.some(t=>t.target===this.domNode&&"attributes"===t.type)&&this.attributes.build()}wrap(t,e){const s=super.wrap(t,e);return s instanceof E&&this.attributes.move(s),s}}E.allowedChildren=[E,N],E.blotName="inline",E.scope=r.INLINE_BLOT,E.tagName="SPAN";var T=E;class B extends u{constructor(t,e){super(t,e),this.attributes=new x(this.domNode)}static formats(t,e){const s=e.query(B.blotName);if(null==s||t.tagName!==s.tagName)return"string"==typeof this.tagName||(Array.isArray(this.tagName)?t.tagName.toLowerCase():void 0)}format(t,e){const s=this.scroll.query(t,r.BLOCK);null!=s&&(s instanceof b?this.attributes.attribute(s,e):t!==this.statics.blotName||e?!e||t===this.statics.blotName&&this.formats()[t]===e||this.replaceWith(t,e):this.replaceWith(B.blotName))}formats(){const t=this.attributes.values(),e=this.statics.formats(this.domNode,this.scroll);return null!=e&&(t[this.statics.blotName]=e),t}formatAt(t,e,s,i){null!=this.scroll.query(s,r.BLOCK)?this.format(s,i):super.formatAt(t,e,s,i)}insertAt(t,e,s){if(null==s||null!=this.scroll.query(e,r.INLINE))super.insertAt(t,e,s);else{const i=this.split(t);if(null==i)throw new Error("Attempt to insertAt after block boundaries");{const t=this.scroll.create(e,s);i.parent.insertBefore(t,i)}}}replaceWith(t,e){const s=super.replaceWith(t,e);return this.attributes.copy(s),s}update(t,e){super.update(t,e),t.some(t=>t.target===this.domNode&&"attributes"===t.type)&&this.attributes.build()}}B.blotName="block",B.scope=r.BLOCK_BLOT,B.tagName="P",B.allowedChildren=[T,B,N];var C=B;var L=class extends N{static formats(t,e){}format(t,e){super.formatAt(0,this.length(),t,e)}formatAt(t,e,s,i){0===t&&e===this.length()?this.format(s,i):super.formatAt(t,e,s,i)}formats(){return this.statics.formats(this.domNode,this.scroll)}};const O={attributes:!0,characterData:!0,characterDataOldValue:!0,childList:!0,subtree:!0};class w extends u{constructor(t,e){super(null,e),this.registry=t,this.scroll=this,this.build(),this.observer=new MutationObserver(t=>{this.update(t)}),this.observer.observe(this.domNode,O),this.attach()}create(t,e){return this.registry.create(this,t,e)}find(t,e=!1){return this.registry.find(t,e)}query(t,e=r.ANY){return this.registry.query(t,e)}register(...t){return this.registry.register(...t)}build(){null!=this.scroll&&super.build()}detach(){super.detach(),this.observer.disconnect()}deleteAt(t,e){this.update(),0===t&&e===this.length()?this.children.forEach(t=>{t.remove()}):super.deleteAt(t,e)}formatAt(t,e,s,i){this.update(),super.formatAt(t,e,s,i)}insertAt(t,e,s){this.update(),super.insertAt(t,e,s)}optimize(t=[],e={}){super.optimize(e);const s=e.mutationsMap||new WeakMap;let i=Array.from(this.observer.takeRecords());for(;i.length>0;)t.push(i.pop());const r=(t,e=!0)=>{null!=t&&t!==this&&null!=t.domNode.parentNode&&(s.has(t.domNode)||s.set(t.domNode,[]),e&&r(t.parent))},n=t=>{s.has(t.domNode)&&(t instanceof u&&t.children.forEach(n),s.delete(t.domNode),t.optimize(e))};let o=t;for(let e=0;o.length>0;e+=1){if(e>=100)throw new Error("[Parchment] Maximum optimize iterations reached");for(o.forEach(t=>{const e=this.find(t.target,!0);null!=e&&(e.domNode===t.target&&("childList"===t.type?(r(this.find(t.previousSibling,!1)),Array.from(t.addedNodes).forEach(t=>{const e=this.find(t,!1);r(e,!1),e instanceof u&&e.children.forEach(t=>{r(t,!1)})})):"attributes"===t.type&&r(e.prev)),r(e))}),this.children.forEach(n),o=Array.from(this.observer.takeRecords()),i=o.slice();i.length>0;)t.push(i.pop())}}update(t,e={}){t=t||this.observer.takeRecords();const s=new WeakMap;t.map(t=>{const e=a.find(t.target,!0);return null==e?null:s.has(e.domNode)?(s.get(e.domNode).push(t),null):(s.set(e.domNode,[t]),e)}).forEach(t=>{null!=t&&t!==this&&s.has(t.domNode)&&t.update(s.get(t.domNode)||[],e)}),e.mutationsMap=s,s.has(this.domNode)&&super.update(s.get(this.domNode),e),this.optimize(t,e)}}w.blotName="scroll",w.defaultChild=C,w.allowedChildren=[C,p],w.scope=r.BLOCK_BLOT,w.tagName="DIV";var I=w;class k extends N{constructor(t,e){super(t,e),this.text=this.statics.value(this.domNode)}static create(t){return document.createTextNode(t)}static value(t){return t.data}deleteAt(t,e){this.domNode.data=this.text=this.text.slice(0,t)+this.text.slice(t+e)}index(t,e){return this.domNode===t?e:-1}insertAt(t,e,s){null==s?(this.text=this.text.slice(0,t)+e+this.text.slice(t),this.domNode.data=this.text):super.insertAt(t,e,s)}length(){return this.text.length}optimize(t){super.optimize(t),this.text=this.statics.value(this.domNode),0===this.text.length?this.remove():this.next instanceof k&&this.next.prev===this&&(this.insertAt(this.length(),this.next.value()),this.next.remove())}position(t,e=!1){return[this.domNode,t]}split(t,e=!1){if(!e){if(0===t)return this;if(t===this.length())return this.next}const s=this.scroll.create(this.domNode.splitText(t));return this.parent.insertBefore(s,this.next||void 0),this.text=this.statics.value(this.domNode),s}update(t,e){t.some(t=>"characterData"===t.type&&t.target===this.domNode)&&(this.text=this.statics.value(this.domNode))}value(){return this.text}}k.blotName="text",k.scope=r.INLINE_BLOT;var _=k}])})); +//# sourceMappingURL=parchment.js.map /***/ }), /* 2 */ -/***/ (function(module, exports) { +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +var keys = __webpack_require__(9); +var hasSymbols = typeof Symbol === 'function' && typeof Symbol('foo') === 'symbol'; + +var toStr = Object.prototype.toString; +var concat = Array.prototype.concat; +var origDefineProperty = Object.defineProperty; + +var isFunction = function (fn) { + return typeof fn === 'function' && toStr.call(fn) === '[object Function]'; +}; + +var arePropertyDescriptorsSupported = function () { + var obj = {}; + try { + origDefineProperty(obj, 'x', { enumerable: false, value: obj }); + // eslint-disable-next-line no-unused-vars, no-restricted-syntax + for (var _ in obj) { // jscs:ignore disallowUnusedVariables + return false; + } + return obj.x === obj; + } catch (e) { /* this is IE 8. */ + return false; + } +}; +var supportsDescriptors = origDefineProperty && arePropertyDescriptorsSupported(); + +var defineProperty = function (object, name, value, predicate) { + if (name in object && (!isFunction(predicate) || !predicate())) { + return; + } + if (supportsDescriptors) { + origDefineProperty(object, name, { + configurable: true, + enumerable: false, + value: value, + writable: true + }); + } else { + object[name] = value; + } +}; + +var defineProperties = function (object, map) { + var predicates = arguments.length > 2 ? arguments[2] : {}; + var props = keys(map); + if (hasSymbols) { + props = concat.call(props, Object.getOwnPropertySymbols(map)); + } + for (var i = 0; i < props.length; i += 1) { + defineProperty(object, props[i], map[props[i]], predicates[props[i]]); + } +}; + +defineProperties.supportsDescriptors = !!supportsDescriptors; + +module.exports = defineProperties; -module.exports = ""; /***/ }), /* 3 */ -/***/ (function(module, exports) { +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +var hasOwn = Object.prototype.hasOwnProperty; +var toStr = Object.prototype.toString; +var defineProperty = Object.defineProperty; +var gOPD = Object.getOwnPropertyDescriptor; + +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); +}; + +// If name is '__proto__', and Object.defineProperty is available, define __proto__ as an own property on target +var setProperty = function setProperty(target, options) { + if (defineProperty && options.name === '__proto__') { + defineProperty(target, options.name, { + enumerable: true, + configurable: true, + value: options.newValue, + writable: true + }); + } else { + target[options.name] = options.newValue; + } +}; + +// Return undefined instead of __proto__ if '__proto__' is not an own property +var getProperty = function getProperty(obj, name) { + if (name === '__proto__') { + if (!hasOwn.call(obj, name)) { + return void 0; + } else if (gOPD) { + // In early versions of node, obj['__proto__'] is buggy when obj has + // __proto__ as an own property. Object.getOwnPropertyDescriptor() works. + return gOPD(obj, name).value; + } + } + + return obj[name]; +}; + +module.exports = function extend() { + var options, name, src, copy, copyIsArray, clone; + var target = arguments[0]; + var i = 1; + var length = arguments.length; + var deep = false; + + // Handle a deep copy situation + if (typeof target === 'boolean') { + deep = target; + target = arguments[1] || {}; + // skip the boolean and the target + i = 2; + } + if (target == null || (typeof target !== 'object' && typeof target !== 'function')) { + 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 = getProperty(target, name); + copy = getProperty(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 + setProperty(target, { name: name, newValue: extend(deep, clone, copy) }); + + // Don't bring in undefined values + } else if (typeof copy !== 'undefined') { + setProperty(target, { name: name, newValue: copy }); + } + } + } + } + } + + // Return the modified object + return target; +}; -module.exports = ""; /***/ }), /* 4 */ -/***/ (function(module, exports) { +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +/* globals + Atomics, + SharedArrayBuffer, +*/ + +var undefined; + +var $TypeError = TypeError; + +var $gOPD = Object.getOwnPropertyDescriptor; +if ($gOPD) { + try { + $gOPD({}, ''); + } catch (e) { + $gOPD = null; // this is IE 8, which has a broken gOPD + } +} + +var throwTypeError = function () { throw new $TypeError(); }; +var ThrowTypeError = $gOPD + ? (function () { + try { + // eslint-disable-next-line no-unused-expressions, no-caller, no-restricted-properties + arguments.callee; // IE 8 does not throw here + return throwTypeError; + } catch (calleeThrows) { + try { + // IE 8 throws on Object.getOwnPropertyDescriptor(arguments, '') + return $gOPD(arguments, 'callee').get; + } catch (gOPDthrows) { + return throwTypeError; + } + } + }()) + : throwTypeError; + +var hasSymbols = __webpack_require__(6)(); + +var getProto = Object.getPrototypeOf || function (x) { return x.__proto__; }; // eslint-disable-line no-proto + +var generator; // = function * () {}; +var generatorFunction = generator ? getProto(generator) : undefined; +var asyncFn; // async function() {}; +var asyncFunction = asyncFn ? asyncFn.constructor : undefined; +var asyncGen; // async function * () {}; +var asyncGenFunction = asyncGen ? getProto(asyncGen) : undefined; +var asyncGenIterator = asyncGen ? asyncGen() : undefined; + +var TypedArray = typeof Uint8Array === 'undefined' ? undefined : getProto(Uint8Array); + +var INTRINSICS = { + '%Array%': Array, + '%ArrayBuffer%': typeof ArrayBuffer === 'undefined' ? undefined : ArrayBuffer, + '%ArrayBufferPrototype%': typeof ArrayBuffer === 'undefined' ? undefined : ArrayBuffer.prototype, + '%ArrayIteratorPrototype%': hasSymbols ? getProto([][Symbol.iterator]()) : undefined, + '%ArrayPrototype%': Array.prototype, + '%ArrayProto_entries%': Array.prototype.entries, + '%ArrayProto_forEach%': Array.prototype.forEach, + '%ArrayProto_keys%': Array.prototype.keys, + '%ArrayProto_values%': Array.prototype.values, + '%AsyncFromSyncIteratorPrototype%': undefined, + '%AsyncFunction%': asyncFunction, + '%AsyncFunctionPrototype%': asyncFunction ? asyncFunction.prototype : undefined, + '%AsyncGenerator%': asyncGen ? getProto(asyncGenIterator) : undefined, + '%AsyncGeneratorFunction%': asyncGenFunction, + '%AsyncGeneratorPrototype%': asyncGenFunction ? asyncGenFunction.prototype : undefined, + '%AsyncIteratorPrototype%': asyncGenIterator && hasSymbols && Symbol.asyncIterator ? asyncGenIterator[Symbol.asyncIterator]() : undefined, + '%Atomics%': typeof Atomics === 'undefined' ? undefined : Atomics, + '%Boolean%': Boolean, + '%BooleanPrototype%': Boolean.prototype, + '%DataView%': typeof DataView === 'undefined' ? undefined : DataView, + '%DataViewPrototype%': typeof DataView === 'undefined' ? undefined : DataView.prototype, + '%Date%': Date, + '%DatePrototype%': Date.prototype, + '%decodeURI%': decodeURI, + '%decodeURIComponent%': decodeURIComponent, + '%encodeURI%': encodeURI, + '%encodeURIComponent%': encodeURIComponent, + '%Error%': Error, + '%ErrorPrototype%': Error.prototype, + '%eval%': eval, // eslint-disable-line no-eval + '%EvalError%': EvalError, + '%EvalErrorPrototype%': EvalError.prototype, + '%Float32Array%': typeof Float32Array === 'undefined' ? undefined : Float32Array, + '%Float32ArrayPrototype%': typeof Float32Array === 'undefined' ? undefined : Float32Array.prototype, + '%Float64Array%': typeof Float64Array === 'undefined' ? undefined : Float64Array, + '%Float64ArrayPrototype%': typeof Float64Array === 'undefined' ? undefined : Float64Array.prototype, + '%Function%': Function, + '%FunctionPrototype%': Function.prototype, + '%Generator%': generator ? getProto(generator()) : undefined, + '%GeneratorFunction%': generatorFunction, + '%GeneratorPrototype%': generatorFunction ? generatorFunction.prototype : undefined, + '%Int8Array%': typeof Int8Array === 'undefined' ? undefined : Int8Array, + '%Int8ArrayPrototype%': typeof Int8Array === 'undefined' ? undefined : Int8Array.prototype, + '%Int16Array%': typeof Int16Array === 'undefined' ? undefined : Int16Array, + '%Int16ArrayPrototype%': typeof Int16Array === 'undefined' ? undefined : Int8Array.prototype, + '%Int32Array%': typeof Int32Array === 'undefined' ? undefined : Int32Array, + '%Int32ArrayPrototype%': typeof Int32Array === 'undefined' ? undefined : Int32Array.prototype, + '%isFinite%': isFinite, + '%isNaN%': isNaN, + '%IteratorPrototype%': hasSymbols ? getProto(getProto([][Symbol.iterator]())) : undefined, + '%JSON%': typeof JSON === 'object' ? JSON : undefined, + '%JSONParse%': typeof JSON === 'object' ? JSON.parse : undefined, + '%Map%': typeof Map === 'undefined' ? undefined : Map, + '%MapIteratorPrototype%': typeof Map === 'undefined' || !hasSymbols ? undefined : getProto(new Map()[Symbol.iterator]()), + '%MapPrototype%': typeof Map === 'undefined' ? undefined : Map.prototype, + '%Math%': Math, + '%Number%': Number, + '%NumberPrototype%': Number.prototype, + '%Object%': Object, + '%ObjectPrototype%': Object.prototype, + '%ObjProto_toString%': Object.prototype.toString, + '%ObjProto_valueOf%': Object.prototype.valueOf, + '%parseFloat%': parseFloat, + '%parseInt%': parseInt, + '%Promise%': typeof Promise === 'undefined' ? undefined : Promise, + '%PromisePrototype%': typeof Promise === 'undefined' ? undefined : Promise.prototype, + '%PromiseProto_then%': typeof Promise === 'undefined' ? undefined : Promise.prototype.then, + '%Promise_all%': typeof Promise === 'undefined' ? undefined : Promise.all, + '%Promise_reject%': typeof Promise === 'undefined' ? undefined : Promise.reject, + '%Promise_resolve%': typeof Promise === 'undefined' ? undefined : Promise.resolve, + '%Proxy%': typeof Proxy === 'undefined' ? undefined : Proxy, + '%RangeError%': RangeError, + '%RangeErrorPrototype%': RangeError.prototype, + '%ReferenceError%': ReferenceError, + '%ReferenceErrorPrototype%': ReferenceError.prototype, + '%Reflect%': typeof Reflect === 'undefined' ? undefined : Reflect, + '%RegExp%': RegExp, + '%RegExpPrototype%': RegExp.prototype, + '%Set%': typeof Set === 'undefined' ? undefined : Set, + '%SetIteratorPrototype%': typeof Set === 'undefined' || !hasSymbols ? undefined : getProto(new Set()[Symbol.iterator]()), + '%SetPrototype%': typeof Set === 'undefined' ? undefined : Set.prototype, + '%SharedArrayBuffer%': typeof SharedArrayBuffer === 'undefined' ? undefined : SharedArrayBuffer, + '%SharedArrayBufferPrototype%': typeof SharedArrayBuffer === 'undefined' ? undefined : SharedArrayBuffer.prototype, + '%String%': String, + '%StringIteratorPrototype%': hasSymbols ? getProto(''[Symbol.iterator]()) : undefined, + '%StringPrototype%': String.prototype, + '%Symbol%': hasSymbols ? Symbol : undefined, + '%SymbolPrototype%': hasSymbols ? Symbol.prototype : undefined, + '%SyntaxError%': SyntaxError, + '%SyntaxErrorPrototype%': SyntaxError.prototype, + '%ThrowTypeError%': ThrowTypeError, + '%TypedArray%': TypedArray, + '%TypedArrayPrototype%': TypedArray ? TypedArray.prototype : undefined, + '%TypeError%': $TypeError, + '%TypeErrorPrototype%': $TypeError.prototype, + '%Uint8Array%': typeof Uint8Array === 'undefined' ? undefined : Uint8Array, + '%Uint8ArrayPrototype%': typeof Uint8Array === 'undefined' ? undefined : Uint8Array.prototype, + '%Uint8ClampedArray%': typeof Uint8ClampedArray === 'undefined' ? undefined : Uint8ClampedArray, + '%Uint8ClampedArrayPrototype%': typeof Uint8ClampedArray === 'undefined' ? undefined : Uint8ClampedArray.prototype, + '%Uint16Array%': typeof Uint16Array === 'undefined' ? undefined : Uint16Array, + '%Uint16ArrayPrototype%': typeof Uint16Array === 'undefined' ? undefined : Uint16Array.prototype, + '%Uint32Array%': typeof Uint32Array === 'undefined' ? undefined : Uint32Array, + '%Uint32ArrayPrototype%': typeof Uint32Array === 'undefined' ? undefined : Uint32Array.prototype, + '%URIError%': URIError, + '%URIErrorPrototype%': URIError.prototype, + '%WeakMap%': typeof WeakMap === 'undefined' ? undefined : WeakMap, + '%WeakMapPrototype%': typeof WeakMap === 'undefined' ? undefined : WeakMap.prototype, + '%WeakSet%': typeof WeakSet === 'undefined' ? undefined : WeakSet, + '%WeakSetPrototype%': typeof WeakSet === 'undefined' ? undefined : WeakSet.prototype +}; + +var bind = __webpack_require__(8); +var $replace = bind.call(Function.call, String.prototype.replace); + +/* adapted from https://github.com/lodash/lodash/blob/4.17.15/dist/lodash.js#L6735-L6744 */ +var rePropName = /[^%.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|%$))/g; +var reEscapeChar = /\\(\\)?/g; /** Used to match backslashes in property paths. */ +var stringToPath = function stringToPath(string) { + var result = []; + $replace(string, rePropName, function (match, number, quote, subString) { + result[result.length] = quote ? $replace(subString, reEscapeChar, '$1') : (number || match); + }); + return result; +}; +/* end adaptation */ + +var getBaseIntrinsic = function getBaseIntrinsic(name, allowMissing) { + if (!(name in INTRINSICS)) { + throw new SyntaxError('intrinsic ' + name + ' does not exist!'); + } + + // istanbul ignore if // hopefully this is impossible to test :-) + if (typeof INTRINSICS[name] === 'undefined' && !allowMissing) { + throw new $TypeError('intrinsic ' + name + ' exists, but is not available. Please file an issue!'); + } + + return INTRINSICS[name]; +}; + +module.exports = function GetIntrinsic(name, allowMissing) { + if (typeof name !== 'string' || name.length === 0) { + throw new TypeError('intrinsic name must be a non-empty string'); + } + if (arguments.length > 1 && typeof allowMissing !== 'boolean') { + throw new TypeError('"allowMissing" argument must be a boolean'); + } + + var parts = stringToPath(name); + + var value = getBaseIntrinsic('%' + (parts.length > 0 ? parts[0] : '') + '%', allowMissing); + for (var i = 1; i < parts.length; i += 1) { + if (value != null) { + if ($gOPD && (i + 1) >= parts.length) { + var desc = $gOPD(value, parts[i]); + if (!allowMissing && !(parts[i] in value)) { + throw new $TypeError('base intrinsic for ' + name + ' exists, but the property is not available.'); + } + value = desc ? (desc.get || desc.value) : value[parts[i]]; + } else { + value = value[parts[i]]; + } + } + } + return value; +}; -module.exports = ""; /***/ }), /* 5 */ /***/ (function(module, exports) { -module.exports = ""; +var g; + +// This works in non-strict mode +g = (function() { + return this; +})(); + +try { + // This works if eval is allowed (see CSP) + g = g || new Function("return this")(); +} catch (e) { + // This works if the window reference is available + if (typeof window === "object") g = window; +} + +// g can still be undefined, but nothing to do about it... +// We return undefined, instead of nothing here, so it's +// easier to handle this case. if(!global) { ...} + +module.exports = g; + /***/ }), /* 6 */ -/***/ (function(module, exports) { +/***/ (function(module, exports, __webpack_require__) { -module.exports = ""; +"use strict"; +/* WEBPACK VAR INJECTION */(function(global) { + +var origSymbol = global.Symbol; +var hasSymbolSham = __webpack_require__(11); + +module.exports = function hasNativeSymbols() { + if (typeof origSymbol !== 'function') { return false; } + if (typeof Symbol !== 'function') { return false; } + if (typeof origSymbol('foo') !== 'symbol') { return false; } + if (typeof Symbol('bar') !== 'symbol') { return false; } + + return hasSymbolSham(); +}; + +/* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(5))) /***/ }), /* 7 */ -/***/ (function(module, exports) { +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +var GetIntrinsic = __webpack_require__(4); + +var callBind = __webpack_require__(10); + +var $indexOf = callBind(GetIntrinsic('String.prototype.indexOf')); + +module.exports = function callBoundIntrinsic(name, allowMissing) { + var intrinsic = GetIntrinsic(name, !!allowMissing); + if (typeof intrinsic === 'function' && $indexOf(name, '.prototype.')) { + return callBind(intrinsic); + } + return intrinsic; +}; -module.exports = ""; /***/ }), /* 8 */ -/***/ (function(module, exports) { +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +var implementation = __webpack_require__(76); + +module.exports = Function.prototype.bind || implementation; -module.exports = ""; /***/ }), /* 9 */ -/***/ (function(module, exports) { +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +var slice = Array.prototype.slice; +var isArgs = __webpack_require__(15); + +var origKeys = Object.keys; +var keysShim = origKeys ? function keys(o) { return origKeys(o); } : __webpack_require__(74); + +var originalKeys = Object.keys; + +keysShim.shim = function shimObjectKeys() { + if (Object.keys) { + var keysWorksWithArguments = (function () { + // Safari 5.0 bug + var args = Object.keys(arguments); + return args && args.length === arguments.length; + }(1, 2)); + if (!keysWorksWithArguments) { + Object.keys = function keys(object) { // eslint-disable-line func-name-matching + if (isArgs(object)) { + return originalKeys(slice.call(object)); + } + return originalKeys(object); + }; + } + } else { + Object.keys = keysShim; + } + return Object.keys || keysShim; +}; + +module.exports = keysShim; -module.exports = ""; /***/ }), /* 10 */ -/***/ (function(module, __webpack_exports__, __webpack_require__) { +/***/ (function(module, exports, __webpack_require__) { "use strict"; -__webpack_require__.r(__webpack_exports__); -// EXTERNAL MODULE: external {"commonjs":"quill","commonjs2":"quill","amd":"quill","root":"Quill"} -var external_commonjs_quill_commonjs2_quill_amd_quill_root_Quill_ = __webpack_require__(0); -var external_commonjs_quill_commonjs2_quill_amd_quill_root_Quill_default = /*#__PURE__*/__webpack_require__.n(external_commonjs_quill_commonjs2_quill_amd_quill_root_Quill_); -// CONCATENATED MODULE: ./src/utils/index.js -function css(domNode, rules) { - if (typeof rules === 'object') { - for (let prop in rules) { - domNode.style[prop] = rules[prop]; - } - } -} -/** - * getRelativeRect - * @param {Object} targetRect rect data for target element - * @param {Element} container container element - * @return {Object} an object with rect data - */ +var bind = __webpack_require__(8); -function getRelativeRect(targetRect, container) { - let containerRect = container.getBoundingClientRect(); - return { - x: targetRect.x - containerRect.x - container.scrollLeft, - y: targetRect.y - containerRect.y - container.scrollTop, - x1: targetRect.x - containerRect.x - container.scrollLeft + targetRect.width, - y1: targetRect.y - containerRect.y - container.scrollTop + targetRect.height, - width: targetRect.width, - height: targetRect.height - }; -} -/** - * _omit - * @param {Object} obj target Object - * @param {Array} uselessKeys keys of removed properties - * @return {Object} new Object without useless properties - */ +var GetIntrinsic = __webpack_require__(4); -function _omit(obj, uselessKeys) { - return obj && Object.keys(obj).reduce((acc, key) => { - return uselessKeys.includes(key) ? acc : Object.assign({}, acc, { - [key]: obj[key] - }); - }, {}); -} -/** - * getEventComposedPath - * compatibility fixed for Event.path/Event.composedPath - * Event.path is only for chrome/opera - * Event.composedPath is for Safari, FF - * Neither for Micro Edge - * @param {Event} evt - * @return {Array} an array of event.path - */ +var $Function = GetIntrinsic('%Function%'); +var $apply = $Function.apply; +var $call = $Function.call; -function getEventComposedPath(evt) { - let path; // chrome, opera, safari, firefox +module.exports = function callBind() { + return bind.apply($call, arguments); +}; - path = evt.path || evt.composedPath && evt.composedPath(); // other: edge +module.exports.apply = function applyBind() { + return bind.apply($apply, arguments); +}; - if (path == undefined && evt.target) { - path = []; - let target = evt.target; - path.push(target); - while (target && target.parentNode) { - target = target.parentNode; - path.push(target); - } - } +/***/ }), +/* 11 */ +/***/ (function(module, exports, __webpack_require__) { - return path; -} -function convertToHex(rgb) { - var reg = /^#([0-9a-fA-f]{3}|[0-9a-fA-f]{6})$/; // if rgb +"use strict"; - if (/^(rgb|RGB)/.test(rgb)) { - var color = rgb.toString().match(/\d+/g); - var hex = "#"; - for (var i = 0; i < 3; i++) { - hex += ("0" + Number(color[i]).toString(16)).slice(-2); - } +/* eslint complexity: [2, 18], max-statements: [2, 33] */ +module.exports = function hasSymbols() { + if (typeof Symbol !== 'function' || typeof Object.getOwnPropertySymbols !== 'function') { return false; } + if (typeof Symbol.iterator === 'symbol') { return true; } - return hex; - } else if (reg.test(rgb)) { - var aNum = rgb.replace(/#/, "").split(""); + var obj = {}; + var sym = Symbol('test'); + var symObj = Object(sym); + if (typeof sym === 'string') { return false; } - if (aNum.length === 6) { - return rgb; - } else if (aNum.length === 3) { - var numHex = "#"; + if (Object.prototype.toString.call(sym) !== '[object Symbol]') { return false; } + if (Object.prototype.toString.call(symObj) !== '[object Symbol]') { return false; } - for (var i = 0; i < aNum.length; i += 1) { - numHex += aNum[i] + aNum[i]; - } + // temp disabled per https://github.com/ljharb/object.assign/issues/17 + // if (sym instanceof Symbol) { return false; } + // temp disabled per https://github.com/WebReflection/get-own-property-symbols/issues/4 + // if (!(symObj instanceof Symbol)) { return false; } - return numHex; - } - } + // if (typeof Symbol.prototype.toString !== 'function') { return false; } + // if (String(sym) !== Symbol.prototype.toString.call(sym)) { return false; } - return rgb; -} -// CONCATENATED MODULE: ./src/modules/table-column-tool.js + var symVal = 42; + obj[sym] = symVal; + for (sym in obj) { return false; } // eslint-disable-line no-restricted-syntax + if (typeof Object.keys === 'function' && Object.keys(obj).length !== 0) { return false; } + if (typeof Object.getOwnPropertyNames === 'function' && Object.getOwnPropertyNames(obj).length !== 0) { return false; } -const COL_TOOL_HEIGHT = 12; -const COL_TOOL_CELL_HEIGHT = 12; -const ROW_TOOL_WIDTH = 12; -const CELL_MIN_WIDTH = 50; -const PRIMARY_COLOR = '#35A7ED'; -class table_column_tool_TableColumnTool { - constructor(table, quill, options) { - if (!table) return null; - this.table = table; - this.quill = quill; - this.options = options; - this.domNode = null; - this.initColTool(); - } + var syms = Object.getOwnPropertySymbols(obj); + if (syms.length !== 1 || syms[0] !== sym) { return false; } - initColTool() { - const parent = this.quill.root.parentNode; - const tableRect = this.table.getBoundingClientRect(); - const containerRect = parent.getBoundingClientRect(); - const tableViewRect = this.table.parentNode.getBoundingClientRect(); - this.domNode = document.createElement('div'); - this.domNode.classList.add('qlbt-col-tool'); - this.updateToolCells(); - parent.appendChild(this.domNode); - css(this.domNode, { - width: "".concat(tableViewRect.width, "px"), - height: "".concat(COL_TOOL_HEIGHT, "px"), - left: "".concat(tableViewRect.left - containerRect.left + parent.scrollLeft, "px"), - top: "".concat(tableViewRect.top - containerRect.top + parent.scrollTop - COL_TOOL_HEIGHT - 5, "px") - }); - } + if (!Object.prototype.propertyIsEnumerable.call(obj, sym)) { return false; } - createToolCell() { - const toolCell = document.createElement('div'); - toolCell.classList.add('qlbt-col-tool-cell'); - const resizeHolder = document.createElement('div'); - resizeHolder.classList.add('qlbt-col-tool-cell-holder'); - css(toolCell, { - 'height': "".concat(COL_TOOL_CELL_HEIGHT, "px") - }); - toolCell.appendChild(resizeHolder); - return toolCell; - } - - updateToolCells() { - const tableContainer = external_commonjs_quill_commonjs2_quill_amd_quill_root_Quill_default.a.find(this.table); - const CellsInFirstRow = tableContainer.children.tail.children.head.children; - const tableCols = tableContainer.colGroup().children; - const cellsNumber = computeCellsNumber(CellsInFirstRow); - let existCells = Array.from(this.domNode.querySelectorAll('.qlbt-col-tool-cell')); - - for (let index = 0; index < Math.max(cellsNumber, existCells.length); index++) { - let col = tableCols.at(index); - let colWidth = col && parseInt(col.formats()[col.statics.blotName].width, 10); // if cell already exist + if (typeof Object.getOwnPropertyDescriptor === 'function') { + var descriptor = Object.getOwnPropertyDescriptor(obj, sym); + if (descriptor.value !== symVal || descriptor.enumerable !== true) { return false; } + } - let toolCell = null; + return true; +}; - if (!existCells[index]) { - toolCell = this.createToolCell(); - this.domNode.appendChild(toolCell); - this.addColCellHolderHandler(toolCell); // set tool cell min-width - css(toolCell, { - 'min-width': "".concat(colWidth, "px") - }); - } else if (existCells[index] && index >= cellsNumber) { - existCells[index].remove(); - } else { - toolCell = existCells[index]; // set tool cell min-width +/***/ }), +/* 12 */ +/***/ (function(module, exports, __webpack_require__) { - css(toolCell, { - 'min-width': "".concat(colWidth, "px") - }); - } - } - } +exports = module.exports = __webpack_require__(104)(false); +// Module +exports.push([module.i, ".ql-container .qlbt-selection-line.qlbt-selection-line-left::before{position:absolute;left:-2px;top:-2px;content:'';width:5px;height:5px;background-color:#0589f3;border-radius:5px}.ql-container .qlbt-selection-line.qlbt-selection-line-right::before{position:absolute;right:-2px;bottom:-3px;content:'';width:5px;height:5px;background-color:#0589f3;border-radius:5px}.quill-better-table-wrapper{overflow-x:auto}table.quill-better-table{table-layout:fixed;border-collapse:collapse}table.quill-better-table td{border:1px solid #000;padding:2px 5px}.qlbt-operation-menu{background-color:#fff;box-shadow:0 2px 8px rgba(0,0,0,0.15);font-size:14px;z-index:100;overflow:hidden}.qlbt-operation-menu .qlbt-operation-menu-dividing{height:1px;background-color:#efefef}.qlbt-operation-menu .qlbt-operation-menu-subtitle{color:#999;font-size:14px;padding:5px 16px}.qlbt-operation-menu .qlbt-operation-color-picker{display:flex;align-items:center;flex-wrap:wrap;padding:0 16px 10px;background-color:#fff;overflow:hidden}.qlbt-operation-menu .qlbt-operation-color-picker .qlbt-operation-color-picker-item{width:20px;height:20px;border:1px solid #595959;margin-right:5px;margin-bottom:5px;cursor:pointer}.qlbt-operation-menu .qlbt-operation-menu-item{display:flex;align-items:center;padding:10px 16px;background-color:#fff;cursor:pointer;color:#595959;overflow:hidden;text-overflow:ellipsis}.qlbt-operation-menu .qlbt-operation-menu-item:hover{background-color:#efefef}.qlbt-operation-menu .qlbt-operation-menu-item .qlbt-operation-menu-icon{margin-right:8px;height:20px;width:20px;font-size:0}.qlbt-col-tool{position:absolute;display:flex;align-items:flex-end;overflow:hidden;z-index:99;height:16px}.qlbt-col-tool .qlbt-col-tool-cell{position:relative;background-color:#fff;border-top:1px solid #000;border-right:1px solid #000;border-bottom:1px solid #000}.qlbt-col-tool .qlbt-col-tool-cell:first-child{border-left:1px solid #000}.qlbt-col-tool .qlbt-col-tool-cell-holder{position:absolute;right:-1px;top:0;bottom:0;z-index:3;width:1px;background-color:transparent;cursor:ew-resize}.qlbt-col-tool .qlbt-col-tool-cell-holder:hover{background-color:#0589f3}.qlbt-col-tool .qlbt-col-tool-cell-holder::before{content:\"\";position:absolute;top:0;left:-6px;display:block;width:8px;height:100%}.qlbt-col-tool .qlbt-col-tool-cell-holder::after{content:\"\";position:absolute;top:0;right:-6px;display:block;width:8px;height:100%}.ql-snow .ql-table-picker{width:28px}.ql-snow .ql-table-picker .ql-picker-options{padding:3px 5px;width:212px}.ql-snow .ql-table-picker .ql-picker-item{background-color:#cce4f8;border:1px solid transparent;float:left;height:16px;margin:2px;padding:0;width:16px}.ql-snow .ql-table-picker .ql-picker-item.hover{background-color:#186bad;border-color:#000000}\n", ""]); - destroy() { - this.domNode.remove(); - return null; - } - addColCellHolderHandler(cell) { - const tableContainer = external_commonjs_quill_commonjs2_quill_amd_quill_root_Quill_default.a.find(this.table); - const $holder = cell.querySelector(".qlbt-col-tool-cell-holder"); - let dragging = false; - let x0 = 0; - let x = 0; - let delta = 0; - let width0 = 0; // helpLine relation varrible - let tableRect = {}; - let cellRect = {}; - let $helpLine = null; +/***/ }), +/* 13 */ +/***/ (function(module, exports, __webpack_require__) { - const handleDrag = e => { - e.preventDefault(); +/* WEBPACK VAR INJECTION */(function(Buffer) {var clone = (function() { +'use strict'; - if (dragging) { - x = e.clientX; +function _instanceof(obj, type) { + return type != null && obj instanceof type; +} - if (width0 + x - x0 >= CELL_MIN_WIDTH) { - delta = x - x0; - } else { - delta = CELL_MIN_WIDTH - width0; - } +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() {}; +} - css($helpLine, { - 'left': "".concat(cellRect.left + cellRect.width - 1 + delta, "px") - }); - } - }; +var nativeSet; +try { + nativeSet = Set; +} catch(_) { + nativeSet = function() {}; +} - const handleMouseup = e => { - e.preventDefault(); - const existCells = Array.from(this.domNode.querySelectorAll('.qlbt-col-tool-cell')); - const colIndex = existCells.indexOf(cell); - const colBlot = tableContainer.colGroup().children.at(colIndex); +var nativePromise; +try { + nativePromise = Promise; +} catch(_) { + nativePromise = function() {}; +} - if (dragging) { - colBlot.format('width', width0 + delta); - css(cell, { - 'min-width': "".concat(width0 + delta, "px") - }); - x0 = 0; - x = 0; - delta = 0; - width0 = 0; - dragging = false; - $holder.classList.remove('dragging'); - } +/** + * 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). + * @param `includeNonEnumerable` - set to true if the non-enumerable properties + * should be cloned as well. Non-enumerable properties on the prototype + * chain will be ignored. (optional - false by default) +*/ +function clone(parent, circular, depth, prototype, includeNonEnumerable) { + if (typeof circular === 'object') { + depth = circular.depth; + prototype = circular.prototype; + includeNonEnumerable = circular.includeNonEnumerable; + circular = circular.circular; + } + // maintain two arrays for circular references, where corresponding parents + // and children have the same index + var allParents = []; + var allChildren = []; - document.removeEventListener('mousemove', handleDrag, false); - document.removeEventListener('mouseup', handleMouseup, false); - tableRect = {}; - cellRect = {}; - $helpLine.remove(); - $helpLine = null; - tableContainer.updateTableWidth(); - const tableSelection = this.quill.getModule('better-table').tableSelection; - tableSelection && tableSelection.clearSelection(); - }; + var useBuffer = typeof Buffer != 'undefined'; - const handleMousedown = e => { - document.addEventListener('mousemove', handleDrag, false); - document.addEventListener('mouseup', handleMouseup, false); - tableRect = this.table.getBoundingClientRect(); - cellRect = cell.getBoundingClientRect(); - $helpLine = document.createElement('div'); - css($helpLine, { - position: 'fixed', - top: "".concat(cellRect.top, "px"), - left: "".concat(cellRect.left + cellRect.width - 1, "px"), - zIndex: '100', - height: "".concat(tableRect.height + COL_TOOL_HEIGHT + 4, "px"), - width: '1px', - backgroundColor: PRIMARY_COLOR - }); - document.body.appendChild($helpLine); - dragging = true; - x0 = e.clientX; - width0 = cellRect.width; - $holder.classList.add('dragging'); - }; + if (typeof circular == 'undefined') + circular = true; - $holder.addEventListener('mousedown', handleMousedown, false); - } + if (typeof depth == 'undefined') + depth = Infinity; - colToolCells() { - return Array.from(this.domNode.querySelectorAll('.qlbt-col-tool-cell')); - } + // 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; -function computeCellsNumber(CellsInFirstRow) { - return CellsInFirstRow.reduce((sum, cell) => { - const cellColspan = cell.formats().colspan; - sum = sum + parseInt(cellColspan, 10); - return sum; - }, 0); -} -// CONCATENATED MODULE: ./src/formats/header.js + var child; + var proto; + if (typeof parent != 'object') { + return parent; + } + if (_instanceof(parent, nativeMap)) { + child = new nativeMap(); + } else if (_instanceof(parent, nativeSet)) { + child = new nativeSet(); + } else if (_instanceof(parent, 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)) { + if (Buffer.allocUnsafe) { + // Node.js >= 4.5.0 + child = Buffer.allocUnsafe(parent.length); + } else { + // Older Node.js versions + child = new Buffer(parent.length); + } + parent.copy(child); + return child; + } else if (_instanceof(parent, Error)) { + child = Object.create(parent); + } else { + if (typeof prototype == 'undefined') { + proto = Object.getPrototypeOf(parent); + child = Object.create(proto); + } + else { + child = Object.create(prototype); + proto = prototype; + } + } -const Block = external_commonjs_quill_commonjs2_quill_amd_quill_root_Quill_default.a.import("blots/block"); + if (circular) { + var index = allParents.indexOf(parent); -class header_Header extends Block { - static create(value) { - if (typeof value === 'string') { - value = { - value - }; + if (index != -1) { + return allChildren[index]; + } + allParents.push(parent); + allChildren.push(child); } - const node = super.create(value.value); - CELL_IDENTITY_KEYS.forEach(key => { - if (value[key]) node.setAttribute("data-".concat(key), value[key]); - }); - CELL_ATTRIBUTES.forEach(key => { - if (value[key]) node.setAttribute("data-".concat(key), value[key]); - }); - return node; - } + if (_instanceof(parent, nativeMap)) { + parent.forEach(function(value, key) { + var keyChild = _clone(key, depth - 1); + var valueChild = _clone(value, depth - 1); + child.set(keyChild, valueChild); + }); + } + if (_instanceof(parent, nativeSet)) { + parent.forEach(function(value) { + var entryChild = _clone(value, depth - 1); + child.add(entryChild); + }); + } - static formats(domNode) { - const formats = {}; - formats.value = this.tagName.indexOf(domNode.tagName) + 1; - return CELL_ATTRIBUTES.concat(CELL_IDENTITY_KEYS).reduce((formats, attribute) => { - if (domNode.hasAttribute("data-".concat(attribute))) { - formats[attribute] = domNode.getAttribute("data-".concat(attribute)) || undefined; + for (var i in parent) { + var attrs; + if (proto) { + attrs = Object.getOwnPropertyDescriptor(proto, i); } - return formats; - }, formats); - } - - format(name, value) { - const { - row, - cell, - rowspan, - colspan - } = header_Header.formats(this.domNode); + if (attrs && attrs.set == null) { + continue; + } + child[i] = _clone(parent[i], depth - 1); + } - if (name === header_Header.blotName) { - if (value) { - super.format(name, { - value, - row, - cell, - rowspan, - colspan - }); - } else { - if (row) { - this.replaceWith(TableCellLine.blotName, { - row, - cell, - rowspan, - colspan + 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]; + var descriptor = Object.getOwnPropertyDescriptor(parent, symbol); + if (descriptor && !descriptor.enumerable && !includeNonEnumerable) { + continue; + } + child[symbol] = _clone(parent[symbol], depth - 1); + if (!descriptor.enumerable) { + Object.defineProperty(child, symbol, { + enumerable: false }); - } else { - super.format(name, value); } } - } else { - super.format(name, value); } - } - optimize(context) { - const { - row, - rowspan, - colspan - } = header_Header.formats(this.domNode); + if (includeNonEnumerable) { + var allPropertyNames = Object.getOwnPropertyNames(parent); + for (var i = 0; i < allPropertyNames.length; i++) { + var propertyName = allPropertyNames[i]; + var descriptor = Object.getOwnPropertyDescriptor(parent, propertyName); + if (descriptor && descriptor.enumerable) { + continue; + } + child[propertyName] = _clone(parent[propertyName], depth - 1); + Object.defineProperty(child, propertyName, { + enumerable: false + }); + } + } - if (row && !(this.parent instanceof TableCell)) { - this.wrap(TableCell.blotName, { - row, - colspan, - rowspan - }); - } // ShadowBlot optimize + return child; + } + return _clone(parent, depth); +} - this.enforceAllowedChildren(); +/** + * 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; - if (this.uiNode != null && this.uiNode !== this.domNode.firstChild) { - this.domNode.insertBefore(this.uiNode, this.domNode.firstChild); - } + var c = function () {}; + c.prototype = parent; + return new c(); +}; - if (this.children.length === 0) { - if (this.statics.defaultChild != null) { - const child = this.scroll.create(this.statics.defaultChild.blotName); - this.appendChild(child); // TODO double check if necessary - // child.optimize(context); - } else { - this.remove(); - } - } // Block optimize +// private utility functions +function __objToStr(o) { + return Object.prototype.toString.call(o); +} +clone.__objToStr = __objToStr; - this.cache = {}; - } +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; -header_Header.blotName = 'header'; -header_Header.tagName = ['H1', 'H2', 'H3', 'H4', 'H5', 'H6']; -/* harmony default export */ var header = (header_Header); -// CONCATENATED MODULE: ./src/formats/table.js +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 ( true && module.exports) { + module.exports = clone; +} -const Break = external_commonjs_quill_commonjs2_quill_amd_quill_root_Quill_default.a.import("blots/break"); -const table_Block = external_commonjs_quill_commonjs2_quill_amd_quill_root_Quill_default.a.import("blots/block"); -const Container = external_commonjs_quill_commonjs2_quill_amd_quill_root_Quill_default.a.import("blots/container"); -const COL_ATTRIBUTES = ["width"]; -const COL_DEFAULT = { - width: 100 +/* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(70).Buffer)) + +/***/ }), +/* 14 */ +/***/ (function(module, exports) { + +module.exports = " "; + +/***/ }), +/* 15 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +var toStr = Object.prototype.toString; + +module.exports = function isArguments(value) { + var str = toStr.call(value); + var isArgs = str === '[object Arguments]'; + if (!isArgs) { + isArgs = str !== '[object Array]' && + value !== null && + typeof value === 'object' && + typeof value.length === 'number' && + value.length >= 0 && + toStr.call(value.callee) === '[object Function]'; + } + return isArgs; }; -const CELL_IDENTITY_KEYS = ["row", "cell"]; -const CELL_ATTRIBUTES = ["rowspan", "colspan"]; -const CELL_DEFAULT = { - rowspan: 1, - colspan: 1 + + +/***/ }), +/* 16 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +var hasToStringTag = typeof Symbol === 'function' && typeof Symbol.toStringTag === 'symbol'; +var toStr = Object.prototype.toString; + +var isStandardArguments = function isArguments(value) { + if (hasToStringTag && value && typeof value === 'object' && Symbol.toStringTag in value) { + return false; + } + return toStr.call(value) === '[object Arguments]'; }; -const ERROR_LIMIT = 5; -class TableCellLine extends table_Block { - static create(value) { - const node = super.create(value); - CELL_IDENTITY_KEYS.forEach(key => { - let identityMaker = key === 'row' ? table_rowId : table_cellId; - node.setAttribute("data-".concat(key), value[key] || identityMaker()); - }); - CELL_ATTRIBUTES.forEach(attrName => { - node.setAttribute("data-".concat(attrName), value[attrName] || CELL_DEFAULT[attrName]); - }); +var isLegacyArguments = function isArguments(value) { + if (isStandardArguments(value)) { + return true; + } + return value !== null && + typeof value === 'object' && + typeof value.length === 'number' && + value.length >= 0 && + toStr.call(value) !== '[object Array]' && + toStr.call(value.callee) === '[object Function]'; +}; - if (value['cell-bg']) { - node.setAttribute('data-cell-bg', value['cell-bg']); - } +var supportsStandardArguments = (function () { + return isStandardArguments(arguments); +}()); - return node; - } +isStandardArguments.isLegacyArguments = isLegacyArguments; // for tests - static formats(domNode) { - const formats = {}; - return CELL_ATTRIBUTES.concat(CELL_IDENTITY_KEYS).concat(['cell-bg']).reduce((formats, attribute) => { - if (domNode.hasAttribute("data-".concat(attribute))) { - formats[attribute] = domNode.getAttribute("data-".concat(attribute)) || undefined; - } +module.exports = supportsStandardArguments ? isStandardArguments : isLegacyArguments; - return formats; - }, formats); - } - format(name, value) { - if (CELL_ATTRIBUTES.concat(CELL_IDENTITY_KEYS).indexOf(name) > -1) { - if (value) { - this.domNode.setAttribute("data-".concat(name), value); - } else { - this.domNode.removeAttribute("data-".concat(name)); - } - } else if (name === 'cell-bg') { - if (value) { - this.domNode.setAttribute('data-cell-bg', value); - } else { - this.domNode.removeAttribute('data-cell-bg'); - } - } else if (name === 'header') { - if (!value) return; - const { - row, - cell, - rowspan, - colspan - } = TableCellLine.formats(this.domNode); - super.format(name, { - value, - row, - cell, - rowspan, - colspan - }); - } else { - super.format(name, value); - } - } +/***/ }), +/* 17 */ +/***/ (function(module, exports, __webpack_require__) { - optimize(context) { - // cover shadowBlot's wrap call, pass params parentBlot initialize - // needed - const rowId = this.domNode.getAttribute('data-row'); - const rowspan = this.domNode.getAttribute('data-rowspan'); - const colspan = this.domNode.getAttribute('data-colspan'); - const cellBg = this.domNode.getAttribute('data-cell-bg'); +"use strict"; - if (this.statics.requiredContainer && !(this.parent instanceof this.statics.requiredContainer)) { - this.wrap(this.statics.requiredContainer.blotName, { - row: rowId, - colspan, - rowspan, - 'cell-bg': cellBg - }); - } - super.optimize(context); - } +var numberIsNaN = function (value) { + return value !== value; +}; - tableCell() { - return this.parent; - } +module.exports = function is(a, b) { + if (a === 0 && b === 0) { + return 1 / a === 1 / b; + } + if (a === b) { + return true; + } + if (numberIsNaN(a) && numberIsNaN(b)) { + return true; + } + return false; +}; -} -TableCellLine.blotName = "table-cell-line"; -TableCellLine.ClassName = "qlbt-cell-line"; -TableCellLine.tagName = "DIV"; -class TableCell extends Container { - checkMerge() { - if (super.checkMerge() && this.next.children.head != null) { - const thisHead = this.children.head.formats()[this.children.head.statics.blotName]; - const thisTail = this.children.tail.formats()[this.children.tail.statics.blotName]; - const nextHead = this.next.children.head.formats()[this.next.children.head.statics.blotName]; - const nextTail = this.next.children.tail.formats()[this.next.children.tail.statics.blotName]; - return thisHead.cell === thisTail.cell && thisHead.cell === nextHead.cell && thisHead.cell === nextTail.cell; - } +/***/ }), +/* 18 */ +/***/ (function(module, exports, __webpack_require__) { - return false; - } +"use strict"; - static create(value) { - const node = super.create(value); - node.setAttribute("data-row", value.row); - CELL_ATTRIBUTES.forEach(attrName => { - if (value[attrName]) { - node.setAttribute(attrName, value[attrName]); - } - }); - if (value['cell-bg']) { - node.setAttribute('data-cell-bg', value['cell-bg']); - node.style.backgroundColor = value['cell-bg']; - } +var implementation = __webpack_require__(17); - return node; - } +module.exports = function getPolyfill() { + return typeof Object.is === 'function' ? Object.is : implementation; +}; - static formats(domNode) { - const formats = {}; - if (domNode.hasAttribute("data-row")) { - formats["row"] = domNode.getAttribute("data-row"); - } +/***/ }), +/* 19 */ +/***/ (function(module, exports, __webpack_require__) { - if (domNode.hasAttribute("data-cell-bg")) { - formats["cell-bg"] = domNode.getAttribute("data-cell-bg"); - } +"use strict"; - return CELL_ATTRIBUTES.reduce((formats, attribute) => { - if (domNode.hasAttribute(attribute)) { - formats[attribute] = domNode.getAttribute(attribute); - } - return formats; - }, formats); - } +var $Object = Object; +var $TypeError = TypeError; + +module.exports = function flags() { + if (this != null && this !== $Object(this)) { + throw new $TypeError('RegExp.prototype.flags getter called on non-object'); + } + var result = ''; + if (this.global) { + result += 'g'; + } + if (this.ignoreCase) { + result += 'i'; + } + if (this.multiline) { + result += 'm'; + } + if (this.dotAll) { + result += 's'; + } + if (this.unicode) { + result += 'u'; + } + if (this.sticky) { + result += 'y'; + } + return result; +}; - cellOffset() { - if (this.parent) { - return this.parent.children.indexOf(this); - } - return -1; - } +/***/ }), +/* 20 */ +/***/ (function(module, exports, __webpack_require__) { - formats() { - const formats = {}; +"use strict"; - if (this.domNode.hasAttribute("data-row")) { - formats["row"] = this.domNode.getAttribute("data-row"); - } - if (this.domNode.hasAttribute("data-cell-bg")) { - formats["cell-bg"] = this.domNode.getAttribute("data-cell-bg"); - } +var implementation = __webpack_require__(19); - return CELL_ATTRIBUTES.reduce((formats, attribute) => { - if (this.domNode.hasAttribute(attribute)) { - formats[attribute] = this.domNode.getAttribute(attribute); - } +var supportsDescriptors = __webpack_require__(2).supportsDescriptors; +var $gOPD = Object.getOwnPropertyDescriptor; +var $TypeError = TypeError; - return formats; - }, formats); - } +module.exports = function getPolyfill() { + if (!supportsDescriptors) { + throw new $TypeError('RegExp.prototype.flags requires a true ES5 environment that supports property descriptors'); + } + if ((/a/mig).flags === 'gim') { + var descriptor = $gOPD(RegExp.prototype, 'flags'); + if (descriptor && typeof descriptor.get === 'function' && typeof (/a/).dotAll === 'boolean') { + return descriptor.get; + } + } + return implementation; +}; - toggleAttribute(name, value) { - if (value) { - this.domNode.setAttribute(name, value); - } else { - this.domNode.removeAttribute(name); - } - } - formatChildren(name, value) { - this.children.forEach(child => { - child.format(name, value); - }); - } +/***/ }), +/* 21 */ +/***/ (function(module, exports, __webpack_require__) { - format(name, value) { - if (CELL_ATTRIBUTES.indexOf(name) > -1) { - this.toggleAttribute(name, value); - this.formatChildren(name, value); - } else if (['row'].indexOf(name) > -1) { - this.toggleAttribute("data-".concat(name), value); - this.formatChildren(name, value); - } else if (name === 'cell-bg') { - this.toggleAttribute('data-cell-bg', value); - this.formatChildren(name, value); +"use strict"; - if (value) { - this.domNode.style.backgroundColor = value; - } else { - this.domNode.style.backgroundColor = 'initial'; - } - } else { - super.format(name, value); - } - } - optimize(context) { - const rowId = this.domNode.getAttribute("data-row"); +var strValue = String.prototype.valueOf; +var tryStringObject = function tryStringObject(value) { + try { + strValue.call(value); + return true; + } catch (e) { + return false; + } +}; +var toStr = Object.prototype.toString; +var strClass = '[object String]'; +var hasToStringTag = typeof Symbol === 'function' && typeof Symbol.toStringTag === 'symbol'; + +module.exports = function isString(value) { + if (typeof value === 'string') { + return true; + } + if (typeof value !== 'object') { + return false; + } + return hasToStringTag ? tryStringObject(value) : toStr.call(value) === strClass; +}; - if (this.statics.requiredContainer && !(this.parent instanceof this.statics.requiredContainer)) { - this.wrap(this.statics.requiredContainer.blotName, { - row: rowId - }); - } - super.optimize(context); - } +/***/ }), +/* 22 */ +/***/ (function(module, exports, __webpack_require__) { - row() { - return this.parent; - } +"use strict"; - rowOffset() { - if (this.row()) { - return this.row().rowOffset(); - } - return -1; - } +var $Map = typeof Map === 'function' && Map.prototype ? Map : null; +var $Set = typeof Set === 'function' && Set.prototype ? Set : null; - table() { - return this.row() && this.row().table(); - } +var exported; +if (!$Map) { + // eslint-disable-next-line no-unused-vars + exported = function isMap(x) { + // `Map` is not present in this environment. + return false; + }; } -TableCell.blotName = "table"; -TableCell.tagName = "TD"; +var $mapHas = $Map ? Map.prototype.has : null; +var $setHas = $Set ? Set.prototype.has : null; +if (!exported && !$mapHas) { + // eslint-disable-next-line no-unused-vars + exported = function isMap(x) { + // `Map` does not have a `has` method + return false; + }; +} -class TableRow extends Container { - checkMerge() { - if (super.checkMerge() && this.next.children.head != null) { - const thisHead = this.children.head.formats(); - const thisTail = this.children.tail.formats(); - const nextHead = this.next.children.head.formats(); - const nextTail = this.next.children.tail.formats(); - return thisHead.row === thisTail.row && thisHead.row === nextHead.row && thisHead.row === nextTail.row; - } +module.exports = exported || function isMap(x) { + if (!x || typeof x !== 'object') { + return false; + } + try { + $mapHas.call(x); + if ($setHas) { + try { + $setHas.call(x); + } catch (e) { + return true; + } + } + return x instanceof $Map; // core-js workaround, pre-v2.5.0 + } catch (e) {} + return false; +}; - return false; - } - static create(value) { - const node = super.create(value); - node.setAttribute("data-row", value.row); - return node; - } +/***/ }), +/* 23 */ +/***/ (function(module, exports, __webpack_require__) { - formats() { - return ["row"].reduce((formats, attrName) => { - if (this.domNode.hasAttribute("data-".concat(attrName))) { - formats[attrName] = this.domNode.getAttribute("data-".concat(attrName)); - } +"use strict"; - return formats; - }, {}); - } - optimize(context) { - // optimize function of ShadowBlot - if (this.statics.requiredContainer && !(this.parent instanceof this.statics.requiredContainer)) { - this.wrap(this.statics.requiredContainer.blotName); - } // optimize function of ParentBlot - // note: modified this optimize function because - // TableRow should not be removed when the length of its children was 0 +var $Map = typeof Map === 'function' && Map.prototype ? Map : null; +var $Set = typeof Set === 'function' && Set.prototype ? Set : null; +var exported; - this.enforceAllowedChildren(); +if (!$Set) { + // eslint-disable-next-line no-unused-vars + exported = function isSet(x) { + // `Set` is not present in this environment. + return false; + }; +} - if (this.uiNode != null && this.uiNode !== this.domNode.firstChild) { - this.domNode.insertBefore(this.uiNode, this.domNode.firstChild); - } // optimize function of ContainerBlot +var $mapHas = $Map ? Map.prototype.has : null; +var $setHas = $Set ? Set.prototype.has : null; +if (!exported && !$setHas) { + // eslint-disable-next-line no-unused-vars + exported = function isSet(x) { + // `Set` does not have a `has` method + return false; + }; +} +module.exports = exported || function isSet(x) { + if (!x || typeof x !== 'object') { + return false; + } + try { + $setHas.call(x); + if ($mapHas) { + try { + $mapHas.call(x); + } catch (e) { + return true; + } + } + return x instanceof $Set; // core-js workaround, pre-v2.5.0 + } catch (e) {} + return false; +}; - if (this.children.length > 0 && this.next != null && this.checkMerge()) { - this.next.moveChildren(this); - this.next.remove(); - } - } - rowOffset() { - if (this.parent) { - return this.parent.children.indexOf(this); - } +/***/ }), +/* 24 */ +/***/ (function(module, exports) { - return -1; - } - table() { - return this.parent && this.parent.parent; - } +var hasOwn = Object.prototype.hasOwnProperty; +var toString = Object.prototype.toString; -} +module.exports = function forEach (obj, fn, ctx) { + if (toString.call(fn) !== '[object Function]') { + throw new TypeError('iterator must be a function'); + } + var l = obj.length; + if (l === +l) { + for (var i = 0; i < l; i++) { + fn.call(ctx, obj[i], i, obj); + } + } else { + for (var k in obj) { + if (hasOwn.call(obj, k)) { + fn.call(ctx, obj[k], k, obj); + } + } + } +}; -TableRow.blotName = "table-row"; -TableRow.tagName = "TR"; -class TableBody extends Container {} -TableBody.blotName = "table-body"; -TableBody.tagName = "TBODY"; +/***/ }), +/* 25 */ +/***/ (function(module, exports, __webpack_require__) { -class TableCol extends table_Block { - static create(value) { - let node = super.create(value); - COL_ATTRIBUTES.forEach(attrName => { - node.setAttribute("".concat(attrName), value[attrName] || COL_DEFAULT[attrName]); - }); - return node; - } +"use strict"; +/* WEBPACK VAR INJECTION */(function(global) { + +var filter = __webpack_require__(99); + +module.exports = function availableTypedArrays() { + return filter([ + 'BigInt64Array', + 'BigUint64Array', + 'Float32Array', + 'Float64Array', + 'Int16Array', + 'Int32Array', + 'Int8Array', + 'Uint16Array', + 'Uint32Array', + 'Uint8Array', + 'Uint8ClampedArray' + ], function (typedArray) { + return typeof global[typedArray] === 'function'; + }); +}; - static formats(domNode) { - return COL_ATTRIBUTES.reduce((formats, attribute) => { - if (domNode.hasAttribute("".concat(attribute))) { - formats[attribute] = domNode.getAttribute("".concat(attribute)) || undefined; - } +/* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(5))) - return formats; - }, {}); - } +/***/ }), +/* 26 */ +/***/ (function(module, exports, __webpack_require__) { - format(name, value) { - if (COL_ATTRIBUTES.indexOf(name) > -1) { - this.domNode.setAttribute("".concat(name), value || COL_DEFAULT[name]); - } else { - super.format(name, value); - } - } +"use strict"; - html() { - return this.domNode.outerHTML; - } +var GetIntrinsic = __webpack_require__(4); + +var $gOPD = GetIntrinsic('%Object.getOwnPropertyDescriptor%'); +if ($gOPD) { + try { + $gOPD([], 'length'); + } catch (e) { + // IE 8 has a broken gOPD + $gOPD = null; + } } -TableCol.blotName = "table-col"; -TableCol.tagName = "col"; +module.exports = $gOPD; -class TableColGroup extends Container {} -TableColGroup.blotName = "table-col-group"; -TableColGroup.tagName = "colgroup"; +/***/ }), +/* 27 */ +/***/ (function(module, exports, __webpack_require__) { -class table_TableContainer extends Container { - static create() { - let node = super.create(); - return node; - } +"use strict"; - constructor(scroll, domNode) { - super(scroll, domNode); - this.updateTableWidth(); - } - updateTableWidth() { - setTimeout(() => { - const colGroup = this.colGroup(); - if (!colGroup) return; - const tableWidth = colGroup.children.reduce((sumWidth, col) => { - sumWidth = sumWidth + parseInt(col.formats()[TableCol.blotName].width, 10); - return sumWidth; - }, 0); - this.domNode.style.width = "".concat(tableWidth, "px"); - }, 0); - } +// modified from https://github.com/es-shims/es6-shim +var keys = __webpack_require__(9); +var bind = __webpack_require__(8); +var canBeObject = function (obj) { + return typeof obj !== 'undefined' && obj !== null; +}; +var hasSymbols = __webpack_require__(11)(); +var toObject = Object; +var push = bind.call(Function.call, Array.prototype.push); +var propIsEnumerable = bind.call(Function.call, Object.prototype.propertyIsEnumerable); +var originalGetSymbols = hasSymbols ? Object.getOwnPropertySymbols : null; + +module.exports = function assign(target, source1) { + if (!canBeObject(target)) { throw new TypeError('target must be an object'); } + var objTarget = toObject(target); + var s, source, i, props, syms, value, key; + for (s = 1; s < arguments.length; ++s) { + source = toObject(arguments[s]); + props = keys(source); + var getSymbols = hasSymbols && (Object.getOwnPropertySymbols || originalGetSymbols); + if (getSymbols) { + syms = getSymbols(source); + for (i = 0; i < syms.length; ++i) { + key = syms[i]; + if (propIsEnumerable(source, key)) { + push(props, key); + } + } + } + for (i = 0; i < props.length; ++i) { + key = props[i]; + value = source[key]; + if (propIsEnumerable(source, key)) { + objTarget[key] = value; + } + } + } + return objTarget; +}; - cells(column) { - return this.rows().map(row => row.children.at(column)); - } - colGroup() { - return this.children.head; - } +/***/ }), +/* 28 */ +/***/ (function(module, exports, __webpack_require__) { - deleteColumns(compareRect) { - let delIndexes = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : []; - let editorWrapper = arguments.length > 2 ? arguments[2] : undefined; - const [body] = this.descendants(TableBody); - if (body == null || body.children.head == null) return; - const tableCells = this.descendants(TableCell); - const removedCells = []; - const modifiedCells = []; - tableCells.forEach(cell => { - const cellRect = getRelativeRect(cell.domNode.getBoundingClientRect(), editorWrapper); +"use strict"; - if (cellRect.x + ERROR_LIMIT > compareRect.x && cellRect.x1 - ERROR_LIMIT < compareRect.x1) { - removedCells.push(cell); - } else if (cellRect.x < compareRect.x + ERROR_LIMIT && cellRect.x1 > compareRect.x1 - ERROR_LIMIT) { - modifiedCells.push(cell); - } - }); - if (removedCells.length === tableCells.length) { - this.tableDestroy(); - return true; - } // remove the matches column tool cell +var implementation = __webpack_require__(27); + +var lacksProperEnumerationOrder = function () { + if (!Object.assign) { + return false; + } + // v8, specifically in node 4.x, has a bug with incorrect property enumeration order + // note: this does not detect the bug unless there's 20 characters + var str = 'abcdefghijklmnopqrst'; + var letters = str.split(''); + var map = {}; + for (var i = 0; i < letters.length; ++i) { + map[letters[i]] = letters[i]; + } + var obj = Object.assign({}, map); + var actual = ''; + for (var k in obj) { + actual += k; + } + return str !== actual; +}; +var assignHasPendingExceptions = function () { + if (!Object.assign || !Object.preventExtensions) { + return false; + } + // Firefox 37 still has "pending exception" logic in its Object.assign implementation, + // which is 72% slower than our shim, and Firefox 40's native implementation. + var thrower = Object.preventExtensions({ 1: 2 }); + try { + Object.assign(thrower, 'xy'); + } catch (e) { + return thrower[1] === 'y'; + } + return false; +}; - delIndexes.forEach(delIndex => { - this.colGroup().children.at(delIndexes[0]).remove(); - }); - removedCells.forEach(cell => { - cell.remove(); - }); - modifiedCells.forEach(cell => { - const cellColspan = parseInt(cell.formats().colspan, 10); - const cellWidth = parseInt(cell.formats().width, 10); - cell.format('colspan', cellColspan - delIndexes.length); - }); - this.updateTableWidth(); - } +module.exports = function getPolyfill() { + if (!Object.assign) { + return implementation; + } + if (lacksProperEnumerationOrder()) { + return implementation; + } + if (assignHasPendingExceptions()) { + return implementation; + } + return Object.assign; +}; - deleteRow(compareRect, editorWrapper) { - const [body] = this.descendants(TableBody); - if (body == null || body.children.head == null) return; - const tableCells = this.descendants(TableCell); - const tableRows = this.descendants(TableRow); - const removedCells = []; // cells to be removed - const modifiedCells = []; // cells to be modified +/***/ }), +/* 29 */ +/***/ (function(module, exports) { - const fallCells = []; // cells to fall into next row - // compute rows to remove - // bugfix: #21 There will be a empty tr left if delete the last row of a table +module.exports = ""; - const removedRows = tableRows.filter(row => { - const rowRect = getRelativeRect(row.domNode.getBoundingClientRect(), editorWrapper); - return rowRect.y > compareRect.y - ERROR_LIMIT && rowRect.y1 < compareRect.y1 + ERROR_LIMIT; - }); - tableCells.forEach(cell => { - const cellRect = getRelativeRect(cell.domNode.getBoundingClientRect(), editorWrapper); +/***/ }), +/* 30 */ +/***/ (function(module, exports) { - if (cellRect.y > compareRect.y - ERROR_LIMIT && cellRect.y1 < compareRect.y1 + ERROR_LIMIT) { - removedCells.push(cell); - } else if (cellRect.y < compareRect.y + ERROR_LIMIT && cellRect.y1 > compareRect.y1 - ERROR_LIMIT) { - modifiedCells.push(cell); +module.exports = ""; - if (Math.abs(cellRect.y - compareRect.y) < ERROR_LIMIT) { - fallCells.push(cell); - } - } - }); +/***/ }), +/* 31 */ +/***/ (function(module, exports) { - if (removedCells.length === tableCells.length) { - this.tableDestroy(); - return; - } // compute length of removed rows +module.exports = ""; +/***/ }), +/* 32 */ +/***/ (function(module, exports) { - const removedRowsLength = this.rows().reduce((sum, row) => { - let rowRect = getRelativeRect(row.domNode.getBoundingClientRect(), editorWrapper); +module.exports = ""; - if (rowRect.y > compareRect.y - ERROR_LIMIT && rowRect.y1 < compareRect.y1 + ERROR_LIMIT) { - sum += 1; - } +/***/ }), +/* 33 */ +/***/ (function(module, exports) { - return sum; - }, 0); // it must excute before the table layout changed with other operation +module.exports = ""; - fallCells.forEach(cell => { - const cellRect = getRelativeRect(cell.domNode.getBoundingClientRect(), editorWrapper); - const nextRow = cell.parent.next; - const cellsInNextRow = nextRow.children; - const refCell = cellsInNextRow.reduce((ref, compareCell) => { - const compareRect = getRelativeRect(compareCell.domNode.getBoundingClientRect(), editorWrapper); +/***/ }), +/* 34 */ +/***/ (function(module, exports) { - if (Math.abs(cellRect.x1 - compareRect.x) < ERROR_LIMIT) { - ref = compareCell; - } +module.exports = ""; - return ref; - }, null); - nextRow.insertBefore(cell, refCell); - cell.format('row', nextRow.formats().row); - }); - removedCells.forEach(cell => { - cell.remove(); - }); - modifiedCells.forEach(cell => { - const cellRowspan = parseInt(cell.formats().rowspan, 10); - cell.format("rowspan", cellRowspan - removedRowsLength); - }); // remove selected rows +/***/ }), +/* 35 */ +/***/ (function(module, exports) { - removedRows.forEach(row => row.remove()); - } +module.exports = ""; - tableDestroy() { - const quill = external_commonjs_quill_commonjs2_quill_amd_quill_root_Quill_default.a.find(this.scroll.domNode.parentNode); - const tableModule = quill.getModule("better-table"); - this.remove(); - tableModule.hideTableTools(); - quill.update(external_commonjs_quill_commonjs2_quill_amd_quill_root_Quill_default.a.sources.USER); +/***/ }), +/* 36 */ +/***/ (function(module, exports) { + +module.exports = ""; + +/***/ }), +/* 37 */ +/***/ (function(module, exports) { + +module.exports = ""; + +/***/ }), +/* 38 */ +/***/ (function(module, exports, __webpack_require__) { + +"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 + * @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 {*} context The context to invoke the listener with. + * @param {Boolean} [once=false] Specify if the listener is a one-time listener. + * @constructor + * @private + */ +function EE(fn, context, once) { + this.fn = fn; + this.context = context; + this.once = once || false; +} + +/** + * Add a listener for a given event. + * + * @param {EventEmitter} emitter Reference to the `EventEmitter` instance. + * @param {(String|Symbol)} event The event name. + * @param {Function} fn The listener function. + * @param {*} context The context to invoke the listener with. + * @param {Boolean} once Specify if the listener is a one-time listener. + * @returns {EventEmitter} + * @private + */ +function addListener(emitter, event, fn, context, once) { + if (typeof fn !== 'function') { + throw new TypeError('The listener must be a function'); } - insertCell(tableRow, ref) { - const id = table_cellId(); - const rId = tableRow.formats().row; - const tableCell = this.scroll.create(TableCell.blotName, Object.assign({}, CELL_DEFAULT, { - row: rId - })); - const cellLine = this.scroll.create(TableCellLine.blotName, { - row: rId, - cell: id - }); - tableCell.appendChild(cellLine); + var listener = new EE(fn, context || emitter, once) + , evt = prefix ? prefix + event : event; - if (ref) { - tableRow.insertBefore(tableCell, ref); - } else { - tableRow.appendChild(tableCell); - } + if (!emitter._events[evt]) emitter._events[evt] = listener, emitter._eventsCount++; + else if (!emitter._events[evt].fn) emitter._events[evt].push(listener); + else emitter._events[evt] = [emitter._events[evt], listener]; + + return emitter; +} + +/** + * Clear event by name. + * + * @param {EventEmitter} emitter Reference to the `EventEmitter` instance. + * @param {(String|Symbol)} evt The Event name. + * @private + */ +function clearEvent(emitter, evt) { + if (--emitter._eventsCount === 0) emitter._events = new Events(); + else delete emitter._events[evt]; +} + +/** + * Minimal `EventEmitter` interface that is molded against the Node.js + * `EventEmitter` interface. + * + * @constructor + * @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} + * @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); } - insertColumn(compareRect, colIndex) { - let isRight = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true; - let editorWrapper = arguments.length > 3 ? arguments[3] : undefined; - const [body] = this.descendants(TableBody); - const [tableColGroup] = this.descendants(TableColGroup); - const tableCols = this.descendants(TableCol); - let addAsideCells = []; - let modifiedCells = []; - let affectedCells = []; - if (body == null || body.children.head == null) return; - const tableCells = this.descendants(TableCell); - tableCells.forEach(cell => { - const cellRect = getRelativeRect(cell.domNode.getBoundingClientRect(), editorWrapper); + if (Object.getOwnPropertySymbols) { + return names.concat(Object.getOwnPropertySymbols(events)); + } - if (isRight) { - if (Math.abs(cellRect.x1 - compareRect.x1) < ERROR_LIMIT) { - // the right of selected boundary equal to the right of table cell, - // add a new table cell right aside this table cell - addAsideCells.push(cell); - } else if (compareRect.x1 - cellRect.x > ERROR_LIMIT && compareRect.x1 - cellRect.x1 < -ERROR_LIMIT) { - // the right of selected boundary is inside this table cell - // colspan of this table cell will increase 1 - modifiedCells.push(cell); - } - } else { - if (Math.abs(cellRect.x - compareRect.x) < ERROR_LIMIT) { - // left of selected boundary equal to left of table cell, - // add a new table cell left aside this table cell - addAsideCells.push(cell); - } else if (compareRect.x - cellRect.x > ERROR_LIMIT && compareRect.x - cellRect.x1 < -ERROR_LIMIT) { - // the left of selected boundary is inside this table cell - // colspan of this table cell will increase 1 - modifiedCells.push(cell); - } + return names; +}; + +/** + * Return the listeners registered for a given event. + * + * @param {(String|Symbol)} event The event name. + * @returns {Array} The registered listeners. + * @public + */ +EventEmitter.prototype.listeners = function listeners(event) { + var evt = prefix ? prefix + event : event + , handlers = this._events[evt]; + + if (!handlers) return []; + if (handlers.fn) return [handlers.fn]; + + for (var i = 0, l = handlers.length, ee = new Array(l); i < l; i++) { + ee[i] = handlers[i].fn; + } + + return ee; +}; + +/** + * Return the number of listeners listening to a given event. + * + * @param {(String|Symbol)} event The event name. + * @returns {Number} The number of listeners. + * @public + */ +EventEmitter.prototype.listenerCount = function listenerCount(event) { + var evt = prefix ? prefix + event : event + , listeners = this._events[evt]; + + if (!listeners) return 0; + if (listeners.fn) return 1; + return listeners.length; +}; + +/** + * 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`. + * @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); } - }); - addAsideCells.forEach(cell => { - const ref = isRight ? cell.next : cell; - const id = table_cellId(); - const tableRow = cell.parent; - const rId = tableRow.formats().row; - const cellFormats = cell.formats(); - const tableCell = this.scroll.create(TableCell.blotName, Object.assign({}, CELL_DEFAULT, { - row: rId, - rowspan: cellFormats.rowspan - })); - const cellLine = this.scroll.create(TableCellLine.blotName, { - row: rId, - cell: id, - rowspan: cellFormats.rowspan - }); - tableCell.appendChild(cellLine); + } + } - if (ref) { - tableRow.insertBefore(tableCell, ref); - } else { - tableRow.appendChild(tableCell); + return true; +}; + +/** + * Add a listener for a given event. + * + * @param {(String|Symbol)} event The event name. + * @param {Function} fn The listener function. + * @param {*} [context=this] The context to invoke the listener with. + * @returns {EventEmitter} `this`. + * @public + */ +EventEmitter.prototype.on = function on(event, fn, context) { + return addListener(this, event, fn, context, false); +}; + +/** + * Add a one-time listener for a given event. + * + * @param {(String|Symbol)} event The event name. + * @param {Function} fn The listener function. + * @param {*} [context=this] The context to invoke the listener with. + * @returns {EventEmitter} `this`. + * @public + */ +EventEmitter.prototype.once = function once(event, fn, context) { + return addListener(this, event, fn, context, true); +}; + +/** + * 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 {*} context Only remove the listeners that have this context. + * @param {Boolean} once Only remove one-time listeners. + * @returns {EventEmitter} `this`. + * @public + */ +EventEmitter.prototype.removeListener = function removeListener(event, fn, context, once) { + var evt = prefix ? prefix + event : event; + + if (!this._events[evt]) return this; + if (!fn) { + clearEvent(this, evt); + return this; + } + + var listeners = this._events[evt]; + + if (listeners.fn) { + if ( + listeners.fn === fn && + (!once || listeners.once) && + (!context || listeners.context === context) + ) { + clearEvent(this, 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]); } + } - affectedCells.push(tableCell); - }); // insert new tableCol + // + // 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 clearEvent(this, evt); + } - const tableCol = this.scroll.create(TableCol.blotName, true); - let colRef = isRight ? tableCols[colIndex].next : tableCols[colIndex]; + return this; +}; - if (colRef) { - tableColGroup.insertBefore(tableCol, colRef); - } else { - tableColGroup.appendChild(tableCol); +/** + * Remove all listeners, or those of the specified event. + * + * @param {(String|Symbol)} [event] The event name. + * @returns {EventEmitter} `this`. + * @public + */ +EventEmitter.prototype.removeAllListeners = function removeAllListeners(event) { + var evt; + + if (event) { + evt = prefix ? prefix + event : event; + if (this._events[evt]) clearEvent(this, 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; + +// +// Expose the prefix. +// +EventEmitter.prefixed = prefix; + +// +// Allow `EventEmitter` to be imported as module namespace. +// +EventEmitter.EventEmitter = EventEmitter; + +// +// Expose the module. +// +if (true) { + module.exports = EventEmitter; +} + + +/***/ }), +/* 39 */ +/***/ (function(module, exports) { + +module.exports = " "; + +/***/ }), +/* 40 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +var objectKeys = __webpack_require__(9); +var isArguments = __webpack_require__(16); +var is = __webpack_require__(75); +var isRegex = __webpack_require__(78); +var flags = __webpack_require__(80); +var isArray = __webpack_require__(82); +var isDate = __webpack_require__(83); +var whichBoxedPrimitive = __webpack_require__(84); +var GetIntrinsic = __webpack_require__(4); +var callBound = __webpack_require__(7); +var whichCollection = __webpack_require__(89); +var getIterator = __webpack_require__(92); +var getSideChannel = __webpack_require__(95); +var whichTypedArray = __webpack_require__(98); +var assign = __webpack_require__(101); + +var $getTime = callBound('Date.prototype.getTime'); +var gPO = Object.getPrototypeOf; +var $objToString = callBound('Object.prototype.toString'); + +var $Set = GetIntrinsic('%Set%', true); +var $mapHas = callBound('Map.prototype.has', true); +var $mapGet = callBound('Map.prototype.get', true); +var $mapSize = callBound('Map.prototype.size', true); +var $setAdd = callBound('Set.prototype.add', true); +var $setDelete = callBound('Set.prototype.delete', true); +var $setHas = callBound('Set.prototype.has', true); +var $setSize = callBound('Set.prototype.size', true); + +// taken from https://github.com/browserify/commonjs-assert/blob/bba838e9ba9e28edf3127ce6974624208502f6bc/internal/util/comparisons.js#L401-L414 +function setHasEqualElement(set, val1, opts, channel) { + var i = getIterator(set); + var result; + while ((result = i.next()) && !result.done) { + if (internalDeepEqual(val1, result.value, opts, channel)) { // eslint-disable-line no-use-before-define + // Remove the matching element to make sure we do not check that again. + $setDelete(set, result.value); + return true; } + } - modifiedCells.forEach(cell => { - const cellColspan = cell.formats().colspan; - cell.format('colspan', parseInt(cellColspan, 10) + 1); - affectedCells.push(cell); - }); - affectedCells.sort((cellA, cellB) => { - let y1 = cellA.domNode.getBoundingClientRect().y; - let y2 = cellB.domNode.getBoundingClientRect().y; - return y1 - y2; - }); - this.updateTableWidth(); - return affectedCells; + return false; +} + +// taken from https://github.com/browserify/commonjs-assert/blob/bba838e9ba9e28edf3127ce6974624208502f6bc/internal/util/comparisons.js#L416-L439 +function findLooseMatchingPrimitives(prim) { + if (typeof prim === 'undefined') { + return null; } + if (typeof prim === 'object') { // Only pass in null as object! + return void 0; + } + if (typeof prim === 'symbol') { + return false; + } + if (typeof prim === 'string' || typeof prim === 'number') { + // Loose equal entries exist only if the string is possible to convert to a regular number and not NaN. + return +prim === +prim; // eslint-disable-line no-implicit-coercion + } + return true; +} - insertRow(compareRect, isDown, editorWrapper) { - const [body] = this.descendants(TableBody); - if (body == null || body.children.head == null) return; - const tableCells = this.descendants(TableCell); - const rId = table_rowId(); - const newRow = this.scroll.create(TableRow.blotName, { - row: rId - }); - let addBelowCells = []; - let modifiedCells = []; - let affectedCells = []; - tableCells.forEach(cell => { - const cellRect = getRelativeRect(cell.domNode.getBoundingClientRect(), editorWrapper); +// taken from https://github.com/browserify/commonjs-assert/blob/bba838e9ba9e28edf3127ce6974624208502f6bc/internal/util/comparisons.js#L449-L460 +function mapMightHaveLoosePrim(a, b, prim, item, opts, channel) { + var altValue = findLooseMatchingPrimitives(prim); + if (altValue != null) { + return altValue; + } + var curB = $mapGet(b, altValue); + var looseOpts = assign({}, opts, { strict: false }); + if ( + (typeof curB === 'undefined' && !$mapHas(b, altValue)) + // eslint-disable-next-line no-use-before-define + || !internalDeepEqual(item, curB, looseOpts, channel) + ) { + return false; + } + // eslint-disable-next-line no-use-before-define + return !$mapHas(a, altValue) && internalDeepEqual(item, curB, looseOpts, channel); +} - if (isDown) { - if (Math.abs(cellRect.y1 - compareRect.y1) < ERROR_LIMIT) { - addBelowCells.push(cell); - } else if (compareRect.y1 - cellRect.y > ERROR_LIMIT && compareRect.y1 - cellRect.y1 < -ERROR_LIMIT) { - modifiedCells.push(cell); - } - } else { - if (Math.abs(cellRect.y - compareRect.y) < ERROR_LIMIT) { - addBelowCells.push(cell); - } else if (compareRect.y - cellRect.y > ERROR_LIMIT && compareRect.y - cellRect.y1 < -ERROR_LIMIT) { - modifiedCells.push(cell); - } - } - }); // ordered table cells with rect.x, fix error for inserting - // new table cell in complicated table with wrong order. +// taken from https://github.com/browserify/commonjs-assert/blob/bba838e9ba9e28edf3127ce6974624208502f6bc/internal/util/comparisons.js#L441-L447 +function setMightHaveLoosePrim(a, b, prim) { + var altValue = findLooseMatchingPrimitives(prim); + if (altValue != null) { + return altValue; + } - const sortFunc = (cellA, cellB) => { - let x1 = cellA.domNode.getBoundingClientRect().x; - let x2 = cellB.domNode.getBoundingClientRect().x; - return x1 - x2; - }; + return $setHas(b, altValue) && !$setHas(a, altValue); +} - addBelowCells.sort(sortFunc); - addBelowCells.forEach(cell => { - const cId = table_cellId(); - const cellFormats = cell.formats(); +// taken from https://github.com/browserify/commonjs-assert/blob/bba838e9ba9e28edf3127ce6974624208502f6bc/internal/util/comparisons.js#L518-L533 +function mapHasEqualEntry(set, map, key1, item1, opts, channel) { + var i = getIterator(set); + var result; + var key2; + while ((result = i.next()) && !result.done) { + key2 = result.value; + if ( + // eslint-disable-next-line no-use-before-define + internalDeepEqual(key1, key2, opts, channel) + // eslint-disable-next-line no-use-before-define + && internalDeepEqual(item1, $mapGet(map, key2), opts, channel) + ) { + $setDelete(set, key2); + return true; + } + } + + return false; +} + +function internalDeepEqual(actual, expected, options, channel) { + var opts = options || {}; + + // 7.1. All identical values are equivalent, as determined by ===. + if (opts.strict ? is(actual, expected) : actual === expected) { + return true; + } + + var actualBoxed = whichBoxedPrimitive(actual); + var expectedBoxed = whichBoxedPrimitive(expected); + if (actualBoxed !== expectedBoxed) { + return false; + } + + // 7.3. Other pairs that do not both pass typeof value == 'object', equivalence is determined by ==. + if (!actual || !expected || (typeof actual !== 'object' && typeof expected !== 'object')) { + return opts.strict ? is(actual, expected) : actual == expected; // eslint-disable-line eqeqeq + } + + /* + * 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. + */ + // see https://github.com/nodejs/node/commit/d3aafd02efd3a403d646a3044adcf14e63a88d32 for memos/channel inspiration + + var hasActual = channel.has(actual); + var hasExpected = channel.has(expected); + var sentinel; + if (hasActual && hasExpected) { + if (channel.get(actual) === channel.get(expected)) { + return true; + } + } else { + sentinel = {}; + } + if (!hasActual) { channel.set(actual, sentinel); } + if (!hasExpected) { channel.set(expected, sentinel); } + + // eslint-disable-next-line no-use-before-define + return objEquiv(actual, expected, opts, channel); +} + +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 !!(x.constructor && x.constructor.isBuffer && x.constructor.isBuffer(x)); +} + +function setEquiv(a, b, opts, channel) { + if ($setSize(a) !== $setSize(b)) { + return false; + } + var iA = getIterator(a); + var iB = getIterator(b); + var resultA; + var resultB; + var set; + while ((resultA = iA.next()) && !resultA.done) { + if (resultA.value && typeof resultA.value === 'object') { + if (!set) { set = new $Set(); } + $setAdd(set, resultA.value); + } else if (!$setHas(b, resultA.value)) { + if (opts.strict) { return false; } + if (!setMightHaveLoosePrim(a, b, resultA.value)) { + return false; + } + if (!set) { set = new $Set(); } + $setAdd(set, resultA.value); + } + } + if (set) { + while ((resultB = iB.next()) && !resultB.done) { + // We have to check if a primitive value is already matching and only if it's not, go hunting for it. + if (resultB.value && typeof resultB.value === 'object') { + if (!setHasEqualElement(set, resultB.value, opts.strict, channel)) { + return false; + } + } else if ( + !opts.strict + && !$setHas(a, resultB.value) + && !setHasEqualElement(set, resultB.value, opts.strict, channel) + ) { + return false; + } + } + return $setSize(set) === 0; + } + return true; +} + +function mapEquiv(a, b, opts, channel) { + if ($mapSize(a) !== $mapSize(b)) { + return false; + } + var iA = getIterator(a); + var iB = getIterator(b); + var resultA; + var resultB; + var set; + var key; + var item1; + var item2; + while ((resultA = iA.next()) && !resultA.done) { + key = resultA.value[0]; + item1 = resultA.value[1]; + if (key && typeof key === 'object') { + if (!set) { set = new $Set(); } + $setAdd(set, key); + } else { + item2 = $mapGet(b, key); + if ((typeof item2 === 'undefined' && !$mapHas(b, key)) || !internalDeepEqual(item1, item2, opts, channel)) { + if (opts.strict) { + return false; + } + if (!mapMightHaveLoosePrim(a, b, key, item1, opts, channel)) { + return false; + } + if (!set) { set = new $Set(); } + $setAdd(set, key); + } + } + } + + if (set) { + while ((resultB = iB.next()) && !resultB.done) { + key = resultB.value[0]; + item2 = resultB.value[1]; + if (key && typeof key === 'object') { + if (!mapHasEqualEntry(set, a, key, item2, opts, channel)) { + return false; + } + } else if ( + !opts.strict + && (!a.has(key) || !internalDeepEqual($mapGet(a, key), item2, opts, channel)) + && !mapHasEqualEntry(set, a, key, item2, assign({}, opts, { strict: false }), channel) + ) { + return false; + } + } + return $setSize(set) === 0; + } + return true; +} + +function objEquiv(a, b, opts, channel) { + /* eslint max-statements: [2, 100], max-lines-per-function: [2, 120], max-depth: [2, 5] */ + var i, key; + + if (typeof a !== typeof b) { return false; } + if (a == null || b == null) { return false; } + + if ($objToString(a) !== $objToString(b)) { return false; } + + if (isArguments(a) !== isArguments(b)) { return false; } + + var aIsArray = isArray(a); + var bIsArray = isArray(b); + if (aIsArray !== bIsArray) { return false; } + + // TODO: replace when a cross-realm brand check is available + var aIsError = a instanceof Error; + var bIsError = b instanceof Error; + if (aIsError !== bIsError) { return false; } + if (aIsError || bIsError) { + if (a.name !== b.name || a.message !== b.message) { return false; } + } + + var aIsRegex = isRegex(a); + var bIsRegex = isRegex(b); + if (aIsRegex !== bIsRegex) { return false; } + if ((aIsRegex || bIsRegex) && (a.source !== b.source || flags(a) !== flags(b))) { + return false; + } + + var aIsDate = isDate(a); + var bIsDate = isDate(b); + if (aIsDate !== bIsDate) { return false; } + if (aIsDate || bIsDate) { // && would work too, because both are true or both false here + if ($getTime(a) !== $getTime(b)) { return false; } + } + if (opts.strict && gPO && gPO(a) !== gPO(b)) { return false; } + + if (whichTypedArray(a) !== whichTypedArray(b)) { + return false; + } + + var aIsBuffer = isBuffer(a); + var bIsBuffer = isBuffer(b); + if (aIsBuffer !== bIsBuffer) { return false; } + if (aIsBuffer || bIsBuffer) { // && would work too, because both are true or both false here + if (a.length !== b.length) { return false; } + for (i = 0; i < a.length; i++) { + if (a[i] !== b[i]) { return false; } + } + return true; + } + + if (typeof a !== typeof b) { return false; } + + var ka = objectKeys(a); + var kb = objectKeys(b); + // 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; } // eslint-disable-line eqeqeq + } + + // equivalent values for every corresponding key, and ~~~possibly expensive deep test + for (i = ka.length - 1; i >= 0; i--) { + key = ka[i]; + if (!internalDeepEqual(a[key], b[key], opts, channel)) { return false; } + } + + var aCollection = whichCollection(a); + var bCollection = whichCollection(b); + if (aCollection !== bCollection) { + return false; + } + if (aCollection === 'Set' || bCollection === 'Set') { // aCollection === bCollection + return setEquiv(a, b, opts, channel); + } + if (aCollection === 'Map') { // aCollection === bCollection + return mapEquiv(a, b, opts, channel); + } + + return true; +} + +module.exports = function deepEqual(a, b, opts) { + return internalDeepEqual(a, b, opts, getSideChannel()); +}; + + +/***/ }), +/* 41 */ +/***/ (function(module, exports) { + +module.exports = " "; + +/***/ }), +/* 42 */ +/***/ (function(module, exports) { + +module.exports = " "; + +/***/ }), +/* 43 */ +/***/ (function(module, exports) { + +module.exports = " "; + +/***/ }), +/* 44 */ +/***/ (function(module, exports) { + +module.exports = " "; + +/***/ }), +/* 45 */ +/***/ (function(module, exports) { + +module.exports = " "; + +/***/ }), +/* 46 */ +/***/ (function(module, exports) { + +module.exports = " "; + +/***/ }), +/* 47 */ +/***/ (function(module, exports) { + +module.exports = " "; + +/***/ }), +/* 48 */ +/***/ (function(module, exports) { + +module.exports = " "; + +/***/ }), +/* 49 */ +/***/ (function(module, exports) { + +module.exports = " "; + +/***/ }), +/* 50 */ +/***/ (function(module, exports) { + +module.exports = " "; + +/***/ }), +/* 51 */ +/***/ (function(module, exports) { + +module.exports = " "; + +/***/ }), +/* 52 */ +/***/ (function(module, exports) { + +module.exports = " "; + +/***/ }), +/* 53 */ +/***/ (function(module, exports) { + +module.exports = " "; + +/***/ }), +/* 54 */ +/***/ (function(module, exports) { + +module.exports = " "; + +/***/ }), +/* 55 */ +/***/ (function(module, exports) { + +module.exports = " "; + +/***/ }), +/* 56 */ +/***/ (function(module, exports) { + +module.exports = " "; + +/***/ }), +/* 57 */ +/***/ (function(module, exports) { + +module.exports = " "; + +/***/ }), +/* 58 */ +/***/ (function(module, exports) { + +module.exports = " "; + +/***/ }), +/* 59 */ +/***/ (function(module, exports) { + +module.exports = " "; + +/***/ }), +/* 60 */ +/***/ (function(module, exports) { + +module.exports = " "; + +/***/ }), +/* 61 */ +/***/ (function(module, exports) { + +module.exports = " "; + +/***/ }), +/* 62 */ +/***/ (function(module, exports) { + +module.exports = " "; + +/***/ }), +/* 63 */ +/***/ (function(module, exports) { + +module.exports = " "; + +/***/ }), +/* 64 */ +/***/ (function(module, exports) { + +module.exports = " "; + +/***/ }), +/* 65 */ +/***/ (function(module, exports) { + +module.exports = " "; + +/***/ }), +/* 66 */ +/***/ (function(module, exports) { + +module.exports = " "; + +/***/ }), +/* 67 */ +/***/ (function(module, exports) { + +module.exports = " "; + +/***/ }), +/* 68 */ +/***/ (function(module, exports) { + +module.exports = " "; + +/***/ }), +/* 69 */ +/***/ (function(module, __webpack_exports__, __webpack_require__) { + +"use strict"; +// ESM COMPAT FLAG +__webpack_require__.r(__webpack_exports__); + +// EXTERNAL MODULE: ./node_modules/extend/index.js +var extend = __webpack_require__(3); +var extend_default = /*#__PURE__*/__webpack_require__.n(extend); + +// EXTERNAL MODULE: external {"commonjs":"quill","commonjs2":"quill","amd":"quill","root":"Quill"} +var external_commonjs_quill_commonjs2_quill_amd_quill_root_Quill_ = __webpack_require__(0); +var external_commonjs_quill_commonjs2_quill_amd_quill_root_Quill_default = /*#__PURE__*/__webpack_require__.n(external_commonjs_quill_commonjs2_quill_amd_quill_root_Quill_); + +// CONCATENATED MODULE: ./src/utils/index.js +function css(domNode, rules) { + if (typeof rules === 'object') { + for (let prop in rules) { + domNode.style[prop] = rules[prop]; + } + } +} +/** + * getRelativeRect + * @param {Object} targetRect rect data for target element + * @param {Element} container container element + * @return {Object} an object with rect data + */ + +function getRelativeRect(targetRect, container) { + let containerRect = container.getBoundingClientRect(); + return { + x: targetRect.x - containerRect.x - container.scrollLeft, + y: targetRect.y - containerRect.y - container.scrollTop, + x1: targetRect.x - containerRect.x - container.scrollLeft + targetRect.width, + y1: targetRect.y - containerRect.y - container.scrollTop + targetRect.height, + width: targetRect.width, + height: targetRect.height + }; +} +/** + * _omit + * @param {Object} obj target Object + * @param {Array} uselessKeys keys of removed properties + * @return {Object} new Object without useless properties + */ + +function _omit(obj, uselessKeys) { + return obj && Object.keys(obj).reduce((acc, key) => { + return uselessKeys.includes(key) ? acc : Object.assign({}, acc, { + [key]: obj[key] + }); + }, {}); +} +/** + * getEventComposedPath + * compatibility fixed for Event.path/Event.composedPath + * Event.path is only for chrome/opera + * Event.composedPath is for Safari, FF + * Neither for Micro Edge + * @param {Event} evt + * @return {Array} an array of event.path + */ + +function getEventComposedPath(evt) { + let path; // chrome, opera, safari, firefox + + path = evt.path || evt.composedPath && evt.composedPath(); // other: edge + + if (path == undefined && evt.target) { + path = []; + let target = evt.target; + path.push(target); + + while (target && target.parentNode) { + target = target.parentNode; + path.push(target); + } + } + + return path; +} +function convertToHex(rgb) { + var reg = /^#([0-9a-fA-f]{3}|[0-9a-fA-f]{6})$/; // if rgb + + if (/^(rgb|RGB)/.test(rgb)) { + var color = rgb.toString().match(/\d+/g); + var hex = "#"; + + for (var i = 0; i < 3; i++) { + hex += ("0" + Number(color[i]).toString(16)).slice(-2); + } + + return hex; + } else if (reg.test(rgb)) { + var aNum = rgb.replace(/#/, "").split(""); + + if (aNum.length === 6) { + return rgb; + } else if (aNum.length === 3) { + var numHex = "#"; + + for (var i = 0; i < aNum.length; i += 1) { + numHex += aNum[i] + aNum[i]; + } + + return numHex; + } + } + + return rgb; +} +// CONCATENATED MODULE: ./src/modules/table-column-tool.js + + +const COL_TOOL_HEIGHT = 12; +const COL_TOOL_CELL_HEIGHT = 12; +const ROW_TOOL_WIDTH = 12; +const CELL_MIN_WIDTH = 50; +const PRIMARY_COLOR = '#35A7ED'; +class table_column_tool_TableColumnTool { + constructor(table, quill, options) { + if (!table) return null; + this.table = table; + this.quill = quill; + this.options = options; + this.domNode = null; + this.initColTool(); + } + + initColTool() { + const parent = this.quill.root.parentNode; + const tableRect = this.table.getBoundingClientRect(); + const containerRect = parent.getBoundingClientRect(); + const tableViewRect = this.table.parentNode.getBoundingClientRect(); + this.domNode = document.createElement('div'); + this.domNode.classList.add('qlbt-col-tool'); + this.updateToolCells(); + parent.appendChild(this.domNode); + css(this.domNode, { + width: "".concat(tableViewRect.width, "px"), + height: "".concat(COL_TOOL_HEIGHT, "px"), + left: "".concat(tableViewRect.left - containerRect.left + parent.scrollLeft, "px"), + top: "".concat(tableViewRect.top - containerRect.top + parent.scrollTop - COL_TOOL_HEIGHT - 5, "px") + }); + } + + createToolCell() { + const toolCell = document.createElement('div'); + toolCell.classList.add('qlbt-col-tool-cell'); + const resizeHolder = document.createElement('div'); + resizeHolder.classList.add('qlbt-col-tool-cell-holder'); + css(toolCell, { + 'height': "".concat(COL_TOOL_CELL_HEIGHT, "px") + }); + toolCell.appendChild(resizeHolder); + return toolCell; + } + + updateToolCells() { + const tableContainer = external_commonjs_quill_commonjs2_quill_amd_quill_root_Quill_default.a.find(this.table); + const CellsInFirstRow = tableContainer.children.tail.children.head.children; + const tableCols = tableContainer.colGroup().children; + const cellsNumber = computeCellsNumber(CellsInFirstRow); + let existCells = Array.from(this.domNode.querySelectorAll('.qlbt-col-tool-cell')); + + for (let index = 0; index < Math.max(cellsNumber, existCells.length); index++) { + let col = tableCols.at(index); + let colWidth = col && parseInt(col.formats()[col.statics.blotName].width, 10); // if cell already exist + + let toolCell = null; + + if (!existCells[index]) { + toolCell = this.createToolCell(); + this.domNode.appendChild(toolCell); + this.addColCellHolderHandler(toolCell); // set tool cell min-width + + css(toolCell, { + 'min-width': "".concat(colWidth, "px") + }); + } else if (existCells[index] && index >= cellsNumber) { + existCells[index].remove(); + } else { + toolCell = existCells[index]; // set tool cell min-width + + css(toolCell, { + 'min-width': "".concat(colWidth, "px") + }); + } + } + } + + destroy() { + this.domNode.remove(); + return null; + } + + addColCellHolderHandler(cell) { + const tableContainer = external_commonjs_quill_commonjs2_quill_amd_quill_root_Quill_default.a.find(this.table); + const $holder = cell.querySelector(".qlbt-col-tool-cell-holder"); + let dragging = false; + let x0 = 0; + let x = 0; + let delta = 0; + let width0 = 0; // helpLine relation varrible + + let tableRect = {}; + let cellRect = {}; + let $helpLine = null; + + const handleDrag = e => { + e.preventDefault(); + + if (dragging) { + x = e.clientX; + + if (width0 + x - x0 >= CELL_MIN_WIDTH) { + delta = x - x0; + } else { + delta = CELL_MIN_WIDTH - width0; + } + + css($helpLine, { + 'left': "".concat(cellRect.left + cellRect.width - 1 + delta, "px") + }); + } + }; + + const handleMouseup = e => { + e.preventDefault(); + const existCells = Array.from(this.domNode.querySelectorAll('.qlbt-col-tool-cell')); + const colIndex = existCells.indexOf(cell); + const colBlot = tableContainer.colGroup().children.at(colIndex); + + if (dragging) { + colBlot.format('width', width0 + delta); + css(cell, { + 'min-width': "".concat(width0 + delta, "px") + }); + x0 = 0; + x = 0; + delta = 0; + width0 = 0; + dragging = false; + $holder.classList.remove('dragging'); + } + + document.removeEventListener('mousemove', handleDrag, false); + document.removeEventListener('mouseup', handleMouseup, false); + tableRect = {}; + cellRect = {}; + $helpLine.remove(); + $helpLine = null; + tableContainer.updateTableWidth(); + const tableSelection = this.quill.getModule('better-table').tableSelection; + tableSelection && tableSelection.clearSelection(); + }; + + const handleMousedown = e => { + document.addEventListener('mousemove', handleDrag, false); + document.addEventListener('mouseup', handleMouseup, false); + tableRect = this.table.getBoundingClientRect(); + cellRect = cell.getBoundingClientRect(); + $helpLine = document.createElement('div'); + css($helpLine, { + position: 'fixed', + top: "".concat(cellRect.top, "px"), + left: "".concat(cellRect.left + cellRect.width - 1, "px"), + zIndex: '100', + height: "".concat(tableRect.height + COL_TOOL_HEIGHT + 4, "px"), + width: '1px', + backgroundColor: PRIMARY_COLOR + }); + document.body.appendChild($helpLine); + dragging = true; + x0 = e.clientX; + width0 = cellRect.width; + $holder.classList.add('dragging'); + }; + + $holder.addEventListener('mousedown', handleMousedown, false); + } + + colToolCells() { + return Array.from(this.domNode.querySelectorAll('.qlbt-col-tool-cell')); + } + +} + +function computeCellsNumber(CellsInFirstRow) { + return CellsInFirstRow.reduce((sum, cell) => { + const cellColspan = cell.formats().colspan; + sum = sum + parseInt(cellColspan, 10); + return sum; + }, 0); +} +// CONCATENATED MODULE: ./src/formats/header.js + + +const Block = external_commonjs_quill_commonjs2_quill_amd_quill_root_Quill_default.a.import("blots/block"); + +class header_Header extends Block { + static create(value) { + if (typeof value === 'string') { + value = { + value + }; + } + + const node = super.create(value.value); + CELL_IDENTITY_KEYS.forEach(key => { + if (value[key]) node.setAttribute("data-".concat(key), value[key]); + }); + CELL_ATTRIBUTES.forEach(key => { + if (value[key]) node.setAttribute("data-".concat(key), value[key]); + }); + return node; + } + + static formats(domNode) { + const formats = {}; + formats.value = this.tagName.indexOf(domNode.tagName) + 1; + return CELL_ATTRIBUTES.concat(CELL_IDENTITY_KEYS).reduce((formats, attribute) => { + if (domNode.hasAttribute("data-".concat(attribute))) { + formats[attribute] = domNode.getAttribute("data-".concat(attribute)) || undefined; + } + + return formats; + }, formats); + } + + format(name, value) { + const { + row, + cell, + rowspan, + colspan + } = header_Header.formats(this.domNode); + + if (name === header_Header.blotName) { + if (value) { + super.format(name, { + value, + row, + cell, + rowspan, + colspan + }); + } else { + if (row) { + this.replaceWith(TableCellLine.blotName, { + row, + cell, + rowspan, + colspan + }); + } else { + super.format(name, value); + } + } + } else { + super.format(name, value); + } + } + + optimize(context) { + const { + row, + rowspan, + colspan + } = header_Header.formats(this.domNode); + + if (row && !(this.parent instanceof TableCell)) { + this.wrap(TableCell.blotName, { + row, + colspan, + rowspan + }); + } // ShadowBlot optimize + + + this.enforceAllowedChildren(); + + if (this.uiNode != null && this.uiNode !== this.domNode.firstChild) { + this.domNode.insertBefore(this.uiNode, this.domNode.firstChild); + } + + if (this.children.length === 0) { + if (this.statics.defaultChild != null) { + const child = this.scroll.create(this.statics.defaultChild.blotName); + this.appendChild(child); // TODO double check if necessary + // child.optimize(context); + } else { + this.remove(); + } + } // Block optimize + + + this.cache = {}; + } + +} + +header_Header.blotName = 'header'; +header_Header.tagName = ['H1', 'H2', 'H3', 'H4', 'H5', 'H6']; +/* harmony default export */ var header = (header_Header); +// CONCATENATED MODULE: ./src/formats/table.js + + + +const table_Break = external_commonjs_quill_commonjs2_quill_amd_quill_root_Quill_default.a.import("blots/break"); +const table_Block = external_commonjs_quill_commonjs2_quill_amd_quill_root_Quill_default.a.import("blots/block"); +const Container = external_commonjs_quill_commonjs2_quill_amd_quill_root_Quill_default.a.import("blots/container"); +const COL_ATTRIBUTES = ["width"]; +const COL_DEFAULT = { + width: 100 +}; +const CELL_IDENTITY_KEYS = ["row", "cell"]; +const CELL_ATTRIBUTES = ["rowspan", "colspan"]; +const CELL_DEFAULT = { + rowspan: 1, + colspan: 1 +}; +const ERROR_LIMIT = 5; + +class TableCellLine extends table_Block { + static create(value) { + const node = super.create(value); + CELL_IDENTITY_KEYS.forEach(key => { + let identityMaker = key === 'row' ? table_rowId : table_cellId; + node.setAttribute("data-".concat(key), value[key] || identityMaker()); + }); + CELL_ATTRIBUTES.forEach(attrName => { + node.setAttribute("data-".concat(attrName), value[attrName] || CELL_DEFAULT[attrName]); + }); + + if (value['cell-bg']) { + node.setAttribute('data-cell-bg', value['cell-bg']); + } + + return node; + } + + static formats(domNode) { + const formats = {}; + return CELL_ATTRIBUTES.concat(CELL_IDENTITY_KEYS).concat(['cell-bg']).reduce((formats, attribute) => { + if (domNode.hasAttribute("data-".concat(attribute))) { + formats[attribute] = domNode.getAttribute("data-".concat(attribute)) || undefined; + } + + return formats; + }, formats); + } + + format(name, value) { + if (CELL_ATTRIBUTES.concat(CELL_IDENTITY_KEYS).indexOf(name) > -1) { + if (value) { + this.domNode.setAttribute("data-".concat(name), value); + } else { + this.domNode.removeAttribute("data-".concat(name)); + } + } else if (name === 'cell-bg') { + if (value) { + this.domNode.setAttribute('data-cell-bg', value); + } else { + this.domNode.removeAttribute('data-cell-bg'); + } + } else if (name === 'header') { + if (!value) return; + const { + row, + cell, + rowspan, + colspan + } = TableCellLine.formats(this.domNode); + super.format(name, { + value, + row, + cell, + rowspan, + colspan + }); + } else { + super.format(name, value); + } + } + + optimize(context) { + // cover shadowBlot's wrap call, pass params parentBlot initialize + // needed + const rowId = this.domNode.getAttribute('data-row'); + const rowspan = this.domNode.getAttribute('data-rowspan'); + const colspan = this.domNode.getAttribute('data-colspan'); + const cellBg = this.domNode.getAttribute('data-cell-bg'); + + if (this.statics.requiredContainer && !(this.parent instanceof this.statics.requiredContainer)) { + this.wrap(this.statics.requiredContainer.blotName, { + row: rowId, + colspan, + rowspan, + 'cell-bg': cellBg + }); + } + + super.optimize(context); + } + + tableCell() { + return this.parent; + } + +} + +TableCellLine.blotName = "table-cell-line"; +TableCellLine.ClassName = "qlbt-cell-line"; +TableCellLine.tagName = "DIV"; + +class TableCell extends Container { + checkMerge() { + if (super.checkMerge() && this.next.children.head != null) { + const thisHead = this.children.head.formats()[this.children.head.statics.blotName]; + const thisTail = this.children.tail.formats()[this.children.tail.statics.blotName]; + const nextHead = this.next.children.head.formats()[this.next.children.head.statics.blotName]; + const nextTail = this.next.children.tail.formats()[this.next.children.tail.statics.blotName]; + return thisHead.cell === thisTail.cell && thisHead.cell === nextHead.cell && thisHead.cell === nextTail.cell; + } + + return false; + } + + static create(value) { + const node = super.create(value); + node.setAttribute("data-row", value.row); + CELL_ATTRIBUTES.forEach(attrName => { + if (value[attrName]) { + node.setAttribute(attrName, value[attrName]); + } + }); + + if (value['cell-bg']) { + node.setAttribute('data-cell-bg', value['cell-bg']); + node.style.backgroundColor = value['cell-bg']; + } + + return node; + } + + static formats(domNode) { + const formats = {}; + + if (domNode.hasAttribute("data-row")) { + formats["row"] = domNode.getAttribute("data-row"); + } + + if (domNode.hasAttribute("data-cell-bg")) { + formats["cell-bg"] = domNode.getAttribute("data-cell-bg"); + } + + return CELL_ATTRIBUTES.reduce((formats, attribute) => { + if (domNode.hasAttribute(attribute)) { + formats[attribute] = domNode.getAttribute(attribute); + } + + return formats; + }, formats); + } + + cellOffset() { + if (this.parent) { + return this.parent.children.indexOf(this); + } + + return -1; + } + + formats() { + const formats = {}; + + if (this.domNode.hasAttribute("data-row")) { + formats["row"] = this.domNode.getAttribute("data-row"); + } + + if (this.domNode.hasAttribute("data-cell-bg")) { + formats["cell-bg"] = this.domNode.getAttribute("data-cell-bg"); + } + + return CELL_ATTRIBUTES.reduce((formats, attribute) => { + if (this.domNode.hasAttribute(attribute)) { + formats[attribute] = this.domNode.getAttribute(attribute); + } + + return formats; + }, formats); + } + + toggleAttribute(name, value) { + if (value) { + this.domNode.setAttribute(name, value); + } else { + this.domNode.removeAttribute(name); + } + } + + formatChildren(name, value) { + this.children.forEach(child => { + child.format(name, value); + }); + } + + format(name, value) { + if (CELL_ATTRIBUTES.indexOf(name) > -1) { + this.toggleAttribute(name, value); + this.formatChildren(name, value); + } else if (['row'].indexOf(name) > -1) { + this.toggleAttribute("data-".concat(name), value); + this.formatChildren(name, value); + } else if (name === 'cell-bg') { + this.toggleAttribute('data-cell-bg', value); + this.formatChildren(name, value); + + if (value) { + this.domNode.style.backgroundColor = value; + } else { + this.domNode.style.backgroundColor = 'initial'; + } + } else { + super.format(name, value); + } + } + + optimize(context) { + const rowId = this.domNode.getAttribute("data-row"); + + if (this.statics.requiredContainer && !(this.parent instanceof this.statics.requiredContainer)) { + this.wrap(this.statics.requiredContainer.blotName, { + row: rowId + }); + } + + super.optimize(context); + } + + row() { + return this.parent; + } + + rowOffset() { + if (this.row()) { + return this.row().rowOffset(); + } + + return -1; + } + + table() { + return this.row() && this.row().table(); + } + +} + +TableCell.blotName = "table"; +TableCell.tagName = "TD"; + +class TableRow extends Container { + checkMerge() { + if (super.checkMerge() && this.next.children.head != null) { + const thisHead = this.children.head.formats(); + const thisTail = this.children.tail.formats(); + const nextHead = this.next.children.head.formats(); + const nextTail = this.next.children.tail.formats(); + return thisHead.row === thisTail.row && thisHead.row === nextHead.row && thisHead.row === nextTail.row; + } + + return false; + } + + static create(value) { + const node = super.create(value); + node.setAttribute("data-row", value.row); + return node; + } + + formats() { + return ["row"].reduce((formats, attrName) => { + if (this.domNode.hasAttribute("data-".concat(attrName))) { + formats[attrName] = this.domNode.getAttribute("data-".concat(attrName)); + } + + return formats; + }, {}); + } + + optimize(context) { + // optimize function of ShadowBlot + if (this.statics.requiredContainer && !(this.parent instanceof this.statics.requiredContainer)) { + this.wrap(this.statics.requiredContainer.blotName); + } // optimize function of ParentBlot + // note: modified this optimize function because + // TableRow should not be removed when the length of its children was 0 + + + this.enforceAllowedChildren(); + + if (this.uiNode != null && this.uiNode !== this.domNode.firstChild) { + this.domNode.insertBefore(this.uiNode, this.domNode.firstChild); + } // optimize function of ContainerBlot + + + if (this.children.length > 0 && this.next != null && this.checkMerge()) { + this.next.moveChildren(this); + this.next.remove(); + } + } + + rowOffset() { + if (this.parent) { + return this.parent.children.indexOf(this); + } + + return -1; + } + + table() { + return this.parent && this.parent.parent; + } + +} + +TableRow.blotName = "table-row"; +TableRow.tagName = "TR"; + +class TableBody extends Container {} + +TableBody.blotName = "table-body"; +TableBody.tagName = "TBODY"; + +class TableCol extends table_Block { + static create(value) { + let node = super.create(value); + COL_ATTRIBUTES.forEach(attrName => { + node.setAttribute("".concat(attrName), value[attrName] || COL_DEFAULT[attrName]); + }); + return node; + } + + static formats(domNode) { + return COL_ATTRIBUTES.reduce((formats, attribute) => { + if (domNode.hasAttribute("".concat(attribute))) { + formats[attribute] = domNode.getAttribute("".concat(attribute)) || undefined; + } + + return formats; + }, {}); + } + + format(name, value) { + if (COL_ATTRIBUTES.indexOf(name) > -1) { + this.domNode.setAttribute("".concat(name), value || COL_DEFAULT[name]); + } else { + super.format(name, value); + } + } + + html() { + return this.domNode.outerHTML; + } + +} + +TableCol.blotName = "table-col"; +TableCol.tagName = "col"; + +class TableColGroup extends Container {} + +TableColGroup.blotName = "table-col-group"; +TableColGroup.tagName = "colgroup"; + +class table_TableContainer extends Container { + static create() { + let node = super.create(); + return node; + } + + constructor(scroll, domNode) { + super(scroll, domNode); + this.updateTableWidth(); + } + + updateTableWidth() { + setTimeout(() => { + const colGroup = this.colGroup(); + if (!colGroup) return; + const tableWidth = colGroup.children.reduce((sumWidth, col) => { + sumWidth = sumWidth + parseInt(col.formats()[TableCol.blotName].width, 10); + return sumWidth; + }, 0); + this.domNode.style.width = "".concat(tableWidth, "px"); + }, 0); + } + + cells(column) { + return this.rows().map(row => row.children.at(column)); + } + + colGroup() { + return this.children.head; + } + + deleteColumns(compareRect, delIndexes = [], editorWrapper) { + const [body] = this.descendants(TableBody); + if (body == null || body.children.head == null) return; + const tableCells = this.descendants(TableCell); + const removedCells = []; + const modifiedCells = []; + tableCells.forEach(cell => { + const cellRect = getRelativeRect(cell.domNode.getBoundingClientRect(), editorWrapper); + + if (cellRect.x + ERROR_LIMIT > compareRect.x && cellRect.x1 - ERROR_LIMIT < compareRect.x1) { + removedCells.push(cell); + } else if (cellRect.x < compareRect.x + ERROR_LIMIT && cellRect.x1 > compareRect.x1 - ERROR_LIMIT) { + modifiedCells.push(cell); + } + }); + + if (removedCells.length === tableCells.length) { + this.tableDestroy(); + return true; + } // remove the matches column tool cell + + + delIndexes.forEach(delIndex => { + this.colGroup().children.at(delIndexes[0]).remove(); + }); + removedCells.forEach(cell => { + cell.remove(); + }); + modifiedCells.forEach(cell => { + const cellColspan = parseInt(cell.formats().colspan, 10); + const cellWidth = parseInt(cell.formats().width, 10); + cell.format('colspan', cellColspan - delIndexes.length); + }); + this.updateTableWidth(); + } + + deleteRow(compareRect, editorWrapper) { + const [body] = this.descendants(TableBody); + if (body == null || body.children.head == null) return; + const tableCells = this.descendants(TableCell); + const tableRows = this.descendants(TableRow); + const removedCells = []; // cells to be removed + + const modifiedCells = []; // cells to be modified + + const fallCells = []; // cells to fall into next row + // compute rows to remove + // bugfix: #21 There will be a empty tr left if delete the last row of a table + + const removedRows = tableRows.filter(row => { + const rowRect = getRelativeRect(row.domNode.getBoundingClientRect(), editorWrapper); + return rowRect.y > compareRect.y - ERROR_LIMIT && rowRect.y1 < compareRect.y1 + ERROR_LIMIT; + }); + tableCells.forEach(cell => { + const cellRect = getRelativeRect(cell.domNode.getBoundingClientRect(), editorWrapper); + + if (cellRect.y > compareRect.y - ERROR_LIMIT && cellRect.y1 < compareRect.y1 + ERROR_LIMIT) { + removedCells.push(cell); + } else if (cellRect.y < compareRect.y + ERROR_LIMIT && cellRect.y1 > compareRect.y1 - ERROR_LIMIT) { + modifiedCells.push(cell); + + if (Math.abs(cellRect.y - compareRect.y) < ERROR_LIMIT) { + fallCells.push(cell); + } + } + }); + + if (removedCells.length === tableCells.length) { + this.tableDestroy(); + return; + } // compute length of removed rows + + + const removedRowsLength = this.rows().reduce((sum, row) => { + let rowRect = getRelativeRect(row.domNode.getBoundingClientRect(), editorWrapper); + + if (rowRect.y > compareRect.y - ERROR_LIMIT && rowRect.y1 < compareRect.y1 + ERROR_LIMIT) { + sum += 1; + } + + return sum; + }, 0); // it must excute before the table layout changed with other operation + + fallCells.forEach(cell => { + const cellRect = getRelativeRect(cell.domNode.getBoundingClientRect(), editorWrapper); + const nextRow = cell.parent.next; + const cellsInNextRow = nextRow.children; + const refCell = cellsInNextRow.reduce((ref, compareCell) => { + const compareRect = getRelativeRect(compareCell.domNode.getBoundingClientRect(), editorWrapper); + + if (Math.abs(cellRect.x1 - compareRect.x) < ERROR_LIMIT) { + ref = compareCell; + } + + return ref; + }, null); + nextRow.insertBefore(cell, refCell); + cell.format('row', nextRow.formats().row); + }); + removedCells.forEach(cell => { + cell.remove(); + }); + modifiedCells.forEach(cell => { + const cellRowspan = parseInt(cell.formats().rowspan, 10); + cell.format("rowspan", cellRowspan - removedRowsLength); + }); // remove selected rows + + removedRows.forEach(row => row.remove()); + } + + tableDestroy() { + const quill = external_commonjs_quill_commonjs2_quill_amd_quill_root_Quill_default.a.find(this.scroll.domNode.parentNode); + const tableModule = quill.getModule("better-table"); + this.remove(); + tableModule.hideTableTools(); + quill.update(external_commonjs_quill_commonjs2_quill_amd_quill_root_Quill_default.a.sources.USER); + } + + insertCell(tableRow, ref) { + const id = table_cellId(); + const rId = tableRow.formats().row; + const tableCell = this.scroll.create(TableCell.blotName, Object.assign({}, CELL_DEFAULT, { + row: rId + })); + const cellLine = this.scroll.create(TableCellLine.blotName, { + row: rId, + cell: id + }); + tableCell.appendChild(cellLine); + + if (ref) { + tableRow.insertBefore(tableCell, ref); + } else { + tableRow.appendChild(tableCell); + } + } + + insertColumn(compareRect, colIndex, isRight = true, editorWrapper) { + const [body] = this.descendants(TableBody); + const [tableColGroup] = this.descendants(TableColGroup); + const tableCols = this.descendants(TableCol); + let addAsideCells = []; + let modifiedCells = []; + let affectedCells = []; + if (body == null || body.children.head == null) return; + const tableCells = this.descendants(TableCell); + tableCells.forEach(cell => { + const cellRect = getRelativeRect(cell.domNode.getBoundingClientRect(), editorWrapper); + + if (isRight) { + if (Math.abs(cellRect.x1 - compareRect.x1) < ERROR_LIMIT) { + // the right of selected boundary equal to the right of table cell, + // add a new table cell right aside this table cell + addAsideCells.push(cell); + } else if (compareRect.x1 - cellRect.x > ERROR_LIMIT && compareRect.x1 - cellRect.x1 < -ERROR_LIMIT) { + // the right of selected boundary is inside this table cell + // colspan of this table cell will increase 1 + modifiedCells.push(cell); + } + } else { + if (Math.abs(cellRect.x - compareRect.x) < ERROR_LIMIT) { + // left of selected boundary equal to left of table cell, + // add a new table cell left aside this table cell + addAsideCells.push(cell); + } else if (compareRect.x - cellRect.x > ERROR_LIMIT && compareRect.x - cellRect.x1 < -ERROR_LIMIT) { + // the left of selected boundary is inside this table cell + // colspan of this table cell will increase 1 + modifiedCells.push(cell); + } + } + }); + addAsideCells.forEach(cell => { + const ref = isRight ? cell.next : cell; + const id = table_cellId(); + const tableRow = cell.parent; + const rId = tableRow.formats().row; + const cellFormats = cell.formats(); + const tableCell = this.scroll.create(TableCell.blotName, Object.assign({}, CELL_DEFAULT, { + row: rId, + rowspan: cellFormats.rowspan + })); + const cellLine = this.scroll.create(TableCellLine.blotName, { + row: rId, + cell: id, + rowspan: cellFormats.rowspan + }); + tableCell.appendChild(cellLine); + + if (ref) { + tableRow.insertBefore(tableCell, ref); + } else { + tableRow.appendChild(tableCell); + } + + affectedCells.push(tableCell); + }); // insert new tableCol + + const tableCol = this.scroll.create(TableCol.blotName, true); + let colRef = isRight ? tableCols[colIndex].next : tableCols[colIndex]; + + if (colRef) { + tableColGroup.insertBefore(tableCol, colRef); + } else { + tableColGroup.appendChild(tableCol); + } + + modifiedCells.forEach(cell => { + const cellColspan = cell.formats().colspan; + cell.format('colspan', parseInt(cellColspan, 10) + 1); + affectedCells.push(cell); + }); + affectedCells.sort((cellA, cellB) => { + let y1 = cellA.domNode.getBoundingClientRect().y; + let y2 = cellB.domNode.getBoundingClientRect().y; + return y1 - y2; + }); + this.updateTableWidth(); + return affectedCells; + } + + insertRow(compareRect, isDown, editorWrapper) { + const [body] = this.descendants(TableBody); + if (body == null || body.children.head == null) return; + const tableCells = this.descendants(TableCell); + const rId = table_rowId(); + const newRow = this.scroll.create(TableRow.blotName, { + row: rId + }); + let addBelowCells = []; + let modifiedCells = []; + let affectedCells = []; + tableCells.forEach(cell => { + const cellRect = getRelativeRect(cell.domNode.getBoundingClientRect(), editorWrapper); + + if (isDown) { + if (Math.abs(cellRect.y1 - compareRect.y1) < ERROR_LIMIT) { + addBelowCells.push(cell); + } else if (compareRect.y1 - cellRect.y > ERROR_LIMIT && compareRect.y1 - cellRect.y1 < -ERROR_LIMIT) { + modifiedCells.push(cell); + } + } else { + if (Math.abs(cellRect.y - compareRect.y) < ERROR_LIMIT) { + addBelowCells.push(cell); + } else if (compareRect.y - cellRect.y > ERROR_LIMIT && compareRect.y - cellRect.y1 < -ERROR_LIMIT) { + modifiedCells.push(cell); + } + } + }); // ordered table cells with rect.x, fix error for inserting + // new table cell in complicated table with wrong order. + + const sortFunc = (cellA, cellB) => { + let x1 = cellA.domNode.getBoundingClientRect().x; + let x2 = cellB.domNode.getBoundingClientRect().x; + return x1 - x2; + }; + + addBelowCells.sort(sortFunc); + addBelowCells.forEach(cell => { + const cId = table_cellId(); + const cellFormats = cell.formats(); const tableCell = this.scroll.create(TableCell.blotName, Object.assign({}, CELL_DEFAULT, { row: rId, colspan: cellFormats.colspan @@ -1942,1302 +4266,7511 @@ class table_TableContainer extends Container { cell: cId, colspan: cellFormats.colspan }); - const empty = this.scroll.create(Break.blotName); - cellLine.appendChild(empty); - tableCell.appendChild(cellLine); - newRow.appendChild(tableCell); - affectedCells.push(tableCell); + const empty = this.scroll.create(table_Break.blotName); + cellLine.appendChild(empty); + tableCell.appendChild(cellLine); + newRow.appendChild(tableCell); + affectedCells.push(tableCell); + }); + modifiedCells.forEach(cell => { + const cellRowspan = parseInt(cell.formats().rowspan, 10); + cell.format("rowspan", cellRowspan + 1); + affectedCells.push(cell); + }); + const refRow = this.rows().find(row => { + let rowRect = getRelativeRect(row.domNode.getBoundingClientRect(), editorWrapper); + + if (isDown) { + return Math.abs(rowRect.y - compareRect.y - compareRect.height) < ERROR_LIMIT; + } else { + return Math.abs(rowRect.y - compareRect.y) < ERROR_LIMIT; + } + }); + body.insertBefore(newRow, refRow); // reordering affectedCells + + affectedCells.sort(sortFunc); + return affectedCells; + } + + mergeCells(compareRect, mergingCells, rowspan, colspan, editorWrapper) { + const mergedCell = mergingCells.reduce((result, tableCell, index) => { + if (index !== 0) { + result && tableCell.moveChildren(result); + tableCell.remove(); + } else { + tableCell.format('colspan', colspan); + tableCell.format('rowspan', rowspan); + result = tableCell; + } + + return result; + }, null); + let rowId = mergedCell.domNode.getAttribute('data-row'); + let cellId = mergedCell.children.head.domNode.getAttribute('data-cell'); + mergedCell.children.forEach(cellLine => { + cellLine.format('cell', cellId); + cellLine.format('row', rowId); + cellLine.format('colspan', colspan); + cellLine.format('rowspan', rowspan); + }); + return mergedCell; + } + + unmergeCells(unmergingCells, editorWrapper) { + let cellFormats = {}; + let cellRowspan = 1; + let cellColspan = 1; + unmergingCells.forEach(tableCell => { + cellFormats = tableCell.formats(); + cellRowspan = cellFormats.rowspan; + cellColspan = cellFormats.colspan; + + if (cellColspan > 1) { + let ref = tableCell.next; + let row = tableCell.row(); + tableCell.format('colspan', 1); + + for (let i = cellColspan; i > 1; i--) { + this.insertCell(row, ref); + } + } + + if (cellRowspan > 1) { + let i = cellRowspan; + let nextRow = tableCell.row().next; + + while (i > 1) { + let refInNextRow = nextRow.children.reduce((result, cell) => { + let compareRect = getRelativeRect(tableCell.domNode.getBoundingClientRect(), editorWrapper); + let cellRect = getRelativeRect(cell.domNode.getBoundingClientRect(), editorWrapper); + + if (Math.abs(compareRect.x1 - cellRect.x) < ERROR_LIMIT) { + result = cell; + } + + return result; + }, null); + + for (let i = cellColspan; i > 0; i--) { + this.insertCell(nextRow, refInNextRow); + } + + i -= 1; + nextRow = nextRow.next; + } + + tableCell.format('rowspan', 1); + } + }); + } + + rows() { + const body = this.children.tail; + if (body == null) return []; + return body.children.map(row => row); + } + +} + +table_TableContainer.blotName = "table-container"; +table_TableContainer.className = "quill-better-table"; +table_TableContainer.tagName = "TABLE"; + +class table_TableViewWrapper extends Container { + constructor(scroll, domNode) { + super(scroll, domNode); + const quill = external_commonjs_quill_commonjs2_quill_amd_quill_root_Quill_default.a.find(scroll.domNode.parentNode); + domNode.addEventListener('scroll', e => { + const tableModule = quill.getModule('better-table'); + + if (tableModule.columnTool) { + tableModule.columnTool.domNode.scrollLeft = e.target.scrollLeft; + } + + if (tableModule.tableSelection && tableModule.tableSelection.selectedTds.length > 0) { + tableModule.tableSelection.repositionHelpLines(); + } + }, false); + } + + table() { + return this.children.head; + } + +} + +table_TableViewWrapper.blotName = "table-view"; +table_TableViewWrapper.className = "quill-better-table-wrapper"; +table_TableViewWrapper.tagName = "DIV"; +table_TableViewWrapper.allowedChildren = [table_TableContainer]; +table_TableContainer.requiredContainer = table_TableViewWrapper; +table_TableContainer.allowedChildren = [TableBody, TableColGroup]; +TableBody.requiredContainer = table_TableContainer; +TableBody.allowedChildren = [TableRow]; +TableRow.requiredContainer = TableBody; +TableRow.allowedChildren = [TableCell]; +TableCell.requiredContainer = TableRow; +TableCell.allowedChildren = [TableCellLine, header]; +TableCellLine.requiredContainer = TableCell; +TableColGroup.allowedChildren = [TableCol]; +TableColGroup.requiredContainer = table_TableContainer; +TableCol.requiredContainer = TableColGroup; + +function table_rowId() { + const id = Math.random().toString(36).slice(2, 6); + return "row-".concat(id); +} + +function table_cellId() { + const id = Math.random().toString(36).slice(2, 6); + return "cell-".concat(id); +} + + +// CONCATENATED MODULE: ./src/modules/table-selection.js + + + +const table_selection_PRIMARY_COLOR = '#0589f3'; +const LINE_POSITIONS = ['left', 'right', 'top', 'bottom']; +const table_selection_ERROR_LIMIT = 2; +class table_selection_TableSelection { + constructor(table, quill, options) { + if (!table) return null; + this.table = table; + this.quill = quill; + this.options = options; + this.boundary = {}; // params for selected square + + this.selectedTds = []; // array for selected table-cells + + this.dragging = false; + this.selectingHandler = this.mouseDownHandler.bind(this); + this.clearSelectionHandler = this.clearSelection.bind(this); + this.helpLinesInitial(); + this.quill.root.addEventListener('mousedown', this.selectingHandler, false); + this.quill.on('text-change', this.clearSelectionHandler); + } + + helpLinesInitial() { + let parent = this.quill.root.parentNode; + LINE_POSITIONS.forEach(direction => { + this[direction] = document.createElement('div'); + this[direction].classList.add('qlbt-selection-line'); + this[direction].classList.add('qlbt-selection-line-' + direction); + css(this[direction], { + position: 'absolute', + display: 'none', + 'background-color': table_selection_PRIMARY_COLOR + }); + parent.appendChild(this[direction]); + }); + } + + mouseDownHandler(e) { + if (e.button !== 0 || !e.target.closest(".quill-better-table")) return; + this.quill.root.addEventListener('mousemove', mouseMoveHandler, false); + this.quill.root.addEventListener('mouseup', mouseUpHandler, false); + const self = this; + const startTd = e.target.closest('td[data-row]'); + const startTdRect = getRelativeRect(startTd.getBoundingClientRect(), this.quill.root.parentNode); + this.dragging = true; + this.boundary = computeBoundaryFromRects(startTdRect, startTdRect); + this.correctBoundary(); + this.selectedTds = this.computeSelectedTds(); + this.repositionHelpLines(); + + function mouseMoveHandler(e) { + if (e.button !== 0 || !e.target.closest(".quill-better-table")) return; + const endTd = e.target.closest('td[data-row]'); + const endTdRect = getRelativeRect(endTd.getBoundingClientRect(), self.quill.root.parentNode); + self.boundary = computeBoundaryFromRects(startTdRect, endTdRect); + self.correctBoundary(); + self.selectedTds = self.computeSelectedTds(); + self.repositionHelpLines(); // avoid select text in multiple table-cell + + if (startTd !== endTd) { + self.quill.blur(); + } + } + + function mouseUpHandler(e) { + self.quill.root.removeEventListener('mousemove', mouseMoveHandler, false); + self.quill.root.removeEventListener('mouseup', mouseUpHandler, false); + self.dragging = false; + } + } + + correctBoundary() { + const tableContainer = external_commonjs_quill_commonjs2_quill_amd_quill_root_Quill_default.a.find(this.table); + const tableCells = tableContainer.descendants(TableCell); + tableCells.forEach(tableCell => { + let { + x, + y, + width, + height + } = getRelativeRect(tableCell.domNode.getBoundingClientRect(), this.quill.root.parentNode); + let isCellIntersected = (x + table_selection_ERROR_LIMIT >= this.boundary.x && x + table_selection_ERROR_LIMIT <= this.boundary.x1 || x - table_selection_ERROR_LIMIT + width >= this.boundary.x && x - table_selection_ERROR_LIMIT + width <= this.boundary.x1) && (y + table_selection_ERROR_LIMIT >= this.boundary.y && y + table_selection_ERROR_LIMIT <= this.boundary.y1 || y - table_selection_ERROR_LIMIT + height >= this.boundary.y && y - table_selection_ERROR_LIMIT + height <= this.boundary.y1); + + if (isCellIntersected) { + this.boundary = computeBoundaryFromRects(this.boundary, { + x, + y, + width, + height + }); + } + }); + } + + computeSelectedTds() { + const tableContainer = external_commonjs_quill_commonjs2_quill_amd_quill_root_Quill_default.a.find(this.table); + const tableCells = tableContainer.descendants(TableCell); + return tableCells.reduce((selectedCells, tableCell) => { + let { + x, + y, + width, + height + } = getRelativeRect(tableCell.domNode.getBoundingClientRect(), this.quill.root.parentNode); + let isCellIncluded = x + table_selection_ERROR_LIMIT >= this.boundary.x && x - table_selection_ERROR_LIMIT + width <= this.boundary.x1 && y + table_selection_ERROR_LIMIT >= this.boundary.y && y - table_selection_ERROR_LIMIT + height <= this.boundary.y1; + + if (isCellIncluded) { + selectedCells.push(tableCell); + } + + return selectedCells; + }, []); + } + + repositionHelpLines() { + const tableViewScrollLeft = this.table.parentNode.scrollLeft; + css(this.left, { + display: 'block', + left: "".concat(this.boundary.x - tableViewScrollLeft - 1, "px"), + top: "".concat(this.boundary.y, "px"), + height: "".concat(this.boundary.height + 1, "px"), + width: '1px' + }); + css(this.right, { + display: 'block', + left: "".concat(this.boundary.x1 - tableViewScrollLeft, "px"), + top: "".concat(this.boundary.y, "px"), + height: "".concat(this.boundary.height + 1, "px"), + width: '1px' + }); + css(this.top, { + display: 'block', + left: "".concat(this.boundary.x - 1 - tableViewScrollLeft, "px"), + top: "".concat(this.boundary.y, "px"), + width: "".concat(this.boundary.width + 1, "px"), + height: '1px' + }); + css(this.bottom, { + display: 'block', + left: "".concat(this.boundary.x - 1 - tableViewScrollLeft, "px"), + top: "".concat(this.boundary.y1 + 1, "px"), + width: "".concat(this.boundary.width + 1, "px"), + height: '1px' + }); + } // based on selectedTds compute positions of help lines + // It is useful when selectedTds are not changed + + + refreshHelpLinesPosition() { + const startRect = getRelativeRect(this.selectedTds[0].domNode.getBoundingClientRect(), this.quill.root.parentNode); + const endRect = getRelativeRect(this.selectedTds[this.selectedTds.length - 1].domNode.getBoundingClientRect(), this.quill.root.parentNode); + this.boundary = computeBoundaryFromRects(startRect, endRect); + this.repositionHelpLines(); + } + + destroy() { + LINE_POSITIONS.forEach(direction => { + this[direction].remove(); + this[direction] = null; + }); + this.quill.root.removeEventListener('mousedown', this.selectingHandler, false); + this.quill.off('text-change', this.clearSelectionHandler); + return null; + } + + setSelection(startRect, endRect) { + this.boundary = computeBoundaryFromRects(getRelativeRect(startRect, this.quill.root.parentNode), getRelativeRect(endRect, this.quill.root.parentNode)); + this.correctBoundary(); + this.selectedTds = this.computeSelectedTds(); + this.repositionHelpLines(); + } + + clearSelection() { + this.boundary = {}; + this.selectedTds = []; + LINE_POSITIONS.forEach(direction => { + this[direction] && css(this[direction], { + display: 'none' + }); + }); + } + +} + +function computeBoundaryFromRects(startRect, endRect) { + let x = Math.min(startRect.x, endRect.x, startRect.x + startRect.width - 1, endRect.x + endRect.width - 1); + let x1 = Math.max(startRect.x, endRect.x, startRect.x + startRect.width - 1, endRect.x + endRect.width - 1); + let y = Math.min(startRect.y, endRect.y, startRect.y + startRect.height - 1, endRect.y + endRect.height - 1); + let y1 = Math.max(startRect.y, endRect.y, startRect.y + startRect.height - 1, endRect.y + endRect.height - 1); + let width = x1 - x; + let height = y1 - y; + return { + x, + x1, + y, + y1, + width, + height + }; +} +// EXTERNAL MODULE: ./src/assets/icons/icon_operation_1.svg +var icon_operation_1 = __webpack_require__(29); +var icon_operation_1_default = /*#__PURE__*/__webpack_require__.n(icon_operation_1); + +// EXTERNAL MODULE: ./src/assets/icons/icon_operation_2.svg +var icon_operation_2 = __webpack_require__(30); +var icon_operation_2_default = /*#__PURE__*/__webpack_require__.n(icon_operation_2); + +// EXTERNAL MODULE: ./src/assets/icons/icon_operation_3.svg +var icon_operation_3 = __webpack_require__(31); +var icon_operation_3_default = /*#__PURE__*/__webpack_require__.n(icon_operation_3); + +// EXTERNAL MODULE: ./src/assets/icons/icon_operation_4.svg +var icon_operation_4 = __webpack_require__(32); +var icon_operation_4_default = /*#__PURE__*/__webpack_require__.n(icon_operation_4); + +// EXTERNAL MODULE: ./src/assets/icons/icon_operation_5.svg +var icon_operation_5 = __webpack_require__(33); +var icon_operation_5_default = /*#__PURE__*/__webpack_require__.n(icon_operation_5); + +// EXTERNAL MODULE: ./src/assets/icons/icon_operation_6.svg +var icon_operation_6 = __webpack_require__(34); +var icon_operation_6_default = /*#__PURE__*/__webpack_require__.n(icon_operation_6); + +// EXTERNAL MODULE: ./src/assets/icons/icon_operation_7.svg +var icon_operation_7 = __webpack_require__(35); +var icon_operation_7_default = /*#__PURE__*/__webpack_require__.n(icon_operation_7); + +// EXTERNAL MODULE: ./src/assets/icons/icon_operation_8.svg +var icon_operation_8 = __webpack_require__(36); +var icon_operation_8_default = /*#__PURE__*/__webpack_require__.n(icon_operation_8); + +// EXTERNAL MODULE: ./src/assets/icons/icon_operation_9.svg +var icon_operation_9 = __webpack_require__(37); +var icon_operation_9_default = /*#__PURE__*/__webpack_require__.n(icon_operation_9); + +// CONCATENATED MODULE: ./src/modules/table-operation-menu.js + + // svg icons + + + + + + + + + + +const MENU_MIN_HEIHGT = 150; +const MENU_WIDTH = 200; +const table_operation_menu_ERROR_LIMIT = 5; +const DEFAULT_CELL_COLORS = ['white', 'red', 'yellow', 'blue']; +const DEFAULT_COLOR_SUBTITLE = 'Background Colors'; +const MENU_ITEMS_DEFAULT = { + insertColumnRight: { + text: 'Insert column right', + iconSrc: icon_operation_1_default.a, + + handler() { + const tableContainer = external_commonjs_quill_commonjs2_quill_amd_quill_root_Quill_default.a.find(this.table); + let colIndex = getColToolCellIndexByBoundary(this.columnToolCells, this.boundary, (cellRect, boundary) => { + return Math.abs(cellRect.x + cellRect.width - boundary.x1) <= table_operation_menu_ERROR_LIMIT; + }, this.quill.root.parentNode); + const newColumn = tableContainer.insertColumn(this.boundary, colIndex, true, this.quill.root.parentNode); + this.tableColumnTool.updateToolCells(); + this.quill.update(external_commonjs_quill_commonjs2_quill_amd_quill_root_Quill_default.a.sources.USER); + this.quill.setSelection(this.quill.getIndex(newColumn[0]), 0, external_commonjs_quill_commonjs2_quill_amd_quill_root_Quill_default.a.sources.SILENT); + this.tableSelection.setSelection(newColumn[0].domNode.getBoundingClientRect(), newColumn[0].domNode.getBoundingClientRect()); + } + + }, + insertColumnLeft: { + text: 'Insert column left', + iconSrc: icon_operation_2_default.a, + + handler() { + const tableContainer = external_commonjs_quill_commonjs2_quill_amd_quill_root_Quill_default.a.find(this.table); + let colIndex = getColToolCellIndexByBoundary(this.columnToolCells, this.boundary, (cellRect, boundary) => { + return Math.abs(cellRect.x - boundary.x) <= table_operation_menu_ERROR_LIMIT; + }, this.quill.root.parentNode); + const newColumn = tableContainer.insertColumn(this.boundary, colIndex, false, this.quill.root.parentNode); + this.tableColumnTool.updateToolCells(); + this.quill.update(external_commonjs_quill_commonjs2_quill_amd_quill_root_Quill_default.a.sources.USER); + this.quill.setSelection(this.quill.getIndex(newColumn[0]), 0, external_commonjs_quill_commonjs2_quill_amd_quill_root_Quill_default.a.sources.SILENT); + this.tableSelection.setSelection(newColumn[0].domNode.getBoundingClientRect(), newColumn[0].domNode.getBoundingClientRect()); + } + + }, + insertRowUp: { + text: 'Insert row up', + iconSrc: icon_operation_3_default.a, + + handler() { + const tableContainer = external_commonjs_quill_commonjs2_quill_amd_quill_root_Quill_default.a.find(this.table); + const affectedCells = tableContainer.insertRow(this.boundary, false, this.quill.root.parentNode); + this.quill.update(external_commonjs_quill_commonjs2_quill_amd_quill_root_Quill_default.a.sources.USER); + this.quill.setSelection(this.quill.getIndex(affectedCells[0]), 0, external_commonjs_quill_commonjs2_quill_amd_quill_root_Quill_default.a.sources.SILENT); + this.tableSelection.setSelection(affectedCells[0].domNode.getBoundingClientRect(), affectedCells[0].domNode.getBoundingClientRect()); + } + + }, + insertRowDown: { + text: 'Insert row down', + iconSrc: icon_operation_4_default.a, + + handler() { + const tableContainer = external_commonjs_quill_commonjs2_quill_amd_quill_root_Quill_default.a.find(this.table); + const affectedCells = tableContainer.insertRow(this.boundary, true, this.quill.root.parentNode); + this.quill.update(external_commonjs_quill_commonjs2_quill_amd_quill_root_Quill_default.a.sources.USER); + this.quill.setSelection(this.quill.getIndex(affectedCells[0]), 0, external_commonjs_quill_commonjs2_quill_amd_quill_root_Quill_default.a.sources.SILENT); + this.tableSelection.setSelection(affectedCells[0].domNode.getBoundingClientRect(), affectedCells[0].domNode.getBoundingClientRect()); + } + + }, + mergeCells: { + text: 'Merge selected cells', + iconSrc: icon_operation_5_default.a, + + handler() { + const tableContainer = external_commonjs_quill_commonjs2_quill_amd_quill_root_Quill_default.a.find(this.table); // compute merged Cell rowspan, equal to length of selected rows + + const rowspan = tableContainer.rows().reduce((sum, row) => { + let rowRect = getRelativeRect(row.domNode.getBoundingClientRect(), this.quill.root.parentNode); + + if (rowRect.y > this.boundary.y - table_operation_menu_ERROR_LIMIT && rowRect.y + rowRect.height < this.boundary.y + this.boundary.height + table_operation_menu_ERROR_LIMIT) { + sum += 1; + } + + return sum; + }, 0); // compute merged cell colspan, equal to length of selected cols + + const colspan = this.columnToolCells.reduce((sum, cell) => { + let cellRect = getRelativeRect(cell.getBoundingClientRect(), this.quill.root.parentNode); + + if (cellRect.x > this.boundary.x - table_operation_menu_ERROR_LIMIT && cellRect.x + cellRect.width < this.boundary.x + this.boundary.width + table_operation_menu_ERROR_LIMIT) { + sum += 1; + } + + return sum; + }, 0); + const mergedCell = tableContainer.mergeCells(this.boundary, this.selectedTds, rowspan, colspan, this.quill.root.parentNode); + this.quill.update(external_commonjs_quill_commonjs2_quill_amd_quill_root_Quill_default.a.sources.USER); + this.tableSelection.setSelection(mergedCell.domNode.getBoundingClientRect(), mergedCell.domNode.getBoundingClientRect()); + } + + }, + unmergeCells: { + text: 'Unmerge cells', + iconSrc: icon_operation_6_default.a, + + handler() { + const tableContainer = external_commonjs_quill_commonjs2_quill_amd_quill_root_Quill_default.a.find(this.table); + tableContainer.unmergeCells(this.selectedTds, this.quill.root.parentNode); + this.quill.update(external_commonjs_quill_commonjs2_quill_amd_quill_root_Quill_default.a.sources.USER); + this.tableSelection.clearSelection(); + } + + }, + deleteColumn: { + text: 'Delete selected columns', + iconSrc: icon_operation_7_default.a, + + handler() { + const tableContainer = external_commonjs_quill_commonjs2_quill_amd_quill_root_Quill_default.a.find(this.table); + let colIndexes = getColToolCellIndexesByBoundary(this.columnToolCells, this.boundary, (cellRect, boundary) => { + return cellRect.x + table_operation_menu_ERROR_LIMIT > boundary.x && cellRect.x + cellRect.width - table_operation_menu_ERROR_LIMIT < boundary.x1; + }, this.quill.root.parentNode); + let isDeleteTable = tableContainer.deleteColumns(this.boundary, colIndexes, this.quill.root.parentNode); + + if (!isDeleteTable) { + this.tableColumnTool.updateToolCells(); + this.quill.update(external_commonjs_quill_commonjs2_quill_amd_quill_root_Quill_default.a.sources.USER); + this.tableSelection.clearSelection(); + } + } + + }, + deleteRow: { + text: 'Delete selected rows', + iconSrc: icon_operation_8_default.a, + + handler() { + const tableContainer = external_commonjs_quill_commonjs2_quill_amd_quill_root_Quill_default.a.find(this.table); + tableContainer.deleteRow(this.boundary, this.quill.root.parentNode); + this.quill.update(external_commonjs_quill_commonjs2_quill_amd_quill_root_Quill_default.a.sources.USER); + this.tableSelection.clearSelection(); + } + + }, + deleteTable: { + text: 'Delete table', + iconSrc: icon_operation_9_default.a, + + handler() { + const betterTableModule = this.quill.getModule('better-table'); + const tableContainer = external_commonjs_quill_commonjs2_quill_amd_quill_root_Quill_default.a.find(this.table); + betterTableModule.hideTableTools(); + tableContainer.remove(); + this.quill.update(external_commonjs_quill_commonjs2_quill_amd_quill_root_Quill_default.a.sources.USER); + } + + } +}; +class table_operation_menu_TableOperationMenu { + constructor(params, quill, options) { + const betterTableModule = quill.getModule('better-table'); + this.tableSelection = betterTableModule.tableSelection; + this.table = params.table; + this.quill = quill; + this.options = options; + this.menuItems = Object.assign({}, MENU_ITEMS_DEFAULT, options.items); + this.tableColumnTool = betterTableModule.columnTool; + this.boundary = this.tableSelection.boundary; + this.selectedTds = this.tableSelection.selectedTds; + this.destroyHandler = this.destroy.bind(this); + this.columnToolCells = this.tableColumnTool.colToolCells(); + this.colorSubTitle = options.color && options.color.text ? options.color.text : DEFAULT_COLOR_SUBTITLE; + this.cellColors = options.color && options.color.colors ? options.color.colors : DEFAULT_CELL_COLORS; + this.menuInitial(params); + this.mount(); + document.addEventListener("click", this.destroyHandler, false); + } + + mount() { + document.body.appendChild(this.domNode); + } + + destroy() { + this.domNode.remove(); + document.removeEventListener("click", this.destroyHandler, false); + return null; + } + + menuInitial({ + table, + left, + top + }) { + this.domNode = document.createElement('div'); + this.domNode.classList.add('qlbt-operation-menu'); + css(this.domNode, { + position: 'absolute', + left: "".concat(left, "px"), + top: "".concat(top, "px"), + 'min-height': "".concat(MENU_MIN_HEIHGT, "px"), + width: "".concat(MENU_WIDTH, "px") + }); + + for (let name in this.menuItems) { + if (this.menuItems[name]) { + this.domNode.appendChild(this.menuItemCreator(Object.assign({}, MENU_ITEMS_DEFAULT[name], this.menuItems[name]))); + + if (['insertRowDown', 'unmergeCells'].indexOf(name) > -1) { + this.domNode.appendChild(dividingCreator()); + } + } + } // if colors option is false, disabled bg color + + + if (this.options.color && this.options.color !== false) { + this.domNode.appendChild(dividingCreator()); + this.domNode.appendChild(subTitleCreator(this.colorSubTitle)); + this.domNode.appendChild(this.colorsItemCreator(this.cellColors)); + } // create dividing line + + + function dividingCreator() { + const dividing = document.createElement('div'); + dividing.classList.add('qlbt-operation-menu-dividing'); + return dividing; + } // create subtitle for menu + + + function subTitleCreator(title) { + const subTitle = document.createElement('div'); + subTitle.classList.add('qlbt-operation-menu-subtitle'); + subTitle.innerText = title; + return subTitle; + } + } + + colorsItemCreator(colors) { + const self = this; + const node = document.createElement('div'); + node.classList.add('qlbt-operation-color-picker'); + colors.forEach(color => { + let colorBox = colorBoxCreator(color); + node.appendChild(colorBox); + }); + + function colorBoxCreator(color) { + const box = document.createElement('div'); + box.classList.add('qlbt-operation-color-picker-item'); + box.setAttribute('data-color', color); + box.style.backgroundColor = color; + box.addEventListener('click', function () { + const selectedTds = self.tableSelection.selectedTds; + + if (selectedTds && selectedTds.length > 0) { + selectedTds.forEach(tableCell => { + tableCell.format('cell-bg', color); + }); + } + }, false); + return box; + } + + return node; + } + + menuItemCreator({ + text, + iconSrc, + handler + }) { + const node = document.createElement('div'); + node.classList.add('qlbt-operation-menu-item'); + const iconSpan = document.createElement('span'); + iconSpan.classList.add('qlbt-operation-menu-icon'); + iconSpan.innerHTML = iconSrc; + const textSpan = document.createElement('span'); + textSpan.classList.add('qlbt-operation-menu-text'); + textSpan.innerText = text; + node.appendChild(iconSpan); + node.appendChild(textSpan); + node.addEventListener('click', handler.bind(this), false); + return node; + } + +} + +function getColToolCellIndexByBoundary(cells, boundary, conditionFn, container) { + return cells.reduce((findIndex, cell) => { + let cellRect = getRelativeRect(cell.getBoundingClientRect(), container); + + if (conditionFn(cellRect, boundary)) { + findIndex = cells.indexOf(cell); + } + + return findIndex; + }, false); +} + +function getColToolCellIndexesByBoundary(cells, boundary, conditionFn, container) { + return cells.reduce((findIndexes, cell) => { + let cellRect = getRelativeRect(cell.getBoundingClientRect(), container); + + if (conditionFn(cellRect, boundary)) { + findIndexes.push(cells.indexOf(cell)); + } + + return findIndexes; + }, []); +} +// EXTERNAL MODULE: ./node_modules/eventemitter3/index.js +var eventemitter3 = __webpack_require__(38); +var eventemitter3_default = /*#__PURE__*/__webpack_require__.n(eventemitter3); + +// CONCATENATED MODULE: ./node_modules/quill/core/instances.js +/* harmony default export */ var instances = (new WeakMap()); + +// CONCATENATED MODULE: ./node_modules/quill/core/logger.js +const levels = ['error', 'warn', 'log', 'info']; +let level = 'warn'; + +function debug(method, ...args) { + if (levels.indexOf(method) <= levels.indexOf(level)) { + console[method](...args); // eslint-disable-line no-console + } +} + +function namespace(ns) { + return levels.reduce((logger, method) => { + logger[method] = debug.bind(console, method, ns); + return logger; + }, {}); +} + +namespace.level = newLevel => { + level = newLevel; +}; +debug.level = namespace.level; + +/* harmony default export */ var logger = (namespace); + +// CONCATENATED MODULE: ./node_modules/quill/core/emitter.js + + + + +const emitter_debug = logger('quill:events'); +const EVENTS = ['selectionchange', 'mousedown', 'mouseup', 'click']; + +EVENTS.forEach(eventName => { + document.addEventListener(eventName, (...args) => { + Array.from(document.querySelectorAll('.ql-container')).forEach(node => { + const quill = instances.get(node); + if (quill && quill.emitter) { + quill.emitter.handleDOM(...args); + } + }); + }); +}); + +class emitter_Emitter extends eventemitter3_default.a { + constructor() { + super(); + this.listeners = {}; + this.on('error', emitter_debug.error); + } + + emit(...args) { + emitter_debug.log.call(emitter_debug, ...args); + super.emit(...args); + } + + handleDOM(event, ...args) { + (this.listeners[event.type] || []).forEach(({ node, handler }) => { + if (event.target === node || node.contains(event.target)) { + handler(event, ...args); + } + }); + } + + listenDOM(eventName, node, handler) { + if (!this.listeners[eventName]) { + this.listeners[eventName] = []; + } + this.listeners[eventName].push({ node, handler }); + } +} + +emitter_Emitter.events = { + EDITOR_CHANGE: 'editor-change', + SCROLL_BEFORE_UPDATE: 'scroll-before-update', + SCROLL_BLOT_MOUNT: 'scroll-blot-mount', + SCROLL_BLOT_UNMOUNT: 'scroll-blot-unmount', + SCROLL_OPTIMIZE: 'scroll-optimize', + SCROLL_UPDATE: 'scroll-update', + SELECTION_CHANGE: 'selection-change', + TEXT_CHANGE: 'text-change', +}; +emitter_Emitter.sources = { + API: 'api', + SILENT: 'silent', + USER: 'user', +}; + +/* harmony default export */ var core_emitter = (emitter_Emitter); + +// CONCATENATED MODULE: ./node_modules/quill/core/theme.js +class Theme { + constructor(quill, options) { + this.quill = quill; + this.options = options; + this.modules = {}; + } + + init() { + Object.keys(this.options.modules).forEach(name => { + if (this.modules[name] == null) { + this.addModule(name); + } + }); + } + + addModule(name) { + const ModuleClass = this.quill.constructor.import(`modules/${name}`); + this.modules[name] = new ModuleClass( + this.quill, + this.options.modules[name] || {}, + ); + return this.modules[name]; + } +} +Theme.DEFAULTS = { + modules: {}, +}; +Theme.themes = { + default: Theme, +}; + +/* harmony default export */ var theme = (Theme); + +// EXTERNAL MODULE: ./node_modules/quill/assets/icons/dropdown.svg +var dropdown = __webpack_require__(39); +var dropdown_default = /*#__PURE__*/__webpack_require__.n(dropdown); + +// CONCATENATED MODULE: ./node_modules/quill/ui/picker.js + + +let optionsCounter = 0; + +function toggleAriaAttribute(element, attribute) { + element.setAttribute( + attribute, + !(element.getAttribute(attribute) === 'true'), + ); +} + +class picker_Picker { + constructor(select) { + 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('mousedown', () => { + this.togglePicker(); + }); + this.label.addEventListener('keydown', event => { + switch (event.key) { + case 'Enter': + this.togglePicker(); + break; + case 'Escape': + this.escape(); + event.preventDefault(); + break; + default: + } + }); + this.select.addEventListener('change', this.update.bind(this)); + } + + togglePicker() { + this.container.classList.toggle('ql-expanded'); + // Toggle aria-expanded and aria-hidden to make the picker accessible + toggleAriaAttribute(this.label, 'aria-expanded'); + toggleAriaAttribute(this.options, 'aria-hidden'); + } + + buildItem(option) { + const item = document.createElement('span'); + item.tabIndex = '0'; + item.setAttribute('role', 'button'); + 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', () => { + this.selectItem(item, true); + }); + item.addEventListener('keydown', event => { + switch (event.key) { + case 'Enter': + this.selectItem(item, true); + event.preventDefault(); + break; + case 'Escape': + this.escape(); + event.preventDefault(); + break; + default: + } + }); + + return item; + } + + buildLabel() { + const label = document.createElement('span'); + label.classList.add('ql-picker-label'); + label.innerHTML = dropdown_default.a; + label.tabIndex = '0'; + label.setAttribute('role', 'button'); + label.setAttribute('aria-expanded', 'false'); + this.container.appendChild(label); + return label; + } + + buildOptions() { + const options = document.createElement('span'); + options.classList.add('ql-picker-options'); + + // Don't want screen readers to read this until options are visible + options.setAttribute('aria-hidden', 'true'); + options.tabIndex = '-1'; + + // Need a unique id for aria-controls + options.id = `ql-picker-options-${optionsCounter}`; + optionsCounter += 1; + this.label.setAttribute('aria-controls', options.id); + + this.options = options; + + Array.from(this.select.options).forEach(option => { + const item = this.buildItem(option); + options.appendChild(item); + if (option.selected === true) { + this.selectItem(item); + } + }); + this.container.appendChild(options); + } + + buildPicker() { + Array.from(this.select.attributes).forEach(item => { + this.container.setAttribute(item.name, item.value); + }); + this.container.classList.add('ql-picker'); + this.label = this.buildLabel(); + this.buildOptions(); + } + + escape() { + // Close menu and return focus to trigger label + this.close(); + // Need setTimeout for accessibility to ensure that the browser executes + // focus on the next process thread and after any DOM content changes + setTimeout(() => this.label.focus(), 1); + } + + close() { + this.container.classList.remove('ql-expanded'); + this.label.setAttribute('aria-expanded', 'false'); + this.options.setAttribute('aria-hidden', 'true'); + } + + selectItem(item, trigger = false) { + const selected = this.container.querySelector('.ql-selected'); + if (item === selected) return; + if (selected != null) { + selected.classList.remove('ql-selected'); + } + if (item == null) return; + item.classList.add('ql-selected'); + this.select.selectedIndex = Array.from(item.parentNode.children).indexOf( + 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) { + this.select.dispatchEvent(new Event('change')); + this.close(); + } + } + + update() { + let option; + if (this.select.selectedIndex > -1) { + const 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); + } + const isActive = + option != null && + option !== this.select.querySelector('option[selected]'); + this.label.classList.toggle('ql-active', isActive); + } +} + +/* harmony default export */ var picker = (picker_Picker); + +// CONCATENATED MODULE: ./node_modules/quill/ui/color-picker.js + + +class color_picker_ColorPicker extends picker { + constructor(select, label) { + super(select); + this.label.innerHTML = label; + this.container.classList.add('ql-color-picker'); + Array.from(this.container.querySelectorAll('.ql-picker-item')) + .slice(0, 7) + .forEach(item => { + item.classList.add('ql-primary'); + }); + } + + buildItem(option) { + const item = super.buildItem(option); + item.style.backgroundColor = option.getAttribute('value') || ''; + return item; + } + + selectItem(item, trigger) { + super.selectItem(item, trigger); + const colorLabel = this.label.querySelector('.ql-color-label'); + const value = item ? item.getAttribute('data-value') || '' : ''; + if (colorLabel) { + if (colorLabel.tagName === 'line') { + colorLabel.style.stroke = value; + } else { + colorLabel.style.fill = value; + } + } + } +} + +/* harmony default export */ var color_picker = (color_picker_ColorPicker); + +// CONCATENATED MODULE: ./node_modules/quill/ui/icon-picker.js + + +class icon_picker_IconPicker extends picker { + constructor(select, icons) { + super(select); + this.container.classList.add('ql-icon-picker'); + Array.from(this.container.querySelectorAll('.ql-picker-item')).forEach( + item => { + item.innerHTML = icons[item.getAttribute('data-value') || '']; + }, + ); + this.defaultItem = this.container.querySelector('.ql-selected'); + this.selectItem(this.defaultItem); + } + + selectItem(target, trigger) { + super.selectItem(target, trigger); + const item = target || this.defaultItem; + if (this.label.innerHTML === item.innerHTML) return; + this.label.innerHTML = item.innerHTML; + } +} + +/* harmony default export */ var icon_picker = (icon_picker_IconPicker); + +// CONCATENATED MODULE: ./node_modules/quill/ui/tooltip.js +class Tooltip { + constructor(quill, boundsContainer) { + this.quill = quill; + this.boundsContainer = boundsContainer || document.body; + this.root = quill.addContainer('ql-tooltip'); + this.root.innerHTML = this.constructor.TEMPLATE; + if (this.quill.root === this.quill.scrollingContainer) { + this.quill.root.addEventListener('scroll', () => { + this.root.style.marginTop = `${-1 * this.quill.root.scrollTop}px`; + }); + } + this.hide(); + } + + hide() { + this.root.classList.add('ql-hidden'); + } + + position(reference) { + const left = + reference.left + reference.width / 2 - this.root.offsetWidth / 2; + // root.scrollTop should be 0 if scrollContainer !== root + const top = reference.bottom + this.quill.root.scrollTop; + this.root.style.left = `${left}px`; + this.root.style.top = `${top}px`; + this.root.classList.remove('ql-flip'); + const containerBounds = this.boundsContainer.getBoundingClientRect(); + const rootBounds = this.root.getBoundingClientRect(); + let 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`; + } + if (rootBounds.bottom > containerBounds.bottom) { + const height = rootBounds.bottom - rootBounds.top; + const verticalShift = reference.bottom - reference.top + height; + this.root.style.top = `${top - verticalShift}px`; + this.root.classList.add('ql-flip'); + } + return shift; + } + + show() { + this.root.classList.remove('ql-editing'); + this.root.classList.remove('ql-hidden'); + } +} + +/* harmony default export */ var tooltip = (Tooltip); + +// CONCATENATED MODULE: ./node_modules/quill/themes/base.js + + + + + + + + +const ALIGNS = [false, 'center', 'right', 'justify']; + +const 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', +]; + +const FONTS = [false, 'serif', 'monospace']; + +const HEADERS = ['1', '2', '3', false]; + +const SIZES = ['small', false, 'large', 'huge']; + +class base_BaseTheme extends theme { + constructor(quill, options) { + super(quill, options); + const listener = e => { + if (!document.body.contains(quill.root)) { + document.body.removeEventListener('click', listener); + return; + } + 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(picker => { + if (!picker.container.contains(e.target)) { + picker.close(); + } + }); + } + }; + quill.emitter.listenDOM('click', document.body, listener); + } + + addModule(name) { + const module = super.addModule(name); + if (name === 'toolbar') { + this.extendToolbar(module); + } + return module; + } + + buildButtons(buttons, icons) { + Array.from(buttons).forEach(button => { + const className = button.getAttribute('class') || ''; + className.split(/\s+/).forEach(name => { + if (!name.startsWith('ql-')) return; + name = name.slice('ql-'.length); + if (icons[name] == null) return; + if (name === 'direction') { + button.innerHTML = icons[name][''] + icons[name].rtl; + } else if (typeof icons[name] === 'string') { + button.innerHTML = icons[name]; + } else { + const value = button.value || ''; + if (value != null && icons[name][value]) { + button.innerHTML = icons[name][value]; + } + } + }); + }); + } + + buildPickers(selects, icons) { + this.pickers = Array.from(selects).map(select => { + if (select.classList.contains('ql-align')) { + if (select.querySelector('option') == null) { + fillSelect(select, ALIGNS); + } + return new icon_picker(select, icons.align); + } + if ( + select.classList.contains('ql-background') || + select.classList.contains('ql-color') + ) { + const format = select.classList.contains('ql-background') + ? 'background' + : 'color'; + if (select.querySelector('option') == null) { + fillSelect( + select, + COLORS, + format === 'background' ? '#ffffff' : '#000000', + ); + } + return new color_picker(select, icons[format]); + } + 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 picker(select); + }); + const update = () => { + this.pickers.forEach(picker => { + picker.update(); + }); + }; + this.quill.on(core_emitter.events.EDITOR_CHANGE, update); + } +} +base_BaseTheme.DEFAULTS = extend_default()(true, {}, theme.DEFAULTS, { + modules: { + toolbar: { + handlers: { + formula() { + this.quill.theme.tooltip.edit('formula'); + }, + image() { + let fileInput = this.container.querySelector( + 'input.ql-image[type=file]', + ); + if (fileInput == null) { + fileInput = document.createElement('input'); + fileInput.setAttribute('type', 'file'); + fileInput.setAttribute( + 'accept', + this.quill.uploader.options.mimetypes.join(', '), + ); + fileInput.classList.add('ql-image'); + fileInput.addEventListener('change', () => { + const range = this.quill.getSelection(true); + this.quill.uploader.upload(range, fileInput.files); + fileInput.value = ''; + }); + this.container.appendChild(fileInput); + } + fileInput.click(); + }, + video() { + this.quill.theme.tooltip.edit('video'); + }, + }, + }, + }, +}); + +class base_BaseTooltip extends tooltip { + constructor(quill, boundsContainer) { + super(quill, boundsContainer); + this.textbox = this.root.querySelector('input[type="text"]'); + this.listen(); + } + + listen() { + this.textbox.addEventListener('keydown', event => { + if (event.key === 'Enter') { + this.save(); + event.preventDefault(); + } else if (event.key === 'Escape') { + this.cancel(); + event.preventDefault(); + } + }); + } + + cancel() { + this.hide(); + } + + edit(mode = 'link', preview = 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); + } + + restoreFocus() { + const { scrollTop } = this.quill.scrollingContainer; + this.quill.focus(); + this.quill.scrollingContainer.scrollTop = scrollTop; + } + + save() { + let { value } = this.textbox; + switch (this.root.getAttribute('data-mode')) { + case 'link': { + const { scrollTop } = this.quill.root; + if (this.linkRange) { + this.quill.formatText( + this.linkRange, + 'link', + value, + core_emitter.sources.USER, + ); + delete this.linkRange; + } else { + this.restoreFocus(); + this.quill.format('link', value, core_emitter.sources.USER); + } + this.quill.root.scrollTop = scrollTop; + break; + } + case 'video': { + value = extractVideoUrl(value); + } // eslint-disable-next-line no-fallthrough + case 'formula': { + if (!value) break; + const range = this.quill.getSelection(true); + if (range != null) { + const index = range.index + range.length; + this.quill.insertEmbed( + index, + this.root.getAttribute('data-mode'), + value, + core_emitter.sources.USER, + ); + if (this.root.getAttribute('data-mode') === 'formula') { + this.quill.insertText(index + 1, ' ', core_emitter.sources.USER); + } + this.quill.setSelection(index + 2, core_emitter.sources.USER); + } + break; + } + default: + } + this.textbox.value = ''; + this.hide(); + } +} + +function extractVideoUrl(url) { + let match = + url.match( + /^(?:(https?):\/\/)?(?:(?:www|m)\.)?youtube\.com\/watch.*v=([a-zA-Z0-9_-]+)/, + ) || + url.match(/^(?:(https?):\/\/)?(?:(?:www|m)\.)?youtu\.be\/([a-zA-Z0-9_-]+)/); + if (match) { + return `${match[1] || 'https'}://www.youtube.com/embed/${ + match[2] + }?showinfo=0`; + } + // eslint-disable-next-line no-cond-assign + if ((match = url.match(/^(?:(https?):\/\/)?(?:www\.)?vimeo\.com\/(\d+)/))) { + return `${match[1] || 'https'}://player.vimeo.com/video/${match[2]}/`; + } + return url; +} + +function fillSelect(select, values, defaultValue = false) { + values.forEach(value => { + const option = document.createElement('option'); + if (value === defaultValue) { + option.setAttribute('selected', 'selected'); + } else { + option.setAttribute('value', value); + } + select.appendChild(option); + }); +} + + + +// EXTERNAL MODULE: ./node_modules/parchment/dist/parchment.js +var parchment = __webpack_require__(1); + +// CONCATENATED MODULE: ./node_modules/quill/blots/break.js + + +class break_Break extends parchment["EmbedBlot"] { + static value() { + return undefined; + } + + optimize() { + if (this.prev || this.next) { + this.remove(); + } + } + + length() { + return 0; + } + + value() { + return ''; + } +} +break_Break.blotName = 'break'; +break_Break.tagName = 'BR'; + +/* harmony default export */ var blots_break = (break_Break); + +// CONCATENATED MODULE: ./node_modules/quill/blots/text.js + + +class text_Text extends parchment["TextBlot"] {} + +function escapeText(text) { + return text.replace(/[&<>"']/g, s => { + // https://lodash.com/docs#escape + const entityMap = { + '&': '&', + '<': '<', + '>': '>', + '"': '"', + "'": ''', + }; + return entityMap[s]; + }); +} + + + +// CONCATENATED MODULE: ./node_modules/quill/blots/inline.js + + + + +class inline_Inline extends parchment["InlineBlot"] { + static compare(self, other) { + const selfIndex = inline_Inline.order.indexOf(self); + const otherIndex = inline_Inline.order.indexOf(other); + if (selfIndex >= 0 || otherIndex >= 0) { + return selfIndex - otherIndex; + } + if (self === other) { + return 0; + } + if (self < other) { + return -1; + } + return 1; + } + + formatAt(index, length, name, value) { + if ( + inline_Inline.compare(this.statics.blotName, name) < 0 && + this.scroll.query(name, parchment["Scope"].BLOT) + ) { + const blot = this.isolate(index, length); + if (value) { + blot.wrap(name, value); + } + } else { + super.formatAt(index, length, name, value); + } + } + + optimize(context) { + super.optimize(context); + if ( + this.parent instanceof inline_Inline && + inline_Inline.compare(this.statics.blotName, this.parent.statics.blotName) > 0 + ) { + const parent = this.parent.isolate(this.offset(), this.length()); + this.moveChildren(parent); + parent.wrap(this); + } + } +} +inline_Inline.allowedChildren = [inline_Inline, blots_break, parchment["EmbedBlot"], text_Text]; +// Lower index means deeper in the DOM tree, since not found (-1) is for embeds +inline_Inline.order = [ + 'cursor', + 'inline', // Must be lower + 'link', // Chrome wants to be lower + 'underline', + 'strike', + 'italic', + 'bold', + 'script', + 'code', // Must be higher +]; + +/* harmony default export */ var inline = (inline_Inline); + +// CONCATENATED MODULE: ./node_modules/quill/formats/link.js + + +class link_Link extends inline { + static create(value) { + const node = super.create(value); + node.setAttribute('href', this.sanitize(value)); + node.setAttribute('rel', 'noopener noreferrer'); + node.setAttribute('target', '_blank'); + return node; + } + + static formats(domNode) { + return domNode.getAttribute('href'); + } + + static sanitize(url) { + return sanitize(url, this.PROTOCOL_WHITELIST) ? url : this.SANITIZED_URL; + } + + format(name, value) { + if (name !== this.statics.blotName || !value) { + super.format(name, value); + } else { + this.domNode.setAttribute('href', this.constructor.sanitize(value)); + } + } +} +link_Link.blotName = 'link'; +link_Link.tagName = 'A'; +link_Link.SANITIZED_URL = 'about:blank'; +link_Link.PROTOCOL_WHITELIST = ['http', 'https', 'mailto', 'tel']; + +function sanitize(url, protocols) { + const anchor = document.createElement('a'); + anchor.href = url; + const protocol = anchor.href.slice(0, anchor.href.indexOf(':')); + return protocols.indexOf(protocol) > -1; +} + + + +// EXTERNAL MODULE: ./node_modules/clone/clone.js +var clone = __webpack_require__(13); +var clone_default = /*#__PURE__*/__webpack_require__.n(clone); + +// EXTERNAL MODULE: ./node_modules/deep-equal/index.js +var deep_equal = __webpack_require__(40); +var deep_equal_default = /*#__PURE__*/__webpack_require__.n(deep_equal); + +// CONCATENATED MODULE: ./node_modules/quill/core/selection.js + + + + + + +const selection_debug = logger('quill:selection'); + +class Range { + constructor(index, length = 0) { + this.index = index; + this.length = length; + } +} + +class selection_Selection { + constructor(scroll, emitter) { + this.emitter = emitter; + this.scroll = scroll; + this.composing = false; + this.mouseDown = false; + this.root = this.scroll.domNode; + this.cursor = this.scroll.create('cursor', this); + // savedRange is last non-null range + this.savedRange = new Range(0, 0); + this.lastRange = this.savedRange; + this.lastNative = null; + this.handleComposition(); + this.handleDragging(); + this.emitter.listenDOM('selectionchange', document, () => { + if (!this.mouseDown && !this.composing) { + setTimeout(this.update.bind(this, core_emitter.sources.USER), 1); + } + }); + this.emitter.on(core_emitter.events.SCROLL_BEFORE_UPDATE, () => { + if (!this.hasFocus()) return; + const native = this.getNativeRange(); + if (native == null) return; + if (native.start.node === this.cursor.textNode) return; // cursor.restore() will handle + this.emitter.once(core_emitter.events.SCROLL_UPDATE, () => { + try { + if ( + this.root.contains(native.start.node) && + this.root.contains(native.end.node) + ) { + this.setNativeRange( + native.start.node, + native.start.offset, + native.end.node, + native.end.offset, + ); + } + this.update(core_emitter.sources.SILENT); + } catch (ignored) { + // ignore + } + }); + }); + this.emitter.on(core_emitter.events.SCROLL_OPTIMIZE, (mutations, context) => { + if (context.range) { + const { startNode, startOffset, endNode, endOffset } = context.range; + this.setNativeRange(startNode, startOffset, endNode, endOffset); + this.update(core_emitter.sources.SILENT); + } + }); + this.update(core_emitter.sources.SILENT); + } + + handleComposition() { + this.root.addEventListener('compositionstart', () => { + this.composing = true; + this.scroll.batchStart(); + }); + this.root.addEventListener('compositionend', () => { + this.scroll.batchEnd(); + this.composing = false; + if (this.cursor.parent) { + const range = this.cursor.restore(); + if (!range) return; + setTimeout(() => { + this.setNativeRange( + range.startNode, + range.startOffset, + range.endNode, + range.endOffset, + ); + }, 1); + } + }); + } + + handleDragging() { + this.emitter.listenDOM('mousedown', document.body, () => { + this.mouseDown = true; + }); + this.emitter.listenDOM('mouseup', document.body, () => { + this.mouseDown = false; + this.update(core_emitter.sources.USER); + }); + } + + focus() { + if (this.hasFocus()) return; + this.root.focus(); + this.setRange(this.savedRange); + } + + format(format, value) { + this.scroll.update(); + const nativeRange = this.getNativeRange(); + if ( + nativeRange == null || + !nativeRange.native.collapsed || + this.scroll.query(format, parchment["Scope"].BLOCK) + ) + return; + if (nativeRange.start.node !== this.cursor.textNode) { + const blot = this.scroll.find(nativeRange.start.node, false); + if (blot == null) return; + // TODO Give blot ability to not split + if (blot instanceof parchment["LeafBlot"]) { + const 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(); + } + + getBounds(index, length = 0) { + const scrollLength = this.scroll.length(); + index = Math.min(index, scrollLength - 1); + length = Math.min(index + length, scrollLength - 1) - index; + let node; + let [leaf, offset] = this.scroll.leaf(index); + if (leaf == null) return null; + [node, offset] = leaf.position(offset, true); + const range = document.createRange(); + if (length > 0) { + range.setStart(node, offset); + [leaf, offset] = this.scroll.leaf(index + length); + if (leaf == null) return null; + [node, offset] = leaf.position(offset, true); + range.setEnd(node, offset); + return range.getBoundingClientRect(); + } + let side = 'left'; + let rect; + 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'; + } + rect = range.getBoundingClientRect(); + } else { + rect = leaf.domNode.getBoundingClientRect(); + if (offset > 0) side = 'right'; + } + return { + bottom: rect.top + rect.height, + height: rect.height, + left: rect[side], + right: rect[side], + top: rect.top, + width: 0, + }; + } + + getNativeRange() { + const selection = document.getSelection(); + if (selection == null || selection.rangeCount <= 0) return null; + const nativeRange = selection.getRangeAt(0); + if (nativeRange == null) return null; + const range = this.normalizeNative(nativeRange); + selection_debug.info('getNativeRange', range); + return range; + } + + getRange() { + const normalized = this.getNativeRange(); + if (normalized == null) return [null, null]; + const range = this.normalizedToRange(normalized); + return [range, normalized]; + } + + hasFocus() { + return ( + document.activeElement === this.root || + contains(this.root, document.activeElement) + ); + } + + normalizedToRange(range) { + const positions = [[range.start.node, range.start.offset]]; + if (!range.native.collapsed) { + positions.push([range.end.node, range.end.offset]); + } + const indexes = positions.map(position => { + const [node, offset] = position; + const blot = this.scroll.find(node, true); + const index = blot.offset(this.scroll); + if (offset === 0) { + return index; + } + if (blot instanceof parchment["LeafBlot"]) { + return index + blot.index(node, offset); + } + return index + blot.length(); + }); + const end = Math.min(Math.max(...indexes), this.scroll.length() - 1); + const start = Math.min(end, ...indexes); + return new Range(start, end - start); + } + + normalizeNative(nativeRange) { + if ( + !contains(this.root, nativeRange.startContainer) || + (!nativeRange.collapsed && !contains(this.root, nativeRange.endContainer)) + ) { + return null; + } + const range = { + start: { + node: nativeRange.startContainer, + offset: nativeRange.startOffset, + }, + end: { node: nativeRange.endContainer, offset: nativeRange.endOffset }, + native: nativeRange, + }; + [range.start, range.end].forEach(position => { + let { node, offset } = position; + 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; + if (node instanceof Text) { + offset = node.data.length; + } else if (node.childNodes.length > 0) { + // Container case + offset = node.childNodes.length; + } else { + // Embed case + offset = node.childNodes.length + 1; + } + } else { + break; + } + } + position.node = node; + position.offset = offset; + }); + return range; + } + + rangeToNative(range) { + const indexes = range.collapsed + ? [range.index] + : [range.index, range.index + range.length]; + const args = []; + const scrollLength = this.scroll.length(); + indexes.forEach((index, i) => { + index = Math.min(scrollLength - 1, index); + const [leaf, leafOffset] = this.scroll.leaf(index); + const [node, offset] = leaf.position(leafOffset, i !== 0); + args.push(node, offset); + }); + if (args.length < 2) { + return args.concat(args); + } + return args; + } + + scrollIntoView(scrollingContainer) { + const range = this.lastRange; + if (range == null) return; + const bounds = this.getBounds(range.index, range.length); + if (bounds == null) return; + const limit = this.scroll.length() - 1; + const [first] = this.scroll.line(Math.min(range.index, limit)); + let last = first; + if (range.length > 0) { + [last] = this.scroll.line(Math.min(range.index + range.length, limit)); + } + if (first == null || last == null) return; + const scrollBounds = scrollingContainer.getBoundingClientRect(); + if (bounds.top < scrollBounds.top) { + scrollingContainer.scrollTop -= scrollBounds.top - bounds.top; + } else if (bounds.bottom > scrollBounds.bottom) { + scrollingContainer.scrollTop += bounds.bottom - scrollBounds.bottom; + } + } + + setNativeRange( + startNode, + startOffset, + endNode = startNode, + endOffset = startOffset, + force = false, + ) { + selection_debug.info('setNativeRange', startNode, startOffset, endNode, endOffset); + if ( + startNode != null && + (this.root.parentNode == null || + startNode.parentNode == null || + endNode.parentNode == null) + ) { + return; + } + const selection = document.getSelection(); + if (selection == null) return; + if (startNode != null) { + if (!this.hasFocus()) this.root.focus(); + const { native } = this.getNativeRange() || {}; + if ( + native == null || + force || + startNode !== native.startContainer || + startOffset !== native.startOffset || + endNode !== native.endContainer || + endOffset !== native.endOffset + ) { + if (startNode.tagName === 'BR') { + startOffset = Array.from(startNode.parentNode.childNodes).indexOf( + startNode, + ); + startNode = startNode.parentNode; + } + if (endNode.tagName === 'BR') { + endOffset = Array.from(endNode.parentNode.childNodes).indexOf( + endNode, + ); + endNode = endNode.parentNode; + } + const range = document.createRange(); + range.setStart(startNode, startOffset); + range.setEnd(endNode, endOffset); + selection.removeAllRanges(); + selection.addRange(range); + } + } else { + selection.removeAllRanges(); + this.root.blur(); + } + } + + setRange(range, force = false, source = core_emitter.sources.API) { + if (typeof force === 'string') { + source = force; + force = false; + } + selection_debug.info('setRange', range); + if (range != null) { + const args = this.rangeToNative(range); + this.setNativeRange(...args, force); + } else { + this.setNativeRange(null); + } + this.update(source); + } + + update(source = core_emitter.sources.USER) { + const oldRange = this.lastRange; + const [lastRange, nativeRange] = this.getRange(); + this.lastRange = lastRange; + this.lastNative = nativeRange; + if (this.lastRange != null) { + this.savedRange = this.lastRange; + } + if (!deep_equal_default()(oldRange, this.lastRange)) { + if ( + !this.composing && + nativeRange != null && + nativeRange.native.collapsed && + nativeRange.start.node !== this.cursor.textNode + ) { + const range = this.cursor.restore(); + if (range) { + this.setNativeRange( + range.startNode, + range.startOffset, + range.endNode, + range.endOffset, + ); + } + } + const args = [ + core_emitter.events.SELECTION_CHANGE, + clone_default()(this.lastRange), + clone_default()(oldRange), + source, + ]; + this.emitter.emit(core_emitter.events.EDITOR_CHANGE, ...args); + if (source !== core_emitter.sources.SILENT) { + this.emitter.emit(...args); + } + } + } +} + +function contains(parent, descendant) { + try { + // Firefox inserts inaccessible nodes around video elements + descendant.parentNode; // eslint-disable-line no-unused-expressions + } catch (e) { + return false; + } + return parent.contains(descendant); +} + + + +// EXTERNAL MODULE: ./node_modules/quill/assets/icons/align-left.svg +var align_left = __webpack_require__(41); +var align_left_default = /*#__PURE__*/__webpack_require__.n(align_left); + +// EXTERNAL MODULE: ./node_modules/quill/assets/icons/align-center.svg +var align_center = __webpack_require__(42); +var align_center_default = /*#__PURE__*/__webpack_require__.n(align_center); + +// EXTERNAL MODULE: ./node_modules/quill/assets/icons/align-right.svg +var align_right = __webpack_require__(43); +var align_right_default = /*#__PURE__*/__webpack_require__.n(align_right); + +// EXTERNAL MODULE: ./node_modules/quill/assets/icons/align-justify.svg +var align_justify = __webpack_require__(44); +var align_justify_default = /*#__PURE__*/__webpack_require__.n(align_justify); + +// EXTERNAL MODULE: ./node_modules/quill/assets/icons/background.svg +var background = __webpack_require__(45); +var background_default = /*#__PURE__*/__webpack_require__.n(background); + +// EXTERNAL MODULE: ./node_modules/quill/assets/icons/blockquote.svg +var blockquote = __webpack_require__(46); +var blockquote_default = /*#__PURE__*/__webpack_require__.n(blockquote); + +// EXTERNAL MODULE: ./node_modules/quill/assets/icons/bold.svg +var bold = __webpack_require__(47); +var bold_default = /*#__PURE__*/__webpack_require__.n(bold); + +// EXTERNAL MODULE: ./node_modules/quill/assets/icons/clean.svg +var clean = __webpack_require__(48); +var clean_default = /*#__PURE__*/__webpack_require__.n(clean); + +// EXTERNAL MODULE: ./node_modules/quill/assets/icons/code.svg +var code = __webpack_require__(14); +var code_default = /*#__PURE__*/__webpack_require__.n(code); + +// EXTERNAL MODULE: ./node_modules/quill/assets/icons/color.svg +var color = __webpack_require__(49); +var color_default = /*#__PURE__*/__webpack_require__.n(color); + +// EXTERNAL MODULE: ./node_modules/quill/assets/icons/direction-ltr.svg +var direction_ltr = __webpack_require__(50); +var direction_ltr_default = /*#__PURE__*/__webpack_require__.n(direction_ltr); + +// EXTERNAL MODULE: ./node_modules/quill/assets/icons/direction-rtl.svg +var direction_rtl = __webpack_require__(51); +var direction_rtl_default = /*#__PURE__*/__webpack_require__.n(direction_rtl); + +// EXTERNAL MODULE: ./node_modules/quill/assets/icons/formula.svg +var formula = __webpack_require__(52); +var formula_default = /*#__PURE__*/__webpack_require__.n(formula); + +// EXTERNAL MODULE: ./node_modules/quill/assets/icons/header.svg +var icons_header = __webpack_require__(53); +var header_default = /*#__PURE__*/__webpack_require__.n(icons_header); + +// EXTERNAL MODULE: ./node_modules/quill/assets/icons/header-2.svg +var header_2 = __webpack_require__(54); +var header_2_default = /*#__PURE__*/__webpack_require__.n(header_2); + +// EXTERNAL MODULE: ./node_modules/quill/assets/icons/italic.svg +var italic = __webpack_require__(55); +var italic_default = /*#__PURE__*/__webpack_require__.n(italic); + +// EXTERNAL MODULE: ./node_modules/quill/assets/icons/image.svg +var icons_image = __webpack_require__(56); +var image_default = /*#__PURE__*/__webpack_require__.n(icons_image); + +// EXTERNAL MODULE: ./node_modules/quill/assets/icons/indent.svg +var indent = __webpack_require__(57); +var indent_default = /*#__PURE__*/__webpack_require__.n(indent); + +// EXTERNAL MODULE: ./node_modules/quill/assets/icons/outdent.svg +var outdent = __webpack_require__(58); +var outdent_default = /*#__PURE__*/__webpack_require__.n(outdent); + +// EXTERNAL MODULE: ./node_modules/quill/assets/icons/link.svg +var icons_link = __webpack_require__(59); +var link_default = /*#__PURE__*/__webpack_require__.n(icons_link); + +// EXTERNAL MODULE: ./node_modules/quill/assets/icons/list-bullet.svg +var list_bullet = __webpack_require__(60); +var list_bullet_default = /*#__PURE__*/__webpack_require__.n(list_bullet); + +// EXTERNAL MODULE: ./node_modules/quill/assets/icons/list-check.svg +var list_check = __webpack_require__(61); +var list_check_default = /*#__PURE__*/__webpack_require__.n(list_check); + +// EXTERNAL MODULE: ./node_modules/quill/assets/icons/list-ordered.svg +var list_ordered = __webpack_require__(62); +var list_ordered_default = /*#__PURE__*/__webpack_require__.n(list_ordered); + +// EXTERNAL MODULE: ./node_modules/quill/assets/icons/subscript.svg +var subscript = __webpack_require__(63); +var subscript_default = /*#__PURE__*/__webpack_require__.n(subscript); + +// EXTERNAL MODULE: ./node_modules/quill/assets/icons/superscript.svg +var superscript = __webpack_require__(64); +var superscript_default = /*#__PURE__*/__webpack_require__.n(superscript); + +// EXTERNAL MODULE: ./node_modules/quill/assets/icons/strike.svg +var strike = __webpack_require__(65); +var strike_default = /*#__PURE__*/__webpack_require__.n(strike); + +// EXTERNAL MODULE: ./node_modules/quill/assets/icons/table.svg +var icons_table = __webpack_require__(66); +var table_default = /*#__PURE__*/__webpack_require__.n(icons_table); + +// EXTERNAL MODULE: ./node_modules/quill/assets/icons/underline.svg +var underline = __webpack_require__(67); +var underline_default = /*#__PURE__*/__webpack_require__.n(underline); + +// EXTERNAL MODULE: ./node_modules/quill/assets/icons/video.svg +var video = __webpack_require__(68); +var video_default = /*#__PURE__*/__webpack_require__.n(video); + +// CONCATENATED MODULE: ./node_modules/quill/ui/icons.js + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +/* harmony default export */ var ui_icons = ({ + align: { + '': align_left_default.a, + center: align_center_default.a, + right: align_right_default.a, + justify: align_justify_default.a, + }, + background: background_default.a, + blockquote: blockquote_default.a, + bold: bold_default.a, + clean: clean_default.a, + code: code_default.a, + 'code-block': code_default.a, + color: color_default.a, + direction: { + '': direction_ltr_default.a, + rtl: direction_rtl_default.a, + }, + formula: formula_default.a, + header: { + '1': header_default.a, + '2': header_2_default.a, + }, + italic: italic_default.a, + image: image_default.a, + indent: { + '+1': indent_default.a, + '-1': outdent_default.a, + }, + link: link_default.a, + list: { + bullet: list_bullet_default.a, + check: list_check_default.a, + ordered: list_ordered_default.a, + }, + script: { + sub: subscript_default.a, + super: superscript_default.a, + }, + strike: strike_default.a, + table: table_default.a, + underline: underline_default.a, + video: video_default.a, +}); + +// CONCATENATED MODULE: ./node_modules/quill/themes/snow.js + + + + + + + +const TOOLBAR_CONFIG = [ + [{ header: ['1', '2', '3', false] }], + ['bold', 'italic', 'underline', 'link'], + [{ list: 'ordered' }, { list: 'bullet' }], + ['clean'], +]; + +class snow_SnowTooltip extends base_BaseTooltip { + constructor(quill, bounds) { + super(quill, bounds); + this.preview = this.root.querySelector('a.ql-preview'); + } + + listen() { + super.listen(); + this.root.querySelector('a.ql-action').addEventListener('click', event => { + if (this.root.classList.contains('ql-editing')) { + this.save(); + } else { + this.edit('link', this.preview.textContent); + } + event.preventDefault(); + }); + this.root.querySelector('a.ql-remove').addEventListener('click', event => { + if (this.linkRange != null) { + const range = this.linkRange; + this.restoreFocus(); + this.quill.formatText(range, 'link', false, core_emitter.sources.USER); + delete this.linkRange; + } + event.preventDefault(); + this.hide(); + }); + this.quill.on( + core_emitter.events.SELECTION_CHANGE, + (range, oldRange, source) => { + if (range == null) return; + if (range.length === 0 && source === core_emitter.sources.USER) { + const [link, offset] = this.quill.scroll.descendant( + link_Link, + range.index, + ); + if (link != null) { + this.linkRange = new Range(range.index - offset, link.length()); + const preview = link_Link.formats(link.domNode); + this.preview.textContent = preview; + this.preview.setAttribute('href', preview); + this.show(); + this.position(this.quill.getBounds(this.linkRange)); + return; + } + } else { + delete this.linkRange; + } + this.hide(); + }, + ); + } + + show() { + super.show(); + this.root.removeAttribute('data-mode'); + } +} +snow_SnowTooltip.TEMPLATE = [ + '', + '', + '', + '', +].join(''); + +class snow_SnowTheme extends base_BaseTheme { + constructor(quill, options) { + if ( + options.modules.toolbar != null && + options.modules.toolbar.container == null + ) { + options.modules.toolbar.container = TOOLBAR_CONFIG; + } + super(quill, options); + this.quill.container.classList.add('ql-snow'); + } + + extendToolbar(toolbar) { + toolbar.container.classList.add('ql-snow'); + this.buildButtons(toolbar.container.querySelectorAll('button'), ui_icons); + this.buildPickers(toolbar.container.querySelectorAll('select'), ui_icons); + this.tooltip = new snow_SnowTooltip(this.quill, this.options.bounds); + if (toolbar.container.querySelector('.ql-link')) { + this.quill.keyboard.addBinding( + { key: 'k', shortKey: true }, + (range, context) => { + toolbar.handlers.link.call(toolbar, !context.format.link); + }, + ); + } + } +} +snow_SnowTheme.DEFAULTS = extend_default()(true, {}, base_BaseTheme.DEFAULTS, { + modules: { + toolbar: { + handlers: { + link(value) { + if (value) { + const range = this.quill.getSelection(); + if (range == null || range.length === 0) return; + let preview = this.quill.getText(range); + if ( + /^\S+@\S+\.\S+$/.test(preview) && + preview.indexOf('mailto:') !== 0 + ) { + preview = `mailto:${preview}`; + } + const { tooltip } = this.quill.theme; + tooltip.edit('link', preview); + } else { + this.quill.format('link', false); + } + }, + }, + }, + }, +}); + +/* harmony default export */ var snow = (snow_SnowTheme); + +// CONCATENATED MODULE: ./src/ui/table-picker.js + + +class table_picker_TablePicker extends picker { + constructor(select, label) { + super(select); + this.label.innerHTML = label; + this.container.classList.add('ql-table-picker'); + } + + buildItem(option) { + const item = super.buildItem(option); + item.addEventListener('mouseover', () => { + let value = item.getAttribute('data-value').split('x'); + let row = parseInt(value[1]); + let column = parseInt(value[0]); + let items = Array.from(this.container.querySelectorAll('.ql-picker-item')); + let lastItem = this.container.querySelector('.ql-picker-item:last-child'); + value = lastItem.getAttribute('data-value').split('x'); // let rows = parseInt(value[1]); + + let cols = parseInt(value[0]); + items.forEach(i => { + i.classList.remove('hover'); + }); + + for (let r = 0; r < row; r++) { + items.slice(r * cols, r * cols + column).forEach(i => { + i.classList.add('hover'); + }); + } + }); + return item; + } + + selectItem(item, trigger = false) { + super.selectItem(item, trigger); + if (item == null) return; + item.classList.remove('ql-selected'); + + if (item.label) { + item.label.removeAttribute('data-value'); + item.label.removeAttribute('data-label'); + } + } + +} + +/* harmony default export */ var table_picker = (table_picker_TablePicker); +// CONCATENATED MODULE: ./src/themes/better-table-snow.js + + + + +class better_table_snow_BetterTableSnowTheme extends snow { + constructor(quill, options) { + super(quill, options); + } + + buildPickers(selects, icons) { + selects = Array.from(selects); + let pickers = selects.map((select, index, selects) => { + if (select.classList.contains('ql-better-table')) { + selects.splice(index, 1); + + if (select.querySelector('option') == null) { + for (let r = 1; r <= 8; r++) { + for (let c = 1; c <= 10; c++) { + const option = document.createElement('option'); + option.setAttribute('value', c + 'x' + r); + select.appendChild(option); + } + } + } + + return new table_picker(select, icons.table); + } + }); + super.buildPickers(selects, icons); + this.pickers = extend_default()([], this.pickers, pickers); + } + +} + +/* harmony default export */ var better_table_snow = (better_table_snow_BetterTableSnowTheme); +// CONCATENATED MODULE: ./src/utils/node-matchers.js + + +const Delta = external_commonjs_quill_commonjs2_quill_amd_quill_root_Quill_default.a.import('delta'); // rebuild delta + +function matchTableCell(node, delta, scroll) { + const row = node.parentNode; + const table = row.parentNode.tagName === 'TABLE' ? row.parentNode : row.parentNode.parentNode; + const rows = Array.from(table.querySelectorAll('tr')); + const cells = Array.from(row.querySelectorAll('td')); + const rowId = rows.indexOf(row) + 1; + const cellId = cells.indexOf(node) + 1; + const colspan = node.getAttribute('colspan') || false; + const rowspan = node.getAttribute('rowspan') || false; + const cellBg = node.getAttribute('data-cell-bg') || node.style.backgroundColor; // The td from external table has no 'data-cell-bg' + // bugfix: empty table cells copied from other place will be removed unexpectedly + + if (delta.length() === 0) { + delta = new Delta().insert('\n', { + 'table-cell-line': { + row: rowId, + cell: cellId, + rowspan, + colspan + } + }); + return delta; + } + + delta = delta.reduce((newDelta, op) => { + if (op.insert && typeof op.insert === 'string') { + const lines = []; + let insertStr = op.insert; + let start = 0; + + for (let i = 0; i < op.insert.length; i++) { + if (insertStr.charAt(i) === '\n') { + if (i === 0) { + lines.push('\n'); + } else { + lines.push(insertStr.substring(start, i)); + lines.push('\n'); + } + + start = i + 1; + } + } + + const tailStr = insertStr.substring(start); + if (tailStr) lines.push(tailStr); + lines.forEach(text => { + text === '\n' ? newDelta.insert('\n', op.attributes) : newDelta.insert(text, _omit(op.attributes, ['table', 'table-cell-line'])); + }); + } else { + newDelta.insert(op.insert, op.attributes); + } + + return newDelta; + }, new Delta()); + return delta.reduce((newDelta, op) => { + if (op.insert && typeof op.insert === 'string' && op.insert.startsWith('\n')) { + newDelta.insert(op.insert, Object.assign({}, Object.assign({}, { + row: rowId + }, op.attributes.table), { + 'table-cell-line': { + row: rowId, + cell: cellId, + rowspan, + colspan, + 'cell-bg': cellBg + } + }, _omit(op.attributes, ['table']))); + } else { + // bugfix: remove background attr from the delta of table cell + // to prevent unexcepted background attr append. + if (op.attributes && op.attributes.background && op.attributes.background === convertToHex(cellBg)) { + newDelta.insert(op.insert, Object.assign({}, _omit(op.attributes, ['table', 'table-cell-line', 'background']))); + } else { + newDelta.insert(op.insert, Object.assign({}, _omit(op.attributes, ['table', 'table-cell-line']))); + } + } + + return newDelta; + }, new Delta()); +} // replace th tag with td tag + +function matchTableHeader(node, delta, scroll) { + const row = node.parentNode; + const table = row.parentNode.tagName === 'TABLE' ? row.parentNode : row.parentNode.parentNode; + const rows = Array.from(table.querySelectorAll('tr')); + const cells = Array.from(row.querySelectorAll('th')); + const rowId = rows.indexOf(row) + 1; + const cellId = cells.indexOf(node) + 1; + const colspan = node.getAttribute('colspan') || false; + const rowspan = node.getAttribute('rowspan') || false; // bugfix: empty table cells copied from other place will be removed unexpectedly + + if (delta.length() === 0) { + delta = new Delta().insert('\n', { + 'table-cell-line': { + row: rowId, + cell: cellId, + rowspan, + colspan + } }); - modifiedCells.forEach(cell => { - const cellRowspan = parseInt(cell.formats().rowspan, 10); - cell.format("rowspan", cellRowspan + 1); - affectedCells.push(cell); + return delta; + } + + delta = delta.reduce((newDelta, op) => { + if (op.insert && typeof op.insert === 'string') { + const lines = []; + let insertStr = op.insert; + let start = 0; + + for (let i = 0; i < op.insert.length; i++) { + if (insertStr.charAt(i) === '\n') { + if (i === 0) { + lines.push('\n'); + } else { + lines.push(insertStr.substring(start, i)); + lines.push('\n'); + } + + start = i + 1; + } + } + + const tailStr = insertStr.substring(start); + if (tailStr) lines.push(tailStr); // bugfix: no '\n' in op.insert, push a '\n' to lines + + if (lines.indexOf('\n') < 0) { + lines.push('\n'); + } + + lines.forEach(text => { + text === '\n' ? newDelta.insert('\n', { + 'table-cell-line': { + row: rowId, + cell: cellId, + rowspan, + colspan + } + }) : newDelta.insert(text, op.attributes); + }); + } else { + newDelta.insert(op.insert, op.attributes); + } + + return newDelta; + }, new Delta()); + return delta.reduce((newDelta, op) => { + if (op.insert && typeof op.insert === 'string' && op.insert.startsWith('\n')) { + newDelta.insert(op.insert, Object.assign({}, { + 'table-cell-line': { + row: rowId, + cell: cellId, + rowspan, + colspan + } + })); + } else { + newDelta.insert(op.insert, Object.assign({}, _omit(op.attributes, ['table', 'table-cell-line']))); + } + + return newDelta; + }, new Delta()); +} // supplement colgroup and col + +function matchTable(node, delta, scroll) { + let newColDelta = new Delta(); + const topRow = node.querySelector('tr'); // bugfix: empty table will return empty delta + + if (topRow === null) return newColDelta; + const cellsInTopRow = Array.from(topRow.querySelectorAll('td')).concat(Array.from(topRow.querySelectorAll('th'))); + const maxCellsNumber = cellsInTopRow.reduce((sum, cell) => { + const cellColspan = cell.getAttribute('colspan') || 1; + sum = sum + parseInt(cellColspan, 10); + return sum; + }, 0); + const colsNumber = node.querySelectorAll('col').length; // issue #2 + // bugfix: the table copied from Excel had some default col tags missing + // add missing col tags + + if (colsNumber === maxCellsNumber) { + return delta; + } else { + for (let i = 0; i < maxCellsNumber - colsNumber; i++) { + newColDelta.insert('\n', { + 'table-col': true + }); + } + + if (colsNumber === 0) return newColDelta.concat(delta); + let lastNumber = 0; + return delta.reduce((finalDelta, op) => { + finalDelta.insert(op.insert, op.attributes); + + if (op.attributes && op.attributes['table-col']) { + lastNumber += op.insert.length; + + if (lastNumber === colsNumber) { + finalDelta = finalDelta.concat(newColDelta); + } + } + + return finalDelta; + }, new Delta()); + } +} +// CONCATENATED MODULE: ./src/quill-better-table.js + + + + + + + // import table node matchers + + + +const Module = external_commonjs_quill_commonjs2_quill_amd_quill_root_Quill_default.a.import('core/module'); +const quill_better_table_Delta = external_commonjs_quill_commonjs2_quill_amd_quill_root_Quill_default.a.import('delta'); + + +class quill_better_table_BetterTable extends Module { + static register() { + external_commonjs_quill_commonjs2_quill_amd_quill_root_Quill_default.a.register(TableCol, true); + external_commonjs_quill_commonjs2_quill_amd_quill_root_Quill_default.a.register(TableColGroup, true); + external_commonjs_quill_commonjs2_quill_amd_quill_root_Quill_default.a.register(TableCellLine, true); + external_commonjs_quill_commonjs2_quill_amd_quill_root_Quill_default.a.register(TableCell, true); + external_commonjs_quill_commonjs2_quill_amd_quill_root_Quill_default.a.register(TableRow, true); + external_commonjs_quill_commonjs2_quill_amd_quill_root_Quill_default.a.register(TableBody, true); + external_commonjs_quill_commonjs2_quill_amd_quill_root_Quill_default.a.register(table_TableContainer, true); + external_commonjs_quill_commonjs2_quill_amd_quill_root_Quill_default.a.register(table_TableViewWrapper, true); + external_commonjs_quill_commonjs2_quill_amd_quill_root_Quill_default.a.register(table_TableViewWrapper, true); // register customized Header,overwriting quill built-in Header + // Quill.register('formats/header', Header, true); + + external_commonjs_quill_commonjs2_quill_amd_quill_root_Quill_default.a.register('themes/better-table-snow', better_table_snow, true); + external_commonjs_quill_commonjs2_quill_amd_quill_root_Quill_default.a.register('ui/table-picker', table_picker, true); + } + + constructor(quill, options) { + super(quill, options); // handle click on quill-better-table + + this.quill.root.addEventListener('click', evt => { + // bugfix: evt.path is undefined in Safari, FF, Micro Edge + const path = getEventComposedPath(evt); + if (!path || path.length <= 0) return; + const tableNode = path.filter(node => { + return node.tagName && node.tagName.toUpperCase() === 'TABLE' && node.classList.contains('quill-better-table'); + })[0]; + + if (tableNode) { + // current table clicked + if (this.table === tableNode) return; // other table clicked + + if (this.table) this.hideTableTools(); + this.showTableTools(tableNode, quill, options); + } else if (this.table) { + // other clicked + this.hideTableTools(); + } + }, false); // handle right click on quill-better-table + + this.quill.root.addEventListener('contextmenu', evt => { + if (!this.table) return true; + evt.preventDefault(); // bugfix: evt.path is undefined in Safari, FF, Micro Edge + + const path = getEventComposedPath(evt); + if (!path || path.length <= 0) return; + const tableNode = path.filter(node => { + return node.tagName && node.tagName.toUpperCase() === 'TABLE' && node.classList.contains('quill-better-table'); + })[0]; + const rowNode = path.filter(node => { + return node.tagName && node.tagName.toUpperCase() === 'TR' && node.getAttribute('data-row'); + })[0]; + const cellNode = path.filter(node => { + return node.tagName && node.tagName.toUpperCase() === 'TD' && node.getAttribute('data-row'); + })[0]; + let isTargetCellSelected = this.tableSelection.selectedTds.map(tableCell => tableCell.domNode).includes(cellNode); + + if (this.tableSelection.selectedTds.length <= 0 || !isTargetCellSelected) { + this.tableSelection.setSelection(cellNode.getBoundingClientRect(), cellNode.getBoundingClientRect()); + } + + if (this.tableOperationMenu) this.tableOperationMenu = this.tableOperationMenu.destroy(); + + if (tableNode) { + this.tableOperationMenu = new table_operation_menu_TableOperationMenu({ + table: tableNode, + row: rowNode, + cell: cellNode, + left: evt.pageX, + top: evt.pageY + }, quill, options.operationMenu); + } + }, false); // add keyboard binding:Backspace + // prevent user hits backspace to delete table cell + + const KeyBoard = quill.getModule('keyboard'); + quill.keyboard.addBinding({ + key: 'Backspace' + }, {}, function (range, context) { + if (range.index === 0 || this.quill.getLength() <= 1) return true; + const [line] = this.quill.getLine(range.index); + + if (context.offset === 0) { + const [prev] = this.quill.getLine(range.index - 1); + + if (prev != null) { + if (prev.statics.blotName === 'table-cell-line' && line.statics.blotName !== 'table-cell-line') return false; + } + } + + return true; + }); // since only one matched bindings callback will excute. + // expected my binding callback excute first + // I changed the order of binding callbacks + + let thisBinding = quill.keyboard.bindings['Backspace'].pop(); + quill.keyboard.bindings['Backspace'].splice(0, 1, thisBinding); // add Matchers to match and render quill-better-table for initialization + // or pasting + + quill.clipboard.addMatcher('td', matchTableCell); + quill.clipboard.addMatcher('th', matchTableHeader); + quill.clipboard.addMatcher('table', matchTable); // quill.clipboard.addMatcher('h1, h2, h3, h4, h5, h6', matchHeader) + // remove matcher for tr tag + + quill.clipboard.matchers = quill.clipboard.matchers.filter(matcher => { + return matcher[0] !== 'tr'; }); - const refRow = this.rows().find(row => { - let rowRect = getRelativeRect(row.domNode.getBoundingClientRect(), editorWrapper); + const toolbar = quill.getModule('toolbar'); + + if (toolbar) { + toolbar.addHandler('better-table', this.insertTable); + } + } + + getTable(range = this.quill.getSelection()) { + if (range == null) return [null, null, null, -1]; + const [cellLine, offset] = this.quill.getLine(range.index); + + if (cellLine == null || cellLine.statics.blotName !== TableCellLine.blotName) { + return [null, null, null, -1]; + } + + const cell = cellLine.tableCell(); + const row = cell.row(); + const table = row.table(); + return [table, row, cell, offset]; + } + + insertTable(rows, columns) { + if (!columns) { + if (rows.match(/^\d+x\d+$/)) { + let tmp = rows.split('x'); + columns = tmp[0]; + rows = tmp[1]; + } else { + return; + } + } + + const range = this.quill.getSelection(true); + if (range == null) return; + let currentBlot = this.quill.getLeaf(range.index)[0]; + let delta = new quill_better_table_Delta().retain(range.index); + + if (isInTableCell(currentBlot)) { + console.warn("Can not insert table into a table cell."); + return; + } + + delta.insert('\n'); // insert table column + + delta = new Array(columns).fill('\n').reduce((memo, text) => { + memo.insert(text, { + 'table-col': true + }); + return memo; + }, delta); // insert table cell line with empty line + + delta = new Array(rows).fill(0).reduce(memo => { + let tableRowId = table_rowId(); + return new Array(columns).fill('\n').reduce((memo, text) => { + memo.insert(text, { + 'table-cell-line': { + row: tableRowId, + cell: table_cellId() + } + }); + return memo; + }, memo); + }, delta); + this.quill.updateContents(delta, external_commonjs_quill_commonjs2_quill_amd_quill_root_Quill_default.a.sources.USER); + this.quill.setSelection(range.index + columns + 1, external_commonjs_quill_commonjs2_quill_amd_quill_root_Quill_default.a.sources.API); + } + + showTableTools(table, quill, options) { + this.table = table; + this.columnTool = new table_column_tool_TableColumnTool(table, quill, options); + this.tableSelection = new table_selection_TableSelection(table, quill, options); + } + + hideTableTools() { + this.columnTool && this.columnTool.destroy(); + this.tableSelection && this.tableSelection.destroy(); + this.tableOperationMenu && this.tableOperationMenu.destroy(); + this.columnTool = null; + this.tableSelection = null; + this.tableOperationMenu = null; + this.table = null; + } + +} + +quill_better_table_BetterTable.keyboardBindings = { + 'table-cell-line backspace': { + key: 'Backspace', + format: ['table-cell-line'], + collapsed: true, + offset: 0, + + handler(range, context) { + const [line, offset] = this.quill.getLine(range.index); + + if (!line.prev || line.prev.statics.blotName !== 'table-cell-line') { + return false; + } + + return true; + } + + }, + 'table-cell-line delete': { + key: 'Delete', + format: ['table-cell-line'], + collapsed: true, + suffix: /^$/, + + handler() {} + + }, + 'table-cell-line enter': { + key: 'Enter', + shiftKey: null, + format: ['table-cell-line'], + + handler(range, context) { + // bugfix: a unexpected new line inserted when user compositionend with hitting Enter + if (this.quill.selection && this.quill.selection.composing) return; + const Scope = external_commonjs_quill_commonjs2_quill_amd_quill_root_Quill_default.a.imports.parchment.Scope; + + if (range.length > 0) { + this.quill.scroll.deleteAt(range.index, range.length); // So we do not trigger text-change + } + + const lineFormats = Object.keys(context.format).reduce((formats, format) => { + if (this.quill.scroll.query(format, Scope.BLOCK) && !Array.isArray(context.format[format])) { + formats[format] = context.format[format]; + } + + return formats; + }, {}); // insert new cellLine with lineFormats + + this.quill.insertText(range.index, '\n', lineFormats['table-cell-line'], external_commonjs_quill_commonjs2_quill_amd_quill_root_Quill_default.a.sources.USER); // Earlier scroll.deleteAt might have messed up our selection, + // so insertText's built in selection preservation is not reliable + + this.quill.setSelection(range.index + 1, external_commonjs_quill_commonjs2_quill_amd_quill_root_Quill_default.a.sources.SILENT); + this.quill.focus(); + Object.keys(context.format).forEach(name => { + if (lineFormats[name] != null) return; + if (Array.isArray(context.format[name])) return; + if (name === 'link') return; + this.quill.format(name, context.format[name], external_commonjs_quill_commonjs2_quill_amd_quill_root_Quill_default.a.sources.USER); + }); + } + + }, + 'table-cell-line up': makeTableArrowHandler(true), + 'table-cell-line down': makeTableArrowHandler(false), + 'down-to-table': { + key: 'ArrowDown', + collapsed: true, + + handler(range, context) { + const target = context.line.next; + + if (target && target.statics.blotName === 'table-view') { + const targetCell = target.table().rows()[0].children.head; + const targetLine = targetCell.children.head; + this.quill.setSelection(targetLine.offset(this.quill.scroll), 0, external_commonjs_quill_commonjs2_quill_amd_quill_root_Quill_default.a.sources.USER); + return false; + } + + return true; + } + + }, + 'up-to-table': { + key: 'ArrowUp', + collapsed: true, + + handler(range, context) { + const target = context.line.prev; + + if (target && target.statics.blotName === 'table-view') { + const rows = target.table().rows(); + const targetCell = rows[rows.length - 1].children.head; + const targetLine = targetCell.children.head; + this.quill.setSelection(targetLine.offset(this.quill.scroll), 0, external_commonjs_quill_commonjs2_quill_amd_quill_root_Quill_default.a.sources.USER); + return false; + } + + return true; + } + + } +}; + +function makeTableArrowHandler(up) { + return { + key: up ? 'ArrowUp' : 'ArrowDown', + collapsed: true, + format: ['table-cell-line'], + + handler(range, context) { + // TODO move to table module + const key = up ? 'prev' : 'next'; + const targetLine = context.line[key]; + if (targetLine != null) return true; + const cell = context.line.parent; + const targetRow = cell.parent[key]; + + if (targetRow != null && targetRow.statics.blotName === 'table-row') { + let targetCell = targetRow.children.head; + let totalColspanOfTargetCell = parseInt(targetCell.formats()['colspan'], 10); + let cur = cell; + let totalColspanOfCur = parseInt(cur.formats()['colspan'], 10); // get targetCell above current cell depends on colspan + + while (cur.prev != null) { + cur = cur.prev; + totalColspanOfCur += parseInt(cur.formats()['colspan'], 10); + } + + while (targetCell.next != null && totalColspanOfTargetCell < totalColspanOfCur) { + targetCell = targetCell.next; + totalColspanOfTargetCell += parseInt(targetCell.formats()['colspan'], 10); + } + + const index = targetCell.offset(this.quill.scroll); + this.quill.setSelection(index, 0, external_commonjs_quill_commonjs2_quill_amd_quill_root_Quill_default.a.sources.USER); + } else { + const targetLine = cell.table().parent[key]; + + if (targetLine != null) { + if (up) { + this.quill.setSelection(targetLine.offset(this.quill.scroll) + targetLine.length() - 1, 0, external_commonjs_quill_commonjs2_quill_amd_quill_root_Quill_default.a.sources.USER); + } else { + this.quill.setSelection(targetLine.offset(this.quill.scroll), 0, external_commonjs_quill_commonjs2_quill_amd_quill_root_Quill_default.a.sources.USER); + } + } + } + + return false; + } + + }; +} + +function isTableCell(blot) { + return blot.statics.blotName === TableCell.blotName; +} + +function isInTableCell(current) { + return current && current.parent ? isTableCell(current.parent) ? true : isInTableCell(current.parent) : false; +} + +/* harmony default export */ var quill_better_table = __webpack_exports__["default"] = (quill_better_table_BetterTable); + +/***/ }), +/* 70 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; +/* WEBPACK VAR INJECTION */(function(global) {/*! + * The buffer module from node.js, for the browser. + * + * @author Feross Aboukhadijeh + * @license MIT + */ +/* eslint-disable no-proto */ + + + +var base64 = __webpack_require__(71) +var ieee754 = __webpack_require__(72) +var isArray = __webpack_require__(73) + +exports.Buffer = Buffer +exports.SlowBuffer = SlowBuffer +exports.INSPECT_MAX_BYTES = 50 + +/** + * If `Buffer.TYPED_ARRAY_SUPPORT`: + * === true Use Uint8Array implementation (fastest) + * === false Use Object implementation (most compatible, even IE6) + * + * Browsers that support typed arrays are IE 10+, Firefox 4+, Chrome 7+, Safari 5.1+, + * Opera 11.6+, iOS 4.2+. + * + * Due to various browser bugs, sometimes the Object implementation will be used even + * when the browser supports typed arrays. + * + * Note: + * + * - Firefox 4-29 lacks support for adding new properties to `Uint8Array` instances, + * See: https://bugzilla.mozilla.org/show_bug.cgi?id=695438. + * + * - Chrome 9-10 is missing the `TypedArray.prototype.subarray` function. + * + * - IE10 has a broken `TypedArray.prototype.subarray` function which returns arrays of + * incorrect length in some situations. + + * We detect these buggy browsers and set `Buffer.TYPED_ARRAY_SUPPORT` to `false` so they + * get the Object implementation, which is slower but behaves correctly. + */ +Buffer.TYPED_ARRAY_SUPPORT = global.TYPED_ARRAY_SUPPORT !== undefined + ? global.TYPED_ARRAY_SUPPORT + : typedArraySupport() + +/* + * Export kMaxLength after typed array support is determined. + */ +exports.kMaxLength = kMaxLength() + +function typedArraySupport () { + try { + var arr = new Uint8Array(1) + arr.__proto__ = {__proto__: Uint8Array.prototype, foo: function () { return 42 }} + return arr.foo() === 42 && // typed array instances can be augmented + typeof arr.subarray === 'function' && // chrome 9-10 lack `subarray` + arr.subarray(1, 1).byteLength === 0 // ie10 has broken `subarray` + } catch (e) { + return false + } +} + +function kMaxLength () { + return Buffer.TYPED_ARRAY_SUPPORT + ? 0x7fffffff + : 0x3fffffff +} + +function createBuffer (that, length) { + if (kMaxLength() < length) { + throw new RangeError('Invalid typed array length') + } + if (Buffer.TYPED_ARRAY_SUPPORT) { + // Return an augmented `Uint8Array` instance, for best performance + that = new Uint8Array(length) + that.__proto__ = Buffer.prototype + } else { + // Fallback: Return an object instance of the Buffer class + if (that === null) { + that = new Buffer(length) + } + that.length = length + } + + return that +} + +/** + * The Buffer constructor returns instances of `Uint8Array` that have their + * prototype changed to `Buffer.prototype`. Furthermore, `Buffer` is a subclass of + * `Uint8Array`, so the returned instances will have all the node `Buffer` methods + * and the `Uint8Array` methods. Square bracket notation works as expected -- it + * returns a single octet. + * + * The `Uint8Array` prototype remains unmodified. + */ + +function Buffer (arg, encodingOrOffset, length) { + if (!Buffer.TYPED_ARRAY_SUPPORT && !(this instanceof Buffer)) { + return new Buffer(arg, encodingOrOffset, length) + } + + // Common case. + if (typeof arg === 'number') { + if (typeof encodingOrOffset === 'string') { + throw new Error( + 'If encoding is specified then the first argument must be a string' + ) + } + return allocUnsafe(this, arg) + } + return from(this, arg, encodingOrOffset, length) +} + +Buffer.poolSize = 8192 // not used by this implementation + +// TODO: Legacy, not needed anymore. Remove in next major version. +Buffer._augment = function (arr) { + arr.__proto__ = Buffer.prototype + return arr +} + +function from (that, value, encodingOrOffset, length) { + if (typeof value === 'number') { + throw new TypeError('"value" argument must not be a number') + } + + if (typeof ArrayBuffer !== 'undefined' && value instanceof ArrayBuffer) { + return fromArrayBuffer(that, value, encodingOrOffset, length) + } + + if (typeof value === 'string') { + return fromString(that, value, encodingOrOffset) + } + + return fromObject(that, value) +} + +/** + * Functionally equivalent to Buffer(arg, encoding) but throws a TypeError + * if value is a number. + * Buffer.from(str[, encoding]) + * Buffer.from(array) + * Buffer.from(buffer) + * Buffer.from(arrayBuffer[, byteOffset[, length]]) + **/ +Buffer.from = function (value, encodingOrOffset, length) { + return from(null, value, encodingOrOffset, length) +} + +if (Buffer.TYPED_ARRAY_SUPPORT) { + Buffer.prototype.__proto__ = Uint8Array.prototype + Buffer.__proto__ = Uint8Array + if (typeof Symbol !== 'undefined' && Symbol.species && + Buffer[Symbol.species] === Buffer) { + // Fix subarray() in ES2016. See: https://github.com/feross/buffer/pull/97 + Object.defineProperty(Buffer, Symbol.species, { + value: null, + configurable: true + }) + } +} + +function assertSize (size) { + if (typeof size !== 'number') { + throw new TypeError('"size" argument must be a number') + } else if (size < 0) { + throw new RangeError('"size" argument must not be negative') + } +} + +function alloc (that, size, fill, encoding) { + assertSize(size) + if (size <= 0) { + return createBuffer(that, size) + } + if (fill !== undefined) { + // Only pay attention to encoding if it's a string. This + // prevents accidentally sending in a number that would + // be interpretted as a start offset. + return typeof encoding === 'string' + ? createBuffer(that, size).fill(fill, encoding) + : createBuffer(that, size).fill(fill) + } + return createBuffer(that, size) +} + +/** + * Creates a new filled Buffer instance. + * alloc(size[, fill[, encoding]]) + **/ +Buffer.alloc = function (size, fill, encoding) { + return alloc(null, size, fill, encoding) +} + +function allocUnsafe (that, size) { + assertSize(size) + that = createBuffer(that, size < 0 ? 0 : checked(size) | 0) + if (!Buffer.TYPED_ARRAY_SUPPORT) { + for (var i = 0; i < size; ++i) { + that[i] = 0 + } + } + return that +} + +/** + * Equivalent to Buffer(num), by default creates a non-zero-filled Buffer instance. + * */ +Buffer.allocUnsafe = function (size) { + return allocUnsafe(null, size) +} +/** + * Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance. + */ +Buffer.allocUnsafeSlow = function (size) { + return allocUnsafe(null, size) +} + +function fromString (that, string, encoding) { + if (typeof encoding !== 'string' || encoding === '') { + encoding = 'utf8' + } + + if (!Buffer.isEncoding(encoding)) { + throw new TypeError('"encoding" must be a valid string encoding') + } + + var length = byteLength(string, encoding) | 0 + that = createBuffer(that, length) + + var actual = that.write(string, encoding) + + if (actual !== length) { + // Writing a hex string, for example, that contains invalid characters will + // cause everything after the first invalid character to be ignored. (e.g. + // 'abxxcd' will be treated as 'ab') + that = that.slice(0, actual) + } + + return that +} + +function fromArrayLike (that, array) { + var length = array.length < 0 ? 0 : checked(array.length) | 0 + that = createBuffer(that, length) + for (var i = 0; i < length; i += 1) { + that[i] = array[i] & 255 + } + return that +} + +function fromArrayBuffer (that, array, byteOffset, length) { + array.byteLength // this throws if `array` is not a valid ArrayBuffer + + if (byteOffset < 0 || array.byteLength < byteOffset) { + throw new RangeError('\'offset\' is out of bounds') + } + + if (array.byteLength < byteOffset + (length || 0)) { + throw new RangeError('\'length\' is out of bounds') + } + + if (byteOffset === undefined && length === undefined) { + array = new Uint8Array(array) + } else if (length === undefined) { + array = new Uint8Array(array, byteOffset) + } else { + array = new Uint8Array(array, byteOffset, length) + } + + if (Buffer.TYPED_ARRAY_SUPPORT) { + // Return an augmented `Uint8Array` instance, for best performance + that = array + that.__proto__ = Buffer.prototype + } else { + // Fallback: Return an object instance of the Buffer class + that = fromArrayLike(that, array) + } + return that +} + +function fromObject (that, obj) { + if (Buffer.isBuffer(obj)) { + var len = checked(obj.length) | 0 + that = createBuffer(that, len) + + if (that.length === 0) { + return that + } + + obj.copy(that, 0, 0, len) + return that + } + + if (obj) { + if ((typeof ArrayBuffer !== 'undefined' && + obj.buffer instanceof ArrayBuffer) || 'length' in obj) { + if (typeof obj.length !== 'number' || isnan(obj.length)) { + return createBuffer(that, 0) + } + return fromArrayLike(that, obj) + } + + if (obj.type === 'Buffer' && isArray(obj.data)) { + return fromArrayLike(that, obj.data) + } + } + + throw new TypeError('First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.') +} + +function checked (length) { + // Note: cannot use `length < kMaxLength()` here because that fails when + // length is NaN (which is otherwise coerced to zero.) + if (length >= kMaxLength()) { + throw new RangeError('Attempt to allocate Buffer larger than maximum ' + + 'size: 0x' + kMaxLength().toString(16) + ' bytes') + } + return length | 0 +} + +function SlowBuffer (length) { + if (+length != length) { // eslint-disable-line eqeqeq + length = 0 + } + return Buffer.alloc(+length) +} + +Buffer.isBuffer = function isBuffer (b) { + return !!(b != null && b._isBuffer) +} + +Buffer.compare = function compare (a, b) { + if (!Buffer.isBuffer(a) || !Buffer.isBuffer(b)) { + throw new TypeError('Arguments must be Buffers') + } + + if (a === b) return 0 + + var x = a.length + var y = b.length + + for (var i = 0, len = Math.min(x, y); i < len; ++i) { + if (a[i] !== b[i]) { + x = a[i] + y = b[i] + break + } + } + + if (x < y) return -1 + if (y < x) return 1 + return 0 +} + +Buffer.isEncoding = function isEncoding (encoding) { + switch (String(encoding).toLowerCase()) { + case 'hex': + case 'utf8': + case 'utf-8': + case 'ascii': + case 'latin1': + case 'binary': + case 'base64': + case 'ucs2': + case 'ucs-2': + case 'utf16le': + case 'utf-16le': + return true + default: + return false + } +} + +Buffer.concat = function concat (list, length) { + if (!isArray(list)) { + throw new TypeError('"list" argument must be an Array of Buffers') + } + + if (list.length === 0) { + return Buffer.alloc(0) + } + + var i + if (length === undefined) { + length = 0 + for (i = 0; i < list.length; ++i) { + length += list[i].length + } + } + + var buffer = Buffer.allocUnsafe(length) + var pos = 0 + for (i = 0; i < list.length; ++i) { + var buf = list[i] + if (!Buffer.isBuffer(buf)) { + throw new TypeError('"list" argument must be an Array of Buffers') + } + buf.copy(buffer, pos) + pos += buf.length + } + return buffer +} + +function byteLength (string, encoding) { + if (Buffer.isBuffer(string)) { + return string.length + } + if (typeof ArrayBuffer !== 'undefined' && typeof ArrayBuffer.isView === 'function' && + (ArrayBuffer.isView(string) || string instanceof ArrayBuffer)) { + return string.byteLength + } + if (typeof string !== 'string') { + string = '' + string + } + + var len = string.length + if (len === 0) return 0 + + // Use a for loop to avoid recursion + var loweredCase = false + for (;;) { + switch (encoding) { + case 'ascii': + case 'latin1': + case 'binary': + return len + case 'utf8': + case 'utf-8': + case undefined: + return utf8ToBytes(string).length + case 'ucs2': + case 'ucs-2': + case 'utf16le': + case 'utf-16le': + return len * 2 + case 'hex': + return len >>> 1 + case 'base64': + return base64ToBytes(string).length + default: + if (loweredCase) return utf8ToBytes(string).length // assume utf8 + encoding = ('' + encoding).toLowerCase() + loweredCase = true + } + } +} +Buffer.byteLength = byteLength + +function slowToString (encoding, start, end) { + var loweredCase = false + + // No need to verify that "this.length <= MAX_UINT32" since it's a read-only + // property of a typed array. + + // This behaves neither like String nor Uint8Array in that we set start/end + // to their upper/lower bounds if the value passed is out of range. + // undefined is handled specially as per ECMA-262 6th Edition, + // Section 13.3.3.7 Runtime Semantics: KeyedBindingInitialization. + if (start === undefined || start < 0) { + start = 0 + } + // Return early if start > this.length. Done here to prevent potential uint32 + // coercion fail below. + if (start > this.length) { + return '' + } + + if (end === undefined || end > this.length) { + end = this.length + } + + if (end <= 0) { + return '' + } + + // Force coersion to uint32. This will also coerce falsey/NaN values to 0. + end >>>= 0 + start >>>= 0 + + if (end <= start) { + return '' + } + + if (!encoding) encoding = 'utf8' + + while (true) { + switch (encoding) { + case 'hex': + return hexSlice(this, start, end) + + case 'utf8': + case 'utf-8': + return utf8Slice(this, start, end) + + case 'ascii': + return asciiSlice(this, start, end) + + case 'latin1': + case 'binary': + return latin1Slice(this, start, end) + + case 'base64': + return base64Slice(this, start, end) + + case 'ucs2': + case 'ucs-2': + case 'utf16le': + case 'utf-16le': + return utf16leSlice(this, start, end) + + default: + if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding) + encoding = (encoding + '').toLowerCase() + loweredCase = true + } + } +} + +// The property is used by `Buffer.isBuffer` and `is-buffer` (in Safari 5-7) to detect +// Buffer instances. +Buffer.prototype._isBuffer = true + +function swap (b, n, m) { + var i = b[n] + b[n] = b[m] + b[m] = i +} + +Buffer.prototype.swap16 = function swap16 () { + var len = this.length + if (len % 2 !== 0) { + throw new RangeError('Buffer size must be a multiple of 16-bits') + } + for (var i = 0; i < len; i += 2) { + swap(this, i, i + 1) + } + return this +} + +Buffer.prototype.swap32 = function swap32 () { + var len = this.length + if (len % 4 !== 0) { + throw new RangeError('Buffer size must be a multiple of 32-bits') + } + for (var i = 0; i < len; i += 4) { + swap(this, i, i + 3) + swap(this, i + 1, i + 2) + } + return this +} + +Buffer.prototype.swap64 = function swap64 () { + var len = this.length + if (len % 8 !== 0) { + throw new RangeError('Buffer size must be a multiple of 64-bits') + } + for (var i = 0; i < len; i += 8) { + swap(this, i, i + 7) + swap(this, i + 1, i + 6) + swap(this, i + 2, i + 5) + swap(this, i + 3, i + 4) + } + return this +} + +Buffer.prototype.toString = function toString () { + var length = this.length | 0 + if (length === 0) return '' + if (arguments.length === 0) return utf8Slice(this, 0, length) + return slowToString.apply(this, arguments) +} + +Buffer.prototype.equals = function equals (b) { + if (!Buffer.isBuffer(b)) throw new TypeError('Argument must be a Buffer') + if (this === b) return true + return Buffer.compare(this, b) === 0 +} + +Buffer.prototype.inspect = function inspect () { + var str = '' + var max = exports.INSPECT_MAX_BYTES + if (this.length > 0) { + str = this.toString('hex', 0, max).match(/.{2}/g).join(' ') + if (this.length > max) str += ' ... ' + } + return '' +} + +Buffer.prototype.compare = function compare (target, start, end, thisStart, thisEnd) { + if (!Buffer.isBuffer(target)) { + throw new TypeError('Argument must be a Buffer') + } + + if (start === undefined) { + start = 0 + } + if (end === undefined) { + end = target ? target.length : 0 + } + if (thisStart === undefined) { + thisStart = 0 + } + if (thisEnd === undefined) { + thisEnd = this.length + } + + if (start < 0 || end > target.length || thisStart < 0 || thisEnd > this.length) { + throw new RangeError('out of range index') + } + + if (thisStart >= thisEnd && start >= end) { + return 0 + } + if (thisStart >= thisEnd) { + return -1 + } + if (start >= end) { + return 1 + } + + start >>>= 0 + end >>>= 0 + thisStart >>>= 0 + thisEnd >>>= 0 + + if (this === target) return 0 + + var x = thisEnd - thisStart + var y = end - start + var len = Math.min(x, y) + + var thisCopy = this.slice(thisStart, thisEnd) + var targetCopy = target.slice(start, end) + + for (var i = 0; i < len; ++i) { + if (thisCopy[i] !== targetCopy[i]) { + x = thisCopy[i] + y = targetCopy[i] + break + } + } + + if (x < y) return -1 + if (y < x) return 1 + return 0 +} + +// Finds either the first index of `val` in `buffer` at offset >= `byteOffset`, +// OR the last index of `val` in `buffer` at offset <= `byteOffset`. +// +// Arguments: +// - buffer - a Buffer to search +// - val - a string, Buffer, or number +// - byteOffset - an index into `buffer`; will be clamped to an int32 +// - encoding - an optional encoding, relevant is val is a string +// - dir - true for indexOf, false for lastIndexOf +function bidirectionalIndexOf (buffer, val, byteOffset, encoding, dir) { + // Empty buffer means no match + if (buffer.length === 0) return -1 + + // Normalize byteOffset + if (typeof byteOffset === 'string') { + encoding = byteOffset + byteOffset = 0 + } else if (byteOffset > 0x7fffffff) { + byteOffset = 0x7fffffff + } else if (byteOffset < -0x80000000) { + byteOffset = -0x80000000 + } + byteOffset = +byteOffset // Coerce to Number. + if (isNaN(byteOffset)) { + // byteOffset: it it's undefined, null, NaN, "foo", etc, search whole buffer + byteOffset = dir ? 0 : (buffer.length - 1) + } + + // Normalize byteOffset: negative offsets start from the end of the buffer + if (byteOffset < 0) byteOffset = buffer.length + byteOffset + if (byteOffset >= buffer.length) { + if (dir) return -1 + else byteOffset = buffer.length - 1 + } else if (byteOffset < 0) { + if (dir) byteOffset = 0 + else return -1 + } + + // Normalize val + if (typeof val === 'string') { + val = Buffer.from(val, encoding) + } + + // Finally, search either indexOf (if dir is true) or lastIndexOf + if (Buffer.isBuffer(val)) { + // Special case: looking for empty string/buffer always fails + if (val.length === 0) { + return -1 + } + return arrayIndexOf(buffer, val, byteOffset, encoding, dir) + } else if (typeof val === 'number') { + val = val & 0xFF // Search for a byte value [0-255] + if (Buffer.TYPED_ARRAY_SUPPORT && + typeof Uint8Array.prototype.indexOf === 'function') { + if (dir) { + return Uint8Array.prototype.indexOf.call(buffer, val, byteOffset) + } else { + return Uint8Array.prototype.lastIndexOf.call(buffer, val, byteOffset) + } + } + return arrayIndexOf(buffer, [ val ], byteOffset, encoding, dir) + } + + throw new TypeError('val must be string, number or Buffer') +} + +function arrayIndexOf (arr, val, byteOffset, encoding, dir) { + var indexSize = 1 + var arrLength = arr.length + var valLength = val.length + + if (encoding !== undefined) { + encoding = String(encoding).toLowerCase() + if (encoding === 'ucs2' || encoding === 'ucs-2' || + encoding === 'utf16le' || encoding === 'utf-16le') { + if (arr.length < 2 || val.length < 2) { + return -1 + } + indexSize = 2 + arrLength /= 2 + valLength /= 2 + byteOffset /= 2 + } + } + + function read (buf, i) { + if (indexSize === 1) { + return buf[i] + } else { + return buf.readUInt16BE(i * indexSize) + } + } + + var i + if (dir) { + var foundIndex = -1 + for (i = byteOffset; i < arrLength; i++) { + if (read(arr, i) === read(val, foundIndex === -1 ? 0 : i - foundIndex)) { + if (foundIndex === -1) foundIndex = i + if (i - foundIndex + 1 === valLength) return foundIndex * indexSize + } else { + if (foundIndex !== -1) i -= i - foundIndex + foundIndex = -1 + } + } + } else { + if (byteOffset + valLength > arrLength) byteOffset = arrLength - valLength + for (i = byteOffset; i >= 0; i--) { + var found = true + for (var j = 0; j < valLength; j++) { + if (read(arr, i + j) !== read(val, j)) { + found = false + break + } + } + if (found) return i + } + } + + return -1 +} + +Buffer.prototype.includes = function includes (val, byteOffset, encoding) { + return this.indexOf(val, byteOffset, encoding) !== -1 +} + +Buffer.prototype.indexOf = function indexOf (val, byteOffset, encoding) { + return bidirectionalIndexOf(this, val, byteOffset, encoding, true) +} + +Buffer.prototype.lastIndexOf = function lastIndexOf (val, byteOffset, encoding) { + return bidirectionalIndexOf(this, val, byteOffset, encoding, false) +} + +function hexWrite (buf, string, offset, length) { + offset = Number(offset) || 0 + var remaining = buf.length - offset + if (!length) { + length = remaining + } else { + length = Number(length) + if (length > remaining) { + length = remaining + } + } + + // must be an even number of digits + var strLen = string.length + if (strLen % 2 !== 0) throw new TypeError('Invalid hex string') + + if (length > strLen / 2) { + length = strLen / 2 + } + for (var i = 0; i < length; ++i) { + var parsed = parseInt(string.substr(i * 2, 2), 16) + if (isNaN(parsed)) return i + buf[offset + i] = parsed + } + return i +} + +function utf8Write (buf, string, offset, length) { + return blitBuffer(utf8ToBytes(string, buf.length - offset), buf, offset, length) +} + +function asciiWrite (buf, string, offset, length) { + return blitBuffer(asciiToBytes(string), buf, offset, length) +} + +function latin1Write (buf, string, offset, length) { + return asciiWrite(buf, string, offset, length) +} + +function base64Write (buf, string, offset, length) { + return blitBuffer(base64ToBytes(string), buf, offset, length) +} + +function ucs2Write (buf, string, offset, length) { + return blitBuffer(utf16leToBytes(string, buf.length - offset), buf, offset, length) +} + +Buffer.prototype.write = function write (string, offset, length, encoding) { + // Buffer#write(string) + if (offset === undefined) { + encoding = 'utf8' + length = this.length + offset = 0 + // Buffer#write(string, encoding) + } else if (length === undefined && typeof offset === 'string') { + encoding = offset + length = this.length + offset = 0 + // Buffer#write(string, offset[, length][, encoding]) + } else if (isFinite(offset)) { + offset = offset | 0 + if (isFinite(length)) { + length = length | 0 + if (encoding === undefined) encoding = 'utf8' + } else { + encoding = length + length = undefined + } + // legacy write(string, encoding, offset, length) - remove in v0.13 + } else { + throw new Error( + 'Buffer.write(string, encoding, offset[, length]) is no longer supported' + ) + } + + var remaining = this.length - offset + if (length === undefined || length > remaining) length = remaining + + if ((string.length > 0 && (length < 0 || offset < 0)) || offset > this.length) { + throw new RangeError('Attempt to write outside buffer bounds') + } + + if (!encoding) encoding = 'utf8' + + var loweredCase = false + for (;;) { + switch (encoding) { + case 'hex': + return hexWrite(this, string, offset, length) + + case 'utf8': + case 'utf-8': + return utf8Write(this, string, offset, length) + + case 'ascii': + return asciiWrite(this, string, offset, length) + + case 'latin1': + case 'binary': + return latin1Write(this, string, offset, length) + + case 'base64': + // Warning: maxLength not taken into account in base64Write + return base64Write(this, string, offset, length) + + case 'ucs2': + case 'ucs-2': + case 'utf16le': + case 'utf-16le': + return ucs2Write(this, string, offset, length) + + default: + if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding) + encoding = ('' + encoding).toLowerCase() + loweredCase = true + } + } +} + +Buffer.prototype.toJSON = function toJSON () { + return { + type: 'Buffer', + data: Array.prototype.slice.call(this._arr || this, 0) + } +} + +function base64Slice (buf, start, end) { + if (start === 0 && end === buf.length) { + return base64.fromByteArray(buf) + } else { + return base64.fromByteArray(buf.slice(start, end)) + } +} + +function utf8Slice (buf, start, end) { + end = Math.min(buf.length, end) + var res = [] + + var i = start + while (i < end) { + var firstByte = buf[i] + var codePoint = null + var bytesPerSequence = (firstByte > 0xEF) ? 4 + : (firstByte > 0xDF) ? 3 + : (firstByte > 0xBF) ? 2 + : 1 + + if (i + bytesPerSequence <= end) { + var secondByte, thirdByte, fourthByte, tempCodePoint + + switch (bytesPerSequence) { + case 1: + if (firstByte < 0x80) { + codePoint = firstByte + } + break + case 2: + secondByte = buf[i + 1] + if ((secondByte & 0xC0) === 0x80) { + tempCodePoint = (firstByte & 0x1F) << 0x6 | (secondByte & 0x3F) + if (tempCodePoint > 0x7F) { + codePoint = tempCodePoint + } + } + break + case 3: + secondByte = buf[i + 1] + thirdByte = buf[i + 2] + if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80) { + tempCodePoint = (firstByte & 0xF) << 0xC | (secondByte & 0x3F) << 0x6 | (thirdByte & 0x3F) + if (tempCodePoint > 0x7FF && (tempCodePoint < 0xD800 || tempCodePoint > 0xDFFF)) { + codePoint = tempCodePoint + } + } + break + case 4: + secondByte = buf[i + 1] + thirdByte = buf[i + 2] + fourthByte = buf[i + 3] + if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80 && (fourthByte & 0xC0) === 0x80) { + tempCodePoint = (firstByte & 0xF) << 0x12 | (secondByte & 0x3F) << 0xC | (thirdByte & 0x3F) << 0x6 | (fourthByte & 0x3F) + if (tempCodePoint > 0xFFFF && tempCodePoint < 0x110000) { + codePoint = tempCodePoint + } + } + } + } + + if (codePoint === null) { + // we did not generate a valid codePoint so insert a + // replacement char (U+FFFD) and advance only 1 byte + codePoint = 0xFFFD + bytesPerSequence = 1 + } else if (codePoint > 0xFFFF) { + // encode to utf16 (surrogate pair dance) + codePoint -= 0x10000 + res.push(codePoint >>> 10 & 0x3FF | 0xD800) + codePoint = 0xDC00 | codePoint & 0x3FF + } + + res.push(codePoint) + i += bytesPerSequence + } + + return decodeCodePointsArray(res) +} + +// Based on http://stackoverflow.com/a/22747272/680742, the browser with +// the lowest limit is Chrome, with 0x10000 args. +// We go 1 magnitude less, for safety +var MAX_ARGUMENTS_LENGTH = 0x1000 + +function decodeCodePointsArray (codePoints) { + var len = codePoints.length + if (len <= MAX_ARGUMENTS_LENGTH) { + return String.fromCharCode.apply(String, codePoints) // avoid extra slice() + } + + // Decode in chunks to avoid "call stack size exceeded". + var res = '' + var i = 0 + while (i < len) { + res += String.fromCharCode.apply( + String, + codePoints.slice(i, i += MAX_ARGUMENTS_LENGTH) + ) + } + return res +} + +function asciiSlice (buf, start, end) { + var ret = '' + end = Math.min(buf.length, end) + + for (var i = start; i < end; ++i) { + ret += String.fromCharCode(buf[i] & 0x7F) + } + return ret +} + +function latin1Slice (buf, start, end) { + var ret = '' + end = Math.min(buf.length, end) + + for (var i = start; i < end; ++i) { + ret += String.fromCharCode(buf[i]) + } + return ret +} + +function hexSlice (buf, start, end) { + var len = buf.length + + if (!start || start < 0) start = 0 + if (!end || end < 0 || end > len) end = len + + var out = '' + for (var i = start; i < end; ++i) { + out += toHex(buf[i]) + } + return out +} + +function utf16leSlice (buf, start, end) { + var bytes = buf.slice(start, end) + var res = '' + for (var i = 0; i < bytes.length; i += 2) { + res += String.fromCharCode(bytes[i] + bytes[i + 1] * 256) + } + return res +} + +Buffer.prototype.slice = function slice (start, end) { + var len = this.length + start = ~~start + end = end === undefined ? len : ~~end + + if (start < 0) { + start += len + if (start < 0) start = 0 + } else if (start > len) { + start = len + } + + if (end < 0) { + end += len + if (end < 0) end = 0 + } else if (end > len) { + end = len + } + + if (end < start) end = start + + var newBuf + if (Buffer.TYPED_ARRAY_SUPPORT) { + newBuf = this.subarray(start, end) + newBuf.__proto__ = Buffer.prototype + } else { + var sliceLen = end - start + newBuf = new Buffer(sliceLen, undefined) + for (var i = 0; i < sliceLen; ++i) { + newBuf[i] = this[i + start] + } + } + + return newBuf +} + +/* + * Need to make sure that buffer isn't trying to write out of bounds. + */ +function checkOffset (offset, ext, length) { + if ((offset % 1) !== 0 || offset < 0) throw new RangeError('offset is not uint') + if (offset + ext > length) throw new RangeError('Trying to access beyond buffer length') +} + +Buffer.prototype.readUIntLE = function readUIntLE (offset, byteLength, noAssert) { + offset = offset | 0 + byteLength = byteLength | 0 + if (!noAssert) checkOffset(offset, byteLength, this.length) + + var val = this[offset] + var mul = 1 + var i = 0 + while (++i < byteLength && (mul *= 0x100)) { + val += this[offset + i] * mul + } + + return val +} + +Buffer.prototype.readUIntBE = function readUIntBE (offset, byteLength, noAssert) { + offset = offset | 0 + byteLength = byteLength | 0 + if (!noAssert) { + checkOffset(offset, byteLength, this.length) + } + + var val = this[offset + --byteLength] + var mul = 1 + while (byteLength > 0 && (mul *= 0x100)) { + val += this[offset + --byteLength] * mul + } + + return val +} + +Buffer.prototype.readUInt8 = function readUInt8 (offset, noAssert) { + if (!noAssert) checkOffset(offset, 1, this.length) + return this[offset] +} + +Buffer.prototype.readUInt16LE = function readUInt16LE (offset, noAssert) { + if (!noAssert) checkOffset(offset, 2, this.length) + return this[offset] | (this[offset + 1] << 8) +} + +Buffer.prototype.readUInt16BE = function readUInt16BE (offset, noAssert) { + if (!noAssert) checkOffset(offset, 2, this.length) + return (this[offset] << 8) | this[offset + 1] +} + +Buffer.prototype.readUInt32LE = function readUInt32LE (offset, noAssert) { + if (!noAssert) checkOffset(offset, 4, this.length) + + return ((this[offset]) | + (this[offset + 1] << 8) | + (this[offset + 2] << 16)) + + (this[offset + 3] * 0x1000000) +} + +Buffer.prototype.readUInt32BE = function readUInt32BE (offset, noAssert) { + if (!noAssert) checkOffset(offset, 4, this.length) + + return (this[offset] * 0x1000000) + + ((this[offset + 1] << 16) | + (this[offset + 2] << 8) | + this[offset + 3]) +} + +Buffer.prototype.readIntLE = function readIntLE (offset, byteLength, noAssert) { + offset = offset | 0 + byteLength = byteLength | 0 + if (!noAssert) checkOffset(offset, byteLength, this.length) + + var val = this[offset] + var mul = 1 + var i = 0 + while (++i < byteLength && (mul *= 0x100)) { + val += this[offset + i] * mul + } + mul *= 0x80 + + if (val >= mul) val -= Math.pow(2, 8 * byteLength) + + return val +} + +Buffer.prototype.readIntBE = function readIntBE (offset, byteLength, noAssert) { + offset = offset | 0 + byteLength = byteLength | 0 + if (!noAssert) checkOffset(offset, byteLength, this.length) + + var i = byteLength + var mul = 1 + var val = this[offset + --i] + while (i > 0 && (mul *= 0x100)) { + val += this[offset + --i] * mul + } + mul *= 0x80 + + if (val >= mul) val -= Math.pow(2, 8 * byteLength) + + return val +} + +Buffer.prototype.readInt8 = function readInt8 (offset, noAssert) { + if (!noAssert) checkOffset(offset, 1, this.length) + if (!(this[offset] & 0x80)) return (this[offset]) + return ((0xff - this[offset] + 1) * -1) +} + +Buffer.prototype.readInt16LE = function readInt16LE (offset, noAssert) { + if (!noAssert) checkOffset(offset, 2, this.length) + var val = this[offset] | (this[offset + 1] << 8) + return (val & 0x8000) ? val | 0xFFFF0000 : val +} + +Buffer.prototype.readInt16BE = function readInt16BE (offset, noAssert) { + if (!noAssert) checkOffset(offset, 2, this.length) + var val = this[offset + 1] | (this[offset] << 8) + return (val & 0x8000) ? val | 0xFFFF0000 : val +} + +Buffer.prototype.readInt32LE = function readInt32LE (offset, noAssert) { + if (!noAssert) checkOffset(offset, 4, this.length) + + return (this[offset]) | + (this[offset + 1] << 8) | + (this[offset + 2] << 16) | + (this[offset + 3] << 24) +} + +Buffer.prototype.readInt32BE = function readInt32BE (offset, noAssert) { + if (!noAssert) checkOffset(offset, 4, this.length) + + return (this[offset] << 24) | + (this[offset + 1] << 16) | + (this[offset + 2] << 8) | + (this[offset + 3]) +} + +Buffer.prototype.readFloatLE = function readFloatLE (offset, noAssert) { + if (!noAssert) checkOffset(offset, 4, this.length) + return ieee754.read(this, offset, true, 23, 4) +} + +Buffer.prototype.readFloatBE = function readFloatBE (offset, noAssert) { + if (!noAssert) checkOffset(offset, 4, this.length) + return ieee754.read(this, offset, false, 23, 4) +} + +Buffer.prototype.readDoubleLE = function readDoubleLE (offset, noAssert) { + if (!noAssert) checkOffset(offset, 8, this.length) + return ieee754.read(this, offset, true, 52, 8) +} + +Buffer.prototype.readDoubleBE = function readDoubleBE (offset, noAssert) { + if (!noAssert) checkOffset(offset, 8, this.length) + return ieee754.read(this, offset, false, 52, 8) +} + +function checkInt (buf, value, offset, ext, max, min) { + if (!Buffer.isBuffer(buf)) throw new TypeError('"buffer" argument must be a Buffer instance') + if (value > max || value < min) throw new RangeError('"value" argument is out of bounds') + if (offset + ext > buf.length) throw new RangeError('Index out of range') +} + +Buffer.prototype.writeUIntLE = function writeUIntLE (value, offset, byteLength, noAssert) { + value = +value + offset = offset | 0 + byteLength = byteLength | 0 + if (!noAssert) { + var maxBytes = Math.pow(2, 8 * byteLength) - 1 + checkInt(this, value, offset, byteLength, maxBytes, 0) + } + + var mul = 1 + var i = 0 + this[offset] = value & 0xFF + while (++i < byteLength && (mul *= 0x100)) { + this[offset + i] = (value / mul) & 0xFF + } + + return offset + byteLength +} + +Buffer.prototype.writeUIntBE = function writeUIntBE (value, offset, byteLength, noAssert) { + value = +value + offset = offset | 0 + byteLength = byteLength | 0 + if (!noAssert) { + var maxBytes = Math.pow(2, 8 * byteLength) - 1 + checkInt(this, value, offset, byteLength, maxBytes, 0) + } + + var i = byteLength - 1 + var mul = 1 + this[offset + i] = value & 0xFF + while (--i >= 0 && (mul *= 0x100)) { + this[offset + i] = (value / mul) & 0xFF + } + + return offset + byteLength +} + +Buffer.prototype.writeUInt8 = function writeUInt8 (value, offset, noAssert) { + value = +value + offset = offset | 0 + if (!noAssert) checkInt(this, value, offset, 1, 0xff, 0) + if (!Buffer.TYPED_ARRAY_SUPPORT) value = Math.floor(value) + this[offset] = (value & 0xff) + return offset + 1 +} + +function objectWriteUInt16 (buf, value, offset, littleEndian) { + if (value < 0) value = 0xffff + value + 1 + for (var i = 0, j = Math.min(buf.length - offset, 2); i < j; ++i) { + buf[offset + i] = (value & (0xff << (8 * (littleEndian ? i : 1 - i)))) >>> + (littleEndian ? i : 1 - i) * 8 + } +} + +Buffer.prototype.writeUInt16LE = function writeUInt16LE (value, offset, noAssert) { + value = +value + offset = offset | 0 + if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0) + if (Buffer.TYPED_ARRAY_SUPPORT) { + this[offset] = (value & 0xff) + this[offset + 1] = (value >>> 8) + } else { + objectWriteUInt16(this, value, offset, true) + } + return offset + 2 +} + +Buffer.prototype.writeUInt16BE = function writeUInt16BE (value, offset, noAssert) { + value = +value + offset = offset | 0 + if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0) + if (Buffer.TYPED_ARRAY_SUPPORT) { + this[offset] = (value >>> 8) + this[offset + 1] = (value & 0xff) + } else { + objectWriteUInt16(this, value, offset, false) + } + return offset + 2 +} + +function objectWriteUInt32 (buf, value, offset, littleEndian) { + if (value < 0) value = 0xffffffff + value + 1 + for (var i = 0, j = Math.min(buf.length - offset, 4); i < j; ++i) { + buf[offset + i] = (value >>> (littleEndian ? i : 3 - i) * 8) & 0xff + } +} + +Buffer.prototype.writeUInt32LE = function writeUInt32LE (value, offset, noAssert) { + value = +value + offset = offset | 0 + if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0) + if (Buffer.TYPED_ARRAY_SUPPORT) { + this[offset + 3] = (value >>> 24) + this[offset + 2] = (value >>> 16) + this[offset + 1] = (value >>> 8) + this[offset] = (value & 0xff) + } else { + objectWriteUInt32(this, value, offset, true) + } + return offset + 4 +} + +Buffer.prototype.writeUInt32BE = function writeUInt32BE (value, offset, noAssert) { + value = +value + offset = offset | 0 + if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0) + if (Buffer.TYPED_ARRAY_SUPPORT) { + this[offset] = (value >>> 24) + this[offset + 1] = (value >>> 16) + this[offset + 2] = (value >>> 8) + this[offset + 3] = (value & 0xff) + } else { + objectWriteUInt32(this, value, offset, false) + } + return offset + 4 +} + +Buffer.prototype.writeIntLE = function writeIntLE (value, offset, byteLength, noAssert) { + value = +value + offset = offset | 0 + if (!noAssert) { + var limit = Math.pow(2, 8 * byteLength - 1) + + checkInt(this, value, offset, byteLength, limit - 1, -limit) + } + + var i = 0 + var mul = 1 + var sub = 0 + this[offset] = value & 0xFF + while (++i < byteLength && (mul *= 0x100)) { + if (value < 0 && sub === 0 && this[offset + i - 1] !== 0) { + sub = 1 + } + this[offset + i] = ((value / mul) >> 0) - sub & 0xFF + } + + return offset + byteLength +} + +Buffer.prototype.writeIntBE = function writeIntBE (value, offset, byteLength, noAssert) { + value = +value + offset = offset | 0 + if (!noAssert) { + var limit = Math.pow(2, 8 * byteLength - 1) + + checkInt(this, value, offset, byteLength, limit - 1, -limit) + } + + var i = byteLength - 1 + var mul = 1 + var sub = 0 + this[offset + i] = value & 0xFF + while (--i >= 0 && (mul *= 0x100)) { + if (value < 0 && sub === 0 && this[offset + i + 1] !== 0) { + sub = 1 + } + this[offset + i] = ((value / mul) >> 0) - sub & 0xFF + } + + return offset + byteLength +} + +Buffer.prototype.writeInt8 = function writeInt8 (value, offset, noAssert) { + value = +value + offset = offset | 0 + if (!noAssert) checkInt(this, value, offset, 1, 0x7f, -0x80) + if (!Buffer.TYPED_ARRAY_SUPPORT) value = Math.floor(value) + if (value < 0) value = 0xff + value + 1 + this[offset] = (value & 0xff) + return offset + 1 +} + +Buffer.prototype.writeInt16LE = function writeInt16LE (value, offset, noAssert) { + value = +value + offset = offset | 0 + if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000) + if (Buffer.TYPED_ARRAY_SUPPORT) { + this[offset] = (value & 0xff) + this[offset + 1] = (value >>> 8) + } else { + objectWriteUInt16(this, value, offset, true) + } + return offset + 2 +} + +Buffer.prototype.writeInt16BE = function writeInt16BE (value, offset, noAssert) { + value = +value + offset = offset | 0 + if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000) + if (Buffer.TYPED_ARRAY_SUPPORT) { + this[offset] = (value >>> 8) + this[offset + 1] = (value & 0xff) + } else { + objectWriteUInt16(this, value, offset, false) + } + return offset + 2 +} + +Buffer.prototype.writeInt32LE = function writeInt32LE (value, offset, noAssert) { + value = +value + offset = offset | 0 + if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000) + if (Buffer.TYPED_ARRAY_SUPPORT) { + this[offset] = (value & 0xff) + this[offset + 1] = (value >>> 8) + this[offset + 2] = (value >>> 16) + this[offset + 3] = (value >>> 24) + } else { + objectWriteUInt32(this, value, offset, true) + } + return offset + 4 +} + +Buffer.prototype.writeInt32BE = function writeInt32BE (value, offset, noAssert) { + value = +value + offset = offset | 0 + if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000) + if (value < 0) value = 0xffffffff + value + 1 + if (Buffer.TYPED_ARRAY_SUPPORT) { + this[offset] = (value >>> 24) + this[offset + 1] = (value >>> 16) + this[offset + 2] = (value >>> 8) + this[offset + 3] = (value & 0xff) + } else { + objectWriteUInt32(this, value, offset, false) + } + return offset + 4 +} + +function checkIEEE754 (buf, value, offset, ext, max, min) { + if (offset + ext > buf.length) throw new RangeError('Index out of range') + if (offset < 0) throw new RangeError('Index out of range') +} + +function writeFloat (buf, value, offset, littleEndian, noAssert) { + if (!noAssert) { + checkIEEE754(buf, value, offset, 4, 3.4028234663852886e+38, -3.4028234663852886e+38) + } + ieee754.write(buf, value, offset, littleEndian, 23, 4) + return offset + 4 +} + +Buffer.prototype.writeFloatLE = function writeFloatLE (value, offset, noAssert) { + return writeFloat(this, value, offset, true, noAssert) +} + +Buffer.prototype.writeFloatBE = function writeFloatBE (value, offset, noAssert) { + return writeFloat(this, value, offset, false, noAssert) +} + +function writeDouble (buf, value, offset, littleEndian, noAssert) { + if (!noAssert) { + checkIEEE754(buf, value, offset, 8, 1.7976931348623157E+308, -1.7976931348623157E+308) + } + ieee754.write(buf, value, offset, littleEndian, 52, 8) + return offset + 8 +} + +Buffer.prototype.writeDoubleLE = function writeDoubleLE (value, offset, noAssert) { + return writeDouble(this, value, offset, true, noAssert) +} + +Buffer.prototype.writeDoubleBE = function writeDoubleBE (value, offset, noAssert) { + return writeDouble(this, value, offset, false, noAssert) +} + +// copy(targetBuffer, targetStart=0, sourceStart=0, sourceEnd=buffer.length) +Buffer.prototype.copy = function copy (target, targetStart, start, end) { + if (!start) start = 0 + if (!end && end !== 0) end = this.length + if (targetStart >= target.length) targetStart = target.length + if (!targetStart) targetStart = 0 + if (end > 0 && end < start) end = start + + // Copy 0 bytes; we're done + if (end === start) return 0 + if (target.length === 0 || this.length === 0) return 0 + + // Fatal error conditions + if (targetStart < 0) { + throw new RangeError('targetStart out of bounds') + } + if (start < 0 || start >= this.length) throw new RangeError('sourceStart out of bounds') + if (end < 0) throw new RangeError('sourceEnd out of bounds') + + // Are we oob? + if (end > this.length) end = this.length + if (target.length - targetStart < end - start) { + end = target.length - targetStart + start + } + + var len = end - start + var i + + if (this === target && start < targetStart && targetStart < end) { + // descending copy from end + for (i = len - 1; i >= 0; --i) { + target[i + targetStart] = this[i + start] + } + } else if (len < 1000 || !Buffer.TYPED_ARRAY_SUPPORT) { + // ascending copy from start + for (i = 0; i < len; ++i) { + target[i + targetStart] = this[i + start] + } + } else { + Uint8Array.prototype.set.call( + target, + this.subarray(start, start + len), + targetStart + ) + } + + return len +} + +// Usage: +// buffer.fill(number[, offset[, end]]) +// buffer.fill(buffer[, offset[, end]]) +// buffer.fill(string[, offset[, end]][, encoding]) +Buffer.prototype.fill = function fill (val, start, end, encoding) { + // Handle string cases: + if (typeof val === 'string') { + if (typeof start === 'string') { + encoding = start + start = 0 + end = this.length + } else if (typeof end === 'string') { + encoding = end + end = this.length + } + if (val.length === 1) { + var code = val.charCodeAt(0) + if (code < 256) { + val = code + } + } + if (encoding !== undefined && typeof encoding !== 'string') { + throw new TypeError('encoding must be a string') + } + if (typeof encoding === 'string' && !Buffer.isEncoding(encoding)) { + throw new TypeError('Unknown encoding: ' + encoding) + } + } else if (typeof val === 'number') { + val = val & 255 + } + + // Invalid ranges are not set to a default, so can range check early. + if (start < 0 || this.length < start || this.length < end) { + throw new RangeError('Out of range index') + } + + if (end <= start) { + return this + } + + start = start >>> 0 + end = end === undefined ? this.length : end >>> 0 + + if (!val) val = 0 + + var i + if (typeof val === 'number') { + for (i = start; i < end; ++i) { + this[i] = val + } + } else { + var bytes = Buffer.isBuffer(val) + ? val + : utf8ToBytes(new Buffer(val, encoding).toString()) + var len = bytes.length + for (i = 0; i < end - start; ++i) { + this[i + start] = bytes[i % len] + } + } + + return this +} + +// HELPER FUNCTIONS +// ================ + +var INVALID_BASE64_RE = /[^+\/0-9A-Za-z-_]/g + +function base64clean (str) { + // Node strips out invalid characters like \n and \t from the string, base64-js does not + str = stringtrim(str).replace(INVALID_BASE64_RE, '') + // Node converts strings with length < 2 to '' + if (str.length < 2) return '' + // Node allows for non-padded base64 strings (missing trailing ===), base64-js does not + while (str.length % 4 !== 0) { + str = str + '=' + } + return str +} + +function stringtrim (str) { + if (str.trim) return str.trim() + return str.replace(/^\s+|\s+$/g, '') +} + +function toHex (n) { + if (n < 16) return '0' + n.toString(16) + return n.toString(16) +} + +function utf8ToBytes (string, units) { + units = units || Infinity + var codePoint + var length = string.length + var leadSurrogate = null + var bytes = [] + + for (var i = 0; i < length; ++i) { + codePoint = string.charCodeAt(i) + + // is surrogate component + if (codePoint > 0xD7FF && codePoint < 0xE000) { + // last char was a lead + if (!leadSurrogate) { + // no lead yet + if (codePoint > 0xDBFF) { + // unexpected trail + if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD) + continue + } else if (i + 1 === length) { + // unpaired lead + if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD) + continue + } + + // valid lead + leadSurrogate = codePoint + + continue + } + + // 2 leads in a row + if (codePoint < 0xDC00) { + if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD) + leadSurrogate = codePoint + continue + } + + // valid surrogate pair + codePoint = (leadSurrogate - 0xD800 << 10 | codePoint - 0xDC00) + 0x10000 + } else if (leadSurrogate) { + // valid bmp char, but last char was a lead + if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD) + } + + leadSurrogate = null + + // encode utf8 + if (codePoint < 0x80) { + if ((units -= 1) < 0) break + bytes.push(codePoint) + } else if (codePoint < 0x800) { + if ((units -= 2) < 0) break + bytes.push( + codePoint >> 0x6 | 0xC0, + codePoint & 0x3F | 0x80 + ) + } else if (codePoint < 0x10000) { + if ((units -= 3) < 0) break + bytes.push( + codePoint >> 0xC | 0xE0, + codePoint >> 0x6 & 0x3F | 0x80, + codePoint & 0x3F | 0x80 + ) + } else if (codePoint < 0x110000) { + if ((units -= 4) < 0) break + bytes.push( + codePoint >> 0x12 | 0xF0, + codePoint >> 0xC & 0x3F | 0x80, + codePoint >> 0x6 & 0x3F | 0x80, + codePoint & 0x3F | 0x80 + ) + } else { + throw new Error('Invalid code point') + } + } + + return bytes +} + +function asciiToBytes (str) { + var byteArray = [] + for (var i = 0; i < str.length; ++i) { + // Node's code seems to be doing this and not & 0x7F.. + byteArray.push(str.charCodeAt(i) & 0xFF) + } + return byteArray +} + +function utf16leToBytes (str, units) { + var c, hi, lo + var byteArray = [] + for (var i = 0; i < str.length; ++i) { + if ((units -= 2) < 0) break + + c = str.charCodeAt(i) + hi = c >> 8 + lo = c % 256 + byteArray.push(lo) + byteArray.push(hi) + } + + return byteArray +} + +function base64ToBytes (str) { + return base64.toByteArray(base64clean(str)) +} + +function blitBuffer (src, dst, offset, length) { + for (var i = 0; i < length; ++i) { + if ((i + offset >= dst.length) || (i >= src.length)) break + dst[i + offset] = src[i] + } + return i +} + +function isnan (val) { + return val !== val // eslint-disable-line no-self-compare +} + +/* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(5))) + +/***/ }), +/* 71 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +exports.byteLength = byteLength +exports.toByteArray = toByteArray +exports.fromByteArray = fromByteArray + +var lookup = [] +var revLookup = [] +var Arr = typeof Uint8Array !== 'undefined' ? Uint8Array : Array + +var code = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/' +for (var i = 0, len = code.length; i < len; ++i) { + lookup[i] = code[i] + revLookup[code.charCodeAt(i)] = i +} + +// Support decoding URL-safe base64 strings, as Node.js does. +// See: https://en.wikipedia.org/wiki/Base64#URL_applications +revLookup['-'.charCodeAt(0)] = 62 +revLookup['_'.charCodeAt(0)] = 63 + +function getLens (b64) { + var len = b64.length + + if (len % 4 > 0) { + throw new Error('Invalid string. Length must be a multiple of 4') + } + + // Trim off extra bytes after placeholder bytes are found + // See: https://github.com/beatgammit/base64-js/issues/42 + var validLen = b64.indexOf('=') + if (validLen === -1) validLen = len + + var placeHoldersLen = validLen === len + ? 0 + : 4 - (validLen % 4) + + return [validLen, placeHoldersLen] +} + +// base64 is 4/3 + up to two characters of the original data +function byteLength (b64) { + var lens = getLens(b64) + var validLen = lens[0] + var placeHoldersLen = lens[1] + return ((validLen + placeHoldersLen) * 3 / 4) - placeHoldersLen +} + +function _byteLength (b64, validLen, placeHoldersLen) { + return ((validLen + placeHoldersLen) * 3 / 4) - placeHoldersLen +} + +function toByteArray (b64) { + var tmp + var lens = getLens(b64) + var validLen = lens[0] + var placeHoldersLen = lens[1] + + var arr = new Arr(_byteLength(b64, validLen, placeHoldersLen)) + + var curByte = 0 + + // if there are placeholders, only get up to the last complete 4 chars + var len = placeHoldersLen > 0 + ? validLen - 4 + : validLen + + var i + for (i = 0; i < len; i += 4) { + tmp = + (revLookup[b64.charCodeAt(i)] << 18) | + (revLookup[b64.charCodeAt(i + 1)] << 12) | + (revLookup[b64.charCodeAt(i + 2)] << 6) | + revLookup[b64.charCodeAt(i + 3)] + arr[curByte++] = (tmp >> 16) & 0xFF + arr[curByte++] = (tmp >> 8) & 0xFF + arr[curByte++] = tmp & 0xFF + } + + if (placeHoldersLen === 2) { + tmp = + (revLookup[b64.charCodeAt(i)] << 2) | + (revLookup[b64.charCodeAt(i + 1)] >> 4) + arr[curByte++] = tmp & 0xFF + } + + if (placeHoldersLen === 1) { + tmp = + (revLookup[b64.charCodeAt(i)] << 10) | + (revLookup[b64.charCodeAt(i + 1)] << 4) | + (revLookup[b64.charCodeAt(i + 2)] >> 2) + arr[curByte++] = (tmp >> 8) & 0xFF + arr[curByte++] = tmp & 0xFF + } + + return arr +} + +function tripletToBase64 (num) { + return lookup[num >> 18 & 0x3F] + + lookup[num >> 12 & 0x3F] + + lookup[num >> 6 & 0x3F] + + lookup[num & 0x3F] +} + +function encodeChunk (uint8, start, end) { + var tmp + var output = [] + for (var i = start; i < end; i += 3) { + tmp = + ((uint8[i] << 16) & 0xFF0000) + + ((uint8[i + 1] << 8) & 0xFF00) + + (uint8[i + 2] & 0xFF) + output.push(tripletToBase64(tmp)) + } + return output.join('') +} + +function fromByteArray (uint8) { + var tmp + var len = uint8.length + var extraBytes = len % 3 // if we have 1 byte left, pad 2 bytes + var parts = [] + var maxChunkLength = 16383 // must be multiple of 3 + + // go through the array every three bytes, we'll deal with trailing stuff later + for (var i = 0, len2 = len - extraBytes; i < len2; i += maxChunkLength) { + parts.push(encodeChunk( + uint8, i, (i + maxChunkLength) > len2 ? len2 : (i + maxChunkLength) + )) + } + + // pad the end with zeros, but make sure to not forget the extra bytes + if (extraBytes === 1) { + tmp = uint8[len - 1] + parts.push( + lookup[tmp >> 2] + + lookup[(tmp << 4) & 0x3F] + + '==' + ) + } else if (extraBytes === 2) { + tmp = (uint8[len - 2] << 8) + uint8[len - 1] + parts.push( + lookup[tmp >> 10] + + lookup[(tmp >> 4) & 0x3F] + + lookup[(tmp << 2) & 0x3F] + + '=' + ) + } + + return parts.join('') +} + + +/***/ }), +/* 72 */ +/***/ (function(module, exports) { + +exports.read = function (buffer, offset, isLE, mLen, nBytes) { + var e, m + var eLen = (nBytes * 8) - mLen - 1 + var eMax = (1 << eLen) - 1 + var eBias = eMax >> 1 + var nBits = -7 + var i = isLE ? (nBytes - 1) : 0 + var d = isLE ? -1 : 1 + var s = buffer[offset + i] + + i += d + + e = s & ((1 << (-nBits)) - 1) + s >>= (-nBits) + nBits += eLen + for (; nBits > 0; e = (e * 256) + buffer[offset + i], i += d, nBits -= 8) {} + + m = e & ((1 << (-nBits)) - 1) + e >>= (-nBits) + nBits += mLen + for (; nBits > 0; m = (m * 256) + buffer[offset + i], i += d, nBits -= 8) {} + + if (e === 0) { + e = 1 - eBias + } else if (e === eMax) { + return m ? NaN : ((s ? -1 : 1) * Infinity) + } else { + m = m + Math.pow(2, mLen) + e = e - eBias + } + return (s ? -1 : 1) * m * Math.pow(2, e - mLen) +} + +exports.write = function (buffer, value, offset, isLE, mLen, nBytes) { + var e, m, c + var eLen = (nBytes * 8) - mLen - 1 + var eMax = (1 << eLen) - 1 + var eBias = eMax >> 1 + var rt = (mLen === 23 ? Math.pow(2, -24) - Math.pow(2, -77) : 0) + var i = isLE ? 0 : (nBytes - 1) + var d = isLE ? 1 : -1 + var s = value < 0 || (value === 0 && 1 / value < 0) ? 1 : 0 + + value = Math.abs(value) + + if (isNaN(value) || value === Infinity) { + m = isNaN(value) ? 1 : 0 + e = eMax + } else { + e = Math.floor(Math.log(value) / Math.LN2) + if (value * (c = Math.pow(2, -e)) < 1) { + e-- + c *= 2 + } + if (e + eBias >= 1) { + value += rt / c + } else { + value += rt * Math.pow(2, 1 - eBias) + } + if (value * c >= 2) { + e++ + c /= 2 + } + + if (e + eBias >= eMax) { + m = 0 + e = eMax + } else if (e + eBias >= 1) { + m = ((value * c) - 1) * Math.pow(2, mLen) + e = e + eBias + } else { + m = value * Math.pow(2, eBias - 1) * Math.pow(2, mLen) + e = 0 + } + } + + for (; mLen >= 8; buffer[offset + i] = m & 0xff, i += d, m /= 256, mLen -= 8) {} + + e = (e << mLen) | m + eLen += mLen + for (; eLen > 0; buffer[offset + i] = e & 0xff, i += d, e /= 256, eLen -= 8) {} + + buffer[offset + i - d] |= s * 128 +} + + +/***/ }), +/* 73 */ +/***/ (function(module, exports) { + +var toString = {}.toString; + +module.exports = Array.isArray || function (arr) { + return toString.call(arr) == '[object Array]'; +}; + + +/***/ }), +/* 74 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +var keysShim; +if (!Object.keys) { + // modified from https://github.com/es-shims/es5-shim + var has = Object.prototype.hasOwnProperty; + var toStr = Object.prototype.toString; + var isArgs = __webpack_require__(15); // eslint-disable-line global-require + var isEnumerable = Object.prototype.propertyIsEnumerable; + var hasDontEnumBug = !isEnumerable.call({ toString: null }, 'toString'); + var hasProtoEnumBug = isEnumerable.call(function () {}, 'prototype'); + var dontEnums = [ + 'toString', + 'toLocaleString', + 'valueOf', + 'hasOwnProperty', + 'isPrototypeOf', + 'propertyIsEnumerable', + 'constructor' + ]; + var equalsConstructorPrototype = function (o) { + var ctor = o.constructor; + return ctor && ctor.prototype === o; + }; + var excludedKeys = { + $applicationCache: true, + $console: true, + $external: true, + $frame: true, + $frameElement: true, + $frames: true, + $innerHeight: true, + $innerWidth: true, + $onmozfullscreenchange: true, + $onmozfullscreenerror: true, + $outerHeight: true, + $outerWidth: true, + $pageXOffset: true, + $pageYOffset: true, + $parent: true, + $scrollLeft: true, + $scrollTop: true, + $scrollX: true, + $scrollY: true, + $self: true, + $webkitIndexedDB: true, + $webkitStorageInfo: true, + $window: true + }; + var hasAutomationEqualityBug = (function () { + /* global window */ + if (typeof window === 'undefined') { return false; } + for (var k in window) { + try { + if (!excludedKeys['$' + k] && has.call(window, k) && window[k] !== null && typeof window[k] === 'object') { + try { + equalsConstructorPrototype(window[k]); + } catch (e) { + return true; + } + } + } catch (e) { + return true; + } + } + return false; + }()); + var equalsConstructorPrototypeIfNotBuggy = function (o) { + /* global window */ + if (typeof window === 'undefined' || !hasAutomationEqualityBug) { + return equalsConstructorPrototype(o); + } + try { + return equalsConstructorPrototype(o); + } catch (e) { + return false; + } + }; + + keysShim = function keys(object) { + var isObject = object !== null && typeof object === 'object'; + var isFunction = toStr.call(object) === '[object Function]'; + var isArguments = isArgs(object); + var isString = isObject && toStr.call(object) === '[object String]'; + var theKeys = []; + + if (!isObject && !isFunction && !isArguments) { + throw new TypeError('Object.keys called on a non-object'); + } + + var skipProto = hasProtoEnumBug && isFunction; + if (isString && object.length > 0 && !has.call(object, 0)) { + for (var i = 0; i < object.length; ++i) { + theKeys.push(String(i)); + } + } + + if (isArguments && object.length > 0) { + for (var j = 0; j < object.length; ++j) { + theKeys.push(String(j)); + } + } else { + for (var name in object) { + if (!(skipProto && name === 'prototype') && has.call(object, name)) { + theKeys.push(String(name)); + } + } + } + + if (hasDontEnumBug) { + var skipConstructor = equalsConstructorPrototypeIfNotBuggy(object); + + for (var k = 0; k < dontEnums.length; ++k) { + if (!(skipConstructor && dontEnums[k] === 'constructor') && has.call(object, dontEnums[k])) { + theKeys.push(dontEnums[k]); + } + } + } + return theKeys; + }; +} +module.exports = keysShim; + + +/***/ }), +/* 75 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +var define = __webpack_require__(2); +var callBind = __webpack_require__(10); + +var implementation = __webpack_require__(17); +var getPolyfill = __webpack_require__(18); +var shim = __webpack_require__(77); + +var polyfill = callBind(getPolyfill(), Object); + +define(polyfill, { + getPolyfill: getPolyfill, + implementation: implementation, + shim: shim +}); + +module.exports = polyfill; + + +/***/ }), +/* 76 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +/* eslint no-invalid-this: 1 */ + +var ERROR_MESSAGE = 'Function.prototype.bind called on incompatible '; +var slice = Array.prototype.slice; +var toStr = Object.prototype.toString; +var funcType = '[object Function]'; + +module.exports = function bind(that) { + var target = this; + if (typeof target !== 'function' || toStr.call(target) !== funcType) { + throw new TypeError(ERROR_MESSAGE + target); + } + var args = slice.call(arguments, 1); + + var bound; + var binder = function () { + if (this instanceof bound) { + var result = target.apply( + this, + args.concat(slice.call(arguments)) + ); + if (Object(result) === result) { + return result; + } + return this; + } else { + return target.apply( + that, + args.concat(slice.call(arguments)) + ); + } + }; + + var boundLength = Math.max(0, target.length - args.length); + var boundArgs = []; + for (var i = 0; i < boundLength; i++) { + boundArgs.push('$' + i); + } + + bound = Function('binder', 'return function (' + boundArgs.join(',') + '){ return binder.apply(this,arguments); }')(binder); + + if (target.prototype) { + var Empty = function Empty() {}; + Empty.prototype = target.prototype; + bound.prototype = new Empty(); + Empty.prototype = null; + } + + return bound; +}; + + +/***/ }), +/* 77 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +var getPolyfill = __webpack_require__(18); +var define = __webpack_require__(2); + +module.exports = function shimObjectIs() { + var polyfill = getPolyfill(); + define(Object, { is: polyfill }, { + is: function testObjectIs() { + return Object.is !== polyfill; + } + }); + return polyfill; +}; + + +/***/ }), +/* 78 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +var has = __webpack_require__(79); +var regexExec = RegExp.prototype.exec; +var gOPD = Object.getOwnPropertyDescriptor; + +var tryRegexExecCall = function tryRegexExec(value) { + try { + var lastIndex = value.lastIndex; + value.lastIndex = 0; // eslint-disable-line no-param-reassign + + regexExec.call(value); + return true; + } catch (e) { + return false; + } finally { + value.lastIndex = lastIndex; // eslint-disable-line no-param-reassign + } +}; +var toStr = Object.prototype.toString; +var regexClass = '[object RegExp]'; +var hasToStringTag = typeof Symbol === 'function' && typeof Symbol.toStringTag === 'symbol'; + +module.exports = function isRegex(value) { + if (!value || typeof value !== 'object') { + return false; + } + if (!hasToStringTag) { + return toStr.call(value) === regexClass; + } + + var descriptor = gOPD(value, 'lastIndex'); + var hasLastIndexDataProperty = descriptor && has(descriptor, 'value'); + if (!hasLastIndexDataProperty) { + return false; + } + + return tryRegexExecCall(value); +}; + + +/***/ }), +/* 79 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +var bind = __webpack_require__(8); + +module.exports = bind.call(Function.call, Object.prototype.hasOwnProperty); + + +/***/ }), +/* 80 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +var define = __webpack_require__(2); +var callBind = __webpack_require__(10); + +var implementation = __webpack_require__(19); +var getPolyfill = __webpack_require__(20); +var shim = __webpack_require__(81); + +var flagsBound = callBind(implementation); + +define(flagsBound, { + getPolyfill: getPolyfill, + implementation: implementation, + shim: shim +}); + +module.exports = flagsBound; + + +/***/ }), +/* 81 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +var supportsDescriptors = __webpack_require__(2).supportsDescriptors; +var getPolyfill = __webpack_require__(20); +var gOPD = Object.getOwnPropertyDescriptor; +var defineProperty = Object.defineProperty; +var TypeErr = TypeError; +var getProto = Object.getPrototypeOf; +var regex = /a/; + +module.exports = function shimFlags() { + if (!supportsDescriptors || !getProto) { + throw new TypeErr('RegExp.prototype.flags requires a true ES5 environment that supports property descriptors'); + } + var polyfill = getPolyfill(); + var proto = getProto(regex); + var descriptor = gOPD(proto, 'flags'); + if (!descriptor || descriptor.get !== polyfill) { + defineProperty(proto, 'flags', { + configurable: true, + enumerable: false, + get: polyfill + }); + } + return polyfill; +}; - if (isDown) { - return Math.abs(rowRect.y - compareRect.y - compareRect.height) < ERROR_LIMIT; - } else { - return Math.abs(rowRect.y - compareRect.y) < ERROR_LIMIT; - } - }); - body.insertBefore(newRow, refRow); // reordering affectedCells - affectedCells.sort(sortFunc); - return affectedCells; - } +/***/ }), +/* 82 */ +/***/ (function(module, exports) { - mergeCells(compareRect, mergingCells, rowspan, colspan, editorWrapper) { - const mergedCell = mergingCells.reduce((result, tableCell, index) => { - if (index !== 0) { - result && tableCell.moveChildren(result); - tableCell.remove(); - } else { - tableCell.format('colspan', colspan); - tableCell.format('rowspan', rowspan); - result = tableCell; - } +var toString = {}.toString; - return result; - }, null); - let rowId = mergedCell.domNode.getAttribute('data-row'); - let cellId = mergedCell.children.head.domNode.getAttribute('data-cell'); - mergedCell.children.forEach(cellLine => { - cellLine.format('cell', cellId); - cellLine.format('row', rowId); - cellLine.format('colspan', colspan); - cellLine.format('rowspan', rowspan); - }); - return mergedCell; - } +module.exports = Array.isArray || function (arr) { + return toString.call(arr) == '[object Array]'; +}; - unmergeCells(unmergingCells, editorWrapper) { - let cellFormats = {}; - let cellRowspan = 1; - let cellColspan = 1; - unmergingCells.forEach(tableCell => { - cellFormats = tableCell.formats(); - cellRowspan = cellFormats.rowspan; - cellColspan = cellFormats.colspan; - if (cellColspan > 1) { - let ref = tableCell.next; - let row = tableCell.row(); - tableCell.format('colspan', 1); +/***/ }), +/* 83 */ +/***/ (function(module, exports, __webpack_require__) { - for (let i = cellColspan; i > 1; i--) { - this.insertCell(row, ref); - } - } +"use strict"; - if (cellRowspan > 1) { - let i = cellRowspan; - let nextRow = tableCell.row().next; - while (i > 1) { - let refInNextRow = nextRow.children.reduce((result, cell) => { - let compareRect = getRelativeRect(tableCell.domNode.getBoundingClientRect(), editorWrapper); - let cellRect = getRelativeRect(cell.domNode.getBoundingClientRect(), editorWrapper); +var getDay = Date.prototype.getDay; +var tryDateObject = function tryDateGetDayCall(value) { + try { + getDay.call(value); + return true; + } catch (e) { + return false; + } +}; - if (Math.abs(compareRect.x1 - cellRect.x) < ERROR_LIMIT) { - result = cell; - } +var toStr = Object.prototype.toString; +var dateClass = '[object Date]'; +var hasToStringTag = typeof Symbol === 'function' && typeof Symbol.toStringTag === 'symbol'; - return result; - }, null); +module.exports = function isDateObject(value) { + if (typeof value !== 'object' || value === null) { + return false; + } + return hasToStringTag ? tryDateObject(value) : toStr.call(value) === dateClass; +}; - for (let i = cellColspan; i > 0; i--) { - this.insertCell(nextRow, refInNextRow); - } - i -= 1; - nextRow = nextRow.next; - } +/***/ }), +/* 84 */ +/***/ (function(module, exports, __webpack_require__) { - tableCell.format('rowspan', 1); - } - }); - } +"use strict"; - rows() { - const body = this.children.tail; - if (body == null) return []; - return body.children.map(row => row); - } -} +var isString = __webpack_require__(21); +var isNumber = __webpack_require__(85); +var isBoolean = __webpack_require__(86); +var isSymbol = __webpack_require__(87); +var isBigInt = __webpack_require__(88); + +// eslint-disable-next-line consistent-return +module.exports = function whichBoxedPrimitive(value) { + // eslint-disable-next-line eqeqeq + if (value == null || (typeof value !== 'object' && typeof value !== 'function')) { + return null; + } + if (isString(value)) { + return 'String'; + } + if (isNumber(value)) { + return 'Number'; + } + if (isBoolean(value)) { + return 'Boolean'; + } + if (isSymbol(value)) { + return 'Symbol'; + } + if (isBigInt(value)) { + return 'BigInt'; + } +}; -table_TableContainer.blotName = "table-container"; -table_TableContainer.className = "quill-better-table"; -table_TableContainer.tagName = "TABLE"; -class table_TableViewWrapper extends Container { - constructor(scroll, domNode) { - super(scroll, domNode); - const quill = external_commonjs_quill_commonjs2_quill_amd_quill_root_Quill_default.a.find(scroll.domNode.parentNode); - domNode.addEventListener('scroll', e => { - const tableModule = quill.getModule('better-table'); +/***/ }), +/* 85 */ +/***/ (function(module, exports, __webpack_require__) { - if (tableModule.columnTool) { - tableModule.columnTool.domNode.scrollLeft = e.target.scrollLeft; - } +"use strict"; - if (tableModule.tableSelection && tableModule.tableSelection.selectedTds.length > 0) { - tableModule.tableSelection.repositionHelpLines(); - } - }, false); - } - table() { - return this.children.head; - } +var numToStr = Number.prototype.toString; +var tryNumberObject = function tryNumberObject(value) { + try { + numToStr.call(value); + return true; + } catch (e) { + return false; + } +}; +var toStr = Object.prototype.toString; +var numClass = '[object Number]'; +var hasToStringTag = typeof Symbol === 'function' && typeof Symbol.toStringTag === 'symbol'; + +module.exports = function isNumberObject(value) { + if (typeof value === 'number') { + return true; + } + if (typeof value !== 'object') { + return false; + } + return hasToStringTag ? tryNumberObject(value) : toStr.call(value) === numClass; +}; -} -table_TableViewWrapper.blotName = "table-view"; -table_TableViewWrapper.className = "quill-better-table-wrapper"; -table_TableViewWrapper.tagName = "DIV"; -table_TableViewWrapper.allowedChildren = [table_TableContainer]; -table_TableContainer.requiredContainer = table_TableViewWrapper; -table_TableContainer.allowedChildren = [TableBody, TableColGroup]; -TableBody.requiredContainer = table_TableContainer; -TableBody.allowedChildren = [TableRow]; -TableRow.requiredContainer = TableBody; -TableRow.allowedChildren = [TableCell]; -TableCell.requiredContainer = TableRow; -TableCell.allowedChildren = [TableCellLine, header]; -TableCellLine.requiredContainer = TableCell; -TableColGroup.allowedChildren = [TableCol]; -TableColGroup.requiredContainer = table_TableContainer; -TableCol.requiredContainer = TableColGroup; +/***/ }), +/* 86 */ +/***/ (function(module, exports, __webpack_require__) { -function table_rowId() { - const id = Math.random().toString(36).slice(2, 6); - return "row-".concat(id); -} +"use strict"; -function table_cellId() { - const id = Math.random().toString(36).slice(2, 6); - return "cell-".concat(id); + +var boolToStr = Boolean.prototype.toString; + +var tryBooleanObject = function booleanBrandCheck(value) { + try { + boolToStr.call(value); + return true; + } catch (e) { + return false; + } +}; +var toStr = Object.prototype.toString; +var boolClass = '[object Boolean]'; +var hasToStringTag = typeof Symbol === 'function' && typeof Symbol.toStringTag === 'symbol'; + +module.exports = function isBoolean(value) { + if (typeof value === 'boolean') { + return true; + } + if (value === null || typeof value !== 'object') { + return false; + } + return hasToStringTag && Symbol.toStringTag in value ? tryBooleanObject(value) : toStr.call(value) === boolClass; +}; + + +/***/ }), +/* 87 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +var toStr = Object.prototype.toString; +var hasSymbols = __webpack_require__(6)(); + +if (hasSymbols) { + var symToStr = Symbol.prototype.toString; + var symStringRegex = /^Symbol\(.*\)$/; + var isSymbolObject = function isRealSymbolObject(value) { + if (typeof value.valueOf() !== 'symbol') { + return false; + } + return symStringRegex.test(symToStr.call(value)); + }; + + module.exports = function isSymbol(value) { + if (typeof value === 'symbol') { + return true; + } + if (toStr.call(value) !== '[object Symbol]') { + return false; + } + try { + return isSymbolObject(value); + } catch (e) { + return false; + } + }; +} else { + + module.exports = function isSymbol(value) { + // this environment does not support Symbols. + return false && false; + }; } -// CONCATENATED MODULE: ./src/modules/table-selection.js +/***/ }), +/* 88 */ +/***/ (function(module, exports, __webpack_require__) { +"use strict"; -const table_selection_PRIMARY_COLOR = '#0589f3'; -const LINE_POSITIONS = ['left', 'right', 'top', 'bottom']; -const table_selection_ERROR_LIMIT = 2; -class table_selection_TableSelection { - constructor(table, quill, options) { - if (!table) return null; - this.table = table; - this.quill = quill; - this.options = options; - this.boundary = {}; // params for selected square +if (typeof BigInt === 'function') { + var bigIntValueOf = BigInt.prototype.valueOf; + var tryBigInt = function tryBigIntObject(value) { + try { + bigIntValueOf.call(value); + return true; + } catch (e) { + } + return false; + }; + + module.exports = function isBigInt(value) { + if ( + value === null + || typeof value === 'undefined' + || typeof value === 'boolean' + || typeof value === 'string' + || typeof value === 'number' + || typeof value === 'symbol' + || typeof value === 'function' + ) { + return false; + } + if (typeof value === 'bigint') { // eslint-disable-line valid-typeof + return true; + } + + return tryBigInt(value); + }; +} else { + module.exports = function isBigInt(value) { + return false && false; + }; +} - this.selectedTds = []; // array for selected table-cells - this.dragging = false; - this.selectingHandler = this.mouseDownHandler.bind(this); - this.clearSelectionHandler = this.clearSelection.bind(this); - this.helpLinesInitial(); - this.quill.root.addEventListener('mousedown', this.selectingHandler, false); - this.quill.on('text-change', this.clearSelectionHandler ); - } +/***/ }), +/* 89 */ +/***/ (function(module, exports, __webpack_require__) { - helpLinesInitial() { - let parent = this.quill.root.parentNode; - LINE_POSITIONS.forEach(direction => { - this[direction] = document.createElement('div'); - this[direction].classList.add('qlbt-selection-line'); - this[direction].classList.add('qlbt-selection-line-' + direction); - css(this[direction], { - position: 'absolute', - display: 'none', - 'background-color': table_selection_PRIMARY_COLOR - }); - parent.appendChild(this[direction]); - }); - } +"use strict"; - mouseDownHandler(e) { - if (e.button !== 0 || !e.target.closest(".quill-better-table")) return; - this.quill.root.addEventListener('mousemove', mouseMoveHandler, false); - this.quill.root.addEventListener('mouseup', mouseUpHandler, false); - const self = this; - const startTd = e.target.closest('td[data-row]'); - const startTdRect = getRelativeRect(startTd.getBoundingClientRect(), this.quill.root.parentNode); - this.dragging = true; - this.boundary = computeBoundaryFromRects(startTdRect, startTdRect); - this.correctBoundary(); - this.selectedTds = this.computeSelectedTds(); - this.repositionHelpLines(); - function mouseMoveHandler(e) { - if (e.button !== 0 || !e.target.closest(".quill-better-table")) return; - const endTd = e.target.closest('td[data-row]'); - const endTdRect = getRelativeRect(endTd.getBoundingClientRect(), self.quill.root.parentNode); - self.boundary = computeBoundaryFromRects(startTdRect, endTdRect); - self.correctBoundary(); - self.selectedTds = self.computeSelectedTds(); - self.repositionHelpLines(); // avoid select text in multiple table-cell +var isMap = __webpack_require__(22); +var isSet = __webpack_require__(23); +var isWeakMap = __webpack_require__(90); +var isWeakSet = __webpack_require__(91); + +module.exports = function whichCollection(value) { + if (value && typeof value === 'object') { + if (isMap(value)) { + return 'Map'; + } + if (isSet(value)) { + return 'Set'; + } + if (isWeakMap(value)) { + return 'WeakMap'; + } + if (isWeakSet(value)) { + return 'WeakSet'; + } + } + return false; +}; - if (startTd !== endTd) { - self.quill.blur(); - } - } - function mouseUpHandler(e) { - self.quill.root.removeEventListener('mousemove', mouseMoveHandler, false); - self.quill.root.removeEventListener('mouseup', mouseUpHandler, false); - self.dragging = false; - } - } +/***/ }), +/* 90 */ +/***/ (function(module, exports, __webpack_require__) { - correctBoundary() { - const tableContainer = external_commonjs_quill_commonjs2_quill_amd_quill_root_Quill_default.a.find(this.table); - const tableCells = tableContainer.descendants(TableCell); - tableCells.forEach(tableCell => { - let { - x, - y, - width, - height - } = getRelativeRect(tableCell.domNode.getBoundingClientRect(), this.quill.root.parentNode); - let isCellIntersected = (x + table_selection_ERROR_LIMIT >= this.boundary.x && x + table_selection_ERROR_LIMIT <= this.boundary.x1 || x - table_selection_ERROR_LIMIT + width >= this.boundary.x && x - table_selection_ERROR_LIMIT + width <= this.boundary.x1) && (y + table_selection_ERROR_LIMIT >= this.boundary.y && y + table_selection_ERROR_LIMIT <= this.boundary.y1 || y - table_selection_ERROR_LIMIT + height >= this.boundary.y && y - table_selection_ERROR_LIMIT + height <= this.boundary.y1); +"use strict"; - if (isCellIntersected) { - this.boundary = computeBoundaryFromRects(this.boundary, { - x, - y, - width, - height - }); - } - }); - } - computeSelectedTds() { - const tableContainer = external_commonjs_quill_commonjs2_quill_amd_quill_root_Quill_default.a.find(this.table); - const tableCells = tableContainer.descendants(TableCell); - return tableCells.reduce((selectedCells, tableCell) => { - let { - x, - y, - width, - height - } = getRelativeRect(tableCell.domNode.getBoundingClientRect(), this.quill.root.parentNode); - let isCellIncluded = x + table_selection_ERROR_LIMIT >= this.boundary.x && x - table_selection_ERROR_LIMIT + width <= this.boundary.x1 && y + table_selection_ERROR_LIMIT >= this.boundary.y && y - table_selection_ERROR_LIMIT + height <= this.boundary.y1; +var $WeakMap = typeof WeakMap === 'function' && WeakMap.prototype ? WeakMap : null; +var $WeakSet = typeof WeakSet === 'function' && WeakSet.prototype ? WeakSet : null; - if (isCellIncluded) { - selectedCells.push(tableCell); - } +var exported; - return selectedCells; - }, []); - } +if (!$WeakMap) { + // eslint-disable-next-line no-unused-vars + exported = function isWeakMap(x) { + // `WeakMap` is not present in this environment. + return false; + }; +} - repositionHelpLines() { - const tableViewScrollLeft = this.table.parentNode.scrollLeft; - css(this.left, { - display: 'block', - left: "".concat(this.boundary.x - tableViewScrollLeft - 1, "px"), - top: "".concat(this.boundary.y, "px"), - height: "".concat(this.boundary.height + 1, "px"), - width: '1px' - }); - css(this.right, { - display: 'block', - left: "".concat(this.boundary.x1 - tableViewScrollLeft, "px"), - top: "".concat(this.boundary.y, "px"), - height: "".concat(this.boundary.height + 1, "px"), - width: '1px' - }); - css(this.top, { - display: 'block', - left: "".concat(this.boundary.x - 1 - tableViewScrollLeft, "px"), - top: "".concat(this.boundary.y, "px"), - width: "".concat(this.boundary.width + 1, "px"), - height: '1px' - }); - css(this.bottom, { - display: 'block', - left: "".concat(this.boundary.x - 1 - tableViewScrollLeft, "px"), - top: "".concat(this.boundary.y1 + 1, "px"), - width: "".concat(this.boundary.width + 1, "px"), - height: '1px' - }); - } // based on selectedTds compute positions of help lines - // It is useful when selectedTds are not changed +var $mapHas = $WeakMap ? $WeakMap.prototype.has : null; +var $setHas = $WeakSet ? $WeakSet.prototype.has : null; +if (!exported && !$mapHas) { + // eslint-disable-next-line no-unused-vars + exported = function isWeakMap(x) { + // `WeakMap` does not have a `has` method + return false; + }; +} +module.exports = exported || function isWeakMap(x) { + if (!x || typeof x !== 'object') { + return false; + } + try { + $mapHas.call(x, $mapHas); + if ($setHas) { + try { + $setHas.call(x, $setHas); + } catch (e) { + return true; + } + } + return x instanceof $WeakMap; // core-js workaround, pre-v3 + } catch (e) {} + return false; +}; - refreshHelpLinesPosition() { - const startRect = getRelativeRect(this.selectedTds[0].domNode.getBoundingClientRect(), this.quill.root.parentNode); - const endRect = getRelativeRect(this.selectedTds[this.selectedTds.length - 1].domNode.getBoundingClientRect(), this.quill.root.parentNode); - this.boundary = computeBoundaryFromRects(startRect, endRect); - this.repositionHelpLines(); - } - destroy() { - LINE_POSITIONS.forEach(direction => { - this[direction].remove(); - this[direction] = null; - }); - this.quill.root.removeEventListener('mousedown', this.selectingHandler, false); - this.quill.off('text-change', this.clearSelectionHandler ); - return null; - } +/***/ }), +/* 91 */ +/***/ (function(module, exports, __webpack_require__) { - setSelection(startRect, endRect) { - this.boundary = computeBoundaryFromRects(getRelativeRect(startRect, this.quill.root.parentNode), getRelativeRect(endRect, this.quill.root.parentNode)); - this.correctBoundary(); - this.selectedTds = this.computeSelectedTds(); - this.repositionHelpLines(); - } +"use strict"; - clearSelection() { - this.boundary = {}; - this.selectedTds = []; - LINE_POSITIONS.forEach(direction => { - this[direction] && css(this[direction], { - display: 'none' - }); - }); - } +var $WeakMap = typeof WeakMap === 'function' && WeakMap.prototype ? WeakMap : null; +var $WeakSet = typeof WeakSet === 'function' && WeakSet.prototype ? WeakSet : null; + +var exported; + +if (!$WeakMap) { + // eslint-disable-next-line no-unused-vars + exported = function isWeakSet(x) { + // `WeakSet` is not present in this environment. + return false; + }; } -function computeBoundaryFromRects(startRect, endRect) { - let x = Math.min(startRect.x, endRect.x, startRect.x + startRect.width - 1, endRect.x + endRect.width - 1); - let x1 = Math.max(startRect.x, endRect.x, startRect.x + startRect.width - 1, endRect.x + endRect.width - 1); - let y = Math.min(startRect.y, endRect.y, startRect.y + startRect.height - 1, endRect.y + endRect.height - 1); - let y1 = Math.max(startRect.y, endRect.y, startRect.y + startRect.height - 1, endRect.y + endRect.height - 1); - let width = x1 - x; - let height = y1 - y; - return { - x, - x1, - y, - y1, - width, - height - }; +var $mapHas = $WeakMap ? $WeakMap.prototype.has : null; +var $setHas = $WeakSet ? $WeakSet.prototype.has : null; +if (!exported && !$setHas) { + // eslint-disable-next-line no-unused-vars + module.exports = function isWeakSet(x) { + // `WeakSet` does not have a `has` method + return false; + }; } -// EXTERNAL MODULE: ./src/assets/icons/icon_operation_1.svg -var icon_operation_1 = __webpack_require__(1); -var icon_operation_1_default = /*#__PURE__*/__webpack_require__.n(icon_operation_1); -// EXTERNAL MODULE: ./src/assets/icons/icon_operation_2.svg -var icon_operation_2 = __webpack_require__(2); -var icon_operation_2_default = /*#__PURE__*/__webpack_require__.n(icon_operation_2); +module.exports = exported || function isWeakSet(x) { + if (!x || typeof x !== 'object') { + return false; + } + try { + $setHas.call(x, $setHas); + if ($mapHas) { + try { + $mapHas.call(x, $mapHas); + } catch (e) { + return true; + } + } + return x instanceof $WeakSet; // core-js workaround, pre-v3 + } catch (e) {} + return false; +}; -// EXTERNAL MODULE: ./src/assets/icons/icon_operation_3.svg -var icon_operation_3 = __webpack_require__(3); -var icon_operation_3_default = /*#__PURE__*/__webpack_require__.n(icon_operation_3); -// EXTERNAL MODULE: ./src/assets/icons/icon_operation_4.svg -var icon_operation_4 = __webpack_require__(4); -var icon_operation_4_default = /*#__PURE__*/__webpack_require__.n(icon_operation_4); +/***/ }), +/* 92 */ +/***/ (function(module, exports, __webpack_require__) { -// EXTERNAL MODULE: ./src/assets/icons/icon_operation_5.svg -var icon_operation_5 = __webpack_require__(5); -var icon_operation_5_default = /*#__PURE__*/__webpack_require__.n(icon_operation_5); +"use strict"; +/* WEBPACK VAR INJECTION */(function(process) { + +/* eslint global-require: 0 */ +// the code is structured this way so that bundlers can +// alias out `has-symbols` to `() => true` or `() => false` if your target +// environments' Symbol capabilities are known, and then use +// dead code elimination on the rest of this module. +// +// Similarly, `isarray` can be aliased to `Array.isArray` if +// available in all target environments. + +var isArguments = __webpack_require__(16); + +if (__webpack_require__(6)() || __webpack_require__(11)()) { + var $iterator = Symbol.iterator; + // Symbol is available natively or shammed + // natively: + // - Chrome >= 38 + // - Edge 12-14?, Edge >= 15 for sure + // - FF >= 36 + // - Safari >= 9 + // - node >= 0.12 + module.exports = function getIterator(iterable) { + // alternatively, `iterable[$iterator]?.()` + if (iterable != null && typeof iterable[$iterator] !== 'undefined') { + return iterable[$iterator](); + } + if (isArguments(iterable)) { + // arguments objects lack Symbol.iterator + // - node 0.12 + return Array.prototype[$iterator].call(iterable); + } + }; +} else { + // Symbol is not available, native or shammed + var isArray = __webpack_require__(94); + var isString = __webpack_require__(21); + var GetIntrinsic = __webpack_require__(4); + var $Map = GetIntrinsic('%Map%', true); + var $Set = GetIntrinsic('%Set%', true); + var callBound = __webpack_require__(7); + var $arrayPush = callBound('Array.prototype.push'); + var $charCodeAt = callBound('String.prototype.charCodeAt'); + var $stringSlice = callBound('String.prototype.slice'); + + var advanceStringIndex = function advanceStringIndex(S, index) { + var length = S.length; + if ((index + 1) >= length) { + return index + 1; + } + + var first = $charCodeAt(S, index); + if (first < 0xD800 || first > 0xDBFF) { + return index + 1; + } + + var second = $charCodeAt(S, index + 1); + if (second < 0xDC00 || second > 0xDFFF) { + return index + 1; + } + + return index + 2; + }; + + var getArrayIterator = function getArrayIterator(arraylike) { + var i = 0; + return { + next: function next() { + var done = i >= arraylike.length; + var value; + if (!done) { + value = arraylike[i]; + i += 1; + } + return { + done: done, + value: value + }; + } + }; + }; + + var getNonCollectionIterator = function getNonCollectionIterator(iterable) { + if (isArray(iterable) || isArguments(iterable)) { + return getArrayIterator(iterable); + } + if (isString(iterable)) { + var i = 0; + return { + next: function next() { + var nextIndex = advanceStringIndex(iterable, i); + var value = $stringSlice(iterable, i, nextIndex); + i = nextIndex; + return { + done: nextIndex > iterable.length, + value: value + }; + } + }; + } + }; + + if (!$Map && !$Set) { + // the only language iterables are Array, String, arguments + // - Safari <= 6.0 + // - Chrome < 38 + // - node < 0.12 + // - FF < 13 + // - IE < 11 + // - Edge < 11 + + module.exports = getNonCollectionIterator; + } else { + // either Map or Set are available, but Symbol is not + // - es6-shim on an ES5 browser + // - Safari 6.2 (maybe 6.1?) + // - FF v[13, 36) + // - IE 11 + // - Edge 11 + // - Safari v[6, 9) + + var isMap = __webpack_require__(22); + var isSet = __webpack_require__(23); + + // Firefox >= 27, IE 11, Safari 6.2 - 9, Edge 11, es6-shim in older envs, all have forEach + var $mapForEach = callBound('Map.prototype.forEach', true); + var $setForEach = callBound('Set.prototype.forEach', true); + if (typeof process === 'undefined' || !process.versions || !process.versions.node) { // "if is not node" + + // Firefox 17 - 26 has `.iterator()`, whose iterator `.next()` either + // returns a value, or throws a StopIteration object. These browsers + // do not have any other mechanism for iteration. + var $mapIterator = callBound('Map.prototype.iterator', true); + var $setIterator = callBound('Set.prototype.iterator', true); + var getStopIterationIterator = function (iterator) { + var done = false; + return { + next: function next() { + try { + return { + done: done, + value: done ? undefined : iterator.next() + }; + } catch (e) { + done = true; + return { + done: true, + value: undefined + }; + } + } + }; + }; + } + // Firefox 27-35, and some older es6-shim versions, use a string "@@iterator" property + // this returns a proper iterator object, so we should use it instead of forEach. + // newer es6-shim versions use a string "_es6-shim iterator_" property. + var $mapAtAtIterator = callBound('Map.prototype.@@iterator', true) || callBound('Map.prototype._es6-shim iterator_', true); + var $setAtAtIterator = callBound('Set.prototype.@@iterator', true) || callBound('Set.prototype._es6-shim iterator_', true); + + var getCollectionIterator = function getCollectionIterator(iterable) { + if (isMap(iterable)) { + if ($mapIterator) { + return getStopIterationIterator($mapIterator(iterable)); + } + if ($mapAtAtIterator) { + return $mapAtAtIterator(iterable); + } + if ($mapForEach) { + var entries = []; + $mapForEach(iterable, function (v, k) { + $arrayPush(entries, [k, v]); + }); + return getArrayIterator(entries); + } + } + if (isSet(iterable)) { + if ($setIterator) { + return getStopIterationIterator($setIterator(iterable)); + } + if ($setAtAtIterator) { + return $setAtAtIterator(iterable); + } + if ($setForEach) { + var values = []; + $setForEach(iterable, function (v) { + $arrayPush(values, v); + }); + return getArrayIterator(values); + } + } + }; + + module.exports = function getIterator(iterable) { + return getCollectionIterator(iterable) || getNonCollectionIterator(iterable); + }; + } +} -// EXTERNAL MODULE: ./src/assets/icons/icon_operation_6.svg -var icon_operation_6 = __webpack_require__(6); -var icon_operation_6_default = /*#__PURE__*/__webpack_require__.n(icon_operation_6); +/* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(93))) -// EXTERNAL MODULE: ./src/assets/icons/icon_operation_7.svg -var icon_operation_7 = __webpack_require__(7); -var icon_operation_7_default = /*#__PURE__*/__webpack_require__.n(icon_operation_7); +/***/ }), +/* 93 */ +/***/ (function(module, exports) { -// EXTERNAL MODULE: ./src/assets/icons/icon_operation_8.svg -var icon_operation_8 = __webpack_require__(8); -var icon_operation_8_default = /*#__PURE__*/__webpack_require__.n(icon_operation_8); +// shim for using process in browser +var process = module.exports = {}; -// EXTERNAL MODULE: ./src/assets/icons/icon_operation_9.svg -var icon_operation_9 = __webpack_require__(9); -var icon_operation_9_default = /*#__PURE__*/__webpack_require__.n(icon_operation_9); +// cached from whatever global is present so that test runners that stub it +// don't break things. But we need to wrap it in a try catch in case it is +// wrapped in strict mode code which doesn't define any globals. It's inside a +// function because try/catches deoptimize in certain engines. -// CONCATENATED MODULE: ./src/modules/table-operation-menu.js +var cachedSetTimeout; +var cachedClearTimeout; - // svg icons +function defaultSetTimout() { + throw new Error('setTimeout has not been defined'); +} +function defaultClearTimeout () { + throw new Error('clearTimeout has not been defined'); +} +(function () { + try { + if (typeof setTimeout === 'function') { + cachedSetTimeout = setTimeout; + } else { + cachedSetTimeout = defaultSetTimout; + } + } catch (e) { + cachedSetTimeout = defaultSetTimout; + } + try { + if (typeof clearTimeout === 'function') { + cachedClearTimeout = clearTimeout; + } else { + cachedClearTimeout = defaultClearTimeout; + } + } catch (e) { + cachedClearTimeout = defaultClearTimeout; + } +} ()) +function runTimeout(fun) { + if (cachedSetTimeout === setTimeout) { + //normal enviroments in sane situations + return setTimeout(fun, 0); + } + // if setTimeout wasn't available but was latter defined + if ((cachedSetTimeout === defaultSetTimout || !cachedSetTimeout) && setTimeout) { + cachedSetTimeout = setTimeout; + return setTimeout(fun, 0); + } + try { + // when when somebody has screwed with setTimeout but no I.E. maddness + return cachedSetTimeout(fun, 0); + } catch(e){ + try { + // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally + return cachedSetTimeout.call(null, fun, 0); + } catch(e){ + // same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error + return cachedSetTimeout.call(this, fun, 0); + } + } +} +function runClearTimeout(marker) { + if (cachedClearTimeout === clearTimeout) { + //normal enviroments in sane situations + return clearTimeout(marker); + } + // if clearTimeout wasn't available but was latter defined + if ((cachedClearTimeout === defaultClearTimeout || !cachedClearTimeout) && clearTimeout) { + cachedClearTimeout = clearTimeout; + return clearTimeout(marker); + } + try { + // when when somebody has screwed with setTimeout but no I.E. maddness + return cachedClearTimeout(marker); + } catch (e){ + try { + // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally + return cachedClearTimeout.call(null, marker); + } catch (e){ + // same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error. + // Some versions of I.E. have different rules for clearTimeout vs setTimeout + return cachedClearTimeout.call(this, marker); + } + } +} +var queue = []; +var draining = false; +var currentQueue; +var queueIndex = -1; + +function cleanUpNextTick() { + if (!draining || !currentQueue) { + return; + } + draining = false; + if (currentQueue.length) { + queue = currentQueue.concat(queue); + } else { + queueIndex = -1; + } + if (queue.length) { + drainQueue(); + } +} +function drainQueue() { + if (draining) { + return; + } + var timeout = runTimeout(cleanUpNextTick); + draining = true; + + var len = queue.length; + while(len) { + currentQueue = queue; + queue = []; + while (++queueIndex < len) { + if (currentQueue) { + currentQueue[queueIndex].run(); + } + } + queueIndex = -1; + len = queue.length; + } + currentQueue = null; + draining = false; + runClearTimeout(timeout); +} +process.nextTick = function (fun) { + var args = new Array(arguments.length - 1); + if (arguments.length > 1) { + for (var i = 1; i < arguments.length; i++) { + args[i - 1] = arguments[i]; + } + } + queue.push(new Item(fun, args)); + if (queue.length === 1 && !draining) { + runTimeout(drainQueue); + } +}; +// v8 likes predictible objects +function Item(fun, array) { + this.fun = fun; + this.array = array; +} +Item.prototype.run = function () { + this.fun.apply(null, this.array); +}; +process.title = 'browser'; +process.browser = true; +process.env = {}; +process.argv = []; +process.version = ''; // empty string to avoid regexp issues +process.versions = {}; + +function noop() {} + +process.on = noop; +process.addListener = noop; +process.once = noop; +process.off = noop; +process.removeListener = noop; +process.removeAllListeners = noop; +process.emit = noop; +process.prependListener = noop; +process.prependOnceListener = noop; + +process.listeners = function (name) { return [] } + +process.binding = function (name) { + throw new Error('process.binding is not supported'); +}; +process.cwd = function () { return '/' }; +process.chdir = function (dir) { + throw new Error('process.chdir is not supported'); +}; +process.umask = function() { return 0; }; -const MENU_MIN_HEIHGT = 150; -const MENU_WIDTH = 200; -const table_operation_menu_ERROR_LIMIT = 5; -const DEFAULT_CELL_COLORS = ['white', 'red', 'yellow', 'blue']; -const DEFAULT_COLOR_SUBTITLE = 'Background Colors'; -const MENU_ITEMS_DEFAULT = { - insertColumnRight: { - text: 'Insert column right', - iconSrc: icon_operation_1_default.a, - handler() { - const tableContainer = external_commonjs_quill_commonjs2_quill_amd_quill_root_Quill_default.a.find(this.table); - let colIndex = getColToolCellIndexByBoundary(this.columnToolCells, this.boundary, (cellRect, boundary) => { - return Math.abs(cellRect.x + cellRect.width - boundary.x1) <= table_operation_menu_ERROR_LIMIT; - }, this.quill.root.parentNode); - const newColumn = tableContainer.insertColumn(this.boundary, colIndex, true, this.quill.root.parentNode); - this.tableColumnTool.updateToolCells(); - this.quill.update(external_commonjs_quill_commonjs2_quill_amd_quill_root_Quill_default.a.sources.USER); - this.quill.setSelection(this.quill.getIndex(newColumn[0]), 0, external_commonjs_quill_commonjs2_quill_amd_quill_root_Quill_default.a.sources.SILENT); - this.tableSelection.setSelection(newColumn[0].domNode.getBoundingClientRect(), newColumn[0].domNode.getBoundingClientRect()); - } +/***/ }), +/* 94 */ +/***/ (function(module, exports) { - }, - insertColumnLeft: { - text: 'Insert column left', - iconSrc: icon_operation_2_default.a, +var toString = {}.toString; - handler() { - const tableContainer = external_commonjs_quill_commonjs2_quill_amd_quill_root_Quill_default.a.find(this.table); - let colIndex = getColToolCellIndexByBoundary(this.columnToolCells, this.boundary, (cellRect, boundary) => { - return Math.abs(cellRect.x - boundary.x) <= table_operation_menu_ERROR_LIMIT; - }, this.quill.root.parentNode); - const newColumn = tableContainer.insertColumn(this.boundary, colIndex, false, this.quill.root.parentNode); - this.tableColumnTool.updateToolCells(); - this.quill.update(external_commonjs_quill_commonjs2_quill_amd_quill_root_Quill_default.a.sources.USER); - this.quill.setSelection(this.quill.getIndex(newColumn[0]), 0, external_commonjs_quill_commonjs2_quill_amd_quill_root_Quill_default.a.sources.SILENT); - this.tableSelection.setSelection(newColumn[0].domNode.getBoundingClientRect(), newColumn[0].domNode.getBoundingClientRect()); +module.exports = Array.isArray || function (arr) { + return toString.call(arr) == '[object Array]'; +}; + + +/***/ }), +/* 95 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +var GetIntrinsic = __webpack_require__(4); +var callBound = __webpack_require__(7); +var inspect = __webpack_require__(96); + +var $TypeError = GetIntrinsic('%TypeError%'); +var $WeakMap = GetIntrinsic('%WeakMap%', true); +var $Map = GetIntrinsic('%Map%', true); +var $push = callBound('Array.prototype.push'); + +var $weakMapGet = callBound('WeakMap.prototype.get', true); +var $weakMapSet = callBound('WeakMap.prototype.set', true); +var $weakMapHas = callBound('WeakMap.prototype.has', true); +var $mapGet = callBound('Map.prototype.get', true); +var $mapSet = callBound('Map.prototype.set', true); +var $mapHas = callBound('Map.prototype.has', true); +var objectGet = function (objects, key) { // eslint-disable-line consistent-return + for (var i = 0; i < objects.length; i += 1) { + if (objects[i].key === key) { + return objects[i].value; + } + } +}; +var objectSet = function (objects, key, value) { + for (var i = 0; i < objects.length; i += 1) { + if (objects[i].key === key) { + objects[i].value = value; // eslint-disable-line no-param-reassign + return; + } + } + $push(objects, { + key: key, + value: value + }); +}; +var objectHas = function (objects, key) { + for (var i = 0; i < objects.length; i += 1) { + if (objects[i].key === key) { + return true; + } + } + return false; +}; + +module.exports = function getSideChannel() { + var $wm; + var $m; + var $o; + var channel = { + assert: function (key) { + if (!channel.has(key)) { + throw new $TypeError('Side channel does not contain ' + inspect(key)); + } + }, + get: function (key) { // eslint-disable-line consistent-return + if ($WeakMap && key && (typeof key === 'object' || typeof key === 'function')) { + if ($wm) { + return $weakMapGet($wm, key); + } + } else if ($Map) { + if ($m) { + return $mapGet($m, key); + } + } else { + if ($o) { // eslint-disable-line no-lonely-if + return objectGet($o, key); + } + } + }, + has: function (key) { + if ($WeakMap && key && (typeof key === 'object' || typeof key === 'function')) { + if ($wm) { + return $weakMapHas($wm, key); + } + } else if ($Map) { + if ($m) { + return $mapHas($m, key); + } + } else { + if ($o) { // eslint-disable-line no-lonely-if + return objectHas($o, key); + } + } + return false; + }, + set: function (key, value) { + if ($WeakMap && key && (typeof key === 'object' || typeof key === 'function')) { + if (!$wm) { + $wm = new $WeakMap(); + } + $weakMapSet($wm, key, value); + } else if ($Map) { + if (!$m) { + $m = new $Map(); + } + $mapSet($m, key, value); + } else { + if (!$o) { + $o = []; + } + objectSet($o, key, value); + } + } + }; + return channel; +}; + + +/***/ }), +/* 96 */ +/***/ (function(module, exports, __webpack_require__) { + +var hasMap = typeof Map === 'function' && Map.prototype; +var mapSizeDescriptor = Object.getOwnPropertyDescriptor && hasMap ? Object.getOwnPropertyDescriptor(Map.prototype, 'size') : null; +var mapSize = hasMap && mapSizeDescriptor && typeof mapSizeDescriptor.get === 'function' ? mapSizeDescriptor.get : null; +var mapForEach = hasMap && Map.prototype.forEach; +var hasSet = typeof Set === 'function' && Set.prototype; +var setSizeDescriptor = Object.getOwnPropertyDescriptor && hasSet ? Object.getOwnPropertyDescriptor(Set.prototype, 'size') : null; +var setSize = hasSet && setSizeDescriptor && typeof setSizeDescriptor.get === 'function' ? setSizeDescriptor.get : null; +var setForEach = hasSet && Set.prototype.forEach; +var hasWeakMap = typeof WeakMap === 'function' && WeakMap.prototype; +var weakMapHas = hasWeakMap ? WeakMap.prototype.has : null; +var hasWeakSet = typeof WeakSet === 'function' && WeakSet.prototype; +var weakSetHas = hasWeakSet ? WeakSet.prototype.has : null; +var booleanValueOf = Boolean.prototype.valueOf; +var objectToString = Object.prototype.toString; +var match = String.prototype.match; +var bigIntValueOf = typeof BigInt === 'function' ? BigInt.prototype.valueOf : null; + +var inspectCustom = __webpack_require__(97).custom; +var inspectSymbol = inspectCustom && isSymbol(inspectCustom) ? inspectCustom : null; + +module.exports = function inspect_(obj, options, depth, seen) { + var opts = options || {}; + + if (has(opts, 'quoteStyle') && (opts.quoteStyle !== 'single' && opts.quoteStyle !== 'double')) { + throw new TypeError('option "quoteStyle" must be "single" or "double"'); } - }, - insertRowUp: { - text: 'Insert row up', - iconSrc: icon_operation_3_default.a, + if (typeof obj === 'undefined') { + return 'undefined'; + } + if (obj === null) { + return 'null'; + } + if (typeof obj === 'boolean') { + return obj ? 'true' : 'false'; + } - handler() { - const tableContainer = external_commonjs_quill_commonjs2_quill_amd_quill_root_Quill_default.a.find(this.table); - const affectedCells = tableContainer.insertRow(this.boundary, false, this.quill.root.parentNode); - this.quill.update(external_commonjs_quill_commonjs2_quill_amd_quill_root_Quill_default.a.sources.USER); - this.quill.setSelection(this.quill.getIndex(affectedCells[0]), 0, external_commonjs_quill_commonjs2_quill_amd_quill_root_Quill_default.a.sources.SILENT); - this.tableSelection.setSelection(affectedCells[0].domNode.getBoundingClientRect(), affectedCells[0].domNode.getBoundingClientRect()); + if (typeof obj === 'string') { + return inspectString(obj, opts); + } + if (typeof obj === 'number') { + if (obj === 0) { + return Infinity / obj > 0 ? '0' : '-0'; + } + return String(obj); + } + if (typeof obj === 'bigint') { // eslint-disable-line valid-typeof + return String(obj) + 'n'; } - }, - insertRowDown: { - text: 'Insert row down', - iconSrc: icon_operation_4_default.a, + var maxDepth = typeof opts.depth === 'undefined' ? 5 : opts.depth; + if (typeof depth === 'undefined') { depth = 0; } + if (depth >= maxDepth && maxDepth > 0 && typeof obj === 'object') { + return '[Object]'; + } - handler() { - const tableContainer = external_commonjs_quill_commonjs2_quill_amd_quill_root_Quill_default.a.find(this.table); - const affectedCells = tableContainer.insertRow(this.boundary, true, this.quill.root.parentNode); - this.quill.update(external_commonjs_quill_commonjs2_quill_amd_quill_root_Quill_default.a.sources.USER); - this.quill.setSelection(this.quill.getIndex(affectedCells[0]), 0, external_commonjs_quill_commonjs2_quill_amd_quill_root_Quill_default.a.sources.SILENT); - this.tableSelection.setSelection(affectedCells[0].domNode.getBoundingClientRect(), affectedCells[0].domNode.getBoundingClientRect()); + if (typeof seen === 'undefined') { + seen = []; + } else if (indexOf(seen, obj) >= 0) { + return '[Circular]'; } - }, - mergeCells: { - text: 'Merge selected cells', - iconSrc: icon_operation_5_default.a, + function inspect(value, from) { + if (from) { + seen = seen.slice(); + seen.push(from); + } + return inspect_(value, opts, depth + 1, seen); + } - handler() { - const tableContainer = external_commonjs_quill_commonjs2_quill_amd_quill_root_Quill_default.a.find(this.table); // compute merged Cell rowspan, equal to length of selected rows + if (typeof obj === 'function') { + var name = nameOf(obj); + return '[Function' + (name ? ': ' + name : '') + ']'; + } + if (isSymbol(obj)) { + var symString = Symbol.prototype.toString.call(obj); + return typeof obj === 'object' ? markBoxed(symString) : symString; + } + if (isElement(obj)) { + var s = '<' + String(obj.nodeName).toLowerCase(); + var attrs = obj.attributes || []; + for (var i = 0; i < attrs.length; i++) { + s += ' ' + attrs[i].name + '=' + wrapQuotes(quote(attrs[i].value), 'double', opts); + } + s += '>'; + if (obj.childNodes && obj.childNodes.length) { s += '...'; } + s += ''; + return s; + } + if (isArray(obj)) { + if (obj.length === 0) { return '[]'; } + return '[ ' + arrObjKeys(obj, inspect).join(', ') + ' ]'; + } + if (isError(obj)) { + var parts = arrObjKeys(obj, inspect); + if (parts.length === 0) { return '[' + String(obj) + ']'; } + return '{ [' + String(obj) + '] ' + parts.join(', ') + ' }'; + } + if (typeof obj === 'object') { + if (inspectSymbol && typeof obj[inspectSymbol] === 'function') { + return obj[inspectSymbol](); + } else if (typeof obj.inspect === 'function') { + return obj.inspect(); + } + } + if (isMap(obj)) { + var mapParts = []; + mapForEach.call(obj, function (value, key) { + mapParts.push(inspect(key, obj) + ' => ' + inspect(value, obj)); + }); + return collectionOf('Map', mapSize.call(obj), mapParts); + } + if (isSet(obj)) { + var setParts = []; + setForEach.call(obj, function (value) { + setParts.push(inspect(value, obj)); + }); + return collectionOf('Set', setSize.call(obj), setParts); + } + if (isWeakMap(obj)) { + return weakCollectionOf('WeakMap'); + } + if (isWeakSet(obj)) { + return weakCollectionOf('WeakSet'); + } + if (isNumber(obj)) { + return markBoxed(inspect(Number(obj))); + } + if (isBigInt(obj)) { + return markBoxed(inspect(bigIntValueOf.call(obj))); + } + if (isBoolean(obj)) { + return markBoxed(booleanValueOf.call(obj)); + } + if (isString(obj)) { + return markBoxed(inspect(String(obj))); + } + if (!isDate(obj) && !isRegExp(obj)) { + var xs = arrObjKeys(obj, inspect); + if (xs.length === 0) { return '{}'; } + return '{ ' + xs.join(', ') + ' }'; + } + return String(obj); +}; - const rowspan = tableContainer.rows().reduce((sum, row) => { - let rowRect = getRelativeRect(row.domNode.getBoundingClientRect(), this.quill.root.parentNode); +function wrapQuotes(s, defaultStyle, opts) { + var quoteChar = (opts.quoteStyle || defaultStyle) === 'double' ? '"' : "'"; + return quoteChar + s + quoteChar; +} - if (rowRect.y > this.boundary.y - table_operation_menu_ERROR_LIMIT && rowRect.y + rowRect.height < this.boundary.y + this.boundary.height + table_operation_menu_ERROR_LIMIT) { - sum += 1; - } +function quote(s) { + return String(s).replace(/"/g, '"'); +} - return sum; - }, 0); // compute merged cell colspan, equal to length of selected cols +function isArray(obj) { return toStr(obj) === '[object Array]'; } +function isDate(obj) { return toStr(obj) === '[object Date]'; } +function isRegExp(obj) { return toStr(obj) === '[object RegExp]'; } +function isError(obj) { return toStr(obj) === '[object Error]'; } +function isSymbol(obj) { return toStr(obj) === '[object Symbol]'; } +function isString(obj) { return toStr(obj) === '[object String]'; } +function isNumber(obj) { return toStr(obj) === '[object Number]'; } +function isBigInt(obj) { return toStr(obj) === '[object BigInt]'; } +function isBoolean(obj) { return toStr(obj) === '[object Boolean]'; } + +var hasOwn = Object.prototype.hasOwnProperty || function (key) { return key in this; }; +function has(obj, key) { + return hasOwn.call(obj, key); +} - const colspan = this.columnToolCells.reduce((sum, cell) => { - let cellRect = getRelativeRect(cell.getBoundingClientRect(), this.quill.root.parentNode); +function toStr(obj) { + return objectToString.call(obj); +} - if (cellRect.x > this.boundary.x - table_operation_menu_ERROR_LIMIT && cellRect.x + cellRect.width < this.boundary.x + this.boundary.width + table_operation_menu_ERROR_LIMIT) { - sum += 1; - } +function nameOf(f) { + if (f.name) { return f.name; } + var m = match.call(f, /^function\s*([\w$]+)/); + if (m) { return m[1]; } + return null; +} - return sum; - }, 0); - const mergedCell = tableContainer.mergeCells(this.boundary, this.selectedTds, rowspan, colspan, this.quill.root.parentNode); - this.quill.update(external_commonjs_quill_commonjs2_quill_amd_quill_root_Quill_default.a.sources.USER); - this.tableSelection.setSelection(mergedCell.domNode.getBoundingClientRect(), mergedCell.domNode.getBoundingClientRect()); +function indexOf(xs, x) { + if (xs.indexOf) { return xs.indexOf(x); } + for (var i = 0, l = xs.length; i < l; i++) { + if (xs[i] === x) { return i; } } + return -1; +} - }, - unmergeCells: { - text: 'Unmerge cells', - iconSrc: icon_operation_6_default.a, - - handler() { - const tableContainer = external_commonjs_quill_commonjs2_quill_amd_quill_root_Quill_default.a.find(this.table); - tableContainer.unmergeCells(this.selectedTds, this.quill.root.parentNode); - this.quill.update(external_commonjs_quill_commonjs2_quill_amd_quill_root_Quill_default.a.sources.USER); - this.tableSelection.clearSelection(); +function isMap(x) { + if (!mapSize || !x || typeof x !== 'object') { + return false; } + try { + mapSize.call(x); + try { + setSize.call(x); + } catch (s) { + return true; + } + return x instanceof Map; // core-js workaround, pre-v2.5.0 + } catch (e) {} + return false; +} - }, - deleteColumn: { - text: 'Delete selected columns', - iconSrc: icon_operation_7_default.a, - - handler() { - const tableContainer = external_commonjs_quill_commonjs2_quill_amd_quill_root_Quill_default.a.find(this.table); - let colIndexes = getColToolCellIndexesByBoundary(this.columnToolCells, this.boundary, (cellRect, boundary) => { - return cellRect.x + table_operation_menu_ERROR_LIMIT > boundary.x && cellRect.x + cellRect.width - table_operation_menu_ERROR_LIMIT < boundary.x1; - }, this.quill.root.parentNode); - let isDeleteTable = tableContainer.deleteColumns(this.boundary, colIndexes, this.quill.root.parentNode); - - if (!isDeleteTable) { - this.tableColumnTool.updateToolCells(); - this.quill.update(external_commonjs_quill_commonjs2_quill_amd_quill_root_Quill_default.a.sources.USER); - this.tableSelection.clearSelection(); - } +function isWeakMap(x) { + if (!weakMapHas || !x || typeof x !== 'object') { + return false; } + try { + weakMapHas.call(x, weakMapHas); + try { + weakSetHas.call(x, weakSetHas); + } catch (s) { + return true; + } + return x instanceof WeakMap; // core-js workaround, pre-v2.5.0 + } catch (e) {} + return false; +} - }, - deleteRow: { - text: 'Delete selected rows', - iconSrc: icon_operation_8_default.a, - - handler() { - const tableContainer = external_commonjs_quill_commonjs2_quill_amd_quill_root_Quill_default.a.find(this.table); - tableContainer.deleteRow(this.boundary, this.quill.root.parentNode); - this.quill.update(external_commonjs_quill_commonjs2_quill_amd_quill_root_Quill_default.a.sources.USER); - this.tableSelection.clearSelection(); +function isSet(x) { + if (!setSize || !x || typeof x !== 'object') { + return false; } + try { + setSize.call(x); + try { + mapSize.call(x); + } catch (m) { + return true; + } + return x instanceof Set; // core-js workaround, pre-v2.5.0 + } catch (e) {} + return false; +} - }, - deleteTable: { - text: 'Delete table', - iconSrc: icon_operation_9_default.a, +function isWeakSet(x) { + if (!weakSetHas || !x || typeof x !== 'object') { + return false; + } + try { + weakSetHas.call(x, weakSetHas); + try { + weakMapHas.call(x, weakMapHas); + } catch (s) { + return true; + } + return x instanceof WeakSet; // core-js workaround, pre-v2.5.0 + } catch (e) {} + return false; +} - handler() { - const betterTableModule = this.quill.getModule('better-table'); - const tableContainer = external_commonjs_quill_commonjs2_quill_amd_quill_root_Quill_default.a.find(this.table); - betterTableModule.hideTableTools(); - tableContainer.remove(); - this.quill.update(external_commonjs_quill_commonjs2_quill_amd_quill_root_Quill_default.a.sources.USER); +function isElement(x) { + if (!x || typeof x !== 'object') { return false; } + if (typeof HTMLElement !== 'undefined' && x instanceof HTMLElement) { + return true; } + return typeof x.nodeName === 'string' && typeof x.getAttribute === 'function'; +} - } -}; -class table_operation_menu_TableOperationMenu { - constructor(params, quill, options) { - const betterTableModule = quill.getModule('better-table'); - this.tableSelection = betterTableModule.tableSelection; - this.table = params.table; - this.quill = quill; - this.options = options; - this.menuItems = Object.assign({}, MENU_ITEMS_DEFAULT, options.items); - this.tableColumnTool = betterTableModule.columnTool; - this.boundary = this.tableSelection.boundary; - this.selectedTds = this.tableSelection.selectedTds; - this.destroyHandler = this.destroy.bind(this); - this.columnToolCells = this.tableColumnTool.colToolCells(); - this.colorSubTitle = options.color && options.color.text ? options.color.text : DEFAULT_COLOR_SUBTITLE; - this.cellColors = options.color && options.color.colors ? options.color.colors : DEFAULT_CELL_COLORS; - this.menuInitial(params); - this.mount(); - document.addEventListener("click", this.destroyHandler, false); - } +function inspectString(str, opts) { + // eslint-disable-next-line no-control-regex + var s = str.replace(/(['\\])/g, '\\$1').replace(/[\x00-\x1f]/g, lowbyte); + return wrapQuotes(s, 'single', opts); +} - mount() { - document.body.appendChild(this.domNode); - } +function lowbyte(c) { + var n = c.charCodeAt(0); + var x = { + 8: 'b', 9: 't', 10: 'n', 12: 'f', 13: 'r' + }[n]; + if (x) { return '\\' + x; } + return '\\x' + (n < 0x10 ? '0' : '') + n.toString(16); +} - destroy() { - this.domNode.remove(); - document.removeEventListener("click", this.destroyHandler, false); - return null; - } +function markBoxed(str) { + return 'Object(' + str + ')'; +} - menuInitial(_ref) { - let { - table, - left, - top - } = _ref; - this.domNode = document.createElement('div'); - this.domNode.classList.add('qlbt-operation-menu'); - css(this.domNode, { - position: 'absolute', - left: "".concat(left, "px"), - top: "".concat(top, "px"), - 'min-height': "".concat(MENU_MIN_HEIHGT, "px"), - width: "".concat(MENU_WIDTH, "px") - }); +function weakCollectionOf(type) { + return type + ' { ? }'; +} - for (let name in this.menuItems) { - if (this.menuItems[name]) { - this.domNode.appendChild(this.menuItemCreator(Object.assign({}, MENU_ITEMS_DEFAULT[name], this.menuItems[name]))); +function collectionOf(type, size, entries) { + return type + ' (' + size + ') {' + entries.join(', ') + '}'; +} - if (['insertRowDown', 'unmergeCells'].indexOf(name) > -1) { - this.domNode.appendChild(dividingCreator()); +function arrObjKeys(obj, inspect) { + var isArr = isArray(obj); + var xs = []; + if (isArr) { + xs.length = obj.length; + for (var i = 0; i < obj.length; i++) { + xs[i] = has(obj, i) ? inspect(obj[i], obj) : ''; } - } - } // if colors option is false, disabled bg color + } + for (var key in obj) { // eslint-disable-line no-restricted-syntax + if (!has(obj, key)) { continue; } // eslint-disable-line no-restricted-syntax, no-continue + if (isArr && String(Number(key)) === key && key < obj.length) { continue; } // eslint-disable-line no-restricted-syntax, no-continue + if ((/[^\w$]/).test(key)) { + xs.push(inspect(key, obj) + ': ' + inspect(obj[key], obj)); + } else { + xs.push(key + ': ' + inspect(obj[key], obj)); + } + } + return xs; +} - if (this.options.color && this.options.color !== false) { - this.domNode.appendChild(dividingCreator()); - this.domNode.appendChild(subTitleCreator(this.colorSubTitle)); - this.domNode.appendChild(this.colorsItemCreator(this.cellColors)); - } // create dividing line +/***/ }), +/* 97 */ +/***/ (function(module, exports) { +/* (ignored) */ - function dividingCreator() { - const dividing = document.createElement('div'); - dividing.classList.add('qlbt-operation-menu-dividing'); - return dividing; - } // create subtitle for menu +/***/ }), +/* 98 */ +/***/ (function(module, exports, __webpack_require__) { +"use strict"; +/* WEBPACK VAR INJECTION */(function(global) { + +var forEach = __webpack_require__(24); +var availableTypedArrays = __webpack_require__(25); +var callBound = __webpack_require__(7); + +var $toString = callBound('Object.prototype.toString'); +var hasSymbols = __webpack_require__(6)(); +var hasToStringTag = hasSymbols && typeof Symbol.toStringTag === 'symbol'; + +var typedArrays = availableTypedArrays(); + +var $slice = callBound('String.prototype.slice'); +var toStrTags = {}; +var gOPD = __webpack_require__(26); +var getPrototypeOf = Object.getPrototypeOf; // require('getprototypeof'); +if (hasToStringTag && gOPD && getPrototypeOf) { + forEach(typedArrays, function (typedArray) { + if (typeof global[typedArray] === 'function') { + var arr = new global[typedArray](); + if (!(Symbol.toStringTag in arr)) { + throw new EvalError('this engine has support for Symbol.toStringTag, but ' + typedArray + ' does not have the property! Please report this.'); + } + var proto = getPrototypeOf(arr); + var descriptor = gOPD(proto, Symbol.toStringTag); + if (!descriptor) { + var superProto = getPrototypeOf(proto); + descriptor = gOPD(superProto, Symbol.toStringTag); + } + toStrTags[typedArray] = descriptor.get; + } + }); +} - function subTitleCreator(title) { - const subTitle = document.createElement('div'); - subTitle.classList.add('qlbt-operation-menu-subtitle'); - subTitle.innerText = title; - return subTitle; - } - } +var tryTypedArrays = function tryAllTypedArrays(value) { + var foundName = false; + forEach(toStrTags, function (getter, typedArray) { + if (!foundName) { + try { + var name = getter.call(value); + if (name === typedArray) { + foundName = name; + } + } catch (e) {} + } + }); + return foundName; +}; - colorsItemCreator(colors) { - const self = this; - const node = document.createElement('div'); - node.classList.add('qlbt-operation-color-picker'); - colors.forEach(color => { - let colorBox = colorBoxCreator(color); - node.appendChild(colorBox); - }); +var isTypedArray = __webpack_require__(100); - function colorBoxCreator(color) { - const box = document.createElement('div'); - box.classList.add('qlbt-operation-color-picker-item'); - box.setAttribute('data-color', color); - box.style.backgroundColor = color; - box.addEventListener('click', function () { - const selectedTds = self.tableSelection.selectedTds; +module.exports = function whichTypedArray(value) { + if (!isTypedArray(value)) { return false; } + if (!hasToStringTag) { return $slice($toString(value), 8, -1); } + return tryTypedArrays(value); +}; - if (selectedTds && selectedTds.length > 0) { - selectedTds.forEach(tableCell => { - tableCell.format('cell-bg', color); - }); - } - }, false); - return box; - } +/* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(5))) - return node; - } +/***/ }), +/* 99 */ +/***/ (function(module, exports) { - menuItemCreator(_ref2) { - let { - text, - iconSrc, - handler - } = _ref2; - const node = document.createElement('div'); - node.classList.add('qlbt-operation-menu-item'); - const iconSpan = document.createElement('span'); - iconSpan.classList.add('qlbt-operation-menu-icon'); - iconSpan.innerHTML = iconSrc; - const textSpan = document.createElement('span'); - textSpan.classList.add('qlbt-operation-menu-text'); - textSpan.innerText = text; - node.appendChild(iconSpan); - node.appendChild(textSpan); - node.addEventListener('click', handler.bind(this), false); - return node; - } -} +/** + * Array#filter. + * + * @param {Array} arr + * @param {Function} fn + * @param {Object=} self + * @return {Array} + * @throw TypeError + */ -function getColToolCellIndexByBoundary(cells, boundary, conditionFn, container) { - return cells.reduce((findIndex, cell) => { - let cellRect = getRelativeRect(cell.getBoundingClientRect(), container); +module.exports = function (arr, fn, self) { + if (arr.filter) return arr.filter(fn, self); + if (void 0 === arr || null === arr) throw new TypeError; + if ('function' != typeof fn) throw new TypeError; + var ret = []; + for (var i = 0; i < arr.length; i++) { + if (!hasOwn.call(arr, i)) continue; + var val = arr[i]; + if (fn.call(self, val, i, arr)) ret.push(val); + } + return ret; +}; - if (conditionFn(cellRect, boundary)) { - findIndex = cells.indexOf(cell); - } +var hasOwn = Object.prototype.hasOwnProperty; - return findIndex; - }, false); -} -function getColToolCellIndexesByBoundary(cells, boundary, conditionFn, container) { - return cells.reduce((findIndexes, cell) => { - let cellRect = getRelativeRect(cell.getBoundingClientRect(), container); +/***/ }), +/* 100 */ +/***/ (function(module, exports, __webpack_require__) { - if (conditionFn(cellRect, boundary)) { - findIndexes.push(cells.indexOf(cell)); - } +"use strict"; +/* WEBPACK VAR INJECTION */(function(global) { - return findIndexes; - }, []); -} -// CONCATENATED MODULE: ./src/utils/node-matchers.js +var forEach = __webpack_require__(24); +var availableTypedArrays = __webpack_require__(25); +var callBound = __webpack_require__(7); +var $toString = callBound('Object.prototype.toString'); +var hasSymbols = __webpack_require__(6)(); +var hasToStringTag = hasSymbols && typeof Symbol.toStringTag === 'symbol'; -const Delta = external_commonjs_quill_commonjs2_quill_amd_quill_root_Quill_default.a.import('delta'); // rebuild delta +var typedArrays = availableTypedArrays(); -function matchTableCell(node, delta, scroll) { - const row = node.parentNode; - const table = row.parentNode.tagName === 'TABLE' ? row.parentNode : row.parentNode.parentNode; - const rows = Array.from(table.querySelectorAll('tr')); - const cells = Array.from(row.querySelectorAll('td')); - const rowId = rows.indexOf(row) + 1; - const cellId = cells.indexOf(node) + 1; - const colspan = node.getAttribute('colspan') || false; - const rowspan = node.getAttribute('rowspan') || false; - const cellBg = node.getAttribute('data-cell-bg') || node.style.backgroundColor; // The td from external table has no 'data-cell-bg' - // bugfix: empty table cells copied from other place will be removed unexpectedly +var $indexOf = callBound('Array.prototype.indexOf', true) || function indexOf(array, value) { + for (var i = 0; i < array.length; i += 1) { + if (array[i] === value) { + return i; + } + } + return -1; +}; +var $slice = callBound('String.prototype.slice'); +var toStrTags = {}; +var gOPD = __webpack_require__(26); +var getPrototypeOf = Object.getPrototypeOf; // require('getprototypeof'); +if (hasToStringTag && gOPD && getPrototypeOf) { + forEach(typedArrays, function (typedArray) { + var arr = new global[typedArray](); + if (!(Symbol.toStringTag in arr)) { + throw new EvalError('this engine has support for Symbol.toStringTag, but ' + typedArray + ' does not have the property! Please report this.'); + } + var proto = getPrototypeOf(arr); + var descriptor = gOPD(proto, Symbol.toStringTag); + if (!descriptor) { + var superProto = getPrototypeOf(proto); + descriptor = gOPD(superProto, Symbol.toStringTag); + } + toStrTags[typedArray] = descriptor.get; + }); +} - if (delta.length() === 0) { - delta = new Delta().insert('\n', { - 'table-cell-line': { - row: rowId, - cell: cellId, - rowspan, - colspan - } - }); - return delta; - } +var tryTypedArrays = function tryAllTypedArrays(value) { + var anyTrue = false; + forEach(toStrTags, function (getter, typedArray) { + if (!anyTrue) { + try { + anyTrue = getter.call(value) === typedArray; + } catch (e) { /**/ } + } + }); + return anyTrue; +}; - delta = delta.reduce((newDelta, op) => { - if (op.insert && typeof op.insert === 'string') { - const lines = []; - let insertStr = op.insert; - let start = 0; +module.exports = function isTypedArray(value) { + if (!value || typeof value !== 'object') { return false; } + if (!hasToStringTag) { + var tag = $slice($toString(value), 8, -1); + return $indexOf(typedArrays, tag) > -1; + } + if (!gOPD) { return false; } + return tryTypedArrays(value); +}; - for (let i = 0; i < op.insert.length; i++) { - if (insertStr.charAt(i) === '\n') { - if (i === 0) { - lines.push('\n'); - } else { - lines.push(insertStr.substring(start, i)); - lines.push('\n'); - } +/* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(5))) - start = i + 1; - } - } +/***/ }), +/* 101 */ +/***/ (function(module, exports, __webpack_require__) { - const tailStr = insertStr.substring(start); - if (tailStr) lines.push(tailStr); - lines.forEach(text => { - text === '\n' ? newDelta.insert('\n', op.attributes) : newDelta.insert(text, _omit(op.attributes, ['table', 'table-cell-line'])); - }); - } else { - newDelta.insert(op.insert, op.attributes); - } +"use strict"; - return newDelta; - }, new Delta()); - return delta.reduce((newDelta, op) => { - if (op.insert && typeof op.insert === 'string' && op.insert.startsWith('\n')) { - newDelta.insert(op.insert, Object.assign({}, Object.assign({}, { - row: rowId - }, op.attributes.table), { - 'table-cell-line': { - row: rowId, - cell: cellId, - rowspan, - colspan, - 'cell-bg': cellBg - } - }, _omit(op.attributes, ['table']))); - } else { - // bugfix: remove background attr from the delta of table cell - // to prevent unexcepted background attr append. - if (op.attributes && op.attributes.background && op.attributes.background === convertToHex(cellBg)) { - newDelta.insert(op.insert, Object.assign({}, _omit(op.attributes, ['table', 'table-cell-line', 'background']))); - } else { - newDelta.insert(op.insert, Object.assign({}, _omit(op.attributes, ['table', 'table-cell-line']))); - } - } - return newDelta; - }, new Delta()); -} // replace th tag with td tag +var defineProperties = __webpack_require__(2); -function matchTableHeader(node, delta, scroll) { - const row = node.parentNode; - const table = row.parentNode.tagName === 'TABLE' ? row.parentNode : row.parentNode.parentNode; - const rows = Array.from(table.querySelectorAll('tr')); - const cells = Array.from(row.querySelectorAll('th')); - const rowId = rows.indexOf(row) + 1; - const cellId = cells.indexOf(node) + 1; - const colspan = node.getAttribute('colspan') || false; - const rowspan = node.getAttribute('rowspan') || false; // bugfix: empty table cells copied from other place will be removed unexpectedly +var implementation = __webpack_require__(27); +var getPolyfill = __webpack_require__(28); +var shim = __webpack_require__(102); - if (delta.length() === 0) { - delta = new Delta().insert('\n', { - 'table-cell-line': { - row: rowId, - cell: cellId, - rowspan, - colspan - } - }); - return delta; - } +var polyfill = getPolyfill(); - delta = delta.reduce((newDelta, op) => { - if (op.insert && typeof op.insert === 'string') { - const lines = []; - let insertStr = op.insert; - let start = 0; +defineProperties(polyfill, { + getPolyfill: getPolyfill, + implementation: implementation, + shim: shim +}); - for (let i = 0; i < op.insert.length; i++) { - if (insertStr.charAt(i) === '\n') { - if (i === 0) { - lines.push('\n'); - } else { - lines.push(insertStr.substring(start, i)); - lines.push('\n'); - } +module.exports = polyfill; - start = i + 1; - } - } - const tailStr = insertStr.substring(start); - if (tailStr) lines.push(tailStr); // bugfix: no '\n' in op.insert, push a '\n' to lines +/***/ }), +/* 102 */ +/***/ (function(module, exports, __webpack_require__) { - if (lines.indexOf('\n') < 0) { - lines.push('\n'); - } +"use strict"; - lines.forEach(text => { - text === '\n' ? newDelta.insert('\n', { - 'table-cell-line': { - row: rowId, - cell: cellId, - rowspan, - colspan - } - }) : newDelta.insert(text, op.attributes); - }); - } else { - newDelta.insert(op.insert, op.attributes); - } - return newDelta; - }, new Delta()); - return delta.reduce((newDelta, op) => { - if (op.insert && typeof op.insert === 'string' && op.insert.startsWith('\n')) { - newDelta.insert(op.insert, Object.assign({}, { - 'table-cell-line': { - row: rowId, - cell: cellId, - rowspan, - colspan - } - })); - } else { - newDelta.insert(op.insert, Object.assign({}, _omit(op.attributes, ['table', 'table-cell-line']))); - } +var define = __webpack_require__(2); +var getPolyfill = __webpack_require__(28); - return newDelta; - }, new Delta()); -} // supplement colgroup and col +module.exports = function shimAssign() { + var polyfill = getPolyfill(); + define( + Object, + { assign: polyfill }, + { assign: function () { return Object.assign !== polyfill; } } + ); + return polyfill; +}; -function matchTable(node, delta, scroll) { - let newColDelta = new Delta(); - const topRow = node.querySelector('tr'); // bugfix: empty table will return empty delta - if (topRow === null) return newColDelta; - const cellsInTopRow = Array.from(topRow.querySelectorAll('td')).concat(Array.from(topRow.querySelectorAll('th'))); - const maxCellsNumber = cellsInTopRow.reduce((sum, cell) => { - const cellColspan = cell.getAttribute('colspan') || 1; - sum = sum + parseInt(cellColspan, 10); - return sum; - }, 0); - const colsNumber = node.querySelectorAll('col').length; // issue #2 - // bugfix: the table copied from Excel had some default col tags missing - // add missing col tags +/***/ }), +/* 103 */ +/***/ (function(module, exports, __webpack_require__) { - if (colsNumber === maxCellsNumber) { - return delta; - } else { - for (let i = 0; i < maxCellsNumber - colsNumber; i++) { - newColDelta.insert('\n', { - 'table-col': true - }); - } - if (colsNumber === 0) return newColDelta.concat(delta); - let lastNumber = 0; - return delta.reduce((finalDelta, op) => { - finalDelta.insert(op.insert, op.attributes); +var content = __webpack_require__(12); - if (op.attributes && op.attributes['table-col']) { - lastNumber += op.insert.length; +if(typeof content === 'string') content = [[module.i, content, '']]; - if (lastNumber === colsNumber) { - finalDelta = finalDelta.concat(newColDelta); - } - } +var transform; +var insertInto; - return finalDelta; - }, new Delta()); - } -} -// CONCATENATED MODULE: ./src/quill-better-table.js +var options = {"hmr":true} - // import table node matchers +options.transform = transform +options.insertInto = undefined; +var update = __webpack_require__(105)(content, options); +if(content.locals) module.exports = content.locals; -const Module = external_commonjs_quill_commonjs2_quill_amd_quill_root_Quill_default.a.import('core/module'); -const quill_better_table_Delta = external_commonjs_quill_commonjs2_quill_amd_quill_root_Quill_default.a.import('delta'); +if(true) { + module.hot.accept(12, function() { + var newContent = __webpack_require__(12); + if(typeof newContent === 'string') newContent = [[module.i, newContent, '']]; -class quill_better_table_BetterTable extends Module { - static register() { - external_commonjs_quill_commonjs2_quill_amd_quill_root_Quill_default.a.register(TableCol, true); - external_commonjs_quill_commonjs2_quill_amd_quill_root_Quill_default.a.register(TableColGroup, true); - external_commonjs_quill_commonjs2_quill_amd_quill_root_Quill_default.a.register(TableCellLine, true); - external_commonjs_quill_commonjs2_quill_amd_quill_root_Quill_default.a.register(TableCell, true); - external_commonjs_quill_commonjs2_quill_amd_quill_root_Quill_default.a.register(TableRow, true); - external_commonjs_quill_commonjs2_quill_amd_quill_root_Quill_default.a.register(TableBody, true); - external_commonjs_quill_commonjs2_quill_amd_quill_root_Quill_default.a.register(table_TableContainer, true); - external_commonjs_quill_commonjs2_quill_amd_quill_root_Quill_default.a.register(table_TableViewWrapper, true); - external_commonjs_quill_commonjs2_quill_amd_quill_root_Quill_default.a.register(table_TableViewWrapper, true); // register customized Header,overwriting quill built-in Header - // Quill.register('formats/header', Header, true); - } + var locals = (function(a, b) { + var key, idx = 0; - constructor(quill, options) { - super(quill, options); // handle click on quill-better-table + for(key in a) { + if(!b || a[key] !== b[key]) return false; + idx++; + } - this.quill.root.addEventListener('click', evt => { - // bugfix: evt.path is undefined in Safari, FF, Micro Edge - const path = getEventComposedPath(evt); - if (!path || path.length <= 0) return; - const tableNode = path.filter(node => { - return node.tagName && node.tagName.toUpperCase() === 'TABLE' && node.classList.contains('quill-better-table'); - })[0]; + for(key in b) idx--; - if (tableNode) { - // current table clicked - if (this.table === tableNode) return; // other table clicked + return idx === 0; + }(content.locals, newContent.locals)); - if (this.table) this.hideTableTools(); - this.showTableTools(tableNode, quill, options); - } else if (this.table) { - // other clicked - this.hideTableTools(); - } - }, false); // handle right click on quill-better-table + if(!locals) throw new Error('Aborting CSS HMR due to changed css-modules locals.'); - this.quill.root.addEventListener('contextmenu', evt => { - if (!this.table) return true; - evt.preventDefault(); // bugfix: evt.path is undefined in Safari, FF, Micro Edge + update(newContent); + }); - const path = getEventComposedPath(evt); - if (!path || path.length <= 0) return; - const tableNode = path.filter(node => { - return node.tagName && node.tagName.toUpperCase() === 'TABLE' && node.classList.contains('quill-better-table'); - })[0]; - const rowNode = path.filter(node => { - return node.tagName && node.tagName.toUpperCase() === 'TR' && node.getAttribute('data-row'); - })[0]; - const cellNode = path.filter(node => { - return node.tagName && node.tagName.toUpperCase() === 'TD' && node.getAttribute('data-row'); - })[0]; - let isTargetCellSelected = this.tableSelection.selectedTds.map(tableCell => tableCell.domNode).includes(cellNode); + module.hot.dispose(function() { update(); }); +} - if (this.tableSelection.selectedTds.length <= 0 || !isTargetCellSelected) { - this.tableSelection.setSelection(cellNode.getBoundingClientRect(), cellNode.getBoundingClientRect()); - } +/***/ }), +/* 104 */ +/***/ (function(module, exports, __webpack_require__) { - if (this.tableOperationMenu) this.tableOperationMenu = this.tableOperationMenu.destroy(); +"use strict"; - if (tableNode) { - this.tableOperationMenu = new table_operation_menu_TableOperationMenu({ - table: tableNode, - row: rowNode, - cell: cellNode, - left: evt.pageX, - top: evt.pageY - }, quill, options.operationMenu); + +/* + MIT License http://www.opensource.org/licenses/mit-license.php + Author Tobias Koppers @sokra +*/ +// css base code, injected by the css-loader +module.exports = function (useSourceMap) { + var list = []; // return the list of modules as css string + + list.toString = function toString() { + return this.map(function (item) { + var content = cssWithMappingToString(item, useSourceMap); + + if (item[2]) { + return '@media ' + item[2] + '{' + content + '}'; + } else { + return content; } - }, false); // add keyboard binding:Backspace - // prevent user hits backspace to delete table cell + }).join(''); + }; // import a list of modules into the list + - const KeyBoard = quill.getModule('keyboard'); - quill.keyboard.addBinding({ - key: 'Backspace' - }, {}, function (range, context) { - if (range.index === 0 || this.quill.getLength() <= 1) return true; - const [line] = this.quill.getLine(range.index); + list.i = function (modules, mediaQuery) { + if (typeof modules === 'string') { + modules = [[null, modules, '']]; + } - if (context.offset === 0) { - const [prev] = this.quill.getLine(range.index - 1); + var alreadyImportedModules = {}; - if (prev != null) { - if (prev.statics.blotName === 'table-cell-line' && line.statics.blotName !== 'table-cell-line') return false; + for (var i = 0; i < this.length; i++) { + var id = this[i][0]; + + if (id != null) { + alreadyImportedModules[id] = true; + } + } + + for (i = 0; i < modules.length; i++) { + var item = modules[i]; // skip already imported module + // this implementation is not 100% perfect for weird media query combinations + // when a module is imported multiple times with different media queries. + // I hope this will never occur (Hey this way we have smaller bundles) + + if (item[0] == null || !alreadyImportedModules[item[0]]) { + if (mediaQuery && !item[2]) { + item[2] = mediaQuery; + } else if (mediaQuery) { + item[2] = '(' + item[2] + ') and (' + mediaQuery + ')'; } + + list.push(item); } + } + }; - return true; - }); // since only one matched bindings callback will excute. - // expected my binding callback excute first - // I changed the order of binding callbacks + return list; +}; - let thisBinding = quill.keyboard.bindings['Backspace'].pop(); - quill.keyboard.bindings['Backspace'].splice(0, 1, thisBinding); // add Matchers to match and render quill-better-table for initialization - // or pasting +function cssWithMappingToString(item, useSourceMap) { + var content = item[1] || ''; + var cssMapping = item[3]; - quill.clipboard.addMatcher('td', matchTableCell); - quill.clipboard.addMatcher('th', matchTableHeader); - quill.clipboard.addMatcher('table', matchTable); // quill.clipboard.addMatcher('h1, h2, h3, h4, h5, h6', matchHeader) - // remove matcher for tr tag + if (!cssMapping) { + return content; + } - quill.clipboard.matchers = quill.clipboard.matchers.filter(matcher => { - return matcher[0] !== 'tr'; + if (useSourceMap && typeof btoa === 'function') { + var sourceMapping = toComment(cssMapping); + var sourceURLs = cssMapping.sources.map(function (source) { + return '/*# sourceURL=' + cssMapping.sourceRoot + source + ' */'; }); + return [content].concat(sourceURLs).concat([sourceMapping]).join('\n'); } - getTable() { - let range = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : this.quill.getSelection(); - if (range == null) return [null, null, null, -1]; - const [cellLine, offset] = this.quill.getLine(range.index); + return [content].join('\n'); +} // Adapted from convert-source-map (MIT) - if (cellLine == null || cellLine.statics.blotName !== TableCellLine.blotName) { - return [null, null, null, -1]; - } - const cell = cellLine.tableCell(); - const row = cell.row(); - const table = row.table(); - return [table, row, cell, offset]; - } +function toComment(sourceMap) { + // eslint-disable-next-line no-undef + var base64 = btoa(unescape(encodeURIComponent(JSON.stringify(sourceMap)))); + var data = 'sourceMappingURL=data:application/json;charset=utf-8;base64,' + base64; + return '/*# ' + data + ' */'; +} - insertTable(rows, columns) { - const range = this.quill.getSelection(true); - if (range == null) return; - let currentBlot = this.quill.getLeaf(range.index)[0]; - let delta = new quill_better_table_Delta().retain(range.index); +/***/ }), +/* 105 */ +/***/ (function(module, exports, __webpack_require__) { - if (isInTableCell(currentBlot)) { - console.warn("Can not insert table into a table cell."); - return; - } +/* + MIT License http://www.opensource.org/licenses/mit-license.php + Author Tobias Koppers @sokra +*/ - delta.insert('\n'); // insert table column +var stylesInDom = {}; - delta = new Array(columns).fill('\n').reduce((memo, text) => { - memo.insert(text, { - 'table-col': true - }); - return memo; - }, delta); // insert table cell line with empty line +var memoize = function (fn) { + var memo; - delta = new Array(rows).fill(0).reduce(memo => { - let tableRowId = table_rowId(); - return new Array(columns).fill('\n').reduce((memo, text) => { - memo.insert(text, { - 'table-cell-line': { - row: tableRowId, - cell: table_cellId() - } - }); - return memo; - }, memo); - }, delta); - this.quill.updateContents(delta, external_commonjs_quill_commonjs2_quill_amd_quill_root_Quill_default.a.sources.USER); - this.quill.setSelection(range.index + columns + 1, external_commonjs_quill_commonjs2_quill_amd_quill_root_Quill_default.a.sources.API); - } + return function () { + if (typeof memo === "undefined") memo = fn.apply(this, arguments); + return memo; + }; +}; - showTableTools(table, quill, options) { - this.table = table; - this.columnTool = new table_column_tool_TableColumnTool(table, quill, options); - this.tableSelection = new table_selection_TableSelection(table, quill, options); +var isOldIE = memoize(function () { + // Test for IE <= 9 as proposed by Browserhacks + // @see http://browserhacks.com/#hack-e71d8692f65334173fee715c222cb805 + // Tests for existence of standard globals is to allow style-loader + // to operate correctly into non-standard environments + // @see https://github.com/webpack-contrib/style-loader/issues/177 + return window && document && document.all && !window.atob; +}); + +var getTarget = function (target, parent) { + if (parent){ + return parent.querySelector(target); } + return document.querySelector(target); +}; - hideTableTools() { - this.columnTool && this.columnTool.destroy(); - this.tableSelection && this.tableSelection.destroy(); - this.tableOperationMenu && this.tableOperationMenu.destroy(); - this.columnTool = null; - this.tableSelection = null; - this.tableOperationMenu = null; - this.table = null; - } +var getElement = (function (fn) { + var memo = {}; + + return function(target, parent) { + // If passing function in options, then use it for resolve "head" element. + // Useful for Shadow Root style i.e + // { + // insertInto: function () { return document.querySelector("#foo").shadowRoot } + // } + if (typeof target === 'function') { + return target(); + } + if (typeof memo[target] === "undefined") { + var styleTarget = getTarget.call(this, target, parent); + // Special case to return head of iframe instead of iframe itself + if (window.HTMLIFrameElement && styleTarget instanceof window.HTMLIFrameElement) { + try { + // This will throw an exception if access to iframe is blocked + // due to cross-origin restrictions + styleTarget = styleTarget.contentDocument.head; + } catch(e) { + styleTarget = null; + } + } + memo[target] = styleTarget; + } + return memo[target] + }; +})(); + +var singleton = null; +var singletonCounter = 0; +var stylesInsertedAtTop = []; + +var fixUrls = __webpack_require__(106); + +module.exports = function(list, options) { + if (typeof DEBUG !== "undefined" && DEBUG) { + if (typeof document !== "object") throw new Error("The style-loader cannot be used in a non-browser environment"); + } + + options = options || {}; + + options.attrs = typeof options.attrs === "object" ? options.attrs : {}; + + // Force single-tag solution on IE6-9, which has a hard limit on the # of