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

Support String Operations on Rich Text while retaining styles #70

Closed
wakaztahir opened this issue Jul 19, 2023 · 2 comments · Fixed by #371
Closed

Support String Operations on Rich Text while retaining styles #70

wakaztahir opened this issue Jul 19, 2023 · 2 comments · Fixed by #371

Comments

@wakaztahir
Copy link
Contributor

wakaztahir commented Jul 19, 2023

User can perform following operations on the text when its a string

  1. User can remove a text range
  2. User can replace a text range
  3. User can add text at an index

These operations are easier because text is a string , you can perform all these operations easily because String is a perfect representation of the Text user wrote , But not in the case of Rich Text

If you want to remove a range of text , You know the indexes , startIndex & endIndex

The problem is retaining styles

I propose that the following methods be added to RichTextState and be exposed publicly

  1. removeTextRange(startIndex : Int,endIndex : Int) : Boolean
  2. replaceTextRange(startIndex : Int,endIndex : Int,replacement : AnnotatedString) : Boolean
  3. addTextAtIndex(index : Int,text : AnnotatedString) : Boolean

When user calls these methods , text range is removed / replaced , or text is added at an index , Without affecting the styles of other text

@wakaztahir
Copy link
Contributor Author

wakaztahir commented Jul 19, 2023

It would be easier to accomplish after

setTextFieldValue(value : TextFieldValue) or setAnnotatedStringValue(value : AnnotatedString) #66

User could build his own text field value from the current styles from annotated string available in rich text state and set it himself by taking out some styles / adding more styles

And we could also provide helper methods that call setTextFieldValue or setAnnotatedStringValue under the hood.

@MohamedRejeb
Copy link
Owner

I think that this a good idea, maybe also users want to remove an entire line or something like that. I'll check these options. At the same time I don't want to provide too much public Api's to the users didn't get confused.

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 a pull request may close this issue.

2 participants