quill-better-table
Advanced tools
Comparing version 1.0.1 to 1.0.2
@@ -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,n){!function(e,t){if(!C[e]||!x[e])return;for(var n in x[e]=!1,t)Object.prototype.hasOwnProperty.call(t,n)&&(b[n]=t[n]);0==--g&&0===y&&q()}(e,n),t&&t(e,n)};var n,o=!0,r="e9d462dbaefc0ccb6596",l=1e4,i={},s=[],a=[];function d(e){var t=S[e];if(!t)return R;var o=function(o){return t.hot.active?(S[o]?-1===S[o].parents.indexOf(e)&&S[o].parents.push(e):(s=[e],n=o),-1===t.children.indexOf(o)&&t.children.push(o)):(console.warn("[HMR] unexpected require("+o+") from disposed module "+e),s=[]),R(o)},r=function(e){return{configurable:!0,enumerable:!0,get:function(){return R[e]},set:function(t){R[e]=t}}};for(var l in R)Object.prototype.hasOwnProperty.call(R,l)&&"e"!==l&&"t"!==l&&Object.defineProperty(o,l,r(l));return o.e=function(e){return"ready"===h&&p("prepare"),y++,R.e(e).then(t,function(e){throw t(),e});function t(){y--,"prepare"===h&&(w[e]||N(e),0===y&&0===g&&q())}},o.t=function(e,t){return 1&t&&(e=o(e)),R.t(e,-2&t)},o}function c(e){var t={_acceptedDependencies:{},_declinedDependencies:{},_selfAccepted:!1,_selfDeclined:!1,_disposeHandlers:[],_main:n!==e,active:!0,accept:function(e,n){if(void 0===e)t._selfAccepted=!0;else if("function"==typeof e)t._selfAccepted=e;else if("object"==typeof e)for(var o=0;o<e.length;o++)t._acceptedDependencies[e[o]]=n||function(){};else t._acceptedDependencies[e]=n||function(){}},decline:function(e){if(void 0===e)t._selfDeclined=!0;else if("object"==typeof e)for(var n=0;n<e.length;n++)t._declinedDependencies[e[n]]=!0;else t._declinedDependencies[e]=!0},dispose:function(e){t._disposeHandlers.push(e)},addDisposeHandler:function(e){t._disposeHandlers.push(e)},removeDisposeHandler:function(e){var n=t._disposeHandlers.indexOf(e);n>=0&&t._disposeHandlers.splice(n,1)},check:T,apply:E,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 n=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={},C={};function v(e){return+e+""===e?+e:e}function T(e){if("idle"!==h)throw new Error("check() is only allowed in idle status");return o=e,p("check"),(t=l,t=t||1e4,new Promise(function(e,n){if("undefined"==typeof XMLHttpRequest)return n(new Error("No browser support"));try{var o=new XMLHttpRequest,l=R.p+""+r+".hot-update.json";o.open("GET",l,!0),o.timeout=t,o.send(null)}catch(e){return n(e)}o.onreadystatechange=function(){if(4===o.readyState)if(0===o.status)n(new Error("Manifest request to "+l+" timed out."));else if(404===o.status)e();else if(200!==o.status&&304!==o.status)n(new Error("Manifest request to "+l+" failed."));else{try{var t=JSON.parse(o.responseText)}catch(e){return void n(e)}e(t)}}})).then(function(e){if(!e)return p("idle"),null;x={},w={},C=e.c,m=e.h,p("prepare");var t=new Promise(function(e,t){f={resolve:e,reject:t}});b={};return N(0),"prepare"===h&&0===y&&0===g&&q(),t});var t}function N(e){C[e]?(x[e]=!0,g++,function(e){var t=document.createElement("script");t.charset="utf-8",t.src=R.p+""+e+"."+r+".hot-update.js",document.head.appendChild(t)}(e)):w[e]=!0}function q(){p("ready");var e=f;if(f=null,e)if(o)Promise.resolve().then(function(){return E(o)}).then(function(t){e.resolve(t)},function(t){e.reject(t)});else{var t=[];for(var n in b)Object.prototype.hasOwnProperty.call(b,n)&&t.push(v(n));e.resolve(t)}}function E(t){if("ready"!==h)throw new Error("apply() is only allowed in ready status");var n,o,l,a,d;function c(e){for(var t=[e],n={},o=t.slice().map(function(e){return{chain:[e],id:e}});o.length>0;){var r=o.pop(),l=r.id,i=r.chain;if((a=S[l])&&!a.hot._selfAccepted){if(a.hot._selfDeclined)return{type:"self-declined",chain:i,moduleId:l};if(a.hot._main)return{type:"unaccepted",chain:i,moduleId:l};for(var s=0;s<a.parents.length;s++){var d=a.parents[s],c=S[d];if(c){if(c.hot._declinedDependencies[l])return{type:"declined",chain:i.concat([d]),moduleId:l,parentId:d};-1===t.indexOf(d)&&(c.hot._acceptedDependencies[l]?(n[d]||(n[d]=[]),u(n[d],[l])):(delete n[d],t.push(d),o.push({chain:i.concat([d]),id:d})))}}}}return{type:"accepted",moduleId:e,outdatedModules:t,outdatedDependencies:n}}function u(e,t){for(var n=0;n<t.length;n++){var o=t[n];-1===e.indexOf(o)&&e.push(o)}}t=t||{};var f={},g=[],y={},w=function(){console.warn("[HMR] unexpected require("+T.moduleId+") to disposed module")};for(var x in b)if(Object.prototype.hasOwnProperty.call(b,x)){var T;d=v(x);var N=!1,q=!1,E=!1,O="";switch((T=b[x]?c(d):{type:"disposed",moduleId:x}).chain&&(O="\nUpdate propagation: "+T.chain.join(" -> ")),T.type){case"self-declined":t.onDeclined&&t.onDeclined(T),t.ignoreDeclined||(N=new Error("Aborted because of self decline: "+T.moduleId+O));break;case"declined":t.onDeclined&&t.onDeclined(T),t.ignoreDeclined||(N=new Error("Aborted because of declined dependency: "+T.moduleId+" in "+T.parentId+O));break;case"unaccepted":t.onUnaccepted&&t.onUnaccepted(T),t.ignoreUnaccepted||(N=new Error("Aborted because "+d+" is not accepted"+O));break;case"accepted":t.onAccepted&&t.onAccepted(T),q=!0;break;case"disposed":t.onDisposed&&t.onDisposed(T),E=!0;break;default:throw new Error("Unexception type "+T.type)}if(N)return p("abort"),Promise.reject(N);if(q)for(d in y[d]=b[d],u(g,T.outdatedModules),T.outdatedDependencies)Object.prototype.hasOwnProperty.call(T.outdatedDependencies,d)&&(f[d]||(f[d]=[]),u(f[d],T.outdatedDependencies[d]));E&&(u(g,[T.moduleId]),y[d]=w)}var A,B=[];for(o=0;o<g.length;o++)d=g[o],S[d]&&S[d].hot._selfAccepted&&B.push({module:d,errorHandler:S[d].hot._selfAccepted});p("dispose"),Object.keys(C).forEach(function(e){!1===C[e]&&function(e){delete installedChunks[e]}(e)});for(var L,M,I=g.slice();I.length>0;)if(d=I.pop(),a=S[d]){var _={},k=a.hot._disposeHandlers;for(l=0;l<k.length;l++)(n=k[l])(_);for(i[d]=_,a.hot.active=!1,delete S[d],delete f[d],l=0;l<a.children.length;l++){var D=S[a.children[l]];D&&((A=D.parents.indexOf(d))>=0&&D.parents.splice(A,1))}}for(d in f)if(Object.prototype.hasOwnProperty.call(f,d)&&(a=S[d]))for(M=f[d],l=0;l<M.length;l++)L=M[l],(A=a.children.indexOf(L))>=0&&a.children.splice(A,1);for(d in p("apply"),r=m,y)Object.prototype.hasOwnProperty.call(y,d)&&(e[d]=y[d]);var $=null;for(d in f)if(Object.prototype.hasOwnProperty.call(f,d)&&(a=S[d])){M=f[d];var j=[];for(o=0;o<M.length;o++)if(L=M[o],n=a.hot._acceptedDependencies[L]){if(-1!==j.indexOf(n))continue;j.push(n)}for(o=0;o<j.length;o++){n=j[o];try{n(M)}catch(e){t.onErrored&&t.onErrored({type:"accept-errored",moduleId:d,dependencyId:M[o],error:e}),t.ignoreErrored||$||($=e)}}}for(o=0;o<B.length;o++){var H=B[o];d=H.module,s=[d];try{R(d)}catch(e){if("function"==typeof H.errorHandler)try{H.errorHandler(e)}catch(n){t.onErrored&&t.onErrored({type:"self-accept-error-handler-errored",moduleId:d,error:n,originalError:e}),t.ignoreErrored||$||($=n),$||($=e)}else t.onErrored&&t.onErrored({type:"self-accept-errored",moduleId:d,error:e}),t.ignoreErrored||$||($=e)}}return $?(p("fail"),Promise.reject($)):(p("idle"),new Promise(function(e){e(g)}))}var S={};function R(t){if(S[t])return S[t].exports;var n=S[t]={i:t,l:!1,exports:{},hot:c(t),parents:(a=s,s=[],a),children:[]};return e[t].call(n.exports,n,n.exports,d(t)),n.l=!0,n.exports}return R.m=e,R.c=S,R.d=function(e,t,n){R.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},R.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},R.t=function(e,t){if(1&t&&(e=R(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(R.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)R.d(n,o,function(t){return e[t]}.bind(null,o));return n},R.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return R.d(t,"a",t),t},R.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},R.p="",R.h=function(){return r},d(10)(R.s=10)}([function(t,n){t.exports=e},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.css=function(e,t){if("object"==typeof t)for(let n in t)e.style[n]=t[n]}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.cellId=t.rowId=t.TableViewWrapper=t.TableContainer=t.TableBody=t.TableRow=t.TableCell=t.TableCellLine=t.TableColGroup=t.TableCol=void 0;var o,r=function(){return function(e,t){if(Array.isArray(e))return e;if(Symbol.iterator in Object(e))return function(e,t){var n=[],o=!0,r=!1,l=void 0;try{for(var i,s=e[Symbol.iterator]();!(o=(i=s.next()).done)&&(n.push(i.value),!t||n.length!==t);o=!0);}catch(e){r=!0,l=e}finally{try{!o&&s.return&&s.return()}finally{if(r)throw l}}return n}(e,t);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}(),l=n(0),i=(o=l)&&o.__esModule?o:{default:o};const s=i.default.import("blots/break"),a=i.default.import("blots/block"),d=i.default.import("blots/container"),c=["width"],u={width:100},h=["row","cell"],p=["rowspan","colspan"],f={rowspan:1,colspan:1},b=5;class m extends a{static create(e){const t=super.create(e);return h.forEach(n=>{let o=`${n}Id`;t.setAttribute(`data-${n}`,e[n]||o())}),p.forEach(n=>{t.setAttribute(`data-${n}`,e[n]||f[n])}),t}static formats(e){return p.concat(h).reduce((t,n)=>(e.hasAttribute(`data-${n}`)&&(t[n]=e.getAttribute(`data-${n}`)||void 0),t),{})}format(e,t){p.concat(h).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"),n=this.domNode.getAttribute("data-rowspan"),o=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:o,rowspan:n}),super.optimize(e)}tableCell(){return this.parent}}m.blotName="table-cell-line",m.ClassName="qlbt-cell-line",m.tagName="DIV";class g extends d{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"],n=this.next.children.head.formats()["table-cell-line"],o=this.next.children.tail.formats()["table-cell-line"];return e.cell===t.cell&&e.cell===n.cell&&e.cell===o.cell}return!1}static create(e){const t=super.create(e);return t.setAttribute("data-row",e.row),p.forEach(n=>{e[n]&&t.setAttribute(n,e[n])}),t}static formats(e){const t={};return e.hasAttribute("data-row")&&(t.row=e.getAttribute("data-row")),p.reduce((t,n)=>(e.hasAttribute(n)&&(t[n]=e.getAttribute(n)),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")),p.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(n=>{n.format(e,t)})}format(e,t){p.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()}}g.blotName="table",g.tagName="TD";class y extends d{checkMerge(){if(super.checkMerge()&&null!=this.next.children.head){const e=this.children.head.formats(),t=this.children.tail.formats(),n=this.next.children.head.formats(),o=this.next.children.tail.formats();return e.row===t.row&&e.row===n.row&&e.row===o.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),{})}rowOffset(){return this.parent?this.parent.children.indexOf(this):-1}table(){return this.parent&&this.parent.parent}}y.blotName="table-row",y.tagName="TR";class w extends d{}w.blotName="table-body",w.tagName="TBODY";class x extends a{static create(e){let t=super.create(e);return c.forEach(n=>{t.setAttribute(`${n}`,e[n]||u[n])}),t}static formats(e){return c.reduce((t,n)=>(e.hasAttribute(`${n}`)&&(t[n]=e.getAttribute(`${n}`)||void 0),t),{})}format(e,t){c.indexOf(e)>-1?this.domNode.setAttribute(`${e}`,t||u[e]):super.format(e,t)}html(){return this.domNode.outerHTML}}x.blotName="table-col",x.tagName="col";class C extends d{}C.blotName="table-col-group",C.tagName="colgroup";class v extends d{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()[x.blotName].width,10),0);this.domNode.style.width=`${t}px`},0)}getSelectedTds(){return this.selectedTds}cells(e){return this.rows().map(t=>t.children.at(e))}colGroup(){return this.children.head}deleteColumns(e,t=[]){var n=this.descendants(w);const o=r(n,1)[0];if(null==o||null==o.children.head)return;const l=this.descendants(g),i=[],s=[];if(l.forEach(t=>{const n=t.domNode.getBoundingClientRect(),o=e.x,r=e.x+e.width,l=n.x,a=n.x+n.width;l+b>o&&a-b<r?i.push(t):l<o+b&&a>r-b&&s.push(t)}),i.length===l.length)return this.tableDestroy(),!0;t.forEach(e=>{this.colGroup().children.at(t[0]).remove()}),i.forEach(e=>{e.remove()}),s.forEach(e=>{const n=parseInt(e.formats().colspan,10);parseInt(e.formats().width,10);e.format("colspan",n-t.length)}),this.updateTableWidth()}deleteRow(e){var t=this.descendants(w);const n=r(t,1)[0];if(null==n||null==n.children.head)return;const o=this.descendants(g),l=[],i=[],s=[];if(o.forEach(t=>{const n=t.domNode.getBoundingClientRect(),o=e.y,r=e.y+e.height,a=n.y,d=n.y+n.height;a>o-b&&d<r+b?l.push(t):a<o+b&&d>r-b&&(i.push(t),Math.abs(a-o)<b&&s.push(t))}),l.length===o.length)return void this.tableDestroy();const a=this.rows().reduce((t,n)=>{let o=n.domNode.getBoundingClientRect();return o.y>e.y-b&&o.y+o.height<e.y+e.height+b&&(t+=1),t},0);s.forEach(e=>{const t=e.domNode.getBoundingClientRect(),n=t.x+t.width,o=e.parent.next,r=o.children.reduce((e,t)=>{const o=t.domNode.getBoundingClientRect();return Math.abs(n-o.x)<b&&(e=t),e},null);o.insertBefore(e,r),e.format("row",o.formats().row)}),l.forEach(e=>{e.remove()}),i.forEach(e=>{const t=parseInt(e.formats().rowspan,10);e.format("rowspan",t-a)})}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 n=q(),o=e.formats().row,r=this.scroll.create(g.blotName,Object.assign({},f,{row:o})),l=this.scroll.create(m.blotName,{row:o,cell:n});r.appendChild(l),t?e.insertBefore(r,t):e.appendChild(r)}insertColumn(e,t,n=!0){var o=this.descendants(w);const l=r(o,1)[0];var i=this.descendants(C);const s=r(i,1)[0],a=this.descendants(x);let d=[],c=[],u=[];if(null==l||null==l.children.head)return;this.descendants(g).forEach(t=>{const o=t.domNode.getBoundingClientRect(),r=o.x,l=o.x+o.width,i=e.x,s=e.x+e.width;n?Math.abs(l-s)<b?d.push(t):s-r>b&&s-l<-b&&c.push(t):Math.abs(r-i)<b?d.push(t):i-r>b&&i-l<-b&&c.push(t)}),d.forEach(e=>{const t=n?e.next:e,o=q(),r=e.parent,l=r.formats().row,i=e.formats(),s=this.scroll.create(g.blotName,Object.assign({},f,{row:l,rowspan:i.rowspan})),a=this.scroll.create(m.blotName,{row:l,cell:o,rowspan:i.rowspan});s.appendChild(a),t?r.insertBefore(s,t):r.appendChild(s),u.push(s)});const h=this.scroll.create(x.blotName,!0);let p=n?a[t].next:a[t];return p?s.insertBefore(h,p):s.appendChild(h),c.forEach(e=>{const t=e.formats().colspan;e.format("colspan",parseInt(t,10)+1),u.push(e)}),u.sort((e,t)=>{return e.domNode.getBoundingClientRect().y-t.domNode.getBoundingClientRect().y}),this.updateTableWidth(),u}insertRow(e,t){var n=this.descendants(w);const o=r(n,1)[0];if(null==o||null==o.children.head)return;const l=this.descendants(g),i=N(),a=this.scroll.create(y.blotName,{row:i});let d=[],c=[],u=[];l.forEach(n=>{const o=n.domNode.getBoundingClientRect(),r=e.y,l=e.y+e.height,i=o.y,s=o.y+o.height;t?Math.abs(s-l)<b?d.push(n):l-i>b&&l-s<-b&&c.push(n):Math.abs(i-r)<b?d.push(n):r-i>b&&r-s<-b&&c.push(n)});const h=(e,t)=>{return e.domNode.getBoundingClientRect().x-t.domNode.getBoundingClientRect().x};d.sort(h),d.forEach(e=>{const t=q(),n=e.formats(),o=this.scroll.create(g.blotName,Object.assign({},f,{row:i,colspan:n.colspan})),r=this.scroll.create(m.blotName,{row:i,cell:t,colspan:n.colspan}),l=this.scroll.create(s.blotName);r.appendChild(l),o.appendChild(r),a.appendChild(o),u.push(o)}),c.forEach(e=>{const t=parseInt(e.formats().rowspan,10);e.format("rowspan",t+1),u.push(e)});const p=this.rows().find(n=>{let o=n.domNode.getBoundingClientRect();return t?Math.abs(o.y-e.y-e.height)<b:Math.abs(o.y-e.y)<b});return o.insertBefore(a,p),u.sort(h),u}mergeCells(e,t,n,o){const r=t.reduce((e,t,r)=>(0!==r?(e&&t.moveChildren(e),t.remove()):(t.format("colspan",o),t.format("rowspan",n),e=t),e),null);let l=r.domNode.getAttribute("data-row"),i=r.children.head.domNode.getAttribute("data-cell");return r.children.forEach(e=>{e.format("cell",i),e.format("row",l),e.format("colspan",o),e.format("rowspan",n)}),r}unmergeCells(e){let t={},n=1,o=1;e.forEach(e=>{if(t=e.formats(),n=t.rowspan,(o=t.colspan)>1){let t=e.next,n=e.row();e.format("colspan",1);for(let e=o;e>1;e--)this.insertCell(n,t)}if(n>1){let t=n,r=e.row().next;for(;t>1;){let n=r.children.reduce((t,n)=>{let o=e.domNode.getBoundingClientRect(),r=n.domNode.getBoundingClientRect();return Math.abs(o.x+o.width-r.x)<b&&(t=n),t},null);for(let e=o;e>0;e--)this.insertCell(r,n);t-=1,r=r.next}e.format("rowspan",1)}})}rows(){const e=this.children.tail;return null==e?[]:e.children.map(e=>e)}}v.blotName="table-container",v.className="quill-better-table",v.tagName="TABLE";class T extends d{constructor(e,t){super(e,t);const n=i.default.find(e.domNode.parentNode);t.addEventListener("scroll",e=>{const t=n.getModule("better-table");t.columnTool&&(t.columnTool.domNode.scrollLeft=e.target.scrollLeft),t.tableSelection&&t.tableSelection.selectedTds.length>0&&t.tableSelection.repositionHelpLines()},!1)}}function N(){return`row-${Math.random().toString(36).slice(2,6)}`}function q(){return`cell-${Math.random().toString(36).slice(2,6)}`}T.blotName="table-view",T.className="quill-better-table-wrapper",T.tagName="DIV",T.allowedChildren=[v],v.requiredContainer=T,v.allowedChildren=[w,C],w.requiredContainer=v,w.allowedChildren=[y],y.requiredContainer=w,y.allowedChildren=[g],g.requiredContainer=y,g.allowedChildren=[m],m.requiredContainer=g,C.allowedChildren=[x],C.requiredContainer=v,x.requiredContainer=C,t.TableCol=x,t.TableColGroup=C,t.TableCellLine=m,t.TableCell=g,t.TableRow=y,t.TableBody=w,t.TableContainer=v,t.TableViewWrapper=T,t.rowId=N,t.cellId=q},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var o=function(){return function(e,t){if(Array.isArray(e))return e;if(Symbol.iterator in Object(e))return function(e,t){var n=[],o=!0,r=!1,l=void 0;try{for(var i,s=e[Symbol.iterator]();!(o=(i=s.next()).done)&&(n.push(i.value),!t||n.length!==t);o=!0);}catch(e){r=!0,l=e}finally{try{!o&&s.return&&s.return()}finally{if(r)throw l}}return n}(e,t);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}(),r=d(n(0)),l=d(n(4)),i=d(n(5)),s=d(n(6)),a=n(2);function d(e){return e&&e.__esModule?e:{default:e}}const c=r.default.import("core/module"),u=r.default.import("delta");class h extends c{static register(){r.default.register(a.TableCol,!0),r.default.register(a.TableColGroup,!0),r.default.register(a.TableCellLine,!0),r.default.register(a.TableCell,!0),r.default.register(a.TableRow,!0),r.default.register(a.TableBody,!0),r.default.register(a.TableContainer,!0),r.default.register(a.TableViewWrapper,!0)}constructor(e,t){super(e,t),this.quill.root.addEventListener("click",n=>{if(!n.path||n.path.length<=0)return;const o=n.path.filter(e=>e.tagName&&"TABLE"===e.tagName.toUpperCase()&&e.classList.contains("quill-better-table"))[0];if(o){if(this.table===o)return;this.table&&this.hideTableTools(),this.showTableTools(o,e,t)}else this.table&&this.hideTableTools()},!1),this.quill.root.addEventListener("contextmenu",n=>{if(!this.table)return!0;if(n.preventDefault(),!n.path||n.path.length<=0)return;const o=n.path.filter(e=>e.tagName&&"TABLE"===e.tagName.toUpperCase()&&e.classList.contains("quill-better-table"))[0],r=n.path.filter(e=>e.tagName&&"TR"===e.tagName.toUpperCase()&&e.getAttribute("data-row"))[0],l=n.path.filter(e=>e.tagName&&"TD"===e.tagName.toUpperCase()&&e.getAttribute("data-row"))[0];let i=this.tableSelection.selectedTds.map(e=>e.domNode).includes(l);(this.tableSelection.selectedTds.length<=0||!i)&&this.tableSelection.setSelection(l.getBoundingClientRect(),l.getBoundingClientRect()),this.tableOperationMenu&&(this.tableOperationMenu=this.tableOperationMenu.destroy()),o&&(this.tableOperationMenu=new s.default({table:o,row:r,cell:l,left:n.pageX,top:n.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 n=this.quill.getLine(e.index);const r=o(n,1)[0];if(0===t.offset){var l=this.quill.getLine(e.index-1);const t=o(l,1)[0];if(null!=t&&"table-cell-line"===t.statics.blotName&&"table-cell-line"!==r.statics.blotName)return!1}return!0});let n=e.keyboard.bindings.Backspace.pop();e.keyboard.bindings.Backspace.splice(0,1,n)}getTable(e=this.quill.getSelection()){if(null==e)return[null,null,null,-1];var t=this.quill.getLine(e.index),n=o(t,2);const r=n[0],l=n[1];if(null==r||r.statics.blotName!==a.TableCellLine.blotName)return[null,null,null,-1];const i=r.tableCell(),s=i.row();return[s.table(),s,i,l]}insertTable(e,t){const n=this.quill.getSelection(!0);if(null==n)return;this.quill.getLeaf(n.index)[0],this.quill.getLeaf(n.index+1)[0];let o=(new u).retain(n.index);o.insert("\n"),o=new Array(t).fill("\n").reduce((e,t)=>(e.insert(t,{"table-col":!0}),e),o),o=new Array(e).fill(0).reduce(e=>{let n=(0,a.rowId)();return new Array(t).fill("\n").reduce((e,t)=>(e.insert(t,{"table-cell-line":{row:n,cell:(0,a.cellId)()}}),e),e)},o),this.quill.updateContents(o,r.default.sources.USER),this.quill.setSelection(n.index+1,r.default.sources.SILENT)}showTableTools(e,t,n){this.table=e,this.columnTool=new l.default(e,t,n),this.tableSelection=new i.default(e,t,n)}hideTableTools(){this.columnTool.destroy(),this.tableSelection.destroy(),this.tableOperationMenu&&this.tableOperationMenu.destroy(),this.columnTool=null,this.tableSelection=null,this.tableOperationMenu=null,this.table=null}}h.keyboardBindings={"table-cell-line backspace":{key:"Backspace",format:["table-cell-line"],collapsed:!0,offset:0,handler(e,t){var n=this.quill.getLine(e.index),r=o(n,2);const l=r[0];r[1];return!(!l.prev||"table-cell-line"!==l.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 n=r.default.imports.parchment.Scope;e.length>0&&this.quill.scroll.deleteAt(e.index,e.length);const o=Object.keys(t.format).reduce((e,o)=>(this.quill.scroll.query(o,n.BLOCK)&&!Array.isArray(t.format[o])&&(e[o]=t.format[o]),e),{});this.quill.insertText(e.index,"\n",o["table-cell-line"],r.default.sources.USER),this.quill.setSelection(e.index+1,r.default.sources.SILENT),this.quill.focus(),Object.keys(t.format).forEach(e=>{null==o[e]&&(Array.isArray(t.format[e])||"link"!==e&&this.quill.format(e,t.format[e],r.default.sources.USER))})}}},t.default=h},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var o,r=n(0),l=(o=r)&&o.__esModule?o:{default:o},i=n(1);const s=12,a=12,d=50,c="#35A7ED";t.default=class{constructor(e,t,n){if(!e)return null;this.table=e,this.quill=t,this.options=n,this.domNode=null,this.initColTool()}initColTool(){const e=this.quill.root.parentNode,t=(this.table.getBoundingClientRect(),e.getBoundingClientRect()),n=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:`${n.width}px`,height:`${s}px`,left:`${n.left-t.left+e.scrollLeft}px`,top:`${n.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=l.default.find(this.table),t=e.children.tail.children.head.children,n=e.colGroup().children,o=function(e){return e.reduce((e,t)=>{const n=t.formats().colspan;return e+=parseInt(n,10)},0)}(t);let r=Array.from(this.domNode.querySelectorAll(".qlbt-col-tool-cell"));for(let e=0;e<Math.max(o,r.length);e++){let t=n.at(e),l=t&&parseInt(t.formats()[t.statics.blotName].width,10),s=null;r[e]?r[e]&&e>=o?r[e].remove():(s=r[e],(0,i.css)(s,{"min-width":`${l}px`})):(s=this.createToolCell(),this.domNode.appendChild(s),this.addColCellHolderHandler(s),(0,i.css)(s,{"min-width":`${l}px`}))}}destroy(){return this.domNode.remove(),null}addColCellHolderHandler(e){const t=l.default.find(this.table),n=e.querySelector(".qlbt-col-tool-cell-holder");let o=!1,r=0,a=0,u=0,h=0,p={},f={},b=null;const m=e=>{e.preventDefault(),o&&(a=e.clientX,u=h+a-r>=d?a-r:d-h,(0,i.css)(b,{left:`${f.left+f.width-1+u}px`}))},g=l=>{l.preventDefault();const s=Array.from(this.domNode.querySelectorAll(".qlbt-col-tool-cell")).indexOf(e),d=t.colGroup().children.at(s);o&&(d.format("width",h+u),(0,i.css)(e,{"min-width":`${h+u}px`}),r=0,a=0,u=0,h=0,o=!1,n.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()};n.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),o=!0,r=t.clientX,h=f.width,n.classList.add("dragging")},!1)}colToolCells(){return Array.from(this.domNode.querySelectorAll(".qlbt-col-tool-cell"))}}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var o,r=n(0),l=(o=r)&&o.__esModule?o:{default:o},i=n(1),s=n(2);const a="#35A7ED",d=["left","right","top","bottom"],c=2;function u(e,t){let n=Math.min(e.x,t.x,e.x+e.width-1,t.x+t.width-1),o=Math.max(e.x,t.x,e.x+e.width-1,t.x+t.width-1),r=Math.min(e.y,t.y,e.y+e.height-1,t.y+t.height-1),l=Math.max(e.y,t.y,e.y+e.height-1,t.y+t.height-1);return{x:n,x1:o,y:r,y1:l,width:o-n,height:l-r}}t.default=class{constructor(e,t,n){if(!e)return null;this.table=e,this.quill=t,this.options=n,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",r,!1),this.quill.root.addEventListener("mouseup",function e(n){t.quill.root.removeEventListener("mousemove",r,!1),t.quill.root.removeEventListener("mouseup",e,!1),t.dragging=!1},!1);const t=this,n=e.target.closest("td[data-row]"),o=n.getBoundingClientRect();function r(e){if(0!==e.button||!e.target.closest(".quill-better-table"))return;const r=e.target.closest("td[data-row]"),l=r.getBoundingClientRect();t.boundary=u(o,l),t.correctBoundary(),t.selectedTds=t.computeSelectedTds(),t.repositionHelpLines(),n!==r&&t.quill.blur()}this.dragging=!0,this.boundary=u(o,o),this.correctBoundary(),this.selectedTds=this.computeSelectedTds(),this.repositionHelpLines()}correctBoundary(){l.default.find(this.table).descendants(s.TableCell).forEach(e=>{var t=e.domNode.getBoundingClientRect();let n=t.x,o=t.y,r=t.width,l=t.height;(n+c>=this.boundary.x&&n+c<=this.boundary.x1||n-c+r>=this.boundary.x&&n-c+r<=this.boundary.x1)&&(o+c>=this.boundary.y&&o+c<=this.boundary.y1||o-c+l>=this.boundary.y&&o-c+l<=this.boundary.y1)&&(this.boundary=u(this.boundary,{x:n,y:o,width:r,height:l}))})}computeSelectedTds(){return l.default.find(this.table).descendants(s.TableCell).reduce((e,t)=>{var n=t.domNode.getBoundingClientRect();let o=n.x,r=n.y,l=n.width,i=n.height;return o+c>=this.boundary.x&&o-c+l<=this.boundary.x1&&r+c>=this.boundary.y&&r-c+i<=this.boundary.y1&&e.push(t),e},[])}repositionHelpLines(){const e=this.quill.root.parentNode.getBoundingClientRect(),t=this.table.parentNode.scrollLeft;(0,i.css)(this.left,{display:"block",left:`${this.boundary.x-e.x-1-t}px`,top:`${this.boundary.y-e.y}px`,height:`${this.boundary.y1-this.boundary.y+1}px`,width:"1px"}),(0,i.css)(this.right,{display:"block",left:`${this.boundary.x1-e.x-t}px`,top:`${this.boundary.y-e.y}px`,height:`${this.boundary.y1-this.boundary.y+1}px`,width:"1px"}),(0,i.css)(this.top,{display:"block",left:`${this.boundary.x-e.x-1-t}px`,top:`${this.boundary.y-e.y}px`,width:`${this.boundary.x1-this.boundary.x+1}px`,height:"1px"}),(0,i.css)(this.bottom,{display:"block",left:`${this.boundary.x-e.x-1-t}px`,top:`${this.boundary.y1-e.y+1}px`,width:`${this.boundary.x1-this.boundary.x+1}px`,height:"1px"})}refreshHelpLinesPosition(){this.selectedTds[0].domNode.getBoundingClientRect();const e=this.selectedTds[this.selectedTds.length-1].domNode.getBoundingClientRect();this.boundary=u(startTdRect,e),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(e,t),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,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var o,r=n(0),l=(o=r)&&o.__esModule?o:{default:o},i=n(1);const s=150,a=200,d={insertColumnRight:{text:"Insert column right",handler(){const e=l.default.find(this.table);let t=c(this.columnToolCells,this.boundary,(e,t)=>Math.abs(e.x+e.width-t.x1)<=3);const n=e.insertColumn(this.boundary,t,!0);this.tableColumnTool.updateToolCells(),this.quill.update(l.default.sources.USER),this.quill.setSelection(this.quill.getIndex(n[0]),0,l.default.sources.SILENT),this.tableSelection.setSelection(n[0].domNode.getBoundingClientRect(),n[0].domNode.getBoundingClientRect())}},insertColumnLeft:{text:"Insert column left",handler(){const e=l.default.find(this.table);let t=c(this.columnToolCells,this.boundary,(e,t)=>Math.abs(e.x-t.x)<=3);const n=e.insertColumn(this.boundary,t,!1);this.tableColumnTool.updateToolCells(),this.quill.update(l.default.sources.USER),this.quill.setSelection(this.quill.getIndex(n[0]),0,l.default.sources.SILENT),this.tableSelection.setSelection(n[0].domNode.getBoundingClientRect(),n[0].domNode.getBoundingClientRect())}},insertRowUp:{text:"Insert row up",handler(){const e=l.default.find(this.table).insertRow(this.boundary,!1);this.quill.update(l.default.sources.USER),this.quill.setSelection(this.quill.getIndex(e[0]),0,l.default.sources.SILENT),this.tableSelection.setSelection(e[0].domNode.getBoundingClientRect(),e[0].domNode.getBoundingClientRect())}},insertRowDown:{text:"Insert row down",handler(){const e=l.default.find(this.table).insertRow(this.boundary,!0);this.quill.update(l.default.sources.USER),this.quill.setSelection(this.quill.getIndex(e[0]),0,l.default.sources.SILENT),this.tableSelection.setSelection(e[0].domNode.getBoundingClientRect(),e[0].domNode.getBoundingClientRect())}},mergeCells:{text:"Merge selected cells",handler(){const e=l.default.find(this.table),t=e.rows().reduce((e,t)=>{let n=t.domNode.getBoundingClientRect();return n.y>this.boundary.y-3&&n.y+n.height<this.boundary.y+this.boundary.height+3&&(e+=1),e},0),n=this.columnToolCells.reduce((e,t)=>{let n=t.getBoundingClientRect();return n.x>this.boundary.x-3&&n.x+n.width<this.boundary.x+this.boundary.width+3&&(e+=1),e},0),o=e.mergeCells(this.boundary,this.selectedTds,t,n);this.quill.update(l.default.sources.USER),this.tableSelection.setSelection(o.domNode.getBoundingClientRect(),o.domNode.getBoundingClientRect())}},unmergeCells:{text:"Unmerge cells",handler(){l.default.find(this.table).unmergeCells(this.selectedTds),this.quill.update(l.default.sources.USER),this.tableSelection.clearSelection()}},deleteColumn:{text:"Delete selected columns",handler(){const e=l.default.find(this.table);let t=(n=this.columnToolCells,o=this.boundary,r=((e,t)=>e.x+3>t.x&&e.x+e.width-3<t.x1),n.reduce((e,t)=>{let l=t.getBoundingClientRect();return r(l,o)&&e.push(n.indexOf(t)),e},[]));var n,o,r;e.deleteColumns(this.boundary,t)||(this.tableColumnTool.updateToolCells(),this.quill.update(l.default.sources.USER),this.tableSelection.clearSelection())}},deleteRow:{text:"Delete selected rows",handler(){l.default.find(this.table).deleteRow(this.boundary),this.quill.update(l.default.sources.USER),this.tableSelection.clearSelection()}},deleteTable:{text:"Delete table",handler(){const e=this.quill.getModule("better-table"),t=l.default.find(this.table);e.hideTableTools(),t.remove(),this.quill.update(l.default.sources.USER)}}};function c(e,t,n){return e.reduce((o,r)=>{let l=r.getBoundingClientRect();return n(l,t)&&(o=e.indexOf(r)),o},!1)}t.default=class{constructor(e,t,n){const o=t.getModule("better-table");this.tableSelection=o.tableSelection,this.table=e.table,this.quill=t,this.options=n,this.menuItems=Object.assign({},d,n.items),this.tableColumnTool=o.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:n}){this.domNode=document.createElement("div"),this.domNode.classList.add("qlbt-operation-menu"),(0,i.css)(this.domNode,{position:"absolute",left:`${t}px`,top:`${n}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 n=document.createElement("div");return n.classList.add("qlbt-operation-menu-item"),n.innerText=e,n.addEventListener("click",t.bind(this),!1),n}}},function(e,t,n){},,,function(e,t,n){"use strict";var o,r=n(3),l=(o=r)&&o.__esModule?o:{default:o};n(7),Quill.register({"modules/better-table":l.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:l.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,o){!function(e,t){if(!v[e]||!x[e])return;for(var o in x[e]=!1,t)Object.prototype.hasOwnProperty.call(t,o)&&(b[o]=t[o]);0==--g&&0===y&&q()}(e,o),t&&t(e,o)};var o,l=!0,n="24ab327e97998cf74839",r=1e4,i={},s=[],a=[];function d(e){var t=E[e];if(!t)return S;var l=function(l){return t.hot.active?(E[l]?-1===E[l].parents.indexOf(e)&&E[l].parents.push(e):(s=[e],o=l),-1===t.children.indexOf(l)&&t.children.push(l)):(console.warn("[HMR] unexpected require("+l+") from disposed module "+e),s=[]),S(l)},n=function(e){return{configurable:!0,enumerable:!0,get:function(){return S[e]},set:function(t){S[e]=t}}};for(var r in S)Object.prototype.hasOwnProperty.call(S,r)&&"e"!==r&&"t"!==r&&Object.defineProperty(l,r,n(r));return l.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())}},l.t=function(e,t){return 1&t&&(e=l(e)),S.t(e,-2&t)},l}function c(e){var t={_acceptedDependencies:{},_declinedDependencies:{},_selfAccepted:!1,_selfDeclined:!1,_disposeHandlers:[],_main:o!==e,active:!0,accept:function(e,o){if(void 0===e)t._selfAccepted=!0;else if("function"==typeof e)t._selfAccepted=e;else if("object"==typeof e)for(var l=0;l<e.length;l++)t._acceptedDependencies[e[l]]=o||function(){};else t._acceptedDependencies[e]=o||function(){}},decline:function(e){if(void 0===e)t._selfDeclined=!0;else if("object"==typeof e)for(var o=0;o<e.length;o++)t._declinedDependencies[e[o]]=!0;else t._declinedDependencies[e]=!0},dispose:function(e){t._disposeHandlers.push(e)},addDisposeHandler:function(e){t._disposeHandlers.push(e)},removeDisposeHandler:function(e){var o=t._disposeHandlers.indexOf(e);o>=0&&t._disposeHandlers.splice(o,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 o=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 l=e,p("check"),(t=r,t=t||1e4,new Promise(function(e,o){if("undefined"==typeof XMLHttpRequest)return o(new Error("No browser support"));try{var l=new XMLHttpRequest,r=S.p+""+n+".hot-update.json";l.open("GET",r,!0),l.timeout=t,l.send(null)}catch(e){return o(e)}l.onreadystatechange=function(){if(4===l.readyState)if(0===l.status)o(new Error("Manifest request to "+r+" timed out."));else if(404===l.status)e();else if(200!==l.status&&304!==l.status)o(new Error("Manifest request to "+r+" failed."));else{try{var t=JSON.parse(l.responseText)}catch(e){return void o(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+"."+n+".hot-update.js",document.head.appendChild(t)}(e)):w[e]=!0}function q(){p("ready");var e=f;if(f=null,e)if(l)Promise.resolve().then(function(){return R(l)}).then(function(t){e.resolve(t)},function(t){e.reject(t)});else{var t=[];for(var o in b)Object.prototype.hasOwnProperty.call(b,o)&&t.push(C(o));e.resolve(t)}}function R(t){if("ready"!==h)throw new Error("apply() is only allowed in ready status");var o,l,r,a,d;function c(e){for(var t=[e],o={},l=t.slice().map(function(e){return{chain:[e],id:e}});l.length>0;){var n=l.pop(),r=n.id,i=n.chain;if((a=E[r])&&!a.hot._selfAccepted){if(a.hot._selfDeclined)return{type:"self-declined",chain:i,moduleId:r};if(a.hot._main)return{type:"unaccepted",chain:i,moduleId:r};for(var s=0;s<a.parents.length;s++){var d=a.parents[s],c=E[d];if(c){if(c.hot._declinedDependencies[r])return{type:"declined",chain:i.concat([d]),moduleId:r,parentId:d};-1===t.indexOf(d)&&(c.hot._acceptedDependencies[r]?(o[d]||(o[d]=[]),u(o[d],[r])):(delete o[d],t.push(d),l.push({chain:i.concat([d]),id:d})))}}}}return{type:"accepted",moduleId:e,outdatedModules:t,outdatedDependencies:o}}function u(e,t){for(var o=0;o<t.length;o++){var l=t[o];-1===e.indexOf(l)&&e.push(l)}}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,O="";switch((N=b[x]?c(d):{type:"disposed",moduleId:x}).chain&&(O="\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+O));break;case"declined":t.onDeclined&&t.onDeclined(N),t.ignoreDeclined||(T=new Error("Aborted because of declined dependency: "+N.moduleId+" in "+N.parentId+O));break;case"unaccepted":t.onUnaccepted&&t.onUnaccepted(N),t.ignoreUnaccepted||(T=new Error("Aborted because "+d+" is not accepted"+O));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 A,B=[];for(l=0;l<g.length;l++)d=g[l],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,I=g.slice();I.length>0;)if(d=I.pop(),a=E[d]){var _={},k=a.hot._disposeHandlers;for(r=0;r<k.length;r++)(o=k[r])(_);for(i[d]=_,a.hot.active=!1,delete E[d],delete f[d],r=0;r<a.children.length;r++){var D=E[a.children[r]];D&&((A=D.parents.indexOf(d))>=0&&D.parents.splice(A,1))}}for(d in f)if(Object.prototype.hasOwnProperty.call(f,d)&&(a=E[d]))for(M=f[d],r=0;r<M.length;r++)L=M[r],(A=a.children.indexOf(L))>=0&&a.children.splice(A,1);for(d in p("apply"),n=m,y)Object.prototype.hasOwnProperty.call(y,d)&&(e[d]=y[d]);var $=null;for(d in f)if(Object.prototype.hasOwnProperty.call(f,d)&&(a=E[d])){M=f[d];var j=[];for(l=0;l<M.length;l++)if(L=M[l],o=a.hot._acceptedDependencies[L]){if(-1!==j.indexOf(o))continue;j.push(o)}for(l=0;l<j.length;l++){o=j[l];try{o(M)}catch(e){t.onErrored&&t.onErrored({type:"accept-errored",moduleId:d,dependencyId:M[l],error:e}),t.ignoreErrored||$||($=e)}}}for(l=0;l<B.length;l++){var H=B[l];d=H.module,s=[d];try{S(d)}catch(e){if("function"==typeof H.errorHandler)try{H.errorHandler(e)}catch(o){t.onErrored&&t.onErrored({type:"self-accept-error-handler-errored",moduleId:d,error:o,originalError:e}),t.ignoreErrored||$||($=o),$||($=e)}else t.onErrored&&t.onErrored({type:"self-accept-errored",moduleId:d,error:e}),t.ignoreErrored||$||($=e)}}return $?(p("fail"),Promise.reject($)):(p("idle"),new Promise(function(e){e(g)}))}var E={};function S(t){if(E[t])return E[t].exports;var o=E[t]={i:t,l:!1,exports:{},hot:c(t),parents:(a=s,s=[],a),children:[]};return e[t].call(o.exports,o,o.exports,d(t)),o.l=!0,o.exports}return S.m=e,S.c=E,S.d=function(e,t,o){S.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:o})},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 o=Object.create(null);if(S.r(o),Object.defineProperty(o,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var l in e)S.d(o,l,function(t){return e[t]}.bind(null,l));return o},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 n},d(10)(S.s=10)}([function(t,o){t.exports=e},function(e,t,o){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.css=function(e,t){if("object"==typeof t)for(let o in t)e.style[o]=t[o]},t.getRelativeRect=function(e,t){let o=t.getBoundingClientRect();return{x:e.x-o.x-t.scrollLeft,y:e.y-o.y-t.scrollTop,x1:e.x-o.x-t.scrollLeft+e.width,y1:e.y-o.y-t.scrollTop+e.height,width:e.width,height:e.height}}},function(e,t,o){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.cellId=t.rowId=t.TableViewWrapper=t.TableContainer=t.TableBody=t.TableRow=t.TableCell=t.TableCellLine=t.TableColGroup=t.TableCol=void 0;var l,n=function(){return function(e,t){if(Array.isArray(e))return e;if(Symbol.iterator in Object(e))return function(e,t){var o=[],l=!0,n=!1,r=void 0;try{for(var i,s=e[Symbol.iterator]();!(l=(i=s.next()).done)&&(o.push(i.value),!t||o.length!==t);l=!0);}catch(e){n=!0,r=e}finally{try{!l&&s.return&&s.return()}finally{if(n)throw r}}return o}(e,t);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}(),r=o(0),i=(l=r)&&l.__esModule?l:{default:l},s=o(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(o=>{let l=`${o}Id`;t.setAttribute(`data-${o}`,e[o]||l())}),f.forEach(o=>{t.setAttribute(`data-${o}`,e[o]||b[o])}),t}static formats(e){return f.concat(p).reduce((t,o)=>(e.hasAttribute(`data-${o}`)&&(t[o]=e.getAttribute(`data-${o}`)||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"),o=this.domNode.getAttribute("data-rowspan"),l=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:l,rowspan:o}),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"],o=this.next.children.head.formats()["table-cell-line"],l=this.next.children.tail.formats()["table-cell-line"];return e.cell===t.cell&&e.cell===o.cell&&e.cell===l.cell}return!1}static create(e){const t=super.create(e);return t.setAttribute("data-row",e.row),f.forEach(o=>{e[o]&&t.setAttribute(o,e[o])}),t}static formats(e){const t={};return e.hasAttribute("data-row")&&(t.row=e.getAttribute("data-row")),f.reduce((t,o)=>(e.hasAttribute(o)&&(t[o]=e.getAttribute(o)),t),t)}cellOffset(){return this.parent?this.parent.children.indexOf(this):-1}formats(){const e={};return this.domNode.hasAttribute("data-row")&&(e.row=this.domNode.getAttribute("data-row")),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(o=>{o.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(),o=this.next.children.head.formats(),l=this.next.children.tail.formats();return e.row===t.row&&e.row===o.row&&e.row===l.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),{})}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(o=>{t.setAttribute(`${o}`,e[o]||h[o])}),t}static formats(e){return u.reduce((t,o)=>(e.hasAttribute(`${o}`)&&(t[o]=e.getAttribute(`${o}`)||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=[],o){var l=this.descendants(x);const r=n(l,1)[0];if(null==r||null==r.children.head)return;const i=this.descendants(y),a=[],d=[];if(i.forEach(t=>{const l=(0,s.getRelativeRect)(t.domNode.getBoundingClientRect(),o);l.x+m>e.x&&l.x1-m<e.x1?a.push(t):l.x<e.x+m&&l.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 o=parseInt(e.formats().colspan,10);parseInt(e.formats().width,10);e.format("colspan",o-t.length)}),this.updateTableWidth()}deleteRow(e,t){var o=this.descendants(x);const l=n(o,1)[0];if(null==l||null==l.children.head)return;const r=this.descendants(y),i=[],a=[],d=[];if(r.forEach(o=>{const l=(0,s.getRelativeRect)(o.domNode.getBoundingClientRect(),t);l.y>e.y-m&&l.y1<e.y1+m?i.push(o):l.y<e.y+m&&l.y1>e.y1-m&&(a.push(o),Math.abs(l.y-e.y)<m&&d.push(o))}),i.length===r.length)return void this.tableDestroy();const c=this.rows().reduce((o,l)=>{let n=(0,s.getRelativeRect)(l.domNode.getBoundingClientRect(),t);return n.y>e.y-m&&n.y1<e.y1+m&&(o+=1),o},0);d.forEach(e=>{const o=(0,s.getRelativeRect)(e.domNode.getBoundingClientRect(),t),l=e.parent.next,n=l.children.reduce((e,l)=>{const n=(0,s.getRelativeRect)(l.domNode.getBoundingClientRect(),t);return Math.abs(o.x1-n.x)<m&&(e=l),e},null);l.insertBefore(e,n),e.format("row",l.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 o=R(),l=e.formats().row,n=this.scroll.create(y.blotName,Object.assign({},b,{row:l})),r=this.scroll.create(g.blotName,{row:l,cell:o});n.appendChild(r),t?e.insertBefore(n,t):e.appendChild(n)}insertColumn(e,t,o=!0,l){var r=this.descendants(x);const i=n(r,1)[0];var a=this.descendants(C);const d=n(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 n=(0,s.getRelativeRect)(t.domNode.getBoundingClientRect(),l);o?Math.abs(n.x1-e.x1)<m?u.push(t):e.x1-n.x>m&&e.x1-n.x1<-m&&h.push(t):Math.abs(n.x-e.x)<m?u.push(t):e.x-n.x>m&&e.x-n.x1<-m&&h.push(t)}),u.forEach(e=>{const t=o?e.next:e,l=R(),n=e.parent,r=n.formats().row,i=e.formats(),s=this.scroll.create(y.blotName,Object.assign({},b,{row:r,rowspan:i.rowspan})),a=this.scroll.create(g.blotName,{row:r,cell:l,rowspan:i.rowspan});s.appendChild(a),t?n.insertBefore(s,t):n.appendChild(s),p.push(s)});const f=this.scroll.create(v.blotName,!0);let w=o?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,o){var l=this.descendants(x);const r=n(l,1)[0];if(null==r||null==r.children.head)return;const i=this.descendants(y),d=q(),c=this.scroll.create(w.blotName,{row:d});let u=[],h=[],p=[];i.forEach(l=>{const n=(0,s.getRelativeRect)(l.domNode.getBoundingClientRect(),o);t?Math.abs(n.y1-e.y1)<m?u.push(l):e.y1-n.y>m&&e.y1-n.y1<-m&&h.push(l):Math.abs(n.y-e.y)<m?u.push(l):e.y-n.y>m&&e.y-n.y1<-m&&h.push(l)});const f=(e,t)=>{return e.domNode.getBoundingClientRect().x-t.domNode.getBoundingClientRect().x};u.sort(f),u.forEach(e=>{const t=R(),o=e.formats(),l=this.scroll.create(y.blotName,Object.assign({},b,{row:d,colspan:o.colspan})),n=this.scroll.create(g.blotName,{row:d,cell:t,colspan:o.colspan}),r=this.scroll.create(a.blotName);n.appendChild(r),l.appendChild(n),c.appendChild(l),p.push(l)}),h.forEach(e=>{const t=parseInt(e.formats().rowspan,10);e.format("rowspan",t+1),p.push(e)});const v=this.rows().find(l=>{let n=(0,s.getRelativeRect)(l.domNode.getBoundingClientRect(),o);return t?Math.abs(n.y-e.y-e.height)<m:Math.abs(n.y-e.y)<m});return r.insertBefore(c,v),p.sort(f),p}mergeCells(e,t,o,l,n){const r=t.reduce((e,t,n)=>(0!==n?(e&&t.moveChildren(e),t.remove()):(t.format("colspan",l),t.format("rowspan",o),e=t),e),null);let i=r.domNode.getAttribute("data-row"),s=r.children.head.domNode.getAttribute("data-cell");return r.children.forEach(e=>{e.format("cell",s),e.format("row",i),e.format("colspan",l),e.format("rowspan",o)}),r}unmergeCells(e,t){let o={},l=1,n=1;e.forEach(e=>{if(o=e.formats(),l=o.rowspan,(n=o.colspan)>1){let t=e.next,o=e.row();e.format("colspan",1);for(let e=n;e>1;e--)this.insertCell(o,t)}if(l>1){let o=l,r=e.row().next;for(;o>1;){let l=r.children.reduce((o,l)=>{let n=(0,s.getRelativeRect)(e.domNode.getBoundingClientRect(),t),r=(0,s.getRelativeRect)(l.domNode.getBoundingClientRect(),t);return Math.abs(n.x1-r.x)<m&&(o=l),o},null);for(let e=n;e>0;e--)this.insertCell(r,l);o-=1,r=r.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 o=i.default.find(e.domNode.parentNode);t.addEventListener("scroll",e=>{const t=o.getModule("better-table");t.columnTool&&(t.columnTool.domNode.scrollLeft=e.target.scrollLeft),t.tableSelection&&t.tableSelection.selectedTds.length>0&&t.tableSelection.repositionHelpLines()},!1)}}function 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},function(e,t,o){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var l=function(){return function(e,t){if(Array.isArray(e))return e;if(Symbol.iterator in Object(e))return function(e,t){var o=[],l=!0,n=!1,r=void 0;try{for(var i,s=e[Symbol.iterator]();!(l=(i=s.next()).done)&&(o.push(i.value),!t||o.length!==t);l=!0);}catch(e){n=!0,r=e}finally{try{!l&&s.return&&s.return()}finally{if(n)throw r}}return o}(e,t);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}(),n=d(o(0)),r=d(o(4)),i=d(o(5)),s=d(o(6)),a=o(2);function d(e){return e&&e.__esModule?e:{default:e}}const c=n.default.import("core/module"),u=n.default.import("delta");class h extends c{static register(){n.default.register(a.TableCol,!0),n.default.register(a.TableColGroup,!0),n.default.register(a.TableCellLine,!0),n.default.register(a.TableCell,!0),n.default.register(a.TableRow,!0),n.default.register(a.TableBody,!0),n.default.register(a.TableContainer,!0),n.default.register(a.TableViewWrapper,!0)}constructor(e,t){super(e,t),this.quill.root.addEventListener("click",o=>{if(!o.path||o.path.length<=0)return;const l=o.path.filter(e=>e.tagName&&"TABLE"===e.tagName.toUpperCase()&&e.classList.contains("quill-better-table"))[0];if(l){if(this.table===l)return;this.table&&this.hideTableTools(),this.showTableTools(l,e,t)}else this.table&&this.hideTableTools()},!1),this.quill.root.addEventListener("contextmenu",o=>{if(!this.table)return!0;if(o.preventDefault(),!o.path||o.path.length<=0)return;const l=o.path.filter(e=>e.tagName&&"TABLE"===e.tagName.toUpperCase()&&e.classList.contains("quill-better-table"))[0],n=o.path.filter(e=>e.tagName&&"TR"===e.tagName.toUpperCase()&&e.getAttribute("data-row"))[0],r=o.path.filter(e=>e.tagName&&"TD"===e.tagName.toUpperCase()&&e.getAttribute("data-row"))[0];let i=this.tableSelection.selectedTds.map(e=>e.domNode).includes(r);(this.tableSelection.selectedTds.length<=0||!i)&&this.tableSelection.setSelection(r.getBoundingClientRect(),r.getBoundingClientRect()),this.tableOperationMenu&&(this.tableOperationMenu=this.tableOperationMenu.destroy()),l&&(this.tableOperationMenu=new s.default({table:l,row:n,cell:r,left:o.pageX,top:o.pageY},e,t.operationMenu))},!1);e.getModule("keyboard");e.keyboard.addBinding({key:"Backspace"},{},function(e,t){if(0===e.index||this.quill.getLength()<=1)return!0;var o=this.quill.getLine(e.index);const n=l(o,1)[0];if(0===t.offset){var r=this.quill.getLine(e.index-1);const t=l(r,1)[0];if(null!=t&&"table-cell-line"===t.statics.blotName&&"table-cell-line"!==n.statics.blotName)return!1}return!0});let o=e.keyboard.bindings.Backspace.pop();e.keyboard.bindings.Backspace.splice(0,1,o)}getTable(e=this.quill.getSelection()){if(null==e)return[null,null,null,-1];var t=this.quill.getLine(e.index),o=l(t,2);const n=o[0],r=o[1];if(null==n||n.statics.blotName!==a.TableCellLine.blotName)return[null,null,null,-1];const i=n.tableCell(),s=i.row();return[s.table(),s,i,r]}insertTable(e,t){const o=this.quill.getSelection(!0);if(null==o)return;this.quill.getLeaf(o.index)[0],this.quill.getLeaf(o.index+1)[0];let l=(new u).retain(o.index);l.insert("\n"),l=new Array(t).fill("\n").reduce((e,t)=>(e.insert(t,{"table-col":!0}),e),l),l=new Array(e).fill(0).reduce(e=>{let o=(0,a.rowId)();return new Array(t).fill("\n").reduce((e,t)=>(e.insert(t,{"table-cell-line":{row:o,cell:(0,a.cellId)()}}),e),e)},l),this.quill.updateContents(l,n.default.sources.USER),this.quill.setSelection(o.index+1,n.default.sources.SILENT)}showTableTools(e,t,o){this.table=e,this.columnTool=new r.default(e,t,o),this.tableSelection=new i.default(e,t,o)}hideTableTools(){this.columnTool.destroy(),this.tableSelection.destroy(),this.tableOperationMenu&&this.tableOperationMenu.destroy(),this.columnTool=null,this.tableSelection=null,this.tableOperationMenu=null,this.table=null}}h.keyboardBindings={"table-cell-line backspace":{key:"Backspace",format:["table-cell-line"],collapsed:!0,offset:0,handler(e,t){var o=this.quill.getLine(e.index),n=l(o,2);const r=n[0];n[1];return!(!r.prev||"table-cell-line"!==r.prev.statics.blotName)}},"table-cell-line delete":{key:"Delete",format:["table-cell-line"],collapsed:!0,suffix:/^$/,handler(){}},"table-cell-line enter":{key:"Enter",shiftKey:null,format:["table-cell-line"],handler(e,t){if(this.quill.selection&&this.quill.selection.composing)return;const o=n.default.imports.parchment.Scope;e.length>0&&this.quill.scroll.deleteAt(e.index,e.length);const l=Object.keys(t.format).reduce((e,l)=>(this.quill.scroll.query(l,o.BLOCK)&&!Array.isArray(t.format[l])&&(e[l]=t.format[l]),e),{});this.quill.insertText(e.index,"\n",l["table-cell-line"],n.default.sources.USER),this.quill.setSelection(e.index+1,n.default.sources.SILENT),this.quill.focus(),Object.keys(t.format).forEach(e=>{null==l[e]&&(Array.isArray(t.format[e])||"link"!==e&&this.quill.format(e,t.format[e],n.default.sources.USER))})}}},t.default=h},function(e,t,o){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var l,n=o(0),r=(l=n)&&l.__esModule?l:{default:l},i=o(1);const s=12,a=12,d=50,c="#35A7ED";t.default=class{constructor(e,t,o){if(!e)return null;this.table=e,this.quill=t,this.options=o,this.domNode=null,this.initColTool()}initColTool(){const e=this.quill.root.parentNode,t=(this.table.getBoundingClientRect(),e.getBoundingClientRect()),o=this.table.parentNode.getBoundingClientRect();this.domNode=document.createElement("div"),this.domNode.classList.add("qlbt-col-tool"),this.updateToolCells(),e.appendChild(this.domNode),(0,i.css)(this.domNode,{width:`${o.width}px`,height:`${s}px`,left:`${o.left-t.left+e.scrollLeft}px`,top:`${o.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=r.default.find(this.table),t=e.children.tail.children.head.children,o=e.colGroup().children,l=function(e){return e.reduce((e,t)=>{const o=t.formats().colspan;return e+=parseInt(o,10)},0)}(t);let n=Array.from(this.domNode.querySelectorAll(".qlbt-col-tool-cell"));for(let e=0;e<Math.max(l,n.length);e++){let t=o.at(e),r=t&&parseInt(t.formats()[t.statics.blotName].width,10),s=null;n[e]?n[e]&&e>=l?n[e].remove():(s=n[e],(0,i.css)(s,{"min-width":`${r}px`})):(s=this.createToolCell(),this.domNode.appendChild(s),this.addColCellHolderHandler(s),(0,i.css)(s,{"min-width":`${r}px`}))}}destroy(){return this.domNode.remove(),null}addColCellHolderHandler(e){const t=r.default.find(this.table),o=e.querySelector(".qlbt-col-tool-cell-holder");let l=!1,n=0,a=0,u=0,h=0,p={},f={},b=null;const m=e=>{e.preventDefault(),l&&(a=e.clientX,u=h+a-n>=d?a-n:d-h,(0,i.css)(b,{left:`${f.left+f.width-1+u}px`}))},g=r=>{r.preventDefault();const s=Array.from(this.domNode.querySelectorAll(".qlbt-col-tool-cell")).indexOf(e),d=t.colGroup().children.at(s);l&&(d.format("width",h+u),(0,i.css)(e,{"min-width":`${h+u}px`}),n=0,a=0,u=0,h=0,l=!1,o.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()};o.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),l=!0,n=t.clientX,h=f.width,o.classList.add("dragging")},!1)}colToolCells(){return Array.from(this.domNode.querySelectorAll(".qlbt-col-tool-cell"))}}},function(e,t,o){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var l,n=o(0),r=(l=n)&&l.__esModule?l:{default:l},i=o(1),s=o(2);const a="#35A7ED",d=["left","right","top","bottom"],c=2;function u(e,t){let o=Math.min(e.x,t.x,e.x+e.width-1,t.x+t.width-1),l=Math.max(e.x,t.x,e.x+e.width-1,t.x+t.width-1),n=Math.min(e.y,t.y,e.y+e.height-1,t.y+t.height-1),r=Math.max(e.y,t.y,e.y+e.height-1,t.y+t.height-1);return{x:o,x1:l,y:n,y1:r,width:l-o,height:r-n}}t.default=class{constructor(e,t,o){if(!e)return null;this.table=e,this.quill=t,this.options=o,this.boundary={},this.selectedTds=[],this.dragging=!1,this.selectingHandler=this.mouseDownHandler.bind(this),this.clearSelectionHanler=this.clearSelection.bind(this),this.helpLinesInitial(),this.quill.root.addEventListener("mousedown",this.selectingHandler,!1),this.quill.on("text-change",this.clearSelectionHanler)}helpLinesInitial(){let e=this.quill.root.parentNode;d.forEach(t=>{this[t]=document.createElement("div"),this[t].classList.add("qlbt-selection-line"),(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",n,!1),this.quill.root.addEventListener("mouseup",function e(o){t.quill.root.removeEventListener("mousemove",n,!1),t.quill.root.removeEventListener("mouseup",e,!1),t.dragging=!1},!1);const t=this,o=e.target.closest("td[data-row]"),l=(0,i.getRelativeRect)(o.getBoundingClientRect(),this.quill.root.parentNode);function n(e){if(0!==e.button||!e.target.closest(".quill-better-table"))return;const n=e.target.closest("td[data-row]"),r=(0,i.getRelativeRect)(n.getBoundingClientRect(),t.quill.root.parentNode);t.boundary=u(l,r),t.correctBoundary(),t.selectedTds=t.computeSelectedTds(),t.repositionHelpLines(),o!==n&&t.quill.blur()}this.dragging=!0,this.boundary=u(l,l),this.correctBoundary(),this.selectedTds=this.computeSelectedTds(),this.repositionHelpLines()}correctBoundary(){r.default.find(this.table).descendants(s.TableCell).forEach(e=>{var t=(0,i.getRelativeRect)(e.domNode.getBoundingClientRect(),this.quill.root.parentNode);let o=t.x,l=t.y,n=t.width,r=t.height;(o+c>=this.boundary.x&&o+c<=this.boundary.x1||o-c+n>=this.boundary.x&&o-c+n<=this.boundary.x1)&&(l+c>=this.boundary.y&&l+c<=this.boundary.y1||l-c+r>=this.boundary.y&&l-c+r<=this.boundary.y1)&&(this.boundary=u(this.boundary,{x:o,y:l,width:n,height:r}))})}computeSelectedTds(){return r.default.find(this.table).descendants(s.TableCell).reduce((e,t)=>{var o=(0,i.getRelativeRect)(t.domNode.getBoundingClientRect(),this.quill.root.parentNode);let l=o.x,n=o.y,r=o.width,s=o.height;return l+c>=this.boundary.x&&l-c+r<=this.boundary.x1&&n+c>=this.boundary.y&&n-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,o){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var l,n=o(0),r=(l=n)&&l.__esModule?l:{default:l},i=o(1);const s=150,a=200,d={insertColumnRight:{text:"Insert column right",handler(){const e=r.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 o=e.insertColumn(this.boundary,t,!0,this.quill.root.parentNode);this.tableColumnTool.updateToolCells(),this.quill.update(r.default.sources.USER),this.quill.setSelection(this.quill.getIndex(o[0]),0,r.default.sources.SILENT),this.tableSelection.setSelection(o[0].domNode.getBoundingClientRect(),o[0].domNode.getBoundingClientRect())}},insertColumnLeft:{text:"Insert column left",handler(){const e=r.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 o=e.insertColumn(this.boundary,t,!1,this.quill.root.parentNode);this.tableColumnTool.updateToolCells(),this.quill.update(r.default.sources.USER),this.quill.setSelection(this.quill.getIndex(o[0]),0,r.default.sources.SILENT),this.tableSelection.setSelection(o[0].domNode.getBoundingClientRect(),o[0].domNode.getBoundingClientRect())}},insertRowUp:{text:"Insert row up",handler(){const e=r.default.find(this.table).insertRow(this.boundary,!1,this.quill.root.parentNode);this.quill.update(r.default.sources.USER),this.quill.setSelection(this.quill.getIndex(e[0]),0,r.default.sources.SILENT),this.tableSelection.setSelection(e[0].domNode.getBoundingClientRect(),e[0].domNode.getBoundingClientRect())}},insertRowDown:{text:"Insert row down",handler(){const e=r.default.find(this.table).insertRow(this.boundary,!0,this.quill.root.parentNode);this.quill.update(r.default.sources.USER),this.quill.setSelection(this.quill.getIndex(e[0]),0,r.default.sources.SILENT),this.tableSelection.setSelection(e[0].domNode.getBoundingClientRect(),e[0].domNode.getBoundingClientRect())}},mergeCells:{text:"Merge selected cells",handler(){const e=r.default.find(this.table),t=e.rows().reduce((e,t)=>{let o=(0,i.getRelativeRect)(t.domNode.getBoundingClientRect(),this.quill.root.parentNode);return o.y>this.boundary.y-5&&o.y+o.height<this.boundary.y+this.boundary.height+5&&(e+=1),e},0),o=this.columnToolCells.reduce((e,t)=>{let o=(0,i.getRelativeRect)(t.getBoundingClientRect(),this.quill.root.parentNode);return o.x>this.boundary.x-5&&o.x+o.width<this.boundary.x+this.boundary.width+5&&(e+=1),e},0),l=e.mergeCells(this.boundary,this.selectedTds,t,o,this.quill.root.parentNode);this.quill.update(r.default.sources.USER),this.tableSelection.setSelection(l.domNode.getBoundingClientRect(),l.domNode.getBoundingClientRect())}},unmergeCells:{text:"Unmerge cells",handler(){r.default.find(this.table).unmergeCells(this.selectedTds,this.quill.root.parentNode),this.quill.update(r.default.sources.USER),this.tableSelection.clearSelection()}},deleteColumn:{text:"Delete selected columns",handler(){const e=r.default.find(this.table);let t=(o=this.columnToolCells,l=this.boundary,n=((e,t)=>e.x+5>t.x&&e.x+e.width-5<t.x1),s=this.quill.root.parentNode,o.reduce((e,t)=>{let r=(0,i.getRelativeRect)(t.getBoundingClientRect(),s);return n(r,l)&&e.push(o.indexOf(t)),e},[]));var o,l,n,s;e.deleteColumns(this.boundary,t,this.quill.root.parentNode)||(this.tableColumnTool.updateToolCells(),this.quill.update(r.default.sources.USER),this.tableSelection.clearSelection())}},deleteRow:{text:"Delete selected rows",handler(){r.default.find(this.table).deleteRow(this.boundary,this.quill.root.parentNode),this.quill.update(r.default.sources.USER),this.tableSelection.clearSelection()}},deleteTable:{text:"Delete table",handler(){const e=this.quill.getModule("better-table"),t=r.default.find(this.table);e.hideTableTools(),t.remove(),this.quill.update(r.default.sources.USER)}}};function c(e,t,o,l){return e.reduce((n,r)=>{let s=(0,i.getRelativeRect)(r.getBoundingClientRect(),l);return o(s,t)&&(n=e.indexOf(r)),n},!1)}t.default=class{constructor(e,t,o){const l=t.getModule("better-table");this.tableSelection=l.tableSelection,this.table=e.table,this.quill=t,this.options=o,this.menuItems=Object.assign({},d,o.items),this.tableColumnTool=l.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:o}){this.domNode=document.createElement("div"),this.domNode.classList.add("qlbt-operation-menu"),(0,i.css)(this.domNode,{position:"absolute",left:`${t}px`,top:`${o}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 o=document.createElement("div");return o.classList.add("qlbt-operation-menu-item"),o.innerText=e,o.addEventListener("click",t.bind(this),!1),o}}},function(e,t,o){},,,function(e,t,o){"use strict";var l,n=o(3),r=(l=n)&&l.__esModule?l:{default:l};o(7),Quill.register({"modules/better-table":r.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:r.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,n){!function(e,t){if(!C[e]||!x[e])return;for(var n in x[e]=!1,t)Object.prototype.hasOwnProperty.call(t,n)&&(b[n]=t[n]);0==--g&&0===y&&q()}(e,n),t&&t(e,n)};var n,o=!0,r="e9d462dbaefc0ccb6596",l=1e4,i={},s=[],a=[];function d(e){var t=S[e];if(!t)return R;var o=function(o){return t.hot.active?(S[o]?-1===S[o].parents.indexOf(e)&&S[o].parents.push(e):(s=[e],n=o),-1===t.children.indexOf(o)&&t.children.push(o)):(console.warn("[HMR] unexpected require("+o+") from disposed module "+e),s=[]),R(o)},r=function(e){return{configurable:!0,enumerable:!0,get:function(){return R[e]},set:function(t){R[e]=t}}};for(var l in R)Object.prototype.hasOwnProperty.call(R,l)&&"e"!==l&&"t"!==l&&Object.defineProperty(o,l,r(l));return o.e=function(e){return"ready"===h&&p("prepare"),y++,R.e(e).then(t,function(e){throw t(),e});function t(){y--,"prepare"===h&&(w[e]||T(e),0===y&&0===g&&q())}},o.t=function(e,t){return 1&t&&(e=o(e)),R.t(e,-2&t)},o}function c(e){var t={_acceptedDependencies:{},_declinedDependencies:{},_selfAccepted:!1,_selfDeclined:!1,_disposeHandlers:[],_main:n!==e,active:!0,accept:function(e,n){if(void 0===e)t._selfAccepted=!0;else if("function"==typeof e)t._selfAccepted=e;else if("object"==typeof e)for(var o=0;o<e.length;o++)t._acceptedDependencies[e[o]]=n||function(){};else t._acceptedDependencies[e]=n||function(){}},decline:function(e){if(void 0===e)t._selfDeclined=!0;else if("object"==typeof e)for(var n=0;n<e.length;n++)t._declinedDependencies[e[n]]=!0;else t._declinedDependencies[e]=!0},dispose:function(e){t._disposeHandlers.push(e)},addDisposeHandler:function(e){t._disposeHandlers.push(e)},removeDisposeHandler:function(e){var n=t._disposeHandlers.indexOf(e);n>=0&&t._disposeHandlers.splice(n,1)},check:N,apply:E,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 n=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={},C={};function v(e){return+e+""===e?+e:e}function N(e){if("idle"!==h)throw new Error("check() is only allowed in idle status");return o=e,p("check"),(t=l,t=t||1e4,new Promise(function(e,n){if("undefined"==typeof XMLHttpRequest)return n(new Error("No browser support"));try{var o=new XMLHttpRequest,l=R.p+""+r+".hot-update.json";o.open("GET",l,!0),o.timeout=t,o.send(null)}catch(e){return n(e)}o.onreadystatechange=function(){if(4===o.readyState)if(0===o.status)n(new Error("Manifest request to "+l+" timed out."));else if(404===o.status)e();else if(200!==o.status&&304!==o.status)n(new Error("Manifest request to "+l+" failed."));else{try{var t=JSON.parse(o.responseText)}catch(e){return void n(e)}e(t)}}})).then(function(e){if(!e)return p("idle"),null;x={},w={},C=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){C[e]?(x[e]=!0,g++,function(e){var t=document.createElement("script");t.charset="utf-8",t.src=R.p+""+e+"."+r+".hot-update.js",document.head.appendChild(t)}(e)):w[e]=!0}function q(){p("ready");var e=f;if(f=null,e)if(o)Promise.resolve().then(function(){return E(o)}).then(function(t){e.resolve(t)},function(t){e.reject(t)});else{var t=[];for(var n in b)Object.prototype.hasOwnProperty.call(b,n)&&t.push(v(n));e.resolve(t)}}function E(t){if("ready"!==h)throw new Error("apply() is only allowed in ready status");var n,o,l,a,d;function c(e){for(var t=[e],n={},o=t.slice().map(function(e){return{chain:[e],id:e}});o.length>0;){var r=o.pop(),l=r.id,i=r.chain;if((a=S[l])&&!a.hot._selfAccepted){if(a.hot._selfDeclined)return{type:"self-declined",chain:i,moduleId:l};if(a.hot._main)return{type:"unaccepted",chain:i,moduleId:l};for(var s=0;s<a.parents.length;s++){var d=a.parents[s],c=S[d];if(c){if(c.hot._declinedDependencies[l])return{type:"declined",chain:i.concat([d]),moduleId:l,parentId:d};-1===t.indexOf(d)&&(c.hot._acceptedDependencies[l]?(n[d]||(n[d]=[]),u(n[d],[l])):(delete n[d],t.push(d),o.push({chain:i.concat([d]),id:d})))}}}}return{type:"accepted",moduleId:e,outdatedModules:t,outdatedDependencies:n}}function u(e,t){for(var n=0;n<t.length;n++){var o=t[n];-1===e.indexOf(o)&&e.push(o)}}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=v(x);var T=!1,q=!1,E=!1,O="";switch((N=b[x]?c(d):{type:"disposed",moduleId:x}).chain&&(O="\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+O));break;case"declined":t.onDeclined&&t.onDeclined(N),t.ignoreDeclined||(T=new Error("Aborted because of declined dependency: "+N.moduleId+" in "+N.parentId+O));break;case"unaccepted":t.onUnaccepted&&t.onUnaccepted(N),t.ignoreUnaccepted||(T=new Error("Aborted because "+d+" is not accepted"+O));break;case"accepted":t.onAccepted&&t.onAccepted(N),q=!0;break;case"disposed":t.onDisposed&&t.onDisposed(N),E=!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]));E&&(u(g,[N.moduleId]),y[d]=w)}var A,B=[];for(o=0;o<g.length;o++)d=g[o],S[d]&&S[d].hot._selfAccepted&&B.push({module:d,errorHandler:S[d].hot._selfAccepted});p("dispose"),Object.keys(C).forEach(function(e){!1===C[e]&&function(e){delete installedChunks[e]}(e)});for(var L,M,I=g.slice();I.length>0;)if(d=I.pop(),a=S[d]){var _={},D=a.hot._disposeHandlers;for(l=0;l<D.length;l++)(n=D[l])(_);for(i[d]=_,a.hot.active=!1,delete S[d],delete f[d],l=0;l<a.children.length;l++){var $=S[a.children[l]];$&&((A=$.parents.indexOf(d))>=0&&$.parents.splice(A,1))}}for(d in f)if(Object.prototype.hasOwnProperty.call(f,d)&&(a=S[d]))for(M=f[d],l=0;l<M.length;l++)L=M[l],(A=a.children.indexOf(L))>=0&&a.children.splice(A,1);for(d in p("apply"),r=m,y)Object.prototype.hasOwnProperty.call(y,d)&&(e[d]=y[d]);var j=null;for(d in f)if(Object.prototype.hasOwnProperty.call(f,d)&&(a=S[d])){M=f[d];var k=[];for(o=0;o<M.length;o++)if(L=M[o],n=a.hot._acceptedDependencies[L]){if(-1!==k.indexOf(n))continue;k.push(n)}for(o=0;o<k.length;o++){n=k[o];try{n(M)}catch(e){t.onErrored&&t.onErrored({type:"accept-errored",moduleId:d,dependencyId:M[o],error:e}),t.ignoreErrored||j||(j=e)}}}for(o=0;o<B.length;o++){var H=B[o];d=H.module,s=[d];try{R(d)}catch(e){if("function"==typeof H.errorHandler)try{H.errorHandler(e)}catch(n){t.onErrored&&t.onErrored({type:"self-accept-error-handler-errored",moduleId:d,error:n,originalError:e}),t.ignoreErrored||j||(j=n),j||(j=e)}else t.onErrored&&t.onErrored({type:"self-accept-errored",moduleId:d,error:e}),t.ignoreErrored||j||(j=e)}}return j?(p("fail"),Promise.reject(j)):(p("idle"),new Promise(function(e){e(g)}))}var S={};function R(t){if(S[t])return S[t].exports;var n=S[t]={i:t,l:!1,exports:{},hot:c(t),parents:(a=s,s=[],a),children:[]};return e[t].call(n.exports,n,n.exports,d(t)),n.l=!0,n.exports}return R.m=e,R.c=S,R.d=function(e,t,n){R.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},R.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},R.t=function(e,t){if(1&t&&(e=R(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(R.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)R.d(n,o,function(t){return e[t]}.bind(null,o));return n},R.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return R.d(t,"a",t),t},R.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},R.p="",R.h=function(){return r},d(8)(R.s=8)}([function(t,n){t.exports=e},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.css=function(e,t){if("object"==typeof t)for(let n in t)e.style[n]=t[n]}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.cellId=t.rowId=t.TableViewWrapper=t.TableContainer=t.TableBody=t.TableRow=t.TableCell=t.TableCellLine=t.TableColGroup=t.TableCol=void 0;var o,r=function(){return function(e,t){if(Array.isArray(e))return e;if(Symbol.iterator in Object(e))return function(e,t){var n=[],o=!0,r=!1,l=void 0;try{for(var i,s=e[Symbol.iterator]();!(o=(i=s.next()).done)&&(n.push(i.value),!t||n.length!==t);o=!0);}catch(e){r=!0,l=e}finally{try{!o&&s.return&&s.return()}finally{if(r)throw l}}return n}(e,t);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}(),l=n(0),i=(o=l)&&o.__esModule?o:{default:o};const s=i.default.import("blots/break"),a=i.default.import("blots/block"),d=i.default.import("blots/container"),c=["width"],u={width:100},h=["row","cell"],p=["rowspan","colspan"],f={rowspan:1,colspan:1},b=5;class m extends a{static create(e){const t=super.create(e);return h.forEach(n=>{let o=`${n}Id`;t.setAttribute(`data-${n}`,e[n]||o())}),p.forEach(n=>{t.setAttribute(`data-${n}`,e[n]||f[n])}),t}static formats(e){return p.concat(h).reduce((t,n)=>(e.hasAttribute(`data-${n}`)&&(t[n]=e.getAttribute(`data-${n}`)||void 0),t),{})}format(e,t){p.concat(h).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"),n=this.domNode.getAttribute("data-rowspan"),o=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:o,rowspan:n}),super.optimize(e)}tableCell(){return this.parent}}m.blotName="table-cell-line",m.ClassName="qlbt-cell-line",m.tagName="DIV";class g extends d{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"],n=this.next.children.head.formats()["table-cell-line"],o=this.next.children.tail.formats()["table-cell-line"];return e.cell===t.cell&&e.cell===n.cell&&e.cell===o.cell}return!1}static create(e){const t=super.create(e);return t.setAttribute("data-row",e.row),p.forEach(n=>{e[n]&&t.setAttribute(n,e[n])}),t}static formats(e){const t={};return e.hasAttribute("data-row")&&(t.row=e.getAttribute("data-row")),p.reduce((t,n)=>(e.hasAttribute(n)&&(t[n]=e.getAttribute(n)),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")),p.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(n=>{n.format(e,t)})}format(e,t){p.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()}}g.blotName="table",g.tagName="TD";class y extends d{checkMerge(){if(super.checkMerge()&&null!=this.next.children.head){const e=this.children.head.formats(),t=this.children.tail.formats(),n=this.next.children.head.formats(),o=this.next.children.tail.formats();return e.row===t.row&&e.row===n.row&&e.row===o.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),{})}rowOffset(){return this.parent?this.parent.children.indexOf(this):-1}table(){return this.parent&&this.parent.parent}}y.blotName="table-row",y.tagName="TR";class w extends d{}w.blotName="table-body",w.tagName="TBODY";class x extends a{static create(e){let t=super.create(e);return c.forEach(n=>{t.setAttribute(`${n}`,e[n]||u[n])}),t}static formats(e){return c.reduce((t,n)=>(e.hasAttribute(`${n}`)&&(t[n]=e.getAttribute(`${n}`)||void 0),t),{})}format(e,t){c.indexOf(e)>-1?this.domNode.setAttribute(`${e}`,t||u[e]):super.format(e,t)}html(){return this.domNode.outerHTML}}x.blotName="table-col",x.tagName="col";class C extends d{}C.blotName="table-col-group",C.tagName="colgroup";class v extends d{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()[x.blotName].width,10),0);this.domNode.style.width=`${t}px`},0)}getSelectedTds(){return this.selectedTds}cells(e){return this.rows().map(t=>t.children.at(e))}colGroup(){return this.children.head}deleteColumns(e,t=[]){var n=this.descendants(w);const o=r(n,1)[0];if(null==o||null==o.children.head)return;const l=this.descendants(g),i=[],s=[];if(l.forEach(t=>{const n=t.domNode.getBoundingClientRect(),o=e.x,r=e.x+e.width,l=n.x,a=n.x+n.width;l+b>o&&a-b<r?i.push(t):l<o+b&&a>r-b&&s.push(t)}),i.length===l.length)return this.tableDestroy(),!0;t.forEach(e=>{this.colGroup().children.at(t[0]).remove()}),i.forEach(e=>{e.remove()}),s.forEach(e=>{const n=parseInt(e.formats().colspan,10);parseInt(e.formats().width,10);e.format("colspan",n-t.length)}),this.updateTableWidth()}deleteRow(e){var t=this.descendants(w);const n=r(t,1)[0];if(null==n||null==n.children.head)return;const o=this.descendants(g),l=[],i=[],s=[];if(o.forEach(t=>{const n=t.domNode.getBoundingClientRect(),o=e.y,r=e.y+e.height,a=n.y,d=n.y+n.height;a>o-b&&d<r+b?l.push(t):a<o+b&&d>r-b&&(i.push(t),Math.abs(a-o)<b&&s.push(t))}),l.length===o.length)return void this.tableDestroy();const a=this.rows().reduce((t,n)=>{let o=n.domNode.getBoundingClientRect();return o.y>e.y-b&&o.y+o.height<e.y+e.height+b&&(t+=1),t},0);s.forEach(e=>{const t=e.domNode.getBoundingClientRect(),n=t.x+t.width,o=e.parent.next,r=o.children.reduce((e,t)=>{const o=t.domNode.getBoundingClientRect();return Math.abs(n-o.x)<b&&(e=t),e},null);o.insertBefore(e,r),e.format("row",o.formats().row)}),l.forEach(e=>{e.remove()}),i.forEach(e=>{const t=parseInt(e.formats().rowspan,10);e.format("rowspan",t-a)})}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 n=q(),o=e.formats().row,r=this.scroll.create(g.blotName,Object.assign({},f,{row:o})),l=this.scroll.create(m.blotName,{row:o,cell:n});r.appendChild(l),t?e.insertBefore(r,t):e.appendChild(r)}insertColumn(e,t,n=!0){var o=this.descendants(w);const l=r(o,1)[0];var i=this.descendants(C);const s=r(i,1)[0],a=this.descendants(x);let d=[],c=[],u=[];if(null==l||null==l.children.head)return;this.descendants(g).forEach(t=>{const o=t.domNode.getBoundingClientRect(),r=o.x,l=o.x+o.width,i=e.x,s=e.x+e.width;n?Math.abs(l-s)<b?d.push(t):s-r>b&&s-l<-b&&c.push(t):Math.abs(r-i)<b?d.push(t):i-r>b&&i-l<-b&&c.push(t)}),d.forEach(e=>{const t=n?e.next:e,o=q(),r=e.parent,l=r.formats().row,i=e.formats(),s=this.scroll.create(g.blotName,Object.assign({},f,{row:l,rowspan:i.rowspan})),a=this.scroll.create(m.blotName,{row:l,cell:o,rowspan:i.rowspan});s.appendChild(a),t?r.insertBefore(s,t):r.appendChild(s),u.push(s)});const h=this.scroll.create(x.blotName,!0);let p=n?a[t].next:a[t];return p?s.insertBefore(h,p):s.appendChild(h),c.forEach(e=>{const t=e.formats().colspan;e.format("colspan",parseInt(t,10)+1),u.push(e)}),u.sort((e,t)=>{return e.domNode.getBoundingClientRect().y-t.domNode.getBoundingClientRect().y}),this.updateTableWidth(),u}insertRow(e,t){var n=this.descendants(w);const o=r(n,1)[0];if(null==o||null==o.children.head)return;const l=this.descendants(g),i=T(),a=this.scroll.create(y.blotName,{row:i});let d=[],c=[],u=[];l.forEach(n=>{const o=n.domNode.getBoundingClientRect(),r=e.y,l=e.y+e.height,i=o.y,s=o.y+o.height;t?Math.abs(s-l)<b?d.push(n):l-i>b&&l-s<-b&&c.push(n):Math.abs(i-r)<b?d.push(n):r-i>b&&r-s<-b&&c.push(n)});const h=(e,t)=>{return e.domNode.getBoundingClientRect().x-t.domNode.getBoundingClientRect().x};d.sort(h),d.forEach(e=>{const t=q(),n=e.formats(),o=this.scroll.create(g.blotName,Object.assign({},f,{row:i,colspan:n.colspan})),r=this.scroll.create(m.blotName,{row:i,cell:t,colspan:n.colspan}),l=this.scroll.create(s.blotName);r.appendChild(l),o.appendChild(r),a.appendChild(o),u.push(o)}),c.forEach(e=>{const t=parseInt(e.formats().rowspan,10);e.format("rowspan",t+1),u.push(e)});const p=this.rows().find(n=>{let o=n.domNode.getBoundingClientRect();return t?Math.abs(o.y-e.y-e.height)<b:Math.abs(o.y-e.y)<b});return o.insertBefore(a,p),u.sort(h),u}mergeCells(e,t,n,o){const r=t.reduce((e,t,r)=>(0!==r?(e&&t.moveChildren(e),t.remove()):(t.format("colspan",o),t.format("rowspan",n),e=t),e),null);let l=r.domNode.getAttribute("data-row"),i=r.children.head.domNode.getAttribute("data-cell");return r.children.forEach(e=>{e.format("cell",i),e.format("row",l),e.format("colspan",o),e.format("rowspan",n)}),r}unmergeCells(e){let t={},n=1,o=1;e.forEach(e=>{if(t=e.formats(),n=t.rowspan,(o=t.colspan)>1){let t=e.next,n=e.row();e.format("colspan",1);for(let e=o;e>1;e--)this.insertCell(n,t)}if(n>1){let t=n,r=e.row().next;for(;t>1;){let n=r.children.reduce((t,n)=>{let o=e.domNode.getBoundingClientRect(),r=n.domNode.getBoundingClientRect();return Math.abs(o.x+o.width-r.x)<b&&(t=n),t},null);for(let e=o;e>0;e--)this.insertCell(r,n);t-=1,r=r.next}e.format("rowspan",1)}})}rows(){const e=this.children.tail;return null==e?[]:e.children.map(e=>e)}}v.blotName="table-container",v.className="quill-better-table",v.tagName="TABLE";class N extends d{constructor(e,t){super(e,t);const n=i.default.find(e.domNode.parentNode);t.addEventListener("scroll",e=>{const t=n.getModule("better-table");t.columnTool&&(t.columnTool.domNode.scrollLeft=e.target.scrollLeft),t.tableSelection&&t.tableSelection.selectedTds.length>0&&t.tableSelection.repositionHelpLines()},!1)}}function T(){return`row-${Math.random().toString(36).slice(2,6)}`}function q(){return`cell-${Math.random().toString(36).slice(2,6)}`}N.blotName="table-view",N.className="quill-better-table-wrapper",N.tagName="DIV",N.allowedChildren=[v],v.requiredContainer=N,v.allowedChildren=[w,C],w.requiredContainer=v,w.allowedChildren=[y],y.requiredContainer=w,y.allowedChildren=[g],g.requiredContainer=y,g.allowedChildren=[m],m.requiredContainer=g,C.allowedChildren=[x],C.requiredContainer=v,x.requiredContainer=C,t.TableCol=x,t.TableColGroup=C,t.TableCellLine=m,t.TableCell=g,t.TableRow=y,t.TableBody=w,t.TableContainer=v,t.TableViewWrapper=N,t.rowId=T,t.cellId=q},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var o=function(){return function(e,t){if(Array.isArray(e))return e;if(Symbol.iterator in Object(e))return function(e,t){var n=[],o=!0,r=!1,l=void 0;try{for(var i,s=e[Symbol.iterator]();!(o=(i=s.next()).done)&&(n.push(i.value),!t||n.length!==t);o=!0);}catch(e){r=!0,l=e}finally{try{!o&&s.return&&s.return()}finally{if(r)throw l}}return n}(e,t);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}(),r=d(n(0)),l=d(n(4)),i=d(n(5)),s=d(n(6)),a=n(2);function d(e){return e&&e.__esModule?e:{default:e}}const c=r.default.import("core/module"),u=r.default.import("delta");class h extends c{static register(){r.default.register(a.TableCol,!0),r.default.register(a.TableColGroup,!0),r.default.register(a.TableCellLine,!0),r.default.register(a.TableCell,!0),r.default.register(a.TableRow,!0),r.default.register(a.TableBody,!0),r.default.register(a.TableContainer,!0),r.default.register(a.TableViewWrapper,!0)}constructor(e,t){super(e,t),this.quill.root.addEventListener("click",n=>{if(!n.path||n.path.length<=0)return;const o=n.path.filter(e=>e.tagName&&"TABLE"===e.tagName.toUpperCase()&&e.classList.contains("quill-better-table"))[0];if(o){if(this.table===o)return;this.table&&this.hideTableTools(),this.showTableTools(o,e,t)}else this.table&&this.hideTableTools()},!1),this.quill.root.addEventListener("contextmenu",n=>{if(!this.table)return!0;if(n.preventDefault(),!n.path||n.path.length<=0)return;const o=n.path.filter(e=>e.tagName&&"TABLE"===e.tagName.toUpperCase()&&e.classList.contains("quill-better-table"))[0],r=n.path.filter(e=>e.tagName&&"TR"===e.tagName.toUpperCase()&&e.getAttribute("data-row"))[0],l=n.path.filter(e=>e.tagName&&"TD"===e.tagName.toUpperCase()&&e.getAttribute("data-row"))[0];let i=this.tableSelection.selectedTds.map(e=>e.domNode).includes(l);(this.tableSelection.selectedTds.length<=0||!i)&&this.tableSelection.setSelection(l.getBoundingClientRect(),l.getBoundingClientRect()),this.tableOperationMenu&&(this.tableOperationMenu=this.tableOperationMenu.destroy()),o&&(this.tableOperationMenu=new s.default({table:o,row:r,cell:l,left:n.pageX,top:n.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 n=this.quill.getLine(e.index);const r=o(n,1)[0];if(0===t.offset){var l=this.quill.getLine(e.index-1);const t=o(l,1)[0];if(null!=t&&"table-cell-line"===t.statics.blotName&&"table-cell-line"!==r.statics.blotName)return!1}return!0});let n=e.keyboard.bindings.Backspace.pop();e.keyboard.bindings.Backspace.splice(0,1,n)}getTable(e=this.quill.getSelection()){if(null==e)return[null,null,null,-1];var t=this.quill.getLine(e.index),n=o(t,2);const r=n[0],l=n[1];if(null==r||r.statics.blotName!==a.TableCellLine.blotName)return[null,null,null,-1];const i=r.tableCell(),s=i.row();return[s.table(),s,i,l]}insertTable(e,t){const n=this.quill.getSelection(!0);if(null==n)return;this.quill.getLeaf(n.index)[0],this.quill.getLeaf(n.index+1)[0];let o=(new u).retain(n.index);o.insert("\n"),o=new Array(t).fill("\n").reduce((e,t)=>(e.insert(t,{"table-col":!0}),e),o),o=new Array(e).fill(0).reduce(e=>{let n=(0,a.rowId)();return new Array(t).fill("\n").reduce((e,t)=>(e.insert(t,{"table-cell-line":{row:n,cell:(0,a.cellId)()}}),e),e)},o),this.quill.updateContents(o,r.default.sources.USER),this.quill.setSelection(n.index+1,r.default.sources.SILENT)}showTableTools(e,t,n){this.table=e,this.columnTool=new l.default(e,t,n),this.tableSelection=new i.default(e,t,n)}hideTableTools(){this.columnTool.destroy(),this.tableSelection.destroy(),this.tableOperationMenu&&this.tableOperationMenu.destroy(),this.columnTool=null,this.tableSelection=null,this.tableOperationMenu=null,this.table=null}}h.keyboardBindings={"table-cell-line backspace":{key:"Backspace",format:["table-cell-line"],collapsed:!0,offset:0,handler(e,t){var n=this.quill.getLine(e.index),r=o(n,2);const l=r[0];r[1];return!(!l.prev||"table-cell-line"!==l.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 n=r.default.imports.parchment.Scope;e.length>0&&this.quill.scroll.deleteAt(e.index,e.length);const o=Object.keys(t.format).reduce((e,o)=>(this.quill.scroll.query(o,n.BLOCK)&&!Array.isArray(t.format[o])&&(e[o]=t.format[o]),e),{});this.quill.insertText(e.index,"\n",o["table-cell-line"],r.default.sources.USER),this.quill.setSelection(e.index+1,r.default.sources.SILENT),this.quill.focus(),Object.keys(t.format).forEach(e=>{null==o[e]&&(Array.isArray(t.format[e])||"link"!==e&&this.quill.format(e,t.format[e],r.default.sources.USER))})}}},t.default=h},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var o,r=n(0),l=(o=r)&&o.__esModule?o:{default:o},i=n(1);const s=12,a=12,d=50,c="#35A7ED";t.default=class{constructor(e,t,n){if(!e)return null;this.table=e,this.quill=t,this.options=n,this.domNode=null,this.initColTool()}initColTool(){const e=this.quill.root.parentNode,t=(this.table.getBoundingClientRect(),e.getBoundingClientRect()),n=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:`${n.width}px`,height:`${s}px`,left:`${n.left-t.left+e.scrollLeft}px`,top:`${n.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=l.default.find(this.table),t=e.children.tail.children.head.children,n=e.colGroup().children,o=function(e){return e.reduce((e,t)=>{const n=t.formats().colspan;return e+=parseInt(n,10)},0)}(t);let r=Array.from(this.domNode.querySelectorAll(".qlbt-col-tool-cell"));for(let e=0;e<Math.max(o,r.length);e++){let t=n.at(e),l=t&&parseInt(t.formats()[t.statics.blotName].width,10),s=null;r[e]?r[e]&&e>=o?r[e].remove():(s=r[e],(0,i.css)(s,{"min-width":`${l}px`})):(s=this.createToolCell(),this.domNode.appendChild(s),this.addColCellHolderHandler(s),(0,i.css)(s,{"min-width":`${l}px`}))}}destroy(){return this.domNode.remove(),null}addColCellHolderHandler(e){const t=l.default.find(this.table),n=e.querySelector(".qlbt-col-tool-cell-holder");let o=!1,r=0,a=0,u=0,h=0,p={},f={},b=null;const m=e=>{e.preventDefault(),o&&(a=e.clientX,u=h+a-r>=d?a-r:d-h,(0,i.css)(b,{left:`${f.left+f.width-1+u}px`}))},g=l=>{l.preventDefault();const s=Array.from(this.domNode.querySelectorAll(".qlbt-col-tool-cell")).indexOf(e),d=t.colGroup().children.at(s);o&&(d.format("width",h+u),(0,i.css)(e,{"min-width":`${h+u}px`}),r=0,a=0,u=0,h=0,o=!1,n.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()};n.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),o=!0,r=t.clientX,h=f.width,n.classList.add("dragging")},!1)}colToolCells(){return Array.from(this.domNode.querySelectorAll(".qlbt-col-tool-cell"))}}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var o,r=n(0),l=(o=r)&&o.__esModule?o:{default:o},i=n(1),s=n(2);const a="#35A7ED",d=["left","right","top","bottom"],c=2;function u(e,t){let n=Math.min(e.x,t.x,e.x+e.width-1,t.x+t.width-1),o=Math.max(e.x,t.x,e.x+e.width-1,t.x+t.width-1),r=Math.min(e.y,t.y,e.y+e.height-1,t.y+t.height-1),l=Math.max(e.y,t.y,e.y+e.height-1,t.y+t.height-1);return{x:n,x1:o,y:r,y1:l,width:o-n,height:l-r}}t.default=class{constructor(e,t,n){if(!e)return null;this.table=e,this.quill=t,this.options=n,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",r,!1),this.quill.root.addEventListener("mouseup",function e(n){t.quill.root.removeEventListener("mousemove",r,!1),t.quill.root.removeEventListener("mouseup",e,!1),t.dragging=!1},!1);const t=this,n=e.target.closest("td[data-row]"),o=n.getBoundingClientRect();function r(e){if(0!==e.button||!e.target.closest(".quill-better-table"))return;const r=e.target.closest("td[data-row]"),l=r.getBoundingClientRect();t.boundary=u(o,l),t.correctBoundary(),t.selectedTds=t.computeSelectedTds(),t.repositionHelpLines(),n!==r&&t.quill.blur()}this.dragging=!0,this.boundary=u(o,o),this.correctBoundary(),this.selectedTds=this.computeSelectedTds(),this.repositionHelpLines()}correctBoundary(){l.default.find(this.table).descendants(s.TableCell).forEach(e=>{var t=e.domNode.getBoundingClientRect();let n=t.x,o=t.y,r=t.width,l=t.height;(n+c>=this.boundary.x&&n+c<=this.boundary.x1||n-c+r>=this.boundary.x&&n-c+r<=this.boundary.x1)&&(o+c>=this.boundary.y&&o+c<=this.boundary.y1||o-c+l>=this.boundary.y&&o-c+l<=this.boundary.y1)&&(this.boundary=u(this.boundary,{x:n,y:o,width:r,height:l}))})}computeSelectedTds(){return l.default.find(this.table).descendants(s.TableCell).reduce((e,t)=>{var n=t.domNode.getBoundingClientRect();let o=n.x,r=n.y,l=n.width,i=n.height;return o+c>=this.boundary.x&&o-c+l<=this.boundary.x1&&r+c>=this.boundary.y&&r-c+i<=this.boundary.y1&&e.push(t),e},[])}repositionHelpLines(){const e=this.quill.root.parentNode.getBoundingClientRect(),t=this.table.parentNode.scrollLeft;(0,i.css)(this.left,{display:"block",left:`${this.boundary.x-e.x-1-t}px`,top:`${this.boundary.y-e.y}px`,height:`${this.boundary.y1-this.boundary.y+1}px`,width:"1px"}),(0,i.css)(this.right,{display:"block",left:`${this.boundary.x1-e.x-t}px`,top:`${this.boundary.y-e.y}px`,height:`${this.boundary.y1-this.boundary.y+1}px`,width:"1px"}),(0,i.css)(this.top,{display:"block",left:`${this.boundary.x-e.x-1-t}px`,top:`${this.boundary.y-e.y}px`,width:`${this.boundary.x1-this.boundary.x+1}px`,height:"1px"}),(0,i.css)(this.bottom,{display:"block",left:`${this.boundary.x-e.x-1-t}px`,top:`${this.boundary.y1-e.y+1}px`,width:`${this.boundary.x1-this.boundary.x+1}px`,height:"1px"})}refreshHelpLinesPosition(){this.selectedTds[0].domNode.getBoundingClientRect();const e=this.selectedTds[this.selectedTds.length-1].domNode.getBoundingClientRect();this.boundary=u(startTdRect,e),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(e,t),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,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var o,r=n(0),l=(o=r)&&o.__esModule?o:{default:o},i=n(1);const s=150,a=200,d={insertColumnRight:{text:"Insert column right",handler(){const e=l.default.find(this.table);let t=c(this.columnToolCells,this.boundary,(e,t)=>Math.abs(e.x+e.width-t.x1)<=3);const n=e.insertColumn(this.boundary,t,!0);this.tableColumnTool.updateToolCells(),this.quill.update(l.default.sources.USER),this.quill.setSelection(this.quill.getIndex(n[0]),0,l.default.sources.SILENT),this.tableSelection.setSelection(n[0].domNode.getBoundingClientRect(),n[0].domNode.getBoundingClientRect())}},insertColumnLeft:{text:"Insert column left",handler(){const e=l.default.find(this.table);let t=c(this.columnToolCells,this.boundary,(e,t)=>Math.abs(e.x-t.x)<=3);const n=e.insertColumn(this.boundary,t,!1);this.tableColumnTool.updateToolCells(),this.quill.update(l.default.sources.USER),this.quill.setSelection(this.quill.getIndex(n[0]),0,l.default.sources.SILENT),this.tableSelection.setSelection(n[0].domNode.getBoundingClientRect(),n[0].domNode.getBoundingClientRect())}},insertRowUp:{text:"Insert row up",handler(){const e=l.default.find(this.table).insertRow(this.boundary,!1);this.quill.update(l.default.sources.USER),this.quill.setSelection(this.quill.getIndex(e[0]),0,l.default.sources.SILENT),this.tableSelection.setSelection(e[0].domNode.getBoundingClientRect(),e[0].domNode.getBoundingClientRect())}},insertRowDown:{text:"Insert row down",handler(){const e=l.default.find(this.table).insertRow(this.boundary,!0);this.quill.update(l.default.sources.USER),this.quill.setSelection(this.quill.getIndex(e[0]),0,l.default.sources.SILENT),this.tableSelection.setSelection(e[0].domNode.getBoundingClientRect(),e[0].domNode.getBoundingClientRect())}},mergeCells:{text:"Merge selected cells",handler(){const e=l.default.find(this.table),t=e.rows().reduce((e,t)=>{let n=t.domNode.getBoundingClientRect();return n.y>this.boundary.y-3&&n.y+n.height<this.boundary.y+this.boundary.height+3&&(e+=1),e},0),n=this.columnToolCells.reduce((e,t)=>{let n=t.getBoundingClientRect();return n.x>this.boundary.x-3&&n.x+n.width<this.boundary.x+this.boundary.width+3&&(e+=1),e},0),o=e.mergeCells(this.boundary,this.selectedTds,t,n);this.quill.update(l.default.sources.USER),this.tableSelection.setSelection(o.domNode.getBoundingClientRect(),o.domNode.getBoundingClientRect())}},unmergeCells:{text:"Unmerge cells",handler(){l.default.find(this.table).unmergeCells(this.selectedTds),this.quill.update(l.default.sources.USER),this.tableSelection.clearSelection()}},deleteColumn:{text:"Delete selected columns",handler(){const e=l.default.find(this.table);let t=(n=this.columnToolCells,o=this.boundary,r=((e,t)=>e.x+3>t.x&&e.x+e.width-3<t.x1),n.reduce((e,t)=>{let l=t.getBoundingClientRect();return r(l,o)&&e.push(n.indexOf(t)),e},[]));var n,o,r;e.deleteColumns(this.boundary,t)||(this.tableColumnTool.updateToolCells(),this.quill.update(l.default.sources.USER),this.tableSelection.clearSelection())}},deleteRow:{text:"Delete selected rows",handler(){l.default.find(this.table).deleteRow(this.boundary),this.quill.update(l.default.sources.USER),this.tableSelection.clearSelection()}},deleteTable:{text:"Delete table",handler(){const e=this.quill.getModule("better-table"),t=l.default.find(this.table);e.hideTableTools(),t.remove(),this.quill.update(l.default.sources.USER)}}};function c(e,t,n){return e.reduce((o,r)=>{let l=r.getBoundingClientRect();return n(l,t)&&(o=e.indexOf(r)),o},!1)}t.default=class{constructor(e,t,n){const o=t.getModule("better-table");this.tableSelection=o.tableSelection,this.table=e.table,this.quill=t,this.options=n,this.menuItems=Object.assign({},d,n.items),this.tableColumnTool=o.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:n}){this.domNode=document.createElement("div"),this.domNode.classList.add("qlbt-operation-menu"),(0,i.css)(this.domNode,{position:"absolute",left:`${t}px`,top:`${n}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 n=document.createElement("div");return n.classList.add("qlbt-operation-menu-item"),n.innerText=e,n.addEventListener("click",t.bind(this),!1),n}}},,function(e,t,n){e.exports=n(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,o){!function(e,t){if(!v[e]||!x[e])return;for(var o in x[e]=!1,t)Object.prototype.hasOwnProperty.call(t,o)&&(b[o]=t[o]);0==--g&&0===y&&q()}(e,o),t&&t(e,o)};var o,l=!0,n="24ab327e97998cf74839",r=1e4,i={},s=[],a=[];function d(e){var t=E[e];if(!t)return S;var l=function(l){return t.hot.active?(E[l]?-1===E[l].parents.indexOf(e)&&E[l].parents.push(e):(s=[e],o=l),-1===t.children.indexOf(l)&&t.children.push(l)):(console.warn("[HMR] unexpected require("+l+") from disposed module "+e),s=[]),S(l)},n=function(e){return{configurable:!0,enumerable:!0,get:function(){return S[e]},set:function(t){S[e]=t}}};for(var r in S)Object.prototype.hasOwnProperty.call(S,r)&&"e"!==r&&"t"!==r&&Object.defineProperty(l,r,n(r));return l.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())}},l.t=function(e,t){return 1&t&&(e=l(e)),S.t(e,-2&t)},l}function c(e){var t={_acceptedDependencies:{},_declinedDependencies:{},_selfAccepted:!1,_selfDeclined:!1,_disposeHandlers:[],_main:o!==e,active:!0,accept:function(e,o){if(void 0===e)t._selfAccepted=!0;else if("function"==typeof e)t._selfAccepted=e;else if("object"==typeof e)for(var l=0;l<e.length;l++)t._acceptedDependencies[e[l]]=o||function(){};else t._acceptedDependencies[e]=o||function(){}},decline:function(e){if(void 0===e)t._selfDeclined=!0;else if("object"==typeof e)for(var o=0;o<e.length;o++)t._declinedDependencies[e[o]]=!0;else t._declinedDependencies[e]=!0},dispose:function(e){t._disposeHandlers.push(e)},addDisposeHandler:function(e){t._disposeHandlers.push(e)},removeDisposeHandler:function(e){var o=t._disposeHandlers.indexOf(e);o>=0&&t._disposeHandlers.splice(o,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 o=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 l=e,p("check"),(t=r,t=t||1e4,new Promise(function(e,o){if("undefined"==typeof XMLHttpRequest)return o(new Error("No browser support"));try{var l=new XMLHttpRequest,r=S.p+""+n+".hot-update.json";l.open("GET",r,!0),l.timeout=t,l.send(null)}catch(e){return o(e)}l.onreadystatechange=function(){if(4===l.readyState)if(0===l.status)o(new Error("Manifest request to "+r+" timed out."));else if(404===l.status)e();else if(200!==l.status&&304!==l.status)o(new Error("Manifest request to "+r+" failed."));else{try{var t=JSON.parse(l.responseText)}catch(e){return void o(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+"."+n+".hot-update.js",document.head.appendChild(t)}(e)):w[e]=!0}function q(){p("ready");var e=f;if(f=null,e)if(l)Promise.resolve().then(function(){return R(l)}).then(function(t){e.resolve(t)},function(t){e.reject(t)});else{var t=[];for(var o in b)Object.prototype.hasOwnProperty.call(b,o)&&t.push(C(o));e.resolve(t)}}function R(t){if("ready"!==h)throw new Error("apply() is only allowed in ready status");var o,l,r,a,d;function c(e){for(var t=[e],o={},l=t.slice().map(function(e){return{chain:[e],id:e}});l.length>0;){var n=l.pop(),r=n.id,i=n.chain;if((a=E[r])&&!a.hot._selfAccepted){if(a.hot._selfDeclined)return{type:"self-declined",chain:i,moduleId:r};if(a.hot._main)return{type:"unaccepted",chain:i,moduleId:r};for(var s=0;s<a.parents.length;s++){var d=a.parents[s],c=E[d];if(c){if(c.hot._declinedDependencies[r])return{type:"declined",chain:i.concat([d]),moduleId:r,parentId:d};-1===t.indexOf(d)&&(c.hot._acceptedDependencies[r]?(o[d]||(o[d]=[]),u(o[d],[r])):(delete o[d],t.push(d),l.push({chain:i.concat([d]),id:d})))}}}}return{type:"accepted",moduleId:e,outdatedModules:t,outdatedDependencies:o}}function u(e,t){for(var o=0;o<t.length;o++){var l=t[o];-1===e.indexOf(l)&&e.push(l)}}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,O="";switch((N=b[x]?c(d):{type:"disposed",moduleId:x}).chain&&(O="\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+O));break;case"declined":t.onDeclined&&t.onDeclined(N),t.ignoreDeclined||(T=new Error("Aborted because of declined dependency: "+N.moduleId+" in "+N.parentId+O));break;case"unaccepted":t.onUnaccepted&&t.onUnaccepted(N),t.ignoreUnaccepted||(T=new Error("Aborted because "+d+" is not accepted"+O));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 A,B=[];for(l=0;l<g.length;l++)d=g[l],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,I=g.slice();I.length>0;)if(d=I.pop(),a=E[d]){var _={},D=a.hot._disposeHandlers;for(r=0;r<D.length;r++)(o=D[r])(_);for(i[d]=_,a.hot.active=!1,delete E[d],delete f[d],r=0;r<a.children.length;r++){var $=E[a.children[r]];$&&((A=$.parents.indexOf(d))>=0&&$.parents.splice(A,1))}}for(d in f)if(Object.prototype.hasOwnProperty.call(f,d)&&(a=E[d]))for(M=f[d],r=0;r<M.length;r++)L=M[r],(A=a.children.indexOf(L))>=0&&a.children.splice(A,1);for(d in p("apply"),n=m,y)Object.prototype.hasOwnProperty.call(y,d)&&(e[d]=y[d]);var j=null;for(d in f)if(Object.prototype.hasOwnProperty.call(f,d)&&(a=E[d])){M=f[d];var k=[];for(l=0;l<M.length;l++)if(L=M[l],o=a.hot._acceptedDependencies[L]){if(-1!==k.indexOf(o))continue;k.push(o)}for(l=0;l<k.length;l++){o=k[l];try{o(M)}catch(e){t.onErrored&&t.onErrored({type:"accept-errored",moduleId:d,dependencyId:M[l],error:e}),t.ignoreErrored||j||(j=e)}}}for(l=0;l<B.length;l++){var H=B[l];d=H.module,s=[d];try{S(d)}catch(e){if("function"==typeof H.errorHandler)try{H.errorHandler(e)}catch(o){t.onErrored&&t.onErrored({type:"self-accept-error-handler-errored",moduleId:d,error:o,originalError:e}),t.ignoreErrored||j||(j=o),j||(j=e)}else t.onErrored&&t.onErrored({type:"self-accept-errored",moduleId:d,error:e}),t.ignoreErrored||j||(j=e)}}return j?(p("fail"),Promise.reject(j)):(p("idle"),new Promise(function(e){e(g)}))}var E={};function S(t){if(E[t])return E[t].exports;var o=E[t]={i:t,l:!1,exports:{},hot:c(t),parents:(a=s,s=[],a),children:[]};return e[t].call(o.exports,o,o.exports,d(t)),o.l=!0,o.exports}return S.m=e,S.c=E,S.d=function(e,t,o){S.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:o})},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 o=Object.create(null);if(S.r(o),Object.defineProperty(o,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var l in e)S.d(o,l,function(t){return e[t]}.bind(null,l));return o},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 n},d(8)(S.s=8)}([function(t,o){t.exports=e},function(e,t,o){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.css=function(e,t){if("object"==typeof t)for(let o in t)e.style[o]=t[o]},t.getRelativeRect=function(e,t){let o=t.getBoundingClientRect();return{x:e.x-o.x-t.scrollLeft,y:e.y-o.y-t.scrollTop,x1:e.x-o.x-t.scrollLeft+e.width,y1:e.y-o.y-t.scrollTop+e.height,width:e.width,height:e.height}}},function(e,t,o){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.cellId=t.rowId=t.TableViewWrapper=t.TableContainer=t.TableBody=t.TableRow=t.TableCell=t.TableCellLine=t.TableColGroup=t.TableCol=void 0;var l,n=function(){return function(e,t){if(Array.isArray(e))return e;if(Symbol.iterator in Object(e))return function(e,t){var o=[],l=!0,n=!1,r=void 0;try{for(var i,s=e[Symbol.iterator]();!(l=(i=s.next()).done)&&(o.push(i.value),!t||o.length!==t);l=!0);}catch(e){n=!0,r=e}finally{try{!l&&s.return&&s.return()}finally{if(n)throw r}}return o}(e,t);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}(),r=o(0),i=(l=r)&&l.__esModule?l:{default:l},s=o(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(o=>{let l=`${o}Id`;t.setAttribute(`data-${o}`,e[o]||l())}),f.forEach(o=>{t.setAttribute(`data-${o}`,e[o]||b[o])}),t}static formats(e){return f.concat(p).reduce((t,o)=>(e.hasAttribute(`data-${o}`)&&(t[o]=e.getAttribute(`data-${o}`)||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"),o=this.domNode.getAttribute("data-rowspan"),l=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:l,rowspan:o}),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"],o=this.next.children.head.formats()["table-cell-line"],l=this.next.children.tail.formats()["table-cell-line"];return e.cell===t.cell&&e.cell===o.cell&&e.cell===l.cell}return!1}static create(e){const t=super.create(e);return t.setAttribute("data-row",e.row),f.forEach(o=>{e[o]&&t.setAttribute(o,e[o])}),t}static formats(e){const t={};return e.hasAttribute("data-row")&&(t.row=e.getAttribute("data-row")),f.reduce((t,o)=>(e.hasAttribute(o)&&(t[o]=e.getAttribute(o)),t),t)}cellOffset(){return this.parent?this.parent.children.indexOf(this):-1}formats(){const e={};return this.domNode.hasAttribute("data-row")&&(e.row=this.domNode.getAttribute("data-row")),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(o=>{o.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(),o=this.next.children.head.formats(),l=this.next.children.tail.formats();return e.row===t.row&&e.row===o.row&&e.row===l.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),{})}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(o=>{t.setAttribute(`${o}`,e[o]||h[o])}),t}static formats(e){return u.reduce((t,o)=>(e.hasAttribute(`${o}`)&&(t[o]=e.getAttribute(`${o}`)||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=[],o){var l=this.descendants(x);const r=n(l,1)[0];if(null==r||null==r.children.head)return;const i=this.descendants(y),a=[],d=[];if(i.forEach(t=>{const l=(0,s.getRelativeRect)(t.domNode.getBoundingClientRect(),o);l.x+m>e.x&&l.x1-m<e.x1?a.push(t):l.x<e.x+m&&l.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 o=parseInt(e.formats().colspan,10);parseInt(e.formats().width,10);e.format("colspan",o-t.length)}),this.updateTableWidth()}deleteRow(e,t){var o=this.descendants(x);const l=n(o,1)[0];if(null==l||null==l.children.head)return;const r=this.descendants(y),i=[],a=[],d=[];if(r.forEach(o=>{const l=(0,s.getRelativeRect)(o.domNode.getBoundingClientRect(),t);l.y>e.y-m&&l.y1<e.y1+m?i.push(o):l.y<e.y+m&&l.y1>e.y1-m&&(a.push(o),Math.abs(l.y-e.y)<m&&d.push(o))}),i.length===r.length)return void this.tableDestroy();const c=this.rows().reduce((o,l)=>{let n=(0,s.getRelativeRect)(l.domNode.getBoundingClientRect(),t);return n.y>e.y-m&&n.y1<e.y1+m&&(o+=1),o},0);d.forEach(e=>{const o=(0,s.getRelativeRect)(e.domNode.getBoundingClientRect(),t),l=e.parent.next,n=l.children.reduce((e,l)=>{const n=(0,s.getRelativeRect)(l.domNode.getBoundingClientRect(),t);return Math.abs(o.x1-n.x)<m&&(e=l),e},null);l.insertBefore(e,n),e.format("row",l.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 o=R(),l=e.formats().row,n=this.scroll.create(y.blotName,Object.assign({},b,{row:l})),r=this.scroll.create(g.blotName,{row:l,cell:o});n.appendChild(r),t?e.insertBefore(n,t):e.appendChild(n)}insertColumn(e,t,o=!0,l){var r=this.descendants(x);const i=n(r,1)[0];var a=this.descendants(C);const d=n(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 n=(0,s.getRelativeRect)(t.domNode.getBoundingClientRect(),l);o?Math.abs(n.x1-e.x1)<m?u.push(t):e.x1-n.x>m&&e.x1-n.x1<-m&&h.push(t):Math.abs(n.x-e.x)<m?u.push(t):e.x-n.x>m&&e.x-n.x1<-m&&h.push(t)}),u.forEach(e=>{const t=o?e.next:e,l=R(),n=e.parent,r=n.formats().row,i=e.formats(),s=this.scroll.create(y.blotName,Object.assign({},b,{row:r,rowspan:i.rowspan})),a=this.scroll.create(g.blotName,{row:r,cell:l,rowspan:i.rowspan});s.appendChild(a),t?n.insertBefore(s,t):n.appendChild(s),p.push(s)});const f=this.scroll.create(v.blotName,!0);let w=o?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,o){var l=this.descendants(x);const r=n(l,1)[0];if(null==r||null==r.children.head)return;const i=this.descendants(y),d=q(),c=this.scroll.create(w.blotName,{row:d});let u=[],h=[],p=[];i.forEach(l=>{const n=(0,s.getRelativeRect)(l.domNode.getBoundingClientRect(),o);t?Math.abs(n.y1-e.y1)<m?u.push(l):e.y1-n.y>m&&e.y1-n.y1<-m&&h.push(l):Math.abs(n.y-e.y)<m?u.push(l):e.y-n.y>m&&e.y-n.y1<-m&&h.push(l)});const f=(e,t)=>{return e.domNode.getBoundingClientRect().x-t.domNode.getBoundingClientRect().x};u.sort(f),u.forEach(e=>{const t=R(),o=e.formats(),l=this.scroll.create(y.blotName,Object.assign({},b,{row:d,colspan:o.colspan})),n=this.scroll.create(g.blotName,{row:d,cell:t,colspan:o.colspan}),r=this.scroll.create(a.blotName);n.appendChild(r),l.appendChild(n),c.appendChild(l),p.push(l)}),h.forEach(e=>{const t=parseInt(e.formats().rowspan,10);e.format("rowspan",t+1),p.push(e)});const v=this.rows().find(l=>{let n=(0,s.getRelativeRect)(l.domNode.getBoundingClientRect(),o);return t?Math.abs(n.y-e.y-e.height)<m:Math.abs(n.y-e.y)<m});return r.insertBefore(c,v),p.sort(f),p}mergeCells(e,t,o,l,n){const r=t.reduce((e,t,n)=>(0!==n?(e&&t.moveChildren(e),t.remove()):(t.format("colspan",l),t.format("rowspan",o),e=t),e),null);let i=r.domNode.getAttribute("data-row"),s=r.children.head.domNode.getAttribute("data-cell");return r.children.forEach(e=>{e.format("cell",s),e.format("row",i),e.format("colspan",l),e.format("rowspan",o)}),r}unmergeCells(e,t){let o={},l=1,n=1;e.forEach(e=>{if(o=e.formats(),l=o.rowspan,(n=o.colspan)>1){let t=e.next,o=e.row();e.format("colspan",1);for(let e=n;e>1;e--)this.insertCell(o,t)}if(l>1){let o=l,r=e.row().next;for(;o>1;){let l=r.children.reduce((o,l)=>{let n=(0,s.getRelativeRect)(e.domNode.getBoundingClientRect(),t),r=(0,s.getRelativeRect)(l.domNode.getBoundingClientRect(),t);return Math.abs(n.x1-r.x)<m&&(o=l),o},null);for(let e=n;e>0;e--)this.insertCell(r,l);o-=1,r=r.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 o=i.default.find(e.domNode.parentNode);t.addEventListener("scroll",e=>{const t=o.getModule("better-table");t.columnTool&&(t.columnTool.domNode.scrollLeft=e.target.scrollLeft),t.tableSelection&&t.tableSelection.selectedTds.length>0&&t.tableSelection.repositionHelpLines()},!1)}}function 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},function(e,t,o){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var l=function(){return function(e,t){if(Array.isArray(e))return e;if(Symbol.iterator in Object(e))return function(e,t){var o=[],l=!0,n=!1,r=void 0;try{for(var i,s=e[Symbol.iterator]();!(l=(i=s.next()).done)&&(o.push(i.value),!t||o.length!==t);l=!0);}catch(e){n=!0,r=e}finally{try{!l&&s.return&&s.return()}finally{if(n)throw r}}return o}(e,t);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}(),n=d(o(0)),r=d(o(4)),i=d(o(5)),s=d(o(6)),a=o(2);function d(e){return e&&e.__esModule?e:{default:e}}const c=n.default.import("core/module"),u=n.default.import("delta");class h extends c{static register(){n.default.register(a.TableCol,!0),n.default.register(a.TableColGroup,!0),n.default.register(a.TableCellLine,!0),n.default.register(a.TableCell,!0),n.default.register(a.TableRow,!0),n.default.register(a.TableBody,!0),n.default.register(a.TableContainer,!0),n.default.register(a.TableViewWrapper,!0)}constructor(e,t){super(e,t),this.quill.root.addEventListener("click",o=>{if(!o.path||o.path.length<=0)return;const l=o.path.filter(e=>e.tagName&&"TABLE"===e.tagName.toUpperCase()&&e.classList.contains("quill-better-table"))[0];if(l){if(this.table===l)return;this.table&&this.hideTableTools(),this.showTableTools(l,e,t)}else this.table&&this.hideTableTools()},!1),this.quill.root.addEventListener("contextmenu",o=>{if(!this.table)return!0;if(o.preventDefault(),!o.path||o.path.length<=0)return;const l=o.path.filter(e=>e.tagName&&"TABLE"===e.tagName.toUpperCase()&&e.classList.contains("quill-better-table"))[0],n=o.path.filter(e=>e.tagName&&"TR"===e.tagName.toUpperCase()&&e.getAttribute("data-row"))[0],r=o.path.filter(e=>e.tagName&&"TD"===e.tagName.toUpperCase()&&e.getAttribute("data-row"))[0];let i=this.tableSelection.selectedTds.map(e=>e.domNode).includes(r);(this.tableSelection.selectedTds.length<=0||!i)&&this.tableSelection.setSelection(r.getBoundingClientRect(),r.getBoundingClientRect()),this.tableOperationMenu&&(this.tableOperationMenu=this.tableOperationMenu.destroy()),l&&(this.tableOperationMenu=new s.default({table:l,row:n,cell:r,left:o.pageX,top:o.pageY},e,t.operationMenu))},!1);e.getModule("keyboard");e.keyboard.addBinding({key:"Backspace"},{},function(e,t){if(0===e.index||this.quill.getLength()<=1)return!0;var o=this.quill.getLine(e.index);const n=l(o,1)[0];if(0===t.offset){var r=this.quill.getLine(e.index-1);const t=l(r,1)[0];if(null!=t&&"table-cell-line"===t.statics.blotName&&"table-cell-line"!==n.statics.blotName)return!1}return!0});let o=e.keyboard.bindings.Backspace.pop();e.keyboard.bindings.Backspace.splice(0,1,o)}getTable(e=this.quill.getSelection()){if(null==e)return[null,null,null,-1];var t=this.quill.getLine(e.index),o=l(t,2);const n=o[0],r=o[1];if(null==n||n.statics.blotName!==a.TableCellLine.blotName)return[null,null,null,-1];const i=n.tableCell(),s=i.row();return[s.table(),s,i,r]}insertTable(e,t){const o=this.quill.getSelection(!0);if(null==o)return;this.quill.getLeaf(o.index)[0],this.quill.getLeaf(o.index+1)[0];let l=(new u).retain(o.index);l.insert("\n"),l=new Array(t).fill("\n").reduce((e,t)=>(e.insert(t,{"table-col":!0}),e),l),l=new Array(e).fill(0).reduce(e=>{let o=(0,a.rowId)();return new Array(t).fill("\n").reduce((e,t)=>(e.insert(t,{"table-cell-line":{row:o,cell:(0,a.cellId)()}}),e),e)},l),this.quill.updateContents(l,n.default.sources.USER),this.quill.setSelection(o.index+1,n.default.sources.SILENT)}showTableTools(e,t,o){this.table=e,this.columnTool=new r.default(e,t,o),this.tableSelection=new i.default(e,t,o)}hideTableTools(){this.columnTool.destroy(),this.tableSelection.destroy(),this.tableOperationMenu&&this.tableOperationMenu.destroy(),this.columnTool=null,this.tableSelection=null,this.tableOperationMenu=null,this.table=null}}h.keyboardBindings={"table-cell-line backspace":{key:"Backspace",format:["table-cell-line"],collapsed:!0,offset:0,handler(e,t){var o=this.quill.getLine(e.index),n=l(o,2);const r=n[0];n[1];return!(!r.prev||"table-cell-line"!==r.prev.statics.blotName)}},"table-cell-line delete":{key:"Delete",format:["table-cell-line"],collapsed:!0,suffix:/^$/,handler(){}},"table-cell-line enter":{key:"Enter",shiftKey:null,format:["table-cell-line"],handler(e,t){if(this.quill.selection&&this.quill.selection.composing)return;const o=n.default.imports.parchment.Scope;e.length>0&&this.quill.scroll.deleteAt(e.index,e.length);const l=Object.keys(t.format).reduce((e,l)=>(this.quill.scroll.query(l,o.BLOCK)&&!Array.isArray(t.format[l])&&(e[l]=t.format[l]),e),{});this.quill.insertText(e.index,"\n",l["table-cell-line"],n.default.sources.USER),this.quill.setSelection(e.index+1,n.default.sources.SILENT),this.quill.focus(),Object.keys(t.format).forEach(e=>{null==l[e]&&(Array.isArray(t.format[e])||"link"!==e&&this.quill.format(e,t.format[e],n.default.sources.USER))})}}},t.default=h},function(e,t,o){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var l,n=o(0),r=(l=n)&&l.__esModule?l:{default:l},i=o(1);const s=12,a=12,d=50,c="#35A7ED";t.default=class{constructor(e,t,o){if(!e)return null;this.table=e,this.quill=t,this.options=o,this.domNode=null,this.initColTool()}initColTool(){const e=this.quill.root.parentNode,t=(this.table.getBoundingClientRect(),e.getBoundingClientRect()),o=this.table.parentNode.getBoundingClientRect();this.domNode=document.createElement("div"),this.domNode.classList.add("qlbt-col-tool"),this.updateToolCells(),e.appendChild(this.domNode),(0,i.css)(this.domNode,{width:`${o.width}px`,height:`${s}px`,left:`${o.left-t.left+e.scrollLeft}px`,top:`${o.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=r.default.find(this.table),t=e.children.tail.children.head.children,o=e.colGroup().children,l=function(e){return e.reduce((e,t)=>{const o=t.formats().colspan;return e+=parseInt(o,10)},0)}(t);let n=Array.from(this.domNode.querySelectorAll(".qlbt-col-tool-cell"));for(let e=0;e<Math.max(l,n.length);e++){let t=o.at(e),r=t&&parseInt(t.formats()[t.statics.blotName].width,10),s=null;n[e]?n[e]&&e>=l?n[e].remove():(s=n[e],(0,i.css)(s,{"min-width":`${r}px`})):(s=this.createToolCell(),this.domNode.appendChild(s),this.addColCellHolderHandler(s),(0,i.css)(s,{"min-width":`${r}px`}))}}destroy(){return this.domNode.remove(),null}addColCellHolderHandler(e){const t=r.default.find(this.table),o=e.querySelector(".qlbt-col-tool-cell-holder");let l=!1,n=0,a=0,u=0,h=0,p={},f={},b=null;const m=e=>{e.preventDefault(),l&&(a=e.clientX,u=h+a-n>=d?a-n:d-h,(0,i.css)(b,{left:`${f.left+f.width-1+u}px`}))},g=r=>{r.preventDefault();const s=Array.from(this.domNode.querySelectorAll(".qlbt-col-tool-cell")).indexOf(e),d=t.colGroup().children.at(s);l&&(d.format("width",h+u),(0,i.css)(e,{"min-width":`${h+u}px`}),n=0,a=0,u=0,h=0,l=!1,o.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()};o.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),l=!0,n=t.clientX,h=f.width,o.classList.add("dragging")},!1)}colToolCells(){return Array.from(this.domNode.querySelectorAll(".qlbt-col-tool-cell"))}}},function(e,t,o){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var l,n=o(0),r=(l=n)&&l.__esModule?l:{default:l},i=o(1),s=o(2);const a="#35A7ED",d=["left","right","top","bottom"],c=2;function u(e,t){let o=Math.min(e.x,t.x,e.x+e.width-1,t.x+t.width-1),l=Math.max(e.x,t.x,e.x+e.width-1,t.x+t.width-1),n=Math.min(e.y,t.y,e.y+e.height-1,t.y+t.height-1),r=Math.max(e.y,t.y,e.y+e.height-1,t.y+t.height-1);return{x:o,x1:l,y:n,y1:r,width:l-o,height:r-n}}t.default=class{constructor(e,t,o){if(!e)return null;this.table=e,this.quill=t,this.options=o,this.boundary={},this.selectedTds=[],this.dragging=!1,this.selectingHandler=this.mouseDownHandler.bind(this),this.clearSelectionHanler=this.clearSelection.bind(this),this.helpLinesInitial(),this.quill.root.addEventListener("mousedown",this.selectingHandler,!1),this.quill.on("text-change",this.clearSelectionHanler)}helpLinesInitial(){let e=this.quill.root.parentNode;d.forEach(t=>{this[t]=document.createElement("div"),this[t].classList.add("qlbt-selection-line"),(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",n,!1),this.quill.root.addEventListener("mouseup",function e(o){t.quill.root.removeEventListener("mousemove",n,!1),t.quill.root.removeEventListener("mouseup",e,!1),t.dragging=!1},!1);const t=this,o=e.target.closest("td[data-row]"),l=(0,i.getRelativeRect)(o.getBoundingClientRect(),this.quill.root.parentNode);function n(e){if(0!==e.button||!e.target.closest(".quill-better-table"))return;const n=e.target.closest("td[data-row]"),r=(0,i.getRelativeRect)(n.getBoundingClientRect(),t.quill.root.parentNode);t.boundary=u(l,r),t.correctBoundary(),t.selectedTds=t.computeSelectedTds(),t.repositionHelpLines(),o!==n&&t.quill.blur()}this.dragging=!0,this.boundary=u(l,l),this.correctBoundary(),this.selectedTds=this.computeSelectedTds(),this.repositionHelpLines()}correctBoundary(){r.default.find(this.table).descendants(s.TableCell).forEach(e=>{var t=(0,i.getRelativeRect)(e.domNode.getBoundingClientRect(),this.quill.root.parentNode);let o=t.x,l=t.y,n=t.width,r=t.height;(o+c>=this.boundary.x&&o+c<=this.boundary.x1||o-c+n>=this.boundary.x&&o-c+n<=this.boundary.x1)&&(l+c>=this.boundary.y&&l+c<=this.boundary.y1||l-c+r>=this.boundary.y&&l-c+r<=this.boundary.y1)&&(this.boundary=u(this.boundary,{x:o,y:l,width:n,height:r}))})}computeSelectedTds(){return r.default.find(this.table).descendants(s.TableCell).reduce((e,t)=>{var o=(0,i.getRelativeRect)(t.domNode.getBoundingClientRect(),this.quill.root.parentNode);let l=o.x,n=o.y,r=o.width,s=o.height;return l+c>=this.boundary.x&&l-c+r<=this.boundary.x1&&n+c>=this.boundary.y&&n-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,o){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var l,n=o(0),r=(l=n)&&l.__esModule?l:{default:l},i=o(1);const s=150,a=200,d={insertColumnRight:{text:"Insert column right",handler(){const e=r.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 o=e.insertColumn(this.boundary,t,!0,this.quill.root.parentNode);this.tableColumnTool.updateToolCells(),this.quill.update(r.default.sources.USER),this.quill.setSelection(this.quill.getIndex(o[0]),0,r.default.sources.SILENT),this.tableSelection.setSelection(o[0].domNode.getBoundingClientRect(),o[0].domNode.getBoundingClientRect())}},insertColumnLeft:{text:"Insert column left",handler(){const e=r.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 o=e.insertColumn(this.boundary,t,!1,this.quill.root.parentNode);this.tableColumnTool.updateToolCells(),this.quill.update(r.default.sources.USER),this.quill.setSelection(this.quill.getIndex(o[0]),0,r.default.sources.SILENT),this.tableSelection.setSelection(o[0].domNode.getBoundingClientRect(),o[0].domNode.getBoundingClientRect())}},insertRowUp:{text:"Insert row up",handler(){const e=r.default.find(this.table).insertRow(this.boundary,!1,this.quill.root.parentNode);this.quill.update(r.default.sources.USER),this.quill.setSelection(this.quill.getIndex(e[0]),0,r.default.sources.SILENT),this.tableSelection.setSelection(e[0].domNode.getBoundingClientRect(),e[0].domNode.getBoundingClientRect())}},insertRowDown:{text:"Insert row down",handler(){const e=r.default.find(this.table).insertRow(this.boundary,!0,this.quill.root.parentNode);this.quill.update(r.default.sources.USER),this.quill.setSelection(this.quill.getIndex(e[0]),0,r.default.sources.SILENT),this.tableSelection.setSelection(e[0].domNode.getBoundingClientRect(),e[0].domNode.getBoundingClientRect())}},mergeCells:{text:"Merge selected cells",handler(){const e=r.default.find(this.table),t=e.rows().reduce((e,t)=>{let o=(0,i.getRelativeRect)(t.domNode.getBoundingClientRect(),this.quill.root.parentNode);return o.y>this.boundary.y-5&&o.y+o.height<this.boundary.y+this.boundary.height+5&&(e+=1),e},0),o=this.columnToolCells.reduce((e,t)=>{let o=(0,i.getRelativeRect)(t.getBoundingClientRect(),this.quill.root.parentNode);return o.x>this.boundary.x-5&&o.x+o.width<this.boundary.x+this.boundary.width+5&&(e+=1),e},0),l=e.mergeCells(this.boundary,this.selectedTds,t,o,this.quill.root.parentNode);this.quill.update(r.default.sources.USER),this.tableSelection.setSelection(l.domNode.getBoundingClientRect(),l.domNode.getBoundingClientRect())}},unmergeCells:{text:"Unmerge cells",handler(){r.default.find(this.table).unmergeCells(this.selectedTds,this.quill.root.parentNode),this.quill.update(r.default.sources.USER),this.tableSelection.clearSelection()}},deleteColumn:{text:"Delete selected columns",handler(){const e=r.default.find(this.table);let t=(o=this.columnToolCells,l=this.boundary,n=((e,t)=>e.x+5>t.x&&e.x+e.width-5<t.x1),s=this.quill.root.parentNode,o.reduce((e,t)=>{let r=(0,i.getRelativeRect)(t.getBoundingClientRect(),s);return n(r,l)&&e.push(o.indexOf(t)),e},[]));var o,l,n,s;e.deleteColumns(this.boundary,t,this.quill.root.parentNode)||(this.tableColumnTool.updateToolCells(),this.quill.update(r.default.sources.USER),this.tableSelection.clearSelection())}},deleteRow:{text:"Delete selected rows",handler(){r.default.find(this.table).deleteRow(this.boundary,this.quill.root.parentNode),this.quill.update(r.default.sources.USER),this.tableSelection.clearSelection()}},deleteTable:{text:"Delete table",handler(){const e=this.quill.getModule("better-table"),t=r.default.find(this.table);e.hideTableTools(),t.remove(),this.quill.update(r.default.sources.USER)}}};function c(e,t,o,l){return e.reduce((n,r)=>{let s=(0,i.getRelativeRect)(r.getBoundingClientRect(),l);return o(s,t)&&(n=e.indexOf(r)),n},!1)}t.default=class{constructor(e,t,o){const l=t.getModule("better-table");this.tableSelection=l.tableSelection,this.table=e.table,this.quill=t,this.options=o,this.menuItems=Object.assign({},d,o.items),this.tableColumnTool=l.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:o}){this.domNode=document.createElement("div"),this.domNode.classList.add("qlbt-operation-menu"),(0,i.css)(this.domNode,{position:"absolute",left:`${t}px`,top:`${o}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 o=document.createElement("div");return o.classList.add("qlbt-operation-menu-item"),o.innerText=e,o.addEventListener("click",t.bind(this),!1),o}}},,function(e,t,o){e.exports=o(3)}]).default}); |
{ | ||
"name": "quill-better-table", | ||
"version": "1.0.1", | ||
"version": "1.0.2", | ||
"description": "Module for better table in Quill, more useful features are supported.", | ||
@@ -5,0 +5,0 @@ "main": "dist/quill-better-table.js", |
import Quill from "quill" | ||
import { getRelativeRect } from '../utils' | ||
@@ -318,7 +319,2 @@ const Break = Quill.import("blots/break") | ||
// 获得选中的td | ||
getSelectedTds() { | ||
return this.selectedTds | ||
} | ||
cells(column) { | ||
@@ -332,3 +328,3 @@ return this.rows().map(row => row.children.at(column)) | ||
deleteColumns(compareRect, delIndexes = []) { | ||
deleteColumns(compareRect, delIndexes = [], editorWrapper) { | ||
const [body] = this.descendants(TableBody) | ||
@@ -342,16 +338,15 @@ if (body == null || body.children.head == null) return | ||
tableCells.forEach(cell => { | ||
const cellRect = cell.domNode.getBoundingClientRect() | ||
const compareLeft = compareRect.x | ||
const compareRight = compareRect.x + compareRect.width | ||
const cellLeft = cellRect.x | ||
const cellRight = cellRect.x + cellRect.width | ||
const cellRect = getRelativeRect( | ||
cell.domNode.getBoundingClientRect(), | ||
editorWrapper | ||
) | ||
if ( | ||
cellLeft + ERROR_LIMIT > compareLeft && | ||
cellRight - ERROR_LIMIT < compareRight | ||
cellRect.x + ERROR_LIMIT > compareRect.x && | ||
cellRect.x1 - ERROR_LIMIT < compareRect.x1 | ||
) { | ||
removedCells.push(cell) | ||
} else if ( | ||
cellLeft < compareLeft + ERROR_LIMIT && | ||
cellRight > compareRight - ERROR_LIMIT | ||
cellRect.x < compareRect.x + ERROR_LIMIT && | ||
cellRect.x1 > compareRect.x1 - ERROR_LIMIT | ||
) { | ||
@@ -367,3 +362,3 @@ modifiedCells.push(cell) | ||
// 删除该列对应的colBlot | ||
// remove the matches column tool cell | ||
delIndexes.forEach((delIndex) => { | ||
@@ -386,3 +381,3 @@ this.colGroup().children.at(delIndexes[0]).remove() | ||
deleteRow(compareRect) { | ||
deleteRow(compareRect, editorWrapper) { | ||
const [body] = this.descendants(TableBody) | ||
@@ -392,24 +387,24 @@ if (body == null || body.children.head == null) return | ||
const tableCells = this.descendants(TableCell) | ||
const removedCells = [] // 将被删掉的单元格 | ||
const modifiedCells = [] // 将被修改属性的单元格 | ||
const fallCells = [] // 将从上一行落到下一行的单元格 | ||
const removedCells = [] // cells to be removed | ||
const modifiedCells = [] // cells to be modified | ||
const fallCells = [] // cells to fall into next row | ||
tableCells.forEach(cell => { | ||
const cellRect = cell.domNode.getBoundingClientRect() | ||
const compareTop = compareRect.y | ||
const compareBottom = compareRect.y + compareRect.height | ||
const cellTop = cellRect.y | ||
const cellBottom = cellRect.y + cellRect.height | ||
const cellRect = getRelativeRect( | ||
cell.domNode.getBoundingClientRect(), | ||
editorWrapper | ||
) | ||
if ( | ||
cellTop > compareTop - ERROR_LIMIT && | ||
cellBottom < compareBottom + ERROR_LIMIT | ||
cellRect.y > compareRect.y - ERROR_LIMIT && | ||
cellRect.y1 < compareRect.y1 + ERROR_LIMIT | ||
) { | ||
removedCells.push(cell) | ||
} else if ( | ||
cellTop < compareTop + ERROR_LIMIT && | ||
cellBottom > compareBottom - ERROR_LIMIT | ||
cellRect.y < compareRect.y + ERROR_LIMIT && | ||
cellRect.y1 > compareRect.y1 - ERROR_LIMIT | ||
) { | ||
modifiedCells.push(cell) | ||
if (Math.abs(cellTop - compareTop) < ERROR_LIMIT) { | ||
if (Math.abs(cellRect.y - compareRect.y) < ERROR_LIMIT) { | ||
fallCells.push(cell) | ||
@@ -427,6 +422,10 @@ } | ||
const removedRowsLength = this.rows().reduce((sum, row) => { | ||
let rowRect = row.domNode.getBoundingClientRect() | ||
let rowRect = getRelativeRect( | ||
row.domNode.getBoundingClientRect(), | ||
editorWrapper | ||
) | ||
if ( | ||
rowRect.y > compareRect.y - ERROR_LIMIT && | ||
rowRect.y + rowRect.height < compareRect.y + compareRect.height + ERROR_LIMIT | ||
rowRect.y1 < compareRect.y1 + ERROR_LIMIT | ||
) { | ||
@@ -438,6 +437,8 @@ sum += 1 | ||
// 需要根据当前cell位置处理,必须放在删除单元格等改变布局的逻辑之前 | ||
// it must excute before the table layout changed with other operation | ||
fallCells.forEach(cell => { | ||
const cellRect = cell.domNode.getBoundingClientRect() | ||
const cellRight = cellRect.x + cellRect.width | ||
const cellRect = getRelativeRect( | ||
cell.domNode.getBoundingClientRect(), | ||
editorWrapper | ||
) | ||
const nextRow = cell.parent.next | ||
@@ -447,4 +448,7 @@ const cellsInNextRow = nextRow.children | ||
const refCell = cellsInNextRow.reduce((ref, compareCell) => { | ||
const compareRect = compareCell.domNode.getBoundingClientRect() | ||
if (Math.abs(cellRight - compareRect.x) < ERROR_LIMIT) { | ||
const compareRect = getRelativeRect( | ||
compareCell.domNode.getBoundingClientRect(), | ||
editorWrapper | ||
) | ||
if (Math.abs(cellRect.x1 - compareRect.x) < ERROR_LIMIT) { | ||
ref = compareCell | ||
@@ -499,7 +503,7 @@ } | ||
insertColumn(compareRect, colIndex, isRight = true) { | ||
insertColumn(compareRect, colIndex, isRight = true, editorWrapper) { | ||
const [body] = this.descendants(TableBody) | ||
const [tableColGroup] = this.descendants(TableColGroup) | ||
const tableCols = this.descendants(TableCol) | ||
let addRightCells = [] | ||
let addAsideCells = [] | ||
let modifiedCells = [] | ||
@@ -511,28 +515,31 @@ let affectedCells = [] | ||
tableCells.forEach(cell => { | ||
const cellRect = cell.domNode.getBoundingClientRect() | ||
const cellLeft = cellRect.x | ||
const cellRight = cellRect.x + cellRect.width | ||
const compareLeft = compareRect.x | ||
const compareRight = compareRect.x + compareRect.width | ||
const cellRect = getRelativeRect( | ||
cell.domNode.getBoundingClientRect(), | ||
editorWrapper | ||
) | ||
if (isRight) { | ||
if (Math.abs(cellRight - compareRight) < ERROR_LIMIT) { | ||
// 列工具单元的右边线与单元格右边线重合,此时在该单元格右边新增一格 | ||
addRightCells.push(cell) | ||
if (Math.abs(cellRect.x1 - compareRect.x1) < ERROR_LIMIT) { | ||
// the right of selected boundary equal to the right of table cell, | ||
// add a new table cell right aside this table cell | ||
addAsideCells.push(cell) | ||
} else if ( | ||
compareRight - cellLeft > ERROR_LIMIT && | ||
compareRight - cellRight < -ERROR_LIMIT | ||
compareRect.x1 - cellRect.x > ERROR_LIMIT && | ||
compareRect.x1 - cellRect.x1 < -ERROR_LIMIT | ||
) { | ||
// 列工具单元的右边线位于单元格之中 | ||
// the right of selected boundary is inside this table cell | ||
// colspan of this table cell will increase 1 | ||
modifiedCells.push(cell) | ||
} | ||
} else { | ||
if (Math.abs(cellLeft - compareLeft) < ERROR_LIMIT) { | ||
// compareRect的左边线与单元格左边线重合,此时在该单元格左边新增一格 | ||
addRightCells.push(cell) | ||
if (Math.abs(cellRect.x - compareRect.x) < ERROR_LIMIT) { | ||
// left of selected boundary equal to left of table cell, | ||
// add a new table cell left aside this table cell | ||
addAsideCells.push(cell) | ||
} else if ( | ||
compareLeft - cellLeft > ERROR_LIMIT && | ||
compareLeft - cellRight < -ERROR_LIMIT | ||
compareRect.x - cellRect.x > ERROR_LIMIT && | ||
compareRect.x - cellRect.x1 < -ERROR_LIMIT | ||
) { | ||
// compareRect的左边线位于单元格之中 | ||
// the left of selected boundary is inside this table cell | ||
// colspan of this table cell will increase 1 | ||
modifiedCells.push(cell) | ||
@@ -543,3 +550,3 @@ } | ||
addRightCells.forEach(cell => { | ||
addAsideCells.forEach(cell => { | ||
const ref = isRight ? cell.next : cell | ||
@@ -572,3 +579,3 @@ const id = cellId() | ||
// 插入新的TableCol | ||
// insert new tableCol | ||
const tableCol = this.scroll.create(TableCol.blotName, true) | ||
@@ -598,3 +605,3 @@ let colRef = isRight ? tableCols[colIndex].next : tableCols[colIndex] | ||
insertRow(compareRect, isDown) { | ||
insertRow(compareRect, isDown, editorWrapper) { | ||
const [body] = this.descendants(TableBody) | ||
@@ -613,28 +620,23 @@ if (body == null || body.children.head == null) return | ||
tableCells.forEach(cell => { | ||
const cellRect = cell.domNode.getBoundingClientRect() | ||
const compareTop = compareRect.y | ||
const compareBottom = compareRect.y + compareRect.height | ||
const cellTop = cellRect.y | ||
const cellBottom = cellRect.y + cellRect.height | ||
const cellRect = getRelativeRect( | ||
cell.domNode.getBoundingClientRect(), | ||
editorWrapper | ||
) | ||
if (isDown) { | ||
if (Math.abs(cellBottom - compareBottom) < ERROR_LIMIT) { | ||
// 行工具单元的下边线与单元格下边线重合,此时在该单元格下边新增一格 | ||
if (Math.abs(cellRect.y1 - compareRect.y1) < ERROR_LIMIT) { | ||
addBelowCells.push(cell) | ||
} else if ( | ||
compareBottom - cellTop > ERROR_LIMIT && | ||
compareBottom - cellBottom < -ERROR_LIMIT | ||
compareRect.y1 - cellRect.y > ERROR_LIMIT && | ||
compareRect.y1 - cellRect.y1 < -ERROR_LIMIT | ||
) { | ||
// 行工具单元的下边线位于单元格之中 | ||
modifiedCells.push(cell) | ||
} | ||
} else { | ||
if (Math.abs(cellTop - compareTop) < ERROR_LIMIT) { | ||
// 行工具单元的上边线与单元格上边线重合,此时在该单元格下边新增一格 | ||
if (Math.abs(cellRect.y - compareRect.y) < ERROR_LIMIT) { | ||
addBelowCells.push(cell) | ||
} else if ( | ||
compareTop - cellTop > ERROR_LIMIT && | ||
compareTop - cellBottom < -ERROR_LIMIT | ||
compareRect.y - cellRect.y > ERROR_LIMIT && | ||
compareRect.y - cellRect.y1 < -ERROR_LIMIT | ||
) { | ||
// 行工具单元的下边线位于单元格之中 | ||
modifiedCells.push(cell) | ||
@@ -645,3 +647,4 @@ } | ||
// 根据单元格Rect.x排序,防止异形表格插入新单元格顺序错误的问题 | ||
// ordered table cells with rect.x, fix error for inserting | ||
// new table cell in complicated table with wrong order. | ||
const sortFunc = (cellA, cellB) => { | ||
@@ -680,3 +683,6 @@ let x1 = cellA.domNode.getBoundingClientRect().x | ||
const refRow = this.rows().find(row => { | ||
let rowRect = row.domNode.getBoundingClientRect() | ||
let rowRect = getRelativeRect( | ||
row.domNode.getBoundingClientRect(), | ||
editorWrapper | ||
) | ||
if (isDown) { | ||
@@ -690,3 +696,3 @@ return Math.abs(rowRect.y - compareRect.y - compareRect.height) < ERROR_LIMIT | ||
// affectedCells根据rect.x排序 | ||
// reordering affectedCells | ||
affectedCells.sort(sortFunc) | ||
@@ -696,3 +702,3 @@ return affectedCells | ||
mergeCells (compareRect, mergingCells, rowspan, colspan) { | ||
mergeCells (compareRect, mergingCells, rowspan, colspan, editorWrapper) { | ||
const mergedCell = mergingCells.reduce((result, tableCell, index) => { | ||
@@ -723,3 +729,3 @@ if (index !== 0) { | ||
unmergeCells (unmergingCells) { | ||
unmergeCells (unmergingCells, editorWrapper) { | ||
let cellFormats = {} | ||
@@ -749,5 +755,11 @@ let cellRowspan = 1 | ||
.reduce((result, cell) => { | ||
let compareRect = tableCell.domNode.getBoundingClientRect() | ||
let cellRect = cell.domNode.getBoundingClientRect() | ||
if (Math.abs(compareRect.x + compareRect.width - cellRect.x) < ERROR_LIMIT) { | ||
let compareRect = getRelativeRect( | ||
tableCell.domNode.getBoundingClientRect(), | ||
editorWrapper | ||
) | ||
let cellRect = getRelativeRect( | ||
cell.domNode.getBoundingClientRect(), | ||
editorWrapper | ||
) | ||
if (Math.abs(compareRect.x1 - cellRect.x) < ERROR_LIMIT) { | ||
result = cell | ||
@@ -754,0 +766,0 @@ } |
import Quill from 'quill' | ||
import { css } from '../utils' | ||
import { css, getRelativeRect } from '../utils' | ||
const MENU_MIN_HEIHGT = 150 | ||
const MENU_WIDTH = 200 | ||
const ERROR_LIMIT = 3 | ||
const ERROR_LIMIT = 5 | ||
@@ -18,6 +18,12 @@ const MENU_ITEMS_DEFAULT = { | ||
return Math.abs(cellRect.x + cellRect.width - boundary.x1) <= ERROR_LIMIT | ||
} | ||
}, | ||
this.quill.root.parentNode | ||
) | ||
const newColumn = tableContainer.insertColumn(this.boundary, colIndex, true) | ||
const newColumn = tableContainer.insertColumn( | ||
this.boundary, | ||
colIndex, | ||
true, | ||
this.quill.root.parentNode) | ||
this.tableColumnTool.updateToolCells() | ||
@@ -46,6 +52,12 @@ this.quill.update(Quill.sources.USER) | ||
return Math.abs(cellRect.x - boundary.x) <= ERROR_LIMIT | ||
} | ||
}, | ||
this.quill.root.parentNode | ||
) | ||
const newColumn = tableContainer.insertColumn(this.boundary, colIndex, false) | ||
const newColumn = tableContainer.insertColumn( | ||
this.boundary, | ||
colIndex, | ||
false, | ||
this.quill.root.parentNode) | ||
this.tableColumnTool.updateToolCells() | ||
@@ -69,3 +81,7 @@ this.quill.update(Quill.sources.USER) | ||
const tableContainer = Quill.find(this.table) | ||
const affectedCells = tableContainer.insertRow(this.boundary, false) | ||
const affectedCells = tableContainer.insertRow( | ||
this.boundary, | ||
false, | ||
this.quill.root.parentNode | ||
) | ||
this.quill.update(Quill.sources.USER) | ||
@@ -88,3 +104,7 @@ this.quill.setSelection( | ||
const tableContainer = Quill.find(this.table) | ||
const affectedCells = tableContainer.insertRow(this.boundary, true) | ||
const affectedCells = tableContainer.insertRow( | ||
this.boundary, | ||
true, | ||
this.quill.root.parentNode | ||
) | ||
this.quill.update(Quill.sources.USER) | ||
@@ -109,3 +129,6 @@ this.quill.setSelection( | ||
const rowspan = tableContainer.rows().reduce((sum, row) => { | ||
let rowRect = row.domNode.getBoundingClientRect() | ||
let rowRect = getRelativeRect( | ||
row.domNode.getBoundingClientRect(), | ||
this.quill.root.parentNode | ||
) | ||
if ( | ||
@@ -122,3 +145,6 @@ rowRect.y > this.boundary.y - ERROR_LIMIT && | ||
const colspan = this.columnToolCells.reduce((sum, cell) => { | ||
let cellRect = cell.getBoundingClientRect() | ||
let cellRect = getRelativeRect( | ||
cell.getBoundingClientRect(), | ||
this.quill.root.parentNode | ||
) | ||
if ( | ||
@@ -133,3 +159,9 @@ cellRect.x > this.boundary.x - ERROR_LIMIT && | ||
const mergedCell = tableContainer.mergeCells(this.boundary, this.selectedTds, rowspan, colspan) | ||
const mergedCell = tableContainer.mergeCells( | ||
this.boundary, | ||
this.selectedTds, | ||
rowspan, | ||
colspan, | ||
this.quill.root.parentNode | ||
) | ||
this.quill.update(Quill.sources.USER) | ||
@@ -147,3 +179,6 @@ this.tableSelection.setSelection( | ||
const tableContainer = Quill.find(this.table) | ||
tableContainer.unmergeCells(this.selectedTds) | ||
tableContainer.unmergeCells( | ||
this.selectedTds, | ||
this.quill.root.parentNode | ||
) | ||
this.quill.update(Quill.sources.USER) | ||
@@ -164,6 +199,11 @@ this.tableSelection.clearSelection() | ||
cellRect.x + cellRect.width - ERROR_LIMIT < boundary.x1 | ||
} | ||
}, | ||
this.quill.root.parentNode | ||
) | ||
let isDeleteTable = tableContainer.deleteColumns(this.boundary, colIndexes) | ||
let isDeleteTable = tableContainer.deleteColumns( | ||
this.boundary, | ||
colIndexes, | ||
this.quill.root.parentNode | ||
) | ||
if (!isDeleteTable) { | ||
@@ -181,3 +221,6 @@ this.tableColumnTool.updateToolCells() | ||
const tableContainer = Quill.find(this.table) | ||
tableContainer.deleteRow(this.boundary) | ||
tableContainer.deleteRow( | ||
this.boundary, | ||
this.quill.root.parentNode | ||
) | ||
this.quill.update(Quill.sources.USER) | ||
@@ -260,5 +303,5 @@ this.tableSelection.clearSelection() | ||
function getColToolCellIndexByBoundary (cells, boundary, conditionFn) { | ||
function getColToolCellIndexByBoundary (cells, boundary, conditionFn, container) { | ||
return cells.reduce((findIndex, cell) => { | ||
let cellRect = cell.getBoundingClientRect() | ||
let cellRect = getRelativeRect(cell.getBoundingClientRect(), container) | ||
if (conditionFn(cellRect, boundary)) { | ||
@@ -271,5 +314,8 @@ findIndex = cells.indexOf(cell) | ||
function getColToolCellIndexesByBoundary (cells, boundary, conditionFn) { | ||
function getColToolCellIndexesByBoundary (cells, boundary, conditionFn, container) { | ||
return cells.reduce((findIndexes, cell) => { | ||
let cellRect = cell.getBoundingClientRect() | ||
let cellRect = getRelativeRect( | ||
cell.getBoundingClientRect(), | ||
container | ||
) | ||
if (conditionFn(cellRect, boundary)) { | ||
@@ -276,0 +322,0 @@ findIndexes.push(cells.indexOf(cell)) |
import Quill from 'quill' | ||
import { css } from '../utils' | ||
import { css, getRelativeRect } from '../utils' | ||
import { TableCell } from '../formats/table' | ||
@@ -50,3 +50,6 @@ | ||
const startTd = e.target.closest('td[data-row]') | ||
const startTdRect = startTd.getBoundingClientRect() | ||
const startTdRect = getRelativeRect( | ||
startTd.getBoundingClientRect(), | ||
this.quill.root.parentNode | ||
) | ||
this.dragging = true | ||
@@ -61,3 +64,6 @@ this.boundary = computeBoundaryFromRects(startTdRect, startTdRect) | ||
const endTd = e.target.closest('td[data-row]') | ||
const endTdRect = endTd.getBoundingClientRect() | ||
const endTdRect = getRelativeRect( | ||
endTd.getBoundingClientRect(), | ||
self.quill.root.parentNode | ||
) | ||
self.boundary = computeBoundaryFromRects(startTdRect, endTdRect) | ||
@@ -86,3 +92,6 @@ self.correctBoundary() | ||
tableCells.forEach(tableCell => { | ||
let { x, y, width, height } = tableCell.domNode.getBoundingClientRect() | ||
let { x, y, width, height } = getRelativeRect( | ||
tableCell.domNode.getBoundingClientRect(), | ||
this.quill.root.parentNode | ||
) | ||
let isCellIntersected = ( | ||
@@ -106,3 +115,6 @@ (x + ERROR_LIMIT >= this.boundary.x && x + ERROR_LIMIT <= this.boundary.x1) || | ||
return tableCells.reduce((selectedCells, tableCell) => { | ||
let { x, y, width, height } = tableCell.domNode.getBoundingClientRect() | ||
let { x, y, width, height } = getRelativeRect( | ||
tableCell.domNode.getBoundingClientRect(), | ||
this.quill.root.parentNode | ||
) | ||
let isCellIncluded = ( | ||
@@ -125,9 +137,8 @@ x + ERROR_LIMIT >= this.boundary.x && | ||
repositionHelpLines () { | ||
const containerRect = this.quill.root.parentNode.getBoundingClientRect() | ||
const tableViewScrollLeft = this.table.parentNode.scrollLeft | ||
css(this.left, { | ||
display: 'block', | ||
left: `${this.boundary.x - containerRect.x - 1 - tableViewScrollLeft}px`, | ||
top: `${this.boundary.y - containerRect.y}px`, | ||
height: `${this.boundary.y1 - this.boundary.y + 1}px`, | ||
left: `${this.boundary.x - tableViewScrollLeft - 1}px`, | ||
top: `${this.boundary.y}px`, | ||
height: `${this.boundary.height + 1}px`, | ||
width: '1px' | ||
@@ -138,5 +149,5 @@ }) | ||
display: 'block', | ||
left: `${this.boundary.x1 - containerRect.x - tableViewScrollLeft}px`, | ||
top: `${this.boundary.y - containerRect.y}px`, | ||
height: `${this.boundary.y1 - this.boundary.y + 1}px`, | ||
left: `${this.boundary.x1 - tableViewScrollLeft}px`, | ||
top: `${this.boundary.y}px`, | ||
height: `${this.boundary.height + 1}px`, | ||
width: '1px' | ||
@@ -147,5 +158,5 @@ }) | ||
display: 'block', | ||
left: `${this.boundary.x - containerRect.x - 1 - tableViewScrollLeft}px`, | ||
top: `${this.boundary.y - containerRect.y}px`, | ||
width: `${this.boundary.x1 - this.boundary.x + 1}px`, | ||
left: `${this.boundary.x - 1 - tableViewScrollLeft}px`, | ||
top: `${this.boundary.y}px`, | ||
width: `${this.boundary.width + 1}px`, | ||
height: '1px' | ||
@@ -156,5 +167,5 @@ }) | ||
display: 'block', | ||
left: `${this.boundary.x - containerRect.x - 1 - tableViewScrollLeft}px`, | ||
top: `${this.boundary.y1 - containerRect.y + 1}px`, | ||
width: `${this.boundary.x1 - this.boundary.x + 1}px`, | ||
left: `${this.boundary.x - 1 - tableViewScrollLeft}px`, | ||
top: `${this.boundary.y1 + 1}px`, | ||
width: `${this.boundary.width + 1}px`, | ||
height: '1px' | ||
@@ -167,5 +178,11 @@ }) | ||
refreshHelpLinesPosition () { | ||
const startRect = this.selectedTds[0].domNode.getBoundingClientRect() | ||
const endRect = this.selectedTds[this.selectedTds.length - 1].domNode.getBoundingClientRect() | ||
this.boundary = computeBoundaryFromRects(startTdRect, endRect) | ||
const startRect = getRelativeRect( | ||
this.selectedTds[0].domNode.getBoundingClientRect(), | ||
this.quill.root.parentNode | ||
) | ||
const endRect = getRelativeRect( | ||
this.selectedTds[this.selectedTds.length - 1].domNode.getBoundingClientRect(), | ||
this.quill.root.parentNode | ||
) | ||
this.boundary = computeBoundaryFromRects(startRect, endRect) | ||
this.repositionHelpLines() | ||
@@ -190,3 +207,6 @@ } | ||
setSelection (startRect, endRect) { | ||
this.boundary = computeBoundaryFromRects(startRect, endRect) | ||
this.boundary = computeBoundaryFromRects( | ||
getRelativeRect(startRect, this.quill.root.parentNode), | ||
getRelativeRect(endRect, this.quill.root.parentNode) | ||
) | ||
this.correctBoundary() | ||
@@ -193,0 +213,0 @@ this.selectedTds = this.computeSelectedTds() |
@@ -8,1 +8,20 @@ export function css (domNode, rules) { | ||
} | ||
/** | ||
* getRelativeRect | ||
* @param {Object} targetRect rect data for target element | ||
* @param {Element} container container element | ||
* @return {Object} an object with rect data | ||
*/ | ||
export function getRelativeRect (targetRect, container) { | ||
let containerRect = container.getBoundingClientRect() | ||
return { | ||
x: targetRect.x - containerRect.x - container.scrollLeft, | ||
y: targetRect.y - containerRect.y - container.scrollTop, | ||
x1: targetRect.x - containerRect.x - container.scrollLeft + targetRect.width, | ||
y1: targetRect.y - containerRect.y - container.scrollTop + targetRect.height, | ||
width: targetRect.width, | ||
height: targetRect.height | ||
} | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
175390
1918