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 <ramonopoly@git.wordpress.org>
Co-authored-by: ntsekouras <ntsekouras@git.wordpress.org>
Co-authored-by: t-hamano <wildworks@git.wordpress.org>
Co-authored-by: youknowriad <youknowriad@git.wordpress.org>
  • Loading branch information
5 people authored and huubl committed Jul 10, 2024
1 parent d8702f7 commit a6b020b
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 a6b020b

Please sign in to comment.