Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Export more types to enhance TypeScript support #443

Merged
merged 4 commits into from
Dec 5, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
75 changes: 39 additions & 36 deletions dist/pptxgen.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,57 +5,83 @@
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.3

export as namespace PptxGenJS;

export = PptxGenJS;

declare class PptxGenJS {
// Presentation Props
getLayout(): string;
setBrowser(isBrowser: boolean): void;
setLayout(layout: PptxGenJS.LayoutName | PptxGenJS.Layout): void;
setRTL(isRTL: boolean): void;

// Presentation Metadata
setAuthor(author: string): void;
setCompany(company: string): void;
setRevision(revision: string): void;
setSubject(subject: string): void;
setTitle(title: string): void;

// Add a new Slide
addNewSlide(masterLayoutName?: string): PptxGenJS.Slide;
defineSlideMaster(opts: PptxGenJS.MasterSlideOptions): void;

// Export
save(exportFileName: string, callbackFunction?: Function, zipOutputType?: PptxGenJS.JsZipOutputType): void;
}

declare namespace PptxGenJS {
const version: string;
type ChartType = "AREA" | "BAR" | "BUBBLE" | "DOUGHNUT" | "LINE" | "PIE" | "RADAR" | "SCATTER";
type JsZipOutputType = "arraybuffer" | "base64" | "binarystring" | "blob" | "nodebuffer" | "uint8array";
type LayoutName = "LAYOUT_4x3" | "LAYOUT_16x9" | "LAYOUT_16x10" | "LAYOUT_WIDE";
interface Layout {
export type ChartType = "AREA" | "BAR" | "BUBBLE" | "DOUGHNUT" | "LINE" | "PIE" | "RADAR" | "SCATTER";
export type JsZipOutputType = "arraybuffer" | "base64" | "binarystring" | "blob" | "nodebuffer" | "uint8array";
export type LayoutName = "LAYOUT_4x3" | "LAYOUT_16x9" | "LAYOUT_16x10" | "LAYOUT_WIDE";
export interface Layout {
name: string;
width: number;
height: number;
}
type Color = string;
type Coord = number | string; // string is in form 'n%'
export type Color = string;
export type Coord = number | string; // string is in form 'n%'

interface CommonOptions {
export interface CommonOptions {
x?: Coord;
y?: Coord;
w?: Coord;
h?: Coord;
}
interface DataOrPath {
export interface DataOrPath {
// Exactly one must be set
data?: string;
path?: string;
}
interface ImageOptions extends CommonOptions, DataOrPath {
export interface ImageOptions extends CommonOptions, DataOrPath {
hyperlink?: string;
rounding?: boolean;
sizing?: "cover" | "contain" | "crop";
}

interface MediaOptions extends CommonOptions, DataOrPath {
export interface MediaOptions extends CommonOptions, DataOrPath {
onlineVideoLink?: string;
type?: "audio" | "online" | "video";
}

interface TextOptions extends CommonOptions, DataOrPath {
export interface TextOptions extends CommonOptions, DataOrPath {
align?: "left" | "center" | "right";
fontSize?: number;
color?: string;
valign?: "top" | "middle" | "bottom";
}

interface MasterSlideOptions {
export interface MasterSlideOptions {
title: string;
bkgd?: string | DataOrPath;
objects?: object[];
slideNumber?: {x?: Coord, y?: Coord, color?: Color};
margin?: number | number[];
}

class Slide {
export class Slide {
// Slide Number methods
getPageNumber(): string;
slideNumber(): object;
Expand All @@ -71,27 +97,4 @@ declare namespace PptxGenJS {
addText(textString: string, options: TextOptions): Slide;
}

class PptxGenJS {
// Presentation Props
getLayout(): string;
setBrowser(isBrowser: boolean): void;
setLayout(layout: LayoutName | Layout): void;
setRTL(isRTL: boolean): void;

// Presentation Metadata
setAuthor(author: string): void;
setCompany(company: string): void;
setRevision(revision: string): void;
setSubject(subject: string): void;
setTitle(title: string): void;

// Add a new Slide
addNewSlide(masterLayoutName?: string): Slide;
defineSlideMaster(opts: MasterSlideOptions): void;

// Export
save(exportFileName: string, callbackFunction?: Function, zipOutputType?: JsZipOutputType): void;
}
}

export = PptxGenJS.PptxGenJS;