TF-2118 Set width/height for drop zone view

(cherry picked from commit f4d844b636750f413f0b65fab78d5f00e6a8d424)
This commit is contained in:
dab246
2023-09-28 16:05:39 +07:00
committed by Dat H. Pham
parent 8b20e9e1d4
commit 89e8a4aaa4
3 changed files with 223 additions and 171 deletions
@@ -24,6 +24,8 @@ class WebEditorWidget extends StatefulWidget {
final OnEditorSettingsChange? onEditorSettings;
final OnImageUploadSuccessAction? onImageUploadSuccessAction;
final OnImageUploadFailureAction? onImageUploadFailureAction;
final double? width;
final double? height;
const WebEditorWidget({
super.key,
@@ -38,6 +40,8 @@ class WebEditorWidget extends StatefulWidget {
this.onEditorSettings,
this.onImageUploadSuccessAction,
this.onImageUploadFailureAction,
this.width,
this.height,
});
@override
@@ -46,12 +50,24 @@ class WebEditorWidget extends StatefulWidget {
class _WebEditorState extends State<WebEditorWidget> {
static const double _offsetHeight = 50;
static const double _offsetWidth = 90;
late HtmlEditorController _editorController;
double? dropZoneWidth;
double? dropZoneHeight;
@override
void initState() {
_editorController = widget.editorController;
super.initState();
_editorController = widget.editorController;
if (widget.height != null) {
dropZoneHeight = widget.height! - _offsetHeight;
}
if (widget.width != null) {
dropZoneWidth = widget.width! - _offsetWidth;
}
log('_WebEditorState::initState:dropZoneWidth: $dropZoneWidth | dropZoneHeight: $dropZoneHeight');
}
@override
@@ -77,9 +93,13 @@ class _WebEditorState extends State<WebEditorWidget> {
),
htmlToolbarOptions: const HtmlToolbarOptions(
toolbarType: ToolbarType.hide,
defaultToolbarButtons: []
defaultToolbarButtons: [],
),
otherOptions: OtherOptions(
height: 550,
dropZoneWidth: dropZoneWidth,
dropZoneHeight: dropZoneHeight,
),
otherOptions: const OtherOptions(height: 550),
callbacks: Callbacks(
onBeforeCommand: widget.onChangeContent,
onChangeContent: widget.onChangeContent,