quill-table-up 3.3.2 → 3.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +43 -1
- package/dist/index.d.ts +11 -29
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/index.umd.js +4 -4
- package/dist/index.umd.js.map +1 -1
- package/package.json +1 -1
- package/src/__tests__/unit/table-refresh-ui.test.ts +50 -0
- package/src/__tests__/unit/utils.ts +2 -2
- package/src/table-up.ts +62 -29
- package/src/utils/types.ts +4 -0
package/dist/index.umd.js
CHANGED
|
@@ -133,11 +133,11 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
133
133
|
<div class="${this.bem.be(`col-separator`)}" style="height: ${t.height+this.options.size-3}px"></div>
|
|
134
134
|
</div>`}}catch(e){s.e(e)}finally{s.f()}var d=document.createElement(`div`);d.classList.add(this.bem.be(`col`));var f=document.createElement(`div`);f.classList.add(this.bem.be(`col-wrapper`)),Object.assign(d.style,{transform:`translateY(-${this.options.size}px)`,maxWidth:`${i.width}px`,height:`${this.options.size}px`}),Object.assign(f.style,{width:`${t.width}px`}),f.innerHTML=o,d.appendChild(f),this.root.appendChild(d),d.scrollLeft=this.tableWrapperBlot.domNode.scrollLeft,this.colHeadWrapper=d,this.bindColEvents()}if(r.length>0){for(var p=``,m=0;m<r.length;m++){var h,g=m,_=r[m],v=_.domNode.getBoundingClientRect().height;if(_.children.length===1&&(((h=_.children.head)==null?void 0:h.emptyRow.length)||0)>0){for(var y=_.children.head.emptyRow.length,x=m+1;x<r.length&&x<=m+y;x++){var S=r[x];v+=S.domNode.getBoundingClientRect().height}m+=y}p+=`<div class="${this.bem.be(`row-header`)}" data-index="${g}" style="height: ${v}px">
|
|
135
135
|
<div class="${this.bem.be(`row-separator`)}" style="width: ${t.width+this.options.size-3}px"></div>
|
|
136
|
-
</div>`}var C=document.createElement(`div`);C.classList.add(this.bem.be(`row`));var w=document.createElement(`div`);w.classList.add(this.bem.be(`row-wrapper`)),Object.assign(C.style,{transform:`translateX(-${this.options.size}px)`,width:`${this.options.size}px`,maxHeight:`${i.height}px`}),Object.assign(w.style,{height:`${t.height}px`}),w.innerHTML=p,C.appendChild(w),this.root.appendChild(C),C.scrollTop=this.tableWrapperBlot.domNode.scrollTop,this.rowHeadWrapper=C,this.bindRowEvents()}var T=F(he(this.tableBlot,Br),1)[0],E=!T||(T==null?void 0:T.side)!==`top`;E?this.root.classList.remove(this.bem.is(`caption-bottom`)):this.root.classList.add(this.bem.is(`caption-bottom`));var D=-1*this.options.size,O=-1*this.options.size;Bi(this.tableBlot)?(this.root.classList.add(this.bem.is(`align-right`)),D=Math.min(i.width,t.width),O=Math.min(i.width,t.width)):this.root.classList.remove(this.bem.is(`align-right`)),this.corner&&Object.assign(this.corner.style,{transform:`translateY(${-1*this.options.size}px) translateX(${D}px)`,top:`${E?0:t.height+this.options.size}px`}),this.rowHeadWrapper&&Object.assign(this.rowHeadWrapper.style,{transform:`translateX(${O}px)`,maxHeight:`${i.height}px`}),this.colHeadWrapper&&Object.assign(this.colHeadWrapper.style,{top:`${E?0:t.height+this.options.size}px`,maxWidth:`${i.width}px`})}}}},{key:`show`,value:function(){var e=this;!this.table||!this.tableBlot||(this.root.classList.remove(this.bem.is(`hidden`)),this.resizeObserver=ar(function(){return e.update()},{ignoreFirstBind:!0}),this.resizeObserver.observe(this.table),this.update(),or.call(this,this.quill.root,function(){e.update()}))}},{key:`hide`,value:function(){this.root.classList.add(this.bem.is(`hidden`)),this.resizeObserver&&(this.resizeObserver.disconnect(),this.resizeObserver=void 0)}},{key:`destroy`,value:function(){I(n,`destroy`,this,3)([]),this.hide(),cr.call(this),this.quill.off(t.default.events.EDITOR_CHANGE,this.updateWhenTextChange);var e=b(this.scrollHandler),r;try{for(e.s();!(r=e.n()).done;){var i=F(r.value,2),a=i[0],o=i[1];a.removeEventListener(`scroll`,o)}}catch(t){e.e(t)}finally{e.f()}this.root.remove()}}])}(Wi);x(Ji,`moduleName`,`table-resize-box`);var Yi=function(e){function n(e,r){var i;return _(this,n),i=g(this,n,[e,r]),x(i,`tableModule`,void 0),x(i,`quill`,void 0),x(i,`colResizer`,void 0),x(i,`rowResizer`,void 0),x(i,`currentTableCell`,void 0),x(i,`tableCellBlot`,void 0),x(i,`bem`,H(`resize-line`)),x(i,`stopColDrag`,void 0),x(i,`stopRowDrag`,void 0),x(i,`scrollHandler`,[]),x(i,`updateWhenTextChange`,function(e){e===t.default.events.TEXT_CHANGE&&(i.table&&!i.quill.root.contains(i.table)?i.setSelectionTable(void 0):i.update())}),x(i,`pointermoveHandler`,function(e){if(!i.dragging){var n=i.tableModule.getModule(V.tableSelectionName);if(!(n!=null&&n.dragging)){var r=i.findTableCell(e);if(!r)return i.hide();var a=t.default.find(r);a&&i.currentTableCell!==r&&(i.show(),i.currentTableCell=r,i.tableCellBlot=a,i.tableBlot=U(a,R.tableMain),i.tableBlot.getCols().length>0&&i.updateColResizer(),i.updateRowResizer(),or.call(i,i.quill.root,function(){i.dragging||i.hideResizer()}))}}}),i.tableModule=e,i.quill=r,i.colResizer=i.tableModule.addContainer(i.bem.be(`col`)),i.rowResizer=i.tableModule.addContainer(i.bem.be(`row`)),i.quill.on(t.default.events.EDITOR_CHANGE,i.updateWhenTextChange),i}return w(n,e),y(n,[{key:`setSelectionTable`,value:function(e){this.table!==e&&(this.hide(),this.table=e,this.table&&this.show())}},{key:`findTableCell`,value:function(e){var t=b(e.composedPath()),n;try{for(t.s();!(n=t.n()).done;){var r=n.value;if(r instanceof HTMLElement&&[`TD`,`TH`].includes(r.tagName))return r;if(r===document.body)return null}}catch(e){t.e(e)}finally{t.f()}return null}},{key:`findDragColIndex`,value:function(e){var t=this;return this.tableCellBlot?e.findIndex(function(e){return e.colId===t.tableCellBlot.colId}):-1}},{key:`updateColResizer`,value:function(){var e=this;if(!(!this.tableBlot||!this.tableCellBlot||!this.colResizer)){this.colResizer.remove();var t=Z(this.tableBlot).rect;if(t){this.colResizer=this.tableModule.addContainer(this.bem.be(`col`));var n=this.tableCellBlot.domNode.getBoundingClientRect(),r=this.quill.root.getBoundingClientRect(),i=n.right-r.x;Bi(this.tableBlot)&&(i=n.left-r.x),Object.assign(this.colResizer.style,{top:`${t.y-r.y}px`,left:`${i}px`,height:`${t.height}px`});var a=er(this.colResizer,{axis:`x`,onStart:function(t,n){if(e.dragging=!0,e.calculateColDragRange(),e.dragXCommon.createBreak(),e.tableBlot){var r=e.tableBlot.domNode.parentElement.getBoundingClientRect(),i=Z(e.tableBlot).rect;if(i){e.dragXCommon.startValue=i.x;var a=e.quill.root.getBoundingClientRect();Object.assign(e.dragXCommon.dragBreak.style,{top:`${Math.max(r.y,i.y)-a.y}px`,left:`${n.clientX-a.x}px`,height:`${Math.min(r.height,i.height)}px`})}}},onMove:function(t){var n=t.position;if(e.dragXCommon.dragBreak){var r=e.dragXCommon.limitRange(e.tableBlot,n.x,!0),i=e.quill.root.getBoundingClientRect();e.dragXCommon.dragBreak.style.left=`${r-i.x}px`}},onEnd:function(t){var n=t.position;if(e.dragging=!1,e.colResizer){var r=e.dragXCommon.limitRange(e.tableBlot,n.x,!0),i=e.quill.root.getBoundingClientRect();e.colResizer.style.left=`${r-i.x}px`}e.updateTableCol(n.x),e.removeBreak()}}).stop;this.stopColDrag&&this.stopColDrag(),this.stopColDrag=a,this.colResizer.addEventListener(`dragstart`,function(e){return e.preventDefault()})}}}},{key:`findDragRowIndex`,value:function(e){if(!this.tableCellBlot)return-1;var t=this.tableCellBlot.parent;return t instanceof J?e.indexOf(t):-1}},{key:`updateRowResizer`,value:function(){var e=this;if(!(!this.tableBlot||!this.tableCellBlot||!this.rowResizer)){var t=this.tableCellBlot;this.rowResizer.remove();var n=Z(this.tableBlot).rect;if(n){this.rowResizer=this.tableModule.addContainer(this.bem.be(`row`));var r=t.domNode.getBoundingClientRect(),i=this.quill.root.getBoundingClientRect();Object.assign(this.rowResizer.style,{top:`${r.bottom-i.y}px`,left:`${n.x-i.x}px`,width:`${n.width}px`});var a=er(this.rowResizer,{axis:`y`,onStart:function(t,n){if(e.dragging=!0,e.calculateRowDragRange(),e.dragYCommon.createBreak(),e.tableBlot){var r=e.tableBlot.domNode.parentElement.getBoundingClientRect(),i=Z(e.tableBlot).rect;if(i){e.dragYCommon.startValue=i.y;var a=e.quill.root.getBoundingClientRect();Object.assign(e.dragYCommon.dragBreak.style,{top:`${n.clientY-a.y}px`,left:`${Math.max(r.x,i.x)-a.x}px`,width:`${Math.min(r.width,i.width)}px`})}}},onMove:function(t){var n=t.position;if(!(!e.dragYCommon.dragBreak||!e.table)){var r=e.dragYCommon.limitRange(e.tableBlot,n.y,!0),i=e.quill.root.getBoundingClientRect();e.dragYCommon.dragBreak.style.top=`${r-i.y}px`}},onEnd:function(t){var n=t.position;if(e.dragging=!1,e.rowResizer){var r=e.dragYCommon.limitRange(e.tableBlot,n.y,!0),i=e.quill.root.getBoundingClientRect();e.rowResizer.style.left=`${r-i.y}px`}e.updateTableRow(n.y),e.removeBreak()}}).stop;this.stopRowDrag&&this.stopRowDrag(),this.stopRowDrag=a,this.rowResizer.addEventListener(`dragstart`,function(e){return e.preventDefault()})}}}},{key:`show`,value:function(){!this.table||!this.rowResizer||!this.colResizer||(this.rowResizer.classList.remove(this.bem.is(`hidden`)),this.colResizer.classList.remove(this.bem.is(`hidden`)),this.table.addEventListener(`pointermove`,this.pointermoveHandler))}},{key:`hideResizer`,value:function(){!this.rowResizer||!this.colResizer||(this.rowResizer.classList.add(this.bem.is(`hidden`)),this.colResizer.classList.add(this.bem.is(`hidden`)))}},{key:`hide`,value:function(){this.currentTableCell=void 0,cr.call(this),this.hideResizer(),this.table&&this.table.removeEventListener(`pointermove`,this.pointermoveHandler)}},{key:`destroy`,value:function(){I(n,`destroy`,this,3)([]),this.colResizer&&(this.colResizer.remove(),this.colResizer=void 0),this.rowResizer&&(this.rowResizer.remove(),this.rowResizer=void 0),this.quill.off(t.default.events.EDITOR_CHANGE,this.updateWhenTextChange)}}])}(Wi);x(Yi,`moduleName`,`table-resize-line`);var Xi=function(e){function n(e,r,i){var a;return _(this,n),a=g(this,n,[e,r]),x(a,`tableModule`,void 0),x(a,`quill`,void 0),x(a,`scrollHandler`,[]),x(a,`tableMainBlot`,void 0),x(a,`tableWrapperBlot`,void 0),x(a,`bem`,H(`scale`)),x(a,`options`,void 0),x(a,`root`,void 0),x(a,`block`,void 0),x(a,`resizeobserver`,new ResizeObserver(function(){return a.update()})),x(a,`updateWhenTextChange`,function(e){e===t.default.events.TEXT_CHANGE&&(a.table&&!a.quill.root.contains(a.table)?a.setSelectionTable(void 0):a.update())}),a.tableModule=e,a.quill=r,a.options=a.resolveOptions(i),a.quill.on(t.default.events.EDITOR_CHANGE,a.updateWhenTextChange),a}return w(n,e),y(n,[{key:`resolveOptions`,value:function(e){return Object.assign({blockSize:12,offset:6},e)}},{key:`buildResizer`,value:function(){var e=this;if(!(!this.tableMainBlot||!this.tableWrapperBlot)){this.root=this.tableModule.addContainer(this.bem.b()),this.block=document.createElement(`div`),this.block.classList.add(this.bem.be(`block`)),Object.assign(this.block.style,{width:`${this.options.blockSize}px`,height:`${this.options.blockSize}px`}),this.root.appendChild(this.block);var t=[],n=[];er(this.block,{onStart:function(){e.tableMainBlot&&(t=e.tableMainBlot.getCols().map(function(e){return{blot:e,width:Math.floor(e.width)}}),n=e.tableMainBlot.getRows().map(function(e){return{blot:e,height:Math.floor(e.domNode.getBoundingClientRect().height)}}))},onMove:function(r){var i=r.movePosition;if(e.tableMainBlot){var a=Bi(e.tableMainBlot)?-1:1,o=i.x*a,s=i.y,c=Math.floor(o/t.length),l=Math.floor(s/n.length),u=b(t),d;try{for(u.s();!(d=u.n()).done;){var f=d.value,p=f.blot,m=f.width;p.width=Math.max(m+c,z.colMinWidthPx)}}catch(e){u.e(e)}finally{u.f()}var h=b(n),g;try{for(h.s();!(g=h.n()).done;){var _=g.value,v=_.blot,y=_.height;v.setHeight(`${Math.max(y+l,z.rowMinHeightPx)}px`)}}catch(e){h.e(e)}finally{h.f()}}},onEnd:function(){t=[],n=[]}}),this.block.addEventListener(`dragstart`,function(e){return e.preventDefault()})}}},{key:`update`,value:function(){if(!(!this.block||!this.root||!this.tableMainBlot||!this.tableWrapperBlot)){if(this.tableMainBlot.full){this.hide();return}var e=Z(this.tableMainBlot).rect;if(e){var t=this.tableWrapperBlot.domNode.getBoundingClientRect(),n=this.quill.root.getBoundingClientRect(),r=this.tableWrapperBlot.domNode,i=r.scrollTop,a=r.scrollLeft,o=this.options.blockSize*2+this.options.offset,s=Math.min(e.width,t.width)+o,c=Math.min(e.height,t.height)+o;Object.assign(this.root.style,{width:`${s}px`,height:`${c}px`,left:`${Math.max(e.x,t.x)-n.x-this.options.blockSize}px`,top:`${Math.max(e.y,t.y)-n.y-this.options.blockSize}px`});var l={left:`${e.width+o-a}px`,top:`${c-i}px`};Bi(this.tableMainBlot)?(this.root.classList.add(this.bem.is(`align-right`)),l.left=`${this.options.blockSize+-1*a}px`):this.root.classList.remove(this.bem.is(`align-right`)),Object.assign(this.block.style,l)}}}},{key:`show`,value:function(){var e=this;this.table&&(this.tableMainBlot=t.default.find(this.table),this.tableMainBlot&&!this.tableMainBlot.full&&(this.tableWrapperBlot=this.tableMainBlot.parent,this.resizeobserver.observe(this.tableMainBlot.domNode),or.call(this,this.quill.root,function(){return e.update()}),or.call(this,this.tableWrapperBlot.domNode,function(){return e.update()})),this.buildResizer())}},{key:`hide`,value:function(){this.tableMainBlot=void 0,this.tableWrapperBlot=void 0,this.root&&(this.root.remove(),this.root=void 0,this.block=void 0),cr.call(this)}},{key:`destroy`,value:function(){I(n,`destroy`,this,3)([]),this.hide(),this.quill.off(t.default.events.EDITOR_CHANGE,this.updateWhenTextChange),this.resizeobserver.disconnect()}}])}(qr);x(Xi,`moduleName`,`table-resize-scale`);var Zi={size:`height`,offset:`offsetHeight`,scrollDirection:`scrollTop`,scrollSize:`scrollHeight`,axis:`y`,direction:`top`,client:`clientY`},Qi={size:`width`,offset:`offsetWidth`,scrollDirection:`scrollLeft`,scrollSize:`scrollWidth`,axis:`x`,direction:`left`,client:`clientX`},$i=function(){function e(n,r,i){var a=this;_(this,e),x(this,`quill`,void 0),x(this,`table`,void 0),x(this,`options`,void 0),x(this,`minSize`,20),x(this,`gap`,4),x(this,`move`,0),x(this,`cursorDown`,!1),x(this,`cursorLeave`,!1),x(this,`ratioY`,1),x(this,`ratioX`,1),x(this,`sizeWidth`,``),x(this,`sizeHeight`,``),x(this,`size`,``),x(this,`bem`,H(`scrollbar`)),x(this,`tableMainBlot`,void 0),x(this,`ob`,void 0),x(this,`container`,void 0),x(this,`scrollbar`,void 0),x(this,`thumb`,document.createElement(`div`)),x(this,`scrollHandler`,[]),x(this,`propertyMap`,void 0),x(this,`thumbState`,{x:0,y:0}),x(this,`showScrollbar`,_r(function(){a.cursorLeave=!1,a.scrollbar.removeEventListener(`transitionend`,a.hideScrollbarTransitionend),a.scrollbar.style.display=a.size?`block`:`none`,requestAnimationFrame(function(){a.scrollbar.classList.remove(a.bem.is(`transparent`))})},200)),x(this,`hideScrollbar`,_r(function(){a.cursorLeave=!0,!a.cursorDown&&(a.scrollbar.removeEventListener(`transitionend`,a.hideScrollbarTransitionend),a.scrollbar.addEventListener(`transitionend`,a.hideScrollbarTransitionend,{once:!0}),a.scrollbar.classList.add(a.bem.is(`transparent`)))},200)),x(this,`hideScrollbarTransitionend`,function(){a.scrollbar.style.display=a.cursorDown&&a.size?`block`:`none`}),this.quill=n,this.table=r,this.options=i,this.tableMainBlot=t.default.find(this.table),this.container=r.parentElement,this.propertyMap=this.isVertical?Zi:Qi,this.calculateSize(),this.ob=new ResizeObserver(function(){return a.update()}),this.ob.observe(r),this.scrollbar=this.createScrollbar(),this.setScrollbarPosition(),or.call(this,this.quill.root,function(){return a.setScrollbarPosition()}),this.showScrollbar()}return y(e,[{key:`isVertical`,get:function(){return this.options.isVertical}},{key:`update`,value:function(){this.calculateSize(),this.setScrollbarPosition()}},{key:`setScrollbarPosition`,value:function(){var e=Z(this.tableMainBlot),t=e.rect,n=e.head,r=e.body,i=e.foot,a=n||r||i;if(!(!a||!t)){var o=this.quill.root,s=o.scrollLeft,c=o.scrollTop,l=o.offsetLeft,u=o.offsetTop,d=this.container,f=d.offsetLeft,p=d.offsetTop,m=a.domNode,h=m.offsetLeft,g=m.offsetTop,_=this.container.getBoundingClientRect(),v=_.width,y=_.height,b=f+h-l,S=p+g-u;this.isVertical?b+=Math.min(v,t.width):S+=Math.min(y,t.height),this.tableMainBlot&&this.tableMainBlot.align!==`left`&&(b+=this.table.offsetLeft-f),Object.assign(this.scrollbar.style,x(x({},this.propertyMap.size,`${this.isVertical?Math.min(y,t.height):v}px`),`transform`,`translate(${b-s}px, ${S-c}px)`)),this.containerScrollHandler(this.container)}}},{key:`calculateSize`,value:function(){var e=this.container.offsetHeight-this.gap,t=this.container.offsetWidth-this.gap,n=Math.pow(e,2)/this.container.scrollHeight,r=Math.pow(t,2)/this.container.scrollWidth,i=Math.max(n,this.minSize),a=Math.max(r,this.minSize);this.ratioY=n/(e-n)/(i/(e-i)),this.ratioX=r/(t-r)/(a/(t-a)),this.sizeWidth=a+this.gap<t?`${a}px`:``,this.sizeHeight=i+this.gap<e?`${i}px`:``,this.size=this.isVertical?this.sizeHeight:this.sizeWidth}},{key:`createScrollbar`,value:function(){var e=this,t=document.createElement(`div`);t.classList.add(this.bem.b(),this.isVertical?this.bem.is(`vertical`):this.bem.is(`horizontal`),this.bem.is(`transparent`)),Object.assign(t.style,{display:`none`}),this.thumb.classList.add(this.bem.be(`thumb`));var n=null,r=function(t){if(e.cursorDown!==!1){var n=e.thumbState[e.propertyMap.axis];if(n){var r=Math.pow(e.scrollbar[e.propertyMap.offset],2)/e.container[e.propertyMap.scrollSize]/(e.isVertical?e.ratioY:e.ratioX)/e.thumb[e.propertyMap.offset],i=((e.scrollbar.getBoundingClientRect()[e.propertyMap.direction]-t[e.propertyMap.client])*-1-(e.thumb[e.propertyMap.offset]-n))*100*r/e.scrollbar[e.propertyMap.offset];e.container[e.propertyMap.scrollDirection]=i*e.container[e.propertyMap.scrollSize]/100}}},i=function(){e.thumbState[e.propertyMap.axis]=0,e.cursorDown=!1,document.removeEventListener(`mousemove`,r),document.removeEventListener(`mouseup`,i),e.cursorLeave&&e.hideScrollbar(),document.onselectstart=n},a=function(t){t.stopImmediatePropagation(),e.cursorDown=!0,document.addEventListener(`mousemove`,r),document.addEventListener(`mouseup`,i),n=document.onselectstart,document.onselectstart=function(){return!1}};this.thumb.addEventListener(`mousedown`,function(t){var n;if(t.stopPropagation(),!(t.ctrlKey||[1,2].includes(t.button))){(n=window.getSelection())==null||n.removeAllRanges(),a(t);var r=t.currentTarget;r&&(e.thumbState[e.propertyMap.axis]=r[e.propertyMap.offset]-(t[e.propertyMap.client]-r.getBoundingClientRect()[e.propertyMap.direction]))}});for(var o=[this.table,t],s=0,c=o;s<c.length;s++){var l=c[s];l.addEventListener(`mouseenter`,this.showScrollbar),l.addEventListener(`mouseleave`,this.hideScrollbar)}return or.call(this,this.container,function(){e.containerScrollHandler(e.container)}),t.appendChild(this.thumb),t}},{key:`containerScrollHandler`,value:function(e){var t=e[this.propertyMap.offset]-this.gap;this.move=e[this.propertyMap.scrollDirection]*100/t*(this.isVertical?this.ratioY:this.ratioX),Object.assign(this.thumb.style,x(x({},this.propertyMap.size,this.size),`transform`,`translate${this.propertyMap.axis.toUpperCase()}(${this.move}%)`))}},{key:`destroy`,value:function(){this.ob.disconnect(),cr.call(this),this.table.removeEventListener(`mouseenter`,this.showScrollbar),this.table.removeEventListener(`mouseleave`,this.hideScrollbar)}}])}(),ea=function(e){function n(e,r,i){var a;_(this,n),a=g(this,n,[e,r]),x(a,`tableModule`,void 0),x(a,`quill`,void 0),x(a,`scrollbarContainer`,void 0),x(a,`scrollbar`,[]),x(a,`bem`,H(`scrollbar`)),x(a,`updateWhenTextChange`,function(e){e===t.default.events.TEXT_CHANGE&&(a.table&&!a.quill.root.contains(a.table)?a.setSelectionTable(void 0):a.update())}),a.tableModule=e,a.quill=r;var o=H(`scrollbar`);return a.quill.container.classList.add(o.bm(`virtual`)),a.scrollbarContainer=a.tableModule.addContainer(a.bem.be(`container`)),a.quill.on(t.default.events.EDITOR_CHANGE,a.updateWhenTextChange),a}return w(n,e),y(n,[{key:`hide`,value:function(){var e=b(this.scrollbar),t;try{for(e.s();!(t=e.n()).done;)t.value.destroy()}catch(t){e.e(t)}finally{e.f()}this.scrollbar=[],this.scrollbarContainer.innerHTML=``}},{key:`show`,value:function(){if(this.table){this.scrollbar=[new $i(this.quill,this.table,{isVertical:!0}),new $i(this.quill,this.table,{isVertical:!1})];var e=b(this.scrollbar),t;try{for(e.s();!(t=e.n()).done;){var n=t.value;this.scrollbarContainer.appendChild(n.scrollbar),n.showScrollbar()}}catch(t){e.e(t)}finally{e.f()}}}},{key:`update`,value:function(){if(this.table){this.scrollbar.length<=0&&this.show();var e=b(this.scrollbar),t;try{for(e.s();!(t=e.n()).done;){var n=t.value;n.calculateSize(),n.setScrollbarPosition()}}catch(t){e.e(t)}finally{e.f()}}else this.scrollbar.length>0&&this.hide()}},{key:`destroy`,value:function(){I(n,`destroy`,this,3)([]),this.hide(),this.scrollbarContainer.remove(),this.quill.off(t.default.events.TEXT_CHANGE,this.updateWhenTextChange)}}])}(qr);x(ea,`moduleName`,`table-scrollbar`);var ta=0,na=function(e){function n(e,r){var i,a=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};return _(this,n),i=g(this,n,[e,r]),x(i,`tableModule`,void 0),x(i,`quill`,void 0),x(i,`options`,void 0),x(i,`boundary`,null),x(i,`scrollRecordEls`,[]),x(i,`startScrollRecordPosition`,[]),x(i,`selectedTableScrollX`,0),x(i,`selectedTableScrollY`,0),x(i,`selectedEditorScrollX`,0),x(i,`selectedEditorScrollY`,0),x(i,`selectedTds`,[]),x(i,`cellSelectWrap`,void 0),x(i,`cellSelect`,void 0),x(i,`scrollHandler`,[]),x(i,`resizeObserver`,void 0),x(i,`isDisplaySelection`,!1),x(i,`bem`,H(`selection`)),x(i,`autoScroller`,void 0),x(i,`lastSelection`,{anchorNode:null,anchorOffset:0,focusNode:null,focusOffset:0}),x(i,`_dragging`,!1),x(i,`handlePaste`,function(e){if(!(!(document.activeElement&&i.quill.root.contains(document.activeElement))||i.quill.getSelection())){var t=e.clipboardData;if(t){e.preventDefault();var n=i.selectedTds;if(!(n.length<=0)){var r=t.getData(`text/html`),a=i.quill.clipboard.convert({html:r}).ops.filter(function(e){var t;return(t=e.attributes)==null?void 0:t[R.tableCellInner]});a.length!==0&&Xr({quill:i.quill,talbeModule:i.tableModule},n,a)}}}}),x(i,`keyboardHandler`,function(){var e=h(P().mark(function e(t){var n;return P().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(!t.ctrlKey){e.next=4;break}n=t.key,e.next=n===`c`||n===`x`?1:3;break;case 1:return e.next=2,Ni(i.tableModule,i.selectedTds,t.key===`x`);case 2:return e.abrupt(`continue`,3);case 3:e.next=5;break;case 4:(t.key===`Backspace`||t.key===`Delete`)&&i.removeCellBySelectedTds();case 5:case`end`:return e.stop()}},e)}));return function(t){return e.apply(this,arguments)}}()),x(i,`updateWhenTextChange`,function(e){e===t.default.events.TEXT_CHANGE&&(i.table&&!i.quill.root.contains(i.table)?i.setSelectionTable(void 0):i.updateAfterEvent())}),x(i,`updateAfterEvent`,function(){var e=b(i.selectedTds),t;try{for(e.s();!(t=e.n()).done;)if(!t.value.domNode.isConnected){i.selectedTds=[];break}}catch(t){e.e(t)}finally{e.f()}i.updateWithSelectedTds()}),x(i,`quillSelectionChangeHandler`,function(e,n,r){if(r!==t.default.sources.API&&e&&!i.quill.composition.isComposing&&i.selectedTds.length>0){var a=i.quill.getFormat(e),o=F(i.quill.getLine(e.index),1)[0],s=!!a[R.tableCellInner]&&!!o,c=o&&i.selectedTds.some(function(e){return e.domNode.contains(o.domNode)});if(s&&!c)try{var l=U(o,R.tableCellInner);i.setSelectedTds([l]),i.updateWithSelectedTds()}catch(e){}else s&&c||i.hide()}}),x(i,`selectionChangeHandler`,function(){var e=window.getSelection();if(e){var n=e.anchorNode,r=e.focusNode,a=e.anchorOffset,o=e.focusOffset;if(!(!n||!r)){var s=t.default.find(n),c=t.default.find(r);if(!(!s||!c||s.scroll!==i.quill.scroll||c.scroll!==i.quill.scroll)){var l=me(s),u=me(c),d=l.has(R.tableColgroup),f=u.has(R.tableColgroup);if(d||f){var p=n,m=a,h=r,g=o;if(d){var _=l.get(R.tableWrapper).descendants(q);_.length>0&&(p=_[0].domNode,m=0)}if(f){var v=u.get(R.tableWrapper).descendants(q);v.length>0&&(h=v[0].domNode,g=0)}i.setSelectionData(e,{anchorNode:p,anchorOffset:m,focusNode:h,focusOffset:g});return}var y=l.has(R.tableCellInner),b=u.has(R.tableCellInner),x=y&&b;if(x){var S=l.get(R.tableCellInner),C=u.get(R.tableCellInner);x&&(x=S!==C)}if(y&&b&&x||!y&&b||!b&&y){i.setSelectionData(e,i.lastSelection),i.selectedTds.length>0&&i.hide();return}i.lastSelection={anchorNode:n,anchorOffset:a,focusNode:r,focusOffset:o}}}}}),i.tableModule=e,i.quill=r,i.options=i.resolveOptions(a),i.scrollRecordEls=[i.quill.root,document.documentElement],i.cellSelectWrap=e.addContainer(i.bem.b()),i.cellSelect=i.helpLinesInitial(),i.resizeObserver=ar(i.updateAfterEvent,{ignoreFirstBind:!0}),i.resizeObserver.observe(i.quill.root),document.addEventListener(`paste`,i.handlePaste),document.addEventListener(`selectionchange`,i.selectionChangeHandler),i.quill.on(B.AFTER_TABLE_RESIZE,i.updateAfterEvent),i.quill.on(t.default.events.SELECTION_CHANGE,i.quillSelectionChangeHandler),i.quill.on(t.default.events.EDITOR_CHANGE,i.updateWhenTextChange),i.autoScroller=new dr(50,40),i.hide(),i}return w(n,e),y(n,[{key:`dragging`,get:function(){return this._dragging},set:function(e){this._dragging!==e&&(this._dragging=e,this.quill.emitter.emit(e?B.TABLE_SELECTION_DRAG_START:B.TABLE_SELECTION_DRAG_END,this))}},{key:`removeCellBySelectedTds`,value:function(){var e=this.quill.getSelection(),n=document.activeElement;if(!(e||!this.quill.root.contains(n))){if(this.table){var r=t.default.find(this.table),i=r.descendants(q);if(this.selectedTds.length===i.length){r.remove();return}}var a=b(this.selectedTds),o;try{for(a.s();!(o=a.n()).done;){var s=o.value,c=s.clone();c.appendChild(s.scroll.create(`block`)),s.parent.insertBefore(c,s),s.remove()}}catch(e){a.e(e)}finally{a.f()}}}},{key:`setSelectedTds`,value:function(e){var t=new Set(this.selectedTds),n=this.selectedTds.length===e.length&&e.every(function(e){return t.has(e)});this.selectedTds=e,n||this.quill.emitter.emit(B.TABLE_SELECTION_CHANGE,this,this.selectedTds)}},{key:`setSelectionData`,value:function(e,t){var n=t.anchorNode,r=t.anchorOffset,i=t.focusNode,a=t.focusOffset;if(!(!n||!i)){var o=document.createRange(),s=this.selectionDirectionUp(t);s?(o.setStart(n,r),o.setEnd(n,r)):(o.setStart(n,r),o.setEnd(i,a)),e.removeAllRanges(),e.addRange(o),s&&e.extend(i,a)}}},{key:`selectionDirectionUp`,value:function(e){var t=e.anchorNode,n=e.anchorOffset,r=e.focusNode,i=e.focusOffset;if(!t||!r)return!1;if(t===r)return n>i;var a=t.compareDocumentPosition(r);return a&Node.DOCUMENT_POSITION_CONTAINS||a&Node.DOCUMENT_POSITION_CONTAINED_BY?(a&Node.DOCUMENT_POSITION_FOLLOWING)!==0:(a&Node.DOCUMENT_POSITION_PRECEDING)!==0}},{key:`resolveOptions`,value:function(e){return Object.assign({selectColor:`#0589f340`},e)}},{key:`helpLinesInitial`,value:function(){this.cellSelectWrap.style.setProperty(`--select-color`,this.options.selectColor);var e=document.createElement(`div`);return e.classList.add(this.bem.be(`line`)),this.cellSelectWrap.appendChild(e),e}},{key:`computeSelectedTds`,value:function(e,n){if(!this.table)return[];var r=t.default.find(this.table);if(!r)return[];var i=new Set(r.descendants(Y).map(function(e,t){return e.index=t,e})),a=this.getScrollPositionDiff(),o=Z(r).rect;if(!o)return[];for(var s=e.x+a.x,c=e.y+a.y,l={x:Math.max(o.left,Math.min(n.x,s)),y:Math.max(o.top,Math.min(n.y,c)),x1:Math.min(o.right,Math.max(n.x,s)),y1:Math.min(o.bottom,Math.max(n.y,c))},u=new Set,d=!0;d;){d=!1;var f=b(i),p;try{for(f.s();!(p=f.n()).done;){var m=p.value;m.__rect||(m.__rect=m.domNode.getBoundingClientRect());var h=m.__rect,g=h.x,_=h.y,v=h.right,y=h.bottom;if(tr({x:Math.floor(l.x),y:Math.floor(l.y),x1:Math.floor(l.x1),y1:Math.floor(l.y1)},{x:Math.floor(g),y:Math.floor(_),x1:Math.floor(v),y1:Math.floor(y)},ta,u.size===0)){u.add(m),i.delete(m),l={x:Math.min(l.x,g),y:Math.min(l.y,_),x1:Math.max(l.x1,v),y1:Math.max(l.y1,y)},d=!0;break}}}catch(e){f.e(e)}finally{f.f()}}for(var x=0,S=[].concat(L(u),L(i));x<S.length;x++){var C=S[x];delete C.__rect}return this.boundary=nr(j(j({},l),{},{width:l.x1-l.x,height:l.y1-l.y}),this.quill.root),Array.from(u).toSorted(function(e,t){return e.index-t.index}).map(function(e){return delete e.index,e.getCellInner()})}},{key:`getScrollPositionDiff`,value:function(){var e=this,t=this.getTableViewScroll(),n=t.x,r=t.y,i=lr(this.quill.root),a=i.x,o=i.y;return this.selectedTableScrollX=n,this.selectedTableScrollY=r,this.selectedEditorScrollX=a,this.selectedEditorScrollY=o,this.startScrollRecordPosition.reduce(function(t,n,r){var i=n.x,a=n.y,o=lr(e.scrollRecordEls[r]),s=o.x,c=o.y;return t.x+=i-s,t.y+=a-c,t},{x:0,y:0})}},{key:`recordScrollPosition`,value:function(){this.clearRecordScrollPosition();var e=b(this.scrollRecordEls),t;try{for(e.s();!(t=e.n()).done;){var n=t.value;this.startScrollRecordPosition.push(lr(n))}}catch(t){e.e(t)}finally{e.f()}}},{key:`clearRecordScrollPosition`,value:function(){this.startScrollRecordPosition=[]}},{key:`tableSelectHandler`,value:function(e){var n=this,r=e.button,i=e.target,a=e.clientX,o=e.clientY,s=i.closest(`table`),c=i.closest(`caption`);if(!(r!==0||!s||c)){this.setSelectionTable(s);var l=s.dataset.tableId,u={x:a,y:o};this.recordScrollPosition(),this.setSelectedTds(this.computeSelectedTds(u,u)),this.show();var d=function(e){n.dragging=!0;var t=e.button,r=e.target,i=e.clientX,a=e.clientY,o=r.closest(`.ql-table`),s=r.closest(`caption`);if(!(t!==0||s||!o||o.dataset.tableId!==l)){var c={x:i,y:a};n.setSelectedTds(n.computeSelectedTds(u,c)),n.selectedTds.length>1&&n.quill.blur(),n.update(),n.autoScroller.updateMousePosition(i,a)}},f=function(){document.body.removeEventListener(`mousemove`,d,!1),document.body.removeEventListener(`mouseup`,f,!1),n.autoScroller.stop(),n.dragging=!1,n.clearRecordScrollPosition()};document.body.addEventListener(`mousemove`,d,!1),document.body.addEventListener(`mouseup`,f,!1);var p=t.default.find(s);if(p){var m=p.parent.domNode;this.autoScroller.updateMousePosition(a,o),this.autoScroller.start(m)}}}},{key:`updateWithSelectedTds`,value:function(){if(this.selectedTds.length<=0){this.hide();return}var e={x:1/0,y:1/0},t={x:-1/0,y:-1/0},n=b(this.selectedTds),r;try{for(n.s();!(r=n.n()).done;){var i=r.value.domNode.getBoundingClientRect();e.x=Math.min(e.x,i.left),e.y=Math.min(e.y,i.top),t.x=Math.max(t.x,i.right),t.y=Math.max(t.y,i.bottom)}}catch(e){n.e(e)}finally{n.f()}this.setSelectedTds(this.computeSelectedTds(e,t)),this.selectedTds.length>0?this.update():this.hide()}},{key:`update`,value:function(){if(!this.table){this.hide();return}if(!(this.selectedTds.length===0||!this.boundary)){var e=lr(this.quill.root),t=e.x,n=e.y,r=this.getTableViewScroll(),i=r.x,a=r.y,o=this.table.parentElement.getBoundingClientRect(),s=this.quill.root.getBoundingClientRect(),c=o.x-s.x,l=o.y-s.y;Object.assign(this.cellSelect.style,{left:`${this.selectedEditorScrollX*2-t+this.boundary.x+this.selectedTableScrollX-i-c}px`,top:`${this.selectedEditorScrollY*2-n+this.boundary.y+this.selectedTableScrollY-a-l}px`,width:`${this.boundary.width}px`,height:`${this.boundary.height}px`}),Object.assign(this.cellSelectWrap.style,{left:`${c}px`,top:`${l}px`,width:`${o.width}px`,height:`${o.height}px`}),this.quill.emitter.emit(B.TABLE_SELECTION_DISPLAY_CHANGE,this)}}},{key:`getTableViewScroll`,value:function(){return this.table?lr(this.table.parentElement):{x:0,y:0}}},{key:`setSelectionTable`,value:function(e){this.table!==e&&(this.table=e,this.table?this.scrollRecordEls.push(this.table.parentElement):this.scrollRecordEls.pop())}},{key:`showDisplay`,value:function(){Object.assign(this.cellSelectWrap.style,{display:`block`}),this.isDisplaySelection=!0,this.table&&this.resizeObserver.observe(this.table)}},{key:`show`,value:function(){var e=this;this.table&&(cr.call(this),this.showDisplay(),this.update(),this.quill.root.addEventListener(`keydown`,this.keyboardHandler),or.call(this,this.quill.root,function(){e.update()}),or.call(this,this.table.parentElement,function(){e.update()}))}},{key:`hideDisplay`,value:function(){Object.assign(this.cellSelectWrap.style,{display:`none`}),this.isDisplaySelection=!1,this.table&&this.resizeObserver.unobserve(this.table)}},{key:`hide`,value:function(){cr.call(this),this.quill.root.removeEventListener(`keydown`,this.keyboardHandler),this.hideDisplay(),this.boundary=null,this.setSelectedTds([]),this.setSelectionTable(void 0)}},{key:`destroy`,value:function(){I(n,`destroy`,this,3)([]),this.resizeObserver.disconnect(),this.hide(),this.cellSelectWrap.remove(),cr.call(this),document.removeEventListener(`paste`,this.handlePaste),document.removeEventListener(`selectionchange`,this.selectionChangeHandler),this.quill.off(B.AFTER_TABLE_RESIZE,this.updateAfterEvent),this.quill.off(t.default.events.EDITOR_CHANGE,this.updateWhenTextChange),this.quill.off(t.default.events.SELECTION_CHANGE,this.quillSelectionChangeHandler)}}])}(qr);x(na,`moduleName`,V.tableSelectionName);var ra=[`attributes`],ia=[`style`],aa=[`emptyRow`],oa=t.default.import(`parchment`),sa=t.default.import(`delta`),ca=t.default.import(`ui/icons`),la=t.default.import(`blots/break`),ua=t.default.import(`blots/block`),da=t.default.import(`blots/block/embed`);function fa(e,t){var n={tableId:t.tableId,rowId:t.rowId,colId:t.colId,colspan:1,rowspan:1},r=e.create(R.tableCell,n),i=e.create(R.tableCellInner,n),a=e.create(`block`);return a.appendChild(e.create(`break`)),i.appendChild(a),r.appendChild(i),r}function pa(e){ue.delete(R.tableCellInner),Object.assign(R,e.blotName||{}),Object.assign(z,e.tableUpSize||{}),Object.assign(B,e.tableUpEvent||{}),Object.assign(V,e.tableUpInternal||{}),ga.moduleName=V.moduleName,ga.toolName=R.tableWrapper,K.blotName=R.container,Br.blotName=R.tableCaption,Kr.blotName=R.tableWrapper,X.blotName=R.tableMain,Hr.blotName=R.tableColgroup,Vr.blotName=R.tableCol,Wr.blotName=R.tableHead,jr.blotName=R.tableBody,Ur.blotName=R.tableFoot,J.blotName=R.tableRow,Y.blotName=R.tableCell,q.blotName=R.tableCellInner,ue.add(R.tableCellInner)}function ma(e,n){return Ue({onSelect:function(r,i){e.insertTable(r,i,t.default.sources.USER),n&&n.close()},customBtn:e.options.customBtn,texts:e.options.texts})}function ha(e){return{bindInHead:!1,key:e?`ArrowUp`:`ArrowDown`,collapsed:!0,format:[R.tableCellInner],handler:function(n,r){var i=e?`prev`:`next`,a=e?`tail`:`head`;if(r.line[i])return!0;var o=this.quill.selection.getBounds(n.index),s=r.line.domNode.getBoundingClientRect();if(!o||!s)return!0;if(e){if(o.top-s.top>3)return!0}else if(s.bottom-o.bottom>3)return!0;var c,l,u,d;try{var f=F(pe(r.line,[R.tableWrapper,R.tableMain,R.tableRow,R.tableCell]),4);c=f[0],l=f[1],u=f[2],d=f[3]}catch(e){return!0}var p=l.getColIds(),m=c.descendants(Br,0)[0],h;if(m){var g=window.getComputedStyle(m.domNode);h=i===`next`&&g.captionSide===`bottom`?m:i===`next`?c.next:m}else h=c[i];if(r.line[i]||!h)return!0;var _=u[i];if(_){var v=p.indexOf(d.colId),y=_.getCellByColId(p[v],i);if(!y)return!0;var b=y.children[a];b.children&&(b=b.children[a]);var x=b.offset(this.quill.scroll)+Math.min(r.offset,b.length()-1);this.quill.setSelection(x,0,t.default.sources.USER)}else{var S=h.offset(this.quill.scroll)+(e?h.length()-1:0);this.quill.setSelection(S,0,t.default.sources.USER)}return!1}}}var ga=function(){function e(t,n){var r=this;_(this,e),x(this,`quill`,void 0),x(this,`options`,void 0),x(this,`toolBox`,void 0),x(this,`fixTableByLisenter`,_r(this.balanceTables,100)),x(this,`selector`,void 0),x(this,`resizeOb`,void 0),x(this,`editableObserver`,void 0),x(this,`modules`,{}),this.quill=t,this.options=this.resolveOptions(n||{}),this.toolBox=this.initialContainer();var i=this.quill.getModule(`toolbar`);if(i&&this.quill.theme.pickers){var a=F((i.controls||[]).find(function(e){return F(e,1)[0]===r.statics.toolName})||[],2)[1];if((a==null?void 0:a.tagName.toLocaleLowerCase())===`select`){var o=this.quill.theme.pickers.find(function(e){return e.select===a});o&&(o.label.innerHTML=this.options.icon,this.buildCustomSelect(this.options.customSelect,o),o.label.addEventListener(`mousedown`,function(){if(!(!r.selector||!o))if(ir(r.selector.getBoundingClientRect()).leftLimited){var e=o.label.getBoundingClientRect();Object.assign(o.options.style,{transform:`translateX(calc(-100% + ${e.width}px))`})}else Object.assign(o.options.style,{transform:void 0})}))}}for(var s=this.quill.getModule(`keyboard`),c=0,l=Object.values(e.keyboradHandler);c<l.length;c++){var u=l[c];u.bindInHead?s.bindings[u.key].unshift(u):s.addBinding(u.key,u)}this.initModules(),this.listenEditableChange(),this.quillHack(),this.listenBalanceCells()}return y(e,[{key:`statics`,get:function(){return this.constructor}},{key:`initialContainer`,value:function(){var e=this,t=H(`toolbox`),n=this.quill.addContainer(t.b());return this.resizeOb=new ResizeObserver(function(){var t=e.quill.root.getBoundingClientRect(),r=e.quill.root,i=r.offsetLeft,a=r.offsetTop;Object.assign(n.style,{top:`${a}px`,left:`${i}px`,width:`${t.width}px`,height:`${t.height}px`})}),this.resizeOb.observe(this.quill.root),n}},{key:`addContainer`,value:function(e){if(Oe(e)){var t=document.createElement(`div`),n=b(e.split(` `)),r;try{for(n.s();!(r=n.n()).done;){var i=r.value;t.classList.add(i)}}catch(e){n.e(e)}finally{n.f()}return this.toolBox.appendChild(t),t}else return this.toolBox.appendChild(e),e}},{key:`resolveOptions`,value:function(e){return Object.assign({customBtn:!1,texts:this.resolveTexts(e.texts||{}),full:!1,fullSwitch:!0,icon:ca.table,autoMergeCell:!0,modules:[]},e)}},{key:`resolveTexts`,value:function(e){return Object.assign({fullCheckboxText:`Insert full width table`,customBtnText:`Custom`,confirmText:`Confirm`,cancelText:`Cancel`,rowText:`Row`,colText:`Column`,notPositiveNumberError:`Please enter a positive integer`,custom:`Custom`,clear:`Clear`,transparent:`Transparent`,perWidthInsufficient:`The percentage width is insufficient. To complete the operation, the table needs to be converted to a fixed width. Do you want to continue?`,CopyCell:`Copy cell`,CutCell:`Cut cell`,InsertTop:`Insert row above`,InsertRight:`Insert column right`,InsertBottom:`Insert row below`,InsertLeft:`Insert column Left`,MergeCell:`Merge Cell`,SplitCell:`Split Cell`,DeleteRow:`Delete Row`,DeleteColumn:`Delete Column`,DeleteTable:`Delete table`,BackgroundColor:`Set background color`,BorderColor:`Set border color`},e)}},{key:`initModules`,value:function(){if(this.quill.isEnabled()){var e=b(this.options.modules),t;try{for(e.s();!(t=e.n()).done;){var n=t.value;this.modules[n.module.moduleName]=new n.module(this,this.quill,n.options)}}catch(t){e.e(t)}finally{e.f()}}}},{key:`listenEditableChange`,value:function(){var e=this;this.editableObserver=new MutationObserver(function(t){var n=b(t),r;try{for(n.s();!(r=n.n()).done;){var i=r.value;if(i.type===`attributes`&&i.attributeName===`contenteditable`){e.quill.root.getAttribute(`contenteditable`)===`false`?e.destroyModules():e.initModules();break}}}catch(e){n.e(e)}finally{n.f()}}),this.editableObserver.observe(this.quill.root,{attributes:!0,attributeFilter:[`contenteditable`]})}},{key:`destroyModules`,value:function(){for(var e=0,t=Object.entries(this.modules);e<t.length;e++){var n=F(t[e],2),r=n[0],i=n[1];if(i&&typeof i.destroy==`function`)try{i.destroy()}catch(e){console.warn(`Failed to destroy module ${r}:`,e)}}this.modules={}}},{key:`getModule`,value:function(e){return this.modules[e]}},{key:`quillHack`,value:function(){var e=this,n=this.quill.getSemanticHTML;this.quill.getSemanticHTML=function(){for(var r=arguments.length>0&&arguments[0]!==void 0?arguments[0]:0,i=arguments.length>1?arguments[1]:void 0,a=n.call(e.quill,r,i),o=t.default.import(`formats/${R.tableWrapper}`),s=new DOMParser().parseFromString(a,`text/html`),c=0,l=Array.from(s.querySelectorAll(`.${o.className} caption[contenteditable], .${o.className} .${Y.className} > [contenteditable]`));c<l.length;c++)l[c].removeAttribute(`contenteditable`);return s.body.innerHTML};var r=this.quill.format;this.quill.format=function(e,n){var i=arguments.length>2&&arguments[2]!==void 0?arguments[2]:t.default.sources.API;if(!(this.scroll.query(e).prototype instanceof oa.EmbedBlot)){var a=this.getModule(V.moduleName),o=this.getSelection(!0),s=this.getFormat(o),c=a.getModule(V.tableSelectionName);if(!s[R.tableCellInner]||o.length>0||a&&c&&c.selectedTds.length<=1)return r.call(this,e,n,i);if(a&&c&&c.selectedTds.length>0){var l=c.selectedTds,u=!1,d=[],f=b(l),p;try{for(f.s();!(p=f.n()).done;){var m=p.value,h=m.offset(this.scroll),g=m.length();d.push({index:h,length:g}),this.getFormat(h,g)[e]!==n&&(u=!0)}}catch(e){f.e(e)}finally{f.f()}var _=u?n:!1,v=new sa,y=b(d.entries()),S;try{for(y.s();!(S=y.n()).done;){var C=F(S.value,2),w=C[0],T=C[1],E=T.index,D=T.length,O=w===0?0:d[w-1].index+d[w-1].length;v.retain(E-O).retain(D,x({},e,_))}}catch(e){y.e(e)}finally{y.f()}var k=this.updateContents(v,i);return this.blur(),k}}return r.call(this,e,n,i)};var i=this.quill.theme.modules.toolbar;if(i){var a,o=(a=i.handlers)==null?void 0:a.clean;if(o){var s=function(t,n){var r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:function(){return``},i=e.quill.getText(t,n),a=F(e.quill.getLine(t+n),2),o=a[0],s=a[1],c=0,l=new sa;o!=null&&(c=o.length()-s,l=o.delta().slice(s,s+c-1).insert(`
|
|
137
|
-
`));var u=e.quill.getContents(t,n+c),d=u.diff(new
|
|
136
|
+
</div>`}var C=document.createElement(`div`);C.classList.add(this.bem.be(`row`));var w=document.createElement(`div`);w.classList.add(this.bem.be(`row-wrapper`)),Object.assign(C.style,{transform:`translateX(-${this.options.size}px)`,width:`${this.options.size}px`,maxHeight:`${i.height}px`}),Object.assign(w.style,{height:`${t.height}px`}),w.innerHTML=p,C.appendChild(w),this.root.appendChild(C),C.scrollTop=this.tableWrapperBlot.domNode.scrollTop,this.rowHeadWrapper=C,this.bindRowEvents()}var T=F(he(this.tableBlot,Br),1)[0],E=!T||(T==null?void 0:T.side)!==`top`;E?this.root.classList.remove(this.bem.is(`caption-bottom`)):this.root.classList.add(this.bem.is(`caption-bottom`));var D=-1*this.options.size,O=-1*this.options.size;Bi(this.tableBlot)?(this.root.classList.add(this.bem.is(`align-right`)),D=Math.min(i.width,t.width),O=Math.min(i.width,t.width)):this.root.classList.remove(this.bem.is(`align-right`)),this.corner&&Object.assign(this.corner.style,{transform:`translateY(${-1*this.options.size}px) translateX(${D}px)`,top:`${E?0:t.height+this.options.size}px`}),this.rowHeadWrapper&&Object.assign(this.rowHeadWrapper.style,{transform:`translateX(${O}px)`,maxHeight:`${i.height}px`}),this.colHeadWrapper&&Object.assign(this.colHeadWrapper.style,{top:`${E?0:t.height+this.options.size}px`,maxWidth:`${i.width}px`})}}}},{key:`show`,value:function(){var e=this;!this.table||!this.tableBlot||(this.root.classList.remove(this.bem.is(`hidden`)),this.resizeObserver=ar(function(){return e.update()},{ignoreFirstBind:!0}),this.resizeObserver.observe(this.table),this.update(),or.call(this,this.quill.root,function(){e.update()}))}},{key:`hide`,value:function(){this.root.classList.add(this.bem.is(`hidden`)),this.resizeObserver&&(this.resizeObserver.disconnect(),this.resizeObserver=void 0)}},{key:`destroy`,value:function(){I(n,`destroy`,this,3)([]),this.hide(),cr.call(this),this.quill.off(t.default.events.EDITOR_CHANGE,this.updateWhenTextChange);var e=b(this.scrollHandler),r;try{for(e.s();!(r=e.n()).done;){var i=F(r.value,2),a=i[0],o=i[1];a.removeEventListener(`scroll`,o)}}catch(t){e.e(t)}finally{e.f()}this.root.remove()}}])}(Wi);x(Ji,`moduleName`,`table-resize-box`);var Yi=function(e){function n(e,r){var i;return _(this,n),i=g(this,n,[e,r]),x(i,`tableModule`,void 0),x(i,`quill`,void 0),x(i,`colResizer`,void 0),x(i,`rowResizer`,void 0),x(i,`currentTableCell`,void 0),x(i,`tableCellBlot`,void 0),x(i,`bem`,H(`resize-line`)),x(i,`stopColDrag`,void 0),x(i,`stopRowDrag`,void 0),x(i,`scrollHandler`,[]),x(i,`updateWhenTextChange`,function(e){e===t.default.events.TEXT_CHANGE&&(i.table&&!i.quill.root.contains(i.table)?i.setSelectionTable(void 0):i.update())}),x(i,`pointermoveHandler`,function(e){if(!i.dragging){var n=i.tableModule.getModule(V.tableSelectionName);if(!(n!=null&&n.dragging)){var r=i.findTableCell(e);if(!r)return i.hide();var a=t.default.find(r);a&&i.currentTableCell!==r&&(i.show(),i.currentTableCell=r,i.tableCellBlot=a,i.tableBlot=U(a,R.tableMain),i.tableBlot.getCols().length>0&&i.updateColResizer(),i.updateRowResizer(),or.call(i,i.quill.root,function(){i.dragging||i.hideResizer()}))}}}),i.tableModule=e,i.quill=r,i.colResizer=i.tableModule.addContainer(i.bem.be(`col`)),i.rowResizer=i.tableModule.addContainer(i.bem.be(`row`)),i.quill.on(t.default.events.EDITOR_CHANGE,i.updateWhenTextChange),i}return w(n,e),y(n,[{key:`setSelectionTable`,value:function(e){this.table!==e&&(this.hide(),this.table=e,this.table&&this.show())}},{key:`findTableCell`,value:function(e){var t=b(e.composedPath()),n;try{for(t.s();!(n=t.n()).done;){var r=n.value;if(r instanceof HTMLElement&&[`TD`,`TH`].includes(r.tagName))return r;if(r===document.body)return null}}catch(e){t.e(e)}finally{t.f()}return null}},{key:`findDragColIndex`,value:function(e){var t=this;return this.tableCellBlot?e.findIndex(function(e){return e.colId===t.tableCellBlot.colId}):-1}},{key:`updateColResizer`,value:function(){var e=this;if(!(!this.tableBlot||!this.tableCellBlot||!this.colResizer)){this.colResizer.remove();var t=Z(this.tableBlot).rect;if(t){this.colResizer=this.tableModule.addContainer(this.bem.be(`col`));var n=this.tableCellBlot.domNode.getBoundingClientRect(),r=this.quill.root.getBoundingClientRect(),i=n.right-r.x;Bi(this.tableBlot)&&(i=n.left-r.x),Object.assign(this.colResizer.style,{top:`${t.y-r.y}px`,left:`${i}px`,height:`${t.height}px`});var a=er(this.colResizer,{axis:`x`,onStart:function(t,n){if(e.dragging=!0,e.calculateColDragRange(),e.dragXCommon.createBreak(),e.tableBlot){var r=e.tableBlot.domNode.parentElement.getBoundingClientRect(),i=Z(e.tableBlot).rect;if(i){e.dragXCommon.startValue=i.x;var a=e.quill.root.getBoundingClientRect();Object.assign(e.dragXCommon.dragBreak.style,{top:`${Math.max(r.y,i.y)-a.y}px`,left:`${n.clientX-a.x}px`,height:`${Math.min(r.height,i.height)}px`})}}},onMove:function(t){var n=t.position;if(e.dragXCommon.dragBreak){var r=e.dragXCommon.limitRange(e.tableBlot,n.x,!0),i=e.quill.root.getBoundingClientRect();e.dragXCommon.dragBreak.style.left=`${r-i.x}px`}},onEnd:function(t){var n=t.position;if(e.dragging=!1,e.colResizer){var r=e.dragXCommon.limitRange(e.tableBlot,n.x,!0),i=e.quill.root.getBoundingClientRect();e.colResizer.style.left=`${r-i.x}px`}e.updateTableCol(n.x),e.removeBreak()}}).stop;this.stopColDrag&&this.stopColDrag(),this.stopColDrag=a,this.colResizer.addEventListener(`dragstart`,function(e){return e.preventDefault()})}}}},{key:`findDragRowIndex`,value:function(e){if(!this.tableCellBlot)return-1;var t=this.tableCellBlot.parent;return t instanceof J?e.indexOf(t):-1}},{key:`updateRowResizer`,value:function(){var e=this;if(!(!this.tableBlot||!this.tableCellBlot||!this.rowResizer)){var t=this.tableCellBlot;this.rowResizer.remove();var n=Z(this.tableBlot).rect;if(n){this.rowResizer=this.tableModule.addContainer(this.bem.be(`row`));var r=t.domNode.getBoundingClientRect(),i=this.quill.root.getBoundingClientRect();Object.assign(this.rowResizer.style,{top:`${r.bottom-i.y}px`,left:`${n.x-i.x}px`,width:`${n.width}px`});var a=er(this.rowResizer,{axis:`y`,onStart:function(t,n){if(e.dragging=!0,e.calculateRowDragRange(),e.dragYCommon.createBreak(),e.tableBlot){var r=e.tableBlot.domNode.parentElement.getBoundingClientRect(),i=Z(e.tableBlot).rect;if(i){e.dragYCommon.startValue=i.y;var a=e.quill.root.getBoundingClientRect();Object.assign(e.dragYCommon.dragBreak.style,{top:`${n.clientY-a.y}px`,left:`${Math.max(r.x,i.x)-a.x}px`,width:`${Math.min(r.width,i.width)}px`})}}},onMove:function(t){var n=t.position;if(!(!e.dragYCommon.dragBreak||!e.table)){var r=e.dragYCommon.limitRange(e.tableBlot,n.y,!0),i=e.quill.root.getBoundingClientRect();e.dragYCommon.dragBreak.style.top=`${r-i.y}px`}},onEnd:function(t){var n=t.position;if(e.dragging=!1,e.rowResizer){var r=e.dragYCommon.limitRange(e.tableBlot,n.y,!0),i=e.quill.root.getBoundingClientRect();e.rowResizer.style.left=`${r-i.y}px`}e.updateTableRow(n.y),e.removeBreak()}}).stop;this.stopRowDrag&&this.stopRowDrag(),this.stopRowDrag=a,this.rowResizer.addEventListener(`dragstart`,function(e){return e.preventDefault()})}}}},{key:`show`,value:function(){!this.table||!this.rowResizer||!this.colResizer||(this.rowResizer.classList.remove(this.bem.is(`hidden`)),this.colResizer.classList.remove(this.bem.is(`hidden`)),this.table.addEventListener(`pointermove`,this.pointermoveHandler))}},{key:`hideResizer`,value:function(){!this.rowResizer||!this.colResizer||(this.rowResizer.classList.add(this.bem.is(`hidden`)),this.colResizer.classList.add(this.bem.is(`hidden`)))}},{key:`hide`,value:function(){this.currentTableCell=void 0,cr.call(this),this.hideResizer(),this.table&&this.table.removeEventListener(`pointermove`,this.pointermoveHandler)}},{key:`destroy`,value:function(){I(n,`destroy`,this,3)([]),this.colResizer&&(this.colResizer.remove(),this.colResizer=void 0),this.rowResizer&&(this.rowResizer.remove(),this.rowResizer=void 0),this.quill.off(t.default.events.EDITOR_CHANGE,this.updateWhenTextChange)}}])}(Wi);x(Yi,`moduleName`,`table-resize-line`);var Xi=function(e){function n(e,r,i){var a;return _(this,n),a=g(this,n,[e,r]),x(a,`tableModule`,void 0),x(a,`quill`,void 0),x(a,`scrollHandler`,[]),x(a,`tableMainBlot`,void 0),x(a,`tableWrapperBlot`,void 0),x(a,`bem`,H(`scale`)),x(a,`options`,void 0),x(a,`root`,void 0),x(a,`block`,void 0),x(a,`resizeobserver`,new ResizeObserver(function(){return a.update()})),x(a,`updateWhenTextChange`,function(e){e===t.default.events.TEXT_CHANGE&&(a.table&&!a.quill.root.contains(a.table)?a.setSelectionTable(void 0):a.update())}),a.tableModule=e,a.quill=r,a.options=a.resolveOptions(i),a.quill.on(t.default.events.EDITOR_CHANGE,a.updateWhenTextChange),a}return w(n,e),y(n,[{key:`resolveOptions`,value:function(e){return Object.assign({blockSize:12,offset:6},e)}},{key:`buildResizer`,value:function(){var e=this;if(!(!this.tableMainBlot||!this.tableWrapperBlot)){this.root=this.tableModule.addContainer(this.bem.b()),this.block=document.createElement(`div`),this.block.classList.add(this.bem.be(`block`)),Object.assign(this.block.style,{width:`${this.options.blockSize}px`,height:`${this.options.blockSize}px`}),this.root.appendChild(this.block);var t=[],n=[];er(this.block,{onStart:function(){e.tableMainBlot&&(t=e.tableMainBlot.getCols().map(function(e){return{blot:e,width:Math.floor(e.width)}}),n=e.tableMainBlot.getRows().map(function(e){return{blot:e,height:Math.floor(e.domNode.getBoundingClientRect().height)}}))},onMove:function(r){var i=r.movePosition;if(e.tableMainBlot){var a=Bi(e.tableMainBlot)?-1:1,o=i.x*a,s=i.y,c=Math.floor(o/t.length),l=Math.floor(s/n.length),u=b(t),d;try{for(u.s();!(d=u.n()).done;){var f=d.value,p=f.blot,m=f.width;p.width=Math.max(m+c,z.colMinWidthPx)}}catch(e){u.e(e)}finally{u.f()}var h=b(n),g;try{for(h.s();!(g=h.n()).done;){var _=g.value,v=_.blot,y=_.height;v.setHeight(`${Math.max(y+l,z.rowMinHeightPx)}px`)}}catch(e){h.e(e)}finally{h.f()}}},onEnd:function(){t=[],n=[]}}),this.block.addEventListener(`dragstart`,function(e){return e.preventDefault()})}}},{key:`update`,value:function(){if(!(!this.block||!this.root||!this.tableMainBlot||!this.tableWrapperBlot)){if(this.tableMainBlot.full){this.hide();return}var e=Z(this.tableMainBlot).rect;if(e){var t=this.tableWrapperBlot.domNode.getBoundingClientRect(),n=this.quill.root.getBoundingClientRect(),r=this.tableWrapperBlot.domNode,i=r.scrollTop,a=r.scrollLeft,o=this.options.blockSize*2+this.options.offset,s=Math.min(e.width,t.width)+o,c=Math.min(e.height,t.height)+o;Object.assign(this.root.style,{width:`${s}px`,height:`${c}px`,left:`${Math.max(e.x,t.x)-n.x-this.options.blockSize}px`,top:`${Math.max(e.y,t.y)-n.y-this.options.blockSize}px`});var l={left:`${e.width+o-a}px`,top:`${c-i}px`};Bi(this.tableMainBlot)?(this.root.classList.add(this.bem.is(`align-right`)),l.left=`${this.options.blockSize+-1*a}px`):this.root.classList.remove(this.bem.is(`align-right`)),Object.assign(this.block.style,l)}}}},{key:`show`,value:function(){var e=this;this.table&&(this.tableMainBlot=t.default.find(this.table),this.tableMainBlot&&!this.tableMainBlot.full&&(this.tableWrapperBlot=this.tableMainBlot.parent,this.resizeobserver.observe(this.tableMainBlot.domNode),or.call(this,this.quill.root,function(){return e.update()}),or.call(this,this.tableWrapperBlot.domNode,function(){return e.update()})),this.buildResizer())}},{key:`hide`,value:function(){this.tableMainBlot=void 0,this.tableWrapperBlot=void 0,this.root&&(this.root.remove(),this.root=void 0,this.block=void 0),cr.call(this)}},{key:`destroy`,value:function(){I(n,`destroy`,this,3)([]),this.hide(),this.quill.off(t.default.events.EDITOR_CHANGE,this.updateWhenTextChange),this.resizeobserver.disconnect()}}])}(qr);x(Xi,`moduleName`,`table-resize-scale`);var Zi={size:`height`,offset:`offsetHeight`,scrollDirection:`scrollTop`,scrollSize:`scrollHeight`,axis:`y`,direction:`top`,client:`clientY`},Qi={size:`width`,offset:`offsetWidth`,scrollDirection:`scrollLeft`,scrollSize:`scrollWidth`,axis:`x`,direction:`left`,client:`clientX`},$i=function(){function e(n,r,i){var a=this;_(this,e),x(this,`quill`,void 0),x(this,`table`,void 0),x(this,`options`,void 0),x(this,`minSize`,20),x(this,`gap`,4),x(this,`move`,0),x(this,`cursorDown`,!1),x(this,`cursorLeave`,!1),x(this,`ratioY`,1),x(this,`ratioX`,1),x(this,`sizeWidth`,``),x(this,`sizeHeight`,``),x(this,`size`,``),x(this,`bem`,H(`scrollbar`)),x(this,`tableMainBlot`,void 0),x(this,`ob`,void 0),x(this,`container`,void 0),x(this,`scrollbar`,void 0),x(this,`thumb`,document.createElement(`div`)),x(this,`scrollHandler`,[]),x(this,`propertyMap`,void 0),x(this,`thumbState`,{x:0,y:0}),x(this,`showScrollbar`,_r(function(){a.cursorLeave=!1,a.scrollbar.removeEventListener(`transitionend`,a.hideScrollbarTransitionend),a.scrollbar.style.display=a.size?`block`:`none`,requestAnimationFrame(function(){a.scrollbar.classList.remove(a.bem.is(`transparent`))})},200)),x(this,`hideScrollbar`,_r(function(){a.cursorLeave=!0,!a.cursorDown&&(a.scrollbar.removeEventListener(`transitionend`,a.hideScrollbarTransitionend),a.scrollbar.addEventListener(`transitionend`,a.hideScrollbarTransitionend,{once:!0}),a.scrollbar.classList.add(a.bem.is(`transparent`)))},200)),x(this,`hideScrollbarTransitionend`,function(){a.scrollbar.style.display=a.cursorDown&&a.size?`block`:`none`}),this.quill=n,this.table=r,this.options=i,this.tableMainBlot=t.default.find(this.table),this.container=r.parentElement,this.propertyMap=this.isVertical?Zi:Qi,this.calculateSize(),this.ob=new ResizeObserver(function(){return a.update()}),this.ob.observe(r),this.scrollbar=this.createScrollbar(),this.setScrollbarPosition(),or.call(this,this.quill.root,function(){return a.setScrollbarPosition()}),this.showScrollbar()}return y(e,[{key:`isVertical`,get:function(){return this.options.isVertical}},{key:`update`,value:function(){this.calculateSize(),this.setScrollbarPosition()}},{key:`setScrollbarPosition`,value:function(){var e=Z(this.tableMainBlot),t=e.rect,n=e.head,r=e.body,i=e.foot,a=n||r||i;if(!(!a||!t)){var o=this.quill.root,s=o.scrollLeft,c=o.scrollTop,l=o.offsetLeft,u=o.offsetTop,d=this.container,f=d.offsetLeft,p=d.offsetTop,m=a.domNode,h=m.offsetLeft,g=m.offsetTop,_=this.container.getBoundingClientRect(),v=_.width,y=_.height,b=f+h-l,S=p+g-u;this.isVertical?b+=Math.min(v,t.width):S+=Math.min(y,t.height),this.tableMainBlot&&this.tableMainBlot.align!==`left`&&(b+=this.table.offsetLeft-f),Object.assign(this.scrollbar.style,x(x({},this.propertyMap.size,`${this.isVertical?Math.min(y,t.height):v}px`),`transform`,`translate(${b-s}px, ${S-c}px)`)),this.containerScrollHandler(this.container)}}},{key:`calculateSize`,value:function(){var e=this.container.offsetHeight-this.gap,t=this.container.offsetWidth-this.gap,n=Math.pow(e,2)/this.container.scrollHeight,r=Math.pow(t,2)/this.container.scrollWidth,i=Math.max(n,this.minSize),a=Math.max(r,this.minSize);this.ratioY=n/(e-n)/(i/(e-i)),this.ratioX=r/(t-r)/(a/(t-a)),this.sizeWidth=a+this.gap<t?`${a}px`:``,this.sizeHeight=i+this.gap<e?`${i}px`:``,this.size=this.isVertical?this.sizeHeight:this.sizeWidth}},{key:`createScrollbar`,value:function(){var e=this,t=document.createElement(`div`);t.classList.add(this.bem.b(),this.isVertical?this.bem.is(`vertical`):this.bem.is(`horizontal`),this.bem.is(`transparent`)),Object.assign(t.style,{display:`none`}),this.thumb.classList.add(this.bem.be(`thumb`));var n=null,r=function(t){if(e.cursorDown!==!1){var n=e.thumbState[e.propertyMap.axis];if(n){var r=Math.pow(e.scrollbar[e.propertyMap.offset],2)/e.container[e.propertyMap.scrollSize]/(e.isVertical?e.ratioY:e.ratioX)/e.thumb[e.propertyMap.offset],i=((e.scrollbar.getBoundingClientRect()[e.propertyMap.direction]-t[e.propertyMap.client])*-1-(e.thumb[e.propertyMap.offset]-n))*100*r/e.scrollbar[e.propertyMap.offset];e.container[e.propertyMap.scrollDirection]=i*e.container[e.propertyMap.scrollSize]/100}}},i=function(){e.thumbState[e.propertyMap.axis]=0,e.cursorDown=!1,document.removeEventListener(`mousemove`,r),document.removeEventListener(`mouseup`,i),e.cursorLeave&&e.hideScrollbar(),document.onselectstart=n},a=function(t){t.stopImmediatePropagation(),e.cursorDown=!0,document.addEventListener(`mousemove`,r),document.addEventListener(`mouseup`,i),n=document.onselectstart,document.onselectstart=function(){return!1}};this.thumb.addEventListener(`mousedown`,function(t){var n;if(t.stopPropagation(),!(t.ctrlKey||[1,2].includes(t.button))){(n=window.getSelection())==null||n.removeAllRanges(),a(t);var r=t.currentTarget;r&&(e.thumbState[e.propertyMap.axis]=r[e.propertyMap.offset]-(t[e.propertyMap.client]-r.getBoundingClientRect()[e.propertyMap.direction]))}});for(var o=[this.table,t],s=0,c=o;s<c.length;s++){var l=c[s];l.addEventListener(`mouseenter`,this.showScrollbar),l.addEventListener(`mouseleave`,this.hideScrollbar)}return or.call(this,this.container,function(){e.containerScrollHandler(e.container)}),t.appendChild(this.thumb),t}},{key:`containerScrollHandler`,value:function(e){var t=e[this.propertyMap.offset]-this.gap;this.move=e[this.propertyMap.scrollDirection]*100/t*(this.isVertical?this.ratioY:this.ratioX),Object.assign(this.thumb.style,x(x({},this.propertyMap.size,this.size),`transform`,`translate${this.propertyMap.axis.toUpperCase()}(${this.move}%)`))}},{key:`destroy`,value:function(){this.ob.disconnect(),cr.call(this),this.table.removeEventListener(`mouseenter`,this.showScrollbar),this.table.removeEventListener(`mouseleave`,this.hideScrollbar)}}])}(),ea=function(e){function n(e,r,i){var a;_(this,n),a=g(this,n,[e,r]),x(a,`tableModule`,void 0),x(a,`quill`,void 0),x(a,`scrollbarContainer`,void 0),x(a,`scrollbar`,[]),x(a,`bem`,H(`scrollbar`)),x(a,`updateWhenTextChange`,function(e){e===t.default.events.TEXT_CHANGE&&(a.table&&!a.quill.root.contains(a.table)?a.setSelectionTable(void 0):a.update())}),a.tableModule=e,a.quill=r;var o=H(`scrollbar`);return a.quill.container.classList.add(o.bm(`virtual`)),a.scrollbarContainer=a.tableModule.addContainer(a.bem.be(`container`)),a.quill.on(t.default.events.EDITOR_CHANGE,a.updateWhenTextChange),a}return w(n,e),y(n,[{key:`hide`,value:function(){var e=b(this.scrollbar),t;try{for(e.s();!(t=e.n()).done;)t.value.destroy()}catch(t){e.e(t)}finally{e.f()}this.scrollbar=[],this.scrollbarContainer.innerHTML=``}},{key:`show`,value:function(){if(this.table){this.scrollbar=[new $i(this.quill,this.table,{isVertical:!0}),new $i(this.quill,this.table,{isVertical:!1})];var e=b(this.scrollbar),t;try{for(e.s();!(t=e.n()).done;){var n=t.value;this.scrollbarContainer.appendChild(n.scrollbar),n.showScrollbar()}}catch(t){e.e(t)}finally{e.f()}}}},{key:`update`,value:function(){if(this.table){this.scrollbar.length<=0&&this.show();var e=b(this.scrollbar),t;try{for(e.s();!(t=e.n()).done;){var n=t.value;n.calculateSize(),n.setScrollbarPosition()}}catch(t){e.e(t)}finally{e.f()}}else this.scrollbar.length>0&&this.hide()}},{key:`destroy`,value:function(){I(n,`destroy`,this,3)([]),this.hide(),this.scrollbarContainer.remove(),this.quill.off(t.default.events.TEXT_CHANGE,this.updateWhenTextChange)}}])}(qr);x(ea,`moduleName`,`table-scrollbar`);var ta=0,na=function(e){function n(e,r){var i,a=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};return _(this,n),i=g(this,n,[e,r]),x(i,`tableModule`,void 0),x(i,`quill`,void 0),x(i,`options`,void 0),x(i,`boundary`,null),x(i,`scrollRecordEls`,[]),x(i,`startScrollRecordPosition`,[]),x(i,`selectedTableScrollX`,0),x(i,`selectedTableScrollY`,0),x(i,`selectedEditorScrollX`,0),x(i,`selectedEditorScrollY`,0),x(i,`selectedTds`,[]),x(i,`cellSelectWrap`,void 0),x(i,`cellSelect`,void 0),x(i,`scrollHandler`,[]),x(i,`resizeObserver`,void 0),x(i,`isDisplaySelection`,!1),x(i,`bem`,H(`selection`)),x(i,`autoScroller`,void 0),x(i,`lastSelection`,{anchorNode:null,anchorOffset:0,focusNode:null,focusOffset:0}),x(i,`_dragging`,!1),x(i,`handlePaste`,function(e){if(!(!(document.activeElement&&i.quill.root.contains(document.activeElement))||i.quill.getSelection())){var t=e.clipboardData;if(t){e.preventDefault();var n=i.selectedTds;if(!(n.length<=0)){var r=t.getData(`text/html`),a=i.quill.clipboard.convert({html:r}).ops.filter(function(e){var t;return(t=e.attributes)==null?void 0:t[R.tableCellInner]});a.length!==0&&Xr({quill:i.quill,talbeModule:i.tableModule},n,a)}}}}),x(i,`keyboardHandler`,function(){var e=h(P().mark(function e(t){var n;return P().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(!t.ctrlKey){e.next=4;break}n=t.key,e.next=n===`c`||n===`x`?1:3;break;case 1:return e.next=2,Ni(i.tableModule,i.selectedTds,t.key===`x`);case 2:return e.abrupt(`continue`,3);case 3:e.next=5;break;case 4:(t.key===`Backspace`||t.key===`Delete`)&&i.removeCellBySelectedTds();case 5:case`end`:return e.stop()}},e)}));return function(t){return e.apply(this,arguments)}}()),x(i,`updateWhenTextChange`,function(e){e===t.default.events.TEXT_CHANGE&&(i.table&&!i.quill.root.contains(i.table)?i.setSelectionTable(void 0):i.updateAfterEvent())}),x(i,`updateAfterEvent`,function(){var e=b(i.selectedTds),t;try{for(e.s();!(t=e.n()).done;)if(!t.value.domNode.isConnected){i.selectedTds=[];break}}catch(t){e.e(t)}finally{e.f()}i.updateWithSelectedTds()}),x(i,`quillSelectionChangeHandler`,function(e,n,r){if(r!==t.default.sources.API&&e&&!i.quill.composition.isComposing&&i.selectedTds.length>0){var a=i.quill.getFormat(e),o=F(i.quill.getLine(e.index),1)[0],s=!!a[R.tableCellInner]&&!!o,c=o&&i.selectedTds.some(function(e){return e.domNode.contains(o.domNode)});if(s&&!c)try{var l=U(o,R.tableCellInner);i.setSelectedTds([l]),i.updateWithSelectedTds()}catch(e){}else s&&c||i.hide()}}),x(i,`selectionChangeHandler`,function(){var e=window.getSelection();if(e){var n=e.anchorNode,r=e.focusNode,a=e.anchorOffset,o=e.focusOffset;if(!(!n||!r)){var s=t.default.find(n),c=t.default.find(r);if(!(!s||!c||s.scroll!==i.quill.scroll||c.scroll!==i.quill.scroll)){var l=me(s),u=me(c),d=l.has(R.tableColgroup),f=u.has(R.tableColgroup);if(d||f){var p=n,m=a,h=r,g=o;if(d){var _=l.get(R.tableWrapper).descendants(q);_.length>0&&(p=_[0].domNode,m=0)}if(f){var v=u.get(R.tableWrapper).descendants(q);v.length>0&&(h=v[0].domNode,g=0)}i.setSelectionData(e,{anchorNode:p,anchorOffset:m,focusNode:h,focusOffset:g});return}var y=l.has(R.tableCellInner),b=u.has(R.tableCellInner),x=y&&b;if(x){var S=l.get(R.tableCellInner),C=u.get(R.tableCellInner);x&&(x=S!==C)}if(y&&b&&x||!y&&b||!b&&y){i.setSelectionData(e,i.lastSelection),i.selectedTds.length>0&&i.hide();return}i.lastSelection={anchorNode:n,anchorOffset:a,focusNode:r,focusOffset:o}}}}}),i.tableModule=e,i.quill=r,i.options=i.resolveOptions(a),i.scrollRecordEls=[i.quill.root,document.documentElement],i.cellSelectWrap=e.addContainer(i.bem.b()),i.cellSelect=i.helpLinesInitial(),i.resizeObserver=ar(i.updateAfterEvent,{ignoreFirstBind:!0}),i.resizeObserver.observe(i.quill.root),document.addEventListener(`paste`,i.handlePaste),document.addEventListener(`selectionchange`,i.selectionChangeHandler),i.quill.on(B.AFTER_TABLE_RESIZE,i.updateAfterEvent),i.quill.on(t.default.events.SELECTION_CHANGE,i.quillSelectionChangeHandler),i.quill.on(t.default.events.EDITOR_CHANGE,i.updateWhenTextChange),i.autoScroller=new dr(50,40),i.hide(),i}return w(n,e),y(n,[{key:`dragging`,get:function(){return this._dragging},set:function(e){this._dragging!==e&&(this._dragging=e,this.quill.emitter.emit(e?B.TABLE_SELECTION_DRAG_START:B.TABLE_SELECTION_DRAG_END,this))}},{key:`removeCellBySelectedTds`,value:function(){var e=this.quill.getSelection(),n=document.activeElement;if(!(e||!this.quill.root.contains(n))){if(this.table){var r=t.default.find(this.table),i=r.descendants(q);if(this.selectedTds.length===i.length){r.remove();return}}var a=b(this.selectedTds),o;try{for(a.s();!(o=a.n()).done;){var s=o.value,c=s.clone();c.appendChild(s.scroll.create(`block`)),s.parent.insertBefore(c,s),s.remove()}}catch(e){a.e(e)}finally{a.f()}}}},{key:`setSelectedTds`,value:function(e){var t=new Set(this.selectedTds),n=this.selectedTds.length===e.length&&e.every(function(e){return t.has(e)});this.selectedTds=e,n||this.quill.emitter.emit(B.TABLE_SELECTION_CHANGE,this,this.selectedTds)}},{key:`setSelectionData`,value:function(e,t){var n=t.anchorNode,r=t.anchorOffset,i=t.focusNode,a=t.focusOffset;if(!(!n||!i)){var o=document.createRange(),s=this.selectionDirectionUp(t);s?(o.setStart(n,r),o.setEnd(n,r)):(o.setStart(n,r),o.setEnd(i,a)),e.removeAllRanges(),e.addRange(o),s&&e.extend(i,a)}}},{key:`selectionDirectionUp`,value:function(e){var t=e.anchorNode,n=e.anchorOffset,r=e.focusNode,i=e.focusOffset;if(!t||!r)return!1;if(t===r)return n>i;var a=t.compareDocumentPosition(r);return a&Node.DOCUMENT_POSITION_CONTAINS||a&Node.DOCUMENT_POSITION_CONTAINED_BY?(a&Node.DOCUMENT_POSITION_FOLLOWING)!==0:(a&Node.DOCUMENT_POSITION_PRECEDING)!==0}},{key:`resolveOptions`,value:function(e){return Object.assign({selectColor:`#0589f340`},e)}},{key:`helpLinesInitial`,value:function(){this.cellSelectWrap.style.setProperty(`--select-color`,this.options.selectColor);var e=document.createElement(`div`);return e.classList.add(this.bem.be(`line`)),this.cellSelectWrap.appendChild(e),e}},{key:`computeSelectedTds`,value:function(e,n){if(!this.table)return[];var r=t.default.find(this.table);if(!r)return[];var i=new Set(r.descendants(Y).map(function(e,t){return e.index=t,e})),a=this.getScrollPositionDiff(),o=Z(r).rect;if(!o)return[];for(var s=e.x+a.x,c=e.y+a.y,l={x:Math.max(o.left,Math.min(n.x,s)),y:Math.max(o.top,Math.min(n.y,c)),x1:Math.min(o.right,Math.max(n.x,s)),y1:Math.min(o.bottom,Math.max(n.y,c))},u=new Set,d=!0;d;){d=!1;var f=b(i),p;try{for(f.s();!(p=f.n()).done;){var m=p.value;m.__rect||(m.__rect=m.domNode.getBoundingClientRect());var h=m.__rect,g=h.x,_=h.y,v=h.right,y=h.bottom;if(tr({x:Math.floor(l.x),y:Math.floor(l.y),x1:Math.floor(l.x1),y1:Math.floor(l.y1)},{x:Math.floor(g),y:Math.floor(_),x1:Math.floor(v),y1:Math.floor(y)},ta,u.size===0)){u.add(m),i.delete(m),l={x:Math.min(l.x,g),y:Math.min(l.y,_),x1:Math.max(l.x1,v),y1:Math.max(l.y1,y)},d=!0;break}}}catch(e){f.e(e)}finally{f.f()}}for(var x=0,S=[].concat(L(u),L(i));x<S.length;x++){var C=S[x];delete C.__rect}return this.boundary=nr(j(j({},l),{},{width:l.x1-l.x,height:l.y1-l.y}),this.quill.root),Array.from(u).toSorted(function(e,t){return e.index-t.index}).map(function(e){return delete e.index,e.getCellInner()})}},{key:`getScrollPositionDiff`,value:function(){var e=this,t=this.getTableViewScroll(),n=t.x,r=t.y,i=lr(this.quill.root),a=i.x,o=i.y;return this.selectedTableScrollX=n,this.selectedTableScrollY=r,this.selectedEditorScrollX=a,this.selectedEditorScrollY=o,this.startScrollRecordPosition.reduce(function(t,n,r){var i=n.x,a=n.y,o=lr(e.scrollRecordEls[r]),s=o.x,c=o.y;return t.x+=i-s,t.y+=a-c,t},{x:0,y:0})}},{key:`recordScrollPosition`,value:function(){this.clearRecordScrollPosition();var e=b(this.scrollRecordEls),t;try{for(e.s();!(t=e.n()).done;){var n=t.value;this.startScrollRecordPosition.push(lr(n))}}catch(t){e.e(t)}finally{e.f()}}},{key:`clearRecordScrollPosition`,value:function(){this.startScrollRecordPosition=[]}},{key:`tableSelectHandler`,value:function(e){var n=this,r=e.button,i=e.target,a=e.clientX,o=e.clientY,s=i.closest(`table`),c=i.closest(`caption`);if(!(r!==0||!s||c)){this.setSelectionTable(s);var l=s.dataset.tableId,u={x:a,y:o};this.recordScrollPosition(),this.setSelectedTds(this.computeSelectedTds(u,u)),this.show();var d=function(e){n.dragging=!0;var t=e.button,r=e.target,i=e.clientX,a=e.clientY,o=r.closest(`.ql-table`),s=r.closest(`caption`);if(!(t!==0||s||!o||o.dataset.tableId!==l)){var c={x:i,y:a};n.setSelectedTds(n.computeSelectedTds(u,c)),n.selectedTds.length>1&&n.quill.blur(),n.update(),n.autoScroller.updateMousePosition(i,a)}},f=function(){document.body.removeEventListener(`mousemove`,d,!1),document.body.removeEventListener(`mouseup`,f,!1),n.autoScroller.stop(),n.dragging=!1,n.clearRecordScrollPosition()};document.body.addEventListener(`mousemove`,d,!1),document.body.addEventListener(`mouseup`,f,!1);var p=t.default.find(s);if(p){var m=p.parent.domNode;this.autoScroller.updateMousePosition(a,o),this.autoScroller.start(m)}}}},{key:`updateWithSelectedTds`,value:function(){if(this.selectedTds.length<=0){this.hide();return}var e={x:1/0,y:1/0},t={x:-1/0,y:-1/0},n=b(this.selectedTds),r;try{for(n.s();!(r=n.n()).done;){var i=r.value.domNode.getBoundingClientRect();e.x=Math.min(e.x,i.left),e.y=Math.min(e.y,i.top),t.x=Math.max(t.x,i.right),t.y=Math.max(t.y,i.bottom)}}catch(e){n.e(e)}finally{n.f()}this.setSelectedTds(this.computeSelectedTds(e,t)),this.selectedTds.length>0?this.update():this.hide()}},{key:`update`,value:function(){if(!this.table){this.hide();return}if(!(this.selectedTds.length===0||!this.boundary)){var e=lr(this.quill.root),t=e.x,n=e.y,r=this.getTableViewScroll(),i=r.x,a=r.y,o=this.table.parentElement.getBoundingClientRect(),s=this.quill.root.getBoundingClientRect(),c=o.x-s.x,l=o.y-s.y;Object.assign(this.cellSelect.style,{left:`${this.selectedEditorScrollX*2-t+this.boundary.x+this.selectedTableScrollX-i-c}px`,top:`${this.selectedEditorScrollY*2-n+this.boundary.y+this.selectedTableScrollY-a-l}px`,width:`${this.boundary.width}px`,height:`${this.boundary.height}px`}),Object.assign(this.cellSelectWrap.style,{left:`${c}px`,top:`${l}px`,width:`${o.width}px`,height:`${o.height}px`}),this.quill.emitter.emit(B.TABLE_SELECTION_DISPLAY_CHANGE,this)}}},{key:`getTableViewScroll`,value:function(){return this.table?lr(this.table.parentElement):{x:0,y:0}}},{key:`setSelectionTable`,value:function(e){this.table!==e&&(this.table=e,this.table?this.scrollRecordEls.push(this.table.parentElement):this.scrollRecordEls.pop())}},{key:`showDisplay`,value:function(){Object.assign(this.cellSelectWrap.style,{display:`block`}),this.isDisplaySelection=!0,this.table&&this.resizeObserver.observe(this.table)}},{key:`show`,value:function(){var e=this;this.table&&(cr.call(this),this.showDisplay(),this.update(),this.quill.root.addEventListener(`keydown`,this.keyboardHandler),or.call(this,this.quill.root,function(){e.update()}),or.call(this,this.table.parentElement,function(){e.update()}))}},{key:`hideDisplay`,value:function(){Object.assign(this.cellSelectWrap.style,{display:`none`}),this.isDisplaySelection=!1,this.table&&this.resizeObserver.unobserve(this.table)}},{key:`hide`,value:function(){cr.call(this),this.quill.root.removeEventListener(`keydown`,this.keyboardHandler),this.hideDisplay(),this.boundary=null,this.setSelectedTds([]),this.setSelectionTable(void 0)}},{key:`destroy`,value:function(){I(n,`destroy`,this,3)([]),this.resizeObserver.disconnect(),this.hide(),this.cellSelectWrap.remove(),cr.call(this),document.removeEventListener(`paste`,this.handlePaste),document.removeEventListener(`selectionchange`,this.selectionChangeHandler),this.quill.off(B.AFTER_TABLE_RESIZE,this.updateAfterEvent),this.quill.off(t.default.events.EDITOR_CHANGE,this.updateWhenTextChange),this.quill.off(t.default.events.SELECTION_CHANGE,this.quillSelectionChangeHandler)}}])}(qr);x(na,`moduleName`,V.tableSelectionName);var ra=[`texts`],ia=[`attributes`],aa=[`style`],oa=[`emptyRow`],sa=t.default.import(`parchment`),ca=t.default.import(`delta`),la=t.default.import(`ui/icons`),ua=t.default.import(`blots/break`),da=t.default.import(`blots/block`),fa=t.default.import(`blots/block/embed`);function pa(e,t){var n={tableId:t.tableId,rowId:t.rowId,colId:t.colId,colspan:1,rowspan:1},r=e.create(R.tableCell,n),i=e.create(R.tableCellInner,n),a=e.create(`block`);return a.appendChild(e.create(`break`)),i.appendChild(a),r.appendChild(i),r}function ma(e){ue.delete(R.tableCellInner),Object.assign(R,e.blotName||{}),Object.assign(z,e.tableUpSize||{}),Object.assign(B,e.tableUpEvent||{}),Object.assign(V,e.tableUpInternal||{}),_a.moduleName=V.moduleName,_a.toolName=R.tableWrapper,K.blotName=R.container,Br.blotName=R.tableCaption,Kr.blotName=R.tableWrapper,X.blotName=R.tableMain,Hr.blotName=R.tableColgroup,Vr.blotName=R.tableCol,Wr.blotName=R.tableHead,jr.blotName=R.tableBody,Ur.blotName=R.tableFoot,J.blotName=R.tableRow,Y.blotName=R.tableCell,q.blotName=R.tableCellInner,ue.add(R.tableCellInner)}function ha(e,n){return Ue({onSelect:function(r,i){e.insertTable(r,i,t.default.sources.USER),n&&n.close()},customBtn:e.options.customBtn,texts:e.options.texts})}function ga(e){return{bindInHead:!1,key:e?`ArrowUp`:`ArrowDown`,collapsed:!0,format:[R.tableCellInner],handler:function(n,r){var i=e?`prev`:`next`,a=e?`tail`:`head`;if(r.line[i])return!0;var o=this.quill.selection.getBounds(n.index),s=r.line.domNode.getBoundingClientRect();if(!o||!s)return!0;if(e){if(o.top-s.top>3)return!0}else if(s.bottom-o.bottom>3)return!0;var c,l,u,d;try{var f=F(pe(r.line,[R.tableWrapper,R.tableMain,R.tableRow,R.tableCell]),4);c=f[0],l=f[1],u=f[2],d=f[3]}catch(e){return!0}var p=l.getColIds(),m=c.descendants(Br,0)[0],h;if(m){var g=window.getComputedStyle(m.domNode);h=i===`next`&&g.captionSide===`bottom`?m:i===`next`?c.next:m}else h=c[i];if(r.line[i]||!h)return!0;var _=u[i];if(_){var v=p.indexOf(d.colId),y=_.getCellByColId(p[v],i);if(!y)return!0;var b=y.children[a];b.children&&(b=b.children[a]);var x=b.offset(this.quill.scroll)+Math.min(r.offset,b.length()-1);this.quill.setSelection(x,0,t.default.sources.USER)}else{var S=h.offset(this.quill.scroll)+(e?h.length()-1:0);this.quill.setSelection(S,0,t.default.sources.USER)}return!1}}}var _a=function(){function e(t,n){var r=this;_(this,e),x(this,`quill`,void 0),x(this,`options`,void 0),x(this,`textOptionsInput`,void 0),x(this,`toolBox`,void 0),x(this,`fixTableByLisenter`,_r(this.balanceTables,100)),x(this,`selector`,void 0),x(this,`resizeOb`,void 0),x(this,`editableObserver`,void 0),x(this,`modules`,{}),this.quill=t,this.textOptionsInput=n==null?void 0:n.texts,this.options=this.resolveOptions(n||{}),this.toolBox=this.initialContainer();var i=this.getToolbarPicker();i&&(i.label.innerHTML=this.options.icon,this.buildCustomSelect(this.options.customSelect,i),i.label.addEventListener(`mousedown`,function(){if(r.selector)if(ir(r.selector.getBoundingClientRect()).leftLimited){var e=i.label.getBoundingClientRect();Object.assign(i.options.style,{transform:`translateX(calc(-100% + ${e.width}px))`})}else Object.assign(i.options.style,{transform:void 0})}));for(var a=this.quill.getModule(`keyboard`),o=0,s=Object.values(e.keyboradHandler);o<s.length;o++){var c=s[o];c.bindInHead?a.bindings[c.key].unshift(c):a.addBinding(c.key,c)}this.initModules(),this.listenEditableChange(),this.quillHack(),this.listenBalanceCells()}return y(e,[{key:`statics`,get:function(){return this.constructor}},{key:`initialContainer`,value:function(){var e=this,t=H(`toolbox`),n=this.quill.addContainer(t.b());return this.resizeOb=new ResizeObserver(function(){var t=e.quill.root.getBoundingClientRect(),r=e.quill.root,i=r.offsetLeft,a=r.offsetTop;Object.assign(n.style,{top:`${a}px`,left:`${i}px`,width:`${t.width}px`,height:`${t.height}px`})}),this.resizeOb.observe(this.quill.root),n}},{key:`addContainer`,value:function(e){if(Oe(e)){var t=document.createElement(`div`),n=b(e.split(` `)),r;try{for(n.s();!(r=n.n()).done;){var i=r.value;t.classList.add(i)}}catch(e){n.e(e)}finally{n.f()}return this.toolBox.appendChild(t),t}else return this.toolBox.appendChild(e),e}},{key:`getToolbarPicker`,value:function(){var e=this,t=this.quill.getModule(`toolbar`);if(!(!t||!this.quill.theme.pickers)){var n=F((t.controls||[]).find(function(t){return F(t,1)[0]===e.statics.toolName})||[],2)[1];if((n==null?void 0:n.tagName.toLocaleLowerCase())===`select`)return this.quill.theme.pickers.find(function(e){return e.select===n})}}},{key:`resolveOptions`,value:function(e){var t=e.texts,n=M(e,ra);return Object.assign({customBtn:!1,texts:this.resolveTexts(t),full:!1,fullSwitch:!0,icon:la.table,autoMergeCell:!0,modules:[]},n)}},{key:`resolveTexts`,value:function(e){var t={fullCheckboxText:`Insert full width table`,customBtnText:`Custom`,confirmText:`Confirm`,cancelText:`Cancel`,rowText:`Row`,colText:`Column`,notPositiveNumberError:`Please enter a positive integer`,custom:`Custom`,clear:`Clear`,transparent:`Transparent`,perWidthInsufficient:`The percentage width is insufficient. To complete the operation, the table needs to be converted to a fixed width. Do you want to continue?`,CopyCell:`Copy cell`,CutCell:`Cut cell`,InsertTop:`Insert row above`,InsertRight:`Insert column right`,InsertBottom:`Insert row below`,InsertLeft:`Insert column Left`,MergeCell:`Merge Cell`,SplitCell:`Split Cell`,DeleteRow:`Delete Row`,DeleteColumn:`Delete Column`,DeleteTable:`Delete table`,BackgroundColor:`Set background color`,BorderColor:`Set border color`};if(Ee(e)){var n=e,r=this;return new Proxy(t,{get:function(e,t){if(typeof t!=`string`)return Reflect.get(e,t);var i=n.call(r,t);return Oe(i)?i:e[t]}})}return Object.assign(t,e)}},{key:`refreshUI`,value:function(){var e=h(P().mark(function e(){var t,n,r,i;return P().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(this.options.texts=this.resolveTexts(this.textOptionsInput),t=this.getToolbarPicker(),!t){e.next=1;break}return t.label.innerHTML=this.options.icon,e.next=1,this.buildCustomSelect(this.options.customSelect,t);case 1:for(n=0,r=Object.values(this.modules);n<r.length;n++)i=r[n],i&&typeof i.hide==`function`&&i.hide();case 2:case`end`:return e.stop()}},e,this)}));function t(){return e.apply(this,arguments)}return t}()},{key:`initModules`,value:function(){if(this.quill.isEnabled()){var e=b(this.options.modules),t;try{for(e.s();!(t=e.n()).done;){var n=t.value;this.modules[n.module.moduleName]=new n.module(this,this.quill,n.options)}}catch(t){e.e(t)}finally{e.f()}}}},{key:`listenEditableChange`,value:function(){var e=this;this.editableObserver=new MutationObserver(function(t){var n=b(t),r;try{for(n.s();!(r=n.n()).done;){var i=r.value;if(i.type===`attributes`&&i.attributeName===`contenteditable`){e.quill.root.getAttribute(`contenteditable`)===`false`?e.destroyModules():e.initModules();break}}}catch(e){n.e(e)}finally{n.f()}}),this.editableObserver.observe(this.quill.root,{attributes:!0,attributeFilter:[`contenteditable`]})}},{key:`destroyModules`,value:function(){for(var e=0,t=Object.entries(this.modules);e<t.length;e++){var n=F(t[e],2),r=n[0],i=n[1];if(i&&typeof i.destroy==`function`)try{i.destroy()}catch(e){console.warn(`Failed to destroy module ${r}:`,e)}}this.modules={}}},{key:`getModule`,value:function(e){return this.modules[e]}},{key:`quillHack`,value:function(){var e=this,n=this.quill.getSemanticHTML;this.quill.getSemanticHTML=function(){for(var r=arguments.length>0&&arguments[0]!==void 0?arguments[0]:0,i=arguments.length>1?arguments[1]:void 0,a=n.call(e.quill,r,i),o=t.default.import(`formats/${R.tableWrapper}`),s=new DOMParser().parseFromString(a,`text/html`),c=0,l=Array.from(s.querySelectorAll(`.${o.className} caption[contenteditable], .${o.className} .${Y.className} > [contenteditable]`));c<l.length;c++)l[c].removeAttribute(`contenteditable`);return s.body.innerHTML};var r=this.quill.format;this.quill.format=function(e,n){var i=arguments.length>2&&arguments[2]!==void 0?arguments[2]:t.default.sources.API;if(!(this.scroll.query(e).prototype instanceof sa.EmbedBlot)){var a=this.getModule(V.moduleName),o=this.getSelection(!0),s=this.getFormat(o),c=a.getModule(V.tableSelectionName);if(!s[R.tableCellInner]||o.length>0||a&&c&&c.selectedTds.length<=1)return r.call(this,e,n,i);if(a&&c&&c.selectedTds.length>0){var l=c.selectedTds,u=!1,d=[],f=b(l),p;try{for(f.s();!(p=f.n()).done;){var m=p.value,h=m.offset(this.scroll),g=m.length();d.push({index:h,length:g}),this.getFormat(h,g)[e]!==n&&(u=!0)}}catch(e){f.e(e)}finally{f.f()}var _=u?n:!1,v=new ca,y=b(d.entries()),S;try{for(y.s();!(S=y.n()).done;){var C=F(S.value,2),w=C[0],T=C[1],E=T.index,D=T.length,O=w===0?0:d[w-1].index+d[w-1].length;v.retain(E-O).retain(D,x({},e,_))}}catch(e){y.e(e)}finally{y.f()}var k=this.updateContents(v,i);return this.blur(),k}}return r.call(this,e,n,i)};var i=this.quill.theme.modules.toolbar;if(i){var a,o=(a=i.handlers)==null?void 0:a.clean;if(o){var s=function(t,n){var r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:function(){return``},i=e.quill.getText(t,n),a=F(e.quill.getLine(t+n),2),o=a[0],s=a[1],c=0,l=new ca;o!=null&&(c=o.length()-s,l=o.delta().slice(s,s+c-1).insert(`
|
|
137
|
+
`));var u=e.quill.getContents(t,n+c),d=u.diff(new ca().insert(i).concat(l)),f=0;return new ca(d.ops.map(function(e){var t=e.attributes,n=M(e,ia);if(e.insert?f-=Oe(e.insert)?e.insert.length:1:e.retain?f+=ke(e.retain)?e.retain:1:e.delete&&(f+=e.delete),t){var i=R.tableCellInner;t[i];var a=M(t,[i].map(ie));if(r){var o,s=u.slice(f-1,f).ops[0];if(s!=null&&(o=s.attributes)!=null&&o[R.tableCellInner]){var c=s.attributes[R.tableCellInner],l=c.style,d=M(c,aa),p=r(l);return p?j(j({},n),{},{attributes:j(j({},a),{},x({},R.tableCellInner,j({style:p},d)))}):j(j({},n),{},{attributes:j(j({},a),{},x({},R.tableCellInner,d))})}}return j(j({},n),{},{attributes:j({},a)})}return e}))};i.handlers.clean=function(e){var n=this,r=this.quill.getModule(V.moduleName),i=this.quill.getSelection();if(i&&i.length>0&&this.quill.getFormat(i)[R.tableCellInner]){var a=s(i.index,i.length,!1),c=new ca().retain(i.index).concat(a);this.quill.updateContents(c,t.default.sources.USER);return}var l=r.getModule(V.tableSelectionName);if(r&&l&&l.selectedTds.length>0&&l.table){var u=t.default.find(l.table);if(!u){console.warn(`TableMainFormat not found`);return}var d=l.selectedTds,f=new Set,p=[],m=b(d),h;try{for(m.s();!(h=m.n()).done;){var g=h.value;if(g.parent instanceof Y){var _=b(g.parent.getNearByCell(`top`)),v;try{for(_.s();!(v=_.n()).done;){var y=v.value;f.has(y)||(f.add(y),p.push({td:y,cleanBorder:`bottom`}))}}catch(e){_.e(e)}finally{_.f()}var x=b(g.parent.getNearByCell(`left`)),S;try{for(x.s();!(S=x.n()).done;){var C=S.value;f.has(C)||(f.add(C),p.push({td:C,cleanBorder:`right`}))}}catch(e){x.e(e)}finally{x.f()}f.add(g.parent),p.push({td:g.parent,cleanBorder:!0})}}}catch(e){m.e(e)}finally{m.f()}var w=u.descendants(Y),T=new Map(w.map(function(e,t){return[e,t]}));p.sort(function(e,t){return T.get(e.td)-T.get(t.td)});for(var E=new ca,D=0,O=function(){var e=A[k],t=e.td,r=e.cleanBorder,i=t.getCellInner().offset(n.quill.scroll),a=t.getCellInner().length(),o=s(i,a-1,function(e){if(!e||r===!0)return``;var t=hr(e);return gr(Object.keys(t).filter(function(e){return!e.startsWith(pr(`border-${r}`))}).reduce(function(e,n){return e[n]=t[n],e},{}))}),c=new ca().retain(i-D).concat(o);E=E.concat(c),D=i+a},k=0,A=p;k<A.length;k++)O();this.quill.updateContents(E,t.default.sources.USER),d.length>1&&this.quill.blur();return}return o.call(this,e)}}}}},{key:`buildCustomSelect`,value:function(){var e=h(P().mark(function e(t,n){var r=this,i,a,o,s,c;return P().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(!(!t||!Ee(t))){e.next=1;break}return e.abrupt(`return`);case 1:return i=document.createElement(`span`),i.classList.add(`ql-custom-select`),e.next=2,t(this,n);case 2:this.selector=e.sent,i.appendChild(this.selector),this.options.fullSwitch&&(a=H(`creator`),o=document.createElement(`label`),o.classList.add(a.be(`checkbox`)),s=document.createElement(`input`),s.type=`checkbox`,s.checked=this.options.full,s.addEventListener(`change`,function(){r.options.full=s.checked}),c=document.createElement(`span`),c.textContent=this.options.texts.fullCheckboxText,o.appendChild(s),o.appendChild(c),i.appendChild(o)),n.options.innerHTML=``,n.options.appendChild(i);case 3:case`end`:return e.stop()}},e,this)}));function t(t,n){return e.apply(this,arguments)}return t}()},{key:`setCellAttrs`,value:function(e,t,n){var r=arguments.length>3&&arguments[3]!==void 0?arguments[3]:!1;if(e.length!==0){var i=b(e),a;try{for(i.s();!(a=i.n()).done;)a.value.setFormatValue(t,n,r)}catch(e){i.e(e)}finally{i.f()}}}},{key:`getTextByCell`,value:function(e){var t=``,n=b(e),r;try{for(n.s();!(r=n.n()).done;){var i=r.value,a=i.offset(this.quill.scroll),o=i.length(),s=b(this.quill.getContents(a,o).ops),c;try{for(s.s();!(c=s.n()).done;){var l=c.value;Oe(l.insert)&&(t+=l.insert)}}catch(e){s.e(e)}finally{s.f()}}}catch(e){n.e(e)}finally{n.f()}return t}},{key:`getHTMLByCell`,value:function(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1;if(e.length===0)return``;var n=null;try{var r=b(e),i;try{for(r.s();!(i=r.n()).done;){var a=i.value,o=U(a,R.tableMain);if(n||(n=o),o!==n)return console.error(`tableMain is not same`),``}}catch(e){r.e(e)}finally{r.f()}}catch(e){return console.error(`tds must be in same tableMain`),``}if(!n)return``;var s=this.quill.getIndex(n),c=n.length(),l=this.quill.getSemanticHTML(s,c),u=new DOMParser().parseFromString(l,`text/html`),d=Array.from(u.querySelectorAll(`col`)),f=d.map(function(e){return e.dataset.colId}),p=[],m=new Set,h=new Set,g=b(e),_;try{for(g.s();!(_=g.n()).done;){var v=_.value;m.add(v.colId);for(var y=v.colId,x=f.indexOf(y),S=0;S<v.colspan;S++)m.add(f[x+S]);h.add(`${v.rowId}-${v.colId}`)}}catch(e){g.e(e)}finally{g.f()}for(var C=0;C<d.length;C++){var w=d[C];m.has(w.dataset.colId)?p.push(w.getAttribute(`width`)):(w.remove(),d.splice(C--,1))}for(var T=0,E=null,D=0,O=Array.from(u.querySelectorAll(`td, th`));D<O.length;D++){var k=O[D];if(h.has(`${k.dataset.rowId}-${k.dataset.colId}`))E!==k.dataset.rowId&&(T+=1,E=k.dataset.rowId);else{var A=k.parentElement;k.remove(),A&&A.children.length<=0&&A.remove()}}var j=d.map(function(e){return Vr.value(e)});if(n.full){var M=j.reduce(function(e,t){return t.width+e},0),N=b(j.entries()),ee;try{for(N.s();!(ee=N.n()).done;){var P=F(ee.value,2),te=P[0],ne=P[1];ne.width=Math.round(ne.width/M*100),d[te].setAttribute(`width`,`${ne.width}%`)}}catch(e){N.e(e)}finally{N.f()}}else{var I=0,L=b(j),re;try{for(L.s();!(re=L.n()).done;){var ie=re.value;I+=ie.width}}catch(e){L.e(e)}finally{L.f()}var ae=u.querySelector(`table`);ae.style.width=`${I}px`}if(t){var oe=n.getRows();if(T===oe.length)this.removeCol(e);else{var se=b(e),z;try{for(se.s();!(z=se.n()).done;){var B=z.value;B.domNode.innerHTML=`<p><br></p>`}}catch(e){se.e(e)}finally{se.f()}}}return u.body.innerHTML}},{key:`insertTable`,value:function(e,n){var r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:t.default.sources.API;if(e>=30||n>=30)throw Error(`Both rows and columns must be less than 30.`);this.quill.focus();var i=this.quill.getSelection();if(i!=null){var a=F(this.quill.getLeaf(i.index),1)[0];if(a){if(fe(a))throw Error(`Not supported ${a.statics.blotName} insert into table.`);var o=G(),s=Array(n).fill(0).map(function(){return G()}),c=this.calculateTableCellBorderWidth(),l=getComputedStyle(this.quill.root),u=Number.parseInt(l.paddingLeft),d=Number.parseInt(l.paddingRight),f=this.quill.root.scrollHeight>this.quill.root.clientHeight?ur({target:this.quill.root}):0,p=Number.parseInt(l.width)-u-d-c-f,m=this.options.full?`${Math.max(1/n*100,z.colMinWidthPre)}%`:`${Math.max(Math.floor(p/n),z.colMinWidthPx)}px`,h=[{retain:i.index}],g=this.quill.getContents(i.index,1),_=F(this.quill.getLine(i.index),2)[1];g.ops[0].insert!==`
|
|
138
138
|
`&&_!==0&&h.push({insert:`
|
|
139
139
|
`});for(var v=0;v<n;v++)h.push({insert:x({},R.tableCol,{width:m,tableId:o,colId:s[v],full:this.options.full})});for(var y=0;y<e;y++)for(var b=G(),S=0;S<n;S++)h.push({insert:`
|
|
140
|
-
`,attributes:x({},R.tableCellInner,{tableId:o,rowId:b,colId:s[S],rowspan:1,colspan:1})});this.quill.updateContents(new
|
|
140
|
+
`,attributes:x({},R.tableCellInner,{tableId:o,rowId:b,colId:s[S],rowspan:1,colspan:1})});this.quill.updateContents(new ca(h),r),this.quill.setSelection(i.index+n,t.default.sources.SILENT),this.quill.focus()}}}},{key:`calculateTableCellBorderWidth`,value:function(){var e=`
|
|
141
141
|
<table class="${X.className}">
|
|
142
142
|
<tbody>
|
|
143
143
|
<tr>
|
|
@@ -145,5 +145,5 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
145
145
|
</tr>
|
|
146
146
|
</tbody>
|
|
147
147
|
</table>
|
|
148
|
-
`,t=document.createElement(`div`);t.className=Kr.className,t.innerHTML=e,t.style.position=`absolute`,t.style.left=`-9999px`,t.style.top=`-9999px`,t.style.visibility=`hidden`,this.quill.root.appendChild(t);var n=window.getComputedStyle(t.querySelector(`td`)),r=Number.parseFloat(n.borderWidth)||0;return this.quill.root.removeChild(t),r}},{key:`fixUnusuaDeletelTable`,value:function(e){var t=e.getColIds();if(t.length===0){e.remove();return}var n=e.getBodys(),r=e.tableId,i=b(n),a;try{for(i.s();!(a=i.n()).done;){var o=a.value,s=o.getRows();if(s.length===0){o.remove();continue}var c=Array(s.length).fill(0).map(function(){return Array(t.length).fill(!1)}),l=b(s.entries()),u;try{for(l.s();!(u=l.n()).done;){for(var d=F(u.value,2),f=d[0],p=d[1],m=0,h=0,g=c[f],_=p.descendants(Y);h<t.length;){if(g[h]){h+=1;continue}var v=_[m];if((v==null?void 0:v.colId)!==t[h])p.insertBefore(fa(this.quill.scroll,{tableId:r,colId:t[h],rowId:p.rowId}),v);else{f+v.rowspan-1>=s.length&&(v.getCellInner().rowspan=s.length-f);var y=v.colspan,x=v.rowspan;if(y>1)for(var S=1;S<y;S++)g[h+S]=!0;if(x>1)for(var C=f+1;C<f+x;C++)for(var w=0;w<y;w++)c[C][h+w]=!0;m+=1}h+=1}if(m<_.length)for(var T=m;T<_.length;T++)_[T].remove()}}catch(e){l.e(e)}finally{l.f()}}}catch(e){i.e(e)}finally{i.f()}}},{key:`balanceTables`,value:function(){var e=b(this.quill.scroll.descendants(X)),t;try{for(e.s();!(t=e.n()).done;){var n=t.value;n.checkEmptyCol(this.options.autoMergeCell),n.checkEmptyRow(this.options.autoMergeCell),this.fixUnusuaDeletelTable(n)}}catch(t){e.e(t)}finally{e.f()}}},{key:`listenBalanceCells`,value:function(){var e=this;this.quill.on(t.default.events.SCROLL_OPTIMIZE,function(n){n.some(function(t){return[`TD`,`TR`,`TBODY`,`TABLE`].includes(t.target.tagName)?(e.fixTableByLisenter(),!0):!1});var r=b(n),i;try{for(r.s();!(i=r.n()).done;){var a=i.value.target;if(a.tagName===`TABLE`){var o=t.default.find(a);if(o){o.sortMergeChildren();break}}}}catch(e){r.e(e)}finally{r.f()}})}},{key:`deleteTable`,value:function(e){if(e.length!==0){var t=U(e[0],R.tableMain);t==null||t.remove()}}},{key:`appendRow`,value:function(e,t){if(!(e.length<=0)){var n=e[t?e.length-1:0],r=F(pe(n,[R.tableMain,R.tableRow]),2),i=r[0],a=r[1],o=i.getRows().indexOf(a)+(t?n.rowspan:0);i.insertRow(o)}}},{key:`appendCol`,value:function(e,t){if(!(e.length<=0)){var n=F(e.reduce(function(e,n){var r=n.getColumnIndex();return(!t&&r<=e[1]||t&&r>=e[1])&&(e=[n,r]),e},[e[0],e[0].getColumnIndex()]),1)[0],r=n.getColumnIndex()+(t?n.colspan:0),i=U(n,R.tableMain),a=i.tableId,o=G(),s=F(i.descendants(Hr),1)[0];s&&s.insertColByIndex(r,{tableId:a,colId:o,width:i.full?6:160,full:i.full});for(var c=i.getRows(),l=[],u=0,d=0,f=Object.values(c);d<f.length;d++){var p=f[d],m=l.shift()||0;if(u>0){--u;continue}var h=p.insertCell(r-m,{tableId:a,rowId:p.rowId,colId:o,rowspan:1,colspan:1});h.skipRowNum&&(u+=h.skipRowNum);var g=b(h.entries()),_;try{for(g.s();!(_=g.n()).done;){var v=F(_.value,2),y=v[0],x=v[1];l[y]=(l[y]||0)+x}}catch(e){g.e(e)}finally{g.f()}}}}},{key:`fixTableByRemove`,value:function(e){if(this.options.autoMergeCell){var t=e.getRows(),n=e.getCols(),r=n.reduce(function(e,t){return e[t.colId]=0,e},{}),i=t.toReversed(),a=[],o=b(i.entries()),s;try{var c=function(){var e=F(s.value,2),n=e[0],i=e[1],o=t.length-n-1;i.children.length<=0?a.push(o):i.foreachCellInner(function(e){var t=a.reduce(function(t,n){return e.rowspan+o>n?t+1:t},0);e.rowspan-=t,r[e.colId]+=1})};for(o.s();!(s=o.n()).done;)c()}catch(e){o.e(e)}finally{o.f()}for(var l=0,u=0,d=Object.values(r);u<d.length;u++)if(d[u]===0)for(var f=[],p=0,m=0,h=Object.values(t);m<h.length;m++){var g=h[m],_=f.shift()||0,v=[];p>0?(v=g.getCellByColumIndex(l-_)[2],--p):(v=g.removeCell(l-_),v.skipRowNum&&(p+=v.skipRowNum));var y=b(v.entries()),x;try{for(y.s();!(x=y.n()).done;){var S=F(x.value,2),C=S[0],w=S[1];f[C]=(f[C]||0)+w}}catch(e){y.e(e)}finally{y.f()}}else l+=1;var T=b(n),E;try{for(T.s();!(E=T.n()).done;){var D=E.value;r[D.colId]===0&&(D.prev?D.prev.width+=D.width:D.next&&(D.next.width+=D.width),D.remove())}}catch(e){T.e(e)}finally{T.f()}}}},{key:`removeRow`,value:function(e){if(!(e.length<=0)){var t=e[0],n=U(t,R.tableMain),r=n.getRows(),i=r.length,a=-1,o=b(e),s;try{for(o.s();!(s=o.n()).done;){var c=s.value,l=U(c,R.tableRow),u=r.indexOf(l);u<i&&(i=u),u+c.rowspan>a&&(a=u+c.rowspan)}}catch(e){o.e(e)}finally{o.f()}for(var d={},f=function(e){var t=r[e];t.foreachCellInner(function(t){t.rowspan+e>a&&(d[t.colId]={rowspan:t.rowspan+e-a,colspan:t.colspan,colIndex:t.getColumnIndex()}),t.parent.remove()}),t.length()===0&&t.remove()},p=i;p<Math.min(r.length,a);p++)f(p);if(r[a])for(var m=r[a],h=n.tableId,g=0,_=Object.entries(d);g<_.length;g++){var v=F(_[g],2),y=v[0],x=v[1],S=x.colIndex,C=x.colspan,w=x.rowspan;m.insertCell(S,{tableId:h,rowId:m.rowId,colId:y,colspan:C,rowspan:w})}this.fixTableByRemove(n)}}},{key:`removeCol`,value:function(e){if(!(e.length<=0)){var t=e[0],n=U(t,R.tableMain),r={},i=b(e),a;try{for(i.s();!(a=i.n()).done;){var o=a.value;r[o.rowId]||(r[o.rowId]=0),r[o.rowId]+=o.colspan}}catch(e){i.e(e)}finally{i.f()}for(var s=Math.max.apply(Math,L(Object.values(r))),c=t.getColumnIndex(),l=n.descendants(J),u=0;u<s;u++)for(var d=[],f=0,p=0,m=Object.values(l);p<m.length;p++){var h=m[p],g=d.shift()||0;if(f>0){--f;continue}var _=h.removeCell(c-g);_.skipRowNum&&(f+=_.skipRowNum);var v=b(_.entries()),y;try{for(v.s();!(y=v.n()).done;){var x=F(y.value,2),S=x[0],C=x[1];d[S]=(d[S]||0)+C}}catch(e){v.e(e)}finally{v.f()}}var w=F(n.descendants(Hr),1)[0];if(w)for(var T=0;T<s;T++)w.removeColByIndex(c);this.fixTableByRemove(n)}}},{key:`mergeCells`,value:function(e){if(!(e.length<=1)){var n=e[0],r=n.getTableBody(),i=n.getTableRow();if(!(!r||!i)){for(var a=1;a<e.length;a++){var o=e[a],s=o.getTableBody();if(s&&s!==r){var c=o.getTableRow();c&&(i.parent.insertBefore(c,i.next),i=c)}}r.convertBody(n.wrapTag);var l=e.reduce(function(e,t,n){var r=t.colId;e[0][r]||(e[0][r]=0),e[0][r]+=t.rowspan;var i=t.rowId;return e[1][i]||(e[1][i]=0),e[1][i]+=t.colspan,n!==0&&(t.length()>1&&t.moveChildren(e[2]),t.parent.remove()),e},[{},{},n]),u=Math.max.apply(Math,L(Object.values(l[0]))),d=Math.max.apply(Math,L(Object.values(l[1]))),f=l[2];f.colspan=d,f.rowspan=u;var p=this.quill.getIndex(f);this.quill.setSelection({index:p,length:0},t.default.sources.SILENT);var m=U(f,R.tableMain);this.fixTableByRemove(m)}}}},{key:`splitCell`,value:function(e){if(e.length===1){var t=e[0];if(!(t.colspan===1&&t.rowspan===1)){var n=F(pe(t,[R.tableMain,R.tableRow]),2),r=n[0],i=n[1],a=r.getRows(),o=r.tableId,s=t.getColumnIndex(),c=r.getColIds().slice(s,s+t.colspan).toReversed(),l=t.formats()[R.tableCellInner];l.emptyRow;var u=M(l,aa),d=a.indexOf(i);if(d!==-1){var f=a[d],p=t.rowspan;for(t.colspan=1,t.rowspan=1;f&&p>0;){var m=b(c),h;try{for(m.s();!(h=m.n()).done;){var g=h.value;f===i&&g===t.colId||f.insertCell(s+(f===i?1:0),j(j({},u),{},{tableId:o,rowId:f.rowId,colId:g,rowspan:1,colspan:1}))}}catch(e){m.e(e)}finally{m.f()}--p,d+=1,f=a[d]}}}}}},{key:`convertTableBodyByCells`,value:function(e,t,n){var r,i,a=e.getRows(),o=b(t),s;try{for(o.s();!(s=o.n()).done;){var c=s.value.getTableRow();if(c){var l=a.indexOf(c);je(r)&&(r=l),je(i)&&(i=l),l<r?(i=r,r=l):l>i&&(i=l)}}}catch(e){o.e(e)}finally{o.f()}if(je(r)||je(i)){console.warn(`TableRow not found`);return}var u=a[r],d=a[i];e.split(d.offset(e)+d.length());var f=e.split(u.offset(e)),p=f.getRows(),m=F(f.getBodys(),1)[0],h=m.clone();f.appendChild(h);var g=b(p),_;try{for(g.s();!(_=g.n()).done;){var v=_.value;v.length()>0&&h.appendChild(v)}}catch(e){g.e(e)}finally{g.f()}h.convertBody(n),m.remove()}}],[{key:`register`,value:function(){var e;Kr.allowedChildren=[X],X.allowedChildren=[Hr,Br,Wr,jr,Ur],X.requiredContainer=Kr,Br.requiredContainer=X,Hr.allowedChildren=[Vr],Hr.requiredContainer=X,Wr.allowedChildren=[J],Wr.requiredContainer=X,jr.allowedChildren=[J],jr.requiredContainer=X,Ur.allowedChildren=[J],Ur.requiredContainer=X,J.allowedChildren=[Y],Y.allowedChildren=[q,la],Y.requiredContainer=J,q.requiredContainer=Y;var n=new Set([`table`]),r=Object.entries(t.default.imports).filter(function(e){var t=F(e,2),r=t[0],i=t[1],a=r.split(`formats/`)[1];return r.startsWith(`formats/`)&&!n.has(a)&&(ve(i,ua)||ve(i,da))}).reduce(function(e,t){var n=F(t,2),r=n[0],i=n[1];return e[r]=function(e){function t(){return _(this,t),g(this,t,arguments)}return w(t,e),y(t,null,[{key:`register`,value:function(){}}])}(_e(i,[ve(i,da)?kr:Or])),e},{});t.default.register(j(j({"blots/scroll":Fr,"blots/block":Or,"blots/block/embed":kr},r),{},(e={},x(x(x(x(x(x(x(x(x(x(e,`blots/${R.container}`,K),`formats/${R.tableCell}`,Y),`formats/${R.tableCellInner}`,q),`formats/${R.tableRow}`,J),`formats/${R.tableHead}`,Wr),`formats/${R.tableBody}`,jr),`formats/${R.tableFoot}`,Ur),`formats/${R.tableCol}`,Vr),`formats/${R.tableColgroup}`,Hr),`formats/${R.tableCaption}`,Br),x(x(x(e,`formats/${R.tableMain}`,X),`formats/${R.tableWrapper}`,Kr),`modules/clipboard`,hi))),!0)}}])}();x(ga,`moduleName`,V.moduleName),x(ga,`toolName`,R.tableWrapper),x(ga,`keyboradHandler`,{"forbid remove table by backspace":{bindInHead:!0,key:`Backspace`,collapsed:!0,offset:0,handler:function(e,t){var n=this.quill.getLine(e.index)[0];return n.prev instanceof Kr?(n.prev.remove(),!1):!(t.format[R.tableCellInner]&&n.offset(U(n,R.tableCellInner))===0)}},"forbid remove table by delete":{bindInHead:!0,key:`Delete`,collapsed:!0,handler:function(e,t){var n=this.quill.getLine(e.index),r=n[0],i=n[1];return!((r.next instanceof Kr||r.next instanceof Vr)&&i===r.length()-1||t.format[R.tableCellInner]&&r===U(r,R.tableCellInner).children.tail&&i===r.length()-1)}},"table up":ha(!0),"table down":ha(!1),"table caption break":{bindInHead:!0,key:`Enter`,shiftKey:null,format:[R.tableCaption],handler:function(e,t){return!1}}});var _a=ga;e.BlockEmbedOverride=kr,e.BlockOverride=Or,e.ContainerFormat=K,e.ScrollOverride=Fr,e.Scrollbar=$i,e.TableAlign=Jr,e.TableBodyFormat=jr,e.TableCaptionFormat=Br,e.TableCellFormat=Y,e.TableCellInnerFormat=q,e.TableClipboard=hi,e.TableColFormat=Vr,e.TableColgroupFormat=Hr,e.TableDomSelector=qr,e.TableFootFormat=Ur,e.TableHeadFormat=Wr,e.TableMainFormat=X,e.TableMenuCommon=Li,e.TableMenuContextmenu=Ri,e.TableMenuSelect=zi,e.TableResizeBox=Ji,e.TableResizeCommon=Wi,e.TableResizeCommonHelper=Ui,e.TableResizeLine=Yi,e.TableResizeScale=Xi,e.TableRowFormat=J,e.TableSelection=na,e.TableUp=ga,e.TableVirtualScrollbar=ea,e.TableWrapperFormat=Kr,e.applyCellUpdates=ai,e.blotName=R,e.createColorPicker=Fe,e.createSelectBox=Ue,e.createTooltip=$n,e.default=_a,e.defaultCustomSelect=ma,e.findParentBlot=U,e.findParentBlots=pe,e.getCellPositions=ti,e.getColRect=Vi,e.getCountByPosition=$r,e.getTableCellStructure=Zr,e.getTableMainRect=Z,e.groupCellByRow=ni,e.isCellsSpan=Hi,e.isTableAlignRight=Bi,e.parsePasteDelta=Qr,e.pasteCells=Xr,e.pasteWithLoop=ri,e.pasteWithStructure=ei,e.prepareCellUpdate=ii,e.randomId=G,e.removeOverlappingCells=oi,e.tableMenuTools=Q,e.tableUpEvent=B,e.tableUpInternal=V,e.tableUpSize=z,e.updateTableConstants=pa});
|
|
148
|
+
`,t=document.createElement(`div`);t.className=Kr.className,t.innerHTML=e,t.style.position=`absolute`,t.style.left=`-9999px`,t.style.top=`-9999px`,t.style.visibility=`hidden`,this.quill.root.appendChild(t);var n=window.getComputedStyle(t.querySelector(`td`)),r=Number.parseFloat(n.borderWidth)||0;return this.quill.root.removeChild(t),r}},{key:`fixUnusuaDeletelTable`,value:function(e){var t=e.getColIds();if(t.length===0){e.remove();return}var n=e.getBodys(),r=e.tableId,i=b(n),a;try{for(i.s();!(a=i.n()).done;){var o=a.value,s=o.getRows();if(s.length===0){o.remove();continue}var c=Array(s.length).fill(0).map(function(){return Array(t.length).fill(!1)}),l=b(s.entries()),u;try{for(l.s();!(u=l.n()).done;){for(var d=F(u.value,2),f=d[0],p=d[1],m=0,h=0,g=c[f],_=p.descendants(Y);h<t.length;){if(g[h]){h+=1;continue}var v=_[m];if((v==null?void 0:v.colId)!==t[h])p.insertBefore(pa(this.quill.scroll,{tableId:r,colId:t[h],rowId:p.rowId}),v);else{f+v.rowspan-1>=s.length&&(v.getCellInner().rowspan=s.length-f);var y=v.colspan,x=v.rowspan;if(y>1)for(var S=1;S<y;S++)g[h+S]=!0;if(x>1)for(var C=f+1;C<f+x;C++)for(var w=0;w<y;w++)c[C][h+w]=!0;m+=1}h+=1}if(m<_.length)for(var T=m;T<_.length;T++)_[T].remove()}}catch(e){l.e(e)}finally{l.f()}}}catch(e){i.e(e)}finally{i.f()}}},{key:`balanceTables`,value:function(){var e=b(this.quill.scroll.descendants(X)),t;try{for(e.s();!(t=e.n()).done;){var n=t.value;n.checkEmptyCol(this.options.autoMergeCell),n.checkEmptyRow(this.options.autoMergeCell),this.fixUnusuaDeletelTable(n)}}catch(t){e.e(t)}finally{e.f()}}},{key:`listenBalanceCells`,value:function(){var e=this;this.quill.on(t.default.events.SCROLL_OPTIMIZE,function(n){n.some(function(t){return[`TD`,`TR`,`TBODY`,`TABLE`].includes(t.target.tagName)?(e.fixTableByLisenter(),!0):!1});var r=b(n),i;try{for(r.s();!(i=r.n()).done;){var a=i.value.target;if(a.tagName===`TABLE`){var o=t.default.find(a);if(o){o.sortMergeChildren();break}}}}catch(e){r.e(e)}finally{r.f()}})}},{key:`deleteTable`,value:function(e){if(e.length!==0){var t=U(e[0],R.tableMain);t==null||t.remove()}}},{key:`appendRow`,value:function(e,t){if(!(e.length<=0)){var n=e[t?e.length-1:0],r=F(pe(n,[R.tableMain,R.tableRow]),2),i=r[0],a=r[1],o=i.getRows().indexOf(a)+(t?n.rowspan:0);i.insertRow(o)}}},{key:`appendCol`,value:function(e,t){if(!(e.length<=0)){var n=F(e.reduce(function(e,n){var r=n.getColumnIndex();return(!t&&r<=e[1]||t&&r>=e[1])&&(e=[n,r]),e},[e[0],e[0].getColumnIndex()]),1)[0],r=n.getColumnIndex()+(t?n.colspan:0),i=U(n,R.tableMain),a=i.tableId,o=G(),s=F(i.descendants(Hr),1)[0];s&&s.insertColByIndex(r,{tableId:a,colId:o,width:i.full?6:160,full:i.full});for(var c=i.getRows(),l=[],u=0,d=0,f=Object.values(c);d<f.length;d++){var p=f[d],m=l.shift()||0;if(u>0){--u;continue}var h=p.insertCell(r-m,{tableId:a,rowId:p.rowId,colId:o,rowspan:1,colspan:1});h.skipRowNum&&(u+=h.skipRowNum);var g=b(h.entries()),_;try{for(g.s();!(_=g.n()).done;){var v=F(_.value,2),y=v[0],x=v[1];l[y]=(l[y]||0)+x}}catch(e){g.e(e)}finally{g.f()}}}}},{key:`fixTableByRemove`,value:function(e){if(this.options.autoMergeCell){var t=e.getRows(),n=e.getCols(),r=n.reduce(function(e,t){return e[t.colId]=0,e},{}),i=t.toReversed(),a=[],o=b(i.entries()),s;try{var c=function(){var e=F(s.value,2),n=e[0],i=e[1],o=t.length-n-1;i.children.length<=0?a.push(o):i.foreachCellInner(function(e){var t=a.reduce(function(t,n){return e.rowspan+o>n?t+1:t},0);e.rowspan-=t,r[e.colId]+=1})};for(o.s();!(s=o.n()).done;)c()}catch(e){o.e(e)}finally{o.f()}for(var l=0,u=0,d=Object.values(r);u<d.length;u++)if(d[u]===0)for(var f=[],p=0,m=0,h=Object.values(t);m<h.length;m++){var g=h[m],_=f.shift()||0,v=[];p>0?(v=g.getCellByColumIndex(l-_)[2],--p):(v=g.removeCell(l-_),v.skipRowNum&&(p+=v.skipRowNum));var y=b(v.entries()),x;try{for(y.s();!(x=y.n()).done;){var S=F(x.value,2),C=S[0],w=S[1];f[C]=(f[C]||0)+w}}catch(e){y.e(e)}finally{y.f()}}else l+=1;var T=b(n),E;try{for(T.s();!(E=T.n()).done;){var D=E.value;r[D.colId]===0&&(D.prev?D.prev.width+=D.width:D.next&&(D.next.width+=D.width),D.remove())}}catch(e){T.e(e)}finally{T.f()}}}},{key:`removeRow`,value:function(e){if(!(e.length<=0)){var t=e[0],n=U(t,R.tableMain),r=n.getRows(),i=r.length,a=-1,o=b(e),s;try{for(o.s();!(s=o.n()).done;){var c=s.value,l=U(c,R.tableRow),u=r.indexOf(l);u<i&&(i=u),u+c.rowspan>a&&(a=u+c.rowspan)}}catch(e){o.e(e)}finally{o.f()}for(var d={},f=function(e){var t=r[e];t.foreachCellInner(function(t){t.rowspan+e>a&&(d[t.colId]={rowspan:t.rowspan+e-a,colspan:t.colspan,colIndex:t.getColumnIndex()}),t.parent.remove()}),t.length()===0&&t.remove()},p=i;p<Math.min(r.length,a);p++)f(p);if(r[a])for(var m=r[a],h=n.tableId,g=0,_=Object.entries(d);g<_.length;g++){var v=F(_[g],2),y=v[0],x=v[1],S=x.colIndex,C=x.colspan,w=x.rowspan;m.insertCell(S,{tableId:h,rowId:m.rowId,colId:y,colspan:C,rowspan:w})}this.fixTableByRemove(n)}}},{key:`removeCol`,value:function(e){if(!(e.length<=0)){var t=e[0],n=U(t,R.tableMain),r={},i=b(e),a;try{for(i.s();!(a=i.n()).done;){var o=a.value;r[o.rowId]||(r[o.rowId]=0),r[o.rowId]+=o.colspan}}catch(e){i.e(e)}finally{i.f()}for(var s=Math.max.apply(Math,L(Object.values(r))),c=t.getColumnIndex(),l=n.descendants(J),u=0;u<s;u++)for(var d=[],f=0,p=0,m=Object.values(l);p<m.length;p++){var h=m[p],g=d.shift()||0;if(f>0){--f;continue}var _=h.removeCell(c-g);_.skipRowNum&&(f+=_.skipRowNum);var v=b(_.entries()),y;try{for(v.s();!(y=v.n()).done;){var x=F(y.value,2),S=x[0],C=x[1];d[S]=(d[S]||0)+C}}catch(e){v.e(e)}finally{v.f()}}var w=F(n.descendants(Hr),1)[0];if(w)for(var T=0;T<s;T++)w.removeColByIndex(c);this.fixTableByRemove(n)}}},{key:`mergeCells`,value:function(e){if(!(e.length<=1)){var n=e[0],r=n.getTableBody(),i=n.getTableRow();if(!(!r||!i)){for(var a=1;a<e.length;a++){var o=e[a],s=o.getTableBody();if(s&&s!==r){var c=o.getTableRow();c&&(i.parent.insertBefore(c,i.next),i=c)}}r.convertBody(n.wrapTag);var l=e.reduce(function(e,t,n){var r=t.colId;e[0][r]||(e[0][r]=0),e[0][r]+=t.rowspan;var i=t.rowId;return e[1][i]||(e[1][i]=0),e[1][i]+=t.colspan,n!==0&&(t.length()>1&&t.moveChildren(e[2]),t.parent.remove()),e},[{},{},n]),u=Math.max.apply(Math,L(Object.values(l[0]))),d=Math.max.apply(Math,L(Object.values(l[1]))),f=l[2];f.colspan=d,f.rowspan=u;var p=this.quill.getIndex(f);this.quill.setSelection({index:p,length:0},t.default.sources.SILENT);var m=U(f,R.tableMain);this.fixTableByRemove(m)}}}},{key:`splitCell`,value:function(e){if(e.length===1){var t=e[0];if(!(t.colspan===1&&t.rowspan===1)){var n=F(pe(t,[R.tableMain,R.tableRow]),2),r=n[0],i=n[1],a=r.getRows(),o=r.tableId,s=t.getColumnIndex(),c=r.getColIds().slice(s,s+t.colspan).toReversed(),l=t.formats()[R.tableCellInner];l.emptyRow;var u=M(l,oa),d=a.indexOf(i);if(d!==-1){var f=a[d],p=t.rowspan;for(t.colspan=1,t.rowspan=1;f&&p>0;){var m=b(c),h;try{for(m.s();!(h=m.n()).done;){var g=h.value;f===i&&g===t.colId||f.insertCell(s+(f===i?1:0),j(j({},u),{},{tableId:o,rowId:f.rowId,colId:g,rowspan:1,colspan:1}))}}catch(e){m.e(e)}finally{m.f()}--p,d+=1,f=a[d]}}}}}},{key:`convertTableBodyByCells`,value:function(e,t,n){var r,i,a=e.getRows(),o=b(t),s;try{for(o.s();!(s=o.n()).done;){var c=s.value.getTableRow();if(c){var l=a.indexOf(c);je(r)&&(r=l),je(i)&&(i=l),l<r?(i=r,r=l):l>i&&(i=l)}}}catch(e){o.e(e)}finally{o.f()}if(je(r)||je(i)){console.warn(`TableRow not found`);return}var u=a[r],d=a[i];e.split(d.offset(e)+d.length());var f=e.split(u.offset(e)),p=f.getRows(),m=F(f.getBodys(),1)[0],h=m.clone();f.appendChild(h);var g=b(p),_;try{for(g.s();!(_=g.n()).done;){var v=_.value;v.length()>0&&h.appendChild(v)}}catch(e){g.e(e)}finally{g.f()}h.convertBody(n),m.remove()}}],[{key:`register`,value:function(){var e;Kr.allowedChildren=[X],X.allowedChildren=[Hr,Br,Wr,jr,Ur],X.requiredContainer=Kr,Br.requiredContainer=X,Hr.allowedChildren=[Vr],Hr.requiredContainer=X,Wr.allowedChildren=[J],Wr.requiredContainer=X,jr.allowedChildren=[J],jr.requiredContainer=X,Ur.allowedChildren=[J],Ur.requiredContainer=X,J.allowedChildren=[Y],Y.allowedChildren=[q,ua],Y.requiredContainer=J,q.requiredContainer=Y;var n=new Set([`table`]),r=Object.entries(t.default.imports).filter(function(e){var t=F(e,2),r=t[0],i=t[1],a=r.split(`formats/`)[1];return r.startsWith(`formats/`)&&!n.has(a)&&(ve(i,da)||ve(i,fa))}).reduce(function(e,t){var n=F(t,2),r=n[0],i=n[1];return e[r]=function(e){function t(){return _(this,t),g(this,t,arguments)}return w(t,e),y(t,null,[{key:`register`,value:function(){}}])}(_e(i,[ve(i,fa)?kr:Or])),e},{});t.default.register(j(j({"blots/scroll":Fr,"blots/block":Or,"blots/block/embed":kr},r),{},(e={},x(x(x(x(x(x(x(x(x(x(e,`blots/${R.container}`,K),`formats/${R.tableCell}`,Y),`formats/${R.tableCellInner}`,q),`formats/${R.tableRow}`,J),`formats/${R.tableHead}`,Wr),`formats/${R.tableBody}`,jr),`formats/${R.tableFoot}`,Ur),`formats/${R.tableCol}`,Vr),`formats/${R.tableColgroup}`,Hr),`formats/${R.tableCaption}`,Br),x(x(x(e,`formats/${R.tableMain}`,X),`formats/${R.tableWrapper}`,Kr),`modules/clipboard`,hi))),!0)}}])}();x(_a,`moduleName`,V.moduleName),x(_a,`toolName`,R.tableWrapper),x(_a,`keyboradHandler`,{"forbid remove table by backspace":{bindInHead:!0,key:`Backspace`,collapsed:!0,offset:0,handler:function(e,t){var n=this.quill.getLine(e.index)[0];return n.prev instanceof Kr?(n.prev.remove(),!1):!(t.format[R.tableCellInner]&&n.offset(U(n,R.tableCellInner))===0)}},"forbid remove table by delete":{bindInHead:!0,key:`Delete`,collapsed:!0,handler:function(e,t){var n=this.quill.getLine(e.index),r=n[0],i=n[1];return!((r.next instanceof Kr||r.next instanceof Vr)&&i===r.length()-1||t.format[R.tableCellInner]&&r===U(r,R.tableCellInner).children.tail&&i===r.length()-1)}},"table up":ga(!0),"table down":ga(!1),"table caption break":{bindInHead:!0,key:`Enter`,shiftKey:null,format:[R.tableCaption],handler:function(e,t){return!1}}});var va=_a;e.BlockEmbedOverride=kr,e.BlockOverride=Or,e.ContainerFormat=K,e.ScrollOverride=Fr,e.Scrollbar=$i,e.TableAlign=Jr,e.TableBodyFormat=jr,e.TableCaptionFormat=Br,e.TableCellFormat=Y,e.TableCellInnerFormat=q,e.TableClipboard=hi,e.TableColFormat=Vr,e.TableColgroupFormat=Hr,e.TableDomSelector=qr,e.TableFootFormat=Ur,e.TableHeadFormat=Wr,e.TableMainFormat=X,e.TableMenuCommon=Li,e.TableMenuContextmenu=Ri,e.TableMenuSelect=zi,e.TableResizeBox=Ji,e.TableResizeCommon=Wi,e.TableResizeCommonHelper=Ui,e.TableResizeLine=Yi,e.TableResizeScale=Xi,e.TableRowFormat=J,e.TableSelection=na,e.TableUp=_a,e.TableVirtualScrollbar=ea,e.TableWrapperFormat=Kr,e.applyCellUpdates=ai,e.blotName=R,e.createColorPicker=Fe,e.createSelectBox=Ue,e.createTooltip=$n,e.default=va,e.defaultCustomSelect=ha,e.findParentBlot=U,e.findParentBlots=pe,e.getCellPositions=ti,e.getColRect=Vi,e.getCountByPosition=$r,e.getTableCellStructure=Zr,e.getTableMainRect=Z,e.groupCellByRow=ni,e.isCellsSpan=Hi,e.isTableAlignRight=Bi,e.parsePasteDelta=Qr,e.pasteCells=Xr,e.pasteWithLoop=ri,e.pasteWithStructure=ei,e.prepareCellUpdate=ii,e.randomId=G,e.removeOverlappingCells=oi,e.tableMenuTools=Q,e.tableUpEvent=B,e.tableUpInternal=V,e.tableUpSize=z,e.updateTableConstants=ma});
|
|
149
149
|
//# sourceMappingURL=index.umd.js.map
|