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

Feat: customizable character and space shortcut events #2228

Merged
merged 19 commits into from
Sep 15, 2024

Conversation

CatHood0
Copy link
Collaborator

@CatHood0 CatHood0 commented Sep 14, 2024

Description

A new possibility to add real-time shortcuts has been created using CharacterShortcutEvent and SpaceShorcutEvent. Both are executed when _onKeyEvent is called, however, checks are made to not execute everything at the same time first (this could be subject to change in order to improve the performance of the operations).

CharacterShorcutEvent is a class that is called in a general way every time the user types something inside the editor (these events are ignored and the key is space, tab, or a new line).

SpaceShorcutEvent is a class that is only called (as its name says) when the space key is pressed.

Example

Without shorcuts implemented

With shorcuts implemented

showcases.mp4
  • New feature: Adds new functionality without breaking existing features.
  • 🛠️ Bug fix: Resolves an issue without altering current behavior.
  • 🧹 Code refactor: Code restructuring that does not affect behavior.
  • Breaking change: Alters existing functionality and requires updates.
  • 🧪 Tests: Adds new tests or modifies existing tests.
  • 📝 Documentation: Updates or additions to documentation.
  • 🗑️ Chore: Routine tasks, or maintenance.
  • Build configuration change: Changes to build or deploy processes.

@CatHood0 CatHood0 changed the title Markdown shortcuts Feat: customizable character and space shorcuts events Sep 14, 2024
@CatHood0 CatHood0 changed the title Feat: customizable character and space shorcuts events Feat: customizable character and space shortcut events Sep 14, 2024
@CatHood0 CatHood0 self-assigned this Sep 14, 2024
@CatHood0 CatHood0 added enhancement New feature or request documentation Improvements or additions to documentation labels Sep 14, 2024
@CatHood0 CatHood0 marked this pull request as draft September 14, 2024 21:52
Copy link
Collaborator

@AtlasAutocode AtlasAutocode left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like this is cleaning up a lot of complex code and enabling a lot of potential for customization. Without trying the code, the only thing that worries me is typing in the following:

Multiplication example: 2 * 3 = 6, whereas the product of 3 * 4 = 12

Would that appear as:

Multiplication example: 2 3 = 6, whereas the product of 3 4 = 12

where the text is converted to italic when it should not be.
Is there a way of saying not to apply the conversion - I really want an asterisk here.
Asterisk is also used as a superscript to refer to a footnote. Would that also trigger the conversion?

On desktops, it is easier to just use control+i (windows, or mac Cmd+i? linux?) to turn on/off italic so it would never occur to me to use markdown syntax. For mobile, the reverse would be true!

@CatHood0
Copy link
Collaborator Author

CatHood0 commented Sep 15, 2024

where the text is converted to italic when it should not be.
Is there a way of saying not to apply the conversion - I really want an asterisk here.
Asterisk is also used as a superscript to refer to a footnote. Would that also trigger the conversion?

There will always be one condition for CharacterShortcutEvents (at least the default ones), and that is, in this case at least, the asterisk needs and must be the one on the right side. That is, if I insert an asterisk on the right and then one on the left, it will not be applied (because it is not what is wanted by default).

Would that appear as:
Multiplication example: 2 3 = 6, whereas the product of 3 4 = 12

If you use the default implementations, yeah. That's a limitation.

I know it may seem a bit confusing, because it is new and probably requires more documentation, but in this case of asterisks the handler could be bypassed if we put the asterisk on the right first and then the one on the left. However, if in your case, at least you want this type of text block to be ignored, you can always create your own handler to ignore any asterisk that is between numbers.

Note

By default, there are not implemented any CharacterShortcutEvent or SpaceShortcutEvent in the editor. The user is who must call standardCharacterShortcutEvents to have these implementations.

@CatHood0 CatHood0 marked this pull request as ready for review September 15, 2024 15:58
@CatHood0 CatHood0 marked this pull request as draft September 15, 2024 16:04
@CatHood0 CatHood0 marked this pull request as ready for review September 15, 2024 16:08
@singerdmx singerdmx merged commit 289139b into singerdmx:master Sep 15, 2024
2 checks passed
@CatHood0 CatHood0 deleted the markdown_shortcuts branch September 15, 2024 17:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants