Skip to content

Commit b01bb7c

Browse files
author
Tim
committed
Updated lib
1 parent a45fdc2 commit b01bb7c

6 files changed

+62
-44
lines changed

lib/rangy-classapplier.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@
99
*
1010
* Copyright 2014, Tim Down
1111
* Licensed under the MIT license.
12-
* Version: 1.3.0-alpha.20140822.2
13-
* Build date: 22 August 2014
12+
* Version: 1.3.0-alpha.20140825
13+
* Build date: 25 August 2014
1414
*/
1515
(function(factory, global) {
1616
if (typeof define == "function" && define.amd) {
@@ -1007,4 +1007,4 @@
10071007
api.createCssClassApplier = api.createClassApplier = createClassApplier;
10081008
});
10091009

1010-
}, this);
1010+
}, /* Ridiculous nonsense to get the global object in any environment follows */(function(f) { return f('return this;')(); })(Function));

lib/rangy-core.js

+10-6
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
*
55
* Copyright 2014, Tim Down
66
* Licensed under the MIT license.
7-
* Version: 1.3.0-alpha.20140822.2
8-
* Build date: 22 August 2014
7+
* Version: 1.3.0-alpha.20140825
8+
* Build date: 25 August 2014
99
*/
1010

1111
(function(factory, global) {
@@ -98,7 +98,7 @@
9898
};
9999

100100
var api = {
101-
version: "1.3.0-alpha.20140822.2",
101+
version: "1.3.0-alpha.20140825",
102102
initialized: false,
103103
isBrowser: isBrowser,
104104
supported: true,
@@ -2311,7 +2311,7 @@
23112311

23122312
/*--------------------------------------------------------------------------------------------------------*/
23132313

2314-
// Test for IE 9 deleteContents() and extractContents() bug and correct it. See issue 107.
2314+
// Test for IE deleteContents() and extractContents() bug and correct it. See issue 107.
23152315

23162316
var el = document.createElement("div");
23172317
el.innerHTML = "123";
@@ -3205,7 +3205,11 @@
32053205
// Clone the native range so that changing the selected range does not affect the selection.
32063206
// This is contrary to the spec but is the only way to achieve consistency between browsers. See
32073207
// issue 80.
3208-
this.nativeSelection.addRange(getNativeRange(range).cloneRange());
3208+
var clonedNativeRange = getNativeRange(range).cloneRange();
3209+
try {
3210+
this.nativeSelection.addRange(clonedNativeRange);
3211+
} catch (ex) {
3212+
}
32093213

32103214
// Check whether adding the range was successful
32113215
this.rangeCount = this.nativeSelection.rangeCount;
@@ -3745,4 +3749,4 @@
37453749
}
37463750

37473751
return api;
3748-
}, this);
3752+
}, /* Ridiculous nonsense to get the global object in any environment follows */(function(f) { return f('return this;')(); })(Function));

lib/rangy-highlighter.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
*
77
* Copyright 2014, Tim Down
88
* Licensed under the MIT license.
9-
* Version: 1.3.0-alpha.20140822.2
10-
* Build date: 22 August 2014
9+
* Version: 1.3.0-alpha.20140825
10+
* Build date: 25 August 2014
1111
*/
1212
(function(factory, global) {
1313
if (typeof define == "function" && define.amd) {
@@ -598,4 +598,4 @@
598598
};
599599
});
600600

601-
}, this);
601+
}, /* Ridiculous nonsense to get the global object in any environment follows */(function(f) { return f('return this;')(); })(Function));

lib/rangy-selectionsaverestore.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@
99
*
1010
* Copyright 2014, Tim Down
1111
* Licensed under the MIT license.
12-
* Version: 1.3.0-alpha.20140822.2
13-
* Build date: 22 August 2014
12+
* Version: 1.3.0-alpha.20140825
13+
* Build date: 25 August 2014
1414
*/
1515
(function(factory, global) {
1616
if (typeof define == "function" && define.amd) {
@@ -245,4 +245,4 @@
245245
});
246246
});
247247

