quill-better-table
Advanced tools
Comparing version 1.1.12 to 1.1.13
@@ -1,1 +0,1 @@ | ||
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("quill")):"function"==typeof define&&define.amd?define(["quill"],t):"object"==typeof exports?exports.quillBetterTable=t(require("quill")):e.quillBetterTable=t(e.Quill)}(window,function(e){return function(e){var t=window.webpackHotUpdatequillBetterTable;window.webpackHotUpdatequillBetterTable=function(e,o){!function(e,t){if(!N[e]||!x[e])return;for(var o in x[e]=!1,t)Object.prototype.hasOwnProperty.call(t,o)&&(b[o]=t[o]);0==--g&&0===y&&E()}(e,o),t&&t(e,o)};var o,n=!0,r="a4cefed99bbf101506f4",i=1e4,l={},s=[],a=[];function c(e){var t=A[e];if(!t)return S;var n=function(n){return t.hot.active?(A[n]?-1===A[n].parents.indexOf(e)&&A[n].parents.push(e):(s=[e],o=n),-1===t.children.indexOf(n)&&t.children.push(n)):(console.warn("[HMR] unexpected require("+n+") from disposed module "+e),s=[]),S(n)},r=function(e){return{configurable:!0,enumerable:!0,get:function(){return S[e]},set:function(t){S[e]=t}}};for(var i in S)Object.prototype.hasOwnProperty.call(S,i)&&"e"!==i&&"t"!==i&&Object.defineProperty(n,i,r(i));return n.e=function(e){return"ready"===h&&p("prepare"),y++,S.e(e).then(t,function(e){throw t(),e});function t(){y--,"prepare"===h&&(w[e]||v(e),0===y&&0===g&&E())}},n.t=function(e,t){return 1&t&&(e=n(e)),S.t(e,-2&t)},n}function d(e){var t={_acceptedDependencies:{},_declinedDependencies:{},_selfAccepted:!1,_selfDeclined:!1,_disposeHandlers:[],_main:o!==e,active:!0,accept:function(e,o){if(void 0===e)t._selfAccepted=!0;else if("function"==typeof e)t._selfAccepted=e;else if("object"==typeof e)for(var n=0;n<e.length;n++)t._acceptedDependencies[e[n]]=o||function(){};else t._acceptedDependencies[e]=o||function(){}},decline:function(e){if(void 0===e)t._selfDeclined=!0;else if("object"==typeof e)for(var o=0;o<e.length;o++)t._declinedDependencies[e[o]]=!0;else t._declinedDependencies[e]=!0},dispose:function(e){t._disposeHandlers.push(e)},addDisposeHandler:function(e){t._disposeHandlers.push(e)},removeDisposeHandler:function(e){var o=t._disposeHandlers.indexOf(e);o>=0&&t._disposeHandlers.splice(o,1)},check:q,apply:T,status:function(e){if(!e)return h;u.push(e)},addStatusHandler:function(e){u.push(e)},removeStatusHandler:function(e){var t=u.indexOf(e);t>=0&&u.splice(t,1)},data:l[e]};return o=void 0,t}var u=[],h="idle";function p(e){h=e;for(var t=0;t<u.length;t++)u[t].call(null,e)}var f,b,m,g=0,y=0,w={},x={},N={};function C(e){return+e+""===e?+e:e}function q(e){if("idle"!==h)throw new Error("check() is only allowed in idle status");return n=e,p("check"),(t=i,t=t||1e4,new Promise(function(e,o){if("undefined"==typeof XMLHttpRequest)return o(new Error("No browser support"));try{var n=new XMLHttpRequest,i=S.p+""+r+".hot-update.json";n.open("GET",i,!0),n.timeout=t,n.send(null)}catch(e){return o(e)}n.onreadystatechange=function(){if(4===n.readyState)if(0===n.status)o(new Error("Manifest request to "+i+" timed out."));else if(404===n.status)e();else if(200!==n.status&&304!==n.status)o(new Error("Manifest request to "+i+" failed."));else{try{var t=JSON.parse(n.responseText)}catch(e){return void o(e)}e(t)}}})).then(function(e){if(!e)return p("idle"),null;x={},w={},N=e.c,m=e.h,p("prepare");var t=new Promise(function(e,t){f={resolve:e,reject:t}});b={};return v(0),"prepare"===h&&0===y&&0===g&&E(),t});var t}function v(e){N[e]?(x[e]=!0,g++,function(e){var t=document.createElement("script");t.charset="utf-8",t.src=S.p+""+e+"."+r+".hot-update.js",document.head.appendChild(t)}(e)):w[e]=!0}function E(){p("ready");var e=f;if(f=null,e)if(n)Promise.resolve().then(function(){return T(n)}).then(function(t){e.resolve(t)},function(t){e.reject(t)});else{var t=[];for(var o in b)Object.prototype.hasOwnProperty.call(b,o)&&t.push(C(o));e.resolve(t)}}function T(t){if("ready"!==h)throw new Error("apply() is only allowed in ready status");var o,n,i,a,c;function d(e){for(var t=[e],o={},n=t.map(function(e){return{chain:[e],id:e}});n.length>0;){var r=n.pop(),i=r.id,l=r.chain;if((a=A[i])&&!a.hot._selfAccepted){if(a.hot._selfDeclined)return{type:"self-declined",chain:l,moduleId:i};if(a.hot._main)return{type:"unaccepted",chain:l,moduleId:i};for(var s=0;s<a.parents.length;s++){var c=a.parents[s],d=A[c];if(d){if(d.hot._declinedDependencies[i])return{type:"declined",chain:l.concat([c]),moduleId:i,parentId:c};-1===t.indexOf(c)&&(d.hot._acceptedDependencies[i]?(o[c]||(o[c]=[]),u(o[c],[i])):(delete o[c],t.push(c),n.push({chain:l.concat([c]),id:c})))}}}}return{type:"accepted",moduleId:e,outdatedModules:t,outdatedDependencies:o}}function u(e,t){for(var o=0;o<t.length;o++){var n=t[o];-1===e.indexOf(n)&&e.push(n)}}t=t||{};var f={},g=[],y={},w=function(){console.warn("[HMR] unexpected require("+q.moduleId+") to disposed module")};for(var x in b)if(Object.prototype.hasOwnProperty.call(b,x)){var q;c=C(x);var v=!1,E=!1,T=!1,O="";switch((q=b[x]?d(c):{type:"disposed",moduleId:x}).chain&&(O="\nUpdate propagation: "+q.chain.join(" -> ")),q.type){case"self-declined":t.onDeclined&&t.onDeclined(q),t.ignoreDeclined||(v=new Error("Aborted because of self decline: "+q.moduleId+O));break;case"declined":t.onDeclined&&t.onDeclined(q),t.ignoreDeclined||(v=new Error("Aborted because of declined dependency: "+q.moduleId+" in "+q.parentId+O));break;case"unaccepted":t.onUnaccepted&&t.onUnaccepted(q),t.ignoreUnaccepted||(v=new Error("Aborted because "+c+" is not accepted"+O));break;case"accepted":t.onAccepted&&t.onAccepted(q),E=!0;break;case"disposed":t.onDisposed&&t.onDisposed(q),T=!0;break;default:throw new Error("Unexception type "+q.type)}if(v)return p("abort"),Promise.reject(v);if(E)for(c in y[c]=b[c],u(g,q.outdatedModules),q.outdatedDependencies)Object.prototype.hasOwnProperty.call(q.outdatedDependencies,c)&&(f[c]||(f[c]=[]),u(f[c],q.outdatedDependencies[c]));T&&(u(g,[q.moduleId]),y[c]=w)}var B,R=[];for(n=0;n<g.length;n++)c=g[n],A[c]&&A[c].hot._selfAccepted&&y[c]!==w&&R.push({module:c,errorHandler:A[c].hot._selfAccepted});p("dispose"),Object.keys(N).forEach(function(e){!1===N[e]&&function(e){delete installedChunks[e]}(e)});for(var L,M,I=g.slice();I.length>0;)if(c=I.pop(),a=A[c]){var k={},H=a.hot._disposeHandlers;for(i=0;i<H.length;i++)(o=H[i])(k);for(l[c]=k,a.hot.active=!1,delete A[c],delete f[c],i=0;i<a.children.length;i++){var D=A[a.children[i]];D&&((B=D.parents.indexOf(c))>=0&&D.parents.splice(B,1))}}for(c in f)if(Object.prototype.hasOwnProperty.call(f,c)&&(a=A[c]))for(M=f[c],i=0;i<M.length;i++)L=M[i],(B=a.children.indexOf(L))>=0&&a.children.splice(B,1);for(c in p("apply"),r=m,y)Object.prototype.hasOwnProperty.call(y,c)&&(e[c]=y[c]);var j=null;for(c in f)if(Object.prototype.hasOwnProperty.call(f,c)&&(a=A[c])){M=f[c];var _=[];for(n=0;n<M.length;n++)if(L=M[n],o=a.hot._acceptedDependencies[L]){if(-1!==_.indexOf(o))continue;_.push(o)}for(n=0;n<_.length;n++){o=_[n];try{o(M)}catch(e){t.onErrored&&t.onErrored({type:"accept-errored",moduleId:c,dependencyId:M[n],error:e}),t.ignoreErrored||j||(j=e)}}}for(n=0;n<R.length;n++){var U=R[n];c=U.module,s=[c];try{S(c)}catch(e){if("function"==typeof U.errorHandler)try{U.errorHandler(e)}catch(o){t.onErrored&&t.onErrored({type:"self-accept-error-handler-errored",moduleId:c,error:o,originalError:e}),t.ignoreErrored||j||(j=o),j||(j=e)}else t.onErrored&&t.onErrored({type:"self-accept-errored",moduleId:c,error:e}),t.ignoreErrored||j||(j=e)}}return j?(p("fail"),Promise.reject(j)):(p("idle"),new Promise(function(e){e(g)}))}var A={};function S(t){if(A[t])return A[t].exports;var o=A[t]={i:t,l:!1,exports:{},hot:d(t),parents:(a=s,s=[],a),children:[]};return e[t].call(o.exports,o,o.exports,c(t)),o.l=!0,o.exports}return S.m=e,S.c=A,S.d=function(e,t,o){S.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:o})},S.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},S.t=function(e,t){if(1&t&&(e=S(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var o=Object.create(null);if(S.r(o),Object.defineProperty(o,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var n in e)S.d(o,n,function(t){return e[t]}.bind(null,n));return o},S.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return S.d(t,"a",t),t},S.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},S.p="",S.h=function(){return r},c(1)(S.s=1)}([function(t,o){t.exports=e},function(e,t,o){e.exports=o(2)},function(e,t,o){"use strict";o.r(t);var n=o(0),r=o.n(n);function i(e,t){if("object"==typeof t)for(let o in t)e.style[o]=t[o]}function l(e,t){let o=t.getBoundingClientRect();return{x:e.x-o.x-t.scrollLeft,y:e.y-o.y-t.scrollTop,x1:e.x-o.x-t.scrollLeft+e.width,y1:e.y-o.y-t.scrollTop+e.height,width:e.width,height:e.height}}function s(e,t){return e&&Object.keys(e).reduce((o,n)=>t.includes(n)?o:Object.assign({},o,{[n]:e[n]}),{})}function a(e){let t;if(null==(t=e.path||e.composedPath&&e.composedPath())&&e.target){t=[];let o=e.target;for(t.push(o);o&&o.parentNode;)o=o.parentNode,t.push(o)}return t}const c=12,d=12,u=50,h="#35A7ED";class p{constructor(e,t,o){if(!e)return null;this.table=e,this.quill=t,this.options=o,this.domNode=null,this.initColTool()}initColTool(){const e=this.quill.root.parentNode,t=(this.table.getBoundingClientRect(),e.getBoundingClientRect()),o=this.table.parentNode.getBoundingClientRect();this.domNode=document.createElement("div"),this.domNode.classList.add("qlbt-col-tool"),this.updateToolCells(),e.appendChild(this.domNode),i(this.domNode,{width:"".concat(o.width,"px"),height:"".concat(c,"px"),left:"".concat(o.left-t.left+e.scrollLeft,"px"),top:"".concat(o.top-t.top+e.scrollTop-c-5,"px")})}createToolCell(){const e=document.createElement("div");e.classList.add("qlbt-col-tool-cell");const t=document.createElement("div");return t.classList.add("qlbt-col-tool-cell-holder"),i(e,{height:"".concat(d,"px")}),e.appendChild(t),e}updateToolCells(){const e=r.a.find(this.table),t=e.children.tail.children.head.children,o=e.colGroup().children,n=function(e){return e.reduce((e,t)=>{const o=t.formats().colspan;return e+=parseInt(o,10)},0)}(t);let l=Array.from(this.domNode.querySelectorAll(".qlbt-col-tool-cell"));for(let e=0;e<Math.max(n,l.length);e++){let t=o.at(e),r=t&&parseInt(t.formats()[t.statics.blotName].width,10),s=null;l[e]?l[e]&&e>=n?l[e].remove():i(s=l[e],{"min-width":"".concat(r,"px")}):(s=this.createToolCell(),this.domNode.appendChild(s),this.addColCellHolderHandler(s),i(s,{"min-width":"".concat(r,"px")}))}}destroy(){return this.domNode.remove(),null}addColCellHolderHandler(e){const t=r.a.find(this.table),o=e.querySelector(".qlbt-col-tool-cell-holder");let n=!1,l=0,s=0,a=0,d=0,p={},f={},b=null;const m=e=>{e.preventDefault(),n&&(s=e.clientX,a=d+s-l>=u?s-l:u-d,i(b,{left:"".concat(f.left+f.width-1+a,"px")}))},g=r=>{r.preventDefault();const c=Array.from(this.domNode.querySelectorAll(".qlbt-col-tool-cell")).indexOf(e),u=t.colGroup().children.at(c);n&&(u.format("width",d+a),i(e,{"min-width":"".concat(d+a,"px")}),l=0,s=0,a=0,d=0,n=!1,o.classList.remove("dragging")),document.removeEventListener("mousemove",m,!1),document.removeEventListener("mouseup",g,!1),p={},f={},b.remove(),b=null,t.updateTableWidth();const h=this.quill.getModule("better-table").tableSelection;h&&h.clearSelection()};o.addEventListener("mousedown",t=>{document.addEventListener("mousemove",m,!1),document.addEventListener("mouseup",g,!1),p=this.table.getBoundingClientRect(),f=e.getBoundingClientRect(),i(b=document.createElement("div"),{position:"fixed",top:"".concat(f.top,"px"),left:"".concat(f.left+f.width-1,"px"),zIndex:"100",height:"".concat(p.height+c+4,"px"),width:"1px",backgroundColor:h}),document.body.appendChild(b),n=!0,l=t.clientX,d=f.width,o.classList.add("dragging")},!1)}colToolCells(){return Array.from(this.domNode.querySelectorAll(".qlbt-col-tool-cell"))}}const f=r.a.import("blots/block");class b extends f{static create(e){"string"==typeof e&&(e={value:e});const t=super.create(e.value);return C.forEach(o=>{e[o]&&t.setAttribute("data-".concat(o),e[o])}),q.forEach(o=>{e[o]&&t.setAttribute("data-".concat(o),e[o])}),t}static formats(e){const t={};return t.value=this.tagName.indexOf(e.tagName)+1,q.concat(C).reduce((t,o)=>(e.hasAttribute("data-".concat(o))&&(t[o]=e.getAttribute("data-".concat(o))||void 0),t),t)}format(e,t){const{row:o,cell:n,rowspan:r,colspan:i}=b.formats(this.domNode);e===b.blotName?t?super.format(e,{value:t,row:o,cell:n,rowspan:r,colspan:i}):o?this.replaceWith(T.blotName,{row:o,cell:n,rowspan:r,colspan:i}):super.format(e,t):super.format(e,t)}optimize(e){const{row:t,rowspan:o,colspan:n}=b.formats(this.domNode);if(!t||this.parent instanceof A||this.wrap(A.blotName,{row:t,colspan:n,rowspan:o}),this.enforceAllowedChildren(),null!=this.uiNode&&this.uiNode!==this.domNode.firstChild&&this.domNode.insertBefore(this.uiNode,this.domNode.firstChild),0===this.children.length)if(null!=this.statics.defaultChild){const e=this.scroll.create(this.statics.defaultChild.blotName);this.appendChild(e)}else this.remove();this.cache={}}}b.blotName="header",b.tagName=["H1","H2","H3","H4","H5","H6"];var m=b;const g=r.a.import("blots/break"),y=r.a.import("blots/block"),w=r.a.import("blots/container"),x=["width"],N={width:100},C=["row","cell"],q=["rowspan","colspan"],v={rowspan:1,colspan:1},E=5;class T extends y{static create(e){const t=super.create(e);return C.forEach(o=>{let n="row"===o?I:k;t.setAttribute("data-".concat(o),e[o]||n())}),q.forEach(o=>{t.setAttribute("data-".concat(o),e[o]||v[o])}),t}static formats(e){return q.concat(C).reduce((t,o)=>(e.hasAttribute("data-".concat(o))&&(t[o]=e.getAttribute("data-".concat(o))||void 0),t),{})}format(e,t){if(q.concat(C).indexOf(e)>-1)t?this.domNode.setAttribute("data-".concat(e),t):this.domNode.removeAttribute("data-".concat(e));else if("header"===e){if(!t)return;const{row:o,cell:n,rowspan:r,colspan:i}=T.formats(this.domNode);super.format(e,{value:t,row:o,cell:n,rowspan:r,colspan:i})}else super.format(e,t)}optimize(e){const t=this.domNode.getAttribute("data-row"),o=this.domNode.getAttribute("data-rowspan"),n=this.domNode.getAttribute("data-colspan");!this.statics.requiredContainer||this.parent instanceof this.statics.requiredContainer||this.wrap(this.statics.requiredContainer.blotName,{row:t,colspan:n,rowspan:o}),super.optimize(e)}tableCell(){return this.parent}}T.blotName="table-cell-line",T.ClassName="qlbt-cell-line",T.tagName="DIV";class A extends w{checkMerge(){if(super.checkMerge()&&null!=this.next.children.head){const e=this.children.head.formats()[this.children.head.statics.blotName],t=this.children.tail.formats()[this.children.tail.statics.blotName],o=this.next.children.head.formats()[this.next.children.head.statics.blotName],n=this.next.children.tail.formats()[this.next.children.tail.statics.blotName];return e.cell===t.cell&&e.cell===o.cell&&e.cell===n.cell}return!1}static create(e){const t=super.create(e);return t.setAttribute("data-row",e.row),q.forEach(o=>{e[o]&&t.setAttribute(o,e[o])}),t}static formats(e){const t={};return e.hasAttribute("data-row")&&(t.row=e.getAttribute("data-row")),q.reduce((t,o)=>(e.hasAttribute(o)&&(t[o]=e.getAttribute(o)),t),t)}cellOffset(){return this.parent?this.parent.children.indexOf(this):-1}formats(){const e={};return this.domNode.hasAttribute("data-row")&&(e.row=this.domNode.getAttribute("data-row")),q.reduce((e,t)=>(this.domNode.hasAttribute(t)&&(e[t]=this.domNode.getAttribute(t)),e),e)}toggleAttribute(e,t){t?this.domNode.setAttribute(e,t):this.domNode.removeAttribute(e)}formatChildren(e,t){this.children.forEach(o=>{o.format(e,t)})}format(e,t){q.indexOf(e)>-1?(this.toggleAttribute(e,t),this.formatChildren(e,t)):["row"].indexOf(e)>-1?(this.toggleAttribute("data-".concat(e),t),this.formatChildren(e,t)):super.format(e,t)}optimize(e){const t=this.domNode.getAttribute("data-row");!this.statics.requiredContainer||this.parent instanceof this.statics.requiredContainer||this.wrap(this.statics.requiredContainer.blotName,{row:t}),super.optimize(e)}row(){return this.parent}rowOffset(){return this.row()?this.row().rowOffset():-1}table(){return this.row()&&this.row().table()}}A.blotName="table",A.tagName="TD";class S extends w{checkMerge(){if(super.checkMerge()&&null!=this.next.children.head){const e=this.children.head.formats(),t=this.children.tail.formats(),o=this.next.children.head.formats(),n=this.next.children.tail.formats();return e.row===t.row&&e.row===o.row&&e.row===n.row}return!1}static create(e){const t=super.create(e);return t.setAttribute("data-row",e.row),t}formats(){return["row"].reduce((e,t)=>(this.domNode.hasAttribute("data-".concat(t))&&(e[t]=this.domNode.getAttribute("data-".concat(t))),e),{})}optimize(e){!this.statics.requiredContainer||this.parent instanceof this.statics.requiredContainer||this.wrap(this.statics.requiredContainer.blotName),this.enforceAllowedChildren(),null!=this.uiNode&&this.uiNode!==this.domNode.firstChild&&this.domNode.insertBefore(this.uiNode,this.domNode.firstChild),this.children.length>0&&null!=this.next&&this.checkMerge()&&(this.next.moveChildren(this),this.next.remove())}rowOffset(){return this.parent?this.parent.children.indexOf(this):-1}table(){return this.parent&&this.parent.parent}}S.blotName="table-row",S.tagName="TR";class O extends w{}O.blotName="table-body",O.tagName="TBODY";class B extends y{static create(e){let t=super.create(e);return x.forEach(o=>{t.setAttribute("".concat(o),e[o]||N[o])}),t}static formats(e){return x.reduce((t,o)=>(e.hasAttribute("".concat(o))&&(t[o]=e.getAttribute("".concat(o))||void 0),t),{})}format(e,t){x.indexOf(e)>-1?this.domNode.setAttribute("".concat(e),t||N[e]):super.format(e,t)}html(){return this.domNode.outerHTML}}B.blotName="table-col",B.tagName="col";class R extends w{}R.blotName="table-col-group",R.tagName="colgroup";class L extends w{static create(){return super.create()}constructor(e,t){super(e,t),this.updateTableWidth()}updateTableWidth(){setTimeout(()=>{const e=this.colGroup();if(!e)return;const t=e.children.reduce((e,t)=>e+=parseInt(t.formats()[B.blotName].width,10),0);this.domNode.style.width="".concat(t,"px")},0)}cells(e){return this.rows().map(t=>t.children.at(e))}colGroup(){return this.children.head}deleteColumns(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[],o=arguments.length>2?arguments[2]:void 0;const[n]=this.descendants(O);if(null==n||null==n.children.head)return;const r=this.descendants(A),i=[],s=[];if(r.forEach(t=>{const n=l(t.domNode.getBoundingClientRect(),o);n.x+E>e.x&&n.x1-E<e.x1?i.push(t):n.x<e.x+E&&n.x1>e.x1-E&&s.push(t)}),i.length===r.length)return this.tableDestroy(),!0;t.forEach(e=>{this.colGroup().children.at(t[0]).remove()}),i.forEach(e=>{e.remove()}),s.forEach(e=>{const o=parseInt(e.formats().colspan,10);parseInt(e.formats().width,10);e.format("colspan",o-t.length)}),this.updateTableWidth()}deleteRow(e,t){const[o]=this.descendants(O);if(null==o||null==o.children.head)return;const n=this.descendants(A),r=[],i=[],s=[];if(n.forEach(o=>{const n=l(o.domNode.getBoundingClientRect(),t);n.y>e.y-E&&n.y1<e.y1+E?r.push(o):n.y<e.y+E&&n.y1>e.y1-E&&(i.push(o),Math.abs(n.y-e.y)<E&&s.push(o))}),r.length===n.length)return void this.tableDestroy();const a=this.rows().reduce((o,n)=>{let r=l(n.domNode.getBoundingClientRect(),t);return r.y>e.y-E&&r.y1<e.y1+E&&(o+=1),o},0);s.forEach(e=>{const o=l(e.domNode.getBoundingClientRect(),t),n=e.parent.next,r=n.children.reduce((e,n)=>{const r=l(n.domNode.getBoundingClientRect(),t);return Math.abs(o.x1-r.x)<E&&(e=n),e},null);n.insertBefore(e,r),e.format("row",n.formats().row)}),r.forEach(e=>{e.remove()}),i.forEach(e=>{const t=parseInt(e.formats().rowspan,10);e.format("rowspan",t-a)})}tableDestroy(){const e=r.a.find(this.scroll.domNode.parentNode),t=e.getModule("better-table");this.remove(),t.hideTableTools(),e.update(r.a.sources.USER)}insertCell(e,t){const o=k(),n=e.formats().row,r=this.scroll.create(A.blotName,Object.assign({},v,{row:n})),i=this.scroll.create(T.blotName,{row:n,cell:o});r.appendChild(i),t?e.insertBefore(r,t):e.appendChild(r)}insertColumn(e,t){let o=!(arguments.length>2&&void 0!==arguments[2])||arguments[2],n=arguments.length>3?arguments[3]:void 0;const[r]=this.descendants(O),[i]=this.descendants(R),s=this.descendants(B);let a=[],c=[],d=[];if(null==r||null==r.children.head)return;this.descendants(A).forEach(t=>{const r=l(t.domNode.getBoundingClientRect(),n);o?Math.abs(r.x1-e.x1)<E?a.push(t):e.x1-r.x>E&&e.x1-r.x1<-E&&c.push(t):Math.abs(r.x-e.x)<E?a.push(t):e.x-r.x>E&&e.x-r.x1<-E&&c.push(t)}),a.forEach(e=>{const t=o?e.next:e,n=k(),r=e.parent,i=r.formats().row,l=e.formats(),s=this.scroll.create(A.blotName,Object.assign({},v,{row:i,rowspan:l.rowspan})),a=this.scroll.create(T.blotName,{row:i,cell:n,rowspan:l.rowspan});s.appendChild(a),t?r.insertBefore(s,t):r.appendChild(s),d.push(s)});const u=this.scroll.create(B.blotName,!0);let h=o?s[t].next:s[t];return h?i.insertBefore(u,h):i.appendChild(u),c.forEach(e=>{const t=e.formats().colspan;e.format("colspan",parseInt(t,10)+1),d.push(e)}),d.sort((e,t)=>{return e.domNode.getBoundingClientRect().y-t.domNode.getBoundingClientRect().y}),this.updateTableWidth(),d}insertRow(e,t,o){const[n]=this.descendants(O);if(null==n||null==n.children.head)return;const r=this.descendants(A),i=I(),s=this.scroll.create(S.blotName,{row:i});let a=[],c=[],d=[];r.forEach(n=>{const r=l(n.domNode.getBoundingClientRect(),o);t?Math.abs(r.y1-e.y1)<E?a.push(n):e.y1-r.y>E&&e.y1-r.y1<-E&&c.push(n):Math.abs(r.y-e.y)<E?a.push(n):e.y-r.y>E&&e.y-r.y1<-E&&c.push(n)});const u=(e,t)=>{return e.domNode.getBoundingClientRect().x-t.domNode.getBoundingClientRect().x};a.sort(u),a.forEach(e=>{const t=k(),o=e.formats(),n=this.scroll.create(A.blotName,Object.assign({},v,{row:i,colspan:o.colspan})),r=this.scroll.create(T.blotName,{row:i,cell:t,colspan:o.colspan}),l=this.scroll.create(g.blotName);r.appendChild(l),n.appendChild(r),s.appendChild(n),d.push(n)}),c.forEach(e=>{const t=parseInt(e.formats().rowspan,10);e.format("rowspan",t+1),d.push(e)});const h=this.rows().find(n=>{let r=l(n.domNode.getBoundingClientRect(),o);return t?Math.abs(r.y-e.y-e.height)<E:Math.abs(r.y-e.y)<E});return n.insertBefore(s,h),d.sort(u),d}mergeCells(e,t,o,n,r){const i=t.reduce((e,t,r)=>(0!==r?(e&&t.moveChildren(e),t.remove()):(t.format("colspan",n),t.format("rowspan",o),e=t),e),null);let l=i.domNode.getAttribute("data-row"),s=i.children.head.domNode.getAttribute("data-cell");return i.children.forEach(e=>{e.format("cell",s),e.format("row",l),e.format("colspan",n),e.format("rowspan",o)}),i}unmergeCells(e,t){let o={},n=1,r=1;e.forEach(e=>{if(o=e.formats(),n=o.rowspan,(r=o.colspan)>1){let t=e.next,o=e.row();e.format("colspan",1);for(let e=r;e>1;e--)this.insertCell(o,t)}if(n>1){let o=n,i=e.row().next;for(;o>1;){let n=i.children.reduce((o,n)=>{let r=l(e.domNode.getBoundingClientRect(),t),i=l(n.domNode.getBoundingClientRect(),t);return Math.abs(r.x1-i.x)<E&&(o=n),o},null);for(let e=r;e>0;e--)this.insertCell(i,n);o-=1,i=i.next}e.format("rowspan",1)}})}rows(){const e=this.children.tail;return null==e?[]:e.children.map(e=>e)}}L.blotName="table-container",L.className="quill-better-table",L.tagName="TABLE";class M extends w{constructor(e,t){super(e,t);const o=r.a.find(e.domNode.parentNode);t.addEventListener("scroll",e=>{const t=o.getModule("better-table");t.columnTool&&(t.columnTool.domNode.scrollLeft=e.target.scrollLeft),t.tableSelection&&t.tableSelection.selectedTds.length>0&&t.tableSelection.repositionHelpLines()},!1)}}function I(){const e=Math.random().toString(36).slice(2,6);return"row-".concat(e)}function k(){const e=Math.random().toString(36).slice(2,6);return"cell-".concat(e)}M.blotName="table-view",M.className="quill-better-table-wrapper",M.tagName="DIV",M.allowedChildren=[L],L.requiredContainer=M,L.allowedChildren=[O,R],O.requiredContainer=L,O.allowedChildren=[S],S.requiredContainer=O,S.allowedChildren=[A],A.requiredContainer=S,A.allowedChildren=[T,m],T.requiredContainer=A,R.allowedChildren=[B],R.requiredContainer=L,B.requiredContainer=R;const H="#35A7ED",D=["left","right","top","bottom"],j=2;class _{constructor(e,t,o){if(!e)return null;this.table=e,this.quill=t,this.options=o,this.boundary={},this.selectedTds=[],this.dragging=!1,this.selectingHandler=this.mouseDownHandler.bind(this),this.clearSelectionHanler=this.clearSelection.bind(this),this.helpLinesInitial(),this.quill.root.addEventListener("mousedown",this.selectingHandler,!1),this.quill.on("text-change",this.clearSelectionHanler)}helpLinesInitial(){let e=this.quill.root.parentNode;D.forEach(t=>{this[t]=document.createElement("div"),this[t].classList.add("qlbt-selection-line"),i(this[t],{position:"absolute",display:"none","background-color":H}),e.appendChild(this[t])})}mouseDownHandler(e){if(0!==e.button||!e.target.closest(".quill-better-table"))return;this.quill.root.addEventListener("mousemove",r,!1),this.quill.root.addEventListener("mouseup",function e(o){t.quill.root.removeEventListener("mousemove",r,!1);t.quill.root.removeEventListener("mouseup",e,!1);t.dragging=!1},!1);const t=this,o=e.target.closest("td[data-row]"),n=l(o.getBoundingClientRect(),this.quill.root.parentNode);function r(e){if(0!==e.button||!e.target.closest(".quill-better-table"))return;const r=e.target.closest("td[data-row]"),i=l(r.getBoundingClientRect(),t.quill.root.parentNode);t.boundary=U(n,i),t.correctBoundary(),t.selectedTds=t.computeSelectedTds(),t.repositionHelpLines(),o!==r&&t.quill.blur()}this.dragging=!0,this.boundary=U(n,n),this.correctBoundary(),this.selectedTds=this.computeSelectedTds(),this.repositionHelpLines()}correctBoundary(){r.a.find(this.table).descendants(A).forEach(e=>{let{x:t,y:o,width:n,height:r}=l(e.domNode.getBoundingClientRect(),this.quill.root.parentNode);(t+j>=this.boundary.x&&t+j<=this.boundary.x1||t-j+n>=this.boundary.x&&t-j+n<=this.boundary.x1)&&(o+j>=this.boundary.y&&o+j<=this.boundary.y1||o-j+r>=this.boundary.y&&o-j+r<=this.boundary.y1)&&(this.boundary=U(this.boundary,{x:t,y:o,width:n,height:r}))})}computeSelectedTds(){return r.a.find(this.table).descendants(A).reduce((e,t)=>{let{x:o,y:n,width:r,height:i}=l(t.domNode.getBoundingClientRect(),this.quill.root.parentNode);return o+j>=this.boundary.x&&o-j+r<=this.boundary.x1&&n+j>=this.boundary.y&&n-j+i<=this.boundary.y1&&e.push(t),e},[])}repositionHelpLines(){const e=this.table.parentNode.scrollLeft;i(this.left,{display:"block",left:"".concat(this.boundary.x-e-1,"px"),top:"".concat(this.boundary.y,"px"),height:"".concat(this.boundary.height+1,"px"),width:"1px"}),i(this.right,{display:"block",left:"".concat(this.boundary.x1-e,"px"),top:"".concat(this.boundary.y,"px"),height:"".concat(this.boundary.height+1,"px"),width:"1px"}),i(this.top,{display:"block",left:"".concat(this.boundary.x-1-e,"px"),top:"".concat(this.boundary.y,"px"),width:"".concat(this.boundary.width+1,"px"),height:"1px"}),i(this.bottom,{display:"block",left:"".concat(this.boundary.x-1-e,"px"),top:"".concat(this.boundary.y1+1,"px"),width:"".concat(this.boundary.width+1,"px"),height:"1px"})}refreshHelpLinesPosition(){const e=l(this.selectedTds[0].domNode.getBoundingClientRect(),this.quill.root.parentNode),t=l(this.selectedTds[this.selectedTds.length-1].domNode.getBoundingClientRect(),this.quill.root.parentNode);this.boundary=U(e,t),this.repositionHelpLines()}destroy(){return D.forEach(e=>{this[e].remove(),this[e]=null}),this.quill.root.removeEventListener("mousedown",this.selectingHandler,!1),this.quill.off("text-change",this.clearSelectionHanler),null}setSelection(e,t){this.boundary=U(l(e,this.quill.root.parentNode),l(t,this.quill.root.parentNode)),this.correctBoundary(),this.selectedTds=this.computeSelectedTds(),this.repositionHelpLines()}clearSelection(){this.boundary={},this.selectedTds=[],D.forEach(e=>{this[e]&&i(this[e],{display:"none"})})}}function U(e,t){let o=Math.min(e.x,t.x,e.x+e.width-1,t.x+t.width-1),n=Math.max(e.x,t.x,e.x+e.width-1,t.x+t.width-1),r=Math.min(e.y,t.y,e.y+e.height-1,t.y+t.height-1),i=Math.max(e.y,t.y,e.y+e.height-1,t.y+t.height-1);return{x:o,x1:n,y:r,y1:i,width:n-o,height:i-r}}const P=150,W=200,z={insertColumnRight:{text:"Insert column right",handler(){const e=r.a.find(this.table);let t=X(this.columnToolCells,this.boundary,(e,t)=>Math.abs(e.x+e.width-t.x1)<=5,this.quill.root.parentNode);const o=e.insertColumn(this.boundary,t,!0,this.quill.root.parentNode);this.tableColumnTool.updateToolCells(),this.quill.update(r.a.sources.USER),this.quill.setSelection(this.quill.getIndex(o[0]),0,r.a.sources.SILENT),this.tableSelection.setSelection(o[0].domNode.getBoundingClientRect(),o[0].domNode.getBoundingClientRect())}},insertColumnLeft:{text:"Insert column left",handler(){const e=r.a.find(this.table);let t=X(this.columnToolCells,this.boundary,(e,t)=>Math.abs(e.x-t.x)<=5,this.quill.root.parentNode);const o=e.insertColumn(this.boundary,t,!1,this.quill.root.parentNode);this.tableColumnTool.updateToolCells(),this.quill.update(r.a.sources.USER),this.quill.setSelection(this.quill.getIndex(o[0]),0,r.a.sources.SILENT),this.tableSelection.setSelection(o[0].domNode.getBoundingClientRect(),o[0].domNode.getBoundingClientRect())}},insertRowUp:{text:"Insert row up",handler(){const e=r.a.find(this.table).insertRow(this.boundary,!1,this.quill.root.parentNode);this.quill.update(r.a.sources.USER),this.quill.setSelection(this.quill.getIndex(e[0]),0,r.a.sources.SILENT),this.tableSelection.setSelection(e[0].domNode.getBoundingClientRect(),e[0].domNode.getBoundingClientRect())}},insertRowDown:{text:"Insert row down",handler(){const e=r.a.find(this.table).insertRow(this.boundary,!0,this.quill.root.parentNode);this.quill.update(r.a.sources.USER),this.quill.setSelection(this.quill.getIndex(e[0]),0,r.a.sources.SILENT),this.tableSelection.setSelection(e[0].domNode.getBoundingClientRect(),e[0].domNode.getBoundingClientRect())}},mergeCells:{text:"Merge selected cells",handler(){const e=r.a.find(this.table),t=e.rows().reduce((e,t)=>{let o=l(t.domNode.getBoundingClientRect(),this.quill.root.parentNode);return o.y>this.boundary.y-5&&o.y+o.height<this.boundary.y+this.boundary.height+5&&(e+=1),e},0),o=this.columnToolCells.reduce((e,t)=>{let o=l(t.getBoundingClientRect(),this.quill.root.parentNode);return o.x>this.boundary.x-5&&o.x+o.width<this.boundary.x+this.boundary.width+5&&(e+=1),e},0),n=e.mergeCells(this.boundary,this.selectedTds,t,o,this.quill.root.parentNode);this.quill.update(r.a.sources.USER),this.tableSelection.setSelection(n.domNode.getBoundingClientRect(),n.domNode.getBoundingClientRect())}},unmergeCells:{text:"Unmerge cells",handler(){r.a.find(this.table).unmergeCells(this.selectedTds,this.quill.root.parentNode),this.quill.update(r.a.sources.USER),this.tableSelection.clearSelection()}},deleteColumn:{text:"Delete selected columns",handler(){const e=r.a.find(this.table);let t=function(e,t,o,n){return e.reduce((r,i)=>{let s=l(i.getBoundingClientRect(),n);return o(s,t)&&r.push(e.indexOf(i)),r},[])}(this.columnToolCells,this.boundary,(e,t)=>e.x+5>t.x&&e.x+e.width-5<t.x1,this.quill.root.parentNode);e.deleteColumns(this.boundary,t,this.quill.root.parentNode)||(this.tableColumnTool.updateToolCells(),this.quill.update(r.a.sources.USER),this.tableSelection.clearSelection())}},deleteRow:{text:"Delete selected rows",handler(){r.a.find(this.table).deleteRow(this.boundary,this.quill.root.parentNode),this.quill.update(r.a.sources.USER),this.tableSelection.clearSelection()}},deleteTable:{text:"Delete table",handler(){const e=this.quill.getModule("better-table"),t=r.a.find(this.table);e.hideTableTools(),t.remove(),this.quill.update(r.a.sources.USER)}}};class G{constructor(e,t,o){const n=t.getModule("better-table");this.tableSelection=n.tableSelection,this.table=e.table,this.quill=t,this.options=o,this.menuItems=Object.assign({},z,o.items),this.tableColumnTool=n.columnTool,this.boundary=this.tableSelection.boundary,this.selectedTds=this.tableSelection.selectedTds,this.destroyHanlder=this.destroy.bind(this),this.columnToolCells=this.tableColumnTool.colToolCells(),this.menuInitial(e),this.mount(),document.addEventListener("click",this.destroyHanlder,!1)}mount(){document.body.appendChild(this.domNode)}destroy(){return this.domNode.remove(),document.removeEventListener("click",this.destroyHanlder,!1),null}menuInitial(e){let{table:t,left:o,top:n}=e;this.domNode=document.createElement("div"),this.domNode.classList.add("qlbt-operation-menu"),i(this.domNode,{position:"absolute",left:"".concat(o,"px"),top:"".concat(n,"px"),"min-height":"".concat(P,"px"),width:"".concat(W,"px")});for(let e in this.menuItems)this.menuItems[e]&&this.domNode.appendChild(this.menuItemCreator(Object.assign({},z[e],this.menuItems[e])))}menuItemCreator(e){let{text:t,handler:o}=e;const n=document.createElement("div");return n.classList.add("qlbt-operation-menu-item"),n.innerText=t,n.addEventListener("click",o.bind(this),!1),n}}function X(e,t,o,n){return e.reduce((r,i)=>{let s=l(i.getBoundingClientRect(),n);return o(s,t)&&(r=e.indexOf(i)),r},!1)}const K=r.a.import("delta");function V(e,t,o){const n=e.parentNode,r="TABLE"===n.parentNode.tagName?n.parentNode:n.parentNode.parentNode,i=Array.from(r.querySelectorAll("tr")),l=Array.from(n.querySelectorAll("td")),a=i.indexOf(n)+1,c=l.indexOf(e)+1,d=e.getAttribute("colspan")||!1,u=e.getAttribute("rowspan")||!1;return 0===t.length()?t=(new K).insert("\n",{"table-cell-line":{row:a,cell:c,rowspan:u,colspan:d}}):(t=t.reduce((e,t)=>{if(t.insert&&"string"==typeof t.insert){const o=[];let n=t.insert,r=0;for(let e=0;e<t.insert.length;e++)"\n"===n.charAt(e)&&(0===e?o.push("\n"):(o.push(n.substring(r,e)),o.push("\n")),r=e+1);const i=n.substring(r);i&&o.push(i),o.forEach(o=>{"\n"===o?e.insert("\n",t.attributes):e.insert(o,s(t.attributes,["table","table-cell-line","header"]))})}else e.insert(t.insert,t.attributes);return e},new K)).reduce((e,t)=>{if(t.insert&&"string"==typeof t.insert&&t.insert.startsWith("\n")){let o={};t.attributes.header?o.header={row:a,cell:c,rowspan:u,colspan:d}:t.attributes["table-cell-line"]&&(o["table-cell-line"]={row:a,cell:c,rowspan:u,colspan:d}),e.insert(t.insert,Object.assign({},Object.assign({},{row:a},t.attributes.table),o,s(t.attributes,["table"])))}else e.insert(t.insert,Object.assign({},s(t.attributes,["table","table-cell-line"])));return console.log(e),e},new K)}function Y(e,t,o){const n=e.parentNode,r="TABLE"===n.parentNode.tagName?n.parentNode:n.parentNode.parentNode,i=Array.from(r.querySelectorAll("tr")),l=Array.from(n.querySelectorAll("th")),a=i.indexOf(n)+1,c=l.indexOf(e)+1,d=e.getAttribute("colspan")||!1,u=e.getAttribute("rowspan")||!1;return 0===t.length()?t=(new K).insert("\n",{"table-cell-line":{row:a,cell:c,rowspan:u,colspan:d}}):(t=t.reduce((e,t)=>{if(t.insert&&"string"==typeof t.insert){const o=[];let n=t.insert,r=0;for(let e=0;e<t.insert.length;e++)"\n"===n.charAt(e)&&(0===e?o.push("\n"):(o.push(n.substring(r,e)),o.push("\n")),r=e+1);const i=n.substring(r);i&&o.push(i),o.indexOf("\n")<0&&o.push("\n"),o.forEach(o=>{"\n"===o?e.insert("\n",{"table-cell-line":{row:a,cell:c,rowspan:u,colspan:d}}):e.insert(o,t.attributes)})}else e.insert(t.insert,t.attributes);return e},new K)).reduce((e,t)=>(t.insert&&"string"==typeof t.insert&&t.insert.startsWith("\n")?e.insert(t.insert,Object.assign({},{"table-cell-line":{row:a,cell:c,rowspan:u,colspan:d}})):e.insert(t.insert,Object.assign({},s(t.attributes,["table","table-cell-line"]))),e),new K)}function J(e,t,o){let n=new K;const r=e.querySelector("tr");if(null===r)return n;const i=Array.from(r.querySelectorAll("td")).concat(Array.from(r.querySelectorAll("th"))).reduce((e,t)=>{const o=t.getAttribute("colspan")||1;return e+=parseInt(o,10)},0),l=e.querySelectorAll("col").length;if(l===i)return t;{for(let e=0;e<i-l;e++)n.insert("\n",{"table-col":!0});if(0===l)return n.concat(t);let e=0;return t.reduce((t,o)=>(t.insert(o.insert,o.attributes),o.attributes&&o.attributes["table-col"]&&(e+=o.insert.length)===l&&(t=t.concat(n)),t),new K)}}function Q(e,t,o){return t}const $=r.a.import("core/module"),F=r.a.import("delta");class Z extends ${static register(){r.a.register(B,!0),r.a.register(R,!0),r.a.register(T,!0),r.a.register(A,!0),r.a.register(S,!0),r.a.register(O,!0),r.a.register(L,!0),r.a.register(M,!0),r.a.register(M,!0),r.a.register("formats/header",m,!0)}constructor(e,t){super(e,t),this.quill.root.addEventListener("click",o=>{const n=a(o);if(!n||n.length<=0)return;const r=n.filter(e=>e.tagName&&"TABLE"===e.tagName.toUpperCase()&&e.classList.contains("quill-better-table"))[0];if(r){if(this.table===r)return;this.table&&this.hideTableTools(),this.showTableTools(r,e,t)}else this.table&&this.hideTableTools()},!1),this.quill.root.addEventListener("contextmenu",o=>{if(!this.table)return!0;o.preventDefault();const n=a(o);if(!n||n.length<=0)return;const r=n.filter(e=>e.tagName&&"TABLE"===e.tagName.toUpperCase()&&e.classList.contains("quill-better-table"))[0],i=n.filter(e=>e.tagName&&"TR"===e.tagName.toUpperCase()&&e.getAttribute("data-row"))[0],l=n.filter(e=>e.tagName&&"TD"===e.tagName.toUpperCase()&&e.getAttribute("data-row"))[0];let s=this.tableSelection.selectedTds.map(e=>e.domNode).includes(l);(this.tableSelection.selectedTds.length<=0||!s)&&this.tableSelection.setSelection(l.getBoundingClientRect(),l.getBoundingClientRect()),this.tableOperationMenu&&(this.tableOperationMenu=this.tableOperationMenu.destroy()),r&&(this.tableOperationMenu=new G({table:r,row:i,cell:l,left:o.pageX,top:o.pageY},e,t.operationMenu))},!1);e.getModule("keyboard");e.keyboard.addBinding({key:"Backspace"},{},function(e,t){if(0===e.index||this.quill.getLength()<=1)return!0;const[o]=this.quill.getLine(e.index);if(0===t.offset){const[t]=this.quill.getLine(e.index-1);if(null!=t&&"table-cell-line"===t.statics.blotName&&"table-cell-line"!==o.statics.blotName)return!1}return!0});let o=e.keyboard.bindings.Backspace.pop();e.keyboard.bindings.Backspace.splice(0,1,o),e.clipboard.addMatcher("td",V),e.clipboard.addMatcher("th",Y),e.clipboard.addMatcher("table",J),e.clipboard.addMatcher("h1, h2, h3, h4, h5, h6",Q),e.clipboard.matchers=e.clipboard.matchers.filter(e=>"tr"!==e[0])}getTable(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.quill.getSelection();if(null==e)return[null,null,null,-1];const[t,o]=this.quill.getLine(e.index);if(null==t||t.statics.blotName!==T.blotName)return[null,null,null,-1];const n=t.tableCell(),r=n.row();return[r.table(),r,n,o]}insertTable(e,t){const o=this.quill.getSelection(!0);if(null==o)return;this.quill.getLeaf(o.index)[0],this.quill.getLeaf(o.index+1)[0];let n=(new F).retain(o.index);n.insert("\n"),n=new Array(t).fill("\n").reduce((e,t)=>(e.insert(t,{"table-col":!0}),e),n),n=new Array(e).fill(0).reduce(e=>{let o=I();return new Array(t).fill("\n").reduce((e,t)=>(e.insert(t,{"table-cell-line":{row:o,cell:k()}}),e),e)},n),this.quill.updateContents(n,r.a.sources.USER),this.quill.setSelection(o.index+t+1,r.a.sources.API)}showTableTools(e,t,o){this.table=e,this.columnTool=new p(e,t,o),this.tableSelection=new _(e,t,o)}hideTableTools(){this.columnTool&&this.columnTool.destroy(),this.tableSelection&&this.tableSelection.destroy(),this.tableOperationMenu&&this.tableOperationMenu.destroy(),this.columnTool=null,this.tableSelection=null,this.tableOperationMenu=null,this.table=null}}Z.keyboardBindings={"table-cell-line backspace":{key:"Backspace",format:["table-cell-line"],collapsed:!0,offset:0,handler(e,t){const[o,n]=this.quill.getLine(e.index);return!(!o.prev||"table-cell-line"!==o.prev.statics.blotName)}},"table-cell-line delete":{key:"Delete",format:["table-cell-line"],collapsed:!0,suffix:/^$/,handler(){}},"table-cell-line enter":{key:"Enter",shiftKey:null,format:["table-cell-line"],handler(e,t){if(this.quill.selection&&this.quill.selection.composing)return;const o=r.a.imports.parchment.Scope;e.length>0&&this.quill.scroll.deleteAt(e.index,e.length);const n=Object.keys(t.format).reduce((e,n)=>(this.quill.scroll.query(n,o.BLOCK)&&!Array.isArray(t.format[n])&&(e[n]=t.format[n]),e),{});this.quill.insertText(e.index,"\n",n["table-cell-line"],r.a.sources.USER),this.quill.setSelection(e.index+1,r.a.sources.SILENT),this.quill.focus(),Object.keys(t.format).forEach(e=>{null==n[e]&&(Array.isArray(t.format[e])||"link"!==e&&this.quill.format(e,t.format[e],r.a.sources.USER))})}}};t.default=Z}]).default}); | ||
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("quill")):"function"==typeof define&&define.amd?define(["quill"],t):"object"==typeof exports?exports.quillBetterTable=t(require("quill")):e.quillBetterTable=t(e.Quill)}(window,function(e){return function(e){var t=window.webpackHotUpdatequillBetterTable;window.webpackHotUpdatequillBetterTable=function(e,o){!function(e,t){if(!N[e]||!x[e])return;for(var o in x[e]=!1,t)Object.prototype.hasOwnProperty.call(t,o)&&(b[o]=t[o]);0==--g&&0===y&&E()}(e,o),t&&t(e,o)};var o,n=!0,r="158e5e1759938947679b",i=1e4,l={},s=[],a=[];function c(e){var t=A[e];if(!t)return S;var n=function(n){return t.hot.active?(A[n]?-1===A[n].parents.indexOf(e)&&A[n].parents.push(e):(s=[e],o=n),-1===t.children.indexOf(n)&&t.children.push(n)):(console.warn("[HMR] unexpected require("+n+") from disposed module "+e),s=[]),S(n)},r=function(e){return{configurable:!0,enumerable:!0,get:function(){return S[e]},set:function(t){S[e]=t}}};for(var i in S)Object.prototype.hasOwnProperty.call(S,i)&&"e"!==i&&"t"!==i&&Object.defineProperty(n,i,r(i));return n.e=function(e){return"ready"===h&&p("prepare"),y++,S.e(e).then(t,function(e){throw t(),e});function t(){y--,"prepare"===h&&(w[e]||v(e),0===y&&0===g&&E())}},n.t=function(e,t){return 1&t&&(e=n(e)),S.t(e,-2&t)},n}function d(e){var t={_acceptedDependencies:{},_declinedDependencies:{},_selfAccepted:!1,_selfDeclined:!1,_disposeHandlers:[],_main:o!==e,active:!0,accept:function(e,o){if(void 0===e)t._selfAccepted=!0;else if("function"==typeof e)t._selfAccepted=e;else if("object"==typeof e)for(var n=0;n<e.length;n++)t._acceptedDependencies[e[n]]=o||function(){};else t._acceptedDependencies[e]=o||function(){}},decline:function(e){if(void 0===e)t._selfDeclined=!0;else if("object"==typeof e)for(var o=0;o<e.length;o++)t._declinedDependencies[e[o]]=!0;else t._declinedDependencies[e]=!0},dispose:function(e){t._disposeHandlers.push(e)},addDisposeHandler:function(e){t._disposeHandlers.push(e)},removeDisposeHandler:function(e){var o=t._disposeHandlers.indexOf(e);o>=0&&t._disposeHandlers.splice(o,1)},check:q,apply:T,status:function(e){if(!e)return h;u.push(e)},addStatusHandler:function(e){u.push(e)},removeStatusHandler:function(e){var t=u.indexOf(e);t>=0&&u.splice(t,1)},data:l[e]};return o=void 0,t}var u=[],h="idle";function p(e){h=e;for(var t=0;t<u.length;t++)u[t].call(null,e)}var f,b,m,g=0,y=0,w={},x={},N={};function C(e){return+e+""===e?+e:e}function q(e){if("idle"!==h)throw new Error("check() is only allowed in idle status");return n=e,p("check"),(t=i,t=t||1e4,new Promise(function(e,o){if("undefined"==typeof XMLHttpRequest)return o(new Error("No browser support"));try{var n=new XMLHttpRequest,i=S.p+""+r+".hot-update.json";n.open("GET",i,!0),n.timeout=t,n.send(null)}catch(e){return o(e)}n.onreadystatechange=function(){if(4===n.readyState)if(0===n.status)o(new Error("Manifest request to "+i+" timed out."));else if(404===n.status)e();else if(200!==n.status&&304!==n.status)o(new Error("Manifest request to "+i+" failed."));else{try{var t=JSON.parse(n.responseText)}catch(e){return void o(e)}e(t)}}})).then(function(e){if(!e)return p("idle"),null;x={},w={},N=e.c,m=e.h,p("prepare");var t=new Promise(function(e,t){f={resolve:e,reject:t}});b={};return v(0),"prepare"===h&&0===y&&0===g&&E(),t});var t}function v(e){N[e]?(x[e]=!0,g++,function(e){var t=document.createElement("script");t.charset="utf-8",t.src=S.p+""+e+"."+r+".hot-update.js",document.head.appendChild(t)}(e)):w[e]=!0}function E(){p("ready");var e=f;if(f=null,e)if(n)Promise.resolve().then(function(){return T(n)}).then(function(t){e.resolve(t)},function(t){e.reject(t)});else{var t=[];for(var o in b)Object.prototype.hasOwnProperty.call(b,o)&&t.push(C(o));e.resolve(t)}}function T(t){if("ready"!==h)throw new Error("apply() is only allowed in ready status");var o,n,i,a,c;function d(e){for(var t=[e],o={},n=t.map(function(e){return{chain:[e],id:e}});n.length>0;){var r=n.pop(),i=r.id,l=r.chain;if((a=A[i])&&!a.hot._selfAccepted){if(a.hot._selfDeclined)return{type:"self-declined",chain:l,moduleId:i};if(a.hot._main)return{type:"unaccepted",chain:l,moduleId:i};for(var s=0;s<a.parents.length;s++){var c=a.parents[s],d=A[c];if(d){if(d.hot._declinedDependencies[i])return{type:"declined",chain:l.concat([c]),moduleId:i,parentId:c};-1===t.indexOf(c)&&(d.hot._acceptedDependencies[i]?(o[c]||(o[c]=[]),u(o[c],[i])):(delete o[c],t.push(c),n.push({chain:l.concat([c]),id:c})))}}}}return{type:"accepted",moduleId:e,outdatedModules:t,outdatedDependencies:o}}function u(e,t){for(var o=0;o<t.length;o++){var n=t[o];-1===e.indexOf(n)&&e.push(n)}}t=t||{};var f={},g=[],y={},w=function(){console.warn("[HMR] unexpected require("+q.moduleId+") to disposed module")};for(var x in b)if(Object.prototype.hasOwnProperty.call(b,x)){var q;c=C(x);var v=!1,E=!1,T=!1,O="";switch((q=b[x]?d(c):{type:"disposed",moduleId:x}).chain&&(O="\nUpdate propagation: "+q.chain.join(" -> ")),q.type){case"self-declined":t.onDeclined&&t.onDeclined(q),t.ignoreDeclined||(v=new Error("Aborted because of self decline: "+q.moduleId+O));break;case"declined":t.onDeclined&&t.onDeclined(q),t.ignoreDeclined||(v=new Error("Aborted because of declined dependency: "+q.moduleId+" in "+q.parentId+O));break;case"unaccepted":t.onUnaccepted&&t.onUnaccepted(q),t.ignoreUnaccepted||(v=new Error("Aborted because "+c+" is not accepted"+O));break;case"accepted":t.onAccepted&&t.onAccepted(q),E=!0;break;case"disposed":t.onDisposed&&t.onDisposed(q),T=!0;break;default:throw new Error("Unexception type "+q.type)}if(v)return p("abort"),Promise.reject(v);if(E)for(c in y[c]=b[c],u(g,q.outdatedModules),q.outdatedDependencies)Object.prototype.hasOwnProperty.call(q.outdatedDependencies,c)&&(f[c]||(f[c]=[]),u(f[c],q.outdatedDependencies[c]));T&&(u(g,[q.moduleId]),y[c]=w)}var B,R=[];for(n=0;n<g.length;n++)c=g[n],A[c]&&A[c].hot._selfAccepted&&y[c]!==w&&R.push({module:c,errorHandler:A[c].hot._selfAccepted});p("dispose"),Object.keys(N).forEach(function(e){!1===N[e]&&function(e){delete installedChunks[e]}(e)});for(var L,M,I=g.slice();I.length>0;)if(c=I.pop(),a=A[c]){var k={},H=a.hot._disposeHandlers;for(i=0;i<H.length;i++)(o=H[i])(k);for(l[c]=k,a.hot.active=!1,delete A[c],delete f[c],i=0;i<a.children.length;i++){var D=A[a.children[i]];D&&((B=D.parents.indexOf(c))>=0&&D.parents.splice(B,1))}}for(c in f)if(Object.prototype.hasOwnProperty.call(f,c)&&(a=A[c]))for(M=f[c],i=0;i<M.length;i++)L=M[i],(B=a.children.indexOf(L))>=0&&a.children.splice(B,1);for(c in p("apply"),r=m,y)Object.prototype.hasOwnProperty.call(y,c)&&(e[c]=y[c]);var j=null;for(c in f)if(Object.prototype.hasOwnProperty.call(f,c)&&(a=A[c])){M=f[c];var _=[];for(n=0;n<M.length;n++)if(L=M[n],o=a.hot._acceptedDependencies[L]){if(-1!==_.indexOf(o))continue;_.push(o)}for(n=0;n<_.length;n++){o=_[n];try{o(M)}catch(e){t.onErrored&&t.onErrored({type:"accept-errored",moduleId:c,dependencyId:M[n],error:e}),t.ignoreErrored||j||(j=e)}}}for(n=0;n<R.length;n++){var U=R[n];c=U.module,s=[c];try{S(c)}catch(e){if("function"==typeof U.errorHandler)try{U.errorHandler(e)}catch(o){t.onErrored&&t.onErrored({type:"self-accept-error-handler-errored",moduleId:c,error:o,originalError:e}),t.ignoreErrored||j||(j=o),j||(j=e)}else t.onErrored&&t.onErrored({type:"self-accept-errored",moduleId:c,error:e}),t.ignoreErrored||j||(j=e)}}return j?(p("fail"),Promise.reject(j)):(p("idle"),new Promise(function(e){e(g)}))}var A={};function S(t){if(A[t])return A[t].exports;var o=A[t]={i:t,l:!1,exports:{},hot:d(t),parents:(a=s,s=[],a),children:[]};return e[t].call(o.exports,o,o.exports,c(t)),o.l=!0,o.exports}return S.m=e,S.c=A,S.d=function(e,t,o){S.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:o})},S.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},S.t=function(e,t){if(1&t&&(e=S(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var o=Object.create(null);if(S.r(o),Object.defineProperty(o,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var n in e)S.d(o,n,function(t){return e[t]}.bind(null,n));return o},S.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return S.d(t,"a",t),t},S.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},S.p="",S.h=function(){return r},c(1)(S.s=1)}([function(t,o){t.exports=e},function(e,t,o){e.exports=o(2)},function(e,t,o){"use strict";o.r(t);var n=o(0),r=o.n(n);function i(e,t){if("object"==typeof t)for(let o in t)e.style[o]=t[o]}function l(e,t){let o=t.getBoundingClientRect();return{x:e.x-o.x-t.scrollLeft,y:e.y-o.y-t.scrollTop,x1:e.x-o.x-t.scrollLeft+e.width,y1:e.y-o.y-t.scrollTop+e.height,width:e.width,height:e.height}}function s(e,t){return e&&Object.keys(e).reduce((o,n)=>t.includes(n)?o:Object.assign({},o,{[n]:e[n]}),{})}function a(e){let t;if(null==(t=e.path||e.composedPath&&e.composedPath())&&e.target){t=[];let o=e.target;for(t.push(o);o&&o.parentNode;)o=o.parentNode,t.push(o)}return t}const c=12,d=12,u=50,h="#35A7ED";class p{constructor(e,t,o){if(!e)return null;this.table=e,this.quill=t,this.options=o,this.domNode=null,this.initColTool()}initColTool(){const e=this.quill.root.parentNode,t=(this.table.getBoundingClientRect(),e.getBoundingClientRect()),o=this.table.parentNode.getBoundingClientRect();this.domNode=document.createElement("div"),this.domNode.classList.add("qlbt-col-tool"),this.updateToolCells(),e.appendChild(this.domNode),i(this.domNode,{width:"".concat(o.width,"px"),height:"".concat(c,"px"),left:"".concat(o.left-t.left+e.scrollLeft,"px"),top:"".concat(o.top-t.top+e.scrollTop-c-5,"px")})}createToolCell(){const e=document.createElement("div");e.classList.add("qlbt-col-tool-cell");const t=document.createElement("div");return t.classList.add("qlbt-col-tool-cell-holder"),i(e,{height:"".concat(d,"px")}),e.appendChild(t),e}updateToolCells(){const e=r.a.find(this.table),t=e.children.tail.children.head.children,o=e.colGroup().children,n=function(e){return e.reduce((e,t)=>{const o=t.formats().colspan;return e+=parseInt(o,10)},0)}(t);let l=Array.from(this.domNode.querySelectorAll(".qlbt-col-tool-cell"));for(let e=0;e<Math.max(n,l.length);e++){let t=o.at(e),r=t&&parseInt(t.formats()[t.statics.blotName].width,10),s=null;l[e]?l[e]&&e>=n?l[e].remove():i(s=l[e],{"min-width":"".concat(r,"px")}):(s=this.createToolCell(),this.domNode.appendChild(s),this.addColCellHolderHandler(s),i(s,{"min-width":"".concat(r,"px")}))}}destroy(){return this.domNode.remove(),null}addColCellHolderHandler(e){const t=r.a.find(this.table),o=e.querySelector(".qlbt-col-tool-cell-holder");let n=!1,l=0,s=0,a=0,d=0,p={},f={},b=null;const m=e=>{e.preventDefault(),n&&(s=e.clientX,a=d+s-l>=u?s-l:u-d,i(b,{left:"".concat(f.left+f.width-1+a,"px")}))},g=r=>{r.preventDefault();const c=Array.from(this.domNode.querySelectorAll(".qlbt-col-tool-cell")).indexOf(e),u=t.colGroup().children.at(c);n&&(u.format("width",d+a),i(e,{"min-width":"".concat(d+a,"px")}),l=0,s=0,a=0,d=0,n=!1,o.classList.remove("dragging")),document.removeEventListener("mousemove",m,!1),document.removeEventListener("mouseup",g,!1),p={},f={},b.remove(),b=null,t.updateTableWidth();const h=this.quill.getModule("better-table").tableSelection;h&&h.clearSelection()};o.addEventListener("mousedown",t=>{document.addEventListener("mousemove",m,!1),document.addEventListener("mouseup",g,!1),p=this.table.getBoundingClientRect(),f=e.getBoundingClientRect(),i(b=document.createElement("div"),{position:"fixed",top:"".concat(f.top,"px"),left:"".concat(f.left+f.width-1,"px"),zIndex:"100",height:"".concat(p.height+c+4,"px"),width:"1px",backgroundColor:h}),document.body.appendChild(b),n=!0,l=t.clientX,d=f.width,o.classList.add("dragging")},!1)}colToolCells(){return Array.from(this.domNode.querySelectorAll(".qlbt-col-tool-cell"))}}const f=r.a.import("blots/block");class b extends f{static create(e){"string"==typeof e&&(e={value:e});const t=super.create(e.value);return C.forEach(o=>{e[o]&&t.setAttribute("data-".concat(o),e[o])}),q.forEach(o=>{e[o]&&t.setAttribute("data-".concat(o),e[o])}),t}static formats(e){const t={};return t.value=this.tagName.indexOf(e.tagName)+1,q.concat(C).reduce((t,o)=>(e.hasAttribute("data-".concat(o))&&(t[o]=e.getAttribute("data-".concat(o))||void 0),t),t)}format(e,t){const{row:o,cell:n,rowspan:r,colspan:i}=b.formats(this.domNode);e===b.blotName?t?super.format(e,{value:t,row:o,cell:n,rowspan:r,colspan:i}):o?this.replaceWith(T.blotName,{row:o,cell:n,rowspan:r,colspan:i}):super.format(e,t):super.format(e,t)}optimize(e){const{row:t,rowspan:o,colspan:n}=b.formats(this.domNode);if(!t||this.parent instanceof A||this.wrap(A.blotName,{row:t,colspan:n,rowspan:o}),this.enforceAllowedChildren(),null!=this.uiNode&&this.uiNode!==this.domNode.firstChild&&this.domNode.insertBefore(this.uiNode,this.domNode.firstChild),0===this.children.length)if(null!=this.statics.defaultChild){const e=this.scroll.create(this.statics.defaultChild.blotName);this.appendChild(e)}else this.remove();this.cache={}}}b.blotName="header",b.tagName=["H1","H2","H3","H4","H5","H6"];var m=b;const g=r.a.import("blots/break"),y=r.a.import("blots/block"),w=r.a.import("blots/container"),x=["width"],N={width:100},C=["row","cell"],q=["rowspan","colspan"],v={rowspan:1,colspan:1},E=5;class T extends y{static create(e){const t=super.create(e);return C.forEach(o=>{let n="row"===o?I:k;t.setAttribute("data-".concat(o),e[o]||n())}),q.forEach(o=>{t.setAttribute("data-".concat(o),e[o]||v[o])}),t}static formats(e){return q.concat(C).reduce((t,o)=>(e.hasAttribute("data-".concat(o))&&(t[o]=e.getAttribute("data-".concat(o))||void 0),t),{})}format(e,t){if(q.concat(C).indexOf(e)>-1)t?this.domNode.setAttribute("data-".concat(e),t):this.domNode.removeAttribute("data-".concat(e));else if("header"===e){if(!t)return;const{row:o,cell:n,rowspan:r,colspan:i}=T.formats(this.domNode);super.format(e,{value:t,row:o,cell:n,rowspan:r,colspan:i})}else super.format(e,t)}optimize(e){const t=this.domNode.getAttribute("data-row"),o=this.domNode.getAttribute("data-rowspan"),n=this.domNode.getAttribute("data-colspan");!this.statics.requiredContainer||this.parent instanceof this.statics.requiredContainer||this.wrap(this.statics.requiredContainer.blotName,{row:t,colspan:n,rowspan:o}),super.optimize(e)}tableCell(){return this.parent}}T.blotName="table-cell-line",T.ClassName="qlbt-cell-line",T.tagName="DIV";class A extends w{checkMerge(){if(super.checkMerge()&&null!=this.next.children.head){const e=this.children.head.formats()[this.children.head.statics.blotName],t=this.children.tail.formats()[this.children.tail.statics.blotName],o=this.next.children.head.formats()[this.next.children.head.statics.blotName],n=this.next.children.tail.formats()[this.next.children.tail.statics.blotName];return e.cell===t.cell&&e.cell===o.cell&&e.cell===n.cell}return!1}static create(e){const t=super.create(e);return t.setAttribute("data-row",e.row),q.forEach(o=>{e[o]&&t.setAttribute(o,e[o])}),t}static formats(e){const t={};return e.hasAttribute("data-row")&&(t.row=e.getAttribute("data-row")),q.reduce((t,o)=>(e.hasAttribute(o)&&(t[o]=e.getAttribute(o)),t),t)}cellOffset(){return this.parent?this.parent.children.indexOf(this):-1}formats(){const e={};return this.domNode.hasAttribute("data-row")&&(e.row=this.domNode.getAttribute("data-row")),q.reduce((e,t)=>(this.domNode.hasAttribute(t)&&(e[t]=this.domNode.getAttribute(t)),e),e)}toggleAttribute(e,t){t?this.domNode.setAttribute(e,t):this.domNode.removeAttribute(e)}formatChildren(e,t){this.children.forEach(o=>{o.format(e,t)})}format(e,t){q.indexOf(e)>-1?(this.toggleAttribute(e,t),this.formatChildren(e,t)):["row"].indexOf(e)>-1?(this.toggleAttribute("data-".concat(e),t),this.formatChildren(e,t)):super.format(e,t)}optimize(e){const t=this.domNode.getAttribute("data-row");!this.statics.requiredContainer||this.parent instanceof this.statics.requiredContainer||this.wrap(this.statics.requiredContainer.blotName,{row:t}),super.optimize(e)}row(){return this.parent}rowOffset(){return this.row()?this.row().rowOffset():-1}table(){return this.row()&&this.row().table()}}A.blotName="table",A.tagName="TD";class S extends w{checkMerge(){if(super.checkMerge()&&null!=this.next.children.head){const e=this.children.head.formats(),t=this.children.tail.formats(),o=this.next.children.head.formats(),n=this.next.children.tail.formats();return e.row===t.row&&e.row===o.row&&e.row===n.row}return!1}static create(e){const t=super.create(e);return t.setAttribute("data-row",e.row),t}formats(){return["row"].reduce((e,t)=>(this.domNode.hasAttribute("data-".concat(t))&&(e[t]=this.domNode.getAttribute("data-".concat(t))),e),{})}optimize(e){!this.statics.requiredContainer||this.parent instanceof this.statics.requiredContainer||this.wrap(this.statics.requiredContainer.blotName),this.enforceAllowedChildren(),null!=this.uiNode&&this.uiNode!==this.domNode.firstChild&&this.domNode.insertBefore(this.uiNode,this.domNode.firstChild),this.children.length>0&&null!=this.next&&this.checkMerge()&&(this.next.moveChildren(this),this.next.remove())}rowOffset(){return this.parent?this.parent.children.indexOf(this):-1}table(){return this.parent&&this.parent.parent}}S.blotName="table-row",S.tagName="TR";class O extends w{}O.blotName="table-body",O.tagName="TBODY";class B extends y{static create(e){let t=super.create(e);return x.forEach(o=>{t.setAttribute("".concat(o),e[o]||N[o])}),t}static formats(e){return x.reduce((t,o)=>(e.hasAttribute("".concat(o))&&(t[o]=e.getAttribute("".concat(o))||void 0),t),{})}format(e,t){x.indexOf(e)>-1?this.domNode.setAttribute("".concat(e),t||N[e]):super.format(e,t)}html(){return this.domNode.outerHTML}}B.blotName="table-col",B.tagName="col";class R extends w{}R.blotName="table-col-group",R.tagName="colgroup";class L extends w{static create(){return super.create()}constructor(e,t){super(e,t),this.updateTableWidth()}updateTableWidth(){setTimeout(()=>{const e=this.colGroup();if(!e)return;const t=e.children.reduce((e,t)=>e+=parseInt(t.formats()[B.blotName].width,10),0);this.domNode.style.width="".concat(t,"px")},0)}cells(e){return this.rows().map(t=>t.children.at(e))}colGroup(){return this.children.head}deleteColumns(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[],o=arguments.length>2?arguments[2]:void 0;const[n]=this.descendants(O);if(null==n||null==n.children.head)return;const r=this.descendants(A),i=[],s=[];if(r.forEach(t=>{const n=l(t.domNode.getBoundingClientRect(),o);n.x+E>e.x&&n.x1-E<e.x1?i.push(t):n.x<e.x+E&&n.x1>e.x1-E&&s.push(t)}),i.length===r.length)return this.tableDestroy(),!0;t.forEach(e=>{this.colGroup().children.at(t[0]).remove()}),i.forEach(e=>{e.remove()}),s.forEach(e=>{const o=parseInt(e.formats().colspan,10);parseInt(e.formats().width,10);e.format("colspan",o-t.length)}),this.updateTableWidth()}deleteRow(e,t){const[o]=this.descendants(O);if(null==o||null==o.children.head)return;const n=this.descendants(A),r=[],i=[],s=[];if(n.forEach(o=>{const n=l(o.domNode.getBoundingClientRect(),t);n.y>e.y-E&&n.y1<e.y1+E?r.push(o):n.y<e.y+E&&n.y1>e.y1-E&&(i.push(o),Math.abs(n.y-e.y)<E&&s.push(o))}),r.length===n.length)return void this.tableDestroy();const a=this.rows().reduce((o,n)=>{let r=l(n.domNode.getBoundingClientRect(),t);return r.y>e.y-E&&r.y1<e.y1+E&&(o+=1),o},0);s.forEach(e=>{const o=l(e.domNode.getBoundingClientRect(),t),n=e.parent.next,r=n.children.reduce((e,n)=>{const r=l(n.domNode.getBoundingClientRect(),t);return Math.abs(o.x1-r.x)<E&&(e=n),e},null);n.insertBefore(e,r),e.format("row",n.formats().row)}),r.forEach(e=>{e.remove()}),i.forEach(e=>{const t=parseInt(e.formats().rowspan,10);e.format("rowspan",t-a)})}tableDestroy(){const e=r.a.find(this.scroll.domNode.parentNode),t=e.getModule("better-table");this.remove(),t.hideTableTools(),e.update(r.a.sources.USER)}insertCell(e,t){const o=k(),n=e.formats().row,r=this.scroll.create(A.blotName,Object.assign({},v,{row:n})),i=this.scroll.create(T.blotName,{row:n,cell:o});r.appendChild(i),t?e.insertBefore(r,t):e.appendChild(r)}insertColumn(e,t){let o=!(arguments.length>2&&void 0!==arguments[2])||arguments[2],n=arguments.length>3?arguments[3]:void 0;const[r]=this.descendants(O),[i]=this.descendants(R),s=this.descendants(B);let a=[],c=[],d=[];if(null==r||null==r.children.head)return;this.descendants(A).forEach(t=>{const r=l(t.domNode.getBoundingClientRect(),n);o?Math.abs(r.x1-e.x1)<E?a.push(t):e.x1-r.x>E&&e.x1-r.x1<-E&&c.push(t):Math.abs(r.x-e.x)<E?a.push(t):e.x-r.x>E&&e.x-r.x1<-E&&c.push(t)}),a.forEach(e=>{const t=o?e.next:e,n=k(),r=e.parent,i=r.formats().row,l=e.formats(),s=this.scroll.create(A.blotName,Object.assign({},v,{row:i,rowspan:l.rowspan})),a=this.scroll.create(T.blotName,{row:i,cell:n,rowspan:l.rowspan});s.appendChild(a),t?r.insertBefore(s,t):r.appendChild(s),d.push(s)});const u=this.scroll.create(B.blotName,!0);let h=o?s[t].next:s[t];return h?i.insertBefore(u,h):i.appendChild(u),c.forEach(e=>{const t=e.formats().colspan;e.format("colspan",parseInt(t,10)+1),d.push(e)}),d.sort((e,t)=>{return e.domNode.getBoundingClientRect().y-t.domNode.getBoundingClientRect().y}),this.updateTableWidth(),d}insertRow(e,t,o){const[n]=this.descendants(O);if(null==n||null==n.children.head)return;const r=this.descendants(A),i=I(),s=this.scroll.create(S.blotName,{row:i});let a=[],c=[],d=[];r.forEach(n=>{const r=l(n.domNode.getBoundingClientRect(),o);t?Math.abs(r.y1-e.y1)<E?a.push(n):e.y1-r.y>E&&e.y1-r.y1<-E&&c.push(n):Math.abs(r.y-e.y)<E?a.push(n):e.y-r.y>E&&e.y-r.y1<-E&&c.push(n)});const u=(e,t)=>{return e.domNode.getBoundingClientRect().x-t.domNode.getBoundingClientRect().x};a.sort(u),a.forEach(e=>{const t=k(),o=e.formats(),n=this.scroll.create(A.blotName,Object.assign({},v,{row:i,colspan:o.colspan})),r=this.scroll.create(T.blotName,{row:i,cell:t,colspan:o.colspan}),l=this.scroll.create(g.blotName);r.appendChild(l),n.appendChild(r),s.appendChild(n),d.push(n)}),c.forEach(e=>{const t=parseInt(e.formats().rowspan,10);e.format("rowspan",t+1),d.push(e)});const h=this.rows().find(n=>{let r=l(n.domNode.getBoundingClientRect(),o);return t?Math.abs(r.y-e.y-e.height)<E:Math.abs(r.y-e.y)<E});return n.insertBefore(s,h),d.sort(u),d}mergeCells(e,t,o,n,r){const i=t.reduce((e,t,r)=>(0!==r?(e&&t.moveChildren(e),t.remove()):(t.format("colspan",n),t.format("rowspan",o),e=t),e),null);let l=i.domNode.getAttribute("data-row"),s=i.children.head.domNode.getAttribute("data-cell");return i.children.forEach(e=>{e.format("cell",s),e.format("row",l),e.format("colspan",n),e.format("rowspan",o)}),i}unmergeCells(e,t){let o={},n=1,r=1;e.forEach(e=>{if(o=e.formats(),n=o.rowspan,(r=o.colspan)>1){let t=e.next,o=e.row();e.format("colspan",1);for(let e=r;e>1;e--)this.insertCell(o,t)}if(n>1){let o=n,i=e.row().next;for(;o>1;){let n=i.children.reduce((o,n)=>{let r=l(e.domNode.getBoundingClientRect(),t),i=l(n.domNode.getBoundingClientRect(),t);return Math.abs(r.x1-i.x)<E&&(o=n),o},null);for(let e=r;e>0;e--)this.insertCell(i,n);o-=1,i=i.next}e.format("rowspan",1)}})}rows(){const e=this.children.tail;return null==e?[]:e.children.map(e=>e)}}L.blotName="table-container",L.className="quill-better-table",L.tagName="TABLE";class M extends w{constructor(e,t){super(e,t);const o=r.a.find(e.domNode.parentNode);t.addEventListener("scroll",e=>{const t=o.getModule("better-table");t.columnTool&&(t.columnTool.domNode.scrollLeft=e.target.scrollLeft),t.tableSelection&&t.tableSelection.selectedTds.length>0&&t.tableSelection.repositionHelpLines()},!1)}}function I(){const e=Math.random().toString(36).slice(2,6);return"row-".concat(e)}function k(){const e=Math.random().toString(36).slice(2,6);return"cell-".concat(e)}M.blotName="table-view",M.className="quill-better-table-wrapper",M.tagName="DIV",M.allowedChildren=[L],L.requiredContainer=M,L.allowedChildren=[O,R],O.requiredContainer=L,O.allowedChildren=[S],S.requiredContainer=O,S.allowedChildren=[A],A.requiredContainer=S,A.allowedChildren=[T,m],T.requiredContainer=A,R.allowedChildren=[B],R.requiredContainer=L,B.requiredContainer=R;const H="#35A7ED",D=["left","right","top","bottom"],j=2;class _{constructor(e,t,o){if(!e)return null;this.table=e,this.quill=t,this.options=o,this.boundary={},this.selectedTds=[],this.dragging=!1,this.selectingHandler=this.mouseDownHandler.bind(this),this.clearSelectionHanler=this.clearSelection.bind(this),this.helpLinesInitial(),this.quill.root.addEventListener("mousedown",this.selectingHandler,!1),this.quill.on("text-change",this.clearSelectionHanler)}helpLinesInitial(){let e=this.quill.root.parentNode;D.forEach(t=>{this[t]=document.createElement("div"),this[t].classList.add("qlbt-selection-line"),i(this[t],{position:"absolute",display:"none","background-color":H}),e.appendChild(this[t])})}mouseDownHandler(e){if(0!==e.button||!e.target.closest(".quill-better-table"))return;this.quill.root.addEventListener("mousemove",r,!1),this.quill.root.addEventListener("mouseup",function e(o){t.quill.root.removeEventListener("mousemove",r,!1);t.quill.root.removeEventListener("mouseup",e,!1);t.dragging=!1},!1);const t=this,o=e.target.closest("td[data-row]"),n=l(o.getBoundingClientRect(),this.quill.root.parentNode);function r(e){if(0!==e.button||!e.target.closest(".quill-better-table"))return;const r=e.target.closest("td[data-row]"),i=l(r.getBoundingClientRect(),t.quill.root.parentNode);t.boundary=U(n,i),t.correctBoundary(),t.selectedTds=t.computeSelectedTds(),t.repositionHelpLines(),o!==r&&t.quill.blur()}this.dragging=!0,this.boundary=U(n,n),this.correctBoundary(),this.selectedTds=this.computeSelectedTds(),this.repositionHelpLines()}correctBoundary(){r.a.find(this.table).descendants(A).forEach(e=>{let{x:t,y:o,width:n,height:r}=l(e.domNode.getBoundingClientRect(),this.quill.root.parentNode);(t+j>=this.boundary.x&&t+j<=this.boundary.x1||t-j+n>=this.boundary.x&&t-j+n<=this.boundary.x1)&&(o+j>=this.boundary.y&&o+j<=this.boundary.y1||o-j+r>=this.boundary.y&&o-j+r<=this.boundary.y1)&&(this.boundary=U(this.boundary,{x:t,y:o,width:n,height:r}))})}computeSelectedTds(){return r.a.find(this.table).descendants(A).reduce((e,t)=>{let{x:o,y:n,width:r,height:i}=l(t.domNode.getBoundingClientRect(),this.quill.root.parentNode);return o+j>=this.boundary.x&&o-j+r<=this.boundary.x1&&n+j>=this.boundary.y&&n-j+i<=this.boundary.y1&&e.push(t),e},[])}repositionHelpLines(){const e=this.table.parentNode.scrollLeft;i(this.left,{display:"block",left:"".concat(this.boundary.x-e-1,"px"),top:"".concat(this.boundary.y,"px"),height:"".concat(this.boundary.height+1,"px"),width:"1px"}),i(this.right,{display:"block",left:"".concat(this.boundary.x1-e,"px"),top:"".concat(this.boundary.y,"px"),height:"".concat(this.boundary.height+1,"px"),width:"1px"}),i(this.top,{display:"block",left:"".concat(this.boundary.x-1-e,"px"),top:"".concat(this.boundary.y,"px"),width:"".concat(this.boundary.width+1,"px"),height:"1px"}),i(this.bottom,{display:"block",left:"".concat(this.boundary.x-1-e,"px"),top:"".concat(this.boundary.y1+1,"px"),width:"".concat(this.boundary.width+1,"px"),height:"1px"})}refreshHelpLinesPosition(){const e=l(this.selectedTds[0].domNode.getBoundingClientRect(),this.quill.root.parentNode),t=l(this.selectedTds[this.selectedTds.length-1].domNode.getBoundingClientRect(),this.quill.root.parentNode);this.boundary=U(e,t),this.repositionHelpLines()}destroy(){return D.forEach(e=>{this[e].remove(),this[e]=null}),this.quill.root.removeEventListener("mousedown",this.selectingHandler,!1),this.quill.off("text-change",this.clearSelectionHanler),null}setSelection(e,t){this.boundary=U(l(e,this.quill.root.parentNode),l(t,this.quill.root.parentNode)),this.correctBoundary(),this.selectedTds=this.computeSelectedTds(),this.repositionHelpLines()}clearSelection(){this.boundary={},this.selectedTds=[],D.forEach(e=>{this[e]&&i(this[e],{display:"none"})})}}function U(e,t){let o=Math.min(e.x,t.x,e.x+e.width-1,t.x+t.width-1),n=Math.max(e.x,t.x,e.x+e.width-1,t.x+t.width-1),r=Math.min(e.y,t.y,e.y+e.height-1,t.y+t.height-1),i=Math.max(e.y,t.y,e.y+e.height-1,t.y+t.height-1);return{x:o,x1:n,y:r,y1:i,width:n-o,height:i-r}}const P=150,W=200,z={insertColumnRight:{text:"Insert column right",handler(){const e=r.a.find(this.table);let t=X(this.columnToolCells,this.boundary,(e,t)=>Math.abs(e.x+e.width-t.x1)<=5,this.quill.root.parentNode);const o=e.insertColumn(this.boundary,t,!0,this.quill.root.parentNode);this.tableColumnTool.updateToolCells(),this.quill.update(r.a.sources.USER),this.quill.setSelection(this.quill.getIndex(o[0]),0,r.a.sources.SILENT),this.tableSelection.setSelection(o[0].domNode.getBoundingClientRect(),o[0].domNode.getBoundingClientRect())}},insertColumnLeft:{text:"Insert column left",handler(){const e=r.a.find(this.table);let t=X(this.columnToolCells,this.boundary,(e,t)=>Math.abs(e.x-t.x)<=5,this.quill.root.parentNode);const o=e.insertColumn(this.boundary,t,!1,this.quill.root.parentNode);this.tableColumnTool.updateToolCells(),this.quill.update(r.a.sources.USER),this.quill.setSelection(this.quill.getIndex(o[0]),0,r.a.sources.SILENT),this.tableSelection.setSelection(o[0].domNode.getBoundingClientRect(),o[0].domNode.getBoundingClientRect())}},insertRowUp:{text:"Insert row up",handler(){const e=r.a.find(this.table).insertRow(this.boundary,!1,this.quill.root.parentNode);this.quill.update(r.a.sources.USER),this.quill.setSelection(this.quill.getIndex(e[0]),0,r.a.sources.SILENT),this.tableSelection.setSelection(e[0].domNode.getBoundingClientRect(),e[0].domNode.getBoundingClientRect())}},insertRowDown:{text:"Insert row down",handler(){const e=r.a.find(this.table).insertRow(this.boundary,!0,this.quill.root.parentNode);this.quill.update(r.a.sources.USER),this.quill.setSelection(this.quill.getIndex(e[0]),0,r.a.sources.SILENT),this.tableSelection.setSelection(e[0].domNode.getBoundingClientRect(),e[0].domNode.getBoundingClientRect())}},mergeCells:{text:"Merge selected cells",handler(){const e=r.a.find(this.table),t=e.rows().reduce((e,t)=>{let o=l(t.domNode.getBoundingClientRect(),this.quill.root.parentNode);return o.y>this.boundary.y-5&&o.y+o.height<this.boundary.y+this.boundary.height+5&&(e+=1),e},0),o=this.columnToolCells.reduce((e,t)=>{let o=l(t.getBoundingClientRect(),this.quill.root.parentNode);return o.x>this.boundary.x-5&&o.x+o.width<this.boundary.x+this.boundary.width+5&&(e+=1),e},0),n=e.mergeCells(this.boundary,this.selectedTds,t,o,this.quill.root.parentNode);this.quill.update(r.a.sources.USER),this.tableSelection.setSelection(n.domNode.getBoundingClientRect(),n.domNode.getBoundingClientRect())}},unmergeCells:{text:"Unmerge cells",handler(){r.a.find(this.table).unmergeCells(this.selectedTds,this.quill.root.parentNode),this.quill.update(r.a.sources.USER),this.tableSelection.clearSelection()}},deleteColumn:{text:"Delete selected columns",handler(){const e=r.a.find(this.table);let t=function(e,t,o,n){return e.reduce((r,i)=>{let s=l(i.getBoundingClientRect(),n);return o(s,t)&&r.push(e.indexOf(i)),r},[])}(this.columnToolCells,this.boundary,(e,t)=>e.x+5>t.x&&e.x+e.width-5<t.x1,this.quill.root.parentNode);e.deleteColumns(this.boundary,t,this.quill.root.parentNode)||(this.tableColumnTool.updateToolCells(),this.quill.update(r.a.sources.USER),this.tableSelection.clearSelection())}},deleteRow:{text:"Delete selected rows",handler(){r.a.find(this.table).deleteRow(this.boundary,this.quill.root.parentNode),this.quill.update(r.a.sources.USER),this.tableSelection.clearSelection()}},deleteTable:{text:"Delete table",handler(){const e=this.quill.getModule("better-table"),t=r.a.find(this.table);e.hideTableTools(),t.remove(),this.quill.update(r.a.sources.USER)}}};class G{constructor(e,t,o){const n=t.getModule("better-table");this.tableSelection=n.tableSelection,this.table=e.table,this.quill=t,this.options=o,this.menuItems=Object.assign({},z,o.items),this.tableColumnTool=n.columnTool,this.boundary=this.tableSelection.boundary,this.selectedTds=this.tableSelection.selectedTds,this.destroyHanlder=this.destroy.bind(this),this.columnToolCells=this.tableColumnTool.colToolCells(),this.menuInitial(e),this.mount(),document.addEventListener("click",this.destroyHanlder,!1)}mount(){document.body.appendChild(this.domNode)}destroy(){return this.domNode.remove(),document.removeEventListener("click",this.destroyHanlder,!1),null}menuInitial(e){let{table:t,left:o,top:n}=e;this.domNode=document.createElement("div"),this.domNode.classList.add("qlbt-operation-menu"),i(this.domNode,{position:"absolute",left:"".concat(o,"px"),top:"".concat(n,"px"),"min-height":"".concat(P,"px"),width:"".concat(W,"px")});for(let e in this.menuItems)this.menuItems[e]&&this.domNode.appendChild(this.menuItemCreator(Object.assign({},z[e],this.menuItems[e])))}menuItemCreator(e){let{text:t,handler:o}=e;const n=document.createElement("div");return n.classList.add("qlbt-operation-menu-item"),n.innerText=t,n.addEventListener("click",o.bind(this),!1),n}}function X(e,t,o,n){return e.reduce((r,i)=>{let s=l(i.getBoundingClientRect(),n);return o(s,t)&&(r=e.indexOf(i)),r},!1)}const K=r.a.import("delta");function V(e,t,o){const n=e.parentNode,r="TABLE"===n.parentNode.tagName?n.parentNode:n.parentNode.parentNode,i=Array.from(r.querySelectorAll("tr")),l=Array.from(n.querySelectorAll("td")),a=i.indexOf(n)+1,c=l.indexOf(e)+1,d=e.getAttribute("colspan")||!1,u=e.getAttribute("rowspan")||!1;return 0===t.length()?t=(new K).insert("\n",{"table-cell-line":{row:a,cell:c,rowspan:u,colspan:d}}):(t=t.reduce((e,t)=>{if(t.insert&&"string"==typeof t.insert){const o=[];let n=t.insert,r=0;for(let e=0;e<t.insert.length;e++)"\n"===n.charAt(e)&&(0===e?o.push("\n"):(o.push(n.substring(r,e)),o.push("\n")),r=e+1);const i=n.substring(r);i&&o.push(i),o.forEach(o=>{"\n"===o?e.insert("\n",t.attributes):e.insert(o,s(t.attributes,["table","table-cell-line","header"]))})}else e.insert(t.insert,t.attributes);return e},new K)).reduce((e,t)=>{if(t.insert&&"string"==typeof t.insert&&t.insert.startsWith("\n")){let o={};t.attributes.header?o.header={row:a,cell:c,rowspan:u,colspan:d}:t.attributes["table-cell-line"]&&(o["table-cell-line"]={row:a,cell:c,rowspan:u,colspan:d}),e.insert(t.insert,Object.assign({},Object.assign({},{row:a},t.attributes.table),o,s(t.attributes,["table"])))}else e.insert(t.insert,Object.assign({},s(t.attributes,["table","table-cell-line"])));return console.log(e),e},new K)}function Y(e,t,o){const n=e.parentNode,r="TABLE"===n.parentNode.tagName?n.parentNode:n.parentNode.parentNode,i=Array.from(r.querySelectorAll("tr")),l=Array.from(n.querySelectorAll("th")),a=i.indexOf(n)+1,c=l.indexOf(e)+1,d=e.getAttribute("colspan")||!1,u=e.getAttribute("rowspan")||!1;return 0===t.length()?t=(new K).insert("\n",{"table-cell-line":{row:a,cell:c,rowspan:u,colspan:d}}):(t=t.reduce((e,t)=>{if(t.insert&&"string"==typeof t.insert){const o=[];let n=t.insert,r=0;for(let e=0;e<t.insert.length;e++)"\n"===n.charAt(e)&&(0===e?o.push("\n"):(o.push(n.substring(r,e)),o.push("\n")),r=e+1);const i=n.substring(r);i&&o.push(i),o.indexOf("\n")<0&&o.push("\n"),o.forEach(o=>{"\n"===o?e.insert("\n",{"table-cell-line":{row:a,cell:c,rowspan:u,colspan:d}}):e.insert(o,t.attributes)})}else e.insert(t.insert,t.attributes);return e},new K)).reduce((e,t)=>(t.insert&&"string"==typeof t.insert&&t.insert.startsWith("\n")?e.insert(t.insert,Object.assign({},{"table-cell-line":{row:a,cell:c,rowspan:u,colspan:d}})):e.insert(t.insert,Object.assign({},s(t.attributes,["table","table-cell-line"]))),e),new K)}function J(e,t,o){let n=new K;const r=e.querySelector("tr");if(null===r)return n;const i=Array.from(r.querySelectorAll("td")).concat(Array.from(r.querySelectorAll("th"))).reduce((e,t)=>{const o=t.getAttribute("colspan")||1;return e+=parseInt(o,10)},0),l=e.querySelectorAll("col").length;if(l===i)return t;{for(let e=0;e<i-l;e++)n.insert("\n",{"table-col":!0});if(0===l)return n.concat(t);let e=0;return t.reduce((t,o)=>(t.insert(o.insert,o.attributes),o.attributes&&o.attributes["table-col"]&&(e+=o.insert.length)===l&&(t=t.concat(n)),t),new K)}}const Q=r.a.import("core/module"),$=r.a.import("delta");class F extends Q{static register(){r.a.register(B,!0),r.a.register(R,!0),r.a.register(T,!0),r.a.register(A,!0),r.a.register(S,!0),r.a.register(O,!0),r.a.register(L,!0),r.a.register(M,!0),r.a.register(M,!0)}constructor(e,t){super(e,t),this.quill.root.addEventListener("click",o=>{const n=a(o);if(!n||n.length<=0)return;const r=n.filter(e=>e.tagName&&"TABLE"===e.tagName.toUpperCase()&&e.classList.contains("quill-better-table"))[0];if(r){if(this.table===r)return;this.table&&this.hideTableTools(),this.showTableTools(r,e,t)}else this.table&&this.hideTableTools()},!1),this.quill.root.addEventListener("contextmenu",o=>{if(!this.table)return!0;o.preventDefault();const n=a(o);if(!n||n.length<=0)return;const r=n.filter(e=>e.tagName&&"TABLE"===e.tagName.toUpperCase()&&e.classList.contains("quill-better-table"))[0],i=n.filter(e=>e.tagName&&"TR"===e.tagName.toUpperCase()&&e.getAttribute("data-row"))[0],l=n.filter(e=>e.tagName&&"TD"===e.tagName.toUpperCase()&&e.getAttribute("data-row"))[0];let s=this.tableSelection.selectedTds.map(e=>e.domNode).includes(l);(this.tableSelection.selectedTds.length<=0||!s)&&this.tableSelection.setSelection(l.getBoundingClientRect(),l.getBoundingClientRect()),this.tableOperationMenu&&(this.tableOperationMenu=this.tableOperationMenu.destroy()),r&&(this.tableOperationMenu=new G({table:r,row:i,cell:l,left:o.pageX,top:o.pageY},e,t.operationMenu))},!1);e.getModule("keyboard");e.keyboard.addBinding({key:"Backspace"},{},function(e,t){if(0===e.index||this.quill.getLength()<=1)return!0;const[o]=this.quill.getLine(e.index);if(0===t.offset){const[t]=this.quill.getLine(e.index-1);if(null!=t&&"table-cell-line"===t.statics.blotName&&"table-cell-line"!==o.statics.blotName)return!1}return!0});let o=e.keyboard.bindings.Backspace.pop();e.keyboard.bindings.Backspace.splice(0,1,o),e.clipboard.addMatcher("td",V),e.clipboard.addMatcher("th",Y),e.clipboard.addMatcher("table",J),e.clipboard.matchers=e.clipboard.matchers.filter(e=>"tr"!==e[0])}getTable(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.quill.getSelection();if(null==e)return[null,null,null,-1];const[t,o]=this.quill.getLine(e.index);if(null==t||t.statics.blotName!==T.blotName)return[null,null,null,-1];const n=t.tableCell(),r=n.row();return[r.table(),r,n,o]}insertTable(e,t){const o=this.quill.getSelection(!0);if(null==o)return;this.quill.getLeaf(o.index)[0],this.quill.getLeaf(o.index+1)[0];let n=(new $).retain(o.index);n.insert("\n"),n=new Array(t).fill("\n").reduce((e,t)=>(e.insert(t,{"table-col":!0}),e),n),n=new Array(e).fill(0).reduce(e=>{let o=I();return new Array(t).fill("\n").reduce((e,t)=>(e.insert(t,{"table-cell-line":{row:o,cell:k()}}),e),e)},n),this.quill.updateContents(n,r.a.sources.USER),this.quill.setSelection(o.index+t+1,r.a.sources.API)}showTableTools(e,t,o){this.table=e,this.columnTool=new p(e,t,o),this.tableSelection=new _(e,t,o)}hideTableTools(){this.columnTool&&this.columnTool.destroy(),this.tableSelection&&this.tableSelection.destroy(),this.tableOperationMenu&&this.tableOperationMenu.destroy(),this.columnTool=null,this.tableSelection=null,this.tableOperationMenu=null,this.table=null}}F.keyboardBindings={"table-cell-line backspace":{key:"Backspace",format:["table-cell-line"],collapsed:!0,offset:0,handler(e,t){const[o,n]=this.quill.getLine(e.index);return!(!o.prev||"table-cell-line"!==o.prev.statics.blotName)}},"table-cell-line delete":{key:"Delete",format:["table-cell-line"],collapsed:!0,suffix:/^$/,handler(){}},"table-cell-line enter":{key:"Enter",shiftKey:null,format:["table-cell-line"],handler(e,t){if(this.quill.selection&&this.quill.selection.composing)return;const o=r.a.imports.parchment.Scope;e.length>0&&this.quill.scroll.deleteAt(e.index,e.length);const n=Object.keys(t.format).reduce((e,n)=>(this.quill.scroll.query(n,o.BLOCK)&&!Array.isArray(t.format[n])&&(e[n]=t.format[n]),e),{});this.quill.insertText(e.index,"\n",n["table-cell-line"],r.a.sources.USER),this.quill.setSelection(e.index+1,r.a.sources.SILENT),this.quill.focus(),Object.keys(t.format).forEach(e=>{null==n[e]&&(Array.isArray(t.format[e])||"link"!==e&&this.quill.format(e,t.format[e],r.a.sources.USER))})}}};t.default=F}]).default}); |
{ | ||
"name": "quill-better-table", | ||
"version": "1.1.12", | ||
"version": "1.1.13", | ||
"description": "Module for better table in Quill, more useful features are supported.", | ||
@@ -5,0 +5,0 @@ "main": "dist/quill-better-table.js", |
@@ -10,6 +10,8 @@ # quill-better-table | ||
<li> | ||
<p>Supporting headers in table cell. (Already done in v1.1.9)</p> | ||
<p>Supporting headers in table cell.(cancelled)</p> | ||
<p>(Already done in v1.1.9, but overwrited quill built-in header blot, maybe this is a bad idea, so I cancel this feature in v1.1.13. This feature may be an optional feature in another module.)</p> | ||
</li> | ||
<li> | ||
<p>Supporting un/ordered list in table cell.</p> | ||
<p>Supporting un/ordered list in table cell.(cancelled)</p> | ||
<p>To implement this, it will do harm to quill built-in blot. This feature may be an optional feature in another module.</p> | ||
</li> | ||
@@ -16,0 +18,0 @@ <li> |
@@ -46,3 +46,3 @@ import Quill from 'quill' | ||
// register customized Header,overwriting quill built-in Header | ||
Quill.register('formats/header', Header, true); | ||
// Quill.register('formats/header', Header, true); | ||
} | ||
@@ -160,3 +160,3 @@ | ||
quill.clipboard.addMatcher('table', matchTable) | ||
quill.clipboard.addMatcher('h1, h2, h3, h4, h5, h6', matchHeader) | ||
// quill.clipboard.addMatcher('h1, h2, h3, h4, h5, h6', matchHeader) | ||
@@ -163,0 +163,0 @@ // remove matcher for tr tag |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
324458
195