mirror of
https://github.com/siyuan-note/siyuan.git
synced 2026-02-24 07:54:07 +01:00
This commit is contained in:
parent
fba386be71
commit
19d9c455a7
4 changed files with 25 additions and 19 deletions
|
|
@ -222,7 +222,8 @@ export const windowMouseMove = (event: MouseEvent, mouseIsEnter: boolean) => {
|
|||
const cellElement = (hasClosestByTag(target, "TH") || hasClosestByTag(target, "TD")) as HTMLTableCellElement;
|
||||
const tableElement = blockElement.querySelector("table");
|
||||
if (cellElement && tableElement && tableElement.getAttribute("contenteditable") === "true") {
|
||||
const tableHeight = blockElement.querySelector("table").clientHeight;
|
||||
const tableHeight = blockElement.querySelector("colgroup").clientHeight;
|
||||
const captionHeight = blockElement.querySelector("caption")?.clientHeight || 0;
|
||||
const resizeElement = blockElement.querySelector(".table__resize");
|
||||
if (blockElement.style.textAlign === "center" || blockElement.style.textAlign === "right") {
|
||||
resizeElement.parentElement.style.left = tableElement.offsetLeft + "px";
|
||||
|
|
@ -232,10 +233,10 @@ export const windowMouseMove = (event: MouseEvent, mouseIsEnter: boolean) => {
|
|||
const rect = cellElement.getBoundingClientRect();
|
||||
if (rect.right - event.clientX < 3 && rect.right - event.clientX > 0) {
|
||||
resizeElement.setAttribute("data-col-index", (getColIndex(cellElement) + cellElement.colSpan - 1).toString());
|
||||
resizeElement.setAttribute("style", `height:${tableHeight}px;left: ${Math.round(cellElement.offsetWidth + cellElement.offsetLeft - blockElement.firstElementChild.scrollLeft - 3)}px;display:block`);
|
||||
resizeElement.setAttribute("style", `top:${captionHeight}px;height:${tableHeight}px;left: ${Math.round(cellElement.offsetWidth + cellElement.offsetLeft - blockElement.firstElementChild.scrollLeft - 3)}px;display:block`);
|
||||
} else if (event.clientX - rect.left < 3 && event.clientX - rect.left > 0 && cellElement.previousElementSibling) {
|
||||
resizeElement.setAttribute("data-col-index", (getColIndex(cellElement) - 1).toString());
|
||||
resizeElement.setAttribute("style", `height:${tableHeight}px;left: ${Math.round(cellElement.offsetLeft - blockElement.firstElementChild.scrollLeft - 3)}px;display:block`);
|
||||
resizeElement.setAttribute("style", `top:${captionHeight}px;height:${tableHeight}px;left: ${Math.round(cellElement.offsetLeft - blockElement.firstElementChild.scrollLeft - 3)}px;display:block`);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue