|
|
|
@ -12,6 +12,7 @@ import 'embeds.dart'; |
|
|
|
|
import 'toolbar/arrow_indicated_button_list.dart'; |
|
|
|
|
import 'toolbar/clear_format_button.dart'; |
|
|
|
|
import 'toolbar/color_button.dart'; |
|
|
|
|
import 'toolbar/enum.dart'; |
|
|
|
|
import 'toolbar/history_button.dart'; |
|
|
|
|
import 'toolbar/indent_button.dart'; |
|
|
|
|
import 'toolbar/link_style_button.dart'; |
|
|
|
@ -117,6 +118,20 @@ class QuillToolbar extends StatelessWidget implements PreferredSizeWidget { |
|
|
|
|
/// Is called after whatever logic the button performs has run. |
|
|
|
|
VoidCallback? afterButtonPressed, |
|
|
|
|
|
|
|
|
|
///Map of tooltips for toolbar buttons |
|
|
|
|
/// |
|
|
|
|
///The example is: |
|
|
|
|
///```dart |
|
|
|
|
/// tooltips = <ToolbarButtons, String>{ |
|
|
|
|
/// ToolbarButtons.undo: 'Undo', |
|
|
|
|
/// ToolbarButtons.redo: 'Redo', |
|
|
|
|
/// } |
|
|
|
|
/// |
|
|
|
|
///``` |
|
|
|
|
/// |
|
|
|
|
/// To disable tooltips just pass empty map as well. |
|
|
|
|
Map<ToolbarButtons, String>? tooltips, |
|
|
|
|
|
|
|
|
|
/// The locale to use for the editor toolbar, defaults to system locale |
|
|
|
|
/// More at https://github.com/singerdmx/flutter-quill#translation |
|
|
|
|
Locale? locale, |
|
|
|
@ -172,6 +187,39 @@ class QuillToolbar extends StatelessWidget implements PreferredSizeWidget { |
|
|
|
|
'Clear'.i18n: 'Clear' |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
//default button tooltips |
|
|
|
|
final buttonTooltips = tooltips ?? |
|
|
|
|
<ToolbarButtons, String>{ |
|
|
|
|
ToolbarButtons.undo: 'Undo'.i18n, |
|
|
|
|
ToolbarButtons.redo: 'Redo'.i18n, |
|
|
|
|
ToolbarButtons.fontFamily: 'Font family'.i18n, |
|
|
|
|
ToolbarButtons.fontSize: 'Font size'.i18n, |
|
|
|
|
ToolbarButtons.bold: 'Bold'.i18n, |
|
|
|
|
ToolbarButtons.italic: 'Italic'.i18n, |
|
|
|
|
ToolbarButtons.small: 'Small'.i18n, |
|
|
|
|
ToolbarButtons.underline: 'Underline'.i18n, |
|
|
|
|
ToolbarButtons.strikeThrough: 'Strike through'.i18n, |
|
|
|
|
ToolbarButtons.inlineCode: 'Inline code'.i18n, |
|
|
|
|
ToolbarButtons.color: 'Font color'.i18n, |
|
|
|
|
ToolbarButtons.backgroundColor: 'Background color'.i18n, |
|
|
|
|
ToolbarButtons.clearFormat: 'Clear format'.i18n, |
|
|
|
|
ToolbarButtons.leftAlignment: 'Align left'.i18n, |
|
|
|
|
ToolbarButtons.centerAlignment: 'Align center'.i18n, |
|
|
|
|
ToolbarButtons.rightAlignment: 'Align right'.i18n, |
|
|
|
|
ToolbarButtons.justifyAlignment: 'Justify win width'.i18n, |
|
|
|
|
ToolbarButtons.direction: 'Text direction'.i18n, |
|
|
|
|
ToolbarButtons.headerStyle: 'Header style'.i18n, |
|
|
|
|
ToolbarButtons.listNumbers: 'Numbered list'.i18n, |
|
|
|
|
ToolbarButtons.listBullets: 'Bullet list'.i18n, |
|
|
|
|
ToolbarButtons.listChecks: 'Checked list'.i18n, |
|
|
|
|
ToolbarButtons.codeBlock: 'Code block'.i18n, |
|
|
|
|
ToolbarButtons.quote: 'Quote'.i18n, |
|
|
|
|
ToolbarButtons.indentIncrease: 'Increase indent'.i18n, |
|
|
|
|
ToolbarButtons.indentDecrease: 'Decrease indent'.i18n, |
|
|
|
|
ToolbarButtons.link: 'Insert URL'.i18n, |
|
|
|
|
ToolbarButtons.search: 'Search'.i18n, |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
return QuillToolbar( |
|
|
|
|
key: key, |
|
|
|
|
axis: axis, |
|
|
|
@ -189,6 +237,7 @@ class QuillToolbar extends StatelessWidget implements PreferredSizeWidget { |
|
|
|
|
HistoryButton( |
|
|
|
|
icon: Icons.undo_outlined, |
|
|
|
|
iconSize: toolbarIconSize, |
|
|
|
|
tooltip: buttonTooltips[ToolbarButtons.undo], |
|
|
|
|
controller: controller, |
|
|
|
|
undo: true, |
|
|
|
|
iconTheme: iconTheme, |
|
|
|
@ -198,6 +247,7 @@ class QuillToolbar extends StatelessWidget implements PreferredSizeWidget { |
|
|
|
|
HistoryButton( |
|
|
|
|
icon: Icons.redo_outlined, |
|
|
|
|
iconSize: toolbarIconSize, |
|
|
|
|
tooltip: buttonTooltips[ToolbarButtons.redo], |
|
|
|
|
controller: controller, |
|
|
|
|
undo: false, |
|
|
|
|
iconTheme: iconTheme, |
|
|
|
@ -207,6 +257,7 @@ class QuillToolbar extends StatelessWidget implements PreferredSizeWidget { |
|
|
|
|
QuillFontFamilyButton( |
|
|
|
|
iconTheme: iconTheme, |
|
|
|
|
iconSize: toolbarIconSize, |
|
|
|
|
tooltip: buttonTooltips[ToolbarButtons.fontFamily], |
|
|
|
|
attribute: Attribute.font, |
|
|
|
|
controller: controller, |
|
|
|
|
items: [ |
|
|
|
@ -231,6 +282,7 @@ class QuillToolbar extends StatelessWidget implements PreferredSizeWidget { |
|
|
|
|
QuillFontSizeButton( |
|
|
|
|
iconTheme: iconTheme, |
|
|
|
|
iconSize: toolbarIconSize, |
|
|
|
|
tooltip: buttonTooltips[ToolbarButtons.fontSize], |
|
|
|
|
attribute: Attribute.size, |
|
|
|
|
controller: controller, |
|
|
|
|
items: [ |
|
|
|
@ -255,6 +307,7 @@ class QuillToolbar extends StatelessWidget implements PreferredSizeWidget { |
|
|
|
|
attribute: Attribute.bold, |
|
|
|
|
icon: Icons.format_bold, |
|
|
|
|
iconSize: toolbarIconSize, |
|
|
|
|
tooltip: buttonTooltips[ToolbarButtons.bold], |
|
|
|
|
controller: controller, |
|
|
|
|
iconTheme: iconTheme, |
|
|
|
|
afterButtonPressed: afterButtonPressed, |
|
|
|
@ -264,6 +317,7 @@ class QuillToolbar extends StatelessWidget implements PreferredSizeWidget { |
|
|
|
|
attribute: Attribute.italic, |
|
|
|
|
icon: Icons.format_italic, |
|
|
|
|
iconSize: toolbarIconSize, |
|
|
|
|
tooltip: buttonTooltips[ToolbarButtons.italic], |
|
|
|
|
controller: controller, |
|
|
|
|
iconTheme: iconTheme, |
|
|
|
|
afterButtonPressed: afterButtonPressed, |
|
|
|
@ -273,6 +327,7 @@ class QuillToolbar extends StatelessWidget implements PreferredSizeWidget { |
|
|
|
|
attribute: Attribute.small, |
|
|
|
|
icon: Icons.format_size, |
|
|
|
|
iconSize: toolbarIconSize, |
|
|
|
|
tooltip: buttonTooltips[ToolbarButtons.small], |
|
|
|
|
controller: controller, |
|
|
|
|
iconTheme: iconTheme, |
|
|
|
|
afterButtonPressed: afterButtonPressed, |
|
|
|
@ -282,6 +337,7 @@ class QuillToolbar extends StatelessWidget implements PreferredSizeWidget { |
|
|
|
|
attribute: Attribute.underline, |
|
|
|
|
icon: Icons.format_underline, |
|
|
|
|
iconSize: toolbarIconSize, |
|
|
|
|
tooltip: buttonTooltips[ToolbarButtons.underline], |
|
|
|
|
controller: controller, |
|
|
|
|
iconTheme: iconTheme, |
|
|
|
|
afterButtonPressed: afterButtonPressed, |
|
|
|
@ -291,6 +347,7 @@ class QuillToolbar extends StatelessWidget implements PreferredSizeWidget { |
|
|
|
|
attribute: Attribute.strikeThrough, |
|
|
|
|
icon: Icons.format_strikethrough, |
|
|
|
|
iconSize: toolbarIconSize, |
|
|
|
|
tooltip: buttonTooltips[ToolbarButtons.strikeThrough], |
|
|
|
|
controller: controller, |
|
|
|
|
iconTheme: iconTheme, |
|
|
|
|
afterButtonPressed: afterButtonPressed, |
|
|
|
@ -300,6 +357,7 @@ class QuillToolbar extends StatelessWidget implements PreferredSizeWidget { |
|
|
|
|
attribute: Attribute.inlineCode, |
|
|
|
|
icon: Icons.code, |
|
|
|
|
iconSize: toolbarIconSize, |
|
|
|
|
tooltip: buttonTooltips[ToolbarButtons.inlineCode], |
|
|
|
|
controller: controller, |
|
|
|
|
iconTheme: iconTheme, |
|
|
|
|
afterButtonPressed: afterButtonPressed, |
|
|
|
@ -308,6 +366,7 @@ class QuillToolbar extends StatelessWidget implements PreferredSizeWidget { |
|
|
|
|
ColorButton( |
|
|
|
|
icon: Icons.color_lens, |
|
|
|
|
iconSize: toolbarIconSize, |
|
|
|
|
tooltip: buttonTooltips[ToolbarButtons.color], |
|
|
|
|
controller: controller, |
|
|
|
|
background: false, |
|
|
|
|
iconTheme: iconTheme, |
|
|
|
@ -317,6 +376,7 @@ class QuillToolbar extends StatelessWidget implements PreferredSizeWidget { |
|
|
|
|
ColorButton( |
|
|
|
|
icon: Icons.format_color_fill, |
|
|
|
|
iconSize: toolbarIconSize, |
|
|
|
|
tooltip: buttonTooltips[ToolbarButtons.backgroundColor], |
|
|
|
|
controller: controller, |
|
|
|
|
background: true, |
|
|
|
|
iconTheme: iconTheme, |
|
|
|
@ -326,6 +386,7 @@ class QuillToolbar extends StatelessWidget implements PreferredSizeWidget { |
|
|
|
|
ClearFormatButton( |
|
|
|
|
icon: Icons.format_clear, |
|
|
|
|
iconSize: toolbarIconSize, |
|
|
|
|
tooltip: buttonTooltips[ToolbarButtons.clearFormat], |
|
|
|
|
controller: controller, |
|
|
|
|
iconTheme: iconTheme, |
|
|
|
|
afterButtonPressed: afterButtonPressed, |
|
|
|
@ -344,6 +405,13 @@ class QuillToolbar extends StatelessWidget implements PreferredSizeWidget { |
|
|
|
|
if (showAlignmentButtons) |
|
|
|
|
SelectAlignmentButton( |
|
|
|
|
controller: controller, |
|
|
|
|
tooltips: Map.of(buttonTooltips) |
|
|
|
|
..removeWhere((key, value) => ![ |
|
|
|
|
ToolbarButtons.leftAlignment, |
|
|
|
|
ToolbarButtons.centerAlignment, |
|
|
|
|
ToolbarButtons.rightAlignment, |
|
|
|
|
ToolbarButtons.justifyAlignment, |
|
|
|
|
].contains(key)), |
|
|
|
|
iconSize: toolbarIconSize, |
|
|
|
|
iconTheme: iconTheme, |
|
|
|
|
showLeftAlignment: showLeftAlignment, |
|
|
|
@ -355,6 +423,7 @@ class QuillToolbar extends StatelessWidget implements PreferredSizeWidget { |
|
|
|
|
if (showDirection) |
|
|
|
|
ToggleStyleButton( |
|
|
|
|
attribute: Attribute.rtl, |
|
|
|
|
tooltip: buttonTooltips[ToolbarButtons.direction], |
|
|
|
|
controller: controller, |
|
|
|
|
icon: Icons.format_textdirection_r_to_l, |
|
|
|
|
iconSize: toolbarIconSize, |
|
|
|
@ -370,6 +439,7 @@ class QuillToolbar extends StatelessWidget implements PreferredSizeWidget { |
|
|
|
|
_dividerOnAxis(axis), |
|
|
|
|
if (showHeaderStyle) |
|
|
|
|
SelectHeaderStyleButton( |
|
|
|
|
tooltip: buttonTooltips[ToolbarButtons.headerStyle], |
|
|
|
|
controller: controller, |
|
|
|
|
axis: axis, |
|
|
|
|
iconSize: toolbarIconSize, |
|
|
|
@ -386,6 +456,7 @@ class QuillToolbar extends StatelessWidget implements PreferredSizeWidget { |
|
|
|
|
if (showListNumbers) |
|
|
|
|
ToggleStyleButton( |
|
|
|
|
attribute: Attribute.ol, |
|
|
|
|
tooltip: buttonTooltips[ToolbarButtons.listNumbers], |
|
|
|
|
controller: controller, |
|
|
|
|
icon: Icons.format_list_numbered, |
|
|
|
|
iconSize: toolbarIconSize, |
|
|
|
@ -395,6 +466,7 @@ class QuillToolbar extends StatelessWidget implements PreferredSizeWidget { |
|
|
|
|
if (showListBullets) |
|
|
|
|
ToggleStyleButton( |
|
|
|
|
attribute: Attribute.ul, |
|
|
|
|
tooltip: buttonTooltips[ToolbarButtons.listBullets], |
|
|
|
|
controller: controller, |
|
|
|
|
icon: Icons.format_list_bulleted, |
|
|
|
|
iconSize: toolbarIconSize, |
|
|
|
@ -404,6 +476,7 @@ class QuillToolbar extends StatelessWidget implements PreferredSizeWidget { |
|
|
|
|
if (showListCheck) |
|
|
|
|
ToggleCheckListButton( |
|
|
|
|
attribute: Attribute.unchecked, |
|
|
|
|
tooltip: buttonTooltips[ToolbarButtons.listChecks], |
|
|
|
|
controller: controller, |
|
|
|
|
icon: Icons.check_box, |
|
|
|
|
iconSize: toolbarIconSize, |
|
|
|
@ -413,6 +486,7 @@ class QuillToolbar extends StatelessWidget implements PreferredSizeWidget { |
|
|
|
|
if (showCodeBlock) |
|
|
|
|
ToggleStyleButton( |
|
|
|
|
attribute: Attribute.codeBlock, |
|
|
|
|
tooltip: buttonTooltips[ToolbarButtons.codeBlock], |
|
|
|
|
controller: controller, |
|
|
|
|
icon: Icons.code, |
|
|
|
|
iconSize: toolbarIconSize, |
|
|
|
@ -426,6 +500,7 @@ class QuillToolbar extends StatelessWidget implements PreferredSizeWidget { |
|
|
|
|
if (showQuote) |
|
|
|
|
ToggleStyleButton( |
|
|
|
|
attribute: Attribute.blockQuote, |
|
|
|
|
tooltip: buttonTooltips[ToolbarButtons.quote], |
|
|
|
|
controller: controller, |
|
|
|
|
icon: Icons.format_quote, |
|
|
|
|
iconSize: toolbarIconSize, |
|
|
|
@ -436,6 +511,7 @@ class QuillToolbar extends StatelessWidget implements PreferredSizeWidget { |
|
|
|
|
IndentButton( |
|
|
|
|
icon: Icons.format_indent_increase, |
|
|
|
|
iconSize: toolbarIconSize, |
|
|
|
|
tooltip: buttonTooltips[ToolbarButtons.indentIncrease], |
|
|
|
|
controller: controller, |
|
|
|
|
isIncrease: true, |
|
|
|
|
iconTheme: iconTheme, |
|
|
|
@ -445,6 +521,7 @@ class QuillToolbar extends StatelessWidget implements PreferredSizeWidget { |
|
|
|
|
IndentButton( |
|
|
|
|
icon: Icons.format_indent_decrease, |
|
|
|
|
iconSize: toolbarIconSize, |
|
|
|
|
tooltip: buttonTooltips[ToolbarButtons.indentDecrease], |
|
|
|
|
controller: controller, |
|
|
|
|
isIncrease: false, |
|
|
|
|
iconTheme: iconTheme, |
|
|
|
@ -454,6 +531,7 @@ class QuillToolbar extends StatelessWidget implements PreferredSizeWidget { |
|
|
|
|
_dividerOnAxis(axis), |
|
|
|
|
if (showLink) |
|
|
|
|
LinkStyleButton( |
|
|
|
|
tooltip: buttonTooltips[ToolbarButtons.link], |
|
|
|
|
controller: controller, |
|
|
|
|
iconSize: toolbarIconSize, |
|
|
|
|
iconTheme: iconTheme, |
|
|
|
@ -464,6 +542,7 @@ class QuillToolbar extends StatelessWidget implements PreferredSizeWidget { |
|
|
|
|
SearchButton( |
|
|
|
|
icon: Icons.search, |
|
|
|
|
iconSize: toolbarIconSize, |
|
|
|
|
tooltip: buttonTooltips[ToolbarButtons.search], |
|
|
|
|
controller: controller, |
|
|
|
|
iconTheme: iconTheme, |
|
|
|
|
dialogTheme: dialogTheme, |
|
|
|
@ -477,6 +556,7 @@ class QuillToolbar extends StatelessWidget implements PreferredSizeWidget { |
|
|
|
|
hoverElevation: 0, |
|
|
|
|
size: toolbarIconSize * kIconButtonFactor, |
|
|
|
|
icon: Icon(customButton.icon, size: toolbarIconSize), |
|
|
|
|
tooltip: customButton.tooltip, |
|
|
|
|
borderRadius: iconTheme?.borderRadius ?? 2, |
|
|
|
|
onPressed: customButton.onTap, |
|
|
|
|
afterPressed: afterButtonPressed, |
|
|
|
|