allow any Range-like objects in session replace/remove

This commit is contained in:
nightwing 2013-08-26 18:37:50 +04:00
commit b23265ad72

View file

@ -402,6 +402,8 @@ var Document = function(text) {
*
**/
this.remove = function(range) {
if (!range instanceof Range)
range = Range.fromPoints(range.start, range.end);
// clip to document
range.start = this.$clipPosition(range.start);
range.end = this.$clipPosition(range.end);
@ -520,6 +522,8 @@ var Document = function(text) {
*
**/
this.replace = function(range, text) {
if (!range instanceof Range)
range = Range.fromPoints(range.start, range.end);
if (text.length == 0 && range.isEmpty())
return range.start;