Skip to content

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

:art: Improve the database assets field file opening (#17054)

Jeffrey Chen5be6c0e2a9aa
diff --git a/app/src/protyle/render/av/blockAttr.ts b/app/src/protyle/render/av/blockAttr.ts
index 5bc73d0f46..36362d0e68 100644
--- a/app/src/protyle/render/av/blockAttr.ts
+++ b/app/src/protyle/render/av/blockAttr.ts
@@ -16,7 +16,7 @@ import {webUtils} from "electron";
/// #endif
import {isBrowser} from "../../../util/functions";
import {Constants} from "../../../constants";
-import {getCompressURL} from "../../../util/image";
+import {getCompressURL, removeCompressURL} from "../../../util/image";
const genAVRollupHTML = (value: IAVCellValue) => {
let html = "";
@@ -502,7 +502,7 @@ const openEdit = (protyle: IProtyle, element: HTMLElement, event: MouseEvent) =>
});
} else {
if (target.tagName === "IMG") {
- previewImages([target.getAttribute("src")]);
+ previewImages([removeCompressURL(target.getAttribute("src"))]);
} else {
openLink(protyle, target.dataset.url, event, event.ctrlKey || event.metaKey);
}
diff --git a/app/src/protyle/render/av/openMenuPanel.ts b/app/src/protyle/render/av/openMenuPanel.ts
index 17c584dc79..275e2507d7 100644
--- a/app/src/protyle/render/av/openMenuPanel.ts
+++ b/app/src/protyle/render/av/openMenuPanel.ts
@@ -21,12 +21,10 @@ import {updateAttrViewCellAnimation} from "./action";
import {addAssetLink, bindAssetEvent, editAssetItem, getAssetHTML, updateAssetCell} from "./asset";
import {Constants} from "../../../constants";
import {hideElements} from "../../ui/hideElements";
-import {isLocalPath, pathPosix} from "../../../util/pathName";
+import {pathPosix} from "../../../util/pathName";
import {openEmojiPanel, unicode2Emoji} from "../../../emoji";
-import {getSearch, isMobile} from "../../../util/functions";
-/// #if !MOBILE
-import {openAsset} from "../../../editor/util";
-/// #endif
+import {isMobile} from "../../../util/functions";
+import {openLink} from "../../../editor/openLink";
import {previewAttrViewImages} from "../../preview/image";
import {assetMenu} from "../../../menus/protyle";
import {
@@ -1358,29 +1356,13 @@ export const openMenuPanel = (options: {
event.stopPropagation();
break;
} else if (type === "openAssetItem") {
- const assetType = target.parentElement.dataset.type;
const assetLink = target.parentElement.dataset.content;
- /// #if !MOBILE
- const suffix = pathPosix().extname(assetLink);
- if (assetType === "image") {
+ if (target.parentElement.dataset.type === "image") {
previewAttrViewImages(assetLink, avID, options.blockElement.getAttribute(Constants.CUSTOM_SY_AV_VIEW),
options.blockElement.querySelector('[data-type="av-search"]')?.textContent.trim() || "");
- } else if (isLocalPath(assetLink) && assetType === "file" && (
- (suffix === ".pdf" && !assetLink.startsWith("file://")) ||
- Constants.SIYUAN_ASSETS_AUDIO.concat(Constants.SIYUAN_ASSETS_VIDEO, Constants.SIYUAN_ASSETS_IMAGE).includes(suffix)
- )) {
- openAsset(options.protyle.app, assetLink.trim(), parseInt(getSearch("page", assetLink)), "right");
} else {
- window.open(assetLink);
+ openLink(options.protyle, assetLink, event, event.ctrlKey || event.metaKey);
}
- /// #else
- if (assetType === "image") {
- previewAttrViewImages(assetLink, avID, options.blockElement.getAttribute(Constants.CUSTOM_SY_AV_VIEW),
- options.blockElement.querySelector('[data-type="av-search"]')?.textContent.trim() || "");
- } else {
- window.open(assetLink);
- }
- /// #endif
event.preventDefault();
event.stopPropagation();
break;