248-
}, this);
248+
}, /* Ridiculous nonsense to get the global object in any environment follows */(function(f) { return f('return this;')(); })(Function));

lib/rangy-serializer.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@
1010
*
1111
* Copyright 2014, Tim Down
1212
* Licensed under the MIT license.
13-
* Version: 1.3.0-alpha.20140822.2
14-
* Build date: 22 August 2014
13+
* Version: 1.3.0-alpha.20140825
14+
* Build date: 25 August 2014
1515
*/
1616
(function(factory, global) {
1717
if (typeof define == "function" && define.amd) {
@@ -309,4 +309,4 @@
309309
api.nodeToInfoString = nodeToInfoString;
310310
});
311311

312-
}, this);
312+
}, /* Ridiculous nonsense to get the global object in any environment follows */(function(f) { return f('return this;')(); })(Function));

lib/rangy-textrange.js

+40-26
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@
2626
*
2727
* Copyright 2014, Tim Down
2828
* Licensed under the MIT license.
29-
* Version: 1.3.0-alpha.20140822.2
30-
* Build date: 22 August 2014
29+
* Version: 1.3.0-alpha.20140825
30+
* Build date: 25 August 2014
3131
*/
3232

3333
/**
@@ -182,8 +182,23 @@
182182
includeBlockContentTrailingSpace: true,
183183
includeSpaceBeforeBr: true,
184184
includeSpaceBeforeBlock: true,
185-
includePreLineTrailingSpace: true
185+
includePreLineTrailingSpace: true,
186+
ignoreCharacters: ""
186187
};
188+
189+
function normalizeIgnoredCharacters(ignoredCharacters) {
190+
// Check if character is ignored
191+
var ignoredChars = ignoredCharacters || "";
192+
193+
// Normalize ignored characters into a string consisting of characters in ascending order of character code
194+
var ignoredCharsArray = (typeof ignoredChars == "string") ? ignoredChars.split("") : ignoredChars;
195+
ignoredCharsArray.sort(function(char1, char2) {
196+
return char1.charCodeAt(0) - char2.charCodeAt(0);
197+
});
198+
199+
/// Convert back to a string and remove duplicates
200+
return ignoredCharsArray.join("").replace(/(.)\1+/g, "$1");
201+
}
187202

188203
var defaultCaretCharacterOptions = {
189204
includeBlockContentTrailingSpace: !trailingSpaceBeforeLineBreakInPreLineCollapses,
@@ -491,12 +506,6 @@
491506
}
492507
};
493508
}
494-
495-
/*
496-
api.report = function() {
497-
console.log("Cached: " + cachedCount + ", uncached: " + uncachedCount);
498-
};
499-
*/
500509

501510
/*----------------------------------------------------------------------------------------------------------------*/
502511

