Open wakaztahir opened 1 year ago
Do you mean like when I type some text, ex "Hello world|", and the cursor is directly after "world" and when I click bold "world" became bold ?
yes , this way when my cursor is in range of that word , if its already bold , pressing bold unbolds it and button reflects that the current word under cursor is bold
Well I still not understand your point exactly xD can you attach a short recording.
In the end when I move the cursor the styles are lost , this is because the editor doesn't retail styles
When I move the cursor to another word , the button indicates that the current word is not bold and when you press it bolds it and when go back to word you bolded previously , you can unbold it
This looks good UX for mobile users, did you make this using this library ? Because I think that it's not possible to do it with the available public Api's.
I was trying to mimic the UX of the most common rich text editors. I'll think of adding some option to make this possible.
The code is available , I've made a link to it , It works with Annotated String and text field value that the outlined text field holds , only problem was retaining styles due to an unavailable saver implementation
Currently the editor options support addCode, addBold, This is like a toggle which turns on and user keeps going with the styles
However some people prefer editing differently , like myself , for example when I click bold , I want editor to grab the current word and just make it bold , unless I have a selection, This also allows editor to have no state other than selection, Not that previous API shouldn't be the way, but there's no way currently to do the above.
So Editor State of isBold on currently , isItalic on should be separated from the editor and allowed to have a different state
I implemented this initially in my editor which doesn't retain styles
https://github.com/Qawaz/markdown-compose/blob/5293904088ab9ace4d4b1e7e7788437cadd513d6/md-compose-core/src/commonMain/kotlin/com/wakaztahir/markdowncompose/editor/utils/TextFormatter.kt#L121