diff --git a/app/lib/dialogs/packs/styles/paragraphs.dart b/app/lib/dialogs/packs/styles/paragraphs.dart index 993ca17e391d..131e666edada 100644 --- a/app/lib/dialogs/packs/styles/paragraphs.dart +++ b/app/lib/dialogs/packs/styles/paragraphs.dart @@ -111,6 +111,9 @@ class _ParagraphsStyleViewState extends State { menuChildren: DocumentDefaults.getParagraphTranslations(context) .entries + .where((element) => !widget + .value.paragraphProperties + .containsKey(element.key)) .map( (e) => MenuItemButton( child: Text(e.value), @@ -128,7 +131,7 @@ class _ParagraphsStyleViewState extends State { .toList(), ), if (_currentStyle != null) ...[ - const Divider(), + const VerticalDivider(), IconButton( icon: const Icon(PhosphorIcons.pencilLight), onPressed: () async { diff --git a/app/lib/dialogs/packs/styles/texts.dart b/app/lib/dialogs/packs/styles/texts.dart index 2be1db1a6308..0c226ba98b8b 100644 --- a/app/lib/dialogs/packs/styles/texts.dart +++ b/app/lib/dialogs/packs/styles/texts.dart @@ -5,6 +5,7 @@ import 'package:flutter/material.dart'; import 'package:flutter_gen/gen_l10n/app_localizations.dart'; import 'package:phosphor_flutter/phosphor_flutter.dart'; +import '../../../models/defaults.dart'; import 'text.dart'; class TextsStyleView extends StatefulWidget { @@ -34,11 +35,10 @@ class _TextsStyleViewState extends State { @override void didUpdateWidget(covariant TextsStyleView oldWidget) { super.didUpdateWidget(oldWidget); - if (oldWidget.value != widget.value) { + if (oldWidget.value != widget.value && _currentStyle != null) { setState(() { - if (!widget.value.spanProperties.containsKey(_currentStyle!) && - _currentStyle != null) { - _currentStyle = widget.value.spanProperties.keys.firstOrNull; + if (!widget.value.spanProperties.containsKey(_currentStyle!)) { + _currentStyle = widget.value.paragraphProperties.keys.firstOrNull; } }); } @@ -94,7 +94,40 @@ class _TextsStyleViewState extends State { )); }, ), + MenuAnchor( + builder: (context, controller, _) { + return IconButton( + icon: const Icon(PhosphorIcons.listLight), + onPressed: () { + if (controller.isOpen) { + controller.close(); + } else { + controller.open(); + } + }, + ); + }, + menuChildren: DocumentDefaults.getSpanTranslations(context) + .entries + .where((element) => + !widget.value.spanProperties.containsKey(element.key)) + .map( + (e) => MenuItemButton( + child: Text(e.value), + onPressed: () { + widget.onChanged(widget.value.copyWith( + spanProperties: { + ...widget.value.spanProperties, + e.key: const text.DefinedSpanProperty(), + }, + )); + }, + ), + ) + .toList(), + ), if (_currentStyle != null) ...[ + const VerticalDivider(), IconButton( icon: const Icon(PhosphorIcons.pencilLight), onPressed: () async { diff --git a/app/lib/l10n/app_en.arb b/app/lib/l10n/app_en.arb index 34201dfd2e3c..e0fef57cfe33 100644 --- a/app/lib/l10n/app_en.arb +++ b/app/lib/l10n/app_en.arb @@ -469,7 +469,6 @@ }, "code": "Code", "quote": "Quote", - "blockquote": "Blockquote", "link": "Link", "checkbox": "Checkbox", "deleted": "Deleted", diff --git a/app/lib/models/defaults.dart b/app/lib/models/defaults.dart index 9c0764bfcf8f..e4f2c8d3e48c 100644 --- a/app/lib/models/defaults.dart +++ b/app/lib/models/defaults.dart @@ -45,13 +45,13 @@ class DocumentDefaults { 'p': AppLocalizations.of(context).paragraph, 'quote': AppLocalizations.of(context).quote, 'code': AppLocalizations.of(context).code, - 'blockquote': AppLocalizations.of(context).blockquote, + 'blockquote': AppLocalizations.of(context).quote, }; static String translateParagraph(String key, BuildContext context) => translate(key, getParagraphTranslations(context)); - static Map getBlockTranslations(BuildContext context) => { + static Map getSpanTranslations(BuildContext context) => { 'a': AppLocalizations.of(context).link, 'checkbox': AppLocalizations.of(context).checkbox, 'del': AppLocalizations.of(context).deleted, @@ -62,5 +62,5 @@ class DocumentDefaults { }; static String translateBlock(String key, BuildContext context) => - translate(key, getBlockTranslations(context)); + translate(key, getSpanTranslations(context)); }