mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-20 08:30:12 +01:00
This commit is contained in:
parent
4f31068205
commit
141889f058
5 changed files with 28 additions and 41 deletions
|
|
@ -105,6 +105,7 @@ export const reloadSync = (
|
||||||
} else if (item.type !== "local" || data.upsertRootIDs.includes(item.blockId)) {
|
} else if (item.type !== "local" || data.upsertRootIDs.includes(item.blockId)) {
|
||||||
fetchPost("/api/outline/getDocOutline", {
|
fetchPost("/api/outline/getDocOutline", {
|
||||||
id: item.blockId,
|
id: item.blockId,
|
||||||
|
preview: item.isPreview
|
||||||
}, response => {
|
}, response => {
|
||||||
item.update(response);
|
item.update(response);
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -578,23 +578,29 @@ export const isCurrentEditor = (blockId: string) => {
|
||||||
|
|
||||||
export const updateOutline = (models: IModels, protyle: IProtyle, reload = false) => {
|
export const updateOutline = (models: IModels, protyle: IProtyle, reload = false) => {
|
||||||
models.outline.find(item => {
|
models.outline.find(item => {
|
||||||
if (protyle && item.blockId === protyle.block.rootID && item.type === "pin") {
|
if (reload ||
|
||||||
item.isPreview = !protyle.preview.element.classList.contains("fn__none");
|
(item.type === "pin" &&
|
||||||
}
|
(!protyle || item.blockId !== protyle.block?.rootID ||
|
||||||
if (reload || (item.type === "pin" && (!protyle || item.blockId !== protyle.block?.rootID))) {
|
item.isPreview === protyle.preview.element.classList.contains("fn__none"))
|
||||||
|
)
|
||||||
|
) {
|
||||||
let blockId = "";
|
let blockId = "";
|
||||||
if (protyle && protyle.block) {
|
if (protyle && protyle.block) {
|
||||||
blockId = protyle.block.rootID;
|
blockId = protyle.block.rootID;
|
||||||
}
|
}
|
||||||
if (blockId === item.blockId && !reload) {
|
if (blockId === item.blockId && !reload && item.isPreview !== protyle.preview.element.classList.contains("fn__none")) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
fetchPost("/api/outline/getDocOutline", {
|
fetchPost("/api/outline/getDocOutline", {
|
||||||
id: blockId,
|
id: blockId,
|
||||||
|
preview: !protyle.preview.element.classList.contains("fn__none")
|
||||||
}, response => {
|
}, response => {
|
||||||
if (!reload && (!isCurrentEditor(blockId) || item.blockId === blockId)) {
|
if (!reload && (!isCurrentEditor(blockId) || item.blockId === blockId) &&
|
||||||
|
item.isPreview !== protyle.preview.element.classList.contains("fn__none")) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
item.isPreview = !protyle.preview.element.classList.contains("fn__none");
|
||||||
item.update(response, blockId);
|
item.update(response, blockId);
|
||||||
if (protyle) {
|
if (protyle) {
|
||||||
item.updateDocTitle(protyle.background.ial);
|
item.updateDocTitle(protyle.background.ial);
|
||||||
|
|
|
||||||
|
|
@ -206,23 +206,14 @@ export class Outline extends Model {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
this.bindSort();
|
this.bindSort();
|
||||||
if (this.isPreview) {
|
|
||||||
if (this.blockId) {
|
|
||||||
fetchPost("/api/export/preview", {
|
|
||||||
id: this.blockId,
|
|
||||||
}, response => {
|
|
||||||
response.data = response.data.outline;
|
|
||||||
this.update(response);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
fetchPost("/api/outline/getDocOutline", {
|
fetchPost("/api/outline/getDocOutline", {
|
||||||
id: this.blockId,
|
id: this.blockId,
|
||||||
|
preview: this.isPreview
|
||||||
}, response => {
|
}, response => {
|
||||||
this.update(response);
|
this.update(response);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
private bindSort() {
|
private bindSort() {
|
||||||
this.element.addEventListener("mousedown", (event: MouseEvent) => {
|
this.element.addEventListener("mousedown", (event: MouseEvent) => {
|
||||||
|
|
@ -368,7 +359,7 @@ export class Outline extends Model {
|
||||||
}
|
}
|
||||||
|
|
||||||
private onTransaction(data: IWebSocketData) {
|
private onTransaction(data: IWebSocketData) {
|
||||||
if (this.isPreview || data.data.rootID !== this.blockId) {
|
if (data.data.rootID !== this.blockId) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
let needReload = false;
|
let needReload = false;
|
||||||
|
|
@ -397,6 +388,7 @@ export class Outline extends Model {
|
||||||
if (needReload) {
|
if (needReload) {
|
||||||
fetchPost("/api/outline/getDocOutline", {
|
fetchPost("/api/outline/getDocOutline", {
|
||||||
id: this.blockId,
|
id: this.blockId,
|
||||||
|
preview: this.isPreview
|
||||||
}, response => {
|
}, response => {
|
||||||
this.update(response);
|
this.update(response);
|
||||||
// https://github.com/siyuan-note/siyuan/issues/8372
|
// https://github.com/siyuan-note/siyuan/issues/8372
|
||||||
|
|
|
||||||
|
|
@ -71,6 +71,7 @@ export class MobileOutline {
|
||||||
}
|
}
|
||||||
fetchPost("/api/outline/getDocOutline", {
|
fetchPost("/api/outline/getDocOutline", {
|
||||||
id: window.siyuan.mobile.editor.protyle.block.rootID,
|
id: window.siyuan.mobile.editor.protyle.block.rootID,
|
||||||
|
preview: !window.siyuan.mobile.editor.protyle.preview.element.classList.contains("fn__none")
|
||||||
}, response => {
|
}, response => {
|
||||||
let currentId;
|
let currentId;
|
||||||
let currentElement = this.element.querySelector(".b3-list-item--focus");
|
let currentElement = this.element.querySelector(".b3-list-item--focus");
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,7 @@ import {getSearch, isMobile} from "../../util/functions";
|
||||||
import {shell} from "electron";
|
import {shell} from "electron";
|
||||||
/// #endif
|
/// #endif
|
||||||
/// #if !MOBILE
|
/// #if !MOBILE
|
||||||
import {openAsset, openBy} from "../../editor/util";
|
import {openAsset, openBy, updateOutline} from "../../editor/util";
|
||||||
import {getAllModels} from "../../layout/getAll";
|
import {getAllModels} from "../../layout/getAll";
|
||||||
/// #endif
|
/// #endif
|
||||||
import {fetchPost} from "../../util/fetch";
|
import {fetchPost} from "../../util/fetch";
|
||||||
|
|
@ -164,7 +164,7 @@ export class Preview {
|
||||||
this.previewElement = previewElement;
|
this.previewElement = previewElement;
|
||||||
}
|
}
|
||||||
|
|
||||||
public render(protyle: IProtyle, cb?: (outlineData: IBlockTree[]) => void) {
|
public render(protyle: IProtyle) {
|
||||||
if (this.element.style.display === "none") {
|
if (this.element.style.display === "none") {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
@ -191,21 +191,8 @@ export class Preview {
|
||||||
avRender(protyle.preview.previewElement, protyle);
|
avRender(protyle.preview.previewElement, protyle);
|
||||||
speechRender(protyle.preview.previewElement, protyle.options.lang);
|
speechRender(protyle.preview.previewElement, protyle.options.lang);
|
||||||
protyle.preview.previewElement.scrollTop = oldScrollTop;
|
protyle.preview.previewElement.scrollTop = oldScrollTop;
|
||||||
/// #if MOBILE
|
/// #if !MOBILE
|
||||||
if (cb) {
|
updateOutline(getAllModels(), protyle);
|
||||||
cb(response.data.outline);
|
|
||||||
}
|
|
||||||
/// #else
|
|
||||||
response.data = response.data.outline;
|
|
||||||
getAllModels().outline.forEach(item => {
|
|
||||||
if (item.type === "pin" || (item.type === "local" && item.blockId === protyle.block.rootID)) {
|
|
||||||
item.isPreview = true;
|
|
||||||
item.update(response, protyle.block.rootID);
|
|
||||||
if (item.type === "pin") {
|
|
||||||
item.updateDocTitle(protyle.background.ial);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
/// #endif
|
/// #endif
|
||||||
loadingElement.remove();
|
loadingElement.remove();
|
||||||
});
|
});
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue