quill-table-up 2.4.0 → 2.4.1
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/dist/index.css +1 -1
- package/dist/index.js +3 -3
- package/dist/index.js.map +1 -1
- package/dist/index.umd.js +3 -3
- package/dist/index.umd.js.map +1 -1
- package/package.json +2 -2
- package/src/__tests__/e2e/table-blots.test.ts +22 -0
- package/src/formats/overrides/block.ts +13 -0
- package/src/modules/table-resize/table-resize-common.ts +2 -4
- package/src/modules/table-scrollbar.ts +4 -5
- package/src/node_modules/.vite/vitest/da39a3ee5e6b4b0d3255bfef95601890afd80709/results.json +1 -1
- package/src/style/table-selection.less +0 -1
package/dist/index.css
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
.ql-toolbar .ql-picker:not(.ql-color-picker):not(.ql-icon-picker).ql-table-up{width:28px}.ql-toolbar .ql-picker:not(.ql-color-picker):not(.ql-icon-picker).ql-table-up .ql-picker-label{padding:2px 4px}.ql-toolbar .ql-picker:not(.ql-color-picker):not(.ql-icon-picker).ql-table-up .ql-picker-label svg{position:static;margin-top:0}.ql-toolbar .ql-picker.ql-expanded .ql-picker-options{z-index:1}.ql-editor .ql-table{display:table;border-collapse:collapse;table-layout:fixed;width:auto}.ql-editor .ql-table[data-full]{width:100%}.ql-editor .ql-table-wrapper{width:100%;overflow:auto;scrollbar-width:none}.ql-editor .ql-table-caption{position:relative;word-break:break-word;outline:0}.ql-editor .ql-table-caption .ql-table-caption--switch{display:flex;align-items:center;justify-content:center;padding:2px;border-radius:4px;border:1px solid #0003;font-size:12px;cursor:pointer;background-color:#fff}.ql-editor .ql-table-caption .ql-table-caption--switch:hover{background-color:#eee}.ql-editor .ql-table-cell{padding:8px 12px;border-color:transparent;font-size:14px;outline:0;overflow:auto}.ql-editor .ql-table-cell-inner{display:inline-block;min-width:100%;word-break:break-word;outline:0;counter-reset:list-0}.ql-editor .ql-table col{border-collapse:separate;text-indent:initial;display:table-column;table-layout:fixed}.ql-editor .ql-table tr+tr td{border-top:none}.ql-editor .ql-table td{border:1px solid #a1a1aa}.ql-editor .ql-table td+td{border-left:none}.table-up-toolbox{position:absolute;top:0;left:0;width:100%;height:100%;overflow:hidden;pointer-events:none}.table-up-toolbox *{pointer-events:all}.table-up-tooltip{position:absolute;z-index:20;padding:.25rem .75rem;border-radius:.25rem;font-size:.75rem;color:#fff;white-space:nowrap;background-color:#303133;transition:opacity .15s linear}.table-up-tooltip.transparent{opacity:0}.table-up-tooltip.hidden{display:none}.table-up-button{--table-btn-color:#606266;--table-btn-bg-hover:#f3f4f6;--table-btn-color-border:#dcdfe6;--table-btn-border:0.0625rem solid var(--table-btn-color-border);--table-btn-confirm-color-border:#409eff;--table-btn-confirm-bg:#409eff;--table-btn-confirm-hover:#79bbff;--table-btn-confirm-outline-focus-visible:0.125rem solid #a0cfff;box-sizing:border-box;display:inline-flex;height:2rem;line-height:1;margin:0;padding:.5rem 1rem;border-radius:.25rem;border:var(--table-btn-border);color:var(--table-btn-color);background-color:transparent;font-size:.875rem;cursor:pointer}.table-up-button+.table-up-button{margin-left:.375rem}.table-up-button:hover{background-color:var(--table-btn-bg-hover)}.table-up-button.confirm{border-color:var(--table-btn-confirm-color-border);background-color:var(--table-btn-confirm-bg);color:#fff}.table-up-button.confirm:hover{border-color:var(--table-btn-confirm-hover);background-color:var(--table-btn-confirm-hover)}.table-up-button.confirm:focus-visible{outline:var(--table-btn-confirm-outline-focus-visible);outline-offset:.0625rem}.table-up-dialog{--dialog-bg:rgba(0, 0, 0, 0.5);--dialog-color-border:#ebeef5;--dialog-color-boxshadow:rgba(0, 0, 0, 0.12);--dialog-border:0.0625rem solid var(--dialog-color-border);--dialog-boxshadow:0 0 0.75rem var(--dialog-color-boxshadow);position:fixed;top:0;right:0;bottom:0;left:0;z-index:2000;height:100%;background-color:var(--dialog-bg);overflow:auto}.table-up-dialog__overlay{position:fixed;top:0;right:0;bottom:0;left:0;padding:1rem;overflow:auto;text-align:center}.table-up-dialog__overlay::after{content:'';display:inline-block;height:100%;width:0;vertical-align:middle}.table-up-dialog__content{display:inline-block;max-width:50vw;width:100%;vertical-align:middle;background-color:#fff;border-radius:.25rem;border:var(--dialog-border);font-size:1.125rem;box-shadow:var(--dialog-boxshadow);text-align:left;overflow:hidden;box-sizing:border-box}.table-up-color-picker{--color-picker-bg-color:#ffffff;box-sizing:border-box;display:inline-flex;flex-direction:column;width:16.75rem;padding:.5rem;border-radius:.375rem;background:var(--color-picker-bg-color);box-shadow:0 0 .375rem #b2b5b8}.table-up-color-picker__content{box-sizing:border-box;width:100%;height:11.75rem;padding-top:.5rem}.table-up-color-picker__selector{width:14.375rem;height:9.375rem;position:absolute}.table-up-color-picker__background{width:100%;height:100%;background:linear-gradient(to top,#000 0,rgba(0,0,0,0) 100%),linear-gradient(to right,#fff 0,rgba(255,255,255,0) 100%)}.table-up-color-picker__background-handle{box-sizing:border-box;position:absolute;border:.0625rem solid #fff;cursor:pointer;top:0;left:14.375rem;border-radius:100%;width:.625rem;height:.625rem;transform:translate(-.3125rem,-.3125rem)}.table-up-color-picker__hue{width:.75rem;height:9.375rem;margin-left:15rem;position:absolute;background:linear-gradient(0deg,red 0,#ff0 17%,#0f0 33%,#0ff 50%,#00f 67%,#f0f 83%,red)}.table-up-color-picker__hue-handle{box-sizing:border-box;position:absolute;border:.0625rem solid #fff;cursor:pointer;background-color:#fff;box-shadow:0 0 .125rem #0009;left:0;width:1rem;height:.625rem;transform:translate(-.125rem,-.3125rem)}.table-up-color-picker__alpha{width:14.375rem;height:.75rem;position:absolute;margin-top:10rem;background:linear-gradient(45deg,#ccc 25%,transparent 25%),linear-gradient(135deg,#ccc 25%,transparent 25%),linear-gradient(45deg,transparent 75%,#ccc 75%),linear-gradient(135deg,transparent 75%,#ccc 75%);background-size:.75rem .75rem;background-position:0 0,.375rem 0,.375rem -.375rem,0 .375rem}.table-up-color-picker__alpha-bg{position:relative;height:100%;background:linear-gradient(to right,rgba(255,255,255,0) 0,#fff 100%)}.table-up-color-picker__alpha-handle{box-sizing:border-box;position:absolute;border:.0625rem solid #fff;cursor:pointer;background-color:#fff;box-shadow:0 0 .125rem #0009;top:0;width:.625rem;height:1rem;transform:translate(-.3125rem,-.125rem)}.table-up-color-picker__action{box-sizing:border-box;display:flex;align-items:center;gap:.375rem;width:100%;padding-top:.5rem;border-top:.0625rem solid #e9ecef}.table-up-color-picker__action-item{flex:1;display:inline-flex;align-items:center;font-size:.75rem}.table-up-color-picker__input{box-sizing:border-box;width:100%;height:1.375rem;margin-left:.125rem;padding:.125rem 0 .125rem .25rem;background-color:#fff;border:.0625rem solid #ced4da;border-radius:.25rem;outline:0;color:#405057}.table-up-tooltip .table-up-color-picker{--color-picker-bg-color:transparent;box-shadow:none;width:15.75rem;padding:.5rem 0}.ql-container .table-up-selection{--select-color:#0589f340;display:none;position:absolute;overflow:hidden;pointer-events:none;z-index:-1}.ql-container .table-up-selection__line{position:absolute;background-color:var(--select-color);pointer-events:none}.table-up-resize-line__col,.table-up-resize-line__row{position:absolute;z-index:0}.table-up-resize-line__col.is-hidden,.table-up-resize-line__row.is-hidden{display:none}.table-up-resize-line__col::after,.table-up-resize-line__col::before,.table-up-resize-line__row::after,.table-up-resize-line__row::before{content:'';display:block;position:absolute;top:0;z-index:1}.table-up-resize-line__row{height:.0625rem;cursor:ns-resize}.table-up-resize-line__row::after,.table-up-resize-line__row::before{width:100%;height:.5rem}.table-up-resize-line__row::before{transform:translateY(-.5rem)}.table-up-resize-line__col{width:.0625rem;cursor:ew-resize}.table-up-resize-line__col::after,.table-up-resize-line__col::before{height:100%;width:.5rem}.table-up-resize-line__col::before{transform:translateX(-.5rem)}.table-up-resize-box{position:absolute;z-index:0}.table-up-resize-box.is-hidden{display:none}.table-up-resize-box.is-caption-bottom .table-up-resize-box__corner{border-top-width:0;border-bottom-width:.0625rem;border-top-left-radius:0;border-bottom-left-radius:50%}.table-up-resize-box.is-align-right .table-up-resize-box__col-separator{left:-.125rem}.table-up-resize-box.is-align-right .table-up-resize-box__corner{border-left-width:0;border-right-width:.0625rem;border-top-left-radius:0;border-top-right-radius:50%}.table-up-resize-box.is-align-right.is-caption-bottom .table-up-resize-box__corner{border-top-right-radius:0;border-bottom-left-radius:0;border-bottom-right-radius:50%}.table-up-resize-box__col,.table-up-resize-box__row{position:absolute;top:0;left:0;overflow:hidden}.table-up-resize-box__col-wrapper,.table-up-resize-box__row-wrapper{display:flex}.table-up-resize-box__col-header,.table-up-resize-box__row-header{position:relative;flex-shrink:0;background-color:#f3f4f5;border:.0625rem solid #ccc}.table-up-resize-box__col-wrapper{height:100%}.table-up-resize-box__col-header{height:100%;cursor:pointer;border-right-color:transparent}.table-up-resize-box__col-header:last-child{border-right-color:#ccc}.table-up-resize-box__col-separator{position:absolute;top:0;bottom:0;right:-.125rem;width:.125rem;cursor:ew-resize;z-index:0}.table-up-resize-box__col-separator::after{right:-.375rem}.table-up-resize-box__col-separator::before{left:-.375rem}.table-up-resize-box__col-separator::after,.table-up-resize-box__col-separator::before{content:'';position:absolute;top:0;display:block;width:.5rem;height:100%;z-index:1}.table-up-resize-box__row-wrapper{flex-direction:column;width:100%}.table-up-resize-box__row-header{width:100%;cursor:pointer;border-bottom-color:transparent}.table-up-resize-box__row-header:last-child{border-bottom-color:#ccc}.table-up-resize-box__row-separator{position:absolute;left:0;right:0;bottom:-.125rem;height:.125rem;cursor:ns-resize;z-index:0}.table-up-resize-box__row-separator::after{bottom:-.375rem}.table-up-resize-box__row-separator::before{top:-.375rem}.table-up-resize-box__row-separator::after,.table-up-resize-box__row-separator::before{content:'';position:absolute;left:0;display:block;width:100%;height:.5rem;z-index:1}.table-up-resize-box__corner{position:absolute;top:0;left:0;background-color:#f3f4f5;border:.0625rem solid #ccc;border-right-width:0;border-bottom-width:0;border-top-left-radius:50%;cursor:pointer}.table-up-drag-line{position:fixed;z-index:0;background-color:#409eff}.table-up-drag-line.is-col{width:.125rem;cursor:ew-resize}.table-up-drag-line.is-row{height:.125rem;cursor:ns-resize}.table-up-scale{position:absolute;top:0;left:0;overflow:hidden;pointer-events:none}.table-up-scale__block{position:absolute;top:0;left:0;transform:translate(-100%,-100%);width:.75rem;height:.75rem;background-color:#f1f5f9;border:.0625rem solid grey;cursor:nwse-resize;pointer-events:all}.table-up-scale.is-align-right .table-up-scale__block{cursor:nesw-resize}.table-up-scale.is-hidden{display:none}.table-up-scrollbar{position:absolute;z-index:1;transition:opacity .15s linear}.table-up-scrollbar__container{position:relative}.table-up-scrollbar.is-transparent{opacity:0}.table-up-scrollbar.is-vertical{top:.125rem;bottom:.125rem;left:-.5rem;width:.375rem}.table-up-scrollbar.is-vertical .table-up-scrollbar__thumb{width:100%}.table-up-scrollbar.is-horizontal{bottom:.125rem;left:.125rem;right:.125rem;height:.375rem}.table-up-scrollbar.is-horizontal .table-up-scrollbar__thumb{height:100%}.table-up-scrollbar__thumb{border-radius:.3125rem;background-color:#d2d2d2;cursor:pointer}.table-up-scrollbar__thumb:hover{background-color:#a1a1aa}.table-up-scrollbar--origin.ql-container .ql-table-wrapper{scrollbar-width:inherit}.table-up-align,.table-up-menu{position:absolute;z-index:1;display:none;align-items:center;padding:.25rem;border-radius:.375rem;box-shadow:0 0 .5rem rgba(0,0,0,.5);background-color:#fff;font-size:.875rem}.table-up-align__item,.table-up-menu__item{position:relative;display:inline-flex;align-items:center;justify-content:center;padding:.25rem;border-radius:.25rem;cursor:pointer}.table-up-align__item:hover,.table-up-menu__item:hover{background-color:#eee}.table-up-align__item.is-break,.table-up-menu__item.is-break{align-self:stretch;width:.0625rem;padding:0;margin:.125rem .25rem;background-color:#a3a3a3;cursor:default}.table-up-align .icon,.table-up-menu .icon{display:flex;flex-shrink:0;font-size:1.25rem}.table-up-align span,.table-up-menu span{text-wrap:nowrap}.table-up-menu.is-contextmenu{flex-direction:column;padding:.25rem .5rem;max-height:21.875rem;overflow-y:auto;overflow-x:hidden}.table-up-menu.is-contextmenu .table-up-menu__item{display:flex;justify-content:flex-start;width:100%;gap:.25rem;cursor:pointer}.table-up-menu.is-contextmenu .is-break{width:100%;height:.0625rem;flex-shrink:0;margin:.25rem 0;background-color:#a3a3a3}.table-up-align--active{display:flex}.table-up-align .icon{width:1.25rem;height:1.25rem}.table-up-color-map{display:flex;flex-direction:column}.table-up-color-map--used{display:flex;align-items:center;justify-content:center;flex-direction:row-reverse;margin-top:.25rem;padding-top:.25rem;border-top:.0625rem solid #ccc}.table-up-color-map__content{display:flex;flex-direction:column}.table-up-color-map__content-row{display:flex;align-items:center;justify-content:center;gap:.25rem}.table-up-color-map__item{width:.875rem;height:.875rem;margin:.125rem;border:.0625rem solid #a3a3a3;cursor:pointer}.table-up-color-map__btn{display:flex;align-items:center;justify-content:center;flex:1;height:1.25rem;padding:0 .375rem;color:#303133;background-color:#fff;cursor:pointer}.table-up-color-map__btn:hover{background-color:#edeeef}
|
|
1
|
+
.ql-toolbar .ql-picker:not(.ql-color-picker):not(.ql-icon-picker).ql-table-up{width:28px}.ql-toolbar .ql-picker:not(.ql-color-picker):not(.ql-icon-picker).ql-table-up .ql-picker-label{padding:2px 4px}.ql-toolbar .ql-picker:not(.ql-color-picker):not(.ql-icon-picker).ql-table-up .ql-picker-label svg{position:static;margin-top:0}.ql-toolbar .ql-picker.ql-expanded .ql-picker-options{z-index:1}.ql-editor .ql-table{display:table;border-collapse:collapse;table-layout:fixed;width:auto}.ql-editor .ql-table[data-full]{width:100%}.ql-editor .ql-table-wrapper{width:100%;overflow:auto;scrollbar-width:none}.ql-editor .ql-table-caption{position:relative;word-break:break-word;outline:0}.ql-editor .ql-table-caption .ql-table-caption--switch{display:flex;align-items:center;justify-content:center;padding:2px;border-radius:4px;border:1px solid #0003;font-size:12px;cursor:pointer;background-color:#fff}.ql-editor .ql-table-caption .ql-table-caption--switch:hover{background-color:#eee}.ql-editor .ql-table-cell{padding:8px 12px;border-color:transparent;font-size:14px;outline:0;overflow:auto}.ql-editor .ql-table-cell-inner{display:inline-block;min-width:100%;word-break:break-word;outline:0;counter-reset:list-0}.ql-editor .ql-table col{border-collapse:separate;text-indent:initial;display:table-column;table-layout:fixed}.ql-editor .ql-table tr+tr td{border-top:none}.ql-editor .ql-table td{border:1px solid #a1a1aa}.ql-editor .ql-table td+td{border-left:none}.table-up-toolbox{position:absolute;top:0;left:0;width:100%;height:100%;overflow:hidden;pointer-events:none}.table-up-toolbox *{pointer-events:all}.table-up-tooltip{position:absolute;z-index:20;padding:.25rem .75rem;border-radius:.25rem;font-size:.75rem;color:#fff;white-space:nowrap;background-color:#303133;transition:opacity .15s linear}.table-up-tooltip.transparent{opacity:0}.table-up-tooltip.hidden{display:none}.table-up-button{--table-btn-color:#606266;--table-btn-bg-hover:#f3f4f6;--table-btn-color-border:#dcdfe6;--table-btn-border:0.0625rem solid var(--table-btn-color-border);--table-btn-confirm-color-border:#409eff;--table-btn-confirm-bg:#409eff;--table-btn-confirm-hover:#79bbff;--table-btn-confirm-outline-focus-visible:0.125rem solid #a0cfff;box-sizing:border-box;display:inline-flex;height:2rem;line-height:1;margin:0;padding:.5rem 1rem;border-radius:.25rem;border:var(--table-btn-border);color:var(--table-btn-color);background-color:transparent;font-size:.875rem;cursor:pointer}.table-up-button+.table-up-button{margin-left:.375rem}.table-up-button:hover{background-color:var(--table-btn-bg-hover)}.table-up-button.confirm{border-color:var(--table-btn-confirm-color-border);background-color:var(--table-btn-confirm-bg);color:#fff}.table-up-button.confirm:hover{border-color:var(--table-btn-confirm-hover);background-color:var(--table-btn-confirm-hover)}.table-up-button.confirm:focus-visible{outline:var(--table-btn-confirm-outline-focus-visible);outline-offset:.0625rem}.table-up-dialog{--dialog-bg:rgba(0, 0, 0, 0.5);--dialog-color-border:#ebeef5;--dialog-color-boxshadow:rgba(0, 0, 0, 0.12);--dialog-border:0.0625rem solid var(--dialog-color-border);--dialog-boxshadow:0 0 0.75rem var(--dialog-color-boxshadow);position:fixed;top:0;right:0;bottom:0;left:0;z-index:2000;height:100%;background-color:var(--dialog-bg);overflow:auto}.table-up-dialog__overlay{position:fixed;top:0;right:0;bottom:0;left:0;padding:1rem;overflow:auto;text-align:center}.table-up-dialog__overlay::after{content:'';display:inline-block;height:100%;width:0;vertical-align:middle}.table-up-dialog__content{display:inline-block;max-width:50vw;width:100%;vertical-align:middle;background-color:#fff;border-radius:.25rem;border:var(--dialog-border);font-size:1.125rem;box-shadow:var(--dialog-boxshadow);text-align:left;overflow:hidden;box-sizing:border-box}.table-up-color-picker{--color-picker-bg-color:#ffffff;box-sizing:border-box;display:inline-flex;flex-direction:column;width:16.75rem;padding:.5rem;border-radius:.375rem;background:var(--color-picker-bg-color);box-shadow:0 0 .375rem #b2b5b8}.table-up-color-picker__content{box-sizing:border-box;width:100%;height:11.75rem;padding-top:.5rem}.table-up-color-picker__selector{width:14.375rem;height:9.375rem;position:absolute}.table-up-color-picker__background{width:100%;height:100%;background:linear-gradient(to top,#000 0,rgba(0,0,0,0) 100%),linear-gradient(to right,#fff 0,rgba(255,255,255,0) 100%)}.table-up-color-picker__background-handle{box-sizing:border-box;position:absolute;border:.0625rem solid #fff;cursor:pointer;top:0;left:14.375rem;border-radius:100%;width:.625rem;height:.625rem;transform:translate(-.3125rem,-.3125rem)}.table-up-color-picker__hue{width:.75rem;height:9.375rem;margin-left:15rem;position:absolute;background:linear-gradient(0deg,red 0,#ff0 17%,#0f0 33%,#0ff 50%,#00f 67%,#f0f 83%,red)}.table-up-color-picker__hue-handle{box-sizing:border-box;position:absolute;border:.0625rem solid #fff;cursor:pointer;background-color:#fff;box-shadow:0 0 .125rem #0009;left:0;width:1rem;height:.625rem;transform:translate(-.125rem,-.3125rem)}.table-up-color-picker__alpha{width:14.375rem;height:.75rem;position:absolute;margin-top:10rem;background:linear-gradient(45deg,#ccc 25%,transparent 25%),linear-gradient(135deg,#ccc 25%,transparent 25%),linear-gradient(45deg,transparent 75%,#ccc 75%),linear-gradient(135deg,transparent 75%,#ccc 75%);background-size:.75rem .75rem;background-position:0 0,.375rem 0,.375rem -.375rem,0 .375rem}.table-up-color-picker__alpha-bg{position:relative;height:100%;background:linear-gradient(to right,rgba(255,255,255,0) 0,#fff 100%)}.table-up-color-picker__alpha-handle{box-sizing:border-box;position:absolute;border:.0625rem solid #fff;cursor:pointer;background-color:#fff;box-shadow:0 0 .125rem #0009;top:0;width:.625rem;height:1rem;transform:translate(-.3125rem,-.125rem)}.table-up-color-picker__action{box-sizing:border-box;display:flex;align-items:center;gap:.375rem;width:100%;padding-top:.5rem;border-top:.0625rem solid #e9ecef}.table-up-color-picker__action-item{flex:1;display:inline-flex;align-items:center;font-size:.75rem}.table-up-color-picker__input{box-sizing:border-box;width:100%;height:1.375rem;margin-left:.125rem;padding:.125rem 0 .125rem .25rem;background-color:#fff;border:.0625rem solid #ced4da;border-radius:.25rem;outline:0;color:#405057}.table-up-tooltip .table-up-color-picker{--color-picker-bg-color:transparent;box-shadow:none;width:15.75rem;padding:.5rem 0}.ql-container .table-up-selection{--select-color:#0589f340;display:none;position:absolute;overflow:hidden;pointer-events:none}.ql-container .table-up-selection__line{position:absolute;background-color:var(--select-color);pointer-events:none}.table-up-resize-line__col,.table-up-resize-line__row{position:absolute;z-index:0}.table-up-resize-line__col.is-hidden,.table-up-resize-line__row.is-hidden{display:none}.table-up-resize-line__col::after,.table-up-resize-line__col::before,.table-up-resize-line__row::after,.table-up-resize-line__row::before{content:'';display:block;position:absolute;top:0;z-index:1}.table-up-resize-line__row{height:.0625rem;cursor:ns-resize}.table-up-resize-line__row::after,.table-up-resize-line__row::before{width:100%;height:.5rem}.table-up-resize-line__row::before{transform:translateY(-.5rem)}.table-up-resize-line__col{width:.0625rem;cursor:ew-resize}.table-up-resize-line__col::after,.table-up-resize-line__col::before{height:100%;width:.5rem}.table-up-resize-line__col::before{transform:translateX(-.5rem)}.table-up-resize-box{position:absolute;z-index:0}.table-up-resize-box.is-hidden{display:none}.table-up-resize-box.is-caption-bottom .table-up-resize-box__corner{border-top-width:0;border-bottom-width:.0625rem;border-top-left-radius:0;border-bottom-left-radius:50%}.table-up-resize-box.is-align-right .table-up-resize-box__col-separator{left:-.125rem}.table-up-resize-box.is-align-right .table-up-resize-box__corner{border-left-width:0;border-right-width:.0625rem;border-top-left-radius:0;border-top-right-radius:50%}.table-up-resize-box.is-align-right.is-caption-bottom .table-up-resize-box__corner{border-top-right-radius:0;border-bottom-left-radius:0;border-bottom-right-radius:50%}.table-up-resize-box__col,.table-up-resize-box__row{position:absolute;top:0;left:0;overflow:hidden}.table-up-resize-box__col-wrapper,.table-up-resize-box__row-wrapper{display:flex}.table-up-resize-box__col-header,.table-up-resize-box__row-header{position:relative;flex-shrink:0;background-color:#f3f4f5;border:.0625rem solid #ccc}.table-up-resize-box__col-wrapper{height:100%}.table-up-resize-box__col-header{height:100%;cursor:pointer;border-right-color:transparent}.table-up-resize-box__col-header:last-child{border-right-color:#ccc}.table-up-resize-box__col-separator{position:absolute;top:0;bottom:0;right:-.125rem;width:.125rem;cursor:ew-resize;z-index:0}.table-up-resize-box__col-separator::after{right:-.375rem}.table-up-resize-box__col-separator::before{left:-.375rem}.table-up-resize-box__col-separator::after,.table-up-resize-box__col-separator::before{content:'';position:absolute;top:0;display:block;width:.5rem;height:100%;z-index:1}.table-up-resize-box__row-wrapper{flex-direction:column;width:100%}.table-up-resize-box__row-header{width:100%;cursor:pointer;border-bottom-color:transparent}.table-up-resize-box__row-header:last-child{border-bottom-color:#ccc}.table-up-resize-box__row-separator{position:absolute;left:0;right:0;bottom:-.125rem;height:.125rem;cursor:ns-resize;z-index:0}.table-up-resize-box__row-separator::after{bottom:-.375rem}.table-up-resize-box__row-separator::before{top:-.375rem}.table-up-resize-box__row-separator::after,.table-up-resize-box__row-separator::before{content:'';position:absolute;left:0;display:block;width:100%;height:.5rem;z-index:1}.table-up-resize-box__corner{position:absolute;top:0;left:0;background-color:#f3f4f5;border:.0625rem solid #ccc;border-right-width:0;border-bottom-width:0;border-top-left-radius:50%;cursor:pointer}.table-up-drag-line{position:fixed;z-index:0;background-color:#409eff}.table-up-drag-line.is-col{width:.125rem;cursor:ew-resize}.table-up-drag-line.is-row{height:.125rem;cursor:ns-resize}.table-up-scale{position:absolute;top:0;left:0;overflow:hidden;pointer-events:none}.table-up-scale__block{position:absolute;top:0;left:0;transform:translate(-100%,-100%);width:.75rem;height:.75rem;background-color:#f1f5f9;border:.0625rem solid grey;cursor:nwse-resize;pointer-events:all}.table-up-scale.is-align-right .table-up-scale__block{cursor:nesw-resize}.table-up-scale.is-hidden{display:none}.table-up-scrollbar{position:absolute;z-index:1;transition:opacity .15s linear}.table-up-scrollbar__container{position:relative}.table-up-scrollbar.is-transparent{opacity:0}.table-up-scrollbar.is-vertical{top:.125rem;bottom:.125rem;left:-.5rem;width:.375rem}.table-up-scrollbar.is-vertical .table-up-scrollbar__thumb{width:100%}.table-up-scrollbar.is-horizontal{bottom:.125rem;left:.125rem;right:.125rem;height:.375rem}.table-up-scrollbar.is-horizontal .table-up-scrollbar__thumb{height:100%}.table-up-scrollbar__thumb{border-radius:.3125rem;background-color:#d2d2d2;cursor:pointer}.table-up-scrollbar__thumb:hover{background-color:#a1a1aa}.table-up-scrollbar--origin.ql-container .ql-table-wrapper{scrollbar-width:inherit}.table-up-align,.table-up-menu{position:absolute;z-index:1;display:none;align-items:center;padding:.25rem;border-radius:.375rem;box-shadow:0 0 .5rem rgba(0,0,0,.5);background-color:#fff;font-size:.875rem}.table-up-align__item,.table-up-menu__item{position:relative;display:inline-flex;align-items:center;justify-content:center;padding:.25rem;border-radius:.25rem;cursor:pointer}.table-up-align__item:hover,.table-up-menu__item:hover{background-color:#eee}.table-up-align__item.is-break,.table-up-menu__item.is-break{align-self:stretch;width:.0625rem;padding:0;margin:.125rem .25rem;background-color:#a3a3a3;cursor:default}.table-up-align .icon,.table-up-menu .icon{display:flex;flex-shrink:0;font-size:1.25rem}.table-up-align span,.table-up-menu span{text-wrap:nowrap}.table-up-menu.is-contextmenu{flex-direction:column;padding:.25rem .5rem;max-height:21.875rem;overflow-y:auto;overflow-x:hidden}.table-up-menu.is-contextmenu .table-up-menu__item{display:flex;justify-content:flex-start;width:100%;gap:.25rem;cursor:pointer}.table-up-menu.is-contextmenu .is-break{width:100%;height:.0625rem;flex-shrink:0;margin:.25rem 0;background-color:#a3a3a3}.table-up-align--active{display:flex}.table-up-align .icon{width:1.25rem;height:1.25rem}.table-up-color-map{display:flex;flex-direction:column}.table-up-color-map--used{display:flex;align-items:center;justify-content:center;flex-direction:row-reverse;margin-top:.25rem;padding-top:.25rem;border-top:.0625rem solid #ccc}.table-up-color-map__content{display:flex;flex-direction:column}.table-up-color-map__content-row{display:flex;align-items:center;justify-content:center;gap:.25rem}.table-up-color-map__item{width:.875rem;height:.875rem;margin:.125rem;border:.0625rem solid #a3a3a3;cursor:pointer}.table-up-color-map__btn{display:flex;align-items:center;justify-content:center;flex:1;height:1.25rem;padding:0 .375rem;color:#303133;background-color:#fff;cursor:pointer}.table-up-color-map__btn:hover{background-color:#edeeef}
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import e from"quill";const t={container:`table-up-container`,tableCaption:`table-up-caption`,tableWrapper:`table-up`,tableMain:`table-up-main`,tableColgroup:`table-up-colgroup`,tableCol:`table-up-col`,tableBody:`table-up-body`,tableRow:`table-up-row`,tableCell:`table-up-cell`,tableCellInner:`table-up-cell-inner`},n={colMinWidthPre:5,colMinWidthPx:40,colDefaultWidth:100,rowMinHeightPx:36},r={AFTER_TABLE_RESIZE:`after-table-resize`},i={moduleName:`table-up`},a=[[`rgb(255, 255, 255)`,`rgb(0, 0, 0)`,`rgb(72, 83, 104)`,`rgb(41, 114, 244)`,`rgb(0, 163, 245)`,`rgb(49, 155, 98)`,`rgb(222, 60, 54)`,`rgb(248, 136, 37)`,`rgb(245, 196, 0)`,`rgb(153, 56, 215)`],[`rgb(242, 242, 242)`,`rgb(127, 127, 127)`,`rgb(243, 245, 247)`,`rgb(229, 239, 255)`,`rgb(229, 246, 255)`,`rgb(234, 250, 241)`,`rgb(254, 233, 232)`,`rgb(254, 243, 235)`,`rgb(254, 249, 227)`,`rgb(253, 235, 255)`],[`rgb(216, 216, 216)`,`rgb(89, 89, 89)`,`rgb(197, 202, 211)`,`rgb(199, 220, 255)`,`rgb(199, 236, 255)`,`rgb(195, 234, 213)`,`rgb(255, 201, 199)`,`rgb(255, 220, 196)`,`rgb(255, 238, 173)`,`rgb(242, 199, 255)`],[`rgb(191, 191, 191)`,`rgb(63, 63, 63)`,`rgb(128, 139, 158)`,`rgb(153, 190, 255)`,`rgb(153, 221, 255)`,`rgb(152, 215, 182)`,`rgb(255, 156, 153)`,`rgb(255, 186, 132)`,`rgb(255, 226, 112)`,`rgb(213, 142, 255)`],[`rgb(165, 165, 165)`,`rgb(38, 38, 38)`,`rgb(53, 59, 69)`,`rgb(20, 80, 184)`,`rgb(18, 116, 165)`,`rgb(39, 124, 79)`,`rgb(158, 30, 26)`,`rgb(184, 96, 20)`,`rgb(163, 130, 0)`,`rgb(94, 34, 129)`],[`rgb(147, 147, 147)`,`rgb(13, 13, 13)`,`rgb(36, 39, 46)`,`rgb(12, 48, 110)`,`rgb(10, 65, 92)`,`rgb(24, 78, 50)`,`rgb(88, 17, 14)`,`rgb(92, 48, 10)`,`rgb(102, 82, 0)`,`rgb(59, 21, 81)`]],o=`table-up`,s=new Set([t.tableCellInner]),c=e=>s.has(e.statics.blotName);function l(e){return e&&e.parent?c(e.parent)?!0:l(e.parent):!1}function u(e,t=o){let n=t?`${t}-`:``;return{b:()=>`${n}${e}`,be:t=>t?`${n}${e}__${t}`:``,bm:t=>t?`${n}${e}--${t}`:``,bem:(t,r)=>t&&r?`${n}${e}__${t}--${r}`:``,ns:e=>e?`${n}${e}`:``,bs:t=>t?`${n}${e}-${t}`:``,cv:e=>e?`--${n}${e}`:``,is:e=>`is-${e}`}}function d(e,t){let n=e.parent;for(;n&&n.statics.blotName!==t&&n!==e.scroll;)n=n.parent;if(n===e.scroll)throw Error(`${e.statics.blotName} must be a child of ${t}`);return n}function f(e,t){let n=Array(t.length),r=new Map(t.map((e,t)=>[e,t])),i=e.parent;for(;i&&i!==e.scroll&&r.size!==0;){if(r.has(i.statics.blotName)){let e=r.get(i.statics.blotName);n[e]=i,r.delete(i.statics.blotName)}i=i.parent}if(r.size>0)throw Error(`${e.statics.blotName} must be a child of ${Array.from(r.keys()).join(`, `)}`);return n}function p(e){let t=new Map,n=e;for(;n&&n.statics.blotName!==`scroll`;)t.set(n.statics.blotName,n),n=n.parent;return t}function m(e,t){let n=[],r=e.children.iterator(),i=null;for(;i=r();)i instanceof t&&n.push(i);return n}function h(e,t,n){for(let r of Object.getOwnPropertyNames(t)){if(n&&n.test(r))continue;Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(t,r))}return e}function g(e,t){let n=class extends e{constructor(...e){super(...e)}};for(let e of t)h(n.prototype,e.prototype,/^constructor$/);return n}function _(e,t){return e.prototype instanceof t}function v(e,t){return e=Math.min(t,Math.max(0,Number.parseFloat(`${e}`))),Math.abs(e-t)<1e-6?1:e%t/Number.parseFloat(t)}function y(e){return{h:Math.min(360,Math.max(0,e.h)),s:Math.min(100,Math.max(0,e.s)),b:Math.min(100,Math.max(0,e.b)),a:Math.min(1,Math.max(0,e.a))}}function b(e){e=e.startsWith(`#`)?e.slice(1):e;let t=Number.parseInt(e.slice(0,2),16),n=Number.parseInt(e.slice(2,4),16),r=Number.parseInt(e.slice(4,6),16),i=Number((Number.parseInt(e.slice(6,8)||`ff`,16)/255).toFixed(2));return{r:t,g:n,b:r,a:i}}function x(e){let{r:t,g:n,b:r,a:i}=e;t=v(t,255),n=v(n,255),r=v(r,255);let a=Math.max(t,n,r),o=Math.min(t,n,r),s,c=a,l=a-o,u=a===0?0:l/a;if(a===o)s=0;else{switch(a){case t:s=(n-r)/l+(n<r?6:0);break;case n:s=(r-t)/l+2;break;case r:s=(t-n)/l+4;break}s/=6}return{h:s*360,s:u*100,b:c*100,a:i}}function ee(e){let{h:t,s:n,b:r,a:i}=e;t=v(t,360)*6,n=v(n,100),r=v(r,100);let a=Math.floor(t),o=t-a,s=r*(1-n),c=r*(1-o*n),l=r*(1-(1-o)*n),u=a%6,d=[r,c,s,s,l,r][u],f=[l,r,r,c,s,s][u],p=[s,s,l,r,r,c][u];return{r:Math.round(d*255),g:Math.round(f*255),b:Math.round(p*255),a:i}}function te(e){let t=[e.r.toString(16),e.g.toString(16),e.b.toString(16),Math.round(e.a*255).toString(16)];for(let e in t)t[e].length===1&&(t[e]=`0${t[e]}`);return t.join(``)}const ne=e=>te(ee(e)),S=e=>typeof e==`function`,C=Array.isArray,w=e=>typeof e==`string`,re=e=>typeof e==`number`,T=e=>typeof e==`object`&&!!e,ie=e=>!Number.isNaN(e)&&Number(e)>0;function ae(e){let{type:t=`default`,content:n}=e||{},r=u(`button`),i=document.createElement(`button`);return i.classList.add(r.b(),t),n&&(w(n)?i.textContent=n:i.appendChild(n)),i}function oe(e={}){let t=230,n=150,r=10,i=x(b(e.color||`#ff0000`)),a=u(`color-picker`),o=document.createElement(`div`);o.classList.add(a.b());let s=document.createElement(`div`);s.classList.add(a.be(`content`));let c=document.createElement(`div`);c.classList.add(a.be(`selector`));let l=document.createElement(`div`);l.classList.add(a.be(`background`)),c.appendChild(l);let d=document.createElement(`div`);d.classList.add(a.be(`background-handle`)),l.appendChild(d);let f=document.createElement(`div`);f.classList.add(a.be(`alpha`));let p=document.createElement(`div`);p.classList.add(a.be(`alpha-bg`));let m=document.createElement(`div`);m.classList.add(a.be(`alpha-handle`)),f.appendChild(p),f.appendChild(m);let h=document.createElement(`div`);h.classList.add(a.be(`hue`));let g=document.createElement(`div`);g.classList.add(a.be(`hue-handle`)),h.appendChild(g);let _=document.createElement(`div`);_.classList.add(a.be(`action`));let[v,S,C,w]=[`r`,`g`,`b`,`a`].map(e=>{let t=document.createElement(`div`);t.classList.add(a.be(`action-item`),e);let n=document.createElement(`label`);n.textContent=e.toUpperCase();let r=document.createElement(`input`);return r.classList.add(a.be(`input`)),r.addEventListener(`input`,()=>{r.value=r.value.replaceAll(/[^0-9]/g,``)}),r.addEventListener(`change`,()=>{let t=Math.round(Number(r.value));e===`a`&&(t/=100);let n=y(x(Object.assign({},ee(i),{[e]:t})));E(n),de()}),t.appendChild(n),t.appendChild(r),_.appendChild(t),r});s.appendChild(h),s.appendChild(c),s.appendChild(f),o.appendChild(s),o.appendChild(_);let re=!1,T=!1,ie=!1;function ae(){let e=ne(i);for(let[t,n]of[v,S,C].entries())n.value=String(Number.parseInt(e[t*2]+e[t*2+1],16));w.value=String((i.a*100).toFixed(0))}function oe(){Object.assign(d.style,{left:`${Math.floor(t*i.s/100)}px`,top:`${Math.floor(n*(100-i.b)/100)}px`})}function se(){c.style.backgroundColor=`#${te(ee({h:i.h,s:100,b:100,a:1}))}`}function ce(){g.style.top=`${Math.floor(n-n*i.h/360)}px`}function le(){m.style.left=`${i.a*100}%`}function ue(){let{r:e,g:t,b:n}=ee(i);p.style.background=`linear-gradient(to right, rgba(${e}, ${t}, ${n}, 0) 0%, rgba(${e}, ${t}, ${n}, 1) 100%)`}function de(){oe(),se(),ce(),le(),ue(),ae()}function E(t){i=y(Object.assign({},i,t)),ae(),e.onChange&&e.onChange(`#${ne(i)}`)}function D(e){let r=c.getBoundingClientRect(),i=r.top+(window.pageYOffset||document.documentElement.scrollTop||document.body.scrollTop||0),a=r.left+document.body.scrollLeft,o=Math.floor(100*Math.max(0,Math.min(t,e.pageX-a))/t),s=Math.floor(100*(n-Math.max(0,Math.min(n,e.pageY-i)))/n);E({s:o,b:s}),de()}function fe(e){let t=h.getBoundingClientRect().top+(window.pageYOffset||document.documentElement.scrollTop||document.body.scrollTop||0);E({h:Math.floor(360*(n-Math.max(0,Math.min(n,e.pageY-t)))/n)}),de()}function pe(e){let{pageX:t}=e,n=f.getBoundingClientRect(),i=t-n.left;i=Math.max(r/2,i),i=Math.min(i,n.width-r/2),E({a:Math.round((i-10/2)/(n.width-10)*100)/100}),de()}function O(e){re&&(e.preventDefault(),D(e)),T&&(e.preventDefault(),fe(e)),ie&&(e.preventDefault(),pe(e))}function me(){document.removeEventListener(`mousemove`,O),document.removeEventListener(`mouseup`,me),re=!1}function he(e){document.addEventListener(`mousemove`,O),document.addEventListener(`mouseup`,me),re=!0,D(e)}c.addEventListener(`mousedown`,he);function ge(){document.removeEventListener(`mousemove`,O),document.removeEventListener(`mouseup`,ge),T=!1}function _e(e){document.addEventListener(`mousemove`,O),document.addEventListener(`mouseup`,ge),T=!0,fe(e)}h.addEventListener(`mousedown`,_e);function k(){document.removeEventListener(`mousemove`,O),document.removeEventListener(`mouseup`,k),ie=!1}function ve(e){document.addEventListener(`mousemove`,O),document.addEventListener(`mouseup`,k),ie=!0,pe(e)}return f.addEventListener(`mousedown`,ve),de(),o}let se=8e3;function ce({child:e,target:t=document.body,beforeClose:n=()=>{}}={}){let r=u(`dialog`),i=t,a=document.createElement(`div`);a.classList.add(r.b()),a.style.zIndex=String(se);let o=document.createElement(`div`);if(o.classList.add(r.be(`overlay`)),a.appendChild(o),e){let t=document.createElement(`div`);t.classList.add(r.be(`content`)),t.appendChild(e),o.appendChild(t),t.addEventListener(`click`,e=>{e.stopPropagation()})}let s=getComputedStyle(i).overflow;i.style.overflow=`hidden`,i.appendChild(a);let c=()=>{n(),a.remove(),i.style.overflow=s};return a.addEventListener(`click`,c),se+=1,{dialog:a,close:c}}function le(e,t){let n=u(`input`);t.type||=`text`,t.value||=``;let r=document.createElement(`div`);if(r.classList.add(n.be(`item`)),e){let t=document.createElement(`span`);t.classList.add(n.be(`label`)),t.textContent=e,r.appendChild(t)}let i=document.createElement(`div`);i.classList.add(n.be(`input`));let a=document.createElement(`input`);for(let e in t)a.setAttribute(e,t[e]);(t.max||t.min)&&a.addEventListener(`blur`,()=>{t.max&&t.max<=Number(a.value)&&(a.value=String(t.max)),t.min&&t.min>=Number(a.value)&&(a.value=String(t.min))}),i.appendChild(a),r.appendChild(i),a.addEventListener(`focus`,()=>{i.classList.add(`focus`)}),a.addEventListener(`blur`,()=>{i.classList.remove(`focus`)});let o=e=>{let t;i.classList.contains(`error`)?t=i.querySelector(`.${n.be(`error-tip`)}`):(t=document.createElement(`span`),t.classList.add(n.be(`error-tip`)),i.appendChild(t)),t.textContent=e,i.classList.add(`error`);let r=()=>{i.classList.remove(`error`),t.remove()};return{removeError:r}};return{item:r,input:a,errorTip:o}}async function ue(e={}){let t=u(`creator`),n=document.createElement(`div`);n.classList.add(t.b());let r=document.createElement(`div`);r.classList.add(t.be(`input`));let{item:i,input:a,errorTip:o}=le(e.rowText||`Row`,{type:`number`,value:String(e.row||``),max:99}),{item:s,input:c,errorTip:l}=le(e.colText||`Column`,{type:`number`,value:String(e.col||``),max:99});r.appendChild(i),r.appendChild(s),n.appendChild(r);let d=document.createElement(`div`);d.classList.add(t.be(`control`));let f=ae({type:`confirm`,content:e.confirmText||`Confirm`}),p=ae({type:`default`,content:e.cancelText||`Cancel`});d.appendChild(f),d.appendChild(p),n.appendChild(d);let m=(t=Number(a.value),n=Number(c.value))=>{if(Number.isNaN(t)||t<=0){o(e.notPositiveNumberError||`Please enter a positive integer`);return}if(Number.isNaN(n)||n<=0){l(e.notPositiveNumberError||`Please enter a positive integer`);return}return{row:t,col:n}},h=e=>{e.key===`Escape`&&(close(),document.removeEventListener(`keydown`,h))};return new Promise((e,t)=>{let{close:r}=ce({child:n,beforeClose:t});a.focus();for(let t of[a,c])t.addEventListener(`keydown`,t=>{if(t.key===`Enter`){let t=m();t&&(e(t),r())}});f.addEventListener(`click`,async()=>{let t=m();t&&(e(t),r())}),document.addEventListener(`keydown`,h),p.addEventListener(`click`,r)})}function de(e={}){let t=u(`select-box`),n=document.createElement(`div`);n.classList.add(t.b());let r=document.createElement(`div`);r.classList.add(t.be(`block`));for(let n=0;n<(e.row||8);n++)for(let i=0;i<(e.col||8);i++){let e=document.createElement(`div`);e.classList.add(t.be(`item`)),e.dataset.row=String(n+1),e.dataset.col=String(i+1),r.appendChild(e)}let i=()=>{let{row:e,col:t}=n.dataset;for(let e of Array.from(r.querySelectorAll(`.active`)))e.classList.remove(`active`);if(!e||!t)return;let i=Array.from(r.children);for(let n=0;n<i.length;n++){let{row:r,col:a}=i[n].dataset;if(r>e&&a>t)return;r<=e&&a<=t?i[n].classList.add(`active`):i[n].classList.remove(`active`)}};if(r.addEventListener(`mousemove`,e=>{if(!e.target)return;let{row:t,col:r}=e.target.dataset;!t||!r||(n.dataset.row=t,n.dataset.col=r,i())}),r.addEventListener(`mouseleave`,()=>{n.removeAttribute(`data-row`),n.removeAttribute(`data-col`),i()}),r.addEventListener(`click`,()=>{let{row:t,col:r}=n.dataset;!t||!r||e.onSelect&&e.onSelect(Number(t),Number(r))}),n.appendChild(r),e.customBtn){let r=e.texts||{},i=document.createElement(`div`);i.classList.add(t.be(`custom`)),i.textContent=r.customBtnText||`Custom`,i.addEventListener(`click`,async()=>{let t=await ue(r);t&&e.onSelect&&e.onSelect(t.row,t.col)}),n.appendChild(i)}return n}const E=Math.min,D=Math.max,fe=Math.round,pe=Math.floor,O=e=>({x:e,y:e}),me={left:`right`,right:`left`,bottom:`top`,top:`bottom`},he={start:`end`,end:`start`};function ge(e,t,n){return D(e,E(t,n))}function _e(e,t){return typeof e==`function`?e(t):e}function k(e){return e.split(`-`)[0]}function ve(e){return e.split(`-`)[1]}function ye(e){return e===`x`?`y`:`x`}function be(e){return e===`y`?`height`:`width`}function A(e){return[`top`,`bottom`].includes(k(e))?`y`:`x`}function xe(e){return ye(A(e))}function Se(e,t,n){n===void 0&&(n=!1);let r=ve(e),i=xe(e),a=be(i),o=i===`x`?r===(n?`end`:`start`)?`right`:`left`:r===`start`?`bottom`:`top`;return t.reference[a]>t.floating[a]&&(o=De(o)),[o,De(o)]}function Ce(e){let t=De(e);return[we(e),t,we(t)]}function we(e){return e.replace(/start|end/g,e=>he[e])}function Te(e,t,n){let r=[`left`,`right`],i=[`right`,`left`],a=[`top`,`bottom`],o=[`bottom`,`top`];switch(e){case`top`:case`bottom`:return n?t?i:r:t?r:i;case`left`:case`right`:return t?a:o;default:return[]}}function Ee(e,t,n,r){let i=ve(e),a=Te(k(e),n===`start`,r);return i&&(a=a.map(e=>e+`-`+i),t&&(a=a.concat(a.map(we)))),a}function De(e){return e.replace(/left|right|bottom|top/g,e=>me[e])}function Oe(e){return{top:0,right:0,bottom:0,left:0,...e}}function ke(e){return typeof e==`number`?{top:e,right:e,bottom:e,left:e}:Oe(e)}function Ae(e){let{x:t,y:n,width:r,height:i}=e;return{width:r,height:i,top:n,left:t,right:t+r,bottom:n+i,x:t,y:n}}function je(e,t,n){let{reference:r,floating:i}=e,a=A(t),o=xe(t),s=be(o),c=k(t),l=a===`y`,u=r.x+r.width/2-i.width/2,d=r.y+r.height/2-i.height/2,f=r[s]/2-i[s]/2,p;switch(c){case`top`:p={x:u,y:r.y-i.height};break;case`bottom`:p={x:u,y:r.y+r.height};break;case`right`:p={x:r.x+r.width,y:d};break;case`left`:p={x:r.x-i.width,y:d};break;default:p={x:r.x,y:r.y}}switch(ve(t)){case`start`:p[o]-=f*(n&&l?-1:1);break;case`end`:p[o]+=f*(n&&l?-1:1);break}return p}const Me=async(e,t,n)=>{let{placement:r=`bottom`,strategy:i=`absolute`,middleware:a=[],platform:o}=n,s=a.filter(Boolean),c=await(o.isRTL==null?void 0:o.isRTL(t)),l=await o.getElementRects({reference:e,floating:t,strategy:i}),{x:u,y:d}=je(l,r,c),f=r,p={},m=0;for(let n=0;n<s.length;n++){let{name:a,fn:h}=s[n],{x:g,y:_,data:v,reset:y}=await h({x:u,y:d,initialPlacement:r,placement:f,strategy:i,middlewareData:p,rects:l,platform:o,elements:{reference:e,floating:t}});u=g??u,d=_??d,p={...p,[a]:{...p[a],...v}},y&&m<=50&&(m++,typeof y==`object`&&(y.placement&&(f=y.placement),y.rects&&(l=y.rects===!0?await o.getElementRects({reference:e,floating:t,strategy:i}):y.rects),{x:u,y:d}=je(l,f,c)),n=-1)}return{x:u,y:d,placement:f,strategy:i,middlewareData:p}};async function Ne(e,t){var n;t===void 0&&(t={});let{x:r,y:i,platform:a,rects:o,elements:s,strategy:c}=e,{boundary:l=`clippingAncestors`,rootBoundary:u=`viewport`,elementContext:d=`floating`,altBoundary:f=!1,padding:p=0}=_e(t,e),m=ke(p),h=d===`floating`?`reference`:`floating`,g=s[f?h:d],_=Ae(await a.getClippingRect({element:(n=await(a.isElement==null?void 0:a.isElement(g)))??!0?g:g.contextElement||await(a.getDocumentElement==null?void 0:a.getDocumentElement(s.floating)),boundary:l,rootBoundary:u,strategy:c})),v=d===`floating`?{x:r,y:i,width:o.floating.width,height:o.floating.height}:o.reference,y=await(a.getOffsetParent==null?void 0:a.getOffsetParent(s.floating)),b=await(a.isElement==null?void 0:a.isElement(y))&&await(a.getScale==null?void 0:a.getScale(y))||{x:1,y:1},x=Ae(a.convertOffsetParentRelativeRectToViewportRelativeRect?await a.convertOffsetParentRelativeRectToViewportRelativeRect({elements:s,rect:v,offsetParent:y,strategy:c}):v);return{top:(_.top-x.top+m.top)/b.y,bottom:(x.bottom-_.bottom+m.bottom)/b.y,left:(_.left-x.left+m.left)/b.x,right:(x.right-_.right+m.right)/b.x}}const Pe=function(e){return e===void 0&&(e={}),{name:`flip`,options:e,async fn(t){var n,r;let{placement:i,middlewareData:a,rects:o,initialPlacement:s,platform:c,elements:l}=t,{mainAxis:u=!0,crossAxis:d=!0,fallbackPlacements:f,fallbackStrategy:p=`bestFit`,fallbackAxisSideDirection:m=`none`,flipAlignment:h=!0,...g}=_e(e,t);if((n=a.arrow)!=null&&n.alignmentOffset)return{};let _=k(i),v=A(s),y=k(s)===s,b=await(c.isRTL==null?void 0:c.isRTL(l.floating)),x=f||(y||!h?[De(s)]:Ce(s)),ee=m!==`none`;!f&&ee&&x.push(...Ee(s,h,m,b));let te=[s,...x],ne=await Ne(t,g),S=[],C=(r=a.flip)?.overflows||[];if(u&&S.push(ne[_]),d){let e=Se(i,o,b);S.push(ne[e[0]],ne[e[1]])}if(C=[...C,{placement:i,overflows:S}],!S.every(e=>e<=0)){var w,re;let e=((w=a.flip)?.index||0)+1,t=te[e];if(t){let n=d===`alignment`?v!==A(t):!1;if(!n||C.every(e=>e.overflows[0]>0&&A(e.placement)===v))return{data:{index:e,overflows:C},reset:{placement:t}}}let n=(re=C.filter(e=>e.overflows[0]<=0).sort((e,t)=>e.overflows[1]-t.overflows[1])[0])?.placement;if(!n)switch(p){case`bestFit`:{var T;let e=(T=C.filter(e=>{if(ee){let t=A(e.placement);return t===v||t===`y`}return!0}).map(e=>[e.placement,e.overflows.filter(e=>e>0).reduce((e,t)=>e+t,0)]).sort((e,t)=>e[1]-t[1])[0])?.[0];e&&(n=e);break}case`initialPlacement`:n=s;break}if(i!==n)return{reset:{placement:n}}}return{}}}};async function Fe(e,t){let{placement:n,platform:r,elements:i}=e,a=await(r.isRTL==null?void 0:r.isRTL(i.floating)),o=k(n),s=ve(n),c=A(n)===`y`,l=[`left`,`top`].includes(o)?-1:1,u=a&&c?-1:1,d=_e(t,e),{mainAxis:f,crossAxis:p,alignmentAxis:m}=typeof d==`number`?{mainAxis:d,crossAxis:0,alignmentAxis:null}:{mainAxis:d.mainAxis||0,crossAxis:d.crossAxis||0,alignmentAxis:d.alignmentAxis};return s&&typeof m==`number`&&(p=s===`end`?m*-1:m),c?{x:p*u,y:f*l}:{x:f*l,y:p*u}}const Ie=function(e){return e===void 0&&(e=0),{name:`offset`,options:e,async fn(t){var n,r;let{x:i,y:a,placement:o,middlewareData:s}=t,c=await Fe(t,e);return o===(n=s.offset)?.placement&&(r=s.arrow)!=null&&r.alignmentOffset?{}:{x:i+c.x,y:a+c.y,data:{...c,placement:o}}}}},Le=function(e){return e===void 0&&(e={}),{name:`shift`,options:e,async fn(t){let{x:n,y:r,placement:i}=t,{mainAxis:a=!0,crossAxis:o=!1,limiter:s={fn:e=>{let{x:t,y:n}=e;return{x:t,y:n}}},...c}=_e(e,t),l={x:n,y:r},u=await Ne(t,c),d=A(k(i)),f=ye(d),p=l[f],m=l[d];if(a){let e=f===`y`?`top`:`left`,t=f===`y`?`bottom`:`right`,n=p+u[e],r=p-u[t];p=ge(n,p,r)}if(o){let e=d===`y`?`top`:`left`,t=d===`y`?`bottom`:`right`,n=m+u[e],r=m-u[t];m=ge(n,m,r)}let h=s.fn({...t,[f]:p,[d]:m});return{...h,data:{x:h.x-n,y:h.y-r,enabled:{[f]:a,[d]:o}}}}}},Re=function(e){return e===void 0&&(e={}),{options:e,fn(t){let{x:n,y:r,placement:i,rects:a,middlewareData:o}=t,{offset:s=0,mainAxis:c=!0,crossAxis:l=!0}=_e(e,t),u={x:n,y:r},d=A(i),f=ye(d),p=u[f],m=u[d],h=_e(s,t),g=typeof h==`number`?{mainAxis:h,crossAxis:0}:{mainAxis:0,crossAxis:0,...h};if(c){let e=f===`y`?`height`:`width`,t=a.reference[f]-a.floating[e]+g.mainAxis,n=a.reference[f]+a.reference[e]-g.mainAxis;p<t?p=t:p>n&&(p=n)}if(l){var _,v;let e=f===`y`?`width`:`height`,t=[`top`,`left`].includes(k(i)),n=a.reference[d]-a.floating[e]+(t&&(_=o.offset)?.[d]||0)+(t?0:g.crossAxis),r=a.reference[d]+a.reference[e]+(t?0:(v=o.offset)?.[d]||0)-(t?g.crossAxis:0);m<n?m=n:m>r&&(m=r)}return{[f]:p,[d]:m}}}};function ze(){return typeof window<`u`}function Be(e){return Ve(e)?(e.nodeName||``).toLowerCase():`#document`}function j(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function M(e){var t;return(t=(Ve(e)?e.ownerDocument:e.document)||window.document)?.documentElement}function Ve(e){return ze()?e instanceof Node||e instanceof j(e).Node:!1}function N(e){return ze()?e instanceof Element||e instanceof j(e).Element:!1}function P(e){return ze()?e instanceof HTMLElement||e instanceof j(e).HTMLElement:!1}function He(e){return!ze()||typeof ShadowRoot>`u`?!1:e instanceof ShadowRoot||e instanceof j(e).ShadowRoot}function Ue(e){let{overflow:t,overflowX:n,overflowY:r,display:i}=F(e);return/auto|scroll|overlay|hidden|clip/.test(t+r+n)&&![`inline`,`contents`].includes(i)}function We(e){return[`table`,`td`,`th`].includes(Be(e))}function Ge(e){return[`:popover-open`,`:modal`].some(t=>{try{return e.matches(t)}catch{return!1}})}function Ke(e){let t=Je(),n=N(e)?F(e):e;return[`transform`,`translate`,`scale`,`rotate`,`perspective`].some(e=>n[e]?n[e]!==`none`:!1)||(n.containerType?n.containerType!==`normal`:!1)||!t&&(n.backdropFilter?n.backdropFilter!==`none`:!1)||!t&&(n.filter?n.filter!==`none`:!1)||[`transform`,`translate`,`scale`,`rotate`,`perspective`,`filter`].some(e=>(n.willChange||``).includes(e))||[`paint`,`layout`,`strict`,`content`].some(e=>(n.contain||``).includes(e))}function qe(e){let t=I(e);for(;P(t)&&!Ye(t);){if(Ke(t))return t;if(Ge(t))return null;t=I(t)}return null}function Je(){return typeof CSS>`u`||!CSS.supports?!1:CSS.supports(`-webkit-backdrop-filter`,`none`)}function Ye(e){return[`html`,`body`,`#document`].includes(Be(e))}function F(e){return j(e).getComputedStyle(e)}function Xe(e){return N(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function I(e){if(Be(e)===`html`)return e;let t=e.assignedSlot||e.parentNode||He(e)&&e.host||M(e);return He(t)?t.host:t}function Ze(e){let t=I(e);return Ye(t)?e.ownerDocument?e.ownerDocument.body:e.body:P(t)&&Ue(t)?t:Ze(t)}function Qe(e,t,n){var r;t===void 0&&(t=[]),n===void 0&&(n=!0);let i=Ze(e),a=i===(r=e.ownerDocument)?.body,o=j(i);if(a){let e=$e(o);return t.concat(o,o.visualViewport||[],Ue(i)?i:[],e&&n?Qe(e):[])}return t.concat(i,Qe(i,[],n))}function $e(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function et(e){let t=F(e),n=parseFloat(t.width)||0,r=parseFloat(t.height)||0,i=P(e),a=i?e.offsetWidth:n,o=i?e.offsetHeight:r,s=fe(n)!==a||fe(r)!==o;return s&&(n=a,r=o),{width:n,height:r,$:s}}function tt(e){return N(e)?e:e.contextElement}function nt(e){let t=tt(e);if(!P(t))return O(1);let n=t.getBoundingClientRect(),{width:r,height:i,$:a}=et(t),o=(a?fe(n.width):n.width)/r,s=(a?fe(n.height):n.height)/i;return(!o||!Number.isFinite(o))&&(o=1),(!s||!Number.isFinite(s))&&(s=1),{x:o,y:s}}const rt=O(0);function it(e){let t=j(e);return!Je()||!t.visualViewport?rt:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function at(e,t,n){return t===void 0&&(t=!1),!n||t&&n!==j(e)?!1:t}function ot(e,t,n,r){t===void 0&&(t=!1),n===void 0&&(n=!1);let i=e.getBoundingClientRect(),a=tt(e),o=O(1);t&&(r?N(r)&&(o=nt(r)):o=nt(e));let s=at(a,n,r)?it(a):O(0),c=(i.left+s.x)/o.x,l=(i.top+s.y)/o.y,u=i.width/o.x,d=i.height/o.y;if(a){let e=j(a),t=r&&N(r)?j(r):r,n=e,i=$e(n);for(;i&&r&&t!==n;){let e=nt(i),t=i.getBoundingClientRect(),r=F(i),a=t.left+(i.clientLeft+parseFloat(r.paddingLeft))*e.x,o=t.top+(i.clientTop+parseFloat(r.paddingTop))*e.y;c*=e.x,l*=e.y,u*=e.x,d*=e.y,c+=a,l+=o,n=j(i),i=$e(n)}}return Ae({width:u,height:d,x:c,y:l})}function st(e,t){let n=Xe(e).scrollLeft;return t?t.left+n:ot(M(e)).left+n}function ct(e,t,n){n===void 0&&(n=!1);let r=e.getBoundingClientRect(),i=r.left+t.scrollLeft-(n?0:st(e,r)),a=r.top+t.scrollTop;return{x:i,y:a}}function lt(e){let{elements:t,rect:n,offsetParent:r,strategy:i}=e,a=i===`fixed`,o=M(r),s=t?Ge(t.floating):!1;if(r===o||s&&a)return n;let c={scrollLeft:0,scrollTop:0},l=O(1),u=O(0),d=P(r);if((d||!d&&!a)&&((Be(r)!==`body`||Ue(o))&&(c=Xe(r)),P(r))){let e=ot(r);l=nt(r),u.x=e.x+r.clientLeft,u.y=e.y+r.clientTop}let f=o&&!d&&!a?ct(o,c,!0):O(0);return{width:n.width*l.x,height:n.height*l.y,x:n.x*l.x-c.scrollLeft*l.x+u.x+f.x,y:n.y*l.y-c.scrollTop*l.y+u.y+f.y}}function ut(e){return Array.from(e.getClientRects())}function dt(e){let t=M(e),n=Xe(e),r=e.ownerDocument.body,i=D(t.scrollWidth,t.clientWidth,r.scrollWidth,r.clientWidth),a=D(t.scrollHeight,t.clientHeight,r.scrollHeight,r.clientHeight),o=-n.scrollLeft+st(e),s=-n.scrollTop;return F(r).direction===`rtl`&&(o+=D(t.clientWidth,r.clientWidth)-i),{width:i,height:a,x:o,y:s}}function ft(e,t){let n=j(e),r=M(e),i=n.visualViewport,a=r.clientWidth,o=r.clientHeight,s=0,c=0;if(i){a=i.width,o=i.height;let e=Je();(!e||e&&t===`fixed`)&&(s=i.offsetLeft,c=i.offsetTop)}return{width:a,height:o,x:s,y:c}}function pt(e,t){let n=ot(e,!0,t===`fixed`),r=n.top+e.clientTop,i=n.left+e.clientLeft,a=P(e)?nt(e):O(1),o=e.clientWidth*a.x,s=e.clientHeight*a.y,c=i*a.x,l=r*a.y;return{width:o,height:s,x:c,y:l}}function mt(e,t,n){let r;if(t===`viewport`)r=ft(e,n);else if(t===`document`)r=dt(M(e));else if(N(t))r=pt(t,n);else{let n=it(e);r={x:t.x-n.x,y:t.y-n.y,width:t.width,height:t.height}}return Ae(r)}function ht(e,t){let n=I(e);return n===t||!N(n)||Ye(n)?!1:F(n).position===`fixed`||ht(n,t)}function gt(e,t){let n=t.get(e);if(n)return n;let r=Qe(e,[],!1).filter(e=>N(e)&&Be(e)!==`body`),i=null,a=F(e).position===`fixed`,o=a?I(e):e;for(;N(o)&&!Ye(o);){let t=F(o),n=Ke(o);!n&&t.position===`fixed`&&(i=null);let s=a?!n&&!i:!n&&t.position===`static`&&!!i&&[`absolute`,`fixed`].includes(i.position)||Ue(o)&&!n&&ht(e,o);s?r=r.filter(e=>e!==o):i=t,o=I(o)}return t.set(e,r),r}function _t(e){let{element:t,boundary:n,rootBoundary:r,strategy:i}=e,a=n===`clippingAncestors`?Ge(t)?[]:gt(t,this._c):[].concat(n),o=[...a,r],s=o[0],c=o.reduce((e,n)=>{let r=mt(t,n,i);return e.top=D(r.top,e.top),e.right=E(r.right,e.right),e.bottom=E(r.bottom,e.bottom),e.left=D(r.left,e.left),e},mt(t,s,i));return{width:c.right-c.left,height:c.bottom-c.top,x:c.left,y:c.top}}function vt(e){let{width:t,height:n}=et(e);return{width:t,height:n}}function yt(e,t,n){let r=P(t),i=M(t),a=n===`fixed`,o=ot(e,!0,a,t),s={scrollLeft:0,scrollTop:0},c=O(0);function l(){c.x=st(i)}if(r||!r&&!a)if((Be(t)!==`body`||Ue(i))&&(s=Xe(t)),r){let e=ot(t,!0,a,t);c.x=e.x+t.clientLeft,c.y=e.y+t.clientTop}else i&&l();a&&!r&&i&&l();let u=i&&!r&&!a?ct(i,s):O(0),d=o.left+s.scrollLeft-c.x-u.x,f=o.top+s.scrollTop-c.y-u.y;return{x:d,y:f,width:o.width,height:o.height}}function bt(e){return F(e).position===`static`}function xt(e,t){if(!P(e)||F(e).position===`fixed`)return null;if(t)return t(e);let n=e.offsetParent;return M(e)===n&&(n=n.ownerDocument.body),n}function St(e,t){let n=j(e);if(Ge(e))return n;if(!P(e)){let t=I(e);for(;t&&!Ye(t);){if(N(t)&&!bt(t))return t;t=I(t)}return n}let r=xt(e,t);for(;r&&We(r)&&bt(r);)r=xt(r,t);return r&&Ye(r)&&bt(r)&&!Ke(r)?n:r||qe(e)||n}const Ct=async function(e){let t=this.getOffsetParent||St,n=this.getDimensions,r=await n(e.floating);return{reference:yt(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function wt(e){return F(e).direction===`rtl`}const Tt={convertOffsetParentRelativeRectToViewportRelativeRect:lt,getDocumentElement:M,getClippingRect:_t,getOffsetParent:St,getElementRects:Ct,getClientRects:ut,getDimensions:vt,getScale:nt,isElement:N,isRTL:wt};function Et(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function Dt(e,t){let n=null,r,i=M(e);function a(){var e;clearTimeout(r),(e=n)==null||e.disconnect(),n=null}function o(s,c){s===void 0&&(s=!1),c===void 0&&(c=1),a();let l=e.getBoundingClientRect(),{left:u,top:d,width:f,height:p}=l;if(s||t(),!f||!p)return;let m=pe(d),h=pe(i.clientWidth-(u+f)),g=pe(i.clientHeight-(d+p)),_=pe(u),v=-m+`px `+-h+`px `+-g+`px `+-_+`px`,y={rootMargin:v,threshold:D(0,E(1,c))||1},b=!0;function x(t){let n=t[0].intersectionRatio;if(n!==c){if(!b)return o();n?o(!1,n):r=setTimeout(()=>{o(!1,1e-7)},1e3)}n===1&&!Et(l,e.getBoundingClientRect())&&o(),b=!1}try{n=new IntersectionObserver(x,{...y,root:i.ownerDocument})}catch{n=new IntersectionObserver(x,y)}n.observe(e)}return o(!0),a}function Ot(e,t,n,r){r===void 0&&(r={});let{ancestorScroll:i=!0,ancestorResize:a=!0,elementResize:o=typeof ResizeObserver==`function`,layoutShift:s=typeof IntersectionObserver==`function`,animationFrame:c=!1}=r,l=tt(e),u=i||a?[...l?Qe(l):[],...Qe(t)]:[];u.forEach(e=>{i&&e.addEventListener(`scroll`,n,{passive:!0}),a&&e.addEventListener(`resize`,n)});let d=l&&s?Dt(l,n):null,f=-1,p=null;o&&(p=new ResizeObserver(e=>{let[r]=e;r&&r.target===l&&p&&(p.unobserve(t),cancelAnimationFrame(f),f=requestAnimationFrame(()=>{var e;(e=p)==null||e.observe(t)})),n()}),l&&!c&&p.observe(l),p.observe(t));let m,h=c?ot(e):null;c&&g();function g(){let t=ot(e);h&&!Et(h,t)&&n(),h=t,m=requestAnimationFrame(g)}return n(),()=>{var e;u.forEach(e=>{i&&e.removeEventListener(`scroll`,n),a&&e.removeEventListener(`resize`,n)}),d?.(),(e=p)==null||e.disconnect(),p=null,c&&cancelAnimationFrame(m)}}const kt=Ie,At=Le,jt=Pe,Mt=Re,Nt=(e,t,n)=>{let r=new Map,i={platform:Tt,...n},a={...i.platform,_c:r};return Me(e,t,{...i,platform:a})};function Pt(e,t,n,r,i){return i&&clearTimeout(i),e.addEventListener(`transitionend`,n,r),setTimeout(()=>{n()},t)}const Ft=4;let It;function Lt(e,t={}){let{msg:n=``,delay:r=150,content:i,direction:a=`bottom`,type:o=`hover`,container:s,onOpen:c,onClose:l,closed:d,onDestroy:f}=t,p=u(`tooltip`);if(n||i){It||(It=document.createElement(`div`),document.body.appendChild(It));let t=s||It,u=document.createElement(`div`);u.classList.add(p.b(),`hidden`,`transparent`),i?u.appendChild(i):n&&(u.textContent=n);let m,h,g,_=()=>{g&&g(),Nt(e,u,{placement:a,middleware:[jt(),At({limiter:Mt()}),kt(Ft)]}).then(({x:e,y:t})=>{Object.assign(u.style,{left:`${e}px`,top:`${t}px`})})},v=()=>{u.classList.add(`hidden`),t.contains(u)&&t.removeChild(u),g&&g(),d&&d()},y=(n=!1)=>{h&&clearTimeout(h),m=setTimeout(()=>{if(c){let e=c(n);if(!n&&e)return}t.appendChild(u),u.removeEventListener(`transitionend`,v),u.classList.remove(`hidden`),g=Ot(e,u,_),u.classList.remove(`transparent`)},r)},b=(e=!1)=>{m&&clearTimeout(m),h=setTimeout(()=>{if(l){let t=l(e);if(!e&&t)return}Pt(u,150,v,{once:!0}),u.classList.add(`transparent`)},r)},x=()=>{let t=[e,u],n=b.bind(void 0,!1),r=y.bind(void 0,!1),i=()=>{for(let e of t)e.addEventListener(`mouseenter`,r),e.addEventListener(`mouseleave`,n)};return{prepare:i,show:y,hide:b,destroy:()=>{for(let e of t)e.removeEventListener(`mouseenter`,r),e.removeEventListener(`mouseleave`,n)}}},ee=()=>{let t=e=>{e.stopPropagation(),b(!1)},n=e=>{e.stopPropagation(),y(),document.removeEventListener(`click`,t),document.addEventListener(`click`,t,{once:!0})};return{prepare:()=>{u.addEventListener(`click`,e=>e.stopPropagation()),e.addEventListener(`click`,n)},show:y,hide:(e=!1)=>{b(e),document.removeEventListener(`click`,t)},destroy:()=>{e.removeEventListener(`click`,n),document.removeEventListener(`click`,t)}}},te={hover:x,click:ee},{prepare:ne,show:S,hide:C,destroy:w}=te[o]();ne();let re=()=>{C(!0),f&&f(),w(),g&&g(),u.remove()};return{show:S,hide:C,destroy:re}}return null}function Rt(e,t,n=0,r=!0){let{x:i,y:a,x1:o,y1:s}=e,{x:c,y:l,x1:u,y1:d}=t,f,p;return r?(f=o<c+n||i-n>u,p=s<l+n||a-n>d):(f=o<=c+n||i-n>=u,p=s<=l+n||a-n>=d),!(f||p)}function zt(e,t){let n=t.getBoundingClientRect();return{x:e.x-n.x-t.scrollLeft,y:e.y-n.y-t.scrollTop,x1:e.x-n.x-t.scrollLeft+e.width,y1:e.y-n.y-t.scrollTop+e.height,width:e.width,height:e.height}}const Bt=8;function Vt(e){let{left:t,top:n,width:r,height:i}=e,{clientWidth:a,clientHeight:o}=document.documentElement,s=!1,c=!1;return t+r>a?(t=a-r-Bt,s=!0):t<0&&(t=Bt,s=!0),n+i>o?(n=o-i-Bt,c=!0):n<0&&(n=Bt,c=!0),{left:t,top:n,leftLimited:s,topLimited:c}}function Ht(e,t={}){let n=Symbol(`ignoreFirstBind`),r=new Set,i=new ResizeObserver(r=>{t.ignoreFirstBind&&r.some(e=>{let t=e.target,r=t[n];return t[n]=!0,!r})||e(r)}),a=i.observe;i.observe=(e,t)=>{r.add(e),a.call(i,e,t)};let o=i.unobserve;i.unobserve=e=>{r.has(e)&&(r.delete(e),e[n]=void 0),o.call(i,e)};let s=i.disconnect;return i.disconnect=()=>{for(let e of r.values())e[n]=void 0;s.call(i)},i}function L(e,t){e.addEventListener(`scroll`,t),this.scrollHandler.push([e,t])}function Ut(){for(let e=0;e<this.scrollHandler.length;e++){let[t,n]=this.scrollHandler[e];t.removeEventListener(`scroll`,n)}this.scrollHandler=[]}function Wt(e){return{y:e.scrollTop,x:e.scrollLeft}}function Gt(e){let t={},n=e.trim().split(`;`);for(let e=0;e<n.length;e++){let r=n[e].trim();if(!r)continue;let i=r.indexOf(`:`);if(i===-1)continue;let a=r.slice(0,Math.max(0,i)).trim(),o=r.slice(Math.max(0,i+1)).trim();t[Jt(a)]=o}return t}function Kt(e){return Object.entries(e).map(([e,t])=>`${qt(e)}: ${t};`).join(` `)}function qt(e){let t=e.replaceAll(/([A-Z])/g,` $1`).trim();return t.split(` `).join(`-`).toLowerCase()}function Jt(e){return e.replaceAll(/-(\w)/g,(e,t)=>t.toUpperCase())}const R=()=>Math.random().toString(36).slice(2);function Yt(e,t){let n;return function(...r){n&&clearTimeout(n),n=setTimeout(()=>{e.apply(this,r)},t)}}const Xt=e.import(`parchment`),Zt=e.import(`blots/container`),Qt=e.import(`blots/block`),$t=e.import(`blots/block/embed`);var z=class e extends Zt{static tagName;static blotName=t.container;static scope=Xt.Scope.BLOCK_BLOT;static allowedChildren=[Qt,$t,Zt];static requiredContainer;static defaultChild;static create(e){let t=document.createElement(this.tagName);return this.className&&t.classList.add(this.className),t}optimize(e){if(this.children.length===0)if(this.statics.defaultChild!=null){let e=this.scroll.create(this.statics.defaultChild.blotName);this.appendChild(e)}else this.remove();this.children.length>0&&this.next!=null&&this.checkMerge()&&(this.next.moveChildren(this),this.next.remove())}enforceAllowedChildren(){this.children.forEach(t=>{let n=this.statics.allowedChildren.some(e=>t instanceof e);n||(t.statics.scope===Xt.Scope.BLOCK_BLOT?(t.parent instanceof e?(t.next!=null&&t.parent.splitAfter(t),t.prev!=null&&t.parent.splitAfter(t.prev)):(t.next!=null&&this.splitAfter(t),t.prev!=null&&this.splitAfter(t.prev)),t.parent.unwrap()):t instanceof Xt.ParentBlot?t.unwrap():t.remove())})}};const B=e=>ie(e)?e:1,en=e.import(`blots/block`),tn=e.import(`blots/block/embed`);var V=class extends z{static blotName=t.tableCellInner;static tagName=`div`;static className=`ql-table-cell-inner`;static allowDataAttrs=new Set([`table-id`,`row-id`,`col-id`,`rowspan`,`colspan`,`empty-row`]);static defaultChild=en;static allowStyle=new Set([`background-color`,`border`,`height`]);static isAllowStyle(e){let t=Jt(e);for(let e of this.allowStyle)if(t.startsWith(Jt(e)))return!0;return!1}static create(e){let{tableId:t,rowId:n,colId:r,rowspan:i,colspan:a,style:o,emptyRow:s}=e,c=super.create();c.dataset.tableId=t,c.dataset.rowId=n,c.dataset.colId=r,c.dataset.rowspan=String(B(i)),c.dataset.colspan=String(B(a)),o&&(c.dataset.style=o);try{s&&(c.dataset.emptyRow=JSON.stringify(s))}catch{}return c}static formats(e){let{tableId:t,rowId:n,colId:r,rowspan:i,colspan:a,style:o,emptyRow:s}=e.dataset,c={tableId:String(t),rowId:String(n),colId:String(r),rowspan:Number(B(i)),colspan:Number(B(a))};o&&(c.style=o);try{s&&(c.emptyRow=JSON.parse(s))}catch{}return c}constructor(e,t,n){super(e,t),t.setAttribute(`contenteditable`,String(e.isEnabled()))}setFormatValue(e,n,r=!1){if(r){if(!this.statics.isAllowStyle(e))return;this.parent&&this.parent.statics.blotName===t.tableCell&&this.parent.setFormatValue(e,n)}else{if(!this.statics.allowDataAttrs.has(e))return;let r=`data-${e}`;n?this.domNode.setAttribute(r,n):this.domNode.removeAttribute(r),this.parent&&this.parent.statics.blotName===t.tableCell&&this.parent.setFormatValue(e,n)}let i=this.descendants(en,0);for(let e of i)e.cache={}}get tableId(){return this.domNode.dataset.tableId}get rowId(){return this.domNode.dataset.rowId}set rowId(e){this.setFormatValue(`row-id`,e)}get colId(){return this.domNode.dataset.colId}set colId(e){this.setFormatValue(`col-id`,e)}get rowspan(){return Number(this.domNode.dataset.rowspan)}set rowspan(e){this.setFormatValue(`rowspan`,e)}get colspan(){return Number(this.domNode.dataset.colspan)}set colspan(e){this.setFormatValue(`colspan`,e)}get emptyRow(){try{return JSON.parse(this.domNode.dataset.emptyRow)}catch{return[]}}set emptyRow(e){if(this.emptyRow.toString()!==e.toString())try{e.length>0?this.setFormatValue(`empty-row`,JSON.stringify(e),!1):this.setFormatValue(`empty-row`,null,!1)}catch{this.setFormatValue(`empty-row`,null,!1)}}getColumnIndex(){let e=d(this,t.tableMain);return e.getColIds().indexOf(this.colId)}setStyleByString(e){let t=Gt(e);for(let[e,n]of Object.entries(t))this.setFormatValue(e,n,!0)}formatAt(e,t,n,r){this.children.length===0&&(this.appendChild(this.scroll.create(this.statics.defaultChild.blotName)),t+=1),super.formatAt(e,t,n,r),r&&r.style&&this.setStyleByString(r.style)}insertAt(e,t,n){let[r]=this.children.find(e);if(!r&&this.statics.defaultChild){let e=this.scroll.create(this.statics.defaultChild.blotName||`block`);this.appendChild(e)}super.insertAt(e,t,n)}formats(){let e=this.statics.formats(this.domNode);return{[this.statics.blotName]:e}}checkMerge(){let{colId:e,rowId:t,colspan:n,rowspan:r}=this,i=this.next;return i!==null&&i.statics.blotName===this.statics.blotName&&i.rowId===t&&i.colId===e&&i.colspan===n&&i.rowspan===r}optimize(){let e=this.parent,n=this.statics.formats(this.domNode);if(this.prev&&this.prev instanceof tn){let e=this.prev;if(this.insertBefore(e,this.children.head),this.length()<=1){let t=this.scroll.create(`block`);this.insertBefore(t,e.next)}}let r=e!==null&&e.statics.blotName!==t.tableCell;if(r&&(this.wrap(t.tableCell,n),this.children.length===0)){let e=this.scroll.create(this.statics.defaultChild.blotName);this.appendChild(e)}this.children.length>0&&this.next!=null&&this.checkMerge()&&(this.next.moveChildren(this),this.next.remove()),this.uiNode!=null&&this.uiNode!==this.domNode.firstChild&&this.domNode.insertBefore(this.uiNode,this.domNode.firstChild),this.children.length===0?this.remove():this.domNode.dataset.style&&r&&e.domNode.style.cssText!==this.domNode.dataset.style&&this.setStyleByString(this.domNode.dataset.style)}insertBefore(e,n){if(e.statics.blotName===this.statics.blotName){let r=e,i=this.statics.formats(r.domNode),a=this.statics.formats(this.domNode),o=Object.entries(a).every(([e,t])=>String(t)===String(i[e]));if(o){let e=this.split(n?n.offset():0);return this.parent.insertBefore(r,e)}else{let[e,o]=f(this,[t.tableRow,t.tableCell]);if(n){let r=n.offset(),i=this.length();if(r+1<i){let n=this.scroll.create(t.tableCellInner,a);this.children.forEachAt(r+1,this.length(),e=>{n.appendChild(e)}),e.insertBefore(n.wrap(t.tableCell,a),o.next)}}if(this.rowId!==r.rowId){if(n){let t=n.offset(e);e.split(t)}else if(o.next){let t=o.next.offset(e);e.split(t)}let a=this.scroll.create(t.tableRow,i),s=this.scroll.create(t.tableCell,i);return s.appendChild(r),a.appendChild(s),e.parent.insertBefore(a,e.next)}return e.insertBefore(r.wrap(t.tableCell,i),n?o:o.next)}}else if(e.statics.blotName===t.tableCol){try{let n=d(this,t.tableBody),r=this.offset(n),i=n.split(r);n.parent.insertBefore(e,i),e.optimize({})}catch{console.warn(`TableCellInner not in TableBody`)}return}super.insertBefore(e,n)}},H=class extends z{static blotName=t.tableRow;static tagName=`tr`;static className=`ql-table-row`;static create(e){let t=super.create();return t.dataset.tableId=e.tableId,t.dataset.rowId=e.rowId,t}get rowId(){return this.domNode.dataset.rowId}get tableId(){return this.domNode.dataset.tableId}setHeight(e){this.foreachCellInner(t=>{t.setFormatValue(`height`,e,!0)})}getCellByColId(e,n){let r=d(this,t.tableMain),i=r.getColIds(),a=i.indexOf(e),o=this.children.iterator(),s=null;for(;s=o();){if(s.colId===e)return s;let t=i.indexOf(s.colId);if(t<a&&t+s.colspan>a)return s}return this[n]&&this[n].statics.blotName===t.tableRow?this[n].getCellByColId(e,n):null}insertCell(e,n){let r=[],i=this.children.iterator(),a=0,o;for(;(o=i())&&(a+=o.colspan,!(a>e));)if(o.rowspan!==1)for(let e=0;e<o.rowspan-1;e++)r[e]=(r[e]||0)+o.colspan;if(o&&a-o.colspan<e){let e=o.getCellInner();e.colspan+=1,o.rowspan!==1&&(r.skipRowNum=o.rowspan-1)}else{let e=this.scroll.create(t.tableCell,n),r=this.scroll.create(t.tableCellInner,n),i=this.scroll.create(`block`);i.appendChild(this.scroll.create(`break`)),r.appendChild(i),e.appendChild(r),this.insertBefore(e,o)}return r}getCellByColumIndex(e){let t=[],n=null,r=0;if(e<0)return[n,r,t];let i=this.children.iterator();for(;n=i();){if(r+=n.colspan,n.rowspan!==1)for(let e=0;e<n.rowspan-1;e++)t[e]=(t[e]||0)+n.colspan;if(r>e)break}return[n,r,t]}removeCell(e){if(e<0)return[];let n=this.getCellByColumIndex(e),[r,i]=n,a=n[2];if(!r)return a;if(i-r.colspan<e||r.colspan>1){let[n]=r.descendants(V);if(r.colspan!==1&&e===i-r.colspan){let e=d(this,t.tableMain),r=e.getColIds();n.colId=r[r.indexOf(n.colId)+1]}r.rowspan!==1&&(a.skipRowNum=r.rowspan-1),--n.colspan}else r.remove();return a}foreachCellInner(e){let t=this.children.iterator(),n=0,r;for(;r=t();){let[t]=r.descendants(V);if(e(t,n++))break}}checkMerge(){let e=this.next;return e!==null&&e.statics.blotName===this.statics.blotName&&e.rowId===this.rowId}optimize(e){let n=this.parent,{tableId:r}=this;n!==null&&n.statics.blotName!==t.tableBody&&this.wrap(t.tableBody,r),this.statics.requiredContainer&&!(this.parent instanceof this.statics.requiredContainer)&&this.wrap(this.statics.requiredContainer.blotName),this.enforceAllowedChildren(),this.children.length>0&&this.next!=null&&this.checkMerge()&&(this.next.moveChildren(this),this.next.remove())}},U=class extends z{static blotName=t.tableBody;static tagName=`tbody`;static create(e){let t=super.create();return t.dataset.tableId=e,t}get tableId(){return this.domNode.dataset.tableId}insertRow(e){let n=d(this,t.tableMain);if(!n)return;let r=n.getColIds(),i=this.descendants(H),a=new Set(r),o=0;for(let t of i){if(o===e)break;t.foreachCellInner(t=>{if(o+t.rowspan>e&&(t.rowspan+=1,a.delete(t.colId),t.colspan!==1)){let e=r.indexOf(t.colId);for(let n=0;n<t.colspan-1;n++)a.delete(r[e+n+1])}}),o+=1}let s=n.tableId,c=R(),l=this.scroll.create(t.tableRow,{tableId:s,rowId:c});for(let e of a){let n=this.scroll.create(`break`),r=n.wrap(`block`),i=r.wrap(t.tableCellInner,{tableId:s,rowId:c,colId:e,rowspan:1,colspan:1}),a=i.wrap(t.tableCell,{tableId:s,rowId:c,colId:e,rowspan:1,colspan:1});l.appendChild(a)}this.insertBefore(l,i[e]||null)}checkMerge(){let e=this.next;return e!==null&&e.statics.blotName===this.statics.blotName&&e.tableId===this.tableId}optimize(e){let n=this.parent;if(n!==null&&n.statics.blotName!==t.tableMain){let{tableId:e}=this;this.wrap(t.tableMain,{tableId:e})}super.optimize(e)}};const nn=e.import(`parchment`),rn=e.import(`blots/block`),an=e.import(`blots/container`);var on=class extends rn{replaceWith(e,n){let r=w(e)?this.scroll.create(e,n):e;if(r instanceof nn.ParentBlot)if(r.statics.blotName===t.tableCellInner){let e=this.parent;if(e.statics.blotName===t.tableCellInner){if(e?.insertBefore(r,this.prev?null:this.next),e.statics.blotName===t.tableCellInner){let e=this;for(;e;){let t=e.next;r.appendChild(e),e=t}}else r.appendChild(this);if(e&&e.length()===0){e.remove(),e.parent.statics.blotName===t.tableCell&&e.parent.length()===0&&e.parent.remove();let n=e.parent.parent;n.statics.blotName===t.tableRow&&n.children.length===0&&n.remove()}}else e instanceof an?e.parent.insertBefore(r,e):e?.insertBefore(r,this.next),r.appendChild(this);return r}else this.moveChildren(r);return this.parent!=null&&(this.parent.insertBefore(r,this.next),this.remove()),this.attributes.copy(r),r}format(e,n){if(e===t.tableCellInner&&this.parent.statics.blotName===e&&!n)try{let e=d(this,t.tableCellInner);e.unwrap()}catch{console.error(`unwrap TableCellInner error`)}else super.format(e,n)}};const sn=e.import(`blots/block/embed`);var cn=class extends sn{delta(){let e=super.delta(),n=ln(this);return n[t.tableCellInner]&&e.insert(`
|
|
1
|
+
import e from"quill";const t={container:`table-up-container`,tableCaption:`table-up-caption`,tableWrapper:`table-up`,tableMain:`table-up-main`,tableColgroup:`table-up-colgroup`,tableCol:`table-up-col`,tableBody:`table-up-body`,tableRow:`table-up-row`,tableCell:`table-up-cell`,tableCellInner:`table-up-cell-inner`},n={colMinWidthPre:5,colMinWidthPx:40,colDefaultWidth:100,rowMinHeightPx:36},r={AFTER_TABLE_RESIZE:`after-table-resize`},i={moduleName:`table-up`},a=[[`rgb(255, 255, 255)`,`rgb(0, 0, 0)`,`rgb(72, 83, 104)`,`rgb(41, 114, 244)`,`rgb(0, 163, 245)`,`rgb(49, 155, 98)`,`rgb(222, 60, 54)`,`rgb(248, 136, 37)`,`rgb(245, 196, 0)`,`rgb(153, 56, 215)`],[`rgb(242, 242, 242)`,`rgb(127, 127, 127)`,`rgb(243, 245, 247)`,`rgb(229, 239, 255)`,`rgb(229, 246, 255)`,`rgb(234, 250, 241)`,`rgb(254, 233, 232)`,`rgb(254, 243, 235)`,`rgb(254, 249, 227)`,`rgb(253, 235, 255)`],[`rgb(216, 216, 216)`,`rgb(89, 89, 89)`,`rgb(197, 202, 211)`,`rgb(199, 220, 255)`,`rgb(199, 236, 255)`,`rgb(195, 234, 213)`,`rgb(255, 201, 199)`,`rgb(255, 220, 196)`,`rgb(255, 238, 173)`,`rgb(242, 199, 255)`],[`rgb(191, 191, 191)`,`rgb(63, 63, 63)`,`rgb(128, 139, 158)`,`rgb(153, 190, 255)`,`rgb(153, 221, 255)`,`rgb(152, 215, 182)`,`rgb(255, 156, 153)`,`rgb(255, 186, 132)`,`rgb(255, 226, 112)`,`rgb(213, 142, 255)`],[`rgb(165, 165, 165)`,`rgb(38, 38, 38)`,`rgb(53, 59, 69)`,`rgb(20, 80, 184)`,`rgb(18, 116, 165)`,`rgb(39, 124, 79)`,`rgb(158, 30, 26)`,`rgb(184, 96, 20)`,`rgb(163, 130, 0)`,`rgb(94, 34, 129)`],[`rgb(147, 147, 147)`,`rgb(13, 13, 13)`,`rgb(36, 39, 46)`,`rgb(12, 48, 110)`,`rgb(10, 65, 92)`,`rgb(24, 78, 50)`,`rgb(88, 17, 14)`,`rgb(92, 48, 10)`,`rgb(102, 82, 0)`,`rgb(59, 21, 81)`]],o=`table-up`,s=new Set([t.tableCellInner]),c=e=>s.has(e.statics.blotName);function l(e){return e&&e.parent?c(e.parent)?!0:l(e.parent):!1}function u(e,t=o){let n=t?`${t}-`:``;return{b:()=>`${n}${e}`,be:t=>t?`${n}${e}__${t}`:``,bm:t=>t?`${n}${e}--${t}`:``,bem:(t,r)=>t&&r?`${n}${e}__${t}--${r}`:``,ns:e=>e?`${n}${e}`:``,bs:t=>t?`${n}${e}-${t}`:``,cv:e=>e?`--${n}${e}`:``,is:e=>`is-${e}`}}function d(e,t){let n=e.parent;for(;n&&n.statics.blotName!==t&&n!==e.scroll;)n=n.parent;if(n===e.scroll)throw Error(`${e.statics.blotName} must be a child of ${t}`);return n}function f(e,t){let n=Array(t.length),r=new Map(t.map((e,t)=>[e,t])),i=e.parent;for(;i&&i!==e.scroll&&r.size!==0;){if(r.has(i.statics.blotName)){let e=r.get(i.statics.blotName);n[e]=i,r.delete(i.statics.blotName)}i=i.parent}if(r.size>0)throw Error(`${e.statics.blotName} must be a child of ${Array.from(r.keys()).join(`, `)}`);return n}function p(e){let t=new Map,n=e;for(;n&&n.statics.blotName!==`scroll`;)t.set(n.statics.blotName,n),n=n.parent;return t}function m(e,t){let n=[],r=e.children.iterator(),i=null;for(;i=r();)i instanceof t&&n.push(i);return n}function h(e,t,n){for(let r of Object.getOwnPropertyNames(t)){if(n&&n.test(r))continue;Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(t,r))}return e}function g(e,t){let n=class extends e{constructor(...e){super(...e)}};for(let e of t)h(n.prototype,e.prototype,/^constructor$/);return n}function _(e,t){return e.prototype instanceof t}function v(e,t){return e=Math.min(t,Math.max(0,Number.parseFloat(`${e}`))),Math.abs(e-t)<1e-6?1:e%t/Number.parseFloat(t)}function y(e){return{h:Math.min(360,Math.max(0,e.h)),s:Math.min(100,Math.max(0,e.s)),b:Math.min(100,Math.max(0,e.b)),a:Math.min(1,Math.max(0,e.a))}}function b(e){e=e.startsWith(`#`)?e.slice(1):e;let t=Number.parseInt(e.slice(0,2),16),n=Number.parseInt(e.slice(2,4),16),r=Number.parseInt(e.slice(4,6),16),i=Number((Number.parseInt(e.slice(6,8)||`ff`,16)/255).toFixed(2));return{r:t,g:n,b:r,a:i}}function x(e){let{r:t,g:n,b:r,a:i}=e;t=v(t,255),n=v(n,255),r=v(r,255);let a=Math.max(t,n,r),o=Math.min(t,n,r),s,c=a,l=a-o,u=a===0?0:l/a;if(a===o)s=0;else{switch(a){case t:s=(n-r)/l+(n<r?6:0);break;case n:s=(r-t)/l+2;break;case r:s=(t-n)/l+4;break}s/=6}return{h:s*360,s:u*100,b:c*100,a:i}}function ee(e){let{h:t,s:n,b:r,a:i}=e;t=v(t,360)*6,n=v(n,100),r=v(r,100);let a=Math.floor(t),o=t-a,s=r*(1-n),c=r*(1-o*n),l=r*(1-(1-o)*n),u=a%6,d=[r,c,s,s,l,r][u],f=[l,r,r,c,s,s][u],p=[s,s,l,r,r,c][u];return{r:Math.round(d*255),g:Math.round(f*255),b:Math.round(p*255),a:i}}function te(e){let t=[e.r.toString(16),e.g.toString(16),e.b.toString(16),Math.round(e.a*255).toString(16)];for(let e in t)t[e].length===1&&(t[e]=`0${t[e]}`);return t.join(``)}const ne=e=>te(ee(e)),S=e=>typeof e==`function`,C=Array.isArray,w=e=>typeof e==`string`,re=e=>typeof e==`number`,T=e=>typeof e==`object`&&!!e,ie=e=>!Number.isNaN(e)&&Number(e)>0;function ae(e){let{type:t=`default`,content:n}=e||{},r=u(`button`),i=document.createElement(`button`);return i.classList.add(r.b(),t),n&&(w(n)?i.textContent=n:i.appendChild(n)),i}function oe(e={}){let t=230,n=150,r=10,i=x(b(e.color||`#ff0000`)),a=u(`color-picker`),o=document.createElement(`div`);o.classList.add(a.b());let s=document.createElement(`div`);s.classList.add(a.be(`content`));let c=document.createElement(`div`);c.classList.add(a.be(`selector`));let l=document.createElement(`div`);l.classList.add(a.be(`background`)),c.appendChild(l);let d=document.createElement(`div`);d.classList.add(a.be(`background-handle`)),l.appendChild(d);let f=document.createElement(`div`);f.classList.add(a.be(`alpha`));let p=document.createElement(`div`);p.classList.add(a.be(`alpha-bg`));let m=document.createElement(`div`);m.classList.add(a.be(`alpha-handle`)),f.appendChild(p),f.appendChild(m);let h=document.createElement(`div`);h.classList.add(a.be(`hue`));let g=document.createElement(`div`);g.classList.add(a.be(`hue-handle`)),h.appendChild(g);let _=document.createElement(`div`);_.classList.add(a.be(`action`));let[v,S,C,w]=[`r`,`g`,`b`,`a`].map(e=>{let t=document.createElement(`div`);t.classList.add(a.be(`action-item`),e);let n=document.createElement(`label`);n.textContent=e.toUpperCase();let r=document.createElement(`input`);return r.classList.add(a.be(`input`)),r.addEventListener(`input`,()=>{r.value=r.value.replaceAll(/[^0-9]/g,``)}),r.addEventListener(`change`,()=>{let t=Math.round(Number(r.value));e===`a`&&(t/=100);let n=y(x(Object.assign({},ee(i),{[e]:t})));E(n),de()}),t.appendChild(n),t.appendChild(r),_.appendChild(t),r});s.appendChild(h),s.appendChild(c),s.appendChild(f),o.appendChild(s),o.appendChild(_);let re=!1,T=!1,ie=!1;function ae(){let e=ne(i);for(let[t,n]of[v,S,C].entries())n.value=String(Number.parseInt(e[t*2]+e[t*2+1],16));w.value=String((i.a*100).toFixed(0))}function oe(){Object.assign(d.style,{left:`${Math.floor(t*i.s/100)}px`,top:`${Math.floor(n*(100-i.b)/100)}px`})}function se(){c.style.backgroundColor=`#${te(ee({h:i.h,s:100,b:100,a:1}))}`}function ce(){g.style.top=`${Math.floor(n-n*i.h/360)}px`}function le(){m.style.left=`${i.a*100}%`}function ue(){let{r:e,g:t,b:n}=ee(i);p.style.background=`linear-gradient(to right, rgba(${e}, ${t}, ${n}, 0) 0%, rgba(${e}, ${t}, ${n}, 1) 100%)`}function de(){oe(),se(),ce(),le(),ue(),ae()}function E(t){i=y(Object.assign({},i,t)),ae(),e.onChange&&e.onChange(`#${ne(i)}`)}function D(e){let r=c.getBoundingClientRect(),i=r.top+(window.pageYOffset||document.documentElement.scrollTop||document.body.scrollTop||0),a=r.left+document.body.scrollLeft,o=Math.floor(100*Math.max(0,Math.min(t,e.pageX-a))/t),s=Math.floor(100*(n-Math.max(0,Math.min(n,e.pageY-i)))/n);E({s:o,b:s}),de()}function fe(e){let t=h.getBoundingClientRect().top+(window.pageYOffset||document.documentElement.scrollTop||document.body.scrollTop||0);E({h:Math.floor(360*(n-Math.max(0,Math.min(n,e.pageY-t)))/n)}),de()}function pe(e){let{pageX:t}=e,n=f.getBoundingClientRect(),i=t-n.left;i=Math.max(r/2,i),i=Math.min(i,n.width-r/2),E({a:Math.round((i-10/2)/(n.width-10)*100)/100}),de()}function O(e){re&&(e.preventDefault(),D(e)),T&&(e.preventDefault(),fe(e)),ie&&(e.preventDefault(),pe(e))}function me(){document.removeEventListener(`mousemove`,O),document.removeEventListener(`mouseup`,me),re=!1}function he(e){document.addEventListener(`mousemove`,O),document.addEventListener(`mouseup`,me),re=!0,D(e)}c.addEventListener(`mousedown`,he);function ge(){document.removeEventListener(`mousemove`,O),document.removeEventListener(`mouseup`,ge),T=!1}function _e(e){document.addEventListener(`mousemove`,O),document.addEventListener(`mouseup`,ge),T=!0,fe(e)}h.addEventListener(`mousedown`,_e);function k(){document.removeEventListener(`mousemove`,O),document.removeEventListener(`mouseup`,k),ie=!1}function ve(e){document.addEventListener(`mousemove`,O),document.addEventListener(`mouseup`,k),ie=!0,pe(e)}return f.addEventListener(`mousedown`,ve),de(),o}let se=8e3;function ce({child:e,target:t=document.body,beforeClose:n=()=>{}}={}){let r=u(`dialog`),i=t,a=document.createElement(`div`);a.classList.add(r.b()),a.style.zIndex=String(se);let o=document.createElement(`div`);if(o.classList.add(r.be(`overlay`)),a.appendChild(o),e){let t=document.createElement(`div`);t.classList.add(r.be(`content`)),t.appendChild(e),o.appendChild(t),t.addEventListener(`click`,e=>{e.stopPropagation()})}let s=getComputedStyle(i).overflow;i.style.overflow=`hidden`,i.appendChild(a);let c=()=>{n(),a.remove(),i.style.overflow=s};return a.addEventListener(`click`,c),se+=1,{dialog:a,close:c}}function le(e,t){let n=u(`input`);t.type||=`text`,t.value||=``;let r=document.createElement(`div`);if(r.classList.add(n.be(`item`)),e){let t=document.createElement(`span`);t.classList.add(n.be(`label`)),t.textContent=e,r.appendChild(t)}let i=document.createElement(`div`);i.classList.add(n.be(`input`));let a=document.createElement(`input`);for(let e in t)a.setAttribute(e,t[e]);(t.max||t.min)&&a.addEventListener(`blur`,()=>{t.max&&t.max<=Number(a.value)&&(a.value=String(t.max)),t.min&&t.min>=Number(a.value)&&(a.value=String(t.min))}),i.appendChild(a),r.appendChild(i),a.addEventListener(`focus`,()=>{i.classList.add(`focus`)}),a.addEventListener(`blur`,()=>{i.classList.remove(`focus`)});let o=e=>{let t;i.classList.contains(`error`)?t=i.querySelector(`.${n.be(`error-tip`)}`):(t=document.createElement(`span`),t.classList.add(n.be(`error-tip`)),i.appendChild(t)),t.textContent=e,i.classList.add(`error`);let r=()=>{i.classList.remove(`error`),t.remove()};return{removeError:r}};return{item:r,input:a,errorTip:o}}async function ue(e={}){let t=u(`creator`),n=document.createElement(`div`);n.classList.add(t.b());let r=document.createElement(`div`);r.classList.add(t.be(`input`));let{item:i,input:a,errorTip:o}=le(e.rowText||`Row`,{type:`number`,value:String(e.row||``),max:99}),{item:s,input:c,errorTip:l}=le(e.colText||`Column`,{type:`number`,value:String(e.col||``),max:99});r.appendChild(i),r.appendChild(s),n.appendChild(r);let d=document.createElement(`div`);d.classList.add(t.be(`control`));let f=ae({type:`confirm`,content:e.confirmText||`Confirm`}),p=ae({type:`default`,content:e.cancelText||`Cancel`});d.appendChild(f),d.appendChild(p),n.appendChild(d);let m=(t=Number(a.value),n=Number(c.value))=>{if(Number.isNaN(t)||t<=0){o(e.notPositiveNumberError||`Please enter a positive integer`);return}if(Number.isNaN(n)||n<=0){l(e.notPositiveNumberError||`Please enter a positive integer`);return}return{row:t,col:n}},h=e=>{e.key===`Escape`&&(close(),document.removeEventListener(`keydown`,h))};return new Promise((e,t)=>{let{close:r}=ce({child:n,beforeClose:t});a.focus();for(let t of[a,c])t.addEventListener(`keydown`,t=>{if(t.key===`Enter`){let t=m();t&&(e(t),r())}});f.addEventListener(`click`,async()=>{let t=m();t&&(e(t),r())}),document.addEventListener(`keydown`,h),p.addEventListener(`click`,r)})}function de(e={}){let t=u(`select-box`),n=document.createElement(`div`);n.classList.add(t.b());let r=document.createElement(`div`);r.classList.add(t.be(`block`));for(let n=0;n<(e.row||8);n++)for(let i=0;i<(e.col||8);i++){let e=document.createElement(`div`);e.classList.add(t.be(`item`)),e.dataset.row=String(n+1),e.dataset.col=String(i+1),r.appendChild(e)}let i=()=>{let{row:e,col:t}=n.dataset;for(let e of Array.from(r.querySelectorAll(`.active`)))e.classList.remove(`active`);if(!e||!t)return;let i=Array.from(r.children);for(let n=0;n<i.length;n++){let{row:r,col:a}=i[n].dataset;if(r>e&&a>t)return;r<=e&&a<=t?i[n].classList.add(`active`):i[n].classList.remove(`active`)}};if(r.addEventListener(`mousemove`,e=>{if(!e.target)return;let{row:t,col:r}=e.target.dataset;!t||!r||(n.dataset.row=t,n.dataset.col=r,i())}),r.addEventListener(`mouseleave`,()=>{n.removeAttribute(`data-row`),n.removeAttribute(`data-col`),i()}),r.addEventListener(`click`,()=>{let{row:t,col:r}=n.dataset;!t||!r||e.onSelect&&e.onSelect(Number(t),Number(r))}),n.appendChild(r),e.customBtn){let r=e.texts||{},i=document.createElement(`div`);i.classList.add(t.be(`custom`)),i.textContent=r.customBtnText||`Custom`,i.addEventListener(`click`,async()=>{let t=await ue(r);t&&e.onSelect&&e.onSelect(t.row,t.col)}),n.appendChild(i)}return n}const E=Math.min,D=Math.max,fe=Math.round,pe=Math.floor,O=e=>({x:e,y:e}),me={left:`right`,right:`left`,bottom:`top`,top:`bottom`},he={start:`end`,end:`start`};function ge(e,t,n){return D(e,E(t,n))}function _e(e,t){return typeof e==`function`?e(t):e}function k(e){return e.split(`-`)[0]}function ve(e){return e.split(`-`)[1]}function ye(e){return e===`x`?`y`:`x`}function be(e){return e===`y`?`height`:`width`}function A(e){return[`top`,`bottom`].includes(k(e))?`y`:`x`}function xe(e){return ye(A(e))}function Se(e,t,n){n===void 0&&(n=!1);let r=ve(e),i=xe(e),a=be(i),o=i===`x`?r===(n?`end`:`start`)?`right`:`left`:r===`start`?`bottom`:`top`;return t.reference[a]>t.floating[a]&&(o=De(o)),[o,De(o)]}function Ce(e){let t=De(e);return[we(e),t,we(t)]}function we(e){return e.replace(/start|end/g,e=>he[e])}function Te(e,t,n){let r=[`left`,`right`],i=[`right`,`left`],a=[`top`,`bottom`],o=[`bottom`,`top`];switch(e){case`top`:case`bottom`:return n?t?i:r:t?r:i;case`left`:case`right`:return t?a:o;default:return[]}}function Ee(e,t,n,r){let i=ve(e),a=Te(k(e),n===`start`,r);return i&&(a=a.map(e=>e+`-`+i),t&&(a=a.concat(a.map(we)))),a}function De(e){return e.replace(/left|right|bottom|top/g,e=>me[e])}function Oe(e){return{top:0,right:0,bottom:0,left:0,...e}}function ke(e){return typeof e==`number`?{top:e,right:e,bottom:e,left:e}:Oe(e)}function Ae(e){let{x:t,y:n,width:r,height:i}=e;return{width:r,height:i,top:n,left:t,right:t+r,bottom:n+i,x:t,y:n}}function je(e,t,n){let{reference:r,floating:i}=e,a=A(t),o=xe(t),s=be(o),c=k(t),l=a===`y`,u=r.x+r.width/2-i.width/2,d=r.y+r.height/2-i.height/2,f=r[s]/2-i[s]/2,p;switch(c){case`top`:p={x:u,y:r.y-i.height};break;case`bottom`:p={x:u,y:r.y+r.height};break;case`right`:p={x:r.x+r.width,y:d};break;case`left`:p={x:r.x-i.width,y:d};break;default:p={x:r.x,y:r.y}}switch(ve(t)){case`start`:p[o]-=f*(n&&l?-1:1);break;case`end`:p[o]+=f*(n&&l?-1:1);break}return p}const Me=async(e,t,n)=>{let{placement:r=`bottom`,strategy:i=`absolute`,middleware:a=[],platform:o}=n,s=a.filter(Boolean),c=await(o.isRTL==null?void 0:o.isRTL(t)),l=await o.getElementRects({reference:e,floating:t,strategy:i}),{x:u,y:d}=je(l,r,c),f=r,p={},m=0;for(let n=0;n<s.length;n++){let{name:a,fn:h}=s[n],{x:g,y:_,data:v,reset:y}=await h({x:u,y:d,initialPlacement:r,placement:f,strategy:i,middlewareData:p,rects:l,platform:o,elements:{reference:e,floating:t}});u=g??u,d=_??d,p={...p,[a]:{...p[a],...v}},y&&m<=50&&(m++,typeof y==`object`&&(y.placement&&(f=y.placement),y.rects&&(l=y.rects===!0?await o.getElementRects({reference:e,floating:t,strategy:i}):y.rects),{x:u,y:d}=je(l,f,c)),n=-1)}return{x:u,y:d,placement:f,strategy:i,middlewareData:p}};async function Ne(e,t){var n;t===void 0&&(t={});let{x:r,y:i,platform:a,rects:o,elements:s,strategy:c}=e,{boundary:l=`clippingAncestors`,rootBoundary:u=`viewport`,elementContext:d=`floating`,altBoundary:f=!1,padding:p=0}=_e(t,e),m=ke(p),h=d===`floating`?`reference`:`floating`,g=s[f?h:d],_=Ae(await a.getClippingRect({element:(n=await(a.isElement==null?void 0:a.isElement(g)))??!0?g:g.contextElement||await(a.getDocumentElement==null?void 0:a.getDocumentElement(s.floating)),boundary:l,rootBoundary:u,strategy:c})),v=d===`floating`?{x:r,y:i,width:o.floating.width,height:o.floating.height}:o.reference,y=await(a.getOffsetParent==null?void 0:a.getOffsetParent(s.floating)),b=await(a.isElement==null?void 0:a.isElement(y))&&await(a.getScale==null?void 0:a.getScale(y))||{x:1,y:1},x=Ae(a.convertOffsetParentRelativeRectToViewportRelativeRect?await a.convertOffsetParentRelativeRectToViewportRelativeRect({elements:s,rect:v,offsetParent:y,strategy:c}):v);return{top:(_.top-x.top+m.top)/b.y,bottom:(x.bottom-_.bottom+m.bottom)/b.y,left:(_.left-x.left+m.left)/b.x,right:(x.right-_.right+m.right)/b.x}}const Pe=function(e){return e===void 0&&(e={}),{name:`flip`,options:e,async fn(t){var n,r;let{placement:i,middlewareData:a,rects:o,initialPlacement:s,platform:c,elements:l}=t,{mainAxis:u=!0,crossAxis:d=!0,fallbackPlacements:f,fallbackStrategy:p=`bestFit`,fallbackAxisSideDirection:m=`none`,flipAlignment:h=!0,...g}=_e(e,t);if((n=a.arrow)!=null&&n.alignmentOffset)return{};let _=k(i),v=A(s),y=k(s)===s,b=await(c.isRTL==null?void 0:c.isRTL(l.floating)),x=f||(y||!h?[De(s)]:Ce(s)),ee=m!==`none`;!f&&ee&&x.push(...Ee(s,h,m,b));let te=[s,...x],ne=await Ne(t,g),S=[],C=(r=a.flip)?.overflows||[];if(u&&S.push(ne[_]),d){let e=Se(i,o,b);S.push(ne[e[0]],ne[e[1]])}if(C=[...C,{placement:i,overflows:S}],!S.every(e=>e<=0)){var w,re;let e=((w=a.flip)?.index||0)+1,t=te[e];if(t){let n=d===`alignment`?v!==A(t):!1;if(!n||C.every(e=>e.overflows[0]>0&&A(e.placement)===v))return{data:{index:e,overflows:C},reset:{placement:t}}}let n=(re=C.filter(e=>e.overflows[0]<=0).sort((e,t)=>e.overflows[1]-t.overflows[1])[0])?.placement;if(!n)switch(p){case`bestFit`:{var T;let e=(T=C.filter(e=>{if(ee){let t=A(e.placement);return t===v||t===`y`}return!0}).map(e=>[e.placement,e.overflows.filter(e=>e>0).reduce((e,t)=>e+t,0)]).sort((e,t)=>e[1]-t[1])[0])?.[0];e&&(n=e);break}case`initialPlacement`:n=s;break}if(i!==n)return{reset:{placement:n}}}return{}}}};async function Fe(e,t){let{placement:n,platform:r,elements:i}=e,a=await(r.isRTL==null?void 0:r.isRTL(i.floating)),o=k(n),s=ve(n),c=A(n)===`y`,l=[`left`,`top`].includes(o)?-1:1,u=a&&c?-1:1,d=_e(t,e),{mainAxis:f,crossAxis:p,alignmentAxis:m}=typeof d==`number`?{mainAxis:d,crossAxis:0,alignmentAxis:null}:{mainAxis:d.mainAxis||0,crossAxis:d.crossAxis||0,alignmentAxis:d.alignmentAxis};return s&&typeof m==`number`&&(p=s===`end`?m*-1:m),c?{x:p*u,y:f*l}:{x:f*l,y:p*u}}const Ie=function(e){return e===void 0&&(e=0),{name:`offset`,options:e,async fn(t){var n,r;let{x:i,y:a,placement:o,middlewareData:s}=t,c=await Fe(t,e);return o===(n=s.offset)?.placement&&(r=s.arrow)!=null&&r.alignmentOffset?{}:{x:i+c.x,y:a+c.y,data:{...c,placement:o}}}}},Le=function(e){return e===void 0&&(e={}),{name:`shift`,options:e,async fn(t){let{x:n,y:r,placement:i}=t,{mainAxis:a=!0,crossAxis:o=!1,limiter:s={fn:e=>{let{x:t,y:n}=e;return{x:t,y:n}}},...c}=_e(e,t),l={x:n,y:r},u=await Ne(t,c),d=A(k(i)),f=ye(d),p=l[f],m=l[d];if(a){let e=f===`y`?`top`:`left`,t=f===`y`?`bottom`:`right`,n=p+u[e],r=p-u[t];p=ge(n,p,r)}if(o){let e=d===`y`?`top`:`left`,t=d===`y`?`bottom`:`right`,n=m+u[e],r=m-u[t];m=ge(n,m,r)}let h=s.fn({...t,[f]:p,[d]:m});return{...h,data:{x:h.x-n,y:h.y-r,enabled:{[f]:a,[d]:o}}}}}},Re=function(e){return e===void 0&&(e={}),{options:e,fn(t){let{x:n,y:r,placement:i,rects:a,middlewareData:o}=t,{offset:s=0,mainAxis:c=!0,crossAxis:l=!0}=_e(e,t),u={x:n,y:r},d=A(i),f=ye(d),p=u[f],m=u[d],h=_e(s,t),g=typeof h==`number`?{mainAxis:h,crossAxis:0}:{mainAxis:0,crossAxis:0,...h};if(c){let e=f===`y`?`height`:`width`,t=a.reference[f]-a.floating[e]+g.mainAxis,n=a.reference[f]+a.reference[e]-g.mainAxis;p<t?p=t:p>n&&(p=n)}if(l){var _,v;let e=f===`y`?`width`:`height`,t=[`top`,`left`].includes(k(i)),n=a.reference[d]-a.floating[e]+(t&&(_=o.offset)?.[d]||0)+(t?0:g.crossAxis),r=a.reference[d]+a.reference[e]+(t?0:(v=o.offset)?.[d]||0)-(t?g.crossAxis:0);m<n?m=n:m>r&&(m=r)}return{[f]:p,[d]:m}}}};function ze(){return typeof window<`u`}function Be(e){return Ve(e)?(e.nodeName||``).toLowerCase():`#document`}function j(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function M(e){var t;return(t=(Ve(e)?e.ownerDocument:e.document)||window.document)?.documentElement}function Ve(e){return ze()?e instanceof Node||e instanceof j(e).Node:!1}function N(e){return ze()?e instanceof Element||e instanceof j(e).Element:!1}function P(e){return ze()?e instanceof HTMLElement||e instanceof j(e).HTMLElement:!1}function He(e){return!ze()||typeof ShadowRoot>`u`?!1:e instanceof ShadowRoot||e instanceof j(e).ShadowRoot}function Ue(e){let{overflow:t,overflowX:n,overflowY:r,display:i}=F(e);return/auto|scroll|overlay|hidden|clip/.test(t+r+n)&&![`inline`,`contents`].includes(i)}function We(e){return[`table`,`td`,`th`].includes(Be(e))}function Ge(e){return[`:popover-open`,`:modal`].some(t=>{try{return e.matches(t)}catch{return!1}})}function Ke(e){let t=Je(),n=N(e)?F(e):e;return[`transform`,`translate`,`scale`,`rotate`,`perspective`].some(e=>n[e]?n[e]!==`none`:!1)||(n.containerType?n.containerType!==`normal`:!1)||!t&&(n.backdropFilter?n.backdropFilter!==`none`:!1)||!t&&(n.filter?n.filter!==`none`:!1)||[`transform`,`translate`,`scale`,`rotate`,`perspective`,`filter`].some(e=>(n.willChange||``).includes(e))||[`paint`,`layout`,`strict`,`content`].some(e=>(n.contain||``).includes(e))}function qe(e){let t=I(e);for(;P(t)&&!Ye(t);){if(Ke(t))return t;if(Ge(t))return null;t=I(t)}return null}function Je(){return typeof CSS>`u`||!CSS.supports?!1:CSS.supports(`-webkit-backdrop-filter`,`none`)}function Ye(e){return[`html`,`body`,`#document`].includes(Be(e))}function F(e){return j(e).getComputedStyle(e)}function Xe(e){return N(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function I(e){if(Be(e)===`html`)return e;let t=e.assignedSlot||e.parentNode||He(e)&&e.host||M(e);return He(t)?t.host:t}function Ze(e){let t=I(e);return Ye(t)?e.ownerDocument?e.ownerDocument.body:e.body:P(t)&&Ue(t)?t:Ze(t)}function Qe(e,t,n){var r;t===void 0&&(t=[]),n===void 0&&(n=!0);let i=Ze(e),a=i===(r=e.ownerDocument)?.body,o=j(i);if(a){let e=$e(o);return t.concat(o,o.visualViewport||[],Ue(i)?i:[],e&&n?Qe(e):[])}return t.concat(i,Qe(i,[],n))}function $e(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function et(e){let t=F(e),n=parseFloat(t.width)||0,r=parseFloat(t.height)||0,i=P(e),a=i?e.offsetWidth:n,o=i?e.offsetHeight:r,s=fe(n)!==a||fe(r)!==o;return s&&(n=a,r=o),{width:n,height:r,$:s}}function tt(e){return N(e)?e:e.contextElement}function nt(e){let t=tt(e);if(!P(t))return O(1);let n=t.getBoundingClientRect(),{width:r,height:i,$:a}=et(t),o=(a?fe(n.width):n.width)/r,s=(a?fe(n.height):n.height)/i;return(!o||!Number.isFinite(o))&&(o=1),(!s||!Number.isFinite(s))&&(s=1),{x:o,y:s}}const rt=O(0);function it(e){let t=j(e);return!Je()||!t.visualViewport?rt:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function at(e,t,n){return t===void 0&&(t=!1),!n||t&&n!==j(e)?!1:t}function ot(e,t,n,r){t===void 0&&(t=!1),n===void 0&&(n=!1);let i=e.getBoundingClientRect(),a=tt(e),o=O(1);t&&(r?N(r)&&(o=nt(r)):o=nt(e));let s=at(a,n,r)?it(a):O(0),c=(i.left+s.x)/o.x,l=(i.top+s.y)/o.y,u=i.width/o.x,d=i.height/o.y;if(a){let e=j(a),t=r&&N(r)?j(r):r,n=e,i=$e(n);for(;i&&r&&t!==n;){let e=nt(i),t=i.getBoundingClientRect(),r=F(i),a=t.left+(i.clientLeft+parseFloat(r.paddingLeft))*e.x,o=t.top+(i.clientTop+parseFloat(r.paddingTop))*e.y;c*=e.x,l*=e.y,u*=e.x,d*=e.y,c+=a,l+=o,n=j(i),i=$e(n)}}return Ae({width:u,height:d,x:c,y:l})}function st(e,t){let n=Xe(e).scrollLeft;return t?t.left+n:ot(M(e)).left+n}function ct(e,t,n){n===void 0&&(n=!1);let r=e.getBoundingClientRect(),i=r.left+t.scrollLeft-(n?0:st(e,r)),a=r.top+t.scrollTop;return{x:i,y:a}}function lt(e){let{elements:t,rect:n,offsetParent:r,strategy:i}=e,a=i===`fixed`,o=M(r),s=t?Ge(t.floating):!1;if(r===o||s&&a)return n;let c={scrollLeft:0,scrollTop:0},l=O(1),u=O(0),d=P(r);if((d||!d&&!a)&&((Be(r)!==`body`||Ue(o))&&(c=Xe(r)),P(r))){let e=ot(r);l=nt(r),u.x=e.x+r.clientLeft,u.y=e.y+r.clientTop}let f=o&&!d&&!a?ct(o,c,!0):O(0);return{width:n.width*l.x,height:n.height*l.y,x:n.x*l.x-c.scrollLeft*l.x+u.x+f.x,y:n.y*l.y-c.scrollTop*l.y+u.y+f.y}}function ut(e){return Array.from(e.getClientRects())}function dt(e){let t=M(e),n=Xe(e),r=e.ownerDocument.body,i=D(t.scrollWidth,t.clientWidth,r.scrollWidth,r.clientWidth),a=D(t.scrollHeight,t.clientHeight,r.scrollHeight,r.clientHeight),o=-n.scrollLeft+st(e),s=-n.scrollTop;return F(r).direction===`rtl`&&(o+=D(t.clientWidth,r.clientWidth)-i),{width:i,height:a,x:o,y:s}}function ft(e,t){let n=j(e),r=M(e),i=n.visualViewport,a=r.clientWidth,o=r.clientHeight,s=0,c=0;if(i){a=i.width,o=i.height;let e=Je();(!e||e&&t===`fixed`)&&(s=i.offsetLeft,c=i.offsetTop)}return{width:a,height:o,x:s,y:c}}function pt(e,t){let n=ot(e,!0,t===`fixed`),r=n.top+e.clientTop,i=n.left+e.clientLeft,a=P(e)?nt(e):O(1),o=e.clientWidth*a.x,s=e.clientHeight*a.y,c=i*a.x,l=r*a.y;return{width:o,height:s,x:c,y:l}}function mt(e,t,n){let r;if(t===`viewport`)r=ft(e,n);else if(t===`document`)r=dt(M(e));else if(N(t))r=pt(t,n);else{let n=it(e);r={x:t.x-n.x,y:t.y-n.y,width:t.width,height:t.height}}return Ae(r)}function ht(e,t){let n=I(e);return n===t||!N(n)||Ye(n)?!1:F(n).position===`fixed`||ht(n,t)}function gt(e,t){let n=t.get(e);if(n)return n;let r=Qe(e,[],!1).filter(e=>N(e)&&Be(e)!==`body`),i=null,a=F(e).position===`fixed`,o=a?I(e):e;for(;N(o)&&!Ye(o);){let t=F(o),n=Ke(o);!n&&t.position===`fixed`&&(i=null);let s=a?!n&&!i:!n&&t.position===`static`&&!!i&&[`absolute`,`fixed`].includes(i.position)||Ue(o)&&!n&&ht(e,o);s?r=r.filter(e=>e!==o):i=t,o=I(o)}return t.set(e,r),r}function _t(e){let{element:t,boundary:n,rootBoundary:r,strategy:i}=e,a=n===`clippingAncestors`?Ge(t)?[]:gt(t,this._c):[].concat(n),o=[...a,r],s=o[0],c=o.reduce((e,n)=>{let r=mt(t,n,i);return e.top=D(r.top,e.top),e.right=E(r.right,e.right),e.bottom=E(r.bottom,e.bottom),e.left=D(r.left,e.left),e},mt(t,s,i));return{width:c.right-c.left,height:c.bottom-c.top,x:c.left,y:c.top}}function vt(e){let{width:t,height:n}=et(e);return{width:t,height:n}}function yt(e,t,n){let r=P(t),i=M(t),a=n===`fixed`,o=ot(e,!0,a,t),s={scrollLeft:0,scrollTop:0},c=O(0);function l(){c.x=st(i)}if(r||!r&&!a)if((Be(t)!==`body`||Ue(i))&&(s=Xe(t)),r){let e=ot(t,!0,a,t);c.x=e.x+t.clientLeft,c.y=e.y+t.clientTop}else i&&l();a&&!r&&i&&l();let u=i&&!r&&!a?ct(i,s):O(0),d=o.left+s.scrollLeft-c.x-u.x,f=o.top+s.scrollTop-c.y-u.y;return{x:d,y:f,width:o.width,height:o.height}}function bt(e){return F(e).position===`static`}function xt(e,t){if(!P(e)||F(e).position===`fixed`)return null;if(t)return t(e);let n=e.offsetParent;return M(e)===n&&(n=n.ownerDocument.body),n}function St(e,t){let n=j(e);if(Ge(e))return n;if(!P(e)){let t=I(e);for(;t&&!Ye(t);){if(N(t)&&!bt(t))return t;t=I(t)}return n}let r=xt(e,t);for(;r&&We(r)&&bt(r);)r=xt(r,t);return r&&Ye(r)&&bt(r)&&!Ke(r)?n:r||qe(e)||n}const Ct=async function(e){let t=this.getOffsetParent||St,n=this.getDimensions,r=await n(e.floating);return{reference:yt(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function wt(e){return F(e).direction===`rtl`}const Tt={convertOffsetParentRelativeRectToViewportRelativeRect:lt,getDocumentElement:M,getClippingRect:_t,getOffsetParent:St,getElementRects:Ct,getClientRects:ut,getDimensions:vt,getScale:nt,isElement:N,isRTL:wt};function Et(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function Dt(e,t){let n=null,r,i=M(e);function a(){var e;clearTimeout(r),(e=n)==null||e.disconnect(),n=null}function o(s,c){s===void 0&&(s=!1),c===void 0&&(c=1),a();let l=e.getBoundingClientRect(),{left:u,top:d,width:f,height:p}=l;if(s||t(),!f||!p)return;let m=pe(d),h=pe(i.clientWidth-(u+f)),g=pe(i.clientHeight-(d+p)),_=pe(u),v=-m+`px `+-h+`px `+-g+`px `+-_+`px`,y={rootMargin:v,threshold:D(0,E(1,c))||1},b=!0;function x(t){let n=t[0].intersectionRatio;if(n!==c){if(!b)return o();n?o(!1,n):r=setTimeout(()=>{o(!1,1e-7)},1e3)}n===1&&!Et(l,e.getBoundingClientRect())&&o(),b=!1}try{n=new IntersectionObserver(x,{...y,root:i.ownerDocument})}catch{n=new IntersectionObserver(x,y)}n.observe(e)}return o(!0),a}function Ot(e,t,n,r){r===void 0&&(r={});let{ancestorScroll:i=!0,ancestorResize:a=!0,elementResize:o=typeof ResizeObserver==`function`,layoutShift:s=typeof IntersectionObserver==`function`,animationFrame:c=!1}=r,l=tt(e),u=i||a?[...l?Qe(l):[],...Qe(t)]:[];u.forEach(e=>{i&&e.addEventListener(`scroll`,n,{passive:!0}),a&&e.addEventListener(`resize`,n)});let d=l&&s?Dt(l,n):null,f=-1,p=null;o&&(p=new ResizeObserver(e=>{let[r]=e;r&&r.target===l&&p&&(p.unobserve(t),cancelAnimationFrame(f),f=requestAnimationFrame(()=>{var e;(e=p)==null||e.observe(t)})),n()}),l&&!c&&p.observe(l),p.observe(t));let m,h=c?ot(e):null;c&&g();function g(){let t=ot(e);h&&!Et(h,t)&&n(),h=t,m=requestAnimationFrame(g)}return n(),()=>{var e;u.forEach(e=>{i&&e.removeEventListener(`scroll`,n),a&&e.removeEventListener(`resize`,n)}),d?.(),(e=p)==null||e.disconnect(),p=null,c&&cancelAnimationFrame(m)}}const kt=Ie,At=Le,jt=Pe,Mt=Re,Nt=(e,t,n)=>{let r=new Map,i={platform:Tt,...n},a={...i.platform,_c:r};return Me(e,t,{...i,platform:a})};function Pt(e,t,n,r,i){return i&&clearTimeout(i),e.addEventListener(`transitionend`,n,r),setTimeout(()=>{n()},t)}const Ft=4;let It;function Lt(e,t={}){let{msg:n=``,delay:r=150,content:i,direction:a=`bottom`,type:o=`hover`,container:s,onOpen:c,onClose:l,closed:d,onDestroy:f}=t,p=u(`tooltip`);if(n||i){It||(It=document.createElement(`div`),document.body.appendChild(It));let t=s||It,u=document.createElement(`div`);u.classList.add(p.b(),`hidden`,`transparent`),i?u.appendChild(i):n&&(u.textContent=n);let m,h,g,_=()=>{g&&g(),Nt(e,u,{placement:a,middleware:[jt(),At({limiter:Mt()}),kt(Ft)]}).then(({x:e,y:t})=>{Object.assign(u.style,{left:`${e}px`,top:`${t}px`})})},v=()=>{u.classList.add(`hidden`),t.contains(u)&&t.removeChild(u),g&&g(),d&&d()},y=(n=!1)=>{h&&clearTimeout(h),m=setTimeout(()=>{if(c){let e=c(n);if(!n&&e)return}t.appendChild(u),u.removeEventListener(`transitionend`,v),u.classList.remove(`hidden`),g=Ot(e,u,_),u.classList.remove(`transparent`)},r)},b=(e=!1)=>{m&&clearTimeout(m),h=setTimeout(()=>{if(l){let t=l(e);if(!e&&t)return}Pt(u,150,v,{once:!0}),u.classList.add(`transparent`)},r)},x=()=>{let t=[e,u],n=b.bind(void 0,!1),r=y.bind(void 0,!1),i=()=>{for(let e of t)e.addEventListener(`mouseenter`,r),e.addEventListener(`mouseleave`,n)};return{prepare:i,show:y,hide:b,destroy:()=>{for(let e of t)e.removeEventListener(`mouseenter`,r),e.removeEventListener(`mouseleave`,n)}}},ee=()=>{let t=e=>{e.stopPropagation(),b(!1)},n=e=>{e.stopPropagation(),y(),document.removeEventListener(`click`,t),document.addEventListener(`click`,t,{once:!0})};return{prepare:()=>{u.addEventListener(`click`,e=>e.stopPropagation()),e.addEventListener(`click`,n)},show:y,hide:(e=!1)=>{b(e),document.removeEventListener(`click`,t)},destroy:()=>{e.removeEventListener(`click`,n),document.removeEventListener(`click`,t)}}},te={hover:x,click:ee},{prepare:ne,show:S,hide:C,destroy:w}=te[o]();ne();let re=()=>{C(!0),f&&f(),w(),g&&g(),u.remove()};return{show:S,hide:C,destroy:re}}return null}function Rt(e,t,n=0,r=!0){let{x:i,y:a,x1:o,y1:s}=e,{x:c,y:l,x1:u,y1:d}=t,f,p;return r?(f=o<c+n||i-n>u,p=s<l+n||a-n>d):(f=o<=c+n||i-n>=u,p=s<=l+n||a-n>=d),!(f||p)}function zt(e,t){let n=t.getBoundingClientRect();return{x:e.x-n.x-t.scrollLeft,y:e.y-n.y-t.scrollTop,x1:e.x-n.x-t.scrollLeft+e.width,y1:e.y-n.y-t.scrollTop+e.height,width:e.width,height:e.height}}const Bt=8;function Vt(e){let{left:t,top:n,width:r,height:i}=e,{clientWidth:a,clientHeight:o}=document.documentElement,s=!1,c=!1;return t+r>a?(t=a-r-Bt,s=!0):t<0&&(t=Bt,s=!0),n+i>o?(n=o-i-Bt,c=!0):n<0&&(n=Bt,c=!0),{left:t,top:n,leftLimited:s,topLimited:c}}function Ht(e,t={}){let n=Symbol(`ignoreFirstBind`),r=new Set,i=new ResizeObserver(r=>{t.ignoreFirstBind&&r.some(e=>{let t=e.target,r=t[n];return t[n]=!0,!r})||e(r)}),a=i.observe;i.observe=(e,t)=>{r.add(e),a.call(i,e,t)};let o=i.unobserve;i.unobserve=e=>{r.has(e)&&(r.delete(e),e[n]=void 0),o.call(i,e)};let s=i.disconnect;return i.disconnect=()=>{for(let e of r.values())e[n]=void 0;s.call(i)},i}function L(e,t){e.addEventListener(`scroll`,t),this.scrollHandler.push([e,t])}function Ut(){for(let e=0;e<this.scrollHandler.length;e++){let[t,n]=this.scrollHandler[e];t.removeEventListener(`scroll`,n)}this.scrollHandler=[]}function Wt(e){return{y:e.scrollTop,x:e.scrollLeft}}function Gt(e){let t={},n=e.trim().split(`;`);for(let e=0;e<n.length;e++){let r=n[e].trim();if(!r)continue;let i=r.indexOf(`:`);if(i===-1)continue;let a=r.slice(0,Math.max(0,i)).trim(),o=r.slice(Math.max(0,i+1)).trim();t[Jt(a)]=o}return t}function Kt(e){return Object.entries(e).map(([e,t])=>`${qt(e)}: ${t};`).join(` `)}function qt(e){let t=e.replaceAll(/([A-Z])/g,` $1`).trim();return t.split(` `).join(`-`).toLowerCase()}function Jt(e){return e.replaceAll(/-(\w)/g,(e,t)=>t.toUpperCase())}const R=()=>Math.random().toString(36).slice(2);function Yt(e,t){let n;return function(...r){n&&clearTimeout(n),n=setTimeout(()=>{e.apply(this,r)},t)}}const Xt=e.import(`parchment`),Zt=e.import(`blots/container`),Qt=e.import(`blots/block`),$t=e.import(`blots/block/embed`);var z=class e extends Zt{static tagName;static blotName=t.container;static scope=Xt.Scope.BLOCK_BLOT;static allowedChildren=[Qt,$t,Zt];static requiredContainer;static defaultChild;static create(e){let t=document.createElement(this.tagName);return this.className&&t.classList.add(this.className),t}optimize(e){if(this.children.length===0)if(this.statics.defaultChild!=null){let e=this.scroll.create(this.statics.defaultChild.blotName);this.appendChild(e)}else this.remove();this.children.length>0&&this.next!=null&&this.checkMerge()&&(this.next.moveChildren(this),this.next.remove())}enforceAllowedChildren(){this.children.forEach(t=>{let n=this.statics.allowedChildren.some(e=>t instanceof e);n||(t.statics.scope===Xt.Scope.BLOCK_BLOT?(t.parent instanceof e?(t.next!=null&&t.parent.splitAfter(t),t.prev!=null&&t.parent.splitAfter(t.prev)):(t.next!=null&&this.splitAfter(t),t.prev!=null&&this.splitAfter(t.prev)),t.parent.unwrap()):t instanceof Xt.ParentBlot?t.unwrap():t.remove())})}};const B=e=>ie(e)?e:1,en=e.import(`blots/block`),tn=e.import(`blots/block/embed`);var V=class extends z{static blotName=t.tableCellInner;static tagName=`div`;static className=`ql-table-cell-inner`;static allowDataAttrs=new Set([`table-id`,`row-id`,`col-id`,`rowspan`,`colspan`,`empty-row`]);static defaultChild=en;static allowStyle=new Set([`background-color`,`border`,`height`]);static isAllowStyle(e){let t=Jt(e);for(let e of this.allowStyle)if(t.startsWith(Jt(e)))return!0;return!1}static create(e){let{tableId:t,rowId:n,colId:r,rowspan:i,colspan:a,style:o,emptyRow:s}=e,c=super.create();c.dataset.tableId=t,c.dataset.rowId=n,c.dataset.colId=r,c.dataset.rowspan=String(B(i)),c.dataset.colspan=String(B(a)),o&&(c.dataset.style=o);try{s&&(c.dataset.emptyRow=JSON.stringify(s))}catch{}return c}static formats(e){let{tableId:t,rowId:n,colId:r,rowspan:i,colspan:a,style:o,emptyRow:s}=e.dataset,c={tableId:String(t),rowId:String(n),colId:String(r),rowspan:Number(B(i)),colspan:Number(B(a))};o&&(c.style=o);try{s&&(c.emptyRow=JSON.parse(s))}catch{}return c}constructor(e,t,n){super(e,t),t.setAttribute(`contenteditable`,String(e.isEnabled()))}setFormatValue(e,n,r=!1){if(r){if(!this.statics.isAllowStyle(e))return;this.parent&&this.parent.statics.blotName===t.tableCell&&this.parent.setFormatValue(e,n)}else{if(!this.statics.allowDataAttrs.has(e))return;let r=`data-${e}`;n?this.domNode.setAttribute(r,n):this.domNode.removeAttribute(r),this.parent&&this.parent.statics.blotName===t.tableCell&&this.parent.setFormatValue(e,n)}let i=this.descendants(en,0);for(let e of i)e.cache={}}get tableId(){return this.domNode.dataset.tableId}get rowId(){return this.domNode.dataset.rowId}set rowId(e){this.setFormatValue(`row-id`,e)}get colId(){return this.domNode.dataset.colId}set colId(e){this.setFormatValue(`col-id`,e)}get rowspan(){return Number(this.domNode.dataset.rowspan)}set rowspan(e){this.setFormatValue(`rowspan`,e)}get colspan(){return Number(this.domNode.dataset.colspan)}set colspan(e){this.setFormatValue(`colspan`,e)}get emptyRow(){try{return JSON.parse(this.domNode.dataset.emptyRow)}catch{return[]}}set emptyRow(e){if(this.emptyRow.toString()!==e.toString())try{e.length>0?this.setFormatValue(`empty-row`,JSON.stringify(e),!1):this.setFormatValue(`empty-row`,null,!1)}catch{this.setFormatValue(`empty-row`,null,!1)}}getColumnIndex(){let e=d(this,t.tableMain);return e.getColIds().indexOf(this.colId)}setStyleByString(e){let t=Gt(e);for(let[e,n]of Object.entries(t))this.setFormatValue(e,n,!0)}formatAt(e,t,n,r){this.children.length===0&&(this.appendChild(this.scroll.create(this.statics.defaultChild.blotName)),t+=1),super.formatAt(e,t,n,r),r&&r.style&&this.setStyleByString(r.style)}insertAt(e,t,n){let[r]=this.children.find(e);if(!r&&this.statics.defaultChild){let e=this.scroll.create(this.statics.defaultChild.blotName||`block`);this.appendChild(e)}super.insertAt(e,t,n)}formats(){let e=this.statics.formats(this.domNode);return{[this.statics.blotName]:e}}checkMerge(){let{colId:e,rowId:t,colspan:n,rowspan:r}=this,i=this.next;return i!==null&&i.statics.blotName===this.statics.blotName&&i.rowId===t&&i.colId===e&&i.colspan===n&&i.rowspan===r}optimize(){let e=this.parent,n=this.statics.formats(this.domNode);if(this.prev&&this.prev instanceof tn){let e=this.prev;if(this.insertBefore(e,this.children.head),this.length()<=1){let t=this.scroll.create(`block`);this.insertBefore(t,e.next)}}let r=e!==null&&e.statics.blotName!==t.tableCell;if(r&&(this.wrap(t.tableCell,n),this.children.length===0)){let e=this.scroll.create(this.statics.defaultChild.blotName);this.appendChild(e)}this.children.length>0&&this.next!=null&&this.checkMerge()&&(this.next.moveChildren(this),this.next.remove()),this.uiNode!=null&&this.uiNode!==this.domNode.firstChild&&this.domNode.insertBefore(this.uiNode,this.domNode.firstChild),this.children.length===0?this.remove():this.domNode.dataset.style&&r&&e.domNode.style.cssText!==this.domNode.dataset.style&&this.setStyleByString(this.domNode.dataset.style)}insertBefore(e,n){if(e.statics.blotName===this.statics.blotName){let r=e,i=this.statics.formats(r.domNode),a=this.statics.formats(this.domNode),o=Object.entries(a).every(([e,t])=>String(t)===String(i[e]));if(o){let e=this.split(n?n.offset():0);return this.parent.insertBefore(r,e)}else{let[e,o]=f(this,[t.tableRow,t.tableCell]);if(n){let r=n.offset(),i=this.length();if(r+1<i){let n=this.scroll.create(t.tableCellInner,a);this.children.forEachAt(r+1,this.length(),e=>{n.appendChild(e)}),e.insertBefore(n.wrap(t.tableCell,a),o.next)}}if(this.rowId!==r.rowId){if(n){let t=n.offset(e);e.split(t)}else if(o.next){let t=o.next.offset(e);e.split(t)}let a=this.scroll.create(t.tableRow,i),s=this.scroll.create(t.tableCell,i);return s.appendChild(r),a.appendChild(s),e.parent.insertBefore(a,e.next)}return e.insertBefore(r.wrap(t.tableCell,i),n?o:o.next)}}else if(e.statics.blotName===t.tableCol){try{let n=d(this,t.tableBody),r=this.offset(n),i=n.split(r);n.parent.insertBefore(e,i),e.optimize({})}catch{console.warn(`TableCellInner not in TableBody`)}return}super.insertBefore(e,n)}},H=class extends z{static blotName=t.tableRow;static tagName=`tr`;static className=`ql-table-row`;static create(e){let t=super.create();return t.dataset.tableId=e.tableId,t.dataset.rowId=e.rowId,t}get rowId(){return this.domNode.dataset.rowId}get tableId(){return this.domNode.dataset.tableId}setHeight(e){this.foreachCellInner(t=>{t.setFormatValue(`height`,e,!0)})}getCellByColId(e,n){let r=d(this,t.tableMain),i=r.getColIds(),a=i.indexOf(e),o=this.children.iterator(),s=null;for(;s=o();){if(s.colId===e)return s;let t=i.indexOf(s.colId);if(t<a&&t+s.colspan>a)return s}return this[n]&&this[n].statics.blotName===t.tableRow?this[n].getCellByColId(e,n):null}insertCell(e,n){let r=[],i=this.children.iterator(),a=0,o;for(;(o=i())&&(a+=o.colspan,!(a>e));)if(o.rowspan!==1)for(let e=0;e<o.rowspan-1;e++)r[e]=(r[e]||0)+o.colspan;if(o&&a-o.colspan<e){let e=o.getCellInner();e.colspan+=1,o.rowspan!==1&&(r.skipRowNum=o.rowspan-1)}else{let e=this.scroll.create(t.tableCell,n),r=this.scroll.create(t.tableCellInner,n),i=this.scroll.create(`block`);i.appendChild(this.scroll.create(`break`)),r.appendChild(i),e.appendChild(r),this.insertBefore(e,o)}return r}getCellByColumIndex(e){let t=[],n=null,r=0;if(e<0)return[n,r,t];let i=this.children.iterator();for(;n=i();){if(r+=n.colspan,n.rowspan!==1)for(let e=0;e<n.rowspan-1;e++)t[e]=(t[e]||0)+n.colspan;if(r>e)break}return[n,r,t]}removeCell(e){if(e<0)return[];let n=this.getCellByColumIndex(e),[r,i]=n,a=n[2];if(!r)return a;if(i-r.colspan<e||r.colspan>1){let[n]=r.descendants(V);if(r.colspan!==1&&e===i-r.colspan){let e=d(this,t.tableMain),r=e.getColIds();n.colId=r[r.indexOf(n.colId)+1]}r.rowspan!==1&&(a.skipRowNum=r.rowspan-1),--n.colspan}else r.remove();return a}foreachCellInner(e){let t=this.children.iterator(),n=0,r;for(;r=t();){let[t]=r.descendants(V);if(e(t,n++))break}}checkMerge(){let e=this.next;return e!==null&&e.statics.blotName===this.statics.blotName&&e.rowId===this.rowId}optimize(e){let n=this.parent,{tableId:r}=this;n!==null&&n.statics.blotName!==t.tableBody&&this.wrap(t.tableBody,r),this.statics.requiredContainer&&!(this.parent instanceof this.statics.requiredContainer)&&this.wrap(this.statics.requiredContainer.blotName),this.enforceAllowedChildren(),this.children.length>0&&this.next!=null&&this.checkMerge()&&(this.next.moveChildren(this),this.next.remove())}},U=class extends z{static blotName=t.tableBody;static tagName=`tbody`;static create(e){let t=super.create();return t.dataset.tableId=e,t}get tableId(){return this.domNode.dataset.tableId}insertRow(e){let n=d(this,t.tableMain);if(!n)return;let r=n.getColIds(),i=this.descendants(H),a=new Set(r),o=0;for(let t of i){if(o===e)break;t.foreachCellInner(t=>{if(o+t.rowspan>e&&(t.rowspan+=1,a.delete(t.colId),t.colspan!==1)){let e=r.indexOf(t.colId);for(let n=0;n<t.colspan-1;n++)a.delete(r[e+n+1])}}),o+=1}let s=n.tableId,c=R(),l=this.scroll.create(t.tableRow,{tableId:s,rowId:c});for(let e of a){let n=this.scroll.create(`break`),r=n.wrap(`block`),i=r.wrap(t.tableCellInner,{tableId:s,rowId:c,colId:e,rowspan:1,colspan:1}),a=i.wrap(t.tableCell,{tableId:s,rowId:c,colId:e,rowspan:1,colspan:1});l.appendChild(a)}this.insertBefore(l,i[e]||null)}checkMerge(){let e=this.next;return e!==null&&e.statics.blotName===this.statics.blotName&&e.tableId===this.tableId}optimize(e){let n=this.parent;if(n!==null&&n.statics.blotName!==t.tableMain){let{tableId:e}=this;this.wrap(t.tableMain,{tableId:e})}super.optimize(e)}};const nn=e.import(`parchment`),rn=e.import(`blots/block`),an=e.import(`blots/container`);var on=class extends rn{replaceWith(e,n){let r=w(e)?this.scroll.create(e,n):e;if(r instanceof nn.ParentBlot)if(r.statics.blotName===t.tableCellInner){try{let e=d(this,t.tableCellInner),n=e.formats(),i=r.formats(),a=Object.keys(n);if(a.every(e=>JSON.stringify(n[e])===JSON.stringify(i[e])))return e}catch{}let e=this.parent;if(e.statics.blotName===t.tableCellInner){if(e?.insertBefore(r,this.prev?null:this.next),e.statics.blotName===t.tableCellInner){let e=this;for(;e;){let t=e.next;r.appendChild(e),e=t}}else r.appendChild(this);if(e&&e.length()===0){e.remove(),e.parent.statics.blotName===t.tableCell&&e.parent.length()===0&&e.parent.remove();let n=e.parent.parent;n.statics.blotName===t.tableRow&&n.children.length===0&&n.remove()}}else e instanceof an?e.parent.insertBefore(r,e):e?.insertBefore(r,this.next),r.appendChild(this);return r}else this.moveChildren(r);return this.parent!=null&&(this.parent.insertBefore(r,this.next),this.remove()),this.attributes.copy(r),r}format(e,n){if(e===t.tableCellInner&&this.parent.statics.blotName===e&&!n)try{let e=d(this,t.tableCellInner);e.unwrap()}catch{console.error(`unwrap TableCellInner error`)}else super.format(e,n)}};const sn=e.import(`blots/block/embed`);var cn=class extends sn{delta(){let e=super.delta(),n=ln(this);return n[t.tableCellInner]&&e.insert(`
|
|
2
2
|
`,{[t.tableCellInner]:n[t.tableCellInner]}),e}length(){let e=ln(this);return e[t.tableCellInner]&&(!this.next||this.next.length()<=1)?super.length()+1:super.length()}};function ln(e,t={},n=!0){return e==null||(`formats`in e&&typeof e.formats==`function`&&(t={...t,...e.formats()},n&&delete t[`code-token`]),e.parent==null||e.parent.statics.blotName===`scroll`||e.parent.statics.scope!==e.statics.scope)?t:ln(e.parent,t,n)}const un=e.import(`parchment`),dn=e.import(`blots/scroll`);var fn=class extends dn{enable(n=!0){let r=e.import(`formats/${t.tableCellInner}`),i=this.domNode.querySelectorAll(`.${r.className}`);for(let e of Array.from(i))e.setAttribute(`contenteditable`,String(!!n));let a=e.import(`formats/${t.tableCaption}`),o=this.domNode.querySelectorAll(`.${a.className}`);for(let e of Array.from(o))e.setAttribute(`contenteditable`,String(!!n));super.enable(n)}createBlock(e,n){let r,i={};if(e[t.tableCellInner])r=t.tableCellInner;else for(let[t,n]of Object.entries(e)){let e=this.query(t,un.Scope.BLOCK&un.Scope.BLOT)!=null;e?r=t:i[t]=n}r===t.tableCellInner&&(i={...e},delete i[r]);let a=this.create(r||this.statics.defaultChild.blotName,r?e[r]:void 0);this.insertBefore(a,n||void 0);let o=a.length();a instanceof V&&o===0&&(o+=1);for(let[e,t]of Object.entries(i))a.formatAt(0,o,e,t);return a}},pn=`<svg xmlns="http://www.w3.org/2000/svg" width="1em" height="1em" viewBox="0 0 24 24">\r
|
|
3
3
|
<!-- Icon from Tabler Icons by Paweł Kuna - https://github.com/tabler/tabler-icons/blob/master/LICENSE -->\r
|
|
4
4
|
<path\r
|
|
@@ -117,11 +117,11 @@ import e from"quill";const t={container:`table-up-container`,tableCaption:`table
|
|
|
117
117
|
<!-- Icon from TDesign Icons by TDesign - https://github.com/Tencent/tdesign-icons/blob/main/LICENSE -->
|
|
118
118
|
<path fill="currentColor" d="M21 10v12h-2V12H5v10H3V10zm0-8v6H3V2zm-2 2H5v2h14z" />
|
|
119
119
|
</svg>
|
|
120
|
-
`;const Vn=`color-selector`,X={Break:{name:`break`},CopyCell:{name:`CopyCell`,tip:`Copy cell`,icon:kn,handle:(e,t)=>{let n=e.getTextByCell(t),r=e.getHTMLByCell(t),i=new ClipboardItem({"text/plain":new Blob([n],{type:`text/plain`}),"text/html":new Blob([r],{type:`text/html`})});navigator.clipboard.write([i]),e.hideTableTools()}},CutCell:{name:`CutCell`,tip:`Cut cell`,icon:An,handle:(e,t)=>{let n=e.getTextByCell(t),r=e.getHTMLByCell(t,!0),i=new ClipboardItem({"text/plain":new Blob([n],{type:`text/plain`}),"text/html":new Blob([r],{type:`text/html`})});navigator.clipboard.write([i]),e.hideTableTools()}},InsertTop:{name:`InsertTop`,icon:Pn,tip:`Insert row above`,handle:(e,t)=>{e.appendRow(t,!1),e.hideTableTools()}},InsertRight:{name:`InsertRight`,icon:Nn,tip:`Insert column right`,handle:(e,t)=>{e.appendCol(t,!0),e.hideTableTools()}},InsertBottom:{name:`InsertBottom`,icon:jn,tip:`Insert row below`,handle:(e,t)=>{e.appendRow(t,!0),e.hideTableTools()}},InsertLeft:{name:`InsertLeft`,icon:Mn,tip:`Insert column Left`,handle:(e,t)=>{e.appendCol(t,!1),e.hideTableTools()}},MergeCell:{name:`MergeCell`,icon:Fn,tip:`Merge Cell`,handle:(e,t)=>{e.mergeCells(t),e.hideTableTools()}},SplitCell:{name:`SplitCell`,icon:zn,tip:`Split Cell`,handle:(e,t)=>{e.splitCell(t),e.hideTableTools()}},DeleteRow:{name:`DeleteRow`,icon:Ln,tip:`Delete Row`,handle:(e,t)=>{e.removeRow(t),e.hideTableTools()}},DeleteColumn:{name:`DeleteColumn`,icon:In,tip:`Delete Column`,handle:(e,t)=>{e.removeCol(t),e.hideTableTools()}},DeleteTable:{name:`DeleteTable`,icon:Rn,tip:`Delete table`,handle:(e,t)=>{e.deleteTable(t)}},BackgroundColor:{name:`BackgroundColor`,icon:Dn,isColorChoose:!0,tip:`Set background color`,key:`background-color`,handle:(e,t,n)=>{e.setCellAttrs(t,`background-color`,n,!0)}},BorderColor:{name:`BorderColor`,icon:On,isColorChoose:!0,tip:`Set border color`,key:`border-color`,handle:(e,t,n)=>{e.setCellAttrs(t,`border-color`,n,!0)}},SwitchWidth:{name:`SwitchWidth`,icon:En,tip:`Switch table width`,handle:t=>{if(!t.table)return;let n=e.find(t.table);n&&(n.full?n.cancelFull():n.setFull())}},InsertCaption:{name:`InsertCaption`,icon:Bn,tip:`Insert table caption`,handle(n){if(!n.table)return;let r=e.find(n.table);if(!r)return;let i=n.quill.scroll.create(`text`,`Table Caption`).wrap(t.tableCaption,{tableId:r.tableId});r.insertBefore(i,r.children.head)}}},Hn=10,Un=u(`color-map`),Z={selectWrapper:Un.b(),used:Un.bm(`used`),item:Un.be(`item`),btn:Un.be(`btn`),map:Un.be(`content`),mapRow:Un.be(`content-row`)};var Wn=class{usedColors=new Set;options;menu=null;isMenuDisplay=!1;isColorPicking=!1;updateUsedColor;tooltipItem=[];activeTooltip=null;bem=u(`menu`);colorItemClass=`color-${R()}`;colorChooseTooltipOption={direction:`top`};constructor(t,n,r){this.tableModule=t,this.quill=n,this.options=this.resolveOptions(r);try{let e=localStorage.getItem(this.options.localstorageKey)||`[]`,t=JSON.parse(e);C(t)||(t=[]),t.slice(-1*Hn).map(e=>this.usedColors.add(e))}catch{}this.updateUsedColor=Yt(e=>{if(!e)return;if(this.usedColors.add(e),this.usedColors.size>Hn){let e=Array.from(this.usedColors).slice(-1*Hn);this.usedColors.clear(),e.map(e=>this.usedColors.add(e))}localStorage.setItem(this.options.localstorageKey,JSON.stringify(Array.from(this.usedColors)));let t=Array.from(document.querySelectorAll(`.${this.colorItemClass}.${Z.used}`));for(let n of t){let t=document.createElement(`div`);t.classList.add(Z.item),t.style.backgroundColor=String(e);let r=Array.from(n.querySelectorAll(`.${Z.item}[style*="background-color: ${t.style.backgroundColor}"]`));r.length<=0&&n.appendChild(t);let i=Array.from(n.querySelectorAll(`.${Z.item}`)).slice(0,-1*Hn);for(let e of i)e.remove()}},1e3),this.quill.on(e.events.TEXT_CHANGE,this.updateWhenTextChange)}updateWhenTextChange=()=>{this.isMenuDisplay&&this.update()};resolveOptions(e){let t=Object.assign({tipText:!0,tools:[X.InsertTop,X.InsertRight,X.InsertBottom,X.InsertLeft,X.Break,X.MergeCell,X.SplitCell,X.Break,X.DeleteRow,X.DeleteColumn,X.DeleteTable,X.Break,X.BackgroundColor,X.BorderColor],localstorageKey:`__table-bg-used-color`,defaultColorMap:a},e);return t}buildTools(){let e=document.createElement(`div`);e.classList.add(this.bem.b()),Object.assign(e.style,{display:`flex`});for(let t of this.options.tools){let{name:n,icon:r,handle:i,isColorChoose:a,key:o,tip:s=``}=t,c=document.createElement(`span`);if(c.classList.add(this.bem.be(`item`)),n===`break`)c.classList.add(this.bem.is(`break`));else{let e=document.createElement(`i`);if(e.classList.add(`icon`),S(r)?e.appendChild(r(this.tableModule)):e.innerHTML=r,c.appendChild(e),a&&o){let e=this.createColorChoose(c,{name:n,icon:r,handle:i,isColorChoose:a,key:o,tip:s});this.tooltipItem.push(e),c.classList.add(Vn)}else S(i)&&c.addEventListener(`click`,e=>{this.quill.focus(),i(this.tableModule,this.getSelectedTds(),e)},!1);let t=this.tableModule.options.texts[n]||s;this.options.tipText&&t&&s&&this.createTipText(c,t)}e.appendChild(c)}return e}createColorChoose(e,{handle:t,key:n}){let r=document.createElement(`div`);if(r.classList.add(Z.selectWrapper),this.options.defaultColorMap.length>0){let e=document.createElement(`div`);e.classList.add(Z.map);for(let t of this.options.defaultColorMap){let n=document.createElement(`div`);n.classList.add(Z.mapRow);for(let e of t){let t=document.createElement(`div`);t.classList.add(Z.item),t.style.backgroundColor=e,n.appendChild(t)}e.appendChild(n)}r.appendChild(e)}let i=document.createElement(`div`);i.classList.add(Z.mapRow),Object.assign(i.style,{marginTop:`4px`});let a=document.createElement(`div`);a.classList.add(Z.btn,`transparent`),a.textContent=this.tableModule.options.texts.transparent,a.addEventListener(`click`,()=>{t(this.tableModule,this.getSelectedTds(),`transparent`)});let o=document.createElement(`div`);o.classList.add(Z.btn,`clear`),o.textContent=this.tableModule.options.texts.clear,o.addEventListener(`click`,()=>{t(this.tableModule,this.getSelectedTds(),null)});let s=document.createElement(`div`);s.classList.add(Z.btn,`custom`),s.textContent=this.tableModule.options.texts.custom;let c=oe({onChange:e=>{t(this.tableModule,this.getSelectedTds(),e),this.updateUsedColor(e)}}),{hide:l,destroy:u}=Lt(s,{direction:`right`,type:`click`,content:c,container:s});i.appendChild(a),i.appendChild(o),i.appendChild(s),r.appendChild(i);let d=document.createElement(`div`);d.classList.add(Z.used,this.colorItemClass);for(let e of this.usedColors){let t=document.createElement(`div`);t.classList.add(Z.item),t.style.backgroundColor=e,d.appendChild(t)}r.appendChild(d),r.addEventListener(`click`,e=>{e.stopPropagation(),l();let t=e.target,r=t.style.backgroundColor,i=this.getSelectedTds();if(t&&r&&i.length>0){if(this.tableModule.setCellAttrs(i,n,r,!0),!t.closest(`.${Z.item}`))return;this.updateUsedColor(r)}});let f=Lt(e,{type:`click`,content:r,onOpen:()=>(this.isMenuDisplay&&this.tableModule.tableSelection&&this.tableModule.tableSelection.hideDisplay(),this.setActiveTooltip(f),!1),onClose:()=>{this.isMenuDisplay&&this.tableModule.tableSelection&&(this.tableModule.tableSelection.updateWithSelectedTds(),this.tableModule.tableSelection.showDisplay());let e=r.contains(c);return e&&l(),this.activeTooltip===f&&(this.activeTooltip=null),!1},onDestroy:()=>{u(),this.activeTooltip===f&&(this.activeTooltip=null)},...this.colorChooseTooltipOption});return f.isColorPick=!0,f}setActiveTooltip(e){this.activeTooltip&&this.activeTooltip!==e&&this.activeTooltip.hide(!0),this.activeTooltip=e}getSelectedTds(){return this.tableModule.tableSelection?.selectedTds||[]}createTipText(e,t){let n=Lt(e,{msg:t});n&&this.tooltipItem.push(n)}show(){!this.menu||!this.tableModule.tableSelection||!this.tableModule.tableSelection.boundary||(Object.assign(this.menu.style,{display:`flex`}),this.isMenuDisplay=!0,this.update())}update(){}hide(){this.menu&&Object.assign(this.menu.style,{display:`none`});for(let e of this.tooltipItem)e.hide(!0);this.isMenuDisplay=!1}destroy(){this.quill.off(e.events.TEXT_CHANGE,this.updateWhenTextChange),this.activeTooltip=null;for(let e of this.tooltipItem)e.destroy();this.menu&&(this.hide(),this.menu.remove(),this.menu=null)}},Gn=class extends Wn{colorChooseTooltipOption={direction:`right`};constructor(e,t,n){super(e,t,n),this.tableModule=e,this.quill=t,this.quill.root.addEventListener(`contextmenu`,this.listenContextmenu)}listenContextmenu=e=>{e.preventDefault();let t=e.composedPath();if(!t||t.length<=0)return;let n=t.find(e=>e.tagName&&e.tagName.toUpperCase()===`TABLE`&&e.classList.contains(`ql-table`));n&&this.tableModule.tableSelection?.selectedTds?.length?(this.menu||=this.buildTools(),Object.assign(this.menu.style,{display:`flex`}),this.isMenuDisplay=!0,this.update({x:e.clientX,y:e.clientY}),document.addEventListener(`click`,()=>{this.hide()},{once:!0})):this.hide()};buildTools(){let e=super.buildTools();e.classList.add(this.bem.is(`contextmenu`));let t=e.getElementsByClassName(Vn);for(let e of Array.from(t))e.addEventListener(`click`,e=>e.stopPropagation());return document.body.appendChild(e),e}createTipText(e,t){let n=document.createElement(`span`);n.textContent=t,e.appendChild(n)}show(){}update(e){if(!this.isMenuDisplay||!this.menu||!this.tableModule.tableSelection||!this.tableModule.tableSelection.isDisplaySelection||!e)return;super.update();let t={display:`flex`,left:0,top:0},{x:n,y:r}=e;t.left=n,t.top=r,Object.assign(this.menu.style,{...t,left:`${t.left+window.scrollX}px`,top:`${t.top+window.scrollY}px`});let i=this.menu.getBoundingClientRect(),{left:a,top:o}=Vt(i);Object.assign(this.menu.style,{left:`${a+window.scrollX}px`,top:`${o+window.scrollY}px`})}destroy(){this.quill.root.removeEventListener(`contextmenu`,this.listenContextmenu),super.destroy()}},Kn=class extends Wn{constructor(e,t,n){super(e,t,n),this.tableModule=e,this.quill=t,this.menu=this.buildTools(),this.tableModule.addContainer(this.menu),this.show(),this.update()}update(){!this.isMenuDisplay||!this.menu||!this.tableModule.tableSelection||!this.tableModule.tableSelection.isDisplaySelection||(super.update(),Nt(this.tableModule.tableSelection.cellSelect,this.menu,{placement:`bottom`,middleware:[jt(),At({limiter:Mt()}),kt(20)]}).then(({x:e,y:t})=>{Object.assign(this.menu.style,{left:`${e}px`,top:`${t}px`})}))}};const Q=e=>!e.full&&e.align===`right`;var qn=class{colIndex=-1;tableMain;dragging=!1;dragColBreak=null;handleColMouseUpFunc=this.handleColMouseUp.bind(this);handleColMouseMoveFunc=this.handleColMouseMove.bind(this);handleColMouseDownFunc=this.handleColMouseDown.bind(this);rowIndex=-1;dragRowBreak=null;handleRowMouseUpFunc=this.handleRowMouseUp.bind(this);handleRowMouseMoveFunc=this.handleRowMouseMove.bind(this);handleRowMouseDownFunc=this.handleRowMouseDown.bind(this);dragBEM=u(`drag-line`);constructor(e,t){this.tableModule=e,this.quill=t}findCurrentColIndex(e){return-1}colWidthChange(e,t,n){}async createConfirmDialog({message:e,confirm:t,cancel:n}){return new Promise(r=>{let i=document.createElement(`div`);Object.assign(i.style,{padding:`8px 12px`,fontSize:`14px`,lineHeight:`1.5`});let a=document.createElement(`p`);a.textContent=e;let o=document.createElement(`div`);Object.assign(o.style,{display:`flex`,justifyContent:`flex-end`,gap:`6px`});let s=ae({content:n}),c=ae({type:`confirm`,content:t});o.appendChild(s),o.appendChild(c),i.appendChild(a),i.appendChild(o);let{close:l}=ce({child:i});s.addEventListener(`click`,()=>{r(!1),l()}),c.addEventListener(`click`,()=>{r(!0),l()})})}async handleColMouseUp(){if(!this.dragColBreak||!this.tableMain||this.colIndex===-1)return;let e=this.tableMain.getCols(),t=Number.parseInt(this.dragColBreak.dataset.w||`0`),i=this.tableMain.full,a=!1,o=[];if(i){let r=this.tableMain.domNode.getBoundingClientRect().width,i=t/r*100,s=e[this.colIndex].width;if(i<s){if(i=Math.max(n.colMinWidthPre,i),e[this.colIndex+1]||e[this.colIndex-1]){let t=e[this.colIndex+1]?this.colIndex+1:this.colIndex-1;o.push({index:t,width:e[t].width+s-i})}else i=100;a=!0,o.push({index:this.colIndex,width:i})}else if(e[this.colIndex+1]){let t=s+e[this.colIndex+1].width;i=Math.min(t-n.colMinWidthPre,i),a=!0,o.push({index:this.colIndex,width:i},{index:this.colIndex+1,width:t-i})}}else this.tableMain.domNode.style.width=`${Number.parseFloat(this.tableMain.domNode.style.width)-e[this.colIndex].domNode.getBoundingClientRect().width+t}px`,a=!0,o.push({index:this.colIndex,width:t});if(document.body.removeChild(this.dragColBreak),this.dragColBreak=null,document.removeEventListener(`mouseup`,this.handleColMouseUpFunc),document.removeEventListener(`mousemove`,this.handleColMouseMoveFunc),this.dragging=!1,a){let t=this.tableMain.domNode.getBoundingClientRect().width;if(i){let n=0,r=new Set(o.map(({index:e,width:t})=>(n+=t,e)));for(let[t,i]of e.entries()){if(r.has(t))continue;n+=i.width}if(n>100){if(!await this.createConfirmDialog({message:this.tableModule.options.texts.perWidthInsufficient,confirm:this.tableModule.options.texts.confirmText,cancel:this.tableModule.options.texts.cancelText}))return;this.tableMain.cancelFull(),i=!1;for(let[e,n]of o.entries()){let{width:r,index:i}=n;o[e]={index:i,width:r/100*t}}}}for(let{index:n,width:r}of o)e[n].width=`${Math.round(r)}${i?`%`:`px`}`,this.colWidthChange(n,{px:Math.round(r/100*t),pre:Math.round(r)},i)}this.quill.emitter.emit(r.AFTER_TABLE_RESIZE)}getColumnRect(e){if(!this.tableMain)return null;let t=this.tableMain.getCols();if(e>=t.length)return null;let n=t[0].domNode.getBoundingClientRect().left;for(let r=0;r<e;r++){let e=t[r].domNode.getBoundingClientRect();n+=e.width}let r=t[e],i=r.domNode.getBoundingClientRect().width;return{left:n,right:n+i,width:i}}handleColMouseMove(e){if(e.preventDefault(),!this.dragColBreak||!this.tableMain||this.colIndex===-1)return;let t=this.tableMain.getCols(),r=this.getColumnRect(this.colIndex),i=this.tableMain.domNode.getBoundingClientRect(),a=e.clientX;if(this.tableMain.full){let e=n.colMinWidthPre/100*i.width,o=i.right;a>r.right&&t[this.colIndex+1]&&(o=Math.max(this.getColumnRect(this.colIndex+1).right-e,r.left+e));let s=r.left+e;a=Math.min(Math.max(a,s),o)}else Q(this.tableMain)?r.right-a<n.colMinWidthPx&&(a=r.right-n.colMinWidthPx):a-r.left<n.colMinWidthPx&&(a=r.left+n.colMinWidthPx);let o=a-r.left;return Q(this.tableMain)&&(o=r.right-a),this.dragColBreak.style.left=`${a}px`,this.dragColBreak.dataset.w=String(o),{left:a,width:o}}handleColMouseDown(e){if(e.button!==0||(e.preventDefault(),!this.tableMain))return;let{rect:t,body:n}=yn(this.tableMain);if(!n||!t)return;let r=this.tableMain.getCols();if(this.colIndex=this.findCurrentColIndex(e),this.colIndex===-1)return;let i=r[this.colIndex].width,a=this.tableMain.full?i/100*t.width:i;document.addEventListener(`mouseup`,this.handleColMouseUpFunc),document.addEventListener(`mousemove`,this.handleColMouseMoveFunc),this.dragging=!0;let o=document.createElement(`div`);o.classList.add(this.dragBEM.b()),o.classList.add(this.dragBEM.is(`col`)),o.dataset.w=String(a);let s={top:t.y,left:e.clientX,height:t.height};Object.assign(o.style,{top:`${s.top}px`,left:`${s.left}px`,height:`${s.height}px`});let c=document.body;return c.appendChild(o),this.dragColBreak&&c.removeChild(this.dragColBreak),this.dragColBreak=o,s}findCurrentRowIndex(e){return-1}rowHeightChange(e,t){}handleRowMouseUp(){if(!this.tableMain||!this.dragRowBreak||this.rowIndex===-1)return;let e=Number.parseInt(this.dragRowBreak.dataset.h||`0`),t=this.tableMain.getRows();t[this.rowIndex].setHeight(`${e}px`),this.rowHeightChange(this.rowIndex,e),document.body.removeChild(this.dragRowBreak),this.dragRowBreak=null,document.removeEventListener(`mouseup`,this.handleRowMouseUpFunc),document.removeEventListener(`mousemove`,this.handleRowMouseMoveFunc),this.dragging=!1,this.quill.emitter.emit(r.AFTER_TABLE_RESIZE)}handleRowMouseMove(e){if(!this.tableMain||!this.dragRowBreak||this.rowIndex===-1)return;e.preventDefault();let t=this.tableMain.getRows(),r=t[this.rowIndex].domNode.getBoundingClientRect(),i=e.clientY;return i-r.y<n.rowMinHeightPx&&(i=r.y+n.rowMinHeightPx),this.dragRowBreak.style.top=`${i}px`,this.dragRowBreak.dataset.h=String(i-r.y),{top:i,height:i-r.y}}handleRowMouseDown(e){if(e.button!==0||(e.preventDefault(),!this.tableMain)||(this.rowIndex=this.findCurrentRowIndex(e),this.rowIndex===-1))return;this.dragging=!0,document.addEventListener(`mouseup`,this.handleRowMouseUpFunc),document.addEventListener(`mousemove`,this.handleRowMouseMoveFunc);let t=this.tableMain.getRows(),n=t[this.rowIndex].domNode.getBoundingClientRect().height,r=this.tableMain.domNode.getBoundingClientRect(),i=document.createElement(`div`);i.classList.add(this.dragBEM.b()),i.classList.add(this.dragBEM.is(`row`)),i.dataset.h=String(n);let a={top:e.clientY,left:r.x,width:r.width};Object.assign(i.style,{top:`${a.top}px`,left:`${a.left}px`,width:`${a.width}px`});let o=document.body;return o.appendChild(i),this.dragRowBreak&&o.removeChild(this.dragRowBreak),this.dragRowBreak=i,a}update(){}destroy(){}},Jn=class extends qn{root;tableMain;tableWrapper;resizeObserver;tableCols=[];tableRows=[];rowHeadWrapper=null;colHeadWrapper=null;corner=null;scrollHandler=[];lastHeaderSelect=null;size=12;bem=u(`resize-box`);constructor(t,n,r){super(t,r),this.tableModule=t,this.table=n,this.tableMain=e.find(this.table),this.tableMain&&(this.tableWrapper=this.tableMain.parent,this.tableWrapper&&(this.root=this.tableModule.addContainer(this.bem.b()),this.resizeObserver=new ResizeObserver(()=>{this.show()}),this.resizeObserver.observe(this.table),this.quill.on(e.events.TEXT_CHANGE,this.updateWhenTextChange)))}updateWhenTextChange=()=>{this.update()};handleResizerHeader(e,t,n){let{clientX:r,clientY:i}=n,a=this.table.getBoundingClientRect();if(this.tableModule.tableSelection){let o=this.tableModule.tableSelection;n.shiftKey||(this.lastHeaderSelect=null);let s=[{x:e?a.left:r,y:e?i:a.top},{x:e?a.right:r,y:e?i:a.bottom}];if(this.lastHeaderSelect){let t,n;if(this.lastHeaderSelect.isX){let e=Array.from(this.root.getElementsByClassName(this.bem.be(`row-header`))),r=e[this.lastHeaderSelect.index].getBoundingClientRect();t=Math.min(r.left,a.left),n=r.top+r.height/2}else{let e=Array.from(this.root.getElementsByClassName(this.bem.be(`col-header`))),r=e[this.lastHeaderSelect.index].getBoundingClientRect();t=r.left+r.width/2,n=Math.min(r.top,a.top)}this.lastHeaderSelect.isX===e?e?(s[0].y=Math.min(s[0].y,n),s[1].y=Math.max(s[1].y,n)):(s[0].x=Math.min(s[0].x,t),s[1].x=Math.max(s[1].x,t)):(s[1]={x:Math.max(s[0].x,t),y:Math.max(s[0].y,n)},s[0]={x:Math.min(s[0].x,t),y:Math.min(s[0].y,n)})}else this.lastHeaderSelect={isX:e,index:t};o.table=this.table,o.selectedTds=o.computeSelectedTds(...s),o.show()}}findCurrentColIndex(e){return Array.from(this.root.getElementsByClassName(this.bem.be(`col-separator`))).indexOf(e.target)}colWidthChange(e,t,n){let r=Array.from(this.root.getElementsByClassName(this.bem.be(`col-header`)));r[e].style.width=n?`${t.pre}%`:`${t.px}px`}handleColMouseDownFunc=function(e){let t=this.handleColMouseDown(e);if(t&&this.dragColBreak){let[e]=m(this.tableMain,W),n=e&&e.side===`top`?0:this.size;Object.assign(this.dragColBreak.style,{top:`${t.top-n}px`,left:`${t.left}px`,height:`${t.height+this.size}px`})}return t}.bind(this);bindColEvents(){let e=Array.from(this.root.getElementsByClassName(this.bem.be(`col-header`))),t=Array.from(this.root.getElementsByClassName(this.bem.be(`col-separator`)));L.call(this,this.tableWrapper.domNode,()=>{this.colHeadWrapper.scrollLeft=this.tableWrapper.domNode.scrollLeft});for(let[t,n]of e.entries())n.addEventListener(`click`,this.handleResizerHeader.bind(this,!1,t));for(let e of t)e.addEventListener(`mousedown`,this.handleColMouseDownFunc),e.addEventListener(`dragstart`,e=>e.preventDefault())}findCurrentRowIndex(e){return Array.from(this.root.getElementsByClassName(this.bem.be(`row-separator`))).indexOf(e.target)}rowHeightChange(e,t){let n=Array.from(this.root.getElementsByClassName(this.bem.be(`row-header`)));n[e].style.height=`${t}px`}handleRowMouseDownFunc=function(e){let t=this.handleRowMouseDown(e);return t&&this.dragRowBreak&&Object.assign(this.dragRowBreak.style,{top:`${t.top}px`,left:`${t.left-this.size}px`,width:`${t.width+this.size}px`}),t}.bind(this);bindRowEvents(){let e=Array.from(this.root.getElementsByClassName(this.bem.be(`row-header`))),t=Array.from(this.root.getElementsByClassName(this.bem.be(`row-separator`)));L.call(this,this.tableWrapper.domNode,()=>{this.rowHeadWrapper.scrollTop=this.tableWrapper.domNode.scrollTop});for(let[t,n]of e.entries())n.addEventListener(`click`,this.handleResizerHeader.bind(this,!0,t));for(let e of t)e.addEventListener(`mousedown`,this.handleRowMouseDownFunc),e.addEventListener(`dragstart`,e=>e.preventDefault())}update(){let{rect:e,body:t}=yn(this.tableMain);if(!t||!e)return;let n=this.tableWrapper.domNode.getBoundingClientRect(),r=this.quill.root.getBoundingClientRect();Object.assign(this.root.style,{top:`${Math.max(e.y,n.y)-r.y}px`,left:`${Math.max(e.x,n.x)-r.x}px`});let i=-1*this.size,a=-1*this.size;Q(this.tableMain)?(this.root.classList.add(this.bem.is(`align-right`)),i=Math.min(n.width,e.width),a=Math.min(n.width,e.width)):this.root.classList.remove(this.bem.is(`align-right`));let[o]=m(this.tableMain,W),s=!o||!(o&&o.side===`top`);s?this.root.classList.remove(this.bem.is(`caption-bottom`)):this.root.classList.add(this.bem.is(`caption-bottom`)),this.corner&&Object.assign(this.corner.style,{transform:`translateY(${-1*this.size}px) translateX(${i}px)`,top:`${s?0:e.height+this.size}px`}),this.rowHeadWrapper&&Object.assign(this.rowHeadWrapper.style,{transform:`translateX(${a}px)`}),this.colHeadWrapper&&Object.assign(this.colHeadWrapper.style,{top:`${s?0:e.height+this.size}px`})}show(){this.tableCols=this.tableMain.getCols(),this.tableRows=this.tableMain.getRows(),this.root.innerHTML=``;let{rect:e,body:t}=yn(this.tableMain);if(!t||!e)return;let n=this.tableWrapper.domNode.getBoundingClientRect();if(this.tableCols.length>0&&this.tableRows.length>0&&(this.corner=document.createElement(`div`),this.corner.classList.add(this.bem.be(`corner`)),Object.assign(this.corner.style,{width:`${this.size}px`,height:`${this.size}px`}),this.corner.addEventListener(`click`,()=>{if(this.tableModule.tableSelection){let e=this.tableMain.descendants(V),t=this.tableModule.tableSelection;t.selectedTds=e,t.show(),t.updateWithSelectedTds()}}),this.root.appendChild(this.corner)),this.tableCols.length>0){let t=``;for(let[,n]of this.tableCols.entries()){let r=n.domNode.getBoundingClientRect().width;t+=`<div class="${this.bem.be(`col-header`)}" style="width: ${r}px">
|
|
120
|
+
`;const Vn=`color-selector`,X={Break:{name:`break`},CopyCell:{name:`CopyCell`,tip:`Copy cell`,icon:kn,handle:(e,t)=>{let n=e.getTextByCell(t),r=e.getHTMLByCell(t),i=new ClipboardItem({"text/plain":new Blob([n],{type:`text/plain`}),"text/html":new Blob([r],{type:`text/html`})});navigator.clipboard.write([i]),e.hideTableTools()}},CutCell:{name:`CutCell`,tip:`Cut cell`,icon:An,handle:(e,t)=>{let n=e.getTextByCell(t),r=e.getHTMLByCell(t,!0),i=new ClipboardItem({"text/plain":new Blob([n],{type:`text/plain`}),"text/html":new Blob([r],{type:`text/html`})});navigator.clipboard.write([i]),e.hideTableTools()}},InsertTop:{name:`InsertTop`,icon:Pn,tip:`Insert row above`,handle:(e,t)=>{e.appendRow(t,!1),e.hideTableTools()}},InsertRight:{name:`InsertRight`,icon:Nn,tip:`Insert column right`,handle:(e,t)=>{e.appendCol(t,!0),e.hideTableTools()}},InsertBottom:{name:`InsertBottom`,icon:jn,tip:`Insert row below`,handle:(e,t)=>{e.appendRow(t,!0),e.hideTableTools()}},InsertLeft:{name:`InsertLeft`,icon:Mn,tip:`Insert column Left`,handle:(e,t)=>{e.appendCol(t,!1),e.hideTableTools()}},MergeCell:{name:`MergeCell`,icon:Fn,tip:`Merge Cell`,handle:(e,t)=>{e.mergeCells(t),e.hideTableTools()}},SplitCell:{name:`SplitCell`,icon:zn,tip:`Split Cell`,handle:(e,t)=>{e.splitCell(t),e.hideTableTools()}},DeleteRow:{name:`DeleteRow`,icon:Ln,tip:`Delete Row`,handle:(e,t)=>{e.removeRow(t),e.hideTableTools()}},DeleteColumn:{name:`DeleteColumn`,icon:In,tip:`Delete Column`,handle:(e,t)=>{e.removeCol(t),e.hideTableTools()}},DeleteTable:{name:`DeleteTable`,icon:Rn,tip:`Delete table`,handle:(e,t)=>{e.deleteTable(t)}},BackgroundColor:{name:`BackgroundColor`,icon:Dn,isColorChoose:!0,tip:`Set background color`,key:`background-color`,handle:(e,t,n)=>{e.setCellAttrs(t,`background-color`,n,!0)}},BorderColor:{name:`BorderColor`,icon:On,isColorChoose:!0,tip:`Set border color`,key:`border-color`,handle:(e,t,n)=>{e.setCellAttrs(t,`border-color`,n,!0)}},SwitchWidth:{name:`SwitchWidth`,icon:En,tip:`Switch table width`,handle:t=>{if(!t.table)return;let n=e.find(t.table);n&&(n.full?n.cancelFull():n.setFull())}},InsertCaption:{name:`InsertCaption`,icon:Bn,tip:`Insert table caption`,handle(n){if(!n.table)return;let r=e.find(n.table);if(!r)return;let i=n.quill.scroll.create(`text`,`Table Caption`).wrap(t.tableCaption,{tableId:r.tableId});r.insertBefore(i,r.children.head)}}},Hn=10,Un=u(`color-map`),Z={selectWrapper:Un.b(),used:Un.bm(`used`),item:Un.be(`item`),btn:Un.be(`btn`),map:Un.be(`content`),mapRow:Un.be(`content-row`)};var Wn=class{usedColors=new Set;options;menu=null;isMenuDisplay=!1;isColorPicking=!1;updateUsedColor;tooltipItem=[];activeTooltip=null;bem=u(`menu`);colorItemClass=`color-${R()}`;colorChooseTooltipOption={direction:`top`};constructor(t,n,r){this.tableModule=t,this.quill=n,this.options=this.resolveOptions(r);try{let e=localStorage.getItem(this.options.localstorageKey)||`[]`,t=JSON.parse(e);C(t)||(t=[]),t.slice(-1*Hn).map(e=>this.usedColors.add(e))}catch{}this.updateUsedColor=Yt(e=>{if(!e)return;if(this.usedColors.add(e),this.usedColors.size>Hn){let e=Array.from(this.usedColors).slice(-1*Hn);this.usedColors.clear(),e.map(e=>this.usedColors.add(e))}localStorage.setItem(this.options.localstorageKey,JSON.stringify(Array.from(this.usedColors)));let t=Array.from(document.querySelectorAll(`.${this.colorItemClass}.${Z.used}`));for(let n of t){let t=document.createElement(`div`);t.classList.add(Z.item),t.style.backgroundColor=String(e);let r=Array.from(n.querySelectorAll(`.${Z.item}[style*="background-color: ${t.style.backgroundColor}"]`));r.length<=0&&n.appendChild(t);let i=Array.from(n.querySelectorAll(`.${Z.item}`)).slice(0,-1*Hn);for(let e of i)e.remove()}},1e3),this.quill.on(e.events.TEXT_CHANGE,this.updateWhenTextChange)}updateWhenTextChange=()=>{this.isMenuDisplay&&this.update()};resolveOptions(e){let t=Object.assign({tipText:!0,tools:[X.InsertTop,X.InsertRight,X.InsertBottom,X.InsertLeft,X.Break,X.MergeCell,X.SplitCell,X.Break,X.DeleteRow,X.DeleteColumn,X.DeleteTable,X.Break,X.BackgroundColor,X.BorderColor],localstorageKey:`__table-bg-used-color`,defaultColorMap:a},e);return t}buildTools(){let e=document.createElement(`div`);e.classList.add(this.bem.b()),Object.assign(e.style,{display:`flex`});for(let t of this.options.tools){let{name:n,icon:r,handle:i,isColorChoose:a,key:o,tip:s=``}=t,c=document.createElement(`span`);if(c.classList.add(this.bem.be(`item`)),n===`break`)c.classList.add(this.bem.is(`break`));else{let e=document.createElement(`i`);if(e.classList.add(`icon`),S(r)?e.appendChild(r(this.tableModule)):e.innerHTML=r,c.appendChild(e),a&&o){let e=this.createColorChoose(c,{name:n,icon:r,handle:i,isColorChoose:a,key:o,tip:s});this.tooltipItem.push(e),c.classList.add(Vn)}else S(i)&&c.addEventListener(`click`,e=>{this.quill.focus(),i(this.tableModule,this.getSelectedTds(),e)},!1);let t=this.tableModule.options.texts[n]||s;this.options.tipText&&t&&s&&this.createTipText(c,t)}e.appendChild(c)}return e}createColorChoose(e,{handle:t,key:n}){let r=document.createElement(`div`);if(r.classList.add(Z.selectWrapper),this.options.defaultColorMap.length>0){let e=document.createElement(`div`);e.classList.add(Z.map);for(let t of this.options.defaultColorMap){let n=document.createElement(`div`);n.classList.add(Z.mapRow);for(let e of t){let t=document.createElement(`div`);t.classList.add(Z.item),t.style.backgroundColor=e,n.appendChild(t)}e.appendChild(n)}r.appendChild(e)}let i=document.createElement(`div`);i.classList.add(Z.mapRow),Object.assign(i.style,{marginTop:`4px`});let a=document.createElement(`div`);a.classList.add(Z.btn,`transparent`),a.textContent=this.tableModule.options.texts.transparent,a.addEventListener(`click`,()=>{t(this.tableModule,this.getSelectedTds(),`transparent`)});let o=document.createElement(`div`);o.classList.add(Z.btn,`clear`),o.textContent=this.tableModule.options.texts.clear,o.addEventListener(`click`,()=>{t(this.tableModule,this.getSelectedTds(),null)});let s=document.createElement(`div`);s.classList.add(Z.btn,`custom`),s.textContent=this.tableModule.options.texts.custom;let c=oe({onChange:e=>{t(this.tableModule,this.getSelectedTds(),e),this.updateUsedColor(e)}}),{hide:l,destroy:u}=Lt(s,{direction:`right`,type:`click`,content:c,container:s});i.appendChild(a),i.appendChild(o),i.appendChild(s),r.appendChild(i);let d=document.createElement(`div`);d.classList.add(Z.used,this.colorItemClass);for(let e of this.usedColors){let t=document.createElement(`div`);t.classList.add(Z.item),t.style.backgroundColor=e,d.appendChild(t)}r.appendChild(d),r.addEventListener(`click`,e=>{e.stopPropagation(),l();let t=e.target,r=t.style.backgroundColor,i=this.getSelectedTds();if(t&&r&&i.length>0){if(this.tableModule.setCellAttrs(i,n,r,!0),!t.closest(`.${Z.item}`))return;this.updateUsedColor(r)}});let f=Lt(e,{type:`click`,content:r,onOpen:()=>(this.isMenuDisplay&&this.tableModule.tableSelection&&this.tableModule.tableSelection.hideDisplay(),this.setActiveTooltip(f),!1),onClose:()=>{this.isMenuDisplay&&this.tableModule.tableSelection&&(this.tableModule.tableSelection.updateWithSelectedTds(),this.tableModule.tableSelection.showDisplay());let e=r.contains(c);return e&&l(),this.activeTooltip===f&&(this.activeTooltip=null),!1},onDestroy:()=>{u(),this.activeTooltip===f&&(this.activeTooltip=null)},...this.colorChooseTooltipOption});return f.isColorPick=!0,f}setActiveTooltip(e){this.activeTooltip&&this.activeTooltip!==e&&this.activeTooltip.hide(!0),this.activeTooltip=e}getSelectedTds(){return this.tableModule.tableSelection?.selectedTds||[]}createTipText(e,t){let n=Lt(e,{msg:t});n&&this.tooltipItem.push(n)}show(){!this.menu||!this.tableModule.tableSelection||!this.tableModule.tableSelection.boundary||(Object.assign(this.menu.style,{display:`flex`}),this.isMenuDisplay=!0,this.update())}update(){}hide(){this.menu&&Object.assign(this.menu.style,{display:`none`});for(let e of this.tooltipItem)e.hide(!0);this.isMenuDisplay=!1}destroy(){this.quill.off(e.events.TEXT_CHANGE,this.updateWhenTextChange),this.activeTooltip=null;for(let e of this.tooltipItem)e.destroy();this.menu&&(this.hide(),this.menu.remove(),this.menu=null)}},Gn=class extends Wn{colorChooseTooltipOption={direction:`right`};constructor(e,t,n){super(e,t,n),this.tableModule=e,this.quill=t,this.quill.root.addEventListener(`contextmenu`,this.listenContextmenu)}listenContextmenu=e=>{e.preventDefault();let t=e.composedPath();if(!t||t.length<=0)return;let n=t.find(e=>e.tagName&&e.tagName.toUpperCase()===`TABLE`&&e.classList.contains(`ql-table`));n&&this.tableModule.tableSelection?.selectedTds?.length?(this.menu||=this.buildTools(),Object.assign(this.menu.style,{display:`flex`}),this.isMenuDisplay=!0,this.update({x:e.clientX,y:e.clientY}),document.addEventListener(`click`,()=>{this.hide()},{once:!0})):this.hide()};buildTools(){let e=super.buildTools();e.classList.add(this.bem.is(`contextmenu`));let t=e.getElementsByClassName(Vn);for(let e of Array.from(t))e.addEventListener(`click`,e=>e.stopPropagation());return document.body.appendChild(e),e}createTipText(e,t){let n=document.createElement(`span`);n.textContent=t,e.appendChild(n)}show(){}update(e){if(!this.isMenuDisplay||!this.menu||!this.tableModule.tableSelection||!this.tableModule.tableSelection.isDisplaySelection||!e)return;super.update();let t={display:`flex`,left:0,top:0},{x:n,y:r}=e;t.left=n,t.top=r,Object.assign(this.menu.style,{...t,left:`${t.left+window.scrollX}px`,top:`${t.top+window.scrollY}px`});let i=this.menu.getBoundingClientRect(),{left:a,top:o}=Vt(i);Object.assign(this.menu.style,{left:`${a+window.scrollX}px`,top:`${o+window.scrollY}px`})}destroy(){this.quill.root.removeEventListener(`contextmenu`,this.listenContextmenu),super.destroy()}},Kn=class extends Wn{constructor(e,t,n){super(e,t,n),this.tableModule=e,this.quill=t,this.menu=this.buildTools(),this.tableModule.addContainer(this.menu),this.show(),this.update()}update(){!this.isMenuDisplay||!this.menu||!this.tableModule.tableSelection||!this.tableModule.tableSelection.isDisplaySelection||(super.update(),Nt(this.tableModule.tableSelection.cellSelect,this.menu,{placement:`bottom`,middleware:[jt(),At({limiter:Mt()}),kt(20)]}).then(({x:e,y:t})=>{Object.assign(this.menu.style,{left:`${e}px`,top:`${t}px`})}))}};const Q=e=>!e.full&&e.align===`right`;var qn=class{colIndex=-1;tableMain;dragging=!1;dragColBreak=null;handleColMouseUpFunc=this.handleColMouseUp.bind(this);handleColMouseMoveFunc=this.handleColMouseMove.bind(this);handleColMouseDownFunc=this.handleColMouseDown.bind(this);rowIndex=-1;dragRowBreak=null;handleRowMouseUpFunc=this.handleRowMouseUp.bind(this);handleRowMouseMoveFunc=this.handleRowMouseMove.bind(this);handleRowMouseDownFunc=this.handleRowMouseDown.bind(this);dragBEM=u(`drag-line`);constructor(e,t){this.tableModule=e,this.quill=t}findCurrentColIndex(e){return-1}colWidthChange(e,t,n){}async createConfirmDialog({message:e,confirm:t,cancel:n}){return new Promise(r=>{let i=document.createElement(`div`);Object.assign(i.style,{padding:`8px 12px`,fontSize:`14px`,lineHeight:`1.5`});let a=document.createElement(`p`);a.textContent=e;let o=document.createElement(`div`);Object.assign(o.style,{display:`flex`,justifyContent:`flex-end`,gap:`6px`});let s=ae({content:n}),c=ae({type:`confirm`,content:t});o.appendChild(s),o.appendChild(c),i.appendChild(a),i.appendChild(o);let{close:l}=ce({child:i});s.addEventListener(`click`,()=>{r(!1),l()}),c.addEventListener(`click`,()=>{r(!0),l()})})}async handleColMouseUp(){if(!this.dragColBreak||!this.tableMain||this.colIndex===-1)return;let e=this.tableMain.getCols(),t=Number.parseInt(this.dragColBreak.dataset.w||`0`),i=this.tableMain.full,a=!1,o=[];if(i){let r=this.tableMain.domNode.getBoundingClientRect().width,i=t/r*100,s=e[this.colIndex].width;if(i<s){if(i=Math.max(n.colMinWidthPre,i),e[this.colIndex+1]||e[this.colIndex-1]){let t=e[this.colIndex+1]?this.colIndex+1:this.colIndex-1;o.push({index:t,width:e[t].width+s-i})}else i=100;a=!0,o.push({index:this.colIndex,width:i})}else if(e[this.colIndex+1]){let t=s+e[this.colIndex+1].width;i=Math.min(t-n.colMinWidthPre,i),a=!0,o.push({index:this.colIndex,width:i},{index:this.colIndex+1,width:t-i})}}else this.tableMain.domNode.style.width=`${Number.parseFloat(this.tableMain.domNode.style.width)-e[this.colIndex].domNode.getBoundingClientRect().width+t}px`,a=!0,o.push({index:this.colIndex,width:t});if(document.body.removeChild(this.dragColBreak),this.dragColBreak=null,document.removeEventListener(`mouseup`,this.handleColMouseUpFunc),document.removeEventListener(`mousemove`,this.handleColMouseMoveFunc),this.dragging=!1,a){let t=this.tableMain.domNode.getBoundingClientRect().width;if(i){let n=0,r=new Set(o.map(({index:e,width:t})=>(n+=t,e)));for(let[t,i]of e.entries()){if(r.has(t))continue;n+=i.width}if(n>100){if(!await this.createConfirmDialog({message:this.tableModule.options.texts.perWidthInsufficient,confirm:this.tableModule.options.texts.confirmText,cancel:this.tableModule.options.texts.cancelText}))return;this.tableMain.cancelFull(),i=!1;for(let[e,n]of o.entries()){let{width:r,index:i}=n;o[e]={index:i,width:r/100*t}}}}for(let{index:n,width:r}of o)e[n].width=`${Math.round(r)}${i?`%`:`px`}`,this.colWidthChange(n,{px:Math.round(r/100*t),pre:Math.round(r)},i)}this.quill.emitter.emit(r.AFTER_TABLE_RESIZE)}getColumnRect(e){if(!this.tableMain)return null;let t=this.tableMain.getCols();if(e>=t.length)return null;let n=t[0].domNode.getBoundingClientRect().left;for(let r=0;r<e;r++){let e=t[r].domNode.getBoundingClientRect();n+=e.width}let r=t[e],i=r.domNode.getBoundingClientRect().width;return{left:n,right:n+i,width:i}}handleColMouseMove(e){if(e.preventDefault(),!this.dragColBreak||!this.tableMain||this.colIndex===-1)return;let t=this.tableMain.getCols(),r=this.getColumnRect(this.colIndex),i=this.tableMain.domNode.getBoundingClientRect(),a=e.clientX;if(this.tableMain.full){let e=n.colMinWidthPre/100*i.width,o=i.right;a>r.right&&t[this.colIndex+1]&&(o=Math.max(this.getColumnRect(this.colIndex+1).right-e,r.left+e));let s=r.left+e;a=Math.min(Math.max(a,s),o)}else Q(this.tableMain)?r.right-a<n.colMinWidthPx&&(a=r.right-n.colMinWidthPx):a-r.left<n.colMinWidthPx&&(a=r.left+n.colMinWidthPx);let o=a-r.left;return Q(this.tableMain)&&(o=r.right-a),this.dragColBreak.style.left=`${a}px`,this.dragColBreak.dataset.w=String(o),{left:a,width:o}}handleColMouseDown(e){if(e.button!==0||(e.preventDefault(),!this.tableMain))return;let{rect:t,body:n}=yn(this.tableMain);if(!n||!t)return;let r=this.tableMain.getCols();if(this.colIndex=this.findCurrentColIndex(e),this.colIndex===-1)return;let i=r[this.colIndex].width,a=this.tableMain.full?i/100*t.width:i;document.addEventListener(`mouseup`,this.handleColMouseUpFunc),document.addEventListener(`mousemove`,this.handleColMouseMoveFunc),this.dragging=!0;let o=document.createElement(`div`);o.classList.add(this.dragBEM.b(),this.dragBEM.is(`col`)),o.dataset.w=String(a);let s={top:t.y,left:e.clientX,height:t.height};Object.assign(o.style,{top:`${s.top}px`,left:`${s.left}px`,height:`${s.height}px`});let c=document.body;return c.appendChild(o),this.dragColBreak&&c.removeChild(this.dragColBreak),this.dragColBreak=o,s}findCurrentRowIndex(e){return-1}rowHeightChange(e,t){}handleRowMouseUp(){if(!this.tableMain||!this.dragRowBreak||this.rowIndex===-1)return;let e=Number.parseInt(this.dragRowBreak.dataset.h||`0`),t=this.tableMain.getRows();t[this.rowIndex].setHeight(`${e}px`),this.rowHeightChange(this.rowIndex,e),document.body.removeChild(this.dragRowBreak),this.dragRowBreak=null,document.removeEventListener(`mouseup`,this.handleRowMouseUpFunc),document.removeEventListener(`mousemove`,this.handleRowMouseMoveFunc),this.dragging=!1,this.quill.emitter.emit(r.AFTER_TABLE_RESIZE)}handleRowMouseMove(e){if(!this.tableMain||!this.dragRowBreak||this.rowIndex===-1)return;e.preventDefault();let t=this.tableMain.getRows(),r=t[this.rowIndex].domNode.getBoundingClientRect(),i=e.clientY;return i-r.y<n.rowMinHeightPx&&(i=r.y+n.rowMinHeightPx),this.dragRowBreak.style.top=`${i}px`,this.dragRowBreak.dataset.h=String(i-r.y),{top:i,height:i-r.y}}handleRowMouseDown(e){if(e.button!==0||(e.preventDefault(),!this.tableMain)||(this.rowIndex=this.findCurrentRowIndex(e),this.rowIndex===-1))return;this.dragging=!0,document.addEventListener(`mouseup`,this.handleRowMouseUpFunc),document.addEventListener(`mousemove`,this.handleRowMouseMoveFunc);let t=this.tableMain.getRows(),n=t[this.rowIndex].domNode.getBoundingClientRect().height,r=this.tableMain.domNode.getBoundingClientRect(),i=document.createElement(`div`);i.classList.add(this.dragBEM.b(),this.dragBEM.is(`row`)),i.dataset.h=String(n);let a={top:e.clientY,left:r.x,width:r.width};Object.assign(i.style,{top:`${a.top}px`,left:`${a.left}px`,width:`${a.width}px`});let o=document.body;return o.appendChild(i),this.dragRowBreak&&o.removeChild(this.dragRowBreak),this.dragRowBreak=i,a}update(){}destroy(){}},Jn=class extends qn{root;tableMain;tableWrapper;resizeObserver;tableCols=[];tableRows=[];rowHeadWrapper=null;colHeadWrapper=null;corner=null;scrollHandler=[];lastHeaderSelect=null;size=12;bem=u(`resize-box`);constructor(t,n,r){super(t,r),this.tableModule=t,this.table=n,this.tableMain=e.find(this.table),this.tableMain&&(this.tableWrapper=this.tableMain.parent,this.tableWrapper&&(this.root=this.tableModule.addContainer(this.bem.b()),this.resizeObserver=new ResizeObserver(()=>{this.show()}),this.resizeObserver.observe(this.table),this.quill.on(e.events.TEXT_CHANGE,this.updateWhenTextChange)))}updateWhenTextChange=()=>{this.update()};handleResizerHeader(e,t,n){let{clientX:r,clientY:i}=n,a=this.table.getBoundingClientRect();if(this.tableModule.tableSelection){let o=this.tableModule.tableSelection;n.shiftKey||(this.lastHeaderSelect=null);let s=[{x:e?a.left:r,y:e?i:a.top},{x:e?a.right:r,y:e?i:a.bottom}];if(this.lastHeaderSelect){let t,n;if(this.lastHeaderSelect.isX){let e=Array.from(this.root.getElementsByClassName(this.bem.be(`row-header`))),r=e[this.lastHeaderSelect.index].getBoundingClientRect();t=Math.min(r.left,a.left),n=r.top+r.height/2}else{let e=Array.from(this.root.getElementsByClassName(this.bem.be(`col-header`))),r=e[this.lastHeaderSelect.index].getBoundingClientRect();t=r.left+r.width/2,n=Math.min(r.top,a.top)}this.lastHeaderSelect.isX===e?e?(s[0].y=Math.min(s[0].y,n),s[1].y=Math.max(s[1].y,n)):(s[0].x=Math.min(s[0].x,t),s[1].x=Math.max(s[1].x,t)):(s[1]={x:Math.max(s[0].x,t),y:Math.max(s[0].y,n)},s[0]={x:Math.min(s[0].x,t),y:Math.min(s[0].y,n)})}else this.lastHeaderSelect={isX:e,index:t};o.table=this.table,o.selectedTds=o.computeSelectedTds(...s),o.show()}}findCurrentColIndex(e){return Array.from(this.root.getElementsByClassName(this.bem.be(`col-separator`))).indexOf(e.target)}colWidthChange(e,t,n){let r=Array.from(this.root.getElementsByClassName(this.bem.be(`col-header`)));r[e].style.width=n?`${t.pre}%`:`${t.px}px`}handleColMouseDownFunc=function(e){let t=this.handleColMouseDown(e);if(t&&this.dragColBreak){let[e]=m(this.tableMain,W),n=e&&e.side===`top`?0:this.size;Object.assign(this.dragColBreak.style,{top:`${t.top-n}px`,left:`${t.left}px`,height:`${t.height+this.size}px`})}return t}.bind(this);bindColEvents(){let e=Array.from(this.root.getElementsByClassName(this.bem.be(`col-header`))),t=Array.from(this.root.getElementsByClassName(this.bem.be(`col-separator`)));L.call(this,this.tableWrapper.domNode,()=>{this.colHeadWrapper.scrollLeft=this.tableWrapper.domNode.scrollLeft});for(let[t,n]of e.entries())n.addEventListener(`click`,this.handleResizerHeader.bind(this,!1,t));for(let e of t)e.addEventListener(`mousedown`,this.handleColMouseDownFunc),e.addEventListener(`dragstart`,e=>e.preventDefault())}findCurrentRowIndex(e){return Array.from(this.root.getElementsByClassName(this.bem.be(`row-separator`))).indexOf(e.target)}rowHeightChange(e,t){let n=Array.from(this.root.getElementsByClassName(this.bem.be(`row-header`)));n[e].style.height=`${t}px`}handleRowMouseDownFunc=function(e){let t=this.handleRowMouseDown(e);return t&&this.dragRowBreak&&Object.assign(this.dragRowBreak.style,{top:`${t.top}px`,left:`${t.left-this.size}px`,width:`${t.width+this.size}px`}),t}.bind(this);bindRowEvents(){let e=Array.from(this.root.getElementsByClassName(this.bem.be(`row-header`))),t=Array.from(this.root.getElementsByClassName(this.bem.be(`row-separator`)));L.call(this,this.tableWrapper.domNode,()=>{this.rowHeadWrapper.scrollTop=this.tableWrapper.domNode.scrollTop});for(let[t,n]of e.entries())n.addEventListener(`click`,this.handleResizerHeader.bind(this,!0,t));for(let e of t)e.addEventListener(`mousedown`,this.handleRowMouseDownFunc),e.addEventListener(`dragstart`,e=>e.preventDefault())}update(){let{rect:e,body:t}=yn(this.tableMain);if(!t||!e)return;let n=this.tableWrapper.domNode.getBoundingClientRect(),r=this.quill.root.getBoundingClientRect();Object.assign(this.root.style,{top:`${Math.max(e.y,n.y)-r.y}px`,left:`${Math.max(e.x,n.x)-r.x}px`});let i=-1*this.size,a=-1*this.size;Q(this.tableMain)?(this.root.classList.add(this.bem.is(`align-right`)),i=Math.min(n.width,e.width),a=Math.min(n.width,e.width)):this.root.classList.remove(this.bem.is(`align-right`));let[o]=m(this.tableMain,W),s=!o||!(o&&o.side===`top`);s?this.root.classList.remove(this.bem.is(`caption-bottom`)):this.root.classList.add(this.bem.is(`caption-bottom`)),this.corner&&Object.assign(this.corner.style,{transform:`translateY(${-1*this.size}px) translateX(${i}px)`,top:`${s?0:e.height+this.size}px`}),this.rowHeadWrapper&&Object.assign(this.rowHeadWrapper.style,{transform:`translateX(${a}px)`}),this.colHeadWrapper&&Object.assign(this.colHeadWrapper.style,{top:`${s?0:e.height+this.size}px`})}show(){this.tableCols=this.tableMain.getCols(),this.tableRows=this.tableMain.getRows(),this.root.innerHTML=``;let{rect:e,body:t}=yn(this.tableMain);if(!t||!e)return;let n=this.tableWrapper.domNode.getBoundingClientRect();if(this.tableCols.length>0&&this.tableRows.length>0&&(this.corner=document.createElement(`div`),this.corner.classList.add(this.bem.be(`corner`)),Object.assign(this.corner.style,{width:`${this.size}px`,height:`${this.size}px`}),this.corner.addEventListener(`click`,()=>{if(this.tableModule.tableSelection){let e=this.tableMain.descendants(V),t=this.tableModule.tableSelection;t.selectedTds=e,t.show(),t.updateWithSelectedTds()}}),this.root.appendChild(this.corner)),this.tableCols.length>0){let t=``;for(let[,n]of this.tableCols.entries()){let r=n.domNode.getBoundingClientRect().width;t+=`<div class="${this.bem.be(`col-header`)}" style="width: ${r}px">
|
|
121
121
|
<div class="${this.bem.be(`col-separator`)}" style="height: ${e.height+this.size-3}px"></div>
|
|
122
122
|
</div>`}let r=document.createElement(`div`);r.classList.add(this.bem.be(`col`));let i=document.createElement(`div`);i.classList.add(this.bem.be(`col-wrapper`)),Object.assign(r.style,{transform:`translateY(-${this.size}px)`,maxWidth:`${n.width}px`,height:`${this.size}px`}),Object.assign(i.style,{width:`${e.width}px`}),i.innerHTML=t,r.appendChild(i),this.root.appendChild(r),r.scrollLeft=this.tableWrapper.domNode.scrollLeft,this.colHeadWrapper=r,this.bindColEvents()}if(this.tableRows.length>0){let t=``;for(let[,n]of this.tableRows.entries()){let r=`${n.domNode.getBoundingClientRect().height}px`;t+=`<div class="${this.bem.be(`row-header`)}" style="height: ${Number.parseFloat(r)}px">
|
|
123
123
|
<div class="${this.bem.be(`row-separator`)}" style="width: ${e.width+this.size-3}px"></div>
|
|
124
|
-
</div>`}let r=document.createElement(`div`);r.classList.add(this.bem.be(`row`));let i=document.createElement(`div`);i.classList.add(this.bem.be(`row-wrapper`)),Object.assign(r.style,{transform:`translateX(-${this.size}px)`,width:`${this.size}px`,maxHeight:`${n.height}px`}),Object.assign(i.style,{height:`${e.height}px`}),i.innerHTML=t,r.appendChild(i),this.root.appendChild(r),r.scrollTop=this.tableWrapper.domNode.scrollTop,this.rowHeadWrapper=r,this.bindRowEvents()}this.update(),L.call(this,this.quill.root,()=>{this.update()})}hide(){this.root.classList.add(this.bem.is(`hidden`))}destroy(){this.hide(),Ut.call(this),this.resizeObserver.disconnect(),this.quill.off(e.events.TEXT_CHANGE,this.updateWhenTextChange);for(let[e,t]of this.scrollHandler)e.removeEventListener(`scroll`,t);this.root.remove()}},Yn=class extends qn{colResizer;rowResizer;currentTableCell;dragging=!1;curColIndex=-1;curRowIndex=-1;tableCellBlot;bem=u(`resize-line`);constructor(t,n,r){super(t,r),this.tableModule=t,this.table=n,this.colResizer=this.tableModule.addContainer(this.bem.be(`col`)),this.rowResizer=this.tableModule.addContainer(this.bem.be(`row`)),this.table.addEventListener(`mousemove`,this.mousemoveHandler),this.quill.on(e.events.TEXT_CHANGE,this.hideWhenTextChange)}mousemoveHandler=n=>{if(this.dragging||this.tableModule.tableSelection&&this.tableModule.tableSelection.dragging)return;let r=this.findTableCell(n);if(!r)return this.hide();let i=e.find(r);i&&this.currentTableCell!==r&&(this.show(),this.currentTableCell=r,this.tableCellBlot=i,this.tableMain=d(i,t.tableMain),this.tableMain.getCols().length>0&&this.updateColResizer(),this.updateRowResizer())};hideWhenTextChange=()=>{this.hide()};findTableCell(e){for(let t of e.composedPath()){if(t instanceof HTMLElement&&t.tagName===`TD`)return t;if(t===document.body)return null}return null}findCurrentColIndex(){return this.curColIndex+(this.tableCellBlot?.colspan||1)-1}handleColMouseUpFunc=async function(){await this.handleColMouseUp(),this.updateColResizer()}.bind(this);updateColResizer(){if(!this.tableMain||!this.tableCellBlot)return;let e=this.tableCellBlot;this.tableModule.toolBox.removeChild(this.colResizer),this.colResizer=this.tableModule.addContainer(this.bem.be(`col`));let[n]=f(e,[t.tableBody]),r=n.domNode.getBoundingClientRect(),i=e.domNode.getBoundingClientRect(),a=this.quill.root.getBoundingClientRect(),o=i.right-a.x;Q(this.tableMain)&&(o=i.left-a.x),Object.assign(this.colResizer.style,{top:`${r.y-a.y}px`,left:`${o}px`,height:`${r.height}px`});let s=this.tableMain.getCols();this.curColIndex=s.findIndex(t=>t.colId===e.colId),this.colResizer.addEventListener(`mousedown`,this.handleColMouseDownFunc),this.colResizer.addEventListener(`dragstart`,e=>{e.preventDefault()})}findCurrentRowIndex(){return this.curRowIndex}handleRowMouseUpFunc=function(){this.handleRowMouseUp(),this.updateRowResizer()}.bind(this);updateRowResizer(){if(!this.tableMain||!this.tableCellBlot)return;let e=this.tableCellBlot;this.tableModule.toolBox.removeChild(this.rowResizer),this.rowResizer=this.tableModule.addContainer(this.bem.be(`row`));let n=e.parent;if(!(n instanceof H))return;let[r]=f(e,[t.tableBody]),i=r.domNode.getBoundingClientRect(),a=e.domNode.getBoundingClientRect(),o=this.quill.root.getBoundingClientRect();Object.assign(this.rowResizer.style,{top:`${a.bottom-o.y}px`,left:`${i.x-o.x}px`,width:`${i.width}px`});let s=this.tableMain.getRows();this.curRowIndex=s.indexOf(n),this.rowResizer.addEventListener(`mousedown`,this.handleRowMouseDownFunc),this.rowResizer.addEventListener(`dragstart`,e=>{e.preventDefault()})}show(){this.rowResizer.classList.remove(this.bem.is(`hidden`)),this.colResizer.classList.remove(this.bem.is(`hidden`))}hide(){this.currentTableCell=void 0,this.rowResizer.classList.add(this.bem.is(`hidden`)),this.colResizer.classList.add(this.bem.is(`hidden`))}update(){this.updateColResizer(),this.updateRowResizer()}destroy(){this.colResizer.remove(),this.rowResizer.remove(),this.table.removeEventListener(`mousemove`,this.mousemoveHandler),this.quill.off(e.events.TEXT_CHANGE,this.hideWhenTextChange)}},Xn=class{scrollHandler=[];tableMainBlot=null;tableWrapperBlot=null;bem=u(`scale`);startX=0;startY=0;offset=6;options;root;block;resizeobserver=new ResizeObserver(()=>this.update());constructor(t,n,r,i){this.tableModule=t,this.table=n,this.quill=r,this.options=this.resolveOptions(i),this.tableMainBlot=e.find(n),this.tableMainBlot&&!this.tableMainBlot.full&&(this.tableWrapperBlot=this.tableMainBlot.parent,this.buildResizer(),this.show()),this.quill.on(e.events.TEXT_CHANGE,this.updateWhenTextChange)}updateWhenTextChange=()=>{this.update()};resolveOptions(e){return Object.assign({blockSize:12},e)}buildResizer(){if(!this.tableMainBlot||!this.tableWrapperBlot)return;this.root=this.tableModule.addContainer(this.bem.b()),this.root.classList.add(this.bem.is(`hidden`)),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);let e=[],t=[],r=r=>{if(!this.tableMainBlot)return;let i=Q(this.tableMainBlot)?-1:1,a=(r.clientX-this.startX)*i,o=r.clientY-this.startY,s=Math.floor(a/e.length),c=Math.floor(o/t.length);for(let{blot:t,width:r}of e)t.width=Math.max(r+s,n.colMinWidthPx);for(let{blot:e,height:r}of t)e.setHeight(`${Math.max(r+c,n.rowMinHeightPx)}px`)},i=()=>{e=[],t=[],document.removeEventListener(`mousemove`,r),document.removeEventListener(`mouseup`,i)};this.block.addEventListener(`mousedown`,n=>{!this.tableMainBlot||this.isTableOutofEditor()||(this.startX=n.clientX,this.startY=n.clientY,e=this.tableMainBlot.getCols().map(e=>({blot:e,width:Math.floor(e.width)})),t=this.tableMainBlot.getRows().map(e=>({blot:e,height:Math.floor(e.domNode.getBoundingClientRect().height)})),document.addEventListener(`mousemove`,r),document.addEventListener(`mouseup`,i))}),this.block.addEventListener(`dragstart`,e=>e.preventDefault()),this.resizeobserver.observe(this.tableMainBlot.domNode),L.call(this,this.quill.root,()=>this.update()),L.call(this,this.tableWrapperBlot.domNode,()=>this.update())}isTableOutofEditor(){if(!this.tableMainBlot||!this.tableWrapperBlot||this.tableMainBlot.full)return!1;let e=this.tableMainBlot.domNode.getBoundingClientRect(),t=this.tableWrapperBlot.domNode.getBoundingClientRect();if(e.width>t.width){for(let n of this.tableMainBlot.getCols())n.width=Math.floor(n.width/e.width*t.width);return this.tableMainBlot.colWidthFillTable(),!0}return!1}update(){if(!this.block||!this.root||!this.tableMainBlot||!this.tableWrapperBlot)return;if(this.tableMainBlot.full){this.hide();return}let{rect:e,body:t}=yn(this.tableMainBlot);if(!t||!e)return;let n=this.tableWrapperBlot.domNode.getBoundingClientRect(),r=this.quill.root.getBoundingClientRect(),{scrollTop:i,scrollLeft:a}=this.tableWrapperBlot.domNode,o=this.options.blockSize*2+this.offset,s=Math.min(e.width,n.width)+o,c=Math.min(e.height,n.height)+o;Object.assign(this.root.style,{width:`${s}px`,height:`${c}px`,left:`${Math.max(e.x,n.x)-r.x-this.options.blockSize}px`,top:`${Math.max(e.y,n.y)-r.y-this.options.blockSize}px`});let l={left:`${e.width+o-a}px`,top:`${c-i}px`};Q(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)}show(){this.root&&(this.root.classList.remove(this.bem.is(`hidden`)),this.update())}hide(){this.root&&this.root.classList.add(this.bem.is(`hidden`))}destroy(){this.hide(),this.quill.off(e.events.TEXT_CHANGE,this.updateWhenTextChange),this.resizeobserver.disconnect(),this.root&&this.root.remove(),Ut.call(this)}},Zn=class{minSize=20;gap=4;move=0;cursorDown=!1;cursorLeave=!1;ratioY=1;ratioX=1;sizeWidth=``;sizeHeight=``;size=``;thumbState={X:0,Y:0};ob;container;scrollbar;thumb=document.createElement(`div`);scrollHandler=[];propertyMap;bem=u(`scrollbar`);tableMainBlot;constructor(t,n,r,i){this.quill=t,this.isVertical=n,this.table=r,this.scrollbarContainer=i,this.tableMainBlot=e.find(this.table),this.container=r.parentElement,this.propertyMap=this.isVertical?{size:`height`,offset:`offsetHeight`,scrollDirection:`scrollTop`,scrollSize:`scrollHeight`,axis:`Y`,direction:`top`,client:`clientY`}:{size:`width`,offset:`offsetWidth`,scrollDirection:`scrollLeft`,scrollSize:`scrollWidth`,axis:`X`,direction:`left`,client:`clientX`},this.calculateSize(),this.ob=new ResizeObserver(()=>{this.update()}),this.ob.observe(r),this.scrollbar=this.createScrollbar(),this.setScrollbarPosition(),L.call(this,this.quill.root,()=>this.setScrollbarPosition()),this.showScrollbar()}update(){this.calculateSize(),this.setScrollbarPosition()}setScrollbarPosition(){let{rect:e,body:t}=yn(this.tableMainBlot);if(!t||!e)return;let{scrollLeft:n,scrollTop:r,offsetLeft:i,offsetTop:a}=this.quill.root,{offsetLeft:o,offsetTop:s}=this.container,{offsetLeft:c,offsetTop:l}=t.domNode,{width:u,height:d}=this.container.getBoundingClientRect(),f=o+c-i,p=s+l-a;this.isVertical?f+=Math.min(u,e.width):p+=Math.min(d,e.height),this.tableMainBlot&&this.tableMainBlot.align!==`left`&&(f+=this.table.offsetLeft-o),Object.assign(this.scrollbar.style,{[this.propertyMap.size]:`${this.isVertical?Math.min(d,e.height):u}px`,transform:`translate(${f-n}px, ${p-r}px)`}),this.containerScrollHandler(this.container)}calculateSize(){let e=this.container.offsetHeight-this.gap,t=this.container.offsetWidth-this.gap,n=e**2/this.container.scrollHeight,r=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}createScrollbar(){let e=document.createElement(`div`);e.classList.add(this.bem.b()),e.classList.add(this.isVertical?this.bem.is(`vertical`):this.bem.is(`horizontal`),this.bem.is(`transparent`)),Object.assign(e.style,{display:`none`}),this.thumb.classList.add(this.bem.be(`thumb`));let t=null,n=e=>{if(this.cursorDown===!1)return;let t=this.thumbState[this.propertyMap.axis];if(!t)return;let n=this.scrollbar[this.propertyMap.offset]**2/this.container[this.propertyMap.scrollSize]/(this.isVertical?this.ratioY:this.ratioX)/this.thumb[this.propertyMap.offset],r=(this.scrollbar.getBoundingClientRect()[this.propertyMap.direction]-e[this.propertyMap.client])*-1,i=this.thumb[this.propertyMap.offset]-t,a=(r-i)*100*n/this.scrollbar[this.propertyMap.offset];this.container[this.propertyMap.scrollDirection]=a*this.container[this.propertyMap.scrollSize]/100},r=()=>{this.thumbState[this.propertyMap.axis]=0,this.cursorDown=!1,document.removeEventListener(`mousemove`,n),document.removeEventListener(`mouseup`,r),this.cursorLeave&&this.hideScrollbar(),document.onselectstart=t},i=e=>{e.stopImmediatePropagation(),this.cursorDown=!0,document.addEventListener(`mousemove`,n),document.addEventListener(`mouseup`,r),t=document.onselectstart,document.onselectstart=()=>!1};this.thumb.addEventListener(`mousedown`,e=>{if(e.stopPropagation(),e.ctrlKey||[1,2].includes(e.button))return;window.getSelection()?.removeAllRanges(),i(e);let t=e.currentTarget;t&&(this.thumbState[this.propertyMap.axis]=t[this.propertyMap.offset]-(e[this.propertyMap.client]-t.getBoundingClientRect()[this.propertyMap.direction]))});let a=[this.table,e];for(let e of a)e.addEventListener(`mouseenter`,this.showScrollbar),e.addEventListener(`mouseleave`,this.hideScrollbar);return L.call(this,this.container,()=>{this.containerScrollHandler(this.container)}),e.appendChild(this.thumb),e}containerScrollHandler(e){let 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,{[this.propertyMap.size]:this.size,transform:`translate${this.propertyMap.axis}(${this.move}%)`})}showScrollbar=Yt(()=>{this.cursorLeave=!1,this.scrollbar.removeEventListener(`transitionend`,this.hideScrollbarTransitionend),this.scrollbar.style.display=this.size?`block`:`none`,requestAnimationFrame(()=>{this.scrollbar.classList.remove(this.bem.is(`transparent`))})},200);hideScrollbar=Yt(()=>{this.cursorLeave=!0,!this.cursorDown&&(this.scrollbar.removeEventListener(`transitionend`,this.hideScrollbarTransitionend),this.scrollbar.addEventListener(`transitionend`,this.hideScrollbarTransitionend,{once:!0}),this.scrollbar.classList.add(this.bem.is(`transparent`)))},200);hideScrollbarTransitionend=()=>{this.scrollbar.style.display=this.cursorDown&&this.size?`block`:`none`};destroy(){this.ob.disconnect(),Ut.call(this),this.table.removeEventListener(`mouseenter`,this.showScrollbar),this.table.removeEventListener(`mouseleave`,this.hideScrollbar)}},Qn=class{scrollbarContainer;scrollbar;bem=u(`scrollbar`);constructor(t,n,r){this.tableModule=t,this.table=n,this.quill=r,this.scrollbarContainer=this.tableModule.addContainer(this.bem.be(`container`)),this.scrollbar=[new Zn(r,!0,n,this.scrollbarContainer),new Zn(r,!1,n,this.scrollbarContainer)];for(let e of this.scrollbar)this.scrollbarContainer.appendChild(e.scrollbar);this.quill.on(e.events.TEXT_CHANGE,this.updateWhenTextChange)}updateWhenTextChange=()=>{this.update()};hide(){for(let e of this.scrollbar)e.hideScrollbar()}show(){for(let e of this.scrollbar)e.showScrollbar()}update(){for(let e of this.scrollbar)e.calculateSize(),e.setScrollbarPosition()}destroy(){this.scrollbarContainer.remove(),this.quill.off(e.events.TEXT_CHANGE,this.updateWhenTextChange);for(let e of this.scrollbar)e.destroy()}};const $n=0;var er=class{options;boundary=null;scrollRecordEls=[];startScrollRecordPosition=[];selectedTableScrollX=0;selectedTableScrollY=0;selectedEditorScrollX=0;selectedEditorScrollY=0;selectedTds=[];cellSelectWrap;cellSelect;dragging=!1;scrollHandler=[];tableMenu;resizeObserver;table;isDisplaySelection=!1;bem=u(`selection`);lastSelection={anchorNode:null,anchorOffset:0,focusNode:null,focusOffset:0};constructor(t,n,i={}){this.tableModule=t,this.quill=n,this.options=this.resolveOptions(i),this.scrollRecordEls=[this.quill.root,document.documentElement],this.cellSelectWrap=t.addContainer(this.bem.b()),this.cellSelect=this.helpLinesInitial(),this.resizeObserver=Ht(()=>this.updateAfterEvent(),{ignoreFirstBind:!0}),this.resizeObserver.observe(this.quill.root),this.quill.root.addEventListener(`mousedown`,this.mouseDownHandler,{passive:!1}),document.addEventListener(`selectionchange`,this.selectionChangeHandler,{passive:!1}),this.quill.on(r.AFTER_TABLE_RESIZE,this.updateAfterEvent),this.quill.on(e.events.SELECTION_CHANGE,this.quillSelectionChangeHandler),this.quill.on(e.events.TEXT_CHANGE,this.updateAfterEvent),this.options.tableMenu&&(this.tableMenu=new this.options.tableMenu(t,n,this.options.tableMenuOptions)),this.hide()}updateAfterEvent=()=>{this.updateWithSelectedTds()};getFirstTextNode(e){for(let t of Array.from(e.childNodes))if(t.nodeType===Node.TEXT_NODE)return t;return e}getLastTextNode(e){for(let t=e.childNodes.length-1;t>=0;t--){let n=e.childNodes[t];if(n.nodeType===Node.TEXT_NODE)return n}return e}getNodeTailOffset(e){let t=document.createRange();return t.selectNodeContents(e),t.collapse(!1),t.startOffset}quillSelectionChangeHandler=(n,r,i)=>{if(i!==e.sources.API&&n&&!this.quill.composition.isComposing&&this.selectedTds.length>0){let e=this.quill.getFormat(n),[r]=this.quill.getLine(n.index),i=!!e[t.tableCellInner]&&!!r,a=this.selectedTds.some(e=>e.children.contains(r));if(i&&!a)try{let e=d(r,t.tableCellInner);this.selectedTds=[e],this.updateWithSelectedTds()}catch{}else i&&a||this.hide()}};setSelectionData(e,t){let{anchorNode:n,anchorOffset:r,focusNode:i,focusOffset:a}=t;if(!n||!i)return;let 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)}selectionDirectionUp(e){let{anchorNode:t,anchorOffset:n,focusNode:r,focusOffset:i}=e;if(!t||!r)return!1;if(t===r)return n>i;let 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}findWrapSelection(e){let t=null,n=0,r=null,i=0;for(let{node:a,offset:o}of e)a&&((!t||this.selectionDirectionUp({anchorNode:t,anchorOffset:n,focusNode:a,focusOffset:o}))&&(t=a,n=o),(!r||this.selectionDirectionUp({anchorNode:a,anchorOffset:o,focusNode:r,focusOffset:i}))&&(r=a,i=o));return{startNode:t,startOffset:n,endNode:r,endOffset:i}}resolveOptions(e){return Object.assign({selectColor:`#0589f340`,tableMenuOptions:{}},e)}selectionChangeHandler=()=>{let n=window.getSelection();if(!n)return;let{anchorNode:r,focusNode:i,anchorOffset:a,focusOffset:o}=n;if(!r||!i)return;let s=e.find(r),c=e.find(i);if(!s||!c||s.scroll!==this.quill.scroll||c.scroll!==this.quill.scroll)return;let l=p(s),u=p(c),d=l.has(t.tableColgroup),f=u.has(t.tableColgroup);if(d||f){let e=r,s=a,c=i,p=o;if(d){let n=l.get(t.tableWrapper),r=n.descendants(V);r.length>0&&(e=r[0].domNode,s=0)}if(f){let e=u.get(t.tableWrapper),n=e.descendants(V);n.length>0&&(c=n[0].domNode,p=0)}this.setSelectionData(n,{anchorNode:e,anchorOffset:s,focusNode:c,focusOffset:p});return}let m=l.has(t.tableCellInner),h=u.has(t.tableCellInner),g=m&&h;if(g){let e=l.get(t.tableCellInner),n=u.get(t.tableCellInner);g&&=e!==n}if(m&&h&&g||!m&&h||!h&&m){this.setSelectionData(n,this.lastSelection),this.selectedTds.length>0&&this.hide();return}this.lastSelection={anchorNode:r,anchorOffset:a,focusNode:i,focusOffset:o}};helpLinesInitial(){this.cellSelectWrap.style.setProperty(`--select-color`,this.options.selectColor);let e=document.createElement(`div`);return e.classList.add(this.bem.be(`line`)),this.cellSelectWrap.appendChild(e),e}computeSelectedTds(t,n){if(!this.table)return[];let r=e.find(this.table);if(!r)return[];let i=r.descendants(U)[0];if(!i)return[];let a=new Set(i.descendants(G).map((e,t)=>(e.index=t,e))),o=this.getScrollPositionDiff(),{rect:s}=yn(r);if(!s)return[];let c=t.x+o.x,l=t.y+o.y,u={x:Math.max(s.left,Math.min(n.x,c)),y:Math.max(s.top,Math.min(n.y,l)),x1:Math.min(s.right,Math.max(n.x,c)),y1:Math.min(s.bottom,Math.max(n.y,l))},d=new Set,f=!0;for(;f;){f=!1;for(let e of a){e.__rect||=e.domNode.getBoundingClientRect();let{x:t,y:n,right:r,bottom:i}=e.__rect;if(Rt({x:Math.floor(u.x),y:Math.floor(u.y),x1:Math.floor(u.x1),y1:Math.floor(u.y1)},{x:Math.floor(t),y:Math.floor(n),x1:Math.floor(r),y1:Math.floor(i)},$n,d.size===0)){d.add(e),a.delete(e),u={x:Math.min(u.x,t),y:Math.min(u.y,n),x1:Math.max(u.x1,r),y1:Math.max(u.y1,i)},f=!0;break}}}for(let e of[...d,...a])delete e.__rect;return this.boundary=zt({...u,width:u.x1-u.x,height:u.y1-u.y},this.quill.root),Array.from(d).sort((e,t)=>e.index-t.index).map(e=>(delete e.index,e.getCellInner()))}getScrollPositionDiff(){let{x:e,y:t}=this.getTableViewScroll(),{x:n,y:r}=Wt(this.quill.root);return this.selectedTableScrollX=e,this.selectedTableScrollY=t,this.selectedEditorScrollX=n,this.selectedEditorScrollY=r,this.startScrollRecordPosition.reduce((e,{x:t,y:n},r)=>{let{x:i,y:a}=Wt(this.scrollRecordEls[r]);return e.x+=t-i,e.y+=n-a,e},{x:0,y:0})}recordScrollPosition(){this.clearRecordScrollPosition();for(let e of this.scrollRecordEls)this.startScrollRecordPosition.push(Wt(e))}clearRecordScrollPosition(){this.startScrollRecordPosition=[]}mouseDownHandler=e=>{let{button:t,target:n,clientX:r,clientY:i}=e,a=n.closest(`.ql-table`),o=n.closest(`caption`);if(t!==0||!a||o)return;this.setSelectionTable(a);let s=a.dataset.tableId,c={x:r,y:i};this.recordScrollPosition(),this.selectedTds=this.computeSelectedTds(c,c),this.dragging=!0,this.show();let l=e=>{this.tableMenu&&this.tableMenu.hide(),this.tableModule.tableResize&&this.tableModule.tableResize.hide();let{button:t,target:n,clientX:r,clientY:i}=e,a=n.closest(`.ql-table`),o=n.closest(`caption`);if(t!==0||o||!a||a.dataset.tableId!==s)return;let l={x:r,y:i};this.selectedTds=this.computeSelectedTds(c,l),this.selectedTds.length>1&&this.quill.blur(),this.update()},u=()=>{document.body.removeEventListener(`mousemove`,l,!1),document.body.removeEventListener(`mouseup`,u,!1),this.dragging=!1,this.clearRecordScrollPosition(),this.tableMenu&&this.selectedTds.length>0&&this.tableMenu.show()};document.body.addEventListener(`mousemove`,l,!1),document.body.addEventListener(`mouseup`,u,!1)};updateWithSelectedTds(){if(this.selectedTds.length<=0)return;let e={x:1/0,y:1/0},t={x:-1/0,y:-1/0};for(let n of this.selectedTds){let r=n.domNode.getBoundingClientRect();e.x=Math.min(e.x,r.left),e.y=Math.min(e.y,r.top),t.x=Math.max(t.x,r.right),t.y=Math.max(t.y,r.bottom)}this.selectedTds=this.computeSelectedTds(e,t),this.selectedTds.length>0?this.update():this.hide()}update(){if(this.selectedTds.length===0||!this.boundary||!this.table)return;let{x:e,y:t}=Wt(this.quill.root),{x:n,y:r}=this.getTableViewScroll(),i=this.table.parentElement.getBoundingClientRect(),a=this.quill.root.getBoundingClientRect(),o=i.x-a.x,s=i.y-a.y;Object.assign(this.cellSelect.style,{left:`${this.selectedEditorScrollX*2-e+this.boundary.x+this.selectedTableScrollX-n-o}px`,top:`${this.selectedEditorScrollY*2-t+this.boundary.y+this.selectedTableScrollY-r-s}px`,width:`${this.boundary.width}px`,height:`${this.boundary.height}px`}),Object.assign(this.cellSelectWrap.style,{left:`${o}px`,top:`${s}px`,width:`${i.width}px`,height:`${i.height}px`}),!this.dragging&&this.tableMenu&&this.tableMenu.update()}getTableViewScroll(){return this.table?Wt(this.table.parentElement):{x:0,y:0}}setSelectionTable(e){this.table!==e&&(this.table=e,this.table?this.scrollRecordEls.push(this.table.parentElement):this.scrollRecordEls.pop())}removeCell=t=>{let n=this.quill.getSelection();if(!(n||t.key!==`Backspace`&&t.key!==`Delete`)){for(let e of this.selectedTds)e.deleteAt(0,e.length()-1);if(this.table){let t=e.find(this.table),n=t.descendants(V);this.selectedTds.length===n.length&&t.remove()}}};showDisplay(){Object.assign(this.cellSelectWrap.style,{display:`block`}),this.isDisplaySelection=!0,this.table&&this.resizeObserver.observe(this.table)}show(){this.table&&(Ut.call(this),this.update(),this.showDisplay(),document.addEventListener(`keydown`,this.removeCell),L.call(this,this.quill.root,()=>{this.update()}),L.call(this,this.table.parentElement,()=>{this.update()}))}hideDisplay(){Object.assign(this.cellSelectWrap.style,{display:`none`}),this.isDisplaySelection=!1,this.table&&this.resizeObserver.unobserve(this.table)}hide(){Ut.call(this),document.removeEventListener(`keydown`,this.removeCell),this.hideDisplay(),this.boundary=null,this.selectedTds=[],this.setSelectionTable(void 0),this.tableMenu&&this.tableMenu.hide()}destroy(){this.resizeObserver.disconnect(),this.hide(),this.cellSelectWrap.remove(),this.tableMenu&&this.tableMenu.destroy(),Ut.call(this),this.quill.root.removeEventListener(`mousedown`,this.mouseDownHandler),document.removeEventListener(`selectionchange`,this.selectionChangeHandler),this.quill.off(e.events.SELECTION_CHANGE,this.quillSelectionChangeHandler),this.quill.off(e.events.TEXT_CHANGE,this.updateAfterEvent),this.quill.on(r.AFTER_TABLE_RESIZE,this.updateAfterEvent)}};const tr=e.import(`parchment`),$=e.import(`delta`),nr=e.import(`ui/icons`),rr=e.import(`blots/break`),ir=e.import(`blots/block`),ar=e.import(`blots/block/embed`);function or(e,{tableId:n,rowId:r,colId:i}){let a={tableId:n,rowId:r,colId:i,colspan:1,rowspan:1},o=e.create(t.tableCell,a),s=e.create(t.tableCellInner,a),c=e.create(`block`);return c.appendChild(e.create(`break`)),s.appendChild(c),o.appendChild(s),o}function sr(e){s.delete(t.tableCellInner),Object.assign(t,e.blotName||{}),Object.assign(n,e.tableUpSize||{}),Object.assign(r,e.tableUpEvent||{}),Object.assign(i,e.tableUpInternal||{}),ur.moduleName=i.moduleName,ur.toolName=t.tableWrapper,z.blotName=t.container,Y.blotName=t.tableWrapper,q.blotName=t.tableMain,J.blotName=t.tableColgroup,K.blotName=t.tableCol,U.blotName=t.tableBody,H.blotName=t.tableRow,G.blotName=t.tableCell,V.blotName=t.tableCellInner,s.add(t.tableCellInner)}function cr(e,t){return de({onSelect:(n,r)=>{e.insertTable(n,r),t&&t.close()},customBtn:e.options.customBtn,texts:e.options.texts})}function lr(n){return{bindInHead:!1,key:n?`ArrowUp`:`ArrowDown`,collapsed:!0,format:[t.tableCellInner],handler(r,i){let a=n?`prev`:`next`,o=n?`tail`:`head`;if(i.line[a])return!0;let s=this.quill.selection.getBounds(r.index),c=i.line.domNode.getBoundingClientRect();if(!s||!c)return!0;if(n){if(s.top-c.top>3)return!0}else if(c.bottom-s.bottom>3)return!0;let l,u,d,p;try{[l,u,d,p]=f(i.line,[t.tableWrapper,t.tableMain,t.tableRow,t.tableCell])}catch{return!0}let m=u.getColIds(),h=l.descendants(W,0)[0],g;if(h){let e=window.getComputedStyle(h.domNode);g=a===`next`&&e.captionSide===`bottom`?h:a===`next`?l.next:h}else g=l[a];if(i.line[a]||!g)return!0;let _=d[a];if(_){let t=m.indexOf(p.colId),n=_.getCellByColId(m[t],a);if(!n)return!0;let r=n.children[o];r.children&&(r=r.children[o]);let s=r.offset(this.quill.scroll)+Math.min(i.offset,r.length()-1);this.quill.setSelection(s,0,e.sources.USER)}else{let t=g.offset(this.quill.scroll)+(n?g.length()-1:0);this.quill.setSelection(t,0,e.sources.USER)}return!1}}}var ur=class r{static moduleName=i.moduleName;static toolName=t.tableWrapper;static keyboradHandler={"forbid remove table by backspace":{bindInHead:!0,key:`Backspace`,collapsed:!0,offset:0,handler(e,n){let r=this.quill.getLine(e.index),i=r[0];if(i.prev instanceof Y)return i.prev.remove(),!1;if(n.format[t.tableCellInner]){let e=i.offset(d(i,t.tableCellInner));if(e===0)return!1}return!0}},"forbid remove table by delete":{bindInHead:!0,key:`Delete`,collapsed:!0,handler(e,n){let r=this.quill.getLine(e.index),i=r[0],a=r[1];if((i.next instanceof Y||i.next instanceof K)&&a===i.length()-1)return!1;if(n.format[t.tableCellInner]){let e=d(i,t.tableCellInner);if(i===e.children.tail&&a===i.length()-1)return!1}return!0}},"table up":lr(!0),"table down":lr(!1),"table caption break":{bindInHead:!0,key:`Enter`,shiftKey:null,format:[t.tableCaption],handler(e,t){return!1}}};static register(){Y.allowedChildren=[q],q.allowedChildren=[U,J,W],q.requiredContainer=Y,W.requiredContainer=q,J.allowedChildren=[K],J.requiredContainer=q,U.allowedChildren=[H],U.requiredContainer=q,H.allowedChildren=[G],G.requiredContainer=U,G.allowedChildren=[V,rr],G.requiredContainer=H,V.requiredContainer=G;let n=new Set([`table`]),r=Object.entries(e.imports).filter(([e,t])=>{let r=e.split(`formats/`)[1];return e.startsWith(`formats/`)&&!n.has(r)&&!_(t,tr.Attributor)&&(_(t,ir)||_(t,ar))}),i=r.reduce((e,[t,n])=>{let r=_(n,ar)?cn:on;return e[t]=class extends g(n,[r]){static register(){}},e},{});e.register({"blots/scroll":fn,"blots/block":on,"blots/block/embed":cn,...i,[`blots/${t.container}`]:z,[`formats/${t.tableCell}`]:G,[`formats/${t.tableCellInner}`]:V,[`formats/${t.tableRow}`]:H,[`formats/${t.tableBody}`]:U,[`formats/${t.tableCol}`]:K,[`formats/${t.tableColgroup}`]:J,[`formats/${t.tableCaption}`]:W,[`formats/${t.tableMain}`]:q,[`formats/${t.tableWrapper}`]:Y,"modules/clipboard":Tn},!0)}quill;options;toolBox;fixTableByLisenter=Yt(this.balanceTables,100);selector;table;tableSelection;tableResize;tableScrollbar;tableAlign;tableResizeScale;resizeOb;get statics(){return this.constructor}constructor(t,n){if(this.quill=t,this.options=this.resolveOptions(n||{}),this.toolBox=this.initialContainer(),!this.options.scrollbar){let e=u(`scrollbar`);this.quill.container.classList.add(e.bm(`origin`))}this.options.selection&&(this.tableSelection=new this.options.selection(this,this.quill,this.options.selectionOptions));let i=this.quill.getModule(`toolbar`);if(i&&this.quill.theme.pickers){let[,e]=(i.controls||[]).find(([e])=>e===this.statics.toolName)||[];if(e&&e.tagName.toLocaleLowerCase()===`select`){let t=this.quill.theme.pickers.find(t=>t.select===e);t&&(t.label.innerHTML=this.options.icon,this.buildCustomSelect(this.options.customSelect,t),t.label.addEventListener(`mousedown`,()=>{if(!this.selector||!t)return;let e=this.selector.getBoundingClientRect(),{leftLimited:n}=Vt(e);if(n){let e=t.label.getBoundingClientRect();Object.assign(t.options.style,{transform:`translateX(calc(-100% + ${e.width}px))`})}else Object.assign(t.options.style,{transform:void 0})}))}}let a=this.quill.getModule(`keyboard`);for(let e of Object.values(r.keyboradHandler))e.bindInHead?a.bindings[e.key].unshift(e):a.addBinding(e.key,e);this.quill.root.addEventListener(`click`,e=>{let t=e.composedPath();if(!t||t.length<=0)return;let n=t.find(e=>e.tagName&&e.tagName.toUpperCase()===`TABLE`&&e.classList.contains(`ql-table`));if(n){if(this.table===n){this.tableSelection&&this.tableSelection.show(),this.tableAlign&&this.tableAlign.update(),this.tableResize&&this.tableResize.update(),this.tableScrollbar&&this.tableScrollbar.update();return}this.table&&this.hideTableTools(),this.showTableTools(n)}else this.table&&this.hideTableTools()},!1),this.quill.on(e.events.EDITOR_CHANGE,t=>{t===e.events.TEXT_CHANGE&&(!this.table||!this.quill.root.contains(this.table))&&this.hideTableTools()}),this.quillHack(),this.listenBalanceCells()}initialContainer(){let e=u(`toolbox`),t=this.quill.addContainer(e.b()),n=()=>{let e=this.quill.root.getBoundingClientRect(),{offsetLeft:n,offsetTop:r}=this.quill.root;Object.assign(t.style,{top:`${r}px`,left:`${n}px`,width:`${e.width}px`,height:`${e.height}px`})};return this.resizeOb=new ResizeObserver(n),this.resizeOb.observe(this.quill.root),t}addContainer(e){if(w(e)){let t=document.createElement(`div`);for(let n of e.split(` `))t.classList.add(n);return this.toolBox.appendChild(t),t}else return this.toolBox.appendChild(e),e}resolveOptions(e){return Object.assign({customBtn:!1,texts:this.resolveTexts(e.texts||{}),full:!1,fullSwitch:!0,icon:nr.table,selectionOptions:{},alignOptions:{},scrollbarOptions:{},resizeOptions:{},resizeScaleOptions:{},autoMergeCell:!0},e)}resolveTexts(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)}quillHack(){let n=this.quill.getSemanticHTML;this.quill.getSemanticHTML=(r=0,i)=>{let a=n.call(this.quill,r,i),o=e.import(`formats/${t.tableWrapper}`),s=new DOMParser,c=s.parseFromString(a,`text/html`);for(let e of Array.from(c.querySelectorAll(`.${o.className} caption[contenteditable], .${o.className} td > [contenteditable]`)))e.removeAttribute(`contenteditable`);return c.body.innerHTML};let r=this.quill.format;this.quill.format=function(n,a,o=e.sources.API){let s=this.scroll.query(n);if(!(s.prototype instanceof tr.EmbedBlot)){let e=this.getModule(i.moduleName),s=this.getSelection(!0),c=this.getFormat(s);if(!c[t.tableCellInner]||s.length>0||e&&e.tableSelection&&e.tableSelection.selectedTds.length<=1)return r.call(this,n,a,o);if(e&&e.tableSelection&&e.tableSelection.selectedTds.length>0){let t=e.tableSelection.selectedTds,r=!1,i=[];for(let e of t){let t=e.offset(this.scroll),o=e.length();i.push({index:t,length:o});let s=this.getFormat(t,o);s[n]!==a&&(r=!0)}let s=r?a:!1,c=new $;for(let[e,{index:t,length:r}]of i.entries()){let a=e===0?0:i[e-1].index+i[e-1].length;c.retain(t-a).retain(r,{[n]:s})}let l=this.updateContents(c,o);return this.blur(),l}}return r.call(this,n,a,o)};let a=this.quill.theme.modules.toolbar;if(a){let n=a.handlers?.clean;if(n){let r=(e,n,r=()=>``)=>{let i=this.quill.getText(e,n),[a,o]=this.quill.getLine(e+n),s=0,c=new $;a!=null&&(s=a.length()-o,c=a.delta().slice(o,o+s-1).insert(`
|
|
124
|
+
</div>`}let r=document.createElement(`div`);r.classList.add(this.bem.be(`row`));let i=document.createElement(`div`);i.classList.add(this.bem.be(`row-wrapper`)),Object.assign(r.style,{transform:`translateX(-${this.size}px)`,width:`${this.size}px`,maxHeight:`${n.height}px`}),Object.assign(i.style,{height:`${e.height}px`}),i.innerHTML=t,r.appendChild(i),this.root.appendChild(r),r.scrollTop=this.tableWrapper.domNode.scrollTop,this.rowHeadWrapper=r,this.bindRowEvents()}this.update(),L.call(this,this.quill.root,()=>{this.update()})}hide(){this.root.classList.add(this.bem.is(`hidden`))}destroy(){this.hide(),Ut.call(this),this.resizeObserver.disconnect(),this.quill.off(e.events.TEXT_CHANGE,this.updateWhenTextChange);for(let[e,t]of this.scrollHandler)e.removeEventListener(`scroll`,t);this.root.remove()}},Yn=class extends qn{colResizer;rowResizer;currentTableCell;dragging=!1;curColIndex=-1;curRowIndex=-1;tableCellBlot;bem=u(`resize-line`);constructor(t,n,r){super(t,r),this.tableModule=t,this.table=n,this.colResizer=this.tableModule.addContainer(this.bem.be(`col`)),this.rowResizer=this.tableModule.addContainer(this.bem.be(`row`)),this.table.addEventListener(`mousemove`,this.mousemoveHandler),this.quill.on(e.events.TEXT_CHANGE,this.hideWhenTextChange)}mousemoveHandler=n=>{if(this.dragging||this.tableModule.tableSelection&&this.tableModule.tableSelection.dragging)return;let r=this.findTableCell(n);if(!r)return this.hide();let i=e.find(r);i&&this.currentTableCell!==r&&(this.show(),this.currentTableCell=r,this.tableCellBlot=i,this.tableMain=d(i,t.tableMain),this.tableMain.getCols().length>0&&this.updateColResizer(),this.updateRowResizer())};hideWhenTextChange=()=>{this.hide()};findTableCell(e){for(let t of e.composedPath()){if(t instanceof HTMLElement&&t.tagName===`TD`)return t;if(t===document.body)return null}return null}findCurrentColIndex(){return this.curColIndex+(this.tableCellBlot?.colspan||1)-1}handleColMouseUpFunc=async function(){await this.handleColMouseUp(),this.updateColResizer()}.bind(this);updateColResizer(){if(!this.tableMain||!this.tableCellBlot)return;let e=this.tableCellBlot;this.tableModule.toolBox.removeChild(this.colResizer),this.colResizer=this.tableModule.addContainer(this.bem.be(`col`));let[n]=f(e,[t.tableBody]),r=n.domNode.getBoundingClientRect(),i=e.domNode.getBoundingClientRect(),a=this.quill.root.getBoundingClientRect(),o=i.right-a.x;Q(this.tableMain)&&(o=i.left-a.x),Object.assign(this.colResizer.style,{top:`${r.y-a.y}px`,left:`${o}px`,height:`${r.height}px`});let s=this.tableMain.getCols();this.curColIndex=s.findIndex(t=>t.colId===e.colId),this.colResizer.addEventListener(`mousedown`,this.handleColMouseDownFunc),this.colResizer.addEventListener(`dragstart`,e=>{e.preventDefault()})}findCurrentRowIndex(){return this.curRowIndex}handleRowMouseUpFunc=function(){this.handleRowMouseUp(),this.updateRowResizer()}.bind(this);updateRowResizer(){if(!this.tableMain||!this.tableCellBlot)return;let e=this.tableCellBlot;this.tableModule.toolBox.removeChild(this.rowResizer),this.rowResizer=this.tableModule.addContainer(this.bem.be(`row`));let n=e.parent;if(!(n instanceof H))return;let[r]=f(e,[t.tableBody]),i=r.domNode.getBoundingClientRect(),a=e.domNode.getBoundingClientRect(),o=this.quill.root.getBoundingClientRect();Object.assign(this.rowResizer.style,{top:`${a.bottom-o.y}px`,left:`${i.x-o.x}px`,width:`${i.width}px`});let s=this.tableMain.getRows();this.curRowIndex=s.indexOf(n),this.rowResizer.addEventListener(`mousedown`,this.handleRowMouseDownFunc),this.rowResizer.addEventListener(`dragstart`,e=>{e.preventDefault()})}show(){this.rowResizer.classList.remove(this.bem.is(`hidden`)),this.colResizer.classList.remove(this.bem.is(`hidden`))}hide(){this.currentTableCell=void 0,this.rowResizer.classList.add(this.bem.is(`hidden`)),this.colResizer.classList.add(this.bem.is(`hidden`))}update(){this.updateColResizer(),this.updateRowResizer()}destroy(){this.colResizer.remove(),this.rowResizer.remove(),this.table.removeEventListener(`mousemove`,this.mousemoveHandler),this.quill.off(e.events.TEXT_CHANGE,this.hideWhenTextChange)}},Xn=class{scrollHandler=[];tableMainBlot=null;tableWrapperBlot=null;bem=u(`scale`);startX=0;startY=0;offset=6;options;root;block;resizeobserver=new ResizeObserver(()=>this.update());constructor(t,n,r,i){this.tableModule=t,this.table=n,this.quill=r,this.options=this.resolveOptions(i),this.tableMainBlot=e.find(n),this.tableMainBlot&&!this.tableMainBlot.full&&(this.tableWrapperBlot=this.tableMainBlot.parent,this.buildResizer(),this.show()),this.quill.on(e.events.TEXT_CHANGE,this.updateWhenTextChange)}updateWhenTextChange=()=>{this.update()};resolveOptions(e){return Object.assign({blockSize:12},e)}buildResizer(){if(!this.tableMainBlot||!this.tableWrapperBlot)return;this.root=this.tableModule.addContainer(this.bem.b()),this.root.classList.add(this.bem.is(`hidden`)),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);let e=[],t=[],r=r=>{if(!this.tableMainBlot)return;let i=Q(this.tableMainBlot)?-1:1,a=(r.clientX-this.startX)*i,o=r.clientY-this.startY,s=Math.floor(a/e.length),c=Math.floor(o/t.length);for(let{blot:t,width:r}of e)t.width=Math.max(r+s,n.colMinWidthPx);for(let{blot:e,height:r}of t)e.setHeight(`${Math.max(r+c,n.rowMinHeightPx)}px`)},i=()=>{e=[],t=[],document.removeEventListener(`mousemove`,r),document.removeEventListener(`mouseup`,i)};this.block.addEventListener(`mousedown`,n=>{!this.tableMainBlot||this.isTableOutofEditor()||(this.startX=n.clientX,this.startY=n.clientY,e=this.tableMainBlot.getCols().map(e=>({blot:e,width:Math.floor(e.width)})),t=this.tableMainBlot.getRows().map(e=>({blot:e,height:Math.floor(e.domNode.getBoundingClientRect().height)})),document.addEventListener(`mousemove`,r),document.addEventListener(`mouseup`,i))}),this.block.addEventListener(`dragstart`,e=>e.preventDefault()),this.resizeobserver.observe(this.tableMainBlot.domNode),L.call(this,this.quill.root,()=>this.update()),L.call(this,this.tableWrapperBlot.domNode,()=>this.update())}isTableOutofEditor(){if(!this.tableMainBlot||!this.tableWrapperBlot||this.tableMainBlot.full)return!1;let e=this.tableMainBlot.domNode.getBoundingClientRect(),t=this.tableWrapperBlot.domNode.getBoundingClientRect();if(e.width>t.width){for(let n of this.tableMainBlot.getCols())n.width=Math.floor(n.width/e.width*t.width);return this.tableMainBlot.colWidthFillTable(),!0}return!1}update(){if(!this.block||!this.root||!this.tableMainBlot||!this.tableWrapperBlot)return;if(this.tableMainBlot.full){this.hide();return}let{rect:e,body:t}=yn(this.tableMainBlot);if(!t||!e)return;let n=this.tableWrapperBlot.domNode.getBoundingClientRect(),r=this.quill.root.getBoundingClientRect(),{scrollTop:i,scrollLeft:a}=this.tableWrapperBlot.domNode,o=this.options.blockSize*2+this.offset,s=Math.min(e.width,n.width)+o,c=Math.min(e.height,n.height)+o;Object.assign(this.root.style,{width:`${s}px`,height:`${c}px`,left:`${Math.max(e.x,n.x)-r.x-this.options.blockSize}px`,top:`${Math.max(e.y,n.y)-r.y-this.options.blockSize}px`});let l={left:`${e.width+o-a}px`,top:`${c-i}px`};Q(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)}show(){this.root&&(this.root.classList.remove(this.bem.is(`hidden`)),this.update())}hide(){this.root&&this.root.classList.add(this.bem.is(`hidden`))}destroy(){this.hide(),this.quill.off(e.events.TEXT_CHANGE,this.updateWhenTextChange),this.resizeobserver.disconnect(),this.root&&this.root.remove(),Ut.call(this)}},Zn=class{minSize=20;gap=4;move=0;cursorDown=!1;cursorLeave=!1;ratioY=1;ratioX=1;sizeWidth=``;sizeHeight=``;size=``;thumbState={X:0,Y:0};ob;container;scrollbar;thumb=document.createElement(`div`);scrollHandler=[];propertyMap;bem=u(`scrollbar`);tableMainBlot;constructor(t,n,r,i){this.quill=t,this.isVertical=n,this.table=r,this.scrollbarContainer=i,this.tableMainBlot=e.find(this.table),this.container=r.parentElement,this.propertyMap=this.isVertical?{size:`height`,offset:`offsetHeight`,scrollDirection:`scrollTop`,scrollSize:`scrollHeight`,axis:`Y`,direction:`top`,client:`clientY`}:{size:`width`,offset:`offsetWidth`,scrollDirection:`scrollLeft`,scrollSize:`scrollWidth`,axis:`X`,direction:`left`,client:`clientX`},this.calculateSize(),this.ob=new ResizeObserver(()=>{this.update()}),this.ob.observe(r),this.scrollbar=this.createScrollbar(),this.setScrollbarPosition(),L.call(this,this.quill.root,()=>this.setScrollbarPosition()),this.showScrollbar()}update(){this.calculateSize(),this.setScrollbarPosition()}setScrollbarPosition(){let{rect:e,body:t}=yn(this.tableMainBlot);if(!t||!e)return;let{scrollLeft:n,scrollTop:r,offsetLeft:i,offsetTop:a}=this.quill.root,{offsetLeft:o,offsetTop:s}=this.container,{offsetLeft:c,offsetTop:l}=t.domNode,{width:u,height:d}=this.container.getBoundingClientRect(),f=o+c-i,p=s+l-a;this.isVertical?f+=Math.min(u,e.width):p+=Math.min(d,e.height),this.tableMainBlot&&this.tableMainBlot.align!==`left`&&(f+=this.table.offsetLeft-o),Object.assign(this.scrollbar.style,{[this.propertyMap.size]:`${this.isVertical?Math.min(d,e.height):u}px`,transform:`translate(${f-n}px, ${p-r}px)`}),this.containerScrollHandler(this.container)}calculateSize(){let e=this.container.offsetHeight-this.gap,t=this.container.offsetWidth-this.gap,n=e**2/this.container.scrollHeight,r=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}createScrollbar(){let e=document.createElement(`div`);e.classList.add(this.bem.b(),this.isVertical?this.bem.is(`vertical`):this.bem.is(`horizontal`),this.bem.is(`transparent`)),Object.assign(e.style,{display:`none`}),this.thumb.classList.add(this.bem.be(`thumb`));let t=null,n=e=>{if(this.cursorDown===!1)return;let t=this.thumbState[this.propertyMap.axis];if(!t)return;let n=this.scrollbar[this.propertyMap.offset]**2/this.container[this.propertyMap.scrollSize]/(this.isVertical?this.ratioY:this.ratioX)/this.thumb[this.propertyMap.offset],r=(this.scrollbar.getBoundingClientRect()[this.propertyMap.direction]-e[this.propertyMap.client])*-1,i=this.thumb[this.propertyMap.offset]-t,a=(r-i)*100*n/this.scrollbar[this.propertyMap.offset];this.container[this.propertyMap.scrollDirection]=a*this.container[this.propertyMap.scrollSize]/100},r=()=>{this.thumbState[this.propertyMap.axis]=0,this.cursorDown=!1,document.removeEventListener(`mousemove`,n),document.removeEventListener(`mouseup`,r),this.cursorLeave&&this.hideScrollbar(),document.onselectstart=t},i=e=>{e.stopImmediatePropagation(),this.cursorDown=!0,document.addEventListener(`mousemove`,n),document.addEventListener(`mouseup`,r),t=document.onselectstart,document.onselectstart=()=>!1};this.thumb.addEventListener(`mousedown`,e=>{if(e.stopPropagation(),e.ctrlKey||[1,2].includes(e.button))return;window.getSelection()?.removeAllRanges(),i(e);let t=e.currentTarget;t&&(this.thumbState[this.propertyMap.axis]=t[this.propertyMap.offset]-(e[this.propertyMap.client]-t.getBoundingClientRect()[this.propertyMap.direction]))});let a=[this.table,e];for(let e of a)e.addEventListener(`mouseenter`,this.showScrollbar),e.addEventListener(`mouseleave`,this.hideScrollbar);return L.call(this,this.container,()=>{this.containerScrollHandler(this.container)}),e.appendChild(this.thumb),e}containerScrollHandler(e){let 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,{[this.propertyMap.size]:this.size,transform:`translate${this.propertyMap.axis}(${this.move}%)`})}showScrollbar=Yt(()=>{this.cursorLeave=!1,this.scrollbar.removeEventListener(`transitionend`,this.hideScrollbarTransitionend),this.scrollbar.style.display=this.size?`block`:`none`,requestAnimationFrame(()=>{this.scrollbar.classList.remove(this.bem.is(`transparent`))})},200);hideScrollbar=Yt(()=>{this.cursorLeave=!0,!this.cursorDown&&(this.scrollbar.removeEventListener(`transitionend`,this.hideScrollbarTransitionend),this.scrollbar.addEventListener(`transitionend`,this.hideScrollbarTransitionend,{once:!0}),this.scrollbar.classList.add(this.bem.is(`transparent`)))},200);hideScrollbarTransitionend=()=>{this.scrollbar.style.display=this.cursorDown&&this.size?`block`:`none`};destroy(){this.ob.disconnect(),Ut.call(this),this.table.removeEventListener(`mouseenter`,this.showScrollbar),this.table.removeEventListener(`mouseleave`,this.hideScrollbar)}},Qn=class{scrollbarContainer;scrollbar;bem=u(`scrollbar`);constructor(t,n,r){this.tableModule=t,this.table=n,this.quill=r,this.scrollbarContainer=this.tableModule.addContainer(this.bem.be(`container`)),this.scrollbar=[new Zn(r,!0,n,this.scrollbarContainer),new Zn(r,!1,n,this.scrollbarContainer)];for(let e of this.scrollbar)this.scrollbarContainer.appendChild(e.scrollbar);this.quill.on(e.events.TEXT_CHANGE,this.updateWhenTextChange)}updateWhenTextChange=()=>{this.update()};hide(){for(let e of this.scrollbar)e.hideScrollbar()}show(){for(let e of this.scrollbar)e.showScrollbar()}update(){for(let e of this.scrollbar)e.calculateSize(),e.setScrollbarPosition()}destroy(){this.scrollbarContainer.remove(),this.quill.off(e.events.TEXT_CHANGE,this.updateWhenTextChange);for(let e of this.scrollbar)e.destroy()}};const $n=0;var er=class{options;boundary=null;scrollRecordEls=[];startScrollRecordPosition=[];selectedTableScrollX=0;selectedTableScrollY=0;selectedEditorScrollX=0;selectedEditorScrollY=0;selectedTds=[];cellSelectWrap;cellSelect;dragging=!1;scrollHandler=[];tableMenu;resizeObserver;table;isDisplaySelection=!1;bem=u(`selection`);lastSelection={anchorNode:null,anchorOffset:0,focusNode:null,focusOffset:0};constructor(t,n,i={}){this.tableModule=t,this.quill=n,this.options=this.resolveOptions(i),this.scrollRecordEls=[this.quill.root,document.documentElement],this.cellSelectWrap=t.addContainer(this.bem.b()),this.cellSelect=this.helpLinesInitial(),this.resizeObserver=Ht(()=>this.updateAfterEvent(),{ignoreFirstBind:!0}),this.resizeObserver.observe(this.quill.root),this.quill.root.addEventListener(`mousedown`,this.mouseDownHandler,{passive:!1}),document.addEventListener(`selectionchange`,this.selectionChangeHandler,{passive:!1}),this.quill.on(r.AFTER_TABLE_RESIZE,this.updateAfterEvent),this.quill.on(e.events.SELECTION_CHANGE,this.quillSelectionChangeHandler),this.quill.on(e.events.TEXT_CHANGE,this.updateAfterEvent),this.options.tableMenu&&(this.tableMenu=new this.options.tableMenu(t,n,this.options.tableMenuOptions)),this.hide()}updateAfterEvent=()=>{this.updateWithSelectedTds()};getFirstTextNode(e){for(let t of Array.from(e.childNodes))if(t.nodeType===Node.TEXT_NODE)return t;return e}getLastTextNode(e){for(let t=e.childNodes.length-1;t>=0;t--){let n=e.childNodes[t];if(n.nodeType===Node.TEXT_NODE)return n}return e}getNodeTailOffset(e){let t=document.createRange();return t.selectNodeContents(e),t.collapse(!1),t.startOffset}quillSelectionChangeHandler=(n,r,i)=>{if(i!==e.sources.API&&n&&!this.quill.composition.isComposing&&this.selectedTds.length>0){let e=this.quill.getFormat(n),[r]=this.quill.getLine(n.index),i=!!e[t.tableCellInner]&&!!r,a=this.selectedTds.some(e=>e.children.contains(r));if(i&&!a)try{let e=d(r,t.tableCellInner);this.selectedTds=[e],this.updateWithSelectedTds()}catch{}else i&&a||this.hide()}};setSelectionData(e,t){let{anchorNode:n,anchorOffset:r,focusNode:i,focusOffset:a}=t;if(!n||!i)return;let 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)}selectionDirectionUp(e){let{anchorNode:t,anchorOffset:n,focusNode:r,focusOffset:i}=e;if(!t||!r)return!1;if(t===r)return n>i;let 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}findWrapSelection(e){let t=null,n=0,r=null,i=0;for(let{node:a,offset:o}of e)a&&((!t||this.selectionDirectionUp({anchorNode:t,anchorOffset:n,focusNode:a,focusOffset:o}))&&(t=a,n=o),(!r||this.selectionDirectionUp({anchorNode:a,anchorOffset:o,focusNode:r,focusOffset:i}))&&(r=a,i=o));return{startNode:t,startOffset:n,endNode:r,endOffset:i}}resolveOptions(e){return Object.assign({selectColor:`#0589f340`,tableMenuOptions:{}},e)}selectionChangeHandler=()=>{let n=window.getSelection();if(!n)return;let{anchorNode:r,focusNode:i,anchorOffset:a,focusOffset:o}=n;if(!r||!i)return;let s=e.find(r),c=e.find(i);if(!s||!c||s.scroll!==this.quill.scroll||c.scroll!==this.quill.scroll)return;let l=p(s),u=p(c),d=l.has(t.tableColgroup),f=u.has(t.tableColgroup);if(d||f){let e=r,s=a,c=i,p=o;if(d){let n=l.get(t.tableWrapper),r=n.descendants(V);r.length>0&&(e=r[0].domNode,s=0)}if(f){let e=u.get(t.tableWrapper),n=e.descendants(V);n.length>0&&(c=n[0].domNode,p=0)}this.setSelectionData(n,{anchorNode:e,anchorOffset:s,focusNode:c,focusOffset:p});return}let m=l.has(t.tableCellInner),h=u.has(t.tableCellInner),g=m&&h;if(g){let e=l.get(t.tableCellInner),n=u.get(t.tableCellInner);g&&=e!==n}if(m&&h&&g||!m&&h||!h&&m){this.setSelectionData(n,this.lastSelection),this.selectedTds.length>0&&this.hide();return}this.lastSelection={anchorNode:r,anchorOffset:a,focusNode:i,focusOffset:o}};helpLinesInitial(){this.cellSelectWrap.style.setProperty(`--select-color`,this.options.selectColor);let e=document.createElement(`div`);return e.classList.add(this.bem.be(`line`)),this.cellSelectWrap.appendChild(e),e}computeSelectedTds(t,n){if(!this.table)return[];let r=e.find(this.table);if(!r)return[];let i=r.descendants(U)[0];if(!i)return[];let a=new Set(i.descendants(G).map((e,t)=>(e.index=t,e))),o=this.getScrollPositionDiff(),{rect:s}=yn(r);if(!s)return[];let c=t.x+o.x,l=t.y+o.y,u={x:Math.max(s.left,Math.min(n.x,c)),y:Math.max(s.top,Math.min(n.y,l)),x1:Math.min(s.right,Math.max(n.x,c)),y1:Math.min(s.bottom,Math.max(n.y,l))},d=new Set,f=!0;for(;f;){f=!1;for(let e of a){e.__rect||=e.domNode.getBoundingClientRect();let{x:t,y:n,right:r,bottom:i}=e.__rect;if(Rt({x:Math.floor(u.x),y:Math.floor(u.y),x1:Math.floor(u.x1),y1:Math.floor(u.y1)},{x:Math.floor(t),y:Math.floor(n),x1:Math.floor(r),y1:Math.floor(i)},$n,d.size===0)){d.add(e),a.delete(e),u={x:Math.min(u.x,t),y:Math.min(u.y,n),x1:Math.max(u.x1,r),y1:Math.max(u.y1,i)},f=!0;break}}}for(let e of[...d,...a])delete e.__rect;return this.boundary=zt({...u,width:u.x1-u.x,height:u.y1-u.y},this.quill.root),Array.from(d).sort((e,t)=>e.index-t.index).map(e=>(delete e.index,e.getCellInner()))}getScrollPositionDiff(){let{x:e,y:t}=this.getTableViewScroll(),{x:n,y:r}=Wt(this.quill.root);return this.selectedTableScrollX=e,this.selectedTableScrollY=t,this.selectedEditorScrollX=n,this.selectedEditorScrollY=r,this.startScrollRecordPosition.reduce((e,{x:t,y:n},r)=>{let{x:i,y:a}=Wt(this.scrollRecordEls[r]);return e.x+=t-i,e.y+=n-a,e},{x:0,y:0})}recordScrollPosition(){this.clearRecordScrollPosition();for(let e of this.scrollRecordEls)this.startScrollRecordPosition.push(Wt(e))}clearRecordScrollPosition(){this.startScrollRecordPosition=[]}mouseDownHandler=e=>{let{button:t,target:n,clientX:r,clientY:i}=e,a=n.closest(`.ql-table`),o=n.closest(`caption`);if(t!==0||!a||o)return;this.setSelectionTable(a);let s=a.dataset.tableId,c={x:r,y:i};this.recordScrollPosition(),this.selectedTds=this.computeSelectedTds(c,c),this.dragging=!0,this.show();let l=e=>{this.tableMenu&&this.tableMenu.hide(),this.tableModule.tableResize&&this.tableModule.tableResize.hide();let{button:t,target:n,clientX:r,clientY:i}=e,a=n.closest(`.ql-table`),o=n.closest(`caption`);if(t!==0||o||!a||a.dataset.tableId!==s)return;let l={x:r,y:i};this.selectedTds=this.computeSelectedTds(c,l),this.selectedTds.length>1&&this.quill.blur(),this.update()},u=()=>{document.body.removeEventListener(`mousemove`,l,!1),document.body.removeEventListener(`mouseup`,u,!1),this.dragging=!1,this.clearRecordScrollPosition(),this.tableMenu&&this.selectedTds.length>0&&this.tableMenu.show()};document.body.addEventListener(`mousemove`,l,!1),document.body.addEventListener(`mouseup`,u,!1)};updateWithSelectedTds(){if(this.selectedTds.length<=0)return;let e={x:1/0,y:1/0},t={x:-1/0,y:-1/0};for(let n of this.selectedTds){let r=n.domNode.getBoundingClientRect();e.x=Math.min(e.x,r.left),e.y=Math.min(e.y,r.top),t.x=Math.max(t.x,r.right),t.y=Math.max(t.y,r.bottom)}this.selectedTds=this.computeSelectedTds(e,t),this.selectedTds.length>0?this.update():this.hide()}update(){if(this.selectedTds.length===0||!this.boundary||!this.table)return;let{x:e,y:t}=Wt(this.quill.root),{x:n,y:r}=this.getTableViewScroll(),i=this.table.parentElement.getBoundingClientRect(),a=this.quill.root.getBoundingClientRect(),o=i.x-a.x,s=i.y-a.y;Object.assign(this.cellSelect.style,{left:`${this.selectedEditorScrollX*2-e+this.boundary.x+this.selectedTableScrollX-n-o}px`,top:`${this.selectedEditorScrollY*2-t+this.boundary.y+this.selectedTableScrollY-r-s}px`,width:`${this.boundary.width}px`,height:`${this.boundary.height}px`}),Object.assign(this.cellSelectWrap.style,{left:`${o}px`,top:`${s}px`,width:`${i.width}px`,height:`${i.height}px`}),!this.dragging&&this.tableMenu&&this.tableMenu.update()}getTableViewScroll(){return this.table?Wt(this.table.parentElement):{x:0,y:0}}setSelectionTable(e){this.table!==e&&(this.table=e,this.table?this.scrollRecordEls.push(this.table.parentElement):this.scrollRecordEls.pop())}removeCell=t=>{let n=this.quill.getSelection();if(!(n||t.key!==`Backspace`&&t.key!==`Delete`)){for(let e of this.selectedTds)e.deleteAt(0,e.length()-1);if(this.table){let t=e.find(this.table),n=t.descendants(V);this.selectedTds.length===n.length&&t.remove()}}};showDisplay(){Object.assign(this.cellSelectWrap.style,{display:`block`}),this.isDisplaySelection=!0,this.table&&this.resizeObserver.observe(this.table)}show(){this.table&&(Ut.call(this),this.update(),this.showDisplay(),document.addEventListener(`keydown`,this.removeCell),L.call(this,this.quill.root,()=>{this.update()}),L.call(this,this.table.parentElement,()=>{this.update()}))}hideDisplay(){Object.assign(this.cellSelectWrap.style,{display:`none`}),this.isDisplaySelection=!1,this.table&&this.resizeObserver.unobserve(this.table)}hide(){Ut.call(this),document.removeEventListener(`keydown`,this.removeCell),this.hideDisplay(),this.boundary=null,this.selectedTds=[],this.setSelectionTable(void 0),this.tableMenu&&this.tableMenu.hide()}destroy(){this.resizeObserver.disconnect(),this.hide(),this.cellSelectWrap.remove(),this.tableMenu&&this.tableMenu.destroy(),Ut.call(this),this.quill.root.removeEventListener(`mousedown`,this.mouseDownHandler),document.removeEventListener(`selectionchange`,this.selectionChangeHandler),this.quill.off(e.events.SELECTION_CHANGE,this.quillSelectionChangeHandler),this.quill.off(e.events.TEXT_CHANGE,this.updateAfterEvent),this.quill.on(r.AFTER_TABLE_RESIZE,this.updateAfterEvent)}};const tr=e.import(`parchment`),$=e.import(`delta`),nr=e.import(`ui/icons`),rr=e.import(`blots/break`),ir=e.import(`blots/block`),ar=e.import(`blots/block/embed`);function or(e,{tableId:n,rowId:r,colId:i}){let a={tableId:n,rowId:r,colId:i,colspan:1,rowspan:1},o=e.create(t.tableCell,a),s=e.create(t.tableCellInner,a),c=e.create(`block`);return c.appendChild(e.create(`break`)),s.appendChild(c),o.appendChild(s),o}function sr(e){s.delete(t.tableCellInner),Object.assign(t,e.blotName||{}),Object.assign(n,e.tableUpSize||{}),Object.assign(r,e.tableUpEvent||{}),Object.assign(i,e.tableUpInternal||{}),ur.moduleName=i.moduleName,ur.toolName=t.tableWrapper,z.blotName=t.container,Y.blotName=t.tableWrapper,q.blotName=t.tableMain,J.blotName=t.tableColgroup,K.blotName=t.tableCol,U.blotName=t.tableBody,H.blotName=t.tableRow,G.blotName=t.tableCell,V.blotName=t.tableCellInner,s.add(t.tableCellInner)}function cr(e,t){return de({onSelect:(n,r)=>{e.insertTable(n,r),t&&t.close()},customBtn:e.options.customBtn,texts:e.options.texts})}function lr(n){return{bindInHead:!1,key:n?`ArrowUp`:`ArrowDown`,collapsed:!0,format:[t.tableCellInner],handler(r,i){let a=n?`prev`:`next`,o=n?`tail`:`head`;if(i.line[a])return!0;let s=this.quill.selection.getBounds(r.index),c=i.line.domNode.getBoundingClientRect();if(!s||!c)return!0;if(n){if(s.top-c.top>3)return!0}else if(c.bottom-s.bottom>3)return!0;let l,u,d,p;try{[l,u,d,p]=f(i.line,[t.tableWrapper,t.tableMain,t.tableRow,t.tableCell])}catch{return!0}let m=u.getColIds(),h=l.descendants(W,0)[0],g;if(h){let e=window.getComputedStyle(h.domNode);g=a===`next`&&e.captionSide===`bottom`?h:a===`next`?l.next:h}else g=l[a];if(i.line[a]||!g)return!0;let _=d[a];if(_){let t=m.indexOf(p.colId),n=_.getCellByColId(m[t],a);if(!n)return!0;let r=n.children[o];r.children&&(r=r.children[o]);let s=r.offset(this.quill.scroll)+Math.min(i.offset,r.length()-1);this.quill.setSelection(s,0,e.sources.USER)}else{let t=g.offset(this.quill.scroll)+(n?g.length()-1:0);this.quill.setSelection(t,0,e.sources.USER)}return!1}}}var ur=class r{static moduleName=i.moduleName;static toolName=t.tableWrapper;static keyboradHandler={"forbid remove table by backspace":{bindInHead:!0,key:`Backspace`,collapsed:!0,offset:0,handler(e,n){let r=this.quill.getLine(e.index),i=r[0];if(i.prev instanceof Y)return i.prev.remove(),!1;if(n.format[t.tableCellInner]){let e=i.offset(d(i,t.tableCellInner));if(e===0)return!1}return!0}},"forbid remove table by delete":{bindInHead:!0,key:`Delete`,collapsed:!0,handler(e,n){let r=this.quill.getLine(e.index),i=r[0],a=r[1];if((i.next instanceof Y||i.next instanceof K)&&a===i.length()-1)return!1;if(n.format[t.tableCellInner]){let e=d(i,t.tableCellInner);if(i===e.children.tail&&a===i.length()-1)return!1}return!0}},"table up":lr(!0),"table down":lr(!1),"table caption break":{bindInHead:!0,key:`Enter`,shiftKey:null,format:[t.tableCaption],handler(e,t){return!1}}};static register(){Y.allowedChildren=[q],q.allowedChildren=[U,J,W],q.requiredContainer=Y,W.requiredContainer=q,J.allowedChildren=[K],J.requiredContainer=q,U.allowedChildren=[H],U.requiredContainer=q,H.allowedChildren=[G],G.requiredContainer=U,G.allowedChildren=[V,rr],G.requiredContainer=H,V.requiredContainer=G;let n=new Set([`table`]),r=Object.entries(e.imports).filter(([e,t])=>{let r=e.split(`formats/`)[1];return e.startsWith(`formats/`)&&!n.has(r)&&!_(t,tr.Attributor)&&(_(t,ir)||_(t,ar))}),i=r.reduce((e,[t,n])=>{let r=_(n,ar)?cn:on;return e[t]=class extends g(n,[r]){static register(){}},e},{});e.register({"blots/scroll":fn,"blots/block":on,"blots/block/embed":cn,...i,[`blots/${t.container}`]:z,[`formats/${t.tableCell}`]:G,[`formats/${t.tableCellInner}`]:V,[`formats/${t.tableRow}`]:H,[`formats/${t.tableBody}`]:U,[`formats/${t.tableCol}`]:K,[`formats/${t.tableColgroup}`]:J,[`formats/${t.tableCaption}`]:W,[`formats/${t.tableMain}`]:q,[`formats/${t.tableWrapper}`]:Y,"modules/clipboard":Tn},!0)}quill;options;toolBox;fixTableByLisenter=Yt(this.balanceTables,100);selector;table;tableSelection;tableResize;tableScrollbar;tableAlign;tableResizeScale;resizeOb;get statics(){return this.constructor}constructor(t,n){if(this.quill=t,this.options=this.resolveOptions(n||{}),this.toolBox=this.initialContainer(),!this.options.scrollbar){let e=u(`scrollbar`);this.quill.container.classList.add(e.bm(`origin`))}this.options.selection&&(this.tableSelection=new this.options.selection(this,this.quill,this.options.selectionOptions));let i=this.quill.getModule(`toolbar`);if(i&&this.quill.theme.pickers){let[,e]=(i.controls||[]).find(([e])=>e===this.statics.toolName)||[];if(e&&e.tagName.toLocaleLowerCase()===`select`){let t=this.quill.theme.pickers.find(t=>t.select===e);t&&(t.label.innerHTML=this.options.icon,this.buildCustomSelect(this.options.customSelect,t),t.label.addEventListener(`mousedown`,()=>{if(!this.selector||!t)return;let e=this.selector.getBoundingClientRect(),{leftLimited:n}=Vt(e);if(n){let e=t.label.getBoundingClientRect();Object.assign(t.options.style,{transform:`translateX(calc(-100% + ${e.width}px))`})}else Object.assign(t.options.style,{transform:void 0})}))}}let a=this.quill.getModule(`keyboard`);for(let e of Object.values(r.keyboradHandler))e.bindInHead?a.bindings[e.key].unshift(e):a.addBinding(e.key,e);this.quill.root.addEventListener(`click`,e=>{let t=e.composedPath();if(!t||t.length<=0)return;let n=t.find(e=>e.tagName&&e.tagName.toUpperCase()===`TABLE`&&e.classList.contains(`ql-table`));if(n){if(this.table===n){this.tableSelection&&this.tableSelection.show(),this.tableAlign&&this.tableAlign.update(),this.tableResize&&this.tableResize.update(),this.tableScrollbar&&this.tableScrollbar.update();return}this.table&&this.hideTableTools(),this.showTableTools(n)}else this.table&&this.hideTableTools()},!1),this.quill.on(e.events.EDITOR_CHANGE,t=>{t===e.events.TEXT_CHANGE&&(!this.table||!this.quill.root.contains(this.table))&&this.hideTableTools()}),this.quillHack(),this.listenBalanceCells()}initialContainer(){let e=u(`toolbox`),t=this.quill.addContainer(e.b()),n=()=>{let e=this.quill.root.getBoundingClientRect(),{offsetLeft:n,offsetTop:r}=this.quill.root;Object.assign(t.style,{top:`${r}px`,left:`${n}px`,width:`${e.width}px`,height:`${e.height}px`})};return this.resizeOb=new ResizeObserver(n),this.resizeOb.observe(this.quill.root),t}addContainer(e){if(w(e)){let t=document.createElement(`div`);for(let n of e.split(` `))t.classList.add(n);return this.toolBox.appendChild(t),t}else return this.toolBox.appendChild(e),e}resolveOptions(e){return Object.assign({customBtn:!1,texts:this.resolveTexts(e.texts||{}),full:!1,fullSwitch:!0,icon:nr.table,selectionOptions:{},alignOptions:{},scrollbarOptions:{},resizeOptions:{},resizeScaleOptions:{},autoMergeCell:!0},e)}resolveTexts(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)}quillHack(){let n=this.quill.getSemanticHTML;this.quill.getSemanticHTML=(r=0,i)=>{let a=n.call(this.quill,r,i),o=e.import(`formats/${t.tableWrapper}`),s=new DOMParser,c=s.parseFromString(a,`text/html`);for(let e of Array.from(c.querySelectorAll(`.${o.className} caption[contenteditable], .${o.className} td > [contenteditable]`)))e.removeAttribute(`contenteditable`);return c.body.innerHTML};let r=this.quill.format;this.quill.format=function(n,a,o=e.sources.API){let s=this.scroll.query(n);if(!(s.prototype instanceof tr.EmbedBlot)){let e=this.getModule(i.moduleName),s=this.getSelection(!0),c=this.getFormat(s);if(!c[t.tableCellInner]||s.length>0||e&&e.tableSelection&&e.tableSelection.selectedTds.length<=1)return r.call(this,n,a,o);if(e&&e.tableSelection&&e.tableSelection.selectedTds.length>0){let t=e.tableSelection.selectedTds,r=!1,i=[];for(let e of t){let t=e.offset(this.scroll),o=e.length();i.push({index:t,length:o});let s=this.getFormat(t,o);s[n]!==a&&(r=!0)}let s=r?a:!1,c=new $;for(let[e,{index:t,length:r}]of i.entries()){let a=e===0?0:i[e-1].index+i[e-1].length;c.retain(t-a).retain(r,{[n]:s})}let l=this.updateContents(c,o);return this.blur(),l}}return r.call(this,n,a,o)};let a=this.quill.theme.modules.toolbar;if(a){let n=a.handlers?.clean;if(n){let r=(e,n,r=()=>``)=>{let i=this.quill.getText(e,n),[a,o]=this.quill.getLine(e+n),s=0,c=new $;a!=null&&(s=a.length()-o,c=a.delta().slice(o,o+s-1).insert(`
|
|
125
125
|
`));let l=this.quill.getContents(e,n+s),u=l.diff(new $().insert(i).concat(c)),d=0,f=u.ops.map(e=>{let{attributes:n,...i}=e;if(e.insert?d-=w(e.insert)?e.insert.length:1:e.retain?d+=re(e.retain)?e.retain:1:e.delete&&(d+=e.delete),n){let{[t.tableCellInner]:e,...a}=n;if(r){let e=l.slice(d-1,d).ops[0];if(e&&e.attributes&&e.attributes[t.tableCellInner]){let n=e.attributes[t.tableCellInner],{style:o,...s}=n,c=r(o);return c?{...i,attributes:{...a,[t.tableCellInner]:{style:c,...s}}}:{...i,attributes:{...a,[t.tableCellInner]:s}}}}return{...i,attributes:{...a}}}return e});return new $(f)};a.handlers.clean=function(a){let o=this.quill.getModule(i.moduleName),s=this.quill.getSelection();if(s&&s.length>0){let n=this.quill.getFormat(s);if(n[t.tableCellInner]){let t=r(s.index,s.length,!1),n=new $().retain(s.index).concat(t);this.quill.updateContents(n,e.sources.USER);return}}if(o&&o.tableSelection&&o.tableSelection.selectedTds.length>0&&o.tableSelection.table){let t=e.find(o.tableSelection.table);if(!t){console.warn(`TableMainFormat not found`);return}let n=o.tableSelection.selectedTds,i=new Set,a=[];for(let e of n)if(e.parent instanceof G){for(let t of e.parent.getNearByCell(`top`)){if(i.has(t))continue;i.add(t),a.push({td:t,cleanBorder:`bottom`})}for(let t of e.parent.getNearByCell(`left`)){if(i.has(t))continue;i.add(t),a.push({td:t,cleanBorder:`right`})}i.add(e.parent),a.push({td:e.parent,cleanBorder:!0})}let s=t.descendants(G),c=new Map(s.map((e,t)=>[e,t]));a.sort((e,t)=>c.get(e.td)-c.get(t.td));let l=new $,u=0;for(let{td:e,cleanBorder:t}of a){let n=e.getCellInner().offset(this.quill.scroll),i=e.getCellInner().length(),a=r(n,i-1,e=>{if(!e||t===!0)return``;let n=Gt(e),r=Object.keys(n).filter(e=>!e.startsWith(Jt(`border-${t}`))).reduce((e,t)=>(e[t]=n[t],e),{});return Kt(r)}),o=new $().retain(n-u).concat(a);l=l.concat(o),u=n+i}this.quill.updateContents(l,e.sources.USER),n.length>1&&this.quill.blur();return}return n.call(this,a)}}}}showTableTools(e){e&&(this.table=e,this.tableSelection?.show(),this.options.align&&(this.tableAlign=new this.options.align(this,e,this.quill,this.options.alignOptions)),this.options.scrollbar&&(this.tableScrollbar=new this.options.scrollbar(this,e,this.quill,this.options.scrollbarOptions)),this.options.resize&&(this.tableResize=new this.options.resize(this,e,this.quill,this.options.resizeOptions)),this.options.resizeScale&&(this.tableResizeScale=new this.options.resizeScale(this,e,this.quill,this.options.resizeScaleOptions)))}hideTableTools(){this.tableSelection?.hide(),this.tableScrollbar&&(this.tableScrollbar.destroy(),this.tableScrollbar=void 0),this.tableAlign&&(this.tableAlign.destroy(),this.tableAlign=void 0),this.tableResize&&(this.tableResize.destroy(),this.tableResize=void 0),this.tableResizeScale&&this.tableResizeScale.destroy(),this.table=void 0}async buildCustomSelect(e,t){if(!e||!S(e))return;let n=document.createElement(`div`);if(n.classList.add(`ql-custom-select`),this.selector=await e(this,t),n.appendChild(this.selector),this.options.fullSwitch){let e=u(`creator`),t=document.createElement(`label`);t.classList.add(e.be(`checkbox`));let r=document.createElement(`input`);r.type=`checkbox`,r.checked=this.options.full,r.addEventListener(`change`,()=>{this.options.full=r.checked});let i=document.createElement(`span`);i.textContent=this.options.texts.fullCheckboxText,t.appendChild(r),t.appendChild(i),n.appendChild(t)}t.options.innerHTML=``,t.options.appendChild(n)}setCellAttrs(e,t,n,r=!1){if(e.length!==0)for(let i of e)i.setFormatValue(t,n,r)}getTextByCell(e){let t=``;for(let n of e){let e=n.offset(this.quill.scroll),r=n.length();for(let n of this.quill.getContents(e,r).ops)w(n.insert)&&(t+=n.insert)}return t}getHTMLByCell(e,n=!1){if(e.length===0)return``;let r=null;try{for(let n of e){let e=d(n,t.tableMain);if(r||=e,e!==r)return console.error(`tableMain is not same`),``}}catch{return console.error(`tds must be in same tableMain`),``}if(!r)return``;let i=this.quill.getIndex(r),a=r.length(),o=this.quill.getSemanticHTML(i,a),s=new DOMParser,c=s.parseFromString(o,`text/html`),l=[],u=new Set,f=new Set;for(let t of e)u.add(t.colId),f.add(`${t.rowId}-${t.colId}`);for(let e of Array.from(c.querySelectorAll(`col`)))u.has(e.dataset.colId)?l.push(e.getAttribute(`width`)):e.remove();let p=0,m=null;for(let e of Array.from(c.querySelectorAll(`td`)))if(f.has(`${e.dataset.rowId}-${e.dataset.colId}`))m!==e.dataset.rowId&&(p+=1,m=e.dataset.rowId);else{let t=e.parentElement;e.remove(),t&&t.children.length<=0&&t.remove()}let h=Array.from(c.querySelectorAll(`col`)),g=h.map(e=>K.value(e));if(r.full){let e=g.reduce((e,t)=>t.width+e,0);for(let[t,n]of g.entries())n.width=Math.round(n.width/e*100),h[t].setAttribute(`width`,`${n.width}%`)}else{let e=0;for(let t of g)e+=t.width;let t=c.querySelector(`table`);t.style.width=`${e}px`}if(n){let t=r.getRows();if(p===t.length)this.removeCol(e);else for(let t of e)t.domNode.innerHTML=`<p><br></p>`}return c.body.innerHTML}insertTable(r,i){if(r>=30||i>=30)throw Error(`Both rows and columns must be less than 30.`);this.quill.focus();let a=this.quill.getSelection();if(a==null)return;let[o]=this.quill.getLeaf(a.index);if(!o)return;if(l(o))throw Error(`Not supported ${o.statics.blotName} insert into table.`);let s=this.calculateTableCellBorderWidth(),c=getComputedStyle(this.quill.root),u=Number.parseInt(c.paddingLeft),d=Number.parseInt(c.paddingRight),f=Number.parseInt(c.width)-u-d-s,p=R(),m=Array(i).fill(0).map(()=>R()),h=this.options.full?`${Math.max(1/i*100,n.colMinWidthPre)}%`:`${Math.max(Math.floor(f/i),n.colMinWidthPx)}px`,g=[{retain:a.index}],_=this.quill.getContents(a.index,1),[,v]=this.quill.getLine(a.index);_.ops[0].insert!==`
|
|
126
126
|
`&&v!==0&&g.push({insert:`
|
|
127
127
|
`});for(let e=0;e<i;e++)g.push({insert:{[t.tableCol]:{width:h,tableId:p,colId:m[e],full:this.options.full}}});for(let e=0;e<r;e++){let e=R();for(let n=0;n<i;n++)g.push({insert:`
|