-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
RichText: Use a simplified format for rich text values #7476
Conversation
Few thoughts at a glance:
|
That's true, what should we do in that case? Just move it to |
I wouldn't quite say that this closes #771? It does help to get rid of staring the React element objects. Why |
To match React's shape essentially. Not certain I understand what's the content of This doesn't solve the "selection" state of RichText but solves only the value state from #771 |
No the |
There's an incidental performance benefit to this change, where currently we call Having fewer properties is also more efficient a comparison. |
So what's remaining here? this maybe #7476 (comment) |
90bfbd5
to
1634a05
Compare
@@ -1,7 +1,7 @@ | |||
/** | |||
* External dependencies | |||
*/ | |||
import { every, keys, isEqual, isFunction, isString } from 'lodash'; | |||
import { every, keys, isEqual, isFunction, isString, omit } from 'lodash'; |
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.
Unused variable.
}, | ||
" text...", | ||
{ | ||
"type": "br" | ||
"type": "br", |
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.
Funny formatting? Running npm run fixtures:regenerates
introduces a number of changes locally.
@@ -45,6 +46,24 @@ import serialize from './serialize'; | |||
*/ | |||
export { createElement }; | |||
|
|||
/** | |||
* Creates a simplified element representation. |
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.
What is a simplified element, and why would I need one?
This is my main concern with this change, mostly that we have this separate concept of an element which is very incidental to a specific need for blocks, though could be a reasonable replacement for element altogether. So I don't think it's strictly unsuitable for @wordpress/element
, though its existence parallel to the "full" element is unfortunate. The previous implementation where it existed in blocks
was more accurate to the fact that it's an implementation detail therein, but then is complicated by the serializer's awareness of this shape.
I don't really have an answer here, just expressing thoughts in my head in response to your desire to move forward ( #7476 (comment) ).
Couple options to consider:
createElement
should return the simplified form, and we somehow teach React to deal with it in rendering.- We move this back to
blocks
, but with some adapter which prepares an element for serialization, even if right now that just means returning the element verbatim.- Speaks also to the fact that we're misaligned between what React's renderer expects and our custom serializer can handle
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.
What if we just consider this as a separate thing? It's just the HTML format of Gutenberg. Doesn't need to be coupled with element at all. Though I don't know what name to give it.
Another issue we'll need to address: Merging two paragraphs uses |
Superseded by #7934 |
This PR updates the RichText "element" format to use a simplified version of a React element instead of the whole object. This has the advantages:
{ type, props: { ...props, children }
Testing instructions
closes #4489
related #771