slate-politico-editor
A Slate.js-based editor we use at POLITICO when we want to create some filthy rich ¢ontent.
Integrates with our oembed and S3 image upload services.
Demo.
Using
The library is packaged as an ES module. To use it:
- Install the library.
$ yarn add slate-politico-editor
- Styles are imported in the module, so be sure your Webpack config includes a CSS loader.
test: /\.s?css$/ use: 'style-loader' 'css-loader' 'sass-loader'
-
Include babel-polyfill in your build process.
-
Add Font Awesome on the page. (Icons on the editor are added by class.)
-
Import and use the component.
;; ; ; const initialValue = document: nodes: object: 'block' type: 'paragraph' nodes: object: 'text' leaves: text: 'Your text.' ; const value = Value; Component { superprops; thisstate = value ; } { return <Editor value=thisstatevalue // Must be a Slate Value onChange= this oembedAPI='https://staging.politicoapps.com/api/services/oembed/' imageAPI='https://staging.politicoapps.com/api/services/s3imageservice/' authorization='Token YOUR_TOKEN' /> ; } ReactDOM;
Developing
- Install
$ yarn
- Develop
$ yarn start
- Build
$ yarn build
- Publish 🏁
$ yarn publish