diff --git a/CHANGELOG.md b/CHANGELOG.md index ff863a258..595b23390 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,11 +10,15 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +### Changed + +- **BREAKING**: Change the `options` parameter class type from `QuillToolbarToggleStyleButtonOptions` to `QuillToolbarClipboardButtonOptions` in `QuillToolbarClipboardButton`. To migrate, use `QuillToolbarClipboardButtonOptions` instead of `QuillToolbarToggleStyleButtonOptions` [#2433](https://github.com/singerdmx/flutter-quill/pull/2433). + ## [11.0.0-dev.19] - 2025-01-10 ### Added -- Croatian (hr) language translation. +- Croatian (hr) language translation [#2431](https://github.com/singerdmx/flutter-quill/pull/2431). ## [11.0.0-dev.18] - 2025-01-06 diff --git a/doc/migration/10_to_11.md b/doc/migration/10_to_11.md index dbd06b762..cdbd377dd 100644 --- a/doc/migration/10_to_11.md +++ b/doc/migration/10_to_11.md @@ -351,6 +351,7 @@ required for **custom toolbars**. - Renames `QuillToolbarToggleCheckListButtonOptions.isShouldRequestKeyboard` to `QuillToolbarToggleCheckListButtonOptions.shouldRequestKeyboard`. - Moved `onClipboardPaste` from `QuillControllerConfig` to `QuillClipboardConfig`. Added `clipboardConfig` property to `QuillControllerConfig`. - Moved `onImagePaste` and `onGifPaste` from the editor's config (`QuillEditorConfig` or `QuillRawEditorConfig`) to the clipboard's config (`QuillClipboardConfig`), which is part of the controller's config (`QuillControllerConfig`). +- Changed the options type from `QuillToolbarToggleStyleButtonOptions` to `QuillToolbarClipboardButtonOptions` in `QuillToolbarClipboardButton`, use the new options class. ## 💥 Breaking behavior diff --git a/lib/src/toolbar/buttons/clipboard_button.dart b/lib/src/toolbar/buttons/clipboard_button.dart index 1a0562ae4..1b631e8ce 100644 --- a/lib/src/toolbar/buttons/clipboard_button.dart +++ b/lib/src/toolbar/buttons/clipboard_button.dart @@ -46,13 +46,18 @@ class QuillToolbarClipboardButton extends QuillToolbarToggleStyleBaseButton { QuillToolbarClipboardButton({ required super.controller, required this.clipboardAction, - super.options = const QuillToolbarToggleStyleButtonOptions(), + QuillToolbarClipboardButtonOptions? options, /// Shares common options between all buttons, prefer the [options] /// over the [baseOptions]. super.baseOptions, super.key, - }); + }) : _options = options, + super(options: options ?? const QuillToolbarClipboardButtonOptions()); + + // TODO: This field will be used by the PR: https://github.com/singerdmx/flutter-quill/pull/2427 + // ignore: unused_field + final QuillToolbarClipboardButtonOptions? _options; final ClipboardAction clipboardAction; diff --git a/lib/src/toolbar/config/buttons/clipboard_button_options.dart b/lib/src/toolbar/config/buttons/clipboard_button_options.dart new file mode 100644 index 000000000..0bc89b8cc --- /dev/null +++ b/lib/src/toolbar/config/buttons/clipboard_button_options.dart @@ -0,0 +1,29 @@ +/// @docImport '../../buttons/clipboard_button.dart'; + +@experimental +library; + +import 'package:meta/meta.dart'; +import 'toggle_style_options.dart'; + +@experimental +class QuillToolbarClipboardButtonOptions + extends QuillToolbarToggleStyleButtonOptions { + const QuillToolbarClipboardButtonOptions({ + super.iconData, + super.afterButtonPressed, + super.childBuilder, + super.iconTheme, + super.tooltip, + super.iconSize, + super.iconButtonFactor, + this.enableClipboardPaste, + }); + + /// Determines if the paste button is enabled. The button is disabled and cannot be clicked if set to `false`. + /// + /// Defaults to [ClipboardMonitor] in case of `null`, which checks if the clipboard has content to paste every second and only then enables the button, indicating to the user that they can paste something. + /// + /// Set it to `true` to enable it even if the clipboard has no content to paste, which will do nothing on a press. + final bool? enableClipboardPaste; +} diff --git a/lib/src/toolbar/config/simple_toolbar_button_options.dart b/lib/src/toolbar/config/simple_toolbar_button_options.dart index 8794af97c..435c2d03b 100644 --- a/lib/src/toolbar/config/simple_toolbar_button_options.dart +++ b/lib/src/toolbar/config/simple_toolbar_button_options.dart @@ -1,7 +1,8 @@ -import 'package:flutter/foundation.dart' show immutable; +import 'package:meta/meta.dart'; import 'base_button_options.dart'; import 'buttons/clear_format_options.dart'; +import 'buttons/clipboard_button_options.dart'; import 'buttons/color_options.dart'; import 'buttons/custom_button_options.dart'; import 'buttons/font_family_options.dart'; @@ -21,6 +22,7 @@ import 'buttons/toggle_style_options.dart'; export '../buttons/search/search_dialog.dart'; export 'base_button_options.dart'; export 'buttons/clear_format_options.dart'; +export 'buttons/clipboard_button_options.dart'; export 'buttons/color_options.dart'; export 'buttons/custom_button_options.dart'; export 'buttons/font_family_options.dart'; @@ -76,9 +78,12 @@ class QuillSimpleToolbarButtonOptions { this.linkStyle = const QuillToolbarLinkStyleButtonOptions(), this.linkStyle2 = const QuillToolbarLinkStyleButton2Options(), this.customButtons = const QuillToolbarCustomButtonOptions(), - this.clipboardCut = const QuillToolbarToggleStyleButtonOptions(), - this.clipboardCopy = const QuillToolbarToggleStyleButtonOptions(), - this.clipboardPaste = const QuillToolbarToggleStyleButtonOptions(), + @experimental + this.clipboardCut = const QuillToolbarClipboardButtonOptions(), + @experimental + this.clipboardCopy = const QuillToolbarClipboardButtonOptions(), + @experimental + this.clipboardPaste = const QuillToolbarClipboardButtonOptions(), }); /// The base options that will apply to all buttons, @@ -109,26 +114,19 @@ class QuillSimpleToolbarButtonOptions { final QuillToolbarColorButtonOptions backgroundColor; final QuillToolbarClearFormatButtonOptions clearFormat; - /// The reason we call this buttons in the end because this is responsible - /// for all the alignment buttons and not just one, you still - /// can customize the icons and tooltips - /// and you have child builder final QuillToolbarSelectAlignmentButtonOptions selectAlignmentButtons; final QuillToolbarSearchButtonOptions search; - final QuillToolbarToggleStyleButtonOptions clipboardCut; - final QuillToolbarToggleStyleButtonOptions clipboardCopy; - final QuillToolbarToggleStyleButtonOptions clipboardPaste; + @experimental + final QuillToolbarClipboardButtonOptions clipboardCut; + @experimental + final QuillToolbarClipboardButtonOptions clipboardCopy; + @experimental + final QuillToolbarClipboardButtonOptions clipboardPaste; - /// The reason we call this buttons in the end because this is responsible - /// for all the header style buttons and not just one, you still - /// can customize it and you also have child builder final QuillToolbarSelectHeaderStyleButtonsOptions selectHeaderStyleButtons; - /// The reason we call this buttons in the end because this is responsible - /// for all the header style buttons and not just one, you still - /// can customize it and you also have child builder final QuillToolbarSelectHeaderStyleDropdownButtonOptions selectHeaderStyleDropdownButton;