This commit is contained in:
Vanessa 2023-04-04 19:52:00 +08:00
parent cbddfb1962
commit e014d6e1f7

View File

@ -69,9 +69,13 @@ const switchDialogEvent = (event: MouseEvent, switchDialog: Dialog) => {
let target = event.target as HTMLElement; let target = event.target as HTMLElement;
while (!target.isSameNode(switchDialog.element)) { while (!target.isSameNode(switchDialog.element)) {
if (target.classList.contains("b3-list-item")) { if (target.classList.contains("b3-list-item")) {
const currentType = target.getAttribute("data-type") as TDockType; const currentType = target.getAttribute("data-type");
if (currentType) { if (currentType) {
getDockByType(currentType).toggleModel(currentType, true); if (currentType === "riffCard") {
openCard();
} else {
getDockByType(currentType as TDockType).toggleModel(currentType as TDockType, true);
}
} else { } else {
const currentId = target.getAttribute("data-id"); const currentId = target.getAttribute("data-id");
getAllTabs().find(item => { getAllTabs().find(item => {
@ -358,9 +362,13 @@ export const globalShortcut = () => {
currentLiElement.removeAttribute("data-original"); currentLiElement.removeAttribute("data-original");
currentLiElement = switchDialog.element.querySelector(".b3-list-item--focus"); currentLiElement = switchDialog.element.querySelector(".b3-list-item--focus");
} }
const currentType = currentLiElement.getAttribute("data-type") as TDockType; const currentType = currentLiElement.getAttribute("data-type");
if (currentType) { if (currentType) {
getDockByType(currentType).toggleModel(currentType, true); if (currentType === "riffCard") {
openCard()
} else {
getDockByType(currentType as TDockType).toggleModel(currentType as TDockType, true);
}
if (document.activeElement) { if (document.activeElement) {
(document.activeElement as HTMLElement).blur(); (document.activeElement as HTMLElement).blur();
} }
@ -465,9 +473,14 @@ export const globalShortcut = () => {
} }
let dockHtml = ""; let dockHtml = "";
if (!isTabWindow) { if (!isTabWindow) {
dockHtml = '<ul class="b3-list b3-list--background" style="max-height: calc(70vh - 35px);overflow: auto">'; dockHtml = `<ul class="b3-list b3-list--background" style="max-height: calc(70vh - 35px);overflow: auto">
<li data-type="riffCard" data-index="0" class="b3-list-item${!tabHtml ? " b3-list-item--focus" : ""}">
<svg class="b3-list-item__graphic"><use xlink:href="#iconRiffCard"></use></svg>
<span class="b3-list-item__text">${window.siyuan.languages.riffCard}</span>
<span class="b3-list-item__meta">${updateHotkeyTip(window.siyuan.config.keymap.general.riffCard.custom)}</span>
</li>`;
getAllDocks().forEach((item, index) => { getAllDocks().forEach((item, index) => {
dockHtml += `<li data-type="${item.type}" data-index="${index}" class="b3-list-item${(!tabHtml && !dockHtml) ? " b3-list-item--focus" : ""}"> dockHtml += `<li data-type="${item.type}" data-index="${index + 1}" class="b3-list-item">
<svg class="b3-list-item__graphic"><use xlink:href="#${item.icon}"></use></svg> <svg class="b3-list-item__graphic"><use xlink:href="#${item.icon}"></use></svg>
<span class="b3-list-item__text">${window.siyuan.languages[item.hotkeyLangId]}</span> <span class="b3-list-item__text">${window.siyuan.languages[item.hotkeyLangId]}</span>
<span class="b3-list-item__meta">${updateHotkeyTip(window.siyuan.config.keymap.general[item.hotkeyLangId].custom)}</span> <span class="b3-list-item__meta">${updateHotkeyTip(window.siyuan.config.keymap.general[item.hotkeyLangId].custom)}</span>
@ -915,9 +928,13 @@ const dialogArrow = (element: HTMLElement, event: KeyboardEvent) => {
(sideElement.querySelector(`[data-index="${currentLiElement.getAttribute("data-index")}"]`) || sideElement.lastElementChild).classList.add("b3-list-item--focus"); (sideElement.querySelector(`[data-index="${currentLiElement.getAttribute("data-index")}"]`) || sideElement.lastElementChild).classList.add("b3-list-item--focus");
} }
} else if (event.key === "Enter") { } else if (event.key === "Enter") {
const currentType = currentLiElement.getAttribute("data-type") as TDockType; const currentType = currentLiElement.getAttribute("data-type");
if (currentType) { if (currentType) {
getDockByType(currentType).toggleModel(currentType, true); if (currentType === "riffCard") {
openCard()
} else {
getDockByType(currentType as TDockType).toggleModel(currentType as TDockType, true);
}
} else { } else {
openFileById({ openFileById({
id: currentLiElement.getAttribute("data-node-id"), id: currentLiElement.getAttribute("data-node-id"),
@ -963,9 +980,14 @@ ${unicode2Emoji(item.icon || Constants.SIYUAN_IMAGE_FILE, false, "b3-list-item__
}); });
let dockHtml = ""; let dockHtml = "";
if (!isWindow()) { if (!isWindow()) {
dockHtml = '<ul class="b3-list b3-list--background" style="max-height: calc(70vh - 35px);overflow: auto">'; dockHtml = `<ul class="b3-list b3-list--background" style="max-height: calc(70vh - 35px);overflow: auto">
<li data-type="riffCard" data-index="0" class="b3-list-item${!tabHtml ? " b3-list-item--focus" : ""}">
<svg class="b3-list-item__graphic"><use xlink:href="#iconRiffCard"></use></svg>
<span class="b3-list-item__text">${window.siyuan.languages.riffCard}</span>
<span class="b3-list-item__meta">${updateHotkeyTip(window.siyuan.config.keymap.general.riffCard.custom)}</span>
</li>`;
getAllDocks().forEach((item, index) => { getAllDocks().forEach((item, index) => {
dockHtml += `<li data-type="${item.type}" data-index="${index}" class="b3-list-item${(!tabHtml && !dockHtml) ? " b3-list-item--focus" : ""}"> dockHtml += `<li data-type="${item.type}" data-index="${index + 1}" class="b3-list-item">
<svg class="b3-list-item__graphic"><use xlink:href="#${item.icon}"></use></svg> <svg class="b3-list-item__graphic"><use xlink:href="#${item.icon}"></use></svg>
<span class="b3-list-item__text">${window.siyuan.languages[item.hotkeyLangId]}</span> <span class="b3-list-item__text">${window.siyuan.languages[item.hotkeyLangId]}</span>
<span class="b3-list-item__meta">${updateHotkeyTip(window.siyuan.config.keymap.general[item.hotkeyLangId].custom)}</span> <span class="b3-list-item__meta">${updateHotkeyTip(window.siyuan.config.keymap.general[item.hotkeyLangId].custom)}</span>