I#1269 - Composer: Paste plain text as Preformatted
Closes https://gitlab.gnome.org/GNOME/evolution/-/issues/1269
This commit is contained in:
@ -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);
|
||||
|
||||
|
||||
@ -761,12 +761,12 @@ test_bug_773164 (TestFixture *fixture)
|
||||
"undo:undo:3\n"
|
||||
"undo:test\n"
|
||||
"undo:redo:3\n",
|
||||
HTML_PREFIX "<div style=\"width: 71ch;\">This is paragraph 1</div>"
|
||||
"<div style=\"width: 71ch;\"><br></div>"
|
||||
"<div style=\"width: 71ch;\">This is a longer paragraph 3</div>"
|
||||
"<div style=\"width: 71ch;\"><br></div>"
|
||||
"<div style=\"width: 71ch;\">This is paragraph 2</div>"
|
||||
"<div style=\"width: 71ch;\"><br></div>"
|
||||
HTML_PREFIX "<pre>This is paragraph 1</pre>"
|
||||
"<pre><br></pre>"
|
||||
"<pre>This is a longer paragraph 3</pre>"
|
||||
"<pre><br></pre>"
|
||||
"<pre>This is paragraph 2</pre>"
|
||||
"<pre><br></pre>"
|
||||
HTML_SUFFIX,
|
||||
"This is paragraph 1\n"
|
||||
"\n"
|
||||
@ -982,8 +982,8 @@ test_bug_780275_html (TestFixture *fixture)
|
||||
"undo:redo\n",
|
||||
HTML_PREFIX "<div>line 0</div>"
|
||||
"<blockquote type=\"cite\" " BLOCKQUOTE_STYLE ">"
|
||||
"<div>Xline 1</div>"
|
||||
"<div>line 2</div>"
|
||||
"<pre>Xline 1</pre>"
|
||||
"<pre>line 2</pre>"
|
||||
"</blockquote>"
|
||||
"<div>line 4</div>"
|
||||
HTML_SUFFIX,
|
||||
@ -1020,8 +1020,8 @@ test_bug_780275_plain (TestFixture *fixture)
|
||||
"undo:redo\n",
|
||||
HTML_PREFIX "<div style=\"width: 71ch;\">line 0</div>"
|
||||
"<blockquote type=\"cite\">"
|
||||
"<div>" QUOTE_SPAN (QUOTE_CHR) "Xline 1</div>"
|
||||
"<div>" QUOTE_SPAN (QUOTE_CHR) "line 2</div>"
|
||||
"<pre>" QUOTE_SPAN (QUOTE_CHR) "Xline 1</pre>"
|
||||
"<pre>" QUOTE_SPAN (QUOTE_CHR) "line 2</pre>"
|
||||
"</blockquote>"
|
||||
"<div style=\"width: 71ch;\">line 4</div>"
|
||||
HTML_SUFFIX,
|
||||
|
||||
@ -4353,7 +4353,7 @@ test_paste_multiline_plain2html (TestFixture *fixture)
|
||||
"type:text before \n"
|
||||
"action:paste\n"
|
||||
"type:text after\n",
|
||||
HTML_PREFIX "<div>text before line 1</div><div>line 2</div><div>line 3</div><div>text after</div>" HTML_SUFFIX,
|
||||
HTML_PREFIX "<div>text before line 1</div><pre>line 2</pre><pre>line 3</pre><pre>text after</pre>" 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 "<div style=\"width: 71ch;\">text before line 1</div>"
|
||||
"<div style=\"width: 71ch;\">line 2</div>"
|
||||
"<div style=\"width: 71ch;\">line 3</div>"
|
||||
"<div style=\"width: 71ch;\">text after</div>" HTML_SUFFIX,
|
||||
"<pre>line 2</pre>"
|
||||
"<pre>line 3</pre>"
|
||||
"<pre>text after</pre>" 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 "<div>text before </div>"
|
||||
"<blockquote type=\"cite\" " BLOCKQUOTE_STYLE "><div>line 1</div>"
|
||||
"<div>line 2</div>"
|
||||
"<div>line 3</div>"
|
||||
"<div><br></div></blockquote>"
|
||||
"<blockquote type=\"cite\" " BLOCKQUOTE_STYLE "><pre>line 1</pre>"
|
||||
"<pre>line 2</pre>"
|
||||
"<pre>line 3</pre>"
|
||||
"<pre><br></pre></blockquote>"
|
||||
"<div>text after</div>" 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 "<div style=\"width: 71ch;\">text before </div>"
|
||||
"<blockquote type=\"cite\"><div>" QUOTE_SPAN (QUOTE_CHR) "line 1</div>"
|
||||
"<div>" QUOTE_SPAN (QUOTE_CHR) "line 2</div>"
|
||||
"<div>" QUOTE_SPAN (QUOTE_CHR) "line 3</div></blockquote>"
|
||||
"<blockquote type=\"cite\"><pre>" QUOTE_SPAN (QUOTE_CHR) "line 1</pre>"
|
||||
"<pre>" QUOTE_SPAN (QUOTE_CHR) "line 2</pre>"
|
||||
"<pre>" QUOTE_SPAN (QUOTE_CHR) "line 3</pre></blockquote>"
|
||||
"<div style=\"width: 71ch;\">text after</div>" HTML_SUFFIX,
|
||||
"text before \n"
|
||||
"> line 1\n"
|
||||
@ -6842,10 +6842,10 @@ test_delete_quoted_selection (TestFixture *fixture)
|
||||
"type:X\n",
|
||||
HTML_PREFIX "<div style=\"width: 71ch;\">line 0</div>"
|
||||
"<blockquote type=\"cite\">"
|
||||
"<div>" QUOTE_SPAN (QUOTE_CHR) "line 1</div>"
|
||||
"<div>" QUOTE_SPAN (QUOTE_CHR) "<br></div>"
|
||||
"<div>" QUOTE_SPAN (QUOTE_CHR) "line 2</div>"
|
||||
"<div>" QUOTE_SPAN (QUOTE_CHR) "X</div>"
|
||||
"<pre>" QUOTE_SPAN (QUOTE_CHR) "line 1</pre>"
|
||||
"<pre>" QUOTE_SPAN (QUOTE_CHR) "<br></pre>"
|
||||
"<pre>" QUOTE_SPAN (QUOTE_CHR) "line 2</pre>"
|
||||
"<pre>" QUOTE_SPAN (QUOTE_CHR) "X</pre>"
|
||||
"</blockquote>"
|
||||
HTML_SUFFIX,
|
||||
"line 0\n"
|
||||
@ -6868,8 +6868,8 @@ test_delete_quoted_multiselect (TestFixture *fixture)
|
||||
"undo:save\n" /* 1 */
|
||||
"seq:ChcrrSdsD\n",
|
||||
HTML_PREFIX "<blockquote type=\"cite\" " BLOCKQUOTE_STYLE ">"
|
||||
"<div>line 2</div>"
|
||||
"<div>line 3X</div>"
|
||||
"<pre>line 2</pre>"
|
||||
"<pre>line 3X</pre>"
|
||||
"</blockquote>"
|
||||
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 "<blockquote type=\"cite\" " BLOCKQUOTE_STYLE ">"
|
||||
"<div>line 2</div>"
|
||||
"<div>line 3X</div>"
|
||||
"<pre>line 2</pre>"
|
||||
"<pre>line 3X</pre>"
|
||||
"</blockquote>"
|
||||
"<div>Y</div>"
|
||||
HTML_SUFFIX,
|
||||
@ -6907,8 +6907,8 @@ test_delete_quoted_multiselect (TestFixture *fixture)
|
||||
"undo:save\n" /* 1 */
|
||||
"seq:ChcrrSdsD\n",
|
||||
HTML_PREFIX "<blockquote type=\"cite\">"
|
||||
"<div>" QUOTE_SPAN (QUOTE_CHR) "line 2</div>"
|
||||
"<div>" QUOTE_SPAN (QUOTE_CHR) "line 3X</div>"
|
||||
"<pre>" QUOTE_SPAN (QUOTE_CHR) "line 2</pre>"
|
||||
"<pre>" QUOTE_SPAN (QUOTE_CHR) "line 3X</pre>"
|
||||
"</blockquote>"
|
||||
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 "<blockquote type=\"cite\">"
|
||||
"<div>" QUOTE_SPAN (QUOTE_CHR) "line 2</div>"
|
||||
"<div>" QUOTE_SPAN (QUOTE_CHR) "line 3X</div>"
|
||||
"<pre>" QUOTE_SPAN (QUOTE_CHR) "line 2</pre>"
|
||||
"<pre>" QUOTE_SPAN (QUOTE_CHR) "line 3X</pre>"
|
||||
"</blockquote>"
|
||||
"<div style=\"width: 71ch;\">Y</div>"
|
||||
HTML_SUFFIX,
|
||||
|
||||
@ -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,
|
||||
|
||||
Reference in New Issue
Block a user