Fix editor and attachment in composer on web
This commit is contained in:
@@ -232,6 +232,12 @@ class ComposerController extends BaseController {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void setFullScreenEditor() {
|
||||||
|
Future.delayed(const Duration(milliseconds: 1000), () {
|
||||||
|
htmlControllerBrowser.setFullScreen();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
Tuple2<String, String>? _getHeaderEmailQuoted(String locale, ComposerArguments arguments) {
|
Tuple2<String, String>? _getHeaderEmailQuoted(String locale, ComposerArguments arguments) {
|
||||||
if (arguments.presentationEmail != null) {
|
if (arguments.presentationEmail != null) {
|
||||||
final sentDate = arguments.presentationEmail?.sentAt;
|
final sentDate = arguments.presentationEmail?.sentAt;
|
||||||
@@ -263,12 +269,6 @@ class ComposerController extends BaseController {
|
|||||||
listBccEmailAddress = recipients.value3.toSet().filterEmailAddress(userEmailAddress);
|
listBccEmailAddress = recipients.value3.toSet().filterEmailAddress(userEmailAddress);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (listCcEmailAddress.isNotEmpty || listBccEmailAddress.isNotEmpty) {
|
|
||||||
expandMode.value = ExpandMode.EXPAND;
|
|
||||||
} else {
|
|
||||||
expandMode.value = ExpandMode.COLLAPSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (listToEmailAddress.isNotEmpty || listCcEmailAddress.isNotEmpty || listBccEmailAddress.isNotEmpty) {
|
if (listToEmailAddress.isNotEmpty || listCcEmailAddress.isNotEmpty || listBccEmailAddress.isNotEmpty) {
|
||||||
isInitialRecipient.value = true;
|
isInitialRecipient.value = true;
|
||||||
}
|
}
|
||||||
@@ -319,7 +319,7 @@ class ComposerController extends BaseController {
|
|||||||
.toList()
|
.toList()
|
||||||
.join('<br>') ?? '';
|
.join('<br>') ?? '';
|
||||||
|
|
||||||
final emailQuotedHtml = '<br><br><br>$headerEmailQuotedAsHtml${trustAsHtml.addBlockQuoteTag()}<br>';
|
final emailQuotedHtml = '<br><br>$headerEmailQuotedAsHtml${trustAsHtml.addBlockQuoteTag()}<br>';
|
||||||
|
|
||||||
return emailQuotedHtml;
|
return emailQuotedHtml;
|
||||||
}
|
}
|
||||||
@@ -369,7 +369,6 @@ class ComposerController extends BaseController {
|
|||||||
} else {
|
} else {
|
||||||
userAgent = FkUserAgent.userAgent ?? '';
|
userAgent = FkUserAgent.userAgent ?? '';
|
||||||
}
|
}
|
||||||
log('ComposerController - userAgentPlatform(): userAgent: $userAgent');
|
|
||||||
} on Exception {
|
} on Exception {
|
||||||
userAgent = '';
|
userAgent = '';
|
||||||
}
|
}
|
||||||
@@ -666,8 +665,7 @@ class ComposerController extends BaseController {
|
|||||||
|
|
||||||
void _updateTextForEditor() async {
|
void _updateTextForEditor() async {
|
||||||
final textCurrent = await htmlControllerBrowser.getText();
|
final textCurrent = await htmlControllerBrowser.getText();
|
||||||
log('_updateTextForEditor() | textCurrent: $textCurrent');
|
htmlControllerBrowser.insertText(textCurrent);
|
||||||
htmlControllerBrowser.insertHtml(textCurrent);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void deleteComposer() {
|
void deleteComposer() {
|
||||||
|
|||||||
@@ -55,8 +55,8 @@ class ComposerView extends GetWidget<ComposerController> {
|
|||||||
color: Colors.transparent,
|
color: Colors.transparent,
|
||||||
child: Container(
|
child: Container(
|
||||||
decoration: BoxDecoration(color: Colors.white, borderRadius: BorderRadius.all(Radius.circular(20))),
|
decoration: BoxDecoration(color: Colors.white, borderRadius: BorderRadius.all(Radius.circular(20))),
|
||||||
width: responsiveUtils.getSizeWidthScreen(context) * 0.5,
|
width: responsiveUtils.getSizeWidthScreen(context) * 0.55,
|
||||||
height: responsiveUtils.getSizeHeightScreen(context) * 0.65,
|
height: responsiveUtils.getSizeHeightScreen(context) * 0.75,
|
||||||
child: PointerInterceptor(child: Column(
|
child: PointerInterceptor(child: Column(
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
children: [
|
children: [
|
||||||
@@ -119,8 +119,8 @@ class ComposerView extends GetWidget<ComposerController> {
|
|||||||
shape: RoundedRectangleBorder(borderRadius: BorderRadius.all(Radius.circular(20))),
|
shape: RoundedRectangleBorder(borderRadius: BorderRadius.all(Radius.circular(20))),
|
||||||
child: Container(
|
child: Container(
|
||||||
decoration: BoxDecoration(color: Colors.white, borderRadius: BorderRadius.all(Radius.circular(20))),
|
decoration: BoxDecoration(color: Colors.white, borderRadius: BorderRadius.all(Radius.circular(20))),
|
||||||
width: responsiveUtils.getSizeWidthScreen(context) * 0.8,
|
width: responsiveUtils.getSizeWidthScreen(context) * 0.85,
|
||||||
height: responsiveUtils.getSizeHeightScreen(context) * 0.85,
|
height: responsiveUtils.getSizeHeightScreen(context) * 0.9,
|
||||||
child: ClipRRect(
|
child: ClipRRect(
|
||||||
borderRadius: BorderRadius.all(Radius.circular(20)),
|
borderRadius: BorderRadius.all(Radius.circular(20)),
|
||||||
child: PointerInterceptor(child: Column(
|
child: PointerInterceptor(child: Column(
|
||||||
@@ -391,52 +391,55 @@ class ComposerView extends GetWidget<ComposerController> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Widget _buildEditorAndAttachments(BuildContext context) {
|
Widget _buildEditorAndAttachments(BuildContext context) {
|
||||||
return SingleChildScrollView(
|
return Column(
|
||||||
physics: ClampingScrollPhysics(),
|
children: [
|
||||||
child: Column(
|
Obx(() => controller.attachments.isNotEmpty
|
||||||
children: [
|
? Padding(
|
||||||
Obx(() => controller.attachments.isNotEmpty
|
padding: EdgeInsets.symmetric(vertical: 4, horizontal: 10),
|
||||||
? Padding(
|
child: _buildAttachmentsTitle(context, controller.attachments, controller.expandModeAttachments.value))
|
||||||
padding: EdgeInsets.symmetric(vertical: 4, horizontal: 10),
|
: SizedBox.shrink()),
|
||||||
child: _buildAttachmentsTitle(context, controller.attachments, controller.expandModeAttachments.value))
|
Obx(() => controller.attachments.isEmpty
|
||||||
: SizedBox.shrink()),
|
? _buildAttachmentsLoadingView()
|
||||||
Obx(() => controller.attachments.isEmpty
|
: SizedBox.shrink()),
|
||||||
? _buildAttachmentsLoadingView()
|
Obx(() => controller.attachments.isNotEmpty && controller.expandModeAttachments.value == ExpandMode.COLLAPSE
|
||||||
: SizedBox.shrink()),
|
? Padding(padding: EdgeInsets.symmetric(horizontal: 10), child: Divider(color: AppColor.colorDividerComposer, height: 1))
|
||||||
Obx(() => controller.attachments.isNotEmpty
|
: SizedBox.shrink()),
|
||||||
? Padding(
|
Obx(() => controller.attachments.isNotEmpty
|
||||||
padding: EdgeInsets.only(bottom: 8, left: 10, right: 10),
|
? Padding(
|
||||||
child: _buildAttachmentsList(context, controller.attachments, controller.expandModeAttachments.value))
|
padding: EdgeInsets.only(bottom: 8, left: 10, right: 10),
|
||||||
: SizedBox.shrink()),
|
child: _buildAttachmentsList(context, controller.attachments, controller.expandModeAttachments.value))
|
||||||
Padding(
|
: SizedBox.shrink()),
|
||||||
padding: EdgeInsets.symmetric(horizontal: 10),
|
Expanded(child: Padding(padding: EdgeInsets.symmetric(horizontal: 10), child: _buildEditor(context))),
|
||||||
child: _buildComposerEditor(context)),
|
]
|
||||||
]
|
|
||||||
)
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget _buildComposerEditor(BuildContext context) {
|
Widget _buildEditor(BuildContext context) {
|
||||||
return Obx(() => HtmlEditorBrowser.HtmlEditor(
|
return HtmlEditorBrowser.HtmlEditor(
|
||||||
key: Key('composer_editor_web'),
|
key: Key('composer_editor_web'),
|
||||||
controller: controller.htmlControllerBrowser,
|
controller: controller.htmlControllerBrowser,
|
||||||
htmlEditorOptions: HtmlEditorBrowser.HtmlEditorOptions(
|
htmlEditorOptions: HtmlEditorBrowser.HtmlEditorOptions(
|
||||||
hint: '',
|
hint: '<p></p>',
|
||||||
initialText: controller.initTextEditorComposer,
|
initialText: controller.initTextEditorComposer,
|
||||||
autoAdjustHeight: true,
|
|
||||||
darkMode: false,
|
darkMode: false,
|
||||||
disableScrollbarEditor: true,
|
|
||||||
),
|
),
|
||||||
htmlToolbarOptions: HtmlEditorBrowser.HtmlToolbarOptions(
|
htmlToolbarOptions: HtmlEditorBrowser.HtmlToolbarOptions(
|
||||||
toolbarPosition: HtmlEditorBrowser.ToolbarPosition.custom
|
toolbarPosition: HtmlEditorBrowser.ToolbarPosition.custom
|
||||||
),
|
),
|
||||||
otherOptions: HtmlEditorBrowser.OtherOptions(height: 550),
|
otherOptions: HtmlEditorBrowser.OtherOptions(height: 550),
|
||||||
callbacks: HtmlEditorBrowser.Callbacks(onBeforeCommand: (String? currentHtml) {
|
callbacks: HtmlEditorBrowser.Callbacks(
|
||||||
controller.setTextEditor(currentHtml);
|
onBeforeCommand: (String? currentHtml) {
|
||||||
}, onChangeContent: (String? changed) {
|
log('ComposerView::_buildComposerEditor(): onBeforeCommand');
|
||||||
controller.setTextEditor(changed);
|
controller.setTextEditor(currentHtml);
|
||||||
}),
|
}, onChangeContent: (String? changed) {
|
||||||
));
|
log('ComposerView::_buildComposerEditor(): onChangeContent');
|
||||||
|
controller.setTextEditor(changed);
|
||||||
|
}, onInit: () {
|
||||||
|
log('ComposerView::_buildComposerEditor(): onInit');
|
||||||
|
controller.setFullScreenEditor();
|
||||||
|
}
|
||||||
|
),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget _buildAttachmentsLoadingView({EdgeInsets? padding, double? size}) {
|
Widget _buildAttachmentsLoadingView({EdgeInsets? padding, double? size}) {
|
||||||
@@ -477,24 +480,8 @@ class ComposerView extends GetWidget<ComposerController> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Widget _buildAttachmentsList(BuildContext context, List<Attachment> attachments, ExpandMode expandMode) {
|
Widget _buildAttachmentsList(BuildContext context, List<Attachment> attachments, ExpandMode expandMode) {
|
||||||
if (expandMode == ExpandMode.EXPAND) {
|
if (expandMode == ExpandMode.COLLAPSE) {
|
||||||
return LayoutBuilder(builder: (context, constraints) {
|
return SizedBox.shrink();
|
||||||
return GridView.builder(
|
|
||||||
key: Key('list_attachment_full'),
|
|
||||||
primary: false,
|
|
||||||
shrinkWrap: true,
|
|
||||||
itemCount: attachments.length,
|
|
||||||
gridDelegate: SliverGridDelegateFixedHeight(
|
|
||||||
height: 60,
|
|
||||||
crossAxisCount: _getMaxItemRowListAttachment(context, constraints),
|
|
||||||
crossAxisSpacing: 8.0,
|
|
||||||
mainAxisSpacing: 8.0),
|
|
||||||
itemBuilder: (context, index) =>
|
|
||||||
(AttachmentFileComposerBuilder(context, imagePaths, attachments[index])
|
|
||||||
..addOnDeleteAttachmentAction((attachment) => controller.removeAttachmentAction(attachment)))
|
|
||||||
.build()
|
|
||||||
);
|
|
||||||
});
|
|
||||||
} else {
|
} else {
|
||||||
return LayoutBuilder(builder: (context, constraints) {
|
return LayoutBuilder(builder: (context, constraints) {
|
||||||
return Align(
|
return Align(
|
||||||
|
|||||||
+1
-1
@@ -128,7 +128,7 @@ dependencies:
|
|||||||
html_editor_enhanced:
|
html_editor_enhanced:
|
||||||
git:
|
git:
|
||||||
url: https://github.com/dab246/html-editor-enhanced.git
|
url: https://github.com/dab246/html-editor-enhanced.git
|
||||||
ref: html_editor_for_web
|
ref: improvements
|
||||||
|
|
||||||
# fk_user_agent
|
# fk_user_agent
|
||||||
fk_user_agent: 2.1.0
|
fk_user_agent: 2.1.0
|
||||||
|
|||||||
Reference in New Issue
Block a user