mirror of
https://github.com/Hopiu/fabric.js.git
synced 2026-05-05 12:24:46 +00:00
Add chaining to iText selection methods (#4178)
This commit is contained in:
parent
ddb9896455
commit
da27ef57c4
2 changed files with 10 additions and 0 deletions
|
|
@ -169,12 +169,15 @@
|
|||
|
||||
/**
|
||||
* Selects entire text
|
||||
* @return {fabric.IText} thisArg
|
||||
* @chainable
|
||||
*/
|
||||
selectAll: function() {
|
||||
this.selectionStart = 0;
|
||||
this.selectionEnd = this._text.length;
|
||||
this._fireSelectionChanged();
|
||||
this._updateTextarea();
|
||||
return this;
|
||||
},
|
||||
|
||||
/**
|
||||
|
|
@ -303,6 +306,8 @@
|
|||
/**
|
||||
* Selects a line based on the index
|
||||
* @param {Number} selectionStart Index of a character
|
||||
* @return {fabric.IText} thisArg
|
||||
* @chainable
|
||||
*/
|
||||
selectLine: function(selectionStart) {
|
||||
selectionStart = selectionStart || this.selectionStart;
|
||||
|
|
@ -313,6 +318,7 @@
|
|||
this.selectionEnd = newSelectionEnd;
|
||||
this._fireSelectionChanged();
|
||||
this._updateTextarea();
|
||||
return this;
|
||||
},
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -243,6 +243,8 @@
|
|||
iText.selectAll();
|
||||
equal(iText.selectionStart, 0);
|
||||
equal(iText.selectionEnd, 4);
|
||||
|
||||
equal(iText.selectAll(), iText, 'should be chainable');
|
||||
});
|
||||
|
||||
test('getSelectedText', function() {
|
||||
|
|
@ -506,6 +508,8 @@
|
|||
iText.selectLine(18);
|
||||
equal(iText.selectionStart, 17); // |qux|
|
||||
equal(iText.selectionEnd, 20);
|
||||
|
||||
equal(iText.selectLine(0), iText, 'should be chainable');
|
||||
});
|
||||
|
||||
test('findWordBoundaryLeft', function() {
|
||||
|
|
|
|||
Loading…
Reference in a new issue