Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
86 changes: 46 additions & 40 deletions super_editor/lib/src/super_textfield/android/android_textfield.dart
Original file line number Diff line number Diff line change
Expand Up @@ -575,48 +575,54 @@ class SuperAndroidTextFieldState extends State<SuperAndroidTextField>

@override
Widget build(BuildContext context) {
return TapRegion(
groupId: widget.tapRegionGroupId,
child: Focus(
key: _textFieldKey,
focusNode: _focusNode,
onKeyEvent: _onKeyEventPressed,
child: CompositedTransformTarget(
link: _textFieldLayerLink,
child: AndroidTextFieldTouchInteractor(
focusNode: _focusNode,
tapHandlers: widget.tapHandlers,
textKey: _textContentKey,
getGlobalCaretRect: _getGlobalCaretRect,
textFieldLayerLink: _textFieldLayerLink,
textController: _textEditingController,
editingOverlayController: _editingOverlayController,
textScrollController: _textScrollController,
isMultiline: _isMultiline,
handleColor: widget.handlesColor,
showDebugPaint: widget.showDebugPaint,
child: TextScrollView(
key: _scrollKey,
textScrollController: _textScrollController,
return Semantics(
textField: true,
focusable: true,
focused: _focusNode.hasFocus,
value: _textEditingController.text.toPlainText(),
child: TapRegion(
groupId: widget.tapRegionGroupId,
child: Focus(
key: _textFieldKey,
focusNode: _focusNode,
onKeyEvent: _onKeyEventPressed,
child: CompositedTransformTarget(
link: _textFieldLayerLink,
child: AndroidTextFieldTouchInteractor(
focusNode: _focusNode,
tapHandlers: widget.tapHandlers,
textKey: _textContentKey,
textEditingController: _textEditingController,
textAlign: _textAlign,
minLines: widget.minLines,
maxLines: widget.maxLines,
lineHeight: widget.lineHeight,
padding: EdgeInsets.only(top: widget.padding?.top ?? 0, bottom: widget.padding?.bottom ?? 0),
perLineAutoScrollDuration: const Duration(milliseconds: 100),
getGlobalCaretRect: _getGlobalCaretRect,
textFieldLayerLink: _textFieldLayerLink,
textController: _textEditingController,
editingOverlayController: _editingOverlayController,
textScrollController: _textScrollController,
isMultiline: _isMultiline,
handleColor: widget.handlesColor,
showDebugPaint: widget.showDebugPaint,
child: FillWidthIfConstrained(
child: Padding(
padding: EdgeInsets.only(left: widget.padding?.left ?? 0, right: widget.padding?.right ?? 0),
child: CompositedTransformTarget(
link: _textContentLayerLink,
child: ListenableBuilder(
listenable: _textEditingController,
builder: (context, _) {
return _buildSelectableText();
},
child: TextScrollView(
key: _scrollKey,
textScrollController: _textScrollController,
textKey: _textContentKey,
textEditingController: _textEditingController,
textAlign: _textAlign,
minLines: widget.minLines,
maxLines: widget.maxLines,
lineHeight: widget.lineHeight,
padding: EdgeInsets.only(top: widget.padding?.top ?? 0, bottom: widget.padding?.bottom ?? 0),
perLineAutoScrollDuration: const Duration(milliseconds: 100),
showDebugPaint: widget.showDebugPaint,
child: FillWidthIfConstrained(
child: Padding(
padding: EdgeInsets.only(left: widget.padding?.left ?? 0, right: widget.padding?.right ?? 0),
child: CompositedTransformTarget(
link: _textContentLayerLink,
child: ListenableBuilder(
listenable: _textEditingController,
builder: (context, _) {
return _buildSelectableText();
},
),
),
),
),
Expand Down
106 changes: 56 additions & 50 deletions super_editor/lib/src/super_textfield/desktop/desktop_textfield.dart
Original file line number Diff line number Diff line change
Expand Up @@ -429,58 +429,64 @@ class SuperDesktopTextFieldState extends State<SuperDesktopTextField> implements

final isMultiline = widget.minLines != 1 || widget.maxLines != 1;

return TapRegion(
groupId: widget.tapRegionGroupId,
child: _buildTextInputSystem(
isMultiline: isMultiline,
// As we handle the scrolling gestures ourselves,
// we use NeverScrollableScrollPhysics to prevent SingleChildScrollView
// from scrolling. This also prevents the user from interacting
// with the scrollbar.
// We use a modified version of Flutter's Scrollbar that allows
// configuring it with a different scroll physics.
//
// See https://github.com/superlistapp/super_editor/issues/1628 for more details.
child: ScrollbarWithCustomPhysics(
controller: _scrollController,
physics: ScrollConfiguration.of(context).getScrollPhysics(context),
child: SuperTextFieldGestureInteractor(
focusNode: _focusNode,
textController: _controller,
textKey: _textKey,
textScrollKey: _textScrollKey,
isMultiline: isMultiline,
onRightClick: widget.onRightClick,
tapHandlers: widget.tapHandlers,
child: MultiListenableBuilder(
listenables: {
_focusNode,
_controller,
},
builder: (context) {
return _buildDecoration(
child: SuperTextFieldScrollview(
key: _textScrollKey,
textKey: _textKey,
textController: _controller,
textAlign: _textAlign,
scrollController: _scrollController,
viewportHeight: _viewportHeight,
estimatedLineHeight: _getEstimatedLineHeight(),
isMultiline: isMultiline,
child: FillWidthIfConstrained(
child: Padding(
// WARNING: Padding within the text scroll view must be placed here, under
// FillWidthIfConstrained, rather than around it, because FillWidthIfConstrained makes
// decisions about sizing that expects its child to fill all available space in the
// ancestor Scrollable.
padding: widget.padding,
child: _buildSelectableText(),
return Semantics(
textField: true,
focusable: true,
focused: _focusNode.hasFocus,
value: _controller.text.toPlainText(),
child: TapRegion(
groupId: widget.tapRegionGroupId,
child: _buildTextInputSystem(
isMultiline: isMultiline,
// As we handle the scrolling gestures ourselves,
// we use NeverScrollableScrollPhysics to prevent SingleChildScrollView
// from scrolling. This also prevents the user from interacting
// with the scrollbar.
// We use a modified version of Flutter's Scrollbar that allows
// configuring it with a different scroll physics.
//
// See https://github.com/superlistapp/super_editor/issues/1628 for more details.
child: ScrollbarWithCustomPhysics(
controller: _scrollController,
physics: ScrollConfiguration.of(context).getScrollPhysics(context),
child: SuperTextFieldGestureInteractor(
focusNode: _focusNode,
textController: _controller,
textKey: _textKey,
textScrollKey: _textScrollKey,
isMultiline: isMultiline,
onRightClick: widget.onRightClick,
tapHandlers: widget.tapHandlers,
child: MultiListenableBuilder(
listenables: {
_focusNode,
_controller,
},
builder: (context) {
return _buildDecoration(
child: SuperTextFieldScrollview(
key: _textScrollKey,
textKey: _textKey,
textController: _controller,
textAlign: _textAlign,
scrollController: _scrollController,
viewportHeight: _viewportHeight,
estimatedLineHeight: _getEstimatedLineHeight(),
isMultiline: isMultiline,
child: FillWidthIfConstrained(
child: Padding(
// WARNING: Padding within the text scroll view must be placed here, under
// FillWidthIfConstrained, rather than around it, because FillWidthIfConstrained makes
// decisions about sizing that expects its child to fill all available space in the
// ancestor Scrollable.
padding: widget.padding,
child: _buildSelectableText(),
),
),
),
),
);
},
);
},
),
),
),
),
Expand Down
84 changes: 45 additions & 39 deletions super_editor/lib/src/super_textfield/ios/ios_textfield.dart
Original file line number Diff line number Diff line change
Expand Up @@ -575,47 +575,53 @@ class SuperIOSTextFieldState extends State<SuperIOSTextField>

@override
Widget build(BuildContext context) {
return TapRegion(
groupId: widget.tapRegionGroupId,
child: Focus(
key: _textFieldKey,
focusNode: _focusNode,
child: CompositedTransformTarget(
link: _textFieldLayerLink,
child: IOSTextFieldTouchInteractor(
focusNode: _focusNode,
tapHandlers: widget.tapHandlers,
selectableTextKey: _textContentKey,
getGlobalCaretRect: _getGlobalCaretRect,
textFieldLayerLink: _textFieldLayerLink,
textController: _textEditingController,
editingOverlayController: _editingOverlayController,
textScrollController: _textScrollController,
isMultiline: _isMultiline,
handleColor: widget.handlesColor,
showDebugPaint: widget.showDebugPaint,
child: TextScrollView(
key: _scrollKey,
return Semantics(
textField: true,
focusable: true,
focused: _focusNode.hasFocus,
value: _textEditingController.text.toPlainText(),
child: TapRegion(
groupId: widget.tapRegionGroupId,
child: Focus(
key: _textFieldKey,
focusNode: _focusNode,
child: CompositedTransformTarget(
link: _textFieldLayerLink,
child: IOSTextFieldTouchInteractor(
focusNode: _focusNode,
tapHandlers: widget.tapHandlers,
selectableTextKey: _textContentKey,
getGlobalCaretRect: _getGlobalCaretRect,
textFieldLayerLink: _textFieldLayerLink,
textController: _textEditingController,
editingOverlayController: _editingOverlayController,
textScrollController: _textScrollController,
textKey: _textContentKey,
textEditingController: _textEditingController,
textAlign: _textAlign,
minLines: widget.minLines,
maxLines: widget.maxLines,
lineHeight: widget.lineHeight,
padding: EdgeInsets.only(top: widget.padding?.top ?? 0, bottom: widget.padding?.bottom ?? 0),
perLineAutoScrollDuration: const Duration(milliseconds: 100),
isMultiline: _isMultiline,
handleColor: widget.handlesColor,
showDebugPaint: widget.showDebugPaint,
child: FillWidthIfConstrained(
child: Padding(
padding: EdgeInsets.only(left: widget.padding?.left ?? 0, right: widget.padding?.right ?? 0),
child: CompositedTransformTarget(
link: _textContentLayerLink,
child: ListenableBuilder(
listenable: _textEditingController,
builder: (context, _) {
return _buildSelectableText();
},
child: TextScrollView(
key: _scrollKey,
textScrollController: _textScrollController,
textKey: _textContentKey,
textEditingController: _textEditingController,
textAlign: _textAlign,
minLines: widget.minLines,
maxLines: widget.maxLines,
lineHeight: widget.lineHeight,
padding: EdgeInsets.only(top: widget.padding?.top ?? 0, bottom: widget.padding?.bottom ?? 0),
perLineAutoScrollDuration: const Duration(milliseconds: 100),
showDebugPaint: widget.showDebugPaint,
child: FillWidthIfConstrained(
child: Padding(
padding: EdgeInsets.only(left: widget.padding?.left ?? 0, right: widget.padding?.right ?? 0),
child: CompositedTransformTarget(
link: _textContentLayerLink,
child: ListenableBuilder(
listenable: _textEditingController,
builder: (context, _) {
return _buildSelectableText();
},
),
),
),
),
Expand Down