[evolution/wip/mcrha/webkit-jsc-api] test-html-editor-units: Fix and extend test for selection wrap in quoted text
- From: Milan Crha <mcrha src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution/wip/mcrha/webkit-jsc-api] test-html-editor-units: Fix and extend test for selection wrap in quoted text
- Date: Fri, 27 Mar 2020 11:56:48 +0000 (UTC)
commit 0f4e400b09cccf195cdc25c1751f546a48e409da
Author: Milan Crha <mcrha redhat com>
Date: Fri Mar 27 12:59:04 2020 +0100
test-html-editor-units: Fix and extend test for selection wrap in quoted text
data/webkit/e-editor.js | 56 ++++++++++++++++++--------------
src/e-util/test-html-editor-units-bugs.c | 54 ++++++++++++++++++++++++++++--
2 files changed, 83 insertions(+), 27 deletions(-)
---
diff --git a/data/webkit/e-editor.js b/data/webkit/e-editor.js
index 57523f7e21..0fa42643be 100644
--- a/data/webkit/e-editor.js
+++ b/data/webkit/e-editor.js
@@ -989,6 +989,23 @@ EvoEditor.renameElement = function(element, tagName, attributes, targetElement,
return newElement;
}
+EvoEditor.getBlockquoteLevel = function(node)
+{
+ if (!node || node.tagName == "BODY")
+ return 0;
+
+ var blockquoteLevel = 0, parent = node;
+
+ while (parent && parent.tagName != "BODY") {
+ if (parent.tagName == "BLOCKQUOTE")
+ blockquoteLevel++;
+
+ parent = parent.parentElement;
+ }
+
+ return blockquoteLevel;
+}
+
EvoEditor.SetBlockFormat = function(format)
{
var traversar = {
@@ -1043,14 +1060,7 @@ EvoEditor.SetBlockFormat = function(format)
newElement = EvoEditor.renameElement(element, this.toSet.tagName,
this.toSet.attributes, this.targetElement, this.selectionUpdater);
if (EvoEditor.mode == EvoEditor.MODE_PLAIN_TEXT && (this.toSet.tagName == "DIV" ||
this.toSet.tagName == "PRE")) {
- var node = newElement, blockquoteLevel = 0;
-
- while (node && node.tagName != "BODY") {
- if (node.tagName == "BLOCKQUOTE")
- blockquoteLevel++;
-
- node = node.parentElement;
- }
+ var blockquoteLevel = EvoEditor.getBlockquoteLevel(newElement);
if (blockquoteLevel > 0) {
var width = -1;
@@ -2901,14 +2911,7 @@ EvoEditor.requoteNodeParagraph = function(node)
EvoEditor.CLAIM_CONTENT_FLAG_SAVE_HTML);
try {
- var blockquoteLevel = 0, parent = node;
-
- while (parent && parent.tagName != "BODY") {
- if (parent.tagName == "BLOCKQUOTE")
- blockquoteLevel++;
-
- parent = parent.parentElement;
- }
+ var blockquoteLevel = EvoEditor.getBlockquoteLevel(node);
EvoEditor.quoteParagraph(node, blockquoteLevel, EvoEditor.NORMAL_PARAGRAPH_WIDTH - (2 *
blockquoteLevel));
} finally {
@@ -3380,14 +3383,7 @@ EvoEditor.AfterInputEvent = function(inputEvent, isWordDelim)
parent = childNode.parentElement;
}
- blockquoteLevel = 0;
-
- while (parent && parent.tagName != "BODY") {
- if (parent.tagName == "BLOCKQUOTE")
- blockquoteLevel++;
-
- parent = parent.parentElement;
- }
+ blockquoteLevel = EvoEditor.getBlockquoteLevel(parent);
EvoEditor.quoteParagraph(childNode, blockquoteLevel,
EvoEditor.NORMAL_PARAGRAPH_WIDTH - (2 * blockquoteLevel));
@@ -5495,6 +5491,8 @@ EvoEditor.WrapSelection = function()
currentPar = null;
while (nodeFrom) {
+ EvoEditor.removeQuoteMarks(nodeFrom);
+
if (lastParTagName != nodeFrom.tagName) {
lastParTagName = nodeFrom.tagName;
currentPar = null;
@@ -5506,7 +5504,15 @@ EvoEditor.WrapSelection = function()
currentPar = null;
usedLetters = 0;
} else {
- usedLetters = EvoEditor.wrapParagraph(nodeFrom, maxLetters,
currentPar, usedLetters, false);
+ var blockquoteLevel = 0;
+
+ if (EvoEditor.mode == EvoEditor.MODE_PLAIN_TEXT)
+ blockquoteLevel = EvoEditor.getBlockquoteLevel(nodeFrom);
+
+ usedLetters = EvoEditor.wrapParagraph(nodeFrom, maxLetters - (2 *
blockquoteLevel), currentPar, usedLetters, false);
+
+ if (blockquoteLevel)
+ EvoEditor.requoteNodeParagraph(nodeFrom);
if (usedLetters == -1) {
currentPar = null;
diff --git a/src/e-util/test-html-editor-units-bugs.c b/src/e-util/test-html-editor-units-bugs.c
index 3a1ff1a93a..9572354726 100644
--- a/src/e-util/test-html-editor-units-bugs.c
+++ b/src/e-util/test-html-editor-units-bugs.c
@@ -1070,7 +1070,7 @@ test_bug_781116 (TestFixture *fixture)
test_utils_insert_content (fixture,
"<pre>a very long text, which splits into multiple lines when this paragraph is not marked as
preformatted, but as normal, as it should be</pre>\n"
- "</pre><span class=\"-x-evo-to-body\" data-credits=\"Credits:\"></span>"
+ "<span class=\"-x-evo-to-body\" data-credits=\"Credits:\"></span>"
"<span class=\"-x-evo-cite-body\"></span>",
E_CONTENT_EDITOR_INSERT_REPLACE_ALL | E_CONTENT_EDITOR_INSERT_TEXT_HTML);
@@ -1087,7 +1087,57 @@ test_bug_781116 (TestFixture *fixture)
"Credits:\n"
"> a very long text, which splits into multiple lines when this\n"
"> paragraph is not marked as preformatted, but as normal, as it should\n"
- "> be</pre>\n"))
+ "> be\n")) {
+ g_test_fail ();
+ return;
+ }
+
+ test_utils_insert_content (fixture,
+ "<blockquote type=\"cite\"><div>a very long text, which splits into multiple lines when this
paragraph is not marked as preformatted, but as normal, as it should be</div></blockquote>"
+ "<span class=\"-x-evo-to-body\" data-credits=\"Credits:\"></span>",
+ E_CONTENT_EDITOR_INSERT_REPLACE_ALL | E_CONTENT_EDITOR_INSERT_TEXT_HTML);
+
+ if (!test_utils_run_simple_test (fixture,
+ "seq:dd\n"
+ "action:wrap-lines\n",
+ HTML_PREFIX "<div style=\"width: 71ch;\">Credits:</div>"
+ "<blockquote type=\"cite\">"
+ "<div>" QUOTE_SPAN (QUOTE_CHR) "a very long text, which splits into multiple lines when
this<br>"
+ QUOTE_SPAN (QUOTE_CHR) "paragraph is not marked as preformatted, but as normal, as it
should<br>"
+ QUOTE_SPAN (QUOTE_CHR) "be</div>"
+ "</blockquote>"
+ HTML_SUFFIX,
+ "Credits:\n"
+ "> a very long text, which splits into multiple lines when this\n"
+ "> paragraph is not marked as preformatted, but as normal, as it should\n"
+ "> be\n")) {
+ g_test_fail ();
+ return;
+ }
+
+ if (!test_utils_process_commands (fixture,
+ "mode:html\n")) {
+ g_test_fail ();
+ return;
+ }
+
+ test_utils_insert_content (fixture,
+ "<blockquote type=\"cite\"><div>a very long text, which splits into multiple lines when this
paragraph is not marked as preformatted, but as normal, as it should be</div></blockquote>"
+ "<span class=\"-x-evo-to-body\" data-credits=\"Credits:\"></span>",
+ E_CONTENT_EDITOR_INSERT_REPLACE_ALL | E_CONTENT_EDITOR_INSERT_TEXT_HTML);
+
+ if (!test_utils_run_simple_test (fixture,
+ "seq:dd\n"
+ "action:wrap-lines\n",
+ HTML_PREFIX "<div>Credits:</div>"
+ "<blockquote type=\"cite\" " BLOCKQUOTE_STYLE ">"
+ "<div>a very long text, which splits into multiple lines when this paragraph<br>"
+ "is not marked as preformatted, but as normal, as it should be</div>"
+ "</blockquote>"
+ HTML_SUFFIX,
+ "Credits:\n"
+ "> a very long text, which splits into multiple lines when this paragraph\n"
+ "> is not marked as preformatted, but as normal, as it should be\n"))
g_test_fail ();
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]