|
diff --git a/src/sidebar/components/share-dialog.js b/src/sidebar/components/share-dialog.js |
|
index 652d1b8d..534597e4 100644 |
|
--- a/src/sidebar/components/share-dialog.js |
|
+++ b/src/sidebar/components/share-dialog.js |
|
@@ -2,6 +2,21 @@ |
|
|
|
var VIA_PREFIX = 'https://via.hypothes.is/'; |
|
|
|
+function copyToClipboard(text) { |
|
+ // Temporarily add a hidden input element and populate it with the text we |
|
+ // want to copy. |
|
+ var inputEl = document.createElement('textarea'); |
|
+ document.body.appendChild(inputEl); |
|
+ inputEl.textContent = text; |
|
+ inputEl.focus(); |
|
+ inputEl.selectionStart = 0; |
|
+ inputEl.selectionEnd = text.length; |
|
+ |
|
+ document.execCommand('copy'); |
|
+ |
|
+ inputEl.remove(); |
|
+} |
|
+ |
|
// @ngInject |
|
function ShareDialogController($scope, $element, analytics, annotationUI) { |
|
var self = this; |
|
@@ -32,6 +47,13 @@ function ShareDialogController($scope, $element, analytics, annotationUI) { |
|
analytics.track(analytics.events.DOCUMENT_SHARED, target); |
|
} |
|
}; |
|
+ |
|
+ $scope.copyAnnotations = function () { |
|
+ var annotations = annotationUI.getState().annotations; |
|
+ var content = annotations.map(ann => ann.text).join('\n\n'); |
|
+ |
|
+ copyToClipboard(content); |
|
+ }; |
|
} |
|
|
|
module.exports = { |
|
diff --git a/src/sidebar/templates/share-dialog.html b/src/sidebar/templates/share-dialog.html |
|
index 1bf4438c..af497bd7 100644 |
|
--- a/src/sidebar/templates/share-dialog.html |
|
+++ b/src/sidebar/templates/share-dialog.html |
|
@@ -35,6 +35,7 @@ |
|
class="share-link-icon h-icon-mail" |
|
ng-click="onShareClick('email')"></a> |
|
</p> |
|
+ <button ng-click="copyAnnotations()">Copy annotations</button> |
|
</div> |
|
</div> |
|
</div> |