-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Julian KOUNE
committed
Dec 16, 2023
1 parent
014be33
commit b3dd975
Showing
3 changed files
with
41 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
# 13. Converting Linebreaks in SDK | ||
|
||
Date: 2023-13-12 | ||
|
||
## Status | ||
|
||
Accepted | ||
|
||
## Context | ||
|
||
In Twake Chat, we allow users to send messages with linebreaks. However, we only limit them to 2 linebreaks in a row. This is to prevent users from sending messages with too many linebreaks, which would make the chat hard to read. | ||
|
||
## Decision | ||
|
||
- Add a new method (syntax) to the SDK that converts more then 2 linebreaks in a row to 1 linebreak. | ||
- Process the whole message and not line by line before sending it to the server. | ||
|
||
```dart | ||
class MultipleLinebreaksSyntax extends InlineSyntax { | ||
MultipleLinebreaksSyntax() : super(r'\n{2,}'); | ||
@override | ||
bool onMatch(InlineParser parser, Match match) { | ||
parser.addNode(Element.empty('br')); | ||
return true; | ||
} | ||
} | ||
``` | ||
|
||
The regex `r'\n{2,}'` matches 2 or more linebreaks in a row. | ||
If the regex matches, we replace the linebreaks with a `<br>` tag. | ||
|
||
```dart | ||
## Consequences | ||
- The SDK will be able to convert more than 2 linebreaks in a row to 1 linebreak. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -949,8 +949,8 @@ packages: | |
dependency: "direct main" | ||
description: | ||
path: "." | ||
ref: master | ||
resolved-ref: "608fb381790d068664f73e33c3277671e5e172ca" | ||
ref: TW-1135-support-br | ||
resolved-ref: "8362c0f07bd4178fd1c832f718e97941b48becfc" | ||
url: "https://github.com/linagora/flutter_matrix_html.git" | ||
source: git | ||
version: "1.2.0" | ||
|
@@ -1583,7 +1583,7 @@ packages: | |
description: | ||
path: "." | ||
ref: "twake-supported-0.22.6" | ||
resolved-ref: bfff7db647b177a0a0e04780e063bfbdd22031b8 | ||
resolved-ref: e5e67b2d0158b9398eb6430841c2bed7f61d8997 | ||
url: "[email protected]:linagora/matrix-dart-sdk.git" | ||
source: git | ||
version: "0.22.6" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters