Merge branch 'singerdmx:master' into master

pull/1270/head
Cierra_Runis 2 years ago committed by GitHub
commit 7c278fac20
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 7
      CHANGELOG.md
  2. 8
      flutter_quill_extensions/CHANGELOG.md
  3. 3
      flutter_quill_extensions/pubspec.yaml
  4. 2
      lib/src/widgets/proxy.dart
  5. 184
      lib/src/widgets/raw_editor.dart
  6. 34
      lib/src/widgets/raw_editor/raw_editor_state_text_input_client_mixin.dart
  7. 12
      lib/src/widgets/text_line.dart
  8. 2
      pubspec.yaml

@ -1,3 +1,10 @@
# [7.0.5]
* Fix IME position bug for Mac and Windows.
* Unfocus when tap outside editor. fix the bug that cant refocus in afterButtonPressed after click ToggleStyleButton on Mac.
# [7.0.4]
* Have text selection span full line height for uneven sized text.
# [7.0.3] # [7.0.3]
* Fix ordered list numeration for lists with more than one level of list. * Fix ordered list numeration for lists with more than one level of list.

@ -1,3 +1,11 @@
## 0.2.0
* Allow widgets to override widget span properties [b7951b0](https://github.com/singerdmx/flutter-quill/commit/b7951b02c9086ea42e7aad6d78e6c9b0297562e5)
* Remove tuples [3e9452e](https://github.com/singerdmx/flutter-quill/commit/3e9452e675e8734ff50364c5f7b5d34088d5ff05)
* Remove transparent color of ImageVideoUtils dialog [74544bd](https://github.com/singerdmx/flutter-quill/commit/74544bd945a9d212ca1e8d6b3053dbecee22b720)
* Migrate to `youtube_player_flutter` from `youtube_player_flutter_quill`
* Updates to forumla button [5228f38](https://github.com/singerdmx/flutter-quill/commit/5228f389ba6f37d61d445cfe138c19fcf8766d71)
## 0.1.0 ## 0.1.0
* Initial release * Initial release

@ -1,6 +1,6 @@
name: flutter_quill_extensions name: flutter_quill_extensions
description: Embed extensions for flutter_quill including image, video, formula and etc. description: Embed extensions for flutter_quill including image, video, formula and etc.
version: 0.1.0 version: 0.2.0
homepage: https://bulletjournal.us/home/index.html homepage: https://bulletjournal.us/home/index.html
repository: https://github.com/singerdmx/flutter-quill/tree/master/flutter_quill_extensions repository: https://github.com/singerdmx/flutter-quill/tree/master/flutter_quill_extensions
@ -21,6 +21,7 @@ dependencies:
gallery_saver: ^2.3.2 gallery_saver: ^2.3.2
math_keyboard: ^0.1.8 math_keyboard: ^0.1.8
string_validator: ^1.0.0 string_validator: ^1.0.0
url_launcher: ^6.1.9
# dependency_overrides: # dependency_overrides:
# flutter_quill: # flutter_quill:

@ -290,7 +290,7 @@ class RenderParagraphProxy extends RenderProxyBox
@override @override
List<TextBox> getBoxesForSelection(TextSelection selection) => child! List<TextBox> getBoxesForSelection(TextSelection selection) => child!
.getBoxesForSelection(selection, boxHeightStyle: BoxHeightStyle.strut); .getBoxesForSelection(selection, boxHeightStyle: BoxHeightStyle.max);
@override @override
void performLayout() { void performLayout() {

@ -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,
),
), ),
), ),
), ),

@ -63,12 +63,44 @@ mixin RawEditorStateTextInputClientMixin on EditorState
); );
_updateSizeAndTransform(); _updateSizeAndTransform();
//update IME position for Windows
_updateComposingRectIfNeeded();
//update IME position for Macos
_updateCaretRectIfNeeded();
_textInputConnection!.setEditingState(_lastKnownRemoteTextEditingValue!); _textInputConnection!.setEditingState(_lastKnownRemoteTextEditingValue!);
} }
_textInputConnection!.show(); _textInputConnection!.show();
} }
void _updateComposingRectIfNeeded() {
final composingRange = _lastKnownRemoteTextEditingValue?.composing ??
textEditingValue.composing;
if (hasConnection) {
assert(mounted);
final offset = composingRange.isValid ? composingRange.start : 0;
final composingRect =
renderEditor.getLocalRectForCaret(TextPosition(offset: offset));
_textInputConnection!.setComposingRect(composingRect);
SchedulerBinding.instance
.addPostFrameCallback((_) => _updateComposingRectIfNeeded());
}
}
void _updateCaretRectIfNeeded() {
if (hasConnection) {
if (renderEditor.selection.isValid &&
renderEditor.selection.isCollapsed) {
final currentTextPosition =
TextPosition(offset: renderEditor.selection.baseOffset);
final caretRect =
renderEditor.getLocalRectForCaret(currentTextPosition);
_textInputConnection!.setCaretRect(caretRect);
}
SchedulerBinding.instance
.addPostFrameCallback((_) => _updateCaretRectIfNeeded());
}
}
/// Closes input connection if it's currently open. Otherwise does nothing. /// Closes input connection if it's currently open. Otherwise does nothing.
void closeConnectionIfNeeded() { void closeConnectionIfNeeded() {
if (!hasConnection) { if (!hasConnection) {

@ -1107,6 +1107,18 @@ class RenderEditableTextLine extends RenderEditableBox {
_selectedRects ??= _body!.getBoxesForSelection( _selectedRects ??= _body!.getBoxesForSelection(
local, local,
); );
// Paint a small rect at the start of empty lines that
// are contained by the selection.
if (line.isEmpty &&
textSelection.baseOffset <= line.offset &&
textSelection.extentOffset > line.offset) {
final lineHeight =
preferredLineHeight(TextPosition(offset: line.offset));
_selectedRects
?.add(TextBox.fromLTRBD(0, 0, 3, lineHeight, textDirection));
}
_paintSelection(context, effectiveOffset); _paintSelection(context, effectiveOffset);
} }
} }

@ -1,6 +1,6 @@
name: flutter_quill name: flutter_quill
description: A rich text editor supporting mobile and web (Demo App @ bulletjournal.us) description: A rich text editor supporting mobile and web (Demo App @ bulletjournal.us)
version: 7.0.3 version: 7.0.5
#author: bulletjournal #author: bulletjournal
homepage: https://bulletjournal.us/home/index.html homepage: https://bulletjournal.us/home/index.html
repository: https://github.com/singerdmx/flutter-quill repository: https://github.com/singerdmx/flutter-quill

Loading…
Cancel
Save