mirror of
https://github.com/siyuan-note/siyuan.git
synced 2026-01-01 06:18:49 +01:00
This commit is contained in:
parent
a21e51fa19
commit
cd4f4b8094
2 changed files with 6 additions and 2 deletions
|
|
@ -18,7 +18,7 @@ export const showKeyboardToolbar = (bottom = 0) => {
|
|||
!window.siyuan.mobileEditor.protyle.wysiwyg.element.contains(range.startContainer)) {
|
||||
return;
|
||||
}
|
||||
scrollCenter(window.siyuan.mobileEditor.protyle);
|
||||
scrollCenter(window.siyuan.mobileEditor.protyle, undefined, false, (window.outerHeight - 65) / 2 - 30);
|
||||
};
|
||||
|
||||
export const hideKeyboardToolbar = () => {
|
||||
|
|
|
|||
|
|
@ -38,10 +38,14 @@ export const highlightById = (protyle: IProtyle, id: string, top = false) => {
|
|||
}
|
||||
};
|
||||
|
||||
export const scrollCenter = (protyle: IProtyle, nodeElement?: Element, top = false) => {
|
||||
export const scrollCenter = (protyle: IProtyle, nodeElement?: Element, top = false, offset= 0) => {
|
||||
if (!top && getSelection().rangeCount > 0 && hasClosestBlock(getSelection().getRangeAt(0).startContainer)) {
|
||||
const editorElement = protyle.contentElement;
|
||||
const cursorTop = getSelectionPosition(editorElement).top - editorElement.getBoundingClientRect().top;
|
||||
if (offset) { // 仅移动端弹起键盘用到
|
||||
editorElement.scrollTop = editorElement.scrollTop + cursorTop - offset;
|
||||
return;
|
||||
}
|
||||
if (cursorTop < 0) {
|
||||
editorElement.scrollTop = editorElement.scrollTop + cursorTop;
|
||||
} else if (cursorTop > editorElement.clientHeight - 34) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue