Skip to content

Commit

Permalink
Merge pull request #1034 from summernote/feature/update-range-getword…
Browse files Browse the repository at this point in the history
…range

add hasFullElement parameter in range.getWordRange
  • Loading branch information
hackerwins committed Apr 24, 2015
2 parents 996faef + 1b2b9f2 commit 636e55e
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/js/core/range.js
Original file line number Diff line number Diff line change
Expand Up @@ -516,9 +516,10 @@ define([
/**
* returns range for word before cursor
*
* @param {Boolean} hasFullElement get range for full element at current cursor
* @return {WrappedRange}
*/
this.getWordRange = function () {
this.getWordRange = function (hasFullElement) {
var endPoint = this.getEndPoint();

if (!dom.isCharPoint(endPoint)) {
Expand All @@ -529,6 +530,12 @@ define([
return !dom.isCharPoint(point);
});

if (hasFullElement) {
endPoint = dom.nextPointUntil(endPoint, function (point) {
return !dom.isCharPoint(point);
});
}

return new WrappedRange(
startPoint.node,
startPoint.offset,
Expand Down

0 comments on commit 636e55e

Please sign in to comment.