🐛 打开定位
This commit is contained in:
parent
b0857eef5e
commit
acfa766027
1 changed files with 7 additions and 9 deletions
|
@ -251,10 +251,7 @@ const setHTML = (options: {
|
|||
// 使用动态滚动条定位到最后一个块,重启后无法触发滚动事件,需要再次更新 index
|
||||
protyle.scroll.updateIndex(protyle, options.scrollAttr.startId);
|
||||
// https://github.com/siyuan-note/siyuan/issues/8224
|
||||
const contentRect = protyle.contentElement.getBoundingClientRect();
|
||||
if (protyle.wysiwyg.element.clientHeight - parseInt(protyle.wysiwyg.element.style.paddingBottom) < protyle.contentElement.clientHeight &&
|
||||
protyle.wysiwyg.element.lastElementChild.getBoundingClientRect().bottom < contentRect.bottom &&
|
||||
protyle.wysiwyg.element.firstElementChild.getBoundingClientRect().top > contentRect.top) {
|
||||
if (protyle.contentElement.scrollHeight <= protyle.contentElement.clientHeight) {
|
||||
showMessage(window.siyuan.languages.scrollGetMore);
|
||||
}
|
||||
}
|
||||
|
@ -361,12 +358,8 @@ export const enableProtyle = (protyle: IProtyle) => {
|
|||
|
||||
const focusElementById = (protyle: IProtyle, action: string[], scrollAttr?: IScrollAttr) => {
|
||||
let focusElement: Element;
|
||||
let range: Range;
|
||||
if (scrollAttr && scrollAttr.focusId) {
|
||||
focusElement = protyle.wysiwyg.element.querySelector(`[data-node-id="${scrollAttr.focusId}"]`)
|
||||
if (action.includes(Constants.CB_GET_FOCUS)) {
|
||||
range = focusByOffset(focusElement, scrollAttr.focusStart, scrollAttr.focusEnd) as Range;
|
||||
}
|
||||
} else {
|
||||
Array.from(protyle.wysiwyg.element.querySelectorAll(`[data-node-id="${protyle.block.id}"]`)).find((item: HTMLElement) => {
|
||||
if (!hasClosestByAttribute(item, "data-type", "block-render", true)) {
|
||||
|
@ -386,7 +379,12 @@ const focusElementById = (protyle: IProtyle, action: string[], scrollAttr?: IScr
|
|||
bgFade(focusElement);
|
||||
}
|
||||
if (action.includes(Constants.CB_GET_FOCUS) || action.includes(Constants.CB_GET_FOCUSFIRST)) {
|
||||
focusBlock(focusElement);
|
||||
let range: Range;
|
||||
if (scrollAttr && scrollAttr.focusId) {
|
||||
range = focusByOffset(focusElement, scrollAttr.focusStart, scrollAttr.focusEnd) as Range;
|
||||
} else {
|
||||
focusBlock(focusElement);
|
||||
}
|
||||
/// #if !MOBILE
|
||||
if (!action.includes(Constants.CB_GET_UNUNDO)) {
|
||||
pushBack(protyle, range, focusElement);
|
||||
|
|
Loading…
Add table
Reference in a new issue