matrix-org / matrix-rich-text-editor

Matrix Rich Text Editor
https://matrix-org.github.io/matrix-rich-text-editor/
Apache License 2.0
84 stars 20 forks source link

[iOS] Key Commands Refactor #908

Closed Velin92 closed 7 months ago

Velin92 commented 7 months ago

The issue with the current KeyCommandsHandler, is that even if the key command is set to be false, the command is not really ignored and was stll being handled by the default function, which at the same time was not working properly with plain text mode since it forced an update in the model.

Also the usage of the enter() function was redundant also for the RTE mode, since we already handle the enter directly in the replaceText properly, and we are constraining the usage of the key commands only to the ones we have defined in the library not giving to the users of the library a proper control on which and when they should be and should enabled.

The alternative approach was to disabled the default handling in plain text mode for such commands, but this created two issues:

The current solution allows full control and customisation for the key commands while also providing the possibility of creating some default rapid key commands (like .enter) for the general use cases, while also fixing the shift+enter bug in plain text mode.

sonarcloud[bot] commented 7 months ago

Quality Gate Passed Quality Gate passed

Kudos, no new issues were introduced!

0 New issues
0 Security Hotspots
No data about Coverage
No data about Duplication

See analysis details on SonarCloud

codecov-commenter commented 7 months ago

Codecov Report

Attention: 3 lines in your changes are missing coverage. Please review.

Comparison is base (91fae40) 87.39% compared to head (200c096) 89.49%.

Files Patch % Lines
...mponents/WysiwygComposerView/WysiwygTextView.swift 60.00% 2 Missing :warning:
...ents/WysiwygComposerView/WysiwygComposerView.swift 83.33% 1 Missing :warning:
Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #908 +/- ## ============================================ + Coverage 87.39% 89.49% +2.09% ============================================ Files 166 118 -48 Lines 19027 16906 -2121 Branches 1052 616 -436 ============================================ - Hits 16629 15130 -1499 + Misses 2096 1752 -344 + Partials 302 24 -278 ``` | [Flag](https://app.codecov.io/gh/matrix-org/matrix-rich-text-editor/pull/908/flags?src=pr&el=flags&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=matrix-org) | Coverage Δ | | |---|---|---| | [uitests](https://app.codecov.io/gh/matrix-org/matrix-rich-text-editor/pull/908/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=matrix-org) | `78.89% <76.92%> (+7.98%)` | :arrow_up: | | [uitests-android](https://app.codecov.io/gh/matrix-org/matrix-rich-text-editor/pull/908/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=matrix-org) | `?` | | | [uitests-ios](https://app.codecov.io/gh/matrix-org/matrix-rich-text-editor/pull/908/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=matrix-org) | `78.89% <76.92%> (+0.87%)` | :arrow_up: | | [unittests](https://app.codecov.io/gh/matrix-org/matrix-rich-text-editor/pull/908/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=matrix-org) | `88.15% <0.00%> (+2.75%)` | :arrow_up: | | [unittests-android](https://app.codecov.io/gh/matrix-org/matrix-rich-text-editor/pull/908/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=matrix-org) | `?` | | | [unittests-ios](https://app.codecov.io/gh/matrix-org/matrix-rich-text-editor/pull/908/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=matrix-org) | `75.54% <0.00%> (+1.61%)` | :arrow_up: | | [unittests-rust](https://app.codecov.io/gh/matrix-org/matrix-rich-text-editor/pull/908/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=matrix-org) | `89.42% <ø> (ø)` | | Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=matrix-org#carryforward-flags-in-the-pull-request-comment) to find out more.

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.