diff --git a/builder/build.js b/builder/build.js
index 656a7049..3a1825b6 100644
--- a/builder/build.js
+++ b/builder/build.js
@@ -118,14 +118,14 @@ function getVersion() {
console.log("Getting version from Git repo");
exec("git describe", function(error, stdout, stderr) {
console.log(error, stdout, stderr);
- console.log("Getting version from package.json");
buildVersion = JSON.parse( fs.readFileSync("package.json")).version;
+ console.log("Got version " + buildVersion + " from package.json");
zipDir = buildDir + "rangy-" + buildVersion + "/";
fs.mkdirSync(zipDir);
uncompressedBuildDir = zipDir + "uncompressed/";
fs.mkdirSync(uncompressedBuildDir);
- console.log("Got git version " + stdout);
+ console.log("Got git version " + stdout + " but not using that");
callback();
});
}
diff --git a/demos/highlighter.html b/demos/highlighter.html
index b34c80c9..aa12c5b1 100644
--- a/demos/highlighter.html
+++ b/demos/highlighter.html
@@ -11,7 +11,7 @@
.note {
background-color: limegreen;
}
-
+
#summary {
border: dotted orange 1px;
}
diff --git a/fiddlings/browserify/test.html b/fiddlings/browserify/test.html
index 49483fd7..21827a90 100644
--- a/fiddlings/browserify/test.html
+++ b/fiddlings/browserify/test.html
@@ -3,6 +3,12 @@
+
diff --git a/roadmap.txt b/roadmap.txt
index dff21a2c..3e333fae 100644
--- a/roadmap.txt
+++ b/roadmap.txt
@@ -29,6 +29,8 @@
- [ ] Add withinRange and withinNode options to move(), moveStart() and moveEnd() methods
- [?] Positions module
(http://stackoverflow.com/questions/4122315/how-to-find-xy-position-in-javascript-with-offset/4123495#4123495)
+- [ ] Config module or something so that config can work with AMD. See P" 285
+ (https://github.com/timdown/rangy/pull/285)
Possible features for some version
----------------------------------
@@ -37,3 +39,4 @@ Possible features for some version
(http://stackoverflow.com/questions/2887101/apply-style-to-range-of-text-with-javascript-in-uiwebview/2888969#2888969)
- [?] More commands (block? Insert line break? Think about this, don't want to build a WYSIWYG editor)
- [ ] Add selection extend()? Don't think this is possible.
+- [ ] Option in TextRange module for alternative ways to extract text for an element (see email from Bruce Augustine)
diff --git a/test/rangetests.js b/test/rangetests.js
index 1a2a709e..e611dd68 100644
--- a/test/rangetests.js
+++ b/test/rangetests.js
@@ -301,6 +301,19 @@ function testRangeCreator(docs, docName, rangeCreator, rangeCreatorName) {
});
s.test("extractContents in single text node", function(t) {
+ var range = rangeCreator(doc);
+ t.nodes.div.innerHTML = "1 2 3 4 5
";
+ var p = t.nodes.div.firstChild;
+ range.setStart(p.firstChild, 2);
+ range.setEnd(p.lastChild, 2);
+ var frag = range.extractContents();
+ var container = doc.createElement("div");
+ container.appendChild(frag);
+ t.assertEquals(container.innerHTML, "2 3 4");
+ t.assertEquals(t.nodes.div.innerHTML, "1 5
");
+ });
+
+ s.test("extractContents inside paragraph (issue 163)", function(t) {
var range = rangeCreator(doc);
range.setStart(t.nodes.plainText, 1);
range.setEnd(t.nodes.plainText, 2);
diff --git a/test/textrangetests.js b/test/textrangetests.js
index f7120268..60e0000a 100644
--- a/test/textrangetests.js
+++ b/test/textrangetests.js
@@ -495,34 +495,38 @@ xn.test.suite("Text Range module tests", function(s) {
t.assertEquals(range.startOffset, 0);
});
+ function visibleSpaces(str) {
+ return str.replace(/\n/g, "\\n").replace(/\r/g, "\\r").replace(/\s/g, function(m) { return "[" + m.charCodeAt(0) + "]"; });
+ }
+
s.test("innerText on br inside block 1", function(t) {
t.el.innerHTML = '
';
- t.assertEquals(rangy.innerText(t.el).replace(/\n/g, "\\n"), "\\n");
+ t.assertEquals(visibleSpaces( rangy.innerText(t.el) ), "\\n");
});
s.test("innerText on br inside block 2", function(t) {
t.el.innerHTML = '';
- t.assertEquals(rangy.innerText(t.el).replace(/\n/g, "\\n"), "x\\n");
+ t.assertEquals(visibleSpaces( rangy.innerText(t.el) ), "x\\n");
});
s.test("innerText on br inside block 3", function(t) {
t.el.innerHTML = 'z';
- t.assertEquals(rangy.innerText(t.el).replace(/\n/g, "\\n"), "x\\ny\\nz");
+ t.assertEquals(visibleSpaces( rangy.innerText(t.el) ), "x\\ny\\nz");
});
s.test("innerText on br inside block 4", function(t) {
t.el.innerHTML = 'z';
- t.assertEquals(rangy.innerText(t.el).replace(/\n/g, "\\n"), "x\\ny\\nz");
+ t.assertEquals(visibleSpaces( rangy.innerText(t.el) ), "x\\ny\\nz");
});
s.test("innerText on br inside block 5", function(t) {
t.el.innerHTML = 'x
';
- t.assertEquals(rangy.innerText(t.el).replace(/\n/g, "\\n"), "x\\n\\n");
+ t.assertEquals(visibleSpaces( rangy.innerText(t.el) ), "x\\n\\n");
});
s.test("innerText on br inside block 6", function(t) {
t.el.innerHTML = '';
- t.assertEquals(rangy.innerText(t.el).replace(/\n/g, "\\n"), "\\n");
+ t.assertEquals(visibleSpaces( rangy.innerText(t.el) ), "\\n");
});
@@ -1257,4 +1261,54 @@ xn.test.suite("Text Range module tests", function(s) {
t.assertEquals(charRange.start, 2);
t.assertEquals(charRange.end, 2);
});
+
+ s.test("Issue 304", function(t) {
+/*
+ t.el.innerHTML = "1 2";
+ t.assertEquals(visibleSpaces(rangy.innerText(t.el)), visibleSpaces("1 2") );
+*/
+
+ t.el.innerHTML = "X Y";
+ t.assertEquals(visibleSpaces(rangy.innerText(t.el)), visibleSpaces("X Y") );
+
+/*
+ t.el.innerHTML = ["female",
+ " presents to the ED with a Chief Complaint of ",
+ " Shoulder Pain"].join("\n");
+
+ t.assertEquals(visibleSpaces(rangy.innerText(t.el)), visibleSpaces("female presents to the ED with a Chief Complaint of Shoulder Pain") );
+*/
+ });
+
+ s.test("Paragraphs test (issue 128)", function(t) {
+ t.el.innerHTML = "\n a
\n a
\n";
+ var p = t.el.getElementsByTagName("p")[1];
+ var range = rangy.createRange();
+ range.setStartAndEnd(p.firstChild, 0, 1);
+ var charRange = range.toCharacterRange(t.el);
+ t.assertEquals(charRange.start, 2);
+ t.assertEquals(charRange.end, 3);
+
+ var sel = rangy.getSelection();
+ sel.selectAllChildren(p);
+ charRange = sel.getRangeAt(0).toCharacterRange(t.el);
+ t.assertEquals(charRange.start, 2);
+ t.assertEquals(charRange.end, 3);
+ });
+
+ s.test("Word iterator test (issue 130)", function(t) {
+ t.el.innerHTML = "Hello . . Goodbye";
+ var it = rangy.createWordIterator(t.el, 0);
+ var word, words = [];
+ while ( (word = it.next()) ) {
+ if (!rangy.dom.isOrIsAncestorOf(t.el, word.chars[0].node)) {
+ break;
+ }
+ if (word.isWord) {
+ words.push(word.toString());
+ }
+ }
+ t.assertArraysEquivalent(words, ["Hello", "Goodbye"]);
+ });
+
}, false);