Super editor

This commit is contained in:
Hillel Coren 2022-03-23 11:33:04 +02:00
parent 8414ae8620
commit bf0710d2f6
7 changed files with 74 additions and 17 deletions

View File

@ -100,6 +100,7 @@ abstract class CompanyEntity extends Object
passwordTimeout: 30 * 60 * 1000, passwordTimeout: 30 * 60 * 1000,
oauthPasswordRequired: false, oauthPasswordRequired: false,
markdownEnabled: true, markdownEnabled: true,
markdownEmailEnabled: true,
useCommaAsDecimalPlace: false, useCommaAsDecimalPlace: false,
reportIncludeDrafts: false, reportIncludeDrafts: false,
groups: BuiltList<GroupEntity>(), groups: BuiltList<GroupEntity>(),
@ -243,6 +244,9 @@ abstract class CompanyEntity extends Object
@BuiltValueField(wireName: 'markdown_enabled') @BuiltValueField(wireName: 'markdown_enabled')
bool get markdownEnabled; bool get markdownEnabled;
@BuiltValueField(wireName: 'markdown_email_enabled')
bool get markdownEmailEnabled;
@BuiltValueField(wireName: 'use_comma_as_decimal_place') @BuiltValueField(wireName: 'use_comma_as_decimal_place')
bool get useCommaAsDecimalPlace; bool get useCommaAsDecimalPlace;
@ -590,6 +594,7 @@ abstract class CompanyEntity extends Object
..invoiceTaskDatelog = true ..invoiceTaskDatelog = true
..showTaskEndDate = false ..showTaskEndDate = false
..markdownEnabled = true ..markdownEnabled = true
..markdownEmailEnabled = true
..useCommaAsDecimalPlace = false ..useCommaAsDecimalPlace = false
..reportIncludeDrafts = false ..reportIncludeDrafts = false
..convertRateToClient = true ..convertRateToClient = true

View File

