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

Allow implementing editor actions differently #67

Open
wakaztahir opened this issue Jul 18, 2023 · 7 comments
Open

Allow implementing editor actions differently #67

wakaztahir opened this issue Jul 18, 2023 · 7 comments

Comments

@wakaztahir
Copy link
Contributor

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

@MohamedRejeb
Copy link
Owner

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 ?

@wakaztahir
Copy link
Contributor Author

wakaztahir commented Jul 18, 2023

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

@MohamedRejeb
Copy link
Owner

Well I still not understand your point exactly xD can you attach a short recording.

@wakaztahir
Copy link
Contributor Author

VID_20230718_194100.mp4

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

@MohamedRejeb
Copy link
Owner

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.

@MohamedRejeb
Copy link
Owner

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.

@wakaztahir
Copy link
Contributor Author

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

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

No branches or pull requests

2 participants