mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-22 09:30:14 +01:00
This commit is contained in:
parent
b5894597a7
commit
8af51b8592
2 changed files with 7 additions and 1 deletions
|
|
@ -1189,6 +1189,8 @@ export const openMenuPanel = (options: {
|
|||
event.stopPropagation();
|
||||
break;
|
||||
} else if (type === "addColOptionOrCell") {
|
||||
menuElement.querySelector(".b3-menu__item--current")?.classList.remove("b3-menu__item--current");
|
||||
target.classList.add("b3-menu__item--current");
|
||||
if (target.querySelector(".b3-menu__checked")) {
|
||||
removeCellOption(options.protyle, options.cellElements, menuElement.querySelector(`.b3-chips .b3-chip[data-content="${escapeAttr(target.dataset.name)}"]`), options.blockElement);
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -24,12 +24,13 @@ const filterSelectHTML = (key: string, options: {
|
|||
});
|
||||
}
|
||||
if (options) {
|
||||
const currentName = document.querySelector(".av__panel .b3-menu__item--current")?.getAttribute("data-name") || "";
|
||||
options.forEach(item => {
|
||||
if (!key ||
|
||||
(key.toLowerCase().indexOf(item.name.toLowerCase()) > -1 ||
|
||||
item.name.toLowerCase().indexOf(key.toLowerCase()) > -1)) {
|
||||
const airaLabel = item.desc ? `${escapeAriaLabel(item.name)}<div class='ft__on-surface'>${escapeAriaLabel(item.desc || "")}</div>` : "";
|
||||
html += `<button data-type="addColOptionOrCell" class="b3-menu__item" data-name="${escapeAttr(item.name)}" data-desc="${escapeAttr(item.desc || "")}" draggable="true" data-color="${item.color}">
|
||||
html += `<button data-type="addColOptionOrCell" class="b3-menu__item${currentName === item.name ? " b3-menu__item--current" : ""}" data-name="${escapeAttr(item.name)}" data-desc="${escapeAttr(item.desc || "")}" draggable="true" data-color="${item.color}">
|
||||
<svg class="b3-menu__icon fn__grab"><use xlink:href="#iconDrag"></use></svg>
|
||||
<div class="fn__flex-1 ariaLabel" data-position="parentW" aria-label="${airaLabel}">
|
||||
<span class="b3-chip" style="background-color:var(--b3-font-background${item.color});color:var(--b3-font-color${item.color})">
|
||||
|
|
@ -46,6 +47,7 @@ const filterSelectHTML = (key: string, options: {
|
|||
});
|
||||
}
|
||||
if (!hasMatch && key) {
|
||||
html = html.replace('class="b3-menu__item b3-menu__item--current"', 'class="b3-menu__item"');
|
||||
const colorIndex = (options?.length || 0) % 14 + 1;
|
||||
html = `<button data-type="addColOptionOrCell" class="b3-menu__item b3-menu__item--current" data-name="${key}" data-color="${colorIndex}">
|
||||
<svg class="b3-menu__icon"><use xlink:href="#iconAdd"></use></svg>
|
||||
|
|
@ -56,6 +58,8 @@ const filterSelectHTML = (key: string, options: {
|
|||
</div>
|
||||
<span class="b3-menu__accelerator">${window.siyuan.languages.enterKey}</span>
|
||||
</button>${html}`;
|
||||
} else if (html.indexOf("b3-menu__item--current") === -1) {
|
||||
html = html.replace('class="b3-menu__item"', 'class="b3-menu__item b3-menu__item--current"');
|
||||
}
|
||||
return html;
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue