fix: 鼠标框选块或单元格时不应选中其中的文本 (#14010)

* fix: 鼠标框选块或单元格时不应选中其中的文本

fix https://github.com/siyuan-note/siyuan/issues/12120

* refactor: 表格选择单元格不灵活

fix https://github.com/siyuan-note/siyuan/issues/11388
This commit is contained in:
Jeffrey Chen 2025-02-05 11:37:08 +08:00 committed by GitHub
parent 737c3f6559
commit 2863eec46c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 11 additions and 7 deletions

View file

@ -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;

View file

@ -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,