next-slate-plugin
Slate plugin manager.
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.