[3.5.3] Change link button behavior

pull/602/head
X Code 3 years ago
parent 702bb2a9b9
commit c89779b4a6
  1. 3
      CHANGELOG.md
  2. 14
      lib/src/translations/toolbar.i18n.dart
  3. 2
      lib/src/widgets/toolbar/link_dialog.dart
  4. 18
      lib/src/widgets/toolbar/link_style_button.dart
  5. 2
      pubspec.yaml

@ -1,3 +1,6 @@
# [3.5.3]
* Change link button behavior.
# [3.5.2] # [3.5.2]
* Bug fix for embed. * Bug fix for embed.

@ -17,6 +17,7 @@ extension Localization on String {
'Save': 'Save', 'Save': 'Save',
'Zoom': 'Zoom', 'Zoom': 'Zoom',
'Saved': 'Saved', 'Saved': 'Saved',
'Text': 'Text',
}, },
'ar': { 'ar': {
'Paste a link': 'نسخ الرابط', 'Paste a link': 'نسخ الرابط',
@ -32,6 +33,7 @@ extension Localization on String {
'Save': 'يحفظ', 'Save': 'يحفظ',
'Zoom': 'تكبير', 'Zoom': 'تكبير',
'Saved': 'أنقذ', 'Saved': 'أنقذ',
'Text': 'Text',
}, },
'da': { 'da': {
'Paste a link': 'Indsæt link', 'Paste a link': 'Indsæt link',
@ -47,6 +49,7 @@ extension Localization on String {
'Save': 'Gemme', 'Save': 'Gemme',
'Zoom': 'Zoom ind', 'Zoom': 'Zoom ind',
'Saved': 'Gemt', 'Saved': 'Gemt',
'Text': 'Text',
}, },
'de': { 'de': {
'Paste a link': 'Link hinzufügen', 'Paste a link': 'Link hinzufügen',
@ -63,6 +66,7 @@ extension Localization on String {
'Save': 'Speichern', 'Save': 'Speichern',
'Zoom': 'Zoomen', 'Zoom': 'Zoomen',
'Saved': 'Gerettet', 'Saved': 'Gerettet',
'Text': 'Text',
}, },
'fr': { 'fr': {
'Paste a link': 'Coller un lien', 'Paste a link': 'Coller un lien',
@ -78,6 +82,7 @@ extension Localization on String {
'Save': 'Sauvegarder', 'Save': 'Sauvegarder',
'Zoom': 'Zoom', 'Zoom': 'Zoom',
'Saved': 'Enregistrée', 'Saved': 'Enregistrée',
'Text': 'Text',
}, },
'zh_CN': { 'zh_CN': {
'Paste a link': '粘贴链接', 'Paste a link': '粘贴链接',
@ -93,6 +98,7 @@ extension Localization on String {
'Save': '保存', 'Save': '保存',
'Zoom': '放大', 'Zoom': '放大',
'Saved': '已保存', 'Saved': '已保存',
'Text': '文字',
}, },
'ko': { 'ko': {
'Paste a link': '링크를 붙여넣어 주세요.', 'Paste a link': '링크를 붙여넣어 주세요.',
@ -108,6 +114,7 @@ extension Localization on String {
'Save': '저장하기', 'Save': '저장하기',
'Zoom': '확대하기', 'Zoom': '확대하기',
'Saved': '저장되었습니다.', 'Saved': '저장되었습니다.',
'Text': 'Text',
}, },
'ru': { 'ru': {
'Paste a link': 'Вставить ссылку', 'Paste a link': 'Вставить ссылку',
@ -123,6 +130,7 @@ extension Localization on String {
'Save': 'Сохранять', 'Save': 'Сохранять',
'Zoom': 'Увеличить', 'Zoom': 'Увеличить',
'Saved': 'Сохранено', 'Saved': 'Сохранено',
'Text': 'Text',
}, },
'es': { 'es': {
'Paste a link': 'Pega un enlace', 'Paste a link': 'Pega un enlace',
@ -139,6 +147,7 @@ extension Localization on String {
'Save': 'Ahorrar', 'Save': 'Ahorrar',
'Zoom': 'Zoom', 'Zoom': 'Zoom',
'Saved': 'Salvado', 'Saved': 'Salvado',
'Text': 'Text',
}, },
'tr': { 'tr': {
'Paste a link': 'Bağlantıyı Yapıştır', 'Paste a link': 'Bağlantıyı Yapıştır',
@ -154,6 +163,7 @@ extension Localization on String {
'Save': 'Kayıt etmek', 'Save': 'Kayıt etmek',
'Zoom': 'yakınlaştır', 'Zoom': 'yakınlaştır',
'Saved': 'kaydedildi', 'Saved': 'kaydedildi',
'Text': 'Text',
}, },
'uk': { 'uk': {
'Paste a link': 'Вставити посилання', 'Paste a link': 'Вставити посилання',
@ -169,6 +179,7 @@ extension Localization on String {
'Save': 'Зберегти', 'Save': 'Зберегти',
'Zoom': 'Збільшити', 'Zoom': 'Збільшити',
'Saved': 'Збережено', 'Saved': 'Збережено',
'Text': 'Text',
}, },
'pt': { 'pt': {
'Paste a link': 'Colar um link', 'Paste a link': 'Colar um link',
@ -185,6 +196,7 @@ extension Localization on String {
'Save': 'Salve', 'Save': 'Salve',
'Zoom': 'Ampliação', 'Zoom': 'Ampliação',
'Saved': 'Salvou', 'Saved': 'Salvou',
'Text': 'Text',
}, },
'pl': { 'pl': {
'Paste a link': 'Wklej link', 'Paste a link': 'Wklej link',
@ -200,6 +212,7 @@ extension Localization on String {
'Save': 'Zapisać', 'Save': 'Zapisać',
'Zoom': 'Powiększenie', 'Zoom': 'Powiększenie',
'Saved': 'Zapisane', 'Saved': 'Zapisane',
'Text': 'Text',
}, },
'vi': { 'vi': {
'Paste a link': 'Chèn liên kết', 'Paste a link': 'Chèn liên kết',
@ -215,6 +228,7 @@ extension Localization on String {
'Save': 'Lưu', 'Save': 'Lưu',
'Zoom': 'Thu phóng', 'Zoom': 'Thu phóng',
'Saved': 'Đã lưu', 'Saved': 'Đã lưu',
'Text': 'Text',
}, },
}; };

@ -31,7 +31,7 @@ class LinkDialogState extends State<LinkDialog> {
content: TextField( content: TextField(
style: widget.dialogTheme?.inputTextStyle, style: widget.dialogTheme?.inputTextStyle,
decoration: InputDecoration( decoration: InputDecoration(
labelText: 'Paste a link'.i18n, labelText: 'Link'.i18n,
labelStyle: widget.dialogTheme?.labelTextStyle, labelStyle: widget.dialogTheme?.labelTextStyle,
floatingLabelStyle: widget.dialogTheme?.labelTextStyle), floatingLabelStyle: widget.dialogTheme?.labelTextStyle),
autofocus: true, autofocus: true,

@ -59,8 +59,8 @@ class _LinkStyleButtonState extends State<LinkStyleButton> {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
final theme = Theme.of(context); final theme = Theme.of(context);
final isEnabled = !widget.controller.selection.isCollapsed; final isToggled = _getLinkAttributeValue() != null;
final pressedHandler = isEnabled ? () => _openLinkDialog(context) : null; final pressedHandler = () => _openLinkDialog(context);
return GestureDetector( return GestureDetector(
onTap: () async { onTap: () async {
final dynamic tooltip = _toolTipKey.currentState; final dynamic tooltip = _toolTipKey.currentState;
@ -82,7 +82,7 @@ class _LinkStyleButtonState extends State<LinkStyleButton> {
icon: Icon( icon: Icon(
widget.icon ?? Icons.link, widget.icon ?? Icons.link,
size: widget.iconSize, size: widget.iconSize,
color: isEnabled color: isToggled
? (widget.iconTheme?.iconUnselectedColor ?? ? (widget.iconTheme?.iconUnselectedColor ??
theme.iconTheme.color) theme.iconTheme.color)
: (widget.iconTheme?.disabledIconColor ?? theme.disabledColor), : (widget.iconTheme?.disabledIconColor ?? theme.disabledColor),
@ -99,15 +99,19 @@ class _LinkStyleButtonState extends State<LinkStyleButton> {
showDialog<String>( showDialog<String>(
context: context, context: context,
builder: (ctx) { builder: (ctx) {
final link = widget.controller final link = _getLinkAttributeValue();
.getSelectionStyle()
.attributes[Attribute.link.key]
?.value;
return LinkDialog(dialogTheme: widget.dialogTheme, link: link); return LinkDialog(dialogTheme: widget.dialogTheme, link: link);
}, },
).then(_linkSubmitted); ).then(_linkSubmitted);
} }
String? _getLinkAttributeValue() {
return widget.controller
.getSelectionStyle()
.attributes[Attribute.link.key]
?.value;
}
void _linkSubmitted(String? value) { void _linkSubmitted(String? value) {
if (value == null || value.isEmpty) { if (value == null || value.isEmpty) {
return; return;

@ -1,6 +1,6 @@
name: flutter_quill name: flutter_quill
description: A rich text editor supporting mobile and web (Demo App @ bulletjournal.us) description: A rich text editor supporting mobile and web (Demo App @ bulletjournal.us)
version: 3.5.2 version: 3.5.3
#author: bulletjournal #author: bulletjournal
homepage: https://bulletjournal.us/home/index.html homepage: https://bulletjournal.us/home/index.html
repository: https://github.com/singerdmx/flutter-quill repository: https://github.com/singerdmx/flutter-quill

Loading…
Cancel
Save