Skip to content

Commit

Permalink
isRequired on attrs
Browse files Browse the repository at this point in the history
  • Loading branch information
thatsjonsense authored and bdbch committed May 20, 2022
1 parent 6fe3024 commit 23483d5
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
17 changes: 12 additions & 5 deletions packages/core/src/helpers/getAttributesFromExtensions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ export function getAttributesFromExtensions(extensions: Extensions): ExtensionAt
renderHTML: null,
parseHTML: null,
keepOnSplit: true,
isRequired: false,
}

extensions.forEach(extension => {
Expand Down Expand Up @@ -87,14 +88,20 @@ export function getAttributesFromExtensions(extensions: Extensions): ExtensionAt
Object
.entries(attributes)
.forEach(([name, attribute]) => {
const mergedAttr = {
...defaultAttribute,
...attribute,
}

if (attribute.isRequired && attribute.default === undefined) {

This comment has been minimized.

Copy link
@justame

justame Aug 9, 2022

attribute might be null.
Link for bug report

delete mergedAttr.default;
}

extensionAttributes.push({
type: extension.name,
name,
attribute: {
...defaultAttribute,
...attribute,
},
})
attribute: mergedAttr,
});
})
})

Expand Down
1 change: 1 addition & 0 deletions packages/core/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ export type Attribute = {
renderHTML?: ((attributes: Record<string, any>) => Record<string, any> | null) | null,
parseHTML?: ((element: HTMLElement) => any | null) | null,
keepOnSplit: boolean,
isRequired?: boolean,
}

export type Attributes = {
Expand Down

0 comments on commit 23483d5

Please sign in to comment.