From 4cd97ac7fa2d53284a93bf7df7ba556cecf6dbf8 Mon Sep 17 00:00:00 2001 From: Milan Crha Date: Wed, 13 Jan 2021 10:51:17 +0100 Subject: [PATCH] I#1269 - Composer: Paste plain text as Preformatted Closes https://gitlab.gnome.org/GNOME/evolution/-/issues/1269 --- data/webkit/e-editor.js | 4 +- src/e-util/test-html-editor-units-bugs.c | 20 ++++----- src/e-util/test-html-editor-units.c | 46 ++++++++++----------- src/modules/webkit-editor/e-webkit-editor.c | 6 --- 4 files changed, 35 insertions(+), 41 deletions(-) diff --git a/data/webkit/e-editor.js b/data/webkit/e-editor.js index ad39ad1161..45bb2aa144 100644 --- a/data/webkit/e-editor.js +++ b/data/webkit/e-editor.js @@ -5087,7 +5087,7 @@ EvoEditor.InsertContent = function(text, isHTML, quote) } var wasPlain = !isHTML; - var content = document.createElement(quote ? "BLOCKQUOTE" : "DIV"); + var content = document.createElement(quote ? "BLOCKQUOTE" : wasPlain ? "PRE" : "DIV"); if (quote) { content.setAttribute("type", "cite"); @@ -5145,7 +5145,7 @@ EvoEditor.InsertContent = function(text, isHTML, quote) for (ii = 0; ii < lines.length; ii++) { line = lines[ii]; - divNode = document.createElement("DIV"); + divNode = document.createElement(wasPlain ? "PRE" : "DIV"); content.appendChild(divNode); diff --git a/src/e-util/test-html-editor-units-bugs.c b/src/e-util/test-html-editor-units-bugs.c index 83844a063e..f6c5b68579 100644 --- a/src/e-util/test-html-editor-units-bugs.c +++ b/src/e-util/test-html-editor-units-bugs.c @@ -761,12 +761,12 @@ test_bug_773164 (TestFixture *fixture) "undo:undo:3\n" "undo:test\n" "undo:redo:3\n", - HTML_PREFIX "
This is paragraph 1
" - "

" - "
This is a longer paragraph 3
" - "

" - "
This is paragraph 2
" - "

" + HTML_PREFIX "
This is paragraph 1
" + "

" + "
This is a longer paragraph 3
" + "

" + "
This is paragraph 2
" + "

" HTML_SUFFIX, "This is paragraph 1\n" "\n" @@ -982,8 +982,8 @@ test_bug_780275_html (TestFixture *fixture) "undo:redo\n", HTML_PREFIX "
line 0
" "
" - "
Xline 1
" - "
line 2
" + "
Xline 1
" + "
line 2
" "
" "
line 4
" HTML_SUFFIX, @@ -1020,8 +1020,8 @@ test_bug_780275_plain (TestFixture *fixture) "undo:redo\n", HTML_PREFIX "
line 0
" "
" - "
" QUOTE_SPAN (QUOTE_CHR) "Xline 1
" - "
" QUOTE_SPAN (QUOTE_CHR) "line 2
" + "
" QUOTE_SPAN (QUOTE_CHR) "Xline 1
" + "
" QUOTE_SPAN (QUOTE_CHR) "line 2
" "
" "
line 4
" HTML_SUFFIX, diff --git a/src/e-util/test-html-editor-units.c b/src/e-util/test-html-editor-units.c index 75ec24f3ff..f5126d1a1d 100644 --- a/src/e-util/test-html-editor-units.c +++ b/src/e-util/test-html-editor-units.c @@ -4353,7 +4353,7 @@ test_paste_multiline_plain2html (TestFixture *fixture) "type:text before \n" "action:paste\n" "type:text after\n", - HTML_PREFIX "
text before line 1
line 2
line 3
text after
" HTML_SUFFIX, + HTML_PREFIX "
text before line 1
line 2
line 3
text after
" HTML_SUFFIX, "text before line 1\nline 2\nline 3\ntext after\n")) g_test_fail (); } @@ -4369,9 +4369,9 @@ test_paste_multiline_plain2plain (TestFixture *fixture) "action:paste\n" "type:\\ntext after\n", HTML_PREFIX "
text before line 1
" - "
line 2
" - "
line 3
" - "
text after
" HTML_SUFFIX, + "
line 2
" + "
line 3
" + "
text after
" HTML_SUFFIX, "text before line 1\nline 2\nline 3\ntext after\n")) g_test_fail (); } @@ -4518,10 +4518,10 @@ test_paste_quoted_multiline_plain2html (TestFixture *fixture) "type:\\n\n" /* stop quotting */ "type:text after\n", HTML_PREFIX "
text before
" - "
line 1
" - "
line 2
" - "
line 3
" - "

" + "
line 1
" + "
line 2
" + "
line 3
" + "

