feat(core): Update to ckeditor 5. Fixes #5920. Encapsulate signature in raw-html-embed div when there are tables inside. Changed settings for raw html to enable preview.

This commit is contained in:
smizrahi
2024-03-05 21:57:01 +01:00
parent 1719baea7a
commit dd965baae1
5 changed files with 54 additions and 1 deletions

View File

@@ -1091,7 +1091,42 @@ static const NSString *kEncryptedUserNamePrefix = @"uenc";
}
}
return mailAccounts;
// Patch for CKEditor 5
// HTML Signatures with tables are broken with CKEditor 5
// In this case, signatures may be encapsulated with a <div class="raw-html-embed">
// Details in https://bugs.sogo.nu/view.php?id=5920
NSMutableArray *tmpMailAccounts, *tmpIdentities;
NSDictionary *account, *identities, *identity;
NSMutableDictionary *tmpAccount, *tmpIdentity;
NSString *signature;
if (mailAccounts && [mailAccounts count] > 0) {
tmpMailAccounts = [NSMutableArray array];
for (account in mailAccounts) {
tmpAccount = [NSMutableDictionary dictionaryWithDictionary: account];
if ([account objectForKey: @"identities"]) {
identities = [account objectForKey: @"identities"];
tmpIdentities = [NSMutableArray array];
for (identity in identities) {
tmpIdentity = [NSMutableDictionary dictionaryWithDictionary: identity];
if ([tmpIdentity objectForKey: @"signature"]) {
// Add raw html embed class
if ([[tmpIdentity objectForKey: @"signature"] rangeOfString:@"<table"].location != NSNotFound
&& [[tmpIdentity objectForKey: @"signature"] rangeOfString:@"<figure class=\"table\""].location == NSNotFound
&& [[tmpIdentity objectForKey: @"signature"] rangeOfString:@"raw-html-embed"].location == NSNotFound) {
signature = [NSString stringWithFormat:@"<div class=\"raw-html-embed\">%@</div>", [tmpIdentity objectForKey: @"signature"]];
[tmpIdentity setObject:signature forKey:@"signature"];
}
}
[tmpIdentities addObject: tmpIdentity];
}
[tmpAccount setObject:tmpIdentities forKey: @"identities"];
}
[tmpMailAccounts addObject: tmpAccount];
}
}
return tmpMailAccounts;
}
- (NSDictionary *) accountWithName: (NSString *) accountName;

View File

@@ -254,6 +254,9 @@
}
]
};
config.htmlEmbed = {
showPreviews: true
};
config.image = {
resizeUnit: "px",
insert: {

View File

@@ -10,4 +10,9 @@
.ck-editor__editable {
min-height: 200px;
}
.ck-widget.raw-html-embed .raw-html-embed__preview-content>* {
margin-left: unset !important;
margin-right: unset !important;
}
}

View File

@@ -423,4 +423,9 @@ md-dialog md-dialog-actions.sg-mail-editor-attachments {
right: 0!important;
left: auto!important;
}
.ck-widget.raw-html-embed .raw-html-embed__preview-content>* {
margin-left: unset!important;
margin-right: unset!important;
}
}

View File

@@ -18,4 +18,9 @@
.ck-editor__editable {
min-height: 70px;
}
.ck-widget.raw-html-embed .raw-html-embed__preview-content>* {
margin-left: unset!important;
margin-right: unset!important;
}
}