mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-09-22 08:30:42 +02:00
🐛 打开定位
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
|
// 使用动态滚动条定位到最后一个块,重启后无法触发滚动事件,需要再次更新 index
|
||||||
protyle.scroll.updateIndex(protyle, options.scrollAttr.startId);
|
protyle.scroll.updateIndex(protyle, options.scrollAttr.startId);
|
||||||
// https://github.com/siyuan-note/siyuan/issues/8224
|
// https://github.com/siyuan-note/siyuan/issues/8224
|
||||||
const contentRect = protyle.contentElement.getBoundingClientRect();
|
if (protyle.contentElement.scrollHeight <= protyle.contentElement.clientHeight) {
|
||||||
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) {
|
|
||||||
showMessage(window.siyuan.languages.scrollGetMore);
|
showMessage(window.siyuan.languages.scrollGetMore);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -361,12 +358,8 @@ export const enableProtyle = (protyle: IProtyle) => {
|
||||||
|
|
||||||
const focusElementById = (protyle: IProtyle, action: string[], scrollAttr?: IScrollAttr) => {
|
const focusElementById = (protyle: IProtyle, action: string[], scrollAttr?: IScrollAttr) => {
|
||||||
let focusElement: Element;
|
let focusElement: Element;
|
||||||
let range: Range;
|
|
||||||
if (scrollAttr && scrollAttr.focusId) {
|
if (scrollAttr && scrollAttr.focusId) {
|
||||||
focusElement = protyle.wysiwyg.element.querySelector(`[data-node-id="${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 {
|
} else {
|
||||||
Array.from(protyle.wysiwyg.element.querySelectorAll(`[data-node-id="${protyle.block.id}"]`)).find((item: HTMLElement) => {
|
Array.from(protyle.wysiwyg.element.querySelectorAll(`[data-node-id="${protyle.block.id}"]`)).find((item: HTMLElement) => {
|
||||||
if (!hasClosestByAttribute(item, "data-type", "block-render", true)) {
|
if (!hasClosestByAttribute(item, "data-type", "block-render", true)) {
|
||||||
|
@ -386,7 +379,12 @@ const focusElementById = (protyle: IProtyle, action: string[], scrollAttr?: IScr
|
||||||
bgFade(focusElement);
|
bgFade(focusElement);
|
||||||
}
|
}
|
||||||
if (action.includes(Constants.CB_GET_FOCUS) || action.includes(Constants.CB_GET_FOCUSFIRST)) {
|
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 !MOBILE
|
||||||
if (!action.includes(Constants.CB_GET_UNUNDO)) {
|
if (!action.includes(Constants.CB_GET_UNUNDO)) {
|
||||||
pushBack(protyle, range, focusElement);
|
pushBack(protyle, range, focusElement);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue