feat(backend,frontend): search everywhere in buttons, links and message data, a jump from search or an alert lights up the found words and buttons
This commit is contained in:
1 parent
acfa726e61
commit
d660079c02
21 files changed
+840
-76
No files matched your search
@@ -8,14 +8,16 @@
|
||||
jumboEmojiCount,
|
||||
linkHref,
|
||||
} from "#lib/format/entities.js";
|
||||
import { markText } from "#lib/format/search.js";
|
||||
|
||||
interface Props {
|
||||
entities: EntityView[];
|
||||
marks?: string[];
|
||||
own?: boolean;
|
||||
text: string;
|
||||
}
|
||||
|
||||
let { text, entities, own = false }: Props = $props();
|
||||
let { text, entities, marks = [], own = false }: Props = $props();
|
||||
|
||||
const nodes = $derived(buildEntityTree(text, entities));
|
||||
const jumbo = $derived(entities.length === 0 ? jumboEmojiCount(text) : 0);
|
||||
@@ -32,13 +34,29 @@
|
||||
)}
|
||||
{#each items as node, i (i)}
|
||||
{#if node.kind === "text"}
|
||||
{node.text}
|
||||
{@render plain(node.text)}
|
||||
{:else}
|
||||
{@render entity(node)}
|
||||
{/if}
|
||||
{/each}
|
||||
{/snippet}
|
||||
|
||||
{#snippet plain(
|
||||
value: string
|
||||
)}
|
||||
{#if marks.length === 0}
|
||||
{value}
|
||||
{:else}
|
||||
{#each markText(value, marks) as segment, i (i)}
|
||||
{#if segment.hit}
|
||||
<mark class="found" class:own>{segment.text}</mark>
|
||||
{:else}
|
||||
{segment.text}
|
||||
{/if}
|
||||
{/each}
|
||||
{/if}
|
||||
{/snippet}
|
||||
|
||||
{#snippet entity(
|
||||
node: EntityNode
|
||||
)}
|
||||
@@ -186,6 +204,35 @@
|
||||
background-color: var(--color-primary-tint);
|
||||
}
|
||||
|
||||
.found {
|
||||
padding: 0;
|
||||
border-radius: 0.25rem;
|
||||
color: inherit;
|
||||
background-color: transparent;
|
||||
animation: found-flash 3s ease;
|
||||
|
||||
--found-color: color-mix(in srgb, var(--color-primary) 40%, transparent);
|
||||
|
||||
&.own {
|
||||
--found-color: color-mix(
|
||||
in srgb,
|
||||
var(--color-own-links) 35%,
|
||||
transparent
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@keyframes found-flash {
|
||||
0%,
|
||||
70% {
|
||||
background-color: var(--found-color);
|
||||
}
|
||||
|
||||
100% {
|
||||
background-color: transparent;
|
||||
}
|
||||
}
|
||||
|
||||
.spoiler {
|
||||
cursor: pointer;
|
||||
|
||||
|
||||
Reference in new issue
Block a user