From c06f740c1c8252e44ba6accf04d40de2df4b6eba Mon Sep 17 00:00:00 2001 From: Vanessa Date: Wed, 5 Feb 2025 17:08:35 +0800 Subject: [PATCH] :art: https://github.com/siyuan-note/siyuan/pull/14010 --- app/src/assets/scss/protyle/_wysiwyg.scss | 2 +- app/src/protyle/wysiwyg/index.ts | 22 ++++++++++++++-------- 2 files changed, 15 insertions(+), 9 deletions(-) diff --git a/app/src/assets/scss/protyle/_wysiwyg.scss b/app/src/assets/scss/protyle/_wysiwyg.scss index ade1740cd..f594aa951 100644 --- a/app/src/assets/scss/protyle/_wysiwyg.scss +++ b/app/src/assets/scss/protyle/_wysiwyg.scss @@ -511,7 +511,7 @@ transition: var(--b3-background-transition); } - &--hidden ::selection { + &--hiderange ::selection { background-color: transparent; } diff --git a/app/src/protyle/wysiwyg/index.ts b/app/src/protyle/wysiwyg/index.ts index 456ba5f82..ea3951e40 100644 --- a/app/src/protyle/wysiwyg/index.ts +++ b/app/src/protyle/wysiwyg/index.ts @@ -440,6 +440,7 @@ export class WYSIWYG { }); this.element.addEventListener("mousedown", (event: MouseEvent) => { + protyle.wysiwyg.element.classList.remove("protyle-wysiwyg--hiderange"); if (event.button === 2 || window.siyuan.ctrlIsPressed) { // 右键 return; @@ -729,7 +730,6 @@ export class WYSIWYG { tableBlockElement = hasClosestBlock(target); if (tableBlockElement) { tableBlockElement.querySelector(".table__select").removeAttribute("style"); - tableBlockElement.classList.remove("protyle-wysiwyg--hidden"); window.siyuan.menus.menu.remove(); event.stopPropagation(); } @@ -811,9 +811,15 @@ export class WYSIWYG { // table cell select if (!protyle.disabled && tableBlockElement && tableBlockElement.contains(moveTarget) && !hasClosestByClassName(tableBlockElement, "protyle-wysiwyg__embed")) { + if (moveTarget.classList.contains("table__select")) { + moveTarget.classList.add("fn__none"); + const pointElement = document.elementFromPoint(moveEvent.clientX, moveEvent.clientY); + moveTarget.classList.remove("fn__none"); + moveTarget = hasClosestByMatchTag(pointElement, "TH") || hasClosestByMatchTag(pointElement, "TD"); + } if (moveTarget && moveTarget.isSameNode(target)) { tableBlockElement.querySelector(".table__select").removeAttribute("style"); - tableBlockElement.classList.remove("protyle-wysiwyg--hidden"); + protyle.wysiwyg.element.classList.remove("protyle-wysiwyg--hiderange"); moveCellElement = moveTarget; return false; } @@ -871,8 +877,8 @@ export class WYSIWYG { width = item.offsetLeft + item.clientWidth - left; } }); - tableBlockElement.classList.add("protyle-wysiwyg--hidden"); - tableBlockElement.querySelector(".table__select").setAttribute("style", `left:${left - tableBlockElement.firstElementChild.scrollLeft}px;top:${top}px;height:${height}px;width:${width + 1}px;pointer-events:none;`); + protyle.wysiwyg.element.classList.add("protyle-wysiwyg--hiderange"); + tableBlockElement.querySelector(".table__select").setAttribute("style", `left:${left - tableBlockElement.firstElementChild.scrollLeft}px;top:${top}px;height:${height}px;width:${width + 1}px;`); moveCellElement = moveTarget; } return; @@ -1049,12 +1055,13 @@ export class WYSIWYG { if (moveEvent.clientY <= y && !endLastElement) { endLastElement = selectElements[selectElements.length - 1]; } - if (selectElements.length === 1 && !selectElements[0].classList.contains("list") && !selectElements[0].classList.contains("bq") && !selectElements[0].classList.contains("sb")) { - protyle.wysiwyg.element.classList.remove("protyle-wysiwyg--hidden"); + if (selectElements.length === 1 && !selectElements[0].classList.contains("list") && + !selectElements[0].classList.contains("bq") && !selectElements[0].classList.contains("sb")) { // 只有一个 p 时不选中 protyle.selectElement.style.backgroundColor = "transparent"; + protyle.wysiwyg.element.classList.remove("protyle-wysiwyg--hiderange"); } else { - protyle.wysiwyg.element.classList.add("protyle-wysiwyg--hidden"); + protyle.wysiwyg.element.classList.add("protyle-wysiwyg--hiderange"); selectElements.forEach(item => { if (!hasClosestByClassName(item, "protyle-wysiwyg__embed")) { item.classList.add("protyle-wysiwyg--select"); @@ -2181,7 +2188,6 @@ export class WYSIWYG { this.preventClick = false; return; } - protyle.wysiwyg.element.classList.remove("protyle-wysiwyg--hidden"); protyle.app.plugins.forEach(item => { item.eventBus.emit("click-editorcontent", { protyle,