Vanessa 2024-06-24 21:46:20 +08:00
parent 4f6f4770eb
commit 4f4d41ebb4
3 changed files with 16 additions and 6 deletions

View file

@ -35,7 +35,14 @@ const updateTitle = (rootID: string, tab: Tab, protyle?: IProtyle) => {
}); });
}; };
export const reloadSync = (app: App, data: { upsertRootIDs: string[], removeRootIDs: string[] }, hideMsg = true) => { export const reloadSync = (
app: App,
data: { upsertRootIDs: string[], removeRootIDs: string[] },
hideMsg = true,
// 同步的时候需要更新只读状态 https://github.com/siyuan-note/siyuan/issues/11517
// 调整大纲的时候需要使用现有状态 https://github.com/siyuan-note/siyuan/issues/11808
updateReadonly = true
) => {
if (hideMsg) { if (hideMsg) {
hideMessage(); hideMessage();
} }
@ -44,14 +51,14 @@ export const reloadSync = (app: App, data: { upsertRootIDs: string[], removeRoot
if (data.removeRootIDs.includes(window.siyuan.mobile.popEditor.protyle.block.rootID)) { if (data.removeRootIDs.includes(window.siyuan.mobile.popEditor.protyle.block.rootID)) {
hideElements(["dialog"]); hideElements(["dialog"]);
} else { } else {
reloadProtyle(window.siyuan.mobile.popEditor.protyle, false); reloadProtyle(window.siyuan.mobile.popEditor.protyle, false, updateReadonly);
} }
} }
if (window.siyuan.mobile.editor) { if (window.siyuan.mobile.editor) {
if (data.removeRootIDs.includes(window.siyuan.mobile.editor.protyle.block.rootID)) { if (data.removeRootIDs.includes(window.siyuan.mobile.editor.protyle.block.rootID)) {
setEmpty(app); setEmpty(app);
} else { } else {
reloadProtyle(window.siyuan.mobile.editor.protyle, false); reloadProtyle(window.siyuan.mobile.editor.protyle, false, updateReadonly);
fetchPost("/api/block/getDocInfo", { fetchPost("/api/block/getDocInfo", {
id: window.siyuan.mobile.editor.protyle.block.rootID id: window.siyuan.mobile.editor.protyle.block.rootID
}, (response) => { }, (response) => {
@ -71,7 +78,7 @@ export const reloadSync = (app: App, data: { upsertRootIDs: string[], removeRoot
id: item.editor.protyle.block.rootID, id: item.editor.protyle.block.rootID,
}, (response) => { }, (response) => {
item.editor.protyle.wysiwyg.renderCustom(response.data.ial); item.editor.protyle.wysiwyg.renderCustom(response.data.ial);
reloadProtyle(item.editor.protyle, false, true); reloadProtyle(item.editor.protyle, false, updateReadonly);
updateTitle(item.editor.protyle.block.rootID, item.parent, item.editor.protyle); updateTitle(item.editor.protyle.block.rootID, item.parent, item.editor.protyle);
}); });
} else if (data.removeRootIDs.includes(item.editor.protyle.block.rootID)) { } else if (data.removeRootIDs.includes(item.editor.protyle.block.rootID)) {

View file

@ -72,7 +72,7 @@ export class App {
reloadSync(this, data.data); reloadSync(this, data.data);
break; break;
case "reloaddoc": case "reloaddoc":
reloadSync(this, {upsertRootIDs: [data.data], removeRootIDs: []}, false); reloadSync(this, {upsertRootIDs: [data.data], removeRootIDs: []}, false, false);
break; break;
case "readonly": case "readonly":
window.siyuan.config.editor.readOnly = data.data; window.siyuan.config.editor.readOnly = data.data;

View file

@ -59,6 +59,9 @@ class App {
window.siyuan.emojis = response.data as IEmoji[]; window.siyuan.emojis = response.data as IEmoji[];
}); });
break; break;
case "reloaddoc":
reloadSync(this, {upsertRootIDs: [data.data], removeRootIDs: []}, false, false);
break;
case "syncMergeResult": case "syncMergeResult":
reloadSync(this, data.data); reloadSync(this, data.data);
break; break;