mirror of
https://github.com/siyuan-note/siyuan.git
synced 2026-02-13 18:54:21 +01:00
This commit is contained in:
parent
05cfcf7c2b
commit
64900706b2
13 changed files with 119 additions and 58 deletions
|
|
@ -84,6 +84,10 @@ ${contentHTML}
|
|||
}
|
||||
return `<div class="b3-menu__items">
|
||||
${html}
|
||||
<button data-type="addAssetExist" class="b3-menu__item">
|
||||
<svg class="b3-menu__icon"><use xlink:href="#iconImage"></use></svg>
|
||||
<span class="b3-menu__label">${window.siyuan.languages.assets}</span>
|
||||
</button>
|
||||
<button class="b3-menu__item">
|
||||
<svg class="b3-menu__icon"><use xlink:href="#iconDownload"></use></svg>
|
||||
<span class="b3-menu__label">${window.siyuan.languages.insertAsset}</span>
|
||||
|
|
@ -314,8 +318,8 @@ export const addAssetLink = (protyle: IProtyle, data: IAV, cellElements: HTMLEle
|
|||
const rect = target.getBoundingClientRect();
|
||||
menu.open({
|
||||
x: rect.right,
|
||||
y: rect.top,
|
||||
w: rect.width,
|
||||
y: rect.bottom,
|
||||
w: target.parentElement.clientWidth + 8,
|
||||
h: rect.height,
|
||||
});
|
||||
};
|
||||
|
|
|
|||
|
|
@ -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