React-TagEditor
A tag editor coded in ES6, with React.js as its dependency. Inspired by StackOverflow's tag editor.
Features
- Basic editing/removing
- Navigating through tags via
left/right
on keyboard - Tag can be modified after being created
- Tag can be split at the cursor point.
Demo
Install
bower:
bower install react-tageditor --save
npm:
npm install react-tageditor --save
API
Attributes
All attributes are optional.
tags
: An array of tags.delimiters
: An array of delimiters for splitting tags. Element in array could be string or number(keyCode).placeholder
validation(currentTag, allTags)
: A function for validating. Throw an error when tag/tags do not meet your requirement. Error will be passed toonError
.onChange(tagsChanged, allTags, action)
: Callback triggered after tags added or removed.action
will beadd
orremove
.onError(error)
: Callback triggered on error. Access more information about the error viaerror.name
&error.message
.
Methods
add(tagText)
remove(tagText)
output()
: returns an array of tag text
Styling
;;;; ;; ; ;;
Development
-
gem install sass
-
npm install
This will installreact
,webpack
,babel-loader
and other dependencies. -
bower install
This will installreact
,neutron
for building examples. -
npm run build
Compile ourjs/scss
files todist/
License
MIT.