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

Text does not show when updating state #203

Open
pkasson opened this issue Oct 10, 2024 · 7 comments
Open

Text does not show when updating state #203

pkasson opened this issue Oct 10, 2024 · 7 comments
Labels
adjustment Changes to existing functionality

Comments

@pkasson
Copy link

pkasson commented Oct 10, 2024

When the text (@State) is updated, the component does not show it:

@State var text = NSAttributedString(string: "Type text here...")

RichTextEditor(text: $text, context: context)
.focusedValue(.richTextContext, context)
.focused($isFocused)

The initial text works, but when text is updated, it does not get rendered.

@danielsaidi
Copy link
Owner

Hi @pkasson

That's unfortunately a side-effect of striving for better performance, since the text editor would otherwise be redrawn whenever you type.

I've been thinking about adding an internal binding that always writes out to the external one, but also listen for those changes and update whenever the external one changes.

For now, you can use setter functions in the rich text context, which affect the editor.

@danielsaidi danielsaidi added the adjustment Changes to existing functionality label Oct 13, 2024
@pkasson
Copy link
Author

pkasson commented Oct 13, 2024

Thanks - that worked. I agree, there is a balancing act on updating content that has rich content and performance

@pkasson
Copy link
Author

pkasson commented Oct 13, 2024

Next Q - how can I set the BG color - it appears maybe using the Theme, but I can't see how to set it to white.

@danielsaidi
Copy link
Owner

You can set a color with the rich text action approach.

@pkasson
Copy link
Author

pkasson commented Oct 15, 2024

How do you do that ?

@danielsaidi
Copy link
Owner

You can trigger a RichTextAction.

The documentation is a bit fuzzy about this, but you can see some examples in the docs:
https://danielsaidi.github.io/RichTextKit/documentation/richtextkit/context-article

@pkasson
Copy link
Author

pkasson commented Oct 21, 2024

Yes, quite fuzzy - didn't find anything around this ... thanks for trying - will find another RTF editor.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
adjustment Changes to existing functionality
Projects
None yet
Development

No branches or pull requests

2 participants