Fix issue with basic text editing and editor display

pull/95/head
Miller Adulu 4 years ago
parent 933a17eafb
commit 419f31371b
  1. 17
      lib/widgets/editor.dart
  2. 1
      lib/widgets/raw_editor.dart
  3. 16
      lib/widgets/text_line.dart

@ -149,7 +149,7 @@ class QuillEditor extends StatefulWidget {
final bool? showCursor; final bool? showCursor;
final bool readOnly; final bool readOnly;
final String? placeholder; final String? placeholder;
final bool? enableInteractiveSelection; final bool enableInteractiveSelection;
final double? minHeight; final double? minHeight;
final double? maxHeight; final double? maxHeight;
final DefaultStyles? customStyles; final DefaultStyles? customStyles;
@ -161,8 +161,7 @@ class QuillEditor extends StatefulWidget {
final EmbedBuilder embedBuilder; final EmbedBuilder embedBuilder;
QuillEditor( QuillEditor(
{Key? key, {required this.controller,
required this.controller,
required this.focusNode, required this.focusNode,
required this.scrollController, required this.scrollController,
required this.scrollable, required this.scrollable,
@ -171,7 +170,7 @@ class QuillEditor extends StatefulWidget {
this.showCursor, this.showCursor,
required this.readOnly, required this.readOnly,
this.placeholder, this.placeholder,
this.enableInteractiveSelection, this.enableInteractiveSelection = true,
this.minHeight, this.minHeight,
this.maxHeight, this.maxHeight,
this.customStyles, this.customStyles,
@ -184,7 +183,7 @@ class QuillEditor extends StatefulWidget {
kIsWeb ? _defaultEmbedBuilderWeb : _defaultEmbedBuilder}); kIsWeb ? _defaultEmbedBuilderWeb : _defaultEmbedBuilder});
factory QuillEditor.basic( factory QuillEditor.basic(
{Key? key, required QuillController controller, required bool readOnly}) { {required QuillController controller, required bool readOnly}) {
return QuillEditor( return QuillEditor(
controller: controller, controller: controller,
scrollController: ScrollController(), scrollController: ScrollController(),
@ -296,7 +295,7 @@ class _QuillEditorState extends State<QuillEditor>
selectionColor, selectionColor,
textSelectionControls, textSelectionControls,
widget.keyboardAppearance, widget.keyboardAppearance,
widget.enableInteractiveSelection!, widget.enableInteractiveSelection ?? true,
widget.scrollPhysics, widget.scrollPhysics,
widget.embedBuilder), widget.embedBuilder),
); );
@ -313,7 +312,7 @@ class _QuillEditorState extends State<QuillEditor>
} }
@override @override
bool? getSelectionEnabled() { bool getSelectionEnabled() {
return widget.enableInteractiveSelection; return widget.enableInteractiveSelection;
} }
@ -341,7 +340,7 @@ class _QuillEditorSelectionGestureDetectorBuilder
@override @override
void onSingleLongTapMoveUpdate(LongPressMoveUpdateDetails details) { void onSingleLongTapMoveUpdate(LongPressMoveUpdateDetails details) {
if (!delegate.getSelectionEnabled()!) { if (!delegate.getSelectionEnabled()) {
return; return;
} }
switch (Theme.of(_state.context).platform) { switch (Theme.of(_state.context).platform) {
@ -470,7 +469,7 @@ class _QuillEditorSelectionGestureDetectorBuilder
bool positionSelected = _onTapping(details); bool positionSelected = _onTapping(details);
if (delegate.getSelectionEnabled()! && !positionSelected) { if (delegate.getSelectionEnabled() && !positionSelected) {
switch (Theme.of(_state.context).platform) { switch (Theme.of(_state.context).platform) {
case TargetPlatform.iOS: case TargetPlatform.iOS:
case TargetPlatform.macOS: case TargetPlatform.macOS:

@ -29,6 +29,7 @@ import 'delegate.dart';
import 'editor.dart'; import 'editor.dart';
import 'keyboard_listener.dart'; import 'keyboard_listener.dart';
class RawEditor extends StatefulWidget { class RawEditor extends StatefulWidget {
final QuillController controller; final QuillController controller;
final FocusNode focusNode; final FocusNode focusNode;

@ -101,7 +101,7 @@ class TextLine extends StatelessWidget {
Attribute.h3: defaultStyles.h3!.style, Attribute.h3: defaultStyles.h3!.style,
}; };
textStyle = textStyle.merge(m[header!] ?? defaultStyles.paragraph!.style); textStyle = textStyle.merge(m[header] ?? defaultStyles.paragraph!.style);
Attribute? block = line.style.getBlockExceptHeader(); Attribute? block = line.style.getBlockExceptHeader();
TextStyle? toMerge; TextStyle? toMerge;
@ -187,8 +187,8 @@ class TextLine extends StatelessWidget {
decorations.add(b.decoration); decorations.add(b.decoration);
} }
return a.merge(b).apply( return a.merge(b).apply(
decoration: decoration: TextDecoration.combine(
TextDecoration.combine(decorations as List<TextDecoration>)); List.castFrom<dynamic, TextDecoration>(decorations)));
} }
} }
@ -824,8 +824,8 @@ class _TextLineElement extends RenderObjectElement {
} }
@override @override
insertRenderObjectChild(RenderObject child, TextLineSlot? slot) { insertRenderObjectChild(RenderBox child, TextLineSlot? slot) {
assert(child is RenderBox); // assert(child is RenderBox);
_updateRenderObject(child, slot); _updateRenderObject(child, slot);
assert(renderObject.children.keys.contains(slot)); assert(renderObject.children.keys.contains(slot));
} }
@ -854,13 +854,13 @@ class _TextLineElement extends RenderObjectElement {
} }
} }
_updateRenderObject(RenderObject? child, TextLineSlot? slot) { _updateRenderObject(RenderBox? child, TextLineSlot? slot) {
switch (slot) { switch (slot) {
case TextLineSlot.LEADING: case TextLineSlot.LEADING:
renderObject.setLeading(child as RenderBox?); renderObject.setLeading(child);
break; break;
case TextLineSlot.BODY: case TextLineSlot.BODY:
renderObject.setBody((child as RenderBox?) as RenderContentProxyBox?); renderObject.setBody((child) as RenderContentProxyBox?);
break; break;
default: default:
throw UnimplementedError(); throw UnimplementedError();

Loading…
Cancel
Save