mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-05-13 15:41:29 +08:00
This commit is contained in:
parent
4427507892
commit
1a20840a2a
@ -47,9 +47,7 @@ export const scrollCenter = (protyle: IProtyle, nodeElement?: Element, top = fal
|
|||||||
if (blockElement.classList.contains("code-block")) {
|
if (blockElement.classList.contains("code-block")) {
|
||||||
const brElement = document.createElement('br');
|
const brElement = document.createElement('br');
|
||||||
range.insertNode(brElement);
|
range.insertNode(brElement);
|
||||||
brElement.scrollIntoView({
|
brElement.scrollIntoView({block: "center", behavior});
|
||||||
block: 'end',
|
|
||||||
});
|
|
||||||
brElement.remove();
|
brElement.remove();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -58,8 +56,11 @@ export const scrollCenter = (protyle: IProtyle, nodeElement?: Element, top = fal
|
|||||||
(blockElement.querySelector(".av__row--header").getAttribute("style")?.indexOf("transform") > -1 || blockElement.querySelector(".av__row--footer").getAttribute("style")?.indexOf("transform") > -1)) {
|
(blockElement.querySelector(".av__row--header").getAttribute("style")?.indexOf("transform") > -1 || blockElement.querySelector(".av__row--footer").getAttribute("style")?.indexOf("transform") > -1)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const br2Element = document.createElement('br');
|
||||||
|
range.insertNode(br2Element);
|
||||||
const editorElement = protyle.contentElement;
|
const editorElement = protyle.contentElement;
|
||||||
const cursorTop = getSelectionPosition(editorElement).top - editorElement.getBoundingClientRect().top;
|
const cursorTop = br2Element.getBoundingClientRect().top - editorElement.getBoundingClientRect().top;
|
||||||
let scrollTop = 0;
|
let scrollTop = 0;
|
||||||
if (cursorTop < 0) {
|
if (cursorTop < 0) {
|
||||||
scrollTop = editorElement.scrollTop + cursorTop;
|
scrollTop = editorElement.scrollTop + cursorTop;
|
||||||
@ -69,6 +70,7 @@ export const scrollCenter = (protyle: IProtyle, nodeElement?: Element, top = fal
|
|||||||
if (scrollTop !== 0) {
|
if (scrollTop !== 0) {
|
||||||
editorElement.scroll({top: scrollTop, behavior});
|
editorElement.scroll({top: scrollTop, behavior});
|
||||||
}
|
}
|
||||||
|
br2Element.remove();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user