0.0.7 • Published 6 years ago

slate-data-filter-plugin v0.0.7

Weekly downloads
3
License
ISC
Repository
github
Last release
6 years ago

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
0.0.7

6 years ago

0.0.6

6 years ago

0.0.5

6 years ago

0.0.4

6 years ago

0.0.3

6 years ago

0.0.2

6 years ago

0.0.1

6 years ago

1.0.0

6 years ago