Skip to content
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

Open
wants to merge 26 commits into
base: main
Choose a base branch
from

Conversation

Wavesonics
Copy link
Contributor

@Wavesonics Wavesonics commented Feb 3, 2024

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 the BasicRichTextEditor, 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?

@Wavesonics
Copy link
Contributor Author

Wavesonics commented Nov 13, 2024

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, RichSpanStyle needs to be a public, open, class now so that custom spans can be applied.

@Wavesonics Wavesonics marked this pull request as ready for review November 13, 2024 05:16
@Wavesonics Wavesonics mentioned this pull request Nov 14, 2024
@Wavesonics
Copy link
Contributor Author

Wavesonics commented Nov 22, 2024

Okay, I'm understanding the code base quite a bit better than before, I refactored things so I no longer have to make RichParagraph or RichSpan public.

@Wavesonics Wavesonics force-pushed the handle-link-click-in-editor branch from f849418 to 0940b42 Compare November 25, 2024 07:11
@Wavesonics
Copy link
Contributor Author

Wavesonics commented Nov 25, 2024

Just rebased this to get the line-wrapping fix #436

But the issue with OutlinedRichTextEditor click offsets being incorrect appears to remain.

@Wavesonics
Copy link
Contributor Author

Ha never mind, I think I fixed the OutlinedRichTextEditor issue! Just had to correct for ContentPadding

@Wavesonics Wavesonics force-pushed the handle-link-click-in-editor branch from 16966e7 to 5514261 Compare December 7, 2024 19:42
@Wavesonics Wavesonics force-pushed the handle-link-click-in-editor branch from 5514261 to 32a1c14 Compare December 9, 2024 05:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants