import ElementPluginEntry from './element'; import type { SchemaBlock, BlockInterface, PluginInterface, PluginOptions, } from '../types'; abstract class BlockEntry extends ElementPluginEntry implements BlockInterface { readonly kind: string = 'block'; /** * 标签名称 */ abstract readonly tagName: string | Array; /** * 该节点允许可以放入的block节点 */ readonly allowIn?: Array; /** * 禁用的mark插件样式 */ readonly disableMark?: Array; /** * 是否能够合并 */ readonly canMerge?: boolean; schema(): SchemaBlock | Array { const schema = super.schema(); if (Array.isArray(schema)) { return schema.map((schema) => { return { ...schema, allowIn: this.allowIn, } as SchemaBlock; }); } return { ...schema, allowIn: this.allowIn, canMerge: this.canMerge, } as SchemaBlock; } } export default BlockEntry; export const isBlockPlugin = ( plugin: PluginInterface, ): plugin is BlockInterface => { return plugin.kind === 'block'; };