Better mention support, fixed open thread.
This commit is contained in:
parent
21ce55f1cd
commit
3970bb5acd
3 changed files with 16 additions and 9 deletions
|
@ -32,6 +32,9 @@ th, td {
|
||||||
font-size: var(--fsNormal);
|
font-size: var(--fsNormal);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.bold {
|
||||||
|
font-weight: bold;
|
||||||
|
}
|
||||||
.row {
|
.row {
|
||||||
margin: 15px 0;
|
margin: 15px 0;
|
||||||
}
|
}
|
||||||
|
|
14
js/ui/fmt.js
14
js/ui/fmt.js
|
@ -32,8 +32,7 @@ function format_content(model, ev, show_media) {
|
||||||
}
|
}
|
||||||
const content = (ev.kind == KIND_DM ? ev.decrypted || ev.content : ev.content)
|
const content = (ev.kind == KIND_DM ? ev.decrypted || ev.content : ev.content)
|
||||||
.trim();
|
.trim();
|
||||||
const body = fmt_mentions(model, fmt_body(content, show_media),
|
const body = fmt_mentions(model, fmt_body(content, show_media), ev.tags);
|
||||||
event_get_tag_values(ev));
|
|
||||||
let cw = get_content_warning(ev.tags)
|
let cw = get_content_warning(ev.tags)
|
||||||
if (cw !== null) {
|
if (cw !== null) {
|
||||||
let cwHTML = "Content Warning"
|
let cwHTML = "Content Warning"
|
||||||
|
@ -78,16 +77,21 @@ function fmt_mentions(model, str, tags) {
|
||||||
}
|
}
|
||||||
if (x == "")
|
if (x == "")
|
||||||
continue;
|
continue;
|
||||||
// Specification says it's 0-based
|
let tag = tags[parseInt(x)];
|
||||||
let ref = tags[parseInt(x)];
|
if (!tag) {
|
||||||
if (!ref) {
|
|
||||||
buf += `#[${x}]`
|
buf += `#[${x}]`
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
let ref = tag[1];
|
||||||
|
if (tag[0] == 'e') {
|
||||||
|
buf += `<span class="clickable bold" action="open-thread"
|
||||||
|
data-thread-id="${ref}">note:${fmt_pubkey(ref)}</span>`;
|
||||||
|
} else if (tag[0] == 'p') {
|
||||||
let profile = model_get_profile(model, ref);
|
let profile = model_get_profile(model, ref);
|
||||||
buf += `<span class="username clickable" data-pubkey="${ref}">
|
buf += `<span class="username clickable" data-pubkey="${ref}">
|
||||||
${fmt_name(profile)}</span>`;
|
${fmt_name(profile)}</span>`;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return buf;
|
return buf;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -599,7 +599,7 @@ function onclick_any(ev) {
|
||||||
show_new();
|
show_new();
|
||||||
break;
|
break;
|
||||||
case "open-thread":
|
case "open-thread":
|
||||||
open_trhead(el.dataset.threadId);
|
open_thread(el.dataset.threadId);
|
||||||
break;
|
break;
|
||||||
case "reply":
|
case "reply":
|
||||||
send_reply(el.dataset.emoji, el.dataset.to);
|
send_reply(el.dataset.emoji, el.dataset.to);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue