Skip to content

Commit

Permalink
feat(core): Update to ckeditor 5. Fixes #5920. Encapsulate signature …
Browse files Browse the repository at this point in the history
…in raw-html-embed div when there are tables inside. Changed settings for raw html to enable preview.
  • Loading branch information
WoodySlum committed Mar 5, 2024
1 parent 1719bae commit dd965ba
Show file tree
Hide file tree
Showing 5 changed files with 54 additions and 1 deletion.
37 changes: 36 additions & 1 deletion SoObjects/SOGo/SOGoUser.m
Expand Up @@ -1091,7 +1091,42 @@ - (NSArray *) mailAccountsWithDelegatedIdentities: (BOOL) appendDeletegatedIdent
}
}

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;
Expand Down
3 changes: 3 additions & 0 deletions UI/WebServerResources/js/Common/sgCkeditor.component.js
Expand Up @@ -254,6 +254,9 @@
}
]
};
config.htmlEmbed = {
showPreviews: true
};
config.image = {
resizeUnit: "px",
insert: {
Expand Down
5 changes: 5 additions & 0 deletions UI/WebServerResources/scss/views/AdministrationUI.scss
Expand Up @@ -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;
}
}
5 changes: 5 additions & 0 deletions UI/WebServerResources/scss/views/MailerUI.scss
Expand Up @@ -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;
}
}
5 changes: 5 additions & 0 deletions UI/WebServerResources/scss/views/PreferencesUI.scss
Expand Up @@ -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;
}
}

0 comments on commit dd965ba

Please sign in to comment.