mirror of
https://github.com/siyuan-note/siyuan.git
synced 2026-02-24 07:54:07 +01:00
This commit is contained in:
parent
b5b46afabd
commit
f742e664c7
4 changed files with 30 additions and 40 deletions
|
|
@ -4,6 +4,7 @@ import {fetchPost} from "../../util/fetch";
|
|||
import {onGet} from "../util/onGet";
|
||||
import {showMessage} from "../../dialog/message";
|
||||
import {updateHotkeyTip} from "../util/compatibility";
|
||||
import {isMobile} from "../../util/functions";
|
||||
|
||||
export const scrollEvent = (protyle: IProtyle, element: HTMLElement) => {
|
||||
let elementRect = element.getBoundingClientRect();
|
||||
|
|
@ -21,8 +22,12 @@ export const scrollEvent = (protyle: IProtyle, element: HTMLElement) => {
|
|||
protyle.toolbar.element.style.top = top + "px";
|
||||
protyle.toolbar.element.style.display = "";
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (!protyle.element.classList.contains("block__edit") && !isMobile()) {
|
||||
protyle.contentElement.setAttribute("data-scrolltop", element.scrollTop.toString());
|
||||
}
|
||||
|
||||
if (!window.siyuan.dragElement) { // https://ld246.com/article/1649638389841
|
||||
hideElements(["gutter"], protyle);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,13 +9,15 @@ export const saveScroll = (protyle: IProtyle, getObject = false) => {
|
|||
const attr: IScrollAttr = {
|
||||
startId: protyle.wysiwyg.element.firstElementChild.getAttribute("data-node-id"),
|
||||
endId: protyle.wysiwyg.element.lastElementChild.getAttribute("data-node-id"),
|
||||
scrollTop: protyle.contentElement.scrollTop
|
||||
scrollTop: protyle.contentElement.scrollTop || parseInt(protyle.contentElement.getAttribute("data-scrolltop")) || 0,
|
||||
}
|
||||
let range: Range
|
||||
if (getSelection().rangeCount > 0) {
|
||||
range = getSelection().getRangeAt(0)
|
||||
}
|
||||
|
||||
if (!range || !protyle.wysiwyg.element.contains(range.startContainer)) {
|
||||
range = protyle.toolbar.range
|
||||
}
|
||||
if (range && protyle.wysiwyg.element.contains(range.startContainer)) {
|
||||
const blockElement = hasClosestBlock(range.startContainer);
|
||||
if (blockElement) {
|
||||
|
|
@ -23,9 +25,9 @@ export const saveScroll = (protyle: IProtyle, getObject = false) => {
|
|||
attr.focusId = blockElement.getAttribute("data-node-id");
|
||||
attr.focusStart = position.start
|
||||
attr.focusEnd = position.end
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
if (protyle.block.showAll) {
|
||||
attr.zoomInId = protyle.block.id
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue