|
|
|
@ -7,6 +7,7 @@ import '../../../translations.dart'; |
|
|
|
|
import '../../models/documents/attribute.dart'; |
|
|
|
|
import '../../models/themes/quill_dialog_theme.dart'; |
|
|
|
|
import '../../models/themes/quill_icon_theme.dart'; |
|
|
|
|
import '../../utils/widgets.dart'; |
|
|
|
|
import '../controller.dart'; |
|
|
|
|
import '../link.dart'; |
|
|
|
|
import '../toolbar.dart'; |
|
|
|
@ -232,8 +233,10 @@ class _LinkStyleDialogState extends State<LinkStyleDialog> { |
|
|
|
|
_isEditMode = _link.isNotEmpty; |
|
|
|
|
_linkController = TextEditingController.fromValue( |
|
|
|
|
TextEditingValue( |
|
|
|
|
text: _isEditMode ? _link : _text, |
|
|
|
|
selection: TextSelection(baseOffset: 0, extentOffset: _text.length), |
|
|
|
|
text: _isEditMode ? _link : '', |
|
|
|
|
selection: _isEditMode |
|
|
|
|
? TextSelection(baseOffset: 0, extentOffset: _link.length) |
|
|
|
|
: const TextSelection.collapsed(offset: 0), |
|
|
|
|
), |
|
|
|
|
); |
|
|
|
|
} |
|
|
|
@ -255,27 +258,23 @@ class _LinkStyleDialogState extends State<LinkStyleDialog> { |
|
|
|
|
.style |
|
|
|
|
?.copyWith(fixedSize: MaterialStatePropertyAll(widget.buttonSize)) |
|
|
|
|
: widget.dialogTheme?.buttonStyle; |
|
|
|
|
; |
|
|
|
|
|
|
|
|
|
return Dialog( |
|
|
|
|
backgroundColor: widget.dialogTheme?.dialogBackgroundColor, |
|
|
|
|
shape: widget.dialogTheme?.shape ?? |
|
|
|
|
DialogTheme.of(context).shape ?? |
|
|
|
|
RoundedRectangleBorder(borderRadius: BorderRadius.circular(4)), |
|
|
|
|
child: ConstrainedBox( |
|
|
|
|
constraints: constraints, |
|
|
|
|
child: Padding( |
|
|
|
|
padding: widget.contentPadding, |
|
|
|
|
child: Row( |
|
|
|
|
children: [ |
|
|
|
|
if (_isEditMode) ...[ |
|
|
|
|
final isWrappable = widget.dialogTheme?.isWrappable ?? false; |
|
|
|
|
|
|
|
|
|
final children = _isEditMode |
|
|
|
|
? [ |
|
|
|
|
Text(widget.editLinkLabel ?? 'Visit link'.i18n), |
|
|
|
|
Expanded( |
|
|
|
|
UtilityWidgets.maybeWidget( |
|
|
|
|
enabled: !isWrappable, |
|
|
|
|
wrapper: (child) => Expanded( |
|
|
|
|
child: Align( |
|
|
|
|
alignment: Alignment.centerLeft, |
|
|
|
|
child: child, |
|
|
|
|
), |
|
|
|
|
), |
|
|
|
|
child: Padding( |
|
|
|
|
padding: EdgeInsets.symmetric( |
|
|
|
|
horizontal: widget.childrenSpacing), |
|
|
|
|
padding: |
|
|
|
|
EdgeInsets.symmetric(horizontal: widget.childrenSpacing), |
|
|
|
|
child: Link( |
|
|
|
|
uri: Uri.parse(_linkController.text), |
|
|
|
|
builder: (context, followLink) { |
|
|
|
@ -288,8 +287,7 @@ class _LinkStyleDialogState extends State<LinkStyleDialog> { |
|
|
|
|
widget.link!, |
|
|
|
|
textAlign: TextAlign.left, |
|
|
|
|
overflow: TextOverflow.ellipsis, |
|
|
|
|
style: |
|
|
|
|
widget.dialogTheme?.inputTextStyle?.copyWith( |
|
|
|
|
style: widget.dialogTheme?.inputTextStyle?.copyWith( |
|
|
|
|
color: widget.linkColor ?? Colors.blue, |
|
|
|
|
decoration: TextDecoration.underline, |
|
|
|
|
), |
|
|
|
@ -299,7 +297,6 @@ class _LinkStyleDialogState extends State<LinkStyleDialog> { |
|
|
|
|
), |
|
|
|
|
), |
|
|
|
|
), |
|
|
|
|
), |
|
|
|
|
ElevatedButton( |
|
|
|
|
onPressed: () { |
|
|
|
|
setState(() { |
|
|
|
@ -317,12 +314,17 @@ class _LinkStyleDialogState extends State<LinkStyleDialog> { |
|
|
|
|
child: Text('Remove'.i18n), |
|
|
|
|
), |
|
|
|
|
), |
|
|
|
|
] else ...[ |
|
|
|
|
] |
|
|
|
|
: [ |
|
|
|
|
Text(widget.addLinkLabel ?? 'Enter link'.i18n), |
|
|
|
|
Expanded( |
|
|
|
|
UtilityWidgets.maybeWidget( |
|
|
|
|
enabled: !isWrappable, |
|
|
|
|
wrapper: (child) => Expanded( |
|
|
|
|
child: child, |
|
|
|
|
), |
|
|
|
|
child: Padding( |
|
|
|
|
padding: EdgeInsets.symmetric( |
|
|
|
|
horizontal: widget.childrenSpacing), |
|
|
|
|
padding: |
|
|
|
|
EdgeInsets.symmetric(horizontal: widget.childrenSpacing), |
|
|
|
|
child: TextFormField( |
|
|
|
|
controller: _linkController, |
|
|
|
|
style: widget.dialogTheme?.inputTextStyle, |
|
|
|
@ -343,8 +345,26 @@ class _LinkStyleDialogState extends State<LinkStyleDialog> { |
|
|
|
|
style: buttonStyle, |
|
|
|
|
child: Text('Apply'.i18n), |
|
|
|
|
), |
|
|
|
|
], |
|
|
|
|
], |
|
|
|
|
]; |
|
|
|
|
|
|
|
|
|
return Dialog( |
|
|
|
|
backgroundColor: widget.dialogTheme?.dialogBackgroundColor, |
|
|
|
|
shape: widget.dialogTheme?.shape ?? |
|
|
|
|
DialogTheme.of(context).shape ?? |
|
|
|
|
RoundedRectangleBorder(borderRadius: BorderRadius.circular(4)), |
|
|
|
|
child: ConstrainedBox( |
|
|
|
|
constraints: constraints, |
|
|
|
|
child: Padding( |
|
|
|
|
padding: widget.contentPadding, |
|
|
|
|
child: isWrappable |
|
|
|
|
? Wrap( |
|
|
|
|
alignment: WrapAlignment.center, |
|
|
|
|
crossAxisAlignment: WrapCrossAlignment.center, |
|
|
|
|
runSpacing: widget.dialogTheme?.runSpacing ?? 0.0, |
|
|
|
|
children: children, |
|
|
|
|
) |
|
|
|
|
: Row( |
|
|
|
|
children: children, |
|
|
|
|
), |
|
|
|
|
), |
|
|
|
|
), |
|
|
|
|