From 2733f945c55abf68fe6c73c3c3bfddaa80e64716 Mon Sep 17 00:00:00 2001 From: iliajie Date: Wed, 21 Jun 2023 12:42:08 +0300 Subject: [PATCH 1/5] Add ability for themes to embed styles into quote `iframe` --- mailboxes/folders-lib.pl | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/mailboxes/folders-lib.pl b/mailboxes/folders-lib.pl index 33ae04a90..c23af585e 100755 --- a/mailboxes/folders-lib.pl +++ b/mailboxes/folders-lib.pl @@ -2950,10 +2950,21 @@ sub iframe_quote my ($quote) = @_; return $quote if (!$quote); +# Do we have theme styles to embed +# for local display purposes only +my $iframe_styles_theme = ''; +if ($ENV{'HTTP_X_COLOR_PALETTE_FILE'}) { + my $iframe_theme_file = + "$root_directory/$current_theme/unauthenticated/css/_iframe/$ENV{'HTTP_X_COLOR_PALETTE_FILE'}.min.css"; + $iframe_styles_theme = &read_file_contents($iframe_theme_file) + if (-r $iframe_theme_file); +} + # Quote mail iframe inner styles my $iframe_styles = < html, body { overflow-y: hidden; } + $iframe_styles_theme EOF # Add inner styles to the email body From 444c101d191ceaee8ff798fb3ba282bb2c420057 Mon Sep 17 00:00:00 2001 From: iliajie Date: Wed, 21 Jun 2023 15:40:13 +0300 Subject: [PATCH 2/5] Fix to remove outline for inner contenteditable --- mailboxes/folders-lib.pl | 1 + 1 file changed, 1 insertion(+) diff --git a/mailboxes/folders-lib.pl b/mailboxes/folders-lib.pl index c23af585e..d811b4ff5 100755 --- a/mailboxes/folders-lib.pl +++ b/mailboxes/folders-lib.pl @@ -2964,6 +2964,7 @@ if ($ENV{'HTTP_X_COLOR_PALETTE_FILE'}) { my $iframe_styles = < html, body { overflow-y: hidden; } + div[contenteditable] { outline: none; } $iframe_styles_theme EOF From d191f1ba925f02e8f8a1f499af9a50cdd13058bc Mon Sep 17 00:00:00 2001 From: iliajie Date: Wed, 21 Jun 2023 16:07:42 +0300 Subject: [PATCH 3/5] Add to consider different navigation types --- html-editor-lib.pl | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/html-editor-lib.pl b/html-editor-lib.pl index 6b3273971..e41d1d503 100644 --- a/html-editor-lib.pl +++ b/html-editor-lib.pl @@ -236,7 +236,8 @@ my $iframe_styles = "e_escape( &read_file_contents("$root_directory/unauthenticated/css/_iframe/$iframe_styles_mode.min.css"), '"'); $iframe_styles =~ s/\n/ /g; - +my $navigation_type = $ENV{'HTTP_X_NAVIGATION_TYPE'}; +$navigation_type ||= 'navigate'; my $html_editor_init_script = < @@ -245,6 +246,7 @@ my $html_editor_init_script = qs = Quill.import('attributors/style/size'), qf = Quill.import('attributors/style/font'), isMac = navigator.userAgent.toLowerCase().includes('mac'), + navigation_type = '$navigation_type', iframe_styles = "$iframe_styles"; qs.whitelist = ["0.75em", "1.15em", "1.3em"]; @@ -340,7 +342,8 @@ my $html_editor_init_script = // is reloaded or history back is clicked let restore_message = false; try { - restore_message = window.performance?.navigation?.type > 0 + restore_message = window.performance.getEntriesByType("navigation")[0].type !== 'navigate' && + navigation_type === 'navigate' } catch(e) { restore_message = false; } From ea8c76b5b8fef42085af7eab9f45a0b046ee56f0 Mon Sep 17 00:00:00 2001 From: iliajie Date: Wed, 21 Jun 2023 17:53:11 +0300 Subject: [PATCH 4/5] Fix to consider framed theme to load `iframe` inner styles too --- .../unauthenticated/css/_iframe/quote.min.css | 7 +++++++ mailboxes/folders-lib.pl | 14 +++++++------- 2 files changed, 14 insertions(+), 7 deletions(-) create mode 100644 gray-theme/unauthenticated/css/_iframe/quote.min.css diff --git a/gray-theme/unauthenticated/css/_iframe/quote.min.css b/gray-theme/unauthenticated/css/_iframe/quote.min.css new file mode 100644 index 000000000..a5677b358 --- /dev/null +++ b/gray-theme/unauthenticated/css/_iframe/quote.min.css @@ -0,0 +1,7 @@ +body blockquote:not([style*="border-left"]) { + border-left: 1px solid #ccc; + margin-left: 6px; + margin-top: 0; + margin-bottom: 0; + padding-left: 12px; +} diff --git a/mailboxes/folders-lib.pl b/mailboxes/folders-lib.pl index d811b4ff5..03dd68d99 100755 --- a/mailboxes/folders-lib.pl +++ b/mailboxes/folders-lib.pl @@ -2952,13 +2952,13 @@ return $quote if (!$quote); # Do we have theme styles to embed # for local display purposes only -my $iframe_styles_theme = ''; -if ($ENV{'HTTP_X_COLOR_PALETTE_FILE'}) { - my $iframe_theme_file = - "$root_directory/$current_theme/unauthenticated/css/_iframe/$ENV{'HTTP_X_COLOR_PALETTE_FILE'}.min.css"; - $iframe_styles_theme = &read_file_contents($iframe_theme_file) - if (-r $iframe_theme_file); -} +my $iframe_theme_file = sub { + my $f = + "$root_directory/$current_theme/unauthenticated/css/_iframe/$_[0].min.css"; + return -r $f ? &read_file_contents($f) : ''; +}; +my $iframe_styles_theme = + &$iframe_theme_file('quote'); # Quote mail iframe inner styles my $iframe_styles = < Date: Wed, 21 Jun 2023 18:21:42 +0300 Subject: [PATCH 5/5] Fix navigation type detection bug --- html-editor-lib.pl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/html-editor-lib.pl b/html-editor-lib.pl index e41d1d503..0f556f5ee 100644 --- a/html-editor-lib.pl +++ b/html-editor-lib.pl @@ -237,7 +237,7 @@ my $iframe_styles = &read_file_contents("$root_directory/unauthenticated/css/_iframe/$iframe_styles_mode.min.css"), '"'); $iframe_styles =~ s/\n/ /g; my $navigation_type = $ENV{'HTTP_X_NAVIGATION_TYPE'}; -$navigation_type ||= 'navigate'; +$navigation_type ||= 'reload'; my $html_editor_init_script = < @@ -343,7 +343,7 @@ my $html_editor_init_script = let restore_message = false; try { restore_message = window.performance.getEntriesByType("navigation")[0].type !== 'navigate' && - navigation_type === 'navigate' + navigation_type !== 'navigate' } catch(e) { restore_message = false; }