-
• #301
-
• #302
Test
-
• #303
Test 2
1 Attachment
-
• #304
test
1 Attachment
-
• #305
test
1 Attachment
-
• #306
test
1 Attachment
-
• #307
-
• #308
awwww
-
• #309
.
-
• #310
-
• #311
test
1 Attachment
-
• #312
.
-
• #314
test
-
• #315
-
• #316
-
• #317
-
• #318
Come on Imgur. Work dammit!!!
-
• #319
.
-
• #320
.
-
• #321
test
1 Attachment
-
• #322
.
-
• #323
Test
-
• #324
Alright... thinking aloud:
core/templates/conversation.html has this JS at the bottom:
$('#post-a-reply-handle').on('click',function(e){ var selectedText = Comments.prototype.getWindowSelectedText(); if (selectedText){ replyBox.textarea.value = selectedText; replyBox.quote(); } });
Which then calls:
core/static/js/simpleEditor.jssimpleEditor.prototype.quote = function(){ this.textarea.value = this.formattedTextWith("> %s"); };
Which in turn calls (same file):
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 whatthis.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 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.
-
• #325