-
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
Use format-library in gutenberg-mobile #12249
Conversation
5b04b44
to
1747389
Compare
e9e2419
to
d877d6e
Compare
> | ||
<View style={ { ...styles.content, borderColor: 'rgba(0, 0, 0, 0.1)' } }> | ||
<View style={ styles.head }> | ||
<Button |
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.
We can't reuse Button
from @wordpress/components
as they currently have hardcoded styles and it's outside of the scope of this PR to refactor it imo.
Let's use Button from react-native
in the meantime even though we might not be able to style them as much as we'd like (wrap text)
99bc5cd
to
878ab76
Compare
This is ready for review! |
91dfbd8
to
8fb02d7
Compare
f3188d9
to
0c85a37
Compare
@koke @Tug - I'm working on the images setting, and it uses a bottom-sheet very similar to the one you are developing here. I'm taking as a base the I created a cc @hypest |
I thought most of the work was done by |
@etoledom I gave it a thought actually when writing this component and I think we could create a mobile only component at |
@koke - It's true that most of the hard work is done by @Tug - That sounds good, I'll give it a try 👍 |
@koke |
The changes applied to web look good. At this point, we have a format library covered with basic e2e tests so this would be caught as a regression :) I will leave the final ✅ to the mobile team as those changes mostly impact Aztec integration. If you have any specific question regarding |
I can't approve since I'm the original PR author, but I'd say this looks good enough. |
We've given the "go ahead with merge" for the parent PR over at the gutenberg-mobile repo, capturing the known issues that will be worked on in follow PRs (see here). Will merge this and iterate. |
We should also add a simple e2e test which checks whether all format controls are displayed in the UI to prevent it from happing in the future. Actually, there is an open PR which would cover it indirectly #13455. So we might want to land PR from @tjnicolaides first and figure out the next steps. |
This one is not added to the UI. It's only a shortcut. It should get an e2e test, yes. |
👋 @iseulde , right, apparently we missed copying it over in https://github.com/WordPress/gutenberg/blob/master/packages/format-library/src/default-formats.js#L18 |
I can open a PR but, unfortunately don't have the bandwidth to properly test it (we're wrangling the release of v1.0 of gutenberg-mobile), is that OK @iseulde ? |
* Store current selection in RichText state * Make native RichText use format-library This is a work in progress. Sometimes it works, sometimes it doesn't, I haven't figured out the right way to wire the RichText structure into Aztec * Fix bad merge * Don't use applyRecord for now * Missing newlines * Do not change lastContent on formatChange, let the component rerender and update record. Also minor cleanup * Make sure the component rerenders when isSelected changes so FormatToolbar is removed * Make a simple version of Link that displays on mobile * Rerender on selection change to update record * Make it update onFormatChange when url changes * Cleanup changes in Heading and Paragraph * Remove unnecessary components and styles added while testing * Improve link editing UI * Fix adding a new url without a selection * Fix editing the text part of the url * Fill modal URL to current value * Pressing Remove dismisses the popup. Improve styles * Bring back multilineTag prop * Remove unused param in shouldComponentUpdate * Remove withBlockEditContext for now, it will need a better refactor to properly deal with focus from Aztec * Temporary fix for whitespace in HTML, will need to be addressed later * Make sure end is always greater than start for the text selection * Remove unsupported css property * Disable autoCapitalize and autoCorrect for URLInput * Fix lint errors in mobile and in rnmobile/rich-text-formats * Use a template string to generate html for Aztec in RichText * Preprocess the HTML value before sending it to Aztec, removing whitespaces in the process * Use custom button instead of native provided by react-native * Add some padding to our custom button * Send active formats to RCTAztecView so we can type new words in a format * Handle multiple formats with format placeholder * Cleanup applyFormat * Make applyFormat support applying multiple formats at once * Keep formatting when onSelectionChange is emitted without changes * Keep the same order of formats * Prevent inserting anything other that a formatting element from the link modal * Make sure wrapping tags returned by aztec are removed so it's not added to formats * Improve styling of the modal * Make sure we don't pass undefined values in activeFormats * Update formatPlaceholder when user decides to unselect a format in an existing formatted text * Update props.value on format change * Force update native view onFormatChange by not setting this.lastContent * Handle inserting a link * Fix updating format properties * Expand link selection automatically so we can edit a link without selecting it explicitly * Force an aztec text refresh on format change so we make sure the active formats are in sync * Add comment and make the code more consistent for debugging * Make sure we don't use format ref inside the placeholder formats * Make sure we don't use format ref inside the placeholder formats * Do not try to call valueToFormat on format change without selection * Fix editing link url * Add the ability to remove a link without selection * Do not remove trailing whitespace characters * Unescape spaces coming from Aztec * Fix code styling issues * Pick the formats of the first char when in text start * Fix lint errors * RichText value may be undefined * Update lastEventCount on enter and selection changes * Update ModalLinkUI to avoid the keyboard * Lint fixes
* Store current selection in RichText state * Make native RichText use format-library This is a work in progress. Sometimes it works, sometimes it doesn't, I haven't figured out the right way to wire the RichText structure into Aztec * Fix bad merge * Don't use applyRecord for now * Missing newlines * Do not change lastContent on formatChange, let the component rerender and update record. Also minor cleanup * Make sure the component rerenders when isSelected changes so FormatToolbar is removed * Make a simple version of Link that displays on mobile * Rerender on selection change to update record * Make it update onFormatChange when url changes * Cleanup changes in Heading and Paragraph * Remove unnecessary components and styles added while testing * Improve link editing UI * Fix adding a new url without a selection * Fix editing the text part of the url * Fill modal URL to current value * Pressing Remove dismisses the popup. Improve styles * Bring back multilineTag prop * Remove unused param in shouldComponentUpdate * Remove withBlockEditContext for now, it will need a better refactor to properly deal with focus from Aztec * Temporary fix for whitespace in HTML, will need to be addressed later * Make sure end is always greater than start for the text selection * Remove unsupported css property * Disable autoCapitalize and autoCorrect for URLInput * Fix lint errors in mobile and in rnmobile/rich-text-formats * Use a template string to generate html for Aztec in RichText * Preprocess the HTML value before sending it to Aztec, removing whitespaces in the process * Use custom button instead of native provided by react-native * Add some padding to our custom button * Send active formats to RCTAztecView so we can type new words in a format * Handle multiple formats with format placeholder * Cleanup applyFormat * Make applyFormat support applying multiple formats at once * Keep formatting when onSelectionChange is emitted without changes * Keep the same order of formats * Prevent inserting anything other that a formatting element from the link modal * Make sure wrapping tags returned by aztec are removed so it's not added to formats * Improve styling of the modal * Make sure we don't pass undefined values in activeFormats * Update formatPlaceholder when user decides to unselect a format in an existing formatted text * Update props.value on format change * Force update native view onFormatChange by not setting this.lastContent * Handle inserting a link * Fix updating format properties * Expand link selection automatically so we can edit a link without selecting it explicitly * Force an aztec text refresh on format change so we make sure the active formats are in sync * Add comment and make the code more consistent for debugging * Make sure we don't use format ref inside the placeholder formats * Make sure we don't use format ref inside the placeholder formats * Do not try to call valueToFormat on format change without selection * Fix editing link url * Add the ability to remove a link without selection * Do not remove trailing whitespace characters * Unescape spaces coming from Aztec * Fix code styling issues * Pick the formats of the first char when in text start * Fix lint errors * RichText value may be undefined * Update lastEventCount on enter and selection changes * Update ModalLinkUI to avoid the keyboard * Lint fixes
Fixes wordpress-mobile/gutenberg-mobile#221
This PR reuses the existing logic for the format buttons in
@wordpress/format-library
instead of our custom solution added in Aztec.Moreover, it adds a React Native custom modal component to the format-library
Link
component which handles creating and editing links. It also create a RN version ofURLInput
.This is what it looks like (Not as nice as the mockup yet wordpress-mobile/gutenberg-mobile#221 (comment) but I think we can iterate on it):
To test
Check out the gutenberg-mobile PR at wordpress-mobile/gutenberg-mobile#275. Try to use the formatting bar on paragraphs and headings.