|
|
|
@ -1,6 +1,7 @@ |
|
|
|
|
import 'dart:async'; |
|
|
|
|
import 'dart:convert'; |
|
|
|
|
import 'dart:io'; |
|
|
|
|
import 'dart:ui' as ui hide TextStyle; |
|
|
|
|
import 'dart:math' as math; |
|
|
|
|
// ignore: unnecessary_import |
|
|
|
|
import 'dart:typed_data'; |
|
|
|
@ -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 |
|
|
|
|
Widget build(BuildContext context) { |
|
|
|
|
assert(debugCheckHasMediaQuery(context)); |
|
|
|
@ -454,7 +489,9 @@ class RawEditorState extends EditorState |
|
|
|
|
minHeight: widget.minHeight ?? 0.0, |
|
|
|
|
maxHeight: widget.maxHeight ?? double.infinity); |
|
|
|
|
|
|
|
|
|
return QuillStyles( |
|
|
|
|
return TextFieldTapRegion( |
|
|
|
|
onTapOutside: _defaultOnTapOutside, |
|
|
|
|
child: QuillStyles( |
|
|
|
|
data: _styles!, |
|
|
|
|
child: Shortcuts( |
|
|
|
|
shortcuts: <LogicalKeySet, Intent>{ |
|
|
|
@ -490,8 +527,8 @@ class RawEditorState extends EditorState |
|
|
|
|
LogicalKeyboardKey.tilde): |
|
|
|
|
const ToggleTextStyleIntent(Attribute.codeBlock), |
|
|
|
|
// Indent |
|
|
|
|
LogicalKeySet( |
|
|
|
|
LogicalKeyboardKey.control, LogicalKeyboardKey.bracketRight): |
|
|
|
|
LogicalKeySet(LogicalKeyboardKey.control, |
|
|
|
|
LogicalKeyboardKey.bracketRight): |
|
|
|
|
const IndentSelectionIntent(true), |
|
|
|
|
LogicalKeySet( |
|
|
|
|
LogicalKeyboardKey.control, LogicalKeyboardKey.bracketLeft): |
|
|
|
@ -500,13 +537,17 @@ class RawEditorState extends EditorState |
|
|
|
|
LogicalKeySet(LogicalKeyboardKey.control, LogicalKeyboardKey.keyF): |
|
|
|
|
const OpenSearchIntent(), |
|
|
|
|
|
|
|
|
|
LogicalKeySet(LogicalKeyboardKey.control, LogicalKeyboardKey.digit1): |
|
|
|
|
LogicalKeySet( |
|
|
|
|
LogicalKeyboardKey.control, LogicalKeyboardKey.digit1): |
|
|
|
|
const ApplyHeaderIntent(Attribute.h1), |
|
|
|
|
LogicalKeySet(LogicalKeyboardKey.control, LogicalKeyboardKey.digit2): |
|
|
|
|
LogicalKeySet( |
|
|
|
|
LogicalKeyboardKey.control, LogicalKeyboardKey.digit2): |
|
|
|
|
const ApplyHeaderIntent(Attribute.h2), |
|
|
|
|
LogicalKeySet(LogicalKeyboardKey.control, LogicalKeyboardKey.digit3): |
|
|
|
|
LogicalKeySet( |
|
|
|
|
LogicalKeyboardKey.control, LogicalKeyboardKey.digit3): |
|
|
|
|
const ApplyHeaderIntent(Attribute.h3), |
|
|
|
|
LogicalKeySet(LogicalKeyboardKey.control, LogicalKeyboardKey.digit0): |
|
|
|
|
LogicalKeySet( |
|
|
|
|
LogicalKeyboardKey.control, LogicalKeyboardKey.digit0): |
|
|
|
|
const ApplyHeaderIntent(Attribute.header), |
|
|
|
|
|
|
|
|
|
LogicalKeySet(LogicalKeyboardKey.control, LogicalKeyboardKey.shift, |
|
|
|
@ -531,6 +572,7 @@ class RawEditorState extends EditorState |
|
|
|
|
), |
|
|
|
|
), |
|
|
|
|
), |
|
|
|
|
), |
|
|
|
|
); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|