]> _ Git - fluidbook-toolbox.git/commitdiff
wait #6003 @0.5
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Wed, 7 Jun 2023 14:32:54 +0000 (16:32 +0200)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Wed, 7 Jun 2023 14:32:54 +0000 (16:32 +0200)
resources/linkeditor/js/linkeditor.clipboard.js
resources/linkeditor/js/linkeditor.utils.js

index f624f284346d3a03a7d8ca5c039c1a4f48b5e85a..2bdd603b375017c5571f5f8e17d7f66cfe57b334 100644 (file)
@@ -1,6 +1,7 @@
 function LinkeditorClipboard(linkeditor) {
     this.linkeditor = linkeditor;
     this.content = '';
+    this.blocked = true;
     this._isEmpty = true;
 
     this.init();
@@ -8,25 +9,46 @@ function LinkeditorClipboard(linkeditor) {
 
 LinkeditorClipboard.prototype = {
     init: function () {
-        if (!this.enabled()) {
+        let $this = this;
+        if (!this.support()) {
+            return;
+        }
+        $(document).on('touchstart click', function () {
+            if (document.hasFocus()) {
+                $this.checkBlocked();
+            }
+            return true;
+        });
+
+    },
+
+    checkBlocked: function () {
+        if (!this.blocked) {
             return;
         }
         let $this = this;
+        this.get(function (c) {
+        }, true);
     },
 
     enabled: function () {
-        return !this.linkeditor.utils.isFirefox();
+        return !this.blocked && this.support();
+    },
+
+    support: function () {
+        return this.linkeditor.utils.isWindows() && !this.linkeditor.utils.isFirefox();
     },
 
     empty: function () {
         this.set('');
     },
 
-    get: function (callback) {
+    get: function (callback, force) {
         let $this = this;
-        if (this.enabled()) {
+        if (force || this.enabled()) {
             navigator.clipboard.read()
                 .then(items => {
+                    $this.blocked = false;
                     items[0].getType('text/html')
                         .then(blob => {
                             blob.text()
index 36890b479077314ec9bd3a02d405fa769feec689..7995da4332959f33ead752a691634f251af27bda 100644 (file)
@@ -151,6 +151,14 @@ LinkeditorUtils.prototype = {
     isFirefox: function () {
         return navigator.userAgent.search("Firefox") >= 0;
     },
+
+    isSafari: function () {
+        return /^((?!chrome|android).)*safari/i.test(navigator.userAgent);
+    },
+
+    isWindows: function () {
+        return navigator.userAgent.search('Windows') >= 0;
+    }
 };
 
 module.exports = LinkeditorUtils;