This commit is contained in:
parent
6ca9dedd70
commit
dc5882bd60
7 changed files with 62 additions and 19 deletions
|
@ -14,6 +14,7 @@ import {webViewerPageNumberChanged} from "./pdf/app";
|
|||
import {fetchPost} from "../util/fetch";
|
||||
import {setStorageVal, updateHotkeyTip} from "../protyle/util/compatibility";
|
||||
import {App} from "../index";
|
||||
import {clearOBG} from "../layout/dock/util";
|
||||
|
||||
export class Asset extends Model {
|
||||
public path: string;
|
||||
|
@ -31,6 +32,7 @@ export class Asset extends Model {
|
|||
this.path = options.path;
|
||||
this.pdfId = options.page;
|
||||
this.element.addEventListener("click", (event) => {
|
||||
clearOBG();
|
||||
setPanelFocus(this.element.parentElement.parentElement);
|
||||
this.app.plugins.forEach(item => {
|
||||
item.eventBus.emit("click-pdf", {event});
|
||||
|
|
|
@ -5,6 +5,7 @@ import {fetchPost} from "../util/fetch";
|
|||
import {Protyle} from "../protyle";
|
||||
import {setPanelFocus} from "../layout/util";
|
||||
import {App} from "../index";
|
||||
import {clearOBG} from "../layout/dock/util";
|
||||
|
||||
export const newCardModel = (options: {
|
||||
app: App,
|
||||
|
@ -108,6 +109,7 @@ export const newCardModel = (options: {
|
|||
}
|
||||
});
|
||||
customObj.element.addEventListener("click", () => {
|
||||
clearOBG();
|
||||
setPanelFocus(customObj.element.parentElement.parentElement);
|
||||
});
|
||||
return customObj;
|
||||
|
|
|
@ -28,6 +28,7 @@ import {Search} from "../search";
|
|||
import {App} from "../index";
|
||||
import {newCardModel} from "../card/newCardTab";
|
||||
import {preventScroll} from "../protyle/scroll/preventScroll";
|
||||
import {clearOBG} from "../layout/dock/util";
|
||||
|
||||
export const openFileById = async (options: {
|
||||
app: App,
|
||||
|
@ -86,9 +87,14 @@ export const openFile = async (options: IOpenFileOptions) => {
|
|||
document.querySelectorAll(".av__panel, .av__mask").forEach(item => {
|
||||
item.remove();
|
||||
});
|
||||
// 打开 PDF 时移除文档光标
|
||||
if (document.activeElement instanceof HTMLElement) {
|
||||
document.activeElement.blur();
|
||||
}
|
||||
const allModels = getAllModels();
|
||||
// 文档已打开
|
||||
if (options.assetPath) {
|
||||
clearOBG();
|
||||
const asset = allModels.asset.find((item) => {
|
||||
if (item.path == options.assetPath) {
|
||||
if (!pdfIsLoading(item.parent.parent.element)) {
|
||||
|
@ -106,6 +112,7 @@ export const openFile = async (options: IOpenFileOptions) => {
|
|||
return asset.parent;
|
||||
}
|
||||
} else if (options.custom) {
|
||||
clearOBG();
|
||||
const custom = allModels.custom.find((item) => {
|
||||
if (objEquals(item.data, options.custom.data) && (!options.custom.id || options.custom.id === item.type)) {
|
||||
if (!pdfIsLoading(item.parent.parent.element)) {
|
||||
|
@ -129,6 +136,7 @@ export const openFile = async (options: IOpenFileOptions) => {
|
|||
return hasModel;
|
||||
}
|
||||
} else if (options.searchData) {
|
||||
clearOBG();
|
||||
const search = allModels.search.find((item) => {
|
||||
if (objEquals(item.config, options.searchData)) {
|
||||
if (!pdfIsLoading(item.parent.parent.element)) {
|
||||
|
@ -547,14 +555,14 @@ export const isCurrentEditor = (blockId: string) => {
|
|||
if (activeElement) {
|
||||
const tab = getInstanceById(activeElement.getAttribute("data-id"));
|
||||
if (tab instanceof Tab && tab.model instanceof Editor) {
|
||||
if (tab.model.editor.protyle.block.rootID !== blockId &&
|
||||
tab.model.editor.protyle.block.parentID !== blockId && // updateBacklinkGraph 时会传入 parentID
|
||||
tab.model.editor.protyle.block.id !== blockId) {
|
||||
return false;
|
||||
if (tab.model.editor.protyle.block.rootID === blockId ||
|
||||
tab.model.editor.protyle.block.parentID === blockId || // updateBacklinkGraph 时会传入 parentID
|
||||
tab.model.editor.protyle.block.id === blockId) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
return false;
|
||||
};
|
||||
|
||||
export const updateOutline = (models: IModels, protyle: IProtyle, reload = false) => {
|
||||
|
|
|
@ -40,6 +40,7 @@ import {newCenterEmptyTab, resizeTabs} from "./tabUtil";
|
|||
import {fullscreen} from "../protyle/breadcrumb/action";
|
||||
import {setPadding} from "../protyle/ui/initUI";
|
||||
import {setPosition} from "../util/setPosition";
|
||||
import {clearOBG} from "./dock/util";
|
||||
|
||||
export class Wnd {
|
||||
private app: App;
|
||||
|
@ -497,13 +498,7 @@ export class Wnd {
|
|||
setPadding(currentTab.model.editor.protyle);
|
||||
}
|
||||
} else {
|
||||
updatePanelByEditor({
|
||||
protyle: undefined,
|
||||
focus: false,
|
||||
pushBackStack: false,
|
||||
reload: false,
|
||||
resize,
|
||||
});
|
||||
clearOBG();
|
||||
}
|
||||
if (isSaveLayout) {
|
||||
saveLayout();
|
||||
|
@ -721,13 +716,7 @@ export class Wnd {
|
|||
// 关闭分屏页签后光标消失
|
||||
const editors = getAllModels().editor;
|
||||
if (editors.length === 0) {
|
||||
updatePanelByEditor({
|
||||
protyle: undefined,
|
||||
focus: true,
|
||||
pushBackStack: false,
|
||||
reload: false,
|
||||
resize: true,
|
||||
});
|
||||
clearOBG()
|
||||
} else {
|
||||
editors.forEach(item => {
|
||||
if (!item.element.classList.contains("fn__none")) {
|
||||
|
|
|
@ -196,3 +196,41 @@ export const toggleDockBar = (useElement: Element) => {
|
|||
resizeTabs();
|
||||
resetFloatDockSize();
|
||||
};
|
||||
|
||||
export const clearOBG = () => {
|
||||
const models = getAllModels();
|
||||
models.outline.find(item => {
|
||||
if (item.type === "pin") {
|
||||
if ("" === item.blockId) {
|
||||
return;
|
||||
}
|
||||
item.isPreview = false;
|
||||
item.update({data: [], msg: "", code: 0}, "");
|
||||
item.updateDocTitle();
|
||||
}
|
||||
});
|
||||
models.graph.forEach(item => {
|
||||
if (item.type !== "global") {
|
||||
if (item.type === "local") {
|
||||
return;
|
||||
}
|
||||
if ("" === item.blockId) {
|
||||
return;
|
||||
}
|
||||
item.blockId = "";
|
||||
item.graphData = undefined;
|
||||
item.onGraph(false);
|
||||
}
|
||||
});
|
||||
models.backlink.forEach(item => {
|
||||
if (item.type === "local") {
|
||||
return;
|
||||
}
|
||||
if ("" === item.blockId) {
|
||||
return;
|
||||
}
|
||||
item.saveStatus();
|
||||
item.blockId = "";
|
||||
item.render(undefined);
|
||||
});
|
||||
}
|
||||
|
|
|
@ -14,6 +14,7 @@ import {MobileCustom} from "../mobile/dock/MobileCustom";
|
|||
import {hasClosestByAttribute} from "../protyle/util/hasClosest";
|
||||
import {BlockPanel} from "../block/Panel";
|
||||
import {Setting} from "./Setting";
|
||||
import {clearOBG} from "../layout/dock/util";
|
||||
|
||||
export class Plugin {
|
||||
private app: App;
|
||||
|
@ -268,6 +269,7 @@ export class Plugin {
|
|||
update: options.update,
|
||||
});
|
||||
customObj.element.addEventListener("click", () => {
|
||||
clearOBG();
|
||||
setPanelFocus(customObj.element.parentElement.parentElement);
|
||||
});
|
||||
return customObj;
|
||||
|
|
|
@ -4,6 +4,7 @@ import {Protyle} from "../protyle";
|
|||
import {genSearch} from "./util";
|
||||
import {setPanelFocus} from "../layout/util";
|
||||
import {App} from "../index";
|
||||
import {clearOBG} from "../layout/dock/util";
|
||||
|
||||
export class Search extends Model {
|
||||
public element: HTMLElement;
|
||||
|
@ -22,6 +23,7 @@ export class Search extends Model {
|
|||
this.config = options.config;
|
||||
this.editors = genSearch(options.app, this.config, this.element);
|
||||
this.element.addEventListener("click", () => {
|
||||
clearOBG();
|
||||
setPanelFocus(this.element.parentElement.parentElement);
|
||||
});
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue