mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-05-10 15:42:25 +08:00
This commit is contained in:
parent
8ae79ed363
commit
8bb5c190b9
@ -34,6 +34,7 @@ import {App} from "../index";
|
|||||||
import {newCardModel} from "../card/newCardTab";
|
import {newCardModel} from "../card/newCardTab";
|
||||||
import {preventScroll} from "../protyle/scroll/preventScroll";
|
import {preventScroll} from "../protyle/scroll/preventScroll";
|
||||||
import {clearOBG} from "../layout/dock/util";
|
import {clearOBG} from "../layout/dock/util";
|
||||||
|
import {Model} from "../layout/Model";
|
||||||
|
|
||||||
export const openFileById = async (options: {
|
export const openFileById = async (options: {
|
||||||
app: App,
|
app: App,
|
||||||
@ -44,7 +45,7 @@ export const openFileById = async (options: {
|
|||||||
keepCursor?: boolean
|
keepCursor?: boolean
|
||||||
zoomIn?: boolean
|
zoomIn?: boolean
|
||||||
removeCurrentTab?: boolean
|
removeCurrentTab?: boolean
|
||||||
afterOpen?: () => void
|
afterOpen?: (model:Model) => void
|
||||||
}) => {
|
}) => {
|
||||||
const response = await fetchSyncPost("/api/block/getBlockInfo", {id: options.id});
|
const response = await fetchSyncPost("/api/block/getBlockInfo", {id: options.id});
|
||||||
if (response.code === -1) {
|
if (response.code === -1) {
|
||||||
@ -112,7 +113,7 @@ export const openFile = async (options: IOpenFileOptions) => {
|
|||||||
});
|
});
|
||||||
if (asset) {
|
if (asset) {
|
||||||
if (options.afterOpen) {
|
if (options.afterOpen) {
|
||||||
options.afterOpen();
|
options.afterOpen(asset);
|
||||||
}
|
}
|
||||||
return asset.parent;
|
return asset.parent;
|
||||||
}
|
}
|
||||||
@ -129,14 +130,14 @@ export const openFile = async (options: IOpenFileOptions) => {
|
|||||||
});
|
});
|
||||||
if (custom) {
|
if (custom) {
|
||||||
if (options.afterOpen) {
|
if (options.afterOpen) {
|
||||||
options.afterOpen();
|
options.afterOpen(custom);
|
||||||
}
|
}
|
||||||
return custom.parent;
|
return custom.parent;
|
||||||
}
|
}
|
||||||
const hasModel = getUnInitTab(options);
|
const hasModel = getUnInitTab(options);
|
||||||
if (hasModel) {
|
if (hasModel) {
|
||||||
if (options.afterOpen) {
|
if (options.afterOpen) {
|
||||||
options.afterOpen();
|
options.afterOpen(hasModel.model);
|
||||||
}
|
}
|
||||||
return hasModel;
|
return hasModel;
|
||||||
}
|
}
|
||||||
@ -176,7 +177,7 @@ export const openFile = async (options: IOpenFileOptions) => {
|
|||||||
switchEditor(editor, options, allModels);
|
switchEditor(editor, options, allModels);
|
||||||
}
|
}
|
||||||
if (options.afterOpen) {
|
if (options.afterOpen) {
|
||||||
options.afterOpen();
|
options.afterOpen(editor);
|
||||||
}
|
}
|
||||||
return editor.parent;
|
return editor.parent;
|
||||||
}
|
}
|
||||||
@ -184,7 +185,7 @@ export const openFile = async (options: IOpenFileOptions) => {
|
|||||||
const hasEditor = getUnInitTab(options);
|
const hasEditor = getUnInitTab(options);
|
||||||
if (hasEditor) {
|
if (hasEditor) {
|
||||||
if (options.afterOpen) {
|
if (options.afterOpen) {
|
||||||
options.afterOpen();
|
options.afterOpen(hasEditor.model);
|
||||||
}
|
}
|
||||||
return hasEditor;
|
return hasEditor;
|
||||||
}
|
}
|
||||||
@ -268,7 +269,7 @@ export const openFile = async (options: IOpenFileOptions) => {
|
|||||||
}
|
}
|
||||||
wnd.showHeading();
|
wnd.showHeading();
|
||||||
if (options.afterOpen) {
|
if (options.afterOpen) {
|
||||||
options.afterOpen();
|
options.afterOpen(createdTab.model);
|
||||||
}
|
}
|
||||||
return createdTab;
|
return createdTab;
|
||||||
}
|
}
|
||||||
@ -305,7 +306,7 @@ export const openFile = async (options: IOpenFileOptions) => {
|
|||||||
}
|
}
|
||||||
wnd.showHeading();
|
wnd.showHeading();
|
||||||
if (options.afterOpen) {
|
if (options.afterOpen) {
|
||||||
options.afterOpen();
|
options.afterOpen(createdTab.model);
|
||||||
}
|
}
|
||||||
return createdTab;
|
return createdTab;
|
||||||
}
|
}
|
||||||
|
@ -11,11 +11,12 @@ import {openFileById} from "../../editor/util";
|
|||||||
import {Constants} from "../../constants";
|
import {Constants} from "../../constants";
|
||||||
import {escapeHtml} from "../../util/escape";
|
import {escapeHtml} from "../../util/escape";
|
||||||
import {unicode2Emoji} from "../../emoji";
|
import {unicode2Emoji} from "../../emoji";
|
||||||
import {onGet} from "../../protyle/util/onGet";
|
|
||||||
import {getPreviousBlock} from "../../protyle/wysiwyg/getBlock";
|
import {getPreviousBlock} from "../../protyle/wysiwyg/getBlock";
|
||||||
import {App} from "../../index";
|
import {App} from "../../index";
|
||||||
import {checkFold} from "../../util/noRelyPCFunction";
|
import {checkFold} from "../../util/noRelyPCFunction";
|
||||||
import {transaction} from "../../protyle/wysiwyg/transaction";
|
import {transaction} from "../../protyle/wysiwyg/transaction";
|
||||||
|
import {goHome} from "../../protyle/wysiwyg/commonHotkey";
|
||||||
|
import {Editor} from "../../editor";
|
||||||
|
|
||||||
export class Outline extends Model {
|
export class Outline extends Model {
|
||||||
public tree: Tree;
|
public tree: Tree;
|
||||||
@ -166,12 +167,8 @@ export class Outline extends Model {
|
|||||||
setStorageVal(Constants.LOCAL_OUTLINE, window.siyuan.storage[Constants.LOCAL_OUTLINE]);
|
setStorageVal(Constants.LOCAL_OUTLINE, window.siyuan.storage[Constants.LOCAL_OUTLINE]);
|
||||||
});
|
});
|
||||||
options.tab.panelElement.addEventListener("click", (event: MouseEvent & { target: HTMLElement }) => {
|
options.tab.panelElement.addEventListener("click", (event: MouseEvent & { target: HTMLElement }) => {
|
||||||
if (this.type === "local") {
|
|
||||||
setPanelFocus(options.tab.panelElement.parentElement.parentElement);
|
|
||||||
} else {
|
|
||||||
setPanelFocus(options.tab.panelElement);
|
|
||||||
}
|
|
||||||
let target = event.target as HTMLElement;
|
let target = event.target as HTMLElement;
|
||||||
|
let isFocus = true;
|
||||||
while (target && !target.isEqualNode(options.tab.panelElement)) {
|
while (target && !target.isEqualNode(options.tab.panelElement)) {
|
||||||
if (target.classList.contains("block__icon")) {
|
if (target.classList.contains("block__icon")) {
|
||||||
const type = target.getAttribute("data-type");
|
const type = target.getAttribute("data-type");
|
||||||
@ -182,30 +179,27 @@ export class Outline extends Model {
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
} else if (target.isSameNode(this.headerElement.nextElementSibling) || target.classList.contains("block__icons")) {
|
} else if (target.isSameNode(this.headerElement.nextElementSibling) || target.classList.contains("block__icons")) {
|
||||||
getAllModels().editor.find(item => {
|
openFileById({
|
||||||
if (this.blockId === item.editor.protyle.block.rootID) {
|
app: options.app,
|
||||||
if (item.editor.protyle.scroll.element.classList.contains("fn__none")) {
|
id: this.blockId,
|
||||||
item.editor.protyle.contentElement.scrollTop = 0;
|
afterOpen(model: Editor) {
|
||||||
} else {
|
if (model) {
|
||||||
fetchPost("/api/filetree/getDoc", {
|
goHome(model.editor.protyle);
|
||||||
id: item.editor.protyle.block.rootID,
|
|
||||||
mode: 0,
|
|
||||||
size: window.siyuan.config.editor.dynamicLoadBlocks,
|
|
||||||
}, getResponse => {
|
|
||||||
onGet({
|
|
||||||
data: getResponse,
|
|
||||||
protyle: item.editor.protyle,
|
|
||||||
action: [Constants.CB_GET_FOCUS],
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
isFocus = false;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
target = target.parentElement;
|
target = target.parentElement;
|
||||||
}
|
}
|
||||||
|
if (isFocus) {
|
||||||
|
if (this.type === "local") {
|
||||||
|
setPanelFocus(options.tab.panelElement.parentElement.parentElement);
|
||||||
|
} else {
|
||||||
|
setPanelFocus(options.tab.panelElement);
|
||||||
|
}
|
||||||
|
}
|
||||||
});
|
});
|
||||||
this.bindSort();
|
this.bindSort();
|
||||||
if (this.isPreview) {
|
if (this.isPreview) {
|
||||||
|
@ -17,6 +17,7 @@ import {Menu} from "./Menu";
|
|||||||
import {Protyle} from "../protyle";
|
import {Protyle} from "../protyle";
|
||||||
import {openMobileFileById} from "../mobile/editor";
|
import {openMobileFileById} from "../mobile/editor";
|
||||||
import {lockScreen} from "../dialog/processSystem";
|
import {lockScreen} from "../dialog/processSystem";
|
||||||
|
import {Model} from "../layout/Model";
|
||||||
|
|
||||||
let openTab;
|
let openTab;
|
||||||
let openWindow;
|
let openWindow;
|
||||||
@ -77,7 +78,7 @@ openTab = (options: {
|
|||||||
position?: "right" | "bottom",
|
position?: "right" | "bottom",
|
||||||
keepCursor?: boolean // 是否跳转到新 tab 上
|
keepCursor?: boolean // 是否跳转到新 tab 上
|
||||||
removeCurrentTab?: boolean // 在当前页签打开时需移除原有页签
|
removeCurrentTab?: boolean // 在当前页签打开时需移除原有页签
|
||||||
afterOpen?: () => void // 打开后回调
|
afterOpen?: (model?: Model) => void // 打开后回调
|
||||||
}) => {
|
}) => {
|
||||||
if (options.doc) {
|
if (options.doc) {
|
||||||
if (options.doc.zoomIn) {
|
if (options.doc.zoomIn) {
|
||||||
|
2
app/src/types/index.d.ts
vendored
2
app/src/types/index.d.ts
vendored
@ -552,7 +552,7 @@ interface IOpenFileOptions {
|
|||||||
keepCursor?: boolean // file,是否跳转到新 tab 上
|
keepCursor?: boolean // file,是否跳转到新 tab 上
|
||||||
zoomIn?: boolean // 是否缩放
|
zoomIn?: boolean // 是否缩放
|
||||||
removeCurrentTab?: boolean // 在当前页签打开时需移除原有页签
|
removeCurrentTab?: boolean // 在当前页签打开时需移除原有页签
|
||||||
afterOpen?: () => void // 打开后回调
|
afterOpen?: (model?: import("../layout/Model").Model) => void // 打开后回调
|
||||||
}
|
}
|
||||||
|
|
||||||
interface ILayoutOptions {
|
interface ILayoutOptions {
|
||||||
|
Loading…
Reference in New Issue
Block a user