Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
addColCellHolderHandler(cell) {
const tableContainer = Quill.find(this.table)
const $holder = cell.querySelector(".qlbt-col-tool-cell-holder")
let dragging = false
let x0 = 0
let x = 0
let delta = 0
let width0 = 0
// helpLine relation varrible
let tableRect = {}
let cellRect = {}
let $helpLine = null
const handleDrag = e => {
e.preventDefault()
if (dragging) {
x = e.clientX
updateToolCells () {
const tableContainer = Quill.find(this.table)
const CellsInFirstRow = tableContainer.children.tail.children.head.children
const tableCols = tableContainer.colGroup().children
const cellsNumber = computeCellsNumber(CellsInFirstRow)
let existCells = Array.from(this.domNode.querySelectorAll('.qlbt-col-tool-cell'))
for (let index = 0; index < Math.max(cellsNumber, existCells.length); index++) {
let col = tableCols.at(index)
let colWidth = col && parseInt(col.formats()[col.statics.blotName].width, 10)
// if cell already exist
let toolCell = null
if (!existCells[index]) {
toolCell = this.createToolCell()
this.domNode.appendChild(toolCell)
this.addColCellHolderHandler(toolCell)
// set tool cell min-width
css(toolCell, {
handler () {
const tableContainer = Quill.find(this.table)
tableContainer.deleteRow(
this.boundary,
this.quill.root.parentNode
)
this.quill.update(Quill.sources.USER)
this.tableSelection.clearSelection()
}
},
tableDestroy() {
const quill = Quill.find(this.scroll.domNode.parentNode)
const tableModule = quill.getModule("better-table")
this.remove()
tableModule.hideTableTools()
quill.update(Quill.sources.USER)
}
handler () {
const betterTableModule = this.quill.getModule('better-table')
const tableContainer = Quill.find(this.table)
betterTableModule.hideTableTools()
tableContainer.remove()
this.quill.update(Quill.sources.USER)
}
}
handler () {
const tableContainer = Quill.find(this.table)
const affectedCells = tableContainer.insertRow(
this.boundary,
false,
this.quill.root.parentNode
)
this.quill.update(Quill.sources.USER)
this.quill.setSelection(
this.quill.getIndex(affectedCells[0]),
0,
Quill.sources.SILENT
)
this.tableSelection.setSelection(
affectedCells[0].domNode.getBoundingClientRect(),
affectedCells[0].domNode.getBoundingClientRect()
)
}
correctBoundary () {
const tableContainer = Quill.find(this.table)
const tableCells = tableContainer.descendants(TableCell)
tableCells.forEach(tableCell => {
let { x, y, width, height } = getRelativeRect(
tableCell.domNode.getBoundingClientRect(),
this.quill.root.parentNode
)
let isCellIntersected = (
(x + ERROR_LIMIT >= this.boundary.x && x + ERROR_LIMIT <= this.boundary.x1) ||
(x - ERROR_LIMIT + width >= this.boundary.x && x - ERROR_LIMIT + width <= this.boundary.x1)
) && (
(y + ERROR_LIMIT >= this.boundary.y && y + ERROR_LIMIT <= this.boundary.y1) ||
(y - ERROR_LIMIT + height >= this.boundary.y && y - ERROR_LIMIT + height <= this.boundary.y1)
)
if (isCellIntersected) {
this.boundary = computeBoundaryFromRects(this.boundary, { x, y, width, height })
handler () {
const tableContainer = Quill.find(this.table)
let colIndexes = getColToolCellIndexesByBoundary(
this.columnToolCells,
this.boundary,
(cellRect, boundary) => {
return cellRect.x + ERROR_LIMIT > boundary.x &&
cellRect.x + cellRect.width - ERROR_LIMIT < boundary.x1
},
this.quill.root.parentNode
)
let isDeleteTable = tableContainer.deleteColumns(
this.boundary,
colIndexes,
this.quill.root.parentNode
)
if (!isDeleteTable) {
computeSelectedTds () {
const tableContainer = Quill.find(this.table)
const tableCells = tableContainer.descendants(TableCell)
return tableCells.reduce((selectedCells, tableCell) => {
let { x, y, width, height } = getRelativeRect(
tableCell.domNode.getBoundingClientRect(),
this.quill.root.parentNode
)
let isCellIncluded = (
x + ERROR_LIMIT >= this.boundary.x &&
x - ERROR_LIMIT + width <= this.boundary.x1
) && (
y + ERROR_LIMIT >= this.boundary.y &&
y - ERROR_LIMIT + height <= this.boundary.y1
)
if (isCellIncluded) {