-
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
Framework: Move components from the blocks to the editor module #6521
Conversation
7a9c1d8
to
c7f3d23
Compare
A polyfill with a |
c7f3d23
to
0086b5e
Compare
0086b5e
to
af2a4ad
Compare
editor/index.native.js
Outdated
@@ -0,0 +1 @@ | |||
export { default as PlainText } from './components/plain-text'; |
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.
@hypest is it enough to make it work on mobile?
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.
Thanks for asking @gziolo , yes, that's enough to make it work on mobile. I wonder though, wdyt about "native-ize" ./components/index.native.js
instead of ./editor/index.native.js
? Is the components
module too web-specific you think?
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.
The difference between editor
and components
is that components
is meant to be generic UI components independent from WP backend or the editor while the editor
is for components used to build blocks/editor.
PlainText and RichText can be bound to the editor state, that's wy they live in editor.
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.
Thanks for the insight @youknowriad , that's helpful!
In this particular case, I'm actually referring to the editor/components mobule, not the top-level components. If I understand it correctly, PlainText and RichText live in the submodule in this PR, the index.js of which I'm suggesting to "native-ize". So, editor/index.native.js will still import * from './components'
but editor/components/index.native.js will only export PlainText for now. Does that make sense?
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, Understood and actually, I don't know. I don't really know how your react-native setup works, I thought the most important thing would be the root module (editor/index
) but yeah if you need to keep the rest of the editor/index
as is. I can update to move this to editor/components/index.native.js
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.
I thought the most important thing would be the root module (editor/index)
Glad you mention that so we can expand a bit. I guess the main premise for now is to use the index.js
s that serve as muster points as a good opportunity for specialization/nativization. Not necessarily the root module ones though. All index.js
s can fall under that pattern. Hope this makes sense.
I can update to move this to editor/components/index.native.js
Yes, let's go with that, thanks! 🙇
export { default as RichText } from './rich-text'; | ||
export { default as RichTextProvider } from './rich-text/provider'; | ||
export { default as UrlInput } from './url-input'; | ||
export { default as UrlInputButton } from './url-input/button'; | ||
export { default as EditorSettings, withEditorSettings } from './editor-settings'; |
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.
Why do editor-settings
and editor-media-upload
remain?
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.
because I was planning to them separately. See #6500 for the editor settings. And both require the components to be moved first.
editor/components/index.js
Outdated
@@ -1,3 +1,28 @@ | |||
// Block Creation Component |
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.
Nit: "Component" -> "Components"
editor/deprecated.js
Outdated
alternative: 'wp.editor.' + key, | ||
plugin: 'Gutenberg', | ||
} ); | ||
wrappedFunction( ...args ); |
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.
Should this return
?
0d97455
to
93f9bfc
Compare
@youknowriad, can we list all the remaining task so we could split work with follow-ups? |
Pushed c3463ca with RN changes. |
withColorContext, | ||
getColorClass, | ||
getColorName, | ||
withColors, |
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.
@jorgefilipecosta what's the difference between withColors
and withColorContext
?
It's the last chance to rename them to make it less confusing.
40920e9
to
2673327
Compare
ec95203
to
d12ff98
Compare
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.
I tested with a plugin that registers block that uses deprecated wp.blocks.*
component and it worked properly and I could see the warning:
wp.blocks.InspectorControls is deprecated and will be removed from Gutenberg in 3.1. Please use wp.editor.InspectorControls instead.
There is one small debugging change introduced which should be removed. I also see the React warning coming from the Custom HTML block. It needs to be confirmed it isn't regression introduced by this PR:
Warning: Failed prop type: You provided a
value
prop to a form field without anonChange
handler. This will render a read-only field. If the field should be mutable usedefaultValue
. Otherwise, set eitheronChange
orreadOnly
.
in textarea (created by CodeEditor)
in CodeEditor (created by LazyCodeEditor)
In overall, this works as expected and looks great. I think we should proceed as soon as two issues raised are sorted out.
lib/client-assets.php
Outdated
@@ -471,10 +452,10 @@ function gutenberg_preload_api_request( $memo, $path ) { | |||
* @since 0.1.0 | |||
*/ | |||
function gutenberg_register_vendor_scripts() { | |||
$suffix = SCRIPT_DEBUG ? '' : '.min'; | |||
$suffix = SCRIPT_DEBUG || true ? '' : '.min'; |
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.
|| true
shouldn't be included here and in the next statement :)
Confirmed the React warning is also present in master, let's address separately. |
🎉 |
Spoiler alert: Huge PR coming with big implications.
Related #6275
Sorry for the huge PR but sometimes big changes are unavoidable. The idea of this PR is to move the reusable components to build blocks from the blocks module to the editor module (the reasoning behind this is explained in #6275)
Notes
wp.blocks.*
components to ensure backward compatibilityQuestions
How can we move forward with this?