Vanessa 2025-03-16 11:35:19 +08:00
parent 244d360ef0
commit ecb186c969
4 changed files with 42 additions and 19 deletions

View File

@ -71,7 +71,7 @@ ${contentHTML}
});
return `<div class="b3-menu__items">
${html}
<button data-type="addAssetExist" class="b3-menu__item">
<button data-type="addAssetExist" class="b3-menu__item b3-menu__item--current">
<svg class="b3-menu__icon"><use xlink:href="#iconImage"></use></svg>
<span class="b3-menu__label">${window.siyuan.languages.assets}</span>
</button>

View File

@ -202,21 +202,40 @@ export const avKeydown = (event: KeyboardEvent, nodeElement: HTMLElement, protyl
export const bindAVPanelKeydown = (event: KeyboardEvent) => {
const avPanelElement = document.querySelector(".av__panel");
if (avPanelElement && avPanelElement.querySelector('[data-type="goSearchRollupCol"]') &&
!avPanelElement.querySelector(".b3-text-field") &&
window.siyuan.menus.menu.element.classList.contains("fn__none")) {
const menuElement = avPanelElement.querySelector(".b3-menu__items")
if (event.key === "Enter") {
const currentElement = menuElement.querySelector(".b3-menu__item--current");
if (currentElement) {
avPanelElement.dispatchEvent(new CustomEvent("click", {detail: currentElement.getAttribute("data-type")}));
if (avPanelElement && window.siyuan.menus.menu.element.classList.contains("fn__none")) {
if ((avPanelElement.querySelector('[data-type="goSearchRollupCol"]') && !avPanelElement.querySelector(".b3-text-field")) ||
avPanelElement.querySelector('[data-type="addAssetExist"]')) {
const menuElement = avPanelElement.querySelector(".b3-menu__items")
if (event.key === "Enter") {
const currentElement = menuElement.querySelector(".b3-menu__item--current");
if (currentElement) {
const editElement = currentElement.querySelector('[data-type="editAssetItem"]')
const uploadElement = currentElement.querySelector(".b3-form__upload")
if (editElement) {
avPanelElement.dispatchEvent(new CustomEvent("click", {
detail: {
type: editElement.getAttribute("data-type"),
target: editElement
}
}));
} else if (uploadElement) {
uploadElement.dispatchEvent(new MouseEvent('click', {bubbles: true}));
} else {
avPanelElement.dispatchEvent(new CustomEvent("click", {
detail: {
type: currentElement.getAttribute("data-type"),
target: currentElement
}
}));
}
}
} else if (event.key === "Escape") {
avPanelElement.dispatchEvent(new CustomEvent("click", {detail: "close"}));
} else {
upDownHint(menuElement, event, "b3-menu__item--current", menuElement.firstElementChild)
}
} else if (event.key === "Escape") {
avPanelElement.dispatchEvent(new CustomEvent("click", {detail: "close"}));
} else {
upDownHint(menuElement, event, "b3-menu__item--current", menuElement.firstElementChild)
return true;
}
return true;
}
return false;
}

View File

@ -139,6 +139,7 @@ export const openMenuPanel = (options: {
cellElements: options.cellElements,
blockElement: options.blockElement
});
(avPanelElement.querySelector(".b3-menu__item") as HTMLButtonElement).focus();
setTimeout(() => {
setPosition(menuElement, cellRect.left, cellRect.bottom, cellRect.height);
}, Constants.TIMEOUT_LOAD); // 等待加载
@ -496,10 +497,13 @@ export const openMenuPanel = (options: {
});
avPanelElement.addEventListener("click", (event: MouseEvent) => {
let type: string;
let target = event.target as HTMLElement;
if (typeof event.detail === "string") {
type = event.detail;
} else if (typeof event.detail === "object") {
type = (event.detail as { type: string }).type;
target = (event.detail as { target: HTMLElement }).target;
}
let target = event.target as HTMLElement;
while (target && !target.isSameNode(avPanelElement) || type) {
type = target?.dataset.type || type;
if (type === "close") {
@ -970,7 +974,7 @@ export const openMenuPanel = (options: {
break;
} else if (type === "goSearchRollupCol") {
goSearchRollupCol({
target: avPanelElement.querySelector('[data-type="goSearchRollupCol"]'),
target,
data,
isRelation: true,
protyle: options.protyle,
@ -981,7 +985,7 @@ export const openMenuPanel = (options: {
break;
} else if (type === "goSearchRollupTarget") {
goSearchRollupCol({
target: avPanelElement.querySelector('[data-type="goSearchRollupTarget"]'),
target,
data,
isRelation: false,
protyle: options.protyle,
@ -991,7 +995,7 @@ export const openMenuPanel = (options: {
event.stopPropagation();
break;
} else if (type === "goSearchRollupCalc") {
openCalcMenu(options.protyle, avPanelElement.querySelector('[data-type="goSearchRollupTarget"]'), {
openCalcMenu(options.protyle, target, {
data,
colId: options.colId || menuElement.querySelector(".b3-menu__item").getAttribute("data-col-id"),
blockID

View File

@ -173,7 +173,7 @@ export const getRollupHTML = (options: { data?: IAV, cellElements?: HTMLElement[
}
});
}
return `<button class="b3-menu__item" data-type="goSearchRollupCol" data-old-value='${JSON.stringify(colData.rollup || {})}'>
return `<button class="b3-menu__item b3-menu__item--current" data-type="goSearchRollupCol" data-old-value='${JSON.stringify(colData.rollup || {})}'>
<span class="b3-menu__label">${window.siyuan.languages.relation}</span>
<span class="b3-menu__accelerator"></span>
<svg class="b3-menu__icon b3-menu__icon--small"><use xlink:href="#iconRight"></use></svg>