Fix basic widget rendering and editor usage (#95)

* Upgrade upgradable packages

* Apply default null-safety migrations

* Remove hashnode as a dependency and localize its functionality to the package.

Maintenance was done long time ago hence no need to wait for the update

* Localize ui package to reduce maintenance burdens

* Replace universal html with dart:html

* Remove unnecessary checks

* Fix formatting

* Migrate app to null safety

* Enable methods to be nullable

* Fix non-nullable issue with node methods

* Cast as Node

* Use universal html

* Use universal html package to bring in the ImageElement class

* Remove unused imports

* Fix imports on the editor file

* Add key to quill editor

* Remove final from the GlobalKey

* Remove final on GlobalKey

* Remove custom util implementation in favor of quiver

* Fix issue with null on token attrivute

* Remove final hashcode that is replaced by quiver functionality

* Fix merge request

* Fix hit test position in text_line.dart

* Fix null safety errors on text_selection.dart

* Fix sound null safe errors in toolbar.dart

* Import null safe file picker

* Fix issue with basic text editing and editor display

* Fix issues with basic widget rendering and editing
pull/97/head
Miller Adulu 4 years ago committed by GitHub
parent c593026fd9
commit 3021fbf060
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 12
      lib/widgets/delegate.dart
  2. 29
      lib/widgets/editor.dart
  3. 2
      lib/widgets/text_block.dart
  4. 16
      lib/widgets/text_line.dart

@ -14,7 +14,7 @@ abstract class EditorTextSelectionGestureDetectorBuilderDelegate {
bool getForcePressEnabled();
bool? getSelectionEnabled();
bool getSelectionEnabled();
}
class EditorTextSelectionGestureDetectorBuilder {
@ -43,7 +43,7 @@ class EditorTextSelectionGestureDetectorBuilder {
onForcePressStart(ForcePressDetails details) {
assert(delegate.getForcePressEnabled());
shouldShowSelectionToolbar = true;
if (delegate.getSelectionEnabled()!) {
if (delegate.getSelectionEnabled()) {
getRenderEditor()!.selectWordsInRange(
details.globalPosition,
null,
@ -65,7 +65,7 @@ class EditorTextSelectionGestureDetectorBuilder {
}
onSingleTapUp(TapUpDetails details) {
if (delegate.getSelectionEnabled()!) {
if (delegate.getSelectionEnabled()) {
getRenderEditor()!.selectWordEdge(SelectionChangedCause.tap);
}
}
@ -73,7 +73,7 @@ class EditorTextSelectionGestureDetectorBuilder {
onSingleTapCancel() {}
onSingleLongTapStart(LongPressStartDetails details) {
if (delegate.getSelectionEnabled()!) {
if (delegate.getSelectionEnabled()) {
getRenderEditor()!.selectPositionAt(
details.globalPosition,
null,
@ -83,7 +83,7 @@ class EditorTextSelectionGestureDetectorBuilder {
}
onSingleLongTapMoveUpdate(LongPressMoveUpdateDetails details) {
if (delegate.getSelectionEnabled()!) {
if (delegate.getSelectionEnabled()) {
getRenderEditor()!.selectPositionAt(
details.globalPosition,
null,
@ -99,7 +99,7 @@ class EditorTextSelectionGestureDetectorBuilder {
}
onDoubleTapDown(TapDownDetails details) {
if (delegate.getSelectionEnabled()!) {
if (delegate.getSelectionEnabled()) {
getRenderEditor()!.selectWord(SelectionChangedCause.tap);
if (shouldShowSelectionToolbar) {
getEditor()!.showToolbar();

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

@ -107,7 +107,7 @@ class EditableTextBlock extends StatelessWidget {
int count = block.children.length;
var children = <Widget>[];
int index = 0;
for (Line line in block.children as Iterable<Line>) {
for (Line line in Iterable.castFrom<dynamic, Line>(block.children)) {
index++;
EditableTextLine editableTextLine = EditableTextLine(
line,

@ -101,7 +101,7 @@ class TextLine extends StatelessWidget {
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();
TextStyle? toMerge;
@ -187,8 +187,8 @@ class TextLine extends StatelessWidget {
decorations.add(b.decoration);
}
return a.merge(b).apply(
decoration:
TextDecoration.combine(decorations as List<TextDecoration>));
decoration: TextDecoration.combine(
List.castFrom<dynamic, TextDecoration>(decorations)));
}
}
@ -824,8 +824,8 @@ class _TextLineElement extends RenderObjectElement {
}
@override
insertRenderObjectChild(RenderObject child, TextLineSlot? slot) {
assert(child is RenderBox);
insertRenderObjectChild(RenderBox child, TextLineSlot? slot) {
// assert(child is RenderBox);
_updateRenderObject(child, 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) {
case TextLineSlot.LEADING:
renderObject.setLeading(child as RenderBox?);
renderObject.setLeading(child);
break;
case TextLineSlot.BODY:
renderObject.setBody((child as RenderBox?) as RenderContentProxyBox?);
renderObject.setBody((child) as RenderContentProxyBox?);
break;
default:
throw UnimplementedError();

Loading…
Cancel
Save