From b1152cc919aa879c10ef176923d6dd5166bdcf17 Mon Sep 17 00:00:00 2001 From: Data Date: Sun, 22 Mar 2026 21:20:18 +0100 Subject: [PATCH] feat(editor): add @everyone mention support Adds ad4m://everyone as a protocol-level group mention: - Autocomplete shows 'everyone' option when typing @e... - Uses ad4m://everyone URI (protocol-level, not app-specific) - renderLabel correctly prefixes @ for ad4m:// URIs Companion to coasys/ad4m#769 Closes #571 --- packages/flux-editor/src/flux-editor.ts | 12 +++++++++--- packages/flux-editor/src/mention.ts | 2 +- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/packages/flux-editor/src/flux-editor.ts b/packages/flux-editor/src/flux-editor.ts index 51d530566..20bf779b0 100644 --- a/packages/flux-editor/src/flux-editor.ts +++ b/packages/flux-editor/src/flux-editor.ts @@ -300,10 +300,16 @@ export default class MyElement extends LitElement { } async getMentionSuggestions(query: string) { - const matches = this.members + // Protocol-level group mentions + const groupMentions: Suggestion[] = [ + { id: 'ad4m://everyone', label: 'everyone' }, + ].filter((m) => m.label.toLowerCase().startsWith(query.toLowerCase())); + + const memberMatches = this.members .filter((m) => this.getSafeString(m.username).toLowerCase().startsWith(query.toLowerCase())) - .map((m) => ({ id: m.did, label: m.username || 'anonymous' })) - .slice(0, 10) as Suggestion[]; + .map((m) => ({ id: m.did, label: m.username || 'anonymous' })); + + const matches = [...groupMentions, ...memberMatches].slice(0, 10) as Suggestion[]; this.suggestions = matches; return matches; diff --git a/packages/flux-editor/src/mention.ts b/packages/flux-editor/src/mention.ts index 0d9b06af8..7c69059ae 100644 --- a/packages/flux-editor/src/mention.ts +++ b/packages/flux-editor/src/mention.ts @@ -18,7 +18,7 @@ export default Node.create({ return { HTMLAttributes: {}, renderLabel({ node }) { - const isMention = node.attrs.id.startsWith('did:'); + const isMention = node.attrs.id.startsWith('did:') || node.attrs.id.startsWith('ad4m://'); return `${isMention ? '@' : '#'}${node.attrs.label ?? node.attrs.id}`; }, suggestion: {