simpleEditor.prototype.formattedTextWith = function(tag){
var selection = this.getSelectionDetailsObject();
var newText = selection.start.text +
this.applyFormatting(selection.selected.text, tag) +
selection.end.text;
return newText;
};
And applyFormatting looks like:
simpleEditor.prototype.applyFormatting = function(text, tag){
// splits text into array by newlines and applies tag to each index of array.
var selectedTextFragments = text.split(/\n/g);
for(var i=0,j=selectedTextFragments.length;i<j;i++){
selectedTextFragments[i] = tag.replace(/%s/g, selectedTextFragments[i]);
}
var formattedText = selectedTextFragments.join('\n');
return formattedText;
};
I don't understand applyFormatting, and am not sure what this.getSelectionDetailsObject() returns.
Ah... getSelectionDetailsObject is a local this. reference, so that's in this file too:
simpleEditor.prototype.getSelectionDetailsObject = function(){
var text = this.textarea.value,
startPos = this.textarea.selectionStart,
endPos = this.textarea.selectionEnd,
selectedLength = this.textarea.selectionEnd-this.textarea.selectionStart;
var startText = text.substr(0,startPos),
selectedText = text.substr(startPos,selectedLength),
endText = text.substr(endPos,text.length);
var retval = {
start : {
position : startPos,
text : startText
},
end : {
position : endPos,
text : endText
},
selected : {
length : selectedLength,
text : selectedText
}
};
return retval;
};
I'll look into whether that does sane things later on.
As I don't understand applyFormatting in relation to quote I will probably seek to fix by just making another version of quote to be used for new messages as quote seems to work intra-message... and this only really has issues when the selection is outside of the text box.
Actually... maybe that's the bug... the selection is outside the textbox and so it gets confused as when quote is called there is no set of selection attributes on the textarea, which it looks like getSelectionDetailsObject needs.
Yeah... that's the bug.
Cool.
I'll think of the fix after the meeting and journey home.
Alright... thinking aloud:
core/templates/conversation.html has this JS at the bottom:
Which then calls:
core/static/js/simpleEditor.js
Which in turn calls (same file):
And
applyFormatting
looks like:I don't understand
applyFormatting
, and am not sure whatthis.getSelectionDetailsObject()
returns.Ah...
getSelectionDetailsObject
is a local this. reference, so that's in this file too:I'll look into whether that does sane things later on.
As I don't understand
applyFormatting
in relation toquote
I will probably seek to fix by just making another version of quote to be used for new messages as quote seems to work intra-message... and this only really has issues when the selection is outside of the text box.Actually... maybe that's the bug... the selection is outside the textbox and so it gets confused as when
quote
is called there is no set ofselection
attributes on the textarea, which it looks likegetSelectionDetailsObject
needs.Yeah... that's the bug.
Cool.
I'll think of the fix after the meeting and journey home.