diff --git a/README.md b/README.md
index 3897f35..8059892 100644
--- a/README.md
+++ b/README.md
@@ -7,10 +7,12 @@ A module for better table in Quill, more useful features are supported. There is
# Planning to
-
-
Supporting headers in table cell. (Already done in v1.1.9)
+ Supporting headers in table cell.(cancelled)
+ (Already done in v1.1.9, but overwrited quill built-in header blot, maybe this is a bad idea, so I cancel this feature in v1.1.13. This feature may be an optional feature in another module.)
-
-
Supporting un/ordered list in table cell.
+ Supporting un/ordered list in table cell.(cancelled)
+ To implement this, it will do harm to quill built-in blot. This feature may be an optional feature in another module.
-
UI optimization(icons, selected areas...).
diff --git a/dist/demo/demo1.js b/dist/demo/demo1.js
index 5a56e33..4f33d88 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 = "7eea064f0aba78ebf4ab";
+/******/ var hotCurrentHash = "16dafd8763b8395da6a4";
/******/ var hotRequestTimeout = 10000;
/******/ var hotCurrentModuleData = {};
/******/ var hotCurrentChildModule;
@@ -2648,8 +2648,7 @@ class quill_better_table_BetterTable extends Module {
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
-
- external_commonjs_quill_commonjs2_quill_amd_quill_root_Quill_default.a.register('formats/header', header, true);
+ // Quill.register('formats/header', Header, true);
}
constructor(quill, options) {
@@ -2736,8 +2735,8 @@ class quill_better_table_BetterTable extends Module {
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.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';
diff --git a/dist/quill-better-table.js b/dist/quill-better-table.js
index c080ddd..e96cf48 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 = "7eea064f0aba78ebf4ab";
+/******/ var hotCurrentHash = "16dafd8763b8395da6a4";
/******/ var hotRequestTimeout = 10000;
/******/ var hotCurrentModuleData = {};
/******/ var hotCurrentChildModule;
@@ -2648,8 +2648,7 @@ class quill_better_table_BetterTable extends Module {
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
-
- external_commonjs_quill_commonjs2_quill_amd_quill_root_Quill_default.a.register('formats/header', header, true);
+ // Quill.register('formats/header', Header, true);
}
constructor(quill, options) {
@@ -2736,8 +2735,8 @@ class quill_better_table_BetterTable extends Module {
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.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';
diff --git a/dist/quill-better-table.min.js b/dist/quill-better-table.min.js
index 7d122e3..a46fa11 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(!N[e]||!x[e])return;for(var o in x[e]=!1,t)Object.prototype.hasOwnProperty.call(t,o)&&(b[o]=t[o]);0==--g&&0===y&&E()}(e,o),t&&t(e,o)};var o,n=!0,r="a4cefed99bbf101506f4",i=1e4,l={},s=[],a=[];function c(e){var t=A[e];if(!t)return S;var n=function(n){return t.hot.active?(A[n]?-1===A[n].parents.indexOf(e)&&A[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=[]),S(n)},r=function(e){return{configurable:!0,enumerable:!0,get:function(){return S[e]},set:function(t){S[e]=t}}};for(var i in S)Object.prototype.hasOwnProperty.call(S,i)&&"e"!==i&&"t"!==i&&Object.defineProperty(n,i,r(i));return n.e=function(e){return"ready"===h&&p("prepare"),y++,S.e(e).then(t,function(e){throw t(),e});function t(){y--,"prepare"===h&&(w[e]||v(e),0===y&&0===g&&E())}},n.t=function(e,t){return 1&t&&(e=n(e)),S.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:q,apply:T,status:function(e){if(!e)return h;u.push(e)},addStatusHandler:function(e){u.push(e)},removeStatusHandler:function(e){var t=u.indexOf(e);t>=0&&u.splice(t,1)},data:l[e]};return o=void 0,t}var u=[],h="idle";function p(e){h=e;for(var t=0;t0;){var r=n.pop(),i=r.id,l=r.chain;if((a=A[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 ")),q.type){case"self-declined":t.onDeclined&&t.onDeclined(q),t.ignoreDeclined||(v=new Error("Aborted because of self decline: "+q.moduleId+O));break;case"declined":t.onDeclined&&t.onDeclined(q),t.ignoreDeclined||(v=new Error("Aborted because of declined dependency: "+q.moduleId+" in "+q.parentId+O));break;case"unaccepted":t.onUnaccepted&&t.onUnaccepted(q),t.ignoreUnaccepted||(v=new Error("Aborted because "+c+" is not accepted"+O));break;case"accepted":t.onAccepted&&t.onAccepted(q),E=!0;break;case"disposed":t.onDisposed&&t.onDisposed(q),T=!0;break;default:throw new Error("Unexception type "+q.type)}if(v)return p("abort"),Promise.reject(v);if(E)for(c in y[c]=b[c],u(g,q.outdatedModules),q.outdatedDependencies)Object.prototype.hasOwnProperty.call(q.outdatedDependencies,c)&&(f[c]||(f[c]=[]),u(f[c],q.outdatedDependencies[c]));T&&(u(g,[q.moduleId]),y[c]=w)}var B,R=[];for(n=0;n0;)if(c=I.pop(),a=A[c]){var k={},H=a.hot._disposeHandlers;for(i=0;i=0&&D.parents.splice(B,1))}}for(c in f)if(Object.prototype.hasOwnProperty.call(f,c)&&(a=A[c]))for(M=f[c],i=0;i=0&&a.children.splice(B,1);for(c in p("apply"),r=m,y)Object.prototype.hasOwnProperty.call(y,c)&&(e[c]=y[c]);var j=null;for(c in f)if(Object.prototype.hasOwnProperty.call(f,c)&&(a=A[c])){M=f[c];var _=[];for(n=0;nt.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,u=50,h="#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={},f={},b=null;const m=e=>{e.preventDefault(),n&&(s=e.clientX,a=d+s-l>=u?s-l:u-d,i(b,{left:"".concat(f.left+f.width-1+a,"px")}))},g=r=>{r.preventDefault();const c=Array.from(this.domNode.querySelectorAll(".qlbt-col-tool-cell")).indexOf(e),u=t.colGroup().children.at(c);n&&(u.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",m,!1),document.removeEventListener("mouseup",g,!1),p={},f={},b.remove(),b=null,t.updateTableWidth();const h=this.quill.getModule("better-table").tableSelection;h&&h.clearSelection()};o.addEventListener("mousedown",t=>{document.addEventListener("mousemove",m,!1),document.addEventListener("mouseup",g,!1),p=this.table.getBoundingClientRect(),f=e.getBoundingClientRect(),i(b=document.createElement("div"),{position:"fixed",top:"".concat(f.top,"px"),left:"".concat(f.left+f.width-1,"px"),zIndex:"100",height:"".concat(p.height+c+4,"px"),width:"1px",backgroundColor:h}),document.body.appendChild(b),n=!0,l=t.clientX,d=f.width,o.classList.add("dragging")},!1)}colToolCells(){return Array.from(this.domNode.querySelectorAll(".qlbt-col-tool-cell"))}}const f=r.a.import("blots/block");class b extends f{static create(e){"string"==typeof e&&(e={value:e});const t=super.create(e.value);return C.forEach(o=>{e[o]&&t.setAttribute("data-".concat(o),e[o])}),q.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,q.concat(C).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}=b.formats(this.domNode);e===b.blotName?t?super.format(e,{value:t,row:o,cell:n,rowspan:r,colspan:i}):o?this.replaceWith(T.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}=b.formats(this.domNode);if(!t||this.parent instanceof A||this.wrap(A.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={}}}b.blotName="header",b.tagName=["H1","H2","H3","H4","H5","H6"];var m=b;const g=r.a.import("blots/break"),y=r.a.import("blots/block"),w=r.a.import("blots/container"),x=["width"],N={width:100},C=["row","cell"],q=["rowspan","colspan"],v={rowspan:1,colspan:1},E=5;class T extends y{static create(e){const t=super.create(e);return C.forEach(o=>{let n="row"===o?I:k;t.setAttribute("data-".concat(o),e[o]||n())}),q.forEach(o=>{t.setAttribute("data-".concat(o),e[o]||v[o])}),t}static formats(e){return q.concat(C).reduce((t,o)=>(e.hasAttribute("data-".concat(o))&&(t[o]=e.getAttribute("data-".concat(o))||void 0),t),{})}format(e,t){if(q.concat(C).indexOf(e)>-1)t?this.domNode.setAttribute("data-".concat(e),t):this.domNode.removeAttribute("data-".concat(e));else if("header"===e){if(!t)return;const{row:o,cell:n,rowspan:r,colspan:i}=T.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");!this.statics.requiredContainer||this.parent instanceof this.statics.requiredContainer||this.wrap(this.statics.requiredContainer.blotName,{row:t,colspan:n,rowspan:o}),super.optimize(e)}tableCell(){return this.parent}}T.blotName="table-cell-line",T.ClassName="qlbt-cell-line",T.tagName="DIV";class A extends w{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),q.forEach(o=>{e[o]&&t.setAttribute(o,e[o])}),t}static formats(e){const t={};return e.hasAttribute("data-row")&&(t.row=e.getAttribute("data-row")),q.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")),q.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){q.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)):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()}}A.blotName="table",A.tagName="TD";class S extends w{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}}S.blotName="table-row",S.tagName="TR";class O extends w{}O.blotName="table-body",O.tagName="TBODY";class B extends y{static create(e){let t=super.create(e);return x.forEach(o=>{t.setAttribute("".concat(o),e[o]||N[o])}),t}static formats(e){return x.reduce((t,o)=>(e.hasAttribute("".concat(o))&&(t[o]=e.getAttribute("".concat(o))||void 0),t),{})}format(e,t){x.indexOf(e)>-1?this.domNode.setAttribute("".concat(e),t||N[e]):super.format(e,t)}html(){return this.domNode.outerHTML}}B.blotName="table-col",B.tagName="col";class R extends w{}R.blotName="table-col-group",R.tagName="colgroup";class L extends w{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()[B.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(O);if(null==n||null==n.children.head)return;const r=this.descendants(A),i=[],s=[];if(r.forEach(t=>{const n=l(t.domNode.getBoundingClientRect(),o);n.x+E>e.x&&n.x1-Ee.x1-E&&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(O);if(null==o||null==o.children.head)return;const n=this.descendants(A),r=[],i=[],s=[];if(n.forEach(o=>{const n=l(o.domNode.getBoundingClientRect(),t);n.y>e.y-E&&n.y1e.y1-E&&(i.push(o),Math.abs(n.y-e.y){let r=l(n.domNode.getBoundingClientRect(),t);return r.y>e.y-E&&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=k(),n=e.formats().row,r=this.scroll.create(A.blotName,Object.assign({},v,{row:n})),i=this.scroll.create(T.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(O),[i]=this.descendants(R),s=this.descendants(B);let a=[],c=[],d=[];if(null==r||null==r.children.head)return;this.descendants(A).forEach(t=>{const r=l(t.domNode.getBoundingClientRect(),n);o?Math.abs(r.x1-e.x1)E&&e.x1-r.x1<-E&&c.push(t):Math.abs(r.x-e.x)E&&e.x-r.x1<-E&&c.push(t)}),a.forEach(e=>{const t=o?e.next:e,n=k(),r=e.parent,i=r.formats().row,l=e.formats(),s=this.scroll.create(A.blotName,Object.assign({},v,{row:i,rowspan:l.rowspan})),a=this.scroll.create(T.blotName,{row:i,cell:n,rowspan:l.rowspan});s.appendChild(a),t?r.insertBefore(s,t):r.appendChild(s),d.push(s)});const u=this.scroll.create(B.blotName,!0);let h=o?s[t].next:s[t];return h?i.insertBefore(u,h):i.appendChild(u),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(O);if(null==n||null==n.children.head)return;const r=this.descendants(A),i=I(),s=this.scroll.create(S.blotName,{row:i});let a=[],c=[],d=[];r.forEach(n=>{const r=l(n.domNode.getBoundingClientRect(),o);t?Math.abs(r.y1-e.y1)E&&e.y1-r.y1<-E&&c.push(n):Math.abs(r.y-e.y)E&&e.y-r.y1<-E&&c.push(n)});const u=(e,t)=>{return e.domNode.getBoundingClientRect().x-t.domNode.getBoundingClientRect().x};a.sort(u),a.forEach(e=>{const t=k(),o=e.formats(),n=this.scroll.create(A.blotName,Object.assign({},v,{row:i,colspan:o.colspan})),r=this.scroll.create(T.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 h=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)}}L.blotName="table-container",L.className="quill-better-table",L.tagName="TABLE";class M extends w{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 I(){const e=Math.random().toString(36).slice(2,6);return"row-".concat(e)}function k(){const e=Math.random().toString(36).slice(2,6);return"cell-".concat(e)}M.blotName="table-view",M.className="quill-better-table-wrapper",M.tagName="DIV",M.allowedChildren=[L],L.requiredContainer=M,L.allowedChildren=[O,R],O.requiredContainer=L,O.allowedChildren=[S],S.requiredContainer=O,S.allowedChildren=[A],A.requiredContainer=S,A.allowedChildren=[T,m],T.requiredContainer=A,R.allowedChildren=[B],R.requiredContainer=L,B.requiredContainer=R;const H="#35A7ED",D=["left","right","top","bottom"],j=2;class _{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;D.forEach(t=>{this[t]=document.createElement("div"),this[t].classList.add("qlbt-selection-line"),i(this[t],{position:"absolute",display:"none","background-color":H}),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=U(n,i),t.correctBoundary(),t.selectedTds=t.computeSelectedTds(),t.repositionHelpLines(),o!==r&&t.quill.blur()}this.dragging=!0,this.boundary=U(n,n),this.correctBoundary(),this.selectedTds=this.computeSelectedTds(),this.repositionHelpLines()}correctBoundary(){r.a.find(this.table).descendants(A).forEach(e=>{let{x:t,y:o,width:n,height:r}=l(e.domNode.getBoundingClientRect(),this.quill.root.parentNode);(t+j>=this.boundary.x&&t+j<=this.boundary.x1||t-j+n>=this.boundary.x&&t-j+n<=this.boundary.x1)&&(o+j>=this.boundary.y&&o+j<=this.boundary.y1||o-j+r>=this.boundary.y&&o-j+r<=this.boundary.y1)&&(this.boundary=U(this.boundary,{x:t,y:o,width:n,height:r}))})}computeSelectedTds(){return r.a.find(this.table).descendants(A).reduce((e,t)=>{let{x:o,y:n,width:r,height:i}=l(t.domNode.getBoundingClientRect(),this.quill.root.parentNode);return o+j>=this.boundary.x&&o-j+r<=this.boundary.x1&&n+j>=this.boundary.y&&n-j+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=U(e,t),this.repositionHelpLines()}destroy(){return D.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=U(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=[],D.forEach(e=>{this[e]&&i(this[e],{display:"none"})})}}function U(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}}const P=150,W=200,z={insertColumnRight:{text:"Insert column right",handler(){const e=r.a.find(this.table);let t=X(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",handler(){const e=r.a.find(this.table);let t=X(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",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",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",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{let s=l(i.getBoundingClientRect(),n);return o(s,t)&&(r=e.indexOf(i)),r},!1)}const K=r.a.import("delta");function V(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,u=e.getAttribute("rowspan")||!1;return 0===t.length()?t=(new K).insert("\n",{"table-cell-line":{row:a,cell:c,rowspan:u,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","header"]))})}else e.insert(t.insert,t.attributes);return e},new K)).reduce((e,t)=>{if(t.insert&&"string"==typeof t.insert&&t.insert.startsWith("\n")){let o={};t.attributes.header?o.header={row:a,cell:c,rowspan:u,colspan:d}:t.attributes["table-cell-line"]&&(o["table-cell-line"]={row:a,cell:c,rowspan:u,colspan:d}),e.insert(t.insert,Object.assign({},Object.assign({},{row:a},t.attributes.table),o,s(t.attributes,["table"])))}else e.insert(t.insert,Object.assign({},s(t.attributes,["table","table-cell-line"])));return console.log(e),e},new K)}function Y(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("th")),a=i.indexOf(n)+1,c=l.indexOf(e)+1,d=e.getAttribute("colspan")||!1,u=e.getAttribute("rowspan")||!1;return 0===t.length()?t=(new K).insert("\n",{"table-cell-line":{row:a,cell:c,rowspan:u,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",{"table-cell-line":{row:a,cell:c,rowspan:u,colspan:d}}):e.insert(o,t.attributes)})}else e.insert(t.insert,t.attributes);return e},new K)).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:u,colspan:d}})):e.insert(t.insert,Object.assign({},s(t.attributes,["table","table-cell-line"]))),e),new K)}function J(e,t,o){let n=new K;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 K)}}function Q(e,t,o){return t}const $=r.a.import("core/module"),F=r.a.import("delta");class Z extends ${static register(){r.a.register(B,!0),r.a.register(R,!0),r.a.register(T,!0),r.a.register(A,!0),r.a.register(S,!0),r.a.register(O,!0),r.a.register(L,!0),r.a.register(M,!0),r.a.register(M,!0),r.a.register("formats/header",m,!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 G({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",V),e.clipboard.addMatcher("th",Y),e.clipboard.addMatcher("table",J),e.clipboard.addMatcher("h1, h2, h3, h4, h5, h6",Q),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!==T.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 F).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=I();return new Array(t).fill("\n").reduce((e,t)=>(e.insert(t,{"table-cell-line":{row:o,cell:k()}}),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 _(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}}Z.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=Z}]).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(!N[e]||!x[e])return;for(var o in x[e]=!1,t)Object.prototype.hasOwnProperty.call(t,o)&&(b[o]=t[o]);0==--g&&0===y&&E()}(e,o),t&&t(e,o)};var o,n=!0,r="158e5e1759938947679b",i=1e4,l={},s=[],a=[];function c(e){var t=A[e];if(!t)return S;var n=function(n){return t.hot.active?(A[n]?-1===A[n].parents.indexOf(e)&&A[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=[]),S(n)},r=function(e){return{configurable:!0,enumerable:!0,get:function(){return S[e]},set:function(t){S[e]=t}}};for(var i in S)Object.prototype.hasOwnProperty.call(S,i)&&"e"!==i&&"t"!==i&&Object.defineProperty(n,i,r(i));return n.e=function(e){return"ready"===h&&p("prepare"),y++,S.e(e).then(t,function(e){throw t(),e});function t(){y--,"prepare"===h&&(w[e]||v(e),0===y&&0===g&&E())}},n.t=function(e,t){return 1&t&&(e=n(e)),S.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:q,apply:T,status:function(e){if(!e)return h;u.push(e)},addStatusHandler:function(e){u.push(e)},removeStatusHandler:function(e){var t=u.indexOf(e);t>=0&&u.splice(t,1)},data:l[e]};return o=void 0,t}var u=[],h="idle";function p(e){h=e;for(var t=0;t0;){var r=n.pop(),i=r.id,l=r.chain;if((a=A[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 ")),q.type){case"self-declined":t.onDeclined&&t.onDeclined(q),t.ignoreDeclined||(v=new Error("Aborted because of self decline: "+q.moduleId+O));break;case"declined":t.onDeclined&&t.onDeclined(q),t.ignoreDeclined||(v=new Error("Aborted because of declined dependency: "+q.moduleId+" in "+q.parentId+O));break;case"unaccepted":t.onUnaccepted&&t.onUnaccepted(q),t.ignoreUnaccepted||(v=new Error("Aborted because "+c+" is not accepted"+O));break;case"accepted":t.onAccepted&&t.onAccepted(q),E=!0;break;case"disposed":t.onDisposed&&t.onDisposed(q),T=!0;break;default:throw new Error("Unexception type "+q.type)}if(v)return p("abort"),Promise.reject(v);if(E)for(c in y[c]=b[c],u(g,q.outdatedModules),q.outdatedDependencies)Object.prototype.hasOwnProperty.call(q.outdatedDependencies,c)&&(f[c]||(f[c]=[]),u(f[c],q.outdatedDependencies[c]));T&&(u(g,[q.moduleId]),y[c]=w)}var B,R=[];for(n=0;n0;)if(c=I.pop(),a=A[c]){var k={},H=a.hot._disposeHandlers;for(i=0;i=0&&D.parents.splice(B,1))}}for(c in f)if(Object.prototype.hasOwnProperty.call(f,c)&&(a=A[c]))for(M=f[c],i=0;i=0&&a.children.splice(B,1);for(c in p("apply"),r=m,y)Object.prototype.hasOwnProperty.call(y,c)&&(e[c]=y[c]);var j=null;for(c in f)if(Object.prototype.hasOwnProperty.call(f,c)&&(a=A[c])){M=f[c];var _=[];for(n=0;nt.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,u=50,h="#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={},f={},b=null;const m=e=>{e.preventDefault(),n&&(s=e.clientX,a=d+s-l>=u?s-l:u-d,i(b,{left:"".concat(f.left+f.width-1+a,"px")}))},g=r=>{r.preventDefault();const c=Array.from(this.domNode.querySelectorAll(".qlbt-col-tool-cell")).indexOf(e),u=t.colGroup().children.at(c);n&&(u.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",m,!1),document.removeEventListener("mouseup",g,!1),p={},f={},b.remove(),b=null,t.updateTableWidth();const h=this.quill.getModule("better-table").tableSelection;h&&h.clearSelection()};o.addEventListener("mousedown",t=>{document.addEventListener("mousemove",m,!1),document.addEventListener("mouseup",g,!1),p=this.table.getBoundingClientRect(),f=e.getBoundingClientRect(),i(b=document.createElement("div"),{position:"fixed",top:"".concat(f.top,"px"),left:"".concat(f.left+f.width-1,"px"),zIndex:"100",height:"".concat(p.height+c+4,"px"),width:"1px",backgroundColor:h}),document.body.appendChild(b),n=!0,l=t.clientX,d=f.width,o.classList.add("dragging")},!1)}colToolCells(){return Array.from(this.domNode.querySelectorAll(".qlbt-col-tool-cell"))}}const f=r.a.import("blots/block");class b extends f{static create(e){"string"==typeof e&&(e={value:e});const t=super.create(e.value);return C.forEach(o=>{e[o]&&t.setAttribute("data-".concat(o),e[o])}),q.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,q.concat(C).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}=b.formats(this.domNode);e===b.blotName?t?super.format(e,{value:t,row:o,cell:n,rowspan:r,colspan:i}):o?this.replaceWith(T.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}=b.formats(this.domNode);if(!t||this.parent instanceof A||this.wrap(A.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={}}}b.blotName="header",b.tagName=["H1","H2","H3","H4","H5","H6"];var m=b;const g=r.a.import("blots/break"),y=r.a.import("blots/block"),w=r.a.import("blots/container"),x=["width"],N={width:100},C=["row","cell"],q=["rowspan","colspan"],v={rowspan:1,colspan:1},E=5;class T extends y{static create(e){const t=super.create(e);return C.forEach(o=>{let n="row"===o?I:k;t.setAttribute("data-".concat(o),e[o]||n())}),q.forEach(o=>{t.setAttribute("data-".concat(o),e[o]||v[o])}),t}static formats(e){return q.concat(C).reduce((t,o)=>(e.hasAttribute("data-".concat(o))&&(t[o]=e.getAttribute("data-".concat(o))||void 0),t),{})}format(e,t){if(q.concat(C).indexOf(e)>-1)t?this.domNode.setAttribute("data-".concat(e),t):this.domNode.removeAttribute("data-".concat(e));else if("header"===e){if(!t)return;const{row:o,cell:n,rowspan:r,colspan:i}=T.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");!this.statics.requiredContainer||this.parent instanceof this.statics.requiredContainer||this.wrap(this.statics.requiredContainer.blotName,{row:t,colspan:n,rowspan:o}),super.optimize(e)}tableCell(){return this.parent}}T.blotName="table-cell-line",T.ClassName="qlbt-cell-line",T.tagName="DIV";class A extends w{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),q.forEach(o=>{e[o]&&t.setAttribute(o,e[o])}),t}static formats(e){const t={};return e.hasAttribute("data-row")&&(t.row=e.getAttribute("data-row")),q.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")),q.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){q.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)):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()}}A.blotName="table",A.tagName="TD";class S extends w{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}}S.blotName="table-row",S.tagName="TR";class O extends w{}O.blotName="table-body",O.tagName="TBODY";class B extends y{static create(e){let t=super.create(e);return x.forEach(o=>{t.setAttribute("".concat(o),e[o]||N[o])}),t}static formats(e){return x.reduce((t,o)=>(e.hasAttribute("".concat(o))&&(t[o]=e.getAttribute("".concat(o))||void 0),t),{})}format(e,t){x.indexOf(e)>-1?this.domNode.setAttribute("".concat(e),t||N[e]):super.format(e,t)}html(){return this.domNode.outerHTML}}B.blotName="table-col",B.tagName="col";class R extends w{}R.blotName="table-col-group",R.tagName="colgroup";class L extends w{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()[B.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(O);if(null==n||null==n.children.head)return;const r=this.descendants(A),i=[],s=[];if(r.forEach(t=>{const n=l(t.domNode.getBoundingClientRect(),o);n.x+E>e.x&&n.x1-Ee.x1-E&&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(O);if(null==o||null==o.children.head)return;const n=this.descendants(A),r=[],i=[],s=[];if(n.forEach(o=>{const n=l(o.domNode.getBoundingClientRect(),t);n.y>e.y-E&&n.y1e.y1-E&&(i.push(o),Math.abs(n.y-e.y){let r=l(n.domNode.getBoundingClientRect(),t);return r.y>e.y-E&&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=k(),n=e.formats().row,r=this.scroll.create(A.blotName,Object.assign({},v,{row:n})),i=this.scroll.create(T.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(O),[i]=this.descendants(R),s=this.descendants(B);let a=[],c=[],d=[];if(null==r||null==r.children.head)return;this.descendants(A).forEach(t=>{const r=l(t.domNode.getBoundingClientRect(),n);o?Math.abs(r.x1-e.x1)E&&e.x1-r.x1<-E&&c.push(t):Math.abs(r.x-e.x)E&&e.x-r.x1<-E&&c.push(t)}),a.forEach(e=>{const t=o?e.next:e,n=k(),r=e.parent,i=r.formats().row,l=e.formats(),s=this.scroll.create(A.blotName,Object.assign({},v,{row:i,rowspan:l.rowspan})),a=this.scroll.create(T.blotName,{row:i,cell:n,rowspan:l.rowspan});s.appendChild(a),t?r.insertBefore(s,t):r.appendChild(s),d.push(s)});const u=this.scroll.create(B.blotName,!0);let h=o?s[t].next:s[t];return h?i.insertBefore(u,h):i.appendChild(u),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(O);if(null==n||null==n.children.head)return;const r=this.descendants(A),i=I(),s=this.scroll.create(S.blotName,{row:i});let a=[],c=[],d=[];r.forEach(n=>{const r=l(n.domNode.getBoundingClientRect(),o);t?Math.abs(r.y1-e.y1)E&&e.y1-r.y1<-E&&c.push(n):Math.abs(r.y-e.y)E&&e.y-r.y1<-E&&c.push(n)});const u=(e,t)=>{return e.domNode.getBoundingClientRect().x-t.domNode.getBoundingClientRect().x};a.sort(u),a.forEach(e=>{const t=k(),o=e.formats(),n=this.scroll.create(A.blotName,Object.assign({},v,{row:i,colspan:o.colspan})),r=this.scroll.create(T.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 h=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)}}L.blotName="table-container",L.className="quill-better-table",L.tagName="TABLE";class M extends w{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 I(){const e=Math.random().toString(36).slice(2,6);return"row-".concat(e)}function k(){const e=Math.random().toString(36).slice(2,6);return"cell-".concat(e)}M.blotName="table-view",M.className="quill-better-table-wrapper",M.tagName="DIV",M.allowedChildren=[L],L.requiredContainer=M,L.allowedChildren=[O,R],O.requiredContainer=L,O.allowedChildren=[S],S.requiredContainer=O,S.allowedChildren=[A],A.requiredContainer=S,A.allowedChildren=[T,m],T.requiredContainer=A,R.allowedChildren=[B],R.requiredContainer=L,B.requiredContainer=R;const H="#35A7ED",D=["left","right","top","bottom"],j=2;class _{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;D.forEach(t=>{this[t]=document.createElement("div"),this[t].classList.add("qlbt-selection-line"),i(this[t],{position:"absolute",display:"none","background-color":H}),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=U(n,i),t.correctBoundary(),t.selectedTds=t.computeSelectedTds(),t.repositionHelpLines(),o!==r&&t.quill.blur()}this.dragging=!0,this.boundary=U(n,n),this.correctBoundary(),this.selectedTds=this.computeSelectedTds(),this.repositionHelpLines()}correctBoundary(){r.a.find(this.table).descendants(A).forEach(e=>{let{x:t,y:o,width:n,height:r}=l(e.domNode.getBoundingClientRect(),this.quill.root.parentNode);(t+j>=this.boundary.x&&t+j<=this.boundary.x1||t-j+n>=this.boundary.x&&t-j+n<=this.boundary.x1)&&(o+j>=this.boundary.y&&o+j<=this.boundary.y1||o-j+r>=this.boundary.y&&o-j+r<=this.boundary.y1)&&(this.boundary=U(this.boundary,{x:t,y:o,width:n,height:r}))})}computeSelectedTds(){return r.a.find(this.table).descendants(A).reduce((e,t)=>{let{x:o,y:n,width:r,height:i}=l(t.domNode.getBoundingClientRect(),this.quill.root.parentNode);return o+j>=this.boundary.x&&o-j+r<=this.boundary.x1&&n+j>=this.boundary.y&&n-j+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=U(e,t),this.repositionHelpLines()}destroy(){return D.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=U(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=[],D.forEach(e=>{this[e]&&i(this[e],{display:"none"})})}}function U(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}}const P=150,W=200,z={insertColumnRight:{text:"Insert column right",handler(){const e=r.a.find(this.table);let t=X(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",handler(){const e=r.a.find(this.table);let t=X(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",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",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",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{let s=l(i.getBoundingClientRect(),n);return o(s,t)&&(r=e.indexOf(i)),r},!1)}const K=r.a.import("delta");function V(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,u=e.getAttribute("rowspan")||!1;return 0===t.length()?t=(new K).insert("\n",{"table-cell-line":{row:a,cell:c,rowspan:u,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","header"]))})}else e.insert(t.insert,t.attributes);return e},new K)).reduce((e,t)=>{if(t.insert&&"string"==typeof t.insert&&t.insert.startsWith("\n")){let o={};t.attributes.header?o.header={row:a,cell:c,rowspan:u,colspan:d}:t.attributes["table-cell-line"]&&(o["table-cell-line"]={row:a,cell:c,rowspan:u,colspan:d}),e.insert(t.insert,Object.assign({},Object.assign({},{row:a},t.attributes.table),o,s(t.attributes,["table"])))}else e.insert(t.insert,Object.assign({},s(t.attributes,["table","table-cell-line"])));return console.log(e),e},new K)}function Y(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("th")),a=i.indexOf(n)+1,c=l.indexOf(e)+1,d=e.getAttribute("colspan")||!1,u=e.getAttribute("rowspan")||!1;return 0===t.length()?t=(new K).insert("\n",{"table-cell-line":{row:a,cell:c,rowspan:u,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",{"table-cell-line":{row:a,cell:c,rowspan:u,colspan:d}}):e.insert(o,t.attributes)})}else e.insert(t.insert,t.attributes);return e},new K)).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:u,colspan:d}})):e.insert(t.insert,Object.assign({},s(t.attributes,["table","table-cell-line"]))),e),new K)}function J(e,t,o){let n=new K;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 K)}}const Q=r.a.import("core/module"),$=r.a.import("delta");class F extends Q{static register(){r.a.register(B,!0),r.a.register(R,!0),r.a.register(T,!0),r.a.register(A,!0),r.a.register(S,!0),r.a.register(O,!0),r.a.register(L,!0),r.a.register(M,!0),r.a.register(M,!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 G({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",V),e.clipboard.addMatcher("th",Y),e.clipboard.addMatcher("table",J),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!==T.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 $).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=I();return new Array(t).fill("\n").reduce((e,t)=>(e.insert(t,{"table-cell-line":{row:o,cell:k()}}),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 _(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}}F.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=F}]).default});
\ No newline at end of file
diff --git a/package.json b/package.json
index 58bed19..3231555 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
"name": "quill-better-table",
- "version": "1.1.12",
+ "version": "1.1.13",
"description": "Module for better table in Quill, more useful features are supported.",
"main": "dist/quill-better-table.js",
"scripts": {