Skip to content

Commit

Permalink
Patterns: check for edited entity content property when exporting (Wo…
Browse files Browse the repository at this point in the history
…rdPress#63227)

* Because an item can either be an entity record fetched via getEntityRecord or getEditedEntityRecord check for content?.raw and content. The reason being getEditedEntityRecord calls getRawEntityRecord. getRawEntityRecord maps properties to their raw values.

* Update type and add type check to keep the type linter happy

Co-authored-by: ramonjd <[email protected]>
Co-authored-by: ntsekouras <[email protected]>
Co-authored-by: t-hamano <[email protected]>
Co-authored-by: youknowriad <[email protected]>
  • Loading branch information
5 people authored and carstingaxion committed Jul 18, 2024
1 parent 70b21fa commit 28e2187
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
5 changes: 4 additions & 1 deletion packages/editor/src/dataviews/actions/export-pattern.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,10 @@ function getJsonFromItem( item: Pattern ) {
{
__file: item.type,
title: getItemTitle( item ),
content: item.content.raw,
content:
typeof item.content === 'string'
? item.content
: item.content?.raw,
syncStatus: item.wp_pattern_sync_status,
},
null,
Expand Down
4 changes: 1 addition & 3 deletions packages/editor/src/dataviews/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,7 @@ export interface TemplateOrTemplatePart extends BasePost {
export interface Pattern extends BasePost {
slug: string;
title: { raw: string };
content: {
raw: string;
};
content: { raw: string } | string;
wp_pattern_sync_status: string;
}

Expand Down

0 comments on commit 28e2187

Please sign in to comment.