mirror of
https://github.com/siyuan-note/siyuan.git
synced 2026-01-24 09:16:09 +01:00
🎨 Improve image clicking behavior in database asset field menu (#16671)
- Fix: Images without file extensions (e.g., api/icon/getDynamicIcon) in data-type="image" cannot be previewed after clicking - Fix: When data-type="file" but content is an image link, clicking on desktop cannot open in split-screen, and clicking on mobile cannot open in browser
This commit is contained in:
parent
18aa22ca2f
commit
b0dce4510d
1 changed files with 9 additions and 8 deletions
|
|
@ -1354,23 +1354,24 @@ export const openMenuPanel = (options: {
|
|||
event.stopPropagation();
|
||||
break;
|
||||
} else if (type === "openAssetItem") {
|
||||
const assetType = target.parentElement.dataset.type;
|
||||
const assetLink = target.parentElement.dataset.content;
|
||||
const suffix = pathPosix().extname(assetLink);
|
||||
/// #if !MOBILE
|
||||
if (isLocalPath(assetLink) && (
|
||||
[".pdf"].concat(Constants.SIYUAN_ASSETS_AUDIO).concat(Constants.SIYUAN_ASSETS_VIDEO).includes(suffix) && (
|
||||
suffix !== ".pdf" || (suffix === ".pdf" && !assetLink.startsWith("file://"))
|
||||
)
|
||||
)) {
|
||||
openAsset(options.protyle.app, assetLink.trim(), parseInt(getSearch("page", assetLink)), "right");
|
||||
} else if (Constants.SIYUAN_ASSETS_IMAGE.includes(suffix)) {
|
||||
if (assetType === "image") {
|
||||
previewAttrViewImages(assetLink, avID, options.blockElement.getAttribute(Constants.CUSTOM_SY_AV_VIEW),
|
||||
(options.blockElement.querySelector('[data-type="av-search"]') as HTMLInputElement)?.value.trim() || "");
|
||||
} else if (isLocalPath(assetLink) && (
|
||||
assetType === "file" && Constants.SIYUAN_ASSETS_IMAGE.includes(suffix) || // data-type="file" 但内容是图片链接时,分屏打开
|
||||
suffix === ".pdf" && !assetLink.startsWith("file://") ||
|
||||
Constants.SIYUAN_ASSETS_AUDIO.concat(Constants.SIYUAN_ASSETS_VIDEO).includes(suffix)
|
||||
)) {
|
||||
openAsset(options.protyle.app, assetLink.trim(), parseInt(getSearch("page", assetLink)), "right");
|
||||
} else {
|
||||
window.open(assetLink);
|
||||
}
|
||||
/// #else
|
||||
if (Constants.SIYUAN_ASSETS_IMAGE.includes(suffix)) {
|
||||
if (assetType === "image") {
|
||||
previewAttrViewImages(assetLink, avID, options.blockElement.getAttribute(Constants.CUSTOM_SY_AV_VIEW),
|
||||
(options.blockElement.querySelector('[data-type="av-search"]') as HTMLInputElement)?.value.trim() || "");
|
||||
} else {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue