function LinkeditorClipboard(linkeditor) {
this.linkeditor = linkeditor;
this.content = '';
+ this.blocked = true;
this._isEmpty = true;
this.init();
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()
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;