mirror of
https://github.com/siyuan-note/siyuan.git
synced 2026-02-20 14:04:06 +01:00
This commit is contained in:
parent
45302d5a28
commit
56ca4ed2e1
2 changed files with 18 additions and 14 deletions
|
|
@ -9,14 +9,10 @@ import {viewCards} from "./viewCards";
|
||||||
import {Constants} from "../constants";
|
import {Constants} from "../constants";
|
||||||
|
|
||||||
export const genCardItem = (item: ICardPackage) => {
|
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"}">
|
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">${item.name}</span>
|
<span class="b3-list-item__text">
|
||||||
<span class="counter b3-tooltips b3-tooltips__w${isMobile() ? "" : " fn__none"}" aria-label="${window.siyuan.languages.riffCard}">${item.size}</span>
|
<span>${item.name}</span>
|
||||||
<span data-type="add" class="b3-list-item__action b3-tooltips b3-tooltips__w" aria-label="${window.siyuan.languages.addDeck}">
|
<span class="b3-list-item__meta">${item.size}</span>
|
||||||
<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>
|
|
||||||
</span>
|
</span>
|
||||||
<span data-type="rename" class="b3-list-item__action b3-tooltips b3-tooltips__w" aria-label="${window.siyuan.languages.rename}">
|
<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>
|
<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}">
|
<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>
|
<svg><use xlink:href="#iconEye"></use></svg>
|
||||||
</span>
|
</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>
|
<span class="b3-list-item__meta${isMobile() ? " fn__none" : ""}">${item.updated}</span>
|
||||||
</li>`;
|
</li>`;
|
||||||
};
|
};
|
||||||
|
|
@ -116,7 +117,7 @@ export const makeCard = (nodeElement: Element[]) => {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
break;
|
break;
|
||||||
} else if (type === "delete") {
|
} 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", {
|
fetchPost("/api/riff/removeRiffDeck", {
|
||||||
deckID: target.parentElement.getAttribute("data-id"),
|
deckID: target.parentElement.getAttribute("data-id"),
|
||||||
}, () => {
|
}, () => {
|
||||||
|
|
@ -127,7 +128,7 @@ export const makeCard = (nodeElement: Element[]) => {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
break;
|
break;
|
||||||
} else if (type === "view") {
|
} 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);
|
target.parentElement.outerHTML = genCardItem(removeResponse.data);
|
||||||
});
|
});
|
||||||
event.stopPropagation();
|
event.stopPropagation();
|
||||||
|
|
@ -148,7 +149,7 @@ export const makeCard = (nodeElement: Element[]) => {
|
||||||
renameDialog.bindInput(inputElement, () => {
|
renameDialog.bindInput(inputElement, () => {
|
||||||
(btnsElement[1] as HTMLButtonElement).click();
|
(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.focus();
|
||||||
inputElement.select();
|
inputElement.select();
|
||||||
btnsElement[0].addEventListener("click", () => {
|
btnsElement[0].addEventListener("click", () => {
|
||||||
|
|
@ -159,7 +160,8 @@ export const makeCard = (nodeElement: Element[]) => {
|
||||||
name: inputElement.value,
|
name: inputElement.value,
|
||||||
deckID: target.parentElement.getAttribute("data-id"),
|
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();
|
renameDialog.destroy();
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -129,14 +129,16 @@ export const viewCards = (deckID: string, title: string, cb:(response:IWebSocket
|
||||||
if (!nextElment && target.parentElement.parentElement.childElementCount > 1) {
|
if (!nextElment && target.parentElement.parentElement.childElementCount > 1) {
|
||||||
nextElment = target.parentElement.parentElement.firstElementChild;
|
nextElment = target.parentElement.parentElement.firstElementChild;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!nextElment) {
|
if (!nextElment) {
|
||||||
getArticle(edit, "");
|
getArticle(edit, "");
|
||||||
|
listElement.innerHTML = `<div class="b3-list--empty">${window.siyuan.languages.emptyContent}</div>`
|
||||||
} else {
|
} else {
|
||||||
getArticle(edit, nextElment.getAttribute("data-id"));
|
getArticle(edit, nextElment.getAttribute("data-id"));
|
||||||
listElement.querySelector(".b3-list-item--focus")?.classList.remove("b3-list-item--focus");
|
listElement.querySelector(".b3-list-item--focus")?.classList.remove("b3-list-item--focus");
|
||||||
nextElment.classList.add("b3-list-item--focus");
|
nextElment.classList.add("b3-list-item--focus");
|
||||||
|
target.parentElement.remove();
|
||||||
}
|
}
|
||||||
target.parentElement.remove();
|
|
||||||
cb(removeResponse);
|
cb(removeResponse);
|
||||||
});
|
});
|
||||||
event.stopPropagation();
|
event.stopPropagation();
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue