-
Notifications
You must be signed in to change notification settings - Fork 4
Add support for pasting rich text content (Rust + Web) #71
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
Conversation
…ogle docs and ms word)
…tribute of a particular value
and bring it's error handling in line with sys parser so that it returns an error if external_html_source is false and it encounters tags it doesn't support.
…ren, not the li/ol's). Also adds post processing to cleanup sibling text nodes.
… where there are inline + block containers in the same parent.
Namely, fixing the cursor position after insert, and adding more parsing post processing to keep the dom in an expected state with wrap_inline_nodes_into_paragraphs_if_needed and join_nodes_in_container. Also fixing some tests.
As we are now parsing from non-matrix sources, adding some rigour around validation of a valid dom. E.g. making sure nodes other than list items are not added to lists or that list items are not added to containers other than lists.
… == "bold". This fixes the pasting bold content from google docs(and possibly other sources).
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #71 +/- ##
==========================================
+ Coverage 89.66% 89.69% +0.02%
==========================================
Files 170 171 +1
Lines 20848 21390 +542
Branches 291 294 +3
==========================================
+ Hits 18693 19185 +492
- Misses 2152 2202 +50
Partials 3 3
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
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 ran the Android and iOS checks, but then I remembered they won't really matter much since replace_html isn't used there 😅 . Since the code is quite large and complex I've taken a quick look and I trust the tests will check the right cases 🤞 .
| } | ||
| } | ||
|
|
||
| #[cfg(test)] |
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.
Can we have some comments stating which structure these huge HTML chunks should represent? It's quite difficult to understand if the tests are doing the right thing since we can't compare the tree structures.
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.
Yea most of this chunk is actually the same as the one in parse.rs so I'll use format here to make things clearer and avoid the copy paste and add some comments.
| indoc! { | ||
| r#" | ||
| ├>ol |
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're merging the several ordered list nodes in the MS docs HTML?
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.
Yea, this was happening an offshot of the join_nodes_in_container being called in in a number of places like here. And the behaviour wasn't totally unwanted, as it's kind of weird that ms docs was splitting these into separate lists anyway(in the UI I had created 1 list, I think in their html they have all items as separate lists use margin to do indenting).
Do you think this is ok? Or should we avoid calling join_nodes_in_container over zealously?
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 think it's probably ok, as you say the resulting structure makes more sense.
|



What's in this PR?
HTMLSourcethat can be Matrix(i.e. what s generated by the RTE), GoogleDoc (there is a bit of special casing to clean it's content up) or UnknownExternal(all other external sources).<li>within a<ol>or<ul>it's invalid and should be ignored).What does it look like?
Screen.Recording.2025-07-23.at.15.33.41.mov