Fix reported issues (#1886)

* toggle_style_button : calls to options.afterButtonPressed replaced by call to class function afterButtonPressed to allow default call to base button settings
quill_icon_button: L26 build for isSelected updated to call afterButtonPressed = same as if not selected
QuillController _updateSelection removed param=source because not used; added new param insertNewline when true set tog to style of preceding char (last entered); updated replaceText to call _updateSelection for NL
document collectStyle:  Selecting the start of a line, user expects the style to be the visible style of the line including inline styles

* color_button calls afterButtonPressed
insert at start of line uses style for line

* Remove comments

* Fix formatting issue

* Fix FontFamily and Size button actions

* Fix FontFamily and Size button actions

* Value setting Stateful toolbar buttons derive from base class

* Rename base class as QuillToolbarBaseValueButton

* Fixes for before_push script

* Removed deprecated functions

* Move clipboard actions to QuillController

* Fix: collectAllIndividualStylesAndEmbed for result span

* Add: Clipboard toolbar buttons

* export: Clipboard toolbar buttons

* Fix: Dividers not shown in toolbar when multiRowsDisplay.
Fix: Toolbar drop buttons clipped when !multiRowsDisplay

* Add: test for QuillController clipboard
Dart Formatted

* Localizations updated

* QuillControllerConfigurations and clipboard paste

* Fix: CheckList action

* Fix: Multiline selection  and refactor toolbar buttons

* Add tests: Multiline selection

* Fix header toggle button and new block attribute support.

* Fix QuillToolbarColorButtonExtraOptions

---------

Co-authored-by: Douglas Ward <dward@scied.com>
pull/1893/head v9.3.19
AtlasAutocode 11 months ago committed by GitHub
parent 0f3f159931
commit f7a00e5a01
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 1
      lib/src/models/documents/nodes/line.dart
  2. 4
      lib/src/models/rules/insert.dart
  3. 7
      lib/src/widgets/toolbar/base_button/base_value_button.dart
  4. 5
      lib/src/widgets/toolbar/buttons/clipboard_button.dart
  5. 10
      lib/src/widgets/toolbar/buttons/color/color_button.dart
  6. 3
      lib/src/widgets/toolbar/buttons/font_family_button.dart
  7. 3
      lib/src/widgets/toolbar/buttons/font_size_button.dart
  8. 3
      lib/src/widgets/toolbar/buttons/hearder_style/select_header_style_buttons.dart
  9. 3
      lib/src/widgets/toolbar/buttons/hearder_style/select_header_style_dropdown_button.dart
  10. 7
      lib/src/widgets/toolbar/buttons/history_button.dart
  11. 11
      lib/src/widgets/toolbar/buttons/indent_button.dart
  12. 5
      lib/src/widgets/toolbar/buttons/link_style_button.dart
  13. 7
      lib/src/widgets/toolbar/buttons/toggle_check_list_button.dart
  14. 8
      lib/src/widgets/toolbar/buttons/toggle_style_button.dart

@ -519,6 +519,7 @@ base class Line extends QuillContainer<Leaf?> {
int _getNodeText(Leaf node, StringBuffer buffer, int offset, int remaining) {
final text = node.toPlainText();
if (text == Embed.kObjectReplacementCharacter) {
buffer.write(Embed.kObjectReplacementCharacter);
return remaining - node.length;
}

@ -565,8 +565,8 @@ class PreserveInlineStylesRule extends InsertRule {
if ((prev.data as String).endsWith('\n')) {
if (prev.attributes != null) {
for (final key in prev.attributes!.keys) {
if (Attribute.blockKeys.contains(key)) {
for (final value in prev.attributes!.values) {
if (!(value as Attribute).isInline) {
return null;
}
}

@ -32,6 +32,13 @@ abstract class QuillToolbarCommonButtonState<
String get tooltip =>
options.tooltip ?? baseButtonExtraOptions?.tooltip ?? defaultTooltip;
IconData get defaultIconData;
IconData get iconData =>
options.iconData ??
context.quillToolbarBaseButtonOptions?.iconData ??
defaultIconData;
double get iconSize =>
options.iconSize ?? baseButtonExtraOptions?.iconSize ?? kDefaultIconSize;

@ -91,7 +91,8 @@ class QuillToolbarClipboardButtonState
ClipboardAction.paste => context.loc.paste,
};
IconData get _icon => switch (widget.clipboardAction) {
@override
IconData get defaultIconData => switch (widget.clipboardAction) {
ClipboardAction.cut => Icons.cut_outlined,
ClipboardAction.copy => Icons.copy_outlined,
ClipboardAction.paste => Icons.paste_outlined,
@ -132,7 +133,7 @@ class QuillToolbarClipboardButtonState
message: tooltip,
child: QuillToolbarIconButton(
icon: Icon(
_icon,
iconData,
size: iconSize * iconButtonFactor,
),
isSelected: false,

@ -103,11 +103,9 @@ class QuillToolbarColorButtonState extends QuillToolbarColorBaseButtonState {
super.dispose();
}
IconData get iconData {
return options.iconData ??
baseButtonExtraOptions?.iconData ??
(widget.isBackground ? Icons.format_color_fill : Icons.color_lens);
}
@override
IconData get defaultIconData =>
widget.isBackground ? Icons.format_color_fill : Icons.color_lens;
@override
Widget build(BuildContext context) {
@ -140,7 +138,7 @@ class QuillToolbarColorButtonState extends QuillToolbarColorBaseButtonState {
_showColorPicker();
afterButtonPressed?.call();
},
iconColor: null,
iconColor: iconColor,
iconColorBackground: iconColorBackground,
fillColor: fillColor,
fillColorBackground: fillColorBackground,

@ -79,6 +79,9 @@ class QuillToolbarFontFamilyButtonState extends QuillToolbarBaseButtonState<
@override
String get defaultTooltip => context.loc.fontFamily;
@override
IconData get defaultIconData => Icons.font_download_outlined;
void _onPressed() {
if (_menuController.isOpen) {
_menuController.close();

@ -85,6 +85,9 @@ class QuillToolbarFontSizeButtonState extends QuillToolbarBaseButtonState<
@override
String get defaultTooltip => context.loc.fontSize;
@override
IconData get defaultIconData => Icons.format_size_outlined;
void _onDropdownButtonPressed() {
if (_menuController.isOpen) {
_menuController.close();

@ -39,6 +39,9 @@ class QuillToolbarSelectHeaderStyleButtonsState
@override
String get defaultTooltip => context.loc.headerStyle;
@override
IconData get defaultIconData => Icons.question_mark_outlined;
Style get _selectionStyle => controller.getSelectionStyle();
final _valueToText = <Attribute, String>{

@ -35,6 +35,9 @@ class _QuillToolbarSelectHeaderStyleDropdownButtonState
@override
String get defaultTooltip => context.loc.headerStyle;
@override
IconData get defaultIconData => Icons.question_mark_outlined;
Attribute<dynamic> _selectedItem = Attribute.header;
final _menuController = MenuController();

@ -36,6 +36,10 @@ class QuillToolbarHistoryButtonState
String get defaultTooltip =>
widget.isUndo ? context.loc.undo : context.loc.redo;
@override
IconData get defaultIconData =>
(widget.isUndo ? Icons.undo_outlined : Icons.redo_outlined);
@override
void initState() {
super.initState();
@ -53,9 +57,6 @@ class QuillToolbarHistoryButtonState
@override
Widget build(BuildContext context) {
final iconData = options.iconData ??
baseButtonExtraOptions?.iconData ??
(widget.isUndo ? Icons.undo_outlined : Icons.redo_outlined);
final childBuilder =
options.childBuilder ?? baseButtonExtraOptions?.childBuilder;

@ -33,13 +33,10 @@ class QuillToolbarIndentButtonState extends QuillToolbarIndentBaseButtonState {
? context.loc.increaseIndent
: context.loc.decreaseIndent;
IconData get iconData {
return options.iconData ??
baseButtonExtraOptions?.iconData ??
(widget.isIncrease
? Icons.format_indent_increase
: Icons.format_indent_decrease);
}
@override
IconData get defaultIconData => widget.isIncrease
? Icons.format_indent_increase
: Icons.format_indent_decrease;
void _sharedOnPressed() {
widget.controller.indentSelection(widget.isIncrease);

@ -62,9 +62,8 @@ class QuillToolbarLinkStyleButtonState
controller.removeListener(_didChangeSelection);
}
IconData get iconData {
return options.iconData ?? baseButtonExtraOptions?.iconData ?? Icons.link;
}
@override
IconData get defaultIconData => Icons.link;
Color get dialogBarrierColor {
return options.dialogBarrierColor ??

@ -52,11 +52,8 @@ class QuillToolbarToggleCheckListButtonState
@override
String get defaultTooltip => context.loc.checkedList;
IconData get iconData {
return options.iconData ??
baseButtonExtraOptions?.iconData ??
Icons.check_box;
}
@override
IconData get defaultIconData => Icons.check_box;
@override
Widget build(BuildContext context) {

@ -96,11 +96,8 @@ class QuillToolbarToggleStyleButtonState
@override
String get defaultTooltip => _defaultTooltipAndIconData.$1;
IconData get iconData {
return options.iconData ??
context.quillToolbarBaseButtonOptions?.iconData ??
_defaultTooltipAndIconData.$2;
}
@override
IconData get defaultIconData => _defaultTooltipAndIconData.$2;
void _onPressed() {
_toggleAttribute();
@ -140,6 +137,7 @@ class QuillToolbarToggleStyleButtonState
bool _getIsToggled(Map<String, Attribute> attrs) {
if (widget.attribute.key == Attribute.list.key ||
widget.attribute.key == Attribute.header.key ||
widget.attribute.key == Attribute.script.key ||
widget.attribute.key == Attribute.align.key) {
final attribute = attrs[widget.attribute.key];

Loading…
Cancel
Save