-
Notifications
You must be signed in to change notification settings - Fork 8
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
feat: migrate block definitions to Config API #42
Open
Swanand01
wants to merge
11
commits into
rtCamp:develop
Choose a base branch
from
Swanand01:migrate-block-definitions
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+5
−14
Open
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
98236c1
feat: move `blockDefinitions` to `SnapWPConfigManager`
Swanand01 c2a79b1
feat: import `blockDefinitions` from `getConfig`
Swanand01 87660db
chore: remove old todo
Swanand01 a89dabc
example: pass custom `CoreQuote` definition
Swanand01 be538ae
format: lint fix
Swanand01 cfc4b00
Merge branch 'develop' into migrate-block-definitions
Swanand01 b4368b9
Merge branch 'develop' into migrate-block-definitions
justlevine 3c43141
Merge remote-tracking branch 'upstream/develop' into migrate-block-de…
Swanand01 c370af2
chore: add types package dependency to next app
Swanand01 386295d
refactor: remove `blockDefinitions` from `SnapWPEnv` and `SnapWPConfig`
Swanand01 6470738
revert: delete core-quote.tsx
Swanand01 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
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
Original file line number | Diff line number | Diff line change | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
@@ -1,5 +1,7 @@ | ||||||||||||
import React from 'react'; | ||||||||||||
import BlockManager from '@/block-manager'; | ||||||||||||
import { getConfig } from '@snapwp/core/config'; | ||||||||||||
|
||||||||||||
import type { BlockData, BlockDefinitions, BlockTreeNode } from '@snapwp/types'; | ||||||||||||
|
||||||||||||
type EditorBlocksRendererProps = { | ||||||||||||
|
@@ -10,14 +12,13 @@ type EditorBlocksRendererProps = { | |||||||||||
/** | ||||||||||||
* A react component to render editor blocks. | ||||||||||||
* @param props - Props. | ||||||||||||
* @param props.blockDefinitions - blocks rendering functions. | ||||||||||||
* @param props.editorBlocks - A list of blocks to be rendered. | ||||||||||||
* @return The rendered template | ||||||||||||
*/ | ||||||||||||
export default function EditorBlocksRenderer( { | ||||||||||||
editorBlocks, | ||||||||||||
blockDefinitions, | ||||||||||||
}: EditorBlocksRendererProps ) { | ||||||||||||
const { blockDefinitions } = getConfig(); | ||||||||||||
if ( blockDefinitions ) { | ||||||||||||
Comment on lines
+21
to
22
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nitpick, but whitespace is free ;-)
Suggested change
|
||||||||||||
BlockManager.addBlockDefinitions( blockDefinitions ); | ||||||||||||
} | ||||||||||||
|
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
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.
Pros vs cons about leaving keeping this prop, and then having a hierarchy of
props?.blockDefinitions || getConfig()?.blockDefinitions || defaultBlockDefinitions