From 2863eec46cef972370f142e0ae9efb1f16e4d38d Mon Sep 17 00:00:00 2001 From: Jeffrey Chen <78434827+TCOTC@users.noreply.github.com> Date: Wed, 5 Feb 2025 11:37:08 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E9=BC=A0=E6=A0=87=E6=A1=86=E9=80=89?= =?UTF-8?q?=E5=9D=97=E6=88=96=E5=8D=95=E5=85=83=E6=A0=BC=E6=97=B6=E4=B8=8D?= =?UTF-8?q?=E5=BA=94=E9=80=89=E4=B8=AD=E5=85=B6=E4=B8=AD=E7=9A=84=E6=96=87?= =?UTF-8?q?=E6=9C=AC=20(#14010)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * fix: 鼠标框选块或单元格时不应选中其中的文本 fix https://github.com/siyuan-note/siyuan/issues/12120 * refactor: 表格选择单元格不灵活 fix https://github.com/siyuan-note/siyuan/issues/11388 --- app/src/assets/scss/protyle/_wysiwyg.scss | 4 ++++ app/src/protyle/wysiwyg/index.ts | 14 +++++++------- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/app/src/assets/scss/protyle/_wysiwyg.scss b/app/src/assets/scss/protyle/_wysiwyg.scss index f9ba5724a..ade1740cd 100644 --- a/app/src/assets/scss/protyle/_wysiwyg.scss +++ b/app/src/assets/scss/protyle/_wysiwyg.scss @@ -511,6 +511,10 @@ transition: var(--b3-background-transition); } + &--hidden ::selection { + background-color: transparent; + } + // https://github.com/siyuan-note/siyuan/issues/11589 .hljs wbr { display: none; diff --git a/app/src/protyle/wysiwyg/index.ts b/app/src/protyle/wysiwyg/index.ts index e4e367799..456ba5f82 100644 --- a/app/src/protyle/wysiwyg/index.ts +++ b/app/src/protyle/wysiwyg/index.ts @@ -729,6 +729,7 @@ 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(); } @@ -810,14 +811,9 @@ 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"); moveCellElement = moveTarget; return false; } @@ -875,7 +871,8 @@ export class WYSIWYG { width = item.offsetLeft + item.clientWidth - left; } }); - tableBlockElement.querySelector(".table__select").setAttribute("style", `left:${left - tableBlockElement.firstElementChild.scrollLeft}px;top:${top}px;height:${height}px;width:${width + 1}px;`); + 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;`); moveCellElement = moveTarget; } return; @@ -1053,9 +1050,11 @@ export class WYSIWYG { 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"); // 只有一个 p 时不选中 protyle.selectElement.style.backgroundColor = "transparent"; } else { + protyle.wysiwyg.element.classList.add("protyle-wysiwyg--hidden"); selectElements.forEach(item => { if (!hasClosestByClassName(item, "protyle-wysiwyg__embed")) { item.classList.add("protyle-wysiwyg--select"); @@ -2182,6 +2181,7 @@ 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,