mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-22 09:30:14 +01:00
✨ https://github.com/siyuan-note/siyuan/issues/8895 edit asset item
This commit is contained in:
parent
67574984d0
commit
e8c15eebb6
7 changed files with 192 additions and 37 deletions
|
|
@ -10,7 +10,8 @@ import {addSort, bindSortsEvent, getSortsHTML} from "./sort";
|
|||
import {bindDateEvent, getDateHTML, setDateValue} from "./date";
|
||||
import {formatNumber} from "./number";
|
||||
import {removeAttrViewColAnimation} from "./action";
|
||||
import {addAssetLink, bindAssetEvent, getAssetHTML} from "./asset";
|
||||
import {addAssetLink, bindAssetEvent, editAssetItem, getAssetHTML} from "./asset";
|
||||
import {Constants} from "../../../constants";
|
||||
|
||||
export const openMenuPanel = (options: {
|
||||
protyle: IProtyle,
|
||||
|
|
@ -60,18 +61,21 @@ export const openMenuPanel = (options: {
|
|||
const tabRect = options.blockElement.querySelector(".layout-tab-bar").getBoundingClientRect();
|
||||
if (["select", "date", "asset"].includes(options.type)) {
|
||||
const cellRect = options.cellElements[options.cellElements.length - 1].getBoundingClientRect();
|
||||
setPosition(menuElement, cellRect.left, cellRect.bottom, cellRect.height);
|
||||
if (options.type === "select") {
|
||||
bindSelectEvent(options.protyle, data, menuElement, options.cellElements);
|
||||
} else if (options.type === "date") {
|
||||
bindDateEvent({protyle: options.protyle, data, menuElement, cellElements: options.cellElements});
|
||||
} else if (options.type === "asset") {
|
||||
bindAssetEvent({protyle: options.protyle, data, menuElement, cellElements: options.cellElements});
|
||||
setTimeout(() => {
|
||||
setPosition(menuElement, cellRect.left, cellRect.bottom, cellRect.height);
|
||||
}, Constants.TIMEOUT_LOAD); // 等待图片加载
|
||||
}
|
||||
if (["select", "date"].includes(options.type)) {
|
||||
const inputElement = menuElement.querySelector("input");
|
||||
inputElement.select();
|
||||
inputElement.focus();
|
||||
setPosition(menuElement, cellRect.left, cellRect.bottom, cellRect.height);
|
||||
}
|
||||
} else {
|
||||
setPosition(menuElement, tabRect.right - menuElement.clientWidth, tabRect.bottom, tabRect.height);
|
||||
|
|
@ -639,6 +643,11 @@ export const openMenuPanel = (options: {
|
|||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
break;
|
||||
} else if (type === "editAssetItem") {
|
||||
editAssetItem(options.protyle, data, options.cellElements, target.parentElement)
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
break;
|
||||
} else if (type === "clearDate") {
|
||||
setDateValue({
|
||||
cellElements: options.cellElements,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue