mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-12-06 13:11:46 +00:00
Merge pull request #12413 from WatchBeam/types-2.0
Treat clipboard as a module
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
|
||||
import * as Clipboard from 'clipboard';
|
||||
|
||||
var cb1 = new Clipboard('.btn');
|
||||
var cb2 = new Clipboard(document.getElementById('id'), {
|
||||
|
||||
Vendored
+50
-48
@@ -3,54 +3,56 @@
|
||||
// Definitions by: Andrei Kurosh <https://github.com/impworks>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
declare class Clipboard {
|
||||
constructor(selector: (string | Element | NodeListOf<Element>), options?: ClipboardOptions);
|
||||
|
||||
/**
|
||||
* Subscribes to events that indicate the result of a copy/cut operation.
|
||||
* @param type {String} Event type ('success' or 'error').
|
||||
* @param handler Callback function.
|
||||
*/
|
||||
on(type: "success", handler: (e: ClipboardEvent) => void): this;
|
||||
on(type: "error", handler: (e: ClipboardEvent) => void): this;
|
||||
on(type: string, handler: (e: ClipboardEvent) => void): this;
|
||||
|
||||
/**
|
||||
* Clears all event bindings.
|
||||
*/
|
||||
destroy(): void;
|
||||
}
|
||||
|
||||
interface ClipboardOptions {
|
||||
/**
|
||||
* Overwrites default command ('cut' or 'copy').
|
||||
* @param {Element} elem Current element
|
||||
* @returns {String} Only 'cut' or 'copy'.
|
||||
*/
|
||||
action?: (elem: Element) => string;
|
||||
|
||||
/**
|
||||
* Overwrites default target input element.
|
||||
* @param {Element} elem Current element
|
||||
* @returns {Element} <input> element to use.
|
||||
*/
|
||||
target?: (elem: Element) => Element;
|
||||
|
||||
/**
|
||||
* Returns the explicit text to copy.
|
||||
* @param {Element} elem Current element
|
||||
* @returns {String} Text to be copied.
|
||||
*/
|
||||
text?: (elem: Element) => string;
|
||||
}
|
||||
|
||||
interface ClipboardEvent {
|
||||
action: string;
|
||||
text: string;
|
||||
trigger: Element;
|
||||
clearSelection(): void;
|
||||
}
|
||||
|
||||
declare module 'clipboard' {
|
||||
class Clipboard {
|
||||
constructor(selector: (string | Element | NodeListOf<Element>), options?: Clipboard.Options);
|
||||
|
||||
/**
|
||||
* Subscribes to events that indicate the result of a copy/cut operation.
|
||||
* @param type {String} Event type ('success' or 'error').
|
||||
* @param handler Callback function.
|
||||
*/
|
||||
on(type: "success", handler: (e: Clipboard.Event) => void): this;
|
||||
on(type: "error", handler: (e: Clipboard.Event) => void): this;
|
||||
on(type: string, handler: (e: Clipboard.Event) => void): this;
|
||||
|
||||
/**
|
||||
* Clears all event bindings.
|
||||
*/
|
||||
destroy(): void;
|
||||
}
|
||||
|
||||
namespace Clipboard {
|
||||
interface Options {
|
||||
/**
|
||||
* Overwrites default command ('cut' or 'copy').
|
||||
* @param {Element} elem Current element
|
||||
* @returns {String} Only 'cut' or 'copy'.
|
||||
*/
|
||||
action?: (elem: Element) => string;
|
||||
|
||||
/**
|
||||
* Overwrites default target input element.
|
||||
* @param {Element} elem Current element
|
||||
* @returns {Element} <input> element to use.
|
||||
*/
|
||||
target?: (elem: Element) => Element;
|
||||
|
||||
/**
|
||||
* Returns the explicit text to copy.
|
||||
* @param {Element} elem Current element
|
||||
* @returns {String} Text to be copied.
|
||||
*/
|
||||
text?: (elem: Element) => string;
|
||||
}
|
||||
|
||||
interface Event {
|
||||
action: string;
|
||||
text: string;
|
||||
trigger: Element;
|
||||
clearSelection(): void;
|
||||
}
|
||||
}
|
||||
|
||||
export = Clipboard;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user