|
|
|
@ -25,9 +25,9 @@ class InsertEmbedButton extends StatelessWidget { |
|
|
|
|
final IconData icon; |
|
|
|
|
|
|
|
|
|
const InsertEmbedButton({ |
|
|
|
|
Key? key, |
|
|
|
|
required this.controller, |
|
|
|
|
required this.icon, |
|
|
|
|
Key? key, |
|
|
|
|
}) : super(key: key); |
|
|
|
|
|
|
|
|
|
@override |
|
|
|
@ -56,9 +56,9 @@ class LinkStyleButton extends StatefulWidget { |
|
|
|
|
final IconData? icon; |
|
|
|
|
|
|
|
|
|
const LinkStyleButton({ |
|
|
|
|
Key? key, |
|
|
|
|
required this.controller, |
|
|
|
|
this.icon, |
|
|
|
|
Key? key, |
|
|
|
|
}) : super(key: key); |
|
|
|
|
|
|
|
|
|
@override |
|
|
|
@ -114,7 +114,7 @@ class _LinkStyleButtonState extends State<LinkStyleButton> { |
|
|
|
|
showDialog<String>( |
|
|
|
|
context: context, |
|
|
|
|
builder: (ctx) { |
|
|
|
|
return _LinkDialog(); |
|
|
|
|
return const _LinkDialog(); |
|
|
|
|
}, |
|
|
|
|
).then(_linkSubmitted); |
|
|
|
|
} |
|
|
|
@ -141,14 +141,14 @@ class _LinkDialogState extends State<_LinkDialog> { |
|
|
|
|
Widget build(BuildContext context) { |
|
|
|
|
return AlertDialog( |
|
|
|
|
content: TextField( |
|
|
|
|
decoration: InputDecoration(labelText: 'Paste a link'), |
|
|
|
|
decoration: const InputDecoration(labelText: 'Paste a link'), |
|
|
|
|
autofocus: true, |
|
|
|
|
onChanged: _linkChanged, |
|
|
|
|
), |
|
|
|
|
actions: [ |
|
|
|
|
TextButton( |
|
|
|
|
onPressed: _link.isNotEmpty ? _applyLink : null, |
|
|
|
|
child: Text('Apply'), |
|
|
|
|
child: const Text('Apply'), |
|
|
|
|
), |
|
|
|
|
], |
|
|
|
|
); |
|
|
|
@ -182,12 +182,12 @@ class ToggleStyleButton extends StatefulWidget { |
|
|
|
|
|
|
|
|
|
final ToggleStyleButtonBuilder childBuilder; |
|
|
|
|
|
|
|
|
|
ToggleStyleButton({ |
|
|
|
|
Key? key, |
|
|
|
|
const ToggleStyleButton({ |
|
|
|
|
required this.attribute, |
|
|
|
|
required this.icon, |
|
|
|
|
required this.controller, |
|
|
|
|
this.childBuilder = defaultToggleStyleButtonBuilder, |
|
|
|
|
Key? key, |
|
|
|
|
}) : super(key: key); |
|
|
|
|
|
|
|
|
|
@override |
|
|
|
@ -266,12 +266,12 @@ class ToggleCheckListButton extends StatefulWidget { |
|
|
|
|
|
|
|
|
|
final Attribute attribute; |
|
|
|
|
|
|
|
|
|
ToggleCheckListButton({ |
|
|
|
|
Key? key, |
|
|
|
|
const ToggleCheckListButton({ |
|
|
|
|
required this.icon, |
|
|
|
|
required this.controller, |
|
|
|
|
this.childBuilder = defaultToggleStyleButtonBuilder, |
|
|
|
|
required this.attribute, |
|
|
|
|
this.childBuilder = defaultToggleStyleButtonBuilder, |
|
|
|
|
Key? key, |
|
|
|
|
}) : super(key: key); |
|
|
|
|
|
|
|
|
|
@override |
|
|
|
@ -371,7 +371,7 @@ Widget defaultToggleStyleButtonBuilder( |
|
|
|
|
class SelectHeaderStyleButton extends StatefulWidget { |
|
|
|
|
final QuillController controller; |
|
|
|
|
|
|
|
|
|
const SelectHeaderStyleButton({Key? key, required this.controller}) |
|
|
|
|
const SelectHeaderStyleButton({required this.controller, Key? key}) |
|
|
|
|
: super(key: key); |
|
|
|
|
|
|
|
|
|
@override |
|
|
|
@ -430,7 +430,7 @@ class _SelectHeaderStyleButtonState extends State<SelectHeaderStyleButton> { |
|
|
|
|
|
|
|
|
|
Widget _selectHeadingStyleButtonBuilder(BuildContext context, Attribute? value, |
|
|
|
|
ValueChanged<Attribute?> onSelected) { |
|
|
|
|
final style = TextStyle(fontSize: 13); |
|
|
|
|
final style = const TextStyle(fontSize: 13); |
|
|
|
|
|
|
|
|
|
final Map<Attribute, String> _valueToText = { |
|
|
|
|
Attribute.header: 'Normal text', |
|
|
|
@ -478,7 +478,7 @@ Widget _selectHeadingStyleButtonBuilder(BuildContext context, Attribute? value, |
|
|
|
|
: (value.key == 'h2') |
|
|
|
|
? Attribute.h2 |
|
|
|
|
: Attribute.h3]!, |
|
|
|
|
style: TextStyle(fontSize: 13, fontWeight: FontWeight.w600), |
|
|
|
|
style: const TextStyle(fontSize: 13, fontWeight: FontWeight.w600), |
|
|
|
|
), |
|
|
|
|
); |
|
|
|
|
} |
|
|
|
@ -494,14 +494,14 @@ class ImageButton extends StatefulWidget { |
|
|
|
|
|
|
|
|
|
final ImageSource imageSource; |
|
|
|
|
|
|
|
|
|
ImageButton( |
|
|
|
|
{Key? key, |
|
|
|
|
required this.icon, |
|
|
|
|
required this.controller, |
|
|
|
|
required this.imageSource, |
|
|
|
|
this.onImagePickCallback, |
|
|
|
|
this.imagePickImpl}) |
|
|
|
|
: super(key: key); |
|
|
|
|
const ImageButton({ |
|
|
|
|
required this.icon, |
|
|
|
|
required this.controller, |
|
|
|
|
required this.imageSource, |
|
|
|
|
this.onImagePickCallback, |
|
|
|
|
this.imagePickImpl, |
|
|
|
|
Key? key, |
|
|
|
|
}) : super(key: key); |
|
|
|
|
|
|
|
|
|
@override |
|
|
|
|
_ImageButtonState createState() => _ImageButtonState(); |
|
|
|
@ -525,7 +525,6 @@ class _ImageButtonState extends State<ImageButton> { |
|
|
|
|
Future<String?> _pickImageWeb() async { |
|
|
|
|
_paths = (await FilePicker.platform.pickFiles( |
|
|
|
|
type: _pickingType, |
|
|
|
|
allowMultiple: false, |
|
|
|
|
allowedExtensions: (_extension?.isNotEmpty ?? false) |
|
|
|
|
? _extension?.replaceAll(' ', '').split(',') |
|
|
|
|
: null, |
|
|
|
@ -601,12 +600,12 @@ class ColorButton extends StatefulWidget { |
|
|
|
|
final bool background; |
|
|
|
|
final QuillController controller; |
|
|
|
|
|
|
|
|
|
ColorButton( |
|
|
|
|
{Key? key, |
|
|
|
|
required this.icon, |
|
|
|
|
required this.controller, |
|
|
|
|
required this.background}) |
|
|
|
|
: super(key: key); |
|
|
|
|
const ColorButton({ |
|
|
|
|
required this.icon, |
|
|
|
|
required this.controller, |
|
|
|
|
required this.background, |
|
|
|
|
Key? key, |
|
|
|
|
}) : super(key: key); |
|
|
|
|
|
|
|
|
|
@override |
|
|
|
|
_ColorButtonState createState() => _ColorButtonState(); |
|
|
|
@ -726,7 +725,7 @@ class _ColorButtonState extends State<ColorButton> { |
|
|
|
|
backgroundColor: Theme.of(context).canvasColor, |
|
|
|
|
content: SingleChildScrollView( |
|
|
|
|
child: MaterialPicker( |
|
|
|
|
pickerColor: Color(0x00000000), |
|
|
|
|
pickerColor: const Color(0x00000000), |
|
|
|
|
onColorChanged: _changeColor, |
|
|
|
|
), |
|
|
|
|
)), |
|
|
|
@ -739,12 +738,12 @@ class HistoryButton extends StatefulWidget { |
|
|
|
|
final bool undo; |
|
|
|
|
final QuillController controller; |
|
|
|
|
|
|
|
|
|
HistoryButton( |
|
|
|
|
{Key? key, |
|
|
|
|
required this.icon, |
|
|
|
|
required this.controller, |
|
|
|
|
required this.undo}) |
|
|
|
|
: super(key: key); |
|
|
|
|
const HistoryButton({ |
|
|
|
|
required this.icon, |
|
|
|
|
required this.controller, |
|
|
|
|
required this.undo, |
|
|
|
|
Key? key, |
|
|
|
|
}) : super(key: key); |
|
|
|
|
|
|
|
|
|
@override |
|
|
|
|
_HistoryButtonState createState() => _HistoryButtonState(); |
|
|
|
@ -811,12 +810,12 @@ class IndentButton extends StatefulWidget { |
|
|
|
|
final QuillController controller; |
|
|
|
|
final bool isIncrease; |
|
|
|
|
|
|
|
|
|
IndentButton( |
|
|
|
|
{Key? key, |
|
|
|
|
required this.icon, |
|
|
|
|
required this.controller, |
|
|
|
|
required this.isIncrease}) |
|
|
|
|
: super(key: key); |
|
|
|
|
const IndentButton({ |
|
|
|
|
required this.icon, |
|
|
|
|
required this.controller, |
|
|
|
|
required this.isIncrease, |
|
|
|
|
Key? key, |
|
|
|
|
}) : super(key: key); |
|
|
|
|
|
|
|
|
|
@override |
|
|
|
|
_IndentButtonState createState() => _IndentButtonState(); |
|
|
|
@ -866,8 +865,11 @@ class ClearFormatButton extends StatefulWidget { |
|
|
|
|
|
|
|
|
|
final QuillController controller; |
|
|
|
|
|
|
|
|
|
ClearFormatButton({Key? key, required this.icon, required this.controller}) |
|
|
|
|
: super(key: key); |
|
|
|
|
const ClearFormatButton({ |
|
|
|
|
required this.icon, |
|
|
|
|
required this.controller, |
|
|
|
|
Key? key, |
|
|
|
|
}) : super(key: key); |
|
|
|
|
|
|
|
|
|
@override |
|
|
|
|
_ClearFormatButtonState createState() => _ClearFormatButtonState(); |
|
|
|
@ -897,30 +899,31 @@ class _ClearFormatButtonState extends State<ClearFormatButton> { |
|
|
|
|
class QuillToolbar extends StatefulWidget implements PreferredSizeWidget { |
|
|
|
|
final List<Widget> children; |
|
|
|
|
|
|
|
|
|
const QuillToolbar({Key? key, required this.children}) : super(key: key); |
|
|
|
|
|
|
|
|
|
factory QuillToolbar.basic( |
|
|
|
|
{Key? key, |
|
|
|
|
required QuillController controller, |
|
|
|
|
double toolbarIconSize = 18.0, |
|
|
|
|
bool showBoldButton = true, |
|
|
|
|
bool showItalicButton = true, |
|
|
|
|
bool showUnderLineButton = true, |
|
|
|
|
bool showStrikeThrough = true, |
|
|
|
|
bool showColorButton = true, |
|
|
|
|
bool showBackgroundColorButton = true, |
|
|
|
|
bool showClearFormat = true, |
|
|
|
|
bool showHeaderStyle = true, |
|
|
|
|
bool showListNumbers = true, |
|
|
|
|
bool showListBullets = true, |
|
|
|
|
bool showListCheck = true, |
|
|
|
|
bool showCodeBlock = true, |
|
|
|
|
bool showQuote = true, |
|
|
|
|
bool showIndent = true, |
|
|
|
|
bool showLink = true, |
|
|
|
|
bool showHistory = true, |
|
|
|
|
bool showHorizontalRule = false, |
|
|
|
|
OnImagePickCallback? onImagePickCallback}) { |
|
|
|
|
const QuillToolbar({required this.children, Key? key}) : super(key: key); |
|
|
|
|
|
|
|
|
|
factory QuillToolbar.basic({ |
|
|
|
|
required QuillController controller, |
|
|
|
|
double toolbarIconSize = 18.0, |
|
|
|
|
bool showBoldButton = true, |
|
|
|
|
bool showItalicButton = true, |
|
|
|
|
bool showUnderLineButton = true, |
|
|
|
|
bool showStrikeThrough = true, |
|
|
|
|
bool showColorButton = true, |
|
|
|
|
bool showBackgroundColorButton = true, |
|
|
|
|
bool showClearFormat = true, |
|
|
|
|
bool showHeaderStyle = true, |
|
|
|
|
bool showListNumbers = true, |
|
|
|
|
bool showListBullets = true, |
|
|
|
|
bool showListCheck = true, |
|
|
|
|
bool showCodeBlock = true, |
|
|
|
|
bool showQuote = true, |
|
|
|
|
bool showIndent = true, |
|
|
|
|
bool showLink = true, |
|
|
|
|
bool showHistory = true, |
|
|
|
|
bool showHorizontalRule = false, |
|
|
|
|
OnImagePickCallback? onImagePickCallback, |
|
|
|
|
Key? key, |
|
|
|
|
}) { |
|
|
|
|
iconSize = toolbarIconSize; |
|
|
|
|
return QuillToolbar(key: key, children: [ |
|
|
|
|
Visibility( |
|
|
|
@ -939,7 +942,7 @@ class QuillToolbar extends StatefulWidget implements PreferredSizeWidget { |
|
|
|
|
undo: false, |
|
|
|
|
), |
|
|
|
|
), |
|
|
|
|
SizedBox(width: 0.6), |
|
|
|
|
const SizedBox(width: 0.6), |
|
|
|
|
Visibility( |
|
|
|
|
visible: showBoldButton, |
|
|
|
|
child: ToggleStyleButton( |
|
|
|
@ -948,7 +951,7 @@ class QuillToolbar extends StatefulWidget implements PreferredSizeWidget { |
|
|
|
|
controller: controller, |
|
|
|
|
), |
|
|
|
|
), |
|
|
|
|
SizedBox(width: 0.6), |
|
|
|
|
const SizedBox(width: 0.6), |
|
|
|
|
Visibility( |
|
|
|
|
visible: showItalicButton, |
|
|
|
|
child: ToggleStyleButton( |
|
|
|
@ -957,7 +960,7 @@ class QuillToolbar extends StatefulWidget implements PreferredSizeWidget { |
|
|
|
|
controller: controller, |
|
|
|
|
), |
|
|
|
|
), |
|
|
|
|
SizedBox(width: 0.6), |
|
|
|
|
const SizedBox(width: 0.6), |
|
|
|
|
Visibility( |
|
|
|
|
visible: showUnderLineButton, |
|
|
|
|
child: ToggleStyleButton( |
|
|
|
@ -966,7 +969,7 @@ class QuillToolbar extends StatefulWidget implements PreferredSizeWidget { |
|
|
|
|
controller: controller, |
|
|
|
|
), |
|
|
|
|
), |
|
|
|
|
SizedBox(width: 0.6), |
|
|
|
|
const SizedBox(width: 0.6), |
|
|
|
|
Visibility( |
|
|
|
|
visible: showStrikeThrough, |
|
|
|
|
child: ToggleStyleButton( |
|
|
|
@ -975,7 +978,7 @@ class QuillToolbar extends StatefulWidget implements PreferredSizeWidget { |
|
|
|
|
controller: controller, |
|
|
|
|
), |
|
|
|
|
), |
|
|
|
|
SizedBox(width: 0.6), |
|
|
|
|
const SizedBox(width: 0.6), |
|
|
|
|
Visibility( |
|
|
|
|
visible: showColorButton, |
|
|
|
|
child: ColorButton( |
|
|
|
@ -984,7 +987,7 @@ class QuillToolbar extends StatefulWidget implements PreferredSizeWidget { |
|
|
|
|
background: false, |
|
|
|
|
), |
|
|
|
|
), |
|
|
|
|
SizedBox(width: 0.6), |
|
|
|
|
const SizedBox(width: 0.6), |
|
|
|
|
Visibility( |
|
|
|
|
visible: showBackgroundColorButton, |
|
|
|
|
child: ColorButton( |
|
|
|
@ -993,7 +996,7 @@ class QuillToolbar extends StatefulWidget implements PreferredSizeWidget { |
|
|
|
|
background: true, |
|
|
|
|
), |
|
|
|
|
), |
|
|
|
|
SizedBox(width: 0.6), |
|
|
|
|
const SizedBox(width: 0.6), |
|
|
|
|
Visibility( |
|
|
|
|
visible: showClearFormat, |
|
|
|
|
child: ClearFormatButton( |
|
|
|
@ -1001,7 +1004,7 @@ class QuillToolbar extends StatefulWidget implements PreferredSizeWidget { |
|
|
|
|
controller: controller, |
|
|
|
|
), |
|
|
|
|
), |
|
|
|
|
SizedBox(width: 0.6), |
|
|
|
|
const SizedBox(width: 0.6), |
|
|
|
|
Visibility( |
|
|
|
|
visible: onImagePickCallback != null, |
|
|
|
|
child: ImageButton( |
|
|
|
@ -1011,7 +1014,7 @@ class QuillToolbar extends StatefulWidget implements PreferredSizeWidget { |
|
|
|
|
onImagePickCallback: onImagePickCallback, |
|
|
|
|
), |
|
|
|
|
), |
|
|
|
|
SizedBox(width: 0.6), |
|
|
|
|
const SizedBox(width: 0.6), |
|
|
|
|
Visibility( |
|
|
|
|
visible: onImagePickCallback != null, |
|
|
|
|
child: ImageButton( |
|
|
|
@ -1119,7 +1122,7 @@ class _QuillToolbarState extends State<QuillToolbar> { |
|
|
|
|
@override |
|
|
|
|
Widget build(BuildContext context) { |
|
|
|
|
return Container( |
|
|
|
|
padding: EdgeInsets.symmetric(horizontal: 8), |
|
|
|
|
padding: const EdgeInsets.symmetric(horizontal: 8), |
|
|
|
|
constraints: BoxConstraints.tightFor(height: widget.preferredSize.height), |
|
|
|
|
color: Theme.of(context).canvasColor, |
|
|
|
|
child: CustomScrollView( |
|
|
|
@ -1147,13 +1150,13 @@ class QuillIconButton extends StatelessWidget { |
|
|
|
|
final double highlightElevation; |
|
|
|
|
|
|
|
|
|
const QuillIconButton({ |
|
|
|
|
Key? key, |
|
|
|
|
required this.onPressed, |
|
|
|
|
this.icon, |
|
|
|
|
this.size = 40, |
|
|
|
|
this.fillColor, |
|
|
|
|
this.hoverElevation = 1, |
|
|
|
|
this.highlightElevation = 1, |
|
|
|
|
Key? key, |
|
|
|
|
}) : super(key: key); |
|
|
|
|
|
|
|
|
|
@override |
|
|
|
@ -1163,7 +1166,6 @@ class QuillIconButton extends StatelessWidget { |
|
|
|
|
child: RawMaterialButton( |
|
|
|
|
visualDensity: VisualDensity.compact, |
|
|
|
|
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(2)), |
|
|
|
|
padding: EdgeInsets.zero, |
|
|
|
|
fillColor: fillColor, |
|
|
|
|
elevation: 0, |
|
|
|
|
hoverElevation: hoverElevation, |
|
|
|
@ -1186,15 +1188,15 @@ class QuillDropdownButton<T> extends StatefulWidget { |
|
|
|
|
final ValueChanged<T> onSelected; |
|
|
|
|
|
|
|
|
|
const QuillDropdownButton({ |
|
|
|
|
Key? key, |
|
|
|
|
this.height = 40, |
|
|
|
|
this.fillColor, |
|
|
|
|
this.hoverElevation = 1, |
|
|
|
|
this.highlightElevation = 1, |
|
|
|
|
required this.child, |
|
|
|
|
required this.initialValue, |
|
|
|
|
required this.items, |
|
|
|
|
required this.onSelected, |
|
|
|
|
this.height = 40, |
|
|
|
|
this.fillColor, |
|
|
|
|
this.hoverElevation = 1, |
|
|
|
|
this.highlightElevation = 1, |
|
|
|
|
Key? key, |
|
|
|
|
}) : super(key: key); |
|
|
|
|
|
|
|
|
|
@override |
|
|
|
@ -1209,7 +1211,6 @@ class _QuillDropdownButtonState<T> extends State<QuillDropdownButton<T>> { |
|
|
|
|
child: RawMaterialButton( |
|
|
|
|
visualDensity: VisualDensity.compact, |
|
|
|
|
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(2)), |
|
|
|
|
padding: EdgeInsets.zero, |
|
|
|
|
fillColor: widget.fillColor, |
|
|
|
|
elevation: 0, |
|
|
|
|
hoverElevation: widget.hoverElevation, |
|
|
|
@ -1250,19 +1251,20 @@ class _QuillDropdownButtonState<T> extends State<QuillDropdownButton<T>> { |
|
|
|
|
// if (widget.onCanceled != null) widget.onCanceled(); |
|
|
|
|
return null; |
|
|
|
|
} |
|
|
|
|
widget.onSelected(newValue); |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
Widget _buildContent(BuildContext context) { |
|
|
|
|
return ConstrainedBox( |
|
|
|
|
constraints: BoxConstraints.tightFor(width: 110), |
|
|
|
|
constraints: const BoxConstraints.tightFor(width: 110), |
|
|
|
|
child: Padding( |
|
|
|
|
padding: const EdgeInsets.symmetric(horizontal: 8.0), |
|
|
|
|
child: Row( |
|
|
|
|
children: [ |
|
|
|
|
widget.child, |
|
|
|
|
Expanded(child: Container()), |
|
|
|
|
Icon(Icons.arrow_drop_down, size: 15) |
|
|
|
|
const Icon(Icons.arrow_drop_down, size: 15) |
|
|
|
|
], |
|
|
|
|
), |
|
|
|
|
), |
|
|
|
|