mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-22 09:30:14 +01:00
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 {fetchPost} from "../util/fetch";
|
||||||
import {setStorageVal, updateHotkeyTip} from "../protyle/util/compatibility";
|
import {setStorageVal, updateHotkeyTip} from "../protyle/util/compatibility";
|
||||||
import {App} from "../index";
|
import {App} from "../index";
|
||||||
|
import {clearOBG} from "../layout/dock/util";
|
||||||
|
|
||||||
export class Asset extends Model {
|
export class Asset extends Model {
|
||||||
public path: string;
|
public path: string;
|
||||||
|
|
@ -31,6 +32,7 @@ export class Asset extends Model {
|
||||||
this.path = options.path;
|
this.path = options.path;
|
||||||
this.pdfId = options.page;
|
this.pdfId = options.page;
|
||||||
this.element.addEventListener("click", (event) => {
|
this.element.addEventListener("click", (event) => {
|
||||||
|
clearOBG();
|
||||||
setPanelFocus(this.element.parentElement.parentElement);
|
setPanelFocus(this.element.parentElement.parentElement);
|
||||||
this.app.plugins.forEach(item => {
|
this.app.plugins.forEach(item => {
|
||||||
item.eventBus.emit("click-pdf", {event});
|
item.eventBus.emit("click-pdf", {event});
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,7 @@ import {fetchPost} from "../util/fetch";
|
||||||
import {Protyle} from "../protyle";
|
import {Protyle} from "../protyle";
|
||||||
import {setPanelFocus} from "../layout/util";
|
import {setPanelFocus} from "../layout/util";
|
||||||
import {App} from "../index";
|
import {App} from "../index";
|
||||||
|
import {clearOBG} from "../layout/dock/util";
|
||||||
|
|
||||||
export const newCardModel = (options: {
|
export const newCardModel = (options: {
|
||||||
app: App,
|
app: App,
|
||||||
|
|
@ -108,6 +109,7 @@ export const newCardModel = (options: {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
customObj.element.addEventListener("click", () => {
|
customObj.element.addEventListener("click", () => {
|
||||||
|
clearOBG();
|
||||||
setPanelFocus(customObj.element.parentElement.parentElement);
|
setPanelFocus(customObj.element.parentElement.parentElement);
|
||||||
});
|
});
|
||||||
return customObj;
|
return customObj;
|
||||||
|
|
|
||||||
|
|
@ -28,6 +28,7 @@ import {Search} from "../search";
|
||||||
import {App} from "../index";
|
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";
|
||||||
|
|
||||||
export const openFileById = async (options: {
|
export const openFileById = async (options: {
|
||||||
app: App,
|
app: App,
|
||||||
|
|
@ -86,9 +87,14 @@ export const openFile = async (options: IOpenFileOptions) => {
|
||||||
document.querySelectorAll(".av__panel, .av__mask").forEach(item => {
|
document.querySelectorAll(".av__panel, .av__mask").forEach(item => {
|
||||||
item.remove();
|
item.remove();
|
||||||
});
|
});
|
||||||
|
// 打开 PDF 时移除文档光标
|
||||||
|
if (document.activeElement instanceof HTMLElement) {
|
||||||
|
document.activeElement.blur();
|
||||||
|
}
|
||||||
const allModels = getAllModels();
|
const allModels = getAllModels();
|
||||||
// 文档已打开
|
// 文档已打开
|
||||||
if (options.assetPath) {
|
if (options.assetPath) {
|
||||||
|
clearOBG();
|
||||||
const asset = allModels.asset.find((item) => {
|
const asset = allModels.asset.find((item) => {
|
||||||
if (item.path == options.assetPath) {
|
if (item.path == options.assetPath) {
|
||||||
if (!pdfIsLoading(item.parent.parent.element)) {
|
if (!pdfIsLoading(item.parent.parent.element)) {
|
||||||
|
|
@ -106,6 +112,7 @@ export const openFile = async (options: IOpenFileOptions) => {
|
||||||
return asset.parent;
|
return asset.parent;
|
||||||
}
|
}
|
||||||
} else if (options.custom) {
|
} else if (options.custom) {
|
||||||
|
clearOBG();
|
||||||
const custom = allModels.custom.find((item) => {
|
const custom = allModels.custom.find((item) => {
|
||||||
if (objEquals(item.data, options.custom.data) && (!options.custom.id || options.custom.id === item.type)) {
|
if (objEquals(item.data, options.custom.data) && (!options.custom.id || options.custom.id === item.type)) {
|
||||||
if (!pdfIsLoading(item.parent.parent.element)) {
|
if (!pdfIsLoading(item.parent.parent.element)) {
|
||||||
|
|
@ -129,6 +136,7 @@ export const openFile = async (options: IOpenFileOptions) => {
|
||||||
return hasModel;
|
return hasModel;
|
||||||
}
|
}
|
||||||
} else if (options.searchData) {
|
} else if (options.searchData) {
|
||||||
|
clearOBG();
|
||||||
const search = allModels.search.find((item) => {
|
const search = allModels.search.find((item) => {
|
||||||
if (objEquals(item.config, options.searchData)) {
|
if (objEquals(item.config, options.searchData)) {
|
||||||
if (!pdfIsLoading(item.parent.parent.element)) {
|
if (!pdfIsLoading(item.parent.parent.element)) {
|
||||||
|
|
@ -547,14 +555,14 @@ export const isCurrentEditor = (blockId: string) => {
|
||||||
if (activeElement) {
|
if (activeElement) {
|
||||||
const tab = getInstanceById(activeElement.getAttribute("data-id"));
|
const tab = getInstanceById(activeElement.getAttribute("data-id"));
|
||||||
if (tab instanceof Tab && tab.model instanceof Editor) {
|
if (tab instanceof Tab && tab.model instanceof Editor) {
|
||||||
if (tab.model.editor.protyle.block.rootID !== blockId &&
|
if (tab.model.editor.protyle.block.rootID === blockId ||
|
||||||
tab.model.editor.protyle.block.parentID !== blockId && // updateBacklinkGraph 时会传入 parentID
|
tab.model.editor.protyle.block.parentID === blockId || // updateBacklinkGraph 时会传入 parentID
|
||||||
tab.model.editor.protyle.block.id !== blockId) {
|
tab.model.editor.protyle.block.id === blockId) {
|
||||||
return false;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return true;
|
return false;
|
||||||
};
|
};
|
||||||
|
|
||||||
export const updateOutline = (models: IModels, protyle: IProtyle, reload = 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 {fullscreen} from "../protyle/breadcrumb/action";
|
||||||
import {setPadding} from "../protyle/ui/initUI";
|
import {setPadding} from "../protyle/ui/initUI";
|
||||||
import {setPosition} from "../util/setPosition";
|
import {setPosition} from "../util/setPosition";
|
||||||
|
import {clearOBG} from "./dock/util";
|
||||||
|
|
||||||
export class Wnd {
|
export class Wnd {
|
||||||
private app: App;
|
private app: App;
|
||||||
|
|
@ -497,13 +498,7 @@ export class Wnd {
|
||||||
setPadding(currentTab.model.editor.protyle);
|
setPadding(currentTab.model.editor.protyle);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
updatePanelByEditor({
|
clearOBG();
|
||||||
protyle: undefined,
|
|
||||||
focus: false,
|
|
||||||
pushBackStack: false,
|
|
||||||
reload: false,
|
|
||||||
resize,
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
if (isSaveLayout) {
|
if (isSaveLayout) {
|
||||||
saveLayout();
|
saveLayout();
|
||||||
|
|
@ -721,13 +716,7 @@ export class Wnd {
|
||||||
// 关闭分屏页签后光标消失
|
// 关闭分屏页签后光标消失
|
||||||
const editors = getAllModels().editor;
|
const editors = getAllModels().editor;
|
||||||
if (editors.length === 0) {
|
if (editors.length === 0) {
|
||||||
updatePanelByEditor({
|
clearOBG()
|
||||||
protyle: undefined,
|
|
||||||
focus: true,
|
|
||||||
pushBackStack: false,
|
|
||||||
reload: false,
|
|
||||||
resize: true,
|
|
||||||
});
|
|
||||||
} else {
|
} else {
|
||||||
editors.forEach(item => {
|
editors.forEach(item => {
|
||||||
if (!item.element.classList.contains("fn__none")) {
|
if (!item.element.classList.contains("fn__none")) {
|
||||||
|
|
|
||||||
|
|
@ -196,3 +196,41 @@ export const toggleDockBar = (useElement: Element) => {
|
||||||
resizeTabs();
|
resizeTabs();
|
||||||
resetFloatDockSize();
|
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 {hasClosestByAttribute} from "../protyle/util/hasClosest";
|
||||||
import {BlockPanel} from "../block/Panel";
|
import {BlockPanel} from "../block/Panel";
|
||||||
import {Setting} from "./Setting";
|
import {Setting} from "./Setting";
|
||||||
|
import {clearOBG} from "../layout/dock/util";
|
||||||
|
|
||||||
export class Plugin {
|
export class Plugin {
|
||||||
private app: App;
|
private app: App;
|
||||||
|
|
@ -268,6 +269,7 @@ export class Plugin {
|
||||||
update: options.update,
|
update: options.update,
|
||||||
});
|
});
|
||||||
customObj.element.addEventListener("click", () => {
|
customObj.element.addEventListener("click", () => {
|
||||||
|
clearOBG();
|
||||||
setPanelFocus(customObj.element.parentElement.parentElement);
|
setPanelFocus(customObj.element.parentElement.parentElement);
|
||||||
});
|
});
|
||||||
return customObj;
|
return customObj;
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,7 @@ import {Protyle} from "../protyle";
|
||||||
import {genSearch} from "./util";
|
import {genSearch} from "./util";
|
||||||
import {setPanelFocus} from "../layout/util";
|
import {setPanelFocus} from "../layout/util";
|
||||||
import {App} from "../index";
|
import {App} from "../index";
|
||||||
|
import {clearOBG} from "../layout/dock/util";
|
||||||
|
|
||||||
export class Search extends Model {
|
export class Search extends Model {
|
||||||
public element: HTMLElement;
|
public element: HTMLElement;
|
||||||
|
|
@ -22,6 +23,7 @@ export class Search extends Model {
|
||||||
this.config = options.config;
|
this.config = options.config;
|
||||||
this.editors = genSearch(options.app, this.config, this.element);
|
this.editors = genSearch(options.app, this.config, this.element);
|
||||||
this.element.addEventListener("click", () => {
|
this.element.addEventListener("click", () => {
|
||||||
|
clearOBG();
|
||||||
setPanelFocus(this.element.parentElement.parentElement);
|
setPanelFocus(this.element.parentElement.parentElement);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue