slate-data-filter-plugin

0.0.7 • Public • Published

Filter data on enter handler

Removes any data props which would otherwise be inherited for the enter onKeyDown event. This applies to all block-types.

Accepts a whitelist array parameter to allow defined values to be inherited.

usage

no whitelist

import React, { Component } from 'react'
import { Editor } from 'slate-react'
import FilterData from 'slate-data-filter-plugin';
 
const plugins = [FilterData()];
 
export default class App extends Component {
    state = {
        value: initialValue,
    };
    onChange = ({ value }) => {
        this.setState({ value });
    };
 
    render() {
        return (
            <Editor plugins={plugins} onKeyDown={this.onKeyDown} value={this.state.value} onChange={this.onChange} />
        )
    };
}

with whitelist

import React, { Component } from 'react'
import { Editor } from 'slate-react'
import FilterData from 'slate-data-filter-plugin';
 
const plugins = [FilterData(['foo', 'bar'])];
 
export default class App extends Component {
    state = {
        value: initialValue,
    };
    onChange = ({ value }) => {
        this.setState({ value });
    };
 
    render() {
        return (
            <Editor plugins={plugins} onKeyDown={this.onKeyDown} value={this.state.value} onChange={this.onChange} />
        )
    };
}

testing

npm run test

Versions

Current Tags

VersionDownloads (Last 7 Days)Tag
0.0.70latest

Version History

VersionDownloads (Last 7 Days)Published
0.0.70
0.0.60
0.0.50
0.0.40
0.0.30
0.0.20
0.0.10
1.0.00

Package Sidebar

Install

npm i slate-data-filter-plugin

Weekly Downloads

0

Version

0.0.7

License

ISC

Unpacked Size

5.66 kB

Total Files

7

Last publish

Collaborators

  • phillipbarron