mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-22 09:30:14 +01:00
This commit is contained in:
parent
9c28056204
commit
ad39590205
7 changed files with 105 additions and 61 deletions
|
|
@ -50,6 +50,7 @@ export const openMenuPanel = (options: {
|
|||
id: avID,
|
||||
pageSize: parseInt(options.blockElement.getAttribute("data-page-size")) || undefined,
|
||||
}, (response) => {
|
||||
const isCustomAttr = !options.blockElement.classList.contains("av");
|
||||
const data = response.data as IAV;
|
||||
let html;
|
||||
if (options.type === "config") {
|
||||
|
|
@ -67,7 +68,7 @@ export const openMenuPanel = (options: {
|
|||
} else if (options.type === "asset") {
|
||||
html = getAssetHTML(options.cellElements);
|
||||
} else if (options.type === "edit") {
|
||||
html = getEditHTML({protyle: options.protyle, data, colId: options.colId});
|
||||
html = getEditHTML({protyle: options.protyle, data, colId: options.colId, isCustomAttr});
|
||||
} else if (options.type === "date") {
|
||||
html = getDateHTML(data.view, options.cellElements);
|
||||
} else if (options.type === "rollup") {
|
||||
|
|
@ -75,14 +76,12 @@ export const openMenuPanel = (options: {
|
|||
} else if (options.type === "relation") {
|
||||
html = getRelationHTML(data, options.cellElements);
|
||||
if (!html) {
|
||||
if (options.blockElement.classList.contains("av")) {
|
||||
openMenuPanel({
|
||||
protyle: options.protyle,
|
||||
blockElement: options.blockElement,
|
||||
type: "edit",
|
||||
colId: options.cellElements[0].dataset.colId
|
||||
});
|
||||
}
|
||||
openMenuPanel({
|
||||
protyle: options.protyle,
|
||||
blockElement: options.blockElement,
|
||||
type: "edit",
|
||||
colId: options.cellElements[0].dataset.colId
|
||||
});
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
|
@ -93,7 +92,7 @@ export const openMenuPanel = (options: {
|
|||
</div>`);
|
||||
avPanelElement = document.querySelector(".av__panel");
|
||||
const menuElement = avPanelElement.lastElementChild as HTMLElement;
|
||||
const tabRect = options.blockElement.querySelector(".av__views")?.getBoundingClientRect();
|
||||
const tabRect = options.blockElement.querySelector(`.av__views, .av__row[data-col-id="${options.colId}"] > .block__logo`)?.getBoundingClientRect();
|
||||
if (["select", "date", "asset", "relation", "rollup"].includes(options.type)) {
|
||||
const cellRect = options.cellElements[options.cellElements.length - 1].getBoundingClientRect();
|
||||
if (options.type === "select") {
|
||||
|
|
@ -135,7 +134,7 @@ export const openMenuPanel = (options: {
|
|||
if (options.type === "sorts") {
|
||||
bindSortsEvent(options.protyle, menuElement, data);
|
||||
} else if (options.type === "edit") {
|
||||
bindEditEvent({protyle: options.protyle, data, menuElement});
|
||||
bindEditEvent({protyle: options.protyle, data, menuElement, isCustomAttr});
|
||||
} else if (options.type === "config") {
|
||||
bindViewEvent({protyle: options.protyle, data, menuElement});
|
||||
}
|
||||
|
|
@ -322,9 +321,10 @@ export const openMenuPanel = (options: {
|
|||
menuElement.innerHTML = getEditHTML({
|
||||
protyle: options.protyle,
|
||||
data,
|
||||
colId
|
||||
colId,
|
||||
isCustomAttr
|
||||
});
|
||||
bindEditEvent({protyle: options.protyle, data, menuElement});
|
||||
bindEditEvent({protyle: options.protyle, data, menuElement, isCustomAttr});
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
|
@ -678,7 +678,12 @@ export const openMenuPanel = (options: {
|
|||
data: target.dataset.icon,
|
||||
}]);
|
||||
target.innerHTML = unicode ? unicode2Emoji(unicode) : `<svg><use xlink:href="#${getColIconByType(target.dataset.colType as TAVCol)}"></use></svg>`;
|
||||
updateAttrViewCellAnimation(options.blockElement.querySelector(`.av__row--header .av__cell[data-col-id="${colId}"]`), undefined, {icon: unicode});
|
||||
if (isCustomAttr) {
|
||||
const iconElement = options.blockElement.querySelector(`.av__row[data-col-id="${colId}"] .block__logoicon`)
|
||||
iconElement.outerHTML = unicode ? unicode2Emoji(unicode, "block__logoicon", true) : `<svg class="block__logoicon"><use xlink:href="#${getColIconByType(iconElement.nextElementSibling.getAttribute("data-type") as TAVCol)}"></use></svg>`;
|
||||
} else {
|
||||
updateAttrViewCellAnimation(options.blockElement.querySelector(`.av__row--header .av__cell[data-col-id="${colId}"]`), undefined, {icon: unicode});
|
||||
}
|
||||
target.dataset.icon = unicode;
|
||||
});
|
||||
event.preventDefault();
|
||||
|
|
@ -744,9 +749,10 @@ export const openMenuPanel = (options: {
|
|||
menuElement.innerHTML = getEditHTML({
|
||||
protyle: options.protyle,
|
||||
data,
|
||||
colId: target.parentElement.dataset.id
|
||||
colId: target.parentElement.dataset.id,
|
||||
isCustomAttr
|
||||
});
|
||||
bindEditEvent({protyle: options.protyle, data, menuElement});
|
||||
bindEditEvent({protyle: options.protyle, data, menuElement, isCustomAttr});
|
||||
setPosition(menuElement, tabRect.right - menuElement.clientWidth, tabRect.bottom, tabRect.height);
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
|
|
@ -854,9 +860,10 @@ export const openMenuPanel = (options: {
|
|||
menuElement.innerHTML = getEditHTML({
|
||||
protyle: options.protyle,
|
||||
data,
|
||||
colId
|
||||
colId,
|
||||
isCustomAttr
|
||||
});
|
||||
bindEditEvent({protyle: options.protyle, data, menuElement});
|
||||
bindEditEvent({protyle: options.protyle, data, menuElement, isCustomAttr});
|
||||
} else {
|
||||
menuElement.innerHTML = getPropertiesHTML(data.view);
|
||||
}
|
||||
|
|
@ -883,9 +890,10 @@ export const openMenuPanel = (options: {
|
|||
menuElement.innerHTML = getEditHTML({
|
||||
protyle: options.protyle,
|
||||
data,
|
||||
colId
|
||||
colId,
|
||||
isCustomAttr
|
||||
});
|
||||
bindEditEvent({protyle: options.protyle, data, menuElement});
|
||||
bindEditEvent({protyle: options.protyle, data, menuElement, isCustomAttr});
|
||||
} else {
|
||||
menuElement.innerHTML = getPropertiesHTML(data.view);
|
||||
}
|
||||
|
|
@ -935,7 +943,7 @@ export const openMenuPanel = (options: {
|
|||
event.stopPropagation();
|
||||
break;
|
||||
} else if (type === "setColOption") {
|
||||
setColOption(options.protyle, data, target, options.blockElement, options.cellElements);
|
||||
setColOption(options.protyle, data, target, options.blockElement, isCustomAttr, options.cellElements);
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
break;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue