Skip to content

An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作

:art: Improve opening rows from relation selector https://github.com/siyuan-note/siyuan/issues/13645

Daniel80b4afd810c1
diff --git a/app/src/editor/util.ts b/app/src/editor/util.ts
index 88d04714d5..bb0ae5edfe 100644
--- a/app/src/editor/util.ts
+++ b/app/src/editor/util.ts
@@ -55,6 +55,7 @@ export const openFileById = async (options: {
zoomIn?: boolean
removeCurrentTab?: boolean
openNewTab?: boolean
+ keepAVPanel?: boolean
afterOpen?: (model: Model) => void,
scrollPosition?: ScrollLogicalPosition
}) => {
@@ -83,6 +84,7 @@ export const openFileById = async (options: {
removeCurrentTab: options.removeCurrentTab,
afterOpen: options.afterOpen,
openNewTab: options.openNewTab,
+ keepAVPanel: options.keepAVPanel,
scrollPosition: options.scrollPosition,
});
};
@@ -106,9 +108,11 @@ export const openFile = async (options: IOpenFileOptions) => {
options.removeCurrentTab = true;
}
// https://github.com/siyuan-note/siyuan/issues/10168
- document.querySelectorAll(".av__panel, .av__mask").forEach(item => {
- item.remove();
- });
+ if (!options.keepAVPanel) {
+ document.querySelectorAll(".av__panel, .av__mask").forEach(item => {
+ item.remove();
+ });
+ }
// 打开 PDF 时移除文档光标
if (document.activeElement instanceof HTMLElement) {
document.activeElement.blur();
diff --git a/app/src/protyle/render/av/openDatabaseRow.ts b/app/src/protyle/render/av/openDatabaseRow.ts
index a7ca9ba31c..c77d722007 100644
--- a/app/src/protyle/render/av/openDatabaseRow.ts
+++ b/app/src/protyle/render/av/openDatabaseRow.ts
@@ -141,6 +141,7 @@ const getDatabaseRowPreviewTab = (blockID: string) => {
export const openDatabaseRowByData = async (protyle: IProtyle, data: IDatabaseRowOpenData, options?: {
position?: string,
+ keepAVPanel?: boolean,
}) => {
const title = data.title || window.siyuan.languages.untitled;
const openStandalone = data.isDetached || !window.siyuan.config.editor.databaseAttrShow;
@@ -171,9 +172,10 @@ export const openDatabaseRowByData = async (protyle: IProtyle, data: IDatabaseRo
}
const opened = await openFile({
app: protyle.app,
- position: options ? options.position : "right",
- removeCurrentTab: options ? undefined : false,
- openNewTab: options ? undefined : true,
+ position: options?.position || "right",
+ removeCurrentTab: options && !options.keepAVPanel ? undefined : false,
+ openNewTab: options ? options.keepAVPanel ? false : undefined : true,
+ keepAVPanel: options?.keepAVPanel,
custom: {
id: "siyuan-database-row",
icon: "iconDatabase",
@@ -203,7 +205,7 @@ export const openDatabaseRowByData = async (protyle: IProtyle, data: IDatabaseRo
if (!data.boundBlockID) {
return false;
}
- if (options) {
+ if (options && !options.keepAVPanel) {
const opened = await openFileById({
app: protyle.app,
id: data.boundBlockID,
@@ -244,6 +246,7 @@ export const openDatabaseRowByData = async (protyle: IProtyle, data: IDatabaseRo
position: "right",
openNewTab: true,
removeCurrentTab: false,
+ keepAVPanel: options?.keepAVPanel,
zoomIn: true,
afterOpen(model: Editor) {
showDatabaseRowPreview(model, data);
diff --git a/app/src/protyle/render/av/relation.ts b/app/src/protyle/render/av/relation.ts
index 61d5fb2bfc..afd5406532 100644
--- a/app/src/protyle/render/av/relation.ts
+++ b/app/src/protyle/render/av/relation.ts
@@ -648,6 +648,8 @@ ${genRelationLoaderHTML(state.loading)}`;
title: blockElement.textContent,
boundBlockID: blockElement.dataset.id,
isDetached: !blockElement.classList.contains("popover__block"),
+ }, {
+ keepAVPanel: true,
});
});
listElement.addEventListener("scroll", () => {
diff --git a/app/src/types/index.d.ts b/app/src/types/index.d.ts
index 46f098e602..4fcdff2546 100644
--- a/app/src/types/index.d.ts
+++ b/app/src/types/index.d.ts
@@ -791,6 +791,7 @@ interface IOpenFileOptions {
zoomIn?: boolean // 是否缩放
removeCurrentTab?: boolean // 在当前页签打开时需移除原有页签
openNewTab?: boolean // 使用新页签打开
+ keepAVPanel?: boolean // 打开时保留数据库面板
afterOpen?: (model?: import("../layout/Model").Model) => void // 打开后回调
}