fix some errors

This commit is contained in:
Philipp Kühn
2020-10-23 10:59:26 +02:00
parent 56da8880dc
commit c330e41a50
2 changed files with 8 additions and 2 deletions

View File

@@ -4,6 +4,11 @@ import { Editor } from './Editor'
import { GlobalAttributes } from './types' import { GlobalAttributes } from './types'
export interface ExtensionSpec<Options = {}, Commands = {}> { export interface ExtensionSpec<Options = {}, Commands = {}> {
/**
* Name
*/
name?: string,
/** /**
* Default options * Default options
*/ */
@@ -78,6 +83,7 @@ export type Extension = Required<Omit<ExtensionSpec, 'defaultOptions'> & {
* Default extension * Default extension
*/ */
export const defaultExtension: Extension = { export const defaultExtension: Extension = {
name: 'extension',
type: 'extension', type: 'extension',
options: {}, options: {},
addGlobalAttributes: () => [], addGlobalAttributes: () => [],

View File

@@ -5,14 +5,14 @@ import getAttributesFromExtensions from './getAttributesFromExtensions'
import getRenderedAttributes from './getRenderedAttributes' import getRenderedAttributes from './getRenderedAttributes'
import isEmptyObject from './isEmptyObject' import isEmptyObject from './isEmptyObject'
function cleanUpSchemaItem(data: any) { function cleanUpSchemaItem<T>(data: T) {
return Object.fromEntries(Object.entries(data).filter(([key, value]) => { return Object.fromEntries(Object.entries(data).filter(([key, value]) => {
if (key === 'attrs' && isEmptyObject(value)) { if (key === 'attrs' && isEmptyObject(value)) {
return false return false
} }
return value !== null && value !== undefined return value !== null && value !== undefined
})) })) as T
} }
export default function getSchema(extensions: Extensions): Schema { export default function getSchema(extensions: Extensions): Schema {