Vanessa 2023-01-19 20:31:14 +08:00
parent a00af1bd6c
commit ed3f2af467
16 changed files with 63 additions and 50 deletions

View file

@ -17,13 +17,13 @@ import {setStorageVal} from "../protyle/util/compatibility";
export const openMobileFileById = (id: string, action = [Constants.CB_GET_HL]) => {
window.siyuan.storage[Constants.LOCAL_DOCINFO] = {id, action};
setStorageVal(Constants.LOCAL_DOCINFO, window.siyuan.storage[Constants.LOCAL_DOCINFO]);
if (window.siyuan.mobileEditor) {
hideElements(["toolbar", "hint", "util"], window.siyuan.mobileEditor.protyle);
if (window.siyuan.mobileEditor.protyle.contentElement.classList.contains("fn__none")) {
setEditMode(window.siyuan.mobileEditor.protyle, "wysiwyg");
if (window.siyuan.mobile.editor) {
hideElements(["toolbar", "hint", "util"], window.siyuan.mobile.editor.protyle);
if (window.siyuan.mobile.editor.protyle.contentElement.classList.contains("fn__none")) {
setEditMode(window.siyuan.mobile.editor.protyle, "wysiwyg");
}
let blockElement;
Array.from(window.siyuan.mobileEditor.protyle.wysiwyg.element.querySelectorAll(`[data-node-id="${id}"]`)).find((item: HTMLElement) => {
Array.from(window.siyuan.mobile.editor.protyle.wysiwyg.element.querySelectorAll(`[data-node-id="${id}"]`)).find((item: HTMLElement) => {
if (!hasClosestByAttribute(item.parentElement, "data-type", "NodeBlockQueryEmbed")) {
blockElement = item;
return true;
@ -32,7 +32,7 @@ export const openMobileFileById = (id: string, action = [Constants.CB_GET_HL]) =
if (blockElement) {
pushBack();
focusBlock(blockElement);
scrollCenter(window.siyuan.mobileEditor.protyle, blockElement, true);
scrollCenter(window.siyuan.mobile.editor.protyle, blockElement, true);
closePanel();
return;
}
@ -44,20 +44,20 @@ export const openMobileFileById = (id: string, action = [Constants.CB_GET_HL]) =
lockFile(data.data);
return;
}
if (window.siyuan.mobileEditor) {
if (window.siyuan.mobile.editor) {
pushBack();
addLoading(window.siyuan.mobileEditor.protyle);
addLoading(window.siyuan.mobile.editor.protyle);
fetchPost("/api/filetree/getDoc", {
id,
size: action.includes(Constants.CB_GET_ALL) ? Constants.SIZE_GET_MAX : window.siyuan.config.editor.dynamicLoadBlocks,
mode: action.includes(Constants.CB_GET_CONTEXT) ? 3 : 0,
}, getResponse => {
onGet(getResponse, window.siyuan.mobileEditor.protyle, action);
window.siyuan.mobileEditor.protyle.breadcrumb?.render(window.siyuan.mobileEditor.protyle);
onGet(getResponse, window.siyuan.mobile.editor.protyle, action);
window.siyuan.mobile.editor.protyle.breadcrumb?.render(window.siyuan.mobile.editor.protyle);
});
window.siyuan.mobileEditor.protyle.undo.clear();
window.siyuan.mobile.editor.protyle.undo.clear();
} else {
window.siyuan.mobileEditor = new Protyle(document.getElementById("editor"), {
window.siyuan.mobile.editor = new Protyle(document.getElementById("editor"), {
blockId: id,
action,
render: {