https://github.com/afeiship/next-slate-plugin
Slate plugin manager.
https://github.com/afeiship/next-slate-plugin
define next plugin schema slate
Last synced: 11 months ago
JSON representation
Slate plugin manager.
- Host: GitHub
- URL: https://github.com/afeiship/next-slate-plugin
- Owner: afeiship
- License: mit
- Created: 2021-02-05T06:00:44.000Z (about 5 years ago)
- Default Branch: master
- Last Pushed: 2021-12-13T01:40:37.000Z (about 4 years ago)
- Last Synced: 2025-03-10T16:49:16.890Z (12 months ago)
- Topics: define, next, plugin, schema, slate
- Language: JavaScript
- Homepage:
- Size: 48.8 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
README
# next-slate-plugin
> Slate plugin manager.
[![version][version-image]][version-url]
[![license][license-image]][license-url]
[![size][size-image]][size-url]
[![download][download-image]][download-url]
## installation
```bash
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
```js
import NxSlatePlugin from '@jswork/next-slate-plugin';
const Bold = NxSlatePlugin.define({
id: 'bold',
type: 'format',
serialize: {
output: (node, children) => {
return `${children}`;
}
}
});
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
```js
{
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](https://github.com/afeiship/next-slate-plugin/blob/master/LICENSE.txt).
[version-image]: https://img.shields.io/npm/v/@jswork/next-slate-plugin
[version-url]: https://npmjs.org/package/@jswork/next-slate-plugin
[license-image]: https://img.shields.io/npm/l/@jswork/next-slate-plugin
[license-url]: https://github.com/afeiship/next-slate-plugin/blob/master/LICENSE.txt
[size-image]: https://img.shields.io/bundlephobia/minzip/@jswork/next-slate-plugin
[size-url]: https://github.com/afeiship/next-slate-plugin/blob/master/dist/next-slate-plugin.min.js
[download-image]: https://img.shields.io/npm/dm/@jswork/next-slate-plugin
[download-url]: https://www.npmjs.com/package/@jswork/next-slate-plugin