-
Notifications
You must be signed in to change notification settings - Fork 135
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
[Custom Fields] HTML toggle #12670
base: trunk
Are you sure you want to change the base?
[Custom Fields] HTML toggle #12670
Conversation
Generated by 🚫 Danger |
📲 You can test the changes from this Pull Request in WooCommerce-Wear Android by scanning the QR code below to install the corresponding build.
|
📲 You can test the changes from this Pull Request in WooCommerce Android by scanning the QR code below to install the corresponding build.
|
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## trunk #12670 +/- ##
============================================
- Coverage 40.64% 40.63% -0.02%
+ Complexity 5674 5673 -1
============================================
Files 1229 1229
Lines 69178 69214 +36
Branches 9579 9587 +8
============================================
+ Hits 28119 28125 +6
- Misses 38475 38506 +31
+ Partials 2584 2583 -1
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
5919089
to
1a15a62
Compare
This avoids having an editor that spans longer than the available space making the whole UI scrollable
aztec.visualEditor.addOnLayoutChangeListener { _, _, _, _, _, _, _, _, _ -> | ||
// Because the editors could have different number of lines, we don't set the minLines | ||
// of the source editor, so we set the minHeight instead to match the visual editor | ||
sourceEditorMinHeight = aztec.visualEditor.height | ||
} | ||
|
||
aztec.visualEditor.doAfterTextChanged { | ||
if (!state.isHtmlEditorEnabled) return@doAfterTextChanged | ||
state.updateContent(aztec.visualEditor.toHtml()) | ||
} | ||
aztec.sourceEditor?.doAfterTextChanged { | ||
val sourceEditor = aztec.sourceEditor | ||
if (state.isHtmlEditorEnabled || sourceEditor == null) return@doAfterTextChanged | ||
state.updateContent(sourceEditor.getPureHtml()) | ||
} | ||
|
||
val focusChangeListener = OnFocusChangeListener { _, focused -> | ||
focusState.value = focused | ||
} | ||
aztec.visualEditor.onFocusChangeListener = focusChangeListener | ||
aztec.sourceEditor?.onFocusChangeListener = focusChangeListener | ||
|
||
viewsHolder.layout | ||
}, | ||
update = { | ||
if (aztec.visualEditor.isInCalypsoMode != calypsoMode) { | ||
aztec.visualEditor.isInCalypsoMode = calypsoMode | ||
aztec.sourceEditor?.setCalypsoMode(calypsoMode) | ||
} | ||
|
||
if (sourceEditorMinHeight != aztec.sourceEditor?.minHeight) { | ||
aztec.sourceEditor?.minHeight = sourceEditorMinHeight | ||
} | ||
if (minLines != -1 && minLines != aztec.visualEditor.minLines) { | ||
aztec.visualEditor.minLines = minLines | ||
} | ||
if (maxLines != Int.MAX_VALUE && maxLines != aztec.visualEditor.maxLines) { | ||
aztec.visualEditor.maxLines = maxLines | ||
aztec.sourceEditor?.maxLines = maxLines | ||
} | ||
|
||
if (aztec.visualEditor.label != label) { | ||
aztec.visualEditor.label = label | ||
aztec.sourceEditor?.label = label | ||
} | ||
}, | ||
modifier = modifier | ||
.bringIntoViewRequester(bringIntoViewRequester) | ||
) |
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.
All of this part wasn't touched, it's shown as edited just because it was wrapped in a key
function.
Column( | ||
modifier = Modifier | ||
.verticalScroll(rememberScrollState()) | ||
.heightIn(max = max(maxHeight, 320.dp)) |
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 set the maximum height of the Column to the available maxHeight
, unless it's less than 320.dp, this second condition is needed to avoid having an overlap between the key and value editors when maxHeight
is small, for example when on landscape and the keyboard is shown on a phone.
Closes: #12657
Description
This PR updates the logic of the editor to always offer a toggle to switch between the text editor and the Aztec one.
We decided to take this approach instead of showing the Aztec editor for HTML values by default for two reasons:
DOCTYPE
tag) and also has some issues with inline styling, so it's best to have an explicit action from the user before using it.For more information, check this discussion: p1725529996823859/1724862433.885169-slack-C03L1NF1EA3
Steps to reproduce
Testing information
The tests that have been performed
Same as the above.
Images/gif
Screen_recording_20240923_163725.mp4
RELEASE-NOTES.txt
if necessary. Use the "[Internal]" label for non-user-facing changes.Reviewer (or Author, in the case of optional code reviews):
Please make sure these conditions are met before approving the PR, or request changes if the PR needs improvement: