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

Feature Request: Make formatting actions toggle instead of only adding #29

Open
soryy708 opened this issue Mar 12, 2019 · 5 comments
Open
Labels
help wanted Extra attention is needed refactor Refactors existing code

Comments

@soryy708
Copy link
Contributor

Is your feature request related to a problem? Please describe.
Currently, every time you do a formatting action (use a hotkey, or press a button), it adds a new tag.
This is not intuitive, because users are used to UX like in MS-Word, where for example pressing Bold on already bold text makes it not bold.

Describe the solution you'd like
Make formatting actions toggle instead of only adding

Describe alternatives you've considered
Or don't.

Additional context
N/A

@soryy708 soryy708 added the enhancement New feature or request label Mar 12, 2019
@Dibasic
Copy link
Owner

Dibasic commented Mar 12, 2019

How I'm imagining this could work:

  • If the beginning of the selected text is on or immediately after a [starting] tag, delete it and create a new [starting] tag at the end of the selected text

  • Else, if the ending of the selected text is on or immediately before an [/ending] tag, delete it and create a new [/ending] tag at the beginning of the selected text

  • Else, create an [/ending] tag at the beginning and a [starting] tag at the end of the selected text

  • If the above results in an [empty][/empty] set of tags, delete them

@soryy708
Copy link
Contributor Author

soryy708 commented Mar 12, 2019

@Dibasic That would potentially generate invalid XML / HTML.

Consider the following:

[u]Hello [b]world[/b][/u]

Where the selected text is:

[u]Hello [b]wo

We will end up with

Hello [b]wo[u]rld[/b][/u]

@soryy708
Copy link
Contributor Author

soryy708 commented Mar 12, 2019

How I'm imagining this could work:

  • If either end of selection is child of the tag we're adding, delete that parent.
  • Else, wrap selection in that tag

This ensures valid XML/HTML, but acts a little strange. If you have any amount of characters selected in a bold line, and you perform the bold formatting action, the entire line will stop being bold.

@Dibasic Dibasic added the help wanted Extra attention is needed label Mar 13, 2019
@Dibasic
Copy link
Owner

Dibasic commented Mar 13, 2019

Tricky. I don't know how this should behave if the user selects something that spans several tags, spans more closing tags than opening tags, etc.

@soryy708
Copy link
Contributor Author

Overall tricky feature. Perhaps look in to how other WYSIWYG editors accomplish this?

@Dibasic Dibasic added refactor Refactors existing code and removed enhancement New feature or request labels Mar 14, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed refactor Refactors existing code
Projects
None yet
Development

No branches or pull requests

2 participants