@jswork/next-slate-plugin

    1.0.16 • Public • Published

    next-slate-plugin

    Slate plugin manager.

    version license size download

    installation

    npm install -S @jswork/next-slate-plugin

    apis

    api params description
    define schema Define a plugin.
    actived node,plugins Get actived plugin(s) from plugins.

    usage

    import NxSlatePlugin from '@jswork/next-slate-plugin';
    
    const Bold = NxSlatePlugin.define({
      id: 'bold',
      type: 'format',
      serialize: {
        output: (node, children) => {
          return `<strong>${children}</strong>`;
        }
      }
    });
    
    const node = {
      text: 'i am a bold text',
      bold: true,
      italic: true
    };
    const plugins = [{ id: 'paragraph' }, { id: 'bold' }, { id: 'italic' }, { id: 'blockquote'}];
    const actived = NxSlatePlugin.actived(node, plugins);
    
    /*
    [
      { id: 'bold' },
      { id: 'italic' },
    ];
    */

    full schema

    {
      id: null,
      meta: {
        title: null,
        description: null
      },
      hotkey: null,
      decorator: nx.stubValue,
      serialize: {
        input: nx.noop,
        output: NxSlateDefaults.exporter
      },
      statics: {},
      commands: {
        is: nx.noop,
        isHotkey: nx.noop,
        activate: nx.noop,
        deactivate: nx.noop,
        toggle: nx.noop
      },
      events: {
        keydown: nx.noop,
        paste: nx.noop
      },
      render: nx.noop
    }

    license

    Code released under the MIT license.

    Install

    npm i @jswork/next-slate-plugin

    DownloadsWeekly Downloads

    2

    Version

    1.0.16

    License

    MIT

    Unpacked Size

    9.39 kB

    Total Files

    5

    Last publish

    Collaborators

    • afeiship