Skip to content

Commit

Permalink
feat: update plugin schema define
Browse files Browse the repository at this point in the history
  • Loading branch information
afeiship committed Feb 5, 2021
1 parent 3e73fae commit 69b5f13
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 0 deletions.
46 changes: 46 additions & 0 deletions documentation/001-plugin.md
Original file line number Diff line number Diff line change
@@ -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;
},
}
```
1 change: 1 addition & 0 deletions public/plugins/underline.js
Original file line number Diff line number Diff line change
Expand Up @@ -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') {
Expand Down
1 change: 1 addition & 0 deletions src/components/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down

0 comments on commit 69b5f13

Please sign in to comment.