Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

hgroup and summary should work with source editing #16962

Merged
merged 5 commits into from
Aug 26, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion packages/ckeditor5-html-support/src/schemadefinitions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down Expand Up @@ -341,7 +349,10 @@ export default {
model: 'htmlHgroup',
view: 'hgroup',
modelSchema: {
allowIn: '$root',

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why $root and not $container? hgroup can go anywhere

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it would be safe to use $container here.

allowChildren: [
'paragraph',
'htmlP',
'htmlH1',
'htmlH2',
'htmlH3',
Expand Down
27 changes: 27 additions & 0 deletions packages/ckeditor5-html-support/tests/integrations/heading.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,10 @@ describe( 'HeadingElementSupport', () => {
model: 'htmlHgroup',
view: 'hgroup',
modelSchema: {
allowIn: '$root',
allowChildren: [
'paragraph',
'htmlP',
'htmlH1',
'htmlH2',
'htmlH3',
Expand All @@ -99,6 +102,27 @@ 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'
],
allowIn: 'htmlDetails',
isBlock: false
},
isBlock: true
} ] );
} );

it( 'should preserve attributes on headings', () => {
const expectedHtml =
'<h1 data-foo="bar-1">one</h1>' +
Expand Down Expand Up @@ -487,7 +511,10 @@ describe( 'HeadingElementSupport', () => {
model: 'htmlHgroup',
view: 'hgroup',
modelSchema: {
allowIn: '$root',
allowChildren: [
'paragraph',
'htmlP',
'htmlH1',
'htmlH2',
'htmlH3',
Expand Down