fix some errors
This commit is contained in:
@@ -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: () => [],
|
||||||
|
|||||||
@@ -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 {
|
||||||
|
|||||||
Reference in New Issue
Block a user