Skip to content

Commit

Permalink
Add more markdown element types
Browse files Browse the repository at this point in the history
  • Loading branch information
CodeDoctorDE committed Nov 9, 2023
1 parent 5ced129 commit 2f1e93b
Show file tree
Hide file tree
Showing 5 changed files with 48 additions and 12 deletions.
2 changes: 1 addition & 1 deletion FLUTTER_VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
3.16.0-0.4.pre
3.16.0-0.5.pre
5 changes: 4 additions & 1 deletion app/lib/l10n/app_en.arb
Original file line number Diff line number Diff line change
Expand Up @@ -284,5 +284,8 @@
"italic": "Italic",
"strikethrough": "Strikethrough",
"code": "Code",
"link": "Link"
"link": "Link",
"codeBlock": "Code block",
"quote": "Quote",
"numberedList": "Numbered list"
}
47 changes: 40 additions & 7 deletions app/lib/pages/notes/card.dart
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ class _NoteCardState extends State<NoteCard> {
}
}

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;
Expand All @@ -117,7 +117,7 @@ class _NoteCardState extends State<NoteCard> {
PastePositing.selection => description.substring(0, start) +
text +
description.substring(start, end) +
text +
(endText ?? text) +
description.substring(end),
};
_descriptionController.text = description;
Expand Down Expand Up @@ -366,6 +366,35 @@ class _NoteCardState extends State<NoteCard> {
"${"#" * (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),
...[
(
Expand All @@ -388,11 +417,6 @@ class _NoteCardState extends State<NoteCard> {
PhosphorIconsLight.code,
AppLocalizations.of(context).code
),
(
'[',
PhosphorIconsLight.link,
AppLocalizations.of(context).link
),
].map((e) => IconButton(
icon: PhosphorIcon(e.$2),
tooltip: e.$3,
Expand All @@ -401,6 +425,15 @@ class _NoteCardState extends State<NoteCard> {
e.$1,
),
)),
IconButton(
icon: const PhosphorIcon(PhosphorIconsLight.link),
tooltip: AppLocalizations.of(context).link,
onPressed: () => _addDescription(
PastePositing.selection,
'[',
']()',
),
),
]),
),
),
Expand Down
4 changes: 2 additions & 2 deletions app/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion app/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 2f1e93b

Please sign in to comment.