|
|
|
@ -100,36 +100,7 @@ class QuillToolbar extends StatelessWidget implements PreferredSizeWidget { |
|
|
|
|
List<QuillCustomButton> customButtons = const [], |
|
|
|
|
|
|
|
|
|
///Map of tooltips for toolbar buttons |
|
|
|
|
Map<ToolbarButtons, String> tooltips = const <ToolbarButtons, String>{ |
|
|
|
|
ToolbarButtons.undo: 'Undo', |
|
|
|
|
ToolbarButtons.redo: 'Redo', |
|
|
|
|
ToolbarButtons.fontFamily: 'Font family', |
|
|
|
|
ToolbarButtons.fontSize: 'Font size', |
|
|
|
|
ToolbarButtons.bold: 'Bold', |
|
|
|
|
ToolbarButtons.italic: 'Italic', |
|
|
|
|
ToolbarButtons.small: 'Small', |
|
|
|
|
ToolbarButtons.underline: 'Underline', |
|
|
|
|
ToolbarButtons.strikeThrough: 'Strike through', |
|
|
|
|
ToolbarButtons.inlineCode: 'Inline code', |
|
|
|
|
ToolbarButtons.color: 'Font color', |
|
|
|
|
ToolbarButtons.backgroundColor: 'Background color', |
|
|
|
|
ToolbarButtons.clearFormat: 'Clear format', |
|
|
|
|
ToolbarButtons.leftAlignment: 'Align left', |
|
|
|
|
ToolbarButtons.centerAlignment: 'Align center', |
|
|
|
|
ToolbarButtons.rightAlignment: 'Align right', |
|
|
|
|
ToolbarButtons.justifyAlignment: 'Justify win width', |
|
|
|
|
ToolbarButtons.direction: 'Text direction', |
|
|
|
|
ToolbarButtons.headerStyle: 'Header style', |
|
|
|
|
ToolbarButtons.listNumbers: 'Numbered list', |
|
|
|
|
ToolbarButtons.listBullets: 'Bullet list', |
|
|
|
|
ToolbarButtons.listChecks: 'Checked list', |
|
|
|
|
ToolbarButtons.codeBlock: 'Code block', |
|
|
|
|
ToolbarButtons.quote: 'Quote', |
|
|
|
|
ToolbarButtons.indentIncrease: 'Increase indent', |
|
|
|
|
ToolbarButtons.indentDecrease: 'Decrease indent', |
|
|
|
|
ToolbarButtons.link: 'Insert URL', |
|
|
|
|
ToolbarButtons.search: 'Search', |
|
|
|
|
}, |
|
|
|
|
Map<ToolbarButtons, String>? tooltips, |
|
|
|
|
|
|
|
|
|
///Map of font sizes in string |
|
|
|
|
Map<String, String>? fontSizeValues, |
|
|
|
@ -206,6 +177,38 @@ class QuillToolbar extends StatelessWidget implements PreferredSizeWidget { |
|
|
|
|
'Clear'.i18n: 'Clear' |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
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, |
|
|
|
@ -223,7 +226,7 @@ class QuillToolbar extends StatelessWidget implements PreferredSizeWidget { |
|
|
|
|
HistoryButton( |
|
|
|
|
icon: Icons.undo_outlined, |
|
|
|
|
iconSize: toolbarIconSize, |
|
|
|
|
tooltip: tooltips[ToolbarButtons.undo], |
|
|
|
|
tooltip: buttonTooltips[ToolbarButtons.undo], |
|
|
|
|
controller: controller, |
|
|
|
|
undo: true, |
|
|
|
|
iconTheme: iconTheme, |
|
|
|
@ -233,7 +236,7 @@ class QuillToolbar extends StatelessWidget implements PreferredSizeWidget { |
|
|
|
|
HistoryButton( |
|
|
|
|
icon: Icons.redo_outlined, |
|
|
|
|
iconSize: toolbarIconSize, |
|
|
|
|
tooltip: tooltips[ToolbarButtons.redo], |
|
|
|
|
tooltip: buttonTooltips[ToolbarButtons.redo], |
|
|
|
|
controller: controller, |
|
|
|
|
undo: false, |
|
|
|
|
iconTheme: iconTheme, |
|
|
|
@ -243,7 +246,7 @@ class QuillToolbar extends StatelessWidget implements PreferredSizeWidget { |
|
|
|
|
QuillFontFamilyButton( |
|
|
|
|
iconTheme: iconTheme, |
|
|
|
|
iconSize: toolbarIconSize, |
|
|
|
|
tooltip: tooltips[ToolbarButtons.fontFamily], |
|
|
|
|
tooltip: buttonTooltips[ToolbarButtons.fontFamily], |
|
|
|
|
attribute: Attribute.font, |
|
|
|
|
controller: controller, |
|
|
|
|
items: [ |
|
|
|
@ -268,7 +271,7 @@ class QuillToolbar extends StatelessWidget implements PreferredSizeWidget { |
|
|
|
|
QuillFontSizeButton( |
|
|
|
|
iconTheme: iconTheme, |
|
|
|
|
iconSize: toolbarIconSize, |
|
|
|
|
tooltip: tooltips[ToolbarButtons.fontSize], |
|
|
|
|
tooltip: buttonTooltips[ToolbarButtons.fontSize], |
|
|
|
|
attribute: Attribute.size, |
|
|
|
|
controller: controller, |
|
|
|
|
items: [ |
|
|
|
@ -293,7 +296,7 @@ class QuillToolbar extends StatelessWidget implements PreferredSizeWidget { |
|
|
|
|
attribute: Attribute.bold, |
|
|
|
|
icon: Icons.format_bold, |
|
|
|
|
iconSize: toolbarIconSize, |
|
|
|
|
tooltip: tooltips[ToolbarButtons.bold], |
|
|
|
|
tooltip: buttonTooltips[ToolbarButtons.bold], |
|
|
|
|
controller: controller, |
|
|
|
|
iconTheme: iconTheme, |
|
|
|
|
afterButtonPressed: afterButtonPressed, |
|
|
|
@ -303,7 +306,7 @@ class QuillToolbar extends StatelessWidget implements PreferredSizeWidget { |
|
|
|
|
attribute: Attribute.italic, |
|
|
|
|
icon: Icons.format_italic, |
|
|
|
|
iconSize: toolbarIconSize, |
|
|
|
|
tooltip: tooltips[ToolbarButtons.italic], |
|
|
|
|
tooltip: buttonTooltips[ToolbarButtons.italic], |
|
|
|
|
controller: controller, |
|
|
|
|
iconTheme: iconTheme, |
|
|
|
|
afterButtonPressed: afterButtonPressed, |
|
|
|
@ -313,7 +316,7 @@ class QuillToolbar extends StatelessWidget implements PreferredSizeWidget { |
|
|
|
|
attribute: Attribute.small, |
|
|
|
|
icon: Icons.format_size, |
|
|
|
|
iconSize: toolbarIconSize, |
|
|
|
|
tooltip: tooltips[ToolbarButtons.small], |
|
|
|
|
tooltip: buttonTooltips[ToolbarButtons.small], |
|
|
|
|
controller: controller, |
|
|
|
|
iconTheme: iconTheme, |
|
|
|
|
afterButtonPressed: afterButtonPressed, |
|
|
|
@ -323,7 +326,7 @@ class QuillToolbar extends StatelessWidget implements PreferredSizeWidget { |
|
|
|
|
attribute: Attribute.underline, |
|
|
|
|
icon: Icons.format_underline, |
|
|
|
|
iconSize: toolbarIconSize, |
|
|
|
|
tooltip: tooltips[ToolbarButtons.underline], |
|
|
|
|
tooltip: buttonTooltips[ToolbarButtons.underline], |
|
|
|
|
controller: controller, |
|
|
|
|
iconTheme: iconTheme, |
|
|
|
|
afterButtonPressed: afterButtonPressed, |
|
|
|
@ -333,7 +336,7 @@ class QuillToolbar extends StatelessWidget implements PreferredSizeWidget { |
|
|
|
|
attribute: Attribute.strikeThrough, |
|
|
|
|
icon: Icons.format_strikethrough, |
|
|
|
|
iconSize: toolbarIconSize, |
|
|
|
|
tooltip: tooltips[ToolbarButtons.strikeThrough], |
|
|
|
|
tooltip: buttonTooltips[ToolbarButtons.strikeThrough], |
|
|
|
|
controller: controller, |
|
|
|
|
iconTheme: iconTheme, |
|
|
|
|
afterButtonPressed: afterButtonPressed, |
|
|
|
@ -343,7 +346,7 @@ class QuillToolbar extends StatelessWidget implements PreferredSizeWidget { |
|
|
|
|
attribute: Attribute.inlineCode, |
|
|
|
|
icon: Icons.code, |
|
|
|
|
iconSize: toolbarIconSize, |
|
|
|
|
tooltip: tooltips[ToolbarButtons.inlineCode], |
|
|
|
|
tooltip: buttonTooltips[ToolbarButtons.inlineCode], |
|
|
|
|
controller: controller, |
|
|
|
|
iconTheme: iconTheme, |
|
|
|
|
afterButtonPressed: afterButtonPressed, |
|
|
|
@ -352,7 +355,7 @@ class QuillToolbar extends StatelessWidget implements PreferredSizeWidget { |
|
|
|
|
ColorButton( |
|
|
|
|
icon: Icons.color_lens, |
|
|
|
|
iconSize: toolbarIconSize, |
|
|
|
|
tooltip: tooltips[ToolbarButtons.color], |
|
|
|
|
tooltip: buttonTooltips[ToolbarButtons.color], |
|
|
|
|
controller: controller, |
|
|
|
|
background: false, |
|
|
|
|
iconTheme: iconTheme, |
|
|
|
@ -362,7 +365,7 @@ class QuillToolbar extends StatelessWidget implements PreferredSizeWidget { |
|
|
|
|
ColorButton( |
|
|
|
|
icon: Icons.format_color_fill, |
|
|
|
|
iconSize: toolbarIconSize, |
|
|
|
|
tooltip: tooltips[ToolbarButtons.backgroundColor], |
|
|
|
|
tooltip: buttonTooltips[ToolbarButtons.backgroundColor], |
|
|
|
|
controller: controller, |
|
|
|
|
background: true, |
|
|
|
|
iconTheme: iconTheme, |
|
|
|
@ -372,7 +375,7 @@ class QuillToolbar extends StatelessWidget implements PreferredSizeWidget { |
|
|
|
|
ClearFormatButton( |
|
|
|
|
icon: Icons.format_clear, |
|
|
|
|
iconSize: toolbarIconSize, |
|
|
|
|
tooltip: tooltips[ToolbarButtons.clearFormat], |
|
|
|
|
tooltip: buttonTooltips[ToolbarButtons.clearFormat], |
|
|
|
|
controller: controller, |
|
|
|
|
iconTheme: iconTheme, |
|
|
|
|
afterButtonPressed: afterButtonPressed, |
|
|
|
@ -391,8 +394,8 @@ class QuillToolbar extends StatelessWidget implements PreferredSizeWidget { |
|
|
|
|
if (showAlignmentButtons) |
|
|
|
|
SelectAlignmentButton( |
|
|
|
|
controller: controller, |
|
|
|
|
tooltips: tooltips |
|
|
|
|
..removeWhere((key, value) => [ |
|
|
|
|
tooltips: Map.of(buttonTooltips) |
|
|
|
|
..removeWhere((key, value) => ![ |
|
|
|
|
ToolbarButtons.leftAlignment, |
|
|
|
|
ToolbarButtons.centerAlignment, |
|
|
|
|
ToolbarButtons.rightAlignment, |
|
|
|
@ -409,7 +412,7 @@ class QuillToolbar extends StatelessWidget implements PreferredSizeWidget { |
|
|
|
|
if (showDirection) |
|
|
|
|
ToggleStyleButton( |
|
|
|
|
attribute: Attribute.rtl, |
|
|
|
|
tooltip: tooltips[ToolbarButtons.direction], |
|
|
|
|
tooltip: buttonTooltips[ToolbarButtons.direction], |
|
|
|
|
controller: controller, |
|
|
|
|
icon: Icons.format_textdirection_r_to_l, |
|
|
|
|
iconSize: toolbarIconSize, |
|
|
|
@ -425,7 +428,7 @@ class QuillToolbar extends StatelessWidget implements PreferredSizeWidget { |
|
|
|
|
_dividerOnAxis(axis), |
|
|
|
|
if (showHeaderStyle) |
|
|
|
|
SelectHeaderStyleButton( |
|
|
|
|
tooltip: tooltips[ToolbarButtons.headerStyle], |
|
|
|
|
tooltip: buttonTooltips[ToolbarButtons.headerStyle], |
|
|
|
|
controller: controller, |
|
|
|
|
axis: axis, |
|
|
|
|
iconSize: toolbarIconSize, |
|
|
|
@ -442,7 +445,7 @@ class QuillToolbar extends StatelessWidget implements PreferredSizeWidget { |
|
|
|
|
if (showListNumbers) |
|
|
|
|
ToggleStyleButton( |
|
|
|
|
attribute: Attribute.ol, |
|
|
|
|
tooltip: tooltips[ToolbarButtons.listNumbers], |
|
|
|
|
tooltip: buttonTooltips[ToolbarButtons.listNumbers], |
|
|
|
|
controller: controller, |
|
|
|
|
icon: Icons.format_list_numbered, |
|
|
|
|
iconSize: toolbarIconSize, |
|
|
|
@ -452,7 +455,7 @@ class QuillToolbar extends StatelessWidget implements PreferredSizeWidget { |
|
|
|
|
if (showListBullets) |
|
|
|
|
ToggleStyleButton( |
|
|
|
|
attribute: Attribute.ul, |
|
|
|
|
tooltip: tooltips[ToolbarButtons.listBullets], |
|
|
|
|
tooltip: buttonTooltips[ToolbarButtons.listBullets], |
|
|
|
|
controller: controller, |
|
|
|
|
icon: Icons.format_list_bulleted, |
|
|
|
|
iconSize: toolbarIconSize, |
|
|
|
@ -462,7 +465,7 @@ class QuillToolbar extends StatelessWidget implements PreferredSizeWidget { |
|
|
|
|
if (showListCheck) |
|
|
|
|
ToggleCheckListButton( |
|
|
|
|
attribute: Attribute.unchecked, |
|
|
|
|
tooltip: tooltips[ToolbarButtons.listChecks], |
|
|
|
|
tooltip: buttonTooltips[ToolbarButtons.listChecks], |
|
|
|
|
controller: controller, |
|
|
|
|
icon: Icons.check_box, |
|
|
|
|
iconSize: toolbarIconSize, |
|
|
|
@ -472,7 +475,7 @@ class QuillToolbar extends StatelessWidget implements PreferredSizeWidget { |
|
|
|
|
if (showCodeBlock) |
|
|
|
|
ToggleStyleButton( |
|
|
|
|
attribute: Attribute.codeBlock, |
|
|
|
|
tooltip: tooltips[ToolbarButtons.codeBlock], |
|
|
|
|
tooltip: buttonTooltips[ToolbarButtons.codeBlock], |
|
|
|
|
controller: controller, |
|
|
|
|
icon: Icons.code, |
|
|
|
|
iconSize: toolbarIconSize, |
|
|
|
@ -486,7 +489,7 @@ class QuillToolbar extends StatelessWidget implements PreferredSizeWidget { |
|
|
|
|
if (showQuote) |
|
|
|
|
ToggleStyleButton( |
|
|
|
|
attribute: Attribute.blockQuote, |
|
|
|
|
tooltip: tooltips[ToolbarButtons.quote], |
|
|
|
|
tooltip: buttonTooltips[ToolbarButtons.quote], |
|
|
|
|
controller: controller, |
|
|
|
|
icon: Icons.format_quote, |
|
|
|
|
iconSize: toolbarIconSize, |
|
|
|
@ -497,7 +500,7 @@ class QuillToolbar extends StatelessWidget implements PreferredSizeWidget { |
|
|
|
|
IndentButton( |
|
|
|
|
icon: Icons.format_indent_increase, |
|
|
|
|
iconSize: toolbarIconSize, |
|
|
|
|
tooltip: tooltips[ToolbarButtons.indentIncrease], |
|
|
|
|
tooltip: buttonTooltips[ToolbarButtons.indentIncrease], |
|
|
|
|
controller: controller, |
|
|
|
|
isIncrease: true, |
|
|
|
|
iconTheme: iconTheme, |
|
|
|
@ -507,7 +510,7 @@ class QuillToolbar extends StatelessWidget implements PreferredSizeWidget { |
|
|
|
|
IndentButton( |
|
|
|
|
icon: Icons.format_indent_decrease, |
|
|
|
|
iconSize: toolbarIconSize, |
|
|
|
|
tooltip: tooltips[ToolbarButtons.indentDecrease], |
|
|
|
|
tooltip: buttonTooltips[ToolbarButtons.indentDecrease], |
|
|
|
|
controller: controller, |
|
|
|
|
isIncrease: false, |
|
|
|
|
iconTheme: iconTheme, |
|
|
|
@ -517,7 +520,7 @@ class QuillToolbar extends StatelessWidget implements PreferredSizeWidget { |
|
|
|
|
_dividerOnAxis(axis), |
|
|
|
|
if (showLink) |
|
|
|
|
LinkStyleButton( |
|
|
|
|
tooltip: tooltips[ToolbarButtons.link], |
|
|
|
|
tooltip: buttonTooltips[ToolbarButtons.link], |
|
|
|
|
controller: controller, |
|
|
|
|
iconSize: toolbarIconSize, |
|
|
|
|
iconTheme: iconTheme, |
|
|
|
@ -528,7 +531,7 @@ class QuillToolbar extends StatelessWidget implements PreferredSizeWidget { |
|
|
|
|
SearchButton( |
|
|
|
|
icon: Icons.search, |
|
|
|
|
iconSize: toolbarIconSize, |
|
|
|
|
tooltip: tooltips[ToolbarButtons.search], |
|
|
|
|
tooltip: buttonTooltips[ToolbarButtons.search], |
|
|
|
|
controller: controller, |
|
|
|
|
iconTheme: iconTheme, |
|
|
|
|
dialogTheme: dialogTheme, |
|
|
|
@ -589,6 +592,16 @@ class QuillToolbar extends StatelessWidget implements PreferredSizeWidget { |
|
|
|
|
final List<QuillCustomButton> customButtons; |
|
|
|
|
|
|
|
|
|
/// Tooltips for toolbar buttons. |
|
|
|
|
///Map of tooltips for toolbar buttons |
|
|
|
|
/// |
|
|
|
|
///The example is: |
|
|
|
|
///```dart |
|
|
|
|
/// tooltips = <ToolbarButtons, String>{ |
|
|
|
|
/// ToolbarButtons.undo: 'Undo', |
|
|
|
|
/// ToolbarButtons.redo: 'Redo', |
|
|
|
|
/// } |
|
|
|
|
/// |
|
|
|
|
///``` |
|
|
|
|
final Map<ToolbarButtons, String> tooltips; |
|
|
|
|
|
|
|
|
|
@override |
|
|
|
|