mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-05-03 04:31:50 +08:00
This commit is contained in:
parent
fc558107cf
commit
a003837e88
@ -351,10 +351,6 @@ export const setLastNodeRange = (editElement: Element, range: Range, setStart =
|
|||||||
}
|
}
|
||||||
let lastNode = editElement.lastChild as Element;
|
let lastNode = editElement.lastChild as Element;
|
||||||
while (lastNode && lastNode.nodeType !== 3) {
|
while (lastNode && lastNode.nodeType !== 3) {
|
||||||
if (lastNode.nodeType !== 3 && lastNode.tagName === "BR") {
|
|
||||||
// 防止单元格中 ⇧↓ 全部选中
|
|
||||||
return range;
|
|
||||||
}
|
|
||||||
// https://github.com/siyuan-note/siyuan/issues/12792
|
// https://github.com/siyuan-note/siyuan/issues/12792
|
||||||
if (!lastNode.lastChild) {
|
if (!lastNode.lastChild) {
|
||||||
break;
|
break;
|
||||||
@ -367,14 +363,14 @@ export const setLastNodeRange = (editElement: Element, range: Range, setStart =
|
|||||||
lastNode = editElement;
|
lastNode = editElement;
|
||||||
}
|
}
|
||||||
if (setStart) {
|
if (setStart) {
|
||||||
if (lastNode.nodeType !== 3 && lastNode.classList.contains("render-node") && lastNode.innerHTML === "") {
|
if (lastNode.nodeType !== 3 && (lastNode.classList.contains("render-node") || lastNode.tagName === "BR") && lastNode.innerHTML === "") {
|
||||||
range.setStartAfter(lastNode);
|
range.setStartAfter(lastNode);
|
||||||
} else {
|
} else {
|
||||||
range.setStart(lastNode, lastNode.textContent.length);
|
range.setStart(lastNode, lastNode.textContent.length);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (lastNode.nodeType !== 3 && lastNode.classList.contains("render-node") && lastNode.innerHTML === "") {
|
if (lastNode.nodeType !== 3 && (lastNode.classList.contains("render-node") || lastNode.tagName === "BR") && lastNode.innerHTML === "") {
|
||||||
range.setStartAfter(lastNode);
|
range.setEndAfter(lastNode);
|
||||||
} else {
|
} else {
|
||||||
range.setEnd(lastNode, lastNode.textContent.length);
|
range.setEnd(lastNode, lastNode.textContent.length);
|
||||||
}
|
}
|
||||||
|
@ -205,6 +205,9 @@ export const downSelect = (options: {
|
|||||||
// 代码块中 shift+alt 向下选中到末尾时,最后一个字符无法选中
|
// 代码块中 shift+alt 向下选中到末尾时,最后一个字符无法选中
|
||||||
options.event.preventDefault();
|
options.event.preventDefault();
|
||||||
}
|
}
|
||||||
|
} else if (tdElement) {
|
||||||
|
setLastNodeRange(tdElement, options.range, false);
|
||||||
|
options.event.preventDefault();
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -1379,6 +1379,8 @@ export class WYSIWYG {
|
|||||||
}).element);
|
}).element);
|
||||||
}
|
}
|
||||||
window.siyuan.menus.menu.popup({x: mouseUpEvent.clientX - 8, y: mouseUpEvent.clientY - 16});
|
window.siyuan.menus.menu.popup({x: mouseUpEvent.clientX - 8, y: mouseUpEvent.clientY - 16});
|
||||||
|
// 多选表格单元格后,选择菜单中的居左,然后 shift+左 选中的文字无法显示选中背景,因此需移除
|
||||||
|
protyle.wysiwyg.element.classList.remove("protyle-wysiwyg--hiderange");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1417,12 +1419,17 @@ export class WYSIWYG {
|
|||||||
}
|
}
|
||||||
const startBlockElement = hasClosestBlock(range.startContainer);
|
const startBlockElement = hasClosestBlock(range.startContainer);
|
||||||
let endBlockElement: false | HTMLElement;
|
let endBlockElement: false | HTMLElement;
|
||||||
if (mouseUpEvent.detail > 2 && range.endContainer.nodeType !== 3 && (range.endContainer as HTMLElement).tagName === "DIV" && range.endOffset === 0) {
|
if (mouseUpEvent.detail > 2 && range.endContainer.nodeType !== 3 && ["DIV", "TD", "TH"].includes((range.endContainer as HTMLElement).tagName) && range.endOffset === 0) {
|
||||||
// 三击选中段落块时,rangeEnd 会在下一个块
|
// 三击选中段落块时,rangeEnd 会在下一个块
|
||||||
if ((range.endContainer as HTMLElement).classList.contains("protyle-attr") && startBlockElement) {
|
if ((range.endContainer as HTMLElement).classList.contains("protyle-attr") && startBlockElement) {
|
||||||
// 三击在悬浮层中会选择到 attr https://github.com/siyuan-note/siyuan/issues/4636
|
// 三击在悬浮层中会选择到 attr https://github.com/siyuan-note/siyuan/issues/4636
|
||||||
// 需要获取可编辑元素,使用 previousElementSibling 的话会 https://github.com/siyuan-note/siyuan/issues/9714
|
// 需要获取可编辑元素,使用 previousElementSibling 的话会 https://github.com/siyuan-note/siyuan/issues/9714
|
||||||
setLastNodeRange(getContenteditableElement(startBlockElement), range, false);
|
setLastNodeRange(getContenteditableElement(startBlockElement), range, false);
|
||||||
|
} else if (["TD", "TH"].includes((range.endContainer as HTMLElement).tagName)) {
|
||||||
|
const cellElement = hasClosestByTag(range.startContainer, "TH") || hasClosestByTag(range.startContainer, "TD")
|
||||||
|
if (cellElement) {
|
||||||
|
setLastNodeRange(cellElement, range, false);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
endBlockElement = hasClosestBlock(range.endContainer);
|
endBlockElement = hasClosestBlock(range.endContainer);
|
||||||
|
Loading…
Reference in New Issue
Block a user