-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Editor: Shim meta attributes for early block registrations (#20544)
* Editor: Shim meta attributes for early block registrations * E2E Tests: Add meta block early registration test * Editor: Clarify comment regarding meta attribute shim
- Loading branch information
1 parent
6fd7289
commit 3feaa84
Showing
7 changed files
with
169 additions
and
96 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
( function() { | ||
var registerBlockType = wp.blocks.registerBlockType; | ||
var el = wp.element.createElement; | ||
|
||
registerBlockType( 'test/test-meta-attribute-block-early', { | ||
title: 'Test Meta Attribute Block (Early Registration)', | ||
icon: 'star', | ||
category: 'common', | ||
|
||
attributes: { | ||
content: { | ||
type: 'string', | ||
source: 'meta', | ||
meta: 'my_meta', | ||
}, | ||
}, | ||
|
||
edit: function( props ) { | ||
return el( 'input', { | ||
className: 'my-meta-input', | ||
value: props.attributes.content, | ||
onChange: function( event ) { | ||
props.setAttributes( { content: event.target.value } ); | ||
}, | ||
} ); | ||
}, | ||
|
||
save: function() { | ||
return null; | ||
}, | ||
} ); | ||
} )(); |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
( function() { | ||
var registerBlockType = wp.blocks.registerBlockType; | ||
var el = wp.element.createElement; | ||
|
||
registerBlockType( 'test/test-meta-attribute-block-late', { | ||
title: 'Test Meta Attribute Block (Late Registration)', | ||
icon: 'star', | ||
category: 'common', | ||
|
||
attributes: { | ||
content: { | ||
type: 'string', | ||
source: 'meta', | ||
meta: 'my_meta', | ||
}, | ||
}, | ||
|
||
edit: function( props ) { | ||
return el( 'input', { | ||
className: 'my-meta-input', | ||
value: props.attributes.content, | ||
onChange: function( event ) { | ||
props.setAttributes( { content: event.target.value } ); | ||
}, | ||
} ); | ||
}, | ||
|
||
save: function() { | ||
return null; | ||
}, | ||
} ); | ||
} )(); |
8 changes: 6 additions & 2 deletions
8
packages/e2e-tests/specs/editor/plugins/__snapshots__/meta-attribute-block.test.js.snap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,9 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`Block with a meta attribute Should persist the meta attribute properly 1`] = `"<!-- wp:test/test-meta-attribute-block /-->"`; | ||
exports[`Block with a meta attribute Early Registration Should persist the meta attribute properly 1`] = `"<!-- wp:test/test-meta-attribute-block-early /-->"`; | ||
|
||
exports[`Block with a meta attribute Should persist the meta attribute properly in a different post type 1`] = `"<!-- wp:test/test-meta-attribute-block /-->"`; | ||
exports[`Block with a meta attribute Early Registration Should persist the meta attribute properly in a different post type 1`] = `"<!-- wp:test/test-meta-attribute-block-early /-->"`; | ||
|
||
exports[`Block with a meta attribute Late Registration Should persist the meta attribute properly 1`] = `"<!-- wp:test/test-meta-attribute-block-late /-->"`; | ||
|
||
exports[`Block with a meta attribute Late Registration Should persist the meta attribute properly in a different post type 1`] = `"<!-- wp:test/test-meta-attribute-block-late /-->"`; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters