From b3dd975ac91362183bd260cd564ee49821715e2a Mon Sep 17 00:00:00 2001 From: Julian KOUNE Date: Sat, 16 Dec 2023 09:44:42 +0100 Subject: [PATCH] TW-683: Update pub lock --- docs/adr/0013-converting-linebreaks-in-sdk.md | 37 +++++++++++++++++++ pubspec.lock | 6 +-- pubspec.yaml | 2 +- 3 files changed, 41 insertions(+), 4 deletions(-) create mode 100644 docs/adr/0013-converting-linebreaks-in-sdk.md diff --git a/docs/adr/0013-converting-linebreaks-in-sdk.md b/docs/adr/0013-converting-linebreaks-in-sdk.md new file mode 100644 index 0000000000..582c27089c --- /dev/null +++ b/docs/adr/0013-converting-linebreaks-in-sdk.md @@ -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 `
` tag. + +```dart + +## Consequences + +- The SDK will be able to convert more than 2 linebreaks in a row to 1 linebreak. \ No newline at end of file diff --git a/pubspec.lock b/pubspec.lock index 8551be9a6f..688fbabefa 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -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: "git@github.com:linagora/matrix-dart-sdk.git" source: git version: "0.22.6" diff --git a/pubspec.yaml b/pubspec.yaml index df460ef3f0..226e0d5ff9 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -112,7 +112,7 @@ dependencies: flutter_matrix_html: git: url: https://github.com/linagora/flutter_matrix_html.git - ref: master + ref: TW-1135-support-br overflow_view: ^0.3.1 json_annotation: ^4.8.1 contacts_service: