Skip to content

feature request: (Android) Mention Span to handle actual mentions rather than plain text #6

@divyanshu-patil

Description

@divyanshu-patil

Feature Description

  • currently the Mention span just use Regex based parsing system
  • this just paint background color and does not validates if user exists or not
  • implement a metadata based span which checks for user existence and only apply styling if user exists

Motivation and Use Case

WhatsApp and slack based mentions

Implementation Ideas

  • use a js side command to pass metadata to native side
  • this contains userId, userName, label for user or firstName and possibly avatars (future implementation)
  • we pass the selection start, end with this metadata
  • apply this span replacing the selection with Mention span
  • in the onTextChanged() event we replaces the text with username back while deleting

example command syntax

completeMention({
  start: number,
  end: number,
  label: string, // name of user
  attributes: {
    userId: string,
    username: string
  }
})

for restoring username back

val username = span.getAttributes()["username"] ?: return

runAsATransaction {
  editable.replace(
    editable.getSpanStart(span),
    editable.getSpanEnd(span),
    "@$username"
  )
}

Additional Context

may change implementation later

Metadata

Metadata

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions