Comments (4)
Hi,
We shouldn't use non-composable functions inside the scope of a composable function. You need to make those calls inside a LaunchedEffect:
LaunchedEffect(Unit) {
richTextState.setHtml(content)
richTextState.selection = TextRange.Zero
}
What was happening in your case is when you use setHtml
it causes a recomposition because the text is changed, and the recomposition causes the setHtml to be called again and so on... That's why normal function calls need to be outside the scope of the composable function.
from compose-rich-editor.
Yes, you are absolutely right. I don't know why, but I thought it worked on the binding principle.
Still, i do not get why spaces for this code is applied after few miliseconds:
private fun FxRichText( ) {
val richTextState = rememberRichTextState()
LaunchedEffect(Unit) {
val newContent = "<ol> " +
"\t<li>NLorem ipsum dolor sit amet, consectetur adipiscing elit.Lorem ipsum dolor sit amet, consectetur adipiscing elit. \t</li><br> " +
"\t<li>Lorem ipsum dolor sit amet, consectetur adipiscing elit. " +
"\t \t\t<li>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Lorem ipsum dolor sit amet, consectetur adipiscing elit. \t\t</li>" +
"</ol>"
richTextState.setHtml(newContent)
richTextState.selection = TextRange.Zero
}
RichTextEditor(
state = richTextState,
readOnly = true,
shape = AppTheme.shapes.rectangle,
colors = richTextEditorColors(),
textStyle = AppTheme.typography.normalLightText,
contentPadding = PaddingValues(0.dp)
)
}
from compose-rich-editor.
I will check this. Can you try again with the latest version?
from compose-rich-editor.
Yeap, the latest version fixes this bug.
from compose-rich-editor.
Related Issues (20)
- Support editing existing Link
- Is there any plan to support compose web (wasm) in near future? HOT 1
- Support replacing selected text
- List Item Numbering Not Working HOT 1
- Weird behavior when inputting text with new lines HOT 3
- Slack like behaviour that auto starts formating HOT 1
- Crash after undoing HOT 1
- Bullet list activation reset text style already applied HOT 1
- Separating a separate artifact for rich html text HOT 1
- When trying to toggle style on link - link disappears HOT 1
- Dynamic Text Insertion and Deletion HOT 12
- No code blocks parsing HOT 1
- Lists indent HOT 4
- RichTextEditor Problem for Editing the current state with parsing html content HOT 3
- When calling state.setHtml(html) method for rendering a HTML Ordered list , each <li> tag is rendered as a new Ordered list HOT 2
- should support span id HOT 3
- Padding after html tag HOT 5
- How to highlight a different part of the text depending on the text and the current caret position? HOT 1
- Span style resets to default after deleting all characters HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from compose-rich-editor.