feat(hub): enlarge archive quotes panel and show full text on expand
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -480,6 +480,22 @@
|
||||
return s.length > 36 ? s.slice(0, 36) + "…" : s;
|
||||
}
|
||||
|
||||
function quoteEditRows(text) {
|
||||
const t = String(text || "");
|
||||
const lines = t.split(/\n/).length;
|
||||
const wrapLines = Math.ceil(t.length / 26);
|
||||
return Math.min(32, Math.max(8, lines, wrapLines));
|
||||
}
|
||||
|
||||
function resizeQuoteTextarea(ta) {
|
||||
if (!ta) return;
|
||||
ta.style.height = "auto";
|
||||
const lines = String(ta.value || "").split("\n").length;
|
||||
const wrapLines = Math.ceil(String(ta.value || "").length / 26);
|
||||
ta.rows = Math.min(32, Math.max(8, lines, wrapLines));
|
||||
ta.style.height = Math.max(ta.scrollHeight, 160) + "px";
|
||||
}
|
||||
|
||||
function renderQuotes() {
|
||||
if (!elQuotesList) return;
|
||||
if (elQuotesCount) {
|
||||
@@ -500,11 +516,17 @@
|
||||
'<span class="archive-quote-preview">' +
|
||||
esc(quotePreview(q.content)) +
|
||||
"</span>" +
|
||||
'<span class="archive-quote-open-hint">查看</span>' +
|
||||
"</summary>" +
|
||||
'<div class="archive-quote-body">' +
|
||||
'<div class="archive-quote-full">' +
|
||||
esc(q.content || "(空)") +
|
||||
"</div>" +
|
||||
'<textarea class="archive-quote-edit" data-id="' +
|
||||
q.id +
|
||||
'" rows="4">' +
|
||||
'" rows="' +
|
||||
quoteEditRows(q.content) +
|
||||
'">' +
|
||||
esc(q.content) +
|
||||
"</textarea>" +
|
||||
'<div class="archive-quote-actions">' +
|
||||
@@ -519,6 +541,12 @@
|
||||
})
|
||||
.join("");
|
||||
|
||||
elQuotesList.querySelectorAll(".archive-quote-card").forEach(function (card) {
|
||||
card.addEventListener("toggle", function () {
|
||||
if (!card.open) return;
|
||||
resizeQuoteTextarea(card.querySelector(".archive-quote-edit"));
|
||||
});
|
||||
});
|
||||
elQuotesList.querySelectorAll(".archive-quote-save").forEach(function (btn) {
|
||||
btn.addEventListener("click", function () {
|
||||
const id = btn.getAttribute("data-id");
|
||||
|
||||
Reference in New Issue
Block a user