-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Comment Detail: Render content in web view #17129
Conversation
Also improve styling for <pre> and <blockquote>.
You can trigger an installable build for these changes by visiting CircleCI here. |
WordPress/Classes/ViewRelated/Comments/CommentContentTableViewCell.swift
Outdated
Show resolved
Hide resolved
WordPress/Classes/ViewRelated/Comments/CommentContentTableViewCell.swift
Outdated
Show resolved
Hide resolved
You can trigger optional UI/connected tests for these changes by visiting CircleCI here. |
WordPress/Classes/ViewRelated/Comments/CommentContentTableViewCell.swift
Outdated
Show resolved
Hide resolved
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.
Heya @dvdchr 👋
Looking sharp! I tested in in the iPhone Pro 11 simulator and the iPad Pro 9.7 simulator and things mostly looked good. I did spot a couple of things and left comments about them. Lemme know what you think.
Back to you sir!
WordPress/Classes/ViewRelated/Comments/CommentContentTableViewCell.swift
Outdated
Show resolved
Hide resolved
For some light stress testing I created this comment on a test self-hosted site that includes (I think) all of the default allowed tags for comments, plus images and YouTube embeds (which are not allowed by default). The comment looks pretty hideous in a browser but it looks rather nice in the app. :) I did notice there is some trouble with the the YouTube embed sizing properly. I'm not sure if that's because of the error screen or something else. Something we'll want to look into. Probably we'll have a period of finding lots of one-off quirky things (typical of this sort of change and to be expected) but we'll get 'em sorted and then we'll have some rock solid webview comments. :) |
Additionally, the RowType enum is refactored; the .text case no longer provides a closure as associated value, in order to make the enum class conform to Equatable without manual implementation. Row actions are now implemented in the didSelectRow method instead.
* All elements now have max-width: 100vw to prevent content overflow, unless explicitly overridden (e.g. table). This should fix unexpected content overflows e.g. from YouTube embeds. * Stylize img tags that aren't part of Gutenberg blocks.
The web view needs to be translucent initially, because otherwise the web view might show a short, white flash. This is noticeable in dark color schemes, and a tad annoying. On the other hand, a translucent webview causes scroll indicator to be invisible, regardless of the indicator style. Therefore, the solution is to set the webview to translucent initially, and set it back to opaque once the content has finished loading.
Appreciate the testing effort! 👍 Thank you.
Yeah... Also, considering how many blocks there are, I'm not sure if they would all look great, since the CSS is homegrown and thus, limited. 😆 Additionally, I've found that embedded tweets are causing problems with height calculation since it asynchronously fetches Twitter's widget.js library and resizes the tweet component. This is rather tricky since I've yet to find a way to block async Javascript without affecting the Javascript code that's used to calculate document height. The content is still vertically scrollable, it still doesn't look good since the detail screen now has two vertically scrollable components. Although this only applies to comments with embedded Tweet blocks. I'll take a look at this in the next PR, and will address it if it's not taking up too much time. The rough idea is instead of using
Yeah, for this I figured it's better to restrict everything from the start, and allow elements to scale past * {
max-width: 100vw;
} Update: this is now addressed in 1337847. |
@aerych this is ready for a second round of review! 🙂 |
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.
Heya @dvdchr 👋
Changes look good! Confirming portrait images and youtube embeds are sizing better. :) The styles are preserved when rotating now and sizes are updated.
I noticed if I got very aggressive with rotation I could get into a state where the content height was higher than the actual content. I think it would be pretty hard to do this with an actual device so not a blocker imho.
One thing we might add to a list of things to improve as we go is centering embedded content. What do you think?
Nice work sir. Let's !
super.viewWillTransition(to: size, with: coordinator) | ||
|
||
// when an orientation change is triggered, recalculate the content cell's height. | ||
guard let contentRowIndex = rows.firstIndex(where: { $0 == .content }) else { |
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.
Nice.
Thanks @aerych !
Good catch, and I agree with you. While this is not something crucial to address, I'll note it down with low priority for future reference. Or at least to keep the issue tracked.
It looks like this is because the reply content is not using blocks. Here's an example HTML content: Here\'s an example of a YouTube embed:
<iframe width=\"560\" height=\"315\" src=\"https://www.youtube.com/embed/dQw4w9WgXcQ\" title=\"YouTube video player\" frameborder=\"0\" allow=\"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture\" allowfullscreen></iframe>
Let\'s see how this will be rendered on the mobile side. Unlike blocks, the texts are not wrapped in a paragraph element, thus kinda mucking up with the spacing. I'll try to explore if I can improve the spacing for plain text / non-Gutenberg block comments in the next PR. |
Refs #17108, #17087,
aXjNk0P-zpl
This adds the web view implementation to render the comment content. Some notes:
richCommentTemplate.html
andrichCommentStyle.css
were added to stylize the contents according to the designs.loadHTMLString
on the web view) again.reload()
, through javascript'slocation.reload()
, re-queryingscrollHeight
, ...) to no avail. The resize only works by callingloadHTMLString
again. Somewhat expensive, I know. 😅 But it's what works so far and I've yet to find a better way.To test
New Comment Detail
flag is enabled.Regression Notes
Potential unintended areas of impact
n/a. Feature is still hidden behind a flag.
What I did to test those areas of impact (or what existing automated tests I relied on)
n/a. Feature is still hidden behind a flag.
What automated tests I added (or what prevented me from doing so)
n/a. Feature is still hidden behind a flag.
PR submission checklist:
RELEASE-NOTES.txt
if necessary.