use new clipboard api when available

pull/512/head
nightwing 2018-06-23 00:59:37 +04:00
rodzic eb35256497
commit e5274f29a2
4 zmienionych plików z 22 dodań i 10 usunięć

Wyświetl plik

@ -2631,10 +2631,10 @@
});
plugin.on("paste", function(e) {
if (e.native) return; // Ace handles this herself
var data = e.clipboardData.getData("text/plain");
if (data !== false)
ace.onPaste(data);
e.clipboardData.getData("text/plain", function(err, data) {
if (!err && data && data !== false)
ace.onPaste(data);
});
});
plugin.on("blur", function() {
blur();

Wyświetl plik

@ -124,6 +124,15 @@ define(function(require, exports, module) {
getData: function(type, callback) {
var data = provider.get(type);
if (callback && data && data.then) {
return data.then(function(text) {
callback(null, text);
}, function(err) {
showAlert(null, true);
callback(err || new Error("rejected"));
});
}
// If `data` is false the provider was not able to fetch data from the clipboard.
// This is usually because the browser does not allow this for security reasons.
// The browser (chrome) does allow this when the cloud9 plugin is installed.
@ -255,9 +264,8 @@ define(function(require, exports, module) {
+ "textarea below. <textarea style='width:100%;' rows='4'>"
+ data
+ "</textarea><br /><br />")
+ "To enable the native keyboard either use "
+ "Command-C on Mac or Ctrl-C on Windows or for Chrome install "
+ "the Cloud9 App at <a target='_blank' href='http://bit.ly/K5XNzK'>the Chrome store</a>.",
+ "To enable the native keyboard use Command-C on Mac or Ctrl-C on Windows<br />"
+ (navigator.clipboard ? " or grant clipboard access to the page" : ""),
function() {
if (alert.dontShow)
settings.set("user/clipboard/@dontshow", true);

Wyświetl plik

@ -84,6 +84,9 @@ define(function(require, exports, module) {
if (!full && nativeObject)
return handleClipboardData(nativeObject, type);
if (navigator.clipboard && navigator.clipboard.readText)
return navigator.clipboard.readText();
var data;
var getData = function(e) {
data = full

Wyświetl plik

@ -1167,9 +1167,10 @@ define(function(require, exports, module) {
plugin.on("paste", function(e) {
if (e.native) return; // Ace handles this herself
var data = e.clipboardData.getData("text/plain");
if (data !== false)
aceterm.onPaste(data);
e.clipboardData.getData("text/plain", function(err, data) {
if (!err && data && data !== false)
aceterm.onPaste(data);
});
});
plugin.on("focus", function(e) {