Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

quill-better-table

Package Overview
Dependencies
Maintainers
1
Versions
30
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

quill-better-table - npm Package Compare versions

Comparing version 1.1.5 to 1.1.6

2

dist/demo/demo1.js

@@ -1,1 +0,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,r){!function(e,t){if(!v[e]||!x[e])return;for(var r in x[e]=!1,t)Object.prototype.hasOwnProperty.call(t,r)&&(b[r]=t[r]);0==--g&&0===y&&q()}(e,r),t&&t(e,r)};var r,n=!0,l="7acea3c59aabbdb66211",o=1e4,i={},s=[],a=[];function d(e){var t=E[e];if(!t)return S;var n=function(n){return t.hot.active?(E[n]?-1===E[n].parents.indexOf(e)&&E[n].parents.push(e):(s=[e],r=n),-1===t.children.indexOf(n)&&t.children.push(n)):(console.warn("[HMR] unexpected require("+n+") from disposed module "+e),s=[]),S(n)},l=function(e){return{configurable:!0,enumerable:!0,get:function(){return S[e]},set:function(t){S[e]=t}}};for(var o in S)Object.prototype.hasOwnProperty.call(S,o)&&"e"!==o&&"t"!==o&&Object.defineProperty(n,o,l(o));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]||T(e),0===y&&0===g&&q())}},n.t=function(e,t){return 1&t&&(e=n(e)),S.t(e,-2&t)},n}function c(e){var t={_acceptedDependencies:{},_declinedDependencies:{},_selfAccepted:!1,_selfDeclined:!1,_disposeHandlers:[],_main:r!==e,active:!0,accept:function(e,r){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<e.length;n++)t._acceptedDependencies[e[n]]=r||function(){};else t._acceptedDependencies[e]=r||function(){}},decline:function(e){if(void 0===e)t._selfDeclined=!0;else if("object"==typeof e)for(var r=0;r<e.length;r++)t._declinedDependencies[e[r]]=!0;else t._declinedDependencies[e]=!0},dispose:function(e){t._disposeHandlers.push(e)},addDisposeHandler:function(e){t._disposeHandlers.push(e)},removeDisposeHandler:function(e){var r=t._disposeHandlers.indexOf(e);r>=0&&t._disposeHandlers.splice(r,1)},check:N,apply:R,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:i[e]};return r=void 0,t}var u=[],h="idle";function p(e){h=e;for(var t=0;t<u.length;t++)u[t].call(null,e)}var f,b,m,g=0,y=0,w={},x={},v={};function C(e){return+e+""===e?+e:e}function N(e){if("idle"!==h)throw new Error("check() is only allowed in idle status");return n=e,p("check"),(t=o,t=t||1e4,new Promise(function(e,r){if("undefined"==typeof XMLHttpRequest)return r(new Error("No browser support"));try{var n=new XMLHttpRequest,o=S.p+""+l+".hot-update.json";n.open("GET",o,!0),n.timeout=t,n.send(null)}catch(e){return r(e)}n.onreadystatechange=function(){if(4===n.readyState)if(0===n.status)r(new Error("Manifest request to "+o+" timed out."));else if(404===n.status)e();else if(200!==n.status&&304!==n.status)r(new Error("Manifest request to "+o+" failed."));else{try{var t=JSON.parse(n.responseText)}catch(e){return void r(e)}e(t)}}})).then(function(e){if(!e)return p("idle"),null;x={},w={},v=e.c,m=e.h,p("prepare");var t=new Promise(function(e,t){f={resolve:e,reject:t}});b={};return T(0),"prepare"===h&&0===y&&0===g&&q(),t});var t}function T(e){v[e]?(x[e]=!0,g++,function(e){var t=document.createElement("script");t.charset="utf-8",t.src=S.p+""+e+"."+l+".hot-update.js",document.head.appendChild(t)}(e)):w[e]=!0}function q(){p("ready");var e=f;if(f=null,e)if(n)Promise.resolve().then(function(){return R(n)}).then(function(t){e.resolve(t)},function(t){e.reject(t)});else{var t=[];for(var r in b)Object.prototype.hasOwnProperty.call(b,r)&&t.push(C(r));e.resolve(t)}}function R(t){if("ready"!==h)throw new Error("apply() is only allowed in ready status");var r,n,o,a,d;function c(e){for(var t=[e],r={},n=t.slice().map(function(e){return{chain:[e],id:e}});n.length>0;){var l=n.pop(),o=l.id,i=l.chain;if((a=E[o])&&!a.hot._selfAccepted){if(a.hot._selfDeclined)return{type:"self-declined",chain:i,moduleId:o};if(a.hot._main)return{type:"unaccepted",chain:i,moduleId:o};for(var s=0;s<a.parents.length;s++){var d=a.parents[s],c=E[d];if(c){if(c.hot._declinedDependencies[o])return{type:"declined",chain:i.concat([d]),moduleId:o,parentId:d};-1===t.indexOf(d)&&(c.hot._acceptedDependencies[o]?(r[d]||(r[d]=[]),u(r[d],[o])):(delete r[d],t.push(d),n.push({chain:i.concat([d]),id:d})))}}}}return{type:"accepted",moduleId:e,outdatedModules:t,outdatedDependencies:r}}function u(e,t){for(var r=0;r<t.length;r++){var n=t[r];-1===e.indexOf(n)&&e.push(n)}}t=t||{};var f={},g=[],y={},w=function(){console.warn("[HMR] unexpected require("+N.moduleId+") to disposed module")};for(var x in b)if(Object.prototype.hasOwnProperty.call(b,x)){var N;d=C(x);var T=!1,q=!1,R=!1,A="";switch((N=b[x]?c(d):{type:"disposed",moduleId:x}).chain&&(A="\nUpdate propagation: "+N.chain.join(" -> ")),N.type){case"self-declined":t.onDeclined&&t.onDeclined(N),t.ignoreDeclined||(T=new Error("Aborted because of self decline: "+N.moduleId+A));break;case"declined":t.onDeclined&&t.onDeclined(N),t.ignoreDeclined||(T=new Error("Aborted because of declined dependency: "+N.moduleId+" in "+N.parentId+A));break;case"unaccepted":t.onUnaccepted&&t.onUnaccepted(N),t.ignoreUnaccepted||(T=new Error("Aborted because "+d+" is not accepted"+A));break;case"accepted":t.onAccepted&&t.onAccepted(N),q=!0;break;case"disposed":t.onDisposed&&t.onDisposed(N),R=!0;break;default:throw new Error("Unexception type "+N.type)}if(T)return p("abort"),Promise.reject(T);if(q)for(d in y[d]=b[d],u(g,N.outdatedModules),N.outdatedDependencies)Object.prototype.hasOwnProperty.call(N.outdatedDependencies,d)&&(f[d]||(f[d]=[]),u(f[d],N.outdatedDependencies[d]));R&&(u(g,[N.moduleId]),y[d]=w)}var O,B=[];for(n=0;n<g.length;n++)d=g[n],E[d]&&E[d].hot._selfAccepted&&B.push({module:d,errorHandler:E[d].hot._selfAccepted});p("dispose"),Object.keys(v).forEach(function(e){!1===v[e]&&function(e){delete installedChunks[e]}(e)});for(var L,M,_=g.slice();_.length>0;)if(d=_.pop(),a=E[d]){var I={},j=a.hot._disposeHandlers;for(o=0;o<j.length;o++)(r=j[o])(I);for(i[d]=I,a.hot.active=!1,delete E[d],delete f[d],o=0;o<a.children.length;o++){var k=E[a.children[o]];k&&((O=k.parents.indexOf(d))>=0&&k.parents.splice(O,1))}}for(d in f)if(Object.prototype.hasOwnProperty.call(f,d)&&(a=E[d]))for(M=f[d],o=0;o<M.length;o++)L=M[o],(O=a.children.indexOf(L))>=0&&a.children.splice(O,1);for(d in p("apply"),l=m,y)Object.prototype.hasOwnProperty.call(y,d)&&(e[d]=y[d]);var D=null;for(d in f)if(Object.prototype.hasOwnProperty.call(f,d)&&(a=E[d])){M=f[d];var $=[];for(n=0;n<M.length;n++)if(L=M[n],r=a.hot._acceptedDependencies[L]){if(-1!==$.indexOf(r))continue;$.push(r)}for(n=0;n<$.length;n++){r=$[n];try{r(M)}catch(e){t.onErrored&&t.onErrored({type:"accept-errored",moduleId:d,dependencyId:M[n],error:e}),t.ignoreErrored||D||(D=e)}}}for(n=0;n<B.length;n++){var H=B[n];d=H.module,s=[d];try{S(d)}catch(e){if("function"==typeof H.errorHandler)try{H.errorHandler(e)}catch(r){t.onErrored&&t.onErrored({type:"self-accept-error-handler-errored",moduleId:d,error:r,originalError:e}),t.ignoreErrored||D||(D=r),D||(D=e)}else t.onErrored&&t.onErrored({type:"self-accept-errored",moduleId:d,error:e}),t.ignoreErrored||D||(D=e)}}return D?(p("fail"),Promise.reject(D)):(p("idle"),new Promise(function(e){e(g)}))}var E={};function S(t){if(E[t])return E[t].exports;var r=E[t]={i:t,l:!1,exports:{},hot:c(t),parents:(a=s,s=[],a),children:[]};return e[t].call(r.exports,r,r.exports,d(t)),r.l=!0,r.exports}return S.m=e,S.c=E,S.d=function(e,t,r){S.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},S.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},S.t=function(e,t){if(1&t&&(e=S(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(S.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var n in e)S.d(r,n,function(t){return e[t]}.bind(null,n));return r},S.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return S.d(t,"a",t),t},S.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},S.p="",S.h=function(){return l},d(11)(S.s=11)}([function(t,r){t.exports=e},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.css=function(e,t){if("object"==typeof t)for(let r in t)e.style[r]=t[r]},t.getRelativeRect=function(e,t){let r=t.getBoundingClientRect();return{x:e.x-r.x-t.scrollLeft,y:e.y-r.y-t.scrollTop,x1:e.x-r.x-t.scrollLeft+e.width,y1:e.y-r.y-t.scrollTop+e.height,width:e.width,height:e.height}},t._omit=function(e,t){return e&&Object.keys(e).reduce((r,n)=>t.includes(n)?r:Object.assign({},r,{[n]:e[n]}),{})}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.CELL_ATTRIBUTES=t.cellId=t.rowId=t.TableViewWrapper=t.TableContainer=t.TableBody=t.TableRow=t.TableCell=t.TableCellLine=t.TableColGroup=t.TableCol=void 0;var n,l=function(){return function(e,t){if(Array.isArray(e))return e;if(Symbol.iterator in Object(e))return function(e,t){var r=[],n=!0,l=!1,o=void 0;try{for(var i,s=e[Symbol.iterator]();!(n=(i=s.next()).done)&&(r.push(i.value),!t||r.length!==t);n=!0);}catch(e){l=!0,o=e}finally{try{!n&&s.return&&s.return()}finally{if(l)throw o}}return r}(e,t);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}(),o=r(0),i=(n=o)&&n.__esModule?n:{default:n},s=r(1);const a=i.default.import("blots/break"),d=i.default.import("blots/block"),c=i.default.import("blots/container"),u=["width"],h={width:100},p=["row","cell"],f=["rowspan","colspan"],b={rowspan:1,colspan:1},m=5;class g extends d{static create(e){const t=super.create(e);return p.forEach(r=>{let n=`${r}Id`;t.setAttribute(`data-${r}`,e[r]||n())}),f.forEach(r=>{t.setAttribute(`data-${r}`,e[r]||b[r])}),t}static formats(e){return f.concat(p).reduce((t,r)=>(e.hasAttribute(`data-${r}`)&&(t[r]=e.getAttribute(`data-${r}`)||void 0),t),{})}format(e,t){f.concat(p).indexOf(e)>-1?t?this.domNode.setAttribute(`data-${e}`,t):this.domNode.removeAttribute(`data-${e}`):super.format(e,t)}optimize(e){const t=this.domNode.getAttribute("data-row"),r=this.domNode.getAttribute("data-rowspan"),n=parseInt(this.domNode.getAttribute("data-colspan"),10);!this.statics.requiredContainer||this.parent instanceof this.statics.requiredContainer||this.wrap(this.statics.requiredContainer.blotName,{row:t,colspan:n,rowspan:r}),super.optimize(e)}tableCell(){return this.parent}}g.blotName="table-cell-line",g.ClassName="qlbt-cell-line",g.tagName="DIV";class y extends c{checkMerge(){if(super.checkMerge()&&null!=this.next.children.head){const e=this.children.head.formats()["table-cell-line"],t=this.children.tail.formats()["table-cell-line"],r=this.next.children.head.formats()["table-cell-line"],n=this.next.children.tail.formats()["table-cell-line"];return e.cell===t.cell&&e.cell===r.cell&&e.cell===n.cell}return!1}static create(e){const t=super.create(e);return t.setAttribute("data-row",e.row),f.forEach(r=>{e[r]&&t.setAttribute(r,e[r])}),t}static formats(e){const t={};return e.hasAttribute("data-row")&&(t.row=e.getAttribute("data-row")),f.reduce((t,r)=>(e.hasAttribute(r)&&(t[r]=e.getAttribute(r)),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")),f.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(r=>{r.format(e,t)})}format(e,t){f.indexOf(e)>-1?(this.toggleAttribute(e,t),this.formatChildren(e,t)):["row"].indexOf(e)>-1?(this.toggleAttribute(`data-${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()}}y.blotName="table",y.tagName="TD";class w extends c{checkMerge(){if(super.checkMerge()&&null!=this.next.children.head){const e=this.children.head.formats(),t=this.children.tail.formats(),r=this.next.children.head.formats(),n=this.next.children.tail.formats();return e.row===t.row&&e.row===r.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-${t}`)&&(e[t]=this.domNode.getAttribute(`data-${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}}w.blotName="table-row",w.tagName="TR";class x extends c{}x.blotName="table-body",x.tagName="TBODY";class v extends d{static create(e){let t=super.create(e);return u.forEach(r=>{t.setAttribute(`${r}`,e[r]||h[r])}),t}static formats(e){return u.reduce((t,r)=>(e.hasAttribute(`${r}`)&&(t[r]=e.getAttribute(`${r}`)||void 0),t),{})}format(e,t){u.indexOf(e)>-1?this.domNode.setAttribute(`${e}`,t||h[e]):super.format(e,t)}html(){return this.domNode.outerHTML}}v.blotName="table-col",v.tagName="col";class C extends c{}C.blotName="table-col-group",C.tagName="colgroup";class N extends c{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()[v.blotName].width,10),0);this.domNode.style.width=`${t}px`},0)}cells(e){return this.rows().map(t=>t.children.at(e))}colGroup(){return this.children.head}deleteColumns(e,t=[],r){var n=this.descendants(x);const o=l(n,1)[0];if(null==o||null==o.children.head)return;const i=this.descendants(y),a=[],d=[];if(i.forEach(t=>{const n=(0,s.getRelativeRect)(t.domNode.getBoundingClientRect(),r);n.x+m>e.x&&n.x1-m<e.x1?a.push(t):n.x<e.x+m&&n.x1>e.x1-m&&d.push(t)}),a.length===i.length)return this.tableDestroy(),!0;t.forEach(e=>{this.colGroup().children.at(t[0]).remove()}),a.forEach(e=>{e.remove()}),d.forEach(e=>{const r=parseInt(e.formats().colspan,10);parseInt(e.formats().width,10);e.format("colspan",r-t.length)}),this.updateTableWidth()}deleteRow(e,t){var r=this.descendants(x);const n=l(r,1)[0];if(null==n||null==n.children.head)return;const o=this.descendants(y),i=[],a=[],d=[];if(o.forEach(r=>{const n=(0,s.getRelativeRect)(r.domNode.getBoundingClientRect(),t);n.y>e.y-m&&n.y1<e.y1+m?i.push(r):n.y<e.y+m&&n.y1>e.y1-m&&(a.push(r),Math.abs(n.y-e.y)<m&&d.push(r))}),i.length===o.length)return void this.tableDestroy();const c=this.rows().reduce((r,n)=>{let l=(0,s.getRelativeRect)(n.domNode.getBoundingClientRect(),t);return l.y>e.y-m&&l.y1<e.y1+m&&(r+=1),r},0);d.forEach(e=>{const r=(0,s.getRelativeRect)(e.domNode.getBoundingClientRect(),t),n=e.parent.next,l=n.children.reduce((e,n)=>{const l=(0,s.getRelativeRect)(n.domNode.getBoundingClientRect(),t);return Math.abs(r.x1-l.x)<m&&(e=n),e},null);n.insertBefore(e,l),e.format("row",n.formats().row)}),i.forEach(e=>{e.remove()}),a.forEach(e=>{const t=parseInt(e.formats().rowspan,10);e.format("rowspan",t-c)})}tableDestroy(){const e=i.default.find(this.scroll.domNode.parentNode),t=e.getModule("better-table");this.remove(),t.hideTableTools(),e.update(i.default.sources.USER)}insertCell(e,t){const r=R(),n=e.formats().row,l=this.scroll.create(y.blotName,Object.assign({},b,{row:n})),o=this.scroll.create(g.blotName,{row:n,cell:r});l.appendChild(o),t?e.insertBefore(l,t):e.appendChild(l)}insertColumn(e,t,r=!0,n){var o=this.descendants(x);const i=l(o,1)[0];var a=this.descendants(C);const d=l(a,1)[0],c=this.descendants(v);let u=[],h=[],p=[];if(null==i||null==i.children.head)return;this.descendants(y).forEach(t=>{const l=(0,s.getRelativeRect)(t.domNode.getBoundingClientRect(),n);r?Math.abs(l.x1-e.x1)<m?u.push(t):e.x1-l.x>m&&e.x1-l.x1<-m&&h.push(t):Math.abs(l.x-e.x)<m?u.push(t):e.x-l.x>m&&e.x-l.x1<-m&&h.push(t)}),u.forEach(e=>{const t=r?e.next:e,n=R(),l=e.parent,o=l.formats().row,i=e.formats(),s=this.scroll.create(y.blotName,Object.assign({},b,{row:o,rowspan:i.rowspan})),a=this.scroll.create(g.blotName,{row:o,cell:n,rowspan:i.rowspan});s.appendChild(a),t?l.insertBefore(s,t):l.appendChild(s),p.push(s)});const f=this.scroll.create(v.blotName,!0);let w=r?c[t].next:c[t];return w?d.insertBefore(f,w):d.appendChild(f),h.forEach(e=>{const t=e.formats().colspan;e.format("colspan",parseInt(t,10)+1),p.push(e)}),p.sort((e,t)=>{return e.domNode.getBoundingClientRect().y-t.domNode.getBoundingClientRect().y}),this.updateTableWidth(),p}insertRow(e,t,r){var n=this.descendants(x);const o=l(n,1)[0];if(null==o||null==o.children.head)return;const i=this.descendants(y),d=q(),c=this.scroll.create(w.blotName,{row:d});let u=[],h=[],p=[];i.forEach(n=>{const l=(0,s.getRelativeRect)(n.domNode.getBoundingClientRect(),r);t?Math.abs(l.y1-e.y1)<m?u.push(n):e.y1-l.y>m&&e.y1-l.y1<-m&&h.push(n):Math.abs(l.y-e.y)<m?u.push(n):e.y-l.y>m&&e.y-l.y1<-m&&h.push(n)});const f=(e,t)=>{return e.domNode.getBoundingClientRect().x-t.domNode.getBoundingClientRect().x};u.sort(f),u.forEach(e=>{const t=R(),r=e.formats(),n=this.scroll.create(y.blotName,Object.assign({},b,{row:d,colspan:r.colspan})),l=this.scroll.create(g.blotName,{row:d,cell:t,colspan:r.colspan}),o=this.scroll.create(a.blotName);l.appendChild(o),n.appendChild(l),c.appendChild(n),p.push(n)}),h.forEach(e=>{const t=parseInt(e.formats().rowspan,10);e.format("rowspan",t+1),p.push(e)});const v=this.rows().find(n=>{let l=(0,s.getRelativeRect)(n.domNode.getBoundingClientRect(),r);return t?Math.abs(l.y-e.y-e.height)<m:Math.abs(l.y-e.y)<m});return o.insertBefore(c,v),p.sort(f),p}mergeCells(e,t,r,n,l){const o=t.reduce((e,t,l)=>(0!==l?(e&&t.moveChildren(e),t.remove()):(t.format("colspan",n),t.format("rowspan",r),e=t),e),null);let i=o.domNode.getAttribute("data-row"),s=o.children.head.domNode.getAttribute("data-cell");return o.children.forEach(e=>{e.format("cell",s),e.format("row",i),e.format("colspan",n),e.format("rowspan",r)}),o}unmergeCells(e,t){let r={},n=1,l=1;e.forEach(e=>{if(r=e.formats(),n=r.rowspan,(l=r.colspan)>1){let t=e.next,r=e.row();e.format("colspan",1);for(let e=l;e>1;e--)this.insertCell(r,t)}if(n>1){let r=n,o=e.row().next;for(;r>1;){let n=o.children.reduce((r,n)=>{let l=(0,s.getRelativeRect)(e.domNode.getBoundingClientRect(),t),o=(0,s.getRelativeRect)(n.domNode.getBoundingClientRect(),t);return Math.abs(l.x1-o.x)<m&&(r=n),r},null);for(let e=l;e>0;e--)this.insertCell(o,n);r-=1,o=o.next}e.format("rowspan",1)}})}rows(){const e=this.children.tail;return null==e?[]:e.children.map(e=>e)}}N.blotName="table-container",N.className="quill-better-table",N.tagName="TABLE";class T extends c{constructor(e,t){super(e,t);const r=i.default.find(e.domNode.parentNode);t.addEventListener("scroll",e=>{const t=r.getModule("better-table");t.columnTool&&(t.columnTool.domNode.scrollLeft=e.target.scrollLeft),t.tableSelection&&t.tableSelection.selectedTds.length>0&&t.tableSelection.repositionHelpLines()},!1)}}function q(){return`row-${Math.random().toString(36).slice(2,6)}`}function R(){return`cell-${Math.random().toString(36).slice(2,6)}`}T.blotName="table-view",T.className="quill-better-table-wrapper",T.tagName="DIV",T.allowedChildren=[N],N.requiredContainer=T,N.allowedChildren=[x,C],x.requiredContainer=N,x.allowedChildren=[w],w.requiredContainer=x,w.allowedChildren=[y],y.requiredContainer=w,y.allowedChildren=[g],g.requiredContainer=y,C.allowedChildren=[v],C.requiredContainer=N,v.requiredContainer=C,t.TableCol=v,t.TableColGroup=C,t.TableCellLine=g,t.TableCell=y,t.TableRow=w,t.TableBody=x,t.TableContainer=N,t.TableViewWrapper=T,t.rowId=q,t.cellId=R,t.CELL_ATTRIBUTES=f},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=function(){return function(e,t){if(Array.isArray(e))return e;if(Symbol.iterator in Object(e))return function(e,t){var r=[],n=!0,l=!1,o=void 0;try{for(var i,s=e[Symbol.iterator]();!(n=(i=s.next()).done)&&(r.push(i.value),!t||r.length!==t);n=!0);}catch(e){l=!0,o=e}finally{try{!n&&s.return&&s.return()}finally{if(l)throw o}}return r}(e,t);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}(),l=c(r(0)),o=c(r(4)),i=c(r(5)),s=c(r(6)),a=r(7),d=r(2);function c(e){return e&&e.__esModule?e:{default:e}}const u=l.default.import("core/module"),h=l.default.import("delta");class p extends u{static register(){l.default.register(d.TableCol,!0),l.default.register(d.TableColGroup,!0),l.default.register(d.TableCellLine,!0),l.default.register(d.TableCell,!0),l.default.register(d.TableRow,!0),l.default.register(d.TableBody,!0),l.default.register(d.TableContainer,!0),l.default.register(d.TableViewWrapper,!0)}constructor(e,t){super(e,t),this.quill.root.addEventListener("click",r=>{if(!r.path||r.path.length<=0)return;const n=r.path.filter(e=>e.tagName&&"TABLE"===e.tagName.toUpperCase()&&e.classList.contains("quill-better-table"))[0];if(n){if(this.table===n)return;this.table&&this.hideTableTools(),this.showTableTools(n,e,t)}else this.table&&this.hideTableTools()},!1),this.quill.root.addEventListener("contextmenu",r=>{if(!this.table)return!0;if(r.preventDefault(),!r.path||r.path.length<=0)return;const n=r.path.filter(e=>e.tagName&&"TABLE"===e.tagName.toUpperCase()&&e.classList.contains("quill-better-table"))[0],l=r.path.filter(e=>e.tagName&&"TR"===e.tagName.toUpperCase()&&e.getAttribute("data-row"))[0],o=r.path.filter(e=>e.tagName&&"TD"===e.tagName.toUpperCase()&&e.getAttribute("data-row"))[0];let i=this.tableSelection.selectedTds.map(e=>e.domNode).includes(o);(this.tableSelection.selectedTds.length<=0||!i)&&this.tableSelection.setSelection(o.getBoundingClientRect(),o.getBoundingClientRect()),this.tableOperationMenu&&(this.tableOperationMenu=this.tableOperationMenu.destroy()),n&&(this.tableOperationMenu=new s.default({table:n,row:l,cell:o,left:r.pageX,top:r.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;var r=this.quill.getLine(e.index);const l=n(r,1)[0];if(0===t.offset){var o=this.quill.getLine(e.index-1);const t=n(o,1)[0];if(null!=t&&"table-cell-line"===t.statics.blotName&&"table-cell-line"!==l.statics.blotName)return!1}return!0});let r=e.keyboard.bindings.Backspace.pop();e.keyboard.bindings.Backspace.splice(0,1,r),e.clipboard.addMatcher("td",a.matchTableCell),e.clipboard.addMatcher("th",a.matchTableHeader),e.clipboard.addMatcher("table",a.matchTable),e.clipboard.matchers=e.clipboard.matchers.filter(e=>"tr"!==e[0])}getTable(e=this.quill.getSelection()){if(null==e)return[null,null,null,-1];var t=this.quill.getLine(e.index),r=n(t,2);const l=r[0],o=r[1];if(null==l||l.statics.blotName!==d.TableCellLine.blotName)return[null,null,null,-1];const i=l.tableCell(),s=i.row();return[s.table(),s,i,o]}insertTable(e,t){const r=this.quill.getSelection(!0);if(null==r)return;this.quill.getLeaf(r.index)[0],this.quill.getLeaf(r.index+1)[0];let n=(new h).retain(r.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 r=(0,d.rowId)();return new Array(t).fill("\n").reduce((e,t)=>(e.insert(t,{"table-cell-line":{row:r,cell:(0,d.cellId)()}}),e),e)},n),this.quill.updateContents(n,l.default.sources.USER),this.quill.setSelection(r.index+t+1,l.default.sources.API)}showTableTools(e,t,r){this.table=e,this.columnTool=new o.default(e,t,r),this.tableSelection=new i.default(e,t,r)}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}}p.keyboardBindings={"table-cell-line backspace":{key:"Backspace",format:["table-cell-line"],collapsed:!0,offset:0,handler(e,t){var r=this.quill.getLine(e.index),l=n(r,2);const o=l[0];l[1];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 r=l.default.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,r.BLOCK)&&!Array.isArray(t.format[n])&&(e[n]=t.format[n]),e),{});this.quill.insertText(e.index,"\n",n["table-cell-line"],l.default.sources.USER),this.quill.setSelection(e.index+1,l.default.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],l.default.sources.USER))})}}},t.default=p},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n,l=r(0),o=(n=l)&&n.__esModule?n:{default:n},i=r(1);const s=12,a=12,d=50,c="#35A7ED";t.default=class{constructor(e,t,r){if(!e)return null;this.table=e,this.quill=t,this.options=r,this.domNode=null,this.initColTool()}initColTool(){const e=this.quill.root.parentNode,t=(this.table.getBoundingClientRect(),e.getBoundingClientRect()),r=this.table.parentNode.getBoundingClientRect();this.domNode=document.createElement("div"),this.domNode.classList.add("qlbt-col-tool"),this.updateToolCells(),e.appendChild(this.domNode),(0,i.css)(this.domNode,{width:`${r.width}px`,height:`${s}px`,left:`${r.left-t.left+e.scrollLeft}px`,top:`${r.top-t.top+e.scrollTop-s-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"),(0,i.css)(e,{height:`${a}px`}),e.appendChild(t),e}updateToolCells(){const e=o.default.find(this.table),t=e.children.tail.children.head.children,r=e.colGroup().children,n=function(e){return e.reduce((e,t)=>{const r=t.formats().colspan;return e+=parseInt(r,10)},0)}(t);let l=Array.from(this.domNode.querySelectorAll(".qlbt-col-tool-cell"));for(let e=0;e<Math.max(n,l.length);e++){let t=r.at(e),o=t&&parseInt(t.formats()[t.statics.blotName].width,10),s=null;l[e]?l[e]&&e>=n?l[e].remove():(s=l[e],(0,i.css)(s,{"min-width":`${o}px`})):(s=this.createToolCell(),this.domNode.appendChild(s),this.addColCellHolderHandler(s),(0,i.css)(s,{"min-width":`${o}px`}))}}destroy(){return this.domNode.remove(),null}addColCellHolderHandler(e){const t=o.default.find(this.table),r=e.querySelector(".qlbt-col-tool-cell-holder");let n=!1,l=0,a=0,u=0,h=0,p={},f={},b=null;const m=e=>{e.preventDefault(),n&&(a=e.clientX,u=h+a-l>=d?a-l:d-h,(0,i.css)(b,{left:`${f.left+f.width-1+u}px`}))},g=o=>{o.preventDefault();const s=Array.from(this.domNode.querySelectorAll(".qlbt-col-tool-cell")).indexOf(e),d=t.colGroup().children.at(s);n&&(d.format("width",h+u),(0,i.css)(e,{"min-width":`${h+u}px`}),l=0,a=0,u=0,h=0,n=!1,r.classList.remove("dragging")),document.removeEventListener("mousemove",m,!1),document.removeEventListener("mouseup",g,!1),p={},f={},b.remove(),b=null,t.updateTableWidth();const c=this.quill.getModule("better-table").tableSelection;c&&c.clearSelection()};r.addEventListener("mousedown",t=>{document.addEventListener("mousemove",m,!1),document.addEventListener("mouseup",g,!1),p=this.table.getBoundingClientRect(),f=e.getBoundingClientRect(),b=document.createElement("div"),(0,i.css)(b,{position:"fixed",top:`${f.top}px`,left:`${f.left+f.width-1}px`,zIndex:"100",height:`${p.height+s+4}px`,width:"1px",backgroundColor:c}),document.body.appendChild(b),n=!0,l=t.clientX,h=f.width,r.classList.add("dragging")},!1)}colToolCells(){return Array.from(this.domNode.querySelectorAll(".qlbt-col-tool-cell"))}}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n,l=r(0),o=(n=l)&&n.__esModule?n:{default:n},i=r(1),s=r(2);const a="#35A7ED",d=["left","right","top","bottom"],c=2;function u(e,t){let r=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),l=Math.min(e.y,t.y,e.y+e.height-1,t.y+t.height-1),o=Math.max(e.y,t.y,e.y+e.height-1,t.y+t.height-1);return{x:r,x1:n,y:l,y1:o,width:n-r,height:o-l}}t.default=class{constructor(e,t,r){if(!e)return null;this.table=e,this.quill=t,this.options=r,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"),(0,i.css)(this[t],{position:"absolute",display:"none","background-color":a}),e.appendChild(this[t])})}mouseDownHandler(e){if(0!==e.button||!e.target.closest(".quill-better-table"))return;this.quill.root.addEventListener("mousemove",l,!1),this.quill.root.addEventListener("mouseup",function e(r){t.quill.root.removeEventListener("mousemove",l,!1),t.quill.root.removeEventListener("mouseup",e,!1),t.dragging=!1},!1);const t=this,r=e.target.closest("td[data-row]"),n=(0,i.getRelativeRect)(r.getBoundingClientRect(),this.quill.root.parentNode);function l(e){if(0!==e.button||!e.target.closest(".quill-better-table"))return;const l=e.target.closest("td[data-row]"),o=(0,i.getRelativeRect)(l.getBoundingClientRect(),t.quill.root.parentNode);t.boundary=u(n,o),t.correctBoundary(),t.selectedTds=t.computeSelectedTds(),t.repositionHelpLines(),r!==l&&t.quill.blur()}this.dragging=!0,this.boundary=u(n,n),this.correctBoundary(),this.selectedTds=this.computeSelectedTds(),this.repositionHelpLines()}correctBoundary(){o.default.find(this.table).descendants(s.TableCell).forEach(e=>{var t=(0,i.getRelativeRect)(e.domNode.getBoundingClientRect(),this.quill.root.parentNode);let r=t.x,n=t.y,l=t.width,o=t.height;(r+c>=this.boundary.x&&r+c<=this.boundary.x1||r-c+l>=this.boundary.x&&r-c+l<=this.boundary.x1)&&(n+c>=this.boundary.y&&n+c<=this.boundary.y1||n-c+o>=this.boundary.y&&n-c+o<=this.boundary.y1)&&(this.boundary=u(this.boundary,{x:r,y:n,width:l,height:o}))})}computeSelectedTds(){return o.default.find(this.table).descendants(s.TableCell).reduce((e,t)=>{var r=(0,i.getRelativeRect)(t.domNode.getBoundingClientRect(),this.quill.root.parentNode);let n=r.x,l=r.y,o=r.width,s=r.height;return n+c>=this.boundary.x&&n-c+o<=this.boundary.x1&&l+c>=this.boundary.y&&l-c+s<=this.boundary.y1&&e.push(t),e},[])}repositionHelpLines(){const e=this.table.parentNode.scrollLeft;(0,i.css)(this.left,{display:"block",left:`${this.boundary.x-e-1}px`,top:`${this.boundary.y}px`,height:`${this.boundary.height+1}px`,width:"1px"}),(0,i.css)(this.right,{display:"block",left:`${this.boundary.x1-e}px`,top:`${this.boundary.y}px`,height:`${this.boundary.height+1}px`,width:"1px"}),(0,i.css)(this.top,{display:"block",left:`${this.boundary.x-1-e}px`,top:`${this.boundary.y}px`,width:`${this.boundary.width+1}px`,height:"1px"}),(0,i.css)(this.bottom,{display:"block",left:`${this.boundary.x-1-e}px`,top:`${this.boundary.y1+1}px`,width:`${this.boundary.width+1}px`,height:"1px"})}refreshHelpLinesPosition(){const e=(0,i.getRelativeRect)(this.selectedTds[0].domNode.getBoundingClientRect(),this.quill.root.parentNode),t=(0,i.getRelativeRect)(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((0,i.getRelativeRect)(e,this.quill.root.parentNode),(0,i.getRelativeRect)(t,this.quill.root.parentNode)),this.correctBoundary(),this.selectedTds=this.computeSelectedTds(),this.repositionHelpLines()}clearSelection(){this.boundary={},this.selectedTds=[],d.forEach(e=>{this[e]&&(0,i.css)(this[e],{display:"none"})})}}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n,l=r(0),o=(n=l)&&n.__esModule?n:{default:n},i=r(1);const s=150,a=200,d={insertColumnRight:{text:"Insert column right",handler(){const e=o.default.find(this.table);let t=c(this.columnToolCells,this.boundary,(e,t)=>Math.abs(e.x+e.width-t.x1)<=5,this.quill.root.parentNode);const r=e.insertColumn(this.boundary,t,!0,this.quill.root.parentNode);this.tableColumnTool.updateToolCells(),this.quill.update(o.default.sources.USER),this.quill.setSelection(this.quill.getIndex(r[0]),0,o.default.sources.SILENT),this.tableSelection.setSelection(r[0].domNode.getBoundingClientRect(),r[0].domNode.getBoundingClientRect())}},insertColumnLeft:{text:"Insert column left",handler(){const e=o.default.find(this.table);let t=c(this.columnToolCells,this.boundary,(e,t)=>Math.abs(e.x-t.x)<=5,this.quill.root.parentNode);const r=e.insertColumn(this.boundary,t,!1,this.quill.root.parentNode);this.tableColumnTool.updateToolCells(),this.quill.update(o.default.sources.USER),this.quill.setSelection(this.quill.getIndex(r[0]),0,o.default.sources.SILENT),this.tableSelection.setSelection(r[0].domNode.getBoundingClientRect(),r[0].domNode.getBoundingClientRect())}},insertRowUp:{text:"Insert row up",handler(){const e=o.default.find(this.table).insertRow(this.boundary,!1,this.quill.root.parentNode);this.quill.update(o.default.sources.USER),this.quill.setSelection(this.quill.getIndex(e[0]),0,o.default.sources.SILENT),this.tableSelection.setSelection(e[0].domNode.getBoundingClientRect(),e[0].domNode.getBoundingClientRect())}},insertRowDown:{text:"Insert row down",handler(){const e=o.default.find(this.table).insertRow(this.boundary,!0,this.quill.root.parentNode);this.quill.update(o.default.sources.USER),this.quill.setSelection(this.quill.getIndex(e[0]),0,o.default.sources.SILENT),this.tableSelection.setSelection(e[0].domNode.getBoundingClientRect(),e[0].domNode.getBoundingClientRect())}},mergeCells:{text:"Merge selected cells",handler(){const e=o.default.find(this.table),t=e.rows().reduce((e,t)=>{let r=(0,i.getRelativeRect)(t.domNode.getBoundingClientRect(),this.quill.root.parentNode);return r.y>this.boundary.y-5&&r.y+r.height<this.boundary.y+this.boundary.height+5&&(e+=1),e},0),r=this.columnToolCells.reduce((e,t)=>{let r=(0,i.getRelativeRect)(t.getBoundingClientRect(),this.quill.root.parentNode);return r.x>this.boundary.x-5&&r.x+r.width<this.boundary.x+this.boundary.width+5&&(e+=1),e},0),n=e.mergeCells(this.boundary,this.selectedTds,t,r,this.quill.root.parentNode);this.quill.update(o.default.sources.USER),this.tableSelection.setSelection(n.domNode.getBoundingClientRect(),n.domNode.getBoundingClientRect())}},unmergeCells:{text:"Unmerge cells",handler(){o.default.find(this.table).unmergeCells(this.selectedTds,this.quill.root.parentNode),this.quill.update(o.default.sources.USER),this.tableSelection.clearSelection()}},deleteColumn:{text:"Delete selected columns",handler(){const e=o.default.find(this.table);let t=(r=this.columnToolCells,n=this.boundary,l=((e,t)=>e.x+5>t.x&&e.x+e.width-5<t.x1),s=this.quill.root.parentNode,r.reduce((e,t)=>{let o=(0,i.getRelativeRect)(t.getBoundingClientRect(),s);return l(o,n)&&e.push(r.indexOf(t)),e},[]));var r,n,l,s;e.deleteColumns(this.boundary,t,this.quill.root.parentNode)||(this.tableColumnTool.updateToolCells(),this.quill.update(o.default.sources.USER),this.tableSelection.clearSelection())}},deleteRow:{text:"Delete selected rows",handler(){o.default.find(this.table).deleteRow(this.boundary,this.quill.root.parentNode),this.quill.update(o.default.sources.USER),this.tableSelection.clearSelection()}},deleteTable:{text:"Delete table",handler(){const e=this.quill.getModule("better-table"),t=o.default.find(this.table);e.hideTableTools(),t.remove(),this.quill.update(o.default.sources.USER)}}};function c(e,t,r,n){return e.reduce((l,o)=>{let s=(0,i.getRelativeRect)(o.getBoundingClientRect(),n);return r(s,t)&&(l=e.indexOf(o)),l},!1)}t.default=class{constructor(e,t,r){const n=t.getModule("better-table");this.tableSelection=n.tableSelection,this.table=e.table,this.quill=t,this.options=r,this.menuItems=Object.assign({},d,r.items),this.tableColumnTool=n.columnTool,this.boundary=this.tableSelection.boundary,this.selectedTds=this.tableSelection.selectedTds,this.destroyHanlder=this.destroy.bind(this),this.columnToolCells=this.tableColumnTool.colToolCells(),this.menuInitial(e),this.mount(),document.addEventListener("click",this.destroyHanlder,!1)}mount(){document.body.appendChild(this.domNode)}destroy(){return this.domNode.remove(),document.removeEventListener("click",this.destroyHanlder,!1),null}menuInitial({table:e,left:t,top:r}){this.domNode=document.createElement("div"),this.domNode.classList.add("qlbt-operation-menu"),(0,i.css)(this.domNode,{position:"absolute",left:`${t}px`,top:`${r}px`,"min-height":`${s}px`,width:`${a}px`});for(let e in this.menuItems)this.menuItems[e]&&this.domNode.appendChild(this.menuItemCreator(Object.assign({},d[e],this.menuItems[e])))}menuItemCreator({text:e,handler:t}){const r=document.createElement("div");return r.classList.add("qlbt-operation-menu-item"),r.innerText=e,r.addEventListener("click",t.bind(this),!1),r}}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.matchTableCell=function(e,t,r){const n=e.parentNode,l="TABLE"===n.parentNode.tagName?n.parentNode:n.parentNode.parentNode,o=Array.from(l.querySelectorAll("tr")),a=Array.from(n.querySelectorAll("td")),d=o.indexOf(n)+1,c=a.indexOf(e)+1,u=e.getAttribute("colspan")||!1,h=e.getAttribute("rowspan")||!1;if(0===t.length())return t=(new s).insert("\n",{"table-cell-line":{row:d,cell:c,rowspan:h,colspan:u}});return(t=t.reduce((e,t)=>{if(t.insert&&"string"==typeof t.insert){const r=[];let n=t.insert,l=0;for(let e=0;e<t.insert.length;e++)"\n"===n.charAt(e)&&(0===e?r.push("\n"):(r.push(n.substring(l,e)),r.push("\n")),l=e+1);const o=n.substring(l);o&&r.push(o),r.forEach(r=>{"\n"===r?e.insert("\n",t.attributes):e.insert(r,(0,i._omit)(t.attributes,["table","table-cell-line"]))})}else e.insert(t.insert,t.attributes);return e},new s)).reduce((e,t)=>(t.insert&&"string"==typeof t.insert&&t.insert.startsWith("\n")?e.insert(t.insert,Object.assign({},Object.assign({},{row:d},t.attributes.table),{"table-cell-line":{row:d,cell:c,rowspan:h,colspan:u}},(0,i._omit)(t.attributes,["table"]))):e.insert(t.insert,Object.assign({},(0,i._omit)(t.attributes,["table","table-cell-line"]))),e),new s)},t.matchTableHeader=function(e,t,r){const n=e.parentNode,l="TABLE"===n.parentNode.tagName?n.parentNode:n.parentNode.parentNode,o=Array.from(l.querySelectorAll("tr")),a=Array.from(n.querySelectorAll("th")),d=o.indexOf(n)+1,c=a.indexOf(e)+1,u=e.getAttribute("colspan")||!1,h=e.getAttribute("rowspan")||!1;if(0===t.length())return t=(new s).insert("\n",{"table-cell-line":{row:d,cell:c,rowspan:h,colspan:u}});return(t=t.reduce((e,t)=>{if(t.insert&&"string"==typeof t.insert){const r=[];let n=t.insert,l=0;for(let e=0;e<t.insert.length;e++)"\n"===n.charAt(e)&&(0===e?r.push("\n"):(r.push(n.substring(l,e)),r.push("\n")),l=e+1);const o=n.substring(l);o&&r.push(o),r.indexOf("\n")<0&&r.push("\n"),r.forEach(r=>{"\n"===r?e.insert("\n",{"table-cell-line":{row:d,cell:c,rowspan:h,colspan:u}}):e.insert(r,t.attributes)})}else e.insert(t.insert,t.attributes);return e},new s)).reduce((e,t)=>(t.insert&&"string"==typeof t.insert&&t.insert.startsWith("\n")?e.insert(t.insert,Object.assign({},{"table-cell-line":{row:d,cell:c,rowspan:h,colspan:u}})):e.insert(t.insert,Object.assign({},(0,i._omit)(t.attributes,["table","table-cell-line"]))),e),new s)},t.matchTable=function(e,t,r){let n=new s;const l=e.querySelector("tr"),o=Array.from(l.querySelectorAll("td")).concat(Array.from(l.querySelectorAll("th"))).reduce((e,t)=>{const r=t.getAttribute("colspan")||1;return e+=parseInt(r,10)},0),i=e.querySelectorAll("col").length;if(i===o)return t;{for(let e=0;e<o-i;e++)n.insert("\n",{"table-col":!0});if(0===i)return n.concat(t);let e=0;return t.reduce((t,r)=>(t.insert(r.insert,r.attributes),r.attributes&&r.attributes["table-col"]&&(e+=r.insert.length)===i&&(t=t.concat(n)),t),new s)}};var n,l=r(0),o=(n=l)&&n.__esModule?n:{default:n},i=r(1);const s=o.default.import("delta")},function(e,t,r){},,,function(e,t,r){"use strict";var n,l=r(3),o=(n=l)&&n.__esModule?n:{default:n};r(8),Quill.register({"modules/better-table":o.default},!0),window.onload=(()=>{let e=new Quill("#editor-wrapper",{theme:"snow",modules:{table:!1,"better-table":{operationMenu:{items:{unmergeCells:{text:"Another unmerge cells name"}}}},keyboard:{bindings:o.default.keyboardBindings}}}).getModule("better-table");document.body.querySelector("#insert-table").onclick=(()=>{e.insertTable(3,3)}),document.body.querySelector("#get-table").onclick=(()=>{console.log(e.getTable())})})}]).default});
!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,r){!function(e,t){if(!v[e]||!x[e])return;for(var r in x[e]=!1,t)Object.prototype.hasOwnProperty.call(t,r)&&(b[r]=t[r]);0==--g&&0===y&&q()}(e,r),t&&t(e,r)};var r,n=!0,l="8e86b065f4f6db1f1756",o=1e4,i={},s=[],a=[];function d(e){var t=E[e];if(!t)return S;var n=function(n){return t.hot.active?(E[n]?-1===E[n].parents.indexOf(e)&&E[n].parents.push(e):(s=[e],r=n),-1===t.children.indexOf(n)&&t.children.push(n)):(console.warn("[HMR] unexpected require("+n+") from disposed module "+e),s=[]),S(n)},l=function(e){return{configurable:!0,enumerable:!0,get:function(){return S[e]},set:function(t){S[e]=t}}};for(var o in S)Object.prototype.hasOwnProperty.call(S,o)&&"e"!==o&&"t"!==o&&Object.defineProperty(n,o,l(o));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]||T(e),0===y&&0===g&&q())}},n.t=function(e,t){return 1&t&&(e=n(e)),S.t(e,-2&t)},n}function c(e){var t={_acceptedDependencies:{},_declinedDependencies:{},_selfAccepted:!1,_selfDeclined:!1,_disposeHandlers:[],_main:r!==e,active:!0,accept:function(e,r){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<e.length;n++)t._acceptedDependencies[e[n]]=r||function(){};else t._acceptedDependencies[e]=r||function(){}},decline:function(e){if(void 0===e)t._selfDeclined=!0;else if("object"==typeof e)for(var r=0;r<e.length;r++)t._declinedDependencies[e[r]]=!0;else t._declinedDependencies[e]=!0},dispose:function(e){t._disposeHandlers.push(e)},addDisposeHandler:function(e){t._disposeHandlers.push(e)},removeDisposeHandler:function(e){var r=t._disposeHandlers.indexOf(e);r>=0&&t._disposeHandlers.splice(r,1)},check:N,apply:R,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:i[e]};return r=void 0,t}var u=[],h="idle";function p(e){h=e;for(var t=0;t<u.length;t++)u[t].call(null,e)}var f,b,m,g=0,y=0,w={},x={},v={};function C(e){return+e+""===e?+e:e}function N(e){if("idle"!==h)throw new Error("check() is only allowed in idle status");return n=e,p("check"),(t=o,t=t||1e4,new Promise(function(e,r){if("undefined"==typeof XMLHttpRequest)return r(new Error("No browser support"));try{var n=new XMLHttpRequest,o=S.p+""+l+".hot-update.json";n.open("GET",o,!0),n.timeout=t,n.send(null)}catch(e){return r(e)}n.onreadystatechange=function(){if(4===n.readyState)if(0===n.status)r(new Error("Manifest request to "+o+" timed out."));else if(404===n.status)e();else if(200!==n.status&&304!==n.status)r(new Error("Manifest request to "+o+" failed."));else{try{var t=JSON.parse(n.responseText)}catch(e){return void r(e)}e(t)}}})).then(function(e){if(!e)return p("idle"),null;x={},w={},v=e.c,m=e.h,p("prepare");var t=new Promise(function(e,t){f={resolve:e,reject:t}});b={};return T(0),"prepare"===h&&0===y&&0===g&&q(),t});var t}function T(e){v[e]?(x[e]=!0,g++,function(e){var t=document.createElement("script");t.charset="utf-8",t.src=S.p+""+e+"."+l+".hot-update.js",document.head.appendChild(t)}(e)):w[e]=!0}function q(){p("ready");var e=f;if(f=null,e)if(n)Promise.resolve().then(function(){return R(n)}).then(function(t){e.resolve(t)},function(t){e.reject(t)});else{var t=[];for(var r in b)Object.prototype.hasOwnProperty.call(b,r)&&t.push(C(r));e.resolve(t)}}function R(t){if("ready"!==h)throw new Error("apply() is only allowed in ready status");var r,n,o,a,d;function c(e){for(var t=[e],r={},n=t.slice().map(function(e){return{chain:[e],id:e}});n.length>0;){var l=n.pop(),o=l.id,i=l.chain;if((a=E[o])&&!a.hot._selfAccepted){if(a.hot._selfDeclined)return{type:"self-declined",chain:i,moduleId:o};if(a.hot._main)return{type:"unaccepted",chain:i,moduleId:o};for(var s=0;s<a.parents.length;s++){var d=a.parents[s],c=E[d];if(c){if(c.hot._declinedDependencies[o])return{type:"declined",chain:i.concat([d]),moduleId:o,parentId:d};-1===t.indexOf(d)&&(c.hot._acceptedDependencies[o]?(r[d]||(r[d]=[]),u(r[d],[o])):(delete r[d],t.push(d),n.push({chain:i.concat([d]),id:d})))}}}}return{type:"accepted",moduleId:e,outdatedModules:t,outdatedDependencies:r}}function u(e,t){for(var r=0;r<t.length;r++){var n=t[r];-1===e.indexOf(n)&&e.push(n)}}t=t||{};var f={},g=[],y={},w=function(){console.warn("[HMR] unexpected require("+N.moduleId+") to disposed module")};for(var x in b)if(Object.prototype.hasOwnProperty.call(b,x)){var N;d=C(x);var T=!1,q=!1,R=!1,A="";switch((N=b[x]?c(d):{type:"disposed",moduleId:x}).chain&&(A="\nUpdate propagation: "+N.chain.join(" -> ")),N.type){case"self-declined":t.onDeclined&&t.onDeclined(N),t.ignoreDeclined||(T=new Error("Aborted because of self decline: "+N.moduleId+A));break;case"declined":t.onDeclined&&t.onDeclined(N),t.ignoreDeclined||(T=new Error("Aborted because of declined dependency: "+N.moduleId+" in "+N.parentId+A));break;case"unaccepted":t.onUnaccepted&&t.onUnaccepted(N),t.ignoreUnaccepted||(T=new Error("Aborted because "+d+" is not accepted"+A));break;case"accepted":t.onAccepted&&t.onAccepted(N),q=!0;break;case"disposed":t.onDisposed&&t.onDisposed(N),R=!0;break;default:throw new Error("Unexception type "+N.type)}if(T)return p("abort"),Promise.reject(T);if(q)for(d in y[d]=b[d],u(g,N.outdatedModules),N.outdatedDependencies)Object.prototype.hasOwnProperty.call(N.outdatedDependencies,d)&&(f[d]||(f[d]=[]),u(f[d],N.outdatedDependencies[d]));R&&(u(g,[N.moduleId]),y[d]=w)}var O,B=[];for(n=0;n<g.length;n++)d=g[n],E[d]&&E[d].hot._selfAccepted&&B.push({module:d,errorHandler:E[d].hot._selfAccepted});p("dispose"),Object.keys(v).forEach(function(e){!1===v[e]&&function(e){delete installedChunks[e]}(e)});for(var L,M,_=g.slice();_.length>0;)if(d=_.pop(),a=E[d]){var I={},j=a.hot._disposeHandlers;for(o=0;o<j.length;o++)(r=j[o])(I);for(i[d]=I,a.hot.active=!1,delete E[d],delete f[d],o=0;o<a.children.length;o++){var k=E[a.children[o]];k&&((O=k.parents.indexOf(d))>=0&&k.parents.splice(O,1))}}for(d in f)if(Object.prototype.hasOwnProperty.call(f,d)&&(a=E[d]))for(M=f[d],o=0;o<M.length;o++)L=M[o],(O=a.children.indexOf(L))>=0&&a.children.splice(O,1);for(d in p("apply"),l=m,y)Object.prototype.hasOwnProperty.call(y,d)&&(e[d]=y[d]);var D=null;for(d in f)if(Object.prototype.hasOwnProperty.call(f,d)&&(a=E[d])){M=f[d];var $=[];for(n=0;n<M.length;n++)if(L=M[n],r=a.hot._acceptedDependencies[L]){if(-1!==$.indexOf(r))continue;$.push(r)}for(n=0;n<$.length;n++){r=$[n];try{r(M)}catch(e){t.onErrored&&t.onErrored({type:"accept-errored",moduleId:d,dependencyId:M[n],error:e}),t.ignoreErrored||D||(D=e)}}}for(n=0;n<B.length;n++){var H=B[n];d=H.module,s=[d];try{S(d)}catch(e){if("function"==typeof H.errorHandler)try{H.errorHandler(e)}catch(r){t.onErrored&&t.onErrored({type:"self-accept-error-handler-errored",moduleId:d,error:r,originalError:e}),t.ignoreErrored||D||(D=r),D||(D=e)}else t.onErrored&&t.onErrored({type:"self-accept-errored",moduleId:d,error:e}),t.ignoreErrored||D||(D=e)}}return D?(p("fail"),Promise.reject(D)):(p("idle"),new Promise(function(e){e(g)}))}var E={};function S(t){if(E[t])return E[t].exports;var r=E[t]={i:t,l:!1,exports:{},hot:c(t),parents:(a=s,s=[],a),children:[]};return e[t].call(r.exports,r,r.exports,d(t)),r.l=!0,r.exports}return S.m=e,S.c=E,S.d=function(e,t,r){S.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},S.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},S.t=function(e,t){if(1&t&&(e=S(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(S.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var n in e)S.d(r,n,function(t){return e[t]}.bind(null,n));return r},S.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return S.d(t,"a",t),t},S.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},S.p="",S.h=function(){return l},d(11)(S.s=11)}([function(t,r){t.exports=e},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.css=function(e,t){if("object"==typeof t)for(let r in t)e.style[r]=t[r]},t.getRelativeRect=function(e,t){let r=t.getBoundingClientRect();return{x:e.x-r.x-t.scrollLeft,y:e.y-r.y-t.scrollTop,x1:e.x-r.x-t.scrollLeft+e.width,y1:e.y-r.y-t.scrollTop+e.height,width:e.width,height:e.height}},t._omit=function(e,t){return e&&Object.keys(e).reduce((r,n)=>t.includes(n)?r:Object.assign({},r,{[n]:e[n]}),{})}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.CELL_ATTRIBUTES=t.cellId=t.rowId=t.TableViewWrapper=t.TableContainer=t.TableBody=t.TableRow=t.TableCell=t.TableCellLine=t.TableColGroup=t.TableCol=void 0;var n,l=function(){return function(e,t){if(Array.isArray(e))return e;if(Symbol.iterator in Object(e))return function(e,t){var r=[],n=!0,l=!1,o=void 0;try{for(var i,s=e[Symbol.iterator]();!(n=(i=s.next()).done)&&(r.push(i.value),!t||r.length!==t);n=!0);}catch(e){l=!0,o=e}finally{try{!n&&s.return&&s.return()}finally{if(l)throw o}}return r}(e,t);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}(),o=r(0),i=(n=o)&&n.__esModule?n:{default:n},s=r(1);const a=i.default.import("blots/break"),d=i.default.import("blots/block"),c=i.default.import("blots/container"),u=["width"],h={width:100},p=["row","cell"],f=["rowspan","colspan"],b={rowspan:1,colspan:1},m=5;class g extends d{static create(e){const t=super.create(e);return p.forEach(r=>{let n=`${r}Id`;t.setAttribute(`data-${r}`,e[r]||n())}),f.forEach(r=>{t.setAttribute(`data-${r}`,e[r]||b[r])}),t}static formats(e){return f.concat(p).reduce((t,r)=>(e.hasAttribute(`data-${r}`)&&(t[r]=e.getAttribute(`data-${r}`)||void 0),t),{})}format(e,t){f.concat(p).indexOf(e)>-1?t?this.domNode.setAttribute(`data-${e}`,t):this.domNode.removeAttribute(`data-${e}`):super.format(e,t)}optimize(e){const t=this.domNode.getAttribute("data-row"),r=this.domNode.getAttribute("data-rowspan"),n=parseInt(this.domNode.getAttribute("data-colspan"),10);!this.statics.requiredContainer||this.parent instanceof this.statics.requiredContainer||this.wrap(this.statics.requiredContainer.blotName,{row:t,colspan:n,rowspan:r}),super.optimize(e)}tableCell(){return this.parent}}g.blotName="table-cell-line",g.ClassName="qlbt-cell-line",g.tagName="DIV";class y extends c{checkMerge(){if(super.checkMerge()&&null!=this.next.children.head){const e=this.children.head.formats()["table-cell-line"],t=this.children.tail.formats()["table-cell-line"],r=this.next.children.head.formats()["table-cell-line"],n=this.next.children.tail.formats()["table-cell-line"];return e.cell===t.cell&&e.cell===r.cell&&e.cell===n.cell}return!1}static create(e){const t=super.create(e);return t.setAttribute("data-row",e.row),f.forEach(r=>{e[r]&&t.setAttribute(r,e[r])}),t}static formats(e){const t={};return e.hasAttribute("data-row")&&(t.row=e.getAttribute("data-row")),f.reduce((t,r)=>(e.hasAttribute(r)&&(t[r]=e.getAttribute(r)),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")),f.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(r=>{r.format(e,t)})}format(e,t){f.indexOf(e)>-1?(this.toggleAttribute(e,t),this.formatChildren(e,t)):["row"].indexOf(e)>-1?(this.toggleAttribute(`data-${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()}}y.blotName="table",y.tagName="TD";class w extends c{checkMerge(){if(super.checkMerge()&&null!=this.next.children.head){const e=this.children.head.formats(),t=this.children.tail.formats(),r=this.next.children.head.formats(),n=this.next.children.tail.formats();return e.row===t.row&&e.row===r.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-${t}`)&&(e[t]=this.domNode.getAttribute(`data-${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}}w.blotName="table-row",w.tagName="TR";class x extends c{}x.blotName="table-body",x.tagName="TBODY";class v extends d{static create(e){let t=super.create(e);return u.forEach(r=>{t.setAttribute(`${r}`,e[r]||h[r])}),t}static formats(e){return u.reduce((t,r)=>(e.hasAttribute(`${r}`)&&(t[r]=e.getAttribute(`${r}`)||void 0),t),{})}format(e,t){u.indexOf(e)>-1?this.domNode.setAttribute(`${e}`,t||h[e]):super.format(e,t)}html(){return this.domNode.outerHTML}}v.blotName="table-col",v.tagName="col";class C extends c{}C.blotName="table-col-group",C.tagName="colgroup";class N extends c{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()[v.blotName].width,10),0);this.domNode.style.width=`${t}px`},0)}cells(e){return this.rows().map(t=>t.children.at(e))}colGroup(){return this.children.head}deleteColumns(e,t=[],r){var n=this.descendants(x);const o=l(n,1)[0];if(null==o||null==o.children.head)return;const i=this.descendants(y),a=[],d=[];if(i.forEach(t=>{const n=(0,s.getRelativeRect)(t.domNode.getBoundingClientRect(),r);n.x+m>e.x&&n.x1-m<e.x1?a.push(t):n.x<e.x+m&&n.x1>e.x1-m&&d.push(t)}),a.length===i.length)return this.tableDestroy(),!0;t.forEach(e=>{this.colGroup().children.at(t[0]).remove()}),a.forEach(e=>{e.remove()}),d.forEach(e=>{const r=parseInt(e.formats().colspan,10);parseInt(e.formats().width,10);e.format("colspan",r-t.length)}),this.updateTableWidth()}deleteRow(e,t){var r=this.descendants(x);const n=l(r,1)[0];if(null==n||null==n.children.head)return;const o=this.descendants(y),i=[],a=[],d=[];if(o.forEach(r=>{const n=(0,s.getRelativeRect)(r.domNode.getBoundingClientRect(),t);n.y>e.y-m&&n.y1<e.y1+m?i.push(r):n.y<e.y+m&&n.y1>e.y1-m&&(a.push(r),Math.abs(n.y-e.y)<m&&d.push(r))}),i.length===o.length)return void this.tableDestroy();const c=this.rows().reduce((r,n)=>{let l=(0,s.getRelativeRect)(n.domNode.getBoundingClientRect(),t);return l.y>e.y-m&&l.y1<e.y1+m&&(r+=1),r},0);d.forEach(e=>{const r=(0,s.getRelativeRect)(e.domNode.getBoundingClientRect(),t),n=e.parent.next,l=n.children.reduce((e,n)=>{const l=(0,s.getRelativeRect)(n.domNode.getBoundingClientRect(),t);return Math.abs(r.x1-l.x)<m&&(e=n),e},null);n.insertBefore(e,l),e.format("row",n.formats().row)}),i.forEach(e=>{e.remove()}),a.forEach(e=>{const t=parseInt(e.formats().rowspan,10);e.format("rowspan",t-c)})}tableDestroy(){const e=i.default.find(this.scroll.domNode.parentNode),t=e.getModule("better-table");this.remove(),t.hideTableTools(),e.update(i.default.sources.USER)}insertCell(e,t){const r=R(),n=e.formats().row,l=this.scroll.create(y.blotName,Object.assign({},b,{row:n})),o=this.scroll.create(g.blotName,{row:n,cell:r});l.appendChild(o),t?e.insertBefore(l,t):e.appendChild(l)}insertColumn(e,t,r=!0,n){var o=this.descendants(x);const i=l(o,1)[0];var a=this.descendants(C);const d=l(a,1)[0],c=this.descendants(v);let u=[],h=[],p=[];if(null==i||null==i.children.head)return;this.descendants(y).forEach(t=>{const l=(0,s.getRelativeRect)(t.domNode.getBoundingClientRect(),n);r?Math.abs(l.x1-e.x1)<m?u.push(t):e.x1-l.x>m&&e.x1-l.x1<-m&&h.push(t):Math.abs(l.x-e.x)<m?u.push(t):e.x-l.x>m&&e.x-l.x1<-m&&h.push(t)}),u.forEach(e=>{const t=r?e.next:e,n=R(),l=e.parent,o=l.formats().row,i=e.formats(),s=this.scroll.create(y.blotName,Object.assign({},b,{row:o,rowspan:i.rowspan})),a=this.scroll.create(g.blotName,{row:o,cell:n,rowspan:i.rowspan});s.appendChild(a),t?l.insertBefore(s,t):l.appendChild(s),p.push(s)});const f=this.scroll.create(v.blotName,!0);let w=r?c[t].next:c[t];return w?d.insertBefore(f,w):d.appendChild(f),h.forEach(e=>{const t=e.formats().colspan;e.format("colspan",parseInt(t,10)+1),p.push(e)}),p.sort((e,t)=>{return e.domNode.getBoundingClientRect().y-t.domNode.getBoundingClientRect().y}),this.updateTableWidth(),p}insertRow(e,t,r){var n=this.descendants(x);const o=l(n,1)[0];if(null==o||null==o.children.head)return;const i=this.descendants(y),d=q(),c=this.scroll.create(w.blotName,{row:d});let u=[],h=[],p=[];i.forEach(n=>{const l=(0,s.getRelativeRect)(n.domNode.getBoundingClientRect(),r);t?Math.abs(l.y1-e.y1)<m?u.push(n):e.y1-l.y>m&&e.y1-l.y1<-m&&h.push(n):Math.abs(l.y-e.y)<m?u.push(n):e.y-l.y>m&&e.y-l.y1<-m&&h.push(n)});const f=(e,t)=>{return e.domNode.getBoundingClientRect().x-t.domNode.getBoundingClientRect().x};u.sort(f),u.forEach(e=>{const t=R(),r=e.formats(),n=this.scroll.create(y.blotName,Object.assign({},b,{row:d,colspan:r.colspan})),l=this.scroll.create(g.blotName,{row:d,cell:t,colspan:r.colspan}),o=this.scroll.create(a.blotName);l.appendChild(o),n.appendChild(l),c.appendChild(n),p.push(n)}),h.forEach(e=>{const t=parseInt(e.formats().rowspan,10);e.format("rowspan",t+1),p.push(e)});const v=this.rows().find(n=>{let l=(0,s.getRelativeRect)(n.domNode.getBoundingClientRect(),r);return t?Math.abs(l.y-e.y-e.height)<m:Math.abs(l.y-e.y)<m});return o.insertBefore(c,v),p.sort(f),p}mergeCells(e,t,r,n,l){const o=t.reduce((e,t,l)=>(0!==l?(e&&t.moveChildren(e),t.remove()):(t.format("colspan",n),t.format("rowspan",r),e=t),e),null);let i=o.domNode.getAttribute("data-row"),s=o.children.head.domNode.getAttribute("data-cell");return o.children.forEach(e=>{e.format("cell",s),e.format("row",i),e.format("colspan",n),e.format("rowspan",r)}),o}unmergeCells(e,t){let r={},n=1,l=1;e.forEach(e=>{if(r=e.formats(),n=r.rowspan,(l=r.colspan)>1){let t=e.next,r=e.row();e.format("colspan",1);for(let e=l;e>1;e--)this.insertCell(r,t)}if(n>1){let r=n,o=e.row().next;for(;r>1;){let n=o.children.reduce((r,n)=>{let l=(0,s.getRelativeRect)(e.domNode.getBoundingClientRect(),t),o=(0,s.getRelativeRect)(n.domNode.getBoundingClientRect(),t);return Math.abs(l.x1-o.x)<m&&(r=n),r},null);for(let e=l;e>0;e--)this.insertCell(o,n);r-=1,o=o.next}e.format("rowspan",1)}})}rows(){const e=this.children.tail;return null==e?[]:e.children.map(e=>e)}}N.blotName="table-container",N.className="quill-better-table",N.tagName="TABLE";class T extends c{constructor(e,t){super(e,t);const r=i.default.find(e.domNode.parentNode);t.addEventListener("scroll",e=>{const t=r.getModule("better-table");t.columnTool&&(t.columnTool.domNode.scrollLeft=e.target.scrollLeft),t.tableSelection&&t.tableSelection.selectedTds.length>0&&t.tableSelection.repositionHelpLines()},!1)}}function q(){return`row-${Math.random().toString(36).slice(2,6)}`}function R(){return`cell-${Math.random().toString(36).slice(2,6)}`}T.blotName="table-view",T.className="quill-better-table-wrapper",T.tagName="DIV",T.allowedChildren=[N],N.requiredContainer=T,N.allowedChildren=[x,C],x.requiredContainer=N,x.allowedChildren=[w],w.requiredContainer=x,w.allowedChildren=[y],y.requiredContainer=w,y.allowedChildren=[g],g.requiredContainer=y,C.allowedChildren=[v],C.requiredContainer=N,v.requiredContainer=C,t.TableCol=v,t.TableColGroup=C,t.TableCellLine=g,t.TableCell=y,t.TableRow=w,t.TableBody=x,t.TableContainer=N,t.TableViewWrapper=T,t.rowId=q,t.cellId=R,t.CELL_ATTRIBUTES=f},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=function(){return function(e,t){if(Array.isArray(e))return e;if(Symbol.iterator in Object(e))return function(e,t){var r=[],n=!0,l=!1,o=void 0;try{for(var i,s=e[Symbol.iterator]();!(n=(i=s.next()).done)&&(r.push(i.value),!t||r.length!==t);n=!0);}catch(e){l=!0,o=e}finally{try{!n&&s.return&&s.return()}finally{if(l)throw o}}return r}(e,t);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}(),l=c(r(0)),o=c(r(4)),i=c(r(5)),s=c(r(6)),a=r(7),d=r(2);function c(e){return e&&e.__esModule?e:{default:e}}const u=l.default.import("core/module"),h=l.default.import("delta");class p extends u{static register(){l.default.register(d.TableCol,!0),l.default.register(d.TableColGroup,!0),l.default.register(d.TableCellLine,!0),l.default.register(d.TableCell,!0),l.default.register(d.TableRow,!0),l.default.register(d.TableBody,!0),l.default.register(d.TableContainer,!0),l.default.register(d.TableViewWrapper,!0)}constructor(e,t){super(e,t),this.quill.root.addEventListener("click",r=>{if(!r.path||r.path.length<=0)return;const n=r.path.filter(e=>e.tagName&&"TABLE"===e.tagName.toUpperCase()&&e.classList.contains("quill-better-table"))[0];if(n){if(this.table===n)return;this.table&&this.hideTableTools(),this.showTableTools(n,e,t)}else this.table&&this.hideTableTools()},!1),this.quill.root.addEventListener("contextmenu",r=>{if(!this.table)return!0;if(r.preventDefault(),!r.path||r.path.length<=0)return;const n=r.path.filter(e=>e.tagName&&"TABLE"===e.tagName.toUpperCase()&&e.classList.contains("quill-better-table"))[0],l=r.path.filter(e=>e.tagName&&"TR"===e.tagName.toUpperCase()&&e.getAttribute("data-row"))[0],o=r.path.filter(e=>e.tagName&&"TD"===e.tagName.toUpperCase()&&e.getAttribute("data-row"))[0];let i=this.tableSelection.selectedTds.map(e=>e.domNode).includes(o);(this.tableSelection.selectedTds.length<=0||!i)&&this.tableSelection.setSelection(o.getBoundingClientRect(),o.getBoundingClientRect()),this.tableOperationMenu&&(this.tableOperationMenu=this.tableOperationMenu.destroy()),n&&(this.tableOperationMenu=new s.default({table:n,row:l,cell:o,left:r.pageX,top:r.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;var r=this.quill.getLine(e.index);const l=n(r,1)[0];if(0===t.offset){var o=this.quill.getLine(e.index-1);const t=n(o,1)[0];if(null!=t&&"table-cell-line"===t.statics.blotName&&"table-cell-line"!==l.statics.blotName)return!1}return!0});let r=e.keyboard.bindings.Backspace.pop();e.keyboard.bindings.Backspace.splice(0,1,r),e.clipboard.addMatcher("td",a.matchTableCell),e.clipboard.addMatcher("th",a.matchTableHeader),e.clipboard.addMatcher("table",a.matchTable),e.clipboard.matchers=e.clipboard.matchers.filter(e=>"tr"!==e[0])}getTable(e=this.quill.getSelection()){if(null==e)return[null,null,null,-1];var t=this.quill.getLine(e.index),r=n(t,2);const l=r[0],o=r[1];if(null==l||l.statics.blotName!==d.TableCellLine.blotName)return[null,null,null,-1];const i=l.tableCell(),s=i.row();return[s.table(),s,i,o]}insertTable(e,t){const r=this.quill.getSelection(!0);if(null==r)return;this.quill.getLeaf(r.index)[0],this.quill.getLeaf(r.index+1)[0];let n=(new h).retain(r.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 r=(0,d.rowId)();return new Array(t).fill("\n").reduce((e,t)=>(e.insert(t,{"table-cell-line":{row:r,cell:(0,d.cellId)()}}),e),e)},n),this.quill.updateContents(n,l.default.sources.USER),this.quill.setSelection(r.index+t+1,l.default.sources.API)}showTableTools(e,t,r){this.table=e,this.columnTool=new o.default(e,t,r),this.tableSelection=new i.default(e,t,r)}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}}p.keyboardBindings={"table-cell-line backspace":{key:"Backspace",format:["table-cell-line"],collapsed:!0,offset:0,handler(e,t){var r=this.quill.getLine(e.index),l=n(r,2);const o=l[0];l[1];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 r=l.default.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,r.BLOCK)&&!Array.isArray(t.format[n])&&(e[n]=t.format[n]),e),{});this.quill.insertText(e.index,"\n",n["table-cell-line"],l.default.sources.USER),this.quill.setSelection(e.index+1,l.default.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],l.default.sources.USER))})}}},t.default=p},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n,l=r(0),o=(n=l)&&n.__esModule?n:{default:n},i=r(1);const s=12,a=12,d=50,c="#35A7ED";t.default=class{constructor(e,t,r){if(!e)return null;this.table=e,this.quill=t,this.options=r,this.domNode=null,this.initColTool()}initColTool(){const e=this.quill.root.parentNode,t=(this.table.getBoundingClientRect(),e.getBoundingClientRect()),r=this.table.parentNode.getBoundingClientRect();this.domNode=document.createElement("div"),this.domNode.classList.add("qlbt-col-tool"),this.updateToolCells(),e.appendChild(this.domNode),(0,i.css)(this.domNode,{width:`${r.width}px`,height:`${s}px`,left:`${r.left-t.left+e.scrollLeft}px`,top:`${r.top-t.top+e.scrollTop-s-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"),(0,i.css)(e,{height:`${a}px`}),e.appendChild(t),e}updateToolCells(){const e=o.default.find(this.table),t=e.children.tail.children.head.children,r=e.colGroup().children,n=function(e){return e.reduce((e,t)=>{const r=t.formats().colspan;return e+=parseInt(r,10)},0)}(t);let l=Array.from(this.domNode.querySelectorAll(".qlbt-col-tool-cell"));for(let e=0;e<Math.max(n,l.length);e++){let t=r.at(e),o=t&&parseInt(t.formats()[t.statics.blotName].width,10),s=null;l[e]?l[e]&&e>=n?l[e].remove():(s=l[e],(0,i.css)(s,{"min-width":`${o}px`})):(s=this.createToolCell(),this.domNode.appendChild(s),this.addColCellHolderHandler(s),(0,i.css)(s,{"min-width":`${o}px`}))}}destroy(){return this.domNode.remove(),null}addColCellHolderHandler(e){const t=o.default.find(this.table),r=e.querySelector(".qlbt-col-tool-cell-holder");let n=!1,l=0,a=0,u=0,h=0,p={},f={},b=null;const m=e=>{e.preventDefault(),n&&(a=e.clientX,u=h+a-l>=d?a-l:d-h,(0,i.css)(b,{left:`${f.left+f.width-1+u}px`}))},g=o=>{o.preventDefault();const s=Array.from(this.domNode.querySelectorAll(".qlbt-col-tool-cell")).indexOf(e),d=t.colGroup().children.at(s);n&&(d.format("width",h+u),(0,i.css)(e,{"min-width":`${h+u}px`}),l=0,a=0,u=0,h=0,n=!1,r.classList.remove("dragging")),document.removeEventListener("mousemove",m,!1),document.removeEventListener("mouseup",g,!1),p={},f={},b.remove(),b=null,t.updateTableWidth();const c=this.quill.getModule("better-table").tableSelection;c&&c.clearSelection()};r.addEventListener("mousedown",t=>{document.addEventListener("mousemove",m,!1),document.addEventListener("mouseup",g,!1),p=this.table.getBoundingClientRect(),f=e.getBoundingClientRect(),b=document.createElement("div"),(0,i.css)(b,{position:"fixed",top:`${f.top}px`,left:`${f.left+f.width-1}px`,zIndex:"100",height:`${p.height+s+4}px`,width:"1px",backgroundColor:c}),document.body.appendChild(b),n=!0,l=t.clientX,h=f.width,r.classList.add("dragging")},!1)}colToolCells(){return Array.from(this.domNode.querySelectorAll(".qlbt-col-tool-cell"))}}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n,l=r(0),o=(n=l)&&n.__esModule?n:{default:n},i=r(1),s=r(2);const a="#35A7ED",d=["left","right","top","bottom"],c=2;function u(e,t){let r=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),l=Math.min(e.y,t.y,e.y+e.height-1,t.y+t.height-1),o=Math.max(e.y,t.y,e.y+e.height-1,t.y+t.height-1);return{x:r,x1:n,y:l,y1:o,width:n-r,height:o-l}}t.default=class{constructor(e,t,r){if(!e)return null;this.table=e,this.quill=t,this.options=r,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"),(0,i.css)(this[t],{position:"absolute",display:"none","background-color":a}),e.appendChild(this[t])})}mouseDownHandler(e){if(0!==e.button||!e.target.closest(".quill-better-table"))return;this.quill.root.addEventListener("mousemove",l,!1),this.quill.root.addEventListener("mouseup",function e(r){t.quill.root.removeEventListener("mousemove",l,!1),t.quill.root.removeEventListener("mouseup",e,!1),t.dragging=!1},!1);const t=this,r=e.target.closest("td[data-row]"),n=(0,i.getRelativeRect)(r.getBoundingClientRect(),this.quill.root.parentNode);function l(e){if(0!==e.button||!e.target.closest(".quill-better-table"))return;const l=e.target.closest("td[data-row]"),o=(0,i.getRelativeRect)(l.getBoundingClientRect(),t.quill.root.parentNode);t.boundary=u(n,o),t.correctBoundary(),t.selectedTds=t.computeSelectedTds(),t.repositionHelpLines(),r!==l&&t.quill.blur()}this.dragging=!0,this.boundary=u(n,n),this.correctBoundary(),this.selectedTds=this.computeSelectedTds(),this.repositionHelpLines()}correctBoundary(){o.default.find(this.table).descendants(s.TableCell).forEach(e=>{var t=(0,i.getRelativeRect)(e.domNode.getBoundingClientRect(),this.quill.root.parentNode);let r=t.x,n=t.y,l=t.width,o=t.height;(r+c>=this.boundary.x&&r+c<=this.boundary.x1||r-c+l>=this.boundary.x&&r-c+l<=this.boundary.x1)&&(n+c>=this.boundary.y&&n+c<=this.boundary.y1||n-c+o>=this.boundary.y&&n-c+o<=this.boundary.y1)&&(this.boundary=u(this.boundary,{x:r,y:n,width:l,height:o}))})}computeSelectedTds(){return o.default.find(this.table).descendants(s.TableCell).reduce((e,t)=>{var r=(0,i.getRelativeRect)(t.domNode.getBoundingClientRect(),this.quill.root.parentNode);let n=r.x,l=r.y,o=r.width,s=r.height;return n+c>=this.boundary.x&&n-c+o<=this.boundary.x1&&l+c>=this.boundary.y&&l-c+s<=this.boundary.y1&&e.push(t),e},[])}repositionHelpLines(){const e=this.table.parentNode.scrollLeft;(0,i.css)(this.left,{display:"block",left:`${this.boundary.x-e-1}px`,top:`${this.boundary.y}px`,height:`${this.boundary.height+1}px`,width:"1px"}),(0,i.css)(this.right,{display:"block",left:`${this.boundary.x1-e}px`,top:`${this.boundary.y}px`,height:`${this.boundary.height+1}px`,width:"1px"}),(0,i.css)(this.top,{display:"block",left:`${this.boundary.x-1-e}px`,top:`${this.boundary.y}px`,width:`${this.boundary.width+1}px`,height:"1px"}),(0,i.css)(this.bottom,{display:"block",left:`${this.boundary.x-1-e}px`,top:`${this.boundary.y1+1}px`,width:`${this.boundary.width+1}px`,height:"1px"})}refreshHelpLinesPosition(){const e=(0,i.getRelativeRect)(this.selectedTds[0].domNode.getBoundingClientRect(),this.quill.root.parentNode),t=(0,i.getRelativeRect)(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((0,i.getRelativeRect)(e,this.quill.root.parentNode),(0,i.getRelativeRect)(t,this.quill.root.parentNode)),this.correctBoundary(),this.selectedTds=this.computeSelectedTds(),this.repositionHelpLines()}clearSelection(){this.boundary={},this.selectedTds=[],d.forEach(e=>{this[e]&&(0,i.css)(this[e],{display:"none"})})}}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n,l=r(0),o=(n=l)&&n.__esModule?n:{default:n},i=r(1);const s=150,a=200,d={insertColumnRight:{text:"Insert column right",handler(){const e=o.default.find(this.table);let t=c(this.columnToolCells,this.boundary,(e,t)=>Math.abs(e.x+e.width-t.x1)<=5,this.quill.root.parentNode);const r=e.insertColumn(this.boundary,t,!0,this.quill.root.parentNode);this.tableColumnTool.updateToolCells(),this.quill.update(o.default.sources.USER),this.quill.setSelection(this.quill.getIndex(r[0]),0,o.default.sources.SILENT),this.tableSelection.setSelection(r[0].domNode.getBoundingClientRect(),r[0].domNode.getBoundingClientRect())}},insertColumnLeft:{text:"Insert column left",handler(){const e=o.default.find(this.table);let t=c(this.columnToolCells,this.boundary,(e,t)=>Math.abs(e.x-t.x)<=5,this.quill.root.parentNode);const r=e.insertColumn(this.boundary,t,!1,this.quill.root.parentNode);this.tableColumnTool.updateToolCells(),this.quill.update(o.default.sources.USER),this.quill.setSelection(this.quill.getIndex(r[0]),0,o.default.sources.SILENT),this.tableSelection.setSelection(r[0].domNode.getBoundingClientRect(),r[0].domNode.getBoundingClientRect())}},insertRowUp:{text:"Insert row up",handler(){const e=o.default.find(this.table).insertRow(this.boundary,!1,this.quill.root.parentNode);this.quill.update(o.default.sources.USER),this.quill.setSelection(this.quill.getIndex(e[0]),0,o.default.sources.SILENT),this.tableSelection.setSelection(e[0].domNode.getBoundingClientRect(),e[0].domNode.getBoundingClientRect())}},insertRowDown:{text:"Insert row down",handler(){const e=o.default.find(this.table).insertRow(this.boundary,!0,this.quill.root.parentNode);this.quill.update(o.default.sources.USER),this.quill.setSelection(this.quill.getIndex(e[0]),0,o.default.sources.SILENT),this.tableSelection.setSelection(e[0].domNode.getBoundingClientRect(),e[0].domNode.getBoundingClientRect())}},mergeCells:{text:"Merge selected cells",handler(){const e=o.default.find(this.table),t=e.rows().reduce((e,t)=>{let r=(0,i.getRelativeRect)(t.domNode.getBoundingClientRect(),this.quill.root.parentNode);return r.y>this.boundary.y-5&&r.y+r.height<this.boundary.y+this.boundary.height+5&&(e+=1),e},0),r=this.columnToolCells.reduce((e,t)=>{let r=(0,i.getRelativeRect)(t.getBoundingClientRect(),this.quill.root.parentNode);return r.x>this.boundary.x-5&&r.x+r.width<this.boundary.x+this.boundary.width+5&&(e+=1),e},0),n=e.mergeCells(this.boundary,this.selectedTds,t,r,this.quill.root.parentNode);this.quill.update(o.default.sources.USER),this.tableSelection.setSelection(n.domNode.getBoundingClientRect(),n.domNode.getBoundingClientRect())}},unmergeCells:{text:"Unmerge cells",handler(){o.default.find(this.table).unmergeCells(this.selectedTds,this.quill.root.parentNode),this.quill.update(o.default.sources.USER),this.tableSelection.clearSelection()}},deleteColumn:{text:"Delete selected columns",handler(){const e=o.default.find(this.table);let t=(r=this.columnToolCells,n=this.boundary,l=((e,t)=>e.x+5>t.x&&e.x+e.width-5<t.x1),s=this.quill.root.parentNode,r.reduce((e,t)=>{let o=(0,i.getRelativeRect)(t.getBoundingClientRect(),s);return l(o,n)&&e.push(r.indexOf(t)),e},[]));var r,n,l,s;e.deleteColumns(this.boundary,t,this.quill.root.parentNode)||(this.tableColumnTool.updateToolCells(),this.quill.update(o.default.sources.USER),this.tableSelection.clearSelection())}},deleteRow:{text:"Delete selected rows",handler(){o.default.find(this.table).deleteRow(this.boundary,this.quill.root.parentNode),this.quill.update(o.default.sources.USER),this.tableSelection.clearSelection()}},deleteTable:{text:"Delete table",handler(){const e=this.quill.getModule("better-table"),t=o.default.find(this.table);e.hideTableTools(),t.remove(),this.quill.update(o.default.sources.USER)}}};function c(e,t,r,n){return e.reduce((l,o)=>{let s=(0,i.getRelativeRect)(o.getBoundingClientRect(),n);return r(s,t)&&(l=e.indexOf(o)),l},!1)}t.default=class{constructor(e,t,r){const n=t.getModule("better-table");this.tableSelection=n.tableSelection,this.table=e.table,this.quill=t,this.options=r,this.menuItems=Object.assign({},d,r.items),this.tableColumnTool=n.columnTool,this.boundary=this.tableSelection.boundary,this.selectedTds=this.tableSelection.selectedTds,this.destroyHanlder=this.destroy.bind(this),this.columnToolCells=this.tableColumnTool.colToolCells(),this.menuInitial(e),this.mount(),document.addEventListener("click",this.destroyHanlder,!1)}mount(){document.body.appendChild(this.domNode)}destroy(){return this.domNode.remove(),document.removeEventListener("click",this.destroyHanlder,!1),null}menuInitial({table:e,left:t,top:r}){this.domNode=document.createElement("div"),this.domNode.classList.add("qlbt-operation-menu"),(0,i.css)(this.domNode,{position:"absolute",left:`${t}px`,top:`${r}px`,"min-height":`${s}px`,width:`${a}px`});for(let e in this.menuItems)this.menuItems[e]&&this.domNode.appendChild(this.menuItemCreator(Object.assign({},d[e],this.menuItems[e])))}menuItemCreator({text:e,handler:t}){const r=document.createElement("div");return r.classList.add("qlbt-operation-menu-item"),r.innerText=e,r.addEventListener("click",t.bind(this),!1),r}}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.matchTableCell=function(e,t,r){const n=e.parentNode,l="TABLE"===n.parentNode.tagName?n.parentNode:n.parentNode.parentNode,o=Array.from(l.querySelectorAll("tr")),a=Array.from(n.querySelectorAll("td")),d=o.indexOf(n)+1,c=a.indexOf(e)+1,u=e.getAttribute("colspan")||!1,h=e.getAttribute("rowspan")||!1;if(0===t.length())return t=(new s).insert("\n",{"table-cell-line":{row:d,cell:c,rowspan:h,colspan:u}});return(t=t.reduce((e,t)=>{if(t.insert&&"string"==typeof t.insert){const r=[];let n=t.insert,l=0;for(let e=0;e<t.insert.length;e++)"\n"===n.charAt(e)&&(0===e?r.push("\n"):(r.push(n.substring(l,e)),r.push("\n")),l=e+1);const o=n.substring(l);o&&r.push(o),r.forEach(r=>{"\n"===r?e.insert("\n",t.attributes):e.insert(r,(0,i._omit)(t.attributes,["table","table-cell-line"]))})}else e.insert(t.insert,t.attributes);return e},new s)).reduce((e,t)=>(t.insert&&"string"==typeof t.insert&&t.insert.startsWith("\n")?e.insert(t.insert,Object.assign({},Object.assign({},{row:d},t.attributes.table),{"table-cell-line":{row:d,cell:c,rowspan:h,colspan:u}},(0,i._omit)(t.attributes,["table"]))):e.insert(t.insert,Object.assign({},(0,i._omit)(t.attributes,["table","table-cell-line"]))),e),new s)},t.matchTableHeader=function(e,t,r){const n=e.parentNode,l="TABLE"===n.parentNode.tagName?n.parentNode:n.parentNode.parentNode,o=Array.from(l.querySelectorAll("tr")),a=Array.from(n.querySelectorAll("th")),d=o.indexOf(n)+1,c=a.indexOf(e)+1,u=e.getAttribute("colspan")||!1,h=e.getAttribute("rowspan")||!1;if(0===t.length())return t=(new s).insert("\n",{"table-cell-line":{row:d,cell:c,rowspan:h,colspan:u}});return(t=t.reduce((e,t)=>{if(t.insert&&"string"==typeof t.insert){const r=[];let n=t.insert,l=0;for(let e=0;e<t.insert.length;e++)"\n"===n.charAt(e)&&(0===e?r.push("\n"):(r.push(n.substring(l,e)),r.push("\n")),l=e+1);const o=n.substring(l);o&&r.push(o),r.indexOf("\n")<0&&r.push("\n"),r.forEach(r=>{"\n"===r?e.insert("\n",{"table-cell-line":{row:d,cell:c,rowspan:h,colspan:u}}):e.insert(r,t.attributes)})}else e.insert(t.insert,t.attributes);return e},new s)).reduce((e,t)=>(t.insert&&"string"==typeof t.insert&&t.insert.startsWith("\n")?e.insert(t.insert,Object.assign({},{"table-cell-line":{row:d,cell:c,rowspan:h,colspan:u}})):e.insert(t.insert,Object.assign({},(0,i._omit)(t.attributes,["table","table-cell-line"]))),e),new s)},t.matchTable=function(e,t,r){let n=new s;const l=e.querySelector("tr");if(null===l)return new n;const o=Array.from(l.querySelectorAll("td")).concat(Array.from(l.querySelectorAll("th"))).reduce((e,t)=>{const r=t.getAttribute("colspan")||1;return e+=parseInt(r,10)},0),i=e.querySelectorAll("col").length;if(i===o)return t;{for(let e=0;e<o-i;e++)n.insert("\n",{"table-col":!0});if(0===i)return n.concat(t);let e=0;return t.reduce((t,r)=>(t.insert(r.insert,r.attributes),r.attributes&&r.attributes["table-col"]&&(e+=r.insert.length)===i&&(t=t.concat(n)),t),new s)}};var n,l=r(0),o=(n=l)&&n.__esModule?n:{default:n},i=r(1);const s=o.default.import("delta")},function(e,t,r){},,,function(e,t,r){"use strict";var n,l=r(3),o=(n=l)&&n.__esModule?n:{default:n};r(8),Quill.register({"modules/better-table":o.default},!0),window.onload=(()=>{let e=new Quill("#editor-wrapper",{theme:"snow",modules:{table:!1,"better-table":{operationMenu:{items:{unmergeCells:{text:"Another unmerge cells name"}}}},keyboard:{bindings:o.default.keyboardBindings}}}).getModule("better-table");document.body.querySelector("#insert-table").onclick=(()=>{e.insertTable(3,3)}),document.body.querySelector("#get-table").onclick=(()=>{console.log(e.getTable())})})}]).default});

@@ -1,1 +0,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,r){!function(e,t){if(!v[e]||!x[e])return;for(var r in x[e]=!1,t)Object.prototype.hasOwnProperty.call(t,r)&&(b[r]=t[r]);0==--g&&0===y&&q()}(e,r),t&&t(e,r)};var r,n=!0,l="7acea3c59aabbdb66211",o=1e4,i={},s=[],a=[];function d(e){var t=E[e];if(!t)return S;var n=function(n){return t.hot.active?(E[n]?-1===E[n].parents.indexOf(e)&&E[n].parents.push(e):(s=[e],r=n),-1===t.children.indexOf(n)&&t.children.push(n)):(console.warn("[HMR] unexpected require("+n+") from disposed module "+e),s=[]),S(n)},l=function(e){return{configurable:!0,enumerable:!0,get:function(){return S[e]},set:function(t){S[e]=t}}};for(var o in S)Object.prototype.hasOwnProperty.call(S,o)&&"e"!==o&&"t"!==o&&Object.defineProperty(n,o,l(o));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]||T(e),0===y&&0===g&&q())}},n.t=function(e,t){return 1&t&&(e=n(e)),S.t(e,-2&t)},n}function c(e){var t={_acceptedDependencies:{},_declinedDependencies:{},_selfAccepted:!1,_selfDeclined:!1,_disposeHandlers:[],_main:r!==e,active:!0,accept:function(e,r){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<e.length;n++)t._acceptedDependencies[e[n]]=r||function(){};else t._acceptedDependencies[e]=r||function(){}},decline:function(e){if(void 0===e)t._selfDeclined=!0;else if("object"==typeof e)for(var r=0;r<e.length;r++)t._declinedDependencies[e[r]]=!0;else t._declinedDependencies[e]=!0},dispose:function(e){t._disposeHandlers.push(e)},addDisposeHandler:function(e){t._disposeHandlers.push(e)},removeDisposeHandler:function(e){var r=t._disposeHandlers.indexOf(e);r>=0&&t._disposeHandlers.splice(r,1)},check:C,apply:R,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:i[e]};return r=void 0,t}var u=[],h="idle";function p(e){h=e;for(var t=0;t<u.length;t++)u[t].call(null,e)}var f,b,m,g=0,y=0,w={},x={},v={};function N(e){return+e+""===e?+e:e}function C(e){if("idle"!==h)throw new Error("check() is only allowed in idle status");return n=e,p("check"),(t=o,t=t||1e4,new Promise(function(e,r){if("undefined"==typeof XMLHttpRequest)return r(new Error("No browser support"));try{var n=new XMLHttpRequest,o=S.p+""+l+".hot-update.json";n.open("GET",o,!0),n.timeout=t,n.send(null)}catch(e){return r(e)}n.onreadystatechange=function(){if(4===n.readyState)if(0===n.status)r(new Error("Manifest request to "+o+" timed out."));else if(404===n.status)e();else if(200!==n.status&&304!==n.status)r(new Error("Manifest request to "+o+" failed."));else{try{var t=JSON.parse(n.responseText)}catch(e){return void r(e)}e(t)}}})).then(function(e){if(!e)return p("idle"),null;x={},w={},v=e.c,m=e.h,p("prepare");var t=new Promise(function(e,t){f={resolve:e,reject:t}});b={};return T(2),"prepare"===h&&0===y&&0===g&&q(),t});var t}function T(e){v[e]?(x[e]=!0,g++,function(e){var t=document.createElement("script");t.charset="utf-8",t.src=S.p+""+e+"."+l+".hot-update.js",document.head.appendChild(t)}(e)):w[e]=!0}function q(){p("ready");var e=f;if(f=null,e)if(n)Promise.resolve().then(function(){return R(n)}).then(function(t){e.resolve(t)},function(t){e.reject(t)});else{var t=[];for(var r in b)Object.prototype.hasOwnProperty.call(b,r)&&t.push(N(r));e.resolve(t)}}function R(t){if("ready"!==h)throw new Error("apply() is only allowed in ready status");var r,n,o,a,d;function c(e){for(var t=[e],r={},n=t.slice().map(function(e){return{chain:[e],id:e}});n.length>0;){var l=n.pop(),o=l.id,i=l.chain;if((a=E[o])&&!a.hot._selfAccepted){if(a.hot._selfDeclined)return{type:"self-declined",chain:i,moduleId:o};if(a.hot._main)return{type:"unaccepted",chain:i,moduleId:o};for(var s=0;s<a.parents.length;s++){var d=a.parents[s],c=E[d];if(c){if(c.hot._declinedDependencies[o])return{type:"declined",chain:i.concat([d]),moduleId:o,parentId:d};-1===t.indexOf(d)&&(c.hot._acceptedDependencies[o]?(r[d]||(r[d]=[]),u(r[d],[o])):(delete r[d],t.push(d),n.push({chain:i.concat([d]),id:d})))}}}}return{type:"accepted",moduleId:e,outdatedModules:t,outdatedDependencies:r}}function u(e,t){for(var r=0;r<t.length;r++){var n=t[r];-1===e.indexOf(n)&&e.push(n)}}t=t||{};var f={},g=[],y={},w=function(){console.warn("[HMR] unexpected require("+C.moduleId+") to disposed module")};for(var x in b)if(Object.prototype.hasOwnProperty.call(b,x)){var C;d=N(x);var T=!1,q=!1,R=!1,A="";switch((C=b[x]?c(d):{type:"disposed",moduleId:x}).chain&&(A="\nUpdate propagation: "+C.chain.join(" -> ")),C.type){case"self-declined":t.onDeclined&&t.onDeclined(C),t.ignoreDeclined||(T=new Error("Aborted because of self decline: "+C.moduleId+A));break;case"declined":t.onDeclined&&t.onDeclined(C),t.ignoreDeclined||(T=new Error("Aborted because of declined dependency: "+C.moduleId+" in "+C.parentId+A));break;case"unaccepted":t.onUnaccepted&&t.onUnaccepted(C),t.ignoreUnaccepted||(T=new Error("Aborted because "+d+" is not accepted"+A));break;case"accepted":t.onAccepted&&t.onAccepted(C),q=!0;break;case"disposed":t.onDisposed&&t.onDisposed(C),R=!0;break;default:throw new Error("Unexception type "+C.type)}if(T)return p("abort"),Promise.reject(T);if(q)for(d in y[d]=b[d],u(g,C.outdatedModules),C.outdatedDependencies)Object.prototype.hasOwnProperty.call(C.outdatedDependencies,d)&&(f[d]||(f[d]=[]),u(f[d],C.outdatedDependencies[d]));R&&(u(g,[C.moduleId]),y[d]=w)}var O,B=[];for(n=0;n<g.length;n++)d=g[n],E[d]&&E[d].hot._selfAccepted&&B.push({module:d,errorHandler:E[d].hot._selfAccepted});p("dispose"),Object.keys(v).forEach(function(e){!1===v[e]&&function(e){delete installedChunks[e]}(e)});for(var L,M,_=g.slice();_.length>0;)if(d=_.pop(),a=E[d]){var I={},j=a.hot._disposeHandlers;for(o=0;o<j.length;o++)(r=j[o])(I);for(i[d]=I,a.hot.active=!1,delete E[d],delete f[d],o=0;o<a.children.length;o++){var k=E[a.children[o]];k&&((O=k.parents.indexOf(d))>=0&&k.parents.splice(O,1))}}for(d in f)if(Object.prototype.hasOwnProperty.call(f,d)&&(a=E[d]))for(M=f[d],o=0;o<M.length;o++)L=M[o],(O=a.children.indexOf(L))>=0&&a.children.splice(O,1);for(d in p("apply"),l=m,y)Object.prototype.hasOwnProperty.call(y,d)&&(e[d]=y[d]);var D=null;for(d in f)if(Object.prototype.hasOwnProperty.call(f,d)&&(a=E[d])){M=f[d];var $=[];for(n=0;n<M.length;n++)if(L=M[n],r=a.hot._acceptedDependencies[L]){if(-1!==$.indexOf(r))continue;$.push(r)}for(n=0;n<$.length;n++){r=$[n];try{r(M)}catch(e){t.onErrored&&t.onErrored({type:"accept-errored",moduleId:d,dependencyId:M[n],error:e}),t.ignoreErrored||D||(D=e)}}}for(n=0;n<B.length;n++){var H=B[n];d=H.module,s=[d];try{S(d)}catch(e){if("function"==typeof H.errorHandler)try{H.errorHandler(e)}catch(r){t.onErrored&&t.onErrored({type:"self-accept-error-handler-errored",moduleId:d,error:r,originalError:e}),t.ignoreErrored||D||(D=r),D||(D=e)}else t.onErrored&&t.onErrored({type:"self-accept-errored",moduleId:d,error:e}),t.ignoreErrored||D||(D=e)}}return D?(p("fail"),Promise.reject(D)):(p("idle"),new Promise(function(e){e(g)}))}var E={};function S(t){if(E[t])return E[t].exports;var r=E[t]={i:t,l:!1,exports:{},hot:c(t),parents:(a=s,s=[],a),children:[]};return e[t].call(r.exports,r,r.exports,d(t)),r.l=!0,r.exports}return S.m=e,S.c=E,S.d=function(e,t,r){S.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},S.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},S.t=function(e,t){if(1&t&&(e=S(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(S.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var n in e)S.d(r,n,function(t){return e[t]}.bind(null,n));return r},S.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return S.d(t,"a",t),t},S.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},S.p="",S.h=function(){return l},d(9)(S.s=9)}([function(t,r){t.exports=e},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.css=function(e,t){if("object"==typeof t)for(let r in t)e.style[r]=t[r]},t.getRelativeRect=function(e,t){let r=t.getBoundingClientRect();return{x:e.x-r.x-t.scrollLeft,y:e.y-r.y-t.scrollTop,x1:e.x-r.x-t.scrollLeft+e.width,y1:e.y-r.y-t.scrollTop+e.height,width:e.width,height:e.height}},t._omit=function(e,t){return e&&Object.keys(e).reduce((r,n)=>t.includes(n)?r:Object.assign({},r,{[n]:e[n]}),{})}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.CELL_ATTRIBUTES=t.cellId=t.rowId=t.TableViewWrapper=t.TableContainer=t.TableBody=t.TableRow=t.TableCell=t.TableCellLine=t.TableColGroup=t.TableCol=void 0;var n,l=function(){return function(e,t){if(Array.isArray(e))return e;if(Symbol.iterator in Object(e))return function(e,t){var r=[],n=!0,l=!1,o=void 0;try{for(var i,s=e[Symbol.iterator]();!(n=(i=s.next()).done)&&(r.push(i.value),!t||r.length!==t);n=!0);}catch(e){l=!0,o=e}finally{try{!n&&s.return&&s.return()}finally{if(l)throw o}}return r}(e,t);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}(),o=r(0),i=(n=o)&&n.__esModule?n:{default:n},s=r(1);const a=i.default.import("blots/break"),d=i.default.import("blots/block"),c=i.default.import("blots/container"),u=["width"],h={width:100},p=["row","cell"],f=["rowspan","colspan"],b={rowspan:1,colspan:1},m=5;class g extends d{static create(e){const t=super.create(e);return p.forEach(r=>{let n=`${r}Id`;t.setAttribute(`data-${r}`,e[r]||n())}),f.forEach(r=>{t.setAttribute(`data-${r}`,e[r]||b[r])}),t}static formats(e){return f.concat(p).reduce((t,r)=>(e.hasAttribute(`data-${r}`)&&(t[r]=e.getAttribute(`data-${r}`)||void 0),t),{})}format(e,t){f.concat(p).indexOf(e)>-1?t?this.domNode.setAttribute(`data-${e}`,t):this.domNode.removeAttribute(`data-${e}`):super.format(e,t)}optimize(e){const t=this.domNode.getAttribute("data-row"),r=this.domNode.getAttribute("data-rowspan"),n=parseInt(this.domNode.getAttribute("data-colspan"),10);!this.statics.requiredContainer||this.parent instanceof this.statics.requiredContainer||this.wrap(this.statics.requiredContainer.blotName,{row:t,colspan:n,rowspan:r}),super.optimize(e)}tableCell(){return this.parent}}g.blotName="table-cell-line",g.ClassName="qlbt-cell-line",g.tagName="DIV";class y extends c{checkMerge(){if(super.checkMerge()&&null!=this.next.children.head){const e=this.children.head.formats()["table-cell-line"],t=this.children.tail.formats()["table-cell-line"],r=this.next.children.head.formats()["table-cell-line"],n=this.next.children.tail.formats()["table-cell-line"];return e.cell===t.cell&&e.cell===r.cell&&e.cell===n.cell}return!1}static create(e){const t=super.create(e);return t.setAttribute("data-row",e.row),f.forEach(r=>{e[r]&&t.setAttribute(r,e[r])}),t}static formats(e){const t={};return e.hasAttribute("data-row")&&(t.row=e.getAttribute("data-row")),f.reduce((t,r)=>(e.hasAttribute(r)&&(t[r]=e.getAttribute(r)),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")),f.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(r=>{r.format(e,t)})}format(e,t){f.indexOf(e)>-1?(this.toggleAttribute(e,t),this.formatChildren(e,t)):["row"].indexOf(e)>-1?(this.toggleAttribute(`data-${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()}}y.blotName="table",y.tagName="TD";class w extends c{checkMerge(){if(super.checkMerge()&&null!=this.next.children.head){const e=this.children.head.formats(),t=this.children.tail.formats(),r=this.next.children.head.formats(),n=this.next.children.tail.formats();return e.row===t.row&&e.row===r.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-${t}`)&&(e[t]=this.domNode.getAttribute(`data-${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}}w.blotName="table-row",w.tagName="TR";class x extends c{}x.blotName="table-body",x.tagName="TBODY";class v extends d{static create(e){let t=super.create(e);return u.forEach(r=>{t.setAttribute(`${r}`,e[r]||h[r])}),t}static formats(e){return u.reduce((t,r)=>(e.hasAttribute(`${r}`)&&(t[r]=e.getAttribute(`${r}`)||void 0),t),{})}format(e,t){u.indexOf(e)>-1?this.domNode.setAttribute(`${e}`,t||h[e]):super.format(e,t)}html(){return this.domNode.outerHTML}}v.blotName="table-col",v.tagName="col";class N extends c{}N.blotName="table-col-group",N.tagName="colgroup";class C extends c{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()[v.blotName].width,10),0);this.domNode.style.width=`${t}px`},0)}cells(e){return this.rows().map(t=>t.children.at(e))}colGroup(){return this.children.head}deleteColumns(e,t=[],r){var n=this.descendants(x);const o=l(n,1)[0];if(null==o||null==o.children.head)return;const i=this.descendants(y),a=[],d=[];if(i.forEach(t=>{const n=(0,s.getRelativeRect)(t.domNode.getBoundingClientRect(),r);n.x+m>e.x&&n.x1-m<e.x1?a.push(t):n.x<e.x+m&&n.x1>e.x1-m&&d.push(t)}),a.length===i.length)return this.tableDestroy(),!0;t.forEach(e=>{this.colGroup().children.at(t[0]).remove()}),a.forEach(e=>{e.remove()}),d.forEach(e=>{const r=parseInt(e.formats().colspan,10);parseInt(e.formats().width,10);e.format("colspan",r-t.length)}),this.updateTableWidth()}deleteRow(e,t){var r=this.descendants(x);const n=l(r,1)[0];if(null==n||null==n.children.head)return;const o=this.descendants(y),i=[],a=[],d=[];if(o.forEach(r=>{const n=(0,s.getRelativeRect)(r.domNode.getBoundingClientRect(),t);n.y>e.y-m&&n.y1<e.y1+m?i.push(r):n.y<e.y+m&&n.y1>e.y1-m&&(a.push(r),Math.abs(n.y-e.y)<m&&d.push(r))}),i.length===o.length)return void this.tableDestroy();const c=this.rows().reduce((r,n)=>{let l=(0,s.getRelativeRect)(n.domNode.getBoundingClientRect(),t);return l.y>e.y-m&&l.y1<e.y1+m&&(r+=1),r},0);d.forEach(e=>{const r=(0,s.getRelativeRect)(e.domNode.getBoundingClientRect(),t),n=e.parent.next,l=n.children.reduce((e,n)=>{const l=(0,s.getRelativeRect)(n.domNode.getBoundingClientRect(),t);return Math.abs(r.x1-l.x)<m&&(e=n),e},null);n.insertBefore(e,l),e.format("row",n.formats().row)}),i.forEach(e=>{e.remove()}),a.forEach(e=>{const t=parseInt(e.formats().rowspan,10);e.format("rowspan",t-c)})}tableDestroy(){const e=i.default.find(this.scroll.domNode.parentNode),t=e.getModule("better-table");this.remove(),t.hideTableTools(),e.update(i.default.sources.USER)}insertCell(e,t){const r=R(),n=e.formats().row,l=this.scroll.create(y.blotName,Object.assign({},b,{row:n})),o=this.scroll.create(g.blotName,{row:n,cell:r});l.appendChild(o),t?e.insertBefore(l,t):e.appendChild(l)}insertColumn(e,t,r=!0,n){var o=this.descendants(x);const i=l(o,1)[0];var a=this.descendants(N);const d=l(a,1)[0],c=this.descendants(v);let u=[],h=[],p=[];if(null==i||null==i.children.head)return;this.descendants(y).forEach(t=>{const l=(0,s.getRelativeRect)(t.domNode.getBoundingClientRect(),n);r?Math.abs(l.x1-e.x1)<m?u.push(t):e.x1-l.x>m&&e.x1-l.x1<-m&&h.push(t):Math.abs(l.x-e.x)<m?u.push(t):e.x-l.x>m&&e.x-l.x1<-m&&h.push(t)}),u.forEach(e=>{const t=r?e.next:e,n=R(),l=e.parent,o=l.formats().row,i=e.formats(),s=this.scroll.create(y.blotName,Object.assign({},b,{row:o,rowspan:i.rowspan})),a=this.scroll.create(g.blotName,{row:o,cell:n,rowspan:i.rowspan});s.appendChild(a),t?l.insertBefore(s,t):l.appendChild(s),p.push(s)});const f=this.scroll.create(v.blotName,!0);let w=r?c[t].next:c[t];return w?d.insertBefore(f,w):d.appendChild(f),h.forEach(e=>{const t=e.formats().colspan;e.format("colspan",parseInt(t,10)+1),p.push(e)}),p.sort((e,t)=>{return e.domNode.getBoundingClientRect().y-t.domNode.getBoundingClientRect().y}),this.updateTableWidth(),p}insertRow(e,t,r){var n=this.descendants(x);const o=l(n,1)[0];if(null==o||null==o.children.head)return;const i=this.descendants(y),d=q(),c=this.scroll.create(w.blotName,{row:d});let u=[],h=[],p=[];i.forEach(n=>{const l=(0,s.getRelativeRect)(n.domNode.getBoundingClientRect(),r);t?Math.abs(l.y1-e.y1)<m?u.push(n):e.y1-l.y>m&&e.y1-l.y1<-m&&h.push(n):Math.abs(l.y-e.y)<m?u.push(n):e.y-l.y>m&&e.y-l.y1<-m&&h.push(n)});const f=(e,t)=>{return e.domNode.getBoundingClientRect().x-t.domNode.getBoundingClientRect().x};u.sort(f),u.forEach(e=>{const t=R(),r=e.formats(),n=this.scroll.create(y.blotName,Object.assign({},b,{row:d,colspan:r.colspan})),l=this.scroll.create(g.blotName,{row:d,cell:t,colspan:r.colspan}),o=this.scroll.create(a.blotName);l.appendChild(o),n.appendChild(l),c.appendChild(n),p.push(n)}),h.forEach(e=>{const t=parseInt(e.formats().rowspan,10);e.format("rowspan",t+1),p.push(e)});const v=this.rows().find(n=>{let l=(0,s.getRelativeRect)(n.domNode.getBoundingClientRect(),r);return t?Math.abs(l.y-e.y-e.height)<m:Math.abs(l.y-e.y)<m});return o.insertBefore(c,v),p.sort(f),p}mergeCells(e,t,r,n,l){const o=t.reduce((e,t,l)=>(0!==l?(e&&t.moveChildren(e),t.remove()):(t.format("colspan",n),t.format("rowspan",r),e=t),e),null);let i=o.domNode.getAttribute("data-row"),s=o.children.head.domNode.getAttribute("data-cell");return o.children.forEach(e=>{e.format("cell",s),e.format("row",i),e.format("colspan",n),e.format("rowspan",r)}),o}unmergeCells(e,t){let r={},n=1,l=1;e.forEach(e=>{if(r=e.formats(),n=r.rowspan,(l=r.colspan)>1){let t=e.next,r=e.row();e.format("colspan",1);for(let e=l;e>1;e--)this.insertCell(r,t)}if(n>1){let r=n,o=e.row().next;for(;r>1;){let n=o.children.reduce((r,n)=>{let l=(0,s.getRelativeRect)(e.domNode.getBoundingClientRect(),t),o=(0,s.getRelativeRect)(n.domNode.getBoundingClientRect(),t);return Math.abs(l.x1-o.x)<m&&(r=n),r},null);for(let e=l;e>0;e--)this.insertCell(o,n);r-=1,o=o.next}e.format("rowspan",1)}})}rows(){const e=this.children.tail;return null==e?[]:e.children.map(e=>e)}}C.blotName="table-container",C.className="quill-better-table",C.tagName="TABLE";class T extends c{constructor(e,t){super(e,t);const r=i.default.find(e.domNode.parentNode);t.addEventListener("scroll",e=>{const t=r.getModule("better-table");t.columnTool&&(t.columnTool.domNode.scrollLeft=e.target.scrollLeft),t.tableSelection&&t.tableSelection.selectedTds.length>0&&t.tableSelection.repositionHelpLines()},!1)}}function q(){return`row-${Math.random().toString(36).slice(2,6)}`}function R(){return`cell-${Math.random().toString(36).slice(2,6)}`}T.blotName="table-view",T.className="quill-better-table-wrapper",T.tagName="DIV",T.allowedChildren=[C],C.requiredContainer=T,C.allowedChildren=[x,N],x.requiredContainer=C,x.allowedChildren=[w],w.requiredContainer=x,w.allowedChildren=[y],y.requiredContainer=w,y.allowedChildren=[g],g.requiredContainer=y,N.allowedChildren=[v],N.requiredContainer=C,v.requiredContainer=N,t.TableCol=v,t.TableColGroup=N,t.TableCellLine=g,t.TableCell=y,t.TableRow=w,t.TableBody=x,t.TableContainer=C,t.TableViewWrapper=T,t.rowId=q,t.cellId=R,t.CELL_ATTRIBUTES=f},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=function(){return function(e,t){if(Array.isArray(e))return e;if(Symbol.iterator in Object(e))return function(e,t){var r=[],n=!0,l=!1,o=void 0;try{for(var i,s=e[Symbol.iterator]();!(n=(i=s.next()).done)&&(r.push(i.value),!t||r.length!==t);n=!0);}catch(e){l=!0,o=e}finally{try{!n&&s.return&&s.return()}finally{if(l)throw o}}return r}(e,t);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}(),l=c(r(0)),o=c(r(4)),i=c(r(5)),s=c(r(6)),a=r(7),d=r(2);function c(e){return e&&e.__esModule?e:{default:e}}const u=l.default.import("core/module"),h=l.default.import("delta");class p extends u{static register(){l.default.register(d.TableCol,!0),l.default.register(d.TableColGroup,!0),l.default.register(d.TableCellLine,!0),l.default.register(d.TableCell,!0),l.default.register(d.TableRow,!0),l.default.register(d.TableBody,!0),l.default.register(d.TableContainer,!0),l.default.register(d.TableViewWrapper,!0)}constructor(e,t){super(e,t),this.quill.root.addEventListener("click",r=>{if(!r.path||r.path.length<=0)return;const n=r.path.filter(e=>e.tagName&&"TABLE"===e.tagName.toUpperCase()&&e.classList.contains("quill-better-table"))[0];if(n){if(this.table===n)return;this.table&&this.hideTableTools(),this.showTableTools(n,e,t)}else this.table&&this.hideTableTools()},!1),this.quill.root.addEventListener("contextmenu",r=>{if(!this.table)return!0;if(r.preventDefault(),!r.path||r.path.length<=0)return;const n=r.path.filter(e=>e.tagName&&"TABLE"===e.tagName.toUpperCase()&&e.classList.contains("quill-better-table"))[0],l=r.path.filter(e=>e.tagName&&"TR"===e.tagName.toUpperCase()&&e.getAttribute("data-row"))[0],o=r.path.filter(e=>e.tagName&&"TD"===e.tagName.toUpperCase()&&e.getAttribute("data-row"))[0];let i=this.tableSelection.selectedTds.map(e=>e.domNode).includes(o);(this.tableSelection.selectedTds.length<=0||!i)&&this.tableSelection.setSelection(o.getBoundingClientRect(),o.getBoundingClientRect()),this.tableOperationMenu&&(this.tableOperationMenu=this.tableOperationMenu.destroy()),n&&(this.tableOperationMenu=new s.default({table:n,row:l,cell:o,left:r.pageX,top:r.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;var r=this.quill.getLine(e.index);const l=n(r,1)[0];if(0===t.offset){var o=this.quill.getLine(e.index-1);const t=n(o,1)[0];if(null!=t&&"table-cell-line"===t.statics.blotName&&"table-cell-line"!==l.statics.blotName)return!1}return!0});let r=e.keyboard.bindings.Backspace.pop();e.keyboard.bindings.Backspace.splice(0,1,r),e.clipboard.addMatcher("td",a.matchTableCell),e.clipboard.addMatcher("th",a.matchTableHeader),e.clipboard.addMatcher("table",a.matchTable),e.clipboard.matchers=e.clipboard.matchers.filter(e=>"tr"!==e[0])}getTable(e=this.quill.getSelection()){if(null==e)return[null,null,null,-1];var t=this.quill.getLine(e.index),r=n(t,2);const l=r[0],o=r[1];if(null==l||l.statics.blotName!==d.TableCellLine.blotName)return[null,null,null,-1];const i=l.tableCell(),s=i.row();return[s.table(),s,i,o]}insertTable(e,t){const r=this.quill.getSelection(!0);if(null==r)return;this.quill.getLeaf(r.index)[0],this.quill.getLeaf(r.index+1)[0];let n=(new h).retain(r.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 r=(0,d.rowId)();return new Array(t).fill("\n").reduce((e,t)=>(e.insert(t,{"table-cell-line":{row:r,cell:(0,d.cellId)()}}),e),e)},n),this.quill.updateContents(n,l.default.sources.USER),this.quill.setSelection(r.index+t+1,l.default.sources.API)}showTableTools(e,t,r){this.table=e,this.columnTool=new o.default(e,t,r),this.tableSelection=new i.default(e,t,r)}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}}p.keyboardBindings={"table-cell-line backspace":{key:"Backspace",format:["table-cell-line"],collapsed:!0,offset:0,handler(e,t){var r=this.quill.getLine(e.index),l=n(r,2);const o=l[0];l[1];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 r=l.default.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,r.BLOCK)&&!Array.isArray(t.format[n])&&(e[n]=t.format[n]),e),{});this.quill.insertText(e.index,"\n",n["table-cell-line"],l.default.sources.USER),this.quill.setSelection(e.index+1,l.default.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],l.default.sources.USER))})}}},t.default=p},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n,l=r(0),o=(n=l)&&n.__esModule?n:{default:n},i=r(1);const s=12,a=12,d=50,c="#35A7ED";t.default=class{constructor(e,t,r){if(!e)return null;this.table=e,this.quill=t,this.options=r,this.domNode=null,this.initColTool()}initColTool(){const e=this.quill.root.parentNode,t=(this.table.getBoundingClientRect(),e.getBoundingClientRect()),r=this.table.parentNode.getBoundingClientRect();this.domNode=document.createElement("div"),this.domNode.classList.add("qlbt-col-tool"),this.updateToolCells(),e.appendChild(this.domNode),(0,i.css)(this.domNode,{width:`${r.width}px`,height:`${s}px`,left:`${r.left-t.left+e.scrollLeft}px`,top:`${r.top-t.top+e.scrollTop-s-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"),(0,i.css)(e,{height:`${a}px`}),e.appendChild(t),e}updateToolCells(){const e=o.default.find(this.table),t=e.children.tail.children.head.children,r=e.colGroup().children,n=function(e){return e.reduce((e,t)=>{const r=t.formats().colspan;return e+=parseInt(r,10)},0)}(t);let l=Array.from(this.domNode.querySelectorAll(".qlbt-col-tool-cell"));for(let e=0;e<Math.max(n,l.length);e++){let t=r.at(e),o=t&&parseInt(t.formats()[t.statics.blotName].width,10),s=null;l[e]?l[e]&&e>=n?l[e].remove():(s=l[e],(0,i.css)(s,{"min-width":`${o}px`})):(s=this.createToolCell(),this.domNode.appendChild(s),this.addColCellHolderHandler(s),(0,i.css)(s,{"min-width":`${o}px`}))}}destroy(){return this.domNode.remove(),null}addColCellHolderHandler(e){const t=o.default.find(this.table),r=e.querySelector(".qlbt-col-tool-cell-holder");let n=!1,l=0,a=0,u=0,h=0,p={},f={},b=null;const m=e=>{e.preventDefault(),n&&(a=e.clientX,u=h+a-l>=d?a-l:d-h,(0,i.css)(b,{left:`${f.left+f.width-1+u}px`}))},g=o=>{o.preventDefault();const s=Array.from(this.domNode.querySelectorAll(".qlbt-col-tool-cell")).indexOf(e),d=t.colGroup().children.at(s);n&&(d.format("width",h+u),(0,i.css)(e,{"min-width":`${h+u}px`}),l=0,a=0,u=0,h=0,n=!1,r.classList.remove("dragging")),document.removeEventListener("mousemove",m,!1),document.removeEventListener("mouseup",g,!1),p={},f={},b.remove(),b=null,t.updateTableWidth();const c=this.quill.getModule("better-table").tableSelection;c&&c.clearSelection()};r.addEventListener("mousedown",t=>{document.addEventListener("mousemove",m,!1),document.addEventListener("mouseup",g,!1),p=this.table.getBoundingClientRect(),f=e.getBoundingClientRect(),b=document.createElement("div"),(0,i.css)(b,{position:"fixed",top:`${f.top}px`,left:`${f.left+f.width-1}px`,zIndex:"100",height:`${p.height+s+4}px`,width:"1px",backgroundColor:c}),document.body.appendChild(b),n=!0,l=t.clientX,h=f.width,r.classList.add("dragging")},!1)}colToolCells(){return Array.from(this.domNode.querySelectorAll(".qlbt-col-tool-cell"))}}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n,l=r(0),o=(n=l)&&n.__esModule?n:{default:n},i=r(1),s=r(2);const a="#35A7ED",d=["left","right","top","bottom"],c=2;function u(e,t){let r=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),l=Math.min(e.y,t.y,e.y+e.height-1,t.y+t.height-1),o=Math.max(e.y,t.y,e.y+e.height-1,t.y+t.height-1);return{x:r,x1:n,y:l,y1:o,width:n-r,height:o-l}}t.default=class{constructor(e,t,r){if(!e)return null;this.table=e,this.quill=t,this.options=r,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"),(0,i.css)(this[t],{position:"absolute",display:"none","background-color":a}),e.appendChild(this[t])})}mouseDownHandler(e){if(0!==e.button||!e.target.closest(".quill-better-table"))return;this.quill.root.addEventListener("mousemove",l,!1),this.quill.root.addEventListener("mouseup",function e(r){t.quill.root.removeEventListener("mousemove",l,!1),t.quill.root.removeEventListener("mouseup",e,!1),t.dragging=!1},!1);const t=this,r=e.target.closest("td[data-row]"),n=(0,i.getRelativeRect)(r.getBoundingClientRect(),this.quill.root.parentNode);function l(e){if(0!==e.button||!e.target.closest(".quill-better-table"))return;const l=e.target.closest("td[data-row]"),o=(0,i.getRelativeRect)(l.getBoundingClientRect(),t.quill.root.parentNode);t.boundary=u(n,o),t.correctBoundary(),t.selectedTds=t.computeSelectedTds(),t.repositionHelpLines(),r!==l&&t.quill.blur()}this.dragging=!0,this.boundary=u(n,n),this.correctBoundary(),this.selectedTds=this.computeSelectedTds(),this.repositionHelpLines()}correctBoundary(){o.default.find(this.table).descendants(s.TableCell).forEach(e=>{var t=(0,i.getRelativeRect)(e.domNode.getBoundingClientRect(),this.quill.root.parentNode);let r=t.x,n=t.y,l=t.width,o=t.height;(r+c>=this.boundary.x&&r+c<=this.boundary.x1||r-c+l>=this.boundary.x&&r-c+l<=this.boundary.x1)&&(n+c>=this.boundary.y&&n+c<=this.boundary.y1||n-c+o>=this.boundary.y&&n-c+o<=this.boundary.y1)&&(this.boundary=u(this.boundary,{x:r,y:n,width:l,height:o}))})}computeSelectedTds(){return o.default.find(this.table).descendants(s.TableCell).reduce((e,t)=>{var r=(0,i.getRelativeRect)(t.domNode.getBoundingClientRect(),this.quill.root.parentNode);let n=r.x,l=r.y,o=r.width,s=r.height;return n+c>=this.boundary.x&&n-c+o<=this.boundary.x1&&l+c>=this.boundary.y&&l-c+s<=this.boundary.y1&&e.push(t),e},[])}repositionHelpLines(){const e=this.table.parentNode.scrollLeft;(0,i.css)(this.left,{display:"block",left:`${this.boundary.x-e-1}px`,top:`${this.boundary.y}px`,height:`${this.boundary.height+1}px`,width:"1px"}),(0,i.css)(this.right,{display:"block",left:`${this.boundary.x1-e}px`,top:`${this.boundary.y}px`,height:`${this.boundary.height+1}px`,width:"1px"}),(0,i.css)(this.top,{display:"block",left:`${this.boundary.x-1-e}px`,top:`${this.boundary.y}px`,width:`${this.boundary.width+1}px`,height:"1px"}),(0,i.css)(this.bottom,{display:"block",left:`${this.boundary.x-1-e}px`,top:`${this.boundary.y1+1}px`,width:`${this.boundary.width+1}px`,height:"1px"})}refreshHelpLinesPosition(){const e=(0,i.getRelativeRect)(this.selectedTds[0].domNode.getBoundingClientRect(),this.quill.root.parentNode),t=(0,i.getRelativeRect)(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((0,i.getRelativeRect)(e,this.quill.root.parentNode),(0,i.getRelativeRect)(t,this.quill.root.parentNode)),this.correctBoundary(),this.selectedTds=this.computeSelectedTds(),this.repositionHelpLines()}clearSelection(){this.boundary={},this.selectedTds=[],d.forEach(e=>{this[e]&&(0,i.css)(this[e],{display:"none"})})}}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n,l=r(0),o=(n=l)&&n.__esModule?n:{default:n},i=r(1);const s=150,a=200,d={insertColumnRight:{text:"Insert column right",handler(){const e=o.default.find(this.table);let t=c(this.columnToolCells,this.boundary,(e,t)=>Math.abs(e.x+e.width-t.x1)<=5,this.quill.root.parentNode);const r=e.insertColumn(this.boundary,t,!0,this.quill.root.parentNode);this.tableColumnTool.updateToolCells(),this.quill.update(o.default.sources.USER),this.quill.setSelection(this.quill.getIndex(r[0]),0,o.default.sources.SILENT),this.tableSelection.setSelection(r[0].domNode.getBoundingClientRect(),r[0].domNode.getBoundingClientRect())}},insertColumnLeft:{text:"Insert column left",handler(){const e=o.default.find(this.table);let t=c(this.columnToolCells,this.boundary,(e,t)=>Math.abs(e.x-t.x)<=5,this.quill.root.parentNode);const r=e.insertColumn(this.boundary,t,!1,this.quill.root.parentNode);this.tableColumnTool.updateToolCells(),this.quill.update(o.default.sources.USER),this.quill.setSelection(this.quill.getIndex(r[0]),0,o.default.sources.SILENT),this.tableSelection.setSelection(r[0].domNode.getBoundingClientRect(),r[0].domNode.getBoundingClientRect())}},insertRowUp:{text:"Insert row up",handler(){const e=o.default.find(this.table).insertRow(this.boundary,!1,this.quill.root.parentNode);this.quill.update(o.default.sources.USER),this.quill.setSelection(this.quill.getIndex(e[0]),0,o.default.sources.SILENT),this.tableSelection.setSelection(e[0].domNode.getBoundingClientRect(),e[0].domNode.getBoundingClientRect())}},insertRowDown:{text:"Insert row down",handler(){const e=o.default.find(this.table).insertRow(this.boundary,!0,this.quill.root.parentNode);this.quill.update(o.default.sources.USER),this.quill.setSelection(this.quill.getIndex(e[0]),0,o.default.sources.SILENT),this.tableSelection.setSelection(e[0].domNode.getBoundingClientRect(),e[0].domNode.getBoundingClientRect())}},mergeCells:{text:"Merge selected cells",handler(){const e=o.default.find(this.table),t=e.rows().reduce((e,t)=>{let r=(0,i.getRelativeRect)(t.domNode.getBoundingClientRect(),this.quill.root.parentNode);return r.y>this.boundary.y-5&&r.y+r.height<this.boundary.y+this.boundary.height+5&&(e+=1),e},0),r=this.columnToolCells.reduce((e,t)=>{let r=(0,i.getRelativeRect)(t.getBoundingClientRect(),this.quill.root.parentNode);return r.x>this.boundary.x-5&&r.x+r.width<this.boundary.x+this.boundary.width+5&&(e+=1),e},0),n=e.mergeCells(this.boundary,this.selectedTds,t,r,this.quill.root.parentNode);this.quill.update(o.default.sources.USER),this.tableSelection.setSelection(n.domNode.getBoundingClientRect(),n.domNode.getBoundingClientRect())}},unmergeCells:{text:"Unmerge cells",handler(){o.default.find(this.table).unmergeCells(this.selectedTds,this.quill.root.parentNode),this.quill.update(o.default.sources.USER),this.tableSelection.clearSelection()}},deleteColumn:{text:"Delete selected columns",handler(){const e=o.default.find(this.table);let t=(r=this.columnToolCells,n=this.boundary,l=((e,t)=>e.x+5>t.x&&e.x+e.width-5<t.x1),s=this.quill.root.parentNode,r.reduce((e,t)=>{let o=(0,i.getRelativeRect)(t.getBoundingClientRect(),s);return l(o,n)&&e.push(r.indexOf(t)),e},[]));var r,n,l,s;e.deleteColumns(this.boundary,t,this.quill.root.parentNode)||(this.tableColumnTool.updateToolCells(),this.quill.update(o.default.sources.USER),this.tableSelection.clearSelection())}},deleteRow:{text:"Delete selected rows",handler(){o.default.find(this.table).deleteRow(this.boundary,this.quill.root.parentNode),this.quill.update(o.default.sources.USER),this.tableSelection.clearSelection()}},deleteTable:{text:"Delete table",handler(){const e=this.quill.getModule("better-table"),t=o.default.find(this.table);e.hideTableTools(),t.remove(),this.quill.update(o.default.sources.USER)}}};function c(e,t,r,n){return e.reduce((l,o)=>{let s=(0,i.getRelativeRect)(o.getBoundingClientRect(),n);return r(s,t)&&(l=e.indexOf(o)),l},!1)}t.default=class{constructor(e,t,r){const n=t.getModule("better-table");this.tableSelection=n.tableSelection,this.table=e.table,this.quill=t,this.options=r,this.menuItems=Object.assign({},d,r.items),this.tableColumnTool=n.columnTool,this.boundary=this.tableSelection.boundary,this.selectedTds=this.tableSelection.selectedTds,this.destroyHanlder=this.destroy.bind(this),this.columnToolCells=this.tableColumnTool.colToolCells(),this.menuInitial(e),this.mount(),document.addEventListener("click",this.destroyHanlder,!1)}mount(){document.body.appendChild(this.domNode)}destroy(){return this.domNode.remove(),document.removeEventListener("click",this.destroyHanlder,!1),null}menuInitial({table:e,left:t,top:r}){this.domNode=document.createElement("div"),this.domNode.classList.add("qlbt-operation-menu"),(0,i.css)(this.domNode,{position:"absolute",left:`${t}px`,top:`${r}px`,"min-height":`${s}px`,width:`${a}px`});for(let e in this.menuItems)this.menuItems[e]&&this.domNode.appendChild(this.menuItemCreator(Object.assign({},d[e],this.menuItems[e])))}menuItemCreator({text:e,handler:t}){const r=document.createElement("div");return r.classList.add("qlbt-operation-menu-item"),r.innerText=e,r.addEventListener("click",t.bind(this),!1),r}}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.matchTableCell=function(e,t,r){const n=e.parentNode,l="TABLE"===n.parentNode.tagName?n.parentNode:n.parentNode.parentNode,o=Array.from(l.querySelectorAll("tr")),a=Array.from(n.querySelectorAll("td")),d=o.indexOf(n)+1,c=a.indexOf(e)+1,u=e.getAttribute("colspan")||!1,h=e.getAttribute("rowspan")||!1;if(0===t.length())return t=(new s).insert("\n",{"table-cell-line":{row:d,cell:c,rowspan:h,colspan:u}});return(t=t.reduce((e,t)=>{if(t.insert&&"string"==typeof t.insert){const r=[];let n=t.insert,l=0;for(let e=0;e<t.insert.length;e++)"\n"===n.charAt(e)&&(0===e?r.push("\n"):(r.push(n.substring(l,e)),r.push("\n")),l=e+1);const o=n.substring(l);o&&r.push(o),r.forEach(r=>{"\n"===r?e.insert("\n",t.attributes):e.insert(r,(0,i._omit)(t.attributes,["table","table-cell-line"]))})}else e.insert(t.insert,t.attributes);return e},new s)).reduce((e,t)=>(t.insert&&"string"==typeof t.insert&&t.insert.startsWith("\n")?e.insert(t.insert,Object.assign({},Object.assign({},{row:d},t.attributes.table),{"table-cell-line":{row:d,cell:c,rowspan:h,colspan:u}},(0,i._omit)(t.attributes,["table"]))):e.insert(t.insert,Object.assign({},(0,i._omit)(t.attributes,["table","table-cell-line"]))),e),new s)},t.matchTableHeader=function(e,t,r){const n=e.parentNode,l="TABLE"===n.parentNode.tagName?n.parentNode:n.parentNode.parentNode,o=Array.from(l.querySelectorAll("tr")),a=Array.from(n.querySelectorAll("th")),d=o.indexOf(n)+1,c=a.indexOf(e)+1,u=e.getAttribute("colspan")||!1,h=e.getAttribute("rowspan")||!1;if(0===t.length())return t=(new s).insert("\n",{"table-cell-line":{row:d,cell:c,rowspan:h,colspan:u}});return(t=t.reduce((e,t)=>{if(t.insert&&"string"==typeof t.insert){const r=[];let n=t.insert,l=0;for(let e=0;e<t.insert.length;e++)"\n"===n.charAt(e)&&(0===e?r.push("\n"):(r.push(n.substring(l,e)),r.push("\n")),l=e+1);const o=n.substring(l);o&&r.push(o),r.indexOf("\n")<0&&r.push("\n"),r.forEach(r=>{"\n"===r?e.insert("\n",{"table-cell-line":{row:d,cell:c,rowspan:h,colspan:u}}):e.insert(r,t.attributes)})}else e.insert(t.insert,t.attributes);return e},new s)).reduce((e,t)=>(t.insert&&"string"==typeof t.insert&&t.insert.startsWith("\n")?e.insert(t.insert,Object.assign({},{"table-cell-line":{row:d,cell:c,rowspan:h,colspan:u}})):e.insert(t.insert,Object.assign({},(0,i._omit)(t.attributes,["table","table-cell-line"]))),e),new s)},t.matchTable=function(e,t,r){let n=new s;const l=e.querySelector("tr"),o=Array.from(l.querySelectorAll("td")).concat(Array.from(l.querySelectorAll("th"))).reduce((e,t)=>{const r=t.getAttribute("colspan")||1;return e+=parseInt(r,10)},0),i=e.querySelectorAll("col").length;if(i===o)return t;{for(let e=0;e<o-i;e++)n.insert("\n",{"table-col":!0});if(0===i)return n.concat(t);let e=0;return t.reduce((t,r)=>(t.insert(r.insert,r.attributes),r.attributes&&r.attributes["table-col"]&&(e+=r.insert.length)===i&&(t=t.concat(n)),t),new s)}};var n,l=r(0),o=(n=l)&&n.__esModule?n:{default:n},i=r(1);const s=o.default.import("delta")},,function(e,t,r){e.exports=r(3)}]).default});
!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,r){!function(e,t){if(!v[e]||!x[e])return;for(var r in x[e]=!1,t)Object.prototype.hasOwnProperty.call(t,r)&&(b[r]=t[r]);0==--g&&0===y&&q()}(e,r),t&&t(e,r)};var r,n=!0,l="8e86b065f4f6db1f1756",o=1e4,i={},s=[],a=[];function d(e){var t=E[e];if(!t)return S;var n=function(n){return t.hot.active?(E[n]?-1===E[n].parents.indexOf(e)&&E[n].parents.push(e):(s=[e],r=n),-1===t.children.indexOf(n)&&t.children.push(n)):(console.warn("[HMR] unexpected require("+n+") from disposed module "+e),s=[]),S(n)},l=function(e){return{configurable:!0,enumerable:!0,get:function(){return S[e]},set:function(t){S[e]=t}}};for(var o in S)Object.prototype.hasOwnProperty.call(S,o)&&"e"!==o&&"t"!==o&&Object.defineProperty(n,o,l(o));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]||T(e),0===y&&0===g&&q())}},n.t=function(e,t){return 1&t&&(e=n(e)),S.t(e,-2&t)},n}function c(e){var t={_acceptedDependencies:{},_declinedDependencies:{},_selfAccepted:!1,_selfDeclined:!1,_disposeHandlers:[],_main:r!==e,active:!0,accept:function(e,r){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<e.length;n++)t._acceptedDependencies[e[n]]=r||function(){};else t._acceptedDependencies[e]=r||function(){}},decline:function(e){if(void 0===e)t._selfDeclined=!0;else if("object"==typeof e)for(var r=0;r<e.length;r++)t._declinedDependencies[e[r]]=!0;else t._declinedDependencies[e]=!0},dispose:function(e){t._disposeHandlers.push(e)},addDisposeHandler:function(e){t._disposeHandlers.push(e)},removeDisposeHandler:function(e){var r=t._disposeHandlers.indexOf(e);r>=0&&t._disposeHandlers.splice(r,1)},check:C,apply:R,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:i[e]};return r=void 0,t}var u=[],h="idle";function p(e){h=e;for(var t=0;t<u.length;t++)u[t].call(null,e)}var f,b,m,g=0,y=0,w={},x={},v={};function N(e){return+e+""===e?+e:e}function C(e){if("idle"!==h)throw new Error("check() is only allowed in idle status");return n=e,p("check"),(t=o,t=t||1e4,new Promise(function(e,r){if("undefined"==typeof XMLHttpRequest)return r(new Error("No browser support"));try{var n=new XMLHttpRequest,o=S.p+""+l+".hot-update.json";n.open("GET",o,!0),n.timeout=t,n.send(null)}catch(e){return r(e)}n.onreadystatechange=function(){if(4===n.readyState)if(0===n.status)r(new Error("Manifest request to "+o+" timed out."));else if(404===n.status)e();else if(200!==n.status&&304!==n.status)r(new Error("Manifest request to "+o+" failed."));else{try{var t=JSON.parse(n.responseText)}catch(e){return void r(e)}e(t)}}})).then(function(e){if(!e)return p("idle"),null;x={},w={},v=e.c,m=e.h,p("prepare");var t=new Promise(function(e,t){f={resolve:e,reject:t}});b={};return T(2),"prepare"===h&&0===y&&0===g&&q(),t});var t}function T(e){v[e]?(x[e]=!0,g++,function(e){var t=document.createElement("script");t.charset="utf-8",t.src=S.p+""+e+"."+l+".hot-update.js",document.head.appendChild(t)}(e)):w[e]=!0}function q(){p("ready");var e=f;if(f=null,e)if(n)Promise.resolve().then(function(){return R(n)}).then(function(t){e.resolve(t)},function(t){e.reject(t)});else{var t=[];for(var r in b)Object.prototype.hasOwnProperty.call(b,r)&&t.push(N(r));e.resolve(t)}}function R(t){if("ready"!==h)throw new Error("apply() is only allowed in ready status");var r,n,o,a,d;function c(e){for(var t=[e],r={},n=t.slice().map(function(e){return{chain:[e],id:e}});n.length>0;){var l=n.pop(),o=l.id,i=l.chain;if((a=E[o])&&!a.hot._selfAccepted){if(a.hot._selfDeclined)return{type:"self-declined",chain:i,moduleId:o};if(a.hot._main)return{type:"unaccepted",chain:i,moduleId:o};for(var s=0;s<a.parents.length;s++){var d=a.parents[s],c=E[d];if(c){if(c.hot._declinedDependencies[o])return{type:"declined",chain:i.concat([d]),moduleId:o,parentId:d};-1===t.indexOf(d)&&(c.hot._acceptedDependencies[o]?(r[d]||(r[d]=[]),u(r[d],[o])):(delete r[d],t.push(d),n.push({chain:i.concat([d]),id:d})))}}}}return{type:"accepted",moduleId:e,outdatedModules:t,outdatedDependencies:r}}function u(e,t){for(var r=0;r<t.length;r++){var n=t[r];-1===e.indexOf(n)&&e.push(n)}}t=t||{};var f={},g=[],y={},w=function(){console.warn("[HMR] unexpected require("+C.moduleId+") to disposed module")};for(var x in b)if(Object.prototype.hasOwnProperty.call(b,x)){var C;d=N(x);var T=!1,q=!1,R=!1,A="";switch((C=b[x]?c(d):{type:"disposed",moduleId:x}).chain&&(A="\nUpdate propagation: "+C.chain.join(" -> ")),C.type){case"self-declined":t.onDeclined&&t.onDeclined(C),t.ignoreDeclined||(T=new Error("Aborted because of self decline: "+C.moduleId+A));break;case"declined":t.onDeclined&&t.onDeclined(C),t.ignoreDeclined||(T=new Error("Aborted because of declined dependency: "+C.moduleId+" in "+C.parentId+A));break;case"unaccepted":t.onUnaccepted&&t.onUnaccepted(C),t.ignoreUnaccepted||(T=new Error("Aborted because "+d+" is not accepted"+A));break;case"accepted":t.onAccepted&&t.onAccepted(C),q=!0;break;case"disposed":t.onDisposed&&t.onDisposed(C),R=!0;break;default:throw new Error("Unexception type "+C.type)}if(T)return p("abort"),Promise.reject(T);if(q)for(d in y[d]=b[d],u(g,C.outdatedModules),C.outdatedDependencies)Object.prototype.hasOwnProperty.call(C.outdatedDependencies,d)&&(f[d]||(f[d]=[]),u(f[d],C.outdatedDependencies[d]));R&&(u(g,[C.moduleId]),y[d]=w)}var O,B=[];for(n=0;n<g.length;n++)d=g[n],E[d]&&E[d].hot._selfAccepted&&B.push({module:d,errorHandler:E[d].hot._selfAccepted});p("dispose"),Object.keys(v).forEach(function(e){!1===v[e]&&function(e){delete installedChunks[e]}(e)});for(var L,M,_=g.slice();_.length>0;)if(d=_.pop(),a=E[d]){var I={},j=a.hot._disposeHandlers;for(o=0;o<j.length;o++)(r=j[o])(I);for(i[d]=I,a.hot.active=!1,delete E[d],delete f[d],o=0;o<a.children.length;o++){var k=E[a.children[o]];k&&((O=k.parents.indexOf(d))>=0&&k.parents.splice(O,1))}}for(d in f)if(Object.prototype.hasOwnProperty.call(f,d)&&(a=E[d]))for(M=f[d],o=0;o<M.length;o++)L=M[o],(O=a.children.indexOf(L))>=0&&a.children.splice(O,1);for(d in p("apply"),l=m,y)Object.prototype.hasOwnProperty.call(y,d)&&(e[d]=y[d]);var D=null;for(d in f)if(Object.prototype.hasOwnProperty.call(f,d)&&(a=E[d])){M=f[d];var $=[];for(n=0;n<M.length;n++)if(L=M[n],r=a.hot._acceptedDependencies[L]){if(-1!==$.indexOf(r))continue;$.push(r)}for(n=0;n<$.length;n++){r=$[n];try{r(M)}catch(e){t.onErrored&&t.onErrored({type:"accept-errored",moduleId:d,dependencyId:M[n],error:e}),t.ignoreErrored||D||(D=e)}}}for(n=0;n<B.length;n++){var H=B[n];d=H.module,s=[d];try{S(d)}catch(e){if("function"==typeof H.errorHandler)try{H.errorHandler(e)}catch(r){t.onErrored&&t.onErrored({type:"self-accept-error-handler-errored",moduleId:d,error:r,originalError:e}),t.ignoreErrored||D||(D=r),D||(D=e)}else t.onErrored&&t.onErrored({type:"self-accept-errored",moduleId:d,error:e}),t.ignoreErrored||D||(D=e)}}return D?(p("fail"),Promise.reject(D)):(p("idle"),new Promise(function(e){e(g)}))}var E={};function S(t){if(E[t])return E[t].exports;var r=E[t]={i:t,l:!1,exports:{},hot:c(t),parents:(a=s,s=[],a),children:[]};return e[t].call(r.exports,r,r.exports,d(t)),r.l=!0,r.exports}return S.m=e,S.c=E,S.d=function(e,t,r){S.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},S.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},S.t=function(e,t){if(1&t&&(e=S(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(S.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var n in e)S.d(r,n,function(t){return e[t]}.bind(null,n));return r},S.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return S.d(t,"a",t),t},S.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},S.p="",S.h=function(){return l},d(9)(S.s=9)}([function(t,r){t.exports=e},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.css=function(e,t){if("object"==typeof t)for(let r in t)e.style[r]=t[r]},t.getRelativeRect=function(e,t){let r=t.getBoundingClientRect();return{x:e.x-r.x-t.scrollLeft,y:e.y-r.y-t.scrollTop,x1:e.x-r.x-t.scrollLeft+e.width,y1:e.y-r.y-t.scrollTop+e.height,width:e.width,height:e.height}},t._omit=function(e,t){return e&&Object.keys(e).reduce((r,n)=>t.includes(n)?r:Object.assign({},r,{[n]:e[n]}),{})}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.CELL_ATTRIBUTES=t.cellId=t.rowId=t.TableViewWrapper=t.TableContainer=t.TableBody=t.TableRow=t.TableCell=t.TableCellLine=t.TableColGroup=t.TableCol=void 0;var n,l=function(){return function(e,t){if(Array.isArray(e))return e;if(Symbol.iterator in Object(e))return function(e,t){var r=[],n=!0,l=!1,o=void 0;try{for(var i,s=e[Symbol.iterator]();!(n=(i=s.next()).done)&&(r.push(i.value),!t||r.length!==t);n=!0);}catch(e){l=!0,o=e}finally{try{!n&&s.return&&s.return()}finally{if(l)throw o}}return r}(e,t);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}(),o=r(0),i=(n=o)&&n.__esModule?n:{default:n},s=r(1);const a=i.default.import("blots/break"),d=i.default.import("blots/block"),c=i.default.import("blots/container"),u=["width"],h={width:100},p=["row","cell"],f=["rowspan","colspan"],b={rowspan:1,colspan:1},m=5;class g extends d{static create(e){const t=super.create(e);return p.forEach(r=>{let n=`${r}Id`;t.setAttribute(`data-${r}`,e[r]||n())}),f.forEach(r=>{t.setAttribute(`data-${r}`,e[r]||b[r])}),t}static formats(e){return f.concat(p).reduce((t,r)=>(e.hasAttribute(`data-${r}`)&&(t[r]=e.getAttribute(`data-${r}`)||void 0),t),{})}format(e,t){f.concat(p).indexOf(e)>-1?t?this.domNode.setAttribute(`data-${e}`,t):this.domNode.removeAttribute(`data-${e}`):super.format(e,t)}optimize(e){const t=this.domNode.getAttribute("data-row"),r=this.domNode.getAttribute("data-rowspan"),n=parseInt(this.domNode.getAttribute("data-colspan"),10);!this.statics.requiredContainer||this.parent instanceof this.statics.requiredContainer||this.wrap(this.statics.requiredContainer.blotName,{row:t,colspan:n,rowspan:r}),super.optimize(e)}tableCell(){return this.parent}}g.blotName="table-cell-line",g.ClassName="qlbt-cell-line",g.tagName="DIV";class y extends c{checkMerge(){if(super.checkMerge()&&null!=this.next.children.head){const e=this.children.head.formats()["table-cell-line"],t=this.children.tail.formats()["table-cell-line"],r=this.next.children.head.formats()["table-cell-line"],n=this.next.children.tail.formats()["table-cell-line"];return e.cell===t.cell&&e.cell===r.cell&&e.cell===n.cell}return!1}static create(e){const t=super.create(e);return t.setAttribute("data-row",e.row),f.forEach(r=>{e[r]&&t.setAttribute(r,e[r])}),t}static formats(e){const t={};return e.hasAttribute("data-row")&&(t.row=e.getAttribute("data-row")),f.reduce((t,r)=>(e.hasAttribute(r)&&(t[r]=e.getAttribute(r)),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")),f.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(r=>{r.format(e,t)})}format(e,t){f.indexOf(e)>-1?(this.toggleAttribute(e,t),this.formatChildren(e,t)):["row"].indexOf(e)>-1?(this.toggleAttribute(`data-${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()}}y.blotName="table",y.tagName="TD";class w extends c{checkMerge(){if(super.checkMerge()&&null!=this.next.children.head){const e=this.children.head.formats(),t=this.children.tail.formats(),r=this.next.children.head.formats(),n=this.next.children.tail.formats();return e.row===t.row&&e.row===r.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-${t}`)&&(e[t]=this.domNode.getAttribute(`data-${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}}w.blotName="table-row",w.tagName="TR";class x extends c{}x.blotName="table-body",x.tagName="TBODY";class v extends d{static create(e){let t=super.create(e);return u.forEach(r=>{t.setAttribute(`${r}`,e[r]||h[r])}),t}static formats(e){return u.reduce((t,r)=>(e.hasAttribute(`${r}`)&&(t[r]=e.getAttribute(`${r}`)||void 0),t),{})}format(e,t){u.indexOf(e)>-1?this.domNode.setAttribute(`${e}`,t||h[e]):super.format(e,t)}html(){return this.domNode.outerHTML}}v.blotName="table-col",v.tagName="col";class N extends c{}N.blotName="table-col-group",N.tagName="colgroup";class C extends c{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()[v.blotName].width,10),0);this.domNode.style.width=`${t}px`},0)}cells(e){return this.rows().map(t=>t.children.at(e))}colGroup(){return this.children.head}deleteColumns(e,t=[],r){var n=this.descendants(x);const o=l(n,1)[0];if(null==o||null==o.children.head)return;const i=this.descendants(y),a=[],d=[];if(i.forEach(t=>{const n=(0,s.getRelativeRect)(t.domNode.getBoundingClientRect(),r);n.x+m>e.x&&n.x1-m<e.x1?a.push(t):n.x<e.x+m&&n.x1>e.x1-m&&d.push(t)}),a.length===i.length)return this.tableDestroy(),!0;t.forEach(e=>{this.colGroup().children.at(t[0]).remove()}),a.forEach(e=>{e.remove()}),d.forEach(e=>{const r=parseInt(e.formats().colspan,10);parseInt(e.formats().width,10);e.format("colspan",r-t.length)}),this.updateTableWidth()}deleteRow(e,t){var r=this.descendants(x);const n=l(r,1)[0];if(null==n||null==n.children.head)return;const o=this.descendants(y),i=[],a=[],d=[];if(o.forEach(r=>{const n=(0,s.getRelativeRect)(r.domNode.getBoundingClientRect(),t);n.y>e.y-m&&n.y1<e.y1+m?i.push(r):n.y<e.y+m&&n.y1>e.y1-m&&(a.push(r),Math.abs(n.y-e.y)<m&&d.push(r))}),i.length===o.length)return void this.tableDestroy();const c=this.rows().reduce((r,n)=>{let l=(0,s.getRelativeRect)(n.domNode.getBoundingClientRect(),t);return l.y>e.y-m&&l.y1<e.y1+m&&(r+=1),r},0);d.forEach(e=>{const r=(0,s.getRelativeRect)(e.domNode.getBoundingClientRect(),t),n=e.parent.next,l=n.children.reduce((e,n)=>{const l=(0,s.getRelativeRect)(n.domNode.getBoundingClientRect(),t);return Math.abs(r.x1-l.x)<m&&(e=n),e},null);n.insertBefore(e,l),e.format("row",n.formats().row)}),i.forEach(e=>{e.remove()}),a.forEach(e=>{const t=parseInt(e.formats().rowspan,10);e.format("rowspan",t-c)})}tableDestroy(){const e=i.default.find(this.scroll.domNode.parentNode),t=e.getModule("better-table");this.remove(),t.hideTableTools(),e.update(i.default.sources.USER)}insertCell(e,t){const r=R(),n=e.formats().row,l=this.scroll.create(y.blotName,Object.assign({},b,{row:n})),o=this.scroll.create(g.blotName,{row:n,cell:r});l.appendChild(o),t?e.insertBefore(l,t):e.appendChild(l)}insertColumn(e,t,r=!0,n){var o=this.descendants(x);const i=l(o,1)[0];var a=this.descendants(N);const d=l(a,1)[0],c=this.descendants(v);let u=[],h=[],p=[];if(null==i||null==i.children.head)return;this.descendants(y).forEach(t=>{const l=(0,s.getRelativeRect)(t.domNode.getBoundingClientRect(),n);r?Math.abs(l.x1-e.x1)<m?u.push(t):e.x1-l.x>m&&e.x1-l.x1<-m&&h.push(t):Math.abs(l.x-e.x)<m?u.push(t):e.x-l.x>m&&e.x-l.x1<-m&&h.push(t)}),u.forEach(e=>{const t=r?e.next:e,n=R(),l=e.parent,o=l.formats().row,i=e.formats(),s=this.scroll.create(y.blotName,Object.assign({},b,{row:o,rowspan:i.rowspan})),a=this.scroll.create(g.blotName,{row:o,cell:n,rowspan:i.rowspan});s.appendChild(a),t?l.insertBefore(s,t):l.appendChild(s),p.push(s)});const f=this.scroll.create(v.blotName,!0);let w=r?c[t].next:c[t];return w?d.insertBefore(f,w):d.appendChild(f),h.forEach(e=>{const t=e.formats().colspan;e.format("colspan",parseInt(t,10)+1),p.push(e)}),p.sort((e,t)=>{return e.domNode.getBoundingClientRect().y-t.domNode.getBoundingClientRect().y}),this.updateTableWidth(),p}insertRow(e,t,r){var n=this.descendants(x);const o=l(n,1)[0];if(null==o||null==o.children.head)return;const i=this.descendants(y),d=q(),c=this.scroll.create(w.blotName,{row:d});let u=[],h=[],p=[];i.forEach(n=>{const l=(0,s.getRelativeRect)(n.domNode.getBoundingClientRect(),r);t?Math.abs(l.y1-e.y1)<m?u.push(n):e.y1-l.y>m&&e.y1-l.y1<-m&&h.push(n):Math.abs(l.y-e.y)<m?u.push(n):e.y-l.y>m&&e.y-l.y1<-m&&h.push(n)});const f=(e,t)=>{return e.domNode.getBoundingClientRect().x-t.domNode.getBoundingClientRect().x};u.sort(f),u.forEach(e=>{const t=R(),r=e.formats(),n=this.scroll.create(y.blotName,Object.assign({},b,{row:d,colspan:r.colspan})),l=this.scroll.create(g.blotName,{row:d,cell:t,colspan:r.colspan}),o=this.scroll.create(a.blotName);l.appendChild(o),n.appendChild(l),c.appendChild(n),p.push(n)}),h.forEach(e=>{const t=parseInt(e.formats().rowspan,10);e.format("rowspan",t+1),p.push(e)});const v=this.rows().find(n=>{let l=(0,s.getRelativeRect)(n.domNode.getBoundingClientRect(),r);return t?Math.abs(l.y-e.y-e.height)<m:Math.abs(l.y-e.y)<m});return o.insertBefore(c,v),p.sort(f),p}mergeCells(e,t,r,n,l){const o=t.reduce((e,t,l)=>(0!==l?(e&&t.moveChildren(e),t.remove()):(t.format("colspan",n),t.format("rowspan",r),e=t),e),null);let i=o.domNode.getAttribute("data-row"),s=o.children.head.domNode.getAttribute("data-cell");return o.children.forEach(e=>{e.format("cell",s),e.format("row",i),e.format("colspan",n),e.format("rowspan",r)}),o}unmergeCells(e,t){let r={},n=1,l=1;e.forEach(e=>{if(r=e.formats(),n=r.rowspan,(l=r.colspan)>1){let t=e.next,r=e.row();e.format("colspan",1);for(let e=l;e>1;e--)this.insertCell(r,t)}if(n>1){let r=n,o=e.row().next;for(;r>1;){let n=o.children.reduce((r,n)=>{let l=(0,s.getRelativeRect)(e.domNode.getBoundingClientRect(),t),o=(0,s.getRelativeRect)(n.domNode.getBoundingClientRect(),t);return Math.abs(l.x1-o.x)<m&&(r=n),r},null);for(let e=l;e>0;e--)this.insertCell(o,n);r-=1,o=o.next}e.format("rowspan",1)}})}rows(){const e=this.children.tail;return null==e?[]:e.children.map(e=>e)}}C.blotName="table-container",C.className="quill-better-table",C.tagName="TABLE";class T extends c{constructor(e,t){super(e,t);const r=i.default.find(e.domNode.parentNode);t.addEventListener("scroll",e=>{const t=r.getModule("better-table");t.columnTool&&(t.columnTool.domNode.scrollLeft=e.target.scrollLeft),t.tableSelection&&t.tableSelection.selectedTds.length>0&&t.tableSelection.repositionHelpLines()},!1)}}function q(){return`row-${Math.random().toString(36).slice(2,6)}`}function R(){return`cell-${Math.random().toString(36).slice(2,6)}`}T.blotName="table-view",T.className="quill-better-table-wrapper",T.tagName="DIV",T.allowedChildren=[C],C.requiredContainer=T,C.allowedChildren=[x,N],x.requiredContainer=C,x.allowedChildren=[w],w.requiredContainer=x,w.allowedChildren=[y],y.requiredContainer=w,y.allowedChildren=[g],g.requiredContainer=y,N.allowedChildren=[v],N.requiredContainer=C,v.requiredContainer=N,t.TableCol=v,t.TableColGroup=N,t.TableCellLine=g,t.TableCell=y,t.TableRow=w,t.TableBody=x,t.TableContainer=C,t.TableViewWrapper=T,t.rowId=q,t.cellId=R,t.CELL_ATTRIBUTES=f},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=function(){return function(e,t){if(Array.isArray(e))return e;if(Symbol.iterator in Object(e))return function(e,t){var r=[],n=!0,l=!1,o=void 0;try{for(var i,s=e[Symbol.iterator]();!(n=(i=s.next()).done)&&(r.push(i.value),!t||r.length!==t);n=!0);}catch(e){l=!0,o=e}finally{try{!n&&s.return&&s.return()}finally{if(l)throw o}}return r}(e,t);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}(),l=c(r(0)),o=c(r(4)),i=c(r(5)),s=c(r(6)),a=r(7),d=r(2);function c(e){return e&&e.__esModule?e:{default:e}}const u=l.default.import("core/module"),h=l.default.import("delta");class p extends u{static register(){l.default.register(d.TableCol,!0),l.default.register(d.TableColGroup,!0),l.default.register(d.TableCellLine,!0),l.default.register(d.TableCell,!0),l.default.register(d.TableRow,!0),l.default.register(d.TableBody,!0),l.default.register(d.TableContainer,!0),l.default.register(d.TableViewWrapper,!0)}constructor(e,t){super(e,t),this.quill.root.addEventListener("click",r=>{if(!r.path||r.path.length<=0)return;const n=r.path.filter(e=>e.tagName&&"TABLE"===e.tagName.toUpperCase()&&e.classList.contains("quill-better-table"))[0];if(n){if(this.table===n)return;this.table&&this.hideTableTools(),this.showTableTools(n,e,t)}else this.table&&this.hideTableTools()},!1),this.quill.root.addEventListener("contextmenu",r=>{if(!this.table)return!0;if(r.preventDefault(),!r.path||r.path.length<=0)return;const n=r.path.filter(e=>e.tagName&&"TABLE"===e.tagName.toUpperCase()&&e.classList.contains("quill-better-table"))[0],l=r.path.filter(e=>e.tagName&&"TR"===e.tagName.toUpperCase()&&e.getAttribute("data-row"))[0],o=r.path.filter(e=>e.tagName&&"TD"===e.tagName.toUpperCase()&&e.getAttribute("data-row"))[0];let i=this.tableSelection.selectedTds.map(e=>e.domNode).includes(o);(this.tableSelection.selectedTds.length<=0||!i)&&this.tableSelection.setSelection(o.getBoundingClientRect(),o.getBoundingClientRect()),this.tableOperationMenu&&(this.tableOperationMenu=this.tableOperationMenu.destroy()),n&&(this.tableOperationMenu=new s.default({table:n,row:l,cell:o,left:r.pageX,top:r.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;var r=this.quill.getLine(e.index);const l=n(r,1)[0];if(0===t.offset){var o=this.quill.getLine(e.index-1);const t=n(o,1)[0];if(null!=t&&"table-cell-line"===t.statics.blotName&&"table-cell-line"!==l.statics.blotName)return!1}return!0});let r=e.keyboard.bindings.Backspace.pop();e.keyboard.bindings.Backspace.splice(0,1,r),e.clipboard.addMatcher("td",a.matchTableCell),e.clipboard.addMatcher("th",a.matchTableHeader),e.clipboard.addMatcher("table",a.matchTable),e.clipboard.matchers=e.clipboard.matchers.filter(e=>"tr"!==e[0])}getTable(e=this.quill.getSelection()){if(null==e)return[null,null,null,-1];var t=this.quill.getLine(e.index),r=n(t,2);const l=r[0],o=r[1];if(null==l||l.statics.blotName!==d.TableCellLine.blotName)return[null,null,null,-1];const i=l.tableCell(),s=i.row();return[s.table(),s,i,o]}insertTable(e,t){const r=this.quill.getSelection(!0);if(null==r)return;this.quill.getLeaf(r.index)[0],this.quill.getLeaf(r.index+1)[0];let n=(new h).retain(r.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 r=(0,d.rowId)();return new Array(t).fill("\n").reduce((e,t)=>(e.insert(t,{"table-cell-line":{row:r,cell:(0,d.cellId)()}}),e),e)},n),this.quill.updateContents(n,l.default.sources.USER),this.quill.setSelection(r.index+t+1,l.default.sources.API)}showTableTools(e,t,r){this.table=e,this.columnTool=new o.default(e,t,r),this.tableSelection=new i.default(e,t,r)}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}}p.keyboardBindings={"table-cell-line backspace":{key:"Backspace",format:["table-cell-line"],collapsed:!0,offset:0,handler(e,t){var r=this.quill.getLine(e.index),l=n(r,2);const o=l[0];l[1];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 r=l.default.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,r.BLOCK)&&!Array.isArray(t.format[n])&&(e[n]=t.format[n]),e),{});this.quill.insertText(e.index,"\n",n["table-cell-line"],l.default.sources.USER),this.quill.setSelection(e.index+1,l.default.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],l.default.sources.USER))})}}},t.default=p},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n,l=r(0),o=(n=l)&&n.__esModule?n:{default:n},i=r(1);const s=12,a=12,d=50,c="#35A7ED";t.default=class{constructor(e,t,r){if(!e)return null;this.table=e,this.quill=t,this.options=r,this.domNode=null,this.initColTool()}initColTool(){const e=this.quill.root.parentNode,t=(this.table.getBoundingClientRect(),e.getBoundingClientRect()),r=this.table.parentNode.getBoundingClientRect();this.domNode=document.createElement("div"),this.domNode.classList.add("qlbt-col-tool"),this.updateToolCells(),e.appendChild(this.domNode),(0,i.css)(this.domNode,{width:`${r.width}px`,height:`${s}px`,left:`${r.left-t.left+e.scrollLeft}px`,top:`${r.top-t.top+e.scrollTop-s-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"),(0,i.css)(e,{height:`${a}px`}),e.appendChild(t),e}updateToolCells(){const e=o.default.find(this.table),t=e.children.tail.children.head.children,r=e.colGroup().children,n=function(e){return e.reduce((e,t)=>{const r=t.formats().colspan;return e+=parseInt(r,10)},0)}(t);let l=Array.from(this.domNode.querySelectorAll(".qlbt-col-tool-cell"));for(let e=0;e<Math.max(n,l.length);e++){let t=r.at(e),o=t&&parseInt(t.formats()[t.statics.blotName].width,10),s=null;l[e]?l[e]&&e>=n?l[e].remove():(s=l[e],(0,i.css)(s,{"min-width":`${o}px`})):(s=this.createToolCell(),this.domNode.appendChild(s),this.addColCellHolderHandler(s),(0,i.css)(s,{"min-width":`${o}px`}))}}destroy(){return this.domNode.remove(),null}addColCellHolderHandler(e){const t=o.default.find(this.table),r=e.querySelector(".qlbt-col-tool-cell-holder");let n=!1,l=0,a=0,u=0,h=0,p={},f={},b=null;const m=e=>{e.preventDefault(),n&&(a=e.clientX,u=h+a-l>=d?a-l:d-h,(0,i.css)(b,{left:`${f.left+f.width-1+u}px`}))},g=o=>{o.preventDefault();const s=Array.from(this.domNode.querySelectorAll(".qlbt-col-tool-cell")).indexOf(e),d=t.colGroup().children.at(s);n&&(d.format("width",h+u),(0,i.css)(e,{"min-width":`${h+u}px`}),l=0,a=0,u=0,h=0,n=!1,r.classList.remove("dragging")),document.removeEventListener("mousemove",m,!1),document.removeEventListener("mouseup",g,!1),p={},f={},b.remove(),b=null,t.updateTableWidth();const c=this.quill.getModule("better-table").tableSelection;c&&c.clearSelection()};r.addEventListener("mousedown",t=>{document.addEventListener("mousemove",m,!1),document.addEventListener("mouseup",g,!1),p=this.table.getBoundingClientRect(),f=e.getBoundingClientRect(),b=document.createElement("div"),(0,i.css)(b,{position:"fixed",top:`${f.top}px`,left:`${f.left+f.width-1}px`,zIndex:"100",height:`${p.height+s+4}px`,width:"1px",backgroundColor:c}),document.body.appendChild(b),n=!0,l=t.clientX,h=f.width,r.classList.add("dragging")},!1)}colToolCells(){return Array.from(this.domNode.querySelectorAll(".qlbt-col-tool-cell"))}}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n,l=r(0),o=(n=l)&&n.__esModule?n:{default:n},i=r(1),s=r(2);const a="#35A7ED",d=["left","right","top","bottom"],c=2;function u(e,t){let r=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),l=Math.min(e.y,t.y,e.y+e.height-1,t.y+t.height-1),o=Math.max(e.y,t.y,e.y+e.height-1,t.y+t.height-1);return{x:r,x1:n,y:l,y1:o,width:n-r,height:o-l}}t.default=class{constructor(e,t,r){if(!e)return null;this.table=e,this.quill=t,this.options=r,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"),(0,i.css)(this[t],{position:"absolute",display:"none","background-color":a}),e.appendChild(this[t])})}mouseDownHandler(e){if(0!==e.button||!e.target.closest(".quill-better-table"))return;this.quill.root.addEventListener("mousemove",l,!1),this.quill.root.addEventListener("mouseup",function e(r){t.quill.root.removeEventListener("mousemove",l,!1),t.quill.root.removeEventListener("mouseup",e,!1),t.dragging=!1},!1);const t=this,r=e.target.closest("td[data-row]"),n=(0,i.getRelativeRect)(r.getBoundingClientRect(),this.quill.root.parentNode);function l(e){if(0!==e.button||!e.target.closest(".quill-better-table"))return;const l=e.target.closest("td[data-row]"),o=(0,i.getRelativeRect)(l.getBoundingClientRect(),t.quill.root.parentNode);t.boundary=u(n,o),t.correctBoundary(),t.selectedTds=t.computeSelectedTds(),t.repositionHelpLines(),r!==l&&t.quill.blur()}this.dragging=!0,this.boundary=u(n,n),this.correctBoundary(),this.selectedTds=this.computeSelectedTds(),this.repositionHelpLines()}correctBoundary(){o.default.find(this.table).descendants(s.TableCell).forEach(e=>{var t=(0,i.getRelativeRect)(e.domNode.getBoundingClientRect(),this.quill.root.parentNode);let r=t.x,n=t.y,l=t.width,o=t.height;(r+c>=this.boundary.x&&r+c<=this.boundary.x1||r-c+l>=this.boundary.x&&r-c+l<=this.boundary.x1)&&(n+c>=this.boundary.y&&n+c<=this.boundary.y1||n-c+o>=this.boundary.y&&n-c+o<=this.boundary.y1)&&(this.boundary=u(this.boundary,{x:r,y:n,width:l,height:o}))})}computeSelectedTds(){return o.default.find(this.table).descendants(s.TableCell).reduce((e,t)=>{var r=(0,i.getRelativeRect)(t.domNode.getBoundingClientRect(),this.quill.root.parentNode);let n=r.x,l=r.y,o=r.width,s=r.height;return n+c>=this.boundary.x&&n-c+o<=this.boundary.x1&&l+c>=this.boundary.y&&l-c+s<=this.boundary.y1&&e.push(t),e},[])}repositionHelpLines(){const e=this.table.parentNode.scrollLeft;(0,i.css)(this.left,{display:"block",left:`${this.boundary.x-e-1}px`,top:`${this.boundary.y}px`,height:`${this.boundary.height+1}px`,width:"1px"}),(0,i.css)(this.right,{display:"block",left:`${this.boundary.x1-e}px`,top:`${this.boundary.y}px`,height:`${this.boundary.height+1}px`,width:"1px"}),(0,i.css)(this.top,{display:"block",left:`${this.boundary.x-1-e}px`,top:`${this.boundary.y}px`,width:`${this.boundary.width+1}px`,height:"1px"}),(0,i.css)(this.bottom,{display:"block",left:`${this.boundary.x-1-e}px`,top:`${this.boundary.y1+1}px`,width:`${this.boundary.width+1}px`,height:"1px"})}refreshHelpLinesPosition(){const e=(0,i.getRelativeRect)(this.selectedTds[0].domNode.getBoundingClientRect(),this.quill.root.parentNode),t=(0,i.getRelativeRect)(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((0,i.getRelativeRect)(e,this.quill.root.parentNode),(0,i.getRelativeRect)(t,this.quill.root.parentNode)),this.correctBoundary(),this.selectedTds=this.computeSelectedTds(),this.repositionHelpLines()}clearSelection(){this.boundary={},this.selectedTds=[],d.forEach(e=>{this[e]&&(0,i.css)(this[e],{display:"none"})})}}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n,l=r(0),o=(n=l)&&n.__esModule?n:{default:n},i=r(1);const s=150,a=200,d={insertColumnRight:{text:"Insert column right",handler(){const e=o.default.find(this.table);let t=c(this.columnToolCells,this.boundary,(e,t)=>Math.abs(e.x+e.width-t.x1)<=5,this.quill.root.parentNode);const r=e.insertColumn(this.boundary,t,!0,this.quill.root.parentNode);this.tableColumnTool.updateToolCells(),this.quill.update(o.default.sources.USER),this.quill.setSelection(this.quill.getIndex(r[0]),0,o.default.sources.SILENT),this.tableSelection.setSelection(r[0].domNode.getBoundingClientRect(),r[0].domNode.getBoundingClientRect())}},insertColumnLeft:{text:"Insert column left",handler(){const e=o.default.find(this.table);let t=c(this.columnToolCells,this.boundary,(e,t)=>Math.abs(e.x-t.x)<=5,this.quill.root.parentNode);const r=e.insertColumn(this.boundary,t,!1,this.quill.root.parentNode);this.tableColumnTool.updateToolCells(),this.quill.update(o.default.sources.USER),this.quill.setSelection(this.quill.getIndex(r[0]),0,o.default.sources.SILENT),this.tableSelection.setSelection(r[0].domNode.getBoundingClientRect(),r[0].domNode.getBoundingClientRect())}},insertRowUp:{text:"Insert row up",handler(){const e=o.default.find(this.table).insertRow(this.boundary,!1,this.quill.root.parentNode);this.quill.update(o.default.sources.USER),this.quill.setSelection(this.quill.getIndex(e[0]),0,o.default.sources.SILENT),this.tableSelection.setSelection(e[0].domNode.getBoundingClientRect(),e[0].domNode.getBoundingClientRect())}},insertRowDown:{text:"Insert row down",handler(){const e=o.default.find(this.table).insertRow(this.boundary,!0,this.quill.root.parentNode);this.quill.update(o.default.sources.USER),this.quill.setSelection(this.quill.getIndex(e[0]),0,o.default.sources.SILENT),this.tableSelection.setSelection(e[0].domNode.getBoundingClientRect(),e[0].domNode.getBoundingClientRect())}},mergeCells:{text:"Merge selected cells",handler(){const e=o.default.find(this.table),t=e.rows().reduce((e,t)=>{let r=(0,i.getRelativeRect)(t.domNode.getBoundingClientRect(),this.quill.root.parentNode);return r.y>this.boundary.y-5&&r.y+r.height<this.boundary.y+this.boundary.height+5&&(e+=1),e},0),r=this.columnToolCells.reduce((e,t)=>{let r=(0,i.getRelativeRect)(t.getBoundingClientRect(),this.quill.root.parentNode);return r.x>this.boundary.x-5&&r.x+r.width<this.boundary.x+this.boundary.width+5&&(e+=1),e},0),n=e.mergeCells(this.boundary,this.selectedTds,t,r,this.quill.root.parentNode);this.quill.update(o.default.sources.USER),this.tableSelection.setSelection(n.domNode.getBoundingClientRect(),n.domNode.getBoundingClientRect())}},unmergeCells:{text:"Unmerge cells",handler(){o.default.find(this.table).unmergeCells(this.selectedTds,this.quill.root.parentNode),this.quill.update(o.default.sources.USER),this.tableSelection.clearSelection()}},deleteColumn:{text:"Delete selected columns",handler(){const e=o.default.find(this.table);let t=(r=this.columnToolCells,n=this.boundary,l=((e,t)=>e.x+5>t.x&&e.x+e.width-5<t.x1),s=this.quill.root.parentNode,r.reduce((e,t)=>{let o=(0,i.getRelativeRect)(t.getBoundingClientRect(),s);return l(o,n)&&e.push(r.indexOf(t)),e},[]));var r,n,l,s;e.deleteColumns(this.boundary,t,this.quill.root.parentNode)||(this.tableColumnTool.updateToolCells(),this.quill.update(o.default.sources.USER),this.tableSelection.clearSelection())}},deleteRow:{text:"Delete selected rows",handler(){o.default.find(this.table).deleteRow(this.boundary,this.quill.root.parentNode),this.quill.update(o.default.sources.USER),this.tableSelection.clearSelection()}},deleteTable:{text:"Delete table",handler(){const e=this.quill.getModule("better-table"),t=o.default.find(this.table);e.hideTableTools(),t.remove(),this.quill.update(o.default.sources.USER)}}};function c(e,t,r,n){return e.reduce((l,o)=>{let s=(0,i.getRelativeRect)(o.getBoundingClientRect(),n);return r(s,t)&&(l=e.indexOf(o)),l},!1)}t.default=class{constructor(e,t,r){const n=t.getModule("better-table");this.tableSelection=n.tableSelection,this.table=e.table,this.quill=t,this.options=r,this.menuItems=Object.assign({},d,r.items),this.tableColumnTool=n.columnTool,this.boundary=this.tableSelection.boundary,this.selectedTds=this.tableSelection.selectedTds,this.destroyHanlder=this.destroy.bind(this),this.columnToolCells=this.tableColumnTool.colToolCells(),this.menuInitial(e),this.mount(),document.addEventListener("click",this.destroyHanlder,!1)}mount(){document.body.appendChild(this.domNode)}destroy(){return this.domNode.remove(),document.removeEventListener("click",this.destroyHanlder,!1),null}menuInitial({table:e,left:t,top:r}){this.domNode=document.createElement("div"),this.domNode.classList.add("qlbt-operation-menu"),(0,i.css)(this.domNode,{position:"absolute",left:`${t}px`,top:`${r}px`,"min-height":`${s}px`,width:`${a}px`});for(let e in this.menuItems)this.menuItems[e]&&this.domNode.appendChild(this.menuItemCreator(Object.assign({},d[e],this.menuItems[e])))}menuItemCreator({text:e,handler:t}){const r=document.createElement("div");return r.classList.add("qlbt-operation-menu-item"),r.innerText=e,r.addEventListener("click",t.bind(this),!1),r}}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.matchTableCell=function(e,t,r){const n=e.parentNode,l="TABLE"===n.parentNode.tagName?n.parentNode:n.parentNode.parentNode,o=Array.from(l.querySelectorAll("tr")),a=Array.from(n.querySelectorAll("td")),d=o.indexOf(n)+1,c=a.indexOf(e)+1,u=e.getAttribute("colspan")||!1,h=e.getAttribute("rowspan")||!1;if(0===t.length())return t=(new s).insert("\n",{"table-cell-line":{row:d,cell:c,rowspan:h,colspan:u}});return(t=t.reduce((e,t)=>{if(t.insert&&"string"==typeof t.insert){const r=[];let n=t.insert,l=0;for(let e=0;e<t.insert.length;e++)"\n"===n.charAt(e)&&(0===e?r.push("\n"):(r.push(n.substring(l,e)),r.push("\n")),l=e+1);const o=n.substring(l);o&&r.push(o),r.forEach(r=>{"\n"===r?e.insert("\n",t.attributes):e.insert(r,(0,i._omit)(t.attributes,["table","table-cell-line"]))})}else e.insert(t.insert,t.attributes);return e},new s)).reduce((e,t)=>(t.insert&&"string"==typeof t.insert&&t.insert.startsWith("\n")?e.insert(t.insert,Object.assign({},Object.assign({},{row:d},t.attributes.table),{"table-cell-line":{row:d,cell:c,rowspan:h,colspan:u}},(0,i._omit)(t.attributes,["table"]))):e.insert(t.insert,Object.assign({},(0,i._omit)(t.attributes,["table","table-cell-line"]))),e),new s)},t.matchTableHeader=function(e,t,r){const n=e.parentNode,l="TABLE"===n.parentNode.tagName?n.parentNode:n.parentNode.parentNode,o=Array.from(l.querySelectorAll("tr")),a=Array.from(n.querySelectorAll("th")),d=o.indexOf(n)+1,c=a.indexOf(e)+1,u=e.getAttribute("colspan")||!1,h=e.getAttribute("rowspan")||!1;if(0===t.length())return t=(new s).insert("\n",{"table-cell-line":{row:d,cell:c,rowspan:h,colspan:u}});return(t=t.reduce((e,t)=>{if(t.insert&&"string"==typeof t.insert){const r=[];let n=t.insert,l=0;for(let e=0;e<t.insert.length;e++)"\n"===n.charAt(e)&&(0===e?r.push("\n"):(r.push(n.substring(l,e)),r.push("\n")),l=e+1);const o=n.substring(l);o&&r.push(o),r.indexOf("\n")<0&&r.push("\n"),r.forEach(r=>{"\n"===r?e.insert("\n",{"table-cell-line":{row:d,cell:c,rowspan:h,colspan:u}}):e.insert(r,t.attributes)})}else e.insert(t.insert,t.attributes);return e},new s)).reduce((e,t)=>(t.insert&&"string"==typeof t.insert&&t.insert.startsWith("\n")?e.insert(t.insert,Object.assign({},{"table-cell-line":{row:d,cell:c,rowspan:h,colspan:u}})):e.insert(t.insert,Object.assign({},(0,i._omit)(t.attributes,["table","table-cell-line"]))),e),new s)},t.matchTable=function(e,t,r){let n=new s;const l=e.querySelector("tr");if(null===l)return new n;const o=Array.from(l.querySelectorAll("td")).concat(Array.from(l.querySelectorAll("th"))).reduce((e,t)=>{const r=t.getAttribute("colspan")||1;return e+=parseInt(r,10)},0),i=e.querySelectorAll("col").length;if(i===o)return t;{for(let e=0;e<o-i;e++)n.insert("\n",{"table-col":!0});if(0===i)return n.concat(t);let e=0;return t.reduce((t,r)=>(t.insert(r.insert,r.attributes),r.attributes&&r.attributes["table-col"]&&(e+=r.insert.length)===i&&(t=t.concat(n)),t),new s)}};var n,l=r(0),o=(n=l)&&n.__esModule?n:{default:n},i=r(1);const s=o.default.import("delta")},,function(e,t,r){e.exports=r(3)}]).default});
{
"name": "quill-better-table",
"version": "1.1.5",
"version": "1.1.6",
"description": "Module for better table in Quill, more useful features are supported.",

@@ -5,0 +5,0 @@ "main": "dist/quill-better-table.js",

@@ -66,3 +66,3 @@ # quill-better-table

<link href="https://cdnjs.cloudflare.com/ajax/libs/quill/2.0.0-dev.3/quill.snow.min.css" rel="stylesheet">
<link href="unpkg.com/quill-better-table@1.1.2/dist/quill-better-table.css" rel="stylesheet">
<link href="unpkg.com/quill-better-table@1.1.5/dist/quill-better-table.css" rel="stylesheet">
```

@@ -69,0 +69,0 @@

@@ -158,4 +158,7 @@ import Quill from 'quill'

let newColDelta = new Delta()
const topRow = node.querySelector('tr')
const topRow = node.querySelector('tr')
// bugfix: empty table will return empty delta
if (topRow === null) return new newColDelta
const cellsInTopRow = Array.from(topRow.querySelectorAll('td'))

@@ -162,0 +165,0 @@ .concat(Array.from(topRow.querySelectorAll('th')))

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc