This commit is contained in:
parent
66ee7d4715
commit
0337d12bef
6 changed files with 20 additions and 14 deletions
|
@ -53,7 +53,7 @@ export abstract class Constants {
|
|||
// localstorage
|
||||
public static readonly LOCAL_SEARCHEDATA = "local-searchedata";
|
||||
public static readonly LOCAL_SEARCHETABDATA = "local-searchetabdata";
|
||||
public static readonly LOCAL_DOC = "local-doc";
|
||||
public static readonly LOCAL_DOCINFO = "local-docinfo";
|
||||
public static readonly LOCAL_DAILYNOTEID = "local-dailynoteid";
|
||||
public static readonly LOCAL_HISTORYNOTEID = "local-historynoteid";
|
||||
public static readonly LOCAL_CODELANG = "local-codelang";
|
||||
|
|
|
@ -329,6 +329,11 @@ export const zoomOut = (protyle: IProtyle, id: string, focusId?: string, isPushB
|
|||
}
|
||||
}
|
||||
if (window.siyuan.mobileEditor) {
|
||||
window.localStorage.setItem(Constants.LOCAL_DOCINFO, JSON.stringify({
|
||||
id,
|
||||
hasContext: id === protyle.block.rootID,
|
||||
action: id === protyle.block.rootID ? [Constants.CB_GET_HL] : [Constants.CB_GET_ALL]
|
||||
}));
|
||||
window.siyuan.backStack.push({
|
||||
id: protyle.block.id,
|
||||
scrollTop: protyle.contentElement.scrollTop,
|
||||
|
|
|
@ -12,6 +12,7 @@ import {lockFile} from "../dialog/processSystem";
|
|||
import {hasClosestByAttribute} from "../protyle/util/hasClosest";
|
||||
|
||||
export const openMobileFileById = (id: string, hasContext?: boolean, action = [Constants.CB_GET_HL], pushStack = true) => {
|
||||
window.localStorage.setItem(Constants.LOCAL_DOCINFO, JSON.stringify({id, hasContext, action}));
|
||||
if (window.siyuan.mobileEditor) {
|
||||
let blockElement;
|
||||
Array.from(window.siyuan.mobileEditor.protyle.wysiwyg.element.querySelectorAll(`[data-node-id="${id}"]`)).find(item => {
|
||||
|
@ -83,7 +84,6 @@ export const openMobileFileById = (id: string, hasContext?: boolean, action = [C
|
|||
(document.getElementById("toolbarName") as HTMLInputElement).value = data.data.rootTitle;
|
||||
setEditor();
|
||||
closePanel();
|
||||
window.localStorage.setItem(Constants.LOCAL_DOC, id);
|
||||
if (pushStack) {
|
||||
window.siyuan.backStack.push({
|
||||
id,
|
||||
|
|
|
@ -91,14 +91,14 @@ export const initFramework = () => {
|
|||
});
|
||||
initEditorName();
|
||||
if (getOpenNotebookCount() > 0) {
|
||||
const id = window.localStorage.getItem(Constants.LOCAL_DOC) || "";
|
||||
fetchPost("/api/block/checkBlockExist", {id}, existResponse => {
|
||||
const localDoc = JSON.parse(window.localStorage.getItem(Constants.LOCAL_DOCINFO) || '{"id": ""}');
|
||||
fetchPost("/api/block/checkBlockExist", {id: localDoc.id}, existResponse => {
|
||||
if (existResponse.data) {
|
||||
openMobileFileById(id);
|
||||
openMobileFileById(localDoc.id, localDoc.hasContext, localDoc.action);
|
||||
} else {
|
||||
fetchPost("/api/block/getRecentUpdatedBlocks", {}, (response) => {
|
||||
if (response.data.length !== 0) {
|
||||
openMobileFileById(response.data[0].id);
|
||||
openMobileFileById(response.data[0].id, true);
|
||||
} else {
|
||||
setEmpty();
|
||||
}
|
||||
|
|
|
@ -77,7 +77,7 @@ export const popSearch = (modelElement: HTMLElement, modelMainElement: HTMLEleme
|
|||
preventScroll(window.siyuan.mobileEditor.protyle);
|
||||
}
|
||||
fetchPost("/api/block/checkBlockFold", {id}, (foldResponse) => {
|
||||
openMobileFileById(id, !foldResponse.data);
|
||||
openMobileFileById(id, !foldResponse.data, foldResponse.data ? [Constants.CB_GET_ALL, Constants.CB_GET_HL] : [Constants.CB_GET_HL]);
|
||||
});
|
||||
closePanel();
|
||||
event.preventDefault();
|
||||
|
|
|
@ -1251,10 +1251,11 @@ export class WYSIWYG {
|
|||
} else if (aElement) {
|
||||
refBlockId = aElement.getAttribute("data-href").substring(16, 38);
|
||||
}
|
||||
if (isMobile()) {
|
||||
openMobileFileById(refBlockId, false, [Constants.CB_GET_ALL]);
|
||||
} else {
|
||||
fetchPost("/api/block/checkBlockFold", {id: refBlockId}, (foldResponse) => {
|
||||
|
||||
fetchPost("/api/block/checkBlockFold", {id: refBlockId}, (foldResponse) => {
|
||||
if (isMobile()) {
|
||||
openMobileFileById(refBlockId, !foldResponse.data, foldResponse.data ? [Constants.CB_GET_ALL, Constants.CB_GET_HL] : [Constants.CB_GET_HL]);
|
||||
} else {
|
||||
if (window.siyuan.shiftIsPressed) {
|
||||
openFileById({
|
||||
id: refBlockId,
|
||||
|
@ -1287,8 +1288,8 @@ export class WYSIWYG {
|
|||
zoomIn: foldResponse.data
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
if (protyle.model) {
|
||||
// 打开双链需记录到后退中 https://github.com/siyuan-note/insider/issues/801
|
||||
let blockElement: HTMLElement | false;
|
||||
|
@ -1397,7 +1398,7 @@ export class WYSIWYG {
|
|||
const embedItemElement = hasClosestByClassName(event.target, "protyle-wysiwyg__embed");
|
||||
if (embedItemElement) {
|
||||
if (isMobile()) {
|
||||
openMobileFileById(embedItemElement.getAttribute("data-id"), false, [Constants.CB_GET_ALL], true);
|
||||
openMobileFileById(embedItemElement.getAttribute("data-id"), false, [Constants.CB_GET_ALL]);
|
||||
} else if (!protyle.disabled) {
|
||||
window.siyuan.blockPanels.push(new BlockPanel({
|
||||
targetElement: embedItemElement,
|
||||
|
|
Loading…
Add table
Reference in a new issue