@ -132,6 +132,9 @@ class _$CompanyEntitySerializer implements StructuredSerializer<CompanyEntity> {
'markdown_enabled', 'markdown_enabled',
serializers.serialize(object.markdownEnabled, serializers.serialize(object.markdownEnabled,
specifiedType: const FullType(bool)), specifiedType: const FullType(bool)),
'markdown_email_enabled',
serializers.serialize(object.markdownEmailEnabled,
specifiedType: const FullType(bool)),
'use_comma_as_decimal_place', 'use_comma_as_decimal_place',
serializers.serialize(object.useCommaAsDecimalPlace, serializers.serialize(object.useCommaAsDecimalPlace,
specifiedType: const FullType(bool)), specifiedType: const FullType(bool)),
@ -493,6 +496,10 @@ class _$CompanyEntitySerializer implements StructuredSerializer<CompanyEntity> {
result.markdownEnabled = serializers.deserialize(value, result.markdownEnabled = serializers.deserialize(value,
specifiedType: const FullType(bool)) as bool; specifiedType: const FullType(bool)) as bool;
break; break;
case 'markdown_email_enabled':
result.markdownEmailEnabled = serializers.deserialize(value,
specifiedType: const FullType(bool)) as bool;
break;
case 'use_comma_as_decimal_place': case 'use_comma_as_decimal_place':
result.useCommaAsDecimalPlace = serializers.deserialize(value, result.useCommaAsDecimalPlace = serializers.deserialize(value,
specifiedType: const FullType(bool)) as bool; specifiedType: const FullType(bool)) as bool;
@ -1414,6 +1421,8 @@ class _$CompanyEntity extends CompanyEntity {
@override @override
final bool markdownEnabled; final bool markdownEnabled;
@override @override
final bool markdownEmailEnabled;
@override
final bool useCommaAsDecimalPlace; final bool useCommaAsDecimalPlace;
@override @override
final bool reportIncludeDrafts; final bool reportIncludeDrafts;
@ -1559,6 +1568,7 @@ class _$CompanyEntity extends CompanyEntity {
this.passwordTimeout, this.passwordTimeout,
this.oauthPasswordRequired, this.oauthPasswordRequired,
this.markdownEnabled, this.markdownEnabled,
this.markdownEmailEnabled,
this.useCommaAsDecimalPlace, this.useCommaAsDecimalPlace,
this.reportIncludeDrafts, this.reportIncludeDrafts,
this.groups, this.groups,
@ -1678,6 +1688,8 @@ class _$CompanyEntity extends CompanyEntity {
oauthPasswordRequired, 'CompanyEntity', 'oauthPasswordRequired'); oauthPasswordRequired, 'CompanyEntity', 'oauthPasswordRequired');
BuiltValueNullFieldError.checkNotNull( BuiltValueNullFieldError.checkNotNull(
markdownEnabled, 'CompanyEntity', 'markdownEnabled'); markdownEnabled, 'CompanyEntity', 'markdownEnabled');
BuiltValueNullFieldError.checkNotNull(
markdownEmailEnabled, 'CompanyEntity', 'markdownEmailEnabled');
BuiltValueNullFieldError.checkNotNull( BuiltValueNullFieldError.checkNotNull(
useCommaAsDecimalPlace, 'CompanyEntity', 'useCommaAsDecimalPlace'); useCommaAsDecimalPlace, 'CompanyEntity', 'useCommaAsDecimalPlace');
BuiltValueNullFieldError.checkNotNull( BuiltValueNullFieldError.checkNotNull(
@ -1812,6 +1824,7 @@ class _$CompanyEntity extends CompanyEntity {
passwordTimeout == other.passwordTimeout && passwordTimeout == other.passwordTimeout &&
oauthPasswordRequired == other.oauthPasswordRequired && oauthPasswordRequired == other.oauthPasswordRequired &&
markdownEnabled == other.markdownEnabled && markdownEnabled == other.markdownEnabled &&
markdownEmailEnabled == other.markdownEmailEnabled &&
useCommaAsDecimalPlace == other.useCommaAsDecimalPlace && useCommaAsDecimalPlace == other.useCommaAsDecimalPlace &&
reportIncludeDrafts == other.reportIncludeDrafts && reportIncludeDrafts == other.reportIncludeDrafts &&
groups == other.groups && groups == other.groups &&
@ -1889,7 +1902,7 @@ class _$CompanyEntity extends CompanyEntity {
$jc( $jc(
$jc( $jc(
$jc( $jc(
$jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc(0, enableCustomSurchargeTaxes1.hashCode), enableCustomSurchargeTaxes2.hashCode), enableCustomSurchargeTaxes3.hashCode), enableCustomSurchargeTaxes4.hashCode), sizeId.hashCode), industryId.hashCode), subdomain.hashCode), portalMode.hashCode), portalDomain.hashCode), updateProducts.hashCode), convertProductExchangeRate.hashCode), convertRateToClient.hashCode), fillProducts.hashCode), enableProductCost.hashCode), enableProductQuantity.hashCode), enableProductDiscount.hashCode), defaultTaskIsDateBased.hashCode), defaultQuantity.hashCode), showProductDetails.hashCode), clientCanRegister.hashCode), isLarge.hashCode), isDisabled.hashCode), enableShopApi.hashCode), companyKey.hashCode), firstDayOfWeek.hashCode), firstMonthOfYear.hashCode), numberOfInvoiceTaxRates.hashCode), numberOfItemTaxRates.hashCode), expenseInclusiveTaxes.hashCode), sessionTimeout.hashCode), passwordTimeout.hashCode), oauthPasswordRequired.hashCode), markdownEnabled.hashCode), useCommaAsDecimalPlace.hashCode), reportIncludeDrafts.hashCode), groups.hashCode), activities.hashCode), taxRates.hashCode), taskStatuses.hashCode), taskStatusMap.hashCode), companyGateways.hashCode), expenseCategories.hashCode), users.hashCode), clients.hashCode), products.hashCode), invoices.hashCode), recurringInvoices.hashCode), recurringExpenses.hashCode), payments.hashCode), quotes.hashCode), credits.hashCode), tasks.hashCode), projects.hashCode), expenses.hashCode), vendors.hashCode), designs.hashCode), documents.hashCode), tokens.hashCode), webhooks.hashCode), subscriptions.hashCode), paymentTerms.hashCode), systemLogs.hashCode), clientRegistrationFields.hashCode), customFields.hashCode), slackWebhookUrl.hashCode), googleAnalyticsKey.hashCode), markExpensesInvoiceable.hashCode), markExpensesPaid.hashCode), $jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc(0, enableCustomSurchargeTaxes1.hashCode), enableCustomSurchargeTaxes2.hashCode), enableCustomSurchargeTaxes3.hashCode), enableCustomSurchargeTaxes4.hashCode), sizeId.hashCode), industryId.hashCode), subdomain.hashCode), portalMode.hashCode), portalDomain.hashCode), updateProducts.hashCode), convertProductExchangeRate.hashCode), convertRateToClient.hashCode), fillProducts.hashCode), enableProductCost.hashCode), enableProductQuantity.hashCode), enableProductDiscount.hashCode), defaultTaskIsDateBased.hashCode), defaultQuantity.hashCode), showProductDetails.hashCode), clientCanRegister.hashCode), isLarge.hashCode), isDisabled.hashCode), enableShopApi.hashCode), companyKey.hashCode), firstDayOfWeek.hashCode), firstMonthOfYear.hashCode), numberOfInvoiceTaxRates.hashCode), numberOfItemTaxRates.hashCode), expenseInclusiveTaxes.hashCode), sessionTimeout.hashCode), passwordTimeout.hashCode), oauthPasswordRequired.hashCode), markdownEnabled.hashCode), markdownEmailEnabled.hashCode), useCommaAsDecimalPlace.hashCode), reportIncludeDrafts.hashCode), groups.hashCode), activities.hashCode), taxRates.hashCode), taskStatuses.hashCode), taskStatusMap.hashCode), companyGateways.hashCode), expenseCategories.hashCode), users.hashCode), clients.hashCode), products.hashCode), invoices.hashCode), recurringInvoices.hashCode), recurringExpenses.hashCode), payments.hashCode), quotes.hashCode), credits.hashCode), tasks.hashCode), projects.hashCode), expenses.hashCode), vendors.hashCode), designs.hashCode), documents.hashCode), tokens.hashCode), webhooks.hashCode), subscriptions.hashCode), paymentTerms.hashCode), systemLogs.hashCode), clientRegistrationFields.hashCode), customFields.hashCode), slackWebhookUrl.hashCode), googleAnalyticsKey.hashCode), markExpensesInvoiceable.hashCode), markExpensesPaid.hashCode),
invoiceExpenseDocuments.hashCode), invoiceExpenseDocuments.hashCode),
invoiceTaskDocuments.hashCode), invoiceTaskDocuments.hashCode),
invoiceTaskTimelog.hashCode), invoiceTaskTimelog.hashCode),
@ -1947,6 +1960,7 @@ class _$CompanyEntity extends CompanyEntity {
..add('passwordTimeout', passwordTimeout) ..add('passwordTimeout', passwordTimeout)
..add('oauthPasswordRequired', oauthPasswordRequired) ..add('oauthPasswordRequired', oauthPasswordRequired)
..add('markdownEnabled', markdownEnabled) ..add('markdownEnabled', markdownEnabled)
..add('markdownEmailEnabled', markdownEmailEnabled)
..add('useCommaAsDecimalPlace', useCommaAsDecimalPlace) ..add('useCommaAsDecimalPlace', useCommaAsDecimalPlace)
..add('reportIncludeDrafts', reportIncludeDrafts) ..add('reportIncludeDrafts', reportIncludeDrafts)
..add('groups', groups) ..add('groups', groups)
@ -2165,6 +2179,11 @@ class CompanyEntityBuilder
set markdownEnabled(bool markdownEnabled) => set markdownEnabled(bool markdownEnabled) =>
_$this._markdownEnabled = markdownEnabled; _$this._markdownEnabled = markdownEnabled;
bool _markdownEmailEnabled;
bool get markdownEmailEnabled => _$this._markdownEmailEnabled;
set markdownEmailEnabled(bool markdownEmailEnabled) =>
_$this._markdownEmailEnabled = markdownEmailEnabled;
bool _useCommaAsDecimalPlace; bool _useCommaAsDecimalPlace;
bool get useCommaAsDecimalPlace => _$this._useCommaAsDecimalPlace; bool get useCommaAsDecimalPlace => _$this._useCommaAsDecimalPlace;
set useCommaAsDecimalPlace(bool useCommaAsDecimalPlace) => set useCommaAsDecimalPlace(bool useCommaAsDecimalPlace) =>
@ -2490,6 +2509,7 @@ class CompanyEntityBuilder
_passwordTimeout = $v.passwordTimeout; _passwordTimeout = $v.passwordTimeout;
_oauthPasswordRequired = $v.oauthPasswordRequired; _oauthPasswordRequired = $v.oauthPasswordRequired;
_markdownEnabled = $v.markdownEnabled; _markdownEnabled = $v.markdownEnabled;
_markdownEmailEnabled = $v.markdownEmailEnabled;
_useCommaAsDecimalPlace = $v.useCommaAsDecimalPlace; _useCommaAsDecimalPlace = $v.useCommaAsDecimalPlace;
_reportIncludeDrafts = $v.reportIncludeDrafts; _reportIncludeDrafts = $v.reportIncludeDrafts;
_groups = $v.groups.toBuilder(); _groups = $v.groups.toBuilder();
@ -2613,6 +2633,7 @@ class CompanyEntityBuilder
passwordTimeout: BuiltValueNullFieldError.checkNotNull(passwordTimeout, 'CompanyEntity', 'passwordTimeout'), passwordTimeout: BuiltValueNullFieldError.checkNotNull(passwordTimeout, 'CompanyEntity', 'passwordTimeout'),
oauthPasswordRequired: BuiltValueNullFieldError.checkNotNull(oauthPasswordRequired, 'CompanyEntity', 'oauthPasswordRequired'), oauthPasswordRequired: BuiltValueNullFieldError.checkNotNull(oauthPasswordRequired, 'CompanyEntity', 'oauthPasswordRequired'),
markdownEnabled: BuiltValueNullFieldError.checkNotNull(markdownEnabled, 'CompanyEntity', 'markdownEnabled'), markdownEnabled: BuiltValueNullFieldError.checkNotNull(markdownEnabled, 'CompanyEntity', 'markdownEnabled'),
markdownEmailEnabled: BuiltValueNullFieldError.checkNotNull(markdownEmailEnabled, 'CompanyEntity', 'markdownEmailEnabled'),
useCommaAsDecimalPlace: BuiltValueNullFieldError.checkNotNull(useCommaAsDecimalPlace, 'CompanyEntity', 'useCommaAsDecimalPlace'), useCommaAsDecimalPlace: BuiltValueNullFieldError.checkNotNull(useCommaAsDecimalPlace, 'CompanyEntity', 'useCommaAsDecimalPlace'),
reportIncludeDrafts: BuiltValueNullFieldError.checkNotNull(reportIncludeDrafts, 'CompanyEntity', 'reportIncludeDrafts'), reportIncludeDrafts: BuiltValueNullFieldError.checkNotNull(reportIncludeDrafts, 'CompanyEntity', 'reportIncludeDrafts'),
groups: groups.build(), groups: groups.build(),

View File

@ -1,5 +1,6 @@
// Flutter imports: // Flutter imports:
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:html2md/html2md.dart' as html2md;
// Project imports: // Project imports:
import 'package:invoiceninja_flutter/constants.dart'; import 'package:invoiceninja_flutter/constants.dart';
@ -147,6 +148,12 @@ class _InvoiceEmailViewState extends State<InvoiceEmailView>
_bodyPreview = body.trim(); _bodyPreview = body.trim();
_rawBodyPreview = rawBody.trim(); _rawBodyPreview = rawBody.trim();
final company = widget.viewModel.state.company;
if (company.markdownEmailEnabled &&
_rawBodyPreview.startsWith('<p>')) {
_rawBodyPreview = html2md.convert(_rawBodyPreview);
}
if (origSubject.isEmpty && origBody.isEmpty) { if (origSubject.isEmpty && origBody.isEmpty) {
_subjectController.text = rawSubject.trim(); _subjectController.text = rawSubject.trim();
_bodyController.text = rawBody.trim(); _bodyController.text = rawBody.trim();
@ -292,19 +299,7 @@ class _InvoiceEmailViewState extends State<InvoiceEmailView>
enabled: enableCustomEmail, enabled: enableCustomEmail,
), ),
), ),
if ((_rawBodyPreview ?? '').startsWith('<p>')) if (state.company.markdownEmailEnabled)
Padding(
padding: const EdgeInsets.symmetric(horizontal: 20),
child: DecoratedFormField(
controller: _bodyController,
label: localization.body,
maxLines: enableCustomEmail ? 6 : 2,
keyboardType: TextInputType.multiline,
onChanged: (_) => _onChanged(),
enabled: enableCustomEmail,
),
)
else
Expanded( Expanded(
child: Material( child: Material(
color: Colors.white, color: Colors.white,
@ -324,7 +319,19 @@ class _InvoiceEmailViewState extends State<InvoiceEmailView>
], ],
), ),
), ),
)
else
Padding(
padding: const EdgeInsets.symmetric(horizontal: 20),
child: DecoratedFormField(
controller: _bodyController,
label: localization.body,
maxLines: enableCustomEmail ? 6 : 2,
keyboardType: TextInputType.multiline,
onChanged: (_) => _onChanged(),
enabled: enableCustomEmail,
), ),
)
], ],
); );
} }

