mirror of
https://github.com/ether/etherpad-lite.git
synced 2025-04-28 11:26:16 -04:00
much cleaner
This commit is contained in:
parent
1d1354e212
commit
add21368f9
2 changed files with 18 additions and 9 deletions
|
@ -187,6 +187,17 @@ AttributeManager.prototype = _(AttributeManager.prototype).extend({
|
||||||
getAttributeOnSelection: function(attributeName, prevChar){
|
getAttributeOnSelection: function(attributeName, prevChar){
|
||||||
var rep = this.rep;
|
var rep = this.rep;
|
||||||
if (!(rep.selStart && rep.selEnd)) return
|
if (!(rep.selStart && rep.selEnd)) return
|
||||||
|
// If we're looking for the caret attribute not the selection
|
||||||
|
// has the user already got a selection or is this purely a caret location?
|
||||||
|
var isNotSelection = (rep.selStart[0] == rep.selEnd[0] && rep.selEnd[1] === rep.selStart[1]);
|
||||||
|
if(isNotSelection){
|
||||||
|
if(prevChar){
|
||||||
|
// If it's not the start of the line
|
||||||
|
if(rep.selStart[1] !== 0){
|
||||||
|
rep.selStart[1]--;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
var withIt = Changeset.makeAttribsString('+', [
|
var withIt = Changeset.makeAttribsString('+', [
|
||||||
[attributeName, 'true']
|
[attributeName, 'true']
|
||||||
|
|
|
@ -2341,15 +2341,13 @@ function Ace2Inner(){
|
||||||
// prevChar tells the function if it needs to look at the previous character
|
// prevChar tells the function if it needs to look at the previous character
|
||||||
function getAttributeOnSelection(attributeName, prevChar){
|
function getAttributeOnSelection(attributeName, prevChar){
|
||||||
if (!(rep.selStart && rep.selEnd)) return
|
if (!(rep.selStart && rep.selEnd)) return
|
||||||
|
var isNotSelection = (rep.selStart[0] == rep.selEnd[0] && rep.selEnd[1] === rep.selStart[1]);
|
||||||
// If we're looking for the caret attribute not the selection
|
if(isNotSelection){
|
||||||
if(prevChar){
|
if(prevChar){
|
||||||
// If it's not the start of the line
|
// If it's not the start of the line
|
||||||
if(rep.selStart[1] !== 0){
|
if(rep.selStart[1] !== 0){
|
||||||
rep.selStart[1]--;
|
rep.selStart[1]--;
|
||||||
}else{
|
}
|
||||||
// It's the start of the line so look at the first character
|
|
||||||
rep.selEnd[1]++;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue