UNPKG

@atlaskit/editor-core

Version:

A package contains Atlassian editor core functionality

19 lines (15 loc) 544 B
import { PrimitiveType } from './schema-node'; import SchemaNodeWithValidators, { Indexed } from './schema-node-with-validators'; export default class PrimitiveSchemaNode< T extends Indexed > extends SchemaNodeWithValidators<T> { constructor(type: PrimitiveType, validators: T = {} as T) { super(type, validators); } toJSON(): object { const keys = Object.keys(this.validators) as [keyof T]; const obj = { type: this.type }; return keys.length ? this.mergeValidationInfo(keys, obj) : obj; } } export { Indexed };