View File

@ -56,9 +56,10 @@ dependencies:
boardview: ^0.2.2 boardview: ^0.2.2
pointer_interceptor: ^0.9.0 pointer_interceptor: ^0.9.0
contacts_service: ^0.6.1 contacts_service: ^0.6.1
super_editor: ^0.1.0
diacritic: ^0.1.3 diacritic: ^0.1.3
states_rebuilder: ^5.2.0 states_rebuilder: ^5.2.0
super_editor: ^0.2.0
html2md: ^1.2.5
# bitsdojo_window: ^0.1.1+1 # bitsdojo_window: ^0.1.1+1
# printing: ^5.6.3 # printing: ^5.6.3
# quick_actions: ^0.2.1 # quick_actions: ^0.2.1

View File

@ -225,6 +225,13 @@ packages:
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "3.0.1" version: "3.0.1"
csslib:
dependency: transitive
description:
name: csslib
url: "https://pub.dartlang.org"
source: hosted
version: "0.17.1"
dart_style: dart_style:
dependency: transitive dependency: transitive
description: description:
@ -472,6 +479,20 @@ packages:
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "2.1.0" version: "2.1.0"
html:
dependency: transitive
description:
name: html
url: "https://pub.dartlang.org"
source: hosted
version: "0.15.0"
html2md:
dependency: "direct main"
description:
name: html2md
url: "https://pub.dartlang.org"
source: hosted
version: "1.2.5"
http: http:
dependency: "direct main" dependency: "direct main"
description: description:

