-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
Format library: Allow explicit registration when using npm packages #11611
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,10 @@ | ||
/** | ||
* WordPress dependencies | ||
*/ | ||
import { | ||
registerFormatType, | ||
} from '@wordpress/rich-text'; | ||
|
||
/** | ||
* Internal dependencies | ||
*/ | ||
|
@@ -8,18 +15,21 @@ import { italic } from './italic'; | |
import { link } from './link'; | ||
import { strikethrough } from './strikethrough'; | ||
|
||
/** | ||
* WordPress dependencies | ||
*/ | ||
import { | ||
registerFormatType, | ||
} from '@wordpress/rich-text'; | ||
export function getCoreFormatTypes() { | ||
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. JSDoc. 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. Does it mean we are good with the proposal? |
||
return [ | ||
bold, | ||
code, | ||
image, | ||
italic, | ||
link, | ||
strikethrough, | ||
].map( | ||
( { name, ...settings } ) => [ name, settings ] | ||
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. Why did we land on an array return value here. 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.
We can make it |
||
); | ||
} | ||
|
||
[ | ||
bold, | ||
code, | ||
image, | ||
italic, | ||
link, | ||
strikethrough, | ||
].forEach( ( { name, ...settings } ) => registerFormatType( name, settings ) ); | ||
export function registerCoreFormatTypes() { | ||
getCoreFormatTypes().forEach( | ||
( params ) => registerFormatType( ...params ) | ||
); | ||
} |
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.
How can we make sure someone use the
edit-post
module (via npm) get the formats by default?Can we remove the
wp_enqueue_script
(and style) in favor of an explicit dependency towardswp-format-library
inwp-edit-post
?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.
Does it mean, we would call
registerCoreFormatTypes
inedit-post
instead?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.
Maybe, It's not perfect because people that want to unregister these styles would need
edit-post
as a dependency. I'd love other opinions.