mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 09:48:58 -04:00
[console] Replace zeroclipboard with native copy (#10639)
This commit is contained in:
parent
e48a1a9740
commit
15ee0f05ac
5 changed files with 19 additions and 2646 deletions
|
@ -201,20 +201,3 @@ sense-help-example {
|
|||
.ui-resizable-e.active {
|
||||
background-color: rgba(194, 193, 208, 100);
|
||||
}
|
||||
|
||||
/** COPIED FROM BOOTSTRAP, MODIFIED SELECTORS **/
|
||||
.dropdown-menu li > a.zeroclipboard-is-hover,
|
||||
.dropdown-menu li > a.zeroclipboard-is-active {
|
||||
color: #FFF;
|
||||
text-decoration: none;
|
||||
background-color: #0081C2;
|
||||
background-image: -moz-linear-gradient(top, #08c, #0077b3);
|
||||
background-image: -webkit-gradient(linear, 0 0, 0 100%, from(#08C), to(#0077B3));
|
||||
background-image: -webkit-linear-gradient(top, #08C, #0077B3);
|
||||
background-image: -o-linear-gradient(top, #08c, #0077b3);
|
||||
background-image: linear-gradient(to bottom, #08C, #0077B3);
|
||||
background-repeat: repeat-x;
|
||||
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ff0088cc', endColorstr='#ff0077b3', GradientType=0);
|
||||
}
|
||||
|
||||
/** END COPIED **/
|
||||
|
|
|
@ -1,11 +1,9 @@
|
|||
let $ = require('jquery');
|
||||
let ZeroClipboard = require('zeroclip');
|
||||
require('ace');
|
||||
require('ace/ext-searchbox');
|
||||
let Autocomplete = require('./autocomplete');
|
||||
let SenseEditor = require('./sense_editor/editor');
|
||||
let settings = require('./settings');
|
||||
let storage = require('./storage');
|
||||
let utils = require('./utils');
|
||||
let es = require('./es');
|
||||
let history = require('./history');
|
||||
|
@ -48,46 +46,32 @@ export function initializeInput($el, $actionsEl, $copyAsCurlEl, output) {
|
|||
|
||||
/**
|
||||
* COPY AS CURL
|
||||
*
|
||||
* Since the copy functionality is powered by a flash movie (via ZeroClipboard)
|
||||
* the only way to trigger the copy is with a litteral mouseclick from the user.
|
||||
*
|
||||
* The original shortcut will now just open the menu and highlight the
|
||||
*
|
||||
*/
|
||||
(function setupZeroClipboard() {
|
||||
var zc = new ZeroClipboard($copyAsCurlEl); // the ZeroClipboard instance
|
||||
|
||||
zc.on('wrongflash noflash', function () {
|
||||
if (!storage.get('flash_warning_shown')) {
|
||||
alert('Console needs flash version 10.0 or greater in order to provide "Copy as cURL" functionality');
|
||||
storage.set('flash_warning_shown', 'true');
|
||||
(function setupClipboard() {
|
||||
function copyText(text) {
|
||||
var node = $(`<textarea style="height:1px"></textarea`)
|
||||
.val(text)
|
||||
.appendTo(document.body)
|
||||
.select();
|
||||
document.execCommand('copy');
|
||||
node.remove()
|
||||
}
|
||||
$copyAsCurlEl.hide();
|
||||
});
|
||||
|
||||
zc.on('ready', function () {
|
||||
function setupCopyButton(cb) {
|
||||
cb = typeof cb === 'function' ? cb : $.noop;
|
||||
$copyAsCurlEl.css('visibility', 'hidden');
|
||||
input.getRequestsAsCURL(function (curl) {
|
||||
$copyAsCurlEl.attr('data-clipboard-text', curl);
|
||||
$copyAsCurlEl.css('visibility', 'visible');
|
||||
cb();
|
||||
});
|
||||
if (!document.queryCommandSupported('copy')) {
|
||||
$copyAsCurlEl.hide();
|
||||
return;
|
||||
}
|
||||
|
||||
$copyAsCurlEl.click(() => {
|
||||
copyText($copyAsCurlEl.attr('data-clipboard-text'))
|
||||
});
|
||||
|
||||
input.$actions.on('mouseenter', function () {
|
||||
if (!$(this).hasClass('open')) {
|
||||
setupCopyButton();
|
||||
}
|
||||
if ($(this).hasClass('open')) return;
|
||||
input.getRequestsAsCURL(text => {
|
||||
$copyAsCurlEl.attr('data-clipboard-text', text);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
zc.on('complete', function () {
|
||||
$copyAsCurlEl.click();
|
||||
input.focus();
|
||||
});
|
||||
}());
|
||||
|
||||
/**
|
||||
|
|
File diff suppressed because it is too large
Load diff
Binary file not shown.
|
@ -1,8 +0,0 @@
|
|||
var ZeroClipboard = require('./zero_clipboard.js');
|
||||
|
||||
ZeroClipboard.config({
|
||||
swfPath: require('file!./zero_clipboard.swf'),
|
||||
debug: false
|
||||
});
|
||||
|
||||
module.exports = ZeroClipboard;
|
Loading…
Add table
Add a link
Reference in a new issue