View File

@ -56,9 +56,10 @@ dependencies:
boardview: ^0.2.2 boardview: ^0.2.2
pointer_interceptor: ^0.9.0 pointer_interceptor: ^0.9.0
contacts_service: ^0.6.1 contacts_service: ^0.6.1
super_editor: ^0.1.0
diacritic: ^0.1.3 diacritic: ^0.1.3
states_rebuilder: ^5.2.0 states_rebuilder: ^5.2.0
super_editor: ^0.2.0
html2md: ^1.2.5
# bitsdojo_window: ^0.1.1+1 # bitsdojo_window: ^0.1.1+1
# printing: ^5.6.3 # printing: ^5.6.3
# quick_actions: ^0.2.1 # quick_actions: ^0.2.1

View File

@ -59,6 +59,7 @@ dependencies:
diacritic: ^0.1.3 diacritic: ^0.1.3
states_rebuilder: ^5.2.0 states_rebuilder: ^5.2.0
super_editor: ^0.2.0 super_editor: ^0.2.0
html2md: ^1.2.5
# bitsdojo_window: ^0.1.1+1 # bitsdojo_window: ^0.1.1+1
# printing: ^5.6.3 # printing: ^5.6.3
# quick_actions: ^0.2.1 # quick_actions: ^0.2.1