mirror of
https://github.com/siyuan-note/siyuan.git
synced 2026-03-13 07:56:14 +01:00
🎨 Improve the database assets field file opening (#17054)
This commit is contained in:
parent
53dc005a6f
commit
5be6c0e2a9
2 changed files with 7 additions and 25 deletions
|
|
@ -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);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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") {
|
||||
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);
|
||||
}
|
||||
/// #else
|
||||
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 {
|
||||
window.open(assetLink);
|
||||
openLink(options.protyle, assetLink, event, event.ctrlKey || event.metaKey);
|
||||
}
|
||||
/// #endif
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
break;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue