isRequired on attrs
This commit is contained in:
@@ -24,6 +24,7 @@ export function getAttributesFromExtensions(extensions: Extensions): ExtensionAt
|
|||||||
renderHTML: null,
|
renderHTML: null,
|
||||||
parseHTML: null,
|
parseHTML: null,
|
||||||
keepOnSplit: true,
|
keepOnSplit: true,
|
||||||
|
isRequired: false,
|
||||||
}
|
}
|
||||||
|
|
||||||
extensions.forEach(extension => {
|
extensions.forEach(extension => {
|
||||||
@@ -87,14 +88,20 @@ export function getAttributesFromExtensions(extensions: Extensions): ExtensionAt
|
|||||||
Object
|
Object
|
||||||
.entries(attributes)
|
.entries(attributes)
|
||||||
.forEach(([name, attribute]) => {
|
.forEach(([name, attribute]) => {
|
||||||
|
const mergedAttr = {
|
||||||
|
...defaultAttribute,
|
||||||
|
...attribute,
|
||||||
|
}
|
||||||
|
|
||||||
|
if (attribute.isRequired && attribute.default === undefined) {
|
||||||
|
delete mergedAttr.default;
|
||||||
|
}
|
||||||
|
|
||||||
extensionAttributes.push({
|
extensionAttributes.push({
|
||||||
type: extension.name,
|
type: extension.name,
|
||||||
name,
|
name,
|
||||||
attribute: {
|
attribute: mergedAttr,
|
||||||
...defaultAttribute,
|
});
|
||||||
...attribute,
|
|
||||||
},
|
|
||||||
})
|
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
@@ -128,6 +128,7 @@ export type Attribute = {
|
|||||||
renderHTML?: ((attributes: Record<string, any>) => Record<string, any> | null) | null,
|
renderHTML?: ((attributes: Record<string, any>) => Record<string, any> | null) | null,
|
||||||
parseHTML?: ((element: HTMLElement) => any | null) | null,
|
parseHTML?: ((element: HTMLElement) => any | null) | null,
|
||||||
keepOnSplit: boolean,
|
keepOnSplit: boolean,
|
||||||
|
isRequired?: boolean,
|
||||||
}
|
}
|
||||||
|
|
||||||
export type Attributes = {
|
export type Attributes = {
|
||||||
|
|||||||
Reference in New Issue
Block a user