mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-22 09:30:14 +01:00
This commit is contained in:
parent
eb93255cf3
commit
7486e1a6e2
3 changed files with 37 additions and 4 deletions
|
|
@ -13,8 +13,11 @@ import {removeAttrViewColAnimation, updateAttrViewCellAnimation} from "./action"
|
|||
import {addAssetLink, bindAssetEvent, editAssetItem, getAssetHTML, updateAssetCell} from "./asset";
|
||||
import {Constants} from "../../../constants";
|
||||
import {hideElements} from "../../ui/hideElements";
|
||||
import {pathPosix} from "../../../util/pathName";
|
||||
import {isLocalPath, pathPosix} from "../../../util/pathName";
|
||||
import {openEmojiPanel, unicode2Emoji} from "../../../emoji";
|
||||
import {getSearch, isMobile} from "../../../util/functions";
|
||||
import {openAsset} from "../../../editor/util";
|
||||
import {previewImage} from "../../preview/image";
|
||||
|
||||
export const openMenuPanel = (options: {
|
||||
protyle: IProtyle,
|
||||
|
|
@ -741,6 +744,23 @@ export const openMenuPanel = (options: {
|
|||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
break;
|
||||
} else if (type === "openAssetItem") {
|
||||
const assetLink = target.parentElement.dataset.content;
|
||||
const suffix = pathPosix().extname(assetLink)
|
||||
if (isLocalPath(assetLink) && !isMobile() && (
|
||||
[".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)) {
|
||||
previewImage(assetLink);
|
||||
} else {
|
||||
window.open(assetLink);
|
||||
}
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
break;
|
||||
} else if (type === "editAssetItem") {
|
||||
editAssetItem(options.protyle, data, options.cellElements, target.parentElement);
|
||||
event.preventDefault();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue