corinthia-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pmke...@apache.org
Subject incubator-corinthia git commit: Avoid nesting when inserting footnotes or endnotes
Date Thu, 19 Feb 2015 11:36:15 GMT
Repository: incubator-corinthia
Updated Branches:
  refs/heads/master c2ab40b29 -> 0c34c1a97


Avoid nesting when inserting footnotes or endnotes

If the user tries to insert a footnote or endnote while the cursor is
already inside a node, place the new footnote or endnote *after* it, not
inside.


Project: http://git-wip-us.apache.org/repos/asf/incubator-corinthia/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-corinthia/commit/0c34c1a9
Tree: http://git-wip-us.apache.org/repos/asf/incubator-corinthia/tree/0c34c1a9
Diff: http://git-wip-us.apache.org/repos/asf/incubator-corinthia/diff/0c34c1a9

Branch: refs/heads/master
Commit: 0c34c1a972049c0029c3b70e3d620445df63e814
Parents: c2ab40b
Author: Peter Kelly <peter@uxproductivity.com>
Authored: Thu Feb 19 18:34:26 2015 +0700
Committer: Peter Kelly <peter@uxproductivity.com>
Committed: Thu Feb 19 18:34:26 2015 +0700

----------------------------------------------------------------------
 Editor/src/Cursor.js                               | 17 +++++++++++++++++
 Editor/tests/cursor/insertEndnote07-expected.html  | 11 +++++++++++
 Editor/tests/cursor/insertEndnote07-input.html     | 15 +++++++++++++++
 Editor/tests/cursor/insertEndnote08-expected.html  | 11 +++++++++++
 Editor/tests/cursor/insertEndnote08-input.html     | 15 +++++++++++++++
 Editor/tests/cursor/insertEndnote09-expected.html  | 11 +++++++++++
 Editor/tests/cursor/insertEndnote09-input.html     | 15 +++++++++++++++
 Editor/tests/cursor/insertFootnote07-expected.html | 11 +++++++++++
 Editor/tests/cursor/insertFootnote07-input.html    | 15 +++++++++++++++
 Editor/tests/cursor/insertFootnote08-expected.html | 11 +++++++++++
 Editor/tests/cursor/insertFootnote08-input.html    | 15 +++++++++++++++
 Editor/tests/cursor/insertFootnote09-expected.html | 11 +++++++++++
 Editor/tests/cursor/insertFootnote09-input.html    | 15 +++++++++++++++
 Editor/tests/index.js                              |  6 ++++++
 14 files changed, 179 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-corinthia/blob/0c34c1a9/Editor/src/Cursor.js
----------------------------------------------------------------------
diff --git a/Editor/src/Cursor.js b/Editor/src/Cursor.js
index 3ef60cc..a545477 100644
--- a/Editor/src/Cursor.js
+++ b/Editor/src/Cursor.js
@@ -908,6 +908,22 @@ var Cursor_insertEndnote;
             cursorX = null;
     }
 
