Skip to content

Commit

Permalink
Fix text selection handles when scroll mobile (#2176)
Browse files Browse the repository at this point in the history
* Value setting Stateful toolbar buttons derive from base class

* Removed deprecated functions

* Move clipboard actions to QuillController

* Add: Clipboard toolbar buttons

* Translation Justify

* Translation alignJustify

* Fix: Translation en-US

* Fix text selection handles did not track when drag scroll on mobile

---------

Co-authored-by: Douglas Ward <[email protected]>
  • Loading branch information
AtlasAutocode and Douglas Ward authored Sep 2, 2024
1 parent 914d4bd commit 004b42d
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 33 deletions.
3 changes: 2 additions & 1 deletion doc/code_introduction.md
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,8 @@ RawEditorStateTextInputClientMixin
- CompositedTransformTarget - Hooks the custom widget into the mechanics of layout rendering and calculation of dimensions (Flutter).
- Why CompositedTransformTarget? - Because Quill uses a custom renderer to render the document (for performance reasons)

- If not expanded (meaning scrollable) it wraps the _editor with BaselineProxy QuillSingleChildScrollView and CompositedTransformTarget
- If not expanded (meaning scrollable) it wraps the _editor with BaselineProxy, SingleChildScrollView and CompositedTransformTarget.
[CompositedTransformTarget] is needed to allow selection handle overlays to track the selected text.
Since [SingleChildScrollView] does not implement `computeDistanceToActualBaseline` it prevents the editor from providing its baseline metrics.
To address this issue we wrap the scroll view with [BaselineProxy] which mimics the editor's baseline.
This implies that the first line has no styles applied to it.
Expand Down
68 changes: 36 additions & 32 deletions lib/src/editor/raw_editor/raw_editor_state.dart
Original file line number Diff line number Diff line change
Expand Up @@ -435,39 +435,44 @@ class QuillRawEditorState extends EditorState
final baselinePadding =
EdgeInsets.only(top: _styles!.paragraph!.verticalSpacing.top);
child = BaselineProxy(
textStyle: _styles!.paragraph!.style,
padding: baselinePadding,
child: _scribbleFocusable(
SingleChildScrollView(
controller: _scrollController,
physics: widget.configurations.scrollPhysics,
child: MouseRegion(
cursor: widget.configurations.readOnly
? widget.configurations.readOnlyMouseCursor
: SystemMouseCursors.text,
child: QuillRawEditorMultiChildRenderObject(
key: _editorKey,
document: doc,
selection: controller.selection,
hasFocus: _hasFocus,
scrollable: widget.configurations.scrollable,
textDirection: _textDirection,
startHandleLayerLink: _startHandleLayerLink,
endHandleLayerLink: _endHandleLayerLink,
onSelectionChanged: _handleSelectionChanged,
onSelectionCompleted: _handleSelectionCompleted,
scrollBottomInset: widget.configurations.scrollBottomInset,
padding: widget.configurations.padding,
maxContentWidth: widget.configurations.maxContentWidth,
cursorController: _cursorCont,
floatingCursorDisabled:
widget.configurations.floatingCursorDisabled,
children: _buildChildren(doc, context),
textStyle: _styles!.paragraph!.style,
padding: baselinePadding,
child: _scribbleFocusable(
SingleChildScrollView(
controller: _scrollController,
physics: widget.configurations.scrollPhysics,
child: CompositedTransformTarget(
link: _toolbarLayerLink,
child: MouseRegion(
cursor: widget.configurations.readOnly
? widget.configurations.readOnlyMouseCursor
: SystemMouseCursors.text,
child: QuillRawEditorMultiChildRenderObject(
key: _editorKey,
offset: _scrollController.hasClients
? _scrollController.position
: null,
document: doc,
selection: controller.selection,
hasFocus: _hasFocus,
scrollable: widget.configurations.scrollable,
textDirection: _textDirection,
startHandleLayerLink: _startHandleLayerLink,
endHandleLayerLink: _endHandleLayerLink,
onSelectionChanged: _handleSelectionChanged,
onSelectionCompleted: _handleSelectionCompleted,
scrollBottomInset: widget.configurations.scrollBottomInset,
padding: widget.configurations.padding,
maxContentWidth: widget.configurations.maxContentWidth,
cursorController: _cursorCont,
floatingCursorDisabled:
widget.configurations.floatingCursorDisabled,
children: _buildChildren(doc, context),
),
),
),
),
),
),
);
));
} else {
child = _scribbleFocusable(
CompositedTransformTarget(
Expand Down Expand Up @@ -501,7 +506,6 @@ class QuillRawEditorState extends EditorState
),
);
}

final constraints = widget.configurations.expands
? const BoxConstraints.expand()
: BoxConstraints(
Expand Down

0 comments on commit 004b42d

Please sign in to comment.