Fix cannot scroll editor when disable code view in composer

This commit is contained in:
dab246
2025-09-19 13:41:55 +07:00
committed by Dat H. Pham
parent 69c9476379
commit 64f4096340
6 changed files with 400 additions and 381 deletions
@@ -28,28 +28,25 @@ class AttachmentDropZoneWidget extends StatelessWidget {
Widget build(BuildContext context) {
return DragTarget<Attachment>(
builder: (context, _, __) {
return SizedBox(
width: width,
height: height,
child: Padding(
padding: DropZoneWidgetStyle.margin,
child: DottedBorder(
borderType: BorderType.RRect,
radius: const Radius.circular(DropZoneWidgetStyle.radius),
color: DropZoneWidgetStyle.borderColor,
strokeWidth: DropZoneWidgetStyle.borderWidth,
dashPattern: DropZoneWidgetStyle.dashSize,
child: Container(
clipBehavior: Clip.antiAlias,
decoration: ShapeDecoration(
color: DropZoneWidgetStyle.backgroundColor,
shape: const RoundedRectangleBorder(
borderRadius: BorderRadius.all(Radius.circular(DropZoneWidgetStyle.radius)),
),
final childWidget = Padding(
padding: DropZoneWidgetStyle.margin,
child: DottedBorder(
borderType: BorderType.RRect,
radius: const Radius.circular(DropZoneWidgetStyle.radius),
color: DropZoneWidgetStyle.borderColor,
strokeWidth: DropZoneWidgetStyle.borderWidth,
dashPattern: DropZoneWidgetStyle.dashSize,
child: Container(
clipBehavior: Clip.antiAlias,
decoration: ShapeDecoration(
color: DropZoneWidgetStyle.backgroundColor,
shape: const RoundedRectangleBorder(
borderRadius: BorderRadius.all(Radius.circular(DropZoneWidgetStyle.radius)),
),
padding: DropZoneWidgetStyle.padding,
alignment: AlignmentDirectional.center,
child: Column(
),
padding: DropZoneWidgetStyle.padding,
alignment: AlignmentDirectional.center,
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
SvgPicture.asset(imagePaths.icDropZoneIcon),
@@ -59,11 +56,20 @@ class AttachmentDropZoneWidget extends StatelessWidget {
style: DropZoneWidgetStyle.labelTextStyle,
)
]
),
),
),
),
);
if (width == null && height == null) {
return SizedBox.expand(child: childWidget);
}
return SizedBox(
width: width,
height: height,
child: childWidget,
);
},
onAcceptWithDetails: (details) => onAttachmentDropZoneListener?.call(details.data),
);
@@ -28,44 +28,52 @@ class LocalFileDropZoneWidget extends StatelessWidget {
@override
Widget build(BuildContext context) {
return DropTarget(
onDragDone: onLocalFileDropZoneListener,
child: SizedBox(
width: width,
height: height,
child: Padding(
padding: margin,
child: DottedBorder(
borderType: BorderType.RRect,
radius: const Radius.circular(DropZoneWidgetStyle.radius),
color: DropZoneWidgetStyle.borderColor,
strokeWidth: DropZoneWidgetStyle.borderWidth,
dashPattern: DropZoneWidgetStyle.dashSize,
child: Container(
clipBehavior: Clip.antiAlias,
decoration: ShapeDecoration(
color: DropZoneWidgetStyle.backgroundColor,
shape: const RoundedRectangleBorder(
borderRadius: BorderRadius.all(Radius.circular(DropZoneWidgetStyle.radius)),
),
),
padding: DropZoneWidgetStyle.padding,
alignment: AlignmentDirectional.center,
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
Flexible(child: SvgPicture.asset(imagePaths.icDropZoneIcon)),
const SizedBox(height: DropZoneWidgetStyle.space),
Text(
AppLocalizations.of(context).dropFileHereToAttachThem,
style: DropZoneWidgetStyle.labelTextStyle,
)
]
Widget childWidget = Padding(
padding: margin,
child: DottedBorder(
borderType: BorderType.RRect,
radius: const Radius.circular(DropZoneWidgetStyle.radius),
color: DropZoneWidgetStyle.borderColor,
strokeWidth: DropZoneWidgetStyle.borderWidth,
dashPattern: DropZoneWidgetStyle.dashSize,
child: Container(
clipBehavior: Clip.antiAlias,
decoration: ShapeDecoration(
color: DropZoneWidgetStyle.backgroundColor,
shape: const RoundedRectangleBorder(
borderRadius: BorderRadius.all(
Radius.circular(DropZoneWidgetStyle.radius),
),
),
),
padding: DropZoneWidgetStyle.padding,
alignment: AlignmentDirectional.center,
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
Flexible(child: SvgPicture.asset(imagePaths.icDropZoneIcon)),
const SizedBox(height: DropZoneWidgetStyle.space),
Text(
AppLocalizations
.of(context)
.dropFileHereToAttachThem,
style: DropZoneWidgetStyle.labelTextStyle,
),
],
),
),
),
);
if (width == null && height == null) {
childWidget = SizedBox.expand(child: childWidget);
} else {
childWidget = SizedBox(width: width, height: height, child: childWidget);
}
return DropTarget(
onDragDone: onLocalFileDropZoneListener,
child: childWidget,
);
}
}
@@ -121,6 +121,7 @@ class _WebEditorState extends State<WebEditorWidget> {
@override
Widget build(BuildContext context) {
final maxHeight = widget.height ?? _defaultHtmlEditorHeight;
return HtmlEditor(
controller: _editorController,
htmlEditorOptions: HtmlEditorOptions(
@@ -153,16 +154,18 @@ class _WebEditorState extends State<WebEditorWidget> {
WebScript(
name: HtmlUtils.unregisterDropListener.name,
script: HtmlUtils.unregisterDropListener.script,
)
),
WebScript(
name: HtmlUtils.recalculateEditorHeight(maxHeight: maxHeight).name,
script: HtmlUtils.recalculateEditorHeight(maxHeight: maxHeight).script,
),
])
),
htmlToolbarOptions: const HtmlToolbarOptions(
toolbarType: ToolbarType.hide,
defaultToolbarButtons: [],
),
otherOptions: OtherOptions(
height: widget.height ?? _defaultHtmlEditorHeight,
),
otherOptions: OtherOptions(height: maxHeight),
callbacks: Callbacks(
onBeforeCommand: widget.onChangeContent,
onChangeContent: widget.onChangeContent,