mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-05-19 10:30:45 +08:00
This commit is contained in:
parent
152665335e
commit
ca0a9d4ba4
@ -76,6 +76,10 @@
|
|||||||
|
|
||||||
&--current {
|
&--current {
|
||||||
background-color: var(--b3-list-hover);
|
background-color: var(--b3-list-hover);
|
||||||
|
|
||||||
|
.b3-menu__action {
|
||||||
|
opacity: 1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
&--readonly {
|
&--readonly {
|
||||||
@ -95,6 +99,22 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
&__action {
|
||||||
|
opacity: 0;
|
||||||
|
color: var(--b3-theme-on-surface);
|
||||||
|
width: 8px;
|
||||||
|
height: 8px;
|
||||||
|
align-self: center;
|
||||||
|
margin-left: 8px;
|
||||||
|
padding: 4px;
|
||||||
|
border-radius: 8px;
|
||||||
|
|
||||||
|
&:hover {
|
||||||
|
color: var(--b3-theme-on-background);
|
||||||
|
background: var(--b3-theme-background-light);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
&__label {
|
&__label {
|
||||||
flex: 1;
|
flex: 1;
|
||||||
min-width: 84px;
|
min-width: 84px;
|
||||||
|
@ -28,6 +28,7 @@ import {saveScroll} from "../protyle/scroll/saveScroll";
|
|||||||
import {Asset} from "../asset";
|
import {Asset} from "../asset";
|
||||||
import {newFile} from "../util/newFile";
|
import {newFile} from "../util/newFile";
|
||||||
import {MenuItem} from "../menus/Menu";
|
import {MenuItem} from "../menus/Menu";
|
||||||
|
import {escapeHtml} from "../util/escape";
|
||||||
|
|
||||||
export class Wnd {
|
export class Wnd {
|
||||||
public id: string;
|
public id: string;
|
||||||
@ -463,11 +464,26 @@ export class Wnd {
|
|||||||
const iconElement = item.querySelector(".item__icon");
|
const iconElement = item.querySelector(".item__icon");
|
||||||
const graphicElement = item.querySelector(".item__graphic");
|
const graphicElement = item.querySelector(".item__graphic");
|
||||||
window.siyuan.menus.menu.append(new MenuItem({
|
window.siyuan.menus.menu.append(new MenuItem({
|
||||||
label: item.querySelector(".item__text").textContent,
|
label: escapeHtml(item.querySelector(".item__text").textContent),
|
||||||
|
action: "iconClose",
|
||||||
iconHTML: iconElement ? `<span class="b3-menu__icon">${iconElement.innerHTML}</span>` : "",
|
iconHTML: iconElement ? `<span class="b3-menu__icon">${iconElement.innerHTML}</span>` : "",
|
||||||
icon: graphicElement ? graphicElement.firstElementChild.getAttribute("xlink:href").substring(1) : "",
|
icon: graphicElement ? graphicElement.firstElementChild.getAttribute("xlink:href").substring(1) : "",
|
||||||
click: () => {
|
bind: (element) => {
|
||||||
|
element.addEventListener("click", (event) => {
|
||||||
|
if (hasClosestByTag(event.target as Element, "svg")) {
|
||||||
|
this.removeTab(item.getAttribute("data-id"));
|
||||||
|
if (element.previousElementSibling || element.nextElementSibling) {
|
||||||
|
element.remove();
|
||||||
|
} else {
|
||||||
|
window.siyuan.menus.menu.remove();
|
||||||
|
}
|
||||||
|
} else {
|
||||||
this.switchTab(item, true);
|
this.switchTab(item, true);
|
||||||
|
window.siyuan.menus.menu.remove();
|
||||||
|
}
|
||||||
|
event.preventDefault()
|
||||||
|
event.stopPropagation();
|
||||||
|
});
|
||||||
},
|
},
|
||||||
current: item.classList.contains("item--focus")
|
current: item.classList.contains("item--focus")
|
||||||
}).element);
|
}).element);
|
||||||
|
@ -136,6 +136,9 @@ export class MenuItem {
|
|||||||
if (options.accelerator) {
|
if (options.accelerator) {
|
||||||
html += `<span class="b3-menu__accelerator">${updateHotkeyTip(options.accelerator)}</span>`;
|
html += `<span class="b3-menu__accelerator">${updateHotkeyTip(options.accelerator)}</span>`;
|
||||||
}
|
}
|
||||||
|
if (options.action) {
|
||||||
|
html += `<svg class="b3-menu__action"><use xlink:href="#${options.action}"></use></svg>`;
|
||||||
|
}
|
||||||
if (options.id) {
|
if (options.id) {
|
||||||
this.element.setAttribute("data-id", options.id);
|
this.element.setAttribute("data-id", options.id);
|
||||||
}
|
}
|
||||||
|
1
app/src/types/index.d.ts
vendored
1
app/src/types/index.d.ts
vendored
@ -484,6 +484,7 @@ declare interface IMenu {
|
|||||||
click?: (element: HTMLElement) => void,
|
click?: (element: HTMLElement) => void,
|
||||||
type?: "separator" | "submenu" | "readonly",
|
type?: "separator" | "submenu" | "readonly",
|
||||||
accelerator?: string,
|
accelerator?: string,
|
||||||
|
action?: string,
|
||||||
id?: string,
|
id?: string,
|
||||||
submenu?: IMenu[]
|
submenu?: IMenu[]
|
||||||
disabled?: boolean
|
disabled?: boolean
|
||||||
|
Loading…
Reference in New Issue
Block a user