aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/features/messages.js34
-rw-r--r--src/style.css5
2 files changed, 36 insertions, 3 deletions
diff --git a/src/features/messages.js b/src/features/messages.js
index 2351e2b..952350f 100644
--- a/src/features/messages.js
+++ b/src/features/messages.js
@@ -12946,6 +12946,36 @@ export function messagesFeature(ctx) {
// context: a reply shows the post it answers above itself (the
// Conversations feed, a profile's Replies tab) — a quote card, which opens
// that post; the reply's own tap opens the thread at the reply.
+ // A really long note (ZeroHedge's run to dozens of lines) shows its first
+ // ten lines in a feed, fading out, with Show more under it; its thread, and
+ // a tap on Show more, give the whole thing. "Could you collapse REALLY long
+ // notes, with a 'more...' link to expand" (npub1muckyme, 2026-11-30).
+ // Long = more than 16 lines at this screen's width, by estimate, so a
+ // collapsed note always hides a good part of itself, never a line or two.
+ const NOTE_CLAMP_OVER = 16;
+ const noteExpanded = new Set();
+ function noteLines(text) {
+ const w = Math.min((typeof window !== 'undefined' && window.innerWidth) || 400, 680);
+ const perLine = Math.max(24, Math.floor((w - 90) / 9.5)); // 18px text
+ let n = 0;
+ for (const para of String(text || '').split('\n')) n += Math.max(1, Math.ceil(para.length / perLine));
+ return n;
+ }
+ function noteTextBlock(ev, open, focus) {
+ const clampable = open && !focus;
+ const text = ev.kind === ARTICLE ? '' : momentStripped(ev, shownTranslation(ev)?.text ?? noteText(ev));
+ const clamp = clampable && ev.kind !== ARTICLE && !noteExpanded.has(ev.id) && noteLines(text) > NOTE_CLAMP_OVER;
+ const body = h('div', { class: 'note-text' + (clamp ? ' note-clamped' : ''), style: 'white-space:pre-wrap;overflow-wrap:anywhere' },
+ momentLink(ev),
+ ...(ev.kind === ARTICLE ? (open ? [articleCard(ev)] : articleBody(ev)) : noteBody(text, 0, noteEmojiTags(ev))));
+ if (!clamp) return body;
+ return h('div', { class: 'note-clamp-wrap' }, body,
+ h('button', {
+ class: 'note-more', type: 'button',
+ onClick: (e) => { e.stopPropagation(); noteExpanded.add(ev.id); render(); },
+ }, t('showMore')));
+ }
+
function noteRow(pk, ev, name, { open = true, focus = false, joined = false, context = false } = {}) {
if (ev.kind === REPOST) {
const inner = repostInner(ev);
@@ -13052,9 +13082,7 @@ export function messagesFeature(ctx) {
zapText(ev) ? h('div', {}, ...noteBody(zapText(ev))) : null)
: foreign
? h('div', { class: 'note-text small muted', style: 'white-space:pre-wrap;overflow-wrap:anywhere' }, (ev.kind === 64 ? '\u265f ' : '') + altText)
- : h('div', { class: 'note-text', style: 'white-space:pre-wrap;overflow-wrap:anywhere' },
- momentLink(ev),
- ...(ev.kind === ARTICLE ? (open ? [articleCard(ev)] : articleBody(ev)) : noteBody(momentStripped(ev, shownTranslation(ev)?.text ?? noteText(ev)), 0, noteEmojiTags(ev)))),
+ : noteTextBlock(ev, open, focus),
foreign || pending ? null : translateLine(ev),
ev.kind === POLL ? pollBox(ev) : null,
pending ? null : noteActions(pk, ev, { canZap }),
diff --git a/src/style.css b/src/style.css
index 311cfbb..4a86697 100644
--- a/src/style.css
+++ b/src/style.css
@@ -755,6 +755,11 @@ html:has(#app .chat-card), body:has(#app .chat-card) { overflow: hidden; }
.note-content > * { grid-column: 1 / -1; min-width: 0; }
.note-content > .note-header { grid-column: 2; grid-row: 1; }
.note-content > .note-text { font-size: 18px; line-height: 1.5; }
+/* a really long note in a feed: ten lines, fading out, then Show more */
+.note-content > .note-clamp-wrap > .note-text { font-size: 18px; line-height: 1.5; }
+.note-text.note-clamped { max-height: 15em; overflow: hidden;
+ -webkit-mask-image: linear-gradient(to bottom, #000 72%, transparent); mask-image: linear-gradient(to bottom, #000 72%, transparent); }
+.note-more { background: none; border: 0; padding: 4px 0 2px; color: var(--accent, #f7931a); font: inherit; font-size: 15px; font-weight: 600; cursor: pointer; }
.note-acts { margin-top: 8px; gap: 4px; width: 100%; }
.note-acts > .note-act { flex: 1 1 0; min-width: 0; justify-content: center; padding-inline: 2px; }
/* server comparison table (Settings → Advanced → Ark server) */