dont use instanceof
This commit is contained in:
@@ -65,6 +65,8 @@ export interface ExtensionConfig<Options = any, Commands = {}> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export class Extension<Options = any, Commands = any> {
|
export class Extension<Options = any, Commands = any> {
|
||||||
|
type = 'extension'
|
||||||
|
|
||||||
config: Required<ExtensionConfig> = {
|
config: Required<ExtensionConfig> = {
|
||||||
name: 'extension',
|
name: 'extension',
|
||||||
defaultOptions: {},
|
defaultOptions: {},
|
||||||
|
|||||||
@@ -111,6 +111,8 @@ export interface MarkConfig<Options = any, Commands = {}> extends Overwrite<Exte
|
|||||||
}> {}
|
}> {}
|
||||||
|
|
||||||
export class Mark<Options = any, Commands = {}> {
|
export class Mark<Options = any, Commands = {}> {
|
||||||
|
type = 'mark'
|
||||||
|
|
||||||
config: Required<MarkConfig> = {
|
config: Required<MarkConfig> = {
|
||||||
name: 'mark',
|
name: 'mark',
|
||||||
defaultOptions: {},
|
defaultOptions: {},
|
||||||
|
|||||||
@@ -155,6 +155,8 @@ export interface NodeConfig<Options = any, Commands = {}> extends Overwrite<Exte
|
|||||||
}> {}
|
}> {}
|
||||||
|
|
||||||
export class Node<Options = any, Commands = {}> {
|
export class Node<Options = any, Commands = {}> {
|
||||||
|
type = 'node'
|
||||||
|
|
||||||
config: Required<NodeConfig> = {
|
config: Required<NodeConfig> = {
|
||||||
name: 'node',
|
name: 'node',
|
||||||
defaultOptions: {},
|
defaultOptions: {},
|
||||||
|
|||||||
@@ -4,9 +4,9 @@ import { Node } from '../Node'
|
|||||||
import { Mark } from '../Mark'
|
import { Mark } from '../Mark'
|
||||||
|
|
||||||
export default function splitExtensions(extensions: Extensions) {
|
export default function splitExtensions(extensions: Extensions) {
|
||||||
const baseExtensions = extensions.filter(extension => extension instanceof Extension) as Extension[]
|
const baseExtensions = extensions.filter(extension => extension.type === 'extension') as Extension[]
|
||||||
const nodeExtensions = extensions.filter(extension => extension instanceof Node) as Node[]
|
const nodeExtensions = extensions.filter(extension => extension.type === 'node') as Node[]
|
||||||
const markExtensions = extensions.filter(extension => extension instanceof Mark) as Mark[]
|
const markExtensions = extensions.filter(extension => extension.type === 'mark') as Mark[]
|
||||||
|
|
||||||
return {
|
return {
|
||||||
baseExtensions,
|
baseExtensions,
|
||||||
|
|||||||
Reference in New Issue
Block a user