@ -4,6 +4,7 @@ import 'dart:io';
import ' dart:math ' as math ;
import ' dart:math ' as math ;
/ / ignore: unnecessary_import
/ / ignore: unnecessary_import
import ' dart:typed_data ' ;
import ' dart:typed_data ' ;
import ' dart:ui ' as ui hide TextStyle ;
import ' package:flutter/foundation.dart ' ;
import ' package:flutter/foundation.dart ' ;
import ' package:flutter/material.dart ' ;
import ' package:flutter/material.dart ' ;
@ -371,6 +372,40 @@ class RawEditorState extends EditorState
) ;
) ;
}
}
void _defaultOnTapOutside ( PointerDownEvent event ) {
/ / / The focus dropping behavior is only present on desktop platforms
/ / / and mobile browsers .
switch ( defaultTargetPlatform ) {
case TargetPlatform . android:
case TargetPlatform . iOS:
case TargetPlatform . fuchsia:
/ / On mobile platforms , we don ' t unfocus on touch events unless they ' re
/ / in the web browser , but we do unfocus for all other kinds of events .
switch ( event . kind ) {
case ui . PointerDeviceKind . touch:
if ( kIsWeb ) {
widget . focusNode . unfocus ( ) ;
}
break ;
case ui . PointerDeviceKind . mouse:
case ui . PointerDeviceKind . stylus:
case ui . PointerDeviceKind . invertedStylus:
case ui . PointerDeviceKind . unknown:
widget . focusNode . unfocus ( ) ;
break ;
case ui . PointerDeviceKind . trackpad:
throw UnimplementedError (
' Unexpected pointer down event for trackpad ' ) ;
}
break ;
case TargetPlatform . linux:
case TargetPlatform . macOS:
case TargetPlatform . windows:
widget . focusNode . unfocus ( ) ;
break ;
}
}
@ override
@ override
Widget build ( BuildContext context ) {
Widget build ( BuildContext context ) {
assert ( debugCheckHasMediaQuery ( context ) ) ;
assert ( debugCheckHasMediaQuery ( context ) ) ;
@ -454,78 +489,85 @@ class RawEditorState extends EditorState
minHeight: widget . minHeight ? ? 0.0 ,
minHeight: widget . minHeight ? ? 0.0 ,
maxHeight: widget . maxHeight ? ? double . infinity ) ;
maxHeight: widget . maxHeight ? ? double . infinity ) ;
return QuillStyles (
return TextFieldTapRegion (
data: _styles ! ,
onTapOutside: _defaultOnTapOutside ,
child: Shortcuts (
child: QuillStyles (
shortcuts: < LogicalKeySet , Intent > {
data: _styles ! ,
/ / shortcuts added for Desktop platforms .
child: Shortcuts (
LogicalKeySet ( LogicalKeyboardKey . escape ) :
shortcuts: < LogicalKeySet , Intent > {
const HideSelectionToolbarIntent ( ) ,
/ / shortcuts added for Desktop platforms .
LogicalKeySet ( LogicalKeyboardKey . control , LogicalKeyboardKey . keyZ ) :
LogicalKeySet ( LogicalKeyboardKey . escape ) :
const UndoTextIntent ( SelectionChangedCause . keyboard ) ,
const HideSelectionToolbarIntent ( ) ,
LogicalKeySet ( LogicalKeyboardKey . control , LogicalKeyboardKey . keyY ) :
LogicalKeySet ( LogicalKeyboardKey . control , LogicalKeyboardKey . keyZ ) :
const RedoTextIntent ( SelectionChangedCause . keyboard ) ,
const UndoTextIntent ( SelectionChangedCause . keyboard ) ,
LogicalKeySet ( LogicalKeyboardKey . control , LogicalKeyboardKey . keyY ) :
/ / Selection formatting .
const RedoTextIntent ( SelectionChangedCause . keyboard ) ,
LogicalKeySet ( LogicalKeyboardKey . control , LogicalKeyboardKey . keyB ) :
const ToggleTextStyleIntent ( Attribute . bold ) ,
/ / Selection formatting .
LogicalKeySet ( LogicalKeyboardKey . control , LogicalKeyboardKey . keyU ) :
LogicalKeySet ( LogicalKeyboardKey . control , LogicalKeyboardKey . keyB ) :
const ToggleTextStyleIntent ( Attribute . underline ) ,
const ToggleTextStyleIntent ( Attribute . bold ) ,
LogicalKeySet ( LogicalKeyboardKey . control , LogicalKeyboardKey . keyI ) :
LogicalKeySet ( LogicalKeyboardKey . control , LogicalKeyboardKey . keyU ) :
const ToggleTextStyleIntent ( Attribute . italic ) ,
const ToggleTextStyleIntent ( Attribute . underline ) ,
LogicalKeySet ( LogicalKeyboardKey . control , LogicalKeyboardKey . shift ,
LogicalKeySet ( LogicalKeyboardKey . control , LogicalKeyboardKey . keyI ) :
LogicalKeyboardKey . keyS ) :
const ToggleTextStyleIntent ( Attribute . italic ) ,
const ToggleTextStyleIntent ( Attribute . strikeThrough ) ,
LogicalKeySet ( LogicalKeyboardKey . control , LogicalKeyboardKey . shift ,
LogicalKeySet (
LogicalKeyboardKey . keyS ) :
LogicalKeyboardKey . control , LogicalKeyboardKey . backquote ) :
const ToggleTextStyleIntent ( Attribute . strikeThrough ) ,
const ToggleTextStyleIntent ( Attribute . inlineCode ) ,
LogicalKeySet (
LogicalKeySet ( LogicalKeyboardKey . control , LogicalKeyboardKey . keyL ) :
LogicalKeyboardKey . control , LogicalKeyboardKey . backquote ) :
const ToggleTextStyleIntent ( Attribute . ul ) ,
const ToggleTextStyleIntent ( Attribute . inlineCode ) ,
LogicalKeySet ( LogicalKeyboardKey . control , LogicalKeyboardKey . keyO ) :
LogicalKeySet ( LogicalKeyboardKey . control , LogicalKeyboardKey . keyL ) :
const ToggleTextStyleIntent ( Attribute . ol ) ,
const ToggleTextStyleIntent ( Attribute . ul ) ,
LogicalKeySet ( LogicalKeyboardKey . control , LogicalKeyboardKey . shift ,
LogicalKeySet ( LogicalKeyboardKey . control , LogicalKeyboardKey . keyO ) :
LogicalKeyboardKey . keyB ) :
const ToggleTextStyleIntent ( Attribute . ol ) ,
const ToggleTextStyleIntent ( Attribute . blockQuote ) ,
LogicalKeySet ( LogicalKeyboardKey . control , LogicalKeyboardKey . shift ,
LogicalKeySet ( LogicalKeyboardKey . control , LogicalKeyboardKey . shift ,
LogicalKeyboardKey . keyB ) :
LogicalKeyboardKey . tilde ) :
const ToggleTextStyleIntent ( Attribute . blockQuote ) ,
const ToggleTextStyleIntent ( Attribute . codeBlock ) ,
LogicalKeySet ( LogicalKeyboardKey . control , LogicalKeyboardKey . shift ,
/ / Indent
LogicalKeyboardKey . tilde ) :
LogicalKeySet (
const ToggleTextStyleIntent ( Attribute . codeBlock ) ,
LogicalKeyboardKey . control , LogicalKeyboardKey . bracketRight ) :
/ / Indent
const IndentSelectionIntent ( true ) ,
LogicalKeySet ( LogicalKeyboardKey . control ,
LogicalKeySet (
LogicalKeyboardKey . bracketRight ) :
LogicalKeyboardKey . control , LogicalKeyboardKey . bracketLeft ) :
const IndentSelectionIntent ( true ) ,
const IndentSelectionIntent ( false ) ,
LogicalKeySet (
LogicalKeyboardKey . control , LogicalKeyboardKey . bracketLeft ) :
LogicalKeySet ( LogicalKeyboardKey . control , LogicalKeyboardKey . keyF ) :
const IndentSelectionIntent ( false ) ,
const OpenSearchIntent ( ) ,
LogicalKeySet ( LogicalKeyboardKey . control , LogicalKeyboardKey . keyF ) :
LogicalKeySet ( LogicalKeyboardKey . control , LogicalKeyboardKey . digit1 ) :
const OpenSearchIntent ( ) ,
const ApplyHeaderIntent ( Attribute . h1 ) ,
LogicalKeySet ( LogicalKeyboardKey . control , LogicalKeyboardKey . digit2 ) :
LogicalKeySet (
const ApplyHeaderIntent ( Attribute . h2 ) ,
LogicalKeyboardKey . control , LogicalKeyboardKey . digit1 ) :
LogicalKeySet ( LogicalKeyboardKey . control , LogicalKeyboardKey . digit3 ) :
const ApplyHeaderIntent ( Attribute . h1 ) ,
const ApplyHeaderIntent ( Attribute . h3 ) ,
LogicalKeySet (
LogicalKeySet ( LogicalKeyboardKey . control , LogicalKeyboardKey . digit0 ) :
LogicalKeyboardKey . control , LogicalKeyboardKey . digit2 ) :
const ApplyHeaderIntent ( Attribute . header ) ,
const ApplyHeaderIntent ( Attribute . h2 ) ,
LogicalKeySet (
LogicalKeySet ( LogicalKeyboardKey . control , LogicalKeyboardKey . shift ,
LogicalKeyboardKey . control , LogicalKeyboardKey . digit3 ) :
LogicalKeyboardKey . keyL ) : const ApplyCheckListIntent ( ) ,
const ApplyHeaderIntent ( Attribute . h3 ) ,
LogicalKeySet (
if ( widget . customShortcuts ! = null ) . . . widget . customShortcuts ! ,
LogicalKeyboardKey . control , LogicalKeyboardKey . digit0 ) :
} ,
const ApplyHeaderIntent ( Attribute . header ) ,
child: Actions (
actions: {
LogicalKeySet ( LogicalKeyboardKey . control , LogicalKeyboardKey . shift ,
. . . _actions ,
LogicalKeyboardKey . keyL ) : const ApplyCheckListIntent ( ) ,
if ( widget . customActions ! = null ) . . . widget . customActions ! ,
if ( widget . customShortcuts ! = null ) . . . widget . customShortcuts ! ,
} ,
} ,
child: Focus (
child: Actions (
focusNode: widget . focusNode ,
actions: {
onKey: _onKey ,
. . . _actions ,
child: QuillKeyboardListener (
if ( widget . customActions ! = null ) . . . widget . customActions ! ,
child: Container (
} ,
constraints: constraints ,
child: Focus (
child: child ,
focusNode: widget . focusNode ,
onKey: _onKey ,
child: QuillKeyboardListener (
child: Container (
constraints: constraints ,
child: child ,
) ,
) ,
) ,
) ,
) ,
) ,
) ,