-
Notifications
You must be signed in to change notification settings - Fork 1.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
refactor: Separate Gutenberg editor implementations #21493
Conversation
Generated by 🚫 Danger |
📲 You can test the changes from this Pull Request in Jetpack by scanning the QR code below to install the corresponding build.
|
📲 You can test the changes from this Pull Request in WordPress by scanning the QR code below to install the corresponding build.
|
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.
Android Lint found more than 20 potential problems in the proposed changes. Check the Files changed tab for more details.
Enable simple checking for both GBM and GBK.
This reverts commit 6bb6165.
There are now separate fragments for "new" and "old" Gutenberg, negating the need for branching logic within the fragments themselves.
The majority--if not all--of this code is unused by GutenbergKit. No-op methods were retained to satisfy the requirements of the class shared between Gutenberg Mobile and GutenbergKit.
The use of "new" to uniquely describe something is problematic, as it provides little context and could become incorrect at some future time.
c100ab2
to
e862f40
Compare
Please retry analysis of this Pull-Request directly on SonarQube Cloud |
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## trunk #21493 +/- ##
==========================================
- Coverage 39.44% 39.44% -0.01%
==========================================
Files 2121 2119 -2
Lines 99564 99556 -8
Branches 15313 15313
==========================================
- Hits 39277 39269 -8
Misses 56806 56806
Partials 3481 3481 ☔ View full report in Codecov by Sentry. |
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 consider the failed SonarQube Cloud result irrelevant as previous failed runs originated from crossing a code duplication threshold. However, the point of these changes is to duplicate code in order to reduce unnecessary risk associated with modifying code shared between two very different implementations.
@@ -180,8 +180,8 @@ android { | |||
buildConfigField "boolean", "ENABLE_SITE_MONITORING", "false" | |||
buildConfigField "boolean", "SYNC_PUBLISHING", "false" | |||
buildConfigField "boolean", "ENABLE_IN_APP_UPDATES", "false" | |||
buildConfigField "boolean", "ENABLE_NEW_GUTENBERG", "false" | |||
buildConfigField "boolean", "ENABLE_NEW_GUTENBERG_THEME_STYLES", "false" | |||
buildConfigField "boolean", "ENABLE_GUTENBERG_KIT", "false" |
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 term "new" is problematic, as it provides little context and can become outdated/incorrect in the future. I replaced it with a more meaningful name.
when { | ||
htmlModeMenuStateOn -> PostEditorAnalyticsSession.Editor.HTML | ||
isGutenberg -> PostEditorAnalyticsSession.Editor.GUTENBERG | ||
isGutenbergKit -> PostEditorAnalyticsSession.Editor.GUTENBERG_KIT |
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.
Introduced a new GutenbergKit-specific analytic indicator to denote the different Gutenberg editors.
if (isGutenbergKitEditor && showGutenbergEditor) { | ||
createGutenbergKitEditorFragment() |
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—along with the related fragment files—is the predominant change proposed. The separation is proposed to reduce risk associated with modifying shared logic between the Gutenberg editors, which are diverging and not progressing forward at the same rate.
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.
These changes should, in theory, restore this file to its state prior to 93c47b1, where it was heavily modified for the addition of GutenbergKit. This theory can be validated in the form of copying and pasting the implementation from the parent commit.
I.e., checking out this branch and pasting the previous implementation into this file in your editor should result in Git showing little-to-no modifications1 via git diff
.
Footnotes
-
There are a few stylistic changes—spacing, ordering, etc. ↩
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.
checking out this branch and pasting the previous implementation into this file in your editor should result in Git showing little-to-no modifications1
Just an FYI that I had to implement onEditorContentChanged
and onOpenMediaLibrary
for the previous code to work.
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. That is expected given the current version of the shared interface requires those methods.
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 new GutenbergKit implementation is devoid of all Gutenberg Mobile-specific logic. Hence, the smaller line numbers and several no-ops satisfying the shared interface. Long term, we might consider severing the shared interface.
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.
Long term, we might also consider how this implementation could be simplified, creating clear and useful separation between Aztec, Gutenberg Mobile, and GutenbergKit.
@dcalhoun This is unrelated to this PR but wanted to mention it. While testing I noticed the tool buttons don't always appear correctly. Here I've enabled both bold and italic, but the italic button is solid black. |
Thanks for the note. This relates to the way mobile web browsers apply hover styles and will be addressed within https://github.com/Automattic/dotcom-forge/issues/8678. |
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.
Changes look good and I'm glad for the separation
Suspect IssuesThis pull request was deployed and Sentry observed the following issues:
Did you find this useful? React with a 👍 or 👎 |
Closes https://github.com/Automattic/dotcom-forge/issues/9831.
Separate the Gutenberg Mobile and GutenbergKit fragments to reduce regression risk when modifying one of the two editors. While the editors do share commonalities, there are also significant differences. We also do not iterate on the editors simultaneously or at the same pace.
Testing Instructions
Test both the Gutenberg Mobile and GutenbergKit editors, attempting to find regressions with foundational features—text editing, media uploads, etc. Toggle the "experimental block editor" feature flags to switch between the two editors.
Regression Notes
Regressions in either of the block editors.
Manually tested both editors.
None, deemed unnecessary for the experimental editor.
PR Submission Checklist:
RELEASE-NOTES.txt
if necessary.Testing Checklist (strike-out the not-applying and unnecessary ones):