Skip to content

An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作

:art: fix https://github.com/siyuan-note/siyuan/issues/7448

Vanessa56ca4ed2e182
diff --git a/app/src/card/makeCard.ts b/app/src/card/makeCard.ts
index 14d89c6049..544020a017 100644
--- a/app/src/card/makeCard.ts
+++ b/app/src/card/makeCard.ts
@@ -9,14 +9,10 @@ import {viewCards} from "./viewCards";
import {Constants} from "../constants";
export const genCardItem = (item: ICardPackage) => {
- return `<li data-id="${item.id}" class="b3-list-item b3-list-item--narrow${isMobile() ? "" : " b3-list-item--hide-action"}">
-<span class="b3-list-item__text">${item.name}</span>
-<span class="counter b3-tooltips b3-tooltips__w${isMobile() ? "" : " fn__none"}" aria-label="${window.siyuan.languages.riffCard}">${item.size}</span>
-<span data-type="add" class="b3-list-item__action b3-tooltips b3-tooltips__w" aria-label="${window.siyuan.languages.addDeck}">
- <svg><use xlink:href="#iconAdd"></use></svg>
-</span>
-<span data-type="remove" class="b3-list-item__action b3-tooltips b3-tooltips__w" aria-label="${window.siyuan.languages.removeDeck}">
- <svg><use xlink:href="#iconMin"></use></svg>
+ return `<li data-id="${item.id}" data-name="${item.name}" class="b3-list-item b3-list-item--narrow${isMobile() ? "" : " b3-list-item--hide-action"}">
+<span class="b3-list-item__text">
+ <span>${item.name}</span>
+ <span class="b3-list-item__meta">${item.size}</span>
</span>
<span data-type="rename" class="b3-list-item__action b3-tooltips b3-tooltips__w" aria-label="${window.siyuan.languages.rename}">
<svg><use xlink:href="#iconEdit"></use></svg>
@@ -27,7 +23,12 @@ export const genCardItem = (item: ICardPackage) => {
<span data-type="view" class="b3-list-item__action b3-tooltips b3-tooltips__w" aria-label="${window.siyuan.languages.cardPreview}">
<svg><use xlink:href="#iconEye"></use></svg>
</span>
-<span class="b3-list-item__meta${isMobile() ? " fn__none" : ""}">${item.size}</span>
+<span data-type="remove" class="b3-list-item__action b3-tooltips b3-tooltips__w" aria-label="${window.siyuan.languages.removeDeck}">
+ <svg><use xlink:href="#iconMin"></use></svg>
+</span>
+<span data-type="add" style="display: block" class="b3-list-item__action b3-tooltips b3-tooltips__w" aria-label="${window.siyuan.languages.addDeck}">
+ <svg><use xlink:href="#iconAdd"></use></svg>
+</span>
<span class="b3-list-item__meta${isMobile() ? " fn__none" : ""}">${item.updated}</span>
</li>`;
};
@@ -116,7 +117,7 @@ export const makeCard = (nodeElement: Element[]) => {
event.preventDefault();
break;
} else if (type === "delete") {
- confirmDialog(window.siyuan.languages.confirm, `${window.siyuan.languages.confirmDelete} <b>${target.parentElement.querySelector(".b3-list-item__text").textContent}</b>?`, () => {
+ confirmDialog(window.siyuan.languages.confirm, `${window.siyuan.languages.confirmDelete} <b>${target.parentElement.getAttribute("data-name")}</b>?`, () => {
fetchPost("/api/riff/removeRiffDeck", {
deckID: target.parentElement.getAttribute("data-id"),
}, () => {
@@ -127,7 +128,7 @@ export const makeCard = (nodeElement: Element[]) => {
event.preventDefault();
break;
} else if (type === "view") {
- viewCards(target.parentElement.getAttribute("data-id"), target.parentElement.querySelector(".b3-list-item__text").textContent, (removeResponse) => {
+ viewCards(target.parentElement.getAttribute("data-id"), target.parentElement.getAttribute("data-name"), (removeResponse) => {
target.parentElement.outerHTML = genCardItem(removeResponse.data);
});
event.stopPropagation();
@@ -148,7 +149,7 @@ export const makeCard = (nodeElement: Element[]) => {
renameDialog.bindInput(inputElement, () => {
(btnsElement[1] as HTMLButtonElement).click();
});
- inputElement.value = target.parentElement.querySelector(".b3-list-item__text").textContent;
+ inputElement.value = target.parentElement.getAttribute("data-name");
inputElement.focus();
inputElement.select();
btnsElement[0].addEventListener("click", () => {
@@ -159,7 +160,8 @@ export const makeCard = (nodeElement: Element[]) => {
name: inputElement.value,
deckID: target.parentElement.getAttribute("data-id"),
}, () => {
- target.parentElement.querySelector(".b3-list-item__text").textContent = inputElement.value;
+ target.parentElement.querySelector(".b3-list-item__text span").textContent = inputElement.value;
+ target.parentElement.setAttribute("data-name", inputElement.value);
});
renameDialog.destroy();
});
diff --git a/app/src/card/viewCards.ts b/app/src/card/viewCards.ts
index 7eb8be4b40..b880490d97 100644
--- a/app/src/card/viewCards.ts
+++ b/app/src/card/viewCards.ts
@@ -129,14 +129,16 @@ export const viewCards = (deckID: string, title: string, cb:(response:IWebSocket
if (!nextElment && target.parentElement.parentElement.childElementCount > 1) {
nextElment = target.parentElement.parentElement.firstElementChild;
}
+
if (!nextElment) {
getArticle(edit, "");
+ listElement.innerHTML = `<div class="b3-list--empty">${window.siyuan.languages.emptyContent}</div>`
} else {
getArticle(edit, nextElment.getAttribute("data-id"));
listElement.querySelector(".b3-list-item--focus")?.classList.remove("b3-list-item--focus");
nextElment.classList.add("b3-list-item--focus");
+ target.parentElement.remove();
}
- target.parentElement.remove();
cb(removeResponse);
});
event.stopPropagation();