kopia lustrzana https://github.com/c9/core
use new clipboard api when available
rodzic
eb35256497
commit
e5274f29a2
|
@ -2631,10 +2631,10 @@
|
||||||
});
|
});
|
||||||
plugin.on("paste", function(e) {
|
plugin.on("paste", function(e) {
|
||||||
if (e.native) return; // Ace handles this herself
|
if (e.native) return; // Ace handles this herself
|
||||||
|
e.clipboardData.getData("text/plain", function(err, data) {
|
||||||
var data = e.clipboardData.getData("text/plain");
|
if (!err && data && data !== false)
|
||||||
if (data !== false)
|
ace.onPaste(data);
|
||||||
ace.onPaste(data);
|
});
|
||||||
});
|
});
|
||||||
plugin.on("blur", function() {
|
plugin.on("blur", function() {
|
||||||
blur();
|
blur();
|
||||||
|
|
|
@ -124,6 +124,15 @@ define(function(require, exports, module) {
|
||||||
getData: function(type, callback) {
|
getData: function(type, callback) {
|
||||||
var data = provider.get(type);
|
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.
|
// 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.
|
// 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.
|
// 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'>"
|
+ "textarea below. <textarea style='width:100%;' rows='4'>"
|
||||||
+ data
|
+ data
|
||||||
+ "</textarea><br /><br />")
|
+ "</textarea><br /><br />")
|
||||||
+ "To enable the native keyboard either use "
|
+ "To enable the native keyboard use Command-C on Mac or Ctrl-C on Windows<br />"
|
||||||
+ "Command-C on Mac or Ctrl-C on Windows or for Chrome install "
|
+ (navigator.clipboard ? " or grant clipboard access to the page" : ""),
|
||||||
+ "the Cloud9 App at <a target='_blank' href='http://bit.ly/K5XNzK'>the Chrome store</a>.",
|
|
||||||
function() {
|
function() {
|
||||||
if (alert.dontShow)
|
if (alert.dontShow)
|
||||||
settings.set("user/clipboard/@dontshow", true);
|
settings.set("user/clipboard/@dontshow", true);
|
||||||
|
|
|
@ -84,6 +84,9 @@ define(function(require, exports, module) {
|
||||||
if (!full && nativeObject)
|
if (!full && nativeObject)
|
||||||
return handleClipboardData(nativeObject, type);
|
return handleClipboardData(nativeObject, type);
|
||||||
|
|
||||||
|
if (navigator.clipboard && navigator.clipboard.readText)
|
||||||
|
return navigator.clipboard.readText();
|
||||||
|
|
||||||
var data;
|
var data;
|
||||||
var getData = function(e) {
|
var getData = function(e) {
|
||||||
data = full
|
data = full
|
||||||
|
|
|
@ -1167,9 +1167,10 @@ define(function(require, exports, module) {
|
||||||
plugin.on("paste", function(e) {
|
plugin.on("paste", function(e) {
|
||||||
if (e.native) return; // Ace handles this herself
|
if (e.native) return; // Ace handles this herself
|
||||||
|
|
||||||
var data = e.clipboardData.getData("text/plain");
|
e.clipboardData.getData("text/plain", function(err, data) {
|
||||||
if (data !== false)
|
if (!err && data && data !== false)
|
||||||
aceterm.onPaste(data);
|
aceterm.onPaste(data);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
plugin.on("focus", function(e) {
|
plugin.on("focus", function(e) {
|
||||||
|
|
Ładowanie…
Reference in New Issue