" "
text after
" HTML_SUFFIX, "text before \n" "> line 1\n" @@ -4544,9 +4544,9 @@ test_paste_quoted_multiline_plain2plain (TestFixture *fixture) "type:\\n\n" /* stop quotting */ "type:text after\n", HTML_PREFIX "
text before
" - "
" QUOTE_SPAN (QUOTE_CHR) "line 1
" - "
" QUOTE_SPAN (QUOTE_CHR) "line 2
" - "
" QUOTE_SPAN (QUOTE_CHR) "line 3
" + "
" QUOTE_SPAN (QUOTE_CHR) "line 1
" + "
" QUOTE_SPAN (QUOTE_CHR) "line 2
" + "
" QUOTE_SPAN (QUOTE_CHR) "line 3
" "
text after
" HTML_SUFFIX, "text before \n" "> line 1\n" @@ -6842,10 +6842,10 @@ test_delete_quoted_selection (TestFixture *fixture) "type:X\n", HTML_PREFIX "
line 0
" "
" - "
" QUOTE_SPAN (QUOTE_CHR) "line 1
" - "
" QUOTE_SPAN (QUOTE_CHR) "
" - "
" QUOTE_SPAN (QUOTE_CHR) "line 2
" - "
" QUOTE_SPAN (QUOTE_CHR) "X
" + "
" QUOTE_SPAN (QUOTE_CHR) "line 1
" + "
" QUOTE_SPAN (QUOTE_CHR) "
" + "
" QUOTE_SPAN (QUOTE_CHR) "line 2
" + "
" QUOTE_SPAN (QUOTE_CHR) "X
" "
" HTML_SUFFIX, "line 0\n" @@ -6868,8 +6868,8 @@ test_delete_quoted_multiselect (TestFixture *fixture) "undo:save\n" /* 1 */ "seq:ChcrrSdsD\n", HTML_PREFIX "
" - "
line 2
" - "
line 3X
" + "
line 2
" + "
line 3X
" "
" HTML_SUFFIX, "> line 2\n" @@ -6886,8 +6886,8 @@ test_delete_quoted_multiselect (TestFixture *fixture) "seq:Cec\n" /* Go to the end of the document (Ctrl+End) */ "type:\\nY\n", HTML_PREFIX "
" - "
line 2
" - "
line 3X
" + "
line 2
" + "
line 3X
" "
" "
Y
" HTML_SUFFIX, @@ -6907,8 +6907,8 @@ test_delete_quoted_multiselect (TestFixture *fixture) "undo:save\n" /* 1 */ "seq:ChcrrSdsD\n", HTML_PREFIX "
" - "
" QUOTE_SPAN (QUOTE_CHR) "line 2
" - "
" QUOTE_SPAN (QUOTE_CHR) "line 3X
" + "
" QUOTE_SPAN (QUOTE_CHR) "line 2
" + "
" QUOTE_SPAN (QUOTE_CHR) "line 3X
" "
" HTML_SUFFIX, "> line 2\n" @@ -6924,8 +6924,8 @@ test_delete_quoted_multiselect (TestFixture *fixture) "seq:Cec\n" /* Go to the end of the document (Ctrl+End) */ "type:\\nY\n", HTML_PREFIX "
" - "
" QUOTE_SPAN (QUOTE_CHR) "line 2
" - "
" QUOTE_SPAN (QUOTE_CHR) "line 3X
" + "
" QUOTE_SPAN (QUOTE_CHR) "line 2
" + "
" QUOTE_SPAN (QUOTE_CHR) "line 3X
" "
" "
Y
" HTML_SUFFIX, diff --git a/src/modules/webkit-editor/e-webkit-editor.c b/src/modules/webkit-editor/e-webkit-editor.c index 919d523030..26cff463cf 100644 --- a/src/modules/webkit-editor/e-webkit-editor.c +++ b/src/modules/webkit-editor/e-webkit-editor.c @@ -2047,12 +2047,6 @@ webkit_editor_insert_content (EContentEditor *editor, g_strfreev (lines); g_free (html); - } else if ((flags & E_CONTENT_EDITOR_INSERT_CONVERT) && - !(flags & E_CONTENT_EDITOR_INSERT_REPLACE_ALL) && - !(flags & E_CONTENT_EDITOR_INSERT_QUOTE_CONTENT)) { - e_web_view_jsc_run_script (WEBKIT_WEB_VIEW (wk_editor), wk_editor->priv->cancellable, - "EvoEditor.InsertContent(%s, %x, %x);", - content, TRUE, FALSE); } else if ((flags & E_CONTENT_EDITOR_INSERT_QUOTE_CONTENT) && !(flags & E_CONTENT_EDITOR_INSERT_REPLACE_ALL)) { e_web_view_jsc_run_script (WEBKIT_WEB_VIEW (wk_editor), wk_editor->priv->cancellable,