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

Fix: remove formats from document outline headings #12130

Merged
Merged
Show file tree
Hide file tree
Changes from all 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
12 changes: 7 additions & 5 deletions packages/editor/src/components/document-outline/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,15 @@ import { countBy, flatMap, get } from 'lodash';
import { __ } from '@wordpress/i18n';
import { compose } from '@wordpress/compose';
import { withSelect, withDispatch } from '@wordpress/data';
import {
create,
getTextContent,
} from '@wordpress/rich-text';

/**
* Internal dependencies
*/
import DocumentOutlineItem from './item';
import RichText from './../rich-text';

/**
* Module constants
Expand Down Expand Up @@ -120,10 +123,9 @@ export const DocumentOutline = ( { blocks = [], title, onSelect, isTitleSupporte
>
{ item.isEmpty ?
emptyHeadingContent :
<RichText.Content
tagName="span"
value={ item.attributes.content }
/>
getTextContent(
create( { html: item.attributes.content } )
)
}
{ isIncorrectLevel && incorrectLevelContent }
{ item.level === 1 && hasMultipleH1 && multipleH1Headings }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,7 @@ exports[`DocumentOutline header blocks present should match snapshot 1`] = `
onClick={[Function]}
path={Array []}
>
<Component
format="string"
tagName="span"
value="Heading parent"
/>
Heading parent
</TableOfContentsItem>
<TableOfContentsItem
isValid={true}
Expand All @@ -25,11 +21,7 @@ exports[`DocumentOutline header blocks present should match snapshot 1`] = `
onClick={[Function]}
path={Array []}
>
<Component
format="string"
tagName="span"
value="Heading child"
/>
Heading child
</TableOfContentsItem>
</ul>
</div>
Expand All @@ -47,11 +39,7 @@ exports[`DocumentOutline header blocks present should render warnings for multip
onClick={[Function]}
path={Array []}
>
<Component
format="string"
tagName="span"
value="Heading 1"
/>
Heading 1
<br
key="incorrect-break-multiple-h1"
/>
Expand All @@ -68,11 +56,7 @@ exports[`DocumentOutline header blocks present should render warnings for multip
onClick={[Function]}
path={Array []}
>
<Component
format="string"
tagName="span"
value="Heading 1"
/>
Heading 1
<br
key="incorrect-break-multiple-h1"
/>
Expand Down