Allow disabling of selection toolbar. (#972)

pull/973/head
Benjamin Quinn 3 years ago committed by GitHub
parent 8196311720
commit ccf1850e9a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 1
      example/lib/pages/home_page.dart
  2. 18
      lib/src/widgets/editor.dart

@ -108,6 +108,7 @@ class _HomePageState extends State<HomePage> {
autoFocus: false, autoFocus: false,
readOnly: false, readOnly: false,
placeholder: 'Add content', placeholder: 'Add content',
enableSelectionToolbar: !(kIsWeb || _isDesktop()),
expands: false, expands: false,
padding: EdgeInsets.zero, padding: EdgeInsets.zero,
onImagePaste: _onImagePaste, onImagePaste: _onImagePaste,

@ -157,6 +157,7 @@ class QuillEditor extends StatefulWidget {
this.paintCursorAboveText, this.paintCursorAboveText,
this.placeholder, this.placeholder,
this.enableInteractiveSelection = true, this.enableInteractiveSelection = true,
this.enableSelectionToolbar = true,
this.scrollBottomInset = 0, this.scrollBottomInset = 0,
this.minHeight, this.minHeight,
this.maxHeight, this.maxHeight,
@ -266,8 +267,14 @@ class QuillEditor extends StatefulWidget {
/// When this is false, the text selection cannot be adjusted by /// When this is false, the text selection cannot be adjusted by
/// the user, text cannot be copied, and the user cannot paste into /// the user, text cannot be copied, and the user cannot paste into
/// the text field from the clipboard. /// the text field from the clipboard.
///
/// To disable just the selection toolbar, set enableSelectionToolbar
/// to false.
final bool enableInteractiveSelection; final bool enableInteractiveSelection;
/// Whether to show the cut/copy/paste menu when selecting text.
final bool enableSelectionToolbar;
/// The minimum height to be occupied by this editor. /// The minimum height to be occupied by this editor.
/// ///
/// This only has effect if [scrollable] is set to `true` and [expands] is /// This only has effect if [scrollable] is set to `true` and [expands] is
@ -435,6 +442,9 @@ class QuillEditorState extends State<QuillEditor>
theme.colorScheme.primary.withOpacity(0.40); theme.colorScheme.primary.withOpacity(0.40);
} }
final showSelectionToolbar =
widget.enableInteractiveSelection && widget.enableSelectionToolbar;
final child = RawEditor( final child = RawEditor(
key: _editorKey, key: _editorKey,
controller: widget.controller, controller: widget.controller,
@ -447,10 +457,10 @@ class QuillEditorState extends State<QuillEditor>
placeholder: widget.placeholder, placeholder: widget.placeholder,
onLaunchUrl: widget.onLaunchUrl, onLaunchUrl: widget.onLaunchUrl,
toolbarOptions: ToolbarOptions( toolbarOptions: ToolbarOptions(
copy: widget.enableInteractiveSelection, copy: showSelectionToolbar,
cut: widget.enableInteractiveSelection, cut: showSelectionToolbar,
paste: widget.enableInteractiveSelection, paste: showSelectionToolbar,
selectAll: widget.enableInteractiveSelection, selectAll: showSelectionToolbar,
), ),
showSelectionHandles: isMobile(theme.platform), showSelectionHandles: isMobile(theme.platform),
showCursor: widget.showCursor, showCursor: widget.showCursor,

Loading…
Cancel
Save