From 38f62ac15f7b4b4fae43f783f0f9bf0b7508441d Mon Sep 17 00:00:00 2001 From: luowei Date: Wed, 16 Oct 2019 16:56:49 +0800 Subject: [PATCH] [build]product --- dist/demo/demo1.js | 29 ++++++++++++++++++++++++++--- dist/quill-better-table.js | 29 ++++++++++++++++++++++++++--- dist/quill-better-table.min.js | 2 +- 3 files changed, 53 insertions(+), 7 deletions(-) diff --git a/dist/demo/demo1.js b/dist/demo/demo1.js index 833adae..6f35f50 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 = "97da4b01dfc4fa5473fa"; +/******/ var hotCurrentHash = "0ab79ca97240aece4188"; /******/ var hotRequestTimeout = 10000; /******/ var hotCurrentModuleData = {}; /******/ var hotCurrentChildModule; @@ -1711,12 +1711,19 @@ class table_TableContainer extends Container { 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); @@ -1769,7 +1776,9 @@ class table_TableContainer extends Container { modifiedCells.forEach(cell => { const cellRowspan = parseInt(cell.formats().rowspan, 10); cell.format("rowspan", cellRowspan - removedRowsLength); - }); + }); // remove selected rows + + removedRows.forEach(row => row.remove()); } tableDestroy() { @@ -2996,8 +3005,13 @@ class quill_better_table_BetterTable extends Module { const range = this.quill.getSelection(true); if (range == null) return; let currentBlot = this.quill.getLeaf(range.index)[0]; - let nextBlot = this.quill.getLeaf(range.index + 1)[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) => { @@ -3105,6 +3119,15 @@ quill_better_table_BetterTable.keyboardBindings = { } }; + +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); /***/ }), diff --git a/dist/quill-better-table.js b/dist/quill-better-table.js index feb08d3..b245877 100644 --- a/dist/quill-better-table.js +++ b/dist/quill-better-table.js @@ -73,7 +73,7 @@ return /******/ (function(modules) { // webpackBootstrap /******/ /******/ var hotApplyOnUpdate = true; /******/ // eslint-disable-next-line no-unused-vars -/******/ var hotCurrentHash = "97da4b01dfc4fa5473fa"; +/******/ var hotCurrentHash = "0ab79ca97240aece4188"; /******/ var hotRequestTimeout = 10000; /******/ var hotCurrentModuleData = {}; /******/ var hotCurrentChildModule; @@ -1711,12 +1711,19 @@ class table_TableContainer extends Container { 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); @@ -1769,7 +1776,9 @@ class table_TableContainer extends Container { modifiedCells.forEach(cell => { const cellRowspan = parseInt(cell.formats().rowspan, 10); cell.format("rowspan", cellRowspan - removedRowsLength); - }); + }); // remove selected rows + + removedRows.forEach(row => row.remove()); } tableDestroy() { @@ -2996,8 +3005,13 @@ class quill_better_table_BetterTable extends Module { const range = this.quill.getSelection(true); if (range == null) return; let currentBlot = this.quill.getLeaf(range.index)[0]; - let nextBlot = this.quill.getLeaf(range.index + 1)[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) => { @@ -3105,6 +3119,15 @@ quill_better_table_BetterTable.keyboardBindings = { } }; + +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); /***/ }), diff --git a/dist/quill-better-table.min.js b/dist/quill-better-table.min.js index 213f85d..eb18f00 100644 --- a/dist/quill-better-table.min.js +++ b/dist/quill-better-table.min.js @@ -1 +1 @@ -!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("quill")):"function"==typeof define&&define.amd?define(["quill"],t):"object"==typeof exports?exports.quillBetterTable=t(require("quill")):e.quillBetterTable=t(e.Quill)}(window,function(e){return function(e){var t=window.webpackHotUpdatequillBetterTable;window.webpackHotUpdatequillBetterTable=function(e,o){!function(e,t){if(!x[e]||!y[e])return;for(var o in y[e]=!1,t)Object.prototype.hasOwnProperty.call(t,o)&&(f[o]=t[o]);0==--g&&0===w&&A()}(e,o),t&&t(e,o)};var o,n=!0,r="9bb095182b2e0ba7b9f5",i=1e4,l={},s=[],a=[];function c(e){var t=S[e];if(!t)return T;var n=function(n){return t.hot.active?(S[n]?-1===S[n].parents.indexOf(e)&&S[n].parents.push(e):(s=[e],o=n),-1===t.children.indexOf(n)&&t.children.push(n)):(console.warn("[HMR] unexpected require("+n+") from disposed module "+e),s=[]),T(n)},r=function(e){return{configurable:!0,enumerable:!0,get:function(){return T[e]},set:function(t){T[e]=t}}};for(var i in T)Object.prototype.hasOwnProperty.call(T,i)&&"e"!==i&&"t"!==i&&Object.defineProperty(n,i,r(i));return n.e=function(e){return"ready"===u&&p("prepare"),w++,T.e(e).then(t,function(e){throw t(),e});function t(){w--,"prepare"===u&&(v[e]||q(e),0===w&&0===g&&A())}},n.t=function(e,t){return 1&t&&(e=n(e)),T.t(e,-2&t)},n}function d(e){var t={_acceptedDependencies:{},_declinedDependencies:{},_selfAccepted:!1,_selfDeclined:!1,_disposeHandlers:[],_main:o!==e,active:!0,accept:function(e,o){if(void 0===e)t._selfAccepted=!0;else if("function"==typeof e)t._selfAccepted=e;else if("object"==typeof e)for(var n=0;n=0&&t._disposeHandlers.splice(o,1)},check:C,apply:E,status:function(e){if(!e)return u;h.push(e)},addStatusHandler:function(e){h.push(e)},removeStatusHandler:function(e){var t=h.indexOf(e);t>=0&&h.splice(t,1)},data:l[e]};return o=void 0,t}var h=[],u="idle";function p(e){u=e;for(var t=0;t0;){var r=n.pop(),i=r.id,l=r.chain;if((a=S[i])&&!a.hot._selfAccepted){if(a.hot._selfDeclined)return{type:"self-declined",chain:l,moduleId:i};if(a.hot._main)return{type:"unaccepted",chain:l,moduleId:i};for(var s=0;s ")),C.type){case"self-declined":t.onDeclined&&t.onDeclined(C),t.ignoreDeclined||(q=new Error("Aborted because of self decline: "+C.moduleId+H));break;case"declined":t.onDeclined&&t.onDeclined(C),t.ignoreDeclined||(q=new Error("Aborted because of declined dependency: "+C.moduleId+" in "+C.parentId+H));break;case"unaccepted":t.onUnaccepted&&t.onUnaccepted(C),t.ignoreUnaccepted||(q=new Error("Aborted because "+c+" is not accepted"+H));break;case"accepted":t.onAccepted&&t.onAccepted(C),A=!0;break;case"disposed":t.onDisposed&&t.onDisposed(C),E=!0;break;default:throw new Error("Unexception type "+C.type)}if(q)return p("abort"),Promise.reject(q);if(A)for(c in w[c]=f[c],h(g,C.outdatedModules),C.outdatedDependencies)Object.prototype.hasOwnProperty.call(C.outdatedDependencies,c)&&(m[c]||(m[c]=[]),h(m[c],C.outdatedDependencies[c]));E&&(h(g,[C.moduleId]),w[c]=v)}var M,B=[];for(n=0;n0;)if(c=R.pop(),a=S[c]){var z={},k=a.hot._disposeHandlers;for(i=0;i=0&&I.parents.splice(M,1))}}for(c in m)if(Object.prototype.hasOwnProperty.call(m,c)&&(a=S[c]))for(L=m[c],i=0;i=0&&a.children.splice(M,1);for(c in p("apply"),r=b,w)Object.prototype.hasOwnProperty.call(w,c)&&(e[c]=w[c]);var D=null;for(c in m)if(Object.prototype.hasOwnProperty.call(m,c)&&(a=S[c])){L=m[c];var j=[];for(n=0;n'},function(e,t){e.exports=''},function(e,t){e.exports=''},function(e,t){e.exports=''},function(e,t){e.exports=''},function(e,t){e.exports=''},function(e,t){e.exports=''},function(e,t){e.exports=''},function(e,t){e.exports=''},function(e,t,o){e.exports=o(11)},function(e,t,o){"use strict";o.r(t);var n=o(0),r=o.n(n);function i(e,t){if("object"==typeof t)for(let o in t)e.style[o]=t[o]}function l(e,t){let o=t.getBoundingClientRect();return{x:e.x-o.x-t.scrollLeft,y:e.y-o.y-t.scrollTop,x1:e.x-o.x-t.scrollLeft+e.width,y1:e.y-o.y-t.scrollTop+e.height,width:e.width,height:e.height}}function s(e,t){return e&&Object.keys(e).reduce((o,n)=>t.includes(n)?o:Object.assign({},o,{[n]:e[n]}),{})}function a(e){let t;if(null==(t=e.path||e.composedPath&&e.composedPath())&&e.target){t=[];let o=e.target;for(t.push(o);o&&o.parentNode;)o=o.parentNode,t.push(o)}return t}const c=12,d=12,h=50,u="#35A7ED";class p{constructor(e,t,o){if(!e)return null;this.table=e,this.quill=t,this.options=o,this.domNode=null,this.initColTool()}initColTool(){const e=this.quill.root.parentNode,t=(this.table.getBoundingClientRect(),e.getBoundingClientRect()),o=this.table.parentNode.getBoundingClientRect();this.domNode=document.createElement("div"),this.domNode.classList.add("qlbt-col-tool"),this.updateToolCells(),e.appendChild(this.domNode),i(this.domNode,{width:"".concat(o.width,"px"),height:"".concat(c,"px"),left:"".concat(o.left-t.left+e.scrollLeft,"px"),top:"".concat(o.top-t.top+e.scrollTop-c-5,"px")})}createToolCell(){const e=document.createElement("div");e.classList.add("qlbt-col-tool-cell");const t=document.createElement("div");return t.classList.add("qlbt-col-tool-cell-holder"),i(e,{height:"".concat(d,"px")}),e.appendChild(t),e}updateToolCells(){const e=r.a.find(this.table),t=e.children.tail.children.head.children,o=e.colGroup().children,n=function(e){return e.reduce((e,t)=>{const o=t.formats().colspan;return e+=parseInt(o,10)},0)}(t);let l=Array.from(this.domNode.querySelectorAll(".qlbt-col-tool-cell"));for(let e=0;e=n?l[e].remove():i(s=l[e],{"min-width":"".concat(r,"px")}):(s=this.createToolCell(),this.domNode.appendChild(s),this.addColCellHolderHandler(s),i(s,{"min-width":"".concat(r,"px")}))}}destroy(){return this.domNode.remove(),null}addColCellHolderHandler(e){const t=r.a.find(this.table),o=e.querySelector(".qlbt-col-tool-cell-holder");let n=!1,l=0,s=0,a=0,d=0,p={},m={},f=null;const b=e=>{e.preventDefault(),n&&(s=e.clientX,a=d+s-l>=h?s-l:h-d,i(f,{left:"".concat(m.left+m.width-1+a,"px")}))},g=r=>{r.preventDefault();const c=Array.from(this.domNode.querySelectorAll(".qlbt-col-tool-cell")).indexOf(e),h=t.colGroup().children.at(c);n&&(h.format("width",d+a),i(e,{"min-width":"".concat(d+a,"px")}),l=0,s=0,a=0,d=0,n=!1,o.classList.remove("dragging")),document.removeEventListener("mousemove",b,!1),document.removeEventListener("mouseup",g,!1),p={},m={},f.remove(),f=null,t.updateTableWidth();const u=this.quill.getModule("better-table").tableSelection;u&&u.clearSelection()};o.addEventListener("mousedown",t=>{document.addEventListener("mousemove",b,!1),document.addEventListener("mouseup",g,!1),p=this.table.getBoundingClientRect(),m=e.getBoundingClientRect(),i(f=document.createElement("div"),{position:"fixed",top:"".concat(m.top,"px"),left:"".concat(m.left+m.width-1,"px"),zIndex:"100",height:"".concat(p.height+c+4,"px"),width:"1px",backgroundColor:u}),document.body.appendChild(f),n=!0,l=t.clientX,d=m.width,o.classList.add("dragging")},!1)}colToolCells(){return Array.from(this.domNode.querySelectorAll(".qlbt-col-tool-cell"))}}const m=r.a.import("blots/block");class f extends m{static create(e){"string"==typeof e&&(e={value:e});const t=super.create(e.value);return N.forEach(o=>{e[o]&&t.setAttribute("data-".concat(o),e[o])}),C.forEach(o=>{e[o]&&t.setAttribute("data-".concat(o),e[o])}),t}static formats(e){const t={};return t.value=this.tagName.indexOf(e.tagName)+1,C.concat(N).reduce((t,o)=>(e.hasAttribute("data-".concat(o))&&(t[o]=e.getAttribute("data-".concat(o))||void 0),t),t)}format(e,t){const{row:o,cell:n,rowspan:r,colspan:i}=f.formats(this.domNode);e===f.blotName?t?super.format(e,{value:t,row:o,cell:n,rowspan:r,colspan:i}):o?this.replaceWith(E.blotName,{row:o,cell:n,rowspan:r,colspan:i}):super.format(e,t):super.format(e,t)}optimize(e){const{row:t,rowspan:o,colspan:n}=f.formats(this.domNode);if(!t||this.parent instanceof S||this.wrap(S.blotName,{row:t,colspan:n,rowspan:o}),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 e=this.scroll.create(this.statics.defaultChild.blotName);this.appendChild(e)}else this.remove();this.cache={}}}f.blotName="header",f.tagName=["H1","H2","H3","H4","H5","H6"];var b=f;const g=r.a.import("blots/break"),w=r.a.import("blots/block"),v=r.a.import("blots/container"),y=["width"],x={width:100},N=["row","cell"],C=["rowspan","colspan"],q={rowspan:1,colspan:1},A=5;class E extends w{static create(e){const t=super.create(e);return N.forEach(o=>{let n="row"===o?R:z;t.setAttribute("data-".concat(o),e[o]||n())}),C.forEach(o=>{t.setAttribute("data-".concat(o),e[o]||q[o])}),e["cell-bg"]&&t.setAttribute("data-cell-bg",e["cell-bg"]),t}static formats(e){return C.concat(N).concat(["cell-bg"]).reduce((t,o)=>(e.hasAttribute("data-".concat(o))&&(t[o]=e.getAttribute("data-".concat(o))||void 0),t),{})}format(e,t){if(C.concat(N).indexOf(e)>-1)t?this.domNode.setAttribute("data-".concat(e),t):this.domNode.removeAttribute("data-".concat(e));else if("cell-bg"===e)t?this.domNode.setAttribute("data-cell-bg",t):this.domNode.removeAttribute("data-cell-bg");else if("header"===e){if(!t)return;const{row:o,cell:n,rowspan:r,colspan:i}=E.formats(this.domNode);super.format(e,{value:t,row:o,cell:n,rowspan:r,colspan:i})}else super.format(e,t)}optimize(e){const t=this.domNode.getAttribute("data-row"),o=this.domNode.getAttribute("data-rowspan"),n=this.domNode.getAttribute("data-colspan"),r=this.domNode.getAttribute("data-cell-bg");!this.statics.requiredContainer||this.parent instanceof this.statics.requiredContainer||this.wrap(this.statics.requiredContainer.blotName,{row:t,colspan:n,rowspan:o,"cell-bg":r}),super.optimize(e)}tableCell(){return this.parent}}E.blotName="table-cell-line",E.ClassName="qlbt-cell-line",E.tagName="DIV";class S extends v{checkMerge(){if(super.checkMerge()&&null!=this.next.children.head){const e=this.children.head.formats()[this.children.head.statics.blotName],t=this.children.tail.formats()[this.children.tail.statics.blotName],o=this.next.children.head.formats()[this.next.children.head.statics.blotName],n=this.next.children.tail.formats()[this.next.children.tail.statics.blotName];return e.cell===t.cell&&e.cell===o.cell&&e.cell===n.cell}return!1}static create(e){const t=super.create(e);return t.setAttribute("data-row",e.row),C.forEach(o=>{e[o]&&t.setAttribute(o,e[o])}),e["cell-bg"]&&(t.setAttribute("data-cell-bg",e["cell-bg"]),t.style.backgroundColor=e["cell-bg"]),t}static formats(e){const t={};return e.hasAttribute("data-row")&&(t.row=e.getAttribute("data-row")),e.hasAttribute("data-cell-bg")&&(t["cell-bg"]=e.getAttribute("data-cell-bg")),C.reduce((t,o)=>(e.hasAttribute(o)&&(t[o]=e.getAttribute(o)),t),t)}cellOffset(){return this.parent?this.parent.children.indexOf(this):-1}formats(){const e={};return this.domNode.hasAttribute("data-row")&&(e.row=this.domNode.getAttribute("data-row")),this.domNode.hasAttribute("data-cell-bg")&&(e["cell-bg"]=this.domNode.getAttribute("data-cell-bg")),C.reduce((e,t)=>(this.domNode.hasAttribute(t)&&(e[t]=this.domNode.getAttribute(t)),e),e)}toggleAttribute(e,t){t?this.domNode.setAttribute(e,t):this.domNode.removeAttribute(e)}formatChildren(e,t){this.children.forEach(o=>{o.format(e,t)})}format(e,t){C.indexOf(e)>-1?(this.toggleAttribute(e,t),this.formatChildren(e,t)):["row"].indexOf(e)>-1?(this.toggleAttribute("data-".concat(e),t),this.formatChildren(e,t)):"cell-bg"===e?(this.toggleAttribute("data-cell-bg",t),this.formatChildren(e,t),this.domNode.style.backgroundColor=t||"initial"):super.format(e,t)}optimize(e){const t=this.domNode.getAttribute("data-row");!this.statics.requiredContainer||this.parent instanceof this.statics.requiredContainer||this.wrap(this.statics.requiredContainer.blotName,{row:t}),super.optimize(e)}row(){return this.parent}rowOffset(){return this.row()?this.row().rowOffset():-1}table(){return this.row()&&this.row().table()}}S.blotName="table",S.tagName="TD";class T extends v{checkMerge(){if(super.checkMerge()&&null!=this.next.children.head){const e=this.children.head.formats(),t=this.children.tail.formats(),o=this.next.children.head.formats(),n=this.next.children.tail.formats();return e.row===t.row&&e.row===o.row&&e.row===n.row}return!1}static create(e){const t=super.create(e);return t.setAttribute("data-row",e.row),t}formats(){return["row"].reduce((e,t)=>(this.domNode.hasAttribute("data-".concat(t))&&(e[t]=this.domNode.getAttribute("data-".concat(t))),e),{})}optimize(e){!this.statics.requiredContainer||this.parent instanceof this.statics.requiredContainer||this.wrap(this.statics.requiredContainer.blotName),this.enforceAllowedChildren(),null!=this.uiNode&&this.uiNode!==this.domNode.firstChild&&this.domNode.insertBefore(this.uiNode,this.domNode.firstChild),this.children.length>0&&null!=this.next&&this.checkMerge()&&(this.next.moveChildren(this),this.next.remove())}rowOffset(){return this.parent?this.parent.children.indexOf(this):-1}table(){return this.parent&&this.parent.parent}}T.blotName="table-row",T.tagName="TR";class H extends v{}H.blotName="table-body",H.tagName="TBODY";class M extends w{static create(e){let t=super.create(e);return y.forEach(o=>{t.setAttribute("".concat(o),e[o]||x[o])}),t}static formats(e){return y.reduce((t,o)=>(e.hasAttribute("".concat(o))&&(t[o]=e.getAttribute("".concat(o))||void 0),t),{})}format(e,t){y.indexOf(e)>-1?this.domNode.setAttribute("".concat(e),t||x[e]):super.format(e,t)}html(){return this.domNode.outerHTML}}M.blotName="table-col",M.tagName="col";class B extends v{}B.blotName="table-col-group",B.tagName="colgroup";class O extends v{static create(){return super.create()}constructor(e,t){super(e,t),this.updateTableWidth()}updateTableWidth(){setTimeout(()=>{const e=this.colGroup();if(!e)return;const t=e.children.reduce((e,t)=>e+=parseInt(t.formats()[M.blotName].width,10),0);this.domNode.style.width="".concat(t,"px")},0)}cells(e){return this.rows().map(t=>t.children.at(e))}colGroup(){return this.children.head}deleteColumns(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[],o=arguments.length>2?arguments[2]:void 0;const[n]=this.descendants(H);if(null==n||null==n.children.head)return;const r=this.descendants(S),i=[],s=[];if(r.forEach(t=>{const n=l(t.domNode.getBoundingClientRect(),o);n.x+A>e.x&&n.x1-Ae.x1-A&&s.push(t)}),i.length===r.length)return this.tableDestroy(),!0;t.forEach(e=>{this.colGroup().children.at(t[0]).remove()}),i.forEach(e=>{e.remove()}),s.forEach(e=>{const o=parseInt(e.formats().colspan,10);parseInt(e.formats().width,10);e.format("colspan",o-t.length)}),this.updateTableWidth()}deleteRow(e,t){const[o]=this.descendants(H);if(null==o||null==o.children.head)return;const n=this.descendants(S),r=[],i=[],s=[];if(n.forEach(o=>{const n=l(o.domNode.getBoundingClientRect(),t);n.y>e.y-A&&n.y1e.y1-A&&(i.push(o),Math.abs(n.y-e.y){let r=l(n.domNode.getBoundingClientRect(),t);return r.y>e.y-A&&r.y1{const o=l(e.domNode.getBoundingClientRect(),t),n=e.parent.next,r=n.children.reduce((e,n)=>{const r=l(n.domNode.getBoundingClientRect(),t);return Math.abs(o.x1-r.x){e.remove()}),i.forEach(e=>{const t=parseInt(e.formats().rowspan,10);e.format("rowspan",t-a)})}tableDestroy(){const e=r.a.find(this.scroll.domNode.parentNode),t=e.getModule("better-table");this.remove(),t.hideTableTools(),e.update(r.a.sources.USER)}insertCell(e,t){const o=z(),n=e.formats().row,r=this.scroll.create(S.blotName,Object.assign({},q,{row:n})),i=this.scroll.create(E.blotName,{row:n,cell:o});r.appendChild(i),t?e.insertBefore(r,t):e.appendChild(r)}insertColumn(e,t){let o=!(arguments.length>2&&void 0!==arguments[2])||arguments[2],n=arguments.length>3?arguments[3]:void 0;const[r]=this.descendants(H),[i]=this.descendants(B),s=this.descendants(M);let a=[],c=[],d=[];if(null==r||null==r.children.head)return;this.descendants(S).forEach(t=>{const r=l(t.domNode.getBoundingClientRect(),n);o?Math.abs(r.x1-e.x1)A&&e.x1-r.x1<-A&&c.push(t):Math.abs(r.x-e.x)A&&e.x-r.x1<-A&&c.push(t)}),a.forEach(e=>{const t=o?e.next:e,n=z(),r=e.parent,i=r.formats().row,l=e.formats(),s=this.scroll.create(S.blotName,Object.assign({},q,{row:i,rowspan:l.rowspan})),a=this.scroll.create(E.blotName,{row:i,cell:n,rowspan:l.rowspan});s.appendChild(a),t?r.insertBefore(s,t):r.appendChild(s),d.push(s)});const h=this.scroll.create(M.blotName,!0);let u=o?s[t].next:s[t];return u?i.insertBefore(h,u):i.appendChild(h),c.forEach(e=>{const t=e.formats().colspan;e.format("colspan",parseInt(t,10)+1),d.push(e)}),d.sort((e,t)=>{return e.domNode.getBoundingClientRect().y-t.domNode.getBoundingClientRect().y}),this.updateTableWidth(),d}insertRow(e,t,o){const[n]=this.descendants(H);if(null==n||null==n.children.head)return;const r=this.descendants(S),i=R(),s=this.scroll.create(T.blotName,{row:i});let a=[],c=[],d=[];r.forEach(n=>{const r=l(n.domNode.getBoundingClientRect(),o);t?Math.abs(r.y1-e.y1)A&&e.y1-r.y1<-A&&c.push(n):Math.abs(r.y-e.y)A&&e.y-r.y1<-A&&c.push(n)});const h=(e,t)=>{return e.domNode.getBoundingClientRect().x-t.domNode.getBoundingClientRect().x};a.sort(h),a.forEach(e=>{const t=z(),o=e.formats(),n=this.scroll.create(S.blotName,Object.assign({},q,{row:i,colspan:o.colspan})),r=this.scroll.create(E.blotName,{row:i,cell:t,colspan:o.colspan}),l=this.scroll.create(g.blotName);r.appendChild(l),n.appendChild(r),s.appendChild(n),d.push(n)}),c.forEach(e=>{const t=parseInt(e.formats().rowspan,10);e.format("rowspan",t+1),d.push(e)});const u=this.rows().find(n=>{let r=l(n.domNode.getBoundingClientRect(),o);return t?Math.abs(r.y-e.y-e.height)(0!==r?(e&&t.moveChildren(e),t.remove()):(t.format("colspan",n),t.format("rowspan",o),e=t),e),null);let l=i.domNode.getAttribute("data-row"),s=i.children.head.domNode.getAttribute("data-cell");return i.children.forEach(e=>{e.format("cell",s),e.format("row",l),e.format("colspan",n),e.format("rowspan",o)}),i}unmergeCells(e,t){let o={},n=1,r=1;e.forEach(e=>{if(o=e.formats(),n=o.rowspan,(r=o.colspan)>1){let t=e.next,o=e.row();e.format("colspan",1);for(let e=r;e>1;e--)this.insertCell(o,t)}if(n>1){let o=n,i=e.row().next;for(;o>1;){let n=i.children.reduce((o,n)=>{let r=l(e.domNode.getBoundingClientRect(),t),i=l(n.domNode.getBoundingClientRect(),t);return Math.abs(r.x1-i.x)0;e--)this.insertCell(i,n);o-=1,i=i.next}e.format("rowspan",1)}})}rows(){const e=this.children.tail;return null==e?[]:e.children.map(e=>e)}}O.blotName="table-container",O.className="quill-better-table",O.tagName="TABLE";class L extends v{constructor(e,t){super(e,t);const o=r.a.find(e.domNode.parentNode);t.addEventListener("scroll",e=>{const t=o.getModule("better-table");t.columnTool&&(t.columnTool.domNode.scrollLeft=e.target.scrollLeft),t.tableSelection&&t.tableSelection.selectedTds.length>0&&t.tableSelection.repositionHelpLines()},!1)}}function R(){const e=Math.random().toString(36).slice(2,6);return"row-".concat(e)}function z(){const e=Math.random().toString(36).slice(2,6);return"cell-".concat(e)}L.blotName="table-view",L.className="quill-better-table-wrapper",L.tagName="DIV",L.allowedChildren=[O],O.requiredContainer=L,O.allowedChildren=[H,B],H.requiredContainer=O,H.allowedChildren=[T],T.requiredContainer=H,T.allowedChildren=[S],S.requiredContainer=T,S.allowedChildren=[E,b],E.requiredContainer=S,B.allowedChildren=[M],B.requiredContainer=O,M.requiredContainer=B;const k="#0589f3",I=["left","right","top","bottom"],D=2;class j{constructor(e,t,o){if(!e)return null;this.table=e,this.quill=t,this.options=o,this.boundary={},this.selectedTds=[],this.dragging=!1,this.selectingHandler=this.mouseDownHandler.bind(this),this.clearSelectionHanler=this.clearSelection.bind(this),this.helpLinesInitial(),this.quill.root.addEventListener("mousedown",this.selectingHandler,!1),this.quill.on("text-change",this.clearSelectionHanler)}helpLinesInitial(){let e=this.quill.root.parentNode;I.forEach(t=>{this[t]=document.createElement("div"),this[t].classList.add("qlbt-selection-line"),this[t].classList.add("qlbt-selection-line-"+t),i(this[t],{position:"absolute",display:"none","background-color":k}),e.appendChild(this[t])})}mouseDownHandler(e){if(0!==e.button||!e.target.closest(".quill-better-table"))return;this.quill.root.addEventListener("mousemove",r,!1),this.quill.root.addEventListener("mouseup",function e(o){t.quill.root.removeEventListener("mousemove",r,!1);t.quill.root.removeEventListener("mouseup",e,!1);t.dragging=!1},!1);const t=this,o=e.target.closest("td[data-row]"),n=l(o.getBoundingClientRect(),this.quill.root.parentNode);function r(e){if(0!==e.button||!e.target.closest(".quill-better-table"))return;const r=e.target.closest("td[data-row]"),i=l(r.getBoundingClientRect(),t.quill.root.parentNode);t.boundary=V(n,i),t.correctBoundary(),t.selectedTds=t.computeSelectedTds(),t.repositionHelpLines(),o!==r&&t.quill.blur()}this.dragging=!0,this.boundary=V(n,n),this.correctBoundary(),this.selectedTds=this.computeSelectedTds(),this.repositionHelpLines()}correctBoundary(){r.a.find(this.table).descendants(S).forEach(e=>{let{x:t,y:o,width:n,height:r}=l(e.domNode.getBoundingClientRect(),this.quill.root.parentNode);(t+D>=this.boundary.x&&t+D<=this.boundary.x1||t-D+n>=this.boundary.x&&t-D+n<=this.boundary.x1)&&(o+D>=this.boundary.y&&o+D<=this.boundary.y1||o-D+r>=this.boundary.y&&o-D+r<=this.boundary.y1)&&(this.boundary=V(this.boundary,{x:t,y:o,width:n,height:r}))})}computeSelectedTds(){return r.a.find(this.table).descendants(S).reduce((e,t)=>{let{x:o,y:n,width:r,height:i}=l(t.domNode.getBoundingClientRect(),this.quill.root.parentNode);return o+D>=this.boundary.x&&o-D+r<=this.boundary.x1&&n+D>=this.boundary.y&&n-D+i<=this.boundary.y1&&e.push(t),e},[])}repositionHelpLines(){const e=this.table.parentNode.scrollLeft;i(this.left,{display:"block",left:"".concat(this.boundary.x-e-1,"px"),top:"".concat(this.boundary.y,"px"),height:"".concat(this.boundary.height+1,"px"),width:"1px"}),i(this.right,{display:"block",left:"".concat(this.boundary.x1-e,"px"),top:"".concat(this.boundary.y,"px"),height:"".concat(this.boundary.height+1,"px"),width:"1px"}),i(this.top,{display:"block",left:"".concat(this.boundary.x-1-e,"px"),top:"".concat(this.boundary.y,"px"),width:"".concat(this.boundary.width+1,"px"),height:"1px"}),i(this.bottom,{display:"block",left:"".concat(this.boundary.x-1-e,"px"),top:"".concat(this.boundary.y1+1,"px"),width:"".concat(this.boundary.width+1,"px"),height:"1px"})}refreshHelpLinesPosition(){const e=l(this.selectedTds[0].domNode.getBoundingClientRect(),this.quill.root.parentNode),t=l(this.selectedTds[this.selectedTds.length-1].domNode.getBoundingClientRect(),this.quill.root.parentNode);this.boundary=V(e,t),this.repositionHelpLines()}destroy(){return I.forEach(e=>{this[e].remove(),this[e]=null}),this.quill.root.removeEventListener("mousedown",this.selectingHandler,!1),this.quill.off("text-change",this.clearSelectionHanler),null}setSelection(e,t){this.boundary=V(l(e,this.quill.root.parentNode),l(t,this.quill.root.parentNode)),this.correctBoundary(),this.selectedTds=this.computeSelectedTds(),this.repositionHelpLines()}clearSelection(){this.boundary={},this.selectedTds=[],I.forEach(e=>{this[e]&&i(this[e],{display:"none"})})}}function V(e,t){let o=Math.min(e.x,t.x,e.x+e.width-1,t.x+t.width-1),n=Math.max(e.x,t.x,e.x+e.width-1,t.x+t.width-1),r=Math.min(e.y,t.y,e.y+e.height-1,t.y+t.height-1),i=Math.max(e.y,t.y,e.y+e.height-1,t.y+t.height-1);return{x:o,x1:n,y:r,y1:i,width:n-o,height:i-r}}var _=o(1),U=o.n(_),P=o(2),W=o.n(P),G=o(3),X=o.n(G),K=o(4),Y=o.n(K),$=o(5),J=o.n($),Q=o(6),F=o.n(Q),Z=o(7),ee=o.n(Z),te=o(8),oe=o.n(te),ne=o(9),re=o.n(ne);const ie=150,le=200,se=["white","red","yellow","blue"],ae="Background Colors",ce={insertColumnRight:{text:"Insert column right",iconSrc:U.a,handler(){const e=r.a.find(this.table);let t=he(this.columnToolCells,this.boundary,(e,t)=>Math.abs(e.x+e.width-t.x1)<=5,this.quill.root.parentNode);const o=e.insertColumn(this.boundary,t,!0,this.quill.root.parentNode);this.tableColumnTool.updateToolCells(),this.quill.update(r.a.sources.USER),this.quill.setSelection(this.quill.getIndex(o[0]),0,r.a.sources.SILENT),this.tableSelection.setSelection(o[0].domNode.getBoundingClientRect(),o[0].domNode.getBoundingClientRect())}},insertColumnLeft:{text:"Insert column left",iconSrc:W.a,handler(){const e=r.a.find(this.table);let t=he(this.columnToolCells,this.boundary,(e,t)=>Math.abs(e.x-t.x)<=5,this.quill.root.parentNode);const o=e.insertColumn(this.boundary,t,!1,this.quill.root.parentNode);this.tableColumnTool.updateToolCells(),this.quill.update(r.a.sources.USER),this.quill.setSelection(this.quill.getIndex(o[0]),0,r.a.sources.SILENT),this.tableSelection.setSelection(o[0].domNode.getBoundingClientRect(),o[0].domNode.getBoundingClientRect())}},insertRowUp:{text:"Insert row up",iconSrc:X.a,handler(){const e=r.a.find(this.table).insertRow(this.boundary,!1,this.quill.root.parentNode);this.quill.update(r.a.sources.USER),this.quill.setSelection(this.quill.getIndex(e[0]),0,r.a.sources.SILENT),this.tableSelection.setSelection(e[0].domNode.getBoundingClientRect(),e[0].domNode.getBoundingClientRect())}},insertRowDown:{text:"Insert row down",iconSrc:Y.a,handler(){const e=r.a.find(this.table).insertRow(this.boundary,!0,this.quill.root.parentNode);this.quill.update(r.a.sources.USER),this.quill.setSelection(this.quill.getIndex(e[0]),0,r.a.sources.SILENT),this.tableSelection.setSelection(e[0].domNode.getBoundingClientRect(),e[0].domNode.getBoundingClientRect())}},mergeCells:{text:"Merge selected cells",iconSrc:J.a,handler(){const e=r.a.find(this.table),t=e.rows().reduce((e,t)=>{let o=l(t.domNode.getBoundingClientRect(),this.quill.root.parentNode);return o.y>this.boundary.y-5&&o.y+o.height{let o=l(t.getBoundingClientRect(),this.quill.root.parentNode);return o.x>this.boundary.x-5&&o.x+o.width{let s=l(i.getBoundingClientRect(),n);return o(s,t)&&r.push(e.indexOf(i)),r},[])}(this.columnToolCells,this.boundary,(e,t)=>e.x+5>t.x&&e.x+e.width-5-1&&this.domNode.appendChild(r()));function r(){const e=document.createElement("div");return e.classList.add("qlbt-operation-menu-dividing"),e}this.options.color&&!1!==this.options.color&&(this.domNode.appendChild(r()),this.domNode.appendChild(function(e){const t=document.createElement("div");return t.classList.add("qlbt-operation-menu-subtitle"),t.innerText=e,t}(this.colorSubTitle)),this.domNode.appendChild(this.colorsItemCreator(this.cellColors)))}colorsItemCreator(e){const t=this,o=document.createElement("div");return o.classList.add("qlbt-operation-color-picker"),e.forEach(e=>{let n=function(e){const o=document.createElement("div");return o.classList.add("qlbt-operation-color-picker-item"),o.setAttribute("data-color",e),o.style.backgroundColor=e,o.addEventListener("click",function(){const o=t.tableSelection.selectedTds;o&&o.length>0&&o.forEach(t=>{t.format("cell-bg",e)})},!1),o}(e);o.appendChild(n)}),o}menuItemCreator(e){let{text:t,iconSrc:o,handler:n}=e;const r=document.createElement("div");r.classList.add("qlbt-operation-menu-item");const i=document.createElement("span");i.classList.add("qlbt-operation-menu-icon"),i.innerHTML=o;const l=document.createElement("span");return l.classList.add("qlbt-operation-menu-text"),l.innerText=t,r.appendChild(i),r.appendChild(l),r.addEventListener("click",n.bind(this),!1),r}}function he(e,t,o,n){return e.reduce((r,i)=>{let s=l(i.getBoundingClientRect(),n);return o(s,t)&&(r=e.indexOf(i)),r},!1)}const ue=r.a.import("delta");function pe(e,t,o){const n=e.parentNode,r="TABLE"===n.parentNode.tagName?n.parentNode:n.parentNode.parentNode,i=Array.from(r.querySelectorAll("tr")),l=Array.from(n.querySelectorAll("td")),a=i.indexOf(n)+1,c=l.indexOf(e)+1,d=e.getAttribute("colspan")||!1,h=e.getAttribute("rowspan")||!1,u=e.getAttribute("data-cell-bg")||e.style.backgroundColor;return 0===t.length()?t=(new ue).insert("\n",{"table-cell-line":{row:a,cell:c,rowspan:h,colspan:d}}):(t=t.reduce((e,t)=>{if(t.insert&&"string"==typeof t.insert){const o=[];let n=t.insert,r=0;for(let e=0;e{"\n"===o?e.insert("\n",t.attributes):e.insert(o,s(t.attributes,["table","table-cell-line"]))})}else e.insert(t.insert,t.attributes);return e},new ue)).reduce((e,t)=>(t.insert&&"string"==typeof t.insert&&t.insert.startsWith("\n")?e.insert(t.insert,Object.assign({},Object.assign({},{row:a},t.attributes.table),{"table-cell-line":{row:a,cell:c,rowspan:h,colspan:d,"cell-bg":u}},s(t.attributes,["table"]))):t.attributes&&t.attributes.background&&t.attributes.background===function(e){if(/^(rgb|RGB)/.test(e)){for(var t=e.toString().match(/\d+/g),o="#",n=0;n<3;n++)o+=("0"+Number(t[n]).toString(16)).slice(-2);return o}if(/^#([0-9a-fA-f]{3}|[0-9a-fA-f]{6})$/.test(e)){var r=e.replace(/#/,"").split("");if(6===r.length)return e;if(3===r.length){var i="#";for(n=0;n{if(t.insert&&"string"==typeof t.insert){const o=[];let n=t.insert,r=0;for(let e=0;e{"\n"===o?e.insert("\n",{"table-cell-line":{row:a,cell:c,rowspan:h,colspan:d}}):e.insert(o,t.attributes)})}else e.insert(t.insert,t.attributes);return e},new ue)).reduce((e,t)=>(t.insert&&"string"==typeof t.insert&&t.insert.startsWith("\n")?e.insert(t.insert,Object.assign({},{"table-cell-line":{row:a,cell:c,rowspan:h,colspan:d}})):e.insert(t.insert,Object.assign({},s(t.attributes,["table","table-cell-line"]))),e),new ue)}function fe(e,t,o){let n=new ue;const r=e.querySelector("tr");if(null===r)return n;const i=Array.from(r.querySelectorAll("td")).concat(Array.from(r.querySelectorAll("th"))).reduce((e,t)=>{const o=t.getAttribute("colspan")||1;return e+=parseInt(o,10)},0),l=e.querySelectorAll("col").length;if(l===i)return t;{for(let e=0;e(t.insert(o.insert,o.attributes),o.attributes&&o.attributes["table-col"]&&(e+=o.insert.length)===l&&(t=t.concat(n)),t),new ue)}}const be=r.a.import("core/module"),ge=r.a.import("delta");class we extends be{static register(){r.a.register(M,!0),r.a.register(B,!0),r.a.register(E,!0),r.a.register(S,!0),r.a.register(T,!0),r.a.register(H,!0),r.a.register(O,!0),r.a.register(L,!0),r.a.register(L,!0)}constructor(e,t){super(e,t),this.quill.root.addEventListener("click",o=>{const n=a(o);if(!n||n.length<=0)return;const r=n.filter(e=>e.tagName&&"TABLE"===e.tagName.toUpperCase()&&e.classList.contains("quill-better-table"))[0];if(r){if(this.table===r)return;this.table&&this.hideTableTools(),this.showTableTools(r,e,t)}else this.table&&this.hideTableTools()},!1),this.quill.root.addEventListener("contextmenu",o=>{if(!this.table)return!0;o.preventDefault();const n=a(o);if(!n||n.length<=0)return;const r=n.filter(e=>e.tagName&&"TABLE"===e.tagName.toUpperCase()&&e.classList.contains("quill-better-table"))[0],i=n.filter(e=>e.tagName&&"TR"===e.tagName.toUpperCase()&&e.getAttribute("data-row"))[0],l=n.filter(e=>e.tagName&&"TD"===e.tagName.toUpperCase()&&e.getAttribute("data-row"))[0];let s=this.tableSelection.selectedTds.map(e=>e.domNode).includes(l);(this.tableSelection.selectedTds.length<=0||!s)&&this.tableSelection.setSelection(l.getBoundingClientRect(),l.getBoundingClientRect()),this.tableOperationMenu&&(this.tableOperationMenu=this.tableOperationMenu.destroy()),r&&(this.tableOperationMenu=new de({table:r,row:i,cell:l,left:o.pageX,top:o.pageY},e,t.operationMenu))},!1);e.getModule("keyboard");e.keyboard.addBinding({key:"Backspace"},{},function(e,t){if(0===e.index||this.quill.getLength()<=1)return!0;const[o]=this.quill.getLine(e.index);if(0===t.offset){const[t]=this.quill.getLine(e.index-1);if(null!=t&&"table-cell-line"===t.statics.blotName&&"table-cell-line"!==o.statics.blotName)return!1}return!0});let o=e.keyboard.bindings.Backspace.pop();e.keyboard.bindings.Backspace.splice(0,1,o),e.clipboard.addMatcher("td",pe),e.clipboard.addMatcher("th",me),e.clipboard.addMatcher("table",fe),e.clipboard.matchers=e.clipboard.matchers.filter(e=>"tr"!==e[0])}getTable(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.quill.getSelection();if(null==e)return[null,null,null,-1];const[t,o]=this.quill.getLine(e.index);if(null==t||t.statics.blotName!==E.blotName)return[null,null,null,-1];const n=t.tableCell(),r=n.row();return[r.table(),r,n,o]}insertTable(e,t){const o=this.quill.getSelection(!0);if(null==o)return;this.quill.getLeaf(o.index)[0],this.quill.getLeaf(o.index+1)[0];let n=(new ge).retain(o.index);n.insert("\n"),n=new Array(t).fill("\n").reduce((e,t)=>(e.insert(t,{"table-col":!0}),e),n),n=new Array(e).fill(0).reduce(e=>{let o=R();return new Array(t).fill("\n").reduce((e,t)=>(e.insert(t,{"table-cell-line":{row:o,cell:z()}}),e),e)},n),this.quill.updateContents(n,r.a.sources.USER),this.quill.setSelection(o.index+t+1,r.a.sources.API)}showTableTools(e,t,o){this.table=e,this.columnTool=new p(e,t,o),this.tableSelection=new j(e,t,o)}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}}we.keyboardBindings={"table-cell-line backspace":{key:"Backspace",format:["table-cell-line"],collapsed:!0,offset:0,handler(e,t){const[o,n]=this.quill.getLine(e.index);return!(!o.prev||"table-cell-line"!==o.prev.statics.blotName)}},"table-cell-line delete":{key:"Delete",format:["table-cell-line"],collapsed:!0,suffix:/^$/,handler(){}},"table-cell-line enter":{key:"Enter",shiftKey:null,format:["table-cell-line"],handler(e,t){if(this.quill.selection&&this.quill.selection.composing)return;const o=r.a.imports.parchment.Scope;e.length>0&&this.quill.scroll.deleteAt(e.index,e.length);const n=Object.keys(t.format).reduce((e,n)=>(this.quill.scroll.query(n,o.BLOCK)&&!Array.isArray(t.format[n])&&(e[n]=t.format[n]),e),{});this.quill.insertText(e.index,"\n",n["table-cell-line"],r.a.sources.USER),this.quill.setSelection(e.index+1,r.a.sources.SILENT),this.quill.focus(),Object.keys(t.format).forEach(e=>{null==n[e]&&(Array.isArray(t.format[e])||"link"!==e&&this.quill.format(e,t.format[e],r.a.sources.USER))})}}};t.default=we}]).default}); \ No newline at end of file +!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("quill")):"function"==typeof define&&define.amd?define(["quill"],t):"object"==typeof exports?exports.quillBetterTable=t(require("quill")):e.quillBetterTable=t(e.Quill)}(window,function(e){return function(e){var t=window.webpackHotUpdatequillBetterTable;window.webpackHotUpdatequillBetterTable=function(e,o){!function(e,t){if(!x[e]||!y[e])return;for(var o in y[e]=!1,t)Object.prototype.hasOwnProperty.call(t,o)&&(f[o]=t[o]);0==--g&&0===w&&A()}(e,o),t&&t(e,o)};var o,n=!0,r="9cc154495856e09fb035",i=1e4,l={},s=[],a=[];function c(e){var t=S[e];if(!t)return T;var n=function(n){return t.hot.active?(S[n]?-1===S[n].parents.indexOf(e)&&S[n].parents.push(e):(s=[e],o=n),-1===t.children.indexOf(n)&&t.children.push(n)):(console.warn("[HMR] unexpected require("+n+") from disposed module "+e),s=[]),T(n)},r=function(e){return{configurable:!0,enumerable:!0,get:function(){return T[e]},set:function(t){T[e]=t}}};for(var i in T)Object.prototype.hasOwnProperty.call(T,i)&&"e"!==i&&"t"!==i&&Object.defineProperty(n,i,r(i));return n.e=function(e){return"ready"===u&&p("prepare"),w++,T.e(e).then(t,function(e){throw t(),e});function t(){w--,"prepare"===u&&(v[e]||q(e),0===w&&0===g&&A())}},n.t=function(e,t){return 1&t&&(e=n(e)),T.t(e,-2&t)},n}function d(e){var t={_acceptedDependencies:{},_declinedDependencies:{},_selfAccepted:!1,_selfDeclined:!1,_disposeHandlers:[],_main:o!==e,active:!0,accept:function(e,o){if(void 0===e)t._selfAccepted=!0;else if("function"==typeof e)t._selfAccepted=e;else if("object"==typeof e)for(var n=0;n=0&&t._disposeHandlers.splice(o,1)},check:C,apply:E,status:function(e){if(!e)return u;h.push(e)},addStatusHandler:function(e){h.push(e)},removeStatusHandler:function(e){var t=h.indexOf(e);t>=0&&h.splice(t,1)},data:l[e]};return o=void 0,t}var h=[],u="idle";function p(e){u=e;for(var t=0;t0;){var r=n.pop(),i=r.id,l=r.chain;if((a=S[i])&&!a.hot._selfAccepted){if(a.hot._selfDeclined)return{type:"self-declined",chain:l,moduleId:i};if(a.hot._main)return{type:"unaccepted",chain:l,moduleId:i};for(var s=0;s ")),C.type){case"self-declined":t.onDeclined&&t.onDeclined(C),t.ignoreDeclined||(q=new Error("Aborted because of self decline: "+C.moduleId+H));break;case"declined":t.onDeclined&&t.onDeclined(C),t.ignoreDeclined||(q=new Error("Aborted because of declined dependency: "+C.moduleId+" in "+C.parentId+H));break;case"unaccepted":t.onUnaccepted&&t.onUnaccepted(C),t.ignoreUnaccepted||(q=new Error("Aborted because "+c+" is not accepted"+H));break;case"accepted":t.onAccepted&&t.onAccepted(C),A=!0;break;case"disposed":t.onDisposed&&t.onDisposed(C),E=!0;break;default:throw new Error("Unexception type "+C.type)}if(q)return p("abort"),Promise.reject(q);if(A)for(c in w[c]=f[c],h(g,C.outdatedModules),C.outdatedDependencies)Object.prototype.hasOwnProperty.call(C.outdatedDependencies,c)&&(m[c]||(m[c]=[]),h(m[c],C.outdatedDependencies[c]));E&&(h(g,[C.moduleId]),w[c]=v)}var M,B=[];for(n=0;n0;)if(c=R.pop(),a=S[c]){var z={},k=a.hot._disposeHandlers;for(i=0;i=0&&I.parents.splice(M,1))}}for(c in m)if(Object.prototype.hasOwnProperty.call(m,c)&&(a=S[c]))for(L=m[c],i=0;i=0&&a.children.splice(M,1);for(c in p("apply"),r=b,w)Object.prototype.hasOwnProperty.call(w,c)&&(e[c]=w[c]);var D=null;for(c in m)if(Object.prototype.hasOwnProperty.call(m,c)&&(a=S[c])){L=m[c];var j=[];for(n=0;n'},function(e,t){e.exports=''},function(e,t){e.exports=''},function(e,t){e.exports=''},function(e,t){e.exports=''},function(e,t){e.exports=''},function(e,t){e.exports=''},function(e,t){e.exports=''},function(e,t){e.exports=''},function(e,t,o){e.exports=o(11)},function(e,t,o){"use strict";o.r(t);var n=o(0),r=o.n(n);function i(e,t){if("object"==typeof t)for(let o in t)e.style[o]=t[o]}function l(e,t){let o=t.getBoundingClientRect();return{x:e.x-o.x-t.scrollLeft,y:e.y-o.y-t.scrollTop,x1:e.x-o.x-t.scrollLeft+e.width,y1:e.y-o.y-t.scrollTop+e.height,width:e.width,height:e.height}}function s(e,t){return e&&Object.keys(e).reduce((o,n)=>t.includes(n)?o:Object.assign({},o,{[n]:e[n]}),{})}function a(e){let t;if(null==(t=e.path||e.composedPath&&e.composedPath())&&e.target){t=[];let o=e.target;for(t.push(o);o&&o.parentNode;)o=o.parentNode,t.push(o)}return t}const c=12,d=12,h=50,u="#35A7ED";class p{constructor(e,t,o){if(!e)return null;this.table=e,this.quill=t,this.options=o,this.domNode=null,this.initColTool()}initColTool(){const e=this.quill.root.parentNode,t=(this.table.getBoundingClientRect(),e.getBoundingClientRect()),o=this.table.parentNode.getBoundingClientRect();this.domNode=document.createElement("div"),this.domNode.classList.add("qlbt-col-tool"),this.updateToolCells(),e.appendChild(this.domNode),i(this.domNode,{width:"".concat(o.width,"px"),height:"".concat(c,"px"),left:"".concat(o.left-t.left+e.scrollLeft,"px"),top:"".concat(o.top-t.top+e.scrollTop-c-5,"px")})}createToolCell(){const e=document.createElement("div");e.classList.add("qlbt-col-tool-cell");const t=document.createElement("div");return t.classList.add("qlbt-col-tool-cell-holder"),i(e,{height:"".concat(d,"px")}),e.appendChild(t),e}updateToolCells(){const e=r.a.find(this.table),t=e.children.tail.children.head.children,o=e.colGroup().children,n=function(e){return e.reduce((e,t)=>{const o=t.formats().colspan;return e+=parseInt(o,10)},0)}(t);let l=Array.from(this.domNode.querySelectorAll(".qlbt-col-tool-cell"));for(let e=0;e=n?l[e].remove():i(s=l[e],{"min-width":"".concat(r,"px")}):(s=this.createToolCell(),this.domNode.appendChild(s),this.addColCellHolderHandler(s),i(s,{"min-width":"".concat(r,"px")}))}}destroy(){return this.domNode.remove(),null}addColCellHolderHandler(e){const t=r.a.find(this.table),o=e.querySelector(".qlbt-col-tool-cell-holder");let n=!1,l=0,s=0,a=0,d=0,p={},m={},f=null;const b=e=>{e.preventDefault(),n&&(s=e.clientX,a=d+s-l>=h?s-l:h-d,i(f,{left:"".concat(m.left+m.width-1+a,"px")}))},g=r=>{r.preventDefault();const c=Array.from(this.domNode.querySelectorAll(".qlbt-col-tool-cell")).indexOf(e),h=t.colGroup().children.at(c);n&&(h.format("width",d+a),i(e,{"min-width":"".concat(d+a,"px")}),l=0,s=0,a=0,d=0,n=!1,o.classList.remove("dragging")),document.removeEventListener("mousemove",b,!1),document.removeEventListener("mouseup",g,!1),p={},m={},f.remove(),f=null,t.updateTableWidth();const u=this.quill.getModule("better-table").tableSelection;u&&u.clearSelection()};o.addEventListener("mousedown",t=>{document.addEventListener("mousemove",b,!1),document.addEventListener("mouseup",g,!1),p=this.table.getBoundingClientRect(),m=e.getBoundingClientRect(),i(f=document.createElement("div"),{position:"fixed",top:"".concat(m.top,"px"),left:"".concat(m.left+m.width-1,"px"),zIndex:"100",height:"".concat(p.height+c+4,"px"),width:"1px",backgroundColor:u}),document.body.appendChild(f),n=!0,l=t.clientX,d=m.width,o.classList.add("dragging")},!1)}colToolCells(){return Array.from(this.domNode.querySelectorAll(".qlbt-col-tool-cell"))}}const m=r.a.import("blots/block");class f extends m{static create(e){"string"==typeof e&&(e={value:e});const t=super.create(e.value);return N.forEach(o=>{e[o]&&t.setAttribute("data-".concat(o),e[o])}),C.forEach(o=>{e[o]&&t.setAttribute("data-".concat(o),e[o])}),t}static formats(e){const t={};return t.value=this.tagName.indexOf(e.tagName)+1,C.concat(N).reduce((t,o)=>(e.hasAttribute("data-".concat(o))&&(t[o]=e.getAttribute("data-".concat(o))||void 0),t),t)}format(e,t){const{row:o,cell:n,rowspan:r,colspan:i}=f.formats(this.domNode);e===f.blotName?t?super.format(e,{value:t,row:o,cell:n,rowspan:r,colspan:i}):o?this.replaceWith(E.blotName,{row:o,cell:n,rowspan:r,colspan:i}):super.format(e,t):super.format(e,t)}optimize(e){const{row:t,rowspan:o,colspan:n}=f.formats(this.domNode);if(!t||this.parent instanceof S||this.wrap(S.blotName,{row:t,colspan:n,rowspan:o}),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 e=this.scroll.create(this.statics.defaultChild.blotName);this.appendChild(e)}else this.remove();this.cache={}}}f.blotName="header",f.tagName=["H1","H2","H3","H4","H5","H6"];var b=f;const g=r.a.import("blots/break"),w=r.a.import("blots/block"),v=r.a.import("blots/container"),y=["width"],x={width:100},N=["row","cell"],C=["rowspan","colspan"],q={rowspan:1,colspan:1},A=5;class E extends w{static create(e){const t=super.create(e);return N.forEach(o=>{let n="row"===o?R:z;t.setAttribute("data-".concat(o),e[o]||n())}),C.forEach(o=>{t.setAttribute("data-".concat(o),e[o]||q[o])}),e["cell-bg"]&&t.setAttribute("data-cell-bg",e["cell-bg"]),t}static formats(e){return C.concat(N).concat(["cell-bg"]).reduce((t,o)=>(e.hasAttribute("data-".concat(o))&&(t[o]=e.getAttribute("data-".concat(o))||void 0),t),{})}format(e,t){if(C.concat(N).indexOf(e)>-1)t?this.domNode.setAttribute("data-".concat(e),t):this.domNode.removeAttribute("data-".concat(e));else if("cell-bg"===e)t?this.domNode.setAttribute("data-cell-bg",t):this.domNode.removeAttribute("data-cell-bg");else if("header"===e){if(!t)return;const{row:o,cell:n,rowspan:r,colspan:i}=E.formats(this.domNode);super.format(e,{value:t,row:o,cell:n,rowspan:r,colspan:i})}else super.format(e,t)}optimize(e){const t=this.domNode.getAttribute("data-row"),o=this.domNode.getAttribute("data-rowspan"),n=this.domNode.getAttribute("data-colspan"),r=this.domNode.getAttribute("data-cell-bg");!this.statics.requiredContainer||this.parent instanceof this.statics.requiredContainer||this.wrap(this.statics.requiredContainer.blotName,{row:t,colspan:n,rowspan:o,"cell-bg":r}),super.optimize(e)}tableCell(){return this.parent}}E.blotName="table-cell-line",E.ClassName="qlbt-cell-line",E.tagName="DIV";class S extends v{checkMerge(){if(super.checkMerge()&&null!=this.next.children.head){const e=this.children.head.formats()[this.children.head.statics.blotName],t=this.children.tail.formats()[this.children.tail.statics.blotName],o=this.next.children.head.formats()[this.next.children.head.statics.blotName],n=this.next.children.tail.formats()[this.next.children.tail.statics.blotName];return e.cell===t.cell&&e.cell===o.cell&&e.cell===n.cell}return!1}static create(e){const t=super.create(e);return t.setAttribute("data-row",e.row),C.forEach(o=>{e[o]&&t.setAttribute(o,e[o])}),e["cell-bg"]&&(t.setAttribute("data-cell-bg",e["cell-bg"]),t.style.backgroundColor=e["cell-bg"]),t}static formats(e){const t={};return e.hasAttribute("data-row")&&(t.row=e.getAttribute("data-row")),e.hasAttribute("data-cell-bg")&&(t["cell-bg"]=e.getAttribute("data-cell-bg")),C.reduce((t,o)=>(e.hasAttribute(o)&&(t[o]=e.getAttribute(o)),t),t)}cellOffset(){return this.parent?this.parent.children.indexOf(this):-1}formats(){const e={};return this.domNode.hasAttribute("data-row")&&(e.row=this.domNode.getAttribute("data-row")),this.domNode.hasAttribute("data-cell-bg")&&(e["cell-bg"]=this.domNode.getAttribute("data-cell-bg")),C.reduce((e,t)=>(this.domNode.hasAttribute(t)&&(e[t]=this.domNode.getAttribute(t)),e),e)}toggleAttribute(e,t){t?this.domNode.setAttribute(e,t):this.domNode.removeAttribute(e)}formatChildren(e,t){this.children.forEach(o=>{o.format(e,t)})}format(e,t){C.indexOf(e)>-1?(this.toggleAttribute(e,t),this.formatChildren(e,t)):["row"].indexOf(e)>-1?(this.toggleAttribute("data-".concat(e),t),this.formatChildren(e,t)):"cell-bg"===e?(this.toggleAttribute("data-cell-bg",t),this.formatChildren(e,t),this.domNode.style.backgroundColor=t||"initial"):super.format(e,t)}optimize(e){const t=this.domNode.getAttribute("data-row");!this.statics.requiredContainer||this.parent instanceof this.statics.requiredContainer||this.wrap(this.statics.requiredContainer.blotName,{row:t}),super.optimize(e)}row(){return this.parent}rowOffset(){return this.row()?this.row().rowOffset():-1}table(){return this.row()&&this.row().table()}}S.blotName="table",S.tagName="TD";class T extends v{checkMerge(){if(super.checkMerge()&&null!=this.next.children.head){const e=this.children.head.formats(),t=this.children.tail.formats(),o=this.next.children.head.formats(),n=this.next.children.tail.formats();return e.row===t.row&&e.row===o.row&&e.row===n.row}return!1}static create(e){const t=super.create(e);return t.setAttribute("data-row",e.row),t}formats(){return["row"].reduce((e,t)=>(this.domNode.hasAttribute("data-".concat(t))&&(e[t]=this.domNode.getAttribute("data-".concat(t))),e),{})}optimize(e){!this.statics.requiredContainer||this.parent instanceof this.statics.requiredContainer||this.wrap(this.statics.requiredContainer.blotName),this.enforceAllowedChildren(),null!=this.uiNode&&this.uiNode!==this.domNode.firstChild&&this.domNode.insertBefore(this.uiNode,this.domNode.firstChild),this.children.length>0&&null!=this.next&&this.checkMerge()&&(this.next.moveChildren(this),this.next.remove())}rowOffset(){return this.parent?this.parent.children.indexOf(this):-1}table(){return this.parent&&this.parent.parent}}T.blotName="table-row",T.tagName="TR";class H extends v{}H.blotName="table-body",H.tagName="TBODY";class M extends w{static create(e){let t=super.create(e);return y.forEach(o=>{t.setAttribute("".concat(o),e[o]||x[o])}),t}static formats(e){return y.reduce((t,o)=>(e.hasAttribute("".concat(o))&&(t[o]=e.getAttribute("".concat(o))||void 0),t),{})}format(e,t){y.indexOf(e)>-1?this.domNode.setAttribute("".concat(e),t||x[e]):super.format(e,t)}html(){return this.domNode.outerHTML}}M.blotName="table-col",M.tagName="col";class B extends v{}B.blotName="table-col-group",B.tagName="colgroup";class O extends v{static create(){return super.create()}constructor(e,t){super(e,t),this.updateTableWidth()}updateTableWidth(){setTimeout(()=>{const e=this.colGroup();if(!e)return;const t=e.children.reduce((e,t)=>e+=parseInt(t.formats()[M.blotName].width,10),0);this.domNode.style.width="".concat(t,"px")},0)}cells(e){return this.rows().map(t=>t.children.at(e))}colGroup(){return this.children.head}deleteColumns(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[],o=arguments.length>2?arguments[2]:void 0;const[n]=this.descendants(H);if(null==n||null==n.children.head)return;const r=this.descendants(S),i=[],s=[];if(r.forEach(t=>{const n=l(t.domNode.getBoundingClientRect(),o);n.x+A>e.x&&n.x1-Ae.x1-A&&s.push(t)}),i.length===r.length)return this.tableDestroy(),!0;t.forEach(e=>{this.colGroup().children.at(t[0]).remove()}),i.forEach(e=>{e.remove()}),s.forEach(e=>{const o=parseInt(e.formats().colspan,10);parseInt(e.formats().width,10);e.format("colspan",o-t.length)}),this.updateTableWidth()}deleteRow(e,t){const[o]=this.descendants(H);if(null==o||null==o.children.head)return;const n=this.descendants(S),r=this.descendants(T),i=[],s=[],a=[],c=r.filter(o=>{const n=l(o.domNode.getBoundingClientRect(),t);return n.y>e.y-A&&n.y1{const n=l(o.domNode.getBoundingClientRect(),t);n.y>e.y-A&&n.y1e.y1-A&&(s.push(o),Math.abs(n.y-e.y){let r=l(n.domNode.getBoundingClientRect(),t);return r.y>e.y-A&&r.y1{const o=l(e.domNode.getBoundingClientRect(),t),n=e.parent.next,r=n.children.reduce((e,n)=>{const r=l(n.domNode.getBoundingClientRect(),t);return Math.abs(o.x1-r.x){e.remove()}),s.forEach(e=>{const t=parseInt(e.formats().rowspan,10);e.format("rowspan",t-d)}),c.forEach(e=>e.remove())}tableDestroy(){const e=r.a.find(this.scroll.domNode.parentNode),t=e.getModule("better-table");this.remove(),t.hideTableTools(),e.update(r.a.sources.USER)}insertCell(e,t){const o=z(),n=e.formats().row,r=this.scroll.create(S.blotName,Object.assign({},q,{row:n})),i=this.scroll.create(E.blotName,{row:n,cell:o});r.appendChild(i),t?e.insertBefore(r,t):e.appendChild(r)}insertColumn(e,t){let o=!(arguments.length>2&&void 0!==arguments[2])||arguments[2],n=arguments.length>3?arguments[3]:void 0;const[r]=this.descendants(H),[i]=this.descendants(B),s=this.descendants(M);let a=[],c=[],d=[];if(null==r||null==r.children.head)return;this.descendants(S).forEach(t=>{const r=l(t.domNode.getBoundingClientRect(),n);o?Math.abs(r.x1-e.x1)A&&e.x1-r.x1<-A&&c.push(t):Math.abs(r.x-e.x)A&&e.x-r.x1<-A&&c.push(t)}),a.forEach(e=>{const t=o?e.next:e,n=z(),r=e.parent,i=r.formats().row,l=e.formats(),s=this.scroll.create(S.blotName,Object.assign({},q,{row:i,rowspan:l.rowspan})),a=this.scroll.create(E.blotName,{row:i,cell:n,rowspan:l.rowspan});s.appendChild(a),t?r.insertBefore(s,t):r.appendChild(s),d.push(s)});const h=this.scroll.create(M.blotName,!0);let u=o?s[t].next:s[t];return u?i.insertBefore(h,u):i.appendChild(h),c.forEach(e=>{const t=e.formats().colspan;e.format("colspan",parseInt(t,10)+1),d.push(e)}),d.sort((e,t)=>{return e.domNode.getBoundingClientRect().y-t.domNode.getBoundingClientRect().y}),this.updateTableWidth(),d}insertRow(e,t,o){const[n]=this.descendants(H);if(null==n||null==n.children.head)return;const r=this.descendants(S),i=R(),s=this.scroll.create(T.blotName,{row:i});let a=[],c=[],d=[];r.forEach(n=>{const r=l(n.domNode.getBoundingClientRect(),o);t?Math.abs(r.y1-e.y1)A&&e.y1-r.y1<-A&&c.push(n):Math.abs(r.y-e.y)A&&e.y-r.y1<-A&&c.push(n)});const h=(e,t)=>{return e.domNode.getBoundingClientRect().x-t.domNode.getBoundingClientRect().x};a.sort(h),a.forEach(e=>{const t=z(),o=e.formats(),n=this.scroll.create(S.blotName,Object.assign({},q,{row:i,colspan:o.colspan})),r=this.scroll.create(E.blotName,{row:i,cell:t,colspan:o.colspan}),l=this.scroll.create(g.blotName);r.appendChild(l),n.appendChild(r),s.appendChild(n),d.push(n)}),c.forEach(e=>{const t=parseInt(e.formats().rowspan,10);e.format("rowspan",t+1),d.push(e)});const u=this.rows().find(n=>{let r=l(n.domNode.getBoundingClientRect(),o);return t?Math.abs(r.y-e.y-e.height)(0!==r?(e&&t.moveChildren(e),t.remove()):(t.format("colspan",n),t.format("rowspan",o),e=t),e),null);let l=i.domNode.getAttribute("data-row"),s=i.children.head.domNode.getAttribute("data-cell");return i.children.forEach(e=>{e.format("cell",s),e.format("row",l),e.format("colspan",n),e.format("rowspan",o)}),i}unmergeCells(e,t){let o={},n=1,r=1;e.forEach(e=>{if(o=e.formats(),n=o.rowspan,(r=o.colspan)>1){let t=e.next,o=e.row();e.format("colspan",1);for(let e=r;e>1;e--)this.insertCell(o,t)}if(n>1){let o=n,i=e.row().next;for(;o>1;){let n=i.children.reduce((o,n)=>{let r=l(e.domNode.getBoundingClientRect(),t),i=l(n.domNode.getBoundingClientRect(),t);return Math.abs(r.x1-i.x)0;e--)this.insertCell(i,n);o-=1,i=i.next}e.format("rowspan",1)}})}rows(){const e=this.children.tail;return null==e?[]:e.children.map(e=>e)}}O.blotName="table-container",O.className="quill-better-table",O.tagName="TABLE";class L extends v{constructor(e,t){super(e,t);const o=r.a.find(e.domNode.parentNode);t.addEventListener("scroll",e=>{const t=o.getModule("better-table");t.columnTool&&(t.columnTool.domNode.scrollLeft=e.target.scrollLeft),t.tableSelection&&t.tableSelection.selectedTds.length>0&&t.tableSelection.repositionHelpLines()},!1)}}function R(){const e=Math.random().toString(36).slice(2,6);return"row-".concat(e)}function z(){const e=Math.random().toString(36).slice(2,6);return"cell-".concat(e)}L.blotName="table-view",L.className="quill-better-table-wrapper",L.tagName="DIV",L.allowedChildren=[O],O.requiredContainer=L,O.allowedChildren=[H,B],H.requiredContainer=O,H.allowedChildren=[T],T.requiredContainer=H,T.allowedChildren=[S],S.requiredContainer=T,S.allowedChildren=[E,b],E.requiredContainer=S,B.allowedChildren=[M],B.requiredContainer=O,M.requiredContainer=B;const k="#0589f3",I=["left","right","top","bottom"],D=2;class j{constructor(e,t,o){if(!e)return null;this.table=e,this.quill=t,this.options=o,this.boundary={},this.selectedTds=[],this.dragging=!1,this.selectingHandler=this.mouseDownHandler.bind(this),this.clearSelectionHanler=this.clearSelection.bind(this),this.helpLinesInitial(),this.quill.root.addEventListener("mousedown",this.selectingHandler,!1),this.quill.on("text-change",this.clearSelectionHanler)}helpLinesInitial(){let e=this.quill.root.parentNode;I.forEach(t=>{this[t]=document.createElement("div"),this[t].classList.add("qlbt-selection-line"),this[t].classList.add("qlbt-selection-line-"+t),i(this[t],{position:"absolute",display:"none","background-color":k}),e.appendChild(this[t])})}mouseDownHandler(e){if(0!==e.button||!e.target.closest(".quill-better-table"))return;this.quill.root.addEventListener("mousemove",r,!1),this.quill.root.addEventListener("mouseup",function e(o){t.quill.root.removeEventListener("mousemove",r,!1);t.quill.root.removeEventListener("mouseup",e,!1);t.dragging=!1},!1);const t=this,o=e.target.closest("td[data-row]"),n=l(o.getBoundingClientRect(),this.quill.root.parentNode);function r(e){if(0!==e.button||!e.target.closest(".quill-better-table"))return;const r=e.target.closest("td[data-row]"),i=l(r.getBoundingClientRect(),t.quill.root.parentNode);t.boundary=V(n,i),t.correctBoundary(),t.selectedTds=t.computeSelectedTds(),t.repositionHelpLines(),o!==r&&t.quill.blur()}this.dragging=!0,this.boundary=V(n,n),this.correctBoundary(),this.selectedTds=this.computeSelectedTds(),this.repositionHelpLines()}correctBoundary(){r.a.find(this.table).descendants(S).forEach(e=>{let{x:t,y:o,width:n,height:r}=l(e.domNode.getBoundingClientRect(),this.quill.root.parentNode);(t+D>=this.boundary.x&&t+D<=this.boundary.x1||t-D+n>=this.boundary.x&&t-D+n<=this.boundary.x1)&&(o+D>=this.boundary.y&&o+D<=this.boundary.y1||o-D+r>=this.boundary.y&&o-D+r<=this.boundary.y1)&&(this.boundary=V(this.boundary,{x:t,y:o,width:n,height:r}))})}computeSelectedTds(){return r.a.find(this.table).descendants(S).reduce((e,t)=>{let{x:o,y:n,width:r,height:i}=l(t.domNode.getBoundingClientRect(),this.quill.root.parentNode);return o+D>=this.boundary.x&&o-D+r<=this.boundary.x1&&n+D>=this.boundary.y&&n-D+i<=this.boundary.y1&&e.push(t),e},[])}repositionHelpLines(){const e=this.table.parentNode.scrollLeft;i(this.left,{display:"block",left:"".concat(this.boundary.x-e-1,"px"),top:"".concat(this.boundary.y,"px"),height:"".concat(this.boundary.height+1,"px"),width:"1px"}),i(this.right,{display:"block",left:"".concat(this.boundary.x1-e,"px"),top:"".concat(this.boundary.y,"px"),height:"".concat(this.boundary.height+1,"px"),width:"1px"}),i(this.top,{display:"block",left:"".concat(this.boundary.x-1-e,"px"),top:"".concat(this.boundary.y,"px"),width:"".concat(this.boundary.width+1,"px"),height:"1px"}),i(this.bottom,{display:"block",left:"".concat(this.boundary.x-1-e,"px"),top:"".concat(this.boundary.y1+1,"px"),width:"".concat(this.boundary.width+1,"px"),height:"1px"})}refreshHelpLinesPosition(){const e=l(this.selectedTds[0].domNode.getBoundingClientRect(),this.quill.root.parentNode),t=l(this.selectedTds[this.selectedTds.length-1].domNode.getBoundingClientRect(),this.quill.root.parentNode);this.boundary=V(e,t),this.repositionHelpLines()}destroy(){return I.forEach(e=>{this[e].remove(),this[e]=null}),this.quill.root.removeEventListener("mousedown",this.selectingHandler,!1),this.quill.off("text-change",this.clearSelectionHanler),null}setSelection(e,t){this.boundary=V(l(e,this.quill.root.parentNode),l(t,this.quill.root.parentNode)),this.correctBoundary(),this.selectedTds=this.computeSelectedTds(),this.repositionHelpLines()}clearSelection(){this.boundary={},this.selectedTds=[],I.forEach(e=>{this[e]&&i(this[e],{display:"none"})})}}function V(e,t){let o=Math.min(e.x,t.x,e.x+e.width-1,t.x+t.width-1),n=Math.max(e.x,t.x,e.x+e.width-1,t.x+t.width-1),r=Math.min(e.y,t.y,e.y+e.height-1,t.y+t.height-1),i=Math.max(e.y,t.y,e.y+e.height-1,t.y+t.height-1);return{x:o,x1:n,y:r,y1:i,width:n-o,height:i-r}}var _=o(1),U=o.n(_),P=o(2),W=o.n(P),G=o(3),X=o.n(G),K=o(4),Y=o.n(K),$=o(5),J=o.n($),Q=o(6),F=o.n(Q),Z=o(7),ee=o.n(Z),te=o(8),oe=o.n(te),ne=o(9),re=o.n(ne);const ie=150,le=200,se=["white","red","yellow","blue"],ae="Background Colors",ce={insertColumnRight:{text:"Insert column right",iconSrc:U.a,handler(){const e=r.a.find(this.table);let t=he(this.columnToolCells,this.boundary,(e,t)=>Math.abs(e.x+e.width-t.x1)<=5,this.quill.root.parentNode);const o=e.insertColumn(this.boundary,t,!0,this.quill.root.parentNode);this.tableColumnTool.updateToolCells(),this.quill.update(r.a.sources.USER),this.quill.setSelection(this.quill.getIndex(o[0]),0,r.a.sources.SILENT),this.tableSelection.setSelection(o[0].domNode.getBoundingClientRect(),o[0].domNode.getBoundingClientRect())}},insertColumnLeft:{text:"Insert column left",iconSrc:W.a,handler(){const e=r.a.find(this.table);let t=he(this.columnToolCells,this.boundary,(e,t)=>Math.abs(e.x-t.x)<=5,this.quill.root.parentNode);const o=e.insertColumn(this.boundary,t,!1,this.quill.root.parentNode);this.tableColumnTool.updateToolCells(),this.quill.update(r.a.sources.USER),this.quill.setSelection(this.quill.getIndex(o[0]),0,r.a.sources.SILENT),this.tableSelection.setSelection(o[0].domNode.getBoundingClientRect(),o[0].domNode.getBoundingClientRect())}},insertRowUp:{text:"Insert row up",iconSrc:X.a,handler(){const e=r.a.find(this.table).insertRow(this.boundary,!1,this.quill.root.parentNode);this.quill.update(r.a.sources.USER),this.quill.setSelection(this.quill.getIndex(e[0]),0,r.a.sources.SILENT),this.tableSelection.setSelection(e[0].domNode.getBoundingClientRect(),e[0].domNode.getBoundingClientRect())}},insertRowDown:{text:"Insert row down",iconSrc:Y.a,handler(){const e=r.a.find(this.table).insertRow(this.boundary,!0,this.quill.root.parentNode);this.quill.update(r.a.sources.USER),this.quill.setSelection(this.quill.getIndex(e[0]),0,r.a.sources.SILENT),this.tableSelection.setSelection(e[0].domNode.getBoundingClientRect(),e[0].domNode.getBoundingClientRect())}},mergeCells:{text:"Merge selected cells",iconSrc:J.a,handler(){const e=r.a.find(this.table),t=e.rows().reduce((e,t)=>{let o=l(t.domNode.getBoundingClientRect(),this.quill.root.parentNode);return o.y>this.boundary.y-5&&o.y+o.height{let o=l(t.getBoundingClientRect(),this.quill.root.parentNode);return o.x>this.boundary.x-5&&o.x+o.width{let s=l(i.getBoundingClientRect(),n);return o(s,t)&&r.push(e.indexOf(i)),r},[])}(this.columnToolCells,this.boundary,(e,t)=>e.x+5>t.x&&e.x+e.width-5-1&&this.domNode.appendChild(r()));function r(){const e=document.createElement("div");return e.classList.add("qlbt-operation-menu-dividing"),e}this.options.color&&!1!==this.options.color&&(this.domNode.appendChild(r()),this.domNode.appendChild(function(e){const t=document.createElement("div");return t.classList.add("qlbt-operation-menu-subtitle"),t.innerText=e,t}(this.colorSubTitle)),this.domNode.appendChild(this.colorsItemCreator(this.cellColors)))}colorsItemCreator(e){const t=this,o=document.createElement("div");return o.classList.add("qlbt-operation-color-picker"),e.forEach(e=>{let n=function(e){const o=document.createElement("div");return o.classList.add("qlbt-operation-color-picker-item"),o.setAttribute("data-color",e),o.style.backgroundColor=e,o.addEventListener("click",function(){const o=t.tableSelection.selectedTds;o&&o.length>0&&o.forEach(t=>{t.format("cell-bg",e)})},!1),o}(e);o.appendChild(n)}),o}menuItemCreator(e){let{text:t,iconSrc:o,handler:n}=e;const r=document.createElement("div");r.classList.add("qlbt-operation-menu-item");const i=document.createElement("span");i.classList.add("qlbt-operation-menu-icon"),i.innerHTML=o;const l=document.createElement("span");return l.classList.add("qlbt-operation-menu-text"),l.innerText=t,r.appendChild(i),r.appendChild(l),r.addEventListener("click",n.bind(this),!1),r}}function he(e,t,o,n){return e.reduce((r,i)=>{let s=l(i.getBoundingClientRect(),n);return o(s,t)&&(r=e.indexOf(i)),r},!1)}const ue=r.a.import("delta");function pe(e,t,o){const n=e.parentNode,r="TABLE"===n.parentNode.tagName?n.parentNode:n.parentNode.parentNode,i=Array.from(r.querySelectorAll("tr")),l=Array.from(n.querySelectorAll("td")),a=i.indexOf(n)+1,c=l.indexOf(e)+1,d=e.getAttribute("colspan")||!1,h=e.getAttribute("rowspan")||!1,u=e.getAttribute("data-cell-bg")||e.style.backgroundColor;return 0===t.length()?t=(new ue).insert("\n",{"table-cell-line":{row:a,cell:c,rowspan:h,colspan:d}}):(t=t.reduce((e,t)=>{if(t.insert&&"string"==typeof t.insert){const o=[];let n=t.insert,r=0;for(let e=0;e{"\n"===o?e.insert("\n",t.attributes):e.insert(o,s(t.attributes,["table","table-cell-line"]))})}else e.insert(t.insert,t.attributes);return e},new ue)).reduce((e,t)=>(t.insert&&"string"==typeof t.insert&&t.insert.startsWith("\n")?e.insert(t.insert,Object.assign({},Object.assign({},{row:a},t.attributes.table),{"table-cell-line":{row:a,cell:c,rowspan:h,colspan:d,"cell-bg":u}},s(t.attributes,["table"]))):t.attributes&&t.attributes.background&&t.attributes.background===function(e){if(/^(rgb|RGB)/.test(e)){for(var t=e.toString().match(/\d+/g),o="#",n=0;n<3;n++)o+=("0"+Number(t[n]).toString(16)).slice(-2);return o}if(/^#([0-9a-fA-f]{3}|[0-9a-fA-f]{6})$/.test(e)){var r=e.replace(/#/,"").split("");if(6===r.length)return e;if(3===r.length){var i="#";for(n=0;n{if(t.insert&&"string"==typeof t.insert){const o=[];let n=t.insert,r=0;for(let e=0;e{"\n"===o?e.insert("\n",{"table-cell-line":{row:a,cell:c,rowspan:h,colspan:d}}):e.insert(o,t.attributes)})}else e.insert(t.insert,t.attributes);return e},new ue)).reduce((e,t)=>(t.insert&&"string"==typeof t.insert&&t.insert.startsWith("\n")?e.insert(t.insert,Object.assign({},{"table-cell-line":{row:a,cell:c,rowspan:h,colspan:d}})):e.insert(t.insert,Object.assign({},s(t.attributes,["table","table-cell-line"]))),e),new ue)}function fe(e,t,o){let n=new ue;const r=e.querySelector("tr");if(null===r)return n;const i=Array.from(r.querySelectorAll("td")).concat(Array.from(r.querySelectorAll("th"))).reduce((e,t)=>{const o=t.getAttribute("colspan")||1;return e+=parseInt(o,10)},0),l=e.querySelectorAll("col").length;if(l===i)return t;{for(let e=0;e(t.insert(o.insert,o.attributes),o.attributes&&o.attributes["table-col"]&&(e+=o.insert.length)===l&&(t=t.concat(n)),t),new ue)}}const be=r.a.import("core/module"),ge=r.a.import("delta");class we extends be{static register(){r.a.register(M,!0),r.a.register(B,!0),r.a.register(E,!0),r.a.register(S,!0),r.a.register(T,!0),r.a.register(H,!0),r.a.register(O,!0),r.a.register(L,!0),r.a.register(L,!0)}constructor(e,t){super(e,t),this.quill.root.addEventListener("click",o=>{const n=a(o);if(!n||n.length<=0)return;const r=n.filter(e=>e.tagName&&"TABLE"===e.tagName.toUpperCase()&&e.classList.contains("quill-better-table"))[0];if(r){if(this.table===r)return;this.table&&this.hideTableTools(),this.showTableTools(r,e,t)}else this.table&&this.hideTableTools()},!1),this.quill.root.addEventListener("contextmenu",o=>{if(!this.table)return!0;o.preventDefault();const n=a(o);if(!n||n.length<=0)return;const r=n.filter(e=>e.tagName&&"TABLE"===e.tagName.toUpperCase()&&e.classList.contains("quill-better-table"))[0],i=n.filter(e=>e.tagName&&"TR"===e.tagName.toUpperCase()&&e.getAttribute("data-row"))[0],l=n.filter(e=>e.tagName&&"TD"===e.tagName.toUpperCase()&&e.getAttribute("data-row"))[0];let s=this.tableSelection.selectedTds.map(e=>e.domNode).includes(l);(this.tableSelection.selectedTds.length<=0||!s)&&this.tableSelection.setSelection(l.getBoundingClientRect(),l.getBoundingClientRect()),this.tableOperationMenu&&(this.tableOperationMenu=this.tableOperationMenu.destroy()),r&&(this.tableOperationMenu=new de({table:r,row:i,cell:l,left:o.pageX,top:o.pageY},e,t.operationMenu))},!1);e.getModule("keyboard");e.keyboard.addBinding({key:"Backspace"},{},function(e,t){if(0===e.index||this.quill.getLength()<=1)return!0;const[o]=this.quill.getLine(e.index);if(0===t.offset){const[t]=this.quill.getLine(e.index-1);if(null!=t&&"table-cell-line"===t.statics.blotName&&"table-cell-line"!==o.statics.blotName)return!1}return!0});let o=e.keyboard.bindings.Backspace.pop();e.keyboard.bindings.Backspace.splice(0,1,o),e.clipboard.addMatcher("td",pe),e.clipboard.addMatcher("th",me),e.clipboard.addMatcher("table",fe),e.clipboard.matchers=e.clipboard.matchers.filter(e=>"tr"!==e[0])}getTable(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.quill.getSelection();if(null==e)return[null,null,null,-1];const[t,o]=this.quill.getLine(e.index);if(null==t||t.statics.blotName!==E.blotName)return[null,null,null,-1];const n=t.tableCell(),r=n.row();return[r.table(),r,n,o]}insertTable(e,t){const o=this.quill.getSelection(!0);if(null==o)return;let n=this.quill.getLeaf(o.index)[0],i=(new ge).retain(o.index);!function e(t){return!(!t||!t.parent)&&(o=t.parent,o.statics.blotName===S.blotName||e(t.parent));var o}(n)?(i.insert("\n"),i=new Array(t).fill("\n").reduce((e,t)=>(e.insert(t,{"table-col":!0}),e),i),i=new Array(e).fill(0).reduce(e=>{let o=R();return new Array(t).fill("\n").reduce((e,t)=>(e.insert(t,{"table-cell-line":{row:o,cell:z()}}),e),e)},i),this.quill.updateContents(i,r.a.sources.USER),this.quill.setSelection(o.index+t+1,r.a.sources.API)):console.warn("Can not insert table into a table cell.")}showTableTools(e,t,o){this.table=e,this.columnTool=new p(e,t,o),this.tableSelection=new j(e,t,o)}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}}we.keyboardBindings={"table-cell-line backspace":{key:"Backspace",format:["table-cell-line"],collapsed:!0,offset:0,handler(e,t){const[o,n]=this.quill.getLine(e.index);return!(!o.prev||"table-cell-line"!==o.prev.statics.blotName)}},"table-cell-line delete":{key:"Delete",format:["table-cell-line"],collapsed:!0,suffix:/^$/,handler(){}},"table-cell-line enter":{key:"Enter",shiftKey:null,format:["table-cell-line"],handler(e,t){if(this.quill.selection&&this.quill.selection.composing)return;const o=r.a.imports.parchment.Scope;e.length>0&&this.quill.scroll.deleteAt(e.index,e.length);const n=Object.keys(t.format).reduce((e,n)=>(this.quill.scroll.query(n,o.BLOCK)&&!Array.isArray(t.format[n])&&(e[n]=t.format[n]),e),{});this.quill.insertText(e.index,"\n",n["table-cell-line"],r.a.sources.USER),this.quill.setSelection(e.index+1,r.a.sources.SILENT),this.quill.focus(),Object.keys(t.format).forEach(e=>{null==n[e]&&(Array.isArray(t.format[e])||"link"!==e&&this.quill.format(e,t.format[e],r.a.sources.USER))})}}};t.default=we}]).default}); \ No newline at end of file