-
Notifications
You must be signed in to change notification settings - Fork 798
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
Refactor production blocks registration 4 #33667
Merged
Merged
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
763429a
Refactor Donations block registration
monsieur-z d433665
Refactor OpenTable block registration
monsieur-z 73a17b8
Fix OpenTable restaurant preview
monsieur-z 5fff7bb
Refactor Paywall block registration
monsieur-z 594e35d
Refactor Pinterest block registration
monsieur-z d184d93
Refactor Podcast Player block registration
monsieur-z f555fa7
Refactor Rating Star block registration
monsieur-z cd96795
Refactor Recurring Payments block registration
monsieur-z 07adb1e
Add changelog
monsieur-z d584493
Fix Podcast Player rendering error
monsieur-z 849932e
Add missing Rating Star block attributes
monsieur-z a56f6d8
Fix Recurring Payments block rendering
monsieur-z f9834de
Update Rating Star test fixture
monsieur-z File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
4 changes: 4 additions & 0 deletions
4
projects/plugins/jetpack/changelog/refactor-production-blocks-registration-4
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,4 @@ | ||
Significance: patch | ||
Type: enhancement | ||
|
||
Refactor blocks registration |
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
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
62 changes: 0 additions & 62 deletions
62
projects/plugins/jetpack/extensions/blocks/paywall/index.js
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
4 changes: 2 additions & 2 deletions
4
projects/plugins/jetpack/extensions/blocks/paywall/transforms.js
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
5 changes: 4 additions & 1 deletion
5
projects/plugins/jetpack/extensions/blocks/pinterest/components/edit-url-form.js
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
3 changes: 3 additions & 0 deletions
3
projects/plugins/jetpack/extensions/blocks/pinterest/constants.js
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,3 @@ | ||
export const PINTEREST_EXAMPLE_URL = 'https://pinterest.com/anapinskywalker/'; | ||
export const URL_REGEX = | ||
/^\s*https?:\/\/(?:www\.)?(?:[a-z]{2}\.)?(?:pinterest\.[a-z.]+|pin\.it)\/([^/]+)(\/[^/]+)?/i; |
28 changes: 25 additions & 3 deletions
28
projects/plugins/jetpack/extensions/blocks/pinterest/editor.js
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,4 +1,26 @@ | ||
import registerJetpackBlock from '../../shared/register-jetpack-block'; | ||
import { name, settings } from '.'; | ||
import { createBlock } from '@wordpress/blocks'; | ||
import { registerJetpackBlockFromMetadata } from '../../shared/register-jetpack-block'; | ||
import metadata from './block.json'; | ||
import { URL_REGEX } from './constants'; | ||
import deprecatedV1 from './deprecated/v1'; | ||
import edit from './edit'; | ||
import save from './save'; | ||
|
||
registerJetpackBlock( name, settings ); | ||
registerJetpackBlockFromMetadata( metadata, { | ||
edit, | ||
save, | ||
transforms: { | ||
from: [ | ||
{ | ||
type: 'raw', | ||
isMatch: node => node.nodeName === 'P' && URL_REGEX.test( node.textContent ), | ||
transform: node => { | ||
return createBlock( 'jetpack/pinterest', { | ||
url: node.textContent.trim(), | ||
} ); | ||
}, | ||
}, | ||
], | ||
}, | ||
deprecated: [ deprecatedV1 ], | ||
} ); |
2 changes: 1 addition & 1 deletion
2
projects/plugins/jetpack/extensions/blocks/pinterest/hooks/use-test-pinterest-embed-url.js
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
80 changes: 0 additions & 80 deletions
80
projects/plugins/jetpack/extensions/blocks/pinterest/index.js
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
2 changes: 1 addition & 1 deletion
2
projects/plugins/jetpack/extensions/blocks/pinterest/test/use-test-pinterest-embed-url.js
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
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it the same as
URL_REGEX
inconstants
? Could it be reused?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, or it's the one below