Skip to content

Format rich content using #hashtags and @mentions

Notifications You must be signed in to change notification settings

BurntCaramel/lofi-js

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Lofi · JavaScript

Installation

npm install lofi --save

API Docs

parseElement(input: String)

Element:

  • texts: [ String ] · Array of plain text input
  • mentions: [ [ String ] ] · Array of key paths
  • tags: { String: Boolean | { texts: [ String ] , mentions: [ [ String ] ] } } · Key-value pairs of booleans or strings
  • children: [ Element ] · Array of children elements
parseElement('Click me #button #primary')
/* => {
  texts: ['Click me'],
  mentions: [null],
  tags: { button: true, primary: true },
  children: []
} */

parseElement('Hello @first-name, how are you?')
/* => {
  texts: ['Hello ', ', how are you?'],
  mentions: [['first-name'], null],
  tags: {},
  children: []
} */

Demos

Releases

No releases published

Packages

No packages published