Node.js based forum software built for the modern web
when clicking the reply button, limit the selection to the post's content.
Ben Lubarc50f228accc3
diff --git a/public/src/client/topic/postTools.js b/public/src/client/topic/postTools.jsindex 3fa13e22e6..37f5e5d9cf 100644--- a/public/src/client/topic/postTools.js+++ b/public/src/client/topic/postTools.js@@ -199,13 +199,23 @@ define('forum/topic/postTools', ['share', 'navigator', 'components', 'translatorif (!proceed) {var selectionText = '';var selection = window.getSelection ? window.getSelection() : document.selection.createRange();- var selectionNode = $(selection.baseNode || selection.anchorNode);-- if (selectionNode.parents('[component="post/content"]').length > 0) {- selectionText = selection.toString();+ var content = button.parents('[component="post"]').find('[component="post/content"]').get(0);++ if (selection.containsNode(content, true)) {+ var bounds = document.createRange();+ bounds.selectNodeContents(content);+ var range = selection.getRangeAt(0).cloneRange();+ if (range.compareBoundaryPoints(Range.START_TO_START, bounds) < 0) {+ range.setStart(bounds.startContainer, bounds.startOffset);+ }+ if (range.compareBoundaryPoints(Range.END_TO_END, bounds) > 0) {+ range.setEnd(bounds.endContainer, bounds.endOffset);+ }+ bounds.detach();+ selectionText = range.toString();+ range.detach();}- button = selectionText ? selectionNode : button;var username = getUserName(button);if (getData(button, 'data-uid') === '0' || !getData(button, 'data-userslug')) {username = '';