From 3d58a03a4dda90f2b6f17ba48657f39e1267e270 Mon Sep 17 00:00:00 2001 From: Bui Date: Tue, 30 Sep 2014 14:45:02 +0900 Subject: [PATCH] quote selected text on cite --- templates/main.js | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/templates/main.js b/templates/main.js index 9437c5ca..41d4cd27 100644 --- a/templates/main.js +++ b/templates/main.js @@ -214,6 +214,15 @@ function citeReply(id, with_link) { textarea.value += '>>' + id + '\n'; } if (typeof $ != 'undefined') { + var select = document.getSelection().toString(); + if (select) { + var body = $('#reply_' + id).find('div.body'); // TODO: support for OPs + var index = body.text().indexOf(select.replace('\n', '')); // for some reason this only works like this + if (index > -1) { + textarea.value += '>' + select + '\n'; + } + } + $(window).trigger('cite', [id, with_link]); $(textarea).change(); }