-
-
Notifications
You must be signed in to change notification settings - Fork 77
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
Handle link click in editor #194
base: main
Are you sure you want to change the base?
Handle link click in editor #194
Conversation
This update introduces a callback function `onRichSpanClick` to allow apps to handle clicks on RichSpans in the RichTextEditor. The updates also modify the visibility of some classes and properties to support this- `RichSpan`, `ParagraphType` and `getRichSpanByOffset` method in `RichTextState` are now publicly visible.
7d321cc
to
2c7e21e
Compare
I got this working again, however it suffers from the same problem as outlined in #421 So if there is line wrapping, then it will select the wrong span of text. The bug is separate from this PR, so I think this is ready for review now. I had to make some decisions because of the new strict API checking on what to make public VS internal, so not sure what you think about the choices I made there. Importantly, |
Okay, I'm understanding the code base quite a bit better than before, I refactored things so I no longer have to make |
) { | ||
newParagraphFirstRichSpan.spanStyle = currentSpanStyle | ||
newParagraphFirstRichSpan.richSpanStyle = currentRichSpanStyle | ||
newParagraph.getFirstNonEmptyChild()?.let { newParagraphFirstRichSpan -> |
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.
Handling a nullable, not sure why this isn't a problem in the main branch?
I don't think this is ready to merge yet, but take a look at the current approach.I added a new listener:
RichSpanClickListener
Which gets clicks on all
RichSpans
, and lets the user sort them out.I have an example in
RichEditorContent.kt
using this new listener to show a popup simulating a spellchecker.However
getRichSpanByOffset()
only seems to work in theBasicRichTextEditor
, The Outline variant which I think has extra padding maybe? The clicks return the wrong span. It appears to me to be offset by maybe the amount of padding? Not sure.In order to make all of this work I had to make more classes public, which might be fine? But if we decide we don't want to expose all of those internal workings, maybe we'd have some stripped down classes to return instead in the click listener?