From 93d4a199722de236005bc1c44c71d5809b30911c Mon Sep 17 00:00:00 2001 From: Richard Hepburn Date: Tue, 17 Dec 2013 11:29:04 -0500 Subject: [PATCH] Added TypeScript Definition files for Html2Canvas Added TypeScript Definition files for Html2Canvas - a library for taking screenshots of a browser window. --- README.md | 1 + html2canvas/html2canvas-tests.ts | 7 ++++ html2canvas/html2canvas.d.ts | 66 ++++++++++++++++++++++++++++++++ 3 files changed, 74 insertions(+) create mode 100644 html2canvas/html2canvas-tests.ts create mode 100644 html2canvas/html2canvas.d.ts diff --git a/README.md b/README.md index 7e305efe3..4613bb106 100755 --- a/README.md +++ b/README.md @@ -97,6 +97,7 @@ List of Definitions * [Highcharts](http://www.highcharts.com/) (by [damianog](https://github.com/damianog)) * [highlight.js](https://github.com/isagalaev/highlight.js) (by [Niklas Mollenhauer](https://github.com/nikeee)) * [History.js](https://github.com/browserstate/history.js) (by [Boris Yankov](https://github.com/borisyankov)) +* [Html2Canvas.js](https://github.com/niklasvh/html2canvas/) (by [Richard Hepburn](https://github.com/rwhepburn)) * [Humane.js](http://wavded.github.com/humane-js/) (by [John Vrbanac](https://github.com/jmvrbanac)) * [i18next](http://i18next.com/) (by [Maarten Docter](https://github.com/mdocter)) * [iCheck](http://damirfoy.com/iCheck/) (by [Dániel Tar](https://github.com/qcz)) diff --git a/html2canvas/html2canvas-tests.ts b/html2canvas/html2canvas-tests.ts new file mode 100644 index 000000000..389e3f286 --- /dev/null +++ b/html2canvas/html2canvas-tests.ts @@ -0,0 +1,7 @@ +/// + +var element: HTMLElement; + +html2canvas(element); +html2canvas(element, {}); + diff --git a/html2canvas/html2canvas.d.ts b/html2canvas/html2canvas.d.ts new file mode 100644 index 000000000..689421971 --- /dev/null +++ b/html2canvas/html2canvas.d.ts @@ -0,0 +1,66 @@ +// Type definitions for html2canvas.js v0.4.1 +// Project: https://github.com/niklasvh/html2canvas +// Definitions by: Richard Hepburn +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +/// + +declare module Html2Canvas { + interface Html2CanvasOptions { + /** Whether to allow cross-origin images to taint the canvas */ + allowTaint?: boolean; + + /** Canvas background color, if none is specified in DOM. Set undefined for transparent */ + background?: string; + + /** Define the heigt of the canvas in pixels. If null, renders with full height of the window. */ + height?: number; + + /** Whether to render each letter seperately. Necessary if letter-spacing is used. */ + letterRendering?: boolean; + + /** Whether to log events in the console. */ + logging?: boolean; + + /** Url to the proxy which is to be used for loading cross-origin images. If left empty, cross-origin images won't be loaded. */ + proxy?: string; + + /** Whether to test each image if it taints the canvas before drawing them */ + taintTest?: boolean; + + /** Timeout for loading images, in milliseconds. Setting it to 0 will result in no timeout. */ + timeout?: number; + + /** Define the width of the canvas in pixels. If null, renders with full width of the window. */ + width?: number; + + /** Whether to attempt to load cross-origin images as CORS served, before reverting back to proxy. */ + useCORS?: boolean; + + } +} + +interface Html2CanvasStatic { + + /** + * Renders an HTML element to a canvas so that a screenshot can be generated. + * + * The screenshot is based on the DOM and as such may not be 100% accurate to the real representation as it does not make an actual screenshot, + * but builds the screenshot based on the information available on the page. + * + * @param {HTMLElement} element The HTML element which will be rendered to the canvas. Use the root element to render the entire window. + */ + (element: HTMLElement): void; + /** + * Renders an HTML element to a canvas so that a screenshot can be generated. + * + * The screenshot is based on the DOM and as such may not be 100% accurate to the real representation as it does not make an actual screenshot, + * but builds the screenshot based on the information available on the page. + * + * @param {HTMLElement} element The HTML element which will be rendered to the canvas. Use the root element to render the entire window. + * @param {Html2CanvasOptions} options The options object that controls how the element will be rendered. + */ + (element: HTMLElement, options: Html2Canvas.Html2CanvasOptions): void; +} + +declare var html2canvas: Html2CanvasStatic;