@@ -813,13 +822,20 @@
813822
getCharacter: function(characterOptions) {
814823
this.resolveLeadingAndTrailingSpaces();
815824

825+
var thisChar = this.character, returnChar;
826+
827+
// Check if character is ignored
828+
var ignoredChars = normalizeIgnoredCharacters(characterOptions.ignoreCharacters);
829+
var isIgnoredCharacter = (thisChar !== "" && ignoredChars.indexOf(thisChar) > -1);
830+
816831
// Check if this position's character is invariant (i.e. not dependent on character options) and return it
817832
// if so
818833
if (this.isCharInvariant) {
819-
return this.character;
834+
returnChar = isIgnoredCharacter ? "" : thisChar;
835+
return returnChar;
820836
}
821837

822-
var cacheKey = ["character", characterOptions.includeSpaceBeforeBr, characterOptions.includeBlockContentTrailingSpace, characterOptions.includePreLineTrailingSpace].join("_");
838+
var cacheKey = ["character", characterOptions.includeSpaceBeforeBr, characterOptions.includeBlockContentTrailingSpace, characterOptions.includePreLineTrailingSpace, ignoredChars].join("_");
823839
var cachedChar = this.cache.get(cacheKey);
824840
if (cachedChar !== null) {
825841
return cachedChar;
@@ -829,7 +845,7 @@
829845
var character = "";
830846
var collapsible = (this.characterType == COLLAPSIBLE_SPACE);
831847

832-
var nextPos, previousPos/* = this.getPrecedingUncollapsedPosition(characterOptions)*/;
848+
var nextPos, previousPos;
833849
var gotPreviousPos = false;
834850
var pos = this;
835851

@@ -844,11 +860,11 @@
844860
// Disallow a collapsible space that is followed by a line break or is the last character
845861
if (collapsible) {
846862
// Disallow a collapsible space that follows a trailing space or line break, or is the first character
847-
if (this.character == " " &&
863+
if (thisChar == " " &&
848864
(!getPreviousPos() || previousPos.isTrailingSpace || previousPos.character == "\n")) {
849865
}
850866
// Allow a leading line break unless it follows a line break
851-
else if (this.character == "\n" && this.isLeadingSpace) {
867+
else if (thisChar == "\n" && this.isLeadingSpace) {
852868
if (getPreviousPos() && previousPos.character != "\n") {
853869
character = "\n";
854870
} else {
@@ -864,12 +880,12 @@
864880
this.type = TRAILING_SPACE_BEFORE_BLOCK;
865881
}
866882

867-
if (nextPos.character === "\n") {
883+
if (nextPos.character == "\n") {
868884
if (this.type == TRAILING_SPACE_BEFORE_BR && !characterOptions.includeSpaceBeforeBr) {
869885
} else if (this.type == TRAILING_SPACE_BEFORE_BLOCK && !characterOptions.includeSpaceBeforeBlock) {
870886
} else if (this.type == TRAILING_SPACE_IN_BLOCK && nextPos.isTrailingSpace && !characterOptions.includeBlockContentTrailingSpace) {
871887
} else if (this.type == PRE_LINE_TRAILING_SPACE_BEFORE_LINE_BREAK && nextPos.type == NON_SPACE && !characterOptions.includePreLineTrailingSpace) {
872-
} else if (this.character === "\n") {
888+
} else if (thisChar == "\n") {
873889
if (nextPos.isTrailingSpace) {
874890
if (this.isTrailingSpace) {
875891
} else if (this.isBr) {
@@ -878,34 +894,32 @@
878894
if (getPreviousPos() && previousPos.isLeadingSpace && previousPos.character == "\n") {
879895
nextPos.character = "";
880896
} else {
881-
//character = "\n";
882-
//nextPos
883-
/*
884-
nextPos.character = "";
885-
character = "\n";
886-
*/
887897
}
888898
}
889899
} else {
890900
character = "\n";
891901
}
892-
} else if (this.character === " ") {
902+
} else if (thisChar == " ") {
893903
character = " ";
894904
} else {
895905
}
896906
} else {
897-
character = this.character;
907+
character = thisChar;
898908
}
899909
} else {
900910
}
901911
}
902912
}
903913

904914
// Collapse a br element that is followed by a trailing space
905-
else if (this.character === "\n" &&
915+
else if (thisChar == "\n" &&
906916
(!(nextPos = this.nextUncollapsed()) || nextPos.isTrailingSpace)) {
907917
}
908918

919+
if (ignoredChars.indexOf(character) > -1) {
920+
character = "";
921+
}
922+
909923

910924
this.cache.set(cacheKey, character);
911925

@@ -1917,4 +1931,4 @@
19171931
};
19181932
});
19191933

1920-
}, this);
1934+
}, /* Ridiculous nonsense to get the global object in any environment follows */(function(f) { return f('return this;')(); })(Function));

0 commit comments

Comments
 (0)