-
Notifications
You must be signed in to change notification settings - Fork 6
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!: Support alternate ElementWrapper #320
Conversation
This can be used locally with flexible-content via To do so:
|
Had a chat with @jonathonherbert off GitHub - have a more flexible API change that could achieve these changes - enabling us to replace the |
…to make edge of editor clearer
…ements that opt in, aiming to feel more native to Composer
f944660
to
fdd79a8
Compare
…low user to override ElementWrapper
That's now implemented! |
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.
This looks excellent, nice work!
I wonder about the name AltStyleElement
but can't think of a better one 🤔 I guess we're avoiding calling it anything to do with Key Takeaways as we're hoping to use it more broadly?
/> | ||
</FieldLayoutVertical> | ||
), | ||
elementWrapper: AltStyleElementWrapper, |
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.
Perfect 👌
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.
This looks really neat. One suggestion about naming and commenting.
What does this change?
This adds support for a using an alternate
ElementWrapper
for elements. In this case I'm exporting a newAltStyleElementWrapper
fromprosemirror-elements
, making use of components from the existingElementWrapper
with some design changes. The new layout aims to feel more spacious within - for example when an element makes up most of a piece of content.The controls from
ElementWrapper
are now moved to their own file (WrapperControls
) so that it's simpler to compose a newElementWrapper
.This PR includes a breaking change to
createReactElementSpec
, which will now take an options object as its argument rather than separate ordered arguments. The footprint for this PR looks fairly large because I've needed to update the demo element forms to provide arguments in this format.We are aiming to use these styles in the upcoming 'key takeaways' element, which will represent the majority of content in a key takeaways article.
Since Composer now provides the Form components itself, we will need to provide new or altered components there to restyle the form itself. I've updated the styles used in the demo components here to mirror the intended experience in Compose.
This PR also makes some changes to the overall demo styles to make it slightly more user-friendly.
In the demo app here:
In Composer:
How to test
Run the demo locally and click 'Add Alt Style' alongside another element. Do they have different styles? Are there any React-related errors?