[evolution/gnome-40] I#1469 - Composer: Signatures in HTML inserted into the quote on reply
- From: Milan Crha <mcrha src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution/gnome-40] I#1469 - Composer: Signatures in HTML inserted into the quote on reply
- Date: Thu, 10 Jun 2021 11:33:36 +0000 (UTC)
commit 8fe6b91030715c05afdf0b46526ad659cdfbc06c
Author: Milan Crha <mcrha redhat com>
Date: Thu Jun 10 13:33:01 2021 +0200
I#1469 - Composer: Signatures in HTML inserted into the quote on reply
It could happen when replying to a message composed by Evolution 3.38.1
and earlier.
Closes https://gitlab.gnome.org/GNOME/evolution/-/issues/1469
data/webkit/e-editor.js | 21 +++++++++++++++++++++
src/composer/e-msg-composer.c | 3 ++-
src/e-util/e-util-enums.h | 4 +++-
src/modules/webkit-editor/e-webkit-editor.c | 9 +++++++++
4 files changed, 35 insertions(+), 2 deletions(-)
---
diff --git a/data/webkit/e-editor.js b/data/webkit/e-editor.js
index 706da2739c..be77e8cc85 100644
--- a/data/webkit/e-editor.js
+++ b/data/webkit/e-editor.js
@@ -6222,6 +6222,27 @@ EvoEditor.WrapSelection = function()
}
}
+EvoEditor.CleanupSignatureID = function()
+{
+ var elements, ii;
+
+ elements = document.querySelectorAll(".-x-evo-top-signature-spacer");
+ for (ii = elements.length - 1; ii >= 0; ii--) {
+ elements[ii].removeAttribute("class");
+ }
+
+ elements = document.querySelectorAll(".-x-evo-signature-wrapper");
+ for (ii = elements.length - 1; ii >= 0; ii--) {
+ elements[ii].removeAttribute("class");
+ }
+
+ elements = document.querySelectorAll(".-x-evo-signature");
+ for (ii = elements.length - 1; ii >= 0; ii--) {
+ elements[ii].removeAttribute("class");
+ elements[ii].removeAttribute("id");
+ }
+}
+
EvoEditor.onContextMenu = function(event)
{
var node = event.target;
diff --git a/src/composer/e-msg-composer.c b/src/composer/e-msg-composer.c
index b1094a920b..58bbf39be2 100644
--- a/src/composer/e-msg-composer.c
+++ b/src/composer/e-msg-composer.c
@@ -1775,7 +1775,8 @@ set_editor_text (EMsgComposer *composer,
cnt_editor,
text,
E_CONTENT_EDITOR_INSERT_TEXT_HTML |
- E_CONTENT_EDITOR_INSERT_REPLACE_ALL);
+ E_CONTENT_EDITOR_INSERT_REPLACE_ALL |
+ (e_msg_composer_get_is_reply_or_forward (composer) ?
E_CONTENT_EDITOR_INSERT_CLEANUP_SIGNATURE_ID : 0));
else
e_content_editor_insert_content (
cnt_editor,
diff --git a/src/e-util/e-util-enums.h b/src/e-util/e-util-enums.h
index 2fb3526db6..be9af180b0 100644
--- a/src/e-util/e-util-enums.h
+++ b/src/e-util/e-util-enums.h
@@ -151,6 +151,7 @@ typedef enum {
* @E_CONTENT_EDITOR_INSERT_TEXT_HTML:
* @E_CONTENT_EDITOR_INSERT_TEXT_PLAIN:
* @E_CONTENT_EDITOR_INSERT_CONVERT_PREFER_PRE: Set when should convert plain text into <pre> instead
of <div>. Since 3.40
+ * @E_CONTENT_EDITOR_INSERT_CLEANUP_SIGNATURE_ID: Set when should cleanup signature ID in the body. Since
3.40.3
*
* Since: 3.22
**/
@@ -161,7 +162,8 @@ typedef enum {
E_CONTENT_EDITOR_INSERT_REPLACE_ALL = 1 << 2,
E_CONTENT_EDITOR_INSERT_TEXT_HTML = 1 << 3,
E_CONTENT_EDITOR_INSERT_TEXT_PLAIN = 1 << 4,
- E_CONTENT_EDITOR_INSERT_CONVERT_PREFER_PRE = 1 << 5
+ E_CONTENT_EDITOR_INSERT_CONVERT_PREFER_PRE = 1 << 5,
+ E_CONTENT_EDITOR_INSERT_CLEANUP_SIGNATURE_ID = 1 << 6
} EContentEditorInsertContentFlags;
/**
diff --git a/src/modules/webkit-editor/e-webkit-editor.c b/src/modules/webkit-editor/e-webkit-editor.c
index 0c08104856..fcafeae2ee 100644
--- a/src/modules/webkit-editor/e-webkit-editor.c
+++ b/src/modules/webkit-editor/e-webkit-editor.c
@@ -1973,6 +1973,7 @@ webkit_editor_insert_content (EContentEditor *editor,
{
EWebKitEditor *wk_editor;
gboolean prefer_pre;
+ gboolean cleanup_sig_id;
wk_editor = E_WEBKIT_EDITOR (editor);
@@ -1991,6 +1992,7 @@ webkit_editor_insert_content (EContentEditor *editor,
}
prefer_pre = (flags & E_CONTENT_EDITOR_INSERT_CONVERT_PREFER_PRE) != 0;
+ cleanup_sig_id = (flags & E_CONTENT_EDITOR_INSERT_CLEANUP_SIGNATURE_ID) != 0;
if ((flags & E_CONTENT_EDITOR_INSERT_CONVERT) &&
!(flags & E_CONTENT_EDITOR_INSERT_REPLACE_ALL)) {
@@ -2003,6 +2005,8 @@ webkit_editor_insert_content (EContentEditor *editor,
strstr (content, "data-evo-signature-plain-text-mode"))) {
e_web_view_jsc_run_script (WEBKIT_WEB_VIEW (wk_editor), wk_editor->priv->cancellable,
"EvoEditor.LoadHTML(%s);", content);
+ if (cleanup_sig_id)
+ e_web_view_jsc_run_script (WEBKIT_WEB_VIEW (wk_editor),
wk_editor->priv->cancellable, "EvoEditor.CleanupSignatureID();");
return;
}
@@ -2014,6 +2018,8 @@ webkit_editor_insert_content (EContentEditor *editor,
webkit_editor_set_html_mode (wk_editor, TRUE);
e_web_view_jsc_run_script (WEBKIT_WEB_VIEW (wk_editor),
wk_editor->priv->cancellable,
"EvoEditor.LoadHTML(%s);", content);
+ if (cleanup_sig_id)
+ e_web_view_jsc_run_script (WEBKIT_WEB_VIEW (wk_editor),
wk_editor->priv->cancellable, "EvoEditor.CleanupSignatureID();");
return;
}
}
@@ -2066,6 +2072,9 @@ webkit_editor_insert_content (EContentEditor *editor,
g_warning ("%s: Unsupported flags combination (0x%x)", G_STRFUNC, flags);
}
+ if (cleanup_sig_id)
+ e_web_view_jsc_run_script (WEBKIT_WEB_VIEW (wk_editor), wk_editor->priv->cancellable,
"EvoEditor.CleanupSignatureID();");
+
if (flags & E_CONTENT_EDITOR_INSERT_REPLACE_ALL)
webkit_editor_style_updated (wk_editor, TRUE);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]