mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-05-03 02:09:59 +08:00
🎨 上下键
This commit is contained in:
parent
4dffc849c9
commit
0292c2cf8f
@ -648,7 +648,7 @@ export const keydown = (protyle: IProtyle, editorElement: HTMLElement) => {
|
||||
) ||
|
||||
(!firstEditElement && nodeElement.isSameNode(protyle.wysiwyg.element.firstElementChild))) {
|
||||
// 不能用\n判断,否则文字过长折行将错误 https://github.com/siyuan-note/siyuan/issues/6156
|
||||
if (getSelectionPosition(nodeElement, range).top - parseInt(getComputedStyle(nodeElement).paddingTop) - protyle.wysiwyg.element.getBoundingClientRect().top < 40 || nodeElement.classList.contains("av")) {
|
||||
if (getSelectionPosition(nodeEditableElement, range).top - nodeEditableElement.getBoundingClientRect().top < 20 || nodeElement.classList.contains("av")) {
|
||||
if (protyle.title && protyle.title.editElement &&
|
||||
(protyle.wysiwyg.element.firstElementChild.getAttribute("data-eof") === "1" ||
|
||||
protyle.contentElement.scrollTop === 0)) {
|
||||
@ -663,7 +663,8 @@ export const keydown = (protyle: IProtyle, editorElement: HTMLElement) => {
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (nodeEditableElement?.innerText.substr(0, position.end).indexOf("\n") === -1 || (!isMac() && position.start === 0)) {
|
||||
if (((nodeEditableElement?.innerText.substr(0, position.end).indexOf("\n") === -1 || position.start === 0) &&
|
||||
getSelectionPosition(nodeEditableElement, range).top - nodeEditableElement.getBoundingClientRect().top < 20)) {
|
||||
let previousElement: HTMLElement = getPreviousBlock(nodeElement) as HTMLElement;
|
||||
if (previousElement) {
|
||||
previousElement = getLastBlock(previousElement) as HTMLElement;
|
||||
@ -732,17 +733,17 @@ export const keydown = (protyle: IProtyle, editorElement: HTMLElement) => {
|
||||
}
|
||||
event.stopPropagation();
|
||||
event.preventDefault();
|
||||
} else if (nodeEditableElement?.innerText.substr(position.end).indexOf("\n") === -1) {
|
||||
} else if (nodeEditableElement?.innerText.substr(position.end).indexOf("\n") === -1 || position.end >= nodeEditableElement.innerText.trimEnd().length) {
|
||||
// 需使用 innerText,否则 td 中的 br 无法转换为 \n; position.end 不能加1,否则倒数第二行行末无法下移
|
||||
// 下一个块是折叠块
|
||||
range.collapse(false)
|
||||
const nextFoldElement = getNextBlock(nodeElement) as HTMLElement;
|
||||
if (nextFoldElement) {
|
||||
focusBlock(nextFoldElement);
|
||||
scrollCenter(protyle, nextFoldElement);
|
||||
event.stopPropagation();
|
||||
event.preventDefault();
|
||||
} else {
|
||||
range.collapse(false);
|
||||
if(nodeEditableElement.getBoundingClientRect().bottom - getSelectionPosition(nodeElement, range).top < 40) {
|
||||
focusBlock(nextFoldElement);
|
||||
scrollCenter(protyle, nextFoldElement);
|
||||
event.stopPropagation();
|
||||
event.preventDefault();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user