This commit is contained in:
Vanessa 2022-07-07 23:10:48 +08:00
parent 50ff1cfb1c
commit bd33e98274
9 changed files with 61 additions and 34 deletions

View file

@ -1,4 +1,6 @@
{
"crossKeepLazyLoad": "Cross-page multi-selection needs to select [Keep Loaded Content] in the more menu",
"keepLazyLoad": "Keep loaded content",
"localSnapshot": "Local Snapshot",
"localTagSnapshot": "Local Tag Snapshot",
"cloudTagSnapshot": "Cloud Tag Snapshot",

View file

@ -1,4 +1,6 @@
{
"crossKeepLazyLoad": "La selección múltiple entre páginas debe seleccionar [Mantener contenido cargado] en el menú más",
"keepLazyLoad": "Mantener el contenido cargado",
"localSnapshot": "Instantánea local",
"localTagSnapshot": "Instantánea de etiqueta local",
"cloudTagSnapshot": "Instantánea de etiquetas en la nube",

View file

@ -1,4 +1,6 @@
{
"crossKeepLazyLoad": "La multi-sélection sur plusieurs pages doit sélectionner [Conserver le contenu chargé] dans le menu plus",
"keepLazyLoad": "Conserver le contenu chargé",
"localSnapshot": "Instantané local",
"localTagSnapshot": "Instantané de balise locale",
"cloudTagSnapshot": "Instantané de balise cloud",

View file

@ -1,4 +1,6 @@
{
"crossKeepLazyLoad": "跨頁多選需在更多菜單中選中【保持已加載內容】",
"keepLazyLoad": "保持已加載的內容",
"localSnapshot": "本地快照",
"localTagSnapshot": "本地標記的快照",
"cloudTagSnapshot": "雲端標記的快照",

View file

@ -1,4 +1,6 @@
{
"crossKeepLazyLoad": "跨页多选需在更多菜单中选中【保持已加载内容】",
"keepLazyLoad": "保持已加载的内容",
"localSnapshot": "本地快照",
"localTagSnapshot": "本地标记的快照",
"cloudTagSnapshot": "云端标记的快照",

View file

@ -214,36 +214,6 @@ export class Breadcrumb {
}
}
}).element);
window.siyuan.menus.menu.append(new MenuItem({
label: window.siyuan.languages.optimizeTypography,
click: () => {
fetchPost("/api/format/autoSpace", {
id: protyle.block.rootID
}, () => {
/// #if MOBILE
fetchPost("/api/filetree/getDoc", {
id: protyle.block.id,
mode: 0,
size: Constants.SIZE_GET,
}, getResponse => {
onGet(getResponse, protyle, [Constants.CB_GET_FOCUS]);
});
/// #else
getAllModels().editor.forEach(item => {
if (item.editor.protyle.block.rootID === protyle.block.rootID) {
fetchPost("/api/filetree/getDoc", {
id: item.editor.protyle.block.rootID,
mode: 0,
size: Constants.SIZE_GET,
}, getResponse => {
onGet(getResponse, item.editor.protyle, [Constants.CB_GET_FOCUS]);
});
}
});
/// #endif
});
}
}).element);
window.siyuan.menus.menu.append(new MenuItem({
label: window.siyuan.languages.netImg2LocalAsset,
click: () => {
@ -274,6 +244,45 @@ export class Breadcrumb {
});
}
}).element);
window.siyuan.menus.menu.append(new MenuItem({
label: window.siyuan.languages.optimizeTypography,
click: () => {
fetchPost("/api/format/autoSpace", {
id: protyle.block.rootID
}, () => {
/// #if MOBILE
fetchPost("/api/filetree/getDoc", {
id: protyle.block.id,
mode: 0,
size: Constants.SIZE_GET,
}, getResponse => {
onGet(getResponse, protyle, [Constants.CB_GET_FOCUS]);
});
/// #else
getAllModels().editor.forEach(item => {
if (item.editor.protyle.block.rootID === protyle.block.rootID) {
fetchPost("/api/filetree/getDoc", {
id: item.editor.protyle.block.rootID,
mode: 0,
size: Constants.SIZE_GET,
}, getResponse => {
onGet(getResponse, item.editor.protyle, [Constants.CB_GET_FOCUS]);
});
}
});
/// #endif
});
}
}).element);
if (!protyle.scroll?.element.classList.contains("fn__none")) {
window.siyuan.menus.menu.append(new MenuItem({
current: protyle.scroll.keepLazyLoad,
label: window.siyuan.languages.keepLazyLoad,
click: () => {
protyle.scroll.keepLazyLoad = !protyle.scroll.keepLazyLoad;
}
}).element);
}
window.siyuan.menus.menu.append(new MenuItem({type: "separator"}).element);
window.siyuan.menus.menu.append(new MenuItem({
icon: "iconRefresh",

View file

@ -7,6 +7,7 @@ export class Scroll {
private inputElement: HTMLInputElement;
public blockSize: number;
public lastScrollTop: number;
public keepLazyLoad: boolean;
constructor(protyle: IProtyle) {
const divElement = document.createElement("div");
@ -14,6 +15,7 @@ export class Scroll {
divElement.className = "fn__none protyle-scroll b3-tooltips b3-tooltips__s";
divElement.setAttribute("aria-label", "Blocks 1/1");
this.element = divElement;
this.keepLazyLoad = false;
if (!protyle.options.render.scroll) {
this.element.classList.add("fn__none");
}

View file

@ -104,7 +104,7 @@ const setHTML = (options: { content: string, action?: string[] }, protyle: IProt
const REMOVED_OVER_HEIGHT = protyle.contentElement.clientHeight * 8;
if (options.action.includes(Constants.CB_GET_APPEND)) {
// 动态加载移除
if (protyle.contentElement.scrollHeight > REMOVED_OVER_HEIGHT) {
if (!protyle.wysiwyg.element.querySelector(".protyle-wysiwyg--select") && !protyle.scroll.keepLazyLoad && protyle.contentElement.scrollHeight > REMOVED_OVER_HEIGHT) {
preventScroll(protyle);
let removeElement = protyle.wysiwyg.element.firstElementChild as HTMLElement;
const removeElements = [];
@ -130,9 +130,11 @@ const setHTML = (options: { content: string, action?: string[] }, protyle: IProt
protyle.wysiwyg.element.insertAdjacentHTML("afterbegin", options.content);
protyle.contentElement.scrollTop = protyle.contentElement.scrollTop + (lastElement.getBoundingClientRect().top - lastTop);
// 动态加载移除
while (protyle.wysiwyg.element.childElementCount > 2 && protyle.contentElement.scrollHeight > REMOVED_OVER_HEIGHT &&
protyle.wysiwyg.element.lastElementChild.getBoundingClientRect().top > window.innerHeight) {
protyle.wysiwyg.element.lastElementChild.remove();
if (!protyle.wysiwyg.element.querySelector(".protyle-wysiwyg--select") && !protyle.scroll.keepLazyLoad) {
while (protyle.wysiwyg.element.childElementCount > 2 && protyle.contentElement.scrollHeight > REMOVED_OVER_HEIGHT &&
protyle.wysiwyg.element.lastElementChild.getBoundingClientRect().top > window.innerHeight) {
protyle.wysiwyg.element.lastElementChild.remove();
}
}
} else {
protyle.wysiwyg.element.innerHTML = options.content;

View file

@ -1813,6 +1813,10 @@ export class WYSIWYG {
shiftStartElement = undefined;
} else {
const ids: string[] = [];
if (!protyle.wysiwyg.element.querySelector(".protyle-wysiwyg--select") && protyle.scroll && !protyle.scroll.element.classList.contains("fn__none") && !protyle.scroll.keepLazyLoad &&
(startElement.getBoundingClientRect().top < -protyle.contentElement.clientHeight * 2 || endElement.getBoundingClientRect().bottom > protyle.contentElement.clientHeight * 2)) {
showMessage(window.siyuan.languages.crossKeepLazyLoad);
}
selectElements.forEach(item => {
item.classList.add("protyle-wysiwyg--select");
ids.push(item.getAttribute("data-node-id"));