From 69b5f13b7a82cd3874f6ddba5e1a6c4476e9ccd0 Mon Sep 17 00:00:00 2001 From: afeiship <1290657123@qq.com> Date: Fri, 5 Feb 2021 12:36:57 +0800 Subject: [PATCH] feat: update plugin schema define --- documentation/001-plugin.md | 46 +++++++++++++++++++++++++++++++++++++ public/plugins/underline.js | 1 + src/components/index.js | 1 + 3 files changed, 48 insertions(+) create mode 100644 documentation/001-plugin.md diff --git a/documentation/001-plugin.md b/documentation/001-plugin.md new file mode 100644 index 0000000..39f7ea6 --- /dev/null +++ b/documentation/001-plugin.md @@ -0,0 +1,46 @@ +# plugin + + +## schema +```js +{ + id: '插件唯一标识', + type: '类型', // format/block/extension + disabled: false, + meta: { + title: '标题', + description:'描述', + // 其它自定义 + }, + decorator:{ + instance: (inEditor) => { + return inEditor; + }, + classify: (inEditor) => { + return inEditor; + }, + }, + serialize:{ + input:(props) => { + console.log('当前插件输出的HTML结构'); + }, + output:(props) => { + console.log('当前插件输入到HTML解析的jsx'); + }, + }, + command:{ + is: ()=>{}, + active: ()=>{}, + deactive: ()=>{}, + toggle: ()=>{} + }, + event:{ + keydown:(event)=>{}, + paste:(event)=>{} + }, + render:(context, props){ + // 显示的样子 + const { editor } = context; + }, +} +``` diff --git a/public/plugins/underline.js b/public/plugins/underline.js index 2c7f630..bfcff11 100644 --- a/public/plugins/underline.js +++ b/public/plugins/underline.js @@ -8,6 +8,7 @@ import { jsx } from 'slate-hyperscript'; export default { name: 'underline', + type: 'format', importer: (el, children) => { const nodeName = el.nodeName.toLowerCase(); if (nodeName === 'u') { diff --git a/src/components/index.js b/src/components/index.js index 71201c8..3c598e2 100644 --- a/src/components/index.js +++ b/src/components/index.js @@ -3,6 +3,7 @@ import classNames from 'classnames'; import PropTypes from 'prop-types'; import React, { Component } from 'react'; import { createEditor, Editor, Transforms } from 'slate'; +import nx from '@jswork/next'; import nxCompose from '@jswork/next-compose'; import NxSlateSerialize from '@jswork/next-slate-serialize'; import NxDeslateSerialize from '@jswork/next-slate-deserialize';