From 0e56e210cc983cf9784b1bc992dd7e836efc638a Mon Sep 17 00:00:00 2001 From: yanmao Date: Thu, 4 Nov 2021 12:03:27 +0800 Subject: [PATCH] feat(): export isBlockPlugin, isInlinePlugin, isMarkPlugin --- packages/engine/src/index.ts | 6 ++++++ packages/engine/src/plugin/block.ts | 13 ++++++++++++- packages/engine/src/plugin/index.ts | 16 ++++++---------- 3 files changed, 24 insertions(+), 11 deletions(-) diff --git a/packages/engine/src/index.ts b/packages/engine/src/index.ts index ee90ad4a..09920c9d 100644 --- a/packages/engine/src/index.ts +++ b/packages/engine/src/index.ts @@ -8,6 +8,9 @@ import { MarkPlugin, InlinePlugin, ListPlugin, + isBlockPlugin, + isInlinePlugin, + isMarkPlugin, } from './plugin'; import Card from './card/entry'; import View from './view'; @@ -46,6 +49,9 @@ export { MarkPlugin, InlinePlugin, ListPlugin, + isBlockPlugin, + isInlinePlugin, + isMarkPlugin, Card, Toolbar, Tooltip, diff --git a/packages/engine/src/plugin/block.ts b/packages/engine/src/plugin/block.ts index b8a7901f..b61d040e 100644 --- a/packages/engine/src/plugin/block.ts +++ b/packages/engine/src/plugin/block.ts @@ -1,5 +1,10 @@ import ElementPluginEntry from './element'; -import { SchemaBlock, BlockInterface, NodeInterface } from '../types'; +import { + SchemaBlock, + BlockInterface, + NodeInterface, + PluginInterface, +} from '../types'; abstract class BlockEntry extends ElementPluginEntry @@ -52,3 +57,9 @@ abstract class BlockEntry } export default BlockEntry; + +export const isBlockPlugin = ( + plugin: PluginInterface, +): plugin is BlockInterface => { + return plugin.kind === 'block'; +}; diff --git a/packages/engine/src/plugin/index.ts b/packages/engine/src/plugin/index.ts index 44f3cd1f..38cfb2b7 100644 --- a/packages/engine/src/plugin/index.ts +++ b/packages/engine/src/plugin/index.ts @@ -7,11 +7,10 @@ import { } from '../types/plugin'; import Plugin from './base'; import ElementPlugin from './element'; -import BlockPlugin from './block'; -import InlinePlugin from './inline'; +import BlockPlugin, { isBlockPlugin } from './block'; +import InlinePlugin, { isInlinePlugin } from './inline'; import ListPlugin from './list'; -import MarkPlugin from './mark'; -import { BlockInterface } from '../types/block'; +import MarkPlugin, { isMarkPlugin } from './mark'; import { isEngine } from '../utils'; class PluginModel implements PluginModelInterface { @@ -66,10 +65,7 @@ export { InlinePlugin, BlockPlugin, ListPlugin, -}; - -export const isBlockPlugin = ( - plugin: PluginInterface, -): plugin is BlockInterface => { - return plugin.kind === 'block'; + isBlockPlugin, + isInlinePlugin, + isMarkPlugin, };