-
-
Notifications
You must be signed in to change notification settings - Fork 63
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
Bring signature of RichTextEditor more inline with normal TextFields #95
Comments
Hi,
Give it a try and let me know if it works and I'll work on providing a better approach ASAP |
Thanks for the quick reply. We'll give the workaround a try. |
Hi, Is this still a thing you plan to add? We currently have the following structure with the work around mentioned above: OurCustomizedRichTextEditor(value, onValueChange) {
val richTextState = rememberRichTextState()
LaunchedEffect(value) {
richTextState.setHtml(value ?: "")
}
LaunchedEffect(state.annotatedString) {
val html = richTextState.toHtml()
onValueChange(html) //propagate new value back up
}
RichTextEditor( richTextState)
} However this results in very buggy behavior. Things I noticed:
The above things don't happen when I don't call onValueChange. |
FYI I fixed my issues in the comment above by not always calling OurCustomizedRichTextEditor(value, onValueChange) {
val richTextState = rememberRichTextState()
LaunchedEffect(value) {
//preventing buggy behavior in the rich text editor,
//basically we try not to touch the richTextState
if (richTextState.toHtml() != value) {
richTextState.setHtml(value ?: "")
}
}
LaunchedEffect(state.annotatedString) {
val html = richTextState.toHtml()
onValueChange(html) //propagate new value back up
}
RichTextEditor( richTextState)
} |
Hello, |
Hi,
We are looking into your library to integrate in our app, and use it in our forms. The library looks great and seems to support all our needs.
However there is one thing now that we are struggling with a bit.
Our use case is that the editor is in a form with other textfields, and the content of the form input fields is controlled somewhere else (a ViewModel)
This works great for normal Compose inputs, like the TextField where we have a
value
andonValueChange
.In the current setup of the library we need to use
rememberRichTextState
and then manually callsetHTML
in a LaunchedEffect, which already feels strange. And I don't see a way to continuously update the state in the view model, since I do not see an equivalent ofonValueChange
. I only see the method toHTML which needs to be called manually on the state object.I see you had something like this before in the pre-v1.0 versions but you deprecated this.
Our ideal structure would be to be able to do something like this:
Where the input and output would HTML (or other options depending on what the someone wants, our use case is HTML). This way it can be more or less a drop-in replacement for normal Compose TextFields
What do you suggest? Is something like this already possible?
I think this is similar to #66
The text was updated successfully, but these errors were encountered: