New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details
Socket
Book a DemoSign in
Socket

ld-mention

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ld-mention

Last Draft mention plugin

latest
Source
npmnpm
Version
2.1.0
Version published
Maintainers
1
Created
Source

ld-mention

Mention plugin for last-draft

npm version

Install

npm install ld-mention --save

Use

import {Editor} from 'last-draft'
import mention from 'ld-mention'
let plugins = [mention]

const mentionUsers = [
  {
    name: 'Steven Iseki',
    link: 'https://github.com/steveniseki',
    avatar: 'https://avatars1.githubusercontent.com/u/6695114?v=3&s=400',
  },
  {
    name: 'Nik Graf',
    link: 'https://github.com/nikgraf',
    avatar: 'https://avatars2.githubusercontent.com/u/223045?v=3&s=400',
  }
]

export default class ExampleEditor extends Component {
  constructor(props) {
    super(props)
    const INITIAL_STATE = editorStateFromHtml('<div></div>')
    this.state = { value: INITIAL_STATE }
  }

  onChange(editorState) {
    this.setState({ value: editorState })
  }

  render() {
    return (
      <Editor
        inline={['bold', 'italic', 'code', 'dropcap']}
        blocks={['h2', 'quote']}
        plugins={plugins}
        mentionUsers={mentionUsers}
        editorState={this.state.value}
        onChange={::this.onChange} />
    )
  }
}

You can pass your mention users to mentionUsers in the Editor, or pass to mentionUsersAsync a function that returns the list users for mentions functionality on change of the searchValue.

const mentionUsersAsync = function (searchValue, cb) {
  return new Promise(
    (resolve, reject) => {
      let url = `https://api.github.com/search/users?q=${searchValue}`
      fetch(url)
      .then( (response) => { return response.json() })
      .then((data) => {
        let users = data.items.map( (u, i) => { return { name: u.login, link: u.html_url, avatar: u.avatar_url } })
        resolve({ mentionUsers: users })
      })
    }
  )
}

Styles

Last Draft plugins use styled-components 💅 for the base styling.

Custom Styles with CSS

You can also add custom css to override the base styling with the following class names specified below:

.ld-mention-wrapper {}
.ld-mention {}
.ld-mention-list {}
.ld-mention-autocomplete {}
.ld-mention-menu {}
.ld-mention-menu-list {}
.ld-mention-item {}
.ld-mention-avatar {}
.ld-mention-name {}

Keywords

ld

FAQs

Package last updated on 19 Jun 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts