mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-23 10:00:13 +01:00
This commit is contained in:
parent
1fe22e15f4
commit
17b4d8765a
5 changed files with 35 additions and 4 deletions
|
|
@ -18,6 +18,8 @@ import {redirectToCheckAuth} from "../util/pathName";
|
|||
import {getAllModels} from "../layout/getAll";
|
||||
import {reloadProtyle} from "../protyle/util/reload";
|
||||
import {Tab} from "../layout/Tab";
|
||||
import {setEmpty} from "../mobile/util/setEmpty";
|
||||
import {hideElements} from "../protyle/ui/hideElements";
|
||||
|
||||
|
||||
const updateTitle = (rootID: string, tab: Tab) => {
|
||||
|
|
@ -27,7 +29,30 @@ const updateTitle = (rootID: string, tab: Tab) => {
|
|||
tab.updateTitle(response.data.name);
|
||||
});
|
||||
};
|
||||
|
||||
export const reloadSync = (data: { upsertRootIDs: string[], removeRootIDs: string[] }) => {
|
||||
/// #if MOBILE
|
||||
if (window.siyuan.mobile.popEditor) {
|
||||
if (data.removeRootIDs.includes(window.siyuan.mobile.popEditor.protyle.block.rootID)) {
|
||||
hideElements(["dialog"]);
|
||||
} else {
|
||||
reloadProtyle(window.siyuan.mobile.popEditor.protyle);
|
||||
}
|
||||
}
|
||||
if (window.siyuan.mobile.editor) {
|
||||
if (data.removeRootIDs.includes(window.siyuan.mobile.editor.protyle.block.rootID)) {
|
||||
setEmpty();
|
||||
} else {
|
||||
reloadProtyle(window.siyuan.mobile.editor.protyle);
|
||||
fetchPost("/api/block/getDocInfo", {
|
||||
id: window.siyuan.mobile.editor.protyle.block.rootID
|
||||
}, (response) => {
|
||||
(document.getElementById("toolbarName") as HTMLInputElement).value = response.data.rootTitle === "Untitled" ? "" : response.data.rootTitle;
|
||||
});
|
||||
}
|
||||
}
|
||||
window.siyuan.mobile.files.init(false);
|
||||
/// #else
|
||||
const allModels = getAllModels();
|
||||
allModels.editor.forEach(item => {
|
||||
if (data.upsertRootIDs.includes(item.editor.protyle.block.rootID)) {
|
||||
|
|
@ -84,6 +109,7 @@ export const reloadSync = (data: { upsertRootIDs: string[], removeRootIDs: strin
|
|||
allModels.search.forEach(item => {
|
||||
item.parent.panelElement.querySelector("#searchInput").dispatchEvent(new CustomEvent("input"));
|
||||
});
|
||||
/// #endif
|
||||
};
|
||||
|
||||
export const lockScreen = () => {
|
||||
|
|
|
|||
|
|
@ -266,7 +266,7 @@ export class MobileFiles extends Model {
|
|||
}
|
||||
}
|
||||
|
||||
private init(init = true) {
|
||||
public init(init = true) {
|
||||
let html = "";
|
||||
let closeHtml = "";
|
||||
window.siyuan.notebooks.forEach((item) => {
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
import {openMobileFileById} from "../editor";
|
||||
import {processSync, progressLoading, progressStatus, transactionError} from "../../dialog/processSystem";
|
||||
import {processSync, progressLoading, progressStatus, reloadSync, transactionError} from "../../dialog/processSystem";
|
||||
import {Constants} from "../../constants";
|
||||
|
||||
const processReadonly = () => {
|
||||
|
|
@ -17,6 +17,9 @@ const processReadonly = () => {
|
|||
export const onMessage = (data: IWebSocketData) => {
|
||||
if (data) {
|
||||
switch (data.cmd) {
|
||||
case "syncMergeResult":
|
||||
reloadSync(data.data);
|
||||
break;
|
||||
case "readonly":
|
||||
window.siyuan.config.editor.readOnly = data.data;
|
||||
processReadonly();
|
||||
|
|
|
|||
|
|
@ -64,7 +64,6 @@ export const turnIntoTaskList = (protyle: IProtyle, type: string, blockElement:
|
|||
return false
|
||||
}
|
||||
|
||||
|
||||
export const headingTurnIntoList = (protyle: IProtyle, type: string, blockElement: HTMLElement, editElement: HTMLElement) => {
|
||||
if (type !== "NodeHeading" && ["* ", "- "].includes(editElement.innerHTML.substring(0, 2))) {
|
||||
const id = blockElement.getAttribute("data-node-id")
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ import {openFileById} from "../editor/util";
|
|||
import {
|
||||
processSync, progressBackgroundTask,
|
||||
progressLoading,
|
||||
progressStatus,
|
||||
progressStatus, reloadSync,
|
||||
setTitle,
|
||||
transactionError
|
||||
} from "../dialog/processSystem";
|
||||
|
|
@ -42,6 +42,9 @@ class App {
|
|||
msgCallback: (data) => {
|
||||
if (data) {
|
||||
switch (data.cmd) {
|
||||
case "syncMergeResult":
|
||||
reloadSync(data.data);
|
||||
break;
|
||||
case "progress":
|
||||
progressLoading(data);
|
||||
break;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue