From 2f1e93bb0c0fe7c3ff745d7d55c0b753dd7c0025 Mon Sep 17 00:00:00 2001 From: CodeDoctorDE Date: Thu, 9 Nov 2023 17:12:21 +0100 Subject: [PATCH] Add more markdown element types --- FLUTTER_VERSION | 2 +- app/lib/l10n/app_en.arb | 5 +++- app/lib/pages/notes/card.dart | 47 +++++++++++++++++++++++++++++------ app/pubspec.lock | 4 +-- app/pubspec.yaml | 2 +- 5 files changed, 48 insertions(+), 12 deletions(-) diff --git a/FLUTTER_VERSION b/FLUTTER_VERSION index d9180228ae9..a1259111daa 100644 --- a/FLUTTER_VERSION +++ b/FLUTTER_VERSION @@ -1 +1 @@ -3.16.0-0.4.pre \ No newline at end of file +3.16.0-0.5.pre \ No newline at end of file diff --git a/app/lib/l10n/app_en.arb b/app/lib/l10n/app_en.arb index 7f6b50988e7..a39cafc3922 100644 --- a/app/lib/l10n/app_en.arb +++ b/app/lib/l10n/app_en.arb @@ -284,5 +284,8 @@ "italic": "Italic", "strikethrough": "Strikethrough", "code": "Code", - "link": "Link" + "link": "Link", + "codeBlock": "Code block", + "quote": "Quote", + "numberedList": "Numbered list" } \ No newline at end of file diff --git a/app/lib/pages/notes/card.dart b/app/lib/pages/notes/card.dart index 39a6a827953..670d671a883 100644 --- a/app/lib/pages/notes/card.dart +++ b/app/lib/pages/notes/card.dart @@ -103,7 +103,7 @@ class _NoteCardState extends State { } } - void _addDescription(PastePositing position, String text) { + void _addDescription(PastePositing position, String text, [String? endText]) { var description = _descriptionController.text; final selection = _descriptionController.selection; if (!selection.isValid) return; @@ -117,7 +117,7 @@ class _NoteCardState extends State { PastePositing.selection => description.substring(0, start) + text + description.substring(start, end) + - text + + (endText ?? text) + description.substring(end), }; _descriptionController.text = description; @@ -366,6 +366,35 @@ class _NoteCardState extends State { "${"#" * (index + 1)} ", ), )), + ...[ + ( + '```', + PhosphorIconsLight.codeSimple, + AppLocalizations.of(context).codeBlock + ), + ( + '>', + PhosphorIconsLight.quotes, + AppLocalizations.of(context).quote + ), + ( + '- ', + PhosphorIconsLight.list, + AppLocalizations.of(context).list + ), + ( + '1. ', + PhosphorIconsLight.listNumbers, + AppLocalizations.of(context).numberedList + ), + ].map((e) => IconButton( + icon: PhosphorIcon(e.$2), + tooltip: e.$3, + onPressed: () => _addDescription( + PastePositing.line, + e.$1, + ), + )), const SizedBox(width: 8), ...[ ( @@ -388,11 +417,6 @@ class _NoteCardState extends State { PhosphorIconsLight.code, AppLocalizations.of(context).code ), - ( - '[', - PhosphorIconsLight.link, - AppLocalizations.of(context).link - ), ].map((e) => IconButton( icon: PhosphorIcon(e.$2), tooltip: e.$3, @@ -401,6 +425,15 @@ class _NoteCardState extends State { e.$1, ), )), + IconButton( + icon: const PhosphorIcon(PhosphorIconsLight.link), + tooltip: AppLocalizations.of(context).link, + onPressed: () => _addDescription( + PastePositing.selection, + '[', + ']()', + ), + ), ]), ), ), diff --git a/app/pubspec.lock b/app/pubspec.lock index ce5759019e3..1c7b55aa3c4 100644 --- a/app/pubspec.lock +++ b/app/pubspec.lock @@ -375,10 +375,10 @@ packages: dependency: "direct main" description: name: flutter_markdown - sha256: "8afc9a6aa6d8e8063523192ba837149dbf3d377a37c0b0fc579149a1fbd4a619" + sha256: "35108526a233cc0755664d445f8a6b4b61e6f8fe993b3658b80b4a26827fc196" url: "https://pub.dev" source: hosted - version: "0.6.18" + version: "0.6.18+2" flutter_plugin_android_lifecycle: dependency: transitive description: diff --git a/app/pubspec.yaml b/app/pubspec.yaml index 503912a64b3..82b2948d245 100644 --- a/app/pubspec.yaml +++ b/app/pubspec.yaml @@ -69,7 +69,7 @@ dependencies: connectivity_plus: ^5.0.1 rxdart: ^0.27.7 flutter_secure_storage: ^9.0.0 - flutter_markdown: ^0.6.17+2 + flutter_markdown: ^0.6.18+2 markdown: ^7.1.1 args: ^2.4.2 lib5: ^0.1.0