You are reading a single comment by @branwen and its replies.
Click here to read the full conversation.
-
Quoting is still broken
The failure to quote links?
I think I have a solution to that having looked at the code yesterday.
It is doing this:
comments.prototype.getWindowSelectedText = function(){ var selection = window.getSelection(); if (selection && typeof selection.toString == 'function') { return selection.toString().replace(/\n/g, "\n> "); } return false; };
Note the
.toString()
in there.It would be better if it copied the HTML fragment.
Perhaps something along the lines of:
comments.prototype.getWindowSelectedHTML = function(){ var selection = window.getSelection(); if (selection && typeof selection.getRangeAt == 'function') { // Pull a balanced tree HTML fragment from the DOM for the given selection var range = selection.getRangeAt(0); var fragment = range.cloneContents(); // We only want core HTML and link attributes, almost every other attribute // can be jettisoned var walk = function(node,func) { func(node); node = node.firstChild; while(node) { walk(node,func); node = node.nextSibling; } }; var stripAttrs = function(node) { if (node.attributes) { var names = []; for (var i = 0; i < node.attributes.length; i++) { switch (node.attributes[i].name) { case "href": break; case "title": break; case "alt": break; default: name[names.length] = node.attributes[i].name; } } for (var i = 0; i < names.length; i++) { node.removeAttribute(names[i]); } } } walk(fragment, stripAttrs); return fragment; } return false; };
I wrote that blind... I've no idea whether it would work. I'm just guessing. I wish I had a JS developer around.
Quoting is still broken (#inb4tester)
But srs, glad that bit of it has been fixed