Skip to content
This repository has been archived by the owner on Sep 27, 2024. It is now read-only.

[iOS] Key Commands Refactor #908

Merged
merged 2 commits into from
Dec 14, 2023
Merged

[iOS] Key Commands Refactor #908

merged 2 commits into from
Dec 14, 2023

Conversation

Velin92
Copy link
Member

@Velin92 Velin92 commented Dec 13, 2023

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 command was still handled by the TextView, which was then preventing the key to use the replace text function in the delegate properly, which means that shift+enter and enter were not doing anything.
  • The ignored command was not really ignored at all, but just silently handled in the background, which kinda created a side effect that was not clear to the user of the library

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.

# Conflicts:
#	platforms/ios/example/Wysiwyg/Views/ContentView.swift
#	platforms/ios/lib/WysiwygComposer/Sources/WysiwygComposer/Components/WysiwygComposerView/WysiwygComposerView.swift
#	platforms/ios/lib/WysiwygComposer/Sources/WysiwygComposer/Components/WysiwygComposerView/WysiwygTextView.swift
#	platforms/ios/lib/WysiwygComposer/Sources/WysiwygComposer/Components/WysiwygKeyCommand.swift
@Velin92 Velin92 requested review from pixlwave and langleyd December 13, 2023 20:11
@Velin92 Velin92 added the iOS label Dec 13, 2023
Copy link

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
Copy link

codecov-commenter commented Dec 13, 2023

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 ⚠️
...ents/WysiwygComposerView/WysiwygComposerView.swift 83.33% 1 Missing ⚠️
Additional details and impacted files
@@             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 Coverage Δ
uitests 78.89% <76.92%> (+7.98%) ⬆️
uitests-android ?
uitests-ios 78.89% <76.92%> (+0.87%) ⬆️
unittests 88.15% <0.00%> (+2.75%) ⬆️
unittests-android ?
unittests-ios 75.54% <0.00%> (+1.61%) ⬆️
unittests-rust 89.42% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Member

@pixlwave pixlwave left a comment

Choose a reason for hiding this comment

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

Whilst I'm not familiar with the insides of RTE, this looks like a totally reasonable change to me and makes the API much nicer to use to my eyes.

@Velin92 Velin92 merged commit efe567d into main Dec 14, 2023
7 checks passed
@Velin92 Velin92 deleted the mauroromito/better_key_commands branch December 14, 2023 09:10
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants