matrix-org / matrix-rich-text-editor

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

Auto-replace plain text with emoji #1009

Closed langleyd closed 2 months ago

langleyd commented 3 months ago

What's included this PR?

Custom Suggestion Pattern API and Auto-replace plain text with emoji feature(Web only so far). E.g.:) => 🙂

What does it look like?

https://github.com/matrix-org/matrix-rich-text-editor/assets/6135282/0a7e6ccf-d303-464f-bc79-6c01d921dd90

Implementation detail

I considered 2 approaches for this:

  1. Initially I considered passing all of the text-to-emoji mappings and have all the logic on the rust side to do the replacement when the text changes. The advantage to this is that it maximises code re-use on the rust side.
  2. Then I considered extending the Suggestions api(that slash commands and mentions are built upon) to support "custom" suggestion patterns(in addition to the existing static ones /,@, #). The advantage of this is that it builds upon an existing pattern rather than creating a new way of doing things. It also gives flexibility to the client as to how the feature works. The version implemented works as the web-client does, by automatically replacing the suggestions, but there has been a suggestion previously that it should work as it does on Telegram where suggestions are rendered first from which the user can choose to accept:

image

codecov-commenter commented 3 months ago

Codecov Report

Attention: Patch coverage is 76.75676% with 43 lines in your changes missing coverage. Please review.

Project coverage is 90.14%. Comparing base (4c50704) to head (0bb2c9e).

Files Patch % Lines
bindings/wysiwyg-wasm/src/lib.rs 0.00% 40 Missing :warning:
bindings/wysiwyg-ffi/src/ffi_composer_model.rs 81.81% 2 Missing :warning:
bindings/wysiwyg-ffi/src/ffi_pattern_key.rs 50.00% 1 Missing :warning:
Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #1009 +/- ## ========================================== - Coverage 90.19% 90.14% -0.05% ========================================== Files 179 179 Lines 21468 21627 +159 Branches 280 292 +12 ========================================== + Hits 19363 19496 +133 - Misses 2102 2128 +26 Partials 3 3 ``` | [Flag](https://app.codecov.io/gh/matrix-org/matrix-rich-text-editor/pull/1009/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/1009/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=matrix-org) | `84.61% <50.00%> (ø)` | | | [uitests-ios](https://app.codecov.io/gh/matrix-org/matrix-rich-text-editor/pull/1009/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=matrix-org) | `84.61% <50.00%> (ø)` | | | [unittests](https://app.codecov.io/gh/matrix-org/matrix-rich-text-editor/pull/1009/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=matrix-org) | `89.23% <76.75%> (-0.05%)` | :arrow_down: | | [unittests-ios](https://app.codecov.io/gh/matrix-org/matrix-rich-text-editor/pull/1009/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=matrix-org) | `87.57% <100.00%> (ø)` | | | [unittests-react](https://app.codecov.io/gh/matrix-org/matrix-rich-text-editor/pull/1009/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=matrix-org) | `89.35% <100.00%> (+0.70%)` | :arrow_up: | | [unittests-rust](https://app.codecov.io/gh/matrix-org/matrix-rich-text-editor/pull/1009/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=matrix-org) | `89.50% <62.28%> (-0.18%)` | :arrow_down: | 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.

sonarcloud[bot] commented 2 months ago

Quality Gate Passed Quality Gate passed

Issues
2 New issues
0 Accepted issues

Measures
0 Security Hotspots
98.8% Coverage on New Code
0.0% Duplication on New Code

See analysis details on SonarCloud