Skip to content

Commit e1e4967

Browse files
ramonjdntsekourast-hamanoyouknowriad
authored
Patterns: check for edited entity content property when exporting (#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]>
1 parent 7c85de1 commit e1e4967

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

packages/editor/src/dataviews/actions/export-pattern.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,10 @@ function getJsonFromItem( item: Pattern ) {
2222
{
2323
__file: item.type,
2424
title: getItemTitle( item ),
25-
content: item.content.raw,
25+
content:
26+
typeof item.content === 'string'
27+
? item.content
28+
: item.content?.raw,
2629
syncStatus: item.wp_pattern_sync_status,
2730
},
2831
null,

packages/editor/src/dataviews/types.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,7 @@ export interface TemplateOrTemplatePart extends BasePost {
2323
export interface Pattern extends BasePost {
2424
slug: string;
2525
title: { raw: string };
26-
content: {
27-
raw: string;
28-
};
26+
content: { raw: string } | string;
2927
wp_pattern_sync_status: string;
3028
}
3129

0 commit comments

Comments
 (0)