From 69773c2611c4aeb40727e00d6055c899ada3aa1a Mon Sep 17 00:00:00 2001 From: David Russell Date: Sun, 15 Jan 2017 19:15:52 +0700 Subject: [PATCH] Added support for user selection of code block content for copy/paste. --- .../views/frags/SlideshowReveal.scala.html | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/app/com/gitpitch/views/frags/SlideshowReveal.scala.html b/app/com/gitpitch/views/frags/SlideshowReveal.scala.html index 5259c40..4d4451d 100644 --- a/app/com/gitpitch/views/frags/SlideshowReveal.scala.html +++ b/app/com/gitpitch/views/frags/SlideshowReveal.scala.html @@ -34,4 +34,26 @@ } ] }); + + Reveal.configure({ + keyboard: { + 83: function() { // bind "s" key to "select" code block content + + var currentSlide = Reveal.getCurrentSlide(); + var preBlock = $(currentSlide).find("pre"); + + if(preBlock.length > 0) { + + if (window.getSelection) { + var range = document.createRange(); + range.selectNodeContents(preBlock[0]); + var selection = window.getSelection(); + selection.removeAllRanges(); + selection.addRange(range); + } + } + } + } + }); +