|
@@ -4,6 +4,7 @@ import {openMobileFileById} from "../editor";
|
|
import {Constants} from "../../constants";
|
|
import {Constants} from "../../constants";
|
|
import {getEventName} from "../../protyle/util/compatibility";
|
|
import {getEventName} from "../../protyle/util/compatibility";
|
|
import {App} from "../../index";
|
|
import {App} from "../../index";
|
|
|
|
+import {closePanel} from "../util/closePanel";
|
|
|
|
|
|
export class MobileOutline {
|
|
export class MobileOutline {
|
|
private tree: Tree;
|
|
private tree: Tree;
|
|
@@ -28,9 +29,14 @@ export class MobileOutline {
|
|
data: null,
|
|
data: null,
|
|
click: (element: HTMLElement) => {
|
|
click: (element: HTMLElement) => {
|
|
const id = element.getAttribute("data-node-id");
|
|
const id = element.getAttribute("data-node-id");
|
|
- fetchPost("/api/block/checkBlockFold", {id}, (foldResponse) => {
|
|
|
|
- openMobileFileById(app, id, foldResponse.data ? [Constants.CB_GET_FOCUS, Constants.CB_GET_ALL, Constants.CB_GET_HTML] : [Constants.CB_GET_FOCUS, Constants.CB_GET_SETID, Constants.CB_GET_CONTEXT, Constants.CB_GET_HTML]);
|
|
|
|
- });
|
|
|
|
|
|
+ if (!window.siyuan.mobile.editor.protyle.preview.element.classList.contains("fn__none")) {
|
|
|
|
+ closePanel();
|
|
|
|
+ document.getElementById(id)?.scrollIntoView();
|
|
|
|
+ } else {
|
|
|
|
+ fetchPost("/api/block/checkBlockFold", {id}, (foldResponse) => {
|
|
|
|
+ openMobileFileById(app, id, foldResponse.data ? [Constants.CB_GET_FOCUS, Constants.CB_GET_ALL, Constants.CB_GET_HTML] : [Constants.CB_GET_FOCUS, Constants.CB_GET_SETID, Constants.CB_GET_CONTEXT, Constants.CB_GET_HTML]);
|
|
|
|
+ });
|
|
|
|
+ }
|
|
}
|
|
}
|
|
});
|
|
});
|
|
this.element.firstElementChild.querySelector('[data-type="collapse"]').addEventListener(getEventName(), () => {
|
|
this.element.firstElementChild.querySelector('[data-type="collapse"]').addEventListener(getEventName(), () => {
|
|
@@ -49,6 +55,12 @@ export class MobileOutline {
|
|
}
|
|
}
|
|
|
|
|
|
public update() {
|
|
public update() {
|
|
|
|
+ if (!window.siyuan.mobile.editor.protyle.preview.element.classList.contains("fn__none")) {
|
|
|
|
+ window.siyuan.mobile.editor.protyle.preview.render(window.siyuan.mobile.editor.protyle, (outlineData) => {
|
|
|
|
+ this.tree.updateData(outlineData);
|
|
|
|
+ });
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
fetchPost("/api/outline/getDocOutline", {
|
|
fetchPost("/api/outline/getDocOutline", {
|
|
id: window.siyuan.mobile.editor.protyle.block.rootID,
|
|
id: window.siyuan.mobile.editor.protyle.block.rootID,
|
|
}, response => {
|
|
}, response => {
|