Skip to content

Commit

Permalink
rich text example: enabledMarks & enabledNodeTypes (#1290)
Browse files Browse the repository at this point in the history
* rich text example: enabledMarks & enabledNodeTypes

Added missing marks and nodeTypes to example 22 to improve it as a reference

* test fix

---------

Co-authored-by: Mitch Goudy <[email protected]>
  • Loading branch information
neptunus and mgoudy91 authored Feb 20, 2024
1 parent 2a44931 commit afe1345
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
8 changes: 7 additions & 1 deletion examples/22-create-rich-text-field-with-validation.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,27 +46,33 @@ module.exports = function (migration) {
}
}
},
{
enabledMarks: ['bold', 'italic', 'underline', 'code', 'superscript', 'subscript'],
message: 'Only bold, italic, underline, code, superscript, and subscript marks are allowed'
},
{
enabledNodeTypes: [
'heading-1',
'heading-2',
'heading-3',
'heading-4',
'heading-5',
'heading-6',
'ordered-list',
'unordered-list',
'hr',
'blockquote',
'embedded-entry-block',
'embedded-asset-block',
'table',
'hyperlink',
'entry-hyperlink',
'asset-hyperlink',
'embedded-entry-inline',
'embedded-resource-block'
],
message:
'Only heading 1, heading 2, heading 3, heading 4, heading 5, ordered list, unordered list, horizontal rule, quote, block entry, block embedded resource, asset, link to Url, link to entry, link to asset, and inline entry nodes are allowed'
'Only heading 1, heading 2, heading 3, heading 4, heading 5, heading 6, ordered list, unordered list, horizontal rule, quote, block entry, asset, table, block embedded resource, asset, link to Url, link to entry, link to asset, and inline entry nodes are allowed'
}
])
}
8 changes: 5 additions & 3 deletions test/integration/migration.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -1320,26 +1320,28 @@ describe('the migration', function () {
})

expect(ct.fields[0].type).to.eql('RichText')
expect(ct.fields[0].validations[1].enabledNodeTypes).to.eql([
expect(ct.fields[0].validations[2].enabledNodeTypes).to.eql([
'heading-1',
'heading-2',
'heading-3',
'heading-4',
'heading-5',
'heading-6',
'ordered-list',
'unordered-list',
'hr',
'blockquote',
'embedded-entry-block',
'embedded-asset-block',
'table',
'hyperlink',
'entry-hyperlink',
'asset-hyperlink',
'embedded-entry-inline',
'embedded-resource-block'
])
expect(ct.fields[0].validations[1].message).to.eql(
'Only heading 1, heading 2, heading 3, heading 4, heading 5, ordered list, unordered list, horizontal rule, quote, block entry, block embedded resource, asset, link to Url, link to entry, link to asset, and inline entry nodes are allowed'
expect(ct.fields[0].validations[2].message).to.eql(
'Only heading 1, heading 2, heading 3, heading 4, heading 5, heading 6, ordered list, unordered list, horizontal rule, quote, block entry, asset, table, block embedded resource, asset, link to Url, link to entry, link to asset, and inline entry nodes are allowed'
)
expect(ct.fields[0].validations[0].nodes['embedded-entry-block']).to.eql([
{
Expand Down

0 comments on commit afe1345

Please sign in to comment.