feat(): export isBlockPlugin, isInlinePlugin, isMarkPlugin

This commit is contained in:
yanmao 2021-11-04 12:03:27 +08:00
parent 1e159ac2e4
commit 0e56e210cc
3 changed files with 24 additions and 11 deletions

View File

@ -8,6 +8,9 @@ import {
MarkPlugin, MarkPlugin,
InlinePlugin, InlinePlugin,
ListPlugin, ListPlugin,
isBlockPlugin,
isInlinePlugin,
isMarkPlugin,
} from './plugin'; } from './plugin';
import Card from './card/entry'; import Card from './card/entry';
import View from './view'; import View from './view';
@ -46,6 +49,9 @@ export {
MarkPlugin, MarkPlugin,
InlinePlugin, InlinePlugin,
ListPlugin, ListPlugin,
isBlockPlugin,
isInlinePlugin,
isMarkPlugin,
Card, Card,
Toolbar, Toolbar,
Tooltip, Tooltip,

View File

@ -1,5 +1,10 @@
import ElementPluginEntry from './element'; import ElementPluginEntry from './element';
import { SchemaBlock, BlockInterface, NodeInterface } from '../types'; import {
SchemaBlock,
BlockInterface,
NodeInterface,
PluginInterface,
} from '../types';
abstract class BlockEntry<T extends {} = {}> abstract class BlockEntry<T extends {} = {}>
extends ElementPluginEntry<T> extends ElementPluginEntry<T>
@ -52,3 +57,9 @@ abstract class BlockEntry<T extends {} = {}>
} }
export default BlockEntry; export default BlockEntry;
export const isBlockPlugin = (
plugin: PluginInterface,
): plugin is BlockInterface => {
return plugin.kind === 'block';
};

View File

@ -7,11 +7,10 @@ import {
} from '../types/plugin'; } from '../types/plugin';
import Plugin from './base'; import Plugin from './base';
import ElementPlugin from './element'; import ElementPlugin from './element';
import BlockPlugin from './block'; import BlockPlugin, { isBlockPlugin } from './block';
import InlinePlugin from './inline'; import InlinePlugin, { isInlinePlugin } from './inline';
import ListPlugin from './list'; import ListPlugin from './list';
import MarkPlugin from './mark'; import MarkPlugin, { isMarkPlugin } from './mark';
import { BlockInterface } from '../types/block';
import { isEngine } from '../utils'; import { isEngine } from '../utils';
class PluginModel implements PluginModelInterface { class PluginModel implements PluginModelInterface {
@ -66,10 +65,7 @@ export {
InlinePlugin, InlinePlugin,
BlockPlugin, BlockPlugin,
ListPlugin, ListPlugin,
}; isBlockPlugin,
isInlinePlugin,
export const isBlockPlugin = ( isMarkPlugin,
plugin: PluginInterface,
): plugin is BlockInterface => {
return plugin.kind === 'block';
}; };