diff --git a/.gitignore b/.gitignore index a1e6638..d260fdb 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,6 @@ node_modules +.idea +*.iml *.lock *-lock.json .DS_Store diff --git a/dist/demo/demo1.js b/dist/demo/demo1.js index bb44a32..c146171 100644 --- a/dist/demo/demo1.js +++ b/dist/demo/demo1.js @@ -73,7 +73,7 @@ return /******/ (function(modules) { // webpackBootstrap /******/ /******/ var hotApplyOnUpdate = true; /******/ // eslint-disable-next-line no-unused-vars -/******/ var hotCurrentHash = "ced44c7892a78034ffe4"; +/******/ var hotCurrentHash = "1b0e2a34d0e3d2fc104c"; /******/ var hotRequestTimeout = 10000; /******/ var hotCurrentModuleData = {}; /******/ var hotCurrentChildModule; @@ -166,6 +166,7 @@ return /******/ (function(modules) { // webpackBootstrap /******/ _declinedDependencies: {}, /******/ _selfAccepted: false, /******/ _selfDeclined: false, +/******/ _selfInvalidated: false, /******/ _disposeHandlers: [], /******/ _main: hotCurrentChildModule !== moduleId, /******/ @@ -196,6 +197,29 @@ return /******/ (function(modules) { // webpackBootstrap /******/ var idx = hot._disposeHandlers.indexOf(callback); /******/ if (idx >= 0) hot._disposeHandlers.splice(idx, 1); /******/ }, +/******/ invalidate: function() { +/******/ this._selfInvalidated = true; +/******/ switch (hotStatus) { +/******/ case "idle": +/******/ hotUpdate = {}; +/******/ hotUpdate[moduleId] = modules[moduleId]; +/******/ hotSetStatus("ready"); +/******/ break; +/******/ case "ready": +/******/ hotApplyInvalidatedModule(moduleId); +/******/ break; +/******/ case "prepare": +/******/ case "check": +/******/ case "dispose": +/******/ case "apply": +/******/ (hotQueuedInvalidatedModules = +/******/ hotQueuedInvalidatedModules || []).push(moduleId); +/******/ break; +/******/ default: +/******/ // ignore requests in error states +/******/ break; +/******/ } +/******/ }, /******/ /******/ // Management API /******/ check: hotCheck, @@ -237,7 +261,7 @@ return /******/ (function(modules) { // webpackBootstrap /******/ var hotDeferred; /******/ /******/ // The update info -/******/ var hotUpdate, hotUpdateNewHash; +/******/ var hotUpdate, hotUpdateNewHash, hotQueuedInvalidatedModules; /******/ /******/ function toModuleId(id) { /******/ var isNumber = +id + "" === id; @@ -252,7 +276,7 @@ return /******/ (function(modules) { // webpackBootstrap /******/ hotSetStatus("check"); /******/ return hotDownloadManifest(hotRequestTimeout).then(function(update) { /******/ if (!update) { -/******/ hotSetStatus("idle"); +/******/ hotSetStatus(hotApplyInvalidatedModules() ? "ready" : "idle"); /******/ return null; /******/ } /******/ hotRequestedFilesMap = {}; @@ -271,7 +295,6 @@ return /******/ (function(modules) { // webpackBootstrap /******/ var chunkId = 0; /******/ // eslint-disable-next-line no-lone-blocks /******/ { -/******/ /*globals chunkId */ /******/ hotEnsureUpdateChunk(chunkId); /******/ } /******/ if ( @@ -346,6 +369,11 @@ return /******/ (function(modules) { // webpackBootstrap /******/ if (hotStatus !== "ready") /******/ throw new Error("apply() is only allowed in ready status"); /******/ options = options || {}; +/******/ return hotApplyInternal(options); +/******/ } +/******/ +/******/ function hotApplyInternal(options) { +/******/ hotApplyInvalidatedModules(); /******/ /******/ var cb; /******/ var i; @@ -368,7 +396,11 @@ return /******/ (function(modules) { // webpackBootstrap /******/ var moduleId = queueItem.id; /******/ var chain = queueItem.chain; /******/ module = installedModules[moduleId]; -/******/ if (!module || module.hot._selfAccepted) continue; +/******/ if ( +/******/ !module || +/******/ (module.hot._selfAccepted && !module.hot._selfInvalidated) +/******/ ) +/******/ continue; /******/ if (module.hot._selfDeclined) { /******/ return { /******/ type: "self-declined", @@ -536,10 +568,13 @@ return /******/ (function(modules) { // webpackBootstrap /******/ installedModules[moduleId] && /******/ installedModules[moduleId].hot._selfAccepted && /******/ // removed self-accepted modules should not be required -/******/ appliedUpdate[moduleId] !== warnUnexpectedRequire +/******/ appliedUpdate[moduleId] !== warnUnexpectedRequire && +/******/ // when called invalidate self-accepting is not possible +/******/ !installedModules[moduleId].hot._selfInvalidated /******/ ) { /******/ outdatedSelfAcceptedModules.push({ /******/ module: moduleId, +/******/ parents: installedModules[moduleId].parents.slice(), /******/ errorHandler: installedModules[moduleId].hot._selfAccepted /******/ }); /******/ } @@ -612,7 +647,11 @@ return /******/ (function(modules) { // webpackBootstrap /******/ // Now in "apply" phase /******/ hotSetStatus("apply"); /******/ -/******/ hotCurrentHash = hotUpdateNewHash; +/******/ if (hotUpdateNewHash !== undefined) { +/******/ hotCurrentHash = hotUpdateNewHash; +/******/ hotUpdateNewHash = undefined; +/******/ } +/******/ hotUpdate = undefined; /******/ /******/ // insert new code /******/ for (moduleId in appliedUpdate) { @@ -665,7 +704,8 @@ return /******/ (function(modules) { // webpackBootstrap /******/ for (i = 0; i < outdatedSelfAcceptedModules.length; i++) { /******/ var item = outdatedSelfAcceptedModules[i]; /******/ moduleId = item.module; -/******/ hotCurrentParents = [moduleId]; +/******/ hotCurrentParents = item.parents; +/******/ hotCurrentChildModule = moduleId; /******/ try { /******/ __webpack_require__(moduleId); /******/ } catch (err) { @@ -707,12 +747,35 @@ return /******/ (function(modules) { // webpackBootstrap /******/ return Promise.reject(error); /******/ } /******/ +/******/ if (hotQueuedInvalidatedModules) { +/******/ return hotApplyInternal(options).then(function(list) { +/******/ outdatedModules.forEach(function(moduleId) { +/******/ if (list.indexOf(moduleId) < 0) list.push(moduleId); +/******/ }); +/******/ return list; +/******/ }); +/******/ } +/******/ /******/ hotSetStatus("idle"); /******/ return new Promise(function(resolve) { /******/ resolve(outdatedModules); /******/ }); /******/ } /******/ +/******/ function hotApplyInvalidatedModules() { +/******/ if (hotQueuedInvalidatedModules) { +/******/ if (!hotUpdate) hotUpdate = {}; +/******/ hotQueuedInvalidatedModules.forEach(hotApplyInvalidatedModule); +/******/ hotQueuedInvalidatedModules = undefined; +/******/ return true; +/******/ } +/******/ } +/******/ +/******/ function hotApplyInvalidatedModule(moduleId) { +/******/ if (!Object.prototype.hasOwnProperty.call(hotUpdate, moduleId)) +/******/ hotUpdate[moduleId] = modules[moduleId]; +/******/ } +/******/ /******/ // The module cache /******/ var installedModules = {}; /******/ @@ -801,7 +864,7 @@ return /******/ (function(modules) { // webpackBootstrap /******/ /******/ /******/ // Load entry module and return exports -/******/ return hotCreateRequire(13)(__webpack_require__.s = 13); +/******/ return hotCreateRequire(14)(__webpack_require__.s = 14); /******/ }) /************************************************************************/ /******/ ([ @@ -866,9 +929,134 @@ module.exports = " 1 && arguments[1] !== undefined ? arguments[1] : []; - let editorWrapper = arguments.length > 2 ? arguments[2] : undefined; + deleteColumns(compareRect, delIndexes = [], editorWrapper) { const [body] = this.descendants(TableBody); if (body == null || body.children.head == null) return; const tableCells = this.descendants(TableCell); @@ -1808,9 +1994,7 @@ class table_TableContainer extends Container { } } - insertColumn(compareRect, colIndex) { - let isRight = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true; - let editorWrapper = arguments.length > 3 ? arguments[3] : undefined; + insertColumn(compareRect, colIndex, isRight = true, editorWrapper) { const [body] = this.descendants(TableBody); const [tableColGroup] = this.descendants(TableColGroup); const tableCols = this.descendants(TableCol); @@ -2540,12 +2724,11 @@ class table_operation_menu_TableOperationMenu { return null; } - menuInitial(_ref) { - let { - table, - left, - top - } = _ref; + menuInitial({ + table, + left, + top + }) { this.domNode = document.createElement('div'); this.domNode.classList.add('qlbt-operation-menu'); css(this.domNode, { @@ -2618,12 +2801,11 @@ class table_operation_menu_TableOperationMenu { return node; } - menuItemCreator(_ref2) { - let { - text, - iconSrc, - handler - } = _ref2; + menuItemCreator({ + text, + iconSrc, + handler + }) { const node = document.createElement('div'); node.classList.add('qlbt-operation-menu-item'); const iconSpan = document.createElement('span'); @@ -2663,6 +2845,100 @@ function getColToolCellIndexesByBoundary(cells, boundary, conditionFn, container return findIndexes; }, []); } +// CONCATENATED MODULE: ./src/ui/table-picker.js + +const Picker = external_commonjs_quill_commonjs2_quill_amd_quill_root_Quill_default.a.import('ui/picker'); + +class TablePicker extends Picker { + constructor(select, label) { + super(select); + this.label.innerHTML = label; + this.container.classList.add('ql-table-picker'); + } + + buildItem(option) { + const item = super.buildItem(option); + item.addEventListener('mouseover', () => { + let value = item.getAttribute('data-value').split('x'); + let row = parseInt(value[1]); + let column = parseInt(value[0]); + let items = Array.from(this.container.querySelectorAll('.ql-picker-item')); + let lastItem = this.container.querySelector('.ql-picker-item:last-child'); + value = lastItem.getAttribute('data-value').split('x'); // let rows = parseInt(value[1]); + + let cols = parseInt(value[0]); + items.forEach(i => { + i.classList.remove('hover'); + }); + + for (let r = 0; r < row; r++) { + items.slice(r * cols, r * cols + column).forEach(i => { + i.classList.add('hover'); + }); + } + }); + return item; + } + + selectItem(item, trigger = false) { + super.selectItem(item, trigger); + if (item == null) return; + item.classList.remove('ql-selected'); + + if (item.label) { + item.label.removeAttribute('data-value'); + item.label.removeAttribute('data-label'); + } + + Array.from(this.container.querySelectorAll('.hover')).forEach(item => { + item.classList.remove('hover'); + }); + } + +} + +/* harmony default export */ var table_picker = (TablePicker); +// EXTERNAL MODULE: ./node_modules/extend/index.js +var extend = __webpack_require__(10); +var extend_default = /*#__PURE__*/__webpack_require__.n(extend); + +// CONCATENATED MODULE: ./src/themes/better-table-snow.js + + + +const SnowTheme = external_commonjs_quill_commonjs2_quill_amd_quill_root_Quill_default.a.import('themes/snow'); + +class better_table_snow_BetterTableSnowTheme extends SnowTheme { + constructor(quill, options) { + super(quill, options); + } + + buildPickers(selects, icons) { + selects = Array.from(selects); + let pickers = selects.map((select, index, selects) => { + if (select.classList.contains('ql-better-table')) { + selects.splice(index, 1); + + if (select.querySelector('option') == null) { + for (let r = 1; r <= 8; r++) { + for (let c = 1; c <= 10; c++) { + const option = document.createElement('option'); + option.setAttribute('value', c + 'x' + r); + select.appendChild(option); + } + } + } + + return new table_picker(select, icons.table); + } + }); + super.buildPickers(selects, icons); + this.pickers = extend_default()([], this.pickers, pickers); + } + +} + +/* harmony default export */ var better_table_snow = (better_table_snow_BetterTableSnowTheme); // CONCATENATED MODULE: ./src/utils/node-matchers.js @@ -2876,6 +3152,8 @@ function matchTable(node, delta, scroll) { + + // import table node matchers @@ -2896,6 +3174,9 @@ class quill_better_table_BetterTable extends Module { external_commonjs_quill_commonjs2_quill_amd_quill_root_Quill_default.a.register(table_TableViewWrapper, true); external_commonjs_quill_commonjs2_quill_amd_quill_root_Quill_default.a.register(table_TableViewWrapper, true); // register customized Header,overwriting quill built-in Header // Quill.register('formats/header', Header, true); + + external_commonjs_quill_commonjs2_quill_amd_quill_root_Quill_default.a.register('themes/better-table-snow', better_table_snow, true); + external_commonjs_quill_commonjs2_quill_amd_quill_root_Quill_default.a.register('ui/table-picker', table_picker, true); } constructor(quill, options) { @@ -2951,12 +3232,12 @@ class quill_better_table_BetterTable extends Module { cell: cellNode, left: evt.pageX, top: evt.pageY - }, quill, options.operationMenu); + }, quill, options.operationMenu || {}); } }, false); // add keyboard binding:Backspace // prevent user hits backspace to delete table cell + // const KeyBoard = quill.getModule('keyboard') - const KeyBoard = quill.getModule('keyboard'); quill.keyboard.addBinding({ key: 'Backspace' }, {}, function (range, context) { @@ -2988,10 +3269,16 @@ class quill_better_table_BetterTable extends Module { quill.clipboard.matchers = quill.clipboard.matchers.filter(matcher => { return matcher[0] !== 'tr'; }); + const toolbar = quill.getModule('toolbar'); + const input = toolbar.container.querySelector('select.ql-better-table'); + + if (toolbar && input) { + toolbar.addHandler('better-table', this.insertTable); + toolbar.attach(input); + } } - getTable() { - let range = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : this.quill.getSelection(); + getTable(range = this.quill.getSelection()) { if (range == null) return [null, null, null, -1]; const [cellLine, offset] = this.quill.getLine(range.index); @@ -3006,6 +3293,16 @@ class quill_better_table_BetterTable extends Module { } insertTable(rows, columns) { + if (!columns) { + if (rows.match(/^\d+x\d+$/)) { + let tmp = rows.split('x'); + columns = parseInt(tmp[0]); + rows = parseInt(tmp[1]); + } else { + return; + } + } + const range = this.quill.getSelection(true); if (range == null) return; let currentBlot = this.quill.getLeaf(range.index)[0]; @@ -3068,12 +3365,7 @@ quill_better_table_BetterTable.keyboardBindings = { handler(range, context) { const [line, offset] = this.quill.getLine(range.index); - - if (!line.prev || line.prev.statics.blotName !== 'table-cell-line') { - return false; - } - - return true; + return !(!line.prev || line.prev.statics.blotName !== 'table-cell-line'); } }, @@ -3224,20 +3516,20 @@ function isInTableCell(current) { /* harmony default export */ var quill_better_table = __webpack_exports__["default"] = (quill_better_table_BetterTable); /***/ }), -/* 11 */ +/* 12 */ /***/ (function(module, exports, __webpack_require__) { // extracted by mini-css-extract-plugin /***/ }), -/* 12 */, -/* 13 */ +/* 13 */, +/* 14 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; __webpack_require__.r(__webpack_exports__); -/* harmony import */ var src_quill_better_table_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(10); -/* harmony import */ var src_assets_quill_better_table_scss__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(11); +/* harmony import */ var src_quill_better_table_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(11); +/* harmony import */ var src_assets_quill_better_table_scss__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(12); /* harmony import */ var src_assets_quill_better_table_scss__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(src_assets_quill_better_table_scss__WEBPACK_IMPORTED_MODULE_1__); // import better-table styles file diff --git a/dist/demo/demo1.js.css b/dist/demo/demo1.js.css index cec18b9..3ed923d 100644 --- a/dist/demo/demo1.js.css +++ b/dist/demo/demo1.js.css @@ -1,117 +1,2 @@ -.ql-container .qlbt-selection-line.qlbt-selection-line-left::before { - position: absolute; - left: -2px; - top: -2px; - content: ''; - width: 5px; - height: 5px; - background-color: #0589f3; - border-radius: 5px; } - -.ql-container .qlbt-selection-line.qlbt-selection-line-right::before { - position: absolute; - right: -2px; - bottom: -3px; - content: ''; - width: 5px; - height: 5px; - background-color: #0589f3; - border-radius: 5px; } - -.quill-better-table-wrapper { - overflow-x: auto; } - -table.quill-better-table { - table-layout: fixed; - border-collapse: collapse; } - table.quill-better-table td { - border: 1px solid #000; - padding: 2px 5px; } - -.qlbt-operation-menu { - background-color: #fff; - box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15); - font-size: 14px; - z-index: 100; - overflow: hidden; } - .qlbt-operation-menu .qlbt-operation-menu-dividing { - height: 1px; - background-color: #efefef; } - .qlbt-operation-menu .qlbt-operation-menu-subtitle { - color: #999; - font-size: 14px; - padding: 5px 16px; } - .qlbt-operation-menu .qlbt-operation-color-picker { - display: flex; - align-items: center; - flex-wrap: wrap; - padding: 0 16px 10px; - background-color: #fff; - overflow: hidden; } - .qlbt-operation-menu .qlbt-operation-color-picker .qlbt-operation-color-picker-item { - width: 20px; - height: 20px; - border: 1px solid #595959; - margin-right: 5px; - margin-bottom: 5px; - cursor: pointer; } - .qlbt-operation-menu .qlbt-operation-menu-item { - display: flex; - align-items: center; - padding: 10px 16px; - background-color: #fff; - cursor: pointer; - color: #595959; - overflow: hidden; - text-overflow: ellipsis; } - .qlbt-operation-menu .qlbt-operation-menu-item:hover { - background-color: #efefef; } - .qlbt-operation-menu .qlbt-operation-menu-item .qlbt-operation-menu-icon { - margin-right: 8px; - height: 20px; - width: 20px; - font-size: 0; } - -.qlbt-col-tool { - position: absolute; - display: flex; - align-items: flex-end; - overflow: hidden; - z-index: 99; - height: 16px; } - .qlbt-col-tool .qlbt-col-tool-cell { - position: relative; - background-color: #fff; - border-top: 1px solid #000; - border-right: 1px solid #000; - border-bottom: 1px solid #000; } - .qlbt-col-tool .qlbt-col-tool-cell:first-child { - border-left: 1px solid #000; } - .qlbt-col-tool .qlbt-col-tool-cell-holder { - position: absolute; - right: -1px; - top: 0; - bottom: 0; - z-index: 3; - width: 1px; - background-color: transparent; - cursor: ew-resize; } - .qlbt-col-tool .qlbt-col-tool-cell-holder:hover { - background-color: #0589f3; } - .qlbt-col-tool .qlbt-col-tool-cell-holder::before { - content: ""; - position: absolute; - top: 0; - left: -6px; - display: block; - width: 8px; - height: 100%; } - .qlbt-col-tool .qlbt-col-tool-cell-holder::after { - content: ""; - position: absolute; - top: 0; - right: -6px; - display: block; - width: 8px; - height: 100%; } +.ql-container .qlbt-selection-line.qlbt-selection-line-left::before{position:absolute;left:-2px;top:-2px;content:'';width:5px;height:5px;background-color:#0589f3;border-radius:5px}.ql-container .qlbt-selection-line.qlbt-selection-line-right::before{position:absolute;right:-2px;bottom:-3px;content:'';width:5px;height:5px;background-color:#0589f3;border-radius:5px}.quill-better-table-wrapper{overflow-x:auto}table.quill-better-table{table-layout:fixed;border-collapse:collapse}table.quill-better-table td{border:1px solid #000;padding:2px 5px}.qlbt-operation-menu{background-color:#fff;box-shadow:0 2px 8px rgba(0,0,0,0.15);font-size:14px;z-index:100;overflow:hidden}.qlbt-operation-menu .qlbt-operation-menu-dividing{height:1px;background-color:#efefef}.qlbt-operation-menu .qlbt-operation-menu-subtitle{color:#999;font-size:14px;padding:5px 16px}.qlbt-operation-menu .qlbt-operation-color-picker{display:flex;align-items:center;flex-wrap:wrap;padding:0 16px 10px;background-color:#fff;overflow:hidden}.qlbt-operation-menu .qlbt-operation-color-picker .qlbt-operation-color-picker-item{width:20px;height:20px;border:1px solid #595959;margin-right:5px;margin-bottom:5px;cursor:pointer}.qlbt-operation-menu .qlbt-operation-menu-item{display:flex;align-items:center;padding:10px 16px;background-color:#fff;cursor:pointer;color:#595959;overflow:hidden;text-overflow:ellipsis}.qlbt-operation-menu .qlbt-operation-menu-item:hover{background-color:#efefef}.qlbt-operation-menu .qlbt-operation-menu-item .qlbt-operation-menu-icon{margin-right:8px;height:20px;width:20px;font-size:0}.qlbt-col-tool{position:absolute;display:flex;align-items:flex-end;overflow:hidden;z-index:99;height:16px}.qlbt-col-tool .qlbt-col-tool-cell{position:relative;background-color:#fff;border-top:1px solid #000;border-right:1px solid #000;border-bottom:1px solid #000}.qlbt-col-tool .qlbt-col-tool-cell:first-child{border-left:1px solid #000}.qlbt-col-tool .qlbt-col-tool-cell-holder{position:absolute;right:-1px;top:0;bottom:0;z-index:3;width:1px;background-color:transparent;cursor:ew-resize}.qlbt-col-tool .qlbt-col-tool-cell-holder:hover{background-color:#0589f3}.qlbt-col-tool .qlbt-col-tool-cell-holder::before{content:"";position:absolute;top:0;left:-6px;display:block;width:8px;height:100%}.qlbt-col-tool .qlbt-col-tool-cell-holder::after{content:"";position:absolute;top:0;right:-6px;display:block;width:8px;height:100%}.ql-snow .ql-picker.ql-table-picker{width:28px}.ql-snow .ql-picker.ql-table-picker .ql-picker-label{border:none;padding:0}.ql-snow .ql-picker.ql-table-picker .ql-picker-label svg{float:left;height:100%;margin-top:auto;position:static;right:auto;top:auto;width:auto}.ql-snow .ql-picker.ql-table-picker .ql-picker-options{padding:3px 5px;width:212px}.ql-snow .ql-picker.ql-table-picker .ql-picker-item{background-color:#cce4f8;border:1px solid transparent;float:left;height:16px;margin:2px;padding:0;width:16px}.ql-snow .ql-picker.ql-table-picker .ql-picker-item.hover{background-color:#186bad;border-color:#000000} diff --git a/dist/quill-better-table.css b/dist/quill-better-table.css index cec18b9..3ed923d 100644 --- a/dist/quill-better-table.css +++ b/dist/quill-better-table.css @@ -1,117 +1,2 @@ -.ql-container .qlbt-selection-line.qlbt-selection-line-left::before { - position: absolute; - left: -2px; - top: -2px; - content: ''; - width: 5px; - height: 5px; - background-color: #0589f3; - border-radius: 5px; } - -.ql-container .qlbt-selection-line.qlbt-selection-line-right::before { - position: absolute; - right: -2px; - bottom: -3px; - content: ''; - width: 5px; - height: 5px; - background-color: #0589f3; - border-radius: 5px; } - -.quill-better-table-wrapper { - overflow-x: auto; } - -table.quill-better-table { - table-layout: fixed; - border-collapse: collapse; } - table.quill-better-table td { - border: 1px solid #000; - padding: 2px 5px; } - -.qlbt-operation-menu { - background-color: #fff; - box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15); - font-size: 14px; - z-index: 100; - overflow: hidden; } - .qlbt-operation-menu .qlbt-operation-menu-dividing { - height: 1px; - background-color: #efefef; } - .qlbt-operation-menu .qlbt-operation-menu-subtitle { - color: #999; - font-size: 14px; - padding: 5px 16px; } - .qlbt-operation-menu .qlbt-operation-color-picker { - display: flex; - align-items: center; - flex-wrap: wrap; - padding: 0 16px 10px; - background-color: #fff; - overflow: hidden; } - .qlbt-operation-menu .qlbt-operation-color-picker .qlbt-operation-color-picker-item { - width: 20px; - height: 20px; - border: 1px solid #595959; - margin-right: 5px; - margin-bottom: 5px; - cursor: pointer; } - .qlbt-operation-menu .qlbt-operation-menu-item { - display: flex; - align-items: center; - padding: 10px 16px; - background-color: #fff; - cursor: pointer; - color: #595959; - overflow: hidden; - text-overflow: ellipsis; } - .qlbt-operation-menu .qlbt-operation-menu-item:hover { - background-color: #efefef; } - .qlbt-operation-menu .qlbt-operation-menu-item .qlbt-operation-menu-icon { - margin-right: 8px; - height: 20px; - width: 20px; - font-size: 0; } - -.qlbt-col-tool { - position: absolute; - display: flex; - align-items: flex-end; - overflow: hidden; - z-index: 99; - height: 16px; } - .qlbt-col-tool .qlbt-col-tool-cell { - position: relative; - background-color: #fff; - border-top: 1px solid #000; - border-right: 1px solid #000; - border-bottom: 1px solid #000; } - .qlbt-col-tool .qlbt-col-tool-cell:first-child { - border-left: 1px solid #000; } - .qlbt-col-tool .qlbt-col-tool-cell-holder { - position: absolute; - right: -1px; - top: 0; - bottom: 0; - z-index: 3; - width: 1px; - background-color: transparent; - cursor: ew-resize; } - .qlbt-col-tool .qlbt-col-tool-cell-holder:hover { - background-color: #0589f3; } - .qlbt-col-tool .qlbt-col-tool-cell-holder::before { - content: ""; - position: absolute; - top: 0; - left: -6px; - display: block; - width: 8px; - height: 100%; } - .qlbt-col-tool .qlbt-col-tool-cell-holder::after { - content: ""; - position: absolute; - top: 0; - right: -6px; - display: block; - width: 8px; - height: 100%; } +.ql-container .qlbt-selection-line.qlbt-selection-line-left::before{position:absolute;left:-2px;top:-2px;content:'';width:5px;height:5px;background-color:#0589f3;border-radius:5px}.ql-container .qlbt-selection-line.qlbt-selection-line-right::before{position:absolute;right:-2px;bottom:-3px;content:'';width:5px;height:5px;background-color:#0589f3;border-radius:5px}.quill-better-table-wrapper{overflow-x:auto}table.quill-better-table{table-layout:fixed;border-collapse:collapse}table.quill-better-table td{border:1px solid #000;padding:2px 5px}.qlbt-operation-menu{background-color:#fff;box-shadow:0 2px 8px rgba(0,0,0,0.15);font-size:14px;z-index:100;overflow:hidden}.qlbt-operation-menu .qlbt-operation-menu-dividing{height:1px;background-color:#efefef}.qlbt-operation-menu .qlbt-operation-menu-subtitle{color:#999;font-size:14px;padding:5px 16px}.qlbt-operation-menu .qlbt-operation-color-picker{display:flex;align-items:center;flex-wrap:wrap;padding:0 16px 10px;background-color:#fff;overflow:hidden}.qlbt-operation-menu .qlbt-operation-color-picker .qlbt-operation-color-picker-item{width:20px;height:20px;border:1px solid #595959;margin-right:5px;margin-bottom:5px;cursor:pointer}.qlbt-operation-menu .qlbt-operation-menu-item{display:flex;align-items:center;padding:10px 16px;background-color:#fff;cursor:pointer;color:#595959;overflow:hidden;text-overflow:ellipsis}.qlbt-operation-menu .qlbt-operation-menu-item:hover{background-color:#efefef}.qlbt-operation-menu .qlbt-operation-menu-item .qlbt-operation-menu-icon{margin-right:8px;height:20px;width:20px;font-size:0}.qlbt-col-tool{position:absolute;display:flex;align-items:flex-end;overflow:hidden;z-index:99;height:16px}.qlbt-col-tool .qlbt-col-tool-cell{position:relative;background-color:#fff;border-top:1px solid #000;border-right:1px solid #000;border-bottom:1px solid #000}.qlbt-col-tool .qlbt-col-tool-cell:first-child{border-left:1px solid #000}.qlbt-col-tool .qlbt-col-tool-cell-holder{position:absolute;right:-1px;top:0;bottom:0;z-index:3;width:1px;background-color:transparent;cursor:ew-resize}.qlbt-col-tool .qlbt-col-tool-cell-holder:hover{background-color:#0589f3}.qlbt-col-tool .qlbt-col-tool-cell-holder::before{content:"";position:absolute;top:0;left:-6px;display:block;width:8px;height:100%}.qlbt-col-tool .qlbt-col-tool-cell-holder::after{content:"";position:absolute;top:0;right:-6px;display:block;width:8px;height:100%}.ql-snow .ql-picker.ql-table-picker{width:28px}.ql-snow .ql-picker.ql-table-picker .ql-picker-label{border:none;padding:0}.ql-snow .ql-picker.ql-table-picker .ql-picker-label svg{float:left;height:100%;margin-top:auto;position:static;right:auto;top:auto;width:auto}.ql-snow .ql-picker.ql-table-picker .ql-picker-options{padding:3px 5px;width:212px}.ql-snow .ql-picker.ql-table-picker .ql-picker-item{background-color:#cce4f8;border:1px solid transparent;float:left;height:16px;margin:2px;padding:0;width:16px}.ql-snow .ql-picker.ql-table-picker .ql-picker-item.hover{background-color:#186bad;border-color:#000000} diff --git a/dist/quill-better-table.css.map b/dist/quill-better-table.css.map new file mode 100644 index 0000000..66d6723 --- /dev/null +++ b/dist/quill-better-table.css.map @@ -0,0 +1 @@ +{"version":3,"sourceRoot":"","sources":["../src/assets/quill-better-table.scss"],"names":[],"mappings":"AAKI;EACE;EACA;EACA;EACA;EACA;EACA;EACA,kBAZS;EAaT;;AAKF;EACE;EACA;EACA;EACA;EACA;EACA;EACA,kBAzBS;EA0BT;;;AAKN;EACE;;;AAGF;EACE;EACA;;AAEA;EACE;EACA;;;AAIJ;EACE;EACA;EACA;EACA;EACA;;AAEA;EACE;EACA;;AAGF;EACE;EACA;EACA;;AAGF;EACE;EACA;EACA;EACA;EACA;EACA;;AAEA;EACE;EACA;EACA;EACA;EACA;EACA;;AAIJ;EACE;EACA;EACA;EACA;EACA;EACA;EACA;EACA;;AAEA;EACE;;AAGF;EACE;EACA;EACA;EACA;;;AAKN;EACE;EACA;EACA;EACA;EACA;EACA;;AAEA;EACE;EACA;EACA;EACA;EACA;;AAEA;EACE;;AAIJ;EACE;EACA;EACA;EACA;EACA;EACA;EACA;EACA;;AAEA;EACE,kBAvIS;;AA0IX;EACE;EACA;EACA;EACA;EACA;EACA;EACA;;AAGF;EACE;EACA;EACA;EACA;EACA;EACA;EACA;;;AAMJ;EACE;;AAEA;EACE;EACA;;AAEA;EACE;EACA;EACA;EACA;EACA;EACA;EACA;;AAIJ;EACE;EACA;;AAGF;EACE;EACA;EACA;EACA;EACA;EACA;EACA;;AAEA;EACE;EACA","file":"quill-better-table.css"} \ No newline at end of file diff --git a/dist/quill-better-table.js b/dist/quill-better-table.js index 7e44cf0..336ce6b 100644 --- a/dist/quill-better-table.js +++ b/dist/quill-better-table.js @@ -73,7 +73,7 @@ return /******/ (function(modules) { // webpackBootstrap /******/ /******/ var hotApplyOnUpdate = true; /******/ // eslint-disable-next-line no-unused-vars -/******/ var hotCurrentHash = "ced44c7892a78034ffe4"; +/******/ var hotCurrentHash = "1b0e2a34d0e3d2fc104c"; /******/ var hotRequestTimeout = 10000; /******/ var hotCurrentModuleData = {}; /******/ var hotCurrentChildModule; @@ -166,6 +166,7 @@ return /******/ (function(modules) { // webpackBootstrap /******/ _declinedDependencies: {}, /******/ _selfAccepted: false, /******/ _selfDeclined: false, +/******/ _selfInvalidated: false, /******/ _disposeHandlers: [], /******/ _main: hotCurrentChildModule !== moduleId, /******/ @@ -196,6 +197,29 @@ return /******/ (function(modules) { // webpackBootstrap /******/ var idx = hot._disposeHandlers.indexOf(callback); /******/ if (idx >= 0) hot._disposeHandlers.splice(idx, 1); /******/ }, +/******/ invalidate: function() { +/******/ this._selfInvalidated = true; +/******/ switch (hotStatus) { +/******/ case "idle": +/******/ hotUpdate = {}; +/******/ hotUpdate[moduleId] = modules[moduleId]; +/******/ hotSetStatus("ready"); +/******/ break; +/******/ case "ready": +/******/ hotApplyInvalidatedModule(moduleId); +/******/ break; +/******/ case "prepare": +/******/ case "check": +/******/ case "dispose": +/******/ case "apply": +/******/ (hotQueuedInvalidatedModules = +/******/ hotQueuedInvalidatedModules || []).push(moduleId); +/******/ break; +/******/ default: +/******/ // ignore requests in error states +/******/ break; +/******/ } +/******/ }, /******/ /******/ // Management API /******/ check: hotCheck, @@ -237,7 +261,7 @@ return /******/ (function(modules) { // webpackBootstrap /******/ var hotDeferred; /******/ /******/ // The update info -/******/ var hotUpdate, hotUpdateNewHash; +/******/ var hotUpdate, hotUpdateNewHash, hotQueuedInvalidatedModules; /******/ /******/ function toModuleId(id) { /******/ var isNumber = +id + "" === id; @@ -252,7 +276,7 @@ return /******/ (function(modules) { // webpackBootstrap /******/ hotSetStatus("check"); /******/ return hotDownloadManifest(hotRequestTimeout).then(function(update) { /******/ if (!update) { -/******/ hotSetStatus("idle"); +/******/ hotSetStatus(hotApplyInvalidatedModules() ? "ready" : "idle"); /******/ return null; /******/ } /******/ hotRequestedFilesMap = {}; @@ -271,7 +295,6 @@ return /******/ (function(modules) { // webpackBootstrap /******/ var chunkId = 2; /******/ // eslint-disable-next-line no-lone-blocks /******/ { -/******/ /*globals chunkId */ /******/ hotEnsureUpdateChunk(chunkId); /******/ } /******/ if ( @@ -346,6 +369,11 @@ return /******/ (function(modules) { // webpackBootstrap /******/ if (hotStatus !== "ready") /******/ throw new Error("apply() is only allowed in ready status"); /******/ options = options || {}; +/******/ return hotApplyInternal(options); +/******/ } +/******/ +/******/ function hotApplyInternal(options) { +/******/ hotApplyInvalidatedModules(); /******/ /******/ var cb; /******/ var i; @@ -368,7 +396,11 @@ return /******/ (function(modules) { // webpackBootstrap /******/ var moduleId = queueItem.id; /******/ var chain = queueItem.chain; /******/ module = installedModules[moduleId]; -/******/ if (!module || module.hot._selfAccepted) continue; +/******/ if ( +/******/ !module || +/******/ (module.hot._selfAccepted && !module.hot._selfInvalidated) +/******/ ) +/******/ continue; /******/ if (module.hot._selfDeclined) { /******/ return { /******/ type: "self-declined", @@ -536,10 +568,13 @@ return /******/ (function(modules) { // webpackBootstrap /******/ installedModules[moduleId] && /******/ installedModules[moduleId].hot._selfAccepted && /******/ // removed self-accepted modules should not be required -/******/ appliedUpdate[moduleId] !== warnUnexpectedRequire +/******/ appliedUpdate[moduleId] !== warnUnexpectedRequire && +/******/ // when called invalidate self-accepting is not possible +/******/ !installedModules[moduleId].hot._selfInvalidated /******/ ) { /******/ outdatedSelfAcceptedModules.push({ /******/ module: moduleId, +/******/ parents: installedModules[moduleId].parents.slice(), /******/ errorHandler: installedModules[moduleId].hot._selfAccepted /******/ }); /******/ } @@ -612,7 +647,11 @@ return /******/ (function(modules) { // webpackBootstrap /******/ // Now in "apply" phase /******/ hotSetStatus("apply"); /******/ -/******/ hotCurrentHash = hotUpdateNewHash; +/******/ if (hotUpdateNewHash !== undefined) { +/******/ hotCurrentHash = hotUpdateNewHash; +/******/ hotUpdateNewHash = undefined; +/******/ } +/******/ hotUpdate = undefined; /******/ /******/ // insert new code /******/ for (moduleId in appliedUpdate) { @@ -665,7 +704,8 @@ return /******/ (function(modules) { // webpackBootstrap /******/ for (i = 0; i < outdatedSelfAcceptedModules.length; i++) { /******/ var item = outdatedSelfAcceptedModules[i]; /******/ moduleId = item.module; -/******/ hotCurrentParents = [moduleId]; +/******/ hotCurrentParents = item.parents; +/******/ hotCurrentChildModule = moduleId; /******/ try { /******/ __webpack_require__(moduleId); /******/ } catch (err) { @@ -707,12 +747,35 @@ return /******/ (function(modules) { // webpackBootstrap /******/ return Promise.reject(error); /******/ } /******/ +/******/ if (hotQueuedInvalidatedModules) { +/******/ return hotApplyInternal(options).then(function(list) { +/******/ outdatedModules.forEach(function(moduleId) { +/******/ if (list.indexOf(moduleId) < 0) list.push(moduleId); +/******/ }); +/******/ return list; +/******/ }); +/******/ } +/******/ /******/ hotSetStatus("idle"); /******/ return new Promise(function(resolve) { /******/ resolve(outdatedModules); /******/ }); /******/ } /******/ +/******/ function hotApplyInvalidatedModules() { +/******/ if (hotQueuedInvalidatedModules) { +/******/ if (!hotUpdate) hotUpdate = {}; +/******/ hotQueuedInvalidatedModules.forEach(hotApplyInvalidatedModule); +/******/ hotQueuedInvalidatedModules = undefined; +/******/ return true; +/******/ } +/******/ } +/******/ +/******/ function hotApplyInvalidatedModule(moduleId) { +/******/ if (!Object.prototype.hasOwnProperty.call(hotUpdate, moduleId)) +/******/ hotUpdate[moduleId] = modules[moduleId]; +/******/ } +/******/ /******/ // The module cache /******/ var installedModules = {}; /******/ @@ -801,7 +864,7 @@ return /******/ (function(modules) { // webpackBootstrap /******/ /******/ /******/ // Load entry module and return exports -/******/ return hotCreateRequire(12)(__webpack_require__.s = 12); +/******/ return hotCreateRequire(13)(__webpack_require__.s = 13); /******/ }) /************************************************************************/ /******/ ([ @@ -866,9 +929,134 @@ module.exports = " 1 && arguments[1] !== undefined ? arguments[1] : []; - let editorWrapper = arguments.length > 2 ? arguments[2] : undefined; + deleteColumns(compareRect, delIndexes = [], editorWrapper) { const [body] = this.descendants(TableBody); if (body == null || body.children.head == null) return; const tableCells = this.descendants(TableCell); @@ -1808,9 +1994,7 @@ class table_TableContainer extends Container { } } - insertColumn(compareRect, colIndex) { - let isRight = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true; - let editorWrapper = arguments.length > 3 ? arguments[3] : undefined; + insertColumn(compareRect, colIndex, isRight = true, editorWrapper) { const [body] = this.descendants(TableBody); const [tableColGroup] = this.descendants(TableColGroup); const tableCols = this.descendants(TableCol); @@ -2540,12 +2724,11 @@ class table_operation_menu_TableOperationMenu { return null; } - menuInitial(_ref) { - let { - table, - left, - top - } = _ref; + menuInitial({ + table, + left, + top + }) { this.domNode = document.createElement('div'); this.domNode.classList.add('qlbt-operation-menu'); css(this.domNode, { @@ -2618,12 +2801,11 @@ class table_operation_menu_TableOperationMenu { return node; } - menuItemCreator(_ref2) { - let { - text, - iconSrc, - handler - } = _ref2; + menuItemCreator({ + text, + iconSrc, + handler + }) { const node = document.createElement('div'); node.classList.add('qlbt-operation-menu-item'); const iconSpan = document.createElement('span'); @@ -2663,6 +2845,100 @@ function getColToolCellIndexesByBoundary(cells, boundary, conditionFn, container return findIndexes; }, []); } +// CONCATENATED MODULE: ./src/ui/table-picker.js + +const Picker = external_commonjs_quill_commonjs2_quill_amd_quill_root_Quill_default.a.import('ui/picker'); + +class TablePicker extends Picker { + constructor(select, label) { + super(select); + this.label.innerHTML = label; + this.container.classList.add('ql-table-picker'); + } + + buildItem(option) { + const item = super.buildItem(option); + item.addEventListener('mouseover', () => { + let value = item.getAttribute('data-value').split('x'); + let row = parseInt(value[1]); + let column = parseInt(value[0]); + let items = Array.from(this.container.querySelectorAll('.ql-picker-item')); + let lastItem = this.container.querySelector('.ql-picker-item:last-child'); + value = lastItem.getAttribute('data-value').split('x'); // let rows = parseInt(value[1]); + + let cols = parseInt(value[0]); + items.forEach(i => { + i.classList.remove('hover'); + }); + + for (let r = 0; r < row; r++) { + items.slice(r * cols, r * cols + column).forEach(i => { + i.classList.add('hover'); + }); + } + }); + return item; + } + + selectItem(item, trigger = false) { + super.selectItem(item, trigger); + if (item == null) return; + item.classList.remove('ql-selected'); + + if (item.label) { + item.label.removeAttribute('data-value'); + item.label.removeAttribute('data-label'); + } + + Array.from(this.container.querySelectorAll('.hover')).forEach(item => { + item.classList.remove('hover'); + }); + } + +} + +/* harmony default export */ var table_picker = (TablePicker); +// EXTERNAL MODULE: ./node_modules/extend/index.js +var extend = __webpack_require__(10); +var extend_default = /*#__PURE__*/__webpack_require__.n(extend); + +// CONCATENATED MODULE: ./src/themes/better-table-snow.js + + + +const SnowTheme = external_commonjs_quill_commonjs2_quill_amd_quill_root_Quill_default.a.import('themes/snow'); + +class better_table_snow_BetterTableSnowTheme extends SnowTheme { + constructor(quill, options) { + super(quill, options); + } + + buildPickers(selects, icons) { + selects = Array.from(selects); + let pickers = selects.map((select, index, selects) => { + if (select.classList.contains('ql-better-table')) { + selects.splice(index, 1); + + if (select.querySelector('option') == null) { + for (let r = 1; r <= 8; r++) { + for (let c = 1; c <= 10; c++) { + const option = document.createElement('option'); + option.setAttribute('value', c + 'x' + r); + select.appendChild(option); + } + } + } + + return new table_picker(select, icons.table); + } + }); + super.buildPickers(selects, icons); + this.pickers = extend_default()([], this.pickers, pickers); + } + +} + +/* harmony default export */ var better_table_snow = (better_table_snow_BetterTableSnowTheme); // CONCATENATED MODULE: ./src/utils/node-matchers.js @@ -2876,6 +3152,8 @@ function matchTable(node, delta, scroll) { + + // import table node matchers @@ -2896,6 +3174,9 @@ class quill_better_table_BetterTable extends Module { external_commonjs_quill_commonjs2_quill_amd_quill_root_Quill_default.a.register(table_TableViewWrapper, true); external_commonjs_quill_commonjs2_quill_amd_quill_root_Quill_default.a.register(table_TableViewWrapper, true); // register customized Header,overwriting quill built-in Header // Quill.register('formats/header', Header, true); + + external_commonjs_quill_commonjs2_quill_amd_quill_root_Quill_default.a.register('themes/better-table-snow', better_table_snow, true); + external_commonjs_quill_commonjs2_quill_amd_quill_root_Quill_default.a.register('ui/table-picker', table_picker, true); } constructor(quill, options) { @@ -2951,12 +3232,12 @@ class quill_better_table_BetterTable extends Module { cell: cellNode, left: evt.pageX, top: evt.pageY - }, quill, options.operationMenu); + }, quill, options.operationMenu || {}); } }, false); // add keyboard binding:Backspace // prevent user hits backspace to delete table cell + // const KeyBoard = quill.getModule('keyboard') - const KeyBoard = quill.getModule('keyboard'); quill.keyboard.addBinding({ key: 'Backspace' }, {}, function (range, context) { @@ -2988,10 +3269,16 @@ class quill_better_table_BetterTable extends Module { quill.clipboard.matchers = quill.clipboard.matchers.filter(matcher => { return matcher[0] !== 'tr'; }); + const toolbar = quill.getModule('toolbar'); + const input = toolbar.container.querySelector('select.ql-better-table'); + + if (toolbar && input) { + toolbar.addHandler('better-table', this.insertTable); + toolbar.attach(input); + } } - getTable() { - let range = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : this.quill.getSelection(); + getTable(range = this.quill.getSelection()) { if (range == null) return [null, null, null, -1]; const [cellLine, offset] = this.quill.getLine(range.index); @@ -3006,6 +3293,16 @@ class quill_better_table_BetterTable extends Module { } insertTable(rows, columns) { + if (!columns) { + if (rows.match(/^\d+x\d+$/)) { + let tmp = rows.split('x'); + columns = parseInt(tmp[0]); + rows = parseInt(tmp[1]); + } else { + return; + } + } + const range = this.quill.getSelection(true); if (range == null) return; let currentBlot = this.quill.getLeaf(range.index)[0]; @@ -3068,12 +3365,7 @@ quill_better_table_BetterTable.keyboardBindings = { handler(range, context) { const [line, offset] = this.quill.getLine(range.index); - - if (!line.prev || line.prev.statics.blotName !== 'table-cell-line') { - return false; - } - - return true; + return !(!line.prev || line.prev.statics.blotName !== 'table-cell-line'); } }, @@ -3224,11 +3516,11 @@ function isInTableCell(current) { /* harmony default export */ var quill_better_table = __webpack_exports__["default"] = (quill_better_table_BetterTable); /***/ }), -/* 11 */, -/* 12 */ +/* 12 */, +/* 13 */ /***/ (function(module, exports, __webpack_require__) { -module.exports = __webpack_require__(10); +module.exports = __webpack_require__(11); /***/ }) diff --git a/dist/quill-better-table.min.js b/dist/quill-better-table.min.js index 5f39509..53fae6d 100644 --- a/dist/quill-better-table.min.js +++ b/dist/quill-better-table.min.js @@ -1 +1 @@ -!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("quill")):"function"==typeof define&&define.amd?define(["quill"],t):"object"==typeof exports?exports.quillBetterTable=t(require("quill")):e.quillBetterTable=t(e.Quill)}(window,function(e){return function(e){var t=window.webpackHotUpdatequillBetterTable;window.webpackHotUpdatequillBetterTable=function(e,o){!function(e,t){if(!x[e]||!y[e])return;for(var o in y[e]=!1,t)Object.prototype.hasOwnProperty.call(t,o)&&(m[o]=t[o]);0==--g&&0===w&&A()}(e,o),t&&t(e,o)};var o,n=!0,r="4e3f8499cfb63ceb338e",l=1e4,i={},s=[],a=[];function c(e){var t=E[e];if(!t)return T;var n=function(n){return t.hot.active?(E[n]?-1===E[n].parents.indexOf(e)&&E[n].parents.push(e):(s=[e],o=n),-1===t.children.indexOf(n)&&t.children.push(n)):(console.warn("[HMR] unexpected require("+n+") from disposed module "+e),s=[]),T(n)},r=function(e){return{configurable:!0,enumerable:!0,get:function(){return T[e]},set:function(t){T[e]=t}}};for(var l in T)Object.prototype.hasOwnProperty.call(T,l)&&"e"!==l&&"t"!==l&&Object.defineProperty(n,l,r(l));return n.e=function(e){return"ready"===u&&p("prepare"),w++,T.e(e).then(t,function(e){throw t(),e});function t(){w--,"prepare"===u&&(v[e]||q(e),0===w&&0===g&&A())}},n.t=function(e,t){return 1&t&&(e=n(e)),T.t(e,-2&t)},n}function d(e){var t={_acceptedDependencies:{},_declinedDependencies:{},_selfAccepted:!1,_selfDeclined:!1,_disposeHandlers:[],_main:o!==e,active:!0,accept:function(e,o){if(void 0===e)t._selfAccepted=!0;else if("function"==typeof e)t._selfAccepted=e;else if("object"==typeof e)for(var n=0;n=0&&t._disposeHandlers.splice(o,1)},check:C,apply:S,status:function(e){if(!e)return u;h.push(e)},addStatusHandler:function(e){h.push(e)},removeStatusHandler:function(e){var t=h.indexOf(e);t>=0&&h.splice(t,1)},data:i[e]};return o=void 0,t}var h=[],u="idle";function p(e){u=e;for(var t=0;t0;){var r=n.pop(),l=r.id,i=r.chain;if((a=E[l])&&!a.hot._selfAccepted){if(a.hot._selfDeclined)return{type:"self-declined",chain:i,moduleId:l};if(a.hot._main)return{type:"unaccepted",chain:i,moduleId:l};for(var s=0;s ")),C.type){case"self-declined":t.onDeclined&&t.onDeclined(C),t.ignoreDeclined||(q=new Error("Aborted because of self decline: "+C.moduleId+H));break;case"declined":t.onDeclined&&t.onDeclined(C),t.ignoreDeclined||(q=new Error("Aborted because of declined dependency: "+C.moduleId+" in "+C.parentId+H));break;case"unaccepted":t.onUnaccepted&&t.onUnaccepted(C),t.ignoreUnaccepted||(q=new Error("Aborted because "+c+" is not accepted"+H));break;case"accepted":t.onAccepted&&t.onAccepted(C),A=!0;break;case"disposed":t.onDisposed&&t.onDisposed(C),S=!0;break;default:throw new Error("Unexception type "+C.type)}if(q)return p("abort"),Promise.reject(q);if(A)for(c in w[c]=m[c],h(g,C.outdatedModules),C.outdatedDependencies)Object.prototype.hasOwnProperty.call(C.outdatedDependencies,c)&&(f[c]||(f[c]=[]),h(f[c],C.outdatedDependencies[c]));S&&(h(g,[C.moduleId]),w[c]=v)}var M,B=[];for(n=0;n0;)if(c=L.pop(),a=E[c]){var z={},k=a.hot._disposeHandlers;for(l=0;l=0&&I.parents.splice(M,1))}}for(c in f)if(Object.prototype.hasOwnProperty.call(f,c)&&(a=E[c]))for(R=f[c],l=0;l=0&&a.children.splice(M,1);for(c in p("apply"),r=b,w)Object.prototype.hasOwnProperty.call(w,c)&&(e[c]=w[c]);var D=null;for(c in f)if(Object.prototype.hasOwnProperty.call(f,c)&&(a=E[c])){R=f[c];var j=[];for(n=0;n'},function(e,t){e.exports=''},function(e,t){e.exports=''},function(e,t){e.exports=''},function(e,t){e.exports=''},function(e,t){e.exports=''},function(e,t){e.exports=''},function(e,t){e.exports=''},function(e,t){e.exports=''},function(e,t,o){e.exports=o(11)},function(e,t,o){"use strict";o.r(t);var n=o(0),r=o.n(n);function l(e,t){if("object"==typeof t)for(let o in t)e.style[o]=t[o]}function i(e,t){let o=t.getBoundingClientRect();return{x:e.x-o.x-t.scrollLeft,y:e.y-o.y-t.scrollTop,x1:e.x-o.x-t.scrollLeft+e.width,y1:e.y-o.y-t.scrollTop+e.height,width:e.width,height:e.height}}function s(e,t){return e&&Object.keys(e).reduce((o,n)=>t.includes(n)?o:Object.assign({},o,{[n]:e[n]}),{})}function a(e){let t;if(null==(t=e.path||e.composedPath&&e.composedPath())&&e.target){t=[];let o=e.target;for(t.push(o);o&&o.parentNode;)o=o.parentNode,t.push(o)}return t}const c=12,d=12,h=50,u="#35A7ED";class p{constructor(e,t,o){if(!e)return null;this.table=e,this.quill=t,this.options=o,this.domNode=null,this.initColTool()}initColTool(){const e=this.quill.root.parentNode,t=(this.table.getBoundingClientRect(),e.getBoundingClientRect()),o=this.table.parentNode.getBoundingClientRect();this.domNode=document.createElement("div"),this.domNode.classList.add("qlbt-col-tool"),this.updateToolCells(),e.appendChild(this.domNode),l(this.domNode,{width:"".concat(o.width,"px"),height:"".concat(c,"px"),left:"".concat(o.left-t.left+e.scrollLeft,"px"),top:"".concat(o.top-t.top+e.scrollTop-c-5,"px")})}createToolCell(){const e=document.createElement("div");e.classList.add("qlbt-col-tool-cell");const t=document.createElement("div");return t.classList.add("qlbt-col-tool-cell-holder"),l(e,{height:"".concat(d,"px")}),e.appendChild(t),e}updateToolCells(){const e=r.a.find(this.table),t=e.children.tail.children.head.children,o=e.colGroup().children,n=function(e){return e.reduce((e,t)=>{const o=t.formats().colspan;return e+=parseInt(o,10)},0)}(t);let i=Array.from(this.domNode.querySelectorAll(".qlbt-col-tool-cell"));for(let e=0;e=n?i[e].remove():l(s=i[e],{"min-width":"".concat(r,"px")}):(s=this.createToolCell(),this.domNode.appendChild(s),this.addColCellHolderHandler(s),l(s,{"min-width":"".concat(r,"px")}))}}destroy(){return this.domNode.remove(),null}addColCellHolderHandler(e){const t=r.a.find(this.table),o=e.querySelector(".qlbt-col-tool-cell-holder");let n=!1,i=0,s=0,a=0,d=0,p={},f={},m=null;const b=e=>{e.preventDefault(),n&&(s=e.clientX,a=d+s-i>=h?s-i:h-d,l(m,{left:"".concat(f.left+f.width-1+a,"px")}))},g=r=>{r.preventDefault();const c=Array.from(this.domNode.querySelectorAll(".qlbt-col-tool-cell")).indexOf(e),h=t.colGroup().children.at(c);n&&(h.format("width",d+a),l(e,{"min-width":"".concat(d+a,"px")}),i=0,s=0,a=0,d=0,n=!1,o.classList.remove("dragging")),document.removeEventListener("mousemove",b,!1),document.removeEventListener("mouseup",g,!1),p={},f={},m.remove(),m=null,t.updateTableWidth();const u=this.quill.getModule("better-table").tableSelection;u&&u.clearSelection()};o.addEventListener("mousedown",t=>{document.addEventListener("mousemove",b,!1),document.addEventListener("mouseup",g,!1),p=this.table.getBoundingClientRect(),f=e.getBoundingClientRect(),l(m=document.createElement("div"),{position:"fixed",top:"".concat(f.top,"px"),left:"".concat(f.left+f.width-1,"px"),zIndex:"100",height:"".concat(p.height+c+4,"px"),width:"1px",backgroundColor:u}),document.body.appendChild(m),n=!0,i=t.clientX,d=f.width,o.classList.add("dragging")},!1)}colToolCells(){return Array.from(this.domNode.querySelectorAll(".qlbt-col-tool-cell"))}}const f=r.a.import("blots/block");class m extends f{static create(e){"string"==typeof e&&(e={value:e});const t=super.create(e.value);return N.forEach(o=>{e[o]&&t.setAttribute("data-".concat(o),e[o])}),C.forEach(o=>{e[o]&&t.setAttribute("data-".concat(o),e[o])}),t}static formats(e){const t={};return t.value=this.tagName.indexOf(e.tagName)+1,C.concat(N).reduce((t,o)=>(e.hasAttribute("data-".concat(o))&&(t[o]=e.getAttribute("data-".concat(o))||void 0),t),t)}format(e,t){const{row:o,cell:n,rowspan:r,colspan:l}=m.formats(this.domNode);e===m.blotName?t?super.format(e,{value:t,row:o,cell:n,rowspan:r,colspan:l}):o?this.replaceWith(S.blotName,{row:o,cell:n,rowspan:r,colspan:l}):super.format(e,t):super.format(e,t)}optimize(e){const{row:t,rowspan:o,colspan:n}=m.formats(this.domNode);if(!t||this.parent instanceof E||this.wrap(E.blotName,{row:t,colspan:n,rowspan:o}),this.enforceAllowedChildren(),null!=this.uiNode&&this.uiNode!==this.domNode.firstChild&&this.domNode.insertBefore(this.uiNode,this.domNode.firstChild),0===this.children.length)if(null!=this.statics.defaultChild){const e=this.scroll.create(this.statics.defaultChild.blotName);this.appendChild(e)}else this.remove();this.cache={}}}m.blotName="header",m.tagName=["H1","H2","H3","H4","H5","H6"];var b=m;const g=r.a.import("blots/break"),w=r.a.import("blots/block"),v=r.a.import("blots/container"),y=["width"],x={width:100},N=["row","cell"],C=["rowspan","colspan"],q={rowspan:1,colspan:1},A=5;class S extends w{static create(e){const t=super.create(e);return N.forEach(o=>{let n="row"===o?L:z;t.setAttribute("data-".concat(o),e[o]||n())}),C.forEach(o=>{t.setAttribute("data-".concat(o),e[o]||q[o])}),e["cell-bg"]&&t.setAttribute("data-cell-bg",e["cell-bg"]),t}static formats(e){return C.concat(N).concat(["cell-bg"]).reduce((t,o)=>(e.hasAttribute("data-".concat(o))&&(t[o]=e.getAttribute("data-".concat(o))||void 0),t),{})}format(e,t){if(C.concat(N).indexOf(e)>-1)t?this.domNode.setAttribute("data-".concat(e),t):this.domNode.removeAttribute("data-".concat(e));else if("cell-bg"===e)t?this.domNode.setAttribute("data-cell-bg",t):this.domNode.removeAttribute("data-cell-bg");else if("header"===e){if(!t)return;const{row:o,cell:n,rowspan:r,colspan:l}=S.formats(this.domNode);super.format(e,{value:t,row:o,cell:n,rowspan:r,colspan:l})}else super.format(e,t)}optimize(e){const t=this.domNode.getAttribute("data-row"),o=this.domNode.getAttribute("data-rowspan"),n=this.domNode.getAttribute("data-colspan"),r=this.domNode.getAttribute("data-cell-bg");!this.statics.requiredContainer||this.parent instanceof this.statics.requiredContainer||this.wrap(this.statics.requiredContainer.blotName,{row:t,colspan:n,rowspan:o,"cell-bg":r}),super.optimize(e)}tableCell(){return this.parent}}S.blotName="table-cell-line",S.className="qlbt-cell-line",S.tagName="P";class E extends v{checkMerge(){if(super.checkMerge()&&null!=this.next.children.head){const e=this.children.head.formats()[this.children.head.statics.blotName],t=this.children.tail.formats()[this.children.tail.statics.blotName],o=this.next.children.head.formats()[this.next.children.head.statics.blotName],n=this.next.children.tail.formats()[this.next.children.tail.statics.blotName];return e.cell===t.cell&&e.cell===o.cell&&e.cell===n.cell}return!1}static create(e){const t=super.create(e);return t.setAttribute("data-row",e.row),C.forEach(o=>{e[o]&&t.setAttribute(o,e[o])}),e["cell-bg"]&&(t.setAttribute("data-cell-bg",e["cell-bg"]),t.style.backgroundColor=e["cell-bg"]),t}static formats(e){const t={};return e.hasAttribute("data-row")&&(t.row=e.getAttribute("data-row")),e.hasAttribute("data-cell-bg")&&(t["cell-bg"]=e.getAttribute("data-cell-bg")),C.reduce((t,o)=>(e.hasAttribute(o)&&(t[o]=e.getAttribute(o)),t),t)}cellOffset(){return this.parent?this.parent.children.indexOf(this):-1}formats(){const e={};return this.domNode.hasAttribute("data-row")&&(e.row=this.domNode.getAttribute("data-row")),this.domNode.hasAttribute("data-cell-bg")&&(e["cell-bg"]=this.domNode.getAttribute("data-cell-bg")),C.reduce((e,t)=>(this.domNode.hasAttribute(t)&&(e[t]=this.domNode.getAttribute(t)),e),e)}toggleAttribute(e,t){t?this.domNode.setAttribute(e,t):this.domNode.removeAttribute(e)}formatChildren(e,t){this.children.forEach(o=>{o.format(e,t)})}format(e,t){C.indexOf(e)>-1?(this.toggleAttribute(e,t),this.formatChildren(e,t)):["row"].indexOf(e)>-1?(this.toggleAttribute("data-".concat(e),t),this.formatChildren(e,t)):"cell-bg"===e?(this.toggleAttribute("data-cell-bg",t),this.formatChildren(e,t),this.domNode.style.backgroundColor=t||"initial"):super.format(e,t)}optimize(e){const t=this.domNode.getAttribute("data-row");!this.statics.requiredContainer||this.parent instanceof this.statics.requiredContainer||this.wrap(this.statics.requiredContainer.blotName,{row:t}),super.optimize(e)}row(){return this.parent}rowOffset(){return this.row()?this.row().rowOffset():-1}table(){return this.row()&&this.row().table()}}E.blotName="table",E.tagName="TD";class T extends v{checkMerge(){if(super.checkMerge()&&null!=this.next.children.head){const e=this.children.head.formats(),t=this.children.tail.formats(),o=this.next.children.head.formats(),n=this.next.children.tail.formats();return e.row===t.row&&e.row===o.row&&e.row===n.row}return!1}static create(e){const t=super.create(e);return t.setAttribute("data-row",e.row),t}formats(){return["row"].reduce((e,t)=>(this.domNode.hasAttribute("data-".concat(t))&&(e[t]=this.domNode.getAttribute("data-".concat(t))),e),{})}optimize(e){!this.statics.requiredContainer||this.parent instanceof this.statics.requiredContainer||this.wrap(this.statics.requiredContainer.blotName),this.enforceAllowedChildren(),null!=this.uiNode&&this.uiNode!==this.domNode.firstChild&&this.domNode.insertBefore(this.uiNode,this.domNode.firstChild),this.children.length>0&&null!=this.next&&this.checkMerge()&&(this.next.moveChildren(this),this.next.remove())}rowOffset(){return this.parent?this.parent.children.indexOf(this):-1}table(){return this.parent&&this.parent.parent}}T.blotName="table-row",T.tagName="TR";class H extends v{}H.blotName="table-body",H.tagName="TBODY";class M extends w{static create(e){let t=super.create(e);return y.forEach(o=>{t.setAttribute("".concat(o),e[o]||x[o])}),t}static formats(e){return y.reduce((t,o)=>(e.hasAttribute("".concat(o))&&(t[o]=e.getAttribute("".concat(o))||void 0),t),{})}format(e,t){y.indexOf(e)>-1?this.domNode.setAttribute("".concat(e),t||x[e]):super.format(e,t)}html(){return this.domNode.outerHTML}}M.blotName="table-col",M.tagName="col";class B extends v{}B.blotName="table-col-group",B.tagName="colgroup";class O extends v{static create(){return super.create()}constructor(e,t){super(e,t),this.updateTableWidth()}updateTableWidth(){setTimeout(()=>{const e=this.colGroup();if(!e)return;const t=e.children.reduce((e,t)=>e+=parseInt(t.formats()[M.blotName].width,10),0);this.domNode.style.width="".concat(t,"px")},0)}cells(e){return this.rows().map(t=>t.children.at(e))}colGroup(){return this.children.head}deleteColumns(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[],o=arguments.length>2?arguments[2]:void 0;const[n]=this.descendants(H);if(null==n||null==n.children.head)return;const r=this.descendants(E),l=[],s=[];if(r.forEach(t=>{const n=i(t.domNode.getBoundingClientRect(),o);n.x+A>e.x&&n.x1-Ae.x1-A&&s.push(t)}),l.length===r.length)return this.tableDestroy(),!0;t.forEach(e=>{this.colGroup().children.at(t[0]).remove()}),l.forEach(e=>{e.remove()}),s.forEach(e=>{const o=parseInt(e.formats().colspan,10);parseInt(e.formats().width,10);e.format("colspan",o-t.length)}),this.updateTableWidth()}deleteRow(e,t){const[o]=this.descendants(H);if(null==o||null==o.children.head)return;const n=this.descendants(E),r=this.descendants(T),l=[],s=[],a=[],c=r.filter(o=>{const n=i(o.domNode.getBoundingClientRect(),t);return n.y>e.y-A&&n.y1{const n=i(o.domNode.getBoundingClientRect(),t);n.y>e.y-A&&n.y1e.y1-A&&(s.push(o),Math.abs(n.y-e.y){let r=i(n.domNode.getBoundingClientRect(),t);return r.y>e.y-A&&r.y1{const o=i(e.domNode.getBoundingClientRect(),t),n=e.parent.next,r=n.children.reduce((e,n)=>{const r=i(n.domNode.getBoundingClientRect(),t);return Math.abs(o.x1-r.x){e.remove()}),s.forEach(e=>{const t=parseInt(e.formats().rowspan,10);e.format("rowspan",t-d)}),c.forEach(e=>e.remove())}tableDestroy(){const e=r.a.find(this.scroll.domNode.parentNode),t=e.getModule("better-table");this.remove(),t.hideTableTools(),e.update(r.a.sources.USER)}insertCell(e,t){const o=z(),n=e.formats().row,r=this.scroll.create(E.blotName,Object.assign({},q,{row:n})),l=this.scroll.create(S.blotName,{row:n,cell:o});r.appendChild(l),t?e.insertBefore(r,t):e.appendChild(r)}insertColumn(e,t){let o=!(arguments.length>2&&void 0!==arguments[2])||arguments[2],n=arguments.length>3?arguments[3]:void 0;const[r]=this.descendants(H),[l]=this.descendants(B),s=this.descendants(M);let a=[],c=[],d=[];if(null==r||null==r.children.head)return;this.descendants(E).forEach(t=>{const r=i(t.domNode.getBoundingClientRect(),n);o?Math.abs(r.x1-e.x1)A&&e.x1-r.x1<-A&&c.push(t):Math.abs(r.x-e.x)A&&e.x-r.x1<-A&&c.push(t)}),a.forEach(e=>{const t=o?e.next:e,n=z(),r=e.parent,l=r.formats().row,i=e.formats(),s=this.scroll.create(E.blotName,Object.assign({},q,{row:l,rowspan:i.rowspan})),a=this.scroll.create(S.blotName,{row:l,cell:n,rowspan:i.rowspan});s.appendChild(a),t?r.insertBefore(s,t):r.appendChild(s),d.push(s)});const h=this.scroll.create(M.blotName,!0);let u=o?s[t].next:s[t];return u?l.insertBefore(h,u):l.appendChild(h),c.forEach(e=>{const t=e.formats().colspan;e.format("colspan",parseInt(t,10)+1),d.push(e)}),d.sort((e,t)=>{return e.domNode.getBoundingClientRect().y-t.domNode.getBoundingClientRect().y}),this.updateTableWidth(),d}insertRow(e,t,o){const[n]=this.descendants(H);if(null==n||null==n.children.head)return;const r=this.descendants(E),l=L(),s=this.scroll.create(T.blotName,{row:l});let a=[],c=[],d=[];r.forEach(n=>{const r=i(n.domNode.getBoundingClientRect(),o);t?Math.abs(r.y1-e.y1)A&&e.y1-r.y1<-A&&c.push(n):Math.abs(r.y-e.y)A&&e.y-r.y1<-A&&c.push(n)});const h=(e,t)=>{return e.domNode.getBoundingClientRect().x-t.domNode.getBoundingClientRect().x};a.sort(h),a.forEach(e=>{const t=z(),o=e.formats(),n=this.scroll.create(E.blotName,Object.assign({},q,{row:l,colspan:o.colspan})),r=this.scroll.create(S.blotName,{row:l,cell:t,colspan:o.colspan}),i=this.scroll.create(g.blotName);r.appendChild(i),n.appendChild(r),s.appendChild(n),d.push(n)}),c.forEach(e=>{const t=parseInt(e.formats().rowspan,10);e.format("rowspan",t+1),d.push(e)});const u=this.rows().find(n=>{let r=i(n.domNode.getBoundingClientRect(),o);return t?Math.abs(r.y-e.y-e.height)(0!==r?(e&&t.moveChildren(e),t.remove()):(t.format("colspan",n),t.format("rowspan",o),e=t),e),null);let i=l.domNode.getAttribute("data-row"),s=l.children.head.domNode.getAttribute("data-cell");return l.children.forEach(e=>{e.format("cell",s),e.format("row",i),e.format("colspan",n),e.format("rowspan",o)}),l}unmergeCells(e,t){let o={},n=1,r=1;e.forEach(e=>{if(o=e.formats(),n=o.rowspan,(r=o.colspan)>1){let t=e.next,o=e.row();e.format("colspan",1);for(let e=r;e>1;e--)this.insertCell(o,t)}if(n>1){let o=n,l=e.row().next;for(;o>1;){let n=l.children.reduce((o,n)=>{let r=i(e.domNode.getBoundingClientRect(),t),l=i(n.domNode.getBoundingClientRect(),t);return Math.abs(r.x1-l.x)0;e--)this.insertCell(l,n);o-=1,l=l.next}e.format("rowspan",1)}})}rows(){const e=this.children.tail;return null==e?[]:e.children.map(e=>e)}}O.blotName="table-container",O.className="quill-better-table",O.tagName="TABLE";class R extends v{constructor(e,t){super(e,t);const o=r.a.find(e.domNode.parentNode);t.addEventListener("scroll",e=>{const t=o.getModule("better-table");t.columnTool&&(t.columnTool.domNode.scrollLeft=e.target.scrollLeft),t.tableSelection&&t.tableSelection.selectedTds.length>0&&t.tableSelection.repositionHelpLines()},!1)}table(){return this.children.head}}function L(){const e=Math.random().toString(36).slice(2,6);return"row-".concat(e)}function z(){const e=Math.random().toString(36).slice(2,6);return"cell-".concat(e)}R.blotName="table-view",R.className="quill-better-table-wrapper",R.tagName="DIV",R.allowedChildren=[O],O.requiredContainer=R,O.allowedChildren=[H,B],H.requiredContainer=O,H.allowedChildren=[T],T.requiredContainer=H,T.allowedChildren=[E],E.requiredContainer=T,E.allowedChildren=[S,b],S.requiredContainer=E,B.allowedChildren=[M],B.requiredContainer=O,M.requiredContainer=B;const k="#0589f3",I=["left","right","top","bottom"],D=2;class j{constructor(e,t,o){if(!e)return null;this.table=e,this.quill=t,this.options=o,this.boundary={},this.selectedTds=[],this.dragging=!1,this.selectingHandler=this.mouseDownHandler.bind(this),this.clearSelectionHandler=this.clearSelection.bind(this),this.helpLinesInitial(),this.quill.root.addEventListener("mousedown",this.selectingHandler,!1),this.quill.on("text-change",this.clearSelectionHandler)}helpLinesInitial(){let e=this.quill.root.parentNode;I.forEach(t=>{this[t]=document.createElement("div"),this[t].classList.add("qlbt-selection-line"),this[t].classList.add("qlbt-selection-line-"+t),l(this[t],{position:"absolute",display:"none","background-color":k}),e.appendChild(this[t])})}mouseDownHandler(e){if(0!==e.button||!e.target.closest(".quill-better-table"))return;this.quill.root.addEventListener("mousemove",r,!1),this.quill.root.addEventListener("mouseup",function e(o){t.quill.root.removeEventListener("mousemove",r,!1);t.quill.root.removeEventListener("mouseup",e,!1);t.dragging=!1},!1);const t=this,o=e.target.closest("td[data-row]"),n=i(o.getBoundingClientRect(),this.quill.root.parentNode);function r(e){if(0!==e.button||!e.target.closest(".quill-better-table"))return;const r=e.target.closest("td[data-row]"),l=i(r.getBoundingClientRect(),t.quill.root.parentNode);t.boundary=V(n,l),t.correctBoundary(),t.selectedTds=t.computeSelectedTds(),t.repositionHelpLines(),o!==r&&t.quill.blur()}this.dragging=!0,this.boundary=V(n,n),this.correctBoundary(),this.selectedTds=this.computeSelectedTds(),this.repositionHelpLines()}correctBoundary(){r.a.find(this.table).descendants(E).forEach(e=>{let{x:t,y:o,width:n,height:r}=i(e.domNode.getBoundingClientRect(),this.quill.root.parentNode);(t+D>=this.boundary.x&&t+D<=this.boundary.x1||t-D+n>=this.boundary.x&&t-D+n<=this.boundary.x1)&&(o+D>=this.boundary.y&&o+D<=this.boundary.y1||o-D+r>=this.boundary.y&&o-D+r<=this.boundary.y1)&&(this.boundary=V(this.boundary,{x:t,y:o,width:n,height:r}))})}computeSelectedTds(){return r.a.find(this.table).descendants(E).reduce((e,t)=>{let{x:o,y:n,width:r,height:l}=i(t.domNode.getBoundingClientRect(),this.quill.root.parentNode);return o+D>=this.boundary.x&&o-D+r<=this.boundary.x1&&n+D>=this.boundary.y&&n-D+l<=this.boundary.y1&&e.push(t),e},[])}repositionHelpLines(){const e=this.table.parentNode.scrollLeft;l(this.left,{display:"block",left:"".concat(this.boundary.x-e-1,"px"),top:"".concat(this.boundary.y,"px"),height:"".concat(this.boundary.height+1,"px"),width:"1px"}),l(this.right,{display:"block",left:"".concat(this.boundary.x1-e,"px"),top:"".concat(this.boundary.y,"px"),height:"".concat(this.boundary.height+1,"px"),width:"1px"}),l(this.top,{display:"block",left:"".concat(this.boundary.x-1-e,"px"),top:"".concat(this.boundary.y,"px"),width:"".concat(this.boundary.width+1,"px"),height:"1px"}),l(this.bottom,{display:"block",left:"".concat(this.boundary.x-1-e,"px"),top:"".concat(this.boundary.y1+1,"px"),width:"".concat(this.boundary.width+1,"px"),height:"1px"})}refreshHelpLinesPosition(){const e=i(this.selectedTds[0].domNode.getBoundingClientRect(),this.quill.root.parentNode),t=i(this.selectedTds[this.selectedTds.length-1].domNode.getBoundingClientRect(),this.quill.root.parentNode);this.boundary=V(e,t),this.repositionHelpLines()}destroy(){return I.forEach(e=>{this[e].remove(),this[e]=null}),this.quill.root.removeEventListener("mousedown",this.selectingHandler,!1),this.quill.off("text-change",this.clearSelectionHandler),null}setSelection(e,t){this.boundary=V(i(e,this.quill.root.parentNode),i(t,this.quill.root.parentNode)),this.correctBoundary(),this.selectedTds=this.computeSelectedTds(),this.repositionHelpLines()}clearSelection(){this.boundary={},this.selectedTds=[],I.forEach(e=>{this[e]&&l(this[e],{display:"none"})})}}function V(e,t){let o=Math.min(e.x,t.x,e.x+e.width-1,t.x+t.width-1),n=Math.max(e.x,t.x,e.x+e.width-1,t.x+t.width-1),r=Math.min(e.y,t.y,e.y+e.height-1,t.y+t.height-1),l=Math.max(e.y,t.y,e.y+e.height-1,t.y+t.height-1);return{x:o,x1:n,y:r,y1:l,width:n-o,height:l-r}}var U=o(1),_=o.n(U),P=o(2),W=o.n(P),G=o(3),X=o.n(G),K=o(4),Y=o.n(K),$=o(5),J=o.n($),Q=o(6),F=o.n(Q),Z=o(7),ee=o.n(Z),te=o(8),oe=o.n(te),ne=o(9),re=o.n(ne);const le=150,ie=200,se=["white","red","yellow","blue"],ae="Background Colors",ce={insertColumnRight:{text:"Insert column right",iconSrc:_.a,handler(){const e=r.a.find(this.table);let t=he(this.columnToolCells,this.boundary,(e,t)=>Math.abs(e.x+e.width-t.x1)<=5,this.quill.root.parentNode);const o=e.insertColumn(this.boundary,t,!0,this.quill.root.parentNode);this.tableColumnTool.updateToolCells(),this.quill.update(r.a.sources.USER),this.quill.setSelection(this.quill.getIndex(o[0]),0,r.a.sources.SILENT),this.tableSelection.setSelection(o[0].domNode.getBoundingClientRect(),o[0].domNode.getBoundingClientRect())}},insertColumnLeft:{text:"Insert column left",iconSrc:W.a,handler(){const e=r.a.find(this.table);let t=he(this.columnToolCells,this.boundary,(e,t)=>Math.abs(e.x-t.x)<=5,this.quill.root.parentNode);const o=e.insertColumn(this.boundary,t,!1,this.quill.root.parentNode);this.tableColumnTool.updateToolCells(),this.quill.update(r.a.sources.USER),this.quill.setSelection(this.quill.getIndex(o[0]),0,r.a.sources.SILENT),this.tableSelection.setSelection(o[0].domNode.getBoundingClientRect(),o[0].domNode.getBoundingClientRect())}},insertRowUp:{text:"Insert row up",iconSrc:X.a,handler(){const e=r.a.find(this.table).insertRow(this.boundary,!1,this.quill.root.parentNode);this.quill.update(r.a.sources.USER),this.quill.setSelection(this.quill.getIndex(e[0]),0,r.a.sources.SILENT),this.tableSelection.setSelection(e[0].domNode.getBoundingClientRect(),e[0].domNode.getBoundingClientRect())}},insertRowDown:{text:"Insert row down",iconSrc:Y.a,handler(){const e=r.a.find(this.table).insertRow(this.boundary,!0,this.quill.root.parentNode);this.quill.update(r.a.sources.USER),this.quill.setSelection(this.quill.getIndex(e[0]),0,r.a.sources.SILENT),this.tableSelection.setSelection(e[0].domNode.getBoundingClientRect(),e[0].domNode.getBoundingClientRect())}},mergeCells:{text:"Merge selected cells",iconSrc:J.a,handler(){const e=r.a.find(this.table),t=e.rows().reduce((e,t)=>{let o=i(t.domNode.getBoundingClientRect(),this.quill.root.parentNode);return o.y>this.boundary.y-5&&o.y+o.height{let o=i(t.getBoundingClientRect(),this.quill.root.parentNode);return o.x>this.boundary.x-5&&o.x+o.width{let s=i(l.getBoundingClientRect(),n);return o(s,t)&&r.push(e.indexOf(l)),r},[])}(this.columnToolCells,this.boundary,(e,t)=>e.x+5>t.x&&e.x+e.width-5-1&&this.domNode.appendChild(r()));function r(){const e=document.createElement("div");return e.classList.add("qlbt-operation-menu-dividing"),e}this.options.color&&!1!==this.options.color&&(this.domNode.appendChild(r()),this.domNode.appendChild(function(e){const t=document.createElement("div");return t.classList.add("qlbt-operation-menu-subtitle"),t.innerText=e,t}(this.colorSubTitle)),this.domNode.appendChild(this.colorsItemCreator(this.cellColors)))}colorsItemCreator(e){const t=this,o=document.createElement("div");return o.classList.add("qlbt-operation-color-picker"),e.forEach(e=>{let n=function(e){const o=document.createElement("div");return o.classList.add("qlbt-operation-color-picker-item"),o.setAttribute("data-color",e),o.style.backgroundColor=e,o.addEventListener("click",function(){const o=t.tableSelection.selectedTds;o&&o.length>0&&o.forEach(t=>{t.format("cell-bg",e)})},!1),o}(e);o.appendChild(n)}),o}menuItemCreator(e){let{text:t,iconSrc:o,handler:n}=e;const r=document.createElement("div");r.classList.add("qlbt-operation-menu-item");const l=document.createElement("span");l.classList.add("qlbt-operation-menu-icon"),l.innerHTML=o;const i=document.createElement("span");return i.classList.add("qlbt-operation-menu-text"),i.innerText=t,r.appendChild(l),r.appendChild(i),r.addEventListener("click",n.bind(this),!1),r}}function he(e,t,o,n){return e.reduce((r,l)=>{let s=i(l.getBoundingClientRect(),n);return o(s,t)&&(r=e.indexOf(l)),r},!1)}const ue=r.a.import("delta");function pe(e,t,o){const n=e.parentNode,r="TABLE"===n.parentNode.tagName?n.parentNode:n.parentNode.parentNode,l=Array.from(r.querySelectorAll("tr")),i=Array.from(n.querySelectorAll("td")),a=l.indexOf(n)+1,c=i.indexOf(e)+1,d=e.getAttribute("colspan")||!1,h=e.getAttribute("rowspan")||!1,u=e.getAttribute("data-cell-bg")||e.style.backgroundColor;return 0===t.length()?t=(new ue).insert("\n",{"table-cell-line":{row:a,cell:c,rowspan:h,colspan:d}}):(t=t.reduce((e,t)=>{if(t.insert&&"string"==typeof t.insert){const o=[];let n=t.insert,r=0;for(let e=0;e{"\n"===o?e.insert("\n",t.attributes):e.insert(o,s(t.attributes,["table","table-cell-line"]))})}else e.insert(t.insert,t.attributes);return e},new ue)).reduce((e,t)=>(t.insert&&"string"==typeof t.insert&&t.insert.startsWith("\n")?e.insert(t.insert,Object.assign({},Object.assign({},{row:a},t.attributes.table),{"table-cell-line":{row:a,cell:c,rowspan:h,colspan:d,"cell-bg":u}},s(t.attributes,["table"]))):t.attributes&&t.attributes.background&&t.attributes.background===function(e){if(/^(rgb|RGB)/.test(e)){for(var t=e.toString().match(/\d+/g),o="#",n=0;n<3;n++)o+=("0"+Number(t[n]).toString(16)).slice(-2);return o}if(/^#([0-9a-fA-f]{3}|[0-9a-fA-f]{6})$/.test(e)){var r=e.replace(/#/,"").split("");if(6===r.length)return e;if(3===r.length){var l="#";for(n=0;n{if(t.insert&&"string"==typeof t.insert){const o=[];let n=t.insert,r=0;for(let e=0;e{"\n"===o?e.insert("\n",{"table-cell-line":{row:a,cell:c,rowspan:h,colspan:d}}):e.insert(o,t.attributes)})}else e.insert(t.insert,t.attributes);return e},new ue)).reduce((e,t)=>(t.insert&&"string"==typeof t.insert&&t.insert.startsWith("\n")?e.insert(t.insert,Object.assign({},{"table-cell-line":{row:a,cell:c,rowspan:h,colspan:d}})):e.insert(t.insert,Object.assign({},s(t.attributes,["table","table-cell-line"]))),e),new ue)}function me(e,t,o){let n=new ue;const r=e.querySelector("tr");if(null===r)return n;const l=Array.from(r.querySelectorAll("td")).concat(Array.from(r.querySelectorAll("th"))).reduce((e,t)=>{const o=t.getAttribute("colspan")||1;return e+=parseInt(o,10)},0),i=e.querySelectorAll("col").length;if(i===l)return t;{for(let e=0;e(t.insert(o.insert,o.attributes),o.attributes&&o.attributes["table-col"]&&(e+=o.insert.length)===i&&(t=t.concat(n)),t),new ue)}}const be=r.a.import("core/module"),ge=r.a.import("delta");class we extends be{static register(){r.a.register(M,!0),r.a.register(B,!0),r.a.register(S,!0),r.a.register(E,!0),r.a.register(T,!0),r.a.register(H,!0),r.a.register(O,!0),r.a.register(R,!0),r.a.register(R,!0)}constructor(e,t){super(e,t),this.quill.root.addEventListener("click",o=>{const n=a(o);if(!n||n.length<=0)return;const r=n.filter(e=>e.tagName&&"TABLE"===e.tagName.toUpperCase()&&e.classList.contains("quill-better-table"))[0];if(r){if(this.table===r)return;this.table&&this.hideTableTools(),this.showTableTools(r,e,t)}else this.table&&this.hideTableTools()},!1),this.quill.root.addEventListener("contextmenu",o=>{if(!this.table)return!0;o.preventDefault();const n=a(o);if(!n||n.length<=0)return;const r=n.filter(e=>e.tagName&&"TABLE"===e.tagName.toUpperCase()&&e.classList.contains("quill-better-table"))[0],l=n.filter(e=>e.tagName&&"TR"===e.tagName.toUpperCase()&&e.getAttribute("data-row"))[0],i=n.filter(e=>e.tagName&&"TD"===e.tagName.toUpperCase()&&e.getAttribute("data-row"))[0];let s=this.tableSelection.selectedTds.map(e=>e.domNode).includes(i);(this.tableSelection.selectedTds.length<=0||!s)&&this.tableSelection.setSelection(i.getBoundingClientRect(),i.getBoundingClientRect()),this.tableOperationMenu&&(this.tableOperationMenu=this.tableOperationMenu.destroy()),r&&(this.tableOperationMenu=new de({table:r,row:l,cell:i,left:o.pageX,top:o.pageY},e,t.operationMenu))},!1);e.getModule("keyboard");e.keyboard.addBinding({key:"Backspace"},{},function(e,t){if(0===e.index||this.quill.getLength()<=1)return!0;const[o]=this.quill.getLine(e.index);if(0===t.offset){const[t]=this.quill.getLine(e.index-1);if(null!=t&&"table-cell-line"===t.statics.blotName&&"table-cell-line"!==o.statics.blotName)return!1}return!0});let o=e.keyboard.bindings.Backspace.pop();e.keyboard.bindings.Backspace.splice(0,1,o),e.clipboard.addMatcher("td",pe),e.clipboard.addMatcher("th",fe),e.clipboard.addMatcher("table",me),e.clipboard.matchers=e.clipboard.matchers.filter(e=>"tr"!==e[0])}getTable(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.quill.getSelection();if(null==e)return[null,null,null,-1];const[t,o]=this.quill.getLine(e.index);if(null==t||t.statics.blotName!==S.blotName)return[null,null,null,-1];const n=t.tableCell(),r=n.row();return[r.table(),r,n,o]}insertTable(e,t){const o=this.quill.getSelection(!0);if(null==o)return;let n=this.quill.getLeaf(o.index)[0],l=(new ge).retain(o.index);!function e(t){return!(!t||!t.parent)&&(o=t.parent,o.statics.blotName===E.blotName||e(t.parent));var o}(n)?(l.insert("\n"),l=new Array(t).fill("\n").reduce((e,t)=>(e.insert(t,{"table-col":!0}),e),l),l=new Array(e).fill(0).reduce(e=>{let o=L();return new Array(t).fill("\n").reduce((e,t)=>(e.insert(t,{"table-cell-line":{row:o,cell:z()}}),e),e)},l),this.quill.updateContents(l,r.a.sources.USER),this.quill.setSelection(o.index+t+1,r.a.sources.API)):console.warn("Can not insert table into a table cell.")}showTableTools(e,t,o){this.table=e,this.columnTool=new p(e,t,o),this.tableSelection=new j(e,t,o)}hideTableTools(){this.columnTool&&this.columnTool.destroy(),this.tableSelection&&this.tableSelection.destroy(),this.tableOperationMenu&&this.tableOperationMenu.destroy(),this.columnTool=null,this.tableSelection=null,this.tableOperationMenu=null,this.table=null}}function ve(e){return{key:e?"ArrowUp":"ArrowDown",collapsed:!0,format:["table-cell-line"],handler(t,o){const n=e?"prev":"next";if(null!=o.line[n])return!0;const l=o.line.parent,i=l.parent[n];if(null!=i&&"table-row"===i.statics.blotName){let e=i.children.head,t=parseInt(e.formats().colspan,10),o=l,n=parseInt(o.formats().colspan,10);for(;null!=o.prev;)o=o.prev,n+=parseInt(o.formats().colspan,10);for(;null!=e.next&&t0&&this.quill.scroll.deleteAt(e.index,e.length);const n=Object.keys(t.format).reduce((e,n)=>(this.quill.scroll.query(n,o.BLOCK)&&!Array.isArray(t.format[n])&&(e[n]=t.format[n]),e),{});this.quill.insertText(e.index,"\n",n["table-cell-line"],r.a.sources.USER),this.quill.setSelection(e.index+1,r.a.sources.SILENT),this.quill.focus(),Object.keys(t.format).forEach(e=>{null==n[e]&&(Array.isArray(t.format[e])||"link"!==e&&this.quill.format(e,t.format[e],r.a.sources.USER))})}},"table-cell-line up":ve(!0),"table-cell-line down":ve(!1),"down-to-table":{key:"ArrowDown",collapsed:!0,handler(e,t){const o=t.line.next;if(o&&"table-view"===o.statics.blotName){const e=o.table().rows()[0].children.head.children.head;return this.quill.setSelection(e.offset(this.quill.scroll),0,r.a.sources.USER),!1}return!0}},"up-to-table":{key:"ArrowUp",collapsed:!0,handler(e,t){const o=t.line.prev;if(o&&"table-view"===o.statics.blotName){const e=o.table().rows(),t=e[e.length-1].children.head.children.head;return this.quill.setSelection(t.offset(this.quill.scroll),0,r.a.sources.USER),!1}return!0}}};t.default=we}]).default}); \ No newline at end of file +!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("quill")):"function"==typeof define&&define.amd?define(["quill"],t):"object"==typeof exports?exports.quillBetterTable=t(require("quill")):e.quillBetterTable=t(e.Quill)}(window,(function(e){return function(e){var t=window.webpackHotUpdatequillBetterTable;window.webpackHotUpdatequillBetterTable=function(e,o){!function(e,t){if(!x[e]||!y[e])return;for(var o in y[e]=!1,t)Object.prototype.hasOwnProperty.call(t,o)&&(f[o]=t[o]);0==--g&&0===v&&A()}(e,o),t&&t(e,o)};var o,n=!0,r="7eecf1b3e532dd32e8d1",l={},i=[],s=[];function a(e){var t=O[e];if(!t)return H;var n=function(n){return t.hot.active?(O[n]?-1===O[n].parents.indexOf(e)&&O[n].parents.push(e):(i=[e],o=n),-1===t.children.indexOf(n)&&t.children.push(n)):(console.warn("[HMR] unexpected require("+n+") from disposed module "+e),i=[]),H(n)},r=function(e){return{configurable:!0,enumerable:!0,get:function(){return H[e]},set:function(t){H[e]=t}}};for(var l in H)Object.prototype.hasOwnProperty.call(H,l)&&"e"!==l&&"t"!==l&&Object.defineProperty(n,l,r(l));return n.e=function(e){return"ready"===h&&u("prepare"),v++,H.e(e).then(t,(function(e){throw t(),e}));function t(){v--,"prepare"===h&&(w[e]||q(e),0===v&&0===g&&A())}},n.t=function(e,t){return 1&t&&(e=n(e)),H.t(e,-2&t)},n}function c(t){var n={_acceptedDependencies:{},_declinedDependencies:{},_selfAccepted:!1,_selfDeclined:!1,_selfInvalidated:!1,_disposeHandlers:[],_main:o!==t,active:!0,accept:function(e,t){if(void 0===e)n._selfAccepted=!0;else if("function"==typeof e)n._selfAccepted=e;else if("object"==typeof e)for(var o=0;o=0&&n._disposeHandlers.splice(t,1)},invalidate:function(){switch(this._selfInvalidated=!0,h){case"idle":(f={})[t]=e[t],u("ready");break;case"ready":T(t);break;case"prepare":case"check":case"dispose":case"apply":(b=b||[]).push(t)}},check:C,apply:S,status:function(e){if(!e)return h;d.push(e)},addStatusHandler:function(e){d.push(e)},removeStatusHandler:function(e){var t=d.indexOf(e);t>=0&&d.splice(t,1)},data:l[t]};return o=void 0,n}var d=[],h="idle";function u(e){h=e;for(var t=0;t0;){var r=n.pop(),l=r.id,i=r.chain;if((d=O[l])&&(!d.hot._selfAccepted||d.hot._selfInvalidated)){if(d.hot._selfDeclined)return{type:"self-declined",chain:i,moduleId:l};if(d.hot._main)return{type:"unaccepted",chain:i,moduleId:l};for(var s=0;s ")),A.type){case"self-declined":n.onDeclined&&n.onDeclined(A),n.ignoreDeclined||(S=new Error("Aborted because of self decline: "+A.moduleId+B));break;case"declined":n.onDeclined&&n.onDeclined(A),n.ignoreDeclined||(S=new Error("Aborted because of declined dependency: "+A.moduleId+" in "+A.parentId+B));break;case"unaccepted":n.onUnaccepted&&n.onUnaccepted(A),n.ignoreUnaccepted||(S=new Error("Aborted because "+h+" is not accepted"+B));break;case"accepted":n.onAccepted&&n.onAccepted(A),T=!0;break;case"disposed":n.onDisposed&&n.onDisposed(A),M=!0;break;default:throw new Error("Unexception type "+A.type)}if(S)return u("abort"),Promise.reject(S);if(T)for(h in y[h]=f[h],g(w,A.outdatedModules),A.outdatedDependencies)Object.prototype.hasOwnProperty.call(A.outdatedDependencies,h)&&(v[h]||(v[h]=[]),g(v[h],A.outdatedDependencies[h]));M&&(g(w,[A.moduleId]),y[h]=C)}var L,R=[];for(a=0;a0;)if(h=z.pop(),d=O[h]){var j={},D=d.hot._disposeHandlers;for(c=0;c=0&&V.parents.splice(L,1))}}for(h in v)if(Object.prototype.hasOwnProperty.call(v,h)&&(d=O[h]))for(I=v[h],c=0;c=0&&d.children.splice(L,1);u("apply"),void 0!==m&&(r=m,m=void 0);for(h in f=void 0,y)Object.prototype.hasOwnProperty.call(y,h)&&(e[h]=y[h]);var _=null;for(h in v)if(Object.prototype.hasOwnProperty.call(v,h)&&(d=O[h])){I=v[h];var U=[];for(a=0;a'},function(e,t){e.exports=''},function(e,t){e.exports=''},function(e,t){e.exports=''},function(e,t){e.exports=''},function(e,t){e.exports=''},function(e,t){e.exports=''},function(e,t){e.exports=''},function(e,t){e.exports=''},function(e,t,o){"use strict";var n=Object.prototype.hasOwnProperty,r=Object.prototype.toString,l=Object.defineProperty,i=Object.getOwnPropertyDescriptor,s=function(e){return"function"==typeof Array.isArray?Array.isArray(e):"[object Array]"===r.call(e)},a=function(e){if(!e||"[object Object]"!==r.call(e))return!1;var t,o=n.call(e,"constructor"),l=e.constructor&&e.constructor.prototype&&n.call(e.constructor.prototype,"isPrototypeOf");if(e.constructor&&!o&&!l)return!1;for(t in e);return void 0===t||n.call(e,t)},c=function(e,t){l&&"__proto__"===t.name?l(e,t.name,{enumerable:!0,configurable:!0,value:t.newValue,writable:!0}):e[t.name]=t.newValue},d=function(e,t){if("__proto__"===t){if(!n.call(e,t))return;if(i)return i(e,t).value}return e[t]};e.exports=function e(){var t,o,n,r,l,i,h=arguments[0],u=1,p=arguments.length,f=!1;for("boolean"==typeof h&&(f=h,h=arguments[1]||{},u=2),(null==h||"object"!=typeof h&&"function"!=typeof h)&&(h={});ut.includes(n)?o:Object.assign({},o,{[n]:e[n]}),{})}function a(e){let t;if(t=e.path||e.composedPath&&e.composedPath(),null==t&&e.target){t=[];let o=e.target;for(t.push(o);o&&o.parentNode;)o=o.parentNode,t.push(o)}return t}class c{constructor(e,t,o){if(!e)return null;this.table=e,this.quill=t,this.options=o,this.domNode=null,this.initColTool()}initColTool(){const e=this.quill.root.parentNode,t=(this.table.getBoundingClientRect(),e.getBoundingClientRect()),o=this.table.parentNode.getBoundingClientRect();this.domNode=document.createElement("div"),this.domNode.classList.add("qlbt-col-tool"),this.updateToolCells(),e.appendChild(this.domNode),l(this.domNode,{width:"".concat(o.width,"px"),height:"".concat(12,"px"),left:"".concat(o.left-t.left+e.scrollLeft,"px"),top:"".concat(o.top-t.top+e.scrollTop-12-5,"px")})}createToolCell(){const e=document.createElement("div");e.classList.add("qlbt-col-tool-cell");const t=document.createElement("div");return t.classList.add("qlbt-col-tool-cell-holder"),l(e,{height:"".concat(12,"px")}),e.appendChild(t),e}updateToolCells(){const e=r.a.find(this.table),t=e.children.tail.children.head.children,o=e.colGroup().children,n=function(e){return e.reduce((e,t)=>{const o=t.formats().colspan;return e+=parseInt(o,10)},0)}(t);let i=Array.from(this.domNode.querySelectorAll(".qlbt-col-tool-cell"));for(let e=0;e=n?i[e].remove():(s=i[e],l(s,{"min-width":"".concat(r,"px")})):(s=this.createToolCell(),this.domNode.appendChild(s),this.addColCellHolderHandler(s),l(s,{"min-width":"".concat(r,"px")}))}}destroy(){return this.domNode.remove(),null}addColCellHolderHandler(e){const t=r.a.find(this.table),o=e.querySelector(".qlbt-col-tool-cell-holder");let n=!1,i=0,s=0,a=0,c=0,d={},h={},u=null;const p=e=>{e.preventDefault(),n&&(s=e.clientX,a=c+s-i>=50?s-i:50-c,l(u,{left:"".concat(h.left+h.width-1+a,"px")}))},f=r=>{r.preventDefault();const m=Array.from(this.domNode.querySelectorAll(".qlbt-col-tool-cell")).indexOf(e),b=t.colGroup().children.at(m);n&&(b.format("width",c+a),l(e,{"min-width":"".concat(c+a,"px")}),i=0,s=0,a=0,c=0,n=!1,o.classList.remove("dragging")),document.removeEventListener("mousemove",p,!1),document.removeEventListener("mouseup",f,!1),d={},h={},u.remove(),u=null,t.updateTableWidth();const g=this.quill.getModule("better-table").tableSelection;g&&g.clearSelection()};o.addEventListener("mousedown",t=>{document.addEventListener("mousemove",p,!1),document.addEventListener("mouseup",f,!1),d=this.table.getBoundingClientRect(),h=e.getBoundingClientRect(),u=document.createElement("div"),l(u,{position:"fixed",top:"".concat(h.top,"px"),left:"".concat(h.left+h.width-1,"px"),zIndex:"100",height:"".concat(d.height+12+4,"px"),width:"1px",backgroundColor:"#35A7ED"}),document.body.appendChild(u),n=!0,i=t.clientX,c=h.width,o.classList.add("dragging")},!1)}colToolCells(){return Array.from(this.domNode.querySelectorAll(".qlbt-col-tool-cell"))}}const d=r.a.import("blots/block");class h extends d{static create(e){"string"==typeof e&&(e={value:e});const t=super.create(e.value);return v.forEach(o=>{e[o]&&t.setAttribute("data-".concat(o),e[o])}),w.forEach(o=>{e[o]&&t.setAttribute("data-".concat(o),e[o])}),t}static formats(e){const t={};return t.value=this.tagName.indexOf(e.tagName)+1,w.concat(v).reduce((t,o)=>(e.hasAttribute("data-".concat(o))&&(t[o]=e.getAttribute("data-".concat(o))||void 0),t),t)}format(e,t){const{row:o,cell:n,rowspan:r,colspan:l}=h.formats(this.domNode);e===h.blotName?t?super.format(e,{value:t,row:o,cell:n,rowspan:r,colspan:l}):o?this.replaceWith(x.blotName,{row:o,cell:n,rowspan:r,colspan:l}):super.format(e,t):super.format(e,t)}optimize(e){const{row:t,rowspan:o,colspan:n}=h.formats(this.domNode);if(!t||this.parent instanceof N||this.wrap(N.blotName,{row:t,colspan:n,rowspan:o}),this.enforceAllowedChildren(),null!=this.uiNode&&this.uiNode!==this.domNode.firstChild&&this.domNode.insertBefore(this.uiNode,this.domNode.firstChild),0===this.children.length)if(null!=this.statics.defaultChild){const e=this.scroll.create(this.statics.defaultChild.blotName);this.appendChild(e)}else this.remove();this.cache={}}}h.blotName="header",h.tagName=["H1","H2","H3","H4","H5","H6"];var u=h;const p=r.a.import("blots/break"),f=r.a.import("blots/block"),m=r.a.import("blots/container"),b=["width"],g={width:100},v=["row","cell"],w=["rowspan","colspan"],y={rowspan:1,colspan:1};class x extends f{static create(e){const t=super.create(e);return v.forEach(o=>{let n="row"===o?O:H;t.setAttribute("data-".concat(o),e[o]||n())}),w.forEach(o=>{t.setAttribute("data-".concat(o),e[o]||y[o])}),e["cell-bg"]&&t.setAttribute("data-cell-bg",e["cell-bg"]),t}static formats(e){return w.concat(v).concat(["cell-bg"]).reduce((t,o)=>(e.hasAttribute("data-".concat(o))&&(t[o]=e.getAttribute("data-".concat(o))||void 0),t),{})}format(e,t){if(w.concat(v).indexOf(e)>-1)t?this.domNode.setAttribute("data-".concat(e),t):this.domNode.removeAttribute("data-".concat(e));else if("cell-bg"===e)t?this.domNode.setAttribute("data-cell-bg",t):this.domNode.removeAttribute("data-cell-bg");else if("header"===e){if(!t)return;const{row:o,cell:n,rowspan:r,colspan:l}=x.formats(this.domNode);super.format(e,{value:t,row:o,cell:n,rowspan:r,colspan:l})}else super.format(e,t)}optimize(e){const t=this.domNode.getAttribute("data-row"),o=this.domNode.getAttribute("data-rowspan"),n=this.domNode.getAttribute("data-colspan"),r=this.domNode.getAttribute("data-cell-bg");!this.statics.requiredContainer||this.parent instanceof this.statics.requiredContainer||this.wrap(this.statics.requiredContainer.blotName,{row:t,colspan:n,rowspan:o,"cell-bg":r}),super.optimize(e)}tableCell(){return this.parent}}x.blotName="table-cell-line",x.className="qlbt-cell-line",x.tagName="P";class N extends m{checkMerge(){if(super.checkMerge()&&null!=this.next.children.head){const e=this.children.head.formats()[this.children.head.statics.blotName],t=this.children.tail.formats()[this.children.tail.statics.blotName],o=this.next.children.head.formats()[this.next.children.head.statics.blotName],n=this.next.children.tail.formats()[this.next.children.tail.statics.blotName];return e.cell===t.cell&&e.cell===o.cell&&e.cell===n.cell}return!1}static create(e){const t=super.create(e);return t.setAttribute("data-row",e.row),w.forEach(o=>{e[o]&&t.setAttribute(o,e[o])}),e["cell-bg"]&&(t.setAttribute("data-cell-bg",e["cell-bg"]),t.style.backgroundColor=e["cell-bg"]),t}static formats(e){const t={};return e.hasAttribute("data-row")&&(t.row=e.getAttribute("data-row")),e.hasAttribute("data-cell-bg")&&(t["cell-bg"]=e.getAttribute("data-cell-bg")),w.reduce((t,o)=>(e.hasAttribute(o)&&(t[o]=e.getAttribute(o)),t),t)}cellOffset(){return this.parent?this.parent.children.indexOf(this):-1}formats(){const e={};return this.domNode.hasAttribute("data-row")&&(e.row=this.domNode.getAttribute("data-row")),this.domNode.hasAttribute("data-cell-bg")&&(e["cell-bg"]=this.domNode.getAttribute("data-cell-bg")),w.reduce((e,t)=>(this.domNode.hasAttribute(t)&&(e[t]=this.domNode.getAttribute(t)),e),e)}toggleAttribute(e,t){t?this.domNode.setAttribute(e,t):this.domNode.removeAttribute(e)}formatChildren(e,t){this.children.forEach(o=>{o.format(e,t)})}format(e,t){w.indexOf(e)>-1?(this.toggleAttribute(e,t),this.formatChildren(e,t)):["row"].indexOf(e)>-1?(this.toggleAttribute("data-".concat(e),t),this.formatChildren(e,t)):"cell-bg"===e?(this.toggleAttribute("data-cell-bg",t),this.formatChildren(e,t),this.domNode.style.backgroundColor=t||"initial"):super.format(e,t)}optimize(e){const t=this.domNode.getAttribute("data-row");!this.statics.requiredContainer||this.parent instanceof this.statics.requiredContainer||this.wrap(this.statics.requiredContainer.blotName,{row:t}),super.optimize(e)}row(){return this.parent}rowOffset(){return this.row()?this.row().rowOffset():-1}table(){return this.row()&&this.row().table()}}N.blotName="table",N.tagName="TD";class C extends m{checkMerge(){if(super.checkMerge()&&null!=this.next.children.head){const e=this.children.head.formats(),t=this.children.tail.formats(),o=this.next.children.head.formats(),n=this.next.children.tail.formats();return e.row===t.row&&e.row===o.row&&e.row===n.row}return!1}static create(e){const t=super.create(e);return t.setAttribute("data-row",e.row),t}formats(){return["row"].reduce((e,t)=>(this.domNode.hasAttribute("data-".concat(t))&&(e[t]=this.domNode.getAttribute("data-".concat(t))),e),{})}optimize(e){!this.statics.requiredContainer||this.parent instanceof this.statics.requiredContainer||this.wrap(this.statics.requiredContainer.blotName),this.enforceAllowedChildren(),null!=this.uiNode&&this.uiNode!==this.domNode.firstChild&&this.domNode.insertBefore(this.uiNode,this.domNode.firstChild),this.children.length>0&&null!=this.next&&this.checkMerge()&&(this.next.moveChildren(this),this.next.remove())}rowOffset(){return this.parent?this.parent.children.indexOf(this):-1}table(){return this.parent&&this.parent.parent}}C.blotName="table-row",C.tagName="TR";class q extends m{}q.blotName="table-body",q.tagName="TBODY";class A extends f{static create(e){let t=super.create(e);return b.forEach(o=>{t.setAttribute("".concat(o),e[o]||g[o])}),t}static formats(e){return b.reduce((t,o)=>(e.hasAttribute("".concat(o))&&(t[o]=e.getAttribute("".concat(o))||void 0),t),{})}format(e,t){b.indexOf(e)>-1?this.domNode.setAttribute("".concat(e),t||g[e]):super.format(e,t)}html(){return this.domNode.outerHTML}}A.blotName="table-col",A.tagName="col";class S extends m{}S.blotName="table-col-group",S.tagName="colgroup";class E extends m{static create(){return super.create()}constructor(e,t){super(e,t),this.updateTableWidth()}updateTableWidth(){setTimeout(()=>{const e=this.colGroup();if(!e)return;const t=e.children.reduce((e,t)=>e+=parseInt(t.formats()[A.blotName].width,10),0);this.domNode.style.width="".concat(t,"px")},0)}cells(e){return this.rows().map(t=>t.children.at(e))}colGroup(){return this.children.head}deleteColumns(e,t=[],o){const[n]=this.descendants(q);if(null==n||null==n.children.head)return;const r=this.descendants(N),l=[],s=[];if(r.forEach(t=>{const n=i(t.domNode.getBoundingClientRect(),o);n.x+5>e.x&&n.x1-5e.x1-5&&s.push(t)}),l.length===r.length)return this.tableDestroy(),!0;t.forEach(e=>{this.colGroup().children.at(t[0]).remove()}),l.forEach(e=>{e.remove()}),s.forEach(e=>{const o=parseInt(e.formats().colspan,10);parseInt(e.formats().width,10);e.format("colspan",o-t.length)}),this.updateTableWidth()}deleteRow(e,t){const[o]=this.descendants(q);if(null==o||null==o.children.head)return;const n=this.descendants(N),r=this.descendants(C),l=[],s=[],a=[],c=r.filter(o=>{const n=i(o.domNode.getBoundingClientRect(),t);return n.y>e.y-5&&n.y1{const n=i(o.domNode.getBoundingClientRect(),t);n.y>e.y-5&&n.y1e.y1-5&&(s.push(o),Math.abs(n.y-e.y)<5&&a.push(o))}),l.length===n.length)return void this.tableDestroy();const d=this.rows().reduce((o,n)=>{let r=i(n.domNode.getBoundingClientRect(),t);return r.y>e.y-5&&r.y1{const o=i(e.domNode.getBoundingClientRect(),t),n=e.parent.next,r=n.children.reduce((e,n)=>{const r=i(n.domNode.getBoundingClientRect(),t);return Math.abs(o.x1-r.x)<5&&(e=n),e},null);n.insertBefore(e,r),e.format("row",n.formats().row)}),l.forEach(e=>{e.remove()}),s.forEach(e=>{const t=parseInt(e.formats().rowspan,10);e.format("rowspan",t-d)}),c.forEach(e=>e.remove())}tableDestroy(){const e=r.a.find(this.scroll.domNode.parentNode),t=e.getModule("better-table");this.remove(),t.hideTableTools(),e.update(r.a.sources.USER)}insertCell(e,t){const o=H(),n=e.formats().row,r=this.scroll.create(N.blotName,Object.assign({},y,{row:n})),l=this.scroll.create(x.blotName,{row:n,cell:o});r.appendChild(l),t?e.insertBefore(r,t):e.appendChild(r)}insertColumn(e,t,o=!0,n){const[r]=this.descendants(q),[l]=this.descendants(S),s=this.descendants(A);let a=[],c=[],d=[];if(null==r||null==r.children.head)return;this.descendants(N).forEach(t=>{const r=i(t.domNode.getBoundingClientRect(),n);o?Math.abs(r.x1-e.x1)<5?a.push(t):e.x1-r.x>5&&e.x1-r.x1<-5&&c.push(t):Math.abs(r.x-e.x)<5?a.push(t):e.x-r.x>5&&e.x-r.x1<-5&&c.push(t)}),a.forEach(e=>{const t=o?e.next:e,n=H(),r=e.parent,l=r.formats().row,i=e.formats(),s=this.scroll.create(N.blotName,Object.assign({},y,{row:l,rowspan:i.rowspan})),a=this.scroll.create(x.blotName,{row:l,cell:n,rowspan:i.rowspan});s.appendChild(a),t?r.insertBefore(s,t):r.appendChild(s),d.push(s)});const h=this.scroll.create(A.blotName,!0);let u=o?s[t].next:s[t];return u?l.insertBefore(h,u):l.appendChild(h),c.forEach(e=>{const t=e.formats().colspan;e.format("colspan",parseInt(t,10)+1),d.push(e)}),d.sort((e,t)=>e.domNode.getBoundingClientRect().y-t.domNode.getBoundingClientRect().y),this.updateTableWidth(),d}insertRow(e,t,o){const[n]=this.descendants(q);if(null==n||null==n.children.head)return;const r=this.descendants(N),l=O(),s=this.scroll.create(C.blotName,{row:l});let a=[],c=[],d=[];r.forEach(n=>{const r=i(n.domNode.getBoundingClientRect(),o);t?Math.abs(r.y1-e.y1)<5?a.push(n):e.y1-r.y>5&&e.y1-r.y1<-5&&c.push(n):Math.abs(r.y-e.y)<5?a.push(n):e.y-r.y>5&&e.y-r.y1<-5&&c.push(n)});const h=(e,t)=>e.domNode.getBoundingClientRect().x-t.domNode.getBoundingClientRect().x;a.sort(h),a.forEach(e=>{const t=H(),o=e.formats(),n=this.scroll.create(N.blotName,Object.assign({},y,{row:l,colspan:o.colspan})),r=this.scroll.create(x.blotName,{row:l,cell:t,colspan:o.colspan}),i=this.scroll.create(p.blotName);r.appendChild(i),n.appendChild(r),s.appendChild(n),d.push(n)}),c.forEach(e=>{const t=parseInt(e.formats().rowspan,10);e.format("rowspan",t+1),d.push(e)});const u=this.rows().find(n=>{let r=i(n.domNode.getBoundingClientRect(),o);return t?Math.abs(r.y-e.y-e.height)<5:Math.abs(r.y-e.y)<5});return n.insertBefore(s,u),d.sort(h),d}mergeCells(e,t,o,n,r){const l=t.reduce((e,t,r)=>(0!==r?(e&&t.moveChildren(e),t.remove()):(t.format("colspan",n),t.format("rowspan",o),e=t),e),null);let i=l.domNode.getAttribute("data-row"),s=l.children.head.domNode.getAttribute("data-cell");return l.children.forEach(e=>{e.format("cell",s),e.format("row",i),e.format("colspan",n),e.format("rowspan",o)}),l}unmergeCells(e,t){let o={},n=1,r=1;e.forEach(e=>{if(o=e.formats(),n=o.rowspan,r=o.colspan,r>1){let t=e.next,o=e.row();e.format("colspan",1);for(let e=r;e>1;e--)this.insertCell(o,t)}if(n>1){let o=n,l=e.row().next;for(;o>1;){let n=l.children.reduce((o,n)=>{let r=i(e.domNode.getBoundingClientRect(),t),l=i(n.domNode.getBoundingClientRect(),t);return Math.abs(r.x1-l.x)<5&&(o=n),o},null);for(let e=r;e>0;e--)this.insertCell(l,n);o-=1,l=l.next}e.format("rowspan",1)}})}rows(){const e=this.children.tail;return null==e?[]:e.children.map(e=>e)}}E.blotName="table-container",E.className="quill-better-table",E.tagName="TABLE";class T extends m{constructor(e,t){super(e,t);const o=r.a.find(e.domNode.parentNode);t.addEventListener("scroll",e=>{const t=o.getModule("better-table");t.columnTool&&(t.columnTool.domNode.scrollLeft=e.target.scrollLeft),t.tableSelection&&t.tableSelection.selectedTds.length>0&&t.tableSelection.repositionHelpLines()},!1)}table(){return this.children.head}}function O(){const e=Math.random().toString(36).slice(2,6);return"row-".concat(e)}function H(){const e=Math.random().toString(36).slice(2,6);return"cell-".concat(e)}T.blotName="table-view",T.className="quill-better-table-wrapper",T.tagName="DIV",T.allowedChildren=[E],E.requiredContainer=T,E.allowedChildren=[q,S],q.requiredContainer=E,q.allowedChildren=[C],C.requiredContainer=q,C.allowedChildren=[N],N.requiredContainer=C,N.allowedChildren=[x,u],x.requiredContainer=N,S.allowedChildren=[A],S.requiredContainer=E,A.requiredContainer=S;const M=["left","right","top","bottom"];class B{constructor(e,t,o){if(!e)return null;this.table=e,this.quill=t,this.options=o,this.boundary={},this.selectedTds=[],this.dragging=!1,this.selectingHandler=this.mouseDownHandler.bind(this),this.clearSelectionHandler=this.clearSelection.bind(this),this.helpLinesInitial(),this.quill.root.addEventListener("mousedown",this.selectingHandler,!1),this.quill.on("text-change",this.clearSelectionHandler)}helpLinesInitial(){let e=this.quill.root.parentNode;M.forEach(t=>{this[t]=document.createElement("div"),this[t].classList.add("qlbt-selection-line"),this[t].classList.add("qlbt-selection-line-"+t),l(this[t],{position:"absolute",display:"none","background-color":"#0589f3"}),e.appendChild(this[t])})}mouseDownHandler(e){if(0!==e.button||!e.target.closest(".quill-better-table"))return;this.quill.root.addEventListener("mousemove",r,!1),this.quill.root.addEventListener("mouseup",(function e(o){t.quill.root.removeEventListener("mousemove",r,!1),t.quill.root.removeEventListener("mouseup",e,!1),t.dragging=!1}),!1);const t=this,o=e.target.closest("td[data-row]"),n=i(o.getBoundingClientRect(),this.quill.root.parentNode);function r(e){if(0!==e.button||!e.target.closest(".quill-better-table"))return;const r=e.target.closest("td[data-row]"),l=i(r.getBoundingClientRect(),t.quill.root.parentNode);t.boundary=L(n,l),t.correctBoundary(),t.selectedTds=t.computeSelectedTds(),t.repositionHelpLines(),o!==r&&t.quill.blur()}this.dragging=!0,this.boundary=L(n,n),this.correctBoundary(),this.selectedTds=this.computeSelectedTds(),this.repositionHelpLines()}correctBoundary(){r.a.find(this.table).descendants(N).forEach(e=>{let{x:t,y:o,width:n,height:r}=i(e.domNode.getBoundingClientRect(),this.quill.root.parentNode);(t+2>=this.boundary.x&&t+2<=this.boundary.x1||t-2+n>=this.boundary.x&&t-2+n<=this.boundary.x1)&&(o+2>=this.boundary.y&&o+2<=this.boundary.y1||o-2+r>=this.boundary.y&&o-2+r<=this.boundary.y1)&&(this.boundary=L(this.boundary,{x:t,y:o,width:n,height:r}))})}computeSelectedTds(){return r.a.find(this.table).descendants(N).reduce((e,t)=>{let{x:o,y:n,width:r,height:l}=i(t.domNode.getBoundingClientRect(),this.quill.root.parentNode);return o+2>=this.boundary.x&&o-2+r<=this.boundary.x1&&n+2>=this.boundary.y&&n-2+l<=this.boundary.y1&&e.push(t),e},[])}repositionHelpLines(){const e=this.table.parentNode.scrollLeft;l(this.left,{display:"block",left:"".concat(this.boundary.x-e-1,"px"),top:"".concat(this.boundary.y,"px"),height:"".concat(this.boundary.height+1,"px"),width:"1px"}),l(this.right,{display:"block",left:"".concat(this.boundary.x1-e,"px"),top:"".concat(this.boundary.y,"px"),height:"".concat(this.boundary.height+1,"px"),width:"1px"}),l(this.top,{display:"block",left:"".concat(this.boundary.x-1-e,"px"),top:"".concat(this.boundary.y,"px"),width:"".concat(this.boundary.width+1,"px"),height:"1px"}),l(this.bottom,{display:"block",left:"".concat(this.boundary.x-1-e,"px"),top:"".concat(this.boundary.y1+1,"px"),width:"".concat(this.boundary.width+1,"px"),height:"1px"})}refreshHelpLinesPosition(){const e=i(this.selectedTds[0].domNode.getBoundingClientRect(),this.quill.root.parentNode),t=i(this.selectedTds[this.selectedTds.length-1].domNode.getBoundingClientRect(),this.quill.root.parentNode);this.boundary=L(e,t),this.repositionHelpLines()}destroy(){return M.forEach(e=>{this[e].remove(),this[e]=null}),this.quill.root.removeEventListener("mousedown",this.selectingHandler,!1),this.quill.off("text-change",this.clearSelectionHandler),null}setSelection(e,t){this.boundary=L(i(e,this.quill.root.parentNode),i(t,this.quill.root.parentNode)),this.correctBoundary(),this.selectedTds=this.computeSelectedTds(),this.repositionHelpLines()}clearSelection(){this.boundary={},this.selectedTds=[],M.forEach(e=>{this[e]&&l(this[e],{display:"none"})})}}function L(e,t){let o=Math.min(e.x,t.x,e.x+e.width-1,t.x+t.width-1),n=Math.max(e.x,t.x,e.x+e.width-1,t.x+t.width-1),r=Math.min(e.y,t.y,e.y+e.height-1,t.y+t.height-1),l=Math.max(e.y,t.y,e.y+e.height-1,t.y+t.height-1);return{x:o,x1:n,y:r,y1:l,width:n-o,height:l-r}}var R=o(1),k=o.n(R),I=o(2),z=o.n(I),j=o(3),D=o.n(j),V=o(4),_=o.n(V),U=o(5),P=o.n(U),W=o(6),G=o.n(W),X=o(7),$=o.n(X),K=o(8),Y=o.n(K),J=o(9),Q=o.n(J);const F=["white","red","yellow","blue"],Z={insertColumnRight:{text:"Insert column right",iconSrc:k.a,handler(){const e=r.a.find(this.table);let t=te(this.columnToolCells,this.boundary,(e,t)=>Math.abs(e.x+e.width-t.x1)<=5,this.quill.root.parentNode);const o=e.insertColumn(this.boundary,t,!0,this.quill.root.parentNode);this.tableColumnTool.updateToolCells(),this.quill.update(r.a.sources.USER),this.quill.setSelection(this.quill.getIndex(o[0]),0,r.a.sources.SILENT),this.tableSelection.setSelection(o[0].domNode.getBoundingClientRect(),o[0].domNode.getBoundingClientRect())}},insertColumnLeft:{text:"Insert column left",iconSrc:z.a,handler(){const e=r.a.find(this.table);let t=te(this.columnToolCells,this.boundary,(e,t)=>Math.abs(e.x-t.x)<=5,this.quill.root.parentNode);const o=e.insertColumn(this.boundary,t,!1,this.quill.root.parentNode);this.tableColumnTool.updateToolCells(),this.quill.update(r.a.sources.USER),this.quill.setSelection(this.quill.getIndex(o[0]),0,r.a.sources.SILENT),this.tableSelection.setSelection(o[0].domNode.getBoundingClientRect(),o[0].domNode.getBoundingClientRect())}},insertRowUp:{text:"Insert row up",iconSrc:D.a,handler(){const e=r.a.find(this.table).insertRow(this.boundary,!1,this.quill.root.parentNode);this.quill.update(r.a.sources.USER),this.quill.setSelection(this.quill.getIndex(e[0]),0,r.a.sources.SILENT),this.tableSelection.setSelection(e[0].domNode.getBoundingClientRect(),e[0].domNode.getBoundingClientRect())}},insertRowDown:{text:"Insert row down",iconSrc:_.a,handler(){const e=r.a.find(this.table).insertRow(this.boundary,!0,this.quill.root.parentNode);this.quill.update(r.a.sources.USER),this.quill.setSelection(this.quill.getIndex(e[0]),0,r.a.sources.SILENT),this.tableSelection.setSelection(e[0].domNode.getBoundingClientRect(),e[0].domNode.getBoundingClientRect())}},mergeCells:{text:"Merge selected cells",iconSrc:P.a,handler(){const e=r.a.find(this.table),t=e.rows().reduce((e,t)=>{let o=i(t.domNode.getBoundingClientRect(),this.quill.root.parentNode);return o.y>this.boundary.y-5&&o.y+o.height{let o=i(t.getBoundingClientRect(),this.quill.root.parentNode);return o.x>this.boundary.x-5&&o.x+o.width{let s=i(l.getBoundingClientRect(),n);return o(s,t)&&r.push(e.indexOf(l)),r},[])}(this.columnToolCells,this.boundary,(e,t)=>e.x+5>t.x&&e.x+e.width-5-1&&this.domNode.appendChild(n()));function n(){const e=document.createElement("div");return e.classList.add("qlbt-operation-menu-dividing"),e}this.options.color&&!1!==this.options.color&&(this.domNode.appendChild(n()),this.domNode.appendChild(function(e){const t=document.createElement("div");return t.classList.add("qlbt-operation-menu-subtitle"),t.innerText=e,t}(this.colorSubTitle)),this.domNode.appendChild(this.colorsItemCreator(this.cellColors)))}colorsItemCreator(e){const t=this,o=document.createElement("div");return o.classList.add("qlbt-operation-color-picker"),e.forEach(e=>{let n=function(e){const o=document.createElement("div");return o.classList.add("qlbt-operation-color-picker-item"),o.setAttribute("data-color",e),o.style.backgroundColor=e,o.addEventListener("click",(function(){const o=t.tableSelection.selectedTds;o&&o.length>0&&o.forEach(t=>{t.format("cell-bg",e)})}),!1),o}(e);o.appendChild(n)}),o}menuItemCreator({text:e,iconSrc:t,handler:o}){const n=document.createElement("div");n.classList.add("qlbt-operation-menu-item");const r=document.createElement("span");r.classList.add("qlbt-operation-menu-icon"),r.innerHTML=t;const l=document.createElement("span");return l.classList.add("qlbt-operation-menu-text"),l.innerText=e,n.appendChild(r),n.appendChild(l),n.addEventListener("click",o.bind(this),!1),n}}function te(e,t,o,n){return e.reduce((r,l)=>{let s=i(l.getBoundingClientRect(),n);return o(s,t)&&(r=e.indexOf(l)),r},!1)}const oe=r.a.import("ui/picker");var ne=class extends oe{constructor(e,t){super(e),this.label.innerHTML=t,this.container.classList.add("ql-table-picker")}buildItem(e){const t=super.buildItem(e);return t.addEventListener("mouseover",()=>{let e=t.getAttribute("data-value").split("x"),o=parseInt(e[1]),n=parseInt(e[0]),r=Array.from(this.container.querySelectorAll(".ql-picker-item"));e=this.container.querySelector(".ql-picker-item:last-child").getAttribute("data-value").split("x");let l=parseInt(e[0]);r.forEach(e=>{e.classList.remove("hover")});for(let e=0;e{e.classList.add("hover")})}),t}selectItem(e,t=!1){super.selectItem(e,t),null!=e&&(e.classList.remove("ql-selected"),e.label&&(e.label.removeAttribute("data-value"),e.label.removeAttribute("data-label")),Array.from(this.container.querySelectorAll(".hover")).forEach(e=>{e.classList.remove("hover")}))}},re=o(10),le=o.n(re);const ie=r.a.import("themes/snow");var se=class extends ie{constructor(e,t){super(e,t)}buildPickers(e,t){let o=(e=Array.from(e)).map((e,o,n)=>{if(e.classList.contains("ql-better-table")){if(n.splice(o,1),null==e.querySelector("option"))for(let t=1;t<=8;t++)for(let o=1;o<=10;o++){const n=document.createElement("option");n.setAttribute("value",o+"x"+t),e.appendChild(n)}return new ne(e,t.table)}});super.buildPickers(e,t),this.pickers=le()([],this.pickers,o)}};const ae=r.a.import("delta");function ce(e,t,o){const n=e.parentNode,r="TABLE"===n.parentNode.tagName?n.parentNode:n.parentNode.parentNode,l=Array.from(r.querySelectorAll("tr")),i=Array.from(n.querySelectorAll("td")),a=l.indexOf(n)+1,c=i.indexOf(e)+1,d=e.getAttribute("colspan")||!1,h=e.getAttribute("rowspan")||!1,u=e.getAttribute("data-cell-bg")||e.style.backgroundColor;return 0===t.length()?t=(new ae).insert("\n",{"table-cell-line":{row:a,cell:c,rowspan:h,colspan:d}}):(t=t.reduce((e,t)=>{if(t.insert&&"string"==typeof t.insert){const o=[];let n=t.insert,r=0;for(let e=0;e{"\n"===o?e.insert("\n",t.attributes):e.insert(o,s(t.attributes,["table","table-cell-line"]))})}else e.insert(t.insert,t.attributes);return e},new ae)).reduce((e,t)=>(t.insert&&"string"==typeof t.insert&&t.insert.startsWith("\n")?e.insert(t.insert,Object.assign({},Object.assign({},{row:a},t.attributes.table),{"table-cell-line":{row:a,cell:c,rowspan:h,colspan:d,"cell-bg":u}},s(t.attributes,["table"]))):t.attributes&&t.attributes.background&&t.attributes.background===function(e){if(/^(rgb|RGB)/.test(e)){for(var t=e.toString().match(/\d+/g),o="#",n=0;n<3;n++)o+=("0"+Number(t[n]).toString(16)).slice(-2);return o}if(/^#([0-9a-fA-f]{3}|[0-9a-fA-f]{6})$/.test(e)){var r=e.replace(/#/,"").split("");if(6===r.length)return e;if(3===r.length){var l="#";for(n=0;n{if(t.insert&&"string"==typeof t.insert){const o=[];let n=t.insert,r=0;for(let e=0;e{"\n"===o?e.insert("\n",{"table-cell-line":{row:a,cell:c,rowspan:h,colspan:d}}):e.insert(o,t.attributes)})}else e.insert(t.insert,t.attributes);return e},new ae)).reduce((e,t)=>(t.insert&&"string"==typeof t.insert&&t.insert.startsWith("\n")?e.insert(t.insert,Object.assign({},{"table-cell-line":{row:a,cell:c,rowspan:h,colspan:d}})):e.insert(t.insert,Object.assign({},s(t.attributes,["table","table-cell-line"]))),e),new ae)}function he(e,t,o){let n=new ae;const r=e.querySelector("tr");if(null===r)return n;const l=Array.from(r.querySelectorAll("td")).concat(Array.from(r.querySelectorAll("th"))).reduce((e,t)=>{const o=t.getAttribute("colspan")||1;return e+=parseInt(o,10)},0),i=e.querySelectorAll("col").length;if(i===l)return t;{for(let e=0;e(t.insert(o.insert,o.attributes),o.attributes&&o.attributes["table-col"]&&(e+=o.insert.length,e===i&&(t=t.concat(n))),t),new ae)}}const ue=r.a.import("core/module"),pe=r.a.import("delta");class fe extends ue{static register(){r.a.register(A,!0),r.a.register(S,!0),r.a.register(x,!0),r.a.register(N,!0),r.a.register(C,!0),r.a.register(q,!0),r.a.register(E,!0),r.a.register(T,!0),r.a.register(T,!0),r.a.register("themes/better-table-snow",se,!0),r.a.register("ui/table-picker",ne,!0)}constructor(e,t){super(e,t),this.quill.root.addEventListener("click",o=>{const n=a(o);if(!n||n.length<=0)return;const r=n.filter(e=>e.tagName&&"TABLE"===e.tagName.toUpperCase()&&e.classList.contains("quill-better-table"))[0];if(r){if(this.table===r)return;this.table&&this.hideTableTools(),this.showTableTools(r,e,t)}else this.table&&this.hideTableTools()},!1),this.quill.root.addEventListener("contextmenu",o=>{if(!this.table)return!0;o.preventDefault();const n=a(o);if(!n||n.length<=0)return;const r=n.filter(e=>e.tagName&&"TABLE"===e.tagName.toUpperCase()&&e.classList.contains("quill-better-table"))[0],l=n.filter(e=>e.tagName&&"TR"===e.tagName.toUpperCase()&&e.getAttribute("data-row"))[0],i=n.filter(e=>e.tagName&&"TD"===e.tagName.toUpperCase()&&e.getAttribute("data-row"))[0];let s=this.tableSelection.selectedTds.map(e=>e.domNode).includes(i);(this.tableSelection.selectedTds.length<=0||!s)&&this.tableSelection.setSelection(i.getBoundingClientRect(),i.getBoundingClientRect()),this.tableOperationMenu&&(this.tableOperationMenu=this.tableOperationMenu.destroy()),r&&(this.tableOperationMenu=new ee({table:r,row:l,cell:i,left:o.pageX,top:o.pageY},e,t.operationMenu||{}))},!1),e.keyboard.addBinding({key:"Backspace"},{},(function(e,t){if(0===e.index||this.quill.getLength()<=1)return!0;const[o]=this.quill.getLine(e.index);if(0===t.offset){const[t]=this.quill.getLine(e.index-1);if(null!=t&&"table-cell-line"===t.statics.blotName&&"table-cell-line"!==o.statics.blotName)return!1}return!0}));let o=e.keyboard.bindings.Backspace.pop();e.keyboard.bindings.Backspace.splice(0,1,o),e.clipboard.addMatcher("td",ce),e.clipboard.addMatcher("th",de),e.clipboard.addMatcher("table",he),e.clipboard.matchers=e.clipboard.matchers.filter(e=>"tr"!==e[0]);const n=e.getModule("toolbar"),r=n.container.querySelector("select.ql-better-table");n&&r&&(n.addHandler("better-table",this.insertTable),n.attach(r))}getTable(e=this.quill.getSelection()){if(null==e)return[null,null,null,-1];const[t,o]=this.quill.getLine(e.index);if(null==t||t.statics.blotName!==x.blotName)return[null,null,null,-1];const n=t.tableCell(),r=n.row();return[r.table(),r,n,o]}insertTable(e,t){if(!t){if(!e.match(/^\d+x\d+$/))return;{let o=e.split("x");t=parseInt(o[0]),e=parseInt(o[1])}}const o=this.quill.getSelection(!0);if(null==o)return;let n=this.quill.getLeaf(o.index)[0],l=(new pe).retain(o.index);!function e(t){return!(!t||!t.parent)&&(o=t.parent,o.statics.blotName===N.blotName||e(t.parent));var o}(n)?(l.insert("\n"),l=new Array(t).fill("\n").reduce((e,t)=>(e.insert(t,{"table-col":!0}),e),l),l=new Array(e).fill(0).reduce(e=>{let o=O();return new Array(t).fill("\n").reduce((e,t)=>(e.insert(t,{"table-cell-line":{row:o,cell:H()}}),e),e)},l),this.quill.updateContents(l,r.a.sources.USER),this.quill.setSelection(o.index+t+1,r.a.sources.API)):console.warn("Can not insert table into a table cell.")}showTableTools(e,t,o){this.table=e,this.columnTool=new c(e,t,o),this.tableSelection=new B(e,t,o)}hideTableTools(){this.columnTool&&this.columnTool.destroy(),this.tableSelection&&this.tableSelection.destroy(),this.tableOperationMenu&&this.tableOperationMenu.destroy(),this.columnTool=null,this.tableSelection=null,this.tableOperationMenu=null,this.table=null}}function me(e){return{key:e?"ArrowUp":"ArrowDown",collapsed:!0,format:["table-cell-line"],handler(t,o){const n=e?"prev":"next";if(null!=o.line[n])return!0;const l=o.line.parent,i=l.parent[n];if(null!=i&&"table-row"===i.statics.blotName){let e=i.children.head,t=parseInt(e.formats().colspan,10),o=l,n=parseInt(o.formats().colspan,10);for(;null!=o.prev;)o=o.prev,n+=parseInt(o.formats().colspan,10);for(;null!=e.next&&t0&&this.quill.scroll.deleteAt(e.index,e.length);const n=Object.keys(t.format).reduce((e,n)=>(this.quill.scroll.query(n,o.BLOCK)&&!Array.isArray(t.format[n])&&(e[n]=t.format[n]),e),{});this.quill.insertText(e.index,"\n",n["table-cell-line"],r.a.sources.USER),this.quill.setSelection(e.index+1,r.a.sources.SILENT),this.quill.focus(),Object.keys(t.format).forEach(e=>{null==n[e]&&(Array.isArray(t.format[e])||"link"!==e&&this.quill.format(e,t.format[e],r.a.sources.USER))})}},"table-cell-line up":me(!0),"table-cell-line down":me(!1),"down-to-table":{key:"ArrowDown",collapsed:!0,handler(e,t){const o=t.line.next;if(o&&"table-view"===o.statics.blotName){const e=o.table().rows()[0].children.head.children.head;return this.quill.setSelection(e.offset(this.quill.scroll),0,r.a.sources.USER),!1}return!0}},"up-to-table":{key:"ArrowUp",collapsed:!0,handler(e,t){const o=t.line.prev;if(o&&"table-view"===o.statics.blotName){const e=o.table().rows(),t=e[e.length-1].children.head.children.head;return this.quill.setSelection(t.offset(this.quill.scroll),0,r.a.sources.USER),!1}return!0}}};t.default=fe}]).default})); \ No newline at end of file diff --git a/package.json b/package.json index 5aa6f74..40cd727 100644 --- a/package.json +++ b/package.json @@ -5,7 +5,10 @@ "main": "dist/quill-better-table.js", "scripts": { "dev": "webpack-dev-server --config webpack.config.js --mode=development", - "build": "webpack --config webpack.config.js --mode=production --env.minimize; webpack --config webpack.config.js --mode=production; rm dist/quill-better-table;", + "build": "npm run build:webpack && npm run build:webpack:minimize && npm run build:cleanup", + "build:webpack:minimize": "webpack --config webpack.config.js --mode=production --env.minimize", + "build:webpack": "webpack --config webpack.config.js --mode=production", + "build:cleanup": "rm dist/quill-better-table", "test": "echo \"Error: no test specified\" && exit 1" }, "repository": { @@ -27,17 +30,18 @@ "homepage": "https://github.com/soccerloway/quill-better-table#readme", "dependencies": {}, "devDependencies": { - "quill": "^2.0.0-dev.3", "@babel/core": "^7.4.3", "@babel/preset-env": "^7.4.3", "babel-loader": "^8.0.5", "babel-plugin-istanbul": "^5.1.1", "css-loader": "^2.1.1", + "extend": "^3.0.2", "file-loader": "^3.0.1", "html-loader": "^0.5.5", "html-webpack-plugin": "^3.2.0", "mini-css-extract-plugin": "^0.5.0", "node-sass": "^4.11.0", + "quill": "^2.0.0-dev.3", "sass-loader": "^7.1.0", "style-loader": "^0.23.1", "url-loader": "^1.1.2", diff --git a/src/assets/quill-better-table.scss b/src/assets/quill-better-table.scss index 75f1bd0..e8bc76f 100644 --- a/src/assets/quill-better-table.scss +++ b/src/assets/quill-better-table.scss @@ -157,3 +157,44 @@ table.quill-better-table { } } } + +.ql-snow { + .ql-picker.ql-table-picker { + width: 28px; + + .ql-picker-label { + border: none; + padding: 0; + + svg { + float: left; + height: 100%; + margin-top: auto; + position: static; + right: auto; + top: auto; + width: auto; + } + } + + .ql-picker-options { + padding: 3px 5px; + width: 212px; + } + + .ql-picker-item { + background-color: lighten(desaturate($primaryColor, 20%), 40%); + border: 1px solid transparent; + float: left; + height: 16px; + margin: 2px; + padding: 0; + width: 16px; + + &.hover { + background-color: darken(desaturate($primaryColor, 20%), 10%); + border-color: #000000; + } + } + } +} \ No newline at end of file diff --git a/src/quill-better-table.js b/src/quill-better-table.js index e8d3ca7..ac9a88b 100644 --- a/src/quill-better-table.js +++ b/src/quill-better-table.js @@ -2,6 +2,8 @@ import Quill from 'quill' import TableColumnTool from './modules/table-column-tool' import TableSelection from './modules/table-selection' import TableOperationMenu from './modules/table-operation-menu' +import BetterTableSnowTheme from "./themes/better-table-snow"; +import TablePicker from "./ui/table-picker"; // import table node matchers import { @@ -41,6 +43,9 @@ class BetterTable extends Module { Quill.register(TableViewWrapper, true); // register customized Header,overwriting quill built-in Header // Quill.register('formats/header', Header, true); + + Quill.register('themes/better-table-snow', BetterTableSnowTheme, true); + Quill.register('ui/table-picker', TablePicker, true); } constructor(quill, options) { @@ -120,13 +125,13 @@ class BetterTable extends Module { cell: cellNode, left: evt.pageX, top: evt.pageY - }, quill, options.operationMenu) + }, quill, options.operationMenu || {}) } }, false) // add keyboard binding:Backspace // prevent user hits backspace to delete table cell - const KeyBoard = quill.getModule('keyboard') + // const KeyBoard = quill.getModule('keyboard') quill.keyboard.addBinding( { key: 'Backspace' }, {}, @@ -159,6 +164,13 @@ class BetterTable extends Module { quill.clipboard.matchers = quill.clipboard.matchers.filter(matcher => { return matcher[0] !== 'tr' }) + + const toolbar = quill.getModule('toolbar'); + const input = toolbar.container.querySelector('select.ql-better-table'); + if (toolbar && input) { + toolbar.addHandler('better-table', this.insertTable); + toolbar.attach(input); + } } getTable(range = this.quill.getSelection()) { @@ -174,6 +186,16 @@ class BetterTable extends Module { } insertTable(rows, columns) { + if (!columns) { + if (rows.match(/^\d+x\d+$/)) { + let tmp = rows.split('x'); + columns = parseInt(tmp[0]); + rows = parseInt(tmp[1]); + } else { + return; + } + } + const range = this.quill.getSelection(true) if (range == null) return let currentBlot = this.quill.getLeaf(range.index)[0] @@ -228,10 +250,7 @@ BetterTable.keyboardBindings = { offset: 0, handler(range, context) { const [line, offset] = this.quill.getLine(range.index) - if (!line.prev || line.prev.statics.blotName !== 'table-cell-line') { - return false - } - return true + return !(!line.prev || line.prev.statics.blotName !== 'table-cell-line'); }, }, diff --git a/src/themes/better-table-snow.js b/src/themes/better-table-snow.js new file mode 100644 index 0000000..de08f1b --- /dev/null +++ b/src/themes/better-table-snow.js @@ -0,0 +1,34 @@ +import Quill from 'quill'; +import TablePicker from '../ui/table-picker'; +import extend from 'extend'; + +const SnowTheme = Quill.import('themes/snow'); + +class BetterTableSnowTheme extends SnowTheme { + constructor(quill, options) { + super(quill, options); + } + + buildPickers(selects, icons) { + selects = Array.from(selects); + let pickers = selects.map((select, index, selects) => { + if (select.classList.contains('ql-better-table')) { + selects.splice(index, 1); + if (select.querySelector('option') == null) { + for (let r = 1; r <= 8; r++) { + for (let c = 1; c <= 10; c++) { + const option = document.createElement('option'); + option.setAttribute('value', c + 'x' + r); + select.appendChild(option); + } + } + } + return new TablePicker(select, icons.table); + } + }); + super.buildPickers(selects, icons); + this.pickers = extend([], this.pickers, pickers); + } +} + +export default BetterTableSnowTheme; \ No newline at end of file diff --git a/src/ui/table-picker.js b/src/ui/table-picker.js new file mode 100644 index 0000000..f946e72 --- /dev/null +++ b/src/ui/table-picker.js @@ -0,0 +1,55 @@ +import Quill from 'quill'; + +const Picker = Quill.import('ui/picker'); + +class TablePicker extends Picker { + constructor(select, label) { + super(select); + + this.label.innerHTML = label; + this.container.classList.add('ql-table-picker'); + } + + buildItem(option) { + const item = super.buildItem(option); + + item.addEventListener('mouseover', () => { + let value = item.getAttribute('data-value').split('x'); + let row = parseInt(value[1]); + let column = parseInt(value[0]); + let items = Array.from(this.container.querySelectorAll('.ql-picker-item')); + let lastItem = this.container.querySelector('.ql-picker-item:last-child'); + value = lastItem.getAttribute('data-value').split('x'); + // let rows = parseInt(value[1]); + let cols = parseInt(value[0]); + + items.forEach(i => { + i.classList.remove('hover'); + }); + for (let r = 0; r < row; r++) { + items.slice(r * cols, r * cols + column).forEach(i => { + i.classList.add('hover'); + }); + } + }); + + return item; + } + + selectItem(item, trigger = false) { + super.selectItem(item, trigger); + + if (item == null) return + item.classList.remove('ql-selected'); + if (item.label) { + item.label.removeAttribute('data-value'); + item.label.removeAttribute('data-label'); + } + + Array.from(this.container.querySelectorAll('.hover')).forEach(item => { + item.classList.remove('hover'); + }); + } +} + +export default TablePicker; \ No newline at end of file