+    function moveRangeOutsideOfNote(range)
+    {
+        var node = range.start.node;
+        var offset = range.start.offset;
+
+        for (var anc = node; anc != null; anc = anc.parentNode) {
+            if (isNoteNode(anc) && (anc.parentNode != null)) {
+                node = anc.parentNode;
+                offset = DOM_nodeOffset(anc)+1;
+                return new Range(node,offset,node,offset);
+            }
+        }
+
+        return range;
+    }
+
     function insertNote(className,content)
     {
         var footnote = DOM_createElement(document,"span");
@@ -915,6 +931,7 @@ var Cursor_insertEndnote;
         DOM_appendChild(footnote,DOM_createTextNode(document,content));
 
         var range = Selection_get();
+        range = moveRangeOutsideOfNote(range);
         Formatting_splitAroundSelection(range,false);
 
         var pos = Position_preferElementPosition(range.start);

http://git-wip-us.apache.org/repos/asf/incubator-corinthia/blob/0c34c1a9/Editor/tests/cursor/insertEndnote07-expected.html
----------------------------------------------------------------------
diff --git a/Editor/tests/cursor/insertEndnote07-expected.html b/Editor/tests/cursor/insertEndnote07-expected.html
new file mode 100644
index 0000000..8b3f2f0
--- /dev/null
+++ b/Editor/tests/cursor/insertEndnote07-expected.html
@@ -0,0 +1,11 @@
+<html>
+  <head></head>
+  <body>
+    <p>
+      before
+      <span class="endnote">inside</span>
+      <span class="endnote">[Endnote content]</span>
+      after
+    </p>
+  </body>
+</html>

http://git-wip-us.apache.org/repos/asf/incubator-corinthia/blob/0c34c1a9/Editor/tests/cursor/insertEndnote07-input.html
----------------------------------------------------------------------
diff --git a/Editor/tests/cursor/insertEndnote07-input.html b/Editor/tests/cursor/insertEndnote07-input.html
new file mode 100644
index 0000000..77c4adc
--- /dev/null
+++ b/Editor/tests/cursor/insertEndnote07-input.html
@@ -0,0 +1,15 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script>
+function performTest()
+{
+    Cursor_insertEndnote("Endnote content");
+    showSelection();
+}
+</script>
+</head>
+<body>
+  <p>before <span class="endnote">ins[]ide</span>after</p>
+</body>
+</html>

http://git-wip-us.apache.org/repos/asf/incubator-corinthia/blob/0c34c1a9/Editor/tests/cursor/insertEndnote08-expected.html
----------------------------------------------------------------------
diff --git a/Editor/tests/cursor/insertEndnote08-expected.html b/Editor/tests/cursor/insertEndnote08-expected.html
new file mode 100644
index 0000000..8b3f2f0
--- /dev/null
+++ b/Editor/tests/cursor/insertEndnote08-expected.html
@@ -0,0 +1,11 @@
+<html>
+  <head></head>
+  <body>
+    <p>
+      before
+      <span class="endnote">inside</span>
+      <span class="endnote">[Endnote content]</span>
+      after
+    </p>
+  </body>
+</html>

http://git-wip-us.apache.org/repos/asf/incubator-corinthia/blob/0c34c1a9/Editor/tests/cursor/insertEndnote08-input.html
----------------------------------------------------------------------
diff --git a/Editor/tests/cursor/insertEndnote08-input.html b/Editor/tests/cursor/insertEndnote08-input.html
new file mode 100644
index 0000000..fab5957
--- /dev/null
+++ b/Editor/tests/cursor/insertEndnote08-input.html
@@ -0,0 +1,15 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script>
+function performTest()
+{
+    Cursor_insertEndnote("Endnote content");
+    showSelection();
+}
+</script>
+</head>
+<body>
+  <p>before <span class="endnote">inside[]</span>after</p>
+</body>
+</html>

http://git-wip-us.apache.org/repos/asf/incubator-corinthia/blob/0c34c1a9/Editor/tests/cursor/insertEndnote09-expected.html
----------------------------------------------------------------------
diff --git a/Editor/tests/cursor/insertEndnote09-expected.html b/Editor/tests/cursor/insertEndnote09-expected.html
new file mode 100644
index 0000000..8b3f2f0
--- /dev/null
+++ b/Editor/tests/cursor/insertEndnote09-expected.html
@@ -0,0 +1,11 @@
+<html>
+  <head></head>
+  <body>
+    <p>
+      before
+      <span class="endnote">inside</span>
+      <span class="endnote">[Endnote content]</span>
+      after
+    </p>
+  </body>
+</html>

http://git-wip-us.apache.org/repos/asf/incubator-corinthia/blob/0c34c1a9/Editor/tests/cursor/insertEndnote09-input.html
----------------------------------------------------------------------
diff --git a/Editor/tests/cursor/insertEndnote09-input.html b/Editor/tests/cursor/insertEndnote09-input.html
new file mode 100644
index 0000000..06dd1f6
--- /dev/null
+++ b/Editor/tests/cursor/insertEndnote09-input.html
@@ -0,0 +1,15 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script>
+function performTest()
+{
+    Cursor_insertEndnote("Endnote content");
+    showSelection();
+}
+</script>
+</head>
+<body>
+  <p>before <span class="endnote">[]inside</span>after</p>
+</body>
+</html>

http://git-wip-us.apache.org/repos/asf/incubator-corinthia/blob/0c34c1a9/Editor/tests/cursor/insertFootnote07-expected.html
----------------------------------------------------------------------
diff --git a/Editor/tests/cursor/insertFootnote07-expected.html b/Editor/tests/cursor/insertFootnote07-expected.html
new file mode 100644
index 0000000..70fa0f7
--- /dev/null
+++ b/Editor/tests/cursor/insertFootnote07-expected.html
@@ -0,0 +1,11 @@
+<html>
+  <head></head>
+  <body>
+    <p>
+      before
+      <span class="footnote">inside</span>
+      <span class="footnote">[Footnote content]</span>
+      after
+    </p>
+  </body>
+</html>

http://git-wip-us.apache.org/repos/asf/incubator-corinthia/blob/0c34c1a9/Editor/tests/cursor/insertFootnote07-input.html
----------------------------------------------------------------------
diff --git a/Editor/tests/cursor/insertFootnote07-input.html b/Editor/tests/cursor/insertFootnote07-input.html
new file mode 100644
index 0000000..161adc8
--- /dev/null
+++ b/Editor/tests/cursor/insertFootnote07-input.html
@@ -0,0 +1,15 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script>
+function performTest()
+{
+    Cursor_insertFootnote("Footnote content");
+    showSelection();
+}
+</script>
+</head>
+<body>
+  <p>before <span class="footnote">ins[]ide</span>after</p>
+</body>
+</html>

http://git-wip-us.apache.org/repos/asf/incubator-corinthia/blob/0c34c1a9/Editor/tests/cursor/insertFootnote08-expected.html
----------------------------------------------------------------------
diff --git a/Editor/tests/cursor/insertFootnote08-expected.html b/Editor/tests/cursor/insertFootnote08-expected.html
new file mode 100644
index 0000000..70fa0f7
--- /dev/null
+++ b/Editor/tests/cursor/insertFootnote08-expected.html
@@ -0,0 +1,11 @@
+<html>
+  <head></head>
+  <body>
+    <p>
+      before
+      <span class="footnote">inside</span>
+      <span class="footnote">[Footnote content]</span>
+      after
+    </p>
+  </body>
+</html>

http://git-wip-us.apache.org/repos/asf/incubator-corinthia/blob/0c34c1a9/Editor/tests/cursor/insertFootnote08-input.html
----------------------------------------------------------------------
diff --git a/Editor/tests/cursor/insertFootnote08-input.html b/Editor/tests/cursor/insertFootnote08-input.html
new file mode 100644
index 0000000..b159a66
--- /dev/null
+++ b/Editor/tests/cursor/insertFootnote08-input.html
@@ -0,0 +1,15 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script>
+function performTest()
+{
+    Cursor_insertFootnote("Footnote content");
+    showSelection();
+}
+</script>
+</head>
+<body>
+  <p>before <span class="footnote">inside[]</span>after</p>
+</body>
+</html>

http://git-wip-us.apache.org/repos/asf/incubator-corinthia/blob/0c34c1a9/Editor/tests/cursor/insertFootnote09-expected.html
----------------------------------------------------------------------
diff --git a/Editor/tests/cursor/insertFootnote09-expected.html b/Editor/tests/cursor/insertFootnote09-expected.html
new file mode 100644
index 0000000..70fa0f7
--- /dev/null
+++ b/Editor/tests/cursor/insertFootnote09-expected.html
@@ -0,0 +1,11 @@
+<html>
+  <head></head>
+  <body>
+    <p>
+      before
+      <span class="footnote">inside</span>
+      <span class="footnote">[Footnote content]</span>
+      after
+    </p>
+  </body>
+</html>

http://git-wip-us.apache.org/repos/asf/incubator-corinthia/blob/0c34c1a9/Editor/tests/cursor/insertFootnote09-input.html
----------------------------------------------------------------------
diff --git a/Editor/tests/cursor/insertFootnote09-input.html b/Editor/tests/cursor/insertFootnote09-input.html
new file mode 100644
index 0000000..136b643
--- /dev/null
+++ b/Editor/tests/cursor/insertFootnote09-input.html
@@ -0,0 +1,15 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script>
+function performTest()
+{
+    Cursor_insertFootnote("Footnote content");
+    showSelection();
+}
+</script>
+</head>
+<body>
+  <p>before <span class="footnote">[]inside</span>after</p>
+</body>
+</html>

http://git-wip-us.apache.org/repos/asf/incubator-corinthia/blob/0c34c1a9/Editor/tests/index.js
----------------------------------------------------------------------
diff --git a/Editor/tests/index.js b/Editor/tests/index.js
index d0608f9..b0dedac 100644
--- a/Editor/tests/index.js
+++ b/Editor/tests/index.js
@@ -580,12 +580,18 @@ var tests = [
             "insertEndnote04",
             "insertEndnote05",
             "insertEndnote06",
+            "insertEndnote07",
+            "insertEndnote08",
+            "insertEndnote09",
             "insertFootnote01",
             "insertFootnote02",
             "insertFootnote03",
             "insertFootnote04",
             "insertFootnote05",
             "insertFootnote06",
+            "insertFootnote07",
+            "insertFootnote08",
+            "insertFootnote09",
             "makeContainerInsertionPoint01",
             "makeContainerInsertionPoint02a",
             "makeContainerInsertionPoint02b",


Mime
View raw message