diff --git a/packages/ckeditor5-html-support/src/integrations/heading.ts b/packages/ckeditor5-html-support/src/integrations/heading.ts index b80bf150240..841b096ebbf 100644 --- a/packages/ckeditor5-html-support/src/integrations/heading.ts +++ b/packages/ckeditor5-html-support/src/integrations/heading.ts @@ -70,5 +70,12 @@ export default class HeadingElementSupport extends Plugin { allowChildren: headerModels } } ); + + dataSchema.extendBlockElement( { + model: 'htmlSummary', + modelSchema: { + allowChildren: headerModels + } + } ); } } diff --git a/packages/ckeditor5-html-support/src/schemadefinitions.ts b/packages/ckeditor5-html-support/src/schemadefinitions.ts index b84884ac726..eeb0b76d516 100644 --- a/packages/ckeditor5-html-support/src/schemadefinitions.ts +++ b/packages/ckeditor5-html-support/src/schemadefinitions.ts @@ -279,7 +279,15 @@ export default { model: 'htmlSummary', view: 'summary', modelSchema: { - allowChildren: '$text', + allowChildren: [ + 'htmlH1', + 'htmlH2', + 'htmlH3', + 'htmlH4', + 'htmlH5', + 'htmlH6', + '$text' + ], allowIn: 'htmlDetails', isBlock: false } @@ -341,7 +349,10 @@ export default { model: 'htmlHgroup', view: 'hgroup', modelSchema: { + allowIn: [ '$root', '$container' ], allowChildren: [ + 'paragraph', + 'htmlP', 'htmlH1', 'htmlH2', 'htmlH3', diff --git a/packages/ckeditor5-html-support/tests/integrations/heading.js b/packages/ckeditor5-html-support/tests/integrations/heading.js index a840e861469..e24c304db21 100644 --- a/packages/ckeditor5-html-support/tests/integrations/heading.js +++ b/packages/ckeditor5-html-support/tests/integrations/heading.js @@ -82,7 +82,10 @@ describe( 'HeadingElementSupport', () => { model: 'htmlHgroup', view: 'hgroup', modelSchema: { + allowIn: [ '$root', '$container' ], allowChildren: [ + 'paragraph', + 'htmlP', 'htmlH1', 'htmlH2', 'htmlH3', @@ -99,6 +102,30 @@ describe( 'HeadingElementSupport', () => { } ] ); } ); + it( 'should add heading models as allowed children of htmlSummary', () => { + expect( Array.from( dataSchema.getDefinitionsForView( 'summary' ) ) ).to.deep.equal( [ { + model: 'htmlSummary', + view: 'summary', + modelSchema: { + allowChildren: [ + 'htmlH1', + 'htmlH2', + 'htmlH3', + 'htmlH4', + 'htmlH5', + 'htmlH6', + '$text', + 'heading1', + 'heading2', + 'otherHeading' + ], + allowIn: 'htmlDetails', + isBlock: false + }, + isBlock: true + } ] ); + } ); + it( 'should preserve attributes on headings', () => { const expectedHtml = '

one

' + @@ -487,7 +514,10 @@ describe( 'HeadingElementSupport', () => { model: 'htmlHgroup', view: 'hgroup', modelSchema: { + allowIn: [ '$root', '$container' ], allowChildren: [ + 'paragraph', + 'htmlP', 'htmlH1', 'htmlH2', 'htmlH3',