mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-05-04 04:02:58 +08:00
This commit is contained in:
parent
6ff4b621b2
commit
4dffc849c9
@ -623,6 +623,11 @@ export const keydown = (protyle: IProtyle, editorElement: HTMLElement) => {
|
|||||||
const tdElement = hasClosestByMatchTag(range.startContainer, "TD") || hasClosestByMatchTag(range.startContainer, "TH");
|
const tdElement = hasClosestByMatchTag(range.startContainer, "TD") || hasClosestByMatchTag(range.startContainer, "TH");
|
||||||
const nodeEditableElement = (tdElement || getContenteditableElement(nodeElement) || nodeElement) as HTMLElement;
|
const nodeEditableElement = (tdElement || getContenteditableElement(nodeElement) || nodeElement) as HTMLElement;
|
||||||
const position = getSelectionOffset(nodeEditableElement, protyle.wysiwyg.element, range);
|
const position = getSelectionOffset(nodeEditableElement, protyle.wysiwyg.element, range);
|
||||||
|
if (nodeElement.classList.contains("code-block") && position.end === nodeEditableElement.innerText.length) {
|
||||||
|
// 代码块换最后一个 /n 肉眼是无法区分是否在其后的,因此统一在之前
|
||||||
|
position.end -= 1;
|
||||||
|
|
||||||
|
}
|
||||||
// 需使用 innerText 否则表格内 br 无法传唤为 /n
|
// 需使用 innerText 否则表格内 br 无法传唤为 /n
|
||||||
if (event.key === "ArrowDown" && nodeEditableElement?.innerText.trimRight().substr(position.start).indexOf("\n") === -1 && (
|
if (event.key === "ArrowDown" && nodeEditableElement?.innerText.trimRight().substr(position.start).indexOf("\n") === -1 && (
|
||||||
(tdElement && !tdElement.parentElement.nextElementSibling && nodeElement.getAttribute("data-type") === "NodeTable" && !getNextBlock(nodeElement)) ||
|
(tdElement && !tdElement.parentElement.nextElementSibling && nodeElement.getAttribute("data-type") === "NodeTable" && !getNextBlock(nodeElement)) ||
|
||||||
|
Loading…
Reference in New Issue
Block a user