mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-24 02:20:13 +01:00
This commit is contained in:
parent
05cfcf7c2b
commit
64900706b2
13 changed files with 119 additions and 58 deletions
|
|
@ -12,6 +12,8 @@ import {formatNumber} from "./number";
|
|||
import {removeAttrViewColAnimation} from "./action";
|
||||
import {addAssetLink, bindAssetEvent, editAssetItem, getAssetHTML, updateAssetCell} from "./asset";
|
||||
import {Constants} from "../../../constants";
|
||||
import {hideElements} from "../../ui/hideElements";
|
||||
import {pathPosix} from "../../../util/pathName";
|
||||
|
||||
export const openMenuPanel = (options: {
|
||||
protyle: IProtyle,
|
||||
|
|
@ -322,7 +324,12 @@ export const openMenuPanel = (options: {
|
|||
while (target && !target.isSameNode(avPanelElement)) {
|
||||
const type = target.dataset.type;
|
||||
if (type === "close") {
|
||||
avPanelElement.remove();
|
||||
if (options.protyle.toolbar.subElement.className.includes("fn__none")) {
|
||||
avPanelElement.remove();
|
||||
} else {
|
||||
// 优先关闭资源文件搜索
|
||||
hideElements(["util"], options.protyle)
|
||||
}
|
||||
window.siyuan.menus.menu.remove();
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
|
|
@ -672,6 +679,35 @@ export const openMenuPanel = (options: {
|
|||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
break;
|
||||
} else if (type === "addAssetExist") {
|
||||
const rect = target.getBoundingClientRect()
|
||||
options.protyle.toolbar.showAssets(options.protyle, {x: rect.right, y: rect.bottom, w: target.parentElement.clientWidth + 8, h: rect.height}, (url) => {
|
||||
let value: IAVCellAssetValue;
|
||||
if (Constants.SIYUAN_ASSETS_IMAGE.includes(pathPosix().extname(url).toLowerCase())) {
|
||||
value = {
|
||||
type: "image",
|
||||
content: url,
|
||||
name: ""
|
||||
}
|
||||
} else {
|
||||
value = {
|
||||
type: "file",
|
||||
content: url,
|
||||
name: pathPosix().basename(url).substring(0, Constants.SIZE_LINK_TEXT_MAX)
|
||||
}
|
||||
}
|
||||
updateAssetCell({
|
||||
protyle: options.protyle,
|
||||
data,
|
||||
cellElements: options.cellElements,
|
||||
type: "addUpdate",
|
||||
addUpdateValue: [value]
|
||||
});
|
||||
hideElements(["util"], options.protyle);
|
||||
});
|
||||
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