add editor getSelectedText method
This commit is contained in:
parent
a44cbdc5c2
commit
3b5d742feb
2 changed files with 12 additions and 14 deletions
|
|
@ -739,25 +739,24 @@ var Editor = function(renderer, session) {
|
||||||
this.renderer.updateFull();
|
this.renderer.updateFull();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the string of text currently highlighted.
|
||||||
|
* @returns {String}
|
||||||
|
**/
|
||||||
|
this.getSelectedText = function() {
|
||||||
|
return this.session.getTextRange(this.getSelectionRange());
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Emitted when text is copied.
|
* Emitted when text is copied.
|
||||||
* @event copy
|
* @event copy
|
||||||
* @param {String} text The copied text
|
* @param {String} text The copied text
|
||||||
*
|
*
|
||||||
*
|
|
||||||
**/
|
**/
|
||||||
/**
|
|
||||||
*
|
|
||||||
* Returns the string of text currently highlighted.
|
|
||||||
* @returns {String}
|
|
||||||
**/
|
|
||||||
|
|
||||||
this.getCopyText = function() {
|
this.getCopyText = function() {
|
||||||
var text = "";
|
var text = this.getSelectedText();
|
||||||
if (!this.selection.isEmpty())
|
this._signal("copy", text);
|
||||||
text = this.session.getTextRange(this.getSelectionRange());
|
|
||||||
|
|
||||||
this._emit("copy", text);
|
|
||||||
return text;
|
return text;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -519,7 +519,7 @@ var Editor = require("./editor").Editor;
|
||||||
this.multiSelect.toSingleRange();
|
this.multiSelect.toSingleRange();
|
||||||
};
|
};
|
||||||
|
|
||||||
this.getCopyText = function() {
|
this.getSelectedText = function() {
|
||||||
var text = "";
|
var text = "";
|
||||||
if (this.inMultiSelectMode && !this.inVirtualSelectionMode) {
|
if (this.inMultiSelectMode && !this.inVirtualSelectionMode) {
|
||||||
var ranges = this.multiSelect.rangeList.ranges;
|
var ranges = this.multiSelect.rangeList.ranges;
|
||||||
|
|
@ -534,7 +534,6 @@ var Editor = require("./editor").Editor;
|
||||||
} else if (!this.selection.isEmpty()) {
|
} else if (!this.selection.isEmpty()) {
|
||||||
text = this.session.getTextRange(this.getSelectionRange());
|
text = this.session.getTextRange(this.getSelectionRange());
|
||||||
}
|
}
|
||||||
this._signal("copy", text);
|
|
||||||
return text;
|
return text;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue